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
 

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)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ list_commandscript()

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

Member Function Documentation

◆ GetCommands()

ChatCommandTable list_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

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

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

◆ HandleListAllAurasCommand()

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

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByIdCommand()

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

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByNameCommand()

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

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListCreatureCommand()

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

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

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

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

References ChatHandler::GetAcoreString(), Unit::GetAppliedAuras(), Unit::GetAuraEffectsByType(), Aura::GetCasterGUID(), Aura::GetCharges(), ObjectGuid::GetCounter(), 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, 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
517 {
518 if (spellId)
519 return spellInfo->Id == spellId;
520
521 if (!namePart.empty())
522 {
523 std::string name = spellInfo->SpellName[locale];
524 return Utf8FitTo(name, namePart);
525 }
526
527 return true;
528 }
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition: Util.cpp:476

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

Referenced by ListAurasCommand().