mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
Use enum for better maintainability & error checking
This commit is contained in:
parent
3469ab12ba
commit
c93330bf20
4 changed files with 51 additions and 26 deletions
|
|
@ -58,7 +58,7 @@ I_mutex con_mutex;
|
||||||
static boolean con_started = false; // console has been initialised
|
static boolean con_started = false; // console has been initialised
|
||||||
boolean con_startup = false; // true at game startup, screen need refreshing
|
boolean con_startup = false; // true at game startup, screen need refreshing
|
||||||
|
|
||||||
UINT8 con_startup_loadprogress = 0; // Progress for startup load bar
|
con_loadprogress_t con_startup_loadprogress = 0; // Progress for startup load bar
|
||||||
|
|
||||||
static boolean con_forcepic = true; // at startup toggle console translucency when first off
|
static boolean con_forcepic = true; // at startup toggle console translucency when first off
|
||||||
boolean con_recalc; // set true when screen size has changed
|
boolean con_recalc; // set true when screen size has changed
|
||||||
|
|
@ -1907,6 +1907,22 @@ void CON_Drawer(void)
|
||||||
Unlock_state();
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Error handling for the loading bar, to ensure it doesn't skip any steps.
|
||||||
|
//
|
||||||
|
void CON_SetLoadingProgress(con_loadprogress_t newStep)
|
||||||
|
{
|
||||||
|
const con_loadprogress_t expectedStep = con_startup_loadprogress + 1;
|
||||||
|
|
||||||
|
if (newStep != expectedStep)
|
||||||
|
{
|
||||||
|
I_Error("Something is wrong with the loading bar! (got %d, expected %d)\n", newStep, expectedStep);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
con_startup_loadprogress = newStep;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Draws a simple white fill at the bottom of startup for load progress
|
// Draws a simple white fill at the bottom of startup for load progress
|
||||||
//
|
//
|
||||||
|
|
@ -1917,13 +1933,6 @@ void CON_DrawLoadBar(void)
|
||||||
|
|
||||||
Lock_state();
|
Lock_state();
|
||||||
|
|
||||||
if (con_startup_loadprogress > CON_STARTUP_LOADSTEPS)
|
|
||||||
{
|
|
||||||
Unlock_state();
|
|
||||||
I_Error("CON_STARTUP_LOADSTEPS is too low! (is %d, got %d)\n", CON_STARTUP_LOADSTEPS, con_startup_loadprogress);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!con_started || !graphics_started)
|
if (!con_started || !graphics_started)
|
||||||
{
|
{
|
||||||
Unlock_state();
|
Unlock_state();
|
||||||
|
|
@ -1932,7 +1941,7 @@ void CON_DrawLoadBar(void)
|
||||||
|
|
||||||
CON_DrawBackpic();
|
CON_DrawBackpic();
|
||||||
|
|
||||||
barwidth = (BASEVIDWIDTH * con_startup_loadprogress) / CON_STARTUP_LOADSTEPS;
|
barwidth = (BASEVIDWIDTH * con_startup_loadprogress) / LOADED_ALLDONE;
|
||||||
V_DrawFill(0, BASEVIDHEIGHT - barheight, barwidth, barheight, 0);
|
V_DrawFill(0, BASEVIDHEIGHT - barheight, barwidth, barheight, 0);
|
||||||
|
|
||||||
Unlock_state();
|
Unlock_state();
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,24 @@ extern boolean con_recalc;
|
||||||
|
|
||||||
extern boolean con_startup;
|
extern boolean con_startup;
|
||||||
|
|
||||||
extern UINT8 con_startup_loadprogress;
|
typedef enum
|
||||||
#define CON_STARTUP_LOADSTEPS 12
|
{
|
||||||
|
LOADED_ZINIT = 1,
|
||||||
|
LOADED_ISTARTUPTIMER,
|
||||||
|
LOADED_IWAD,
|
||||||
|
LOADED_PWAD,
|
||||||
|
LOADED_ISTARTUPGRAPHICS,
|
||||||
|
LOADED_HULOADGRAPHICS,
|
||||||
|
LOADED_RENDERER,
|
||||||
|
LOADED_MINIT,
|
||||||
|
LOADED_RINIT,
|
||||||
|
LOADED_SINITSFXCHANNELS,
|
||||||
|
LOADED_STINIT,
|
||||||
|
LOADED_DCHECKNETGAME,
|
||||||
|
LOADED_ALLDONE = LOADED_DCHECKNETGAME,
|
||||||
|
} con_loadprogress_t;
|
||||||
|
|
||||||
|
extern con_loadprogress_t con_startup_loadprogress;
|
||||||
|
|
||||||
// top clip value for view render: do not draw part of view hidden by console
|
// top clip value for view render: do not draw part of view hidden by console
|
||||||
extern INT32 con_clipviewtop;
|
extern INT32 con_clipviewtop;
|
||||||
|
|
@ -67,4 +83,5 @@ boolean CON_Ready(void);
|
||||||
void CON_LogMessage(const char *msg);
|
void CON_LogMessage(const char *msg);
|
||||||
|
|
||||||
// Startup loading bar
|
// Startup loading bar
|
||||||
|
void CON_SetLoadingProgress(con_loadprogress_t newStep);
|
||||||
void CON_DrawLoadBar(void);
|
void CON_DrawLoadBar(void);
|
||||||
|
|
|
||||||
28
src/d_main.c
28
src/d_main.c
|
|
@ -1281,7 +1281,7 @@ void D_SRB2Main(void)
|
||||||
|
|
||||||
CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n");
|
CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n");
|
||||||
Z_Init();
|
Z_Init();
|
||||||
con_startup_loadprogress++;
|
CON_SetLoadingProgress(LOADED_ZINIT);
|
||||||
|
|
||||||
// Do this up here so that WADs loaded through the command line can use ExecCfg
|
// Do this up here so that WADs loaded through the command line can use ExecCfg
|
||||||
COM_Init();
|
COM_Init();
|
||||||
|
|
@ -1365,7 +1365,7 @@ void D_SRB2Main(void)
|
||||||
|
|
||||||
CONS_Printf("I_StartupTimer()...\n");
|
CONS_Printf("I_StartupTimer()...\n");
|
||||||
I_StartupTimer();
|
I_StartupTimer();
|
||||||
con_startup_loadprogress++;
|
CON_SetLoadingProgress(LOADED_ISTARTUPTIMER);
|
||||||
|
|
||||||
// Make backups of some SOCcable tables.
|
// Make backups of some SOCcable tables.
|
||||||
P_BackupTables();
|
P_BackupTables();
|
||||||
|
|
@ -1429,7 +1429,7 @@ void D_SRB2Main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
con_startup_loadprogress++; // finished IWADs
|
CON_SetLoadingProgress(LOADED_IWAD);
|
||||||
|
|
||||||
CONS_Printf("W_InitMultipleFiles(): Adding external PWADs.\n");
|
CONS_Printf("W_InitMultipleFiles(): Adding external PWADs.\n");
|
||||||
W_InitMultipleFiles(startuppwads, true);
|
W_InitMultipleFiles(startuppwads, true);
|
||||||
|
|
@ -1468,7 +1468,7 @@ void D_SRB2Main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
con_startup_loadprogress++; // finished PWADs
|
CON_SetLoadingProgress(LOADED_PWAD);
|
||||||
|
|
||||||
cht_Init();
|
cht_Init();
|
||||||
|
|
||||||
|
|
@ -1477,7 +1477,7 @@ void D_SRB2Main(void)
|
||||||
|
|
||||||
CONS_Printf("I_StartupGraphics()...\n");
|
CONS_Printf("I_StartupGraphics()...\n");
|
||||||
I_StartupGraphics();
|
I_StartupGraphics();
|
||||||
con_startup_loadprogress++;
|
CON_SetLoadingProgress(LOADED_ISTARTUPGRAPHICS);
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
// Lactozilla: Add every hardware mode CVAR and CCMD.
|
// Lactozilla: Add every hardware mode CVAR and CCMD.
|
||||||
|
|
@ -1503,7 +1503,7 @@ void D_SRB2Main(void)
|
||||||
|
|
||||||
CONS_Printf("HU_LoadGraphics()...\n");
|
CONS_Printf("HU_LoadGraphics()...\n");
|
||||||
HU_LoadGraphics();
|
HU_LoadGraphics();
|
||||||
con_startup_loadprogress++;
|
CON_SetLoadingProgress(LOADED_HULOADGRAPHICS);
|
||||||
|
|
||||||
//--------------------------------------------------------- CONFIG.CFG
|
//--------------------------------------------------------- CONFIG.CFG
|
||||||
M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()"
|
M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()"
|
||||||
|
|
@ -1534,7 +1534,7 @@ void D_SRB2Main(void)
|
||||||
// check the renderer's state
|
// check the renderer's state
|
||||||
D_CheckRendererState();
|
D_CheckRendererState();
|
||||||
}
|
}
|
||||||
con_startup_loadprogress++;
|
CON_SetLoadingProgress(LOADED_RENDERER);
|
||||||
|
|
||||||
wipegamestate = gamestate;
|
wipegamestate = gamestate;
|
||||||
|
|
||||||
|
|
@ -1564,11 +1564,11 @@ void D_SRB2Main(void)
|
||||||
|
|
||||||
CONS_Printf("M_Init(): Init miscellaneous info.\n");
|
CONS_Printf("M_Init(): Init miscellaneous info.\n");
|
||||||
M_Init();
|
M_Init();
|
||||||
con_startup_loadprogress++;
|
CON_SetLoadingProgress(LOADED_MINIT);
|
||||||
|
|
||||||
CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n");
|
CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n");
|
||||||
R_Init();
|
R_Init();
|
||||||
con_startup_loadprogress++;
|
CON_SetLoadingProgress(LOADED_RINIT);
|
||||||
|
|
||||||
// setting up sound
|
// setting up sound
|
||||||
if (dedicated)
|
if (dedicated)
|
||||||
|
|
@ -1604,13 +1604,13 @@ void D_SRB2Main(void)
|
||||||
I_InitMusic();
|
I_InitMusic();
|
||||||
S_InitSfxChannels(cv_soundvolume.value);
|
S_InitSfxChannels(cv_soundvolume.value);
|
||||||
}
|
}
|
||||||
con_startup_loadprogress++;
|
CON_SetLoadingProgress(LOADED_SINITSFXCHANNELS);
|
||||||
|
|
||||||
S_InitMusicDefs();
|
S_InitMusicDefs();
|
||||||
|
|
||||||
CONS_Printf("ST_Init(): Init status bar.\n");
|
CONS_Printf("ST_Init(): Init status bar.\n");
|
||||||
ST_Init();
|
ST_Init();
|
||||||
con_startup_loadprogress++;
|
CON_SetLoadingProgress(LOADED_STINIT);
|
||||||
|
|
||||||
// Set up splitscreen players before joining!
|
// Set up splitscreen players before joining!
|
||||||
if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm()))
|
if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm()))
|
||||||
|
|
@ -1628,7 +1628,7 @@ void D_SRB2Main(void)
|
||||||
CONS_Printf("D_CheckNetGame(): Checking network game status.\n");
|
CONS_Printf("D_CheckNetGame(): Checking network game status.\n");
|
||||||
if (D_CheckNetGame())
|
if (D_CheckNetGame())
|
||||||
autostart = true;
|
autostart = true;
|
||||||
con_startup_loadprogress++;
|
CON_SetLoadingProgress(LOADED_DCHECKNETGAME);
|
||||||
|
|
||||||
if (splitscreen && !M_CheckParm("-connect")) // Make sure multiplayer & autostart is set if you have splitscreen, even after D_CheckNetGame
|
if (splitscreen && !M_CheckParm("-connect")) // Make sure multiplayer & autostart is set if you have splitscreen, even after D_CheckNetGame
|
||||||
multiplayer = autostart = true;
|
multiplayer = autostart = true;
|
||||||
|
|
@ -1844,9 +1844,9 @@ void D_SRB2Main(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (con_startup_loadprogress < CON_STARTUP_LOADSTEPS)
|
if (con_startup_loadprogress != LOADED_ALLDONE)
|
||||||
{
|
{
|
||||||
I_Error("CON_STARTUP_LOADSTEPS is too high! (is %d, got %d)\n", CON_STARTUP_LOADSTEPS, con_startup_loadprogress);
|
I_Error("Something is wrong with the loading bar! (got %d, expected %d)\n", con_startup_loadprogress, LOADED_ALLDONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@
|
||||||
#include "p_setup.h"
|
#include "p_setup.h"
|
||||||
#include "st_stuff.h" // hud hiding
|
#include "st_stuff.h" // hud hiding
|
||||||
#include "fastcmp.h"
|
#include "fastcmp.h"
|
||||||
#include "console.h"
|
|
||||||
|
|
||||||
#include "lua_hud.h"
|
#include "lua_hud.h"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue