AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
lookup_commandscript Class Reference
Inheritance diagram for lookup_commandscript:
CommandScript ScriptObject

Public Member Functions

 lookup_commandscript ()
 
ChatCommandTable GetCommands () const override
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleLookupAreaCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupCreatureCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupEventCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupFactionCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupItemCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupItemSetCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupObjectCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupQuestCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupSkillCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupSpellCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupSpellIdCommand (ChatHandler *handler, SpellInfo const *spell)
 
static bool HandleLookupTaxiNodeCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupTeleCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupTitleCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupMapCommand (ChatHandler *handler, Tail namePart)
 
static bool HandleLookupPlayerIpCommand (ChatHandler *handler, Optional< Tail > ip, Optional< int32 > limit)
 
static bool HandleLookupPlayerAccountCommand (ChatHandler *handler, std::string account, Optional< int32 > limit)
 
static bool HandleLookupPlayerEmailCommand (ChatHandler *handler, std::string email, Optional< int32 > limit)
 
static bool LookupPlayerSearchCommand (PreparedQueryResult result, int32 limit, ChatHandler *handler)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ lookup_commandscript()

lookup_commandscript::lookup_commandscript ( )
inline
35: CommandScript("lookup_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable lookup_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

38 {
39 static ChatCommandTable lookupPlayerCommandTable =
40 {
41 { "ip", HandleLookupPlayerIpCommand, SEC_GAMEMASTER, Console::Yes },
42 { "account", HandleLookupPlayerAccountCommand, SEC_GAMEMASTER, Console::Yes },
43 { "email", HandleLookupPlayerEmailCommand, SEC_GAMEMASTER, Console::Yes }
44 };
45
46 static ChatCommandTable lookupCommandTable =
47 {
48 { "area", HandleLookupAreaCommand, SEC_MODERATOR, Console::Yes },
49 { "creature", HandleLookupCreatureCommand, SEC_MODERATOR, Console::Yes },
50 { "event", HandleLookupEventCommand, SEC_MODERATOR, Console::Yes },
51 { "faction", HandleLookupFactionCommand, SEC_MODERATOR, Console::Yes },
52 { "item", HandleLookupItemCommand, SEC_MODERATOR, Console::Yes },
53 { "item set", HandleLookupItemSetCommand, SEC_MODERATOR, Console::Yes },
54 { "map", HandleLookupMapCommand, SEC_MODERATOR, Console::Yes },
55 { "object", HandleLookupObjectCommand, SEC_MODERATOR, Console::Yes },
56 { "gobject", HandleLookupObjectCommand, SEC_MODERATOR, Console::Yes },
57 { "quest", HandleLookupQuestCommand, SEC_MODERATOR, Console::Yes },
58 { "skill", HandleLookupSkillCommand, SEC_MODERATOR, Console::Yes },
59 { "taxinode", HandleLookupTaxiNodeCommand, SEC_MODERATOR, Console::Yes },
60 { "teleport", HandleLookupTeleCommand, SEC_MODERATOR, Console::Yes },
61 { "title", HandleLookupTitleCommand, SEC_MODERATOR, Console::Yes },
62 { "spell", HandleLookupSpellCommand, SEC_MODERATOR, Console::Yes },
63 { "spell id", HandleLookupSpellIdCommand, SEC_MODERATOR, Console::Yes },
64 { "player", lookupPlayerCommandTable },
65 };
66
67 static ChatCommandTable commandTable =
68 {
69 { "lookup", lookupCommandTable }
70 };
71
72 return commandTable;
73 }
@ SEC_GAMEMASTER
Definition Common.h:59
@ SEC_MODERATOR
Definition Common.h:58
static bool HandleLookupTaxiNodeCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:1260
static bool HandleLookupPlayerIpCommand(ChatHandler *handler, Optional< Tail > ip, Optional< int32 > limit)
Definition cs_lookup.cpp:1579
static bool HandleLookupEventCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:262
static bool HandleLookupMapCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:1503
static bool HandleLookupItemCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:454
static bool HandleLookupPlayerEmailCommand(ChatHandler *handler, std::string email, Optional< int32 > limit)
Definition cs_lookup.cpp:1618
static bool HandleLookupItemSetCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:558
static bool HandleLookupObjectCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:649
static bool HandleLookupAreaCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:75
static bool HandleLookupTeleCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:1351
static bool HandleLookupFactionCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:316
static bool HandleLookupQuestCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:744
static bool HandleLookupSkillCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:890
static bool HandleLookupTitleCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:1413
static bool HandleLookupSpellIdCommand(ChatHandler *handler, SpellInfo const *spell)
Definition cs_lookup.cpp:1147
static bool HandleLookupSpellCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:995
static bool HandleLookupCreatureCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:166
static bool HandleLookupPlayerAccountCommand(ChatHandler *handler, std::string account, Optional< int32 > limit)
Definition cs_lookup.cpp:1604
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46

References HandleLookupAreaCommand(), HandleLookupCreatureCommand(), HandleLookupEventCommand(), HandleLookupFactionCommand(), HandleLookupItemCommand(), HandleLookupItemSetCommand(), HandleLookupMapCommand(), HandleLookupObjectCommand(), HandleLookupPlayerAccountCommand(), HandleLookupPlayerEmailCommand(), HandleLookupPlayerIpCommand(), HandleLookupQuestCommand(), HandleLookupSkillCommand(), HandleLookupSpellCommand(), HandleLookupSpellIdCommand(), HandleLookupTaxiNodeCommand(), HandleLookupTeleCommand(), HandleLookupTitleCommand(), SEC_GAMEMASTER, and SEC_MODERATOR.

◆ HandleLookupAreaCommand()

static bool lookup_commandscript::HandleLookupAreaCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
76 {
77 if (namePart.empty())
78 {
79 return false;
80 }
81
82 std::wstring wNamePart;
83
84 if (!Utf8toWStr(namePart, wNamePart))
85 {
86 return false;
87 }
88
89 bool found = false;
90 uint32 count = 0;
91 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
92
93 // converting string that we try to find to lower case
94 wstrToLower(wNamePart);
95
96 // Search in AreaTable.dbc
97 for (auto areaEntry : sAreaTableStore)
98 {
99 int locale = handler->GetSessionDbcLocale();
100 std::string name = areaEntry->area_name[locale];
101
102 if (name.empty())
103 {
104 continue;
105 }
106
107 if (!Utf8FitTo(name, wNamePart))
108 {
109 locale = 0;
110 for (; locale < TOTAL_LOCALES; ++locale)
111 {
112 if (locale == handler->GetSessionDbcLocale())
113 {
114 continue;
115 }
116
117 name = areaEntry->area_name[locale];
118 if (name.empty())
119 {
120 continue;
121 }
122
123 if (Utf8FitTo(name, wNamePart))
124 {
125 break;
126 }
127 }
128 }
129
130 if (locale < TOTAL_LOCALES)
131 {
132 if (maxResults && count++ == maxResults)
133 {
135 return true;
136 }
137
138 // send area in "id - [name]" format
139 std::ostringstream ss;
140 if (handler->GetSession())
141 {
142 ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << ' ' << localeNames[locale] << "]|h|r";
143 }
144 else
145 {
146 ss << areaEntry->ID << " - " << name << ' ' << localeNames[locale];
147 }
148
149 handler->SendSysMessage(ss.str().c_str());
150
151 if (!found)
152 {
153 found = true;
154 }
155 }
156 }
157
158 if (!found)
159 {
161 }
162
163 return true;
164 }
char const * localeNames[TOTAL_LOCALES]
Definition Common.cpp:20
@ TOTAL_LOCALES
Definition Common.h:76
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
std::uint32_t uint32
Definition Define.h:107
@ CONFIG_MAX_RESULTS_LOOKUP_COMMANDS
Definition IWorld.h:363
@ LANG_COMMAND_NOAREAFOUND
Definition Language.h:475
@ LANG_COMMAND_LOOKUP_MAX_RESULTS
Definition Language.h:1077
bool Utf8toWStr(char const *utf8str, std::size_t csize, wchar_t *wstr, std::size_t &wsize)
Definition Util.cpp:281
void wstrToLower(std::wstring &str)
Definition Util.cpp:382
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition Util.cpp:481
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:211
WorldSession * GetSession()
Definition Chat.h:242
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:870
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:160
#define sWorld
Definition World.h:357

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOAREAFOUND, localeNames, ChatHandler::PSendSysMessage(), sAreaTableStore, ChatHandler::SendSysMessage(), sWorld, TOTAL_LOCALES, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupCreatureCommand()

static bool lookup_commandscript::HandleLookupCreatureCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
167 {
168 if (namePart.empty())
169 {
170 return false;
171 }
172
173 std::wstring wNamePart;
174
175 // converting string that we try to find to lower case
176 if (!Utf8toWStr(namePart, wNamePart))
177 {
178 return false;
179 }
180
181 wstrToLower(wNamePart);
182
183 bool found = false;
184 uint32 count = 0;
185 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
186
187 for (auto const& [entry, creatureTemplate] : *sObjectMgr->GetCreatureTemplates())
188 {
189 uint32 id = creatureTemplate.Entry;
190 uint8 localeIndex = handler->GetSessionDbLocaleIndex();
191 if (CreatureLocale const* creatureLocale = sObjectMgr->GetCreatureLocale(id))
192 {
193 if (creatureLocale->Name.size() > localeIndex && !creatureLocale->Name[localeIndex].empty())
194 {
195 std::string name = creatureLocale->Name[localeIndex];
196
197 if (Utf8FitTo(name, wNamePart))
198 {
199 if (maxResults && count++ == maxResults)
200 {
202 return true;
203 }
204
205 if (handler->GetSession())
206 {
207 handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name);
208 }
209 else
210 {
212 }
213
214 if (!found)
215 {
216 found = true;
217 }
218
219 continue;
220 }
221 }
222 }
223
224 std::string name = creatureTemplate.Name;
225 if (name.empty())
226 {
227 continue;
228 }
229
230 if (Utf8FitTo(name, wNamePart))
231 {
232 if (maxResults && count++ == maxResults)
233 {
235 return true;
236 }
237
238 if (handler->GetSession())
239 {
240 handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name);
241 }
242 else
243 {
245 }
246
247 if (!found)
248 {
249 found = true;
250 }
251 }
252 }
253
254 if (!found)
255 {
257 }
258
259 return true;
260 }
std::uint8_t uint8
Definition Define.h:109
@ LANG_COMMAND_NOCREATUREFOUND
Definition Language.h:480
@ LANG_CREATURE_ENTRY_LIST_CONSOLE
Definition Language.h:894
@ LANG_CREATURE_ENTRY_LIST_CHAT
Definition Language.h:558
#define sObjectMgr
Definition ObjectMgr.h:1650
virtual int GetSessionDbLocaleIndex() const
Definition Chat.cpp:875
Definition CreatureData.h:343

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetSession(), ChatHandler::GetSessionDbLocaleIndex(), LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOCREATUREFOUND, LANG_CREATURE_ENTRY_LIST_CHAT, LANG_CREATURE_ENTRY_LIST_CONSOLE, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), sObjectMgr, sWorld, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupEventCommand()

static bool lookup_commandscript::HandleLookupEventCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
263 {
264 if (namePart.empty())
265 return false;
266
267 std::wstring wNamePart;
268
269 // converting string that we try to find to lower case
270 if (!Utf8toWStr(namePart, wNamePart))
271 return false;
272
273 wstrToLower(wNamePart);
274
275 bool found = false;
276 uint32 count = 0;
277 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
278
280 GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
281
282 for (uint32 id = 0; id < events.size(); ++id)
283 {
284 GameEventData const& eventData = events[id];
285
286 std::string descr = eventData.Description;
287 if (descr.empty())
288 continue;
289
290 if (Utf8FitTo(descr, wNamePart))
291 {
292 if (maxResults && count++ == maxResults)
293 {
295 return true;
296 }
297
298 std::string active = activeEvents.find(id) != activeEvents.end() ? handler->GetAcoreString(LANG_ACTIVE) : "";
299
300 if (handler->GetSession())
301 handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.Description, active);
302 else
303 handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.Description, active);
304
305 if (!found)
306 found = true;
307 }
308 }
309
310 if (!found)
312
313 return true;
314 }
#define sGameEventMgr
Definition GameEventMgr.h:201
@ LANG_EVENT_ENTRY_LIST_CONSOLE
Definition Language.h:893
@ LANG_EVENT_ENTRY_LIST_CHAT
Definition Language.h:644
@ LANG_ACTIVE
Definition Language.h:67
@ LANG_NOEVENTFOUND
Definition Language.h:645
events
Definition boss_sartura.cpp:43
virtual std::string GetAcoreString(uint32 entry) const
Definition Chat.cpp:41
std::vector< GameEventData > GameEventDataMap
Definition GameEventMgr.h:107
std::set< uint16 > ActiveEvents
Definition GameEventMgr.h:106
Definition GameEventMgr.h:57
std::string Description
Definition GameEventMgr.h:70

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, GameEventData::Description, ChatHandler::GetAcoreString(), ChatHandler::GetSession(), LANG_ACTIVE, LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_EVENT_ENTRY_LIST_CHAT, LANG_EVENT_ENTRY_LIST_CONSOLE, LANG_NOEVENTFOUND, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), sGameEventMgr, sWorld, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupFactionCommand()

static bool lookup_commandscript::HandleLookupFactionCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
317 {
318 if (namePart.empty())
319 {
320 return false;
321 }
322
323 // Can be nullptr at console call
324 Player* target = handler->getSelectedPlayer();
325
326 std::wstring wNamePart;
327
328 if (!Utf8toWStr(namePart, wNamePart))
329 {
330 return false;
331 }
332
333 // converting string that we try to find to lower case
334 wstrToLower(wNamePart);
335
336 bool found = false;
337 uint32 count = 0;
338 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
339
340 for (auto factionEntry : sFactionStore)
341 {
342 FactionState const* factionState = target ? target->GetReputationMgr().GetState(factionEntry) : nullptr;
343
344 int locale = handler->GetSessionDbcLocale();
345 std::string name = factionEntry->name[locale];
346 if (name.empty())
347 {
348 continue;
349 }
350
351 if (!Utf8FitTo(name, wNamePart))
352 {
353 locale = 0;
354
355 for (; locale < TOTAL_LOCALES; ++locale)
356 {
357 if (locale == handler->GetSessionDbcLocale())
358 {
359 continue;
360 }
361
362 name = factionEntry->name[locale];
363 if (name.empty())
364 {
365 continue;
366 }
367
368 if (Utf8FitTo(name, wNamePart))
369 {
370 break;
371 }
372 }
373 }
374
375 if (locale < TOTAL_LOCALES)
376 {
377 if (maxResults && count++ == maxResults)
378 {
380 return true;
381 }
382
383 // send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format
384 // or "id - [faction] [no reputation]" format
385 std::ostringstream ss;
386 if (handler->GetSession())
387 {
388 ss << factionEntry->ID << " - |cffffffff|Hfaction:" << factionEntry->ID << "|h[" << name << ' ' << localeNames[locale] << "]|h|r";
389 }
390 else
391 {
392 ss << factionEntry->ID << " - " << name << ' ' << localeNames[locale];
393 }
394
395 if (factionState) // and then target != nullptr also
396 {
397 uint32 index = target->GetReputationMgr().GetReputationRankStrIndex(factionEntry);
398 std::string rankName = handler->GetAcoreString(index);
399
400 ss << ' ' << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
401
402 if (factionState->Flags & FACTION_FLAG_VISIBLE)
403 {
404 ss << handler->GetAcoreString(LANG_FACTION_VISIBLE);
405 }
406
407 if (factionState->Flags & FACTION_FLAG_AT_WAR)
408 {
409 ss << handler->GetAcoreString(LANG_FACTION_ATWAR);
410 }
411
412 if (factionState->Flags & FACTION_FLAG_PEACE_FORCED)
413 {
415 }
416
417 if (factionState->Flags & FACTION_FLAG_HIDDEN)
418 {
419 ss << handler->GetAcoreString(LANG_FACTION_HIDDEN);
420 }
421
422 if (factionState->Flags & FACTION_FLAG_INVISIBLE_FORCED)
423 {
425 }
426
427 if (factionState->Flags & FACTION_FLAG_INACTIVE)
428 {
430 }
431 }
432 else
433 {
435 }
436
437 handler->SendSysMessage(ss.str().c_str());
438
439 if (!found)
440 {
441 found = true;
442 }
443 }
444 }
445
446 if (!found)
447 {
449 }
450
451 return true;
452 }
@ FACTION_FLAG_INACTIVE
Definition DBCEnums.h:312
@ FACTION_FLAG_PEACE_FORCED
Definition DBCEnums.h:311
@ FACTION_FLAG_INVISIBLE_FORCED
Definition DBCEnums.h:310
@ FACTION_FLAG_HIDDEN
Definition DBCEnums.h:309
@ FACTION_FLAG_VISIBLE
Definition DBCEnums.h:307
@ FACTION_FLAG_AT_WAR
Definition DBCEnums.h:308
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
@ LANG_FACTION_PEACE_FORCED
Definition Language.h:356
@ LANG_FACTION_ATWAR
Definition Language.h:355
@ LANG_FACTION_NOREPUTATION
Definition Language.h:369
@ LANG_FACTION_INVISIBLE_FORCED
Definition Language.h:358
@ LANG_FACTION_HIDDEN
Definition Language.h:357
@ LANG_COMMAND_FACTION_NOTFOUND
Definition Language.h:349
@ LANG_FACTION_INACTIVE
Definition Language.h:359
@ LANG_FACTION_VISIBLE
Definition Language.h:354
Player * getSelectedPlayer() const
Definition Chat.cpp:374
Definition Player.h:1082
ReputationMgr & GetReputationMgr()
Definition Player.h:2135
int32 GetReputation(uint32 faction_id) const
Definition ReputationMgr.cpp:78
FactionState const * GetState(FactionEntry const *factionEntry) const
Definition ReputationMgr.h:81
uint32 GetReputationRankStrIndex(FactionEntry const *factionEntry) const
Definition ReputationMgr.h:101
Definition ReputationMgr.h:41
uint8 Flags
Definition ReputationMgr.h:45

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, FACTION_FLAG_AT_WAR, FACTION_FLAG_HIDDEN, FACTION_FLAG_INACTIVE, FACTION_FLAG_INVISIBLE_FORCED, FACTION_FLAG_PEACE_FORCED, FACTION_FLAG_VISIBLE, FactionState::Flags, ChatHandler::GetAcoreString(), ReputationMgr::GetReputation(), Player::GetReputationMgr(), ReputationMgr::GetReputationRankStrIndex(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), ReputationMgr::GetState(), LANG_COMMAND_FACTION_NOTFOUND, LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_FACTION_ATWAR, LANG_FACTION_HIDDEN, LANG_FACTION_INACTIVE, LANG_FACTION_INVISIBLE_FORCED, LANG_FACTION_NOREPUTATION, LANG_FACTION_PEACE_FORCED, LANG_FACTION_VISIBLE, localeNames, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), sFactionStore, sWorld, TOTAL_LOCALES, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupItemCommand()

static bool lookup_commandscript::HandleLookupItemCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
455 {
456 if (namePart.empty())
457 {
458 return false;
459 }
460
461 std::wstring wNamePart;
462
463 // converting string that we try to find to lower case
464 if (!Utf8toWStr(namePart, wNamePart))
465 {
466 return false;
467 }
468
469 wstrToLower(wNamePart);
470
471 bool found = false;
472 uint32 count = 0;
473 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
474
475 // Search in `item_template`
476 for (auto const& [entry, itemTemplate] : *sObjectMgr->GetItemTemplateStore())
477 {
478 int localeIndex = handler->GetSessionDbLocaleIndex();
479 if (localeIndex >= 0)
480 {
481 uint8 ulocaleIndex = uint8(localeIndex);
482 if (ItemLocale const* il = sObjectMgr->GetItemLocale(itemTemplate.ItemId))
483 {
484 if (il->Name.size() > ulocaleIndex && !il->Name[ulocaleIndex].empty())
485 {
486 std::string name = il->Name[ulocaleIndex];
487
488 if (Utf8FitTo(name, wNamePart))
489 {
490 if (maxResults && count++ == maxResults)
491 {
493 return true;
494 }
495
496 if (handler->GetSession())
497 {
498 std::ostringstream color;
499 color << std::hex << ItemQualityColors[itemTemplate.Quality];
500 handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, color.str(), itemTemplate.ItemId, name);
501 }
502 else
503 {
504 handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name);
505 }
506
507 if (!found)
508 {
509 found = true;
510 }
511
512 continue;
513 }
514 }
515 }
516 }
517
518 std::string name = itemTemplate.Name1;
519 if (name.empty())
520 {
521 continue;
522 }
523
524 if (Utf8FitTo(name, wNamePart))
525 {
526 if (maxResults && count++ == maxResults)
527 {
529 return true;
530 }
531
532 if (handler->GetSession())
533 {
534 std::ostringstream color;
535 color << std::hex << ItemQualityColors[itemTemplate.Quality];
536 handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, color.str(), itemTemplate.ItemId, name);
537 }
538 else
539 {
540 handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name);
541 }
542
543 if (!found)
544 {
545 found = true;
546 }
547 }
548 }
549
550 if (!found)
551 {
553 }
554
555 return true;
556 }
@ LANG_ITEM_LIST_CHAT
Definition Language.h:556
@ LANG_COMMAND_NOITEMFOUND
Definition Language.h:469
@ LANG_ITEM_LIST_CONSOLE
Definition Language.h:895
const uint32 ItemQualityColors[MAX_ITEM_QUALITY]
Definition SharedDefines.h:353
Definition ItemTemplate.h:838

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetSession(), ChatHandler::GetSessionDbLocaleIndex(), ItemQualityColors, LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOITEMFOUND, LANG_ITEM_LIST_CHAT, LANG_ITEM_LIST_CONSOLE, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), sObjectMgr, sWorld, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupItemSetCommand()

static bool lookup_commandscript::HandleLookupItemSetCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
559 {
560 if (namePart.empty())
561 {
562 return false;
563 }
564
565 std::wstring wNamePart;
566
567 if (!Utf8toWStr(namePart, wNamePart))
568 {
569 return false;
570 }
571
572 // converting string that we try to find to lower case
573 wstrToLower(wNamePart);
574
575 bool found = false;
576 uint32 count = 0;
577 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
578
579 // Search in ItemSet.dbc
580 for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++)
581 {
582 ItemSetEntry const* set = sItemSetStore.LookupEntry(id);
583 if (set)
584 {
585 int locale = handler->GetSessionDbcLocale();
586 std::string name = set->name[locale];
587 if (name.empty())
588 {
589 continue;
590 }
591
592 if (!Utf8FitTo(name, wNamePart))
593 {
594 locale = 0;
595 for (; locale < TOTAL_LOCALES; ++locale)
596 {
597 if (locale == handler->GetSessionDbcLocale())
598 {
599 continue;
600 }
601
602 name = set->name[locale];
603 if (name.empty())
604 {
605 continue;
606 }
607
608 if (Utf8FitTo(name, wNamePart))
609 {
610 break;
611 }
612 }
613 }
614
615 if (locale < TOTAL_LOCALES)
616 {
617 if (maxResults && count++ == maxResults)
618 {
620 return true;
621 }
622
623 // send item set in "id - [namedlink locale]" format
624 if (handler->GetSession())
625 {
626 handler->PSendSysMessage(LANG_ITEMSET_LIST_CHAT, id, id, name, localeNames[locale]);
627 }
628 else
629 {
630 handler->PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name, localeNames[locale]);
631 }
632
633 if (!found)
634 {
635 found = true;
636 }
637 }
638 }
639 }
640
641 if (!found)
642 {
644 }
645
646 return true;
647 }
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetEntryfmt)
@ LANG_ITEMSET_LIST_CHAT
Definition Language.h:562
@ LANG_COMMAND_NOITEMSETFOUND
Definition Language.h:476
@ LANG_ITEMSET_LIST_CONSOLE
Definition Language.h:896
Definition DBCStructure.h:1233
char const * name[16]
Definition DBCStructure.h:1235

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOITEMSETFOUND, LANG_ITEMSET_LIST_CHAT, LANG_ITEMSET_LIST_CONSOLE, localeNames, ItemSetEntry::name, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), sItemSetStore, sWorld, TOTAL_LOCALES, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupMapCommand()

