aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-04-30 00:20:38 +0200
committerShauren <shauren.trinity@gmail.com>2024-04-30 00:20:38 +0200
commit8e3024a96ab06b5e2d6da529c5e3db9ce5744c4e (patch)
tree51f55eed5c2aa7e166a20732a771b739c82c73f8 /src/server/game
parentcc9241784491198581a19f3f5502a42d048ea063 (diff)
Core/Misc: Refactor loading process to remove exit() calls that cause deadlocks because threads are terminated without proper cleanup
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/DataStores/DB2Stores.cpp8
-rw-r--r--src/server/game/World/World.cpp11
-rw-r--r--src/server/game/World/World.h2
3 files changed, 10 insertions, 11 deletions
diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp
index 55c7641c1d7..3f3cf755a5e 100644
--- a/src/server/game/DataStores/DB2Stores.cpp
+++ b/src/server/game/DataStores/DB2Stores.cpp
@@ -980,15 +980,13 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul
LOAD_DB2(sWorldMapOverlayStore);
LOAD_DB2(sWorldStateExpressionStore);
-#undef LOAD_DB2
-
// error checks
if (!loadErrors.empty())
{
sLog->SetSynchronous(); // server will shut down after this, so set sync logging to prevent messages from getting lost
for (std::string const& error : loadErrors)
- TC_LOG_ERROR("misc", "{}", error);
+ TC_LOG_FATAL("misc", "{}", error);
return 0;
}
@@ -1002,8 +1000,8 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul
!sMapStore.LookupEntry(2708) || // last map added in 10.2.5 (53007)
!sSpellNameStore.LookupEntry(438878)) // last spell added in 10.2.5 (53007)
{
- TC_LOG_ERROR("misc", "You have _outdated_ DB2 files. Please extract correct versions from current using client.");
- exit(1);
+ TC_LOG_FATAL("misc", "You have _outdated_ DB2 files. Please extract correct versions from current using client.");
+ return 0;
}
for (AreaGroupMemberEntry const* areaGroupMember : sAreaGroupMemberStore)
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 1c2255e30eb..05b92b9d334 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1730,7 +1730,7 @@ void World::LoadConfigSettings(bool reload)
}
/// Initialize the World
-void World::SetInitialWorldSettings()
+bool World::SetInitialWorldSettings()
{
sLog->SetRealmId(realm.Id.Realm);
@@ -1769,7 +1769,7 @@ void World::SetInitialWorldSettings()
!TerrainMgr::ExistMapAndVMap(530, -3961.64f, -13931.2f))))
{
TC_LOG_FATAL("server.loading", "Unable to load map and vmap data for starting zones - server shutting down!");
- exit(1);
+ return false;
}
///- Initialize pool manager
@@ -1782,7 +1782,7 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading Trinity strings...");
if (!sObjectMgr->LoadTrinityStrings())
- exit(1); // Error message displayed in function already
+ return false; // Error message displayed in function already
///- Update the realm entry in the database with the realm type from the config file
//No SQL injection as values are treated as integers
@@ -1799,14 +1799,14 @@ void World::SetInitialWorldSettings()
if (!(m_availableDbcLocaleMask & (1 << m_defaultDbcLocale)))
{
TC_LOG_FATAL("server.loading", "Unable to load db2 files for {} locale specified in DBC.Locale config!", localeNames[m_defaultDbcLocale]);
- exit(1);
+ return false;
}
TC_LOG_INFO("server.loading", "Loading GameObject models...");
if (!LoadGameObjectModelList(m_dataPath))
{
TC_LOG_FATAL("server.loading", "Unable to load gameobject models (part of vmaps), objects using WMO models will crash the client - server shutting down!");
- exit(1);
+ return false;
}
TC_LOG_INFO("misc", "Loading hotfix blobs...");
@@ -2537,6 +2537,7 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.worldserver", "World initialized in {} minutes {} seconds", (startupDuration / 60000), ((startupDuration % 60000) / 1000));
TC_METRIC_EVENT("events", "World initialized", "World initialized in " + std::to_string(startupDuration / 60000) + " minutes " + std::to_string((startupDuration % 60000) / 1000) + " seconds");
+ return true;
}
void World::SetForcedWarModeFactionBalanceState(TeamId team, int32 reward)
diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
index 7c7dcbb5cfc..80bd856a94a 100644
--- a/src/server/game/World/World.h
+++ b/src/server/game/World/World.h
@@ -648,7 +648,7 @@ class TC_GAME_API World
return lvl > 60 ? 300 + ((lvl - 60) * 75) / 10 : lvl * 5;
}
- void SetInitialWorldSettings();
+ bool SetInitialWorldSettings();
void LoadConfigSettings(bool reload = false);
void SendWorldText(uint32 string_id, ...);