From a23197cf8d332cfe802a1f22e4dbdafbcf300526 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Sat, 15 Mar 2025 03:54:17 +0100 Subject: [PATCH] god i hate cvars --- src/command.c | 14 +++++++++++++- src/console.c | 38 +++++++++++++++++++------------------- src/console.h | 1 + src/d_main.cpp | 34 ++++++++++++++++++++-------------- src/hardware/hw_main.c | 3 ++- src/screen.c | 3 --- src/sdl/i_system.cpp | 2 +- src/sdl/i_video.cpp | 21 ++++++++++++++------- src/v_video.c | 40 ++++++++++++++++++++-------------------- 9 files changed, 90 insertions(+), 66 deletions(-) diff --git a/src/command.c b/src/command.c index 133bcfd69..a6f14c9a8 100644 --- a/src/command.c +++ b/src/command.c @@ -1624,7 +1624,19 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth) const char *overridestr = valstr; - if (CV_CompleteValue(var, &overridestr, &overrideval)) + if (mainwads == 0 && var->PossibleValue == Color_cons_t) + { + override = true; + if (!strcmp(valstr, "Blue")) + overrideval = SKINCOLOR_BLUE; + else if (!strcmp(valstr, "Orange")) + overrideval = SKINCOLOR_ORANGE; + else if (!strcmp(valstr, "Red")) + overrideval = SKINCOLOR_RED; + else + I_Error("Sorry, you need to add %s to the list of skincolors in Setvalue", valstr); + } + else if (CV_CompleteValue(var, &overridestr, &overrideval)) { if (overridestr) { diff --git a/src/console.c b/src/console.c index aa95975f0..613eb4353 100644 --- a/src/console.c +++ b/src/console.c @@ -153,7 +153,7 @@ static CV_PossibleValue_t backcolor_cons_t[] = {{0, "White"}, {1, "Black"}, { {15,"Periwinkle"}, {16,"Blue"}, {17,"Purple"}, {18,"Lavender"}, {0, NULL}}; -consvar_t cons_backcolor = CVAR_INIT ("con_backcolor", "Black", CV_CALL|CV_SAVE, backcolor_cons_t, CONS_backcolor_Change); +consvar_t cons_backcolor = CVAR_INIT ("con_backcolor", "Black", CV_CALL|CV_NOINIT|CV_SAVE, backcolor_cons_t, CONS_backcolor_Change); static CV_PossibleValue_t menuhighlight_cons_t[] = { @@ -461,38 +461,38 @@ void CON_Init(void) con_destlines = vid.height; con_curlines = vid.height; - Unlock_state(); - if (!dedicated) { - Lock_state(); con_started = true; con_startup = true; consoletoggle = false; - - Unlock_state(); - - CV_RegisterVar(&cons_msgtimeout); - CV_RegisterVar(&cons_hudlines); - CV_RegisterVar(&cons_speed); - CV_RegisterVar(&cons_height); - CV_RegisterVar(&cons_backpic); - CV_RegisterVar(&cons_backcolor); - CV_RegisterVar(&cons_menuhighlight); - COM_AddCommand("bind", CONS_Bind_f); } else { - Lock_state(); - con_started = true; con_startup = false; consoletoggle = true; - - Unlock_state(); } + + Unlock_state(); } + +void CON_Register(void) +{ + if (dedicated) + return; + + CV_RegisterVar(&cons_msgtimeout); + CV_RegisterVar(&cons_hudlines); + CV_RegisterVar(&cons_speed); + CV_RegisterVar(&cons_height); + CV_RegisterVar(&cons_backpic); + CV_RegisterVar(&cons_backcolor); + CV_RegisterVar(&cons_menuhighlight); + COM_AddCommand("bind", CONS_Bind_f); +} + // Console input initialization // static void CON_InputInit(void) diff --git a/src/console.h b/src/console.h index 496c3418d..c32430576 100644 --- a/src/console.h +++ b/src/console.h @@ -22,6 +22,7 @@ extern "C" { #endif void CON_Init(void); +void CON_Register(void); boolean CON_Responder(event_t *ev); diff --git a/src/d_main.cpp b/src/d_main.cpp index 686d18bd1..ef7152a6c 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1472,6 +1472,26 @@ void D_SRB2Main(void) // Have to be done here before files are loaded M_InitCharacterTables(); + D_RegisterServerCommands(); + D_RegisterClientCommands(); // be sure that this is called before D_CheckNetGame + R_RegisterEngineStuff(); + S_RegisterSoundStuff(); + CON_Register(); + if (!dedicated) + { + CV_RegisterVar(&cv_ticrate); + CV_RegisterVar(&cv_constextsize); + } + + I_RegisterSysCommands(); + +#ifdef HWRENDER + // Lactozilla: Add every hardware mode CVAR and CCMD. + // Has to be done before the configuration file loads, + // ~~but after the OpenGL library loads.~~ G: no lol + HWR_AddCommands(); +#endif + // load wad, including the main wad file CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n"); W_InitMultipleFiles(startupiwads, false); @@ -1535,13 +1555,6 @@ void D_SRB2Main(void) CONS_Printf("I_StartupGraphics()...\n"); I_StartupGraphics(); -#ifdef HWRENDER - // Lactozilla: Add every hardware mode CVAR and CCMD. - // Has to be done before the configuration file loads, - // but after the OpenGL library loads. - HWR_AddCommands(); -#endif - //--------------------------------------------------------- CONSOLE // setup loading screen SCR_Startup(); @@ -1561,13 +1574,6 @@ void D_SRB2Main(void) timelimits[GT_BATTLE] = 2; - D_RegisterServerCommands(); - D_RegisterClientCommands(); // be sure that this is called before D_CheckNetGame - R_RegisterEngineStuff(); - S_RegisterSoundStuff(); - - I_RegisterSysCommands(); - CON_SetLoadingProgress(LOADED_HUINIT); CONS_Printf("W_InitMultipleFiles(): Adding external PWADs.\n"); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c4e39fddd..3e14d75c2 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6367,13 +6367,14 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_glsolvetjoin); CV_RegisterVar(&cv_glbatching); + + CV_RegisterVar(&cv_glanisotropicmode); } void HWR_AddSessionCommands(void) { if (gl_sessioncommandsadded) return; - CV_RegisterVar(&cv_glanisotropicmode); gl_sessioncommandsadded = true; } diff --git a/src/screen.c b/src/screen.c index ddc9f5af0..01ff1559e 100644 --- a/src/screen.c +++ b/src/screen.c @@ -349,9 +349,6 @@ void SCR_Startup(void) V_Init(); V_Recalc(); - CV_RegisterVar(&cv_ticrate); - CV_RegisterVar(&cv_constextsize); - V_SetPalette(0); } diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index fce0ee9d9..6a91f94c8 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -2688,6 +2688,6 @@ UINT32 I_GetFreeMem(UINT32 *total) } // note CPUAFFINITY code used to reside here -void I_RegisterSysCommands(void) {} +//void I_RegisterSysCommands(void) {} #endif // HAVE_SDL diff --git a/src/sdl/i_video.cpp b/src/sdl/i_video.cpp index 12b858db9..0db299e36 100644 --- a/src/sdl/i_video.cpp +++ b/src/sdl/i_video.cpp @@ -1779,6 +1779,20 @@ static void Impl_VideoSetupBuffer(void) } } +void I_RegisterSysCommands(void) +{ + if (dedicated || graphics_started) + return; + + COM_AddCommand ("vid_nummodes", VID_Command_NumModes_f); + COM_AddCommand ("vid_info", VID_Command_Info_f); + COM_AddCommand ("vid_modelist", VID_Command_ModeList_f); + COM_AddCommand ("vid_mode", VID_Command_Mode_f); + CV_RegisterVar (&cv_vidwait); + CV_RegisterVar (&cv_stretch); + CV_RegisterVar (&cv_alwaysgrabmouse); +} + void I_StartupGraphics(void) { if (dedicated) @@ -1789,13 +1803,6 @@ void I_StartupGraphics(void) if (graphics_started) return; - COM_AddCommand ("vid_nummodes", VID_Command_NumModes_f); - COM_AddCommand ("vid_info", VID_Command_Info_f); - COM_AddCommand ("vid_modelist", VID_Command_ModeList_f); - COM_AddCommand ("vid_mode", VID_Command_Mode_f); - CV_RegisterVar (&cv_vidwait); - CV_RegisterVar (&cv_stretch); - CV_RegisterVar (&cv_alwaysgrabmouse); disable_mouse = static_cast(M_CheckParm("-nomouse")); disable_fullscreen = M_CheckParm("-win") ? SDL_TRUE : SDL_FALSE; diff --git a/src/v_video.c b/src/v_video.c index c0e079a40..e2c7785f6 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -54,34 +54,34 @@ consvar_t cv_ticrate = CVAR_INIT ("showfps", "No", CV_SAVE, CV_YesNo, NULL); static void CV_palette_OnChange(void); static CV_PossibleValue_t gamma_cons_t[] = {{-15, "MIN"}, {5, "MAX"}, {0, NULL}}; -consvar_t cv_globalgamma = CVAR_INIT ("gamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_globalgamma = CVAR_INIT ("gamma", "0", CV_SAVE|CV_CALL|CV_NOINIT, gamma_cons_t, CV_palette_OnChange); static CV_PossibleValue_t saturation_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; -consvar_t cv_globalsaturation = CVAR_INIT ("saturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_globalsaturation = CVAR_INIT ("saturation", "10", CV_SAVE|CV_CALL|CV_NOINIT, saturation_cons_t, CV_palette_OnChange); #define huecoloursteps 4 static CV_PossibleValue_t hue_cons_t[] = {{0, "MIN"}, {(huecoloursteps*6)-1, "MAX"}, {0, NULL}}; -consvar_t cv_rhue = CVAR_INIT ("rhue", "0", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); -consvar_t cv_yhue = CVAR_INIT ("yhue", "4", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); -consvar_t cv_ghue = CVAR_INIT ("ghue", "8", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); -consvar_t cv_chue = CVAR_INIT ("chue", "12", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); -consvar_t cv_bhue = CVAR_INIT ("bhue", "16", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); -consvar_t cv_mhue = CVAR_INIT ("mhue", "20", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); +consvar_t cv_rhue = CVAR_INIT ("rhue", "0", CV_SAVE|CV_CALL|CV_NOINIT, hue_cons_t, CV_palette_OnChange); +consvar_t cv_yhue = CVAR_INIT ("yhue", "4", CV_SAVE|CV_CALL|CV_NOINIT, hue_cons_t, CV_palette_OnChange); +consvar_t cv_ghue = CVAR_INIT ("ghue", "8", CV_SAVE|CV_CALL|CV_NOINIT, hue_cons_t, CV_palette_OnChange); +consvar_t cv_chue = CVAR_INIT ("chue", "12", CV_SAVE|CV_CALL|CV_NOINIT, hue_cons_t, CV_palette_OnChange); +consvar_t cv_bhue = CVAR_INIT ("bhue", "16", CV_SAVE|CV_CALL|CV_NOINIT, hue_cons_t, CV_palette_OnChange); +consvar_t cv_mhue = CVAR_INIT ("mhue", "20", CV_SAVE|CV_CALL|CV_NOINIT, hue_cons_t, CV_palette_OnChange); -consvar_t cv_rgamma = CVAR_INIT ("rgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); -consvar_t cv_ygamma = CVAR_INIT ("ygamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); -consvar_t cv_ggamma = CVAR_INIT ("ggamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); -consvar_t cv_cgamma = CVAR_INIT ("cgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); -consvar_t cv_bgamma = CVAR_INIT ("bgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); -consvar_t cv_mgamma = CVAR_INIT ("mgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_rgamma = CVAR_INIT ("rgamma", "0", CV_SAVE|CV_CALL|CV_NOINIT, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_ygamma = CVAR_INIT ("ygamma", "0", CV_SAVE|CV_CALL|CV_NOINIT, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_ggamma = CVAR_INIT ("ggamma", "0", CV_SAVE|CV_CALL|CV_NOINIT, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_cgamma = CVAR_INIT ("cgamma", "0", CV_SAVE|CV_CALL|CV_NOINIT, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_bgamma = CVAR_INIT ("bgamma", "0", CV_SAVE|CV_CALL|CV_NOINIT, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_mgamma = CVAR_INIT ("mgamma", "0", CV_SAVE|CV_CALL|CV_NOINIT, gamma_cons_t, CV_palette_OnChange); -consvar_t cv_rsaturation = CVAR_INIT ("rsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); -consvar_t cv_ysaturation = CVAR_INIT ("ysaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); -consvar_t cv_gsaturation = CVAR_INIT ("gsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); -consvar_t cv_csaturation = CVAR_INIT ("csaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); -consvar_t cv_bsaturation = CVAR_INIT ("bsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); -consvar_t cv_msaturation = CVAR_INIT ("msaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_rsaturation = CVAR_INIT ("rsaturation", "10", CV_SAVE|CV_CALL|CV_NOINIT, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_ysaturation = CVAR_INIT ("ysaturation", "10", CV_SAVE|CV_CALL|CV_NOINIT, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_gsaturation = CVAR_INIT ("gsaturation", "10", CV_SAVE|CV_CALL|CV_NOINIT, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_csaturation = CVAR_INIT ("csaturation", "10", CV_SAVE|CV_CALL|CV_NOINIT, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_bsaturation = CVAR_INIT ("bsaturation", "10", CV_SAVE|CV_CALL|CV_NOINIT, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_msaturation = CVAR_INIT ("msaturation", "10", CV_SAVE|CV_CALL|CV_NOINIT, saturation_cons_t, CV_palette_OnChange); static CV_PossibleValue_t constextsize_cons_t[] = { {V_NOSCALEPATCH, "Small"}, {V_SMALLSCALEPATCH, "Medium"}, {V_MEDSCALEPATCH, "Large"}, {0, "Huge"},