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 "ChatCommand.h"
29#include "Creature.h"
30#include "DatabaseEnv.h"
31#include "DB2Stores.h"
32#include "GameObject.h"
33#include "GameTime.h"
34#include "Language.h"
35#include "Map.h"
36#include "ObjectMgr.h"
37#include "PhasingHandler.h"
38#include "Player.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
50 std::span<ChatCommandBuilder const> GetCommands() const override
51 {
52 static ChatCommandTable listAurasCommandTable =
53 {
57 };
58
59 static ChatCommandTable listCommandTable =
60 {
64 { "auras", listAurasCommandTable },
69 };
70 static ChatCommandTable commandTable =
71 {
72 { "list", listCommandTable },
73 };
74 return commandTable;
75 }
76
78 {
79 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creatureId);
80 if (!cInfo)
81 {
83 handler->SetSentErrorMessage(true);
84 return false;
85 }
86
87 uint32 count = countArg.value_or(10);
88
89 if (count == 0)
90 return false;
91
92 QueryResult result;
93
94 uint32 creatureCount = 0;
95 result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='{}'", *creatureId);
96 if (result)
97 creatureCount = (*result)[0].GetUInt64();
98
99 if (handler->GetSession())
100 {
101 Player* player = handler->GetSession()->GetPlayer();
102 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 {}",
103 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), *creatureId, count);
104 }
105 else
106 result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '{}' LIMIT {}",
107 *creatureId, count);
108
109 if (result)
110 {
111 do
112 {
113 Field* fields = result->Fetch();
114 ObjectGuid::LowType guid = fields[0].GetUInt64();
115 float x = fields[1].GetFloat();
116 float y = fields[2].GetFloat();
117 float z = fields[3].GetFloat();
118 uint16 mapId = fields[4].GetUInt16();
119 bool liveFound = false;
120
121 // Get map (only support base map from console)
122 Map* thisMap = nullptr;
123 if (handler->GetSession())
124 thisMap = handler->GetSession()->GetPlayer()->GetMap();
125
126 // If map found, try to find active version of this creature
127 if (thisMap)
128 {
129 auto const creBounds = Trinity::Containers::MapEqualRange(thisMap->GetCreatureBySpawnIdStore(), guid);
130 for (auto& [spawnId, creature] : creBounds)
131 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, std::to_string(guid).c_str(), std::to_string(guid).c_str(), cInfo->Name.c_str(),
132 x, y, z, mapId, creature->GetGUID().ToString().c_str(), creature->IsAlive() ? "*" : " ");
133 liveFound = creBounds.begin() != creBounds.end();
134 }
135
136 if (!liveFound)
137 {
138 if (handler->GetSession())
139 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, std::to_string(guid).c_str(), std::to_string(guid).c_str(), cInfo->Name.c_str(), x, y, z, mapId, "", "");
140 else
141 handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, std::to_string(guid).c_str(), cInfo->Name.c_str(), x, y, z, mapId, "", "");
142 }
143 }
144 while (result->NextRow());
145 }
146
147 handler->PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE, *creatureId, creatureCount);
148
149 return true;
150 }
151
152 static bool HandleListItemCommand(ChatHandler* handler, Hyperlink<item> const& item, Optional<uint32> countArg)
153 {
154 uint32 itemId = item->Item->GetId();
155 uint32 count = countArg.value_or(10);
156
157 if (count == 0)
158 return false;
159
160 PreparedQueryResult result;
161
162 // inventory case
163 uint32 inventoryCount = 0;
164
166 stmt->setUInt32(0, itemId);
167 result = CharacterDatabase.Query(stmt);
168
169 if (result)
170 inventoryCount = (*result)[0].GetUInt64();
171
172 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY);
173 stmt->setUInt32(0, itemId);
174 stmt->setUInt32(1, count);
175 result = CharacterDatabase.Query(stmt);
176
177 if (result)
178 {
179 do
180 {
181 Field* fields = result->Fetch();
182 ObjectGuid itemGuid = ObjectGuid::Create<HighGuid::Item>(fields[0].GetUInt64());
183 uint32 itemBag = fields[1].GetUInt32();
184 uint8 itemSlot = fields[2].GetUInt8();
185 ObjectGuid ownerGuid = ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt64());
186 uint32 ownerAccountId = fields[4].GetUInt32();
187 std::string ownerName = fields[5].GetString();
188
189 char const* itemPos = nullptr;
190 if (Player::IsEquipmentPos(itemBag, itemSlot))
191 itemPos = "[equipped]";
192 else if (Player::IsInventoryPos(itemBag, itemSlot))
193 itemPos = "[in inventory]";
194 else if (Player::IsBankPos(itemBag, itemSlot))
195 itemPos = "[in bank]";
196 else
197 itemPos = "";
198
199 handler->PSendSysMessage(LANG_ITEMLIST_SLOT, itemGuid.ToString().c_str(), ownerName.c_str(), ownerGuid.ToString().c_str(), ownerAccountId, itemPos);
200 }
201 while (result->NextRow());
202
203 uint32 resultCount = uint32(result->GetRowCount());
204
205 if (count > resultCount)
206 count -= resultCount;
207 else
208 count = 0;
209 }
210
211 // mail case
212 uint32 mailCount = 0;
213
214 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_COUNT_ITEM);
215 stmt->setUInt32(0, itemId);
216 result = CharacterDatabase.Query(stmt);
217
218 if (result)
219 mailCount = (*result)[0].GetUInt64();
220
221 if (count > 0)
222 {
223 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY);
224 stmt->setUInt32(0, itemId);
225 stmt->setUInt32(1, count);
226 result = CharacterDatabase.Query(stmt);
227 }
228 else
229 result = PreparedQueryResult(nullptr);
230
231 if (result)
232 {
233 do
234 {
235 Field* fields = result->Fetch();
236 ObjectGuid::LowType itemGuid = fields[0].GetUInt64();
237 ObjectGuid::LowType itemSender = fields[1].GetUInt64();
238 ObjectGuid::LowType itemReceiver = fields[2].GetUInt64();
239 uint32 itemSenderAccountId = fields[3].GetUInt32();
240 std::string itemSenderName = fields[4].GetString();
241 uint32 itemReceiverAccount = fields[5].GetUInt32();
242 std::string itemReceiverName = fields[6].GetString();
243
244 char const* itemPos = "[in mail]";
245
246 handler->PSendSysMessage(LANG_ITEMLIST_MAIL, std::to_string(itemGuid).c_str(), itemSenderName.c_str(), std::to_string(itemSender).c_str(), itemSenderAccountId, itemReceiverName.c_str(), std::to_string(itemReceiver).c_str(), itemReceiverAccount, itemPos);
247 }
248 while (result->NextRow());
249
250 uint32 resultCount = uint32(result->GetRowCount());
251
252 if (count > resultCount)
253 count -= resultCount;
254 else
255 count = 0;
256 }
257
258 // auction case
259 uint32 auctionCount = 0;
260
261 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM);
262 stmt->setUInt32(0, itemId);
263 result = CharacterDatabase.Query(stmt);
264
265 if (result)
266 auctionCount = (*result)[0].GetUInt64();
267
268 if (count > 0)
269 {
270 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY);
271 stmt->setUInt32(0, itemId);
272 stmt->setUInt32(1, count);
273 result = CharacterDatabase.Query(stmt);
274 }
275 else
276 result = PreparedQueryResult(nullptr);
277
278 if (result)
279 {
280 do
281 {
282 Field* fields = result->Fetch();
283 ObjectGuid itemGuid = ObjectGuid::Create<HighGuid::Item>(fields[0].GetUInt64());
284 ObjectGuid owner = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt64());
285 uint32 ownerAccountId = fields[2].GetUInt32();
286 std::string ownerName = fields[3].GetString();
287
288 char const* itemPos = "[in auction]";
289
290 handler->PSendSysMessage(LANG_ITEMLIST_AUCTION, itemGuid.ToString().c_str(), ownerName.c_str(), owner.ToString().c_str(), ownerAccountId, itemPos);
291 }
292 while (result->NextRow());
293 }
294
295 // guild bank case
296 uint32 guildCount = 0;
297
298 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_COUNT_ITEM);
299 stmt->setUInt32(0, itemId);
300 result = CharacterDatabase.Query(stmt);
301
302 if (result)
303 guildCount = (*result)[0].GetUInt64();
304
305 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY);
306 stmt->setUInt32(0, itemId);
307 stmt->setUInt32(1, count);
308 result = CharacterDatabase.Query(stmt);
309
310 if (result)
311 {
312 do
313 {
314 Field* fields = result->Fetch();
315 ObjectGuid itemGuid = ObjectGuid::Create<HighGuid::Item>(fields[0].GetUInt64());
316 ObjectGuid guildGuid = ObjectGuid::Create<HighGuid::Guild>(fields[1].GetUInt64());
317 std::string guildName = fields[2].GetString();
318
319 char const* itemPos = "[in guild bank]";
320
321 handler->PSendSysMessage(LANG_ITEMLIST_GUILD, itemGuid.ToString().c_str(), guildName.c_str(), guildGuid.ToString().c_str(), itemPos);
322 }
323 while (result->NextRow());
324
325 uint32 resultCount = uint32(result->GetRowCount());
326
327 if (count > resultCount)
328 count -= resultCount;
329 else
330 count = 0;
331 }
332
333 if (inventoryCount + mailCount + auctionCount + guildCount == 0)
334 {
336 handler->SetSentErrorMessage(true);
337 return false;
338 }
339
340 handler->PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE, itemId, inventoryCount + mailCount + auctionCount + guildCount, inventoryCount, mailCount, auctionCount, guildCount);
341
342 return true;
343 }
344
346 {
347 GameObjectTemplate const* gInfo = sObjectMgr->GetGameObjectTemplate(gameObjectId);
348 if (!gInfo)
349 {
350 handler->PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, *gameObjectId);
351 handler->SetSentErrorMessage(true);
352 return false;
353 }
354
355 uint32 count = countArg.value_or(10);
356
357 if (count == 0)
358 return false;
359
360 QueryResult result;
361
362 uint32 objectCount = 0;
363 result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='{}'", *gameObjectId);
364 if (result)
365 objectCount = (*result)[0].GetUInt64();
366
367 if (handler->GetSession())
368 {
369 Player* player = handler->GetSession()->GetPlayer();
370 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 {}",
371 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), *gameObjectId, count);
372 }
373 else
374 result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '{}' LIMIT {}",
375 *gameObjectId, count);
376
377 if (result)
378 {
379 do
380 {
381 Field* fields = result->Fetch();
382 ObjectGuid::LowType guid = fields[0].GetUInt64();
383 float x = fields[1].GetFloat();
384 float y = fields[2].GetFloat();
385 float z = fields[3].GetFloat();
386 uint16 mapId = fields[4].GetUInt16();
387 uint32 entry = fields[5].GetUInt32();
388 bool liveFound = false;
389
390 // Get map (only support base map from console)
391 Map* thisMap = nullptr;
392 if (handler->GetSession())
393 thisMap = handler->GetSession()->GetPlayer()->GetMap();
394
395 // If map found, try to find active version of this object
396 if (thisMap)
397 {
398 auto const goBounds = Trinity::Containers::MapEqualRange(thisMap->GetGameObjectBySpawnIdStore(), guid);
399 for (auto& [spawnId, go] : goBounds)
400 handler->PSendSysMessage(LANG_GO_LIST_CHAT, std::to_string(guid).c_str(), entry, std::to_string(guid).c_str(), gInfo->name.c_str(), x, y, z, mapId,
401 go->GetGUID().ToString().c_str(), go->isSpawned() ? "*" : " ");
402 liveFound = goBounds.begin() != goBounds.end();
403 }
404
405 if (!liveFound)
406 {
407 if (handler->GetSession())
408 handler->PSendSysMessage(LANG_GO_LIST_CHAT, std::to_string(guid).c_str(), entry, std::to_string(guid).c_str(), gInfo->name.c_str(), x, y, z, mapId, "", "");
409 else
410 handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, std::to_string(guid).c_str(), gInfo->name.c_str(), x, y, z, mapId, "", "");
411 }
412 }
413 while (result->NextRow());
414 }
415
416 handler->PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE, *gameObjectId, objectCount);
417
418 return true;
419 }
420
422 {
423 return ListAurasCommand(handler, {}, {});
424 }
425
426 static bool HandleListAurasByIdCommand(ChatHandler* handler, uint32 spellId)
427 {
428 return ListAurasCommand(handler, spellId, {});
429 }
430
431 static bool HandleListAurasByNameCommand(ChatHandler* handler, WTail namePart)
432 {
433 return ListAurasCommand(handler, {}, namePart);
434 }
435
436 static bool ListAurasCommand(ChatHandler* handler, Optional<uint32> spellId, std::wstring namePart)
437 {
438 Unit* unit = handler->getSelectedUnit();
439 if (!unit)
440 {
442 handler->SetSentErrorMessage(true);
443 return false;
444 }
445
446 wstrToLower(namePart);
447
448 char const* talentStr = handler->GetTrinityString(LANG_TALENT);
449 char const* passiveStr = handler->GetTrinityString(LANG_PASSIVE);
450
451 Unit::AuraApplicationMap const& auras = unit->GetAppliedAuras();
452 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, std::to_string(auras.size()).c_str());
453 for (auto const& [aurId, aurApp] : auras)
454 {
455
456 Aura const* aura = aurApp->GetBase();
457 char const* name = aura->GetSpellInfo()->SpellName->Str[handler->GetSessionDbcLocale()];
458 bool talent = aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_IS_TALENT);
459
460 if (!ShouldListAura(aura->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
461 continue;
462
463 std::string ss_name = Trinity::StringFormat("|cffffffff|Hspell:{}|h[{}]|h|r", aura->GetId(), name);
464
465 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.c_str() : name),
466 aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(),
467 aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""),
468 (talent ? talentStr : ""), aura->GetCasterGUID().IsPlayer() ? "player" : "creature",
469 aura->GetCasterGUID().ToString().c_str());
470 }
471
472 for (uint16 i = 0; i < TOTAL_AURAS; ++i)
473 {
474 Unit::AuraEffectList const& auraList = unit->GetAuraEffectsByType(AuraType(i));
475 if (auraList.empty())
476 continue;
477
478 bool sizeLogged = false;
479
480 for (AuraEffect const* effect : auraList)
481 {
482 if (!ShouldListAura(effect->GetSpellInfo(), spellId, namePart, handler->GetSessionDbcLocale()))
483 continue;
484
485 if (!sizeLogged)
486 {
487 sizeLogged = true;
488 handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, std::to_string(std::distance(auraList.begin(), auraList.end())).c_str(), i);
489 }
490
491 handler->PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, effect->GetId(), effect->GetEffIndex(), effect->GetAmount());
492 }
493 }
494
495 return true;
496 }
497
498 static bool ShouldListAura(SpellInfo const* spellInfo, Optional<uint32> spellId, std::wstring namePart, LocaleConstant locale)
499 {
500 if (spellId)
501 return spellInfo->Id == spellId;
502
503 if (!namePart.empty())
504 {
505 std::string name = (*spellInfo->SpellName)[locale];
506 return Utf8FitTo(name, namePart);
507 }
508
509 return true;
510 }
511
512 // handle list mail command
514 {
515 if (!player)
516 player = PlayerIdentifier::FromTargetOrSelf(handler);
517 if (!player)
518 return false;
519
521 stmt->setUInt64(0, player->GetGUID().GetCounter());
522 PreparedQueryResult queryResult = CharacterDatabase.Query(stmt);
523 if (queryResult)
524 {
525 Field* fields = queryResult->Fetch();
526 uint32 countMail = fields[0].GetUInt64();
527
528 std::string nameLink = handler->playerLink(player->GetName());
529 handler->PSendSysMessage(LANG_LIST_MAIL_HEADER, countMail, nameLink.c_str(), player->GetGUID().ToString().c_str());
531
532 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_LIST_INFO);
533 stmt->setUInt64(0, player->GetGUID().GetCounter());
534 queryResult = CharacterDatabase.Query(stmt);
535
536 if (queryResult)
537 {
538 do
539 {
540 Field* queryFields = queryResult->Fetch();
541 uint32 messageId = queryFields[0].GetUInt32();
542 ObjectGuid::LowType senderId = queryFields[1].GetUInt64();
543 std::string sender = queryFields[2].GetString();
544 ObjectGuid::LowType receiverId = queryFields[3].GetUInt64();
545 std::string receiver = queryFields[4].GetString();
546 std::string subject = queryFields[5].GetString();
547 time_t deliverTime = queryFields[6].GetInt64();
548 time_t expireTime = queryFields[7].GetInt64();
549 uint64 money = queryFields[8].GetUInt64();
550 uint8 hasItem = queryFields[9].GetUInt8();
551 uint32 gold = money / GOLD;
552 uint32 silv = (money % GOLD) / SILVER;
553 uint32 copp = (money % GOLD) % SILVER;
554 std::string receiverStr = handler->playerLink(receiver);
555 std::string senderStr = handler->playerLink(sender);
556 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_1, messageId, subject.c_str(), gold, silv, copp);
557 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_2, senderStr.c_str(), std::to_string(senderId).c_str(), receiverStr.c_str(), std::to_string(receiverId).c_str());
558 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_3, TimeToTimestampStr(deliverTime).c_str(), TimeToTimestampStr(expireTime).c_str());
559
560 if (hasItem == 1)
561 {
562 QueryResult result2;
563 result2 = CharacterDatabase.PQuery("SELECT item_guid FROM mail_items WHERE mail_id = '{}'", messageId);
564 if (result2)
565 {
566 do
567 {
568 uint32 item_guid = (*result2)[0].GetUInt32();
569 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_LIST_ITEMS);
570 stmt->setUInt64(0, item_guid);
571 PreparedQueryResult result3 = CharacterDatabase.Query(stmt);
572 if (result3)
573 {
574 do
575 {
576 Field* fields3 = result3->Fetch();
577 uint32 item_entry = fields3[0].GetUInt32();
578 uint32 item_count = fields3[1].GetUInt32();
579 ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(item_entry);
580 if (!itemTemplate)
581 continue;
582
583 if (handler->GetSession())
584 {
585 uint32 color = ItemQualityColors[itemTemplate->GetQuality()];
586 std::string itemStr = Trinity::StringFormat("|c{:X}|Hitem:{}:0:0:0:0:0:0:0:{}:0:0:0:0:0|h[{}]|h|r",
587 color, item_entry, handler->GetSession()->GetPlayer()->GetLevel(), itemTemplate->GetName(handler->GetSessionDbcLocale()));
588 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_ITEM, itemStr.c_str(), item_entry, item_guid, item_count);
589 }
590 else
591 handler->PSendSysMessage(LANG_LIST_MAIL_INFO_ITEM, itemTemplate->GetName(handler->GetSessionDbcLocale()), item_entry, item_guid, item_count);
592 }
593 while (result3->NextRow());
594 }
595 }
596 while (result2->NextRow());
597 }
598 }
600 }
601 while (queryResult->NextRow());
602 }
603 else
605 return true;
606 }
607 else
609 return true;
610 }
611
613 {
614 Player const* player = handler->GetSession()->GetPlayer();
615 Map const* map = player->GetMap();
616 uint32 const mapId = map->GetId();
617 bool const showAll = map->IsBattlegroundOrArena() || map->IsDungeon();
618 handler->PSendSysMessage("Listing all spawn points in map %u (%s)%s:", mapId, map->GetMapName(), showAll ? "" : " within 5000yd");
619 for (auto const& pair : sObjectMgr->GetAllCreatureData())
620 {
621 SpawnData const& data = pair.second;
622 if (data.mapId != mapId)
623 continue;
624 CreatureTemplate const* cTemp = sObjectMgr->GetCreatureTemplate(data.id);
625 if (!cTemp)
626 continue;
627 if (showAll || data.spawnPoint.IsInDist2d(player, 5000.0))
628 handler->PSendSysMessage("Type: %u | SpawnId: " UI64FMTD " | 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());
629 }
630 for (auto const& pair : sObjectMgr->GetAllGameObjectData())
631 {
632 SpawnData const& data = pair.second;
633 if (data.mapId != mapId)
634 continue;
635 GameObjectTemplate const* goTemp = sObjectMgr->GetGameObjectTemplate(data.id);
636 if (!goTemp)
637 continue;
638 if (showAll || data.spawnPoint.IsInDist2d(player, 5000.0))
639 handler->PSendSysMessage("Type: %u | SpawnId: " UI64FMTD " | 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());
640 }
641 return true;
642 }
643
644 static char const* GetZoneName(uint32 zoneId, LocaleConstant locale)
645 {
646 AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(zoneId);
647 return zoneEntry ? zoneEntry->AreaName[locale] : "<unknown zone>";
648 }
649
651 {
652 Player const* player = handler->GetSession()->GetPlayer();
653 Map* map = player->GetMap();
654
655 LocaleConstant locale = handler->GetSession()->GetSessionDbcLocale();
656 char const* stringOverdue = sObjectMgr->GetTrinityString(LANG_LIST_RESPAWNS_OVERDUE, locale);
657
658 uint32 zoneId = player->GetZoneId();
659 char const* zoneName = GetZoneName(zoneId, locale);
660 for (SpawnObjectType type : EnumUtils::Iterate<SpawnObjectType>())
661 {
662 if (range)
664 else
665 handler->PSendSysMessage(LANG_LIST_RESPAWNS_ZONE, EnumUtils::ToTitle(type), zoneName, zoneId);
666
668 std::vector<RespawnInfo const*> respawns;
669 map->GetRespawnInfo(respawns, SpawnObjectTypeMask(1 << type));
670 for (RespawnInfo const* ri : respawns)
671 {
672 SpawnMetadata const* data = sObjectMgr->GetSpawnMetadata(ri->type, ri->spawnId);
673 if (!data)
674 continue;
675
676 uint32 respawnZoneId = 0;
677 if (SpawnData const* edata = data->ToSpawnData())
678 {
679 respawnZoneId = map->GetZoneId(PhasingHandler::GetEmptyPhaseShift(), edata->spawnPoint);
680 if (range)
681 {
682 if (!player->IsInDist(edata->spawnPoint, *range))
683 continue;
684 }
685 else
686 {
687 if (zoneId != respawnZoneId)
688 continue;
689 }
690 }
691 uint32 gridY = ri->gridId / MAX_NUMBER_OF_GRIDS;
692 uint32 gridX = ri->gridId % MAX_NUMBER_OF_GRIDS;
693 std::string respawnTime = ri->respawnTime > GameTime::GetGameTime() ? secsToTimeString(uint64(ri->respawnTime - GameTime::GetGameTime()), TimeFormat::ShortText) : stringOverdue;
694 handler->PSendSysMessage(UI64FMTD " | %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)");
695 }
696 }
697 return true;
698 }
699
701 {
702 Player* target = handler->getSelectedPlayer();
703
704 if (!target)
705 target = handler->GetSession()->GetPlayer();
706
707 if (!target)
708 {
710 handler->SetSentErrorMessage(true);
711 return false;
712 }
713
714 SceneTemplateByInstance const& instanceByPackageMap = target->GetSceneMgr().GetSceneTemplateByInstanceMap();
715
717
718 for (auto const& instanceByPackage : instanceByPackageMap)
719 handler->PSendSysMessage(LANG_DEBUG_SCENE_OBJECT_DETAIL, instanceByPackage.second->ScenePackageId, instanceByPackage.first);
720
721 return true;
722 }
723};
724
@ 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:51
DB2Storage< AreaTableEntry > sAreaTableStore("AreaTable.db2", &AreaTableLoadInfo::Instance)
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.
#define UI64FMTD
Definition Define.h:138
uint8_t uint8
Definition Define.h:156
uint64_t uint64
Definition Define.h:153
uint16_t uint16
Definition Define.h:155
uint32_t uint32
Definition Define.h:154
#define MAX_NUMBER_OF_GRIDS
Definition GridDefines.h:38
@ LANG_ITEMLIST_GUILD
Definition Language.h:894
@ LANG_COMMAND_TARGET_LISTAURAS
Definition Language.h:530
@ LANG_LIST_RESPAWNS_RANGE
Definition Language.h:1150
@ LANG_DEBUG_SCENE_OBJECT_LIST
Definition Language.h:1139
@ 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:1151
@ LANG_LIST_RESPAWNS_OVERDUE
Definition Language.h:1153
@ LANG_GO_LIST_CHAT
Definition Language.h:591
@ LANG_DEBUG_SCENE_OBJECT_DETAIL
Definition Language.h:1140
@ 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_PLAYER_NOT_FOUND
Definition Language.h:570
@ 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:1152
@ 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 sObjectMgr
Definition ObjectMgr.h:1885
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
Role Based Access Control related classes definition.
std::map< uint32, std::unique_ptr< SceneTemplate > > SceneTemplateByInstance
Definition SceneMgr.h:33
uint32 constexpr ItemQualityColors[MAX_ITEM_QUALITY]
@ SILVER
@ GOLD
SpawnObjectTypeMask
Definition SpawnData.h:44
SpawnObjectType
Definition SpawnData.h:35
@ TOTAL_AURAS
@ SPELL_ATTR0_CU_IS_TALENT
Definition SpellInfo.h:167
void wstrToLower(std::wstring &str)
Definition Util.cpp:433
std::string TimeToTimestampStr(time_t t)
Definition Util.cpp:254
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition Util.cpp:707
std::string secsToTimeString(uint64 timeInSecs, TimeFormat timeFormat, bool hoursOnly)
Definition Util.cpp:116
int32 GetMaxDuration() const
Definition SpellAuras.h:217
ObjectGuid GetCasterGUID() const
Definition SpellAuras.h:187
uint32 GetId() const
Definition SpellAuras.h:183
int32 GetDuration() const
Definition SpellAuras.h:222
uint8 GetStackAmount() const
Definition SpellAuras.h:238
uint8 GetCharges() const
Definition SpellAuras.h:229
SpellInfo const * GetSpellInfo() const
Definition SpellAuras.h:182
bool IsPassive() const
std::string playerLink(std::string const &name) const
Definition Chat.cpp:603
Unit * getSelectedUnit()
Definition Chat.cpp:216
Player * getSelectedPlayer()
Definition Chat.cpp:204
WorldSession * GetSession()
Definition Chat.h:42
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:593
void SetSentErrorMessage(bool val)
Definition Chat.h:127
void PSendSysMessage(char const *fmt, Args &&... args)
Definition Chat.h:62
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:111
virtual char const * GetTrinityString(uint32 entry) const
Definition Chat.cpp:46
static char const * ToTitle(Enum value)
Definition SmartEnum.h:124
Class used to access individual fields of database query result.
Definition Field.h:94
float GetFloat() const noexcept
Definition Field.cpp:85
uint64 GetUInt64() const noexcept
Definition Field.cpp:71
uint32 GetUInt32() const noexcept
Definition Field.cpp:57
uint16 GetUInt16() const noexcept
Definition Field.cpp:43
uint8 GetUInt8() const noexcept
Definition Field.cpp:29
std::string GetString() const noexcept
Definition Field.cpp:113
int64 GetInt64() const noexcept
Definition Field.cpp:78
Definition Map.h:225
bool IsDungeon() const
Definition Map.cpp:3267
bool IsBattlegroundOrArena() const
Definition Map.cpp:3369
bool IsSpawnGroupActive(uint32 groupId) const
Definition Map.cpp:2476
uint32 GetZoneId(PhaseShift const &phaseShift, float x, float y, float z)
Definition Map.cpp:1705
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:465
uint32 GetId() const
Definition Map.cpp:3257
char const * GetMapName() const
Definition Map.cpp:1844
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition Map.h:461
RespawnInfo * GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const
Definition Map.cpp:2142
bool IsPlayer() const
Definition ObjectGuid.h:369
std::string ToString() const
uint64 LowType
Definition ObjectGuid.h:321
static PhaseShift const & GetEmptyPhaseShift()
static bool IsEquipmentPos(uint16 pos)
Definition Player.h:1488
SceneMgr & GetSceneMgr()
Definition Player.h:2888
static bool IsInventoryPos(uint16 pos)
Definition Player.h:1486
static bool IsBankPos(uint16 pos)
Definition Player.h:1491
void setUInt32(uint8 index, uint32 value)
void setUInt64(uint8 index, uint64 value)
uint32 GetActiveSceneCount(uint32 sceneScriptPackageId=0) const
Definition SceneMgr.cpp:230
SceneTemplateByInstance const & GetSceneTemplateByInstanceMap() const
Definition SceneMgr.h:71
uint32 const Id
Definition SpellInfo.h:328
bool HasAttribute(SpellAttr0 attribute) const
Definition SpellInfo.h:456
LocalizedString const * SpellName
Definition SpellInfo.h:409
Definition Unit.h:635
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition Unit.h:1342
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:645
std::forward_list< AuraEffect * > AuraEffectList
Definition Unit.h:652
AuraApplicationMap & GetAppliedAuras()
Definition Unit.h:1295
uint8 GetLevel() const
Definition Unit.h:757
Map * GetMap() const
Definition Object.h:411
uint32 GetZoneId() const
Definition Object.h:332
LocaleConstant GetSessionDbcLocale() const
Player * GetPlayer() const
static bool HandleListMailCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_list.cpp:513
static bool HandleListAurasByIdCommand(ChatHandler *handler, uint32 spellId)
Definition cs_list.cpp:426
static bool HandleListCreatureCommand(ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > creatureId, Optional< uint32 > countArg)
Definition cs_list.cpp:77
static bool ShouldListAura(SpellInfo const *spellInfo, Optional< uint32 > spellId, std::wstring namePart, LocaleConstant locale)
Definition cs_list.cpp:498
static char const * GetZoneName(uint32 zoneId, LocaleConstant locale)
Definition cs_list.cpp:644
static bool HandleListRespawnsCommand(ChatHandler *handler, Optional< uint32 > range)
Definition cs_list.cpp:650
static bool HandleListAurasByNameCommand(ChatHandler *handler, WTail namePart)
Definition cs_list.cpp:431
static bool HandleListAllAurasCommand(ChatHandler *handler)
Definition cs_list.cpp:421
static bool HandleListScenesCommand(ChatHandler *handler)
Definition cs_list.cpp:700
static bool ListAurasCommand(ChatHandler *handler, Optional< uint32 > spellId, std::wstring namePart)
Definition cs_list.cpp:436
static bool HandleListSpawnPointsCommand(ChatHandler *handler)
Definition cs_list.cpp:612
std::span< ChatCommandBuilder const > GetCommands() const override
Definition cs_list.cpp:50
static bool HandleListObjectCommand(ChatHandler *handler, Variant< Hyperlink< gameobject_entry >, uint32 > gameObjectId, Optional< uint32 > countArg)
Definition cs_list.cpp:345
static bool HandleListItemCommand(ChatHandler *handler, Hyperlink< item > const &item, Optional< uint32 > countArg)
Definition cs_list.cpp:152
void AddSC_list_commandscript()
Definition cs_list.cpp:725
time_t GetGameTime()
Definition GameTime.cpp:52
ChatCommandBuilder const [] ChatCommandTable
Definition ChatCommand.h:49
auto MapEqualRange(M &map, typename M::key_type const &key)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args) noexcept
Default TC string format function.
@ RBAC_PERM_COMMAND_LIST_SPAWNPOINTS
Definition RBAC.h:736
@ RBAC_PERM_COMMAND_LIST_MAIL
Definition RBAC.h:313
@ RBAC_PERM_COMMAND_LIST_ITEM
Definition RBAC.h:310
@ RBAC_PERM_COMMAND_LIST_CREATURE
Definition RBAC.h:309
@ RBAC_PERM_COMMAND_LIST_OBJECT
Definition RBAC.h:311
@ RBAC_PERM_COMMAND_LIST_AURAS
Definition RBAC.h:312
@ RBAC_PERM_COMMAND_LIST_SCENES
Definition RBAC.h:720
@ RBAC_PERM_COMMAND_LIST_RESPAWNS
Definition RBAC.h:730
LocalizedString AreaName
std::string Name
uint32 GetQuality() const
char const * GetName(LocaleConstant locale) const
std::array< char const *, TOTAL_LOCALES > Str
Definition Common.h:112
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
constexpr bool IsInDist2d(float x, float y, float dist) const
Definition Position.h:151
constexpr bool IsInDist(float x, float y, float z, float dist) const
Definition Position.h:155
constexpr float GetPositionZ() const
Definition Position.h:89
uint32 id
Definition SpawnData.h:135
Position spawnPoint
Definition SpawnData.h:136
SpawnObjectType const type
Definition SpawnData.h:120
SpawnGroupTemplateData const * spawnGroupData
Definition SpawnData.h:124
uint64 spawnId
Definition SpawnData.h:121
SpawnData const * ToSpawnData() const
Definition SpawnData.h:118
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)