AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
list_commandscript Class Reference
Inheritance diagram for list_commandscript:
CommandScript ScriptObject

Public Member Functions

 list_commandscript ()
 
ChatCommandTable GetCommands () const override
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleListCreatureCommand (ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > creatureId, Optional< uint32 > countArg)
 
static bool HandleListItemCommand (ChatHandler *handler, Variant< Hyperlink< item >, uint32 > itemArg, Optional< uint32 > countArg)
 
static bool HandleListObjectCommand (ChatHandler *handler, Variant< Hyperlink< gameobject_entry >, uint32 > gameObjectId, Optional< uint32 > countArg)
 
static bool HandleListAllAurasCommand (ChatHandler *handler)
 
static bool HandleListAurasByIdCommand (ChatHandler *handler, uint32 spellId)
 
static bool HandleListAurasByNameCommand (ChatHandler *handler, WTail namePart)
 
static bool ListAurasCommand (ChatHandler *handler, Optional< uint32 > spellId, std::wstring namePart)
 
static bool ShouldListAura (SpellInfo const *spellInfo, Optional< uint32 > spellId, std::wstring namePart, uint8 locale)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ list_commandscript()

list_commandscript::list_commandscript ( )
inline
42: CommandScript("list_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable list_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

45 {
46 static ChatCommandTable listAurasCommandTable =
47 {
48 { "", HandleListAllAurasCommand, SEC_MODERATOR, Console::No },
49 { "id", HandleListAurasByIdCommand, SEC_MODERATOR, Console::No },
50 { "name", HandleListAurasByNameCommand, SEC_MODERATOR, Console::No },
51 };
52
53 static ChatCommandTable listCommandTable =
54 {
55 { "creature", HandleListCreatureCommand, SEC_MODERATOR, Console::Yes },
56 { "item", HandleListItemCommand, SEC_MODERATOR, Console::Yes },
57 { "object", HandleListObjectCommand, SEC_MODERATOR, Console::Yes },
58 { "auras", listAurasCommandTable },
59 };
60 static ChatCommandTable commandTable =
61 {
62 { "list", listCommandTable }
63 };
64 return commandTable;
65 }
@ SEC_MODERATOR
Definition Common.h:58
static bool HandleListAurasByIdCommand(ChatHandler *handler, uint32 spellId)
Definition cs_list.cpp:442
static bool HandleListCreatureCommand(ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > creatureId, Optional< uint32 > countArg)
Definition cs_list.cpp:67
static bool HandleListAurasByNameCommand(ChatHandler *handler, WTail namePart)
Definition cs_list.cpp:447
static bool HandleListItemCommand(ChatHandler *handler, Variant< Hyperlink< item >, uint32 > itemArg, Optional< uint32 > countArg)
Definition cs_list.cpp:151
static bool HandleListAllAurasCommand(ChatHandler *handler)
Definition cs_list.cpp:437
static bool HandleListObjectCommand(ChatHandler *handler, Variant< Hyperlink< gameobject_entry >, uint32 > gameObjectId, Optional< uint32 > countArg)
Definition cs_list.cpp:352
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46

References HandleListAllAurasCommand(), HandleListAurasByIdCommand(), HandleListAurasByNameCommand(), HandleListCreatureCommand(), HandleListItemCommand(), HandleListObjectCommand(), and SEC_MODERATOR.

◆ HandleListAllAurasCommand()

static bool list_commandscript::HandleListAllAurasCommand ( ChatHandler handler)
inlinestatic
438 {
439 return ListAurasCommand(handler, {}, {});
440 }
static bool ListAurasCommand(ChatHandler *handler, Optional< uint32 > spellId, std::wstring namePart)
Definition cs_list.cpp:452

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByIdCommand()

static bool list_commandscript::HandleListAurasByIdCommand ( ChatHandler handler,
uint32  spellId 
)
inlinestatic
443 {
444 return ListAurasCommand(handler, spellId, {});
445 }

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByNameCommand()

static bool list_commandscript::HandleListAurasByNameCommand ( ChatHandler handler,
WTail  namePart 
)
inlinestatic
448 {
449 return ListAurasCommand(handler, {}, namePart);
450 }

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListCreatureCommand()

static bool list_commandscript::HandleListCreatureCommand ( ChatHandler handler,
Variant< Hyperlink< creature_entry >, uint32 creatureId,
Optional< uint32 countArg 
)
inlinestatic
68 {
69 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creatureId);
70 if (!cInfo)
71 {
73 return false;
74 }
75
76 uint32 count = countArg.value_or(10);
77
78 if (count == 0)
79 return false;
80
81 QueryResult result;
82
83 uint32 creatureCount = 0;
84 result = WorldDatabase.Query("SELECT COUNT(guid) FROM creature WHERE id1='{}' OR id2='{}' OR id3='{}'", uint32(creatureId), uint32(creatureId), uint32(creatureId));
85 if (result)
86 creatureCount = (*result)[0].Get<uint64>();
87
88 if (handler->GetSession())
89 {
90 Player* player = handler->GetSession()->GetPlayer();
91 result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '{}', 2) + POW(position_y - '{}', 2) + POW(position_z - '{}', 2)) AS order_ FROM creature WHERE id1='{}' OR id2='{}' OR id3='{}' ORDER BY order_ ASC LIMIT {}",
92 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), uint32(creatureId), uint32(creatureId), uint32(creatureId), count);
93 }
94 else
95 result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id1='{}' OR id2='{}' OR id3='{}' LIMIT {}",
96 uint32(creatureId), uint32(creatureId), uint32(creatureId), count);
97
98 if (result)
99 {
100 do
101 {
102 Field* fields = result->Fetch();
103 ObjectGuid::LowType guid = fields[0].Get<uint32>();
104 float x = fields[1].Get<float>();
105 float y = fields[2].Get<float>();
106 float z = fields[3].Get<float>();
107 uint16 mapId = fields[4].Get<uint16>();
108 bool liveFound = false;
109
110 // Get map (only support base map from console)
111 Map* thisMap;
112 if (handler->GetSession())
113 thisMap = handler->GetSession()->GetPlayer()->GetMap();
114 else
115 thisMap = sMapMgr->FindBaseNonInstanceMap(mapId);
116
117 // If map found, try to find active version of this creature
118 if (thisMap)
119 {
120 auto const creBounds = thisMap->GetCreatureBySpawnIdStore().equal_range(guid);
121 if (creBounds.first != creBounds.second)
122 {
123 for (std::unordered_multimap<uint32, Creature*>::const_iterator itr = creBounds.first; itr != creBounds.second;)
124 {
125 if (handler->GetSession())
126 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, cInfo->Entry, guid, cInfo->Name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->IsAlive() ? "*" : " ");
127 else
128 handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->IsAlive() ? "*" : " ");
129 ++itr;
130 }
131 liveFound = true;
132 }
133 }
134
135 if (!liveFound)
136 {
137 if (handler->GetSession())
138 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, cInfo->Entry, guid, cInfo->Name, x, y, z, mapId, "", "");
139 else
140 handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapId, "", "");
141 }
142 }
143 while (result->NextRow());
144 }
145
146 handler->PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE, uint32(creatureId), creatureCount);
147
148 return true;
149 }
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
std::uint32_t uint32
Definition Define.h:107
std::uint64_t uint64
Definition Define.h:106
std::uint16_t uint16
Definition Define.h:108
@ LANG_CREATURE_LIST_CONSOLE
Definition Language.h:900
@ LANG_COMMAND_INVALIDCREATUREID
Definition Language.h:473
@ LANG_COMMAND_LISTCREATUREMESSAGE
Definition Language.h:474
@ LANG_CREATURE_LIST_CHAT
Definition Language.h:559
#define sMapMgr
Definition MapMgr.h:220
#define sObjectMgr
Definition ObjectMgr.h:1636
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:211
WorldSession * GetSession()
Definition Chat.h:242
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:216
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
Definition Map.h:156
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition Map.h:367
uint32 LowType
Definition ObjectGuid.h:122
Definition Player.h:1081
Map * GetMap() const
Definition Object.h:536
Player * GetPlayer() const
Definition WorldSession.h:376
Definition CreatureData.h:186
uint32 Entry
Definition CreatureData.h:187
std::string Name
Definition CreatureData.h:191
float GetPositionZ() const
Definition Position.h:123
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122

References CreatureTemplate::Entry, Field::Get(), Map::GetCreatureBySpawnIdStore(), WorldObject::GetMap(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ChatHandler::GetSession(), LANG_COMMAND_INVALIDCREATUREID, LANG_COMMAND_LISTCREATUREMESSAGE, LANG_CREATURE_LIST_CHAT, LANG_CREATURE_LIST_CONSOLE, CreatureTemplate::Name, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), sMapMgr, sObjectMgr, and WorldDatabase.

Referenced by GetCommands().

◆ HandleListItemCommand()

static bool list_commandscript::HandleListItemCommand ( ChatHandler handler,
Variant< Hyperlink< item >, uint32 itemArg,
Optional< uint32 countArg 
)
inlinestatic
152 {
153 uint32 itemId = 0;
154 uint32 count = countArg.value_or(10);
155
156 if (itemArg.holds_alternative<Hyperlink<item>>())
157 {
158 itemId = itemArg.get<Hyperlink<item>>()->Item->ItemId;
159 }
160 else
161 {
162 itemId = itemArg.get<uint32>();
163 }
164
165 if (!count || !itemId)
166 return false;
167
168 PreparedQueryResult result;
169
170 // inventory case
171 uint32 inventoryCount = 0;
172
174 stmt->SetData(0, itemId);
175 result = CharacterDatabase.Query(stmt);
176
177 if (result)
178 inventoryCount = (*result)[0].Get<uint64>();
179
180 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY);
181 stmt->SetData(0, itemId);
182 stmt->SetData(1, count);
183 result = CharacterDatabase.Query(stmt);
184
185 if (result)
186 {
187 do
188 {
189 Field* fields = result->Fetch();
190 uint32 itemGuid = fields[0].Get<uint32>();
191 uint32 itemBag = fields[1].Get<uint32>();
192 uint8 itemSlot = fields[2].Get<uint8>();
193 uint32 ownerGuid = fields[3].Get<uint32>();
194 uint32 ownerAccountId = fields[4].Get<uint32>();
195 std::string ownerName = fields[5].Get<std::string>();
196
197 char const* itemPos = nullptr;
198 if (Player::IsEquipmentPos(itemBag, itemSlot))
199 itemPos = "[equipped]";
200 else if (Player::IsInventoryPos(itemBag, itemSlot))
201 itemPos = "[in inventory]";
202 else if (Player::IsBankPos(itemBag, itemSlot))
203 itemPos = "[in bank]";
204 else
205 itemPos = "";
206
207 handler->PSendSysMessage(LANG_ITEMLIST_SLOT, itemGuid, ownerName, ownerGuid, ownerAccountId, itemPos);
208 }
209 while (result->NextRow());
210
211 uint32 resultCount = uint32(result->GetRowCount());
212
213 if (count > resultCount)
214 count -= resultCount;
215 else
216 count = 0;
217 }
218
219 // mail case
220 uint32 mailCount = 0;
221
222 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_COUNT_ITEM);
223 stmt->SetData(0, itemId);
224 result = CharacterDatabase.Query(stmt);
225
226 if (result)
227 mailCount = (*result)[0].Get<uint64>();
228
229 if (count > 0)
230 {
231 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY);
232 stmt->SetData(0, itemId);
233 stmt->SetData(1, count);
234 result = CharacterDatabase.Query(stmt);
235 }
236 else
237 result = PreparedQueryResult(nullptr);
238
239 if (result)
240 {
241 do
242 {
243 Field* fields = result->Fetch();
244 ObjectGuid::LowType itemGuid = fields[0].Get<uint32>();
245 ObjectGuid::LowType itemSender = fields[1].Get<uint32>();
246 uint32 itemReceiver = fields[2].Get<uint32>();
247 uint32 itemSenderAccountId = fields[3].Get<uint32>();
248 std::string itemSenderName = fields[4].Get<std::string>();
249 uint32 itemReceiverAccount = fields[5].Get<uint32>();
250 std::string itemReceiverName = fields[6].Get<std::string>();
251
252 char const* itemPos = "[in mail]";
253
254 handler->PSendSysMessage(LANG_ITEMLIST_MAIL, itemGuid, itemSenderName, itemSender, itemSenderAccountId, itemReceiverName, itemReceiver, itemReceiverAccount, itemPos);
255 }
256 while (result->NextRow());
257
258 uint32 resultCount = uint32(result->GetRowCount());
259
260 if (count > resultCount)
261 count -= resultCount;
262 else
263 count = 0;
264 }
265
266 // auction case
267 uint32 auctionCount = 0;
268
269 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM);
270 stmt->SetData(0, itemId);
271 result = CharacterDatabase.Query(stmt);
272
273 if (result)
274 auctionCount = (*result)[0].Get<uint64>();
275
276 if (count > 0)
277 {
278 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY);
279 stmt->SetData(0, itemId);
280 stmt->SetData(1, count);
281 result = CharacterDatabase.Query(stmt);
282 }
283 else
284 result = PreparedQueryResult(nullptr);
285
286 if (result)
287 {
288 do
289 {
290 Field* fields = result->Fetch();
291 uint32 itemGuid = fields[0].Get<uint32>();
292 uint32 owner = fields[1].Get<uint32>();
293 uint32 ownerAccountId = fields[2].Get<uint32>();
294 std::string ownerName = fields[3].Get<std::string>();
295
296 char const* itemPos = "[in auction]";
297
298 handler->PSendSysMessage(LANG_ITEMLIST_AUCTION, itemGuid, ownerName, owner, ownerAccountId, itemPos);
299 }
300 while (result->NextRow());
301 }
302
303 // guild bank case
304 uint32 guildCount = 0;
305
306 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_COUNT_ITEM);
307 stmt->SetData(0, itemId);
308 result = CharacterDatabase.Query(stmt);
309
310 if (result)
311 guildCount = (*result)[0].Get<uint64>();
312
313 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY);
314 stmt->SetData(0, itemId);
315 stmt->SetData(1, count);
316 result = CharacterDatabase.Query(stmt);
317
318 if (result)
319 {
320 do
321 {
322 Field* fields = result->Fetch();
323 uint32 itemGuid = fields[0].Get<uint32>();
324 uint32 guildGuid = fields[1].Get<uint32>();
325 std::string guildName = fields[2].Get<std::string>();
326
327 char const* itemPos = "[in guild bank]";
328
329 handler->PSendSysMessage(LANG_ITEMLIST_GUILD, itemGuid, guildName, guildGuid, itemPos);
330 }
331 while (result->NextRow());
332
333 uint32 resultCount = uint32(result->GetRowCount());
334
335 if (count > resultCount)
336 count -= resultCount;
337 else
338 count = 0;
339 }
340
341 if (inventoryCount + mailCount + auctionCount + guildCount == 0)
342 {
344 return false;
345 }
346
347 handler->PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE, itemId, inventoryCount + mailCount + auctionCount + guildCount, inventoryCount, mailCount, auctionCount, guildCount);
348
349 return true;
350 }
@ CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY
Definition CharacterDatabase.h:360
@ CHAR_SEL_MAIL_COUNT_ITEM
Definition CharacterDatabase.h:357
@ CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM
Definition CharacterDatabase.h:358
@ CHAR_SEL_GUILD_BANK_COUNT_ITEM
Definition CharacterDatabase.h:359
@ CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY
Definition CharacterDatabase.h:363
@ CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY
Definition CharacterDatabase.h:364
@ CHAR_SEL_CHAR_INVENTORY_COUNT_ITEM
Definition CharacterDatabase.h:356
@ CHAR_SEL_MAIL_ITEMS_BY_ENTRY
Definition CharacterDatabase.h:362
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
std::uint8_t uint8
Definition Define.h:109
@ LANG_ITEMLIST_GUILD
Definition Language.h:908
@ LANG_ITEMLIST_MAIL
Definition Language.h:552
@ LANG_COMMAND_NOITEMFOUND
Definition Language.h:469
@ LANG_ITEMLIST_AUCTION
Definition Language.h:553
@ LANG_ITEMLIST_SLOT
Definition Language.h:551
@ LANG_COMMAND_LISTITEMMESSAGE
Definition Language.h:471
Definition Item.h:220
static bool IsEquipmentPos(uint16 pos)
Definition Player.h:1275
static bool IsInventoryPos(uint16 pos)
Definition Player.h:1273
static bool IsBankPos(uint16 pos)
Definition Player.h:1278
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
constexpr decltype(auto) get()
Definition ChatCommandTags.h:284
constexpr bool holds_alternative() const
Definition ChatCommandTags.h:298

References CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM, CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY, CHAR_SEL_CHAR_INVENTORY_COUNT_ITEM, CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY, CHAR_SEL_GUILD_BANK_COUNT_ITEM, CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY, CHAR_SEL_MAIL_COUNT_ITEM, CHAR_SEL_MAIL_ITEMS_BY_ENTRY, CharacterDatabase, Field::Get(), Player::IsBankPos(), Player::IsEquipmentPos(), Player::IsInventoryPos(), LANG_COMMAND_LISTITEMMESSAGE, LANG_COMMAND_NOITEMFOUND, LANG_ITEMLIST_AUCTION, LANG_ITEMLIST_GUILD, LANG_ITEMLIST_MAIL, LANG_ITEMLIST_SLOT, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and PreparedStatementBase::SetData().

Referenced by GetCommands().

◆ HandleListObjectCommand()

static bool list_commandscript::HandleListObjectCommand ( ChatHandler handler,
Variant< Hyperlink< gameobject_entry >, uint32 gameObjectId,
Optional< uint32 countArg 
)
inlinestatic
353 {
354 GameObjectTemplate const* gInfo = sObjectMgr->GetGameObjectTemplate(gameObjectId);
355 if (!gInfo)
356 {
358 return false;
359 }
360
361 uint32 count = countArg.value_or(10);
362
363 if (count == 0)
364 return false;
365
366 QueryResult result;
367
368 uint32 objectCount = 0;
369 result = WorldDatabase.Query("SELECT COUNT(guid) FROM gameobject WHERE id='{}'", uint32(gameObjectId));
370 if (result)
371 objectCount = (*result)[0].Get<uint64>();
372
373 if (handler->GetSession())
374 {
375 Player* player = handler->GetSession()->GetPlayer();
376 result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map, id, (POW(position_x - '{}', 2) + POW(position_y - '{}', 2) + POW(position_z - '{}', 2)) AS order_ FROM gameobject WHERE id = '{}' ORDER BY order_ ASC LIMIT {}",
377 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), uint32(gameObjectId), count);
378 }
379 else
380 result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '{}' LIMIT {}",
381 uint32(gameObjectId), count);
382
383 if (result)
384 {
385 do
386 {
387 Field* fields = result->Fetch();
388 ObjectGuid::LowType guid = fields[0].Get<uint32>();
389 float x = fields[1].Get<float>();
390 float y = fields[2].Get<float>();
391 float z = fields[3].Get<float>();
392 uint16 mapId = fields[4].Get<uint16>();
393 uint32 entry = fields[5].Get<uint32>();
394 bool liveFound = false;
395
396 // Get map (only support base map from console)
397 Map* thisMap;
398 if (handler->GetSession())
399 thisMap = handler->GetSession()->GetPlayer()->GetMap();
400 else
401 thisMap = sMapMgr->FindBaseNonInstanceMap(mapId);
402
403 // If map found, try to find active version of this object
404 if (thisMap)
405 {
406 auto const goBounds = thisMap->GetGameObjectBySpawnIdStore().equal_range(guid);
407 if (goBounds.first != goBounds.second)
408 {
409 for (std::unordered_multimap<uint32, GameObject*>::const_iterator itr = goBounds.first; itr != goBounds.second;)
410 {
411 if (handler->GetSession())
412 handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->isSpawned() ? "*" : " ");
413 else
414 handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->isSpawned() ? "*" : " ");
415 ++itr;
416 }
417 liveFound = true;
418 }
419 }
420
421 if (!liveFound)
422 {
423 if (handler->GetSession())
424 handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapId, "", "");
425 else
426 handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name, x, y, z, mapId, "", "");
427 }
428 }
429 while (result->NextRow());
430 }
431
432 handler->PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE, uint32(gameObjectId), objectCount);
433
434 return true;
435 }
@ LANG_GO_LIST_CHAT
Definition Language.h:561
@ LANG_COMMAND_LISTOBJMESSAGE
Definition Language.h:472
@ LANG_GO_LIST_CONSOLE
Definition Language.h:901
@ LANG_COMMAND_LISTOBJINVALIDID
Definition Language.h:470
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:370
Definition GameObjectData.h:31
std::string name
Definition GameObjectData.h:35

References Field::Get(), Map::GetGameObjectBySpawnIdStore(), WorldObject::GetMap(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ChatHandler::GetSession(), LANG_COMMAND_LISTOBJINVALIDID, LANG_COMMAND_LISTOBJMESSAGE, LANG_GO_LIST_CHAT, LANG_GO_LIST_CONSOLE, GameObjectTemplate::name, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), sMapMgr, sObjectMgr, and WorldDatabase.

Referenced by GetCommands().

◆ ListAurasCommand()

static bool list_commandscript::ListAurasCommand ( ChatHandler handler,
Optional< uint32 spellId,
std::wstring  namePart 
)
inlinestatic
453 {
454 Unit* unit = handler->getSelectedUnit();
455 if (!unit)
456 {
458 return false;
459 }
460
461 wstrToLower(namePart);
462
463 std::string talentStr = handler->GetAcoreString(LANG_TALENT);
464 std::string passiveStr = handler->GetAcoreString(LANG_PASSIVE);
465
466 Unit::AuraApplicationMap const& auras = unit->GetAppliedAuras();
467 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, auras.size());
468 for (auto const& [aurId, aurApp] : auras)
469 {
470 bool talent = GetTalentSpellCost(aurApp->GetBase()->GetId()) > 0;
471
472 Aura const* aura = aurApp->GetBase();
473 char const* name = aura->GetSpellInfo()->SpellName[handler->GetSessionDbcLocale()];
474
475 if (!ShouldListAura(aura->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
476 continue;
477
478 std::ostringstream ss_name;
479 ss_name << "|cffffffff|Hspell:" << aura->GetId() << "|h[" << name << "]|h|r";
480
481 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str() : name),
482 aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(),
483 aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""),
484 (talent ? talentStr : ""), aura->GetCasterGUID().IsPlayer() ? "player" : "creature",
485 aura->GetCasterGUID().ToString());
486 }
487
488 for (uint16 i = 0; i < TOTAL_AURAS; ++i)
489 {
490 Unit::AuraEffectList const& auraList = unit->GetAuraEffectsByType(AuraType(i));
491 if (auraList.empty())
492 continue;
493
494 bool sizeLogged = false;
495
496 for (AuraEffect const* effect : auraList)
497 {
498 if (!ShouldListAura(effect->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
499 continue;
500
501 if (!sizeLogged)
502 {
503 sizeLogged = true;
504 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, auraList.size(), i);
505 }
506
507 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, effect->GetId(), effect->GetEffIndex(), effect->GetAmount());
508 }
509 }
510
511 return true;
512 }
uint32 GetTalentSpellCost(uint32 spellId)
Definition DBCStores.cpp:686
@ LANG_COMMAND_TARGET_LISTAURAS
Definition Language.h:500
@ LANG_TALENT
Definition Language.h:66
@ LANG_COMMAND_TARGET_AURADETAIL
Definition Language.h:501
@ LANG_SELECT_CHAR_OR_CREATURE
Definition Language.h:31
@ LANG_PASSIVE
Definition Language.h:65
@ LANG_COMMAND_TARGET_AURASIMPLE
Definition Language.h:503
@ LANG_COMMAND_TARGET_LISTAURATYPE
Definition Language.h:502
AuraType
Definition SpellAuraDefines.h:62
@ TOTAL_AURAS
Definition SpellAuraDefines.h:380
void wstrToLower(std::wstring &str)
Definition Util.cpp:382
Definition SpellAuraEffects.h:39
Definition SpellAuras.h:87
uint32 GetId() const
Definition SpellAuras.cpp:466
SpellInfo const * GetSpellInfo() const
Definition SpellAuras.h:100
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:870
virtual std::string GetAcoreString(uint32 entry) const
Definition Chat.cpp:41
Unit * getSelectedUnit() const
Definition Chat.cpp:386
std::array< char const *, 16 > SpellName
Definition SpellInfo.h:383
Definition Unit.h:636
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition Unit.h:1358
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:645
AuraApplicationMap & GetAppliedAuras()
Definition Unit.h:1313
std::list< AuraEffect * > AuraEffectList
Definition Unit.h:652
static bool ShouldListAura(SpellInfo const *spellInfo, Optional< uint32 > spellId, std::wstring namePart, uint8 locale)
Definition cs_list.cpp:514
std::string ToString(Type &&val, Params &&... params)
Definition StringConvert.h:250

