mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 14:01:45 +00:00
replaced all 'exit's with an ExitEvent exception
The main exits are initiated from code that cannot filter this back to D_DoomMain easily so the exception is the only way to get there. The 3 main points of exit are: * quit/exit CCMD * quitting the menu through ST_Endoom * receiving a quit message on the main window.
This commit is contained in:
parent
5d265d2d88
commit
ff379e7c0c
8 changed files with 17 additions and 9 deletions
|
@ -101,12 +101,12 @@ bool CheckCheatmode (bool printmsg)
|
|||
|
||||
CCMD (quit)
|
||||
{
|
||||
if (!insave) exit(0);
|
||||
if (!insave) throw CExitEvent(0);
|
||||
}
|
||||
|
||||
CCMD (exit)
|
||||
{
|
||||
if (!insave) exit(0);
|
||||
if (!insave) throw CExitEvent(0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -726,7 +726,7 @@ int FIWadManager::IdentifyVersion (TArray<FString> &wadfiles, const char *iwad,
|
|||
}
|
||||
else
|
||||
{
|
||||
exit(0);
|
||||
return -1;
|
||||
}
|
||||
havepicked = true;
|
||||
}
|
||||
|
@ -793,6 +793,7 @@ int FIWadManager::IdentifyVersion (TArray<FString> &wadfiles, const char *iwad,
|
|||
const FIWADInfo *FIWadManager::FindIWAD(TArray<FString> &wadfiles, const char *iwad, const char *basewad, const char *optionalwad)
|
||||
{
|
||||
int iwadType = IdentifyVersion(wadfiles, iwad, basewad, optionalwad);
|
||||
if (iwadType == -1) return nullptr;
|
||||
//gameiwad = iwadType;
|
||||
const FIWADInfo *iwad_info = &mIWadInfos[iwadType];
|
||||
if (DoomStartupInfo.Name.IsEmpty()) DoomStartupInfo.Name = iwad_info->Name;
|
||||
|
|
|
@ -2459,6 +2459,7 @@ static int D_DoomMain_Internal (void)
|
|||
iwad_man = new FIWadManager(basewad, optionalwad);
|
||||
}
|
||||
const FIWADInfo *iwad_info = iwad_man->FindIWAD(allwads, iwad, basewad, optionalwad);
|
||||
if (!iwad_info) return 0; // user exited the selection popup via cancel button.
|
||||
gameinfo.gametype = iwad_info->gametype;
|
||||
gameinfo.flags = iwad_info->flags;
|
||||
gameinfo.ConfigName = iwad_info->Configname;
|
||||
|
@ -2847,7 +2848,11 @@ int D_DoomMain()
|
|||
{
|
||||
ret = D_DoomMain_Internal();
|
||||
}
|
||||
catch (std::exception &error)
|
||||
catch (const CExitEvent &exit) // This is a regular exit initiated from deeply nested code.
|
||||
{
|
||||
ret = exit.Reason();
|
||||
}
|
||||
catch (const std::exception &error)
|
||||
{
|
||||
I_ShowFatalError(error.what());
|
||||
ret = -1;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "doomtype.h"
|
||||
#include "st_console.h"
|
||||
#include "st_start.h"
|
||||
#include "doomerrors.h"
|
||||
|
||||
|
||||
FStartupScreen *StartScreen;
|
||||
|
@ -174,5 +175,5 @@ void ST_Endoom()
|
|||
extern void I_ShutdownJoysticks();
|
||||
I_ShutdownJoysticks();
|
||||
|
||||
exit(0);
|
||||
throw CExitEvent(0);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "g_game.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "utf8.h"
|
||||
#include "doomerrors.h"
|
||||
|
||||
|
||||
static void I_CheckGUICapture ();
|
||||
|
@ -297,7 +298,7 @@ void MessagePump (const SDL_Event &sev)
|
|||
switch (sev.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
exit(0);
|
||||
throw CExitEvent(0);
|
||||
|
||||
case SDL_WINDOWEVENT:
|
||||
extern void ProcessSDLWindowEvent(const SDL_WindowEvent &);
|
||||
|
|
|
@ -350,5 +350,5 @@ bool FTTYStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata)
|
|||
void ST_Endoom()
|
||||
{
|
||||
I_ShutdownJoysticks();
|
||||
exit(0);
|
||||
throw CExitEvent(0);
|
||||
}
|
||||
|
|
|
@ -739,7 +739,7 @@ void I_GetEvent ()
|
|||
while (PeekMessage (&mess, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
if (mess.message == WM_QUIT)
|
||||
exit(mess.wParam);
|
||||
throw CExitEvent(mess.wParam);
|
||||
|
||||
if (GUICapture)
|
||||
{
|
||||
|
|
|
@ -611,7 +611,7 @@ int RunEndoom()
|
|||
void ST_Endoom()
|
||||
{
|
||||
int code = RunEndoom();
|
||||
exit(code);
|
||||
throw CExitEvent(code);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue