Refactoring of BNetServer
This commit is contained in:
@@ -19,14 +19,15 @@ using Framework.Collections;
|
||||
using Framework.Configuration;
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Framework.Realm;
|
||||
using Game.BattlePets;
|
||||
using Game.Chat;
|
||||
using Game.Collision;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Maps;
|
||||
using Game.Network;
|
||||
using Game.Network.Packets;
|
||||
using Game.Networking;
|
||||
using Game.Networking.Packets;
|
||||
using Game.Spells;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
@@ -335,7 +336,7 @@ namespace Game
|
||||
RealmType server_type = IsFFAPvPRealm() ? RealmType.PVP : (RealmType)WorldConfig.GetIntValue(WorldCfg.GameType);
|
||||
uint realm_zone = WorldConfig.GetUIntValue(WorldCfg.RealmZone);
|
||||
|
||||
DB.Login.Execute("UPDATE realmlist SET icon = {0}, timezone = {1} WHERE id = '{2}'", (byte)server_type, realm_zone, _realm.Id.Realm); // One-time query
|
||||
DB.Login.Execute("UPDATE realmlist SET icon = {0}, timezone = {1} WHERE id = '{2}'", (byte)server_type, realm_zone, _realm.Id.Index); // One-time query
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Initialize DataStorage...");
|
||||
// Load DB2s
|
||||
@@ -857,7 +858,7 @@ namespace Game
|
||||
Log.outInfo(LogFilter.ServerLoading, "Initialize game time and timers");
|
||||
GameTime.UpdateGameTimers();
|
||||
|
||||
DB.Login.Execute("INSERT INTO uptime (realmid, starttime, uptime, revision) VALUES({0}, {1}, 0, '{2}')", _realm.Id.Realm, GameTime.GetStartTime(), ""); // One-time query
|
||||
DB.Login.Execute("INSERT INTO uptime (realmid, starttime, uptime, revision) VALUES({0}, {1}, 0, '{2}')", _realm.Id.Index, GameTime.GetStartTime(), ""); // One-time query
|
||||
|
||||
m_timers[WorldTimers.Auctions].SetInterval(Time.Minute * Time.InMilliseconds);
|
||||
m_timers[WorldTimers.AuctionsPending].SetInterval(250);
|
||||
@@ -987,19 +988,19 @@ namespace Game
|
||||
});
|
||||
}
|
||||
|
||||
Log.SetRealmId(_realm.Id.Realm);
|
||||
Log.SetRealmId(_realm.Id.Index);
|
||||
}
|
||||
|
||||
public void LoadConfigSettings(bool reload = false)
|
||||
{
|
||||
WorldConfig.Load(reload);
|
||||
|
||||
m_defaultDbcLocale = (LocaleConstant)ConfigMgr.GetDefaultValue("DBC.Locale", 0);
|
||||
m_defaultDbcLocale = (Locale)ConfigMgr.GetDefaultValue("DBC.Locale", 0);
|
||||
|
||||
if (m_defaultDbcLocale >= LocaleConstant.Total || m_defaultDbcLocale == LocaleConstant.None)
|
||||
if (m_defaultDbcLocale >= Locale.Total || m_defaultDbcLocale == Locale.None)
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, "Incorrect DBC.Locale! Must be >= 0 and < {0} and not {1} (set to 0)", LocaleConstant.Total, LocaleConstant.None);
|
||||
m_defaultDbcLocale = LocaleConstant.enUS;
|
||||
Log.outError(LogFilter.ServerLoading, "Incorrect DBC.Locale! Must be >= 0 and < {0} and not {1} (set to 0)", Locale.Total, Locale.None);
|
||||
m_defaultDbcLocale = Locale.enUS;
|
||||
}
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Using {0} DBC Locale", m_defaultDbcLocale);
|
||||
@@ -1111,7 +1112,7 @@ namespace Game
|
||||
m_Autobroadcasts.Clear();
|
||||
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_AUTOBROADCAST);
|
||||
stmt.AddValue(0, _realm.Id.Realm);
|
||||
stmt.AddValue(0, _realm.Id.Index);
|
||||
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
if (result.IsEmpty())
|
||||
@@ -1239,7 +1240,7 @@ namespace Game
|
||||
|
||||
stmt.AddValue(0, tmpDiff);
|
||||
stmt.AddValue(1, maxOnlinePlayers);
|
||||
stmt.AddValue(2, _realm.Id.Realm);
|
||||
stmt.AddValue(2, _realm.Id.Index);
|
||||
stmt.AddValue(3, (uint)GameTime.GetStartTime());
|
||||
|
||||
DB.Login.Execute(stmt);
|
||||
@@ -1255,7 +1256,7 @@ namespace Game
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.DEL_OLD_LOGS);
|
||||
stmt.AddValue(0, WorldConfig.GetIntValue(WorldCfg.LogdbCleartime));
|
||||
stmt.AddValue(1, 0);
|
||||
stmt.AddValue(2, GetRealm().Id.Realm);
|
||||
stmt.AddValue(2, GetRealm().Id.Index);
|
||||
|
||||
DB.Login.Execute(stmt);
|
||||
}
|
||||
@@ -1806,13 +1807,13 @@ namespace Game
|
||||
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.DEL_REALM_CHARACTERS_BY_REALM);
|
||||
stmt.AddValue(0, Id);
|
||||
stmt.AddValue(1, _realm.Id.Realm);
|
||||
stmt.AddValue(1, _realm.Id.Index);
|
||||
trans.Append(stmt);
|
||||
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_REALM_CHARACTERS);
|
||||
stmt.AddValue(0, charCount);
|
||||
stmt.AddValue(1, Id);
|
||||
stmt.AddValue(2, _realm.Id.Realm);
|
||||
stmt.AddValue(2, _realm.Id.Index);
|
||||
trans.Append(stmt);
|
||||
|
||||
DB.Login.CommitTransaction(trans);
|
||||
@@ -1961,7 +1962,7 @@ namespace Game
|
||||
public void LoadDBAllowedSecurityLevel()
|
||||
{
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_REALMLIST_SECURITY_LEVEL);
|
||||
stmt.AddValue(0, _realm.Id.Realm);
|
||||
stmt.AddValue(0, _realm.Id.Index);
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
|
||||
if (!result.IsEmpty())
|
||||
@@ -2226,11 +2227,11 @@ namespace Game
|
||||
return WorldConfig.GetIntValue(WorldCfg.GameType) == (int)RealmType.FFAPVP;
|
||||
}
|
||||
|
||||
public LocaleConstant GetDefaultDbcLocale() { return m_defaultDbcLocale; }
|
||||
public Locale GetDefaultDbcLocale() { return m_defaultDbcLocale; }
|
||||
|
||||
public bool LoadRealmInfo()
|
||||
{
|
||||
SQLResult result = DB.Login.Query("SELECT id, name, address, localAddress, localSubnetMask, port, icon, flag, timezone, allowedSecurityLevel, population, gamebuild, Region, Battlegroup FROM realmlist WHERE id = {0}", _realm.Id.Realm);
|
||||
SQLResult result = DB.Login.Query("SELECT id, name, address, localAddress, localSubnetMask, port, icon, flag, timezone, allowedSecurityLevel, population, gamebuild, Region, Battlegroup FROM realmlist WHERE id = {0}", _realm.Id.Index);
|
||||
if (result.IsEmpty())
|
||||
return false;
|
||||
|
||||
@@ -2251,7 +2252,7 @@ namespace Game
|
||||
}
|
||||
|
||||
public Realm GetRealm() { return _realm; }
|
||||
public RealmHandle GetRealmId() { return _realm.Id; }
|
||||
public RealmId GetRealmId() { return _realm.Id; }
|
||||
|
||||
public void RemoveOldCorpses()
|
||||
{
|
||||
@@ -2271,7 +2272,7 @@ namespace Game
|
||||
public int GetVisibilityNotifyPeriodInInstances() { return m_visibility_notify_periodInInstances; }
|
||||
public int GetVisibilityNotifyPeriodInBGArenas() { return m_visibility_notify_periodInBGArenas; }
|
||||
|
||||
public LocaleConstant GetAvailableDbcLocale(LocaleConstant locale)
|
||||
public Locale GetAvailableDbcLocale(Locale locale)
|
||||
{
|
||||
//if (m_availableDbcLocaleMask & (1 << locale))
|
||||
//return locale;
|
||||
@@ -2319,7 +2320,7 @@ namespace Game
|
||||
Dictionary<uint, uint> m_worldstates = new Dictionary<uint, uint>();
|
||||
uint m_playerLimit;
|
||||
AccountTypes m_allowedSecurityLevel;
|
||||
LocaleConstant m_defaultDbcLocale; // from config for one from loaded DBC locales
|
||||
Locale m_defaultDbcLocale; // from config for one from loaded DBC locales
|
||||
List<string> m_motd = new List<string>();
|
||||
|
||||
// scheduled reset times
|
||||
@@ -2405,7 +2406,7 @@ namespace Game
|
||||
i_args = args;
|
||||
}
|
||||
|
||||
public override void Invoke(List<ServerPacket> data_list, LocaleConstant loc_idx)
|
||||
public override void Invoke(List<ServerPacket> data_list, Locale loc_idx)
|
||||
{
|
||||
string text = Global.ObjectMgr.GetCypherString(i_textId, loc_idx);
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ using Game.BattlePets;
|
||||
using Game.Entities;
|
||||
using Game.Guilds;
|
||||
using Game.Maps;
|
||||
using Game.Network;
|
||||
using Game.Network.Packets;
|
||||
using Game.Networking;
|
||||
using Game.Networking.Packets;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -32,12 +32,13 @@ using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Framework.Realm;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
public partial class WorldSession : IDisposable
|
||||
{
|
||||
public WorldSession(uint id, string name, uint battlenetAccountId, WorldSocket sock, AccountTypes sec, Expansion expansion, long mute_time, string os, LocaleConstant locale, uint recruiter, bool isARecruiter)
|
||||
public WorldSession(uint id, string name, uint battlenetAccountId, WorldSocket sock, AccountTypes sec, Expansion expansion, long mute_time, string os, Locale locale, uint recruiter, bool isARecruiter)
|
||||
{
|
||||
m_muteTime = mute_time;
|
||||
AntiDOS = new DosProtection(this);
|
||||
@@ -691,9 +692,9 @@ namespace Game
|
||||
AccountTypes secLevel = GetSecurity();
|
||||
|
||||
Log.outDebug(LogFilter.Rbac, "WorldSession.LoadPermissions [AccountId: {0}, Name: {1}, realmId: {2}, secLevel: {3}]",
|
||||
id, _accountName, Global.WorldMgr.GetRealm().Id.Realm, secLevel);
|
||||
id, _accountName, Global.WorldMgr.GetRealm().Id.Index, secLevel);
|
||||
|
||||
_RBACData = new RBACData(id, _accountName, (int)Global.WorldMgr.GetRealm().Id.Realm, (byte)secLevel);
|
||||
_RBACData = new RBACData(id, _accountName, (int)Global.WorldMgr.GetRealm().Id.Index, (byte)secLevel);
|
||||
_RBACData.LoadFromDB();
|
||||
}
|
||||
|
||||
@@ -703,9 +704,9 @@ namespace Game
|
||||
AccountTypes secLevel = GetSecurity();
|
||||
|
||||
Log.outDebug(LogFilter.Rbac, "WorldSession.LoadPermissions [AccountId: {0}, Name: {1}, realmId: {2}, secLevel: {3}]",
|
||||
id, _accountName, Global.WorldMgr.GetRealm().Id.Realm, secLevel);
|
||||
id, _accountName, Global.WorldMgr.GetRealm().Id.Index, secLevel);
|
||||
|
||||
_RBACData = new RBACData(id, _accountName, (int)Global.WorldMgr.GetRealm().Id.Realm, (byte)secLevel);
|
||||
_RBACData = new RBACData(id, _accountName, (int)Global.WorldMgr.GetRealm().Id.Index, (byte)secLevel);
|
||||
return _RBACData.LoadFromDBAsync();
|
||||
}
|
||||
|
||||
@@ -749,7 +750,7 @@ namespace Game
|
||||
{
|
||||
do
|
||||
{
|
||||
_realmCharacterCounts[new RealmHandle(result.Read<byte>(3), result.Read<byte>(4), result.Read<uint>(2)).GetAddress()] = result.Read<byte>(1);
|
||||
_realmCharacterCounts[new RealmId(result.Read<byte>(3), result.Read<byte>(4), result.Read<uint>(2)).GetAddress()] = result.Read<byte>(1);
|
||||
|
||||
} while (result.NextRow());
|
||||
}
|
||||
@@ -776,7 +777,7 @@ namespace Game
|
||||
|
||||
bool hasPermission = _RBACData.HasPermission(permission);
|
||||
Log.outDebug(LogFilter.Rbac, "WorldSession:HasPermission [AccountId: {0}, Name: {1}, realmId: {2}]",
|
||||
_RBACData.GetId(), _RBACData.GetName(), Global.WorldMgr.GetRealm().Id.Realm);
|
||||
_RBACData.GetId(), _RBACData.GetName(), Global.WorldMgr.GetRealm().Id.Index);
|
||||
|
||||
return hasPermission;
|
||||
}
|
||||
@@ -784,7 +785,7 @@ namespace Game
|
||||
public void InvalidateRBACData()
|
||||
{
|
||||
Log.outDebug(LogFilter.Rbac, "WorldSession:Invalidaterbac:RBACData [AccountId: {0}, Name: {1}, realmId: {2}]",
|
||||
_RBACData.GetId(), _RBACData.GetName(), Global.WorldMgr.GetRealm().Id.Realm);
|
||||
_RBACData.GetId(), _RBACData.GetName(), Global.WorldMgr.GetRealm().Id.Index);
|
||||
_RBACData = null;
|
||||
}
|
||||
|
||||
@@ -801,8 +802,8 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
public LocaleConstant GetSessionDbcLocale() { return m_sessionDbcLocale; }
|
||||
public LocaleConstant GetSessionDbLocaleIndex() { return m_sessionDbLocaleIndex; }
|
||||
public Locale GetSessionDbcLocale() { return m_sessionDbcLocale; }
|
||||
public Locale GetSessionDbLocaleIndex() { return m_sessionDbLocaleIndex; }
|
||||
|
||||
public uint GetLatency() { return m_latency; }
|
||||
public void SetLatency(uint latency) { m_latency = latency; }
|
||||
@@ -866,8 +867,8 @@ namespace Game
|
||||
bool m_playerLogout; // code processed in LogoutPlayer
|
||||
bool m_playerRecentlyLogout;
|
||||
bool m_playerSave;
|
||||
LocaleConstant m_sessionDbcLocale;
|
||||
LocaleConstant m_sessionDbLocaleIndex;
|
||||
Locale m_sessionDbcLocale;
|
||||
Locale m_sessionDbLocaleIndex;
|
||||
uint m_latency;
|
||||
uint m_clientTimeDelay;
|
||||
AccountData[] _accountData = new AccountData[(int)AccountDataTypes.Max];
|
||||
@@ -1048,7 +1049,7 @@ namespace Game
|
||||
stmt.AddValue(0, battlenetAccountId);
|
||||
SetQuery(AccountInfoQueryLoad.Mounts, stmt);
|
||||
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_CHARACTER_COUNTS_BY_ACCOUNT_ID);
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetCharacterCountsByAccountId);
|
||||
stmt.AddValue(0, accountId);
|
||||
SetQuery(AccountInfoQueryLoad.GlobalRealmCharacterCounts, stmt);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user