static bool lookup_commandscript::HandleLookupMapCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
1504 {
1505 if (namePart.empty())
1506 {
1507 return false;
1508 }
1509
1510 std::wstring wNamePart;
1511
1512 if (!Utf8toWStr(namePart, wNamePart))
1513 {
1514 return false;
1515 }
1516
1517 wstrToLower(wNamePart);
1518
1519 uint32 counter = 0;
1520 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1521 uint8 locale = handler->GetSession() ? handler->GetSession()->GetSessionDbcLocale() : sWorld->GetDefaultDbcLocale();
1522
1523 // search in Map.dbc
1524 for (auto mapInfo : sMapStore)
1525 {
1526 std::string name = mapInfo->name[locale];
1527
1528 if (name.empty())
1529 {
1530 continue;
1531 }
1532
1533 if (Utf8FitTo(name, wNamePart) && locale < TOTAL_LOCALES)
1534 {
1535 if (maxResults && counter == maxResults)
1536 {
1538 return true;
1539 }
1540
1541 std::ostringstream ss;
1542 ss << mapInfo->MapID << " - [" << name << ']';
1543
1544 if (mapInfo->IsContinent())
1545 {
1546 ss << handler->GetAcoreString(LANG_CONTINENT);
1547 }
1548
1549 switch (mapInfo->map_type)
1550 {
1551 case MAP_INSTANCE:
1552 ss << handler->GetAcoreString(LANG_INSTANCE);
1553 break;
1554 case MAP_RAID:
1555 ss << handler->GetAcoreString(LANG_RAID);
1556 break;
1557 case MAP_BATTLEGROUND:
1558 ss << handler->GetAcoreString(LANG_BATTLEGROUND);
1559 break;
1560 case MAP_ARENA:
1561 ss << handler->GetAcoreString(LANG_ARENA);
1562 break;
1563 }
1564
1565 handler->SendSysMessage(ss.str().c_str());
1566
1567 ++counter;
1568 }
1569 }
1570
1571 if (!counter)
1572 {
1574 }
1575
1576 return true;
1577 }
@ MAP_BATTLEGROUND
Definition DBCEnums.h:349
@ MAP_ARENA
Definition DBCEnums.h:350
@ MAP_INSTANCE
Definition DBCEnums.h:347
@ MAP_RAID
Definition DBCEnums.h:348
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
@ LANG_COMMAND_NOMAPFOUND
Definition Language.h:1060
@ LANG_BATTLEGROUND
Definition Language.h:1063
@ LANG_ARENA
Definition Language.h:1064
@ LANG_INSTANCE
Definition Language.h:1062
@ LANG_CONTINENT
Definition Language.h:1061
@ LANG_RAID
Definition Language.h:1065
LocaleConstant GetSessionDbcLocale() const
Definition WorldSession.h:511

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetAcoreString(), ChatHandler::GetSession(), WorldSession::GetSessionDbcLocale(), LANG_ARENA, LANG_BATTLEGROUND, LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOMAPFOUND, LANG_CONTINENT, LANG_INSTANCE, LANG_RAID, MAP_ARENA, MAP_BATTLEGROUND, MAP_INSTANCE, MAP_RAID, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), sMapStore, sWorld, TOTAL_LOCALES, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupObjectCommand()

static bool lookup_commandscript::HandleLookupObjectCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
650 {
651 if (namePart.empty())
652 {
653 return false;
654 }
655
656 std::wstring wNamePart;
657
658 // converting string that we try to find to lower case
659 if (!Utf8toWStr(namePart, wNamePart))
660 {
661 return false;
662 }
663
664 wstrToLower(wNamePart);
665
666 bool found = false;
667 uint32 count = 0;
668 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
669
670 for (auto const& [entry, gameObjectTemplate] : *sObjectMgr->GetGameObjectTemplates())
671 {
672 uint8 localeIndex = handler->GetSessionDbLocaleIndex();
673 if (GameObjectLocale const* objectLocalte = sObjectMgr->GetGameObjectLocale(gameObjectTemplate.entry))
674 {
675 if (objectLocalte->Name.size() > localeIndex && !objectLocalte->Name[localeIndex].empty())
676 {
677 std::string name = objectLocalte->Name[localeIndex];
678
679 if (Utf8FitTo(name, wNamePart))
680 {
681 if (maxResults && count++ == maxResults)
682 {
684 return true;
685 }
686
687 if (handler->GetSession())
688 {
689 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name);
690 }
691 else
692 {
693 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name);
694 }
695
696 if (!found)
697 {
698 found = true;
699 }
700
701 continue;
702 }
703 }
704 }
705
706 std::string name = gameObjectTemplate.name;
707 if (name.empty())
708 {
709 continue;
710 }
711
712 if (Utf8FitTo(name, wNamePart))
713 {
714 if (maxResults && count++ == maxResults)
715 {
717 return true;
718 }
719
720 if (handler->GetSession())
721 {
722 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name);
723 }
724 else
725 {
726 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name);
727 }
728
729 if (!found)
730 {
731 found = true;
732 }
733 }
734 }
735
736 if (!found)
737 {
739 }
740
741 return true;
742 }
@ LANG_GO_ENTRY_LIST_CONSOLE
Definition Language.h:897
@ LANG_GO_ENTRY_LIST_CHAT
Definition Language.h:560
@ LANG_COMMAND_NOGAMEOBJECTFOUND
Definition Language.h:481
Definition GameObjectData.h:674

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetSession(), ChatHandler::GetSessionDbLocaleIndex(), LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOGAMEOBJECTFOUND, LANG_GO_ENTRY_LIST_CHAT, LANG_GO_ENTRY_LIST_CONSOLE, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), sObjectMgr, sWorld, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupPlayerAccountCommand()

static bool lookup_commandscript::HandleLookupPlayerAccountCommand ( ChatHandler handler,
std::string  account,
Optional< int32 limit 
)
inlinestatic
1605 {
1606 if (!Utf8ToUpperOnlyLatin(account))
1607 {
1608 return false;
1609 }
1610
1612 stmt->SetData(0, account);
1613 PreparedQueryResult result = LoginDatabase.Query(stmt);
1614
1615 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1616 }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition DatabaseEnv.cpp:22
@ LOGIN_SEL_ACCOUNT_LIST_BY_NAME
Definition LoginDatabase.h:49
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition Util.cpp:532
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
static bool LookupPlayerSearchCommand(PreparedQueryResult result, int32 limit, ChatHandler *handler)
Definition cs_lookup.cpp:1627

References LOGIN_SEL_ACCOUNT_LIST_BY_NAME, LoginDatabase, LookupPlayerSearchCommand(), PreparedStatementBase::SetData(), and Utf8ToUpperOnlyLatin().

Referenced by GetCommands().

◆ HandleLookupPlayerEmailCommand()

static bool lookup_commandscript::HandleLookupPlayerEmailCommand ( ChatHandler handler,
std::string  email,
Optional< int32 limit 
)
inlinestatic
1619 {
1621 stmt->SetData(0, email);
1622 PreparedQueryResult result = LoginDatabase.Query(stmt);
1623
1624 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1625 }
@ LOGIN_SEL_ACCOUNT_LIST_BY_EMAIL
Definition LoginDatabase.h:51

References LOGIN_SEL_ACCOUNT_LIST_BY_EMAIL, LoginDatabase, LookupPlayerSearchCommand(), and PreparedStatementBase::SetData().

Referenced by GetCommands().

◆ HandleLookupPlayerIpCommand()

static bool lookup_commandscript::HandleLookupPlayerIpCommand ( ChatHandler handler,
Optional< Tail ip,
Optional< int32 limit 
)
inlinestatic
1580 {
1581 Player* target = handler->getSelectedPlayerOrSelf();
1582 if (!ip)
1583 {
1584 // nullptr only if used from console
1585 if (!target || target == handler->GetSession()->GetPlayer())
1586 {
1587 return false;
1588 }
1589
1590 *ip = target->GetSession()->GetRemoteAddress();
1591 }
1592 else
1593 {
1594 ip = *ip;
1595 }
1596
1598 stmt->SetData(0, *ip);
1599 PreparedQueryResult result = LoginDatabase.Query(stmt);
1600
1601 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1602 }
@ LOGIN_SEL_ACCOUNT_BY_IP
Definition LoginDatabase.h:54
Player * getSelectedPlayerOrSelf() const
Definition Chat.cpp:418
WorldSession * GetSession() const
Definition Player.h:2007
Player * GetPlayer() const
Definition WorldSession.h:376
std::string const & GetRemoteAddress()
Definition WorldSession.h:385

References WorldSession::GetPlayer(), WorldSession::GetRemoteAddress(), ChatHandler::getSelectedPlayerOrSelf(), ChatHandler::GetSession(), Player::GetSession(), LOGIN_SEL_ACCOUNT_BY_IP, LoginDatabase, LookupPlayerSearchCommand(), and PreparedStatementBase::SetData().

Referenced by GetCommands().

◆ HandleLookupQuestCommand()

static bool lookup_commandscript::HandleLookupQuestCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
745 {
746 if (namePart.empty())
747 {
748 return false;
749 }
750
751 // can be nullptr at console call
752 Player* target = handler->getSelectedPlayer();
753
754 std::wstring wNamePart;
755
756 // converting string that we try to find to lower case
757 if (!Utf8toWStr(namePart, wNamePart))
758 {
759 return false;
760 }
761
762 wstrToLower(wNamePart);
763
764 bool found = false;
765 uint32 count = 0;
766 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
767
768 for (auto const& [entry, qInfo] : sObjectMgr->GetQuestTemplates())
769 {
770 int localeIndex = handler->GetSessionDbLocaleIndex();
771 if (localeIndex >= 0)
772 {
773 uint8 ulocaleIndex = uint8(localeIndex);
774 if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(qInfo->GetQuestId()))
775 {
776 if (questLocale->Title.size() > ulocaleIndex && !questLocale->Title[ulocaleIndex].empty())
777 {
778 std::string title = questLocale->Title[ulocaleIndex];
779
780 if (Utf8FitTo(title, wNamePart))
781 {
782 if (maxResults && count++ == maxResults)
783 {
785 return true;
786 }
787
788 std::string statusStr = "";
789
790 if (target)
791 {
792 QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
793
794 switch (status)
795 {
797 statusStr = handler->GetAcoreString(LANG_COMPLETE);
798 break;
800 statusStr = handler->GetAcoreString(LANG_ACTIVE);
801 break;
803 statusStr = handler->GetAcoreString(LANG_REWARDED);
804 break;
805 default:
806 break;
807 }
808 }
809
810 if (handler->GetSession())
811 {
812 handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title, statusStr);
813 }
814 else
815 {
816 handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title, statusStr);
817 }
818
819 if (!found)
820 {
821 found = true;
822 }
823
824 continue;
825 }
826 }
827 }
828 }
829
830 std::string title = qInfo->GetTitle();
831 if (title.empty())
832 {
833 continue;
834 }
835
836 if (Utf8FitTo(title, wNamePart))
837 {
838 if (maxResults && count++ == maxResults)
839 {
841 return true;
842 }
843
844 std::string statusStr = "";
845
846 if (target)
847 {
848 QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
849
850 switch (status)
851 {
853 statusStr = handler->GetAcoreString(LANG_COMPLETE);
854 break;
856 statusStr = handler->GetAcoreString(LANG_ACTIVE);
857 break;
859 statusStr = handler->GetAcoreString(LANG_REWARDED);
860 break;
861 default:
862 break;
863 }
864 }
865
866 if (handler->GetSession())
867 {
868 handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title, statusStr);
869 }
870 else
871 {
872 handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title, statusStr);
873 }
874
875 if (!found)
876 {
877 found = true;
878 }
879 }
880 }
881
882 if (!found)
883 {
885 }
886
887 return true;
888 }
@ LANG_COMPLETE
Definition Language.h:68
@ LANG_QUEST_LIST_CONSOLE
Definition Language.h:898
@ LANG_REWARDED
Definition Language.h:667
@ LANG_COMMAND_NOQUESTFOUND
Definition Language.h:479
@ LANG_QUEST_LIST_CHAT
Definition Language.h:557
QuestStatus
Definition QuestDef.h:99
@ QUEST_STATUS_REWARDED
Definition QuestDef.h:106
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:103
@ QUEST_STATUS_COMPLETE
Definition QuestDef.h:101
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition PlayerQuest.cpp:1430
Definition QuestDef.h:183

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetAcoreString(), Player::GetQuestStatus(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), ChatHandler::GetSessionDbLocaleIndex(), LANG_ACTIVE, LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOQUESTFOUND, LANG_COMPLETE, LANG_QUEST_LIST_CHAT, LANG_QUEST_LIST_CONSOLE, LANG_REWARDED, ChatHandler::PSendSysMessage(), QUEST_STATUS_COMPLETE, QUEST_STATUS_INCOMPLETE, QUEST_STATUS_REWARDED, ChatHandler::SendSysMessage(), sObjectMgr, sWorld, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupSkillCommand()

