Skip to content

Commit

Permalink
Realm/Core: Implement realm category mapping using realm zone and maj…
Browse files Browse the repository at this point in the history
…or version
  • Loading branch information
Exxenoz authored and killerwife committed Nov 13, 2024
1 parent c5de976 commit 55fbc8e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 37 deletions.
35 changes: 0 additions & 35 deletions src/game/World/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,41 +366,6 @@ enum RealmType
// replaced by REALM_PVP in realm list
};

// [-ZERO] Need drop not existed cases
enum RealmZone
{
REALM_ZONE_UNKNOWN = 0, // any language
REALM_ZONE_DEVELOPMENT = 1, // any language
REALM_ZONE_UNITED_STATES = 2, // extended-Latin
REALM_ZONE_OCEANIC = 3, // extended-Latin
REALM_ZONE_LATIN_AMERICA = 4, // extended-Latin
REALM_ZONE_TOURNAMENT_5 = 5, // basic-Latin at create, any at login
REALM_ZONE_KOREA = 6, // East-Asian
REALM_ZONE_TOURNAMENT_7 = 7, // basic-Latin at create, any at login
REALM_ZONE_ENGLISH = 8, // extended-Latin
REALM_ZONE_GERMAN = 9, // extended-Latin
REALM_ZONE_FRENCH = 10, // extended-Latin
REALM_ZONE_SPANISH = 11, // extended-Latin
REALM_ZONE_RUSSIAN = 12, // Cyrillic
REALM_ZONE_TOURNAMENT_13 = 13, // basic-Latin at create, any at login
REALM_ZONE_TAIWAN = 14, // East-Asian
REALM_ZONE_TOURNAMENT_15 = 15, // basic-Latin at create, any at login
REALM_ZONE_CHINA = 16, // East-Asian
REALM_ZONE_CN1 = 17, // basic-Latin at create, any at login
REALM_ZONE_CN2 = 18, // basic-Latin at create, any at login
REALM_ZONE_CN3 = 19, // basic-Latin at create, any at login
REALM_ZONE_CN4 = 20, // basic-Latin at create, any at login
REALM_ZONE_CN5 = 21, // basic-Latin at create, any at login
REALM_ZONE_CN6 = 22, // basic-Latin at create, any at login
REALM_ZONE_CN7 = 23, // basic-Latin at create, any at login
REALM_ZONE_CN8 = 24, // basic-Latin at create, any at login
REALM_ZONE_TOURNAMENT_25 = 25, // basic-Latin at create, any at login
REALM_ZONE_TEST_SERVER = 26, // any language
REALM_ZONE_TOURNAMENT_27 = 27, // basic-Latin at create, any at login
REALM_ZONE_QA_SERVER = 28, // any language
REALM_ZONE_CN9 = 29 // basic-Latin at create, any at login
};

/// Storage class for commands issued for delayed execution
struct CliCommandHolder
{
Expand Down
8 changes: 6 additions & 2 deletions src/realmd/AuthSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,13 +911,15 @@ void AuthSocket::LoadRealmlist(ByteBuffer& pkt, uint32 acctid, uint8 securityLev
if (!ok_build || (i.second.allowedSecurityLevel > _accountSecurityLevel))
realmflags = RealmFlags(realmflags | REALM_FLAG_OFFLINE);

uint8 categoryId = GetRealmCategoryIdByBuildAndZone(_build, RealmZone(i.second.timezone));

pkt << uint32(i.second.icon); // realm type
pkt << uint8(realmflags); // realmflags
pkt << name; // name
pkt << i.second.address; // address
pkt << float(i.second.populationLevel);
pkt << uint8(AmountOfCharacters);
pkt << uint8(i.second.timezone); // realm category
pkt << uint8(categoryId); // realm category
pkt << uint8(0x00); // unk, may be realm number/id?
}

Expand Down Expand Up @@ -971,14 +973,16 @@ void AuthSocket::LoadRealmlist(ByteBuffer& pkt, uint32 acctid, uint8 securityLev
if (!buildInfo)
realmFlags = RealmFlags(realmFlags & ~REALM_FLAG_SPECIFYBUILD);

uint8 categoryId = GetRealmCategoryIdByBuildAndZone(_build, RealmZone(i.second.timezone));

pkt << uint8(i.second.icon); // realm type (this is second column in Cfg_Configs.dbc)
pkt << uint8(lock); // flags, if 0x01, then realm locked
pkt << uint8(realmFlags); // see enum RealmFlags
pkt << i.first; // name
pkt << i.second.address; // address
pkt << float(i.second.populationLevel);
pkt << uint8(AmountOfCharacters);
pkt << uint8(i.second.timezone); // realm category (Cfg_Categories.dbc)
pkt << uint8(categoryId); // realm category (Cfg_Categories.dbc)
pkt << uint8(0x2C); // unk, may be realm number/id?

if (realmFlags & REALM_FLAG_SPECIFYBUILD)
Expand Down
19 changes: 19 additions & 0 deletions src/realmd/RealmList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,25 @@ RealmBuildInfo const* FindBuildInfo(uint16 _build)
return nullptr;
}

static const uint8 RealmCategoryIdsByRealmZoneByMajorVersion[4][MAX_REALM_ZONES] =
{
{ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // 0 - Alpha
{ 0, 1, 1, 5, 1, 1, 1, 1, 1, 2, 3, 5, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // 1 - Classic
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 0, 0, 0, 0, 0, 0 }, // 2 - TBC
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 } // 3 - WotLK
};

uint8 GetRealmCategoryIdByBuildAndZone(uint16 _build, RealmZone _realmZone)
{
if (_realmZone >= MAX_REALM_ZONES)
{
_realmZone = REALM_ZONE_DEVELOPMENT;
}

RealmBuildInfo const* buildInfo = FindBuildInfo(_build);
return buildInfo ? RealmCategoryIdsByRealmZoneByMajorVersion[buildInfo->major_version][_realmZone] : _realmZone;
}

RealmList::RealmList() : m_UpdateInterval(0), m_NextUpdateTime(time(nullptr))
{
}
Expand Down
1 change: 1 addition & 0 deletions src/realmd/RealmList.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct RealmBuildInfo
};

RealmBuildInfo const* FindBuildInfo(uint16 _build);
uint8 GetRealmCategoryIdByBuildAndZone(uint16 _build, RealmZone _realmZone);

typedef std::set<uint32> RealmBuilds;

Expand Down
46 changes: 46 additions & 0 deletions src/shared/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,52 @@ enum RealmFlags
REALM_FLAG_FULL = 0x80
};

// Used in mangosd/realmd
enum RealmZone : uint8
{
REALM_ZONE_UNKNOWN = 0, // any language
REALM_ZONE_DEVELOPMENT = 1, // any language
REALM_ZONE_UNITED_STATES = 2, // extended-Latin
REALM_ZONE_OCEANIC = 3, // extended-Latin
REALM_ZONE_LATIN_AMERICA = 4, // extended-Latin
REALM_ZONE_TOURNAMENT_5 = 5, // basic-Latin at create, any at login
REALM_ZONE_KOREA = 6, // East-Asian
REALM_ZONE_TOURNAMENT_7 = 7, // basic-Latin at create, any at login
REALM_ZONE_ENGLISH = 8, // extended-Latin
REALM_ZONE_GERMAN = 9, // extended-Latin
REALM_ZONE_FRENCH = 10, // extended-Latin
REALM_ZONE_SPANISH = 11, // extended-Latin
REALM_ZONE_RUSSIAN = 12, // Cyrillic
REALM_ZONE_TOURNAMENT_13 = 13, // basic-Latin at create, any at login
REALM_ZONE_TAIWAN = 14, // East-Asian
REALM_ZONE_TOURNAMENT_15 = 15, // basic-Latin at create, any at login
REALM_ZONE_CHINA = 16, // East-Asian
REALM_ZONE_CN1 = 17, // basic-Latin at create, any at login
REALM_ZONE_CN2 = 18, // basic-Latin at create, any at login
REALM_ZONE_CN3 = 19, // basic-Latin at create, any at login
REALM_ZONE_CN4 = 20, // basic-Latin at create, any at login
REALM_ZONE_CN5 = 21, // basic-Latin at create, any at login
REALM_ZONE_CN6 = 22, // basic-Latin at create, any at login
REALM_ZONE_CN7 = 23, // basic-Latin at create, any at login
REALM_ZONE_CN8 = 24, // basic-Latin at create, any at login
REALM_ZONE_TOURNAMENT_25 = 25, // basic-Latin at create, any at login
REALM_ZONE_TEST_SERVER = 26, // any language
REALM_ZONE_TOURNAMENT_27 = 27, // basic-Latin at create, any at login
REALM_ZONE_QA_SERVER = 28, // any language
REALM_ZONE_CN9 = 29, // basic-Latin at create, any at login
REALM_ZONE_TEST_SERVER_2 = 30, // any language
// in 3.x
REALM_ZONE_CN10 = 31, // basic-Latin at create, any at login
REALM_ZONE_CTC = 32,
REALM_ZONE_CNC = 33,
REALM_ZONE_CN1_4 = 34, // basic-Latin at create, any at login
REALM_ZONE_CN2_6_9 = 35, // basic-Latin at create, any at login
REALM_ZONE_CN3_7 = 36, // basic-Latin at create, any at login
REALM_ZONE_CN5_8 = 37 // basic-Latin at create, any at login
};

#define MAX_REALM_ZONES 38

// operator new[] based version of strdup() function! Release memory by using operator delete[] !
inline char* mangos_strdup(const char* source)
{
Expand Down

0 comments on commit 55fbc8e

Please sign in to comment.