Engine: Add E_PostInit, called from the game after loaddefinitionsfile().

git-svn-id: https://svn.eduke32.com/eduke32@5345 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-09-23 17:54:42 +00:00
parent 6de7ed8d72
commit 43459780af
10 changed files with 94 additions and 45 deletions

View file

@ -997,6 +997,7 @@ typedef struct artheader_t {
int32_t preinitengine(void); // a partial setup of the engine used for launch windows int32_t preinitengine(void); // a partial setup of the engine used for launch windows
int32_t initengine(void); int32_t initengine(void);
int32_t E_PostInit(void);
void uninitengine(void); void uninitengine(void);
void initspritelists(void); void initspritelists(void);
int32_t loadlookups(int32_t fp); int32_t loadlookups(int32_t fp);

View file

@ -192,6 +192,7 @@ extern const char *ExtGetVer(void);
extern int32_t ExtInit(void); extern int32_t ExtInit(void);
extern int32_t ExtPreInit(int32_t argc,const char **argv); extern int32_t ExtPreInit(int32_t argc,const char **argv);
extern int32_t ExtPostStartupWindow(void); extern int32_t ExtPostStartupWindow(void);
extern void ExtPostInit(void);
extern void ExtUnInit(void); extern void ExtUnInit(void);
extern void ExtPreCheckKeys(void); extern void ExtPreCheckKeys(void);
extern void ExtAnalyzeSprites(int32_t, int32_t, int32_t, int32_t); extern void ExtAnalyzeSprites(int32_t, int32_t, int32_t, int32_t);

View file

@ -35,6 +35,7 @@ static const char *CallExtGetVer(void);
static int32_t CallExtInit(void); static int32_t CallExtInit(void);
static int32_t CallExtPreInit(int32_t argc,const char **argv); static int32_t CallExtPreInit(int32_t argc,const char **argv);
static int32_t CallExtPostStartupWindow(void); static int32_t CallExtPostStartupWindow(void);
static void CallExtPostInit(void);
static void CallExtUnInit(void); static void CallExtUnInit(void);
static void CallExtPreCheckKeys(void); static void CallExtPreCheckKeys(void);
static void CallExtAnalyzeSprites(int32_t, int32_t, int32_t, int32_t); static void CallExtAnalyzeSprites(int32_t, int32_t, int32_t, int32_t);
@ -557,6 +558,14 @@ void M32_OnShowOSD(int32_t shown)
AppGrabMouse((!shown) + 2); 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) int32_t app_main(int32_t argc, const char **argv)
{ {
#ifdef STARTUP_SETUP_WINDOW #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)); Bstrncpy(game_executable, DefaultGameLocalExec, sizeof(game_executable));
if (preinitengine()) if (preinitengine())
{ M32_FatalEngineError();
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);
}
if ((i = CallExtInit()) < 0) return -1; 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 // Here used to be the 'whitecol' calculation
if (E_PostInit())
M32_FatalEngineError();
CallExtPostInit();
#ifdef HAVE_CLIPSHAPE_FEATURE #ifdef HAVE_CLIPSHAPE_FEATURE
int k = clipmapinfo_load(); int k = clipmapinfo_load();
if (k>0) if (k>0)
@ -11089,6 +11098,10 @@ static int32_t CallExtPostStartupWindow(void)
{ {
return ExtPostStartupWindow(); return ExtPostStartupWindow();
} }
static void CallExtPostInit(void)
{
return ExtPostInit();
}
static void CallExtUnInit(void) static void CallExtUnInit(void)
{ {
ExtUnInit(); ExtUnInit();

View file

@ -9252,6 +9252,15 @@ int32_t initengine(void)
return 0; return 0;
} }
//
// E_PostInit
//
int32_t E_PostInit(void)
{
return 0;
}
// //
// uninitengine // uninitengine
// //

View file

@ -9945,6 +9945,10 @@ int32_t ExtPostStartupWindow(void)
return 0; return 0;
} }
void ExtPostInit(void)
{
}
void ExtUnInit(void) void ExtUnInit(void)
{ {
// int32_t i; // int32_t i;

View file

@ -11085,6 +11085,15 @@ static void G_HandleMemErr(int32_t line, const char *file, const char *func)
G_GameExit(msg); 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) static void G_Startup(void)
{ {
int32_t i; int32_t i;
@ -11098,13 +11107,7 @@ static void G_Startup(void)
G_CompileScripts(); G_CompileScripts();
if (initengine()) if (initengine())
{ G_FatalEngineError();
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);
}
setbasepaltable(basepaltable, BASEPALCOUNT); setbasepaltable(basepaltable, BASEPALCOUNT);
@ -11701,6 +11704,9 @@ int32_t app_main(int32_t argc, const char **argv)
Bfree(g_defModules); Bfree(g_defModules);
g_defModules = NULL; 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 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) if (numplayers == 1 && boardfilename[0] != 0)

View file

@ -898,6 +898,13 @@ int nextvoxid = 0; // JBF
extern int startwin_run(void); 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 void
InitGame(int32_t argc, const char **argv) InitGame(int32_t argc, const char **argv)
{ {
@ -908,13 +915,8 @@ InitGame(int32_t argc, const char **argv)
DSPRINTF(ds,"InitGame..."); DSPRINTF(ds,"InitGame...");
MONO_PRINT(ds); MONO_PRINT(ds);
if (initengine()) if (initengine())
{ SW_FatalEngineError();
wm_msgbox("Build Engine Initialisation Error",
"There was a problem initialising the Build engine: %s", engineerrstr);
exit(1);
}
//initgroupfile(G_GrpFile()); // JBF: moving this close to start of program to detect shareware //initgroupfile(G_GrpFile()); // JBF: moving this close to start of program to detect shareware
InitSetup(); InitSetup();
@ -1035,6 +1037,9 @@ InitGame(int32_t argc, const char **argv)
Bfree(g_defModules); Bfree(g_defModules);
g_defModules = NULL; g_defModules = NULL;
if (E_PostInit())
SW_FatalEngineError();
DemoModeMenuInit = TRUE; DemoModeMenuInit = TRUE;
// precache as much stuff as you can // precache as much stuff as you can
if (UserMapName[0] == '\0') if (UserMapName[0] == '\0')

View file

@ -778,6 +778,9 @@ else
return rv; return rv;
} }
void ExtPostInit(void)
{
}
void void
ExtUnInit(void) ExtUnInit(void)

View file

@ -156,6 +156,10 @@ int32_t ExtPostStartupWindow(void)
return 0; return 0;
} }
void ExtPostInit(void)
{
}
void ExtUnInit(void) void ExtUnInit(void)
{ {
uninitgroupfile(); uninitgroupfile();

View file

@ -432,6 +432,23 @@ static int osdcmd_map(const osdfuncparm_t *parm)
return OSDCMD_OK; 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) int32_t app_main(int32_t argc, const char **argv)
{ {
#if defined STARTUP_SETUP_WINDOW #if defined STARTUP_SETUP_WINDOW
@ -505,7 +522,7 @@ int32_t app_main(int32_t argc, const char **argv)
initgroupfile(G_GrpFile()); initgroupfile(G_GrpFile());
if (initengine()) if (initengine())
{ {
buildprintf("There was a problem initialising the engine: %s.\n", engineerrstr); Ken_FatalEngineError();
return -1; return -1;
} }
@ -527,14 +544,7 @@ int32_t app_main(int32_t argc, const char **argv)
handleevents(); handleevents();
if (quitevent) if (quitevent)
{ {
sendlogoff(); //Signing off Ken_UninitAll();
musicoff();
uninitmultiplayers();
uninittimer();
uninitinput();
uninitengine();
uninitsb();
uninitgroupfile();
return 0; return 0;
} }
} }
@ -548,6 +558,13 @@ int32_t app_main(int32_t argc, const char **argv)
tiletovox[BROWNMONSTER] = nextvoxid++; tiletovox[BROWNMONSTER] = nextvoxid++;
if (!loaddefinitionsfile(G_DefFile())) buildputs("Definitions file loaded.\n"); 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 //Here's an example of TRUE ornamented walls
//The allocatepermanenttile should be called right after loadpics //The allocatepermanenttile should be called right after loadpics
//Since it resets the tile cache for each call. //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]) if (keystatus[1])
{ {
sendlogoff(); //Signing off Ken_UninitAll();
musicoff(); return 0;
uninitmultiplayers();
uninittimer();
uninitinput();
uninitengine();
uninitsb();
uninitgroupfile();
exit(0);
} }
} }
screenpeek = myconnectindex; screenpeek = myconnectindex;
@ -737,14 +747,7 @@ int32_t app_main(int32_t argc, const char **argv)
drawscreen(screenpeek,i); drawscreen(screenpeek,i);
} }
sendlogoff(); //Signing off Ken_UninitAll();
musicoff();
uninitmultiplayers();
uninittimer();
uninitinput();
uninitengine();
uninitsb();
uninitgroupfile();
return 0; return 0;
} }