static bool lookup_commandscript::HandleLookupSkillCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
891 {
892 if (namePart.empty())
893 {
894 return false;
895 }
896
897 // can be nullptr in console call
898 Player* target = handler->getSelectedPlayer();
899
900 std::wstring wNamePart;
901
902 if (!Utf8toWStr(namePart, wNamePart))
903 {
904 return false;
905 }
906
907 // converting string that we try to find to lower case
908 wstrToLower(wNamePart);
909
910 bool found = false;
911 uint32 count = 0;
912 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
913
914 // Search in SkillLine.dbc
915 for (auto skillInfo : sSkillLineStore)
916 {
917 int locale = handler->GetSessionDbcLocale();
918 std::string name = skillInfo->name[locale];
919
920 if (name.empty())
921 {
922 continue;
923 }
924
925 if (!Utf8FitTo(name, wNamePart))
926 {
927 locale = 0;
928 for (; locale < TOTAL_LOCALES; ++locale)
929 {
930 if (locale == handler->GetSessionDbcLocale())
931 {
932 continue;
933 }
934
935 name = skillInfo->name[locale];
936 if (name.empty())
937 {
938 continue;
939 }
940
941 if (Utf8FitTo(name, wNamePart))
942 {
943 break;
944 }
945 }
946 }
947
948 if (locale < TOTAL_LOCALES)
949 {
950 if (maxResults && count++ == maxResults)
951 {
953 return true;
954 }
955
956 std::string valStr;
957 std::string knownStr;
958
959 if (target && target->HasSkill(skillInfo->id))
960 {
961 knownStr = handler->GetAcoreString(LANG_KNOWN);
962 uint32 curValue = target->GetPureSkillValue(skillInfo->id);
963 uint32 maxValue = target->GetPureMaxSkillValue(skillInfo->id);
964 uint32 permValue = target->GetSkillPermBonusValue(skillInfo->id);
965 uint32 tempValue = target->GetSkillTempBonusValue(skillInfo->id);
966
967 valStr = Acore::StringFormat(handler->GetAcoreString(LANG_SKILL_VALUES), curValue, maxValue, permValue, tempValue);
968 }
969
970 // send skill in "id - [namedlink locale]" format
971 if (handler->GetSession())
972 {
973 handler->PSendSysMessage(LANG_SKILL_LIST_CHAT, skillInfo->id, skillInfo->id, name, localeNames[locale], knownStr, valStr);
974 }
975 else
976 {
977 handler->PSendSysMessage(LANG_SKILL_LIST_CONSOLE, skillInfo->id, name, localeNames[locale], knownStr, valStr);
978 }
979
980 if (!found)
981 {
982 found = true;
983 }
984 }
985 }
986
987 if (!found)
988 {
990 }
991
992 return true;
993 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
@ LANG_SKILL_LIST_CHAT
Definition Language.h:565
@ LANG_KNOWN
Definition Language.h:63
@ LANG_SKILL_LIST_CONSOLE
Definition Language.h:899
@ LANG_COMMAND_NOSKILLFOUND
Definition Language.h:477
@ LANG_SKILL_VALUES
Definition Language.h:912
uint16 GetPureSkillValue(uint32 skill) const
Definition Player.cpp:5522
int16 GetSkillTempBonusValue(uint32 skill) const
Definition Player.cpp:5546
int16 GetSkillPermBonusValue(uint32 skill) const
Definition Player.cpp:5534
bool HasSkill(uint32 skill) const
Definition Player.cpp:5436
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition Player.cpp:5492
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition StringFormat.h:34

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetAcoreString(), Player::GetPureMaxSkillValue(), Player::GetPureSkillValue(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), Player::GetSkillPermBonusValue(), Player::GetSkillTempBonusValue(), Player::HasSkill(), LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOSKILLFOUND, LANG_KNOWN, LANG_SKILL_LIST_CHAT, LANG_SKILL_LIST_CONSOLE, LANG_SKILL_VALUES, localeNames, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), sSkillLineStore, Acore::StringFormat(), sWorld, TOTAL_LOCALES, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupSpellCommand()

static bool lookup_commandscript::HandleLookupSpellCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
996 {
997 if (namePart.empty())
998 {
999 return false;
1000 }
1001
1002 // can be nullptr at console call
1003 Player* target = handler->getSelectedPlayer();
1004
1005 std::wstring wNamePart;
1006
1007 if (!Utf8toWStr(namePart, wNamePart))
1008 {
1009 return false;
1010 }
1011
1012 // converting string that we try to find to lower case
1013 wstrToLower(wNamePart);
1014
1015 bool found = false;
1016 uint32 count = 0;
1017 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1018
1019 // Search in Spell.dbc
1020 for (uint32 id = 0; id < sSpellMgr->GetSpellInfoStoreSize(); id++)
1021 {
1022 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id);
1023 if (spellInfo)
1024 {
1025 int locale = handler->GetSessionDbcLocale();
1026 std::string name = spellInfo->SpellName[locale];
1027 if (name.empty())
1028 {
1029 continue;
1030 }
1031
1032 if (!Utf8FitTo(name, wNamePart))
1033 {
1034 locale = 0;
1035 for (; locale < TOTAL_LOCALES; ++locale)
1036 {
1037 if (locale == handler->GetSessionDbcLocale())
1038 {
1039 continue;
1040 }
1041
1042 name = spellInfo->SpellName[locale];
1043 if (name.empty())
1044 {
1045 continue;
1046 }
1047
1048 if (Utf8FitTo(name, wNamePart))
1049 {
1050 break;
1051 }
1052 }
1053 }
1054
1055 if (locale < TOTAL_LOCALES)
1056 {
1057 if (maxResults && count++ == maxResults)
1058 {
1060 return true;
1061 }
1062
1063 bool known = target && target->HasSpell(id);
1064 bool learn = (spellInfo->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL);
1065
1066 SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[0].TriggerSpell);
1067
1068 uint32 talentCost = GetTalentSpellCost(id);
1069
1070 bool talent = (talentCost > 0);
1071 bool passive = spellInfo->IsPassive();
1072 bool active = target && target->HasAura(id);
1073
1074 // unit32 used to prevent interpreting uint8 as char at output
1075 // find rank of learned spell for learning spell, or talent rank
1076 uint32 rank = talentCost ? talentCost : learn && learnSpellInfo ? learnSpellInfo->GetRank() : spellInfo->GetRank();
1077
1078 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
1079 std::ostringstream ss;
1080 if (handler->GetSession())
1081 {
1082 ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name;
1083 }
1084 else
1085 {
1086 ss << id << " - " << name;
1087 }
1088
1089 // include rank in link name
1090 if (rank)
1091 {
1092 ss << handler->GetAcoreString(LANG_SPELL_RANK) << rank;
1093 }
1094
1095 if (handler->GetSession())
1096 {
1097 ss << ' ' << localeNames[locale] << "]|h|r";
1098 }
1099 else
1100 {
1101 ss << ' ' << localeNames[locale];
1102 }
1103
1104 if (talent)
1105 {
1106 ss << handler->GetAcoreString(LANG_TALENT);
1107 }
1108
1109 if (passive)
1110 {
1111 ss << handler->GetAcoreString(LANG_PASSIVE);
1112 }
1113
1114 if (learn)
1115 {
1116 ss << handler->GetAcoreString(LANG_LEARN);
1117 }
1118
1119 if (known)
1120 {
1121 ss << handler->GetAcoreString(LANG_KNOWN);
1122 }
1123
1124 if (active)
1125 {
1126 ss << handler->GetAcoreString(LANG_ACTIVE);
1127 }
1128
1129 handler->SendSysMessage(ss.str().c_str());
1130
1131 if (!found)
1132 {
1133 found = true;
1134 }
1135 }
1136 }
1137 }
1138
1139 if (!found)
1140 {
1142 }
1143
1144 return true;
1145 }
uint32 GetTalentSpellCost(uint32 spellId)
Definition DBCStores.cpp:686
@ LANG_TALENT
Definition Language.h:66
@ LANG_LEARN
Definition Language.h:64
@ LANG_COMMAND_NOSPELLFOUND
Definition Language.h:478
@ LANG_SPELL_RANK
Definition Language.h:62
@ LANG_PASSIVE
Definition Language.h:65
@ SPELL_EFFECT_LEARN_SPELL
Definition SharedDefines.h:814
#define sSpellMgr
Definition SpellMgr.h:825
bool HasSpell(uint32 spell) const override
Definition Player.cpp:3878
Definition SpellInfo.h:316
bool IsPassive() const
Definition SpellInfo.cpp:1098
uint8 GetRank() const
Definition SpellInfo.cpp:2506
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:393
std::array< char const *, 16 > SpellName
Definition SpellInfo.h:383
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5754

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, SpellInfo::Effects, ChatHandler::GetAcoreString(), SpellInfo::GetRank(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), GetTalentSpellCost(), Unit::HasAura(), Player::HasSpell(), SpellInfo::IsPassive(), LANG_ACTIVE, LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOSPELLFOUND, LANG_KNOWN, LANG_LEARN, LANG_PASSIVE, LANG_SPELL_RANK, LANG_TALENT, localeNames, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), SPELL_EFFECT_LEARN_SPELL, SpellInfo::SpellName, sSpellMgr, sWorld, TOTAL_LOCALES, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupSpellIdCommand()

static bool lookup_commandscript::HandleLookupSpellIdCommand ( ChatHandler handler,
SpellInfo const *  spell 
)
inlinestatic
1148 {
1149 // can be nullptr at console call
1150 Player* target = handler->getSelectedPlayer();
1151
1152 bool found = false;
1153 uint32 count = 0;
1154 uint32 maxResults = 1;
1155
1156 if (!SpellMgr::IsSpellValid(spell))
1157 {
1158 handler->SendErrorMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
1159 return false;
1160 }
1161
1162 int locale = handler->GetSessionDbcLocale();
1163 std::string name = spell->SpellName[locale];
1164 if (name.empty())
1165 {
1167 return true;
1168 }
1169
1170 if (locale < TOTAL_LOCALES)
1171 {
1172 if (maxResults && count++ == maxResults)
1173 {
1175 return true;
1176 }
1177
1178 bool known = target && target->HasSpell(spell->Id);
1179 bool learn = (spell->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL);
1180
1181 SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spell->Effects[0].TriggerSpell);
1182
1183 uint32 talentCost = GetTalentSpellCost(spell->Id);
1184
1185 bool talent = (talentCost > 0);
1186 bool passive = spell->IsPassive();
1187 bool active = target && target->HasAura(spell->Id);
1188
1189 // unit32 used to prevent interpreting uint8 as char at output
1190 // find rank of learned spell for learning spell, or talent rank
1191 uint32 rank = talentCost ? talentCost : learn && learnSpellInfo ? learnSpellInfo->GetRank() : spell->GetRank();
1192
1193 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
1194 std::ostringstream ss;
1195 if (handler->GetSession())
1196 {
1197 ss << spell->Id << " - |cffffffff|Hspell:" << spell->Id << "|h[" << name;
1198 }
1199 else
1200 {
1201 ss << spell->Id << " - " << name;
1202 }
1203
1204 // include rank in link name
1205 if (rank)
1206 {
1207 ss << handler->GetAcoreString(LANG_SPELL_RANK) << rank;
1208 }
1209
1210 if (handler->GetSession())
1211 {
1212 ss << ' ' << localeNames[locale] << "]|h|r";
1213 }
1214 else
1215 {
1216 ss << ' ' << localeNames[locale];
1217 }
1218
1219 if (talent)
1220 {
1221 ss << handler->GetAcoreString(LANG_TALENT);
1222 }
1223
1224 if (passive)
1225 {
1226 ss << handler->GetAcoreString(LANG_PASSIVE);
1227 }
1228
1229 if (learn)
1230 {
1231 ss << handler->GetAcoreString(LANG_LEARN);
1232 }
1233
1234 if (known)
1235 {
1236 ss << handler->GetAcoreString(LANG_KNOWN);
1237 }
1238
1239 if (active)
1240 {
1241 ss << handler->GetAcoreString(LANG_ACTIVE);
1242 }
1243
1244 handler->SendSysMessage(ss.str().c_str());
1245
1246 if (!found)
1247 {
1248 found = true;
1249 }
1250 }
1251
1252 if (!found)
1253 {
1255 }
1256
1257 return true;
1258 }
@ LANG_COMMAND_SPELL_BROKEN
Definition Language.h:521
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:216
static bool IsSpellValid(SpellInfo const *spellInfo)
Definition SpellMgr.cpp:441

References SpellInfo::Effects, ChatHandler::GetAcoreString(), SpellInfo::GetRank(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), GetTalentSpellCost(), Unit::HasAura(), Player::HasSpell(), SpellInfo::Id, SpellInfo::IsPassive(), SpellMgr::IsSpellValid(), LANG_ACTIVE, LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOSPELLFOUND, LANG_COMMAND_SPELL_BROKEN, LANG_KNOWN, LANG_LEARN, LANG_PASSIVE, LANG_SPELL_RANK, LANG_TALENT, localeNames, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), SPELL_EFFECT_LEARN_SPELL, SpellInfo::SpellName, sSpellMgr, and TOTAL_LOCALES.

Referenced by GetCommands().

◆ HandleLookupTaxiNodeCommand()

static bool lookup_commandscript::HandleLookupTaxiNodeCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
1261 {
1262 if (namePart.empty())
1263 {
1264 return false;
1265 }
1266
1267 std::wstring wNamePart;
1268
1269 if (!Utf8toWStr(namePart, wNamePart))
1270 {
1271 return false;
1272 }
1273
1274 // converting string that we try to find to lower case
1275 wstrToLower(wNamePart);
1276
1277 bool found = false;
1278 uint32 count = 0;
1279 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1280
1281 // Search in TaxiNodes.dbc
1282 for (auto nodeEntry : sTaxiNodesStore)
1283 {
1284 int locale = handler->GetSessionDbcLocale();
1285 std::string name = nodeEntry->name[locale];
1286
1287 if (name.empty())
1288 {
1289 continue;
1290 }
1291
1292 if (!Utf8FitTo(name, wNamePart))
1293 {
1294 locale = 0;
1295
1296 for (; locale < TOTAL_LOCALES; ++locale)
1297 {
1298 if (locale == handler->GetSessionDbcLocale())
1299 {
1300 continue;
1301 }
1302
1303 name = nodeEntry->name[locale];
1304 if (name.empty())
1305 {
1306 continue;
1307 }
1308
1309 if (Utf8FitTo(name, wNamePart))
1310 {
1311 break;
1312 }
1313 }
1314 }
1315
1316 if (locale < TOTAL_LOCALES)
1317 {
1318 if (maxResults && count++ == maxResults)
1319 {
1321 return true;
1322 }
1323
1324 // send taxinode in "id - [name] (Map:m X:x Y:y Z:z)" format
1325 if (handler->GetSession())
1326 {
1327 handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CHAT, nodeEntry->ID, nodeEntry->ID, name, localeNames[locale],
1328 nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z);
1329 }
1330 else
1331 {
1332 handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CONSOLE, nodeEntry->ID, name, localeNames[locale],
1333 nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z);
1334 }
1335
1336 if (!found)
1337 {
1338 found = true;
1339 }
1340 }
1341 }
1342 if (!found)
1343 {
1345 }
1346
1347 return true;
1348 }
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
@ LANG_COMMAND_NOTAXINODEFOUND
Definition Language.h:499
@ LANG_TAXINODE_ENTRY_LIST_CHAT
Definition Language.h:918
@ LANG_TAXINODE_ENTRY_LIST_CONSOLE
Definition Language.h:919

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOTAXINODEFOUND, LANG_TAXINODE_ENTRY_LIST_CHAT, LANG_TAXINODE_ENTRY_LIST_CONSOLE, localeNames, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), sTaxiNodesStore, sWorld, TOTAL_LOCALES, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupTeleCommand()

static bool lookup_commandscript::HandleLookupTeleCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
1352 {
1353 if (namePart.empty())
1354 {
1355 return false;
1356 }
1357
1358 std::wstring wNamePart;
1359
1360 if (!Utf8toWStr(namePart, wNamePart))
1361 {
1362 return false;
1363 }
1364
1365 // converting string that we try to find to lower case
1366 wstrToLower(wNamePart);
1367
1368 std::ostringstream reply;
1369 uint32 count = 0;
1370 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1371 bool limitReached = false;
1372
1373 for (auto const& [id, tele] : sObjectMgr->GetGameTeleMap())
1374 {
1375 if (tele.wnameLow.find(wNamePart) == std::wstring::npos)
1376 {
1377 continue;
1378 }
1379
1380 if (maxResults && count++ == maxResults)
1381 {
1382 limitReached = true;
1383 break;
1384 }
1385
1386 if (handler->GetSession())
1387 {
1388 reply << " |cffffffff|Htele:" << id << "|h[" << tele.name << "]|h|r\n";
1389 }
1390 else
1391 {
1392 reply << " " << id << ' ' << tele.name << "\n";
1393 }
1394 }
1395
1396 if (reply.str().empty())
1397 {
1399 }
1400 else
1401 {
1402 handler->PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str());
1403 }
1404
1405 if (limitReached)
1406 {
1408 }
1409
1410 return true;
1411 }
@ LANG_COMMAND_TELE_LOCATION
Definition Language.h:208
@ LANG_COMMAND_TELE_NOLOCATION
Definition Language.h:206

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetSession(), LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_TELE_LOCATION, LANG_COMMAND_TELE_NOLOCATION, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), sObjectMgr, sWorld, Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLookupTitleCommand()

