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
42: CommandScript("lookup_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable lookup_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

45 {
46 static ChatCommandTable lookupPlayerCommandTable =
47 {
48 { "ip", HandleLookupPlayerIpCommand, SEC_GAMEMASTER, Console::Yes },
49 { "account", HandleLookupPlayerAccountCommand, SEC_GAMEMASTER, Console::Yes },
50 { "email", HandleLookupPlayerEmailCommand, SEC_GAMEMASTER, Console::Yes }
51 };
52
53 static ChatCommandTable lookupCommandTable =
54 {
55 { "area", HandleLookupAreaCommand, SEC_MODERATOR, Console::Yes },
56 { "creature", HandleLookupCreatureCommand, SEC_MODERATOR, Console::Yes },
57 { "event", HandleLookupEventCommand, SEC_MODERATOR, Console::Yes },
58 { "faction", HandleLookupFactionCommand, SEC_MODERATOR, Console::Yes },
59 { "item", HandleLookupItemCommand, SEC_MODERATOR, Console::Yes },
60 { "item set", HandleLookupItemSetCommand, SEC_MODERATOR, Console::Yes },
61 { "map", HandleLookupMapCommand, SEC_MODERATOR, Console::Yes },
62 { "object", HandleLookupObjectCommand, SEC_MODERATOR, Console::Yes },
63 { "gobject", HandleLookupObjectCommand, SEC_MODERATOR, Console::Yes },
64 { "quest", HandleLookupQuestCommand, SEC_MODERATOR, Console::Yes },
65 { "skill", HandleLookupSkillCommand, SEC_MODERATOR, Console::Yes },
66 { "taxinode", HandleLookupTaxiNodeCommand, SEC_MODERATOR, Console::Yes },
67 { "teleport", HandleLookupTeleCommand, SEC_MODERATOR, Console::Yes },
68 { "title", HandleLookupTitleCommand, SEC_MODERATOR, Console::Yes },
69 { "spell", HandleLookupSpellCommand, SEC_MODERATOR, Console::Yes },
70 { "spell id", HandleLookupSpellIdCommand, SEC_MODERATOR, Console::Yes },
71 { "player", lookupPlayerCommandTable },
72 };
73
74 static ChatCommandTable commandTable =
75 {
76 { "lookup", lookupCommandTable }
77 };
78
79 return commandTable;
80 }
@ SEC_GAMEMASTER
Definition Common.h:59
@ SEC_MODERATOR
Definition Common.h:58
static bool HandleLookupTaxiNodeCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:1267
static bool HandleLookupPlayerIpCommand(ChatHandler *handler, Optional< Tail > ip, Optional< int32 > limit)
Definition cs_lookup.cpp:1586
static bool HandleLookupEventCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:269
static bool HandleLookupMapCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:1510
static bool HandleLookupItemCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:461
static bool HandleLookupPlayerEmailCommand(ChatHandler *handler, std::string email, Optional< int32 > limit)
Definition cs_lookup.cpp:1625
static bool HandleLookupItemSetCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:565
static bool HandleLookupObjectCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:656
static bool HandleLookupAreaCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:82
static bool HandleLookupTeleCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:1358
static bool HandleLookupFactionCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:323
static bool HandleLookupQuestCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:751
static bool HandleLookupSkillCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:897
static bool HandleLookupTitleCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:1420
static bool HandleLookupSpellIdCommand(ChatHandler *handler, SpellInfo const *spell)
Definition cs_lookup.cpp:1154
static bool HandleLookupSpellCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:1002
static bool HandleLookupCreatureCommand(ChatHandler *handler, Tail namePart)
Definition cs_lookup.cpp:173
static bool HandleLookupPlayerAccountCommand(ChatHandler *handler, std::string account, Optional< int32 > limit)
Definition cs_lookup.cpp:1611
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
83 {
84 if (namePart.empty())
85 {
86 return false;
87 }
88
89 std::wstring wNamePart;
90
91 if (!Utf8toWStr(namePart, wNamePart))
92 {
93 return false;
94 }
95
96 bool found = false;
97 uint32 count = 0;
98 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
99
100 // converting string that we try to find to lower case
101 wstrToLower(wNamePart);
102
103 // Search in AreaTable.dbc
104 for (auto areaEntry : sAreaTableStore)
105 {
106 int locale = handler->GetSessionDbcLocale();
107 std::string name = areaEntry->area_name[locale];
108
109 if (name.empty())
110 {
111 continue;
112 }
113
114 if (!Utf8FitTo(name, wNamePart))
115 {
116 locale = 0;
117 for (; locale < TOTAL_LOCALES; ++locale)
118 {
119 if (locale == handler->GetSessionDbcLocale())
120 {
121 continue;
122 }
123
124 name = areaEntry->area_name[locale];
125 if (name.empty())
126 {
127 continue;
128 }
129
130 if (Utf8FitTo(name, wNamePart))
131 {
132 break;
133 }
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 {
149 ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << ' ' << localeNames[locale] << "]|h|r";
150 }
151 else
152 {
153 ss << areaEntry->ID << " - " << name << ' ' << localeNames[locale];
154 }
155
156 handler->SendSysMessage(ss.str().c_str());
157
158 if (!found)
159 {
160 found = true;
161 }
162 }
163 }
164
165 if (!found)
166 {
168 }
169
170 return true;
171 }
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:362
@ 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:363

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
174 {
175 if (namePart.empty())
176 {
177 return false;
178 }
179
180 std::wstring wNamePart;
181
182 // converting string that we try to find to lower case
183 if (!Utf8toWStr(namePart, wNamePart))
184 {
185 return false;
186 }
187
188 wstrToLower(wNamePart);
189
190 bool found = false;
191 uint32 count = 0;
192 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
193
194 for (auto const& [entry, creatureTemplate] : *sObjectMgr->GetCreatureTemplates())
195 {
196 uint32 id = creatureTemplate.Entry;
197 uint8 localeIndex = handler->GetSessionDbLocaleIndex();
198 if (CreatureLocale const* creatureLocale = sObjectMgr->GetCreatureLocale(id))
199 {
200 if (creatureLocale->Name.size() > localeIndex && !creatureLocale->Name[localeIndex].empty())
201 {
202 std::string name = creatureLocale->Name[localeIndex];
203
204 if (Utf8FitTo(name, wNamePart))
205 {
206 if (maxResults && count++ == maxResults)
207 {
209 return true;
210 }
211
212 if (handler->GetSession())
213 {
214 handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name);
215 }
216 else
217 {
219 }
220
221 if (!found)
222 {
223 found = true;
224 }
225
226 continue;
227 }
228 }
229 }
230
231 std::string name = creatureTemplate.Name;
232 if (name.empty())
233 {
234 continue;
235 }
236
237 if (Utf8FitTo(name, wNamePart))
238 {
239 if (maxResults && count++ == maxResults)
240 {
242 return true;
243 }
244
245 if (handler->GetSession())
246 {
247 handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name);
248 }
249 else
250 {
252 }
253
254 if (!found)
255 {
256 found = true;
257 }
258 }
259 }
260
261 if (!found)
262 {
264 }
265
266 return true;
267 }
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:1636
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
270 {
271 if (namePart.empty())
272 return false;
273
274 std::wstring wNamePart;
275
276 // converting string that we try to find to lower case
277 if (!Utf8toWStr(namePart, wNamePart))
278 return false;
279
280 wstrToLower(wNamePart);
281
282 bool found = false;
283 uint32 count = 0;
284 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
285
287 GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
288
289 for (uint32 id = 0; id < events.size(); ++id)
290 {
291 GameEventData const& eventData = events[id];
292
293 std::string descr = eventData.Description;
294 if (descr.empty())
295 continue;
296
297 if (Utf8FitTo(descr, wNamePart))
298 {
299 if (maxResults && count++ == maxResults)
300 {
302 return true;
303 }
304
305 std::string active = activeEvents.find(id) != activeEvents.end() ? handler->GetAcoreString(LANG_ACTIVE) : "";
306
307 if (handler->GetSession())
308 handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.Description, active);
309 else
310 handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.Description, active);
311
312 if (!found)
313 found = true;
314 }
315 }
316
317 if (!found)
319
320 return true;
321 }
#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
324 {
325 if (namePart.empty())
326 {
327 return false;
328 }
329
330 // Can be nullptr at console call
331 Player* target = handler->getSelectedPlayer();
332
333 std::wstring wNamePart;
334
335 if (!Utf8toWStr(namePart, wNamePart))
336 {
337 return false;
338 }
339
340 // converting string that we try to find to lower case
341 wstrToLower(wNamePart);
342
343 bool found = false;
344 uint32 count = 0;
345 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
346
347 for (auto factionEntry : sFactionStore)
348 {
349 FactionState const* factionState = target ? target->GetReputationMgr().GetState(factionEntry) : nullptr;
350
351 int locale = handler->GetSessionDbcLocale();
352 std::string name = factionEntry->name[locale];
353 if (name.empty())
354 {
355 continue;
356 }
357
358 if (!Utf8FitTo(name, wNamePart))
359 {
360 locale = 0;
361
362 for (; locale < TOTAL_LOCALES; ++locale)
363 {
364 if (locale == handler->GetSessionDbcLocale())
365 {
366 continue;
367 }
368
369 name = factionEntry->name[locale];
370 if (name.empty())
371 {
372 continue;
373 }
374
375 if (Utf8FitTo(name, wNamePart))
376 {
377 break;
378 }
379 }
380 }
381
382 if (locale < TOTAL_LOCALES)
383 {
384 if (maxResults && count++ == maxResults)
385 {
387 return true;
388 }
389
390 // send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format
391 // or "id - [faction] [no reputation]" format
392 std::ostringstream ss;
393 if (handler->GetSession())
394 {
395 ss << factionEntry->ID << " - |cffffffff|Hfaction:" << factionEntry->ID << "|h[" << name << ' ' << localeNames[locale] << "]|h|r";
396 }
397 else
398 {
399 ss << factionEntry->ID << " - " << name << ' ' << localeNames[locale];
400 }
401
402 if (factionState) // and then target != nullptr also
403 {
404 uint32 index = target->GetReputationMgr().GetReputationRankStrIndex(factionEntry);
405 std::string rankName = handler->GetAcoreString(index);
406
407 ss << ' ' << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
408
409 if (factionState->Flags & FACTION_FLAG_VISIBLE)
410 {
411 ss << handler->GetAcoreString(LANG_FACTION_VISIBLE);
412 }
413
414 if (factionState->Flags & FACTION_FLAG_AT_WAR)
415 {
416 ss << handler->GetAcoreString(LANG_FACTION_ATWAR);
417 }
418
419 if (factionState->Flags & FACTION_FLAG_PEACE_FORCED)
420 {
422 }
423
424 if (factionState->Flags & FACTION_FLAG_HIDDEN)
425 {
426 ss << handler->GetAcoreString(LANG_FACTION_HIDDEN);
427 }
428
429 if (factionState->Flags & FACTION_FLAG_INVISIBLE_FORCED)
430 {
432 }
433
434 if (factionState->Flags & FACTION_FLAG_INACTIVE)
435 {
437 }
438 }
439 else
440 {
442 }
443
444 handler->SendSysMessage(ss.str().c_str());
445
446 if (!found)
447 {
448 found = true;
449 }
450 }
451 }
452
453 if (!found)
454 {
456 }
457
458 return true;
459 }
@ 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:1081
ReputationMgr & GetReputationMgr()
Definition Player.h:2133
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
462 {
463 if (namePart.empty())
464 {
465 return false;
466 }
467
468 std::wstring wNamePart;
469
470 // converting string that we try to find to lower case
471 if (!Utf8toWStr(namePart, wNamePart))
472 {
473 return false;
474 }
475
476 wstrToLower(wNamePart);
477
478 bool found = false;
479 uint32 count = 0;
480 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
481
482 // Search in `item_template`
483 for (auto const& [entry, itemTemplate] : *sObjectMgr->GetItemTemplateStore())
484 {
485 int localeIndex = handler->GetSessionDbLocaleIndex();
486 if (localeIndex >= 0)
487 {
488 uint8 ulocaleIndex = uint8(localeIndex);
489 if (ItemLocale const* il = sObjectMgr->GetItemLocale(itemTemplate.ItemId))
490 {
491 if (il->Name.size() > ulocaleIndex && !il->Name[ulocaleIndex].empty())
492 {
493 std::string name = il->Name[ulocaleIndex];
494
495 if (Utf8FitTo(name, wNamePart))
496 {
497 if (maxResults && count++ == maxResults)
498 {
500 return true;
501 }
502
503 if (handler->GetSession())
504 {
505 std::ostringstream color;
506 color << std::hex << ItemQualityColors[itemTemplate.Quality];
507 handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, color.str(), itemTemplate.ItemId, name);
508 }
509 else
510 {
511 handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name);
512 }
513
514 if (!found)
515 {
516 found = true;
517 }
518
519 continue;
520 }
521 }
522 }
523 }
524
525 std::string name = itemTemplate.Name1;
526 if (name.empty())
527 {
528 continue;
529 }
530
531 if (Utf8FitTo(name, wNamePart))
532 {
533 if (maxResults && count++ == maxResults)
534 {
536 return true;
537 }
538
539 if (handler->GetSession())
540 {
541 std::ostringstream color;
542 color << std::hex << ItemQualityColors[itemTemplate.Quality];
543 handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, color.str(), itemTemplate.ItemId, name);
544 }
545 else
546 {
547 handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name);
548 }
549
550 if (!found)
551 {
552 found = true;
553 }
554 }
555 }
556
557 if (!found)
558 {
560 }
561
562 return true;
563 }
@ 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
566 {
567 if (namePart.empty())
568 {
569 return false;
570 }
571
572 std::wstring wNamePart;
573
574 if (!Utf8toWStr(namePart, wNamePart))
575 {
576 return false;
577 }
578
579 // converting string that we try to find to lower case
580 wstrToLower(wNamePart);
581
582 bool found = false;
583 uint32 count = 0;
584 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
585
586 // Search in ItemSet.dbc
587 for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++)
588 {
589 ItemSetEntry const* set = sItemSetStore.LookupEntry(id);
590 if (set)
591 {
592 int locale = handler->GetSessionDbcLocale();
593 std::string name = set->name[locale];
594 if (name.empty())
595 {
596 continue;
597 }
598
599 if (!Utf8FitTo(name, wNamePart))
600 {
601 locale = 0;
602 for (; locale < TOTAL_LOCALES; ++locale)
603 {
604 if (locale == handler->GetSessionDbcLocale())
605 {
606 continue;
607 }
608
609 name = set->name[locale];
610 if (name.empty())
611 {
612 continue;
613 }
614
615 if (Utf8FitTo(name, wNamePart))
616 {
617 break;
618 }
619 }
620 }
621
622 if (locale < TOTAL_LOCALES)
623 {
624 if (maxResults && count++ == maxResults)
625 {
627 return true;
628 }
629
630 // send item set in "id - [namedlink locale]" format
631 if (handler->GetSession())
632 {
633 handler->PSendSysMessage(LANG_ITEMSET_LIST_CHAT, id, id, name, localeNames[locale]);
634 }
635 else
636 {
637 handler->PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name, localeNames[locale]);
638 }
639
640 if (!found)
641 {
642 found = true;
643 }
644 }
645 }
646 }
647
648 if (!found)
649 {
651 }
652
653 return true;
654 }
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:1231
char const * name[16]
Definition DBCStructure.h:1233

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
1511 {
1512 if (namePart.empty())
1513 {
1514 return false;
1515 }
1516
1517 std::wstring wNamePart;
1518
1519 if (!Utf8toWStr(namePart, wNamePart))
1520 {
1521 return false;
1522 }
1523
1524 wstrToLower(wNamePart);
1525
1526 uint32 counter = 0;
1527 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1528 uint8 locale = handler->GetSession() ? handler->GetSession()->GetSessionDbcLocale() : sWorld->GetDefaultDbcLocale();
1529
1530 // search in Map.dbc
1531 for (auto mapInfo : sMapStore)
1532 {
1533 std::string name = mapInfo->name[locale];
1534
1535 if (name.empty())
1536 {
1537 continue;
1538 }
1539
1540 if (Utf8FitTo(name, wNamePart) && locale < TOTAL_LOCALES)
1541 {
1542 if (maxResults && counter == maxResults)
1543 {
1545 return true;
1546 }
1547
1548 std::ostringstream ss;
1549 ss << mapInfo->MapID << " - [" << name << ']';
1550
1551 if (mapInfo->IsContinent())
1552 {
1553 ss << handler->GetAcoreString(LANG_CONTINENT);
1554 }
1555
1556 switch (mapInfo->map_type)
1557 {
1558 case MAP_INSTANCE:
1559 ss << handler->GetAcoreString(LANG_INSTANCE);
1560 break;
1561 case MAP_RAID:
1562 ss << handler->GetAcoreString(LANG_RAID);
1563 break;
1564 case MAP_BATTLEGROUND:
1565 ss << handler->GetAcoreString(LANG_BATTLEGROUND);
1566 break;
1567 case MAP_ARENA:
1568 ss << handler->GetAcoreString(LANG_ARENA);
1569 break;
1570 }
1571
1572 handler->SendSysMessage(ss.str().c_str());
1573
1574 ++counter;
1575 }
1576 }
1577
1578 if (!counter)
1579 {
1581 }
1582
1583 return true;
1584 }
@ 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
657 {
658 if (namePart.empty())
659 {
660 return false;
661 }
662
663 std::wstring wNamePart;
664
665 // converting string that we try to find to lower case
666 if (!Utf8toWStr(namePart, wNamePart))
667 {
668 return false;
669 }
670
671 wstrToLower(wNamePart);
672
673 bool found = false;
674 uint32 count = 0;
675 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
676
677 for (auto const& [entry, gameObjectTemplate] : *sObjectMgr->GetGameObjectTemplates())
678 {
679 uint8 localeIndex = handler->GetSessionDbLocaleIndex();
680 if (GameObjectLocale const* objectLocalte = sObjectMgr->GetGameObjectLocale(gameObjectTemplate.entry))
681 {
682 if (objectLocalte->Name.size() > localeIndex && !objectLocalte->Name[localeIndex].empty())
683 {
684 std::string name = objectLocalte->Name[localeIndex];
685
686 if (Utf8FitTo(name, wNamePart))
687 {
688 if (maxResults && count++ == maxResults)
689 {
691 return true;
692 }
693
694 if (handler->GetSession())
695 {
696 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name);
697 }
698 else
699 {
700 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name);
701 }
702
703 if (!found)
704 {
705 found = true;
706 }
707
708 continue;
709 }
710 }
711 }
712
713 std::string name = gameObjectTemplate.name;
714 if (name.empty())
715 {
716 continue;
717 }
718
719 if (Utf8FitTo(name, wNamePart))
720 {
721 if (maxResults && count++ == maxResults)
722 {
724 return true;
725 }
726
727 if (handler->GetSession())
728 {
729 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name);
730 }
731 else
732 {
733 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name);
734 }
735
736 if (!found)
737 {
738 found = true;
739 }
740 }
741 }
742
743 if (!found)
744 {
746 }
747
748 return true;
749 }
@ 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
1612 {
1613 if (!Utf8ToUpperOnlyLatin(account))
1614 {
1615 return false;
1616 }
1617
1619 stmt->SetData(0, account);
1620 PreparedQueryResult result = LoginDatabase.Query(stmt);
1621
1622 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1623 }
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:1634

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
1626 {
1628 stmt->SetData(0, email);
1629 PreparedQueryResult result = LoginDatabase.Query(stmt);
1630
1631 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1632 }
@ 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
1587 {
1588 Player* target = handler->getSelectedPlayerOrSelf();
1589 if (!ip)
1590 {
1591 // nullptr only if used from console
1592 if (!target || target == handler->GetSession()->GetPlayer())
1593 {
1594 return false;
1595 }
1596
1597 *ip = target->GetSession()->GetRemoteAddress();
1598 }
1599 else
1600 {
1601 ip = *ip;
1602 }
1603
1605 stmt->SetData(0, *ip);
1606 PreparedQueryResult result = LoginDatabase.Query(stmt);
1607
1608 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1609 }
@ LOGIN_SEL_ACCOUNT_BY_IP
Definition LoginDatabase.h:54
Player * getSelectedPlayerOrSelf() const
Definition Chat.cpp:418
WorldSession * GetSession() const
Definition Player.h:2005
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
752 {
753 if (namePart.empty())
754 {
755 return false;
756 }
757
758 // can be nullptr at console call
759 Player* target = handler->getSelectedPlayer();
760
761 std::wstring wNamePart;
762
763 // converting string that we try to find to lower case
764 if (!Utf8toWStr(namePart, wNamePart))
765 {
766 return false;
767 }
768
769 wstrToLower(wNamePart);
770
771 bool found = false;
772 uint32 count = 0;
773 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
774
775 for (auto const& [entry, qInfo] : sObjectMgr->GetQuestTemplates())
776 {
777 int localeIndex = handler->GetSessionDbLocaleIndex();
778 if (localeIndex >= 0)
779 {
780 uint8 ulocaleIndex = uint8(localeIndex);
781 if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(qInfo->GetQuestId()))
782 {
783 if (questLocale->Title.size() > ulocaleIndex && !questLocale->Title[ulocaleIndex].empty())
784 {
785 std::string title = questLocale->Title[ulocaleIndex];
786
787 if (Utf8FitTo(title, wNamePart))
788 {
789 if (maxResults && count++ == maxResults)
790 {
792 return true;
793 }
794
795 std::string statusStr = "";
796
797 if (target)
798 {
799 QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
800
801 switch (status)
802 {
804 statusStr = handler->GetAcoreString(LANG_COMPLETE);
805 break;
807 statusStr = handler->GetAcoreString(LANG_ACTIVE);
808 break;
810 statusStr = handler->GetAcoreString(LANG_REWARDED);
811 break;
812 default:
813 break;
814 }
815 }
816
817 if (handler->GetSession())
818 {
819 handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title, statusStr);
820 }
821 else
822 {
823 handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title, statusStr);
824 }
825
826 if (!found)
827 {
828 found = true;
829 }
830
831 continue;
832 }
833 }
834 }
835 }
836
837 std::string title = qInfo->GetTitle();
838 if (title.empty())
839 {
840 continue;
841 }
842
843 if (Utf8FitTo(title, wNamePart))
844 {
845 if (maxResults && count++ == maxResults)
846 {
848 return true;
849 }
850
851 std::string statusStr = "";
852
853 if (target)
854 {
855 QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
856
857 switch (status)
858 {
860 statusStr = handler->GetAcoreString(LANG_COMPLETE);
861 break;
863 statusStr = handler->GetAcoreString(LANG_ACTIVE);
864 break;
866 statusStr = handler->GetAcoreString(LANG_REWARDED);
867 break;
868 default:
869 break;
870 }
871 }
872
873 if (handler->GetSession())
874 {
875 handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title, statusStr);
876 }
877 else
878 {
879 handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title, statusStr);
880 }
881
882 if (!found)
883 {
884 found = true;
885 }
886 }
887 }
888
889 if (!found)
890 {
892 }
893
894 return true;
895 }
@ 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
898 {
899 if (namePart.empty())
900 {
901 return false;
902 }
903
904 // can be nullptr in console call
905 Player* target = handler->getSelectedPlayer();
906
907 std::wstring wNamePart;
908
909 if (!Utf8toWStr(namePart, wNamePart))
910 {
911 return false;
912 }
913
914 // converting string that we try to find to lower case
915 wstrToLower(wNamePart);
916
917 bool found = false;
918 uint32 count = 0;
919 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
920
921 // Search in SkillLine.dbc
922 for (auto skillInfo : sSkillLineStore)
923 {
924 int locale = handler->GetSessionDbcLocale();
925 std::string name = skillInfo->name[locale];
926
927 if (name.empty())
928 {
929 continue;
930 }
931
932 if (!Utf8FitTo(name, wNamePart))
933 {
934 locale = 0;
935 for (; locale < TOTAL_LOCALES; ++locale)
936 {
937 if (locale == handler->GetSessionDbcLocale())
938 {
939 continue;
940 }
941
942 name = skillInfo->name[locale];
943 if (name.empty())
944 {
945 continue;
946 }
947
948 if (Utf8FitTo(name, wNamePart))
949 {
950 break;
951 }
952 }
953 }
954
955 if (locale < TOTAL_LOCALES)
956 {
957 if (maxResults && count++ == maxResults)
958 {
960 return true;
961 }
962
963 std::string valStr;
964 std::string knownStr;
965
966 if (target && target->HasSkill(skillInfo->id))
967 {
968 knownStr = handler->GetAcoreString(LANG_KNOWN);
969 uint32 curValue = target->GetPureSkillValue(skillInfo->id);
970 uint32 maxValue = target->GetPureMaxSkillValue(skillInfo->id);
971 uint32 permValue = target->GetSkillPermBonusValue(skillInfo->id);
972 uint32 tempValue = target->GetSkillTempBonusValue(skillInfo->id);
973
974 valStr = Acore::StringFormat(handler->GetAcoreString(LANG_SKILL_VALUES), curValue, maxValue, permValue, tempValue);
975 }
976
977 // send skill in "id - [namedlink locale]" format
978 if (handler->GetSession())
979 {
980 handler->PSendSysMessage(LANG_SKILL_LIST_CHAT, skillInfo->id, skillInfo->id, name, localeNames[locale], knownStr, valStr);
981 }
982 else
983 {
984 handler->PSendSysMessage(LANG_SKILL_LIST_CONSOLE, skillInfo->id, name, localeNames[locale], knownStr, valStr);
985 }
986
987 if (!found)
988 {
989 found = true;
990 }
991 }
992 }
993
994 if (!found)
995 {
997 }
998
999 return true;
1000 }
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:5543
int16 GetSkillTempBonusValue(uint32 skill) const
Definition Player.cpp:5567
int16 GetSkillPermBonusValue(uint32 skill) const
Definition Player.cpp:5555
bool HasSkill(uint32 skill) const
Definition Player.cpp:5457
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition Player.cpp:5513
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
1003 {
1004 if (namePart.empty())
1005 {
1006 return false;
1007 }
1008
1009 // can be nullptr at console call
1010 Player* target = handler->getSelectedPlayer();
1011
1012 std::wstring wNamePart;
1013
1014 if (!Utf8toWStr(namePart, wNamePart))
1015 {
1016 return false;
1017 }
1018
1019 // converting string that we try to find to lower case
1020 wstrToLower(wNamePart);
1021
1022 bool found = false;
1023 uint32 count = 0;
1024 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1025
1026 // Search in Spell.dbc
1027 for (uint32 id = 0; id < sSpellMgr->GetSpellInfoStoreSize(); id++)
1028 {
1029 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id);
1030 if (spellInfo)
1031 {
1032 int locale = handler->GetSessionDbcLocale();
1033 std::string name = spellInfo->SpellName[locale];
1034 if (name.empty())
1035 {
1036 continue;
1037 }
1038
1039 if (!Utf8FitTo(name, wNamePart))
1040 {
1041 locale = 0;
1042 for (; locale < TOTAL_LOCALES; ++locale)
1043 {
1044 if (locale == handler->GetSessionDbcLocale())
1045 {
1046 continue;
1047 }
1048
1049 name = spellInfo->SpellName[locale];
1050 if (name.empty())
1051 {
1052 continue;
1053 }
1054
1055 if (Utf8FitTo(name, wNamePart))
1056 {
1057 break;
1058 }
1059 }
1060 }
1061
1062 if (locale < TOTAL_LOCALES)
1063 {
1064 if (maxResults && count++ == maxResults)
1065 {
1067 return true;
1068 }
1069
1070 bool known = target && target->HasSpell(id);
1071 bool learn = (spellInfo->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL);
1072
1073 SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[0].TriggerSpell);
1074
1075 uint32 talentCost = GetTalentSpellCost(id);
1076
1077 bool talent = (talentCost > 0);
1078 bool passive = spellInfo->IsPassive();
1079 bool active = target && target->HasAura(id);
1080
1081 // unit32 used to prevent interpreting uint8 as char at output
1082 // find rank of learned spell for learning spell, or talent rank
1083 uint32 rank = talentCost ? talentCost : learn && learnSpellInfo ? learnSpellInfo->GetRank() : spellInfo->GetRank();
1084
1085 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
1086 std::ostringstream ss;
1087 if (handler->GetSession())
1088 {
1089 ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name;
1090 }
1091 else
1092 {
1093 ss << id << " - " << name;
1094 }
1095
1096 // include rank in link name
1097 if (rank)
1098 {
1099 ss << handler->GetAcoreString(LANG_SPELL_RANK) << rank;
1100 }
1101
1102 if (handler->GetSession())
1103 {
1104 ss << ' ' << localeNames[locale] << "]|h|r";
1105 }
1106 else
1107 {
1108 ss << ' ' << localeNames[locale];
1109 }
1110
1111 if (talent)
1112 {
1113 ss << handler->GetAcoreString(LANG_TALENT);
1114 }
1115
1116 if (passive)
1117 {
1118 ss << handler->GetAcoreString(LANG_PASSIVE);
1119 }
1120
1121 if (learn)
1122 {
1123 ss << handler->GetAcoreString(LANG_LEARN);
1124 }
1125
1126 if (known)
1127 {
1128 ss << handler->GetAcoreString(LANG_KNOWN);
1129 }
1130
1131 if (active)
1132 {
1133 ss << handler->GetAcoreString(LANG_ACTIVE);
1134 }
1135
1136 handler->SendSysMessage(ss.str().c_str());
1137
1138 if (!found)
1139 {
1140 found = true;
1141 }
1142 }
1143 }
1144 }
1145
1146 if (!found)
1147 {
1149 }
1150
1151 return true;
1152 }
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:3899
Definition SpellInfo.h:316
bool IsPassive() const
Definition SpellInfo.cpp:1098
uint8 GetRank() const
Definition SpellInfo.cpp:2494
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:5753

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
1155 {
1156 // can be nullptr at console call
1157 Player* target = handler->getSelectedPlayer();
1158
1159 bool found = false;
1160 uint32 count = 0;
1161 uint32 maxResults = 1;
1162
1163 if (!SpellMgr::IsSpellValid(spell))
1164 {
1165 handler->SendErrorMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
1166 return false;
1167 }
1168
1169 int locale = handler->GetSessionDbcLocale();
1170 std::string name = spell->SpellName[locale];
1171 if (name.empty())
1172 {
1174 return true;
1175 }
1176
1177 if (locale < TOTAL_LOCALES)
1178 {
1179 if (maxResults && count++ == maxResults)
1180 {
1182 return true;
1183 }
1184
1185 bool known = target && target->HasSpell(spell->Id);
1186 bool learn = (spell->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL);
1187
1188 SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spell->Effects[0].TriggerSpell);
1189
1190 uint32 talentCost = GetTalentSpellCost(spell->Id);
1191
1192 bool talent = (talentCost > 0);
1193 bool passive = spell->IsPassive();
1194 bool active = target && target->HasAura(spell->Id);
1195
1196 // unit32 used to prevent interpreting uint8 as char at output
1197 // find rank of learned spell for learning spell, or talent rank
1198 uint32 rank = talentCost ? talentCost : learn && learnSpellInfo ? learnSpellInfo->GetRank() : spell->GetRank();
1199
1200 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
1201 std::ostringstream ss;
1202 if (handler->GetSession())
1203 {
1204 ss << spell->Id << " - |cffffffff|Hspell:" << spell->Id << "|h[" << name;
1205 }
1206 else
1207 {
1208 ss << spell->Id << " - " << name;
1209 }
1210
1211 // include rank in link name
1212 if (rank)
1213 {
1214 ss << handler->GetAcoreString(LANG_SPELL_RANK) << rank;
1215 }
1216
1217 if (handler->GetSession())
1218 {
1219 ss << ' ' << localeNames[locale] << "]|h|r";
1220 }
1221 else
1222 {
1223 ss << ' ' << localeNames[locale];
1224 }
1225
1226 if (talent)
1227 {
1228 ss << handler->GetAcoreString(LANG_TALENT);
1229 }
1230
1231 if (passive)
1232 {
1233 ss << handler->GetAcoreString(LANG_PASSIVE);
1234 }
1235
1236 if (learn)
1237 {
1238 ss << handler->GetAcoreString(LANG_LEARN);
1239 }
1240
1241 if (known)
1242 {
1243 ss << handler->GetAcoreString(LANG_KNOWN);
1244 }
1245
1246 if (active)
1247 {
1248 ss << handler->GetAcoreString(LANG_ACTIVE);
1249 }
1250
1251 handler->SendSysMessage(ss.str().c_str());
1252
1253 if (!found)
1254 {
1255 found = true;
1256 }
1257 }
1258
1259 if (!found)
1260 {
1262 }
1263
1264 return true;
1265 }
@ 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
1268 {
1269 if (namePart.empty())
1270 {
1271 return false;
1272 }
1273
1274 std::wstring wNamePart;
1275
1276 if (!Utf8toWStr(namePart, wNamePart))
1277 {
1278 return false;
1279 }
1280
1281 // converting string that we try to find to lower case
1282 wstrToLower(wNamePart);
1283
1284 bool found = false;
1285 uint32 count = 0;
1286 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1287
1288 // Search in TaxiNodes.dbc
1289 for (auto nodeEntry : sTaxiNodesStore)
1290 {
1291 int locale = handler->GetSessionDbcLocale();
1292 std::string name = nodeEntry->name[locale];
1293
1294 if (name.empty())
1295 {
1296 continue;
1297 }
1298
1299 if (!Utf8FitTo(name, wNamePart))
1300 {
1301 locale = 0;
1302
1303 for (; locale < TOTAL_LOCALES; ++locale)
1304 {
1305 if (locale == handler->GetSessionDbcLocale())
1306 {
1307 continue;
1308 }
1309
1310 name = nodeEntry->name[locale];
1311 if (name.empty())
1312 {
1313 continue;
1314 }
1315
1316 if (Utf8FitTo(name, wNamePart))
1317 {
1318 break;
1319 }
1320 }
1321 }
1322
1323 if (locale < TOTAL_LOCALES)
1324 {
1325 if (maxResults && count++ == maxResults)
1326 {
1328 return true;
1329 }
1330
1331 // send taxinode in "id - [name] (Map:m X:x Y:y Z:z)" format
1332 if (handler->GetSession())
1333 {
1334 handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CHAT, nodeEntry->ID, nodeEntry->ID, name, localeNames[locale],
1335 nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z);
1336 }
1337 else
1338 {
1339 handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CONSOLE, nodeEntry->ID, name, localeNames[locale],
1340 nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z);
1341 }
1342
1343 if (!found)
1344 {
1345 found = true;
1346 }
1347 }
1348 }
1349 if (!found)
1350 {
1352 }
1353
1354 return true;
1355 }
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
1359 {
1360 if (namePart.empty())
1361 {
1362 return false;
1363 }
1364
1365 std::wstring wNamePart;
1366
1367 if (!Utf8toWStr(namePart, wNamePart))
1368 {
1369 return false;
1370 }
1371
1372 // converting string that we try to find to lower case
1373 wstrToLower(wNamePart);
1374
1375 std::ostringstream reply;
1376 uint32 count = 0;
1377 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1378 bool limitReached = false;
1379
1380 for (auto const& [id, tele] : sObjectMgr->GetGameTeleMap())
1381 {
1382 if (tele.wnameLow.find(wNamePart) == std::wstring::npos)
1383 {
1384 continue;
1385 }
1386
1387 if (maxResults && count++ == maxResults)
1388 {
1389 limitReached = true;
1390 break;
1391 }
1392
1393 if (handler->GetSession())
1394 {
1395 reply << " |cffffffff|Htele:" << id << "|h[" << tele.name << "]|h|r\n";
1396 }
1397 else
1398 {
1399 reply << " " << id << ' ' << tele.name << "\n";
1400 }
1401 }
1402
1403 if (reply.str().empty())
1404 {
1406 }
1407 else
1408 {
1409 handler->PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str());
1410 }
1411
1412 if (limitReached)
1413 {
1415 }
1416
1417 return true;
1418 }
@ 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
1421 {
1422 if (namePart.empty())
1423 {
1424 return false;
1425 }
1426
1427 // can be nullptr in console call
1428 Player* target = handler->getSelectedPlayer();
1429
1430 // title name have single string arg for player name
1431 char const* targetName = target ? target->GetName().c_str() : "NAME";
1432
1433 std::wstring wNamePart;
1434
1435 if (!Utf8toWStr(namePart, wNamePart))
1436 {
1437 return false;
1438 }
1439
1440 // converting string that we try to find to lower case
1441 wstrToLower(wNamePart);
1442
1443 uint32 counter = 0; // Counter for figure out that we found smth.
1444 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1445
1446 // Search in CharTitles.dbc
1447 for (auto titleInfo : sCharTitlesStore)
1448 {
1449 int locale = handler->GetSessionDbcLocale();
1450 std::string name = titleInfo->nameMale[locale];
1451 if (name.empty())
1452 {
1453 continue;
1454 }
1455
1456 if (!Utf8FitTo(name, wNamePart))
1457 {
1458 locale = 0;
1459 for (; locale < TOTAL_LOCALES; ++locale)
1460 {
1461 if (locale == handler->GetSessionDbcLocale())
1462 {
1463 continue;
1464 }
1465
1466 name = titleInfo->nameMale[locale];
1467 if (name.empty())
1468 {
1469 continue;
1470 }
1471
1472 if (Utf8FitTo(name, wNamePart))
1473 {
1474 break;
1475 }
1476 }
1477 }
1478
1479 if (locale < TOTAL_LOCALES)
1480 {
1481 if (maxResults && counter == maxResults)
1482 {
1484 return true;
1485 }
1486
1487 std::string knownStr = target && target->HasTitle(titleInfo) ? handler->GetAcoreString(LANG_KNOWN) : "";
1488 std::string activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index ? handler->GetAcoreString(LANG_ACTIVE) : "";
1489
1490 std::string titleNameStr = Acore::StringFormat(name, targetName);
1491
1492 // send title in "id (idx:idx) - [namedlink locale]" format
1493 if (handler->GetSession())
1494 handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, titleInfo->ID, titleInfo->bit_index, titleInfo->ID, titleNameStr, localeNames[locale], knownStr, activeStr);
1495 else
1496 handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, titleInfo->ID, titleInfo->bit_index, titleNameStr, localeNames[locale], knownStr, activeStr);
1497
1498 ++counter;
1499 }
1500 }
1501
1502 if (!counter) // if counter == 0 then we found nth
1503 {
1505 }
1506
1507 return true;
1508 }
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:13383
std::string const & GetName() const
Definition Object.h:463

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
1635 {
1636 if (!result)
1637 {
1639 return false;
1640 }
1641
1642 int32 counter = 0;
1643 uint32 count = 0;
1644 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1645
1646 do
1647 {
1648 if (maxResults && count++ == maxResults)
1649 {
1651 return true;
1652 }
1653
1654 Field* fields = result->Fetch();
1655 uint32 accountId = fields[0].Get<uint32>();
1656 std::string accountName = fields[1].Get<std::string>();
1657
1659 stmt->SetData(0, accountId);
1660 PreparedQueryResult result2 = CharacterDatabase.Query(stmt);
1661
1662 if (result2)
1663 {
1664 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, accountName, accountId);
1665
1666 do
1667 {
1668 Field* characterFields = result2->Fetch();
1669 ObjectGuid::LowType guid = characterFields[0].Get<uint32>();
1670 std::string name = characterFields[1].Get<std::string>();
1671 uint8 plevel = 0, prace = 0, pclass = 0;
1672 bool online = ObjectAccessor::FindPlayerByLowGUID(guid) != nullptr;
1673
1674 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByName(name))
1675 {
1676 plevel = gpd->Level;
1677 prace = gpd->Race;
1678 pclass = gpd->Class;
1679 }
1680
1681 if (plevel > 0 && prace > 0 && prace <= RACE_DRAENEI && pclass > 0 && pclass <= CLASS_DRUID)
1682 {
1683 handler->PSendSysMessage(" {} (GUID {}) - {} - {} - {}{}", name, guid, EnumUtils::ToTitle(Races(prace)), EnumUtils::ToTitle(Classes(pclass)), plevel, (online ? " - [ONLINE]" : ""));
1684 }
1685 else
1686 {
1687 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name, guid);
1688 }
1689
1690 ++counter;
1691 } while (result2->NextRow() && (limit == -1 || counter < limit));
1692 }
1693 } while (result->NextRow());
1694
1695 if (!counter) // empty accounts only
1696 {
1698 return false;
1699 }
1700
1701 return true;
1702 }
#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: