diff --git a/Client/mods/deathmatch/CClient.cpp b/Client/mods/deathmatch/CClient.cpp index f44830fcb2..b2c24f8aca 100644 --- a/Client/mods/deathmatch/CClient.cpp +++ b/Client/mods/deathmatch/CClient.cpp @@ -20,6 +20,7 @@ CGame* g_pGame = NULL; CMultiplayer* g_pMultiplayer = NULL; CNet* g_pNet = NULL; CClientGame* g_pClientGame = NULL; +bool g_bClientShuttingDown = false; int CClient::ClientInitialize(const char* szArguments, CCoreInterface* pCore) { @@ -183,6 +184,9 @@ int CClient::ClientInitialize(const char* szArguments, CCoreInterface* pCore) void CClient::ClientShutdown() { + // Global shutdown flag + g_bClientShuttingDown = true; + // Unbind our radio controls g_pCore->GetKeyBinds()->RemoveControlFunction("radio_next", CClientGame::HandleRadioNext); g_pCore->GetKeyBinds()->RemoveControlFunction("radio_previous", CClientGame::HandleRadioPrevious); diff --git a/Client/mods/deathmatch/CClient.h b/Client/mods/deathmatch/CClient.h index af34d09e00..132cec1be1 100644 --- a/Client/mods/deathmatch/CClient.h +++ b/Client/mods/deathmatch/CClient.h @@ -13,6 +13,8 @@ #include +extern bool g_bClientShuttingDown; + class CClient : public CClientBase { public: diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index f07ac565c8..796c887665 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -6851,6 +6851,10 @@ bool CClientGame::RestreamModel(std::uint16_t model) void CClientGame::RestreamWorld() { + // If game is shutting down, do nothing for avoid crashes + if (g_bClientShuttingDown) + return; + unsigned int numberOfFileIDs = g_pGame->GetCountOfAllFileIDs(); for (unsigned int uiModelID = 0; uiModelID < numberOfFileIDs; uiModelID++)