From 35be353de4d184295480184792188a0f814723ee Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 22 Aug 2019 15:18:14 -0700 Subject: [PATCH 1/6] Save bans when cleared too (Why doesn't it work for I_Quit?) --- src/d_clisrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 213f5dde0..9a2d18772 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2465,6 +2465,7 @@ static void Command_ClearBans(void) return; I_ClearBans(); + D_SaveBan(); reasontail = NULL; while (reasonhead) { From c1949211421b3dff90974600a77de2bda9a77e94 Mon Sep 17 00:00:00 2001 From: filpAM Date: Fri, 13 Sep 2019 13:20:44 -0400 Subject: [PATCH 2/6] Fix "NOMIXER" flag compiling --- src/sdl/sdl_sound.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index d9967ae03..4bb1b5676 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1173,7 +1173,10 @@ void I_StartupSound(void) const char *sdrv_name = NULL; #endif #ifndef HAVE_MIXER - midi_disabled = digital_disabled = true; +#ifndef NO_MIDI + midi_disabled = +#endif + digital_disabled = true; #endif memset(channels, 0, sizeof (channels)); //Alam: Clean it From 7a70f882b12ecb993370b19bbe4f6e80ae8f323e Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 15 Sep 2019 00:32:01 -0700 Subject: [PATCH 3/6] Let first person camera work in demos --- src/r_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index 358a24bb8..faf03c4ba 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1143,7 +1143,7 @@ void R_SetupFrame(player_t *player, boolean skybox) aimingangle = player->aiming; viewangle = viewmobj->angle; - if (/*!demo.playback && */player->playerstate != PST_DEAD) + if (!demo.playback && player->playerstate != PST_DEAD) { if (player == &players[consoleplayer]) { From 43422eb67006e274e54dc2269c1634c134cbd241 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Oct 2019 17:55:31 -0700 Subject: [PATCH 4/6] ferror does not return errno, are you stupid? Use M_FileError to return the proper error description, or "end-of-file". --- src/d_netfil.c | 4 ++-- src/m_argv.c | 2 +- src/m_misc.c | 10 ++++++++++ src/m_misc.h | 2 ++ src/sdl12/sdl_sound.c | 2 +- src/w_wad.c | 12 ++++++------ 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 76b66836b..b72d9c552 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -743,7 +743,7 @@ void SV_FileSendTicker(void) if (ram) M_Memcpy(p->data, &f->id.ram[transfer[i].position], size); else if (fread(p->data, 1, size, transfer[i].currentfile) != size) - I_Error("SV_FileSendTicker: can't read %s byte on %s at %d because %s", sizeu1(size), f->id.filename, transfer[i].position, strerror(ferror(transfer[i].currentfile))); + I_Error("SV_FileSendTicker: can't read %s byte on %s at %d because %s", sizeu1(size), f->id.filename, transfer[i].position, M_FileError(transfer[i].currentfile)); p->position = LONG(transfer[i].position); // Put flag so receiver knows the total size if (transfer[i].position + size == f->size) @@ -822,7 +822,7 @@ void Got_Filetxpak(void) // We can receive packet in the wrong order, anyway all os support gaped file fseek(file->file, pos, SEEK_SET); if (fwrite(netbuffer->u.filetxpak.data,size,1,file->file) != 1) - I_Error("Can't write to %s: %s\n",filename, strerror(ferror(file->file))); + I_Error("Can't write to %s: %s\n",filename, M_FileError(file->file)); file->currentsize += size; // Finished? diff --git a/src/m_argv.c b/src/m_argv.c index e8bfdd3db..a23f938a8 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -166,7 +166,7 @@ void M_FindResponseFile(void) if (!file) I_Error("No more free memory for the response file"); if (fread(file, size, 1, handle) != 1) - I_Error("Couldn't read response file because %s", strerror(ferror(handle))); + I_Error("Couldn't read response file because %s", M_FileError(handle)); fclose(handle); // keep all the command line arguments following @responsefile diff --git a/src/m_misc.c b/src/m_misc.c index f4a4ec291..b83d4034e 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -2355,3 +2355,13 @@ void M_SetupMemcpy(void) M_Memcpy = cpu_cpy; #endif } + +/** Return the appropriate message for a file error or end of file. +*/ +const char *M_FileError(FILE *fp) +{ + if (ferror(fp)) + return strerror(errno); + else + return "end-of-file"; +} diff --git a/src/m_misc.h b/src/m_misc.h index 658028b44..1e7befb1e 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -100,6 +100,8 @@ void strcatbf(char *s1, const char *s2, const char *s3); void M_SetupMemcpy(void); +const char *M_FileError(FILE *handle); + // counting bits, for weapon ammo code, usually FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size); diff --git a/src/sdl12/sdl_sound.c b/src/sdl12/sdl_sound.c index ed1afd8e2..1a7525fee 100644 --- a/src/sdl12/sdl_sound.c +++ b/src/sdl12/sdl_sound.c @@ -1435,7 +1435,7 @@ static boolean LoadSong(void *data, size_t lumplength, size_t selectpos) if (fwrite(data, lumplength, 1, midfile) == 0) { - CONS_Printf(M_GetText("Couldn't write music into file %s because %s\n"), tempname, strerror(ferror(midfile))); + CONS_Printf(M_GetText("Couldn't write music into file %s because %s\n"), tempname, M_FileError(midfile)); Z_Free(data); fclose(midfile); return false; diff --git a/src/w_wad.c b/src/w_wad.c index da82a276d..734308956 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -366,7 +366,7 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen // read the header if (fread(&header, 1, sizeof header, handle) < sizeof header) { - CONS_Alert(CONS_ERROR, M_GetText("Can't read wad header because %s\n"), strerror(ferror(handle))); + CONS_Alert(CONS_ERROR, M_GetText("Can't read wad header because %s\n"), M_FileError(handle)); return NULL; } @@ -389,7 +389,7 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen if (fseek(handle, header.infotableofs, SEEK_SET) == -1 || fread(fileinfo, 1, i, handle) < i) { - CONS_Alert(CONS_ERROR, M_GetText("Corrupt wadfile directory (%s)\n"), strerror(ferror(handle))); + CONS_Alert(CONS_ERROR, M_GetText("Corrupt wadfile directory (%s)\n"), M_FileError(handle)); free(fileinfov); return NULL; } @@ -410,7 +410,7 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen handle) < sizeof realsize) { I_Error("corrupt compressed file: %s; maybe %s", /// \todo Avoid the bailout? - filename, strerror(ferror(handle))); + filename, M_FileError(handle)); } realsize = LONG(realsize); if (realsize != 0) @@ -548,7 +548,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) fseek(handle, -4, SEEK_CUR); if (fread(&zend, 1, sizeof zend, handle) < sizeof zend) { - CONS_Alert(CONS_ERROR, "Corrupt central directory (%s)\n", strerror(ferror(handle))); + CONS_Alert(CONS_ERROR, "Corrupt central directory (%s)\n", M_FileError(handle)); return NULL; } numlumps = zend.entries; @@ -565,7 +565,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) if (fread(zentry, 1, sizeof(zentry_t), handle) < sizeof(zentry_t)) { - CONS_Alert(CONS_ERROR, "Failed to read central directory (%s)\n", strerror(ferror(handle))); + CONS_Alert(CONS_ERROR, "Failed to read central directory (%s)\n", M_FileError(handle)); Z_Free(lumpinfo); free(zentry); return NULL; @@ -585,7 +585,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) fullname = malloc(zentry->namelen + 1); if (fgets(fullname, zentry->namelen + 1, handle) != fullname) { - CONS_Alert(CONS_ERROR, "Unable to read lumpname (%s)\n", strerror(ferror(handle))); + CONS_Alert(CONS_ERROR, "Unable to read lumpname (%s)\n", M_FileError(handle)); Z_Free(lumpinfo); free(zentry); free(fullname); From f5390b26a8f83c223b3e17c9958b91d98ab9050d Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Oct 2019 18:10:33 -0700 Subject: [PATCH 5/6] Forgot includes --- src/m_argv.c | 1 + src/m_misc.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/m_argv.c b/src/m_argv.c index a23f938a8..e1046f8a7 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -16,6 +16,7 @@ #include "doomdef.h" #include "command.h" #include "m_argv.h" +#include "m_misc.h" /** \brief number of arg */ diff --git a/src/m_misc.c b/src/m_misc.c index b83d4034e..a8c55be54 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -23,6 +23,8 @@ #include #endif +#include + // Extended map support. #include From 49ff331ac0f6b633fb923ca3ed16cbd20c12b12e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 14 Apr 2019 16:39:14 +0100 Subject: [PATCH 6/6] Detect infinite alias self-recursion mixed with other commands, such as in the case of `alias a "echo test; a"; a`. (Unfortunately, this does not work if "wait" is used instead of "echo", but oh well) (cherry picked from commit e501d9c6af6bb2feb381bcfc8956bcc5d6d2c608) --- src/command.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/command.c b/src/command.c index bd3a22432..95fd5ef46 100644 --- a/src/command.c +++ b/src/command.c @@ -543,10 +543,7 @@ static void COM_ExecuteString(char *ptext) if (!stricmp(com_argv[0], a->name)) { if (recursion > MAX_ALIAS_RECURSION) - { CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n")); - recursion = 0; - } else { char buf[1024]; @@ -578,8 +575,10 @@ static void COM_ExecuteString(char *ptext) } WRITESTRING(write, read); + // Monster Iestyn: keep track of how many levels of recursion we're in recursion++; COM_BufInsertText(buf); + recursion--; } return; }