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