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:
Christoph Oelckers 2019-10-07 01:24:51 +02:00
commit ff379e7c0c
8 changed files with 17 additions and 9 deletions

View file

@ -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;