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