From 3d5d02fc15197eac5a663f5c79db21ff88cae5a4 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 3 Mar 2019 19:58:01 -0500 Subject: [PATCH 01/26] Error if the lump is a PNG lump --- src/w_wad.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/w_wad.c b/src/w_wad.c index 88e89974a..9ca4e0ff0 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1175,6 +1175,29 @@ void zerr(int ret) } #endif +#define NO_PNG_LUMPS + +#ifdef NO_PNG_LUMPS +static void ErrorIfPNG(void *d, size_t s, char *f, char *l) +{ + if (s < 67) // http://garethrees.org/2007/11/14/pngcrush/ + return; +#define sigcheck ((UINT8 *)d) + if (sigcheck[0] == 0x89 + && sigcheck[1] == 0x50 + && sigcheck[2] == 0x4e + && sigcheck[3] == 0x47 + && sigcheck[4] == 0x0d + && sigcheck[5] == 0x0a + && sigcheck[6] == 0x1a + && sigcheck[7] == 0x0a) + { + I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .PNG - please convert to either Doom or Flat (raw) image format.", l, f); + } +#undef sigcheck +} +#endif + /** Reads bytes from the head of a lump. * Note: If the lump is compressed, the whole thing has to be read anyway. * @@ -1214,7 +1237,15 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si switch(wadfiles[wad]->lumpinfo[lump].compression) { case CM_NOCOMPRESSION: // If it's uncompressed, we directly write the data into our destination, and return the bytes read. +#ifdef NO_PNG_LUMPS + { + size_t bytesread = fread(dest, 1, size, handle); + ErrorIfPNG(dest, bytesread, wadfiles[wad]->filename, l->name2); + return bytesread; + } +#else return fread(dest, 1, size, handle); +#endif case CM_LZF: // Is it LZF compressed? Used by ZWADs. { #ifdef ZWAD @@ -1249,11 +1280,15 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si M_Memcpy(dest, decData + offset, size); Z_Free(rawData); Z_Free(decData); +#ifdef NO_PNG_LUMPS + ErrorIfPNG(dest, size, wadfiles[wad]->filename, l->name2); +#endif return size; #else //I_Error("ZWAD files not supported on this platform."); return 0; #endif + } #ifdef HAVE_ZLIB case CM_DEFLATE: // Is it compressed via DEFLATE? Very common in ZIPs/PK3s, also what most doom-related editors support. @@ -1307,6 +1342,9 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si Z_Free(rawData); Z_Free(decData); +#ifdef NO_PNG_LUMPS + ErrorIfPNG(dest, size, wadfiles[wad]->filename, l->name2); +#endif return size; } #endif From 15323328c5659ebee4c5b740c52b1968167e0f56 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 3 Mar 2019 22:43:21 -0500 Subject: [PATCH 02/26] Check using memcmp() --- src/w_wad.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 9ca4e0ff0..b5aa95fac 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1183,14 +1183,10 @@ static void ErrorIfPNG(void *d, size_t s, char *f, char *l) if (s < 67) // http://garethrees.org/2007/11/14/pngcrush/ return; #define sigcheck ((UINT8 *)d) - if (sigcheck[0] == 0x89 - && sigcheck[1] == 0x50 - && sigcheck[2] == 0x4e - && sigcheck[3] == 0x47 - && sigcheck[4] == 0x0d - && sigcheck[5] == 0x0a - && sigcheck[6] == 0x1a - && sigcheck[7] == 0x0a) + // Check for PNG file signature using memcmp + // As it may be faster on CPUs with slow unaligned memory access + // Ref: http://www.libpng.org/pub/png/spec/1.2/PNG-Rationale.html#R.PNG-file-signature + if (memcmp(&sigcheck[0], "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", 8) == 0) { I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .PNG - please convert to either Doom or Flat (raw) image format.", l, f); } From 9542a47f7fee56f6078b9973233b911370476ef3 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 3 Mar 2019 22:57:09 -0500 Subject: [PATCH 03/26] New -noxinput and -nohidapi command line parameters. --- src/sdl/i_system.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index b5597784e..517c183ee 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1402,7 +1402,13 @@ static int joy_open2(const char *fname) void I_InitJoystick(void) { I_ShutdownJoystick(); - SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); + + if (M_CheckParm("-noxinput")) + SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); + + if (M_CheckParm("-nohidapi")) + SDL_SetHintWithPriority("SDL_JOYSTICK_HIDAPI", "0", SDL_HINT_OVERRIDE); + if (!strcmp(cv_usejoystick.string, "0") || M_CheckParm("-nojoy")) return; if (joy_open(cv_usejoystick.string) != -1) @@ -1418,7 +1424,13 @@ void I_InitJoystick(void) void I_InitJoystick2(void) { I_ShutdownJoystick2(); - SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); + + if (M_CheckParm("-noxinput")) + SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); + + if (M_CheckParm("-nohidapi")) + SDL_SetHintWithPriority("SDL_JOYSTICK_HIDAPI", "0", SDL_HINT_OVERRIDE); + if (!strcmp(cv_usejoystick2.string, "0") || M_CheckParm("-nojoy")) return; if (joy_open2(cv_usejoystick2.string) != -1) From 6d751ff30257ce2f24b8f1aadb848438786b2949 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Fri, 15 Mar 2019 18:46:25 -0400 Subject: [PATCH 04/26] Remove the define. --- src/w_wad.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 4f0142081..c4f9ceca8 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1182,19 +1182,17 @@ void zerr(int ret) #define NO_PNG_LUMPS #ifdef NO_PNG_LUMPS -static void ErrorIfPNG(void *d, size_t s, char *f, char *l) +static void ErrorIfPNG(UINT8 *d, size_t s, char *f, char *l) { if (s < 67) // http://garethrees.org/2007/11/14/pngcrush/ return; -#define sigcheck ((UINT8 *)d) // Check for PNG file signature using memcmp // As it may be faster on CPUs with slow unaligned memory access // Ref: http://www.libpng.org/pub/png/spec/1.2/PNG-Rationale.html#R.PNG-file-signature - if (memcmp(&sigcheck[0], "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", 8) == 0) + if (memcmp(&d[0], "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", 8) == 0) { I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .PNG - please convert to either Doom or Flat (raw) image format.", l, f); } -#undef sigcheck } #endif From d03c53930bfa9f0265ec27223a6a4baa20bb0a73 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 18 Mar 2019 16:50:17 -0400 Subject: [PATCH 05/26] Update CMakeLists.txt, remove CMAKE_SIZEOF_VOID_P check --- CMakeLists.txt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6eb065d04..11898db5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,14 +54,6 @@ macro(copy_files_to_build_dir target dlllist_var) endif() endmacro() -# 64-bit check -if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - message(STATUS "Target is 64-bit") - set(SRB2_SYSTEM_BITS 64) -else() - set(SRB2_SYSTEM_BITS 32) -endif() - # OS macros if (UNIX) add_definitions(-DUNIXCOMMON) @@ -73,9 +65,6 @@ endif() if(${CMAKE_SYSTEM} MATCHES "Linux") add_definitions(-DLINUX) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - add_definitions(-DLINUX64) - endif() endif() if(${CMAKE_SYSTEM} MATCHES "Darwin") From 2fb569857a75571c27b02ffe0230da43cb456312 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 18 Mar 2019 22:00:23 +0000 Subject: [PATCH 06/26] Added the Gametype_Names array and G_GetGametypeByName for ease in converting gametype nums to strings and vice versa gametype_cons_t is now initialised using the Gametype_Names array, like how Color_cons_t is initialised using Color_Names # Conflicts: # src/doomstat.h # src/m_menu.c --- src/d_clisrv.c | 12 ++------ src/d_main.c | 10 ++----- src/d_netcmd.c | 76 +++++++++++++++++++++----------------------------- src/doomstat.h | 5 +++- src/g_game.c | 32 +++++++++++++++++++++ src/g_game.h | 1 + src/hu_stuff.c | 22 +++++++-------- src/m_menu.c | 27 ++++-------------- 8 files changed, 90 insertions(+), 95 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a0f9f40ab..31fec14fa 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2056,17 +2056,11 @@ static void CL_ConnectToServer(boolean viams) if (i != -1) { - INT32 j; + UINT8 num = serverlist[i].info.gametype; const char *gametypestr = NULL; CONS_Printf(M_GetText("Connecting to: %s\n"), serverlist[i].info.servername); - for (j = 0; gametype_cons_t[j].strvalue; j++) - { - if (gametype_cons_t[j].value == serverlist[i].info.gametype) - { - gametypestr = gametype_cons_t[j].strvalue; - break; - } - } + if (num < NUMGAMETYPES) + gametypestr = Gametype_Names[num]; if (gametypestr) CONS_Printf(M_GetText("Gametype: %s\n"), gametypestr); CONS_Printf(M_GetText("Version: %d.%d.%u\n"), serverlist[i].info.version/100, diff --git a/src/d_main.c b/src/d_main.c index 1782e94f5..527031fa8 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1362,13 +1362,9 @@ void D_SRB2Main(void) INT16 newgametype = -1; const char *sgametype = M_GetNextParm(); - for (j = 0; gametype_cons_t[j].strvalue; j++) - if (!strcasecmp(gametype_cons_t[j].strvalue, sgametype)) - { - newgametype = (INT16)gametype_cons_t[j].value; - break; - } - if (!gametype_cons_t[j].strvalue) // reached end of the list with no match + newgametype = G_GetGametypeByName(sgametype); + + if (newgametype == -1) // reached end of the list with no match { j = atoi(sgametype); // assume they gave us a gametype number, which is okay too if (j >= 0 && j < NUMGAMETYPES) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 11b9413a8..71ec55de2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -409,6 +409,16 @@ const char *netxcmdnames[MAXNETXCMD - 1] = */ void D_RegisterServerCommands(void) { + INT32 i; + + for (i = 0; i < NUMGAMETYPES; i++) + { + gametype_cons_t[i].value = i; + gametype_cons_t[i].strvalue = Gametype_Names[i]; + } + gametype_cons_t[NUMGAMETYPES].value = 0; + gametype_cons_t[NUMGAMETYPES].strvalue = NULL; + RegisterNetXCmd(XD_NAMEANDCOLOR, Got_NameAndColor); RegisterNetXCmd(XD_WEAPONPREF, Got_WeaponPref); RegisterNetXCmd(XD_MAP, Got_Mapcmd); @@ -1639,7 +1649,7 @@ static void Command_Map_f(void) { const char *mapname; size_t i; - INT32 j, newmapnum; + INT32 newmapnum; boolean newresetplayers; INT32 newgametype = gametype; @@ -1707,27 +1717,13 @@ static void Command_Map_f(void) return; } - for (j = 0; gametype_cons_t[j].strvalue; j++) - if (!strcasecmp(gametype_cons_t[j].strvalue, COM_Argv(i+1))) - { - // Don't do any variable setting here. Wait until you get your - // map packet first to avoid sending the same info twice! - newgametype = gametype_cons_t[j].value; + newgametype = G_GetGametypeByName(COM_Argv(i+1)); - break; - } - - if (!gametype_cons_t[j].strvalue) // reached end of the list with no match + if (newgametype == -1) // reached end of the list with no match { - // assume they gave us a gametype number, which is okay too - for (j = 0; gametype_cons_t[j].strvalue != NULL; j++) - { - if (atoi(COM_Argv(i+1)) == gametype_cons_t[j].value) - { - newgametype = gametype_cons_t[j].value; - break; - } - } + INT32 j = atoi(COM_Argv(i+1)); // assume they gave us a gametype number, which is okay too + if (j >= 0 && j < NUMGAMETYPES) + newgametype = (INT16)j; } } @@ -1742,12 +1738,11 @@ static void Command_Map_f(void) char gametypestring[32] = "Single Player"; if (multiplayer) - for (i = 0; gametype_cons_t[i].strvalue != NULL; i++) - if (gametype_cons_t[i].value == newgametype) - { - strcpy(gametypestring, gametype_cons_t[i].strvalue); - break; - } + { + if (newgametype >= 0 && newgametype < NUMGAMETYPES + && Gametype_Names[newgametype]) + strcpy(gametypestring, Gametype_Names[newgametype]); + } CONS_Alert(CONS_WARNING, M_GetText("%s doesn't support %s mode!\n(Use -force to override)\n"), mapname, gametypestring); return; @@ -3486,7 +3481,6 @@ static void Command_ModDetails_f(void) // static void Command_ShowGametype_f(void) { - INT32 j; const char *gametypestr = NULL; if (!(netgame || multiplayer)) // print "Single player" instead of "Co-op" @@ -3494,15 +3488,11 @@ static void Command_ShowGametype_f(void) CONS_Printf(M_GetText("Current gametype is %s\n"), M_GetText("Single player")); return; } - // find name string for current gametype - for (j = 0; gametype_cons_t[j].strvalue; j++) - { - if (gametype_cons_t[j].value == gametype) - { - gametypestr = gametype_cons_t[j].strvalue; - break; - } - } + + // get name string for current gametype + if (gametype >= 0 && gametype < NUMGAMETYPES) + gametypestr = Gametype_Names[gametype]; + if (gametypestr) CONS_Printf(M_GetText("Current gametype is %s\n"), gametypestr); else // string for current gametype was not found above (should never happen) @@ -3644,15 +3634,13 @@ void D_GameTypeChanged(INT32 lastgametype) { if (netgame) { - INT32 j; const char *oldgt = NULL, *newgt = NULL; - for (j = 0; gametype_cons_t[j].strvalue; j++) - { - if (gametype_cons_t[j].value == lastgametype) - oldgt = gametype_cons_t[j].strvalue; - if (gametype_cons_t[j].value == gametype) - newgt = gametype_cons_t[j].strvalue; - } + + if (lastgametype >= 0 && lastgametype < NUMGAMETYPES) + oldgt = Gametype_Names[lastgametype]; + if (gametype >= 0 && lastgametype < NUMGAMETYPES) + newgt = Gametype_Names[gametype]; + if (oldgt && newgt) CONS_Printf(M_GetText("Gametype was changed from %s to %s\n"), oldgt, newgt); } diff --git a/src/doomstat.h b/src/doomstat.h index d9132798f..8050a1beb 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -318,7 +318,10 @@ enum GameType NUMGAMETYPES }; -// If you alter this list, update gametype_cons_t in m_menu.c +// If you alter this list, update dehacked.c, and Gametype_Names in g_game.c + +// String names for gametypes +extern const char *Gametype_Names[NUMGAMETYPES]; extern tic_t totalplaytime; diff --git a/src/g_game.c b/src/g_game.c index c0cb469a1..f9477f91e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2698,6 +2698,38 @@ void G_ExitLevel(void) } } +// See also the enum GameType in doomstat.h +const char *Gametype_Names[NUMGAMETYPES] = +{ + "Co-op", // GT_COOP + "Competition", // GT_COMPETITION + "Race", // GT_RACE + + "Match", // GT_MATCH + "Team Match", // GT_TEAMMATCH + + "Tag", // GT_TAG + "Hide and Seek", // GT_HIDEANDSEEK + + "CTF" // GT_CTF +}; + +// +// G_GetGametypeByName +// +// Returns the number for the given gametype name string, or -1 if not valid. +// +INT32 G_GetGametypeByName(const char *gametypestr) +{ + INT32 i; + + for (i = 0; i < NUMGAMETYPES; i++) + if (!stricmp(gametypestr, Gametype_Names[i])) + return i; + + return -1; // unknown gametype +} + // // G_IsSpecialStage // diff --git a/src/g_game.h b/src/g_game.h index 5259eacbb..87ddb3103 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -163,6 +163,7 @@ ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void); void G_StopDemo(void); boolean G_CheckDemoStatus(void); +INT32 G_GetGametypeByName(const char *gametypestr); boolean G_IsSpecialStage(INT32 mapnum); boolean G_GametypeUsesLives(void); boolean G_GametypeHasTeams(void); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index e34e5c35c..f624e39de 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1952,19 +1952,17 @@ static void HU_DrawCEcho(void) static void HU_drawGametype(void) { - INT32 i = 0; + const char *strvalue = NULL; - for (i = 0; gametype_cons_t[i].strvalue; i++) - { - if (gametype_cons_t[i].value == gametype) - { - if (splitscreen) - V_DrawString(4, 184, 0, gametype_cons_t[i].strvalue); - else - V_DrawString(4, 192, 0, gametype_cons_t[i].strvalue); - return; - } - } + if (gametype < 0 || gametype >= NUMGAMETYPES) + return; // not a valid gametype??? + + strvalue = Gametype_Names[gametype]; + + if (splitscreen) + V_DrawString(4, 184, 0, strvalue); + else + V_DrawString(4, 192, 0, strvalue); } // diff --git a/src/m_menu.c b/src/m_menu.c index 65647d2a6..a833ace21 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -347,23 +347,9 @@ static CV_PossibleValue_t skins_cons_t[MAXSKINS+1] = {{1, DEFAULTSKIN}}; consvar_t cv_chooseskin = {"chooseskin", DEFAULTSKIN, CV_HIDEN|CV_CALL, skins_cons_t, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; // This gametype list is integral for many different reasons. -// When you add gametypes here, don't forget to update them in CV_AddValue! -CV_PossibleValue_t gametype_cons_t[] = -{ - {GT_COOP, "Co-op"}, +// When you add gametypes here, don't forget to update them in dehacked.c and doomstat.h! +CV_PossibleValue_t gametype_cons_t[NUMGAMETYPES+1]; - {GT_COMPETITION, "Competition"}, - {GT_RACE, "Race"}, - - {GT_MATCH, "Match"}, - {GT_TEAMMATCH, "Team Match"}, - - {GT_TAG, "Tag"}, - {GT_HIDEANDSEEK, "Hide and Seek"}, - - {GT_CTF, "CTF"}, - {0, NULL} -}; consvar_t cv_newgametype = {"newgametype", "Co-op", CV_HIDEN|CV_CALL, gametype_cons_t, Newgametype_OnChange, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t serversort_cons_t[] = { @@ -6545,7 +6531,7 @@ static void M_DrawRoomMenu(void) static void M_DrawConnectMenu(void) { - UINT16 i, j; + UINT16 i; const char *gt = "Unknown"; INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE; @@ -6591,11 +6577,8 @@ static void M_DrawConnectMenu(void) va("Ping: %u", (UINT32)LONG(serverlist[slindex].info.time))); gt = "Unknown"; - for (j = 0; gametype_cons_t[j].strvalue; j++) - { - if (gametype_cons_t[j].value == serverlist[slindex].info.gametype) - gt = gametype_cons_t[j].strvalue; - } + if (serverlist[slindex].info.gametype < NUMGAMETYPES) + gt = Gametype_Names[serverlist[slindex].info.gametype]; V_DrawSmallString(currentMenu->x+46,S_LINEY(i)+8, globalflags, va("Players: %02d/%02d", serverlist[slindex].info.numberofplayer, serverlist[slindex].info.maxplayer)); From 6142becb4d88e638326c136982e6191aaa6a137d Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 18 Mar 2019 23:58:31 -0400 Subject: [PATCH 07/26] Revert "Update CMakeLists.txt, remove CMAKE_SIZEOF_VOID_P check" This reverts commit d03c53930bfa9f0265ec27223a6a4baa20bb0a73. --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11898db5c..6eb065d04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,14 @@ macro(copy_files_to_build_dir target dlllist_var) endif() endmacro() +# 64-bit check +if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + message(STATUS "Target is 64-bit") + set(SRB2_SYSTEM_BITS 64) +else() + set(SRB2_SYSTEM_BITS 32) +endif() + # OS macros if (UNIX) add_definitions(-DUNIXCOMMON) @@ -65,6 +73,9 @@ endif() if(${CMAKE_SYSTEM} MATCHES "Linux") add_definitions(-DLINUX) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + add_definitions(-DLINUX64) + endif() endif() if(${CMAKE_SYSTEM} MATCHES "Darwin") From 49dddf54ab4ee6ad41dd5c3b00d2f4af33cd9fe8 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Tue, 19 Mar 2019 00:04:14 -0400 Subject: [PATCH 08/26] CMake: check if CMAKE_SIZEOF_VOID_P is defined on Mac? --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6eb065d04..75aa82f32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,8 @@ macro(copy_files_to_build_dir target dlllist_var) endmacro() # 64-bit check -if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) +message(STATUS "CMAKE_SIZEOF_VOID_P=" ${CMAKE_SIZEOF_VOID_P}) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) message(STATUS "Target is 64-bit") set(SRB2_SYSTEM_BITS 64) else() From 1c55daef2a5612bca39d47d490f82987cface0a9 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Tue, 19 Mar 2019 09:10:25 -0400 Subject: [PATCH 09/26] CMake: have funny check for empty CMAKE_SIZEOF_VOID_P --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75aa82f32..0a5507b92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,14 +54,19 @@ macro(copy_files_to_build_dir target dlllist_var) endif() endmacro() -# 64-bit check -message(STATUS "CMAKE_SIZEOF_VOID_P=" ${CMAKE_SIZEOF_VOID_P}) +# bitness check +set(SRB2_SYSTEM_BITS 0) if(CMAKE_SIZEOF_VOID_P EQUAL 8) message(STATUS "Target is 64-bit") set(SRB2_SYSTEM_BITS 64) -else() +endif() +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + message(STATUS "Target is 32-bit") set(SRB2_SYSTEM_BITS 32) endif() +if(${SRB2_SYSTEM_BITS} EQUAL 0) + message(STATUS "Target bitness is unknown") +endif() # OS macros if (UNIX) From f139ffd1dc6c757806c506f0925f2b5a612ab475 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 20 Mar 2019 19:20:34 -0700 Subject: [PATCH 10/26] Let localhost connections --- src/i_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index f8a65b754..37e355579 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -612,7 +612,7 @@ static boolean SOCK_Get(void) if (c != ERRSOCKET) { // find remote node number - for (j = 0; j <= MAXNETNODES; j++) //include LAN + for (j = 1; j <= MAXNETNODES; j++) //include LAN { if (SOCK_cmpaddr(&fromaddress, &clientaddress[j], 0)) { From ed0f8fd96765fec8ac9b6407db7118669b07ddde Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 20 Mar 2019 20:05:45 -0700 Subject: [PATCH 11/26] Actually allow connecting to "localhost" Because IPv6 doesn't seem to work anyway. --- src/i_tcp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 37e355579..11a84ceba 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1340,8 +1340,12 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port) while (runp != NULL) { // find ip of the server - memcpy(&clientaddress[newnode], runp->ai_addr, runp->ai_addrlen); - runp = NULL; + if (sendto(mysockets[0], NULL, 0, 0, runp->ai_addr, runp->ai_addrlen) == 0) + { + memcpy(&clientaddress[newnode], runp->ai_addr, runp->ai_addrlen); + break; + } + runp = runp->ai_next; } I_freeaddrinfo(ai); return newnode; From 147221cf6e67f8d0a4260a265127030efbd880b3 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 25 Mar 2019 18:54:47 +0000 Subject: [PATCH 12/26] R_RenderThickSideRange: clamp lights that fail overflow test, rather than skipping them. --- src/r_segs.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 748365264..7495d7889 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -862,16 +862,18 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) leftheight -= viewz; rightheight -= viewz; -#define OVERFLOWTEST(height, scale) \ - overflow_test = (INT64)centeryfrac - (((INT64)height*scale)>>FRACBITS); \ - if (overflow_test < 0) overflow_test = -overflow_test; \ - if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue; +#define CLAMPMAX INT32_MAX +#define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out. + // Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave. + overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS); + if (overflow_test > (INT64)CLAMPMAX) rlight->height = CLAMPMAX; + else if (overflow_test > (INT64)CLAMPMIN) rlight->height = (fixed_t)overflow_test; + else rlight->height = CLAMPMIN; - OVERFLOWTEST(leftheight, ds->scale1) - OVERFLOWTEST(rightheight, ds->scale2) - - rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1); - rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); + overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS); + if (overflow_test > (INT64)CLAMPMAX) rlight->heightstep = CLAMPMAX; + else if (overflow_test > (INT64)CLAMPMIN) rlight->heightstep = (fixed_t)overflow_test; + else rlight->heightstep = CLAMPMIN; rlight->heightstep = (rlight->heightstep-rlight->height)/(range); #else if (light->height < *pfloor->bottomheight) @@ -893,12 +895,16 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) leftheight -= viewz; rightheight -= viewz; - OVERFLOWTEST(leftheight, ds->scale1) - OVERFLOWTEST(rightheight, ds->scale2) -#undef OVERFLOWTEST + // Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave. + overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS); + if (overflow_test > (INT64)CLAMPMAX) rlight->botheight = CLAMPMAX; + else if (overflow_test > (INT64)CLAMPMIN) rlight->botheight = (fixed_t)overflow_test; + else rlight->botheight = CLAMPMIN; - rlight->botheight = (centeryfrac) - FixedMul(leftheight, ds->scale1); - rlight->botheightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); + overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS); + if (overflow_test > (INT64)CLAMPMAX) rlight->botheightstep = CLAMPMAX; + else if (overflow_test > (INT64)CLAMPMIN) rlight->botheightstep = (fixed_t)overflow_test; + else rlight->botheightstep = CLAMPMIN; rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range); #else lheight = *light->caster->bottomheight;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : *light->caster->bottomheight; @@ -1071,9 +1077,6 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) } #endif -#define CLAMPMAX INT32_MAX -#define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out. - // draw the columns for (dc_x = x1; dc_x <= x2; dc_x++) { From 9a8d36b822839252059701dd4824d3fbafe45e04 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:16:43 -0400 Subject: [PATCH 13/26] Travis-CI: use a new version of xcode and use homebrew add-on to install packages --- .travis.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4bfc58860..07640f837 100644 --- a/.travis.yml +++ b/.travis.yml @@ -222,7 +222,16 @@ matrix: # osx_image: xcode7.2 # #Apple LLVM version 7.0.2 (clang-700.1.81) - os: osx - osx_image: xcode7.3 + #osx_image: xcode7.3 + addons: + homebrew: + packages: + - sdl2 + - sdl2_mixer + - game-music-emu + - p7zip + - cmake + update: false #Apple LLVM version 7.3.0 (clang-703.0.31) allow_failures: - compiler: clang-3.5 @@ -258,9 +267,6 @@ before_script: - cmake .. -DCMAKE_BUILD_TYPE=Release before_install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2 sdl2_mixer game-music-emu p7zip; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install cmake||true; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.6.dmg; hdiutil attach SDL2-2.0.6.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg; hdiutil attach SDL2_mixer-2.0.1.dmg; sudo cp -a /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks/; fi - mkdir -p $HOME/srb2_cache From c4e8a601127d205ff9b36e26cf8b2b61a911700c Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:21:52 -0400 Subject: [PATCH 14/26] CircleCI: also test compiling without BLUA support --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c3674a9e5..e5892b7c7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -43,8 +43,8 @@ jobs: - /var/cache/apt/archives - checkout - run: - name: Compile without network support - command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1 + name: Compile without network support and BLUA + command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1 NO_LUA=1 - run: name: Clean build command: make -C src LINUX=1 clean From fe22fdc5a36fb2769ee83b880a873aa6375a6319 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:30:25 -0400 Subject: [PATCH 15/26] P_SuperDamage() is too big for inlining --- src/p_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_inter.c b/src/p_inter.c index 009a2be1f..29450f6e1 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2643,7 +2643,7 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage) } } -static inline void P_SuperDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) +static void P_SuperDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) { fixed_t fallbackspeed; angle_t ang; From a8681a5b7262d013daea99250139e28d0884b4c6 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:34:25 -0400 Subject: [PATCH 16/26] CircleCI: rebuild depend file with BLUA --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e5892b7c7..1b0cf3407 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -46,7 +46,10 @@ jobs: name: Compile without network support and BLUA command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1 NO_LUA=1 - run: - name: Clean build + name: wipe build + command: make -C src LINUX=1 cleandep + - run: + name: rebuild depend command: make -C src LINUX=1 clean - restore_cache: keys: From 3ab0f675ecbe0d9a79ed4a0cb39c2f7903dba457 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:44:33 -0400 Subject: [PATCH 17/26] TravisCI: move homebrew packages for all mac builds --- .travis.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 07640f837..78a0a30dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -223,15 +223,6 @@ matrix: # #Apple LLVM version 7.0.2 (clang-700.1.81) - os: osx #osx_image: xcode7.3 - addons: - homebrew: - packages: - - sdl2 - - sdl2_mixer - - game-music-emu - - p7zip - - cmake - update: false #Apple LLVM version 7.3.0 (clang-703.0.31) allow_failures: - compiler: clang-3.5 @@ -256,6 +247,14 @@ addons: - libgl1-mesa-dev - libgme-dev - p7zip-full + homebrew: + packages: + - sdl2_mixer + - game-music-emu + - p7zip + - cmake + update: false + before_script: - wget --verbose --server-response -c http://rosenthalcastle.org/srb2/SRB2-v2115-assets-2.7z -O $HOME/srb2_cache/SRB2-v2115-assets-2.7z From 594c906376293942a73ef43ef70b13f421420512 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:48:33 -0400 Subject: [PATCH 18/26] use default osx image --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78a0a30dc..f0ed0a8ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -221,9 +221,11 @@ matrix: # - os: osx # osx_image: xcode7.2 # #Apple LLVM version 7.0.2 (clang-700.1.81) +# - os: osx +# osx_image: xcode7.3 +# #Apple LLVM version 7.3.0 (clang-703.0.31) - os: osx - #osx_image: xcode7.3 - #Apple LLVM version 7.3.0 (clang-703.0.31) + #Default: macOS 10.13 and Xcode 9.4.1 allow_failures: - compiler: clang-3.5 - compiler: clang-3.6 From 3472bf857cab6238fcd9d77013ea97517df48967 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:51:13 -0400 Subject: [PATCH 19/26] TravisCI: build custom sdl2_mixer build --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f0ed0a8ec..7ef0127b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -251,7 +251,7 @@ addons: - p7zip-full homebrew: packages: - - sdl2_mixer + - sdl2 - game-music-emu - p7zip - cmake @@ -268,6 +268,7 @@ before_script: - cmake .. -DCMAKE_BUILD_TYPE=Release before_install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2_mixer; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.6.dmg; hdiutil attach SDL2-2.0.6.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg; hdiutil attach SDL2_mixer-2.0.1.dmg; sudo cp -a /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks/; fi - mkdir -p $HOME/srb2_cache From ec0afaf6c9706760428df566af790de9a9ebefe3 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 16:02:30 -0400 Subject: [PATCH 20/26] TravisCI: try updating homebew --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7ef0127b8..db81b9d91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -255,7 +255,7 @@ addons: - game-music-emu - p7zip - cmake - update: false + update: true before_script: From 9de5055d7fadebee347fd2af173c7e97e33b35ae Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 16:30:02 -0400 Subject: [PATCH 21/26] TravisCI: install deps on sdl2_mixer --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index db81b9d91..252abe0f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -251,6 +251,9 @@ addons: - p7zip-full homebrew: packages: + - libmodplug + - liboog + - libvorbis - sdl2 - game-music-emu - p7zip From fd284f232e09562505a110817481100fabf2aaf7 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 16:43:33 -0400 Subject: [PATCH 22/26] travisCI: add sdl2_mixer from mazmazz's srb2 tap --- .travis.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 252abe0f1..b723f44e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -250,11 +250,10 @@ addons: - libgme-dev - p7zip-full homebrew: + taps: + - mazmazz/srb2 packages: - - libmodplug - - liboog - - libvorbis - - sdl2 + - mazmazz/srb2/sdl2_mixer - game-music-emu - p7zip - cmake @@ -271,7 +270,6 @@ before_script: - cmake .. -DCMAKE_BUILD_TYPE=Release before_install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2_mixer; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.6.dmg; hdiutil attach SDL2-2.0.6.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg; hdiutil attach SDL2_mixer-2.0.1.dmg; sudo cp -a /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks/; fi - mkdir -p $HOME/srb2_cache From 73fa35baf0255a9b9fefbc8256206f8c6964e077 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 16:59:47 -0400 Subject: [PATCH 23/26] TravisCI: use stock sdl2_mixer for prebuild bottle --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b723f44e3..15a3c844c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -253,7 +253,7 @@ addons: taps: - mazmazz/srb2 packages: - - mazmazz/srb2/sdl2_mixer + - sdl2_mixer - game-music-emu - p7zip - cmake From 8c1c0875a2f8dd545920cf7dc7c9bd59af2d43ae Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 25 Mar 2019 21:35:04 +0000 Subject: [PATCH 24/26] Fix credits gamestate in dedicated mode, by properly separating the timer variable code from the drawing code in a semi-hacky way --- src/f_finale.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 64e371211..bcdac295a 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1192,16 +1192,34 @@ void F_CreditDrawer(void) if (FixedMul(y,vid.dupy) > vid.height) break; } +} +void F_CreditTicker(void) +{ + // "Simulate" the drawing of the credits so that dedicated mode doesn't get stuck + UINT16 i; + fixed_t y = (80< vid.height) + break; + } + + // Do this here rather than in the drawer you doofus! (this is why dedicated mode broke at credits) if (!credits[i] && y <= 120< Date: Wed, 27 Mar 2019 18:23:03 -0400 Subject: [PATCH 25/26] CircleCI: Debian Jessie is dead, long live Debian Stretch --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1b0cf3407..74e360255 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ jobs: build: working_directory: /root/SRB2 docker: - - image: debian:jessie + - image: debian:stretch environment: CC: ccache gcc -m32 PKG_CONFIG_LIBDIR: /usr/lib/i386-linux-gnu/pkgconfig From 4d34841a532a974cbc33ab026ec7820bd7055162 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Wed, 27 Mar 2019 18:51:20 -0400 Subject: [PATCH 26/26] CircleCI: use libpng-dev --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 74e360255..1784ba1ea 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -36,7 +36,7 @@ jobs: - v1-SRB2-APT - run: name: Install SDK - command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng12-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 gettext ccache wget gcc-multilib upx openssh-client + command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 gettext ccache wget gcc-multilib upx openssh-client - save_cache: key: v1-SRB2-APT paths: