Core/Client Builds: Move build info out of RealmList class
Port From (https://github.com/TrinityCore/TrinityCore/commit/82031dc720ac485c32158871aec86764c2505581)
This commit is contained in:
@@ -1,79 +0,0 @@
|
|||||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
|
||||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Framework.ClientBuild
|
|
||||||
{
|
|
||||||
struct ClientBuildPlatformType
|
|
||||||
{
|
|
||||||
public static int Windows = "Win".fourcc();
|
|
||||||
public static int macOS = "Mac".fourcc();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ClientBuildArch
|
|
||||||
{
|
|
||||||
public static int x86 = "x86".fourcc();
|
|
||||||
public static int x64 = "x64".fourcc();
|
|
||||||
public static int Arm32 = "A32".fourcc();
|
|
||||||
public static int Arm64 = "A64".fourcc();
|
|
||||||
public static int WA32 = "WA32".fourcc();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ClientBuildType
|
|
||||||
{
|
|
||||||
public static int Retail = "WoW".fourcc();
|
|
||||||
public static int RetailChina = "WoWC".fourcc();
|
|
||||||
public static int Beta = "WoWB".fourcc();
|
|
||||||
public static int BetaRelease = "WoWE".fourcc();
|
|
||||||
public static int Ptr = "WoWT".fourcc();
|
|
||||||
public static int PtrRelease = "WoWR".fourcc();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ClientBuildHelper
|
|
||||||
{
|
|
||||||
public static bool IsValid(string platform)
|
|
||||||
{
|
|
||||||
switch (platform)
|
|
||||||
{
|
|
||||||
case "Win":
|
|
||||||
case "Wn64":
|
|
||||||
case "WinA":
|
|
||||||
case "Mac":
|
|
||||||
case "Mc64":
|
|
||||||
case "MacA":
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ClientBuildVariantId
|
|
||||||
{
|
|
||||||
public int Platform;
|
|
||||||
public int Arch;
|
|
||||||
public int Type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ClientBuildAuthKey
|
|
||||||
{
|
|
||||||
public static int Size = 16;
|
|
||||||
|
|
||||||
public ClientBuildVariantId Variant;
|
|
||||||
public byte[] Key = new byte[Size];
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ClientBuildInfo
|
|
||||||
{
|
|
||||||
public uint Build;
|
|
||||||
public uint MajorVersion;
|
|
||||||
public uint MinorVersion;
|
|
||||||
public uint BugfixVersion;
|
|
||||||
public char[] HotfixVersion = new char[4];
|
|
||||||
public List<ClientBuildAuthKey> AuthKeys = new();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||||
|
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Framework.Database;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Framework.ClientBuild
|
||||||
|
{
|
||||||
|
struct ClientBuildPlatformType
|
||||||
|
{
|
||||||
|
public static int Windows = "Win".fourcc();
|
||||||
|
public static int macOS = "Mac".fourcc();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ClientBuildArch
|
||||||
|
{
|
||||||
|
public static int x86 = "x86".fourcc();
|
||||||
|
public static int x64 = "x64".fourcc();
|
||||||
|
public static int Arm32 = "A32".fourcc();
|
||||||
|
public static int Arm64 = "A64".fourcc();
|
||||||
|
public static int WA32 = "WA32".fourcc();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ClientBuildType
|
||||||
|
{
|
||||||
|
public static int Retail = "WoW".fourcc();
|
||||||
|
public static int RetailChina = "WoWC".fourcc();
|
||||||
|
public static int Beta = "WoWB".fourcc();
|
||||||
|
public static int BetaRelease = "WoWE".fourcc();
|
||||||
|
public static int Ptr = "WoWT".fourcc();
|
||||||
|
public static int PtrRelease = "WoWR".fourcc();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ClientBuildHelper
|
||||||
|
{
|
||||||
|
static List<ClientBuildInfo> _builds = new();
|
||||||
|
|
||||||
|
public static void LoadBuildInfo()
|
||||||
|
{
|
||||||
|
_builds.Clear();
|
||||||
|
|
||||||
|
// 0 1 2 3 4 5 6 7
|
||||||
|
SQLResult result = DB.Login.Query("SELECT majorVersion, minorVersion, bugfixVersion, hotfixVersion, build, win64AuthSeed, mac64AuthSeed, macArmAuthSeed FROM build_info ORDER BY build ASC");
|
||||||
|
if (!result.IsEmpty())
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ClientBuildInfo build = new();
|
||||||
|
build.MajorVersion = result.Read<uint>(0);
|
||||||
|
build.MinorVersion = result.Read<uint>(1);
|
||||||
|
build.BugfixVersion = result.Read<uint>(2);
|
||||||
|
string hotfixVersion = result.Read<string>(3);
|
||||||
|
if (!hotfixVersion.IsEmpty() && hotfixVersion.Length < build.HotfixVersion.Length)
|
||||||
|
build.HotfixVersion = hotfixVersion.ToCharArray();
|
||||||
|
|
||||||
|
build.Build = result.Read<uint>(4);
|
||||||
|
|
||||||
|
string win64AuthSeedHexStr = result.Read<string>(5);
|
||||||
|
if (win64AuthSeedHexStr.Length == ClientBuildAuthKey.Size * 2)
|
||||||
|
{
|
||||||
|
ClientBuildAuthKey buildKey = new();
|
||||||
|
buildKey.Variant = new() { Platform = ClientBuildPlatformType.Windows, Arch = ClientBuildArch.x64, Type = ClientBuildType.Retail };
|
||||||
|
buildKey.Key = win64AuthSeedHexStr.ToByteArray();
|
||||||
|
build.AuthKeys.Add(buildKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
string mac64AuthSeedHexStr = result.Read<string>(6);
|
||||||
|
if (mac64AuthSeedHexStr.Length == ClientBuildAuthKey.Size * 2)
|
||||||
|
{
|
||||||
|
ClientBuildAuthKey buildKey = new();
|
||||||
|
buildKey.Variant = new() { Platform = ClientBuildPlatformType.macOS, Arch = ClientBuildArch.x64, Type = ClientBuildType.Retail };
|
||||||
|
buildKey.Key = mac64AuthSeedHexStr.ToByteArray();
|
||||||
|
build.AuthKeys.Add(buildKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
string macArmAuthSeedHexStr = result.Read<string>(7);
|
||||||
|
if (macArmAuthSeedHexStr.Length == ClientBuildAuthKey.Size * 2)
|
||||||
|
{
|
||||||
|
ClientBuildAuthKey buildKey = new();
|
||||||
|
buildKey.Variant = new() { Platform = ClientBuildPlatformType.macOS, Arch = ClientBuildArch.Arm64, Type = ClientBuildType.Retail };
|
||||||
|
buildKey.Key = macArmAuthSeedHexStr.ToByteArray();
|
||||||
|
build.AuthKeys.Add(buildKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
_builds.Add(build);
|
||||||
|
|
||||||
|
} while (result.NextRow());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ClientBuildInfo GetBuildInfo(uint build)
|
||||||
|
{
|
||||||
|
return _builds.Find(x => x.Build == build);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint GetMinorMajorBugfixVersionForBuild(uint build)
|
||||||
|
{
|
||||||
|
ClientBuildInfo buildInfo = _builds.Find(p => p.Build < build);
|
||||||
|
return buildInfo != null ? (buildInfo.MajorVersion * 10000 + buildInfo.MinorVersion * 100 + buildInfo.BugfixVersion) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsValid(string platform)
|
||||||
|
{
|
||||||
|
switch (platform)
|
||||||
|
{
|
||||||
|
case "Win":
|
||||||
|
case "Wn64":
|
||||||
|
case "WinA":
|
||||||
|
case "Mac":
|
||||||
|
case "Mc64":
|
||||||
|
case "MacA":
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ClientBuildVariantId
|
||||||
|
{
|
||||||
|
public int Platform;
|
||||||
|
public int Arch;
|
||||||
|
public int Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ClientBuildAuthKey
|
||||||
|
{
|
||||||
|
public static int Size = 16;
|
||||||
|
|
||||||
|
public ClientBuildVariantId Variant;
|
||||||
|
public byte[] Key = new byte[Size];
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ClientBuildInfo
|
||||||
|
{
|
||||||
|
public uint Build;
|
||||||
|
public uint MajorVersion;
|
||||||
|
public uint MinorVersion;
|
||||||
|
public uint BugfixVersion;
|
||||||
|
public char[] HotfixVersion = new char[4];
|
||||||
|
public List<ClientBuildAuthKey> AuthKeys = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,66 +28,13 @@ public class RealmManager : Singleton<RealmManager>
|
|||||||
_updateTimer = new Timer(TimeSpan.FromSeconds(updateInterval).TotalMilliseconds);
|
_updateTimer = new Timer(TimeSpan.FromSeconds(updateInterval).TotalMilliseconds);
|
||||||
_updateTimer.Elapsed += UpdateRealms;
|
_updateTimer.Elapsed += UpdateRealms;
|
||||||
|
|
||||||
LoadBuildInfo();
|
ClientBuildHelper.LoadBuildInfo();
|
||||||
|
|
||||||
UpdateRealms(null, null);
|
UpdateRealms(null, null);
|
||||||
|
|
||||||
_updateTimer.Start();
|
_updateTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadBuildInfo()
|
|
||||||
{
|
|
||||||
_builds.Clear();
|
|
||||||
|
|
||||||
// 0 1 2 3 4 5 6 7
|
|
||||||
SQLResult result = DB.Login.Query("SELECT majorVersion, minorVersion, bugfixVersion, hotfixVersion, build, win64AuthSeed, mac64AuthSeed, macArmAuthSeed FROM build_info ORDER BY build ASC");
|
|
||||||
if (!result.IsEmpty())
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
ClientBuildInfo build = new();
|
|
||||||
build.MajorVersion = result.Read<uint>(0);
|
|
||||||
build.MinorVersion = result.Read<uint>(1);
|
|
||||||
build.BugfixVersion = result.Read<uint>(2);
|
|
||||||
string hotfixVersion = result.Read<string>(3);
|
|
||||||
if (!hotfixVersion.IsEmpty() && hotfixVersion.Length < build.HotfixVersion.Length)
|
|
||||||
build.HotfixVersion = hotfixVersion.ToCharArray();
|
|
||||||
|
|
||||||
build.Build = result.Read<uint>(4);
|
|
||||||
|
|
||||||
string win64AuthSeedHexStr = result.Read<string>(5);
|
|
||||||
if (win64AuthSeedHexStr.Length == ClientBuildAuthKey.Size * 2)
|
|
||||||
{
|
|
||||||
ClientBuildAuthKey buildKey = new();
|
|
||||||
buildKey.Variant = new() { Platform = ClientBuildPlatformType.Windows, Arch = ClientBuildArch.x64, Type = ClientBuildType.Retail };
|
|
||||||
buildKey.Key = win64AuthSeedHexStr.ToByteArray();
|
|
||||||
build.AuthKeys.Add(buildKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
string mac64AuthSeedHexStr = result.Read<string>(6);
|
|
||||||
if (mac64AuthSeedHexStr.Length == ClientBuildAuthKey.Size * 2)
|
|
||||||
{
|
|
||||||
ClientBuildAuthKey buildKey = new();
|
|
||||||
buildKey.Variant = new() { Platform = ClientBuildPlatformType.macOS, Arch = ClientBuildArch.x64, Type = ClientBuildType.Retail };
|
|
||||||
buildKey.Key = mac64AuthSeedHexStr.ToByteArray();
|
|
||||||
build.AuthKeys.Add(buildKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
string macArmAuthSeedHexStr = result.Read<string>(7);
|
|
||||||
if (macArmAuthSeedHexStr.Length == ClientBuildAuthKey.Size * 2)
|
|
||||||
{
|
|
||||||
ClientBuildAuthKey buildKey = new();
|
|
||||||
buildKey.Variant = new() { Platform = ClientBuildPlatformType.macOS, Arch = ClientBuildArch.Arm64, Type = ClientBuildType.Retail };
|
|
||||||
buildKey.Key = macArmAuthSeedHexStr.ToByteArray();
|
|
||||||
build.AuthKeys.Add(buildKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
_builds.Add(build);
|
|
||||||
|
|
||||||
} while (result.NextRow());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
_updateTimer.Close();
|
_updateTimer.Close();
|
||||||
@@ -218,21 +165,6 @@ public class RealmManager : Singleton<RealmManager>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientBuildInfo GetBuildInfo(uint build)
|
|
||||||
{
|
|
||||||
foreach (var clientBuild in _builds)
|
|
||||||
if (clientBuild.Build == build)
|
|
||||||
return clientBuild;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint GetMinorMajorBugfixVersionForBuild(uint build)
|
|
||||||
{
|
|
||||||
ClientBuildInfo buildInfo = _builds.FirstOrDefault(p => p.Build < build);
|
|
||||||
return buildInfo != null ? (buildInfo.MajorVersion * 10000 + buildInfo.MinorVersion * 100 + buildInfo.BugfixVersion) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FillRealmEntry(Realm realm, uint clientBuild, AccountTypes accountSecurityLevel, RealmEntry realmEntry)
|
void FillRealmEntry(Realm realm, uint clientBuild, AccountTypes accountSecurityLevel, RealmEntry realmEntry)
|
||||||
{
|
{
|
||||||
realmEntry.WowRealmAddress = (int)realm.Id.GetAddress();
|
realmEntry.WowRealmAddress = (int)realm.Id.GetAddress();
|
||||||
@@ -245,7 +177,7 @@ public class RealmManager : Singleton<RealmManager>
|
|||||||
realmEntry.CfgCategoriesID = realm.Timezone;
|
realmEntry.CfgCategoriesID = realm.Timezone;
|
||||||
|
|
||||||
ClientVersion version = new();
|
ClientVersion version = new();
|
||||||
ClientBuildInfo buildInfo = GetBuildInfo(realm.Build);
|
ClientBuildInfo buildInfo = ClientBuildHelper.GetBuildInfo(realm.Build);
|
||||||
if (buildInfo != null)
|
if (buildInfo != null)
|
||||||
{
|
{
|
||||||
version.Major = (int)buildInfo.MajorVersion;
|
version.Major = (int)buildInfo.MajorVersion;
|
||||||
@@ -412,7 +344,6 @@ public class RealmManager : Singleton<RealmManager>
|
|||||||
public ICollection<Realm> GetRealms() { return _realms.Values; }
|
public ICollection<Realm> GetRealms() { return _realms.Values; }
|
||||||
List<string> GetSubRegions() { return _subRegions; }
|
List<string> GetSubRegions() { return _subRegions; }
|
||||||
|
|
||||||
List<ClientBuildInfo> _builds = new();
|
|
||||||
ConcurrentDictionary<RealmId, Realm> _realms = new();
|
ConcurrentDictionary<RealmId, Realm> _realms = new();
|
||||||
Dictionary<RealmId, string> _removedRealms = new();
|
Dictionary<RealmId, string> _removedRealms = new();
|
||||||
List<string> _subRegions = new();
|
List<string> _subRegions = new();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using Framework.ClientBuild;
|
||||||
using Framework.Constants;
|
using Framework.Constants;
|
||||||
using Framework.Database;
|
using Framework.Database;
|
||||||
using Game.Arenas;
|
using Game.Arenas;
|
||||||
@@ -1442,7 +1443,7 @@ namespace Game.Achievements
|
|||||||
var currentRealm = Global.RealmMgr.GetCurrentRealm();
|
var currentRealm = Global.RealmMgr.GetCurrentRealm();
|
||||||
if (currentRealm == null)
|
if (currentRealm == null)
|
||||||
return false;
|
return false;
|
||||||
if (reqValue < Global.RealmMgr.GetMinorMajorBugfixVersionForBuild(currentRealm.Build))
|
if (reqValue < ClientBuildHelper.GetMinorMajorBugfixVersionForBuild(currentRealm.Build))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case ModifierTreeType.BattlePetTeamLevel: // 34
|
case ModifierTreeType.BattlePetTeamLevel: // 34
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using Framework.ClientBuild;
|
||||||
using Framework.Collections;
|
using Framework.Collections;
|
||||||
using Framework.Constants;
|
using Framework.Constants;
|
||||||
using Framework.Database;
|
using Framework.Database;
|
||||||
@@ -3837,7 +3838,7 @@ namespace Game.Entities
|
|||||||
stmt.AddValue(index++, m_activePlayerData.MultiActionBars);
|
stmt.AddValue(index++, m_activePlayerData.MultiActionBars);
|
||||||
var currentRealm = Global.RealmMgr.GetCurrentRealm();
|
var currentRealm = Global.RealmMgr.GetCurrentRealm();
|
||||||
if (currentRealm != null)
|
if (currentRealm != null)
|
||||||
stmt.AddValue(index++, Global.RealmMgr.GetMinorMajorBugfixVersionForBuild(currentRealm.Build));
|
stmt.AddValue(index++, ClientBuildHelper.GetMinorMajorBugfixVersionForBuild(currentRealm.Build));
|
||||||
else
|
else
|
||||||
stmt.AddValue(index++, 0);
|
stmt.AddValue(index++, 0);
|
||||||
}
|
}
|
||||||
@@ -3998,7 +3999,7 @@ namespace Game.Entities
|
|||||||
stmt.AddValue(index++, finiteAlways(_restMgr.GetRestBonus(RestTypes.Honor)));
|
stmt.AddValue(index++, finiteAlways(_restMgr.GetRestBonus(RestTypes.Honor)));
|
||||||
var currentRealm = Global.RealmMgr.GetCurrentRealm();
|
var currentRealm = Global.RealmMgr.GetCurrentRealm();
|
||||||
if (currentRealm != null)
|
if (currentRealm != null)
|
||||||
stmt.AddValue(index++, Global.RealmMgr.GetMinorMajorBugfixVersionForBuild(currentRealm.Build));
|
stmt.AddValue(index++, ClientBuildHelper.GetMinorMajorBugfixVersionForBuild(currentRealm.Build));
|
||||||
else
|
else
|
||||||
stmt.AddValue(index++, 0);
|
stmt.AddValue(index++, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -482,7 +482,7 @@ namespace Game.Networking
|
|||||||
|
|
||||||
AccountInfo account = new(result.GetFields());
|
AccountInfo account = new(result.GetFields());
|
||||||
|
|
||||||
ClientBuildInfo buildInfo = Global.RealmMgr.GetBuildInfo(account.game.Build);
|
ClientBuildInfo buildInfo = ClientBuildHelper.GetBuildInfo(account.game.Build);
|
||||||
if (buildInfo == null)
|
if (buildInfo == null)
|
||||||
{
|
{
|
||||||
SendAuthResponseError(BattlenetRpcErrorCode.BadVersion);
|
SendAuthResponseError(BattlenetRpcErrorCode.BadVersion);
|
||||||
|
|||||||
Reference in New Issue
Block a user