TrinityCore
cs_lookup.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: lookup_commandscript
20%Complete: 100
21Comment: All lookup related commands
22Category: commandscripts
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "AccountMgr.h"
27#include "Chat.h"
28#include "ChatCommand.h"
29#include "DatabaseEnv.h"
30#include "DB2Stores.h"
31#include "GameEventMgr.h"
32#include "ObjectMgr.h"
33#include "Player.h"
34#include "ReputationMgr.h"
35#include "SpellInfo.h"
36#include "SpellMgr.h"
37#include "World.h"
38#include "WorldSession.h"
39#include <sstream>
40
41#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
42#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
43#endif
44
45using namespace Trinity::ChatCommands;
46
48{
49public:
50 lookup_commandscript() : CommandScript("lookup_commandscript") { }
51
52 std::vector<ChatCommand> GetCommands() const override
53 {
54 static std::vector<ChatCommand> lookupPlayerCommandTable =
55 {
59 };
60
61 static std::vector<ChatCommand> lookupCommandTable =
62 {
73 { "player", lookupPlayerCommandTable },
82 };
83
84 static ChatCommandTable commandTable =
85 {
86 { "lookup", lookupCommandTable },
87 };
88 return commandTable;
89 }
90
91 static bool HandleLookupAreaCommand(ChatHandler* handler, char const* args)
92 {
93 if (!*args)
94 return false;
95
96 std::string namePart = args;
97 std::wstring wNamePart;
98
99 if (!Utf8toWStr(namePart, wNamePart))
100 return false;
101
102 bool found = false;
103 uint32 count = 0;
104 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
105
106 // converting string that we try to find to lower case
107 wstrToLower(wNamePart);
108
109 // Search in AreaTable.dbc
110 for (uint32 i = 0; i < sAreaTableStore.GetNumRows(); ++i)
111 {
112 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(i);
113 if (areaEntry)
114 {
115 LocaleConstant locale = handler->GetSessionDbcLocale();
116 std::string name = areaEntry->AreaName[locale];
117 if (name.empty())
118 continue;
119
120 if (!Utf8FitTo(name, wNamePart))
121 {
122 locale = LOCALE_enUS;
123 for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
124 {
125 if (locale == handler->GetSessionDbcLocale())
126 continue;
127
128 name = areaEntry->AreaName[locale];
129 if (name.empty())
130 continue;
131
132 if (Utf8FitTo(name, wNamePart))
133 break;
134 }
135 }
136
137 if (locale < TOTAL_LOCALES)
138 {
139 if (maxResults && count++ == maxResults)
140 {
142 return true;
143 }
144
145 // send area in "id - [name]" format
146 std::ostringstream ss;
147 if (handler->GetSession())
148 ss << i << " - |cffffffff|Harea:" << i << "|h[" << name << "]|h|r";
149 else
150 ss << i << " - " << name;
151
152 handler->SendSysMessage(ss.str().c_str());
153
154 if (!found)
155 found = true;
156 }
157 }
158 }
159
160 if (!found)
162
163 return true;
164 }
165
166 static bool HandleLookupCreatureCommand(ChatHandler* handler, char const* args)
167 {
168 if (!*args)
169 return false;
170
171 std::string namePart = args;
172 std::wstring wNamePart;
173
174 // converting string that we try to find to lower case
175 if (!Utf8toWStr(namePart, wNamePart))
176 return false;
177
178 wstrToLower(wNamePart);
179
180 bool found = false;
181 uint32 count = 0;
182 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
183
184 CreatureTemplateContainer const& ctc = sObjectMgr->GetCreatureTemplates();
185 for (auto const& creatureTemplatePair : ctc)
186 {
187 uint32 id = creatureTemplatePair.first;
188 uint8 localeIndex = handler->GetSessionDbLocaleIndex();
189 if (CreatureLocale const* creatureLocale = sObjectMgr->GetCreatureLocale(id))
190 {
191 if (creatureLocale->Name.size() > localeIndex && !creatureLocale->Name[localeIndex].empty())
192 {
193 std::string const& name = creatureLocale->Name[localeIndex];
194
195 if (Utf8FitTo(name, wNamePart))
196 {
197 if (maxResults && count++ == maxResults)
198 {
200 return true;
201 }
202
203 if (handler->GetSession())
204 handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str());
205 else
206 handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str());
207
208 if (!found)
209 found = true;
210
211 continue;
212 }
213 }
214 }
215
216 std::string const& name = creatureTemplatePair.second.Name;
217 if (name.empty())
218 continue;
219
220 if (Utf8FitTo(name, wNamePart))
221 {
222 if (maxResults && count++ == maxResults)
223 {
225 return true;
226 }
227
228 if (handler->GetSession())
229 handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str());
230 else
231 handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str());
232
233 if (!found)
234 found = true;
235 }
236 }
237
238 if (!found)
240
241 return true;
242 }
243
244 static bool HandleLookupEventCommand(ChatHandler* handler, char const* args)
245 {
246 if (!*args)
247 return false;
248
249 std::string namePart = args;
250 std::wstring wNamePart;
251
252 // converting string that we try to find to lower case
253 if (!Utf8toWStr(namePart, wNamePart))
254 return false;
255
256 wstrToLower(wNamePart);
257
258 bool found = false;
259 uint32 count = 0;
260 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
261
262 GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
263 GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
264
265 for (uint32 id = 0; id < events.size(); ++id)
266 {
267 GameEventData const& eventData = events[id];
268
269 std::string descr = eventData.description;
270 if (descr.empty())
271 continue;
272
273 if (Utf8FitTo(descr, wNamePart))
274 {
275 if (maxResults && count++ == maxResults)
276 {
278 return true;
279 }
280
281 char const* active = activeEvents.find(id) != activeEvents.end() ? handler->GetTrinityString(LANG_ACTIVE) : "";
282
283 if (handler->GetSession())
284 handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.description.c_str(), active);
285 else
286 handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.description.c_str(), active);
287
288 if (!found)
289 found = true;
290 }
291 }
292
293 if (!found)
295
296 return true;
297 }
298
299 static bool HandleLookupFactionCommand(ChatHandler* handler, char const* args)
300 {
301 if (!*args)
302 return false;
303
304 // Can be NULL at console call
305 Player* target = handler->getSelectedPlayer();
306
307 std::string namePart = args;
308 std::wstring wNamePart;
309
310 if (!Utf8toWStr(namePart, wNamePart))
311 return false;
312
313 // converting string that we try to find to lower case
314 wstrToLower (wNamePart);
315
316 bool found = false;
317 uint32 count = 0;
318 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
319
320 for (uint32 id = 0; id < sFactionStore.GetNumRows(); ++id)
321 {
322 FactionEntry const* factionEntry = sFactionStore.LookupEntry(id);
323 if (factionEntry)
324 {
325 FactionState const* factionState = target ? target->GetReputationMgr().GetState(factionEntry) : nullptr;
326
327 LocaleConstant locale = handler->GetSessionDbcLocale();
328 std::string name = factionEntry->Name[locale];
329 if (name.empty())
330 continue;
331
332 if (!Utf8FitTo(name, wNamePart))
333 {
334 locale = LOCALE_enUS;
335 for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
336 {
337 if (locale == handler->GetSessionDbcLocale())
338 continue;
339
340 name = factionEntry->Name[locale];
341 if (name.empty())
342 continue;
343
344 if (Utf8FitTo(name, wNamePart))
345 break;
346 }
347 }
348
349 if (locale < TOTAL_LOCALES)
350 {
351 if (maxResults && count++ == maxResults)
352 {
354 return true;
355 }
356
357 // send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format
358 // or "id - [faction] [no reputation]" format
359 std::ostringstream ss;
360 if (handler->GetSession())
361 ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << ' ' << localeNames[locale] << "]|h|r";
362 else
363 ss << id << " - " << name << ' ' << localeNames[locale];
364
365 if (factionState) // and then target != NULL also
366 {
367 std::string rankName = target->GetReputationMgr().GetReputationRankName(factionEntry);
368
369 ss << ' ' << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
370
371 if (factionState->Flags.HasFlag(ReputationFlags::Visible))
373 if (factionState->Flags.HasFlag(ReputationFlags::AtWar))
374 ss << handler->GetTrinityString(LANG_FACTION_ATWAR);
375 if (factionState->Flags.HasFlag(ReputationFlags::Peaceful))
377 if (factionState->Flags.HasFlag(ReputationFlags::Hidden))
379 if (factionState->Flags.HasFlag(ReputationFlags::Header))
381 if (factionState->Flags.HasFlag(ReputationFlags::Inactive))
383 }
384 else
386
387 handler->SendSysMessage(ss.str().c_str());
388
389 if (!found)
390 found = true;
391 }
392 }
393 }
394
395 if (!found)
397 return true;
398 }
399
400 static bool HandleLookupItemCommand(ChatHandler* handler, char const* args)
401 {
402 if (!*args)
403 return false;
404
405 std::string namePart = args;
406 std::wstring wNamePart;
407
408 // converting string that we try to find to lower case
409 if (!Utf8toWStr(namePart, wNamePart))
410 return false;
411
412 wstrToLower(wNamePart);
413
414 bool found = false;
415 uint32 count = 0;
416 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
417
418 // Search in ItemSparse
419 ItemTemplateContainer const& its = sObjectMgr->GetItemTemplateStore();
420 for (auto const& itemTemplatePair : its)
421 {
422 std::string name = itemTemplatePair.second.GetName(handler->GetSessionDbcLocale());
423 if (name.empty())
424 continue;
425
426 if (Utf8FitTo(name, wNamePart))
427 {
428 if (maxResults && count++ == maxResults)
429 {
431 return true;
432 }
433
434 if (handler->GetSession())
435 handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplatePair.first, itemTemplatePair.first, name.c_str());
436 else
437 handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplatePair.first, name.c_str());
438
439 if (!found)
440 found = true;
441 }
442 }
443
444 if (!found)
446
447 return true;
448 }
449
450 static bool HandleLookupItemIdCommand(ChatHandler* handler, char const* args)
451 {
452 if (!*args)
453 return false;
454
455 uint32 id = atoi((char*)args);
456
457 if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(id))
458 {
459 std::string name = itemTemplate->GetName(handler->GetSessionDbcLocale());
460
461 if (name.empty())
462 {
464 return true;
465 }
466
467 if (handler->GetSession())
468 handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str());
469 else
470 handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str());
471 }
472 else
474
475 return true;
476 }
477
478 static bool HandleLookupItemSetCommand(ChatHandler* handler, char const* args)
479 {
480 if (!*args)
481 return false;
482
483 std::string namePart = args;
484 std::wstring wNamePart;
485
486 if (!Utf8toWStr(namePart, wNamePart))
487 return false;
488
489 // converting string that we try to find to lower case
490 wstrToLower(wNamePart);
491
492 bool found = false;
493 uint32 count = 0;
494 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
495
496 // Search in ItemSet.dbc
497 for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++)
498 {
499 ItemSetEntry const* set = sItemSetStore.LookupEntry(id);
500 if (set)
501 {
502 LocaleConstant locale = handler->GetSessionDbcLocale();
503 std::string name = set->Name[locale];
504 if (name.empty())
505 continue;
506
507 if (!Utf8FitTo(name, wNamePart))
508 {
509 locale = LOCALE_enUS;
510 for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
511 {
512 if (locale == handler->GetSessionDbcLocale())
513 continue;
514
515 name = set->Name[locale];
516 if (name.empty())
517 continue;
518
519 if (Utf8FitTo(name, wNamePart))
520 break;
521 }
522 }
523
524 if (locale < TOTAL_LOCALES)
525 {
526 if (maxResults && count++ == maxResults)
527 {
529 return true;
530 }
531
532 // send item set in "id - [namedlink locale]" format
533 if (handler->GetSession())
534 handler->PSendSysMessage(LANG_ITEMSET_LIST_CHAT, id, id, name.c_str(), "");
535 else
536 handler->PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name.c_str(), "");
537
538 if (!found)
539 found = true;
540 }
541 }
542 }
543 if (!found)
545
546 return true;
547 }
548
549 static bool HandleLookupObjectCommand(ChatHandler* handler, char const* args)
550 {
551 if (!*args)
552 return false;
553
554 std::string namePart = args;
555 std::wstring wNamePart;
556
557 // converting string that we try to find to lower case
558 if (!Utf8toWStr(namePart, wNamePart))
559 return false;
560
561 wstrToLower(wNamePart);
562
563 bool found = false;
564 uint32 count = 0;
565 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
566
567 GameObjectTemplateContainer const& gotc = sObjectMgr->GetGameObjectTemplates();
568 for (auto const& gameObjectTemplatePair : gotc)
569 {
570 uint8 localeIndex = handler->GetSessionDbLocaleIndex();
571 if (GameObjectLocale const* objectLocalte = sObjectMgr->GetGameObjectLocale(gameObjectTemplatePair.first))
572 {
573 if (objectLocalte->Name.size() > localeIndex && !objectLocalte->Name[localeIndex].empty())
574 {
575 std::string const& name = objectLocalte->Name[localeIndex];
576 if (Utf8FitTo(name, wNamePart))
577 {
578 if (maxResults && count++ == maxResults)
579 {
581 return true;
582 }
583
584 if (handler->GetSession())
585 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplatePair.first, gameObjectTemplatePair.first, name.c_str());
586 else
587 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplatePair.first, name.c_str());
588
589 if (!found)
590 found = true;
591
592 continue;
593 }
594 }
595 }
596
597 std::string const& name = gameObjectTemplatePair.second.name;
598 if (name.empty())
599 continue;
600
601 if (Utf8FitTo(name, wNamePart))
602 {
603 if (maxResults && count++ == maxResults)
604 {
606 return true;
607 }
608
609 if (handler->GetSession())
610 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplatePair.first, gameObjectTemplatePair.first, name.c_str());
611 else
612 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplatePair.first, name.c_str());
613
614 if (!found)
615 found = true;
616 }
617 }
618
619 if (!found)
621
622 return true;
623 }
624
625 static bool HandleLookupQuestCommand(ChatHandler* handler, char const* args)
626 {
627 if (!*args)
628 return false;
629
630 // can be NULL at console call
631 Player* target = handler->getSelectedPlayerOrSelf();
632
633 std::string namePart = args;
634 std::wstring wNamePart;
635
636 // converting string that we try to find to lower case
637 if (!Utf8toWStr(namePart, wNamePart))
638 return false;
639
640 wstrToLower(wNamePart);
641
642 bool found = false;
643 uint32 count = 0;
644 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
645
646 ObjectMgr::QuestContainer const& questTemplates = sObjectMgr->GetQuestTemplates();
647 for (auto const& questTemplatePair : questTemplates)
648 {
649 uint8 localeIndex = handler->GetSessionDbLocaleIndex();
650 if (QuestTemplateLocale const* questLocale = sObjectMgr->GetQuestLocale(questTemplatePair.first))
651 {
652 if (questLocale->LogTitle.size() > localeIndex && !questLocale->LogTitle[localeIndex].empty())
653 {
654 std::string title = questLocale->LogTitle[localeIndex];
655
656 if (Utf8FitTo(title, wNamePart))
657 {
658 if (maxResults && count++ == maxResults)
659 {
661 return true;
662 }
663
664 char const* statusStr = "";
665
666 if (target)
667 {
668 switch (target->GetQuestStatus(questTemplatePair.first))
669 {
671 statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
672 break;
674 statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
675 break;
677 statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
678 break;
679 default:
680 break;
681 }
682 }
683
684 if (handler->GetSession())
685 {
686 int32 maxLevel = 0;
687 if (Optional<ContentTuningLevels> questLevels = sDB2Manager.GetContentTuningData(questTemplatePair.second->GetContentTuningId(),
688 handler->GetSession()->GetPlayer()->m_playerData->CtrOptions->ContentTuningConditionMask))
689 maxLevel = questLevels->MaxLevel;
690
691 int32 scalingFactionGroup = 0;
692 if (ContentTuningEntry const* contentTuning = sContentTuningStore.LookupEntry(questTemplatePair.second->GetContentTuningId()))
693 scalingFactionGroup = contentTuning->GetScalingFactionGroup();
694
695 handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, questTemplatePair.first, questTemplatePair.first,
696 handler->GetSession()->GetPlayer()->GetQuestLevel(questTemplatePair.second.get()),
697 handler->GetSession()->GetPlayer()->GetQuestMinLevel(questTemplatePair.second.get()),
698 maxLevel, scalingFactionGroup,
699 title.c_str(), statusStr);
700 }
701 else
702 handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, questTemplatePair.first, title.c_str(), statusStr);
703
704 if (!found)
705 found = true;
706
707 continue;
708 }
709 }
710 }
711
712 std::string title = questTemplatePair.second->GetLogTitle();
713 if (title.empty())
714 continue;
715
716 if (Utf8FitTo(title, wNamePart))
717 {
718 if (maxResults && count++ == maxResults)
719 {
721 return true;
722 }
723
724 char const* statusStr = "";
725
726 if (target)
727 {
728 switch (target->GetQuestStatus(questTemplatePair.first))
729 {
731 statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
732 break;
734 statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
735 break;
737 statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
738 break;
739 default:
740 break;
741 }
742 }
743
744 if (handler->GetSession())
745 {
746 int32 maxLevel = 0;
747 if (Optional<ContentTuningLevels> questLevels = sDB2Manager.GetContentTuningData(questTemplatePair.second->GetContentTuningId(),
748 handler->GetSession()->GetPlayer()->m_playerData->CtrOptions->ContentTuningConditionMask))
749 maxLevel = questLevels->MaxLevel;
750
751 int32 scalingFactionGroup = 0;
752 if (ContentTuningEntry const* contentTuning = sContentTuningStore.LookupEntry(questTemplatePair.second->GetContentTuningId()))
753 scalingFactionGroup = contentTuning->GetScalingFactionGroup();
754
755 handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, questTemplatePair.first, questTemplatePair.first,
756 handler->GetSession()->GetPlayer()->GetQuestLevel(questTemplatePair.second.get()),
757 handler->GetSession()->GetPlayer()->GetQuestMinLevel(questTemplatePair.second.get()),
758 maxLevel, scalingFactionGroup,
759 title.c_str(), statusStr);
760 }
761 else
762 handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, questTemplatePair.first, title.c_str(), statusStr);
763
764 if (!found)
765 found = true;
766 }
767 }
768
769 if (!found)
771
772 return true;
773 }
774
775 static bool HandleLookupQuestIdCommand(ChatHandler* handler, char const* args)
776 {
777 if (!*args)
778 return false;
779
780 uint32 id = atoi((char*)args);
781
782 // can be NULL at console call
783 Player* target = handler->getSelectedPlayerOrSelf();
784
785 if (Quest const* quest = sObjectMgr->GetQuestTemplate(id))
786 {
787 std::string title = quest->GetLogTitle();
788 if (title.empty())
789 {
791 return true;
792 }
793
794 char const* statusStr = "";
795
796 if (target)
797 {
798 switch (target->GetQuestStatus(id))
799 {
801 statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
802 break;
804 statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
805 break;
807 statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
808 break;
809 default:
810 break;
811 }
812 }
813
814 if (handler->GetSession())
815 {
816 int32 maxLevel = 0;
817 if (Optional<ContentTuningLevels> questLevels = sDB2Manager.GetContentTuningData(quest->GetContentTuningId(),
818 handler->GetSession()->GetPlayer()->m_playerData->CtrOptions->ContentTuningConditionMask))
819 maxLevel = questLevels->MaxLevel;
820
821 int32 scalingFactionGroup = 0;
822 if (ContentTuningEntry const* contentTuning = sContentTuningStore.LookupEntry(quest->GetContentTuningId()))
823 scalingFactionGroup = contentTuning->GetScalingFactionGroup();
824
825 handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, id, id,
826 handler->GetSession()->GetPlayer()->GetQuestLevel(quest),
827 handler->GetSession()->GetPlayer()->GetQuestMinLevel(quest),
828 maxLevel, scalingFactionGroup,
829 title.c_str(), statusStr);
830 }
831 else
832 handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, id, title.c_str(), statusStr);
833 }
834 else
836
837 return true;
838 }
839
840 static bool HandleLookupSkillCommand(ChatHandler* handler, char const* args)
841 {
842 if (!*args)
843 return false;
844
845 // can be NULL in console call
846 Player* target = handler->getSelectedPlayer();
847
848 std::string namePart = args;
849 std::wstring wNamePart;
850
851 if (!Utf8toWStr(namePart, wNamePart))
852 return false;
853
854 // converting string that we try to find to lower case
855 wstrToLower(wNamePart);
856
857 bool found = false;
858 uint32 count = 0;
859 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
860
861 // Search in SkillLine.dbc
862 for (uint32 id = 0; id < sSkillLineStore.GetNumRows(); id++)
863 {
864 SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(id);
865 if (skillInfo)
866 {
867 LocaleConstant locale = handler->GetSessionDbcLocale();
868 std::string name = skillInfo->DisplayName[locale];
869 if (name.empty())
870 continue;
871
872 if (!Utf8FitTo(name, wNamePart))
873 {
874 locale = LOCALE_enUS;
875 for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
876 {
877 if (locale == handler->GetSessionDbcLocale())
878 continue;
879
880 name = skillInfo->DisplayName[locale];
881 if (name.empty())
882 continue;
883
884 if (Utf8FitTo(name, wNamePart))
885 break;
886 }
887 }
888
889 if (locale < TOTAL_LOCALES)
890 {
891 if (maxResults && count++ == maxResults)
892 {
894 return true;
895 }
896
897 std::string valStr = "";
898 char const* knownStr = "";
899 if (target && target->HasSkill(id))
900 {
901 knownStr = handler->GetTrinityString(LANG_KNOWN);
902 uint32 curValue = target->GetPureSkillValue(id);
903 uint32 maxValue = target->GetPureMaxSkillValue(id);
904 uint32 permValue = target->GetSkillPermBonusValue(id);
905 uint32 tempValue = target->GetSkillTempBonusValue(id);
906
907 valStr = handler->PGetParseString(LANG_SKILL_VALUES, curValue, maxValue, permValue, tempValue);
908 }
909
910 // send skill in "id - [namedlink locale]" format
911 if (handler->GetSession())
912 handler->PSendSysMessage(LANG_SKILL_LIST_CHAT, id, id, name.c_str(), "", knownStr, valStr.c_str());
913 else
914 handler->PSendSysMessage(LANG_SKILL_LIST_CONSOLE, id, name.c_str(), "", knownStr, valStr.c_str());
915
916 if (!found)
917 found = true;
918 }
919 }
920 }
921 if (!found)
923
924 return true;
925 }
926
927 static bool HandleLookupSpellCommand(ChatHandler* handler, char const* args)
928 {
929 if (!*args)
930 return false;
931
932 // can be NULL at console call
933 Player* target = handler->getSelectedPlayer();
934
935 std::string namePart = args;
936 std::wstring wNamePart;
937
938 if (!Utf8toWStr(namePart, wNamePart))
939 return false;
940
941 // converting string that we try to find to lower case
942 wstrToLower(wNamePart);
943
944 bool found = false;
945 uint32 count = 0;
946 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
947
948 // Search in SpellName.dbc
949 for (SpellNameEntry const* spellName : sSpellNameStore)
950 {
951 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellName->ID, DIFFICULTY_NONE))
952 {
953 LocaleConstant locale = handler->GetSessionDbcLocale();
954 std::string name = spellInfo->SpellName->Str[locale];
955 if (name.empty())
956 continue;
957
958 if (!Utf8FitTo(name, wNamePart))
959 {
960 locale = LOCALE_enUS;
961 for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
962 {
963 if (locale == handler->GetSessionDbcLocale())
964 continue;
965
966 name = spellInfo->SpellName->Str[locale];
967 if (name.empty())
968 continue;
969
970 if (Utf8FitTo(name, wNamePart))
971 break;
972 }
973 }
974
975 if (locale < TOTAL_LOCALES)
976 {
977 if (maxResults && count++ == maxResults)
978 {
980 return true;
981 }
982
983 bool known = target && target->HasSpell(spellInfo->Id);
984
985 auto spellEffectInfo = std::find_if(spellInfo->GetEffects().begin(), spellInfo->GetEffects().end(), [](SpellEffectInfo const& spelleffectInfo)
986 {
987 return spelleffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL);
988 });
989
990 SpellInfo const* learnSpellInfo = spellEffectInfo != spellInfo->GetEffects().end() ? sSpellMgr->GetSpellInfo(spellEffectInfo->TriggerSpell, spellInfo->Difficulty) : nullptr;
991
992 bool talent = spellInfo->HasAttribute(SPELL_ATTR0_CU_IS_TALENT);
993 bool passive = spellInfo->IsPassive();
994 bool active = target && target->HasAura(spellInfo->Id);
995
996 // unit32 used to prevent interpreting uint8 as char at output
997 // find rank of learned spell for learning spell, or talent rank
998 uint32 rank = learnSpellInfo ? learnSpellInfo->GetRank() : spellInfo->GetRank();
999
1000 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
1001 std::ostringstream ss;
1002 if (handler->GetSession())
1003 ss << spellInfo->Id << " - |cffffffff|Hspell:" << spellInfo->Id << "|h[" << name;
1004 else
1005 ss << spellInfo->Id << " - " << name;
1006
1007 // include rank in link name
1008 if (rank)
1009 ss << handler->GetTrinityString(LANG_SPELL_RANK) << rank;
1010
1011 if (handler->GetSession())
1012 ss << "]|h|r";
1013
1014 if (talent)
1015 ss << handler->GetTrinityString(LANG_TALENT);
1016 if (passive)
1017 ss << handler->GetTrinityString(LANG_PASSIVE);
1018 if (learnSpellInfo)
1019 ss << handler->GetTrinityString(LANG_LEARN);
1020 if (known)
1021 ss << handler->GetTrinityString(LANG_KNOWN);
1022 if (active)
1023 ss << handler->GetTrinityString(LANG_ACTIVE);
1024
1025 handler->SendSysMessage(ss.str().c_str());
1026
1027 if (!found)
1028 found = true;
1029 }
1030 }
1031 }
1032 if (!found)
1034
1035 return true;
1036 }
1037
1038 static bool HandleLookupSpellIdCommand(ChatHandler* handler, char const* args)
1039 {
1040 if (!*args)
1041 return false;
1042
1043 // can be NULL at console call
1044 Player* target = handler->getSelectedPlayer();
1045
1046 uint32 id = atoi((char*)args);
1047
1048 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id, DIFFICULTY_NONE))
1049 {
1050 LocaleConstant locale = handler->GetSessionDbcLocale();
1051 std::string name = spellInfo->SpellName->Str[locale];
1052 if (name.empty())
1053 {
1055 return true;
1056 }
1057
1058 bool known = target && target->HasSpell(id);
1059
1060 auto spellEffectInfo = std::find_if(spellInfo->GetEffects().begin(), spellInfo->GetEffects().end(), [](SpellEffectInfo const& spelleffectInfo)
1061 {
1062 return spelleffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL);
1063 });
1064
1065 SpellInfo const* learnSpellInfo = spellEffectInfo != spellInfo->GetEffects().end() ? sSpellMgr->GetSpellInfo(spellEffectInfo->TriggerSpell, spellInfo->Difficulty) : nullptr;
1066
1067 bool talent = spellInfo->HasAttribute(SPELL_ATTR0_CU_IS_TALENT);
1068 bool passive = spellInfo->IsPassive();
1069 bool active = target && target->HasAura(id);
1070
1071 // unit32 used to prevent interpreting uint8 as char at output
1072 // find rank of learned spell for learning spell, or talent rank
1073 uint32 rank = learnSpellInfo ? learnSpellInfo->GetRank() : spellInfo->GetRank();
1074
1075 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
1076 std::ostringstream ss;
1077 if (handler->GetSession())
1078 ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name;
1079 else
1080 ss << id << " - " << name;
1081
1082 // include rank in link name
1083 if (rank)
1084 ss << handler->GetTrinityString(LANG_SPELL_RANK) << rank;
1085
1086 if (handler->GetSession())
1087 ss << ' ' << localeNames[locale] << "]|h|r";
1088 else
1089 ss << ' ' << localeNames[locale];
1090
1091 if (talent)
1092 ss << handler->GetTrinityString(LANG_TALENT);
1093 if (passive)
1094 ss << handler->GetTrinityString(LANG_PASSIVE);
1095 if (learnSpellInfo)
1096 ss << handler->GetTrinityString(LANG_LEARN);
1097 if (known)
1098 ss << handler->GetTrinityString(LANG_KNOWN);
1099 if (active)
1100 ss << handler->GetTrinityString(LANG_ACTIVE);
1101
1102 handler->SendSysMessage(ss.str().c_str());
1103 }
1104 else
1106
1107 return true;
1108 }
1109
1110 static bool HandleLookupTaxiNodeCommand(ChatHandler* handler, const char * args)
1111 {
1112 if (!*args)
1113 return false;
1114
1115 std::string namePart = args;
1116 std::wstring wNamePart;
1117
1118 if (!Utf8toWStr(namePart, wNamePart))
1119 return false;
1120
1121 // converting string that we try to find to lower case
1122 wstrToLower(wNamePart);
1123
1124 bool found = false;
1125 uint32 count = 0;
1126 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1127 LocaleConstant locale = handler->GetSessionDbcLocale();
1128
1129 // Search in TaxiNodes.dbc
1130 for (TaxiNodesEntry const* nodeEntry : sTaxiNodesStore)
1131 {
1132 std::string name = nodeEntry->Name[locale];
1133 if (name.empty())
1134 continue;
1135
1136 if (!Utf8FitTo(name, wNamePart))
1137 continue;
1138
1139 if (maxResults && count++ == maxResults)
1140 {
1142 return true;
1143 }
1144
1145 // send taxinode in "id - [name] (Map:m X:x Y:y Z:z)" format
1146 if (handler->GetSession())
1147 handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CHAT, nodeEntry->ID, nodeEntry->ID, name.c_str(), "",
1148 uint32(nodeEntry->ContinentID), nodeEntry->Pos.X, nodeEntry->Pos.Y, nodeEntry->Pos.Z);
1149 else
1150 handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CONSOLE, nodeEntry->ID, name.c_str(), "",
1151 uint32(nodeEntry->ContinentID), nodeEntry->Pos.X, nodeEntry->Pos.Y, nodeEntry->Pos.Z);
1152
1153 if (!found)
1154 found = true;
1155 }
1156 if (!found)
1158
1159 return true;
1160 }
1161
1162 // Find tele in game_tele order by name
1163 static bool HandleLookupTeleCommand(ChatHandler* handler, char const* args)
1164 {
1165 if (!*args)
1166 {
1168 handler->SetSentErrorMessage(true);
1169 return false;
1170 }
1171
1172 char const* str = strtok((char*)args, " ");
1173 if (!str)
1174 return false;
1175
1176 std::string namePart = str;
1177 std::wstring wNamePart;
1178
1179 if (!Utf8toWStr(namePart, wNamePart))
1180 return false;
1181
1182 // converting string that we try to find to lower case
1183 wstrToLower(wNamePart);
1184
1185 std::ostringstream reply;
1186 uint32 count = 0;
1187 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1188 bool limitReached = false;
1189
1190 GameTeleContainer const & teleMap = sObjectMgr->GetGameTeleMap();
1191 for (GameTeleContainer::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr)
1192 {
1193 GameTele const* tele = &itr->second;
1194
1195 if (tele->wnameLow.find(wNamePart) == std::wstring::npos)
1196 continue;
1197
1198 if (maxResults && count++ == maxResults)
1199 {
1200 limitReached = true;
1201 break;
1202 }
1203
1204 if (handler->GetSession())
1205 reply << " |cffffffff|Htele:" << itr->first << "|h[" << tele->name << "]|h|r\n";
1206 else
1207 reply << " " << itr->first << ' ' << tele->name << "\n";
1208 }
1209
1210 if (reply.str().empty())
1212 else
1213 handler->PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str().c_str());
1214
1215 if (limitReached)
1217
1218 return true;
1219 }
1220
1221 static bool HandleLookupTitleCommand(ChatHandler* handler, char const* args)
1222 {
1223 if (!*args)
1224 return false;
1225
1226 // can be NULL in console call
1227 Player* target = handler->getSelectedPlayer();
1228
1229 // title name have single string arg for player name
1230 char const* targetName = target ? target->GetName().c_str() : "NAME";
1231
1232 std::string namePart = args;
1233 std::wstring wNamePart;
1234
1235 if (!Utf8toWStr(namePart, wNamePart))
1236 return false;
1237
1238 // converting string that we try to find to lower case
1239 wstrToLower(wNamePart);
1240
1241 uint32 counter = 0; // Counter for figure out that we found smth.
1242 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1243
1244 // Search in CharTitles.dbc
1245 for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++)
1246 {
1247 if (CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id))
1248 {
1249 for (uint8 gender = GENDER_MALE; gender <= GENDER_FEMALE; ++gender)
1250 {
1251 if (target && target->GetGender() != gender)
1252 continue;
1253
1254 LocaleConstant locale = handler->GetSessionDbcLocale();
1255 std::string name = (gender == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[locale];
1256
1257 if (name.empty())
1258 continue;
1259
1260 if (!Utf8FitTo(name, wNamePart))
1261 {
1262 locale = LOCALE_enUS;
1263 for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
1264 {
1265 if (locale == handler->GetSessionDbcLocale())
1266 continue;
1267
1268 name = (gender == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[locale];
1269 if (name.empty())
1270 continue;
1271
1272 if (Utf8FitTo(name, wNamePart))
1273 break;
1274 }
1275 }
1276
1277 if (locale < TOTAL_LOCALES)
1278 {
1279 if (maxResults && counter == maxResults)
1280 {
1282 return true;
1283 }
1284
1285 char const* knownStr = target && target->HasTitle(titleInfo) ? handler->GetTrinityString(LANG_KNOWN) : "";
1286
1287 char const* activeStr = target && *target->m_playerData->PlayerTitle == titleInfo->MaskID
1288 ? handler->GetTrinityString(LANG_ACTIVE)
1289 : "";
1290
1291 std::string titleNameStr = fmt::sprintf(name, targetName);
1292
1293 // send title in "id (idx:idx) - [namedlink locale]" format
1294 if (handler->GetSession())
1295 handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->MaskID, id, titleNameStr.c_str(), "", knownStr, activeStr);
1296 else
1297 handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->MaskID, titleNameStr.c_str(), "", knownStr, activeStr);
1298
1299 ++counter;
1300 }
1301 }
1302 }
1303 }
1304 if (counter == 0) // if counter == 0 then we found nth
1306
1307 return true;
1308 }
1309
1310 static bool HandleLookupMapCommand(ChatHandler* handler, char const* args)
1311 {
1312 if (!*args)
1313 return false;
1314
1315 std::string namePart = args;
1316 std::wstring wNamePart;
1317
1318 if (!Utf8toWStr(namePart, wNamePart))
1319 return false;
1320
1321 wstrToLower(wNamePart);
1322
1323 uint32 counter = 0;
1324 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1325 LocaleConstant locale = handler->GetSessionDbcLocale();
1326
1327 // search in Map.dbc
1328 for (uint32 id = 0; id < sMapStore.GetNumRows(); id++)
1329 {
1330 if (MapEntry const* mapInfo = sMapStore.LookupEntry(id))
1331 {
1332 std::string name = mapInfo->MapName[locale];
1333 if (name.empty())
1334 continue;
1335
1336 if (!Utf8FitTo(name, wNamePart) && handler->GetSession())
1337 {
1338 locale = LOCALE_enUS;
1339 for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
1340 {
1341 if (locale == handler->GetSessionDbcLocale())
1342 continue;
1343
1344 name = mapInfo->MapName[locale];
1345 if (name.empty())
1346 continue;
1347
1348 if (Utf8FitTo(name, wNamePart))
1349 break;
1350 }
1351 }
1352
1353 if (locale < TOTAL_LOCALES)
1354 {
1355 if (maxResults && counter == maxResults)
1356 {
1358 return true;
1359 }
1360
1361 std::ostringstream ss;
1362 ss << id << " - [" << name << ']';
1363
1364 if (mapInfo->IsContinent())
1365 ss << handler->GetTrinityString(LANG_CONTINENT);
1366
1367 switch (mapInfo->InstanceType)
1368 {
1369 case MAP_INSTANCE:
1370 ss << handler->GetTrinityString(LANG_INSTANCE);
1371 break;
1372 case MAP_RAID:
1373 ss << handler->GetTrinityString(LANG_RAID);
1374 break;
1375 case MAP_BATTLEGROUND:
1376 ss << handler->GetTrinityString(LANG_BATTLEGROUND);
1377 break;
1378 case MAP_ARENA:
1379 ss << handler->GetTrinityString(LANG_ARENA);
1380 break;
1381 case MAP_SCENARIO:
1382 ss << handler->GetTrinityString(LANG_SCENARIO);
1383 break;
1384 }
1385
1386 handler->SendSysMessage(ss.str().c_str());
1387
1388 ++counter;
1389 }
1390 }
1391 }
1392
1393 if (!counter)
1395
1396 return true;
1397 }
1398
1399 static bool HandleLookupMapIdCommand(ChatHandler* handler, char const* args)
1400 {
1401 if (!*args)
1402 return false;
1403
1404 uint32 id = atoi((char*)args);
1405
1406 if (MapEntry const* mapInfo = sMapStore.LookupEntry(id))
1407 {
1408 LocaleConstant locale = handler->GetSession() ? handler->GetSession()->GetSessionDbcLocale() : sWorld->GetDefaultDbcLocale();
1409 std::string name = mapInfo->MapName[locale];
1410 if (name.empty())
1411 {
1413 return true;
1414 }
1415
1416 std::ostringstream ss;
1417 ss << id << " - [" << name << ']';
1418
1419 if (mapInfo->IsContinent())
1420 ss << handler->GetTrinityString(LANG_CONTINENT);
1421
1422 switch (mapInfo->InstanceType)
1423 {
1424 case MAP_INSTANCE:
1425 ss << handler->GetTrinityString(LANG_INSTANCE);
1426 break;
1427 case MAP_RAID:
1428 ss << handler->GetTrinityString(LANG_RAID);
1429 break;
1430 case MAP_BATTLEGROUND:
1431 ss << handler->GetTrinityString(LANG_BATTLEGROUND);
1432 break;
1433 case MAP_ARENA:
1434 ss << handler->GetTrinityString(LANG_ARENA);
1435 break;
1436 case MAP_SCENARIO:
1437 ss << handler->GetTrinityString(LANG_SCENARIO);
1438 break;
1439 }
1440
1441 handler->SendSysMessage(ss.str().c_str());
1442 }
1443 else
1445
1446 return true;
1447 }
1448
1449 static bool HandleLookupPlayerIpCommand(ChatHandler* handler, char const* args)
1450 {
1451 std::string ip;
1452 int32 limit;
1453 char* limitStr;
1454
1455 Player* target = handler->getSelectedPlayer();
1456 if (!*args)
1457 {
1458 // NULL only if used from console
1459 if (!target || target == handler->GetSession()->GetPlayer())
1460 return false;
1461
1462 ip = target->GetSession()->GetRemoteAddress();
1463 limit = -1;
1464 }
1465 else
1466 {
1467 ip = strtok((char*)args, " ");
1468 limitStr = strtok(nullptr, " ");
1469 limit = limitStr ? atoi(limitStr) : -1;
1470 }
1471
1473 stmt->setString(0, ip);
1474 PreparedQueryResult result = LoginDatabase.Query(stmt);
1475
1476 return LookupPlayerSearchCommand(result, limit, handler);
1477 }
1478
1479 static bool HandleLookupPlayerAccountCommand(ChatHandler* handler, char const* args)
1480 {
1481 if (!*args)
1482 return false;
1483
1484 std::string account = strtok((char*)args, " ");
1485 char* limitStr = strtok(nullptr, " ");
1486 int32 limit = limitStr ? atoi(limitStr) : -1;
1487
1488 if (!Utf8ToUpperOnlyLatin(account))
1489 return false;
1490
1492 stmt->setString(0, account);
1493 PreparedQueryResult result = LoginDatabase.Query(stmt);
1494
1495 return LookupPlayerSearchCommand(result, limit, handler);
1496 }
1497
1498 static bool HandleLookupPlayerEmailCommand(ChatHandler* handler, char const* args)
1499 {
1500 if (!*args)
1501 return false;
1502
1503 std::string email = strtok((char*)args, " ");
1504 char* limitStr = strtok(nullptr, " ");
1505 int32 limit = limitStr ? atoi(limitStr) : -1;
1506
1508 stmt->setString(0, email);
1509 PreparedQueryResult result = LoginDatabase.Query(stmt);
1510
1511 return LookupPlayerSearchCommand(result, limit, handler);
1512 }
1513
1515 {
1516 if (!result)
1517 {
1519 handler->SetSentErrorMessage(true);
1520 return false;
1521 }
1522
1523 int32 counter = 0;
1524 uint32 count = 0;
1525 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1526
1527 do
1528 {
1529 if (maxResults && count++ == maxResults)
1530 {
1532 return true;
1533 }
1534
1535 Field* fields = result->Fetch();
1536 uint32 accountId = fields[0].GetUInt32();
1537 std::string accountName = fields[1].GetString();
1538
1540 stmt->setUInt32(0, accountId);
1541 PreparedQueryResult result2 = CharacterDatabase.Query(stmt);
1542
1543 if (result2)
1544 {
1545 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, accountName.c_str(), accountId);
1546
1547 do
1548 {
1549 Field* characterFields = result2->Fetch();
1550 ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(characterFields[0].GetUInt64());
1551 std::string name = characterFields[1].GetString();
1552 uint8 online = characterFields[2].GetUInt8();
1553
1554 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name.c_str(), guid.ToString().c_str(), online ? handler->GetTrinityString(LANG_ONLINE) : "");
1555 ++counter;
1556 }
1557 while (result2->NextRow() && (limit == -1 || counter < limit));
1558 }
1559 }
1560 while (result->NextRow());
1561
1562 if (counter == 0) // empty accounts only
1563 {
1565 handler->SetSentErrorMessage(true);
1566 return false;
1567 }
1568
1569 return true;
1570 }
1571};
1572
1574{
1576}
@ CHAR_SEL_CHAR_GUID_NAME_BY_ACC
char const * localeNames[TOTAL_LOCALES]
Definition: Common.cpp:20
LocaleConstant
Definition: Common.h:48
@ TOTAL_LOCALES
Definition: Common.h:62
@ LOCALE_enUS
Definition: Common.h:49
DB2Storage< SkillLineEntry > sSkillLineStore("SkillLine.db2", &SkillLineLoadInfo::Instance)
DB2Storage< SpellNameEntry > sSpellNameStore("SpellName.db2", &SpellNameLoadInfo::Instance)
DB2Storage< MapEntry > sMapStore("Map.db2", &MapLoadInfo::Instance)
DB2Storage< TaxiNodesEntry > sTaxiNodesStore("TaxiNodes.db2", &TaxiNodesLoadInfo::Instance)
DB2Storage< CharTitlesEntry > sCharTitlesStore("CharTitles.db2", &CharTitlesLoadInfo::Instance)
DB2Storage< ItemSetEntry > sItemSetStore("ItemSet.db2", &ItemSetLoadInfo::Instance)
DB2Storage< ContentTuningEntry > sContentTuningStore("ContentTuning.db2", &ContentTuningLoadInfo::Instance)
DB2Storage< AreaTableEntry > sAreaTableStore("AreaTable.db2", &AreaTableLoadInfo::Instance)
DB2Storage< FactionEntry > sFactionStore("Faction.db2", &FactionLoadInfo::Instance)
#define sDB2Manager
Definition: DB2Stores.h:538
@ MAP_SCENARIO
Definition: DBCEnums.h:1233
@ MAP_BATTLEGROUND
Definition: DBCEnums.h:1231
@ MAP_ARENA
Definition: DBCEnums.h:1232
@ MAP_INSTANCE
Definition: DBCEnums.h:1229
@ MAP_RAID
Definition: DBCEnums.h:1230
@ DIFFICULTY_NONE
Definition: DBCEnums.h:874
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
#define sGameEventMgr
Definition: GameEventMgr.h:177
@ LANG_FACTION_PEACE_FORCED
Definition: Language.h:370
@ LANG_COMMAND_TELE_PARAMETER
Definition: Language.h:206
@ LANG_COMMAND_NOAREAFOUND
Definition: Language.h:502
@ LANG_ITEM_LIST_CHAT
Definition: Language.h:583
@ LANG_COMMAND_TELE_LOCATION
Definition: Language.h:209
@ LANG_FACTION_ATWAR
Definition: Language.h:369
@ LANG_COMMAND_QUEST_REWARDED
Definition: Language.h:535
@ LANG_EVENT_ENTRY_LIST_CONSOLE
Definition: Language.h:876
@ LANG_COMMAND_NOTAXINODEFOUND
Definition: Language.h:526
@ LANG_SKILL_LIST_CHAT
Definition: Language.h:592
@ LANG_GO_ENTRY_LIST_CONSOLE
Definition: Language.h:880
@ LANG_COMMAND_TELE_NOLOCATION
Definition: Language.h:207
@ LANG_ITEMSET_LIST_CHAT
Definition: Language.h:589
@ LANG_KNOWN
Definition: Language.h:63
@ LANG_EVENT_ENTRY_LIST_CHAT
Definition: Language.h:668
@ LANG_COMMAND_NOCREATUREFOUND
Definition: Language.h:507
@ LANG_CREATURE_ENTRY_LIST_CONSOLE
Definition: Language.h:877
@ LANG_FACTION_NOREPUTATION
Definition: Language.h:383
@ LANG_SKILL_LIST_CONSOLE
Definition: Language.h:882
@ LANG_TALENT
Definition: Language.h:66
@ LANG_FACTION_INVISIBLE_FORCED
Definition: Language.h:372
@ LANG_COMMAND_NOITEMFOUND
Definition: Language.h:496
@ LANG_QUEST_LIST_CONSOLE
Definition: Language.h:881
@ LANG_COMMAND_QUEST_ACTIVE
Definition: Language.h:537
@ LANG_LOOKUP_PLAYER_CHARACTER
Definition: Language.h:385
@ LANG_GO_ENTRY_LIST_CHAT
Definition: Language.h:587
@ LANG_LEARN
Definition: Language.h:64
@ LANG_COMMAND_NOMAPFOUND
Definition: Language.h:1068
@ LANG_TITLE_LIST_CHAT
Definition: Language.h:405
@ LANG_BATTLEGROUND
Definition: Language.h:1071
@ LANG_COMMAND_NOSKILLFOUND
Definition: Language.h:504
@ LANG_COMMAND_NOTITLEFOUND
Definition: Language.h:407
@ LANG_COMMAND_NOITEMSETFOUND
Definition: Language.h:503
@ LANG_TAXINODE_ENTRY_LIST_CHAT
Definition: Language.h:901
@ LANG_FACTION_HIDDEN
Definition: Language.h:371
@ LANG_COMMAND_NOSPELLFOUND
Definition: Language.h:505
@ LANG_COMMAND_LOOKUP_MAX_RESULTS
Definition: Language.h:1085
@ LANG_COMMAND_NOQUESTFOUND
Definition: Language.h:506
@ LANG_ARENA
Definition: Language.h:1072
@ LANG_INSTANCE
Definition: Language.h:1070
@ LANG_COMMAND_FACTION_NOTFOUND
Definition: Language.h:363
@ LANG_COMMAND_NOGAMEOBJECTFOUND
Definition: Language.h:508
@ LANG_ACTIVE
Definition: Language.h:67
@ LANG_SPELL_RANK
Definition: Language.h:62
@ LANG_TAXINODE_ENTRY_LIST_CONSOLE
Definition: Language.h:902
@ LANG_COMMAND_QUEST_COMPLETE
Definition: Language.h:536
@ LANG_CONTINENT
Definition: Language.h:1069
@ LANG_SKILL_VALUES
Definition: Language.h:895
@ LANG_NOEVENTFOUND
Definition: Language.h:669
@ LANG_TITLE_LIST_CONSOLE
Definition: Language.h:406
@ LANG_PASSIVE
Definition: Language.h:65
@ LANG_ITEMSET_LIST_CONSOLE
Definition: Language.h:879
@ LANG_LOOKUP_PLAYER_ACCOUNT
Definition: Language.h:384
@ LANG_NO_PLAYERS_FOUND
Definition: Language.h:386
@ LANG_RAID
Definition: Language.h:1073
@ LANG_CREATURE_ENTRY_LIST_CHAT
Definition: Language.h:585
@ LANG_FACTION_INACTIVE
Definition: Language.h:373
@ LANG_SCENARIO
Definition: Language.h:1152
@ LANG_FACTION_VISIBLE
Definition: Language.h:368
@ LANG_ITEM_LIST_CONSOLE
Definition: Language.h:878
@ LANG_QUEST_LIST_CHAT
Definition: Language.h:584
@ LANG_ONLINE
Definition: Language.h:80
@ LOGIN_SEL_ACCOUNT_LIST_BY_EMAIL
Definition: LoginDatabase.h:46
@ LOGIN_SEL_ACCOUNT_BY_IP
Definition: LoginDatabase.h:47
@ LOGIN_SEL_ACCOUNT_LIST_BY_NAME
Definition: LoginDatabase.h:44
std::unordered_map< uint32, ItemTemplate > ItemTemplateContainer
Definition: ObjectMgr.h:518
std::unordered_map< uint32, GameObjectTemplate > GameObjectTemplateContainer
Definition: ObjectMgr.h:506
std::unordered_map< uint32, GameTele > GameTeleContainer
Definition: ObjectMgr.h:172
#define sObjectMgr
Definition: ObjectMgr.h:1946
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition: ObjectMgr.h:495
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
@ QUEST_STATUS_REWARDED
Definition: QuestDef.h:148
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:145
@ QUEST_STATUS_COMPLETE
Definition: QuestDef.h:143
@ GENDER_MALE
@ GENDER_FEMALE
@ SPELL_ATTR0_CU_IS_TALENT
Definition: SpellInfo.h:171
#define sSpellMgr
Definition: SpellMgr.h:849
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:795
void wstrToLower(std::wstring &str)
Definition: Util.cpp:480
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition: Util.cpp:750
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:383
Player * getSelectedPlayerOrSelf()
Definition: Chat.cpp:244
virtual LocaleConstant GetSessionDbLocaleIndex() const
Definition: Chat.cpp:597
Player * getSelectedPlayer()
Definition: Chat.cpp:200
WorldSession * GetSession()
Definition: Chat.h:42
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:592
std::string PGetParseString(uint32 entry, Args &&... args) const
Definition: Chat.h:69
void PSendSysMessage(const char *fmt, Args &&... args)
Definition: Chat.h:57
void SetSentErrorMessage(bool val)
Definition: Chat.h:114
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:113
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:48
constexpr bool HasFlag(T flag) const
Definition: EnumFlag.h:106
Class used to access individual fields of database query result.
Definition: Field.h:90
uint8 GetUInt8() const
Definition: Field.cpp:30
std::string GetString() const
Definition: Field.cpp:118
uint32 GetUInt32() const
Definition: Field.cpp:62
std::vector< GameEventData > GameEventDataMap
Definition: GameEventMgr.h:103
std::set< uint16 > ActiveEvents
Definition: GameEventMgr.h:102
std::string ToString() const
Definition: ObjectGuid.cpp:554
std::unordered_map< uint32, Trinity::unique_trackable_ptr< Quest > > QuestContainer
Definition: ObjectMgr.h:1071
int32 GetQuestLevel(Quest const *quest) const
Definition: Player.cpp:14450
UF::UpdateField< UF::PlayerData, 0, TYPEID_PLAYER > m_playerData
Definition: Player.h:2863
bool HasTitle(uint32 bitIndex) const
Definition: Player.cpp:26268
uint16 GetPureSkillValue(uint32 skill) const
Definition: Player.cpp:6108
int16 GetSkillTempBonusValue(uint32 skill) const
Definition: Player.cpp:6132
int16 GetSkillPermBonusValue(uint32 skill) const
Definition: Player.cpp:6120
WorldSession * GetSession() const
Definition: Player.h:2101
bool HasSkill(uint32 skill) const
Definition: Player.cpp:6031
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition: Player.cpp:6082
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:16050
bool HasSpell(uint32 spell) const override
Definition: Player.cpp:3792
int32 GetQuestMinLevel(Quest const *quest) const
Definition: Player.cpp:14429
ReputationMgr & GetReputationMgr()
Definition: Player.h:2251
void setUInt32(const uint8 index, const uint32 value)
void setString(const uint8 index, const std::string &value)
std::string GetReputationRankName(FactionEntry const *factionEntry) const
int32 GetReputation(uint32 faction_id) const
FactionState const * GetState(FactionEntry const *factionEntry) const
uint8 GetRank() const
Definition: SpellInfo.cpp:4265
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:576
Gender GetGender() const
Definition: Unit.h:755
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
std::string const & GetName() const
Definition: Object.h:555
LocaleConstant GetSessionDbcLocale() const
Player * GetPlayer() const
std::string const & GetRemoteAddress() const
std::vector< ChatCommand > GetCommands() const override
Definition: cs_lookup.cpp:52
static bool HandleLookupItemIdCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:450
static bool HandleLookupPlayerAccountCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1479
static bool HandleLookupSkillCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:840
static bool HandleLookupItemCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:400
static bool HandleLookupSpellIdCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1038
static bool HandleLookupPlayerEmailCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1498
static bool HandleLookupFactionCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:299
static bool HandleLookupPlayerIpCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1449
static bool HandleLookupMapCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1310
static bool HandleLookupAreaCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:91
static bool HandleLookupTaxiNodeCommand(ChatHandler *handler, const char *args)
Definition: cs_lookup.cpp:1110
static bool LookupPlayerSearchCommand(PreparedQueryResult result, int32 limit, ChatHandler *handler)
Definition: cs_lookup.cpp:1514
static bool HandleLookupItemSetCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:478
static bool HandleLookupQuestIdCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:775
static bool HandleLookupObjectCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:549
static bool HandleLookupCreatureCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:166
static bool HandleLookupSpellCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:927
static bool HandleLookupQuestCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:625
static bool HandleLookupTitleCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1221
static bool HandleLookupMapIdCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1399
static bool HandleLookupEventCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:244
static bool HandleLookupTeleCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1163
void AddSC_lookup_commandscript()
Definition: cs_lookup.cpp:1573
#define sWorld
Definition: World.h:931
@ CONFIG_MAX_RESULTS_LOOKUP_COMMANDS
Definition: World.h:376
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
@ RBAC_PERM_COMMAND_LOOKUP_QUEST
Definition: RBAC.h:322
@ RBAC_PERM_COMMAND_LOOKUP_EVENT
Definition: RBAC.h:317
@ RBAC_PERM_COMMAND_LOOKUP_SPELL
Definition: RBAC.h:328
@ RBAC_PERM_COMMAND_LOOKUP_PLAYER_EMAIL
Definition: RBAC.h:326
@ RBAC_PERM_COMMAND_LOOKUP_OBJECT
Definition: RBAC.h:321
@ RBAC_PERM_COMMAND_LOOKUP_AREA
Definition: RBAC.h:315
@ RBAC_PERM_COMMAND_LOOKUP_ITEMSET
Definition: RBAC.h:320
@ RBAC_PERM_COMMAND_LOOKUP_FACTION
Definition: RBAC.h:318
@ RBAC_PERM_COMMAND_LOOKUP_TELE
Definition: RBAC.h:331
@ RBAC_PERM_COMMAND_LOOKUP_PLAYER_IP
Definition: RBAC.h:324
@ RBAC_PERM_COMMAND_LOOKUP_QUEST_ID
Definition: RBAC.h:746
@ RBAC_PERM_COMMAND_LOOKUP_ITEM_ID
Definition: RBAC.h:745
@ RBAC_PERM_COMMAND_LOOKUP_SPELL_ID
Definition: RBAC.h:329
@ RBAC_PERM_COMMAND_LOOKUP_SKILL
Definition: RBAC.h:327
@ RBAC_PERM_COMMAND_LOOKUP_CREATURE
Definition: RBAC.h:316
@ RBAC_PERM_COMMAND_LOOKUP_TITLE
Definition: RBAC.h:332
@ RBAC_PERM_COMMAND_LOOKUP_MAP_ID
Definition: RBAC.h:744
@ RBAC_PERM_COMMAND_LOOKUP_PLAYER_ACCOUNT
Definition: RBAC.h:325
@ RBAC_PERM_COMMAND_LOOKUP_ITEM
Definition: RBAC.h:319
@ RBAC_PERM_COMMAND_LOOKUP_MAP
Definition: RBAC.h:333
@ RBAC_PERM_COMMAND_LOOKUP_TAXINODE
Definition: RBAC.h:330
LocalizedString AreaName
Definition: DB2Structure.h:129
LocalizedString Name
EnumFlag< ReputationFlags > Flags
Definition: ReputationMgr.h:58
std::string description
Definition: GameEventMgr.h:74
std::string name
Definition: ObjectMgr.h:168
std::wstring wnameLow
Definition: ObjectMgr.h:169
LocalizedString Name
LocalizedString DisplayName