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
45: CommandScript("list_commandscript") { }
Definition: ScriptMgr.h:850

Member Function Documentation

◆ GetCommands()

ChatCommandTable list_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

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

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

◆ HandleListAllAurasCommand()

static bool list_commandscript::HandleListAllAurasCommand ( ChatHandler handler)
inlinestatic
444 {
445 return ListAurasCommand(handler, {}, {});
446 }
static bool ListAurasCommand(ChatHandler *handler, Optional< uint32 > spellId, std::wstring namePart)
Definition: cs_list.cpp:458

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByIdCommand()

static bool list_commandscript::HandleListAurasByIdCommand ( ChatHandler handler,
uint32  spellId 
)
inlinestatic
449 {
450 return ListAurasCommand(handler, spellId, {});
451 }

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByNameCommand()

static bool list_commandscript::HandleListAurasByNameCommand ( ChatHandler handler,
WTail  namePart 
)
inlinestatic
454 {
455 return ListAurasCommand(handler, {}, namePart);
456 }

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListCreatureCommand()

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

References 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::SetSentErrorMessage(), sMapMgr, sObjectMgr, and WorldDatabase.

Referenced by GetCommands().

◆ HandleListItemCommand()

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

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::SendSysMessage(), PreparedStatementBase::SetData(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleListObjectCommand()

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

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::SetSentErrorMessage(), sMapMgr, sObjectMgr, and WorldDatabase.

Referenced by GetCommands().

◆ ListAurasCommand()

static bool list_commandscript::ListAurasCommand ( ChatHandler handler,
Optional< uint32 spellId,
std::wstring  namePart 
)
inlinestatic
459 {
460 Unit* unit = handler->getSelectedUnit();
461 if (!unit)
462 {
464 handler->SetSentErrorMessage(true);
465 return false;
466 }
467
468 wstrToLower(namePart);
469
470 char const* talentStr = handler->GetAcoreString(LANG_TALENT);
471 char const* passiveStr = handler->GetAcoreString(LANG_PASSIVE);
472
473 Unit::AuraApplicationMap const& auras = unit->GetAppliedAuras();
474 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, auras.size());
475 for (auto const& [aurId, aurApp] : auras)
476 {
477 bool talent = GetTalentSpellCost(aurApp->GetBase()->GetId()) > 0;
478
479 Aura const* aura = aurApp->GetBase();
480 char const* name = aura->GetSpellInfo()->SpellName[handler->GetSessionDbcLocale()];
481
482 if (!ShouldListAura(aura->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
483 continue;
484
485 std::ostringstream ss_name;
486 ss_name << "|cffffffff|Hspell:" << aura->GetId() << "|h[" << name << "]|h|r";
487
488 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str().c_str() : name),
489 aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(),
490 aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""),
491 (talent ? talentStr : ""), aura->GetCasterGUID().IsPlayer() ? "player" : "creature",
492 aura->GetCasterGUID().GetCounter());
493 }
494
495 for (uint16 i = 0; i < TOTAL_AURAS; ++i)
496 {
497 Unit::AuraEffectList const& auraList = unit->GetAuraEffectsByType(AuraType(i));
498 if (auraList.empty())
499 continue;
500
501 bool sizeLogged = false;
502
503 for (AuraEffect const* effect : auraList)
504 {
505 if (!ShouldListAura(effect->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
506 continue;
507
508 if (!sizeLogged)
509 {
510 sizeLogged = true;
511 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, auraList.size(), i);
512 }
513
514 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, effect->GetId(), effect->GetEffIndex(), effect->GetAmount());
515 }
516 }
517
518 return true;
519 }
void wstrToLower(std::wstring &str)
Definition: Util.cpp:383
uint32 GetTalentSpellCost(uint32 spellId)
Definition: DBCStores.cpp:679
@ 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:782
virtual char const * GetAcoreString(uint32 entry) const
Definition: Chat.cpp:42
Unit * getSelectedUnit() const
Definition: Chat.cpp:313
LowType GetCounter() const
Definition: ObjectGuid.h:147
bool IsPlayer() const
Definition: ObjectGuid.h:170
Definition: Unit.h:1290
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1967
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1299
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1924
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1306
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:521

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::SendSysMessage(), ChatHandler::SetSentErrorMessage(), 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
522 {
523 if (spellId)
524 return spellInfo->Id == spellId;
525
526 if (!namePart.empty())
527 {
528 std::string name = spellInfo->SpellName[locale];
529 return Utf8FitTo(name, namePart);
530 }
531
532 return true;
533 }
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition: Util.cpp:477

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

Referenced by ListAurasCommand().