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->GetBuyCount());
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
199 charter->SetPetitionId(charter->GetGUID().GetCounter());
200 charter->SetState(ITEM_CHANGED, _player);
201 _player->SendNewItem(charter, 1, true, false);
202
203 // a petition is invalid, if both the owner and the type matches
204 // we checked above, if this player is in an arenateam, so this must be
205 // datacorruption
206 CharacterDatabase.EscapeString(name);
207 if (Petition const* petition = sPetitionMgr->GetPetitionByOwnerWithType(_player->GetGUID(), type))
208 {
209 // clear from petition store
210 sPetitionMgr->RemovePetition(petition->PetitionGuid);
211 TC_LOG_DEBUG("network", "Invalid petition {}", petition->PetitionGuid.ToString());
212 }
213
214 // fill petition store
215 sPetitionMgr->AddPetition(charter->GetGUID(), _player->GetGUID(), name, type, false);
216}
217
219{
220 TC_LOG_DEBUG("network", "Received opcode CMSG_PETITION_SHOW_SIGNATURES");
221
222 ObjectGuid petitionGuid;
223 recvData >> petitionGuid; // petition guid
224
225 Petition const* petition = sPetitionMgr->GetPetition(petitionGuid);
226 if (!petition)
227 {
228 TC_LOG_DEBUG("entities.player.items", "Petition {} is not found for player {} {}", petitionGuid.ToString(), GetPlayer()->GetGUID().ToString(), GetPlayer()->GetName());
229 return;
230 }
231
232 // if guild petition and has guild => error, return;
233 if (petition->PetitionType == GUILD_CHARTER_TYPE && _player->GetGuildId())
234 return;
235
236 TC_LOG_DEBUG("network", "CMSG_PETITION_SHOW_SIGNATURES petition {}", petitionGuid.ToString());
237
238 SendPetitionSigns(petition, _player);
239}
240
241void WorldSession::SendPetitionSigns(Petition const* petition, Player* sendTo)
242{
243 SignaturesVector const& signatures = petition->Signatures;
244 WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + 1 + signatures.size() * 12));
245 data << petition->PetitionGuid; // petition guid
246 data << petition->OwnerGuid; // owner guid
247 data << uint32(petition->PetitionGuid.GetCounter()); // guild guid
248 data << uint8(signatures.size()); // sign's count
249
250 for (Signature const& signature : signatures)
251 {
252 data << signature.second; // Player GUID
253 data << uint32(0); // there 0 ...
254 }
255
256 sendTo->SendDirectMessage(&data);
257}
258
260{
261 TC_LOG_DEBUG("network", "Received opcode CMSG_PETITION_QUERY"); // ok
262
263 ObjectGuid::LowType guildguid;
264 ObjectGuid petitionguid;
265 recvData >> guildguid; // in Trinity always same as GUID_LOPART(petitionguid)
266 recvData >> petitionguid; // petition guid
267 TC_LOG_DEBUG("network", "CMSG_PETITION_QUERY Petition {} Guild GUID {}", petitionguid.ToString(), guildguid);
268
269 SendPetitionQueryOpcode(petitionguid);
270}
271
273{
274 Petition const* petition = sPetitionMgr->GetPetition(petitionguid);
275 if (!petition)
276 {
277 TC_LOG_DEBUG("network", "CMSG_PETITION_QUERY failed for petition ({})", petitionguid.ToString());
278 return;
279 }
280
281 WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4+8+petition->PetitionName.size()+1+1+4*12+2+10));
282 data << uint32(petitionguid.GetCounter()); // guild/team guid (in Trinity always same as GUID_LOPART(petition guid)
283 data << petition->OwnerGuid; // charter owner guid
284 data << petition->PetitionName; // name (guild/arena team)
285 data << uint8(0); // some string
286
287 CharterTypes type = petition->PetitionType;
288 if (type == GUILD_CHARTER_TYPE)
289 {
290 uint32 needed = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS);
291 data << uint32(needed);
292 data << uint32(needed);
293 data << uint32(0); // bypass client - side limitation, a different value is needed here for each petition
294 }
295 else
296 {
297 data << uint32(type-1);
298 data << uint32(type-1);
299 data << uint32(type); // bypass client - side limitation, a different value is needed here for each petition
300 }
301 data << uint32(0); // 5
302 data << uint32(0); // 6
303 data << uint32(0); // 7
304 data << uint32(0); // 8
305 data << uint16(0); // 9 2 bytes field
306 data << uint32(0); // 10
307 data << uint32(0); // 11
308 data << uint32(0); // 13 count of next strings?
309
310 for (int i = 0; i < 10; ++i)
311 data << uint8(0); // some string
312
313 data << uint32(0); // 14
314
315 data << uint32(type != GUILD_CHARTER_TYPE); // 15 0 - guild, 1 - arena team
316
317 SendPacket(&data);
318}
319
321{
322 TC_LOG_DEBUG("network", "Received opcode CMSG_PETITION_RENAME_GUILD");
323
324 ObjectGuid petitionGuid;
325 std::string newName;
326
327 recvData >> petitionGuid; // guid
328 recvData >> newName; // new name
329
330 Item* item = _player->GetItemByGuid(petitionGuid);
331 if (!item)
332 return;
333
334 Petition* petition = sPetitionMgr->GetPetition(petitionGuid);
335 if (!petition)
336 {
337 TC_LOG_DEBUG("network", "CMSG_PETITION_QUERY failed for petition {}", petitionGuid.ToString());
338 return;
339 }
340
341 CharterTypes type = petition->PetitionType;
342 if (type == GUILD_CHARTER_TYPE)
343 {
344 if (sGuildMgr->GetGuildByName(newName))
345 {
347 return;
348 }
349 if (sObjectMgr->IsReservedName(newName) || !ObjectMgr::IsValidCharterName(newName))
350 {
352 return;
353 }
354 }
355 else
356 {
357 if (sArenaTeamMgr->GetArenaTeamByName(newName))
358 {
360 return;
361 }
362 if (sObjectMgr->IsReservedName(newName) || !ObjectMgr::IsValidCharterName(newName))
363 {
365 return;
366 }
367 }
368
369 CharacterDatabase.EscapeString(newName);
370
371 // update petition storage
372 petition->UpdateName(newName);
373
374 TC_LOG_DEBUG("network", "Petition {} renamed to '{}'", petitionGuid.ToString(), newName);
375 WorldPacket data(MSG_PETITION_RENAME, (8 + newName.size() + 1));
376 data << petitionGuid;
377 data << newName;
378 SendPacket(&data);
379}
380
382{
383 TC_LOG_DEBUG("network", "Received opcode CMSG_PETITION_SIGN"); // ok
384
385 ObjectGuid petitionGuid;
386 uint8 unk;
387 recvData >> petitionGuid; // petition guid
388 recvData >> unk;
389
390 Petition* petition = sPetitionMgr->GetPetition(petitionGuid);
391 if (!petition)
392 {
393 TC_LOG_ERROR("network", "Petition {} is not found for player {} {}", petitionGuid.ToString(), GetPlayer()->GetGUID().ToString(), GetPlayer()->GetName());
394 return;
395 }
396
397 ObjectGuid ownerGuid = petition->OwnerGuid;
398 CharterTypes type = petition->PetitionType;
399 uint8 signs = uint8(petition->Signatures.size());
400
401 if (ownerGuid == _player->GetGUID())
402 return;
403
404 // not let enemies sign guild charter
405 if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != sCharacterCache->GetCharacterTeamByGuid(ownerGuid))
406 {
407 if (type != GUILD_CHARTER_TYPE)
409 else
411 return;
412 }
413
414 if (type != GUILD_CHARTER_TYPE)
415 {
416 if (!_player->IsMaxLevel())
417 {
419 return;
420 }
421
422 uint8 slot = ArenaTeam::GetSlotByType(static_cast<uint32>(type));
423 if (slot >= MAX_ARENA_SLOT)
424 return;
425
426 if (_player->GetArenaTeamId(slot))
427 {
429 return;
430 }
431
433 {
435 return;
436 }
437 }
438 else
439 {
440 if (_player->GetGuildId())
441 {
443 return;
444 }
446 {
448 return;
449 }
450 }
451
452 if (++signs > static_cast<uint8>(type)) // client signs maximum
453 return;
454
455 // Client doesn't allow to sign petition two times by one character, but not check sign by another character from same account
456 // not allow sign another player from already sign player account
457 bool isSigned = petition->IsPetitionSignedByAccount(GetAccountId());
458 if (isSigned)
459 {
461 data << petitionGuid;
462 data << _player->GetGUID();
464
465 // close at signer side
466 SendPacket(&data);
467
468 // update for owner if online
469 if (Player* owner = ObjectAccessor::FindConnectedPlayer(ownerGuid))
470 owner->SendDirectMessage(&data);
471 return;
472 }
473
474 // fill petition store
475 petition->AddSignature(GetAccountId(), _player->GetGUID(), false);
476
477 TC_LOG_DEBUG("network", "PETITION SIGN: {} by player: {} ({} Account: {})", petitionGuid.ToString(), _player->GetName(), _player->GetGUID().ToString(), GetAccountId());
478
480 data << petitionGuid;
481 data << _player->GetGUID();
482 data << uint32(PETITION_SIGN_OK);
483 SendPacket(&data);
484
485 // update signs count on charter
486 if (Item* item = _player->GetItemByGuid(petitionGuid))
487 {
488 item->SetPetitionNumSignatures(signs);
489 item->SetState(ITEM_CHANGED, _player);
490 }
491
492 // update for owner if online
493 if (Player* owner = ObjectAccessor::FindConnectedPlayer(ownerGuid))
494 owner->SendDirectMessage(&data);
495}
496
498{
499 TC_LOG_DEBUG("network", "Received opcode MSG_PETITION_DECLINE"); // ok
500
501 ObjectGuid petitionguid;
502 recvData >> petitionguid; // petition guid
503 TC_LOG_DEBUG("network", "Petition {} declined by {}", petitionguid.ToString(), _player->GetGUID().ToString());
504
505 Petition const* petition = sPetitionMgr->GetPetition(petitionguid);
506 if (!petition)
507 return;
508
509 // petition owner online
511 {
513 data << _player->GetGUID();
514 owner->SendDirectMessage(&data);
515 }
516}
517
519{
520 TC_LOG_DEBUG("network", "Received opcode CMSG_OFFER_PETITION"); // ok
521
522 ObjectGuid petitionGuid, offererGuid;
523 uint32 junk;
524 recvData >> junk; // this is not petition type!
525 recvData >> petitionGuid; // petition guid
526 recvData >> offererGuid; // player guid
527
528 Player* player = ObjectAccessor::FindConnectedPlayer(offererGuid);
529 if (!player)
530 return;
531
532 Petition const* petition = sPetitionMgr->GetPetition(petitionGuid);
533 if (!petition)
534 return;
535
536 CharterTypes type = petition->PetitionType;
537
538 TC_LOG_DEBUG("network", "OFFER PETITION: type {}, {}, to {}", static_cast<uint32>(type), petitionGuid.ToString(), offererGuid.ToString());
539
540 if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam())
541 {
542 if (type != GUILD_CHARTER_TYPE)
544 else
546 return;
547 }
548
549 if (type != GUILD_CHARTER_TYPE)
550 {
551 if (!player->IsMaxLevel())
552 {
553 // player is too low level to join an arena team
555 return;
556 }
557
558 uint8 slot = ArenaTeam::GetSlotByType(static_cast<uint32>(type));
559 if (slot >= MAX_ARENA_SLOT)
560 return;
561
562 if (player->GetArenaTeamId(slot))
563 {
564 // player is already in an arena team
566 return;
567 }
568
569 if (player->GetArenaTeamIdInvited())
570 {
572 return;
573 }
574 }
575 else
576 {
577 if (player->GetGuildId())
578 {
580 return;
581 }
582
583 if (player->GetGuildIdInvited())
584 {
586 return;
587 }
588 }
589
590 SendPetitionSigns(petition, player);
591}
592
594{
595 TC_LOG_DEBUG("network", "Received opcode CMSG_TURN_IN_PETITION");
596
597 // Get petition guid from packet
598 WorldPacket data;
599 ObjectGuid petitionGuid;
600
601 recvData >> petitionGuid;
602
603 // Check if player really has the required petition charter
604 Item* item = _player->GetItemByGuid(petitionGuid);
605 if (!item)
606 return;
607
608 TC_LOG_DEBUG("network", "Petition {} turned in by {}", petitionGuid.ToString(), _player->GetGUID().ToString());
609
610 Petition const* petition = sPetitionMgr->GetPetition(petitionGuid);
611 if (!petition)
612 {
613 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());
614 return;
615 }
616
617 CharterTypes type = petition->PetitionType;
618 std::string const name = petition->PetitionName; // we need a copy, it will be removed on guild/arena remove
619
620 // Only the petition owner can turn in the petition
621 if (_player->GetGUID() != petition->OwnerGuid)
622 return;
623
624 // Petition type (guild/arena) specific checks
625 if (type == GUILD_CHARTER_TYPE)
626 {
627 // Check if player is already in a guild
628 if (_player->GetGuildId())
629 {
633 return;
634 }
635
636 // Check if guild name is already taken
637 if (sGuildMgr->GetGuildByName(name))
638 {
640 return;
641 }
642 }
643 else
644 {
645 // Check for valid arena bracket (2v2, 3v3, 5v5)
646 uint8 slot = ArenaTeam::GetSlotByType(static_cast<uint32>(type));
647 if (slot >= MAX_ARENA_SLOT)
648 return;
649
650 // Check if player is already in an arena team
651 if (_player->GetArenaTeamId(slot))
652 {
654 return;
655 }
656
657 // Check if arena team name is already taken
658 if (sArenaTeamMgr->GetArenaTeamByName(name))
659 {
661 return;
662 }
663 }
664
665 SignaturesVector const signatures = petition->Signatures; // we need a copy, it will be removed on guild/arena remove
666 uint32 requiredSignatures = static_cast<uint32>(type) - 1;
667 if (type == GUILD_CHARTER_TYPE)
668 requiredSignatures = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS);
669
670 // Notify player if signatures are missing
671 if (signatures.size() < requiredSignatures)
672 {
675 SendPacket(&data);
676 return;
677 }
678
679 // Proceed with guild/arena team creation
680
681 // Delete charter item
682 _player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
683
684 if (type == GUILD_CHARTER_TYPE)
685 {
686 // Create guild
687 Guild* guild = new Guild;
688
689 if (!guild->Create(_player, name))
690 {
691 delete guild;
692 return;
693 }
694
695 // Register guild and add guild master
696 sGuildMgr->AddGuild(guild);
697
699
700 {
701 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
702
703 // Add members from signatures
704 for (Signature const& signature : signatures)
705 guild->AddMember(trans, signature.second);
706
707 CharacterDatabase.CommitTransaction(trans);
708 }
709 }
710 else
711 {
712 // Receive the rest of the packet in arena team creation case
713 uint32 background, icon, iconcolor, border, bordercolor;
714 recvData >> background >> icon >> iconcolor >> border >> bordercolor;
715
716 // Create arena team
717 ArenaTeam* arenaTeam = new ArenaTeam();
718
719 if (!arenaTeam->Create(_player->GetGUID(), type, name, background, icon, iconcolor, border, bordercolor))
720 {
721 delete arenaTeam;
722 return;
723 }
724
725 // Register arena team
726 sArenaTeamMgr->AddArenaTeam(arenaTeam);
727 TC_LOG_DEBUG("network", "PetitonsHandler: Arena team (guid: {}) added to ObjectMgr", arenaTeam->GetId());
728
729 // Add members
730 for (Signature const& signature : signatures)
731 {
732 TC_LOG_DEBUG("network", "PetitionsHandler: Adding arena team (guid: {}) member {}", arenaTeam->GetId(), signature.second.ToString());
733 arenaTeam->AddMember(signature.second);
734 }
735 }
736
737 sPetitionMgr->RemovePetition(petitionGuid);
738
739 // created
740 TC_LOG_DEBUG("network", "Player {} ({}) turning in petition {}", _player->GetName(), _player->GetGUID().ToString(), petitionGuid.ToString());
741
743 data << (uint32)PETITION_TURN_OK;
744 SendPacket(&data);
745}
746
748{
749 TC_LOG_DEBUG("network", "Received CMSG_PETITION_SHOWLIST");
750
751 ObjectGuid guid;
752 recvData >> guid;
753
755}
756
758{
760 if (!creature)
761 {
762 TC_LOG_DEBUG("network", "WORLD: HandlePetitionShowListOpcode - {} not found or you can't interact with him.", guid.ToString());
763 return;
764 }
765
766 WorldPacket data(SMSG_PETITION_SHOWLIST, 8+1+4*6);
767 data << guid; // npc guid
768
769 if (creature->IsTabardDesigner())
770 {
771 data << uint8(1); // count
772 data << uint32(1); // index
773 data << uint32(GUILD_CHARTER); // charter entry
774 data << uint32(CHARTER_DISPLAY_ID); // charter display id
775 data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_GUILD)); // charter cost
776 data << uint32(0); // unknown
777 data << uint32(sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS)); // required signs
778 }
779 else
780 {
781 data << uint8(3); // count
782 // 2v2
783 data << uint32(1); // index
784 data << uint32(ARENA_TEAM_CHARTER_2v2); // charter entry
785 data << uint32(CHARTER_DISPLAY_ID); // charter display id
786 data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_2v2)); // charter cost
787 data << uint32(2); // unknown
788 data << uint32(2); // required signs?
789 // 3v3
790 data << uint32(2); // index
791 data << uint32(ARENA_TEAM_CHARTER_3v3); // charter entry
792 data << uint32(CHARTER_DISPLAY_ID); // charter display id
793 data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_3v3)); // charter cost
794 data << uint32(3); // unknown
795 data << uint32(3); // required signs?
796 // 5v5
797 data << uint32(3); // index
798 data << uint32(ARENA_TEAM_CHARTER_5v5); // charter entry
799 data << uint32(CHARTER_DISPLAY_ID); // charter display id
800 data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_5v5)); // charter cost
801 data << uint32(5); // unknown
802 data << uint32(5); // required signs?
803 }
804
805 SendPacket(&data);
806 TC_LOG_DEBUG("network", "Sent SMSG_PETITION_SHOWLIST");
807}
#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:632
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:234
@ NULL_BAG
Definition Unit.h:60
@ NULL_SLOT
Definition Unit.h:61
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:334
Definition Guild.h:284
bool AddMember(CharacterDatabaseTransaction trans, ObjectGuid guid, uint8 rankId=GUILD_RANK_NONE)
Definition Guild.cpp:2188
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:644
uint8 GetSlot() const
Definition Item.h:143
void SetPetitionId(uint32 petitionId)
Definition Item.h:235
uint8 GetBagSlot() const
Definition Item.cpp:717
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 SendEquipError(InventoryResult msg, Item const *item1=nullptr, Item const *item2=nullptr, uint32 itemId=0) const
Definition Player.cpp:13070
uint32 GetTeam() const
Definition Player.h:1818
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 itemId, bool update, int32 randomPropertyId=0, GuidSet const &allowedLooters=GuidSet())
Definition Player.cpp:11619
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:6163
uint32 GetArenaTeamIdInvited() const
Definition Player.h:1618
bool ModifyMoney(int32 amount, bool sendError=true)
Definition Player.cpp:22336
bool IsMaxLevel() const
Definition Player.cpp:2537
bool HasEnoughMoney(uint32 amount) const
Definition Player.h:1394
void DestroyItem(uint8 bag, uint8 slot, bool update)
Definition Player.cpp:12111
Creature * GetNPCIfCanInteractWith(ObjectGuid const &guid, NPCFlags npcFlags) const
Definition Player.cpp:2126
uint32 GetArenaTeamId(uint8 slot) const
Definition Player.h:1615
void SendBuyError(BuyResult msg, Creature *creature, uint32 item, uint32 param) const
Definition Player.cpp:13119
ObjectGuid::LowType GetGuildId() const
Definition Player.h:1605
void SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast=false, bool sendChatMessage=true)
Definition Player.cpp:13857
ObjectGuid::LowType GetGuildIdInvited() const
Definition Player.h:1608
Item * GetItemByGuid(ObjectGuid guid) const
Definition Player.cpp:9516
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=nullptr) const
Definition Player.cpp:9987
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3788
bool IsTabardDesigner() const
Definition Unit.h:1126
std::string const & GetName() const
Definition Object.h:384
void Initialize(uint16 opcode, size_t newres=200)
Definition WorldPacket.h:51
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:901
@ CONFIG_CHARTER_COST_GUILD
Definition World.h:386
@ CONFIG_MIN_PETITION_SIGNS
Definition World.h:254
@ CONFIG_CHARTER_COST_ARENA_5v5
Definition World.h:389
@ CONFIG_CHARTER_COST_ARENA_2v2
Definition World.h:387
@ CONFIG_CHARTER_COST_ARENA_3v3
Definition World.h:388
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD
Definition World.h:99
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
uint32 GetBuyCount() 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