From b35c33a1b5f6716761dc4477351532221ce25dc5 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Jan 2023 18:09:50 +0000 Subject: [PATCH 01/20] M_GetToken: check whether startPos is beyond string length BEFORE using it as string index --- src/m_misc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/m_misc.c b/src/m_misc.c index cf03c5e2d..25a6c8624 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1940,14 +1940,14 @@ char *M_GetToken(const char *inputString) } // Find the first non-whitespace char, or else the end of the string trying - while ((stringToUse[startPos] == ' ' + while (startPos < stringLength + && (stringToUse[startPos] == ' ' || stringToUse[startPos] == '\t' || stringToUse[startPos] == '\r' || stringToUse[startPos] == '\n' || stringToUse[startPos] == '\0' || stringToUse[startPos] == '=' || stringToUse[startPos] == ';' // UDMF TEXTMAP. - || inComment != 0) - && startPos < stringLength) + || inComment != 0)) { // Try to detect comment endings now if (inComment == 1 @@ -1988,7 +1988,7 @@ char *M_GetToken(const char *inputString) } // If the end of the string is reached, no token is to be read - if (startPos == stringLength) { + if (startPos >= stringLength) { endPos = stringLength; return NULL; } @@ -2007,7 +2007,7 @@ char *M_GetToken(const char *inputString) else if (stringToUse[startPos] == '"') { endPos = ++startPos; - while (stringToUse[endPos] != '"' && endPos < stringLength) + while (endPos < stringLength && stringToUse[endPos] != '"') endPos++; texturesTokenLength = endPos++ - startPos; @@ -2023,7 +2023,8 @@ char *M_GetToken(const char *inputString) // Now find the end of the token. This includes several additional characters that are okay to capture as one character, but not trailing at the end of another token. endPos = startPos + 1; - while ((stringToUse[endPos] != ' ' + while (endPos < stringLength + && (stringToUse[endPos] != ' ' && stringToUse[endPos] != '\t' && stringToUse[endPos] != '\r' && stringToUse[endPos] != '\n' @@ -2031,8 +2032,7 @@ char *M_GetToken(const char *inputString) && stringToUse[endPos] != '{' && stringToUse[endPos] != '}' && stringToUse[endPos] != '=' && stringToUse[endPos] != ';' // UDMF TEXTMAP. - && inComment == 0) - && endPos < stringLength) + && inComment == 0)) { endPos++; // Try to detect comment starts now; if it's in a comment, we don't want it in this token From 4520d56fa3a81a8f460d73c455de40662cc7ea25 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Jan 2023 18:10:42 +0000 Subject: [PATCH 02/20] K_InitTerrain: Do what ANIMDEFs parsing does and create a copy of the TERRAIN lump with a guaranteed null terminator --- src/k_terrain.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/k_terrain.c b/src/k_terrain.c index a702f53ad..44a704834 100644 --- a/src/k_terrain.c +++ b/src/k_terrain.c @@ -1745,9 +1745,9 @@ static boolean K_DoTERRAINLumpParse(size_t num, void (*parser)(size_t, char *, c Return:- false if any errors occured, otherwise true. --------------------------------------------------*/ -static boolean K_TERRAINLumpParser(UINT8 *data, size_t size) +static boolean K_TERRAINLumpParser(char *data, size_t size) { - char *tkn = M_GetToken((char *)data); + char *tkn = M_GetToken(data); UINT32 tknHash = 0; size_t pos = 0; size_t i; @@ -2136,6 +2136,7 @@ void K_InitTerrain(UINT16 wadNum) else { size_t size = W_LumpLengthPwad(wadNum, lumpNum); + char *datacopy; size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name char *name = malloc(nameLength + 1); @@ -2146,7 +2147,16 @@ void K_InitTerrain(UINT16 wadNum) size = W_LumpLengthPwad(wadNum, lumpNum); CONS_Printf(M_GetText("Loading TERRAIN from %s\n"), name); - K_TERRAINLumpParser(data, size); + + datacopy = (char *)Z_Malloc((size+1)*sizeof(char),PU_STATIC,NULL); + memmove(datacopy,data,size); + datacopy[size] = '\0'; + + Z_Free(data); + + K_TERRAINLumpParser(datacopy, size); + + Z_Free(datacopy); free(name); } From afafdea14b54975ce65baf6478825d07ae59a044 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Jan 2023 19:30:13 +0000 Subject: [PATCH 03/20] readfollower: Fix plenty of memory unsafety - Fix uninitialised memory usage caused by goofy delayed strcpy - Use strlcpy instead of strcpy for unknown length sources, just for additional memory safety - Remove opportunity for printing a number of more than one digit into a buffer only two chars long --- src/deh_soc.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/deh_soc.c b/src/deh_soc.c index 4fb40b087..853c7f182 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -3213,12 +3213,12 @@ void readfollower(MYFILE *f) if (fastcmp(word, "NAME")) { - strcpy(followers[numfollowers].name, word2); + strlcpy(followers[numfollowers].name, word2, SKINNAMESIZE+1); nameset = true; } else if (fastcmp(word, "ICON")) { - strcpy(followers[numfollowers].icon, word2); + strlcpy(followers[numfollowers].icon, word2, 8+1); nameset = true; } else if (fastcmp(word, "CATEGORY")) @@ -3362,30 +3362,26 @@ void readfollower(MYFILE *f) if (!nameset) { // well this is problematic. - strcpy(followers[numfollowers].name, va("Follower%d", numfollowers)); // this is lazy, so what + strlcpy(followers[numfollowers].name, va("Follower%d", numfollowers), SKINNAMESIZE+1); + strcpy(testname, followers[numfollowers].name); } - - // set skin name (this is just the follower's name in lowercases): - // but before we do, let's... actually check if another follower isn't doing the same shit... - - res = K_FollowerAvailable(testname); - if (res > -1) // yikes, someone else has stolen our name already + else { - INT32 startlen = strlen(testname); - char cpy[2]; - //deh_warning("There was already a follower with the same name. (%s)", testname); This warning probably isn't necessary anymore? - sprintf(cpy, "%d", numfollowers); - memcpy(&testname[startlen], cpy, 2); - // in that case, we'll be very lazy and copy numfollowers to the end of our skin name. - } + strcpy(testname, followers[numfollowers].name); - strcpy(testname, followers[numfollowers].name); + // now that the skin name is ready, post process the actual name to turn the underscores into spaces! + for (i = 0; followers[numfollowers].name[i]; i++) + { + if (followers[numfollowers].name[i] == '_') + followers[numfollowers].name[i] = ' '; + } - // now that the skin name is ready, post process the actual name to turn the underscores into spaces! - for (i = 0; followers[numfollowers].name[i]; i++) - { - if (followers[numfollowers].name[i] == '_') - followers[numfollowers].name[i] = ' '; + res = K_FollowerAvailable(followers[numfollowers].name); + if (res > -1) // yikes, someone else has stolen our name already + { + deh_warning("Follower%d: Name \"%s\" already in use!", numfollowers, testname); + strlcpy(followers[numfollowers].name, va("Follower%d", numfollowers), SKINNAMESIZE+1); + } } // fallbacks for variables From 496cc2fa0bc87db4ef7f51405460c1cd0ea60fba Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Jan 2023 20:21:46 +0000 Subject: [PATCH 04/20] CV_palette_OnChange: do not reload colour cube until LOADED_CONFIG is complete No substitute for an actual mutex on the palette, but this does at least prevent 21 redundant calls to palette reinitialisation --- src/v_video.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/v_video.c b/src/v_video.c index e633b4e3f..9f707ef1c 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -476,6 +476,8 @@ void V_SetPaletteLump(const char *pal) static void CV_palette_OnChange(void) { + if (con_startup_loadprogress < LOADED_CONFIG) + return; // recalculate Color Cube V_ReloadPalette(); V_SetPalette(0); From 2d95c177ea4fd44980d1d9836261aac75338810e Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Jan 2023 20:50:13 +0000 Subject: [PATCH 05/20] K_InitBrightmapsPwad: Also use guaranteed null-terminated data copy ala K_InitTerrain --- src/k_brightmap.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/k_brightmap.c b/src/k_brightmap.c index a70d7a955..5b9963426 100644 --- a/src/k_brightmap.c +++ b/src/k_brightmap.c @@ -86,7 +86,7 @@ static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkN } /*-------------------------------------------------- - static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size) + static boolean K_BRIGHTLumpParser(char *data, size_t size) Parses inputted lump data as a BRIGHT lump. @@ -97,7 +97,7 @@ static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkN Return:- false if any errors occured, otherwise true. --------------------------------------------------*/ -static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size) +static boolean K_BRIGHTLumpParser(char *data, size_t size) { char *tkn = M_GetToken((char *)data); size_t pos = 0; @@ -188,6 +188,7 @@ void K_InitBrightmapsPwad(INT32 wadNum) { lumpinfo_t *lump_p = &wadfiles[wadNum]->lumpinfo[lumpNum]; size_t size = W_LumpLengthPwad(wadNum, lumpNum); + char *datacopy; size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name char *name = malloc(nameLength + 1); @@ -198,10 +199,18 @@ void K_InitBrightmapsPwad(INT32 wadNum) size = W_LumpLengthPwad(wadNum, lumpNum); CONS_Printf(M_GetText("Loading BRIGHT from %s\n"), name); - K_BRIGHTLumpParser(data, size); + + datacopy = (char *)Z_Malloc((size+1)*sizeof(char),PU_STATIC,NULL); + memmove(datacopy,data,size); + datacopy[size] = '\0'; + + Z_Free(data); + + K_BRIGHTLumpParser(datacopy, size); + + Z_Free(datacopy); free(name); - Z_Free(data); } lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1); From b0a8a0efad4597734a1083c1d8cb8c0a8fec2b10 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Jan 2023 20:50:34 +0000 Subject: [PATCH 06/20] Update comment for K_TERRAINLumpParser --- src/k_terrain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_terrain.c b/src/k_terrain.c index 44a704834..322aecdce 100644 --- a/src/k_terrain.c +++ b/src/k_terrain.c @@ -1734,7 +1734,7 @@ static boolean K_DoTERRAINLumpParse(size_t num, void (*parser)(size_t, char *, c } /*-------------------------------------------------- - static boolean K_TERRAINLumpParser(UINT8 *data, size_t size) + static boolean K_TERRAINLumpParser(char *data, size_t size) Parses inputted lump data as a TERRAIN lump. From 99808d7a4c508ae7f5a57ec0e9353c4aa5a9efb1 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Jan 2023 21:35:24 +0000 Subject: [PATCH 07/20] filesrch.c: Initialise struct stat --- src/filesrch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/filesrch.c b/src/filesrch.c index 9db81ad37..ae1c0e85c 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -450,7 +450,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want filestatus_t retval = FS_NOTFOUND; DIR **dirhandle; struct dirent *dent; - struct stat fsstat; + struct stat fsstat = {0}; int found = 0; char *searchname = strdup(filename); int depthleft = maxsearchdepth; @@ -709,7 +709,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut) { DIR *dirhandle; struct dirent *dent; - struct stat fsstat; + struct stat fsstat = {0}; size_t pos = 0, folderpos = 0, numfolders = 0; char *tempname = NULL; From 89b77b656950275877d284ee3dcdbe01d3375d19 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Jan 2023 21:44:14 +0000 Subject: [PATCH 08/20] opendir: initialise dd_dta struct --- src/filesrch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/filesrch.c b/src/filesrch.c index ae1c0e85c..a97a45444 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -172,6 +172,7 @@ opendir (const CHAR *szPath) /* Initialize the dirent structure. ino and reclen are invalid under * Win32, and name simply points at the appropriate part of the * findfirst_t structure. */ + nd->dd_dta = {0}; nd->dd_dir.d_ino = 0; nd->dd_dir.d_reclen = 0; nd->dd_dir.d_namlen = 0; From 59d8c540d17c9d1103d6c3d79bee750a84e8b19d Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Jan 2023 22:14:31 +0000 Subject: [PATCH 09/20] SetChannelsNum: Callocate sound channels, don't mallocate them --- src/s_sound.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index a721a9ff4..5dd621725 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -291,12 +291,8 @@ static void SetChannelsNum(void) } #endif if (cv_numChannels.value) - channels = (channel_t *)Z_Malloc(cv_numChannels.value * sizeof (channel_t), PU_STATIC, NULL); - numofchannels = cv_numChannels.value; - - // Free all channels for use - for (i = 0; i < numofchannels; i++) - channels[i].sfxinfo = 0; + channels = (channel_t *)Z_Calloc(cv_numChannels.value * sizeof (channel_t), PU_STATIC, NULL); + numofchannels = (channels ? cv_numChannels.value : 0); S_ResetCaptions(); } From f5b985bcc3132dc09a4ee16727b63058899820ae Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 5 Jan 2023 18:20:42 -0800 Subject: [PATCH 10/20] doomdef.h: refactor comptime externs --- src/doomdef.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 72ba17a84..3a1e11b44 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -663,9 +663,15 @@ UINT32 quickncasehash (const char *p, size_t n) #define PUNCTUATION "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" // Compile date and time and revision. -extern const char *compdate, *comptime, *comprevision, *compbranch; -extern int compuncommitted, compoptimized; -extern const char *comptype; +extern const char + *compdate, + *comptime, + *comprevision, + *compbranch, + *comptype; +extern int + compuncommitted, + compoptimized; // Disabled code and code under testing // None of these that are disabled in the normal build are guaranteed to work perfectly From 55636fa690ac95f50220d83b1b47984b28315410 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 5 Jan 2023 18:29:51 -0800 Subject: [PATCH 11/20] Separate git commit subject line from comprevision, add SRB2_COMP_NOTE --- cmake/Comptime.cmake | 5 +++-- cmake/Modules/GitUtilities.cmake | 4 ++-- src/comptime.c | 1 + src/config.h.in | 1 + src/d_netcmd.c | 2 +- src/doomdef.h | 1 + src/f_finale.c | 2 +- 7 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmake/Comptime.cmake b/cmake/Comptime.cmake index f50faf933..8388aed9e 100644 --- a/cmake/Comptime.cmake +++ b/cmake/Comptime.cmake @@ -11,8 +11,9 @@ include(GitUtilities) git_current_branch(SRB2_COMP_BRANCH) git_working_tree_dirty(SRB2_COMP_UNCOMMITTED) -git_summary(revision) -string(REGEX REPLACE "([\"\\])" "\\\\\\1" SRB2_COMP_REVISION "${revision}") +git_latest_commit(SRB2_COMP_REVISION) +git_subject(subject) +string(REGEX REPLACE "([\"\\])" "\\\\\\1" SRB2_COMP_NOTE "${subject}") if("${CMAKE_BUILD_TYPE}" STREQUAL "") set(CMAKE_BUILD_TYPE None) diff --git a/cmake/Modules/GitUtilities.cmake b/cmake/Modules/GitUtilities.cmake index bddc552a6..586c7b433 100644 --- a/cmake/Modules/GitUtilities.cmake +++ b/cmake/Modules/GitUtilities.cmake @@ -50,8 +50,8 @@ function(git_working_tree_dirty variable) endif() endfunction() -function(git_summary variable) - _git_easy_command(log -1 "--format=%h %s") +function(git_subject variable) + _git_easy_command(log -1 --format=%s) endfunction() function(get_git_dir variable) diff --git a/src/comptime.c b/src/comptime.c index 74b810062..386b53f46 100644 --- a/src/comptime.c +++ b/src/comptime.c @@ -11,6 +11,7 @@ #include "config.h" const char *compbranch = SRB2_COMP_BRANCH; const char *comprevision = SRB2_COMP_REVISION; +const char *compnote = SRB2_COMP_NOTE; const char *comptype = CMAKE_BUILD_TYPE; const int compoptimized = SRB2_COMP_OPTIMIZED; diff --git a/src/config.h.in b/src/config.h.in index 77a205a74..bf79b61ad 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -13,6 +13,7 @@ #define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}" #define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}" +#define SRB2_COMP_NOTE "${SRB2_COMP_NOTE}" // This is done with configure_file instead of defines in order to avoid // recompiling the whole target whenever the working directory state changes #cmakedefine SRB2_COMP_UNCOMMITTED diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 97b71478e..7529a5e94 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4772,7 +4772,7 @@ static void Command_ListDoomednums_f(void) static void Command_Version_f(void) { #ifdef DEVELOP - CONS_Printf("Ring Racers %s %s (%s %s)\n", compbranch, comprevision, compdate, comptime); + CONS_Printf("Ring Racers %s %s %s (%s %s)\n", compbranch, comprevision, compnote, compdate, comptime); #else CONS_Printf("Ring Racers %s (%s %s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision, compbranch); #endif diff --git a/src/doomdef.h b/src/doomdef.h index 3a1e11b44..ffffd59d5 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -668,6 +668,7 @@ extern const char *comptime, *comprevision, *compbranch, + *compnote, *comptype; extern int compuncommitted, diff --git a/src/f_finale.c b/src/f_finale.c index 36ca452f9..54a7bbb3b 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1913,7 +1913,7 @@ void F_VersionDrawer(void) addtext(V_ALLOWLOWERCASE|V_REDMAP, "Netgame host for testers"); addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s", compdate)); #elif defined(DEVELOP) - addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, comprevision); + addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s %s", comprevision, compnote)); addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, compbranch); #else // Regular build addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s", VERSIONSTRING)); From 94e3050f104209401dc372970ade7e8a1999187b Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 5 Jan 2023 18:15:15 -0800 Subject: [PATCH 12/20] Do not overwrite compbranch in case of detached HEAD --- src/d_main.c | 17 +++++++++++------ src/d_main.h | 2 ++ src/d_netcmd.c | 4 ++-- src/f_finale.c | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ac454f6cb..128fe9c0b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1189,6 +1189,17 @@ D_ConvertVersionNumbers (void) #endif } +const char *D_GetFancyBranchName(void) +{ + if (!strcmp(compbranch, "")) + { + // \x8b = aqua highlight + return "\x8b" "detached HEAD" "\x80"; + } + + return compbranch; +} + // // D_SRB2Main // @@ -1206,12 +1217,6 @@ void D_SRB2Main(void) /* break the version string into version numbers, for netplay */ D_ConvertVersionNumbers(); - if (!strcmp(compbranch, "")) - { - // \x8b = aqua highlight - compbranch = "\x8b" "detached HEAD" "\x80"; - } - #ifdef DEVELOP D_AbbrevCommit(); #endif diff --git a/src/d_main.h b/src/d_main.h index 0b4f6f19d..ee636e387 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -42,6 +42,8 @@ void D_SRB2Loop(void) FUNCNORETURN; // void D_SRB2Main(void); +const char *D_GetFancyBranchName(void); + // Called by IO functions when input is detected. void D_PostEvent(const event_t *ev); #if defined (PC_DOS) && !defined (DOXYGEN) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7529a5e94..1ebda16d5 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4772,9 +4772,9 @@ static void Command_ListDoomednums_f(void) static void Command_Version_f(void) { #ifdef DEVELOP - CONS_Printf("Ring Racers %s %s %s (%s %s)\n", compbranch, comprevision, compnote, compdate, comptime); + CONS_Printf("Ring Racers %s %s %s (%s %s)\n", D_GetFancyBranchName(), comprevision, compnote, compdate, comptime); #else - CONS_Printf("Ring Racers %s (%s %s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision, compbranch); + CONS_Printf("Ring Racers %s (%s %s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision, D_GetFancyBranchName()); #endif // Base library diff --git a/src/f_finale.c b/src/f_finale.c index 54a7bbb3b..2a7d83146 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1914,7 +1914,7 @@ void F_VersionDrawer(void) addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s", compdate)); #elif defined(DEVELOP) addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s %s", comprevision, compnote)); - addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, compbranch); + addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, D_GetFancyBranchName()); #else // Regular build addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s", VERSIONSTRING)); #endif From 1f827a9c25eb656c32aaae2988a01b27d0f41cfc Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 5 Jan 2023 18:36:41 -0800 Subject: [PATCH 13/20] Omit hyphen in replay folder name if compbranch is empty (detached HEAD) --- src/p_setup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index d77a27971..52441c62e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -7177,7 +7177,10 @@ static void P_InitGametype(void) int parts; #ifdef DEVELOP - sprintf(ver, "%s-%s", compbranch, comprevision); + if (strcmp(compbranch, "")) + sprintf(ver, "%s-%s", compbranch, comprevision); + else + strcpy(ver, comprevision); #else strcpy(ver, VERSIONSTRING); #endif From 4adc25eb7452abcc07d0b089015ca9449d555f8d Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 5 Jan 2023 19:20:43 -0800 Subject: [PATCH 14/20] Apply tiregrease exception to offroad TERRAIN --- src/k_kart.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 603266aed..5bc291225 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1045,10 +1045,6 @@ static fixed_t K_CheckOffroadCollide(mobj_t *mo) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); - // If tiregrease is active, don't - if (mo->player && mo->player->tiregrease) - return 0; - for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (!node->m_sector) @@ -1103,14 +1099,18 @@ static void K_UpdateOffroad(player_t *player) terrain_t *terrain = player->mo->terrain; fixed_t offroadstrength = 0; - // TODO: Make this use actual special touch code. - if (terrain != NULL && terrain->offroad > 0) + // If tiregrease is active, don't + if (player->tiregrease == 0) { - offroadstrength = (terrain->offroad << FRACBITS); - } - else - { - offroadstrength = K_CheckOffroadCollide(player->mo); + // TODO: Make this use actual special touch code. + if (terrain != NULL && terrain->offroad > 0) + { + offroadstrength = (terrain->offroad << FRACBITS); + } + else + { + offroadstrength = K_CheckOffroadCollide(player->mo); + } } // If you are in offroad, a timer starts. From 731446bb3e866efd9754ba074628face6a2e8e0f Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 6 Jan 2023 11:58:17 +0000 Subject: [PATCH 15/20] opendir: Eidolon suggestion for initialiser --- src/filesrch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesrch.c b/src/filesrch.c index 2ab8c23bb..1d01a44fc 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -172,7 +172,7 @@ opendir (const CHAR *szPath) /* Initialize the dirent structure. ino and reclen are invalid under * Win32, and name simply points at the appropriate part of the * findfirst_t structure. */ - nd->dd_dta = {0}; + nd->dd_dta = (struct _finddata_t) {0}; nd->dd_dir.d_ino = 0; nd->dd_dir.d_reclen = 0; nd->dd_dir.d_namlen = 0; From 2fdf5de545a885051036df4ef52e1f0c14f9d392 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 6 Jan 2023 11:58:42 +0000 Subject: [PATCH 16/20] SetChannelsNum: Remove now-unused iterator variable --- src/s_sound.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index e71d93d89..0d3746d33 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -268,8 +268,6 @@ void S_RegisterSoundStuff(void) static void SetChannelsNum(void) { - INT32 i; - // Allocating the internal channels for mixing // (the maximum number of sounds rendered // simultaneously) within zone memory. From 12138365647cbba393f34e5b86dd2de1ec923ef4 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 6 Jan 2023 13:16:11 +0000 Subject: [PATCH 17/20] Permit a lightsnaking player to go into RESPAWNST_DROP (the final second of lightsnake) early at any time after the initail bring-back-to-last-waypoint. Needs balance testing, but resolves #299. --- src/d_player.h | 1 + src/k_kart.c | 33 ++++++++++++++++++++++++++------- src/k_respawn.c | 13 ++++++++++++- src/p_user.c | 2 +- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 45f4c6074..2fc8bb62b 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -308,6 +308,7 @@ struct respawnvars_t tic_t dropdash; // Drop Dash charge timer boolean truedeath; // Your soul has left your body boolean manual; // Respawn coords were manually set, please respawn exactly there + boolean init; }; // player_t struct for all bot variables diff --git a/src/k_kart.c b/src/k_kart.c index 603266aed..16d263b00 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9406,17 +9406,28 @@ static INT32 K_FlameShieldMax(player_t *player) boolean K_PlayerEBrake(player_t *player) { + if (player->respawn.state != RESPAWNST_NONE + && player->respawn.init == true) + { + return false; + } + if (player->fastfall != 0) { return true; } - return (K_GetKartButtons(player) & BT_EBRAKEMASK) == BT_EBRAKEMASK + if ((K_GetKartButtons(player) & BT_EBRAKEMASK) == BT_EBRAKEMASK && player->drift == 0 && P_PlayerInPain(player) == false && player->justbumped == 0 && player->spindashboost == 0 - && player->nocontrol == 0; + && player->nocontrol == 0) + { + return true; + } + + return false; } SINT8 K_Sliptiding(player_t *player) @@ -9444,10 +9455,13 @@ void K_KartEbrakeVisuals(player_t *p) { wave = P_SpawnMobj(p->mo->x, p->mo->y, p->mo->z, MT_SOFTLANDING); P_SetScale(wave, p->mo->scale); - wave->momx = p->mo->momx; - wave->momy = p->mo->momy; - wave->momz = p->mo->momz; - wave->standingslope = p->mo->standingslope; + if (p->respawn.state == RESPAWNST_NONE) + { + wave->momx = p->mo->momx; + wave->momy = p->mo->momy; + wave->momz = p->mo->momz; + wave->standingslope = p->mo->standingslope; + } K_ReduceVFX(wave, p); } @@ -9688,7 +9702,12 @@ static void K_KartSpindash(player_t *player) } // Handle fast falling behaviors first. - if (onGround == false) + if (player->respawn.state != RESPAWNST_NONE) + { + // This is handled in K_MovePlayerToRespawnPoint. + return; + } + else if (onGround == false) { // Update fastfall. player->fastfall = player->mo->momz; diff --git a/src/k_respawn.c b/src/k_respawn.c index 5e3a3ecc6..7d1207b10 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -269,6 +269,7 @@ void K_DoIngameRespawn(player_t *player) player->respawn.timer = RESPAWN_TIME; player->respawn.state = RESPAWNST_MOVE; + player->respawn.init = true; player->respawn.airtimer = player->airtime; player->respawn.truedeath = false; @@ -337,7 +338,7 @@ static void K_MovePlayerToRespawnPoint(player_t *player) player->mo->momx = player->mo->momy = player->mo->momz = 0; player->flashing = 2; - player->nocontrol = max(2, player->nocontrol); + //player->nocontrol = max(2, player->nocontrol); if (leveltime % 8 == 0 && !mapreset) { @@ -366,6 +367,9 @@ static void K_MovePlayerToRespawnPoint(player_t *player) player->mo->z = dest.z; P_SetThingPosition(player->mo); + // At the first valid waypoint, permit extra player control options. + player->respawn.init = false; + // Find the next waypoint to head towards if (player->respawn.wp != NULL) { @@ -446,6 +450,13 @@ static void K_MovePlayerToRespawnPoint(player_t *player) player->mo->momz = step.z; } + if (player->respawn.init == false && K_PlayerEBrake(player) == true) + { + // Manual drop! + player->respawn.state = RESPAWNST_DROP; + return; + } + // NOW THEN, time for loads of dumb duplication! // "Emulate" the rest of the path, that way we can spawn a particle a certain distance ahead of you. diff --git a/src/p_user.c b/src/p_user.c index 34c016d18..1409e7bb4 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2219,7 +2219,7 @@ void P_MovePlayer(player_t *player) runspd = FixedMul(runspd, player->mo->movefactor); // Control relinquishing stuff! - if (player->nocontrol) + if (player->nocontrol || player->respawn.state == RESPAWNST_MOVE) player->pflags |= PF_STASIS; // note: don't unset stasis here From 5e4a715394a22f1b89f90ba83f92f568704d3864 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 6 Jan 2023 13:30:34 +0000 Subject: [PATCH 18/20] Decrease spinouttimer every other tic in lightsnake, to a minimum of 1 to still prevent drop dashing Resolves #309. --- src/k_kart.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 16d263b00..1ff8f5c8f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7596,9 +7596,12 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->spinouttimer) { - if ((P_IsObjectOnGround(player->mo) + if (((P_IsObjectOnGround(player->mo) || ( player->spinouttype & KSPIN_AIRTIMER )) && (!player->sneakertimer)) + || (player->respawn.state != RESPAWNST_NONE + && player->spinouttimer > 1 + && (leveltime & 1))) { player->spinouttimer--; if (player->wipeoutslow > 1) From 6d1dd5f08936350ae1b166c5644035b6f86d95cd Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 6 Jan 2023 13:43:11 +0000 Subject: [PATCH 19/20] Fix player potentially getting stuck invisible while lightsnaking when not true death respawn --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 1409e7bb4..e40a69569 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4211,7 +4211,7 @@ void P_PlayerThink(player_t *player) // Flash player after being hit. if (!(player->hyudorotimer // SRB2kart - fixes Hyudoro not flashing when it should. || player->growshrinktimer > 0 // Grow doesn't flash either. - || (player->respawn.state != RESPAWNST_NONE) // Respawn timer (for drop dash effect) + || (player->respawn.state != RESPAWNST_NONE && player->respawn.truedeath == true) // Respawn timer (for drop dash effect) || (player->pflags & PF_NOCONTEST) // NO CONTEST explosion || ((gametyperules & GTR_BUMPERS) && player->bumpers <= 0 && player->karmadelay))) { From f4071ce42fcb82dcd51fa6bf5abb8e98ca512b1c Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 6 Jan 2023 13:50:47 +0000 Subject: [PATCH 20/20] Fix getting race-endingly stuck in zoom tubes while respawning --- src/p_spec.c | 3 +++ src/p_user.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 48d38a125..47afb87be 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4401,6 +4401,9 @@ static void P_ProcessZoomTube(player_t *player, mtag_t sectag, boolean end) if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->carry == CR_ZOOMTUBE) return; + if (player->respawn.state != RESPAWNST_NONE) + return; + // Find line #3 tagged to this sector lineindex = Tag_FindLineSpecial(3, sectag); diff --git a/src/p_user.c b/src/p_user.c index e40a69569..d626e1e19 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4166,7 +4166,7 @@ void P_PlayerThink(player_t *player) // for a bit after a teleport. player->mo->reactiontime--; } - else if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) + else if (player->carry == CR_ZOOMTUBE && player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) { P_DoZoomTube(player); player->rmomx = player->rmomy = 0;