From 72defa325f50c59fc7256c72b10347de5b3b7500 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 29 Mar 2021 17:02:08 +0100 Subject: [PATCH] * Add a seperate step for I_STARTUPSKINS - "Load characters" - since it takes a similar length to loading all other types of sprites. * Adjust several loading strings, and left-align their rendering. * Don't call HU_LoadGraphics() again (startup cached ALL FONTS twice). * Adjust when some functions are called during loading to more effectively compartmentalise sections of loading that depend on each other. * LOADED_ISTARTUPGRAPHICS now comes after SCR_Startup, as we can explicitly guarantee the palette has been loaded after that function. * Make sure everything closely related to configurations (gamedata, console stuff, etc) which is not directly dependent on anything else is loaded under LOADED_CONFIG - "Load settings" (formerly LOADED_MINIT). * The `-warp` command line parameter is now checked alongside LOADED_DCHECKNETGAME. * Don't attempt to draw the loading bar before LOADED_ISTARTUPGRAPHICS, as the palette is not loaded, which means you're wasting cycles on a white screen. --- src/console.c | 18 ++++++++------ src/console.h | 5 ++-- src/d_main.c | 67 +++++++++++++++++++++++++++----------------------- src/m_menu.c | 4 +-- src/r_skins.c | 14 +++++++++-- src/r_things.c | 24 ------------------ src/v_video.c | 3 +++ 7 files changed, 67 insertions(+), 68 deletions(-) diff --git a/src/console.c b/src/console.c index be829b378..a4e711090 100644 --- a/src/console.c +++ b/src/console.c @@ -1880,21 +1880,23 @@ void CON_Drawer(void) Unlock_state(); } -static const char *CON_LoadingStrings[LOADED_ALLDONE] = +static const char *CON_LoadingStrings[LOADED_ALLDONE+1] = { - "Init Zone Memory...", //LOADED_ZINIT + "Init zone memory...", //LOADED_ZINIT "Init game timing...", //LOADED_ISTARTUPTIMER "Loading main assets...", //LOADED_IWAD "Loading add-ons...", //LOADED_PWAD "Init graphics subsystem...", //LOADED_ISTARTUPGRAPHICS - "Cache fonts...", //LOADED_HULOADGRAPHICS - "Init miscellaneous...", //LOADED_MINIT + "Cache fonts...", //LOADED_HUINIT + "Load settings...", //LOADED_CONFIG "Cache textures...", //LOADED_INITTEXTUREDATA "Cache sprites...", //LOADED_INITSPIRTES + "Load characters...", //LOADED_INITSKINS "Init rendering daemon...", //LOADED_RINIT "Init audio subsystem...", //LOADED_SINITSFXCHANNELS "Cache HUD...", //LOADED_STINIT "Check game status...", //LOADED_DCHECKNETGAME + "Now starting..." }; // see also con_loadprogress_t in console.h // @@ -1912,9 +1914,11 @@ void CON_SetLoadingProgress(con_loadprogress_t newStep) con_startup_loadprogress = newStep; - if (con_startup_loadprogress < LOADED_ALLDONE) + if (con_startup_loadprogress <= LOADED_ALLDONE) CONS_Printf("LOADING UPDATE - %s\n", CON_LoadingStrings[con_startup_loadprogress]); + if (con_startup_loadprogress < LOADED_ISTARTUPGRAPHICS) // rendering not possible? + return; CON_DrawLoadBar(); // here we display the console text I_FinishUpdate(); // page flip or blit buffer } @@ -1940,8 +1944,8 @@ void CON_DrawLoadBar(void) barwidth = (BASEVIDWIDTH * con_startup_loadprogress) / LOADED_ALLDONE; V_DrawFill(0, BASEVIDHEIGHT - barheight, barwidth, barheight, 0); #ifdef DEVELOP - if (con_startup_loadprogress < LOADED_ALLDONE) - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT - (barheight + 8 + 4), 0, CON_LoadingStrings[con_startup_loadprogress]); + if (con_startup_loadprogress <= LOADED_ALLDONE) + V_DrawString(4, BASEVIDHEIGHT - (barheight + 8 + 4), 0, CON_LoadingStrings[con_startup_loadprogress]); #endif Unlock_state(); diff --git a/src/console.h b/src/console.h index caeefbb19..c7a459330 100644 --- a/src/console.h +++ b/src/console.h @@ -36,10 +36,11 @@ typedef enum LOADED_IWAD, LOADED_PWAD, LOADED_ISTARTUPGRAPHICS, - LOADED_HULOADGRAPHICS, - LOADED_MINIT, + LOADED_HUINIT, + LOADED_CONFIG, LOADED_INITTEXTUREDATA, LOADED_INITSPRITES, + LOADED_INITSKINS, LOADED_RINIT, LOADED_SINITSFXCHANNELS, LOADED_STINIT, diff --git a/src/d_main.c b/src/d_main.c index 11305966e..0b0172f96 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1434,7 +1434,6 @@ void D_SRB2Main(void) CONS_Printf("I_StartupGraphics()...\n"); I_StartupGraphics(); - CON_SetLoadingProgress(LOADED_ISTARTUPGRAPHICS); #ifdef HWRENDER // Lactozilla: Add every hardware mode CVAR and CCMD. @@ -1447,10 +1446,15 @@ void D_SRB2Main(void) // setup loading screen SCR_Startup(); + CON_SetLoadingProgress(LOADED_ISTARTUPGRAPHICS); + + CONS_Printf("HU_Init()...\n"); HU_Init(); CON_Init(); + CON_SetLoadingProgress(LOADED_HUINIT); + memset(timelimits, 0, sizeof(timelimits)); memset(pointlimits, 0, sizeof(pointlimits)); @@ -1463,14 +1467,10 @@ void D_SRB2Main(void) I_RegisterSysCommands(); - CONS_Printf("HU_LoadGraphics()...\n"); - HU_LoadGraphics(); - CON_SetLoadingProgress(LOADED_HULOADGRAPHICS); - //--------------------------------------------------------- CONFIG.CFG M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()" - G_LoadGameData(); + M_Init(); #if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen @@ -1479,36 +1479,18 @@ void D_SRB2Main(void) // set user default mode or mode set at cmdline SCR_CheckDefaultMode(); + if (M_CheckParm("-noupload")) + COM_BufAddText("downloading 0\n"); + + G_LoadGameData(); + wipegamestate = gamestate; savedata.lives = 0; // flag this as not-used - //------------------------------------------------ COMMAND LINE PARAMS - - // this must be done after loading gamedata, - // to avoid setting off the corrupted gamedata code in G_LoadGameData if a SOC with custom gamedata is added - // -- Monster Iestyn 20/02/20 - if (M_CheckParm("-warp") && M_IsNextParm()) - { - const char *word = M_GetNextParm(); - pstartmap = G_FindMapByNameOrCode(word, 0); - if (! pstartmap) - I_Error("Cannot find a map remotely named '%s'\n", word); - else - { - if (!M_CheckParm("-server")) - G_SetGameModified(multiplayer, true); - autostart = true; - } - } - - if (M_CheckParm("-noupload")) - COM_BufAddText("downloading 0\n"); - - CONS_Printf("M_Init(): Init miscellaneous info.\n"); - M_Init(); - CON_SetLoadingProgress(LOADED_MINIT); + CON_SetLoadingProgress(LOADED_CONFIG); + CONS_Printf("R_InitTextureData()...\n"); R_InitTextureData(); // seperated out from below because it takes ages by itself CON_SetLoadingProgress(LOADED_INITTEXTUREDATA); @@ -1516,6 +1498,10 @@ void D_SRB2Main(void) R_InitSprites(); // ditto CON_SetLoadingProgress(LOADED_INITSPRITES); + CONS_Printf("R_InitSkins()...\n"); + R_InitSkins(); // ditto + CON_SetLoadingProgress(LOADED_INITSKINS); + CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n"); R_Init(); CON_SetLoadingProgress(LOADED_RINIT); @@ -1562,6 +1548,25 @@ void D_SRB2Main(void) ST_Init(); CON_SetLoadingProgress(LOADED_STINIT); + //------------------------------------------------ COMMAND LINE PARAMS + + // this must be done after loading gamedata, + // to avoid setting off the corrupted gamedata code in G_LoadGameData if a SOC with custom gamedata is added + // -- Monster Iestyn 20/02/20 + if (M_CheckParm("-warp") && M_IsNextParm()) + { + const char *word = M_GetNextParm(); + pstartmap = G_FindMapByNameOrCode(word, 0); + if (! pstartmap) + I_Error("Cannot find a map remotely named '%s'\n", word); + else + { + if (!M_CheckParm("-server")) + G_SetGameModified(multiplayer, true); + autostart = true; + } + } + // Set up splitscreen players before joining! if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm())) { diff --git a/src/m_menu.c b/src/m_menu.c index 28570c699..ef16721b9 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3466,8 +3466,6 @@ void M_Init(void) { UINT8 i; - COM_AddCommand("manual", Command_Manual_f); - CV_RegisterVar(&cv_nextmap); CV_RegisterVar(&cv_newgametype); CV_RegisterVar(&cv_chooseskin); @@ -3476,6 +3474,8 @@ void M_Init(void) if (dedicated) return; + COM_AddCommand("manual", Command_Manual_f); + // Menu hacks CV_RegisterVar(&cv_dummymenuplayer); CV_RegisterVar(&cv_dummyteam); diff --git a/src/r_skins.c b/src/r_skins.c index 57995b0f5..1e80e18ce 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -133,9 +133,11 @@ static void Sk_SetDefaultValue(skin_t *skin) // void R_InitSkins(void) { -#ifdef SKINVALUES - INT32 i; + size_t i; + // it can be is do before loading config for skin cvar possible value + // (... what the fuck did you just say to me? "it can be is do"?) +#ifdef SKINVALUES for (i = 0; i <= MAXSKINS; i++) { skin_cons_t[i].value = 0; @@ -145,6 +147,14 @@ void R_InitSkins(void) // no default skin! numskins = 0; + + for (i = 0; i < numwadfiles; i++) + { + R_AddSkins((UINT16)i); + R_PatchSkins((UINT16)i); + R_LoadSpriteInfoLumps(i, wadfiles[i]->numlumps); + } + ST_ReloadSkinFaceGraphics(); } UINT32 R_GetSkinAvailabilities(void) diff --git a/src/r_things.c b/src/r_things.c index dc61ac539..aaa272e02 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -546,30 +546,6 @@ void R_InitSprites(void) for (i = 0; i < numwadfiles; i++) R_AddSpriteDefs((UINT16)i); - // - // now check for skins - // - - // it can be is do before loading config for skin cvar possible value - // (... what the fuck did you just say to me? "it can be is do"?) -#ifdef SKINVALUES - for (i = 0; i <= MAXSKINS; i++) - { - skin_cons_t[i].value = 0; - skin_cons_t[i].strvalue = NULL; - } -#endif - - numskins = 0; - - for (i = 0; i < numwadfiles; i++) - { - R_AddSkins((UINT16)i); - R_PatchSkins((UINT16)i); - R_LoadSpriteInfoLumps(i, wadfiles[i]->numlumps); - } - ST_ReloadSkinFaceGraphics(); - // // check if all sprites have frames // diff --git a/src/v_video.c b/src/v_video.c index 0b22378a4..40e1a13f6 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -131,6 +131,9 @@ static boolean InitCube(void) float globalgammamul, globalgammaoffs; boolean doinggamma; + if (con_startup_loadprogress < LOADED_MINIT) + return false; + #define diffcons(cv) (cv.value != atoi(cv.defaultvalue)) doinggamma = diffcons(cv_globalgamma);