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)
 
static bool HandleListRespawnsCommand (ChatHandler *handler)
 

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

Member Function Documentation

◆ GetCommands()

ChatCommandTable list_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

40 {
41 static ChatCommandTable listAurasCommandTable =
42 {
46 };
47
48 static ChatCommandTable listCommandTable =
49 {
53 { "auras", listAurasCommandTable },
55 };
56 static ChatCommandTable commandTable =
57 {
58 { "list", listCommandTable }
59 };
60 return commandTable;
61 }
static bool HandleListAurasByIdCommand(ChatHandler *handler, uint32 spellId)
Definition cs_list.cpp:438
static bool HandleListCreatureCommand(ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > creatureId, Optional< uint32 > countArg)
Definition cs_list.cpp:63
static bool HandleListAurasByNameCommand(ChatHandler *handler, WTail namePart)
Definition cs_list.cpp:443
static bool HandleListItemCommand(ChatHandler *handler, Variant< Hyperlink< item >, uint32 > itemArg, Optional< uint32 > countArg)
Definition cs_list.cpp:147
static bool HandleListAllAurasCommand(ChatHandler *handler)
Definition cs_list.cpp:433
static bool HandleListObjectCommand(ChatHandler *handler, Variant< Hyperlink< gameobject_entry >, uint32 > gameObjectId, Optional< uint32 > countArg)
Definition cs_list.cpp:348
static bool HandleListRespawnsCommand(ChatHandler *handler)
Definition cs_list.cpp:524
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46
@ RBAC_PERM_COMMAND_LIST_ITEM
Definition RBAC.h:270
@ RBAC_PERM_COMMAND_LIST_CREATURE
Definition RBAC.h:269
@ RBAC_PERM_COMMAND_LIST_OBJECT
Definition RBAC.h:271
@ RBAC_PERM_COMMAND_LIST_AURAS
Definition RBAC.h:272

References HandleListAllAurasCommand(), HandleListAurasByIdCommand(), HandleListAurasByNameCommand(), HandleListCreatureCommand(), HandleListItemCommand(), HandleListObjectCommand(), HandleListRespawnsCommand(), rbac::RBAC_PERM_COMMAND_LIST_AURAS, rbac::RBAC_PERM_COMMAND_LIST_CREATURE, rbac::RBAC_PERM_COMMAND_LIST_ITEM, and rbac::RBAC_PERM_COMMAND_LIST_OBJECT.

◆ HandleListAllAurasCommand()

static bool list_commandscript::HandleListAllAurasCommand ( ChatHandler handler)
inlinestatic
434 {
435 return ListAurasCommand(handler, {}, {});
436 }
static bool ListAurasCommand(ChatHandler *handler, Optional< uint32 > spellId, std::wstring namePart)
Definition cs_list.cpp:448

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByIdCommand()

static bool list_commandscript::HandleListAurasByIdCommand ( ChatHandler handler,
uint32  spellId 
)
inlinestatic
439 {
440 return ListAurasCommand(handler, spellId, {});
441 }

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListAurasByNameCommand()

static bool list_commandscript::HandleListAurasByNameCommand ( ChatHandler handler,
WTail  namePart 
)
inlinestatic
444 {
445 return ListAurasCommand(handler, {}, namePart);
446 }

References ListAurasCommand().

Referenced by GetCommands().

◆ HandleListCreatureCommand()

static bool list_commandscript::HandleListCreatureCommand ( ChatHandler handler,
Variant< Hyperlink< creature_entry >, uint32 creatureId,
Optional< uint32 countArg 
)
inlinestatic
64 {
65 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creatureId);
66 if (!cInfo)
67 {
69 return false;
70 }
71
72 uint32 count = countArg.value_or(10);
73
74 if (count == 0)
75 return false;
76
77 QueryResult result;
78
79 uint32 creatureCount = 0;
80 result = WorldDatabase.Query("SELECT COUNT(guid) FROM creature WHERE id1='{}' OR id2='{}' OR id3='{}'", uint32(creatureId), uint32(creatureId), uint32(creatureId));
81 if (result)
82 creatureCount = (*result)[0].Get<uint64>();
83
84 if (handler->GetSession())
85 {
86 Player* player = handler->GetSession()->GetPlayer();
87 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 {}",
88 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), uint32(creatureId), uint32(creatureId), uint32(creatureId), count);
89 }
90 else
91 result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id1='{}' OR id2='{}' OR id3='{}' LIMIT {}",
92 uint32(creatureId), uint32(creatureId), uint32(creatureId), count);
93
94 if (result)
95 {
96 do
97 {
98 Field* fields = result->Fetch();
99 ObjectGuid::LowType guid = fields[0].Get<uint32>();
100 float x = fields[1].Get<float>();
101 float y = fields[2].Get<float>();
102 float z = fields[3].Get<float>();
103 uint16 mapId = fields[4].Get<uint16>();
104 bool liveFound = false;
105
106 // Get map (only support base map from console)
107 Map* thisMap;
108 if (handler->GetSession())
109 thisMap = handler->GetSession()->GetPlayer()->GetMap();
110 else
111 thisMap = sMapMgr->FindBaseNonInstanceMap(mapId);
112
113 // If map found, try to find active version of this creature
114 if (thisMap)
115 {
116 auto const creBounds = thisMap->GetCreatureBySpawnIdStore().equal_range(guid);
117 if (creBounds.first != creBounds.second)
118 {
119 for (std::unordered_multimap<uint32, Creature*>::const_iterator itr = creBounds.first; itr != creBounds.second;)
120 {
121 if (handler->GetSession())
122 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, cInfo->Entry, guid, cInfo->Name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->IsAlive() ? "*" : " ");
123 else
124 handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->IsAlive() ? "*" : " ");
125 ++itr;
126 }
127 liveFound = true;
128 }
129 }
130
131 if (!liveFound)
132 {
133 if (handler->GetSession())
134 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, cInfo->Entry, guid, cInfo->Name, x, y, z, mapId, "", "");
135 else
136 handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapId, "", "");
137 }
138 }
139 while (result->NextRow());
140 }
141
142 handler->PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE, uint32(creatureId), creatureCount);
143
144 return true;
145 }
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:911
@ LANG_COMMAND_INVALIDCREATUREID
Definition Language.h:481
@ LANG_COMMAND_LISTCREATUREMESSAGE
Definition Language.h:482
@ LANG_CREATURE_LIST_CHAT
Definition Language.h:567
#define sMapMgr
Definition MapMgr.h:220
#define sObjectMgr
Definition ObjectMgr.h:1723
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:219
WorldSession * GetSession()
Definition Chat.h:242
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:224
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:166
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition Map.h:355
uint32 LowType
Definition ObjectGuid.h:122
Definition Player.h:1084
Map * GetMap() const
Definition Object.h:625
Player * GetPlayer() const
Definition WorldSession.h:454
Definition CreatureData.h:187
uint32 Entry
Definition CreatureData.h:188
std::string Name
Definition CreatureData.h:192
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
148 {
149 uint32 itemId = 0;
150 uint32 count = countArg.value_or(10);
151
152 if (itemArg.holds_alternative<Hyperlink<item>>())
153 {
154 itemId = itemArg.get<Hyperlink<item>>()->Item->ItemId;
155 }
156 else
157 {
158 itemId = itemArg.get<uint32>();
159 }
160
161 if (!count || !itemId)
162 return false;
163
164 PreparedQueryResult result;
165
166 // inventory case
167 uint32 inventoryCount = 0;
168
170 stmt->SetData(0, itemId);
171 result = CharacterDatabase.Query(stmt);
172
173 if (result)
174 inventoryCount = (*result)[0].Get<uint64>();
175
176 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY);
177 stmt->SetData(0, itemId);
178 stmt->SetData(1, count);
179 result = CharacterDatabase.Query(stmt);
180
181 if (result)
182 {
183 do
184 {
185 Field* fields = result->Fetch();
186 uint32 itemGuid = fields[0].Get<uint32>();
187 uint32 itemBag = fields[1].Get<uint32>();
188 uint8 itemSlot = fields[2].Get<uint8>();
189 uint32 ownerGuid = fields[3].Get<uint32>();
190 uint32 ownerAccountId = fields[4].Get<uint32>();
191 std::string ownerName = fields[5].Get<std::string>();
192
193 char const* itemPos = nullptr;
194 if (Player::IsEquipmentPos(itemBag, itemSlot))
195 itemPos = "[equipped]";
196 else if (Player::IsInventoryPos(itemBag, itemSlot))
197 itemPos = "[in inventory]";
198 else if (Player::IsBankPos(itemBag, itemSlot))
199 itemPos = "[in bank]";
200 else
201 itemPos = "";
202
203 handler->PSendSysMessage(LANG_ITEMLIST_SLOT, itemGuid, ownerName, ownerGuid, ownerAccountId, itemPos);
204 }
205 while (result->NextRow());
206
207 uint32 resultCount = uint32(result->GetRowCount());
208
209 if (count > resultCount)
210 count -= resultCount;
211 else
212 count = 0;
213 }
214
215 // mail case
216 uint32 mailCount = 0;
217
218 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_COUNT_ITEM);
219 stmt->SetData(0, itemId);
220 result = CharacterDatabase.Query(stmt);
221
222 if (result)
223 mailCount = (*result)[0].Get<uint64>();
224
225 if (count > 0)
226 {
227 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY);
228 stmt->SetData(0, itemId);
229 stmt->SetData(1, count);
230 result = CharacterDatabase.Query(stmt);
231 }
232 else
233 result = PreparedQueryResult(nullptr);
234
235 if (result)
236 {
237 do
238 {
239 Field* fields = result->Fetch();
240 ObjectGuid::LowType itemGuid = fields[0].Get<uint32>();
241 ObjectGuid::LowType itemSender = fields[1].Get<uint32>();
242 uint32 itemReceiver = fields[2].Get<uint32>();
243 uint32 itemSenderAccountId = fields[3].Get<uint32>();
244 std::string itemSenderName = fields[4].Get<std::string>();
245 uint32 itemReceiverAccount = fields[5].Get<uint32>();
246 std::string itemReceiverName = fields[6].Get<std::string>();
247
248 char const* itemPos = "[in mail]";
249
250 handler->PSendSysMessage(LANG_ITEMLIST_MAIL, itemGuid, itemSenderName, itemSender, itemSenderAccountId, itemReceiverName, itemReceiver, itemReceiverAccount, itemPos);
251 }
252 while (result->NextRow());
253
254 uint32 resultCount = uint32(result->GetRowCount());
255
256 if (count > resultCount)
257 count -= resultCount;
258 else
259 count = 0;
260 }
261
262 // auction case
263 uint32 auctionCount = 0;
264
265 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM);
266 stmt->SetData(0, itemId);
267 result = CharacterDatabase.Query(stmt);
268
269 if (result)
270 auctionCount = (*result)[0].Get<uint64>();
271
272 if (count > 0)
273 {
274 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY);
275 stmt->SetData(0, itemId);
276 stmt->SetData(1, count);
277 result = CharacterDatabase.Query(stmt);
278 }
279 else
280 result = PreparedQueryResult(nullptr);
281
282 if (result)
283 {
284 do
285 {
286 Field* fields = result->Fetch();
287 uint32 itemGuid = fields[0].Get<uint32>();
288 uint32 owner = fields[1].Get<uint32>();
289 uint32 ownerAccountId = fields[2].Get<uint32>();
290 std::string ownerName = fields[3].Get<std::string>();
291
292 char const* itemPos = "[in auction]";
293
294 handler->PSendSysMessage(LANG_ITEMLIST_AUCTION, itemGuid, ownerName, owner, ownerAccountId, itemPos);
295 }
296 while (result->NextRow());
297 }
298
299 // guild bank case
300 uint32 guildCount = 0;
301
302 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_COUNT_ITEM);
303 stmt->SetData(0, itemId);
304 result = CharacterDatabase.Query(stmt);
305
306 if (result)
307 guildCount = (*result)[0].Get<uint64>();
308
309 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY);
310 stmt->SetData(0, itemId);
311 stmt->SetData(1, count);
312 result = CharacterDatabase.Query(stmt);
313
314 if (result)
315 {
316 do
317 {
318 Field* fields = result->Fetch();
319 uint32 itemGuid = fields[0].Get<uint32>();
320 uint32 guildGuid = fields[1].Get<uint32>();
321 std::string guildName = fields[2].Get<std::string>();
322
323 char const* itemPos = "[in guild bank]";
324
325 handler->PSendSysMessage(LANG_ITEMLIST_GUILD, itemGuid, guildName, guildGuid, itemPos);
326 }
327 while (result->NextRow());
328
329 uint32 resultCount = uint32(result->GetRowCount());
330
331 if (count > resultCount)
332 count -= resultCount;
333 else
334 count = 0;
335 }
336
337 if (inventoryCount + mailCount + auctionCount + guildCount == 0)
338 {
340 return false;
341 }
342
343 handler->PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE, itemId, inventoryCount + mailCount + auctionCount + guildCount, inventoryCount, mailCount, auctionCount, guildCount);
344
345 return true;
346 }
@ CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY
Definition CharacterDatabase.h:362
@ CHAR_SEL_MAIL_COUNT_ITEM
Definition CharacterDatabase.h:359
@ CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM
Definition CharacterDatabase.h:360
@ CHAR_SEL_GUILD_BANK_COUNT_ITEM
Definition CharacterDatabase.h:361
@ CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY
Definition CharacterDatabase.h:365
@ CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY
Definition CharacterDatabase.h:366
@ CHAR_SEL_CHAR_INVENTORY_COUNT_ITEM
Definition CharacterDatabase.h:358
@ CHAR_SEL_MAIL_ITEMS_BY_ENTRY
Definition CharacterDatabase.h:364
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:919
@ LANG_ITEMLIST_MAIL
Definition Language.h:560
@ LANG_COMMAND_NOITEMFOUND
Definition Language.h:477
@ LANG_ITEMLIST_AUCTION
Definition Language.h:561
@ LANG_ITEMLIST_SLOT
Definition Language.h:559
@ LANG_COMMAND_LISTITEMMESSAGE
Definition Language.h:479
Definition Item.h:220
static bool IsEquipmentPos(uint16 pos)
Definition Player.h:1278
static bool IsInventoryPos(uint16 pos)
Definition Player.h:1276
static bool IsBankPos(uint16 pos)
Definition Player.h:1281
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:289
constexpr bool holds_alternative() const
Definition ChatCommandTags.h:303

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

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().

