From ae306351ba469682f345339e74922bbc2dd1bec8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 16:25:43 +0100 Subject: [PATCH 01/12] add cv_precachetextures to advanced video options --- src/m_menudefs.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 6bda9c733..6633085bf 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -944,21 +944,23 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 40}, - {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 50}, + {IT_STRING | IT_CVAR, NULL, "Precache Level Textures", &cv_precachetextures, 50}, - {IT_STRING | IT_CVAR, NULL, "Frameskip", &cv_frameskip, 60}, + {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 60}, - {IT_STRING | IT_CVAR, NULL, "Votescreen Scaling", &cv_votebgscaling, 70}, + {IT_STRING | IT_CVAR, NULL, "Frameskip", &cv_frameskip, 70}, + + {IT_STRING | IT_CVAR, NULL, "Votescreen Scaling", &cv_votebgscaling, 80}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 80}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 90}, #ifdef USE_FBO_OGL - {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 85}, - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 95}, - {IT_DISABLED, NULL, "", NULL, 105}, // dummy text + {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 95}, + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 105}, + {IT_DISABLED, NULL, "", NULL, 115}, // dummy text #else - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 90}, - {IT_DISABLED, NULL, "", NULL, 100}, // dummy text + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 100}, + {IT_DISABLED, NULL, "", NULL, 110}, // dummy text #endif #endif }; @@ -971,6 +973,7 @@ static const char* OP_ExpTooltips[] = "Sets minimum sector brightness, useful for dark areas.", //"Should the directional lightning be randomized each map?\nTakes effect on next map load.", "Toggle being able to see the sky.", + "Preload all level textures on level load.\nMassively reduces texture related stuttering during gameplay\nat the cost of longer level loading times.\nDisable this if you experience timeouts during level switches.", "Change the FPS counter sampling method\nInaccurate updates slower\nand might miss sudden framerate changes and drops,\nproviding a more averaged result.\nAccurate updates faster, but might be less readable.", // how to ingles?? "Skips rendering frames if game logic takes too long\npreventing gameplay issues during performance drops.", // idk im shit as describing things "Different methods of scaling the votescreen backgrounds.", @@ -991,6 +994,7 @@ enum op_exp_secbright, //op_exp_dirlight, op_exp_skybox, + op_exp_texcache, op_exp_accuratefps, op_exp_frameskip, op_exp_votescrn, From feff5a7c17487681b0a1680ebdb4d105303e70b3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 16:32:04 +0100 Subject: [PATCH 02/12] make a toggle for using angleturn in replays while this is more accurate to how the player experienced stuff in the actual game, this also can be somewhat jittery and stuttery depending on the net conditions the replay was recorded in, so make this toggable if someone wants it --- src/d_netcmd.c | 5 +++++ src/d_netcmd.h | 2 ++ src/p_user.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 92d9fb935..86c9b12b1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -292,6 +292,10 @@ consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, // Lagless camera! Yay! consvar_t cv_laglesscam = {"lagless_camera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +// makes the camera use the saved angleturn in replays instead of the players angle +// more accurate to how the recording player seen things in game, but may be jittery if they encountered net issues +consvar_t cv_demoangturn = {"useangleturninreplays", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_verticallook[MAXSPLITSCREENPLAYERS] = { {"verticallook", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"verticallook2", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, @@ -1043,6 +1047,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_betainterscreen); CV_RegisterVar(&cv_laglesscam); + CV_RegisterVar(&cv_demoangturn); for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 52f777e2b..6b7382403 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -209,6 +209,8 @@ extern consvar_t cv_betainterscreen; extern consvar_t cv_laglesscam; +extern consvar_t cv_demoangturn; + typedef enum { SKINMENUTYPE_SCROLL = 0, diff --git a/src/p_user.c b/src/p_user.c index b99998844..5ccc43f0a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3824,7 +3824,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // Hack-adjacent. // Sometimes stale ticcmds send a weird angle at the start of the race. // P_UpdatePlayerAngle knows to ignore cmd angle when you literally can't turn, so we do the same here. - if (leveltime > starttime) + if (cv_demoangturn.value && leveltime > starttime) focusangle = player->cmd.angleturn << 16; else focusangle = mo->angle; // Just use something known sane. From c428472c6f919f1981c52b81b1ad262b72676e56 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 16:12:05 +0100 Subject: [PATCH 03/12] dont precache anything ever in HWR_PrecacheLevel if disabled before some cvar callbacks called this unconditionally --- src/hardware/hw_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index e58169e14..1a09ee33f 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -812,7 +812,7 @@ static void HWR_PrecacheLevelSprites(void) void HWR_PrecacheLevel(void) { - if (gamestate != GS_LEVEL) + if (gamestate != GS_LEVEL || !cv_precachetextures.value) return; // Precache flats. From 456a380e3a975311ecfbc898635a17232e12e8f3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 15:39:21 +0100 Subject: [PATCH 04/12] HWR_PrecacheLevel: disable sprite precaching in some cases this may lead to crashes, its mostly useless in gl eitherway due to how colourmapped sprites work --- src/hardware/hw_cache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 1a09ee33f..4d9fdb54c 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -745,7 +745,7 @@ static void HWR_PrecacheLevelTextures(void) free(texturepresent); } -static void HWR_PrecacheLevelSprites(void) +/*static void HWR_PrecacheLevelSprites(void) { patch_t *spritepatch; char *spritepresent; @@ -808,7 +808,7 @@ static void HWR_PrecacheLevelSprites(void) } } free(spritepresent); -} +}*/ void HWR_PrecacheLevel(void) { @@ -822,7 +822,7 @@ void HWR_PrecacheLevel(void) HWR_PrecacheLevelTextures(); // Precache sprites. - HWR_PrecacheLevelSprites(); + //HWR_PrecacheLevelSprites(); } void HWR_LoadMapTextures(size_t pnumtextures) From eaee95a026244cc793cd8c6eb60adee9b0cb8cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Tue, 29 Jul 2025 13:10:44 +0200 Subject: [PATCH 05/12] Add -workdir --- src/d_main.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ca2ffa4f7..50b3330e9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1721,8 +1721,14 @@ void D_SRB2Main(void) else { // use user specific config file + if (M_CheckParm("-workdir") && M_IsNextParm()) + snprintf(srb2home, sizeof srb2home, "%s", M_GetNextParm()); + else #ifdef DEFAULTDIR - snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome); + snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome); +#else // DEFAULTDIR + snprintf(srb2home, sizeof srb2home, "%s", userhome); +#endif // DEFAULTDIR snprintf(downloaddir, sizeof downloaddir, "%s" PATHSEP "DOWNLOAD", srb2home); if (dedicated) snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home); @@ -1731,17 +1737,6 @@ void D_SRB2Main(void) // can't use sprintf since there is %u in savegamename strcatbf(savegamename, srb2home, PATHSEP); -#else - snprintf(srb2home, sizeof srb2home, "%s", userhome); - snprintf(downloaddir, sizeof downloaddir, "%s", userhome); - if (dedicated) - snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, userhome); - else - snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, userhome); - - // can't use sprintf since there is %u in savegamename - strcatbf(savegamename, userhome, PATHSEP); -#endif } configfile[sizeof configfile - 1] = '\0'; @@ -1767,6 +1762,9 @@ void D_SRB2Main(void) } } + // make sure workdir exists + I_mkdir(srb2home, 0755); + // Create addons dir snprintf(addonsdir, sizeof addonsdir, "%s%s%s", srb2home, PATHSEP, "addons"); I_mkdir(addonsdir, 0755); From 908e07362872c132ebb4c8360d318194ef37918c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 18:28:47 +0100 Subject: [PATCH 06/12] removed unused autoload variables M_ConnectMenuModChecks been checking an uninitialized bool the whole time Zzz... --- src/d_main.c | 10 ++++------ src/d_main.h | 2 -- src/m_menu.c | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 50b3330e9..1f425a468 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -102,10 +102,8 @@ static char *startuppwads[MAX_WADFILES]; // autoloading static char *autoloadwadfiles[MAX_WADFILES]; static char *autoloadwadfilespost[MAX_WADFILES]; -boolean autoloading; -boolean autoloaded; +static boolean autoloaded = false; boolean postautoloaded = false; -boolean wasautoloaded = false; // boolean devparm = false; // started game with -devparm @@ -1158,7 +1156,7 @@ static void D_FindAddonsToAutoload(void) // If the file is found, run our shit if (!autoloadconfigfile) // nope outta here { - wasautoloaded = postautoloaded = true; // so D_AddAutoloadFiles can skip everything since nothings there to autoload + autoloaded = postautoloaded = true; // so D_AddAutoloadFiles can skip everything since nothings there to autoload return; } @@ -1206,7 +1204,7 @@ static void D_FindAddonsToAutoload(void) static void D_AddAutoloadFiles(void) { - if (wasautoloaded) + if (autoloaded) return; CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); @@ -1214,7 +1212,7 @@ static void D_AddAutoloadFiles(void) CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); D_CleanFile(autoloadwadfiles); - wasautoloaded = true; + autoloaded = true; } void D_AddPostloadFiles(void) diff --git a/src/d_main.h b/src/d_main.h index 86c79a63c..deeca4c07 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -61,8 +61,6 @@ extern boolean minilighticon; // mkwii-style minimap headlight // // autoload stuff -extern boolean autoloading; -extern boolean autoloaded; extern boolean postautoloaded; void D_AddPostloadFiles(void); diff --git a/src/m_menu.c b/src/m_menu.c index 6eaccdce0..49398df34 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6956,9 +6956,9 @@ static void M_ConnectMenuModChecks(INT32 choice) (void)choice; // okay never mind we want to COMMUNICATE to the player pre-emptively instead of letting them try and then get confused when it doesn't work - if (modifiedgame || autoloaded) + if (modifiedgame) { - M_StartMessage(M_GetText("You have addons loaded.\nYou won't be able to join netgames!\n\nTo play online, restart the game\nand don't load any addons.\nSRB2Kart will automatically add\neverything you need when you join.\n\n(Press a key)\n"),M_ConnectMenu,MM_EVENTHANDLER); + M_StartMessage("You have addons loaded.\nYou won't be able to join netgames!\n\nTo play online, restart the game\nand don't load any addons.\nSRB2Kart will automatically add\neverything you need when you join.\n\n(Press a key)\n", M_ConnectMenu, MM_EVENTHANDLER); return; } From de73c536658a8f3b479ba5123967f0f42418128d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 19:20:04 +0100 Subject: [PATCH 07/12] optimize addon autoload handling --- src/d_main.c | 73 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 1f425a468..1fde58a7b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -102,6 +102,8 @@ static char *startuppwads[MAX_WADFILES]; // autoloading static char *autoloadwadfiles[MAX_WADFILES]; static char *autoloadwadfilespost[MAX_WADFILES]; +static size_t autoloadcount = 0; +static size_t postloadcount = 0; static boolean autoloaded = false; boolean postautoloaded = false; // @@ -1057,6 +1059,7 @@ static void D_AddFile(const char *file, char **filearray) static void D_CleanFile(char **filearray) { size_t pnumwadfiles; + for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++) { free(filearray[pnumwadfiles]); @@ -1064,6 +1067,17 @@ static void D_CleanFile(char **filearray) } } +static void D_CleanAutoloadFile(char **filearray, size_t count) +{ + size_t i; + + for (i = 0; i < count; i++) + { + free(filearray[i]); + filearray[i] = NULL; + } +} + // Taken from TSoURDt3rd // https://github.com/StarManiaKG/The-Story-of-Uncapped-Revengence-Discord-the-3rd/blob/main/src/STAR/star_functions.c static INT32 D_DetectFileType(const char* filename) @@ -1092,9 +1106,8 @@ static INT32 D_DetectFileType(const char* filename) } // autoload that shit -static void D_AutoloadFile(const char *file, char **filearray) +static void D_AutoloadFile(const char *file, char **filearray, size_t count) { - size_t pnumwadfiles; char *newfile; INT32 fileType = D_DetectFileType(file); @@ -1104,9 +1117,6 @@ static void D_AutoloadFile(const char *file, char **filearray) return; } - for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++) - ; - if (fileType <= 6) { newfile = malloc(strlen(file) + 1); @@ -1114,7 +1124,7 @@ static void D_AutoloadFile(const char *file, char **filearray) I_Error("No more free memory to AutoloadFile %s",file); strcpy(newfile, file); - filearray[pnumwadfiles] = newfile; + filearray[count] = newfile; } else { @@ -1144,13 +1154,14 @@ static void D_FindAddonsToAutoload(void) { FILE *autoloadconfigfile; const char *autoloadpath; + char *newline; + boolean postload; - INT32 i; char wadsToAutoload[256] = ""; // does it exist tho - autoloadpath = va("%s"PATHSEP"%s",srb2home,AUTOLOADCONFIGFILENAME); + autoloadpath = va("%s"PATHSEP"%s", srb2home, AUTOLOADCONFIGFILENAME); autoloadconfigfile = fopen(autoloadpath, "r"); // If the file is found, run our shit @@ -1160,26 +1171,27 @@ static void D_FindAddonsToAutoload(void) return; } - while (fgets(wadsToAutoload, sizeof wadsToAutoload, autoloadconfigfile) != NULL) + while (fgets(wadsToAutoload, sizeof(wadsToAutoload), autoloadconfigfile) != NULL) { postload = false; + // skip if commented or empty - if ((wadsToAutoload[1] == '\0' || wadsToAutoload[1] == '\n') - || (wadsToAutoload[0] == '#')) + if (wadsToAutoload[0] == '\n' || + wadsToAutoload[0] == '#' || + wadsToAutoload[0] == '\0') continue; + // this marks it so that it loads after loading server addons - else if (fastncmp(wadsToAutoload, "postload ", 9)) + if (fastncmp(wadsToAutoload, "postload ", 9)) { strremove(wadsToAutoload, "postload "); postload = true; } // Remove Any Empty or Skipped Lines - for (i = 0; wadsToAutoload[i] != '\0'; i++) - { - if (wadsToAutoload[i] == '\n') - wadsToAutoload[i] = '\0'; - } + newline = strchr(wadsToAutoload, '\n'); + if (newline) + *newline = '\0'; if (!postload && W_CheckPostLoadList(wadsToAutoload)) { @@ -1189,15 +1201,20 @@ static void D_FindAddonsToAutoload(void) // LOAD IT if (!postload) - D_AutoloadFile(wadsToAutoload, autoloadwadfiles); + { + D_AutoloadFile(wadsToAutoload, autoloadwadfiles, autoloadcount); + autoloadcount++; + } else - D_AutoloadFile(wadsToAutoload, autoloadwadfilespost); - - // end it here - for (i = 0; wadsToAutoload[i] != '\0'; i++) - wadsToAutoload[i] = '\0'; + { + D_AutoloadFile(wadsToAutoload, autoloadwadfilespost, postloadcount); + postloadcount++; + } } + autoloadwadfiles[autoloadcount] = NULL; + autoloadwadfilespost[postloadcount] = NULL; + // we dont want memory leaks around here do we? fclose(autoloadconfigfile); } @@ -1208,10 +1225,13 @@ static void D_AddAutoloadFiles(void) return; CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); + if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfiles); + D_CleanAutoloadFile(autoloadwadfiles, autoloadcount); + + autoloadcount = 0; autoloaded = true; } @@ -1221,10 +1241,13 @@ void D_AddPostloadFiles(void) return; CONS_Printf("D_AddPostloadFiles(): Loading postloaded addons...\n"); + if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) CONS_Printf("D_AddPostloadFiles(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfilespost); + D_CleanAutoloadFile(autoloadwadfilespost, postloadcount); + + postloadcount = 0; postautoloaded = true; } From c0f24ebbbcdacde32f0753ba4a7bee6a247561c6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 19:36:28 +0100 Subject: [PATCH 08/12] postautoloaded can be static not used outside of d_main --- src/d_main.c | 2 +- src/d_main.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 1fde58a7b..f3b2486c8 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -105,7 +105,7 @@ static char *autoloadwadfilespost[MAX_WADFILES]; static size_t autoloadcount = 0; static size_t postloadcount = 0; static boolean autoloaded = false; -boolean postautoloaded = false; +static boolean postautoloaded = false; // boolean devparm = false; // started game with -devparm diff --git a/src/d_main.h b/src/d_main.h index deeca4c07..d9954a5b0 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -61,7 +61,6 @@ extern boolean minilighticon; // mkwii-style minimap headlight // // autoload stuff -extern boolean postautoloaded; void D_AddPostloadFiles(void); // the infinite loop of D_SRB2Loop() called from win_main for windows version From 42b1f849c030e35f5db44b905e4a808920f0ca3d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 20:00:43 +0100 Subject: [PATCH 09/12] cleanup and optimize startup wad handling --- src/d_main.c | 102 ++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 55 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f3b2486c8..b7704318b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -97,7 +97,9 @@ UINT8 window_notinfocus = false; static char *startupiwadfiles[MAX_WADFILES]; +static size_t startupiwadcount = 0; static char *startuppwads[MAX_WADFILES]; +static size_t startuppwadcount = 0; // autoloading static char *autoloadwadfiles[MAX_WADFILES]; @@ -1038,14 +1040,10 @@ void D_StartTitle(void) // // D_AddFile // -static void D_AddFile(const char *file, char **filearray) +static void D_AddFile(const char *file, char **filearray, size_t count) { - size_t pnumwadfiles; char *newfile; - for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++) - ; - newfile = malloc(strlen(file) + 1); if (!newfile) { @@ -1053,21 +1051,10 @@ static void D_AddFile(const char *file, char **filearray) } strcpy(newfile, file); - filearray[pnumwadfiles] = newfile; + filearray[count] = newfile; } -static void D_CleanFile(char **filearray) -{ - size_t pnumwadfiles; - - for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++) - { - free(filearray[pnumwadfiles]); - filearray[pnumwadfiles] = NULL; - } -} - -static void D_CleanAutoloadFile(char **filearray, size_t count) +static void D_CleanFile(char **filearray, size_t count) { size_t i; @@ -1229,7 +1216,7 @@ static void D_AddAutoloadFiles(void) if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); - D_CleanAutoloadFile(autoloadwadfiles, autoloadcount); + D_CleanFile(autoloadwadfiles, autoloadcount); autoloadcount = 0; autoloaded = true; @@ -1245,7 +1232,7 @@ void D_AddPostloadFiles(void) if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) CONS_Printf("D_AddPostloadFiles(): Are you sure you put in valid files or what?\n"); - D_CleanAutoloadFile(autoloadwadfilespost, postloadcount); + D_CleanFile(autoloadwadfilespost, postloadcount); postloadcount = 0; postautoloaded = true; @@ -1255,13 +1242,13 @@ void D_AddPostloadFiles(void) // Identify the SRB2 version, and IWAD file to use. // ========================================================================== -static boolean AddIWAD(void) +static boolean AddIWAD(const char * file, const char *dir) { - char * path = va(pandf, srb2path, "srb2.srb"); + char * path = va(pandf, dir, file); if (FIL_ReadFileOK(path)) { - D_AddFile(path, startupiwadfiles); + D_AddFile(path, startupiwadfiles, startupiwadcount++); return true; } @@ -1304,7 +1291,7 @@ static void IdentifyVersion(void) } // Load the IWAD - if (!AddIWAD()) + if (!AddIWAD("srb2.srb", srb2path)) // not sure why this uses srb2path and not srb2waddir? { I_Error("SRB2.SRB not found! Expected in %s\n", srb2waddir); } @@ -1318,48 +1305,51 @@ static void IdentifyVersion(void) #ifdef USE_PATCH_DTA // Add our crappy patches to fix our bugs - D_AddFile(va(pandf,srb2waddir,"patch.dta")); + if (!AddIWAD("patch.dta", srb2waddir)) + { + I_Error("patch.dta not found! Expected in %s\n", srb2waddir); + } #endif + if (!AddIWAD("gfx.kart", srb2waddir)) + { + I_Error("gfx.kart not found! Expected in %s\n", srb2waddir); + } - D_AddFile(va(pandf, srb2waddir, "gfx.kart"), startupiwadfiles); - D_AddFile(va(pandf, srb2waddir, "textures.kart"), startupiwadfiles); - D_AddFile(va(pandf, srb2waddir, "chars.kart"), startupiwadfiles); - D_AddFile(va(pandf, srb2waddir, "maps.kart"), startupiwadfiles); + if (!AddIWAD("textures.kart", srb2waddir)) + { + I_Error("textures.kart not found! Expected in %s\n", srb2waddir); + } + + if (!AddIWAD("chars.kart", srb2waddir)) + { + I_Error("chars.kart not found! Expected in %s\n", srb2waddir); + } + + if (!AddIWAD("maps.kart", srb2waddir)) + { + I_Error("maps.kart not found! Expected in %s\n", srb2waddir); + } #ifdef USE_PATCH_KART - D_AddFile(va(pandf,srb2waddir,"patch.kart"), startupiwadfiles); + if (!AddIWAD("patch.kart", srb2waddir)) + { + I_Error("patch.kart not found! Expected in %s\n", srb2waddir); + } #endif - const char *path = NULL; - - path = va(pandf, srb2waddir, "extra.kart"); - // completely optional - if (FIL_ReadFileOK(path)) - { - D_AddFile(path, startupiwadfiles); + if (AddIWAD("extra.kart", srb2waddir)) found_extra_kart = true; - } - - path = va(pandf, srb2waddir, "extra2.kart"); // completely optional 2: Back with a vengence - if (FIL_ReadFileOK(path)) - { - D_AddFile(path, startupiwadfiles); + if (AddIWAD("extra2.kart", srb2waddir)) found_extra2_kart = true; - } - path = va(pandf, srb2waddir, "extra3.kart"); - - if (FIL_ReadFileOK(path)) - { - D_AddFile(path, startupiwadfiles); + if (AddIWAD("extra3.kart", srb2waddir)) found_extra3_kart = true; - } #if !defined (HAVE_SDL) || defined (HAVE_MIXER) #define MUSICTEST(str) \ - musicpath = va(pandf,srb2waddir,str);\ + musicpath = va(pandf, srb2waddir, str);\ handle = W_OpenWadFile(&musicpath, false); \ if (handle) \ {\ @@ -1368,7 +1358,7 @@ static void IdentifyVersion(void) if (ms == 0) \ I_Error("File " str " has been modified with non-music/sound lumps"); \ if (ms == 1) \ - D_AddFile(musicpath, startupiwadfiles); \ + D_AddFile(musicpath, startupiwadfiles, startupiwadcount++); \ } { const char *musicpath; @@ -1814,7 +1804,7 @@ void D_SRB2Main(void) const char *s = M_GetNextParm(); if (s) // Check for NULL? - D_AddFile(s, startuppwads); + D_AddFile(s, startuppwads, startuppwadcount++); } } } @@ -1848,7 +1838,8 @@ void D_SRB2Main(void) CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n"); W_InitMultipleFiles(startupiwadfiles, false); - D_CleanFile(startupiwadfiles); + D_CleanFile(startupiwadfiles, startupiwadcount); + startupiwadcount = 0; mainwads = 0; #ifndef DEVELOP @@ -1895,7 +1886,8 @@ void D_SRB2Main(void) D_CheckMaps(true); } - D_CleanFile(startuppwads); + D_CleanFile(startuppwads, startuppwadcount); + startuppwadcount = 0; cht_Init(); From c8ae4a89d9a7b73210a17301f094786b99050c15 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 19:28:41 +0100 Subject: [PATCH 10/12] throw motion blur effect stuff behind an ifdef so we can get rid of the unused array prob could just remove it at this point, but maybe ill fix it someday for the funnis --- src/d_main.c | 6 ++++++ src/doomstat.h | 3 +++ src/p_user.c | 14 +++++++++----- src/v_video.c | 11 +++++++++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index b7704318b..ee587cfdc 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -115,7 +115,9 @@ boolean devparm = false; // started game with -devparm boolean singletics = false; // timedemo boolean lastdraw = false; +#ifdef MOTIONBLUR INT32 postimgparam[MAXSPLITSCREENPLAYERS]; +#endif // These variables are only true if // whether the respective sound system is disabled @@ -399,7 +401,11 @@ static void D_Renderview(void) if (i == 0) R_ApplyViewMorph(); +#ifdef MOTIONBLUR V_DoPostProcessor(i, postimgparam[i]); +#else + V_DoPostProcessor(i, 0); +#endif } } diff --git a/src/doomstat.h b/src/doomstat.h index 46c3d61f9..a9bd9bbac 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -116,7 +116,10 @@ extern UINT8 window_notinfocus; // are we in focus? (backend independant -- hand extern boolean nodrawers; extern boolean noblit; extern boolean lastdraw; + +#ifdef MOTIONBLUR extern INT32 postimgparam[MAXSPLITSCREENPLAYERS]; +#endif extern INT32 viewwindowx, viewwindowy; extern INT32 viewwidth; diff --git a/src/p_user.c b/src/p_user.c index 5ccc43f0a..481cd6060 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4315,17 +4315,19 @@ static void P_CalcPostImg(player_t *player, camera_t *thiscam) { sector_t *sector = NULL; UINT8 postimgtype = 0; - //INT32 *param; fixed_t pviewheight = 0; +#ifdef MOTIONBLUR + INT32 *param; - /*for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= splitscreen; i++) { if (player == &players[displayplayers[i]]) { param = &postimgparam[i]; break; } - }*/ + } +#endif if (encoremode) // srb2kart postimgtype |= POSTIMG_MIRROR; @@ -4361,16 +4363,18 @@ static void P_CalcPostImg(player_t *player, camera_t *thiscam) else if (P_CameraCheckHeatFirstperson(player, sector, pviewheight)) postimgtype |= POSTIMG_HEAT; +#ifdef MOTIONBLUR // Motion blur // unused - /*if (player->speed > (35<speed > (35<speed - 32)/4; if (*param > 5) *param = 5; - }*/ + } +#endif thiscam->postimg = postimgtype; } diff --git a/src/v_video.c b/src/v_video.c index 9805e910c..e7d9a87ca 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3581,6 +3581,9 @@ boolean *heatshifter = NULL; INT32 lastheight = 0; INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; +// unused motion blur effect, probably non functional +//#define MOTIONBLUR + // // V_DoPostProcessor // @@ -3595,7 +3598,9 @@ void V_DoPostProcessor(INT32 view, INT32 param) (void)type; (void)param; #else +#ifndef MOTIONBLUR (void)param; // unused motion blur stuff +#endif INT32 yoffset, xoffset; #ifdef HWRENDER @@ -3730,7 +3735,8 @@ void V_DoPostProcessor(INT32 view, INT32 param) srcscr = tmp; } - /*if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur! +#ifdef MOTIONBLUR + if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur! { INT32 x, y; @@ -3742,7 +3748,8 @@ void V_DoPostProcessor(INT32 view, INT32 param) for (x = xoffset; x < xoffset+viewwidth; x++) tmpscr[y*vid.width + x] = colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))]; } - }*/ + } +#endif if ((thiscam->postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down { From 7c1f17bb8dcbc2dc6ea8ace3c11e9e80368720c0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 20:47:19 +0100 Subject: [PATCH 11/12] pass our file counts to W_InitMultipleFiles smol opzimiation, skips some ptr deref --- src/d_main.c | 17 +++++++++-------- src/w_wad.c | 13 +++++++------ src/w_wad.h | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ee587cfdc..7bb932b1b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1046,7 +1046,7 @@ void D_StartTitle(void) // // D_AddFile // -static void D_AddFile(const char *file, char **filearray, size_t count) +static void D_AddFile(const char *file, char **filearray, size_t index) { char *newfile; @@ -1057,14 +1057,14 @@ static void D_AddFile(const char *file, char **filearray, size_t count) } strcpy(newfile, file); - filearray[count] = newfile; + filearray[index] = newfile; } -static void D_CleanFile(char **filearray, size_t count) +static void D_CleanFile(char **filearray, size_t index) { size_t i; - for (i = 0; i < count; i++) + for (i = 0; i < index; i++) { free(filearray[i]); filearray[i] = NULL; @@ -1358,7 +1358,7 @@ static void IdentifyVersion(void) musicpath = va(pandf, srb2waddir, str);\ handle = W_OpenWadFile(&musicpath, false); \ if (handle) \ - {\ + { \ int ms = W_VerifyNMUSlumps(musicpath, handle, false); \ fclose(handle); \ if (ms == 0) \ @@ -1843,7 +1843,8 @@ void D_SRB2Main(void) // load wad, including the main wad file CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n"); - W_InitMultipleFiles(startupiwadfiles, false); + W_InitMultipleFiles(startupiwadfiles, startupiwadcount, false); + //mainwads = startupiwadcount - musicwads; D_CleanFile(startupiwadfiles, startupiwadcount); startupiwadcount = 0; mainwads = 0; @@ -1884,10 +1885,10 @@ void D_SRB2Main(void) D_CheckMaps(false); - W_InitMultipleFiles(startuppwads, true); + W_InitMultipleFiles(startuppwads, startuppwadcount, true); // Only search for pwad maps if we actually have a pwad added - if (startuppwads[0] != NULL) + if (startuppwadcount > 0) { D_CheckMaps(true); } diff --git a/src/w_wad.c b/src/w_wad.c index 756dee4a6..f9eb9b361 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -971,24 +971,25 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup) * \return 1 if all files were loaded, 0 if at least one was missing or * invalid. */ -INT32 W_InitMultipleFiles(char **filenames, boolean addons) +INT32 W_InitMultipleFiles(char **filenames, size_t count, boolean addons) { INT32 rc = 1; INT32 overallrc = 1; - + size_t i; (void)addons; - // will be realloced as lumps are added - for (; *filenames; filenames++) + for (i = 0; i < count; i++) { + const char *filename = filenames[i]; + // Previously, W_VerifyNMUSlumps was called to mark game modified // for addons... but W_InitFile already does exactly that! //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); - rc = W_InitFile(*filenames, false, true); + rc = W_InitFile(filename, false, true); if (rc == INT16_MAX) - CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames); + CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), filename); overallrc &= (rc != INT16_MAX) ? 1 : 0; } diff --git a/src/w_wad.h b/src/w_wad.h index c3cae627f..6240c31f3 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -167,7 +167,7 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup); // W_InitMultipleFiles returns 1 if all is okay, 0 otherwise, // so that it stops with a message if a file was not found, but not if all is okay. -INT32 W_InitMultipleFiles(char **filenames, boolean addons); +INT32 W_InitMultipleFiles(char **filenames, size_t count, boolean addons); // Used for autoload. Uses P_AddWadFileLocal instead of W_InitFiles. INT32 W_AddAutoloadedLocalFiles(char **filenames); From 3e0150d4f31be79d30c99d0d6f8b00a02e85360b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 20:53:21 +0100 Subject: [PATCH 12/12] remove auto/postload check variables we can just check our counts since D_FindAddonsToAutoload will never be called again --- src/d_main.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 7bb932b1b..aa6c905c2 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -106,8 +106,6 @@ static char *autoloadwadfiles[MAX_WADFILES]; static char *autoloadwadfilespost[MAX_WADFILES]; static size_t autoloadcount = 0; static size_t postloadcount = 0; -static boolean autoloaded = false; -static boolean postautoloaded = false; // boolean devparm = false; // started game with -devparm @@ -1160,7 +1158,7 @@ static void D_FindAddonsToAutoload(void) // If the file is found, run our shit if (!autoloadconfigfile) // nope outta here { - autoloaded = postautoloaded = true; // so D_AddAutoloadFiles can skip everything since nothings there to autoload + autoloadcount = postloadcount = 0; // so D_AddAutoloadFiles can skip everything since nothings there to autoload return; } @@ -1214,7 +1212,8 @@ static void D_FindAddonsToAutoload(void) static void D_AddAutoloadFiles(void) { - if (autoloaded) + // nothing to autoload + if (autoloadcount == 0) return; CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); @@ -1225,12 +1224,12 @@ static void D_AddAutoloadFiles(void) D_CleanFile(autoloadwadfiles, autoloadcount); autoloadcount = 0; - autoloaded = true; } void D_AddPostloadFiles(void) { - if (postautoloaded || !netgame) + // nothing to postload + if (postloadcount == 0 || !netgame) return; CONS_Printf("D_AddPostloadFiles(): Loading postloaded addons...\n"); @@ -1241,7 +1240,6 @@ void D_AddPostloadFiles(void) D_CleanFile(autoloadwadfilespost, postloadcount); postloadcount = 0; - postautoloaded = true; } // ==========================================================================