diff options
author | Shauren <shauren.trinity@gmail.com> | 2024-08-18 18:59:58 +0200 |
---|---|---|
committer | Ovahlord <dreadkiller@gmx.de> | 2024-08-18 20:39:21 +0200 |
commit | 25ffdbc5ef0859aeaadfa132329a498e86827e68 (patch) | |
tree | d7df51da8cdc3e3df7c50e5058803f9324715ee4 /src/server/shared/Realm/Realm.h | |
parent | 0c98004896cb91ef2d22baa5569ff0e0d6cd15ee (diff) |
Core/Realms: Realmlist refactors
* Removed global realm variable from World and use RealmList everywhere
* Match auth build key with client version
* Restored allowedSecurityLevel checks for realmlist packet building
* Restored updating population field, mysteriously removed 15 years ago in f20b25d1c90f608deab28c9957b3b376ab2a0d50
(cherry picked from commit c4b710446d62c95eb8124175203fa5f394912594)
# Conflicts:
# sql/base/auth_database.sql
Diffstat (limited to 'src/server/shared/Realm/Realm.h')
-rw-r--r-- | src/server/shared/Realm/Realm.h | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/src/server/shared/Realm/Realm.h b/src/server/shared/Realm/Realm.h index 45a07ebaa52..e44ff308c4f 100644 --- a/src/server/shared/Realm/Realm.h +++ b/src/server/shared/Realm/Realm.h @@ -18,12 +18,42 @@ #ifndef Realm_h__ #define Realm_h__ -#include "Common.h" #include "AsioHacksFwd.h" +#include "Common.h" +#include "EnumFlag.h" #include <compare> #include <vector> -enum RealmFlags +enum class RealmFlags : uint8 +{ + None = 0x00, + VersionMismatch = 0x01, + Hidden = 0x02, + Tournament = 0x04, + VersionBelow = 0x08, + VersionAbove = 0x10, + MobileVersionMismatch = 0x20, + MobileVersionBelow = 0x40, + MobileVersionAbove = 0x80 +}; + +DEFINE_ENUM_FLAG(RealmFlags); + +enum class RealmPopulationState : uint8 +{ + Offline = 0, + Low = 1, + Medium = 2, + High = 3, + New = 4, + Recommended = 5, + Full = 6, + Locked = 7 +}; + +namespace Trinity::Legacy +{ +enum RealmFlags : uint8 { REALM_FLAG_NONE = 0x00, REALM_FLAG_VERSION_MISMATCH = 0x01, @@ -36,6 +66,34 @@ enum RealmFlags REALM_FLAG_FULL = 0x80 }; +inline constexpr uint8 format_as(RealmFlags e) { return uint8(e); } + +inline constexpr ::RealmFlags ConvertLegacyRealmFlags(RealmFlags legacyRealmFlags) +{ + ::RealmFlags realmFlags = ::RealmFlags::None; + if (legacyRealmFlags & REALM_FLAG_VERSION_MISMATCH) + realmFlags |= ::RealmFlags::VersionMismatch; + return realmFlags; +} + +inline constexpr RealmPopulationState ConvertLegacyPopulationState(RealmFlags legacyRealmFlags, float population) +{ + if (legacyRealmFlags & REALM_FLAG_OFFLINE) + return RealmPopulationState::Offline; + if (legacyRealmFlags & REALM_FLAG_RECOMMENDED) + return RealmPopulationState::Recommended; + if (legacyRealmFlags & REALM_FLAG_NEW) + return RealmPopulationState::New; + if (legacyRealmFlags & REALM_FLAG_FULL || population > 0.95f) + return RealmPopulationState::Full; + if (population > 0.66f) + return RealmPopulationState::High; + if (population > 0.33f) + return RealmPopulationState::Medium; + return RealmPopulationState::Low; +} +} + namespace Battlenet { struct TC_SHARED_API RealmHandle @@ -89,7 +147,7 @@ struct TC_SHARED_API Realm RealmFlags Flags; uint8 Timezone; AccountTypes AllowedSecurityLevel; - float PopulationLevel; + RealmPopulationState PopulationLevel; void SetName(std::string name); |