diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 4cd3369b7..be1beaddd 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -997,6 +997,7 @@ typedef struct artheader_t { int32_t preinitengine(void); // a partial setup of the engine used for launch windows int32_t initengine(void); +int32_t E_PostInit(void); void uninitengine(void); void initspritelists(void); int32_t loadlookups(int32_t fp); diff --git a/polymer/eduke32/build/include/editor.h b/polymer/eduke32/build/include/editor.h index db6354df5..06921a4e7 100644 --- a/polymer/eduke32/build/include/editor.h +++ b/polymer/eduke32/build/include/editor.h @@ -192,6 +192,7 @@ extern const char *ExtGetVer(void); extern int32_t ExtInit(void); extern int32_t ExtPreInit(int32_t argc,const char **argv); extern int32_t ExtPostStartupWindow(void); +extern void ExtPostInit(void); extern void ExtUnInit(void); extern void ExtPreCheckKeys(void); extern void ExtAnalyzeSprites(int32_t, int32_t, int32_t, int32_t); diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 647374362..d6b8833ac 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -35,6 +35,7 @@ static const char *CallExtGetVer(void); static int32_t CallExtInit(void); static int32_t CallExtPreInit(int32_t argc,const char **argv); static int32_t CallExtPostStartupWindow(void); +static void CallExtPostInit(void); static void CallExtUnInit(void); static void CallExtPreCheckKeys(void); static void CallExtAnalyzeSprites(int32_t, int32_t, int32_t, int32_t); @@ -557,6 +558,14 @@ void M32_OnShowOSD(int32_t shown) AppGrabMouse((!shown) + 2); } +static void M32_FatalEngineError(void) +{ + wm_msgbox("Build Engine Initialization Error", + "There was a problem initializing the Build engine: %s", engineerrstr); + ERRprintf("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr); + exit(2); +} + int32_t app_main(int32_t argc, const char **argv) { #ifdef STARTUP_SETUP_WINDOW @@ -636,12 +645,7 @@ int32_t app_main(int32_t argc, const char **argv) Bstrncpy(game_executable, DefaultGameLocalExec, sizeof(game_executable)); if (preinitengine()) - { - wm_msgbox("Build Engine Initialization Error", - "There was a problem initializing the Build engine: %s", engineerrstr); - ERRprintf("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr); - Bexit(2); - } + M32_FatalEngineError(); if ((i = CallExtInit()) < 0) return -1; @@ -720,6 +724,11 @@ int32_t app_main(int32_t argc, const char **argv) // Here used to be the 'whitecol' calculation + if (E_PostInit()) + M32_FatalEngineError(); + + CallExtPostInit(); + #ifdef HAVE_CLIPSHAPE_FEATURE int k = clipmapinfo_load(); if (k>0) @@ -11089,6 +11098,10 @@ static int32_t CallExtPostStartupWindow(void) { return ExtPostStartupWindow(); } +static void CallExtPostInit(void) +{ + return ExtPostInit(); +} static void CallExtUnInit(void) { ExtUnInit(); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 6678e0292..9f05a9428 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -9252,6 +9252,15 @@ int32_t initengine(void) return 0; } +// +// E_PostInit +// + +int32_t E_PostInit(void) +{ + return 0; +} + // // uninitengine // diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index a08f3ea06..231ab4eb0 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -9945,6 +9945,10 @@ int32_t ExtPostStartupWindow(void) return 0; } +void ExtPostInit(void) +{ +} + void ExtUnInit(void) { // int32_t i; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 92da984b6..30bb11569 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -11085,6 +11085,15 @@ static void G_HandleMemErr(int32_t line, const char *file, const char *func) G_GameExit(msg); } +static void G_FatalEngineError(void) +{ + wm_msgbox("Build Engine Initialization Error", + "There was a problem initializing the Build engine: %s", engineerrstr); + G_Cleanup(); + ERRprintf("G_Startup: There was a problem initializing the Build engine: %s\n", engineerrstr); + exit(6); +} + static void G_Startup(void) { int32_t i; @@ -11098,13 +11107,7 @@ static void G_Startup(void) G_CompileScripts(); if (initengine()) - { - wm_msgbox("Build Engine Initialization Error", - "There was a problem initializing the Build engine: %s", engineerrstr); - G_Cleanup(); - ERRprintf("G_Startup: There was a problem initializing the Build engine: %s\n", engineerrstr); - Bexit(6); - } + G_FatalEngineError(); setbasepaltable(basepaltable, BASEPALCOUNT); @@ -11701,6 +11704,9 @@ int32_t app_main(int32_t argc, const char **argv) Bfree(g_defModules); g_defModules = NULL; + if (E_PostInit()) + G_FatalEngineError(); + Gv_ResetSystemDefaults(); // called here to populate our fake tilesizx and tilesizy arrays presented to CON with sizes generated by dummytiles if (numplayers == 1 && boardfilename[0] != 0) diff --git a/polymer/eduke32/source/sw/src/game.c b/polymer/eduke32/source/sw/src/game.c index b40c12ab2..b905ee6fd 100644 --- a/polymer/eduke32/source/sw/src/game.c +++ b/polymer/eduke32/source/sw/src/game.c @@ -898,6 +898,13 @@ int nextvoxid = 0; // JBF extern int startwin_run(void); +static void SW_FatalEngineError(void) +{ + wm_msgbox("Build Engine Initialisation Error", + "There was a problem initialising the Build engine: %s", engineerrstr); + exit(1); +} + void InitGame(int32_t argc, const char **argv) { @@ -908,13 +915,8 @@ InitGame(int32_t argc, const char **argv) DSPRINTF(ds,"InitGame..."); MONO_PRINT(ds); - if (initengine()) - { - wm_msgbox("Build Engine Initialisation Error", - "There was a problem initialising the Build engine: %s", engineerrstr); - exit(1); - } + SW_FatalEngineError(); //initgroupfile(G_GrpFile()); // JBF: moving this close to start of program to detect shareware InitSetup(); @@ -1035,6 +1037,9 @@ InitGame(int32_t argc, const char **argv) Bfree(g_defModules); g_defModules = NULL; + if (E_PostInit()) + SW_FatalEngineError(); + DemoModeMenuInit = TRUE; // precache as much stuff as you can if (UserMapName[0] == '\0') diff --git a/polymer/eduke32/source/sw/src/jnstub.c b/polymer/eduke32/source/sw/src/jnstub.c index bac6ab4b1..aa21ebcbb 100644 --- a/polymer/eduke32/source/sw/src/jnstub.c +++ b/polymer/eduke32/source/sw/src/jnstub.c @@ -778,6 +778,9 @@ else return rv; } +void ExtPostInit(void) +{ +} void ExtUnInit(void) diff --git a/polymer/eduke32/source/testgame/src/bstub.c b/polymer/eduke32/source/testgame/src/bstub.c index 40123043c..e022998f3 100644 --- a/polymer/eduke32/source/testgame/src/bstub.c +++ b/polymer/eduke32/source/testgame/src/bstub.c @@ -156,6 +156,10 @@ int32_t ExtPostStartupWindow(void) return 0; } +void ExtPostInit(void) +{ +} + void ExtUnInit(void) { uninitgroupfile(); diff --git a/polymer/eduke32/source/testgame/src/game.c b/polymer/eduke32/source/testgame/src/game.c index ef89399c0..fa038abb8 100644 --- a/polymer/eduke32/source/testgame/src/game.c +++ b/polymer/eduke32/source/testgame/src/game.c @@ -432,6 +432,23 @@ static int osdcmd_map(const osdfuncparm_t *parm) return OSDCMD_OK; } +static void Ken_UninitAll(void) +{ + sendlogoff(); //Signing off + musicoff(); + uninitmultiplayers(); + uninittimer(); + uninitinput(); + uninitengine(); + uninitsb(); + uninitgroupfile(); +} + +static void Ken_FatalEngineError(void) +{ + buildprintf("There was a problem initialising the engine: %s.\n", engineerrstr); +} + int32_t app_main(int32_t argc, const char **argv) { #if defined STARTUP_SETUP_WINDOW @@ -505,7 +522,7 @@ int32_t app_main(int32_t argc, const char **argv) initgroupfile(G_GrpFile()); if (initengine()) { - buildprintf("There was a problem initialising the engine: %s.\n", engineerrstr); + Ken_FatalEngineError(); return -1; } @@ -527,14 +544,7 @@ int32_t app_main(int32_t argc, const char **argv) handleevents(); if (quitevent) { - sendlogoff(); //Signing off - musicoff(); - uninitmultiplayers(); - uninittimer(); - uninitinput(); - uninitengine(); - uninitsb(); - uninitgroupfile(); + Ken_UninitAll(); return 0; } } @@ -548,6 +558,13 @@ int32_t app_main(int32_t argc, const char **argv) tiletovox[BROWNMONSTER] = nextvoxid++; if (!loaddefinitionsfile(G_DefFile())) buildputs("Definitions file loaded.\n"); + if (E_PostInit()) + { + Ken_UninitAll(); + Ken_FatalEngineError(); + return -1; + } + //Here's an example of TRUE ornamented walls //The allocatepermanenttile should be called right after loadpics //Since it resets the tile cache for each call. @@ -618,15 +635,8 @@ int32_t app_main(int32_t argc, const char **argv) if (keystatus[1]) { - sendlogoff(); //Signing off - musicoff(); - uninitmultiplayers(); - uninittimer(); - uninitinput(); - uninitengine(); - uninitsb(); - uninitgroupfile(); - exit(0); + Ken_UninitAll(); + return 0; } } screenpeek = myconnectindex; @@ -737,14 +747,7 @@ int32_t app_main(int32_t argc, const char **argv) drawscreen(screenpeek,i); } - sendlogoff(); //Signing off - musicoff(); - uninitmultiplayers(); - uninittimer(); - uninitinput(); - uninitengine(); - uninitsb(); - uninitgroupfile(); + Ken_UninitAll(); return 0; }