From b84470ec51aa09906c73a7d508ea887243a57419 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Dec 2018 12:01:07 -0500 Subject: [PATCH 1/5] Fix savegamename being improperly built due to missing null char after copying timeattackfolder --- src/dehacked.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index edc4e01d..db1d6eed 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3080,7 +3080,7 @@ static void readmaincfg(MYFILE *f) strncpy(timeattackfolder, gamedatafilename, min(filenamelen, sizeof (timeattackfolder))); timeattackfolder[min(filenamelen, sizeof (timeattackfolder) - 1)] = '\0'; - strncpy(savegamename, timeattackfolder, strlen(timeattackfolder)); + strcpy(savegamename, timeattackfolder); strlcat(savegamename, "%u.ssg", sizeof(savegamename)); // can't use sprintf since there is %u in savegamename strcatbf(savegamename, srb2home, PATHSEP); From 93eda4e7c9308c289645bebb36deb4f389d6b534 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Dec 2018 13:11:25 -0500 Subject: [PATCH 2/5] EXEC: Search for CFG by file path --- src/command.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/command.c b/src/command.c index 47c6d2e5..16f18749 100644 --- a/src/command.c +++ b/src/command.c @@ -32,6 +32,7 @@ #include "hu_stuff.h" #include "p_setup.h" #include "lua_script.h" +#include "d_netfil.h" // findfile //======== // protos. @@ -641,6 +642,7 @@ static void COM_CEchoDuration_f(void) static void COM_Exec_f(void) { UINT8 *buf = NULL; + char filename[256]; if (COM_Argc() < 2 || COM_Argc() > 3) { @@ -649,13 +651,23 @@ static void COM_Exec_f(void) } // load file + // Try with Argv passed verbatim first, for back compat FIL_ReadFile(COM_Argv(1), &buf); if (!buf) { - if (!COM_CheckParm("-noerror")) - CONS_Printf(M_GetText("couldn't execute file %s\n"), COM_Argv(1)); - return; + // Now try by searching the file path + // filename is modified with the full found path + strcpy(filename, COM_Argv(1)); + if (findfile(filename, NULL, true) != FS_NOTFOUND) + FIL_ReadFile(filename, &buf); + + if (!buf) + { + if (!COM_CheckParm("-noerror")) + CONS_Printf(M_GetText("couldn't execute file %s\n"), COM_Argv(1)); + return; + } } if (!COM_CheckParm("-silent")) From b1641aa8e9e5fe5336e89eccfe3b33935d9bc919 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Dec 2018 13:17:56 -0500 Subject: [PATCH 3/5] Apply srb2home to SAVECONFIG --- src/m_misc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/m_misc.c b/src/m_misc.c index 1ab5f1fe..b6ebbb43 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -518,6 +518,7 @@ void M_FirstLoadConfig(void) void M_SaveConfig(const char *filename) { FILE *f; + char *filepath; // make sure not to write back the config until it's been correctly loaded if (!gameconfig_loaded) @@ -532,10 +533,14 @@ void M_SaveConfig(const char *filename) return; } - f = fopen(filename, "w"); + // append srb2home to beginning of filename + // configfile already has this applied + filepath = va(pandf,srb2home, filename); + + f = fopen(filepath, "w"); // change it only if valid if (f) - strcpy(configfile, filename); + strcpy(configfile, filepath); else { CONS_Alert(CONS_ERROR, M_GetText("Couldn't save game config file %s\n"), filename); From 93f7f0a8dfecf194108d076b0b87fe673e25817c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Dec 2018 13:23:09 -0500 Subject: [PATCH 4/5] Apply srb2home to debugfile --- src/d_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 82c60e4a..cdd63ea3 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -27,6 +27,7 @@ #include "d_clisrv.h" #include "z_zone.h" #include "i_tcp.h" +#include "d_main.h" // srb2home // // NETWORKING @@ -1374,12 +1375,12 @@ boolean D_CheckNetGame(void) { k++; sprintf(filename, "debug%d.txt", k); - debugfile = fopen(filename, "w"); + debugfile = fopen(va("%s" PATHSEP "%s", srb2home, filename), "w"); } if (debugfile) - CONS_Printf(M_GetText("debug output to: %s\n"), filename); + CONS_Printf(M_GetText("debug output to: %s\n"), va("%s" PATHSEP "%s", srb2home, filename)); else - CONS_Alert(CONS_WARNING, M_GetText("cannot debug output to file %s!\n"), filename); + CONS_Alert(CONS_WARNING, M_GetText("cannot debug output to file %s!\n"), va("%s" PATHSEP "%s", srb2home, filename)); } #endif #endif From d18b2cda5947d10a6da7fee313f038a0341593e4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Dec 2018 13:32:38 -0500 Subject: [PATCH 5/5] Apply srb2home to saveconfig ONLY if srb2home isn't already there --- src/m_misc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/m_misc.c b/src/m_misc.c index b6ebbb43..a4f53c71 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -534,8 +534,11 @@ void M_SaveConfig(const char *filename) } // append srb2home to beginning of filename - // configfile already has this applied - filepath = va(pandf,srb2home, filename); + // but check if srb2home isn't already there, first + if (!strstr(filename, srb2home)) + filepath = va(pandf,srb2home, filename); + else + filepath = Z_StrDup(filename); f = fopen(filepath, "w"); // change it only if valid @@ -543,7 +546,7 @@ void M_SaveConfig(const char *filename) strcpy(configfile, filepath); else { - CONS_Alert(CONS_ERROR, M_GetText("Couldn't save game config file %s\n"), filename); + CONS_Alert(CONS_ERROR, M_GetText("Couldn't save game config file %s\n"), filepath); return; } }