TrinityCore
Loading...
Searching...
No Matches
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
40
42{
43 public:
50 static CharacterCache* instance();
51
52 void LoadCharacterCacheStorage();
53 void AddCharacterCacheEntry(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, bool isDeleted);
54 void DeleteCharacterCacheEntry(ObjectGuid const& guid, std::string const& name);
55
56 void UpdateCharacterData(ObjectGuid const& guid, std::string const& name, Optional<uint8> gender = {}, Optional<uint8> race = {});
57 void UpdateCharacterGender(ObjectGuid const& guid, uint8 gender);
58 void UpdateCharacterLevel(ObjectGuid const& guid, uint8 level);
59 void UpdateCharacterAccountId(ObjectGuid const& guid, uint32 accountId);
60 void UpdateCharacterGuildId(ObjectGuid const& guid, ObjectGuid::LowType guildId);
61 void UpdateCharacterArenaTeamId(ObjectGuid const& guid, uint8 slot, uint32 arenaTeamId);
62 void UpdateCharacterInfoDeleted(ObjectGuid const& guid, bool deleted, std::string const& name);
63
64 bool HasCharacterCacheEntry(ObjectGuid const& guid) const;
65 CharacterCacheEntry const* GetCharacterCacheByGuid(ObjectGuid const& guid) const;
66 CharacterCacheEntry const* GetCharacterCacheByName(std::string const& name) const;
67
68 ObjectGuid GetCharacterGuidByName(std::string const& name) const;
69 bool GetCharacterNameByGuid(ObjectGuid guid, std::string& name) const;
70 Team GetCharacterTeamByGuid(ObjectGuid guid) const;
71 uint32 GetCharacterAccountIdByGuid(ObjectGuid guid) const;
72 uint32 GetCharacterAccountIdByName(std::string const& name) const;
73 uint8 GetCharacterLevelByGuid(ObjectGuid guid) const;
74 ObjectGuid::LowType GetCharacterGuildIdByGuid(ObjectGuid guid) const;
75 uint32 GetCharacterArenaTeamIdByGuid(ObjectGuid guid, uint8 type) const;
76 bool GetCharacterNameAndClassByGUID(ObjectGuid guid, std::string& name, uint8& _class) const;
77};
78
79#define sCharacterCache CharacterCache::instance()
80
81#endif // CharacterCache_h__
#define TC_GAME_API
Definition Define.h:129
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
CharacterCache & operator=(CharacterCache &&)=delete
CharacterCache & operator=(CharacterCache const &)=delete
CharacterCache(CharacterCache const &)=delete
CharacterCache(CharacterCache &&)=delete
uint64 LowType
Definition ObjectGuid.h:321
ObjectGuid::LowType GuildId