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: 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:61
@ SEC_MODERATOR
Definition: Common.h:60
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
static bool HandleLookupTaxiNodeCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1277
static bool HandleLookupPlayerIpCommand(ChatHandler *handler, Optional< Tail > ip, Optional< int32 > limit)
Definition: cs_lookup.cpp:1600
static bool HandleLookupEventCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:269
static bool HandleLookupMapCommand(ChatHandler *handler, Tail namePart)
Definition: cs_lookup.cpp:1524
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:1639
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:1368
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:1430
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:1625

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:78
std::uint32_t uint32
Definition: Define.h:108
void wstrToLower(std::wstring &str)
Definition: Util.cpp:382
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition: Util.cpp:476
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
@ LANG_COMMAND_NOAREAFOUND
Definition: Language.h:457
@ LANG_COMMAND_LOOKUP_MAX_RESULTS
Definition: Language.h:1092
@ CONFIG_MAX_RESULTS_LOOKUP_COMMANDS
Definition: IWorld.h:358
#define sWorld
Definition: World.h:447
WorldSession * GetSession()
Definition: Chat.h:139
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:789
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:101

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:875
@ LANG_CREATURE_ENTRY_LIST_CHAT
Definition: Language.h:540
virtual int GetSessionDbLocaleIndex() const
Definition: Chat.cpp:794
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:874
@ 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:320
@ FACTION_FLAG_PEACE_FORCED
Definition: DBCEnums.h:319
@ FACTION_FLAG_INVISIBLE_FORCED
Definition: DBCEnums.h:318
@ FACTION_FLAG_HIDDEN
Definition: DBCEnums.h:317
@ FACTION_FLAG_VISIBLE
Definition: DBCEnums.h:315
@ FACTION_FLAG_AT_WAR
Definition: DBCEnums.h:316
Player * getSelectedPlayer() const
Definition: Chat.cpp:310
Definition: Player.h:1056
ReputationMgr & GetReputationMgr()
Definition: Player.h:2089
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:876
Definition: ItemTemplate.h:843

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:877
Definition: DBCStructure.h:1223
char const * name[16]
Definition: DBCStructure.h:1225

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

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:878
@ 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
1626 {
1627 if (!Utf8ToUpperOnlyLatin(account))
1628 {
1629 return false;
1630 }
1631
1633 stmt->SetData(0, account);
1634 PreparedQueryResult result = LoginDatabase.Query(stmt);
1635
1636 return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
1637 }
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:527
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:1648

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

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:879
@ 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:1416
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:880
@ LANG_COMMAND_NOSKILLFOUND
Definition: Language.h:459
@ LANG_SKILL_VALUES
Definition: Language.h:893
std::string StringFormat(Format &&fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:30
uint16 GetPureSkillValue(uint32 skill) const
Definition: Player.cpp:5432
int16 GetSkillTempBonusValue(uint32 skill) const
Definition: Player.cpp:5456
int16 GetSkillPermBonusValue(uint32 skill) const
Definition: Player.cpp:5444
bool HasSkill(uint32 skill) const
Definition: Player.cpp:5346
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition: Player.cpp:5402

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:682
@ 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:825
@ SPELL_EFFECT_LEARN_SPELL
Definition: SharedDefines.h:814
bool HasSpell(uint32 spell) const override
Definition: Player.cpp:3831
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5636
Definition: SpellInfo.h:314
bool IsPassive() const
Definition: SpellInfo.cpp:1085
uint8 GetRank() const
Definition: SpellInfo.cpp:2480
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->SendErrorMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
1176 return false;
1177 }
1178
1179 int locale = handler->GetSessionDbcLocale();
1180 std::string name = spell->SpellName[locale];
1181 if (name.empty())
1182 {
1184 return true;
1185 }
1186
1187 if (locale < TOTAL_LOCALES)
1188 {
1189 if (maxResults && count++ == maxResults)
1190 {
1192 return true;
1193 }
1194
1195 bool known = target && target->HasSpell(spell->Id);
1196 bool learn = (spell->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL);
1197
1198 SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spell->Effects[0].TriggerSpell);
1199
1200 uint32 talentCost = GetTalentSpellCost(spell->Id);
1201
1202 bool talent = (talentCost > 0);
1203 bool passive = spell->IsPassive();
1204 bool active = target && target->HasAura(spell->Id);
1205
1206 // unit32 used to prevent interpreting uint8 as char at output
1207 // find rank of learned spell for learning spell, or talent rank
1208 uint32 rank = talentCost ? talentCost : learn && learnSpellInfo ? learnSpellInfo->GetRank() : spell->GetRank();
1209
1210 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
1211 std::ostringstream ss;
1212 if (handler->GetSession())
1213 {
1214 ss << spell->Id << " - |cffffffff|Hspell:" << spell->Id << "|h[" << name;
1215 }
1216 else
1217 {
1218 ss << spell->Id << " - " << name;
1219 }
1220
1221 // include rank in link name
1222 if (rank)
1223 {
1224 ss << handler->GetAcoreString(LANG_SPELL_RANK) << rank;
1225 }
1226
1227 if (handler->GetSession())
1228 {
1229 ss << ' ' << localeNames[locale] << "]|h|r";
1230 }
1231 else
1232 {
1233 ss << ' ' << localeNames[locale];
1234 }
1235
1236 if (talent)
1237 {
1238 ss << handler->GetAcoreString(LANG_TALENT);
1239 }
1240
1241 if (passive)
1242 {
1243 ss << handler->GetAcoreString(LANG_PASSIVE);
1244 }
1245
1246 if (learn)
1247 {
1248 ss << handler->GetAcoreString(LANG_LEARN);
1249 }
1250
1251 if (known)
1252 {
1253 ss << handler->GetAcoreString(LANG_KNOWN);
1254 }
1255
1256 if (active)
1257 {
1258 ss << handler->GetAcoreString(LANG_ACTIVE);
1259 }
1260
1261 handler->SendSysMessage(ss.str().c_str());
1262
1263 if (!found)
1264 {
1265 found = true;
1266 }
1267 }
1268
1269 if (!found)
1270 {
1272 }
1273
1274 return true;
1275 }
@ LANG_COMMAND_SPELL_BROKEN
Definition: Language.h:503
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:152
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
1278 {
1279 if (namePart.empty())
1280 {
1281 return false;
1282 }
1283
1284 std::wstring wNamePart;
1285
1286 if (!Utf8toWStr(namePart, wNamePart))
1287 {
1288 return false;
1289 }
1290
1291 // converting string that we try to find to lower case
1292 wstrToLower(wNamePart);
1293
1294 bool found = false;
1295 uint32 count = 0;
1296 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1297
1298 // Search in TaxiNodes.dbc
1299 for (auto nodeEntry : sTaxiNodesStore)
1300 {
1301 int locale = handler->GetSessionDbcLocale();
1302 std::string name = nodeEntry->name[locale];
1303
1304 if (name.empty())
1305 {
1306 continue;
1307 }
1308
1309 if (!Utf8FitTo(name, wNamePart))
1310 {
1311 locale = 0;
1312
1313 for (; locale < TOTAL_LOCALES; ++locale)
1314 {
1315 if (locale == handler->GetSessionDbcLocale())
1316 {
1317 continue;
1318 }
1319
1320 name = nodeEntry->name[locale];
1321 if (name.empty())
1322 {
1323 continue;
1324 }
1325
1326 if (Utf8FitTo(name, wNamePart))
1327 {
1328 break;
1329 }
1330 }
1331 }
1332
1333 if (locale < TOTAL_LOCALES)
1334 {
1335 if (maxResults && count++ == maxResults)
1336 {
1338 return true;
1339 }
1340
1341 // send taxinode in "id - [name] (Map:m X:x Y:y Z:z)" format
1342 if (handler->GetSession())
1343 {
1344 handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CHAT, nodeEntry->ID, nodeEntry->ID, name.c_str(), localeNames[locale],
1345 nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z);
1346 }
1347 else
1348 {
1349 handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CONSOLE, nodeEntry->ID, name.c_str(), localeNames[locale],
1350 nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z);
1351 }
1352
1353 if (!found)
1354 {
1355 found = true;
1356 }
1357 }
1358 }
1359 if (!found)
1360 {
1362 }
1363
1364 return true;
1365 }
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
@ LANG_COMMAND_NOTAXINODEFOUND
Definition: Language.h:481
@ LANG_TAXINODE_ENTRY_LIST_CHAT
Definition: Language.h:899
@ LANG_TAXINODE_ENTRY_LIST_CONSOLE
Definition: Language.h:900

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

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
1649 {
1650 if (!result)
1651 {
1653 return false;
1654 }
1655
1656 int32 counter = 0;
1657 uint32 count = 0;
1658 uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1659
1660 do
1661 {
1662 if (maxResults && count++ == maxResults)
1663 {
1665 return true;
1666 }
1667
1668 Field* fields = result->Fetch();
1669 uint32 accountId = fields[0].Get<uint32>();
1670 std::string accountName = fields[1].Get<std::string>();
1671
1673 stmt->SetData(0, accountId);
1674 PreparedQueryResult result2 = CharacterDatabase.Query(stmt);
1675
1676 if (result2)
1677 {
1678 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, accountName.c_str(), accountId);
1679
1680 do
1681 {
1682 Field* characterFields = result2->Fetch();
1683 ObjectGuid::LowType guid = characterFields[0].Get<uint32>();
1684 std::string name = characterFields[1].Get<std::string>();
1685 uint8 plevel = 0, prace = 0, pclass = 0;
1686 bool online = ObjectAccessor::FindPlayerByLowGUID(guid) != nullptr;
1687
1688 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByName(name))
1689 {
1690 plevel = gpd->Level;
1691 prace = gpd->Race;
1692 pclass = gpd->Class;
1693 }
1694
1695 if (plevel > 0 && prace > 0 && prace <= RACE_DRAENEI && pclass > 0 && pclass <= CLASS_DRUID)
1696 {
1697 handler->PSendSysMessage(" %s (GUID %u) - %s - %s - %u%s", name.c_str(), guid, EnumUtils::ToTitle(Races(prace)), EnumUtils::ToTitle(Classes(pclass)), plevel, (online ? " - [ONLINE]" : ""));
1698 }
1699 else
1700 {
1701 handler->PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name.c_str(), guid);
1702 }
1703
1704 ++counter;
1705 } while (result2->NextRow() && (limit == -1 || counter < limit));
1706 }
1707 } while (result->NextRow());
1708
1709 if (!counter) // empty accounts only
1710 {
1712 return false;
1713 }
1714
1715 return true;
1716 }
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: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: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::SendErrorMessage(), sWorld, and EnumUtils::ToTitle().

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