diff options
Diffstat (limited to 'src/server')
41 files changed, 830 insertions, 495 deletions
diff --git a/src/server/bnetserver/Server/Session.cpp b/src/server/bnetserver/Server/Session.cpp index c94ee6e3e56..46fd1d1479a 100644 --- a/src/server/bnetserver/Server/Session.cpp +++ b/src/server/bnetserver/Server/Session.cpp @@ -625,7 +625,7 @@ uint32 Battlenet::Session::GetLastCharPlayed(std::unordered_map<std::string, Var auto lastPlayerChar = _gameAccountInfo->LastPlayedCharacters.find(subRegion->string_value()); if (lastPlayerChar != _gameAccountInfo->LastPlayedCharacters.end()) { - std::vector<uint8> compressed = sRealmList->GetRealmEntryJSON(lastPlayerChar->second.RealmId, _build); + std::vector<uint8> compressed = sRealmList->GetRealmEntryJSON(lastPlayerChar->second.RealmId, _build, _gameAccountInfo->SecurityLevel); if (compressed.empty()) return ERROR_UTIL_SERVER_FAILED_TO_SERIALIZE_RESPONSE; @@ -662,7 +662,7 @@ uint32 Battlenet::Session::GetRealmList(std::unordered_map<std::string, Variant if (Variant const* subRegion = GetParam(params, "Command_RealmListRequest_v1")) subRegionId = subRegion->string_value(); - std::vector<uint8> compressed = sRealmList->GetRealmList(_build, subRegionId); + std::vector<uint8> compressed = sRealmList->GetRealmList(_build, _gameAccountInfo->SecurityLevel, subRegionId); if (compressed.empty()) return ERROR_UTIL_SERVER_FAILED_TO_SERIALIZE_RESPONSE; @@ -698,7 +698,7 @@ uint32 Battlenet::Session::JoinRealm(std::unordered_map<std::string, Variant con { if (Variant const* realmAddress = GetParam(params, "Param_RealmAddress")) return sRealmList->JoinRealm(realmAddress->uint_value(), _build, GetRemoteIpAddress(), _clientSecret, GetLocaleByName(_locale), - _os, _timezoneOffset, _gameAccountInfo->Name, response); + _os, _timezoneOffset, _gameAccountInfo->Name, _gameAccountInfo->SecurityLevel, response); return ERROR_WOW_SERVICES_INVALID_JOIN_TICKET; } diff --git a/src/server/database/Database/Implementation/LoginDatabase.cpp b/src/server/database/Database/Implementation/LoginDatabase.cpp index 1b12b4a98ba..c916a0ac458 100644 --- a/src/server/database/Database/Implementation/LoginDatabase.cpp +++ b/src/server/database/Database/Implementation/LoginDatabase.cpp @@ -24,6 +24,7 @@ void LoginDatabaseConnection::DoPrepareStatements() m_stmts.resize(MAX_LOGINDATABASE_STATEMENTS); PrepareStatement(LOGIN_SEL_REALMLIST, "SELECT id, name, address, localAddress, port, icon, flag, timezone, allowedSecurityLevel, population, gamebuild, Region, Battlegroup FROM realmlist WHERE flag <> 3 ORDER BY name", CONNECTION_SYNCH); + PrepareStatement(LOGIN_UPD_REALM_POPULATION, "UPDATE realmlist SET population = ? WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_DEL_EXPIRED_IP_BANS, "DELETE FROM ip_banned WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_EXPIRED_ACCOUNT_BANS, "UPDATE account_banned SET active = 0 WHERE active = 1 AND unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_IP_INFO, "SELECT unbandate > UNIX_TIMESTAMP() OR unbandate = bandate AS banned, NULL as country FROM ip_banned WHERE ip = ?", CONNECTION_ASYNC); @@ -39,7 +40,7 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_UPD_LOGON, "UPDATE account SET salt = ?, verifier = ? WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_ACCOUNT_ID_BY_NAME, "SELECT id FROM account WHERE username = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_ACCOUNT_LIST_BY_NAME, "SELECT id, username FROM account WHERE username = ?", CONNECTION_SYNCH); - PrepareStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME, "SELECT a.id, a.session_key_bnet, ba.last_ip, ba.locked, ba.lock_country, a.expansion, a.mutetime, ba.locale, a.recruiter, a.os, a.timezone_offset, ba.id, aa.SecurityLevel, " + PrepareStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME, "SELECT a.id, a.session_key_bnet, ba.last_ip, ba.locked, ba.lock_country, a.expansion, a.mutetime, a.client_build, a.locale, a.recruiter, a.os, a.timezone_offset, ba.id, aa.SecurityLevel, " "bab.unbandate > UNIX_TIMESTAMP() OR bab.unbandate = bab.bandate, ab.unbandate > UNIX_TIMESTAMP() OR ab.unbandate = ab.bandate, r.id " "FROM account a LEFT JOIN account r ON a.id = r.recruiter LEFT JOIN battlenet_accounts ba ON a.battlenet_account = ba.id " "LEFT JOIN account_access aa ON a.id = aa.AccountID AND aa.RealmID IN (-1, ?) LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id LEFT JOIN account_banned ab ON a.id = ab.id AND ab.active = 1 " @@ -88,7 +89,6 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_SEL_ACCOUNT_WHOIS, "SELECT username, email, last_ip FROM account WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_LAST_ATTEMPT_IP, "SELECT last_attempt_ip FROM account WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_LAST_IP, "SELECT last_ip FROM account WHERE id = ?", CONNECTION_SYNCH); - PrepareStatement(LOGIN_SEL_REALMLIST_SECURITY_LEVEL, "SELECT allowedSecurityLevel from realmlist WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_DEL_ACCOUNT, "DELETE FROM account WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_AUTOBROADCAST, "SELECT id, weight, text FROM autobroadcast WHERE realmid = ? OR realmid = -1", CONNECTION_SYNCH); PrepareStatement(LOGIN_GET_EMAIL_BY_ID, "SELECT email FROM account WHERE id = ?", CONNECTION_SYNCH); @@ -129,7 +129,7 @@ void LoginDatabaseConnection::DoPrepareStatements() " FROM battlenet_accounts ba LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id LEFT JOIN account a ON ba.id = a.battlenet_account" " LEFT JOIN account_banned ab ON a.id = ab.id AND ab.active = 1 LEFT JOIN account_access aa ON a.id = aa.AccountID AND aa.RealmID = -1 WHERE ba.LoginTicket = ? ORDER BY a.id", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_BNET_LAST_LOGIN_INFO, "UPDATE battlenet_accounts SET last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ? WHERE id = ?", CONNECTION_ASYNC); - PrepareStatement(LOGIN_UPD_BNET_GAME_ACCOUNT_LOGIN_INFO, "UPDATE account SET session_key_bnet = ?, last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ?, timezone_offset = ? WHERE username = ?", CONNECTION_SYNCH); + PrepareStatement(LOGIN_UPD_BNET_GAME_ACCOUNT_LOGIN_INFO, "UPDATE account SET session_key_bnet = ?, last_ip = ?, last_login = NOW(), client_build = ?, locale = ?, failed_logins = 0, os = ?, timezone_offset = ? WHERE username = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_BNET_CHARACTER_COUNTS_BY_ACCOUNT_ID, "SELECT rc.acctid, rc.numchars, r.id, r.Region, r.Battlegroup FROM realmcharacters rc INNER JOIN realmlist r ON rc.realmid = r.id WHERE rc.acctid = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_BNET_CHARACTER_COUNTS_BY_BNET_ID, "SELECT rc.acctid, rc.numchars, r.id, r.Region, r.Battlegroup FROM realmcharacters rc INNER JOIN realmlist r ON rc.realmid = r.id LEFT JOIN account a ON rc.acctid = a.id WHERE a.battlenet_account = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_BNET_LAST_PLAYER_CHARACTERS, "SELECT lpc.accountId, lpc.region, lpc.battlegroup, lpc.realmId, lpc.characterName, lpc.characterGUID, lpc.lastPlayedTime FROM account_last_played_character lpc LEFT JOIN account a ON lpc.accountId = a.id WHERE a.battlenet_account = ?", CONNECTION_ASYNC); @@ -162,7 +162,7 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_REP_ACCOUNT_TOYS, "REPLACE INTO battlenet_account_toys (accountId, itemId, isFavourite, hasFanfare) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); // Battle Pets - PrepareStatement(LOGIN_SEL_BATTLE_PETS, "SELECT bp.guid, bp.species, bp.breed, bp.displayId, bp.level, bp.exp, bp.health, bp.quality, bp.flags, bp.name, bp.nameTimestamp, bp.owner, dn.genitive, dn.dative, dn.accusative, dn.instrumental, dn.prepositional FROM battle_pets bp LEFT JOIN battle_pet_declinedname dn ON bp.guid = dn.guid WHERE bp.battlenetAccountId = ? AND (bp.ownerRealmId IS NULL OR bp.ownerRealmId = ?)", CONNECTION_ASYNC); + PrepareStatement(LOGIN_SEL_BATTLE_PETS, "SELECT bp.guid, bp.species, bp.breed, bp.displayId, bp.level, bp.exp, bp.health, bp.quality, bp.flags, bp.name, bp.nameTimestamp, bp.owner, bp.ownerRealmId, dn.genitive, dn.dative, dn.accusative, dn.instrumental, dn.prepositional FROM battle_pets bp LEFT JOIN battle_pet_declinedname dn ON bp.guid = dn.guid WHERE bp.battlenetAccountId = ? AND (bp.ownerRealmId IS NULL OR bp.ownerRealmId = ?)", CONNECTION_ASYNC); PrepareStatement(LOGIN_INS_BATTLE_PETS, "INSERT INTO battle_pets (guid, battlenetAccountId, species, breed, displayId, level, exp, health, quality, flags, name, nameTimestamp, owner, ownerRealmId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(LOGIN_DEL_BATTLE_PETS, "DELETE FROM battle_pets WHERE battlenetAccountId = ? AND guid = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_DEL_BATTLE_PETS_BY_OWNER, "DELETE FROM battle_pets WHERE owner = ? AND ownerRealmId = ?", CONNECTION_ASYNC); diff --git a/src/server/database/Database/Implementation/LoginDatabase.h b/src/server/database/Database/Implementation/LoginDatabase.h index 9fa77877cbd..e03fd277e02 100644 --- a/src/server/database/Database/Implementation/LoginDatabase.h +++ b/src/server/database/Database/Implementation/LoginDatabase.h @@ -29,6 +29,7 @@ enum LoginDatabaseStatements : uint32 */ LOGIN_SEL_REALMLIST, + LOGIN_UPD_REALM_POPULATION, LOGIN_DEL_EXPIRED_IP_BANS, LOGIN_UPD_EXPIRED_ACCOUNT_BANS, LOGIN_SEL_IP_INFO, @@ -86,7 +87,6 @@ enum LoginDatabaseStatements : uint32 LOGIN_SEL_ACCOUNT_ACCESS_SECLEVEL_TEST, LOGIN_SEL_ACCOUNT_ACCESS, LOGIN_SEL_ACCOUNT_WHOIS, - LOGIN_SEL_REALMLIST_SECURITY_LEVEL, LOGIN_DEL_ACCOUNT, LOGIN_SEL_AUTOBROADCAST, LOGIN_SEL_LAST_ATTEMPT_IP, diff --git a/src/server/game/Accounts/AccountMgr.cpp b/src/server/game/Accounts/AccountMgr.cpp index 113e81153ba..2055bf437c6 100644 --- a/src/server/game/Accounts/AccountMgr.cpp +++ b/src/server/game/Accounts/AccountMgr.cpp @@ -22,11 +22,10 @@ #include "Log.h" #include "ObjectAccessor.h" #include "Player.h" -#include "Realm.h" +#include "RealmList.h" #include "ScriptMgr.h" #include "SRP6.h" #include "Util.h" -#include "World.h" #include "WorldSession.h" using AccountSRP6 = Trinity::Crypto::SRP::GruntSRP6; @@ -503,7 +502,7 @@ void AccountMgr::LoadRBAC() while (result->NextRow()); TC_LOG_DEBUG("rbac", "AccountMgr::LoadRBAC: Loading default permissions"); - result = LoginDatabase.PQuery("SELECT secId, permissionId FROM rbac_default_permissions WHERE (realmId = {} OR realmId = -1) ORDER BY secId ASC", realm.Id.Realm); + result = LoginDatabase.PQuery("SELECT secId, permissionId FROM rbac_default_permissions WHERE (realmId = {} OR realmId = -1) ORDER BY secId ASC", sRealmList->GetCurrentRealmId().Realm); if (!result) { TC_LOG_INFO("server.loading", ">> Loaded 0 default permission definitions. DB table `rbac_default_permissions` is empty."); diff --git a/src/server/game/Achievements/CriteriaHandler.cpp b/src/server/game/Achievements/CriteriaHandler.cpp index 4f70a7986e0..97d43ac2140 100644 --- a/src/server/game/Achievements/CriteriaHandler.cpp +++ b/src/server/game/Achievements/CriteriaHandler.cpp @@ -1880,9 +1880,14 @@ bool CriteriaHandler::ModifierSatisfied(ModifierTreeEntry const* modifier, uint6 return false; break; case ModifierTreeType::ClientVersionEqualOrLessThan: // 33 - if (reqValue < sRealmList->GetMinorMajorBugfixVersionForBuild(realm.Build)) + { + std::shared_ptr<Realm const> currentRealm = sRealmList->GetCurrentRealm(); + if (!currentRealm) + return false; + if (reqValue < sRealmList->GetMinorMajorBugfixVersionForBuild(currentRealm->Build)) return false; break; + } case ModifierTreeType::BattlePetTeamLevel: // 34 for (WorldPackets::BattlePet::BattlePetSlot const& slot : referencePlayer->GetSession()->GetBattlePetMgr()->GetSlots()) if (slot.Pet.Level < reqValue) diff --git a/src/server/game/BattlePets/BattlePetMgr.cpp b/src/server/game/BattlePets/BattlePetMgr.cpp index f153f7d4138..d42a668b12f 100644 --- a/src/server/game/BattlePets/BattlePetMgr.cpp +++ b/src/server/game/BattlePets/BattlePetMgr.cpp @@ -27,7 +27,7 @@ #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" -#include "Realm.h" +#include "RealmList.h" #include "Util.h" #include "World.h" #include "WorldSession.h" @@ -290,18 +290,19 @@ void BattlePetMgr::LoadFromDB(PreparedQueryResult pets, PreparedQueryResult slot pet.NameTimestamp = fields[10].GetInt64(); pet.PacketInfo.CreatureID = speciesEntry->CreatureID; - if (!fields[12].IsNull()) + if (!fields[13].IsNull()) { pet.DeclinedName = std::make_unique<DeclinedName>(); for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i) - pet.DeclinedName->name[i] = fields[12 + i].GetString(); + pet.DeclinedName->name[i] = fields[13 + i].GetString(); } if (!ownerGuid.IsEmpty()) { pet.PacketInfo.OwnerInfo.emplace(); pet.PacketInfo.OwnerInfo->Guid = ownerGuid; - pet.PacketInfo.OwnerInfo->PlayerVirtualRealm = pet.PacketInfo.OwnerInfo->PlayerNativeRealm = GetVirtualRealmAddress(); + if (std::shared_ptr<Realm const> ownerRealm = sRealmList->GetRealm(fields[12].GetInt32())) + pet.PacketInfo.OwnerInfo->PlayerVirtualRealm = pet.PacketInfo.OwnerInfo->PlayerNativeRealm = ownerRealm->Id.GetAddress(); } pet.SaveInfo = BATTLE_PET_UNCHANGED; @@ -353,7 +354,7 @@ void BattlePetMgr::SaveToDB(LoginDatabaseTransaction trans) if (itr->second.PacketInfo.OwnerInfo) { stmt->setInt64(12, itr->second.PacketInfo.OwnerInfo->Guid.GetCounter()); - stmt->setInt32(13, realm.Id.Realm); + stmt->setInt32(13, sRealmList->GetCurrentRealmId().Realm); } else { diff --git a/src/server/game/BlackMarket/BlackMarketMgr.cpp b/src/server/game/BlackMarket/BlackMarketMgr.cpp index 59ebe4555d3..7a782558180 100644 --- a/src/server/game/BlackMarket/BlackMarketMgr.cpp +++ b/src/server/game/BlackMarket/BlackMarketMgr.cpp @@ -29,7 +29,7 @@ #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" -#include "Realm.h" +#include "RealmList.h" #include "StringConvert.h" #include "World.h" #include "WorldSession.h" @@ -285,7 +285,7 @@ void BlackMarketMgr::SendAuctionWonMail(BlackMarketEntry* entry, CharacterDataba if (!bidderAccId) // Account exists return; - logGmTrade = AccountMgr::HasPermission(bidderAccId, rbac::RBAC_PERM_LOG_GM_TRADE, realm.Id.Realm); + logGmTrade = AccountMgr::HasPermission(bidderAccId, rbac::RBAC_PERM_LOG_GM_TRADE, sRealmList->GetCurrentRealmId().Realm); if (logGmTrade && !sCharacterCache->GetCharacterNameByGuid(bidderGuid, bidderName)) bidderName = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN); diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index 7b05b344f65..ea06221f36d 100644 --- a/src/server/game/Chat/Channels/ChannelMgr.cpp +++ b/src/server/game/Chat/Channels/ChannelMgr.cpp @@ -22,7 +22,7 @@ #include "DB2Stores.h" #include "Log.h" #include "Player.h" -#include "Realm.h" +#include "RealmList.h" #include "World.h" #include "WorldSession.h" @@ -286,9 +286,10 @@ ObjectGuid ChannelMgr::CreateBuiltinChannelGuid(uint32 channelId, AreaTableEntry zoneId = zoneEntry->ID; if (channelEntry->GetFlags().HasFlag(ChatChannelFlags::GlobalForTournament)) - if (Cfg_CategoriesEntry const* category = sCfgCategoriesStore.LookupEntry(realm.Timezone)) - if (category->GetFlags().HasFlag(CfgCategoriesFlags::Tournament)) - zoneId = 0; + if (std::shared_ptr<Realm const> currentRealm = sRealmList->GetCurrentRealm()) + if (Cfg_CategoriesEntry const* category = sCfgCategoriesStore.LookupEntry(currentRealm->Timezone)) + if (category->GetFlags().HasFlag(CfgCategoriesFlags::Tournament)) + zoneId = 0; return ObjectGuid::Create<HighGuid::ChatChannel>(true, channelEntry->GetFlags().HasFlag(ChatChannelFlags::LinkedChannel), zoneId, _team == ALLIANCE ? 3 : 5, channelId); } diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 832d14631bc..4255cc1daad 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -29,7 +29,7 @@ #include "ObjectMgr.h" #include "Optional.h" #include "Player.h" -#include "Realm.h" +#include "RealmList.h" #include "StringConvert.h" #include "World.h" #include "WorldSession.h" @@ -95,7 +95,7 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac if (target) target_sec = target->GetSecurity(); else if (target_account) - target_sec = AccountMgr::GetSecurity(target_account, realm.Id.Realm); + target_sec = AccountMgr::GetSecurity(target_account, sRealmList->GetCurrentRealmId().Realm); else return true; // caller must report error for (target == nullptr && target_account == 0) diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 710bfec570c..357e0be46e4 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -43,7 +43,7 @@ #include "PhasingHandler.h" #include "Player.h" #include "RaceMask.h" -#include "Realm.h" +#include "RealmList.h" #include "ReputationMgr.h" #include "ScriptMgr.h" #include "Spell.h" @@ -3328,7 +3328,7 @@ static int32(* const WorldStateExpressionFunctions[WSE_FUNCTION_MAX])(Map const* // WSE_FUNCTION_REGION [](Map const* /*map*/, uint32 /*arg1*/, uint32 /*arg2*/) -> int32 { - return realm.Id.Region; + return sRealmList->GetCurrentRealmId().Region; }, // WSE_FUNCTION_CLOCK_HOUR @@ -3376,7 +3376,7 @@ static int32(* const WorldStateExpressionFunctions[WSE_FUNCTION_MAX])(Map const* { time_t now = GameTime::GetGameTime(); uint32 raidOrigin = 1135695600; - if (Cfg_RegionsEntry const* region = sCfgRegionsStore.LookupEntry(realm.Id.Region)) + if (Cfg_RegionsEntry const* region = sCfgRegionsStore.LookupEntry(sRealmList->GetCurrentRealmId().Region)) raidOrigin = region->Raidorigin; return (now - raidOrigin) / WEEK; diff --git a/src/server/game/Entities/Object/ObjectGuid.cpp b/src/server/game/Entities/Object/ObjectGuid.cpp index 4b3c661ccaa..0c59aa0fe52 100644 --- a/src/server/game/Entities/Object/ObjectGuid.cpp +++ b/src/server/game/Entities/Object/ObjectGuid.cpp @@ -20,7 +20,7 @@ #include "Errors.h" #include "Hash.h" #include "Log.h" -#include "Realm.h" +#include "RealmList.h" #include "Util.h" #include "World.h" #include <charconv> @@ -815,7 +815,7 @@ static inline uint32 GetRealmIdForObjectGuid(uint32 realmId) if (realmId) return realmId; - return realm.Id.Realm; + return sRealmList->GetCurrentRealmId().Realm; } ObjectGuid ObjectGuidFactory::CreateNull() diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index cb5dc78020b..e455efcfb74 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -3913,12 +3913,12 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_BATTLE_PET_DECLINED_NAME_BY_OWNER); loginStmt->setInt64(0, guid); - loginStmt->setInt32(1, realm.Id.Realm); + loginStmt->setInt32(1, sRealmList->GetCurrentRealmId().Realm); loginTransaction->Append(loginStmt); loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_BATTLE_PETS_BY_OWNER); loginStmt->setInt64(0, guid); - loginStmt->setInt32(1, realm.Id.Realm); + loginStmt->setInt32(1, sRealmList->GetCurrentRealmId().Realm); loginTransaction->Append(loginStmt); Corpse::DeleteFromDB(playerguid, trans); @@ -19070,7 +19070,10 @@ void Player::SaveToDB(LoginDatabaseTransaction loginTransaction, CharacterDataba stmt->setString(index++, ss.str()); stmt->setUInt8(index++, m_activePlayerData->MultiActionBars); - stmt->setUInt32(index++, sRealmList->GetMinorMajorBugfixVersionForBuild(realm.Build)); + if (std::shared_ptr<Realm const> currentRealm = sRealmList->GetCurrentRealm()) + stmt->setUInt32(index++, sRealmList->GetMinorMajorBugfixVersionForBuild(currentRealm->Build)); + else + stmt->setUInt32(index++, 0); } else { @@ -19213,7 +19216,10 @@ void Player::SaveToDB(LoginDatabaseTransaction loginTransaction, CharacterDataba stmt->setUInt32(index++, GetHonorLevel()); stmt->setUInt8(index++, m_activePlayerData->RestInfo[REST_TYPE_HONOR].StateID); stmt->setFloat(index++, finiteAlways(_restMgr->GetRestBonus(REST_TYPE_HONOR))); - stmt->setUInt32(index++, sRealmList->GetMinorMajorBugfixVersionForBuild(realm.Build)); + if (std::shared_ptr<Realm const> currentRealm = sRealmList->GetCurrentRealm()) + stmt->setUInt32(index++, sRealmList->GetMinorMajorBugfixVersionForBuild(currentRealm->Build)); + else + stmt->setUInt32(index++, 0); // Index stmt->setUInt64(index, GetGUID().GetCounter()); @@ -19273,17 +19279,19 @@ void Player::SaveToDB(LoginDatabaseTransaction loginTransaction, CharacterDataba GetSession()->GetCollectionMgr()->SaveAccountItemAppearances(loginTransaction); GetSession()->GetCollectionMgr()->SaveAccountTransmogIllusions(loginTransaction); + Battlenet::RealmHandle currentRealmId = sRealmList->GetCurrentRealmId(); + LoginDatabasePreparedStatement* loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_BNET_LAST_PLAYER_CHARACTERS); loginStmt->setUInt32(0, GetSession()->GetAccountId()); - loginStmt->setUInt8(1, realm.Id.Region); - loginStmt->setUInt8(2, realm.Id.Site); + loginStmt->setUInt8(1, currentRealmId.Region); + loginStmt->setUInt8(2, currentRealmId.Site); loginTransaction->Append(loginStmt); loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_BNET_LAST_PLAYER_CHARACTERS); loginStmt->setUInt32(0, GetSession()->GetAccountId()); - loginStmt->setUInt8(1, realm.Id.Region); - loginStmt->setUInt8(2, realm.Id.Site); - loginStmt->setUInt32(3, realm.Id.Realm); + loginStmt->setUInt8(1, currentRealmId.Region); + loginStmt->setUInt8(2, currentRealmId.Site); + loginStmt->setUInt32(3, currentRealmId.Realm); loginStmt->setString(4, GetName()); loginStmt->setUInt64(5, GetGUID().GetCounter()); loginStmt->setUInt32(6, GameTime::GetGameTime()); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index ed782815fd3..d13f4ace139 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -52,7 +52,7 @@ #include "QueryPackets.h" #include "QuestDef.h" #include "Random.h" -#include "Realm.h" +#include "RealmList.h" #include "ReputationMgr.h" #include "ScriptMgr.h" #include "ScriptReloadMgr.h" @@ -8728,8 +8728,9 @@ bool ObjectMgr::IsReservedName(std::string_view name) const static EnumFlag<CfgCategoriesCharsets> GetRealmLanguageType(bool create) { - if (Cfg_CategoriesEntry const* category = sCfgCategoriesStore.LookupEntry(realm.Timezone)) - return create ? category->GetCreateCharsetMask() : category->GetExistingCharsetMask(); + if (std::shared_ptr<Realm const> currentRealm = sRealmList->GetCurrentRealm()) + if (Cfg_CategoriesEntry const* category = sCfgCategoriesStore.LookupEntry(currentRealm->Timezone)) + return create ? category->GetCreateCharsetMask() : category->GetExistingCharsetMask(); return create ? CfgCategoriesCharsets::English : CfgCategoriesCharsets::Any; // basic-Latin at create, any at login } diff --git a/src/server/game/Handlers/AuthHandler.cpp b/src/server/game/Handlers/AuthHandler.cpp index 13db0718450..7af2a1e46fa 100644 --- a/src/server/game/Handlers/AuthHandler.cpp +++ b/src/server/game/Handlers/AuthHandler.cpp @@ -24,7 +24,7 @@ #include "GameTime.h" #include "ObjectMgr.h" #include "RBAC.h" -#include "Realm.h" +#include "RealmList.h" #include "SystemPackets.h" #include "Timezone.h" #include "World.h" @@ -40,11 +40,14 @@ void WorldSession::SendAuthResponse(uint32 code, bool queued, uint32 queuePos) response.SuccessInfo->ActiveExpansionLevel = GetExpansion(); response.SuccessInfo->AccountExpansionLevel = GetAccountExpansion(); - response.SuccessInfo->VirtualRealmAddress = realm.Id.GetAddress(); response.SuccessInfo->Time = int32(GameTime::GetGameTime()); // Send current home realm. Also there is no need to send it later in realm queries. - response.SuccessInfo->VirtualRealms.emplace_back(realm.Id.GetAddress(), true, false, realm.Name, realm.NormalizedName); + if (std::shared_ptr<Realm const> currentRealm = sRealmList->GetCurrentRealm()) + { + response.SuccessInfo->VirtualRealmAddress = currentRealm->Id.GetAddress(); + response.SuccessInfo->VirtualRealms.emplace_back(currentRealm->Id.GetAddress(), true, false, currentRealm->Name, currentRealm->NormalizedName); + } if (HasPermission(rbac::RBAC_PERM_USE_CHARACTER_TEMPLATES)) for (auto&& templ : sCharacterTemplateDataStore->GetCharacterTemplates()) diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 55be2545110..17dcbefcc86 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -55,7 +55,7 @@ #include "PlayerDump.h" #include "QueryHolder.h" #include "QueryPackets.h" -#include "Realm.h" +#include "RealmList.h" #include "ReputationMgr.h" #include "ScriptMgr.h" #include "SocialMgr.h" @@ -901,7 +901,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_REP_REALM_CHARACTERS); stmt->setUInt32(0, createInfo->CharCount); stmt->setUInt32(1, GetAccountId()); - stmt->setUInt32(2, realm.Id.Realm); + stmt->setUInt32(2, sRealmList->GetCurrentRealmId().Realm); trans->Append(stmt); LoginDatabase.CommitTransaction(trans); diff --git a/src/server/game/Handlers/HotfixHandler.cpp b/src/server/game/Handlers/HotfixHandler.cpp index 54e70d3884e..82c741f40bc 100644 --- a/src/server/game/Handlers/HotfixHandler.cpp +++ b/src/server/game/Handlers/HotfixHandler.cpp @@ -61,7 +61,7 @@ void WorldSession::HandleDBQueryBulk(WorldPackets::Hotfix::DBQueryBulk& dbQuery) void WorldSession::SendAvailableHotfixes() { WorldPackets::Hotfix::AvailableHotfixes availableHotfixes; - availableHotfixes.VirtualRealmAddress = realm.Id.GetAddress(); + availableHotfixes.VirtualRealmAddress = GetVirtualRealmAddress(); for (auto const& [pushId, push] : sDB2Manager.GetHotfixData()) { diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index 4bcab4d2074..c848cc67c7d 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -321,12 +321,13 @@ void WorldSession::HandleQueryRealmName(WorldPackets::Query::QueryRealmName& que WorldPackets::Query::RealmQueryResponse realmQueryResponse; realmQueryResponse.VirtualRealmAddress = queryRealmName.VirtualRealmAddress; - Battlenet::RealmHandle realmHandle(queryRealmName.VirtualRealmAddress); - if (sRealmList->GetRealmNames(realmHandle, &realmQueryResponse.NameInfo.RealmNameActual, &realmQueryResponse.NameInfo.RealmNameNormalized)) + if (std::shared_ptr<Realm const> realm = sRealmList->GetRealm(queryRealmName.VirtualRealmAddress)) { realmQueryResponse.LookupState = RESPONSE_SUCCESS; realmQueryResponse.NameInfo.IsInternalRealm = false; realmQueryResponse.NameInfo.IsLocal = queryRealmName.VirtualRealmAddress == GetVirtualRealmAddress(); + realmQueryResponse.NameInfo.RealmNameActual = realm->Name; + realmQueryResponse.NameInfo.RealmNameNormalized = realm->NormalizedName; } else realmQueryResponse.LookupState = RESPONSE_FAILURE; diff --git a/src/server/game/Handlers/SocialHandler.cpp b/src/server/game/Handlers/SocialHandler.cpp index 02e381e2be6..16dc1421da4 100644 --- a/src/server/game/Handlers/SocialHandler.cpp +++ b/src/server/game/Handlers/SocialHandler.cpp @@ -25,10 +25,9 @@ #include "Player.h" #include "QueryCallback.h" #include "RBAC.h" -#include "Realm.h" +#include "RealmList.h" #include "SocialMgr.h" #include "SocialPackets.h" -#include "World.h" void WorldSession::HandleContactListOpcode(WorldPackets::Social::SendContactList& packet) { @@ -104,7 +103,7 @@ void WorldSession::HandleAddFriendOpcode(WorldPackets::Social::AddFriend& packet } // When not found, consult database - GetQueryProcessor().AddCallback(AccountMgr::GetSecurityAsync(friendCharacterInfo->AccountId, realm.Id.Realm, + GetQueryProcessor().AddCallback(AccountMgr::GetSecurityAsync(friendCharacterInfo->AccountId, sRealmList->GetCurrentRealmId().Realm, [this, continuation = std::move(processFriendRequest)](uint32 friendSecurity) { if (!AccountMgr::IsPlayerAccount(friendSecurity)) diff --git a/src/server/game/Server/Packets/PartyPackets.cpp b/src/server/game/Server/Packets/PartyPackets.cpp index fc8365dd507..2d9ffc64354 100644 --- a/src/server/game/Server/Packets/PartyPackets.cpp +++ b/src/server/game/Server/Packets/PartyPackets.cpp @@ -19,11 +19,10 @@ #include "Pet.h" #include "PhasingHandler.h" #include "Player.h" -#include "Realm.h" +#include "RealmList.h" #include "SpellAuraEffects.h" #include "SpellAuras.h" #include "Vehicle.h" -#include "World.h" #include "WorldSession.h" WorldPacket const* WorldPackets::Party::PartyCommandResult::Write() @@ -95,7 +94,8 @@ void WorldPackets::Party::PartyInvite::Initialize(Player const* inviter, int32 p ProposedRoles = proposedRoles; - InviterRealm = Auth::VirtualRealmInfo(realm.Id.GetAddress(), true, false, realm.Name, realm.NormalizedName); + if (std::shared_ptr<Realm const> realm = sRealmList->GetRealm(*inviter->m_playerData->VirtualPlayerRealm)) + InviterRealm = Auth::VirtualRealmInfo(realm->Id.GetAddress(), true, false, realm->Name, realm->NormalizedName); } void WorldPackets::Party::PartyInviteResponse::Read() diff --git a/src/server/game/Server/Protocol/PacketLog.cpp b/src/server/game/Server/Protocol/PacketLog.cpp index 595738330d3..c912114849d 100644 --- a/src/server/game/Server/Protocol/PacketLog.cpp +++ b/src/server/game/Server/Protocol/PacketLog.cpp @@ -19,9 +19,8 @@ #include "Config.h" #include "GameTime.h" #include "IpAddress.h" -#include "Realm.h" +#include "RealmList.h" #include "Timer.h" -#include "World.h" #include "WorldPacket.h" #pragma pack(push, 1) @@ -98,7 +97,10 @@ void PacketLog::Initialize() header.Signature[0] = 'P'; header.Signature[1] = 'K'; header.Signature[2] = 'T'; header.FormatVersion = 0x0301; header.SnifferId = 'T'; - header.Build = realm.Build; + if (std::shared_ptr<Realm const> currentRealm = sRealmList->GetCurrentRealm()) + header.Build = currentRealm->Build; + else + header.Build = 0; header.Locale[0] = 'e'; header.Locale[1] = 'n'; header.Locale[2] = 'U'; header.Locale[3] = 'S'; std::memset(header.SessionKey, 0, sizeof(header.SessionKey)); header.SniffStartUnixtime = GameTime::GetGameTime(); diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index d8c4d2839c9..ba3bb98d958 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -47,7 +47,7 @@ #include "QueryHolder.h" #include "Random.h" #include "RBAC.h" -#include "Realm.h" +#include "RealmList.h" #include "ScriptMgr.h" #include "SocialMgr.h" #include "WardenWin.h" @@ -106,7 +106,7 @@ bool WorldSessionFilter::Process(WorldPacket* packet) /// WorldSession constructor WorldSession::WorldSession(uint32 id, std::string&& name, uint32 battlenetAccountId, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, - std::string os, Minutes timezoneOffset, LocaleConstant locale, uint32 recruiter, bool isARecruiter): + std::string os, Minutes timezoneOffset, uint32 build, LocaleConstant locale, uint32 recruiter, bool isARecruiter): m_muteTime(mute_time), m_timeOutTime(0), AntiDOS(this), @@ -119,6 +119,7 @@ WorldSession::WorldSession(uint32 id, std::string&& name, uint32 battlenetAccoun m_accountExpansion(expansion), m_expansion(std::min<uint8>(expansion, sWorld->getIntConfig(CONFIG_EXPANSION))), _os(std::move(os)), + _clientBuild(build), _battlenetRequestToken(0), _logoutTime(0), m_inQueue(false), @@ -797,7 +798,9 @@ void WorldSession::Handle_EarlyProccess(WorldPackets::Null& null) void WorldSession::SendConnectToInstance(WorldPackets::Auth::ConnectToSerial serial) { boost::system::error_code ignored_error; - boost::asio::ip::address instanceAddress = realm.GetAddressForClient(Trinity::Net::make_address(GetRemoteAddress(), ignored_error)); + boost::asio::ip::address instanceAddress; + if (std::shared_ptr<Realm const> currentRealm = sRealmList->GetCurrentRealm()) + instanceAddress = currentRealm->GetAddressForClient(Trinity::Net::make_address(GetRemoteAddress(), ignored_error)); _instanceConnectKey.Fields.AccountId = GetAccountId(); _instanceConnectKey.Fields.ConnectionType = CONNECTION_TYPE_INSTANCE; @@ -1020,9 +1023,9 @@ void WorldSession::LoadPermissions() uint8 secLevel = GetSecurity(); TC_LOG_DEBUG("rbac", "WorldSession::LoadPermissions [AccountId: {}, Name: {}, realmId: {}, secLevel: {}]", - id, _accountName, realm.Id.Realm, secLevel); + id, _accountName, sRealmList->GetCurrentRealmId().Realm, secLevel); - _RBACData = new rbac::RBACData(id, _accountName, realm.Id.Realm, secLevel); + _RBACData = new rbac::RBACData(id, _accountName, sRealmList->GetCurrentRealmId().Realm, secLevel); _RBACData->LoadFromDB(); } @@ -1032,9 +1035,9 @@ QueryCallback WorldSession::LoadPermissionsAsync() uint8 secLevel = GetSecurity(); TC_LOG_DEBUG("rbac", "WorldSession::LoadPermissions [AccountId: {}, Name: {}, realmId: {}, secLevel: {}]", - id, _accountName, realm.Id.Realm, secLevel); + id, _accountName, sRealmList->GetCurrentRealmId().Realm, secLevel); - _RBACData = new rbac::RBACData(id, _accountName, realm.Id.Realm, secLevel); + _RBACData = new rbac::RBACData(id, _accountName, sRealmList->GetCurrentRealmId().Realm, secLevel); return _RBACData->LoadFromDBAsync(); } @@ -1097,7 +1100,7 @@ public: stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BATTLE_PETS); stmt->setUInt32(0, battlenetAccountId); - stmt->setInt32(1, realm.Id.Realm); + stmt->setInt32(1, sRealmList->GetCurrentRealmId().Realm); ok = SetPreparedQuery(BATTLE_PETS, stmt) && ok; stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BATTLE_PET_SLOTS); @@ -1226,7 +1229,7 @@ bool WorldSession::HasPermission(uint32 permission) bool hasPermission = _RBACData->HasPermission(permission); TC_LOG_DEBUG("rbac", "WorldSession::HasPermission [AccountId: {}, Name: {}, realmId: {}]", - _RBACData->GetId(), _RBACData->GetName(), realm.Id.Realm); + _RBACData->GetId(), _RBACData->GetName(), sRealmList->GetCurrentRealmId().Realm); return hasPermission; } @@ -1234,7 +1237,7 @@ bool WorldSession::HasPermission(uint32 permission) void WorldSession::InvalidateRBACData() { TC_LOG_DEBUG("rbac", "WorldSession::Invalidaterbac::RBACData [AccountId: {}, Name: {}, realmId: {}]", - _RBACData->GetId(), _RBACData->GetName(), realm.Id.Realm); + _RBACData->GetId(), _RBACData->GetName(), sRealmList->GetCurrentRealmId().Realm); delete _RBACData; _RBACData = nullptr; } diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index b2f1b06868c..49cc7721504 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -938,7 +938,7 @@ class TC_GAME_API WorldSession { public: WorldSession(uint32 id, std::string&& name, uint32 battlenetAccountId, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, - std::string os, Minutes timezoneOffset, LocaleConstant locale, uint32 recruiter, bool isARecruiter); + std::string os, Minutes timezoneOffset, uint32 build, LocaleConstant locale, uint32 recruiter, bool isARecruiter); ~WorldSession(); bool PlayerLoading() const { return !m_playerLoading.IsEmpty(); } @@ -987,6 +987,7 @@ class TC_GAME_API WorldSession uint8 GetAccountExpansion() const { return m_accountExpansion; } uint8 GetExpansion() const { return m_expansion; } std::string const& GetOS() const { return _os; } + uint32 GetClientBuild() const { return _clientBuild; } bool CanAccessAlliedRaces() const; Warden* GetWarden() { return _warden.get(); } @@ -1884,6 +1885,7 @@ class TC_GAME_API WorldSession uint8 m_accountExpansion; uint8 m_expansion; std::string _os; + uint32 _clientBuild; std::array<uint8, 32> _realmListSecret; std::unordered_map<uint32 /*realmAddress*/, uint8> _realmCharacterCounts; diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 688c8c5aed0..68783a321ae 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -616,9 +616,7 @@ struct AccountInfo bool IsLockedToIP; std::string LastIP; std::string LockCountry; - LocaleConstant Locale; bool IsBanned; - } BattleNet; struct @@ -627,6 +625,8 @@ struct AccountInfo std::array<uint8, 64> KeyData; uint8 Expansion; int64 MuteTime; + uint32 Build; + LocaleConstant Locale; uint32 Recruiter; std::string OS; Minutes TimezoneOffset; @@ -639,9 +639,9 @@ struct AccountInfo explicit AccountInfo(Field const* fields) { - // 0 1 2 3 4 5 6 7 8 9 10 11 12 - // SELECT a.id, a.session_key, ba.last_ip, ba.locked, ba.lock_country, a.expansion, a.mutetime, ba.locale, a.recruiter, a.os, a.timezone_offset, ba.id, aa.SecurityLevel, - // 13 14 15 + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 + // SELECT a.id, a.session_key, ba.last_ip, ba.locked, ba.lock_country, a.expansion, a.mutetime, a.client_build, a.locale, a.recruiter, a.os, a.timezone_offset, ba.id, aa.SecurityLevel, + // 14 15 16 // bab.unbandate > UNIX_TIMESTAMP() OR bab.unbandate = bab.bandate, ab.unbandate > UNIX_TIMESTAMP() OR ab.unbandate = ab.bandate, r.id // FROM account a LEFT JOIN battlenet_accounts ba ON a.battlenet_account = ba.id LEFT JOIN account_access aa ON a.id = aa.AccountID AND aa.RealmID IN (-1, ?) // LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id LEFT JOIN account_banned ab ON a.id = ab.id LEFT JOIN account r ON a.id = r.recruiter @@ -653,18 +653,19 @@ struct AccountInfo BattleNet.LockCountry = fields[4].GetString(); Game.Expansion = fields[5].GetUInt8(); Game.MuteTime = fields[6].GetInt64(); - BattleNet.Locale = LocaleConstant(fields[7].GetUInt8()); - Game.Recruiter = fields[8].GetUInt32(); - Game.OS = fields[9].GetString(); - Game.TimezoneOffset = Minutes(fields[10].GetInt16()); - BattleNet.Id = fields[11].GetUInt32(); - Game.Security = AccountTypes(fields[12].GetUInt8()); - BattleNet.IsBanned = fields[13].GetUInt32() != 0; - Game.IsBanned = fields[14].GetUInt32() != 0; - Game.IsRectuiter = fields[15].GetUInt32() != 0; - - if (BattleNet.Locale >= TOTAL_LOCALES) - BattleNet.Locale = LOCALE_enUS; + Game.Build = fields[7].GetUInt32(); + Game.Locale = LocaleConstant(fields[8].GetUInt8()); + Game.Recruiter = fields[9].GetUInt32(); + Game.OS = fields[10].GetString(); + Game.TimezoneOffset = Minutes(fields[11].GetInt16()); + BattleNet.Id = fields[12].GetUInt32(); + Game.Security = AccountTypes(fields[13].GetUInt8()); + BattleNet.IsBanned = fields[14].GetUInt32() != 0; + Game.IsBanned = fields[15].GetUInt32() != 0; + Game.IsRectuiter = fields[16].GetUInt32() != 0; + + if (Game.Locale >= TOTAL_LOCALES) + Game.Locale = LOCALE_enUS; } }; @@ -672,7 +673,7 @@ void WorldSocket::HandleAuthSession(std::shared_ptr<WorldPackets::Auth::AuthSess { // Get the account information from the auth database LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME); - stmt->setInt32(0, int32(realm.Id.Realm)); + stmt->setInt32(0, int32(sRealmList->GetCurrentRealmId().Realm)); stmt->setString(1, authSession->RealmJoinTicket); _queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback([this, authSession = std::move(authSession)](PreparedQueryResult result) mutable @@ -692,17 +693,17 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<WorldPackets::Auth:: return; } - RealmBuildInfo const* buildInfo = sRealmList->GetBuildInfo(realm.Build); + AccountInfo account(result->Fetch()); + + RealmBuildInfo const* buildInfo = sRealmList->GetBuildInfo(account.Game.Build); if (!buildInfo) { SendAuthResponseError(ERROR_BAD_VERSION); - TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Missing auth seed for realm build {} ({}).", realm.Build, GetRemoteIpAddress().to_string()); + TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Missing auth seed for realm build {} ({}).", account.Game.Build, GetRemoteIpAddress().to_string()); DelayedCloseSocket(); return; } - AccountInfo account(result->Fetch()); - // For hook purposes, we get Remoteaddress at this point. std::string address = GetRemoteIpAddress().to_string(); @@ -778,11 +779,11 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<WorldPackets::Auth:: return; } - if (authSession->RealmID != realm.Id.Realm) + if (authSession->RealmID != sRealmList->GetCurrentRealmId().Realm) { SendAuthResponseError(ERROR_DENIED); TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Client {} requested connecting with realm id {} but this realm has id {} set in config.", - GetRemoteIpAddress().to_string(), authSession->RealmID, realm.Id.Realm); + GetRemoteIpAddress().to_string(), authSession->RealmID, sRealmList->GetCurrentRealmId().Realm); DelayedCloseSocket(); return; } @@ -877,7 +878,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<WorldPackets::Auth:: _authed = true; _worldSession = new WorldSession(account.Game.Id, std::move(authSession->RealmJoinTicket), account.BattleNet.Id, shared_from_this(), account.Game.Security, - account.Game.Expansion, mutetime, account.Game.OS, account.Game.TimezoneOffset, account.BattleNet.Locale, account.Game.Recruiter, account.Game.IsRectuiter); + account.Game.Expansion, mutetime, account.Game.OS, account.Game.TimezoneOffset, account.Game.Build, account.Game.Locale, account.Game.Recruiter, account.Game.IsRectuiter); // Initialize Warden system only if it is enabled by config if (wardenActive) diff --git a/src/server/game/Services/ClubUtils.cpp b/src/server/game/Services/ClubUtils.cpp index 7147b2367b1..ec85e4a4a7c 100644 --- a/src/server/game/Services/ClubUtils.cpp +++ b/src/server/game/Services/ClubUtils.cpp @@ -16,10 +16,9 @@ */ #include "ClubUtils.h" -#include "Realm.h" -#include "World.h" +#include "RealmList.h" uint64 Battlenet::Services::Clubs::CreateClubMemberId(ObjectGuid guid) { - return guid.GetCounter() | (uint64(realm.Id.Realm & 0xFFF) << 48); + return guid.GetCounter() | (uint64(sRealmList->GetCurrentRealmId().Realm & 0xFFF) << 48); } diff --git a/src/server/game/Services/WorldserverGameUtilitiesService.cpp b/src/server/game/Services/WorldserverGameUtilitiesService.cpp index 63c8223c72f..94a41a8a24f 100644 --- a/src/server/game/Services/WorldserverGameUtilitiesService.cpp +++ b/src/server/game/Services/WorldserverGameUtilitiesService.cpp @@ -20,10 +20,8 @@ #include "IpAddress.h" #include "Log.h" #include "ProtobufJSON.h" -#include "Realm.h" #include "RealmList.h" #include "RealmList.pb.h" -#include "World.h" #include <zlib.h> std::unordered_map<std::string, Battlenet::Services::GameUtilitiesService::ClientRequestHandler> const Battlenet::Services::GameUtilitiesService::ClientRequestHandlers = @@ -89,7 +87,7 @@ uint32 Battlenet::Services::GameUtilitiesService::HandleRealmListRequest(std::un if (Variant const* subRegion = GetParam(params, "Command_RealmListRequest_v1")) subRegionId = subRegion->string_value(); - std::vector<uint8> compressed = sRealmList->GetRealmList(realm.Build, subRegionId); + std::vector<uint8> compressed = sRealmList->GetRealmList(_session->GetClientBuild(), _session->GetSecurity(), subRegionId); if (compressed.empty()) return ERROR_UTIL_SERVER_FAILED_TO_SERIALIZE_RESPONSE; @@ -125,8 +123,8 @@ uint32 Battlenet::Services::GameUtilitiesService::HandleRealmListRequest(std::un uint32 Battlenet::Services::GameUtilitiesService::HandleRealmJoinRequest(std::unordered_map<std::string, Variant const*> const& params, game_utilities::v1::ClientResponse* response) { if (Variant const* realmAddress = GetParam(params, "Param_RealmAddress")) - return sRealmList->JoinRealm(uint32(realmAddress->uint_value()), realm.Build, Trinity::Net::make_address(_session->GetRemoteAddress()), _session->GetRealmListSecret(), - _session->GetSessionDbcLocale(), _session->GetOS(), _session->GetTimezoneOffset(), _session->GetAccountName(), response); + return sRealmList->JoinRealm(uint32(realmAddress->uint_value()), _session->GetClientBuild(), Trinity::Net::make_address(_session->GetRemoteAddress()), _session->GetRealmListSecret(), + _session->GetSessionDbcLocale(), _session->GetOS(), _session->GetTimezoneOffset(), _session->GetAccountName(), _session->GetSecurity(), response); return ERROR_WOW_SERVICES_INVALID_JOIN_TICKET; } diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index f492880fb65..cd4986d2c32 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -81,7 +81,7 @@ #include "PlayerDump.h" #include "PoolMgr.h" #include "QuestPools.h" -#include "Realm.h" +#include "RealmList.h" #include "ScenarioMgr.h" #include "ScriptMgr.h" #include "ScriptReloadMgr.h" @@ -244,12 +244,8 @@ void World::SetClosed(bool val) void World::LoadDBAllowedSecurityLevel() { - LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_REALMLIST_SECURITY_LEVEL); - stmt->setInt32(0, int32(realm.Id.Realm)); - PreparedQueryResult result = LoginDatabase.Query(stmt); - - if (result) - SetPlayerSecurityLimit(AccountTypes(result->Fetch()->GetUInt8())); + if (std::shared_ptr<Realm const> currentRealm = sRealmList->GetCurrentRealm()) + SetPlayerSecurityLimit(currentRealm->AllowedSecurityLevel); } void World::SetPlayerSecurityLimit(AccountTypes _sec) @@ -429,7 +425,12 @@ void World::AddSession_(WorldSession* s) { float popu = (float)GetActiveSessionCount(); // updated number of users on the server popu /= pLimit; - popu *= 2; + + LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_REALM_POPULATION); + stmt->setFloat(0, popu); + stmt->setUInt32(1, sRealmList->GetCurrentRealmId().Realm); + LoginDatabase.Execute(stmt); + TC_LOG_INFO("misc", "Server Population ({}).", popu); } } @@ -1734,7 +1735,7 @@ void World::LoadConfigSettings(bool reload) /// Initialize the World bool World::SetInitialWorldSettings() { - sLog->SetRealmId(realm.Id.Realm); + sLog->SetRealmId(sRealmList->GetCurrentRealmId().Realm); ///- Server startup begin uint32 startupBegin = getMSTime(); @@ -1793,7 +1794,7 @@ bool World::SetInitialWorldSettings() uint32 server_type = IsFFAPvPRealm() ? uint32(REALM_TYPE_PVP) : getIntConfig(CONFIG_GAME_TYPE); uint32 realm_zone = getIntConfig(CONFIG_REALM_ZONE); - LoginDatabase.PExecute("UPDATE realmlist SET icon = {}, timezone = {} WHERE id = '{}'", server_type, realm_zone, realm.Id.Realm); // One-time query + LoginDatabase.PExecute("UPDATE realmlist SET icon = {}, timezone = {} WHERE id = '{}'", server_type, realm_zone, sRealmList->GetCurrentRealmId().Realm); // One-time query TC_LOG_INFO("server.loading", "Initialize data stores..."); ///- Load DB2s @@ -2422,7 +2423,7 @@ bool World::SetInitialWorldSettings() GameTime::UpdateGameTimers(); LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, uptime, revision) VALUES({}, {}, 0, '{}')", - realm.Id.Realm, uint32(GameTime::GetStartTime()), GitRevision::GetFullVersion()); // One-time query + sRealmList->GetCurrentRealmId().Realm, uint32(GameTime::GetStartTime()), GitRevision::GetFullVersion()); // One-time query m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE*IN_MILLISECONDS); m_timers[WUPDATE_AUCTIONS_PENDING].SetInterval(250); @@ -2574,7 +2575,7 @@ void World::LoadAutobroadcasts() m_Autobroadcasts.clear(); LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_AUTOBROADCAST); - stmt->setInt32(0, realm.Id.Realm); + stmt->setInt32(0, sRealmList->GetCurrentRealmId().Realm); PreparedQueryResult result = LoginDatabase.Query(stmt); if (!result) @@ -2753,7 +2754,7 @@ void World::Update(uint32 diff) stmt->setUInt32(0, tmpDiff); stmt->setUInt16(1, uint16(maxOnlinePlayers)); - stmt->setUInt32(2, realm.Id.Realm); + stmt->setUInt32(2, sRealmList->GetCurrentRealmId().Realm); stmt->setUInt32(3, uint32(GameTime::GetStartTime())); LoginDatabase.Execute(stmt); @@ -2771,7 +2772,7 @@ void World::Update(uint32 diff) stmt->setUInt32(0, getIntConfig(CONFIG_LOGDB_CLEARTIME)); stmt->setUInt32(1, uint32(GameTime::GetGameTime())); - stmt->setUInt32(2, realm.Id.Realm); + stmt->setUInt32(2, sRealmList->GetCurrentRealmId().Realm); LoginDatabase.Execute(stmt); } @@ -3535,7 +3536,7 @@ void World::_UpdateRealmCharCount(PreparedQueryResult resultCharCount) LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_REP_REALM_CHARACTERS); stmt->setUInt8(0, charCount); stmt->setUInt32(1, accountId); - stmt->setUInt32(2, realm.Id.Realm); + stmt->setUInt32(2, sRealmList->GetCurrentRealmId().Realm); trans->Append(stmt); LoginDatabase.CommitTransaction(trans); @@ -3989,11 +3990,9 @@ void World::UpdateWarModeRewardValues() sWorldStateMgr->SetValueAndSaveInDb(WS_WAR_MODE_ALLIANCE_BUFF_VALUE, 10 + (dominantFaction == TEAM_HORDE ? outnumberedFactionReward : 0), false, nullptr); } -Realm realm; - uint32 GetVirtualRealmAddress() { - return realm.Id.GetAddress(); + return sRealmList->GetCurrentRealmId().GetAddress(); } CliCommandHolder::CliCommandHolder(void* callbackArg, char const* command, Print zprint, CommandFinished commandFinished) diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 4d6ef2211f5..56892b85884 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -42,7 +42,6 @@ class Player; class WorldPacket; class WorldSession; class WorldSocket; -struct Realm; // ServerMessages.dbc enum ServerMessageType @@ -925,8 +924,6 @@ class TC_GAME_API World friend class debug_commandscript; }; -TC_GAME_API extern Realm realm; - TC_GAME_API uint32 GetVirtualRealmAddress(); #define sWorld World::instance() diff --git a/src/server/proto/RealmList/RealmList.pb.cc b/src/server/proto/RealmList/RealmList.pb.cc index c94de181531..44c27eadcd8 100644 --- a/src/server/proto/RealmList/RealmList.pb.cc +++ b/src/server/proto/RealmList/RealmList.pb.cc @@ -39,12 +39,15 @@ const ::google::protobuf::internal::GeneratedMessageReflection* const ::google::protobuf::Descriptor* RealmCharacterCountList_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* RealmCharacterCountList_reflection_ = NULL; +const ::google::protobuf::Descriptor* RealmListRAFInfo_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + RealmListRAFInfo_reflection_ = NULL; const ::google::protobuf::Descriptor* RealmEntry_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* RealmEntry_reflection_ = NULL; -const ::google::protobuf::Descriptor* RealmState_descriptor_ = NULL; +const ::google::protobuf::Descriptor* RealmListUpdatePart_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* - RealmState_reflection_ = NULL; + RealmListUpdatePart_reflection_ = NULL; const ::google::protobuf::Descriptor* RealmListUpdates_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* RealmListUpdates_reflection_ = NULL; @@ -174,7 +177,23 @@ void protobuf_AssignDesc_RealmList_2eproto() { ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(RealmCharacterCountList)); - RealmEntry_descriptor_ = file->message_type(6); + RealmListRAFInfo_descriptor_ = file->message_type(6); + static const int RealmListRAFInfo_offsets_[2] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmListRAFInfo, wowrealmaddress_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmListRAFInfo, faction_), + }; + RealmListRAFInfo_reflection_ = + new ::google::protobuf::internal::GeneratedMessageReflection( + RealmListRAFInfo_descriptor_, + RealmListRAFInfo::default_instance_, + RealmListRAFInfo_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmListRAFInfo, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmListRAFInfo, _unknown_fields_), + -1, + ::google::protobuf::DescriptorPool::generated_pool(), + ::google::protobuf::MessageFactory::generated_factory(), + sizeof(RealmListRAFInfo)); + RealmEntry_descriptor_ = file->message_type(7); static const int RealmEntry_offsets_[10] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmEntry, wowrealmaddress_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmEntry, cfgtimezonesid_), @@ -198,23 +217,24 @@ void protobuf_AssignDesc_RealmList_2eproto() { ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(RealmEntry)); - RealmState_descriptor_ = file->message_type(7); - static const int RealmState_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmState, update_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmState, deleting_), + RealmListUpdatePart_descriptor_ = file->message_type(8); + static const int RealmListUpdatePart_offsets_[3] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmListUpdatePart, wowrealmaddress_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmListUpdatePart, update_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmListUpdatePart, deleting_), }; - RealmState_reflection_ = + RealmListUpdatePart_reflection_ = new ::google::protobuf::internal::GeneratedMessageReflection( - RealmState_descriptor_, - RealmState::default_instance_, - RealmState_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmState, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmState, _unknown_fields_), + RealmListUpdatePart_descriptor_, + RealmListUpdatePart::default_instance_, + RealmListUpdatePart_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmListUpdatePart, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmListUpdatePart, _unknown_fields_), -1, ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), - sizeof(RealmState)); - RealmListUpdates_descriptor_ = file->message_type(8); + sizeof(RealmListUpdatePart)); + RealmListUpdates_descriptor_ = file->message_type(9); static const int RealmListUpdates_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmListUpdates, updates_), }; @@ -229,7 +249,7 @@ void protobuf_AssignDesc_RealmList_2eproto() { ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(RealmListUpdates)); - IPAddress_descriptor_ = file->message_type(9); + IPAddress_descriptor_ = file->message_type(10); static const int IPAddress_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(IPAddress, ip_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(IPAddress, port_), @@ -245,7 +265,7 @@ void protobuf_AssignDesc_RealmList_2eproto() { ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(IPAddress)); - RealmIPAddressFamily_descriptor_ = file->message_type(10); + RealmIPAddressFamily_descriptor_ = file->message_type(11); static const int RealmIPAddressFamily_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmIPAddressFamily, family_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmIPAddressFamily, addresses_), @@ -261,7 +281,7 @@ void protobuf_AssignDesc_RealmList_2eproto() { ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(RealmIPAddressFamily)); - RealmListServerIPAddresses_descriptor_ = file->message_type(11); + RealmListServerIPAddresses_descriptor_ = file->message_type(12); static const int RealmListServerIPAddresses_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RealmListServerIPAddresses, families_), }; @@ -301,9 +321,11 @@ void protobuf_RegisterTypes(const ::std::string&) { ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( RealmCharacterCountList_descriptor_, &RealmCharacterCountList::default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + RealmListRAFInfo_descriptor_, &RealmListRAFInfo::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( RealmEntry_descriptor_, &RealmEntry::default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - RealmState_descriptor_, &RealmState::default_instance()); + RealmListUpdatePart_descriptor_, &RealmListUpdatePart::default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( RealmListUpdates_descriptor_, &RealmListUpdates::default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( @@ -329,10 +351,12 @@ void protobuf_ShutdownFile_RealmList_2eproto() { delete RealmCharacterCountEntry_reflection_; delete RealmCharacterCountList::default_instance_; delete RealmCharacterCountList_reflection_; + delete RealmListRAFInfo::default_instance_; + delete RealmListRAFInfo_reflection_; delete RealmEntry::default_instance_; delete RealmEntry_reflection_; - delete RealmState::default_instance_; - delete RealmState_reflection_; + delete RealmListUpdatePart::default_instance_; + delete RealmListUpdatePart_reflection_; delete RealmListUpdates::default_instance_; delete RealmListUpdates_reflection_; delete IPAddress::default_instance_; @@ -369,23 +393,25 @@ void protobuf_AddDesc_RealmList_2eproto() { "almCharacterCountEntry\022\027\n\017wowRealmAddres" "s\030\001 \002(\007\022\r\n\005count\030\002 \002(\r\"S\n\027RealmCharacter" "CountList\0228\n\006counts\030\001 \003(\0132(.JSON.RealmLi" - "st.RealmCharacterCountEntry\"\377\001\n\nRealmEnt" - "ry\022\027\n\017wowRealmAddress\030\001 \002(\007\022\026\n\016cfgTimezo" - "nesID\030\002 \002(\r\022\027\n\017populationState\030\003 \002(\r\022\027\n\017" - "cfgCategoriesID\030\004 \002(\r\022.\n\007version\030\005 \002(\0132\035" - ".JSON.RealmList.ClientVersion\022\023\n\013cfgReal" - "msID\030\006 \002(\r\022\r\n\005flags\030\007 \002(\r\022\014\n\004name\030\010 \002(\t\022" - "\024\n\014cfgConfigsID\030\t \002(\r\022\026\n\016cfgLanguagesID\030" - "\n \002(\r\"J\n\nRealmState\022*\n\006update\030\001 \001(\0132\032.JS" - "ON.RealmList.RealmEntry\022\020\n\010deleting\030\002 \002(" - "\010\"\?\n\020RealmListUpdates\022+\n\007updates\030\001 \003(\0132\032" - ".JSON.RealmList.RealmState\"%\n\tIPAddress\022" - "\n\n\002ip\030\001 \002(\t\022\014\n\004port\030\002 \002(\r\"T\n\024RealmIPAddr" - "essFamily\022\016\n\006family\030\001 \002(\r\022,\n\taddresses\030\002" - " \003(\0132\031.JSON.RealmList.IPAddress\"T\n\032Realm" - "ListServerIPAddresses\0226\n\010families\030\001 \003(\0132" - "$.JSON.RealmList.RealmIPAddressFamilyB\002H" - "\002", 1401); + "st.RealmCharacterCountEntry\"<\n\020RealmList" + "RAFInfo\022\027\n\017wowRealmAddress\030\001 \002(\007\022\017\n\007fact" + "ion\030\002 \002(\r\"\377\001\n\nRealmEntry\022\027\n\017wowRealmAddr" + "ess\030\001 \002(\007\022\026\n\016cfgTimezonesID\030\002 \002(\r\022\027\n\017pop" + "ulationState\030\003 \002(\r\022\027\n\017cfgCategoriesID\030\004 " + "\002(\r\022.\n\007version\030\005 \002(\0132\035.JSON.RealmList.Cl" + "ientVersion\022\023\n\013cfgRealmsID\030\006 \002(\r\022\r\n\005flag" + "s\030\007 \002(\r\022\014\n\004name\030\010 \002(\t\022\024\n\014cfgConfigsID\030\t " + "\002(\r\022\026\n\016cfgLanguagesID\030\n \002(\r\"l\n\023RealmList" + "UpdatePart\022\027\n\017wowRealmAddress\030\001 \002(\007\022*\n\006u" + "pdate\030\002 \001(\0132\032.JSON.RealmList.RealmEntry\022" + "\020\n\010deleting\030\003 \002(\010\"H\n\020RealmListUpdates\0224\n" + "\007updates\030\001 \003(\0132#.JSON.RealmList.RealmLis" + "tUpdatePart\"%\n\tIPAddress\022\n\n\002ip\030\001 \002(\t\022\014\n\004" + "port\030\002 \002(\r\"T\n\024RealmIPAddressFamily\022\016\n\006fa" + "mily\030\001 \002(\r\022,\n\taddresses\030\002 \003(\0132\031.JSON.Rea" + "lmList.IPAddress\"T\n\032RealmListServerIPAdd" + "resses\0226\n\010families\030\001 \003(\0132$.JSON.RealmLis" + "t.RealmIPAddressFamilyB\002H\002", 1506); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "RealmList.proto", &protobuf_RegisterTypes); RealmListTicketIdentity::default_instance_ = new RealmListTicketIdentity(); @@ -394,8 +420,9 @@ void protobuf_AddDesc_RealmList_2eproto() { RealmListTicketClientInformation::default_instance_ = new RealmListTicketClientInformation(); RealmCharacterCountEntry::default_instance_ = new RealmCharacterCountEntry(); RealmCharacterCountList::default_instance_ = new RealmCharacterCountList(); + RealmListRAFInfo::default_instance_ = new RealmListRAFInfo(); RealmEntry::default_instance_ = new RealmEntry(); - RealmState::default_instance_ = new RealmState(); + RealmListUpdatePart::default_instance_ = new RealmListUpdatePart(); RealmListUpdates::default_instance_ = new RealmListUpdates(); IPAddress::default_instance_ = new IPAddress(); RealmIPAddressFamily::default_instance_ = new RealmIPAddressFamily(); @@ -406,8 +433,9 @@ void protobuf_AddDesc_RealmList_2eproto() { RealmListTicketClientInformation::default_instance_->InitAsDefaultInstance(); RealmCharacterCountEntry::default_instance_->InitAsDefaultInstance(); RealmCharacterCountList::default_instance_->InitAsDefaultInstance(); + RealmListRAFInfo::default_instance_->InitAsDefaultInstance(); RealmEntry::default_instance_->InitAsDefaultInstance(); - RealmState::default_instance_->InitAsDefaultInstance(); + RealmListUpdatePart::default_instance_->InitAsDefaultInstance(); RealmListUpdates::default_instance_->InitAsDefaultInstance(); IPAddress::default_instance_->InitAsDefaultInstance(); RealmIPAddressFamily::default_instance_->InitAsDefaultInstance(); @@ -908,6 +936,80 @@ void RealmCharacterCountList::Swap(RealmCharacterCountList* other) { // =================================================================== #ifndef _MSC_VER +const int RealmListRAFInfo::kWowRealmAddressFieldNumber; +const int RealmListRAFInfo::kFactionFieldNumber; +#endif // !_MSC_VER + +RealmListRAFInfo::RealmListRAFInfo() + : ::google::protobuf::Message() { + SharedCtor(); + // @@protoc_insertion_point(constructor:JSON.RealmList.RealmListRAFInfo) +} + +void RealmListRAFInfo::InitAsDefaultInstance() { +} + +RealmListRAFInfo::RealmListRAFInfo(const RealmListRAFInfo& from) + : ::google::protobuf::Message() { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:JSON.RealmList.RealmListRAFInfo) +} + +void RealmListRAFInfo::SharedCtor() { + _cached_size_ = 0; + wowrealmaddress_ = 0u; + faction_ = 0u; + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +RealmListRAFInfo::~RealmListRAFInfo() { + // @@protoc_insertion_point(destructor:JSON.RealmList.RealmListRAFInfo) + SharedDtor(); +} + +void RealmListRAFInfo::SharedDtor() { + if (this != default_instance_) { + } +} + +void RealmListRAFInfo::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* RealmListRAFInfo::descriptor() { + protobuf_AssignDescriptorsOnce(); + return RealmListRAFInfo_descriptor_; +} + +const RealmListRAFInfo& RealmListRAFInfo::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_RealmList_2eproto(); + return *default_instance_; +} + +RealmListRAFInfo* RealmListRAFInfo::default_instance_ = NULL; + +RealmListRAFInfo* RealmListRAFInfo::New() const { + return new RealmListRAFInfo; +} + +void RealmListRAFInfo::Swap(RealmListRAFInfo* other) { + if (other != this) { + GetReflection()->Swap(this, other);} +} + +::google::protobuf::Metadata RealmListRAFInfo::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = RealmListRAFInfo_descriptor_; + metadata.reflection = RealmListRAFInfo_reflection_; + return metadata; +} + +// =================================================================== + +#ifndef _MSC_VER const int RealmEntry::kWowRealmAddressFieldNumber; const int RealmEntry::kCfgTimezonesIDFieldNumber; const int RealmEntry::kPopulationStateFieldNumber; @@ -1004,76 +1106,78 @@ void RealmEntry::Swap(RealmEntry* other) { // =================================================================== #ifndef _MSC_VER -const int RealmState::kUpdateFieldNumber; -const int RealmState::kDeletingFieldNumber; +const int RealmListUpdatePart::kWowRealmAddressFieldNumber; +const int RealmListUpdatePart::kUpdateFieldNumber; +const int RealmListUpdatePart::kDeletingFieldNumber; #endif // !_MSC_VER -RealmState::RealmState() +RealmListUpdatePart::RealmListUpdatePart() : ::google::protobuf::Message() { SharedCtor(); - // @@protoc_insertion_point(constructor:JSON.RealmList.RealmState) + // @@protoc_insertion_point(constructor:JSON.RealmList.RealmListUpdatePart) } -void RealmState::InitAsDefaultInstance() { +void RealmListUpdatePart::InitAsDefaultInstance() { update_ = const_cast< ::JSON::RealmList::RealmEntry*>(&::JSON::RealmList::RealmEntry::default_instance()); } -RealmState::RealmState(const RealmState& from) +RealmListUpdatePart::RealmListUpdatePart(const RealmListUpdatePart& from) : ::google::protobuf::Message() { SharedCtor(); MergeFrom(from); - // @@protoc_insertion_point(copy_constructor:JSON.RealmList.RealmState) + // @@protoc_insertion_point(copy_constructor:JSON.RealmList.RealmListUpdatePart) } -void RealmState::SharedCtor() { +void RealmListUpdatePart::SharedCtor() { _cached_size_ = 0; + wowrealmaddress_ = 0u; update_ = NULL; deleting_ = false; ::memset(_has_bits_, 0, sizeof(_has_bits_)); } -RealmState::~RealmState() { - // @@protoc_insertion_point(destructor:JSON.RealmList.RealmState) +RealmListUpdatePart::~RealmListUpdatePart() { + // @@protoc_insertion_point(destructor:JSON.RealmList.RealmListUpdatePart) SharedDtor(); } -void RealmState::SharedDtor() { +void RealmListUpdatePart::SharedDtor() { if (this != default_instance_) { delete update_; } } -void RealmState::SetCachedSize(int size) const { +void RealmListUpdatePart::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } -const ::google::protobuf::Descriptor* RealmState::descriptor() { +const ::google::protobuf::Descriptor* RealmListUpdatePart::descriptor() { protobuf_AssignDescriptorsOnce(); - return RealmState_descriptor_; + return RealmListUpdatePart_descriptor_; } -const RealmState& RealmState::default_instance() { +const RealmListUpdatePart& RealmListUpdatePart::default_instance() { if (default_instance_ == NULL) protobuf_AddDesc_RealmList_2eproto(); return *default_instance_; } -RealmState* RealmState::default_instance_ = NULL; +RealmListUpdatePart* RealmListUpdatePart::default_instance_ = NULL; -RealmState* RealmState::New() const { - return new RealmState; +RealmListUpdatePart* RealmListUpdatePart::New() const { + return new RealmListUpdatePart; } -void RealmState::Swap(RealmState* other) { +void RealmListUpdatePart::Swap(RealmListUpdatePart* other) { if (other != this) { GetReflection()->Swap(this, other);} } -::google::protobuf::Metadata RealmState::GetMetadata() const { +::google::protobuf::Metadata RealmListUpdatePart::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; - metadata.descriptor = RealmState_descriptor_; - metadata.reflection = RealmState_reflection_; + metadata.descriptor = RealmListUpdatePart_descriptor_; + metadata.reflection = RealmListUpdatePart_reflection_; return metadata; } diff --git a/src/server/proto/RealmList/RealmList.pb.h b/src/server/proto/RealmList/RealmList.pb.h index a79e15cef83..56e61f22ae1 100644 --- a/src/server/proto/RealmList/RealmList.pb.h +++ b/src/server/proto/RealmList/RealmList.pb.h @@ -41,8 +41,9 @@ class ClientInformation; class RealmListTicketClientInformation; class RealmCharacterCountEntry; class RealmCharacterCountList; +class RealmListRAFInfo; class RealmEntry; -class RealmState; +class RealmListUpdatePart; class RealmListUpdates; class IPAddress; class RealmIPAddressFamily; @@ -653,6 +654,82 @@ class TC_PROTO_API RealmCharacterCountList : public ::google::protobuf::Message }; // ------------------------------------------------------------------- +class TC_PROTO_API RealmListRAFInfo : public ::google::protobuf::Message { + public: + RealmListRAFInfo(); + virtual ~RealmListRAFInfo(); + + RealmListRAFInfo(const RealmListRAFInfo& from); + + inline RealmListRAFInfo& operator=(const RealmListRAFInfo& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const RealmListRAFInfo& default_instance(); + + void Swap(RealmListRAFInfo* other); + + // implements Message ---------------------------------------------- + + RealmListRAFInfo* New() const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // required fixed32 wowRealmAddress = 1; + inline bool has_wowrealmaddress() const; + inline void clear_wowrealmaddress(); + static const int kWowRealmAddressFieldNumber = 1; + inline ::google::protobuf::uint32 wowrealmaddress() const; + inline void set_wowrealmaddress(::google::protobuf::uint32 value); + + // required uint32 faction = 2; + inline bool has_faction() const; + inline void clear_faction(); + static const int kFactionFieldNumber = 2; + inline ::google::protobuf::uint32 faction() const; + inline void set_faction(::google::protobuf::uint32 value); + + // @@protoc_insertion_point(class_scope:JSON.RealmList.RealmListRAFInfo) + private: + inline void set_has_wowrealmaddress(); + inline void clear_has_wowrealmaddress(); + inline void set_has_faction(); + inline void clear_has_faction(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::google::protobuf::uint32 _has_bits_[1]; + mutable int _cached_size_; + ::google::protobuf::uint32 wowrealmaddress_; + ::google::protobuf::uint32 faction_; + friend void TC_PROTO_API protobuf_AddDesc_RealmList_2eproto(); + friend void protobuf_AssignDesc_RealmList_2eproto(); + friend void protobuf_ShutdownFile_RealmList_2eproto(); + + void InitAsDefaultInstance(); + static RealmListRAFInfo* default_instance_; +}; +// ------------------------------------------------------------------- + class TC_PROTO_API RealmEntry : public ::google::protobuf::Message { public: RealmEntry(); @@ -816,14 +893,14 @@ class TC_PROTO_API RealmEntry : public ::google::protobuf::Message { }; // ------------------------------------------------------------------- -class TC_PROTO_API RealmState : public ::google::protobuf::Message { +class TC_PROTO_API RealmListUpdatePart : public ::google::protobuf::Message { public: - RealmState(); - virtual ~RealmState(); + RealmListUpdatePart(); + virtual ~RealmListUpdatePart(); - RealmState(const RealmState& from); + RealmListUpdatePart(const RealmListUpdatePart& from); - inline RealmState& operator=(const RealmState& from) { + inline RealmListUpdatePart& operator=(const RealmListUpdatePart& from) { CopyFrom(from); return *this; } @@ -837,13 +914,13 @@ class TC_PROTO_API RealmState : public ::google::protobuf::Message { } static const ::google::protobuf::Descriptor* descriptor(); - static const RealmState& default_instance(); + static const RealmListUpdatePart& default_instance(); - void Swap(RealmState* other); + void Swap(RealmListUpdatePart* other); // implements Message ---------------------------------------------- - RealmState* New() const; + RealmListUpdatePart* New() const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); @@ -856,24 +933,33 @@ class TC_PROTO_API RealmState : public ::google::protobuf::Message { // accessors ------------------------------------------------------- - // optional .JSON.RealmList.RealmEntry update = 1; + // required fixed32 wowRealmAddress = 1; + inline bool has_wowrealmaddress() const; + inline void clear_wowrealmaddress(); + static const int kWowRealmAddressFieldNumber = 1; + inline ::google::protobuf::uint32 wowrealmaddress() const; + inline void set_wowrealmaddress(::google::protobuf::uint32 value); + + // optional .JSON.RealmList.RealmEntry update = 2; inline bool has_update() const; inline void clear_update(); - static const int kUpdateFieldNumber = 1; + static const int kUpdateFieldNumber = 2; inline const ::JSON::RealmList::RealmEntry& update() const; inline ::JSON::RealmList::RealmEntry* mutable_update(); inline ::JSON::RealmList::RealmEntry* release_update(); inline void set_allocated_update(::JSON::RealmList::RealmEntry* update); - // required bool deleting = 2; + // required bool deleting = 3; inline bool has_deleting() const; inline void clear_deleting(); - static const int kDeletingFieldNumber = 2; + static const int kDeletingFieldNumber = 3; inline bool deleting() const; inline void set_deleting(bool value); - // @@protoc_insertion_point(class_scope:JSON.RealmList.RealmState) + // @@protoc_insertion_point(class_scope:JSON.RealmList.RealmListUpdatePart) private: + inline void set_has_wowrealmaddress(); + inline void clear_has_wowrealmaddress(); inline void set_has_update(); inline void clear_has_update(); inline void set_has_deleting(); @@ -884,13 +970,14 @@ class TC_PROTO_API RealmState : public ::google::protobuf::Message { ::google::protobuf::uint32 _has_bits_[1]; mutable int _cached_size_; ::JSON::RealmList::RealmEntry* update_; + ::google::protobuf::uint32 wowrealmaddress_; bool deleting_; friend void TC_PROTO_API protobuf_AddDesc_RealmList_2eproto(); friend void protobuf_AssignDesc_RealmList_2eproto(); friend void protobuf_ShutdownFile_RealmList_2eproto(); void InitAsDefaultInstance(); - static RealmState* default_instance_; + static RealmListUpdatePart* default_instance_; }; // ------------------------------------------------------------------- @@ -934,16 +1021,16 @@ class TC_PROTO_API RealmListUpdates : public ::google::protobuf::Message { // accessors ------------------------------------------------------- - // repeated .JSON.RealmList.RealmState updates = 1; + // repeated .JSON.RealmList.RealmListUpdatePart updates = 1; inline int updates_size() const; inline void clear_updates(); static const int kUpdatesFieldNumber = 1; - inline const ::JSON::RealmList::RealmState& updates(int index) const; - inline ::JSON::RealmList::RealmState* mutable_updates(int index); - inline ::JSON::RealmList::RealmState* add_updates(); - inline const ::google::protobuf::RepeatedPtrField< ::JSON::RealmList::RealmState >& + inline const ::JSON::RealmList::RealmListUpdatePart& updates(int index) const; + inline ::JSON::RealmList::RealmListUpdatePart* mutable_updates(int index); + inline ::JSON::RealmList::RealmListUpdatePart* add_updates(); + inline const ::google::protobuf::RepeatedPtrField< ::JSON::RealmList::RealmListUpdatePart >& updates() const; - inline ::google::protobuf::RepeatedPtrField< ::JSON::RealmList::RealmState >* + inline ::google::protobuf::RepeatedPtrField< ::JSON::RealmList::RealmListUpdatePart >* mutable_updates(); // @@protoc_insertion_point(class_scope:JSON.RealmList.RealmListUpdates) @@ -953,7 +1040,7 @@ class TC_PROTO_API RealmListUpdates : public ::google::protobuf::Message { ::google::protobuf::uint32 _has_bits_[1]; mutable int _cached_size_; - ::google::protobuf::RepeatedPtrField< ::JSON::RealmList::RealmState > updates_; + ::google::protobuf::RepeatedPtrField< ::JSON::RealmList::RealmListUpdatePart > updates_; friend void TC_PROTO_API protobuf_AddDesc_RealmList_2eproto(); friend void protobuf_AssignDesc_RealmList_2eproto(); friend void protobuf_ShutdownFile_RealmList_2eproto(); @@ -2044,6 +2131,58 @@ RealmCharacterCountList::mutable_counts() { // ------------------------------------------------------------------- +// RealmListRAFInfo + +// required fixed32 wowRealmAddress = 1; +inline bool RealmListRAFInfo::has_wowrealmaddress() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void RealmListRAFInfo::set_has_wowrealmaddress() { + _has_bits_[0] |= 0x00000001u; +} +inline void RealmListRAFInfo::clear_has_wowrealmaddress() { + _has_bits_[0] &= ~0x00000001u; +} +inline void RealmListRAFInfo::clear_wowrealmaddress() { + wowrealmaddress_ = 0u; + clear_has_wowrealmaddress(); +} +inline ::google::protobuf::uint32 RealmListRAFInfo::wowrealmaddress() const { + // @@protoc_insertion_point(field_get:JSON.RealmList.RealmListRAFInfo.wowRealmAddress) + return wowrealmaddress_; +} +inline void RealmListRAFInfo::set_wowrealmaddress(::google::protobuf::uint32 value) { + set_has_wowrealmaddress(); + wowrealmaddress_ = value; + // @@protoc_insertion_point(field_set:JSON.RealmList.RealmListRAFInfo.wowRealmAddress) +} + +// required uint32 faction = 2; +inline bool RealmListRAFInfo::has_faction() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void RealmListRAFInfo::set_has_faction() { + _has_bits_[0] |= 0x00000002u; +} +inline void RealmListRAFInfo::clear_has_faction() { + _has_bits_[0] &= ~0x00000002u; +} +inline void RealmListRAFInfo::clear_faction() { + faction_ = 0u; + clear_has_faction(); +} +inline ::google::protobuf::uint32 RealmListRAFInfo::faction() const { + // @@protoc_insertion_point(field_get:JSON.RealmList.RealmListRAFInfo.faction) + return faction_; +} +inline void RealmListRAFInfo::set_faction(::google::protobuf::uint32 value) { + set_has_faction(); + faction_ = value; + // @@protoc_insertion_point(field_set:JSON.RealmList.RealmListRAFInfo.faction) +} + +// ------------------------------------------------------------------- + // RealmEntry // required fixed32 wowRealmAddress = 1; @@ -2357,39 +2496,63 @@ inline void RealmEntry::set_cfglanguagesid(::google::protobuf::uint32 value) { // ------------------------------------------------------------------- -// RealmState +// RealmListUpdatePart -// optional .JSON.RealmList.RealmEntry update = 1; -inline bool RealmState::has_update() const { +// required fixed32 wowRealmAddress = 1; +inline bool RealmListUpdatePart::has_wowrealmaddress() const { return (_has_bits_[0] & 0x00000001u) != 0; } -inline void RealmState::set_has_update() { +inline void RealmListUpdatePart::set_has_wowrealmaddress() { _has_bits_[0] |= 0x00000001u; } -inline void RealmState::clear_has_update() { +inline void RealmListUpdatePart::clear_has_wowrealmaddress() { _has_bits_[0] &= ~0x00000001u; } -inline void RealmState::clear_update() { +inline void RealmListUpdatePart::clear_wowrealmaddress() { + wowrealmaddress_ = 0u; + clear_has_wowrealmaddress(); +} +inline ::google::protobuf::uint32 RealmListUpdatePart::wowrealmaddress() const { + // @@protoc_insertion_point(field_get:JSON.RealmList.RealmListUpdatePart.wowRealmAddress) + return wowrealmaddress_; +} +inline void RealmListUpdatePart::set_wowrealmaddress(::google::protobuf::uint32 value) { + set_has_wowrealmaddress(); + wowrealmaddress_ = value; + // @@protoc_insertion_point(field_set:JSON.RealmList.RealmListUpdatePart.wowRealmAddress) +} + +// optional .JSON.RealmList.RealmEntry update = 2; +inline bool RealmListUpdatePart::has_update() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void RealmListUpdatePart::set_has_update() { + _has_bits_[0] |= 0x00000002u; +} +inline void RealmListUpdatePart::clear_has_update() { + _has_bits_[0] &= ~0x00000002u; +} +inline void RealmListUpdatePart::clear_update() { if (update_ != NULL) update_->::JSON::RealmList::RealmEntry::Clear(); clear_has_update(); } -inline const ::JSON::RealmList::RealmEntry& RealmState::update() const { - // @@protoc_insertion_point(field_get:JSON.RealmList.RealmState.update) +inline const ::JSON::RealmList::RealmEntry& RealmListUpdatePart::update() const { + // @@protoc_insertion_point(field_get:JSON.RealmList.RealmListUpdatePart.update) return update_ != NULL ? *update_ : *default_instance_->update_; } -inline ::JSON::RealmList::RealmEntry* RealmState::mutable_update() { +inline ::JSON::RealmList::RealmEntry* RealmListUpdatePart::mutable_update() { set_has_update(); if (update_ == NULL) update_ = new ::JSON::RealmList::RealmEntry; - // @@protoc_insertion_point(field_mutable:JSON.RealmList.RealmState.update) + // @@protoc_insertion_point(field_mutable:JSON.RealmList.RealmListUpdatePart.update) return update_; } -inline ::JSON::RealmList::RealmEntry* RealmState::release_update() { +inline ::JSON::RealmList::RealmEntry* RealmListUpdatePart::release_update() { clear_has_update(); ::JSON::RealmList::RealmEntry* temp = update_; update_ = NULL; return temp; } -inline void RealmState::set_allocated_update(::JSON::RealmList::RealmEntry* update) { +inline void RealmListUpdatePart::set_allocated_update(::JSON::RealmList::RealmEntry* update) { delete update_; update_ = update; if (update) { @@ -2397,62 +2560,62 @@ inline void RealmState::set_allocated_update(::JSON::RealmList::RealmEntry* upda } else { clear_has_update(); } - // @@protoc_insertion_point(field_set_allocated:JSON.RealmList.RealmState.update) + // @@protoc_insertion_point(field_set_allocated:JSON.RealmList.RealmListUpdatePart.update) } -// required bool deleting = 2; -inline bool RealmState::has_deleting() const { - return (_has_bits_[0] & 0x00000002u) != 0; +// required bool deleting = 3; +inline bool RealmListUpdatePart::has_deleting() const { + return (_has_bits_[0] & 0x00000004u) != 0; } -inline void RealmState::set_has_deleting() { - _has_bits_[0] |= 0x00000002u; +inline void RealmListUpdatePart::set_has_deleting() { + _has_bits_[0] |= 0x00000004u; } -inline void RealmState::clear_has_deleting() { - _has_bits_[0] &= ~0x00000002u; +inline void RealmListUpdatePart::clear_has_deleting() { + _has_bits_[0] &= ~0x00000004u; } -inline void RealmState::clear_deleting() { +inline void RealmListUpdatePart::clear_deleting() { deleting_ = false; clear_has_deleting(); } -inline bool RealmState::deleting() const { - // @@protoc_insertion_point(field_get:JSON.RealmList.RealmState.deleting) +inline bool RealmListUpdatePart::deleting() const { + // @@protoc_insertion_point(field_get:JSON.RealmList.RealmListUpdatePart.deleting) return deleting_; } -inline void RealmState::set_deleting(bool value) { +inline void RealmListUpdatePart::set_deleting(bool value) { set_has_deleting(); deleting_ = value; - // @@protoc_insertion_point(field_set:JSON.RealmList.RealmState.deleting) + // @@protoc_insertion_point(field_set:JSON.RealmList.RealmListUpdatePart.deleting) } // ------------------------------------------------------------------- // RealmListUpdates -// repeated .JSON.RealmList.RealmState updates = 1; +// repeated .JSON.RealmList.RealmListUpdatePart updates = 1; inline int RealmListUpdates::updates_size() const { return updates_.size(); } inline void RealmListUpdates::clear_updates() { updates_.Clear(); } -inline const ::JSON::RealmList::RealmState& RealmListUpdates::updates(int index) const { +inline const ::JSON::RealmList::RealmListUpdatePart& RealmListUpdates::updates(int index) const { // @@protoc_insertion_point(field_get:JSON.RealmList.RealmListUpdates.updates) return updates_.Get(index); } -inline ::JSON::RealmList::RealmState* RealmListUpdates::mutable_updates(int index) { +inline ::JSON::RealmList::RealmListUpdatePart* RealmListUpdates::mutable_updates(int index) { // @@protoc_insertion_point(field_mutable:JSON.RealmList.RealmListUpdates.updates) return updates_.Mutable(index); } -inline ::JSON::RealmList::RealmState* RealmListUpdates::add_updates() { +inline ::JSON::RealmList::RealmListUpdatePart* RealmListUpdates::add_updates() { // @@protoc_insertion_point(field_add:JSON.RealmList.RealmListUpdates.updates) return updates_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::JSON::RealmList::RealmState >& +inline const ::google::protobuf::RepeatedPtrField< ::JSON::RealmList::RealmListUpdatePart >& RealmListUpdates::updates() const { // @@protoc_insertion_point(field_list:JSON.RealmList.RealmListUpdates.updates) return updates_; } -inline ::google::protobuf::RepeatedPtrField< ::JSON::RealmList::RealmState >* +inline ::google::protobuf::RepeatedPtrField< ::JSON::RealmList::RealmListUpdatePart >* RealmListUpdates::mutable_updates() { // @@protoc_insertion_point(field_mutable_list:JSON.RealmList.RealmListUpdates.updates) return &updates_; diff --git a/src/server/proto/RealmList/RealmList.proto b/src/server/proto/RealmList/RealmList.proto index c6ebc5ee2a9..aa184d46f8c 100644 --- a/src/server/proto/RealmList/RealmList.proto +++ b/src/server/proto/RealmList/RealmList.proto @@ -46,6 +46,11 @@ message RealmCharacterCountList { repeated RealmCharacterCountEntry counts = 1; } +message RealmListRAFInfo { + required fixed32 wowRealmAddress = 1; + required uint32 faction = 2; +} + message RealmEntry { required fixed32 wowRealmAddress = 1; required uint32 cfgTimezonesID = 2; @@ -59,13 +64,14 @@ message RealmEntry { required uint32 cfgLanguagesID = 10; } -message RealmState { - optional RealmEntry update = 1; - required bool deleting = 2; +message RealmListUpdatePart { + required fixed32 wowRealmAddress = 1; + optional RealmEntry update = 2; + required bool deleting = 3; } message RealmListUpdates { - repeated RealmState updates = 1; + repeated RealmListUpdatePart updates = 1; } message IPAddress { diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index d4b644ec62f..d4302e4bb0d 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -30,7 +30,7 @@ EndScriptData */ #include "Language.h" #include "ObjectAccessor.h" #include "Player.h" -#include "Realm.h" +#include "RealmList.h" #include "World.h" #include "WorldSession.h" @@ -161,7 +161,7 @@ public: ///- Get the accounts with GM Level >0 LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_GM_ACCOUNTS); stmt->setUInt8(0, uint8(SEC_MODERATOR)); - stmt->setInt32(1, int32(realm.Id.Realm)); + stmt->setInt32(1, int32(sRealmList->GetCurrentRealmId().Realm)); PreparedQueryResult result = LoginDatabase.Query(stmt); if (result) diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 15709e59205..35f3ef340d4 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -40,7 +40,7 @@ #include "ObjectMgr.h" #include "PhasingHandler.h" #include "Player.h" -#include "Realm.h" +#include "RealmList.h" #include "SpellAuras.h" #include "SpellHistory.h" #include "SpellMgr.h" @@ -1781,7 +1781,7 @@ public: // Query the prepared statement for login data LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO); - stmt2->setInt32(0, int32(realm.Id.Realm)); + stmt2->setInt32(0, int32(sRealmList->GetCurrentRealmId().Realm)); stmt2->setUInt32(1, accId); PreparedQueryResult result = LoginDatabase.Query(stmt2); diff --git a/src/server/scripts/Commands/cs_rbac.cpp b/src/server/scripts/Commands/cs_rbac.cpp index 5beb4caaf72..2d42cf2f6dd 100644 --- a/src/server/scripts/Commands/cs_rbac.cpp +++ b/src/server/scripts/Commands/cs_rbac.cpp @@ -29,7 +29,7 @@ EndScriptData */ #include "Config.h" #include "Language.h" #include "Player.h" -#include "Realm.h" +#include "RealmList.h" #include "World.h" #include "WorldSession.h" @@ -83,7 +83,8 @@ public: if (account.IsConnected()) return { account.GetConnectedSession()->GetRBACData(), false }; - rbac::RBACData* rbac = new rbac::RBACData(account.GetID(), account.GetName(), realm.Id.Realm, AccountMgr::GetSecurity(account.GetID(), realm.Id.Realm)); + uint32 realmId = sRealmList->GetCurrentRealmId().Realm; + rbac::RBACData* rbac = new rbac::RBACData(account.GetID(), account.GetName(), realmId, AccountMgr::GetSecurity(account.GetID(), realmId)); rbac->LoadFromDB(); return { rbac, true }; diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index 6b607244805..c58f038677a 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -34,7 +34,7 @@ EndScriptData */ #include "Log.h" #include "MySQLThreading.h" #include "RBAC.h" -#include "Realm.h" +#include "RealmList.h" #include "UpdateTime.h" #include "Util.h" #include "VMapFactory.h" @@ -124,14 +124,10 @@ public: { std::string dbPortOutput; - uint16 dbPort = 0; - if (QueryResult res = LoginDatabase.PQuery("SELECT port FROM realmlist WHERE id = {}", realm.Id.Realm)) - dbPort = (*res)[0].GetUInt16(); - - if (dbPort) - dbPortOutput = Trinity::StringFormat("Realmlist (Realm Id: {}) configured in port {}", realm.Id.Realm, dbPort); + if (std::shared_ptr<Realm const> currentRealm = sRealmList->GetCurrentRealm()) + dbPortOutput = Trinity::StringFormat("Realmlist (Realm Id: {}) configured in port {}", currentRealm->Id.Realm, currentRealm->Port); else - dbPortOutput = Trinity::StringFormat("Realm Id: {} not found in `realmlist` table. Please check your setup", realm.Id.Realm); + dbPortOutput = Trinity::StringFormat("Realm Id: {} not found in `realmlist` table. Please check your setup", sRealmList->GetCurrentRealmId().Realm); handler->PSendSysMessage("%s", GitRevision::GetFullVersion()); handler->PSendSysMessage("Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp index 471d46cd77f..bcba814325c 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -30,7 +30,7 @@ EndScriptData */ #include "Language.h" #include "ObjectMgr.h" #include "Player.h" -#include "Realm.h" +#include "RealmList.h" #include "SupportMgr.h" #include "World.h" #include "WorldSession.h" @@ -132,7 +132,7 @@ bool ticket_commandscript::HandleTicketAssignToCommand(ChatHandler* handler, cha ObjectGuid targetGuid = sCharacterCache->GetCharacterGuidByName(target); uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(targetGuid); // Target must exist and have administrative rights - if (!AccountMgr::HasPermission(accountId, rbac::RBAC_PERM_COMMANDS_BE_ASSIGNED_TICKET, realm.Id.Realm)) + if (!AccountMgr::HasPermission(accountId, rbac::RBAC_PERM_COMMANDS_BE_ASSIGNED_TICKET, sRealmList->GetCurrentRealmId().Realm)) { handler->SendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_A); return true; @@ -328,7 +328,7 @@ bool ticket_commandscript::HandleTicketUnAssignCommand(ChatHandler* handler, cha { ObjectGuid guid = ticket->GetAssignedToGUID(); uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guid); - security = AccountMgr::GetSecurity(accountId, realm.Id.Realm); + security = AccountMgr::GetSecurity(accountId, sRealmList->GetCurrentRealmId().Realm); } // Check security diff --git a/src/server/scripts/World/action_ip_logger.cpp b/src/server/scripts/World/action_ip_logger.cpp index 47691a565fd..9f83a15bd45 100644 --- a/src/server/scripts/World/action_ip_logger.cpp +++ b/src/server/scripts/World/action_ip_logger.cpp @@ -18,7 +18,7 @@ #include "ScriptMgr.h" #include "DatabaseEnv.h" #include "Player.h" -#include "Realm.h" +#include "RealmList.h" #include "World.h" #include "WorldSession.h" @@ -97,7 +97,7 @@ class AccountActionIpLogger : public AccountScript // We declare all the required variables uint32 playerGuid = accountId; - uint32 realmId = realm.Id.Realm; + uint32 realmId = sRealmList->GetCurrentRealmId().Realm; std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it later. // With this switch, we change systemNote so that we have a more accurate phrasing of what type it is. @@ -204,7 +204,7 @@ class CharacterActionIpLogger : public PlayerScript // We declare all the required variables uint32 playerGuid = player->GetSession()->GetAccountId(); - uint32 realmId = realm.Id.Realm; + uint32 realmId = sRealmList->GetCurrentRealmId().Realm; const std::string currentIp = player->GetSession()->GetRemoteAddress(); std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it... @@ -272,7 +272,7 @@ public: // Action IP Logger is only intialized if config is set up // Else, this script isn't loaded in the first place: We require no config check. - uint32 realmId = realm.Id.Realm; + uint32 realmId = sRealmList->GetCurrentRealmId().Realm; // Query playerGuid/accountId, as we only have characterGuid std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it later. 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); diff --git a/src/server/shared/Realm/RealmList.cpp b/src/server/shared/Realm/RealmList.cpp index d4a9938476b..2568a859f88 100644 --- a/src/server/shared/Realm/RealmList.cpp +++ b/src/server/shared/Realm/RealmList.cpp @@ -20,8 +20,6 @@ #include "CryptoRandom.h" #include "DatabaseEnv.h" #include "DeadlineTimer.h" -#include "Errors.h" -#include "IoContext.h" #include "Log.h" #include "MapUtils.h" #include "ProtobufJSON.h" @@ -32,6 +30,26 @@ #include <boost/asio/ip/tcp.hpp> #include <zlib.h> +namespace +{ +bool CompressJson(std::string const& json, std::vector<uint8>* compressed) +{ + uLong uncompressedLength = uLong(json.length() + 1); + uLong compressedLength = compressBound(uLong(json.length())); + compressed->resize(compressedLength + 4); + memcpy(compressed->data(), &uncompressedLength, sizeof(uncompressedLength)); + + if (compress(compressed->data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.data()), uncompressedLength) != Z_OK) + { + compressed->clear(); + return false; + } + + compressed->resize(compressedLength + 4); // trim excess bytes + return true; +} +} + RealmList::RealmList() : _updateInterval(0) { } @@ -76,18 +94,22 @@ void RealmList::LoadBuildInfo() build.BugfixVersion = fields[2].GetUInt32(); std::string hotfixVersion = fields[3].GetString(); if (hotfixVersion.length() < build.HotfixVersion.size()) - std::copy(hotfixVersion.begin(), hotfixVersion.end(), build.HotfixVersion.begin()); + std::ranges::copy(hotfixVersion, build.HotfixVersion.begin()); else - std::fill(hotfixVersion.begin(), hotfixVersion.end(), '\0'); + build.HotfixVersion = { }; build.Build = fields[4].GetUInt32(); std::string win64AuthSeedHexStr = fields[5].GetString(); if (win64AuthSeedHexStr.length() == build.Win64AuthSeed.size() * 2) HexStrToByteArray(win64AuthSeedHexStr, build.Win64AuthSeed); + else + build.Win64AuthSeed = { }; std::string mac64AuthSeedHexStr = fields[6].GetString(); if (mac64AuthSeedHexStr.length() == build.Mac64AuthSeed.size() * 2) HexStrToByteArray(mac64AuthSeedHexStr, build.Mac64AuthSeed); + else + build.Mac64AuthSeed = { }; } while (result->NextRow()); } @@ -96,7 +118,7 @@ void RealmList::LoadBuildInfo() void RealmList::UpdateRealm(Realm& realm, Battlenet::RealmHandle const& id, uint32 build, std::string const& name, boost::asio::ip::address&& address, boost::asio::ip::address&& localAddr, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, - float population) + RealmPopulationState population) { realm.Id = id; realm.Build = build; @@ -122,7 +144,7 @@ void RealmList::UpdateRealms() std::map<Battlenet::RealmHandle, std::string> existingRealms; for (auto const& p : _realms) - existingRealms[p.first] = p.second.Name; + existingRealms[p.first] = p.second->Name; std::unordered_set<std::string> newSubRegions; RealmMap newRealms; @@ -132,61 +154,51 @@ void RealmList::UpdateRealms() { do { - try + Field* fields = result->Fetch(); + uint32 realmId = fields[0].GetUInt32(); + std::string name = fields[1].GetString(); + std::string externalAddressString = fields[2].GetString(); + std::string localAddressString = fields[3].GetString(); + + Optional<boost::asio::ip::tcp::endpoint> externalAddress = _resolver->Resolve(boost::asio::ip::tcp::v4(), externalAddressString, ""); + if (!externalAddress) { - Field* fields = result->Fetch(); - uint32 realmId = fields[0].GetUInt32(); - std::string name = fields[1].GetString(); - std::string externalAddressString = fields[2].GetString(); - std::string localAddressString = fields[3].GetString(); - - Optional<boost::asio::ip::tcp::endpoint> externalAddress = _resolver->Resolve(boost::asio::ip::tcp::v4(), externalAddressString, ""); - if (!externalAddress) - { - TC_LOG_ERROR("realmlist", "Could not resolve address {} for realm \"{}\" id {}", externalAddressString, name, realmId); - continue; - } - - Optional<boost::asio::ip::tcp::endpoint> localAddress = _resolver->Resolve(boost::asio::ip::tcp::v4(), localAddressString, ""); - if (!localAddress) - { - TC_LOG_ERROR("realmlist", "Could not resolve localAddress {} for realm \"{}\" id {}", localAddressString, name, realmId); - continue; - } - - uint16 port = fields[4].GetUInt16(); - uint8 icon = fields[5].GetUInt8(); - if (icon == REALM_TYPE_FFA_PVP) - icon = REALM_TYPE_PVP; - if (icon >= MAX_CLIENT_REALM_TYPE) - icon = REALM_TYPE_NORMAL; - RealmFlags flag = RealmFlags(fields[6].GetUInt8()); - uint8 timezone = fields[7].GetUInt8(); - uint8 allowedSecurityLevel = fields[8].GetUInt8(); - float pop = fields[9].GetFloat(); - uint32 build = fields[10].GetUInt32(); - uint8 region = fields[11].GetUInt8(); - uint8 battlegroup = fields[12].GetUInt8(); - - Battlenet::RealmHandle id{ region, battlegroup, realmId }; - - UpdateRealm(newRealms[id], id, build, name, externalAddress->address(), localAddress->address(), port, icon, - flag, timezone, (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop); - - newSubRegions.insert(Battlenet::RealmHandle{ region, battlegroup, 0 }.GetAddressString()); - - if (!existingRealms.count(id)) - TC_LOG_INFO("realmlist", "Added realm \"{}\" at {}:{}.", name, externalAddressString, port); - else - TC_LOG_DEBUG("realmlist", "Updating realm \"{}\" at {}:{}.", name, externalAddressString, port); - - existingRealms.erase(id); + TC_LOG_ERROR("realmlist", "Could not resolve address {} for realm \"{}\" id {}", externalAddressString, name, realmId); + continue; } - catch (std::exception& ex) + + Optional<boost::asio::ip::tcp::endpoint> localAddress = _resolver->Resolve(boost::asio::ip::tcp::v4(), localAddressString, ""); + if (!localAddress) { - TC_LOG_ERROR("realmlist", "Realmlist::UpdateRealms has thrown an exception: {}", ex.what()); - ABORT(); + TC_LOG_ERROR("realmlist", "Could not resolve localAddress {} for realm \"{}\" id {}", localAddressString, name, realmId); + continue; } + + uint16 port = fields[4].GetUInt16(); + uint8 icon = fields[5].GetUInt8(); + if (icon == REALM_TYPE_FFA_PVP) + icon = REALM_TYPE_PVP; + if (icon >= MAX_CLIENT_REALM_TYPE) + icon = REALM_TYPE_NORMAL; + RealmFlags flag = ConvertLegacyRealmFlags(Trinity::Legacy::RealmFlags(fields[6].GetUInt8())); + uint8 timezone = fields[7].GetUInt8(); + uint8 allowedSecurityLevel = fields[8].GetUInt8(); + RealmPopulationState pop = ConvertLegacyPopulationState(Trinity::Legacy::RealmFlags(fields[6].GetUInt8()), fields[9].GetFloat()); + uint32 build = fields[10].GetUInt32(); + uint8 region = fields[11].GetUInt8(); + uint8 battlegroup = fields[12].GetUInt8(); + + Battlenet::RealmHandle id{ region, battlegroup, realmId }; + + UpdateRealm(*newRealms.try_emplace(id, std::make_shared<Realm>()).first->second, id, build, name, externalAddress->address(), localAddress->address(), port, icon, + flag, timezone, (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop); + + newSubRegions.insert(Battlenet::RealmHandle{ region, battlegroup, 0 }.GetAddressString()); + + if (!existingRealms.erase(id)) + TC_LOG_INFO("realmlist", "Added realm \"{}\" at {}:{}.", name, externalAddressString, port); + else + TC_LOG_DEBUG("realmlist", "Updating realm \"{}\" at {}:{}.", name, externalAddressString, port); } while (result->NextRow()); } @@ -199,6 +211,11 @@ void RealmList::UpdateRealms() _subRegions.swap(newSubRegions); _realms.swap(newRealms); + _removedRealms.swap(existingRealms); + + if (_currentRealmId) + if (std::shared_ptr<Realm> realm = Trinity::Containers::MapGetValuePtr(_realms, *_currentRealmId)) + _currentRealmId = realm->Id; // fill other fields of realm id } if (_updateInterval) @@ -214,39 +231,38 @@ void RealmList::UpdateRealms() } } -Realm const* RealmList::GetRealm(Battlenet::RealmHandle const& id) const +std::shared_ptr<Realm const> RealmList::GetRealm(Battlenet::RealmHandle const& id) const { std::shared_lock<std::shared_mutex> lock(_realmsMutex); return Trinity::Containers::MapGetValuePtr(_realms, id); } -bool RealmList::GetRealmNames(Battlenet::RealmHandle const& id, std::string* name, std::string* normalizedName) const +Battlenet::RealmHandle RealmList::GetCurrentRealmId() const { - std::shared_lock<std::shared_mutex> lock(_realmsMutex); - Realm const* realm = Trinity::Containers::MapGetValuePtr(_realms, id); - if (!realm) - return false; - - *name = realm->Name; - *normalizedName = realm->NormalizedName; - return true; + return _currentRealmId ? *_currentRealmId : Battlenet::RealmHandle(); } -RealmBuildInfo const* RealmList::GetBuildInfo(uint32 build) const +void RealmList::SetCurrentRealmId(Battlenet::RealmHandle const& id) { - for (RealmBuildInfo const& clientBuild : _builds) - if (clientBuild.Build == build) - return &clientBuild; + _currentRealmId = id; +} +std::shared_ptr<Realm const> RealmList::GetCurrentRealm() const +{ + if (_currentRealmId) + return GetRealm(*_currentRealmId); return nullptr; } +RealmBuildInfo const* RealmList::GetBuildInfo(uint32 build) const +{ + auto buildInfo = std::ranges::find(_builds, build, &RealmBuildInfo::Build); + return buildInfo != _builds.end() ? &*buildInfo : nullptr; +} + uint32 RealmList::GetMinorMajorBugfixVersionForBuild(uint32 build) const { - auto buildInfo = std::lower_bound(_builds.begin(), _builds.end(), build, [](RealmBuildInfo const& buildInfo, uint32 value) - { - return buildInfo.Build < value; - }); + auto buildInfo = std::ranges::lower_bound(_builds, build, {}, &RealmBuildInfo::Build); return buildInfo != _builds.end() ? (buildInfo->MajorVersion * 10000 + buildInfo->MinorVersion * 100 + buildInfo->BugfixVersion) : 0; } @@ -257,127 +273,101 @@ void RealmList::WriteSubRegions(bgs::protocol::game_utilities::v1::GetAllValuesF response->add_attribute_value()->set_string_value(subRegion); } -std::vector<uint8> RealmList::GetRealmEntryJSON(Battlenet::RealmHandle const& id, uint32 build) const +void RealmList::FillRealmEntry(Realm const& realm, uint32 clientBuild, AccountTypes accountSecurityLevel, JSON::RealmList::RealmEntry* realmEntry) const { - std::vector<uint8> compressed; - std::shared_lock<std::shared_mutex> lock(_realmsMutex); - if (Realm const* realm = GetRealm(id)) - { - if (!(realm->Flags & REALM_FLAG_OFFLINE) && realm->Build == build) - { - JSON::RealmList::RealmEntry realmEntry; - realmEntry.set_wowrealmaddress(realm->Id.GetAddress()); - realmEntry.set_cfgtimezonesid(1); - realmEntry.set_populationstate(std::max(uint32(realm->PopulationLevel), 1u)); - realmEntry.set_cfgcategoriesid(realm->Timezone); + realmEntry->set_wowrealmaddress(realm.Id.GetAddress()); + realmEntry->set_cfgtimezonesid(1); + if (accountSecurityLevel >= realm.AllowedSecurityLevel || realm.PopulationLevel == RealmPopulationState::Offline) + realmEntry->set_populationstate(AsUnderlyingType(realm.PopulationLevel)); + else + realmEntry->set_populationstate(AsUnderlyingType(RealmPopulationState::Locked)); - JSON::RealmList::ClientVersion* version = realmEntry.mutable_version(); - if (RealmBuildInfo const* buildInfo = GetBuildInfo(realm->Build)) - { - version->set_versionmajor(buildInfo->MajorVersion); - version->set_versionminor(buildInfo->MinorVersion); - version->set_versionrevision(buildInfo->BugfixVersion); - version->set_versionbuild(buildInfo->Build); - } - else - { - version->set_versionmajor(6); - version->set_versionminor(2); - version->set_versionrevision(4); - version->set_versionbuild(realm->Build); - } + realmEntry->set_cfgcategoriesid(realm.Timezone); - realmEntry.set_cfgrealmsid(realm->Id.Realm); - realmEntry.set_flags(realm->Flags); - realmEntry.set_name(realm->Name); - realmEntry.set_cfgconfigsid(realm->GetConfigId()); - realmEntry.set_cfglanguagesid(1); + JSON::RealmList::ClientVersion* version = realmEntry->mutable_version(); + if (RealmBuildInfo const* buildInfo = GetBuildInfo(realm.Build)) + { + version->set_versionmajor(buildInfo->MajorVersion); + version->set_versionminor(buildInfo->MinorVersion); + version->set_versionrevision(buildInfo->BugfixVersion); + version->set_versionbuild(buildInfo->Build); + } + else + { + version->set_versionmajor(6); + version->set_versionminor(2); + version->set_versionrevision(4); + version->set_versionbuild(realm.Build); + } - lock.unlock(); + RealmFlags flag = realm.Flags; + if (realm.Build != clientBuild) + flag |= RealmFlags::VersionMismatch; - std::string json = "JamJSONRealmEntry:" + JSON::Serialize(realmEntry); + realmEntry->set_cfgrealmsid(realm.Id.Realm); + realmEntry->set_flags(AsUnderlyingType(flag)); + realmEntry->set_name(realm.Name); + realmEntry->set_cfgconfigsid(realm.GetConfigId()); + realmEntry->set_cfglanguagesid(1); +} - uLong compressedLength = compressBound(uLong(json.length())); - compressed.resize(compressedLength + 4); - *reinterpret_cast<uint32*>(compressed.data()) = uint32(json.length() + 1); +std::vector<uint8> RealmList::GetRealmEntryJSON(Battlenet::RealmHandle const& id, uint32 build, AccountTypes accountSecurityLevel) const +{ + std::vector<uint8> compressed; + if (std::shared_ptr<Realm const> realm = GetRealm(id)) + { + if (realm->PopulationLevel != RealmPopulationState::Offline && realm->Build == build && accountSecurityLevel >= realm->AllowedSecurityLevel) + { + JSON::RealmList::RealmEntry realmEntry; + FillRealmEntry(*realm, build, accountSecurityLevel, &realmEntry); - if (compress(compressed.data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.c_str()), uLong(json.length() + 1)) == Z_OK) - compressed.resize(compressedLength + 4); - else - compressed.clear(); + std::string json = "JamJSONRealmEntry:" + JSON::Serialize(realmEntry); + CompressJson(json, &compressed); } } return compressed; } -std::vector<uint8> RealmList::GetRealmList(uint32 build, std::string const& subRegion) const +std::vector<uint8> RealmList::GetRealmList(uint32 build, AccountTypes accountSecurityLevel, std::string const& subRegion) const { JSON::RealmList::RealmListUpdates realmList; { std::shared_lock<std::shared_mutex> lock(_realmsMutex); - for (auto const& realm : _realms) + for (auto const& [_, realm] : _realms) { - if (realm.second.Id.GetSubRegionAddress() != subRegion) + if (realm->Id.GetSubRegionAddress() != subRegion) continue; - uint32 flag = realm.second.Flags; - if (realm.second.Build != build) - flag |= REALM_FLAG_VERSION_MISMATCH; - - JSON::RealmList::RealmState* state = realmList.add_updates(); - state->mutable_update()->set_wowrealmaddress(realm.second.Id.GetAddress()); - state->mutable_update()->set_cfgtimezonesid(1); - state->mutable_update()->set_populationstate((realm.second.Flags & REALM_FLAG_OFFLINE) ? 0u : std::max(uint32(realm.second.PopulationLevel), 1u)); - state->mutable_update()->set_cfgcategoriesid(realm.second.Timezone); - - JSON::RealmList::ClientVersion* version = state->mutable_update()->mutable_version(); - if (RealmBuildInfo const* buildInfo = GetBuildInfo(realm.second.Build)) - { - version->set_versionmajor(buildInfo->MajorVersion); - version->set_versionminor(buildInfo->MinorVersion); - version->set_versionrevision(buildInfo->BugfixVersion); - version->set_versionbuild(buildInfo->Build); - } - else - { - version->set_versionmajor(6); - version->set_versionminor(2); - version->set_versionrevision(4); - version->set_versionbuild(realm.second.Build); - } + JSON::RealmList::RealmListUpdatePart* state = realmList.add_updates(); + FillRealmEntry(*realm, build, accountSecurityLevel, state->mutable_update()); + state->set_deleting(false); + } - state->mutable_update()->set_cfgrealmsid(realm.second.Id.Realm); - state->mutable_update()->set_flags(flag); - state->mutable_update()->set_name(realm.second.Name); - state->mutable_update()->set_cfgconfigsid(realm.second.GetConfigId()); - state->mutable_update()->set_cfglanguagesid(1); + for (auto const& [id, _] : _removedRealms) + { + if (id.GetSubRegionAddress() != subRegion) + continue; - state->set_deleting(false); + JSON::RealmList::RealmListUpdatePart* state = realmList.add_updates(); + state->set_wowrealmaddress(id.GetAddress()); + state->set_deleting(true); } } std::string json = "JSONRealmListUpdates:" + JSON::Serialize(realmList); - - uLong compressedLength = compressBound(uLong(json.length())); std::vector<uint8> compressed; - compressed.resize(4 + compressedLength); - *reinterpret_cast<uint32*>(compressed.data()) = uint32(json.length() + 1); - - compress(compressed.data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.c_str()), uLong(json.length() + 1)); - - compressed.resize(compressedLength + 4); - + CompressJson(json, &compressed); return compressed; } uint32 RealmList::JoinRealm(uint32 realmAddress, uint32 build, boost::asio::ip::address const& clientAddress, std::array<uint8, 32> const& clientSecret, - LocaleConstant locale, std::string const& os, Minutes timezoneOffset, std::string const& accountName, bgs::protocol::game_utilities::v1::ClientResponse* response) const + LocaleConstant locale, std::string const& os, Minutes timezoneOffset, std::string const& accountName, AccountTypes accountSecurityLevel, + bgs::protocol::game_utilities::v1::ClientResponse* response) const { - std::shared_lock<std::shared_mutex> lock(_realmsMutex); - if (Realm const* realm = GetRealm(Battlenet::RealmHandle(realmAddress))) + if (std::shared_ptr<Realm const> realm = GetRealm(realmAddress)) { - if (realm->Flags & REALM_FLAG_OFFLINE || realm->Build != build) + if (realm->PopulationLevel == RealmPopulationState::Offline || realm->Build != build || accountSecurityLevel < realm->AllowedSecurityLevel) return ERROR_USER_SERVER_NOT_PERMITTED_ON_REALM; JSON::RealmList::RealmListServerIPAddresses serverAddresses; @@ -388,32 +378,27 @@ uint32 RealmList::JoinRealm(uint32 realmAddress, uint32 build, boost::asio::ip:: address->set_ip(realm->GetAddressForClient(clientAddress).to_string()); address->set_port(realm->Port); - lock.unlock(); - std::string json = "JSONRealmListServerIPAddresses:" + JSON::Serialize(serverAddresses); - - uLong compressedLength = compressBound(uLong(json.length())); std::vector<uint8> compressed; - compressed.resize(4 + compressedLength); - *reinterpret_cast<uint32*>(compressed.data()) = uint32(json.length() + 1); - if (compress(compressed.data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.c_str()), uLong(json.length() + 1)) != Z_OK) + if (!CompressJson(json, &compressed)) return ERROR_UTIL_SERVER_FAILED_TO_SERIALIZE_RESPONSE; std::array<uint8, 32> serverSecret = Trinity::Crypto::GetRandomBytes<32>(); std::array<uint8, 64> keyData; auto keyDestItr = keyData.begin(); - keyDestItr = std::copy(clientSecret.begin(), clientSecret.end(), keyDestItr); - keyDestItr = std::copy(serverSecret.begin(), serverSecret.end(), keyDestItr); + keyDestItr = std::ranges::copy(clientSecret, keyDestItr).out; + keyDestItr = std::ranges::copy(serverSecret, keyDestItr).out; LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_GAME_ACCOUNT_LOGIN_INFO); stmt->setBinary(0, keyData); stmt->setString(1, clientAddress.to_string()); - stmt->setUInt8(2, locale); - stmt->setString(3, os); - stmt->setInt16(4, timezoneOffset.count()); - stmt->setString(5, accountName); + stmt->setUInt32(2, build); + stmt->setUInt8(3, locale); + stmt->setString(4, os); + stmt->setInt16(5, timezoneOffset.count()); + stmt->setString(6, accountName); LoginDatabase.DirectExecute(stmt); bgs::protocol::Attribute* attribute = response->add_attribute(); @@ -422,11 +407,11 @@ uint32 RealmList::JoinRealm(uint32 realmAddress, uint32 build, boost::asio::ip:: attribute = response->add_attribute(); attribute->set_name("Param_ServerAddresses"); - attribute->mutable_value()->set_blob_value(compressed.data(), compressedLength + 4); + attribute->mutable_value()->set_blob_value(compressed.data(), compressed.size()); attribute = response->add_attribute(); attribute->set_name("Param_JoinSecret"); - attribute->mutable_value()->set_blob_value(serverSecret.data(), 32); + attribute->mutable_value()->set_blob_value(serverSecret.data(), serverSecret.size()); return ERROR_OK; } diff --git a/src/server/shared/Realm/RealmList.h b/src/server/shared/Realm/RealmList.h index 7e85cbcfd38..3cbbb97c316 100644 --- a/src/server/shared/Realm/RealmList.h +++ b/src/server/shared/Realm/RealmList.h @@ -20,6 +20,7 @@ #include "Define.h" #include "Duration.h" +#include "Optional.h" #include "Realm.h" #include <array> #include <map> @@ -47,32 +48,39 @@ class GetAllValuesForAttributeResponse; namespace JSON::RealmList { -class RealmListUpdates; +class RealmEntry; } /// Storage object for the list of realms on the server class TC_SHARED_API RealmList { public: - typedef std::map<Battlenet::RealmHandle, Realm> RealmMap; + typedef std::map<Battlenet::RealmHandle, std::shared_ptr<Realm>> RealmMap; static RealmList* Instance(); + RealmList(RealmList const&) = delete; + RealmList(RealmList&&) = delete; + RealmList& operator=(RealmList const&) = delete; + RealmList& operator=(RealmList&&) = delete; + ~RealmList(); void Initialize(Trinity::Asio::IoContext& ioContext, uint32 updateInterval); void Close(); - Realm const* GetRealm(Battlenet::RealmHandle const& id) const; - bool GetRealmNames(Battlenet::RealmHandle const& id, std::string* name, std::string* normalizedName) const; + std::shared_ptr<Realm const> GetRealm(Battlenet::RealmHandle const& id) const; + Battlenet::RealmHandle GetCurrentRealmId() const; + void SetCurrentRealmId(Battlenet::RealmHandle const& id); + std::shared_ptr<Realm const> GetCurrentRealm() const; RealmBuildInfo const* GetBuildInfo(uint32 build) const; uint32 GetMinorMajorBugfixVersionForBuild(uint32 build) const; void WriteSubRegions(bgs::protocol::game_utilities::v1::GetAllValuesForAttributeResponse* response) const; - std::vector<uint8> GetRealmEntryJSON(Battlenet::RealmHandle const& id, uint32 build) const; - std::vector<uint8> GetRealmList(uint32 build, std::string const& subRegion) const; + std::vector<uint8> GetRealmEntryJSON(Battlenet::RealmHandle const& id, uint32 build, AccountTypes accountSecurityLevel) const; + std::vector<uint8> GetRealmList(uint32 build, AccountTypes accountSecurityLevel, std::string const& subRegion) const; uint32 JoinRealm(uint32 realmAddress, uint32 build, boost::asio::ip::address const& clientAddress, std::array<uint8, 32> const& clientSecret, - LocaleConstant locale, std::string const& os, Minutes timezoneOffset, std::string const& accountName, + LocaleConstant locale, std::string const& os, Minutes timezoneOffset, std::string const& accountName, AccountTypes accountSecurityLevel, bgs::protocol::game_utilities::v1::ClientResponse* response) const; private: @@ -80,17 +88,20 @@ private: void LoadBuildInfo(); void UpdateRealms(); - void UpdateRealm(Realm& realm, Battlenet::RealmHandle const& id, uint32 build, std::string const& name, + static void UpdateRealm(Realm& realm, Battlenet::RealmHandle const& id, uint32 build, std::string const& name, boost::asio::ip::address&& address, boost::asio::ip::address&& localAddr, - uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population); + uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, RealmPopulationState population); + void FillRealmEntry(Realm const& realm, uint32 clientBuild, AccountTypes accountSecurityLevel, JSON::RealmList::RealmEntry* realmEntry) const; std::vector<RealmBuildInfo> _builds; mutable std::shared_mutex _realmsMutex; RealmMap _realms; + std::map<Battlenet::RealmHandle, std::string> _removedRealms; std::unordered_set<std::string> _subRegions; uint32 _updateInterval; std::unique_ptr<Trinity::Asio::DeadlineTimer> _updateTimer; std::unique_ptr<Trinity::Asio::Resolver> _resolver; + Optional<Battlenet::RealmHandle> _currentRealmId; }; #define sRealmList RealmList::Instance() diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index e781fb8b95e..c3ad9b4f420 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -126,10 +126,9 @@ AsyncAcceptor* StartRaSocketAcceptor(Trinity::Asio::IoContext& ioContext); bool StartDB(); void StopDB(); void WorldUpdateLoop(); -void ClearOnlineAccounts(); +void ClearOnlineAccounts(uint32 realmId); struct ShutdownTCSoapThread { void operator()(std::thread* thread) const; }; struct ShutdownCLIThread { void operator()(std::thread* cliThread) const; }; -bool LoadRealmInfo(); variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, fs::path& configDir, std::string& winServiceAction); /// Launch the Trinity server @@ -305,16 +304,33 @@ extern int main(int argc, char** argv) Trinity::Net::ScanLocalNetworks(); - // Set server offline (not connectable) - LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag | {} WHERE id = '{}'", REALM_FLAG_OFFLINE, realm.Id.Realm); - sRealmList->Initialize(*ioContext, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10)); auto sRealmListHandle = Trinity::make_unique_ptr_with_deleter(sRealmList, [](RealmList* realmList) { realmList->Close(); }); - LoadRealmInfo(); + ///- Get the realm Id from the configuration file + uint32 realmId = sConfigMgr->GetIntDefault("RealmID", 0); + if (!realmId) + { + TC_LOG_ERROR("server.worldserver", "Realm ID not defined in configuration file"); + return 1; + } + + sRealmList->SetCurrentRealmId(realmId); - sMetric->Initialize(realm.Name, *ioContext, []() + TC_LOG_INFO("server.worldserver", "Realm running as realm ID {}", realmId); + + ///- Clean the database before starting + ClearOnlineAccounts(realmId); + + std::shared_ptr<Realm const> realm = sRealmList->GetCurrentRealm(); + if (!realm) + return 1; + + // Set server offline (not connectable) + LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag | {} WHERE id = '{}'", Trinity::Legacy::REALM_FLAG_OFFLINE, realmId); + + sMetric->Initialize(realm->Name, *ioContext, []() { TC_METRIC_VALUE("online_players", sWorld->GetPlayerCount()); TC_METRIC_VALUE("db_queue_login", uint64(LoginDatabase.QueueSize())); @@ -322,6 +338,8 @@ extern int main(int argc, char** argv) TC_METRIC_VALUE("db_queue_world", uint64(WorldDatabase.QueueSize())); }); + realm = nullptr; + TC_METRIC_EVENT("events", "Worldserver started", ""); auto sMetricHandle = Trinity::make_unique_ptr_with_deleter(sMetric, [](Metric* metric) @@ -388,7 +406,7 @@ extern int main(int argc, char** argv) return 1; } - auto sWorldSocketMgrHandle = Trinity::make_unique_ptr_with_deleter(&sWorldSocketMgr, [](WorldSocketMgr* mgr) + auto sWorldSocketMgrHandle = Trinity::make_unique_ptr_with_deleter(&sWorldSocketMgr, [realmId](WorldSocketMgr* mgr) { sWorld->KickAll(); // save and kick all players sWorld->UpdateSessions(1); // real players unload required UpdateSessions call @@ -396,13 +414,11 @@ extern int main(int argc, char** argv) mgr->StopNetwork(); ///- Clean database before leaving - ClearOnlineAccounts(); + ClearOnlineAccounts(realmId); }); // Set server online (allow connecting now) - LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag & ~{}, population = 0 WHERE id = '{}'", REALM_FLAG_OFFLINE, realm.Id.Realm); - realm.PopulationLevel = 0.0f; - realm.Flags = RealmFlags(realm.Flags & ~uint32(REALM_FLAG_OFFLINE)); + LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag & ~{}, population = 0 WHERE id = '{}'", Trinity::Legacy::REALM_FLAG_OFFLINE, realmId); // Start the freeze check callback cycle in 5 seconds (cycle itself is 1 sec) std::shared_ptr<FreezeDetector> freezeDetector; @@ -443,7 +459,7 @@ extern int main(int argc, char** argv) sScriptMgr->OnShutdown(); // set server offline - LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag | {} WHERE id = '{}'", REALM_FLAG_OFFLINE, realm.Id.Realm); + LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag | {} WHERE id = '{}'", Trinity::Legacy::REALM_FLAG_OFFLINE, realmId); TC_LOG_INFO("server.worldserver", "Halting process..."); @@ -633,17 +649,6 @@ AsyncAcceptor* StartRaSocketAcceptor(Trinity::Asio::IoContext& ioContext) return acceptor; } -bool LoadRealmInfo() -{ - if (Realm const* realmListRealm = sRealmList->GetRealm(realm.Id)) - { - realm = *realmListRealm; - return true; - } - - return false; -} - /// Initialize connection to the databases bool StartDB() { @@ -660,19 +665,6 @@ bool StartDB() if (!loader.Load()) return false; - ///- Get the realm Id from the configuration file - realm.Id.Realm = sConfigMgr->GetIntDefault("RealmID", 0); - if (!realm.Id.Realm) - { - TC_LOG_ERROR("server.worldserver", "Realm ID not defined in configuration file"); - return false; - } - - TC_LOG_INFO("server.worldserver", "Realm running as realm ID {}", realm.Id.Realm); - - ///- Clean the database before starting - ClearOnlineAccounts(); - ///- Insert version info into DB WorldDatabase.PExecute("UPDATE version SET core_version = '{}', core_revision = '{}'", GitRevision::GetFullVersion(), GitRevision::GetHash()); // One-time query @@ -693,10 +685,10 @@ void StopDB() } /// Clear 'online' status for all accounts with characters in this realm -void ClearOnlineAccounts() +void ClearOnlineAccounts(uint32 realmId) { // Reset online status for all accounts with characters on the current realm - LoginDatabase.DirectPExecute("UPDATE account SET online = 0 WHERE online > 0 AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = {})", realm.Id.Realm); + LoginDatabase.DirectPExecute("UPDATE account SET online = 0 WHERE online > 0 AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = {})", realmId); // Reset online status for all characters CharacterDatabase.DirectExecute("UPDATE characters SET online = 0 WHERE online <> 0"); diff --git a/src/server/worldserver/TCSoap/TCSoap.cpp b/src/server/worldserver/TCSoap/TCSoap.cpp index 71b299ca786..84087bd3b2b 100644 --- a/src/server/worldserver/TCSoap/TCSoap.cpp +++ b/src/server/worldserver/TCSoap/TCSoap.cpp @@ -20,7 +20,7 @@ #include "IpAddress.h" #include "Log.h" #include "Memory.h" -#include "Realm.h" +#include "RealmList.h" #include "World.h" #include "soapH.h" #include "soapStub.h" @@ -105,7 +105,7 @@ int ns1__executeCommand(soap* soap, char* command, char** result) return 401; } - if (AccountMgr::GetSecurity(accountId, realm.Id.Realm) < SEC_ADMINISTRATOR) + if (AccountMgr::GetSecurity(accountId, sRealmList->GetCurrentRealmId().Realm) < SEC_ADMINISTRATOR) { TC_LOG_INFO("network.soap", "{}'s gmlevel is too low", soap->userid); return 403; |