◆ HandleListRespawnsCommand()

static bool list_commandscript::HandleListRespawnsCommand ( ChatHandler handler)
inlinestatic
525 {
526 Player* player = handler->GetSession()->GetPlayer();
527 if (!player)
528 return false;
529
530 Map* map = player->GetMap();
531 uint32 count = 0;
532 time_t now = GameTime::GetGameTime().count();
533
535 for (auto const& pair : map->GetCreatureRespawnTimes())
536 {
537 CreatureData const* data = sObjectMgr->GetCreatureData(pair.first);
538 if (!data)
539 continue;
540
541 CreatureTemplate const* cTemplate = sObjectMgr->GetCreatureTemplate(data->id1);
542 std::string name = cTemplate ? cTemplate->Name : "Unknown";
543 time_t remaining = pair.second > now ? pair.second - now : 0;
544 handler->PSendSysMessage(LANG_LIST_RESPAWNS_CREATURE_ENTRY, pair.first, name, data->id1, remaining);
545 ++count;
546 if (count >= 50)
547 {
549 break;
550 }
551 }
552
553 count = 0;
555 for (auto const& pair : map->GetGORespawnTimes())
556 {
557 GameObjectData const* data = sObjectMgr->GetGameObjectData(pair.first);
558 if (!data)
559 continue;
560
561 GameObjectTemplate const* goTemplate = sObjectMgr->GetGameObjectTemplate(data->id);
562 std::string name = goTemplate ? goTemplate->name : "Unknown";
563 time_t remaining = pair.second > now ? pair.second - now : 0;
564 handler->PSendSysMessage(LANG_LIST_RESPAWNS_GO_ENTRY, pair.first, name, data->id, remaining);
565 ++count;
566 if (count >= 50)
567 {
569 break;
570 }
571 }
572
573 return true;
574 }
@ LANG_LIST_RESPAWNS_LIMIT
Definition Language.h:1468
@ LANG_LIST_RESPAWNS_GO_HEADER
Definition Language.h:1466
@ LANG_LIST_RESPAWNS_CREATURE_ENTRY
Definition Language.h:1465
@ LANG_LIST_RESPAWNS_CREATURE_HEADER
Definition Language.h:1464
@ LANG_LIST_RESPAWNS_GO_ENTRY
Definition Language.h:1467
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:168
uint32 GetId() const
Definition Map.h:232
uint32 GetInstanceId() const
Definition Map.h:268
Seconds GetGameTime()
Definition GameTime.cpp:38
Definition CreatureData.h:370
uint32 id1
Definition CreatureData.h:372
Definition GameObjectData.h:715
uint32 id
Definition GameObjectData.h:717

References Map::GetCreatureRespawnTimes(), GameTime::GetGameTime(), Map::GetGORespawnTimes(), Map::GetId(), Map::GetInstanceId(), WorldObject::GetMap(), WorldSession::GetPlayer(), ChatHandler::GetSession(), GameObjectData::id, CreatureData::id1, LANG_LIST_RESPAWNS_CREATURE_ENTRY, LANG_LIST_RESPAWNS_CREATURE_HEADER, LANG_LIST_RESPAWNS_GO_ENTRY, LANG_LIST_RESPAWNS_GO_HEADER, LANG_LIST_RESPAWNS_LIMIT, CreatureTemplate::Name, GameObjectTemplate::name, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ ListAurasCommand()

static bool list_commandscript::ListAurasCommand ( ChatHandler handler,
Optional< uint32 spellId,
std::wstring  namePart 
)
inlinestatic
449 {
450 Unit* unit = handler->getSelectedUnit();
451 if (!unit)
452 {
454 return false;
455 }
456
457 wstrToLower(namePart);
458
459 std::string talentStr = handler->GetAcoreString(LANG_TALENT);
460 std::string passiveStr = handler->GetAcoreString(LANG_PASSIVE);
461
462 Unit::AuraApplicationMap const& auras = unit->GetAppliedAuras();
463 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, auras.size());
464 for (auto const& [aurId, aurApp] : auras)
465 {
466 bool talent = GetTalentSpellCost(aurApp->GetBase()->GetId()) > 0;
467
468 Aura const* aura = aurApp->GetBase();
469 char const* name = aura->GetSpellInfo()->SpellName[handler->GetSessionDbcLocale()];
470
471 if (!ShouldListAura(aura->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
472 continue;
473
474 std::ostringstream ss_name;
475 ss_name << "|cffffffff|Hspell:" << aura->GetId() << "|h[" << name << "]|h|r";
476
477 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str() : name),
478 aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(),
479 aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""),
480 (talent ? talentStr : ""), aura->GetCasterGUID().IsPlayer() ? "player" : "creature",
481 aura->GetCasterGUID().ToString());
482 }
483
484 for (uint16 i = 0; i < TOTAL_AURAS; ++i)
485 {
486 Unit::AuraEffectList const& auraList = unit->GetAuraEffectsByType(AuraType(i));
487 if (auraList.empty())
488 continue;
489
490 bool sizeLogged = false;
491
492 for (AuraEffect const* effect : auraList)
493 {
494 if (!ShouldListAura(effect->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
495 continue;
496
497 if (!sizeLogged)
498 {
499 sizeLogged = true;
500 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, auraList.size(), i);
501 }
502
503 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, effect->GetId(), effect->GetEffIndex(), effect->GetAmount());
504 }
505 }
506
507 return true;
508 }
uint32 GetTalentSpellCost(uint32 spellId)
Definition DBCStores.cpp:686
@ LANG_COMMAND_TARGET_LISTAURAS
Definition Language.h:508
@ LANG_TALENT
Definition Language.h:66
@ LANG_COMMAND_TARGET_AURADETAIL
Definition Language.h:509
@ LANG_SELECT_CHAR_OR_CREATURE
Definition Language.h:31
@ LANG_PASSIVE
Definition Language.h:65
@ LANG_COMMAND_TARGET_AURASIMPLE
Definition Language.h:511
@ LANG_COMMAND_TARGET_LISTAURATYPE
Definition Language.h:510
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:405
SpellInfo const * GetSpellInfo() const
Definition SpellAuras.h:100
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:878
virtual std::string GetAcoreString(uint32 entry) const
Definition Chat.cpp:42
Unit * getSelectedUnit() const
Definition Chat.cpp:394
std::array< char const *, 16 > SpellName
Definition SpellInfo.h:407
Definition Unit.h:664
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition Unit.h:1428
std::vector< AuraEffect * > AuraEffectList
Definition Unit.h:680
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:673
AuraApplicationMap & GetAppliedAuras()
Definition Unit.h:1383
static bool ShouldListAura(SpellInfo const *spellInfo, Optional< uint32 > spellId, std::wstring namePart, uint8 locale)
Definition cs_list.cpp:510
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
511 {
512 if (spellId)
513 return spellInfo->Id == spellId;
514
515 if (!namePart.empty())
516 {
517 std::string name = spellInfo->SpellName[locale];
518 return Utf8FitTo(name, namePart);
519 }
520
521 return true;
522 }
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: