From c703bc2fd7823c170ec5c40e7f89b40b8c6b2c80 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 6 Aug 2018 22:37:44 +0100 Subject: [PATCH 01/52] Trim off any extra null bytes off the end of sector floorpic/ceiling when you access them in Lua --- src/lua_maplib.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 208aebe3..4e9dbd5a 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -327,6 +327,7 @@ static int sector_get(lua_State *L) { sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); enum sector_e field = luaL_checkoption(L, 2, sector_opt[0], sector_opt); + INT16 i; if (!sector) { @@ -349,11 +350,23 @@ static int sector_get(lua_State *L) lua_pushfixed(L, sector->ceilingheight); return 1; case sector_floorpic: // floorpic - lua_pushlstring(L, levelflats[sector->floorpic].name, 8); + { + levelflat_t *levelflat = &levelflats[sector->floorpic]; + for (i = 0; i < 8; i++) + if (!levelflat->name[i]) + break; + lua_pushlstring(L, levelflat->name, i); return 1; + } case sector_ceilingpic: // ceilingpic - lua_pushlstring(L, levelflats[sector->ceilingpic].name, 8); + { + levelflat_t *levelflat = &levelflats[sector->ceilingpic]; + for (i = 0; i < 8; i++) + if (!levelflat->name[i]) + break; + lua_pushlstring(L, levelflat->name, i); return 1; + } case sector_lightlevel: lua_pushinteger(L, sector->lightlevel); return 1; From 710550bb9dc3332e20dc3849161d6c1296b68d0e Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 26 Aug 2018 12:38:53 +0100 Subject: [PATCH 02/52] Missed one! --- src/v_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_video.c b/src/v_video.c index 7541402a..aa2852c0 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -470,7 +470,7 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t { // same thing here if ((scrn & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) - y += (vid.height/2 - (BASEVIDHEIGHT/2 * dupy)) * vid.width; + y += (vid.height/2 - (BASEVIDHEIGHT/2 * dupy)); else if (scrn & V_SNAPTOBOTTOM) y += (vid.height - (BASEVIDHEIGHT * dupy)); else if (!(scrn & V_SNAPTOTOP)) From 0f5d685d1f61c3db55b820dc56f3c46f4b2fecc8 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 30 Aug 2018 18:32:26 -0400 Subject: [PATCH 03/52] Only do this if the admin player isn't the server host also. --- src/d_netcmd.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index bf26ca61..74212400 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2697,6 +2697,12 @@ static void Command_Login_f(void) XBOXSTATIC UINT8 finalmd5[16]; const char *pw; + if (!netgame) + { + CONS_Printf(M_GetText("This only works in a netgame.\n")); + return; + } + // If the server uses login, it will effectively just remove admin privileges // from whoever has them. This is good. if (COM_Argc() != 2) @@ -2764,6 +2770,12 @@ static void Command_Verify_f(void) return; } + if (!netgame) + { + CONS_Printf(M_GetText("This only works in a netgame.\n")); + return; + } + if (COM_Argc() != 2) { CONS_Printf(M_GetText("verify : give admin privileges to a node\n")); @@ -3075,7 +3087,7 @@ static void Command_Addfile(void) WRITEMEM(buf_p, md5sum, 16); } - if (adminplayer == consoleplayer) // Request to add file + if (adminplayer == consoleplayer && (!server)) // Request to add file SendNetXCmd(XD_REQADDFILE, buf, buf_p - buf); else SendNetXCmd(XD_ADDFILE, buf, buf_p - buf); From 322da62b3c1eb9bbab46adc344100b13b8fa602b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 31 Aug 2018 17:14:44 +0100 Subject: [PATCH 04/52] Fix HOM removal not working properly for non-green resolutions --- src/r_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index e50e8001..f2a0c889 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1235,9 +1235,9 @@ void R_RenderPlayerView(player_t *player) if (cv_homremoval.value && player == &players[displayplayer]) // if this is display player 1 { if (cv_homremoval.value == 1) - V_DrawFill(0, 0, vid.width, vid.height, 31); // No HOM effect! + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // No HOM effect! else //'development' HOM removal -- makes it blindingly obvious if HOM is spotted. - V_DrawFill(0, 0, vid.width, vid.height, 128+(timeinmap&15)); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 128+(timeinmap&15)); } // load previous saved value of skyVisible for the player From 24aafa6dacaa03a73674ef049ceeae102693438f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 3 Sep 2018 15:43:36 +0100 Subject: [PATCH 05/52] UDP_Socket: Add missing limit checks for s, for client and broadcast addresses --- src/i_tcp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 6488e984..5c660666 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1044,7 +1044,7 @@ static boolean UDP_Socket(void) if (gaie == 0) { runp = ai; - while (runp != NULL) + while (runp != NULL && s < MAXNETNODES+1) { memcpy(&clientaddress[s], runp->ai_addr, runp->ai_addrlen); s++; @@ -1064,7 +1064,7 @@ static boolean UDP_Socket(void) if (gaie == 0) { runp = ai; - while (runp != NULL) + while (runp != NULL && s < MAXNETNODES+1) { memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen); s++; @@ -1087,7 +1087,7 @@ static boolean UDP_Socket(void) if (gaie == 0) { runp = ai; - while (runp != NULL) + while (runp != NULL && s < MAXNETNODES+1) { memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen); s++; From 846bddfdcf9514e8164bd1157c58ab2ac614ae8a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 3 Sep 2018 15:52:22 +0100 Subject: [PATCH 06/52] SOCK_Send: Fix what appears to be a mistaken use of i instead of j --- src/i_tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 5c660666..3b609914 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -707,10 +707,10 @@ static void SOCK_Send(void) { if (myfamily[i] == broadcastaddress[j].any.sa_family) { - if (broadcastaddress[i].any.sa_family == AF_INET) + if (broadcastaddress[j].any.sa_family == AF_INET) d = d4; #ifdef HAVE_IPV6 - else if (broadcastaddress[i].any.sa_family == AF_INET6) + else if (broadcastaddress[j].any.sa_family == AF_INET6) d = d6; #endif else From 7b083f07cd306ca8790427b0257ca1f06f7d3a3e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 3 Sep 2018 15:56:02 +0100 Subject: [PATCH 07/52] UDP_Socket: I doubt client addresses are meant to be included in the total for broadcast addresses --- src/i_tcp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/i_tcp.c b/src/i_tcp.c index 3b609914..d11be428 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1059,6 +1059,9 @@ static boolean UDP_Socket(void) clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip s++; } + + s = 0; + // setup broadcast adress to BROADCASTADDR entry gaie = I_getaddrinfo("255.255.255.255", "0", &hints, &ai); if (gaie == 0) From ea06e8a62b42d4e85112742ca668a7a6495beaf9 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 3 Sep 2018 20:53:40 +0100 Subject: [PATCH 08/52] SOCK_Send: Split the actual sending data parts into a new function, SOCK_SendToAddr, to make everything look a bit neater in general --- src/i_tcp.c | 59 ++++++++++++++++++----------------------------------- 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index d11be428..16e7bf2f 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -686,14 +686,29 @@ static boolean SOCK_CanGet(void) #endif #ifndef NONET -static void SOCK_Send(void) +static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr) { - ssize_t c = ERRSOCKET; socklen_t d4 = (socklen_t)sizeof(struct sockaddr_in); #ifdef HAVE_IPV6 socklen_t d6 = (socklen_t)sizeof(struct sockaddr_in6); #endif socklen_t d, da = (socklen_t)sizeof(mysockaddr_t); + + switch (sockaddr->any.sa_family) + { + case AF_INET: d = d4; break; +#ifdef HAVE_IPV6 + case AF_INET6: d = d6; break; +#endif + default: d = da; break; + } + + return sendto(socket, (char *)&doomcom->data, doomcom->datalength, 0, &sockaddr->any, d); +} + +static void SOCK_Send(void) +{ + ssize_t c = ERRSOCKET; size_t i, j; if (!nodeconnected[doomcom->remotenode]) @@ -706,19 +721,7 @@ static void SOCK_Send(void) for (j = 0; j < broadcastaddresses; j++) { if (myfamily[i] == broadcastaddress[j].any.sa_family) - { - if (broadcastaddress[j].any.sa_family == AF_INET) - d = d4; -#ifdef HAVE_IPV6 - else if (broadcastaddress[j].any.sa_family == AF_INET6) - d = d6; -#endif - else - d = da; - - c = sendto(mysockets[i], (char *)&doomcom->data, doomcom->datalength, 0, - &broadcastaddress[j].any, d); - } + SOCK_SendToAddr(mysockets[i], &broadcastaddress[j]); } } return; @@ -728,35 +731,13 @@ static void SOCK_Send(void) for (i = 0; i < mysocketses; i++) { if (myfamily[i] == clientaddress[doomcom->remotenode].any.sa_family) - { - if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET) - d = d4; -#ifdef HAVE_IPV6 - else if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET6) - d = d6; -#endif - else - d = da; - - sendto(mysockets[i], (char *)&doomcom->data, doomcom->datalength, 0, - &clientaddress[doomcom->remotenode].any, d); - } + SOCK_SendToAddr(mysockets[i], &clientaddress[doomcom->remotenode]); } return; } else { - if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET) - d = d4; -#ifdef HAVE_IPV6 - else if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET6) - d = d6; -#endif - else - d = da; - - c = sendto(nodesocket[doomcom->remotenode], (char *)&doomcom->data, doomcom->datalength, 0, - &clientaddress[doomcom->remotenode].any, d); + c = SOCK_SendToAddr(nodesocket[doomcom->remotenode], &clientaddress[doomcom->remotenode]); } if (c == ERRSOCKET && errno != ECONNREFUSED && errno != EWOULDBLOCK) From c0bf79ad8e8230bb315035f6be7d93d137d3d176 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 9 Sep 2018 22:48:09 +0100 Subject: [PATCH 09/52] R_CreateColormap2 and R_MakeColormaps have been made obsolete, it's just R_CreateColormap now, like it used to be! With that, I moved R_CreateColormap2's exclusive software colormap malloc code to R_CreateColormap, and merged the two software-only blocks of code into one. I also disabled any unneeded variables and fixed a preprocessor-related goofup --- src/p_setup.c | 2 +- src/r_data.c | 88 +++++++++++++++++++++++++++++++++++++++------------ src/r_data.h | 4 +-- 3 files changed, 71 insertions(+), 23 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index d8c913e0..58170e26 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2673,7 +2673,7 @@ boolean P_SetupLevel(boolean skipprecip) P_CreateBlockMap(); // Graue 02-29-2004 P_LoadSideDefs2(lastloadedmaplumpnum + ML_SIDEDEFS); - R_MakeColormaps(); + //R_MakeColormaps(); P_LoadLineDefs2(); P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS); P_LoadNodes(lastloadedmaplumpnum + ML_NODES); diff --git a/src/r_data.c b/src/r_data.c index e1d4b893..2551a294 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1038,8 +1038,8 @@ void R_ReInitColormaps(UINT16 num) static lumpnum_t foundcolormaps[MAXCOLORMAPS]; -static char colormapFixingArray[MAXCOLORMAPS][3][9]; -static size_t carrayindex; +//static char colormapFixingArray[MAXCOLORMAPS][3][9]; +//static size_t carrayindex; // // R_ClearColormaps @@ -1052,7 +1052,7 @@ void R_ClearColormaps(void) num_extra_colormaps = 0; - carrayindex = 0; + //carrayindex = 0; for (i = 0; i < MAXCOLORMAPS; i++) foundcolormaps[i] = LUMPERROR; @@ -1110,7 +1110,7 @@ static int RoundUp(double number); INT32 R_CreateColormap(char *p1, char *p2, char *p3) { double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; - double r, g, b, cbrightness, maskamt = 0, othermask = 0; + double maskamt = 0, othermask = 0; int mask, fog = 0; size_t mapnum = num_extra_colormaps; size_t i; @@ -1163,7 +1163,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) fadedist = fadeend - fadestart; fog = NUMFROMCHAR(p2[1]); } -#undef getnum +#undef NUMFROMCHAR if (p3[0] == '#') { @@ -1194,14 +1194,35 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) if (num_extra_colormaps == MAXCOLORMAPS) I_Error("R_CreateColormap: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); - strncpy(colormapFixingArray[num_extra_colormaps][0], p1, 8); - strncpy(colormapFixingArray[num_extra_colormaps][1], p2, 8); - strncpy(colormapFixingArray[num_extra_colormaps][2], p3, 8); + //strncpy(colormapFixingArray[num_extra_colormaps][0], p1, 8); + //strncpy(colormapFixingArray[num_extra_colormaps][1], p2, 8); + //strncpy(colormapFixingArray[num_extra_colormaps][2], p3, 8); num_extra_colormaps++; + foundcolormaps[mapnum] = LUMPERROR; + + // aligned on 8 bit for asm code + extra_colormaps[mapnum].colormap = NULL; + extra_colormaps[mapnum].maskcolor = (UINT16)maskcolor; + extra_colormaps[mapnum].fadecolor = (UINT16)fadecolor; + extra_colormaps[mapnum].maskamt = maskamt; + extra_colormaps[mapnum].fadestart = (UINT16)fadestart; + extra_colormaps[mapnum].fadeend = (UINT16)fadeend; + extra_colormaps[mapnum].fog = fog; + + // This code creates the colormap array used by software renderer if (rendermode == render_soft) { + double r, g, b, cbrightness; + int p; + char *colormap_p; + + // Initialise the map and delta arrays + // map[i] stores an RGB color (as double) for index i, + // which is then converted to SRB2's palette later + // deltas[i] stores a corresponding fade delta between the RGB color and the final fade color; + // map[i]'s values are decremented by after each use for (i = 0; i < 256; i++) { r = pLocalPalette[i].s.red; @@ -1224,22 +1245,48 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) map[i][2] = 255.0l; deltas[i][2] = (map[i][2] - cdestb) / (double)fadedist; } + + // Now allocate memory for the actual colormap array itself! + colormap_p = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8); + extra_colormaps[mapnum].colormap = (UINT8 *)colormap_p; + + // Calculate the palette index for each palette index, for each light level + // (as well as the two unused colormap lines we inherited from Doom) + for (p = 0; p < 34; p++) + { + for (i = 0; i < 256; i++) + { + *colormap_p = NearestColor((UINT8)RoundUp(map[i][0]), + (UINT8)RoundUp(map[i][1]), + (UINT8)RoundUp(map[i][2])); + colormap_p++; + + if ((UINT32)p < fadestart) + continue; +#define ABS2(x) ((x) < 0 ? -(x) : (x)) + if (ABS2(map[i][0] - cdestr) > ABS2(deltas[i][0])) + map[i][0] -= deltas[i][0]; + else + map[i][0] = cdestr; + + if (ABS2(map[i][1] - cdestg) > ABS2(deltas[i][1])) + map[i][1] -= deltas[i][1]; + else + map[i][1] = cdestg; + + if (ABS2(map[i][2] - cdestb) > ABS2(deltas[i][1])) + map[i][2] -= deltas[i][2]; + else + map[i][2] = cdestb; +#undef ABS2 + } + } } - foundcolormaps[mapnum] = LUMPERROR; - - // aligned on 8 bit for asm code - extra_colormaps[mapnum].colormap = NULL; - extra_colormaps[mapnum].maskcolor = (UINT16)maskcolor; - extra_colormaps[mapnum].fadecolor = (UINT16)fadecolor; - extra_colormaps[mapnum].maskamt = maskamt; - extra_colormaps[mapnum].fadestart = (UINT16)fadestart; - extra_colormaps[mapnum].fadeend = (UINT16)fadeend; - extra_colormaps[mapnum].fog = fog; - return (INT32)mapnum; } +/* void R_MakeColormaps(void) { size_t i; @@ -1310,7 +1357,7 @@ void R_CreateColormap2(char *p1, char *p2, char *p3) fadedist = fadeend - fadestart; fog = NUMFROMCHAR(p2[1]); } -#undef getnum +#undef NUMFROMCHAR if (p3[0] == '#') { @@ -1419,6 +1466,7 @@ void R_CreateColormap2(char *p1, char *p2, char *p3) return; } +*/ // Thanks to quake2 source! // utils3/qdata/images.c diff --git a/src/r_data.h b/src/r_data.h index 1e9e0eb5..c1f2a73d 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -93,8 +93,8 @@ void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); INT32 R_ColormapNumForName(char *name); INT32 R_CreateColormap(char *p1, char *p2, char *p3); -void R_CreateColormap2(char *p1, char *p2, char *p3); -void R_MakeColormaps(void); +//void R_CreateColormap2(char *p1, char *p2, char *p3); +//void R_MakeColormaps(void); const char *R_ColormapNameForNum(INT32 num); extern INT32 numtextures; From 40ff43682971987413b56721d03b5bd8a2daba9a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 10 Sep 2018 15:49:21 +0100 Subject: [PATCH 10/52] Remove commented out stuff, now I've confirmed everything works fine without them --- src/p_setup.c | 1 - src/r_data.c | 191 -------------------------------------------------- src/r_data.h | 2 - 3 files changed, 194 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 58170e26..17a6797f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2673,7 +2673,6 @@ boolean P_SetupLevel(boolean skipprecip) P_CreateBlockMap(); // Graue 02-29-2004 P_LoadSideDefs2(lastloadedmaplumpnum + ML_SIDEDEFS); - //R_MakeColormaps(); P_LoadLineDefs2(); P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS); P_LoadNodes(lastloadedmaplumpnum + ML_NODES); diff --git a/src/r_data.c b/src/r_data.c index 2551a294..f2c9b146 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1038,9 +1038,6 @@ void R_ReInitColormaps(UINT16 num) static lumpnum_t foundcolormaps[MAXCOLORMAPS]; -//static char colormapFixingArray[MAXCOLORMAPS][3][9]; -//static size_t carrayindex; - // // R_ClearColormaps // @@ -1052,8 +1049,6 @@ void R_ClearColormaps(void) num_extra_colormaps = 0; - //carrayindex = 0; - for (i = 0; i < MAXCOLORMAPS; i++) foundcolormaps[i] = LUMPERROR; @@ -1194,10 +1189,6 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) if (num_extra_colormaps == MAXCOLORMAPS) I_Error("R_CreateColormap: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); - //strncpy(colormapFixingArray[num_extra_colormaps][0], p1, 8); - //strncpy(colormapFixingArray[num_extra_colormaps][1], p2, 8); - //strncpy(colormapFixingArray[num_extra_colormaps][2], p3, 8); - num_extra_colormaps++; foundcolormaps[mapnum] = LUMPERROR; @@ -1286,188 +1277,6 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) return (INT32)mapnum; } -/* -void R_MakeColormaps(void) -{ - size_t i; - - carrayindex = num_extra_colormaps; - num_extra_colormaps = 0; - - for (i = 0; i < carrayindex; i++) - R_CreateColormap2(colormapFixingArray[i][0], colormapFixingArray[i][1], - colormapFixingArray[i][2]); -} - -void R_CreateColormap2(char *p1, char *p2, char *p3) -{ - double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; - double r, g, b, cbrightness; - double maskamt = 0, othermask = 0; - int mask, p, fog = 0; - size_t mapnum = num_extra_colormaps; - size_t i; - char *colormap_p; - UINT32 cr, cg, cb, maskcolor, fadecolor; - UINT32 fadestart = 0, fadeend = 31, fadedist = 31; - -#define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) - if (p1[0] == '#') - { - cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); - cmaskr = cr; - cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); - cmaskg = cg; - cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); - cmaskb = cb; - // Create a rough approximation of the color (a 16 bit color) - maskcolor = ((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11); - if (p1[7] >= 'a' && p1[7] <= 'z') - mask = (p1[7] - 'a'); - else if (p1[7] >= 'A' && p1[7] <= 'Z') - mask = (p1[7] - 'A'); - else - mask = 24; - - maskamt = (double)(mask/24.0l); - - othermask = 1 - maskamt; - maskamt /= 0xff; - cmaskr *= maskamt; - cmaskg *= maskamt; - cmaskb *= maskamt; - } - else - { - cmaskr = cmaskg = cmaskb = 0xff; - maskamt = 0; - maskcolor = ((0xff) >> 3) + (((0xff) >> 2) << 5) + (((0xff) >> 3) << 11); - } - -#define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) - if (p2[0] == '#') - { - // Get parameters like fadestart, fadeend, and the fogflag - fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); - fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); - if (fadestart > 30) - fadestart = 0; - if (fadeend > 31 || fadeend < 1) - fadeend = 31; - fadedist = fadeend - fadestart; - fog = NUMFROMCHAR(p2[1]); - } -#undef NUMFROMCHAR - - if (p3[0] == '#') - { - cdestr = cr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); - cdestg = cg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); - cdestb = cb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); - fadecolor = (((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11)); - } - else - cdestr = cdestg = cdestb = fadecolor = 0; -#undef HEX2INT - - for (i = 0; i < num_extra_colormaps; i++) - { - if (foundcolormaps[i] != LUMPERROR) - continue; - if (maskcolor == extra_colormaps[i].maskcolor - && fadecolor == extra_colormaps[i].fadecolor - && (float)maskamt == (float)extra_colormaps[i].maskamt - && fadestart == extra_colormaps[i].fadestart - && fadeend == extra_colormaps[i].fadeend - && fog == extra_colormaps[i].fog) - { - return; - } - } - - if (num_extra_colormaps == MAXCOLORMAPS) - I_Error("R_CreateColormap: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); - - num_extra_colormaps++; - - if (rendermode == render_soft) - { - for (i = 0; i < 256; i++) - { - r = pLocalPalette[i].s.red; - g = pLocalPalette[i].s.green; - b = pLocalPalette[i].s.blue; - cbrightness = sqrt((r*r) + (g*g) + (b*b)); - - map[i][0] = (cbrightness * cmaskr) + (r * othermask); - if (map[i][0] > 255.0l) - map[i][0] = 255.0l; - deltas[i][0] = (map[i][0] - cdestr) / (double)fadedist; - - map[i][1] = (cbrightness * cmaskg) + (g * othermask); - if (map[i][1] > 255.0l) - map[i][1] = 255.0l; - deltas[i][1] = (map[i][1] - cdestg) / (double)fadedist; - - map[i][2] = (cbrightness * cmaskb) + (b * othermask); - if (map[i][2] > 255.0l) - map[i][2] = 255.0l; - deltas[i][2] = (map[i][2] - cdestb) / (double)fadedist; - } - } - - foundcolormaps[mapnum] = LUMPERROR; - - // aligned on 8 bit for asm code - extra_colormaps[mapnum].colormap = NULL; - extra_colormaps[mapnum].maskcolor = (UINT16)maskcolor; - extra_colormaps[mapnum].fadecolor = (UINT16)fadecolor; - extra_colormaps[mapnum].maskamt = maskamt; - extra_colormaps[mapnum].fadestart = (UINT16)fadestart; - extra_colormaps[mapnum].fadeend = (UINT16)fadeend; - extra_colormaps[mapnum].fog = fog; - -#define ABS2(x) ((x) < 0 ? -(x) : (x)) - if (rendermode == render_soft) - { - colormap_p = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8); - extra_colormaps[mapnum].colormap = (UINT8 *)colormap_p; - - for (p = 0; p < 34; p++) - { - for (i = 0; i < 256; i++) - { - *colormap_p = NearestColor((UINT8)RoundUp(map[i][0]), - (UINT8)RoundUp(map[i][1]), - (UINT8)RoundUp(map[i][2])); - colormap_p++; - - if ((UINT32)p < fadestart) - continue; - - if (ABS2(map[i][0] - cdestr) > ABS2(deltas[i][0])) - map[i][0] -= deltas[i][0]; - else - map[i][0] = cdestr; - - if (ABS2(map[i][1] - cdestg) > ABS2(deltas[i][1])) - map[i][1] -= deltas[i][1]; - else - map[i][1] = cdestg; - - if (ABS2(map[i][2] - cdestb) > ABS2(deltas[i][1])) - map[i][2] -= deltas[i][2]; - else - map[i][2] = cdestb; - } - } - } -#undef ABS2 - - return; -} -*/ - // Thanks to quake2 source! // utils3/qdata/images.c static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b) diff --git a/src/r_data.h b/src/r_data.h index c1f2a73d..a656e5db 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -93,8 +93,6 @@ void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); INT32 R_ColormapNumForName(char *name); INT32 R_CreateColormap(char *p1, char *p2, char *p3); -//void R_CreateColormap2(char *p1, char *p2, char *p3); -//void R_MakeColormaps(void); const char *R_ColormapNameForNum(INT32 num); extern INT32 numtextures; From d26ba2ee5451bb53bf15384b1ad7af12ecd665ff Mon Sep 17 00:00:00 2001 From: PrisimaTheFox Date: Sun, 9 Sep 2018 23:16:28 -0500 Subject: [PATCH 11/52] Update m_anigif.c More accurate GIF delay. --- src/m_anigif.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 2540665a..5c7cfbd6 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -492,7 +492,9 @@ static void GIF_framewrite(void) // screen regions are handled in GIF_lzw { - UINT16 delay = 3; // todo + int d1 = (int)((100.0/NEWTICRATE)*gif_frames); + int d2 = (int)((100.0/NEWTICRATE)*(gif_frames-1)); + UINT16 delay = d1-d2; INT32 startline; WRITEMEM(p, gifframe_gchead, 4); From 4ada0b0a9e42f5b3b71cf509bc66f7881104b4aa Mon Sep 17 00:00:00 2001 From: PrisimaTheFox Date: Sun, 9 Sep 2018 23:33:51 -0500 Subject: [PATCH 12/52] Update m_anigif.c Remember gif_frames starts at 0 --- src/m_anigif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 5c7cfbd6..d46d889b 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -492,8 +492,8 @@ static void GIF_framewrite(void) // screen regions are handled in GIF_lzw { - int d1 = (int)((100.0/NEWTICRATE)*gif_frames); - int d2 = (int)((100.0/NEWTICRATE)*(gif_frames-1)); + int d1 = (int)((100.0/NEWTICRATE)*gif_frames+1); + int d2 = (int)((100.0/NEWTICRATE)*(gif_frames)); UINT16 delay = d1-d2; INT32 startline; From c32c72c401b16d15184b1821cb52ff9e80717910 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 7 Sep 2018 18:14:52 -0400 Subject: [PATCH 13/52] Thwomp fix: Don't trigger (look for players) when ~FF_EXISTS --- src/p_floor.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index f3063765..f3dda23b 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1818,6 +1818,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) #define ceilingwasheight vars[5] fixed_t thwompx, thwompy; sector_t *actionsector; + ffloor_t *rover = NULL; INT32 secnum; // If you just crashed down, wait a second before coming back up. @@ -1832,7 +1833,16 @@ void T_ThwompSector(levelspecthink_t *thwomp) secnum = P_FindSectorFromTag((INT16)thwomp->vars[0], -1); if (secnum > 0) + { actionsector = §ors[secnum]; + + // Look for thwomp FFloor + for (rover = actionsector->ffloors; rover; rover = rover->next) + { + if (rover->master == thwomp->sourceline) + break; + } + } else return; // Bad bad bad! @@ -1921,10 +1931,13 @@ void T_ThwompSector(levelspecthink_t *thwomp) { mobj_t *mp = (void *)&actionsector->soundorg; - if (thwomp->sourceline->flags & ML_EFFECT4) - S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); - else - S_StartSound(mp, sfx_thwomp); + if (!rover || (rover->flags & FF_EXISTS)) + { + if (thwomp->sourceline->flags & ML_EFFECT4) + S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); + else + S_StartSound(mp, sfx_thwomp); + } thwomp->direction = 1; // start heading back up thwomp->distance = TICRATE; // but only after a small delay @@ -1938,18 +1951,21 @@ void T_ThwompSector(levelspecthink_t *thwomp) thinker_t *th; mobj_t *mo; - // scan the thinkers to find players! - for (th = thinkercap.next; th != &thinkercap; th = th->next) + if (!rover || (rover->flags & FF_EXISTS)) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight - && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + // scan the thinkers to find players! + for (th = thinkercap.next; th != &thinkercap; th = th->next) { - thwomp->direction = -1; - break; + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + mo = (mobj_t *)th; + if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight + && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + { + thwomp->direction = -1; + break; + } } } From 89a6694d6743375e3dbaaabfec48f7e12d1f9cfb Mon Sep 17 00:00:00 2001 From: Digiku Date: Thu, 13 Sep 2018 11:30:00 -0400 Subject: [PATCH 14/52] Don't trigger thwomp on spectators --- src/p_floor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_floor.c b/src/p_floor.c index f3dda23b..e613b5ed 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1960,7 +1960,8 @@ void T_ThwompSector(levelspecthink_t *thwomp) continue; mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight + if (mo->type == MT_PLAYER && mo->health && mo->player && !mo->player->spectator + && mo->z <= thwomp->sector->ceilingheight && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) { thwomp->direction = -1; From 546fa383c1c74499552e031b11020ed71a6d8561 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Sep 2018 21:01:07 +0100 Subject: [PATCH 15/52] Make sure that T_MarioBlockChecker is synced in netgames, so that the textures of Mario Blocks can change when there are no more items --- src/p_saveg.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index d1ec8e5a..6e0c704f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -950,6 +950,7 @@ typedef enum tc_bouncecheese, tc_startcrumble, tc_marioblock, + tc_marioblockchecker, tc_spikesector, tc_floatsector, tc_bridgethinker, @@ -1774,6 +1775,11 @@ static void P_NetArchiveThinkers(void) SaveSpecialLevelThinker(th, tc_marioblock); continue; } + else if (th->function.acp1 == (actionf_p1)T_MarioBlockChecker) + { + SaveSpecialLevelThinker(th, tc_marioblockchecker); + continue; + } else if (th->function.acp1 == (actionf_p1)T_SpikeSector) { SaveSpecialLevelThinker(th, tc_spikesector); @@ -2730,6 +2736,10 @@ static void P_NetUnArchiveThinkers(void) LoadSpecialLevelThinker((actionf_p1)T_MarioBlock, 3); break; + case tc_marioblockchecker: + LoadSpecialLevelThinker((actionf_p1)T_MarioBlockChecker, 0); + break; + case tc_spikesector: LoadSpecialLevelThinker((actionf_p1)T_SpikeSector, 0); break; From 1b7b1f3f796eb08385f86e817b4486ec3a25361a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 16 Sep 2018 20:25:07 +0100 Subject: [PATCH 16/52] Fix order of operations messups by adding brackets --- src/m_anigif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index d46d889b..e2af7009 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -492,7 +492,7 @@ static void GIF_framewrite(void) // screen regions are handled in GIF_lzw { - int d1 = (int)((100.0/NEWTICRATE)*gif_frames+1); + int d1 = (int)((100.0/NEWTICRATE)*(gif_frames+1)); int d2 = (int)((100.0/NEWTICRATE)*(gif_frames)); UINT16 delay = d1-d2; INT32 startline; From 20c4702986f6f3f99d30bf3efe19a10bc13141cc Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 14:12:16 -0400 Subject: [PATCH 17/52] Line exec trigger netsync: Save var2s in addition to vars --- src/p_saveg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 6e0c704f..6010a1d2 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1260,7 +1260,10 @@ static void SaveSpecialLevelThinker(const thinker_t *th, const UINT8 type) size_t i; WRITEUINT8(save_p, type); for (i = 0; i < 16; i++) + { WRITEFIXED(save_p, ht->vars[i]); //var[16] + WRITEFIXED(save_p, ht->var2s[i]); //var[16] + } WRITEUINT32(save_p, SaveLine(ht->sourceline)); WRITEUINT32(save_p, SaveSector(ht->sector)); } @@ -2163,7 +2166,10 @@ static void LoadSpecialLevelThinker(actionf_p1 thinker, UINT8 floorOrCeiling) size_t i; ht->thinker.function.acp1 = thinker; for (i = 0; i < 16; i++) + { ht->vars[i] = READFIXED(save_p); //var[16] + ht->var2s[i] = READFIXED(save_p); //var[16] + } ht->sourceline = LoadLine(READUINT32(save_p)); ht->sector = LoadSector(READUINT32(save_p)); From a53f036149a4ff1d7c9371f9f082fbfe5b65a5b7 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 20 Sep 2018 18:26:59 -0400 Subject: [PATCH 18/52] Use MemAvailable instead --- src/sdl/i_system.c | 49 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index e86a39ca..984f6dd2 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -124,6 +124,10 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include "macosx/mac_resources.h" #endif +#ifndef errno +#include +#endif + // Locations for searching the srb2.srb #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #define DEFAULTWADLOCATION1 "/usr/local/share/games/SRB2" @@ -2712,9 +2716,31 @@ const char *I_LocateWad(void) #ifdef __linux__ #define MEMINFO_FILE "/proc/meminfo" #define MEMTOTAL "MemTotal:" +#define MEMAVAILABLE "MemAvailable:" #define MEMFREE "MemFree:" +#define CACHED "Cached:" +#define BUFFERS "Buffers:" +#define SHMEM "Shmem:" #endif +/* Parse the contents of /proc/meminfo (in buf), return value of "name" + * (example: MemTotal) */ +static long get_entry(const char* name, const char* buf) +{ + char* hit = strstr(buf, name); + if (hit == NULL) { + return -1; + } + + errno = 0; + long val = strtol(hit + strlen(name), NULL, 10); + if (errno != 0) { + CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno)); + return -1; + } + return val; +} + // quick fix for compil UINT32 I_GetFreeMem(UINT32 *total) { @@ -2809,7 +2835,17 @@ UINT32 I_GetFreeMem(UINT32 *total) memTag += sizeof (MEMTOTAL); totalKBytes = atoi(memTag); - if ((memTag = strstr(buf, MEMFREE)) == NULL) + if ((memTag = strstr(buf, MEMAVAILABLE)) == NULL) + { + Cached = get_entry(CACHED, buf); + MemFree = get_entry(MEMFREE, buf); + Buffers = get_entry(BUFFERS, buf); + Shmem = get_entry(SHMEM, buf); + MemAvailable = Cached + MemFree + Buffers - Shmem; + guessed = true; + } + + if (MemAvailable == -1 && guessed) { // Error if (total) @@ -2817,8 +2853,15 @@ UINT32 I_GetFreeMem(UINT32 *total) return 0; } - memTag += sizeof (MEMFREE); - freeKBytes = atoi(memTag); + if (guessed) + { + freeKBytes = MemAvailable; + } + else + { + memTag += sizeof (MEMAVAILABLE); + freeKBytes = atoi(memTag); + } if (total) *total = totalKBytes << 10; From 378495cb2b8337c37b6bfefc3f510cf9b6117e61 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 20 Sep 2018 18:33:50 -0400 Subject: [PATCH 19/52] Add some stuff --- src/sdl/i_system.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 984f6dd2..3610a534 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2810,6 +2810,12 @@ UINT32 I_GetFreeMem(UINT32 *total) UINT32 totalKBytes; INT32 n; INT32 meminfo_fd = -1; + long Cached; + long MemFree; + long Buffers; + long Shmem; + long MemAvailable = -1; + boolean guessed = false; // Stupid way to verify if the amount was guessed or not. meminfo_fd = open(MEMINFO_FILE, O_RDONLY); n = read(meminfo_fd, buf, 1023); From be74b4e58b93974bc56a7f96f3f175b541b04230 Mon Sep 17 00:00:00 2001 From: Steel Date: Fri, 21 Sep 2018 07:16:54 -0400 Subject: [PATCH 20/52] Fix up errors with buildbots --- src/sdl/i_system.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 3610a534..e9e1ae92 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1,6 +1,6 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- -// +- // // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. // @@ -2095,7 +2095,6 @@ INT32 I_StartupSystem(void) return 0; } - // // I_Quit // @@ -2721,25 +2720,26 @@ const char *I_LocateWad(void) #define CACHED "Cached:" #define BUFFERS "Buffers:" #define SHMEM "Shmem:" -#endif /* Parse the contents of /proc/meminfo (in buf), return value of "name" * (example: MemTotal) */ static long get_entry(const char* name, const char* buf) { + long val; char* hit = strstr(buf, name); if (hit == NULL) { return -1; } errno = 0; - long val = strtol(hit + strlen(name), NULL, 10); + val = strtol(hit + strlen(name), NULL, 10); if (errno != 0) { CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno)); return -1; } return val; } +#endif // quick fix for compil UINT32 I_GetFreeMem(UINT32 *total) From af58ba9ae3fa661ea406bca3b134ae2ac6b76a2c Mon Sep 17 00:00:00 2001 From: Steel Date: Fri, 21 Sep 2018 07:21:49 -0400 Subject: [PATCH 21/52] Remove this that somehow slipped in. --- src/sdl/i_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index e9e1ae92..b7326b06 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1,6 +1,6 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- -- // +// // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. // From 68ec8119096c3744e25115337fd03ea3e124df2a Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Fri, 21 Sep 2018 11:26:08 -0400 Subject: [PATCH 22/52] Rearrange the code. Thanks again MonsterIestyn! --- src/sdl/i_system.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index b7326b06..05d9e092 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2815,7 +2815,6 @@ UINT32 I_GetFreeMem(UINT32 *total) long Buffers; long Shmem; long MemAvailable = -1; - boolean guessed = false; // Stupid way to verify if the amount was guessed or not. meminfo_fd = open(MEMINFO_FILE, O_RDONLY); n = read(meminfo_fd, buf, 1023); @@ -2848,26 +2847,21 @@ UINT32 I_GetFreeMem(UINT32 *total) Buffers = get_entry(BUFFERS, buf); Shmem = get_entry(SHMEM, buf); MemAvailable = Cached + MemFree + Buffers - Shmem; - guessed = true; - } - if (MemAvailable == -1 && guessed) - { - // Error - if (total) - *total = 0L; - return 0; - } - - if (guessed) - { + if (MemAvailable == -1) + { + // Error + if (total) + *total = 0L; + return 0; + } freeKBytes = MemAvailable; - } - else - { + } + else + { memTag += sizeof (MEMAVAILABLE); freeKBytes = atoi(memTag); - } + } if (total) *total = totalKBytes << 10; From f88708bb75810e5ef089b5cf5246d3a2f9154d02 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Fri, 21 Sep 2018 12:05:52 -0400 Subject: [PATCH 23/52] Fix the weird indentation --- src/sdl/i_system.c | 76 +++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 05d9e092..f92cd4b6 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1683,7 +1683,7 @@ static void I_ShutdownMouse2(void) EscapeCommFunction(mouse2filehandle, CLRRTS); PurgeComm(mouse2filehandle, PURGE_TXABORT | PURGE_RXABORT | - PURGE_TXCLEAR | PURGE_RXCLEAR); + PURGE_TXCLEAR | PURGE_RXCLEAR); CloseHandle(mouse2filehandle); @@ -1876,11 +1876,11 @@ void I_StartupMouse2(void) { // COM file handle mouse2filehandle = CreateFileA(cv_mouse2port.string, GENERIC_READ | GENERIC_WRITE, - 0, // exclusive access - NULL, // no security attrs - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); + 0, // exclusive access + NULL, // no security attrs + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); if (mouse2filehandle == INVALID_HANDLE_VALUE) { INT32 e = GetLastError(); @@ -1900,7 +1900,7 @@ void I_StartupMouse2(void) // purge buffers PurgeComm(mouse2filehandle, PURGE_TXABORT | PURGE_RXABORT - | PURGE_TXCLEAR | PURGE_RXCLEAR); + | PURGE_TXCLEAR | PURGE_RXCLEAR); // setup port to 1200 7N1 dcb.DCBlength = sizeof (DCB); @@ -2029,7 +2029,7 @@ static void I_ShutdownTimer(void) tic_t I_GetTime (void) { static Uint32 basetime = 0; - Uint32 ticks = SDL_GetTicks(); + Uint32 ticks = SDL_GetTicks(); if (!basetime) basetime = ticks; @@ -2373,7 +2373,7 @@ void I_GetDiskFreeSpace(INT64 *freespace) { DWORD SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalNumberOfClusters; GetDiskFreeSpace(NULL, &SectorsPerCluster, &BytesPerSector, - &NumberOfFreeClusters, &TotalNumberOfClusters); + &NumberOfFreeClusters, &TotalNumberOfClusters); *freespace = BytesPerSector*SectorsPerCluster*NumberOfFreeClusters; } #else // Dummy for platform independent; 1GB should be enough @@ -2595,22 +2595,22 @@ static const char *locateWad(void) #ifdef CMAKECONFIG #ifndef NDEBUG - I_OutputMsg(","CMAKE_ASSETS_DIR); - strcpy(returnWadPath, CMAKE_ASSETS_DIR); - if (isWadPathOk(returnWadPath)) - { - return returnWadPath; - } + I_OutputMsg(","CMAKE_ASSETS_DIR); + strcpy(returnWadPath, CMAKE_ASSETS_DIR); + if (isWadPathOk(returnWadPath)) + { + return returnWadPath; + } #endif #endif #ifdef __APPLE__ - OSX_GetResourcesPath(returnWadPath); - I_OutputMsg(",%s", returnWadPath); - if (isWadPathOk(returnWadPath)) - { - return returnWadPath; - } + OSX_GetResourcesPath(returnWadPath); + I_OutputMsg(",%s", returnWadPath); + if (isWadPathOk(returnWadPath)) + { + return returnWadPath; + } #endif // examine default dirs @@ -2725,19 +2725,19 @@ const char *I_LocateWad(void) * (example: MemTotal) */ static long get_entry(const char* name, const char* buf) { - long val; - char* hit = strstr(buf, name); - if (hit == NULL) { - return -1; - } + long val; + char* hit = strstr(buf, name); + if (hit == NULL) { + return -1; + } - errno = 0; - val = strtol(hit + strlen(name), NULL, 10); - if (errno != 0) { - CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno)); - return -1; - } - return val; + errno = 0; + val = strtol(hit + strlen(name), NULL, 10); + if (errno != 0) { + CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno)); + return -1; + } + return val; } #endif @@ -2850,18 +2850,18 @@ UINT32 I_GetFreeMem(UINT32 *total) if (MemAvailable == -1) { - // Error + // Error if (total) *total = 0L; return 0; } freeKBytes = MemAvailable; - } - else - { + } + else + { memTag += sizeof (MEMAVAILABLE); freeKBytes = atoi(memTag); - } + } if (total) *total = totalKBytes << 10; From 800b3bb2407f793730b88f2b6c70c583f3a2f8a8 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 30 Sep 2018 22:18:48 +0100 Subject: [PATCH 24/52] Move player + player mobj existence checks to top of P_MoveChaseCamera. This is the only place it makes sense to even check them tbh. While I'm at it, let's also use the "mo" variable instead of player->mo throughout the function (to be consistent) --- src/p_user.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index da8e19ca..91b5feb8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7853,7 +7853,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall subsector_t *newsubsec; fixed_t f1, f2; - cameranoclip = (player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) || (player->mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!! + // We probably shouldn't move the camera if there is no player or player mobj somehow + if (!player || !player->mo) + return true; + + mo = player->mo; + + cameranoclip = (player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!! if (!(player->climbing || (player->pflags & PF_NIGHTSMODE) || player->playerstate == PST_DEAD)) { @@ -7874,7 +7880,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall else if (player == &players[secondarydisplayplayer]) focusangle = localangle2; else - focusangle = player->mo->angle; + focusangle = mo->angle; if (thiscam == &camera) camrotate = cv_cam_rotate.value; else if (thiscam == &camera2) @@ -7886,17 +7892,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall return true; } - if (!player || !player->mo) - return true; - - mo = player->mo; - thiscam->radius = FixedMul(20*FRACUNIT, mo->scale); thiscam->height = FixedMul(16*FRACUNIT, mo->scale); - if (!mo) - return true; - // Don't run while respawning from a starpost // Inu 4/8/13 Why not?! // if (leveltime > 0 && timeinmap <= 0) @@ -7904,7 +7902,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (player->pflags & PF_NIGHTSMODE) { - focusangle = player->mo->angle; + focusangle = mo->angle; focusaiming = 0; } else if (player == &players[consoleplayer]) @@ -7919,7 +7917,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } else { - focusangle = player->mo->angle; + focusangle = mo->angle; focusaiming = player->aiming; } @@ -7966,12 +7964,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall angle = R_PointToAngle2(player->axis1->x, player->axis1->y, player->axis2->x, player->axis2->y); angle += ANGLE_90; } - else if (player->mo->target) + else if (mo->target) { - if (player->mo->target->flags & MF_AMBUSH) - angle = R_PointToAngle2(player->mo->target->x, player->mo->target->y, player->mo->x, player->mo->y); + if (mo->target->flags & MF_AMBUSH) + angle = R_PointToAngle2(mo->target->x, mo->target->y, mo->x, mo->y); else - angle = R_PointToAngle2(player->mo->x, player->mo->y, player->mo->target->x, player->mo->target->y); + angle = R_PointToAngle2(mo->x, mo->y, mo->target->x, mo->target->y); } } else if (P_AnalogMove(player)) // Analog @@ -8066,7 +8064,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (twodlevel || (mo->flags2 & MF2_TWOD)) { // Camera doesn't ALWAYS need to move, only when running... - if (abs(player->mo->momx) > 10) + if (abs(mo->momx) > 10) { // Move the camera all smooth-like, not jerk it around... if (mo->momx > 0) @@ -8384,13 +8382,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall vy = thiscam->y; } - if (P_AproxDistance(vx - player->mo->x, vy - player->mo->y) < FixedMul(48*FRACUNIT, mo->scale)) - player->mo->flags2 |= MF2_SHADOW; + if (P_AproxDistance(vx - mo->x, vy - mo->y) < FixedMul(48*FRACUNIT, mo->scale)) + mo->flags2 |= MF2_SHADOW; else - player->mo->flags2 &= ~MF2_SHADOW; + mo->flags2 &= ~MF2_SHADOW; } else - player->mo->flags2 &= ~MF2_SHADOW; + mo->flags2 &= ~MF2_SHADOW; /* if (!resetcalled && (player->pflags & PF_NIGHTSMODE && player->exiting)) { From 79f5f4885c70e373cd6d4afc275c2141aa545736 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 4 Oct 2018 19:47:19 -0400 Subject: [PATCH 25/52] Split zlib and libpng --- src/Makefile | 22 +++++++++++++++------- src/sdl/mixer_sound.c | 17 ++++++++--------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/Makefile b/src/Makefile index dd250b0b..7a67c3f0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -66,6 +66,7 @@ # Compile without 3D sound support, add 'NOHS=1' # Compile with GDBstubs, add 'RDB=1' # Compile without PNG, add 'NOPNG=1' +# Compile without zlib, add 'NOZLIB=1' # # Addon for SDL: # To Cross-Compile, add 'SDL_CONFIG=/usr/*/bin/sdl-config' @@ -119,6 +120,7 @@ include Makefile.cfg ifdef DUMMY NOPNG=1 +NOZLIB=1 NONET=1 NOHW=1 NOHS=1 @@ -199,6 +201,7 @@ endif ifdef NDS NOPNG=1 +NOZLIB=1 NONET=1 #NOHW=1 NOHS=1 @@ -325,13 +328,6 @@ LIBS+=$(PNG_LDFLAGS) CFLAGS+=$(PNG_CFLAGS) endif -ZLIB_PKGCONFIG?=zlib -ZLIB_CFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --cflags) -ZLIB_LDFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --libs) - -LIBS+=$(ZLIB_LDFLAGS) -CFLAGS+=$(ZLIB_CFLAGS) - ifdef HAVE_LIBGME OPTS+=-DHAVE_LIBGME @@ -343,6 +339,18 @@ LIBS+=$(LIBGME_LDFLAGS) CFLAGS+=$(LIBGME_CFLAGS) endif +ifndef NOZLIB +OPTS+=-DHAVE_ZLIB +ZLIB_PKGCONFIG?=zlib +ZLIB_CFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --cflags) +ZLIB_LDFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --libs) + +LIBS+=$(ZLIB_LDFLAGS) +CFLAGS+=$(ZLIB_CFLAGS) +else +NOPNG=1 +endif + ifdef STATIC LIBS:=-static $(LIBS) endif diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 5211efe0..362d7f26 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -38,9 +38,6 @@ #include "gme/gme.h" #define GME_TREBLE 5.0 #define GME_BASS 1.0 -#ifdef HAVE_PNG /// TODO: compile with zlib support without libpng - -#define HAVE_ZLIB #ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE @@ -56,10 +53,13 @@ #define _FILE_OFFSET_BITS 0 #endif -#include "zlib.h" #endif #endif +#ifdef HAVE_ZLIB +#include "zlib.h" +#endif + UINT8 sound_started = false; static boolean midimode; @@ -361,7 +361,7 @@ void *I_GetSfx(sfxinfo_t *sfx) } Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up #else - //CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n"); + return NULL; // No zlib support #endif } // Try to read it as a GME sound @@ -621,7 +621,8 @@ boolean I_StartDigSong(const char *musicname, boolean looping) } Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up #else - //CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n"); + CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n"); + return true; #endif } else if (!gme_open_data(data, len, &gme, 44100)) @@ -840,6 +841,4 @@ void I_UnRegisterSong(INT32 handle) (void)handle; Mix_FreeMusic(music); music = NULL; -} - -#endif +} \ No newline at end of file From 49cb1ffe9fb578f8abb29a3f45355ded6211dc03 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 4 Oct 2018 22:38:59 -0400 Subject: [PATCH 26/52] Restore deleted endif --- src/sdl/mixer_sound.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 362d7f26..d1083518 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -51,8 +51,6 @@ #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 0 -#endif - #endif #endif @@ -841,4 +839,6 @@ void I_UnRegisterSong(INT32 handle) (void)handle; Mix_FreeMusic(music); music = NULL; -} \ No newline at end of file +} + +#endif \ No newline at end of file From fc5d969642f57f54c12acd137355473f14d84acd Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 4 Oct 2018 22:44:26 -0400 Subject: [PATCH 27/52] Fix DD compiling --- src/win32/win_snd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index f168f1fe..c030eec5 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -17,9 +17,6 @@ #include "gme/gme.h" #define GME_TREBLE 5.0 #define GME_BASS 1.0 -#ifdef HAVE_PNG /// TODO: compile with zlib support without libpng - -#define HAVE_ZLIB #ifndef _MSC_VER #ifndef _WII From b812a6a4abdf705d65c6f204291ec6645fe5d729 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 4 Oct 2018 22:56:11 -0400 Subject: [PATCH 28/52] Really fix DD compiling this time. --- src/win32/win_snd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index c030eec5..bc04bd6d 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -34,6 +34,7 @@ #define _FILE_OFFSET_BITS 0 #endif +#ifdef HAVE_ZLIB #include "zlib.h" #endif #endif From 1ec601af6b989f7ebdc0fa89f4bc2452977ae209 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 5 Oct 2018 22:42:36 +0100 Subject: [PATCH 29/52] Draw a star for continues if invalid skin numbers are somehow supplied --- src/v_video.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index aa2852c0..802a4d38 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -653,14 +653,10 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ // void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT8 skincolor) { - if (skins[skinnum].flags & SF_HIRES -#ifdef HWRENDER -// || (rendermode != render_soft && rendermode != render_none) -#endif - ) - V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_CACHE)); + if (skinnum < 0 || skinnum >= numskins || (skins[skinnum].flags & SF_HIRES)) + V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_CACHE)); // Draw a star else - { + { // Find front angle of the first waiting frame of the character's actual sprites spriteframe_t *sprframe = &skins[skinnum].spritedef.spriteframes[2 & FF_FRAMEMASK]; patch_t *patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); const UINT8 *colormap = R_GetTranslationColormap(skinnum, skincolor, GTC_CACHE); From 725a65c1f7eff77e5632b6a7d7fdb11c47ee0c3f Mon Sep 17 00:00:00 2001 From: Sryder Date: Sat, 6 Oct 2018 21:44:40 +0100 Subject: [PATCH 30/52] Call SDL_RWclose after an SDL_RWFromMem call to close the RWops. --- src/sdl/mixer_sound.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 5211efe0..e835a55c 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -387,7 +387,15 @@ void *I_GetSfx(sfxinfo_t *sfx) #endif // Try to load it as a WAVE or OGG using Mixer. - return Mix_LoadWAV_RW(SDL_RWFromMem(lump, sfx->length), 1); + SDL_RWops *rw = SDL_RWFromMem(lump, sfx->length); + if (rw != NULL) + { + Mix_Chunk *chunk = Mix_LoadWAV_RW(rw, 1); + SDL_RWclose(rw); + return chunk; + } + + return NULL; // haven't been able to get anything } void I_FreeSfx(sfxinfo_t *sfx) @@ -635,7 +643,12 @@ boolean I_StartDigSong(const char *musicname, boolean looping) } #endif - music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len), SDL_FALSE); + SDL_RWops *rw = SDL_RWFromMem(data, len); + if (rw != NULL) + { + music = Mix_LoadMUS_RW(rw, SDL_FALSE); + SDL_RWclose(rw); + } if (!music) { CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError()); @@ -798,7 +811,12 @@ void I_SetMIDIMusicVolume(UINT8 volume) INT32 I_RegisterSong(void *data, size_t len) { - music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len), SDL_FALSE); + SDL_RWops *rw = SDL_RWFromMem(data, len); + if (rw != NULL) + { + music = Mix_LoadMUS_RW(rw, SDL_FALSE); + SDL_RWclose(rw); + } if (!music) { CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError()); From 7b417b573c61eeaeb325366196d78ace780f1b5a Mon Sep 17 00:00:00 2001 From: Sryder Date: Sat, 6 Oct 2018 23:59:39 +0100 Subject: [PATCH 31/52] Mix_QuickLoad_RAW sets a flag in the Mix_Chunk so that Mix_FreeChunk doesn't actually Free the sound. Checks for the flag when freeing, and if it's 0, we free the data manually after Mix_FreeChunk. I went back to Z_Malloc and Z_Free for this because they still work after this. --- src/sdl/mixer_sound.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index e835a55c..15f1595c 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -178,7 +178,7 @@ static Mix_Chunk *ds2chunk(void *stream) return NULL; // would and/or did wrap, can't store. break; } - sound = malloc(newsamples<<2); // samples * frequency shift * bytes per sample * channels + sound = Z_Malloc(newsamples<<2, PU_SOUND, 0); // samples * frequency shift * bytes per sample * channels s = (SINT8 *)stream; d = (INT16 *)sound; @@ -401,7 +401,22 @@ void *I_GetSfx(sfxinfo_t *sfx) void I_FreeSfx(sfxinfo_t *sfx) { if (sfx->data) + { + Mix_Chunk *chunk = (Mix_Chunk*)sfx->data; + UINT8 *abufdata = NULL; + if (chunk->allocated == 0) + { + // We allocated the data in this chunk, so get the abuf from mixer, then let it free the chunk, THEN we free the data + // I believe this should ensure the sound is not playing when we free it + abufdata = chunk->abuf; + } Mix_FreeChunk(sfx->data); + if (abufdata) + { + // I'm going to assume we used Z_Malloc to allocate this data. + Z_Free(abufdata); + } + } sfx->data = NULL; sfx->lumpnum = LUMPERROR; } From d072dd27254596c7c8925b4f6d08c151e57535f2 Mon Sep 17 00:00:00 2001 From: Sryder Date: Sun, 7 Oct 2018 00:22:23 +0100 Subject: [PATCH 32/52] I think that should be NULL, not 0 actually. --- src/sdl/mixer_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 15f1595c..9fef1646 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -178,7 +178,7 @@ static Mix_Chunk *ds2chunk(void *stream) return NULL; // would and/or did wrap, can't store. break; } - sound = Z_Malloc(newsamples<<2, PU_SOUND, 0); // samples * frequency shift * bytes per sample * channels + sound = Z_Malloc(newsamples<<2, PU_SOUND, NULL); // samples * frequency shift * bytes per sample * channels s = (SINT8 *)stream; d = (INT16 *)sound; From 02597e0bf923c76cb1aed2bd15c285371bdd71ff Mon Sep 17 00:00:00 2001 From: Sryder Date: Sun, 7 Oct 2018 09:26:18 +0100 Subject: [PATCH 33/52] Fix compiler warnings. --- src/sdl/mixer_sound.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 9fef1646..ed15fcda 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -246,6 +246,7 @@ void *I_GetSfx(sfxinfo_t *sfx) { void *lump; Mix_Chunk *chunk; + SDL_RWops *rw; #ifdef HAVE_LIBGME Music_Emu *emu; gme_info_t *info; @@ -387,10 +388,10 @@ void *I_GetSfx(sfxinfo_t *sfx) #endif // Try to load it as a WAVE or OGG using Mixer. - SDL_RWops *rw = SDL_RWFromMem(lump, sfx->length); + rw = SDL_RWFromMem(lump, sfx->length); if (rw != NULL) { - Mix_Chunk *chunk = Mix_LoadWAV_RW(rw, 1); + chunk = Mix_LoadWAV_RW(rw, 1); SDL_RWclose(rw); return chunk; } @@ -547,6 +548,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) char *data; size_t len; lumpnum_t lumpnum = W_CheckNumForName(va("O_%s",musicname)); + SDL_RWops *rw; I_Assert(!music); #ifdef HAVE_LIBGME @@ -658,7 +660,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) } #endif - SDL_RWops *rw = SDL_RWFromMem(data, len); + rw = SDL_RWFromMem(data, len); if (rw != NULL) { music = Mix_LoadMUS_RW(rw, SDL_FALSE); From fb6c3298702e76ee8a167264cc7dc0e86936f862 Mon Sep 17 00:00:00 2001 From: Sryder Date: Sun, 7 Oct 2018 10:37:45 +0100 Subject: [PATCH 34/52] Fix the crashing bug hopefully A value of 1 in freesrc for Mix_LoadWAV_RW and Mix_LoadMus_RW calls SDL_RWclose on the RWops anyway. For Mix_LoadWAV_RW the RWops is freed right after the data is loaded (because it makes a copy of the data in memory) For Mix_LoadMUS_RW the RWops is freed when Mix_FreeMusic is called (because the data is not a copy) So setting 1 on freesrc doesn't actually free the RWops immediately on Mix_LoadMus_RW *unless* it failed to load any music. --- src/sdl/mixer_sound.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index ed15fcda..53a767df 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -392,7 +392,6 @@ void *I_GetSfx(sfxinfo_t *sfx) if (rw != NULL) { chunk = Mix_LoadWAV_RW(rw, 1); - SDL_RWclose(rw); return chunk; } @@ -663,8 +662,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) rw = SDL_RWFromMem(data, len); if (rw != NULL) { - music = Mix_LoadMUS_RW(rw, SDL_FALSE); - SDL_RWclose(rw); + music = Mix_LoadMUS_RW(rw, 1); } if (!music) { @@ -831,8 +829,7 @@ INT32 I_RegisterSong(void *data, size_t len) SDL_RWops *rw = SDL_RWFromMem(data, len); if (rw != NULL) { - music = Mix_LoadMUS_RW(rw, SDL_FALSE); - SDL_RWclose(rw); + music = Mix_LoadMUS_RW(rw, 1); } if (!music) { From b1e02467bfc009d1b08d83a12181fde87869bae0 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 7 Oct 2018 15:00:58 +0100 Subject: [PATCH 35/52] Weather is already run client-side. What if we ran it render-side, for major performance gains? This commit will answer all your questions - and more! --- src/hardware/hw_main.c | 22 ++++++++++++++++++---- src/p_mobj.c | 37 ++++++++++++++++++++----------------- src/p_mobj.h | 4 ++++ src/p_saveg.c | 6 ++---- src/p_spec.c | 34 ++++++++++------------------------ src/p_tick.c | 24 ++++++++++++------------ src/r_things.c | 23 +++++++++++++++++++---- 7 files changed, 85 insertions(+), 65 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d7c73415..871a6a49 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5140,8 +5140,10 @@ static void HWR_AddSprites(sector_t *sec) approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - if (approx_dist <= limit_dist) - HWR_ProjectSprite(thing); + if (approx_dist > limit_dist) + continue; + + HWR_ProjectSprite(thing); } } else @@ -5163,8 +5165,10 @@ static void HWR_AddSprites(sector_t *sec) approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); - if (approx_dist <= limit_dist) - HWR_ProjectPrecipitationSprite(precipthing); + if (approx_dist > limit_dist) + continue; + + HWR_ProjectPrecipitationSprite(precipthing); } } else @@ -5449,6 +5453,16 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) x1 = tr_x + x1 * rightcos; x2 = tr_x - x2 * rightcos; + // okay, we can't return now... this is a hack, but weather isn't networked, so it should be ok + if (!(thing->precipflags & PCF_THUNK)) + { + if (thing->precipflags & PCF_RAIN) + P_RainThinker(thing); + else + P_SnowThinker(thing); + thing->precipflags |= PCF_THUNK; + } + // // store information in a vissprite // diff --git a/src/p_mobj.c b/src/p_mobj.c index 5f85474c..bb9483d1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3840,7 +3840,8 @@ void P_RecalcPrecipInSector(sector_t *sector) // void P_NullPrecipThinker(precipmobj_t *mobj) { - (void)mobj; + //(void)mobj; + mobj->precipflags &= ~PCF_THUNK; } void P_SnowThinker(precipmobj_t *mobj) @@ -3860,25 +3861,26 @@ void P_RainThinker(precipmobj_t *mobj) { // cycle through states, // calling action functions at transitions - if (mobj->tics > 0 && --mobj->tics == 0) - { - // you can cycle through multiple states in a tic - if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate)) - return; // freed itself - } + if (mobj->tics <= 0) + return; + + if (--mobj->tics) + return; + + if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate)) + return; + + if (mobj->state != &states[S_RAINRETURN]) + return; + + mobj->z = mobj->ceilingz; + P_SetPrecipMobjState(mobj, S_RAIN1); - if (mobj->state == &states[S_RAINRETURN]) - { - mobj->z = mobj->ceilingz; - P_SetPrecipMobjState(mobj, S_RAIN1); - } return; } // adjust height - mobj->z += mobj->momz; - - if (mobj->z <= mobj->floorz) + if ((mobj->z += mobj->momz) <= mobj->floorz) { // no splashes on sky or bottomless pits if (mobj->precipflags & PCF_PIT) @@ -7926,14 +7928,15 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype static inline precipmobj_t *P_SpawnRainMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type); - mo->thinker.function.acp1 = (actionf_p1)P_RainThinker; + mo->precipflags |= PCF_RAIN; + //mo->thinker.function.acp1 = (actionf_p1)P_RainThinker; return mo; } static inline precipmobj_t *P_SpawnSnowMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type); - mo->thinker.function.acp1 = (actionf_p1)P_SnowThinker; + //mo->thinker.function.acp1 = (actionf_p1)P_SnowThinker; return mo; } diff --git a/src/p_mobj.h b/src/p_mobj.h index 79cffae8..620028d8 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -252,6 +252,10 @@ typedef enum { PCF_FOF = 4, // Above MOVING FOF (this means we need to keep floorz up to date...) PCF_MOVINGFOF = 8, + // Is rain. + PCF_RAIN = 16, + // Ran the thinker this tic. + PCF_THUNK = 32, } precipflag_t; // Map Object definition. typedef struct mobj_s diff --git a/src/p_saveg.c b/src/p_saveg.c index d1ec8e5a..17d28302 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1661,8 +1661,7 @@ static void P_NetArchiveThinkers(void) for (th = thinkercap.next; th != &thinkercap; th = th->next) { if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed - || th->function.acp1 == (actionf_p1)P_RainThinker - || th->function.acp1 == (actionf_p1)P_SnowThinker)) + || th->function.acp1 == (actionf_p1)P_NullPrecipThinker)) numsaved++; if (th->function.acp1 == (actionf_p1)P_MobjThinker) @@ -1671,8 +1670,7 @@ static void P_NetArchiveThinkers(void) continue; } #ifdef PARANOIA - else if (th->function.acp1 == (actionf_p1)P_RainThinker - || th->function.acp1 == (actionf_p1)P_SnowThinker); + else if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker); #endif else if (th->function.acp1 == (actionf_p1)T_MoveCeiling) { diff --git a/src/p_spec.c b/src/p_spec.c index c62c3b20..ff6691a9 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2039,8 +2039,7 @@ void P_SwitchWeather(INT32 weathernum) for (think = thinkercap.next; think != &thinkercap; think = think->next) { - if ((think->function.acp1 != (actionf_p1)P_SnowThinker) - && (think->function.acp1 != (actionf_p1)P_RainThinker)) + if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker precipmobj = (precipmobj_t *)think; @@ -2056,14 +2055,12 @@ void P_SwitchWeather(INT32 weathernum) for (think = thinkercap.next; think != &thinkercap; think = think->next) { + if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) + continue; // not a precipmobj thinker + precipmobj = (precipmobj_t *)think; + if (swap == PRECIP_RAIN) // Snow To Rain { - if (!(think->function.acp1 == (actionf_p1)P_SnowThinker - || think->function.acp1 == (actionf_p1)P_NullPrecipThinker)) - continue; // not a precipmobj thinker - - precipmobj = (precipmobj_t *)think; - precipmobj->flags = mobjinfo[MT_RAIN].flags; st = &states[mobjinfo[MT_RAIN].spawnstate]; precipmobj->state = st; @@ -2074,18 +2071,13 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->precipflags &= ~PCF_INVISIBLE; - think->function.acp1 = (actionf_p1)P_RainThinker; + precipmobj->precipflags |= PCF_RAIN; + //think->function.acp1 = (actionf_p1)P_RainThinker; } else if (swap == PRECIP_SNOW) // Rain To Snow { INT32 z; - if (!(think->function.acp1 == (actionf_p1)P_RainThinker - || think->function.acp1 == (actionf_p1)P_NullPrecipThinker)) - continue; // not a precipmobj thinker - - precipmobj = (precipmobj_t *)think; - precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags; z = M_RandomByte(); @@ -2103,19 +2095,13 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->frame = st->frame; precipmobj->momz = mobjinfo[MT_SNOWFLAKE].speed; - precipmobj->precipflags &= ~PCF_INVISIBLE; + precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_RAIN); - think->function.acp1 = (actionf_p1)P_SnowThinker; + //think->function.acp1 = (actionf_p1)P_SnowThinker; } else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. { - if (!(think->function.acp1 == (actionf_p1)P_RainThinker - || think->function.acp1 == (actionf_p1)P_SnowThinker)) - continue; - - precipmobj = (precipmobj_t *)think; - - think->function.acp1 = (actionf_p1)P_NullPrecipThinker; + //think->function.acp1 = (actionf_p1)P_NullPrecipThinker; precipmobj->precipflags |= PCF_INVISIBLE; } diff --git a/src/p_tick.c b/src/p_tick.c index f4bc5932..5ba74707 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -56,12 +56,12 @@ void Command_Numthinkers_f(void) CONS_Printf(M_GetText("numthinkers <#>: Count number of thinkers\n")); CONS_Printf( "\t1: P_MobjThinker\n" - "\t2: P_RainThinker\n" - "\t3: P_SnowThinker\n" - "\t4: P_NullPrecipThinker\n" - "\t5: T_Friction\n" - "\t6: T_Pusher\n" - "\t7: P_RemoveThinkerDelayed\n"); + /*"\t2: P_RainThinker\n" + "\t3: P_SnowThinker\n"*/ + "\t2: P_NullPrecipThinker\n" + "\t3: T_Friction\n" + "\t4: T_Pusher\n" + "\t5: P_RemoveThinkerDelayed\n"); return; } @@ -73,27 +73,27 @@ void Command_Numthinkers_f(void) action = (actionf_p1)P_MobjThinker; CONS_Printf(M_GetText("Number of %s: "), "P_MobjThinker"); break; - case 2: + /*case 2: action = (actionf_p1)P_RainThinker; CONS_Printf(M_GetText("Number of %s: "), "P_RainThinker"); break; case 3: action = (actionf_p1)P_SnowThinker; CONS_Printf(M_GetText("Number of %s: "), "P_SnowThinker"); - break; - case 4: + break;*/ + case 2: action = (actionf_p1)P_NullPrecipThinker; CONS_Printf(M_GetText("Number of %s: "), "P_NullPrecipThinker"); break; - case 5: + case 3: action = (actionf_p1)T_Friction; CONS_Printf(M_GetText("Number of %s: "), "T_Friction"); break; - case 6: + case 4: action = (actionf_p1)T_Pusher; CONS_Printf(M_GetText("Number of %s: "), "T_Pusher"); break; - case 7: + case 5: action = (actionf_p1)P_RemoveThinkerDelayed; CONS_Printf(M_GetText("Number of %s: "), "P_RemoveThinkerDelayed"); break; diff --git a/src/r_things.c b/src/r_things.c index 0b176416..910a52b3 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1451,6 +1451,17 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; } + // okay, we can't return now except for vertical clipping... this is a hack, but weather isn't networked, so it should be ok + if (!(thing->precipflags & PCF_THUNK)) + { + if (thing->precipflags & PCF_RAIN) + P_RainThinker(thing); + else + P_SnowThinker(thing); + thing->precipflags |= PCF_THUNK; + } + + //SoM: 3/17/2000: Disregard sprites that are out of view.. gzt = thing->z + spritecachedinfo[lump].topoffset; gz = gzt - spritecachedinfo[lump].height; @@ -1569,8 +1580,10 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - if (approx_dist <= limit_dist) - R_ProjectSprite(thing); + if (approx_dist > limit_dist) + continue; + + R_ProjectSprite(thing); } } else @@ -1591,8 +1604,10 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); - if (approx_dist <= limit_dist) - R_ProjectPrecipitationSprite(precipthing); + if (approx_dist > limit_dist) + continue; + + R_ProjectPrecipitationSprite(precipthing); } } else From def090c9f0245c148d2313c30c4ef398578d1738 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 7 Oct 2018 14:45:03 -0400 Subject: [PATCH 36/52] Move the ifdef --- src/sdl/mixer_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index d1083518..1b0974b1 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -52,11 +52,11 @@ #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 0 #endif -#endif #ifdef HAVE_ZLIB #include "zlib.h" #endif +#endif UINT8 sound_started = false; From 232a7ae7b713c5c5854d0d0205a4fbd5dea9ee47 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 7 Oct 2018 14:52:25 -0400 Subject: [PATCH 37/52] Change order of the ifdef --- src/sdl/mixer_sound.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 1b0974b1..c4d2a8b0 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -39,6 +39,7 @@ #define GME_TREBLE 5.0 #define GME_BASS 1.0 +#ifdef HAVE_ZLIB #ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE @@ -53,10 +54,9 @@ #define _FILE_OFFSET_BITS 0 #endif -#ifdef HAVE_ZLIB #include "zlib.h" -#endif -#endif +#endif // HAVE_ZLIB +#endif // HAVE_LIBGME UINT8 sound_started = false; From 027e6e8e3c91777efa302c63ab5eab23e315925d Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 7 Oct 2018 15:00:48 -0400 Subject: [PATCH 38/52] Change win_snd.c also --- src/win32/win_snd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index bc04bd6d..58644457 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -18,13 +18,12 @@ #define GME_TREBLE 5.0 #define GME_BASS 1.0 +#ifdef HAVE_ZLIB #ifndef _MSC_VER -#ifndef _WII #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE @@ -34,10 +33,9 @@ #define _FILE_OFFSET_BITS 0 #endif -#ifdef HAVE_ZLIB #include "zlib.h" -#endif -#endif +#endif // HAVE_ZLIB +#endif // HAVE_LIBGME static FMOD_SYSTEM *fsys; static FMOD_SOUND *music_stream; From 1324e0bfcd945651a90c339042523d4f35e89a24 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 8 Oct 2018 18:50:17 +0100 Subject: [PATCH 39/52] * Fix a memory leak regarding implementation of SOC_ (improperly copypasted code from LUA_LoadLump!!) * Optimise the repeated strlen usage into a single call, which is stored for later. --- src/lua_script.c | 12 +++++++----- src/w_wad.c | 15 ++++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index ce96878b..1c1b01f6 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -182,19 +182,21 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump) { MYFILE f; char *name; + size_t len; f.wad = wad; f.size = W_LumpLengthPwad(wad, lump); f.data = Z_Malloc(f.size, PU_LUA, NULL); W_ReadLumpPwad(wad, lump, f.data); f.curpos = f.data; - name = malloc(strlen(wadfiles[wad]->filename)+10); + len = strlen(wadfiles[wad]->filename); + name = malloc(len+10); strcpy(name, wadfiles[wad]->filename); - if (!fasticmp(&name[strlen(name) - 4], ".lua")) { + if (!fasticmp(&name[len - 4], ".lua")) { // If it's not a .lua file, copy the lump name in too. - name[strlen(wadfiles[wad]->filename)] = '|'; - M_Memcpy(name+strlen(wadfiles[wad]->filename)+1, wadfiles[wad]->lumpinfo[lump].name, 8); - name[strlen(wadfiles[wad]->filename)+9] = '\0'; + name[len] = '|'; + M_Memcpy(name+len+1, wadfiles[wad]->lumpinfo[lump].name, 8); + name[len+9] = '\0'; } LUA_LoadFile(&f, name); diff --git a/src/w_wad.c b/src/w_wad.c index 3a828559..3f0082a1 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -194,16 +194,21 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++) if (memcmp(lump_p->name,"SOC_",4)==0) // Check for generic SOC lump { // shameless copy+paste of code from LUA_LoadLump - char *name = malloc(strlen(wadfiles[wadnum]->filename)+10); + size_t len = strlen(wadfiles[wadnum]->filename); + char *name = malloc(len+10); + strcpy(name, wadfiles[wadnum]->filename); - if (!fasticmp(&name[strlen(name) - 4], ".soc")) { + if (!fasticmp(&name[len - 4], ".soc")) { // If it's not a .soc file, copy the lump name in too. - name[strlen(wadfiles[wadnum]->filename)] = '|'; - M_Memcpy(name+strlen(wadfiles[wadnum]->filename)+1, lump_p->name, 8); - name[strlen(wadfiles[wadnum]->filename)+9] = '\0'; + name[len] = '|'; + M_Memcpy(name+len+1, lump_p->name, 8); + name[len+9] = '\0'; } + CONS_Printf(M_GetText("Loading SOC from %s\n"), name); DEH_LoadDehackedLumpPwad(wadnum, lump); + + free(name); } else if (memcmp(lump_p->name,"MAINCFG",8)==0) // Check for MAINCFG { From 497314fdc44551a46395f41cd579d845d92b270e Mon Sep 17 00:00:00 2001 From: Sryder Date: Tue, 9 Oct 2018 19:43:18 +0100 Subject: [PATCH 40/52] Tiny fix so that joystick2 being closed can let the JoystickSubSystem close before game close. No memory leak here, just a very tiny thing I noticed. --- src/sdl/i_system.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index f92cd4b6..7b14f1f1 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1154,6 +1154,7 @@ static void I_ShutdownJoystick2(void) D_PostEvent(&event); } + joystick2_started = 0; JoyReset(&JoyInfo2); if (!joystick_started && !joystick2_started && SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) { From a4419abfdc21d0d0ec69e3d73528a4c9bb68205e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 25 Jan 2017 19:36:32 +0000 Subject: [PATCH 41/52] debugfile is only used by DEBUGFILE code, no need to declare/define it for anything else --- src/d_net.c | 2 ++ src/doomstat.h | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 643c41ac..8de5cf08 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -49,7 +49,9 @@ doomcom_t *doomcom = NULL; /// \brief network packet data, points inside doomcom doomdata_t *netbuffer = NULL; +#ifdef DEBUGFILE FILE *debugfile = NULL; // put some net info in a file during the game +#endif #define MAXREBOUND 8 static doomdata_t reboundstore[MAXREBOUND]; diff --git a/src/doomstat.h b/src/doomstat.h index 8072a155..341cc70a 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -445,19 +445,17 @@ extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF #if defined (macintosh) #define DEBFILE(msg) I_OutputMsg(msg) -extern FILE *debugfile; #else #define DEBUGFILE #ifdef DEBUGFILE #define DEBFILE(msg) { if (debugfile) { fputs(msg, debugfile); fflush(debugfile); } } -extern FILE *debugfile; #else #define DEBFILE(msg) {} -extern FILE *debugfile; #endif #endif #ifdef DEBUGFILE +extern FILE *debugfile; extern INT32 debugload; #endif From 61a29bed853a737f79fb5aac2c1ceb4ddd758aeb Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Feb 2017 22:41:15 +0000 Subject: [PATCH 42/52] Remove unused sscount variable (it's only set to 0 in software, and only ++'d in OpenGL, what kind of sense does that make?) --- src/hardware/hw_bsp.c | 2 -- src/hardware/hw_main.c | 1 - src/r_main.c | 5 ----- src/r_state.h | 3 --- 4 files changed, 11 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 17eb8761..a32609fc 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -564,8 +564,6 @@ static inline void HWR_SubsecPoly(INT32 num, poly_t *poly) subsector_t *sub; seg_t *lseg; - sscount++; - sub = &subsectors[num]; count = sub->numlines; lseg = &segs[sub->firstline]; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 871a6a49..ecb70a0f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3264,7 +3264,6 @@ static void HWR_Subsector(size_t num) if (num < numsubsectors) { - sscount++; // subsector sub = &subsectors[num]; // sector diff --git a/src/r_main.c b/src/r_main.c index f2a0c889..6c92983f 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -60,7 +60,6 @@ fixed_t projectiony; // aspect ratio // just for profiling purposes size_t framecount; -size_t sscount; size_t loopcount; fixed_t viewx, viewy, viewz; @@ -964,8 +963,6 @@ void R_SkyboxFrame(player_t *player) viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - sscount = 0; - // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight). @@ -1089,8 +1086,6 @@ void R_SetupFrame(player_t *player, boolean skybox) viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - sscount = 0; - // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight). diff --git a/src/r_state.h b/src/r_state.h index 49d0457b..ac3e1fa4 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -108,7 +108,4 @@ extern angle_t rw_normalangle; // angle to line origin extern angle_t rw_angle1; -// Segs count? -extern size_t sscount; - #endif From 07dd527e7e58e06ce621e80357bef7ae91424f76 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Feb 2017 22:56:08 +0000 Subject: [PATCH 43/52] Removed unused function prototypes in d_main.h Also corrected what appears to be a typo in some comments above? --- src/d_main.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/d_main.h b/src/d_main.h index 6dc273b1..d73b19d1 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -34,7 +34,7 @@ void D_SRB2Loop(void) FUNCNORETURN; // D_SRB2Main() // Not a globally visible function, just included for source reference, // calls all startup code, parses command line options. -// If not overrided by user input, calls N_AdvanceDemo. +// If not overrided by user input, calls D_AdvanceDemo. // void D_SRB2Main(void); @@ -51,9 +51,6 @@ const char *D_Home(void); // // BASE LEVEL // -void D_PageTicker(void); -// pagename is lumpname of a 320x200 patch to fill the screen -void D_PageDrawer(const char *pagename); void D_AdvanceDemo(void); void D_StartTitle(void); From 91b2f5e570b1b3783b54ca014a11ed07d0570ef4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Feb 2017 23:24:12 +0000 Subject: [PATCH 44/52] "t" is not needed to take out fencepost cases from viewangletox --- src/r_main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 6c92983f..d1cd71b3 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -491,9 +491,6 @@ static void R_InitTextureMapping(void) // Take out the fencepost cases from viewangletox. for (i = 0; i < FINEANGLES/2; i++) { - t = FixedMul(FINETANGENT(i), focallength); - t = centerx - t; - if (viewangletox[i] == -1) viewangletox[i] = 0; else if (viewangletox[i] == viewwidth+1) From 49c5a6f7e474ff6aa30a726ae7cbcf9e224fb533 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Feb 2017 23:28:42 +0000 Subject: [PATCH 45/52] Remove unused "runcount" variable from p_local.h --- src/p_local.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_local.h b/src/p_local.h index 1fd7ada0..b82bcf0e 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -68,7 +68,6 @@ // both the head and tail of the thinker list extern thinker_t thinkercap; -extern INT32 runcount; void P_InitThinkers(void); void P_AddThinker(thinker_t *thinker); From ef78c942f798e0d736cc84de8b912889d9232fbc Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 15 Feb 2017 21:16:56 +0000 Subject: [PATCH 46/52] Remove unused ObjectPlace_OnChange prototype (from when Objectplace was a consvar, which it is not anymore) --- src/d_netcmd.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index d8fae72f..023bbd09 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -212,7 +212,6 @@ void Command_ExitGame_f(void); void Command_Retry_f(void); void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore void D_MapChange(INT32 pmapnum, INT32 pgametype, boolean pultmode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pfromlevelselect); -void ObjectPlace_OnChange(void); void ItemFinder_OnChange(void); void D_SetPassword(const char *pw); From 9c464742b7d0b10b35ef27dcdad2e72d33e4f8da Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 22 Feb 2017 21:07:29 +0000 Subject: [PATCH 47/52] Remove "playerdeadview" variable; it's not been used for its stated purpose for who knows how long now Besides rankings popping up when you die just sounds weird anyway, maybe I'm just used to SRB2 not doing it I guess --- src/d_clisrv.c | 2 -- src/d_main.c | 1 - src/f_finale.c | 6 ------ src/g_game.c | 1 - src/hu_stuff.h | 3 --- src/p_user.c | 9 --------- 6 files changed, 22 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6e22dde2..95003823 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1568,8 +1568,6 @@ static void CL_LoadReceivedSavegame(void) automapactive = false; // load a base level - playerdeadview = false; - if (P_LoadNetGame()) { const INT32 actnum = mapheaderinfo[gamemap-1]->actnum; diff --git a/src/d_main.c b/src/d_main.c index df339875..f807e307 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -720,7 +720,6 @@ void D_StartTitle(void) maptol = 0; gameaction = ga_nothing; - playerdeadview = false; displayplayer = consoleplayer = 0; //demosequence = -1; gametype = GT_COOP; diff --git a/src/f_finale.c b/src/f_finale.c index a8b27bb8..fb1387c1 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -442,7 +442,6 @@ void F_StartIntro(void) G_SetGamestate(GS_INTRO); gameaction = ga_nothing; - playerdeadview = false; paused = false; CON_ToggleOff(); CON_ClearHUD(); @@ -1130,7 +1129,6 @@ void F_StartCredits(void) } gameaction = ga_nothing; - playerdeadview = false; paused = false; CON_ToggleOff(); CON_ClearHUD(); @@ -1277,7 +1275,6 @@ void F_StartGameEvaluation(void) G_SaveGame((UINT32)cursaveslot); gameaction = ga_nothing; - playerdeadview = false; paused = false; CON_ToggleOff(); CON_ClearHUD(); @@ -1388,7 +1385,6 @@ void F_StartGameEnd(void) G_SetGamestate(GS_GAMEEND); gameaction = ga_nothing; - playerdeadview = false; paused = false; CON_ToggleOff(); CON_ClearHUD(); @@ -1591,7 +1587,6 @@ void F_StartContinue(void) gameaction = ga_nothing; keypressed = false; - playerdeadview = false; paused = false; CON_ToggleOff(); CON_ClearHUD(); @@ -1760,7 +1755,6 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset G_SetGamestate(GS_CUTSCENE); gameaction = ga_nothing; - playerdeadview = false; paused = false; CON_ToggleOff(); diff --git a/src/g_game.c b/src/g_game.c index 4f1c49b4..0e8c14f6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3616,7 +3616,6 @@ void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean mapmusflags |= MUSIC_RELOADRESET; ultimatemode = pultmode; - playerdeadview = false; automapactive = false; imcontinuing = false; diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 7b22f33f..5356ba8a 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -78,9 +78,6 @@ extern boolean chat_on; // set true whenever the tab rankings are being shown for any reason extern boolean hu_showscores; -// P_DeathThink sets this true to show scores while dead, in multiplayer -extern boolean playerdeadview; - // init heads up data at game startup. void HU_Init(void); diff --git a/src/p_user.c b/src/p_user.c index 7abf8534..7e206930 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8648,8 +8648,6 @@ void P_DoPityCheck(player_t *player) // P_PlayerThink // -boolean playerdeadview; // show match/chaos/tag/capture the flag rankings while in death view - void P_PlayerThink(player_t *player) { ticcmd_t *cmd; @@ -8838,10 +8836,6 @@ void P_PlayerThink(player_t *player) if (player->playerstate == PST_DEAD) { player->mo->flags2 &= ~MF2_SHADOW; - // show the multiplayer rankings while dead - if (player == &players[displayplayer]) - playerdeadview = true; - P_DeathThink(player); return; @@ -8862,9 +8856,6 @@ void P_PlayerThink(player_t *player) player->lives = cv_startinglives.value; } - if (player == &players[displayplayer]) - playerdeadview = false; - if ((gametype == GT_RACE || gametype == GT_COMPETITION) && leveltime < 4*TICRATE) { cmd->buttons &= BT_USE; // Remove all buttons except BT_USE From c1d5c711a940fc2e66cbfe53571be01f8bee9420 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 19 Apr 2017 20:00:19 +0100 Subject: [PATCH 48/52] Be gone ye old texture hack --- src/r_data.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index f2c9b146..ee9144b7 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -472,40 +472,22 @@ void R_LoadTextures(void) } else { - UINT16 patchcount = 1; //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height); - if (SHORT(patchlump->width) == 64 - && SHORT(patchlump->height) == 64) - { // 64x64 patch - const column_t *column; - for (k = 0; k < SHORT(patchlump->width); k++) - { // Find use of transparency. - column = (const column_t *)((const UINT8 *)patchlump + LONG(patchlump->columnofs[k])); - if (column->length != SHORT(patchlump->height)) - break; - } - if (k == SHORT(patchlump->width)) - patchcount = 2; // No transparency? 64x128 texture. - } - texture = textures[i] = Z_Calloc(sizeof(texture_t) + (sizeof(texpatch_t) * patchcount), PU_STATIC, NULL); + texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); // Set texture properties. M_Memcpy(texture->name, W_CheckNameForNumPwad((UINT16)w, texstart + j), sizeof(texture->name)); texture->width = SHORT(patchlump->width); - texture->height = SHORT(patchlump->height)*patchcount; - texture->patchcount = patchcount; + texture->height = SHORT(patchlump->height); + texture->patchcount = 1; texture->holes = false; // Allocate information for the texture's patches. - for (k = 0; k < patchcount; k++) - { - patch = &texture->patches[k]; + patch = &texture->patches[0]; - patch->originx = 0; - patch->originy = (INT16)(k*patchlump->height); - patch->wad = (UINT16)w; - patch->lump = texstart + j; - } + patch->originx = patch->originy = 0; + patch->wad = (UINT16)w; + patch->lump = texstart + j; Z_Unlock(patchlump); From 6184f91dd3bd82164282c7379d457ffcea5e5a8c Mon Sep 17 00:00:00 2001 From: Sryder Date: Sat, 13 Oct 2018 23:01:11 +0100 Subject: [PATCH 49/52] Add an int to I_PlaySound to tell an interface which channel number SRB2 is using. I've voided this out on other sound interfaces than SDL Mixer ones because I'm both not sure whether they need it, and not sure how to make them work with it if they do. --- src/djgppdos/i_sound.c | 4 +++- src/dummy/i_sound.c | 3 ++- src/i_sound.h | 2 +- src/nds/i_sound.c | 3 ++- src/s_sound.c | 4 ++-- src/sdl/mixer_sound.c | 4 ++-- src/sdl/sdl_sound.c | 3 ++- src/sdl12/mixer_sound.c | 4 ++-- src/sdl12/sdl_sound.c | 3 ++- src/win32/win_snd.c | 3 ++- src/win32ce/win_snd.c | 4 +++- 11 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 88fc807f..f1e2ad2b 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -165,9 +165,11 @@ INT32 I_StartSound ( sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, - INT32 priority ) + INT32 priority + INT32 channel) { int voice; + (void)channel; if (nosound) return 0; diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index 51dbb610..143da186 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -23,13 +23,14 @@ void I_UpdateSound(void){}; // SFX I/O // -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { (void)id; (void)vol; (void)sep; (void)pitch; (void)priority; + (void)channel; return -1; } diff --git a/src/i_sound.h b/src/i_sound.h index 084479ee..098c9be1 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -64,7 +64,7 @@ void I_ShutdownSound(void); \return sfx handle */ -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority); +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel); /** \brief Stops a sound channel. diff --git a/src/nds/i_sound.c b/src/nds/i_sound.c index 8dea4ad7..a17c7f66 100644 --- a/src/nds/i_sound.c +++ b/src/nds/i_sound.c @@ -21,13 +21,14 @@ void I_ShutdownSound(void){} // SFX I/O // -INT32 I_StartSound(sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, INT32 priority) +INT32 I_StartSound(sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, INT32 priority, INT32 channel) { (void)id; (void)vol; (void)sep; (void)pitch; (void)priority; + (void)channel; return -1; } diff --git a/src/s_sound.c b/src/s_sound.c index 76ee4c64..3b35b36f 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -529,7 +529,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) // Assigns the handle to one of the channels in the // mix/output buffer. - channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority); + channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority, cnum); } dontplay: @@ -579,7 +579,7 @@ dontplay: // Assigns the handle to one of the channels in the // mix/output buffer. - channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority); + channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority, cnum); } void S_StartSound(const void *origin, sfxenum_t sfx_id) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index cfdb3230..4b4ad3e6 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -419,10 +419,10 @@ void I_FreeSfx(sfxinfo_t *sfx) sfx->lumpnum = LUMPERROR; } -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127 - INT32 handle = Mix_PlayChannel(-1, S_sfx[id].data, 0); + INT32 handle = Mix_PlayChannel(channel, S_sfx[id].data, 0); Mix_Volume(handle, volume); Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff)); (void)pitch; // Mixer can't handle pitch diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 6c70c163..a7c8383a 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -604,10 +604,11 @@ void I_FreeSfx(sfxinfo_t * sfx) // Pitching (that is, increased speed of playback) // is set, but currently not used by mixing. // -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { (void)priority; (void)pitch; + (void)channel; if (nosound) return 0; diff --git a/src/sdl12/mixer_sound.c b/src/sdl12/mixer_sound.c index 542a6716..daf09ab9 100644 --- a/src/sdl12/mixer_sound.c +++ b/src/sdl12/mixer_sound.c @@ -376,10 +376,10 @@ void I_FreeSfx(sfxinfo_t *sfx) sfx->data = NULL; } -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127 - INT32 handle = Mix_PlayChannel(-1, S_sfx[id].data, 0); + INT32 handle = Mix_PlayChannel(channel, S_sfx[id].data, 0); Mix_Volume(handle, volume); Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff)); (void)pitch; // Mixer can't handle pitch diff --git a/src/sdl12/sdl_sound.c b/src/sdl12/sdl_sound.c index 6ba83104..01a27153 100644 --- a/src/sdl12/sdl_sound.c +++ b/src/sdl12/sdl_sound.c @@ -621,10 +621,11 @@ void I_FreeSfx(sfxinfo_t * sfx) // Pitching (that is, increased speed of playback) // is set, but currently not used by mixing. // -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { (void)priority; (void)pitch; + (void)channel; if (nosound) return 0; diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 58644457..e50a4737 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -353,12 +353,13 @@ void I_FreeSfx(sfxinfo_t *sfx) sfx->data = NULL; } -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { FMOD_SOUND *sound; FMOD_CHANNEL *chan; INT32 i; float frequency; + (void)channel; sound = (FMOD_SOUND *)S_sfx[id].data; I_Assert(sound != NULL); diff --git a/src/win32ce/win_snd.c b/src/win32ce/win_snd.c index f9c65217..a58bbc3c 100644 --- a/src/win32ce/win_snd.c +++ b/src/win32ce/win_snd.c @@ -538,7 +538,8 @@ INT32 I_StartSound (sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, - INT32 priority) + INT32 priority + INT32 channel) { HRESULT hr; LPDIRECTSOUNDBUFFER dsbuffer; @@ -549,6 +550,7 @@ INT32 I_StartSound (sfxenum_t id, #ifdef SURROUND LPDIRECTSOUNDBUFFER dssurround; #endif + (void)channel; if (nosound) return -1; From 3886888b3014da650aa2ae5bd843b8ef7dcea28f Mon Sep 17 00:00:00 2001 From: Sryder Date: Sun, 14 Oct 2018 10:14:07 +0100 Subject: [PATCH 50/52] Fix missing commas and missed interface --- src/android/i_sound.c | 3 ++- src/djgppdos/i_sound.c | 2 +- src/win32ce/win_snd.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/android/i_sound.c b/src/android/i_sound.c index ecf96f2f..77f8e6a5 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -21,13 +21,14 @@ void I_ShutdownSound(void){} // SFX I/O // -INT32 I_StartSound(sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, INT32 priority) +INT32 I_StartSound(sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, INT32 priority, INT32 channel) { (void)id; (void)vol; (void)sep; (void)pitch; (void)priority; + (void)channel; return -1; } diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index f1e2ad2b..ec6f4412 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -165,7 +165,7 @@ INT32 I_StartSound ( sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, - INT32 priority + INT32 priority, INT32 channel) { int voice; diff --git a/src/win32ce/win_snd.c b/src/win32ce/win_snd.c index a58bbc3c..14ce4add 100644 --- a/src/win32ce/win_snd.c +++ b/src/win32ce/win_snd.c @@ -538,7 +538,7 @@ INT32 I_StartSound (sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, - INT32 priority + INT32 priority, INT32 channel) { HRESULT hr; From 880e4c06313feee422d09da72d065e2ea2e5d326 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 14 Oct 2018 22:32:34 +0100 Subject: [PATCH 51/52] Final weather stuff. * Multiplied rain speed by 3, per Oni's request. * Disable weather density - force to 1 if weather draw distance, otherwise zero * Move the ceilingpic check into a more convenient part of the weather spawning loop. * `drawdist_precip_cons_t` - replaces "Infinite" with "None". * Disable the lowest normal draw distance (256), given... both kart and srb2 are basically unplayable like that. * Disable cv_drawdist_nights entirely. --- src/hardware/hw_main.c | 2 +- src/info.c | 2 +- src/m_menu.c | 12 ++++++------ src/p_mobj.c | 23 ++++++++--------------- src/r_main.c | 23 ++++++++++++++++------- src/r_main.h | 2 +- src/r_things.c | 2 +- 7 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2a23a4d6..c0a3514e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5147,7 +5147,7 @@ static void HWR_AddSprites(sector_t *sec, UINT8 ssplayer) // Handle all things in sector. // If a limit exists, handle things a tiny bit different. - if ((limit_dist = (fixed_t)((maptol & TOL_NIGHTS) ? cv_drawdist_nights.value : cv_drawdist.value) << FRACBITS)) + if ((limit_dist = (fixed_t)(/*(maptol & TOL_NIGHTS) ? cv_drawdist_nights.value : */cv_drawdist.value) << FRACBITS)) { for (thing = sec->thinglist; thing; thing = thing->snext) { diff --git a/src/info.c b/src/info.c index 40327462..932ff21a 100644 --- a/src/info.c +++ b/src/info.c @@ -10755,7 +10755,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound - -24*FRACUNIT, // speed + -72*FRACUNIT, // speed -- -24*FRACUNIT originally, srb2kart x3 (nya) 1*FRACUNIT, // radius 8*FRACUNIT, // height 0, // display offset diff --git a/src/m_menu.c b/src/m_menu.c index 03e74a9a..2f848a2a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1255,14 +1255,14 @@ static menuitem_t OP_VideoOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 45}, //{IT_STRING | IT_CVAR, NULL, "NiGHTS Draw Dist", &cv_drawdist_nights, 55}, {IT_STRING | IT_CVAR, NULL, "Weather Draw Distance",&cv_drawdist_precip, 55}, - {IT_STRING | IT_CVAR, NULL, "Weather Density", &cv_precipdensity, 65}, - {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 75}, + //{IT_STRING | IT_CVAR, NULL, "Weather Density", &cv_precipdensity, 65}, + {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 65}, - {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 90}, - {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 100}, + {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 80}, + {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 90}, #ifdef HWRENDER - {IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 115}, + {IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 105}, #endif }; @@ -1275,7 +1275,7 @@ enum op_video_gamma, op_video_dd, op_video_wdd, - op_video_wd, + //op_video_wd, op_video_skybox, op_video_fps, op_video_vsync, diff --git a/src/p_mobj.c b/src/p_mobj.c index face1cd3..32ac6550 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9744,13 +9744,12 @@ consvar_t cv_suddendeath = {"suddendeath", "Off", CV_NETVAR|CV_CHEAT, CV_OnOff, void P_SpawnPrecipitation(void) { - INT32 i, j, mrand; + INT32 i, mrand; fixed_t basex, basey, x, y, height; subsector_t *precipsector = NULL; precipmobj_t *rainmo = NULL; - if (dedicated || !cv_precipdensity.value || curWeather == PRECIP_NONE - || netgame) // SRB2Kart + if (dedicated || /*!cv_precipdensity*/!cv_drawdist_precip.value || curWeather == PRECIP_NONE) // SRB2Kart return; // Use the blockmap to narrow down our placing patterns @@ -9759,7 +9758,7 @@ void P_SpawnPrecipitation(void) basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE; basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE; - for (j = 0; j < cv_precipdensity.value; ++j) + //for (j = 0; j < cv_precipdensity.value; ++j) -- density is 1 for kart always { x = basex + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3); y = basey + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3); @@ -9769,7 +9768,11 @@ void P_SpawnPrecipitation(void) // No sector? Stop wasting time, // move on to the next entry in the blockmap if (!precipsector) - break; + continue; + + // Not in a sector with visible sky? + if (precipsector->sector->ceilingpic != skyflatnum) + continue; // Exists, but is too small for reasonable precipitation. if (!(precipsector->sector->floorheight <= precipsector->sector->ceilingheight - (32<sector->ceilingpic != skyflatnum) - continue; - rainmo = P_SpawnSnowMobj(x, y, height, MT_SNOWFLAKE); mrand = M_RandomByte(); if (mrand < 64) @@ -9792,13 +9791,7 @@ void P_SpawnPrecipitation(void) P_SetPrecipMobjState(rainmo, S_SNOW2); } else // everything else. - { - // Not in a sector with visible sky. - if (precipsector->sector->ceilingpic != skyflatnum) - continue; - rainmo = P_SpawnRainMobj(x, y, height, MT_RAIN); - } // Randomly assign a height, now that floorz is set. rainmo->z = M_RandomRange(rainmo->floorz>>FRACBITS, rainmo->ceilingz>>FRACBITS)<thinglist; thing; thing = thing->snext) { From 6098a36bfe9d1d3ca136277bfee77a42e680e933 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 14 Oct 2018 23:13:11 +0100 Subject: [PATCH 52/52] More sensible `drawdist_precip_cons_t` maximum (slightly more conservative than Sryder's suggestion) --- src/r_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 68d9cf4d..bd1cd477 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -132,8 +132,7 @@ static CV_PossibleValue_t drawdist_cons_t[] = { static CV_PossibleValue_t drawdist_precip_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, - {8192, "8192"}, {0, "None"}, {0, NULL}}; + {0, "None"}, {0, NULL}}; //static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}}; static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}};