AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
pool_commandscript Class Reference
Inheritance diagram for pool_commandscript:
CommandScript ScriptObject

Public Member Functions

 pool_commandscript ()
 
ChatCommandTable GetCommands () const override
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Private Member Functions

static char const * StatusTag (bool active)
 
static void ListPoolMembers (ChatHandler *handler, char const *typeName, std::vector< PoolObject > const &explicitly, std::vector< PoolObject > const &equal, bool isCreature)
 
static bool HandlePoolInfoCommand (ChatHandler *handler, uint32 poolId)
 
static bool HandlePoolLookupCommand (ChatHandler *handler)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ pool_commandscript()

pool_commandscript::pool_commandscript ( )
inline
34: CommandScript("pool_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable pool_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

37 {
38 static ChatCommandTable poolCommandTable =
39 {
40 { "info", HandlePoolInfoCommand, SEC_GAMEMASTER, Console::Yes },
41 { "lookup", HandlePoolLookupCommand, SEC_GAMEMASTER, Console::No },
42 };
43 static ChatCommandTable commandTable =
44 {
45 { "pool", poolCommandTable }
46 };
47 return commandTable;
48 }
@ SEC_GAMEMASTER
Definition Common.h:59
static bool HandlePoolLookupCommand(ChatHandler *handler)
Definition cs_pool.cpp:180
static bool HandlePoolInfoCommand(ChatHandler *handler, uint32 poolId)
Definition cs_pool.cpp:114
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46

References HandlePoolInfoCommand(), HandlePoolLookupCommand(), and SEC_GAMEMASTER.

◆ HandlePoolInfoCommand()

static bool pool_commandscript::HandlePoolInfoCommand ( ChatHandler handler,
uint32  poolId 
)
inlinestaticprivate
115 {
116 PoolTemplateData const* tpl = sPoolMgr->GetPoolTemplate(poolId);
117 if (!tpl)
118 {
119 handler->PSendSysMessage(LANG_POOL_NOT_FOUND, poolId);
120 handler->SetSentErrorMessage(true);
121 return false;
122 }
123
124 uint32 activeCount = sPoolMgr->GetSpawnedData().GetActiveObjectCount(poolId);
125 handler->PSendSysMessage(LANG_POOL_INFO_HEADER, poolId,
126 tpl->Description.empty() ? "(none)" : tpl->Description,
127 tpl->MaxLimit, activeCount);
128
129 // Show parent pool if nested
130 uint32 parentPool = sPoolMgr->IsPartOfAPool<Pool>(poolId);
131 if (parentPool)
132 handler->PSendSysMessage(" Parent pool: {}", parentPool);
133
134 // Creature members
135 if (PoolGroup<Creature> const* creGroup = sPoolMgr->GetPoolCreatureGroup(poolId))
136 {
137 if (!creGroup->IsEmpty())
138 ListPoolMembers(handler, "Creatures",
139 creGroup->GetExplicitlyChanced(), creGroup->GetEqualChanced(), true);
140 }
141
142 // GameObject members
143 if (PoolGroup<GameObject> const* goGroup = sPoolMgr->GetPoolGameObjectGroup(poolId))
144 {
145 if (!goGroup->IsEmpty())
146 ListPoolMembers(handler, "GameObjects",
147 goGroup->GetExplicitlyChanced(), goGroup->GetEqualChanced(), false);
148 }
149
150 // Sub-pool members
151 if (PoolGroup<Pool> const* poolGroup = sPoolMgr->GetPoolPoolGroup(poolId))
152 {
153 auto const& explicitly = poolGroup->GetExplicitlyChanced();
154 auto const& equal = poolGroup->GetEqualChanced();
155 if (!explicitly.empty() || !equal.empty())
156 {
157 uint32 total = explicitly.size() + equal.size();
159
160 auto printSubPool = [&](PoolObject const& obj)
161 {
162 bool active = sPoolMgr->GetSpawnedData().IsActiveObject<Pool>(obj.guid);
163 PoolTemplateData const* subTpl = sPoolMgr->GetPoolTemplate(obj.guid);
164 std::string desc = subTpl ? subTpl->Description : "Unknown";
165
167 StatusTag(active), obj.guid, desc);
168 };
169
170 for (auto const& obj : explicitly)
171 printSubPool(obj);
172 for (auto const& obj : equal)
173 printSubPool(obj);
174 }
175 }
176
177 return true;
178 }
std::uint32_t uint32
Definition Define.h:107
@ LANG_POOL_INFO_SUBPOOL
Definition Language.h:1477
@ LANG_POOL_NOT_FOUND
Definition Language.h:1472
@ LANG_POOL_INFO_SUBPOOLS_HEADER
Definition Language.h:1476
@ LANG_POOL_INFO_HEADER
Definition Language.h:1473
#define sPoolMgr
Definition PoolMgr.h:177
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:219
void SetSentErrorMessage(bool val)
Definition Chat.h:238
Definition PoolMgr.h:70
Definition PoolMgr.h:40
static void ListPoolMembers(ChatHandler *handler, char const *typeName, std::vector< PoolObject > const &explicitly, std::vector< PoolObject > const &equal, bool isCreature)
Definition cs_pool.cpp:56
static char const * StatusTag(bool active)
Definition cs_pool.cpp:51
Definition PoolMgr.h:33
Definition PoolMgr.h:27
std::string Description
Definition PoolMgr.h:29

References PoolTemplateData::Description, LANG_POOL_INFO_HEADER, LANG_POOL_INFO_SUBPOOL, LANG_POOL_INFO_SUBPOOLS_HEADER, LANG_POOL_NOT_FOUND, ListPoolMembers(), PoolTemplateData::MaxLimit, ChatHandler::PSendSysMessage(), ChatHandler::SetSentErrorMessage(), sPoolMgr, and StatusTag().

Referenced by GetCommands().

◆ HandlePoolLookupCommand()

static bool pool_commandscript::HandlePoolLookupCommand ( ChatHandler handler)
inlinestaticprivate
181 {
182 Player* player = handler->GetSession()->GetPlayer();
183 if (!player)
184 return false;
185
186 // Check targeted creature
187 Creature* target = handler->getSelectedCreature();
188 if (target && target->GetSpawnId())
189 {
190 uint32 spawnId = target->GetSpawnId();
191 uint32 poolId = sPoolMgr->GetCreaturePoolId(spawnId);
192 if (poolId)
193 {
194 bool spawned = sPoolMgr->IsSpawnedObject<Creature>(spawnId);
196 target->GetName(), spawnId, poolId, StatusTag(spawned));
198 }
199 else
201 target->GetName(), spawnId);
202
203 return true;
204 }
205
206 // Check nearby gameobject
207 GameObject* goTarget = handler->GetNearbyGameObject();
208 if (goTarget && goTarget->GetSpawnId())
209 {
210 uint32 spawnId = goTarget->GetSpawnId();
211 uint32 poolId = sPoolMgr->GetGameObjectPoolId(spawnId);
212 if (poolId)
213 {
214 bool spawned = sPoolMgr->IsSpawnedObject<GameObject>(spawnId);
216 goTarget->GetName(), spawnId, poolId, StatusTag(spawned));
218 }
219 else
221 goTarget->GetName(), spawnId);
222
223 return true;
224 }
225
227 handler->SetSentErrorMessage(true);
228 return false;
229 }
@ LANG_POOL_LOOKUP_NOT_IN_POOL
Definition Language.h:1479
@ LANG_POOL_LOOKUP_USE_INFO
Definition Language.h:1480
@ LANG_POOL_LOOKUP_IN_POOL
Definition Language.h:1478
@ LANG_POOL_LOOKUP_NOTARGET
Definition Language.h:1481
WorldSession * GetSession()
Definition Chat.h:242
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:168
GameObject * GetNearbyGameObject() const
Definition Chat.cpp:573
Creature * getSelectedCreature() const
Definition Chat.cpp:418
Definition Creature.h:47
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:69
Definition GameObject.h:120
ObjectGuid::LowType GetSpawnId() const
Definition GameObject.h:144
Definition Player.h:1084
std::string const & GetName() const
Definition Object.h:528
Player * GetPlayer() const
Definition WorldSession.h:454

References WorldObject::GetName(), ChatHandler::GetNearbyGameObject(), WorldSession::GetPlayer(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), Creature::GetSpawnId(), GameObject::GetSpawnId(), LANG_POOL_LOOKUP_IN_POOL, LANG_POOL_LOOKUP_NOT_IN_POOL, LANG_POOL_LOOKUP_NOTARGET, LANG_POOL_LOOKUP_USE_INFO, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), ChatHandler::SetSentErrorMessage(), sPoolMgr, and StatusTag().

Referenced by GetCommands().

◆ ListPoolMembers()

static void pool_commandscript::ListPoolMembers ( ChatHandler handler,
char const *  typeName,
std::vector< PoolObject > const &  explicitly,
std::vector< PoolObject > const &  equal,
bool  isCreature 
)
inlinestaticprivate
59 {
60 if (explicitly.empty() && equal.empty())
61 return;
62
63 uint32 total = explicitly.size() + equal.size();
64 handler->PSendSysMessage(LANG_POOL_INFO_MEMBERS_HEADER, typeName, total);
65
66 auto printMember = [&](PoolObject const& obj)
67 {
68 bool spawned = isCreature
69 ? sPoolMgr->IsSpawnedObject<Creature>(obj.guid)
70 : sPoolMgr->IsSpawnedObject<GameObject>(obj.guid);
71
72 std::string name = "Unknown";
73 uint32 entry = 0;
74 uint32 mapId = 0;
75 float x = 0, y = 0, z = 0;
76
77 if (isCreature)
78 {
79 if (CreatureData const* data = sObjectMgr->GetCreatureData(obj.guid))
80 {
81 entry = data->id1;
82 mapId = data->mapid;
83 x = data->posX;
84 y = data->posY;
85 z = data->posZ;
86 if (CreatureTemplate const* tpl = sObjectMgr->GetCreatureTemplate(entry))
87 name = tpl->Name;
88 }
89 }
90 else
91 {
92 if (GameObjectData const* data = sObjectMgr->GetGameObjectData(obj.guid))
93 {
94 entry = data->id;
95 mapId = data->mapid;
96 x = data->posX;
97 y = data->posY;
98 z = data->posZ;
99 if (GameObjectTemplate const* tpl = sObjectMgr->GetGameObjectTemplate(entry))
100 name = tpl->name;
101 }
102 }
103
105 StatusTag(spawned), obj.guid, name, entry, mapId, x, y, z);
106 };
107
108 for (auto const& obj : explicitly)
109 printMember(obj);
110 for (auto const& obj : equal)
111 printMember(obj);
112 }
@ LANG_POOL_INFO_MEMBERS_HEADER
Definition Language.h:1474
@ LANG_POOL_INFO_MEMBER
Definition Language.h:1475
#define sObjectMgr
Definition ObjectMgr.h:1723
Definition CreatureData.h:370
Definition CreatureData.h:187
Definition GameObjectData.h:715
Definition GameObjectData.h:32

References LANG_POOL_INFO_MEMBER, LANG_POOL_INFO_MEMBERS_HEADER, ChatHandler::PSendSysMessage(), sObjectMgr, sPoolMgr, and StatusTag().

Referenced by HandlePoolInfoCommand().

◆ StatusTag()

static char const * pool_commandscript::StatusTag ( bool  active)
inlinestaticprivate
52 {
53 return active ? "ACTIVE" : "inactive";
54 }

Referenced by HandlePoolInfoCommand(), HandlePoolLookupCommand(), and ListPoolMembers().


The documentation for this class was generated from the following file: