TrinityCore
cs_debug.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/* ScriptData
19Name: debug_commandscript
20%Complete: 100
21Comment: All debug related commands
22Category: commandscripts
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "Bag.h"
27#include "BattlefieldMgr.h"
28#include "BattlegroundMgr.h"
29#include "CellImpl.h"
30#include "Channel.h"
31#include "ChannelPackets.h"
32#include "Chat.h"
33#include "ChatCommand.h"
34#include "ChatPackets.h"
35#include "Conversation.h"
36#include "CreatureAI.h"
37#include "DB2Stores.h"
38#include "GameTime.h"
39#include "GridNotifiersImpl.h"
40#include "InstanceScript.h"
41#include "Language.h"
42#include "Log.h"
43#include "M2Stores.h"
44#include "MapManager.h"
45#include "MovementPackets.h"
46#include "ObjectAccessor.h"
47#include "ObjectMgr.h"
48#include "PhasingHandler.h"
49#include "PoolMgr.h"
50#include "RBAC.h"
51#include "SpellMgr.h"
52#include "SpellPackets.h"
53#include "Transport.h"
54#include "Warden.h"
55#include "World.h"
56#include "WorldSession.h"
57#include <fstream>
58#include <limits>
59#include <map>
60#include <set>
61#include <sstream>
62
63using namespace Trinity::ChatCommands;
64
66{
67public:
68 debug_commandscript() : CommandScript("debug_commandscript") { }
69
71 {
72 static ChatCommandTable debugPlayCommandTable =
73 {
79 };
80 static ChatCommandTable debugSendCommandTable =
81 {
84 { "chatmessage", HandleDebugSendChatMsgCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
94 };
95 static ChatCommandTable debugCommandTable =
96 {
98 { "threatinfo", HandleDebugThreatInfoCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
101 { "arena", HandleDebugArenaCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
103 { "getitemstate", HandleDebugGetItemStateCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
104 { "lootrecipient", HandleDebugGetLootRecipientCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
105 { "play", debugPlayCommandTable },
106 { "send", debugSendCommandTable },
107 { "setaurastate", HandleDebugSetAuraStateCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
108 { "spawnvehicle", HandleDebugSpawnVehicleCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
109 { "entervehicle", HandleDebugEnterVehicleCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
111 { "itemexpire", HandleDebugItemExpireCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
112 { "areatriggers", HandleDebugAreaTriggersCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
114 { "moveflags", HandleDebugMoveflagsCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
115 { "transport", HandleDebugTransportCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
116 { "loadcells", HandleDebugLoadCellsCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
118 { "boundary", HandleDebugBoundaryCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
119 { "raidreset", HandleDebugRaidResetCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
120 { "neargraveyard", HandleDebugNearGraveyard, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
121 { "instancespawn", HandleDebugInstanceSpawns, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
122 { "conversation", HandleDebugConversationCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
123 { "wsexpression", HandleDebugWSExpressionCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
124 { "playercondition", HandleDebugPlayerConditionCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
125 { "pvp warmode", HandleDebugWarModeBalanceCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
127 { "asan memoryleak", HandleDebugMemoryLeak, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
128 { "asan outofbounds", HandleDebugOutOfBounds, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
129 { "guidlimits", HandleDebugGuidLimitsCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
130 { "objectcount", HandleDebugObjectCountCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
131 { "questreset", HandleDebugQuestResetCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
132 { "warden force", HandleDebugWardenForce, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
133 { "personalclone", HandleDebugBecomePersonalClone, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No }
134 };
135 static ChatCommandTable commandTable =
136 {
137 { "debug", debugCommandTable },
138 { "wpgps", HandleWPGPSCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
139 };
140 return commandTable;
141 }
142
143 static bool TryExtractTeamId(std::string const &args, TeamId &outFaction)
144 {
145 if ("a" == args || "alliance" == args)
146 outFaction = TEAM_ALLIANCE;
147 else if ("h" == args || "horde" == args)
148 outFaction = TEAM_HORDE;
149 else if ("n" == args || "neutral" == args)
150 outFaction = TEAM_NEUTRAL;
151 else
152 return false;
153
154 return true;
155 }
156
157 static bool HandleDebugWarModeBalanceCommand(ChatHandler* handler, Variant<uint32, EXACT_SEQUENCE("alliance"), EXACT_SEQUENCE("horde"), EXACT_SEQUENCE("neutral"), EXACT_SEQUENCE("off")> command, Optional<int32> rewardValue)
158 {
159 // USAGE: .debug pvp fb <alliance|horde|neutral|off> [pct]
160 // neutral Sets faction balance off.
161 // alliance Set faction balance to alliance.
162 // horde Set faction balance to horde.
163 // off Reset the faction balance and use the calculated value of it
164 switch (command.index())
165 {
166 case 0: // workaround for Variant of only ExactSequences not being supported
168 handler->SetSentErrorMessage(true);
169 return false;
170 case 1:
171 sWorld->SetForcedWarModeFactionBalanceState(TEAM_ALLIANCE, rewardValue.value_or(0));
172 break;
173 case 2:
174 sWorld->SetForcedWarModeFactionBalanceState(TEAM_HORDE, rewardValue.value_or(0));
175 break;
176 case 3:
177 sWorld->SetForcedWarModeFactionBalanceState(TEAM_NEUTRAL);
178 break;
179 case 4:
180 sWorld->DisableForcedWarModeFactionBalanceState();
181 break;
182 }
183
184 return true;
185 }
186
187 // cinematicId - ID from CinematicSequences.dbc
188 static bool HandleDebugPlayCinematicCommand(ChatHandler* handler, uint32 cinematicId)
189 {
190 CinematicSequencesEntry const* cineSeq = sCinematicSequencesStore.LookupEntry(cinematicId);
191 if (!cineSeq)
192 {
193 handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, cinematicId);
194 handler->SetSentErrorMessage(true);
195 return false;
196 }
197
198 // Dump camera locations
199 if (std::vector<FlyByCamera> const* flyByCameras = GetFlyByCameras(cineSeq->Camera[0]))
200 {
201 handler->PSendSysMessage("Waypoints for sequence %u, camera %u", cinematicId, cineSeq->Camera[0]);
202 uint32 count = 1;
203 for (FlyByCamera const& cam : *flyByCameras)
204 {
205 handler->PSendSysMessage("%02u - %7ums [%s (%f degrees)]", count, cam.timeStamp, cam.locations.ToString().c_str(), cam.locations.GetOrientation() * (180 / M_PI));
206 ++count;
207 }
208 handler->PSendSysMessage(SZFMTD " waypoints dumped", flyByCameras->size());
209 }
210
211 handler->GetPlayer()->SendCinematicStart(cinematicId);
212 return true;
213 }
214
215 // movieId - ID from Movie.dbc
216 static bool HandleDebugPlayMovieCommand(ChatHandler* handler, uint32 movieId)
217 {
218
219 if (!sMovieStore.LookupEntry(movieId))
220 {
221 handler->PSendSysMessage(LANG_MOVIE_NOT_EXIST, movieId);
222 handler->SetSentErrorMessage(true);
223 return false;
224 }
225
226 handler->GetPlayer()->SendMovieStart(movieId);
227 return true;
228 }
229
230 // soundId - ID from SoundKit.db2
231 static bool HandleDebugPlaySoundCommand(ChatHandler* handler, uint32 soundId, Optional<uint32> broadcastTextId)
232 {
233 if (!sSoundKitStore.LookupEntry(soundId))
234 {
235 handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId);
236 handler->SetSentErrorMessage(true);
237 return false;
238 }
239
240 Player* player = handler->GetPlayer();
241
242 Unit* unit = handler->getSelectedUnit();
243 if (!unit)
244 {
246 handler->SetSentErrorMessage(true);
247 return false;
248 }
249
250 if (player->GetTarget().IsEmpty())
251 unit->PlayDistanceSound(soundId, player);
252 else
253 unit->PlayDirectSound(soundId, player, broadcastTextId.value_or(0));
254
255 handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, soundId);
256 return true;
257 }
258
259 // musicId - ID from SoundEntries.dbc
260 static bool HandleDebugPlayMusicCommand(ChatHandler* handler, uint32 musicId)
261 {
262 if (!sSoundKitStore.LookupEntry(musicId))
263 {
264 handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, musicId);
265 handler->SetSentErrorMessage(true);
266 return false;
267 }
268
269 Player* player = handler->GetPlayer();
270
271 player->PlayDirectMusic(musicId, player);
272
273 handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, musicId);
274 return true;
275 }
276
277 static bool HandleDebugPlayObjectSoundCommand(ChatHandler* handler, int32 soundKitId, Optional<int32> broadcastTextId)
278 {
279 if (!sSoundKitStore.LookupEntry(soundKitId))
280 {
281 handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundKitId);
282 handler->SetSentErrorMessage(true);
283 return false;
284 }
285
286 Player* player = handler->GetPlayer();
287
288 player->PlayObjectSound(soundKitId, player->GetGUID(), player, broadcastTextId.has_value() ? *broadcastTextId : 0);
289
290 handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, soundKitId);
291 return true;
292 }
293
295 {
297 castFailed.CastID = ObjectGuid::Empty;
298 castFailed.SpellID = 133;
299 castFailed.Reason = result;
300 castFailed.FailedArg1 = failArg1.value_or(-1);
301 castFailed.FailedArg2 = failArg2.value_or(-1);
302 handler->GetSession()->SendPacket(castFailed.Write());
303
304 return true;
305 }
306
308 {
309 Player* player = handler->GetPlayer();
310 player->SendPlayerChoice(player->GetGUID(), choiceId);
311 return true;
312 }
313
315 {
316 handler->GetPlayer()->SendEquipError(error, nullptr, nullptr);
317 return true;
318 }
319
321 {
322 handler->GetPlayer()->SendSellError(error, nullptr, ObjectGuid::Empty);
323 return true;
324 }
325
327 {
328 handler->GetPlayer()->SendBuyError(error, nullptr, 0, 0);
329 return true;
330 }
331
333 {
334 Unit* unit = handler->getSelectedUnit();
335 Player* player = nullptr;
336 if (!unit || (unit->GetTypeId() != TYPEID_PLAYER))
337 player = handler->GetPlayer();
338 else
339 player = unit->ToPlayer();
340
341 if (!unit)
342 unit = player;
343
344 std::ifstream ifs("opcode.txt");
345 if (ifs.fail())
346 return false;
347
348 // remove comments from file
349 std::stringstream parsedStream;
350 while (!ifs.eof())
351 {
352 char commentToken[2] = {};
353 ifs.get(commentToken[0]);
354 if (ifs.eof())
355 break;
356 if (commentToken[0] == '/')
357 {
358 ifs.get(commentToken[1]);
359 if (!ifs.eof())
360 {
361 // /* comment
362 if (commentToken[1] == '*')
363 {
364 while (!ifs.eof())
365 {
366 ifs.get(commentToken[0]);
367 if (ifs.eof())
368 break;
369 if (commentToken[0] == '*')
370 {
371 ifs.get(commentToken[1]);
372 if (ifs.eof())
373 break;
374 if (commentToken[1] == '/')
375 break;
376 else
377 ifs.putback(commentToken[1]);
378 }
379 }
380 continue;
381 }
382 // line comment
383 else if (commentToken[1] == '/')
384 {
385 std::string str;
386 std::getline(ifs, str);
387 if (ifs.eof())
388 break;
389 continue;
390 }
391 // regular data
392 else
393 ifs.putback(commentToken[1]);
394 }
395 }
396 parsedStream.put(commentToken[0]);
397 }
398 ifs.close();
399
400 uint32 opcode = 0;
401 parsedStream >> opcode;
402
403 if (!opcode)
404 return false;
405
406 WorldPacket data(OpcodeServer(opcode), 0);
407
408 while (!parsedStream.eof() && !parsedStream.fail())
409 {
410 std::string type;
411 parsedStream >> type;
412
413 if (type.empty())
414 break;
415
416 if (type == "uint8")
417 {
418 if (parsedStream.eof())
419 return false;
420 uint16 val1 = 0;
421 parsedStream >> val1;
422 if (parsedStream.fail())
423 return false;
424 data << uint8(val1);
425 }
426 else if (type == "uint16")
427 {
428 if (parsedStream.eof())
429 return false;
430 uint16 val2 = 0;
431 parsedStream >> val2;
432 if (parsedStream.fail())
433 return false;
434 data << val2;
435 }
436 else if (type == "uint32")
437 {
438 if (parsedStream.eof())
439 return false;
440 uint32 val3 = 0;
441 parsedStream >> val3;
442 if (parsedStream.fail())
443 return false;
444 data << val3;
445 }
446 else if (type == "uint64")
447 {
448 if (parsedStream.eof())
449 return false;
450 uint64 val4 = 0;
451 parsedStream >> val4;
452 if (parsedStream.fail())
453 return false;
454 data << val4;
455 }
456 else if (type == "float")
457 {
458 if (parsedStream.eof())
459 return false;
460 float val5 = 0.0f;
461 parsedStream >> val5;
462 if (parsedStream.fail())
463 return false;
464 data << val5;
465 }
466 else if (type == "string")
467 {
468 std::string val6;
469 parsedStream >> val6;
470 // empty string is allowed so no need to check eof/fail here
471 data << val6;
472 }
473 else if (type == "goguid")
474 {
475 GameObject* obj = handler->GetNearbyGameObject();
476 if (!obj)
477 {
479 handler->SetSentErrorMessage(true);
480 return false;
481 }
482 data << obj->GetGUID();
483 }
484 else if (type == "myguid")
485 {
486 data << player->GetGUID();
487 }
488 else if (type == "itsguid")
489 {
490 data << unit->GetGUID();
491 }
492 else if (type == "itspos")
493 {
494 data << unit->GetPositionX();
495 data << unit->GetPositionY();
496 data << unit->GetPositionZ();
497 }
498 else if (type == "mypos")
499 {
500 data << player->GetPositionX();
501 data << player->GetPositionY();
502 data << player->GetPositionZ();
503 }
504 else
505 {
506 TC_LOG_ERROR("misc", "Sending opcode that has unknown type '{}'", type);
507 break;
508 }
509 }
510 TC_LOG_DEBUG("network", "Sending opcode {}", data.GetOpcode());
511 data.hexlike();
512 player->GetSession()->SendPacket(&data, true);
513 handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName().c_str());
514 return true;
515 }
516
517 static bool HandleDebugUpdateWorldStateCommand(ChatHandler* handler, uint32 variable, uint32 value)
518 {
519 handler->GetPlayer()->SendUpdateWorldState(variable, value);
520 return true;
521 }
522
524 {
525 Player* player = handler->GetPlayer();
526 if (!player->isDebugAreaTriggers)
527 {
529 player->isDebugAreaTriggers = true;
530 }
531 else
532 {
534 player->isDebugAreaTriggers = false;
535 }
536 player->UpdateObjectVisibility();
537 return true;
538 }
539
541 {
543 channelNotify.Type = type;
544 channelNotify._Channel = "test";
545 handler->GetSession()->SendPacket(channelNotify.Write());
546 return true;
547 }
548
550 {
552 packet.Initialize(type, LANG_UNIVERSAL, handler->GetPlayer(), handler->GetPlayer(), "testtest", 0, "chan");
553 handler->GetSession()->SendPacket(packet.Write());
554 return true;
555 }
556
558 {
559 handler->GetSession()->GetPlayer()->SendPushToPartyResponse(handler->GetPlayer(), msg);
560 return true;
561 }
562
564 {
565 Creature* target = handler->getSelectedCreature();
566 if (!target)
567 return false;
568
569 handler->PSendSysMessage("Loot recipients for creature %s (%s, SpawnID " UI64FMTD ") are:",
570 target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetSpawnId());
571
572 for (ObjectGuid tapperGuid : target->GetTapList())
573 {
574 Player* tapper = ObjectAccessor::GetPlayer(*target, tapperGuid);
575 handler->PSendSysMessage("* %s", tapper ? tapper->GetName().c_str() : "offline");
576 }
577
578 return true;
579 }
580
582 {
583 handler->GetPlayer()->SendCanTakeQuestResponse(msg);
584 return true;
585 }
586
587 static bool HandleDebugGetItemStateCommand(ChatHandler* handler, std::string itemState)
588 {
590 bool listQueue = false;
591 bool checkAll = false;
592
593 if (itemState == "unchanged")
594 state = ITEM_UNCHANGED;
595 else if (itemState == "changed")
596 state = ITEM_CHANGED;
597 else if (itemState == "new")
598 state = ITEM_NEW;
599 else if (itemState == "removed")
600 state = ITEM_REMOVED;
601 else if (itemState == "queue")
602 listQueue = true;
603 else if (itemState == "check_all")
604 checkAll = true;
605 else
606 return false;
607
608 Player* player = handler->getSelectedPlayer();
609 if (!player)
610 player = handler->GetPlayer();
611
612 if (!listQueue && !checkAll)
613 {
614 itemState = "The player has the following " + itemState + " items: ";
615 handler->SendSysMessage(itemState.c_str());
616 for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
617 {
618 if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END)
619 continue;
620
621 if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
622 {
623 if (Bag* bag = item->ToBag())
624 {
625 for (uint8 j = 0; j < bag->GetBagSize(); ++j)
626 if (Item* item2 = bag->GetItemByPos(j))
627 if (item2->GetState() == state)
628 handler->PSendSysMessage("bag: 255 slot: %d %s owner: %s", item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetOwnerGUID().ToString().c_str());
629 }
630 else if (item->GetState() == state)
631 handler->PSendSysMessage("bag: 255 slot: %d %s owner: %s", item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str());
632 }
633 }
634 }
635
636 if (listQueue)
637 {
638 std::vector<Item*>& updateQueue = player->GetItemUpdateQueue();
639 for (size_t i = 0; i < updateQueue.size(); ++i)
640 {
641 Item* item = updateQueue[i];
642 if (!item)
643 continue;
644
645 Bag* container = item->GetContainer();
646 uint8 bagSlot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0);
647
648 std::string st;
649 switch (item->GetState())
650 {
651 case ITEM_UNCHANGED:
652 st = "unchanged";
653 break;
654 case ITEM_CHANGED:
655 st = "changed";
656 break;
657 case ITEM_NEW:
658 st = "new";
659 break;
660 case ITEM_REMOVED:
661 st = "removed";
662 break;
663 }
664
665 handler->PSendSysMessage("bag: %d slot: %d %s - state: %s", bagSlot, item->GetSlot(), item->GetGUID().ToString().c_str(), st.c_str());
666 }
667 if (updateQueue.empty())
668 handler->PSendSysMessage("The player's updatequeue is empty");
669 }
670
671 if (checkAll)
672 {
673 bool error = false;
674 std::vector<Item*>& updateQueue = player->GetItemUpdateQueue();
675 for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
676 {
677 if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END)
678 continue;
679
680 Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
681 if (!item)
682 continue;
683
684 if (item->GetSlot() != i)
685 {
686 handler->PSendSysMessage("Item with slot %d and %s has an incorrect slot value: %d", i, item->GetGUID().ToString().c_str(), item->GetSlot());
687 error = true;
688 continue;
689 }
690
691 if (item->GetOwnerGUID() != player->GetGUID())
692 {
693 handler->PSendSysMessage("The item with slot %d %s does have non-matching owner guid %s and %s!", item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
694 error = true;
695 continue;
696 }
697
698 if (Bag* container = item->GetContainer())
699 {
700 handler->PSendSysMessage("The item with slot %d %s has a container (slot: %d, %s) but shouldn't!", item->GetSlot(), item->GetGUID().ToString().c_str(), container->GetSlot(), container->GetGUID().ToString().c_str());
701 error = true;
702 continue;
703 }
704
705 if (item->IsInUpdateQueue())
706 {
707 uint16 qp = item->GetQueuePos();
708 if (qp > updateQueue.size())
709 {
710 handler->PSendSysMessage("The item with slot %d and %s has its queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUID().ToString().c_str(), qp);
711 error = true;
712 continue;
713 }
714
715 if (updateQueue[qp] == nullptr)
716 {
717 handler->PSendSysMessage("The item with slot %d and %s has its queuepos (%d) pointing to NULL in the queue!", item->GetSlot(), item->GetGUID().ToString().c_str(), qp);
718 error = true;
719 continue;
720 }
721
722 if (updateQueue[qp] != item)
723 {
724 handler->PSendSysMessage("The item with slot %d and %s has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, %s)", item->GetSlot(), item->GetGUID().ToString().c_str(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().ToString().c_str());
725 error = true;
726 continue;
727 }
728 }
729 else if (item->GetState() != ITEM_UNCHANGED)
730 {
731 handler->PSendSysMessage("The item with slot %d and %s is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetState());
732 error = true;
733 continue;
734 }
735
736 if (Bag* bag = item->ToBag())
737 {
738 for (uint8 j = 0; j < bag->GetBagSize(); ++j)
739 {
740 Item* item2 = bag->GetItemByPos(j);
741 if (!item2)
742 continue;
743
744 if (item2->GetSlot() != j)
745 {
746 handler->PSendSysMessage("The item in bag %d and slot %d (%s) has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUID().ToString().c_str(), item2->GetSlot());
747 error = true;
748 continue;
749 }
750
751 if (item2->GetOwnerGUID() != player->GetGUID())
752 {
753 handler->PSendSysMessage("The item in bag %d at slot %d and %s, the owner (%s) and the player (%s) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
754 error = true;
755 continue;
756 }
757
758 Bag* container = item2->GetContainer();
759 if (!container)
760 {
761 handler->PSendSysMessage("The item in bag %d at slot %d %s has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str());
762 error = true;
763 continue;
764 }
765
766 if (container != bag)
767 {
768 handler->PSendSysMessage("The item in bag %d at slot %d %s has a different container(slot %d %s)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), container->GetSlot(), container->GetGUID().ToString().c_str());
769 error = true;
770 continue;
771 }
772
773 if (item2->IsInUpdateQueue())
774 {
775 uint16 qp = item2->GetQueuePos();
776 if (qp > updateQueue.size())
777 {
778 handler->PSendSysMessage("The item in bag %d at slot %d having %s has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp);
779 error = true;
780 continue;
781 }
782
783 if (updateQueue[qp] == nullptr)
784 {
785 handler->PSendSysMessage("The item in bag %d at slot %d having %s has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp);
786 error = true;
787 continue;
788 }
789
790 if (updateQueue[qp] != item2)
791 {
792 handler->PSendSysMessage("The item in bag %d at slot %d having %s has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, %s)", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().ToString().c_str());
793 error = true;
794 continue;
795 }
796 }
797 else if (item2->GetState() != ITEM_UNCHANGED)
798 {
799 handler->PSendSysMessage("The item in bag %d at slot %d having %s is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetState());
800 error = true;
801 continue;
802 }
803 }
804 }
805 }
806
807 for (size_t i = 0; i < updateQueue.size(); ++i)
808 {
809 Item* item = updateQueue[i];
810 if (!item)
811 continue;
812
813 if (item->GetOwnerGUID() != player->GetGUID())
814 {
815 handler->PSendSysMessage("queue(%zu): For the item %s, the owner (%s) and the player (%s) don't match!", i, item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
816 error = true;
817 continue;
818 }
819
820 if (item->GetQueuePos() != i)
821 {
822 handler->PSendSysMessage("queue(%zu): For the item %s, the queuepos doesn't match it's position in the queue!", i, item->GetGUID().ToString().c_str());
823 error = true;
824 continue;
825 }
826
827 if (item->GetState() == ITEM_REMOVED)
828 continue;
829
830 Item* test = player->GetItemByPos(item->GetBagSlot(), item->GetSlot());
831
832 if (test == nullptr)
833 {
834 handler->PSendSysMessage("queue(%zu): The bag(%d) and slot(%d) values for %s are incorrect, the player doesn't have any item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str());
835 error = true;
836 continue;
837 }
838
839 if (test != item)
840 {
841 handler->PSendSysMessage("queue(%zu): The bag(%d) and slot(%d) values for the %s are incorrect, %s is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), test->GetGUID().ToString().c_str());
842 error = true;
843 continue;
844 }
845 }
846 if (!error)
847 handler->SendSysMessage("All OK!");
848 }
849
850 return true;
851 }
852
854 {
855 sBattlegroundMgr->ToggleTesting();
856 return true;
857 }
858
859 static bool HandleDebugArenaCommand(ChatHandler* /*handler*/)
860 {
861 sBattlegroundMgr->ToggleArenaTesting();
862 return true;
863 }
864
866 {
867 Unit* target = handler->getSelectedUnit();
868 if (!target)
869 target = handler->GetPlayer();
870
871 ThreatManager& mgr = target->GetThreatManager();
872 if (!target->IsAlive())
873 {
874 handler->PSendSysMessage("%s (%s) is not alive.%s", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->IsEngaged() ? " (It is, however, engaged. Huh?)" : "");
875 return true;
876 }
877
878 uint32 count = 0;
879 auto const& threatenedByMe = target->GetThreatManager().GetThreatenedByMeList();
880 if (threatenedByMe.empty())
881 handler->PSendSysMessage("%s (%s) does not threaten any units.", target->GetName().c_str(), target->GetGUID().ToString().c_str());
882 else
883 {
884 handler->PSendSysMessage("List of units threatened by %s (%s)", target->GetName().c_str(), target->GetGUID().ToString().c_str());
885 for (auto const& pair : threatenedByMe)
886 {
887 Unit* unit = pair.second->GetOwner();
888 handler->PSendSysMessage(" %u. %s (%s, SpawnID " UI64FMTD ") - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetSpawnId() : 0, pair.second->GetThreat());
889 }
890 handler->SendSysMessage("End of threatened-by-me list.");
891 }
892
893 if (mgr.CanHaveThreatList())
894 {
895 if (!mgr.IsThreatListEmpty(true))
896 {
897 if (target->IsEngaged())
898 handler->PSendSysMessage("Threat list of %s (%s, SpawnID " UI64FMTD "):", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0);
899 else
900 handler->PSendSysMessage("%s (%s, SpawnID " UI64FMTD ") is not engaged, but still has a threat list? Well, here it is:", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0);
901
902 count = 0;
903 Unit* fixateVictim = mgr.GetFixateTarget();
904 for (ThreatReference const* ref : mgr.GetSortedThreatList())
905 {
906 Unit* unit = ref->GetVictim();
907 char const* onlineStr;
908 switch (ref->GetOnlineState())
909 {
911 onlineStr = " [SUPPRESSED]";
912 break;
914 onlineStr = " [OFFLINE]";
915 break;
916 default:
917 onlineStr = "";
918 }
919 char const* tauntStr;
920 if (unit == fixateVictim)
921 tauntStr = " [FIXATE]";
922 else
923 switch (ref->GetTauntState())
924 {
926 tauntStr = " [TAUNT]";
927 break;
929 tauntStr = " [DETAUNT]";
930 break;
931 default:
932 tauntStr = "";
933 }
934 handler->PSendSysMessage(" %u. %s (%s) - threat %f%s%s", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), ref->GetThreat(), tauntStr, onlineStr);
935 }
936 handler->SendSysMessage("End of threat list.");
937 }
938 else if (!target->IsEngaged())
939 handler->PSendSysMessage("%s (%s, SpawnID " UI64FMTD ") is not currently engaged.", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0);
940 else
941 handler->PSendSysMessage("%s (%s, SpawnID " UI64FMTD ") seems to be engaged, but does not have a threat list??", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0);
942 }
943 else if (target->IsEngaged())
944 handler->PSendSysMessage("%s (%s) is currently engaged. (This unit cannot have a threat list.)", target->GetName().c_str(), target->GetGUID().ToString().c_str());
945 else
946 handler->PSendSysMessage("%s (%s) is not currently engaged. (This unit cannot have a threat list.)", target->GetName().c_str(), target->GetGUID().ToString().c_str());
947 return true;
948 }
949
951 {
952 Unit* target = handler->getSelectedUnit();
953 if (!target)
954 {
956 handler->SetSentErrorMessage(true);
957 return false;
958 }
959
960 handler->PSendSysMessage("Threat info for %s (%s):", target->GetName().c_str(), target->GetGUID().ToString().c_str());
961
962 ThreatManager const& mgr = target->GetThreatManager();
963
964 // _singleSchoolModifiers
965 {
966 auto& mods = mgr._singleSchoolModifiers;
967 handler->SendSysMessage(" - Single-school threat modifiers:");
968 handler->PSendSysMessage(" |-- Physical: %.2f%%", mods[SPELL_SCHOOL_NORMAL] * 100.0f);
969 handler->PSendSysMessage(" |-- Holy : %.2f%%", mods[SPELL_SCHOOL_HOLY] * 100.0f);
970 handler->PSendSysMessage(" |-- Fire : %.2f%%", mods[SPELL_SCHOOL_FIRE] * 100.0f);
971 handler->PSendSysMessage(" |-- Nature : %.2f%%", mods[SPELL_SCHOOL_NATURE] * 100.0f);
972 handler->PSendSysMessage(" |-- Frost : %.2f%%", mods[SPELL_SCHOOL_FROST] * 100.0f);
973 handler->PSendSysMessage(" |-- Shadow : %.2f%%", mods[SPELL_SCHOOL_SHADOW] * 100.0f);
974 handler->PSendSysMessage(" |-- Arcane : %.2f%%", mods[SPELL_SCHOOL_ARCANE] * 100.0f);
975 }
976
977 // _multiSchoolModifiers
978 {
979 auto& mods = mgr._multiSchoolModifiers;
980 handler->PSendSysMessage("- Multi-school threat modifiers (%zu entries):", mods.size());
981 for (auto const& pair : mods)
982 handler->PSendSysMessage(" |-- Mask 0x%x: %.2f%%", uint32(pair.first), pair.second);
983 }
984
985 // _redirectInfo
986 {
987 auto const& redirectInfo = mgr._redirectInfo;
988 if (redirectInfo.empty())
989 handler->SendSysMessage(" - No redirects being applied");
990 else
991 {
992 handler->PSendSysMessage(" - %02zu redirects being applied:", redirectInfo.size());
993 for (auto const& pair : redirectInfo)
994 {
995 Unit* unit = ObjectAccessor::GetUnit(*target, pair.first);
996 handler->PSendSysMessage(" |-- %02u%% to %s", pair.second, unit ? unit->GetName().c_str() : pair.first.ToString().c_str());
997 }
998 }
999 }
1000
1001 // _redirectRegistry
1002 {
1003 auto const& redirectRegistry = mgr._redirectRegistry;
1004 if (redirectRegistry.empty())
1005 handler->SendSysMessage(" - No redirects are registered");
1006 else
1007 {
1008 handler->PSendSysMessage(" - %02zu spells may have redirects registered", redirectRegistry.size());
1009 for (auto const& outerPair : redirectRegistry) // (spellId, (guid, pct))
1010 {
1011 SpellInfo const* const spell = sSpellMgr->GetSpellInfo(outerPair.first, DIFFICULTY_NONE);
1012 handler->PSendSysMessage(" |-- #%06u %s (%zu entries):", outerPair.first, spell ? (*spell->SpellName)[sWorld->GetDefaultDbcLocale()] : "<unknown>", outerPair.second.size());
1013 for (auto const& innerPair : outerPair.second) // (guid, pct)
1014 {
1015 Unit* unit = ObjectAccessor::GetUnit(*target, innerPair.first);
1016 handler->PSendSysMessage(" |-- %02u%% to %s", innerPair.second, unit ? unit->GetName().c_str() : innerPair.first.ToString().c_str());
1017 }
1018 }
1019 }
1020 }
1021
1022 return true;
1023 }
1024
1026 {
1027 Unit* target = handler->getSelectedUnit();
1028 if (!target)
1029 target = handler->GetPlayer();
1030
1031 handler->PSendSysMessage("Combat refs: (Combat state: %d | Manager state: %d)", target->IsInCombat(), target->GetCombatManager().HasCombat());
1032 for (auto const& ref : target->GetCombatManager().GetPvPCombatRefs())
1033 {
1034 Unit* unit = ref.second->GetOther(target);
1035 handler->PSendSysMessage("[PvP] %s (SpawnID %u)", unit->GetName().c_str(), unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetSpawnId() : 0);
1036 }
1037 for (auto const& ref : target->GetCombatManager().GetPvECombatRefs())
1038 {
1039 Unit* unit = ref.second->GetOther(target);
1040 handler->PSendSysMessage("[PvE] %s (SpawnID %u)", unit->GetName().c_str(), unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetSpawnId() : 0);
1041 }
1042 return true;
1043 }
1044
1046 {
1047 Unit* target = handler->getSelectedUnit();
1048 if (!target || !target->IsVehicle())
1049 return false;
1050
1051 if (!seatId)
1052 seatId = -1;
1053
1054 if (!entry)
1055 handler->GetPlayer()->EnterVehicle(target, *seatId);
1056 else
1057 {
1058 Creature* passenger = nullptr;
1059 Trinity::AllCreaturesOfEntryInRange check(handler->GetPlayer(), entry, 20.0f);
1061 Cell::VisitAllObjects(handler->GetPlayer(), searcher, 30.0f);
1062 if (!passenger || passenger == target)
1063 return false;
1064 passenger->EnterVehicle(target, *seatId);
1065 }
1066
1067 handler->PSendSysMessage("Unit %u entered vehicle %hhd", entry, *seatId);
1068 return true;
1069 }
1070
1072 {
1073 float x, y, z, o = handler->GetPlayer()->GetOrientation();
1074 handler->GetPlayer()->GetClosePoint(x, y, z, handler->GetPlayer()->GetCombatReach());
1075
1076 if (!id)
1077 return handler->GetPlayer()->SummonCreature(entry, x, y, z, o) != nullptr;
1078
1079 CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(entry);
1080
1081 if (!ci)
1082 return false;
1083
1084 VehicleEntry const* ve = sVehicleStore.LookupEntry(*id);
1085
1086 if (!ve)
1087 return false;
1088
1089 Map* map = handler->GetPlayer()->GetMap();
1090 Position pos = { x, y, z, o };
1091
1092 Creature* v = Creature::CreateCreature(entry, map, pos, *id);
1093 if (!v)
1094 return false;
1095
1097
1098 map->AddToMap(v);
1099
1100 return true;
1101 }
1102
1104 {
1105 std::ostringstream ss;
1106 while (ss.str().size() < 128000)
1107 ss << "This is a dummy string to push the packet's size beyond 128000 bytes. ";
1108 handler->SendSysMessage(ss.str().c_str());
1109 return true;
1110 }
1111
1113 {
1114 PhaseShift phaseShift;
1115
1116 if (phaseId)
1117 phaseShift.AddPhase(*phaseId, PhaseFlags::None, nullptr);
1118
1119 if (visibleMapId)
1120 phaseShift.AddVisibleMapId(*visibleMapId, nullptr);
1121
1122 if (uiMapPhaseId)
1123 phaseShift.AddUiMapPhaseId(*uiMapPhaseId);
1124
1125 PhasingHandler::SendToPlayer(handler->GetSession()->GetPlayer(), phaseShift);
1126 return true;
1127 }
1128
1130 {
1131 Item* i = handler->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid));
1132
1133 if (!i)
1134 return false;
1135
1136 handler->GetPlayer()->DestroyItem(i->GetBagSlot(), i->GetSlot(), true);
1137 sScriptMgr->OnItemExpire(handler->GetPlayer(), i->GetTemplate());
1138
1139 return true;
1140 }
1141
1142 // Play emote animation
1143 static bool HandleDebugAnimCommand(ChatHandler* handler, Emote emote)
1144 {
1145 if (Unit* unit = handler->getSelectedUnit())
1146 unit->HandleEmoteCommand(emote);
1147
1148 handler->PSendSysMessage("Playing emote %s", EnumUtils::ToConstant(emote));
1149
1150 return true;
1151 }
1152
1154 {
1155 if (Unit* unit = handler->getSelectedUnit())
1156 {
1157 Player* player = handler->GetPlayer();
1158 handler->PSendSysMessage("Checking LoS %s -> %s:", player->GetName().c_str(), unit->GetName().c_str());
1159 handler->PSendSysMessage(" VMAP LoS: %s", player->IsWithinLOSInMap(unit, LINEOFSIGHT_CHECK_VMAP) ? "clear" : "obstructed");
1160 handler->PSendSysMessage(" GObj LoS: %s", player->IsWithinLOSInMap(unit, LINEOFSIGHT_CHECK_GOBJECT) ? "clear" : "obstructed");
1161 handler->PSendSysMessage("%s is %sin line of sight of %s.", unit->GetName().c_str(), (player->IsWithinLOSInMap(unit) ? "" : "not "), player->GetName().c_str());
1162 return true;
1163 }
1164 return false;
1165 }
1166
1168 {
1169 Unit* unit = handler->getSelectedUnit();
1170 if (!unit)
1171 {
1173 handler->SetSentErrorMessage(true);
1174 return false;
1175 }
1176
1177 if (!state)
1178 {
1179 // reset all states
1180 for (AuraStateType s : EnumUtils::Iterate<AuraStateType>())
1181 unit->ModifyAuraState(s, false);
1182 return true;
1183 }
1184
1185 unit->ModifyAuraState(*state, apply);
1186 return true;
1187 }
1188
1189 static bool HandleDebugMoveflagsCommand(ChatHandler* handler, Optional<uint32> moveFlags, Optional<uint32> moveFlagsExtra)
1190 {
1191 Unit* target = handler->getSelectedUnit();
1192 if (!target)
1193 target = handler->GetPlayer();
1194
1195 if (!moveFlags)
1196 {
1199 }
1200 else
1201 {
1203
1204 if (moveFlagsExtra)
1205 {
1206 target->SetExtraUnitMovementFlags(*moveFlagsExtra);
1207 }
1208
1209 if (target->GetTypeId() != TYPEID_PLAYER)
1210 target->DestroyForNearbyPlayers(); // Force new SMSG_UPDATE_OBJECT:CreateObject
1211 else
1212 {
1214 moveUpdate.Status = &target->m_movementInfo;
1215 target->SendMessageToSet(moveUpdate.Write(), true);
1216 }
1217
1219 }
1220
1221 return true;
1222 }
1223
1224 static bool HandleWPGPSCommand(ChatHandler* handler)
1225 {
1226 Player* player = handler->GetPlayer();
1227
1228 TC_LOG_INFO("sql.dev", "(@PATH, XX, {:.3f}, {:.3f}, {:.5f}, {:.5f}, 0, 0, 0, 100, 0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
1229
1230 handler->PSendSysMessage("Waypoint SQL written to SQL Developer log");
1231 return true;
1232 }
1233
1234 static bool HandleDebugTransportCommand(ChatHandler* handler, std::string operation)
1235 {
1236 Transport* transport = dynamic_cast<Transport*>(handler->GetPlayer()->GetTransport());
1237 if (!transport)
1238 return false;
1239
1240 bool start = false;
1241 if (StringEqualI(operation, "stop"))
1242 transport->EnableMovement(false);
1243 else if (StringEqualI(operation, "start"))
1244 {
1245 transport->EnableMovement(true);
1246 start = true;
1247 }
1248 else
1249 {
1250 Position pos = transport->GetPosition();
1251 handler->PSendSysMessage("Transport %s is %s", transport->GetName().c_str(), transport->GetGoState() == GO_STATE_READY ? "stopped" : "moving");
1252 handler->PSendSysMessage("Transport position: %s", pos.ToString().c_str());
1253 return true;
1254 }
1255
1256 handler->PSendSysMessage("Transport %s %s", transport->GetName().c_str(), start ? "started" : "stopped");
1257 return true;
1258 }
1259
1261 {
1262 if (mapId)
1263 {
1264 sMapMgr->DoForAllMapsWithMapId(*mapId, [&](Map* map)
1265 {
1266 HandleDebugLoadCellsCommandHelper(handler, map, tileX, tileY);
1267 });
1268 return true;
1269 }
1270
1271 if (Player* player = handler->GetPlayer())
1272 {
1273 // Fallback to player's map if no map has been specified
1274 return HandleDebugLoadCellsCommandHelper(handler, player->GetMap(), tileX, tileY);
1275 }
1276
1277 return false;
1278 }
1279
1281 {
1282 if (!map)
1283 return false;
1284
1285 // Load 1 single tile if specified, otherwise load the whole map
1286 if (tileX && tileY)
1287 {
1288 handler->PSendSysMessage("Loading cell (mapId: %u tile: %u, %u). Current GameObjects " SZFMTD ", Creatures " SZFMTD,
1289 map->GetId(), *tileX, *tileY, map->GetObjectsStore().Size<GameObject>(), map->GetObjectsStore().Size<Creature>());
1290
1291 // Some unit convertions to go from TileXY to GridXY to WorldXY
1292 float x = ((float(64 - 1 - *tileX) - 0.5f - CENTER_GRID_ID) * SIZE_OF_GRIDS) + (CENTER_GRID_OFFSET * 2);
1293 float y = ((float(64 - 1 - *tileY) - 0.5f - CENTER_GRID_ID) * SIZE_OF_GRIDS) + (CENTER_GRID_OFFSET * 2);
1294 map->LoadGrid(x, y);
1295
1296 handler->PSendSysMessage("Cell loaded (mapId: %u tile: %u, %u) After load - GameObject " SZFMTD ", Creatures " SZFMTD,
1297 map->GetId(), *tileX, *tileY, map->GetObjectsStore().Size<GameObject>(), map->GetObjectsStore().Size<Creature>());
1298 }
1299 else
1300 {
1301 handler->PSendSysMessage("Loading all cells (mapId: %u). Current GameObjects " SZFMTD ", Creatures " SZFMTD, map->GetId(), map->GetObjectsStore().Size<GameObject>(), map->GetObjectsStore().Size<Creature>());
1302
1303 map->LoadAllCells();
1304
1305 handler->PSendSysMessage("Cells loaded (mapId: %u) After load - GameObject " SZFMTD ", Creatures " SZFMTD, map->GetId(), map->GetObjectsStore().Size<GameObject>(), map->GetObjectsStore().Size<Creature>());
1306 }
1307
1308 return true;
1309 }
1310
1311 static bool HandleDebugBoundaryCommand(ChatHandler* handler, Optional<EXACT_SEQUENCE("fill")> fill, Optional<uint32> durationArg)
1312 {
1313 Player* player = handler->GetPlayer();
1314 if (!player)
1315 return false;
1316 Creature* target = handler->getSelectedCreature();
1317 if (!target || !target->IsAIEnabled())
1318 return false;
1319
1320 Seconds duration = durationArg ? Seconds(*durationArg) : 0s;
1321 if (duration <= 0s || duration >= 30min) // arbitrary upper limit
1322 duration = 3min;
1323
1324 int32 errMsg = target->AI()->VisualizeBoundary(duration, player, fill.has_value());
1325 if (errMsg > 0)
1326 handler->PSendSysMessage(errMsg);
1327
1328 return true;
1329 }
1330
1332 {
1333 Unit* target = handler->getSelectedUnit();
1334
1335 if (!target)
1336 {
1338 handler->SetSentErrorMessage(true);
1339 return false;
1340 }
1341
1342 if (target->GetDBPhase() > 0)
1343 handler->PSendSysMessage("Target creature's PhaseId in DB: %d", target->GetDBPhase());
1344 else if (target->GetDBPhase() < 0)
1345 handler->PSendSysMessage("Target creature's PhaseGroup in DB: %d", abs(target->GetDBPhase()));
1346
1347 PhasingHandler::PrintToChat(handler, target);
1348 return true;
1349 }
1350
1351 static bool HandleDebugRaidResetCommand(ChatHandler* handler, uint32 mapId, Optional<uint32> difficulty)
1352 {
1353 MapEntry const* mEntry = sMapStore.LookupEntry(mapId);
1354 if (!mEntry)
1355 {
1356 handler->PSendSysMessage("Invalid map specified.");
1357 return true;
1358 }
1359 if (!mEntry->IsDungeon())
1360 {
1361 handler->PSendSysMessage("'%s' is not a dungeon map.", mEntry->MapName[handler->GetSessionDbcLocale()]);
1362 return true;
1363 }
1364 if (difficulty && !sDifficultyStore.HasRecord(*difficulty))
1365 {
1366 handler->PSendSysMessage("Invalid difficulty %d.", *difficulty);
1367 return false;
1368 }
1369 if (difficulty && !sDB2Manager.GetMapDifficultyData(mEntry->ID, Difficulty(*difficulty)))
1370 {
1371 handler->PSendSysMessage("Difficulty %d is not valid for '%s'.", *difficulty, mEntry->MapName[handler->GetSessionDbcLocale()]);
1372 return true;
1373 }
1374
1375 return true;
1376 }
1377
1378 static bool HandleDebugQuestResetCommand(ChatHandler* handler, std::string arg)
1379 {
1380 if (!Utf8ToUpperOnlyLatin(arg))
1381 return false;
1382
1383 bool daily = false, weekly = false, monthly = false;
1384 if (arg == "ALL")
1385 daily = weekly = monthly = true;
1386 else if (arg == "DAILY")
1387 daily = true;
1388 else if (arg == "WEEKLY")
1389 weekly = true;
1390 else if (arg == "MONTHLY")
1391 monthly = true;
1392 else
1393 return false;
1394
1395 if (daily)
1396 {
1397 sWorld->DailyReset();
1398 handler->PSendSysMessage("Daily quests have been reset. Next scheduled reset: %s", TimeToHumanReadable(sWorld->GetPersistentWorldVariable(World::NextDailyQuestResetTimeVarId)).c_str());
1399 }
1400 if (weekly)
1401 {
1402 sWorld->ResetWeeklyQuests();
1403 handler->PSendSysMessage("Weekly quests have been reset. Next scheduled reset: %s", TimeToHumanReadable(sWorld->GetPersistentWorldVariable(World::NextWeeklyQuestResetTimeVarId)).c_str());
1404 }
1405 if (monthly)
1406 {
1407 sWorld->ResetMonthlyQuests();
1408 handler->PSendSysMessage("Monthly quests have been reset. Next scheduled reset: %s", TimeToHumanReadable(sWorld->GetPersistentWorldVariable(World::NextMonthlyQuestResetTimeVarId)).c_str());
1409 }
1410
1411 return true;
1412 }
1413
1414 static bool HandleDebugNearGraveyard(ChatHandler* handler, Optional<EXACT_SEQUENCE("linked")> linked)
1415 {
1416 Player* player = handler->GetPlayer();
1417 WorldSafeLocsEntry const* nearestLoc = nullptr;
1418
1419 if (linked)
1420 {
1421 if (Battleground* bg = player->GetBattleground())
1422 nearestLoc = bg->GetClosestGraveyard(player);
1423 else
1424 {
1425 if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetMap(), player->GetZoneId()))
1426 nearestLoc = bf->GetClosestGraveyard(player);
1427 else
1428 nearestLoc = sObjectMgr->GetClosestGraveyard(*player, player->GetTeam(), player);
1429 }
1430 }
1431 else
1432 {
1433 float x = player->GetPositionX();
1434 float y = player->GetPositionY();
1435 float z = player->GetPositionZ();
1436 float distNearest = std::numeric_limits<float>::max();
1437
1438 for (auto&& kvp : sObjectMgr->GetWorldSafeLocs())
1439 {
1440 if (kvp.second.Loc.GetMapId() == player->GetMapId())
1441 {
1442 float dist = (kvp.second.Loc.GetPositionX() - x) * (kvp.second.Loc.GetPositionX() - x)
1443 + (kvp.second.Loc.GetPositionY() - y) * (kvp.second.Loc.GetPositionY() - y)
1444 + (kvp.second.Loc.GetPositionZ() - z) * (kvp.second.Loc.GetPositionZ() - z);
1445 if (dist < distNearest)
1446 {
1447 distNearest = dist;
1448 nearestLoc = &kvp.second;
1449 }
1450 }
1451 }
1452 }
1453
1454 if (nearestLoc)
1455 handler->PSendSysMessage(LANG_COMMAND_NEARGRAVEYARD, nearestLoc->ID, nearestLoc->Loc.GetPositionX(), nearestLoc->Loc.GetPositionY(), nearestLoc->Loc.GetPositionZ());
1456 else
1458
1459 return true;
1460 }
1461
1462 static bool HandleDebugInstanceSpawns(ChatHandler* handler, Variant<uint32, EXACT_SEQUENCE("explain")> optArg)
1463 {
1464 Player const* const player = handler->GetPlayer();
1465 if (!player)
1466 return false;
1467
1468 bool explain = false;
1469 uint32 groupID = 0;
1470 if (optArg.holds_alternative<uint32>())
1471 groupID = optArg.get<uint32>();
1472 else
1473 explain = true;
1474
1475 if (groupID && !sObjectMgr->GetSpawnGroupData(groupID))
1476 {
1477 handler->PSendSysMessage("There is no spawn group with ID %u.", groupID);
1478 handler->SetSentErrorMessage(true);
1479 return false;
1480 }
1481
1482 Map const* const map = player->GetMap();
1483 char const* const mapName = map->GetMapName();
1484 InstanceScript const* const instance = player->GetInstanceScript();
1485 if (!instance)
1486 {
1487 handler->PSendSysMessage("%s has no instance script.", mapName);
1488 handler->SetSentErrorMessage(true);
1489 return false;
1490 }
1491 if (!instance->_instanceSpawnGroups || instance->_instanceSpawnGroups->empty())
1492 {
1493 handler->PSendSysMessage("%s's instance script does not manage any spawn groups.", mapName);
1494 handler->SetSentErrorMessage(true);
1495 return false;
1496 }
1497 auto const& spawnGroups = *instance->_instanceSpawnGroups;
1498 std::map<uint32, std::set<std::tuple<bool, uint8, uint8>>> store;
1499 for (InstanceSpawnGroupInfo const& info : spawnGroups)
1500 {
1501 if (groupID && info.SpawnGroupId != groupID)
1502 continue;
1503
1504 bool isSpawn;
1506 isSpawn = false;
1507 else if (info.Flags & InstanceSpawnGroupInfo::FLAG_ACTIVATE_SPAWN)
1508 isSpawn = true;
1509 else
1510 continue;
1511
1512 store[info.SpawnGroupId].emplace(isSpawn, info.BossStateId, info.BossStates);
1513 }
1514
1515 if (groupID && store.find(groupID) == store.end())
1516 {
1517 handler->PSendSysMessage("%s's instance script does not manage group '%s'.", mapName, sObjectMgr->GetSpawnGroupData(groupID)->name.c_str());
1518 handler->SetSentErrorMessage(true);
1519 return false;
1520 }
1521
1522 if (!groupID)
1523 handler->PSendSysMessage("Spawn groups managed by %s (%u):", mapName, map->GetId());
1524
1525 for (auto const& pair : store)
1526 {
1527 SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(pair.first);
1528 ASSERT(groupData); // checked by objectmgr on load
1529 if (explain)
1530 {
1531 handler->PSendSysMessage(" |-- '%s' (%u)", groupData->name.c_str(), pair.first);
1532 bool isBlocked = false, isSpawned = false;
1533 for (auto const& tuple : pair.second)
1534 {
1535 bool const isSpawn = std::get<0>(tuple);
1536 uint8 const bossStateId = std::get<1>(tuple);
1537 EncounterState const actualState = instance->GetBossState(bossStateId);
1538 if (std::get<2>(tuple) & (1 << actualState))
1539 {
1540 if (isSpawn)
1541 {
1542 isSpawned = true;
1543 if (isBlocked)
1544 handler->PSendSysMessage(" | |-- '%s' would be allowed to spawn by boss state %u being %s, but this is overruled", groupData->name.c_str(), bossStateId, InstanceScript::GetBossStateName(actualState));
1545 else
1546 handler->PSendSysMessage(" | |-- '%s' is allowed to spawn because boss state %u is %s.", groupData->name.c_str(), bossStateId, InstanceScript::GetBossStateName(bossStateId));
1547 }
1548 else
1549 {
1550 isBlocked = true;
1551 handler->PSendSysMessage(" | |-- '%s' is blocked from spawning because boss state %u is %s.", groupData->name.c_str(), bossStateId, InstanceScript::GetBossStateName(bossStateId));
1552 }
1553 }
1554 else
1555 handler->PSendSysMessage(" | |-- '%s' could've been %s if boss state %u matched mask 0x%02x; but it is %s -> 0x%02x, which does not match.",
1556 groupData->name.c_str(), isSpawn ? "allowed to spawn" : "blocked from spawning", bossStateId, std::get<2>(tuple), InstanceScript::GetBossStateName(actualState), (1 << actualState));
1557 }
1558 if (isBlocked)
1559 handler->PSendSysMessage(" | |=> '%s' is not active due to a blocking rule being matched", groupData->name.c_str());
1560 else if (isSpawned)
1561 handler->PSendSysMessage(" | |=> '%s' is active due to a spawn rule being matched", groupData->name.c_str());
1562 else
1563 handler->PSendSysMessage(" | |=> '%s' is not active due to none of its rules being matched", groupData->name.c_str());
1564 }
1565 else
1566 handler->PSendSysMessage(" - '%s' (%u) is %sactive", groupData->name.c_str(), pair.first, map->IsSpawnGroupActive(pair.first) ? "" : "not ");
1567 }
1568 return true;
1569 }
1570
1571 static bool HandleDebugConversationCommand(ChatHandler* handler, uint32 conversationEntry)
1572 {
1573 Player* target = handler->getSelectedPlayerOrSelf();
1574
1575 if (!target)
1576 {
1578 handler->SetSentErrorMessage(true);
1579 return false;
1580 }
1581
1582 return Conversation::CreateConversation(conversationEntry, target, *target, target->GetGUID()) != nullptr;
1583 }
1584
1585 static bool HandleDebugWSExpressionCommand(ChatHandler* handler, uint32 expressionId)
1586 {
1587 Player* target = handler->getSelectedPlayerOrSelf();
1588
1589 if (!target)
1590 {
1592 handler->SetSentErrorMessage(true);
1593 return false;
1594 }
1595
1596 WorldStateExpressionEntry const* wsExpressionEntry = sWorldStateExpressionStore.LookupEntry(expressionId);
1597 if (!wsExpressionEntry)
1598 return false;
1599
1600 if (ConditionMgr::IsMeetingWorldStateExpression(target->GetMap(), wsExpressionEntry))
1601 handler->PSendSysMessage("Expression %u meet", expressionId);
1602 else
1603 handler->PSendSysMessage("Expression %u not meet", expressionId);
1604
1605 return true;
1606 }
1607
1608 static bool HandleDebugPlayerConditionCommand(ChatHandler* handler, uint32 playerConditionId)
1609 {
1610 Player* target = handler->getSelectedPlayerOrSelf();
1611
1612 if (!target)
1613 {
1615 handler->SetSentErrorMessage(true);
1616 return false;
1617 }
1618
1619 PlayerConditionEntry const* playerConditionEntry = sPlayerConditionStore.LookupEntry(playerConditionId);
1620 if (!playerConditionEntry)
1621 return false;
1622
1623 if (ConditionMgr::IsPlayerMeetingCondition(target, playerConditionEntry))
1624 handler->PSendSysMessage("PlayerCondition %u met", playerConditionId);
1625 else
1626 handler->PSendSysMessage("PlayerCondition %u not met", playerConditionId);
1627
1628 return true;
1629 }
1630
1631 static bool HandleDebugOutOfBounds([[maybe_unused]] ChatHandler* handler)
1632 {
1633#ifdef ASAN
1634 uint8 stack_array[10] = {};
1635 int size = 10;
1636
1637 handler->PSendSysMessage("Triggered an array out of bounds read at address %p, value %u", static_cast<void*>(stack_array + size), stack_array[size]);
1638#endif
1639 return true;
1640 }
1641
1642 static bool HandleDebugMemoryLeak([[maybe_unused]] ChatHandler* handler)
1643 {
1644#ifdef ASAN
1645 uint8* leak = new uint8();
1646 handler->PSendSysMessage("Leaked 1 uint8 object at address %p", static_cast<void*>(leak));
1647#endif
1648 return true;
1649 }
1650
1651 static bool HandleDebugWardenForce(ChatHandler* handler, std::vector<uint16> checkIds)
1652 {
1653 if (checkIds.empty())
1654 return false;
1655
1656 Warden* const warden = handler->GetSession()->GetWarden();
1657 if (!warden)
1658 {
1659 handler->SendSysMessage("Warden system is not enabled");
1660 return true;
1661 }
1662
1663 size_t const nQueued = warden->DEBUG_ForceSpecificChecks(checkIds);
1664 handler->PSendSysMessage("%zu/%zu checks queued for your Warden, they should be sent over the next few minutes (depending on settings)", nQueued, checkIds.size());
1665 return true;
1666 }
1667
1669 {
1670 if (mapId)
1671 {
1672 sMapMgr->DoForAllMapsWithMapId(mapId.value(),
1673 [handler](Map* map) -> void
1674 {
1675 HandleDebugGuidLimitsMap(handler, map);
1676 }
1677 );
1678 }
1679 else
1680 {
1681 sMapMgr->DoForAllMaps(
1682 [handler](Map* map) -> void
1683 {
1684 HandleDebugGuidLimitsMap(handler, map);
1685 }
1686 );
1687 }
1688
1689 handler->PSendSysMessage("Guid Warn Level: %u", sWorld->getIntConfig(CONFIG_RESPAWN_GUIDWARNLEVEL));
1690 handler->PSendSysMessage("Guid Alert Level: %u", sWorld->getIntConfig(CONFIG_RESPAWN_GUIDALERTLEVEL));
1691 return true;
1692 }
1693
1694 static void HandleDebugGuidLimitsMap(ChatHandler* handler, Map* map)
1695 {
1696 handler->PSendSysMessage("Map Id: %u Name: '%s' Instance Id: %u Highest Guid Creature: " UI64FMTD " GameObject: " UI64FMTD,
1698 }
1699
1701 {
1702 if (mapId)
1703 {
1704 sMapMgr->DoForAllMapsWithMapId(mapId.value(),
1705 [handler](Map* map) -> void
1706 {
1707 HandleDebugObjectCountMap(handler, map);
1708 }
1709 );
1710 }
1711 else
1712 {
1713 sMapMgr->DoForAllMaps(
1714 [handler](Map* map) -> void
1715 {
1716 HandleDebugObjectCountMap(handler, map);
1717 }
1718 );
1719 }
1720
1721 return true;
1722 }
1723
1725 {
1726 public:
1728
1729 void Visit(std::unordered_map<ObjectGuid, Creature*>& creatureMap)
1730 {
1731 for (auto const& p : creatureMap)
1732 {
1733 uint32& count = creatureIds[p.second->GetEntry()];
1734 ++count;
1735 }
1736 }
1737
1738 template<class T>
1739 void Visit(std::unordered_map<ObjectGuid, T*>&) { }
1740
1741 std::vector<std::pair<uint32, uint32>> GetTopCreatureCount(uint32 count)
1742 {
1743 auto comp = [](std::pair<uint32, uint32> const& a, std::pair<uint32, uint32> const& b)
1744 {
1745 return a.second > b.second;
1746 };
1747 std::set<std::pair<uint32, uint32>, decltype(comp)> set(creatureIds.begin(), creatureIds.end(), comp);
1748
1749 count = std::min(count, uint32(set.size()));
1750 std::vector<std::pair<uint32, uint32>> result(count);
1751 std::copy_n(set.begin(), count, result.begin());
1752
1753 return result;
1754 }
1755
1756 private:
1757 std::unordered_map<uint32, uint32> creatureIds;
1758 };
1759
1760 static void HandleDebugObjectCountMap(ChatHandler* handler, Map* map)
1761 {
1762 handler->PSendSysMessage("Map Id: %u Name: '%s' Instance Id: %u Creatures: " UI64FMTD " GameObjects: " UI64FMTD " SetActive Objects: " UI64FMTD,
1763 map->GetId(), map->GetMapName(), map->GetInstanceId(),
1767
1768 CreatureCountWorker worker;
1770 visitor.Visit(map->GetObjectsStore());
1771
1772 handler->PSendSysMessage("Top Creatures count:");
1773
1774 for (auto&& p : worker.GetTopCreatureCount(5))
1775 handler->PSendSysMessage("Entry: %u Count: %u", p.first, p.second);
1776 }
1777
1779 {
1780 Creature* selection = handler->getSelectedCreature();
1781 if (!selection)
1782 return false;
1783
1784 Player* player = handler->GetSession()->GetPlayer();
1785 selection->SummonPersonalClone(player->GetPosition(), TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
1786 return true;
1787 }
1788
1790 {
1791 handler->SendSysMessage("This command does nothing right now. Edit your local core (cs_debug.cpp) to make it do whatever you need for testing.");
1792 return true;
1793 }
1794};
1795
1797{
1798 new debug_commandscript();
1799}
#define sBattlefieldMgr
#define sBattlegroundMgr
ChatNotify
Definition: Channel.h:40
#define EXACT_SEQUENCE(str)
#define M_PI
Definition: Common.h:115
DB2Storage< DifficultyEntry > sDifficultyStore("Difficulty.db2", &DifficultyLoadInfo::Instance)
DB2Storage< MapEntry > sMapStore("Map.db2", &MapLoadInfo::Instance)
DB2Storage< WorldStateExpressionEntry > sWorldStateExpressionStore("WorldStateExpression.db2", &WorldStateExpressionLoadInfo::Instance)
DB2Storage< PlayerConditionEntry > sPlayerConditionStore("PlayerCondition.db2", &PlayerConditionLoadInfo::Instance)
DB2Storage< MovieEntry > sMovieStore("Movie.db2", &MovieLoadInfo::Instance)
DB2Storage< SoundKitEntry > sSoundKitStore("SoundKit.db2", &SoundKitLoadInfo::Instance)
DB2Storage< VehicleEntry > sVehicleStore("Vehicle.db2", &VehicleLoadInfo::Instance)
DB2Storage< CinematicSequencesEntry > sCinematicSequencesStore("CinematicSequences.db2", &CinematicSequencesLoadInfo::Instance)
#define sDB2Manager
Definition: DB2Stores.h:538
Difficulty
Definition: DBCEnums.h:873
@ DIFFICULTY_NONE
Definition: DBCEnums.h:874
#define UI64FMTD
Definition: Define.h:126
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint64_t uint64
Definition: Define.h:141
uint16_t uint16
Definition: Define.h:143
uint32_t uint32
Definition: Define.h:142
#define SZFMTD
Definition: Define.h:132
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
#define ASSERT
Definition: Errors.h:68
#define SIZE_OF_GRIDS
Definition: GridDefines.h:40
#define CENTER_GRID_ID
Definition: GridDefines.h:41
#define CENTER_GRID_OFFSET
Definition: GridDefines.h:43
EncounterState
InventoryResult
Definition: ItemDefines.h:25
BuyResult
Definition: ItemDefines.h:149
SellResult
Definition: ItemDefines.h:163
ItemUpdateState
Definition: Item.h:53
@ ITEM_CHANGED
Definition: Item.h:55
@ ITEM_REMOVED
Definition: Item.h:57
@ ITEM_NEW
Definition: Item.h:56
@ ITEM_UNCHANGED
Definition: Item.h:54
@ LANG_SELECT_CREATURE
Definition: Language.h:32
@ LANG_COMMAND_OBJNOTFOUND
Definition: Language.h:325
@ LANG_DEBUG_AREATRIGGER_ON
Definition: Language.h:977
@ LANG_CINEMATIC_NOT_EXIST
Definition: Language.h:975
@ LANG_MOVEFLAGS_GET
Definition: Language.h:916
@ LANG_COMMAND_OPCODESENT
Definition: Language.h:541
@ LANG_COMMAND_NEARGRAVEYARD
Definition: Language.h:114
@ LANG_YOU_HEAR_SOUND
Definition: Language.h:198
@ LANG_MOVEFLAGS_SET
Definition: Language.h:917
@ LANG_SELECT_CHAR_OR_CREATURE
Definition: Language.h:31
@ LANG_MOVIE_NOT_EXIST
Definition: Language.h:976
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:567
@ LANG_SOUND_NOT_EXIST
Definition: Language.h:212
@ LANG_BAD_VALUE
Definition: Language.h:149
@ LANG_COMMAND_NEARGRAVEYARD_NOTFOUND
Definition: Language.h:115
@ LANG_DEBUG_AREATRIGGER_OFF
Definition: Language.h:978
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:165
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:159
std::vector< FlyByCamera > const * GetFlyByCameras(uint32 cinematicCameraId)
Definition: M2Stores.cpp:267
#define sMapMgr
Definition: MapManager.h:184
@ TEMPSUMMON_MANUAL_DESPAWN
Definition: ObjectDefines.h:70
@ TYPEID_UNIT
Definition: ObjectGuid.h:40
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
#define sObjectMgr
Definition: ObjectMgr.h:1946
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
@ BUYBACK_SLOT_END
Definition: Player.h:707
@ BUYBACK_SLOT_START
Definition: Player.h:706
#define INVENTORY_SLOT_BAG_0
Definition: Player.h:625
@ PLAYER_SLOT_START
Definition: Player.h:617
@ PLAYER_SLOT_END
Definition: Player.h:619
QuestFailedReason
Definition: QuestDef.h:57
QuestPushReason
Definition: QuestDef.h:76
Role Based Access Control related classes definition.
#define sScriptMgr
Definition: ScriptMgr.h:1418
@ LANG_UNIVERSAL
Emote
TeamId
@ TEAM_NEUTRAL
@ TEAM_ALLIANCE
@ TEAM_HORDE
@ LINEOFSIGHT_CHECK_VMAP
@ LINEOFSIGHT_CHECK_GOBJECT
SpellCastResult
AuraStateType
@ SPELL_SCHOOL_SHADOW
@ SPELL_SCHOOL_NORMAL
@ SPELL_SCHOOL_NATURE
@ SPELL_SCHOOL_FROST
@ SPELL_SCHOOL_ARCANE
@ SPELL_SCHOOL_FIRE
@ SPELL_SCHOOL_HOLY
ChatMsg
@ GO_STATE_READY
#define sSpellMgr
Definition: SpellMgr.h:849
bool StringEqualI(std::string_view a, std::string_view b)
Definition: Util.cpp:891
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:795
std::string TimeToHumanReadable(time_t t)
Definition: Util.cpp:303
Definition: Bag.h:27
void hexlike() const
Definition: ByteBuffer.cpp:177
Player * getSelectedPlayerOrSelf()
Definition: Chat.cpp:244
Unit * getSelectedUnit()
Definition: Chat.cpp:212
Player * getSelectedPlayer()
Definition: Chat.cpp:200
WorldSession * GetSession()
Definition: Chat.h:42
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:592
void PSendSysMessage(const char *fmt, Args &&... args)
Definition: Chat.h:57
Creature * getSelectedCreature()
Definition: Chat.cpp:236
void SetSentErrorMessage(bool val)
Definition: Chat.h:114
Player * GetPlayer() const
Definition: Chat.cpp:39
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:113
GameObject * GetNearbyGameObject()
Definition: Chat.cpp:374
bool HasCombat() const
std::unordered_map< ObjectGuid, PvPCombatReference * > const & GetPvPCombatRefs() const
std::unordered_map< ObjectGuid, CombatReference * > const & GetPvECombatRefs() const
static bool IsPlayerMeetingCondition(Player const *player, PlayerConditionEntry const *condition)
static bool IsMeetingWorldStateExpression(Map const *map, WorldStateExpressionEntry const *expression)
static Conversation * CreateConversation(uint32 conversationEntry, Unit *creator, Position const &pos, ObjectGuid privateObjectOwner, SpellInfo const *spellInfo=nullptr, bool autoStart=true)
int32 VisualizeBoundary(Seconds duration, Unit *owner=nullptr, bool fill=false) const
Definition: CreatureAI.cpp:353
static Creature * CreateCreature(uint32 entry, Map *map, Position const &pos, uint32 vehId=0)
Definition: Creature.cpp:1177
GuidUnorderedSet const & GetTapList() const
Definition: Creature.h:282
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:98
CreatureAI * AI() const
Definition: Creature.h:214
static char const * ToConstant(Enum value)
Definition: SmartEnum.h:120
GOState GetGoState() const
Definition: GameObject.h:281
static char const * GetBossStateName(uint8 state)
EncounterState GetBossState(uint32 id) const
std::vector< InstanceSpawnGroupInfo > const *const _instanceSpawnGroups
Definition: Item.h:170
uint8 GetSlot() const
Definition: Item.h:280
Bag * GetContainer()
Definition: Item.h:281
Bag * ToBag()
Definition: Item.h:241
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:1141
ItemUpdateState GetState() const
Definition: Item.h:322
uint16 GetQueuePos() const
Definition: Item.h:325
ObjectGuid GetOwnerGUID() const
Definition: Item.h:188
uint8 GetBagSlot() const
Definition: Item.cpp:1239
bool IsInUpdateQueue() const
Definition: Item.h:324
Definition: Map.h:189
MapStoredObjectTypesContainer & GetObjectsStore()
Definition: Map.h:422
void LoadGrid(float x, float y)
Definition: Map.cpp:405
bool AddToMap(T *)
Definition: Map.cpp:550
ObjectGuid::LowType GetMaxLowGuid()
Definition: Map.h:526
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:519
bool IsSpawnGroupActive(uint32 groupId) const
Definition: Map.cpp:2474
uint32 GetId() const
Definition: Map.cpp:3228
char const * GetMapName() const
Definition: Map.cpp:1854
uint32 GetInstanceId() const
Definition: Map.h:314
void LoadAllCells()
Definition: Map.cpp:110
size_t GetActiveNonPlayersCount() const
Definition: Map.h:542
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
bool IsEmpty() const
Definition: ObjectGuid.h:319
std::string ToString() const
Definition: ObjectGuid.cpp:554
uint64 LowType
Definition: ObjectGuid.h:278
static Creature * ToCreature(Object *o)
Definition: Object.h:219
TypeID GetTypeId() const
Definition: Object.h:173
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static Player * ToPlayer(Object *o)
Definition: Object.h:213
bool AddVisibleMapId(uint32 visibleMapId, TerrainSwapInfo const *visibleMapInfo, int32 references=1)
Definition: PhaseShift.cpp:51
bool AddUiMapPhaseId(uint32 uiMapPhaseId, int32 references=1)
Definition: PhaseShift.cpp:70
bool AddPhase(uint32 phaseId, PhaseFlags flags, std::vector< Condition > const *areaConditions, int32 references=1)
Definition: PhaseShift.cpp:28
static void PrintToChat(ChatHandler *chat, WorldObject const *target)
static void InheritPhaseShift(WorldObject *target, WorldObject const *source)
static void SendToPlayer(Player const *player, PhaseShift const &phaseShift)
void SendMovieStart(uint32 movieId)
Definition: Player.cpp:6338
void SendEquipError(InventoryResult msg, Item const *item1=nullptr, Item const *item2=nullptr, uint32 itemId=0) const
Definition: Player.cpp:13254
void SendPlayerChoice(ObjectGuid sender, int32 choiceId)
Definition: Player.cpp:29251
void SendSellError(SellResult msg, Creature *creature, ObjectGuid guid) const
Definition: Player.cpp:13309
WorldSession * GetSession() const
Definition: Player.h:2101
Item * GetItemByPos(uint16 pos) const
Definition: Player.cpp:9582
void DestroyItem(uint8 bag, uint8 slot, bool update)
Definition: Player.cpp:12180
void SendBuyError(BuyResult msg, Creature *creature, uint32 item, uint32 param) const
Definition: Player.cpp:13300
Battleground * GetBattleground() const
Definition: Player.cpp:24976
void SendCinematicStart(uint32 CinematicSequenceId) const
Definition: Player.cpp:6329
void SendCanTakeQuestResponse(QuestFailedReason reason, bool sendErrorMessage=true, std::string reasonText="") const
Definition: Player.cpp:17254
void SendUpdateWorldState(uint32 variable, uint32 value, bool hidden=false) const
Definition: Player.cpp:9174
std::vector< Item * > & GetItemUpdateQueue()
Definition: Player.h:1362
void SendPushToPartyResponse(Player const *player, QuestPushReason reason, Quest const *quest=nullptr) const
Definition: Player.cpp:17286
void UpdateObjectVisibility(bool forced=true) override
Definition: Player.cpp:24070
Item * GetItemByGuid(ObjectGuid guid) const
Definition: Player.cpp:9566
bool isDebugAreaTriggers
Definition: Player.h:2675
Team GetTeam() const
Definition: Player.h:2235
LocalizedString const * SpellName
Definition: SpellInfo.h:403
std::vector< std::pair< ObjectGuid, uint32 > > _redirectInfo
std::array< float, MAX_SPELL_SCHOOL > _singleSchoolModifiers
std::unordered_map< uint32, std::unordered_map< ObjectGuid, uint32 > > _redirectRegistry
auto const & GetThreatenedByMeList() const
bool IsThreatListEmpty(bool includeOffline=false) const
static bool CanHaveThreatList(Unit const *who)
Trinity::IteratorPair< ThreatListIterator, std::nullptr_t > GetSortedThreatList() const
std::unordered_map< std::underlying_type< SpellSchoolMask >::type, float > _multiSchoolModifiers
Unit * GetFixateTarget() const
void EnableMovement(bool enabled)
Definition: Transport.cpp:593
void Visit(TYPE_CONTAINER &c)
std::size_t Size() const
Definition: Unit.h:627
void EnterVehicle(Unit *base, int8 seatId=-1)
Definition: Unit.cpp:12118
bool IsVehicle() const
Definition: Unit.h:743
uint32 GetUnitMovementFlags() const
Definition: Unit.h:1664
ThreatManager & GetThreatManager()
Definition: Unit.h:1063
bool IsAlive() const
Definition: Unit.h:1164
float GetCombatReach() const override
Definition: Unit.h:694
void ModifyAuraState(AuraStateType flag, bool apply)
Definition: Unit.cpp:5894
bool IsAIEnabled() const
Definition: Unit.h:658
Unit * GetVictim() const
Definition: Unit.h:715
uint32 GetExtraUnitMovementFlags() const
Definition: Unit.h:1670
CombatManager & GetCombatManager()
Definition: Unit.h:1023
void SetExtraUnitMovementFlags(uint32 f)
Definition: Unit.h:1671
virtual bool IsEngaged() const
Definition: Unit.h:1019
ObjectGuid GetTarget() const
Definition: Unit.h:1759
bool IsInCombat() const
Definition: Unit.h:1043
Definition: Warden.h:85
virtual size_t DEBUG_ForceSpecificChecks(std::vector< uint16 > const &checks)=0
constexpr uint32 GetMapId() const
Definition: Position.h:201
TempSummon * SummonPersonalClone(Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, Player *privateObjectOwner=nullptr)
Definition: Object.cpp:2048
void PlayDirectSound(uint32 soundId, Player const *target=nullptr, uint32 broadcastTextId=0) const
Definition: Object.cpp:3592
virtual void SendMessageToSet(WorldPacket const *data, bool self) const
Definition: Object.cpp:1744
Map * GetMap() const
Definition: Object.h:624
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float relAngle=0) const
Definition: Object.cpp:3403
void PlayDirectMusic(uint32 musicId, Player const *target=nullptr) const
Definition: Object.cpp:3600
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition: Object.cpp:2025
Unit * GetOwner() const
Definition: Object.cpp:2229
TransportBase * GetTransport() const
Definition: Object.h:750
void PlayDistanceSound(uint32 soundId, Player const *target=nullptr) const
Definition: Object.cpp:3576
std::string const & GetName() const
Definition: Object.h:555
bool IsWithinLOSInMap(WorldObject const *obj, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
Definition: Object.cpp:1181
void DestroyForNearbyPlayers()
Definition: Object.cpp:3623
uint32 GetZoneId() const
Definition: Object.h:545
MovementInfo m_movementInfo
Definition: Object.h:761
void PlayObjectSound(int32 soundKitId, ObjectGuid targetObject, Player const *target=nullptr, int32 broadcastTextId=0) const
Definition: Object.cpp:3608
int32 GetDBPhase() const
Definition: Object.h:540
uint32 GetOpcode() const
Definition: WorldPacket.h:84
std::string _Channel
Channel Name.
WorldPacket const * Write() override
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string_view message, uint32 achievementId=0, std::string_view channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string_view addonPrefix="")
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
Player * GetPlayer() const
Warden * GetWarden()
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
static PersistentWorldVariable const NextMonthlyQuestResetTimeVarId
Definition: World.h:730
static PersistentWorldVariable const NextDailyQuestResetTimeVarId
Definition: World.h:731
static PersistentWorldVariable const NextWeeklyQuestResetTimeVarId
Definition: World.h:726
std::unordered_map< uint32, uint32 > creatureIds
Definition: cs_debug.cpp:1757
std::vector< std::pair< uint32, uint32 > > GetTopCreatureCount(uint32 count)
Definition: cs_debug.cpp:1741
void Visit(std::unordered_map< ObjectGuid, Creature * > &creatureMap)
Definition: cs_debug.cpp:1729
void Visit(std::unordered_map< ObjectGuid, T * > &)
Definition: cs_debug.cpp:1739
static bool HandleDebugThreatListCommand(ChatHandler *handler)
Definition: cs_debug.cpp:865
static bool HandleDebugGetItemStateCommand(ChatHandler *handler, std::string itemState)
Definition: cs_debug.cpp:587
static bool HandleDebugSendLargePacketCommand(ChatHandler *handler)
Definition: cs_debug.cpp:1103
static void HandleDebugGuidLimitsMap(ChatHandler *handler, Map *map)
Definition: cs_debug.cpp:1694
static bool HandleDebugPlayerConditionCommand(ChatHandler *handler, uint32 playerConditionId)
Definition: cs_debug.cpp:1608
static bool HandleDebugWardenForce(ChatHandler *handler, std::vector< uint16 > checkIds)
Definition: cs_debug.cpp:1651
static bool HandleDebugRaidResetCommand(ChatHandler *handler, uint32 mapId, Optional< uint32 > difficulty)
Definition: cs_debug.cpp:1351
static bool HandleDebugMoveflagsCommand(ChatHandler *handler, Optional< uint32 > moveFlags, Optional< uint32 > moveFlagsExtra)
Definition: cs_debug.cpp:1189
static bool HandleDebugSendChatMsgCommand(ChatHandler *handler, ChatMsg type)
Definition: cs_debug.cpp:549
static bool HandleDebugLoadCellsCommandHelper(ChatHandler *handler, Map *map, Optional< uint32 > tileX, Optional< uint32 > tileY)
Definition: cs_debug.cpp:1280
static bool HandleDebugAreaTriggersCommand(ChatHandler *handler)
Definition: cs_debug.cpp:523
static bool HandleDebugSendSellErrorCommand(ChatHandler *handler, SellResult error)
Definition: cs_debug.cpp:320
static bool HandleDebugSendSpellFailCommand(ChatHandler *handler, SpellCastResult result, Optional< int32 > failArg1, Optional< int32 > failArg2)
Definition: cs_debug.cpp:294
static bool HandleDebugTransportCommand(ChatHandler *handler, std::string operation)
Definition: cs_debug.cpp:1234
static bool HandleDebugGetLootRecipientCommand(ChatHandler *handler)
Definition: cs_debug.cpp:563
static bool HandleDebugLoSCommand(ChatHandler *handler)
Definition: cs_debug.cpp:1153
static bool HandleDebugPlayMovieCommand(ChatHandler *handler, uint32 movieId)
Definition: cs_debug.cpp:216
static bool HandleWPGPSCommand(ChatHandler *handler)
Definition: cs_debug.cpp:1224
static bool HandleDebugOutOfBounds(ChatHandler *handler)
Definition: cs_debug.cpp:1631
static bool HandleDebugSendOpcodeCommand(ChatHandler *handler)
Definition: cs_debug.cpp:332
static bool HandleDebugDummyCommand(ChatHandler *handler)
Definition: cs_debug.cpp:1789
static bool HandleDebugSendEquipErrorCommand(ChatHandler *handler, InventoryResult error)
Definition: cs_debug.cpp:314
static bool HandleDebugThreatInfoCommand(ChatHandler *handler)
Definition: cs_debug.cpp:950
static bool HandleDebugSpawnVehicleCommand(ChatHandler *handler, uint32 entry, Optional< uint32 > id)
Definition: cs_debug.cpp:1071
static bool HandleDebugPlayMusicCommand(ChatHandler *handler, uint32 musicId)
Definition: cs_debug.cpp:260
static bool HandleDebugWSExpressionCommand(ChatHandler *handler, uint32 expressionId)
Definition: cs_debug.cpp:1585
static bool HandleDebugBattlegroundCommand(ChatHandler *)
Definition: cs_debug.cpp:853
static bool HandleDebugSendBuyErrorCommand(ChatHandler *handler, BuyResult error)
Definition: cs_debug.cpp:326
static bool TryExtractTeamId(std::string const &args, TeamId &outFaction)
Definition: cs_debug.cpp:143
static bool HandleDebugPhaseCommand(ChatHandler *handler)
Definition: cs_debug.cpp:1331
static bool HandleDebugWarModeBalanceCommand(ChatHandler *handler, Variant< uint32, EXACT_SEQUENCE("alliance"), EXACT_SEQUENCE("horde"), EXACT_SEQUENCE("neutral"), EXACT_SEQUENCE("off")> command, Optional< int32 > rewardValue)
Definition: cs_debug.cpp:157
static bool HandleDebugObjectCountCommand(ChatHandler *handler, Optional< uint32 > mapId)
Definition: cs_debug.cpp:1700
static bool HandleDebugSendChannelNotifyCommand(ChatHandler *handler, ChatNotify type)
Definition: cs_debug.cpp:540
static bool HandleDebugSendQuestPartyMsgCommand(ChatHandler *handler, QuestPushReason msg)
Definition: cs_debug.cpp:557
static bool HandleDebugGuidLimitsCommand(ChatHandler *handler, Optional< uint32 > mapId)
Definition: cs_debug.cpp:1668
static bool HandleDebugCombatListCommand(ChatHandler *handler)
Definition: cs_debug.cpp:1025
static bool HandleDebugLoadCellsCommand(ChatHandler *handler, Optional< uint32 > mapId, Optional< uint32 > tileX, Optional< uint32 > tileY)
Definition: cs_debug.cpp:1260
static bool HandleDebugEnterVehicleCommand(ChatHandler *handler, uint32 entry, Optional< int8 > seatId)
Definition: cs_debug.cpp:1045
static bool HandleDebugSendPlayerChoiceCommand(ChatHandler *handler, int32 choiceId)
Definition: cs_debug.cpp:307
static bool HandleDebugMemoryLeak(ChatHandler *handler)
Definition: cs_debug.cpp:1642
static bool HandleDebugItemExpireCommand(ChatHandler *handler, ObjectGuid::LowType guid)
Definition: cs_debug.cpp:1129
static bool HandleDebugSendQuestInvalidMsgCommand(ChatHandler *handler, QuestFailedReason msg)
Definition: cs_debug.cpp:581
static bool HandleDebugQuestResetCommand(ChatHandler *handler, std::string arg)
Definition: cs_debug.cpp:1378
static bool HandleDebugPlayCinematicCommand(ChatHandler *handler, uint32 cinematicId)
Definition: cs_debug.cpp:188
static bool HandleDebugUpdateWorldStateCommand(ChatHandler *handler, uint32 variable, uint32 value)
Definition: cs_debug.cpp:517
static bool HandleDebugPlayObjectSoundCommand(ChatHandler *handler, int32 soundKitId, Optional< int32 > broadcastTextId)
Definition: cs_debug.cpp:277
static void HandleDebugObjectCountMap(ChatHandler *handler, Map *map)
Definition: cs_debug.cpp:1760
static bool HandleDebugArenaCommand(ChatHandler *)
Definition: cs_debug.cpp:859
static bool HandleDebugInstanceSpawns(ChatHandler *handler, Variant< uint32, EXACT_SEQUENCE("explain")> optArg)
Definition: cs_debug.cpp:1462
static bool HandleDebugNearGraveyard(ChatHandler *handler, Optional< EXACT_SEQUENCE("linked")> linked)
Definition: cs_debug.cpp:1414
static bool HandleDebugConversationCommand(ChatHandler *handler, uint32 conversationEntry)
Definition: cs_debug.cpp:1571
static bool HandleDebugAnimCommand(ChatHandler *handler, Emote emote)
Definition: cs_debug.cpp:1143
static bool HandleDebugBecomePersonalClone(ChatHandler *handler)
Definition: cs_debug.cpp:1778
static bool HandleDebugSendSetPhaseShiftCommand(ChatHandler *handler, Optional< uint32 > phaseId, Optional< uint32 > visibleMapId, Optional< uint32 > uiMapPhaseId)
Definition: cs_debug.cpp:1112
ChatCommandTable GetCommands() const override
Definition: cs_debug.cpp:70
static bool HandleDebugBoundaryCommand(ChatHandler *handler, Optional< EXACT_SEQUENCE("fill")> fill, Optional< uint32 > durationArg)
Definition: cs_debug.cpp:1311
static bool HandleDebugSetAuraStateCommand(ChatHandler *handler, Optional< AuraStateType > state, bool apply)
Definition: cs_debug.cpp:1167
static bool HandleDebugPlaySoundCommand(ChatHandler *handler, uint32 soundId, Optional< uint32 > broadcastTextId)
Definition: cs_debug.cpp:231
void AddSC_debug_commandscript()
Definition: cs_debug.cpp:1796
OpcodeServer
Definition: Opcodes.h:901
#define sWorld
Definition: World.h:931
@ CONFIG_RESPAWN_GUIDALERTLEVEL
Definition: World.h:432
@ CONFIG_RESPAWN_GUIDWARNLEVEL
Definition: World.h:431
void apply(T *val)
Definition: ByteConverter.h:41
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
constexpr std::size_t size()
Definition: UpdateField.h:796
@ RBAC_PERM_COMMAND_DEBUG
Definition: RBAC.h:214
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:203
std::array< uint16, 8 > Camera
Definition: DB2Structure.h:895
LocalizedString MapName
uint32 ID
bool IsDungeon() const
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
std::string ToString() const
Definition: Position.cpp:128
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
constexpr float GetOrientation() const
Definition: Position.h:79
constexpr float GetPositionZ() const
Definition: Position.h:78
std::string name
Definition: SpawnData.h:68
WorldLocation Loc
Definition: ObjectMgr.h:835