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->ItemId;
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 bool talent = GetTalentSpellCost(aurApp->GetBase()->GetId()) > 0;
475
476 Aura const* aura = aurApp->GetBase();
477 char const* name = aura->GetSpellInfo()->SpellName[handler->GetSessionDbcLocale()];
478
479 if (!ShouldListAura(aura->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
480 continue;
481
482 std::ostringstream ss_name;
483 ss_name << "|cffffffff|Hspell:" << aura->GetId() << "|h[" << name << "]|h|r";
484
485 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str().c_str() : name),
486 aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(),
487 aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""),
488 (talent ? talentStr : ""), aura->GetCasterGUID().IsPlayer() ? "player" : "creature",
489 aura->GetCasterGUID().ToString().c_str());
490 }
491
492 for (uint16 i = 0; i < TOTAL_AURAS; ++i)
493 {
494 Unit::AuraEffectList const& auraList = unit->GetAuraEffectsByType(AuraType(i));
495 if (auraList.empty())
496 continue;
497
498 bool sizeLogged = false;
499
500 for (AuraEffect const* effect : auraList)
501 {
502 if (!ShouldListAura(effect->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
503 continue;
504
505 if (!sizeLogged)
506 {
507 sizeLogged = true;
508 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, auraList.size(), i);
509 }
510
511 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, effect->GetId(), effect->GetEffIndex(), effect->GetAmount());
512 }
513 }
514
515 return true;
516 }
517
518 static bool ShouldListAura(SpellInfo const* spellInfo, Optional<uint32> spellId, std::wstring namePart, uint8 locale)
519 {
520 if (spellId)
521 return spellInfo->Id == spellId;
522
523 if (!namePart.empty())
524 {
525 std::string name = spellInfo->SpellName[locale];
526 return Utf8FitTo(name, namePart);
527 }
528
529 return true;
530 }
531
532 // handle list mail command
534 {
535 if (!player)
536 player = PlayerIdentifier::FromTargetOrSelf(handler);
537 if (!player)
538 return false;
539
541 stmt->setUInt32(0, player->GetGUID().GetCounter());
542 PreparedQueryResult queryResult = CharacterDatabase.Query(stmt);
543 if (queryResult)
544 {
545 Field* fields = queryResult->Fetch();
546 uint32 countMail = fields[0].GetUInt64();
547
548 std::string nameLink = handler->playerLink(player->GetName());
549 handler->PSendSysMessage(LANG_LIST_MAIL_HEADER, countMail, nameLink.c_str(), player->GetGUID().ToString().c_str());
551
552 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_LIST_INFO);
553 stmt->setUInt32(0, player->GetGUID().GetCounter());
554 queryResult = CharacterDatabase.Query(stmt);
555
556 if (queryResult)
557 {
558 do
559 {
560 Field* queryFields = queryResult->Fetch();
561 uint32 messageId = queryFields[0].GetUInt32();
562 ObjectGuid::LowType senderId = queryFields[1].GetUInt32();
563 std::string sender = queryFields[2].GetString();
564 ObjectGuid::LowType receiverId = queryFields[3].GetUInt32();
565 std::string receiver = queryFields[4].GetString();
566 std::string subject = queryFields[5].GetString();
567 uint64 deliverTime = queryFields[6].GetUInt32();
568 uint64 expireTime = queryFields[7].GetUInt32();
569 uint32 money = queryFields[8].GetUInt32();
570 uint8 hasItem = queryFields[9].GetUInt8();
571 uint32 gold = money / GOLD;
572 uint32 silv = (money % GOLD) / SILVER;
573 uint32 copp = (money % GOLD) % SILVER;
574 std::string receiverStr = handler->playerLink(receiver);
575 std::string senderStr = handler->playerLink(sender);
576 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_1, messageId, subject.c_str(), gold, silv, copp);
577 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_2, senderStr.c_str(), senderId, receiverStr.c_str(), receiverId);
578 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_3, TimeToTimestampStr(deliverTime).c_str(), TimeToTimestampStr(expireTime).c_str());
579
580 if (hasItem == 1)
581 {
582 QueryResult result2;
583 result2 = CharacterDatabase.PQuery("SELECT item_guid FROM mail_items WHERE mail_id = '{}'", messageId);
584 if (result2)
585 {
586 do
587 {
588 ObjectGuid::LowType item_guid = (*result2)[0].GetUInt32();
589 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_LIST_ITEMS);
590 stmt->setUInt32(0, item_guid);
591 PreparedQueryResult result3 = CharacterDatabase.Query(stmt);
592 if (result3)
593 {
594 do
595 {
596 Field* fields3 = result3->Fetch();
597 uint32 item_entry = fields3[0].GetUInt32();
598 uint32 item_count = fields3[1].GetUInt32();
599 QueryResult result4;
600 result4 = WorldDatabase.PQuery("SELECT name, quality FROM item_template WHERE entry = '{}'", item_entry);
601 Field* fields1 = result4->Fetch();
602 std::string item_name = fields1[0].GetString();
603 int item_quality = fields1[1].GetUInt8();
604 if (handler->GetSession())
605 {
606 uint32 color = ItemQualityColors[item_quality];
607 std::ostringstream itemStr;
608 itemStr << "|c" << std::hex << color << "|Hitem:" << item_entry << ":0:0:0:0:0:0:0:0:0|h[" << item_name << "]|h|r";
609 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_ITEM, itemStr.str().c_str(), item_entry, item_guid, item_count);
610 }
611 else
612 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_ITEM, item_name.c_str(), item_entry, item_guid, item_count);
613 }
614 while (result3->NextRow());
615 }
616 }
617 while (result2->NextRow());
618 }
619 }
621 }
622 while (queryResult->NextRow());
623 }
624 else
626 return true;
627 }
628 else
630 return true;
631 }
632
634 {
635 Player const* player = handler->GetSession()->GetPlayer();
636 Map const* map = player->GetMap();
637 uint32 const mapId = map->GetId();
638 bool const showAll = map->IsBattlegroundOrArena() || map->IsDungeon();
639 handler->PSendSysMessage("Listing all spawn points in map %u (%s)%s:", mapId, map->GetMapName(), showAll ? "" : " within 5000yd");
640 for (auto const& pair : sObjectMgr->GetAllCreatureData())
641 {
642 SpawnData const& data = pair.second;
643 if (data.mapId != mapId)
644 continue;
645 CreatureTemplate const* cTemp = sObjectMgr->GetCreatureTemplate(data.id);
646 if (!cTemp)
647 continue;
648 if (showAll || data.spawnPoint.IsInDist2d(player, 5000.0))
649 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());
650 }
651 for (auto const& pair : sObjectMgr->GetAllGameObjectData())
652 {
653 SpawnData const& data = pair.second;
654 if (data.mapId != mapId)
655 continue;
656 GameObjectTemplate const* goTemp = sObjectMgr->GetGameObjectTemplate(data.id);
657 if (!goTemp)
658 continue;
659 if (showAll || data.spawnPoint.IsInDist2d(player, 5000.0))
660 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());
661 }
662 return true;
663 }
664
665 static char const* GetZoneName(uint32 zoneId, LocaleConstant locale)
666 {
667 AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(zoneId);
668 return zoneEntry ? zoneEntry->AreaName[locale] : "<unknown zone>";
669 }
670
672 {
673 Player const* player = handler->GetSession()->GetPlayer();
674 Map const* map = player->GetMap();
675
676 LocaleConstant locale = handler->GetSession()->GetSessionDbcLocale();
677 char const* stringOverdue = sObjectMgr->GetTrinityString(LANG_LIST_RESPAWNS_OVERDUE, locale);
678
679 uint32 zoneId = player->GetZoneId();
680 char const* zoneName = GetZoneName(zoneId, locale);
681 for (SpawnObjectType type : EnumUtils::Iterate<SpawnObjectType>())
682 {
683 if (range)
685 else
686 handler->PSendSysMessage(LANG_LIST_RESPAWNS_ZONE, EnumUtils::ToTitle(type), zoneName, zoneId);
687
689 std::vector<RespawnInfo const*> respawns;
690 map->GetRespawnInfo(respawns, SpawnObjectTypeMask(1 << type));
691 for (RespawnInfo const* ri : respawns)
692 {
693 SpawnMetadata const* data = sObjectMgr->GetSpawnMetadata(ri->type, ri->spawnId);
694 if (!data)
695 continue;
696
697 uint32 respawnZoneId = 0;
698 if (SpawnData const* edata = data->ToSpawnData())
699 {
700 respawnZoneId = map->GetZoneId(edata->phaseMask, edata->spawnPoint);
701 if (range)
702 {
703 if (!player->IsInDist(edata->spawnPoint, *range))
704 continue;
705 }
706 else
707 {
708 if (zoneId != respawnZoneId)
709 continue;
710 }
711 }
712 uint32 gridY = ri->gridId / MAX_NUMBER_OF_GRIDS;
713 uint32 gridX = ri->gridId % MAX_NUMBER_OF_GRIDS;
714 std::string respawnTime = ri->respawnTime > GameTime::GetGameTime() ? secsToTimeString(uint64(ri->respawnTime - GameTime::GetGameTime()), TimeFormat::ShortText) : stringOverdue;
715 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)");
716 }
717 }
718 return true;
719 }
720};
721
@ 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
uint32 GetTalentSpellCost(uint32 spellId)
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
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:143
ObjectGuid GetCasterGUID() const
Definition SpellAuras.h:119
uint32 GetId() const
Definition SpellAuras.h:116
int32 GetDuration() const
Definition SpellAuras.h:148
uint8 GetStackAmount() const
Definition SpellAuras.h:164
uint8 GetCharges() const
Definition SpellAuras.h:155
SpellInfo const * GetSpellInfo() const
Definition SpellAuras.h:115
bool IsPassive() const
std::string playerLink(std::string const &name) const
Definition Chat.h:127
Unit * getSelectedUnit()
Definition Chat.cpp:314
WorldSession * GetSession()
Definition Chat.h:46
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:692
void SetSentErrorMessage(bool val)
Definition Chat.h:134
void PSendSysMessage(char const *fmt, Args &&... args)
Definition Chat.h:69
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:101
virtual char const * GetTrinityString(uint32 entry) const
Definition Chat.cpp:36
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:281
bool IsDungeon() const
Definition Map.cpp:4236
bool IsBattlegroundOrArena() const
Definition Map.cpp:4277
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:496
uint32 GetId() const
Definition Map.cpp:4216
char const * GetMapName() const
Definition Map.cpp:2924
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition Map.h:492
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:1117
static bool IsInventoryPos(uint16 pos)
Definition Player.h:1115
static bool IsBankPos(uint16 pos)
Definition Player.h:1120
void setUInt32(uint8 index, uint32 value)
uint32 Id
Definition SpellInfo.h:289
std::array< char const *, 16 > SpellName
Definition SpellInfo.h:352
Definition Unit.h:769
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition Unit.h:1384
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:780
AuraApplicationMap & GetAppliedAuras()
Definition Unit.h:1338
std::list< AuraEffect * > AuraEffectList
Definition Unit.h:787
Map * GetMap() const
Definition Object.h:449
uint32 GetZoneId() const
Definition Object.h:373
LocaleConstant GetSessionDbcLocale() const
Player * GetPlayer() const
static bool HandleListMailCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_list.cpp:533
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:665
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:671
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:633
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:518
void AddSC_list_commandscript()
Definition cs_list.cpp:722
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)