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
35: CommandScript("list_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable list_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

38 {
39 static ChatCommandTable listAurasCommandTable =
40 {
41 { "", HandleListAllAurasCommand, SEC_MODERATOR, Console::No },
42 { "id", HandleListAurasByIdCommand, SEC_MODERATOR, Console::No },
43 { "name", HandleListAurasByNameCommand, SEC_MODERATOR, Console::No },
44 };
45
46 static ChatCommandTable listCommandTable =
47 {
48 { "creature", HandleListCreatureCommand, SEC_MODERATOR, Console::Yes },
49 { "item", HandleListItemCommand, SEC_MODERATOR, Console::Yes },
50 { "object", HandleListObjectCommand, SEC_MODERATOR, Console::Yes },
51 { "auras", listAurasCommandTable },
52 };
53 static ChatCommandTable commandTable =
54 {
55 { "list", listCommandTable }
56 };
57 return commandTable;
58 }
@ SEC_MODERATOR
Definition Common.h:58
static bool HandleListAurasByIdCommand(ChatHandler *handler, uint32 spellId)
Definition cs_list.cpp:435
static bool HandleListCreatureCommand(ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > creatureId, Optional< uint32 > countArg)
Definition cs_list.cpp:60
static bool HandleListAurasByNameCommand(ChatHandler *handler, WTail namePart)
Definition cs_list.cpp:440
static bool HandleListItemCommand(ChatHandler *handler, Variant< Hyperlink< item >, uint32 > itemArg, Optional< uint32 > countArg)
Definition cs_list.cpp:144
static bool HandleListAllAurasCommand(ChatHandler *handler)
Definition cs_list.cpp:430
static bool HandleListObjectCommand(ChatHandler *handler, Variant< Hyperlink< gameobject_entry >, uint32 > gameObjectId, Optional< uint32 > countArg)
Definition cs_list.cpp:345
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
431 {
432 return ListAurasCommand(handler, {}, {});
433 }
static bool ListAurasCommand(ChatHandler *handler, Optional< uint32 > spellId, std::wstring namePart)
Definition cs_list.cpp:445

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByIdCommand()

static bool list_commandscript::HandleListAurasByIdCommand ( ChatHandler handler,
uint32  spellId 
)
inlinestatic
436 {
437 return ListAurasCommand(handler, spellId, {});
438 }

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByNameCommand()

static bool list_commandscript::HandleListAurasByNameCommand ( ChatHandler handler,
WTail  namePart 
)
inlinestatic
441 {
442 return ListAurasCommand(handler, {}, namePart);
443 }

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListCreatureCommand()

static bool list_commandscript::HandleListCreatureCommand ( ChatHandler handler,
Variant< Hyperlink< creature_entry >, uint32 creatureId,
Optional< uint32 countArg 
)
inlinestatic
61 {
62 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creatureId);
63 if (!cInfo)
64 {
66 return false;
67 }
68
69 uint32 count = countArg.value_or(10);
70
71 if (count == 0)
72 return false;
73
74 QueryResult result;
75
76 uint32 creatureCount = 0;
77 result = WorldDatabase.Query("SELECT COUNT(guid) FROM creature WHERE id1='{}' OR id2='{}' OR id3='{}'", uint32(creatureId), uint32(creatureId), uint32(creatureId));
78 if (result)
79 creatureCount = (*result)[0].Get<uint64>();
80
81 if (handler->GetSession())
82 {
83 Player* player = handler->GetSession()->GetPlayer();
84 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 {}",
85 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), uint32(creatureId), uint32(creatureId), uint32(creatureId), count);
86 }
87 else
88 result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id1='{}' OR id2='{}' OR id3='{}' LIMIT {}",
89 uint32(creatureId), uint32(creatureId), uint32(creatureId), count);
90
91 if (result)
92 {
93 do
94 {
95 Field* fields = result->Fetch();
96 ObjectGuid::LowType guid = fields[0].Get<uint32>();
97 float x = fields[1].Get<float>();
98 float y = fields[2].Get<float>();
99 float z = fields[3].Get<float>();
100 uint16 mapId = fields[4].Get<uint16>();
101 bool liveFound = false;
102
103 // Get map (only support base map from console)
104 Map* thisMap;
105 if (handler->GetSession())
106 thisMap = handler->GetSession()->GetPlayer()->GetMap();
107 else
108 thisMap = sMapMgr->FindBaseNonInstanceMap(mapId);
109
110 // If map found, try to find active version of this creature
111 if (thisMap)
112 {
113 auto const creBounds = thisMap->GetCreatureBySpawnIdStore().equal_range(guid);
114 if (creBounds.first != creBounds.second)
115 {
116 for (std::unordered_multimap<uint32, Creature*>::const_iterator itr = creBounds.first; itr != creBounds.second;)
117 {
118 if (handler->GetSession())
119 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, cInfo->Entry, guid, cInfo->Name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->IsAlive() ? "*" : " ");
120 else
121 handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->IsAlive() ? "*" : " ");
122 ++itr;
123 }
124 liveFound = true;
125 }
126 }
127
128 if (!liveFound)
129 {
130 if (handler->GetSession())
131 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, cInfo->Entry, guid, cInfo->Name, x, y, z, mapId, "", "");
132 else
133 handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapId, "", "");
134 }
135 }
136 while (result->NextRow());
137 }
138
139 handler->PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE, uint32(creatureId), creatureCount);
140
141 return true;
142 }
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:1650
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:1082
Map * GetMap() const
Definition Object.h:537
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
145 {
146 uint32 itemId = 0;
147 uint32 count = countArg.value_or(10);
148
149 if (itemArg.holds_alternative<Hyperlink<item>>())
150 {
151 itemId = itemArg.get<Hyperlink<item>>()->Item->ItemId;
152 }
153 else
154 {
155 itemId = itemArg.get<uint32>();
156 }
157
158 if (!count || !itemId)
159 return false;
160
161 PreparedQueryResult result;
162
163 // inventory case
164 uint32 inventoryCount = 0;
165
167 stmt->SetData(0, itemId);
168 result = CharacterDatabase.Query(stmt);
169
170 if (result)
171 inventoryCount = (*result)[0].Get<uint64>();
172
173 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY);
174 stmt->SetData(0, itemId);
175 stmt->SetData(1, count);
176 result = CharacterDatabase.Query(stmt);
177
178 if (result)
179 {
180 do
181 {
182 Field* fields = result->Fetch();
183 uint32 itemGuid = fields[0].Get<uint32>();
184 uint32 itemBag = fields[1].Get<uint32>();
185 uint8 itemSlot = fields[2].Get<uint8>();
186 uint32 ownerGuid = fields[3].Get<uint32>();
187 uint32 ownerAccountId = fields[4].Get<uint32>();
188 std::string ownerName = fields[5].Get<std::string>();
189
190 char const* itemPos = nullptr;
191 if (Player::IsEquipmentPos(itemBag, itemSlot))
192 itemPos = "[equipped]";
193 else if (Player::IsInventoryPos(itemBag, itemSlot))
194 itemPos = "[in inventory]";
195 else if (Player::IsBankPos(itemBag, itemSlot))
196 itemPos = "[in bank]";
197 else
198 itemPos = "";
199
200 handler->PSendSysMessage(LANG_ITEMLIST_SLOT, itemGuid, ownerName, ownerGuid, ownerAccountId, itemPos);
201 }
202 while (result->NextRow());
203
204 uint32 resultCount = uint32(result->GetRowCount());
205
206 if (count > resultCount)
207 count -= resultCount;
208 else
209 count = 0;
210 }
211
212 // mail case
213 uint32 mailCount = 0;
214
215 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_COUNT_ITEM);
216 stmt->SetData(0, itemId);
217 result = CharacterDatabase.Query(stmt);
218
219 if (result)
220 mailCount = (*result)[0].Get<uint64>();
221
222 if (count > 0)
223 {
224 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY);
225 stmt->SetData(0, itemId);
226 stmt->SetData(1, count);
227 result = CharacterDatabase.Query(stmt);
228 }
229 else
230 result = PreparedQueryResult(nullptr);
231
232 if (result)
233 {
234 do
235 {
236 Field* fields = result->Fetch();
237 ObjectGuid::LowType itemGuid = fields[0].Get<uint32>();
238 ObjectGuid::LowType itemSender = fields[1].Get<uint32>();
239 uint32 itemReceiver = fields[2].Get<uint32>();
240 uint32 itemSenderAccountId = fields[3].Get<uint32>();
241 std::string itemSenderName = fields[4].Get<std::string>();
242 uint32 itemReceiverAccount = fields[5].Get<uint32>();
243 std::string itemReceiverName = fields[6].Get<std::string>();
244
245 char const* itemPos = "[in mail]";
246
247 handler->PSendSysMessage(LANG_ITEMLIST_MAIL, itemGuid, itemSenderName, itemSender, itemSenderAccountId, itemReceiverName, itemReceiver, itemReceiverAccount, itemPos);
248 }
249 while (result->NextRow());
250
251 uint32 resultCount = uint32(result->GetRowCount());
252
253 if (count > resultCount)
254 count -= resultCount;
255 else
256 count = 0;
257 }
258
259 // auction case
260 uint32 auctionCount = 0;
261
262 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM);
263 stmt->SetData(0, itemId);
264 result = CharacterDatabase.Query(stmt);
265
266 if (result)
267 auctionCount = (*result)[0].Get<uint64>();
268
269 if (count > 0)
270 {
271 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY);
272 stmt->SetData(0, itemId);
273 stmt->SetData(1, count);
274 result = CharacterDatabase.Query(stmt);
275 }
276 else
277 result = PreparedQueryResult(nullptr);
278
279 if (result)
280 {
281 do
282 {
283 Field* fields = result->Fetch();
284 uint32 itemGuid = fields[0].Get<uint32>();
285 uint32 owner = fields[1].Get<uint32>();
286 uint32 ownerAccountId = fields[2].Get<uint32>();
287 std::string ownerName = fields[3].Get<std::string>();
288
289 char const* itemPos = "[in auction]";
290
291 handler->PSendSysMessage(LANG_ITEMLIST_AUCTION, itemGuid, ownerName, owner, ownerAccountId, itemPos);
292 }
293 while (result->NextRow());
294 }
295
296 // guild bank case
297 uint32 guildCount = 0;
298
299 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_COUNT_ITEM);
300 stmt->SetData(0, itemId);
301 result = CharacterDatabase.Query(stmt);
302
303 if (result)
304 guildCount = (*result)[0].Get<uint64>();
305
306 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY);
307 stmt->SetData(0, itemId);
308 stmt->SetData(1, count);
309 result = CharacterDatabase.Query(stmt);
310
311 if (result)
312 {
313 do
314 {
315 Field* fields = result->Fetch();
316 uint32 itemGuid = fields[0].Get<uint32>();
317 uint32 guildGuid = fields[1].Get<uint32>();
318 std::string guildName = fields[2].Get<std::string>();
319
320 char const* itemPos = "[in guild bank]";
321
322 handler->PSendSysMessage(LANG_ITEMLIST_GUILD, itemGuid, guildName, guildGuid, itemPos);
323 }
324 while (result->NextRow());
325
326 uint32 resultCount = uint32(result->GetRowCount());
327
328 if (count > resultCount)
329 count -= resultCount;
330 else
331 count = 0;
332 }
333
334 if (inventoryCount + mailCount + auctionCount + guildCount == 0)
335 {
337 return false;
338 }
339
340 handler->PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE, itemId, inventoryCount + mailCount + auctionCount + guildCount, inventoryCount, mailCount, auctionCount, guildCount);
341
342 return true;
343 }
@ 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:1276
static bool IsInventoryPos(uint16 pos)
Definition Player.h:1274
static bool IsBankPos(uint16 pos)
Definition Player.h:1279
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
346 {
347 GameObjectTemplate const* gInfo = sObjectMgr->GetGameObjectTemplate(gameObjectId);
348 if (!gInfo)
349 {
351 return false;
352 }
353
354 uint32 count = countArg.value_or(10);
355
356 if (count == 0)
357 return false;
358
359 QueryResult result;
360
361 uint32 objectCount = 0;
362 result = WorldDatabase.Query("SELECT COUNT(guid) FROM gameobject WHERE id='{}'", uint32(gameObjectId));
363 if (result)
364 objectCount = (*result)[0].Get<uint64>();
365
366 if (handler->GetSession())
367 {
368 Player* player = handler->GetSession()->GetPlayer();
369 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 {}",
370 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), uint32(gameObjectId), count);
371 }
372 else
373 result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '{}' LIMIT {}",
374 uint32(gameObjectId), count);
375
376 if (result)
377 {
378 do
379 {
380 Field* fields = result->Fetch();
381 ObjectGuid::LowType guid = fields[0].Get<uint32>();
382 float x = fields[1].Get<float>();
383 float y = fields[2].Get<float>();
384 float z = fields[3].Get<float>();
385 uint16 mapId = fields[4].Get<uint16>();
386 uint32 entry = fields[5].Get<uint32>();
387 bool liveFound = false;
388
389 // Get map (only support base map from console)
390 Map* thisMap;
391 if (handler->GetSession())
392 thisMap = handler->GetSession()->GetPlayer()->GetMap();
393 else
394 thisMap = sMapMgr->FindBaseNonInstanceMap(mapId);
395
396 // If map found, try to find active version of this object
397 if (thisMap)
398 {
399 auto const goBounds = thisMap->GetGameObjectBySpawnIdStore().equal_range(guid);
400 if (goBounds.first != goBounds.second)
401 {
402 for (std::unordered_multimap<uint32, GameObject*>::const_iterator itr = goBounds.first; itr != goBounds.second;)
403 {
404 if (handler->GetSession())
405 handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->isSpawned() ? "*" : " ");
406 else
407 handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->isSpawned() ? "*" : " ");
408 ++itr;
409 }
410 liveFound = true;
411 }
412 }
413
414 if (!liveFound)
415 {
416 if (handler->GetSession())
417 handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapId, "", "");
418 else
419 handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name, x, y, z, mapId, "", "");
420 }
421 }
422 while (result->NextRow());
423 }
424
425 handler->PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE, uint32(gameObjectId), objectCount);
426
427 return true;
428 }
@ 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
446 {
447 Unit* unit = handler->getSelectedUnit();
448 if (!unit)
449 {
451 return false;
452 }
453
454 wstrToLower(namePart);
455
456 std::string talentStr = handler->GetAcoreString(LANG_TALENT);
457 std::string passiveStr = handler->GetAcoreString(LANG_PASSIVE);
458
459 Unit::AuraApplicationMap const& auras = unit->GetAppliedAuras();
460 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, auras.size());
461 for (auto const& [aurId, aurApp] : auras)
462 {
463 bool talent = GetTalentSpellCost(aurApp->GetBase()->GetId()) > 0;
464
465 Aura const* aura = aurApp->GetBase();
466 char const* name = aura->GetSpellInfo()->SpellName[handler->GetSessionDbcLocale()];
467
468 if (!ShouldListAura(aura->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
469 continue;
470
471 std::ostringstream ss_name;
472 ss_name << "|cffffffff|Hspell:" << aura->GetId() << "|h[" << name << "]|h|r";
473
474 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str() : name),
475 aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(),
476 aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""),
477 (talent ? talentStr : ""), aura->GetCasterGUID().IsPlayer() ? "player" : "creature",
478 aura->GetCasterGUID().ToString());
479 }
480
481 for (uint16 i = 0; i < TOTAL_AURAS; ++i)
482 {
483 Unit::AuraEffectList const& auraList = unit->GetAuraEffectsByType(AuraType(i));
484 if (auraList.empty())
485 continue;
486
487 bool sizeLogged = false;
488
489 for (AuraEffect const* effect : auraList)
490 {
491 if (!ShouldListAura(effect->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
492 continue;
493
494 if (!sizeLogged)
495 {
496 sizeLogged = true;
497 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, auraList.size(), i);
498 }
499
500 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, effect->GetId(), effect->GetEffIndex(), effect->GetAmount());
501 }
502 }
503
504 return true;
505 }
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:620
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition Unit.h:1349
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:629
AuraApplicationMap & GetAppliedAuras()
Definition Unit.h:1304
std::list< AuraEffect * > AuraEffectList
Definition Unit.h:636
static bool ShouldListAura(SpellInfo const *spellInfo, Optional< uint32 > spellId, std::wstring namePart, uint8 locale)
Definition cs_list.cpp:507
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
508 {
509 if (spellId)
510 return spellInfo->Id == spellId;
511
512 if (!namePart.empty())
513 {
514 std::string name = spellInfo->SpellName[locale];
515 return Utf8FitTo(name, namePart);
516 }
517
518 return true;
519 }
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: