Refactoring of BNetServer

This commit is contained in:
hondacrx
2020-07-12 00:06:43 -04:00
parent 4164384b72
commit 581d077acd
318 changed files with 2046 additions and 4694 deletions
+8 -8
View File
@@ -20,7 +20,7 @@ using Framework.Constants;
using Framework.Database;
using Game;
using Game.Chat;
using Game.Network;
using Game.Networking;
using System;
using System.Diagnostics;
using System.Globalization;
@@ -50,7 +50,7 @@ namespace WorldServer
uint startupBegin = Time.GetMSTime();
// set server offline (not connectable)
DB.Login.DirectExecute("UPDATE realmlist SET flag = (flag & ~{0}) | {1} WHERE id = '{2}'", (uint)RealmFlags.VersionMismatch, (uint)RealmFlags.Offline, Global.WorldMgr.GetRealm().Id.Realm);
DB.Login.DirectExecute("UPDATE realmlist SET flag = (flag & ~{0}) | {1} WHERE id = '{2}'", (uint)RealmFlags.VersionMismatch, (uint)RealmFlags.Offline, Global.WorldMgr.GetRealm().Id.Index);
Global.RealmMgr.Initialize(ConfigMgr.GetDefaultValue("RealmsStateUpdateDelay", 10));
@@ -76,7 +76,7 @@ namespace WorldServer
}
// set server online (allow connecting now)
DB.Login.DirectExecute("UPDATE realmlist SET flag = flag & ~{0}, population = 0 WHERE id = '{1}'", (uint)RealmFlags.Offline, Global.WorldMgr.GetRealm().Id.Realm);
DB.Login.DirectExecute("UPDATE realmlist SET flag = flag & ~{0}, population = 0 WHERE id = '{1}'", (uint)RealmFlags.Offline, Global.WorldMgr.GetRealm().Id.Index);
Global.WorldMgr.GetRealm().PopulationLevel = 0.0f;
Global.WorldMgr.GetRealm().Flags = Global.WorldMgr.GetRealm().Flags & ~RealmFlags.VersionMismatch;
@@ -111,7 +111,7 @@ namespace WorldServer
Global.ScriptMgr.Unload();
// set server offline
DB.Login.DirectExecute("UPDATE realmlist SET flag = flag | {0} WHERE id = '{1}'", (uint)RealmFlags.Offline, Global.WorldMgr.GetRealm().Id.Realm);
DB.Login.DirectExecute("UPDATE realmlist SET flag = flag | {0} WHERE id = '{1}'", (uint)RealmFlags.Offline, Global.WorldMgr.GetRealm().Id.Index);
Global.RealmMgr.Close();
ClearOnlineAccounts();
@@ -138,13 +138,13 @@ namespace WorldServer
return false;
// Get the realm Id from the configuration file
Global.WorldMgr.GetRealm().Id.Realm = ConfigMgr.GetDefaultValue("RealmID", 0u);
if (Global.WorldMgr.GetRealm().Id.Realm == 0)
Global.WorldMgr.GetRealm().Id.Index = ConfigMgr.GetDefaultValue("RealmID", 0u);
if (Global.WorldMgr.GetRealm().Id.Index == 0)
{
Log.outError(LogFilter.Server, "Realm ID not defined in configuration file");
return false;
}
Log.outInfo(LogFilter.ServerLoading, "Realm running as realm ID {0} ", Global.WorldMgr.GetRealm().Id.Realm);
Log.outInfo(LogFilter.ServerLoading, "Realm running as realm ID {0} ", Global.WorldMgr.GetRealm().Id.Index);
// Clean the database before starting
ClearOnlineAccounts();
@@ -156,7 +156,7 @@ namespace WorldServer
static void ClearOnlineAccounts()
{
// Reset online status for all accounts with characters on the current realm
DB.Login.DirectExecute("UPDATE account SET online = 0 WHERE online > 0 AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = {0})", Global.WorldMgr.GetRealm().Id.Realm);
DB.Login.DirectExecute("UPDATE account SET online = 0 WHERE online > 0 AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = {0})", Global.WorldMgr.GetRealm().Id.Index);
// Reset online status for all characters
DB.Characters.DirectExecute("UPDATE characters SET online = 0 WHERE online <> 0");