From 83d2ade6991c5252e6b98b3b619b729d43fe4091 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 12 Dec 2024 01:02:46 +0100 Subject: [PATCH 01/44] seperate thinkerlist for precip i sure hope i handled everything right lmao --- src/m_perfstats.c | 14 ++++++++++---- src/p_local.h | 2 ++ src/p_mobj.c | 2 +- src/p_saveg.c | 23 +++++++++++++++++------ src/p_spec.c | 4 ++-- src/p_tick.c | 41 +++++++++++++++++++++++++++++++++++------ src/r_main.c | 2 +- 7 files changed, 68 insertions(+), 20 deletions(-) diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 14980b162..e54d1df06 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -577,8 +577,7 @@ static void PS_CountThinkers(void) ps_removecount.value.i = 0; for (thinker = thinkercap.next; thinker != &thinkercap; thinker = thinker->next) { - if (thinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) - ps_thinkercount.value.i++; + ps_thinkercount.value.i++; if (thinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) ps_removecount.value.i++; @@ -593,11 +592,18 @@ static void PS_CountThinkers(void) else ps_regularcount.value.i++; } - else if (thinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) - ps_precipcount.value.i++; else ps_otherthcount.value.i++; } + + for (thinker = precipcap.next; thinker != &precipcap; thinker = thinker->next) + { + if (thinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) + continue; // not a precipmobj thinker + + ps_precipcount.value.i++; + } + /*for (i = 0; i < NUM_THINKERLISTS; i++) { for (thinker = thlist[i].next; thinker != &thlist[i]; thinker = thinker->next) diff --git a/src/p_local.h b/src/p_local.h index ea0bff603..acb62ad67 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -66,10 +66,12 @@ // both the head and tail of the thinker list extern thinker_t thinkercap; +extern thinker_t precipcap; extern mobj_t *mobjcache; void P_InitThinkers(void); void P_AddThinker(thinker_t *thinker); +void P_AddPrecipThinker(thinker_t *thinker); void P_RemoveThinker(thinker_t *thinker); void P_UnlinkThinker(thinker_t *thinker); diff --git a/src/p_mobj.c b/src/p_mobj.c index 03e7e9f99..c9a316087 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10003,7 +10003,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->momz = cv_mobjscaleprecip.value ? FixedMul(info->speed, mapobjectscale) : info->speed; mobj->thinker.function.acp1 = (actionf_p1)P_NullPrecipThinker; - P_AddThinker(&mobj->thinker); + P_AddPrecipThinker(&mobj->thinker); CalculatePrecipFloor(mobj); diff --git a/src/p_saveg.c b/src/p_saveg.c index 898a53d68..5b70695d7 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1680,8 +1680,7 @@ static void P_NetArchiveThinkers(savebuffer_t *save) // save off the current thinkers for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed - || th->function.acp1 == (actionf_p1)P_NullPrecipThinker)) + if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) numsaved++; if (th->function.acp1 == (actionf_p1)P_MobjThinker) @@ -1689,9 +1688,6 @@ static void P_NetArchiveThinkers(savebuffer_t *save) SaveMobjThinker(save, th, tc_mobj); continue; } -#ifdef PARANOIA - else if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker); -#endif else if (th->function.acp1 == (actionf_p1)T_MoveCeiling) { SaveCeilingThinker(save, th, tc_ceiling); @@ -2685,7 +2681,22 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) { next = currentthinker->next; - if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker || currentthinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) + if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) + P_RemoveSavegameMobj((mobj_t *)currentthinker); // item isn't saved, don't remove it + else + { + (next->prev = currentthinker->prev)->next = next; + R_DestroyLevelInterpolators(currentthinker); + Z_Free(currentthinker); + } + } + + currentthinker = precipcap.next; + for (currentthinker = precipcap.next; currentthinker != &precipcap; currentthinker = next) + { + next = currentthinker->next; + + if (currentthinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) P_RemoveSavegameMobj((mobj_t *)currentthinker); // item isn't saved, don't remove it else { diff --git a/src/p_spec.c b/src/p_spec.c index d272764be..ee76ae542 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1779,7 +1779,7 @@ void P_SwitchWeather(INT32 weathernum) thinker_t *next; precipmobj_t *precipmobj; - for (think = thinkercap.next; think != &thinkercap; think = next) + for (think = precipcap.next; think != &precipcap; think = next) { next = think->next; @@ -1796,7 +1796,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj_t *precipmobj; state_t *st; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = precipcap.next; think != &precipcap; think = think->next) { if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker diff --git a/src/p_tick.c b/src/p_tick.c index 3b0cadde8..e6239e312 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -49,6 +49,7 @@ tic_t leveltime; // Both the head and tail of the thinker list. thinker_t thinkercap; +thinker_t precipcap; void Command_Numthinkers_f(void) { @@ -104,12 +105,25 @@ void Command_Numthinkers_f(void) return; } - for (think = thinkercap.next; think != &thinkercap; think = think->next) + if (num == 2) // P_NullPrecipThinker { - if (think->function.acp1 != action) - continue; + for (think = precipcap.next; think != &precipcap; think = think->next) + { + if (think->function.acp1 != action) + continue; - count++; + count++; + } + } + else + { + for (think = thinkercap.next; think != &thinkercap; think = think->next) + { + if (think->function.acp1 != action) + continue; + + count++; + } } CONS_Printf("%d\n", count); @@ -181,6 +195,7 @@ void Command_CountMobjs_f(void) void P_InitThinkers(void) { thinkercap.prev = thinkercap.next = &thinkercap; + precipcap.prev = precipcap.next = &precipcap; waypointcap = NULL; } @@ -200,6 +215,22 @@ void P_AddThinker(thinker_t *thinker) thinker->cachable = (thinker->function.acp1 == (actionf_p1)P_MobjThinker); } +// +// P_AddPrecipThinker +// Adds a new precip thinker at the end of the list. +// +void P_AddPrecipThinker(thinker_t *thinker) +{ + precipcap.prev->next = thinker; + thinker->next = &precipcap; + thinker->prev = precipcap.prev; + precipcap.prev = thinker; + + thinker->references = 0; // killough 11/98: init reference counter to 0 + + thinker->cachable = false; +} + // // killough 11/98: // @@ -341,8 +372,6 @@ static inline void P_RunThinkers(void) { for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) - continue; #ifdef PARANOIA I_Assert(currentthinker->function.acp1 != NULL) #endif diff --git a/src/r_main.c b/src/r_main.c index 9541fef41..01c97652b 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -284,7 +284,7 @@ static void Precipstuff_OnChange(void) thinker_t *next; precipmobj_t *precipmobj; - for (think = thinkercap.next; think != &thinkercap; think = next) + for (think = precipcap.next; think != &precipcap; think = next) { next = think->next; -- 2.54.0 From ffc7832ec76df571666da187cfeaaa42360e900a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 31 Dec 2024 00:57:32 +0100 Subject: [PATCH 02/44] attempt to optimize column drawers a little --- src/r_draw8.c | 665 +++++++++++++++++++++++++++++-------------------- src/r_things.c | 3 + 2 files changed, 400 insertions(+), 268 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 3c7562beb..30fe49372 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -34,17 +34,19 @@ void R_DrawColumn_8(void) count = dc_yh - dc_yl; if (count < 0) // Zero length, column does not exceed a pixel. + { return; + } + -#ifdef RANGECHECK if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + { return; -#endif + } // Framebuffer destination address. // Use ylookup LUT to avoid multiply with ScreenWidth. // Use columnofs LUT for subwindows? - dest = &topleft[dc_yl*vid.width + dc_x]; count++; @@ -55,10 +57,15 @@ void R_DrawColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. + register const UINT8 *source = dc_source; + register const lighttable_t *colormap = dc_colormap; + + register INT32 heightmask = dc_texheight-1; + + if (dc_texheight & heightmask) // not a power of 2 -- killough { - register const UINT8 *source = dc_source; - register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight-1; + heightmask++; + heightmask <<= FRACBITS; if (dc_sourcelength <= 0) { @@ -73,55 +80,77 @@ void R_DrawColumn_8(void) npow2max = dc_sourcelength; } - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (frac < 0) { - heightmask++; - heightmask <<= FRACBITS; - - if (frac < 0) - while ((frac += heightmask) < 0); - else - while (frac >= heightmask) - frac -= heightmask; - - do + while ((frac += heightmask) < 0) { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - *dest = colormap[source[CLAMP(frac>>FRACBITS, npow2min, npow2max)]]; - dest += vid.width; - - // Avoid overflow. - if (fracstep > 0x7FFFFFFF - frac) - frac += fracstep - heightmask; - else - frac += fracstep; - - while (frac >= heightmask) - frac -= heightmask; - } while (--count); + ; + } } else { - while ((count -= 2) >= 0) // texture height is a power of 2 + while (frac >= heightmask) { - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; - dest += vid.width; - frac += fracstep; + frac -= heightmask; + } + } - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; - dest += vid.width; + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix + + // -1 is the lower clamp bound because column posts have a "safe" byte before the real data + // and a few bytes after as well + + // jartha: faster on my AMD FX-6300 CPU. + // Faster than ternaries, faster than std::min/std::max. Don't ask me why. + // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. + // The framerate difference was about 50 frames at 640x400. + INT32 n = frac >> FRACBITS; + if (n < npow2min) + n = npow2min; + if (n > npow2max) + n = npow2max; + *dest = colormap[source[n]]; + + dest += vid.width; + + // Avoid overflow. + if (fracstep > 0x7FFFFFFF - frac) + { + frac += fracstep - heightmask; + } + else + { frac += fracstep; } - if (count & 1) + while (frac >= heightmask) { - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + frac -= heightmask; } + } while (--count); + } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 + { + *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + + dest += vid.width; + frac += fracstep; + + *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + + dest += vid.width; + frac += fracstep; + } + + if (count & 1) + { + *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; } } } @@ -139,34 +168,37 @@ void R_Draw2sMultiPatchColumn_8(void) count = dc_yh - dc_yl; if (count < 0) // Zero length, column does not exceed a pixel. + { return; + } -#ifdef RANGECHECK if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + { return; -#endif + } // Framebuffer destination address. // Use ylookup LUT to avoid multiply with ScreenWidth. // Use columnofs LUT for subwindows? - - //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; count++; // Determine scaling, which is the only mapping to be done. fracstep = dc_iscale; - //frac = dc_texturemid + (dc_yl - centery)*fracstep; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. + register const UINT8 *source = dc_source; + register const lighttable_t *colormap = dc_colormap; + register INT32 heightmask = dc_texheight-1; + register UINT8 val; + + if (dc_texheight & heightmask) // not a power of 2 -- killough { - register const UINT8 *source = dc_source; - register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight-1; - register UINT8 val; + heightmask++; + heightmask <<= FRACBITS; if (dc_sourcelength <= 0) { @@ -181,74 +213,94 @@ void R_Draw2sMultiPatchColumn_8(void) npow2max = dc_sourcelength; } - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (frac < 0) { - heightmask++; - heightmask <<= FRACBITS; - - if (frac < 0) - while ((frac += heightmask) < 0); - else - while (frac >= heightmask) - frac -= heightmask; - - do + while ((frac += heightmask) < 0) { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - val = source[CLAMP(frac>>FRACBITS, npow2min, npow2max)]; - - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } - - dest += vid.width; - - // Avoid overflow. - if (fracstep > 0x7FFFFFFF - frac) - frac += fracstep - heightmask; - else - frac += fracstep; - - while (frac >= heightmask) - frac -= heightmask; - } while (--count); + ; + } } else { - while ((count -= 2) >= 0) // texture height is a power of 2 + while (frac >= heightmask) { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } + frac -= heightmask; + } + } - dest += vid.width; - frac += fracstep; + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } + // -1 is the lower clamp bound because column posts have a "safe" byte before the real data + // and a few bytes after as well - dest += vid.width; + // jartha: faster on my AMD FX-6300 CPU. + // Faster than ternaries, faster than std::min/std::max. Don't ask me why. + // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. + // The framerate difference was about 50 frames at 640x400. + INT32 n = frac >> FRACBITS; + if (n < npow2min) + n = npow2min; + if (n > npow2max) + n = npow2max; + + val = source[n]; + + if (val != TRANSPARENTPIXEL) + { + *dest = colormap[val]; + } + + dest += vid.width; + + // Avoid overflow. + if (fracstep > 0x7FFFFFFF - frac) + { + frac += fracstep - heightmask; + } + else + { frac += fracstep; } - if (count & 1) + while (frac >= heightmask) { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } + frac -= heightmask; + } + } while (--count); + } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 + { + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = colormap[val]; + } + + dest += vid.width; + frac += fracstep; + + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = colormap[val]; + } + + dest += vid.width; + frac += fracstep; + } + + if (count & 1) + { + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = colormap[val]; } } } @@ -266,35 +318,38 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) count = dc_yh - dc_yl; if (count < 0) // Zero length, column does not exceed a pixel. + { return; + } -#ifdef RANGECHECK if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + { return; -#endif + } // Framebuffer destination address. // Use ylookup LUT to avoid multiply with ScreenWidth. // Use columnofs LUT for subwindows? - - //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; count++; // Determine scaling, which is the only mapping to be done. fracstep = dc_iscale; - //frac = dc_texturemid + (dc_yl - centery)*fracstep; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. + register const UINT8 *source = dc_source; + register const UINT8 *transmap = dc_transmap; + register const lighttable_t *colormap = dc_colormap; + register INT32 heightmask = dc_texheight-1; + register UINT8 val; + + if (dc_texheight & heightmask) // not a power of 2 -- killough { - register const UINT8 *source = dc_source; - register const UINT8 *transmap = dc_transmap; - register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight-1; - register UINT8 val; + heightmask++; + heightmask <<= FRACBITS; if (dc_sourcelength <= 0) { @@ -309,74 +364,94 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) npow2max = dc_sourcelength; } - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (frac < 0) { - heightmask++; - heightmask <<= FRACBITS; - - if (frac < 0) - while ((frac += heightmask) < 0); - else - while (frac >= heightmask) - frac -= heightmask; - - do + while ((frac += heightmask) < 0) { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - val = source[CLAMP(frac>>FRACBITS, npow2min, npow2max)]; - - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } - - dest += vid.width; - - // Avoid overflow. - if (fracstep > 0x7FFFFFFF - frac) - frac += fracstep - heightmask; - else - frac += fracstep; - - while (frac >= heightmask) - frac -= heightmask; - } while (--count); + ; + } } else { - while ((count -= 2) >= 0) // texture height is a power of 2 + while (frac >= heightmask) { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } + frac -= heightmask; + } + } - dest += vid.width; - frac += fracstep; + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } + // -1 is the lower clamp bound because column posts have a "safe" byte before the real data + // and a few bytes after as well - dest += vid.width; + // jartha: faster on my AMD FX-6300 CPU. + // Faster than ternaries, faster than std::min/std::max. Don't ask me why. + // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. + // The framerate difference was about 50 frames at 640x400. + INT32 n = frac >> FRACBITS; + if (n < npow2min) + n = npow2min; + if (n > npow2max) + n = npow2max; + + val = source[n]; + + if (val != TRANSPARENTPIXEL) + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); + } + + dest += vid.width; + + // Avoid overflow. + if (fracstep > 0x7FFFFFFF - frac) + { + frac += fracstep - heightmask; + } + else + { frac += fracstep; } - if (count & 1) + while (frac >= heightmask) { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } + frac -= heightmask; + } + } while (--count); + } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 + { + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); + } + + dest += vid.width; + frac += fracstep; + + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); + } + + dest += vid.width; + frac += fracstep; + } + + if (count & 1) + { + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); } } } @@ -396,21 +471,22 @@ void R_DrawShadeColumn_8(void) return; count = dc_yh - dc_yl; - if (count < 0) - return; -#ifdef RANGECHECK + if (count < 0) // Zero length, column does not exceed a pixel. + { + return; + } + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - I_Error("R_DrawShadeColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x); -#endif + { + return; + } // FIXME. As above. - //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; // Looks familiar. fracstep = dc_iscale; - //frac = dc_texturemid + (dc_yl - centery)*fracstep; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Here we do an additional index re-mapping. @@ -438,29 +514,33 @@ void R_DrawTranslucentColumn_8(void) count = dc_yh - dc_yl + 1; if (count <= 0) // Zero length, column does not exceed a pixel. + { return; + } -#ifdef RANGECHECK if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - I_Error("R_DrawTranslucentColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x); -#endif + { + return; + } // FIXME. As above. - //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; // Looks familiar. fracstep = dc_iscale; - //frac = dc_texturemid + (dc_yl - centery)*fracstep; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. + register const UINT8 *source = dc_source; + register const UINT8 *transmap = dc_transmap; + register const lighttable_t *colormap = dc_colormap; + register INT32 heightmask = dc_texheight - 1; + + if (dc_texheight & heightmask) { - register const UINT8 *source = dc_source; - register const UINT8 *transmap = dc_transmap; - register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight - 1; + heightmask++; + heightmask <<= FRACBITS; if (dc_sourcelength <= 0) { @@ -475,53 +555,68 @@ void R_DrawTranslucentColumn_8(void) npow2max = dc_sourcelength; } - if (dc_texheight & heightmask) + if (frac < 0) { - heightmask++; - heightmask <<= FRACBITS; - - if (frac < 0) - while ((frac += heightmask) < 0) - ; - else - while (frac >= heightmask) - frac -= heightmask; - - do + while ((frac += heightmask) < 0) { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - *dest = *(transmap + (colormap[source[CLAMP(frac>>FRACBITS, npow2min, npow2max)]]<<8) + (*dest)); - - dest += vid.width; - - if ((frac += fracstep) >= heightmask) - frac -= heightmask; + ; } - while (--count); } else { - while ((count -= 2) >= 0) // texture height is a power of 2 + while (frac >= heightmask) { - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; - - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; + frac -= heightmask; } + } - if (count & 1) + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix + + // -1 is the lower clamp bound because column posts have a "safe" byte before the real data + // and a few bytes after as well + + // jartha: faster on my AMD FX-6300 CPU. + // Faster than ternaries, faster than std::min/std::max. Don't ask me why. + // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. + // The framerate difference was about 50 frames at 640x400. + INT32 n = frac >> FRACBITS; + if (n < npow2min) + n = npow2min; + if (n > npow2max) + n = npow2max; + + *dest = *(transmap + (colormap[source[n]]<<8) + (*dest)); + + dest += vid.width; + + if ((frac += fracstep) >= heightmask) { - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + frac -= heightmask; } } + while (--count); + } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 + { + *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + dest += vid.width; + frac += fracstep; + + *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + dest += vid.width; + frac += fracstep; + } + + if (count & 1) + { + *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + } } } @@ -540,21 +635,30 @@ void R_DrawTranslatedTranslucentColumn_8(void) count = dc_yh - dc_yl + 1; if (count <= 0) // Zero length, column does not exceed a pixel. + { return; + } + + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + { + return; + } // FIXME. As above. - //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; // Looks familiar. fracstep = dc_iscale; - //frac = dc_texturemid + (dc_yl - centery)*fracstep; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. + register INT32 heightmask = dc_texheight - 1; + + if (dc_texheight & heightmask) { - register INT32 heightmask = dc_texheight - 1; + heightmask++; + heightmask <<= FRACBITS; if (dc_sourcelength <= 0) { @@ -569,52 +673,68 @@ void R_DrawTranslatedTranslucentColumn_8(void) npow2max = dc_sourcelength; } - if (dc_texheight & heightmask) + if (frac < 0) { - heightmask++; - heightmask <<= FRACBITS; - - if (frac < 0) - while ((frac += heightmask) < 0) - ; - else - while (frac >= heightmask) - frac -= heightmask; - - do + while ((frac += heightmask) < 0) { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[CLAMP(frac>>FRACBITS, npow2min, npow2max)]]]<<8) + (*dest)); - dest += vid.width; - - if ((frac += fracstep) >= heightmask) - frac -= heightmask; + ; } - while (--count); } else { - while ((count -= 2) >= 0) // texture height is a power of 2 + while (frac >= heightmask) { - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; - - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; + frac -= heightmask; } + } - if (count & 1) + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix + + // -1 is the lower clamp bound because column posts have a "safe" byte before the real data + // and a few bytes after as well + + // jartha: faster on my AMD FX-6300 CPU. + // Faster than ternaries, faster than std::min/std::max. Don't ask me why. + // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. + // The framerate difference was about 50 frames at 640x400. + INT32 n = frac >> FRACBITS; + if (n < npow2min) + n = npow2min; + if (n > npow2max) + n = npow2max; + + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[n]]]<<8) + (*dest)); + + dest += vid.width; + + if ((frac += fracstep) >= heightmask) { - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + frac -= heightmask; } } + while (--count); + } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 + { + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + dest += vid.width; + frac += fracstep; + + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + dest += vid.width; + frac += fracstep; + } + + if (count & 1) + { + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + } } } @@ -630,21 +750,22 @@ void R_DrawTranslatedColumn_8(void) register fixed_t frac, fracstep; count = dc_yh - dc_yl; - if (count < 0) - return; -#ifdef RANGECHECK + if (count < 0) + { + return; + } + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - I_Error("R_DrawTranslatedColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x); -#endif + { + return; + } // FIXME. As above. - //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; // Looks familiar. fracstep = dc_iscale; - //frac = dc_texturemid + (dc_yl-centery)*fracstep; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Here we do an additional index re-mapping. @@ -709,7 +830,9 @@ void R_DrawSpan_8 (void) dest = ylookup[ds_y] + columnofs[ds_x1]; if (dest+8 > deststop) + { return; + } while (count >= 8) { @@ -752,12 +875,18 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) // I wanna do some optimizing by checking for out-of-range segments on either side to fill in all at once, // but I'm too bad at coding to not crash the game trying to do that. I guess this is fast enough for now... - for (i = left; i <= right; i++) { + for (i = left; i <= right; i++) + { tiltlighting[i] = (start += step) >> FRACBITS; + if (tiltlighting[i] < 0) + { tiltlighting[i] = 0; + } else if (tiltlighting[i] >= MAXLIGHTSCALE) + { tiltlighting[i] = MAXLIGHTSCALE-1; + } } } diff --git a/src/r_things.c b/src/r_things.c index 94d108fec..511c26bd6 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -623,6 +623,7 @@ void R_DrawMaskedColumn(column_t *column) { dc_source = (UINT8 *)column + 3; dc_sourcelength = column->length; + dc_texheight = column->length; dc_texturemid = basetexturemid - (topdelta<length); dc_sourcelength = column->length; + dc_texheight = column->length; + for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s) *d++ = *s; dc_texturemid = basetexturemid - (topdelta< Date: Wed, 1 Jan 2025 05:06:52 +0100 Subject: [PATCH 03/44] dont iterate through precip blockmap if there is no precip --- 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 5eefc9c7e..aaf1cb2e6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4360,7 +4360,7 @@ static void HWR_AddPrecipitationSprites(void) fixed_t drawdist; // save a little time on invisible weather - if (curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) + if (curWeather == PRECIP_NONE || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) { return; } diff --git a/src/r_things.c b/src/r_things.c index 94d108fec..5de515d68 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1976,7 +1976,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 || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) + if (drawdist == 0 || curWeather == PRECIP_NONE || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) { return; } -- 2.54.0 From 136d9143e7c6a22ef3b9be725cf42de9d9f244ac Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 05:07:56 +0100 Subject: [PATCH 04/44] we dont really need to check for precipthinkers in the precip thinkerlist also makes precip handling in P_NetUnArchiveThinkers a little safer --- src/p_saveg.c | 23 ++++++++++++++--------- src/p_spec.c | 4 ++++ src/p_tick.c | 22 ++++++---------------- src/r_main.c | 2 ++ 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 5b70695d7..7bdea61b4 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2667,6 +2667,8 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) { thinker_t *currentthinker; thinker_t *next; + thinker_t *currentprecipthinker; + thinker_t *nextprecip; UINT8 tclass; UINT8 restoreNum = false; UINT32 i; @@ -2691,19 +2693,22 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) } } - currentthinker = precipcap.next; - for (currentthinker = precipcap.next; currentthinker != &precipcap; currentthinker = next) + // remove all the current precip thinkers + currentprecipthinker = precipcap.next; + for (currentprecipthinker = precipcap.next; currentprecipthinker != &precipcap; currentprecipthinker = nextprecip) { - next = currentthinker->next; + nextprecip = currentprecipthinker->next; - if (currentthinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) - P_RemoveSavegameMobj((mobj_t *)currentthinker); // item isn't saved, don't remove it - else +#ifdef PARANOIA + if (currentprecipthinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) { - (next->prev = currentthinker->prev)->next = next; - R_DestroyLevelInterpolators(currentthinker); - Z_Free(currentthinker); + (next->prev = currentprecipthinker->prev)->next = nextprecip; + R_DestroyLevelInterpolators(currentprecipthinker); + Z_Free(currentprecipthinker); } + else +#endif + P_RemoveSavegameMobj((mobj_t *)currentprecipthinker); // item isn't saved, don't remove it } // we don't want the removed mobjs to come back diff --git a/src/p_spec.c b/src/p_spec.c index ee76ae542..fc25a94ad 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1783,8 +1783,10 @@ void P_SwitchWeather(INT32 weathernum) { next = think->next; +#ifdef PARANOIA if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker +#endif precipmobj = (precipmobj_t *)think; P_FreePrecipMobj(precipmobj); @@ -1798,8 +1800,10 @@ void P_SwitchWeather(INT32 weathernum) for (think = precipcap.next; think != &precipcap; think = think->next) { +#ifdef PARANOIA if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker +#endif precipmobj = (precipmobj_t *)think; diff --git a/src/p_tick.c b/src/p_tick.c index e6239e312..aec4aba20 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -57,6 +57,7 @@ void Command_Numthinkers_f(void) INT32 count = 0; actionf_p1 action; thinker_t *think; + thinker_t *listtype; if (gamestate != GS_LEVEL) { @@ -105,25 +106,14 @@ void Command_Numthinkers_f(void) return; } - if (num == 2) // P_NullPrecipThinker - { - for (think = precipcap.next; think != &precipcap; think = think->next) - { - if (think->function.acp1 != action) - continue; + listtype = (num == 2) ? &precipcap : &thinkercap; - count++; - } - } - else + for (think = listtype->next; think != listtype; think = think->next) { - for (think = thinkercap.next; think != &thinkercap; think = think->next) - { - if (think->function.acp1 != action) - continue; + if (think->function.acp1 != action) + continue; - count++; - } + count++; } CONS_Printf("%d\n", count); diff --git a/src/r_main.c b/src/r_main.c index 01c97652b..51c590d46 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -288,8 +288,10 @@ static void Precipstuff_OnChange(void) { next = think->next; +#ifdef PARANOIA if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker +#endif precipmobj = (precipmobj_t *)think; P_FreePrecipMobj(precipmobj); -- 2.54.0 From 9c37a8472ef758dd3028c24db20339b948c241a6 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 05:10:52 +0100 Subject: [PATCH 05/44] move early return even earlier so theres no need to constantly init scale and drawdist --- src/hardware/hw_main.c | 2 +- src/r_things.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index aaf1cb2e6..3d7fbbd50 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4359,7 +4359,7 @@ static void HWR_AddPrecipitationSprites(void) fixed_t drawdist; - // save a little time on invisible weather + // save a little time if theres no or invisible weather if (curWeather == PRECIP_NONE || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) { return; diff --git a/src/r_things.c b/src/r_things.c index 5de515d68..f4638c5b1 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1969,14 +1969,20 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // void R_AddPrecipitationSprites(void) { - fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); - fixed_t drawdist = ((fixed_t)(cv_drawdist_precip.value) * precipscale); - INT32 xl, xh, yl, yh, bx, by; precipmobj_t *th, *next; + // save a little time if theres no or invisible weather + if (curWeather == PRECIP_NONE || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) + { + return; + } + + const fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); + const fixed_t drawdist = ((fixed_t)(cv_drawdist_precip.value) * precipscale); + // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off - if (drawdist == 0 || curWeather == PRECIP_NONE || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) + if (drawdist == 0) { return; } -- 2.54.0 From 3180221a4250721ccd9d84deac91db8bd016e116 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 05:06:52 +0100 Subject: [PATCH 06/44] dont iterate through precip blockmap if there is no precip --- 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 5eefc9c7e..aaf1cb2e6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4360,7 +4360,7 @@ static void HWR_AddPrecipitationSprites(void) fixed_t drawdist; // save a little time on invisible weather - if (curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) + if (curWeather == PRECIP_NONE || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) { return; } diff --git a/src/r_things.c b/src/r_things.c index 511c26bd6..ca534f54b 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1979,7 +1979,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 || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) + if (drawdist == 0 || curWeather == PRECIP_NONE || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) { return; } -- 2.54.0 From 3ade8b09c5e6a9e44a4de6e409139ad859f6f20f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 05:10:52 +0100 Subject: [PATCH 07/44] move early return even earlier so theres no need to constantly init scale and drawdist --- src/hardware/hw_main.c | 2 +- src/r_things.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index aaf1cb2e6..3d7fbbd50 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4359,7 +4359,7 @@ static void HWR_AddPrecipitationSprites(void) fixed_t drawdist; - // save a little time on invisible weather + // save a little time if theres no or invisible weather if (curWeather == PRECIP_NONE || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) { return; diff --git a/src/r_things.c b/src/r_things.c index ca534f54b..9bdb9ea67 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1972,14 +1972,20 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // void R_AddPrecipitationSprites(void) { - fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); - fixed_t drawdist = ((fixed_t)(cv_drawdist_precip.value) * precipscale); - INT32 xl, xh, yl, yh, bx, by; precipmobj_t *th, *next; + // save a little time if theres no or invisible weather + if (curWeather == PRECIP_NONE || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) + { + return; + } + + const fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); + const fixed_t drawdist = ((fixed_t)(cv_drawdist_precip.value) * precipscale); + // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off - if (drawdist == 0 || curWeather == PRECIP_NONE || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) + if (drawdist == 0) { return; } -- 2.54.0 From 5e1d43b5affe45e0b5382ec3362e8a1d8df30da1 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 06:18:05 +0100 Subject: [PATCH 08/44] those will never be changed ever --- src/g_game.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index e7dc9d92d..c4fbec8bc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -701,9 +701,7 @@ const char *G_BuildMapName(INT32 map) */ INT16 G_ClipAimingPitch(INT32 *aiming) { - INT32 limitangle; - - limitangle = ANGLE_90 - 1; + static const INT32 limitangle = ANGLE_90 - 1; if (*aiming > limitangle) *aiming = limitangle; @@ -715,10 +713,8 @@ INT16 G_ClipAimingPitch(INT32 *aiming) INT16 G_SoftwareClipAimingPitch(INT32 *aiming) { - INT32 limitangle; - // note: the current software mode implementation doesn't have true perspective - limitangle = ANGLE_90 - ANG10; // Some viewing fun, but not too far down... + static const INT32 limitangle = ANGLE_90 - ANG10; // Some viewing fun, but not too far down... if (*aiming > limitangle) *aiming = limitangle; -- 2.54.0 From 8f0c5fb5084d3adaefc4e7a8536b96ac567ffb2a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 17:06:03 +0100 Subject: [PATCH 09/44] always close any menus when using "connect" command --- src/d_clisrv.c | 3 ++- src/m_menu.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5d04b98e0..e6cc26690 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3069,9 +3069,10 @@ static void Command_connect(void) return; } + M_ClearMenus(true); + if (Playing() || demo.title) { - M_ClearMenus(true); if (demo.title) G_CheckDemoStatus(); diff --git a/src/m_menu.c b/src/m_menu.c index 8cfe16a97..42cf93f9c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4587,7 +4587,7 @@ void M_ClearMenus(boolean callexitmenufunc) if (currentMenu->quitroutine && callexitmenufunc && !currentMenu->quitroutine()) return; // we can't quit this menu (also used to set parameter from the menu) -// Save the config file. I'm sick of crashing the game later and losing all my changes! + // Save the config file. I'm sick of crashing the game later and losing all my changes! COM_BufAddText(va("saveconfig \"%s\" -silent\n", configfile)); if (currentMenu == &MessageDef) // Oh sod off! @@ -9600,16 +9600,17 @@ static void M_DrawConnectMenu(void) highlightflags, va("%u of %d", serverlistpage+1, numPages)); // Did you change the Server Browser address? Have a little reminder. - #ifdef MASTERSERVER +#ifdef MASTERSERVER if (CV_IsSetToDefault(&cv_masterserver)) mservflags = mservflags|highlightflags|V_30TRANS; else mservflags = mservflags|warningflags; + V_DrawRightAlignedSmallString(BASEVIDWIDTH - currentMenu->x, currentMenu->y+3 + MP_ConnectMenu[mp_connect_refresh].alphaKey, mservflags, va("MS: %s", cv_masterserver.string)); M_DrawServerCountAndHorizontalBar(); - #endif +#endif // When switching pages, slide the old page and the // new page across the screen -- 2.54.0 From 8da59dc288f734d0926c39de853a94f8d0ee02ca Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 17:36:47 +0100 Subject: [PATCH 10/44] slightly cleanup rumble and led ticker --- src/d_main.c | 7 +++++-- src/p_tick.c | 17 +++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index a44c12ad6..f9e1ca27e 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -171,14 +171,17 @@ static inline void D_DeviceLEDTick(void) UINT16 color[MAXSPLITSCREENPLAYERS]; UINT16 curcolor[MAXSPLITSCREENPLAYERS]; - if (I_NumJoys() == 0 || (cv_gamepadled[0].value == 0 && cv_gamepadled[1].value == 0 && cv_gamepadled[2].value == 0 && cv_gamepadled[3].value == 0)) + if (I_NumJoys() == 0) { return; } for (i = 0; i <= splitscreen; i++) { - if (cv_usejoystick[i].value == 0) + if (!cv_usejoystick[i].value) + continue; + + if (!cv_gamepadled[i].value) continue; color[i] = G_GetSkinColor(i); diff --git a/src/p_tick.c b/src/p_tick.c index 3b0cadde8..9d5c8539b 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -354,21 +354,25 @@ static void P_DeviceRumbleTick(void) { UINT8 i; - if (I_NumJoys() == 0 || (cv_rumble[0].value == 0 && cv_rumble[1].value == 0 && cv_rumble[2].value == 0 && cv_rumble[3].value == 0)) + if (I_NumJoys() == 0 || gamestate != GS_LEVEL) { return; } for (i = 0; i <= splitscreen; i++) { - player_t *player = &players[displayplayers[i]]; UINT16 low = 0; UINT16 high = 0; - if (!P_IsLocalPlayer(player)) + if (!cv_usejoystick[i].value) continue; - if (cv_usejoystick[i].value == 0) + if (!cv_rumble[i].value) + continue; + + player_t *player = &players[displayplayers[i]]; + + if (!P_IsLocalPlayer(player)) continue; if (!playeringame[displayplayers[i]] || player->spectator) @@ -402,10 +406,11 @@ static void P_DeviceRumbleTick(void) high = 65536 / 256; } - if (low == 0 && high == 0) + // hack alert! i just dont want this thing constantly resetting the rumble lol + if (low == 0 && high == 0) continue; - G_PlayerDeviceRumble(i, low, high, 57); // hack alert! i just dont want this think constantly resetting the rumble lol + G_PlayerDeviceRumble(i, low, high, 57); } } -- 2.54.0 From bb3a65f8ffc8e85a27f4aa234fcb343a1598e450 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 1 Jan 2025 19:58:49 +0300 Subject: [PATCH 11/44] Repurpose ST_DrawTextInput into M_DrawTextInputScroll, and move its definition into m_textinput.c. M_DrawTextInput is now a macro using M_DrawTextInputScroll --- src/m_menu.c | 36 ++++-------------------- src/m_menu.h | 4 --- src/m_textinput.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++ src/m_textinput.h | 5 ++++ src/st_stuff.c | 71 +---------------------------------------------- 5 files changed, 82 insertions(+), 105 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 42cf93f9c..03eeef210 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4980,33 +4980,6 @@ void M_DrawTextBoxFlags(INT32 x, INT32 y, INT32 width, INT32 boxlines, INT32 fla V_DrawFill(x+5, y+5, width*8+6, boxlines*8+6, 239|flags); } -void M_DrawTextInput(INT32 x, INT32 y, textinput_t *input, INT32 flags) -{ - INT32 skullx = x; - - V_DrawString(x, y, V_ALLOWLOWERCASE|flags, input->buffer); - - // draw text cursor for name - if (input->length) - skullx = x+V_SubStringWidth(input->buffer, input->cursor, V_ALLOWLOWERCASE); - - if (skullAnimCounter < 4) // blink cursor - V_DrawCharacter(skullx, y+3, '_'|flags, false); - - // draw selection - if (input->select != input->cursor) - { - size_t start = min(input->select, input->cursor); - size_t end = max(input->select, input->cursor); - - size_t len = end - start; - - INT32 startx = V_SubStringWidth(input->buffer, start, V_ALLOWLOWERCASE); - - V_DrawFill(x+startx, y, V_SubStringWidth(input->buffer+start, len, V_ALLOWLOWERCASE), 8, 103|V_TRANSLUCENT|flags); - } -} - // horizontally centered text static void M_CentreText(INT32 y, const char *string) { @@ -10195,7 +10168,8 @@ static void M_StartServerMenu(INT32 choice) // CONNECT VIA IP // ============== -static char setupm_ip[28]; +#define SETUPM_IP_MAXSIZE ((28-1)*8) +static char setupm_ip[64]; static textinput_t setupm_input_ip; #endif @@ -10203,8 +10177,8 @@ void M_Multiplayer(INT32 choice) { (void)choice; #ifndef NONET - memset(setupm_ip, 0, 28); - M_TextInputInit(&setupm_input_ip, setupm_ip, 28); + memset(setupm_ip, 0, sizeof(setupm_ip)); + M_TextInputInit(&setupm_input_ip, setupm_ip, sizeof(setupm_ip)); #endif M_SetupNextMenu(&MP_MainDef); } @@ -10243,7 +10217,7 @@ Update the maxplayers label... if (itemOn != 9) V_DrawString(x+8,y+12, V_ALLOWLOWERCASE, setupm_ip); else - M_DrawTextInput(x+8, y+12, &setupm_input_ip, 0); + M_DrawTextInputScroll(x+8, y+12, &setupm_input_ip, 0, SETUPM_IP_MAXSIZE); #endif // character bar, ripped off the color bar :V diff --git a/src/m_menu.h b/src/m_menu.h index 9806773b4..72864c669 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -64,10 +64,6 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines); // Same but with extra flags applied void M_DrawTextBoxFlags(INT32 x, INT32 y, INT32 width, INT32 boxlines, INT32 flags); -// Draw text input -typedef struct textinput_s textinput_t; -void M_DrawTextInput(INT32 x, INT32 y, textinput_t *input, INT32 flags); - // Used in d_netcmd to restart time attack void M_ModeAttackRetry(INT32 choice); diff --git a/src/m_textinput.c b/src/m_textinput.c index 266a8f300..dfe9f5a64 100644 --- a/src/m_textinput.c +++ b/src/m_textinput.c @@ -1,4 +1,7 @@ #include "m_textinput.h" +#include "m_menu.h" // MAXSTRINGLENGTH +#include "v_video.h" +#include "r_main.h" // renderisnewtic #include "i_system.h" #include "keys.h" #include "console.h" @@ -132,6 +135,8 @@ void M_TextInputInit(textinput_t *input, char *buffer, size_t buffer_size) input->buffer = buffer; input->buffer_size = buffer_size; + input->skull = 0; + M_TextInputClear(input); } @@ -314,3 +319,69 @@ boolean M_TextInputHandle(textinput_t *input, INT32 key) return true; } + +void M_DrawTextInputScroll(INT32 x, INT32 y, textinput_t *input, INT32 flags, INT32 MAXINPUTWIDTH) +{ + if (renderisnewtic) + input->skull++; + input->skull %= 8; + + char nametodraw[MAXSTRINGLENGTH*2+1] = {0}; + + size_t drawstart = 0; + size_t drawend = 0; // Only used for selection + + INT32 skullx = x; + + while (V_SubStringWidth(input->buffer+drawstart, input->cursor-drawstart, V_ALLOWLOWERCASE) > MAXINPUTWIDTH) + ++drawstart; + + size_t drawlength = V_SubStringLengthToFit(input->buffer+drawstart, MAXINPUTWIDTH+8, V_ALLOWLOWERCASE)+1; + drawend = drawstart + drawlength; + + memcpy(nametodraw, input->buffer+drawstart, drawlength); + + if (input->length) + skullx += V_SubStringWidth(nametodraw, input->cursor-drawstart, V_ALLOWLOWERCASE); + + V_DrawString(x, y, V_ALLOWLOWERCASE|flags, nametodraw); + + // draw text cursor for name + if (input->skull < 4) // blink cursor + V_DrawCharacter(skullx, y+3, '_'|flags, false); + + // draw selection + if (input->select != input->cursor) + { + size_t start = min(input->select, input->cursor); + size_t end = max(input->select, input->cursor); + + INT32 startx = 0; + INT32 width = 0; + + // I couldn't figure out one formula so here's bunch of separate cases + if (start < drawstart && end > drawend) // Selection covers whole visible portion of demo name + { + startx = -2; + width = V_StringWidth(nametodraw, V_ALLOWLOWERCASE)+4; + } + else if (start < drawstart) // Only left side of selection is off visible part + { + startx = -2; + size_t len = (end - start) - (drawstart - start); + width = V_SubStringWidth(nametodraw, len, V_ALLOWLOWERCASE)+2; + } + else if (end > drawend) // Only right side of selection is off visible part + { + startx = V_SubStringWidth(nametodraw, start-drawstart, V_ALLOWLOWERCASE); + width = V_StringWidth(nametodraw+(start-drawstart), V_ALLOWLOWERCASE)+2; + } + else // All selection is on visible part + { + startx = V_SubStringWidth(nametodraw, start-drawstart, V_ALLOWLOWERCASE); + width = V_SubStringWidth(nametodraw+(start-drawstart), end-start, V_ALLOWLOWERCASE); + } + + V_DrawFill(x+startx, y, width, 8, 103|V_TRANSLUCENT|flags); + } +} diff --git a/src/m_textinput.h b/src/m_textinput.h index aad5e94ab..649288ec4 100644 --- a/src/m_textinput.h +++ b/src/m_textinput.h @@ -10,6 +10,8 @@ typedef struct textinput_s { char *buffer; size_t buffer_size; + + unsigned skull; } textinput_t; void M_TextInputInit(textinput_t *input, char *buffer, size_t buffer_size); @@ -20,4 +22,7 @@ void M_TextInputSetString(textinput_t *input, const char *c); boolean M_TextInputHandle(textinput_t *input, INT32 key); +#define M_DrawTextInput(x, y, input, flags) M_DrawTextInputScroll((x), (y), (input), (flags), ((input)->buffer_size-1)*8) +void M_DrawTextInputScroll(INT32 x, INT32 y, textinput_t *input, INT32 flags, INT32 MAXINPUTWIDTH); + #endif diff --git a/src/st_stuff.c b/src/st_stuff.c index aaa926515..fa64b3709 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -829,82 +829,13 @@ static void ST_overlayDrawer(void) } } -static void ST_DrawTextInput(INT32 x, INT32 y, textinput_t *input, INT32 flags) -{ - static UINT8 skullAnimCounter = 0; - static const INT32 MAXINPUTWIDTH = (MAXSTRINGLENGTH-1)*8; - - if (renderisnewtic) - skullAnimCounter++; - skullAnimCounter %= 8; - - char nametodraw[MAXSTRINGLENGTH*2+1] = {0}; - - size_t drawstart = 0; - size_t drawend = 0; // Only used for selection - - INT32 skullx = x; - - while (V_SubStringWidth(input->buffer+drawstart, input->cursor-drawstart, V_ALLOWLOWERCASE) > MAXINPUTWIDTH) - ++drawstart; - - size_t drawlength = V_SubStringLengthToFit(input->buffer+drawstart, MAXINPUTWIDTH+8, V_ALLOWLOWERCASE)+1; - drawend = drawstart + drawlength; - - memcpy(nametodraw, input->buffer+drawstart, drawlength); - - if (input->length) - skullx += V_SubStringWidth(nametodraw, input->cursor-drawstart, V_ALLOWLOWERCASE); - - V_DrawString(x, y, V_ALLOWLOWERCASE|flags, nametodraw); - - // draw text cursor for name - if (skullAnimCounter < 4) // blink cursor - V_DrawCharacter(skullx, y+3, '_'|flags, false); - - // draw selection - if (input->select != input->cursor) - { - size_t start = min(input->select, input->cursor); - size_t end = max(input->select, input->cursor); - - INT32 startx = 0; - INT32 width = 0; - - // I couldn't figure out one formula so here's bunch of separate cases - if (start < drawstart && end > drawend) // Selection covers whole visible portion of demo name - { - startx = -2; - width = V_StringWidth(nametodraw, V_ALLOWLOWERCASE)+4; - } - else if (start < drawstart) // Only left side of selection is off visible part - { - startx = -2; - size_t len = (end - start) - (drawstart - start); - width = V_SubStringWidth(nametodraw, len, V_ALLOWLOWERCASE)+2; - } - else if (end > drawend) // Only right side of selection is off visible part - { - startx = V_SubStringWidth(nametodraw, start-drawstart, V_ALLOWLOWERCASE); - width = V_StringWidth(nametodraw+(start-drawstart), V_ALLOWLOWERCASE)+2; - } - else // All selection is on visible part - { - startx = V_SubStringWidth(nametodraw, start-drawstart, V_ALLOWLOWERCASE); - width = V_SubStringWidth(nametodraw+(start-drawstart), end-start, V_ALLOWLOWERCASE); - } - - V_DrawFill(x+startx, y, width, 8, 103|V_TRANSLUCENT|flags); - } -} - void ST_DrawDemoTitleEntry(void) { #define x (BASEVIDWIDTH/2 - 139) #define y (BASEVIDHEIGHT/2) M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1); - ST_DrawTextInput(x + 8, y + 12, &demo.titlenameinput, 0); + M_DrawTextInputScroll(x + 8, y + 12, &demo.titlenameinput, 0, (MAXSTRINGLENGTH-1)*8); M_DrawTextBox(x + 30, y - 24, 26, 1); V_DrawString(x + 38, y - 16, V_ALLOWLOWERCASE, "Enter the name of the replay."); -- 2.54.0 From e321d759c0bc8461d5ab7bccf96a718dd5edd2e3 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 1 Jan 2025 20:01:54 +0300 Subject: [PATCH 12/44] Thats not defined or used anywhere, bad automerge maybe? --- src/st_stuff.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index fa64b3709..8b431b2f0 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -788,8 +788,6 @@ static void ST_overlayDrawer(void) snprintf(directortoggle, 32, "%s - Toggle Director", item1 != NULL ? item1 : item2 != NULL ? item2 : "Not Bound"); V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, directortoggle); - - directortextactive = true; } else { -- 2.54.0 From 5d44b445581323f4dfa914dc3be1aa5c8c80a2fe Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 21:34:02 +0100 Subject: [PATCH 13/44] use FRACUNIT in rumbleticker + some changes - brakedrift will now add to any rumble thats currently going on - both hyu and invul now rumble less heavy on offroad --- src/p_tick.c | 59 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 9d5c8539b..4f91ff89b 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -365,21 +365,31 @@ static void P_DeviceRumbleTick(void) UINT16 high = 0; if (!cv_usejoystick[i].value) + { continue; + } if (!cv_rumble[i].value) + { continue; + } player_t *player = &players[displayplayers[i]]; if (!P_IsLocalPlayer(player)) + { continue; + } if (!playeringame[displayplayers[i]] || player->spectator) + { continue; + } if (player->mo == NULL) + { continue; + } if (player->exiting) { @@ -389,26 +399,50 @@ static void P_DeviceRumbleTick(void) if (player->kartstuff[k_spinouttimer]) { - low = high = 65536 / 4; + low = high = FRACUNIT / 4; } else if (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))) { - low = high = 65536 / 8; + low = high = FRACUNIT / 8; } - else if ((player->kartstuff[k_offroad] && !player->kartstuff[k_hyudorotimer]) + else if ((player->kartstuff[k_offroad]) && P_IsObjectOnGround(player->mo) && player->speed != 0) { - low = high = 65536 / 64; + if (player->kartstuff[k_hyudorotimer]) + { + high = FRACUNIT / 128; + } + else if (player->kartstuff[k_invincibilitytimer]) + { + high = FRACUNIT / 64; + } + else + { + low = high = FRACUNIT / 64; + } } - else if (player->kartstuff[k_brakedrift]) + + if (player->kartstuff[k_brakedrift]) { - low = 0; - high = 65536 / 256; + high += FRACUNIT / 256; } // hack alert! i just dont want this thing constantly resetting the rumble lol if (low == 0 && high == 0) + { continue; + } + + // pls dont overflow or smth lel + if (low > FRACUNIT-1) + { + low = FRACUNIT-1; + } + + if (high > FRACUNIT-1) + { + high = FRACUNIT-1; + } G_PlayerDeviceRumble(i, low, high, 57); } @@ -782,8 +816,15 @@ void P_PreTicker(INT32 frames) // Run any "after all the other thinkers" stuff for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) - P_PlayerAfterThink(&players[i]); + { + if (!playeringame[i]) + continue; + + if (!players[i].mo || P_MobjWasRemoved(players[i].mo)) + continue; + + P_PlayerAfterThink(&players[i]); + } LUA_HookThinkFrame(); -- 2.54.0 From 54fda32591a7fd4cfa6bf1859d361f45c8fad30e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 21:52:54 +0100 Subject: [PATCH 14/44] logic error lmao oops --- src/p_tick.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 4f91ff89b..af4facd53 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -424,7 +424,7 @@ static void P_DeviceRumbleTick(void) if (player->kartstuff[k_brakedrift]) { - high += FRACUNIT / 256; + high = CLAMP((high + FRACUNIT / 256), 0, UINT16_MAX); } // hack alert! i just dont want this thing constantly resetting the rumble lol @@ -433,17 +433,6 @@ static void P_DeviceRumbleTick(void) continue; } - // pls dont overflow or smth lel - if (low > FRACUNIT-1) - { - low = FRACUNIT-1; - } - - if (high > FRACUNIT-1) - { - high = FRACUNIT-1; - } - G_PlayerDeviceRumble(i, low, high, 57); } } -- 2.54.0 From 30dc0abc2512020d342c7d7982ef0fec93e314cc Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 17:07:41 +0100 Subject: [PATCH 15/44] move camera noclip stuff into its own function its not used in kart anyways and moving it makes crap more readable --- src/p_user.c | 406 ++++++++++++++++++++++++++------------------------- 1 file changed, 208 insertions(+), 198 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index afce1d7a7..51900717e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3398,6 +3398,212 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) while (!P_MoveChaseCamera(player,thiscam,true) && ++tries < 2*TICRATE); } +#ifndef NOCLIPCAM // Disable all z-clipping for noclip cam +static boolean P_CheckNoclipCameraPosition(player_t *player, camera_t *thiscam, fixed_t x, fixed_t y, fixed_t z, boolean resetcalled) +{ + subsector_t *newsubsec; + boolean cameranoclip; + mobj_t *mo = player->mo; + + cameranoclip = ((player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) + || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)) // Noclipping player camera noclips too!! + || (leveltime < introtime)); // Kart intro cam + + // move camera down to move under lower ceilings + newsubsec = R_IsPointInSubsector(((mo->x>>FRACBITS) + (thiscam->x>>FRACBITS))<<(FRACBITS-1), ((mo->y>>FRACBITS) + (thiscam->y>>FRACBITS))<<(FRACBITS-1)); + + if (!newsubsec) + newsubsec = thiscam->subsector; + + if (newsubsec) + { + fixed_t myfloorz, myceilingz; + fixed_t midz = thiscam->z + (thiscam->z - mo->z)/2; + fixed_t midx = ((mo->x>>FRACBITS) + (thiscam->x>>FRACBITS))<<(FRACBITS-1); + fixed_t midy = ((mo->y>>FRACBITS) + (thiscam->y>>FRACBITS))<<(FRACBITS-1); + + // Cameras use the heightsec's heights rather then the actual sector heights. + // If you can see through it, why not move the camera through it too? + if (newsubsec->sector->camsec >= 0) + { + myfloorz = sectors[newsubsec->sector->camsec].floorheight; + myceilingz = sectors[newsubsec->sector->camsec].ceilingheight; + } + else if (newsubsec->sector->heightsec >= 0) + { + myfloorz = sectors[newsubsec->sector->heightsec].floorheight; + myceilingz = sectors[newsubsec->sector->heightsec].ceilingheight; + } + else + { + myfloorz = P_CameraGetFloorZ(thiscam, newsubsec->sector, midx, midy, NULL); + myceilingz = P_CameraGetCeilingZ(thiscam, newsubsec->sector, midx, midy, NULL); + } + + // Check list of fake floors and see if floorz/ceilingz need to be altered. + if (newsubsec->sector->ffloors) + { + ffloor_t *rover; + fixed_t delta1, delta2; + INT32 thingtop = midz + thiscam->height; + + for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERALL) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) + continue; + + topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); + bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); + + delta1 = midz - (bottomheight + + ((topheight - bottomheight)/2)); + delta2 = thingtop - (bottomheight + + ((topheight - bottomheight)/2)); + if (topheight > myfloorz && abs(delta1) < abs(delta2)) + myfloorz = topheight; + if (bottomheight < myceilingz && abs(delta1) >= abs(delta2)) + myceilingz = bottomheight; + } + } + + // Check polyobjects and see if floorz/ceilingz need to be altered + { + INT32 xl, xh, yl, yh, bx, by; + validcount++; + + xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; + xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; + yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; + yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; + + BMBOUNDFIX(xl, xh, yl, yh); + + for (by = yl; by <= yh; by++) + { + for (bx = xl; bx <= xh; bx++) + { + INT32 offset; + polymaplink_t *plink; // haleyjd 02/22/06 + + if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) + continue; + + offset = by*bmapwidth + bx; + + // haleyjd 02/22/06: consider polyobject lines + plink = polyblocklinks[offset]; + + while (plink) + { + polyobj_t *po = plink->po; + + if (po->validcount != validcount) // if polyobj hasn't been checked + { + sector_t *polysec; + fixed_t delta1, delta2, thingtop; + fixed_t polytop, polybottom; + + po->validcount = validcount; + + if (!P_PointInsidePolyobj(po, x, y) || !(po->flags & POF_SOLID)) + { + plink = (polymaplink_t *)(plink->link.next); + continue; + } + + // We're inside it! Yess... + polysec = po->lines[0]->backsector; + + if (GETSECSPECIAL(polysec->special, 4) == 12) + { // Camera noclip polyobj. + plink = (polymaplink_t *)(plink->link.next); + continue; + } + + if (po->flags & POF_CLIPPLANES) + { + polytop = polysec->ceilingheight; + polybottom = polysec->floorheight; + } + else + { + polytop = INT32_MAX; + polybottom = INT32_MIN; + } + + thingtop = midz + thiscam->height; + delta1 = midz - (polybottom + ((polytop - polybottom)/2)); + delta2 = thingtop - (polybottom + ((polytop - polybottom)/2)); + + if (polytop > myfloorz && abs(delta1) < abs(delta2)) + myfloorz = polytop; + + if (polybottom < myceilingz && abs(delta1) >= abs(delta2)) + myceilingz = polybottom; + } + plink = (polymaplink_t *)(plink->link.next); + } + } + } + } + + // crushed camera + if (myceilingz <= myfloorz + thiscam->height && !resetcalled && !cameranoclip) + { + P_ResetCamera(player, thiscam); + return true; + } + + // camera fit? + if (myceilingz != myfloorz + && myceilingz - thiscam->height < z) + { + z = myceilingz - thiscam->height-FixedMul(11*FRACUNIT, mo->scale); + // is the camera fit is there own sector + } + + // Make the camera a tad smarter with 3d floors + if (newsubsec->sector->ffloors && !cameranoclip) + { + ffloor_t *rover; + + for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + if ((rover->flags & FF_BLOCKOTHERS) && (rover->flags & FF_RENDERALL) && (rover->flags & FF_EXISTS) && GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) + { + topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); + bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); + + if (bottomheight - thiscam->height < z + && midz < bottomheight) + z = bottomheight - thiscam->height-FixedMul(11*FRACUNIT, mo->scale); + + else if (topheight + thiscam->height > z + && midz > topheight) + z = topheight; + + if ((mo->z >= topheight && midz < bottomheight) + || ((mo->z < bottomheight && mo->z+mo->height < topheight) && midz >= topheight)) + { + // Can't see + if (!resetcalled) + P_ResetCamera(player, thiscam); + return true; + } + } + } + } + } + + if (thiscam->z < thiscam->floorz && !cameranoclip) + thiscam->z = thiscam->floorz; + + return false; +} +#endif + boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled) { static boolean lookbackactive[MAXSPLITSCREENPLAYERS]; @@ -3411,10 +3617,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall UINT8 timeover; mobj_t *mo; fixed_t f1, f2; -#ifndef NOCLIPCAM - boolean cameranoclip; - subsector_t *newsubsec; -#endif democam.soundmobj = NULL; // reset this each frame, we don't want the game crashing for stupid reasons now do we @@ -3472,12 +3674,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall mo = player->mo; -#ifndef NOCLIPCAM - cameranoclip = ((player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) - || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)) // Noclipping player camera noclips too!! - || (leveltime < introtime)); // Kart intro cam -#endif - if (player->pflags & PF_TIMEOVER) // 1 for momentum keep, 2 for turnaround timeover = (player->kartstuff[k_timeovercam] > 2*TICRATE ? 2 : 1); else @@ -3663,194 +3859,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall z = mo->z + pviewheight + camheight; #ifndef NOCLIPCAM // Disable all z-clipping for noclip cam - // move camera down to move under lower ceilings - newsubsec = R_IsPointInSubsector(((mo->x>>FRACBITS) + (thiscam->x>>FRACBITS))<<(FRACBITS-1), ((mo->y>>FRACBITS) + (thiscam->y>>FRACBITS))<<(FRACBITS-1)); - - if (!newsubsec) - newsubsec = thiscam->subsector; - - if (newsubsec) - { - fixed_t myfloorz, myceilingz; - fixed_t midz = thiscam->z + (thiscam->z - mo->z)/2; - fixed_t midx = ((mo->x>>FRACBITS) + (thiscam->x>>FRACBITS))<<(FRACBITS-1); - fixed_t midy = ((mo->y>>FRACBITS) + (thiscam->y>>FRACBITS))<<(FRACBITS-1); - - // Cameras use the heightsec's heights rather then the actual sector heights. - // If you can see through it, why not move the camera through it too? - if (newsubsec->sector->camsec >= 0) - { - myfloorz = sectors[newsubsec->sector->camsec].floorheight; - myceilingz = sectors[newsubsec->sector->camsec].ceilingheight; - } - else if (newsubsec->sector->heightsec >= 0) - { - myfloorz = sectors[newsubsec->sector->heightsec].floorheight; - myceilingz = sectors[newsubsec->sector->heightsec].ceilingheight; - } - else - { - myfloorz = P_CameraGetFloorZ(thiscam, newsubsec->sector, midx, midy, NULL); - myceilingz = P_CameraGetCeilingZ(thiscam, newsubsec->sector, midx, midy, NULL); - } - - // Check list of fake floors and see if floorz/ceilingz need to be altered. - if (newsubsec->sector->ffloors) - { - ffloor_t *rover; - fixed_t delta1, delta2; - INT32 thingtop = midz + thiscam->height; - - for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) - { - fixed_t topheight, bottomheight; - if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERALL) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) - continue; - - topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); - bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); - - delta1 = midz - (bottomheight - + ((topheight - bottomheight)/2)); - delta2 = thingtop - (bottomheight - + ((topheight - bottomheight)/2)); - if (topheight > myfloorz && abs(delta1) < abs(delta2)) - myfloorz = topheight; - if (bottomheight < myceilingz && abs(delta1) >= abs(delta2)) - myceilingz = bottomheight; - } - } - - // Check polyobjects and see if floorz/ceilingz need to be altered - { - INT32 xl, xh, yl, yh, bx, by; - validcount++; - - xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; - xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; - yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; - yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; - - BMBOUNDFIX(xl, xh, yl, yh); - - for (by = yl; by <= yh; by++) - for (bx = xl; bx <= xh; bx++) - { - INT32 offset; - polymaplink_t *plink; // haleyjd 02/22/06 - - if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) - continue; - - offset = by*bmapwidth + bx; - - // haleyjd 02/22/06: consider polyobject lines - plink = polyblocklinks[offset]; - - while (plink) - { - polyobj_t *po = plink->po; - - if (po->validcount != validcount) // if polyobj hasn't been checked - { - sector_t *polysec; - fixed_t delta1, delta2, thingtop; - fixed_t polytop, polybottom; - - po->validcount = validcount; - - if (!P_PointInsidePolyobj(po, x, y) || !(po->flags & POF_SOLID)) - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - // We're inside it! Yess... - polysec = po->lines[0]->backsector; - - if (GETSECSPECIAL(polysec->special, 4) == 12) - { // Camera noclip polyobj. - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - if (po->flags & POF_CLIPPLANES) - { - polytop = polysec->ceilingheight; - polybottom = polysec->floorheight; - } - else - { - polytop = INT32_MAX; - polybottom = INT32_MIN; - } - - thingtop = midz + thiscam->height; - delta1 = midz - (polybottom + ((polytop - polybottom)/2)); - delta2 = thingtop - (polybottom + ((polytop - polybottom)/2)); - - if (polytop > myfloorz && abs(delta1) < abs(delta2)) - myfloorz = polytop; - - if (polybottom < myceilingz && abs(delta1) >= abs(delta2)) - myceilingz = polybottom; - } - plink = (polymaplink_t *)(plink->link.next); - } - } - } - - // crushed camera - if (myceilingz <= myfloorz + thiscam->height && !resetcalled && !cameranoclip) - { - P_ResetCamera(player, thiscam); - return true; - } - - // camera fit? - if (myceilingz != myfloorz - && myceilingz - thiscam->height < z) - { - z = myceilingz - thiscam->height-FixedMul(11*FRACUNIT, mo->scale); - // is the camera fit is there own sector - } - - // Make the camera a tad smarter with 3d floors - if (newsubsec->sector->ffloors && !cameranoclip) - { - ffloor_t *rover; - - for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) - { - fixed_t topheight, bottomheight; - if ((rover->flags & FF_BLOCKOTHERS) && (rover->flags & FF_RENDERALL) && (rover->flags & FF_EXISTS) && GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) - { - topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); - bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); - - if (bottomheight - thiscam->height < z - && midz < bottomheight) - z = bottomheight - thiscam->height-FixedMul(11*FRACUNIT, mo->scale); - - else if (topheight + thiscam->height > z - && midz > topheight) - z = topheight; - - if ((mo->z >= topheight && midz < bottomheight) - || ((mo->z < bottomheight && mo->z+mo->height < topheight) && midz >= topheight)) - { - // Can't see - if (!resetcalled) - P_ResetCamera(player, thiscam); - return true; - } - } - } - } - } - - if (thiscam->z < thiscam->floorz && !cameranoclip) - thiscam->z = thiscam->floorz; + if (P_CheckNoclipCameraPosition(player, thiscam, x, y, z, resetcalled)) + return true; #endif // NOCLIPCAM // point viewed by the camera -- 2.54.0 From e105d8f51eae21b711202ecbdb42a8d42b134e68 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 15:54:44 +0100 Subject: [PATCH 16/44] apparently this is slower for everything but rendering --- src/d_clisrv.c | 2 +- src/hardware/hw_main.c | 2 +- src/hardware/hw_portal.c | 2 +- src/p_mobj.c | 4 ++-- src/p_setup.c | 4 ++-- src/p_user.c | 4 ++-- src/r_fps.c | 2 +- src/r_main.h | 11 ----------- src/s_sound.c | 4 ++-- 9 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e6cc26690..af6a82289 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1959,7 +1959,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - camera[i].subsector = R_PointInSubsectorFast(camera[i].x, camera[i].y); + camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); } cl_redownloadinggamestate = false; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3d7fbbd50..0c2de5227 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3172,7 +3172,7 @@ static gl_vissprite_t *HWR_NewVisSprite(void) // Finds a floor through which light does not pass. static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) { - const sector_t *sec = R_PointInSubsectorFast(x, y)->sector; + const sector_t *sec = R_PointInSubsector(x, y)->sector; fixed_t floorz = sec->floorheight; if (sec->ffloors) diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index f26e71331..27d77af2e 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -132,7 +132,7 @@ void HWR_PortalFrame(gl_portal_t* portal) { portalclipline = NULL; portalcullsector = NULL; - viewsector = R_PointInSubsectorFast(viewx, viewy)->sector; + viewsector = R_PointInSubsector(viewx, viewy)->sector; } } diff --git a/src/p_mobj.c b/src/p_mobj.c index 03e7e9f99..4a7a34918 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3337,7 +3337,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled if (!itsatwodlevel) P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam); - thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y); + thiscam->subsector = R_PointInSubsector(thiscam->x, thiscam->y); thiscam->floorz = tmfloorz; thiscam->ceilingz = tmceilingz; @@ -10415,7 +10415,7 @@ void P_PrecipitationEffects(void) for (y = yl; y <= yh; y += RADIUSSTEP) for (x = xl; x <= xh; x += RADIUSSTEP) { - if (R_PointInSubsectorFast((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors! + if (R_PointInSubsector((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors! continue; newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, (fixed_t)x, (fixed_t)y, 0); diff --git a/src/p_setup.c b/src/p_setup.c index 0e7f89dcf..477b805db 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2437,7 +2437,7 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) cam->y = players[pnum].mo->y; cam->z = players[pnum].mo->z; cam->angle = players[pnum].mo->angle; - cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) + cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) } else { @@ -2462,7 +2462,7 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) cam->y = thing->y; cam->z = thing->z; cam->angle = FixedAngle((fixed_t)thing->angle << FRACBITS); - cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) + cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) } } diff --git a/src/p_user.c b/src/p_user.c index 51900717e..0e587e659 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3348,7 +3348,7 @@ void P_DemoCameraMovement(camera_t *cam) democam.soundmobj = awayviewmobj_hack; // update subsector to avoid crashes; - cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); + cam->subsector = R_PointInSubsector(cam->x, cam->y); } void P_ResetCamera(player_t *player, camera_t *thiscam) @@ -3390,7 +3390,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->relativex = 0; - thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y); + thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y); thiscam->radius = 20*FRACUNIT; thiscam->height = 16*FRACUNIT; diff --git a/src/r_fps.c b/src/r_fps.c index b861dea56..92eb37a32 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -198,7 +198,7 @@ void R_InterpolateView(fixed_t frac, boolean forceinvalid) viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); viewplayer = newview->player; - viewsector = R_PointInSubsectorFast(viewx, viewy)->sector; + viewsector = R_PointInSubsector(viewx, viewy)->sector; R_SetupFreelook(); } diff --git a/src/r_main.h b/src/r_main.h index 523e924d5..c66c9bf55 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -140,17 +140,6 @@ FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsector(fixed_t x, fixed_t return &subsectors[nodenum & ~NF_SUBSECTOR]; } -// uses R_PointOnSideFast -// SHOULD NOT BE USED FOR ANYTHING GAMEPLAY RELATED!! -FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsectorFast(fixed_t x, fixed_t y) -{ - size_t nodenum = numnodes-1; - - while (!(nodenum & NF_SUBSECTOR)) - nodenum = nodes[nodenum].children[R_PointOnSideFast(x, y, nodes+nodenum)]; - - return &subsectors[nodenum & ~NF_SUBSECTOR]; -} #define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y) #define R_PointToDist2(px2, py2, px1, py1) FixedHypot((px1) - (px2), (py1) - (py2)) diff --git a/src/s_sound.c b/src/s_sound.c index 06f6be1eb..4181d57d4 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -962,7 +962,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 INT64 x, y, yl, yh, xl, xh; fixed_t newdist; - if (R_PointInSubsectorFast(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum) + if (R_PointInSubsector(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum) approx_dist = 0; else { @@ -975,7 +975,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 for (y = yl; y <= yh; y += FRACUNIT*64) for (x = xl; x <= xh; x += FRACUNIT*64) { - if (R_PointInSubsectorFast(x, y)->sector->ceilingpic == skyflatnum) + if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) { // Found the outdoors! newdist = S_CalculateSoundDistance(listensource.x, listensource.y, 0, x, y, 0); -- 2.54.0 From 8b94aded16a095efd3d58b42ca5bd597b2d88646 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 22:18:52 +0100 Subject: [PATCH 17/44] smol fix --- src/p_mobj.c | 3 +++ src/r_main.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 4a7a34918..30bc10c9a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3568,11 +3568,14 @@ static void CalculatePrecipFloor(precipmobj_t *mobj) { // recalculate floorz each time const sector_t *mobjsecsubsec; + if (mobj && mobj->subsector && mobj->subsector->sector) mobjsecsubsec = mobj->subsector->sector; else return; + mobj->floorz = P_GetSectorFloorZAt(mobjsecsubsec, mobj->x, mobj->y); + if (mobjsecsubsec->ffloors) { ffloor_t *rover; diff --git a/src/r_main.h b/src/r_main.h index c66c9bf55..bb407ab4f 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -104,7 +104,7 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSideFast(fixed_t x, fixed_t y, const node_t *node) { // use cross product to determine side quickly - return ((INT64)y - node->y) * node->dx - ((INT64)x - node->x) * node->dy > 0; + return ((((INT64)y - node->y) * node->dx - ((INT64)x - node->x) * node->dy) >= 0); } FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line) @@ -115,7 +115,7 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t fixed_t ldy = line->v2->y - ly; // use cross product to determine side quickly - return ((INT64)y - ly) * ldx - ((INT64)x - lx) * ldy > 0; + return ((((INT64)y - ly) * ldx - ((INT64)x - lx) * ldy) >= 0); } angle_t R_PointToAngle(fixed_t x, fixed_t y); -- 2.54.0 From c5b70ccc4aae9880768310f40263dac85be52a66 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 15:51:38 +0100 Subject: [PATCH 18/44] do NOT repeatedly call M_Responder!! "thread safety" or smth also put stuff into two seperate functions, since i started hating nesting --- src/d_main.c | 71 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f9e1ca27e..ac4326f65 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -165,6 +165,48 @@ UINT8 ctrldown = 0; // 0x1 left, 0x2 right UINT8 altdown = 0; // 0x1 left, 0x2 right boolean capslock = 0; // gee i wonder what this does. +static void D_PadScrollInput(int input) +{ + event_t myev = {0, 0, 0, 0}; + myev.type = ev_keydown; + myev.data1 = input; + D_PostEvent(&myev); // put into eventlist +} + +#define SCROLLDELAY 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 + +// this is absolutely awful and i hate it lmao +// but le hAx0r to make dpad also be able to scroll in the menu +static void D_GamePadMenuScrollTicker(void) +{ + static SINT8 menuInputDelayTimer = 0; + int key = 0; // butt-on output + + // wish i had a switch ono + if (DPADUPSCROLL) + key = KEY_UPARROW; + else if (DPADDOWNSCROLL) + key = KEY_DOWNARROW; + else if (DPADLEFTSCROLL) + key = KEY_LEFTARROW; + else if (DPADRIGHTSCROLL) + key = KEY_RIGHTARROW; + + if (key) + { + if (menuInputDelayTimer < SCROLLDELAY) + menuInputDelayTimer++; + + if (menuInputDelayTimer == SCROLLDELAY) + D_PadScrollInput(key); + } + else + { + menuInputDelayTimer = 0; + } +} +#undef SCROLLDELAY + static inline void D_DeviceLEDTick(void) { UINT8 i; @@ -651,7 +693,6 @@ static boolean D_Display(void) // ========================================================================= tic_t rendergametic; -static SINT8 menuInputDelayTimer = 0; void D_SRB2Loop(void) { @@ -774,35 +815,11 @@ 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)) + if (menuactive) { - event_t myev; - myev.type = ev_keydown; - - 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 (DPADUPSCROLL) - DPADSCROLLINPUT(KEY_UPARROW) - else if (DPADDOWNSCROLL) - DPADSCROLLINPUT(KEY_DOWNARROW) - else if (DPADLEFTSCROLL) - DPADSCROLLINPUT(KEY_LEFTARROW) - else if (DPADRIGHTSCROLL) - DPADSCROLLINPUT(KEY_RIGHTARROW) - } + D_GamePadMenuScrollTicker(); } - else - menuInputDelayTimer = 0; -#undef DPADSCROLLINPUT D_DeviceLEDTick(); } -- 2.54.0 From b69bb8500318f4c3ed0387c685a9a1b90cb7a334 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 20:09:28 +0100 Subject: [PATCH 19/44] remove redundant stuff can just set this all the time, its only used when menu is active anyways so it doesent matter if we set it --- src/d_main.c | 5 ++--- src/m_menu.c | 26 ++++++++------------------ 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ac4326f65..94fe8792d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -165,7 +165,7 @@ UINT8 ctrldown = 0; // 0x1 left, 0x2 right UINT8 altdown = 0; // 0x1 left, 0x2 right boolean capslock = 0; // gee i wonder what this does. -static void D_PadScrollInput(int input) +static void D_PadMenuScrollInput(int input) { event_t myev = {0, 0, 0, 0}; myev.type = ev_keydown; @@ -198,7 +198,7 @@ static void D_GamePadMenuScrollTicker(void) menuInputDelayTimer++; if (menuInputDelayTimer == SCROLLDELAY) - D_PadScrollInput(key); + D_PadMenuScrollInput(key); } else { @@ -815,7 +815,6 @@ void D_SRB2Loop(void) doDisplay = true; } - // this is absolutely awful and i hate it lmao if (menuactive) { D_GamePadMenuScrollTicker(); diff --git a/src/m_menu.c b/src/m_menu.c index 03eeef210..6272f57fa 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3675,40 +3675,28 @@ boolean M_Responder(event_t *ev) break; case KEY_HAT1: ch = KEY_UPARROW; + DPADUPSCROLL = true; break; case KEY_HAT1 + 1: ch = KEY_DOWNARROW; + DPADDOWNSCROLL = true; break; case KEY_HAT1 + 2: ch = KEY_LEFTARROW; + DPADLEFTSCROLL = true; break; case KEY_HAT1 + 3: ch = KEY_RIGHTARROW; + DPADRIGHTSCROLL = true; break; } if (menuactive) { - switch (ev->data1) // if you pressed it set those to true - { - case KEY_HAT1: - DPADUPSCROLL = true; - break; - case KEY_HAT1 + 1: - DPADDOWNSCROLL = true; - break; - case KEY_HAT1 + 2: - DPADLEFTSCROLL = true; - break; - case KEY_HAT1 + 3: - DPADRIGHTSCROLL = true; - break; - } - if (currentMenu == &MISC_ChangeLevelDef || currentMenu == &MP_OfflineServerDef || currentMenu == &MP_ServerDef) { - if (ev->data1 == gamecontrol[gc_fire][0] - || ev->data1 == gamecontrol[gc_fire][1]) + if (ch == gamecontrol[gc_fire][0] + || ch == gamecontrol[gc_fire][1]) { COM_ImmedExecute("add kartencore 1"); } @@ -4383,10 +4371,12 @@ void M_StartControlPanel(void) menuactive = true; + // reset those just in case the game missed the keyup event DPADUPSCROLL = false; DPADDOWNSCROLL = false; DPADLEFTSCROLL = false; DPADRIGHTSCROLL = false; + // if (demo.playback) { -- 2.54.0 From 98db1a57576d0875babb70ad04215507b28a4bca Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 00:32:23 +0100 Subject: [PATCH 20/44] Further improve sleep accuracy on UNIX systems hanichad https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2583 --- src/sdl/i_system.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 882535203..102f1b162 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2121,16 +2121,24 @@ void I_Sleep(UINT32 ms) void I_SleepDuration(precise_t duration) { -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) UINT64 precision = I_GetPrecisePrecision(); - struct timespec ts = { - .tv_sec = duration / precision, - .tv_nsec = duration * 1000000000 / precision % 1000000000, - }; - int status; - do status = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts); - while (status == EINTR); -#else + precise_t dest = I_GetPreciseTime() + duration; + if (duration > 100000) + { + duration -= 100000; // 0.1 ms slack + struct timespec ts = { + .tv_sec = duration / precision, + .tv_nsec = duration * 1000000000 / precision % 1000000000, + }; + int status; + do status = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts); + while (status == EINTR); + } + + // busy-wait the rest + while (((INT64)dest - (INT64)I_GetPreciseTime()) > 0); +#elif defined (MIN_SLEEP_DURATION_MS) UINT64 precision = I_GetPrecisePrecision(); INT32 sleepvalue = cv_sleep.value; UINT64 delaygranularity; @@ -2159,7 +2167,6 @@ void I_SleepDuration(precise_t duration) } // Otherwise, this is a spinloop. - cur = I_GetPreciseTime(); } #endif -- 2.54.0 From 92649a393dbb240866c176173433c4870ee81fdf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 00:41:41 +0100 Subject: [PATCH 21/44] dont cast "infinity" to int lel --- 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 94fe8792d..9bbaa6017 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -743,7 +743,7 @@ void D_SRB2Loop(void) { // Casting the return value of a function is bad practice (apparently) - double budget = round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision()); + double budget = ((R_GetFramerateCap() == 0) ? 0.0 : round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision())); capbudget = (precise_t) budget; } -- 2.54.0 From 8ff5cc7cbb21af85ee60c6779df4f40b7cafb67e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 15:11:09 +0100 Subject: [PATCH 22/44] --------- --- src/k_kart.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index a6aa76e4d..70410e1c3 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8179,11 +8179,7 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI ; else if (mode && !drawtime) { - // apostrophe location _'__ __ - V_DrawKartString(TX+24, TY+3, splitflags, va("'")); - - // quotation mark location _ __"__ - V_DrawKartString(TX+60, TY+3, splitflags, va("\"")); + V_DrawKartString(TX, TY+3, splitflags, va("--'--\"--")); } else { -- 2.54.0 From 7ca2051f8458d14ecdf44b76b67837c797834eee Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 17:41:02 +0100 Subject: [PATCH 23/44] Adjust slack based on precision https://git.do.srb2.org/STJr/SRB2/-/commit/d20552c49d9fd6a2075ebd7d46b0b133c69f1dbe?merge_request_iid=2583 --- src/sdl/i_system.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 102f1b162..86e818901 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2124,9 +2124,9 @@ void I_SleepDuration(precise_t duration) #if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) UINT64 precision = I_GetPrecisePrecision(); precise_t dest = I_GetPreciseTime() + duration; - if (duration > 100000) + if (duration * 100000 / precision > 1) { - duration -= 100000; // 0.1 ms slack + duration -= (precision / 10000); // 0.1 ms slack struct timespec ts = { .tv_sec = duration / precision, .tv_nsec = duration * 1000000000 / precision % 1000000000, -- 2.54.0 From 718fe7e8ae86bac9d1c89a987cd422daaebb6086 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 20:12:19 +0100 Subject: [PATCH 24/44] slight slep optimization https://git.do.srb2.org/STJr/SRB2/-/commit/1da55066d43ed6a0cb666999c20316bef463024b?merge_request_iid=2583 --- src/sdl/i_system.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 86e818901..2c8b59ce1 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2124,9 +2124,10 @@ void I_SleepDuration(precise_t duration) #if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) UINT64 precision = I_GetPrecisePrecision(); precise_t dest = I_GetPreciseTime() + duration; - if (duration * 100000 / precision > 1) + precise_t slack = (precision / 10000); // 0.1 ms slack + if (duration > slack) { - duration -= (precision / 10000); // 0.1 ms slack + duration -= slack; struct timespec ts = { .tv_sec = duration / precision, .tv_nsec = duration * 1000000000 / precision % 1000000000, -- 2.54.0 From 890779713ac34ebd469fae41924cda18543ece5e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 21:23:45 +0100 Subject: [PATCH 25/44] turn off any active menus when using demo play commands --- src/d_netcmd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a6943fe6a..dfd8eda5e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2435,6 +2435,9 @@ static void Command_Playdemo_f(void) return; } + // turn off any open menus + M_ClearMenus(true); + // disconnect from server here? if (demo.playback) G_StopDemo(); @@ -2480,6 +2483,9 @@ static void Command_Timedemo_f(void) return; } + // turn off any open menus + M_ClearMenus(true); + // disconnect from server here? if (demo.playback) G_StopDemo(); -- 2.54.0 From e796f7e81fa91e9ee95ff4819436d22ae0af2c6e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 21:24:48 +0100 Subject: [PATCH 26/44] thats not timedemo lel --- 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 dfd8eda5e..eaec437fe 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2431,7 +2431,7 @@ static void Command_Playdemo_f(void) if (!demo.playback && gamestate == GS_LEVEL) // special case: allow starting another demo while watching a demo { - CONS_Printf(M_GetText("You can't time a demo while in a game.\n")); + CONS_Printf(M_GetText("You can't play a demo while in a game.\n")); return; } -- 2.54.0 From 7177b396e05ab3a94045b3abca05b55b0c8eeb7d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 23:02:27 +0100 Subject: [PATCH 27/44] any of those may be NULL in MakePatch no idea but this crap keeps crashing in some other place every single time i add a check somewhere else --- src/hardware/hw_cache.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index ad140c025..65e120002 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -410,6 +410,16 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe // patch may be NULL if glMipmap has been initialised already and makebitmap is false void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap) { + if (glMipmap == NULL) + return; + + if (patch == NULL || glPatch == NULL) + { + Z_Free(glMipmap->data); + glMipmap->data = NULL; + return; + } + // don't do it twice (like a cache) if (glMipmap->width == 0) { -- 2.54.0 From afa66d0418681237d2f32f0b9944cd2490ff101c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 6 Jan 2025 19:01:58 +0100 Subject: [PATCH 28/44] double the slack for slep --- src/sdl/i_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 2c8b59ce1..ff1651c3b 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2124,7 +2124,7 @@ void I_SleepDuration(precise_t duration) #if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) UINT64 precision = I_GetPrecisePrecision(); precise_t dest = I_GetPreciseTime() + duration; - precise_t slack = (precision / 10000); // 0.1 ms slack + precise_t slack = (precision / 5000); // 0.2 ms slack if (duration > slack) { duration -= slack; -- 2.54.0 From dbb5c1482b59550a44792b2a74478e26cf26bc57 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 6 Jan 2025 19:49:29 +0100 Subject: [PATCH 29/44] add a little extra safety here ig this crashed on levelload once so idk maybe player was null ig --- src/d_main.c | 4 ++-- src/r_main.c | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 9bbaa6017..95f7c895d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -485,11 +485,11 @@ static boolean D_Display(void) { PS_START_TIMING(ps_rendercalltime); - R_ApplyLevelInterpolators(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT); + R_ApplyLevelInterpolators(rendertimefrac); for (i = 0; i <= splitscreen; i++) { - if (players[displayplayers[i]].mo || players[displayplayers[i]].playerstate == PST_DEAD) + if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD) { viewssnum = i; diff --git a/src/r_main.c b/src/r_main.c index 9541fef41..511bbe293 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1060,11 +1060,13 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) mobj_t *viewmobj; -static void -R_SetupCommonFrame -( player_t * player, - subsector_t * subsector) +static void R_SetupCommonFrame(player_t * player, subsector_t * subsector) { + if (!player) + { + return; + } + newview->player = player; newview->x += quake.x; @@ -1073,7 +1075,7 @@ R_SetupCommonFrame newview->roll = R_ViewRollAngle(player); - if (subsector) + if (subsector != NULL) newview->sector = subsector->sector; else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; @@ -1214,7 +1216,7 @@ void R_SetupFrame(int s, boolean skybox) { player_t *player = &players[displayplayers[s]]; camera_t *thiscam = &camera[s]; - boolean chasecam = (cv_chasecam[s].value != 0); + boolean chasecam = (cv_chasecam[s].value); subsector_t * subsector = NULL; R_SetViewContext(VIEWCONTEXT_PLAYER1 + s); @@ -1263,7 +1265,10 @@ void R_SetupFrame(int s, boolean skybox) newview->y = thiscam->y; newview->z = thiscam->z + (thiscam->height>>1); - R_SetupCommonFrame(player, thiscam->subsector); + if (thiscam != NULL) + subsector = thiscam->subsector; + + R_SetupCommonFrame(player, subsector); } else // use the player's eyes view { -- 2.54.0 From ce31ceda651cdefbee9aaebefcbc7d5bf494eeaf Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 7 Jan 2025 14:52:19 +0300 Subject: [PATCH 30/44] If available, add map title into crash log --- src/sdl/i_system.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index ff1651c3b..d3de6f6b0 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -178,6 +178,7 @@ static char returnWadPath[256]; #include "../d_net.h" #include "../g_game.h" #include "../filesrch.h" +#include "../z_zone.h" // Z_Free #include "endtxt.h" #include "sdlmain.h" @@ -344,7 +345,17 @@ static void write_backtrace(bt_crash_reason_t reason) fprintf(out, "Compiled: %s %s, commit %s, branch %s\n", compdate, comptime, comprevision, compbranch); if (gamestate == GS_LEVEL) - fprintf(out, "Game map: %s\n", G_BuildMapName(gamemap)); + { + char *title = G_BuildMapTitle(gamemap); + + if (title) + { + fprintf(out, "Game map: %s (%s)\n", title, G_BuildMapName(gamemap)); + Z_Free(title); + } + else + fprintf(out, "Game map: %s\n", G_BuildMapName(gamemap)); + } fprintf(out, "Time of crash: %s\n", asctime(timeinfo)); -- 2.54.0 From 864d747e3bbdcb6df62992ec92ed3b2f15e6cded Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jan 2025 19:49:36 +0100 Subject: [PATCH 31/44] check if subsector has sector before assigning --- src/r_main.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 511bbe293..2ccd926af 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1062,11 +1062,6 @@ mobj_t *viewmobj; static void R_SetupCommonFrame(player_t * player, subsector_t * subsector) { - if (!player) - { - return; - } - newview->player = player; newview->x += quake.x; @@ -1075,7 +1070,7 @@ static void R_SetupCommonFrame(player_t * player, subsector_t * subsector) newview->roll = R_ViewRollAngle(player); - if (subsector != NULL) + if (subsector && subsector->sector) newview->sector = subsector->sector; else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; -- 2.54.0 From 5c5a5e200e1e8b3c68ef8a33efdde53585bdc2bd Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jan 2025 20:16:28 +0100 Subject: [PATCH 32/44] fix fbo crap once again --- src/sdl/i_video.c | 5 ----- src/sdl/ogl_sdl.c | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 7af6455fe..609afc30a 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -707,11 +707,6 @@ static void I_CheckDesktopRes(void) int currentDisplayIndex = -1; SDL_DisplayMode curmode; - if (desktopwidth == vid.width && desktopheight == vid.height) - { - return; - } - desktopwidth = 0; desktopheight = 0; diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 9093f9a18..8a3a0eabb 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -289,7 +289,8 @@ void OglSdlFinishUpdate(boolean waitvbl) #if defined (__unix__) #ifdef USE_FBO_OGL - xwaylandcrap = false; + if (loaded_config == true) + xwaylandcrap = false; #endif #endif } -- 2.54.0 From c0d4599a35196a691508f3476ee663c89c431689 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jan 2025 23:48:41 +0100 Subject: [PATCH 33/44] TEST: revert sleep stuff for now dedi may sometimes get stuck here somehow --- src/sdl/i_system.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index d3de6f6b0..7302a12e1 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2134,22 +2134,13 @@ void I_SleepDuration(precise_t duration) { #if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) UINT64 precision = I_GetPrecisePrecision(); - precise_t dest = I_GetPreciseTime() + duration; - precise_t slack = (precision / 5000); // 0.2 ms slack - if (duration > slack) - { - duration -= slack; - struct timespec ts = { - .tv_sec = duration / precision, - .tv_nsec = duration * 1000000000 / precision % 1000000000, - }; - int status; - do status = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts); - while (status == EINTR); - } - - // busy-wait the rest - while (((INT64)dest - (INT64)I_GetPreciseTime()) > 0); + struct timespec ts = { + .tv_sec = duration / precision, + .tv_nsec = duration * 1000000000 / precision % 1000000000, + }; + int status; + do status = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts); + while (status == EINTR); #elif defined (MIN_SLEEP_DURATION_MS) UINT64 precision = I_GetPrecisePrecision(); INT32 sleepvalue = cv_sleep.value; -- 2.54.0 From ee8fd22f3659498747dd03b3c4f40705c8ea1e19 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 00:13:27 +0100 Subject: [PATCH 34/44] oops fix software lel --- src/r_things.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 9bdb9ea67..1cca7bbed 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -623,7 +623,6 @@ void R_DrawMaskedColumn(column_t *column) { dc_source = (UINT8 *)column + 3; dc_sourcelength = column->length; - dc_texheight = column->length; dc_texturemid = basetexturemid - (topdelta<length); dc_sourcelength = column->length; - dc_texheight = column->length; for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s) *d++ = *s; -- 2.54.0 From bb91d8e1e33acea5312536d27e4fffbb0977a099 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 01:33:37 +0100 Subject: [PATCH 35/44] dont rumble in freecam + player fix --- src/p_tick.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index af4facd53..ec77d50cf 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -364,6 +364,8 @@ static void P_DeviceRumbleTick(void) UINT16 low = 0; UINT16 high = 0; + player_t *player = ((i == 0) ? &players[consoleplayer] : &players[displayplayers[i]]); + if (!cv_usejoystick[i].value) { continue; @@ -374,14 +376,12 @@ static void P_DeviceRumbleTick(void) continue; } - player_t *player = &players[displayplayers[i]]; - - if (!P_IsLocalPlayer(player)) + if (player->spectator) { continue; } - if (!playeringame[displayplayers[i]] || player->spectator) + if (camera[i].freecam) { continue; } -- 2.54.0 From f74cd97c4b1567125e29e2465bb7e1790e9aef61 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jan 2025 22:47:35 +0100 Subject: [PATCH 36/44] clean up this mess a little --- src/r_patch.c | 574 ++++++++++++-------------------------------------- src/r_patch.h | 6 +- 2 files changed, 131 insertions(+), 449 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index 50dda0c5f..75bd3361c 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -28,425 +28,6 @@ #include "hardware/hw_glob.h" #endif -static unsigned char imgbuf[1<<26]; - -// -// R_CheckIfPatch -// -// Returns true if the lump is a valid patch. -// -boolean R_CheckIfPatch(lumpnum_t lump) -{ - size_t size; - INT16 width, height; - patch_t *patch; - boolean result; - - size = W_LumpLength(lump); - - // minimum length of a valid Doom patch - if (size < 13) - return false; - - patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); - - width = SHORT(patch->width); - height = SHORT(patch->height); - - result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(size / 4)); - - if (result) - { - // The dimensions seem like they might be valid for a patch, so - // check the column directory for extra security. All columns - // must begin after the column directory, and none of them must - // point past the end of the patch. - INT16 x; - - for (x = 0; x < width; x++) - { - UINT32 ofs = LONG(patch->columnofs[x]); - - // Need one byte for an empty column (but there's patches that don't know that!) - if (ofs < (UINT32)width * 4 + 8 || ofs >= (UINT32)size) - { - result = false; - break; - } - } - } - - return result; -} - -// -// R_TextureToFlat -// -// Convert a texture to a flat. -// -void R_TextureToFlat(size_t tex, UINT8 *flat) -{ - texture_t *texture = textures[tex]; - - fixed_t col, ofs; - column_t *column; - UINT8 *desttop, *dest, *deststop; - UINT8 *source; - - // yea - R_CheckTextureCache(tex); - - desttop = flat; - deststop = desttop + (texture->width * texture->height); - - for (col = 0; col < texture->width; col++, desttop++) - { - // no post_t info - if (!texture->holes) - { - column = (column_t *)(R_GetColumn(tex, col)); - source = (UINT8 *)(column); - dest = desttop; - for (ofs = 0; dest < deststop && ofs < texture->height; ofs++) - { - if (source[ofs] != TRANSPARENTPIXEL) - *dest = source[ofs]; - dest += texture->width; - } - } - else - { - INT32 topdelta, prevdelta = -1; - column = (column_t *)((UINT8 *)R_GetColumn(tex, col) - 3); - while (column->topdelta != 0xff) - { - topdelta = column->topdelta; - if (topdelta <= prevdelta) - topdelta += prevdelta; - prevdelta = topdelta; - - dest = desttop + (topdelta * texture->width); - source = (UINT8 *)column + 3; - for (ofs = 0; dest < deststop && ofs < column->length; ofs++) - { - if (source[ofs] != TRANSPARENTPIXEL) - *dest = source[ofs]; - dest += texture->width; - } - column = (column_t *)((UINT8 *)column + column->length + 4); - } - } - } -} - -// -// R_PatchToFlat -// -// Convert a patch to a flat. -// -void R_PatchToFlat(patch_t *patch, UINT8 *flat) -{ - fixed_t col, ofs; - column_t *column; - UINT8 *desttop, *dest, *deststop; - UINT8 *source; - - desttop = flat; - deststop = desttop + (SHORT(patch->width) * SHORT(patch->height)); - - for (col = 0; col < SHORT(patch->width); col++, desttop++) - { - INT32 topdelta, prevdelta = -1; - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[col])); - - while (column->topdelta != 0xff) - { - topdelta = column->topdelta; - if (topdelta <= prevdelta) - topdelta += prevdelta; - prevdelta = topdelta; - - dest = desttop + (topdelta * SHORT(patch->width)); - source = (UINT8 *)(column) + 3; - for (ofs = 0; dest < deststop && ofs < column->length; ofs++) - { - *dest = source[ofs]; - dest += SHORT(patch->width); - } - column = (column_t *)((UINT8 *)column + column->length + 4); - } - } -} - -// -// R_PatchToMaskedFlat -// -// Convert a patch to a masked flat. -// Now, what is a "masked" flat anyway? -// It means the flat uses two bytes to store image data. -// The upper byte is used to store the transparent pixel, -// and the lower byte stores a palette index. -// -void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip) -{ - fixed_t col, ofs; - column_t *column; - UINT16 *desttop, *dest, *deststop; - UINT8 *source; - - desttop = raw; - deststop = desttop + (SHORT(patch->width) * SHORT(patch->height)); - - for (col = 0; col < SHORT(patch->width); col++, desttop++) - { - INT32 topdelta, prevdelta = -1; - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[flip ? (patch->width-1-col) : col])); - while (column->topdelta != 0xff) - { - topdelta = column->topdelta; - if (topdelta <= prevdelta) - topdelta += prevdelta; - prevdelta = topdelta; - dest = desttop + (topdelta * SHORT(patch->width)); - source = (UINT8 *)(column) + 3; - for (ofs = 0; dest < deststop && ofs < column->length; ofs++) - { - *dest = source[ofs]; - dest += SHORT(patch->width); - } - column = (column_t *)((UINT8 *)column + column->length + 4); - } - } -} - -// -// R_FlatToPatch -// -// Convert a flat to a patch. -// -patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency) -{ - UINT32 x, y; - UINT8 *img; - UINT8 *imgptr = imgbuf; - UINT8 *colpointers, *startofspan; - size_t size = 0; - - if (!raw) - return NULL; - - // Write image size and offset - WRITEINT16(imgptr, width); - WRITEINT16(imgptr, height); - WRITEINT16(imgptr, leftoffset); - WRITEINT16(imgptr, topoffset); - - // Leave placeholder to column pointers - colpointers = imgptr; - imgptr += width*4; - - // Write columns - for (x = 0; x < width; x++) - { - int lastStartY = 0; - int spanSize = 0; - startofspan = NULL; - - // Write column pointer - WRITEINT32(colpointers, imgptr - imgbuf); - - // Write pixels - for (y = 0; y < height; y++) - { - UINT8 paletteIndex = raw[((y * width) + x)]; - boolean opaque = transparency ? (paletteIndex != TRANSPARENTPIXEL) : true; - - // End span if we have a transparent pixel - if (!opaque) - { - if (startofspan) - WRITEUINT8(imgptr, 0); - startofspan = NULL; - continue; - } - - // Start new column if we need to - if (!startofspan || spanSize == 255) - { - int writeY = y; - - // If we reached the span size limit, finish the previous span - if (startofspan) - WRITEUINT8(imgptr, 0); - - if (y > 254) - { - // Make sure we're aligned to 254 - if (lastStartY < 254) - { - WRITEUINT8(imgptr, 254); - WRITEUINT8(imgptr, 0); - imgptr += 2; - lastStartY = 254; - } - - // Write stopgap empty spans if needed - writeY = y - lastStartY; - - while (writeY > 254) - { - WRITEUINT8(imgptr, 254); - WRITEUINT8(imgptr, 0); - imgptr += 2; - writeY -= 254; - } - } - - startofspan = imgptr; - WRITEUINT8(imgptr, writeY); - imgptr += 2; - spanSize = 0; - - lastStartY = y; - } - - // Write the pixel - WRITEUINT8(imgptr, paletteIndex); - spanSize++; - startofspan[1] = spanSize; - } - - if (startofspan) - WRITEUINT8(imgptr, 0); - - WRITEUINT8(imgptr, 0xFF); - } - - size = imgptr-imgbuf; - img = Z_Malloc(size, PU_STATIC, NULL); - memcpy(img, imgbuf, size); - - Z_Free(raw); - - if (destsize != NULL) - *destsize = size; - return (patch_t *)img; -} - -// -// R_MaskedFlatToPatch -// -// Convert a masked flat to a patch. -// Explanation of "masked" flats in R_PatchToMaskedFlat. -// -patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) -{ - UINT32 x, y; - UINT8 *img; - UINT8 *imgptr = imgbuf; - UINT8 *colpointers, *startofspan; - size_t size = 0; - - if (!raw) - return NULL; - - // Write image size and offset - WRITEINT16(imgptr, width); - WRITEINT16(imgptr, height); - WRITEINT16(imgptr, leftoffset); - WRITEINT16(imgptr, topoffset); - - // Leave placeholder to column pointers - colpointers = imgptr; - imgptr += width*4; - - // Write columns - for (x = 0; x < width; x++) - { - int lastStartY = 0; - int spanSize = 0; - startofspan = NULL; - - // Write column pointer - WRITEINT32(colpointers, imgptr - imgbuf); - - // Write pixels - for (y = 0; y < height; y++) - { - UINT16 pixel = raw[((y * width) + x)]; - UINT8 paletteIndex = (pixel & 0xFF); - UINT8 opaque = (pixel != 0xFF00); // If 1, we have a pixel - - // End span if we have a transparent pixel - if (!opaque) - { - if (startofspan) - WRITEUINT8(imgptr, 0); - startofspan = NULL; - continue; - } - - // Start new column if we need to - if (!startofspan || spanSize == 255) - { - int writeY = y; - - // If we reached the span size limit, finish the previous span - if (startofspan) - WRITEUINT8(imgptr, 0); - - if (y > 254) - { - // Make sure we're aligned to 254 - if (lastStartY < 254) - { - WRITEUINT8(imgptr, 254); - WRITEUINT8(imgptr, 0); - imgptr += 2; - lastStartY = 254; - } - - // Write stopgap empty spans if needed - writeY = y - lastStartY; - - while (writeY > 254) - { - WRITEUINT8(imgptr, 254); - WRITEUINT8(imgptr, 0); - imgptr += 2; - writeY -= 254; - } - } - - startofspan = imgptr; - WRITEUINT8(imgptr, writeY); - imgptr += 2; - spanSize = 0; - - lastStartY = y; - } - - // Write the pixel - WRITEUINT8(imgptr, paletteIndex); - spanSize++; - startofspan[1] = spanSize; - } - - if (startofspan) - WRITEUINT8(imgptr, 0); - - WRITEUINT8(imgptr, 0xFF); - } - - size = imgptr-imgbuf; - img = Z_Malloc(size, PU_STATIC, NULL); - memcpy(img, imgbuf, size); - - if (destsize != NULL) - *destsize = size; - return (patch_t *)img; -} - // // R_ParseSpriteInfoFrame // @@ -745,6 +326,124 @@ void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps) } } + +static unsigned char imgbuf[1<<26]; + +// +// R_MaskedFlatToPatch +// +// Convert a masked flat to a patch. +// Explanation of "masked" flats in R_PatchToMaskedFlat. +// +void *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) +{ + UINT32 x, y; + UINT8 *img; + UINT8 *imgptr = imgbuf; + UINT8 *colpointers, *startofspan; + size_t size = 0; + + if (!raw) + return NULL; + + // Write image size and offset + WRITEINT16(imgptr, width); + WRITEINT16(imgptr, height); + WRITEINT16(imgptr, leftoffset); + WRITEINT16(imgptr, topoffset); + + // Leave placeholder to column pointers + colpointers = imgptr; + imgptr += width*4; + + // Write columns + for (x = 0; x < width; x++) + { + int lastStartY = 0; + int spanSize = 0; + startofspan = NULL; + + // Write column pointer + WRITEINT32(colpointers, imgptr - imgbuf); + + // Write pixels + for (y = 0; y < height; y++) + { + UINT16 pixel = raw[((y * width) + x)]; + UINT8 paletteIndex = (pixel & 0xFF); + UINT8 opaque = (pixel != 0xFF00); // If 1, we have a pixel + + // End span if we have a transparent pixel + if (!opaque) + { + if (startofspan) + WRITEUINT8(imgptr, 0); + startofspan = NULL; + continue; + } + + // Start new column if we need to + if (!startofspan || spanSize == 255) + { + int writeY = y; + + // If we reached the span size limit, finish the previous span + if (startofspan) + WRITEUINT8(imgptr, 0); + + if (y > 254) + { + // Make sure we're aligned to 254 + if (lastStartY < 254) + { + WRITEUINT8(imgptr, 254); + WRITEUINT8(imgptr, 0); + imgptr += 2; + lastStartY = 254; + } + + // Write stopgap empty spans if needed + writeY = y - lastStartY; + + while (writeY > 254) + { + WRITEUINT8(imgptr, 254); + WRITEUINT8(imgptr, 0); + imgptr += 2; + writeY -= 254; + } + } + + startofspan = imgptr; + WRITEUINT8(imgptr, writeY); + imgptr += 2; + spanSize = 0; + + lastStartY = y; + } + + // Write the pixel + WRITEUINT8(imgptr, paletteIndex); + spanSize++; + startofspan[1] = spanSize; + } + + if (startofspan) + WRITEUINT8(imgptr, 0); + + WRITEUINT8(imgptr, 0xFF); + } + + size = imgptr-imgbuf; + img = Z_Malloc(size, PU_STATIC, NULL); + memcpy(img, imgbuf, size); + + if (destsize != NULL) + *destsize = size; + + return img; +} + static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) { fixed_t ofs; @@ -904,10 +603,6 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle UINT32 i; patch_t *rotated; -#ifdef HWRENDER - patch_t *hwpatch; -#endif - UINT16 *rawdst, *rawconv; size_t size; INT32 bflip = (flip != 0x00); @@ -1020,29 +715,20 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle } // make patch - rotated = R_MaskedFlatToPatch(rawconv, width, height, 0, 0, &size); - { - rotated->leftoffset = ox; - rotated->topoffset = oy; - } -#ifdef HWRENDER - if (rendermode == render_opengl) - { - hwpatch = R_CreateHardwarePatch(rotated); - } -#endif // HWRENDER - - //Z_ChangeTag(rotated, PU_PATCH_ROTATED); // important for memory clearing -#ifdef HWRENDER - if (rendermode == render_opengl) - Z_SetUser(hwpatch, (void **)(&rotsprite->patches[idx])); - else -#endif - Z_SetUser(rotated, (void **)(&rotsprite->patches[idx])); - - Z_Free(rawconv); + rotated = (patch_t *)R_MaskedFlatToPatch(rawconv, width, height, 0, 0, &size); rotated->leftoffset = ox; rotated->topoffset = oy; + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + rotated = R_CreateHardwarePatch(rotated); + } +#endif // HWRENDER + + //Z_ChangeTag(rotated, PU_LEVEL); + Z_SetUser(rotated, (void **)(&rotsprite->patches[idx])); + Z_Free(rawconv); } #endif diff --git a/src/r_patch.h b/src/r_patch.h index 5edaa46fb..447f1b4fc 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -40,11 +40,7 @@ typedef struct // Conversions between patches / flats / textures... boolean R_CheckIfPatch(lumpnum_t lump); -void R_TextureToFlat(size_t tex, UINT8 *flat); -void R_PatchToFlat(patch_t *patch, UINT8 *flat); -void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip); -patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency); -patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); +void *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); // SpriteInfo extern spriteinfo_t spriteinfo[NUMSPRITES]; -- 2.54.0 From ddc8e4a29e739bba81b651759ef2f50d973254da Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 01:46:56 +0100 Subject: [PATCH 37/44] clean up gamepad led stuff --- src/d_main.c | 2 +- src/g_input.c | 50 ++++++++++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 95f7c895d..09218fe72 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -207,7 +207,7 @@ static void D_GamePadMenuScrollTicker(void) } #undef SCROLLDELAY -static inline void D_DeviceLEDTick(void) +static void D_DeviceLEDTick(void) { UINT8 i; UINT16 color[MAXSPLITSCREENPLAYERS]; diff --git a/src/g_input.c b/src/g_input.c index 7f2fff283..1f3c69464 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -908,18 +908,23 @@ static const char *gamecontrolname[num_gamecontrols] = #include "k_kart.h" -inline UINT16 G_GetSkinColor(INT32 player) +UINT16 G_GetSkinColor(INT32 playernum) { - // make rgb rainbow vomit when invul or flash blue when grow - if (cv_ledpowerup[player].value && gamestate == GS_LEVEL && players[displayplayers[player]].mo && (players[displayplayers[player]].kartstuff[k_invincibilitytimer] || players[displayplayers[player]].powers[pw_invulnerability] || players[displayplayers[player]].kartstuff[k_growshrinktimer])) - return players[displayplayers[player]].mo->color; + if (gamestate == GS_LEVEL) + { + player_t *player = &players[displayplayers[playernum]]; - // take actual player skincolour when ingame - if (gamestate == GS_LEVEL && players[displayplayers[player]].skincolor) - return players[displayplayers[player]].skincolor; + // make rgb rainbow vomit when invul or flash blue when grow + if (cv_ledpowerup[playernum].value && player->mo && (player->kartstuff[k_invincibilitytimer] || player->kartstuff[k_growshrinktimer] || player->powers[pw_invulnerability])) + return player->mo->color; + + // take actual player skincolour when ingame + if (player->skincolor) + return player->skincolor; + } // otherwise just fallback to whatever the cvar is - switch (player) + switch (playernum) { case 0: return cv_playercolor.value; @@ -939,49 +944,50 @@ inline UINT16 G_GetSkinColor(INT32 player) } } -void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color) +void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color) { INT32 device; UINT16 skincolor; byteColor_t byte_color; - I_Assert(player >= 0 && player < MAXSPLITSCREENPLAYERS); + I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); - if (cv_gamepadled[player].value == 0) + if (cv_gamepadled[playernum].value == 0) return; - device = cv_usejoystick[player].value; + device = cv_usejoystick[playernum].value; if (device <= 0) { return; } - skincolor = color ? color : G_GetSkinColor(player); + skincolor = color ? color : G_GetSkinColor(playernum); byte_color = V_GetColor(colortranslations[skincolor][8]).s; I_SetGamepadIndicatorColor(device, byte_color.red, byte_color.green, byte_color.blue); } -static void G_ResetPlayerGamepadIndicatorColor(INT32 player) +static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) { - if (cv_gamepadled[player].value == 0) + if (cv_gamepadled[playernum].value == 0) { - INT32 device = cv_usejoystick[player].value; + INT32 device = cv_usejoystick[playernum].value; + if (device <= 0) return; I_SetGamepadIndicatorColor(device, 0, 0, 255); } else - G_SetPlayerGamepadIndicatorColor(player, 0); + G_SetPlayerGamepadIndicatorColor(playernum, 0); } -static void G_ResetPlayerDeviceRumble(INT32 player) +static void G_ResetPlayerDeviceRumble(INT32 playernum) { INT32 device_id; - device_id = cv_usejoystick[player].value; + device_id = cv_usejoystick[playernum].value; if (device_id < 1) { @@ -1006,16 +1012,16 @@ void G_ResetAllDeviceRumbles(void) } } -void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength, UINT32 duration) +void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { INT32 device_id; - if (cv_rumble[player].value == 0) + if (cv_rumble[playernum].value == 0) { return; } - device_id = cv_usejoystick[player].value; + device_id = cv_usejoystick[playernum].value; if (device_id < 1) { -- 2.54.0 From cdfef0f884019bd8f5871adfb61a2743ef2273fb Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 01:48:55 +0100 Subject: [PATCH 38/44] oops forgor those --- src/g_input.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/g_input.h b/src/g_input.h index 18fff51a4..f6e69337d 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -134,11 +134,10 @@ extern INT32 gamecontrol4[num_gamecontrols][2]; // peace to my little coder fingers! // check a gamecontrol being active or not -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); +UINT16 G_GetSkinColor(INT32 playernum); +void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color); void G_ResetAllDeviceRumbles(void); +void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration); // remaps the input event to a game control. void G_MapEventsToControls(event_t *ev); -- 2.54.0 From d01ed388958ee6322f69315cd60615201908c36a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 03:17:14 +0100 Subject: [PATCH 39/44] fix "connect" command not saving to last server --- src/d_clisrv.c | 2 ++ src/i_tcp.c | 4 ---- src/m_menu.c | 4 ---- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index af6a82289..775668d5b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3132,6 +3132,8 @@ static void Command_connect(void) CONS_Alert(CONS_ERROR, M_GetText("There is no network driver\n")); } + CV_Set(&cv_lastserver, I_GetNodeAddress(servernode)); + if (splitscreen != cv_splitplayers.value-1) { splitscreen = cv_splitplayers.value-1; diff --git a/src/i_tcp.c b/src/i_tcp.c index 14dd8b5ed..54c446258 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1669,7 +1669,6 @@ boolean I_InitTcpNetwork(void) // server address only in ip if (serverhostname[0]) { - CV_Set(&cv_lastserver, serverhostname); COM_BufAddText("connect \""); COM_BufAddText(serverhostname); COM_BufAddText("\"\n"); @@ -1679,9 +1678,6 @@ boolean I_InitTcpNetwork(void) } else { - // Not quite sure if we want to save that but i'll do that for now - CV_Set(&cv_lastserver, "any"); - // so we're on a LAN COM_BufAddText("connect any\n"); diff --git a/src/m_menu.c b/src/m_menu.c index 6272f57fa..a2732c3a7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9433,9 +9433,6 @@ static void M_Connect(INT32 choice) { // do not call menuexitfunc M_ClearMenus(false); - - CV_Set(&cv_lastserver, I_GetNodeAddress(serverlist[choice-FIRSTSERVERLINE + serverlistpage * SERVERS_PER_PAGE].node)); - COM_BufAddText(va("connect node %d\n", serverlist[choice-FIRSTSERVERLINE + serverlistpage * SERVERS_PER_PAGE].node)); } @@ -10364,7 +10361,6 @@ static void M_ConnectIP(INT32 choice) M_ClearMenus(true); - CV_Set(&cv_lastserver,setupm_ip); COM_BufAddText(va("connect \"%s\"\n", setupm_ip)); // A little "please wait" message. -- 2.54.0 From 165803c95c069be734b78be6f04220d64f1aa6ca Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 04:00:57 +0100 Subject: [PATCH 40/44] toggle for smol positionnum and posnum animation --- src/g_game.h | 2 ++ src/k_kart.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 3a957d00a..d092f229f 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -167,6 +167,8 @@ DECL_HUD_OFFSET(stat); // Stats #undef DECL_HUD_OFFSET_Y extern consvar_t cv_showinput; +extern consvar_t cv_posanim; +extern consvar_t cv_smallposnum; extern consvar_t cv_newspeedometer; extern consvar_t cv_saltyhop; diff --git a/src/k_kart.c b/src/k_kart.c index 70410e1c3..b8174dc57 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -79,6 +79,10 @@ consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_posanim = {"postitionanimation", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_smallposnum = {"smallpositionnumber", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + + CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; consvar_t cv_newspeedometer = {"newspeedometer", "Default", CV_SAVE, speedo_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -723,6 +727,10 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_showstats); CV_RegisterVar(&cv_showinput); + + CV_RegisterVar(&cv_posanim); + CV_RegisterVar(&cv_smallposnum); + CV_RegisterVar(&cv_showlaptimes); CV_RegisterVar(&cv_newspeedometer); @@ -8309,13 +8317,13 @@ static void K_DrawKartPositionNum(INT32 num) boolean flipvdraw = false; // used only for 2p splitscreen so overtaking doesn't make 1P's position fly off the screen. boolean overtake = false; - if (stplyr->kartstuff[k_positiondelay] || stplyr->exiting) + if ((cv_posanim.value && stplyr->kartstuff[k_positiondelay]) || stplyr->exiting) { scale *= 2; overtake = true; // this is used for splitscreen stuff in conjunction with flipdraw. } - if (splitscreen || (cv_showinput.value && !splitscreen)) + if (splitscreen || cv_smallposnum.value || cv_showinput.value) scale /= 2; W = FixedMul(W<>FRACBITS; -- 2.54.0 From 51e367a61d40caae37e472c9f1ff0d9d14d6e30c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 04:01:48 +0100 Subject: [PATCH 41/44] move saturn hud cvars to k_kart and fix driftgauge extra showing if there is no patch for it its kinda dumb, since technically would allow to not load all of em but im lazy and dont wanna change possiblevalues around --- src/d_main.c | 18 +++++++---- src/d_netcmd.c | 65 -------------------------------------- src/k_kart.c | 86 ++++++++++++++++++++++++++++++++++++++++++-------- src/k_kart.h | 1 + 4 files changed, 86 insertions(+), 84 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 09218fe72..209e7fb76 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1571,8 +1571,10 @@ void D_SRB2Main(void) // Possible value that changes depending on whether required files for speedometer are found or not CV_PossibleValue_t speedo_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; + CV_PossibleValue_t driftgaugestyle_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}, {0, NULL}}; // ugh i dont want this but bleh unsigned last_speedo_i = 0; -#define PUSHSPEEDO(id, name) { ++last_speedo_i; speedo_cons_temp[last_speedo_i].value = id; speedo_cons_temp[last_speedo_i].strvalue = name; } + unsigned last_driftgauge_i = 0; +#define PUSHCONS(cons, i, id, name) { ++i; cons[i].value = id; cons[i].strvalue = name; } if (found_extra_kart || found_extra2_kart || found_extra3_kart) // found the funny, add it in! { @@ -1588,7 +1590,7 @@ void D_SRB2Main(void) if (W_CheckMultipleLumps("SP_SMSTC", "K_TRNULL", "SP_MKMH", "SP_MMPH", "SP_MFRAC", "SP_MPERC", NULL)) { xtra_speedo = true; - PUSHSPEEDO(2, "Small"); + PUSHCONS(speedo_cons_temp, last_speedo_i, 2, "Small"); } if (W_LumpExists("SC_SMSTC")) @@ -1598,7 +1600,7 @@ void D_SRB2Main(void) if (W_CheckMultipleLumps("SP_AMSTC", "K_TRNULL", "SP_AKMH", "SP_AMPH", "SP_AFRAC", "SP_APERC", NULL)) { achi_speedo = true; - PUSHSPEEDO(3, "Achii"); + PUSHCONS(speedo_cons_temp, last_speedo_i, 3, "Achii"); } if (W_CheckMultipleLumps("SC_AMSTC", "K_TRNULL", "SC_AKMH", "SC_AMPH", "SC_AFRAC", "SC_APERC", NULL)) @@ -1624,7 +1626,7 @@ void D_SRB2Main(void) "K_KZSP20", "K_KZSP21", "K_KZSP22", "K_KZSP23", "K_KZSP24", "K_KZSP25", NULL)) { kartzspeedo = true; - PUSHSPEEDO(4, "P-Meter"); + PUSHCONS(speedo_cons_temp, last_speedo_i, 4, "P-Meter"); } // stat display for extended player setup @@ -1637,7 +1639,9 @@ void D_SRB2Main(void) nametaggfx = true; if (W_CheckMultipleLumps("K_DGAU","K_DCAU","K_DGSU","K_DCSU", NULL)) + { driftgaugegfx = true; + } if (found_extra3_kart) { @@ -1645,7 +1649,8 @@ void D_SRB2Main(void) if (W_LumpExists("SP_SM3TC")) { xtra_speedo3 = true; - PUSHSPEEDO(5, "Extra"); + PUSHCONS(speedo_cons_temp, last_speedo_i, 5, "Extra"); + PUSHCONS(driftgaugestyle_cons_temp, last_driftgauge_i, 5, "Extra"); } if (W_LumpExists("SC_SM3TC")) @@ -1653,8 +1658,9 @@ void D_SRB2Main(void) } } -#undef PUSHSPEEDO +#undef PUSHCONS memcpy(speedo_cons_t, speedo_cons_temp, sizeof(speedo_cons_t)); + memcpy(driftgaugestyle_cons_t, driftgaugestyle_cons_temp, sizeof(driftgaugestyle_cons_t)); // Do it before P_InitMapData because PNG patch // conversion sometimes needs the palette diff --git a/src/d_netcmd.c b/src/d_netcmd.c index eaec437fe..b01f87e5a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -490,12 +490,6 @@ consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, 0, 0 consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_minihead = {"smallminimapplayers", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_showminimapnames = {"showminimapnames", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_showlapemblem = {"showlapemblem", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; @@ -516,45 +510,6 @@ consvar_t cv_mute = {"mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_OnChange, consvar_t cv_sleep = {"cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL, -1, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t nametagtrans_cons_t[] = { - {0, "Never"}, {1, "Far only"}, {2, "Dynamic"}, {3, "Always"}, {4, "HUD Trans."}, {0, NULL}}; -/*static CV_PossibleValue_t nametagscaling_cons_t[] = { - {0, "MIN"}, {320, "MAX"}, {0, NULL}};*/ -static CV_PossibleValue_t nametagdistance_cons_t[] = { - {0, "MIN"}, {640, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t nametagmaxplayer_cons_t[] = { - {1, "MIN"}, {MAXPLAYERS, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t nametagsize_cons_t[] = { - {0, "Off"}, {1, "Small"}, {2, "Minimal"}, {0, NULL}}; -static CV_PossibleValue_t nametagrestat_cons_t[] = { - {0, "Off"}, {1, "Restat"}, {2, "Always"}, {0, NULL}}; - -consvar_t cv_nametag = {"kartnametag", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagtrans = {"kartnametagtransparency", "Dynamic", CV_SAVE, nametagtrans_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagfacerank = {"kartnametagfacerank", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagrestat = {"kartnametagrestat", "Restat", CV_SAVE, nametagrestat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagdist = {"kartnametagdist", "320", CV_SAVE, nametagdistance_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagmaxplayers = {"kartnametagmaxplayers", "3", CV_SAVE, nametagmaxplayer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagmaxlenght = {"kartnametagmaxlenght", "12", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -//consvar_t cv_nametagscaling = {"nametagscaling", "160", CV_SAVE, nametagscaling_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showownnametag = {"kartnametagshowown", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_smallnametags = {"kartnametagsmall", "Off", CV_SAVE, nametagsize_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametaghop = {"kartnametaghop", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagscore = {"kartnametagscore", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_shownametagfinish = {"kartshownametagfinished", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; - - -static CV_PossibleValue_t driftgaugeoffset_cons_t[] = { - {-FRACUNIT*128, "MIN"}, {FRACUNIT*128, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t driftgaugestyle_cons_t[] = { - {1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {5, "Extra"}, {0, NULL}}; - -consvar_t cv_driftgauge = {"kartdriftgauge", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_driftgaugeofs = {"kartdriftgaugeoffset", "-20", CV_FLOAT|CV_SAVE, driftgaugeoffset_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_driftgaugetrans = {"kartdriftgaugetransparency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_driftgaugestyle = {"kartdriftgaugestyle", "1", CV_SAVE, driftgaugestyle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - static CV_PossibleValue_t skinselectspin_cons_t[] = { {0, "Off"}, {1, "Slow"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"}, {8, "8"}, {9, "9"}, {10, "Fast"}, {SKINSELECTSPIN_PAIN, "Pain"}, {0, NULL}}; consvar_t cv_skinselectspin = {"skinselectspin", "5", CV_SAVE, skinselectspin_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1122,26 +1077,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_soundtest); - CV_RegisterVar(&cv_nametag); - CV_RegisterVar(&cv_nametagtrans); - CV_RegisterVar(&cv_nametagfacerank); - CV_RegisterVar(&cv_nametagmaxplayers); - CV_RegisterVar(&cv_nametagmaxlenght); - //CV_RegisterVar(&cv_nametagscaling); - CV_RegisterVar(&cv_nametagdist); - CV_RegisterVar(&cv_showownnametag); - CV_RegisterVar(&cv_smallnametags); - CV_RegisterVar(&cv_nametagrestat); - CV_RegisterVar(&cv_nametaghop); - CV_RegisterVar(&cv_nametagscore); - CV_RegisterVar(&cv_shownametagfinish); - CV_RegisterVar(&cv_shownametagspectator); - - CV_RegisterVar(&cv_driftgauge); - CV_RegisterVar(&cv_driftgaugeofs); - CV_RegisterVar(&cv_driftgaugetrans); - CV_RegisterVar(&cv_driftgaugestyle); - CV_RegisterVar(&cv_perfstats); CV_RegisterVar(&cv_ps_thinkframe_page); CV_RegisterVar(&cv_ps_samplesize); diff --git a/src/k_kart.c b/src/k_kart.c index b8174dc57..8afc37819 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -82,9 +82,18 @@ consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, consvar_t cv_posanim = {"postitionanimation", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_smallposnum = {"smallpositionnumber", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_minihead = {"smallminimapplayers", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showminimapnames = {"showminimapnames", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_highresportrait = {"highresportrait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //make char potraits use their high-res version instead + +consvar_t cv_showlapemblem = {"showlapemblem", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_darkitembox = {"darkitembox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //itembox gets a dark box with specific items +consvar_t cv_biglaps = {"biglaphud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //here for ppl who dont want to make 2 more patches for their custom hud CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; consvar_t cv_newspeedometer = {"newspeedometer", "Default", CV_SAVE, speedo_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //toggle for showing the speedometer in battlemode //hardcode saltyhop mhhm consvar_t cv_saltyhop = {"hardcodehop", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -98,13 +107,45 @@ consvar_t cv_colorizeditembox = {"colorizeditembox", "Off", CV_SAVE, CV_OnOff, N static CV_PossibleValue_t HudColor_cons_t[MAXSKINCOLORS+1]; consvar_t cv_colorizedhudcolor = {"colorizedhudcolor", "Skin Color", CV_SAVE, HudColor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_highresportrait = {"highresportrait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //make char potraits use their high-res version instead +// driftgauge stuffs +static CV_PossibleValue_t driftgaugeoffset_cons_t[] = { + {-FRACUNIT*128, "MIN"}, {FRACUNIT*128, "MAX"}, {0, NULL}}; +CV_PossibleValue_t driftgaugestyle_cons_t[NUMSPEEDOSTUFF]; -consvar_t cv_darkitembox = {"darkitembox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //itembox gets a dark box with specific items +consvar_t cv_driftgauge = {"kartdriftgauge", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_driftgaugeofs = {"kartdriftgaugeoffset", "-20", CV_FLOAT|CV_SAVE, driftgaugeoffset_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_driftgaugetrans = {"kartdriftgaugetransparency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_driftgaugestyle = {"kartdriftgaugestyle", "1", CV_SAVE, driftgaugestyle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_biglaps = {"biglaphud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //here for ppl who dont want to make 2 more patches for their custom hud +// nametags +static CV_PossibleValue_t nametagtrans_cons_t[] = { + {0, "Never"}, {1, "Far only"}, {2, "Dynamic"}, {3, "Always"}, {4, "HUD Trans."}, {0, NULL}}; +/*static CV_PossibleValue_t nametagscaling_cons_t[] = { + {0, "MIN"}, {320, "MAX"}, {0, NULL}};*/ +static CV_PossibleValue_t nametagdistance_cons_t[] = { + {0, "MIN"}, {640, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t nametagmaxplayer_cons_t[] = { + {1, "MIN"}, {MAXPLAYERS, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t nametagsize_cons_t[] = { + {0, "Off"}, {1, "Small"}, {2, "Minimal"}, {0, NULL}}; +static CV_PossibleValue_t nametagrestat_cons_t[] = { + {0, "Off"}, {1, "Restat"}, {2, "Always"}, {0, NULL}}; + +consvar_t cv_nametag = {"kartnametag", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagtrans = {"kartnametagtransparency", "Dynamic", CV_SAVE, nametagtrans_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagfacerank = {"kartnametagfacerank", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagrestat = {"kartnametagrestat", "Restat", CV_SAVE, nametagrestat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagdist = {"kartnametagdist", "320", CV_SAVE, nametagdistance_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagmaxplayers = {"kartnametagmaxplayers", "3", CV_SAVE, nametagmaxplayer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagmaxlenght = {"kartnametagmaxlenght", "12", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +//consvar_t cv_nametagscaling = {"nametagscaling", "160", CV_SAVE, nametagscaling_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showownnametag = {"kartnametagshowown", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_smallnametags = {"kartnametagsmall", "Off", CV_SAVE, nametagsize_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametaghop = {"kartnametaghop", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagscore = {"kartnametagscore", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shownametagfinish = {"kartshownametagfinished", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //toggle for showing the speedometer in battlemode // SOME IMPORTANT VARIABLES DEFINED IN DOOMDEF.H: // gamespeed is cc (0 for easy, 1 for normal, 2 for hard) @@ -736,9 +777,11 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_battlespeedo); - CV_RegisterVar(&cv_saltyhop); - CV_RegisterVar(&cv_saltyhopsfx); - CV_RegisterVar(&cv_saltysquish); + CV_RegisterVar(&cv_minihead); + CV_RegisterVar(&cv_showminimapnames); + CV_RegisterVar(&cv_showlapemblem); + + CV_RegisterVar(&cv_stagetitle); //Colourized HUD CV_RegisterVar(&cv_colorizedhud); @@ -751,14 +794,31 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_highresportrait); + CV_RegisterVar(&cv_nametag); + CV_RegisterVar(&cv_nametagtrans); + CV_RegisterVar(&cv_nametagfacerank); + CV_RegisterVar(&cv_nametagmaxplayers); + CV_RegisterVar(&cv_nametagmaxlenght); + //CV_RegisterVar(&cv_nametagscaling); + CV_RegisterVar(&cv_nametagdist); + CV_RegisterVar(&cv_showownnametag); + CV_RegisterVar(&cv_smallnametags); + CV_RegisterVar(&cv_nametagrestat); + CV_RegisterVar(&cv_nametaghop); + CV_RegisterVar(&cv_nametagscore); + CV_RegisterVar(&cv_shownametagfinish); + CV_RegisterVar(&cv_shownametagspectator); + + CV_RegisterVar(&cv_driftgauge); + CV_RegisterVar(&cv_driftgaugeofs); + CV_RegisterVar(&cv_driftgaugetrans); + CV_RegisterVar(&cv_driftgaugestyle); + + CV_RegisterVar(&cv_saltyhop); + CV_RegisterVar(&cv_saltyhopsfx); + CV_RegisterVar(&cv_saltysquish); CV_RegisterVar(&cv_slamsound); - CV_RegisterVar(&cv_minihead); - CV_RegisterVar(&cv_showminimapnames); - CV_RegisterVar(&cv_showlapemblem); - - CV_RegisterVar(&cv_stagetitle); - CV_RegisterVar(&cv_lessflicker); CV_RegisterVar(&cv_mouseturn); diff --git a/src/k_kart.h b/src/k_kart.h index 647ae3bf0..34c59c622 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -36,6 +36,7 @@ extern consvar_t cv_battlespeedo; #define NUMSPEEDOSTUFF 6 extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; +extern CV_PossibleValue_t driftgaugestyle_cons_t[NUMSPEEDOSTUFF]; boolean K_IsPlayerLosing(player_t *player); boolean K_IsPlayerWanted(player_t *player); -- 2.54.0 From 38b52b826a83e84b4cc5177aefcc148631462653 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 8 Jan 2025 12:00:41 +0300 Subject: [PATCH 42/44] huh --- src/p_tick.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index ec77d50cf..9d5a64cf3 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -381,11 +381,6 @@ static void P_DeviceRumbleTick(void) continue; } - if (camera[i].freecam) - { - continue; - } - if (player->mo == NULL) { continue; -- 2.54.0 From d9f0c55fee5d5456af4c4c28d927fbe3c31f0de0 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Jan 2025 22:31:31 +0100 Subject: [PATCH 43/44] "Invinciblity" --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index a2732c3a7..c4fad470c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2160,7 +2160,7 @@ static menuitem_t OP_MonitorToggleMenu[] = {IT_KEYHANDLER | IT_NOTHING, NULL, "Jawz x2", M_HandleMonitorToggles, KRITEM_DUALJAWZ}, {IT_KEYHANDLER | IT_NOTHING, NULL, "Ballhogs", M_HandleMonitorToggles, KITEM_BALLHOG}, {IT_KEYHANDLER | IT_NOTHING, NULL, "Self-Propelled Bombs", M_HandleMonitorToggles, KITEM_SPB}, - {IT_KEYHANDLER | IT_NOTHING, NULL, "Invinciblity", M_HandleMonitorToggles, KITEM_INVINCIBILITY}, + {IT_KEYHANDLER | IT_NOTHING, NULL, "Invincibility", M_HandleMonitorToggles, KITEM_INVINCIBILITY}, {IT_KEYHANDLER | IT_NOTHING, NULL, "Grow", M_HandleMonitorToggles, KITEM_GROW}, {IT_KEYHANDLER | IT_NOTHING, NULL, "Shrink", M_HandleMonitorToggles, KITEM_SHRINK}, {IT_KEYHANDLER | IT_NOTHING, NULL, "Thunder Shields", M_HandleMonitorToggles, KITEM_THUNDERSHIELD}, -- 2.54.0 From 2a948ca4c2c82b04e71664a6aa60a306d874dc47 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Jan 2025 22:46:05 +0100 Subject: [PATCH 44/44] move this --- src/m_menu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index c4fad470c..ace9d585e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4336,10 +4336,11 @@ void M_Drawer(void) #ifdef HWRENDER if (rendermode == render_opengl) - V_DrawThinString(0, 0, V_GREENMAP|V_SNAPTOTOP|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("Opengl")); + V_DrawThinString(0, 0, V_GREENMAP|V_SNAPTOTOP|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("Opengl")); + else #endif if (rendermode == render_soft) - V_DrawThinString(0, 0, V_REDMAP|V_SNAPTOTOP|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("Software")); + V_DrawThinString(0, 0, V_REDMAP|V_SNAPTOTOP|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("Software")); } } } -- 2.54.0