TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lookup_commandscript Class Reference

Public Member Functions

 lookup_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleLookupAreaCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupCreatureCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupEventCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupFactionCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupItemCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupItemSetCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupObjectCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupQuestCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupSkillCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupSpellCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupSpellIdCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupTaxiNodeCommand (ChatHandler *handler, const char *args)
 
static bool HandleLookupTeleCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupTitleCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupMapCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupPlayerIpCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupPlayerAccountCommand (ChatHandler *handler, char const *args)
 
static bool HandleLookupPlayerEmailCommand (ChatHandler *handler, char const *args)
 
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 ()
 

Constructor & Destructor Documentation

lookup_commandscript::lookup_commandscript ( )
inline
38 : CommandScript("lookup_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector<ChatCommand> lookup_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

41  {
42  static std::vector<ChatCommand> lookupPlayerCommandTable =
43  {
47  };
48 
49  static std::vector<ChatCommand> lookupSpellCommandTable =
50  {
53  };
54 
55  static std::vector<ChatCommand> lookupCommandTable =
56  {
65  { "player", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER, true, NULL, "", lookupPlayerCommandTable },
67  { "spell", rbac::RBAC_PERM_COMMAND_LOOKUP_SPELL, true, NULL, "", lookupSpellCommandTable },
72  };
73 
74  static std::vector<ChatCommand> commandTable =
75  {
76  { "lookup", rbac::RBAC_PERM_COMMAND_LOOKUP, true, NULL, "", lookupCommandTable },
77  };
78  return commandTable;
79  }
Definition: RBAC.h:349
static bool HandleLookupFactionCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:271
static bool HandleLookupObjectCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:457
static bool HandleLookupTaxiNodeCommand(ChatHandler *handler, const char *args)
Definition: cs_lookup.cpp:896
static bool HandleLookupPlayerIpCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1148
static bool HandleLookupSpellIdCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:826
arena_t NULL
Definition: jemalloc_internal.h:624
static bool HandleLookupMapCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1079
static bool HandleLookupSpellCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:734
static bool HandleLookupEventCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:216
static bool HandleLookupTitleCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1007
static bool HandleLookupItemSetCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:404
static bool HandleLookupTeleCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:949
static bool HandleLookupItemCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:354
static bool HandleLookupPlayerAccountCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1178
static bool HandleLookupPlayerEmailCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:1197
static bool HandleLookupAreaCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:81
static bool HandleLookupQuestCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:534
static bool HandleLookupSkillCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:664
static bool HandleLookupCreatureCommand(ChatHandler *handler, char const *args)
Definition: cs_lookup.cpp:138

+ Here is the call graph for this function:

static bool lookup_commandscript::HandleLookupAreaCommand ( ChatHandler handler,
char const args 
)
inlinestatic
82  {
83  if (!*args)
84  return false;
85 
86  std::string namePart = args;
87  std::wstring wNamePart;
88 
89  if (!Utf8toWStr(namePart, wNamePart))
90  return false;
91 
92  bool found = false;
93  uint32 count = 0;
94  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
95 
96  // converting string that we try to find to lower case
97  wstrToLower(wNamePart);
98 
99  // Search in AreaTable.dbc
100  for (uint32 i = 0; i < sAreaTableStore.GetNumRows(); ++i)
101  {
102  AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(i);
103  if (areaEntry)
104  {
105  std::string name = areaEntry->AreaName_lang;
106  if (name.empty())
107  continue;
108 
109  if (!Utf8FitTo(name, wNamePart))
110  continue;
111 
112  if (maxResults && count++ == maxResults)
113  {
114  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
115  return true;
116  }
117 
118  // send area in "id - [name]" format
119  std::ostringstream ss;
120  if (handler->GetSession())
121  ss << i << " - |cffffffff|Harea:" << i << "|h[" << name<< "]|h|r";
122  else
123  ss << i << " - " << name;
124 
125  handler->SendSysMessage(ss.str().c_str());
126 
127  if (!found)
128  found = true;
129  }
130  }
131 
132  if (!found)
134 
135  return true;
136  }
Definition: DBCStructure.h:37
Definition: Language.h:444
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
Definition: World.h:338
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:1095
uint32_t uint32
Definition: Define.h:150
char * AreaName_lang
Definition: DBCStructure.h:51
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupCreatureCommand ( ChatHandler handler,
char const args 
)
inlinestatic
139  {
140  if (!*args)
141  return false;
142 
143  std::string namePart = args;
144  std::wstring wNamePart;
145 
146  // converting string that we try to find to lower case
147  if (!Utf8toWStr(namePart, wNamePart))
148  return false;
149 
150  wstrToLower(wNamePart);
151 
152  bool found = false;
153  uint32 count = 0;
154  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
155 
156  CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
157  for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
158  {
159  uint32 id = itr->second.Entry;
160  uint8 localeIndex = handler->GetSessionDbLocaleIndex();
161  if (CreatureLocale const* creatureLocale = sObjectMgr->GetCreatureLocale(id))
162  {
163  if (creatureLocale->Name.size() > localeIndex && !creatureLocale->Name[localeIndex].empty())
164  {
165  std::string name = creatureLocale->Name[localeIndex];
166 
167  if (Utf8FitTo(name, wNamePart))
168  {
169  if (maxResults && count++ == maxResults)
170  {
171  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
172  return true;
173  }
174 
175  if (handler->GetSession())
176  handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str());
177  else
178  handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str());
179 
180  if (!found)
181  found = true;
182 
183  continue;
184  }
185  }
186  }
187 
188  std::string name = itr->second.Name;
189  if (name.empty())
190  continue;
191 
192  if (Utf8FitTo(name, wNamePart))
193  {
194  if (maxResults && count++ == maxResults)
195  {
196  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
197  return true;
198  }
199 
200  if (handler->GetSession())
201  handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str());
202  else
203  handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str());
204 
205  if (!found)
206  found = true;
207  }
208  }
209 
210  if (!found)
212 
213  return true;
214  }
Definition: Language.h:527
Definition: Creature.h:258
virtual int GetSessionDbLocaleIndex() const
Definition: Chat.cpp:1067
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
Definition: Language.h:907
#define sObjectMgr
Definition: ObjectMgr.h:1567
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: World.h:338
Definition: Language.h:449
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:1095
uint32_t uint32
Definition: Define.h:150
WorldSession * GetSession()
Definition: Chat.h:59
uint8_t uint8
Definition: Define.h:152
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition: Creature.h:213

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupEventCommand ( ChatHandler handler,
char const args 
)
inlinestatic
217  {
218  if (!*args)
219  return false;
220 
221  std::string namePart = args;
222  std::wstring wNamePart;
223 
224  // converting string that we try to find to lower case
225  if (!Utf8toWStr(namePart, wNamePart))
226  return false;
227 
228  wstrToLower(wNamePart);
229 
230  bool found = false;
231  uint32 count = 0;
232  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
233 
234  GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
235  GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
236 
237  for (uint32 id = 0; id < events.size(); ++id)
238  {
239  GameEventData const& eventData = events[id];
240 
241  std::string descr = eventData.description;
242  if (descr.empty())
243  continue;
244 
245  if (Utf8FitTo(descr, wNamePart))
246  {
247  if (maxResults && count++ == maxResults)
248  {
249  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
250  return true;
251  }
252 
253  char const* active = activeEvents.find(id) != activeEvents.end() ? handler->GetTrinityString(LANG_ACTIVE) : "";
254 
255  if (handler->GetSession())
256  handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.description.c_str(), active);
257  else
258  handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.description.c_str(), active);
259 
260  if (!found)
261  found = true;
262  }
263  }
264 
265  if (!found)
267 
268  return true;
269  }
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: Language.h:610
Definition: World.h:338
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:1095
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:611
Definition: Language.h:906
#define sGameEventMgr
Definition: GameEventMgr.h:184
std::set< uint16 > ActiveEvents
Definition: GameEventMgr.h:106
Definition: Language.h:68
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
std::vector< GameEventData > GameEventDataMap
Definition: GameEventMgr.h:107
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: GameEventMgr.h:56
std::string description
Definition: GameEventMgr.h:69

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupFactionCommand ( ChatHandler handler,
char const args 
)
inlinestatic
272  {
273  if (!*args)
274  return false;
275 
276  // Can be NULL at console call
277  Player* target = handler->getSelectedPlayer();
278 
279  std::string namePart = args;
280  std::wstring wNamePart;
281 
282  if (!Utf8toWStr(namePart, wNamePart))
283  return false;
284 
285  // converting string that we try to find to lower case
286  wstrToLower (wNamePart);
287 
288  bool found = false;
289  uint32 count = 0;
290  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
291 
292  for (uint32 id = 0; id < sFactionStore.GetNumRows(); ++id)
293  {
294  if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(id))
295  {
296  FactionState const* factionState = target ? target->GetReputationMgr().GetState(factionEntry) : NULL;
297 
298  std::string name = factionEntry->Name_lang;
299  if (name.empty())
300  continue;
301 
302  if (!Utf8FitTo(name, wNamePart))
303  continue;
304 
305  if (maxResults && count++ == maxResults)
306  {
307  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
308  return true;
309  }
310 
311  // send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format
312  // or "id - [faction] [no reputation]" format
313  std::ostringstream ss;
314  if (handler->GetSession())
315  ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << "]|h|r";
316  else
317  ss << id << " - " << name;
318 
319  if (factionState) // and then target != NULL also
320  {
321  uint32 index = target->GetReputationMgr().GetReputationRankStrIndex(factionEntry);
322  std::string rankName = handler->GetTrinityString(index);
323 
324  ss << ' ' << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
325 
326  if (factionState->Flags & FACTION_FLAG_VISIBLE)
327  ss << handler->GetTrinityString(LANG_FACTION_VISIBLE);
328  if (factionState->Flags & FACTION_FLAG_AT_WAR)
329  ss << handler->GetTrinityString(LANG_FACTION_ATWAR);
330  if (factionState->Flags & FACTION_FLAG_PEACE_FORCED)
332  if (factionState->Flags & FACTION_FLAG_HIDDEN)
333  ss << handler->GetTrinityString(LANG_FACTION_HIDDEN);
334  if (factionState->Flags & FACTION_FLAG_INVISIBLE_FORCED)
336  if (factionState->Flags & FACTION_FLAG_INACTIVE)
337  ss << handler->GetTrinityString(LANG_FACTION_INACTIVE);
338  }
339  else
341 
342  handler->SendSysMessage(ss.str().c_str());
343 
344  if (!found)
345  found = true;
346  }
347  }
348 
349  if (!found)
351  return true;
352  }
Definition: ReputationMgr.h:41
Definition: Language.h:335
Definition: ReputationMgr.h:43
Definition: Language.h:345
Definition: ReputationMgr.h:39
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:340
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
Definition: ReputationMgr.h:42
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: World.h:338
Definition: Language.h:341
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: ReputationMgr.h:40
Definition: Language.h:1095
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:344
Definition: DBCStructure.h:405
Player * getSelectedPlayer()
Definition: Chat.cpp:579
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
uint8 Flags
Definition: ReputationMgr.h:54
WorldSession * GetSession()
Definition: Chat.h:59
Definition: ReputationMgr.h:38
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: Language.h:343
DBCStorage< FactionEntry > sFactionStore(Factionfmt)
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:355
Definition: ReputationMgr.h:49
Definition: Language.h:342

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupItemCommand ( ChatHandler handler,
char const args 
)
inlinestatic
355  {
356  if (!*args)
357  return false;
358 
359  std::string namePart = args;
360  std::wstring wNamePart;
361 
362  // converting string that we try to find to lower case
363  if (!Utf8toWStr(namePart, wNamePart))
364  return false;
365 
366  wstrToLower(wNamePart);
367 
368  bool found = false;
369  uint32 count = 0;
370  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
371 
372  // Search in `item_template`
373  ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
374  for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
375  {
376  std::string name = itr->second.GetName(handler->GetSessionDbcLocale());
377  if (name.empty())
378  continue;
379 
380  if (Utf8FitTo(name, wNamePart))
381  {
382  if (maxResults && count++ == maxResults)
383  {
384  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
385  return true;
386  }
387 
388  if (handler->GetSession())
389  handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itr->second.GetId(), itr->second.GetId(), name.c_str());
390  else
391  handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itr->second.GetId(), name.c_str());
392 
393  if (!found)
394  found = true;
395  }
396  }
397 
398  if (!found)
400 
401  return true;
402  }
Definition: Language.h:438
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
#define sObjectMgr
Definition: ObjectMgr.h:1567
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: World.h:338
Definition: Language.h:525
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:1095
Definition: Language.h:908
uint32_t uint32
Definition: Define.h:150
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:1062
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
std::unordered_map< uint32, ItemTemplate > ItemTemplateContainer
Definition: ItemTemplate.h:769

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupItemSetCommand ( ChatHandler handler,
char const args 
)
inlinestatic
405  {
406  if (!*args)
407  return false;
408 
409  std::string namePart = args;
410  std::wstring wNamePart;
411 
412  if (!Utf8toWStr(namePart, wNamePart))
413  return false;
414 
415  // converting string that we try to find to lower case
416  wstrToLower(wNamePart);
417 
418  bool found = false;
419  uint32 count = 0;
420  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
421 
422  // Search in ItemSet.dbc
423  for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++)
424  {
425  ItemSetEntry const* set = sItemSetStore.LookupEntry(id);
426  if (set)
427  {
428  std::string name = set->Name_lang;
429  if (name.empty())
430  continue;
431 
432  if (!Utf8FitTo(name, wNamePart))
433  continue;
434 
435  if (maxResults && count++ == maxResults)
436  {
437  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
438  return true;
439  }
440 
441  // send item set in "id - [namedlink locale]" format
442  if (handler->GetSession())
443  handler->PSendSysMessage(LANG_ITEMSET_LIST_CHAT, id, id, name.c_str(), "");
444  else
445  handler->PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name.c_str(), "");
446 
447  if (!found)
448  found = true;
449  }
450  }
451  if (!found)
453 
454  return true;
455  }
char * Name_lang
Definition: DBCStructure.h:727
Definition: Language.h:445
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetfmt)
Definition: DBCStructure.h:724
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: World.h:338
Definition: Language.h:909
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:1095
Definition: Language.h:531
uint32_t uint32
Definition: Define.h:150
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupMapCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1080  {
1081  if (!*args)
1082  return false;
1083 
1084  std::string namePart = args;
1085  std::wstring wNamePart;
1086 
1087  if (!Utf8toWStr(namePart, wNamePart))
1088  return false;
1089 
1090  wstrToLower(wNamePart);
1091 
1092  uint32 counter = 0;
1093  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1094  uint8 locale = handler->GetSession() ? handler->GetSession()->GetSessionDbcLocale() : sWorld->GetDefaultDbcLocale();
1095 
1096  // search in Map.dbc
1097  for (uint32 id = 0; id < sMapStore.GetNumRows(); id++)
1098  {
1099  if (MapEntry const* mapInfo = sMapStore.LookupEntry(id))
1100  {
1101  std::string name = mapInfo->MapName_lang;
1102  if (name.empty())
1103  continue;
1104 
1105  if (Utf8FitTo(name, wNamePart) && locale < TOTAL_LOCALES)
1106  {
1107  if (maxResults && counter == maxResults)
1108  {
1109  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
1110  return true;
1111  }
1112 
1113  std::ostringstream ss;
1114  ss << id << " - [" << name << ']';
1115 
1116  if (mapInfo->IsContinent())
1117  ss << handler->GetTrinityString(LANG_CONTINENT);
1118 
1119  switch (mapInfo->InstanceType)
1120  {
1121  case MAP_INSTANCE:
1122  ss << handler->GetTrinityString(LANG_INSTANCE);
1123  break;
1124  case MAP_RAID:
1125  ss << handler->GetTrinityString(LANG_RAID);
1126  break;
1127  case MAP_BATTLEGROUND:
1128  ss << handler->GetTrinityString(LANG_BATTLEGROUND);
1129  break;
1130  case MAP_ARENA:
1131  ss << handler->GetTrinityString(LANG_ARENA);
1132  break;
1133  }
1134 
1135  handler->SendSysMessage(ss.str().c_str());
1136 
1137  ++counter;
1138  }
1139  }
1140  }
1141 
1142  if (!counter)
1144 
1145  return true;
1146  }
Definition: Language.h:1081
Definition: DBCEnums.h:482
Definition: Language.h:1079
Definition: DBCStructure.h:830
#define sWorld
Definition: World.h:887
LocaleConstant GetSessionDbcLocale() const
Definition: WorldSession.h:1059
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: Language.h:1082
Definition: DBCEnums.h:480
Definition: World.h:338
Definition: Language.h:1078
Definition: DBCEnums.h:481
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:1095
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:1083
DBCStorage< MapEntry > sMapStore(Mapfmt)
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
Definition: Language.h:1080
WorldSession * GetSession()
Definition: Chat.h:59
uint8_t uint8
Definition: Define.h:152
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: DBCEnums.h:479
Definition: Common.h:130

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupObjectCommand ( ChatHandler handler,
char const args 
)
inlinestatic
458  {
459  if (!*args)
460  return false;
461 
462  std::string namePart = args;
463  std::wstring wNamePart;
464 
465  // converting string that we try to find to lower case
466  if (!Utf8toWStr(namePart, wNamePart))
467  return false;
468 
469  wstrToLower(wNamePart);
470 
471  bool found = false;
472  uint32 count = 0;
473  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
474 
475  GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
476  for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
477  {
478  uint8 localeIndex = handler->GetSessionDbLocaleIndex();
479  if (GameObjectLocale const* objectLocalte = sObjectMgr->GetGameObjectLocale(itr->second.entry))
480  {
481  if (objectLocalte->Name.size() > localeIndex && !objectLocalte->Name[localeIndex].empty())
482  {
483  std::string name = objectLocalte->Name[localeIndex];
484 
485  if (Utf8FitTo(name, wNamePart))
486  {
487  if (maxResults && count++ == maxResults)
488  {
489  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
490  return true;
491  }
492 
493  if (handler->GetSession())
494  handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, itr->second.entry, itr->second.entry, name.c_str());
495  else
496  handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->second.entry, name.c_str());
497 
498  if (!found)
499  found = true;
500 
501  continue;
502  }
503  }
504  }
505 
506  std::string name = itr->second.name;
507  if (name.empty())
508  continue;
509 
510  if (Utf8FitTo(name, wNamePart))
511  {
512  if (maxResults && count++ == maxResults)
513  {
514  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
515  return true;
516  }
517 
518  if (handler->GetSession())
519  handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, itr->second.entry, itr->second.entry, name.c_str());
520  else
521  handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->second.entry, name.c_str());
522 
523  if (!found)
524  found = true;
525  }
526  }
527 
528  if (!found)
530 
531  return true;
532  }
virtual int GetSessionDbLocaleIndex() const
Definition: Chat.cpp:1067
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
#define sObjectMgr
Definition: ObjectMgr.h:1567
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: World.h:338
Definition: Language.h:450
Definition: Language.h:910
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:1095
Definition: GameObject.h:803
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:529
WorldSession * GetSession()
Definition: Chat.h:59
std::unordered_map< uint32, GameObjectTemplate > GameObjectTemplateContainer
Definition: GameObject.h:769
uint8_t uint8
Definition: Define.h:152
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupPlayerAccountCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1179  {
1180  if (!*args)
1181  return false;
1182 
1183  std::string account = strtok((char*)args, " ");
1184  char* limitStr = strtok(NULL, " ");
1185  int32 limit = limitStr ? atoi(limitStr) : -1;
1186 
1187  if (!Utf8ToUpperOnlyLatin(account))
1188  return false;
1189 
1191  stmt->setString(0, account);
1192  PreparedQueryResult result = LoginDatabase.Query(stmt);
1193 
1194  return LookupPlayerSearchCommand(result, limit, handler);
1195  }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
int32_t int32
Definition: Define.h:146
static bool LookupPlayerSearchCommand(PreparedQueryResult result, int32 limit, ChatHandler *handler)
Definition: cs_lookup.cpp:1213
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498
Definition: LoginDatabase.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupPlayerEmailCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1198  {
1199  if (!*args)
1200  return false;
1201 
1202  std::string email = strtok((char*)args, " ");
1203  char* limitStr = strtok(NULL, " ");
1204  int32 limit = limitStr ? atoi(limitStr) : -1;
1205 
1207  stmt->setString(0, email);
1208  PreparedQueryResult result = LoginDatabase.Query(stmt);
1209 
1210  return LookupPlayerSearchCommand(result, limit, handler);
1211  }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
int32_t int32
Definition: Define.h:146
static bool LookupPlayerSearchCommand(PreparedQueryResult result, int32 limit, ChatHandler *handler)
Definition: cs_lookup.cpp:1213
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: LoginDatabase.h:47
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupPlayerIpCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1149  {
1150  std::string ip;
1151  int32 limit;
1152  char* limitStr;
1153 
1154  Player* target = handler->getSelectedPlayer();
1155  if (!*args)
1156  {
1157  // NULL only if used from console
1158  if (!target || target == handler->GetSession()->GetPlayer())
1159  return false;
1160 
1161  ip = target->GetSession()->GetRemoteAddress();
1162  limit = -1;
1163  }
1164  else
1165  {
1166  ip = strtok((char*)args, " ");
1167  limitStr = strtok(NULL, " ");
1168  limit = limitStr ? atoi(limitStr) : -1;
1169  }
1170 
1172  stmt->setString(0, ip);
1173  PreparedQueryResult result = LoginDatabase.Query(stmt);
1174 
1175  return LookupPlayerSearchCommand(result, limit, handler);
1176  }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
int32_t int32
Definition: Define.h:146
static bool LookupPlayerSearchCommand(PreparedQueryResult result, int32 limit, ChatHandler *handler)
Definition: cs_lookup.cpp:1213
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Player * getSelectedPlayer()
Definition: Chat.cpp:579
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
WorldSession * GetSession()
Definition: Chat.h:59
Definition: LoginDatabase.h:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupQuestCommand ( ChatHandler handler,
char const args 
)
inlinestatic
535  {
536  if (!*args)
537  return false;
538 
539  // can be NULL at console call
540  Player* target = handler->getSelectedPlayerOrSelf();
541 
542  std::string namePart = args;
543  std::wstring wNamePart;
544 
545  // converting string that we try to find to lower case
546  if (!Utf8toWStr(namePart, wNamePart))
547  return false;
548 
549  wstrToLower(wNamePart);
550 
551  bool found = false;
552  uint32 count = 0;
553  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
554 
555  ObjectMgr::QuestMap const& qTemplates = sObjectMgr->GetQuestTemplates();
556  for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter)
557  {
558  Quest* qInfo = iter->second;
559 
560  int localeIndex = handler->GetSessionDbLocaleIndex();
561  if (localeIndex >= 0)
562  {
563  uint8 ulocaleIndex = uint8(localeIndex);
564  if (QuestTemplateLocale const* questLocale = sObjectMgr->GetQuestLocale(qInfo->GetQuestId()))
565  {
566  if (questLocale->LogTitle.size() > ulocaleIndex && !questLocale->LogTitle[ulocaleIndex].empty())
567  {
568  std::string title = questLocale->LogTitle[ulocaleIndex];
569 
570  if (Utf8FitTo(title, wNamePart))
571  {
572  if (maxResults && count++ == maxResults)
573  {
574  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
575  return true;
576  }
577 
578  char const* statusStr = "";
579 
580  if (target)
581  {
582  QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
583 
584  switch (status)
585  {
587  statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
588  break;
590  statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
591  break;
593  statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
594  break;
595  default:
596  break;
597  }
598  }
599 
600  if (handler->GetSession())
601  handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title.c_str(), statusStr);
602  else
603  handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title.c_str(), statusStr);
604 
605  if (!found)
606  found = true;
607 
608  continue;
609  }
610  }
611  }
612  }
613 
614  std::string title = qInfo->GetLogTitle();
615  if (title.empty())
616  continue;
617 
618  if (Utf8FitTo(title, wNamePart))
619  {
620  if (maxResults && count++ == maxResults)
621  {
622  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
623  return true;
624  }
625 
626  char const* statusStr = "";
627 
628  if (target)
629  {
630  QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
631 
632  switch (status)
633  {
635  statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
636  break;
638  statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
639  break;
641  statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
642  break;
643  default:
644  break;
645  }
646  }
647 
648  if (handler->GetSession())
649  handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title.c_str(), statusStr);
650  else
651  handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title.c_str(), statusStr);
652 
653  if (!found)
654  found = true;
655  }
656  }
657 
658  if (!found)
660 
661  return true;
662  }
virtual int GetSessionDbLocaleIndex() const
Definition: Chat.cpp:1067
Definition: QuestDef.h:111
Definition: QuestDef.h:279
Definition: Language.h:526
Definition: Language.h:448
Definition: Language.h:479
Definition: QuestDef.h:239
QuestStatus
Definition: QuestDef.h:108
Player * getSelectedPlayerOrSelf()
Definition: Chat.cpp:623
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
#define sObjectMgr
Definition: ObjectMgr.h:1567
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: World.h:338
Definition: QuestDef.h:116
Definition: Language.h:911
uint32 GetQuestId() const
Definition: QuestDef.h:304
std::unordered_map< uint32, Quest * > QuestMap
Definition: ObjectMgr.h:721
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:477
Definition: Language.h:1095
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:478
uint8_t uint8
Definition: g3dmath.h:164
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
WorldSession * GetSession()
Definition: Chat.h:59
Definition: QuestDef.h:113
uint8_t uint8
Definition: Define.h:152
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
std::string const & GetLogTitle() const
Definition: QuestDef.h:334
int32 GetQuestLevel() const
Definition: QuestDef.h:310
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupSkillCommand ( ChatHandler handler,
char const args 
)
inlinestatic
665  {
666  if (!*args)
667  return false;
668 
669  // can be NULL in console call
670  Player* target = handler->getSelectedPlayer();
671 
672  std::string namePart = args;
673  std::wstring wNamePart;
674 
675  if (!Utf8toWStr(namePart, wNamePart))
676  return false;
677 
678  // converting string that we try to find to lower case
679  wstrToLower(wNamePart);
680 
681  bool found = false;
682  uint32 count = 0;
683  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
684 
685  // Search in SkillLine.dbc
686  for (uint32 id = 0; id < sSkillLineStore.GetNumRows(); id++)
687  {
688  SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(id);
689  if (skillInfo)
690  {
691  std::string name = skillInfo->DisplayName_lang;
692  if (name.empty())
693  continue;
694 
695  if (!Utf8FitTo(name, wNamePart))
696  continue;
697 
698  if (maxResults && count++ == maxResults)
699  {
700  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
701  return true;
702  }
703 
704  char valStr[50] = "";
705  char const* knownStr = "";
706  if (target && target->HasSkill(id))
707  {
708  knownStr = handler->GetTrinityString(LANG_KNOWN);
709  uint32 curValue = target->GetPureSkillValue(id);
710  uint32 maxValue = target->GetPureMaxSkillValue(id);
711  uint32 permValue = target->GetSkillPermBonusValue(id);
712  uint32 tempValue = target->GetSkillTempBonusValue(id);
713 
714  char const* valFormat = handler->GetTrinityString(LANG_SKILL_VALUES);
715  snprintf(valStr, 50, valFormat, curValue, maxValue, permValue, tempValue);
716  }
717 
718  // send skill in "id - [namedlink locale]" format
719  if (handler->GetSession())
720  handler->PSendSysMessage(LANG_SKILL_LIST_CHAT, id, id, name.c_str(), "", knownStr, valStr);
721  else
722  handler->PSendSysMessage(LANG_SKILL_LIST_CONSOLE, id, name.c_str(), "", knownStr, valStr);
723 
724  if (!found)
725  found = true;
726  }
727  }
728  if (!found)
730 
731  return true;
732  }
Definition: DBCStructure.h:952
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
#define snprintf
Definition: Common.h:76
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: World.h:338
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:1095
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:912
char * DisplayName_lang
Definition: DBCStructure.h:956
Definition: Language.h:925
Player * getSelectedPlayer()
Definition: Chat.cpp:579
Definition: Language.h:446
Definition: Language.h:534
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:64

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupSpellCommand ( ChatHandler handler,
char const args 
)
inlinestatic
735  {
736  if (!*args)
737  return false;
738 
739  // can be NULL at console call
740  Player* target = handler->getSelectedPlayer();
741 
742  std::string namePart = args;
743  std::wstring wNamePart;
744 
745  if (!Utf8toWStr(namePart, wNamePart))
746  return false;
747 
748  // converting string that we try to find to lower case
749  wstrToLower(wNamePart);
750 
751  bool found = false;
752  uint32 count = 0;
753  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
754 
755  // Search in Spell.dbc
756  for (uint32 id = 0; id < sSpellMgr->GetSpellInfoStoreSize(); id++)
757  {
758  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id);
759  if (spellInfo)
760  {
761  std::string name = spellInfo->SpellName;
762  if (name.empty())
763  continue;
764 
765  if (!Utf8FitTo(name, wNamePart))
766  continue;
767 
768  if (maxResults && count++ == maxResults)
769  {
770  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
771  return true;
772  }
773 
774  bool known = target && target->HasSpell(id);
775 
776  SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0);
777  bool learn = effect ? (effect->Effect == SPELL_EFFECT_LEARN_SPELL) : false;
778 
779  SpellInfo const* learnSpellInfo = effect ? sSpellMgr->GetSpellInfo(effect->TriggerSpell) : NULL;
780 
781  bool talent = spellInfo->HasAttribute(SPELL_ATTR0_CU_IS_TALENT);
782  bool passive = spellInfo->IsPassive();
783  bool active = target && target->HasAura(id);
784 
785  // unit32 used to prevent interpreting uint8 as char at output
786  // find rank of learned spell for learning spell, or talent rank
787  uint32 rank = learn && learnSpellInfo ? learnSpellInfo->GetRank() : spellInfo->GetRank();
788 
789  // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
790  std::ostringstream ss;
791  if (handler->GetSession())
792  ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name;
793  else
794  ss << id << " - " << name;
795 
796  // include rank in link name
797  if (rank)
798  ss << handler->GetTrinityString(LANG_SPELL_RANK) << rank;
799 
800  if (handler->GetSession())
801  ss << "]|h|r";
802 
803  if (talent)
804  ss << handler->GetTrinityString(LANG_TALENT);
805  if (passive)
806  ss << handler->GetTrinityString(LANG_PASSIVE);
807  if (learn)
808  ss << handler->GetTrinityString(LANG_LEARN);
809  if (known)
810  ss << handler->GetTrinityString(LANG_KNOWN);
811  if (active)
812  ss << handler->GetTrinityString(LANG_ACTIVE);
813 
814  handler->SendSysMessage(ss.str().c_str());
815 
816  if (!found)
817  found = true;
818  }
819  }
820  if (!found)
822 
823  return true;
824  }
bool IsPassive() const
Definition: SpellInfo.cpp:1403
Definition: SpellInfo.h:326
Definition: SharedDefines.h:28
Definition: Language.h:63
arena_t NULL
Definition: jemalloc_internal.h:624
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
Definition: SharedDefines.h:1046
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: World.h:338
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Language.h:447
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:1095
Definition: Language.h:65
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
char * SpellName
Definition: SpellInfo.h:392
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:67
Player * getSelectedPlayer()
Definition: Chat.cpp:579
SpellEffectInfo const * GetEffect(uint32 difficulty, uint32 index) const
Definition: SpellInfo.cpp:3348
Definition: Language.h:68
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32 Effect
Definition: SpellInfo.h:243
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
uint8 GetRank() const
Definition: SpellInfo.cpp:2746
Definition: Language.h:64
Definition: Language.h:66
Definition: SpellInfo.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupSpellIdCommand ( ChatHandler handler,
char const args 
)
inlinestatic
827  {
828  if (!*args)
829  return false;
830 
831  // can be NULL at console call
832  Player* target = handler->getSelectedPlayer();
833 
834  uint32 id = atoi((char*)args);
835 
836  if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id))
837  {
838  int locale = handler->GetSessionDbcLocale();
839  std::string name = spellInfo->SpellName;
840  if (name.empty())
841  {
843  return true;
844  }
845 
846  bool known = target && target->HasSpell(id);
847 
848  SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0);
849  bool learn = effect? (effect->Effect == SPELL_EFFECT_LEARN_SPELL) : false;
850 
851  SpellInfo const* learnSpellInfo = effect ? sSpellMgr->GetSpellInfo(effect->TriggerSpell) : NULL;
852 
853  bool talent = spellInfo->HasAttribute(SPELL_ATTR0_CU_IS_TALENT);
854  bool passive = spellInfo->IsPassive();
855  bool active = target && target->HasAura(id);
856 
857  // unit32 used to prevent interpreting uint8 as char at output
858  // find rank of learned spell for learning spell, or talent rank
859  uint32 rank = learn && learnSpellInfo ? learnSpellInfo->GetRank() : spellInfo->GetRank();
860 
861  // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
862  std::ostringstream ss;
863  if (handler->GetSession())
864  ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name;
865  else
866  ss << id << " - " << name;
867 
868  // include rank in link name
869  if (rank)
870  ss << handler->GetTrinityString(LANG_SPELL_RANK) << rank;
871 
872  if (handler->GetSession())
873  ss << ' ' << localeNames[locale] << "]|h|r";
874  else
875  ss << ' ' << localeNames[locale];
876 
877  if (talent)
878  ss << handler->GetTrinityString(LANG_TALENT);
879  if (passive)
880  ss << handler->GetTrinityString(LANG_PASSIVE);
881  if (learn)
882  ss << handler->GetTrinityString(LANG_LEARN);
883  if (known)
884  ss << handler->GetTrinityString(LANG_KNOWN);
885  if (active)
886  ss << handler->GetTrinityString(LANG_ACTIVE);
887 
888  handler->SendSysMessage(ss.str().c_str());
889  }
890  else
892 
893  return true;
894  }
Definition: SpellInfo.h:326
Definition: SharedDefines.h:28
Definition: Language.h:63
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:1046
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Language.h:447
Definition: Language.h:65
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:67
Player * getSelectedPlayer()
Definition: Chat.cpp:579
TC_COMMON_API char const * localeNames[TOTAL_LOCALES]
Definition: Common.cpp:21
Definition: Language.h:68
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
WorldSession * GetSession()
Definition: Chat.h:59
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:1062
uint32 Effect
Definition: SpellInfo.h:243
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:64
Definition: Language.h:66
Definition: SpellInfo.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupTaxiNodeCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic
897  {
898  if (!*args)
899  return false;
900 
901  std::string namePart = args;
902  std::wstring wNamePart;
903 
904  if (!Utf8toWStr(namePart, wNamePart))
905  return false;
906 
907  // converting string that we try to find to lower case
908  wstrToLower(wNamePart);
909 
910  bool found = false;
911  uint32 count = 0;
912  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
913  int32 locale = handler->GetSessionDbcLocale();
914 
915  // Search in TaxiNodes.dbc
916  for (TaxiNodesEntry const* nodeEntry : sTaxiNodesStore)
917  {
918  std::string name = nodeEntry->Name->Str[locale];
919  if (name.empty())
920  continue;
921 
922  if (!Utf8FitTo(name, wNamePart))
923  continue;
924 
925  if (maxResults && count++ == maxResults)
926  {
927  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
928  return true;
929  }
930 
931  // send taxinode in "id - [name] (Map:m X:x Y:y Z:z)" format
932  if (handler->GetSession())
933  handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CHAT, nodeEntry->ID, nodeEntry->ID, name.c_str(), "",
934  nodeEntry->MapID, nodeEntry->Pos.X, nodeEntry->Pos.Y, nodeEntry->Pos.Z);
935  else
936  handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CONSOLE, nodeEntry->ID, name.c_str(), "",
937  nodeEntry->MapID, nodeEntry->Pos.X, nodeEntry->Pos.Y, nodeEntry->Pos.Z);
938 
939  if (!found)
940  found = true;
941  }
942  if (!found)
944 
945  return true;
946  }
Definition: Language.h:931
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: World.h:338
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:1095
Definition: Language.h:468
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:932
WorldSession * GetSession()
Definition: Chat.h:59
Definition: DB2Structure.h:1324
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:1062
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
DB2Storage< TaxiNodesEntry > sTaxiNodesStore("TaxiNodes.db2", TaxiNodesFormat, HOTFIX_SEL_TAXI_NODES)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupTeleCommand ( ChatHandler handler,
char const args 
)
inlinestatic
950  {
951  if (!*args)
952  {
954  handler->SetSentErrorMessage(true);
955  return false;
956  }
957 
958  char const* str = strtok((char*)args, " ");
959  if (!str)
960  return false;
961 
962  std::string namePart = str;
963  std::wstring wNamePart;
964 
965  if (!Utf8toWStr(namePart, wNamePart))
966  return false;
967 
968  // converting string that we try to find to lower case
969  wstrToLower(wNamePart);
970 
971  std::ostringstream reply;
972  uint32 count = 0;
973  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
974  bool limitReached = false;
975 
976  GameTeleContainer const & teleMap = sObjectMgr->GetGameTeleMap();
977  for (GameTeleContainer::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr)
978  {
979  GameTele const* tele = &itr->second;
980 
981  if (tele->wnameLow.find(wNamePart) == std::wstring::npos)
982  continue;
983 
984  if (maxResults && count++ == maxResults)
985  {
986  limitReached = true;
987  break;
988  }
989 
990  if (handler->GetSession())
991  reply << " |cffffffff|Htele:" << itr->first << "|h[" << tele->name << "]|h|r\n";
992  else
993  reply << " " << itr->first << ' ' << tele->name << "\n";
994  }
995 
996  if (reply.str().empty())
998  else
999  handler->PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str().c_str());
1000 
1001  if (limitReached)
1002  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
1003 
1004  return true;
1005  }
std::wstring wnameLow
Definition: ObjectMgr.h:133
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
std::string name
Definition: ObjectMgr.h:132
std::unordered_map< uint32, GameTele > GameTeleContainer
Definition: ObjectMgr.h:136
Definition: ObjectMgr.h:125
Definition: Language.h:199
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
#define sObjectMgr
Definition: ObjectMgr.h:1567
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: World.h:338
Definition: Language.h:197
Definition: Language.h:1095
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:196
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::HandleLookupTitleCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1008  {
1009  if (!*args)
1010  return false;
1011 
1012  // can be NULL in console call
1013  Player* target = handler->getSelectedPlayer();
1014 
1015  // title name have single string arg for player name
1016  char const* targetName = target ? target->GetName().c_str() : "NAME";
1017 
1018  std::string namePart = args;
1019  std::wstring wNamePart;
1020 
1021  if (!Utf8toWStr(namePart, wNamePart))
1022  return false;
1023 
1024  // converting string that we try to find to lower case
1025  wstrToLower(wNamePart);
1026 
1027  uint32 counter = 0; // Counter for figure out that we found smth.
1028  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1029 
1030  // Search in CharTitles.dbc
1031  for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++)
1032  {
1033  if (CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id))
1034  {
1035  for (uint8 gender = GENDER_MALE; gender <= GENDER_FEMALE; ++gender)
1036  {
1037  if (target && target->getGender() != gender)
1038  continue;
1039 
1040  std::string name = gender == GENDER_MALE ? titleInfo->NameMale_lang : titleInfo->NameFemale_lang;
1041 
1042  if (name.empty())
1043  continue;
1044 
1045  if (!Utf8FitTo(name, wNamePart))
1046  continue;
1047 
1048  if (maxResults && counter == maxResults)
1049  {
1050  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
1051  return true;
1052  }
1053 
1054  char const* knownStr = target && target->HasTitle(titleInfo) ? handler->GetTrinityString(LANG_KNOWN) : "";
1055 
1056  char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->MaskID
1057  ? handler->GetTrinityString(LANG_ACTIVE)
1058  : "";
1059 
1060  char titleNameStr[80];
1061  snprintf(titleNameStr, 80, name.c_str(), targetName);
1062 
1063  // send title in "id (idx:idx) - [namedlink locale]" format
1064  if (handler->GetSession())
1065  handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->MaskID, id, titleNameStr, "", knownStr, activeStr);
1066  else
1067  handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->MaskID, titleNameStr, "", knownStr, activeStr);
1068 
1069  ++counter;
1070  }
1071  }
1072  }
1073  if (counter == 0) // if counter == 0 then we found nth
1075 
1076  return true;
1077  }
Definition: Language.h:379
Definition: Language.h:377
Definition: DBCStructure.h:162
#define snprintf
Definition: Common.h:76
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesfmt)
Definition: World.h:338
Definition: Language.h:378
Definition: SharedDefines.h:93
Definition: SharedDefines.h:94
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
Definition: Language.h:1095
uint32_t uint32
Definition: Define.h:150
Player * getSelectedPlayer()
Definition: Chat.cpp:579
Definition: Language.h:68
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
WorldSession * GetSession()
Definition: Chat.h:59
uint8_t uint8
Definition: Define.h:152
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: UpdateFields.h:203
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:64

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool lookup_commandscript::LookupPlayerSearchCommand ( PreparedQueryResult  result,
int32  limit,
ChatHandler handler 
)
inlinestatic
1214  {
1215  if (!result)
1216  {
1218  handler->SetSentErrorMessage(true);
1219  return false;
1220  }
1221 
1222  int32 counter = 0;
1223  uint32 count = 0;
1224  uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
1225 
1226  do
1227  {
1228  if (maxResults && count++ == maxResults)
1229  {
1230  handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
1231  return true;
1232  }
1233 
1234  Field* fields = result->Fetch();
1235  uint32 accountId = fields[0].GetUInt32();
1236  std::string accountName = fields[1].GetString();
1237 
1239  stmt->setUInt32(0, accountId);
1241 
1242  if (result2)
1243  {
1244  handler->PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, accountName.c_str(), accountId);
1245 
1246  do
1247  {
1248  Field* characterFields = result2->Fetch();
1249  ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(characterFields[0].GetUInt64());
1250  std::string name = characterFields[1].GetString();
1251 
1252  handler->PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name.c_str(), guid.ToString().c_str());
1253  ++counter;
1254  }
1255  while (result2->NextRow() && (limit == -1 || counter < limit));
1256  }
1257  }
1258  while (result->NextRow());
1259 
1260  if (counter == 0) // empty accounts only
1261  {
1263  handler->SetSentErrorMessage(true);
1264  return false;
1265  }
1266 
1267  return true;
1268  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Definition: Language.h:357
Class used to access individual fields of database query result.
Definition: Field.h:56
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
Definition: World.h:338
Definition: CharacterDatabase.h:387
Definition: Language.h:1095
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: Language.h:358
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 GetUInt32() const
Definition: Field.h:146
Definition: Language.h:356
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
std::string GetString() const
Definition: Field.h:276
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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