From 0137f2254d1f5b1bc6866566badec65ea536ea26 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 24 Sep 2024 22:18:17 +0200 Subject: [PATCH 01/62] add toggle for water ripples Zzz... --- src/hardware/hw_main.c | 2 +- src/r_main.c | 4 ++++ src/r_main.h | 1 + src/r_plane.c | 53 ++++++++++++++++++++++++------------------ 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c0131ba93..a1bd98a62 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -846,7 +846,7 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc { if (PolyFlags & PF_Fog) shader = SHADER_FOG; - else if (PolyFlags & PF_Ripple) + else if (cv_ripplewater.value && (PolyFlags & PF_Ripple)) shader = SHADER_WATER; else shader = SHADER_FLOOR; diff --git a/src/r_main.c b/src/r_main.c index 5a686fb3b..ba2c3551e 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -213,6 +213,8 @@ consvar_t cv_mobjscaleprecip = {"scaleprecipmobjscale", "Off", CV_SAVE|CV_CALL|C consvar_t cv_grmaxinterpdist = {"gr_maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_ripplewater = {"waterripples", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + // cap fov, fov too high tears software apart. consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL|CV_SAVE, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -1889,6 +1891,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_grmaxinterpdist); + CV_RegisterVar(&cv_ripplewater); + // Default viewheight is changeable, // initialized to standard viewheight //CV_RegisterVar(&cv_viewheight); diff --git a/src/r_main.h b/src/r_main.h index dbf1a141b..34fe686b5 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -124,6 +124,7 @@ extern consvar_t cv_fov; extern consvar_t cv_skybox; extern consvar_t cv_tailspickup; extern consvar_t cv_grmaxinterpdist; +extern consvar_t cv_ripplewater; // Called by startup code. void R_Init(void); diff --git a/src/r_plane.c b/src/r_plane.c index ec5aa90eb..208478440 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -910,34 +910,41 @@ void R_DrawSinglePlane(visplane_t *pl) INT32 top, bottom; UINT8 *scr; - planeripple.active = true; - - if (spanfunc == R_DrawTranslucentSpan_8) + if (cv_ripplewater.value) { - spanfunc = R_DrawTranslucentWaterSpan_8; + planeripple.active = true; - // Copy the current scene, ugh - top = pl->high-8; - bottom = pl->low+8; + if (spanfunc == R_DrawTranslucentSpan_8) + { + spanfunc = R_DrawTranslucentWaterSpan_8; - if (top < 0) - top = 0; - if (bottom > vid.height) - bottom = vid.height; + // Copy the current scene, ugh + top = pl->high-8; + bottom = pl->low+8; - if (splitscreen > 2 && viewplayer == &players[displayplayers[3]]) // Only copy the part of the screen we need - scr = (screens[0] + (top+(viewheight))*vid.width + viewwidth); - else if ((splitscreen == 1 && viewplayer == &players[displayplayers[1]]) - || (splitscreen > 1 && viewplayer == &players[displayplayers[2]])) - scr = (screens[0] + (top+(viewheight))*vid.width); - else if (splitscreen > 1 && viewplayer == &players[displayplayers[1]]) - scr = (screens[0] + ((top)*vid.width) + viewwidth); - else - scr = (screens[0] + ((top)*vid.width)); + if (top < 0) + top = 0; + if (bottom > vid.height) + bottom = vid.height; - VID_BlitLinearScreen(scr, screens[1]+((top)*vid.width), - vid.width, bottom-top, - vid.width, vid.width); + if (splitscreen > 2 && viewplayer == &players[displayplayers[3]]) // Only copy the part of the screen we need + scr = (screens[0] + (top+(viewheight))*vid.width + viewwidth); + else if ((splitscreen == 1 && viewplayer == &players[displayplayers[1]]) + || (splitscreen > 1 && viewplayer == &players[displayplayers[2]])) + scr = (screens[0] + (top+(viewheight))*vid.width); + else if (splitscreen > 1 && viewplayer == &players[displayplayers[1]]) + scr = (screens[0] + ((top)*vid.width) + viewwidth); + else + scr = (screens[0] + ((top)*vid.width)); + + VID_BlitLinearScreen(scr, screens[1]+((top)*vid.width), + vid.width, bottom-top, + vid.width, vid.width); + } + } + else + { + planeripple.active = false; } } #endif From d5c33326357555d012be71fa74a36e54682b4d87 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 24 Sep 2024 22:23:23 +0200 Subject: [PATCH 02/62] those can be static --- src/d_netfil.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 9423a368d..2559cbcf1 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -65,10 +65,10 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid); #ifdef HAVE_CURL size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream); #if defined(CURL_AT_LEAST_VERSION) && CURL_AT_LEAST_VERSION(7, 35, 0) -int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow); +static int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow); #define XFERINFOFUNCTION #else -int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); +static int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); #endif #endif @@ -1203,7 +1203,7 @@ size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream) } #ifdef XFERINFOFUNCTION -int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) +static int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) { time_t curtime; @@ -1228,7 +1228,7 @@ int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow, return 0; } #else -int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) +static int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) { time_t curtime; From d8da0a11a23988bfc629684632001c19a619b5d8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Sep 2024 19:31:07 +0200 Subject: [PATCH 03/62] gamestate resend counter was never proper reset for nodes means it would carry over to the next person occupieing that node and made them have less chances to get the gamestate resent --- src/d_clisrv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 139817d1b..8165d6a1c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4246,6 +4246,7 @@ static void ResetNode(INT32 node) resendingsavegame[node] = false; can_receive_gamestate[node] = false; savegameresendcooldown[node] = 0; + gamestate_resend_counter[node] = 0; #endif // } @@ -5431,6 +5432,7 @@ static void HandlePacketFromPlayer(SINT8 node) DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n", netconsole, realstart, consistancy[realstart%TICQUEUE], SHORT(netbuffer->u.clientpak.consistancy))); + gamestate_resend_counter[node] = 0 break; } } From 7a3ccec38ded7b3a4d7fc3db476a6fe4ccf8d683 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Sep 2024 18:18:34 +0200 Subject: [PATCH 04/62] ; --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8165d6a1c..171d61b01 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5432,7 +5432,7 @@ static void HandlePacketFromPlayer(SINT8 node) DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n", netconsole, realstart, consistancy[realstart%TICQUEUE], SHORT(netbuffer->u.clientpak.consistancy))); - gamestate_resend_counter[node] = 0 + gamestate_resend_counter[node] = 0; break; } } From b3b2b65c5fc1f076e40ac0e85c4b52d25f8a8492 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 04:24:45 +0200 Subject: [PATCH 05/62] reformat this --- src/qs22j.c | 264 ++++++++++++++++++++++++++-------------------------- src/qs22j.h | 18 +++- 2 files changed, 148 insertions(+), 134 deletions(-) diff --git a/src/qs22j.c b/src/qs22j.c index 16dc217bd..24f5de44d 100644 --- a/src/qs22j.c +++ b/src/qs22j.c @@ -24,7 +24,9 @@ #define MEDOF3THRESH 50 // < this use median-of-3 as pivot // larger subfiles use med-of-3-medians +#ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif typedef int32_t WORD; typedef int64_t DWORD; @@ -37,242 +39,240 @@ typedef void *pref_typ; #define ASWAP(a, b, t) ((void)(t = a, a = b, b = t)) #define SWAP(a, b) if (swap_type) swapf(a, b, size);\ - else do {pref_typ t; ASWAP(*(pref_typ*)(a), *(pref_typ*)(b), t);} while (0) + else do {pref_typ t; ASWAP(*(pref_typ*)(a), *(pref_typ*)(b), t);} while (0) #define COMP(a, b) ((*compar)((void *)(a), (void *)(b))) static inline void swapbytes(void *a0, void *b0, size_t n) { - char *a = a0, *b = b0, t; - do {ASWAP(*a, *b, t); a++; b++;} while (--n); + char *a = a0, *b = b0, t; + do {ASWAP(*a, *b, t); a++; b++;} while (--n); } static inline void swapdword(void *a0, void *b0, size_t n) { - DWORD *a = a0, *b = b0, t; - ASWAP(*a, *b, t); - (void)n; + DWORD *a = a0, *b = b0, t; + ASWAP(*a, *b, t); + (void)n; } static inline void swapdwords(void *a0, void *b0, size_t n) { - DWORD *a = a0, *b = b0, t; - do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(DWORD)); + DWORD *a = a0, *b = b0, t; + do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(DWORD)); } static inline void swapword(void *a0, void *b0, size_t n) { - WORD *a = a0, *b = b0, t; - ASWAP(*a, *b, t); - (void)n; + WORD *a = a0, *b = b0, t; + ASWAP(*a, *b, t); + (void)n; } static inline void swapwords(void *a0, void *b0, size_t n) { - WORD *a = a0, *b = b0, t; - do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(WORD)); + WORD *a = a0, *b = b0, t; + do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(WORD)); } typedef void (*swapf_typ)(void *, void *, size_t); static inline char *med3(char *a, char *b, char *c, int (*compar)(const void *, const void *)) { - return COMP(a, b) < 0 ? - (COMP(b, c) < 0 ? b : COMP(a, c) < 0 ? c : a) : - (COMP(b, c) > 0 ? b : COMP(a, c) > 0 ? c : a); + return COMP(a, b) < 0 ? + (COMP(b, c) < 0 ? b : COMP(a, c) < 0 ? c : a) : + (COMP(b, c) > 0 ? b : COMP(a, c) > 0 ? c : a); } void qs22j(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { - char *stack[2*8*sizeof(size_t)], **sp = stack; // stack and stack pointer - char *left = base; // set up char * base pointer - char *limit = left + nmemb * size; // pointer past end of array - char *i, *ii, *j, *jj; // scan pointers - int ki = 0, kj = 0; - int swap_type = 1; - swapf_typ swapf, vecswapf; + char *stack[2*8*sizeof(size_t)], **sp = stack; // stack and stack pointer + char *left = base; // set up char * base pointer + char *limit = left + nmemb * size; // pointer past end of array + char *i, *ii, *j, *jj; // scan pointers + int ki = 0, kj = 0; + int swap_type = 1; + swapf_typ swapf, vecswapf; - vecswapf = swapf = swapbytes; - if ((ptr_to_int(left) | size) % sizeof(WORD)) + vecswapf = swapf = swapbytes; + if ((ptr_to_int(left) | size) % sizeof(WORD)) { - ; // unaligned or not multple of WORD size; swap bytes - } + ; // unaligned or not multple of WORD size; swap bytes + } else if (size == sizeof(DWORD)) { - swapf = swapdword; - vecswapf = swapdwords; - if (size == sizeof(pref_typ)) - swap_type = 0; - } + swapf = swapdword; + vecswapf = swapdwords; + if (size == sizeof(pref_typ)) + swap_type = 0; + } else if (size == sizeof(WORD)) { - swapf = swapword; - vecswapf = swapwords; - if (size == sizeof(pref_typ)) - swap_type = 0; + swapf = swapword; + vecswapf = swapwords; + if (size == sizeof(pref_typ)) + swap_type = 0; } else if ((size % sizeof(DWORD)) == 0) { - swapf = vecswapf = swapdwords; - } + swapf = vecswapf = swapdwords; + } else if ((size % sizeof(WORD)) == 0) { - swapf = vecswapf = swapwords; - } - for (;;) + swapf = vecswapf = swapwords; + } + for (;;) { - nmemb = (limit - left) / size; - for (i = left + size; i < limit && COMP(i - size, i) <= 0; i += size) - ; + nmemb = (limit - left) / size; + for (i = left + size; i < limit && COMP(i - size, i) <= 0; i += size) + ; - if (i == limit) // if already in order - goto pop; + if (i == limit) // if already in order + goto pop; - if (nmemb >= INSORTTHRESH) // otherwise use insertion sort + if (nmemb >= INSORTTHRESH) // otherwise use insertion sort { - char *right = limit - size; - // best so far? fewer compares, a few more swaps - char *p = left + (nmemb / 2) * size; - if (nmemb >= MIDTHRESH) + char *right = limit - size; + // best so far? fewer compares, a few more swaps + char *p = left + (nmemb / 2) * size; + if (nmemb >= MIDTHRESH) { - char *pleft = left + size; - char *pright = right - size; + char *pleft = left + size; + char *pright = right - size; - if (nmemb >= MEDOF3THRESH) + if (nmemb >= MEDOF3THRESH) { - size_t k = (nmemb / 8) * size; - pleft = med3(pleft, left + k, left + k * 2, compar); - p = med3(p - k, p, p + k, compar); - pright = med3(right - k * 2, right - k, pright, compar); - } + size_t k = (nmemb / 8) * size; + pleft = med3(pleft, left + k, left + k * 2, compar); + p = med3(p - k, p, p + k, compar); + pright = med3(right - k * 2, right - k, pright, compar); + } - p = med3(pleft, p, pright, compar); - } + p = med3(pleft, p, pright, compar); + } - i = ii = left; // i scans left to right - j = jj = right; // j scans right to left + i = ii = left; // i scans left to right + j = jj = right; // j scans right to left for (;;) { - while (i <= j) { if (i != p && ((ki = COMP(i, p)) >= 0)) { - if (ki) - break; + if (ki) + break; if (ii == p) { - p = i; + p = i; } else if (i != ii) { - SWAP(i, ii); + SWAP(i, ii); } - ii += size; - } - i += size; - } + ii += size; + } + i += size; + } - while (i < j) + while (i < j) { - if (j != p && ((kj = COMP(j, p)) <= 0)) + if (j != p && ((kj = COMP(j, p)) <= 0)) { - if (kj) - break; + if (kj) + break; - if (jj == p) + if (jj == p) { - p = j; + p = j; } - else if (j != jj) + else if (j != jj) { - SWAP(j, jj); + SWAP(j, jj); } - jj -= size; - } - j -= size; - } + jj -= size; + } + j -= size; + } - if (i >= j) - break; + if (i >= j) + break; - SWAP(i, j); - i += size; - j -= size; - } + SWAP(i, j); + i += size; + j -= size; + } - if (p < i) - i -= size; + if (p < i) + i -= size; if (p != i) { SWAP(p, i); } - ptrdiff_t lessthan = i - ii; - size_t k = min(lessthan, ii - left); + ptrdiff_t lessthan = i - ii; + size_t k = min(lessthan, ii - left); - if (k) - vecswapf(left, i - k, k); + if (k) + vecswapf(left, i - k, k); - ptrdiff_t morethan = jj - i; - k = min(morethan, right - jj); + ptrdiff_t morethan = jj - i; + k = min(morethan, right - jj); - if (k) - vecswapf(i + size, limit - k, k); + if (k) + vecswapf(i + size, limit - k, k); - if (lessthan > morethan) + if (lessthan > morethan) { - if (lessthan > 1) + if (lessthan > 1) { - sp[0] = left; - sp[1] = left + lessthan; - sp += 2; // increment stack pointer - } + sp[0] = left; + sp[1] = left + lessthan; + sp += 2; // increment stack pointer + } - if (morethan <= 1) - goto pop; + if (morethan <= 1) + goto pop; - left = limit - morethan; + left = limit - morethan; } else { - if (morethan > 1) + if (morethan > 1) { - sp[0] = limit - morethan; - sp[1] = limit; - sp += 2; // increment stack pointer - } + sp[0] = limit - morethan; + sp[1] = limit; + sp += 2; // increment stack pointer + } - if (lessthan <= 1) - goto pop; + if (lessthan <= 1) + goto pop; - limit = left + lessthan; - } - - } + limit = left + lessthan; + } + } else // else subfile is small, use insertion sort { - for (i = left + size; i < limit; i += size) + for (i = left + size; i < limit; i += size) { - for (j = i; j != left && COMP(j - size, j) > 0; j -= size) + for (j = i; j != left && COMP(j - size, j) > 0; j -= size) { - SWAP(j - size, j); - } - } + SWAP(j - size, j); + } + } pop: - if (sp != stack) // if any entries on stack + if (sp != stack) // if any entries on stack { - sp -= 2; // pop the left and limit - left = sp[0]; - limit = sp[1]; - } - else // else stack empty, done - break; + sp -= 2; // pop the left and limit + left = sp[0]; + limit = sp[1]; + } + else // else stack empty, done + break; } } } diff --git a/src/qs22j.h b/src/qs22j.h index 95d1c1292..c388b9c46 100644 --- a/src/qs22j.h +++ b/src/qs22j.h @@ -1,7 +1,21 @@ +// License: 0BSD +// +// Copyright 2022 Raymond Gardner +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + #ifndef __QS22J__ #define __QS22J__ - void qs22j(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); - #endif From c3b6121968d00376e8e50aa3f03e2b66580c2253 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 04:26:43 +0200 Subject: [PATCH 06/62] forgor this --- src/qs22j.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qs22j.c b/src/qs22j.c index 24f5de44d..17f2b7c2e 100644 --- a/src/qs22j.c +++ b/src/qs22j.c @@ -18,11 +18,11 @@ #include #include "qs22j.h" -#define INSORTTHRESH 5 // if n < this use insertion sort - // MUST be >= 2 -#define MIDTHRESH 20 // < this use middle as pivot -#define MEDOF3THRESH 50 // < this use median-of-3 as pivot - // larger subfiles use med-of-3-medians +#define INSORTTHRESH 5 // if n < this use insertion sort + // MUST be >= 2 +#define MIDTHRESH 20 // < this use middle as pivot +#define MEDOF3THRESH 50 // < this use median-of-3 as pivot + // larger subfiles use med-of-3-medians #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) @@ -41,7 +41,7 @@ typedef void *pref_typ; #define SWAP(a, b) if (swap_type) swapf(a, b, size);\ else do {pref_typ t; ASWAP(*(pref_typ*)(a), *(pref_typ*)(b), t);} while (0) -#define COMP(a, b) ((*compar)((void *)(a), (void *)(b))) +#define COMP(a, b) ((*compar)((void *)(a), (void *)(b))) static inline void swapbytes(void *a0, void *b0, size_t n) { @@ -51,9 +51,9 @@ static inline void swapbytes(void *a0, void *b0, size_t n) static inline void swapdword(void *a0, void *b0, size_t n) { + (void)n; DWORD *a = a0, *b = b0, t; ASWAP(*a, *b, t); - (void)n; } static inline void swapdwords(void *a0, void *b0, size_t n) @@ -64,9 +64,9 @@ static inline void swapdwords(void *a0, void *b0, size_t n) static inline void swapword(void *a0, void *b0, size_t n) { + (void)n; WORD *a = a0, *b = b0, t; ASWAP(*a, *b, t); - (void)n; } static inline void swapwords(void *a0, void *b0, size_t n) From 7a832df4d37a425ba8acfcb2aede213603225fef Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 15:05:31 +0200 Subject: [PATCH 07/62] cleanup + reformatting --- src/hardware/hw_main.c | 129 ++++++++++++++++++++--------------------- src/r_bsp.c | 3 +- src/v_video.c | 26 ++++----- 3 files changed, 75 insertions(+), 83 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a1bd98a62..0bb78bee5 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -195,7 +195,7 @@ static void CV_grshaders_OnChange(void) { ONLY_IF_GL_LOADED HWR_SetShaderState(); - if ((cv_grpaletterendering.value)) + if (cv_grpaletterendering.value) { // can't do palette rendering without shaders, so update the state if needed HWR_TogglePaletteRendering(); @@ -205,7 +205,6 @@ static void CV_grshaders_OnChange(void) static void CV_grpaletterendering_OnChange(void) { ONLY_IF_GL_LOADED - if (cv_grscreentextures.value != 2) // can't do palette rendering without screen textures CV_Set(&cv_grpaletterendering, "Off"); @@ -573,11 +572,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col Surface->LightInfo.light_level = light_level; Surface->LightInfo.fade_start = (colormap != NULL) ? colormap->fadestart : 0; Surface->LightInfo.fade_end = (colormap != NULL) ? colormap->fadeend : 31; - - if (HWR_ShouldUsePaletteRendering()) - Surface->LightTableId = HWR_GetLightTableID(colormap); - else - Surface->LightTableId = 0; + Surface->LightTableId = HWR_ShouldUsePaletteRendering() ? HWR_GetLightTableID(colormap) : 0; } UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if this can work @@ -3382,13 +3377,13 @@ static gr_vissprite_t gr_overflowsprite; static gr_vissprite_t *HWR_GetVisSprite(UINT32 num) { - UINT32 chunk = num >> VISSPRITECHUNKBITS; + UINT32 chunk = num >> VISSPRITECHUNKBITS; - // Allocate chunk if necessary - if (!gr_visspritechunks[chunk]) - Z_Malloc(sizeof(gr_vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &gr_visspritechunks[chunk]); + // Allocate chunk if necessary + if (!gr_visspritechunks[chunk]) + Z_Malloc(sizeof(gr_vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &gr_visspritechunks[chunk]); - return gr_visspritechunks[chunk] + (num & VISSPRITEINDEXMASK); + return gr_visspritechunks[chunk] + (num & VISSPRITEINDEXMASK); } static gr_vissprite_t *HWR_NewVisSprite(void) @@ -3764,15 +3759,13 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); // push it toward the camera to mitigate floor-clipping sprites + float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->gzt - gr_viewz)*(spr->gzt - gr_viewz)); + float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; + for (i = 0; i < 4; i++) { - float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->gzt - gr_viewz)*(spr->gzt - gr_viewz)); - float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; - for (i = 0; i < 4; i++) - { - baseWallVerts[i].x += (gr_viewx - baseWallVerts[i].x)*distfact; - baseWallVerts[i].z += (gr_viewy - baseWallVerts[i].z)*distfact; - baseWallVerts[i].y += (gr_viewz - baseWallVerts[i].y)*distfact; - } + baseWallVerts[i].x += (gr_viewx - baseWallVerts[i].x)*distfact; + baseWallVerts[i].z += (gr_viewy - baseWallVerts[i].z)*distfact; + baseWallVerts[i].y += (gr_viewz - baseWallVerts[i].y)*distfact; } realtop = top = baseWallVerts[3].y; @@ -3957,6 +3950,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) FOutVector wallVerts[4]; GLPatch_t *gpatch; // sprite patch converted to hardware FSurfaceInfo Surf; + FBITFIELD blend = 0; INT32 shader = SHADER_NONE; @@ -4039,16 +4033,14 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) HWR_RotateSpritePolyToAim(spr, wallVerts, false); // push it toward the camera to mitigate floor-clipping sprites + float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->gzt - gr_viewz)*(spr->gzt - gr_viewz)); + float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; + size_t i; + for (i = 0; i < 4; i++) { - float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->gzt - gr_viewz)*(spr->gzt - gr_viewz)); - float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; - size_t i; - for (i = 0; i < 4; i++) - { - wallVerts[i].x += (gr_viewx - wallVerts[i].x)*distfact; - wallVerts[i].z += (gr_viewy - wallVerts[i].z)*distfact; - wallVerts[i].y += (gr_viewz - wallVerts[i].y)*distfact; - } + wallVerts[i].x += (gr_viewx - wallVerts[i].x)*distfact; + wallVerts[i].z += (gr_viewy - wallVerts[i].z)*distfact; + wallVerts[i].y += (gr_viewz - wallVerts[i].y)*distfact; } // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. @@ -4065,38 +4057,35 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) HWR_Lighting(&Surf, lightlevel, colormap); + if (!cv_translucency.value) // translucency disabled { - FBITFIELD blend = 0; - if (!cv_translucency.value) // translucency disabled - { - Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; - } - else if (spr->mobj->flags2 & MF2_SHADOW) - { - Surf.PolyColor.s.alpha = 0x40; - blend = PF_Translucent; - } - else if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); - else - { - // BP: i agree that is little better in environement but it don't - // work properly under glide nor with fogcolor to ffffff :( - // Hurdler: PF_Environement would be cool, but we need to fix - // the issue with the fog before - Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; - } - - if (HWR_UseShader()) - { - shader = SHADER_SPRITE; - blend |= PF_ColorMapped; - } - - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); + Surf.PolyColor.s.alpha = 0xFF; + blend = PF_Translucent|PF_Occlude; } + else if (spr->mobj->flags2 & MF2_SHADOW) + { + Surf.PolyColor.s.alpha = 0x40; + blend = PF_Translucent; + } + else if (spr->mobj->frame & FF_TRANSMASK) + blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + else + { + // BP: i agree that is little better in environement but it don't + // work properly under glide nor with fogcolor to ffffff :( + // Hurdler: PF_Environement would be cool, but we need to fix + // the issue with the fog before + Surf.PolyColor.s.alpha = 0xFF; + blend = PF_Translucent|PF_Occlude; + } + + if (HWR_UseShader()) + { + shader = SHADER_SPRITE; + blend |= PF_ColorMapped; + } + + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); } // Sprite drawer for precipitation @@ -4467,8 +4456,9 @@ static void HWR_RenderDrawNodes(void) if (!(plane->blend & PF_NoTexture)) HWR_GetFlat(plane->lumpnum, R_NoEncore(plane->FOFSector, plane->isceiling)); + HWR_RenderPlane(NULL, plane->xsub, plane->isceiling, plane->fixedheight, plane->blend, plane->lightlevel, - plane->lumpnum, plane->FOFSector, plane->alpha, plane->planecolormap); + plane->lumpnum, plane->FOFSector, plane->alpha, plane->planecolormap); } else if (drawnode->type == DRAWNODE_POLYOBJECT_PLANE) { @@ -4479,8 +4469,9 @@ static void HWR_RenderDrawNodes(void) if (!(polyplane->blend & PF_NoTexture)) HWR_GetFlat(polyplane->lumpnum, R_NoEncore(polyplane->FOFSector, polyplane->isceiling)); + HWR_RenderPolyObjectPlane(polyplane->polysector, polyplane->isceiling, polyplane->fixedheight, polyplane->blend, polyplane->lightlevel, - polyplane->lumpnum, polyplane->FOFSector, polyplane->alpha, polyplane->planecolormap); + polyplane->lumpnum, polyplane->FOFSector, polyplane->alpha, polyplane->planecolormap); } else if (drawnode->type == DRAWNODE_WALL) { @@ -4488,8 +4479,9 @@ static void HWR_RenderDrawNodes(void) if (!(wall->blend & PF_NoTexture)) HWR_GetTexture(wall->texnum, wall->noencore); + HWR_RenderWall(wall->wallVerts, &wall->Surf, wall->blend, wall->fogwall, - wall->lightlevel, wall->wallcolormap); + wall->lightlevel, wall->wallcolormap); } } @@ -4799,8 +4791,8 @@ void HWR_ProjectSprite(mobj_t *thing) flip ^= (1<skin && ((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->flags & SF_HIRES) - this_scale *= FIXED_TO_FLOAT(((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->highresscale); + if (thing->skin && ((skin_t *)(thing->localskin ? thing->localskin : thing->skin))->flags & SF_HIRES) + this_scale *= FIXED_TO_FLOAT(((skin_t *)(thing->localskin ? thing->localskin : thing->skin))->highresscale); spr_width = spritecachedinfo[lumpoff].width; spr_height = spritecachedinfo[lumpoff].height; @@ -4921,6 +4913,7 @@ void HWR_ProjectSprite(mobj_t *thing) FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) : gzt < FIXED_TO_FLOAT(sectors[heightsec].floorheight)) return; + if (gr_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ? gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gr_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) : FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight)) @@ -5377,9 +5370,10 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe gl_portallist_t portallist; gl_portal_t *portal; gl_portal_t *gl_portal_temp; - portallist.base = portallist.cap = NULL; const boolean skybox = (skyboxmo[0] && cv_skybox.value); - boolean useportals = gr_maphasportals && cv_grportals.value && allow_portals; + const boolean useportals = cv_grportals.value && gr_maphasportals && allow_portals; + + portallist.base = portallist.cap = NULL; if (useportals && stencil_level < cv_maxportals.value) // if recursion limit is not reached { @@ -5388,6 +5382,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe gr_portal = GRPORTAL_SEARCH; HWR_ClearClipper(); + if (!rootportal) portalclipline = NULL; else @@ -5845,7 +5840,7 @@ void HWR_DoPostProcessor(player_t *player) // Armageddon Blast Flash! // Could this even be considered postprocessor? - if ((player->flashcount) && (!HWR_PalRenderFlashpal())) + if (!HWR_PalRenderFlashpal() && player->flashcount) { FOutVector v[4]; FSurfaceInfo Surf; diff --git a/src/r_bsp.c b/src/r_bsp.c index 54d6cada1..d1ceadbf4 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1333,8 +1333,7 @@ void R_RenderBSPNode(INT32 bspnum) // PORTAL CULLING if (portalcullsector) { - sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector; - if (sect != portalcullsector) + if (subsectors[bspnum & ~NF_SUBSECTOR].sector != portalcullsector) return; portalcullsector = NULL; } diff --git a/src/v_video.c b/src/v_video.c index 5746d963e..ee9cfa5f9 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1611,21 +1611,19 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength) } #endif - { - const UINT8 *fadetable = - (color > 0xFFF0) // Grab a specific colormap palette? - ? R_GetTranslationColormap(color | 0xFFFF0000, strength, GTC_CACHE) - : ((color & 0xFF00) // Color is not palette index? - ? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade. - : ((UINT8 *)transtables + ((9-strength)< 0xFFF0) // Grab a specific colormap palette? + ? R_GetTranslationColormap(color | 0xFFFF0000, strength, GTC_CACHE) + : ((color & 0xFF00) // Color is not palette index? + ? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade. + : ((UINT8 *)transtables + ((9-strength)< Date: Fri, 27 Sep 2024 05:19:52 +0200 Subject: [PATCH 08/62] use qs22j here again it is really faster thought it wasnt in this case --- src/d_net.c | 8 ++++---- src/hardware/hw_main.c | 3 +-- src/p_polyobj.c | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index ad031a76b..a8602f567 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1446,13 +1446,13 @@ void Command_Ping_f(void) } } - if (f_width < 10) f_width = 1; + if (f_width < 10) f_width = 1; else if (f_width < 100) f_width = 2; - else f_width = 3; + else f_width = 3; - if (ms_width < 10) ms_width = 1; + if (ms_width < 10) ms_width = 1; else if (ms_width < 100) ms_width = 2; - else ms_width = 3; + else ms_width = 3; qsort(pingv, pingc, sizeof (struct pingcell), &pingcellcmp); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0bb78bee5..30c6f7454 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -12,7 +12,6 @@ /// \brief hardware renderer, using the standard HardWareRender driver DLL for SRB2 #include -#include // qsort #include "../doomstat.h" @@ -4227,7 +4226,7 @@ static void HWR_SortVisSprites(void) gr_vsprorder[i] = HWR_GetVisSprite(i); } - qsort(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites); + qs22j(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites); } // A drawnode is something that points to a 3D floor, 3D side, or masked diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 7a21497e3..f890b0bd0 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -28,6 +28,7 @@ #include "r_main.h" #include "r_state.h" #include "r_defs.h" +#include "qs22j.h" /* @@ -580,7 +581,7 @@ static void Polyobj_findExplicit(polyobj_t *po) // sort the array if necessary if (numSegItems >= 2) - qsort(segitems, numSegItems, sizeof(segitem_t), Polyobj_segCompare); + qs22j(segitems, numSegItems, sizeof(segitem_t), Polyobj_segCompare); // second loop: put the sorted segs into the polyobject for (i = 0; i < numSegItems; ++i) From 1c6fce9339bfa25adae5eff9b65e4d7ba46fdedd Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 15:04:01 +0200 Subject: [PATCH 09/62] fix encore minimap --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 5128093f6..44497b0f2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9731,7 +9731,7 @@ static void K_drawKartMinimap(void) splitflags |= minimaptrans; if (encoremode) - V_DrawScaledPatch(x+SHORT(minimapinfo.minimap_pic->width), y, minimaptrans|V_FLIP, minimapinfo.minimap_pic); + V_DrawScaledPatch(x+SHORT(minimapinfo.minimap_pic->width), y, splitflags|V_FLIP, minimapinfo.minimap_pic); else V_DrawScaledPatch(x, y, splitflags, minimapinfo.minimap_pic); From 48e71afec13d8a414fa8179791355eda956d8e68 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 18:21:17 +0200 Subject: [PATCH 10/62] update lzf compression to 1.6 --- src/lzf.c | 528 +++++++++++++++++++++++++++++++++++------------------- src/lzf.h | 4 +- 2 files changed, 346 insertions(+), 186 deletions(-) diff --git a/src/lzf.c b/src/lzf.c index f81c3ee0a..eb0d73b78 100644 --- a/src/lzf.c +++ b/src/lzf.c @@ -37,9 +37,8 @@ /* * Sacrifice very little compression quality in favour of compression speed. * This gives almost the same compression as the default code, and is - * (very roughly) 15% faster. This is the preferable mode of operation. + * (very roughly) 15% faster. This is the preferred mode of operation. */ - #ifndef VERY_FAST # define VERY_FAST 1 #endif @@ -48,7 +47,7 @@ * Sacrifice some more compression quality in favour of compression speed. * (roughly 1-2% worse compression for large blocks and * 9-10% for small, redundant, blocks and >>20% better speed in both cases) - * In INT16: when in need for speed, enable this for binary data, + * In short: when in need for speed, enable this for binary data, * possibly disable this for text data. */ #ifndef ULTRA_FAST @@ -66,21 +65,10 @@ #endif #endif -/* - * Use string functions to copy memory. - * this is usually a loss, even with glibc's optimized memcpy - */ -#ifndef USE_MEMCPY -#ifdef _MSC_VER -# define USE_MEMCPY 0 -#else -# define USE_MEMCPY 1 -#endif -#endif - /* * You may choose to pre-set the hash table (might be faster on some - * modern cpus and large (>>64k) blocks) + * modern cpus and large (>>64k) blocks, and also makes compression + * deterministic/repeatable when the configuration otherwise is the same). */ #ifndef INIT_HTAB # define INIT_HTAB 1 @@ -88,15 +76,15 @@ /* * Avoid assigning values to errno variable? for some embedding purposes - * (linux kernel for example), this is neccessary. NOTE: this breaks - * the documentation in lzf.h. + * (linux kernel for example), this is necessary. NOTE: this breaks + * the documentation in lzf.h. Avoiding errno has no speed impact. */ #ifndef AVOID_ERRNO # define AVOID_ERRNO 0 #endif /* - * Wether to pass the LZF_STATE variable as argument, or allocate it + * Whether to pass the LZF_STATE variable as argument, or allocate it * on the stack. For small-stack environments, define this to 1. * NOTE: this breaks the prototype in lzf.h. */ @@ -105,51 +93,109 @@ #endif /* - * Wether to add extra checks for input validity in lzf_decompress + * Whether to add extra checks for input validity in lzf_decompress * and return EINVAL if the input stream has been corrupted. This * only shields against overflowing the input buffer and will not * detect most corrupted streams. - * This check is not normally noticable on modern hardware + * This check is not normally noticeable on modern hardware * (<1% slowdown), but might slow down older cpus considerably. */ #ifndef CHECK_INPUT # define CHECK_INPUT 1 #endif +/* + * Whether the target CPU has a slow multiplication. This affects + * the default hash function for the compressor, and enables a slightly + * worse hash function that needs only shifts. + */ +#ifndef MULTIPLICATION_IS_SLOW +# define MULTIPLICATION_IS_SLOW 0 +#endif + +/* + * If defined, then this data type will be used for storing offsets. + * This can be useful if you want to use a huge hashtable, want to + * conserve memory, or both, and your data fits into e.g. 64kb. + * If instead you want to compress data > 4GB, then it's better to + * to "#define LZF_USE_OFFSETS 0" instead. + */ +/*#define LZF_HSLOT unsigned short*/ + +/* + * Whether to store pointers or offsets inside the hash table. On + * 64 bit architetcures, pointers take up twice as much space, + * and might also be slower. Default is to autodetect. + */ +/*#define LZF_USE_OFFSETS autodetect */ + +/* + * Whether to optimise code for size, at the expense of speed. Use + * this when you are extremely tight on memory, perhaps in combination + * with AVOID_ERRNO 1 and CHECK_INPUT 0. + */ +#ifndef OPTIMISE_SIZE +# ifdef __OPTIMIZE_SIZE__ +# define OPTIMISE_SIZE 1 +# else +# define OPTIMISE_SIZE 0 +# endif +#endif + /*****************************************************************************/ /* nothing should be changed below */ -typedef unsigned char u8; - -typedef const u8 *LZF_STATE[1 << (HLOG)]; - -#if !STRICT_ALIGN -/* for unaligned accesses we need a 16 bit datatype. */ +# include # include -# if USHRT_MAX == 65535 - typedef unsigned short u16; -# elif UINT_MAX == 65535 - typedef unsigned int u16; -# else -# undef STRICT_ALIGN -# define STRICT_ALIGN 1 -# endif -#endif #if ULTRA_FAST -# if defined(VERY_FAST) -# undef VERY_FAST +# undef VERY_FAST +#endif + +#ifndef LZF_USE_OFFSETS +# ifdef _WIN32 +# define LZF_USE_OFFSETS defined(_M_X64) +# else +# include +# define LZF_USE_OFFSETS (UINTPTR_MAX > 0xffffffffU) # endif #endif -#if USE_MEMCPY || INIT_HTAB -# ifdef __cplusplus -# include +typedef unsigned char u8; + +#ifdef LZF_HSLOT +# define LZF_HSLOT_BIAS ((const u8 *)in_data) +#else +# if LZF_USE_OFFSETS +# define LZF_HSLOT_BIAS ((const u8 *)in_data) + typedef unsigned int LZF_HSLOT; # else -# include +# define LZF_HSLOT_BIAS 0 + typedef const u8 *LZF_HSLOT; # endif #endif +#if USHRT_MAX == 65535 + typedef unsigned short u16; +#elif UINT_MAX == 65535 + typedef unsigned int u16; +#else +# undef STRICT_ALIGN +# define STRICT_ALIGN 1 +#endif + +#define LZF_MAX_LIT (1 << 5) +#define LZF_MAX_OFF (1 << 13) +#define LZF_MAX_REF ((1 << 8) + (1 << 3)) + +typedef LZF_HSLOT LZF_STATE[1 << (HLOG)]; + +typedef struct +{ + const u8 *first [1 << (6+8)]; /* most recent occurance of a match */ + u16 prev [LZF_MAX_OFF]; /* how many bytes to go backwards for the next match */ +} LZF_STATE_BEST[1]; + #endif @@ -164,14 +210,31 @@ typedef const u8 *LZF_STATE[1 << (HLOG)]; # define SET_ERRNO(n) errno = (n) #endif +#ifndef USE_REP_MOVSB +#if (defined (__i386) || defined (__amd64)) && __GNUC__ >= 3 +#define USE_REP_MOVSB 1 +#else +#define USE_REP_MOVSB 0 // Default to 0 if not defined elsewhere +#endif +#endif + +#if USE_REP_MOVSB /* small win on amd, big loss on intel */ +#if (defined (__i386) || defined (__amd64)) && __GNUC__ >= 3 +# define lzf_movsb(dst, src, len) \ + asm ("rep movsb" \ + : "=D" (dst), "=S" (src), "=c" (len) \ + : "0" (dst), "1" (src), "2" (len)); +#endif +#endif + size_t lzf_decompress (const void *const in_data, size_t in_len, - void *out_data, size_t out_len) + void *out_data, size_t out_len) { u8 const *ip = (const u8 *)in_data; - u8 *op = (u8 *)out_data; + u8 *op = (u8 *)out_data; u8 const *const in_end = ip + in_len; - u8 *const out_end = op + out_len; + u8 *const out_end = op + out_len; do { @@ -195,14 +258,23 @@ lzf_decompress (const void *const in_data, size_t in_len, } #endif -#if USE_MEMCPY - M_Memcpy (op, ip, ctrl); - op += ctrl; - ip += ctrl; -#else - do +#ifdef lzf_movsb + lzf_movsb (op, ip, ctrl); +#elif OPTIMISE_SIZE + while (ctrl--) *op++ = *ip++; - while (--ctrl); +#else + switch (ctrl) + { + case 32: *op++ = *ip++; case 31: *op++ = *ip++; case 30: *op++ = *ip++; case 29: *op++ = *ip++; + case 28: *op++ = *ip++; case 27: *op++ = *ip++; case 26: *op++ = *ip++; case 25: *op++ = *ip++; + case 24: *op++ = *ip++; case 23: *op++ = *ip++; case 22: *op++ = *ip++; case 21: *op++ = *ip++; + case 20: *op++ = *ip++; case 19: *op++ = *ip++; case 18: *op++ = *ip++; case 17: *op++ = *ip++; + case 16: *op++ = *ip++; case 15: *op++ = *ip++; case 14: *op++ = *ip++; case 13: *op++ = *ip++; + case 12: *op++ = *ip++; case 11: *op++ = *ip++; case 10: *op++ = *ip++; case 9: *op++ = *ip++; + case 8: *op++ = *ip++; case 7: *op++ = *ip++; case 6: *op++ = *ip++; case 5: *op++ = *ip++; + case 4: *op++ = *ip++; case 3: *op++ = *ip++; case 2: *op++ = *ip++; case 1: *op++ = *ip++; + } #endif } else /* back reference */ @@ -244,12 +316,49 @@ lzf_decompress (const void *const in_data, size_t in_len, return 0; } - *op++ = *ref++; - *op++ = *ref++; +#ifdef lzf_movsb + len += 2; + lzf_movsb (op, ref, len); +#elif OPTIMISE_SIZE + len += 2; do *op++ = *ref++; while (--len); +#else + switch (len) + { + default: + len += 2; + + if (op >= ref + len) + { + /* disjunct areas */ + memcpy (op, ref, len); + op += len; + } + else + { + /* overlapping, use octet by octet copying */ + do + *op++ = *ref++; + while (--len); + } + break; + + case 9: *op++ = *ref++; + case 8: *op++ = *ref++; + case 7: *op++ = *ref++; + case 6: *op++ = *ref++; + case 5: *op++ = *ref++; + case 4: *op++ = *ref++; + case 3: *op++ = *ref++; + case 2: *op++ = *ref++; + case 1: *op++ = *ref++; + case 0: *op++ = *ref++; /* two octets more */ + *op++ = *ref++; + } +#endif } } while (ip < in_end); @@ -266,23 +375,29 @@ lzf_decompress (const void *const in_data, size_t in_len, /* * don't play with this unless you benchmark! - * decompression is not dependent on the hash function - * the hashing function might seem strange, just believe me + * the data format is not dependent on the hash function. + * the hash function might seem strange, just believe me, * it works ;) */ #ifndef FRST # define FRST(p) (((p[0]) << 8) | p[1]) # define NEXT(v,p) (((v) << 8) | p[2]) -# define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1)) -#endif -/* - * IDX works because it is very similar to a multiplicative hash, e.g. - * ((h * 57321 >> (3*8 - HLOG)) & (HSIZE - 1)) - * the latter is also quite fast on newer CPUs, and sligthly better - * - * the next one is also quite good, albeit slow ;) - * (int)(cos(h & 0xffffff) * 1e6) +# if MULTIPLICATION_IS_SLOW +# if ULTRA_FAST +# define IDX(h) ((( h >> (3*8 - HLOG)) - h ) & (HSIZE - 1)) +# elif VERY_FAST +# define IDX(h) ((( h >> (3*8 - HLOG)) - h*5) & (HSIZE - 1)) +# else +# define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1)) +# endif +# else +/* this one was developed with sesse, + * and is very similar to the one in snappy. + * it does need a modern enough cpu with a fast multiplication. */ +# define IDX(h) (((h * 0x1e35a7bdU) >> (32 - HLOG - 8)) & (HSIZE - 1)) +# endif +#endif #if 0 /* original lzv-like hash function, much worse and thus slower */ @@ -291,177 +406,222 @@ lzf_decompress (const void *const in_data, size_t in_len, # define IDX(h) ((h) & (HSIZE - 1)) #endif -#define MAX_LIT (1 << 5) -#define MAX_OFF (1 << 13) -#define MAX_REF ((1 << 8) + (1 << 3)) +#if __GNUC__ >= 3 +# define expect(expr,value) __builtin_expect ((expr),(value)) +# define inline inline +#else +# define expect(expr,value) (expr) +# define inline static +#endif + +#define expect_false(expr) expect ((expr) != 0, 0) +#define expect_true(expr) expect ((expr) != 0, 1) /* * compressed format * - * 000LLLLL ; literal - * LLLooooo oooooooo ; backref L - * 111ooooo LLLLLLLL oooooooo ; backref L+7 + * 000LLLLL ; literal, L+1=1..33 octets + * LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset + * 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset * */ size_t -lzf_compress (const void *const in_data,size_t in_len, - void *out_data, size_t out_len +lzf_compress (const void *const in_data, size_t in_len, + void *out_data, size_t out_len #if LZF_STATE_ARG - , LZF_STATE *htab + , LZF_STATE htab #endif - ) + ) { #if !LZF_STATE_ARG LZF_STATE htab; #endif - const u8 **hslot; const u8 *ip = (const u8 *)in_data; - u8 *op = (u8 *)out_data; + u8 *op = (u8 *)out_data; const u8 *in_end = ip + in_len; - u8 *out_end = op + out_len; - const u8 *ref = NULL; + u8 *out_end = op + out_len; + const u8 *ref; - unsigned int hval = FRST (ip); - size_t off; - int lit = 0; + /* + * off requires a type wide enough to hold a general pointer difference. + * ISO C doesn't have that (size_t might not be enough and ptrdiff_t only + * works for differences within a single object). We also assume that + * no bit pattern traps. Since the only platform that is both non-POSIX + * and fails to support both assumptions is windows 64 bit, we make a + * special workaround for it. + */ +#if defined (_WIN32) && defined (_M_X64) + /* workaround for missing POSIX compliance */ +#if __GNUC__ + unsigned long long off; +#else + unsigned __int64 off; +#endif +#else + unsigned long off; +#endif + unsigned int hval; + int lit; + + if (!in_len || !out_len) + return 0; #if INIT_HTAB -# if USE_MEMCPY memset (htab, 0, sizeof (htab)); -# else - for (hslot = htab; hslot < htab + HSIZE; hslot++) - *hslot++ = ip; -# endif #endif - for (;;) + lit = 0; op++; /* start run */ + + hval = FRST (ip); + while (ip < in_end - 2) { - if (ip < in_end - 2) - { - hval = NEXT (hval, ip); - hslot = htab + IDX (hval); - ref = *hslot; *hslot = ip; + LZF_HSLOT *hslot; - if ( -#if INIT_HTAB && !USE_MEMCPY - ref < ip /* the next test will actually take care of this, but this is faster */ - && + hval = NEXT (hval, ip); + hslot = htab + IDX (hval); + ref = *hslot + LZF_HSLOT_BIAS; *hslot = ip - LZF_HSLOT_BIAS; + + if (1 +#if INIT_HTAB + && ref < ip /* the next test will actually take care of this, but this is faster */ #endif - (off = ip - ref - 1) < MAX_OFF - && ip + 4 < in_end - && ref > (const u8 *)in_data + && (off = ip - ref - 1) < LZF_MAX_OFF + && ref > (const u8 *)in_data + && ref[2] == ip[2] #if STRICT_ALIGN - && ref[0] == ip[0] - && ref[1] == ip[1] - && ref[2] == ip[2] + && ((ref[1] << 8) | ref[0]) == ((ip[1] << 8) | ip[0]) #else - && *(const u16 *)ref == *(const u16 *)ip - && ref[2] == ip[2] + && *(const u16 *)ref == *(const u16 *)ip #endif - ) - { - /* match found at *ref++ */ - unsigned int len = 2; - size_t maxlen = in_end - ip - len; - maxlen = maxlen > MAX_REF ? MAX_REF : maxlen; + ) + { + /* match found at *ref++ */ + unsigned int len = 2; + unsigned int maxlen = in_end - ip - len; + maxlen = maxlen > LZF_MAX_REF ? LZF_MAX_REF : maxlen; - if (op + lit + 1 + 3 >= out_end) + if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */ + if (op - !lit + 3 + 1 >= out_end) /* second the exact but rare test */ return 0; + op [- lit - 1] = lit - 1; /* stop run */ + op -= !lit; /* undo run if length is zero */ + + for (;;) + { + if (expect_true (maxlen > 16)) + { + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + len++; if (ref [len] != ip [len]) break; + } + do len++; while (len < maxlen && ref[len] == ip[len]); - if (lit) - { - *op++ = (u8)(lit - 1); - lit = -lit; - do - *op++ = ip[lit]; - while (++lit); - } + break; + } - len -= 2; - ip++; + len -= 2; /* len is now #octets - 1 */ + ip++; - if (len < 7) - { - *op++ = (u8)((off >> 8) + (len << 5)); - } - else - { - *op++ = (u8)((off >> 8) + ( 7 << 5)); - *op++ = (u8)(len - 7); - } + if (len < 7) + { + *op++ = (off >> 8) + (len << 5); + } + else + { + *op++ = (off >> 8) + ( 7 << 5); + *op++ = len - 7; + } - *op++ = (u8)off; + *op++ = off; + + lit = 0; op++; /* start run */ + + ip += len + 1; + + if (expect_false (ip >= in_end - 2)) + break; #if ULTRA_FAST || VERY_FAST - ip += len; -#if VERY_FAST && !ULTRA_FAST - --ip; -#endif - hval = FRST (ip); + --ip; +# if VERY_FAST && !ULTRA_FAST + --ip; +# endif + hval = FRST (ip); - hval = NEXT (hval, ip); - htab[IDX (hval)] = ip; - ip++; + hval = NEXT (hval, ip); + htab[IDX (hval)] = ip - LZF_HSLOT_BIAS; + ip++; -#if VERY_FAST && !ULTRA_FAST - hval = NEXT (hval, ip); - htab[IDX (hval)] = ip; - ip++; -#endif +# if VERY_FAST && !ULTRA_FAST + hval = NEXT (hval, ip); + htab[IDX (hval)] = ip - LZF_HSLOT_BIAS; + ip++; +# endif #else - do - { - hval = NEXT (hval, ip); - htab[IDX (hval)] = ip; - ip++; - } - while (len--); -#endif - continue; + ip -= len + 1; + + do + { + hval = NEXT (hval, ip); + htab[IDX (hval)] = ip - LZF_HSLOT_BIAS; + ip++; } + while (len--); +#endif } - else if (ip == in_end) - break; - - /* one more literal byte we must copy */ - lit++; - ip++; - - if (lit == MAX_LIT) + else { - if (op + 1 + MAX_LIT >= out_end) + /* one more literal byte we must copy */ + if (expect_false (op >= out_end)) return 0; - *op++ = MAX_LIT - 1; -#if USE_MEMCPY - M_Memcpy (op, ip - MAX_LIT, MAX_LIT); - op += MAX_LIT; - lit = 0; -#else - lit = -lit; - do - *op++ = ip[lit]; - while (++lit); -#endif + lit++; *op++ = *ip++; + + if (expect_false (lit == LZF_MAX_LIT)) + { + op [- lit - 1] = lit - 1; /* stop run */ + lit = 0; op++; /* start run */ + } } } - if (lit) - { - if (op + lit + 1 >= out_end) - return 0; + if (op + 3 > out_end) /* at most 3 bytes can be missing here */ + return 0; - *op++ = (u8)(lit - 1); - lit = -lit; - do - *op++ = ip[lit]; - while (++lit); + while (ip < in_end) + { + lit++; *op++ = *ip++; + + if (expect_false (lit == LZF_MAX_LIT)) + { + op [- lit - 1] = lit - 1; /* stop run */ + lit = 0; op++; /* start run */ + } } - return op - (u8 *) out_data; + op [- lit - 1] = lit - 1; /* end run */ + op -= !lit; /* undo run if length is zero */ + + return op - (u8 *)out_data; } diff --git a/src/lzf.h b/src/lzf.h index 85daf255e..dae8b131c 100644 --- a/src/lzf.h +++ b/src/lzf.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2000-2005 by Marc Alexander Lehmann +// Copyright (c) 2000-2010 Marc Alexander Lehmann // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -22,7 +22,7 @@ ** ***********************************************************************/ -#define LZF_VERSION 0x0105 /* 1.5 */ +#define LZF_VERSION 0x0106 /* 1.6 */ /* * Compress in_len bytes stored at the memory block starting at From b357c09171d52c891b1a829775d000bb9c3596b6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 18:52:53 +0200 Subject: [PATCH 11/62] those should be size_t --- src/lzf.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/lzf.c b/src/lzf.c index eb0d73b78..28ba1b6cb 100644 --- a/src/lzf.c +++ b/src/lzf.c @@ -451,16 +451,8 @@ lzf_compress (const void *const in_data, size_t in_len, * and fails to support both assumptions is windows 64 bit, we make a * special workaround for it. */ -#if defined (_WIN32) && defined (_M_X64) - /* workaround for missing POSIX compliance */ -#if __GNUC__ - unsigned long long off; -#else - unsigned __int64 off; -#endif -#else - unsigned long off; -#endif + + size_t off; unsigned int hval; int lit; @@ -498,7 +490,7 @@ lzf_compress (const void *const in_data, size_t in_len, { /* match found at *ref++ */ unsigned int len = 2; - unsigned int maxlen = in_end - ip - len; + size_t maxlen = in_end - ip - len; maxlen = maxlen > LZF_MAX_REF ? LZF_MAX_REF : maxlen; if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */ From a1d490cb4902989ba80424499374a8d19062d59b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 20:18:21 +0200 Subject: [PATCH 12/62] R_DrawMaskedColumn: do not draw zero length column --- src/r_things.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 85fe49f63..981988933 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -614,7 +614,7 @@ void R_DrawMaskedColumn(column_t *column) if (dc_yh >= vid.height) dc_yh = vid.height - 1; - if (dc_yl <= dc_yh && dc_yh > 0) + if (dc_yl <= dc_yh && dc_yh > 0&& column->length != 0) { dc_source = (UINT8 *)column + 3; dc_texturemid = basetexturemid - (topdelta<= vid.height) dc_yh = vid.height - 1; - if (dc_yl <= dc_yh && dc_yh > 0) + if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0) { dc_source = ZZ_Alloc(column->length); for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s) From 2622ba286e908b7cfc5fd0037e4af29b11119953 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 20:18:36 +0200 Subject: [PATCH 13/62] z --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 981988933..84d73d2a5 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -614,7 +614,7 @@ void R_DrawMaskedColumn(column_t *column) if (dc_yh >= vid.height) dc_yh = vid.height - 1; - if (dc_yl <= dc_yh && dc_yh > 0&& column->length != 0) + if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0) { dc_source = (UINT8 *)column + 3; dc_texturemid = basetexturemid - (topdelta< Date: Fri, 27 Sep 2024 22:28:57 +0200 Subject: [PATCH 14/62] this does nothing --- src/m_menu.c | 31 ++++++++++++++----------------- src/s_sound.c | 26 ++++---------------------- src/s_sound.h | 1 - 3 files changed, 18 insertions(+), 40 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index c42c923e2..2bfb3e1f1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1598,7 +1598,20 @@ static menuitem_t OP_SoundOptionsMenu[] = //{IT_STRING|IT_CALL, NULL, "Restart Audio System", M_RestartAudio, 50}, #ifdef NO_MIDI {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 50}, - {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 60}, + + {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 65}, + {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 75}, + {IT_STRING|IT_CVAR, NULL, "Hit Em Delay", &cv_karthitemdialog, 85}, + {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95}, + + {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, + {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, + + {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, + {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 145} +#else + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 75}, {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85}, @@ -1611,21 +1624,6 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 135}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 145}, {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} -#else - {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, - {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 70}, - - {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 85}, - {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 95}, - {IT_STRING|IT_CVAR, NULL, "Hit Em Delay", &cv_karthitemdialog, 105}, - {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 115}, - - {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 125}, - {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 135}, - - {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 145}, - {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 155}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 165} #endif }; @@ -1640,7 +1638,6 @@ static const char* OP_SoundTooltips[] = "Volume of Midi Music.", #endif "Reverse left and right channels of audio.", - "Surround Sound.", "Chat notification sound.", "Frequency of character voice lines.", "Play 'Hit Em' character line after other player's hurt line.", diff --git a/src/s_sound.c b/src/s_sound.c index f3450b6f4..ec5ebf00d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -85,7 +85,6 @@ consvar_t cv_midimusicvolume = {"midimusicvolume", "18", CV_SAVE, soundvolume_co // number of channels available consvar_t cv_numChannels = {"snd_channels", "64", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL}; -consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE|CV_NOSHOWHELP, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; // Sound system toggles, saved into the config @@ -163,10 +162,6 @@ consvar_t cv_amigatype = {"amigatype", "0", CV_SAVE|CV_CALL|CV_NOINIT, amigatype #define S_PITCH_PERTURB 1 #define S_STEREO_SWING (96*0x10000) -#ifdef SURROUND -#define SURROUND_SEP -128 -#endif - // percent attenuation from front to back #define S_IFRACVOL 30 @@ -272,7 +267,6 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&stereoreverse); CV_RegisterVar(&precachesound); - CV_RegisterVar(&surround); CV_RegisterVar(&cv_samplerate); //CV_RegisterVar(&cv_resetmusic); CV_RegisterVar(&cv_gamesounds); @@ -616,11 +610,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) } // Avoid channel reverse if surround - if (reverse -#ifdef SURROUND - && sep != SURROUND_SEP -#endif - ) + if (reverse) { sep = (~sep) & 255; } @@ -1102,18 +1092,10 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 if (reverse) angle = InvAngle(angle); -#ifdef SURROUND - // Produce a surround sound for angle from 105 till 255 - if (surround.value == 1 && (angle > ANG105 && angle < ANG255 )) - *sep = SURROUND_SEP; - else -#endif - { - angle >>= ANGLETOFINESHIFT; + angle >>= ANGLETOFINESHIFT; - // stereo separation - *sep = 128 - (FixedMul(S_STEREO_SWING, FINESINE(angle))>>FRACBITS); - } + // stereo separation + *sep = 128 - (FixedMul(S_STEREO_SWING, FINESINE(angle))>>FRACBITS); } // volume calculation diff --git a/src/s_sound.h b/src/s_sound.h index 8787ea5e5..6f4d03f09 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -32,7 +32,6 @@ extern consvar_t stereoreverse; extern consvar_t cv_soundvolume, cv_digmusicvolume;//, cv_midimusicvolume; extern consvar_t cv_numChannels; -extern consvar_t surround; extern consvar_t cv_audbuffersize; //extern consvar_t cv_resetmusic; extern consvar_t cv_gamedigimusic; From eb74f3525af05f3771c5559968df21a5b3d831db Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 22:36:48 +0200 Subject: [PATCH 15/62] consolidate this --- src/p_saveg.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index b8a517f0e..0bf03aa04 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3031,6 +3031,13 @@ static inline void P_FinishMobjs(void) } } +static inline mobj_t *RelinkMobj(mobj_t **ptr) +{ + UINT32 temp = (UINT32)(size_t)*ptr; + *ptr = NULL; + return P_SetTarget(ptr, P_FindNewPosition(temp)); +} + static void P_RelinkPointers(void) { thinker_t *currentthinker; @@ -3051,58 +3058,42 @@ static void P_RelinkPointers(void) if (mobj->tracer) { - temp = (UINT32)(size_t)mobj->tracer; - mobj->tracer = NULL; - if (!P_SetTarget(&mobj->tracer, P_FindNewPosition(temp))) + if (!RelinkMobj(&mobj->tracer)) CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type); } if (mobj->target) { - temp = (UINT32)(size_t)mobj->target; - mobj->target = NULL; - if (!P_SetTarget(&mobj->target, P_FindNewPosition(temp))) + if (!RelinkMobj(&mobj->target)) CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type); } if (mobj->hnext) { - temp = (UINT32)(size_t)mobj->hnext; - mobj->hnext = NULL; - if (!P_SetTarget(&mobj->hnext, P_FindNewPosition(temp))) + if (!RelinkMobj(&mobj->hnext)) CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type); } if (mobj->hprev) { - temp = (UINT32)(size_t)mobj->hprev; - mobj->hprev = NULL; - if (!P_SetTarget(&mobj->hprev, P_FindNewPosition(temp))) + if (!RelinkMobj(&mobj->hprev)) CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type); } if (mobj->player && mobj->player->capsule) { - temp = (UINT32)(size_t)mobj->player->capsule; - mobj->player->capsule = NULL; - if (!P_SetTarget(&mobj->player->capsule, P_FindNewPosition(temp))) + if (!RelinkMobj(&mobj->player->capsule)) CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type); } if (mobj->player && mobj->player->axis1) { - temp = (UINT32)(size_t)mobj->player->axis1; - mobj->player->axis1 = NULL; - if (!P_SetTarget(&mobj->player->axis1, P_FindNewPosition(temp))) + if (!RelinkMobj(&mobj->player->axis1)) CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type); } if (mobj->player && mobj->player->axis2) { - temp = (UINT32)(size_t)mobj->player->axis2; - mobj->player->axis2 = NULL; - if (!P_SetTarget(&mobj->player->axis2, P_FindNewPosition(temp))) + if (!RelinkMobj(&mobj->player->axis2)) CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type); } if (mobj->player && mobj->player->awayviewmobj) { - temp = (UINT32)(size_t)mobj->player->awayviewmobj; - mobj->player->awayviewmobj = NULL; - if (!P_SetTarget(&mobj->player->awayviewmobj, P_FindNewPosition(temp))) + if (!RelinkMobj(&mobj->player->awayviewmobj)) CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); } } From 89965ad718f739b01ada206943057f5a55311a8d Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 22:40:08 +0200 Subject: [PATCH 16/62] forgor remove this --- src/p_saveg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 0bf03aa04..dc0276bb5 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3042,7 +3042,6 @@ static void P_RelinkPointers(void) { thinker_t *currentthinker; mobj_t *mobj; - UINT32 temp; // use info field (value = oldposition) to relink mobjs for (currentthinker = thinkercap.next; currentthinker != &thinkercap; From 1533e13d68a5b7c1842f531d1b64b62f518f222d Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 22:40:38 +0200 Subject: [PATCH 17/62] let player pointer be const in P_IsLocalPlayer and P_IsDisplayPlayer --- src/p_local.h | 5 +++-- src/p_user.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 6916acc44..ab078e8b5 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -164,8 +164,9 @@ void P_InitCameraCmd(void); boolean P_PlayerInPain(player_t *player); void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); void P_ResetPlayer(player_t *player); -boolean P_IsLocalPlayer(player_t *player); -boolean P_IsDisplayPlayer(player_t *player); +boolean P_IsLocalPlayer(const player_t *player); +boolean P_IsDisplayPlayer(const player_t *player); + boolean P_SpectatorJoinGame(player_t *player); boolean P_IsObjectInGoop(mobj_t *mo); diff --git a/src/p_user.c b/src/p_user.c index 7d9e0e21f..f09f8b1ef 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1041,7 +1041,7 @@ fixed_t P_GetPlayerSpinHeight(player_t *player) // Returns true if player is // on the local machine. // -boolean P_IsLocalPlayer(player_t *player) +boolean P_IsLocalPlayer(const player_t *player) { UINT8 i; @@ -1065,7 +1065,7 @@ boolean P_IsLocalPlayer(player_t *player) // Returns true if player is // currently being watched. // -boolean P_IsDisplayPlayer(player_t *player) +boolean P_IsDisplayPlayer(const player_t *player) { UINT8 i; From 01c9632025897fc1ad46e7d2e52c98aca8229f6e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 22:46:54 +0200 Subject: [PATCH 18/62] set those in P_SpawnGhostMobj too --- src/p_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index f09f8b1ef..a9b1b6b72 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1179,6 +1179,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_GHOST); P_SetScale(ghost, mobj->scale); + ghost->scalespeed = mobj->scalespeed; ghost->destscale = mobj->scale; if (mobj->eflags & MFE_VERTICALFLIP) @@ -1230,6 +1231,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->old_roll = mobj->old_roll2; ghost->old_sloperoll = mobj->old_sloperoll2; ghost->old_slopepitch = mobj->old_slopepitch2; + ghost->old_scale = mobj->old_scale2; return ghost; } From b71870f57bf4f1b4aa2b0fcaff66c9ea22414337 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Sep 2024 23:45:52 +0200 Subject: [PATCH 19/62] this needs no dedi check actually --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index a57bf9eb2..e0d427b01 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -866,7 +866,7 @@ void D_SRB2Loop(void) else menuInputDelayTimer = 0; - if (!dedicated && renderisnewtic) // idk does this need dedi check?? + if (renderisnewtic) // idk does this need dedi check?? D_DeviceLEDTick(); // Fully completed frame made. From 222f56d1b21ec7b50784e57d5c93de38eb145f54 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Sep 2024 00:12:57 +0200 Subject: [PATCH 20/62] smol director stuffs --- src/k_director.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index 51406cf07..3c5938713 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -23,7 +23,7 @@ #define BOREDOMTIME 3 * TICRATE / 2 // how long until players considered far apart? #define TRANSFERTIME TICRATE // how long to delay reaction shots? #define BREAKAWAYDIST 2000 // how *far* until players considered far apart? -#define WALKBACKDIST 600 // how close should a trailing player be before we switch? +#define WALKBACKDIST 400 // how close should a trailing player be before we switch? #define PINCHDIST 20000 // how close should the leader be to be considered "end of race"? struct directorinfo @@ -377,6 +377,12 @@ void K_UpdateDirector(void) break; } + // if this is a splitscreen player, try next pair + if (P_IsDisplayPlayer(&players[target])) + { + continue; + } + // if we're certain the back half of the pair is actually in this position, try to switch if (!players[target].kartstuff[k_positiondelay]) { From fd4833568880ea0db4d709e80aa021fda037a935 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Sep 2024 01:30:14 +0200 Subject: [PATCH 21/62] Replace portalline boolean with g_portal pointer to current portal Beta --- src/r_bsp.c | 4 ++-- src/r_bsp.h | 4 +++- src/r_main.c | 20 +------------------- src/r_main.h | 21 +++++++++++++++++++++ src/r_segs.c | 2 +- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index d1ceadbf4..586aa3799 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -28,7 +28,7 @@ side_t *sidedef; line_t *linedef; sector_t *frontsector; sector_t *backsector; -boolean portalline; // is curline a portal seg? +portal_pair *g_portal; // is curline a portal seg? // very ugly realloc() of drawsegs at run-time, I upped it to 512 // instead of 256.. and someone managed to send me a level with @@ -417,7 +417,7 @@ static void R_AddLine(seg_t *line) angle_t angle1, angle2, span, tspan; static sector_t tempsec; - portalline = false; + g_portal = NULL; if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES)) return; diff --git a/src/r_bsp.h b/src/r_bsp.h index 2803a90e4..0d73c2bc4 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -18,12 +18,14 @@ #pragma interface #endif +#include "r_main.h" + extern seg_t *curline; extern side_t *sidedef; extern line_t *linedef; extern sector_t *frontsector; extern sector_t *backsector; -extern boolean portalline; // is curline a portal seg? +extern portal_pair *g_portal; // is curline a portal seg? // drawsegs are allocated on the fly... see r_segs.c diff --git a/src/r_main.c b/src/r_main.c index ba2c3551e..9b1787931 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -70,24 +70,6 @@ player_t *viewplayer; // You can thank and/or curse JTE for these. UINT8 portalrender; sector_t *portalcullsector; -typedef struct portal_pair -{ - INT32 line1; - INT32 line2; - UINT8 pass; - struct portal_pair *next; - - fixed_t viewx; - fixed_t viewy; - fixed_t viewz; - angle_t viewangle; - - INT32 start; - INT32 end; - INT16 *ceilingclip; - INT16 *floorclip; - fixed_t *frontscale; -} portal_pair; portal_pair *portal_base, *portal_cap; line_t *portalclipline; INT32 portalclipstart, portalclipend; @@ -1613,7 +1595,7 @@ void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2) portal->start = x1; portal->end = x2; - portalline = true; // this tells R_StoreWallRange that curline is a portal seg + g_portal = portal; // this tells R_StoreWallRange that curline is a portal seg portal->viewx = viewx; portal->viewy = viewy; diff --git a/src/r_main.h b/src/r_main.h index 34fe686b5..8766ea65c 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -88,6 +88,27 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph); void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 *yl, INT32 *yh); + +typedef struct portal_pair +{ + INT32 line1; + INT32 line2; + UINT8 pass; + struct portal_pair *next; + + fixed_t viewx; + fixed_t viewy; + fixed_t viewz; + angle_t viewangle; + + INT32 start; + INT32 end; + INT16 *ceilingclip; + INT16 *floorclip; + fixed_t *frontscale; +} portal_pair; + + // Performance stats extern precise_t ps_prevframetime;// time when previous frame was rendered extern ps_metric_t ps_rendercalltime; diff --git a/src/r_segs.c b/src/r_segs.c index 07d217608..e89a10780 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2840,7 +2840,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) R_RenderSegLoop(); colfunc = wallcolfunc; - if (portalline) // if curline is a portal, set portalrender for drawseg + if (g_portal) // if curline is a portal, set portalrender for drawseg ds_p->portalpass = portalrender+1; else ds_p->portalpass = 0; From 4554bcc56545d52a2ab1d0d187fce4a3530ef788 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Sep 2024 01:37:54 +0200 Subject: [PATCH 22/62] reset rumble on some conditions --- src/d_clisrv.c | 1 + src/d_netcmd.c | 2 ++ src/g_game.c | 4 ++++ src/g_input.c | 15 +++++++++++++++ src/g_input.h | 1 + 5 files changed, 23 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 171d61b01..cf6637edc 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3394,6 +3394,7 @@ void CL_Reset(void) curl_running = false; http_source[0] = '\0'; #endif + G_ResetAllDeviceRumbles(); // D_StartTitle should get done now, but the calling function will handle it } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a1868ce0a..c2e2c6fe1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3228,6 +3228,8 @@ static void Got_Pause(UINT8 **cp, INT32 playernum) else S_ResumeAudio(); } + + G_ResetAllDeviceRumbles(); } static void Command_ReplayMarker(void) diff --git a/src/g_game.c b/src/g_game.c index 8311d7cbc..7906d10a9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1600,6 +1600,8 @@ void G_DoLoadLevel(boolean resetplayer) // clear hud messages remains (usually from game startup) CON_ClearHUD(); + + G_ResetAllDeviceRumbles(); } static INT32 pausedelay = 0; @@ -3031,6 +3033,8 @@ void G_AddPlayer(INT32 playernum) void G_ExitLevel(void) { + G_ResetAllDeviceRumbles(); + if (gamestate == GS_LEVEL) { gameaction = ga_completed; diff --git a/src/g_input.c b/src/g_input.c index a4046350d..ad7758a7a 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1013,6 +1013,21 @@ static void G_ResetPlayerDeviceRumble(INT32 player) I_GamepadRumble(device_id, 0, 0, 0); } +void G_ResetAllDeviceRumbles(void) +{ + int i; + int devices; + + devices = I_NumJoys(); + + for (i = 0; i < devices; i++) + { + INT32 device_id = G_GetDeviceForPlayer(i); + + I_GamepadRumble(device_id, 0, 0, 0); + } +} + void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { INT32 device_id; diff --git a/src/g_input.h b/src/g_input.h index 6799f6ca0..18fff51a4 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -138,6 +138,7 @@ UINT16 G_GetSkinColor(INT32 player); INT32 G_GetDeviceForPlayer(INT32 player); void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color); void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength, UINT32 duration); +void G_ResetAllDeviceRumbles(void); // remaps the input event to a game control. void G_MapEventsToControls(event_t *ev); From 564838a4393e1d3fc2d2bc04fbc1f94013db157c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Sep 2024 15:15:49 +0200 Subject: [PATCH 23/62] only draw lua hud stuff when patch exists --- src/lua_hudlib_drawlist.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 2ee9b8156..1cef45a87 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -632,12 +632,18 @@ void LUA_HUD_DrawList(huddrawlist_h list) switch (item->type) { case DI_Draw: + if (!item->patch || item->patch == NULL) + return; V_DrawFixedPatch(LERPS(x), LERPS(y), FRACUNIT, item->flags, item->patch, item->colormap); break; case DI_DrawScaled: + if (!item->patch || item->patch == NULL) + return; V_DrawFixedPatch(LERPS(x), LERPS(y), LERP(scale), item->flags, item->patch, item->colormap); break; case DI_DrawStretched: + if (!item->patch || item->patch == NULL) + return; V_DrawStretchyFixedPatch(LERPS(x), LERPS(y), LERP(hscale), LERP(vscale), item->flags, item->patch, item->colormap); break; case DI_DrawNum: From cadb67e6c909f25b7797114232e7fbcb8f5450dc Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Sep 2024 15:14:43 +0200 Subject: [PATCH 24/62] move this stuff so dont need check for renderisnewtic multiple times and dont need to check for menu and dpad stuff every single frame --- src/d_main.c | 72 ++++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index e0d427b01..9ca370c2a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -780,6 +780,37 @@ void D_SRB2Loop(void) doDisplay = true; } + +#define DPADSCROLLINPUT(INPUT)\ + {\ + myev.data1 = INPUT;\ + M_Responder(&myev);\ + } + // this is absolutely awful and i hate it lmao + if (menuactive && (DPADUPSCROLL || DPADDOWNSCROLL || DPADLEFTSCROLL || DPADRIGHTSCROLL)) + { + event_t myev; + myev.type = ev_keydown; + + menuInputDelayTimer++; + + if (menuInputDelayTimer >= 19) // TICRATE * ( (k+2) (1 - [wz + h + j - q]^2 - [(gk + 2g + k + 1)(h + j) + h - z]^2 - [16(k + 1)^3(k + 2)(n + 1)^2 + 1 - f^2]^2 calculated by my butt + { + if (DPADUPSCROLL) + DPADSCROLLINPUT(KEY_UPARROW) + else if (DPADDOWNSCROLL) + DPADSCROLLINPUT(KEY_DOWNARROW) + else if (DPADLEFTSCROLL) + DPADSCROLLINPUT(KEY_LEFTARROW) + else if (DPADRIGHTSCROLL) + DPADSCROLLINPUT(KEY_RIGHTARROW) + } + } + else + menuInputDelayTimer = 0; +#undef DPADSCROLLINPUT + + D_DeviceLEDTick(); } if (interp) @@ -828,47 +859,6 @@ void D_SRB2Loop(void) } #endif - // this is absolutely awful and i hate it lmao - if (menuactive && (DPADUPSCROLL || DPADDOWNSCROLL || DPADLEFTSCROLL || DPADRIGHTSCROLL)) - { - event_t myev; - myev.type = ev_keydown; - - if (renderisnewtic) - { - menuInputDelayTimer++; - - if (menuInputDelayTimer >= 19) // TICRATE * ( (k+2) (1 - [wz + h + j - q]^2 - [(gk + 2g + k + 1)(h + j) + h - z]^2 - [16(k + 1)^3(k + 2)(n + 1)^2 + 1 - f^2]^2 calculated by my butt - { - if (DPADUPSCROLL) - { - myev.data1 = KEY_UPARROW; - M_Responder(&myev); - } - else if (DPADDOWNSCROLL) - { - myev.data1 = KEY_DOWNARROW; - M_Responder(&myev); - } - else if (DPADLEFTSCROLL) - { - myev.data1 = KEY_LEFTARROW; - M_Responder(&myev); - } - else if (DPADRIGHTSCROLL) - { - myev.data1 = KEY_RIGHTARROW; - M_Responder(&myev); - } - } - } - } - else - menuInputDelayTimer = 0; - - if (renderisnewtic) // idk does this need dedi check?? - D_DeviceLEDTick(); - // Fully completed frame made. finishprecise = I_GetPreciseTime(); From d7b0726e424f70dc54c461f066563fe8d7b73434 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Sep 2024 21:51:31 +0200 Subject: [PATCH 25/62] no need to even traverse part of the blockmap when PRECIP_STORM_NORAIN and PRECIP_BLANK --- src/hardware/hw_main.c | 2 +- src/r_things.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 30c6f7454..db9846c07 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4601,7 +4601,7 @@ static void HWR_AddPrecipitationSprites(void) drawdist = (fixed_t)(cv_drawdist_precip.value) * precipscale; // No to infinite precipitation draw distance. - if (drawdist == 0) + if (drawdist == 0 || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) { return; } diff --git a/src/r_things.c b/src/r_things.c index 84d73d2a5..31c3dcbe4 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1987,7 +1987,7 @@ void R_AddPrecipitationSprites(void) precipmobj_t *th, *next; // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off - if (drawdist == 0) + if (drawdist == 0 || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) { return; } From 913426bfdbddd0bed7cf3d85c7a1ed11f1d6e3ab Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Sep 2024 22:26:49 +0200 Subject: [PATCH 26/62] let SOC also use PRECIP_BLANK/ weather = 4 no idea why it couldnt doesent make any sense --- src/p_mobj.c | 6 ++---- src/p_spec.c | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 91cf6f388..3e94b3ec4 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10237,6 +10237,7 @@ void P_SpawnPrecipitation(void) // 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<>(FRACBITS+2)); } - if (volume < 0) - volume = 0; - else if (volume > 255) - volume = 255; + volume = CLAMP(volume, 0, 255); if (sounds_rain && (!leveltime || leveltime % 80 == 1)) S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_rainin, volume); diff --git a/src/p_spec.c b/src/p_spec.c index 133176db6..7066058fa 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5308,6 +5308,8 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) curWeather = PRECIP_STORM_NORAIN; else if (mapheaderinfo[gamemap-1]->weather == 6) // storm w/o lightning curWeather = PRECIP_STORM_NOSTRIKES; + else if (mapheaderinfo[gamemap-1]->weather == 4) // blank + curWeather = PRECIP_BLANK; else curWeather = PRECIP_NONE; From f051e33a0c34cc0ac3ca3e9b2058826d9677ce3b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 30 Sep 2024 23:00:25 +0200 Subject: [PATCH 27/62] cv_showdirectorhud didnt save Zzz... --- src/d_netcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c2e2c6fe1..46a2a2ba7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -569,7 +569,7 @@ consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_ consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebugdirector = {"debugdirector", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showdirectorhud = {"showdirectorhud", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showdirectorhud = {"showdirectorhud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showtrackaddon = {"showtrackaddon", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; From b24caf397aa6d4f95522e458d34dc201871d57ca Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 1 Oct 2024 14:49:37 +0200 Subject: [PATCH 28/62] add "map ?" shortcut for random map --- src/g_game.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 7906d10a9..f6b7d562c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4621,6 +4621,8 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) { if (mapname[0] == '*') // current map return gamemap; + else if (mapname[0] == '?') + return G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, false, NULL); else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map { newmapnum = mapheaderinfo[gamemap-1]->nextlevel; From 31516c7987698bd7a3be7973304b0bf2d0a42bd3 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 1 Oct 2024 17:56:15 +0200 Subject: [PATCH 29/62] fix G_BuildMapTitle leaks --- src/d_netcmd.c | 5 ++++- src/hu_stuff.c | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 46a2a2ba7..ceaa38e2b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3247,7 +3247,10 @@ static void Command_ReplayMarker(void) demo.savemode = DSM_WILLAUTOSAVE; if (adjustedleveltime < 0) adjustedleveltime = 0; - snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", G_BuildMapTitle(gamemap), G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + char *title = G_BuildMapTitle(gamemap); + snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + if (title) + Z_Free(title); CONS_Printf("Replay will be saved!\n"); } } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index ba6bb72bc..35430119b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2748,10 +2748,14 @@ static void HU_DrawRankings(void) //V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, gametype_cons_t[gametype].strvalue); // draw the current map in the lower right if theres none just say its unknown - if (!G_BuildMapTitle(gamemap)) + char *maptitle = G_BuildMapTitle(gamemap); + if (!maptitle) V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, "UNKNOWN"); else - V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, G_BuildMapTitle(gamemap)); + { + V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, maptitle); + Z_Free(maptitle); + } if (G_GametypeHasTeams()) { From dfb6006f9c3f23cddd133a2bc33bacaa580f4020 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Oct 2024 12:14:31 +0200 Subject: [PATCH 30/62] fix up old fps counter --- src/screen.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/screen.c b/src/screen.c index 8fe00e821..b7777fc32 100644 --- a/src/screen.c +++ b/src/screen.c @@ -366,15 +366,13 @@ double averageFPS = 0.0f; #define USE_FPS_SAMPLES #ifdef USE_FPS_SAMPLES -#define MAX_FRAME_TIME 0.05 +#define MAX_FRAME_TIME (0.05) #define NUM_FPS_SAMPLES (16) // Number of samples to store -#define NUM_FPS_SAMPLES2 (32) // Number of samples to store for inaccurate counter static double total_frame_time = 0.0; static int frame_index; -static double fps_samples[NUM_FPS_SAMPLES2]; -static int fps_index; +static double fps_samples[NUM_FPS_SAMPLES]; #endif static boolean fps_init = false; @@ -383,7 +381,6 @@ static precise_t fps_enter = 0; void SCR_CalculateFPS(void) { precise_t fps_finish = 0; - int i; double frameElapsed = 0.0; @@ -398,7 +395,6 @@ void SCR_CalculateFPS(void) fps_enter = fps_finish; #ifdef USE_FPS_SAMPLES - if (cv_accuratefps.value) { total_frame_time += frameElapsed; @@ -411,13 +407,35 @@ void SCR_CalculateFPS(void) } else { - fps_samples[fps_index] = frameElapsed / NUM_FPS_SAMPLES2; - fps_index = (fps_index + 1) % NUM_FPS_SAMPLES2; + total_frame_time += frameElapsed; - averageFPS = 0.0; - for (i = 0; i < NUM_FPS_SAMPLES2; i++) - averageFPS += fps_samples[i]; - averageFPS = 1.0 / averageFPS; + if (total_frame_time >= MAX_FRAME_TIME) + { + static int sampleIndex = 0; + int i; + + fps_samples[sampleIndex] = frameElapsed; + + sampleIndex++; + if (sampleIndex >= NUM_FPS_SAMPLES) + sampleIndex = 0; + + averageFPS = 0.0; + for (i = 0; i < NUM_FPS_SAMPLES; i++) + { + averageFPS += fps_samples[i]; + } + + if (averageFPS > 0.0) + { + averageFPS = 1.0 / (averageFPS / NUM_FPS_SAMPLES); + } + } + + while (total_frame_time >= MAX_FRAME_TIME) + { + total_frame_time -= MAX_FRAME_TIME; + } } #else // Direct, unsampled counter. From 837216d78e60213cdc9a38c1aad81c30d9cc85e6 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Oct 2024 14:22:39 +0200 Subject: [PATCH 31/62] we dont need any of this in ogl --- src/r_main.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 9b1787931..25394a2e3 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -979,6 +979,16 @@ void R_ExecuteSetViewSize(void) R_InitTextureMapping(); + // why did we calc all the software crap? +#ifdef HWRENDER + if (rendermode == render_opengl) + { + HWR_SetViewSize(); + am_recalc = true; + return; + } +#endif + // thing clipping for (i = 0; i < viewwidth; i++) screenheightarray[i] = (INT16)viewheight; @@ -987,27 +997,24 @@ void R_ExecuteSetViewSize(void) R_SetSkyScale(); // planes - if (rendermode == render_soft) + // this is only used for planes rendering in software mode + j = viewheight*16; + for (i = 0; i < j; i++) { - // this is only used for planes rendering in software mode - j = viewheight*16; - for (i = 0; i < j; i++) - { - dy = (i - viewheight*8)< Date: Wed, 2 Oct 2024 14:20:29 +0200 Subject: [PATCH 32/62] prevent this from overflowing ye well idk anymore. --- src/screen.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/screen.h b/src/screen.h index 4f3b0b1ff..be8cd9614 100644 --- a/src/screen.h +++ b/src/screen.h @@ -39,12 +39,12 @@ // we try to re-allocate a minimum of buffers for stability of the memory, // so all the small-enough tables based on screen size, are allocated once // and for all at the maximum size. -#define MAXVIDWIDTH 2560 // don't set this too high because actually -#define MAXVIDHEIGHT 1440 // lots of tables are allocated with the MAX size. +#define MAXVIDWIDTH 5120 // don't set this too high because actually +#define MAXVIDHEIGHT 2880 // lots of tables are allocated with the MAX size. #define BASEVIDWIDTH 320 // NEVER CHANGE THIS! This is the original #define BASEVIDHEIGHT 200 // resolution of the graphics. -// max res for png capture; seperated it so both MAXVID values can be lower for software performance reasons; OpenGL does not care about those anyways +// max res for png capture; just here to prevent some crashes on very high resoltions; tho you should never go this high cause ogl allocs certain things with MAXVIDWIDTH and MAXVIDHEIGHT too Zzz... #define MAXPNGWIDTH 7680 #define MAXPNGHEIGHT 4320 From a0437713bf1635d6a73ec82244c0026396d39271 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Oct 2024 14:39:57 +0200 Subject: [PATCH 33/62] smol dupe --- src/screen.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/screen.c b/src/screen.c index b7777fc32..22ce5e8f1 100644 --- a/src/screen.c +++ b/src/screen.c @@ -395,9 +395,10 @@ void SCR_CalculateFPS(void) fps_enter = fps_finish; #ifdef USE_FPS_SAMPLES + total_frame_time += frameElapsed; + if (cv_accuratefps.value) { - total_frame_time += frameElapsed; if (frame_index++ >= NUM_FPS_SAMPLES || total_frame_time >= MAX_FRAME_TIME) { averageFPS = 1.0 / (total_frame_time / frame_index); @@ -407,8 +408,6 @@ void SCR_CalculateFPS(void) } else { - total_frame_time += frameElapsed; - if (total_frame_time >= MAX_FRAME_TIME) { static int sampleIndex = 0; From ec3b1cf130919b93be111c562a14ac47100c6666 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Oct 2024 20:32:26 +0200 Subject: [PATCH 34/62] make this more readable --- src/p_mobj.c | 72 +++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 3e94b3ec4..fb5a0fd0a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -592,7 +592,8 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t { I_Assert(mobj != NULL); I_Assert(sector != NULL); - if (sector->f_slope) { + if (sector->f_slope) + { fixed_t testx, testy; pslope_t *slope = sector->f_slope; @@ -607,7 +608,8 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t else testy = -mobj->radius; - if ((slope->zdelta > 0) ^ !!(lowest)) { + if ((slope->zdelta > 0) ^ !!(lowest)) + { testx = -testx; testy = -testy; } @@ -620,22 +622,21 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) { + if (perfect) + { size_t i; line_t *ld; fixed_t bbox[4]; fixed_t finalheight; - if (lowest) - finalheight = INT32_MAX; - else - finalheight = INT32_MIN; + finalheight = lowest ? INT32_MAX : INT32_MIN; bbox[BOXLEFT] = x-mobj->radius; bbox[BOXRIGHT] = x+mobj->radius; bbox[BOXTOP] = y+mobj->radius; bbox[BOXBOTTOM] = y-mobj->radius; - for (i = 0; i < boundsec->linecount; i++) { + for (i = 0; i < boundsec->linecount; i++) + { ld = boundsec->lines[i]; if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] @@ -668,7 +669,8 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed { I_Assert(mobj != NULL); I_Assert(sector != NULL); - if (sector->c_slope) { + if (sector->c_slope) + { fixed_t testx, testy; pslope_t *slope = sector->c_slope; @@ -683,7 +685,8 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed else testy = -mobj->radius; - if ((slope->zdelta > 0) ^ !!(lowest)) { + if ((slope->zdelta > 0) ^ !!(lowest)) + { testx = -testx; testy = -testy; } @@ -696,22 +699,21 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) { + if (perfect) + { size_t i; line_t *ld; fixed_t bbox[4]; fixed_t finalheight; - if (lowest) - finalheight = INT32_MAX; - else - finalheight = INT32_MIN; + finalheight = lowest ? INT32_MAX : INT32_MIN; bbox[BOXLEFT] = x-mobj->radius; bbox[BOXRIGHT] = x+mobj->radius; bbox[BOXTOP] = y+mobj->radius; bbox[BOXBOTTOM] = y-mobj->radius; - for (i = 0; i < boundsec->linecount; i++) { + for (i = 0; i < boundsec->linecount; i++) + { ld = boundsec->lines[i]; if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] @@ -746,7 +748,8 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix I_Assert(mobj != NULL); I_Assert(sector != NULL); - if (sector->f_slope) { + if (sector->f_slope) + { fixed_t testx, testy; pslope_t *slope = sector->f_slope; @@ -761,7 +764,8 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix else testy = -mobj->radius; - if ((slope->zdelta > 0) ^ !!(lowest)) { + if ((slope->zdelta > 0) ^ !!(lowest)) + { testx = -testx; testy = -testy; } @@ -774,22 +778,21 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) { + if (perfect) + { size_t i; line_t *ld; fixed_t bbox[4]; fixed_t finalheight; - if (lowest) - finalheight = INT32_MAX; - else - finalheight = INT32_MIN; + finalheight = lowest ? INT32_MAX : INT32_MIN; bbox[BOXLEFT] = x-mobj->radius; bbox[BOXRIGHT] = x+mobj->radius; bbox[BOXTOP] = y+mobj->radius; bbox[BOXBOTTOM] = y-mobj->radius; - for (i = 0; i < boundsec->linecount; i++) { + for (i = 0; i < boundsec->linecount; i++) + { ld = boundsec->lines[i]; if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] @@ -823,7 +826,8 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f I_Assert(mobj != NULL); I_Assert(sector != NULL); - if (sector->c_slope) { + if (sector->c_slope) + { fixed_t testx, testy; pslope_t *slope = sector->c_slope; @@ -838,7 +842,8 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f else testy = -mobj->radius; - if ((slope->zdelta > 0) ^ !!(lowest)) { + if ((slope->zdelta > 0) ^ !!(lowest)) + { testx = -testx; testy = -testy; } @@ -851,22 +856,21 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) { + if (perfect) + { size_t i; line_t *ld; fixed_t bbox[4]; fixed_t finalheight; - if (lowest) - finalheight = INT32_MAX; - else - finalheight = INT32_MIN; + finalheight = lowest ? INT32_MAX : INT32_MIN; bbox[BOXLEFT] = x-mobj->radius; bbox[BOXRIGHT] = x+mobj->radius; bbox[BOXTOP] = y+mobj->radius; bbox[BOXBOTTOM] = y-mobj->radius; - for (i = 0; i < boundsec->linecount; i++) { + for (i = 0; i < boundsec->linecount; i++) + { ld = boundsec->lines[i]; if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] @@ -6034,7 +6038,7 @@ void P_RollPitchMobj(mobj_t* mobj) if (cv_sloperolldist.value > 0) usedist = true; - if ((cv_spriteroll.value) && (cv_sloperoll.value == 2)) + if (cv_spriteroll.value && cv_sloperoll.value == 2) { K_RollMobjBySlopes(mobj, usedist); } @@ -6260,7 +6264,7 @@ void P_MobjThinker(mobj_t *mobj) return; } - if (mobj->state == &states[S_SHADOW] && cv_sloperoll.value == 2) + if (cv_sloperoll.value == 2 && mobj->state == &states[S_SHADOW]) { mobj->slopepitch = mobj->target->slopepitch; mobj->sloperoll = mobj->target->sloperoll; From 3165004d0e2b781ab7706d02e8e15be2e3b1af24 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Oct 2024 18:15:12 +0200 Subject: [PATCH 35/62] add comment to try and explain this crap --- src/d_clisrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index cf6637edc..f9110bb2d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5383,6 +5383,7 @@ static void HandlePacketFromPlayer(SINT8 node) } #ifdef SATURNSYNCH + // this decreases by one point at twice the cooldown time (ex cooldown of 2 seconds means, this counter decreases by one every 4 seconds), pretty much there to prevent a resynch loop if ((gamestate_resend_counter[node] != 0) && (I_GetTime() % ((max(cv_resynchcooldown.value, 1) * TICRATE) *2) == 0)) gamestate_resend_counter[node]--; From 6f1252e27d165485ed81d156d741f4b61b48b2b9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Oct 2024 05:41:30 +0200 Subject: [PATCH 36/62] set timeinmap for demo rewind idk maybe this helps with that feature desynching all the time lol --- src/p_tick.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_tick.c b/src/p_tick.c index 9dbdd7ed5..6ffc18a49 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -429,6 +429,8 @@ void P_Ticker(boolean run) if (demo.rewinding && leveltime > 0) { leveltime = (leveltime-1) & ~3; + if (timeinmap > 0) + timeinmap = (timeinmap-1) & ~3; G_PreviewRewind(leveltime); } else if (demo.freecam && democam.cam) // special case: allow freecam to MOVE during pause! From f54bb349b53c02211e704ea43256ec38b7f9e489 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Oct 2024 06:04:12 +0200 Subject: [PATCH 37/62] add G_FixCamera --- src/g_game.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index f6b7d562c..adf86476b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1991,6 +1991,23 @@ INT32 G_CountPlayersPotentiallyViewable(boolean active) return total; } +// +// G_FixCamera +// Reset camera position, angle and interpolation on a view +// after changing state. +// +static void G_FixCamera(UINT8 view) +{ + player_t *player = &players[displayplayers[view - 1]]; + // The order of displayplayers can change, which would + // invalidate localangle. + localangle[view - 1] = player->cmd.angleturn; + P_ResetCamera(player, &camera[view - 1]); + // Make sure the viewport doesn't interpolate at all into + // its new position -- just snap instantly into place. + R_ResetViewInterpolation(view); +} + // // G_ResetView // Correct a viewpoint to playernum or the next available, wraps forward. @@ -2003,7 +2020,6 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) UINT8 viewd; INT32 *displayplayerp; - camera_t *camerap; INT32 olddisplayplayer; INT32 playersviewable; @@ -2042,28 +2058,14 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) (*displayplayerp) = playernum; if ((*displayplayerp) != olddisplayplayer) { - camerap = &camera[viewnum-1]; - P_ResetCamera(&players[(*displayplayerp)], camerap); - - // Make sure the viewport doesn't interpolate at all into - // its new position -- just snap instantly into place. - R_ResetViewInterpolation(viewnum); + G_FixCamera(viewnum); } if (viewnum > splits) { for (viewd = splits+1; viewd < viewnum; ++viewd) { - displayplayerp = (&displayplayers[viewd-1]); - camerap = &camera[viewd]; - - (*displayplayerp) = G_FindView(0, viewd, onlyactive, false); - - P_ResetCamera(&players[(*displayplayerp)], camerap); - - // Make sure the viewport doesn't interpolate at all into - // its new position -- just snap instantly into place. - R_ResetViewInterpolation(viewd); + G_FixCamera(viewd); } } From 6574ec2fb9b187a2b0d8bd3e1810360eb2ebeb3f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Oct 2024 06:09:48 +0200 Subject: [PATCH 38/62] attempt to cleanup R_SetupFrame --- src/r_main.c | 105 ++++++++++++++++++++------------------------------- 1 file changed, 41 insertions(+), 64 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 25394a2e3..c85ef09f2 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1361,51 +1361,35 @@ void R_SetupFrame(player_t *player, boolean skybox) camera_t *thiscam; boolean chasecam = false; +#define SETUPCAM(num, var, context)\ + thiscam = &camera[num];\ + chasecam = (var.value != 0);\ + R_SetViewContext(context);\ + if (thiscam->reset)\ + {\ + R_ResetViewInterpolation(num+1);\ + thiscam->reset = false;\ + } + if (splitscreen > 2 && player == &players[displayplayers[3]]) { - thiscam = &camera[3]; - chasecam = (cv_chasecam4.value != 0); - R_SetViewContext(VIEWCONTEXT_PLAYER4); - if (thiscam->reset) - { - R_ResetViewInterpolation(4); - thiscam->reset = false; - } + SETUPCAM(3, cv_chasecam4, VIEWCONTEXT_PLAYER4) } else if (splitscreen > 1 && player == &players[displayplayers[2]]) { - thiscam = &camera[2]; - chasecam = (cv_chasecam3.value != 0); - R_SetViewContext(VIEWCONTEXT_PLAYER3); - if (thiscam->reset) - { - R_ResetViewInterpolation(3); - thiscam->reset = false; - } + SETUPCAM(2, cv_chasecam3, VIEWCONTEXT_PLAYER3) } else if (splitscreen && player == &players[displayplayers[1]]) { - thiscam = &camera[1]; - chasecam = (cv_chasecam2.value != 0); - R_SetViewContext(VIEWCONTEXT_PLAYER2); - if (thiscam->reset) - { - R_ResetViewInterpolation(2); - thiscam->reset = false; - } + SETUPCAM(1, cv_chasecam2, VIEWCONTEXT_PLAYER2) } else { - thiscam = &camera[0]; - chasecam = (cv_chasecam.value != 0); - R_SetViewContext(VIEWCONTEXT_PLAYER1); - if (thiscam->reset) - { - R_ResetViewInterpolation(1); - thiscam->reset = false; - } + SETUPCAM(0, cv_chasecam, VIEWCONTEXT_PLAYER1) } +#undef SETUPCAM + if (player->spectator) // no spectator chasecam chasecam = false; // force chasecam off else if (player->playerstate == PST_DEAD || player->exiting) @@ -1425,20 +1409,40 @@ void R_SetupFrame(player_t *player, boolean skybox) // cut-away view stuff viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN I_Assert(viewmobj != NULL); + + newview->x = viewmobj->x; + newview->y = viewmobj->y; newview->z = viewmobj->z + 20*FRACUNIT; newview->aim = player->awayviewaiming; newview->angle = viewmobj->angle; + + newview->x += quake.x; + newview->y += quake.y; + + if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && thiscam && thiscam->subsector->sector) + newview->sector = viewmobj->subsector->sector; + else + newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; } - else if (!player->spectator && (thiscam && chasecam)) - // use outside cam view + else if (!player->spectator && (thiscam && chasecam)) // use outside cam view { viewmobj = NULL; + + newview->x = thiscam->x; + newview->y = thiscam->y; newview->z = thiscam->z + (thiscam->height>>1); newview->aim = thiscam->aiming; newview->angle = thiscam->angle; + + newview->x += quake.x; + newview->y += quake.y; + + if (thiscam->subsector && thiscam->subsector->sector) + newview->sector = thiscam->subsector->sector; + else + newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; } - else - // use the player's eyes view + else // use the player's eyes view { newview->z = player->viewz; @@ -1470,39 +1474,12 @@ void R_SetupFrame(player_t *player, boolean skybox) } } } + newview->roll = R_ViewRollAngle(player); newview->z += quake.z; newview->player = player; - if ((thiscam && chasecam) && !player->awayviewtics && !player->spectator) - { - newview->x = thiscam->x; - newview->y = thiscam->y; - newview->x += quake.x; - newview->y += quake.y; - - if (thiscam->subsector && thiscam->subsector->sector) - newview->sector = thiscam->subsector->sector; - else - newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - } - else - { - newview->x = viewmobj->x; - newview->y = viewmobj->y; - newview->x += quake.x; - newview->y += quake.y; - - if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && thiscam && thiscam->subsector->sector) - newview->sector = viewmobj->subsector->sector; - else - newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - } - - // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); - // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT, false); } From 4b083ee72ee6616bda2e2f4ee917abe1c7b5d972 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Oct 2024 08:26:06 +0200 Subject: [PATCH 39/62] make function for quakes, scale with mobjscale --- src/doomstat.h | 2 +- src/k_kart.c | 3 +-- src/lua_baselib.c | 8 +++----- src/p_inter.c | 3 +-- src/p_spec.c | 33 ++++++++++++++++++++++++++------- src/p_spec.h | 2 ++ 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 35ae67d1b..01d98fd4e 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -192,7 +192,7 @@ extern struct quake // camera offsets and duration fixed_t x,y,z; angle_t roll; - UINT16 time; + tic_t time; // location, radius, and intensity... mappoint_t *epicenter; diff --git a/src/k_kart.c b/src/k_kart.c index 44497b0f2..a96a6bbda 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2686,8 +2686,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b if (P_IsLocalPlayer(player)) { - quake.intensity = 64*FRACUNIT; - quake.time = 5; + P_StartQuake(5, 64<kartstuff[k_instashield] = 15; diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 3fbfd463d..1e60863ef 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1553,8 +1553,9 @@ static int lib_pSetSkyboxMobj(lua_State *L) // Shhh, neither does P_StartQuake. static int lib_pStartQuake(lua_State *L) { + tic_t q_time = (tic_t)luaL_checkinteger(L, 2); fixed_t q_intensity = luaL_checkinteger(L, 1); - UINT16 q_time = (UINT16)luaL_checkinteger(L, 2); + fixed_t q_radius = luaL_optinteger(L, 4, 512<sidenum[0]].textureoffset; - quake.radius = sides[line->sidenum[0]].rowoffset; - quake.time = P_AproxDistance(line->dx, line->dy)>>FRACBITS; + fixed_t intensity = sides[line->sidenum[0]].textureoffset; + fixed_t radius = sides[line->sidenum[0]].rowoffset; + tic_t time = P_AproxDistance(line->dx, line->dy)>>FRACBITS; quake.epicenter = NULL; /// \todo // reasonable defaults. - if (!quake.intensity) - quake.intensity = 8< 0) + { + quake.radius = FixedMul(radius, mapobjectscale); + } +} + static void P_SearchForDisableLinedefs(void) { size_t i; diff --git a/src/p_spec.h b/src/p_spec.h index 477dd4950..7612ac657 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -454,4 +454,6 @@ void P_CalcHeight(player_t *player); sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo); +void P_StartQuake(tic_t time, fixed_t intensity, fixed_t radius); + #endif From 55c9c7297f984afb3a778b1432c66dabc3968bd8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Oct 2024 08:29:40 +0200 Subject: [PATCH 40/62] throw this into own function too --- src/p_tick.c | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 6ffc18a49..5edb29f80 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -397,6 +397,36 @@ void P_RunChaseCameras(void) } } +static inline void P_RunQuakes(void) +{ + fixed_t ir; + + if (quake.time <= 0) + { + quake.x = quake.y = quake.z = quake.roll = 0; + return; + } + + ir = quake.intensity>>1; + + /// \todo Calculate distance from epicenter if set and modulate the intensity accordingly based on radius. + quake.x = M_RandomRange(-ir,ir); + quake.y = M_RandomRange(-ir,ir); + quake.z = M_RandomRange(-ir,ir); + + ir >>= 2; + ir = M_RandomRange(-ir,ir); + + if (ir < 0) + ir = ANGLE_MAX - FixedAngle(-ir); + else + ir = FixedAngle(ir); + + quake.roll = ir; + + --quake.time; +} + // // P_Ticker // @@ -589,24 +619,7 @@ void P_Ticker(boolean run) K_CalculateBattleWanted(); } - if (quake.time) - { - fixed_t ir = quake.intensity>>1; - /// \todo Calculate distance from epicenter if set and modulate the intensity accordingly based on radius. - quake.x = M_RandomRange(-ir,ir); - quake.y = M_RandomRange(-ir,ir); - quake.z = M_RandomRange(-ir,ir); - ir >>= 2; - ir = M_RandomRange(-ir,ir); - if (ir < 0) - ir = ANGLE_MAX - FixedAngle(-ir); - else - ir = FixedAngle(ir); - quake.roll = ir; - --quake.time; - } - else - quake.x = quake.y = quake.z = quake.roll = 0; + P_RunQuakes(); if (metalplayback) G_ReadMetalTic(metalplayback); From ff2006ad74052b048f7c2b3b55f1a9d3dfa8d0a1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Oct 2024 08:35:35 +0200 Subject: [PATCH 41/62] smol fix --- src/g_game.c | 14 +++++++++----- src/p_tick.c | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index adf86476b..1b6beb96c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2056,18 +2056,22 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) /* Focus our target view first so that we don't take its player. */ (*displayplayerp) = playernum; - if ((*displayplayerp) != olddisplayplayer) - { - G_FixCamera(viewnum); - } + /* If a viewpoint changes, reset the camera to clear uninitialized memory. */ if (viewnum > splits) { - for (viewd = splits+1; viewd < viewnum; ++viewd) + for (viewd = splits+1; viewd <= viewnum; ++viewd) { G_FixCamera(viewd); } } + else + { + if ((*displayplayerp) != olddisplayplayer) + { + G_FixCamera(viewnum); + } + } if (viewnum == 1 && demo.playback) consoleplayer = displayplayers[0]; diff --git a/src/p_tick.c b/src/p_tick.c index 5edb29f80..7405792d0 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -683,8 +683,10 @@ void P_Ticker(boolean run) { player_t *player = &players[displayplayers[i]]; boolean isSkyVisibleForPlayer = skyVisiblePerPlayer[i]; + if (!player->mo) continue; + if (isSkyVisibleForPlayer && skyboxmo[0] && cv_skybox.value) { R_SkyboxFrame(player); @@ -698,8 +700,6 @@ void P_Ticker(boolean run) if (demo.playback) G_StoreRewindInfo(); - -// Z_CheckMemCleanup(); } // Abbreviated ticker for pre-loading, calls thinkers and assorted things From 76198f61de21179c2bb32f97869512097d3fefca Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 12:56:19 +0200 Subject: [PATCH 42/62] add missing break --- src/p_telept.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_telept.c b/src/p_telept.c index a7cef7b1d..ceed7dc93 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -166,6 +166,7 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle P_ResetCamera(thing->player, &camera[i]); R_ResetViewInterpolation(i + 1); + break; } // don't run in place after a teleport From a2799ddccad59e982ae8340c24fe187e365a5d80 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 13:12:27 +0200 Subject: [PATCH 43/62] Interpolate view, even when paused https://github.com/KartKrewDev/RingRacers/commit/3320faec8cebecb124882d38c7ec0ad37b79340a#diff-607b68058edc6124b3061267d902aabeddb6ba338c6483df0af8b1a7cf796a01R43 --- src/d_main.c | 3 +++ src/r_main.c | 5 +++-- src/r_main.h | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 9ca370c2a..28c1dd594 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -825,11 +825,14 @@ void D_SRB2Loop(void) { rendertimefrac = FRACUNIT; } + + rendertimefrac_unpaused = g_time.timefrac; } else { renderdeltatics = realtics * FRACUNIT; rendertimefrac = FRACUNIT; + rendertimefrac_unpaused = FRACUNIT; } if ((interp || doDisplay) && !frameskip) diff --git a/src/r_main.c b/src/r_main.c index c85ef09f2..e0cc44ea9 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -75,6 +75,7 @@ line_t *portalclipline; INT32 portalclipstart, portalclipend; fixed_t rendertimefrac; +fixed_t rendertimefrac_unpaused; fixed_t renderdeltatics; boolean renderisnewtic; @@ -1353,7 +1354,7 @@ void R_SkyboxFrame(player_t *player) // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); } void R_SetupFrame(player_t *player, boolean skybox) @@ -1480,7 +1481,7 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->player = player; - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); } #define ANGLED_PORTALS diff --git a/src/r_main.h b/src/r_main.h index 8766ea65c..e6ae49103 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -33,6 +33,8 @@ extern size_t validcount, linecount, loopcount, framecount; // The fraction of a tic being drawn (for interpolation between two tics) extern fixed_t rendertimefrac; +// Same as rendertimefrac but not suspended when the game is paused +extern fixed_t rendertimefrac_unpaused; // Evaluated delta tics for this frame (how many tics since the last frame) extern fixed_t renderdeltatics; // The current render is a new logical tic From e3b0204b2c6d658ed8d3c175adef01e2d7957e9b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 13:32:46 +0200 Subject: [PATCH 44/62] fix main menu interpolation apparently in main menu, opening the menu pauses the game so rendertimefrac was FRACUNIT and didnt interpolate --- src/f_finale.c | 10 +++++----- src/r_main.c | 5 +++++ src/r_main.h | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 7f86303c0..18eab51eb 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -170,8 +170,8 @@ static void F_SkyScroll(INT32 scrollspeed) w = (vid.width / vid.dupx)<width)*16))<width)<width)*16))<width)*16))<width)<width)*16))<= 20) V_DrawSmallScaledPatch(84, 87, 0, ttkart); else if (finalecount >= 10) - V_DrawSciencePatch((84< Date: Sun, 6 Oct 2024 14:30:21 +0200 Subject: [PATCH 45/62] only do this in replays otherwise shit will jitter during netlag --- 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 f61753a19..90b4bbd55 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1359,7 +1359,7 @@ void R_SkyboxFrame(player_t *player) // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); } void R_SetupFrame(player_t *player, boolean skybox) @@ -1486,7 +1486,7 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->player = player; - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); } #define ANGLED_PORTALS From 48a00ba911ba0861b65b4bd4c0872cf63549a7df Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 14:52:54 +0200 Subject: [PATCH 46/62] this needs to be set twice Zzz... --- src/g_game.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 1b6beb96c..6b61f0a43 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1999,12 +1999,18 @@ INT32 G_CountPlayersPotentiallyViewable(boolean active) static void G_FixCamera(UINT8 view) { player_t *player = &players[displayplayers[view - 1]]; + // The order of displayplayers can change, which would // invalidate localangle. localangle[view - 1] = player->cmd.angleturn; + P_ResetCamera(player, &camera[view - 1]); + // Make sure the viewport doesn't interpolate at all into // its new position -- just snap instantly into place. + + // Why does it need to be done twice? + R_ResetViewInterpolation(view); R_ResetViewInterpolation(view); } From cfdbf1f4ad60472cadb983b0e663e615f5d619a7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 14:53:10 +0200 Subject: [PATCH 47/62] hopefully fix awayview cam interp crap --- src/p_spec.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index c0ad9ea7f..2a4e13d55 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2485,6 +2485,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 422: // Cut away to another view { mobj_t *altview; + INT32 i; if (!mo || !mo->player) // only players have views return; @@ -2499,6 +2500,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_SetTarget(&mo->player->awayviewmobj, altview); mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS; + if (gamestate == GS_LEVEL) + { + for (i = 0; i <= splitscreen; i++) + { + if (displayplayers[i] == (mo->player - players)) + { + R_ResetViewInterpolation(i + 1); + R_ResetViewInterpolation(i + 1); + } + } + } + if (line->flags & ML_NOCLIMB) // lets you specify a vertical angle { INT32 aim; From 6722b4324465fb777b1bc044312f9538272f60fb Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 18:31:09 +0200 Subject: [PATCH 48/62] rendertimefrac_unpaused should be fracunit on netlag makes this a little more sane tbh --- src/d_main.c | 4 ++-- src/r_main.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 28c1dd594..fd07648be 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -826,7 +826,7 @@ void D_SRB2Loop(void) rendertimefrac = FRACUNIT; } - rendertimefrac_unpaused = g_time.timefrac; + rendertimefrac_unpaused = (!hu_stopped) ? g_time.timefrac : FRACUNIT; } else { @@ -856,7 +856,7 @@ void D_SRB2Loop(void) LUA_Step(); #ifdef HAVE_DISCORDRPC - if (! dedicated) + if (!dedicated) { Discord_RunCallbacks(); } diff --git a/src/r_main.c b/src/r_main.c index 90b4bbd55..f61753a19 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1359,7 +1359,7 @@ void R_SkyboxFrame(player_t *player) // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); } void R_SetupFrame(player_t *player, boolean skybox) @@ -1486,7 +1486,7 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->player = player; - R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); } #define ANGLED_PORTALS From d1346dee533741b8ab4081622aa38560bbe87445 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 18:31:40 +0200 Subject: [PATCH 49/62] shouldnt that be a bool? --- src/d_clisrv.c | 2 +- src/d_clisrv.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f9110bb2d..ce6871288 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -136,7 +136,7 @@ static UINT8 gamestate_resend_counter[MAXNETNODES]; #endif // kart, true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks -UINT8 hu_stopped = 0; +boolean hu_stopped = false; // Client specific static ticcmd_t localcmds; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index cc123b1d2..197f3b794 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -656,7 +656,7 @@ extern UINT8 hu_resynching; #ifdef SATURNSYNCH extern UINT8 hu_redownloadinggamestate; #endif -extern UINT8 hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player +extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player typedef struct rewind_s { UINT8 savebuffer[(768*1024)]; From c82148fafc3e12cb4b6ba2a015413e7fc5064079 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 18:44:14 +0200 Subject: [PATCH 50/62] prevent this from become super large somehow lol just like cap it at 19 it works just fine --- src/d_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index fd07648be..471d29fa2 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -654,7 +654,7 @@ static boolean D_Display(void) // ========================================================================= tic_t rendergametic; -static int menuInputDelayTimer = 0; +static SINT8 menuInputDelayTimer = 0; void D_SRB2Loop(void) { @@ -792,9 +792,10 @@ void D_SRB2Loop(void) event_t myev; myev.type = ev_keydown; - menuInputDelayTimer++; + if (menuInputDelayTimer < 19) + menuInputDelayTimer++; - if (menuInputDelayTimer >= 19) // TICRATE * ( (k+2) (1 - [wz + h + j - q]^2 - [(gk + 2g + k + 1)(h + j) + h - z]^2 - [16(k + 1)^3(k + 2)(n + 1)^2 + 1 - f^2]^2 calculated by my butt + if (menuInputDelayTimer == 19) // TICRATE * ( (k+2) (1 - [wz + h + j - q]^2 - [(gk + 2g + k + 1)(h + j) + h - z]^2 - [16(k + 1)^3(k + 2)(n + 1)^2 + 1 - f^2]^2 calculated by my butt { if (DPADUPSCROLL) DPADSCROLLINPUT(KEY_UPARROW) From 3f5b96bd4532ef2d27fc8c2ab3b22e302d0d3129 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 18:33:25 +0200 Subject: [PATCH 51/62] this shouldnt be here lol --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ce6871288..345431d4e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6385,7 +6385,7 @@ boolean TryRunTics(tic_t realtics) if (demo.playback) { - neededtic = gametic + realtics * (gamestate == GS_LEVEL ? cv_playbackspeed.value : 1); + neededtic = gametic + realtics; // start a game after a demo maketic += realtics; firstticstosend = maketic; From e47c13b7ac5540cda013efdc0ac9534b7960af30 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Oct 2024 23:01:03 +0200 Subject: [PATCH 52/62] proper inline M_Memcpy --- src/doomdef.h | 7 ++++++- src/m_misc.c | 5 ----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index bdc82a0ca..92e45ac1a 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -474,7 +474,12 @@ void M_StartupLocale(void); // M_GetText function that just returns the string. #define M_GetText(x) (x) #endif -void *M_Memcpy(void* dest, const void* src, size_t n); + +FUNCINLINE static ATTRINLINE void *M_Memcpy(void *dest, const void *src, size_t n) +{ + return memcpy(dest, src, n); +} + char *va(const char *format, ...) FUNCPRINTF; char *M_GetToken(const char *inputString); char *sizeu1(size_t num); diff --git a/src/m_misc.c b/src/m_misc.c index b8c88abb5..8bb82cdd7 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1987,11 +1987,6 @@ char *sizeu5(size_t num) return sizeu5_buf; } -FUNCINLINE ATTRINLINE void *M_Memcpy(void *dest, const void *src, size_t n) -{ - return memcpy(dest, src, n); -} - /** Return the appropriate message for a file error or end of file. */ const char *M_FileError(FILE *fp) From 9d13ff3c9fa18d97f828133ee585b16c61dbd8dd Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Oct 2024 23:01:17 +0200 Subject: [PATCH 53/62] proper inline P_MobjWasRemoved --- src/p_local.h | 8 +++++++- src/p_mobj.c | 7 ------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index ab078e8b5..0902c8b3d 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -249,7 +249,7 @@ void P_RecalcPrecipInSector(sector_t *sector); void P_PrecipitationEffects(void); void P_RemoveMobj(mobj_t *th); -boolean P_MobjWasRemoved(const mobj_t *th); + void P_RemoveSavegameMobj(mobj_t *th); boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state); boolean P_SetMobjState(mobj_t *mobj, statenum_t state); @@ -261,6 +261,12 @@ boolean P_RailThinker(mobj_t *mobj); void P_PushableThinker(mobj_t *mobj); void P_SceneryThinker(mobj_t *mobj); +// This does not need to be added to Lua. +// To test it in Lua, check mobj.valid +FUNCINLINE static ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj) +{ + return !(mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker); +} fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect); fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect); diff --git a/src/p_mobj.c b/src/p_mobj.c index fb5a0fd0a..0fc870045 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10140,13 +10140,6 @@ void P_RemoveMobj(mobj_t *mobj) } } -// This does not need to be added to Lua. -// To test it in Lua, check mobj.valid -FUNCINLINE ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj) -{ - return !(mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker); -} - void P_FreePrecipMobj(precipmobj_t *mobj) { // unlink from sector and block lists From aa0cbfda74b55539b8355f683104259147cd858a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 9 Oct 2024 15:32:51 +0200 Subject: [PATCH 54/62] Revert "rendertimefrac_unpaused should be fracunit on netlag" This reverts commit 6722b4324465fb777b1bc044312f9538272f60fb. --- src/d_main.c | 4 ++-- src/r_main.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 471d29fa2..996d879e3 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -827,7 +827,7 @@ void D_SRB2Loop(void) rendertimefrac = FRACUNIT; } - rendertimefrac_unpaused = (!hu_stopped) ? g_time.timefrac : FRACUNIT; + rendertimefrac_unpaused = g_time.timefrac; } else { @@ -857,7 +857,7 @@ void D_SRB2Loop(void) LUA_Step(); #ifdef HAVE_DISCORDRPC - if (!dedicated) + if (! dedicated) { Discord_RunCallbacks(); } diff --git a/src/r_main.c b/src/r_main.c index f61753a19..90b4bbd55 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1359,7 +1359,7 @@ void R_SkyboxFrame(player_t *player) // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); } void R_SetupFrame(player_t *player, boolean skybox) @@ -1486,7 +1486,7 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->player = player; - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); } #define ANGLED_PORTALS From 1428c3c2bfb74f2e08eb727120945a0c32134a97 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Oct 2024 21:00:05 +0200 Subject: [PATCH 55/62] fix spec cam bug + more cleanup --- src/r_main.c | 59 +++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 90b4bbd55..618899c72 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1362,6 +1362,27 @@ void R_SkyboxFrame(player_t *player) R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); } +static void +R_SetupCommonFrame +( player_t * player, + subsector_t * subsector) +{ + newview->player = player; + + newview->x += quake.x; + newview->y += quake.y; + newview->z += quake.z; + + newview->roll = R_ViewRollAngle(player); + + if (subsector) + newview->sector = subsector->sector; + else + newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; + + R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); +} + void R_SetupFrame(player_t *player, boolean skybox) { camera_t *thiscam; @@ -1393,7 +1414,6 @@ void R_SetupFrame(player_t *player, boolean skybox) { SETUPCAM(0, cv_chasecam, VIEWCONTEXT_PLAYER1) } - #undef SETUPCAM if (player->spectator) // no spectator chasecam @@ -1410,25 +1430,20 @@ void R_SetupFrame(player_t *player, boolean skybox) thiscam->chase = false; newview->sky = !skybox; - if (player->awayviewtics) + + if (player->awayviewtics) // cut-away view stuff { - // cut-away view stuff viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN I_Assert(viewmobj != NULL); newview->x = viewmobj->x; newview->y = viewmobj->y; newview->z = viewmobj->z + 20*FRACUNIT; + newview->aim = player->awayviewaiming; newview->angle = viewmobj->angle; - newview->x += quake.x; - newview->y += quake.y; - - if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && thiscam && thiscam->subsector->sector) - newview->sector = viewmobj->subsector->sector; - else - newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; + R_SetupCommonFrame(player, viewmobj->subsector); } else if (!player->spectator && (thiscam && chasecam)) // use outside cam view { @@ -1437,24 +1452,21 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->x = thiscam->x; newview->y = thiscam->y; newview->z = thiscam->z + (thiscam->height>>1); + newview->aim = thiscam->aiming; newview->angle = thiscam->angle; - newview->x += quake.x; - newview->y += quake.y; - - if (thiscam->subsector && thiscam->subsector->sector) - newview->sector = thiscam->subsector->sector; - else - newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; + R_SetupCommonFrame(player, thiscam->subsector); } else // use the player's eyes view { - newview->z = player->viewz; - viewmobj = player->mo; I_Assert(viewmobj != NULL); + newview->x = viewmobj->x; + newview->y = viewmobj->y; + newview->z = player->viewz; + newview->aim = player->aiming; newview->angle = viewmobj->angle; @@ -1479,14 +1491,9 @@ void R_SetupFrame(player_t *player, boolean skybox) } } } + + R_SetupCommonFrame(player, viewmobj->subsector); } - - newview->roll = R_ViewRollAngle(player); - newview->z += quake.z; - - newview->player = player; - - R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); } #define ANGLED_PORTALS From c33afa4a3bf70ff9a592d28778b163ef5e729dd0 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Oct 2024 19:09:49 +0200 Subject: [PATCH 56/62] shut up mingw --- src/lzf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lzf.c b/src/lzf.c index 28ba1b6cb..d5a837888 100644 --- a/src/lzf.c +++ b/src/lzf.c @@ -166,7 +166,7 @@ typedef unsigned char u8; #ifdef LZF_HSLOT # define LZF_HSLOT_BIAS ((const u8 *)in_data) #else -# if LZF_USE_OFFSETS +# ifdef LZF_USE_OFFSETS # define LZF_HSLOT_BIAS ((const u8 *)in_data) typedef unsigned int LZF_HSLOT; # else From b6a84c1646204332adc148b3c2ca36047ace765d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Oct 2024 19:39:52 +0200 Subject: [PATCH 57/62] readd music_resync_powerups_only --- src/m_menu.c | 1 + src/p_spec.c | 4 +--- src/s_sound.c | 2 ++ src/s_sound.h | 1 + src/sdl/mixer_sound.c | 4 +++- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 2bfb3e1f1..62a303d7e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2577,6 +2577,7 @@ static menuitem_t OP_AdvancedBirdMenu[] = {IT_STRING | IT_CVAR, NULL, "Fade Back In While Respawning", &cv_respawnfademusicback, 40}, {IT_STRING | IT_CVAR, NULL, "Resync Threshold", &cv_music_resync_threshold, 60}, + {IT_STRING | IT_CVAR, NULL, "Resync Special Music Only", &cv_music_resync_powerups_only, 70}, }; static const char* OP_AdvancedBirdTooltips[] = diff --git a/src/p_spec.c b/src/p_spec.c index 2a4e13d55..81d5ad8b4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2179,9 +2179,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) mapmusflags |= MUSIC_FORCERESET; mapmusposition = position; - - if (cv_birdmusic.value) - mapmusresume = 0; + mapmusresume = 0; S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position, !(line->flags & ML_EFFECT2) ? prefadems : 0, diff --git a/src/s_sound.c b/src/s_sound.c index ec5ebf00d..9496ea4e9 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -107,6 +107,7 @@ static CV_PossibleValue_t music_resync_threshold_cons_t[] = { {0} }; consvar_t cv_music_resync_threshold = {"music_resync_threshold", "0", CV_SAVE|CV_CALL, music_resync_threshold_cons_t, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_music_resync_powerups_only = {"music_resync_powerups_only", "No", CV_SAVE|CV_CALL, CV_YesNo, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -281,6 +282,7 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_pausemusic); CV_RegisterVar(&cv_music_resync_threshold); + CV_RegisterVar(&cv_music_resync_powerups_only); CV_RegisterVar(&cv_invincmusicfade); CV_RegisterVar(&cv_growmusicfade); diff --git a/src/s_sound.h b/src/s_sound.h index 6f4d03f09..899d0e043 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -54,6 +54,7 @@ extern consvar_t cv_amigatype; //bird music stuff extern consvar_t cv_music_resync_threshold; +extern consvar_t cv_music_resync_powerups_only; extern consvar_t cv_invincmusicfade; extern consvar_t cv_growmusicfade; diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 12abb7c65..2fb3dc621 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -93,6 +93,8 @@ static UINT16 SAMPLERATE = 44100; /// ------------------------ UINT8 sound_started = false; + +static UINT32 stutter_threshold_user; static UINT32 stutter_threshold; static Mix_Music *music; @@ -1046,7 +1048,7 @@ void I_UpdateSongLagThreshold (void) if (!cv_birdmusic.value) return; - stutter_threshold = cv_music_resync_threshold.value/1000.0*(4*44100); + stutter_threshold = cv_music_resync_powerups_only.value ? 0 : (cv_music_resync_threshold.value/1000.0*(4*44100)); } /// ------------------------ From 659243baa1302c2937c0568cf91d6de590e8638f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Oct 2024 19:44:15 +0200 Subject: [PATCH 58/62] always assign stutter_threshold --- src/sdl/mixer_sound.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 2fb3dc621..3f36399b3 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -594,6 +594,9 @@ Countstutter (int len) { UINT32 bytes; + if (!cv_birdmusic.value || gamestate != GS_LEVEL) + return; + if (hu_stopped) { music_stutter_bytes += len; @@ -629,8 +632,7 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata) music_bytes += len; - if (cv_birdmusic.value && gamestate == GS_LEVEL) - Countstutter(len); + Countstutter(len); } static void music_loop(void) @@ -1045,9 +1047,6 @@ UINT32 I_GetSongPosition(void) void I_UpdateSongLagThreshold (void) { - if (!cv_birdmusic.value) - return; - stutter_threshold = cv_music_resync_powerups_only.value ? 0 : (cv_music_resync_threshold.value/1000.0*(4*44100)); } From 8630d8cd4759ba63a37cda17739c5f9e3d07c2e8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Oct 2024 19:54:56 +0200 Subject: [PATCH 59/62] clean bird music stuff again we dont need to return everywhere but instead stuff can be mostly just set to 0 this also somewhat ensures stuff works after toggling without having to restart the game or map --- src/p_user.c | 16 +++++----------- src/s_sound.c | 9 ++++----- src/sdl/mixer_sound.c | 2 +- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index a9b1b6b72..4cdbd2ae5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -800,19 +800,13 @@ void P_RestoreMusic(player_t *player) if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1)) S_SpeedMusic(1.2f); #endif - if (cv_birdmusic.value) - { - if (mapmusresume && cv_resume.value) - position = mapmusresume; - else - position = mapmusposition; - - S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn()); - S_ClearRestoreMusicFadeInCvar(); - } + if (mapmusresume && cv_resume.value) // mapmusresume will be 0 anyways when birdmusic stuff is disabled + position = mapmusresume; else - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + position = mapmusposition; + S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn()); + S_ClearRestoreMusicFadeInCvar(); mapmusresume = 0; } } diff --git a/src/s_sound.c b/src/s_sound.c index 9496ea4e9..2abafc7ee 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2036,8 +2036,10 @@ void S_StopMusic(void) || demo.title) // SRB2Kart: Demos don't interrupt title screen music return; - if ((cv_birdmusic.value) && (strcasecmp(music_name, mapmusname) == 0)) + if (cv_birdmusic.value && (strcasecmp(music_name, mapmusname) == 0)) mapmusresume = I_GetSongPosition(); + else + mapmusresume = 0; if (I_SongPaused()) I_ResumeSong(); @@ -2110,10 +2112,7 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) void S_SetRestoreMusicFadeInCvar (consvar_t *cv) { - if (!cv_birdmusic.value) - return; - - music_refade_cv = cv; + music_refade_cv = cv_birdmusic.value ? cv : 0; } int S_GetRestoreMusicFadeIn (void) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 3f36399b3..854b451ad 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1045,7 +1045,7 @@ UINT32 I_GetSongPosition(void) // 8M: 1 | 8S: 2 | 16M: 2 | 16S: 4 } -void I_UpdateSongLagThreshold (void) +void I_UpdateSongLagThreshold(void) { stutter_threshold = cv_music_resync_powerups_only.value ? 0 : (cv_music_resync_threshold.value/1000.0*(4*44100)); } From 4927e55c7ea8baafc00d7fbaa929a5130602b086 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Oct 2024 21:23:58 +0200 Subject: [PATCH 60/62] fix some warnings when compiling with older sdl version --- src/sdl/i_system.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 444fbb370..0815ee968 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2668,6 +2668,7 @@ void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, (void)device_id; (void)low_strength; (void)high_strength; + (void)duration; #else I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher @@ -2685,6 +2686,9 @@ void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 b { #if !(SDL_VERSION_ATLEAST(2,0,14)) (void)device_id; + (void)red; + (void)green; + (void)blue; #else I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher From 2e7f0721b9e48a89ed94fe51c8abe5cb143d4b68 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Oct 2024 21:24:37 +0200 Subject: [PATCH 61/62] make s_sound a little prettier --- src/s_sound.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 2abafc7ee..f8db2b296 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -276,14 +276,14 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_gamemidimusic); #endif - //bird music stuff + // bird music stuff CV_RegisterVar(&cv_playmusicifunfocused); CV_RegisterVar(&cv_playsoundifunfocused); CV_RegisterVar(&cv_pausemusic); CV_RegisterVar(&cv_music_resync_threshold); CV_RegisterVar(&cv_music_resync_powerups_only); - + CV_RegisterVar(&cv_invincmusicfade); CV_RegisterVar(&cv_growmusicfade); @@ -295,6 +295,7 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_resume); CV_RegisterVar(&cv_fading); CV_RegisterVar(&cv_birdmusic); + // bird music stuff end COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); @@ -1244,7 +1245,7 @@ void S_InitSfxChannels(INT32 sfxVolume) if (S_PrecacheSound()) { // Initialize external data (all sounds) at start, keep static. - CONS_Printf(M_GetText("Loading sounds... ")); + CONS_Printf(M_GetText("Pre-caching sounds...")); for (i = 1; i < sfx_freeslot0; i++) if (S_sfx[i].name && !S_sfx[i].data) @@ -1254,7 +1255,7 @@ void S_InitSfxChannels(INT32 sfxVolume) if (S_sfx[i].priority && !S_sfx[i].data) S_sfx[i].data = I_GetSfx(&S_sfx[i]); - CONS_Printf(M_GetText(" pre-cached all sound data\n")); + CONS_Printf(M_GetText("...pre-cached all sound data\n")); } } @@ -1770,9 +1771,7 @@ boolean S_MusicPaused(void) boolean S_MusicNotInFocus(void) { - return ( - ( window_notinfocus && ! cv_playmusicifunfocused.value ) - ); + return (window_notinfocus && !cv_playmusicifunfocused.value); } musictype_t S_MusicType(void) @@ -1800,10 +1799,8 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi) { - return ( - (checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false) - || (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false) - ); + return (checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false) + || (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false); } /// ------------------------ @@ -2371,7 +2368,7 @@ static void GameDigiMusic_OnChange(void) digital_disabled = false; I_StartupSound(); // will return early if initialised I_InitMusic(); - + if (Playing()) P_RestoreMusic(&players[consoleplayer]); else @@ -2408,14 +2405,12 @@ static void ModFilter_OnChange(void) { if (openmpt_mhandle) openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value); - } static void StereoSep_OnChange(void) { if (openmpt_mhandle) openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT, cv_stereosep.value); - } static void AmigaFilter_OnChange(void) From 23b36b50749008fd2be4ecb44eb6de8b28576e80 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Oct 2024 21:29:39 +0200 Subject: [PATCH 62/62] oops --- src/sdl/mixer_sound.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 854b451ad..20cd3107c 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -94,7 +94,6 @@ static UINT16 SAMPLERATE = 44100; UINT8 sound_started = false; -static UINT32 stutter_threshold_user; static UINT32 stutter_threshold; static Mix_Music *music;