From 34645238d4693852cbdded8c35b61efed44ff72f Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 3 Mar 2019 20:08:11 -0500 Subject: [PATCH 1/9] Fix MF_NOCLIPTHING --- src/p_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 95ad02588..58007052f 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -456,7 +456,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; } - if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE))) + if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE)) || (thing->flags & MF_NOCLIPTHING)) return true; // Don't collide with your buddies while NiGHTS-flying. From e9771cd7d01e43f61608161e87571bd3773d6599 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Mon, 8 Jul 2019 08:39:31 -0500 Subject: [PATCH 2/9] Make FixedRem less laggy by just using the modulo operator. --- src/m_fixed.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/m_fixed.h b/src/m_fixed.h index 4609913b7..654af6bea 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -206,14 +206,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedDiv(fixed_t a, fixed_t b) */ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRem(fixed_t x, fixed_t y) { - const boolean n = x < 0; - x = abs(x); - while (x >= y) - x -= y; - if (n) - return -x; - else - return x; + return x % y; } /** \brief The FixedSqrt function From 7731bf6b09d5027bd984c2641911e361a6d24103 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 21 Aug 2019 21:25:45 -0400 Subject: [PATCH 3/9] Use correct integer format --- src/lua_playerlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index dd7439321..1b219c70a 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -628,7 +628,7 @@ static int power_get(lua_State *L) UINT16 *powers = *((UINT16 **)luaL_checkudata(L, 1, META_POWERS)); powertype_t p = luaL_checkinteger(L, 2); if (p >= NUMPOWERS) - return luaL_error(L, LUA_QL("powertype_t") " cannot be %u", p); + return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", p); lua_pushinteger(L, powers[p]); return 1; } @@ -640,7 +640,7 @@ static int power_set(lua_State *L) powertype_t p = luaL_checkinteger(L, 2); UINT16 i = (UINT16)luaL_checkinteger(L, 3); if (p >= NUMPOWERS) - return luaL_error(L, LUA_QL("powertype_t") " cannot be %u", p); + return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", p); if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); powers[p] = i; From 9f7613ef6d280d30b571f35fbf53293004172450 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 24 Aug 2019 18:22:18 -0400 Subject: [PATCH 4/9] Typecast p to INT16 Since the enum type is implementation-defined, and could be either signed or unsigned. --- src/lua_playerlib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 1b219c70a..d5b949f43 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -628,19 +628,19 @@ static int power_get(lua_State *L) UINT16 *powers = *((UINT16 **)luaL_checkudata(L, 1, META_POWERS)); powertype_t p = luaL_checkinteger(L, 2); if (p >= NUMPOWERS) - return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", p); + return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", (INT16)p); lua_pushinteger(L, powers[p]); return 1; } // powers, p, value -> powers[p] = value -static int power_set(lua_State *L) -{ +static int power_set(lua_State *L){ + UINT16 *powers = *((UINT16 **)luaL_checkudata(L, 1, META_POWERS)); powertype_t p = luaL_checkinteger(L, 2); UINT16 i = (UINT16)luaL_checkinteger(L, 3); if (p >= NUMPOWERS) - return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", p); + return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", (INT16)p); if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); powers[p] = i; From 08808e220077b8899e361423cb665903d3c360ad Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 24 Aug 2019 18:27:07 -0400 Subject: [PATCH 5/9] I don't even know how this happened --- src/lua_playerlib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index d5b949f43..b3bda2520 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -634,7 +634,8 @@ static int power_get(lua_State *L) } // powers, p, value -> powers[p] = value -static int power_set(lua_State *L){ +static int power_set(lua_State *L) +{ UINT16 *powers = *((UINT16 **)luaL_checkudata(L, 1, META_POWERS)); powertype_t p = luaL_checkinteger(L, 2); From 13d627ee7fbe64697845cfea613a384c5ca81b40 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 24 Aug 2019 18:29:56 -0400 Subject: [PATCH 6/9] Remove extra whitespace --- src/lua_playerlib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index b3bda2520..68e3e7891 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -636,7 +636,6 @@ static int power_get(lua_State *L) // powers, p, value -> powers[p] = value static int power_set(lua_State *L) { - UINT16 *powers = *((UINT16 **)luaL_checkudata(L, 1, META_POWERS)); powertype_t p = luaL_checkinteger(L, 2); UINT16 i = (UINT16)luaL_checkinteger(L, 3); From 2f521f2eb18a79fd7e0a6aca2f2b7b6113042d6c Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Oct 2019 17:55:31 -0700 Subject: [PATCH 7/9] 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 d25b6a278..8ee2df451 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -723,7 +723,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) @@ -803,7 +803,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 c5e4fa21c..8c175857d 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -2371,3 +2371,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 7dd8baabf..72725ec52 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 7de64f9ad..a20e458ae 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -370,7 +370,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; } @@ -393,7 +393,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; } @@ -414,7 +414,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) @@ -552,7 +552,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; @@ -569,7 +569,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(zentries); return NULL; @@ -589,7 +589,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(zentries); free(fullname); From 92dd9d20663c8c601053354326fd9412694e3078 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Oct 2019 18:10:33 -0700 Subject: [PATCH 8/9] 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 8c175857d..edcd2a474 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -23,6 +23,8 @@ #include #endif +#include + // Extended map support. #include From 0a24c82346e9ae283ac8bdae9a02fbf5782507da Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Thu, 5 Dec 2019 10:51:55 -0500 Subject: [PATCH 9/9] Fix building with MSVC --- src/sdl/i_video.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 77bf414cc..12695585a 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -32,6 +32,7 @@ #include "SDL.h" #ifdef _MSC_VER +#include #pragma warning(default : 4214 4244) #endif