TrinityCore
Loading...
Searching...
No Matches
cs_list.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/* ScriptData
19Name: list_commandscript
20%Complete: 100
21Comment: All list related commands
22Category: commandscripts
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "CharacterCache.h"
27#include "Chat.h"
28#include "Creature.h"
29#include "DatabaseEnv.h"
30#include "DBCStores.h"
31#include "GameObject.h"
32#include "GameTime.h"
33#include "Language.h"
34#include "MapManager.h"
35#include "ObjectAccessor.h"
36#include "ObjectMgr.h"
37#include "Player.h"
38#include "Random.h"
39#include "RBAC.h"
40#include "SpellAuraEffects.h"
41#include "WorldSession.h"
42
43using namespace Trinity::ChatCommands;
44
46{
47public:
48 list_commandscript() : CommandScript("list_commandscript") { }
49
51 {
52 static ChatCommandTable listAurasCommandTable =
53 {
57 };
58
59 static ChatCommandTable listCommandTable =
60 {
64 { "auras", listAurasCommandTable },
68 };
69 static ChatCommandTable commandTable =
70 {
71 { "list", listCommandTable },
72 };
73 return commandTable;
74 }
75
77 {
78 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creatureId);
79 if (!cInfo)
80 {
82 handler->SetSentErrorMessage(true);
83 return false;
84 }
85
86 uint32 count = countArg.value_or(10);
87
88 if (count == 0)
89 return false;
90
91 QueryResult result;
92
93 uint32 creatureCount = 0;
94 result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='{}'", creatureId);
95 if (result)
96 creatureCount = (*result)[0].GetUInt64();
97
98 if (handler->GetSession())
99 {
100 Player* player = handler->GetSession()->GetPlayer();
101 result = WorldDatabase.PQuery("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 id = '{}' ORDER BY order_ ASC LIMIT {}",
102 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), creatureId, count);
103 }
104 else
105 result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '{}' LIMIT {}",
106 creatureId, count);
107
108 if (result)
109 {
110 do
111 {
112 Field* fields = result->Fetch();
113 ObjectGuid::LowType guid = fields[0].GetUInt32();
114 float x = fields[1].GetFloat();
115 float y = fields[2].GetFloat();
116 float z = fields[3].GetFloat();
117 uint16 mapId = fields[4].GetUInt16();
118 bool liveFound = false;
119
120 // Get map (only support base map from console)
121 Map* thisMap;
122 if (handler->GetSession())
123 thisMap = handler->GetSession()->GetPlayer()->GetMap();
124 else
125 thisMap = sMapMgr->FindBaseNonInstanceMap(mapId);
126
127 // If map found, try to find active version of this creature
128 if (thisMap)
129 {
130 auto const creBounds = thisMap->GetCreatureBySpawnIdStore().equal_range(guid);
131 if (creBounds.first != creBounds.second)
132 {
133 for (std::unordered_multimap<uint32, Creature*>::const_iterator itr = creBounds.first; itr != creBounds.second;)
134 {
135 if (handler->GetSession())
136 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() ? "*" : " ");
137 else
138 handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name.c_str(), x, y, z, mapId, itr->second->GetGUID().ToString().c_str(), itr->second->IsAlive() ? "*" : " ");
139 ++itr;
140 }
141 liveFound = true;
142 }
143 }
144
145 if (!liveFound)
146 {
147 if (handler->GetSession())
148 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name.c_str(), x, y, z, mapId, "", "");
149 else
150 handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name.c_str(), x, y, z, mapId, "", "");
151 }
152 }
153 while (result->NextRow());
154 }
155
156 handler->PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE, *creatureId, creatureCount);
157
158 return true;
159 }
160
162 {
163 uint32 itemId = item->Item->GetId();
164 uint32 count = countArg.value_or(10);
165
166 if (count == 0)
167 return false;
168
169 PreparedQueryResult result;
170
171 // inventory case
172 uint32 inventoryCount = 0;
173
175 stmt->setUInt32(0, itemId);
176 result = CharacterDatabase.Query(stmt);
177
178 if (result)
179 inventoryCount = (*result)[0].GetUInt64();
180
181 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY);
182 stmt->setUInt32(0, itemId);
183 stmt->setUInt32(1, count);
184 result = CharacterDatabase.Query(stmt);
185
186 if (result)
187 {
188 do
189 {
190 Field* fields = result->Fetch();
191 ObjectGuid itemGuid = ObjectGuid::Create<HighGuid::Item>(fields[0].GetUInt32());
192 uint32 itemBag = fields[1].GetUInt32();
193 uint8 itemSlot = fields[2].GetUInt8();
194 ObjectGuid ownerGuid = ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt32());
195 uint32 ownerAccountId = fields[4].GetUInt32();
196 std::string ownerName = fields[5].GetString();
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.ToString().c_str(), ownerName.c_str(), ownerGuid.ToString().c_str(), 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->setUInt32(0, itemId);
225 result = CharacterDatabase.Query(stmt);
226
227 if (result)
228 mailCount = (*result)[0].GetUInt64();
229
230 if (count > 0)
231 {
232 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY);
233 stmt->setUInt32(0, itemId);
234 stmt->setUInt32(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].GetUInt32();
246 ObjectGuid::LowType itemSender = fields[1].GetUInt32();
247 ObjectGuid::LowType itemReceiver = fields[2].GetUInt32();
248 uint32 itemSenderAccountId = fields[3].GetUInt32();
249 std::string itemSenderName = fields[4].GetString();
250 uint32 itemReceiverAccount = fields[5].GetUInt32();
251 std::string itemReceiverName = fields[6].GetString();
252
253 char const* itemPos = "[in mail]";
254
255 handler->PSendSysMessage(LANG_ITEMLIST_MAIL, itemGuid, itemSenderName.c_str(), itemSender, itemSenderAccountId, itemReceiverName.c_str(), 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->setUInt32(0, itemId);
272 result = CharacterDatabase.Query(stmt);
273
274 if (result)
275 auctionCount = (*result)[0].GetUInt64();
276
277 if (count > 0)
278 {
279 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY);
280 stmt->setUInt32(0, itemId);
281 stmt->setUInt32(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].GetUInt32();
293 uint32 owner = fields[1].GetUInt32();
294 uint32 ownerAccountId = fields[2].GetUInt32();
295 std::string ownerName = fields[3].GetString();
296
297 char const* itemPos = "[in auction]";
298
299 handler->PSendSysMessage(LANG_ITEMLIST_AUCTION, itemGuid, ownerName.c_str(), 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->setUInt32(0, itemId);
309 result = CharacterDatabase.Query(stmt);
310
311 if (result)
312 guildCount = (*result)[0].GetUInt64();
313
314 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY);
315 stmt->setUInt32(0, itemId);
316 stmt->setUInt32(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].GetUInt32();
325 uint32 guildGuid = fields[1].GetUInt32();
326 std::string guildName = fields[2].GetString();
327
328 char const* itemPos = "[in guild bank]";
329
330 handler->PSendSysMessage(LANG_ITEMLIST_GUILD, itemGuid, guildName.c_str(), 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 handler->SetSentErrorMessage(true);
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 }
353
355 {
356 GameObjectTemplate const* gInfo = sObjectMgr->GetGameObjectTemplate(gameObjectId);
357 if (!gInfo)
358 {
359 handler->PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, *gameObjectId);
360 handler->SetSentErrorMessage(true);
361 return false;
362 }
363
364 uint32 count = countArg.value_or(10);
365
366 if (count == 0)
367 return false;
368
369 QueryResult result;
370
371 uint32 objectCount = 0;
372 result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='{}'", gameObjectId);
373 if (result)
374 objectCount = (*result)[0].GetUInt64();
375
376 if (handler->GetSession())
377 {
378 Player* player = handler->GetSession()->GetPlayer();
379 result = WorldDatabase.PQuery("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 {}",
380 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), gameObjectId, count);
381 }
382 else
383 result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '{}' LIMIT {}",
384 gameObjectId, count);
385
386 if (result)
387 {
388 do
389 {
390 Field* fields = result->Fetch();
391 ObjectGuid::LowType guid = fields[0].GetUInt32();
392 float x = fields[1].GetFloat();
393 float y = fields[2].GetFloat();
394 float z = fields[3].GetFloat();
395 uint16 mapId = fields[4].GetUInt16();
396 uint32 entry = fields[5].GetUInt32();
397 bool liveFound = false;
398
399 // Get map (only support base map from console)
400 Map* thisMap;
401 if (handler->GetSession())
402 thisMap = handler->GetSession()->GetPlayer()->GetMap();
403 else
404 thisMap = sMapMgr->FindBaseNonInstanceMap(mapId);
405
406 // If map found, try to find active version of this object
407 if (thisMap)
408 {
409 auto const goBounds = thisMap->GetGameObjectBySpawnIdStore().equal_range(guid);
410 if (goBounds.first != goBounds.second)
411 {
412 for (std::unordered_multimap<uint32, GameObject*>::const_iterator itr = goBounds.first; itr != goBounds.second;)
413 {
414 if (handler->GetSession())
415 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() ? "*" : " ");
416 else
417 handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name.c_str(), x, y, z, mapId, itr->second->GetGUID().ToString().c_str(), itr->second->isSpawned() ? "*" : " ");
418 ++itr;
419 }
420 liveFound = true;
421 }
422 }
423
424 if (!liveFound)
425 {
426 if (handler->GetSession())
427 handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name.c_str(), x, y, z, mapId, "", "");
428 else
429 handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name.c_str(), x, y, z, mapId, "", "");
430 }
431 }
432 while (result->NextRow());
433 }
434
435 handler->PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE, *gameObjectId, objectCount);
436
437 return true;
438 }
439
441 {
442 return ListAurasCommand(handler, {}, {});
443 }
444
445 static bool HandleListAurasByIdCommand(ChatHandler* handler, uint32 spellId)
446 {
447 return ListAurasCommand(handler, spellId, {});
448 }
449
450 static bool HandleListAurasByNameCommand(ChatHandler* handler, WTail namePart)
451 {
452 return ListAurasCommand(handler, {}, namePart);
453 }
454
455 static bool ListAurasCommand(ChatHandler* handler, Optional<uint32> spellId, std::wstring namePart)
456 {
457 Unit* unit = handler->getSelectedUnit();
458 if (!unit)
459 {
461 handler->SetSentErrorMessage(true);
462 return false;
463 }
464
465 wstrToLower(namePart);
466
467 char const* talentStr = handler->GetTrinityString(LANG_TALENT);
468 char const* passiveStr = handler->GetTrinityString(LANG_PASSIVE);
469
470 Unit::AuraApplicationMap const& auras = unit->GetAppliedAuras();
471 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, auras.size());
472 for (auto const& [aurId, aurApp] : auras)
473 {
474 Aura const* aura = aurApp->GetBase();
475 char const* name = aura->GetSpellInfo()->SpellName[handler->GetSessionDbcLocale()];
476 bool talent = aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_IS_TALENT);
477
478 if (!ShouldListAura(aura->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
479 continue;
480
481 std::ostringstream ss_name;
482 ss_name << "|cffffffff|Hspell:" << aura->GetId() << "|h[" << name << "]|h|r";
483
484 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str().c_str() : name),
485 aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(),
486 aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""),
487 (talent ? talentStr : ""), aura->GetCasterGUID().IsPlayer() ? "player" : "creature",
488 aura->GetCasterGUID().ToString().c_str());
489 }
490
491 for (uint16 i = 0; i < TOTAL_AURAS; ++i)
492 {
493 Unit::AuraEffectList const& auraList = unit->GetAuraEffectsByType(AuraType(i));
494 if (auraList.empty())
495 continue;
496
497 bool sizeLogged = false;
498
499 for (AuraEffect const* effect : auraList)
500 {
501 if (!ShouldListAura(effect->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
502 continue;
503
504 if (!sizeLogged)
505 {
506 sizeLogged = true;
507 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, auraList.size(), i);
508 }
509
510 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, effect->GetId(), effect->GetEffIndex(), effect->GetAmount());
511 }
512 }
513
514 return true;
515 }
516
517 static bool ShouldListAura(SpellInfo const* spellInfo, Optional<uint32> spellId, std::wstring namePart, uint8 locale)
518 {
519 if (spellId)
520 return spellInfo->Id == spellId;
521
522 if (!namePart.empty())
523 {
524 std::string name = spellInfo->SpellName[locale];
525 return Utf8FitTo(name, namePart);
526 }
527
528 return true;
529 }
530
531 // handle list mail command
533 {
534 if (!player)
535 player = PlayerIdentifier::FromTargetOrSelf(handler);
536 if (!player)
537 return false;
538
540 stmt->setUInt32(0, player->GetGUID().GetCounter());
541 PreparedQueryResult queryResult = CharacterDatabase.Query(stmt);
542 if (queryResult)
543 {
544 Field* fields = queryResult->Fetch();
545 uint32 countMail = fields[0].GetUInt64();
546
547 std::string nameLink = handler->playerLink(player->GetName());
548 handler->PSendSysMessage(LANG_LIST_MAIL_HEADER, countMail, nameLink.c_str(), player->GetGUID().ToString().c_str());
550
551 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_LIST_INFO);
552 stmt->setUInt32(0, player->GetGUID().GetCounter());
553 queryResult = CharacterDatabase.Query(stmt);
554
555 if (queryResult)
556 {
557 do
558 {
559 Field* queryFields = queryResult->Fetch();
560 uint32 messageId = queryFields[0].GetUInt32();
561 ObjectGuid::LowType senderId = queryFields[1].GetUInt32();
562 std::string sender = queryFields[2].GetString();
563 ObjectGuid::LowType receiverId = queryFields[3].GetUInt32();
564 std::string receiver = queryFields[4].GetString();
565 std::string subject = queryFields[5].GetString();
566 uint64 deliverTime = queryFields[6].GetUInt32();
567 uint64 expireTime = queryFields[7].GetUInt32();
568 uint32 money = queryFields[8].GetUInt32();
569 uint8 hasItem = queryFields[9].GetUInt8();
570 uint32 gold = money / GOLD;
571 uint32 silv = (money % GOLD) / SILVER;
572 uint32 copp = (money % GOLD) % SILVER;
573 std::string receiverStr = handler->playerLink(receiver);
574 std::string senderStr = handler->playerLink(sender);
575 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_1, messageId, subject.c_str(), gold, silv, copp);
576 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_2, senderStr.c_str(), senderId, receiverStr.c_str(), receiverId);
577 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_3, TimeToTimestampStr(deliverTime).c_str(), TimeToTimestampStr(expireTime).c_str());
578
579 if (hasItem == 1)
580 {
581 QueryResult result2;
582 result2 = CharacterDatabase.PQuery("SELECT item_guid FROM mail_items WHERE mail_id = '{}'", messageId);
583 if (result2)
584 {
585 do
586 {
587 ObjectGuid::LowType item_guid = (*result2)[0].GetUInt32();
588 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_LIST_ITEMS);
589 stmt->setUInt32(0, item_guid);
590 PreparedQueryResult result3 = CharacterDatabase.Query(stmt);
591 if (result3)
592 {
593 do
594 {
595 Field* fields3 = result3->Fetch();
596 uint32 item_entry = fields3[0].GetUInt32();
597 uint32 item_count = fields3[1].GetUInt32();
598 QueryResult result4;
599 result4 = WorldDatabase.PQuery("SELECT name, quality FROM item_template WHERE entry = '{}'", item_entry);
600 Field* fields1 = result4->Fetch();
601 std::string item_name = fields1[0].GetString();
602 int item_quality = fields1[1].GetUInt8();
603 if (handler->GetSession())
604 {
605 uint32 color = ItemQualityColors[item_quality];
606 std::ostringstream itemStr;
607 itemStr << "|c" << std::hex << color << "|Hitem:" << item_entry << ":0:0:0:0:0:0:0:0:0|h[" << item_name << "]|h|r";
608 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_ITEM, itemStr.str().c_str(), item_entry, item_guid, item_count);
609 }
610 else
611 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_ITEM, item_name.c_str(), item_entry, item_guid, item_count);
612 }
613 while (result3->NextRow());
614 }
615 }
616 while (result2->NextRow());
617 }
618 }
620 }
621 while (queryResult->NextRow());
622 }
623 else
625 return true;
626 }
627 else
629 return true;
630 }
631
633 {
634 Player const* player = handler->GetSession()->GetPlayer();
635 Map const* map = player->GetMap();
636 uint32 const mapId = map->GetId();
637 bool const showAll = map->IsBattlegroundOrArena() || map->IsDungeon();
638 handler->PSendSysMessage("Listing all spawn points in map %u (%s)%s:", mapId, map->GetMapName(), showAll ? "" : " within 5000yd");
639 for (auto const& pair : sObjectMgr->GetAllCreatureData())
640 {
641 SpawnData const& data = pair.second;
642 if (data.mapId != mapId)
643 continue;
644 CreatureTemplate const* cTemp = sObjectMgr->GetCreatureTemplate(data.id);
645 if (!cTemp)
646 continue;
647 if (showAll || data.spawnPoint.IsInDist2d(player, 5000.0))
648 handler->PSendSysMessage("Type: %u | SpawnId: %u | Entry: %u (%s) | X: %.3f | Y: %.3f | Z: %.3f", uint32(data.type), data.spawnId, data.id, cTemp->Name.c_str(), data.spawnPoint.GetPositionX(), data.spawnPoint.GetPositionY(), data.spawnPoint.GetPositionZ());
649 }
650 for (auto const& pair : sObjectMgr->GetAllGameObjectData())
651 {
652 SpawnData const& data = pair.second;
653 if (data.mapId != mapId)
654 continue;
655 GameObjectTemplate const* goTemp = sObjectMgr->GetGameObjectTemplate(data.id);
656 if (!goTemp)
657 continue;
658 if (showAll || data.spawnPoint.IsInDist2d(player, 5000.0))
659 handler->PSendSysMessage("Type: %u | SpawnId: %u | Entry: %u (%s) | X: %.3f | Y: %.3f | Z: %.3f", uint32(data.type), data.spawnId, data.id, goTemp->name.c_str(), data.spawnPoint.GetPositionX(), data.spawnPoint.GetPositionY(), data.spawnPoint.GetPositionZ());
660 }
661 return true;
662 }
663
664 static char const* GetZoneName(uint32 zoneId, LocaleConstant locale)
665 {
666 AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(zoneId);
667 return zoneEntry ? zoneEntry->AreaName[locale] : "<unknown zone>";
668 }
669
671 {
672 Player const* player = handler->GetSession()->GetPlayer();
673 Map const* map = player->GetMap();
674
675 LocaleConstant locale = handler->GetSession()->GetSessionDbcLocale();
676 char const* stringOverdue = sObjectMgr->GetTrinityString(LANG_LIST_RESPAWNS_OVERDUE, locale);
677
678 uint32 zoneId = player->GetZoneId();
679 char const* zoneName = GetZoneName(zoneId, locale);
680 for (SpawnObjectType type : EnumUtils::Iterate<SpawnObjectType>())
681 {
682 if (range)
684 else
685 handler->PSendSysMessage(LANG_LIST_RESPAWNS_ZONE, EnumUtils::ToTitle(type), zoneName, zoneId);
686
688 std::vector<RespawnInfo const*> respawns;
689 map->GetRespawnInfo(respawns, SpawnObjectTypeMask(1 << type));
690 for (RespawnInfo const* ri : respawns)
691 {
692 SpawnMetadata const* data = sObjectMgr->GetSpawnMetadata(ri->type, ri->spawnId);
693 if (!data)
694 continue;
695
696 uint32 respawnZoneId = 0;
697 if (SpawnData const* edata = data->ToSpawnData())
698 {
699 respawnZoneId = map->GetZoneId(edata->phaseMask, edata->spawnPoint);
700 if (range)
701 {
702 if (!player->IsInDist(edata->spawnPoint, *range))
703 continue;
704 }
705 else
706 {
707 if (zoneId != respawnZoneId)
708 continue;
709 }
710 }
711 uint32 gridY = ri->gridId / MAX_NUMBER_OF_GRIDS;
712 uint32 gridX = ri->gridId % MAX_NUMBER_OF_GRIDS;
713 std::string respawnTime = ri->respawnTime > GameTime::GetGameTime() ? secsToTimeString(uint64(ri->respawnTime - GameTime::GetGameTime()), TimeFormat::ShortText) : stringOverdue;
714 handler->PSendSysMessage("%u | %u | [%02u,%02u] | %s (%u) | %s%s", ri->spawnId, ri->entry, gridX, gridY, GetZoneName(respawnZoneId, locale), respawnZoneId, respawnTime.c_str(), map->IsSpawnGroupActive(data->spawnGroupData->groupId) ? "" : " (inactive)");
715 }
716 }
717 return true;
718 }
719};
720
@ CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY
@ CHAR_SEL_MAIL_LIST_COUNT
@ CHAR_SEL_MAIL_LIST_ITEMS
@ CHAR_SEL_MAIL_LIST_INFO
@ CHAR_SEL_MAIL_COUNT_ITEM
@ CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM
@ CHAR_SEL_GUILD_BANK_COUNT_ITEM
@ CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY
@ CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY
@ CHAR_SEL_CHAR_INVENTORY_COUNT_ITEM
@ CHAR_SEL_MAIL_ITEMS_BY_ENTRY
LocaleConstant
Definition Common.h:48
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
std::shared_ptr< ResultSet > QueryResult
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
uint8_t uint8
Definition Define.h:135
uint64_t uint64
Definition Define.h:132
uint16_t uint16
Definition Define.h:134
uint32_t uint32
Definition Define.h:133
#define MAX_NUMBER_OF_GRIDS
Definition GridDefines.h:36
@ LANG_ITEMLIST_GUILD
Definition Language.h:894
@ LANG_COMMAND_TARGET_LISTAURAS
Definition Language.h:530
@ LANG_LIST_RESPAWNS_RANGE
Definition Language.h:1144
@ LANG_LIST_MAIL_INFO_ITEM
Definition Language.h:931
@ LANG_LIST_MAIL_INFO_1
Definition Language.h:928
@ LANG_CREATURE_LIST_CONSOLE
Definition Language.h:886
@ LANG_ITEMLIST_MAIL
Definition Language.h:582
@ LANG_TALENT
Definition Language.h:66
@ LANG_COMMAND_NOITEMFOUND
Definition Language.h:499
@ LANG_ITEMLIST_AUCTION
Definition Language.h:583
@ LANG_LIST_RESPAWNS_ZONE
Definition Language.h:1145
@ LANG_LIST_RESPAWNS_OVERDUE
Definition Language.h:1147
@ LANG_GO_LIST_CHAT
Definition Language.h:591
@ LANG_LIST_MAIL_NOT_FOUND
Definition Language.h:932
@ LANG_COMMAND_LISTOBJMESSAGE
Definition Language.h:502
@ LANG_LIST_MAIL_HEADER
Definition Language.h:927
@ LANG_ACCOUNT_LIST_BAR
Definition Language.h:849
@ LANG_ITEMLIST_SLOT
Definition Language.h:581
@ LANG_COMMAND_TARGET_AURADETAIL
Definition Language.h:531
@ LANG_GO_LIST_CONSOLE
Definition Language.h:887
@ LANG_SELECT_CHAR_OR_CREATURE
Definition Language.h:31
@ LANG_COMMAND_INVALIDCREATUREID
Definition Language.h:503
@ LANG_COMMAND_LISTCREATUREMESSAGE
Definition Language.h:504
@ LANG_PASSIVE
Definition Language.h:65
@ LANG_CREATURE_LIST_CHAT
Definition Language.h:589
@ LANG_LIST_MAIL_INFO_2
Definition Language.h:929
@ LANG_COMMAND_TARGET_AURASIMPLE
Definition Language.h:533
@ LANG_LIST_RESPAWNS_LISTHEADER
Definition Language.h:1146
@ LANG_COMMAND_LISTITEMMESSAGE
Definition Language.h:501
@ LANG_COMMAND_TARGET_LISTAURATYPE
Definition Language.h:532
@ LANG_LIST_MAIL_INFO_3
Definition Language.h:930
@ LANG_COMMAND_LISTOBJINVALIDID
Definition Language.h:500
#define sMapMgr
Definition MapManager.h:211
#define sObjectMgr
Definition ObjectMgr.h:1721
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
Role Based Access Control related classes definition.
uint32 constexpr ItemQualityColors[MAX_ITEM_QUALITY]
@ SILVER
@ GOLD
SpawnObjectTypeMask
Definition SpawnData.h:38
SpawnObjectType
Definition SpawnData.h:30
@ TOTAL_AURAS
@ SPELL_ATTR0_CU_IS_TALENT
Definition SpellInfo.h:164
void wstrToLower(std::wstring &str)
Definition Util.cpp:480
std::string TimeToTimestampStr(time_t t)
Definition Util.cpp:290
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition Util.cpp:565
std::string secsToTimeString(uint64 timeInSecs, TimeFormat timeFormat, bool hoursOnly)
Definition Util.cpp:115
int32 GetMaxDuration() const
Definition SpellAuras.h:168
ObjectGuid GetCasterGUID() const
Definition SpellAuras.h:144
uint32 GetId() const
Definition SpellAuras.h:141
int32 GetDuration() const
Definition SpellAuras.h:173
uint8 GetStackAmount() const
Definition SpellAuras.h:189
uint8 GetCharges() const
Definition SpellAuras.h:180
SpellInfo const * GetSpellInfo() const
Definition SpellAuras.h:140
bool IsPassive() const
std::string playerLink(std::string const &name) const
Definition Chat.h:119
Unit * getSelectedUnit()
Definition Chat.cpp:206
WorldSession * GetSession()
Definition Chat.h:46
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:584
void SetSentErrorMessage(bool val)
Definition Chat.h:126
void PSendSysMessage(char const *fmt, Args &&... args)
Definition Chat.h:61
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:102
virtual char const * GetTrinityString(uint32 entry) const
Definition Chat.cpp:37
static char const * ToTitle(Enum value)
Definition SmartEnum.h:123
Class used to access individual fields of database query result.
Definition Field.h:92
uint8 GetUInt8() const
Definition Field.cpp:29
std::string GetString() const
Definition Field.cpp:125
uint64 GetUInt64() const
Definition Field.cpp:77
uint16 GetUInt16() const
Definition Field.cpp:45
float GetFloat() const
Definition Field.cpp:93
uint32 GetUInt32() const
Definition Field.cpp:61
Definition Map.h:302
bool IsDungeon() const
Definition Map.cpp:4231
bool IsBattlegroundOrArena() const
Definition Map.cpp:4272
uint32 GetZoneId(uint32 phaseMask, float x, float y, float z) const
Definition Map.cpp:2617
bool IsSpawnGroupActive(uint32 groupId) const
Definition Map.cpp:3495
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:516
uint32 GetId() const
Definition Map.cpp:4216
char const * GetMapName() const
Definition Map.cpp:2924
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition Map.h:512
RespawnInfo * GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const
Definition Map.cpp:3185
bool IsPlayer() const
Definition ObjectGuid.h:179
std::string ToString() const
uint32 LowType
Definition ObjectGuid.h:142
static bool IsEquipmentPos(uint16 pos)
Definition Player.h:1095
static bool IsInventoryPos(uint16 pos)
Definition Player.h:1093
static bool IsBankPos(uint16 pos)
Definition Player.h:1098
void setUInt32(uint8 index, uint32 value)
uint32 Id
Definition SpellInfo.h:289
bool HasAttribute(SpellAttr0 attribute) const
Definition SpellInfo.h:375
std::array< char const *, 16 > SpellName
Definition SpellInfo.h:352
Definition Unit.h:783
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition Unit.h:1397
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:794
AuraApplicationMap & GetAppliedAuras()
Definition Unit.h:1351
std::list< AuraEffect * > AuraEffectList
Definition Unit.h:801
Map * GetMap() const
Definition Object.h:451
uint32 GetZoneId() const
Definition Object.h:375
LocaleConstant GetSessionDbcLocale() const
Player * GetPlayer() const
static bool HandleListMailCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_list.cpp:532
static bool HandleListAurasByIdCommand(ChatHandler *handler, uint32 spellId)
Definition cs_list.cpp:445
static bool HandleListCreatureCommand(ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > creatureId, Optional< uint32 > countArg)
Definition cs_list.cpp:76
static char const * GetZoneName(uint32 zoneId, LocaleConstant locale)
Definition cs_list.cpp:664
static bool HandleListItemCommand(ChatHandler *handler, Hyperlink< item > item, Optional< uint32 > countArg)
Definition cs_list.cpp:161
static bool HandleListRespawnsCommand(ChatHandler *handler, Optional< uint32 > range)
Definition cs_list.cpp:670
static bool HandleListAurasByNameCommand(ChatHandler *handler, WTail namePart)
Definition cs_list.cpp:450
static bool HandleListAllAurasCommand(ChatHandler *handler)
Definition cs_list.cpp:440
ChatCommandTable GetCommands() const override
Definition cs_list.cpp:50
static bool ListAurasCommand(ChatHandler *handler, Optional< uint32 > spellId, std::wstring namePart)
Definition cs_list.cpp:455
static bool HandleListSpawnPointsCommand(ChatHandler *handler)
Definition cs_list.cpp:632
static bool HandleListObjectCommand(ChatHandler *handler, Variant< Hyperlink< gameobject_entry >, uint32 > gameObjectId, Optional< uint32 > countArg)
Definition cs_list.cpp:354
static bool ShouldListAura(SpellInfo const *spellInfo, Optional< uint32 > spellId, std::wstring namePart, uint8 locale)
Definition cs_list.cpp:517
void AddSC_list_commandscript()
Definition cs_list.cpp:721
time_t GetGameTime()
Definition GameTime.cpp:42
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:50
@ RBAC_PERM_COMMAND_LIST_SPAWNPOINTS
Definition RBAC.h:735
@ RBAC_PERM_COMMAND_LIST_MAIL
Definition RBAC.h:311
@ RBAC_PERM_COMMAND_LIST_ITEM
Definition RBAC.h:308
@ RBAC_PERM_COMMAND_LIST_CREATURE
Definition RBAC.h:307
@ RBAC_PERM_COMMAND_LIST_OBJECT
Definition RBAC.h:309
@ RBAC_PERM_COMMAND_LIST_AURAS
Definition RBAC.h:310
@ RBAC_PERM_COMMAND_LIST_RESPAWNS
Definition RBAC.h:729
char const * AreaName[16]
std::string Name
float GetPositionZ() const
Definition Position.h:81
bool IsInDist2d(float x, float y, float dist) const
Definition Position.h:145
bool IsInDist(float x, float y, float z, float dist) const
Definition Position.h:148
float GetPositionX() const
Definition Position.h:79
float GetPositionY() const
Definition Position.h:80
uint32 id
Definition SpawnData.h:96
Position spawnPoint
Definition SpawnData.h:97
SpawnObjectType const type
Definition SpawnData.h:84
uint32 spawnId
Definition SpawnData.h:85
SpawnGroupTemplateData const * spawnGroupData
Definition SpawnData.h:88
SpawnData const * ToSpawnData() const
Definition SpawnData.h:82
uint32 mapId
Definition SpawnData.h:86
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)