TrinityCore
CharacterCache.h
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#ifndef CharacterCache_h__
19#define CharacterCache_h__
20
21#include "Define.h"
22#include "ObjectGuid.h"
23#include "Optional.h"
24#include "SharedDefines.h"
25#include <string>
26
28{
30 std::string Name;
39};
40
42{
43 public:
46 static CharacterCache* instance();
47
48 void LoadCharacterCacheStorage();
49 void AddCharacterCacheEntry(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, bool isDeleted);
50 void DeleteCharacterCacheEntry(ObjectGuid const& guid, std::string const& name);
51
52 void UpdateCharacterData(ObjectGuid const& guid, std::string const& name, Optional<uint8> gender = {}, Optional<uint8> race = {});
53 void UpdateCharacterGender(ObjectGuid const& guid, uint8 gender);
54 void UpdateCharacterLevel(ObjectGuid const& guid, uint8 level);
55 void UpdateCharacterAccountId(ObjectGuid const& guid, uint32 accountId);
56 void UpdateCharacterGuildId(ObjectGuid const& guid, ObjectGuid::LowType guildId);
57 void UpdateCharacterArenaTeamId(ObjectGuid const& guid, uint8 slot, uint32 arenaTeamId);
58 void UpdateCharacterInfoDeleted(ObjectGuid const& guid, bool deleted, std::string const& name);
59
60 bool HasCharacterCacheEntry(ObjectGuid const& guid) const;
61 CharacterCacheEntry const* GetCharacterCacheByGuid(ObjectGuid const& guid) const;
62 CharacterCacheEntry const* GetCharacterCacheByName(std::string const& name) const;
63
64 ObjectGuid GetCharacterGuidByName(std::string const& name) const;
65 bool GetCharacterNameByGuid(ObjectGuid guid, std::string& name) const;
66 Team GetCharacterTeamByGuid(ObjectGuid guid) const;
67 uint32 GetCharacterAccountIdByGuid(ObjectGuid guid) const;
68 uint32 GetCharacterAccountIdByName(std::string const& name) const;
69 uint8 GetCharacterLevelByGuid(ObjectGuid guid) const;
70 ObjectGuid::LowType GetCharacterGuildIdByGuid(ObjectGuid guid) const;
71 uint32 GetCharacterArenaTeamIdByGuid(ObjectGuid guid, uint8 type) const;
72 bool GetCharacterNameAndClassByGUID(ObjectGuid guid, std::string& name, uint8& _class) const;
73};
74
75#define sCharacterCache CharacterCache::instance()
76
77#endif // CharacterCache_h__
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
Team
uint64 LowType
Definition: ObjectGuid.h:278
ObjectGuid::LowType GuildId