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
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
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
43: CommandScript("list_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable list_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

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

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

◆ HandleListAllAurasCommand()

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

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByIdCommand()

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

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByNameCommand()

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

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListCreatureCommand()

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

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

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

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

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
516 {
517 if (spellId)
518 return spellInfo->Id == spellId;
519
520 if (!namePart.empty())
521 {
522 std::string name = spellInfo->SpellName[locale];
523 return Utf8FitTo(name, namePart);
524 }
525
526 return true;
527 }
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition: Util.cpp:481

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

Referenced by ListAurasCommand().