Core/vmaps: Stop worldserver startup when gameobject models cannot be loaded

Port From (https://github.com/TrinityCore/TrinityCore/commit/a2ec80b14ced0d32e5929af6286667de63e9d0ae)
This commit is contained in:
hondacrx
2023-01-04 16:41:58 -05:00
parent 4718f88ed5
commit c686484ce5
2 changed files with 10 additions and 4 deletions
@@ -225,14 +225,14 @@ namespace Game.Collision
public bool IsMapObject() { return isWmo; } public bool IsMapObject() { return isWmo; }
public byte GetNameSetId() { return owner.GetNameSetId(); } public byte GetNameSetId() { return owner.GetNameSetId(); }
public static void LoadGameObjectModelList() public static bool LoadGameObjectModelList()
{ {
uint oldMSTime = Time.GetMSTime(); uint oldMSTime = Time.GetMSTime();
var filename = Global.WorldMgr.GetDataPath() + "/vmaps/GameObjectModels.dtree"; var filename = Global.WorldMgr.GetDataPath() + "/vmaps/GameObjectModels.dtree";
if (!File.Exists(filename)) if (!File.Exists(filename))
{ {
Log.outWarn(LogFilter.Server, "Unable to open '{0}' file.", filename); Log.outWarn(LogFilter.Server, "Unable to open '{0}' file.", filename);
return; return false;
} }
try try
{ {
@@ -241,7 +241,7 @@ namespace Game.Collision
if (magic != MapConst.VMapMagic) if (magic != MapConst.VMapMagic)
{ {
Log.outError(LogFilter.Misc, $"File '{filename}' has wrong header, expected {MapConst.VMapMagic}."); Log.outError(LogFilter.Misc, $"File '{filename}' has wrong header, expected {MapConst.VMapMagic}.");
return; return false;
} }
long length = reader.BaseStream.Length; long length = reader.BaseStream.Length;
@@ -266,6 +266,7 @@ namespace Game.Collision
} }
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} GameObject models in {1} ms", StaticModelList.models.Count, Time.GetMSTimeDiffToNow(oldMSTime)); Log.outInfo(LogFilter.ServerLoading, "Loaded {0} GameObject models in {1} ms", StaticModelList.models.Count, Time.GetMSTimeDiffToNow(oldMSTime));
return true;
} }
bool _collisionEnabled; bool _collisionEnabled;
+6 -1
View File
@@ -410,7 +410,7 @@ namespace Game
|| !TerrainManager.ExistMapAndVMap(1, 10311.3f, 832.463f) || !TerrainManager.ExistMapAndVMap(1, -2917.58f, -257.98f) || !TerrainManager.ExistMapAndVMap(1, 10311.3f, 832.463f) || !TerrainManager.ExistMapAndVMap(1, -2917.58f, -257.98f)
|| (WorldConfig.GetIntValue(WorldCfg.Expansion) != 0 && (!TerrainManager.ExistMapAndVMap(530, 10349.6f, -6357.29f) || !TerrainManager.ExistMapAndVMap(530, -3961.64f, -13931.2f)))) || (WorldConfig.GetIntValue(WorldCfg.Expansion) != 0 && (!TerrainManager.ExistMapAndVMap(530, 10349.6f, -6357.29f) || !TerrainManager.ExistMapAndVMap(530, -3961.64f, -13931.2f))))
{ {
Log.outError(LogFilter.ServerLoading, "Unable to load critical files - server shutting down !!!"); Log.outError(LogFilter.ServerLoading, "Unable to load map and vmap data for starting zones - server shutting down!");
Environment.Exit(1); Environment.Exit(1);
} }
@@ -508,6 +508,11 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, "Loading GameObject models..."); Log.outInfo(LogFilter.ServerLoading, "Loading GameObject models...");
GameObjectModel.LoadGameObjectModelList(); GameObjectModel.LoadGameObjectModelList();
if (!GameObjectModel.LoadGameObjectModelList())
{
Log.outFatal(LogFilter.ServerLoading, "Unable to load gameobject models, objects using WMO models will crash the client - server shutting down!");
ShutdownServ(0, ShutdownMask.Force, ShutdownExitCode.Shutdown);
}
Log.outInfo(LogFilter.ServerLoading, "Loading Instance Template..."); Log.outInfo(LogFilter.ServerLoading, "Loading Instance Template...");
Global.ObjectMgr.LoadInstanceTemplate(); Global.ObjectMgr.LoadInstanceTemplate();