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

Public Member Functions

 cache_commandscript ()
 
ChatCommandTable GetCommands () const override
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- 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 Public Member Functions

static bool HandleCacheInfoCommand (ChatHandler *handler, Optional< PlayerIdentifier > player)
 
static bool HandleCacheDeleteCommand (ChatHandler *handler, Optional< PlayerIdentifier > player)
 
static bool HandleCacheRefreshCommand (ChatHandler *handler, Optional< PlayerIdentifier > player)
 

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

◆ cache_commandscript()

cache_commandscript::cache_commandscript ( )
inline
29: CommandScript("cache_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable cache_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

32 {
33 static ChatCommandTable cacheCommandTable =
34 {
35 { "info", HandleCacheInfoCommand, SEC_GAMEMASTER, Console::Yes },
36 { "delete", HandleCacheDeleteCommand, SEC_ADMINISTRATOR, Console::Yes },
37 { "refresh", HandleCacheRefreshCommand, SEC_GAMEMASTER, Console::Yes }
38 };
39
40 static ChatCommandTable commandTable =
41 {
42 { "cache", cacheCommandTable },
43 };
44 return commandTable;
45 }
@ SEC_ADMINISTRATOR
Definition: Common.h:60
@ SEC_GAMEMASTER
Definition: Common.h:59
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:46
static bool HandleCacheDeleteCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition: cs_cache.cpp:76
static bool HandleCacheInfoCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition: cs_cache.cpp:47
static bool HandleCacheRefreshCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition: cs_cache.cpp:95

References HandleCacheDeleteCommand(), HandleCacheInfoCommand(), HandleCacheRefreshCommand(), SEC_ADMINISTRATOR, and SEC_GAMEMASTER.

◆ HandleCacheDeleteCommand()

static bool cache_commandscript::HandleCacheDeleteCommand ( ChatHandler handler,
Optional< PlayerIdentifier player 
)
inlinestatic
77 {
78 if (!player)
79 {
80 player = PlayerIdentifier::FromTargetOrSelf(handler);
81 }
82
83 if (!player)
84 {
86 return false;
87 }
88
89 sCharacterCache->DeleteCharacterCacheEntry(player->GetGUID(), player->GetName());
90 handler->PSendSysMessage(LANG_COMMAND_CACHE_DELETE, player->GetName(), player->GetGUID().ToString());
91 handler->SetSentErrorMessage(false);
92 return true;
93 }
@ LANG_COMMAND_CACHE_DELETE
Definition: Language.h:1117
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:539
#define sCharacterCache
Definition: CharacterCache.h:83
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:210
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:215
void SetSentErrorMessage(bool val)
Definition: Chat.h:238
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:184

References Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), LANG_COMMAND_CACHE_DELETE, LANG_PLAYER_NOT_FOUND, ChatHandler::PSendSysMessage(), sCharacterCache, ChatHandler::SendErrorMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleCacheInfoCommand()

static bool cache_commandscript::HandleCacheInfoCommand ( ChatHandler handler,
Optional< PlayerIdentifier player 
)
inlinestatic
48 {
49 if (!player)
50 {
51 player = PlayerIdentifier::FromTargetOrSelf(handler);
52 }
53
54 if (!player)
55 {
57 return false;
58 }
59
60 CharacterCacheEntry const* cache = sCharacterCache->GetCharacterCacheByGuid(player->GetGUID());
61
62 if (!cache)
63 {
64 handler->SendErrorMessage(LANG_COMMAND_CACHE_NOT_FOUND, player->GetName());
65 return false;
66 }
67
68 handler->PSendSysMessage(LANG_COMMAND_CACHE_INFO, cache->Name, cache->Guid.ToString(), cache->AccountId,
69 cache->Class, cache->Race, cache->Sex, cache->Level, cache->MailCount, cache->GuildId, cache->GroupGuid.ToString(),
71
72 handler->SetSentErrorMessage(false);
73 return true;
74 }
@ LANG_COMMAND_CACHE_NOT_FOUND
Definition: Language.h:1119
@ LANG_COMMAND_CACHE_INFO
Definition: Language.h:1116
@ ARENA_SLOT_2v2
Definition: ArenaTeam.h:102
@ ARENA_SLOT_5v5
Definition: ArenaTeam.h:104
@ ARENA_SLOT_3v3
Definition: ArenaTeam.h:103
Definition: CharacterCache.h:28
uint8 Class
Definition: CharacterCache.h:32
std::array< uint32, MAX_ARENA_SLOT > ArenaTeamId
Definition: CharacterCache.h:38
uint8 Level
Definition: CharacterCache.h:35
ObjectGuid GroupGuid
Definition: CharacterCache.h:39
ObjectGuid::LowType GuildId
Definition: CharacterCache.h:37
std::string Name
Definition: CharacterCache.h:30
uint8 MailCount
Definition: CharacterCache.h:36
uint8 Sex
Definition: CharacterCache.h:34
uint8 Race
Definition: CharacterCache.h:33
ObjectGuid Guid
Definition: CharacterCache.h:29
uint32 AccountId
Definition: CharacterCache.h:31
std::string ToString() const
Definition: ObjectGuid.cpp:47

References CharacterCacheEntry::AccountId, ARENA_SLOT_2v2, ARENA_SLOT_3v3, ARENA_SLOT_5v5, CharacterCacheEntry::ArenaTeamId, CharacterCacheEntry::Class, Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), CharacterCacheEntry::GroupGuid, CharacterCacheEntry::Guid, CharacterCacheEntry::GuildId, LANG_COMMAND_CACHE_INFO, LANG_COMMAND_CACHE_NOT_FOUND, LANG_PLAYER_NOT_FOUND, CharacterCacheEntry::Level, CharacterCacheEntry::MailCount, CharacterCacheEntry::Name, ChatHandler::PSendSysMessage(), CharacterCacheEntry::Race, sCharacterCache, ChatHandler::SendErrorMessage(), ChatHandler::SetSentErrorMessage(), CharacterCacheEntry::Sex, and ObjectGuid::ToString().

Referenced by GetCommands().

◆ HandleCacheRefreshCommand()

static bool cache_commandscript::HandleCacheRefreshCommand ( ChatHandler handler,
Optional< PlayerIdentifier player 
)
inlinestatic
96 {
97 if (!player)
98 {
99 player = PlayerIdentifier::FromTargetOrSelf(handler);
100 }
101
102 if (!player)
103 {
105 return false;
106 }
107
108 if (player->IsConnected())
109 {
110 if (Player* cPlayer = ObjectAccessor::FindConnectedPlayer(player->GetGUID()))
111 {
112 if (sCharacterCache->HasCharacterCacheEntry(cPlayer->GetGUID()))
113 {
114 sCharacterCache->UpdateCharacterData(cPlayer->GetGUID(), cPlayer->GetName(), cPlayer->getGender(), cPlayer->getRace());
115 }
116 else
117 {
118 sCharacterCache->AddCharacterCacheEntry(cPlayer->GetGUID(), cPlayer->GetSession()->GetAccountId(), cPlayer->GetName(),
119 cPlayer->getGender(), cPlayer->getRace(), cPlayer->getClass(), cPlayer->GetLevel());
120 }
121
122 sCharacterCache->UpdateCharacterAccountId(cPlayer->GetGUID(), cPlayer->GetSession()->GetAccountId());
123 sCharacterCache->UpdateCharacterGuildId(cPlayer->GetGUID(), cPlayer->GetGuildId());
124 sCharacterCache->UpdateCharacterMailCount(cPlayer->GetGUID(), cPlayer->GetMailSize(), true);
125 sCharacterCache->UpdateCharacterArenaTeamId(cPlayer->GetGUID(), ARENA_SLOT_2v2, cPlayer->GetArenaTeamId(ARENA_SLOT_2v2));
126 sCharacterCache->UpdateCharacterArenaTeamId(cPlayer->GetGUID(), ARENA_SLOT_3v3, cPlayer->GetArenaTeamId(ARENA_SLOT_3v3));
127 sCharacterCache->UpdateCharacterArenaTeamId(cPlayer->GetGUID(), ARENA_SLOT_5v5, cPlayer->GetArenaTeamId(ARENA_SLOT_5v5));
128
129 if (Group* group = cPlayer->GetGroup())
130 {
131 sCharacterCache->UpdateCharacterGroup(cPlayer->GetGUID(), group->GetGUID());
132 }
133 else
134 {
135 sCharacterCache->ClearCharacterGroup(cPlayer->GetGUID());
136 }
137 }
138 }
139 else
140 {
141 sCharacterCache->RefreshCacheEntry(player->GetGUID().GetCounter());
142 }
143
144 handler->PSendSysMessage(LANG_COMMAND_CACHE_REFRESH, player->GetName(), player->GetGUID().ToString());
145 handler->SetSentErrorMessage(false);
146 return true;
147 }
@ LANG_COMMAND_CACHE_REFRESH
Definition: Language.h:1118
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:257
Definition: Player.h:1081
Definition: Group.h:169

References ARENA_SLOT_2v2, ARENA_SLOT_3v3, ARENA_SLOT_5v5, ObjectAccessor::FindConnectedPlayer(), Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), LANG_COMMAND_CACHE_REFRESH, LANG_PLAYER_NOT_FOUND, ChatHandler::PSendSysMessage(), sCharacterCache, ChatHandler::SendErrorMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().