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
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- 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
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
static bool HandleLookupTaxiNodeCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1281
static bool HandleLookupPlayerIpCommand(ChatHandler *handler, Optional< Tail > ip, Optional< int32 > limit)
Definition: cs_lookup.cpp:1604
static bool HandleLookupEventCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:269
static bool HandleLookupMapCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1528
static bool HandleLookupItemCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:475
static bool HandleLookupPlayerEmailCommand(ChatHandler *handler, std::string email, Optional< int32 > limit)
Definition: cs_lookup.cpp:1643
static bool HandleLookupItemSetCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:579
static bool HandleLookupObjectCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:670
static bool HandleLookupAreaCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:82
static bool HandleLookupTeleCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1372
static bool HandleLookupFactionCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:337
static bool HandleLookupQuestCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:765
static bool HandleLookupSkillCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:911
static bool HandleLookupTitleCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1434
static bool HandleLookupSpellIdCommand(ChatHandler *handler, SpellInfo const *spell)
Definition: cs_lookup.cpp:1168
static bool HandleLookupSpellCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1016
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:1629

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 }
@ TOTAL_LOCALES
Definition: Common.h:76
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
std::uint32_t uint32
Definition: Define.h:107
char const * localeNames[TOTAL_LOCALES]
Definition: Common.cpp:20
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
@ CONFIG_MAX_RESULTS_LOOKUP_COMMANDS
Definition: IWorld.h:362
@ LANG_COMMAND_NOAREAFOUND
Definition: Language.h:474
@ LANG_COMMAND_LOOKUP_MAX_RESULTS
Definition: Language.h:1076
#define sWorld
Definition: World.h:444
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:213
WorldSession * GetSession()
Definition: Chat.h:244
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:872
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:162

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
#define sObjectMgr
Definition: ObjectMgr.h:1623
@ LANG_COMMAND_NOCREATUREFOUND
Definition: Language.h:479
@ LANG_CREATURE_ENTRY_LIST_CONSOLE
Definition: Language.h:893
@ LANG_CREATURE_ENTRY_LIST_CHAT
Definition: Language.h:557
virtual int GetSessionDbLocaleIndex() const
Definition: Chat.cpp:877
Definition: CreatureData.h:346

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 {
273 return false;
274 }
275
276 std::wstring wNamePart;
277
278 // converting string that we try to find to lower case
279 if (!Utf8toWStr(namePart, wNamePart))
280 {
281 return false;
282 }
283
284 wstrToLower(wNamePart);
285
286 bool found = false;
287 uint32 count = 0;
288 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
289
291 GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
292
293 for (uint32 id = 0; id < events.size(); ++id)
294 {
295 GameEventData const& eventData = events[id];
296
297 std::string descr = eventData.description;
298 if (descr.empty())
299 {
300 continue;
301 }
302
303 if (Utf8FitTo(descr, wNamePart))
304 {
305 if (maxResults && count++ == maxResults)
306 {
308 return true;
309 }
310
311 char const* active = activeEvents.find(id) != activeEvents.end() ? handler->GetAcoreString(LANG_ACTIVE) : "";
312
313 if (handler->GetSession())
314 {
315 handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.description, active);
316 }
317 else
318 {
319 handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.description, active);
320 }
321
322 if (!found)
323 {
324 found = true;
325 }
326 }
327 }
328
329 if (!found)
330 {
332 }
333
334 return true;
335 }
#define sGameEventMgr
Definition: GameEventMgr.h:186
@ LANG_EVENT_ENTRY_LIST_CONSOLE
Definition: Language.h:892
@ LANG_EVENT_ENTRY_LIST_CHAT
Definition: Language.h:643
@ LANG_ACTIVE
Definition: Language.h:67
@ LANG_NOEVENTFOUND
Definition: Language.h:644
events
Definition: boss_sartura.cpp:43
virtual char const * GetAcoreString(uint32 entry) const
Definition: Chat.cpp:43
Definition: GameEventMgr.h:57
std::string description
Definition: GameEventMgr.h:70
std::vector< GameEventData > GameEventDataMap
Definition: GameEventMgr.h:107
std::set< uint16 > ActiveEvents
Definition: GameEventMgr.h:106

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
338 {
339 if (namePart.empty())
340 {
341 return false;
342 }
343
344 // Can be nullptr at console call
345 Player* target = handler->getSelectedPlayer();
346
347 std::wstring wNamePart;
348
349 if (!Utf8toWStr(namePart, wNamePart))
350 {
351 return false;
352 }
353
354 // converting string that we try to find to lower case
355 wstrToLower(wNamePart);
356
357 bool found = false;
358 uint32 count = 0;
359 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
360
361 for (auto factionEntry : sFactionStore)
362 {
363 FactionState const* factionState = target ? target->GetReputationMgr().GetState(factionEntry) : nullptr;
364
365 int locale = handler->GetSessionDbcLocale();
366 std::string name = factionEntry->name[locale];
367 if (name.empty())
368 {
369 continue;
370 }
371
372 if (!Utf8FitTo(name, wNamePart))
373 {
374 locale = 0;
375
376 for (; locale < TOTAL_LOCALES; ++locale)
377 {
378 if (locale == handler->GetSessionDbcLocale())
379 {
380 continue;
381 }
382
383 name = factionEntry->name[locale];
384 if (name.empty())
385 {
386 continue;
387 }
388
389 if (Utf8FitTo(name, wNamePart))
390 {
391 break;
392 }
393 }
394 }
395
396 if (locale < TOTAL_LOCALES)
397 {
398 if (maxResults && count++ == maxResults)
399 {
401 return true;
402 }
403
404 // send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format
405 // or "id - [faction] [no reputation]" format
406 std::ostringstream ss;
407 if (handler->GetSession())
408 {
409 ss << factionEntry->ID << " - |cffffffff|Hfaction:" << factionEntry->ID << "|h[" << name << ' ' << localeNames[locale] << "]|h|r";
410 }
411 else
412 {
413 ss << factionEntry->ID << " - " << name << ' ' << localeNames[locale];
414 }
415
416 if (factionState) // and then target != nullptr also
417 {
418 uint32 index = target->GetReputationMgr().GetReputationRankStrIndex(factionEntry);
419 std::string rankName = handler->GetAcoreString(index);
420
421 ss << ' ' << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
422
423 if (factionState->Flags & FACTION_FLAG_VISIBLE)
424 {
425 ss << handler->GetAcoreString(LANG_FACTION_VISIBLE);
426 }
427
428 if (factionState->Flags & FACTION_FLAG_AT_WAR)
429 {
430 ss << handler->GetAcoreString(LANG_FACTION_ATWAR);
431 }
432
433 if (factionState->Flags & FACTION_FLAG_PEACE_FORCED)
434 {
436 }
437
438 if (factionState->Flags & FACTION_FLAG_HIDDEN)
439 {
440 ss << handler->GetAcoreString(LANG_FACTION_HIDDEN);
441 }
442
443 if (factionState->Flags & FACTION_FLAG_INVISIBLE_FORCED)
444 {
446 }
447
448 if (factionState->Flags & FACTION_FLAG_INACTIVE)
449 {
451 }
452 }
453 else
454 {
456 }
457
458 handler->SendSysMessage(ss.str().c_str());
459
460 if (!found)
461 {
462 found = true;
463 }
464 }
465 }
466
467 if (!found)
468 {
470 }
471
472 return true;
473 }
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
@ LANG_FACTION_PEACE_FORCED
Definition: Language.h:355
@ LANG_FACTION_ATWAR
Definition: Language.h:354
@ LANG_FACTION_NOREPUTATION
Definition: Language.h:368
@ LANG_FACTION_INVISIBLE_FORCED
Definition: Language.h:357
@ LANG_FACTION_HIDDEN
Definition: Language.h:356
@ LANG_COMMAND_FACTION_NOTFOUND
Definition: Language.h:348
@ LANG_FACTION_INACTIVE
Definition: Language.h:358
@ LANG_FACTION_VISIBLE
Definition: Language.h:353
@ 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
Player * getSelectedPlayer() const
Definition: Chat.cpp:376
Definition: Player.h:1064
ReputationMgr & GetReputationMgr()
Definition: Player.h:2105
Definition: ReputationMgr.h:42
uint8 Flags
Definition: ReputationMgr.h:46
int32 GetReputation(uint32 faction_id) const
Definition: ReputationMgr.cpp:78
FactionState const * GetState(FactionEntry const *factionEntry) const
Definition: ReputationMgr.h:82
uint32 GetReputationRankStrIndex(FactionEntry const *factionEntry) const
Definition: ReputationMgr.h:102

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
476 {
477 if (namePart.empty())
478 {
479 return false;
480 }
481
482 std::wstring wNamePart;
483
484 // converting string that we try to find to lower case
485 if (!Utf8toWStr(namePart, wNamePart))
486 {
487 return false;
488 }
489
490 wstrToLower(wNamePart);
491
492 bool found = false;
493 uint32 count = 0;
494 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
495
496 // Search in `item_template`
497 for (auto const& [entry, itemTemplate] : *sObjectMgr->GetItemTemplateStore())
498 {
499 int localeIndex = handler->GetSessionDbLocaleIndex();
500 if (localeIndex >= 0)
501 {
502 uint8 ulocaleIndex = uint8(localeIndex);
503 if (ItemLocale const* il = sObjectMgr->GetItemLocale(itemTemplate.ItemId))
504 {
505 if (il->Name.size() > ulocaleIndex && !il->Name[ulocaleIndex].empty())
506 {
507 std::string name = il->Name[ulocaleIndex];
508
509 if (Utf8FitTo(name, wNamePart))
510 {
511 if (maxResults && count++ == maxResults)
512 {
514 return true;
515 }
516
517 if (handler->GetSession())
518 {
519 std::ostringstream color;
520 color << std::hex << ItemQualityColors[itemTemplate.Quality];
521 handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, color.str(), itemTemplate.ItemId, name);
522 }
523 else
524 {
525 handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name);
526 }
527
528 if (!found)
529 {
530 found = true;
531 }
532
533 continue;
534 }
535 }
536 }
537 }
538
539 std::string name = itemTemplate.Name1;
540 if (name.empty())
541 {
542 continue;
543 }
544
545 if (Utf8FitTo(name, wNamePart))
546 {
547 if (maxResults && count++ == maxResults)
548 {
550 return true;
551 }
552
553 if (handler->GetSession())
554 {
555 std::ostringstream color;
556 color << std::hex << ItemQualityColors[itemTemplate.Quality];
557 handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, color.str(), itemTemplate.ItemId, name);
558 }
559 else
560 {
561 handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name);
562 }
563
564 if (!found)
565 {
566 found = true;
567 }
568 }
569 }
570
571 if (!found)
572 {
574 }
575
576 return true;
577 }
@ LANG_ITEM_LIST_CHAT
Definition: Language.h:555
@ LANG_COMMAND_NOITEMFOUND
Definition: Language.h:468
@ LANG_ITEM_LIST_CONSOLE
Definition: Language.h:894
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
580 {
581 if (namePart.empty())
582 {
583 return false;
584 }
585
586 std::wstring wNamePart;
587
588 if (!Utf8toWStr(namePart, wNamePart))
589 {
590 return false;
591 }
592
593 // converting string that we try to find to lower case
594 wstrToLower(wNamePart);
595
596 bool found = false;
597 uint32 count = 0;
598 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
599
600 // Search in ItemSet.dbc
601 for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++)
602 {
603 ItemSetEntry const* set = sItemSetStore.LookupEntry(id);
604 if (set)
605 {
606 int locale = handler->GetSessionDbcLocale();
607 std::string name = set->name[locale];
608 if (name.empty())
609 {
610 continue;
611 }
612
613 if (!Utf8FitTo(name, wNamePart))
614 {
615 locale = 0;
616 for (; locale < TOTAL_LOCALES; ++locale)
617 {
618 if (locale == handler->GetSessionDbcLocale())
619 {
620 continue;
621 }
622
623 name = set->name[locale];
624 if (name.empty())
625 {
626 continue;
627 }
628
629 if (Utf8FitTo(name, wNamePart))
630 {
631 break;
632 }
633 }
634 }
635
636 if (locale < TOTAL_LOCALES)
637 {
638 if (maxResults && count++ == maxResults)
639 {
641 return true;
642 }
643
644 // send item set in "id - [namedlink locale]" format
645 if (handler->GetSession())
646 {
647 handler->PSendSysMessage(LANG_ITEMSET_LIST_CHAT, id, id, name, localeNames[locale]);
648 }
649 else
650 {
651 handler->PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name, localeNames[locale]);
652 }
653
654 if (!found)
655 {
656 found = true;
657 }
658 }
659 }
660 }
661
662 if (!found)
663 {
665 }
666
667 return true;
668 }
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetEntryfmt)
@ LANG_ITEMSET_LIST_CHAT
Definition: Language.h:561
@ LANG_COMMAND_NOITEMSETFOUND
Definition: Language.h:475
@ LANG_ITEMSET_LIST_CONSOLE
Definition: Language.h:895
Definition: DBCStructure.h:1232
char const * name[16]
Definition: DBCStructure.h:1234

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
1529 {
1530 if (namePart.empty())
1531 {
1532 return false;
1533 }
1534
1535 std::wstring wNamePart;
1536
1537 if (!Utf8toWStr(namePart, wNamePart))
1538 {
1539 return false;
1540 }
1541
1542 wstrToLower(wNamePart);
1543
1544 uint32 counter = 0;
1545 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1546 uint8 locale = handler->GetSession() ? handler->GetSession()->GetSessionDbcLocale() : sWorld->GetDefaultDbcLocale();
1547
1548 // search in Map.dbc
1549 for (auto mapInfo : sMapStore)
1550 {
1551 std::string name = mapInfo->name[locale];
1552
1553 if (name.empty())
1554 {
1555 continue;
1556 }
1557
1558 if (Utf8FitTo(name, wNamePart) && locale < TOTAL_LOCALES)
1559 {
1560 if (maxResults && counter == maxResults)
1561 {
1563 return true;
1564 }
1565
1566 std::ostringstream ss;
1567 ss << mapInfo->MapID << " - [" << name << ']';
1568
1569 if (mapInfo->IsContinent())
1570 {
1571 ss << handler->GetAcoreString(LANG_CONTINENT);
1572 }
1573
1574 switch (mapInfo->map_type)
1575 {
1576 case MAP_INSTANCE:
1577 ss << handler->GetAcoreString(LANG_INSTANCE);
1578 break;
1579 case MAP_RAID:
1580 ss << handler->GetAcoreString(LANG_RAID);
1581 break;
1582 case MAP_BATTLEGROUND:
1583 ss << handler->GetAcoreString(LANG_BATTLEGROUND);
1584 break;
1585 case MAP_ARENA:
1586 ss << handler->GetAcoreString(LANG_ARENA);
1587 break;
1588 }
1589
1590 handler->SendSysMessage(ss.str().c_str());
1591
1592 ++counter;
1593 }
1594 }
1595
1596 if (!counter)
1597 {
1599 }
1600
1601 return true;
1602 }
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
@ LANG_COMMAND_NOMAPFOUND
Definition: Language.h:1059
@ LANG_BATTLEGROUND
Definition: Language.h:1062
@ LANG_ARENA
Definition: Language.h:1063
@ LANG_INSTANCE
Definition: Language.h:1061
@ LANG_CONTINENT
Definition: Language.h:1060
@ LANG_RAID
Definition: Language.h:1064
@ MAP_BATTLEGROUND
Definition: DBCEnums.h:349
@ MAP_ARENA
Definition: DBCEnums.h:350
@ MAP_INSTANCE
Definition: DBCEnums.h:347
@ MAP_RAID
Definition: DBCEnums.h:348
LocaleConstant GetSessionDbcLocale() const
Definition: WorldSession.h:497

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
671 {
672 if (namePart.empty())
673 {
674 return false;
675 }
676
677 std::wstring wNamePart;
678
679 // converting string that we try to find to lower case
680 if (!Utf8toWStr(namePart, wNamePart))
681 {
682 return false;
683 }
684
685 wstrToLower(wNamePart);
686
687 bool found = false;
688 uint32 count = 0;
689 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
690
691 for (auto const& [entry, gameObjectTemplate] : *sObjectMgr->GetGameObjectTemplates())
692 {
693 uint8 localeIndex = handler->GetSessionDbLocaleIndex();
694 if (GameObjectLocale const* objectLocalte = sObjectMgr->GetGameObjectLocale(gameObjectTemplate.entry))
695 {
696 if (objectLocalte->Name.size() > localeIndex && !objectLocalte->Name[localeIndex].empty())
697 {
698 std::string name = objectLocalte->Name[localeIndex];
699
700 if (Utf8FitTo(name, wNamePart))
701 {
702 if (maxResults && count++ == maxResults)
703 {
705 return true;
706 }
707
708 if (handler->GetSession())
709 {
710 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name);
711 }
712 else
713 {
714 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name);
715 }
716
717 if (!found)
718 {
719 found = true;
720 }
721
722 continue;
723 }
724 }
725 }
726
727 std::string name = gameObjectTemplate.name;
728 if (name.empty())
729 {
730 continue;
731 }
732
733 if (Utf8FitTo(name, wNamePart))
734 {
735 if (maxResults && count++ == maxResults)
736 {
738 return true;
739 }
740
741 if (handler->GetSession())
742 {
743 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name);
744 }
745 else
746 {
747 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name);
748 }
749
750 if (!found)
751 {
752 found = true;
753 }
754 }
755 }
756
757 if (!found)
758 {
760 }
761
762 return true;
763 }
@ LANG_GO_ENTRY_LIST_CONSOLE
Definition: Language.h:896
@ LANG_GO_ENTRY_LIST_CHAT
Definition: Language.h:559
@ LANG_COMMAND_NOGAMEOBJECTFOUND
Definition: Language.h:480
Definition: GameObjectData.h:675

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
1630 {
1631 if (!Utf8ToUpperOnlyLatin(account))
1632 {
1633 return false;
1634 }
1635
1637 stmt->SetData(0, account);
1638 PreparedQueryResult result = LoginDatabase.Query(stmt);
1639
1640 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1641 }
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:532
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ LOGIN_SEL_ACCOUNT_LIST_BY_NAME
Definition: LoginDatabase.h:49
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
static bool LookupPlayerSearchCommand(PreparedQueryResult result, int32 limit, ChatHandler *handler)
Definition: cs_lookup.cpp:1652

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
1644 {
1646 stmt->SetData(0, email);
1647 PreparedQueryResult result = LoginDatabase.Query(stmt);
1648
1649 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1650 }
@ 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
1605 {
1606 Player* target = handler->getSelectedPlayerOrSelf();
1607 if (!ip)
1608 {
1609 // nullptr only if used from console
1610 if (!target || target == handler->GetSession()->GetPlayer())
1611 {
1612 return false;
1613 }
1614
1615 *ip = target->GetSession()->GetRemoteAddress();
1616 }
1617 else
1618 {
1619 ip = *ip;
1620 }
1621
1623 stmt->SetData(0, *ip);
1624 PreparedQueryResult result = LoginDatabase.Query(stmt);
1625
1626 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1627 }
@ LOGIN_SEL_ACCOUNT_BY_IP
Definition: LoginDatabase.h:54
Player * getSelectedPlayerOrSelf() const
Definition: Chat.cpp:420
WorldSession * GetSession() const
Definition: Player.h:1978
Player * GetPlayer() const
Definition: WorldSession.h:362
std::string const & GetRemoteAddress()
Definition: WorldSession.h:371

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
766 {
767 if (namePart.empty())
768 {
769 return false;
770 }
771
772 // can be nullptr at console call
773 Player* target = handler->getSelectedPlayer();
774
775 std::wstring wNamePart;
776
777 // converting string that we try to find to lower case
778 if (!Utf8toWStr(namePart, wNamePart))
779 {
780 return false;
781 }
782
783 wstrToLower(wNamePart);
784
785 bool found = false;
786 uint32 count = 0;
787 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
788
789 for (auto const& [entry, qInfo] : sObjectMgr->GetQuestTemplates())
790 {
791 int localeIndex = handler->GetSessionDbLocaleIndex();
792 if (localeIndex >= 0)
793 {
794 uint8 ulocaleIndex = uint8(localeIndex);
795 if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(qInfo->GetQuestId()))
796 {
797 if (questLocale->Title.size() > ulocaleIndex && !questLocale->Title[ulocaleIndex].empty())
798 {
799 std::string title = questLocale->Title[ulocaleIndex];
800
801 if (Utf8FitTo(title, wNamePart))
802 {
803 if (maxResults && count++ == maxResults)
804 {
806 return true;
807 }
808
809 char const* statusStr = "";
810
811 if (target)
812 {
813 QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
814
815 switch (status)
816 {
818 statusStr = handler->GetAcoreString(LANG_COMPLETE);
819 break;
821 statusStr = handler->GetAcoreString(LANG_ACTIVE);
822 break;
824 statusStr = handler->GetAcoreString(LANG_REWARDED);
825 break;
826 default:
827 break;
828 }
829 }
830
831 if (handler->GetSession())
832 {
833 handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title, statusStr);
834 }
835 else
836 {
837 handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title, statusStr);
838 }
839
840 if (!found)
841 {
842 found = true;
843 }
844
845 continue;
846 }
847 }
848 }
849 }
850
851 std::string title = qInfo->GetTitle();
852 if (title.empty())
853 {
854 continue;
855 }
856
857 if (Utf8FitTo(title, wNamePart))
858 {
859 if (maxResults && count++ == maxResults)
860 {
862 return true;
863 }
864
865 char const* statusStr = "";
866
867 if (target)
868 {
869 QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
870
871 switch (status)
872 {
874 statusStr = handler->GetAcoreString(LANG_COMPLETE);
875 break;
877 statusStr = handler->GetAcoreString(LANG_ACTIVE);
878 break;
880 statusStr = handler->GetAcoreString(LANG_REWARDED);
881 break;
882 default:
883 break;
884 }
885 }
886
887 if (handler->GetSession())
888 {
889 handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title, statusStr);
890 }
891 else
892 {
893 handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title, statusStr);
894 }
895
896 if (!found)
897 {
898 found = true;
899 }
900 }
901 }
902
903 if (!found)
904 {
906 }
907
908 return true;
909 }
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
@ LANG_COMPLETE
Definition: Language.h:68
@ LANG_QUEST_LIST_CONSOLE
Definition: Language.h:897
@ LANG_REWARDED
Definition: Language.h:666
@ LANG_COMMAND_NOQUESTFOUND
Definition: Language.h:478
@ LANG_QUEST_LIST_CHAT
Definition: Language.h:556
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: PlayerQuest.cpp:1424
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
912 {
913 if (namePart.empty())
914 {
915 return false;
916 }
917
918 // can be nullptr in console call
919 Player* target = handler->getSelectedPlayer();
920
921 std::wstring wNamePart;
922
923 if (!Utf8toWStr(namePart, wNamePart))
924 {
925 return false;
926 }
927
928 // converting string that we try to find to lower case
929 wstrToLower(wNamePart);
930
931 bool found = false;
932 uint32 count = 0;
933 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
934
935 // Search in SkillLine.dbc
936 for (auto skillInfo : sSkillLineStore)
937 {
938 int locale = handler->GetSessionDbcLocale();
939 std::string name = skillInfo->name[locale];
940
941 if (name.empty())
942 {
943 continue;
944 }
945
946 if (!Utf8FitTo(name, wNamePart))
947 {
948 locale = 0;
949 for (; locale < TOTAL_LOCALES; ++locale)
950 {
951 if (locale == handler->GetSessionDbcLocale())
952 {
953 continue;
954 }
955
956 name = skillInfo->name[locale];
957 if (name.empty())
958 {
959 continue;
960 }
961
962 if (Utf8FitTo(name, wNamePart))
963 {
964 break;
965 }
966 }
967 }
968
969 if (locale < TOTAL_LOCALES)
970 {
971 if (maxResults && count++ == maxResults)
972 {
974 return true;
975 }
976
977 std::string valStr;
978 std::string knownStr;
979
980 if (target && target->HasSkill(skillInfo->id))
981 {
982 knownStr = handler->GetAcoreString(LANG_KNOWN);
983 uint32 curValue = target->GetPureSkillValue(skillInfo->id);
984 uint32 maxValue = target->GetPureMaxSkillValue(skillInfo->id);
985 uint32 permValue = target->GetSkillPermBonusValue(skillInfo->id);
986 uint32 tempValue = target->GetSkillTempBonusValue(skillInfo->id);
987
988 valStr = Acore::StringFormat(handler->GetAcoreString(LANG_SKILL_VALUES), curValue, maxValue, permValue, tempValue);
989 }
990
991 // send skill in "id - [namedlink locale]" format
992 if (handler->GetSession())
993 {
994 handler->PSendSysMessage(LANG_SKILL_LIST_CHAT, skillInfo->id, skillInfo->id, name, localeNames[locale], knownStr, valStr);
995 }
996 else
997 {
998 handler->PSendSysMessage(LANG_SKILL_LIST_CONSOLE, skillInfo->id, name, localeNames[locale], knownStr, valStr);
999 }
1000
1001 if (!found)
1002 {
1003 found = true;
1004 }
1005 }
1006 }
1007
1008 if (!found)
1009 {
1011 }
1012
1013 return true;
1014 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
@ LANG_SKILL_LIST_CHAT
Definition: Language.h:564
@ LANG_KNOWN
Definition: Language.h:63
@ LANG_SKILL_LIST_CONSOLE
Definition: Language.h:898
@ LANG_COMMAND_NOSKILLFOUND
Definition: Language.h:476
@ LANG_SKILL_VALUES
Definition: Language.h:911
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:34
uint16 GetPureSkillValue(uint32 skill) const
Definition: Player.cpp:5502
int16 GetSkillTempBonusValue(uint32 skill) const
Definition: Player.cpp:5526
int16 GetSkillPermBonusValue(uint32 skill) const
Definition: Player.cpp:5514
bool HasSkill(uint32 skill) const
Definition: Player.cpp:5416
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition: Player.cpp:5472

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

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
1169 {
1170 // can be nullptr at console call
1171 Player* target = handler->getSelectedPlayer();
1172
1173 bool found = false;
1174 uint32 count = 0;
1175 uint32 maxResults = 1;
1176
1177 if (!SpellMgr::IsSpellValid(spell))
1178 {
1179 handler->SendErrorMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
1180 return false;
1181 }
1182
1183 int locale = handler->GetSessionDbcLocale();
1184 std::string name = spell->SpellName[locale];
1185 if (name.empty())
1186 {
1188 return true;
1189 }
1190
1191 if (locale < TOTAL_LOCALES)
1192 {
1193 if (maxResults && count++ == maxResults)
1194 {
1196 return true;
1197 }
1198
1199 bool known = target && target->HasSpell(spell->Id);
1200 bool learn = (spell->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL);
1201
1202 SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spell->Effects[0].TriggerSpell);
1203
1204 uint32 talentCost = GetTalentSpellCost(spell->Id);
1205
1206 bool talent = (talentCost > 0);
1207 bool passive = spell->IsPassive();
1208 bool active = target && target->HasAura(spell->Id);
1209
1210 // unit32 used to prevent interpreting uint8 as char at output
1211 // find rank of learned spell for learning spell, or talent rank
1212 uint32 rank = talentCost ? talentCost : learn && learnSpellInfo ? learnSpellInfo->GetRank() : spell->GetRank();
1213
1214 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
1215 std::ostringstream ss;
1216 if (handler->GetSession())
1217 {
1218 ss << spell->Id << " - |cffffffff|Hspell:" << spell->Id << "|h[" << name;
1219 }
1220 else
1221 {
1222 ss << spell->Id << " - " << name;
1223 }
1224
1225 // include rank in link name
1226 if (rank)
1227 {
1228 ss << handler->GetAcoreString(LANG_SPELL_RANK) << rank;
1229 }
1230
1231 if (handler->GetSession())
1232 {
1233 ss << ' ' << localeNames[locale] << "]|h|r";
1234 }
1235 else
1236 {
1237 ss << ' ' << localeNames[locale];
1238 }
1239
1240 if (talent)
1241 {
1242 ss << handler->GetAcoreString(LANG_TALENT);
1243 }
1244
1245 if (passive)
1246 {
1247 ss << handler->GetAcoreString(LANG_PASSIVE);
1248 }
1249
1250 if (learn)
1251 {
1252 ss << handler->GetAcoreString(LANG_LEARN);
1253 }
1254
1255 if (known)
1256 {
1257 ss << handler->GetAcoreString(LANG_KNOWN);
1258 }
1259
1260 if (active)
1261 {
1262 ss << handler->GetAcoreString(LANG_ACTIVE);
1263 }
1264
1265 handler->SendSysMessage(ss.str().c_str());
1266
1267 if (!found)
1268 {
1269 found = true;
1270 }
1271 }
1272
1273 if (!found)
1274 {
1276 }
1277
1278 return true;
1279 }
@ LANG_COMMAND_SPELL_BROKEN
Definition: Language.h:520
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:218
static bool IsSpellValid(SpellInfo const *spellInfo)
Definition: SpellMgr.cpp:442

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
1282 {
1283 if (namePart.empty())
1284 {
1285 return false;
1286 }
1287
1288 std::wstring wNamePart;
1289
1290 if (!Utf8toWStr(namePart, wNamePart))
1291 {
1292 return false;
1293 }
1294
1295 // converting string that we try to find to lower case
1296 wstrToLower(wNamePart);
1297
1298 bool found = false;
1299 uint32 count = 0;
1300 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1301
1302 // Search in TaxiNodes.dbc
1303 for (auto nodeEntry : sTaxiNodesStore)
1304 {
1305 int locale = handler->GetSessionDbcLocale();
1306 std::string name = nodeEntry->name[locale];
1307
1308 if (name.empty())
1309 {
1310 continue;
1311 }
1312
1313 if (!Utf8FitTo(name, wNamePart))
1314 {
1315 locale = 0;
1316
1317 for (; locale < TOTAL_LOCALES; ++locale)
1318 {
1319 if (locale == handler->GetSessionDbcLocale())
1320 {
1321 continue;
1322 }
1323
1324 name = nodeEntry->name[locale];
1325 if (name.empty())
1326 {
1327 continue;
1328 }
1329
1330 if (Utf8FitTo(name, wNamePart))
1331 {
1332 break;
1333 }
1334 }
1335 }
1336
1337 if (locale < TOTAL_LOCALES)
1338 {
1339 if (maxResults && count++ == maxResults)
1340 {
1342 return true;
1343 }
1344
1345 // send taxinode in "id - [name] (Map:m X:x Y:y Z:z)" format
1346 if (handler->GetSession())
1347 {
1348 handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CHAT, nodeEntry->ID, nodeEntry->ID, name, localeNames[locale],
1349 nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z);
1350 }
1351 else
1352 {
1353 handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CONSOLE, nodeEntry->ID, name, localeNames[locale],
1354 nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z);
1355 }
1356
1357 if (!found)
1358 {
1359 found = true;
1360 }
1361 }
1362 }
1363 if (!found)
1364 {
1366 }
1367
1368 return true;
1369 }
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
@ LANG_COMMAND_NOTAXINODEFOUND
Definition: Language.h:498
@ LANG_TAXINODE_ENTRY_LIST_CHAT
Definition: Language.h:917
@ LANG_TAXINODE_ENTRY_LIST_CONSOLE
Definition: Language.h:918

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
1373 {
1374 if (namePart.empty())
1375 {
1376 return false;
1377 }
1378
1379 std::wstring wNamePart;
1380
1381 if (!Utf8toWStr(namePart, wNamePart))
1382 {
1383 return false;
1384 }
1385
1386 // converting string that we try to find to lower case
1387 wstrToLower(wNamePart);
1388
1389 std::ostringstream reply;
1390 uint32 count = 0;
1391 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1392 bool limitReached = false;
1393
1394 for (auto const& [id, tele] : sObjectMgr->GetGameTeleMap())
1395 {
1396 if (tele.wnameLow.find(wNamePart) == std::wstring::npos)
1397 {
1398 continue;
1399 }
1400
1401 if (maxResults && count++ == maxResults)
1402 {
1403 limitReached = true;
1404 break;
1405 }
1406
1407 if (handler->GetSession())
1408 {
1409 reply << " |cffffffff|Htele:" << id << "|h[" << tele.name << "]|h|r\n";
1410 }
1411 else
1412 {
1413 reply << " " << id << ' ' << tele.name << "\n";
1414 }
1415 }
1416
1417 if (reply.str().empty())
1418 {
1420 }
1421 else
1422 {
1423 handler->PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str());
1424 }
1425
1426 if (limitReached)
1427 {
1429 }
1430
1431 return true;
1432 }
@ LANG_COMMAND_TELE_LOCATION
Definition: Language.h:207
@ LANG_COMMAND_TELE_NOLOCATION
Definition: Language.h:205

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
1435 {
1436 if (namePart.empty())
1437 {
1438 return false;
1439 }
1440
1441 // can be nullptr in console call
1442 Player* target = handler->getSelectedPlayer();
1443
1444 // title name have single string arg for player name
1445 char const* targetName = target ? target->GetName().c_str() : "NAME";
1446
1447 std::wstring wNamePart;
1448
1449 if (!Utf8toWStr(namePart, wNamePart))
1450 {
1451 return false;
1452 }
1453
1454 // converting string that we try to find to lower case
1455 wstrToLower(wNamePart);
1456
1457 uint32 counter = 0; // Counter for figure out that we found smth.
1458 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1459
1460 // Search in CharTitles.dbc
1461 for (auto titleInfo : sCharTitlesStore)
1462 {
1463 int locale = handler->GetSessionDbcLocale();
1464 std::string name = titleInfo->nameMale[locale];
1465 if (name.empty())
1466 {
1467 continue;
1468 }
1469
1470 if (!Utf8FitTo(name, wNamePart))
1471 {
1472 locale = 0;
1473 for (; locale < TOTAL_LOCALES; ++locale)
1474 {
1475 if (locale == handler->GetSessionDbcLocale())
1476 {
1477 continue;
1478 }
1479
1480 name = titleInfo->nameMale[locale];
1481 if (name.empty())
1482 {
1483 continue;
1484 }
1485
1486 if (Utf8FitTo(name, wNamePart))
1487 {
1488 break;
1489 }
1490 }
1491 }
1492
1493 if (locale < TOTAL_LOCALES)
1494 {
1495 if (maxResults && counter == maxResults)
1496 {
1498 return true;
1499 }
1500
1501 char const* knownStr = target && target->HasTitle(titleInfo) ? handler->GetAcoreString(LANG_KNOWN) : "";
1502 char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index ? handler->GetAcoreString(LANG_ACTIVE) : "";
1503
1504 std::string titleNameStr = Acore::StringFormat(name, targetName);
1505
1506 // send title in "id (idx:idx) - [namedlink locale]" format
1507 if (handler->GetSession())
1508 {
1509 handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, titleInfo->ID, titleInfo->bit_index, titleInfo->ID, titleNameStr, localeNames[locale], knownStr, activeStr);
1510 }
1511 else
1512 {
1513 handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, titleInfo->ID, titleInfo->bit_index, titleNameStr, localeNames[locale], knownStr, activeStr);
1514 }
1515
1516 ++counter;
1517 }
1518 }
1519
1520 if (!counter) // if counter == 0 then we found nth
1521 {
1523 }
1524
1525 return true;
1526 }
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
@ LANG_TITLE_LIST_CHAT
Definition: Language.h:390
@ LANG_COMMAND_NOTITLEFOUND
Definition: Language.h:392
@ LANG_TITLE_LIST_CONSOLE
Definition: Language.h:391
@ PLAYER_CHOSEN_TITLE
Definition: UpdateFields.h:324
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305
std::string const & GetName() const
Definition: Object.h:458
bool HasTitle(uint32 bitIndex) const
Definition: Player.cpp:13324

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
1653 {
1654 if (!result)
1655 {
1657 return false;
1658 }
1659
1660 int32 counter = 0;
1661 uint32 count = 0;
1662 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1663
1664 do
1665 {
1666 if (maxResults && count++ == maxResults)
1667 {
1669 return true;
1670 }
1671
1672 Field* fields = result->Fetch();
1673 uint32 accountId = fields[0].Get<uint32>();
1674 std::string accountName = fields[1].Get<std::string>();
1675
1677 stmt->SetData(0, accountId);
1678 PreparedQueryResult result2 = CharacterDatabase.Query(stmt);
1679
1680 if (result2)
1681 {
1682 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, accountName, accountId);
1683
1684 do
1685 {
1686 Field* characterFields = result2->Fetch();
1687 ObjectGuid::LowType guid = characterFields[0].Get<uint32>();
1688 std::string name = characterFields[1].Get<std::string>();
1689 uint8 plevel = 0, prace = 0, pclass = 0;
1690 bool online = ObjectAccessor::FindPlayerByLowGUID(guid) != nullptr;
1691
1692 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByName(name))
1693 {
1694 plevel = gpd->Level;
1695 prace = gpd->Race;
1696 pclass = gpd->Class;
1697 }
1698
1699 if (plevel > 0 && prace > 0 && prace <= RACE_DRAENEI && pclass > 0 && pclass <= CLASS_DRUID)
1700 {
1701 handler->PSendSysMessage(" {} (GUID {}) - {} - {} - {}{}", name, guid, EnumUtils::ToTitle(Races(prace)), EnumUtils::ToTitle(Classes(pclass)), plevel, (online ? " - [ONLINE]" : ""));
1702 }
1703 else
1704 {
1705 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name, guid);
1706 }
1707
1708 ++counter;
1709 } while (result2->NextRow() && (limit == -1 || counter < limit));
1710 }
1711 } while (result->NextRow());
1712
1713 if (!counter) // empty accounts only
1714 {
1716 return false;
1717 }
1718
1719 return true;
1720 }
std::int32_t int32
Definition: Define.h:103
#define sCharacterCache
Definition: CharacterCache.h:83
@ LANG_LOOKUP_PLAYER_CHARACTER
Definition: Language.h:370
@ LANG_LOOKUP_PLAYER_ACCOUNT
Definition: Language.h:369
@ LANG_NO_PLAYERS_FOUND
Definition: Language.h:371
@ CHAR_SEL_CHAR_GUID_NAME_BY_ACC
Definition: CharacterDatabase.h:340
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Classes
Definition: SharedDefines.h:139
@ CLASS_DRUID
Definition: SharedDefines.h:151
Races
Definition: SharedDefines.h:69
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Definition: ObjectAccessor.cpp:254
static char const * ToTitle(Enum value)
Definition: SmartEnum.h:127
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
Definition: CharacterCache.h:28
uint32 LowType
Definition: ObjectGuid.h:122

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(), sWorld, and EnumUtils::ToTitle().

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