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