From 49c49b26727b94496aa506c019ab00d6c218a192 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 24 Dec 2019 20:06:55 +0100 Subject: [PATCH] - read the global settings before presenting the game selection dialog - deinit the menu in GameMain instead of using atexit. - gi == null check must include the call to FreeGameData. --- source/common/gameconfigfile.cpp | 2 +- source/common/gamecontrol.cpp | 13 +++++++------ source/common/menu/menu.h | 1 + source/common/menu/menudef.cpp | 5 ++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/source/common/gameconfigfile.cpp b/source/common/gameconfigfile.cpp index e8c360aae..82780d099 100644 --- a/source/common/gameconfigfile.cpp +++ b/source/common/gameconfigfile.cpp @@ -509,11 +509,11 @@ static FString GameName; void G_LoadConfig() { GameConfig = new FGameConfigFile(); + GameConfig->DoGlobalSetup(); } void G_ReadConfig(const char* game) { - GameConfig->DoGlobalSetup(); GameConfig->DoGameSetup(game); GameConfig->DoKeySetup(game); FBaseCVar::EnableCallbacks(); diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index 7ea2ecbd1..0e7f82727 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -322,9 +322,14 @@ int GameMain() TileFiles.CloseAll(); // do this before shutting down graphics. GLInterface.Deinit(); I_ShutdownGraphics(); + M_DeinitMenus(); paletteFreeColorTables(); - gi->FreeGameData(); - if (gi) delete gi; + if (gi) + { + gi->FreeGameData(); + delete gi; + gi = nullptr; + } #ifndef NETCODE_DISABLE if (gHaveNetworking) enet_deinitialize(); #endif @@ -521,10 +526,6 @@ int RunGame() userConfig.ProcessOptions(); G_LoadConfig(); - //I_StartupJoysticks(); - //mouseInit(); - - #ifndef NETCODE_DISABLE gHaveNetworking = !enet_initialize(); if (!gHaveNetworking) diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index 01066b110..832191be9 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -781,6 +781,7 @@ void M_UnhideCustomMenu(int menu, int itemmask); void M_MenuSound(EMenuSounds snd); void M_Autosave(); bool M_Active(); +void M_DeinitMenus(); void I_SetMouseCapture(); diff --git a/source/common/menu/menudef.cpp b/source/common/menu/menudef.cpp index 94bedc889..bfb3fed08 100644 --- a/source/common/menu/menudef.cpp +++ b/source/common/menu/menudef.cpp @@ -67,7 +67,7 @@ void I_BuildMIDIMenuList(FOptionValues* opt); void I_BuildALDeviceList(FOptionValues *opt); void I_BuildALResamplersList(FOptionValues* opt); -static void DeinitMenus() +void M_DeinitMenus() { { MenuDescriptorList::Iterator it(MenuDescriptors); @@ -1143,8 +1143,7 @@ void M_ParseMenuDefs() DefaultListMenuSettings.Reset(); DefaultOptionMenuSettings.Reset(); - atexit(DeinitMenus); - DeinitMenus(); + M_DeinitMenus(); while ((lump = fileSystem.Iterate("demolition/menudef.txt", &lastlump)) != -1) { FScanner sc(lump);