TrinityCore
Loading...
Searching...
No Matches
PetitionsHandler.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "WorldSession.h"
19#include "ArenaTeam.h"
20#include "ArenaTeamMgr.h"
21#include "CharacterCache.h"
22#include "Common.h"
23#include "Creature.h"
24#include "DatabaseEnv.h"
25#include "Guild.h"
26#include "GuildMgr.h"
27#include "Item.h"
28#include "Log.h"
29#include "ObjectAccessor.h"
30#include "ObjectMgr.h"
31#include "Opcodes.h"
32#include "Player.h"
33#include "PetitionMgr.h"
34#include "WorldPacket.h"
35#include "World.h"
36
37#define CHARTER_DISPLAY_ID 16161
38
39// Charters ID in item_template
47
49{
50 TC_LOG_DEBUG("network", "Received opcode CMSG_PETITION_BUY");
51
52 ObjectGuid guidNPC;
53 uint32 clientIndex; // 1 for guild and arenaslot+1 for arenas in client
54 std::string name;
55
56 recvData >> guidNPC; // NPC GUID
57 recvData.read_skip<uint32>(); // 0
58 recvData.read_skip<uint64>(); // 0
59 recvData >> name; // name
60 recvData.read_skip<std::string>(); // some string
61 recvData.read_skip<uint32>(); // 0
62 recvData.read_skip<uint32>(); // 0
63 recvData.read_skip<uint32>(); // 0
64 recvData.read_skip<uint32>(); // 0
65 recvData.read_skip<uint32>(); // 0
66 recvData.read_skip<uint32>(); // 0
67 recvData.read_skip<uint32>(); // 0
68 recvData.read_skip<uint16>(); // 0
69 recvData.read_skip<uint32>(); // 0
70 recvData.read_skip<uint32>(); // 0
71 recvData.read_skip<uint32>(); // 0
72
73 for (int i = 0; i < 10; ++i)
74 recvData.read_skip<std::string>();
75
76 recvData >> clientIndex; // index
77 recvData.read_skip<uint32>(); // 0
78
79 TC_LOG_DEBUG("network", "Petitioner {} tried sell petition: name {}", guidNPC.ToString(), name);
80
81 // prevent cheating
83 if (!creature)
84 {
85 TC_LOG_DEBUG("network", "WORLD: HandlePetitionBuyOpcode - {} not found or you can't interact with him.", guidNPC.ToString());
86 return;
87 }
88
89 // remove fake death
90 if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
92
93 uint32 charterid = 0;
94 uint32 cost = 0;
96 if (creature->IsTabardDesigner())
97 {
98 // if tabard designer, then trying to buy a guild charter.
99 // do not let if already in guild.
100 if (_player->GetGuildId())
101 return;
102
103 charterid = GUILD_CHARTER;
104 cost = sWorld->getIntConfig(CONFIG_CHARTER_COST_GUILD);
105 type = GUILD_CHARTER_TYPE;
106 }
107 else
108 {
110 if (!_player->IsMaxLevel())
111 {
113 return;
114 }
115
116 switch (clientIndex) // arenaSlot+1 as received from client (1 from 3 case)
117 {
118 case 1:
119 charterid = ARENA_TEAM_CHARTER_2v2;
120 cost = sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_2v2);
122 break;
123 case 2:
124 charterid = ARENA_TEAM_CHARTER_3v3;
125 cost = sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_3v3);
127 break;
128 case 3:
129 charterid = ARENA_TEAM_CHARTER_5v5;
130 cost = sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_5v5);
132 break;
133 default:
134 TC_LOG_DEBUG("network", "unknown selection at buy arena petition: {}", clientIndex);
135 return;
136 }
137
138 if (_player->GetArenaTeamId(clientIndex - 1)) // arenaSlot+1 as received from client
139 {
141 return;
142 }
143 }
144
145 if (type == GUILD_CHARTER_TYPE)
146 {
147 if (sGuildMgr->GetGuildByName(name))
148 {
150 return;
151 }
152
153 if (sObjectMgr->IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
154 {
156 return;
157 }
158 }
159 else
160 {
161 if (sArenaTeamMgr->GetArenaTeamByName(name))
162 {
164 return;
165 }
166 if (sObjectMgr->IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
167 {
169 return;
170 }
171 }
172
173 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(charterid);
174 if (!pProto)
175 {
176 _player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, charterid, 0);
177 return;
178 }
179
180 if (!_player->HasEnoughMoney(cost))
181 { //player hasn't got enough money
182 _player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, charterid, 0);
183 return;
184 }
185
186 ItemPosCountVec dest;
187 InventoryResult msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, charterid, pProto->BuyCount);
188 if (msg != EQUIP_ERR_OK)
189 {
190 _player->SendEquipError(msg, nullptr, nullptr, charterid);
191 return;
192 }
193
194 _player->ModifyMoney(-(int32)cost);
195 Item* charter = _player->StoreNewItem(dest, charterid, true);
196 if (!charter)
197 return;
198
200 // ITEM_FIELD_ENCHANTMENT_1_1 is guild/arenateam id
201 // ITEM_FIELD_ENCHANTMENT_1_1+1 is current signatures count (showed on item)
202 charter->SetState(ITEM_CHANGED, _player);
203 _player->SendNewItem(charter, 1, true, false);
204
205 // a petition is invalid, if both the owner and the type matches
206 // we checked above, if this player is in an arenateam, so this must be
207 // datacorruption
208 CharacterDatabase.EscapeString(name);
209 if (Petition const* petition = sPetitionMgr->GetPetitionByOwnerWithType(_player->GetGUID(), type))
210 {
211 // clear from petition store
212 sPetitionMgr->RemovePetition(petition->PetitionGuid);
213 TC_LOG_DEBUG("network", "Invalid petition {}", petition->PetitionGuid.ToString());
214 }
215
216 // fill petition store
217 sPetitionMgr->AddPetition(charter->GetGUID(), _player->GetGUID(), name, type, false);
218}
219
221{
222 TC_LOG_DEBUG("network", "Received opcode CMSG_PETITION_SHOW_SIGNATURES");
223
224 ObjectGuid petitionGuid;
225 recvData >> petitionGuid; // petition guid
226
227 Petition const* petition = sPetitionMgr->GetPetition(petitionGuid);
228 if (!petition)
229 {
230 TC_LOG_DEBUG("entities.player.items", "Petition {} is not found for player {} {}", petitionGuid.ToString(), GetPlayer()->GetGUID().ToString(), GetPlayer()->GetName());
231 return;
232 }
233
234 // if guild petition and has guild => error, return;
235 if (petition->PetitionType == GUILD_CHARTER_TYPE && _player->GetGuildId())
236 return;
237
238 TC_LOG_DEBUG("network", "CMSG_PETITION_SHOW_SIGNATURES petition {}", petitionGuid.ToString());
239
240 SendPetitionSigns(petition, _player);
241}
242
243void WorldSession::SendPetitionSigns(Petition const* petition, Player* sendTo)
244{
245 SignaturesVector const& signatures = petition->Signatures;
246 WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + 1 + signatures.size() * 12));
247 data << petition->PetitionGuid; // petition guid
248 data << petition->OwnerGuid; // owner guid
249 data << uint32(petition->PetitionGuid.GetCounter()); // guild guid
250 data << uint8(signatures.size()); // sign's count
251
252 for (Signature const& signature : signatures)
253 {
254 data << signature.second; // Player GUID
255 data << uint32(0); // there 0 ...
256 }
257
258 sendTo->SendDirectMessage(&data);
259}
260
262{
263 TC_LOG_DEBUG("network", "Received opcode CMSG_PETITION_QUERY"); // ok
264
265 ObjectGuid::LowType guildguid;
266 ObjectGuid petitionguid;
267 recvData >> guildguid; // in Trinity always same as GUID_LOPART(petitionguid)
268 recvData >> petitionguid; // petition guid
269 TC_LOG_DEBUG("network", "CMSG_PETITION_QUERY Petition {} Guild GUID {}", petitionguid.ToString(), guildguid);
270
271 SendPetitionQueryOpcode(petitionguid);
272}
273
275{
276 Petition const* petition = sPetitionMgr->GetPetition(petitionguid);
277 if (!petition)
278 {
279 TC_LOG_DEBUG("network", "CMSG_PETITION_QUERY failed for petition ({})", petitionguid.ToString());
280 return;
281 }
282
283 WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4+8+petition->PetitionName.size()+1+1+4*12+2+10));
284 data << uint32(petitionguid.GetCounter()); // guild/team guid (in Trinity always same as GUID_LOPART(petition guid)
285 data << petition->OwnerGuid; // charter owner guid
286 data << petition->PetitionName; // name (guild/arena team)
287 data << uint8(0); // some string
288
289 CharterTypes type = petition->PetitionType;
290 if (type == GUILD_CHARTER_TYPE)
291 {
292 uint32 needed = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS);
293 data << uint32(needed);
294 data << uint32(needed);
295 data << uint32(0); // bypass client - side limitation, a different value is needed here for each petition
296 }
297 else
298 {
299 data << uint32(type-1);
300 data << uint32(type-1);
301 data << uint32(type); // bypass client - side limitation, a different value is needed here for each petition
302 }
303 data << uint32(0); // 5
304 data << uint32(0); // 6
305 data << uint32(0); // 7
306 data << uint32(0); // 8
307 data << uint16(0); // 9 2 bytes field
308 data << uint32(0); // 10
309 data << uint32(0); // 11
310 data << uint32(0); // 13 count of next strings?
311
312 for (int i = 0; i < 10; ++i)
313 data << uint8(0); // some string
314
315 data << uint32(0); // 14
316
317 data << uint32(type != GUILD_CHARTER_TYPE); // 15 0 - guild, 1 - arena team
318
319 SendPacket(&data);
320}
321
323{
324 TC_LOG_DEBUG("network", "Received opcode MSG_PETITION_RENAME");
325
326 ObjectGuid petitionGuid;
327 std::string newName;
328
329 recvData >> petitionGuid; // guid
330 recvData >> newName; // new name
331
332 Item* item = _player->GetItemByGuid(petitionGuid);
333 if (!item)
334 return;
335
336 Petition* petition = sPetitionMgr->GetPetition(petitionGuid);
337 if (!petition)
338 {
339 TC_LOG_DEBUG("network", "CMSG_PETITION_QUERY failed for petition {}", petitionGuid.ToString());
340 return;
341 }
342
343 CharterTypes type = petition->PetitionType;
344 if (type == GUILD_CHARTER_TYPE)
345 {
346 if (sGuildMgr->GetGuildByName(newName))
347 {
349 return;
350 }
351 if (sObjectMgr->IsReservedName(newName) || !ObjectMgr::IsValidCharterName(newName))
352 {
354 return;
355 }
356 }
357 else
358 {
359 if (sArenaTeamMgr->GetArenaTeamByName(newName))
360 {
362 return;
363 }
364 if (sObjectMgr->IsReservedName(newName) || !ObjectMgr::IsValidCharterName(newName))
365 {
367 return;
368 }
369 }
370
371 CharacterDatabase.EscapeString(newName);
372
373 // update petition storage
374 petition->UpdateName(newName);
375
376 TC_LOG_DEBUG("network", "Petition {} renamed to '{}'", petitionGuid.ToString(), newName);
377 WorldPacket data(MSG_PETITION_RENAME, (8 + newName.size() + 1));
378 data << petitionGuid;
379 data << newName;
380 SendPacket(&data);
381}
382
384{
385 TC_LOG_DEBUG("network", "Received opcode CMSG_PETITION_SIGN"); // ok
386
387 ObjectGuid petitionGuid;
388 uint8 unk;
389 recvData >> petitionGuid; // petition guid
390 recvData >> unk;
391
392 Petition* petition = sPetitionMgr->GetPetition(petitionGuid);
393 if (!petition)
394 {
395 TC_LOG_ERROR("network", "Petition {} is not found for player {} {}", petitionGuid.ToString(), GetPlayer()->GetGUID().ToString(), GetPlayer()->GetName());
396 return;
397 }
398
399 ObjectGuid ownerGuid = petition->OwnerGuid;
400 CharterTypes type = petition->PetitionType;
401 uint8 signs = uint8(petition->Signatures.size());
402
403 if (ownerGuid == _player->GetGUID())
404 return;
405
406 // not let enemies sign guild charter
407 if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != sCharacterCache->GetCharacterTeamByGuid(ownerGuid))
408 {
409 if (type != GUILD_CHARTER_TYPE)
411 else
413 return;
414 }
415
416 if (type != GUILD_CHARTER_TYPE)
417 {
418 if (!_player->IsMaxLevel())
419 {
421 return;
422 }
423
424 uint8 slot = ArenaTeam::GetSlotByType(static_cast<uint32>(type));
425 if (slot >= MAX_ARENA_SLOT)
426 return;
427
428 if (_player->GetArenaTeamId(slot))
429 {
431 return;
432 }
433
435 {
437 return;
438 }
439 }
440 else
441 {
442 if (_player->GetGuildId())
443 {
445 return;
446 }
448 {
450 return;
451 }
452 }
453
454 if (++signs > static_cast<uint8>(type)) // client signs maximum
455 return;
456
457 // Client doesn't allow to sign petition two times by one character, but not check sign by another character from same account
458 // not allow sign another player from already sign player account
459 bool isSigned = petition->IsPetitionSignedByAccount(GetAccountId());
460 if (isSigned)
461 {
463 data << petitionGuid;
464 data << _player->GetGUID();
466
467 // close at signer side
468 SendPacket(&data);
469
470 // update for owner if online
471 if (Player* owner = ObjectAccessor::FindConnectedPlayer(ownerGuid))
472 owner->SendDirectMessage(&data);
473 return;
474 }
475
476 // fill petition store
477 petition->AddSignature(GetAccountId(), _player->GetGUID(), false);
478
479 TC_LOG_DEBUG("network", "PETITION SIGN: {} by player: {} ({} Account: {})", petitionGuid.ToString(), _player->GetName(), _player->GetGUID().ToString(), GetAccountId());
480
482 data << petitionGuid;
483 data << _player->GetGUID();
484 data << uint32(PETITION_SIGN_OK);
485 SendPacket(&data);
486
487 // update for owner if online
488 if (Player* owner = ObjectAccessor::FindConnectedPlayer(ownerGuid))
489 owner->SendDirectMessage(&data);
490}
491
493{
494 TC_LOG_DEBUG("network", "Received opcode MSG_PETITION_DECLINE"); // ok
495
496 ObjectGuid petitionguid;
497 recvData >> petitionguid; // petition guid
498 TC_LOG_DEBUG("network", "Petition {} declined by {}", petitionguid.ToString(), _player->GetGUID().ToString());
499
500 Petition const* petition = sPetitionMgr->GetPetition(petitionguid);
501 if (!petition)
502 return;
503
504 // petition owner online
506 {
508 data << _player->GetGUID();
509 owner->SendDirectMessage(&data);
510 }
511}
512
514{
515 TC_LOG_DEBUG("network", "Received opcode CMSG_OFFER_PETITION"); // ok
516
517 ObjectGuid petitionGuid, offererGuid;
518 uint32 junk;
519 recvData >> junk; // this is not petition type!
520 recvData >> petitionGuid; // petition guid
521 recvData >> offererGuid; // player guid
522
523 Player* player = ObjectAccessor::FindConnectedPlayer(offererGuid);
524 if (!player)
525 return;
526
527 Petition const* petition = sPetitionMgr->GetPetition(petitionGuid);
528 if (!petition)
529 return;
530
531 CharterTypes type = petition->PetitionType;
532
533 TC_LOG_DEBUG("network", "OFFER PETITION: type {}, {}, to {}", static_cast<uint32>(type), petitionGuid.ToString(), offererGuid.ToString());
534
535 if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam())
536 {
537 if (type != GUILD_CHARTER_TYPE)
539 else
541 return;
542 }
543
544 if (type != GUILD_CHARTER_TYPE)
545 {
546 if (!player->IsMaxLevel())
547 {
548 // player is too low level to join an arena team
550 return;
551 }
552
553 uint8 slot = ArenaTeam::GetSlotByType(static_cast<uint32>(type));
554 if (slot >= MAX_ARENA_SLOT)
555 return;
556
557 if (player->GetArenaTeamId(slot))
558 {
559 // player is already in an arena team
561 return;
562 }
563
564 if (player->GetArenaTeamIdInvited())
565 {
567 return;
568 }
569 }
570 else
571 {
572 if (player->GetGuildId())
573 {
575 return;
576 }
577
578 if (player->GetGuildIdInvited())
579 {
581 return;
582 }
583 }
584
585 SendPetitionSigns(petition, player);
586}
587
589{
590 TC_LOG_DEBUG("network", "Received opcode CMSG_TURN_IN_PETITION");
591
592 // Get petition guid from packet
593 WorldPacket data;
594 ObjectGuid petitionGuid;
595
596 recvData >> petitionGuid;
597
598 // Check if player really has the required petition charter
599 Item* item = _player->GetItemByGuid(petitionGuid);
600 if (!item)
601 return;
602
603 TC_LOG_DEBUG("network", "Petition {} turned in by {}", petitionGuid.ToString(), _player->GetGUID().ToString());
604
605 Petition const* petition = sPetitionMgr->GetPetition(petitionGuid);
606 if (!petition)
607 {
608 TC_LOG_ERROR("entities.player.cheat", "Player {} {} tried to turn in petition ({}) that is not present in the database", _player->GetName(), _player->GetGUID().ToString(), petitionGuid.ToString());
609 return;
610 }
611
612 CharterTypes type = petition->PetitionType;
613 std::string const name = petition->PetitionName; // we need a copy, it will be removed on guild/arena remove
614
615 // Only the petition owner can turn in the petition
616 if (_player->GetGUID() != petition->OwnerGuid)
617 return;
618
619 // Petition type (guild/arena) specific checks
620 if (type == GUILD_CHARTER_TYPE)
621 {
622 // Check if player is already in a guild
623 if (_player->GetGuildId())
624 {
628 return;
629 }
630
631 // Check if guild name is already taken
632 if (sGuildMgr->GetGuildByName(name))
633 {
635 return;
636 }
637 }
638 else
639 {
640 // Check for valid arena bracket (2v2, 3v3, 5v5)
641 uint8 slot = ArenaTeam::GetSlotByType(static_cast<uint32>(type));
642 if (slot >= MAX_ARENA_SLOT)
643 return;
644
645 // Check if player is already in an arena team
646 if (_player->GetArenaTeamId(slot))
647 {
649 return;
650 }
651
652 // Check if arena team name is already taken
653 if (sArenaTeamMgr->GetArenaTeamByName(name))
654 {
656 return;
657 }
658 }
659
660 SignaturesVector const signatures = petition->Signatures; // we need a copy, it will be removed on guild/arena remove
661 uint32 requiredSignatures = static_cast<uint32>(type) - 1;
662 if (type == GUILD_CHARTER_TYPE)
663 requiredSignatures = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS);
664
665 // Notify player if signatures are missing
666 if (signatures.size() < requiredSignatures)
667 {
670 SendPacket(&data);
671 return;
672 }
673
674 // Proceed with guild/arena team creation
675
676 // Delete charter item
677 _player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
678
679 if (type == GUILD_CHARTER_TYPE)
680 {
681 // Create guild
682 Guild* guild = new Guild;
683
684 if (!guild->Create(_player, name))
685 {
686 delete guild;
687 return;
688 }
689
690 // Register guild and add guild master
691 sGuildMgr->AddGuild(guild);
692
694
695 {
696 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
697
698 // Add members from signatures
699 for (Signature const& signature : signatures)
700 guild->AddMember(trans, signature.second);
701
702 CharacterDatabase.CommitTransaction(trans);
703 }
704 }
705 else
706 {
707 // Receive the rest of the packet in arena team creation case
708 uint32 background, icon, iconcolor, border, bordercolor;
709 recvData >> background >> icon >> iconcolor >> border >> bordercolor;
710
711 // Create arena team
712 ArenaTeam* arenaTeam = new ArenaTeam();
713
714 if (!arenaTeam->Create(_player->GetGUID(), type, name, background, icon, iconcolor, border, bordercolor))
715 {
716 delete arenaTeam;
717 return;
718 }
719
720 // Register arena team
721 sArenaTeamMgr->AddArenaTeam(arenaTeam);
722 TC_LOG_DEBUG("network", "PetitonsHandler: Arena team (guid: {}) added to ObjectMgr", arenaTeam->GetId());
723
724 // Add members
725 for (Signature const& signature : signatures)
726 {
727 TC_LOG_DEBUG("network", "PetitionsHandler: Adding arena team (guid: {}) member {}", arenaTeam->GetId(), signature.second.ToString());
728 arenaTeam->AddMember(signature.second);
729 }
730 }
731
732 sPetitionMgr->RemovePetition(petitionGuid);
733
734 // created
735 TC_LOG_DEBUG("network", "Player {} ({}) turning in petition {}", _player->GetName(), _player->GetGUID().ToString(), petitionGuid.ToString());
736
738 data << (uint32)PETITION_TURN_OK;
739 SendPacket(&data);
740}
741
743{
744 TC_LOG_DEBUG("network", "Received CMSG_PETITION_SHOWLIST");
745
746 ObjectGuid guid;
747 recvData >> guid;
748
750}
751
753{
755 if (!creature)
756 {
757 TC_LOG_DEBUG("network", "WORLD: HandlePetitionShowListOpcode - {} not found or you can't interact with him.", guid.ToString());
758 return;
759 }
760
761 WorldPacket data(SMSG_PETITION_SHOWLIST, 8+1+4*6);
762 data << guid; // npc guid
763
764 if (creature->IsTabardDesigner())
765 {
766 data << uint8(1); // count
767 data << uint32(1); // index
768 data << uint32(GUILD_CHARTER); // charter entry
769 data << uint32(CHARTER_DISPLAY_ID); // charter display id
770 data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_GUILD)); // charter cost
771 data << uint32(0); // unknown
772 data << uint32(sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS)); // required signs
773 }
774 else
775 {
776 data << uint8(3); // count
777 // 2v2
778 data << uint32(1); // index
779 data << uint32(ARENA_TEAM_CHARTER_2v2); // charter entry
780 data << uint32(CHARTER_DISPLAY_ID); // charter display id
781 data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_2v2)); // charter cost
782 data << uint32(2); // unknown
783 data << uint32(2); // required signs?
784 // 3v3
785 data << uint32(2); // index
786 data << uint32(ARENA_TEAM_CHARTER_3v3); // charter entry
787 data << uint32(CHARTER_DISPLAY_ID); // charter display id
788 data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_3v3)); // charter cost
789 data << uint32(3); // unknown
790 data << uint32(3); // required signs?
791 // 5v5
792 data << uint32(3); // index
793 data << uint32(ARENA_TEAM_CHARTER_5v5); // charter entry
794 data << uint32(CHARTER_DISPLAY_ID); // charter display id
795 data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_5v5)); // charter cost
796 data << uint32(5); // unknown
797 data << uint32(5); // required signs?
798 }
799
800 SendPacket(&data);
801 TC_LOG_DEBUG("network", "Sent SMSG_PETITION_SHOWLIST");
802}
#define sArenaTeamMgr
@ ERR_ARENA_TEAM_INVITE_SS
Definition ArenaTeam.h:34
@ ERR_ARENA_TEAM_CREATE_S
Definition ArenaTeam.h:33
#define MAX_ARENA_SLOT
Definition ArenaTeam.h:114
@ ERR_ARENA_TEAM_NAME_INVALID
Definition ArenaTeam.h:46
@ ERR_ALREADY_IN_ARENA_TEAM_S
Definition ArenaTeam.h:43
@ ERR_ALREADY_IN_ARENA_TEAM
Definition ArenaTeam.h:42
@ ERR_ARENA_TEAM_NOT_ALLIED
Definition ArenaTeam.h:53
@ ERR_ARENA_TEAM_TARGET_TOO_LOW_S
Definition ArenaTeam.h:55
@ ERR_ALREADY_INVITED_TO_ARENA_TEAM_S
Definition ArenaTeam.h:45
@ ERR_ARENA_TEAM_NAME_EXISTS_S
Definition ArenaTeam.h:47
#define sCharacterCache
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint64_t uint64
Definition Define.h:132
uint16_t uint16
Definition Define.h:134
uint32_t uint32
Definition Define.h:133
#define sGuildMgr
Definition GuildMgr.h:59
@ GUILD_COMMAND_INVITE
Definition Guild.h:108
@ GUILD_COMMAND_CREATE
Definition Guild.h:107
@ ERR_ALREADY_IN_GUILD_S
Definition Guild.h:130
@ ERR_GUILD_COMMAND_SUCCESS
Definition Guild.h:127
@ ERR_GUILD_NOT_ALLIED
Definition Guild.h:140
@ ERR_GUILD_NAME_EXISTS_S
Definition Guild.h:134
@ ERR_ALREADY_INVITED_TO_GUILD_S
Definition Guild.h:132
@ ERR_GUILD_NAME_INVALID
Definition Guild.h:133
InventoryResult
Definition ItemDefines.h:25
@ EQUIP_ERR_OK
Definition ItemDefines.h:26
@ BUY_ERR_CANT_FIND_ITEM
@ BUY_ERR_NOT_ENOUGHT_MONEY
@ ITEM_CHANGED
Definition Item.h:54
#define TC_LOG_DEBUG(filterType__,...)
Definition Log.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition Log.h:165
#define sObjectMgr
Definition ObjectMgr.h:1721
#define sPetitionMgr
Definition PetitionMgr.h:86
@ PETITION_SIGN_ALREADY_SIGNED
Definition PetitionMgr.h:39
@ PETITION_SIGN_OK
Definition PetitionMgr.h:38
@ PETITION_TURN_NEED_MORE_SIGNATURES
Definition PetitionMgr.h:32
@ PETITION_TURN_ALREADY_IN_GUILD
Definition PetitionMgr.h:31
@ PETITION_TURN_OK
Definition PetitionMgr.h:30
std::pair< uint32, ObjectGuid > Signature
Definition PetitionMgr.h:48
std::vector< Signature > SignaturesVector
Definition PetitionMgr.h:49
#define CHARTER_DISPLAY_ID
CharterItemIDs
@ GUILD_CHARTER
@ ARENA_TEAM_CHARTER_2v2
@ ARENA_TEAM_CHARTER_5v5
@ ARENA_TEAM_CHARTER_3v3
std::vector< ItemPosCount > ItemPosCountVec
Definition Player.h:624
CharterTypes
@ CHARTER_TYPE_NONE
@ ARENA_TEAM_CHARTER_2v2_TYPE
@ GUILD_CHARTER_TYPE
@ ARENA_TEAM_CHARTER_3v3_TYPE
@ ARENA_TEAM_CHARTER_5v5_TYPE
@ SPELL_AURA_FEIGN_DEATH
@ UNIT_NPC_FLAG_PETITIONER
@ UNIT_STATE_DIED
Definition Unit.h:220
@ NULL_BAG
Definition Unit.h:61
@ NULL_SLOT
Definition Unit.h:62
@ ITEM_FIELD_ENCHANTMENT_1_1
bool Create(ObjectGuid captainGuid, uint8 type, std::string const &teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor)
Definition ArenaTeam.cpp:49
bool AddMember(ObjectGuid PlayerGuid)
Definition ArenaTeam.cpp:94
uint32 GetId() const
Definition ArenaTeam.h:128
static uint8 GetSlotByType(uint32 type)
void read_skip()
Definition ByteBuffer.h:330
Definition Guild.h:284
bool AddMember(CharacterDatabaseTransaction trans, ObjectGuid guid, uint8 rankId=GUILD_RANK_NONE)
Definition Guild.cpp:2187
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string_view param="")
Definition Guild.cpp:106
bool Create(Player *pLeader, std::string_view name)
Definition Guild.cpp:1087
Definition Item.h:62
void SetState(ItemUpdateState state, Player *forplayer=nullptr)
Definition Item.cpp:638
uint8 GetSlot() const
Definition Item.h:126
uint8 GetBagSlot() const
Definition Item.cpp:711
LowType GetCounter() const
Definition ObjectGuid.h:156
std::string ToString() const
uint32 LowType
Definition ObjectGuid.h:142
static bool IsValidCharterName(std::string_view name)
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void SetUInt32Value(uint16 index, uint32 value)
Definition Object.cpp:585
uint32 GetTeam() const
Definition Player.h:1832
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 item, bool update, int32 randomPropertyId=0, GuidSet const &allowedLooters=GuidSet())
Definition Player.cpp:11621
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:6161
uint32 GetArenaTeamIdInvited() const
Definition Player.h:1632
bool ModifyMoney(int32 amount, bool sendError=true)
Definition Player.cpp:22339
bool IsMaxLevel() const
Definition Player.cpp:2501
bool HasEnoughMoney(uint32 amount) const
Definition Player.h:1410
void DestroyItem(uint8 bag, uint8 slot, bool update)
Definition Player.cpp:12113
Creature * GetNPCIfCanInteractWith(ObjectGuid const &guid, NPCFlags npcFlags) const
Definition Player.cpp:2094
uint32 GetArenaTeamId(uint8 slot) const
Definition Player.h:1629
void SendBuyError(BuyResult msg, Creature *creature, uint32 item, uint32 param) const
Definition Player.cpp:13118
ObjectGuid::LowType GetGuildId() const
Definition Player.h:1620
void SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast=false, bool sendChatMessage=true)
Definition Player.cpp:13856
ObjectGuid::LowType GetGuildIdInvited() const
Definition Player.h:1622
void SendEquipError(InventoryResult msg, Item *pItem, Item *pItem2=nullptr, uint32 itemid=0) const
Definition Player.cpp:13075
Item * GetItemByGuid(ObjectGuid guid) const
Definition Player.cpp:9518
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=nullptr) const
Definition Player.cpp:9989
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3765
bool IsTabardDesigner() const
Definition Unit.h:1112
std::string const & GetName() const
Definition Object.h:382
void Initialize(uint16 opcode, size_t newres=200)
Definition WorldPacket.h:73
void SendPetitionShowList(ObjectGuid guid)
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
void HandlePetitionShowListOpcode(WorldPacket &recvPacket)
void HandleTurnInPetitionOpcode(WorldPacket &recvData)
Player * GetPlayer() const
void HandleQueryPetition(WorldPacket &recvData)
void SendPetitionSigns(Petition const *petition, Player *sendTo)
void HandlePetitionRenameGuild(WorldPacket &recvData)
void HandlePetitionBuyOpcode(WorldPacket &recvData)
void HandleSignPetition(WorldPacket &recvData)
void SendPetitionQueryOpcode(ObjectGuid petitionguid)
uint32 GetAccountId() const
Player * _player
void HandleDeclinePetition(WorldPacket &recvData)
void SendArenaTeamCommandResult(uint32 team_action, std::string const &team, std::string const &player, uint32 error_id=0)
void HandleOfferPetitionOpcode(WorldPacket &recvData)
void HandlePetitionShowSignatures(WorldPacket &recvData)
@ MSG_PETITION_DECLINE
Definition Opcodes.h:479
@ SMSG_PETITION_SHOWLIST
Definition Opcodes.h:473
@ SMSG_PETITION_SHOW_SIGNATURES
Definition Opcodes.h:476
@ SMSG_PETITION_QUERY_RESPONSE
Definition Opcodes.h:484
@ SMSG_TURN_IN_PETITION_RESULTS
Definition Opcodes.h:482
@ SMSG_PETITION_SIGN_RESULTS
Definition Opcodes.h:478
@ MSG_PETITION_RENAME
Definition Opcodes.h:734
#define sWorld
Definition World.h:900
@ CONFIG_CHARTER_COST_GUILD
Definition World.h:385
@ CONFIG_MIN_PETITION_SIGNS
Definition World.h:253
@ CONFIG_CHARTER_COST_ARENA_5v5
Definition World.h:388
@ CONFIG_CHARTER_COST_ARENA_2v2
Definition World.h:386
@ CONFIG_CHARTER_COST_ARENA_3v3
Definition World.h:387
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD
Definition World.h:99
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
void UpdateName(std::string const &newName)
ObjectGuid OwnerGuid
Definition PetitionMgr.h:54
SignaturesVector Signatures
Definition PetitionMgr.h:57
CharterTypes PetitionType
Definition PetitionMgr.h:55
bool IsPetitionSignedByAccount(uint32 accountId) const
ObjectGuid PetitionGuid
Definition PetitionMgr.h:53
void AddSignature(uint32 accountId, ObjectGuid playerGuid, bool isLoading)
std::string PetitionName
Definition PetitionMgr.h:56