AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
ChatCommand.cpp File Reference
#include "ChatCommand.h"
#include "AccountMgr.h"
#include "Chat.h"
#include "DBCStores.h"
#include "DatabaseEnv.h"
#include "Log.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "StringFormat.h"
#include "Tokenize.h"
#include "WorldSession.h"

Go to the source code of this file.

Classes

struct  Acore::Impl::ChatCommands::FilteredCommandListIterator
 

Namespaces

namespace  Acore
 
namespace  Acore::Impl
 
namespace  Acore::Impl::ChatCommands
 

Typedefs

using ChatSubCommandMap = std::map< std::string_view, Acore::Impl::ChatCommands::ChatCommandNode, StringCompareLessI_T >
 

Functions

static void LogCommandUsage (WorldSession const &session, std::string_view cmdStr)
 

Variables

static ChatSubCommandMap COMMAND_MAP
 

Typedef Documentation

◆ ChatSubCommandMap

Function Documentation

◆ LogCommandUsage()

static void LogCommandUsage ( WorldSession const &  session,
std::string_view  cmdStr 
)
static
156{
157 if (AccountMgr::IsPlayerAccount(session.GetSecurity()))
158 return;
159
160 Player* player = session.GetPlayer();
161 ObjectGuid targetGuid = player->GetTarget();
162 uint32 areaId = player->GetAreaId();
163 uint32 zoneId = player->GetZoneId();
164 std::string areaName = "Unknown";
165 std::string zoneName = "Unknown";
166 LocaleConstant locale = sWorld->GetDefaultDbcLocale();
167
168 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId))
169 {
170 areaName = area->area_name[locale];
171 }
172
173 if (AreaTableEntry const* zone = sAreaTableStore.LookupEntry(zoneId))
174 {
175 zoneName = zone->area_name[locale];
176 }
177
178 std::string logMessage = Acore::StringFormat("Command: {} [Player: {} ({}) (Account: {}) X: {} Y: {} Z: {} Map: {} ({}) Area: {} ({}) Zone: {} ({}) Selected: {} ({})]",
179 cmdStr, player->GetName(), player->GetGUID().ToString(),
180 session.GetAccountId(),
181 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(),
182 player->FindMap() ? player->FindMap()->GetMapName() : "Unknown",
183 areaId, areaName, zoneId, zoneName,
184 (player->GetSelectedUnit()) ? player->GetSelectedUnit()->GetName() : "",
185 targetGuid.ToString());
186
187 LOG_GM(session.GetAccountId(), logMessage);
188}
LocaleConstant
Definition: Common.h:65
#define LOG_GM(accountId__,...)
Definition: Log.h:175
std::uint32_t uint32
Definition: Define.h:107
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define sWorld
Definition: World.h:444
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:34
bool IsPlayerAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:305
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
Map * FindMap() const
Definition: Object.h:532
std::string const & GetName() const
Definition: Object.h:458
uint32 GetAreaId() const
Definition: Object.cpp:3154
uint32 GetZoneId() const
Definition: Object.cpp:3146
Definition: ObjectGuid.h:118
std::string ToString() const
Definition: ObjectGuid.cpp:47
float GetPositionZ() const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
uint32 GetMapId() const
Definition: Position.h:276
Definition: Player.h:1064
Unit * GetSelectedUnit() const
Definition: Player.cpp:11538
ObjectGuid GetTarget() const
Definition: Unit.h:1756
const char * GetMapName() const
Definition: Map.cpp:2524
Definition: DBCStructure.h:518

References WorldObject::FindMap(), WorldSession::GetAccountId(), WorldObject::GetAreaId(), Object::GetGUID(), WorldLocation::GetMapId(), Map::GetMapName(), WorldObject::GetName(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), WorldSession::GetSecurity(), Player::GetSelectedUnit(), Unit::GetTarget(), WorldObject::GetZoneId(), AccountMgr::IsPlayerAccount(), LOG_GM, sAreaTableStore, Acore::StringFormat(), sWorld, and ObjectGuid::ToString().

Referenced by Acore::Impl::ChatCommands::ChatCommandNode::TryExecuteCommand().

Variable Documentation

◆ COMMAND_MAP