static bool lookup_commandscript::HandleLookupTitleCommand ( ChatHandler handler,
Tail  namePart 
)
inlinestatic
1414 {
1415 if (namePart.empty())
1416 {
1417 return false;
1418 }
1419
1420 // can be nullptr in console call
1421 Player* target = handler->getSelectedPlayer();
1422
1423 // title name have single string arg for player name
1424 char const* targetName = target ? target->GetName().c_str() : "NAME";
1425
1426 std::wstring wNamePart;
1427
1428 if (!Utf8toWStr(namePart, wNamePart))
1429 {
1430 return false;
1431 }
1432
1433 // converting string that we try to find to lower case
1434 wstrToLower(wNamePart);
1435
1436 uint32 counter = 0; // Counter for figure out that we found smth.
1437 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1438
1439 // Search in CharTitles.dbc
1440 for (auto titleInfo : sCharTitlesStore)
1441 {
1442 int locale = handler->GetSessionDbcLocale();
1443 std::string name = titleInfo->nameMale[locale];
1444 if (name.empty())
1445 {
1446 continue;
1447 }
1448
1449 if (!Utf8FitTo(name, wNamePart))
1450 {
1451 locale = 0;
1452 for (; locale < TOTAL_LOCALES; ++locale)
1453 {
1454 if (locale == handler->GetSessionDbcLocale())
1455 {
1456 continue;
1457 }
1458
1459 name = titleInfo->nameMale[locale];
1460 if (name.empty())
1461 {
1462 continue;
1463 }
1464
1465 if (Utf8FitTo(name, wNamePart))
1466 {
1467 break;
1468 }
1469 }
1470 }
1471
1472 if (locale < TOTAL_LOCALES)
1473 {
1474 if (maxResults && counter == maxResults)
1475 {
1477 return true;
1478 }
1479
1480 std::string knownStr = target && target->HasTitle(titleInfo) ? handler->GetAcoreString(LANG_KNOWN) : "";
1481 std::string activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index ? handler->GetAcoreString(LANG_ACTIVE) : "";
1482
1483 std::string titleNameStr = Acore::StringFormat(name, targetName);
1484
1485 // send title in "id (idx:idx) - [namedlink locale]" format
1486 if (handler->GetSession())
1487 handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, titleInfo->ID, titleInfo->bit_index, titleInfo->ID, titleNameStr, localeNames[locale], knownStr, activeStr);
1488 else
1489 handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, titleInfo->ID, titleInfo->bit_index, titleNameStr, localeNames[locale], knownStr, activeStr);
1490
1491 ++counter;
1492 }
1493 }
1494
1495 if (!counter) // if counter == 0 then we found nth
1496 {
1498 }
1499
1500 return true;
1501 }
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
@ LANG_TITLE_LIST_CHAT
Definition Language.h:391
@ LANG_COMMAND_NOTITLEFOUND
Definition Language.h:393
@ LANG_TITLE_LIST_CONSOLE
Definition Language.h:392
@ PLAYER_CHOSEN_TITLE
Definition UpdateFields.h:324
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:305
bool HasTitle(uint32 bitIndex) const
Definition Player.cpp:13268
std::string const & GetName() const
Definition Object.h:464

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetAcoreString(), WorldObject::GetName(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), Object::GetUInt32Value(), Player::HasTitle(), LANG_ACTIVE, LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOTITLEFOUND, LANG_KNOWN, LANG_TITLE_LIST_CHAT, LANG_TITLE_LIST_CONSOLE, localeNames, PLAYER_CHOSEN_TITLE, ChatHandler::PSendSysMessage(), sCharTitlesStore, ChatHandler::SendSysMessage(), Acore::StringFormat(), sWorld, TOTAL_LOCALES, Utf8FitTo(), Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ LookupPlayerSearchCommand()

static bool lookup_commandscript::LookupPlayerSearchCommand ( PreparedQueryResult  result,
int32  limit,
ChatHandler handler 
)
inlinestatic
1628 {
1629 if (!result)
1630 {
1632 return false;
1633 }
1634
1635 int32 counter = 0;
1636 uint32 count = 0;
1637 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1638
1639 do
1640 {
1641 if (maxResults && count++ == maxResults)
1642 {
1644 return true;
1645 }
1646
1647 Field* fields = result->Fetch();
1648 uint32 accountId = fields[0].Get<uint32>();
1649 std::string accountName = fields[1].Get<std::string>();
1650
1652 stmt->SetData(0, accountId);
1653 PreparedQueryResult result2 = CharacterDatabase.Query(stmt);
1654
1655 if (result2)
1656 {
1657 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, accountName, accountId);
1658
1659 do
1660 {
1661 Field* characterFields = result2->Fetch();
1662 ObjectGuid::LowType guid = characterFields[0].Get<uint32>();
1663 std::string name = characterFields[1].Get<std::string>();
1664 uint8 plevel = 0, prace = 0, pclass = 0;
1665 bool online = ObjectAccessor::FindPlayerByLowGUID(guid) != nullptr;
1666
1667 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByName(name))
1668 {
1669 plevel = gpd->Level;
1670 prace = gpd->Race;
1671 pclass = gpd->Class;
1672 }
1673
1674 if (plevel > 0 && prace > 0 && prace <= RACE_DRAENEI && pclass > 0 && pclass <= CLASS_DRUID)
1675 {
1676 handler->PSendSysMessage(" {} (GUID {}) - {} - {} - {}{}", name, guid, EnumUtils::ToTitle(Races(prace)), EnumUtils::ToTitle(Classes(pclass)), plevel, (online ? " - [ONLINE]" : ""));
1677 }
1678 else
1679 {
1680 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name, guid);
1681 }
1682
1683 ++counter;
1684 } while (result2->NextRow() && (limit == -1 || counter < limit));
1685 }
1686 } while (result->NextRow());
1687
1688 if (!counter) // empty accounts only
1689 {
1691 return false;
1692 }
1693
1694 return true;
1695 }
#define sCharacterCache
Definition CharacterCache.h:83
@ CHAR_SEL_CHAR_GUID_NAME_BY_ACC
Definition CharacterDatabase.h:342
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
std::int32_t int32
Definition Define.h:103
@ LANG_LOOKUP_PLAYER_CHARACTER
Definition Language.h:371
@ LANG_LOOKUP_PLAYER_ACCOUNT
Definition Language.h:370
@ LANG_NO_PLAYERS_FOUND
Definition Language.h:372
Classes
Definition SharedDefines.h:139
@ CLASS_DRUID
Definition SharedDefines.h:151
Races
Definition SharedDefines.h:69
static char const * ToTitle(Enum value)
Definition SmartEnum.h:126
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
uint32 LowType
Definition ObjectGuid.h:122
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Definition ObjectAccessor.cpp:251
Definition CharacterCache.h:28

References CHAR_SEL_CHAR_GUID_NAME_BY_ACC, CharacterDatabase, CLASS_DRUID, CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ObjectAccessor::FindPlayerByLowGUID(), Field::Get(), LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_LOOKUP_PLAYER_ACCOUNT, LANG_LOOKUP_PLAYER_CHARACTER, LANG_NO_PLAYERS_FOUND, ChatHandler::PSendSysMessage(), sCharacterCache, ChatHandler::SendErrorMessage(), PreparedStatementBase::SetData(), sWorld, and EnumUtils::ToTitle().

Referenced by HandleLookupPlayerAccountCommand(), HandleLookupPlayerEmailCommand(), and HandleLookupPlayerIpCommand().


The documentation for this class was generated from the following file: