TrinityCore
Loading...
Searching...
No Matches
Realm.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 Realm_h__
19#define Realm_h__
20
21#include "AsioHacksFwd.h"
22#include "Common.h"
23#include "EnumFlag.h"
24#include <compare>
25#include <vector>
26
27enum class RealmFlags : uint8
28{
29 None = 0x00,
30 VersionMismatch = 0x01,
31 Hidden = 0x02,
32 Tournament = 0x04,
33 VersionBelow = 0x08,
34 VersionAbove = 0x10,
36 MobileVersionBelow = 0x40,
38};
39
41
43{
44 Offline = 0,
45 Low = 1,
46 Medium = 2,
47 High = 3,
48 New = 4,
49 Recommended = 5,
50 Full = 6,
51 Locked = 7
52};
53
54namespace Trinity::Legacy
55{
68
69inline constexpr uint8 format_as(RealmFlags e) { return uint8(e); }
70
71inline constexpr ::RealmFlags ConvertLegacyRealmFlags(RealmFlags legacyRealmFlags)
72{
74 if (legacyRealmFlags & REALM_FLAG_VERSION_MISMATCH)
76 return realmFlags;
77}
78
79inline constexpr RealmPopulationState ConvertLegacyPopulationState(RealmFlags legacyRealmFlags, float population)
80{
81 if (legacyRealmFlags & REALM_FLAG_OFFLINE)
83 if (legacyRealmFlags & REALM_FLAG_RECOMMENDED)
85 if (legacyRealmFlags & REALM_FLAG_NEW)
87 if (legacyRealmFlags & REALM_FLAG_FULL || population > 0.95f)
89 if (population > 0.66f)
91 if (population > 0.33f)
94}
95}
96
97namespace Battlenet
98{
100 {
101 RealmHandle() : Region(0), Site(0), Realm(0) { }
102 RealmHandle(uint8 region, uint8 battlegroup, uint32 index)
103 : Region(region), Site(battlegroup), Realm(index) { }
104 RealmHandle(uint32 realmAddress) : Region((realmAddress >> 24) & 0xFF), Site((realmAddress >> 16) & 0xFF), Realm(realmAddress & 0xFFFF) { }
105
108 uint32 Realm; // primary key in `realmlist` table
109
110 bool operator==(RealmHandle const& r) const { return Realm == r.Realm; }
111
112 std::strong_ordering operator<=>(RealmHandle const& r) const { return Realm <=> r.Realm; }
113
114 uint32 GetAddress() const { return (Region << 24) | (Site << 16) | uint16(Realm); }
115 std::string GetAddressString() const;
116 std::string GetSubRegionAddress() const;
117 };
118}
119
122{
128
130
131 REALM_TYPE_FFA_PVP = 16 // custom, free for all pvp mode like arena PvP in all zones except rest activated places and sanctuaries
132 // replaced by REALM_PVP in realm list
134
136
137// Storage object for a realm
139{
142 std::vector<boost::asio::ip::address> Addresses;
144 std::string Name;
145 std::string NormalizedName;
151
152 void SetName(std::string name);
153
154 boost::asio::ip::address GetAddressForClient(boost::asio::ip::address const& clientAddr) const;
155 uint32 GetConfigId() const;
156
157 static uint32 const ConfigIdByType[MAX_CLIENT_REALM_TYPE];
158};
159
160#endif // Realm_h__
AccountTypes
Definition Common.h:42
uint8_t uint8
Definition Define.h:156
#define TC_SHARED_API
Definition Define.h:123
uint16_t uint16
Definition Define.h:155
uint32_t uint32
Definition Define.h:154
#define DEFINE_ENUM_FLAG(enumType)
Definition EnumFlag.h:26
constexpr uint32 HARDCODED_DEVELOPMENT_REALM_CATEGORY_ID
Definition Realm.h:135
RealmFlags
Definition Realm.h:28
@ MobileVersionMismatch
@ MobileVersionAbove
@ MobileVersionBelow
RealmPopulationState
Definition Realm.h:43
RealmType
Type of server, this is values from second column of Cfg_Configs.dbc.
Definition Realm.h:122
@ REALM_TYPE_FFA_PVP
Definition Realm.h:131
@ MAX_CLIENT_REALM_TYPE
Definition Realm.h:129
@ REALM_TYPE_RPPVP
Definition Realm.h:127
@ REALM_TYPE_PVP
Definition Realm.h:124
@ REALM_TYPE_RP
Definition Realm.h:126
@ REALM_TYPE_NORMAL2
Definition Realm.h:125
@ REALM_TYPE_NORMAL
Definition Realm.h:123
constexpr RealmPopulationState ConvertLegacyPopulationState(RealmFlags legacyRealmFlags, float population)
Definition Realm.h:79
constexpr ::RealmFlags ConvertLegacyRealmFlags(RealmFlags legacyRealmFlags)
Definition Realm.h:71
constexpr uint8 format_as(RealmFlags e)
Definition Realm.h:69
@ REALM_FLAG_VERSION_MISMATCH
Definition Realm.h:59
@ REALM_FLAG_OFFLINE
Definition Realm.h:60
@ REALM_FLAG_UNK1
Definition Realm.h:62
@ REALM_FLAG_SPECIFYBUILD
Definition Realm.h:61
@ REALM_FLAG_NONE
Definition Realm.h:58
@ REALM_FLAG_FULL
Definition Realm.h:66
@ REALM_FLAG_RECOMMENDED
Definition Realm.h:64
@ REALM_FLAG_UNK2
Definition Realm.h:63
uint32 GetAddress() const
Definition Realm.h:114
bool operator==(RealmHandle const &r) const
Definition Realm.h:110
RealmHandle(uint8 region, uint8 battlegroup, uint32 index)
Definition Realm.h:102
std::strong_ordering operator<=>(RealmHandle const &r) const
Definition Realm.h:112
RealmHandle(uint32 realmAddress)
Definition Realm.h:104
Definition Realm.h:139
uint16 Port
Definition Realm.h:143
RealmFlags Flags
Definition Realm.h:147
AccountTypes AllowedSecurityLevel
Definition Realm.h:149
uint8 Timezone
Definition Realm.h:148
uint32 Build
Definition Realm.h:141
std::string NormalizedName
Definition Realm.h:145
std::string Name
Definition Realm.h:144
RealmPopulationState PopulationLevel
Definition Realm.h:150
Battlenet::RealmHandle Id
Definition Realm.h:140
std::vector< boost::asio::ip::address > Addresses
Definition Realm.h:142
uint8 Type
Definition Realm.h:146