References ChatHandler::GetAcoreString(), Unit::GetAppliedAuras(), Unit::GetAuraEffectsByType(), Aura::GetCasterGUID(), Aura::GetCharges(), Aura::GetDuration(), Aura::GetId(), Aura::GetMaxDuration(), ChatHandler::getSelectedUnit(), ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), Aura::GetSpellInfo(), Aura::GetStackAmount(), GetTalentSpellCost(), Aura::IsPassive(), ObjectGuid::IsPlayer(), LANG_COMMAND_TARGET_AURADETAIL, LANG_COMMAND_TARGET_AURASIMPLE, LANG_COMMAND_TARGET_LISTAURAS, LANG_COMMAND_TARGET_LISTAURATYPE, LANG_PASSIVE, LANG_SELECT_CHAR_OR_CREATURE, LANG_TALENT, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), ShouldListAura(), SpellInfo::SpellName, ObjectGuid::ToString(), TOTAL_AURAS, and wstrToLower().

Referenced by HandleListAllAurasCommand(), HandleListAurasByIdCommand(), and HandleListAurasByNameCommand().

◆ ShouldListAura()

static bool list_commandscript::ShouldListAura ( SpellInfo const *  spellInfo,
Optional< uint32 spellId,
std::wstring  namePart,
uint8  locale 
)
inlinestatic
515 {
516 if (spellId)
517 return spellInfo->Id == spellId;
518
519 if (!namePart.empty())
520 {
521 std::string name = spellInfo->SpellName[locale];
522 return Utf8FitTo(name, namePart);
523 }
524
525 return true;
526 }
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition Util.cpp:481

References SpellInfo::Id, SpellInfo::SpellName, and Utf8FitTo().

Referenced by ListAurasCommand().


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