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
 

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)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ lookup_commandscript()

lookup_commandscript::lookup_commandscript ( )
inline
42: CommandScript("lookup_commandscript") { }
Definition: ScriptMgr.h:850

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:68
@ SEC_MODERATOR
Definition: Common.h:67
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:50
static bool HandleLookupTaxiNodeCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1278
static bool HandleLookupPlayerIpCommand(ChatHandler *handler, Optional< Tail > ip, Optional< int32 > limit)
Definition: cs_lookup.cpp:1601
static bool HandleLookupEventCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:269
static bool HandleLookupMapCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1525
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:1640
static bool HandleLookupItemSetCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:575
static bool HandleLookupObjectCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:666
static bool HandleLookupAreaCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:82
static bool HandleLookupTeleCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1369
static bool HandleLookupFactionCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:337
static bool HandleLookupQuestCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:761
static bool HandleLookupSkillCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:907
static bool HandleLookupTitleCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1431
static bool HandleLookupSpellIdCommand(ChatHandler *handler, SpellInfo const *spell)
Definition: cs_lookup.cpp:1164
static bool HandleLookupSpellCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1012
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:1626

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:85
std::uint32_t uint32
Definition: Define.h:108
void wstrToLower(std::wstring &str)
Definition: Util.cpp:383
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition: Util.cpp:477
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:282
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
@ LANG_COMMAND_NOAREAFOUND
Definition: Language.h:457
@ LANG_COMMAND_LOOKUP_MAX_RESULTS
Definition: Language.h:1083
@ CONFIG_MAX_RESULTS_LOOKUP_COMMANDS
Definition: IWorld.h:354
#define sWorld
Definition: World.h:451
WorldSession * GetSession()
Definition: Chat.h:122
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:782
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103

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.c_str());
215 }
216 else
217 {
218 handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str());
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.c_str());
248 }
249 else
250 {
251 handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str());
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:110
#define sObjectMgr
Definition: ObjectMgr.h:1640
@ LANG_COMMAND_NOCREATUREFOUND
Definition: Language.h:462
@ LANG_CREATURE_ENTRY_LIST_CONSOLE
Definition: Language.h:866
@ LANG_CREATURE_ENTRY_LIST_CHAT
Definition: Language.h:540
virtual int GetSessionDbLocaleIndex() const
Definition: Chat.cpp:787
Definition: CreatureData.h:332

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.c_str(), active);
316 }
317 else
318 {
319 handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.description.c_str(), 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:865
@ LANG_EVENT_ENTRY_LIST_CHAT
Definition: Language.h:626
@ LANG_ACTIVE
Definition: Language.h:67
@ LANG_NOEVENTFOUND
Definition: Language.h:627
events
Definition: boss_sartura.cpp:43
virtual char const * GetAcoreString(uint32 entry) const
Definition: Chat.cpp:42
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:317
@ FACTION_FLAG_PEACE_FORCED
Definition: DBCEnums.h:316
@ FACTION_FLAG_INVISIBLE_FORCED
Definition: DBCEnums.h:315
@ FACTION_FLAG_HIDDEN
Definition: DBCEnums.h:314
@ FACTION_FLAG_VISIBLE
Definition: DBCEnums.h:312
@ FACTION_FLAG_AT_WAR
Definition: DBCEnums.h:313
Player * getSelectedPlayer() const
Definition: Chat.cpp:301
Definition: Player.h:1046
ReputationMgr & GetReputationMgr()
Definition: Player.h:2076
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 handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, itemTemplate.ItemId, name.c_str());
520 }
521 else
522 {
523 handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name.c_str());
524 }
525
526 if (!found)
527 {
528 found = true;
529 }
530
531 continue;
532 }
533 }
534 }
535 }
536
537 std::string name = itemTemplate.Name1;
538 if (name.empty())
539 {
540 continue;
541 }
542
543 if (Utf8FitTo(name, wNamePart))
544 {
545 if (maxResults && count++ == maxResults)
546 {
548 return true;
549 }
550
551 if (handler->GetSession())
552 {
553 handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, itemTemplate.ItemId, name.c_str());
554 }
555 else
556 {
557 handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name.c_str());
558 }
559
560 if (!found)
561 {
562 found = true;
563 }
564 }
565 }
566
567 if (!found)
568 {
570 }
571
572 return true;
573 }
@ LANG_ITEM_LIST_CHAT
Definition: Language.h:538
@ LANG_COMMAND_NOITEMFOUND
Definition: Language.h:451
@ LANG_ITEM_LIST_CONSOLE
Definition: Language.h:867
Definition: ItemTemplate.h:841

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetSession(), ChatHandler::GetSessionDbLocaleIndex(), 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
576 {
577 if (namePart.empty())
578 {
579 return false;
580 }
581
582 std::wstring wNamePart;
583
584 if (!Utf8toWStr(namePart, wNamePart))
585 {
586 return false;
587 }
588
589 // converting string that we try to find to lower case
590 wstrToLower(wNamePart);
591
592 bool found = false;
593 uint32 count = 0;
594 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
595
596 // Search in ItemSet.dbc
597 for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++)
598 {
599 ItemSetEntry const* set = sItemSetStore.LookupEntry(id);
600 if (set)
601 {
602 int locale = handler->GetSessionDbcLocale();
603 std::string name = set->name[locale];
604 if (name.empty())
605 {
606 continue;
607 }
608
609 if (!Utf8FitTo(name, wNamePart))
610 {
611 locale = 0;
612 for (; locale < TOTAL_LOCALES; ++locale)
613 {
614 if (locale == handler->GetSessionDbcLocale())
615 {
616 continue;
617 }
618
619 name = set->name[locale];
620 if (name.empty())
621 {
622 continue;
623 }
624
625 if (Utf8FitTo(name, wNamePart))
626 {
627 break;
628 }
629 }
630 }
631
632 if (locale < TOTAL_LOCALES)
633 {
634 if (maxResults && count++ == maxResults)
635 {
637 return true;
638 }
639
640 // send item set in "id - [namedlink locale]" format
641 if (handler->GetSession())
642 {
643 handler->PSendSysMessage(LANG_ITEMSET_LIST_CHAT, id, id, name.c_str(), localeNames[locale]);
644 }
645 else
646 {
647 handler->PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name.c_str(), localeNames[locale]);
648 }
649
650 if (!found)
651 {
652 found = true;
653 }
654 }
655 }
656 }
657
658 if (!found)
659 {
661 }
662
663 return true;
664 }
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetEntryfmt)
@ LANG_ITEMSET_LIST_CHAT
Definition: Language.h:544
@ LANG_COMMAND_NOITEMSETFOUND
Definition: Language.h:458
@ LANG_ITEMSET_LIST_CONSOLE
Definition: Language.h:868
Definition: DBCStructure.h:1211
char const * name[16]
Definition: DBCStructure.h:1213

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

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
667 {
668 if (namePart.empty())
669 {
670 return false;
671 }
672
673 std::wstring wNamePart;
674
675 // converting string that we try to find to lower case
676 if (!Utf8toWStr(namePart, wNamePart))
677 {
678 return false;
679 }
680
681 wstrToLower(wNamePart);
682
683 bool found = false;
684 uint32 count = 0;
685 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
686
687 for (auto const& [entry, gameObjectTemplate] : *sObjectMgr->GetGameObjectTemplates())
688 {
689 uint8 localeIndex = handler->GetSessionDbLocaleIndex();
690 if (GameObjectLocale const* objectLocalte = sObjectMgr->GetGameObjectLocale(gameObjectTemplate.entry))
691 {
692 if (objectLocalte->Name.size() > localeIndex && !objectLocalte->Name[localeIndex].empty())
693 {
694 std::string name = objectLocalte->Name[localeIndex];
695
696 if (Utf8FitTo(name, wNamePart))
697 {
698 if (maxResults && count++ == maxResults)
699 {
701 return true;
702 }
703
704 if (handler->GetSession())
705 {
706 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name.c_str());
707 }
708 else
709 {
710 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name.c_str());
711 }
712
713 if (!found)
714 {
715 found = true;
716 }
717
718 continue;
719 }
720 }
721 }
722
723 std::string name = gameObjectTemplate.name;
724 if (name.empty())
725 {
726 continue;
727 }
728
729 if (Utf8FitTo(name, wNamePart))
730 {
731 if (maxResults && count++ == maxResults)
732 {
734 return true;
735 }
736
737 if (handler->GetSession())
738 {
739 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name.c_str());
740 }
741 else
742 {
743 handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name.c_str());
744 }
745
746 if (!found)
747 {
748 found = true;
749 }
750 }
751 }
752
753 if (!found)
754 {
756 }
757
758 return true;
759 }
@ LANG_GO_ENTRY_LIST_CONSOLE
Definition: Language.h:869
@ LANG_GO_ENTRY_LIST_CHAT
Definition: Language.h:542
@ LANG_COMMAND_NOGAMEOBJECTFOUND
Definition: Language.h:463
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
1627 {
1628 if (!Utf8ToUpperOnlyLatin(account))
1629 {
1630 return false;
1631 }
1632
1634 stmt->SetData(0, account);
1635 PreparedQueryResult result = LoginDatabase.Query(stmt);
1636
1637 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1638 }
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:528
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ LOGIN_SEL_ACCOUNT_LIST_BY_NAME
Definition: LoginDatabase.h:49
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:1649

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
1641 {
1643 stmt->SetData(0, email);
1644 PreparedQueryResult result = LoginDatabase.Query(stmt);
1645
1646 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1647 }
@ 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
1602 {
1603 Player* target = handler->getSelectedPlayerOrSelf();
1604 if (!ip)
1605 {
1606 // nullptr only if used from console
1607 if (!target || target == handler->GetSession()->GetPlayer())
1608 {
1609 return false;
1610 }
1611
1612 *ip = target->GetSession()->GetRemoteAddress();
1613 }
1614 else
1615 {
1616 ip = *ip;
1617 }
1618
1620 stmt->SetData(0, *ip);
1621 PreparedQueryResult result = LoginDatabase.Query(stmt);
1622
1623 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1624 }
@ LOGIN_SEL_ACCOUNT_BY_IP
Definition: LoginDatabase.h:54
Player * getSelectedPlayerOrSelf() const
Definition: Chat.cpp:345
WorldSession * GetSession() const
Definition: Player.h:1948
Player * GetPlayer() const
Definition: WorldSession.h:361
std::string const & GetRemoteAddress()
Definition: WorldSession.h:370

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
762 {
763 if (namePart.empty())
764 {
765 return false;
766 }
767
768 // can be nullptr at console call
769 Player* target = handler->getSelectedPlayer();
770
771 std::wstring wNamePart;
772
773 // converting string that we try to find to lower case
774 if (!Utf8toWStr(namePart, wNamePart))
775 {
776 return false;
777 }
778
779 wstrToLower(wNamePart);
780
781 bool found = false;
782 uint32 count = 0;
783 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
784
785 for (auto const& [entry, qInfo] : sObjectMgr->GetQuestTemplates())
786 {
787 int localeIndex = handler->GetSessionDbLocaleIndex();
788 if (localeIndex >= 0)
789 {
790 uint8 ulocaleIndex = uint8(localeIndex);
791 if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(qInfo->GetQuestId()))
792 {
793 if (questLocale->Title.size() > ulocaleIndex && !questLocale->Title[ulocaleIndex].empty())
794 {
795 std::string title = questLocale->Title[ulocaleIndex];
796
797 if (Utf8FitTo(title, wNamePart))
798 {
799 if (maxResults && count++ == maxResults)
800 {
802 return true;
803 }
804
805 char const* statusStr = "";
806
807 if (target)
808 {
809 QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
810
811 switch (status)
812 {
814 statusStr = handler->GetAcoreString(LANG_COMMAND_QUEST_COMPLETE);
815 break;
817 statusStr = handler->GetAcoreString(LANG_COMMAND_QUEST_ACTIVE);
818 break;
820 statusStr = handler->GetAcoreString(LANG_COMMAND_QUEST_REWARDED);
821 break;
822 default:
823 break;
824 }
825 }
826
827 if (handler->GetSession())
828 {
829 handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title.c_str(), statusStr);
830 }
831 else
832 {
833 handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title.c_str(), statusStr);
834 }
835
836 if (!found)
837 {
838 found = true;
839 }
840
841 continue;
842 }
843 }
844 }
845 }
846
847 std::string title = qInfo->GetTitle();
848 if (title.empty())
849 {
850 continue;
851 }
852
853 if (Utf8FitTo(title, wNamePart))
854 {
855 if (maxResults && count++ == maxResults)
856 {
858 return true;
859 }
860
861 char const* statusStr = "";
862
863 if (target)
864 {
865 QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
866
867 switch (status)
868 {
870 statusStr = handler->GetAcoreString(LANG_COMMAND_QUEST_COMPLETE);
871 break;
873 statusStr = handler->GetAcoreString(LANG_COMMAND_QUEST_ACTIVE);
874 break;
876 statusStr = handler->GetAcoreString(LANG_COMMAND_QUEST_REWARDED);
877 break;
878 default:
879 break;
880 }
881 }
882
883 if (handler->GetSession())
884 {
885 handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title.c_str(), statusStr);
886 }
887 else
888 {
889 handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title.c_str(), statusStr);
890 }
891
892 if (!found)
893 {
894 found = true;
895 }
896 }
897 }
898
899 if (!found)
900 {
902 }
903
904 return true;
905 }
@ LANG_COMMAND_QUEST_REWARDED
Definition: Language.h:490
@ LANG_QUEST_LIST_CONSOLE
Definition: Language.h:870
@ LANG_COMMAND_QUEST_ACTIVE
Definition: Language.h:492
@ LANG_COMMAND_NOQUESTFOUND
Definition: Language.h:461
@ LANG_COMMAND_QUEST_COMPLETE
Definition: Language.h:491
@ LANG_QUEST_LIST_CHAT
Definition: Language.h:539
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:1414
Definition: QuestDef.h:180

References CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, ChatHandler::GetAcoreString(), Player::GetQuestStatus(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), ChatHandler::GetSessionDbLocaleIndex(), LANG_COMMAND_LOOKUP_MAX_RESULTS, LANG_COMMAND_NOQUESTFOUND, LANG_COMMAND_QUEST_ACTIVE, LANG_COMMAND_QUEST_COMPLETE, LANG_COMMAND_QUEST_REWARDED, LANG_QUEST_LIST_CHAT, LANG_QUEST_LIST_CONSOLE, 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
908 {
909 if (namePart.empty())
910 {
911 return false;
912 }
913
914 // can be nullptr in console call
915 Player* target = handler->getSelectedPlayer();
916
917 std::wstring wNamePart;
918
919 if (!Utf8toWStr(namePart, wNamePart))
920 {
921 return false;
922 }
923
924 // converting string that we try to find to lower case
925 wstrToLower(wNamePart);
926
927 bool found = false;
928 uint32 count = 0;
929 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
930
931 // Search in SkillLine.dbc
932 for (auto skillInfo : sSkillLineStore)
933 {
934 int locale = handler->GetSessionDbcLocale();
935 std::string name = skillInfo->name[locale];
936
937 if (name.empty())
938 {
939 continue;
940 }
941
942 if (!Utf8FitTo(name, wNamePart))
943 {
944 locale = 0;
945 for (; locale < TOTAL_LOCALES; ++locale)
946 {
947 if (locale == handler->GetSessionDbcLocale())
948 {
949 continue;
950 }
951
952 name = skillInfo->name[locale];
953 if (name.empty())
954 {
955 continue;
956 }
957
958 if (Utf8FitTo(name, wNamePart))
959 {
960 break;
961 }
962 }
963 }
964
965 if (locale < TOTAL_LOCALES)
966 {
967 if (maxResults && count++ == maxResults)
968 {
970 return true;
971 }
972
973 std::string valStr;
974 std::string knownStr;
975
976 if (target && target->HasSkill(skillInfo->id))
977 {
978 knownStr = handler->GetAcoreString(LANG_KNOWN);
979 uint32 curValue = target->GetPureSkillValue(skillInfo->id);
980 uint32 maxValue = target->GetPureMaxSkillValue(skillInfo->id);
981 uint32 permValue = target->GetSkillPermBonusValue(skillInfo->id);
982 uint32 tempValue = target->GetSkillTempBonusValue(skillInfo->id);
983
984 valStr = Acore::StringFormat(handler->GetAcoreString(LANG_SKILL_VALUES), curValue, maxValue, permValue, tempValue);
985 }
986
987 // send skill in "id - [namedlink locale]" format
988 if (handler->GetSession())
989 {
990 handler->PSendSysMessage(LANG_SKILL_LIST_CHAT, skillInfo->id, skillInfo->id, name.c_str(), localeNames[locale], knownStr.c_str(), valStr.c_str());
991 }
992 else
993 {
994 handler->PSendSysMessage(LANG_SKILL_LIST_CONSOLE, skillInfo->id, name.c_str(), localeNames[locale], knownStr.c_str(), valStr.c_str());
995 }
996
997 if (!found)
998 {
999 found = true;
1000 }
1001 }
1002 }
1003
1004 if (!found)
1005 {
1007 }
1008
1009 return true;
1010 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
@ LANG_SKILL_LIST_CHAT
Definition: Language.h:547
@ LANG_KNOWN
Definition: Language.h:63
@ LANG_SKILL_LIST_CONSOLE
Definition: Language.h:871
@ LANG_COMMAND_NOSKILLFOUND
Definition: Language.h:459
@ LANG_SKILL_VALUES
Definition: Language.h:884
std::string StringFormat(Format &&fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:29
uint16 GetPureSkillValue(uint32 skill) const
Definition: Player.cpp:5419
int16 GetSkillTempBonusValue(uint32 skill) const
Definition: Player.cpp:5443
int16 GetSkillPermBonusValue(uint32 skill) const
Definition: Player.cpp:5431
bool HasSkill(uint32 skill) const
Definition: Player.cpp:5333
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition: Player.cpp:5389

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

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

Referenced by GetCommands().

◆ HandleLookupTaxiNodeCommand()

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

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
1370 {
1371 if (namePart.empty())
1372 {
1373 return false;
1374 }
1375
1376 std::wstring wNamePart;
1377
1378 if (!Utf8toWStr(namePart, wNamePart))
1379 {
1380 return false;
1381 }
1382
1383 // converting string that we try to find to lower case
1384 wstrToLower(wNamePart);
1385
1386 std::ostringstream reply;
1387 uint32 count = 0;
1388 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1389 bool limitReached = false;
1390
1391 for (auto const& [id, tele] : sObjectMgr->GetGameTeleMap())
1392 {
1393 if (tele.wnameLow.find(wNamePart) == std::wstring::npos)
1394 {
1395 continue;
1396 }
1397
1398 if (maxResults && count++ == maxResults)
1399 {
1400 limitReached = true;
1401 break;
1402 }
1403
1404 if (handler->GetSession())
1405 {
1406 reply << " |cffffffff|Htele:" << id << "|h[" << tele.name << "]|h|r\n";
1407 }
1408 else
1409 {
1410 reply << " " << id << ' ' << tele.name << "\n";
1411 }
1412 }
1413
1414 if (reply.str().empty())
1415 {
1417 }
1418 else
1419 {
1420 handler->PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str().c_str());
1421 }
1422
1423 if (limitReached)
1424 {
1426 }
1427
1428 return true;
1429 }
@ 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
1432 {
1433 if (namePart.empty())
1434 {
1435 return false;
1436 }
1437
1438 // can be nullptr in console call
1439 Player* target = handler->getSelectedPlayer();
1440
1441 // title name have single string arg for player name
1442 char const* targetName = target ? target->GetName().c_str() : "NAME";
1443
1444 std::wstring wNamePart;
1445
1446 if (!Utf8toWStr(namePart, wNamePart))
1447 {
1448 return false;
1449 }
1450
1451 // converting string that we try to find to lower case
1452 wstrToLower(wNamePart);
1453
1454 uint32 counter = 0; // Counter for figure out that we found smth.
1455 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1456
1457 // Search in CharTitles.dbc
1458 for (auto titleInfo : sCharTitlesStore)
1459 {
1460 int locale = handler->GetSessionDbcLocale();
1461 std::string name = titleInfo->nameMale[locale];
1462 if (name.empty())
1463 {
1464 continue;
1465 }
1466
1467 if (!Utf8FitTo(name, wNamePart))
1468 {
1469 locale = 0;
1470 for (; locale < TOTAL_LOCALES; ++locale)
1471 {
1472 if (locale == handler->GetSessionDbcLocale())
1473 {
1474 continue;
1475 }
1476
1477 name = titleInfo->nameMale[locale];
1478 if (name.empty())
1479 {
1480 continue;
1481 }
1482
1483 if (Utf8FitTo(name, wNamePart))
1484 {
1485 break;
1486 }
1487 }
1488 }
1489
1490 if (locale < TOTAL_LOCALES)
1491 {
1492 if (maxResults && counter == maxResults)
1493 {
1495 return true;
1496 }
1497
1498 char const* knownStr = target && target->HasTitle(titleInfo) ? handler->GetAcoreString(LANG_KNOWN) : "";
1499 char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index ? handler->GetAcoreString(LANG_ACTIVE) : "";
1500
1501 std::string titleNameStr = Acore::StringFormat(name, targetName);
1502
1503 // send title in "id (idx:idx) - [namedlink locale]" format
1504 if (handler->GetSession())
1505 {
1506 handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, titleInfo->ID, titleInfo->bit_index, titleInfo->ID, titleNameStr, localeNames[locale], knownStr, activeStr);
1507 }
1508 else
1509 {
1510 handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, titleInfo->ID, titleInfo->bit_index, titleNameStr, localeNames[locale], knownStr, activeStr);
1511 }
1512
1513 ++counter;
1514 }
1515 }
1516
1517 if (!counter) // if counter == 0 then we found nth
1518 {
1520 }
1521
1522 return true;
1523 }
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
@ PLAYER_CHOSEN_TITLE
Definition: UpdateFields.h:324
@ LANG_TITLE_LIST_CHAT
Definition: Language.h:390
@ LANG_COMMAND_NOTITLEFOUND
Definition: Language.h:392
@ LANG_TITLE_LIST_CONSOLE
Definition: Language.h:391
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305
std::string const & GetName() const
Definition: Object.h:446
bool HasTitle(uint32 bitIndex) const
Definition: Player.cpp:13218

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
1650 {
1651 if (!result)
1652 {
1654 handler->SetSentErrorMessage(true);
1655 return false;
1656 }
1657
1658 int32 counter = 0;
1659 uint32 count = 0;
1660 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1661
1662 do
1663 {
1664 if (maxResults && count++ == maxResults)
1665 {
1667 return true;
1668 }
1669
1670 Field* fields = result->Fetch();
1671 uint32 accountId = fields[0].Get<uint32>();
1672 std::string accountName = fields[1].Get<std::string>();
1673
1675 stmt->SetData(0, accountId);
1676 PreparedQueryResult result2 = CharacterDatabase.Query(stmt);
1677
1678 if (result2)
1679 {
1680 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, accountName.c_str(), accountId);
1681
1682 do
1683 {
1684 Field* characterFields = result2->Fetch();
1685 ObjectGuid::LowType guid = characterFields[0].Get<uint32>();
1686 std::string name = characterFields[1].Get<std::string>();
1687 uint8 plevel = 0, prace = 0, pclass = 0;
1688 bool online = ObjectAccessor::FindPlayerByLowGUID(guid) != nullptr;
1689
1690 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByName(name))
1691 {
1692 plevel = gpd->Level;
1693 prace = gpd->Race;
1694 pclass = gpd->Class;
1695 }
1696
1697 if (plevel > 0 && prace > 0 && prace <= RACE_DRAENEI && pclass > 0 && pclass <= CLASS_DRUID)
1698 {
1699 handler->PSendSysMessage(" %s (GUID %u) - %s - %s - %u%s", name.c_str(), guid, EnumUtils::ToTitle(Races(prace)), EnumUtils::ToTitle(Classes(pclass)), plevel, (online ? " - [ONLINE]" : ""));
1700 }
1701 else
1702 {
1703 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name.c_str(), guid);
1704 }
1705
1706 ++counter;
1707 } while (result2->NextRow() && (limit == -1 || counter < limit));
1708 }
1709 } while (result->NextRow());
1710
1711 if (!counter) // empty accounts only
1712 {
1714 handler->SetSentErrorMessage(true);
1715 return false;
1716 }
1717
1718 return true;
1719 }
std::int32_t int32
Definition: Define.h:104
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
@ CHAR_SEL_CHAR_GUID_NAME_BY_ACC
Definition: CharacterDatabase.h:340
#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
Classes
Definition: SharedDefines.h:111
@ CLASS_DRUID
Definition: SharedDefines.h:123
Races
Definition: SharedDefines.h:68
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Definition: ObjectAccessor.cpp:256
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:124

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

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