From 9d1bef9ab9294272391e19e84e08aa35ec509d2e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Dec 2024 10:18:27 +0100 Subject: [PATCH 001/418] i love menus --- 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 31dd19f3c..3a8180811 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1373,7 +1373,7 @@ static menuitem_t OP_VideoOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_globalsaturation , 40}, - {IT_SUBMENU|IT_STRING, NULL, "Advanced Color Settings...", &OP_ColorOptionsDef, 45}, + {IT_SUBMENU|IT_STRING, NULL, "Advanced Color Settings...", &OP_ColorOptionsDef, 50}, {IT_STRING | IT_CVAR, NULL, "Randomized Directional Light",&cv_randomdirlight, 60}, From a920556feb1d3d61cfe08e3a6a9daa5e42507eaa Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Dec 2024 16:53:10 +0100 Subject: [PATCH 002/418] fix papersprite directional light uhhh idk?? also passes papersprite bool directly instead of rechecking every frame for it --- src/hardware/hw_glob.h | 2 +- src/hardware/hw_main.c | 17 +++++++++-------- src/hardware/hw_md2.c | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index f0fad4f23..df4ac6f5f 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -43,7 +43,7 @@ typedef struct gl_vissprite_s INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing } gl_vissprite_t; -void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model); +void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite); // -------- // hw_bsp.c diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c7b210d6c..c605aa73c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -340,21 +340,22 @@ boolean HWR_PalRenderFlashpal(void) return (HWR_ShouldUsePaletteRendering() && cv_glflashpal.value); } -void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model) +void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite) { - const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE); - *lightlevel += R_ThingLightLevel(spr->mobj); if (maplighting.directional == true && P_SectorUsesDirectionalLighting(sector)) { if (model == false) // this is implemented by shader { - fixed_t extralight = R_GetSpriteDirectionalLighting( + fixed_t extralight = R_GetSpriteDirectionalLighting(R_PointToAngle(spr->mobj->x, spr->mobj->y)); + + // this seems to be wrong??? + /*fixed_t extralight = R_GetSpriteDirectionalLighting( papersprite ? R_PointToAngle(spr->mobj->x, spr->mobj->y) + (spr->flip ? -ANGLE_90 : ANGLE_90) : R_PointToAngle(spr->mobj->x, spr->mobj->y) // fixme - ); + );*/ // Less change in contrast in dark sectors extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255); @@ -3661,7 +3662,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) break; } - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); for (i = 0; i < sector->numlights; i++) { @@ -3673,7 +3674,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = min(*list[i].lightlevel, 255); - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); colormap = list[i].extra_colormap; } @@ -3873,7 +3874,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = min(sector->lightlevel, 255); - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT)); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 956df2625..d1eae9087 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1142,7 +1142,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) colormap = sector->extra_colormap; } - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, true); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, true, false); HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT)); } From d8fe3920b1425fe3596775a9ea4387bc1d0120a4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Dec 2024 17:14:20 +0100 Subject: [PATCH 003/418] fix papersprite lightlevels again kek + remove shit that does nothing --- src/hardware/hw_main.c | 69 +++++++++++++++++++++--------------------- src/p_mobj.h | 2 -- src/r_things.c | 9 +----- src/r_things.h | 1 - 4 files changed, 35 insertions(+), 46 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c605aa73c..3556ae531 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -342,44 +342,43 @@ boolean HWR_PalRenderFlashpal(void) void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite) { - *lightlevel += R_ThingLightLevel(spr->mobj); + (void)papersprite; - if (maplighting.directional == true && P_SectorUsesDirectionalLighting(sector)) + if (maplighting.directional == false || !P_SectorUsesDirectionalLighting(sector) || model == true) + return; + + fixed_t extralight = R_GetSpriteDirectionalLighting(R_PointToAngle(spr->mobj->x, spr->mobj->y)); + + // this seems to be wrong??? + /*fixed_t extralight = R_GetSpriteDirectionalLighting( + papersprite + ? R_PointToAngle(spr->mobj->x, spr->mobj->y) + (spr->flip ? -ANGLE_90 : ANGLE_90) + : R_PointToAngle(spr->mobj->x, spr->mobj->y) // fixme + );*/ + + // Less change in contrast in dark sectors + extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255); + + // NO NO BAD! WHY!? + /*if (papersprite) { - if (model == false) // this is implemented by shader - { - fixed_t extralight = R_GetSpriteDirectionalLighting(R_PointToAngle(spr->mobj->x, spr->mobj->y)); - - // this seems to be wrong??? - /*fixed_t extralight = R_GetSpriteDirectionalLighting( - papersprite - ? R_PointToAngle(spr->mobj->x, spr->mobj->y) + (spr->flip ? -ANGLE_90 : ANGLE_90) - : R_PointToAngle(spr->mobj->x, spr->mobj->y) // fixme - );*/ - - // Less change in contrast in dark sectors - extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255); - - if (papersprite) - { - // Papersprite contrast should match walls - *lightlevel += FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; - } - else - { - // simple OGL approximation - fixed_t tr = R_PointToDist(spr->mobj->x, spr->mobj->y); - fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); - - // Less change in contrast at further distances, to counteract DOOM diminished light - fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); - extralight = FixedMul(extralight, min(n, FRACUNIT)); - - // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance - *lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT; - } - } + // Papersprite contrast should match walls + *lightlevel += FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; } + else*/ + { + // simple OGL approximation + fixed_t tr = R_PointToDist(spr->mobj->x, spr->mobj->y); + fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); + + // Less change in contrast at further distances, to counteract DOOM diminished light + fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); + extralight = FixedMul(extralight, min(n, FRACUNIT)); + + // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance + *lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT; + } + } void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap, const boolean directional) diff --git a/src/p_mobj.h b/src/p_mobj.h index 0529c4891..cd7c64dc1 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -293,7 +293,6 @@ typedef struct mobj_s fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; fixed_t old_spritexoffset, old_spriteyoffset; - INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch @@ -446,7 +445,6 @@ typedef struct precipmobj_s fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; fixed_t old_spritexoffset, old_spriteyoffset; - INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch diff --git a/src/r_things.c b/src/r_things.c index 20603cbc8..66a0b82df 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -109,13 +109,6 @@ static drawseg_xrange_item_t *drawsegs_xrange; static size_t drawsegs_xrange_size = 0; static INT32 drawsegs_xrange_count = 0; -INT32 R_ThingLightLevel(mobj_t* thing) -{ - INT32 lightlevel = thing->lightlevel; - - return lightlevel; -} - // ========================================================================== // // Sprite loading routines: support sprites in pwad, dehacked sprite renaming, @@ -1613,7 +1606,7 @@ static void R_ProjectSprite(mobj_t *thing) lightnum = thing->subsector->sector->lightlevel; } - lightnum = (lightnum + R_ThingLightLevel(thing)) >> LIGHTSEGSHIFT; + lightnum = (lightnum) >> LIGHTSEGSHIFT; if (maplighting.directional == true && P_SectorUsesDirectionalLighting(thing->subsector->sector)) { diff --git a/src/r_things.h b/src/r_things.h index 1af5d99bd..78221d794 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -57,7 +57,6 @@ extern fixed_t windowtop; extern fixed_t windowbottom; extern INT32 lengthcol; -INT32 R_ThingLightLevel(mobj_t *thing); fixed_t R_GetSpriteDirectionalLighting(angle_t angle); fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); From 4aaa2c6fede3f6cc565a187ffc1642367494e8be Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Dec 2024 15:48:15 +0100 Subject: [PATCH 004/418] add shadows to faster slope z checking --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 6af0a6cad..d65d9070e 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -578,7 +578,7 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, ); } -#define NOCOLLISION ((mobj->flags & MF_NOBLOCKMAP) || (mobj->flags & MF_NOCLIPTHING)) +#define NOCOLLISION ((mobj->type == MT_SHADOW) || (mobj->flags & MF_NOBLOCKMAP) || (mobj->flags & MF_NOCLIPTHING)) fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) { From 83cc7015bf24ac2f04395d724e1741bbb08027c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Dec 2024 18:24:26 +0100 Subject: [PATCH 005/418] Revert "add shadows to faster slope z checking" This reverts commit 4aaa2c6fede3f6cc565a187ffc1642367494e8be. --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index d65d9070e..6af0a6cad 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -578,7 +578,7 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, ); } -#define NOCOLLISION ((mobj->type == MT_SHADOW) || (mobj->flags & MF_NOBLOCKMAP) || (mobj->flags & MF_NOCLIPTHING)) +#define NOCOLLISION ((mobj->flags & MF_NOBLOCKMAP) || (mobj->flags & MF_NOCLIPTHING)) fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) { From 34f9dd9ea20409e133714bdb340b64ed7687c490 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Dec 2024 18:38:09 +0100 Subject: [PATCH 006/418] fix compile --- src/p_mobj.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 021271c49..96651dd74 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3236,7 +3236,6 @@ void P_DestroyRobots(void) // the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { - boolean itsatwodlevel = false; const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); UINT16 postimgflags = 0; UINT8 i; @@ -3246,21 +3245,6 @@ static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) if (flipcam) postimgflags |= POSTIMG_FLIP; - if (twodlevel) - itsatwodlevel = true; - else - { - for (i = 0; i <= splitscreen; i++) - { - if (thiscam == &camera[i] && players[displayplayers[i]].mo - && (players[displayplayers[i]].mo->flags2 & MF2_TWOD)) - { - itsatwodlevel = true; - break; - } - } - } - if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist { camera_t dummycam; @@ -3302,12 +3286,30 @@ static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) // Process the mobj-ish required functions of the camera boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled) { + boolean itsatwodlevel = false; + UINT8 i; + // This can happen when joining if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; P_CalcChasePostImg(player, thiscam); + if (twodlevel) + itsatwodlevel = true; + else + { + for (i = 0; i <= splitscreen; i++) + { + if (thiscam == &camera[i] && players[displayplayers[i]].mo + && (players[displayplayers[i]].mo->flags2 & MF2_TWOD)) + { + itsatwodlevel = true; + break; + } + } + } + if (thiscam->momx || thiscam->momy) { if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam)) // Never fails for 2D mode. @@ -3335,7 +3337,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled } if (!itsatwodlevel) - P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam); + P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam); thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y); thiscam->floorz = tmfloorz; From 7a232c8f5d0e370d807be4c7641a7502606a1e13 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Dec 2024 18:38:09 +0100 Subject: [PATCH 007/418] fix compile --- src/p_mobj.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 9b02a1e38..ee7a22591 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3245,7 +3245,6 @@ void P_DestroyRobots(void) // the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { - boolean itsatwodlevel = false; const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); UINT16 postimgflags = 0; UINT8 i; @@ -3255,21 +3254,6 @@ static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) if (flipcam) postimgflags |= POSTIMG_FLIP; - if (twodlevel) - itsatwodlevel = true; - else - { - for (i = 0; i <= splitscreen; i++) - { - if (thiscam == &camera[i] && players[displayplayers[i]].mo - && (players[displayplayers[i]].mo->flags2 & MF2_TWOD)) - { - itsatwodlevel = true; - break; - } - } - } - if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist { camera_t dummycam; @@ -3311,12 +3295,30 @@ static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) // Process the mobj-ish required functions of the camera boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled) { + boolean itsatwodlevel = false; + UINT8 i; + // This can happen when joining if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; P_CalcChasePostImg(player, thiscam); + if (twodlevel) + itsatwodlevel = true; + else + { + for (i = 0; i <= splitscreen; i++) + { + if (thiscam == &camera[i] && players[displayplayers[i]].mo + && (players[displayplayers[i]].mo->flags2 & MF2_TWOD)) + { + itsatwodlevel = true; + break; + } + } + } + if (thiscam->momx || thiscam->momy) { if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam)) // Never fails for 2D mode. @@ -3344,7 +3346,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled } if (!itsatwodlevel) - P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam); + P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam); thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y); thiscam->floorz = tmfloorz; From 39535e9bf8c29a46b3ff42fb8bd60b3ffdce0fdf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Dec 2024 18:52:27 +0100 Subject: [PATCH 008/418] this stuff somehow wasnt merged --- src/hardware/hw_glob.h | 2 +- src/hardware/hw_main.c | 74 +++++++++++++------------- src/hardware/hw_md2.c | 5 +- src/lua_baselib.c | 4 +- src/m_menu.c | 12 ++--- src/p_map.c | 115 ----------------------------------------- src/p_mobj.c | 2 +- src/p_tick.c | 1 - src/p_user.c | 2 - src/r_things.c | 9 +--- src/r_things.h | 1 - 11 files changed, 48 insertions(+), 179 deletions(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index f0fad4f23..df4ac6f5f 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -43,7 +43,7 @@ typedef struct gl_vissprite_s INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing } gl_vissprite_t; -void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model); +void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite); // -------- // hw_bsp.c diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 31181b8e4..06362cc11 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -339,45 +339,45 @@ boolean HWR_PalRenderFlashpal(void) return (HWR_ShouldUsePaletteRendering() && cv_glflashpal.value); } -void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model) +void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite) { - const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE); + (void)papersprite; - *lightlevel += R_ThingLightLevel(spr->mobj); + if (maplighting.directional == false || !P_SectorUsesDirectionalLighting(sector) || model == true) + return; - if (maplighting.directional == true && P_SectorUsesDirectionalLighting(sector)) + fixed_t extralight = R_GetSpriteDirectionalLighting(R_PointToAngle(spr->mobj->x, spr->mobj->y)); + + // this seems to be wrong??? + /*fixed_t extralight = R_GetSpriteDirectionalLighting( + papersprite + ? R_PointToAngle(spr->mobj->x, spr->mobj->y) + (spr->flip ? -ANGLE_90 : ANGLE_90) + : R_PointToAngle(spr->mobj->x, spr->mobj->y) // fixme + );*/ + + // Less change in contrast in dark sectors + extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255); + + // NO NO BAD! WHY!? + /*if (papersprite) { - if (model == false) // this is implemented by shader - { - fixed_t extralight = R_GetSpriteDirectionalLighting( - papersprite - ? R_PointToAngle(spr->mobj->x, spr->mobj->y) + (spr->flip ? -ANGLE_90 : ANGLE_90) - : R_PointToAngle(spr->mobj->x, spr->mobj->y) // fixme - ); - - // Less change in contrast in dark sectors - extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255); - - if (papersprite) - { - // Papersprite contrast should match walls - *lightlevel += FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; - } - else - { - // simple OGL approximation - fixed_t tr = R_PointToDist(spr->mobj->x, spr->mobj->y); - fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); - - // Less change in contrast at further distances, to counteract DOOM diminished light - fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); - extralight = FixedMul(extralight, min(n, FRACUNIT)); - - // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance - *lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT; - } - } + // Papersprite contrast should match walls + *lightlevel += FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; } + else*/ + { + // simple OGL approximation + fixed_t tr = R_PointToDist(spr->mobj->x, spr->mobj->y); + fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); + + // Less change in contrast at further distances, to counteract DOOM diminished light + fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); + extralight = FixedMul(extralight, min(n, FRACUNIT)); + + // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance + *lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT; + } + } void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap, const boolean directional) @@ -3643,7 +3643,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) break; } - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); for (i = 0; i < sector->numlights; i++) { @@ -3655,7 +3655,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = min(*list[i].lightlevel, 255); - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); colormap = list[i].extra_colormap; } @@ -3855,7 +3855,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = min(sector->lightlevel, 255); - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT)); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 1118caf8d..09d2ba979 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1054,7 +1054,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT return; } - // search for the mimmap + // search for the Mipmap // skip the first (no colormap translated) for (glMipmap = gpatch->mipmap; glMipmap->nextcolormap; ) { @@ -1090,7 +1090,6 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT Z_ChangeTag(newMipmap->data, PU_HWRCACHE_UNLOCKED); } - // -----------------+ // HWR_DrawMD2 : Draw MD2 // : @@ -1144,7 +1143,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) colormap = sector->extra_colormap; } - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, true); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, true, false); HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT)); } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 277d4eb22..50660781e 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1961,7 +1961,7 @@ static int lib_sStartSoundAtVolume(lua_State *L) return LUA_ErrInvalid(L, "player_t"); } if (!player || P_IsLocalPlayer(player)) - S_StartSoundAtVolume(origin, sound_id, volume); + S_StartSoundAtVolume(origin, sound_id, volume); return 0; } @@ -2063,7 +2063,7 @@ static int lib_sChangeMusic(lua_State *L) music_flags = (UINT16)((music_num & 0x7FFF0000) >> 16); else #endif - music_flags = (UINT16)luaL_optinteger(L, 4, 0); + music_flags = (UINT16)luaL_optinteger(L, 4, 0); position = (UINT32)luaL_optinteger(L, 5, 0); prefadems = (UINT32)luaL_optinteger(L, 6, 0); diff --git a/src/m_menu.c b/src/m_menu.c index 4160b5663..1ab2c157b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6186,8 +6186,6 @@ static void M_AddonsClearName(INT32 choice) M_StopMessage(choice); } -int errorshitspam = 0; // prevent the warning screen from crapping itself when errors get spammed lmao - // returns whether to do message draw static boolean M_AddonsRefresh(void) { @@ -6207,6 +6205,7 @@ static boolean M_AddonsRefresh(void) if ((refreshdirmenu & REFRESHDIR_ADDFILE) || (majormods && !prevmajormods)) { char *message = NULL; + boolean majormodtext = false; if (refreshdirmenu & REFRESHDIR_NOTLOADED) { @@ -6216,20 +6215,19 @@ static boolean M_AddonsRefresh(void) else message = va("%c%s\x80\nA file was not loaded.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); } - else if ((refreshdirmenu & (REFRESHDIR_WARNING | REFRESHDIR_ERROR)) && !errorshitspam) + else if (refreshdirmenu & (REFRESHDIR_WARNING | REFRESHDIR_ERROR)) { S_StartSound(NULL, sfx_s224); message = va("%c%s\x80\nA file was loaded with %s.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname, ((refreshdirmenu & REFRESHDIR_ERROR) ? "errors" : "warnings")); - errorshitspam = 1; // you already said that shit } else if (majormods && !prevmajormods) { S_StartSound(NULL, sfx_s221); message = va("%c%s\x80\nYou've loaded a gameplay-modifying addon.\n\nRecord Attack has been disabled, but you\ncan still play alone in local Multiplayer.\n\nIf you wish to play Record Attack mode, restart the game to disable loaded addons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); - prevmajormods = majormods; + majormodtext = prevmajormods = majormods; } - if (message) + if (message && (refreshdirmenu || majormodtext)) // special case for gameplay modify text { M_StartMessage(message,M_AddonsClearName,MM_EVENTHANDLER); return true; @@ -6572,7 +6570,6 @@ static void M_HandleAddons(INT32 choice) if (DumbStartsWith("KC_", dirmenu[dir_on[menudepthleft]]+DIR_STRING) || DumbStartsWith("kc_", dirmenu[dir_on[menudepthleft]]+DIR_STRING)) { M_StartMessage(va("%c%s\x80\nYou are loading a local skin.\nLocal skins will not be usable\nafter going back from\nthe title screen.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); COM_BufAddText(va("addskins \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); - errorshitspam = 0; // reset it so it can show the warning screen again lmao } else S_StartSound(NULL, sfx_s26d); @@ -6580,7 +6577,6 @@ static void M_HandleAddons(INT32 choice) else { COM_BufAddText(va("addfile \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); - errorshitspam = 0; // reset it so it can show the warning screen again lmao } break; default: diff --git a/src/p_map.c b/src/p_map.c index bd809df9e..ecaf322d2 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1670,8 +1670,6 @@ static boolean PIT_CheckLine(line_t *ld) // MOVEMENT CLIPPING // ========================================================================= -static boolean P_CheckPositionShadow(mobj_t *thing, fixed_t x, fixed_t y); - // // P_CheckPosition // This is purely informative, nothing is modified @@ -1717,12 +1715,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) I_Error("Previously-removed Thing of type %u crashes P_CheckPosition!", thing->type); #endif - // crappy optimization lmao hope this works out - if (thing->type == MT_SHADOW) - { - return P_CheckPositionShadow(thing, x, y); - } - P_SetTarget(&tmthing, thing); tmflags = thing->flags; @@ -1968,113 +1960,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) return blockval; } -// P_CheckPosition but its actually R_GetShadowZ from SRB2 -// this checks for less and keeps everything simpler -// since i dont want VISUAL shadows crapping by checking for a crapton of stuff -static boolean P_CheckPositionShadow(mobj_t *thing, fixed_t x, fixed_t y) -{ - subsector_t *newsubsec; - - P_SetTarget(&tmthing, thing); - tmflags = thing->flags; - - tmx = x; - tmy = y; - - tmbbox[BOXTOP] = y + tmthing->radius; - tmbbox[BOXBOTTOM] = y - tmthing->radius; - tmbbox[BOXRIGHT] = x + tmthing->radius; - tmbbox[BOXLEFT] = x - tmthing->radius; - - if (thing->x != x || thing->y != y || thing->subsector == NULL) - newsubsec = R_PointInSubsector(x, y); - else - newsubsec = thing->subsector; - - ceilingline = blockingline = NULL; - - // The base floor / ceiling is from the subsector - // that contains the point. - // Any contacted lines the step closer together - // will adjust them. - tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; - tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; - tmfloorslope = newsubsec->sector->f_slope; - tmceilingslope = newsubsec->sector->c_slope; - - const fixed_t halfHeight = (thing->z + (thing->height >> 1)); - - // Check list of fake floors and see if tmfloorz/tmceilingz need to be altered. - if (newsubsec->sector->ffloors) - { - ffloor_t *rover; - - for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) - { - fixed_t topheight, bottomheight; - - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE))) - continue; - - topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); - bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); - - if (topheight < halfHeight && topheight > tmfloorz) - { - tmfloorz = tmdropoffz = topheight; - tmfloorslope = *rover->t_slope; - } - if (bottomheight > halfHeight && bottomheight < tmfloorz) - { - tmceilingz = tmdrpoffceilz = bottomheight; - tmceilingslope = *rover->b_slope; - } - } - } - - tmfloorthing = NULL; - tmhitthing = NULL; - - // Check polyobjects and see if groundz needs to be altered - // This isn't very precise, but the precise method was far too slow. - // (Polies are just naturally pretty flickery anyway :P) - - // do we really have to iterate through the complete blockmap for polyobjects if there are no polyobjects on the map? - if (numPolyObjects) - { - polyobj_t *po = newsubsec->polyList; - fixed_t z; - - while (po) - { - if (!(po->flags & POF_RENDERPLANES) || !P_MobjInsidePolyobj(po, tmthing)) - { - po = (polyobj_t *)(po->link.next); - continue; - } - - // We're inside it! Yess... - z = po->lines[0]->backsector->floorheight; - if (z < halfHeight && z > tmfloorz) - { - tmfloorz = z; - tmfloorslope = NULL; - } - - z = po->lines[0]->backsector->ceilingheight; - if (z > halfHeight && z < tmfloorz) - { - tmceilingz = z; - tmceilingslope = NULL; - } - - po = (polyobj_t *)(po->link.next); - } - } - - return true; -} - static const fixed_t hoopblockdist = 16*FRACUNIT + 8*FRACUNIT; static const fixed_t hoophalfheight = (56*FRACUNIT)/2; diff --git a/src/p_mobj.c b/src/p_mobj.c index ee7a22591..76023935f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -578,7 +578,7 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, ); } -#define NOCOLLISION ((mobj->type == MT_SHADOW) || (mobj->flags & MF_NOBLOCKMAP) || (mobj->flags & MF_NOCLIPTHING)) +#define NOCOLLISION ((mobj->flags & MF_NOBLOCKMAP) || (mobj->flags & MF_NOCLIPTHING)) fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) { diff --git a/src/p_tick.c b/src/p_tick.c index e6239e312..03c8e864b 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -306,7 +306,6 @@ void P_UnlinkThinker(thinker_t *thinker) } } - // // P_RemoveThinker // diff --git a/src/p_user.c b/src/p_user.c index c3ca34ad7..d74aa7973 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4599,8 +4599,6 @@ void P_PlayerThink(player_t *player) { player->pflags ^= PF_WANTSTOJOIN; player->powers[pw_flashing] = TICRATE/2 + 1; - /*if (P_SpectatorJoinGame(player)) - return; // player->mo was removed.*/ } // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. diff --git a/src/r_things.c b/src/r_things.c index 45e1403fc..c876eb640 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -109,13 +109,6 @@ static drawseg_xrange_item_t *drawsegs_xrange; static size_t drawsegs_xrange_size = 0; static INT32 drawsegs_xrange_count = 0; -INT32 R_ThingLightLevel(mobj_t* thing) -{ - INT32 lightlevel = thing->lightlevel; - - return lightlevel; -} - // ========================================================================== // // Sprite loading routines: support sprites in pwad, dehacked sprite renaming, @@ -1616,7 +1609,7 @@ static void R_ProjectSprite(mobj_t *thing) lightnum = thing->subsector->sector->lightlevel; } - lightnum = (lightnum + R_ThingLightLevel(thing)) >> LIGHTSEGSHIFT; + lightnum = (lightnum) >> LIGHTSEGSHIFT; if (maplighting.directional == true && P_SectorUsesDirectionalLighting(thing->subsector->sector)) { diff --git a/src/r_things.h b/src/r_things.h index 1af5d99bd..78221d794 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -57,7 +57,6 @@ extern fixed_t windowtop; extern fixed_t windowbottom; extern INT32 lengthcol; -INT32 R_ThingLightLevel(mobj_t *thing); fixed_t R_GetSpriteDirectionalLighting(angle_t angle); fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); From d478a8a8b421b4f9941b40763b2f05b85fbac976 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Dec 2024 19:59:42 +0100 Subject: [PATCH 009/418] just skip missing/broken fields in musiccredit handling like vanilla kek still will throw warnings but atleast will show stuff if theres anything left in the musicdef --- src/s_sound.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index aff169807..cd9eb4e90 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1222,12 +1222,13 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) if (!stricmp(stoken, "lump")) { value = strtok(NULL, " "); + if (!value) { CONS_Alert(CONS_WARNING, "MUSICDEF: Field '%s' is missing name. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); - return false; + goto skip_lump; } else { @@ -1248,6 +1249,10 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) (*defp) = def; } + +skip_lump: + stoken = strtok(NULL, " "); + line++; } else { @@ -1264,7 +1269,7 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) CONS_Alert(CONS_WARNING, "MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); - return false; + goto skip_field; } else { @@ -1316,6 +1321,10 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) else CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); #undef ADDDEF + +skip_field: + stoken = strtok(NULL, "= "); + line++; } } From c379db831cd1762bd3e580c9bf4c798833de9a59 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Dec 2024 20:57:56 +0100 Subject: [PATCH 010/418] readd mobj lightlevel field so i dont have to edit frameflags --- src/hardware/hw_main.c | 2 ++ src/r_things.c | 9 ++++++++- src/r_things.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 06362cc11..90db6b7cd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -343,6 +343,8 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 { (void)papersprite; + *lightlevel += R_ThingLightLevel(spr->mobj); + if (maplighting.directional == false || !P_SectorUsesDirectionalLighting(sector) || model == true) return; diff --git a/src/r_things.c b/src/r_things.c index c876eb640..45e1403fc 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -109,6 +109,13 @@ static drawseg_xrange_item_t *drawsegs_xrange; static size_t drawsegs_xrange_size = 0; static INT32 drawsegs_xrange_count = 0; +INT32 R_ThingLightLevel(mobj_t* thing) +{ + INT32 lightlevel = thing->lightlevel; + + return lightlevel; +} + // ========================================================================== // // Sprite loading routines: support sprites in pwad, dehacked sprite renaming, @@ -1609,7 +1616,7 @@ static void R_ProjectSprite(mobj_t *thing) lightnum = thing->subsector->sector->lightlevel; } - lightnum = (lightnum) >> LIGHTSEGSHIFT; + lightnum = (lightnum + R_ThingLightLevel(thing)) >> LIGHTSEGSHIFT; if (maplighting.directional == true && P_SectorUsesDirectionalLighting(thing->subsector->sector)) { diff --git a/src/r_things.h b/src/r_things.h index 78221d794..1af5d99bd 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -57,6 +57,7 @@ extern fixed_t windowtop; extern fixed_t windowbottom; extern INT32 lengthcol; +INT32 R_ThingLightLevel(mobj_t *thing); fixed_t R_GetSpriteDirectionalLighting(angle_t angle); fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); From 01208a858dc1b2533d52bb205c8c57375af21138 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Dec 2024 20:56:11 +0100 Subject: [PATCH 011/418] settable mobj lightlevel from lua --- src/lua_mobjlib.c | 1 + src/p_saveg.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 7385cccf6..8cb3ecf98 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -97,6 +97,7 @@ static const udata_field_t mobj_fields[] = { FIELD(mobj_t, spritexoffset, udatalib_getter_fixed, udatalib_setter_fixed), FIELD(mobj_t, spriteyoffset, udatalib_getter_fixed, udatalib_setter_fixed), FIELD(mobj_t, touching_sectorlist, mobj_touching_sectorlist_unimplemented, mobj_touching_sectorlist_unimplemented), + FIELD(mobj_t, lightlevel, udatalib_getter_int16, udatalib_setter_int16), FIELD(mobj_t, subsector, udatalib_getter_subsector, mobj_nosetpos_subsector), FIELD(mobj_t, floorz, udatalib_getter_fixed, mobj_nosetpos_floorz), FIELD(mobj_t, ceilingz, udatalib_getter_fixed, mobj_nosetpos_ceilingz), diff --git a/src/p_saveg.c b/src/p_saveg.c index 5b70695d7..20dd40937 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2158,6 +2158,9 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) // Timer for slam sound effect mobj->slamsoundtimer = 0; + // extra mobjlightlevel + mobj->lightlevel = 0; + //} if (diff & MD_REDFLAG) From 09e901b31b10ebbfac084614f999395d620f03a3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Dec 2024 20:57:56 +0100 Subject: [PATCH 012/418] readd mobj lightlevel field so i dont have to edit frameflags --- src/hardware/hw_main.c | 2 ++ src/r_things.c | 9 ++++++++- src/r_things.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5e340ef00..b80b5907f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -344,6 +344,8 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 { (void)papersprite; + *lightlevel += R_ThingLightLevel(spr->mobj); + if (maplighting.directional == false || !P_SectorUsesDirectionalLighting(sector) || model == true) return; diff --git a/src/r_things.c b/src/r_things.c index c876eb640..45e1403fc 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -109,6 +109,13 @@ static drawseg_xrange_item_t *drawsegs_xrange; static size_t drawsegs_xrange_size = 0; static INT32 drawsegs_xrange_count = 0; +INT32 R_ThingLightLevel(mobj_t* thing) +{ + INT32 lightlevel = thing->lightlevel; + + return lightlevel; +} + // ========================================================================== // // Sprite loading routines: support sprites in pwad, dehacked sprite renaming, @@ -1609,7 +1616,7 @@ static void R_ProjectSprite(mobj_t *thing) lightnum = thing->subsector->sector->lightlevel; } - lightnum = (lightnum) >> LIGHTSEGSHIFT; + lightnum = (lightnum + R_ThingLightLevel(thing)) >> LIGHTSEGSHIFT; if (maplighting.directional == true && P_SectorUsesDirectionalLighting(thing->subsector->sector)) { diff --git a/src/r_things.h b/src/r_things.h index 78221d794..1af5d99bd 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -57,6 +57,7 @@ extern fixed_t windowtop; extern fixed_t windowbottom; extern INT32 lengthcol; +INT32 R_ThingLightLevel(mobj_t *thing); fixed_t R_GetSpriteDirectionalLighting(angle_t angle); fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); From d2ca916043c5384a998437bf43af913fc96037ed Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Dec 2024 20:56:11 +0100 Subject: [PATCH 013/418] settable mobj lightlevel from lua --- src/lua_mobjlib.c | 1 + src/p_saveg.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 7385cccf6..8cb3ecf98 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -97,6 +97,7 @@ static const udata_field_t mobj_fields[] = { FIELD(mobj_t, spritexoffset, udatalib_getter_fixed, udatalib_setter_fixed), FIELD(mobj_t, spriteyoffset, udatalib_getter_fixed, udatalib_setter_fixed), FIELD(mobj_t, touching_sectorlist, mobj_touching_sectorlist_unimplemented, mobj_touching_sectorlist_unimplemented), + FIELD(mobj_t, lightlevel, udatalib_getter_int16, udatalib_setter_int16), FIELD(mobj_t, subsector, udatalib_getter_subsector, mobj_nosetpos_subsector), FIELD(mobj_t, floorz, udatalib_getter_fixed, mobj_nosetpos_floorz), FIELD(mobj_t, ceilingz, udatalib_getter_fixed, mobj_nosetpos_ceilingz), diff --git a/src/p_saveg.c b/src/p_saveg.c index 83f607bf2..4a438d0c4 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2177,6 +2177,9 @@ static void LoadMobjThinker(actionf_p1 thinker) // Timer for slam sound effect mobj->slamsoundtimer = 0; + // extra mobjlightlevel + mobj->lightlevel = 0; + //} if (diff & MD_REDFLAG) From 7dcd5f41ec589f6d5d1b4d45b2c2a58ee03be1c6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Dec 2024 21:18:57 +0100 Subject: [PATCH 014/418] use P_MobjWasRemoved for HWR_DrawSprite --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 90db6b7cd..e24ff8ef7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3766,7 +3766,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) INT32 shader = SHADER_NONE; - if (!spr->mobj) + if (P_MobjWasRemoved(spr->mobj)) return; if (!spr->mobj->subsector) From a700ec32fda89acb267d6e628bc679bf48f67a86 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Dec 2024 00:58:11 +0100 Subject: [PATCH 015/418] fixeur comptime stuff (thx indev <3) --- comptime.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comptime.sh b/comptime.sh index 1172061fe..82dfa0060 100755 --- a/comptime.sh +++ b/comptime.sh @@ -17,7 +17,7 @@ EOF versiongit() { gitbranch="$(git rev-parse --abbrev-ref HEAD)" - gitversion="$(git show --pretty=format:'%h %s' -s HEAD)" + gitversion="$(git show --pretty=format:'%h %s' -s HEAD | sed 's/"/\\"/g')" version "$gitbranch" "$gitversion"; exit 0 } From edf38cef33ba8daa5bd76f01b60692aef65c3727 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 23 Dec 2024 12:41:36 +0300 Subject: [PATCH 016/418] If player has mobj, use it to assign localangle in G_FixCamera --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 5b3a0d5bf..df30a1799 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1694,7 +1694,7 @@ static void G_FixCamera(UINT8 view) // The order of displayplayers can change, which would // invalidate localangle. - localangle[view - 1] = (angle_t)(player->cmd.angleturn << 16); + localangle[view - 1] = (P_MobjWasRemoved(player->mo) ? ((angle_t)player->cmd.angleturn << 16) : player->mo->angle); P_ResetCamera(player, &camera[view - 1]); From c74898b970e7a0ac7772a2666b697ff02e24c6a6 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Dec 2024 18:06:56 +0100 Subject: [PATCH 017/418] make those const --- src/p_floor.c | 18 +++++++++--------- src/p_map.c | 10 ++++------ src/p_mobj.c | 4 ++-- src/p_spec.c | 8 ++++---- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 738524b02..26a2d0cf1 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2119,11 +2119,11 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) sec = §ors[secnum]; FOFsector = false; - INT32 special = GETSECSPECIAL(sec->special, 2); + const INT32 secspecial = GETSECSPECIAL(sec->special, 2); - if (special == 3 || special == 5) + if (secspecial == 3 || secspecial == 5) floortouch = true; - else if (special >= 1 && special <= 8) + else if (secspecial >= 1 && secspecial <= 8) floortouch = false; else continue; @@ -2255,7 +2255,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) continue; if (!(players[i].mo->subsector->sector == sec - || P_PlayerTouchingSectorSpecial(&players[i], 2, special) == sec)) + || P_PlayerTouchingSectorSpecial(&players[i], 2, secspecial) == sec)) continue; if (floortouch == true && P_IsObjectOnRealGround(players[i].mo, sec)) @@ -2299,9 +2299,9 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) while ((affectPlayer = P_HavePlayersEnteredArea(playersArea, oldPlayersArea, inAndOut)) != -1) { - INT32 special = GETSECSPECIAL(sec->special, 2); + const INT32 secspecial = GETSECSPECIAL(sec->special, 2); - if (special == 2 || special == 3) + if (secspecial == 2 || secspecial == 3) { for (i = 0; i < MAXPLAYERS; i++) { @@ -2920,12 +2920,12 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) fixed_t a, b, c; mobjtype_t type = MT_ROCKCRUMBLE1; const fixed_t spacing = 48*mapobjectscale; - INT32 special = GETSECSPECIAL(rover->master->frontsector->special, 3); + const INT32 secspecial = GETSECSPECIAL(rover->master->frontsector->special, 3); // If the control sector has a special // of Section3:7-15, use the custom debris. - if (special >= 8) - type = MT_ROCKCRUMBLE1+(special-7); + if (secspecial >= 8) + type = MT_ROCKCRUMBLE1+(secspecial-7); sec->soundorg.z = (rover->master->frontsector->floorheight + rover->master->frontsector->ceilingheight)/2; S_StartSound(&sec->soundorg, sfx_crumbl); diff --git a/src/p_map.c b/src/p_map.c index ecaf322d2..1aa35e9c6 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2403,19 +2403,17 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { //All things are affected by their scale. fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale); - INT32 special = 0; + const INT32 secspecial = (thing->player) ? GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) : 0; if (thing->player) { - special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1); - // If using type Section1:13, double the maxstep. if (P_PlayerTouchingSectorSpecial(thing->player, 1, 13) - || special == 13) + || secspecial == 13) maxstep <<= 1; // If using type Section1:12, no maxstep. For ledges you don't want the player to climb! (see: Egg Zeppelin & SMK port walls) else if (P_PlayerTouchingSectorSpecial(thing->player, 1, 12) - || special == 12) + || secspecial == 12) maxstep = 0; } @@ -2461,7 +2459,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (maxstep > 0 && !( thing->player && ( P_PlayerTouchingSectorSpecial(thing->player, 1, 14) - || special == 14) + || secspecial == 14) )) // Step down { // If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS diff --git a/src/p_mobj.c b/src/p_mobj.c index 76023935f..4286c23a2 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1890,13 +1890,13 @@ boolean P_CheckDeathPitCollide(mobj_t *mo) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); - INT32 special = GETSECSPECIAL(mo->subsector->sector->special, 1); + const INT32 secspecial = GETSECSPECIAL(mo->subsector->sector->special, 1); if (((mo->z <= mo->subsector->sector->floorheight && !(mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR)) || (mo->z + mo->height >= mo->subsector->sector->ceilingheight && (mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING))) - && (special == 6 || special == 7)) + && (secspecial == 6 || secspecial == 7)) return true; return false; diff --git a/src/p_spec.c b/src/p_spec.c index 2e76bb299..fda195038 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1427,14 +1427,14 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller } else if (caller) { - INT32 special = GETSECSPECIAL(caller->special, 2); + const INT32 secspecial = GETSECSPECIAL(caller->special, 2); - if (special == 6) + if (secspecial == 6) { if (!(ALL7EMERALDS(emeralds))) return false; } - else if (special == 7) // SRB2Kart: reusing for Race Lap executor + else if (secspecial == 7) // SRB2Kart: reusing for Race Lap executor { UINT8 lap; @@ -1468,7 +1468,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller // If we were not triggered by a sector type especially for the purpose, // a Linedef Executor linedef trigger is not handling sector triggers properly, return. - else if ((!special || special > 7) && (specialtype > 322)) + else if ((!secspecial || secspecial > 7) && (specialtype > 322)) { CONS_Alert(CONS_WARNING, M_GetText("Linedef executor trigger isn't handling sector triggers properly!\nspecialtype = %d, if you are not a dev, report this warning instance\nalong with the wad that caused it!\n"), From 9bde946c5594de7eedad1b96e72be828dd7a0613 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Dec 2024 01:56:58 +0100 Subject: [PATCH 018/418] add tweakmap support https://git.do.srb2.org/KartKrew/RingRacers/-/commit/7fb44bdb0239a8012be73cb9ee384a9fdca9addb --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index cf9c6df0e..58fd66208 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2834,7 +2834,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) curmapvirt = vres_GetMap(lastloadedmaplumpnum); R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, - (encoremode ? W_CheckNumForName(va("%sE", maplumpname)) : LUMPERROR)); + W_CheckNumForName(va("%s%c", maplumpname, (encoremode ? 'E' : 'T')))); CON_SetupBackColormap(); // SRB2 determines the sky texture to be used depending on the map header. From 8776b36bb01edaa5a1d0775c6c595ca2fbba3247 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Dec 2024 00:01:42 +0100 Subject: [PATCH 019/418] super smol optimizations --- src/hardware/hw_main.c | 57 +++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e24ff8ef7..1e863109d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2509,16 +2509,16 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, { float height; //constant y for all points on the convex flat polygon FOutVector *v3d; - INT32 i; + INT32 i; float flatxref,flatyref; - float fflatsize; - INT32 flatflag; - size_t len; - float scrollx = 0.0f, scrolly = 0.0f; - angle_t angle = 0; + float fflatsize; + INT32 flatflag; + size_t len; + float scrollx = 0.0f, scrolly = 0.0f; + angle_t angle = 0; FSurfaceInfo Surf; - fixed_t tempxsow, tempytow; - size_t nrPlaneVerts; + fixed_t tempxsow, tempytow; + size_t nrPlaneVerts; static FOutVector *planeVerts = NULL; static UINT16 numAllocedPlaneVerts = 0; @@ -2527,8 +2527,6 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, nrPlaneVerts = polysector->numVertices; - height = FIXED_TO_FLOAT(fixedheight); - if (nrPlaneVerts < 3) //not even a triangle ? return; @@ -2546,6 +2544,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts); } + height = FIXED_TO_FLOAT(fixedheight); + len = W_LumpLength(lumpnum); switch (len) @@ -2743,7 +2743,6 @@ static void HWR_AddPolyObjectPlanes(void) } } - // // HWR_DoCulling // Hardware version of R_DoCulling @@ -2756,6 +2755,7 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v return false; cullplane = FIXED_TO_FLOAT(cullheight->frontsector->floorheight); + if (cullheight->flags & ML_NOCLIMB) // Group culling { if (!viewcullheight) @@ -3467,6 +3467,7 @@ static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts // be mobj->z or mobj->z + mobj->height wallVerts[2].y = wallVerts[3].y = (spr->gzt - basey) * gl_viewludsin + basey; wallVerts[0].y = wallVerts[1].y = (lowy - basey) * gl_viewludsin + basey; + // translate back to be around 0 before translating back wallVerts[3].x += ((spr->gzt - basey) * gl_viewludcos) * gl_viewcos; wallVerts[2].x += ((spr->gzt - basey) * gl_viewludcos) * gl_viewcos; @@ -3853,13 +3854,14 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) sector_t *sector = spr->mobj->subsector->sector; INT32 lightlevel = 255; extracolormap_t *colormap = sector->extra_colormap; + const boolean fullbright = (spr->mobj->frame & FF_FULLBRIGHT); - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (!fullbright) lightlevel = min(sector->lightlevel, 255); HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); - HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT)); + HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !fullbright); if (!cv_translucency.value) // translucency disabled { @@ -4317,6 +4319,7 @@ static void HWR_DrawSprites(void) if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) { md2_t *md2; + if (spr->mobj->localskin) { if (spr->mobj->skinlocal) @@ -4394,20 +4397,27 @@ static void HWR_AddSprites(sector_t *sec) // -------------------------------------------------------------------------- static void HWR_AddPrecipitationSprites(void) { - fixed_t drawdist; - fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); - //const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale; - INT32 xl, xh, yl, yh, bx, by; precipmobj_t *th; + fixed_t drawdist; + + // save a little time on invisible weather + if (curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) + { + return; + } + + const fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); + //const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale; + if (current_bsp_culling_distance) drawdist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * precipscale); else drawdist = ((fixed_t)(cv_drawdist_precip.value) * precipscale); // No to infinite precipitation draw distance. - if (drawdist == 0 || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) + if (drawdist == 0) { return; } @@ -4476,11 +4486,6 @@ static void HWR_ProjectSprite(mobj_t *thing) // uncapped/interpolation interpmobjstate_t interp = {0}; - const boolean mirrored = thing->mirrored; - const boolean vflip = (thing->eflags & MFE_VERTICALFLIP); - const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); - const boolean papersprite = (thing->frame & FF_PAPERSPRITE); - if (cv_maxinterpdist.value) dist = R_QuickCamDist(thing->x, thing->y); @@ -4496,6 +4501,11 @@ static void HWR_ProjectSprite(mobj_t *thing) if (interp.spritexscale < 1 || interp.spriteyscale < 1) return; + const boolean mirrored = thing->mirrored; + const boolean vflip = (thing->eflags & MFE_VERTICALFLIP); + const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); + const boolean papersprite = (thing->frame & FF_PAPERSPRITE); + this_scale = FIXED_TO_FLOAT(interp.scale); spritexscale = FIXED_TO_FLOAT(interp.spritexscale); spriteyscale = FIXED_TO_FLOAT(interp.spriteyscale); @@ -5263,6 +5273,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl { HWR_RenderPortal(portal, rootportal, fpov, player, stencil_level); } + HWR_SetPortalState(GLPORTAL_INSIDE); // when portal walls are encountered in following bsp traversal, nothing should be drawn } else From a3b3f91f8d7b53d208ea532c409262f8ca7e1e04 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Dec 2024 01:07:49 +0100 Subject: [PATCH 020/418] 1px --- src/k_kart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index bc9c7399d..a6aa76e4d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9375,10 +9375,10 @@ skipcrap: if (K_UseColorHud() && xtra_speedo_clr3) // Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((basex - dup*30)< Date: Thu, 26 Dec 2024 15:38:43 +0100 Subject: [PATCH 021/418] oops forgor --- 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 ae811c803..44177bf08 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -548,7 +548,7 @@ consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, 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"}, {0, NULL}}; + {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}; From 378382f3ad5a34f760d1cc0234ba4d625099b6db Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 23:34:09 +0100 Subject: [PATCH 022/418] use demo freecam for spec its more versataile and lets you pass through walls and floors just like in replays --- src/d_clisrv.c | 5 ++ src/d_clisrv.h | 2 + src/g_game.c | 1 - src/m_menu.c | 15 +----- src/p_local.h | 10 ++-- src/p_mobj.c | 24 +++++++--- src/p_setup.c | 2 + src/p_tick.c | 4 +- src/p_user.c | 128 ++++++++++++++++++++++++++++++++++++++----------- src/r_main.c | 13 +++-- src/s_sound.c | 25 ++++------ 11 files changed, 155 insertions(+), 74 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4820515ca..178309b80 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -467,6 +467,11 @@ void D_ResetTiccmds(void) D_Clearticcmd(textcmds[i]->tic); } +ticcmd_t *D_LocalTiccmd(UINT8 ss) +{ + return &localcmds[ss]; +} + // ----------------------------------------------------------------- // end of extra data function // ----------------------------------------------------------------- diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 4e81621d9..94c7c6827 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -645,7 +645,9 @@ extern char motd[254], server_context[8]; extern UINT8 playernode[MAXPLAYERS]; INT32 D_NumPlayers(void); + void D_ResetTiccmds(void); +ticcmd_t *D_LocalTiccmd(UINT8 ss); tic_t GetLag(INT32 node); //UINT8 GetFreeXCmdSize(UINT8 playerid); diff --git a/src/g_game.c b/src/g_game.c index 6c45c99a4..dadcee0e2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -7854,7 +7854,6 @@ void G_StopDemo(void) demo.freecam = false; // reset democam shit too: democam.cam = NULL; - democam.soundmobj = NULL; democam.localangle = 0; democam.localaiming = 0; democam.turnheld = false; diff --git a/src/m_menu.c b/src/m_menu.c index a4121d448..cf34db301 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7712,20 +7712,7 @@ static void M_PlaybackToggleFreecam(INT32 choice) splitscreen = 0; R_ExecuteSetViewSize(); - P_InitCameraCmd(); // init camera controls - if (!demo.freecam) // toggle on - { - demo.freecam = true; - democam.cam = &camera[0]; // this is rather useful - } - else // toggle off - { - demo.freecam = false; - // reset democam vars: - democam.cam = NULL; - democam.turnheld = false; - democam.keyboardlook = false; // reset only these. localangle / aiming gets set before the cam does anything anyway - } + P_ToggleDemoCamera(); } diff --git a/src/p_local.h b/src/p_local.h index ea0bff603..63dbed216 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -81,6 +81,10 @@ typedef struct camera_s boolean chase; angle_t aiming; + // Freecam: aiming needs to be reset after switching from chasecam + boolean reset_aiming; + + // Things used by FS cameras. fixed_t viewheight; angle_t startangle; @@ -114,14 +118,14 @@ typedef struct camera_s // demo freecam or something before i commit die struct demofreecam_s { - camera_t *cam; // this is useful when the game is paused, notably - mobj_t *soundmobj; // mobj to play sound from, used in s_sound angle_t localangle; // keeps track of the cam angle for cmds angle_t localaiming; // ditto with aiming boolean turnheld; // holding turn button for gradual turn speed boolean keyboardlook; // keyboard look + + UINT8 button_a_held; // A button was held since entering from menu, so don't move camera }; extern struct demofreecam_s democam; @@ -153,7 +157,7 @@ void P_SlideCameraMove(camera_t *thiscam); void P_DemoCameraMovement(camera_t *cam); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); void P_ResetLocalCamAiming(player_t *player); -void P_InitCameraCmd(void); +void P_ToggleDemoCamera(void); boolean P_PlayerInPain(player_t *player); void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); void P_ResetPlayer(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index 03e7e9f99..d68cf9dcc 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10755,6 +10755,15 @@ void P_SpawnPlayer(INT32 playernum) P_SetScale(karmahitbox, mobj->scale); } } + + // TODO: handle splitscreen + // Spectators can switch to freecam. This should be + // disabled when they enter the race, or when the level + // changes. + if (playernum == consoleplayer && !demo.playback) + { + demo.freecam = false; + } } void P_AfterPlayerSpawn(INT32 playernum) @@ -10797,15 +10806,18 @@ void P_AfterPlayerSpawn(INT32 playernum) SV_SpawnPlayer(playernum, mobj->x, mobj->y, mobj->angle); - for (i = 0; i <= splitscreen; i++) + if (p->spectator == false) { - if (!camera[i].chase) - continue; + for (i = 0; i <= splitscreen; i++) + { + if (!camera[i].chase) + continue; - if (displayplayers[i] != playernum) - continue; + if (displayplayers[i] != playernum) + continue; - P_ResetCamera(p, &camera[i]); + P_ResetCamera(p, &camera[i]); + } } if (CheckForReverseGravity) diff --git a/src/p_setup.c b/src/p_setup.c index c0ca1d0a6..75143d6c3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2464,6 +2464,8 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) 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->chase = false; // tell camera to reset its position next tic } static void P_InitCamera(void) diff --git a/src/p_tick.c b/src/p_tick.c index 3b0cadde8..0784957f3 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -497,8 +497,8 @@ void P_Ticker(boolean run) timeinmap = (timeinmap-1) & ~3; G_PreviewRewind(leveltime); } - else if (demo.freecam && democam.cam) // special case: allow freecam to MOVE during pause! - P_DemoCameraMovement(democam.cam); + else + P_RunChaseCameras(); // special case: allow freecam to MOVE during pause! return; } diff --git a/src/p_user.c b/src/p_user.c index 3133ee49b..59b223e9a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1056,6 +1056,15 @@ boolean P_IsDisplayPlayer(const player_t *player) { UINT8 i; + // Freecam still techically has a player in + // displayplayers. But since the camera is detached, it + // would be weird if sounds were heard from that player's + // perspective. + if (demo.freecam) + { + return false; + } + for (i = 0; i <= splitscreen; i++) // DON'T skip P1 { if (player == &players[displayplayers[i]]) @@ -3129,16 +3138,9 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn -static ticcmd_t cameracmd; - struct demofreecam_s democam; // called by m_menu to reinit cam input every time it's toggled -void P_InitCameraCmd(void) -{ - memset(&cameracmd, 0, sizeof(ticcmd_t)); // initialize cmd -} - static ticcmd_t *P_CameraCmd(camera_t *cam) { INT32 laim, th, tspeed, forward, side, axis; //i @@ -3150,12 +3152,12 @@ static ticcmd_t *P_CameraCmd(camera_t *cam) INT32 player_invert; INT32 screen_invert; - ticcmd_t *cmd = &cameracmd; + ticcmd_t *cmd = D_LocalTiccmd(0); (void)cam; - if (!demo.playback) - return cmd; // empty cmd, no. + //if (!demo.playback) + //return cmd; // empty cmd, no. lang = democam.localangle; laim = democam.localaiming; @@ -3295,11 +3297,32 @@ static ticcmd_t *P_CameraCmd(camera_t *cam) return cmd; } +void P_ToggleDemoCamera(void) +{ + if (!demo.freecam) // toggle on + { + demo.freecam = true; + democam.button_a_held = 2; + camera[0].reset_aiming = true; + democam.cam = &camera[0]; // this is rather useful + } + else // toggle off + { + demo.freecam = false; + // reset democam vars: + democam.cam = NULL; + democam.turnheld = false; + democam.keyboardlook = false; // reset only these. localangle / aiming gets set before the cam does anything anyway + } +} + +#define intsign(n) \ + ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) + void P_DemoCameraMovement(camera_t *cam) { ticcmd_t *cmd; angle_t thrustangle; - mobj_t *awayviewmobj_hack; player_t *lastp; // update democam stuff with what we got here: @@ -3307,6 +3330,8 @@ void P_DemoCameraMovement(camera_t *cam) democam.localangle = cam->angle; democam.localaiming = cam->aiming; + boolean moving = false; + // first off we need to get button input cmd = P_CameraCmd(cam); @@ -3314,11 +3339,24 @@ void P_DemoCameraMovement(camera_t *cam) cam->angle = cmd->angleturn<<16; // camera movement: + if (!democam.button_a_held) + { + if (cmd->buttons & BT_ACCELERATE) + { + cam->z += 32*mapobjectscale; + moving = true; + } + else if (cmd->buttons & BT_BRAKE) + { + cam->z -= 32*mapobjectscale; + moving = true; + } + } - if (cmd->buttons & BT_ACCELERATE) - cam->z += 32*mapobjectscale; - else if (cmd->buttons & BT_BRAKE) - cam->z -= 32*mapobjectscale; + if (!(cmd->buttons & (BT_ACCELERATE | BT_DRIFT)) && democam.button_a_held) + { + democam.button_a_held--; + } // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") if (cmd->buttons & BT_ATTACK) @@ -3326,35 +3364,64 @@ void P_DemoCameraMovement(camera_t *cam) lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); cam->aiming = R_PointToAngle2(0, cam->z, R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y), lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. + + cam->reset_aiming = false; } + if (cmd->forwardmove != 0) + { + moving = true; + } + + // After switching to democam, the vertical angle of + // chasecam is inherited. This is intentional because it + // creates a smooth transition. However, moving + // forward/back will have a slope. So, as long as democam + // controls haven't been used to alter the vertical angle, + // slowly reset it to flat. + if ((cam->reset_aiming && moving) || ((cmd->buttons & BT_DRIFT) && !democam.button_a_held)) + { + INT32 aiming = cam->aiming; + INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming)); + + if (abs(smooth) < abs(aiming)) + { + cam->aiming -= smooth * intsign(aiming); + } + else + { + cam->aiming = 0; + cam->reset_aiming = false; // completely smoothed out + } + } + + G_ClipAimingPitch((INT32 *)&cam->aiming); + cam->momx = cam->momy = cam->momz = 0; if (cmd->forwardmove != 0) { - thrustangle = cam->angle >> ANGLETOFINESHIFT; cam->x += FixedMul(cmd->forwardmove*mapobjectscale, FINECOSINE(thrustangle)); cam->y += FixedMul(cmd->forwardmove*mapobjectscale, FINESINE(thrustangle)); - cam->z += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(cam->aiming)); + + if (!cam->reset_aiming) + { + cam->z += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(cam->aiming)); + } + // momentums are useless here, directly add to the coordinates // this.......... doesn't actually check for floors and walls and whatnot but the function to do that is a pure mess so fuck that. // besides freecam going inside walls sounds pretty cool on paper. } - // awayviewmobj hack; this is to prevent us from hearing sounds from the player's perspective - - awayviewmobj_hack = P_SpawnMobj(cam->x, cam->y, cam->z, MT_THOK); - awayviewmobj_hack->tics = 2; - awayviewmobj_hack->flags2 |= MF2_DONTDRAW; - - democam.soundmobj = awayviewmobj_hack; - // update subsector to avoid crashes; cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); } +#undef intsign + void P_ResetCamera(player_t *player, camera_t *thiscam) { tic_t tries = 0; @@ -3399,6 +3466,9 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->radius = 20*FRACUNIT; thiscam->height = 16*FRACUNIT; + thiscam->reset_aiming = true; + + while (!P_MoveChaseCamera(player,thiscam,true) && ++tries < 2*TICRATE); } @@ -3420,8 +3490,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall subsector_t *newsubsec; #endif - democam.soundmobj = NULL; // reset this each frame, we don't want the game crashing for stupid reasons now do we - // We probably shouldn't move the camera if there is no player or player mobj somehow if (!player || !player->mo) return true; @@ -3430,12 +3498,16 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; - if (demo.freecam) + if (demo.freecam || player->spectator) { P_DemoCameraMovement(thiscam); return true; } + if (paused || P_AutoPause()) + return true; + + if (thiscam == &camera[1]) // Camera 2 { num = 1; diff --git a/src/r_main.c b/src/r_main.c index 9541fef41..a6caf8614 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1224,9 +1224,14 @@ void R_SetupFrame(int s, boolean skybox) thiscam->reset = false; } - if (player->spectator) // no spectator chasecam - chasecam = false; // force chasecam off - else if (player->playerstate == PST_DEAD || player->exiting) + if (player->spectator) + { + // Free flying spectator uses demo freecam. This + // requires chasecam to be enabled. + chasecam = true; + } + + if (player->playerstate == PST_DEAD || player->exiting) chasecam = true; // force chasecam on if (chasecam && (thiscam && !thiscam->chase)) @@ -1255,7 +1260,7 @@ void R_SetupFrame(int s, boolean skybox) R_SetupCommonFrame(player, subsector); } - else if (!player->spectator && (thiscam && chasecam)) // use outside cam view + else if (thiscam && chasecam) // use outside cam view { viewmobj = NULL; diff --git a/src/s_sound.c b/src/s_sound.c index c770957b6..fa56ab8ad 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -491,11 +491,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) memset(&listener[i], 0, sizeof (listener[i])); listenmobj[i] = NULL; - if (i == 0 && democam.soundmobj) - { - listenmobj[i] = democam.soundmobj; - } - else if (player->awayviewtics) + if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; } @@ -504,7 +500,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) listenmobj[i] = player->mo; } - if (origin && origin == listenmobj[i]) + if (origin && origin == listenmobj[i] && !demo.freecam) { itsUs = true; } @@ -775,12 +771,6 @@ void S_UpdateSounds(void) memset(&listener[i], 0, sizeof (listener[i])); listenmobj[i] = NULL; - if (i == 0 && democam.soundmobj) - { - listenmobj[i] = democam.soundmobj; - continue; - } - if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; @@ -843,12 +833,15 @@ void S_UpdateSounds(void) { boolean itsUs = false; - for (i = splitscreen; i >= 0; i--) + if (!demo.freecam) { - if (c->origin != listenmobj[i]) - continue; + for (i = splitscreen; i >= 0; i--) + { + if (c->origin != listenmobj[i]) + continue; - itsUs = true; + itsUs = true; + } } if (itsUs == false) From 6bb72c363f159397af8ab930123bcc5354e8680c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 23:37:23 +0100 Subject: [PATCH 023/418] fix freecam not being interpolated when ingame --- src/r_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index a6caf8614..7bd9f8630 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1078,7 +1078,7 @@ R_SetupCommonFrame else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? (demo.freecam ? rendertimefrac_unpaused : rendertimefrac) : FRACUNIT, false); } static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) From 1922b32799dd3c2ff0ca61fef433bc4fa8a74248 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 23:55:19 +0100 Subject: [PATCH 024/418] add bindable freecam toggle --- src/g_game.c | 5 ++++ src/g_input.c | 1 + src/g_input.h | 1 + src/m_menu.c | 64 +++++++++++++++++++++++++++------------------------ 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index dadcee0e2..b5569fbe0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1554,6 +1554,11 @@ boolean G_Responder(event_t *ev) { K_ToggleDirector(); } + if (ev->data1 == gamecontrol[gc_freecam][0] + || ev->data1 == gamecontrol[gc_freecam][1]) + { + P_ToggleDemoCamera(); + } return true; diff --git a/src/g_input.c b/src/g_input.c index 7f2fff283..3e6e056f6 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -902,6 +902,7 @@ static const char *gamecontrolname[num_gamecontrols] = "custom2", "custom3", "director", + "freecam", }; #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) diff --git a/src/g_input.h b/src/g_input.h index 18fff51a4..76d3a50c7 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -100,6 +100,7 @@ typedef enum gc_custom2, // Lua scriptable gc_custom3, // Lua scriptable gc_director, + gc_freecam, // Toggle for freecam while ingame num_gamecontrols } gamecontrols_e; diff --git a/src/m_menu.c b/src/m_menu.c index cf34db301..57be0699d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1182,6 +1182,7 @@ static menuitem_t OP_AllControlsMenu[] = { {IT_SUBMENU|IT_STRING, NULL, "Gamepad Options...", &OP_Joystick1Def, 0}, {IT_CALL|IT_STRING, NULL, "Reset to defaults", M_ResetControls, 8}, + //{IT_SPACE, NULL, NULL, NULL, 0}, {IT_HEADER, NULL, "Gameplay Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, @@ -1194,26 +1195,33 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Aim Forward", M_ChangeControl, gc_aimforward }, {IT_CONTROL, NULL, "Aim Backward", M_ChangeControl, gc_aimbackward}, {IT_CONTROL, NULL, "Look Backward", M_ChangeControl, gc_lookback }, + {IT_HEADER, NULL, "Miscelleanous Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, {IT_CONTROL, NULL, "Chat", M_ChangeControl, gc_talkkey }, - //{IT_CONTROL, NULL, "Team Chat", M_ChangeControl, gc_teamkey }, + //{IT_CONTROL, NULL, "Team Chat", M_ChangeControl, gc_teamkey }, {IT_CONTROL, NULL, "Show Rankings", M_ChangeControl, gc_scores }, - {IT_CONTROL, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, - {IT_CONTROL, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, - {IT_CONTROL, NULL, "Toggle First-Person", M_ChangeControl, gc_camtoggle }, {IT_CONTROL, NULL, "Pause", M_ChangeControl, gc_pause }, {IT_CONTROL, NULL, "Screenshot", M_ChangeControl, gc_screenshot }, {IT_CONTROL, NULL, "Toggle GIF Recording", M_ChangeControl, gc_recordgif }, {IT_CONTROL, NULL, "Open/Close Menu (ESC)", M_ChangeControl, gc_systemmenu }, {IT_CONTROL, NULL, "Developer Console", M_ChangeControl, gc_console }, - {IT_HEADER, NULL, "Spectator Controls", NULL, 0}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, - {IT_CONTROL, NULL, "Become Spectator", M_ChangeControl, gc_spectate }, + {IT_CONTROL, NULL, "Toggle Freecam", M_ChangeControl, gc_freecam }, {IT_CONTROL, NULL, "Look Up", M_ChangeControl, gc_lookup }, {IT_CONTROL, NULL, "Look Down", M_ChangeControl, gc_lookdown }, {IT_CONTROL, NULL, "Center View", M_ChangeControl, gc_centerview }, + {IT_CONTROL, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, + {IT_CONTROL, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, + //{IT_CONTROL, NULL, "Toggle First-Person", M_ChangeControl, gc_camtoggle }, + + {IT_HEADER, NULL, "Spectator Controls", NULL, 0}, + {IT_SPACE, NULL, NULL, NULL, 0}, + {IT_CONTROL, NULL, "Become Spectator", M_ChangeControl, gc_spectate }, {IT_CONTROL, NULL, "Toggle Director", M_ChangeControl, gc_director }, + {IT_HEADER, NULL, "Custom Lua Actions", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, {IT_CONTROL, NULL, "Custom Action 1", M_ChangeControl, gc_custom1 }, @@ -12082,12 +12090,11 @@ static void M_Setup1PControlsMenu(INT32 choice) // Unhide P1-only controls OP_AllControlsMenu[15].status = IT_CONTROL; // Chat OP_AllControlsMenu[16].status = IT_CONTROL; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_CONTROL; // Pause - OP_AllControlsMenu[21].status = IT_CONTROL; // Screenshot - OP_AllControlsMenu[22].status = IT_CONTROL; // GIF - OP_AllControlsMenu[23].status = IT_CONTROL; // System Menu - OP_AllControlsMenu[24].status = IT_CONTROL; // Console + OP_AllControlsMenu[17].status = IT_CONTROL; // Pause + OP_AllControlsMenu[18].status = IT_CONTROL; // Screenshot + OP_AllControlsMenu[19].status = IT_CONTROL; // GIF + OP_AllControlsMenu[20].status = IT_CONTROL; // System Menu + OP_AllControlsMenu[21].status = IT_CONTROL; // Console M_SetupNextMenu(&OP_AllControlsDef); } @@ -12105,12 +12112,11 @@ static void M_Setup2PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause - OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot - OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF - OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu - OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Pause + OP_AllControlsMenu[18].status = IT_GRAYEDOUT2; // Screenshot + OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF + OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu + OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console M_SetupNextMenu(&OP_AllControlsDef); } @@ -12128,12 +12134,11 @@ static void M_Setup3PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause - OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot - OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF - OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu - OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Pause + OP_AllControlsMenu[18].status = IT_GRAYEDOUT2; // Screenshot + OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF + OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu + OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console M_SetupNextMenu(&OP_AllControlsDef); } @@ -12151,12 +12156,11 @@ static void M_Setup4PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause - OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot - OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF - OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu - OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Pause + OP_AllControlsMenu[18].status = IT_GRAYEDOUT2; // Screenshot + OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF + OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu + OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console M_SetupNextMenu(&OP_AllControlsDef); } From 45d33b951ccec52b038fa89e1dd083e7186c01db Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 00:04:49 +0100 Subject: [PATCH 025/418] add alternative cam float and sink buttons --- src/g_input.c | 2 ++ src/g_input.h | 2 ++ src/m_menu.c | 2 ++ src/p_user.c | 4 ++-- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 3e6e056f6..c948ed751 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -903,6 +903,8 @@ static const char *gamecontrolname[num_gamecontrols] = "custom3", "director", "freecam", + "camfloat", + "camsink", }; #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) diff --git a/src/g_input.h b/src/g_input.h index 76d3a50c7..1dbbb937f 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -101,6 +101,8 @@ typedef enum gc_custom3, // Lua scriptable gc_director, gc_freecam, // Toggle for freecam while ingame + gc_camfloat, // alternative button for raising cam + gc_camsink, // alternative button for sinking num_gamecontrols } gamecontrols_e; diff --git a/src/m_menu.c b/src/m_menu.c index 57be0699d..ac6fc90db 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1213,6 +1213,8 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Look Up", M_ChangeControl, gc_lookup }, {IT_CONTROL, NULL, "Look Down", M_ChangeControl, gc_lookdown }, {IT_CONTROL, NULL, "Center View", M_ChangeControl, gc_centerview }, + {IT_CONTROL, NULL, "Float", M_ChangeControl, gc_camfloat }, + {IT_CONTROL, NULL, "Sink", M_ChangeControl, gc_camsink }, {IT_CONTROL, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, {IT_CONTROL, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, //{IT_CONTROL, NULL, "Toggle First-Person", M_ChangeControl, gc_camtoggle }, diff --git a/src/p_user.c b/src/p_user.c index 59b223e9a..54f67eec8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3341,12 +3341,12 @@ void P_DemoCameraMovement(camera_t *cam) // camera movement: if (!democam.button_a_held) { - if (cmd->buttons & BT_ACCELERATE) + if (cmd->buttons & BT_ACCELERATE || PLAYER1INPUTDOWN(gc_camfloat)) { cam->z += 32*mapobjectscale; moving = true; } - else if (cmd->buttons & BT_BRAKE) + else if (cmd->buttons & BT_BRAKE || PLAYER1INPUTDOWN(gc_camsink)) { cam->z -= 32*mapobjectscale; moving = true; From 3381f6af3a4b3a99dca672bce8b9eb3f700485f6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 00:21:41 +0100 Subject: [PATCH 026/418] set default controls for float and sink ig --- src/g_input.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/g_input.c b/src/g_input.c index c948ed751..606f20770 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1142,6 +1142,12 @@ void G_Controldefault(UINT8 player) //gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up + + gamecontrol[gc_camfloat ][1] = 'a'; + gamecontrol[gc_camsink ][1] = 'd'; + + gamecontrol[gc_camfloat ][1] = KEY_JOY1+0; // A + gamecontrol[gc_camsink ][1] = KEY_JOY1+1; // B } if (player == 0 || player == 2) From 332f7db32f79c5b6d482b5d02dca9edd170e61b5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 01:38:08 +0100 Subject: [PATCH 027/418] make freecam work in splitscreen banish cameracmd shit --- src/d_netcmd.c | 2 +- src/g_game.c | 49 +++++---- src/k_kart.c | 25 ++--- src/m_menu.c | 6 +- src/p_local.h | 24 ++--- src/p_mobj.c | 7 +- src/p_user.c | 279 ++++++++++++------------------------------------- src/r_fps.h | 4 + src/r_main.c | 3 +- src/s_sound.c | 16 +-- src/st_stuff.c | 4 +- 11 files changed, 135 insertions(+), 284 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e49f6c17a..5e1927ff0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2301,7 +2301,7 @@ static void Command_View_f(void) return; } - if (demo.freecam) + if (camera[viewnum-1].freecam) return; displayplayerp = &displayplayers[viewnum-1]; diff --git a/src/g_game.c b/src/g_game.c index b5569fbe0..1be80c944 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1402,7 +1402,7 @@ boolean G_Responder(event_t *ev) } } - if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback && !demo.freecam) + if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback) { if (ev->data1 == gamecontrolbis[gc_viewpoint][0] || ev->data1 == gamecontrolbis[gc_viewpoint][1]) { @@ -1554,10 +1554,22 @@ boolean G_Responder(event_t *ev) { K_ToggleDirector(); } - if (ev->data1 == gamecontrol[gc_freecam][0] - || ev->data1 == gamecontrol[gc_freecam][1]) + + if (ev->data1 == gamecontrol[gc_freecam][0] || ev->data1 == gamecontrol[gc_freecam][1]) { - P_ToggleDemoCamera(); + P_ToggleDemoCamera(0); + } + else if (ev->data1 == gamecontrolbis[gc_freecam][0] || ev->data1 == gamecontrolbis[gc_freecam][1]) + { + P_ToggleDemoCamera(1); + } + else if (ev->data1 == gamecontrol3[gc_freecam][0] || ev->data1 == gamecontrol3[gc_freecam][1]) + { + P_ToggleDemoCamera(2); + } + else if (ev->data1 == gamecontrol4[gc_freecam][0] || ev->data1 == gamecontrol4[gc_freecam][1]) + { + P_ToggleDemoCamera(3); } return true; @@ -1740,13 +1752,6 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) viewnum = playersviewable; splitscreen = viewnum-1; - /* Prepare extra views for G_FindView to pass. */ - for (viewd = splits+1; viewd < viewnum; ++viewd) - { - displayplayerp = (&displayplayers[viewd-1]); - (*displayplayerp) = INT32_MAX; - } - R_ExecuteSetViewSize(); } @@ -5769,9 +5774,6 @@ void G_ConfirmRewind(tic_t rewindtime) COM_BufInsertText("renderview on\n"); - if (demo.freecam) - return; // don't touch from there - splitscreen = oldss; displayplayers[0] = olddp1; displayplayers[1] = olddp2; @@ -7154,15 +7156,14 @@ void G_DoPlayDemo(char *defdemoname) //LUA_HookInt(gamemap, HOOK(MapChange)); - displayplayers[0] = consoleplayer = 0; + consoleplayer = 0; memset(playeringame,0,sizeof(playeringame)); + memset(displayplayers,0,sizeof(displayplayers)); + memset(camera,0,sizeof(camera)); // reset freecam // Load players that were in-game when the map started p = READUINT8(demo_p); - for (i = 1; i < MAXSPLITSCREENPLAYERS; i++) - displayplayers[i] = INT32_MAX; - while (p != 0xFF) { spectator = false; @@ -7856,13 +7857,11 @@ void G_StopDemo(void) demo.timing = false; singletics = false; - demo.freecam = false; - // reset democam shit too: - democam.cam = NULL; - democam.localangle = 0; - democam.localaiming = 0; - democam.turnheld = false; - democam.keyboardlook = false; + UINT8 i; + for (i = 0; i < MAXSPLITSCREENPLAYERS; ++i) + { + camera[i].freecam = false; + } CV_SetValue(&cv_playbackspeed, 1); demo.rewinding = false; diff --git a/src/k_kart.c b/src/k_kart.c index a6aa76e4d..7a9f43f55 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1233,7 +1233,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) dontforcespb = true; // This makes the roulette produce the random noises. - if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player) && !demo.freecam) + if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player)) { #define PLAYROULETTESND S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8)) for (i = 0; i <= splitscreen; i++) @@ -1267,7 +1267,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) //player->kartstuff[k_itemblinkmode] = 1; player->kartstuff[k_itemroulette] = 0; player->kartstuff[k_roulettetype] = 0; - if (P_IsDisplayPlayer(player) && !demo.freecam) + if (P_IsDisplayPlayer(player)) S_StartSound(NULL, sfx_itrole); return; } @@ -1280,7 +1280,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) player->kartstuff[k_itemblinkmode] = 2; player->kartstuff[k_itemroulette] = 0; player->kartstuff[k_roulettetype] = 0; - if (P_IsDisplayPlayer(player) && !demo.freecam) + if (P_IsDisplayPlayer(player)) S_StartSound(NULL, sfx_dbgsal); return; } @@ -1312,7 +1312,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) player->kartstuff[k_itemamount] = 1; } - if (P_IsDisplayPlayer(player) && !demo.freecam) + if (P_IsDisplayPlayer(player)) S_StartSound(NULL, ((player->kartstuff[k_roulettetype] == 1) ? sfx_itrolk : (mashed ? sfx_itrolm : sfx_itrolf))); player->kartstuff[k_itemblink] = TICRATE; @@ -9311,7 +9311,7 @@ static void K_drawDriftGauge(void) 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 }; - if (demo.playback && demo.freecam) + if (demo.playback && camera[R_GetViewNumber()].freecam) return; if (P_MobjWasRemoved(stplyr->mo) || (!splitscreen && !camera->chase)) @@ -10419,22 +10419,19 @@ void K_drawKartHUD(void) { boolean isfreeplay = false; boolean battlefullscreen = false; - boolean freecam = demo.freecam; //disable some hud elements w/ freecam - UINT8 i; + UINT8 viewnum = R_GetViewNumber(); + boolean freecam = camera[viewnum].freecam; //disable some hud elements w/ freecam // Define the X and Y for each drawn object // This is handled by console/menu values K_initKartHUD(); // Draw that fun first person HUD! Drawn ASAP so it looks more "real". - for (i = 0; i <= splitscreen; i++) - { - if (stplyr == &players[displayplayers[i]] && !camera[i].chase && !freecam) - K_drawKartFirstPerson(); - } + if (!camera[viewnum].chase && !freecam) + K_drawKartFirstPerson(); // Draw full screen stuff that turns off the rest of the HUD - if (mapreset && stplyr == &players[displayplayers[0]]) + if (mapreset && R_GetViewNumber() == 0) { K_drawChallengerScreen(); return; @@ -10527,7 +10524,7 @@ void K_drawKartHUD(void) } } - if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode + if (!stplyr->spectator && !freecam) // Bottom of the screen elements, don't need in spectate mode { if (!(splitscreen || demo.title)) { diff --git a/src/m_menu.c b/src/m_menu.c index ac6fc90db..0bfacba82 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7722,7 +7722,11 @@ static void M_PlaybackToggleFreecam(INT32 choice) splitscreen = 0; R_ExecuteSetViewSize(); - P_ToggleDemoCamera(); + UINT8 i; + for (i = 0; i <= splitscreen; ++i) + { + P_ToggleDemoCamera(i); + } } diff --git a/src/p_local.h b/src/p_local.h index 63dbed216..368779983 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -79,12 +79,16 @@ void P_UnlinkThinker(thinker_t *thinker); typedef struct camera_s { boolean chase; + boolean freecam; + angle_t aiming; + // Freecam: A button was held since entering from menu, so don't move camera + UINT8 button_a_held; + // Freecam: aiming needs to be reset after switching from chasecam boolean reset_aiming; - // Things used by FS cameras. fixed_t viewheight; angle_t startangle; @@ -116,20 +120,6 @@ typedef struct camera_s fixed_t pan; } camera_t; -// demo freecam or something before i commit die -struct demofreecam_s { - camera_t *cam; // this is useful when the game is paused, notably - - angle_t localangle; // keeps track of the cam angle for cmds - angle_t localaiming; // ditto with aiming - boolean turnheld; // holding turn button for gradual turn speed - boolean keyboardlook; // keyboard look - - UINT8 button_a_held; // A button was held since entering from menu, so don't move camera -}; - -extern struct demofreecam_s democam; - extern camera_t camera[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS]; @@ -154,10 +144,10 @@ void P_AddPlayerScore(player_t *player, UINT32 amount); void P_ResetCamera(player_t *player, camera_t *thiscam); boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam); void P_SlideCameraMove(camera_t *thiscam); -void P_DemoCameraMovement(camera_t *cam); +void P_DemoCameraMovement(camera_t *cam, UINT8 num); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); void P_ResetLocalCamAiming(player_t *player); -void P_ToggleDemoCamera(void); +void P_ToggleDemoCamera(UINT8 viewnum); boolean P_PlayerInPain(player_t *player); void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); void P_ResetPlayer(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index d68cf9dcc..bdf6b1a93 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10760,9 +10760,12 @@ void P_SpawnPlayer(INT32 playernum) // Spectators can switch to freecam. This should be // disabled when they enter the race, or when the level // changes. - if (playernum == consoleplayer && !demo.playback) + if (!demo.playback) { - demo.freecam = false; + if (!p->spectator) + { + camera[playernum].freecam = false; + } } } diff --git a/src/p_user.c b/src/p_user.c index 54f67eec8..b562ca33c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1056,17 +1056,17 @@ boolean P_IsDisplayPlayer(const player_t *player) { UINT8 i; - // Freecam still techically has a player in - // displayplayers. But since the camera is detached, it - // would be weird if sounds were heard from that player's - // perspective. - if (demo.freecam) - { - return false; - } - for (i = 0; i <= splitscreen; i++) // DON'T skip P1 { + if (camera[i].freecam) + { + // Freecam still techically has a player in + // displayplayers. But since the camera is + // detached, it would be weird if sounds were + // heard from that player's perspective. + continue; + } + if (player == &players[displayplayers[i]]) return true; } @@ -3130,232 +3130,69 @@ fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42}; #define MAXCAMERADIST 140*FRACUNIT // Max distance the camera can be in front of the player (2D mode) -// Heavily simplified version of G_BuildTicCmd that only takes the local first player's control input and converts it to readable ticcmd_t -// we then throw that ticcmd garbage in the camera and make it move - -// redefine this -static fixed_t forwardmove[2] = {25<>16, 50<>16}; -static fixed_t sidemove[2] = {2<>16, 4<>16}; -static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn - -struct demofreecam_s democam; - -// called by m_menu to reinit cam input every time it's toggled -static ticcmd_t *P_CameraCmd(camera_t *cam) +void P_ToggleDemoCamera(UINT8 viewnum) { - INT32 laim, th, tspeed, forward, side, axis; //i - const INT32 speed = 1; - // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming; - boolean invertmouse, lookaxis, usejoystick, kbl; - angle_t lang; - INT32 player_invert; - INT32 screen_invert; + camera_t *cam = &camera[viewnum]; - ticcmd_t *cmd = D_LocalTiccmd(0); - - (void)cam; - - //if (!demo.playback) - //return cmd; // empty cmd, no. - - lang = democam.localangle; - laim = democam.localaiming; - th = democam.turnheld; - kbl = democam.keyboardlook; - - G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver - - cmd->angleturn = (INT16)(lang >> 16); - cmd->aiming = G_ClipAimingPitch(&laim); - - mouseaiming = true; - invertmouse = cv_invertmouse.value; - lookaxis = cv_lookaxis[0].value; - - usejoystick = true; - turnright = InputDown(gc_turnright, 1); - turnleft = InputDown(gc_turnleft, 1); - - axis = JoyAxis(AXISTURN, 1); - - if (encoremode) + if (!cam->freecam) // toggle on { - turnright ^= turnleft; // swap these using three XORs - turnleft ^= turnright; - turnright ^= turnleft; - axis = -axis; - } - - if (axis != 0) - { - turnright = turnright || (axis > 0); - turnleft = turnleft || (axis < 0); - } - forward = side = 0; - - // use two stage accelerative turning - // on the keyboard and joystick - if (turnleft || turnright) - th += 1; - else - th = 0; - - if (th < SLOWTURNTICS) - tspeed = 2; // slow turn - else - tspeed = speed; - - // let movement keys cancel each other out - if (turnright && !(turnleft)) - { - cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed])); - side += sidemove[1]; - } - else if (turnleft && !(turnright)) - { - cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed])); - side -= sidemove[1]; - } - - cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); - - axis = JoyAxis(AXISMOVE, 1); - if (InputDown(gc_accelerate, 1) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ACCELERATE; - axis = JoyAxis(AXISBRAKE, 1); - if (InputDown(gc_brake, 1) || (usejoystick && axis > 0)) - cmd->buttons |= BT_BRAKE; - axis = JoyAxis(AXISAIM, 1); - if (InputDown(gc_aimforward, 1) || (usejoystick && axis < 0)) - forward += forwardmove[1]; - if (InputDown(gc_aimbackward, 1) || (usejoystick && axis > 0)) - forward -= forwardmove[1]; - - // fire with any button/key - axis = JoyAxis(AXISFIRE, 1); - if (InputDown(gc_fire, 1) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ATTACK; - - // spectator aiming shit, ahhhh... - player_invert = invertmouse ? -1 : 1; - screen_invert = 1; // nope - - // mouse look stuff (mouse look is not the same as mouse aim) - kbl = false; - - // looking up/down - laim += (mlooky<<19)*player_invert*screen_invert; - - axis = JoyAxis(AXISLOOK, 1); - - // spring back if not using keyboard neither mouselookin' - if (!kbl && !lookaxis && !mouseaiming) - laim = 0; - - if (InputDown(gc_lookup, 1) || (axis < 0)) - { - laim += KB_LOOKSPEED * screen_invert; - kbl = true; - } - else if (InputDown(gc_lookdown, 1) || (axis > 0)) - { - laim -= KB_LOOKSPEED * screen_invert; - kbl = true; - } - - if (InputDown(gc_centerview, 1)) // No need to put a spectator limit on this one though :V - laim = 0; - - cmd->aiming = G_ClipAimingPitch(&laim); - - mousex = mousey = mlooky = 0; - - if (forward > MAXPLMOVE) - forward = MAXPLMOVE; - else if (forward < -MAXPLMOVE) - forward = -MAXPLMOVE; - - if (side > MAXPLMOVE) - side = MAXPLMOVE; - else if (side < -MAXPLMOVE) - side = -MAXPLMOVE; - - if (forward || side) - { - cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); - cmd->sidemove = (SINT8)(cmd->sidemove + side); - } - - lang += (cmd->angleturn<<16); - - democam.localangle = lang; - democam.localaiming = laim; - democam.turnheld = th; - democam.keyboardlook = kbl; - - return cmd; -} - -void P_ToggleDemoCamera(void) -{ - if (!demo.freecam) // toggle on - { - demo.freecam = true; - democam.button_a_held = 2; - camera[0].reset_aiming = true; - democam.cam = &camera[0]; // this is rather useful + cam->freecam = true; + cam->button_a_held = 2; + cam->reset_aiming = true; } else // toggle off { - demo.freecam = false; - // reset democam vars: - democam.cam = NULL; - democam.turnheld = false; - democam.keyboardlook = false; // reset only these. localangle / aiming gets set before the cam does anything anyway + cam->freecam = false; } } #define intsign(n) \ ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) -void P_DemoCameraMovement(camera_t *cam) +void P_DemoCameraMovement(camera_t *cam, UINT8 num) { ticcmd_t *cmd; angle_t thrustangle; player_t *lastp; - - // update democam stuff with what we got here: - democam.cam = cam; - democam.localangle = cam->angle; - democam.localaiming = cam->aiming; + angle_t turning; boolean moving = false; // first off we need to get button input - cmd = P_CameraCmd(cam); + cmd = D_LocalTiccmd(num); - cam->aiming = cmd->aiming<angle = cmd->angleturn<<16; + if (cmd->aiming != 0) + { + cam->aiming = cmd->aiming << FRACBITS; + + cam->reset_aiming = false; + } + + turning = cmd->angleturn << 16; + if (encoremode) + { + turning = -turning; + } + cam->angle = turning; // camera movement: - if (!democam.button_a_held) + if (!cam->button_a_held) { - if (cmd->buttons & BT_ACCELERATE || PLAYER1INPUTDOWN(gc_camfloat)) + if (InputDown(gc_camfloat, num+1)) { cam->z += 32*mapobjectscale; moving = true; } - else if (cmd->buttons & BT_BRAKE || PLAYER1INPUTDOWN(gc_camsink)) + else if (InputDown(gc_camsink, num+1)) { cam->z -= 32*mapobjectscale; moving = true; } } - if (!(cmd->buttons & (BT_ACCELERATE | BT_DRIFT)) && democam.button_a_held) + if (!(InputDown(gc_camfloat, num+1) || InputDown(gc_camsink, num+1)) && cam->button_a_held) { - democam.button_a_held--; + cam->button_a_held--; } // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") @@ -3379,7 +3216,7 @@ void P_DemoCameraMovement(camera_t *cam) // forward/back will have a slope. So, as long as democam // controls haven't been used to alter the vertical angle, // slowly reset it to flat. - if ((cam->reset_aiming && moving) || ((cmd->buttons & BT_DRIFT) && !democam.button_a_held)) + if ((cam->reset_aiming && moving) || ((InputDown(gc_camsink, num+1)) && !cam->button_a_held)) { INT32 aiming = cam->aiming; INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming)); @@ -3395,7 +3232,23 @@ void P_DemoCameraMovement(camera_t *cam) } } - G_ClipAimingPitch((INT32 *)&cam->aiming); + if (rendermode == render_soft +#ifdef HWRENDER + || (rendermode == render_opengl && (cv_glshearing.value == 1)) +#endif + ) + { + // Extra restriction on this so it's not possible to + // distort the view too much. + if ((INT32)cam->aiming > ANGLE_45) + cam->aiming = ANGLE_45; + else if ((INT32)cam->aiming < -ANGLE_45) + cam->aiming = -ANGLE_45; + } + else + { + G_ClipAimingPitch((INT32 *)&cam->aiming); + } cam->momx = cam->momy = cam->momz = 0; if (cmd->forwardmove != 0) @@ -3427,7 +3280,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) tic_t tries = 0; fixed_t x, y, z; - if (demo.freecam) + if (thiscam->freecam) return; // do not reset the camera there. if (!player->mo) @@ -3468,7 +3321,6 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->reset_aiming = true; - while (!P_MoveChaseCamera(player,thiscam,true) && ++tries < 2*TICRATE); } @@ -3498,16 +3350,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; - if (demo.freecam || player->spectator) - { - P_DemoCameraMovement(thiscam); - return true; - } - - if (paused || P_AutoPause()) - return true; - - if (thiscam == &camera[1]) // Camera 2 { num = 1; @@ -3525,6 +3367,15 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall num = 0; } + if (thiscam->freecam || player->spectator) + { + P_DemoCameraMovement(thiscam, num); + return true; + } + + if (paused || P_AutoPause()) + return true; + if (player == &players[consoleplayer]) { plyrnum = 0; diff --git a/src/r_fps.h b/src/r_fps.h index 5ac6cfe90..563989fa6 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -37,6 +37,10 @@ enum viewcontext_e VIEWCONTEXT_SKY4 }; +extern enum viewcontext_e viewcontext; + +#define R_GetViewNumber() ((viewcontext - VIEWCONTEXT_PLAYER1) & 3) + typedef struct { fixed_t x; fixed_t y; diff --git a/src/r_main.c b/src/r_main.c index 7bd9f8630..79950a458 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -841,6 +841,7 @@ static inline int intsign(int n) { angle_t R_ViewRollAngle(const player_t *player) { angle_t roll = 0; + const UINT8 viewnum = R_GetViewNumber(); if (gamestate != GS_LEVEL) { @@ -859,7 +860,7 @@ angle_t R_ViewRollAngle(const player_t *player) if (cv_tilting.value) { - if (!player->spectator && !demo.freecam) + if (!player->spectator && !camera[viewnum].freecam) roll += player->tilt; if (cv_actionmovie.value) diff --git a/src/s_sound.c b/src/s_sound.c index fa56ab8ad..9a7dd5542 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -500,7 +500,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) listenmobj[i] = player->mo; } - if (origin && origin == listenmobj[i] && !demo.freecam) + if (origin && origin == listenmobj[i] && !camera[i].freecam) { itsUs = true; } @@ -833,15 +833,15 @@ void S_UpdateSounds(void) { boolean itsUs = false; - if (!demo.freecam) + for (i = splitscreen; i >= 0; i--) { - for (i = splitscreen; i >= 0; i--) - { - if (c->origin != listenmobj[i]) - continue; + if (camera[i].freecam) + continue; - itsUs = true; - } + if (c->origin != listenmobj[i]) + continue; + + itsUs = true; } if (itsUs == false) diff --git a/src/st_stuff.c b/src/st_stuff.c index 30b8b5cf7..398dc7dbe 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -657,6 +657,8 @@ static void ST_drawLevelTitle(void) // static void ST_overlayDrawer(void) { + const UINT8 viewnum = R_GetViewNumber(); + //hu_showscores = auto hide score/time/rings when tab rankings are shown if (!(hu_showscores && (netgame || multiplayer))) { @@ -665,7 +667,7 @@ static void ST_overlayDrawer(void) if (!hu_showscores) // hide the following if TAB is held { - if (cv_showdirectorhud.value && !splitscreen && ((demo.playback && !demo.freecam && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !K_DirectorIsPlayerAlone()) + if (cv_showdirectorhud.value && !splitscreen && ((demo.playback && !camera[viewnum].freecam && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !K_DirectorIsPlayerAlone()) { char directortext[20] = {0}; From 2c769f804341960feff6663d37758e9da2de44ec Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 01:41:49 +0100 Subject: [PATCH 028/418] changable freecam speed --- src/p_local.h | 2 ++ src/p_user.c | 17 ++++++++++++----- src/r_main.c | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 368779983..b45cebdc2 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -128,6 +128,8 @@ extern consvar_t cv_cam_speed[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_rotate[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_freecam_speed; + extern consvar_t cv_tilting; extern consvar_t cv_quaketilt; extern consvar_t cv_tiltsmoothing; diff --git a/src/p_user.c b/src/p_user.c index b562ca33c..9484197ef 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3117,6 +3117,9 @@ consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS] = { {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; +static CV_PossibleValue_t freecam_speed_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; +consvar_t cv_freecam_speed = {"freecam_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_tilting = {"tilting", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_quaketilt = {"quaketilt", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_tiltsmoothing = {"tiltsmoothing", "32", CV_SAVE, CV_Natural, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -3178,14 +3181,16 @@ void P_DemoCameraMovement(camera_t *cam, UINT8 num) // camera movement: if (!cam->button_a_held) { + fixed_t spd = 32*mapobjectscale*cv_freecam_speed.value; + if (InputDown(gc_camfloat, num+1)) { - cam->z += 32*mapobjectscale; + cam->z += spd; moving = true; } else if (InputDown(gc_camsink, num+1)) { - cam->z -= 32*mapobjectscale; + cam->z -= spd; moving = true; } } @@ -3253,14 +3258,16 @@ void P_DemoCameraMovement(camera_t *cam, UINT8 num) cam->momx = cam->momy = cam->momz = 0; if (cmd->forwardmove != 0) { + fixed_t spd = cmd->forwardmove*mapobjectscale*cv_freecam_speed.value; + thrustangle = cam->angle >> ANGLETOFINESHIFT; - cam->x += FixedMul(cmd->forwardmove*mapobjectscale, FINECOSINE(thrustangle)); - cam->y += FixedMul(cmd->forwardmove*mapobjectscale, FINESINE(thrustangle)); + cam->x += FixedMul(spd, FINECOSINE(thrustangle)); + cam->y += FixedMul(spd, FINESINE(thrustangle)); if (!cam->reset_aiming) { - cam->z += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(cam->aiming)); + cam->z += FixedMul(spd, AIMINGTOSLOPE(cam->aiming)); } // momentums are useless here, directly add to the coordinates diff --git a/src/r_main.c b/src/r_main.c index 79950a458..b863d8141 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1537,6 +1537,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam_rotspeed[i]); } + CV_RegisterVar(&cv_freecam_speed); + CV_RegisterVar(&cv_tilting); CV_RegisterVar(&cv_quaketilt); CV_RegisterVar(&cv_tiltsmoothing); From 2639f94dfff0301a53e4a3512babca15dfd24872 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 03:44:21 +0100 Subject: [PATCH 029/418] fix freecam not being steerable when not in spec ugh this is godawful its literally almost a complete copy of --- src/g_game.c | 4 ++ src/p_local.h | 7 +- src/p_user.c | 191 ++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 187 insertions(+), 15 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 1be80c944..79e94a24b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -886,6 +886,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) thiscam = (player->bot == 2 ? &camera[0] : &camera[forplayer]); else thiscam = &camera[forplayer]; + lang = localangle[forplayer]; laim = localaiming[forplayer]; th = turnheld[forplayer]; @@ -7861,6 +7862,9 @@ void G_StopDemo(void) for (i = 0; i < MAXSPLITSCREENPLAYERS; ++i) { camera[i].freecam = false; + camera[i].localangle = 0; + camera[i].localaiming = 0; + camera[i].keyboardlook = false; } CV_SetValue(&cv_playbackspeed, 1); diff --git a/src/p_local.h b/src/p_local.h index b45cebdc2..13219c429 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -81,6 +81,11 @@ typedef struct camera_s boolean chase; boolean freecam; + angle_t localangle; + INT32 localaiming; + + boolean keyboardlook; // keyboard look + angle_t aiming; // Freecam: A button was held since entering from menu, so don't move camera @@ -146,7 +151,7 @@ void P_AddPlayerScore(player_t *player, UINT32 amount); void P_ResetCamera(player_t *player, camera_t *thiscam); boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam); void P_SlideCameraMove(camera_t *thiscam); -void P_DemoCameraMovement(camera_t *cam, UINT8 num); +//void P_DemoCameraMovement(camera_t *cam, UINT8 num); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); void P_ResetLocalCamAiming(player_t *player); void P_ToggleDemoCamera(UINT8 viewnum); diff --git a/src/p_user.c b/src/p_user.c index 9484197ef..8b0f15cf3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3133,10 +3133,18 @@ fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42}; #define MAXCAMERADIST 140*FRACUNIT // Max distance the camera can be in front of the player (2D mode) +static fixed_t forwardmove[2] = {25<>16, 50<>16}; +static fixed_t sidemove[2] = {2<>16, 4<>16}; +static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn + +static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS]; + void P_ToggleDemoCamera(UINT8 viewnum) { camera_t *cam = &camera[viewnum]; + memset(&cameracmd[viewnum], 0, sizeof(ticcmd_t)); + if (!cam->freecam) // toggle on { cam->freecam = true; @@ -3149,20 +3157,180 @@ void P_ToggleDemoCamera(UINT8 viewnum) } } +static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) +{ + INT32 laim, forward, side, axis; //i + // these ones used for multiple conditions + boolean turnleft, turnright; + boolean usejoystick, kbl; + angle_t lang; + INT32 screen_invert; + const UINT8 forplayer = num+1; + + ticcmd_t *cmd = &cameracmd[num]; + + lang = cam->localangle; + laim = cam->localaiming; + kbl = cam->keyboardlook; + + if (!cam->freecam) + return cmd; // empty cmd, no. + + switch (num) + { + case 1: + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); + break; + case 2: + G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + break; + case 3: + G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + break; + case 0: + default: + G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + break; + } + + cmd->angleturn = (INT16)(lang >> 16); + cmd->aiming = G_ClipAimingPitch(&laim); + + const boolean lookaxis = cv_lookaxis[num].value; + const boolean analogjoystickmove = cv_usejoystick[num].value && !Joystick[num].bGamepadStyle; + const boolean gamepadjoystickmove = cv_usejoystick[num].value && Joystick[num].bGamepadStyle; + + usejoystick = (analogjoystickmove || gamepadjoystickmove); + + turnright = InputDown(gc_turnright, forplayer); + turnleft = InputDown(gc_turnleft, forplayer); + + axis = JoyAxis(AXISTURN, forplayer); + + if (encoremode) + { + turnright ^= turnleft; // swap these using three XORs + turnleft ^= turnright; + turnright ^= turnleft; + axis = -axis; + } + + if (gamepadjoystickmove && axis != 0) + { + turnright = turnright || (axis > 0); + turnleft = turnleft || (axis < 0); + } + forward = side = 0; + + // let movement keys cancel each other out + if (turnright && !(turnleft)) + { + cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); + side += sidemove[1]; + } + else if (turnleft && !(turnright)) + { + cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); + side -= sidemove[1]; + } + + if (analogjoystickmove && axis != 0) + { + // JOYAXISRANGE should be 1023 (divide by 1024) + cmd->angleturn = (INT16)(cmd->angleturn - (((axis * angleturn[1]) >> 10))); // ANALOG! + side += ((axis * sidemove[0]) >> 10); + } + + cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); + + axis = JoyAxis(AXISAIM, forplayer); + if (InputDown(gc_aimforward, forplayer) || (usejoystick && axis < 0)) + forward += forwardmove[1]; + if (InputDown(gc_aimbackward, forplayer) || (usejoystick && axis > 0)) + forward -= forwardmove[1]; + + // fire with any button/key + axis = JoyAxis(AXISFIRE, forplayer); + if (InputDown(gc_fire, 1) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ATTACK; + + // spectator aiming shit, ahhhh... + screen_invert = 1; // nope + + // mouse look stuff (mouse look is not the same as mouse aim) + kbl = false; + + // looking up/down + laim += (mlooky<<19)*screen_invert; + + axis = JoyAxis(AXISLOOK, forplayer); + + if (analogjoystickmove && axis != 0 && lookaxis) + laim += (axis<<16) * screen_invert; + + // spring back if not using keyboard neither mouselookin' + if (!kbl && !lookaxis) + laim = 0; + + if (InputDown(gc_lookup, forplayer) || (gamepadjoystickmove && axis < 0)) + { + laim += KB_LOOKSPEED * screen_invert; + kbl = true; + } + else if (InputDown(gc_lookdown, forplayer) || (gamepadjoystickmove && axis > 0)) + { + laim -= KB_LOOKSPEED * screen_invert; + kbl = true; + } + + if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V + laim = 0; + + cmd->aiming = G_ClipAimingPitch(&laim); + + mousex = mousey = mlooky = 0; + + if (forward > MAXPLMOVE) + forward = MAXPLMOVE; + else if (forward < -MAXPLMOVE) + forward = -MAXPLMOVE; + + if (side > MAXPLMOVE) + side = MAXPLMOVE; + else if (side < -MAXPLMOVE) + side = -MAXPLMOVE; + + if (forward || side) + { + cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); + cmd->sidemove = (SINT8)(cmd->sidemove + side); + } + + lang += (cmd->angleturn<<16); + + cam->localangle = lang; + cam->localaiming = laim; + cam->keyboardlook = kbl; + + return cmd; +} + #define intsign(n) \ ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) -void P_DemoCameraMovement(camera_t *cam, UINT8 num) +static void P_DemoCameraMovement(camera_t *cam, UINT8 num) { ticcmd_t *cmd; angle_t thrustangle; player_t *lastp; - angle_t turning; - + const UINT8 forplayer = num+1; boolean moving = false; + cam->localangle = cam->angle; + cam->localaiming = cam->aiming; + // first off we need to get button input - cmd = D_LocalTiccmd(num); + cmd = P_CameraCmd(cam, num); if (cmd->aiming != 0) { @@ -3171,31 +3339,26 @@ void P_DemoCameraMovement(camera_t *cam, UINT8 num) cam->reset_aiming = false; } - turning = cmd->angleturn << 16; - if (encoremode) - { - turning = -turning; - } - cam->angle = turning; + cam->angle = cmd->angleturn << 16; // camera movement: if (!cam->button_a_held) { fixed_t spd = 32*mapobjectscale*cv_freecam_speed.value; - if (InputDown(gc_camfloat, num+1)) + if (InputDown(gc_camfloat, forplayer)) { cam->z += spd; moving = true; } - else if (InputDown(gc_camsink, num+1)) + else if (InputDown(gc_camsink, forplayer)) { cam->z -= spd; moving = true; } } - if (!(InputDown(gc_camfloat, num+1) || InputDown(gc_camsink, num+1)) && cam->button_a_held) + if (!(InputDown(gc_camfloat, forplayer) || InputDown(gc_camsink, forplayer)) && cam->button_a_held) { cam->button_a_held--; } @@ -3221,7 +3384,7 @@ void P_DemoCameraMovement(camera_t *cam, UINT8 num) // forward/back will have a slope. So, as long as democam // controls haven't been used to alter the vertical angle, // slowly reset it to flat. - if ((cam->reset_aiming && moving) || ((InputDown(gc_camsink, num+1)) && !cam->button_a_held)) + if ((cam->reset_aiming && moving) || ((InputDown(gc_camsink, forplayer)) && !cam->button_a_held)) { INT32 aiming = cam->aiming; INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming)); From a19cb5f2bcf0c4790cfda772d6a3131e40c24499 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 04:00:56 +0100 Subject: [PATCH 030/418] fix speccam again --- src/p_user.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 8b0f15cf3..37a5ee0df 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3137,14 +3137,10 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn -static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS]; - void P_ToggleDemoCamera(UINT8 viewnum) { camera_t *cam = &camera[viewnum]; - memset(&cameracmd[viewnum], 0, sizeof(ticcmd_t)); - if (!cam->freecam) // toggle on { cam->freecam = true; @@ -3167,15 +3163,15 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) INT32 screen_invert; const UINT8 forplayer = num+1; - ticcmd_t *cmd = &cameracmd[num]; + ticcmd_t *cmd = D_LocalTiccmd(num); + + if (!cam->freecam) + return cmd; // empty cmd, no. lang = cam->localangle; laim = cam->localaiming; kbl = cam->keyboardlook; - if (!cam->freecam) - return cmd; // empty cmd, no. - switch (num) { case 1: From 3156851554096001904be635e6528e5b4ba85a77 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 04:01:09 +0100 Subject: [PATCH 031/418] fix cam interp during pause again --- src/r_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index b863d8141..2a97136be 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1066,6 +1066,8 @@ R_SetupCommonFrame ( player_t * player, subsector_t * subsector) { + const UINT8 viewnum = R_GetViewNumber(); + newview->player = player; newview->x += quake.x; @@ -1079,7 +1081,7 @@ R_SetupCommonFrame else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - R_InterpolateView(R_UsingFrameInterpolation() ? (demo.freecam ? rendertimefrac_unpaused : rendertimefrac) : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? (camera[viewnum].freecam ? rendertimefrac_unpaused : rendertimefrac) : FRACUNIT, false); } static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) From da9c19bba430891d382e2cb7722aa79f7b446b86 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 28 Dec 2024 18:48:58 +0300 Subject: [PATCH 032/418] Update replayfreecam lua global to use camera.freecam for currently viewed player --- src/dehacked.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index e4b4028ef..54ea4e510 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8542,6 +8542,16 @@ static int lua_enumlib_mariomode_get(lua_State *L) return 1; } +static int lua_enumlib_replayfreecam_get(lua_State *L) +{ + if (dedicated) // huh? + lua_pushboolean(L, false); + else + lua_pushboolean(L, camera[R_GetViewNumber()].freecam); + + return 1; +} + static int lua_enumlib_twodlevel_get(lua_State *L) { lua_pushboolean(L, twodlevel); @@ -9219,7 +9229,7 @@ int LUA_EnumLib(lua_State *L) lua_pushcfunction(L, lua_glib_new_getter); lua_pushliteral(L, "replayfreecam"); - lua_glib_push_bool_getter(L, &demo.freecam); + lua_pushcfunction(L, lua_enumlib_replayfreecam_get); lua_call(L, 2, 0); if (!mathlib) From 229e8d9592966a438d3aa50dbc3e1273512bfad7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 17:47:58 +0100 Subject: [PATCH 033/418] WIP splitscreen director lel --- src/g_game.c | 18 +++++- src/k_director.c | 149 +++++++++++++++++++++++++++-------------------- src/k_director.h | 4 +- src/p_tick.c | 5 +- 4 files changed, 108 insertions(+), 68 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 79e94a24b..d6e7ac2ab 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1550,10 +1550,22 @@ boolean G_Responder(event_t *ev) COM_ImmedExecute("changeteam4 spectator"); } } - if (ev->data1 == gamecontrol[gc_director][0] - || ev->data1 == gamecontrol[gc_director][1]) + + if (ev->data1 == gamecontrol[gc_director][0] || ev->data1 == gamecontrol[gc_director][1]) { - K_ToggleDirector(); + K_ToggleDirector(0); + } + else if (ev->data1 == gamecontrolbis[gc_director][0] || ev->data1 == gamecontrolbis[gc_director][1]) + { + K_ToggleDirector(1); + } + else if (ev->data1 == gamecontrol3[gc_director][0] || ev->data1 == gamecontrol3[gc_director][1]) + { + K_ToggleDirector(2); + } + else if (ev->data1 == gamecontrol4[gc_director][0] || ev->data1 == gamecontrol4[gc_director][1]) + { + K_ToggleDirector(3); } if (ev->data1 == gamecontrol[gc_freecam][0] || ev->data1 == gamecontrol[gc_freecam][1]) diff --git a/src/k_director.c b/src/k_director.c index dafea6072..375f8ddb3 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -12,6 +12,7 @@ //#include "k_kart.h" #include "doomdef.h" +#include "doomstat.h" #include "g_game.h" #include "v_video.h" #include "k_director.h" @@ -19,6 +20,8 @@ #include "p_local.h" #include "st_stuff.h" +#include "r_fps.h" + #define SWITCHTIME TICRATE * 5 // cooldown between unforced switches #define BOREDOMTIME 3 * TICRATE / 2 // how long until players considered far apart? #define TRANSFERTIME TICRATE // how long to delay reaction shots? @@ -28,6 +31,7 @@ struct directorinfo { + boolean active; tic_t cooldown; // how long has it been since we last switched? tic_t freeze; // when nonzero, fixed switch pending, freeze logic! INT32 attacker; // who to switch to when freeze delay elapses @@ -38,6 +42,8 @@ struct directorinfo INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers? } directorinfo; +struct directorinfo directorinfosplit[MAXSPLITSCREENPLAYERS]; + boolean K_DirectorIsPlayerAlone(void) { UINT8 pingame = 0; @@ -67,25 +73,30 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) return FixedMul(n, FixedDiv(scale, mapobjectscale)); } -static boolean K_DirectorIsEnabled(void) +static boolean K_DirectorIsEnabled(const UINT8 viewnum) { - return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !demo.freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone()); + //return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !camera[0].freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone()); + return directorinfosplit[viewnum].active; } void K_InitDirector(void) { INT32 playernum; - directorinfo.cooldown = SWITCHTIME; - directorinfo.freeze = 0; - directorinfo.attacker = 0; - directorinfo.maxdist = 0; - - for (playernum = 0; playernum < MAXPLAYERS; playernum++) + for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - directorinfo.sortedplayers[playernum] = -1; - directorinfo.gap[playernum] = INT32_MAX; - directorinfo.boredom[playernum] = 0; + directorinfosplit[i].cooldown = SWITCHTIME; + directorinfosplit[i].freeze = 0; + directorinfosplit[i].attacker = 0; + directorinfosplit[i].maxdist = 0; + directorinfosplit[i].active = 0; + + for (playernum = 0; playernum < MAXPLAYERS; playernum++) + { + directorinfosplit[i].sortedplayers[playernum] = -1; + directorinfosplit[i].gap[playernum] = INT32_MAX; + directorinfosplit[i].boredom[playernum] = 0; + } } } @@ -148,13 +159,13 @@ static fixed_t K_GetFinishGap(INT32 leader, INT32 follower) } } -static void K_UpdateDirectorPositions(void) +static void K_UpdateDirectorPositions(const UINT8 viewnum) { INT32 playernum; INT32 position; player_t* target; - memset(directorinfo.sortedplayers, -1, sizeof(directorinfo.sortedplayers)); + memset(directorinfosplit[viewnum].sortedplayers, -1, sizeof(directorinfo.sortedplayers)); for (playernum = 0; playernum < MAXPLAYERS; playernum++) { @@ -162,43 +173,43 @@ static void K_UpdateDirectorPositions(void) if (playeringame[playernum] && !target->spectator && target->kartstuff[k_position] > 0) { - directorinfo.sortedplayers[target->kartstuff[k_position] - 1] = playernum; + directorinfosplit[viewnum].sortedplayers[target->kartstuff[k_position] - 1] = playernum; } } for (position = 0; position < MAXPLAYERS - 1; position++) { - directorinfo.gap[position] = INT32_MAX; + directorinfosplit[viewnum].gap[position] = INT32_MAX; - if (directorinfo.sortedplayers[position] == -1 || directorinfo.sortedplayers[position + 1] == -1) + if (directorinfosplit[viewnum].sortedplayers[position] == -1 || directorinfosplit[viewnum].sortedplayers[position + 1] == -1) { continue; } - directorinfo.gap[position] = ScaleFromMap(K_GetFinishGap(directorinfo.sortedplayers[position], directorinfo.sortedplayers[position + 1]), FRACUNIT); + directorinfosplit[viewnum].gap[position] = ScaleFromMap(K_GetFinishGap(directorinfosplit[viewnum].sortedplayers[position], directorinfosplit[viewnum].sortedplayers[position + 1]), FRACUNIT); - if (directorinfo.gap[position] >= BREAKAWAYDIST) + if (directorinfosplit[viewnum].gap[position] >= BREAKAWAYDIST) { - directorinfo.boredom[position] = (INT32)(min(BOREDOMTIME * 2, directorinfo.boredom[position] + 1)); + directorinfosplit[viewnum].boredom[position] = (INT32)(min(BOREDOMTIME * 2, directorinfosplit[viewnum].boredom[position] + 1)); } - else if (directorinfo.boredom[position] > 0) + else if (directorinfosplit[viewnum].boredom[position] > 0) { - directorinfo.boredom[position]--; + directorinfosplit[viewnum].boredom[position]--; } } - if (directorinfo.sortedplayers[0] == -1) + if (directorinfosplit[viewnum].sortedplayers[0] == -1) { - directorinfo.maxdist = -1; + directorinfosplit[viewnum].maxdist = -1; return; } - directorinfo.maxdist = ScaleFromMap(K_GetDistanceToFinish(players[directorinfo.sortedplayers[0]]), FRACUNIT); + directorinfosplit[viewnum].maxdist = ScaleFromMap(K_GetDistanceToFinish(players[directorinfosplit[viewnum].sortedplayers[0]]), FRACUNIT); } -static boolean K_CanSwitchDirector(void) +static boolean K_CanSwitchDirector(const UINT8 viewnum) { - if (directorinfo.cooldown > 0) + if (directorinfosplit[viewnum].cooldown > 0) { return false; } @@ -206,9 +217,9 @@ static boolean K_CanSwitchDirector(void) return true; } -static void K_DirectorSwitch(INT32 player, boolean force) +static void K_DirectorSwitch(INT32 player, boolean force, const UINT8 viewnum) { - if (!K_DirectorIsEnabled()) + if (!K_DirectorIsEnabled(viewnum)) { return; } @@ -223,29 +234,34 @@ static void K_DirectorSwitch(INT32 player, boolean force) return; } - if (!force && !K_CanSwitchDirector()) + if (!force && !K_CanSwitchDirector(viewnum)) { return; } - G_ResetView(1, player, true); - directorinfo.cooldown = SWITCHTIME; + G_ResetView(viewnum+1, player, true); + directorinfosplit[viewnum].cooldown = SWITCHTIME; } -static void K_DirectorForceSwitch(INT32 player, INT32 time) +static void K_DirectorForceSwitch(INT32 player, INT32 time, const UINT8 viewnum) { if (players[player].exiting) { return; } - directorinfo.attacker = player; - directorinfo.freeze = time; + directorinfosplit[viewnum].attacker = player; + directorinfosplit[viewnum].freeze = time; } +static UINT8 curview = 0; + void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) { - if (!K_DirectorIsEnabled()) + if (player != &players[displayplayers[curview]]) + return; + + if (!K_DirectorIsEnabled(curview)) { return; } @@ -257,11 +273,11 @@ void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) if (inflictor && inflictor->player) { - K_DirectorForceSwitch(inflictor->player - players, TRANSFERTIME); + K_DirectorForceSwitch(inflictor->player - players, TRANSFERTIME, curview); } else if (source && source->player) { - K_DirectorForceSwitch(source->player - players, TRANSFERTIME); + K_DirectorForceSwitch(source->player - players, TRANSFERTIME, curview); } } @@ -317,37 +333,39 @@ void K_DrawDirectorDebugger(void) } } -void K_UpdateDirector(void) +void K_UpdateDirector(const UINT8 viewnum) { - INT32 *displayplayerp = &displayplayers[0]; + INT32 *displayplayerp = &displayplayers[viewnum]; INT32 targetposition; - if (!K_DirectorIsEnabled()) + curview = viewnum; + + if (!K_DirectorIsEnabled(viewnum)) { return; } - K_UpdateDirectorPositions(); + K_UpdateDirectorPositions(viewnum); - if (directorinfo.cooldown > 0) { - directorinfo.cooldown--; + if (directorinfosplit[viewnum].cooldown > 0) { + directorinfosplit[viewnum].cooldown--; } // handle pending forced switches - if (directorinfo.freeze > 0) + if (directorinfosplit[viewnum].freeze > 0) { - if (!(--directorinfo.freeze)) - K_DirectorSwitch(directorinfo.attacker, true); + if (!(--directorinfosplit[viewnum].freeze)) + K_DirectorSwitch(directorinfosplit[viewnum].attacker, true, viewnum); return; } // if there's only one player left in the list, just switch to that player - if (directorinfo.sortedplayers[0] != -1 && (directorinfo.sortedplayers[1] == -1 || + if (directorinfosplit[viewnum].sortedplayers[0] != -1 && (directorinfosplit[viewnum].sortedplayers[1] == -1 || // TODO: Battle; I just threw this together quick. Focus on leader. !race_rules())) { - K_DirectorSwitch(directorinfo.sortedplayers[0], false); + K_DirectorSwitch(directorinfosplit[viewnum].sortedplayers[0], false, viewnum); return; } @@ -359,36 +377,36 @@ void K_UpdateDirector(void) INT32 target; // you are out of players, try again - if (directorinfo.sortedplayers[targetposition] == -1) + if (directorinfosplit[viewnum].sortedplayers[targetposition] == -1) { break; } // pair too far apart? try the next one - if (directorinfo.boredom[targetposition - 1] >= BOREDOMTIME) + if (directorinfosplit[viewnum].boredom[targetposition - 1] >= BOREDOMTIME) { continue; } // pair finished? try the next one - if (players[directorinfo.sortedplayers[targetposition]].exiting) + if (players[directorinfosplit[viewnum].sortedplayers[targetposition]].exiting) { continue; } // don't risk switching away from forward pairs at race end, might miss something! - if (directorinfo.maxdist > PINCHDIST) + if (directorinfosplit[viewnum].maxdist > PINCHDIST) { // if the "next" player is close enough, they should be able to see everyone fine! // walk back through the standings to find a vantage that gets everyone in frame. // (also creates a pretty cool effect w/ overtakes at speed) - while (targetposition < MAXPLAYERS && directorinfo.gap[targetposition] < WALKBACKDIST) + while (targetposition < MAXPLAYERS && directorinfosplit[viewnum].gap[targetposition] < WALKBACKDIST) { targetposition++; } } - target = directorinfo.sortedplayers[targetposition]; + target = directorinfosplit[viewnum].sortedplayers[targetposition]; // stop here since we're already viewing this player if (*displayplayerp == target) @@ -405,30 +423,37 @@ void K_UpdateDirector(void) // if we're certain the back half of the pair is actually in this position, try to switch if (!players[target].kartstuff[k_positiondelay]) { - K_DirectorSwitch(target, false); + K_DirectorSwitch(target, false, viewnum); } // even if we're not certain, if we're certain we're watching the WRONG player, try to switch if (players[*displayplayerp].kartstuff[k_position] != targetposition+1 && !players[*displayplayerp].kartstuff[k_positiondelay]) { - K_DirectorSwitch(target, false); + K_DirectorSwitch(target, false, viewnum); } break; } } -void K_ToggleDirector(void) +void K_ToggleDirector(const UINT8 viewnum) { - if (!directortextactive) - return; + //if (!directortextactive) + //return; - if (!K_DirectorIsEnabled()) + if (!K_DirectorIsEnabled(viewnum)) { - directorinfo.cooldown = 0; // switch immediately + directorinfosplit[viewnum].cooldown = 0; // switch immediately } directortoggletimer = 0; - COM_ImmedExecute("add director 1"); + if (directorinfosplit[viewnum].active == false) + directorinfosplit[viewnum].active = true; + else + directorinfosplit[viewnum].active = false; + + CONS_Printf("director active %d for %d\n", directorinfosplit[viewnum].active, viewnum); + + //COM_ImmedExecute("add director 1"); } diff --git a/src/k_director.h b/src/k_director.h index 3be71b675..a5431d4f5 100644 --- a/src/k_director.h +++ b/src/k_director.h @@ -11,7 +11,7 @@ /// \brief SRB2kart automatic spectator camera. void K_InitDirector(void); -void K_UpdateDirector(void); +void K_UpdateDirector(UINT8 viewnum); void K_DrawDirectorDebugger(void); void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source); -void K_ToggleDirector(void); +void K_ToggleDirector(UINT8 viewnum); diff --git a/src/p_tick.c b/src/p_tick.c index 0784957f3..1bd6fa72b 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -698,7 +698,10 @@ void P_Ticker(boolean run) PS_STOP_TIMING(ps_lua_postthinkframe_time); } - K_UpdateDirector(); + for (i = 0; i <= splitscreen; i++) + { + K_UpdateDirector(i); + } // Always move the camera. P_RunChaseCameras(); From b51731d6754f85a4c9bb86b4f0fd7f9a393af10c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 17:42:04 +0100 Subject: [PATCH 034/418] cleanup director splitscreen stuff --- src/d_netcmd.c | 16 ++++++++++++++-- src/d_netcmd.h | 3 ++- src/g_game.c | 20 +++++++++++++------- src/k_director.c | 38 ++++++++++++++++++++++---------------- src/st_stuff.c | 6 +++--- 5 files changed, 54 insertions(+), 29 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5e1927ff0..19360a24b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -572,7 +572,15 @@ static CV_PossibleValue_t ps_descriptor_cons_t[] = { {1, "Average"}, {2, "SD"}, {3, "Minimum"}, {4, "Maximum"}, {0, NULL}}; consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +//consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_director[MAXSPLITSCREENPLAYERS] = { + {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"director2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"director3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"director4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + consvar_t cv_kartdebugdirector = {"debugdirector", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showdirectorhud = {"showdirectorhud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1005,7 +1013,11 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_showviewpointtext); CV_RegisterVar(&cv_showdownloadprompt); - CV_RegisterVar(&cv_director); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + CV_RegisterVar(&cv_director[i]); + } + CV_RegisterVar(&cv_kartdebugdirector); CV_RegisterVar(&cv_showdirectorhud); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 87d96b40d..77852f60c 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -197,7 +197,8 @@ extern consvar_t cv_ps_thinkframe_page; extern consvar_t cv_ps_samplesize; extern consvar_t cv_ps_descriptor; -extern consvar_t cv_director, cv_kartdebugdirector, cv_showdirectorhud; +extern consvar_t cv_director[4]; // screw you includes +extern consvar_t cv_kartdebugdirector, cv_showdirectorhud; extern consvar_t cv_showtrackaddon; diff --git a/src/g_game.c b/src/g_game.c index d6e7ac2ab..e99400502 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -337,7 +337,7 @@ INT16 prevmap, nextmap; // save if director is enabled // so demos can disable it by default and restore it after -static int directorstate = 0; +static int directorstate[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; tic_t directortoggletimer = 0; static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; @@ -1213,8 +1213,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) displayplayers[0] = consoleplayer; G_FixCamera(1); // i dont like this lmao - if (cv_director.value) - CV_SetValue(&cv_director, 0); + if (cv_director[0].value) + CV_SetValue(&cv_director[0], 0); } } @@ -7292,8 +7292,11 @@ post_compat: players[i].kartweight = kartweight[i]; } - directorstate = cv_director.value; - CV_SetValue(&cv_director, 0); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + directorstate[i] = cv_director[i].value; + CV_SetValue(&cv_director[i], 0); + } demo.deferstart = true; } @@ -7860,8 +7863,11 @@ void G_StopDemo(void) demobuffer = NULL; if (demo.playback) { - CV_SetValue(&cv_director, directorstate); - directorstate = 0; + for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + CV_SetValue(&cv_director[i], directorstate[i]); + directorstate[i] = 0; + } } demo.playback = false; if (demo.title) diff --git a/src/k_director.c b/src/k_director.c index 375f8ddb3..f3dd3733c 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -31,7 +31,6 @@ struct directorinfo { - boolean active; tic_t cooldown; // how long has it been since we last switched? tic_t freeze; // when nonzero, fixed switch pending, freeze logic! INT32 attacker; // who to switch to when freeze delay elapses @@ -76,7 +75,7 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) static boolean K_DirectorIsEnabled(const UINT8 viewnum) { //return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !camera[0].freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone()); - return directorinfosplit[viewnum].active; + return (cv_director[viewnum].value && (gamestate == GS_LEVEL && (((!playeringame[displayplayers[viewnum]] || players[displayplayers[viewnum]].spectator)) || (demo.playback && !camera[viewnum].freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone())); } void K_InitDirector(void) @@ -89,7 +88,6 @@ void K_InitDirector(void) directorinfosplit[i].freeze = 0; directorinfosplit[i].attacker = 0; directorinfosplit[i].maxdist = 0; - directorinfosplit[i].active = 0; for (playernum = 0; playernum < MAXPLAYERS; playernum++) { @@ -254,6 +252,7 @@ static void K_DirectorForceSwitch(INT32 player, INT32 time, const UINT8 viewnum) directorinfosplit[viewnum].freeze = time; } +// HACK: this is awful but idk any other way to pass the viewnum to this static UINT8 curview = 0; void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) @@ -266,11 +265,6 @@ void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) return; } - if (!P_IsDisplayPlayer(player)) - { - return; - } - if (inflictor && inflictor->player) { K_DirectorForceSwitch(inflictor->player - players, TRANSFERTIME, curview); @@ -441,6 +435,9 @@ void K_ToggleDirector(const UINT8 viewnum) //if (!directortextactive) //return; + if (gamestate != GS_LEVEL && (playeringame[displayplayers[viewnum]] || !players[displayplayers[viewnum]].spectator)) + return; + if (!K_DirectorIsEnabled(viewnum)) { directorinfosplit[viewnum].cooldown = 0; // switch immediately @@ -448,12 +445,21 @@ void K_ToggleDirector(const UINT8 viewnum) directortoggletimer = 0; - if (directorinfosplit[viewnum].active == false) - directorinfosplit[viewnum].active = true; - else - directorinfosplit[viewnum].active = false; - - CONS_Printf("director active %d for %d\n", directorinfosplit[viewnum].active, viewnum); - - //COM_ImmedExecute("add director 1"); + switch (viewnum) + { + case 1: + COM_ImmedExecute("add director2 1"); + break; + case 2: + COM_ImmedExecute("add director3 1"); + break; + case 3: + COM_ImmedExecute("add director4 1"); + break; + case 0: + COM_ImmedExecute("add director 1"); + break; + default: + break; + } } diff --git a/src/st_stuff.c b/src/st_stuff.c index 398dc7dbe..b9730000e 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -671,9 +671,9 @@ static void ST_overlayDrawer(void) { char directortext[20] = {0}; - snprintf(directortext, 20, "Director: %s", cv_director.value ? "On" : "Off"); + snprintf(directortext, 20, "Director: %s", cv_director[0].value ? "On" : "Off"); - directortextactive = true; + //directortextactive = true; if ((!demo.playback && directortoggletimer < 13*TICRATE) || (demo.playback && directortoggletimer < 4*TICRATE)) { @@ -689,7 +689,7 @@ static void ST_overlayDrawer(void) else { directortoggletimer = 0; - directortextactive = false; + //directortextactive = false; } if (cv_showviewpointtext.value) From b5b2062efa808f1621a65c6cd1cbd51563ba31c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 18:17:34 +0100 Subject: [PATCH 035/418] add K_DirectorIsAvailable --- src/k_director.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index f3dd3733c..7dca59f41 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -72,10 +72,15 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) return FixedMul(n, FixedDiv(scale, mapobjectscale)); } +static boolean K_DirectorIsAvailable(UINT8 viewnum) +{ + return ((gamestate == GS_LEVEL) && (viewnum <= splitscreen) && (!playeringame[displayplayers[viewnum]] || players[displayplayers[viewnum]].spectator)); +} + static boolean K_DirectorIsEnabled(const UINT8 viewnum) { //return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !camera[0].freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone()); - return (cv_director[viewnum].value && (gamestate == GS_LEVEL && (((!playeringame[displayplayers[viewnum]] || players[displayplayers[viewnum]].spectator)) || (demo.playback && !camera[viewnum].freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone())); + return (cv_director[viewnum].value && (K_DirectorIsAvailable(viewnum) || (demo.playback && (!demo.title || !modeattacking) && !camera[viewnum].freecam)) && !K_DirectorIsPlayerAlone()); } void K_InitDirector(void) @@ -435,7 +440,7 @@ void K_ToggleDirector(const UINT8 viewnum) //if (!directortextactive) //return; - if (gamestate != GS_LEVEL && (playeringame[displayplayers[viewnum]] || !players[displayplayers[viewnum]].spectator)) + if (K_DirectorIsAvailable(viewnum)) return; if (!K_DirectorIsEnabled(viewnum)) From 86aeff55476e1f1d36f9ad06f3e1b13993e5efcb Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 18:25:23 +0100 Subject: [PATCH 036/418] cleanup K_DirectorIsAvailable --- src/k_director.c | 9 +++++---- src/k_director.h | 1 + src/st_stuff.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index 7dca59f41..6de578f5f 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -72,15 +72,16 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) return FixedMul(n, FixedDiv(scale, mapobjectscale)); } -static boolean K_DirectorIsAvailable(UINT8 viewnum) +boolean K_DirectorIsAvailable(UINT8 viewnum) { - return ((gamestate == GS_LEVEL) && (viewnum <= splitscreen) && (!playeringame[displayplayers[viewnum]] || players[displayplayers[viewnum]].spectator)); + if ((demo.playback && demo.title) || modeattacking) + return false; + return ((gamestate == GS_LEVEL) && (viewnum <= splitscreen) && (!playeringame[displayplayers[viewnum]] || players[displayplayers[viewnum]].spectator) && !camera[viewnum].freecam); } static boolean K_DirectorIsEnabled(const UINT8 viewnum) { - //return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !camera[0].freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone()); - return (cv_director[viewnum].value && (K_DirectorIsAvailable(viewnum) || (demo.playback && (!demo.title || !modeattacking) && !camera[viewnum].freecam)) && !K_DirectorIsPlayerAlone()); + return (cv_director[viewnum].value && K_DirectorIsAvailable(viewnum) && !K_DirectorIsPlayerAlone()); } void K_InitDirector(void) diff --git a/src/k_director.h b/src/k_director.h index a5431d4f5..acc00b253 100644 --- a/src/k_director.h +++ b/src/k_director.h @@ -10,6 +10,7 @@ /// \file k_director.h /// \brief SRB2kart automatic spectator camera. +boolean K_DirectorIsAvailable(UINT8 viewnum); void K_InitDirector(void); void K_UpdateDirector(UINT8 viewnum); void K_DrawDirectorDebugger(void); diff --git a/src/st_stuff.c b/src/st_stuff.c index b9730000e..5e536d853 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -667,7 +667,7 @@ static void ST_overlayDrawer(void) if (!hu_showscores) // hide the following if TAB is held { - if (cv_showdirectorhud.value && !splitscreen && ((demo.playback && !camera[viewnum].freecam && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !K_DirectorIsPlayerAlone()) + if (cv_showdirectorhud.value && !splitscreen && !P_IsLocalPlayer(stplyr) && K_DirectorIsAvailable(0) && !K_DirectorIsPlayerAlone()) { char directortext[20] = {0}; From 03280db3778570e30258c9a758173299906cda13 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 18:52:49 +0100 Subject: [PATCH 037/418] missing inlucde --- src/st_stuff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/st_stuff.c b/src/st_stuff.c index 5e536d853..3c15a4ff7 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -16,6 +16,7 @@ #include "doomdef.h" #include "g_game.h" #include "g_input.h" +#include "k_director.h" #include "r_local.h" #include "p_local.h" #include "f_finale.h" From f355b2269c8a5b27c34d9296f126ac11e2c3f319 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 05:00:41 +0100 Subject: [PATCH 038/418] toggle off freecam when f12ing --- src/g_game.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 79e94a24b..2c3e2fa02 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1773,7 +1773,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) G_FixCamera(viewd); } - if (viewnum == 1 && demo.playback) + if (demo.playback && viewnum == 1) consoleplayer = displayplayers[0]; } @@ -1787,6 +1787,10 @@ void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive) INT32 *displayplayerp, oldview; displayplayerp = &displayplayers[viewnum-1]; oldview = (*displayplayerp); + + // turn off the freecam + camera[viewnum].freecam = false; + G_ResetView(viewnum, ( (*displayplayerp) + offset ), onlyactive); // If no other view could be found, go back to what we had. From a379764076c068500f439a6c57cb7d3f4d1aeaf0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 05:32:51 +0100 Subject: [PATCH 039/418] fix director toggling + smol cleanup --- src/k_director.c | 27 ++++----------------------- src/st_stuff.c | 8 +------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index 6de578f5f..c35d10036 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -76,12 +76,12 @@ boolean K_DirectorIsAvailable(UINT8 viewnum) { if ((demo.playback && demo.title) || modeattacking) return false; - return ((gamestate == GS_LEVEL) && (viewnum <= splitscreen) && (!playeringame[displayplayers[viewnum]] || players[displayplayers[viewnum]].spectator) && !camera[viewnum].freecam); + return ((gamestate == GS_LEVEL) && (demo.playback || ((viewnum <= splitscreen) && (!playeringame[displayplayers[viewnum]] || players[displayplayers[viewnum]].spectator) && !camera[viewnum].freecam && !K_DirectorIsPlayerAlone()))); } static boolean K_DirectorIsEnabled(const UINT8 viewnum) { - return (cv_director[viewnum].value && K_DirectorIsAvailable(viewnum) && !K_DirectorIsPlayerAlone()); + return (cv_director[viewnum].value && K_DirectorIsAvailable(viewnum)); } void K_InitDirector(void) @@ -438,10 +438,7 @@ void K_UpdateDirector(const UINT8 viewnum) void K_ToggleDirector(const UINT8 viewnum) { - //if (!directortextactive) - //return; - - if (K_DirectorIsAvailable(viewnum)) + if (!K_DirectorIsAvailable(viewnum)) return; if (!K_DirectorIsEnabled(viewnum)) @@ -451,21 +448,5 @@ void K_ToggleDirector(const UINT8 viewnum) directortoggletimer = 0; - switch (viewnum) - { - case 1: - COM_ImmedExecute("add director2 1"); - break; - case 2: - COM_ImmedExecute("add director3 1"); - break; - case 3: - COM_ImmedExecute("add director4 1"); - break; - case 0: - COM_ImmedExecute("add director 1"); - break; - default: - break; - } + CV_SetValue(&cv_director[viewnum], (cv_director[viewnum].value ^ 1)); } diff --git a/src/st_stuff.c b/src/st_stuff.c index 3c15a4ff7..26a38b177 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -157,8 +157,6 @@ static patch_t *envelope; player_t *stplyr; UINT8 stplyrnum; -boolean directortextactive = false; - // SRB2kart hudinfo_t hudinfo[NUMHUDITEMS] = @@ -668,14 +666,13 @@ static void ST_overlayDrawer(void) if (!hu_showscores) // hide the following if TAB is held { + // TODO: splitscreen support! if (cv_showdirectorhud.value && !splitscreen && !P_IsLocalPlayer(stplyr) && K_DirectorIsAvailable(0) && !K_DirectorIsPlayerAlone()) { char directortext[20] = {0}; snprintf(directortext, 20, "Director: %s", cv_director[0].value ? "On" : "Off"); - //directortextactive = true; - if ((!demo.playback && directortoggletimer < 13*TICRATE) || (demo.playback && directortoggletimer < 4*TICRATE)) { if (renderisnewtic) @@ -690,7 +687,6 @@ static void ST_overlayDrawer(void) else { directortoggletimer = 0; - //directortextactive = false; } if (cv_showviewpointtext.value) @@ -794,8 +790,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 { From 88536666458eb8589fc7d363e26b803ffbea9ff1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 05:42:21 +0100 Subject: [PATCH 040/418] track views in directorinfo structs should hopefully fix any potential remaining issues --- src/k_director.c | 69 +++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index c35d10036..aae77baf9 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -31,6 +31,8 @@ struct directorinfo { + UINT8 viewnum; + player_t* viewplayer; tic_t cooldown; // how long has it been since we last switched? tic_t freeze; // when nonzero, fixed switch pending, freeze logic! INT32 attacker; // who to switch to when freeze delay elapses @@ -88,12 +90,15 @@ void K_InitDirector(void) { INT32 playernum; + directorinfo.viewnum = 0; + for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) { directorinfosplit[i].cooldown = SWITCHTIME; directorinfosplit[i].freeze = 0; directorinfosplit[i].attacker = 0; directorinfosplit[i].maxdist = 0; + directorinfosplit[i].viewplayer = NULL; for (playernum = 0; playernum < MAXPLAYERS; playernum++) { @@ -119,8 +124,8 @@ static fixed_t K_GetDistanceToFinish(player_t player) continue; dist = P_AproxDistance(P_AproxDistance(mo->x - player.mo->x, - mo->y - player.mo->y), - mo->z - player.mo->z) / FRACUNIT; + mo->y - player.mo->y), + mo->z - player.mo->z) / FRACUNIT; break; } @@ -139,7 +144,7 @@ static fixed_t K_GetDistanceToFinish(player_t player) dist = P_AproxDistance(P_AproxDistance(mo->x - player.mo->x, mo->y - player.mo->y), - mo->z - player.mo->z) / FRACUNIT; + mo->z - player.mo->z) / FRACUNIT; break; } @@ -258,26 +263,25 @@ static void K_DirectorForceSwitch(INT32 player, INT32 time, const UINT8 viewnum) directorinfosplit[viewnum].freeze = time; } -// HACK: this is awful but idk any other way to pass the viewnum to this -static UINT8 curview = 0; - void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) { - if (player != &players[displayplayers[curview]]) + if (!K_DirectorIsEnabled(directorinfo.viewnum)) + { return; + } - if (!K_DirectorIsEnabled(curview)) + if (directorinfosplit[directorinfo.viewnum].viewplayer != player) { return; } if (inflictor && inflictor->player) { - K_DirectorForceSwitch(inflictor->player - players, TRANSFERTIME, curview); + K_DirectorForceSwitch(inflictor->player - players, TRANSFERTIME, directorinfo.viewnum); } else if (source && source->player) { - K_DirectorForceSwitch(source->player - players, TRANSFERTIME, curview); + K_DirectorForceSwitch(source->player - players, TRANSFERTIME, directorinfo.viewnum); } } @@ -335,37 +339,36 @@ void K_DrawDirectorDebugger(void) void K_UpdateDirector(const UINT8 viewnum) { - INT32 *displayplayerp = &displayplayers[viewnum]; INT32 targetposition; + directorinfo.viewnum = viewnum; + directorinfosplit[directorinfo.viewnum].viewplayer = &players[displayplayers[directorinfo.viewnum]]; - curview = viewnum; - - if (!K_DirectorIsEnabled(viewnum)) + if (!K_DirectorIsEnabled(directorinfo.viewnum)) { return; } - K_UpdateDirectorPositions(viewnum); + K_UpdateDirectorPositions(directorinfo.viewnum); - if (directorinfosplit[viewnum].cooldown > 0) { - directorinfosplit[viewnum].cooldown--; + if (directorinfosplit[directorinfo.viewnum].cooldown > 0) { + directorinfosplit[directorinfo.viewnum].cooldown--; } // handle pending forced switches - if (directorinfosplit[viewnum].freeze > 0) + if (directorinfosplit[directorinfo.viewnum].freeze > 0) { - if (!(--directorinfosplit[viewnum].freeze)) - K_DirectorSwitch(directorinfosplit[viewnum].attacker, true, viewnum); + if (!(--directorinfosplit[directorinfo.viewnum].freeze)) + K_DirectorSwitch(directorinfosplit[directorinfo.viewnum].attacker, true, directorinfo.viewnum); return; } // if there's only one player left in the list, just switch to that player - if (directorinfosplit[viewnum].sortedplayers[0] != -1 && (directorinfosplit[viewnum].sortedplayers[1] == -1 || + if (directorinfosplit[directorinfo.viewnum].sortedplayers[0] != -1 && (directorinfosplit[directorinfo.viewnum].sortedplayers[1] == -1 || // TODO: Battle; I just threw this together quick. Focus on leader. !race_rules())) { - K_DirectorSwitch(directorinfosplit[viewnum].sortedplayers[0], false, viewnum); + K_DirectorSwitch(directorinfosplit[directorinfo.viewnum].sortedplayers[0], false, directorinfo.viewnum); return; } @@ -377,39 +380,39 @@ void K_UpdateDirector(const UINT8 viewnum) INT32 target; // you are out of players, try again - if (directorinfosplit[viewnum].sortedplayers[targetposition] == -1) + if (directorinfosplit[directorinfo.viewnum].sortedplayers[targetposition] == -1) { break; } // pair too far apart? try the next one - if (directorinfosplit[viewnum].boredom[targetposition - 1] >= BOREDOMTIME) + if (directorinfosplit[directorinfo.viewnum].boredom[targetposition - 1] >= BOREDOMTIME) { continue; } // pair finished? try the next one - if (players[directorinfosplit[viewnum].sortedplayers[targetposition]].exiting) + if (players[directorinfosplit[directorinfo.viewnum].sortedplayers[targetposition]].exiting) { continue; } // don't risk switching away from forward pairs at race end, might miss something! - if (directorinfosplit[viewnum].maxdist > PINCHDIST) + if (directorinfosplit[directorinfo.viewnum].maxdist > PINCHDIST) { // if the "next" player is close enough, they should be able to see everyone fine! // walk back through the standings to find a vantage that gets everyone in frame. // (also creates a pretty cool effect w/ overtakes at speed) - while (targetposition < MAXPLAYERS && directorinfosplit[viewnum].gap[targetposition] < WALKBACKDIST) + while (targetposition < MAXPLAYERS && directorinfosplit[directorinfo.viewnum].gap[targetposition] < WALKBACKDIST) { targetposition++; } } - target = directorinfosplit[viewnum].sortedplayers[targetposition]; + target = directorinfosplit[directorinfo.viewnum].sortedplayers[targetposition]; // stop here since we're already viewing this player - if (*displayplayerp == target) + if (displayplayers[directorinfo.viewnum] == target) { break; } @@ -423,13 +426,13 @@ void K_UpdateDirector(const UINT8 viewnum) // if we're certain the back half of the pair is actually in this position, try to switch if (!players[target].kartstuff[k_positiondelay]) { - K_DirectorSwitch(target, false, viewnum); + K_DirectorSwitch(target, false, directorinfo.viewnum); } - // even if we're not certain, if we're certain we're watching the WRONG player, try to switch - if (players[*displayplayerp].kartstuff[k_position] != targetposition+1 && !players[*displayplayerp].kartstuff[k_positiondelay]) + // even if we're not certain, if we're cetain we're watching the WRONG player, try to switch + if (directorinfosplit[directorinfo.viewnum].viewplayer->kartstuff[k_position] != targetposition+1 && !directorinfosplit[directorinfo.viewnum].viewplayer->kartstuff[k_positiondelay]) { - K_DirectorSwitch(target, false, viewnum); + K_DirectorSwitch(target, false, directorinfo.viewnum); } break; From eef56a7c822a0af1af5799da2ace6495d72338ae Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 05:51:04 +0100 Subject: [PATCH 041/418] make debugdirector show stuff for p1 atleast --- src/k_director.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index aae77baf9..a91221af8 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -301,14 +301,14 @@ void K_DrawDirectorDebugger(void) V_DrawThinString(40, 0, V_70TRANS, va("CONF?")); V_DrawThinString(80, 0, V_70TRANS, va("GAP")); V_DrawThinString(120, 0, V_70TRANS, va("BORED")); - V_DrawThinString(150, 0, V_70TRANS, va("COOLDOWN: %d", directorinfo.cooldown)); - V_DrawThinString(230, 0, V_70TRANS, va("MAXDIST: %d", directorinfo.maxdist)); + V_DrawThinString(150, 0, V_70TRANS, va("COOLDOWN: %d", directorinfosplit[0].cooldown)); + V_DrawThinString(230, 0, V_70TRANS, va("MAXDIST: %d", directorinfosplit[0].maxdist)); for (position = 0; position < MAXPLAYERS - 1; position++) { ytxt = 10 * (position + 1); - leader = directorinfo.sortedplayers[position]; - follower = directorinfo.sortedplayers[position + 1]; + leader = directorinfosplit[0].sortedplayers[position]; + follower = directorinfosplit[0].sortedplayers[position + 1]; if (leader == -1 || follower == -1) break; @@ -321,15 +321,15 @@ void K_DrawDirectorDebugger(void) V_DrawThinString(40, ytxt, V_70TRANS, va("NG")); } - V_DrawThinString(80, ytxt, V_70TRANS, va("%d", directorinfo.gap[position])); + V_DrawThinString(80, ytxt, V_70TRANS, va("%d", directorinfosplit[0].gap[position])); - if (directorinfo.boredom[position] >= BOREDOMTIME) + if (directorinfosplit[0].boredom[position] >= BOREDOMTIME) { V_DrawThinString(120, ytxt, V_70TRANS, va("BORED")); } else { - V_DrawThinString(120, ytxt, V_70TRANS, va("%d", directorinfo.boredom[position])); + V_DrawThinString(120, ytxt, V_70TRANS, va("%d", directorinfosplit[0].boredom[position])); } V_DrawThinString(150, ytxt, V_70TRANS, va("%s", player_names[leader])); From 3d39f5038805d3f1e3796a7449e94bdbef8cb4f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:03:10 +0100 Subject: [PATCH 042/418] make function to return button names to use with new rebindable cam controls --- src/st_stuff.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 398dc7dbe..da5628827 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -652,6 +652,20 @@ static void ST_drawLevelTitle(void) V_DrawLevelTitle(ttlnumxpos+12, bary+6, V_SNAPTOBOTTOM, actnum); } +static const char *ST_GetButtonName(INT32 control, const char *inputtext) +{ + static char buttname[32] = {0}; // Static buffer + const char *item1 = gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL; + const char *item2 = gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL; + + if (item1 != NULL && item2 != NULL) + snprintf(buttname, 32, "%s/%s - %s", item1, item2, inputtext); + else + snprintf(buttname, 32, "%s - %s", item1 != NULL ? item1 : item2 != NULL ? item2 : "Not Bound", inputtext); + + return buttname; +} + // Draw the status bar overlay, customisable: the user chooses which // kind of information to overlay // @@ -780,19 +794,9 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-50, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Accelerate - Float")); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Brake - Sink")); - - char directortoggle[32] = {0}; - const char *item1 = gamecontrol[gc_director][0] != 0 ? G_KeynumToString(gamecontrol[gc_director][0]) : NULL; - const char *item2 = gamecontrol[gc_director][1] != 0 ? G_KeynumToString(gamecontrol[gc_director][1]) : NULL; - - if (item1 != NULL && item2 != NULL) - snprintf(directortoggle, 32, "%s/%s - Toggle Director", item1, item2); - else - 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); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director")); directortextactive = true; } @@ -800,8 +804,8 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Accelerate - Float")); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Brake - Sink")); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); } } } From 97e6222176568d77e33ebaee72486711292d477e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:02:35 +0100 Subject: [PATCH 043/418] make function to return button names to use with new rebindable cam controls --- src/st_stuff.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 26a38b177..00d5376ed 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -651,6 +651,20 @@ static void ST_drawLevelTitle(void) V_DrawLevelTitle(ttlnumxpos+12, bary+6, V_SNAPTOBOTTOM, actnum); } +static const char *ST_GetButtonName(INT32 control, const char *inputtext) +{ + static char buttname[32] = {0}; // Static buffer + const char *item1 = gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL; + const char *item2 = gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL; + + if (item1 != NULL && item2 != NULL) + snprintf(buttname, 32, "%s/%s - %s", item1, item2, inputtext); + else + snprintf(buttname, 32, "%s - %s", item1 != NULL ? item1 : item2 != NULL ? item2 : "Not Bound", inputtext); + + return buttname; +} + // Draw the status bar overlay, customisable: the user chooses which // kind of information to overlay // @@ -777,26 +791,16 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-50, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Accelerate - Float")); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Brake - Sink")); - - char directortoggle[32] = {0}; - const char *item1 = gamecontrol[gc_director][0] != 0 ? G_KeynumToString(gamecontrol[gc_director][0]) : NULL; - const char *item2 = gamecontrol[gc_director][1] != 0 ? G_KeynumToString(gamecontrol[gc_director][1]) : NULL; - - if (item1 != NULL && item2 != NULL) - snprintf(directortoggle, 32, "%s/%s - Toggle Director", item1, item2); - else - 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); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director")); } else { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Accelerate - Float")); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Brake - Sink")); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); } } } From 6b9900ad4ed25237bffa1f1f7187d0e76ce741c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:27:18 +0100 Subject: [PATCH 044/418] clean up cam stuff for good --- src/g_game.c | 1 - src/p_local.h | 2 -- src/p_user.c | 78 +++++++++++++++++++++------------------------------ 3 files changed, 32 insertions(+), 49 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 2c3e2fa02..f612b813d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -7868,7 +7868,6 @@ void G_StopDemo(void) camera[i].freecam = false; camera[i].localangle = 0; camera[i].localaiming = 0; - camera[i].keyboardlook = false; } CV_SetValue(&cv_playbackspeed, 1); diff --git a/src/p_local.h b/src/p_local.h index 13219c429..c2a2ee017 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -84,8 +84,6 @@ typedef struct camera_s angle_t localangle; INT32 localaiming; - boolean keyboardlook; // keyboard look - angle_t aiming; // Freecam: A button was held since entering from menu, so don't move camera diff --git a/src/p_user.c b/src/p_user.c index 37a5ee0df..1456f1cbf 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3155,12 +3155,12 @@ void P_ToggleDemoCamera(UINT8 viewnum) static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { - INT32 laim, forward, side, axis; //i + INT32 laim, th, tspeed, forward, side, axis; + // these ones used for multiple conditions boolean turnleft, turnright; - boolean usejoystick, kbl; + boolean usejoystick; angle_t lang; - INT32 screen_invert; const UINT8 forplayer = num+1; ticcmd_t *cmd = D_LocalTiccmd(num); @@ -3170,24 +3170,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) lang = cam->localangle; laim = cam->localaiming; - kbl = cam->keyboardlook; - - switch (num) - { - case 1: - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); - break; - case 2: - G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); - break; - case 3: - G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); - break; - case 0: - default: - G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver - break; - } cmd->angleturn = (INT16)(lang >> 16); cmd->aiming = G_ClipAimingPitch(&laim); @@ -3218,15 +3200,27 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) } forward = side = 0; + // use two stage accelerative turning + // on the keyboard and joystick + if (turnleft || turnright) + th += 1; + else + th = 0; + + if (th < SLOWTURNTICS) + tspeed = 2; // slow turn + else + tspeed = 1; + // let movement keys cancel each other out if (turnright && !(turnleft)) { - cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); + cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed])); side += sidemove[1]; } else if (turnleft && !(turnright)) { - cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); + cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed])); side -= sidemove[1]; } @@ -3251,32 +3245,22 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) cmd->buttons |= BT_ATTACK; // spectator aiming shit, ahhhh... - screen_invert = 1; // nope - - // mouse look stuff (mouse look is not the same as mouse aim) - kbl = false; // looking up/down - laim += (mlooky<<19)*screen_invert; + laim += (mlooky<<19); axis = JoyAxis(AXISLOOK, forplayer); if (analogjoystickmove && axis != 0 && lookaxis) - laim += (axis<<16) * screen_invert; - - // spring back if not using keyboard neither mouselookin' - if (!kbl && !lookaxis) - laim = 0; + laim += (axis<<16); if (InputDown(gc_lookup, forplayer) || (gamepadjoystickmove && axis < 0)) { - laim += KB_LOOKSPEED * screen_invert; - kbl = true; + laim += KB_LOOKSPEED; } else if (InputDown(gc_lookdown, forplayer) || (gamepadjoystickmove && axis > 0)) { - laim -= KB_LOOKSPEED * screen_invert; - kbl = true; + laim -= KB_LOOKSPEED; } if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V @@ -3306,7 +3290,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) cam->localangle = lang; cam->localaiming = laim; - cam->keyboardlook = kbl; return cmd; } @@ -3341,16 +3324,19 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (!cam->button_a_held) { fixed_t spd = 32*mapobjectscale*cv_freecam_speed.value; + int dir = ((InputDown(gc_camfloat, forplayer)) ? 1 : 0) + ((InputDown(gc_camsink, forplayer)) ? -1 : 0); - if (InputDown(gc_camfloat, forplayer)) + switch (dir) { - cam->z += spd; - moving = true; - } - else if (InputDown(gc_camsink, forplayer)) - { - cam->z -= spd; - moving = true; + case 1: + cam->z += spd; + moving = true; + break; + + case -1: + cam->z -= spd; + moving = true; + break; } } From 4110130ca7dc96980df6ad6b437cc393ce741057 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:36:36 +0100 Subject: [PATCH 045/418] block freecam toggling when player is in spec --- src/p_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 1456f1cbf..31f2820bb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3141,13 +3141,17 @@ void P_ToggleDemoCamera(UINT8 viewnum) { camera_t *cam = &camera[viewnum]; + // dont let freecam be toggled when in spec lel + if (players[displayplayers[viewnum]].spectator) + return; + if (!cam->freecam) // toggle on { cam->freecam = true; cam->button_a_held = 2; cam->reset_aiming = true; } - else // toggle off + else // toggle off { cam->freecam = false; } From 11546cd9060622bd858fb7b2ea750c399aa157da Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:37:10 +0100 Subject: [PATCH 046/418] fix centerview --- src/p_user.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 31f2820bb..22ea6454c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3315,6 +3315,10 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // first off we need to get button input cmd = P_CameraCmd(cam, num); + // let centerview work proper + if (InputDown(gc_centerview, forplayer)) + cam->aiming = 0; + if (cmd->aiming != 0) { cam->aiming = cmd->aiming << FRACBITS; From ca09a5dd465267d68c6a01b8982ac0c380dc6037 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:40:13 +0100 Subject: [PATCH 047/418] dont need to do this twice --- src/p_user.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 22ea6454c..7a9e1f67c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3390,24 +3390,6 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } } - if (rendermode == render_soft -#ifdef HWRENDER - || (rendermode == render_opengl && (cv_glshearing.value == 1)) -#endif - ) - { - // Extra restriction on this so it's not possible to - // distort the view too much. - if ((INT32)cam->aiming > ANGLE_45) - cam->aiming = ANGLE_45; - else if ((INT32)cam->aiming < -ANGLE_45) - cam->aiming = -ANGLE_45; - } - else - { - G_ClipAimingPitch((INT32 *)&cam->aiming); - } - cam->momx = cam->momy = cam->momz = 0; if (cmd->forwardmove != 0) { From 31a0122cd1fda470e576c9a088488a2a1ed327ff Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 15:34:10 +0100 Subject: [PATCH 048/418] add a bunch of extra checks into demo stuff buffer may be NULL in some cases should fix dedis crashing when replay recording is disabled --- src/g_game.c | 46 +++++++++++++++++++++++++++++++++++++--------- src/p_setup.c | 5 +++-- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index df30a1799..1b96ace10 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4784,6 +4784,7 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) if (!demobuf.p) return; + ziptic_p = demobuf.p++; // the ziptic, written at the end of this function if (cmd->forwardmove != oldcmd[playernum].forwardmove) @@ -4912,10 +4913,14 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim) void G_WriteAllGhostTics(void) { + if (!demobuf.p) + return; + UINT8 *save_demo_p = demobuf.p; #define CHECKSPACE(num) if (demobuf.p+(num) > demoend) { demobuf.p = save_demo_p; G_CheckDemoStatus(); return; } INT32 i, counter = leveltime; + for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator) @@ -4949,11 +4954,12 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) UINT8 sprite; UINT8 frame; + if (!demobuf.p) + return; + UINT8 *save_demo_p = demobuf.p; #define CHECKSPACE(num) if (demobuf.p+(num) > demoend) { demobuf.p = save_demo_p; G_CheckDemoStatus(); return; } - if (!demobuf.p) - return; if (!(demoflags & DF_GHOST)) return; // No ghost data to write. @@ -5146,6 +5152,9 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) void G_ConsAllGhostTics(void) { + if (!demobuf.p) + return; + UINT8 p = READUINT8(demobuf.p); while (p != 0xFF) @@ -5206,7 +5215,8 @@ void G_ConsGhostTic(INT32 playernum) demobuf.p++; if (ziptic & GZT_SPRITE) demobuf.p++; - if(ziptic & GZT_NIGHTS) { + if (ziptic & GZT_NIGHTS) + { if (!testmo || !testmo->player || !(testmo->player->pflags & PF_NIGHTSMODE) || !testmo->tracer) nightsfail = true; else @@ -6047,8 +6057,12 @@ void G_BeginRecording(void) UINT8 totalfiles; UINT8 *m; - if (demobuf.p) + if (!cv_recordmultiplayerdemos.value) return; + + if (demobuf.p || demobuf.buffer == NULL) + return; + memset(name,0,sizeof(name)); demobuf.p = demobuf.buffer; @@ -6058,7 +6072,7 @@ void G_BeginRecording(void) demoflags |= DF_ENCORE; if (!modeattacking && gL) // Ghosts don't read luavars, and you shouldn't ever need to save Lua in replays, you doof! - // SERIOUSLY THOUGH WHY WOULD YOU LOAD HOSTMOD AND RECORD A GHOST WITH IT !???? + // SERIOUSLY THOUGH WHY WOULD YOU LOAD HOSTMOD AND RECORD A GHOST WITH IT !???? demoflags |= DF_LUAVARS; // Setup header. @@ -6126,7 +6140,7 @@ void G_BeginRecording(void) break; } - WRITEUINT32(demobuf.p,P_GetInitSeed()); + WRITEUINT32(demobuf.p, P_GetInitSeed()); // Reserved for extrainfo location from start of file demoinfo_p = demobuf.p; @@ -6203,7 +6217,7 @@ void G_BeginMetal(void) { mobj_t *mo = players[consoleplayer].mo; - if (demobuf.p) + if (demobuf.p || demobuf.buffer == NULL) return; demobuf.p = demobuf.buffer; @@ -6231,7 +6245,10 @@ void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT { char temp[17]; - if (demoinfo_p && *(UINT32 *)demoinfo_p == 0) + if (!demobuf.p) + return; + + if (demoinfo_p && *(UINT32 *)demoinfo_p == 0 && demobuf.buffer != NULL) { WRITEUINT8(demobuf.p, DEMOMARKER); // add the demo end marker *(UINT32 *)demoinfo_p = demobuf.p - demobuf.buffer; @@ -6817,6 +6834,9 @@ void G_DoPlayDemo(char *defdemoname) boolean spectator; UINT8 slots[MAXPLAYERS], kartspeed[MAXPLAYERS], kartweight[MAXPLAYERS], numslots = 0; + if (demobuf.buffer == NULL) + return; + G_InitDemoRewind(); skin[16] = '\0'; @@ -7812,7 +7832,7 @@ void G_StopMetalDemo(void) ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void) { boolean saved = false; - if (demobuf.p) + if (demobuf.p && demobuf.buffer != NULL) { UINT8 *p = demobuf.buffer+16; // checksum position #ifdef NOMD5 @@ -7974,6 +7994,14 @@ void G_SaveDemo(void) return; } + if (demobuf.buffer == NULL) + { + CONS_Alert(CONS_ERROR, "Failed to save Demo. No Demo buffer allocated!\n"); + // reset the demo buffer + G_ResetDemoRecording(); + return; + } + UINT8 *p = demobuf.buffer+16; // after version UINT32 length; #ifdef NOMD5 diff --git a/src/p_setup.c b/src/p_setup.c index 58fd66208..468ecbaf6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2969,8 +2969,9 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) : mapheaderinfo[gamemap - 1]->numlaps); // Start recording replay in multiplayer with a temp filename - //Ensure dedis only record a replay if there is a player at the start of the map, otherwise we get invalid replays! - if (!demo.playback && multiplayer && D_NumPlayers()) { + // Ensure dedis only record a replay if there is a player at the start of the map, otherwise we get invalid replays! + if (!demo.playback && multiplayer && D_NumPlayers()) + { static char buf[256]; sprintf(buf, "replay"PATHSEP"online"PATHSEP"%d-%s", (int) (time(NULL)), G_BuildMapName(gamemap)); From 55c7dd860c285defed644ab03b6548cdedc963a6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 15:39:39 +0100 Subject: [PATCH 049/418] fix offbyone issue --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 0d88c3743..1030c6e60 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1800,7 +1800,7 @@ void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive) oldview = (*displayplayerp); // turn off the freecam - camera[viewnum].freecam = false; + camera[viewnum-1].freecam = false; G_ResetView(viewnum, ( (*displayplayerp) + offset ), onlyactive); From 267e2be69b6a34f42e2b741d86f9642d699c7ada Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 15:39:39 +0100 Subject: [PATCH 050/418] fix offbyone issue --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 961dfbf8f..6732e8c70 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1786,7 +1786,7 @@ void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive) oldview = (*displayplayerp); // turn off the freecam - camera[viewnum].freecam = false; + camera[viewnum-1].freecam = false; G_ResetView(viewnum, ( (*displayplayerp) + offset ), onlyactive); From b23020435f58636fb54957c7dea8509d7323cc28 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 16:43:09 +0100 Subject: [PATCH 051/418] replace all this crap with either stplyrnum or R_GetViewNumber --- src/hardware/hw_main.c | 6 ++--- src/k_kart.c | 59 +++++++++++++++++------------------------- src/lua_hudlib.c | 2 +- src/r_bsp.c | 16 +++--------- src/st_stuff.c | 8 +++--- 5 files changed, 34 insertions(+), 57 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5eefc9c7e..638b450a2 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3232,11 +3232,11 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) angle_t shadowdir; // Set direction - if (splitscreen && stplyr == &players[displayplayers[1]]) + if (splitscreen && R_GetViewNumber() == 1) shadowdir = localangle[1] + FixedAngle(cv_cam_rotate[1].value); - else if (splitscreen > 1 && stplyr == &players[displayplayers[2]]) + else if (splitscreen > 1 && R_GetViewNumber() == 2) shadowdir = localangle[2] + FixedAngle(cv_cam_rotate[2].value); - else if (splitscreen > 2 && stplyr == &players[displayplayers[3]]) + else if (splitscreen > 2 && R_GetViewNumber() == 3) shadowdir = localangle[3] + FixedAngle(cv_cam_rotate[3].value); else shadowdir = localangle[0] + FixedAngle(cv_cam_rotate[0].value); diff --git a/src/k_kart.c b/src/k_kart.c index 7a9f43f55..f386b5ad9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7618,17 +7618,17 @@ INT32 K_calcSplitFlags(INT32 snapflags) if (splitscreen == 0) return snapflags; - if (stplyr != &players[displayplayers[0]]) + if (stplyrnum != 0) { - if (splitscreen == 1 && stplyr == &players[displayplayers[1]]) + if (splitscreen == 1 && stplyrnum == 1) { splitflags |= V_SPLITSCREEN; } else if (splitscreen > 1) { - if (stplyr == &players[displayplayers[2]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]])) + if (stplyrnum == 2 || (splitscreen == 3 && stplyrnum == 3)) splitflags |= V_SPLITSCREEN; - if (stplyr == &players[displayplayers[1]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]])) + if (stplyrnum == 1 || (splitscreen == 3 && stplyrnum == 3)) splitflags |= V_HORZSCREEN; } } @@ -7748,7 +7748,7 @@ static void K_drawKartStats(void) for (; splitnum < MAXSPLITSCREENPLAYERS; ++splitnum) { - if (stplyr == &players[displayplayers[splitnum]]) + if (stplyrnum == splitnum) break; } @@ -8334,7 +8334,7 @@ static void K_DrawKartPositionNum(INT32 num) else if (splitscreen == 1) // for this splitscreen, we'll use case by case because it's a bit different. { fx = POSI_X; - if (stplyr == &players[displayplayers[0]]) // for player 1: display this at the top right, above the minimap. + if (stplyrnum == 0) // for player 1: display this at the top right, above the minimap. { fy = 30 + cv_posi_yoffset.value; fflags = V_SNAPTOTOP|V_SNAPTORIGHT; @@ -8349,11 +8349,11 @@ static void K_DrawKartPositionNum(INT32 num) } else { - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... + if (!(stplyrnum & 1)) // If we are P1 or P3... { fx = POSI_X; fy = POSI_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. + fflags = V_SNAPTOLEFT|((stplyrnum == 2) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. flipdraw = true; if (num && num >= 10) fx += W; // this seems dumb, but we need to do this in order for positions above 10 going off screen. @@ -8362,7 +8362,7 @@ static void K_DrawKartPositionNum(INT32 num) { fx = POSI2_X; fy = POSI2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom + fflags = V_SNAPTORIGHT|((stplyrnum == 3) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom } } @@ -9311,7 +9311,7 @@ static void K_drawDriftGauge(void) 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 }; - if (demo.playback && camera[R_GetViewNumber()].freecam) + if (demo.playback && camera[stplyrnum].freecam) return; if (P_MobjWasRemoved(stplyr->mo) || (!splitscreen && !camera->chase)) @@ -9469,7 +9469,7 @@ static void K_drawKartWanted(void) UINT8 *colormap = NULL; INT32 basex = 0, basey = 0; - if (stplyr != &players[displayplayers[0]]) + if (stplyrnum != 0) return; for (i = 0; i < 4; i++) @@ -9666,7 +9666,7 @@ static void K_drawKartMinimap(void) if (gamestate != GS_LEVEL) return; - if (stplyr != &players[displayplayers[0]]) + if (stplyrnum != 0) return; if (minimapinfo.minimap_pic == NULL) @@ -9828,7 +9828,7 @@ static void K_drawKartFinish(void) xval = (SHORT(kp_racefinish[pnum]->width)<kartstuff[k_cardanimation])< x ? xval : x))/TICRATE; - if (splitscreen && stplyr == &players[displayplayers[1]]) + if (splitscreen && stplyrnum == 1) x = -x; V_DrawFixedPatch(x + (STCD_X<>1), @@ -9985,14 +9985,9 @@ static void K_drawKartFirstPerson(void) if (stplyr->spectator || !stplyr->mo || (stplyr->mo->flags2 & MF2_DONTDRAW)) return; - if (stplyr == &players[displayplayers[1]] && splitscreen) - { pn = pnum[1]; tn = turn[1]; dr = drift[1]; } - else if (stplyr == &players[displayplayers[2]] && splitscreen > 1) - { pn = pnum[2]; tn = turn[2]; dr = drift[2]; } - else if (stplyr == &players[displayplayers[3]] && splitscreen > 2) - { pn = pnum[3]; tn = turn[3]; dr = drift[3]; } - else - { pn = pnum[0]; tn = turn[0]; dr = drift[0]; } + pn = pnum[stplyrnum]; + tn = turn[stplyrnum]; + dr = drift[stplyrnum]; if (splitscreen) { @@ -10114,14 +10109,9 @@ static void K_drawKartFirstPerson(void) V_DrawFixedPatch(x, y, scale, splitflags, kp_fpview[target], colmap); - if (stplyr == &players[displayplayers[1]] && splitscreen) - { pnum[1] = pn; turn[1] = tn; drift[1] = dr; } - else if (stplyr == &players[displayplayers[2]] && splitscreen > 1) - { pnum[2] = pn; turn[2] = tn; drift[2] = dr; } - else if (stplyr == &players[displayplayers[3]] && splitscreen > 2) - { pnum[3] = pn; turn[3] = tn; drift[3] = dr; } - else - { pnum[0] = pn; turn[0] = tn; drift[0] = dr; } + pnum[stplyrnum] = pn; + turn[stplyrnum] = tn; + drift[stplyrnum] = dr; } // doesn't need to ever support 4p @@ -10341,7 +10331,7 @@ static void K_drawDistributionDebugger(void) boolean dontforcespb = false; boolean spbrush = false; - if (stplyr != &players[displayplayers[0]]) // only for p1 + if (stplyrnum != 0) // only for p1 return; // The only code duplication from the Kart, just to avoid the actual item function from calculating pingame twice @@ -10405,7 +10395,7 @@ static void K_drawDistributionDebugger(void) static void K_drawCheckpointDebugger(void) { - if (stplyr != &players[displayplayers[0]]) // only for p1 + if (stplyrnum != 0) // only for p1 return; if (stplyr->starpostnum >= (numstarposts - (numstarposts/2))) @@ -10419,19 +10409,18 @@ void K_drawKartHUD(void) { boolean isfreeplay = false; boolean battlefullscreen = false; - UINT8 viewnum = R_GetViewNumber(); - boolean freecam = camera[viewnum].freecam; //disable some hud elements w/ freecam + boolean freecam = camera[stplyrnum].freecam; //disable some hud elements w/ freecam // Define the X and Y for each drawn object // This is handled by console/menu values K_initKartHUD(); // Draw that fun first person HUD! Drawn ASAP so it looks more "real". - if (!camera[viewnum].chase && !freecam) + if (!camera[stplyrnum].chase && !freecam) K_drawKartFirstPerson(); // Draw full screen stuff that turns off the rest of the HUD - if (mapreset && R_GetViewNumber() == 0) + if (mapreset && stplyrnum == 0) { K_drawChallengerScreen(); return; diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index f3c01f4eb..708eb8740 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -649,7 +649,7 @@ static int libd_drawOnMinimap(lua_State *L) if (gamestate != GS_LEVEL) return 0; - if (stplyr != &players[displayplayers[0]]) + if (stplyrnum != 0) return 0; AutomapPic = minimapinfo.minimap_pic; diff --git a/src/r_bsp.c b/src/r_bsp.c index db6a4378d..dbb6fb4d3 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -263,21 +263,11 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, mobj_t *pviewmobj = viewplayer->mo; INT32 heightsec; boolean underwater; - UINT8 i; - - for (i = 0; i <= splitscreen; i++) - { - if (viewplayer != &players[displayplayers[i]]) - continue; - - if (!camera[i].chase) - continue; + UINT8 i = R_GetViewNumber(); + if (camera[i].chase) heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; - break; - } - - if (i > splitscreen && pviewmobj) + else if (i > splitscreen && viewmobj) heightsec = R_PointInSubsector(pviewmobj->x, pviewmobj->y)->sector->heightsec; else return sec; diff --git a/src/st_stuff.c b/src/st_stuff.c index da5628827..d5d438414 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -671,8 +671,6 @@ static const char *ST_GetButtonName(INT32 control, const char *inputtext) // static void ST_overlayDrawer(void) { - const UINT8 viewnum = R_GetViewNumber(); - //hu_showscores = auto hide score/time/rings when tab rankings are shown if (!(hu_showscores && (netgame || multiplayer))) { @@ -681,7 +679,7 @@ static void ST_overlayDrawer(void) if (!hu_showscores) // hide the following if TAB is held { - if (cv_showdirectorhud.value && !splitscreen && ((demo.playback && !camera[viewnum].freecam && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !K_DirectorIsPlayerAlone()) + if (cv_showdirectorhud.value && !splitscreen && ((demo.playback && !camera[stplyrnum].freecam && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !K_DirectorIsPlayerAlone()) { char directortext[20] = {0}; @@ -721,7 +719,7 @@ static void ST_overlayDrawer(void) V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_SNAPTOBOTTOM|V_HUDTRANS|V_ALLOWLOWERCASE, player_names[stplyr-players]); } } - else if (!demo.title && !demo.freecam) + else if (!demo.title && !camera[stplyrnum].freecam) { if (!splitscreen) { @@ -732,7 +730,7 @@ static void ST_overlayDrawer(void) { char name[MAXPLAYERNAME+12]; - INT32 y = (stplyr == &players[displayplayers[0]]) ? 4 : BASEVIDHEIGHT/2-12; + INT32 y = (stplyrnum == 0) ? 4 : BASEVIDHEIGHT/2-12; sprintf(name, "VIEWPOINT: %s", player_names[stplyr-players]); V_DrawRightAlignedThinString(BASEVIDWIDTH-40, y, V_HUDTRANSHALF|V_ALLOWLOWERCASE|K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOBOTTOM|V_SNAPTORIGHT), name); } From 26480882c847713ef32784ff8dc2fcd8df7a19b4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 16:43:34 +0100 Subject: [PATCH 052/418] remove the remainder or demo.freecam --- src/k_director.c | 2 +- src/m_menu.c | 19 +++++++++---------- src/p_setup.c | 6 +++++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index dafea6072..1385754f0 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -69,7 +69,7 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) static boolean K_DirectorIsEnabled(void) { - return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !demo.freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone()); + return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !camera[0].freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone()); } void K_InitDirector(void) diff --git a/src/m_menu.c b/src/m_menu.c index 0bfacba82..3c7153d2c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4033,19 +4033,19 @@ boolean M_Responder(event_t *ev) // switch viewpoints: case '1': // viewpoint for p1 (also f12) // maximum laziness: - if (!demo.freecam) + if (!camera[0].freecam) G_AdjustView(1, 1, true); break; case '2': // viewpoint for p2 - if (!demo.freecam) + if (!camera[1].freecam) G_AdjustView(2, 1, true); break; case '3': // viewpoint for p3 - if (!demo.freecam) + if (!camera[2].freecam) G_AdjustView(3, 1, true); break; case '4': // viewpoint for p4 - if (!demo.freecam) + if (!camera[3].freecam) G_AdjustView(4, 1, true); break; @@ -4272,19 +4272,19 @@ boolean M_DemoResponder(event_t *ev) // switch viewpoints: case '1': // viewpoint for p1 (also f12) // maximum laziness: - if (!demo.freecam) + if (!camera[0].freecam) G_AdjustView(1, 1, true); break; case '2': // viewpoint for p2 - if (!demo.freecam) + if (!camera[1].freecam) G_AdjustView(2, 1, true); break; case '3': // viewpoint for p3 - if (!demo.freecam) + if (!camera[2].freecam) G_AdjustView(3, 1, true); break; case '4': // viewpoint for p4 - if (!demo.freecam) + if (!camera[3].freecam) G_AdjustView(4, 1, true); break; @@ -7691,8 +7691,7 @@ static void M_PlaybackAdvance(INT32 choice) static void M_PlaybackSetViews(INT32 choice) { - - if (demo.freecam) + if (camera[0].freecam || camera[1].freecam || camera[2].freecam || camera[3].freecam) return; // not here. if (choice > 0) diff --git a/src/p_setup.c b/src/p_setup.c index b87c6e843..bcfb20978 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2474,9 +2474,13 @@ static void P_InitCamera(void) if (!dedicated) { - if (!demo.freecam) for (i = 0; i <= splitscreen; i++) + { + if (camera[i].freecam) + continue; + P_SetupCamera(displayplayers[i], &camera[i]); + } // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) From 27d6447a83393f0250b8a6d0d7caf79439300285 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 16:51:07 +0100 Subject: [PATCH 053/418] fix wrong cam default controls --- src/g_input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 606f20770..b99874b8d 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1143,8 +1143,8 @@ void G_Controldefault(UINT8 player) gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up - gamecontrol[gc_camfloat ][1] = 'a'; - gamecontrol[gc_camsink ][1] = 'd'; + gamecontrol[gc_camfloat ][0] = 'a'; + gamecontrol[gc_camsink ][0] = 'd'; gamecontrol[gc_camfloat ][1] = KEY_JOY1+0; // A gamecontrol[gc_camsink ][1] = KEY_JOY1+1; // B From ac90a0973df5c81a49fc3c70ff834597e1784d03 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 16:51:07 +0100 Subject: [PATCH 054/418] fix wrong cam default controls --- src/g_input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 606f20770..b99874b8d 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1143,8 +1143,8 @@ void G_Controldefault(UINT8 player) gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up - gamecontrol[gc_camfloat ][1] = 'a'; - gamecontrol[gc_camsink ][1] = 'd'; + gamecontrol[gc_camfloat ][0] = 'a'; + gamecontrol[gc_camsink ][0] = 'd'; gamecontrol[gc_camfloat ][1] = KEY_JOY1+0; // A gamecontrol[gc_camsink ][1] = KEY_JOY1+1; // B From f6d83c17bda16e58b86f5c99df839c6d6413eb6a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 17:14:47 +0100 Subject: [PATCH 055/418] fix demo playback --- src/g_game.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 1030c6e60..5ee31ffd3 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6858,9 +6858,6 @@ void G_DoPlayDemo(char *defdemoname) boolean spectator; UINT8 slots[MAXPLAYERS], kartspeed[MAXPLAYERS], kartweight[MAXPLAYERS], numslots = 0; - if (demobuf.buffer == NULL) - return; - G_InitDemoRewind(); skin[16] = '\0'; From 6101ded74ae9ce3d1986b4dd5c79cb595b0ebcb4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 17:56:35 +0100 Subject: [PATCH 056/418] allocate some extra buffer for demobuffer incase this might overflow that we dont write to unvalid memory thx indev <3 --- src/g_game.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 76b2e295e..14c095228 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6044,7 +6044,7 @@ void G_RecordDemo(const char *name) maxsize = cv_maxdemosize.value*1024*1024; - demobuf.buffer = Z_Malloc(maxsize, PU_STATIC, NULL); + demobuf.buffer = Z_Malloc(maxsize + 100*1024, PU_STATIC, NULL); demoend = demobuf.buffer + maxsize; if (demobuf.buffer) @@ -6062,7 +6062,7 @@ void G_RecordMetal(void) Z_Free(demobuf.buffer); demobuf.p = NULL; metalrecording = false; - demobuf.buffer = Z_Malloc(maxsize, PU_STATIC, NULL); + demobuf.buffer = Z_Malloc(maxsize + 100*1024, PU_STATIC, NULL); demoend = demobuf.buffer + maxsize; if (demobuf.buffer) From cd566ac9c070b49a98d0d134dcae95a59296359e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Dec 2024 23:24:23 +0100 Subject: [PATCH 057/418] refactor intermission standings drawer abstract the data stuff too --- src/y_inter.c | 450 +++++++++++++++++++++++++------------------------- src/y_inter.h | 17 ++ 2 files changed, 240 insertions(+), 227 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 61f4a069b..fc06c5fca 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -55,27 +55,8 @@ typedef struct UINT8 display; } y_bonus_t; -typedef union -{ - struct - { - UINT8 *color[MAXPLAYERS]; // Winner's color # - INT32 *character[MAXPLAYERS]; // Winner's character # - INT32 num[MAXPLAYERS]; // Winner's player # - char *name[MAXPLAYERS]; // Winner's name - INT32 numplayers; // Number of players being displayed - char levelstring[64]; // holds levelnames up to 64 characters - // SRB2kart - UINT8 increase[MAXPLAYERS]; // how much did the score increase by? - UINT8 jitter[MAXPLAYERS]; // wiggle - UINT32 val[MAXPLAYERS]; // Gametype-specific value - UINT8 pos[MAXPLAYERS]; // player positions. used for ties - boolean rankingsmode; // rankings mode - boolean encore; // encore mode - } match; -} y_data; +static y_data_t data; -static y_data data; // graphics static patch_t *bgpatch = NULL; // INTERSCR @@ -159,11 +140,11 @@ static void Y_CompareRace(INT32 i) UINT32 val = ((players[i].pflags & PF_TIMEOVER || players[i].realtime == UINT32_MAX) ? (UINT32_MAX-1) : players[i].realtime); - if (!(val < data.match.val[data.match.numplayers])) + if (!(val < data.val[data.numplayers])) return; - data.match.val[data.match.numplayers] = val; - data.match.num[data.match.numplayers] = i; + data.val[data.numplayers] = val; + data.num[data.numplayers] = i; } static void Y_CompareBattle(INT32 i) @@ -171,22 +152,22 @@ static void Y_CompareBattle(INT32 i) UINT32 val = ((players[i].pflags & PF_TIMEOVER) ? (UINT32_MAX-1) : players[i].marescore); - if (!(data.match.val[data.match.numplayers] == UINT32_MAX - || (!(players[i].pflags & PF_TIMEOVER) && val > data.match.val[data.match.numplayers]))) + if (!(data.val[data.numplayers] == UINT32_MAX + || (!(players[i].pflags & PF_TIMEOVER) && val > data.val[data.numplayers]))) return; - data.match.val[data.match.numplayers] = val; - data.match.num[data.match.numplayers] = i; + data.val[data.numplayers] = val; + data.num[data.numplayers] = i; } static void Y_CompareRank(INT32 i) { - UINT8 increase = ((data.match.increase[i] == UINT8_MAX) ? 0 : data.match.increase[i]); - if (!(data.match.val[data.match.numplayers] == UINT32_MAX || (players[i].score - increase) > data.match.val[data.match.numplayers])) + UINT8 increase = ((data.increase[i] == UINT8_MAX) ? 0 : data.increase[i]); + if (!(data.val[data.numplayers] == UINT32_MAX || (players[i].score - increase) > data.val[data.numplayers])) return; - data.match.val[data.match.numplayers] = (players[i].score - increase); - data.match.num[data.match.numplayers] = i; + data.val[data.numplayers] = (players[i].score - increase); + data.num[data.numplayers] = i; } static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) @@ -198,10 +179,10 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) // Initialize variables if (rankingsmode > 1) ; - else if ((data.match.rankingsmode = (boolean)rankingsmode)) + else if ((data.rankingsmode = (boolean)rankingsmode)) { - sprintf(data.match.levelstring, "* Total Rankings *"); - data.match.encore = false; + sprintf(data.levelstring, "* Total Rankings *"); + data.encore = false; } else { @@ -209,13 +190,13 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) if (mapheaderinfo[prevmap]->levelflags & LF_NOZONE) { if (mapheaderinfo[prevmap]->actnum[0]) - snprintf(data.match.levelstring, - sizeof data.match.levelstring, + snprintf(data.levelstring, + sizeof data.levelstring, "* %s %s *", mapheaderinfo[prevmap]->lvlttl, mapheaderinfo[prevmap]->actnum); else - snprintf(data.match.levelstring, - sizeof data.match.levelstring, + snprintf(data.levelstring, + sizeof data.levelstring, "* %s *", mapheaderinfo[prevmap]->lvlttl); } @@ -223,44 +204,44 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) { const char *zonttl = (mapheaderinfo[prevmap]->zonttl[0] ? mapheaderinfo[prevmap]->zonttl : "Zone"); if (mapheaderinfo[prevmap]->actnum[0]) - snprintf(data.match.levelstring, - sizeof data.match.levelstring, + snprintf(data.levelstring, + sizeof data.levelstring, "* %s %s %s *", mapheaderinfo[prevmap]->lvlttl, zonttl, mapheaderinfo[prevmap]->actnum); else - snprintf(data.match.levelstring, - sizeof data.match.levelstring, + snprintf(data.levelstring, + sizeof data.levelstring, "* %s %s *", mapheaderinfo[prevmap]->lvlttl, zonttl); } - data.match.levelstring[sizeof data.match.levelstring - 1] = '\0'; + data.levelstring[sizeof data.levelstring - 1] = '\0'; - data.match.encore = encoremode; + data.encore = encoremode; - memset(data.match.jitter, 0, sizeof (data.match.jitter)); + memset(data.jitter, 0, sizeof (data.jitter)); } for (i = 0; i < MAXPLAYERS; i++) { - data.match.val[i] = UINT32_MAX; + data.val[i] = UINT32_MAX; if (!playeringame[i] || players[i].spectator) { - data.match.increase[i] = UINT8_MAX; + data.increase[i] = UINT8_MAX; continue; } if (!rankingsmode) - data.match.increase[i] = UINT8_MAX; + data.increase[i] = UINT8_MAX; numplayersingame++; } - memset(data.match.color, 0, sizeof (data.match.color)); - memset(data.match.character, 0, sizeof (data.match.character)); + memset(data.color, 0, sizeof (data.color)); + memset(data.character, 0, sizeof (data.character)); memset(completed, 0, sizeof (completed)); - data.match.numplayers = 0; + data.numplayers = 0; for (j = 0; j < numplayersingame; j++) { @@ -274,35 +255,35 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) comparison(i); } - i = data.match.num[data.match.numplayers]; + i = data.num[data.numplayers]; completed[i] = true; - data.match.color[data.match.numplayers] = &players[i].skincolor; - data.match.character[data.match.numplayers] = &players[i].skin; - data.match.name[data.match.numplayers] = player_names[i]; + data.color[data.numplayers] = &players[i].skincolor; + data.character[data.numplayers] = &players[i].skin; + data.name[data.numplayers] = player_names[i]; - if (data.match.numplayers && (data.match.val[data.match.numplayers] == data.match.val[data.match.numplayers-1])) - data.match.pos[data.match.numplayers] = data.match.pos[data.match.numplayers-1]; + if (data.numplayers && (data.val[data.numplayers] == data.val[data.numplayers-1])) + data.pos[data.numplayers] = data.pos[data.numplayers-1]; else - data.match.pos[data.match.numplayers] = data.match.numplayers+1; + data.pos[data.numplayers] = data.numplayers+1; - if (!rankingsmode && !(players[i].pflags & PF_TIMEOVER) && (data.match.pos[data.match.numplayers] < nump)) + if (!rankingsmode && !(players[i].pflags & PF_TIMEOVER) && (data.pos[data.numplayers] < nump)) { - data.match.increase[i] = nump - data.match.pos[data.match.numplayers]; - players[i].score += data.match.increase[i]; + data.increase[i] = nump - data.pos[data.numplayers]; + players[i].score += data.increase[i]; } if (demo.recording && !rankingsmode) G_WriteStanding( - data.match.pos[data.match.numplayers], - data.match.name[data.match.numplayers], - *data.match.character[data.match.numplayers], - *data.match.color[data.match.numplayers], - data.match.val[data.match.numplayers] + data.pos[data.numplayers], + data.name[data.numplayers], + *data.character[data.numplayers], + *data.color[data.numplayers], + data.val[data.numplayers] ); - data.match.numplayers++; + data.numplayers++; } } @@ -353,6 +334,169 @@ static void Y_AnimatedVoteScreenCheck(void) } } +// Y_PlayerStandingsDrawer +// +// Handles drawing the center-of-screen player standings. +// +void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) +{ + if (standings->numplayers == 0) + { + return; + } + + INT32 i, whiteplayer = MAXPLAYERS; + + if (!splitscreen) + whiteplayer = (demo.playback ? displayplayers[0] : consoleplayer); + +#define NUMFORNEWCOLUMN 8 + INT32 y = 41, gutter = ((standings->numplayers > NUMFORNEWCOLUMN) ? 0 : (BASEVIDWIDTH/2)); + INT32 dupadjust = cv_betainterscreen.value ? 314 : (vid.width/vid.dupx), duptweak = cv_betainterscreen.value ? -3 : (dupadjust - BASEVIDWIDTH)/2; + const char *timeheader; + + if (standings->rankingsmode) + timeheader = "RANK"; + else + timeheader = (intertype == int_race ? "TIME" : "SCORE"); + + // draw the level name + V_DrawCenteredString(-4 + x + BASEVIDWIDTH/2, 12, 0, standings->levelstring); + V_DrawFill((x-3) - duptweak, 34, dupadjust-2, 1, 0); + + if (standings->encore) + V_DrawCenteredString(-4 + x + BASEVIDWIDTH/2, 12-8, hilicol, "ENCORE MODE"); + + if (standings->numplayers > NUMFORNEWCOLUMN) + { + V_DrawFill(x+156, 24, 1, 158, 0); + V_DrawFill((x-3) - duptweak, 182, dupadjust-2, 1, 0); + + V_DrawCenteredString(x+6+(BASEVIDWIDTH/2), 24, hilicol, "#"); + V_DrawString(x+36+(BASEVIDWIDTH/2), 24, hilicol, "NAME"); + + V_DrawRightAlignedString(x+152, 24, hilicol, timeheader); + } + + V_DrawCenteredString(x+6, 24, hilicol, "#"); + V_DrawString(x+36, 24, hilicol, "NAME"); + + V_DrawRightAlignedString(x+(BASEVIDWIDTH/2)+152, 24, hilicol, timeheader); + + for (i = 0; i < standings->numplayers; i++) + { + if (standings->num[i] != MAXPLAYERS && playeringame[standings->num[i]] && !players[standings->num[i]].spectator) + { + char strtime[MAXPLAYERNAME+1]; + + // Apply the jitter offset (later reversed) + if (standings->jitter[standings->num[i]] > 0) + y--; + + V_DrawCenteredString(x+6, y, 0, va("%d", standings->pos[i])); + + if (standings->color[i] != SKINCOLOR_NONE) + { + UINT8 *colormap = R_GetTranslationColormap(*standings->character[i], *standings->color[i], GTC_CACHE); + // i fucking hate this i fucking hate this i hate this so much + if (!players[standings->num[i]].skinlocal) + { + int skinIndex = players[standings->num[i]].localskin ? players[standings->num[i]].localskin - 1 : *standings->character[i]; + + if (cv_highresportrait.value) + V_DrawSmallMappedPatch(x + 16, y - 4, 0, facewantprefix[skinIndex], colormap); + else + V_DrawMappedPatch(x + 16, y - 4, 0, facerankprefix[skinIndex], colormap); + } + else + { + if (cv_highresportrait.value) + V_DrawSmallMappedPatch(x + 16, y - 4, 0, localfacewantprefix[players[standings->num[i]].localskin - 1], colormap); + else + V_DrawMappedPatch(x + 16, y - 4, 0, localfacerankprefix[players[standings->num[i]].localskin - 1], colormap); + } + } + + if (standings->num[i] == whiteplayer) + { + UINT8 cursorframe = (intertic / 4) % 8; + V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); + } + + STRBUFCPY(strtime, standings->name[i]); + + if (standings->numplayers > NUMFORNEWCOLUMN) + V_DrawThinString(x+36, y-1, ((standings->num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); + else + V_DrawString(x+36, y, ((standings->num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); + + if (standings->rankingsmode) + { + if (standings->increase[standings->num[i]] != UINT8_MAX) + { + if (standings->increase[standings->num[i]] > 9) + snprintf(strtime, sizeof strtime, "(+%02d)", standings->increase[standings->num[i]]); + else + snprintf(strtime, sizeof strtime, "(+ %d)", standings->increase[standings->num[i]]); + + if (standings->numplayers > NUMFORNEWCOLUMN) + V_DrawRightAlignedThinString(x+135+gutter, y-1, V_6WIDTHSPACE, strtime); + else + V_DrawRightAlignedString(x+120+gutter, y, 0, strtime); + } + + snprintf(strtime, sizeof strtime, "%d", standings->val[i]); + + if (standings->numplayers > NUMFORNEWCOLUMN) + V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); + else + V_DrawRightAlignedString(x+152+gutter, y, 0, strtime); + } + else + { + if (standings->val[i] == (UINT32_MAX-1)) + V_DrawRightAlignedThinString(x+152+gutter, y-1, (standings->numplayers > NUMFORNEWCOLUMN ? V_6WIDTHSPACE : 0), "NO CONTEST."); + else + { + if (intertype == int_race) + { + snprintf(strtime, sizeof strtime, "%i'%02i\"%02i", G_TicsToMinutes(standings->val[i], true), + G_TicsToSeconds(standings->val[i]), G_TicsToCentiseconds(standings->val[i])); + strtime[sizeof strtime - 1] = '\0'; + + if (standings->numplayers > NUMFORNEWCOLUMN) + V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); + else + V_DrawRightAlignedString(x+152+gutter, y, 0, strtime); + } + else + { + if (standings->numplayers > NUMFORNEWCOLUMN) + V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, va("%i", standings->val[i])); + else + V_DrawRightAlignedString(x+152+gutter, y, 0, va("%i", standings->val[i])); + } + } + } + + // Apply the jitter offset (later reversed) + if (standings->jitter[standings->num[i]] > 0) + y++; + } + else + standings->num[i] = MAXPLAYERS; // this should be the only field setting in this function + + y += 18; + + if (i == NUMFORNEWCOLUMN-1) + { + y = 41; + x += BASEVIDWIDTH/2; + } +#undef NUMFORNEWCOLUMN + } +} + // // Y_IntermissionDrawer // @@ -361,7 +505,7 @@ static void Y_AnimatedVoteScreenCheck(void) // void Y_IntermissionDrawer(void) { - INT32 i, whiteplayer = MAXPLAYERS, x = 4, hilicol = V_YELLOWMAP; // fallback + INT32 x = 4, hilicol = V_YELLOWMAP; // fallback if (intertype == int_none || rendermode == render_none) return; @@ -385,9 +529,6 @@ void Y_IntermissionDrawer(void) // Fade everything out V_DrawFadeScreen(0xFF00, 22); - if (!splitscreen) - whiteplayer = demo.playback ? displayplayers[0] : consoleplayer; - if (cons_menuhighlight.value) hilicol = cons_menuhighlight.value; else if (modeattacking) @@ -407,152 +548,7 @@ void Y_IntermissionDrawer(void) } if (intertype == int_race || intertype == int_match) - { -#define NUMFORNEWCOLUMN 8 - INT32 y = 41, gutter = ((data.match.numplayers > NUMFORNEWCOLUMN) ? 0 : (BASEVIDWIDTH/2)); - INT32 dupadjust = cv_betainterscreen.value ? 314 : (vid.width/vid.dupx), duptweak = cv_betainterscreen.value ? -3 : (dupadjust - BASEVIDWIDTH)/2; - const char *timeheader; - - if (data.match.rankingsmode) - timeheader = "RANK"; - else - timeheader = (intertype == int_race ? "TIME" : "SCORE"); - - // draw the level name - V_DrawCenteredString(-4 + x + BASEVIDWIDTH/2, 12, 0, data.match.levelstring); - V_DrawFill((x-3) - duptweak, 34, dupadjust-2, 1, 0); - - if (data.match.encore) - V_DrawCenteredString(-4 + x + BASEVIDWIDTH/2, 12-8, hilicol, "ENCORE MODE"); - - if (data.match.numplayers > NUMFORNEWCOLUMN) - { - V_DrawFill(x+156, 24, 1, 158, 0); - V_DrawFill((x-3) - duptweak, 182, dupadjust-2, 1, 0); - - V_DrawCenteredString(x+6+(BASEVIDWIDTH/2), 24, hilicol, "#"); - V_DrawString(x+36+(BASEVIDWIDTH/2), 24, hilicol, "NAME"); - - V_DrawRightAlignedString(x+152, 24, hilicol, timeheader); - } - - V_DrawCenteredString(x+6, 24, hilicol, "#"); - V_DrawString(x+36, 24, hilicol, "NAME"); - - V_DrawRightAlignedString(x+(BASEVIDWIDTH/2)+152, 24, hilicol, timeheader); - - for (i = 0; i < data.match.numplayers; i++) - { - if (data.match.num[i] != MAXPLAYERS && playeringame[data.match.num[i]] && !players[data.match.num[i]].spectator) - { - char strtime[MAXPLAYERNAME+1]; - - // Apply the jitter offset (later reversed) - if (data.match.jitter[data.match.num[i]] > 0) - y--; - - V_DrawCenteredString(x+6, y, 0, va("%d", data.match.pos[i])); - - if (data.match.color[i]) - { - UINT8 *colormap = R_GetTranslationColormap(*data.match.character[i], *data.match.color[i], GTC_CACHE); - // i fucking hate this i fucking hate this i hate this so much - if (!players[data.match.num[i]].skinlocal) - { - int skinIndex = players[data.match.num[i]].localskin ? players[data.match.num[i]].localskin - 1 : *data.match.character[i]; - - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x + 16, y - 4, 0, facewantprefix[skinIndex], colormap); - else - V_DrawMappedPatch(x + 16, y - 4, 0, facerankprefix[skinIndex], colormap); - } - else - { - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x + 16, y - 4, 0, localfacewantprefix[players[data.match.num[i]].localskin - 1], colormap); - else - V_DrawMappedPatch(x + 16, y - 4, 0, localfacerankprefix[players[data.match.num[i]].localskin - 1], colormap); - } - } - - if (data.match.num[i] == whiteplayer) - { - UINT8 cursorframe = (intertic / 4) % 8; - V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); - } - - STRBUFCPY(strtime, data.match.name[i]); - - if (data.match.numplayers > NUMFORNEWCOLUMN) - V_DrawThinString(x+36, y-1, ((data.match.num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); - else - V_DrawString(x+36, y, ((data.match.num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); - - if (data.match.rankingsmode) - { - if (data.match.increase[data.match.num[i]] != UINT8_MAX) - { - if (data.match.increase[data.match.num[i]] > 9) - snprintf(strtime, sizeof strtime, "(+%02d)", data.match.increase[data.match.num[i]]); - else - snprintf(strtime, sizeof strtime, "(+ %d)", data.match.increase[data.match.num[i]]); - - if (data.match.numplayers > NUMFORNEWCOLUMN) - V_DrawRightAlignedThinString(x+135+gutter, y-1, V_6WIDTHSPACE, strtime); - else - V_DrawRightAlignedString(x+120+gutter, y, 0, strtime); - } - - snprintf(strtime, sizeof strtime, "%d", data.match.val[i]); - - if (data.match.numplayers > NUMFORNEWCOLUMN) - V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); - else - V_DrawRightAlignedString(x+152+gutter, y, 0, strtime); - } - else - { - if (data.match.val[i] == (UINT32_MAX-1)) - V_DrawRightAlignedThinString(x+152+gutter, y-1, (data.match.numplayers > NUMFORNEWCOLUMN ? V_6WIDTHSPACE : 0), "NO CONTEST."); - else - { - if (intertype == int_race) - { - snprintf(strtime, sizeof strtime, "%i'%02i\"%02i", G_TicsToMinutes(data.match.val[i], true), - G_TicsToSeconds(data.match.val[i]), G_TicsToCentiseconds(data.match.val[i])); - strtime[sizeof strtime - 1] = '\0'; - - if (data.match.numplayers > NUMFORNEWCOLUMN) - V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); - else - V_DrawRightAlignedString(x+152+gutter, y, 0, strtime); - } - else - { - if (data.match.numplayers > NUMFORNEWCOLUMN) - V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, va("%i", data.match.val[i])); - else - V_DrawRightAlignedString(x+152+gutter, y, 0, va("%i", data.match.val[i])); - } - } - } - - if (data.match.jitter[data.match.num[i]] > 0) - y++; - } - else - data.match.num[i] = MAXPLAYERS; // this should be the only field setting in this function - - y += 18; - - if (i == NUMFORNEWCOLUMN-1) - { - y = 41; - x += BASEVIDWIDTH/2; - } -#undef NUMFORNEWCOLUMN - } - } + Y_PlayerStandingsDrawer(&data, x, hilicol); if (timer) { @@ -651,9 +647,9 @@ void Y_Ticker(void) return; } - if (data.match.rankingsmode && intertic & 1) + if (data.rankingsmode && intertic & 1) { - memset(data.match.jitter, 0, sizeof (data.match.jitter)); + memset(data.jitter, 0, sizeof (data.jitter)); return; } @@ -665,24 +661,24 @@ void Y_Ticker(void) sorttic = intertic + max((cv_inttime.value/2)-2, 2)*TICRATE; // 8 second pause after match results else if (!(multiplayer && demo.playback)) // Don't advance to rankings in replays { - if (!data.match.rankingsmode && (intertic >= sorttic + 8)) + if (!data.rankingsmode && (intertic >= sorttic + 8)) Y_CalculateMatchData(1, Y_CompareRank); - if (data.match.rankingsmode && intertic > sorttic+16+(2*TICRATE)) + if (data.rankingsmode && intertic > sorttic+16+(2*TICRATE)) { INT32 q=0,r=0; boolean kaching = true; - for (q = 0; q < data.match.numplayers; q++) + for (q = 0; q < data.numplayers; q++) { - if (data.match.num[q] == MAXPLAYERS - || !data.match.increase[data.match.num[q]] - || data.match.increase[data.match.num[q]] == UINT8_MAX) + if (data.num[q] == MAXPLAYERS + || !data.increase[data.num[q]] + || data.increase[data.num[q]] == UINT8_MAX) continue; r++; - data.match.jitter[data.match.num[q]] = 1; - if (--data.match.increase[data.match.num[q]]) + data.jitter[data.num[q]] = 1; + if (--data.increase[data.num[q]]) kaching = false; } diff --git a/src/y_inter.h b/src/y_inter.h index ee320d474..be0192a27 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -23,6 +23,23 @@ void Y_StartVote(void); void Y_EndVote(void); void Y_SetupVoteFinish(SINT8 pick, SINT8 level); +typedef struct +{ + UINT8 *color[MAXPLAYERS]; // Winner's color # + INT32 *character[MAXPLAYERS]; // Winner's character # + INT32 num[MAXPLAYERS]; // Winner's player # + char *name[MAXPLAYERS]; // Winner's name + INT32 numplayers; // Number of players being displayed + char levelstring[64]; // holds levelnames up to 64 characters + // SRB2kart + UINT8 increase[MAXPLAYERS]; // how much did the score increase by? + UINT8 jitter[MAXPLAYERS]; // wiggle + UINT32 val[MAXPLAYERS]; // Gametype-specific value + UINT8 pos[MAXPLAYERS]; // player positions. used for ties + boolean rankingsmode; // rankings mode + boolean encore; // encore mode +} y_data_t; + typedef enum { int_none, From ecf55e64ae0565a1b8aa1758af0314083c8bd18a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Dec 2024 23:46:52 +0100 Subject: [PATCH 058/418] more smol refactoring --- src/y_inter.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index fc06c5fca..c8a80e068 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -338,7 +338,7 @@ static void Y_AnimatedVoteScreenCheck(void) // // Handles drawing the center-of-screen player standings. // -void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) +static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) { if (standings->numplayers == 0) { @@ -385,12 +385,18 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) for (i = 0; i < standings->numplayers; i++) { - if (standings->num[i] != MAXPLAYERS && playeringame[standings->num[i]] && !players[standings->num[i]].spectator) + const UINT8 pnum = standings->num[i]; + + if (pnum == MAXPLAYERS) + ; + else if (!playeringame[pnum] || players[pnum].spectator == true) + standings->num[i] = MAXPLAYERS; // this should be the only field setting in this function + else { char strtime[MAXPLAYERNAME+1]; // Apply the jitter offset (later reversed) - if (standings->jitter[standings->num[i]] > 0) + if (standings->jitter[pnum] > 0) y--; V_DrawCenteredString(x+6, y, 0, va("%d", standings->pos[i])); @@ -398,10 +404,11 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) if (standings->color[i] != SKINCOLOR_NONE) { UINT8 *colormap = R_GetTranslationColormap(*standings->character[i], *standings->color[i], GTC_CACHE); + // i fucking hate this i fucking hate this i hate this so much - if (!players[standings->num[i]].skinlocal) + if (!players[pnum].skinlocal) { - int skinIndex = players[standings->num[i]].localskin ? players[standings->num[i]].localskin - 1 : *standings->character[i]; + int skinIndex = (players[pnum].localskin ? (players[pnum].localskin - 1) : *standings->character[i]); if (cv_highresportrait.value) V_DrawSmallMappedPatch(x + 16, y - 4, 0, facewantprefix[skinIndex], colormap); @@ -411,13 +418,13 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) else { if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x + 16, y - 4, 0, localfacewantprefix[players[standings->num[i]].localskin - 1], colormap); + V_DrawSmallMappedPatch(x + 16, y - 4, 0, localfacewantprefix[players[pnum].localskin - 1], colormap); else - V_DrawMappedPatch(x + 16, y - 4, 0, localfacerankprefix[players[standings->num[i]].localskin - 1], colormap); + V_DrawMappedPatch(x + 16, y - 4, 0, localfacerankprefix[players[pnum].localskin - 1], colormap); } } - if (standings->num[i] == whiteplayer) + if (pnum == whiteplayer) { UINT8 cursorframe = (intertic / 4) % 8; V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); @@ -426,18 +433,18 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) STRBUFCPY(strtime, standings->name[i]); if (standings->numplayers > NUMFORNEWCOLUMN) - V_DrawThinString(x+36, y-1, ((standings->num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); + V_DrawThinString(x+36, y-1, ((pnum == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); else - V_DrawString(x+36, y, ((standings->num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); + V_DrawString(x+36, y, ((pnum == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); if (standings->rankingsmode) { - if (standings->increase[standings->num[i]] != UINT8_MAX) + if (standings->increase[pnum] != UINT8_MAX) { - if (standings->increase[standings->num[i]] > 9) - snprintf(strtime, sizeof strtime, "(+%02d)", standings->increase[standings->num[i]]); + if (standings->increase[pnum] > 9) + snprintf(strtime, sizeof strtime, "(+%02d)", standings->increase[pnum]); else - snprintf(strtime, sizeof strtime, "(+ %d)", standings->increase[standings->num[i]]); + snprintf(strtime, sizeof strtime, "(+ %d)", standings->increase[pnum]); if (standings->numplayers > NUMFORNEWCOLUMN) V_DrawRightAlignedThinString(x+135+gutter, y-1, V_6WIDTHSPACE, strtime); @@ -479,12 +486,9 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) } } - // Apply the jitter offset (later reversed) - if (standings->jitter[standings->num[i]] > 0) + if (standings->jitter[pnum] > 0) y++; } - else - standings->num[i] = MAXPLAYERS; // this should be the only field setting in this function y += 18; @@ -521,7 +525,7 @@ void Y_IntermissionDrawer(void) if (rendermode == render_soft) VID_BlitLinearScreen(screens[1], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); #ifdef HWRENDER - else if(rendermode == render_opengl) + else if (rendermode == render_opengl) HWR_DrawIntermissionBG(); #endif } @@ -560,8 +564,7 @@ void Y_IntermissionDrawer(void) else string = va("%s starts in %d", cv_advancemap.string, tickdown); - V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol, - string); + V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol, string); } if ((demo.recording || demo.savemode == DSM_SAVED) && !demo.playback) From 6f5a0b9a3f0a8775b7e111ad2d3ca4e3ed55a2a4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 00:34:51 +0100 Subject: [PATCH 059/418] also add playernum var to tabrankings drawer --- src/k_kart.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index a6aa76e4d..3c1b51c07 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8582,13 +8582,14 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I for (i = 0; i < scorelines; i++) { char strtime[MAXPLAYERNAME+1]; + const UINT8 pnum = tab[i].num; - if (players[tab[i].num].spectator || !players[tab[i].num].mo) + if (players[pnum].spectator || !players[pnum].mo) continue; //ignore them. if (netgame // don't draw it offline - && tab[i].num != serverplayer) - HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[tab[i].num], 0); + && pnum != serverplayer) + HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[pnum], 0); STRBUFCPY(strtime, tab[i].name); @@ -8597,27 +8598,28 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I else V_DrawString(x + 20, y, ((tab[i].num == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); - if (players[tab[i].num].mo->color) + if (players[pnum].mo->color) { - colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo->color, GTC_CACHE); - if (players[tab[i].num].mo->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, players[tab[i].num].mo->color, GTC_CACHE); + colormap = R_GetTranslationColormap(players[pnum].skin, players[pnum].mo->color, GTC_CACHE); + + if (players[pnum].mo->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, players[pnum].mo->color, GTC_CACHE); else - colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo->color, GTC_CACHE); + colormap = R_GetTranslationColormap(players[pnum].skin, players[pnum].mo->color, GTC_CACHE); { player_t *p; - p = &players[tab[i].num]; + p = &players[pnum]; if (cv_highresportrait.value) V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(p), colormap); else V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(p), colormap); } - /*if (G_BattleGametype() && players[tab[i].num].kartstuff[k_bumper] > 0) -- not enough space for this + /*if (G_BattleGametype() && players[pnum].kartstuff[k_bumper] > 0) -- not enough space for this { INT32 bumperx = x+19; V_DrawMappedPatch(bumperx-2, y-4, 0, kp_tinybumper[0], colormap); - for (j = 1; j < players[tab[i].num].kartstuff[k_bumper]; j++) + for (j = 1; j < players[pnum].kartstuff[k_bumper]; j++) { bumperx += 5; V_DrawMappedPatch(bumperx, y-4, 0, kp_tinybumper[1], colormap); @@ -8628,11 +8630,11 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (tab[i].num == whiteplayer) V_DrawScaledPatch(x, y-4, 0, kp_facehighlight[(leveltime / 4) % 8]); - if (G_BattleGametype() && players[tab[i].num].kartstuff[k_bumper] <= 0) + if (G_BattleGametype() && players[pnum].kartstuff[k_bumper] <= 0) V_DrawScaledPatch(x-4, y-7, 0, kp_ranknobumpers); else { - INT32 pos = players[tab[i].num].kartstuff[k_position]; + INT32 pos = players[pnum].kartstuff[k_position]; if (pos < 0 || pos > MAXPLAYERS) pos = 0; // Draws the little number over the face @@ -8644,18 +8646,18 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I #define timestring(time) va("%i'%02i\"%02i", G_TicsToMinutes(time, true), G_TicsToSeconds(time), G_TicsToCentiseconds(time)) if (scorelines > 8) { - if (players[tab[i].num].exiting) - V_DrawRightAlignedThinString(x+rightoffset, y-1, hilicol|V_6WIDTHSPACE, timestring(players[tab[i].num].realtime)); - else if (players[tab[i].num].pflags & PF_TIMEOVER) + if (players[pnum].exiting) + V_DrawRightAlignedThinString(x+rightoffset, y-1, hilicol|V_6WIDTHSPACE, timestring(players[pnum].realtime)); + else if (players[pnum].pflags & PF_TIMEOVER) V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, "NO CONTEST."); else if (circuitmap) V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, va("Lap %d", tab[i].count)); } else { - if (players[tab[i].num].exiting) - V_DrawRightAlignedString(x+rightoffset, y, hilicol, timestring(players[tab[i].num].realtime)); - else if (players[tab[i].num].pflags & PF_TIMEOVER) + if (players[pnum].exiting) + V_DrawRightAlignedString(x+rightoffset, y, hilicol, timestring(players[pnum].realtime)); + else if (players[pnum].pflags & PF_TIMEOVER) V_DrawRightAlignedThinString(x+rightoffset, y-1, 0, "NO CONTEST."); else if (circuitmap) V_DrawRightAlignedString(x+rightoffset, y, 0, va("Lap %d", tab[i].count)); From 43f9bd52390d228efba55e4229dc964c01d9dcc3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 18:43:31 +0100 Subject: [PATCH 060/418] make highlight color in scoreboard and tab ranking player coloured also make it appear in splitscreen similar to hostmod things --- src/hu_stuff.c | 8 +--- src/hu_stuff.h | 2 +- src/k_kart.c | 14 ++++-- src/v_video.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++ src/v_video.h | 2 + src/y_inter.c | 9 +++- 6 files changed, 147 insertions(+), 14 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 6cbb46148..c3fa5c9ae 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2615,7 +2615,6 @@ static void HU_DrawRankings(void) playersort_t tab[MAXPLAYERS]; INT32 i, j, scorelines, hilicol, numplayersingame = 0; boolean completed[MAXPLAYERS]; - UINT32 whiteplayer = MAXPLAYERS; if (!automapactive) V_DrawFadeScreen(0xFF00, 16); // A little more readable, and prevents cheating the fades under other circumstances. @@ -2703,11 +2702,6 @@ static void HU_DrawRankings(void) V_DrawCenteredString(256, 16, hilicol, cv_kartspeed.string); } - // When you play, you quickly see your score because your name is displayed in white. - // When playing back a demo, you quickly see who's the view. - if (!splitscreen) - whiteplayer = demo.playback ? displayplayers[0] : consoleplayer; - scorelines = 0; memset(completed, 0, sizeof (completed)); memset(tab, 0, sizeof (playersort_t)*MAXPLAYERS); @@ -2763,7 +2757,7 @@ static void HU_DrawRankings(void) #endif } - HU_DrawTabRankings(((scorelines > 8) ? 32 : 40), 33, tab, scorelines, whiteplayer, hilicol); + HU_DrawTabRankings(((scorelines > 8) ? 32 : 40), 33, tab, scorelines, hilicol); // draw spectators in a ticker across the bottom if (netgame && G_GametypeHasSpectators()) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 66459c716..258e16c9d 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -128,7 +128,7 @@ void HU_clearChatChars(void); void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); // Lat': Ping drawer for scoreboard. //void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer); //void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer); -void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol); +void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 hilicol); void HU_DrawEmeralds(INT32 x, INT32 y, INT32 pemeralds); const char *HU_SkinColorToConsoleColor(skincolors_t color); diff --git a/src/k_kart.c b/src/k_kart.c index 3c1b51c07..f5b220a04 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8562,12 +8562,14 @@ static boolean K_drawKartPositionFaces(void) // // HU_DrawTabRankings -- moved here to take advantage of kart stuff! // -void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol) +void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 hilicol) { INT32 i, rightoffset = 240; const UINT8 *colormap; INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; + boolean (*_isHighlightedPlayer)(const player_t *) = (demo.playback ? P_IsDisplayPlayer : P_IsLocalPlayer); + //this function is designed for 9 or less score lines only //I_Assert(scorelines <= 9); -- not today bitch, kart fixed it up @@ -8587,6 +8589,10 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (players[pnum].spectator || !players[pnum].mo) continue; //ignore them. + const boolean whiteplayer = _isHighlightedPlayer(&players[pnum]); + + const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(players[pnum].skincolor) : 0); + if (netgame // don't draw it offline && pnum != serverplayer) HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[pnum], 0); @@ -8594,9 +8600,9 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I STRBUFCPY(strtime, tab[i].name); if (scorelines > 8) - V_DrawThinString(x + 20, y, ((tab[i].num == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); + V_DrawThinString(x + 20, y, philicol|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); else - V_DrawString(x + 20, y, ((tab[i].num == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); + V_DrawString(x + 20, y, philicol|V_ALLOWLOWERCASE, strtime); if (players[pnum].mo->color) { @@ -8627,7 +8633,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I }*/ } - if (tab[i].num == whiteplayer) + if (whiteplayer) V_DrawScaledPatch(x, y-4, 0, kp_facehighlight[(leveltime / 4) % 8]); if (G_BattleGametype() && players[pnum].kartstuff[k_bumper] <= 0) diff --git a/src/v_video.c b/src/v_video.c index 987a40a03..b381f6bc1 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3165,6 +3165,132 @@ char V_GetSkincolorChar(INT32 color) return cstart; } +INT32 V_SkinColorToHighlightcolor(skincolors_t color) +{ + switch (color) + { + case SKINCOLOR_WHITE: + case SKINCOLOR_SILVER: + case SKINCOLOR_SLATE: + return 0; // White + case SKINCOLOR_GREY: + case SKINCOLOR_NICKEL: + case SKINCOLOR_BLACK: + case SKINCOLOR_SKUNK: + case SKINCOLOR_JET: + return V_GRAYMAP; + case SKINCOLOR_SEPIA: + case SKINCOLOR_BEIGE: + case SKINCOLOR_WALNUT: + case SKINCOLOR_BROWN: + case SKINCOLOR_LEATHER: + case SKINCOLOR_RUST: + case SKINCOLOR_WRISTWATCH: + return V_BROWNMAP; + case SKINCOLOR_FAIRY: + case SKINCOLOR_SALMON: + case SKINCOLOR_PINK: + case SKINCOLOR_ROSE: + case SKINCOLOR_BRICK: + case SKINCOLOR_LEMONADE: + case SKINCOLOR_BUBBLEGUM: + case SKINCOLOR_LILAC: + return V_PINKMAP; + case SKINCOLOR_CINNAMON: + case SKINCOLOR_RUBY: + case SKINCOLOR_RASPBERRY: + case SKINCOLOR_CHERRY: + case SKINCOLOR_RED: + case SKINCOLOR_CRIMSON: + case SKINCOLOR_MAROON: + case SKINCOLOR_FLAME: + case SKINCOLOR_SCARLET: + case SKINCOLOR_KETCHUP: + return V_REDMAP; + case SKINCOLOR_DAWN: + case SKINCOLOR_SUNSET: + case SKINCOLOR_CREAMSICLE: + case SKINCOLOR_ORANGE: + case SKINCOLOR_PUMPKIN: + case SKINCOLOR_ROSEWOOD: + case SKINCOLOR_BURGUNDY: + case SKINCOLOR_TANGERINE: + return V_ORANGEMAP; + case SKINCOLOR_PEACH: + case SKINCOLOR_CARAMEL: + case SKINCOLOR_CREAM: + return V_PEACHMAP; + case SKINCOLOR_GOLD: + case SKINCOLOR_ROYAL: + case SKINCOLOR_BRONZE: + case SKINCOLOR_COPPER: + case SKINCOLOR_THUNDER: + return V_GOLDMAP; + case SKINCOLOR_POPCORN: + case SKINCOLOR_QUARRY: + case SKINCOLOR_YELLOW: + case SKINCOLOR_MUSTARD: + case SKINCOLOR_CROCODILE: + case SKINCOLOR_OLIVE: + return V_YELLOWMAP; + case SKINCOLOR_ARTICHOKE: + case SKINCOLOR_VOMIT: + case SKINCOLOR_GARDEN: + case SKINCOLOR_TEA: + case SKINCOLOR_PISTACHIO: + return V_TEAMAP; + case SKINCOLOR_LIME: + case SKINCOLOR_HANDHELD: + case SKINCOLOR_MOSS: + case SKINCOLOR_CAMOUFLAGE: + case SKINCOLOR_ROBOHOOD: + case SKINCOLOR_MINT: + case SKINCOLOR_GREEN: + case SKINCOLOR_PINETREE: + case SKINCOLOR_EMERALD: + case SKINCOLOR_SWAMP: + case SKINCOLOR_DREAM: + case SKINCOLOR_PLAGUE: + case SKINCOLOR_ALGAE: + return V_GREENMAP; + case SKINCOLOR_CARIBBEAN: + case SKINCOLOR_AZURE: + case SKINCOLOR_AQUA: + case SKINCOLOR_TEAL: + case SKINCOLOR_CYAN: + case SKINCOLOR_JAWZ: + case SKINCOLOR_CERULEAN: + case SKINCOLOR_NAVY: + case SKINCOLOR_SAPPHIRE: + return V_SKYMAP; + case SKINCOLOR_PIGEON: + case SKINCOLOR_PLATINUM: + case SKINCOLOR_STEEL: + return V_STEELMAP; + case SKINCOLOR_PERIWINKLE: + case SKINCOLOR_BLUE: + case SKINCOLOR_BLUEBERRY: + case SKINCOLOR_NOVA: + return V_BLUEMAP; + case SKINCOLOR_ULTRAVIOLET: + case SKINCOLOR_PURPLE: + case SKINCOLOR_FUCHSIA: + return V_PURPLEMAP; + case SKINCOLOR_PASTEL: + case SKINCOLOR_MOONSLAM: + case SKINCOLOR_DUSK: + case SKINCOLOR_TOXIC: + case SKINCOLOR_MAUVE: + case SKINCOLOR_LAVENDER: + case SKINCOLOR_BYZANTIUM: + case SKINCOLOR_POMEGRANATE: + return V_LAVENDERMAP; + + default: + return 0; + } +} + boolean *heatshifter = NULL; INT32 lastheight = 0; INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; diff --git a/src/v_video.h b/src/v_video.h index dfab7dfde..1898f438b 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -254,6 +254,8 @@ INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option); char V_GetSkincolorChar(INT32 color); +INT32 V_SkinColorToHighlightcolor(skincolors_t color); + typedef struct player_s player_t; void V_DoPostProcessor(INT32 view, player_t *player, INT32 param); diff --git a/src/y_inter.c b/src/y_inter.c index c8a80e068..7aa4c4d6f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -383,6 +383,8 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) V_DrawRightAlignedString(x+(BASEVIDWIDTH/2)+152, 24, hilicol, timeheader); + boolean (*_isHighlightedPlayer)(const player_t *) = (demo.playback ? P_IsDisplayPlayer : P_IsLocalPlayer); + for (i = 0; i < standings->numplayers; i++) { const UINT8 pnum = standings->num[i]; @@ -395,6 +397,9 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) { char strtime[MAXPLAYERNAME+1]; + const boolean whiteplayer = _isHighlightedPlayer(&players[pnum]); + const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(players[pnum].skincolor) : 0); + // Apply the jitter offset (later reversed) if (standings->jitter[pnum] > 0) y--; @@ -433,9 +438,9 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) STRBUFCPY(strtime, standings->name[i]); if (standings->numplayers > NUMFORNEWCOLUMN) - V_DrawThinString(x+36, y-1, ((pnum == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); + V_DrawThinString(x+36, y-1, philicol|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); else - V_DrawString(x+36, y, ((pnum == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); + V_DrawString(x+36, y, philicol|V_ALLOWLOWERCASE, strtime); if (standings->rankingsmode) { From 3a8e4e065e66639dbc9d328cd22e84db8ae7de01 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 00:44:10 +0100 Subject: [PATCH 061/418] draw gametype in tabrankings during replay playback replays already show the mapname in there so --- src/hu_stuff.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index c3fa5c9ae..90c598a47 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2626,20 +2626,25 @@ static void HU_DrawRankings(void) else hilicol = ((gametype == GT_RACE) ? V_SKYMAP : V_REDMAP); - // draw the current gametype in the lower right - //if (modeattacking) - //V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, "Record Attack"); - //else - //V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, gametype_cons_t[gametype].strvalue); - - // draw the current map in the lower right if theres none just say its unknown - char *maptitle = G_BuildMapTitle(gamemap); - if (!maptitle) - V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, "UNKNOWN"); + if (!demo.playback) + { + // draw the current map in the lower right + char *maptitle = G_BuildMapTitle(gamemap); + + if (maptitle) + { + V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, maptitle); + Z_Free(maptitle); + } + else + { + V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, "UNKNOWN"); + } + } else { - V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, maptitle); - Z_Free(maptitle); + // draw the current gametype in the lower right + V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, (modeattacking)? "Record Attack" : gametype_cons_t[gametype].strvalue); } if (G_GametypeHasTeams()) From 4b856fba2a0ab14579c94fc001b5a97704f9afcb Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 00:44:20 +0100 Subject: [PATCH 062/418] z --- src/hu_stuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 90c598a47..3f8a0c13b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2644,7 +2644,7 @@ static void HU_DrawRankings(void) else { // draw the current gametype in the lower right - V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, (modeattacking)? "Record Attack" : gametype_cons_t[gametype].strvalue); + V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, (modeattacking) ? "Record Attack" : gametype_cons_t[gametype].strvalue); } if (G_GametypeHasTeams()) From 17f6f1cd4c4182cdb4e5ed6a641e8c0c799746e4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 18:41:50 +0100 Subject: [PATCH 063/418] use V_STEELMAP for white skincolours instead cause white on white be weird --- src/v_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_video.c b/src/v_video.c index b381f6bc1..d3c65b4c5 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3172,7 +3172,7 @@ INT32 V_SkinColorToHighlightcolor(skincolors_t color) case SKINCOLOR_WHITE: case SKINCOLOR_SILVER: case SKINCOLOR_SLATE: - return 0; // White + return V_STEELMAP; case SKINCOLOR_GREY: case SKINCOLOR_NICKEL: case SKINCOLOR_BLACK: From 7d6cce5881770f3055abcfd54c3500436c6a0b7d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 19:21:23 +0100 Subject: [PATCH 064/418] readd cam cmd stuff cause it may break the cam in replays or smth a --- src/p_user.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 7a9e1f67c..a91bebd79 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3157,9 +3157,11 @@ void P_ToggleDemoCamera(UINT8 viewnum) } } +static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS]; + static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { - INT32 laim, th, tspeed, forward, side, axis; + INT32 laim, forward, side, axis; // these ones used for multiple conditions boolean turnleft, turnright; @@ -3167,14 +3169,30 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) angle_t lang; const UINT8 forplayer = num+1; - ticcmd_t *cmd = D_LocalTiccmd(num); + memset(&cameracmd[num], 0, sizeof(ticcmd_t)); // initialize cmd - if (!cam->freecam) - return cmd; // empty cmd, no. + ticcmd_t *cmd = &cameracmd[num]; lang = cam->localangle; laim = cam->localaiming; + switch (num) + { + case 1: + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); + break; + case 2: + G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + break; + case 3: + G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + break; + case 0: + default: + G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + break; + } + cmd->angleturn = (INT16)(lang >> 16); cmd->aiming = G_ClipAimingPitch(&laim); @@ -3204,27 +3222,15 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) } forward = side = 0; - // use two stage accelerative turning - // on the keyboard and joystick - if (turnleft || turnright) - th += 1; - else - th = 0; - - if (th < SLOWTURNTICS) - tspeed = 2; // slow turn - else - tspeed = 1; - // let movement keys cancel each other out if (turnright && !(turnleft)) { - cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed])); + cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); side += sidemove[1]; } else if (turnleft && !(turnright)) { - cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed])); + cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); side -= sidemove[1]; } From 92a3e974b046e32a14f678ffb61950fe17d79064 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 19:21:40 +0100 Subject: [PATCH 065/418] fix driftgauge showing with freecam while ingame --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index f386b5ad9..ef73e4b2b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9311,7 +9311,7 @@ static void K_drawDriftGauge(void) 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 }; - if (demo.playback && camera[stplyrnum].freecam) + if (camera[stplyrnum].freecam) return; if (P_MobjWasRemoved(stplyr->mo) || (!splitscreen && !camera->chase)) From f72c64d7d15974a86e8e694e6c2ed139a0f6a728 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 19:29:12 +0100 Subject: [PATCH 066/418] fix some potential issues with viewinterp now unpaused disabled interp on netlag also fixes screencoord stuff not being interpolated during pause --- src/d_main.c | 9 ++++++++- src/k_kart.c | 2 +- src/r_main.c | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 642870a86..a46ba11c0 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -825,7 +825,14 @@ void D_SRB2Loop(void) rendertimefrac = FRACUNIT; } - rendertimefrac_unpaused = g_time.timefrac; + if (!hu_stopped) + { + rendertimefrac_unpaused = g_time.timefrac; + } + else + { + rendertimefrac_unpaused = FRACUNIT; + } } else { diff --git a/src/k_kart.c b/src/k_kart.c index ef73e4b2b..ec8e5aa73 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7608,7 +7608,7 @@ static void K_initKartHUD(void) // K_GetScreenCoords needs the right view* variables R_SetViewContext(stplyrnum); - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT, !cv_uncappedhud.value); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, !cv_uncappedhud.value); } INT32 K_calcSplitFlags(INT32 snapflags) diff --git a/src/r_main.c b/src/r_main.c index 2a97136be..dbbd1ee54 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1081,7 +1081,7 @@ R_SetupCommonFrame else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - R_InterpolateView(R_UsingFrameInterpolation() ? (camera[viewnum].freecam ? rendertimefrac_unpaused : rendertimefrac) : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); } static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) From 6d01ec4c553f687c11315a9642642a98dfb2702f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 19:46:14 +0100 Subject: [PATCH 067/418] dont need this anymore --- src/r_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index dbbd1ee54..cd38fab85 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1066,8 +1066,6 @@ R_SetupCommonFrame ( player_t * player, subsector_t * subsector) { - const UINT8 viewnum = R_GetViewNumber(); - newview->player = player; newview->x += quake.x; From 761df3f2cf6db55abe3b3e8a816a8384187fd225 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 30 Dec 2024 11:29:49 +0100 Subject: [PATCH 068/418] hide director control stuff for others than player 1 --- src/m_menu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index ff4096244..d78e41274 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12098,6 +12098,7 @@ static void M_Setup1PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_CONTROL; // GIF OP_AllControlsMenu[20].status = IT_CONTROL; // System Menu OP_AllControlsMenu[21].status = IT_CONTROL; // Console + OP_AllControlsMenu[35].status = IT_CONTROL; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12120,6 +12121,7 @@ static void M_Setup2PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12142,6 +12144,7 @@ static void M_Setup3PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12164,6 +12167,7 @@ static void M_Setup4PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } From 7465e1ae4b991f91fb0791ee9ac1255cb8f6dc98 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 30 Dec 2024 11:34:10 +0100 Subject: [PATCH 069/418] kill splitscreen director again --- src/d_netcmd.c | 6 +-- src/d_netcmd.h | 3 +- src/g_game.c | 34 +++---------- src/g_game.h | 3 -- src/k_director.c | 128 +++++++++++++++++++++-------------------------- src/k_director.h | 4 +- src/p_tick.c | 5 +- src/p_user.c | 1 + src/st_stuff.c | 2 +- 9 files changed, 71 insertions(+), 115 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index bcd9b5797..28f75fde4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1010,11 +1010,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_showviewpointtext); CV_RegisterVar(&cv_showdownloadprompt); - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - CV_RegisterVar(&cv_director[i]); - } - + CV_RegisterVar(&cv_director); CV_RegisterVar(&cv_kartdebugdirector); CV_RegisterVar(&cv_showdirectorhud); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 77852f60c..87d96b40d 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -197,8 +197,7 @@ extern consvar_t cv_ps_thinkframe_page; extern consvar_t cv_ps_samplesize; extern consvar_t cv_ps_descriptor; -extern consvar_t cv_director[4]; // screw you includes -extern consvar_t cv_kartdebugdirector, cv_showdirectorhud; +extern consvar_t cv_director, cv_kartdebugdirector, cv_showdirectorhud; extern consvar_t cv_showtrackaddon; diff --git a/src/g_game.c b/src/g_game.c index b25442bdd..0610bb47b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -338,7 +338,7 @@ INT16 prevmap, nextmap; // save if director is enabled // so demos can disable it by default and restore it after -static int directorstate[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; +static int directorstate = 0; tic_t directortoggletimer = 0; static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; @@ -360,8 +360,6 @@ void SendWeaponPref2(void); void SendWeaponPref3(void); void SendWeaponPref4(void); -static void G_FixCamera(UINT8 view); - // don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler. // chat timer thingy @@ -1549,19 +1547,7 @@ boolean G_Responder(event_t *ev) if (ev->data1 == gamecontrol[gc_director][0] || ev->data1 == gamecontrol[gc_director][1]) { - K_ToggleDirector(0); - } - else if (ev->data1 == gamecontrolbis[gc_director][0] || ev->data1 == gamecontrolbis[gc_director][1]) - { - K_ToggleDirector(1); - } - else if (ev->data1 == gamecontrol3[gc_director][0] || ev->data1 == gamecontrol3[gc_director][1]) - { - K_ToggleDirector(2); - } - else if (ev->data1 == gamecontrol4[gc_director][0] || ev->data1 == gamecontrol4[gc_director][1]) - { - K_ToggleDirector(3); + K_ToggleDirector(); } if (ev->data1 == gamecontrol[gc_freecam][0] || ev->data1 == gamecontrol[gc_freecam][1]) @@ -1715,7 +1701,7 @@ INT32 G_CountPlayersPotentiallyViewable(boolean active) // Reset camera position, angle and interpolation on a view // after changing state. // -static void G_FixCamera(UINT8 view) +void G_FixCamera(UINT8 view) { player_t *player = &players[displayplayers[view - 1]]; @@ -7336,11 +7322,8 @@ post_compat: players[i].kartweight = kartweight[i]; } - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - directorstate[i] = cv_director[i].value; - CV_SetValue(&cv_director[i], 0); - } + directorstate = cv_director.value; + CV_SetValue(&cv_director, 0); demo.deferstart = true; } @@ -7907,11 +7890,8 @@ void G_StopDemo(void) demobuf.buffer = NULL; if (demo.playback) { - for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - CV_SetValue(&cv_director[i], directorstate[i]); - directorstate[i] = 0; - } + CV_SetValue(&cv_director, directorstate); + directorstate = 0; } demo.playback = false; if (demo.title) diff --git a/src/g_game.h b/src/g_game.h index 3a957d00a..ebed4ac0d 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -66,9 +66,6 @@ struct demovars_s { DSM_WILLSAVE, DSM_SAVED } savemode; - - boolean freecam; - }; extern struct demovars_s demo; diff --git a/src/k_director.c b/src/k_director.c index 49b518523..fcd4660ce 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -83,11 +83,6 @@ static boolean K_DirectorIsEnabled(void) return (cv_director.value && K_DirectorIsAvailable()); } -static boolean K_DirectorIsEnabled(const UINT8 viewnum) -{ - return (cv_director[viewnum].value && K_DirectorIsAvailable(viewnum)); -} - void K_InitDirector(void) { INT32 playernum; @@ -98,20 +93,11 @@ void K_InitDirector(void) directorinfo.maxdist = 0; directorinfo.viewplayer = NULL; - for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) + for (playernum = 0; playernum < MAXPLAYERS; playernum++) { - directorinfosplit[i].cooldown = SWITCHTIME; - directorinfosplit[i].freeze = 0; - directorinfosplit[i].attacker = 0; - directorinfosplit[i].maxdist = 0; - directorinfosplit[i].viewplayer = NULL; - - for (playernum = 0; playernum < MAXPLAYERS; playernum++) - { - directorinfosplit[i].sortedplayers[playernum] = -1; - directorinfosplit[i].gap[playernum] = INT32_MAX; - directorinfosplit[i].boredom[playernum] = 0; - } + directorinfo.sortedplayers[playernum] = -1; + directorinfo.gap[playernum] = INT32_MAX; + directorinfo.boredom[playernum] = 0; } } @@ -174,13 +160,13 @@ static fixed_t K_GetFinishGap(INT32 leader, INT32 follower) } } -static void K_UpdateDirectorPositions(const UINT8 viewnum) +static void K_UpdateDirectorPositions(void) { INT32 playernum; INT32 position; player_t* target; - memset(directorinfosplit[viewnum].sortedplayers, -1, sizeof(directorinfo.sortedplayers)); + memset(directorinfo.sortedplayers, -1, sizeof(directorinfo.sortedplayers)); for (playernum = 0; playernum < MAXPLAYERS; playernum++) { @@ -188,43 +174,43 @@ static void K_UpdateDirectorPositions(const UINT8 viewnum) if (playeringame[playernum] && !target->spectator && target->kartstuff[k_position] > 0) { - directorinfosplit[viewnum].sortedplayers[target->kartstuff[k_position] - 1] = playernum; + directorinfo.sortedplayers[target->kartstuff[k_position] - 1] = playernum; } } for (position = 0; position < MAXPLAYERS - 1; position++) { - directorinfosplit[viewnum].gap[position] = INT32_MAX; + directorinfo.gap[position] = INT32_MAX; - if (directorinfosplit[viewnum].sortedplayers[position] == -1 || directorinfosplit[viewnum].sortedplayers[position + 1] == -1) + if (directorinfo.sortedplayers[position] == -1 || directorinfo.sortedplayers[position + 1] == -1) { continue; } - directorinfosplit[viewnum].gap[position] = ScaleFromMap(K_GetFinishGap(directorinfosplit[viewnum].sortedplayers[position], directorinfosplit[viewnum].sortedplayers[position + 1]), FRACUNIT); + directorinfo.gap[position] = ScaleFromMap(K_GetFinishGap(directorinfo.sortedplayers[position], directorinfo.sortedplayers[position + 1]), FRACUNIT); - if (directorinfosplit[viewnum].gap[position] >= BREAKAWAYDIST) + if (directorinfo.gap[position] >= BREAKAWAYDIST) { - directorinfosplit[viewnum].boredom[position] = (INT32)(min(BOREDOMTIME * 2, directorinfosplit[viewnum].boredom[position] + 1)); + directorinfo.boredom[position] = (INT32)(min(BOREDOMTIME * 2, directorinfo.boredom[position] + 1)); } - else if (directorinfosplit[viewnum].boredom[position] > 0) + else if (directorinfo.boredom[position] > 0) { - directorinfosplit[viewnum].boredom[position]--; + directorinfo.boredom[position]--; } } - if (directorinfosplit[viewnum].sortedplayers[0] == -1) + if (directorinfo.sortedplayers[0] == -1) { - directorinfosplit[viewnum].maxdist = -1; + directorinfo.maxdist = -1; return; } - directorinfosplit[viewnum].maxdist = ScaleFromMap(K_GetDistanceToFinish(players[directorinfosplit[viewnum].sortedplayers[0]]), FRACUNIT); + directorinfo.maxdist = ScaleFromMap(K_GetDistanceToFinish(players[directorinfo.sortedplayers[0]]), FRACUNIT); } -static boolean K_CanSwitchDirector(const UINT8 viewnum) +static boolean K_CanSwitchDirector(void) { - if (directorinfosplit[viewnum].cooldown > 0) + if (directorinfo.cooldown > 0) { return false; } @@ -232,9 +218,9 @@ static boolean K_CanSwitchDirector(const UINT8 viewnum) return true; } -static void K_DirectorSwitch(INT32 player, boolean force, const UINT8 viewnum) +static void K_DirectorSwitch(INT32 player, boolean force) { - if (!K_DirectorIsEnabled(viewnum)) + if (!K_DirectorIsEnabled()) { return; } @@ -244,29 +230,29 @@ static void K_DirectorSwitch(INT32 player, boolean force, const UINT8 viewnum) return; } - if (!force && !K_CanSwitchDirector(viewnum)) + if (!force && !K_CanSwitchDirector()) { return; } - G_ResetView(viewnum+1, player, true); - directorinfosplit[viewnum].cooldown = SWITCHTIME; + G_ResetView(1, player, true); + directorinfo.cooldown = SWITCHTIME; } -static void K_DirectorForceSwitch(INT32 player, INT32 time, const UINT8 viewnum) +static void K_DirectorForceSwitch(INT32 player, INT32 time) { if (players[player].exiting) { return; } - directorinfosplit[viewnum].attacker = player; - directorinfosplit[viewnum].freeze = time; + directorinfo.attacker = player; + directorinfo.freeze = time; } void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) { - if (!K_DirectorIsEnabled(directorinfo.viewnum)) + if (!K_DirectorIsEnabled()) { return; } @@ -278,11 +264,11 @@ void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) if (inflictor && inflictor->player) { - K_DirectorForceSwitch(inflictor->player - players, TRANSFERTIME, directorinfo.viewnum); + K_DirectorForceSwitch(inflictor->player - players, TRANSFERTIME); } else if (source && source->player) { - K_DirectorForceSwitch(source->player - players, TRANSFERTIME, directorinfo.viewnum); + K_DirectorForceSwitch(source->player - players, TRANSFERTIME); } } @@ -302,14 +288,14 @@ void K_DrawDirectorDebugger(void) V_DrawThinString(40, 0, V_70TRANS, va("CONF?")); V_DrawThinString(80, 0, V_70TRANS, va("GAP")); V_DrawThinString(120, 0, V_70TRANS, va("BORED")); - V_DrawThinString(150, 0, V_70TRANS, va("COOLDOWN: %d", directorinfosplit[0].cooldown)); - V_DrawThinString(230, 0, V_70TRANS, va("MAXDIST: %d", directorinfosplit[0].maxdist)); + V_DrawThinString(150, 0, V_70TRANS, va("COOLDOWN: %d", directorinfo.cooldown)); + V_DrawThinString(230, 0, V_70TRANS, va("MAXDIST: %d", directorinfo.maxdist)); for (position = 0; position < MAXPLAYERS - 1; position++) { ytxt = 10 * (position + 1); - leader = directorinfosplit[0].sortedplayers[position]; - follower = directorinfosplit[0].sortedplayers[position + 1]; + leader = directorinfo.sortedplayers[position]; + follower = directorinfo.sortedplayers[position + 1]; if (leader == -1 || follower == -1) break; @@ -322,15 +308,15 @@ void K_DrawDirectorDebugger(void) V_DrawThinString(40, ytxt, V_70TRANS, va("NG")); } - V_DrawThinString(80, ytxt, V_70TRANS, va("%d", directorinfosplit[0].gap[position])); + V_DrawThinString(80, ytxt, V_70TRANS, va("%d", directorinfo.gap[position])); - if (directorinfosplit[0].boredom[position] >= BOREDOMTIME) + if (directorinfo.boredom[position] >= BOREDOMTIME) { V_DrawThinString(120, ytxt, V_70TRANS, va("BORED")); } else { - V_DrawThinString(120, ytxt, V_70TRANS, va("%d", directorinfosplit[0].boredom[position])); + V_DrawThinString(120, ytxt, V_70TRANS, va("%d", directorinfo.boredom[position])); } V_DrawThinString(150, ytxt, V_70TRANS, va("%s", player_names[leader])); @@ -338,37 +324,37 @@ void K_DrawDirectorDebugger(void) } } -void K_UpdateDirector(const UINT8 viewnum) +void K_UpdateDirector(void) { INT32 targetposition; directorinfo.viewplayer = &players[displayplayers[0]]; - if (!K_DirectorIsEnabled(directorinfo.viewnum)) + if (!K_DirectorIsEnabled()) { return; } - K_UpdateDirectorPositions(directorinfo.viewnum); + K_UpdateDirectorPositions(); - if (directorinfosplit[directorinfo.viewnum].cooldown > 0) { - directorinfosplit[directorinfo.viewnum].cooldown--; + if (directorinfo.cooldown > 0) { + directorinfo.cooldown--; } // handle pending forced switches - if (directorinfosplit[directorinfo.viewnum].freeze > 0) + if (directorinfo.freeze > 0) { - if (!(--directorinfosplit[directorinfo.viewnum].freeze)) - K_DirectorSwitch(directorinfosplit[directorinfo.viewnum].attacker, true, directorinfo.viewnum); + if (!(--directorinfo.freeze)) + K_DirectorSwitch(directorinfo.attacker, true); return; } // if there's only one player left in the list, just switch to that player - if (directorinfosplit[directorinfo.viewnum].sortedplayers[0] != -1 && (directorinfosplit[directorinfo.viewnum].sortedplayers[1] == -1 || + if (directorinfo.sortedplayers[0] != -1 && (directorinfo.sortedplayers[1] == -1 || // TODO: Battle; I just threw this together quick. Focus on leader. !race_rules())) { - K_DirectorSwitch(directorinfosplit[directorinfo.viewnum].sortedplayers[0], false, directorinfo.viewnum); + K_DirectorSwitch(directorinfo.sortedplayers[0], false); return; } @@ -380,36 +366,36 @@ void K_UpdateDirector(const UINT8 viewnum) INT32 target; // you are out of players, try again - if (directorinfosplit[directorinfo.viewnum].sortedplayers[targetposition] == -1) + if (directorinfo.sortedplayers[targetposition] == -1) { break; } // pair too far apart? try the next one - if (directorinfosplit[directorinfo.viewnum].boredom[targetposition - 1] >= BOREDOMTIME) + if (directorinfo.boredom[targetposition - 1] >= BOREDOMTIME) { continue; } // pair finished? try the next one - if (players[directorinfosplit[directorinfo.viewnum].sortedplayers[targetposition]].exiting) + if (players[directorinfo.sortedplayers[targetposition]].exiting) { continue; } // don't risk switching away from forward pairs at race end, might miss something! - if (directorinfosplit[directorinfo.viewnum].maxdist > PINCHDIST) + if (directorinfo.maxdist > PINCHDIST) { // if the "next" player is close enough, they should be able to see everyone fine! // walk back through the standings to find a vantage that gets everyone in frame. // (also creates a pretty cool effect w/ overtakes at speed) - while (targetposition < MAXPLAYERS && directorinfosplit[directorinfo.viewnum].gap[targetposition] < WALKBACKDIST) + while (targetposition < MAXPLAYERS && directorinfo.gap[targetposition] < WALKBACKDIST) { targetposition++; } } - target = directorinfosplit[directorinfo.viewnum].sortedplayers[targetposition]; + target = directorinfo.sortedplayers[targetposition]; // stop here since we're already viewing this player if (displayplayers[0] == target) @@ -420,20 +406,20 @@ void K_UpdateDirector(const UINT8 viewnum) // if we're certain the back half of the pair is actually in this position, try to switch if (!players[target].kartstuff[k_positiondelay]) { - K_DirectorSwitch(target, false, directorinfo.viewnum); + K_DirectorSwitch(target, false); } // even if we're not certain, if we're cetain we're watching the WRONG player, try to switch if (directorinfo.viewplayer->kartstuff[k_position] != targetposition+1 && !directorinfo.viewplayer->kartstuff[k_positiondelay]) { - K_DirectorSwitch(target, false, directorinfo.viewnum); + K_DirectorSwitch(target, false); } break; } } -void K_ToggleDirector(const UINT8 viewnum) +void K_ToggleDirector(void) { if (!K_DirectorIsAvailable()) return; @@ -442,7 +428,7 @@ void K_ToggleDirector(const UINT8 viewnum) if (!K_DirectorIsEnabled()) { - directorinfosplit[viewnum].cooldown = 0; // switch immediately + directorinfo.cooldown = 0; // switch immediately } directortoggletimer = 0; diff --git a/src/k_director.h b/src/k_director.h index 23ab8d9f7..30b44d9cf 100644 --- a/src/k_director.h +++ b/src/k_director.h @@ -12,7 +12,7 @@ boolean K_DirectorIsAvailable(void); void K_InitDirector(void); -void K_UpdateDirector(UINT8 viewnum); +void K_UpdateDirector(void); void K_DrawDirectorDebugger(void); void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source); -void K_ToggleDirector(UINT8 viewnum); +void K_ToggleDirector(void); diff --git a/src/p_tick.c b/src/p_tick.c index 541a404d5..f5acdae06 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -726,10 +726,7 @@ void P_Ticker(boolean run) PS_STOP_TIMING(ps_lua_postthinkframe_time); } - for (i = 0; i <= splitscreen; i++) - { - K_UpdateDirector(i); - } + K_UpdateDirector(); // Always move the camera. P_RunChaseCameras(); diff --git a/src/p_user.c b/src/p_user.c index 868704d45..f5df23641 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3150,6 +3150,7 @@ void P_ToggleDemoCamera(UINT8 viewnum) else // toggle off { cam->freecam = false; + G_FixCamera(viewnum+1); } } diff --git a/src/st_stuff.c b/src/st_stuff.c index 7b91bec7a..e9be6e0da 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -683,7 +683,7 @@ static void ST_overlayDrawer(void) { char directortext[20] = {0}; - snprintf(directortext, 20, "Director: %s", cv_director[0].value ? "On" : "Off"); + snprintf(directortext, 20, "Director: %s", cv_director.value ? "On" : "Off"); if ((!demo.playback && directortoggletimer < 13*TICRATE) || (demo.playback && directortoggletimer < 4*TICRATE)) { From b2823c81e46fdc077f38addc2b5b363cbd5ad51e Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 04:09:43 +0100 Subject: [PATCH 070/418] fix jitter when toggling freecam off --- src/g_game.c | 4 +--- src/g_game.h | 2 ++ src/p_user.c | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 18c67e4f9..385b7b6cf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -358,8 +358,6 @@ void SendWeaponPref2(void); void SendWeaponPref3(void); void SendWeaponPref4(void); -static void G_FixCamera(UINT8 view); - // don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler. // chat timer thingy @@ -1701,7 +1699,7 @@ INT32 G_CountPlayersPotentiallyViewable(boolean active) // Reset camera position, angle and interpolation on a view // after changing state. // -static void G_FixCamera(UINT8 view) +void G_FixCamera(UINT8 view) { player_t *player = &players[displayplayers[view - 1]]; diff --git a/src/g_game.h b/src/g_game.h index 3a957d00a..ba26cd507 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -444,4 +444,6 @@ INT16 G_TOLFlag(INT32 pgametype); INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer, UINT8 maphell, boolean callagainsoon, INT16 *extbuffer); void G_AddMapToBuffer(INT16 map); +void G_FixCamera(UINT8 view); + #endif diff --git a/src/p_user.c b/src/p_user.c index a91bebd79..ce404866e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3154,6 +3154,7 @@ void P_ToggleDemoCamera(UINT8 viewnum) else // toggle off { cam->freecam = false; + G_FixCamera(viewnum+1); } } From 6fcfb9cf36d44ffd662738bde07bc4b5bd5e28de Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 30 Dec 2024 22:21:26 +0100 Subject: [PATCH 071/418] readd this check lel --- src/r_bsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index dbb6fb4d3..66861c49a 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -265,7 +265,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, boolean underwater; UINT8 i = R_GetViewNumber(); - if (camera[i].chase) + if (viewplayer == &players[displayplayers[i]] && camera[i].chase) heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; else if (i > splitscreen && viewmobj) heightsec = R_PointInSubsector(pviewmobj->x, pviewmobj->y)->sector->heightsec; From 3910e66905bd928b62c824a5caa6ca490bbd758e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 30 Dec 2024 23:10:51 +0100 Subject: [PATCH 072/418] dont try to chase after your spec mobj lel --- src/p_user.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index ce404866e..652fd0fea 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3364,10 +3364,15 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (cmd->buttons & BT_ATTACK) { lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. - cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); - cam->aiming = R_PointToAngle2(0, cam->z, R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y), lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. - cam->reset_aiming = false; + // dont chase after your spectator self + if (!lastp->spectator) + { + const fixed_t dist = R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); + cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); + cam->aiming = R_PointToAngle2(0, cam->z, dist, lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. + cam->reset_aiming = false; + } } if (cmd->forwardmove != 0) From 487018f1467ac64fab0fb6b86ace257820840f47 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 05:37:30 +0100 Subject: [PATCH 073/418] hack: only let freecam for spec move when youre actually able to move as spec cause kart weird, and we cant remove the spec movement due to synch reasons and letting the cam move instantly instead of waiting, may put you in a weird cam position --- src/p_user.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 652fd0fea..e160068ae 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -67,6 +67,8 @@ static boolean onground; +static boolean speccam = false; + // // P_Thrust // Moves the given origin along a given angle. @@ -2278,8 +2280,11 @@ static void P_MovePlayer(player_t *player) if (player->spectator) { P_SpectatorMovement(player); + speccam = true; return; } + else + speccam = false; ////////////////////// // MOVEMENT CODE // @@ -3521,7 +3526,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall num = 0; } - if (thiscam->freecam || player->spectator) + if (thiscam->freecam || (player->spectator && speccam == true)) { P_DemoCameraMovement(thiscam, num); return true; From 2912994e6b941ceab70de37f47893d075ca6adf7 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 23:28:48 +0100 Subject: [PATCH 074/418] speed up camera position checks --- src/p_map.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 1aa35e9c6..cb9f8e929 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2003,7 +2003,11 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) tmbbox[BOXRIGHT] = x + thiscam->radius; tmbbox[BOXLEFT] = x - thiscam->radius; - newsubsec = R_PointInSubsector(x, y); + if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) + newsubsec = R_PointInSubsectorFast(x, y); + else + newsubsec = thiscam->subsector; + ceilingline = blockingline = NULL; mapcampointer = thiscam; @@ -2175,7 +2179,13 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) // boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) { - subsector_t *s = R_PointInSubsector(x, y); + subsector_t *s; + + if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) + s = R_PointInSubsectorFast(x, y); + else + s = thiscam->subsector; + boolean retval = true; boolean itsatwodlevel = false; UINT8 i; @@ -2378,10 +2388,13 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) radius = MAXRADIUS/2; do { - if (thing->flags & MF_NOCLIP) { + if (thing->flags & MF_NOCLIP) + { tryx = x; tryy = y; - } else { + } + else + { if (x-tryx > radius) tryx += radius; else if (x-tryx < -radius) @@ -2523,14 +2536,16 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (!(thing->flags & MF_NOCLIPHEIGHT)) { // Assign thing's standingslope if needed - if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) { + if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) + { if (!startingonground && tmfloorslope) P_HandleSlopeLanding(thing, tmfloorslope); if (thing->momz <= 0) thing->standingslope = tmfloorslope; } - else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) { + else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) + { if (!startingonground && tmceilingslope) P_HandleSlopeLanding(thing, tmceilingslope); From 28109dfb39a46b275eb18b369508fe563fcc394f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 23:30:16 +0100 Subject: [PATCH 075/418] save subsector checks for dedi --- src/p_map.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index cb9f8e929..73522b6fa 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2181,11 +2181,6 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) { subsector_t *s; - if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) - s = R_PointInSubsectorFast(x, y); - else - s = thiscam->subsector; - boolean retval = true; boolean itsatwodlevel = false; UINT8 i; @@ -2195,6 +2190,11 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) if (dedicated) // this crashes so don't even try it return false; + if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) + s = R_PointInSubsectorFast(x, y); + else + s = thiscam->subsector; + if (twodlevel) itsatwodlevel = true; else From 2cc73cc52adef86458f1f6ee5a7bc91a503cdd74 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 01:50:37 +0100 Subject: [PATCH 076/418] this may not be synchsafe --- src/p_floor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_floor.c b/src/p_floor.c index 26a2d0cf1..e81dce5bc 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2927,7 +2927,9 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) if (secspecial >= 8) type = MT_ROCKCRUMBLE1+(secspecial-7); - sec->soundorg.z = (rover->master->frontsector->floorheight + rover->master->frontsector->ceilingheight)/2; + // soundorg z height never gets set normally, so MEH. + sec->soundorg.z = sec->floorheight; + //sec->soundorg.z = (rover->master->frontsector->floorheight + rover->master->frontsector->ceilingheight)/2; // actual accurate z but well smth smth synchsafe S_StartSound(&sec->soundorg, sfx_crumbl); // Find the outermost vertexes in the subsector From af968f1868a2dc08e83631b73eb509433254b0da Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 03:28:21 +0100 Subject: [PATCH 077/418] add speccam playerflag the other thing was weird and dumb lol --- src/d_player.h | 2 ++ src/p_mobj.c | 6 ++++++ src/p_user.c | 10 ++++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 140a4a748..a34094572 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -538,6 +538,8 @@ typedef struct player_s INT32 awayviewtics; angle_t awayviewaiming; // Used for cut-away view + boolean speccam; + boolean spectator; UINT8 bot; diff --git a/src/p_mobj.c b/src/p_mobj.c index f4d78900d..336b9adef 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10629,7 +10629,10 @@ void P_SpawnPlayer(INT32 playernum) if (multiplayer && demo.playback) ; // Don't mess with spectator values since the demo setup handles them already. else if (!G_GametypeHasSpectators()) + { p->spectator = false; + p->speccam = false; + } else if (netgame && p->jointime <= 1 && pcount) { p->spectator = true; @@ -10661,7 +10664,10 @@ void P_SpawnPlayer(INT32 playernum) SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } else // Otherwise, never spectator. + { p->spectator = false; + p->speccam = false; + } } if (G_GametypeHasTeams()) diff --git a/src/p_user.c b/src/p_user.c index 5225bfb02..d4bc960bb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -63,8 +63,6 @@ static boolean onground; -static boolean speccam = false; - // // P_Thrust // Moves the given origin along a given angle. @@ -2275,12 +2273,10 @@ static void P_MovePlayer(player_t *player) if (player->spectator) { + player->speccam = true; P_SpectatorMovement(player); - speccam = true; return; } - else - speccam = false; ////////////////////// // MOVEMENT CODE // @@ -3522,7 +3518,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall num = 0; } - if (thiscam->freecam || (player->spectator && speccam == true)) + if (thiscam->freecam || (player->spectator && player->speccam == true)) { P_DemoCameraMovement(thiscam, num); return true; @@ -4094,6 +4090,7 @@ boolean P_SpectatorJoinGame(player_t *player) player->mo = NULL; } player->spectator = false; + player->speccam = false; player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->ctfteam = changeto; @@ -4122,6 +4119,7 @@ boolean P_SpectatorJoinGame(player_t *player) player->mo = NULL; } player->spectator = false; + player->speccam = false; player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->playerstate = PST_REBORN; From f7ca8fb9436d6b37aa572491358c7bbe67e14ced Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 03:28:21 +0100 Subject: [PATCH 078/418] add speccam playerflag the other thing was weird and dumb lol --- src/d_player.h | 2 ++ src/p_mobj.c | 6 ++++++ src/p_user.c | 10 ++++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 140a4a748..a34094572 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -538,6 +538,8 @@ typedef struct player_s INT32 awayviewtics; angle_t awayviewaiming; // Used for cut-away view + boolean speccam; + boolean spectator; UINT8 bot; diff --git a/src/p_mobj.c b/src/p_mobj.c index bdf6b1a93..35f0b9883 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10618,7 +10618,10 @@ void P_SpawnPlayer(INT32 playernum) if (multiplayer && demo.playback) ; // Don't mess with spectator values since the demo setup handles them already. else if (!G_GametypeHasSpectators()) + { p->spectator = false; + p->speccam = false; + } else if (netgame && p->jointime <= 1 && pcount) { p->spectator = true; @@ -10650,7 +10653,10 @@ void P_SpawnPlayer(INT32 playernum) SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } else // Otherwise, never spectator. + { p->spectator = false; + p->speccam = false; + } } if (G_GametypeHasTeams()) diff --git a/src/p_user.c b/src/p_user.c index e160068ae..168de782a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -67,8 +67,6 @@ static boolean onground; -static boolean speccam = false; - // // P_Thrust // Moves the given origin along a given angle. @@ -2279,12 +2277,10 @@ static void P_MovePlayer(player_t *player) if (player->spectator) { + player->speccam = true; P_SpectatorMovement(player); - speccam = true; return; } - else - speccam = false; ////////////////////// // MOVEMENT CODE // @@ -3526,7 +3522,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall num = 0; } - if (thiscam->freecam || (player->spectator && speccam == true)) + if (thiscam->freecam || (player->spectator && player->speccam == true)) { P_DemoCameraMovement(thiscam, num); return true; @@ -4098,6 +4094,7 @@ boolean P_SpectatorJoinGame(player_t *player) player->mo = NULL; } player->spectator = false; + player->speccam = false; player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->ctfteam = changeto; @@ -4126,6 +4123,7 @@ boolean P_SpectatorJoinGame(player_t *player) player->mo = NULL; } player->spectator = false; + player->speccam = false; player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->playerstate = PST_REBORN; From 854cb7ee49dc6e1c0cf2b458fc8ec6879a43f7f4 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 05:21:25 +0100 Subject: [PATCH 079/418] this doesent work for us --- src/p_user.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 168de782a..29eeb585a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3362,13 +3362,13 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") - if (cmd->buttons & BT_ATTACK) + // well this only really works in replays for us, since we still move our spec player around which causes displayplayer to be the spec player + if (demo.playback) { - lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. - - // dont chase after your spectator self - if (!lastp->spectator) + if (cmd->buttons & BT_ATTACK) { + lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. + const fixed_t dist = R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); cam->aiming = R_PointToAngle2(0, cam->z, dist, lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. From a7a6e9edfca72029ada5d8b2d9b128014fc86388 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 17:07:41 +0100 Subject: [PATCH 080/418] 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 29eeb585a..2bc50d2e0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3479,6 +3479,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]; @@ -3492,10 +3698,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 // We probably shouldn't move the camera if there is no player or player mobj somehow if (!player || !player->mo) @@ -3554,12 +3756,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 @@ -3745,194 +3941,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 From 7386a2f40f51ae8904cded1de2722676db0960c5 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 19:53:59 +0100 Subject: [PATCH 081/418] let windoze detect 64bit mingw in makefile lets us use just "make" cmd without specifieng any other crap on mingw64 --- src/Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index e26b696b3..515f2d533 100644 --- a/src/Makefile +++ b/src/Makefile @@ -81,13 +81,18 @@ ALL_SYSTEMS=\ ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES))) ifeq ($(OS),Windows_NT) # all windows are Windows_NT... - $(info Detected a Windows system, compiling for 32-bit MinGW SDL2...) - - # go for a 32-bit sdl mingw exe by default - MINGW=1 + ifeq ($(shell uname -s | grep -o MINGW64),MINGW64) # 64-bit MinGW + $(info Detected a Windows system, compiling for 64-bit MinGW SDL2...) + MINGW64=1 + else # 32-bit MinGW + $(info Detected a Windows system, compiling for 32-bit MinGW SDL2...) + MINGW=1 + endif + SDL=1 WINDOWSHELL=1 NOUPX=1 + NOOBJDUMP=1 else # if you on the *nix From b2097e2f93921dbb061f7ed6c79c7ff76dcadd2c Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 21:50:02 +0100 Subject: [PATCH 082/418] 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_map.c | 4 ++-- src/p_mobj.c | 4 ++-- src/p_setup.c | 4 ++-- src/p_sight.c | 4 ++-- src/p_user.c | 4 ++-- src/r_fps.c | 2 +- src/r_main.h | 15 +-------------- src/s_sound.c | 4 ++-- 11 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 457dbe251..54df3af04 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2008,7 +2008,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 fe70914b7..87d4d046a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3210,7 +3210,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_map.c b/src/p_map.c index 73522b6fa..707ef26b0 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2004,7 +2004,7 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) tmbbox[BOXLEFT] = x - thiscam->radius; if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) - newsubsec = R_PointInSubsectorFast(x, y); + newsubsec = R_PointInSubsector(x, y); else newsubsec = thiscam->subsector; @@ -2191,7 +2191,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) return false; if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) - s = R_PointInSubsectorFast(x, y); + s = R_PointInSubsector(x, y); else s = thiscam->subsector; diff --git a/src/p_mobj.c b/src/p_mobj.c index 336b9adef..8d728c389 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3348,7 +3348,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; @@ -10426,7 +10426,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 65393f412..2f730fdec 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2498,7 +2498,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 { @@ -2523,7 +2523,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) } cam->chase = false; // tell camera to reset its position next tic diff --git a/src/p_sight.c b/src/p_sight.c index 862b98e03..5f31df827 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -305,8 +305,8 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) { register node_t *bsp = nodes + bspnum; - INT32 side = (fast ? R_PointOnSideFast(los->strace.x, los->strace.y, bsp) : (P_DivlineSide(los->strace.x,los->strace.y, (divline_t *)bsp) & 1)); - INT32 side2 = (fast ? R_PointOnSideFast(los->t2x, los->t2y, bsp) : P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp)); + INT32 side = (fast ? R_PointOnSide(los->strace.x, los->strace.y, bsp) : (P_DivlineSide(los->strace.x,los->strace.y, (divline_t *)bsp) & 1)); + INT32 side2 = (fast ? R_PointOnSide(los->t2x, los->t2y, bsp) : P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp)); if (side == side2) { diff --git a/src/p_user.c b/src/p_user.c index 5d025e9a4..07a66075a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3421,7 +3421,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } // update subsector to avoid crashes; - cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); + cam->subsector = R_PointInSubsector(cam->x, cam->y); } #undef intsign @@ -3465,7 +3465,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 b8aae6d56..a3938fd0a 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -182,18 +182,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]; -} - // // R_IsPointInSubsector, same as above but returns 0 if not in subsector // @@ -209,8 +197,7 @@ FUNCINLINE static ATTRINLINE subsector_t *R_IsPointInSubsector(fixed_t x, fixed_ while (!(nodenum & NF_SUBSECTOR)) { node = &nodes[nodenum]; - //side = R_PointOnSide(x, y, node); - side = R_PointOnSideFast(x, y, node); // this is fine since R_IsPointInSubsector is only used for precip spawn unless you disable noclipcam lol + side = R_PointOnSide(x, y, node); nodenum = node->children[side]; } diff --git a/src/s_sound.c b/src/s_sound.c index aa2a1a773..58146d1a8 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -955,7 +955,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 { @@ -968,7 +968,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); From d1c80dfd9bb18c16344282e1131cc8a576ea8a64 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 22:18:52 +0100 Subject: [PATCH 083/418] 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 8d728c389..a70ab5f91 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3579,11 +3579,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 a3938fd0a..53579c163 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); From 5844330301641d1518892ad9f6543b0bddbfd21b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 01:14:01 +0100 Subject: [PATCH 084/418] only ever touch this if player has a mobjs angleturn is dumb in kart and rarely really is what we want --- src/g_game.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 63cc6a75b..36dd9fd5f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1703,7 +1703,8 @@ void G_FixCamera(UINT8 view) // The order of displayplayers can change, which would // invalidate localangle. - localangle[view - 1] = (P_MobjWasRemoved(player->mo) ? ((angle_t)player->cmd.angleturn << 16) : player->mo->angle); + if (!P_MobjWasRemoved(player->mo)) + localangle[view - 1] = player->mo->angle; P_ResetCamera(player, &camera[view - 1]); From 54ed7250619d3febb50aece598d4d04050d4b6ee Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 15:53:08 +0100 Subject: [PATCH 085/418] didnt mean to revert this one --- src/p_sight.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index 5f31df827..862b98e03 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -305,8 +305,8 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) { register node_t *bsp = nodes + bspnum; - INT32 side = (fast ? R_PointOnSide(los->strace.x, los->strace.y, bsp) : (P_DivlineSide(los->strace.x,los->strace.y, (divline_t *)bsp) & 1)); - INT32 side2 = (fast ? R_PointOnSide(los->t2x, los->t2y, bsp) : P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp)); + INT32 side = (fast ? R_PointOnSideFast(los->strace.x, los->strace.y, bsp) : (P_DivlineSide(los->strace.x,los->strace.y, (divline_t *)bsp) & 1)); + INT32 side2 = (fast ? R_PointOnSideFast(los->t2x, los->t2y, bsp) : P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp)); if (side == side2) { From 3388d35fe0ac9801a2f3835d403e142d87a5c70a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 16:40:43 +0100 Subject: [PATCH 086/418] fix encore mirroring not applyingg to freecam/democam --- src/p_user.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 2bc50d2e0..1919cc007 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3317,6 +3317,9 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) const UINT8 forplayer = num+1; boolean moving = false; + if (encoremode) + players[displayplayers[num]].postimgflags |= POSTIMG_MIRROR; + cam->localangle = cam->angle; cam->localaiming = cam->aiming; From 01b942e1fcecedc1f671abf78197e1bac678bdaf Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 06:47:04 +0100 Subject: [PATCH 087/418] giga shizo spec synch "fix" ok so, for whatever dumb reason, spectatormovement will desynch at random, even on localhost. with this we just literally fucking ignore almost every button input locally and just wont move our spectator player at all. but since we are indeed still runiing specatotr movement code, and this is localcmd shit, the server just thinks we dont want to move and thus is "synchsave". sadly this does not fix desynchs from vanilla players the only code we keep is for button inputs that do certain actions like "item" so we can still join from spec with it and other crap --- src/g_game.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/p_user.c | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 385b7b6cf..59ff420cd 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -905,6 +905,46 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) break; } + if (player->spectator) + { + axis = JoyAxis(AXISMOVE, ssplayer); + if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ACCELERATE; + axis = JoyAxis(AXISBRAKE, ssplayer); + if (InputDown(gc_brake, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_BRAKE; + axis = JoyAxis(AXISFIRE, ssplayer); + if (InputDown(gc_fire, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ATTACK; + + // drift with any button/key + axis = JoyAxis(AXISDRIFT, ssplayer); + if (InputDown(gc_drift, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_DRIFT; + + // Lua scriptable buttons + axis = JoyAxis(AXISCUSTOM1, ssplayer); + if (InputDown(gc_custom1, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM1; + axis = JoyAxis(AXISCUSTOM2, ssplayer); + if (InputDown(gc_custom2, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM2; + axis = JoyAxis(AXISCUSTOM3, ssplayer); + if (InputDown(gc_custom3, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM3; + + // Reset camera + if (InputDown(gc_camreset, ssplayer)) + { + if (thiscam->chase && !rd) + P_ResetCamera(player, thiscam); + rd = true; + } + else + rd = false; + return; + } + // why build a ticcmd if we're paused? // Or, for that matter, if we're being reborn. // Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions diff --git a/src/p_user.c b/src/p_user.c index 1919cc007..19a25513b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2109,7 +2109,7 @@ static void P_SpectatorMovement(player_t *player) { ticcmd_t *cmd = &player->cmd; - player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); + player->mo->angle = (angle_t)(cmd->angleturn<<16 /* not FRACBITS */); ticruned++; if (!(cmd->angleturn & TICCMD_RECEIVED)) From 7de32c74e6befb1df1b5efc6262336380e65c7f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 16:44:30 +0100 Subject: [PATCH 088/418] move spectator hack after pause/desynch code this should take priority over everything --- src/g_game.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 59ff420cd..51ce128e8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -905,6 +905,17 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) break; } + // why build a ticcmd if we're paused? + // Or, for that matter, if we're being reborn. + // Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions + if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching) + { + cmd->angleturn = (INT16)(lang >> 16); + cmd->aiming = G_ClipAimingPitch(&laim); + return; + } + + // lmfao this is beyond hellish if (player->spectator) { axis = JoyAxis(AXISMOVE, ssplayer); @@ -942,16 +953,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } else rd = false; - return; - } - // why build a ticcmd if we're paused? - // Or, for that matter, if we're being reborn. - // Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions - if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching) - { - cmd->angleturn = (INT16)(lang >> 16); - cmd->aiming = G_ClipAimingPitch(&laim); return; } From 45237c9298da97046a4e29b313055e645e7fdd93 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 16:54:54 +0100 Subject: [PATCH 089/418] fix unitialised use of controller stuff --- src/g_game.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 51ce128e8..5c033e74e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -918,6 +918,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // lmfao this is beyond hellish if (player->spectator) { + usejoystick = (analogjoystickmove || gamepadjoystickmove); + axis = JoyAxis(AXISMOVE, ssplayer); if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_ACCELERATE; From 575e46c3db9047b70ed19498b3e1ef2558afd41f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 16:55:20 +0100 Subject: [PATCH 090/418] let playercmd lua hook run during "spectator" input crap lmao --- src/g_game.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 5c033e74e..bfa265030 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -956,6 +956,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else rd = false; + if (gamestate == GS_LEVEL) + LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); + return; } From ba4329e623c2774ba07f3ffe3c049662c53a0b34 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 01:18:30 +0100 Subject: [PATCH 091/418] add another local ticcmd builder so it can guess if we "moved" and put us into freecam state and shit --- src/d_player.h | 2 - src/g_game.c | 108 ++++++++++++++++++++++++++++++++----------------- src/p_mobj.c | 2 - src/p_user.c | 21 ++++------ 4 files changed, 79 insertions(+), 54 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index a34094572..140a4a748 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -538,8 +538,6 @@ typedef struct player_s INT32 awayviewtics; angle_t awayviewaiming; // Used for cut-away view - boolean speccam; - boolean spectator; UINT8 bot; diff --git a/src/g_game.c b/src/g_game.c index bfa265030..7968e1f5f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -850,6 +850,76 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn +// this is absolutely awful +// but we need this if we dont want spectators to move but be able to go to freecam from watching someone +static void G_BuildLocalTiccmd(UINT8 ssplayer) +{ + const UINT8 forplayer = ssplayer-1; + boolean forward, side, axis; //i + boolean usejoystick; + boolean turnleft, turnright; + + ticcmd_t *cmd = D_LocalTiccmd(forplayer); + + const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; + const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; + + usejoystick = (analogjoystickmove || gamepadjoystickmove); + + turnright = InputDown(gc_turnright, ssplayer); + turnleft = InputDown(gc_turnleft, ssplayer); + + axis = JoyAxis(AXISTURN, ssplayer); + + if (gamepadjoystickmove && axis != 0) + { + turnright = turnright || (axis > 0); + turnleft = turnleft || (axis < 0); + } + side = (turnright || turnleft || (analogjoystickmove && axis != 0)); + + forward = false; + axis = JoyAxis(AXISAIM, ssplayer); + if (InputDown(gc_aimforward, ssplayer) || (usejoystick && axis < 0)) + forward = true; + if (InputDown(gc_aimbackward, ssplayer) || (usejoystick && axis > 0)) + forward = true; + + axis = JoyAxis(AXISMOVE, ssplayer); + if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ACCELERATE; + axis = JoyAxis(AXISBRAKE, ssplayer); + if (InputDown(gc_brake, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_BRAKE; + axis = JoyAxis(AXISFIRE, ssplayer); + if (InputDown(gc_fire, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ATTACK; + + // drift with any button/key + axis = JoyAxis(AXISDRIFT, ssplayer); + if (InputDown(gc_drift, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_DRIFT; + + // Lua scriptable buttons + axis = JoyAxis(AXISCUSTOM1, ssplayer); + if (InputDown(gc_custom1, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM1; + axis = JoyAxis(AXISCUSTOM2, ssplayer); + if (InputDown(gc_custom2, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM2; + axis = JoyAxis(AXISCUSTOM3, ssplayer); + if (InputDown(gc_custom3, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM3; + + //Reset away view if a command is given. + if ((forward || side || cmd->buttons) + && displayplayers[0] != consoleplayer && ssplayer == 1) + { + displayplayers[0] = consoleplayer; + G_FixCamera(1); + } +} + void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { const UINT8 forplayer = ssplayer-1; @@ -918,43 +988,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // lmfao this is beyond hellish if (player->spectator) { - usejoystick = (analogjoystickmove || gamepadjoystickmove); - - axis = JoyAxis(AXISMOVE, ssplayer); - if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ACCELERATE; - axis = JoyAxis(AXISBRAKE, ssplayer); - if (InputDown(gc_brake, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_BRAKE; - axis = JoyAxis(AXISFIRE, ssplayer); - if (InputDown(gc_fire, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ATTACK; - - // drift with any button/key - axis = JoyAxis(AXISDRIFT, ssplayer); - if (InputDown(gc_drift, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_DRIFT; - - // Lua scriptable buttons - axis = JoyAxis(AXISCUSTOM1, ssplayer); - if (InputDown(gc_custom1, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM1; - axis = JoyAxis(AXISCUSTOM2, ssplayer); - if (InputDown(gc_custom2, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM2; - axis = JoyAxis(AXISCUSTOM3, ssplayer); - if (InputDown(gc_custom3, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM3; - - // Reset camera - if (InputDown(gc_camreset, ssplayer)) - { - if (thiscam->chase && !rd) - P_ResetCamera(player, thiscam); - rd = true; - } - else - rd = false; + G_BuildLocalTiccmd(ssplayer); if (gamestate == GS_LEVEL) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); diff --git a/src/p_mobj.c b/src/p_mobj.c index 35f0b9883..b46c542a0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10620,7 +10620,6 @@ void P_SpawnPlayer(INT32 playernum) else if (!G_GametypeHasSpectators()) { p->spectator = false; - p->speccam = false; } else if (netgame && p->jointime <= 1 && pcount) { @@ -10655,7 +10654,6 @@ void P_SpawnPlayer(INT32 playernum) else // Otherwise, never spectator. { p->spectator = false; - p->speccam = false; } } diff --git a/src/p_user.c b/src/p_user.c index 19a25513b..6f4b2c471 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2275,9 +2275,9 @@ static void P_MovePlayer(player_t *player) } } + // have to keep this crap for synch reasons if (player->spectator) { - player->speccam = true; P_SpectatorMovement(player); return; } @@ -3366,17 +3366,14 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") // well this only really works in replays for us, since we still move our spec player around which causes displayplayer to be the spec player - if (demo.playback) + if (cmd->buttons & BT_ATTACK) { - if (cmd->buttons & BT_ATTACK) - { - lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. + lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. - const fixed_t dist = R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); - cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); - cam->aiming = R_PointToAngle2(0, cam->z, dist, lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. - cam->reset_aiming = false; - } + const fixed_t dist = R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); + cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); + cam->aiming = R_PointToAngle2(0, cam->z, dist, lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. + cam->reset_aiming = false; } if (cmd->forwardmove != 0) @@ -3727,7 +3724,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall num = 0; } - if (thiscam->freecam || (player->spectator && player->speccam == true)) + if (thiscam->freecam || player->spectator) { P_DemoCameraMovement(thiscam, num); return true; @@ -4107,7 +4104,6 @@ boolean P_SpectatorJoinGame(player_t *player) player->mo = NULL; } player->spectator = false; - player->speccam = false; player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->ctfteam = changeto; @@ -4136,7 +4132,6 @@ boolean P_SpectatorJoinGame(player_t *player) player->mo = NULL; } player->spectator = false; - player->speccam = false; player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->playerstate = PST_REBORN; From caa09cbcfbcafc539609e69e457bff3a1c04d68e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 07:01:04 +0100 Subject: [PATCH 092/418] try and clean up this mess + fix cam angle being wrong when you switch to freecam from viewing someone --- src/g_game.c | 94 ++++++++++++++++++---------------------------------- 1 file changed, 33 insertions(+), 61 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 7968e1f5f..207513fd7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -834,14 +834,6 @@ boolean InputDown(INT32 gc, UINT8 p) } } -// -// G_BuildTiccmd -// Builds a ticcmd from all of the available inputs -// or reads it from the demo buffer. -// If recording a demo, write it out -// -// set secondaryplayer true to build player 2's ticcmd in splitscreen mode -// INT32 localaiming[MAXSPLITSCREENPLAYERS]; angle_t localangle[MAXSPLITSCREENPLAYERS]; boolean camspin[MAXSPLITSCREENPLAYERS]; @@ -852,79 +844,59 @@ static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // this is absolutely awful // but we need this if we dont want spectators to move but be able to go to freecam from watching someone -static void G_BuildLocalTiccmd(UINT8 ssplayer) +static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) { - const UINT8 forplayer = ssplayer-1; - boolean forward, side, axis; //i - boolean usejoystick; - boolean turnleft, turnright; - - ticcmd_t *cmd = D_LocalTiccmd(forplayer); - - const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; - const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; - - usejoystick = (analogjoystickmove || gamepadjoystickmove); - - turnright = InputDown(gc_turnright, ssplayer); - turnleft = InputDown(gc_turnleft, ssplayer); + boolean forward = false; + INT32 axis = 0; + const UINT8 forplayer = (ssplayer-1); + const boolean usejoystick = (cv_usejoystick[forplayer].value); + boolean turn = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer)); axis = JoyAxis(AXISTURN, ssplayer); + boolean side = (turn || (usejoystick && axis != 0)); - if (gamepadjoystickmove && axis != 0) - { - turnright = turnright || (axis > 0); - turnleft = turnleft || (axis < 0); - } - side = (turnright || turnleft || (analogjoystickmove && axis != 0)); - - forward = false; axis = JoyAxis(AXISAIM, ssplayer); if (InputDown(gc_aimforward, ssplayer) || (usejoystick && axis < 0)) forward = true; if (InputDown(gc_aimbackward, ssplayer) || (usejoystick && axis > 0)) forward = true; - axis = JoyAxis(AXISMOVE, ssplayer); - if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ACCELERATE; - axis = JoyAxis(AXISBRAKE, ssplayer); - if (InputDown(gc_brake, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_BRAKE; - axis = JoyAxis(AXISFIRE, ssplayer); - if (InputDown(gc_fire, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ATTACK; + // check for inputs and return button commands + // for stuff like joining with item button, etc. +#define CHECKINPUT(button, AXIS, buttflag) \ + axis = JoyAxis(AXIS, ssplayer); \ + if (InputDown(button, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= buttflag; - // drift with any button/key - axis = JoyAxis(AXISDRIFT, ssplayer); - if (InputDown(gc_drift, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_DRIFT; + CHECKINPUT(gc_accelerate, AXISMOVE, BT_ACCELERATE); + CHECKINPUT(gc_brake, AXISBRAKE, BT_BRAKE); + CHECKINPUT(gc_fire, AXISFIRE, BT_ATTACK); + CHECKINPUT(gc_drift, AXISDRIFT, BT_DRIFT); + CHECKINPUT(gc_custom1, AXISCUSTOM1, BT_CUSTOM1); + CHECKINPUT(gc_custom2, AXISCUSTOM2, BT_CUSTOM2); + CHECKINPUT(gc_custom3, AXISCUSTOM3, BT_CUSTOM3); - // Lua scriptable buttons - axis = JoyAxis(AXISCUSTOM1, ssplayer); - if (InputDown(gc_custom1, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM1; - axis = JoyAxis(AXISCUSTOM2, ssplayer); - if (InputDown(gc_custom2, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM2; - axis = JoyAxis(AXISCUSTOM3, ssplayer); - if (InputDown(gc_custom3, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM3; +#undef CHECKINPUT - //Reset away view if a command is given. + // Reset to our spec player if we watch someone else. if ((forward || side || cmd->buttons) && displayplayers[0] != consoleplayer && ssplayer == 1) { displayplayers[0] = consoleplayer; - G_FixCamera(1); + R_ResetViewInterpolation(0); } } +// +// G_BuildTiccmd +// Builds a ticcmd from all of the available inputs +// or reads it from the demo buffer. +// If recording a demo, write it out +// void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { - const UINT8 forplayer = ssplayer-1; - INT32 laim, th, tspeed, forward, side, axis; //i - const INT32 speed = 1; + const UINT8 forplayer = (ssplayer-1); + INT32 laim, th, tspeed, forward, side, axis; + // these ones used for multiple conditions boolean turnleft, turnright, mouseaiming; boolean invertmouse, usejoystick, kbl, rd; @@ -988,7 +960,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // lmfao this is beyond hellish if (player->spectator) { - G_BuildLocalTiccmd(ssplayer); + G_BuildLocalTiccmd(cmd, ssplayer); if (gamestate == GS_LEVEL) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); @@ -1048,7 +1020,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (th < SLOWTURNTICS) tspeed = cv_turnsmooth.value == 2 ? 2 : 0; // slow turn else - tspeed = speed; + tspeed = 1; cmd->driftturn = 0; From 64a2fe141060f29eb40e85470a684dece9802277 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 07:33:28 +0100 Subject: [PATCH 093/418] clean shit up even more + fix cam aiming reset dont really care about which input anyways. --- src/g_game.c | 17 ++++++----------- src/p_user.c | 9 ++++++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 207513fd7..ad14a83f6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -846,20 +846,14 @@ static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // but we need this if we dont want spectators to move but be able to go to freecam from watching someone static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) { - boolean forward = false; + boolean moveinput = false; INT32 axis = 0; const UINT8 forplayer = (ssplayer-1); const boolean usejoystick = (cv_usejoystick[forplayer].value); - boolean turn = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer)); - axis = JoyAxis(AXISTURN, ssplayer); - boolean side = (turn || (usejoystick && axis != 0)); - - axis = JoyAxis(AXISAIM, ssplayer); - if (InputDown(gc_aimforward, ssplayer) || (usejoystick && axis < 0)) - forward = true; - if (InputDown(gc_aimbackward, ssplayer) || (usejoystick && axis > 0)) - forward = true; + moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) + || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || + (usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0)); // check for inputs and return button commands // for stuff like joining with item button, etc. @@ -878,11 +872,12 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) #undef CHECKINPUT // Reset to our spec player if we watch someone else. - if ((forward || side || cmd->buttons) + if ((moveinput || cmd->buttons) && displayplayers[0] != consoleplayer && ssplayer == 1) { displayplayers[0] = consoleplayer; R_ResetViewInterpolation(0); + camera[0].reset_aiming = true; } } diff --git a/src/p_user.c b/src/p_user.c index 6f4b2c471..9182001c6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3144,7 +3144,9 @@ void P_ToggleDemoCamera(UINT8 viewnum) // dont let freecam be toggled when in spec lel if (players[displayplayers[viewnum]].spectator) + { return; + } if (!cam->freecam) // toggle on { @@ -3328,13 +3330,14 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // let centerview work proper if (InputDown(gc_centerview, forplayer)) + { cam->aiming = 0; + cam->reset_aiming = false; + } if (cmd->aiming != 0) { cam->aiming = cmd->aiming << FRACBITS; - - cam->reset_aiming = false; } cam->angle = cmd->angleturn << 16; @@ -3366,7 +3369,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") // well this only really works in replays for us, since we still move our spec player around which causes displayplayer to be the spec player - if (cmd->buttons & BT_ATTACK) + if (cam->freecam && cmd->buttons & BT_ATTACK) { lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. From 2e1120dc5010f674b39eed9a1b0fe3ae69f094c4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 18:18:20 +0100 Subject: [PATCH 094/418] move postimg flags to camera struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - also dont let water and heat be applied on top of each other since it does not look good (water postimg takes priority over heat) - also save a little time in opengl splitscreen since it does not support heat or wöter effects --- src/d_main.c | 2 +- src/d_player.h | 2 - src/hardware/hw_main.c | 23 ++++-- src/hardware/hw_main.h | 2 +- src/hardware/hw_portal.c | 4 +- src/p_local.h | 3 + src/p_mobj.c | 36 ++++----- src/p_user.c | 158 +++++++++++++++++++++------------------ src/v_video.c | 45 +++++------ src/v_video.h | 2 +- 10 files changed, 151 insertions(+), 126 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index a46ba11c0..dc464b0d6 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -517,7 +517,7 @@ static boolean D_Display(void) for (i = 0; i <= splitscreen; i++) { - V_DoPostProcessor(i, &players[displayplayers[i]], postimgparam[i]); + V_DoPostProcessor(i, postimgparam[i]); } } diff --git a/src/d_player.h b/src/d_player.h index 140a4a748..6ddca1622 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -412,8 +412,6 @@ typedef struct player_s // See pflags_t, above. pflags_t pflags; - UINT16 postimgflags; - // playing animation. panim_t panim; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 638b450a2..7bbad95b3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5133,8 +5133,11 @@ static void HWR_SetTransformAiming(FTransform *trans) trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); } -void HWR_SetTransform(float fpov, player_t *player) +void HWR_SetTransform(float fpov) { + UINT8 viewnum = R_GetViewNumber(); + camera_t *thiscam = &camera[viewnum]; + gl_viewx = FIXED_TO_FLOAT(viewx); gl_viewy = FIXED_TO_FLOAT(viewy); gl_viewz = FIXED_TO_FLOAT(viewz); @@ -5164,15 +5167,15 @@ void HWR_SetTransform(float fpov, player_t *player) atransform.splitscreen = splitscreen; atransform.flip = false; - if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR)) + if ((thiscam->postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) atransform.flip = true; atransform.mirror = false; - if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP)) + if ((thiscam->postimg & POSTIMG_MIRROR) && !(thiscam->postimg & POSTIMG_FLIP)) atransform.mirror = true; atransform.mirrorflip = false; - if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR)) + if ((thiscam->postimg & POSTIMG_FLIP) && (thiscam->postimg & POSTIMG_MIRROR)) atransform.mirrorflip = true; // Set transform. @@ -5239,7 +5242,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl // draw normal things in current frame in current incremented stencil buffer area HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); - HWR_SetTransform(fpov, player); + HWR_SetTransform(fpov); HWR_ClearSprites(); HWR_ClearClipper(); @@ -5296,7 +5299,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl HWR_DrawSkyBackground(); HWR_SetStencilState(HWR_STENCIL_NORMAL, 0); GL_ClearBuffer(false, false, true, 0);// clear skywall markings from the stencil buffer - HWR_SetTransform(fpov, player);// restore transform + HWR_SetTransform(fpov);// restore transform } gl_collect_skywalls = false; @@ -5745,8 +5748,12 @@ static void HWR_DoPostProcessor(player_t *player) if (splitscreen) // Not supported in splitscreen - someone want to add support? return; + //UINT8 viewnum = R_GetViewNumber(); // see above + //camera_t *thiscam = &camera[viewnum]; + camera_t *thiscam = &camera[0]; + // Drunken vision! WooOOooo~ - if (player->postimgflags & POSTIMG_WATER || player->postimgflags & POSTIMG_HEAT) + if (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT) { // 10 by 10 grid. 2 coordinates (xy) float v[SCREENVERTS][SCREENVERTS][2]; @@ -5758,7 +5765,7 @@ static void HWR_DoPostProcessor(player_t *player) INT32 FREQUENCY; // Modifies the wave. - if (player->postimgflags & POSTIMG_WATER) + if (thiscam->postimg & POSTIMG_WATER) { WAVELENGTH = 5; AMPLITUDE = 20; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 52616b7e4..07c77ba98 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -108,7 +108,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl void HWR_ClearSkyDome(void); void HWR_BuildSkyDome(void); -void HWR_SetTransform(float fpov, player_t *player); +void HWR_SetTransform(float fpov); void HWR_ClearClipper(void); void HWR_SetStencilState(int state, int level); diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index f26e71331..2109fb851 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -160,7 +160,7 @@ static void HWR_RenderPortalSeg(gl_portal_t* portal, SINT8 state) void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float fpov, player_t *player, int stencil_level) { // draw portal seg to stencil buffer with increment - HWR_SetTransform(fpov, player); + HWR_SetTransform(fpov); HWR_ClearClipper(); HWR_SetStencilState(HWR_STENCIL_BEGIN, stencil_level); @@ -180,7 +180,7 @@ void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float } // remove portal seg from stencil buffer - HWR_SetTransform(fpov, player); + HWR_SetTransform(fpov); HWR_ClearClipper(); HWR_SetStencilState(HWR_STENCIL_REVERSE, stencil_level); diff --git a/src/p_local.h b/src/p_local.h index c2a2ee017..452b92dff 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -121,6 +121,9 @@ typedef struct camera_s // SRB2Kart: camera pans while drifting fixed_t pan; + + // postproccess effects + UINT16 postimg; } camera_t; extern camera_t camera[MAXSPLITSCREENPLAYERS]; diff --git a/src/p_mobj.c b/src/p_mobj.c index b46c542a0..5860d2137 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3235,13 +3235,20 @@ void P_DestroyRobots(void) static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); - UINT16 postimgflags = 0; - UINT8 i; + UINT16 postimgtype = 0; if (encoremode) - postimgflags |= POSTIMG_MIRROR; + postimgtype |= POSTIMG_MIRROR; if (flipcam) - postimgflags |= POSTIMG_FLIP; + postimgtype |= POSTIMG_FLIP; + +#ifdef HWRENDER + if (rendermode == render_opengl && splitscreen) + { + thiscam->postimg = postimgtype; + return; + } +#endif if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist { @@ -3256,27 +3263,20 @@ static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) // Are we in water? if (P_CameraCheckWater(&dummycam)) - postimgflags |= POSTIMG_WATER; - if (P_CameraCheckHeat(&dummycam)) - postimgflags |= POSTIMG_HEAT; + postimgtype |= POSTIMG_WATER; + else if (P_CameraCheckHeat(&dummycam)) + postimgtype |= POSTIMG_HEAT; } else { // Are we in water? if (P_CameraCheckWater(thiscam)) - postimgflags |= POSTIMG_WATER; - if (P_CameraCheckHeat(thiscam)) - postimgflags |= POSTIMG_HEAT; + postimgtype |= POSTIMG_WATER; + else if (P_CameraCheckHeat(thiscam)) + postimgtype |= POSTIMG_HEAT; } - for (i = 0; i <= splitscreen; i++) - { - if (player != &players[displayplayers[i]]) - continue; - - players[displayplayers[i]].postimgflags = postimgflags; - break; - } + thiscam->postimg = postimgtype; } // P_CameraThinker diff --git a/src/p_user.c b/src/p_user.c index 9182001c6..c6fac5c8d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3320,7 +3320,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) boolean moving = false; if (encoremode) - players[displayplayers[num]].postimgflags |= POSTIMG_MIRROR; + cam->postimg |= POSTIMG_MIRROR; cam->localangle = cam->angle; cam->localaiming = cam->aiming; @@ -4152,26 +4152,66 @@ boolean P_SpectatorJoinGame(player_t *player) return false; } -// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam -static void P_CalcPostImg(player_t *player) +static boolean P_CameraCheckHeatFirstperson(player_t *player, sector_t *sector, fixed_t pviewheight) { - sector_t *sector = player->mo->subsector->sector; - INT16 typeflag = 0; - //INT32 *param; - fixed_t pviewheight; - UINT8 i; + if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1) + return true; - if (player->mo->eflags & MFE_VERTICALFLIP) - pviewheight = player->mo->z + player->mo->height - player->viewheight; - else - pviewheight = player->mo->z + player->viewheight; - - if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) + if (sector->ffloors) { - sector = player->awayviewmobj->subsector->sector; - pviewheight = player->awayviewmobj->z + 20*FRACUNIT; + ffloor_t *rover; + + for (rover = sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (pviewheight >= P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y)) + continue; + + if (pviewheight <= P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y)) + continue; + + if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1) + return true; + } } + return false; +} + +static boolean P_CameraCheckWaterFirstperson(player_t *player, sector_t *sector, fixed_t pviewheight) +{ + if (sector->ffloors) + { + ffloor_t *rover; + + for (rover = sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKPLAYER) + continue; + + if (pviewheight >= P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y)) + continue; + + if (pviewheight <= P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y)) + continue; + + return true; + } + } + + return false; +} + +// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam +static void P_CalcPostImg(player_t *player, camera_t *thiscam) +{ + sector_t *sector = NULL; + INT16 postimgtype = 0; + //INT32 *param; + fixed_t pviewheight = 0; + /*for (i = 0; i <= splitscreen; i++) { if (player == &players[displayplayers[i]]) @@ -4181,79 +4221,55 @@ static void P_CalcPostImg(player_t *player) } }*/ - // see if we are in heat (no, not THAT kind of heat...) + if (encoremode) // srb2kart + postimgtype |= POSTIMG_MIRROR; - if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1) - typeflag |= POSTIMG_HEAT; - else if (sector->ffloors) + if (player->mo->eflags & MFE_VERTICALFLIP) + postimgtype |= POSTIMG_FLIP; + +#ifdef HWRENDER + if (rendermode == render_opengl && splitscreen) { - ffloor_t *rover; - fixed_t topheight; - fixed_t bottomheight; + thiscam->postimg = postimgtype; + return; + } +#endif - for (rover = sector->ffloors; rover; rover = rover->next) + sector = player->mo->subsector->sector; + + if (sector->ffloors) + { + if (player->mo->eflags & MFE_VERTICALFLIP) + pviewheight = player->mo->z + player->mo->height - player->viewheight; + else + pviewheight = player->mo->z + player->viewheight; + + if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) { - if (!(rover->flags & FF_EXISTS)) - continue; - - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; - - if (pviewheight >= topheight || pviewheight <= bottomheight) - continue; - - if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1) - typeflag |= POSTIMG_HEAT; + sector = player->awayviewmobj->subsector->sector; + pviewheight = player->awayviewmobj->z + 20*FRACUNIT; } } // see if we are in water (water trumps heat) - if (sector->ffloors) - { - ffloor_t *rover; - fixed_t topheight; - fixed_t bottomheight; - - for (rover = sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKPLAYER) - continue; - - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; - - if (pviewheight >= topheight || pviewheight <= bottomheight) - continue; - - typeflag |= POSTIMG_WATER; - } - } - - if (encoremode) // srb2kart - typeflag |= POSTIMG_MIRROR; - - if (player->mo->eflags & MFE_VERTICALFLIP) - typeflag |= POSTIMG_FLIP; + if (P_CameraCheckWaterFirstperson(player, sector, pviewheight)) + postimgtype |= POSTIMG_WATER; + // see if we are in heat (no, not THAT kind of heat...) + else if (P_CameraCheckHeatFirstperson(player, sector, pviewheight)) + postimgtype |= POSTIMG_HEAT; // Motion blur // unused /*if (player->speed > (35<speed - 32)/4; if (*param > 5) *param = 5; }*/ - for (i = 0; i <= splitscreen; i++) - { - if (player != &players[displayplayers[i]]) - continue; - - players[displayplayers[i]].postimgflags = typeflag; - break; - } + thiscam->postimg = postimgtype; } void P_DoTimeOver(player_t *player) @@ -5038,7 +5054,7 @@ void P_PlayerAfterThink(player_t *player) if (!thiscam->chase) // bob view only if looking through the player's eyes { P_CalcHeight(player); - P_CalcPostImg(player); + P_CalcPostImg(player, thiscam); } else { diff --git a/src/v_video.c b/src/v_video.c index 987a40a03..da2b0677a 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3175,7 +3175,7 @@ INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; // Perform a particular image postprocessing function. // -void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) +void V_DoPostProcessor(INT32 view, INT32 param) { #if NUMSCREENS < 5 // do not enable image post processing for ARM, SH and MIPS CPUs @@ -3194,7 +3194,9 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) if (view < 0 || view > 3 || view > splitscreen) return; - if (!player->postimgflags) + camera_t *thiscam = &camera[view]; + + if (!thiscam->postimg) return; if ((view == 1 && splitscreen == 1) || view >= 2) @@ -3210,7 +3212,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) UINT8 *tmpscr = screens[4]; UINT8 *srcscr = screens[0]; - if (player->postimgflags & POSTIMG_WATER) + if (thiscam->postimg & POSTIMG_WATER) { INT32 y; // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic @@ -3269,22 +3271,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) tmpscr = srcscr; srcscr = tmp; } - - /*if (player->postimgflags & POSTIMG_MOTION) // Motion Blur! - { - INT32 x, y; - - // TODO: Add a postimg_param so that we can pick the translucency level... - UINT8 *transme = transtables + ((param-1)<postimgflags & POSTIMG_HEAT) // Heat wave + else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave { INT32 y; @@ -3331,7 +3318,21 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) srcscr = tmp; } - if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR)) // Flip the screen upside-down + /*if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur! + { + INT32 x, y; + + // TODO: Add a postimg_param so that we can pick the translucency level... + UINT8 *transme = transtables + ((param-1)<postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down { INT32 y, y2; @@ -3342,7 +3343,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) tmpscr = srcscr; srcscr = tmp; } - else if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP)) // Flip the screen on the x axis + else if ((thiscam->postimg & POSTIMG_MIRROR) && !(thiscam->postimg & POSTIMG_FLIP)) // Flip the screen on the x axis { INT32 y, x, x2; @@ -3354,7 +3355,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) tmpscr = srcscr; srcscr = tmp; } - else if ((player->postimgflags & POSTIMG_MIRROR) && (player->postimgflags & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis + else if ((thiscam->postimg & POSTIMG_MIRROR) && (thiscam->postimg & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis { INT32 y, x; diff --git a/src/v_video.h b/src/v_video.h index dfab7dfde..2513825c2 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -256,7 +256,7 @@ char V_GetSkincolorChar(INT32 color); typedef struct player_s player_t; -void V_DoPostProcessor(INT32 view, player_t *player, INT32 param); +void V_DoPostProcessor(INT32 view, INT32 param); void V_DrawPatchFill(patch_t *pat); From 7d47834e55d6295056415537556721dc9ec6a953 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 18:29:21 +0100 Subject: [PATCH 095/418] oops smol error --- src/p_user.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index c6fac5c8d..e7f8ea009 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4237,18 +4237,15 @@ static void P_CalcPostImg(player_t *player, camera_t *thiscam) sector = player->mo->subsector->sector; - if (sector->ffloors) - { - if (player->mo->eflags & MFE_VERTICALFLIP) - pviewheight = player->mo->z + player->mo->height - player->viewheight; - else - pviewheight = player->mo->z + player->viewheight; + if (player->mo->eflags & MFE_VERTICALFLIP) + pviewheight = player->mo->z + player->mo->height - player->viewheight; + else + pviewheight = player->mo->z + player->viewheight; - if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) - { - sector = player->awayviewmobj->subsector->sector; - pviewheight = player->awayviewmobj->z + 20*FRACUNIT; - } + if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) + { + sector = player->awayviewmobj->subsector->sector; + pviewheight = player->awayviewmobj->z + 20*FRACUNIT; } // see if we are in water (water trumps heat) From f9b107153964876844702aa9281109c1533be5f6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 19:35:29 +0100 Subject: [PATCH 096/418] simplify this --- src/g_game.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ad14a83f6..2dae7dfbf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -848,8 +848,7 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) { boolean moveinput = false; INT32 axis = 0; - const UINT8 forplayer = (ssplayer-1); - const boolean usejoystick = (cv_usejoystick[forplayer].value); + const boolean usejoystick = (cv_usejoystick[(ssplayer-1)].value); moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || @@ -914,8 +913,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else player = &players[displayplayers[forplayer]]; - if (ssplayer == 2) - thiscam = (player->bot == 2 ? &camera[0] : &camera[forplayer]); + if ((ssplayer == 2) && (player->bot == 2)) + thiscam = &camera[0]; else thiscam = &camera[forplayer]; From 729a74a5612d20021bcd9f113e9338ec6a6ee448 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 20:09:28 +0100 Subject: [PATCH 097/418] 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 503357901..571c136ca 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -166,7 +166,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; @@ -199,7 +199,7 @@ static void D_GamePadMenuScrollTicker(void) menuInputDelayTimer++; if (menuInputDelayTimer == SCROLLDELAY) - D_PadScrollInput(key); + D_PadMenuScrollInput(key); } else { @@ -816,7 +816,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 41256170b..1bf46a25b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3689,40 +3689,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"); } @@ -4398,10 +4386,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) { From 8cb7396f33cff00000e0236f10f136096ea22f4d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 01:53:44 +0100 Subject: [PATCH 098/418] check for consoleplayer since displayplayer is who youre watching --- src/p_user.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index e7f8ea009..03cf054d9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3142,9 +3142,11 @@ void P_ToggleDemoCamera(UINT8 viewnum) { camera_t *cam = &camera[viewnum]; - // dont let freecam be toggled when in spec lel - if (players[displayplayers[viewnum]].spectator) + // dont toggle freecam when in spec + // special case since only non splitscreen can change viewpoints + if ((!splitscreen && players[consoleplayer].spectator) || players[displayplayers[viewnum]].spectator) { + cam->freecam = false; return; } From 338bcf0d2d8e38c21d68c650be6ac065a1bc17f3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 01:54:32 +0100 Subject: [PATCH 099/418] forgor about lookback ig --- src/g_game.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 2dae7dfbf..cd96729fc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -870,6 +870,9 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) #undef CHECKINPUT + axis = JoyAxis(AXISLOOKBACK, ssplayer); + camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); + // Reset to our spec player if we watch someone else. if ((moveinput || cmd->buttons) && displayplayers[0] != consoleplayer && ssplayer == 1) From f512a080513669e15e36dc5c00122f87a102e643 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 19:33:43 +0100 Subject: [PATCH 100/418] dont do this while not in replay this is kinda awkward tbh, but its useful for replay stuff --- src/p_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 03cf054d9..e5c1c86b2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3370,8 +3370,8 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") - // well this only really works in replays for us, since we still move our spec player around which causes displayplayer to be the spec player - if (cam->freecam && cmd->buttons & BT_ATTACK) + // this feels kinda pointless for ingame freecam so keep it for replays only + if (demo.playback && cmd->buttons & BT_ATTACK) { lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. From 2f4a113685bea06fbe512bd4dd0a757f15e7715b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 19:37:52 +0100 Subject: [PATCH 101/418] more hAx: dont move player during freecam state besides hop and honk useful if you wanna take pics and dont feel like driving away --- src/g_game.c | 38 +++++++++++++++++++++++++------------- src/p_user.c | 11 +++++++---- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index cd96729fc..861c09497 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -842,34 +842,45 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn -// this is absolutely awful -// but we need this if we dont want spectators to move but be able to go to freecam from watching someone -static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) +// +// G_BuildLocalTiccmd +// extremely basic cut down ticcmd builder +// for spectator and freecam +// this does not make the player move at all but keeps important things working +// +static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) { boolean moveinput = false; INT32 axis = 0; const boolean usejoystick = (cv_usejoystick[(ssplayer-1)].value); - moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) - || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || - (usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0)); - // check for inputs and return button commands - // for stuff like joining with item button, etc. + // for stuff like joining with item button, saltyhop, honking, etc. #define CHECKINPUT(button, AXIS, buttflag) \ axis = JoyAxis(AXIS, ssplayer); \ if (InputDown(button, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= buttflag; - CHECKINPUT(gc_accelerate, AXISMOVE, BT_ACCELERATE); - CHECKINPUT(gc_brake, AXISBRAKE, BT_BRAKE); CHECKINPUT(gc_fire, AXISFIRE, BT_ATTACK); CHECKINPUT(gc_drift, AXISDRIFT, BT_DRIFT); CHECKINPUT(gc_custom1, AXISCUSTOM1, BT_CUSTOM1); CHECKINPUT(gc_custom2, AXISCUSTOM2, BT_CUSTOM2); CHECKINPUT(gc_custom3, AXISCUSTOM3, BT_CUSTOM3); + // we dont need the rest of this if were in freecam state + if (freecam) + { + return; + } + + CHECKINPUT(gc_accelerate, AXISMOVE, BT_ACCELERATE); + CHECKINPUT(gc_brake, AXISBRAKE, BT_BRAKE); + #undef CHECKINPUT + moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) + || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || + (usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0)); + axis = JoyAxis(AXISLOOKBACK, ssplayer); camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); @@ -954,11 +965,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) return; } - // lmfao this is beyond hellish - if (player->spectator) + // dumbass thing so we can use a few buttons but dont accidentally drive away + if (player->spectator || camera[forplayer].freecam) { - G_BuildLocalTiccmd(cmd, ssplayer); + G_BuildLocalTiccmd(cmd, ssplayer, !player->spectator); + // let lua override everything if (gamestate == GS_LEVEL) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); diff --git a/src/p_user.c b/src/p_user.c index e5c1c86b2..ca2616461 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3155,6 +3155,12 @@ void P_ToggleDemoCamera(UINT8 viewnum) cam->freecam = true; cam->button_a_held = 2; cam->reset_aiming = true; + + // get rid of some hud elements + if (displayplayers[0] != consoleplayer) + { + displayplayers[0] = consoleplayer; + } } else // toggle off { @@ -3255,13 +3261,10 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_aimbackward, forplayer) || (usejoystick && axis > 0)) forward -= forwardmove[1]; - // fire with any button/key axis = JoyAxis(AXISFIRE, forplayer); - if (InputDown(gc_fire, 1) || (usejoystick && axis > 0)) + if (InputDown(gc_fire, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; - // spectator aiming shit, ahhhh... - // looking up/down laim += (mlooky<<19); From 5c8b318a937c2cc1f2c74a2b8278a1d3ba3bbaa7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 21:03:22 +0100 Subject: [PATCH 102/418] make float and sink use accel and brake again but also keep rebindable controls keeps intended behaviour since we now dont need to worry about player controls anymore but keeps the rebindable buttons incase someone wants to do a crazy control setup for some reason --- src/g_input.c | 6 ------ src/p_user.c | 10 +++++++++- src/st_stuff.c | 26 ++++++++++++++------------ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index b99874b8d..c948ed751 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1142,12 +1142,6 @@ void G_Controldefault(UINT8 player) //gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up - - gamecontrol[gc_camfloat ][0] = 'a'; - gamecontrol[gc_camsink ][0] = 'd'; - - gamecontrol[gc_camfloat ][1] = KEY_JOY1+0; // A - gamecontrol[gc_camsink ][1] = KEY_JOY1+1; // B } if (player == 0 || player == 2) diff --git a/src/p_user.c b/src/p_user.c index 45889d327..a2b6b01c8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3261,6 +3261,14 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_fire, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; + // float and sink + axis = JoyAxis(AXISMOVE, forplayer); + if (InputDown(gc_accelerate, forplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ACCELERATE; + axis = JoyAxis(AXISBRAKE, forplayer); + if (InputDown(gc_brake, forplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_BRAKE; + // looking up/down laim += (mlooky<<19); @@ -3347,7 +3355,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (!cam->button_a_held) { fixed_t spd = 32*mapobjectscale*cv_freecam_speed.value; - int dir = ((InputDown(gc_camfloat, forplayer)) ? 1 : 0) + ((InputDown(gc_camsink, forplayer)) ? -1 : 0); + int dir = ((cmd->buttons & BT_ACCELERATE || InputDown(gc_camfloat, forplayer)) ? 1 : 0) + ((cmd->buttons & BT_BRAKE || InputDown(gc_camsink, forplayer)) ? -1 : 0); switch (dir) { diff --git a/src/st_stuff.c b/src/st_stuff.c index 6f0777919..527d7af76 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -651,16 +651,18 @@ static void ST_drawLevelTitle(void) V_DrawLevelTitle(ttlnumxpos+12, bary+6, V_SNAPTOBOTTOM, actnum); } -static const char *ST_GetButtonName(INT32 control, const char *inputtext) +// returns the actual button name for any gamecontrol +// if unbound is set, it returns "Unbound" as a string should there be no button bound to a gamecontrol +static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound) { - static char buttname[32] = {0}; // Static buffer - const char *item1 = gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL; - const char *item2 = gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL; + static char buttname[32] = {0}; + const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); + const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind - if (item1 != NULL && item2 != NULL) - snprintf(buttname, 32, "%s/%s - %s", item1, item2, inputtext); + if (butt1 != NULL && butt2 != NULL) + snprintf(buttname, 32, "%s/%s - %s", butt1, butt2, inputtext); else - snprintf(buttname, 32, "%s - %s", item1 != NULL ? item1 : item2 != NULL ? item2 : "Not Bound", inputtext); + snprintf(buttname, 32, (unbound ? "%s - %s" : "- %s - %s"), (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : unbound ? "Unbound" : ""), inputtext); return buttname; } @@ -789,16 +791,16 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-50, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director")); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director", true)); } else { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); } } } From e53c6bb4da0507a324ba367df41dd814c3878a83 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 21:54:45 +0100 Subject: [PATCH 103/418] reduce ternary hell a little lel --- src/st_stuff.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 527d7af76..523bbc44a 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -655,14 +655,16 @@ static void ST_drawLevelTitle(void) // if unbound is set, it returns "Unbound" as a string should there be no button bound to a gamecontrol static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound) { - static char buttname[32] = {0}; + static char buttname[32] = ""; const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind - if (butt1 != NULL && butt2 != NULL) + if (butt1 == NULL && butt2 == NULL) // not bound to a button + snprintf(buttname, 32, (unbound ? "%s - %s" : "- %s - %s"), (unbound ? "Unbound" : ""), inputtext); + else if (butt1 != NULL && butt2 != NULL) // bound to two buttons snprintf(buttname, 32, "%s/%s - %s", butt1, butt2, inputtext); - else - snprintf(buttname, 32, (unbound ? "%s - %s" : "- %s - %s"), (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : unbound ? "Unbound" : ""), inputtext); + else // bound to only one + snprintf(buttname, 32, "- %s - %s", (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : ""), inputtext); return buttname; } From e06b61e8d2c44bddaf146a85396bd6fbae3e1766 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 22:17:15 +0100 Subject: [PATCH 104/418] revert "Faster z position checks for mobjs without collision" --- src/p_mobj.c | 10 ++++------ src/r_main.h | 44 -------------------------------------------- 2 files changed, 4 insertions(+), 50 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index d8d34b243..904f61271 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -578,8 +578,6 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, ); } -#define NOCOLLISION ((mobj->flags & MF_NOBLOCKMAP) || (mobj->flags & MF_NOCLIPTHING)) - fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) { I_Assert(mobj != NULL); @@ -611,7 +609,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (NOCOLLISION ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -690,7 +688,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (NOCOLLISION ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -770,7 +768,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -849,7 +847,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point diff --git a/src/r_main.h b/src/r_main.h index 53579c163..511450665 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -125,50 +125,6 @@ angle_t R_PlayerSliptideAngle(player_t *player); fixed_t R_ScaleFromGlobalAngle(angle_t visangle); -// -// R_IsPointInSector -// -FUNCINLINE static ATTRINLINE boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y) -{ - size_t i; - size_t passes = 0; - - for (i = 0; i < sector->linecount; i++) - { - line_t *line = sector->lines[i]; - vertex_t *v1, *v2; - - if (line->frontsector == line->backsector) - continue; - - v1 = line->v1; - v2 = line->v2; - - // make sure v1 is below v2 - if (v1->y > v2->y) - { - vertex_t *tmp = v1; - v1 = v2; - v2 = tmp; - } - else if (v1->y == v2->y) // horizontal line, we can't match this - continue; - - if (v1->y < y && y <= v2->y) - { - // if the y axis in inside the line, find the point where we intersect on the x axis... - fixed_t vx = v1->x + (INT64)(v2->x - v1->x) * (y - v1->y) / (v2->y - v1->y); - - // ...and if that point is to the left of the point, count it as inside. - if (vx < x) - passes++; - } - } - - // and odd number of passes means we're inside the polygon. - return (boolean)(passes % 2); -} - // // R_PointInSubsector // From ebedca82f3e516e5fbb1a16483929ccc0b48738f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 00:32:23 +0100 Subject: [PATCH 105/418] 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 52503cfc8..0dfe2d042 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2130,16 +2130,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; @@ -2168,7 +2176,6 @@ void I_SleepDuration(precise_t duration) } // Otherwise, this is a spinloop. - cur = I_GetPreciseTime(); } #endif From 7e8c8f4bb708cdf169d265021049f566e66c9cb7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 00:41:41 +0100 Subject: [PATCH 106/418] 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 571c136ca..96223431b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -744,7 +744,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; } From 841c22673288e25472060fefd77c0348fdaaed77 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 01:11:26 +0100 Subject: [PATCH 107/418] this somehow got lost lel --- src/d_main.c | 4 ++-- src/k_kart.c | 2 +- src/r_main.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 96223431b..c7360c5cd 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -828,7 +828,7 @@ void D_SRB2Loop(void) { renderdeltatics = FLOAT_TO_FIXED(deltatics); - if (!(paused || P_AutoPause()) && !hu_stopped) + if (!(paused || P_AutoPause()) && deltatics < 1.0 && !hu_stopped) { rendertimefrac = g_time.timefrac; } @@ -837,7 +837,7 @@ void D_SRB2Loop(void) rendertimefrac = FRACUNIT; } - if (!hu_stopped) + if (deltatics < 1.0 && !hu_stopped) { rendertimefrac_unpaused = g_time.timefrac; } diff --git a/src/k_kart.c b/src/k_kart.c index ec8e5aa73..c6a614418 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7608,7 +7608,7 @@ static void K_initKartHUD(void) // K_GetScreenCoords needs the right view* variables R_SetViewContext(stplyrnum); - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, !cv_uncappedhud.value); + R_InterpolateView(rendertimefrac_unpaused, !cv_uncappedhud.value); } INT32 K_calcSplitFlags(INT32 snapflags) diff --git a/src/r_main.c b/src/r_main.c index 37a94b9ef..ad8524f56 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1079,7 +1079,7 @@ R_SetupCommonFrame else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); + R_InterpolateView(rendertimefrac_unpaused, false); } static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) From 606a50047c66ce1f1c81e5542082e4b07db54945 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 14:14:34 +0100 Subject: [PATCH 108/418] put refreshdirmenu back here --- src/d_clisrv.c | 2 +- src/d_main.c | 29 +++++++++++++---------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 54df3af04..20b8c894f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6263,8 +6263,8 @@ static void Local_Maketic(INT32 realtics) // game responder calls HU_Responder, AM_Responder, F_Responder, // and G_MapEventsToControls if (!dedicated) rendergametic = gametic; - // translate inputs (keyboard/mouse/joystick) into game controls + // translate inputs (keyboard/mouse/joystick) into game controls for (i = 0; i <= splitscreen; i++) { CreateNewLocalCMD(i, realtics); diff --git a/src/d_main.c b/src/d_main.c index c7360c5cd..1de1ad1b9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -353,6 +353,7 @@ static boolean D_Display(void) // save the current screen if about to wipe wipe = (gamestate != wipegamestate); + if (wipe) { // set for all later @@ -742,11 +743,9 @@ void D_SRB2Loop(void) precise_t enterprecise = I_GetPreciseTime(); precise_t finishprecise = enterprecise; - { - // Casting the return value of a function is bad practice (apparently) - double budget = ((R_GetFramerateCap() == 0) ? 0.0 : round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision())); - capbudget = (precise_t) budget; - } + // Casting the return value of a function is bad practice (apparently) + double budget = ((R_GetFramerateCap() == 0) ? 0.0 : round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision())); + capbudget = (precise_t) budget; boolean ranwipe = false; @@ -775,7 +774,9 @@ void D_SRB2Loop(void) debugload--; #endif - interp = R_UsingFrameInterpolation() && !dedicated; + refreshdirmenu = 0; + + interp = (R_UsingFrameInterpolation() && !dedicated); doDisplay = false; renderisnewtic = (realtics > 0 || singletics); @@ -792,7 +793,7 @@ void D_SRB2Loop(void) // process tics (but maybe not if realtic == 0) TryRunTics(realtics); - if (lastdraw || singletics || gametic > rendergametic) + if (lastdraw || singletics || (gametic > rendergametic)) { rendergametic = gametic; rendertimeout = entertic + TICRATE/17; @@ -806,7 +807,7 @@ void D_SRB2Loop(void) { // Evaluate the chase cam once for every local realtic // This might actually be better suited inside G_Ticker or TryRunTics - for (tic_t chasecamtics = 0; chasecamtics < realtics; chasecamtics++) + for (tic_t chasecamtics = 0; (chasecamtics < realtics); chasecamtics++) { P_RunChaseCameras(); } @@ -837,7 +838,7 @@ void D_SRB2Loop(void) rendertimefrac = FRACUNIT; } - if (deltatics < 1.0 && !hu_stopped) + if ((deltatics < 1.0) && !hu_stopped) { rendertimefrac_unpaused = g_time.timefrac; } @@ -893,7 +894,7 @@ void D_SRB2Loop(void) // // Wipes run an inner loop and artificially increase // the measured time. - if (!ranwipe && frameskip < 3 && deltatics > 1.0) + if (!ranwipe && (frameskip < 3) && (deltatics > 1.0)) { frameskip++; } @@ -909,7 +910,7 @@ void D_SRB2Loop(void) // in the case of "match refresh rate" + vsync, don't sleep at all const boolean vsync_with_match_refresh = cv_vidwait.value && cv_fpscap.value == 0; - if (elapsed > 0 && (INT64)capbudget > elapsed && !vsync_with_match_refresh) + if ((elapsed > 0) && ((INT64)capbudget > elapsed) && !vsync_with_match_refresh) { I_SleepDuration(capbudget - (finishprecise - enterprecise)); } @@ -984,10 +985,6 @@ void D_StartTitle(void) S_ResetKeepAndSpecialMus(); // just in case F_StartTitleScreen(); - - // Reset the palette -- SRB2Kart: actually never mind let's do this in the middle of every fade - /*if (rendermode != render_none) - V_SetPaletteLump("PLAYPAL");*/ } // @@ -2076,7 +2073,7 @@ void D_SRB2Main(void) } #ifdef HAVE_DISCORDRPC - if (! dedicated) + if (!dedicated) { DRPC_Init(); } From ce5fc9715d1f4fd179a843ca4470cea5bbd83e2a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 14:17:44 +0100 Subject: [PATCH 109/418] slight cleanup buildticcmd --- src/g_game.c | 64 ++++------ src/p_maputl.c | 335 ++++++++++++++++++++++++++----------------------- 2 files changed, 201 insertions(+), 198 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index c49ccfbb1..06bb24305 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -900,36 +900,30 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) // void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { - const UINT8 forplayer = (ssplayer-1); INT32 laim, th, tspeed, forward, side, axis; // these ones used for multiple conditions boolean turnleft, turnright, mouseaiming; boolean invertmouse, usejoystick, kbl, rd; - player_t *player; - camera_t *thiscam; angle_t lang; static INT32 turnheld[MAXSPLITSCREENPLAYERS]; // for accelerative turning static boolean keyboard_look[MAXSPLITSCREENPLAYERS]; // true if lookup/down using keyboard static boolean resetdown[MAXSPLITSCREENPLAYERS]; // don't cam reset every frame + if (demo.playback) + return; + + const UINT8 forplayer = (ssplayer-1); + player_t *player = ((ssplayer == 1) ? &players[consoleplayer] : &players[displayplayers[forplayer]]); + + camera_t *thiscam = &camera[forplayer]; + const boolean freecam = camera[forplayer].freecam; + const boolean lookaxis = cv_lookaxis[forplayer].value; const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; - if (demo.playback) return; - - if (ssplayer == 1) - player = &players[consoleplayer]; - else - player = &players[displayplayers[forplayer]]; - - if ((ssplayer == 2) && (player->bot == 2)) - thiscam = &camera[0]; - else - thiscam = &camera[forplayer]; - lang = localangle[forplayer]; laim = localaiming[forplayer]; th = turnheld[forplayer]; @@ -940,16 +934,23 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { case 2: G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); + mouseaiming = player->spectator; + invertmouse = cv_invertmouse2.value; break; case 3: G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + mouseaiming = false; + invertmouse = false; break; case 4: G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + mouseaiming = false; + invertmouse = false; break; case 1: - default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + mouseaiming = player->spectator; + invertmouse = cv_invertmouse.value; break; } @@ -964,9 +965,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } // dumbass thing so we can use a few buttons but dont accidentally drive away - if (player->spectator || camera[forplayer].freecam) + if (player->spectator || freecam) { - G_BuildLocalTiccmd(cmd, ssplayer, !player->spectator); + G_BuildLocalTiccmd(cmd, ssplayer, freecam); // let lua override everything if (gamestate == GS_LEVEL) @@ -975,27 +976,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) return; } - switch (ssplayer) - { - case 2: - mouseaiming = player->spectator; //(PLAYER2INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook2.value; - invertmouse = cv_invertmouse2.value; - break; - case 3: - mouseaiming = false; - invertmouse = false; - break; - case 4: - mouseaiming = false; - invertmouse = false; - break; - case 1: - default: - mouseaiming = player->spectator; //(PLAYER1INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook.value; - invertmouse = cv_invertmouse.value; - break; - } - usejoystick = (analogjoystickmove || gamepadjoystickmove); turnright = InputDown(gc_turnright, ssplayer); turnleft = InputDown(gc_turnleft, ssplayer); @@ -1147,7 +1127,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) INT32 player_invert = invertmouse ? -1 : 1; INT32 screen_invert = (player->mo && (player->mo->eflags & MFE_VERTICALFLIP) - && (!thiscam->chase || player->pflags & PF_FLIPCAM)) //because chasecam's not inverted + && (!thiscam->chase || player->pflags & PF_FLIPCAM)) // because chasecam's not inverted ? -1 : 1; // set to -1 or 1 to multiply // mouse look stuff (mouse look is not the same as mouse aim) @@ -1262,8 +1242,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); //Reset away view if a command is given. - if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) - && displayplayers[0] != consoleplayer && ssplayer == 1) + if (displayplayers[0] != consoleplayer && ssplayer == 1 + && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) { displayplayers[0] = consoleplayer; G_FixCamera(1); diff --git a/src/p_maputl.c b/src/p_maputl.c index 3c91dc922..13dd85592 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -296,7 +296,7 @@ void P_CameraLineOpening(line_t *linedef) { frontfloor = sectors[front->camsec].floorheight; frontceiling = sectors[front->camsec].ceilingheight; - if (sectors[front->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[front->camsec].f_slope) frontfloor = P_GetZAt(sectors[front->camsec].f_slope, camera[0].x, camera[0].y); if (sectors[front->camsec].c_slope) frontceiling = P_GetZAt(sectors[front->camsec].c_slope, camera[0].x, camera[0].y); @@ -306,7 +306,7 @@ void P_CameraLineOpening(line_t *linedef) { frontfloor = sectors[front->heightsec].floorheight; frontceiling = sectors[front->heightsec].ceilingheight; - if (sectors[front->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[front->heightsec].f_slope) frontfloor = P_GetZAt(sectors[front->heightsec].f_slope, camera[0].x, camera[0].y); if (sectors[front->heightsec].c_slope) frontceiling = P_GetZAt(sectors[front->heightsec].c_slope, camera[0].x, camera[0].y); @@ -316,11 +316,12 @@ void P_CameraLineOpening(line_t *linedef) frontfloor = P_CameraGetFloorZ(mapcampointer, front, tmx, tmy, linedef); frontceiling = P_CameraGetCeilingZ(mapcampointer, front, tmx, tmy, linedef); } + if (back->camsec >= 0) { backfloor = sectors[back->camsec].floorheight; backceiling = sectors[back->camsec].ceilingheight; - if (sectors[back->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[back->camsec].f_slope) frontfloor = P_GetZAt(sectors[back->camsec].f_slope, camera[0].x, camera[0].y); if (sectors[back->camsec].c_slope) frontceiling = P_GetZAt(sectors[back->camsec].c_slope, camera[0].x, camera[0].y); @@ -329,7 +330,7 @@ void P_CameraLineOpening(line_t *linedef) { backfloor = sectors[back->heightsec].floorheight; backceiling = sectors[back->heightsec].ceilingheight; - if (sectors[back->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[back->heightsec].f_slope) frontfloor = P_GetZAt(sectors[back->heightsec].f_slope, camera[0].x, camera[0].y); if (sectors[back->heightsec].c_slope) frontceiling = P_GetZAt(sectors[back->heightsec].c_slope, camera[0].x, camera[0].y); @@ -340,104 +341,111 @@ void P_CameraLineOpening(line_t *linedef) backceiling = P_CameraGetCeilingZ(mapcampointer, back, tmx, tmy, linedef); } + fixed_t thingtop = mapcampointer->z + mapcampointer->height; + + if (frontceiling < backceiling) { - fixed_t thingtop = mapcampointer->z + mapcampointer->height; - - if (frontceiling < backceiling) - { - opentop = frontceiling; - highceiling = backceiling; - } - else - { - opentop = backceiling; - highceiling = frontceiling; - } - - if (frontfloor > backfloor) - { - openbottom = frontfloor; - lowfloor = backfloor; - } - else - { - openbottom = backfloor; - lowfloor = frontfloor; - } - - // Check for fake floors in the sector. - if (front->ffloors || back->ffloors) - { - ffloor_t *rover; - fixed_t highestceiling = highceiling; - fixed_t lowestceiling = opentop; - fixed_t highestfloor = openbottom; - fixed_t lowestfloor = lowfloor; - fixed_t delta1, delta2; - - // Check for frontsector's fake floors - if (front->ffloors) - for (rover = front->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) - continue; - - topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); - - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; - - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; - } - - // Check for backsectors fake floors - if (back->ffloors) - for (rover = back->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) - continue; - - topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); - - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; - - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; - } - - if (highestceiling < highceiling) - highceiling = highestceiling; - - if (highestfloor > openbottom) - openbottom = highestfloor; - - if (lowestceiling < opentop) - opentop = lowestceiling; - - if (lowestfloor > lowfloor) - lowfloor = lowestfloor; - } - openrange = opentop - openbottom; - return; + opentop = frontceiling; + highceiling = backceiling; } + else + { + opentop = backceiling; + highceiling = frontceiling; + } + + if (frontfloor > backfloor) + { + openbottom = frontfloor; + lowfloor = backfloor; + } + else + { + openbottom = backfloor; + lowfloor = frontfloor; + } + + // Check for fake floors in the sector. + if (front->ffloors || back->ffloors) + { + ffloor_t *rover; + fixed_t highestceiling = highceiling; + fixed_t lowestceiling = opentop; + fixed_t highestfloor = openbottom; + fixed_t lowestfloor = lowfloor; + fixed_t delta1, delta2; + + // Check for frontsector's fake floors + if (front->ffloors) + { + for (rover = front->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) + continue; + + topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); + + delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); + delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + + if (bottomheight < lowestceiling && delta1 >= delta2) + lowestceiling = bottomheight; + else if (bottomheight < highestceiling && delta1 >= delta2) + highestceiling = bottomheight; + + if (topheight > highestfloor && delta1 < delta2) + highestfloor = topheight; + else if (topheight > lowestfloor && delta1 < delta2) + lowestfloor = topheight; + } + } + + // Check for backsectors fake floors + if (back->ffloors) + { + for (rover = back->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) + continue; + + topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); + + delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); + delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + + if (bottomheight < lowestceiling && delta1 >= delta2) + lowestceiling = bottomheight; + else if (bottomheight < highestceiling && delta1 >= delta2) + highestceiling = bottomheight; + + if (topheight > highestfloor && delta1 < delta2) + highestfloor = topheight; + else if (topheight > lowestfloor && delta1 < delta2) + lowestfloor = topheight; + } + } + + if (highestceiling < highceiling) + highceiling = highestceiling; + + if (highestfloor > openbottom) + openbottom = highestfloor; + + if (lowestceiling < opentop) + opentop = lowestceiling; + + if (lowestfloor > lowfloor) + lowfloor = lowestfloor; + } + + openrange = opentop - openbottom; + return; } void P_LineOpening(line_t *linedef, mobj_t *mobj) @@ -466,40 +474,39 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) I_Assert(front != NULL); I_Assert(back != NULL); - { // Set open and high/low values here - fixed_t frontheight, backheight; + // Set open and high/low values here + fixed_t frontheight, backheight; - frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); + frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); - if (frontheight < backheight) - { - opentop = frontheight; - highceiling = backheight; - opentopslope = front->c_slope; - } - else - { - opentop = backheight; - highceiling = frontheight; - opentopslope = back->c_slope; - } + if (frontheight < backheight) + { + opentop = frontheight; + highceiling = backheight; + opentopslope = front->c_slope; + } + else + { + opentop = backheight; + highceiling = frontheight; + opentopslope = back->c_slope; + } - frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); + frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); - if (frontheight > backheight) - { - openbottom = frontheight; - lowfloor = backheight; - openbottomslope = front->f_slope; - } - else - { - openbottom = backheight; - lowfloor = frontheight; - openbottomslope = back->f_slope; - } + if (frontheight > backheight) + { + openbottom = frontheight; + lowfloor = backheight; + openbottomslope = front->f_slope; + } + else + { + openbottom = backheight; + lowfloor = frontheight; + openbottomslope = back->f_slope; } if (mobj) @@ -508,29 +515,33 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // Check for collision with front side's midtexture if Effect 4 is set if (linedef->flags & ML_EFFECT4 - && !linedef->polyobj // don't do anything for polyobjects! ...for now - ) { + && !linedef->polyobj) // don't do anything for polyobjects! ...for now + { side_t *side = &sides[linedef->sidenum[0]]; fixed_t textop, texbottom, texheight; fixed_t texmid, delta1, delta2; INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid - if (texnum) { + if (texnum) + { // Get the midtexture's height texheight = textures[texnum]->height << FRACBITS; // Set texbottom and textop to the Z coordinates of the texture's boundaries + if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) // "infinite" repeat { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = openbottom + side->rowoffset; - textop = opentop + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = openbottom + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = opentop + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); - } + texbottom = openbottom + side->rowoffset; + textop = opentop + side->rowoffset; + } + else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) + { + texbottom = openbottom + side->rowoffset; + textop = texbottom + texheight*(side->repeatcnt+1); + } + else + { + textop = opentop + side->rowoffset; + texbottom = textop - texheight*(side->repeatcnt+1); } texmid = texbottom+(textop-texbottom)/2; @@ -538,10 +549,13 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - texmid); delta2 = abs(thingtop - texmid); - if (delta1 > delta2) { // Below + if (delta1 > delta2) // Below + { if (opentop > texbottom) opentop = texbottom; - } else { // Above + } + else // Above + { if (openbottom < textop) openbottom = textop; } @@ -549,9 +563,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) } // Check for fake floors in the sector. - if (front->ffloors || back->ffloors - || linedef->polyobj - ) + if (front->ffloors || back->ffloors || linedef->polyobj) { ffloor_t *rover; @@ -567,6 +579,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) for (rover = front->ffloors; rover; rover = rover->next) { fixed_t topheight, bottomheight; + if (!(rover->flags & FF_EXISTS)) continue; @@ -584,7 +597,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { - if (bottomheight < lowestceiling) { + if (bottomheight < lowestceiling) + { lowestceiling = bottomheight; ceilingslope = *rover->b_slope; } @@ -594,7 +608,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF { - if (topheight > highestfloor) { + if (topheight > highestfloor) + { highestfloor = topheight; floorslope = *rover->t_slope; } @@ -624,7 +639,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { - if (bottomheight < lowestceiling) { + if (bottomheight < lowestceiling) + { lowestceiling = bottomheight; ceilingslope = *rover->b_slope; } @@ -634,7 +650,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF { - if (topheight > highestfloor) { + if (topheight > highestfloor) + { highestfloor = topheight; floorslope = *rover->t_slope; } @@ -650,29 +667,35 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); - if (polysec->floorheight < lowestceiling && delta1 >= delta2) { + + if (polysec->floorheight < lowestceiling && delta1 >= delta2) + { lowestceiling = polysec->floorheight; ceilingslope = NULL; } else if (polysec->floorheight < highestceiling && delta1 >= delta2) highestceiling = polysec->floorheight; - if (polysec->ceilingheight > highestfloor && delta1 < delta2) { + if (polysec->ceilingheight > highestfloor && delta1 < delta2) + { highestfloor = polysec->ceilingheight; floorslope = NULL; } else if (polysec->ceilingheight > lowestfloor && delta1 < delta2) lowestfloor = polysec->ceilingheight; } + if (highestceiling < highceiling) highceiling = highestceiling; - if (highestfloor > openbottom) { + if (highestfloor > openbottom) + { openbottom = highestfloor; openbottomslope = floorslope; } - if (lowestceiling < opentop) { + if (lowestceiling < opentop) + { opentop = lowestceiling; opentopslope = ceilingslope; } From ca3c2bf70a99014469d1371d8b6dabaa7eca6f38 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 15:03:39 +0100 Subject: [PATCH 110/418] remove this again seems like it basically doesent change anything --- src/d_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 1de1ad1b9..ffbee4337 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -581,8 +581,6 @@ static boolean D_Display(void) PS_START_TIMING(ps_uitime); ST_Drawer(); HU_Drawer(); - - NetUpdate(); // TEST: run this EVERY frame } else { From 9af243177fcf92221cfae6f0d51c43301a03fb50 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 15:11:09 +0100 Subject: [PATCH 111/418] --------- --- 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 c6a614418..4dafb5fd2 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 { From bca4af201d3247018b62a5e2e463a45b859ed6fd Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 14:51:32 +0100 Subject: [PATCH 112/418] no u may be used uninitialised --- src/g_game.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_game.c b/src/g_game.c index 06bb24305..ad06c74a6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -948,6 +948,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) invertmouse = false; break; case 1: + default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver mouseaiming = player->spectator; invertmouse = cv_invertmouse.value; From 077076532f3f701562d91a97dfcc84817749b299 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 14:17:44 +0100 Subject: [PATCH 113/418] slight cleanup buildticcmd --- src/g_game.c | 64 ++++------ src/p_maputl.c | 335 ++++++++++++++++++++++++++----------------------- 2 files changed, 201 insertions(+), 198 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index e76d0ef5f..00d3f861b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -898,36 +898,30 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) // void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { - const UINT8 forplayer = (ssplayer-1); INT32 laim, th, tspeed, forward, side, axis; // these ones used for multiple conditions boolean turnleft, turnright, mouseaiming; boolean invertmouse, usejoystick, kbl, rd; - player_t *player; - camera_t *thiscam; angle_t lang; static INT32 turnheld[MAXSPLITSCREENPLAYERS]; // for accelerative turning static boolean keyboard_look[MAXSPLITSCREENPLAYERS]; // true if lookup/down using keyboard static boolean resetdown[MAXSPLITSCREENPLAYERS]; // don't cam reset every frame + if (demo.playback) + return; + + const UINT8 forplayer = (ssplayer-1); + player_t *player = ((ssplayer == 1) ? &players[consoleplayer] : &players[displayplayers[forplayer]]); + + camera_t *thiscam = &camera[forplayer]; + const boolean freecam = camera[forplayer].freecam; + const boolean lookaxis = cv_lookaxis[forplayer].value; const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; - if (demo.playback) return; - - if (ssplayer == 1) - player = &players[consoleplayer]; - else - player = &players[displayplayers[forplayer]]; - - if ((ssplayer == 2) && (player->bot == 2)) - thiscam = &camera[0]; - else - thiscam = &camera[forplayer]; - lang = localangle[forplayer]; laim = localaiming[forplayer]; th = turnheld[forplayer]; @@ -938,16 +932,23 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { case 2: G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); + mouseaiming = player->spectator; + invertmouse = cv_invertmouse2.value; break; case 3: G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + mouseaiming = false; + invertmouse = false; break; case 4: G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + mouseaiming = false; + invertmouse = false; break; case 1: - default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + mouseaiming = player->spectator; + invertmouse = cv_invertmouse.value; break; } @@ -962,9 +963,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } // dumbass thing so we can use a few buttons but dont accidentally drive away - if (player->spectator || camera[forplayer].freecam) + if (player->spectator || freecam) { - G_BuildLocalTiccmd(cmd, ssplayer, !player->spectator); + G_BuildLocalTiccmd(cmd, ssplayer, freecam); // let lua override everything if (gamestate == GS_LEVEL) @@ -973,27 +974,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) return; } - switch (ssplayer) - { - case 2: - mouseaiming = player->spectator; //(PLAYER2INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook2.value; - invertmouse = cv_invertmouse2.value; - break; - case 3: - mouseaiming = false; - invertmouse = false; - break; - case 4: - mouseaiming = false; - invertmouse = false; - break; - case 1: - default: - mouseaiming = player->spectator; //(PLAYER1INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook.value; - invertmouse = cv_invertmouse.value; - break; - } - usejoystick = (analogjoystickmove || gamepadjoystickmove); turnright = InputDown(gc_turnright, ssplayer); turnleft = InputDown(gc_turnleft, ssplayer); @@ -1145,7 +1125,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) INT32 player_invert = invertmouse ? -1 : 1; INT32 screen_invert = (player->mo && (player->mo->eflags & MFE_VERTICALFLIP) - && (!thiscam->chase || player->pflags & PF_FLIPCAM)) //because chasecam's not inverted + && (!thiscam->chase || player->pflags & PF_FLIPCAM)) // because chasecam's not inverted ? -1 : 1; // set to -1 or 1 to multiply // mouse look stuff (mouse look is not the same as mouse aim) @@ -1260,8 +1240,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); //Reset away view if a command is given. - if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) - && displayplayers[0] != consoleplayer && ssplayer == 1) + if (displayplayers[0] != consoleplayer && ssplayer == 1 + && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) { displayplayers[0] = consoleplayer; G_FixCamera(1); diff --git a/src/p_maputl.c b/src/p_maputl.c index 3c91dc922..13dd85592 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -296,7 +296,7 @@ void P_CameraLineOpening(line_t *linedef) { frontfloor = sectors[front->camsec].floorheight; frontceiling = sectors[front->camsec].ceilingheight; - if (sectors[front->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[front->camsec].f_slope) frontfloor = P_GetZAt(sectors[front->camsec].f_slope, camera[0].x, camera[0].y); if (sectors[front->camsec].c_slope) frontceiling = P_GetZAt(sectors[front->camsec].c_slope, camera[0].x, camera[0].y); @@ -306,7 +306,7 @@ void P_CameraLineOpening(line_t *linedef) { frontfloor = sectors[front->heightsec].floorheight; frontceiling = sectors[front->heightsec].ceilingheight; - if (sectors[front->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[front->heightsec].f_slope) frontfloor = P_GetZAt(sectors[front->heightsec].f_slope, camera[0].x, camera[0].y); if (sectors[front->heightsec].c_slope) frontceiling = P_GetZAt(sectors[front->heightsec].c_slope, camera[0].x, camera[0].y); @@ -316,11 +316,12 @@ void P_CameraLineOpening(line_t *linedef) frontfloor = P_CameraGetFloorZ(mapcampointer, front, tmx, tmy, linedef); frontceiling = P_CameraGetCeilingZ(mapcampointer, front, tmx, tmy, linedef); } + if (back->camsec >= 0) { backfloor = sectors[back->camsec].floorheight; backceiling = sectors[back->camsec].ceilingheight; - if (sectors[back->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[back->camsec].f_slope) frontfloor = P_GetZAt(sectors[back->camsec].f_slope, camera[0].x, camera[0].y); if (sectors[back->camsec].c_slope) frontceiling = P_GetZAt(sectors[back->camsec].c_slope, camera[0].x, camera[0].y); @@ -329,7 +330,7 @@ void P_CameraLineOpening(line_t *linedef) { backfloor = sectors[back->heightsec].floorheight; backceiling = sectors[back->heightsec].ceilingheight; - if (sectors[back->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[back->heightsec].f_slope) frontfloor = P_GetZAt(sectors[back->heightsec].f_slope, camera[0].x, camera[0].y); if (sectors[back->heightsec].c_slope) frontceiling = P_GetZAt(sectors[back->heightsec].c_slope, camera[0].x, camera[0].y); @@ -340,104 +341,111 @@ void P_CameraLineOpening(line_t *linedef) backceiling = P_CameraGetCeilingZ(mapcampointer, back, tmx, tmy, linedef); } + fixed_t thingtop = mapcampointer->z + mapcampointer->height; + + if (frontceiling < backceiling) { - fixed_t thingtop = mapcampointer->z + mapcampointer->height; - - if (frontceiling < backceiling) - { - opentop = frontceiling; - highceiling = backceiling; - } - else - { - opentop = backceiling; - highceiling = frontceiling; - } - - if (frontfloor > backfloor) - { - openbottom = frontfloor; - lowfloor = backfloor; - } - else - { - openbottom = backfloor; - lowfloor = frontfloor; - } - - // Check for fake floors in the sector. - if (front->ffloors || back->ffloors) - { - ffloor_t *rover; - fixed_t highestceiling = highceiling; - fixed_t lowestceiling = opentop; - fixed_t highestfloor = openbottom; - fixed_t lowestfloor = lowfloor; - fixed_t delta1, delta2; - - // Check for frontsector's fake floors - if (front->ffloors) - for (rover = front->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) - continue; - - topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); - - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; - - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; - } - - // Check for backsectors fake floors - if (back->ffloors) - for (rover = back->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) - continue; - - topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); - - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; - - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; - } - - if (highestceiling < highceiling) - highceiling = highestceiling; - - if (highestfloor > openbottom) - openbottom = highestfloor; - - if (lowestceiling < opentop) - opentop = lowestceiling; - - if (lowestfloor > lowfloor) - lowfloor = lowestfloor; - } - openrange = opentop - openbottom; - return; + opentop = frontceiling; + highceiling = backceiling; } + else + { + opentop = backceiling; + highceiling = frontceiling; + } + + if (frontfloor > backfloor) + { + openbottom = frontfloor; + lowfloor = backfloor; + } + else + { + openbottom = backfloor; + lowfloor = frontfloor; + } + + // Check for fake floors in the sector. + if (front->ffloors || back->ffloors) + { + ffloor_t *rover; + fixed_t highestceiling = highceiling; + fixed_t lowestceiling = opentop; + fixed_t highestfloor = openbottom; + fixed_t lowestfloor = lowfloor; + fixed_t delta1, delta2; + + // Check for frontsector's fake floors + if (front->ffloors) + { + for (rover = front->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) + continue; + + topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); + + delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); + delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + + if (bottomheight < lowestceiling && delta1 >= delta2) + lowestceiling = bottomheight; + else if (bottomheight < highestceiling && delta1 >= delta2) + highestceiling = bottomheight; + + if (topheight > highestfloor && delta1 < delta2) + highestfloor = topheight; + else if (topheight > lowestfloor && delta1 < delta2) + lowestfloor = topheight; + } + } + + // Check for backsectors fake floors + if (back->ffloors) + { + for (rover = back->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) + continue; + + topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); + + delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); + delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + + if (bottomheight < lowestceiling && delta1 >= delta2) + lowestceiling = bottomheight; + else if (bottomheight < highestceiling && delta1 >= delta2) + highestceiling = bottomheight; + + if (topheight > highestfloor && delta1 < delta2) + highestfloor = topheight; + else if (topheight > lowestfloor && delta1 < delta2) + lowestfloor = topheight; + } + } + + if (highestceiling < highceiling) + highceiling = highestceiling; + + if (highestfloor > openbottom) + openbottom = highestfloor; + + if (lowestceiling < opentop) + opentop = lowestceiling; + + if (lowestfloor > lowfloor) + lowfloor = lowestfloor; + } + + openrange = opentop - openbottom; + return; } void P_LineOpening(line_t *linedef, mobj_t *mobj) @@ -466,40 +474,39 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) I_Assert(front != NULL); I_Assert(back != NULL); - { // Set open and high/low values here - fixed_t frontheight, backheight; + // Set open and high/low values here + fixed_t frontheight, backheight; - frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); + frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); - if (frontheight < backheight) - { - opentop = frontheight; - highceiling = backheight; - opentopslope = front->c_slope; - } - else - { - opentop = backheight; - highceiling = frontheight; - opentopslope = back->c_slope; - } + if (frontheight < backheight) + { + opentop = frontheight; + highceiling = backheight; + opentopslope = front->c_slope; + } + else + { + opentop = backheight; + highceiling = frontheight; + opentopslope = back->c_slope; + } - frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); + frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); - if (frontheight > backheight) - { - openbottom = frontheight; - lowfloor = backheight; - openbottomslope = front->f_slope; - } - else - { - openbottom = backheight; - lowfloor = frontheight; - openbottomslope = back->f_slope; - } + if (frontheight > backheight) + { + openbottom = frontheight; + lowfloor = backheight; + openbottomslope = front->f_slope; + } + else + { + openbottom = backheight; + lowfloor = frontheight; + openbottomslope = back->f_slope; } if (mobj) @@ -508,29 +515,33 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // Check for collision with front side's midtexture if Effect 4 is set if (linedef->flags & ML_EFFECT4 - && !linedef->polyobj // don't do anything for polyobjects! ...for now - ) { + && !linedef->polyobj) // don't do anything for polyobjects! ...for now + { side_t *side = &sides[linedef->sidenum[0]]; fixed_t textop, texbottom, texheight; fixed_t texmid, delta1, delta2; INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid - if (texnum) { + if (texnum) + { // Get the midtexture's height texheight = textures[texnum]->height << FRACBITS; // Set texbottom and textop to the Z coordinates of the texture's boundaries + if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) // "infinite" repeat { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = openbottom + side->rowoffset; - textop = opentop + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = openbottom + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = opentop + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); - } + texbottom = openbottom + side->rowoffset; + textop = opentop + side->rowoffset; + } + else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) + { + texbottom = openbottom + side->rowoffset; + textop = texbottom + texheight*(side->repeatcnt+1); + } + else + { + textop = opentop + side->rowoffset; + texbottom = textop - texheight*(side->repeatcnt+1); } texmid = texbottom+(textop-texbottom)/2; @@ -538,10 +549,13 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - texmid); delta2 = abs(thingtop - texmid); - if (delta1 > delta2) { // Below + if (delta1 > delta2) // Below + { if (opentop > texbottom) opentop = texbottom; - } else { // Above + } + else // Above + { if (openbottom < textop) openbottom = textop; } @@ -549,9 +563,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) } // Check for fake floors in the sector. - if (front->ffloors || back->ffloors - || linedef->polyobj - ) + if (front->ffloors || back->ffloors || linedef->polyobj) { ffloor_t *rover; @@ -567,6 +579,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) for (rover = front->ffloors; rover; rover = rover->next) { fixed_t topheight, bottomheight; + if (!(rover->flags & FF_EXISTS)) continue; @@ -584,7 +597,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { - if (bottomheight < lowestceiling) { + if (bottomheight < lowestceiling) + { lowestceiling = bottomheight; ceilingslope = *rover->b_slope; } @@ -594,7 +608,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF { - if (topheight > highestfloor) { + if (topheight > highestfloor) + { highestfloor = topheight; floorslope = *rover->t_slope; } @@ -624,7 +639,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { - if (bottomheight < lowestceiling) { + if (bottomheight < lowestceiling) + { lowestceiling = bottomheight; ceilingslope = *rover->b_slope; } @@ -634,7 +650,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF { - if (topheight > highestfloor) { + if (topheight > highestfloor) + { highestfloor = topheight; floorslope = *rover->t_slope; } @@ -650,29 +667,35 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); - if (polysec->floorheight < lowestceiling && delta1 >= delta2) { + + if (polysec->floorheight < lowestceiling && delta1 >= delta2) + { lowestceiling = polysec->floorheight; ceilingslope = NULL; } else if (polysec->floorheight < highestceiling && delta1 >= delta2) highestceiling = polysec->floorheight; - if (polysec->ceilingheight > highestfloor && delta1 < delta2) { + if (polysec->ceilingheight > highestfloor && delta1 < delta2) + { highestfloor = polysec->ceilingheight; floorslope = NULL; } else if (polysec->ceilingheight > lowestfloor && delta1 < delta2) lowestfloor = polysec->ceilingheight; } + if (highestceiling < highceiling) highceiling = highestceiling; - if (highestfloor > openbottom) { + if (highestfloor > openbottom) + { openbottom = highestfloor; openbottomslope = floorslope; } - if (lowestceiling < opentop) { + if (lowestceiling < opentop) + { opentop = lowestceiling; opentopslope = ceilingslope; } From a90c51ec0fb182892edf5dbeff268de284f4ce2a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 14:51:32 +0100 Subject: [PATCH 114/418] no u may be used uninitialised --- src/g_game.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_game.c b/src/g_game.c index 00d3f861b..47b975b92 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -946,6 +946,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) invertmouse = false; break; case 1: + default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver mouseaiming = player->spectator; invertmouse = cv_invertmouse.value; From 1d8be20962a528966c641c8c87cea10adb2ef807 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 19:01:54 +0100 Subject: [PATCH 115/418] disable director while in replay freecam --- src/k_director.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index 611c64701..eca7903f5 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -73,7 +73,7 @@ boolean K_DirectorIsAvailable(void) { if ((demo.playback && demo.title) || modeattacking) return false; - return ((gamestate == GS_LEVEL) && (demo.playback || (players[consoleplayer].spectator && !K_DirectorIsPlayerAlone()))); + return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && !K_DirectorIsPlayerAlone()))); } static boolean K_DirectorIsEnabled(void) From 258447c17bd596ef8459d2aea9c714d62e51039f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 19:01:54 +0100 Subject: [PATCH 116/418] disable director while in replay freecam --- src/k_director.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index fcd4660ce..121ee1d87 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -75,7 +75,7 @@ boolean K_DirectorIsAvailable(void) { if ((demo.playback && demo.title) || modeattacking) return false; - return ((gamestate == GS_LEVEL) && (demo.playback || (players[consoleplayer].spectator && !K_DirectorIsPlayerAlone()))); + return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && !K_DirectorIsPlayerAlone()))); } static boolean K_DirectorIsEnabled(void) From c4c995a9a35c8fba364c067d822a249b87f0d029 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 20:37:39 +0100 Subject: [PATCH 117/418] disable pause vhs effect when in freecam mode --- src/hu_stuff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 6cbb46148..7097e36a2 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -26,6 +26,7 @@ #include "i_video.h" #include "i_system.h" +#include "r_fps.h" #include "st_stuff.h" // ST_HEIGHT #include "r_local.h" @@ -2231,7 +2232,7 @@ void HU_DrawSongCredits(void) // void HU_Drawer(void) { - if (cv_vhseffect.value && (paused || (demo.playback && cv_playbackspeed.value > 1))) + if (cv_vhseffect.value && ((paused && !camera[R_GetViewNumber()].freecam) || (demo.playback && cv_playbackspeed.value > 1))) V_DrawVhsEffect(demo.rewinding); #ifndef NONET From 63b8cc1104a9c69af3b327b098a54076d5da6d78 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 20:37:39 +0100 Subject: [PATCH 118/418] disable pause vhs effect when in freecam mode --- src/hu_stuff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 6cbb46148..7097e36a2 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -26,6 +26,7 @@ #include "i_video.h" #include "i_system.h" +#include "r_fps.h" #include "st_stuff.h" // ST_HEIGHT #include "r_local.h" @@ -2231,7 +2232,7 @@ void HU_DrawSongCredits(void) // void HU_Drawer(void) { - if (cv_vhseffect.value && (paused || (demo.playback && cv_playbackspeed.value > 1))) + if (cv_vhseffect.value && ((paused && !camera[R_GetViewNumber()].freecam) || (demo.playback && cv_playbackspeed.value > 1))) V_DrawVhsEffect(demo.rewinding); #ifndef NONET From 8499ca358b397295e0541aea0a06c3c1fdc2e973 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 21:23:45 +0100 Subject: [PATCH 119/418] 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 28f75fde4..3112c7cc9 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2439,6 +2439,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(); @@ -2484,6 +2487,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(); From 006fde8fea12e0a82bcc2b7389d68669eaf58f54 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 21:24:48 +0100 Subject: [PATCH 120/418] 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 3112c7cc9..ddbccc92e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2435,7 +2435,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; } From 03259aeca0876c392875a2c780ea56bdb8717620 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 6 Jan 2025 22:02:34 +0100 Subject: [PATCH 121/418] let postimg stuff also apply to freecam --- src/p_local.h | 1 + src/p_mobj.c | 2 +- src/p_user.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_local.h b/src/p_local.h index 452b92dff..d330c8c34 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -156,6 +156,7 @@ void P_SlideCameraMove(camera_t *thiscam); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); void P_ResetLocalCamAiming(player_t *player); void P_ToggleDemoCamera(UINT8 viewnum); +void P_CalcChasePostImg(player_t *player, camera_t *thiscam); boolean P_PlayerInPain(player_t *player); void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); void P_ResetPlayer(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index e69e9192b..46fb35f65 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3232,7 +3232,7 @@ void P_DestroyRobots(void) } // the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person -static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) +void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); UINT16 postimgtype = 0; diff --git a/src/p_user.c b/src/p_user.c index a2b6b01c8..13750c594 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3739,6 +3739,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (thiscam->freecam || player->spectator) { P_DemoCameraMovement(thiscam, num); + P_CalcChasePostImg(player, thiscam); return true; } From eff6b31ee8a40d03cae83f15784960545b75e7d8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 6 Jan 2025 22:40:36 +0100 Subject: [PATCH 122/418] change director toggling handling - now not changable over console anymore, bind only! - it doesent save anymore so its always disabled at game start - moving while in spec state will disable director when active so stand still - disable it in splitscreen completely - only adjust view when toggling it on --- src/d_netcmd.c | 3 ++- src/g_game.c | 17 +++++------------ src/g_game.h | 2 -- src/k_director.c | 5 ++--- src/st_stuff.c | 3 +++ src/st_stuff.h | 2 ++ 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5156ed0c5..9b293aef6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -572,7 +572,8 @@ static CV_PossibleValue_t ps_descriptor_cons_t[] = { {1, "Average"}, {2, "SD"}, {3, "Minimum"}, {4, "Maximum"}, {0, NULL}}; consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +// only there to better keep track of it globally +consvar_t cv_director = {"director", "Off", CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebugdirector = {"debugdirector", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showdirectorhud = {"showdirectorhud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/g_game.c b/src/g_game.c index 47b975b92..1bcd9778c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -334,11 +334,6 @@ boolean precache = true; // if true, load all graphics at start INT16 prevmap, nextmap; -// save if director is enabled -// so demos can disable it by default and restore it after -static int directorstate = 0; -tic_t directortoggletimer = 0; - static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; consvar_t cv_recordmultiplayerdemos = {"netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -884,6 +879,9 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) if ((moveinput || cmd->buttons) && displayplayers[0] != consoleplayer && ssplayer == 1) { + if (cv_director.value) + CV_SetValue(&cv_director, 0); + displayplayers[0] = consoleplayer; R_ResetViewInterpolation(0); camera[0].reset_aiming = true; @@ -7359,8 +7357,8 @@ post_compat: players[i].kartweight = kartweight[i]; } - directorstate = cv_director.value; - CV_SetValue(&cv_director, 0); + if (cv_director.value) + CV_SetValue(&cv_director, 0); demo.deferstart = true; } @@ -7925,11 +7923,6 @@ void G_StopDemo(void) { Z_Free(demobuf.buffer); demobuf.buffer = NULL; - if (demo.playback) - { - CV_SetValue(&cv_director, directorstate); - directorstate = 0; - } demo.playback = false; if (demo.title) modeattacking = false; diff --git a/src/g_game.h b/src/g_game.h index ba26cd507..10c2a6156 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -229,8 +229,6 @@ extern angle_t localangle[MAXSPLITSCREENPLAYERS]; extern INT32 localaiming[MAXSPLITSCREENPLAYERS]; // should be an angle_t but signed extern boolean camspin[MAXSPLITSCREENPLAYERS]; // SRB2Kart -extern tic_t directortoggletimer; - // // GAME // diff --git a/src/k_director.c b/src/k_director.c index eca7903f5..402f5d039 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -71,7 +71,7 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) boolean K_DirectorIsAvailable(void) { - if ((demo.playback && demo.title) || modeattacking) + if (splitscreen || (demo.playback && demo.title) || modeattacking) return false; return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && !K_DirectorIsPlayerAlone()))); } @@ -422,10 +422,9 @@ void K_ToggleDirector(void) if (!K_DirectorIsAvailable()) return; - G_AdjustView(1, 1, true); - if (!K_DirectorIsEnabled()) { + G_AdjustView(1, 1, true); directorinfo.cooldown = 0; // switch immediately } diff --git a/src/st_stuff.c b/src/st_stuff.c index 523bbc44a..64e244b78 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -53,6 +53,9 @@ UINT16 objectsdrawn = 0; +// dumb fade thing for director toggle +tic_t directortoggletimer = 0; + // // STATUS BAR DATA // diff --git a/src/st_stuff.h b/src/st_stuff.h index 250db1e7f..d289e64ce 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -23,6 +23,8 @@ // STATUS BAR // +extern tic_t directortoggletimer; + // Called by main loop. void ST_Ticker(void); From 2e31e085227a1afde497964dd9603c14bae581cd Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 6 Jan 2025 22:40:56 +0100 Subject: [PATCH 123/418] check for 0 to avoid division by 0 --- src/sdl/mixer_sound.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index ced911eba..8059a93df 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -282,6 +282,9 @@ static Mix_Chunk *ds2chunk(void *stream) freq = READUINT16(stream); samples = READUINT32(stream); + if (freq == 0) + return NULL; // division by zero + // convert from signed 8bit ???hz to signed 16bit 44100hz. switch(freq) { From c8737bd43f35d7af2c5436d6afcaf9d3292043e3 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 6 Jan 2025 22:50:15 +0100 Subject: [PATCH 124/418] make this more complicated due to a "-" --- src/st_stuff.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 64e244b78..d189e2c23 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -656,18 +656,19 @@ static void ST_drawLevelTitle(void) // returns the actual button name for any gamecontrol // if unbound is set, it returns "Unbound" as a string should there be no button bound to a gamecontrol -static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound) +// if gamectrl is set, it adds an extra "-" for cases where theres also a hardcoded button like accelerate +static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound, boolean gamectrl) { static char buttname[32] = ""; const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind if (butt1 == NULL && butt2 == NULL) // not bound to a button - snprintf(buttname, 32, (unbound ? "%s - %s" : "- %s - %s"), (unbound ? "Unbound" : ""), inputtext); + snprintf(buttname, 32, (unbound ? "%s - %s" : (gamectrl ? "-%s - %s" : "%s - %s")), (unbound ? "Unbound" : ""), inputtext); else if (butt1 != NULL && butt2 != NULL) // bound to two buttons snprintf(buttname, 32, "%s/%s - %s", butt1, butt2, inputtext); else // bound to only one - snprintf(buttname, 32, "- %s - %s", (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : ""), inputtext); + snprintf(buttname, 32, (gamectrl ? "-%s - %s" : "%s - %s"), (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : ""), inputtext); return buttname; } @@ -796,16 +797,16 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-50, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director", true)); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director", true, false)); } else { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); } } } From fd5575ace58e7a7090c319e5c788d39fe621356b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 6 Jan 2025 22:50:15 +0100 Subject: [PATCH 125/418] make this more complicated due to a "-" --- src/st_stuff.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 64e244b78..d189e2c23 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -656,18 +656,19 @@ static void ST_drawLevelTitle(void) // returns the actual button name for any gamecontrol // if unbound is set, it returns "Unbound" as a string should there be no button bound to a gamecontrol -static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound) +// if gamectrl is set, it adds an extra "-" for cases where theres also a hardcoded button like accelerate +static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound, boolean gamectrl) { static char buttname[32] = ""; const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind if (butt1 == NULL && butt2 == NULL) // not bound to a button - snprintf(buttname, 32, (unbound ? "%s - %s" : "- %s - %s"), (unbound ? "Unbound" : ""), inputtext); + snprintf(buttname, 32, (unbound ? "%s - %s" : (gamectrl ? "-%s - %s" : "%s - %s")), (unbound ? "Unbound" : ""), inputtext); else if (butt1 != NULL && butt2 != NULL) // bound to two buttons snprintf(buttname, 32, "%s/%s - %s", butt1, butt2, inputtext); else // bound to only one - snprintf(buttname, 32, "- %s - %s", (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : ""), inputtext); + snprintf(buttname, 32, (gamectrl ? "-%s - %s" : "%s - %s"), (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : ""), inputtext); return buttname; } @@ -796,16 +797,16 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-50, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director", true)); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director", true, false)); } else { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); } } } From aa00419198c588c27760d0271317fc409fe39598 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 7 Jan 2025 14:52:19 +0300 Subject: [PATCH 126/418] 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 e47a85a17..831aceac1 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -182,6 +182,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" @@ -348,7 +349,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)); From 03e45f459008315749cecc8a04c0c83be10ae039 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jan 2025 16:28:38 +0100 Subject: [PATCH 127/418] check for cam subsector since we can move it around and i added this to freecam mode, subsector may be null for reason so better be safe than sorry --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 46fb35f65..2b120b99c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3141,7 +3141,7 @@ static boolean P_CameraCheckHeat(camera_t *thiscam) sector_t *sector; fixed_t halfheight; - if (!thiscam) + if (!thiscam || !thiscam->subsector) return false; halfheight = thiscam->z + (thiscam->height >> 1); @@ -3179,7 +3179,7 @@ static boolean P_CameraCheckWater(camera_t *thiscam) sector_t *sector; fixed_t halfheight; - if (!thiscam) + if (!thiscam || !thiscam->subsector) return false; halfheight = thiscam->z + (thiscam->height >> 1); From fe3ff155396528a86f87fe20cf8aba2cb0c386c6 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jan 2025 16:29:33 +0100 Subject: [PATCH 128/418] readd check for banan this time without mobjwasremoved just check if banan exists --- src/k_kart.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index 4dafb5fd2..1b42bf627 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4148,6 +4148,10 @@ void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source) mobj_t *cachenext; killnext: + + if (!banana) + return; + cachenext = banana->hnext; if (banana->health) From 3b60cb2bcd14e7bdb9e4387c5bde4dcd18f6bdf4 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jan 2025 16:30:32 +0100 Subject: [PATCH 129/418] replace common damage magic numbers with named macros that stuff always confused me before lol --- src/d_netcmd.c | 4 ++-- src/g_game.c | 4 ++-- src/p_enemy.c | 10 ++++++---- src/p_inter.c | 13 ++++++------- src/p_local.h | 4 ++++ src/p_map.c | 8 ++++---- src/p_mobj.c | 31 +++++++++++++++++-------------- src/p_spec.c | 4 ++-- src/p_tick.c | 2 +- src/p_user.c | 8 ++------ 10 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a172cde96..363e55f0b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3247,7 +3247,7 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum) return; if (players[respawnplayer].mo) - P_DamageMobj(players[respawnplayer].mo, NULL, NULL, 10000); + P_DamageMobj(players[respawnplayer].mo, NULL, NULL, DMG_INSTAKILL); demo_extradata[playernum] |= DXD_RESPAWN; } @@ -3949,7 +3949,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) if (!players[playernum].spectator) { if (players[playernum].mo) - P_DamageMobj(players[playernum].mo, NULL, NULL, 10000); + P_DamageMobj(players[playernum].mo, NULL, NULL, DMG_INSTAKILL); else players[playernum].playerstate = PST_REBORN; } diff --git a/src/g_game.c b/src/g_game.c index 2e2155f98..fbe506f50 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4586,7 +4586,7 @@ void G_ReadDemoExtraData(void) if (extradata & DXD_RESPAWN) { if (players[p].mo) - P_DamageMobj(players[p].mo, NULL, NULL, 10000); // Is this how this should work..? + P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); // Is this how this should work..? } if (extradata & DXD_SKIN) { @@ -4652,7 +4652,7 @@ void G_ReadDemoExtraData(void) { players[p].spectator = true; if (players[p].mo) - P_DamageMobj(players[p].mo, NULL, NULL, 10000); + P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); else players[p].playerstate = PST_REBORN; } diff --git a/src/p_enemy.c b/src/p_enemy.c index dfb237d74..1ee8b9a2c 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3920,10 +3920,12 @@ void A_MineExplode(mobj_t *actor) for (d = 0; d < 16; d++) K_SpawnKartExplosion(actor->x, actor->y, actor->z, explodedist + 32*mapobjectscale, 32, type, d*(ANGLE_45/4), true, false, actor->target); // 32 <-> 64 + skincolors_t color = SKINCOLOR_KETCHUP; + if (actor->target && actor->target->player) - K_SpawnMineExplosion(actor, actor->target->player->skincolor); - else - K_SpawnMineExplosion(actor, SKINCOLOR_KETCHUP); + color = actor->target->player->skincolor; + + K_SpawnMineExplosion(actor, color); P_SpawnMobj(actor->x, actor->y, actor->z, MT_MINEEXPLOSIONSOUND); @@ -10137,7 +10139,7 @@ void A_RemoteDamage(mobj_t *actor) if (locvar2 == 1) // Kill mobj! { if (target->player) // players die using P_DamageMobj instead for some reason - P_DamageMobj(target, source, source, 10000); + P_DamageMobj(target, source, source, DMG_INSTAKILL); else P_KillMobj(target, source, source); } diff --git a/src/p_inter.c b/src/p_inter.c index d4a5b3c1d..ce7494ef8 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2364,10 +2364,9 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN * player is hit by a ring, the player who shot it. In some * cases, the target will go after this object after * receiving damage. This can be NULL. - * \param damage Amount of damage to be dealt. 10000 is instant death. + * \param damage Amount of damage to be dealt. DMG_INSTAKILL is instant death. * \return True if the target sustained damage, otherwise false. * \todo Clean up this mess, split into multiple functions. - * \todo Get rid of the magic number 10000. * \sa P_KillMobj */ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) @@ -2384,8 +2383,8 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da // Spectator handling if (netgame) { - if (damage == 42000 && target->player && target->player->spectator) - damage = 10000; + if (damage == DMG_SPECTATOR && target->player && target->player->spectator) + damage = DMG_INSTAKILL; else if (target->player && target->player->spectator) return false; @@ -2524,7 +2523,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da { if ((G_BattleGametype()) && cv_suddendeath.value && !player->powers[pw_flashing] && !player->powers[pw_invulnerability]) - damage = 10000; + damage = DMG_INSTAKILL; } // Player hits another player @@ -2538,7 +2537,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // Instant-Death - if (damage == 10000) + if (damage == DMG_INSTAKILL) P_KillPlayer(player, source, damage); else if (player->kartstuff[k_invincibilitytimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->powers[pw_flashing]) { @@ -2591,7 +2590,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da else { player->health -= damage; // mirror mobj health here - if (damage < 10000) + if (damage < DMG_INSTAKILL) { target->player->powers[pw_flashing] = K_GetKartFlashing(target->player); if (damage > 0) // don't spill emeralds/ammo/panels for shield damage diff --git a/src/p_local.h b/src/p_local.h index 4570ccd0c..69417bcda 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -435,6 +435,10 @@ typedef struct BasicFF_s INT32 Magnitude; ///< Magnitude of the effect, in the range from 0 through 10,000. } BasicFF_t; +// replace damage magic numbers with smth readable +#define DMG_INSTAKILL 10000 +#define DMG_SPECTATOR 42000 + void P_ForceFeed(const player_t *player, INT32 attack, INT32 fade, tic_t duration, INT32 period); void P_ForceConstant(const BasicFF_t *FFInfo); void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End); diff --git a/src/p_map.c b/src/p_map.c index 707ef26b0..2a803304d 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -724,7 +724,7 @@ static boolean PIT_CheckThing(mobj_t *thing) HU_SetCEchoDuration(5); HU_DoCEcho(va("%s\\was hit by a kitchen sink.\\\\\\\\", player_names[thing->player-players])); I_OutputMsg("%s was hit by a kitchen sink.\n", player_names[thing->player-players]); - P_DamageMobj(thing, tmthing, tmthing->target, 10000); + P_DamageMobj(thing, tmthing, tmthing->target, DMG_INSTAKILL); P_KillMobj(tmthing, thing, thing); } @@ -991,7 +991,7 @@ static boolean PIT_CheckThing(mobj_t *thing) HU_SetCEchoDuration(5); HU_DoCEcho(va("%s\\was hit by a kitchen sink.\\\\\\\\", player_names[tmthing->player-players])); I_OutputMsg("%s was hit by a kitchen sink.\n", player_names[tmthing->player-players]); - P_DamageMobj(tmthing, thing, thing->target, 10000); + P_DamageMobj(tmthing, thing, thing->target, DMG_INSTAKILL); P_KillMobj(thing, tmthing, tmthing); } @@ -3674,7 +3674,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) { // Crush the object if (netgame && thing->player && thing->player->spectator) - P_DamageMobj(thing, NULL, NULL, 42000); // Respawn crushed spectators + P_DamageMobj(thing, NULL, NULL, DMG_SPECTATOR); // Respawn crushed spectators else { if (!killer) @@ -3684,7 +3684,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) killer->threshold = 44; // Special flag for crushing } if (!thing->player) - P_DamageMobj(thing, killer, killer, 10000); + P_DamageMobj(thing, killer, killer, DMG_INSTAKILL); else K_SquishPlayer(thing->player, killer, killer); // SRB2kart - Squish instead of kill } diff --git a/src/p_mobj.c b/src/p_mobj.c index 8cbf709c5..482da8833 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -435,7 +435,7 @@ void P_ExplodeMissile(mobj_t *mo) } // Hack: Release an animal. - P_DamageMobj(mo, NULL, NULL, 10000); + P_DamageMobj(mo, NULL, NULL, DMG_INSTAKILL); } mo->flags &= ~MF_MISSILE; @@ -1363,12 +1363,16 @@ void P_XYMovement(mobj_t *mo) oldy = mo->y; // adjust various things based on slope - if (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8) { - if (!P_IsObjectOnGround(mo)) { // We fell off at some point? Do the twisty thing! + if (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8) + { + if (!P_IsObjectOnGround(mo)) // We fell off at some point? Do the twisty thing! + { P_SlopeLaunch(mo); xmove = mo->momx; ymove = mo->momy; - } else { // Still on the ground. + } + else // Still on the ground. + { slopemom.x = xmove; slopemom.y = ymove; slopemom.z = 0; @@ -1381,7 +1385,8 @@ void P_XYMovement(mobj_t *mo) oldslope = mo->standingslope; } - } else if (P_IsObjectOnGround(mo) && !mo->momz) + } + else if (P_IsObjectOnGround(mo) && !mo->momz) predictedz = mo->z; // Pushables can break some blocks @@ -3008,11 +3013,6 @@ void P_MobjCheckWater(mobj_t *mobj) else if (mobj->eflags & MFE_VERTICALFLIP && mobj->momz > FixedMul(-min, mobj->scale)) mobj->momz = FixedMul(-min, mobj->scale); - /*if (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->momz > FixedMul(max, mobj->scale)) - mobj->momz = FixedMul(max, mobj->scale); - else if (mobj->eflags & MFE_VERTICALFLIP && mobj->momz < FixedMul(-max, mobj->scale)) - mobj->momz = FixedMul(-max, mobj->scale);*/ - p->kartstuff[k_waterskip]++; } @@ -4856,7 +4856,13 @@ static void P_Boss7Thinker(mobj_t *mobj) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && (mo2->spawnpoint->options & 7) == waypointNum) + + if (mo2->type != MT_BOSS3WAYPOINT) + continue; + if (!mo2->spawnpoint) + continue; + + if ((mo2->spawnpoint->options & 7) == waypointNum) { hitspot = mo2; break; @@ -5699,9 +5705,6 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y if (!dest || dest->health <= 0 || !dest->player || !source->tracer) return; - // change angle - //source->angle = R_PointToAngle2(source->x, source->y, tx, ty); - // change slope dist = P_AproxDistance(P_AproxDistance(tx - source->x, ty - source->y), tz - source->z); diff --git a/src/p_spec.c b/src/p_spec.c index a933c214f..4471a1285 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3339,10 +3339,10 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers case 6: // Death Pit (Camera Tilt) case 7: // Death Pit (No Camera Tilt) if (roversector || P_MobjReadyToTrigger(player->mo, sector)) - P_DamageMobj(player->mo, NULL, NULL, 10000); + P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL); break; case 8: // Instant Kill - P_DamageMobj(player->mo, NULL, NULL, 10000); + P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL); break; case 9: // Ring Drainer (Floor Touch) case 10: // Ring Drainer (No Floor Touch) diff --git a/src/p_tick.c b/src/p_tick.c index c3850f8c4..c64e83b33 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -670,7 +670,7 @@ void P_Ticker(boolean run) if (!players[i].mo) continue; - P_DamageMobj(players[i].mo, NULL, NULL, 10000); + P_DamageMobj(players[i].mo, NULL, NULL, DMG_INSTAKILL); } } diff --git a/src/p_user.c b/src/p_user.c index 832a1565c..8e027e4ec 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -362,7 +362,6 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor) if (inflictor) { ang = R_PointToAngle2(inflictor->x, inflictor->y, player->mo->x, player->mo->y); // SRB2kart - //ang = R_PointToAngle2(inflictor->x-inflictor->momx, inflictor->y - inflictor->momy, player->mo->x - player->mo->momx, player->mo->y - player->mo->momy); // explosion and rail rings send you farther back, making it more difficult // to recover @@ -2485,7 +2484,7 @@ static void P_MovePlayer(player_t *player) && !(player->mo->flags & MF_NOCLIP)) { if ((netgame || multiplayer) && player->spectator) - P_DamageMobj(player->mo, NULL, NULL, 42000); // Respawn crushed spectators + P_DamageMobj(player->mo, NULL, NULL, DMG_SPECTATOR); // Respawn crushed spectators else { K_SquishPlayer(player, NULL, NULL); // SRB2kart - we don't kill when squished, we squish when squished. @@ -2676,9 +2675,6 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) if (mo->flags & MF_MONITOR) continue; // Monitors cannot be 'nuked'. - //if (!G_BattleGametype() && mo->type == MT_PLAYER) - // continue; // Don't hurt players in Co-Op! - if (abs(inflictor->x - mo->x) > radius || abs(inflictor->y - mo->y) > radius || abs(inflictor->z - mo->z) > radius) continue; // Workaround for possible integer overflow in the below -Red @@ -4294,7 +4290,7 @@ void P_DoTimeOver(player_t *player) if (player->mo) { S_StopSound(player->mo); - P_DamageMobj(player->mo, NULL, NULL, 10000); + P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL); } player->lives = 0; From d41b6c185a1c0f296d45037eb26da165c3491d9c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jan 2025 18:47:12 +0100 Subject: [PATCH 130/418] fix freecam aim getting stuck and other issues - gamepads now aim like they used to and at same speed as keyboard - aim reset has been changed so it resets automatically, but also can be manually reset with centerview - aiming is locked during cam reset --- src/p_local.h | 2 + src/p_user.c | 126 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 82 insertions(+), 46 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index d330c8c34..d80223531 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -81,6 +81,8 @@ typedef struct camera_s boolean chase; boolean freecam; + boolean keyboardlook; + angle_t localangle; INT32 localaiming; diff --git a/src/p_user.c b/src/p_user.c index 13750c594..0675808b0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3167,15 +3167,20 @@ void P_ToggleDemoCamera(UINT8 viewnum) static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS]; +#define intsign(n) \ + ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) + static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { INT32 laim, forward, side, axis; // these ones used for multiple conditions - boolean turnleft, turnright; - boolean usejoystick; + boolean turnleft, turnright, mouseaiming; + boolean invertmouse, usejoystick, kbl; angle_t lang; + INT32 player_invert; const UINT8 forplayer = num+1; + player_t *player = ((forplayer == 1) ? &players[consoleplayer] : &players[displayplayers[forplayer]]); memset(&cameracmd[num], 0, sizeof(ticcmd_t)); // initialize cmd @@ -3183,21 +3188,30 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) lang = cam->localangle; laim = cam->localaiming; + kbl = cam->keyboardlook; - switch (num) + switch (forplayer) { - case 1: - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); - break; case 2: - G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); + mouseaiming = player->spectator; + invertmouse = cv_invertmouse2.value; break; case 3: - G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + mouseaiming = false; + invertmouse = false; break; - case 0: + case 4: + G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + mouseaiming = false; + invertmouse = false; + break; + case 1: default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + mouseaiming = player->spectator; + invertmouse = cv_invertmouse.value; break; } @@ -3223,7 +3237,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) axis = -axis; } - if (gamepadjoystickmove && axis != 0) + if (usejoystick && axis != 0) { turnright = turnright || (axis > 0); turnleft = turnleft || (axis < 0); @@ -3242,13 +3256,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) side -= sidemove[1]; } - if (analogjoystickmove && axis != 0) - { - // JOYAXISRANGE should be 1023 (divide by 1024) - cmd->angleturn = (INT16)(cmd->angleturn - (((axis * angleturn[1]) >> 10))); // ANALOG! - side += ((axis * sidemove[0]) >> 10); - } - cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); axis = JoyAxis(AXISAIM, forplayer); @@ -3261,6 +3268,11 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_fire, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; + // drift with any button/key + axis = JoyAxis(AXISDRIFT, forplayer); + if (InputDown(gc_drift, forplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_DRIFT; + // float and sink axis = JoyAxis(AXISMOVE, forplayer); if (InputDown(gc_accelerate, forplayer) || (usejoystick && axis > 0)) @@ -3269,27 +3281,59 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_brake, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_BRAKE; + // spectator aiming shit, ahhhh... + player_invert = invertmouse ? -1 : 1; + + // mouse look stuff (mouse look is not the same as mouse aim) + kbl = false; + // looking up/down - laim += (mlooky<<19); + laim += (mlooky<<19)*player_invert; axis = JoyAxis(AXISLOOK, forplayer); - if (analogjoystickmove && axis != 0 && lookaxis) - laim += (axis<<16); + // spring back if not using keyboard neither mouselookin' + if (!kbl && !lookaxis && !mouseaiming) + laim = 0; - if (InputDown(gc_lookup, forplayer) || (gamepadjoystickmove && axis < 0)) + if (InputDown(gc_lookup, forplayer) || (usejoystick && axis < 0)) { laim += KB_LOOKSPEED; + kbl = true; } - else if (InputDown(gc_lookdown, forplayer) || (gamepadjoystickmove && axis > 0)) + else if (InputDown(gc_lookdown, forplayer) || (usejoystick && axis > 0)) { laim -= KB_LOOKSPEED; + kbl = true; } if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V + { laim = 0; + cam->reset_aiming = false; + } - cmd->aiming = G_ClipAimingPitch(&laim); + //if (cam->reset_aiming || ((cmd->buttons & BT_DRIFT) && !cam->button_a_held)) + if (cam->reset_aiming) + { + INT32 aiming = laim; + INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(laim)); + + if (abs(smooth) < abs(aiming)) + { + laim -= (angle_t)(smooth * intsign(aiming)); + } + else + { + laim = 0; + cam->reset_aiming = false; // completely smoothed out + } + } + + if (!cam->reset_aiming) + { + cmd->aiming = G_ClipAimingPitch(&laim); + } mousex = mousey = mlooky = 0; @@ -3312,24 +3356,21 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) lang += (cmd->angleturn<<16); cam->localangle = lang; - cam->localaiming = laim; + if (!cam->reset_aiming) + { + cam->localaiming = laim; + } + cam->keyboardlook = kbl; return cmd; } -#define intsign(n) \ - ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) - static void P_DemoCameraMovement(camera_t *cam, UINT8 num) { ticcmd_t *cmd; angle_t thrustangle; player_t *lastp; const UINT8 forplayer = num+1; - boolean moving = false; - - if (encoremode) - cam->postimg |= POSTIMG_MIRROR; cam->localangle = cam->angle; cam->localaiming = cam->aiming; @@ -3337,14 +3378,8 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // first off we need to get button input cmd = P_CameraCmd(cam, num); - // let centerview work proper - if (InputDown(gc_centerview, forplayer)) - { - cam->aiming = 0; - cam->reset_aiming = false; - } - - if (cmd->aiming != 0) + // make sure we dont aim away during reset + if (!cam->reset_aiming) { cam->aiming = cmd->aiming << FRACBITS; } @@ -3361,17 +3396,15 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) { case 1: cam->z += spd; - moving = true; break; case -1: cam->z -= spd; - moving = true; break; } } - if (!(InputDown(gc_camfloat, forplayer) || InputDown(gc_camsink, forplayer)) && cam->button_a_held) + if (!(cmd->buttons & (BT_ACCELERATE | BT_DRIFT) || InputDown(gc_camfloat, forplayer)) && cam->button_a_held) { cam->button_a_held--; } @@ -3388,9 +3421,10 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) cam->reset_aiming = false; } - if (cmd->forwardmove != 0) + if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V { - moving = true; + cam->aiming = 0; + cam->reset_aiming = false; } // After switching to democam, the vertical angle of @@ -3399,7 +3433,8 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // forward/back will have a slope. So, as long as democam // controls haven't been used to alter the vertical angle, // slowly reset it to flat. - if ((cam->reset_aiming && moving) || ((InputDown(gc_camsink, forplayer)) && !cam->button_a_held)) + //if (cam->reset_aiming || ((cmd->buttons & BT_DRIFT) && !cam->button_a_held)) + if (cam->reset_aiming) { INT32 aiming = cam->aiming; INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming)); @@ -3424,7 +3459,6 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) cam->x += FixedMul(spd, FINECOSINE(thrustangle)); cam->y += FixedMul(spd, FINESINE(thrustangle)); - if (!cam->reset_aiming) { cam->z += FixedMul(spd, AIMINGTOSLOPE(cam->aiming)); From d623820833ea97f5f14050ac7dfdcc494b2afe7b Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jan 2025 19:49:36 +0100 Subject: [PATCH 131/418] 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 9df4e9702..15a50b314 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1063,11 +1063,6 @@ mobj_t *viewmobj; static void R_SetupCommonFrame(player_t * player, subsector_t * subsector) { - if (!player) - { - return; - } - newview->player = player; newview->x += quake.x; @@ -1076,7 +1071,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; From bbb489385784089af9b350dc56181190a7ef2073 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 04:47:25 +0100 Subject: [PATCH 132/418] throw this into a function smth smth nesting --- src/k_kart.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 26c6b4d1b..c294f1787 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3116,6 +3116,29 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I return NULL; } +static UINT16 K_DriftSparkColor(player_t *player, INT32 charge) +{ + UINT16 color = SKINCOLOR_NONE; + + if (charge >= K_GetKartDriftSparkValue(player)*4) + { + color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); + } + else if (charge >= K_GetKartDriftSparkValue(player)*2) + { + if (charge <= (K_GetKartDriftSparkValue(player)*2)+(24*3)) + color = SKINCOLOR_RASPBERRY; // transition + else + color = SKINCOLOR_KETCHUP; + } + else + { + color = SKINCOLOR_SAPPHIRE; + } + + return color; +} + #define DRIFTSPARKGROWTICS 8 static void K_SpawnDriftSparks(player_t *player) @@ -3177,21 +3200,7 @@ static void K_SpawnDriftSparks(player_t *player) spark->sloperoll = player->mo->sloperoll; } - if (player->kartstuff[k_driftcharge] >= K_GetKartDriftSparkValue(player)*4) - { - spark->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); - } - else if (player->kartstuff[k_driftcharge] >= K_GetKartDriftSparkValue(player)*2) - { - if (player->kartstuff[k_driftcharge] <= (K_GetKartDriftSparkValue(player)*2)+(24*3)) - spark->color = SKINCOLOR_RASPBERRY; // transition - else - spark->color = SKINCOLOR_KETCHUP; - } - else - { - spark->color = SKINCOLOR_SAPPHIRE; - } + spark->color = K_DriftSparkColor(player, player->kartstuff[k_driftcharge]); if ((player->kartstuff[k_drift] > 0 && player->cmd.driftturn > 0) // Inward drifts || (player->kartstuff[k_drift] < 0 && player->cmd.driftturn < 0)) From 4acf6d336bec0261b83ce72c97e1ad49831f61db Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 05:08:27 +0100 Subject: [PATCH 133/418] add colourized speedlines smth i had laying around in lugstuff --- src/k_kart.c | 69 +++++++++++++++++++++++++++++++++++++++++++--------- src/k_kart.h | 8 +++--- src/m_menu.c | 18 ++++++++------ 3 files changed, 72 insertions(+), 23 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 13853a4c4..533086aaf 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -74,6 +74,9 @@ IMPL_HUD_OFFSET(stat); // Stats #undef IMPL_HUD_OFFSET_X #undef IMPL_HUD_OFFSET_Y +static CV_PossibleValue_t colorspeedlines_cons_t[] = {{0, "Off"}, {1, "Normal"}, {2, "+Driftcharge"}, {0, NULL}}; +consvar_t cv_coloredspeedlines = {"colorizedspeedlines", "Off", CV_SAVE, colorspeedlines_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + //extra hud things consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -766,6 +769,8 @@ void K_RegisterKartStuff(void) #undef REG_HUD_OFFSET_X #undef REG_HUD_OFFSET_Y + CV_RegisterVar(&cv_coloredspeedlines); + CV_RegisterVar(&cv_showstats); CV_RegisterVar(&cv_showinput); @@ -5123,6 +5128,57 @@ void K_KartPlayerHUDUpdate(player_t *player) player->kartstuff[k_cardanimation] = 0; } +static inline void K_SpawnNormalSpeedLines(player_t *player) +{ + mobj_t *fast = P_SpawnMobj(player->mo->x + (P_RandomRange(-36,36) * player->mo->scale), + player->mo->y + (P_RandomRange(-36,36) * player->mo->scale), + player->mo->z + (player->mo->height/2) + (P_RandomRange(-20,20) * player->mo->scale), + MT_FASTLINE); + + fast->angle = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); + fast->momx = 3*player->mo->momx/4; + fast->momy = 3*player->mo->momy/4; + fast->momz = 3*player->mo->momz/4; + P_SetTarget(&fast->target, player->mo); // easier lua access + + K_MatchGenericExtraFlags(fast, player->mo); + + if (cv_coloredspeedlines.value) + { + const boolean goodSpeed = (player->speed >= (3*K_GetKartSpeed(player, false))/4); + + // cant have nice shit cause of synched rng + if (player->kartstuff[k_eggmanexplode]) + { + // Make it red when you have the eggman speed boost + fast->color = SKINCOLOR_RED; + fast->colorized = true; + } + else if (player->kartstuff[k_invincibilitytimer]) + { + fast->color = player->mo->color; + fast->colorized = true; + } + else if (goodSpeed) + { + UINT8 driftcolor = SKINCOLOR_NONE; + + if (cv_coloredspeedlines.value == 2 && player->kartstuff[k_driftboost]) + { + if (player->kartstuff[k_driftboost] <= 20) + driftcolor = SKINCOLOR_SAPPHIRE; + else if (player->kartstuff[k_driftboost] <= 50) + driftcolor = SKINCOLOR_RASPBERRY; + else if (player->kartstuff[k_driftboost] <= 125) + driftcolor = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); + } + + fast->color = (leveltime & 1) ? player->mo->color : driftcolor; + fast->colorized = true; + } + } +} + /** \brief Decreases various kart timers and powers per frame. Called in P_PlayerThink in p_user.c \param player player object passed from P_PlayerThink @@ -5142,18 +5198,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) K_GetKartBoostPower(player); // Speed lines - if ((player->kartstuff[k_sneakertimer] || player->kartstuff[k_driftboost] || player->kartstuff[k_startboost]) && player->speed > 0) + if ((player->kartstuff[k_sneakertimer] || player->kartstuff[k_driftboost] || player->kartstuff[k_startboost] /*|| player->kartstuff[k_eggmanexplode]*/) && player->speed > 0) // gotta love the speedlines calling synched rng :chaosleep: { - mobj_t *fast = P_SpawnMobj(player->mo->x + (P_RandomRange(-36,36) * player->mo->scale), - player->mo->y + (P_RandomRange(-36,36) * player->mo->scale), - player->mo->z + (player->mo->height/2) + (P_RandomRange(-20,20) * player->mo->scale), - MT_FASTLINE); - fast->angle = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); - fast->momx = 3*player->mo->momx/4; - fast->momy = 3*player->mo->momy/4; - fast->momz = 3*player->mo->momz/4; - P_SetTarget(&fast->target, player->mo); // easier lua access - K_MatchGenericExtraFlags(fast, player->mo); + K_SpawnNormalSpeedLines(player); } if (player->playerstate == PST_DEAD || player->kartstuff[k_respawn] > 1) // Ensure these are set correctly here diff --git a/src/k_kart.h b/src/k_kart.h index 34c59c622..ac860ab7e 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -22,14 +22,12 @@ boolean K_UseColorHud(void); void K_RegisterKartStuff(void); -extern consvar_t cv_colorizedhud; -extern consvar_t cv_colorizeditembox; -extern consvar_t cv_colorizedhudcolor; +extern consvar_t cv_coloredspeedlines; +extern consvar_t cv_colorizedhud, cv_colorizeditembox, cv_colorizedhudcolor; extern consvar_t cv_darkitembox; extern consvar_t cv_biglaps; extern consvar_t cv_highresportrait; -extern consvar_t cv_stat_xoffset; -extern consvar_t cv_stat_yoffset; +extern consvar_t cv_stat_xoffset, cv_stat_yoffset; extern consvar_t cv_showstats; extern consvar_t cv_showlaptimes; extern consvar_t cv_battlespeedo; diff --git a/src/m_menu.c b/src/m_menu.c index 09f856306..c3345139e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2194,16 +2194,18 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 20}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 30}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 35}, + {IT_STRING | IT_CVAR, NULL, "Colourized Speedlines", &cv_coloredspeedlines, 30}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 45}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 40}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 45}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 55}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 55}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 65}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 70}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 80}, // uwu + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 65}, + + {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 75}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 80}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 90}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -2211,6 +2213,7 @@ static const char* OP_SaturnTooltips[] = NULL, "How long can the game wait before it kicks you out from the server\nconnecting screen.", "How much speen do you want?", + "Colourize the speedlines in your skincolor if you go fast enough!", "Show Localskin Menus.", "Force menu to only use uppercase.", "Use your desired Keyboard Layout for Text Input\nthis is either the Default, Native or Azerty\nNative does not affect Gameplay only Text!", @@ -2225,6 +2228,7 @@ enum sm_header, sm_waittime, sm_skinselspeed, + sm_colorlines, sm_showlocalskin, op_uppercase_menu, sm_nativkey, From 1416650c9d7315450f30254cbe28a83c3d91cf21 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 04:31:11 +0100 Subject: [PATCH 134/418] reorder saturn hud menu a little also remove uncapped hud from it, since why would you ever wanna turn it off? --- src/m_menu.c | 61 +++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index c3345139e..807648bf5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2288,34 +2288,35 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 10}, {IT_STRING | IT_CVAR, NULL, "Battle Speedometer", &cv_battlespeedo, 15}, - {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 20}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 25}, + {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 30}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 35}, - {IT_STRING | IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 25}, + {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 45}, - {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 30}, + {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 55}, - {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 35}, + {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 65}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 40}, - {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 45}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 50}, + {IT_STRING | IT_CVAR, NULL, "Small Positionnumber", &cv_smallposnum, 75}, + {IT_STRING | IT_CVAR, NULL, "Positionnumber Animation", &cv_posanim, 80}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 60}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 65}, + {IT_STRING | IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 90}, - {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 70}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 75}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 100}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 105}, - {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 80}, + {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 115}, + {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 120}, - {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 90}, + {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 130}, - {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 100}, + {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 140}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 110}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 115}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 150}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 155}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 125}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 165}, }; static const char* OP_SaturnHudTooltips[] = @@ -2323,20 +2324,21 @@ static const char* OP_SaturnHudTooltips[] = NULL, "Change what style the speedometer is.", "Draw the Speedometer in Battle.", - "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", - "Flash current Lap Time when doing a Lap on the Timer.", - "Enable the stat display.", - "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "Enable colourized hud.", "Enable the colourized itembox when colourized hud is enabled.", "The color to use instead of the player color when\ncolourized hud is enabled.", + "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", + "Enable the stat display.", + "Enable the use of the higher resolution want icons instead of rank\nfor some places.", + "Make the Postionnumber half the size.", + "Disable the animation of the Positionnumber\nwhen overtaking someone.", + "Flash current Lap Time when doing a Lap on the Timer.", "Show the big 'LAP' text on a lap change.", "Show the big Cecho Messages.", "Show player names on the minimap.", "Minimize the player icons on the minimap.", - "Show the Director Toggle prompt when spectating.", "Make the Intermission screen look like in beta versions of Kart!\nEither with background or just the rest.", - "Uncaps the HUD framerate, making it appear smoother.", + "Show the Director Toggle prompt when spectating.", "Nametag Options.", "Driftgauge Options.", "Move position of HUD elements.", @@ -2347,20 +2349,21 @@ enum sh_header, sh_speedometer, sh_battlespeedo, - sh_input, - sh_laptime, - sh_statdisplay, - sh_highresport, sh_colorhud, sh_coloritem, sh_colorhud_customcolor, + sh_input, + sh_statdisplay, + sh_highresport, + sh_smolpos, + sh_posanim, + sh_laptime, sh_lapemblem, sh_cechotogle, sh_mapname, sh_smallmap, - sh_directorhud, sh_betainter, - sh_uncappedhud, + sh_directorhud, sh_nametagmen, sh_driftgaugemen, sh_hudoffsets, From 44ee017dee237c1b3ca2a927f619241e8da69c73 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 04:12:51 +0100 Subject: [PATCH 135/418] forgor to delet this --- src/y_inter.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 7aa4c4d6f..a436b9080 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -345,10 +345,7 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) return; } - INT32 i, whiteplayer = MAXPLAYERS; - - if (!splitscreen) - whiteplayer = (demo.playback ? displayplayers[0] : consoleplayer); + INT32 i;; #define NUMFORNEWCOLUMN 8 INT32 y = 41, gutter = ((standings->numplayers > NUMFORNEWCOLUMN) ? 0 : (BASEVIDWIDTH/2)); From f92cf3df4f91db536aa8bbcc867f11cdfbeb2762 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 05:50:41 +0100 Subject: [PATCH 136/418] add slight fadeout to spinout rumble --- src/p_tick.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index 686710927..d81b720af 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -417,7 +417,8 @@ static void P_DeviceRumbleTick(void) if (player->kartstuff[k_spinouttimer]) { - low = high = FRACUNIT / 4; + //low = high = FRACUNIT / 6; + low = high = FixedMul((FRACUNIT / 4), (FixedDiv(player->kartstuff[k_spinouttimer], (3*TICRATE / 2)))); } else if (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))) { From 3b0d0dcd0c87524cd3d4a611b83e8fa12313d805 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 05:51:00 +0100 Subject: [PATCH 137/418] add banandrag rumble lol --- src/p_tick.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_tick.c b/src/p_tick.c index d81b720af..9931c75eb 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -440,6 +440,11 @@ static void P_DeviceRumbleTick(void) low = high = FRACUNIT / 64; } } + else if (player->kartstuff[k_bananadrag] > TICRATE) + { + if (leveltime & 1) // this is actually funny lel + high = FRACUNIT / 64; + } if (player->kartstuff[k_brakedrift]) { From 2a5d1fb84a0db90a12e2c77faba18637d29abe0a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 05:52:01 +0100 Subject: [PATCH 138/418] ; --- src/y_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index a436b9080..985057571 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -345,7 +345,7 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) return; } - INT32 i;; + INT32 i; #define NUMFORNEWCOLUMN 8 INT32 y = 41, gutter = ((standings->numplayers > NUMFORNEWCOLUMN) ? 0 : (BASEVIDWIDTH/2)); From f52db71ec65ddd92c44df4d99a6d69ba4e0ae351 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 15:12:31 +0100 Subject: [PATCH 139/418] this is not needed anymore --- src/lua_hooklib.c | 35 +---------------------------------- src/lua_script.c | 2 -- src/lua_script.h | 1 - 3 files changed, 1 insertion(+), 37 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 6f6f5dc61..12c09a8ba 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -934,40 +934,7 @@ int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source) return hook.status; } -#if 0 -void LUA_HookNetArchive(lua_CFunction archFunc) -{ - const hook_t * map = &hookIds[HOOK(NetVars)]; - Hook_State hook; - hook.force_mobj = false; - /* this is a remarkable case where the stack isn't reset */ - if (map->numHooks > 0) - { - // stack: tables - I_Assert(lua_gettop(gL) > 0); - I_Assert(lua_istable(gL, -1)); - - push_error_handler(); - lua_insert(gL, EINDEX); - - begin_hook_values(&hook); - - // tables becomes an upvalue of archFunc - lua_pushvalue(gL, -1); - lua_pushcclosure(gL, archFunc, 2); - // stack: tables, archFunc - - init_hook_call(&hook, 0, res_none); - call_mapped(&hook, map); - - lua_pop(gL, 1); // pop archFunc - lua_remove(gL, EINDEX); // pop error handler - // stack: tables - } -} -#endif - -void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save) // +void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save) { const hook_t * map = &hookIds[HOOK(NetVars)]; Hook_State hook; diff --git a/src/lua_script.c b/src/lua_script.c index 7ed3d8b56..9ad0c1a27 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1363,7 +1363,6 @@ void LUA_Archive(savebuffer_t *save, boolean network) WRITEUINT32(save->p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. LUA_HookNetArchive(NetArchive, save); // call the NetArchive hook in archive mode - //LUA_HookNetArchive(NetArchive); // call the NetArchive hook in archive mode } ArchiveTables(&save->p); @@ -1404,7 +1403,6 @@ void LUA_UnArchive(savebuffer_t *save, boolean network) } while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker. LUA_HookNetArchive(NetUnArchive, save); // call the NetArchive hook in unarchive mode - //LUA_HookNetArchive(NetUnArchive); // call the NetArchive hook in unarchive mode } UnArchiveTables(&save->p, network); diff --git a/src/lua_script.h b/src/lua_script.h index 738aca9d8..c524e94dc 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -74,7 +74,6 @@ void LUA_CVarChanged(const char *name); // lua_consolelib.c int Lua_optoption(lua_State *L, int narg, int def, int list_ref); int Lua_CreateFieldTable(lua_State *L, const char *const lst[]); void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save); -//void LUA_HookNetArchive(lua_CFunction archFunc); // Console wrapper void COM_Lua_f(void); From 10b56e7b4fb45eac764788108b02a488fffa7ea3 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 18:23:25 +0100 Subject: [PATCH 140/418] fix postimg data types mismatch also remove the "postimgflag_t" typedef since its useless and use smoler type for everything we dont need much space lol --- src/doomtype.h | 9 --------- src/p_local.h | 13 ++++++++++++- src/p_mobj.c | 2 +- src/p_user.c | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index 429eba77e..116d5cdfb 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -342,15 +342,6 @@ union FColorRGBA } ATTRPACK; typedef union FColorRGBA RGBA_t; -typedef enum -{ - POSTIMG_WATER = 1, // Underwater screen effect. - POSTIMG_MOTION = 1<<1, // Unused motion blur effect. - POSTIMG_FLIP = 1<<2, // Flipcam screen effect. - POSTIMG_HEAT = 1<<3, // Heatwave screen effect. - POSTIMG_MIRROR = 1<<4, // encore screen effect. -} postimgflag_t; - typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num) #define LUMPERROR UINT32_MAX diff --git a/src/p_local.h b/src/p_local.h index 5bf5bbf7a..a0bcfa716 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -78,6 +78,7 @@ void P_UnlinkThinker(thinker_t *thinker); // // P_USER // + typedef struct camera_s { boolean chase; @@ -127,9 +128,19 @@ typedef struct camera_s fixed_t pan; // postproccess effects - UINT16 postimg; + UINT8 postimg; } camera_t; +// post process types +enum +{ + POSTIMG_WATER = 1, // Underwater screen effect. + POSTIMG_MOTION = 1<<1, // Unused motion blur effect. + POSTIMG_FLIP = 1<<2, // Flipcam screen effect. + POSTIMG_HEAT = 1<<3, // Heatwave screen effect. + POSTIMG_MIRROR = 1<<4, // encore screen effect. +}; + extern camera_t camera[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS]; diff --git a/src/p_mobj.c b/src/p_mobj.c index 482da8833..ef1f40ea3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3244,7 +3244,7 @@ void P_DestroyRobots(void) void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); - UINT16 postimgtype = 0; + UINT8 postimgtype = 0; if (encoremode) postimgtype |= POSTIMG_MIRROR; diff --git a/src/p_user.c b/src/p_user.c index 3c7b1b6ac..fc07e56af 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4248,7 +4248,7 @@ static boolean P_CameraCheckWaterFirstperson(player_t *player, sector_t *sector, static void P_CalcPostImg(player_t *player, camera_t *thiscam) { sector_t *sector = NULL; - INT16 postimgtype = 0; + UINT8 postimgtype = 0; //INT32 *param; fixed_t pviewheight = 0; From a11227b15a2ed5e8ef595271d07e678d52ff044d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 18:23:25 +0100 Subject: [PATCH 141/418] fix postimg data types mismatch also remove the "postimgflag_t" typedef since its useless and use smoler type for everything we dont need much space lol --- src/doomtype.h | 9 --------- src/p_local.h | 13 ++++++++++++- src/p_mobj.c | 2 +- src/p_user.c | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index 429eba77e..116d5cdfb 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -342,15 +342,6 @@ union FColorRGBA } ATTRPACK; typedef union FColorRGBA RGBA_t; -typedef enum -{ - POSTIMG_WATER = 1, // Underwater screen effect. - POSTIMG_MOTION = 1<<1, // Unused motion blur effect. - POSTIMG_FLIP = 1<<2, // Flipcam screen effect. - POSTIMG_HEAT = 1<<3, // Heatwave screen effect. - POSTIMG_MIRROR = 1<<4, // encore screen effect. -} postimgflag_t; - typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num) #define LUMPERROR UINT32_MAX diff --git a/src/p_local.h b/src/p_local.h index d80223531..318f99f87 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -76,6 +76,7 @@ void P_UnlinkThinker(thinker_t *thinker); // // P_USER // + typedef struct camera_s { boolean chase; @@ -125,9 +126,19 @@ typedef struct camera_s fixed_t pan; // postproccess effects - UINT16 postimg; + UINT8 postimg; } camera_t; +// post process types +enum +{ + POSTIMG_WATER = 1, // Underwater screen effect. + POSTIMG_MOTION = 1<<1, // Unused motion blur effect. + POSTIMG_FLIP = 1<<2, // Flipcam screen effect. + POSTIMG_HEAT = 1<<3, // Heatwave screen effect. + POSTIMG_MIRROR = 1<<4, // encore screen effect. +}; + extern camera_t camera[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS]; diff --git a/src/p_mobj.c b/src/p_mobj.c index 2b120b99c..dd3f62169 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3235,7 +3235,7 @@ void P_DestroyRobots(void) void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); - UINT16 postimgtype = 0; + UINT8 postimgtype = 0; if (encoremode) postimgtype |= POSTIMG_MIRROR; diff --git a/src/p_user.c b/src/p_user.c index 0675808b0..52399e56f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4252,7 +4252,7 @@ static boolean P_CameraCheckWaterFirstperson(player_t *player, sector_t *sector, static void P_CalcPostImg(player_t *player, camera_t *thiscam) { sector_t *sector = NULL; - INT16 postimgtype = 0; + UINT8 postimgtype = 0; //INT32 *param; fixed_t pviewheight = 0; From 3c268c8cbd83cbbb75861bd84fbca651b175fcb3 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 23:49:26 +0100 Subject: [PATCH 142/418] slightly refactor chasecam stuff again --- src/p_user.c | 123 +++++++++++++++++++++++---------------------------- 1 file changed, 56 insertions(+), 67 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index fc07e56af..6976b6be8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3476,6 +3476,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) { tic_t tries = 0; fixed_t x, y, z; + UINT8 i; if (thiscam->freecam) return; // do not reset the camera there. @@ -3500,13 +3501,14 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->z = z; thiscam->reset = true; - if (!(thiscam == &camera[0] && (cv_cam_still[0].value)) - && !(thiscam == &camera[1] && (cv_cam_still[1].value)) - && !(thiscam == &camera[2] && (cv_cam_still[2].value)) - && !(thiscam == &camera[3] && (cv_cam_still[3].value))) + for (i = 0; i <= splitscreen; i++) { - thiscam->angle = player->mo->angle; - thiscam->aiming = 0; + if (!(thiscam == &camera[i] && cv_cam_still[i].value)) + { + thiscam->angle = player->mo->angle; + thiscam->aiming = 0; + break; + } } thiscam->relativex = 0; @@ -3731,7 +3733,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { static boolean lookbackactive[MAXSPLITSCREENPLAYERS]; static UINT8 lookbackdelay[MAXSPLITSCREENPLAYERS]; - UINT8 num, plyrnum; + UINT8 num = 0; angle_t angle = 0, focusangle = 0, focusaiming = 0; fixed_t x, y, z, dist, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight; fixed_t pan, xpan, ypan; @@ -3749,21 +3751,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; - if (thiscam == &camera[1]) // Camera 2 + for (UINT8 i = 0; i <= splitscreen; i++) { - num = 1; - } - else if (thiscam == &camera[2]) // Camera 3 - { - num = 2; - } - else if (thiscam == &camera[3]) // Camera 4 - { - num = 3; - } - else // Camera 1 - { - num = 0; + if (thiscam == &camera[i]) + { + num = i; + break; + } } if (thiscam->freecam || player->spectator) @@ -3776,29 +3770,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (paused || P_AutoPause()) return true; - if (player == &players[consoleplayer]) - { - plyrnum = 0; - } - else if (player == &players[displayplayers[1]]) - { - plyrnum = 1; - } - else if (player == &players[displayplayers[2]]) - { - plyrnum = 2; - } - else if (player == &players[displayplayers[3]]) - { - plyrnum = 3; - } - else - { - plyrnum = 255; - } - mo = player->mo; + const boolean vflip = (mo->eflags & MFE_VERTICALFLIP); + if (player->pflags & PF_TIMEOVER) // 1 for momentum keep, 2 for turnaround timeover = (player->kartstuff[k_timeovercam] > 2*TICRATE ? 2 : 1); else @@ -3815,19 +3790,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (!thiscam->chase && !resetcalled) { - if (plyrnum != 255) - { - focusangle = localangle[plyrnum]; - } - else - { - focusangle = mo->angle; - } - - if (thiscam == &camera[num]) - camrotate = cv_cam_rotate[num].value; - else - camrotate = 0; + focusangle = ((P_IsLocalPlayer(player)) ? localangle[num] : mo->angle); + camrotate = ((thiscam == &camera[num]) ? cv_cam_rotate[num].value : 0); if (leveltime < introtime) // Whoooshy camera! { @@ -3848,10 +3812,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall focusangle = mo->angle; focusaiming = 0; } - else if (plyrnum != 255) + else if (P_IsLocalPlayer(player)) { - focusangle = localangle[plyrnum]; - focusaiming = localaiming[plyrnum]; + focusangle = localangle[num]; + focusaiming = localaiming[num]; } else { @@ -3882,7 +3846,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camheight += (introcam * mapobjectscale)*2; } else if (player->exiting) // SRB2Kart: Leave the camera behind while exiting, for dramatic effect! + { camstill = true; + } else if (lookback || lookbackdelay[num]) // SRB2kart - Camera flipper { #define MAXLOOKBACKDELAY 2 @@ -3895,26 +3861,35 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall else lookbackdelay[num]--; } + lookbackdown = (lookbackdelay[num] == MAXLOOKBACKDELAY) != lookbackactive[num]; lookbackactive[num] = (lookbackdelay[num] == MAXLOOKBACKDELAY); #undef MAXLOOKBACKDELAY - if (mo->eflags & MFE_VERTICALFLIP) + if (vflip) camheight += thiscam->height; if (camspeed > FRACUNIT) camspeed = FRACUNIT; if (timeover) + { angle = mo->angle + FixedAngle(camrotate*FRACUNIT); + } else if (leveltime < starttime) + { angle = focusangle + FixedAngle(camrotate*FRACUNIT); + } else if (camstill || resetcalled || player->playerstate == PST_DEAD) + { angle = thiscam->angle; + } else { if (camspeed == FRACUNIT) + { angle = focusangle + FixedAngle(camrotate<angle; @@ -3952,7 +3927,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // SRB2Kart: set camera panning if (camstill || resetcalled || player->playerstate == PST_DEAD) + { pan = xpan = ypan = 0; + } else { if (player->kartstuff[k_drift] != 0) @@ -3978,7 +3955,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall pviewheight = FixedMul(32<scale); - if (mo->eflags & MFE_VERTICALFLIP) + if (vflip) z = mo->z + mo->height - pviewheight - camheight; else z = mo->z + pviewheight + camheight; @@ -4006,7 +3983,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall thiscam->momz = 0; } else if (player->exiting || timeover == 2) + { thiscam->momx = thiscam->momy = thiscam->momz = 0; + } else if (leveltime < starttime) { thiscam->momx = FixedMul(x - thiscam->x, camspeed); @@ -4037,7 +4016,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall f2 = viewpointy-thiscam->y; dist = FixedHypot(f1, f2); - if (mo->eflags & MFE_VERTICALFLIP) + if (vflip) angle = R_PointToAngle2(0, thiscam->z + thiscam->height, dist, mo->z + mo->height - P_GetPlayerHeight(player)); else angle = R_PointToAngle2(0, thiscam->z, dist, mo->z + P_GetPlayerHeight(player)); @@ -4050,7 +4029,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall G_ClipAimingPitch((INT32 *)&angle); if (camspeed == FRACUNIT) + { thiscam->aiming = angle; + } else { angle_t input; @@ -4073,12 +4054,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { // Don't let the camera match your movement. thiscam->momz = 0; + if (player->spectator) thiscam->aiming = 0; // Only let the camera go a little bit downwards. - else if (!(mo->eflags & MFE_VERTICALFLIP) && thiscam->aiming < ANGLE_337h && thiscam->aiming > ANGLE_180) + else if (!vflip && thiscam->aiming < ANGLE_337h && thiscam->aiming > ANGLE_180) thiscam->aiming = ANGLE_337h; - else if (mo->eflags & MFE_VERTICALFLIP && thiscam->aiming > ANGLE_22h && thiscam->aiming < ANGLE_180) + else if (vflip && thiscam->aiming > ANGLE_22h && thiscam->aiming < ANGLE_180) thiscam->aiming = ANGLE_22h; } @@ -4093,12 +4075,19 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall void P_ResetLocalCamAiming(player_t *player) { - for (int i = 0; i <= splitscreen; i++) + UINT8 i; + + if (player == &players[consoleplayer]) + localaiming[0] = 0; + else if (splitscreen) { - UINT8 id = (i == 0) ? consoleplayer : displayplayers[i]; - if (player - players == id) + for (i = 1; i <= splitscreen; i++) // Skip P1 { - localaiming[i] = 0; + if (player == &players[displayplayers[i]]) + { + localaiming[i] = 0; + break; + } } } } From ac8f6455ffa9c879870c33388b7f2daaf3706a66 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 9 Jan 2025 17:06:45 +0100 Subject: [PATCH 143/418] dont reset cam using f12 when only one player is ingame --- src/g_game.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index fbe506f50..5681b9ad3 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1802,7 +1802,14 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) (*displayplayerp) = playernumd; /* If a viewpoint changes, reset the camera to clear uninitialized memory. */ - G_FixCamera(viewd); + if (viewnum > splits) + { + G_FixCamera(viewd); + } + else if ((*displayplayerp) != olddisplayplayer) + { + G_FixCamera(viewnum); + } } if (demo.playback && viewnum == 1) From 8e7fddd6b0320adb2e3f3355565bc492f2fb8b62 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 9 Jan 2025 17:11:02 +0100 Subject: [PATCH 144/418] =?UTF-8?q?use=20l=C3=B6=C3=B6ps=20for=20those=20t?= =?UTF-8?q?o=20look=20a=20little=20better=20lel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/p_map.c | 17 +++++++++-------- src/p_spec.c | 54 +++++++++++++++++++--------------------------------- 2 files changed, 29 insertions(+), 42 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 2a803304d..a887ccd52 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -235,14 +235,15 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (!demo.playback || P_AnalogMove(object->player)) { - if (object->player == &players[consoleplayer]) - localangle[0] = spring->angle; - else if (object->player == &players[displayplayers[1]]) - localangle[1] = spring->angle; - else if (object->player == &players[displayplayers[2]]) - localangle[2] = spring->angle; - else if (object->player == &players[displayplayers[3]]) - localangle[3] = spring->angle; + for (UINT8 j = 0; j <= splitscreen; ++j) + { + INT32 id = (j == 0 ? consoleplayer : displayplayers[j]); + if (object->player == &players[id]) + { + localangle[j] = spring->angle; + break; + } + } } } diff --git a/src/p_spec.c b/src/p_spec.c index 4471a1285..aea198e60 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3590,14 +3590,15 @@ DoneSection2: if (!demo.playback || P_AnalogMove(player)) { - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; + for (UINT8 j = 0; j <= splitscreen; ++j) + { + INT32 id = (j == 0 ? consoleplayer : displayplayers[j]); + if (player == &players[id]) + { + localangle[j] = player->mo->angle; + break; + } + } } if (!(lines[i].flags & ML_EFFECT4)) @@ -7439,33 +7440,18 @@ void T_Pusher(pusher_t *p) if (!demo.playback || P_AnalogMove(thing->player)) { - if (thing->player == &players[consoleplayer]) + for (UINT8 i = 0; i <= splitscreen; ++i) { - if (thing->angle - localangle[0] > ANGLE_180) - localangle[0] -= (localangle[0] - thing->angle) / 8; - else - localangle[0] += (thing->angle - localangle[0]) / 8; - } - else if (thing->player == &players[displayplayers[1]]) - { - if (thing->angle - localangle[1] > ANGLE_180) - localangle[1] -= (localangle[1] - thing->angle) / 8; - else - localangle[1] += (thing->angle - localangle[1]) / 8; - } - else if (thing->player == &players[displayplayers[2]]) - { - if (thing->angle - localangle[2] > ANGLE_180) - localangle[2] -= (localangle[2] - thing->angle) / 8; - else - localangle[2] += (thing->angle - localangle[2]) / 8; - } - else if (thing->player == &players[displayplayers[3]]) - { - if (thing->angle - localangle[3] > ANGLE_180) - localangle[3] -= (localangle[3] - thing->angle) / 8; - else - localangle[3] += (thing->angle - localangle[3]) / 8; + INT32 id = (i == 0 ? consoleplayer : displayplayers[i]); + if (thing->player == &players[id]) + { + if (thing->angle - localangle[i] > ANGLE_180) + localangle[i] -= (localangle[i] - thing->angle) / 8; + else + localangle[i] += (thing->angle - localangle[i]) / 8; + + break; + } } } } From 1a9865ebc45bff2d65835d4451b3bf85f42a4532 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 9 Jan 2025 17:25:50 +0100 Subject: [PATCH 145/418] this should also use unpaused rendertimefrac --- src/d_main.c | 2 +- src/r_things.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index d74950b65..5b24c5c00 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -334,7 +334,7 @@ static boolean D_Display(void) if (rendermode == render_soft && !splitscreen) { - R_InterpolateViewRollAngle(rendertimefrac); + R_InterpolateViewRollAngle(rendertimefrac_unpaused); R_CheckViewMorph(); } diff --git a/src/r_things.c b/src/r_things.c index 9bdb9ea67..8f4677bcf 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -584,7 +584,7 @@ void R_DrawMaskedColumn(column_t *column) basetexturemid = dc_texturemid; - if (!column || column == 0) + if (column == NULL) return; for (; column->topdelta != 0xff ;) From 9bf6a72621b6e801ab3ca438b468d739c60af867 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 9 Jan 2025 18:21:32 +0100 Subject: [PATCH 146/418] make gamestate download show total gamestate size --- src/d_clisrv.c | 21 +++++++++++++++++---- src/d_netfil.c | 3 +++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ee20a0780..9485f00b3 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1208,7 +1208,8 @@ static inline void CL_DrawConnectionStatus(void) INT32 ccstime = I_GetTime(); // Draw background fade - V_DrawFadeScreen(0xFF00, 16); + if (!menuactive) // menu already draws its own fade + V_DrawFadeScreen(0xFF00, 16); // force default if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_LOADFILES && cl_mode != CL_CHECKFILES #ifdef HAVE_CURL @@ -1234,10 +1235,22 @@ static inline void CL_DrawConnectionStatus(void) case CL_DOWNLOADSAVEGAME: if (lastfilenum != -1) { + UINT32 currentsize = fileneeded[lastfilenum].currentsize; + UINT32 totalsize = fileneeded[lastfilenum].totalsize; + INT32 dldlength; + cltext = M_GetText("Downloading game state..."); Net_GetNetStat(); + + dldlength = (INT32)((currentsize/(double)totalsize) * 256); + if (dldlength > 256) + dldlength = 256; + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 111); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, dldlength, 8, 96); + V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, - va(" %4uK",fileneeded[lastfilenum].currentsize>>10)); + va(" %4uK/%4uK",currentsize>>10,totalsize>>10)); + V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, va("%3.1fK/s ", ((double)getbps)/1024)); } @@ -2732,12 +2745,12 @@ static void CL_ConnectToServer(void) sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); #endif - cl_mode = CL_SEARCHING; - #ifdef CLIENT_LOADINGSCREEN lastfilenum = -1; #endif + cl_mode = CL_SEARCHING; + #ifdef JOININGAME // Don't get a corrupt savegame error because tmpsave already exists if (FIL_FileExists(tmpsave) && unlink(tmpsave) == -1) diff --git a/src/d_netfil.c b/src/d_netfil.c index fd0bf879c..e488e083e 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -233,6 +233,9 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi void CL_PrepareDownloadSaveGame(const char *tmpsave) { +#ifdef CLIENT_LOADINGSCREEN + lastfilenum = -1; +#endif fileneedednum = 1; fileneeded[0].status = FS_REQUESTED; fileneeded[0].totalsize = UINT32_MAX; From 5689e3815adc5575b0de629d74d5299e15ac1c09 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 15:42:36 +0100 Subject: [PATCH 147/418] shouldnt this be uint? --- src/p_saveg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index dcf8f0de9..76a363c73 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1893,7 +1893,7 @@ mobj_t *P_FindNewPosition(UINT32 oldposition) if (mobj->mobjnum == oldposition) return mobj; } - CONS_Debug(DBG_GAMELOGIC, "mobj not found\n"); + CONS_Debug(DBG_GAMELOGIC, "mobj %d not found\n", oldposition); return NULL; } @@ -3463,7 +3463,7 @@ void P_SaveNetGame(savebuffer_t *save, boolean resending) { thinker_t *th; mobj_t *mobj; - INT32 i = 1; // don't start from 0, it'd be confused with a blank pointer otherwise + UINT32 i = 1; // don't start from 0, it'd be confused with a blank pointer otherwise CV_SaveNetVars(&save->p, false); P_NetArchiveMisc(save, resending); From 3c6116255bbf34b6bedbb816e508ab66024422e7 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 9 Jan 2025 20:05:06 +0100 Subject: [PATCH 148/418] kill unarchivevaluedemo just pass if we load from replay or not and do stuff accordingly --- src/lua_script.c | 186 +++++++++++------------------------------------ 1 file changed, 41 insertions(+), 145 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index 9ad0c1a27..5078a22c0 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -993,7 +993,7 @@ static void ArchiveTables(UINT8 **p) } } -static UINT8 UnArchiveValue(UINT8 **p, int TABLESINDEX) +static UINT8 UnArchiveValue(UINT8 **p, int TABLESINDEX, boolean network) { UINT8 type = READUINT8(*p); switch (type) @@ -1045,6 +1045,12 @@ static UINT8 UnArchiveValue(UINT8 **p, int TABLESINDEX) LUA_PushUserdata(gL, &states[READUINT16(*p)], META_STATE); break; case ARCH_MOBJ: + if (network == false) // for replays :chaosleep: + { + *p += sizeof(UINT32); // Skip this data, we can't read a mobj here, it'd point to garbage and crash the game. + return 3; // Don't set the field + } + LUA_PushUserdata(gL, P_FindNewPosition(READUINT32(*p)), META_MOBJ); break; case ARCH_PLAYER: @@ -1086,106 +1092,6 @@ static UINT8 UnArchiveValue(UINT8 **p, int TABLESINDEX) return 0; } - -// Unarchives from demo_p: -// Return values: -// 0: Normal -// 1: Read table key -// 2: Read table value -// 3: Don't use setfield - -static UINT8 UnArchiveValueDemo(UINT8 **p, int TABLESINDEX, char field[1024]) -{ - UINT8 type = READUINT8(*p); - switch (type) - { - case ARCH_NULL: - lua_pushnil(gL); - break; - case ARCH_BOOLEAN: - lua_pushboolean(gL, READUINT8(*p)); - break; - case ARCH_SIGNED: - lua_pushinteger(gL, READFIXED(*p)); - break; - case ARCH_STRING: - { - UINT16 len = READUINT16(*p); // length of string, including embedded zeros - char *value; - UINT16 i = 0; - // See my comments in the ArchiveValue function; - // it's much the same for reading strings as writing them! - // (i.e. we can't use READSTRING either) - // -- Monster Iestyn 05/08/18 - value = malloc(len); // make temp buffer of size len - // now read the actual string - while (i < len) - value[i++] = READCHAR(*p); // read chars individually, including the embedded zeros - lua_pushlstring(gL, value, len); // push the string (note: this function supports embedded zeros) - free(value); // free the buffer - break; - } - case ARCH_TABLE: - { - UINT16 tid = READUINT16(*p); - lua_rawgeti(gL, TABLESINDEX, tid); - if (lua_isnil(gL, -1)) - { - lua_pop(gL, 1); - lua_newtable(gL); - lua_pushvalue(gL, -1); - lua_rawseti(gL, TABLESINDEX, tid); - return 2; - } - break; - } - case ARCH_MOBJINFO: - LUA_PushUserdata(gL, &mobjinfo[READUINT16(*p)], META_MOBJINFO); - break; - case ARCH_STATE: - LUA_PushUserdata(gL, &states[READUINT16(*p)], META_STATE); - break; - case ARCH_MOBJ: - *p += sizeof(UINT32); // Skip this data, we can't read a mobj here, it'd point to garbage and crash the game. - if (field) - CONS_Alert(CONS_WARNING,"Cannot read mobj_t stored in player variable \'%s\'. Desyncs may occur.\n", field); - else - CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); - return 3; // Don't set the field - - case ARCH_PLAYER: - LUA_PushUserdata(gL, &players[READUINT8(*p)], META_PLAYER); - break; - case ARCH_MAPTHING: - LUA_PushUserdata(gL, &mapthings[READUINT16(*p)], META_MAPTHING); - break; - case ARCH_VERTEX: - LUA_PushUserdata(gL, &vertexes[READUINT16(*p)], META_VERTEX); - break; - case ARCH_LINE: - LUA_PushUserdata(gL, &lines[READUINT16(*p)], META_LINE); - break; - case ARCH_SIDE: - LUA_PushUserdata(gL, &sides[READUINT16(*p)], META_SIDE); - break; - case ARCH_SUBSECTOR: - LUA_PushUserdata(gL, &subsectors[READUINT16(*p)], META_SUBSECTOR); - break; - case ARCH_SECTOR: - LUA_PushUserdata(gL, §ors[READUINT16(*p)], META_SECTOR); - break; - case ARCH_SLOPE: - LUA_PushUserdata(gL, P_SlopeById(READUINT16(*p)), META_SLOPE); - break; - case ARCH_MAPHEADER: - LUA_PushUserdata(gL, mapheaderinfo[READUINT16(*p)], META_MAPHEADER); - break; - case ARCH_TEND: - return 1; - } - return 0; -} - static void UnArchiveExtVars(UINT8 **p, void *pointer, boolean network) { int TABLESINDEX; @@ -1205,29 +1111,25 @@ static void UnArchiveExtVars(UINT8 **p, void *pointer, boolean network) TABLESINDEX = lua_gettop(gL); lua_createtable(gL, 0, field_count); // pointer's ext vars subtable - if (network) + for (i = 0; i < field_count; i++) { - for (i = 0; i < field_count; i++) - { - READSTRING(*p, field); + UINT8 ret; + READSTRING(*p, field); - if (UnArchiveValue(p, TABLESINDEX) == 1) - { - CONS_Alert(CONS_ERROR, "Unexpected end marker when reading ExtVars (field '%s')\n", field); - break; - } + ret = UnArchiveValue(p, TABLESINDEX, network); - lua_setfield(gL, -2, field); - } - } - else - { - for (i = 0; i < field_count; i++) + if (ret == 1) { - READSTRING(*p, field); - if (UnArchiveValueDemo(p, TABLESINDEX, field) != 3) // This will return 3 if we shouldn't set this field. - lua_setfield(gL, -2, field); + CONS_Alert(CONS_ERROR, "Unexpected end marker when reading ExtVars (field '%s')\n", field); + break; } + else if (ret == 3) // This will return 3 if we shouldn't set this field. + { + CONS_Alert(CONS_WARNING,"Cannot read mobj_t stored in player variable \'%s\'. Desyncs may occur.\n", field); + continue; + } + + lua_setfield(gL, -2, field); } lua_getfield(gL, LUA_REGISTRYINDEX, LREG_EXTVARS); @@ -1244,7 +1146,7 @@ static int NetUnArchive(lua_State *L) savebuffer_t *save = lua_touserdata(L, lua_upvalueindex(2)); int i, n = lua_gettop(L); for (i = 1; i <= n; i++) - UnArchiveValue(&save->p, TABLESINDEX); + UnArchiveValue(&save->p, TABLESINDEX, true); return n; } @@ -1274,35 +1176,29 @@ static void UnArchiveTables(UINT8 **p, boolean network) { UINT8 ret; - if (network) + ret = UnArchiveValue(p, TABLESINDEX, network); + if (ret == 3) { - if (UnArchiveValue(p, TABLESINDEX) == 1) // read key - break; - - ret = UnArchiveValue(p, TABLESINDEX); - if (ret == 1) - { - CONS_Alert(CONS_ERROR, "Unexpected end of save reached (Corrupted save?)\n"); - lua_pop(gL, 1); // Pop key - break; - } - else if (ret == 2) // read value - n++; + CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); + lua_pushnil(gL); } - else + else if (ret == 1) // read key + break; + + ret = UnArchiveValue(p, TABLESINDEX, network); + if (ret == 1) { - ret = UnArchiveValueDemo(p, TABLESINDEX, NULL); - if (ret == 3) - lua_pushnil(gL); - else if (ret == 1) // read key - break; - - ret = UnArchiveValueDemo(p, TABLESINDEX, NULL); - if (ret == 3) - lua_pushnil(gL); - else if (ret == 2) // read value - n++; + CONS_Alert(CONS_ERROR, "Unexpected end of save reached (Corrupted save?)\n"); + lua_pop(gL, 1); // Pop key + break; } + else if (ret == 3) + { + CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); + lua_pushnil(gL); + } + else if (ret == 2) // read value + n++; if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved) { From 07c443598b6ea04d27c807fab3f160d47f0c5f51 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Jan 2025 01:54:31 +0100 Subject: [PATCH 149/418] fix column drawers clamping stuff --- src/r_draw8.c | 110 ++++++++++++-------------------------------------- src/r_plane.c | 1 + src/r_segs.c | 8 ++-- 3 files changed, 30 insertions(+), 89 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 30fe49372..18ecda5eb 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -60,25 +60,13 @@ void R_DrawColumn_8(void) register const UINT8 *source = dc_source; register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight-1; + register INT32 heightmask = dc_sourcelength-1; + npow2min = -1; + npow2max = dc_sourcelength; - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (dc_sourcelength & heightmask) // not a power of 2 -- killough { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -192,26 +180,14 @@ void R_Draw2sMultiPatchColumn_8(void) // 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 INT32 heightmask = dc_sourcelength-1; register UINT8 val; + npow2min = -1; + npow2max = dc_sourcelength; - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (dc_sourcelength & heightmask) // not a power of 2 -- killough { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -343,26 +319,14 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) 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 INT32 heightmask = dc_sourcelength-1; register UINT8 val; + npow2min = -1; + npow2max = dc_sourcelength; - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (dc_sourcelength & heightmask) // not a power of 2 -- killough { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -535,25 +499,13 @@ void R_DrawTranslucentColumn_8(void) 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 INT32 heightmask = dc_sourcelength - 1; + npow2min = -1; + npow2max = dc_sourcelength; - if (dc_texheight & heightmask) + if (dc_sourcelength & heightmask) { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -653,25 +605,13 @@ void R_DrawTranslatedTranslucentColumn_8(void) // 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; + register INT32 heightmask = dc_sourcelength - 1; + npow2min = -1; + npow2max = dc_sourcelength; - if (dc_texheight & heightmask) + if (dc_sourcelength & heightmask) { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { diff --git a/src/r_plane.c b/src/r_plane.c index 078ab0bb3..8044851fc 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -662,6 +662,7 @@ static void R_DrawSkyPlane(visplane_t *pl) dc_texturemid = skytexturemid; dc_texheight = textureheight[skytexture] >>FRACBITS; + dc_sourcelength = dc_texheight; for (x = pl->minx; x <= pl->maxx; x++) { diff --git a/src/r_segs.c b/src/r_segs.c index d967eec4b..918beb873 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -277,7 +277,7 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) if (dc_yl <= dc_yh && dc_yh < vid.height && dc_yh > 0) { dc_source = (UINT8 *)column + 3; - dc_sourcelength = 0; + dc_sourcelength = column2s_length; if (colfunc == wallcolfunc) twosmultipatchfunc(); @@ -1450,7 +1450,7 @@ static void R_RenderSegLoop (void) dc_texturemid = rw_midtexturemid; dc_source = R_GetColumn(midtexture,texturecolumn); dc_texheight = textureheight[midtexture]>>FRACBITS; - dc_sourcelength = 0; + dc_sourcelength = dc_texheight; colfunc(); // dont draw anything more for this column, since @@ -1498,7 +1498,7 @@ static void R_RenderSegLoop (void) dc_texturemid = rw_toptexturemid; dc_source = R_GetColumn(toptexture,texturecolumn); dc_texheight = textureheight[toptexture]>>FRACBITS; - dc_sourcelength = 0; + dc_sourcelength = dc_texheight; colfunc(); ceilingclip[rw_x] = (INT16)mid; } @@ -1536,7 +1536,7 @@ static void R_RenderSegLoop (void) dc_source = R_GetColumn(bottomtexture, texturecolumn); dc_texheight = textureheight[bottomtexture]>>FRACBITS; - dc_sourcelength = 0; + dc_sourcelength = dc_texheight; colfunc(); floorclip[rw_x] = (INT16)mid; } From 5cc756f853c19a0a007797fbd1c6ef374d6abfe7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Jan 2025 02:12:13 +0100 Subject: [PATCH 150/418] reinit minimap stuff when a wad is added while ingame --- src/p_local.h | 1 - src/p_setup.c | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index a0bcfa716..b07d5e34a 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -424,7 +424,6 @@ extern precipmobj_t **precipblocklinks; // special blockmap for precip rendering extern struct minimapinfo { patch_t *minimap_pic; - UINT8 mapthingcount; INT32 min_x, min_y; INT32 max_x, max_y; INT32 map_w, map_h; diff --git a/src/p_setup.c b/src/p_setup.c index 2f730fdec..1a90f610a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2574,8 +2574,6 @@ static void P_InitMinimapInfo(void) if (lumpnum != -1) minimapinfo.minimap_pic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_HUDGFX); - minimapinfo.mapthingcount = 0; - // TODO iterate over mapthings to look for possible user-defined bounds minimapinfo.min_x = bsp->bbox[0][BOXLEFT]; minimapinfo.max_x = bsp->bbox[0][BOXRIGHT]; minimapinfo.min_y = bsp->bbox[0][BOXBOTTOM]; @@ -3296,6 +3294,10 @@ boolean P_MultiSetupWadFiles(boolean fullsetup) ST_LoadGraphics(); ST_ReloadSkinFaceGraphics(); + // reload minimap stuff while were in the map since it may get replaced otherwise + if (gamestate == GS_LEVEL) + P_InitMinimapInfo(); + if (!partadd_important) partadd_stage = -1; // everything done else if (fullsetup) From d093b461d6fdd111430eeeb2b2843ed5da187678 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Jan 2025 02:14:31 +0100 Subject: [PATCH 151/418] clamp to length-1 --- src/r_draw8.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 18ecda5eb..084114fa2 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -62,7 +62,7 @@ void R_DrawColumn_8(void) register INT32 heightmask = dc_sourcelength-1; npow2min = -1; - npow2max = dc_sourcelength; + npow2max = dc_sourcelength-1; if (dc_sourcelength & heightmask) // not a power of 2 -- killough { @@ -183,7 +183,7 @@ void R_Draw2sMultiPatchColumn_8(void) register INT32 heightmask = dc_sourcelength-1; register UINT8 val; npow2min = -1; - npow2max = dc_sourcelength; + npow2max = dc_sourcelength-1; if (dc_sourcelength & heightmask) // not a power of 2 -- killough { @@ -322,7 +322,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) register INT32 heightmask = dc_sourcelength-1; register UINT8 val; npow2min = -1; - npow2max = dc_sourcelength; + npow2max = dc_sourcelength-1; if (dc_sourcelength & heightmask) // not a power of 2 -- killough { @@ -499,9 +499,9 @@ void R_DrawTranslucentColumn_8(void) register const UINT8 *source = dc_source; register const UINT8 *transmap = dc_transmap; register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_sourcelength - 1; + register INT32 heightmask = dc_sourcelength-1; npow2min = -1; - npow2max = dc_sourcelength; + npow2max = dc_sourcelength-1; if (dc_sourcelength & heightmask) { @@ -605,9 +605,9 @@ void R_DrawTranslatedTranslucentColumn_8(void) // 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_sourcelength - 1; + register INT32 heightmask = dc_sourcelength-1; npow2min = -1; - npow2max = dc_sourcelength; + npow2max = dc_sourcelength-1; if (dc_sourcelength & heightmask) { From 817df662da27ae07e2a56a7397ed8cddc9678464 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Jan 2025 02:17:38 +0100 Subject: [PATCH 152/418] slight cleanup r_draw8 --- src/r_draw8.c | 60 ++++++++++++++------------------------------------- 1 file changed, 16 insertions(+), 44 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 084114fa2..1a6e45a5a 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -744,17 +744,14 @@ void R_DrawSpan_8 (void) fixed_t xstep, ystep; register UINT32 bit; - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; + const UINT8 *source = ds_source; + const UINT8 *colormap = ds_colormap; + register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; register size_t count = (ds_x2 - ds_x1 + 1); size_t i; - xposition = ds_xfrac; yposition = ds_yfrac; - xstep = ds_xstep; ystep = ds_ystep; - // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the // texture with two shifts, an OR and one AND. (see below) @@ -762,12 +759,8 @@ void R_DrawSpan_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition <<= nflatshiftup; yposition <<= nflatshiftup; - xstep <<= nflatshiftup; ystep <<= nflatshiftup; - - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; + xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; + xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; if (dest+8 > deststop) { @@ -808,14 +801,13 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) { // ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version // of this function. Here's my own. - INT32 left = ds_x1, right = ds_x2; - fixed_t step = (end-start)/(ds_x2-ds_x1+1); INT32 i; + fixed_t step = (end-start)/(ds_x2-ds_x1+1); // 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 = ds_x1; i <= ds_x2; i++) { tiltlighting[i] = (start += step) >> FRACBITS; @@ -837,7 +829,6 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) */ void R_DrawTiltedSpan_8(void) { - // x1, x2 = ds_x1, ds_x2 int width = ds_x2 - ds_x1; double iz, uz, vz; UINT32 u, v; @@ -873,7 +864,6 @@ void R_DrawTiltedSpan_8(void) dest = ylookup[ds_y] + columnofs[ds_x1]; source = ds_source; - //colormap = ds_colormap; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -901,7 +891,6 @@ void R_DrawTiltedSpan_8(void) izstep = ds_szp->x * SPANSIZE; uzstep = ds_sup->x * SPANSIZE; vzstep = ds_svp->x * SPANSIZE; - //x1 = 0; width++; while (width >= SPANSIZE) @@ -978,7 +967,6 @@ void R_DrawTiltedSpan_8(void) */ void R_DrawTiltedTranslucentSpan_8(void) { - // x1, x2 = ds_x1, ds_x2 int width = ds_x2 - ds_x1; double iz, uz, vz; UINT32 u, v; @@ -1014,7 +1002,6 @@ void R_DrawTiltedTranslucentSpan_8(void) dest = ylookup[ds_y] + columnofs[ds_x1]; source = ds_source; - //colormap = ds_colormap; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -1042,7 +1029,6 @@ void R_DrawTiltedTranslucentSpan_8(void) izstep = ds_szp->x * SPANSIZE; uzstep = ds_sup->x * SPANSIZE; vzstep = ds_svp->x * SPANSIZE; - //x1 = 0; width++; while (width >= SPANSIZE) @@ -1120,7 +1106,6 @@ void R_DrawTiltedTranslucentSpan_8(void) */ void R_DrawTiltedTranslucentWaterSpan_8(void) { - // x1, x2 = ds_x1, ds_x2 int width = ds_x2 - ds_x1; double iz, uz, vz; UINT32 u, v; @@ -1158,7 +1143,6 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; source = ds_source; - //colormap = ds_colormap; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -1186,7 +1170,6 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) izstep = ds_szp->x * SPANSIZE; uzstep = ds_sup->x * SPANSIZE; vzstep = ds_svp->x * SPANSIZE; - //x1 = 0; width++; while (width >= SPANSIZE) @@ -1558,17 +1541,14 @@ void R_DrawTranslucentSpan_8 (void) fixed_t xstep, ystep; register UINT32 bit; - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; + const UINT8 *source = ds_source; + const UINT8 *colormap = ds_colormap; + register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; register size_t count = (ds_x2 - ds_x1 + 1); size_t i; - xposition = ds_xfrac; yposition = ds_yfrac; - xstep = ds_xstep; ystep = ds_ystep; - // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the // texture with two shifts, an OR and one AND. (see below) @@ -1576,12 +1556,8 @@ void R_DrawTranslucentSpan_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition <<= nflatshiftup; yposition <<= nflatshiftup; - xstep <<= nflatshiftup; ystep <<= nflatshiftup; - - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; + xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; + xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; while (count >= 8) { @@ -1617,10 +1593,10 @@ void R_DrawTranslucentWaterSpan_8(void) UINT32 xstep, ystep; register UINT32 bit; - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; - UINT8 *dsrc; + const UINT8 *source = ds_source; + const UINT8 *colormap = ds_colormap; + register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; + register UINT8 *dsrc; register size_t count; size_t i; @@ -1635,9 +1611,6 @@ void R_DrawTranslucentWaterSpan_8(void) xposition = ds_xfrac << nflatshiftup; yposition = (ds_yfrac + ds_waterofs) << nflatshiftup; xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; count = ds_x2 - ds_x1 + 1; @@ -1679,7 +1652,6 @@ void R_DrawFogSpan_8(void) register size_t count; colormap = ds_colormap; - //dest = ylookup[ds_y] + columnofs[ds_x1]; dest = &topleft[ds_y *vid.width + ds_x1]; count = ds_x2 - ds_x1 + 1; From d39fd5bb5c4e4f4df16f2d234d9f2dfcf91dd30f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Jan 2025 18:31:40 +0100 Subject: [PATCH 153/418] strafe controls for speccam/freecam TODO: seperate cam turning axis from gameplay turn axis for gamepads --- src/d_netcmd.c | 1 + src/g_game.c | 10 ++ src/g_game.h | 2 + src/g_input.c | 2 + src/g_input.h | 2 + src/m_menu.c | 265 ++++++++++++++++++++++--------------------------- src/p_user.c | 51 +++++++++- 7 files changed, 185 insertions(+), 148 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9b293aef6..1f2a0e95a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1033,6 +1033,7 @@ void D_RegisterClientCommands(void) { CV_RegisterVar(&cv_turnaxis[i]); CV_RegisterVar(&cv_moveaxis[i]); + CV_RegisterVar(&cv_strafeaxis[i]); CV_RegisterVar(&cv_brakeaxis[i]); CV_RegisterVar(&cv_aimaxis[i]); CV_RegisterVar(&cv_lookaxis[i]); diff --git a/src/g_game.c b/src/g_game.c index 1bcd9778c..87fd1b1d5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -440,6 +440,13 @@ consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS] = { {"joyaxis4_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; +consvar_t cv_strafeaxis[MAXSPLITSCREENPLAYERS] = { + {"joyaxis_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis2_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis3_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis4_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS] = { {"joyaxis_brake", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"joyaxis2_brake", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, @@ -732,6 +739,9 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player) case AXISMOVE: axisval = cv_moveaxis[player-1].value; break; + case AXISSTRAFE: + axisval = cv_strafeaxis[player-1].value; + break; case AXISBRAKE: axisval = cv_brakeaxis[player-1].value; break; diff --git a/src/g_game.h b/src/g_game.h index 10c2a6156..9ca6dce09 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -124,6 +124,7 @@ extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mo extern consvar_t cv_turnaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_strafeaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_aimaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_lookaxis[MAXSPLITSCREENPLAYERS]; @@ -192,6 +193,7 @@ typedef enum AXISNONE = 0, AXISTURN, AXISMOVE, + AXISSTRAFE, AXISBRAKE, AXISAIM, AXISLOOK, diff --git a/src/g_input.c b/src/g_input.c index c948ed751..e80bbacd1 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -905,6 +905,8 @@ static const char *gamecontrolname[num_gamecontrols] = "freecam", "camfloat", "camsink", + "strafeleft", + "straferight", }; #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) diff --git a/src/g_input.h b/src/g_input.h index 1dbbb937f..1475af582 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -103,6 +103,8 @@ typedef enum gc_freecam, // Toggle for freecam while ingame gc_camfloat, // alternative button for raising cam gc_camsink, // alternative button for sinking + gc_strafeleft, + gc_straferight, num_gamecontrols } gamecontrols_e; diff --git a/src/m_menu.c b/src/m_menu.c index 664f734e5..b899efa30 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -643,23 +643,23 @@ static menuitem_t MISC_ReplayOptionsMenu[] = static tic_t playback_last_menu_interaction_leveltime = 0; static menuitem_t PlaybackMenu[] = { - {IT_CALL | IT_STRING, "M_PHIDE", "Hide Menu (Esc)", M_SelectableClearMenus, 0}, + {IT_CALL | IT_STRING, "M_PHIDE", "Hide Menu (Esc)", M_SelectableClearMenus, 0}, - {IT_CALL | IT_STRING, "M_PREW", "Rewind ([)", M_PlaybackRewind, 20}, - {IT_CALL | IT_STRING, "M_PPAUSE", "Pause (\\)", M_PlaybackPause, 36}, - {IT_CALL | IT_STRING, "M_PFFWD", "Fast-Forward (])", M_PlaybackFastForward, 52}, - {IT_CALL | IT_STRING, "M_PSTEPB", "Backup Frame ([)", M_PlaybackRewind, 20}, - {IT_CALL | IT_STRING, "M_PRESUM", "Resume", M_PlaybackPause, 36}, - {IT_CALL | IT_STRING, "M_PFADV", "Advance Frame (])", M_PlaybackAdvance, 52}, + {IT_CALL | IT_STRING, "M_PREW", "Rewind ([)", M_PlaybackRewind, 20}, + {IT_CALL | IT_STRING, "M_PPAUSE", "Pause (\\)", M_PlaybackPause, 36}, + {IT_CALL | IT_STRING, "M_PFFWD", "Fast-Forward (])", M_PlaybackFastForward, 52}, + {IT_CALL | IT_STRING, "M_PSTEPB", "Backup Frame ([)", M_PlaybackRewind, 20}, + {IT_CALL | IT_STRING, "M_PRESUM", "Resume", M_PlaybackPause, 36}, + {IT_CALL | IT_STRING, "M_PFADV", "Advance Frame (])", M_PlaybackAdvance, 52}, - {IT_ARROWS | IT_STRING, "M_PVIEWS", "View Count (- and =)", M_PlaybackSetViews, 72}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint (1)", M_PlaybackAdjustView, 88}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 2 (2)", M_PlaybackAdjustView, 104}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 3 (3)", M_PlaybackAdjustView, 120}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 4 (4)", M_PlaybackAdjustView, 136}, + {IT_ARROWS | IT_STRING, "M_PVIEWS", "View Count (- and =)", M_PlaybackSetViews, 72}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint (1)", M_PlaybackAdjustView, 88}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 2 (2)", M_PlaybackAdjustView, 104}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 3 (3)", M_PlaybackAdjustView, 120}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 4 (4)", M_PlaybackAdjustView, 136}, {IT_CALL | IT_STRING, "M_PVIEWS", "Toggle Free Camera (')", M_PlaybackToggleFreecam, 156}, - {IT_CALL | IT_STRING, "M_PEXIT", "Stop Playback", M_PlaybackQuit, 172}, + {IT_CALL | IT_STRING, "M_PEXIT", "Stop Playback", M_PlaybackQuit, 172}, }; typedef enum { @@ -702,8 +702,8 @@ typedef enum // --------------------- static menuitem_t MPauseMenu[] = { - {IT_STRING | IT_CALL, NULL, "Addons...", M_Addons, 8}, - {IT_STRING | IT_CALL, NULL, "Add local skins...", M_LocalSkins, 16}, + {IT_STRING | IT_CALL, NULL, "Addons...", M_Addons, 8}, + {IT_STRING | IT_CALL, NULL, "Add local skins...", M_LocalSkins, 16}, {IT_STRING | IT_SUBMENU, NULL, "Scramble Teams...", &MISC_ScrambleTeamDef, 24}, {IT_STRING | IT_CALL, NULL, "Switch Map..." , M_MapChange, 32}, @@ -766,7 +766,7 @@ static menuitem_t SPauseMenu[] = // Pandora's Box will be shifted up if both options are available {IT_CALL | IT_STRING, NULL, "Pandora's Box...", M_PandorasBox, 16}, {IT_CALL | IT_STRING, NULL, "Medal Hints...", M_EmblemHints, 24}, - //{IT_CALL | IT_STRING, NULL, "Level Select...", M_LoadGameLevelSelect, 32}, + //{IT_CALL | IT_STRING, NULL, "Level Select...", M_LoadGameLevelSelect, 32}, {IT_CALL | IT_STRING, NULL, "Continue", M_SelectableClearMenus,48}, {IT_CALL | IT_STRING, NULL, "Retry", M_Retry, 56}, @@ -1034,13 +1034,13 @@ menuitem_t PlayerMenu[MAXSKINS]; static menuitem_t MP_MainMenu[] = { {IT_HEADER, NULL, "Players", NULL, 0}, - {IT_STRING|IT_CVAR, NULL, "Number of local players", &cv_splitplayers, 10}, + {IT_STRING|IT_CVAR, NULL, "Number of local players", &cv_splitplayers, 10}, - {IT_STRING|IT_KEYHANDLER,NULL, "Player setup...", M_SetupMultiHandler,18}, + {IT_STRING|IT_KEYHANDLER,NULL, "Player setup...", M_SetupMultiHandler, 18}, {IT_HEADER, NULL, "Host a game", NULL, 100-24}, #ifndef NONET - {IT_STRING|IT_CALL, NULL, "Internet/LAN...", M_PreStartServerMenu, 110-24}, + {IT_STRING|IT_CALL, NULL, "Internet/LAN...", M_PreStartServerMenu, 110-24}, #else {IT_GRAYEDOUT, NULL, "Internet/LAN...", NULL, 110-24}, #endif @@ -1049,11 +1049,11 @@ static menuitem_t MP_MainMenu[] = {IT_HEADER, NULL, "Join a game", NULL, 132-24}, #ifndef NONET #ifndef MASTERSERVER - {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, + {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, #else - {IT_STRING|IT_CALL, NULL, "Internet server browser...",M_PreConnectMenu, 142-24}, + {IT_STRING|IT_CALL, NULL, "Internet server browser...",M_PreConnectMenu, 142-24}, #endif - {IT_STRING|IT_CALL, NULL, "Join last server", M_ConnectLastServer, 150-24}, + {IT_STRING|IT_CALL, NULL, "Join last server", M_ConnectLastServer, 150-24}, {IT_STRING|IT_KEYHANDLER, NULL, "Specify IPv4 address:", M_HandleConnectIP, 158-24}, #else {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, @@ -1149,7 +1149,7 @@ static menuitem_t OP_MainMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 135}, - {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 145}, {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 155}, }; @@ -1158,13 +1158,13 @@ static menuitem_t OP_ControlsMenu[] = {IT_CALL | IT_STRING, NULL, "Player 1 Controls...", M_Setup1PControlsMenu, 10}, {IT_CALL | IT_STRING, NULL, "Player 2 Controls...", M_Setup2PControlsMenu, 20}, - {IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30}, - {IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40}, + {IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30}, + {IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40}, - {IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 60}, + {IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 60}, - {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 80}, - {IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 90}, + {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 80}, + {IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 90}, }; static const char* OP_ControlsTooltips[] = @@ -1217,6 +1217,8 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Sink", M_ChangeControl, gc_camsink }, {IT_CONTROL, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, {IT_CONTROL, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, + {IT_CONTROL, NULL, "Strafe Left", M_ChangeControl, gc_strafeleft }, + {IT_CONTROL, NULL, "Strafe Right", M_ChangeControl, gc_straferight}, //{IT_CONTROL, NULL, "Toggle First-Person", M_ChangeControl, gc_camtoggle }, {IT_HEADER, NULL, "Spectator Controls", NULL, 0}, @@ -1233,90 +1235,94 @@ static menuitem_t OP_AllControlsMenu[] = static menuitem_t OP_Joystick1Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu, 10}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu , 10}, {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[0] , 20}, {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[0] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[0] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[0] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[0] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[0] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[0] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[0] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[0] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[0] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[0] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[0] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[0] , 80}, + {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[0] , 30}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[0] , 35}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[0] , 40}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[0] , 45}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[0] , 50}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[0] , 55}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[0] , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[0] , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[0] , 70}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[0] , 75}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[0] , 80}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[0] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 100}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 95}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 100}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 105}, }; static menuitem_t OP_Joystick2Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup2PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[1] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[1] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[1] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[1] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[1] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[1] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[1] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[1] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[1] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[1] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[1] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[1] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[1] , 80}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup2PJoystickMenu , 10}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[1] , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[1] , 25}, + {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[1] , 30}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[1] , 35}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[1] , 40}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[1] , 45}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[1] , 50}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[1] , 55}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[1] , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[1] , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[1] , 70}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[1] , 75}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[1] , 80}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[1] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 100}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 95}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 100}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 105}, }; static menuitem_t OP_Joystick3Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup3PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[2] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[2] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[2] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[2] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[2] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[2] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[2] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[2] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[2] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[2] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[2] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[2] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[2] , 80}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup3PJoystickMenu , 10}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[2] , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[2] , 25}, + {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[2] , 30}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[2] , 35}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[2] , 40}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[2] , 45}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[2] , 50}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[2] , 55}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[2] , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[2] , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[2] , 70}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[2] , 75}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[2] , 80}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[2] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 100}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 95}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 100}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 105}, }; static menuitem_t OP_Joystick4Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup4PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[3] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[3] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[3] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[3] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[3] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[3] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[3] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[3] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[3] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[3] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[3] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[3] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[3] , 80}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup4PJoystickMenu , 10}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[3] , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[3] , 25}, + {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[3] , 30}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[3] , 35}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[3] , 40}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[3] , 45}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[3] , 50}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[3] , 55}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[3] , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[3] , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[3] , 70}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[3] , 75}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[3] , 80}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[3] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 100}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 95}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 100}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 105}, }; static menuitem_t OP_JoystickSetMenu[] = @@ -12063,7 +12069,7 @@ static void M_Setup1PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_CONTROL; // GIF OP_AllControlsMenu[20].status = IT_CONTROL; // System Menu OP_AllControlsMenu[21].status = IT_CONTROL; // Console - OP_AllControlsMenu[35].status = IT_CONTROL; // Director + OP_AllControlsMenu[37].status = IT_CONTROL; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12086,7 +12092,7 @@ static void M_Setup2PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console - OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director + OP_AllControlsMenu[37].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12109,7 +12115,7 @@ static void M_Setup3PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console - OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director + OP_AllControlsMenu[37].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12132,7 +12138,7 @@ static void M_Setup4PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console - OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director + OP_AllControlsMenu[37].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12388,53 +12394,24 @@ static void M_ResetControlsResponse(INT32 ch) G_Controldefault(setupcontrolplayer); // Setup gamepad option defaults (yucky) - switch (setupcontrolplayer) + for (UINT8 j = 0; j < MAXSPLITSCREENPLAYERS; j++) { - case 4: - CV_StealthSet(&cv_usejoystick[3], cv_usejoystick[3].defaultvalue); - CV_StealthSet(&cv_turnaxis[3], cv_turnaxis[3].defaultvalue); - CV_StealthSet(&cv_moveaxis[3], cv_moveaxis[3].defaultvalue); - CV_StealthSet(&cv_brakeaxis[3], cv_brakeaxis[3].defaultvalue); - CV_StealthSet(&cv_aimaxis[3], cv_aimaxis[3].defaultvalue); - CV_StealthSet(&cv_lookaxis[3], cv_lookaxis[3].defaultvalue); - CV_StealthSet(&cv_fireaxis[3], cv_fireaxis[3].defaultvalue); - CV_StealthSet(&cv_driftaxis[3], cv_driftaxis[3].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[3], cv_lookbackaxis[3].defaultvalue); - break; - case 3: - CV_StealthSet(&cv_usejoystick[2], cv_usejoystick[2].defaultvalue); - CV_StealthSet(&cv_turnaxis[2], cv_turnaxis[2].defaultvalue); - CV_StealthSet(&cv_moveaxis[2], cv_moveaxis[2].defaultvalue); - CV_StealthSet(&cv_brakeaxis[2], cv_brakeaxis[2].defaultvalue); - CV_StealthSet(&cv_aimaxis[2], cv_aimaxis[2].defaultvalue); - CV_StealthSet(&cv_lookaxis[2], cv_lookaxis[2].defaultvalue); - CV_StealthSet(&cv_fireaxis[2], cv_fireaxis[2].defaultvalue); - CV_StealthSet(&cv_driftaxis[2], cv_driftaxis[2].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[2], cv_lookbackaxis[2].defaultvalue); - break; - case 2: - CV_StealthSet(&cv_usejoystick[1], cv_usejoystick[1].defaultvalue); - CV_StealthSet(&cv_turnaxis[1], cv_turnaxis[1].defaultvalue); - CV_StealthSet(&cv_moveaxis[1], cv_moveaxis[1].defaultvalue); - CV_StealthSet(&cv_brakeaxis[1], cv_brakeaxis[1].defaultvalue); - CV_StealthSet(&cv_aimaxis[1], cv_aimaxis[1].defaultvalue); - CV_StealthSet(&cv_lookaxis[1], cv_lookaxis[1].defaultvalue); - CV_StealthSet(&cv_fireaxis[1], cv_fireaxis[1].defaultvalue); - CV_StealthSet(&cv_driftaxis[1], cv_driftaxis[1].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[1], cv_lookbackaxis[1].defaultvalue); - break; - case 1: - default: - CV_StealthSet(&cv_usejoystick[0], cv_usejoystick[0].defaultvalue); - CV_StealthSet(&cv_turnaxis[0], cv_turnaxis[0].defaultvalue); - CV_StealthSet(&cv_moveaxis[0], cv_moveaxis[0].defaultvalue); - CV_StealthSet(&cv_brakeaxis[0], cv_brakeaxis[0].defaultvalue); - CV_StealthSet(&cv_aimaxis[0], cv_aimaxis[0].defaultvalue); - CV_StealthSet(&cv_lookaxis[0], cv_lookaxis[0].defaultvalue); - CV_StealthSet(&cv_fireaxis[0], cv_fireaxis[0].defaultvalue); - CV_StealthSet(&cv_driftaxis[0], cv_driftaxis[0].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[0], cv_lookbackaxis[0].defaultvalue); - break; + if (setupcontrolplayer != j) + continue; + + CV_StealthSet(&cv_usejoystick[j], cv_usejoystick[j].defaultvalue); + CV_StealthSet(&cv_turnaxis[j], cv_turnaxis[j].defaultvalue); + CV_StealthSet(&cv_strafeaxis[j], cv_strafeaxis[j].defaultvalue); + CV_StealthSet(&cv_moveaxis[j], cv_moveaxis[j].defaultvalue); + CV_StealthSet(&cv_brakeaxis[j], cv_brakeaxis[j].defaultvalue); + CV_StealthSet(&cv_aimaxis[j], cv_aimaxis[j].defaultvalue); + CV_StealthSet(&cv_lookaxis[j], cv_lookaxis[j].defaultvalue); + CV_StealthSet(&cv_fireaxis[j], cv_fireaxis[j].defaultvalue); + CV_StealthSet(&cv_driftaxis[j], cv_driftaxis[j].defaultvalue); + CV_StealthSet(&cv_lookbackaxis[j], cv_lookbackaxis[j].defaultvalue); + CV_StealthSet(&cv_custom1axis[j], cv_custom1axis[j].defaultvalue); + CV_StealthSet(&cv_custom2axis[j], cv_custom2axis[j].defaultvalue); + CV_StealthSet(&cv_custom3axis[j], cv_custom3axis[j].defaultvalue); } S_StartSound(NULL, sfx_s224); diff --git a/src/p_user.c b/src/p_user.c index 52399e56f..6dfe4d0af 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3131,8 +3131,9 @@ fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42}; #define MAXCAMERADIST 140*FRACUNIT // Max distance the camera can be in front of the player (2D mode) static fixed_t forwardmove[2] = {25<>16, 50<>16}; -static fixed_t sidemove[2] = {2<>16, 4<>16}; +//static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn +static fixed_t strafemove[2] = {25<>16, 50<>16}; // faster! void P_ToggleDemoCamera(UINT8 viewnum) { @@ -3176,6 +3177,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) // these ones used for multiple conditions boolean turnleft, turnright, mouseaiming; + boolean strafeleft, straferight; boolean invertmouse, usejoystick, kbl; angle_t lang; INT32 player_invert; @@ -3242,18 +3244,48 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) turnright = turnright || (axis > 0); turnleft = turnleft || (axis < 0); } - forward = side = 0; + forward = 0; // let movement keys cancel each other out if (turnright && !(turnleft)) { cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); - side += sidemove[1]; + //side += sidemove[1]; } else if (turnleft && !(turnright)) { cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); - side -= sidemove[1]; + //side -= sidemove[1]; + } + + straferight = InputDown(gc_straferight, forplayer); + strafeleft = InputDown(gc_strafeleft, forplayer); + + axis = JoyAxis(AXISSTRAFE, forplayer); + + if (encoremode) + { + straferight ^= strafeleft; // swap these using three XORs + strafeleft ^= straferight; + straferight ^= strafeleft; + axis = -axis; + } + + if (usejoystick && axis != 0) + { + straferight = straferight || (axis > 0); + strafeleft = strafeleft || (axis < 0); + } + side = 0; + + // let strafe keys cancel each other out + if (straferight && !(strafeleft)) + { + side += strafemove[1]; + } + else if (strafeleft && !(straferight)) + { + side -= strafemove[1]; } cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); @@ -3470,6 +3502,17 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // besides freecam going inside walls sounds pretty cool on paper. } + // cmd->strafemove -- cant really add stuff to ticcmd struct so im reusing this + if (cmd->sidemove != 0) // was disabled in practice anyways, since sidemove was suppressed + { + //False I fixed this shit - Nep + fixed_t spd = cmd->sidemove*mapobjectscale; + + thrustangle = (cam->angle-ANGLE_90) >> ANGLETOFINESHIFT; + cam->x += FixedMul(spd, FINECOSINE(thrustangle)); + cam->y += FixedMul(spd, FINESINE(thrustangle)); + } + // update subsector to avoid crashes; cam->subsector = R_PointInSubsector(cam->x, cam->y); } From 50d2bf5d8da6604f8c141f613c44ecdd26a82953 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Jan 2025 22:23:28 +0100 Subject: [PATCH 154/418] seperate game turn axis from cam turn axis both are bound to the same value by default, so vanilla controls remain intact theres no other good way to have gamepad controls for this sadly --- src/d_netcmd.c | 3 +- src/g_game.c | 24 +++++-- src/g_game.h | 6 +- src/m_menu.c | 176 +++++++++++++++++++++++++++++-------------------- src/p_user.c | 4 +- 5 files changed, 129 insertions(+), 84 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1f2a0e95a..13d7bd679 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1033,7 +1033,8 @@ void D_RegisterClientCommands(void) { CV_RegisterVar(&cv_turnaxis[i]); CV_RegisterVar(&cv_moveaxis[i]); - CV_RegisterVar(&cv_strafeaxis[i]); + CV_RegisterVar(&cv_camturnaxis[i]); + CV_RegisterVar(&cv_camstrafeaxis[i]); CV_RegisterVar(&cv_brakeaxis[i]); CV_RegisterVar(&cv_aimaxis[i]); CV_RegisterVar(&cv_lookaxis[i]); diff --git a/src/g_game.c b/src/g_game.c index 87fd1b1d5..60dca3870 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -440,11 +440,18 @@ consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS] = { {"joyaxis4_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; -consvar_t cv_strafeaxis[MAXSPLITSCREENPLAYERS] = { - {"joyaxis_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"joyaxis2_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"joyaxis3_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"joyaxis4_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +consvar_t cv_camstrafeaxis[MAXSPLITSCREENPLAYERS] = { + {"joyaxis_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis2_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis3_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis4_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + +consvar_t cv_camturnaxis[MAXSPLITSCREENPLAYERS] = { + {"joyaxis_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis2_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis3_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis4_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS] = { @@ -739,8 +746,11 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player) case AXISMOVE: axisval = cv_moveaxis[player-1].value; break; - case AXISSTRAFE: - axisval = cv_strafeaxis[player-1].value; + case AXISCAMTURN: + axisval = cv_camturnaxis[player-1].value; + break; + case AXISCAMSTRAFE: + axisval = cv_camstrafeaxis[player-1].value; break; case AXISBRAKE: axisval = cv_brakeaxis[player-1].value; diff --git a/src/g_game.h b/src/g_game.h index 9ca6dce09..53da464a5 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -124,7 +124,8 @@ extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mo extern consvar_t cv_turnaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS]; -extern consvar_t cv_strafeaxis[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_camturnaxis[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_camstrafeaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_aimaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_lookaxis[MAXSPLITSCREENPLAYERS]; @@ -193,7 +194,8 @@ typedef enum AXISNONE = 0, AXISTURN, AXISMOVE, - AXISSTRAFE, + AXISCAMTURN, + AXISCAMSTRAFE, AXISBRAKE, AXISAIM, AXISLOOK, diff --git a/src/m_menu.c b/src/m_menu.c index b899efa30..41bae3132 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1196,7 +1196,7 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Aim Backward", M_ChangeControl, gc_aimbackward}, {IT_CONTROL, NULL, "Look Backward", M_ChangeControl, gc_lookback }, - {IT_HEADER, NULL, "Miscelleanous Controls", NULL, 0}, + {IT_HEADER, NULL, "Miscellaneous Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, {IT_CONTROL, NULL, "Chat", M_ChangeControl, gc_talkkey }, //{IT_CONTROL, NULL, "Team Chat", M_ChangeControl, gc_teamkey }, @@ -1235,94 +1235,126 @@ static menuitem_t OP_AllControlsMenu[] = static menuitem_t OP_Joystick1Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu , 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[0] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[0] , 25}, - {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[0] , 30}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[0] , 35}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[0] , 40}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[0] , 45}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[0] , 50}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[0] , 55}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[0] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[0] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[0] , 70}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[0] , 75}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[0] , 80}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[0] , 85}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu , 0}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 95}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 100}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 105}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[0] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[0] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[0] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[0] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[0] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[0] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[0] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[0] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[0] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[0] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[0] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[0] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[0] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[0] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[0] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 130}, }; static menuitem_t OP_Joystick2Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup2PJoystickMenu , 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[1] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[1] , 25}, - {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[1] , 30}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[1] , 35}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[1] , 40}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[1] , 45}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[1] , 50}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[1] , 55}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[1] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[1] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[1] , 70}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[1] , 75}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[1] , 80}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[1] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 95}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 100}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 105}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[1] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[1] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[1] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[1] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[1] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[1] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[1] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[1] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[1] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[1] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[1] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[1] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[1] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[1] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[1] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 130}, }; static menuitem_t OP_Joystick3Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup3PJoystickMenu , 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[2] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[2] , 25}, - {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[2] , 30}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[2] , 35}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[2] , 40}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[2] , 45}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[2] , 50}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[2] , 55}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[2] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[2] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[2] , 70}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[2] , 75}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[2] , 80}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[2] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 95}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 100}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 105}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[2] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[2] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[2] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[2] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[2] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[2] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[2] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[2] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[2] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[2] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[2] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[2] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[2] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[2] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[2] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 130}, }; static menuitem_t OP_Joystick4Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup4PJoystickMenu , 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[3] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[3] , 25}, - {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[3] , 30}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[3] , 35}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[3] , 40}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[3] , 45}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[3] , 50}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[3] , 55}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[3] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[3] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[3] , 70}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[3] , 75}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[3] , 80}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[3] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 95}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 100}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 105}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[3] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[3] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[3] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[3] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[3] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[3] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[3] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[3] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[3] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[3] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[3] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[3] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[3] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[3] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[3] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 130}, }; static menuitem_t OP_JoystickSetMenu[] = @@ -12401,7 +12433,8 @@ static void M_ResetControlsResponse(INT32 ch) CV_StealthSet(&cv_usejoystick[j], cv_usejoystick[j].defaultvalue); CV_StealthSet(&cv_turnaxis[j], cv_turnaxis[j].defaultvalue); - CV_StealthSet(&cv_strafeaxis[j], cv_strafeaxis[j].defaultvalue); + CV_StealthSet(&cv_camturnaxis[j], cv_camturnaxis[j].defaultvalue); + CV_StealthSet(&cv_camstrafeaxis[j], cv_camstrafeaxis[j].defaultvalue); CV_StealthSet(&cv_moveaxis[j], cv_moveaxis[j].defaultvalue); CV_StealthSet(&cv_brakeaxis[j], cv_brakeaxis[j].defaultvalue); CV_StealthSet(&cv_aimaxis[j], cv_aimaxis[j].defaultvalue); @@ -12413,7 +12446,6 @@ static void M_ResetControlsResponse(INT32 ch) CV_StealthSet(&cv_custom2axis[j], cv_custom2axis[j].defaultvalue); CV_StealthSet(&cv_custom3axis[j], cv_custom3axis[j].defaultvalue); } - S_StartSound(NULL, sfx_s224); } diff --git a/src/p_user.c b/src/p_user.c index 6dfe4d0af..48287b187 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3229,7 +3229,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) turnright = InputDown(gc_turnright, forplayer); turnleft = InputDown(gc_turnleft, forplayer); - axis = JoyAxis(AXISTURN, forplayer); + axis = JoyAxis(AXISCAMTURN, forplayer); if (encoremode) { @@ -3261,7 +3261,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) straferight = InputDown(gc_straferight, forplayer); strafeleft = InputDown(gc_strafeleft, forplayer); - axis = JoyAxis(AXISSTRAFE, forplayer); + axis = JoyAxis(AXISCAMSTRAFE, forplayer); if (encoremode) { From ab064c90dd820186037e78d18b8388cb6d57e557 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Jan 2025 14:58:58 +0100 Subject: [PATCH 155/418] let "fovchange" work in software --- src/d_player.h | 3 +- src/hardware/hw_main.c | 6 +--- src/hardware/hw_main.h | 2 -- src/lua_playerlib.c | 5 ++- src/p_user.c | 4 +-- src/r_main.c | 76 +++++++++++++++++++++++++++++------------- src/r_main.h | 6 +++- src/r_sky.c | 3 +- 8 files changed, 63 insertions(+), 42 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 6ddca1622..b18fea1eb 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -549,9 +549,8 @@ typedef struct player_s UINT8 hitemvictim; UINT8 splitscreenindex; -#ifdef HWRENDER + fixed_t fovadd; // adjust FOV for hw rendering -#endif } player_t; #endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e1f5a509c..4c9d0e262 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -223,8 +223,6 @@ consvar_t cv_glrenderdistance = {"gr_renderdistance", "Max", CV_SAVE, glrenderdi consvar_t cv_glhorizonlines = {"gr_horizonlines", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glportals = {"gr_portals", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_glpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_glpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -5368,7 +5366,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl // ========================================================================== static void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) { - const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd); + const float fpov = FixedToFloat(R_GetPlayerFov(player)); // set window position gl_viewwindowx = gl_baseviewwindowx; @@ -5598,8 +5596,6 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_glhorizonlines); CV_RegisterVar(&cv_glportals); - CV_RegisterVar(&cv_glfovchange); - CV_RegisterVar(&cv_glpaletterendering); CV_RegisterVar(&cv_glpalettedepth); CV_RegisterVar(&cv_glflashpal); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index ef31be40c..0378fa634 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -181,8 +181,6 @@ extern consvar_t cv_glrenderdistance; extern consvar_t cv_glhorizonlines; extern consvar_t cv_glportals; -extern consvar_t cv_glfovchange; - extern consvar_t cv_glpaletterendering; extern consvar_t cv_glpalettedepth; extern consvar_t cv_glflashpal; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index dd4cf7b03..32b4abfe7 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -157,9 +157,8 @@ static const udata_field_t player_fields[] = { FIELD(player_t, grieftime, udatalib_getter_tic, udatalib_setter_tic), FIELD(player_t, griefstrikes, udatalib_getter_uint8, udatalib_setter_uint8), FIELD(player_t, splitscreenindex, udatalib_getter_uint8, player_splitscreenindex_noset), -#ifdef HWRENDER FIELD(player_t, fovadd, udatalib_getter_fixed, udatalib_setter_fixed), // Mmm yeah thats definitely synch safe -#endif + // Same as player.name { "sliproll", 0, player_sliproll_getter, player_sliproll_noset }, { "viewrollangle", 0, player_viewrollangle_getter, player_viewrollangle_noset }, @@ -882,4 +881,4 @@ int LUA_PlayerLib(lua_State *L) lua_setglobal(L, "displayplayers"); return 0; -} \ No newline at end of file +} diff --git a/src/p_user.c b/src/p_user.c index 6976b6be8..4d3308162 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2494,8 +2494,7 @@ static void P_MovePlayer(player_t *player) return; } -#ifdef HWRENDER - if (rendermode == render_opengl && cv_glfovchange.value) + if (cv_fovchange.value) { fixed_t speed; const fixed_t runnyspeed = 20*FRACUNIT; @@ -2515,7 +2514,6 @@ static void P_MovePlayer(player_t *player) } else player->fovadd = 0; -#endif #ifdef FLOORSPLATS if (cv_shadow.value && rendermode == render_soft) diff --git a/src/r_main.c b/src/r_main.c index 15a50b314..78d6c2d31 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -143,12 +143,14 @@ static CV_PossibleValue_t maxinterpdist_cons_t[] = { {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; -static CV_PossibleValue_t fov_cons_t[] = {{5*FRACUNIT, "MIN"}, {178*FRACUNIT, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t fov_cons_t[] = {{MINFOV*FRACUNIT, "MIN"}, {MAXFOV*FRACUNIT, "MAX"}, {0, NULL}}; static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; static CV_PossibleValue_t maxportals_cons_t[] = {{0, "MIN"}, {12, "MAX"}, {0, NULL}}; // lmao rendering 32 portals, you're a card static CV_PossibleValue_t homremoval_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Flash"}, {0, NULL}}; +static void R_SetFov(fixed_t playerfov); + static void Fov_OnChange(void); static void FlipCam_OnChange(void); static void FlipCam2_OnChange(void); @@ -202,6 +204,7 @@ consvar_t cv_ripplewater = {"waterripples", "On", CV_SAVE, CV_OnOff, NULL, 0, NU // cap fov, fov too high tears software apart. consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL|CV_SAVE, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fovchange = {"fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Okay, whoever said homremoval causes a performance hit should be shot. consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -921,12 +924,10 @@ void R_SetViewSize(void) // void R_ExecuteSetViewSize(void) { - fixed_t dy; INT32 i; INT32 j; INT32 level; INT32 startmapl; - angle_t fov; setsizeneeded = false; @@ -955,17 +956,10 @@ void R_ExecuteSetViewSize(void) centerxfrac = centerx<> ANGLETOFINESHIFT), viewmorph.zoomneeded); - if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view - fovtan = 17*fovtan/10; - - projection = projectiony = FixedDiv(centerxfrac, fovtan); + R_SetFov(cv_fov.value); R_InitViewBuffer(scaledviewwidth, viewheight); - R_InitTextureMapping(); - // why did we calc all the software crap? #ifdef HWRENDER if (rendermode == render_opengl) @@ -980,19 +974,6 @@ void R_ExecuteSetViewSize(void) for (i = 0; i < viewwidth; i++) screenheightarray[i] = (INT16)viewheight; - // setup sky scaling - R_SetSkyScale(); - - // planes - // this is only used for planes rendering in software mode - j = viewheight*16; - for (i = 0; i < j; i++) - { - dy = (i - viewheight*8)<fovadd; + return max(MINFOV*FRACUNIT, min(fov, MAXFOV*FRACUNIT)); +} + +static void R_SetFov(fixed_t playerfov) +{ + angle_t fov = FixedAngle(playerfov/2) + ANGLE_90; + fovtan = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph.zoomneeded); + if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view + fovtan = 17*fovtan/10; + + // this is only used for planes rendering in software mode + INT32 j = viewheight*16; + for (INT32 i = 0; i < j; i++) + { + fixed_t dy = (i - viewheight*8)< Date: Fri, 10 Jan 2025 22:46:05 +0100 Subject: [PATCH 156/418] 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 302f08837..0fd1ce5e6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4396,10 +4396,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")); } } } From e5e7205c95e40aa6b34c612aec4cc2f286f8d57d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 07:25:12 +0100 Subject: [PATCH 157/418] change how randomized light works so it doesent kill actual soc set randomlight if you toggle it --- src/d_main.c | 8 ++++---- src/dehacked.c | 3 +++ src/doomstat.h | 1 + src/p_setup.c | 15 +++++---------- src/p_spec.c | 27 +++++++++++++++++++++++---- src/r_main.c | 24 +----------------------- 6 files changed, 37 insertions(+), 41 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 209e7fb76..b03fa3da4 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -183,13 +183,13 @@ static void D_GamePadMenuScrollTicker(void) int key = 0; // butt-on output // wish i had a switch ono - if (DPADUPSCROLL) + if (DPADUPSCROLL) key = KEY_UPARROW; - else if (DPADDOWNSCROLL) + else if (DPADDOWNSCROLL) key = KEY_DOWNARROW; - else if (DPADLEFTSCROLL) + else if (DPADLEFTSCROLL) key = KEY_LEFTARROW; - else if (DPADRIGHTSCROLL) + else if (DPADRIGHTSCROLL) key = KEY_RIGHTARROW; if (key) diff --git a/src/dehacked.c b/src/dehacked.c index 57feee732..1413ad314 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -986,10 +986,12 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) else if (fastcmp(word, "LIGHTCONTRAST")) { mapheaderinfo[num-1]->light_contrast = (UINT8)i; + mapheaderinfo[num-1]->use_custom_light = true; } else if (fastcmp(word, "SPRITEBACKLIGHT")) { mapheaderinfo[num-1]->sprite_backlight = (SINT8)i; + mapheaderinfo[num-1]->use_custom_light = true; } else if (fastcmp(word, "LIGHTANGLE")) { @@ -1003,6 +1005,7 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) mapheaderinfo[num-1]->use_light_angle = true; mapheaderinfo[num-1]->light_angle = FixedAngle(FloatToFixed(atof(word2))); } + mapheaderinfo[num-1]->use_custom_light = true; } // Individual triggers for level flags, for ease of use (and 2.0 compatibility) diff --git a/src/doomstat.h b/src/doomstat.h index 03c295f65..cb8f83f8d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -259,6 +259,7 @@ typedef struct //boolean automap; ///< Displays a level's white map outline in modified games fixed_t mobj_scale; ///< Replacement for TOL_ERZ3 + boolean use_custom_light; UINT8 light_contrast; ///< Range of wall lighting. 0 is no lighting. SINT8 sprite_backlight; ///< Subtract from wall lighting for sprites only. boolean use_light_angle; ///< When false, wall lighting is evenly distributed. When true, wall lighting is directional. diff --git a/src/p_setup.c b/src/p_setup.c index ca41f9f7a..fcc5ae5fa 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -324,17 +324,13 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) // SRB2Kart //mapheaderinfo[num]->automap = false; mapheaderinfo[num]->mobj_scale = FRACUNIT; - // an even further impossibility, delfile custom opts support + mapheaderinfo[num]->customopts = NULL; mapheaderinfo[num]->numCustomOptions = 0; -} - -void P_ClearDirectionalLightMapHeaderInfo(INT16 i) // lol dont always reset this on every map load -{ - mapheaderinfo[i]->light_contrast = cv_randomdirlight.value ? M_RandomRange(0, 58) : 8; - mapheaderinfo[i]->sprite_backlight = 0; - mapheaderinfo[i]->use_light_angle = cv_randomdirlight.value ? true : false; - mapheaderinfo[i]->light_angle = cv_randomdirlight.value ? M_RandomRange(-382, 382) : 0; + mapheaderinfo[num]->light_contrast = 8; + mapheaderinfo[num]->sprite_backlight = 0; + mapheaderinfo[num]->use_light_angle = false; + mapheaderinfo[num]->light_angle = 0; } /** Allocates a new map-header structure. @@ -347,7 +343,6 @@ void P_AllocMapHeader(INT16 i) { mapheaderinfo[i] = Z_Malloc(sizeof(mapheader_t), PU_STATIC, NULL); mapheaderinfo[i]->grades = NULL; - P_ClearDirectionalLightMapHeaderInfo(i); } P_ClearSingleMapHeaderInfo(i + 1); } diff --git a/src/p_spec.c b/src/p_spec.c index 045e9db58..cbb5b0d5c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5225,6 +5225,28 @@ static void P_RunLevelLoadExecutors(void) } } +static void P_SetupDirectionalLight(void) +{ + if (cv_randomdirlight.value && mapheaderinfo[gamemap-1]->use_custom_light == false) + { + static INT16 oldmap = 0; // dont reset stuff when you restart a map + if (gamemap != oldmap) + { + maplighting.contrast = M_RandomRange(0, 58); + maplighting.backlight = 0; + maplighting.directional = M_RandomRange(0, 1); // either on or off + maplighting.angle = M_RandomRange(-382, 382); + } + oldmap = gamemap; + return; + } + + maplighting.contrast = mapheaderinfo[gamemap-1]->light_contrast; + maplighting.backlight = mapheaderinfo[gamemap-1]->sprite_backlight; + maplighting.directional = mapheaderinfo[gamemap-1]->use_light_angle; + maplighting.angle = mapheaderinfo[gamemap-1]->light_angle; +} + /** After the map has loaded, scans for specials that spawn 3Dfloors and * thinkers. * @@ -5251,10 +5273,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) gravity = (FRACUNIT*8)/10; // Set map lighting settings. - maplighting.contrast = mapheaderinfo[gamemap-1]->light_contrast; - maplighting.backlight = mapheaderinfo[gamemap-1]->sprite_backlight; - maplighting.directional = mapheaderinfo[gamemap-1]->use_light_angle; - maplighting.angle = mapheaderinfo[gamemap-1]->light_angle; + P_SetupDirectionalLight(); // Defaults in case levels don't have them set. sstimer = 90*TICRATE + 6; diff --git a/src/r_main.c b/src/r_main.c index 76ee85428..f4054fbfd 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -159,8 +159,6 @@ void SendWeaponPref2(void); void SendWeaponPref3(void); void SendWeaponPref4(void); -static void DirLight_OnChange(void); - static void Precipstuff_OnChange(void); consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -209,27 +207,7 @@ consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // randomized directional lightning -consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, DirLight_OnChange, 0, NULL, NULL, 0, 0, NULL}; - -static void DirLight_OnChange(void) -{ - for (int i = 0; i < NUMMAPS; i++) - { - if (!mapheaderinfo[i]) - continue; - - P_ClearDirectionalLightMapHeaderInfo(i); - } - - //current map - if (mapheaderinfo[gamemap-1]) - { - maplighting.contrast = mapheaderinfo[gamemap-1]->light_contrast; - maplighting.backlight = mapheaderinfo[gamemap-1]->sprite_backlight; - maplighting.directional = mapheaderinfo[gamemap-1]->use_light_angle; - maplighting.angle = mapheaderinfo[gamemap-1]->light_angle; - } -} +consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; void SplitScreen_OnChange(void) { From c1514635b045d9ec0c5e0ebbb61de6fa12555e01 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 07:34:41 +0100 Subject: [PATCH 158/418] if disabled and no soc overrides light behave like vanilla always apply wall and slope contrast pls --- src/p_setup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index fcc5ae5fa..140ba4a8f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -545,6 +545,9 @@ boolean P_SectorUsesDirectionalLighting(const sector_t *sector) boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector) { + if (!cv_randomdirlight.value && mapheaderinfo[gamemap-1]->use_custom_light == false) + return (baselightnum < LIGHTLEVELS-1 && baselightnum > 0); + if (!P_SectorUsesDirectionalLighting(sector)) { return false; @@ -557,6 +560,9 @@ boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector) boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector) { + if (!cv_randomdirlight.value && mapheaderinfo[gamemap-1]->use_custom_light == false) + return (baselightlevel < 255 && baselightlevel > 0); + if (!P_SectorUsesDirectionalLighting(sector)) { return false; From 02595b9ea63c0546ed730756d6445e6e07240ca1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 07:50:10 +0100 Subject: [PATCH 159/418] forgor this --- src/p_setup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.h b/src/p_setup.h index 6de1a1b90..4118fb455 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -97,9 +97,9 @@ void P_UpdateSegLightOffset(seg_t *li); boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector); boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector); boolean P_SectorUsesDirectionalLighting(const sector_t *sector); + size_t P_PrecacheLevelFlats(void); -void P_ClearDirectionalLightMapHeaderInfo(INT16 i); void P_AllocMapHeader(INT16 i); // Needed for NiGHTS From ef1faf9f68ae94458e66050454bc433b80f8e25b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 08:26:12 +0100 Subject: [PATCH 160/418] those somehow got lost --- src/p_mobj.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_mobj.h b/src/p_mobj.h index cd7c64dc1..0529c4891 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -293,6 +293,7 @@ typedef struct mobj_s fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; fixed_t old_spritexoffset, old_spriteyoffset; + INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch @@ -445,6 +446,7 @@ typedef struct precipmobj_s fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; fixed_t old_spritexoffset, old_spriteyoffset; + INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch From c1ec72e6065198f44580f6073371d815b8e2e741 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 08:28:49 +0100 Subject: [PATCH 161/418] oops --- src/p_setup.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 140ba4a8f..180ded60f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -545,7 +545,14 @@ boolean P_SectorUsesDirectionalLighting(const sector_t *sector) boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector) { - if (!cv_randomdirlight.value && mapheaderinfo[gamemap-1]->use_custom_light == false) + mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; + + if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) + { + lighting = &mapheaderinfo[gamemap-1]->lighting_encore; + } + + if (!cv_randomdirlight.value && lighting->use_custom_light == false) return (baselightnum < LIGHTLEVELS-1 && baselightnum > 0); if (!P_SectorUsesDirectionalLighting(sector)) @@ -560,7 +567,14 @@ boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector) boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector) { - if (!cv_randomdirlight.value && mapheaderinfo[gamemap-1]->use_custom_light == false) + mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; + + if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) + { + lighting = &mapheaderinfo[gamemap-1]->lighting_encore; + } + + if (!cv_randomdirlight.value && lighting->use_custom_light == false) return (baselightlevel < 255 && baselightlevel > 0); if (!P_SectorUsesDirectionalLighting(sector)) From 124b2ff431914962b56cad30681cd35e52e84afe Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 08:03:59 +0100 Subject: [PATCH 162/418] add encore variants of maplight --- src/dehacked.c | 43 +++++++++++++++++++++++++++++++------------ src/doomstat.h | 17 ++++++++++++----- src/p_setup.c | 17 +++++++++++++---- src/p_spec.c | 23 +++++++++++++++++------ 4 files changed, 73 insertions(+), 27 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 1413ad314..c914bc5cb 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -690,6 +690,20 @@ static const struct { {NULL, 0} }; +static mapheader_lighting_t *usemaplighting(INT32 mapnum, const char *word) +{ + if (fastncmp(word, "ENCORE", 6)) + { + mapheaderinfo[mapnum]->use_encore_lighting = true; + + return &mapheaderinfo[mapnum]->lighting_encore; + } + else + { + return &mapheaderinfo[mapnum]->lighting; + } +} + static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) { char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); @@ -983,29 +997,34 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) }*/ else if (fastcmp(word, "MOBJSCALE")) mapheaderinfo[num-1]->mobj_scale = get_number(word2); - else if (fastcmp(word, "LIGHTCONTRAST")) + else if (fastcmp(word, "LIGHTCONTRAST") || fastcmp(word, "ENCORELIGHTCONTRAST")) { - mapheaderinfo[num-1]->light_contrast = (UINT8)i; - mapheaderinfo[num-1]->use_custom_light = true; + mapheader_lighting_t *lighting = usemaplighting(num-1, word); + lighting->light_contrast = (UINT8)i; + lighting->use_custom_light = true; } - else if (fastcmp(word, "SPRITEBACKLIGHT")) + else if (fastcmp(word, "SPRITEBACKLIGHT") || fastcmp(word, "ENCORESPRITEBACKLIGHT")) { - mapheaderinfo[num-1]->sprite_backlight = (SINT8)i; - mapheaderinfo[num-1]->use_custom_light = true; + mapheader_lighting_t *lighting = usemaplighting(num-1, word); + lighting->sprite_backlight = (SINT8)i; + lighting->use_custom_light = true; } - else if (fastcmp(word, "LIGHTANGLE")) + else if (fastcmp(word, "LIGHTANGLE") || fastcmp(word, "ENCORELIGHTANGLE")) { + mapheader_lighting_t *lighting = usemaplighting(num-1, word); + if (fastcmp(word2, "EVEN")) { - mapheaderinfo[num-1]->use_light_angle = false; - mapheaderinfo[num-1]->light_angle = 0; + lighting->use_light_angle = false; + lighting->light_angle = 0; } else { - mapheaderinfo[num-1]->use_light_angle = true; - mapheaderinfo[num-1]->light_angle = FixedAngle(FloatToFixed(atof(word2))); + lighting->use_light_angle = true; + lighting->light_angle = FixedAngle(FloatToFixed(atof(word2))); } - mapheaderinfo[num-1]->use_custom_light = true; + + lighting->use_custom_light = true; } // Individual triggers for level flags, for ease of use (and 2.0 compatibility) diff --git a/src/doomstat.h b/src/doomstat.h index cb8f83f8d..a97723b5a 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -212,6 +212,15 @@ typedef struct char value[256]; // 255 usable characters. If this seriously isn't enough then wtf. } customoption_t; +typedef struct +{ + boolean use_custom_light; + UINT8 light_contrast; ///< Range of wall lighting. 0 is no lighting. + SINT8 sprite_backlight; ///< Subtract from wall lighting for sprites only. + boolean use_light_angle; ///< When false, wall lighting is evenly distributed. When true, wall lighting is directional. + angle_t light_angle; ///< Angle of directional wall lighting. +} mapheader_lighting_t; + /** Map header information. */ typedef struct @@ -259,11 +268,9 @@ typedef struct //boolean automap; ///< Displays a level's white map outline in modified games fixed_t mobj_scale; ///< Replacement for TOL_ERZ3 - boolean use_custom_light; - UINT8 light_contrast; ///< Range of wall lighting. 0 is no lighting. - SINT8 sprite_backlight; ///< Subtract from wall lighting for sprites only. - boolean use_light_angle; ///< When false, wall lighting is evenly distributed. When true, wall lighting is directional. - angle_t light_angle; ///< Angle of directional wall lighting. + mapheader_lighting_t lighting; ///< Wall and sprite lighting + mapheader_lighting_t lighting_encore; ///< Alternative lighting for Encore mode + boolean use_encore_lighting; ///< Whether to use separate Encore lighting // Music stuff. UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds diff --git a/src/p_setup.c b/src/p_setup.c index 180ded60f..1dbb43bac 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -278,6 +278,15 @@ FUNCNORETURN static ATTRNORETURN void CorruptMapError(const char *msg) #define NUMLAPS_DEFAULT 3 +static void P_ClearMapHeaderLighting(mapheader_lighting_t *lighting) +{ + lighting->light_contrast = 8; + lighting->sprite_backlight = 0; + lighting->use_light_angle = false; + lighting->light_angle = 0; + lighting->use_custom_light = false; +} + /** Clears the data from a single map header. * * \param i Map number to clear header for. @@ -327,10 +336,10 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->customopts = NULL; mapheaderinfo[num]->numCustomOptions = 0; - mapheaderinfo[num]->light_contrast = 8; - mapheaderinfo[num]->sprite_backlight = 0; - mapheaderinfo[num]->use_light_angle = false; - mapheaderinfo[num]->light_angle = 0; + + P_ClearMapHeaderLighting(&mapheaderinfo[num]->lighting); + P_ClearMapHeaderLighting(&mapheaderinfo[num]->lighting_encore); + mapheaderinfo[num]->use_encore_lighting = false; } /** Allocates a new map-header structure. diff --git a/src/p_spec.c b/src/p_spec.c index cbb5b0d5c..786ba633f 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5227,24 +5227,35 @@ static void P_RunLevelLoadExecutors(void) static void P_SetupDirectionalLight(void) { - if (cv_randomdirlight.value && mapheaderinfo[gamemap-1]->use_custom_light == false) + mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; + + if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) + { + lighting = &mapheaderinfo[gamemap-1]->lighting_encore; + } + + if (cv_randomdirlight.value && lighting->use_custom_light == false) { static INT16 oldmap = 0; // dont reset stuff when you restart a map - if (gamemap != oldmap) + static boolean oldencore = false; + + if (gamemap != oldmap || encoremode != oldencore) { maplighting.contrast = M_RandomRange(0, 58); maplighting.backlight = 0; maplighting.directional = M_RandomRange(0, 1); // either on or off maplighting.angle = M_RandomRange(-382, 382); } + oldmap = gamemap; + oldencore = encoremode; return; } - maplighting.contrast = mapheaderinfo[gamemap-1]->light_contrast; - maplighting.backlight = mapheaderinfo[gamemap-1]->sprite_backlight; - maplighting.directional = mapheaderinfo[gamemap-1]->use_light_angle; - maplighting.angle = mapheaderinfo[gamemap-1]->light_angle; + maplighting.contrast = lighting->light_contrast; + maplighting.backlight = lighting->sprite_backlight; + maplighting.directional = lighting->use_light_angle; + maplighting.angle = lighting->light_angle; } /** After the map has loaded, scans for specials that spawn 3Dfloors and From 96b7a4efe63a70bf0cf22593508e7907ddcfb900 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 08:22:30 +0100 Subject: [PATCH 163/418] add FF_ABSOLUTELIGHTLEVEL mobj_t.lightlevel is absolute instead of relative when set --- src/hardware/hw_main.c | 10 +++- src/p_pspr.h | 2 + src/r_things.c | 110 ++++++++++++++++++++++------------------- 3 files changed, 71 insertions(+), 51 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a2b324273..c7620d9e4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -343,7 +343,15 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 { (void)papersprite; - *lightlevel += R_ThingLightLevel(spr->mobj); + if (spr->mobj->frame & FF_ABSOLUTELIGHTLEVEL) + { + *lightlevel = R_ThingLightLevel(spr->mobj); + return; + } + else + { + *lightlevel += R_ThingLightLevel(spr->mobj); + } if (maplighting.directional == false || !P_SectorUsesDirectionalLighting(sector) || model == true) return; diff --git a/src/p_pspr.h b/src/p_pspr.h index 5ac1d1d84..c5e736d91 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -45,6 +45,8 @@ #define FF_ANIMATE 0x4000 /// \brief Frame flags: frame always appears full bright #define FF_FULLBRIGHT 0x8000 +/// \brief mobj_t.lightlevel is absolute instead of relative +#define FF_ABSOLUTELIGHTLEVEL 0x40000 /// \brief Frame flags: 0 = no trans(opaque), 1-15 = transl. table #define FF_TRANSMASK 0xf0000 /// \brief shift for FF_TRANSMASK diff --git a/src/r_things.c b/src/r_things.c index 1e147cdae..cac08bc9c 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1596,71 +1596,81 @@ static void R_ProjectSprite(mobj_t *thing) return; } - if (thing->subsector->sector->numlights) + if (oldthing->frame & FF_ABSOLUTELIGHTLEVEL) { - light = thing->subsector->sector->numlights - 1; + const UINT8 n = R_ThingLightLevel(oldthing); - for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { - fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, interp.x, interp.y) - : thing->subsector->sector->lightlist[lightnum].height; - if (h <= gzt) - { - light = lightnum - 1; - break; - } - } - - lightnum = *thing->subsector->sector->lightlist[light].lightlevel; + // n = uint8 aka 0 - 255, so the shift will always be 0 - LIGHTLEVELS - 1 + lights_array = scalelight[n >> LIGHTSEGSHIFT]; } else { - lightnum = thing->subsector->sector->lightlevel; - } - lightnum = (lightnum + R_ThingLightLevel(thing)) >> LIGHTSEGSHIFT; - - if (maplighting.directional == true && P_SectorUsesDirectionalLighting(thing->subsector->sector)) - { - fixed_t extralight = R_GetSpriteDirectionalLighting(papersprite - ? interp.angle + (ang >= ANGLE_180 ? -ANGLE_90 : ANGLE_90) - : R_PointToAngle(interp.x, interp.y)); - - // Krangle contrast in 3P/4P because scalelight - // scales differently depending on the screen - // width (which is halved in 3P/4P). - if (splitscreen > 1) + if (thing->subsector->sector->numlights) { - extralight *= 2; - } + light = thing->subsector->sector->numlights - 1; - // Less change in contrast in dark sectors - extralight = FixedMul(extralight, min(max(0, lightnum), LIGHTLEVELS - 1) * FRACUNIT / (LIGHTLEVELS - 1)); + for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { + fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, interp.x, interp.y) + : thing->subsector->sector->lightlist[lightnum].height; + if (h <= gzt) + { + light = lightnum - 1; + break; + } + } - if (papersprite) - { - // Papersprite contrast should match walls - lightnum += FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; + lightnum = *thing->subsector->sector->lightlist[light].lightlevel; } else { - fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); - - // Less change in contrast at further distances, to counteract DOOM diminished light - extralight = FixedMul(extralight, min(n, FRACUNIT)); - - // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance - lightnum += FixedFloor((extralight / 4) + (FRACUNIT / 2)) / FRACUNIT; + lightnum = thing->subsector->sector->lightlevel; } + + lightnum = (lightnum + R_ThingLightLevel(thing)) >> LIGHTSEGSHIFT; + + if (maplighting.directional == true && P_SectorUsesDirectionalLighting(thing->subsector->sector)) + { + fixed_t extralight = R_GetSpriteDirectionalLighting(papersprite + ? interp.angle + (ang >= ANGLE_180 ? -ANGLE_90 : ANGLE_90) + : R_PointToAngle(interp.x, interp.y)); + + // Krangle contrast in 3P/4P because scalelight + // scales differently depending on the screen + // width (which is halved in 3P/4P). + if (splitscreen > 1) + { + extralight *= 2; + } + + // Less change in contrast in dark sectors + extralight = FixedMul(extralight, min(max(0, lightnum), LIGHTLEVELS - 1) * FRACUNIT / (LIGHTLEVELS - 1)); + + if (papersprite) + { + // Papersprite contrast should match walls + lightnum += FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; + } + else + { + fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); + + // Less change in contrast at further distances, to counteract DOOM diminished light + extralight = FixedMul(extralight, min(n, FRACUNIT)); + + // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance + lightnum += FixedFloor((extralight / 4) + (FRACUNIT / 2)) / FRACUNIT; + } + } + + if (lightnum < 0) + lights_array = scalelight[0]; + else if (lightnum >= LIGHTLEVELS) + lights_array = scalelight[LIGHTLEVELS-1]; + else + lights_array = scalelight[lightnum]; } - if (lightnum < 0) - lights_array = scalelight[0]; - else if (lightnum >= LIGHTLEVELS) - lights_array = scalelight[LIGHTLEVELS-1]; - else - lights_array = scalelight[lightnum]; - - heightsec = thing->subsector->sector->heightsec; if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; From a07c2f4c3236dca4fdeb2a8ce3c2c7d8ff9ce7e7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 08:52:41 +0100 Subject: [PATCH 164/418] reinit random maplight on mapchange when toggled the condition may otherwise not change the light if you restart the same map --- src/p_setup.h | 1 + src/p_spec.c | 6 +++++- src/r_main.c | 10 +++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/p_setup.h b/src/p_setup.h index 4118fb455..79acfff3f 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -93,6 +93,7 @@ void P_WriteThings(lumpnum_t lump); fixed_t P_SegLength(seg_t *seg); #endif +extern boolean reinitmaplight; void P_UpdateSegLightOffset(seg_t *li); boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector); boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector); diff --git a/src/p_spec.c b/src/p_spec.c index 786ba633f..30c14fdf4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5225,6 +5225,8 @@ static void P_RunLevelLoadExecutors(void) } } +// dumb thing to reset maplight on next map change when its toggled +boolean reinitmaplight = false; static void P_SetupDirectionalLight(void) { mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; @@ -5239,12 +5241,14 @@ static void P_SetupDirectionalLight(void) static INT16 oldmap = 0; // dont reset stuff when you restart a map static boolean oldencore = false; - if (gamemap != oldmap || encoremode != oldencore) + if (gamemap != oldmap || encoremode != oldencore || reinitmaplight) { maplighting.contrast = M_RandomRange(0, 58); maplighting.backlight = 0; maplighting.directional = M_RandomRange(0, 1); // either on or off maplighting.angle = M_RandomRange(-382, 382); + + reinitmaplight = false; } oldmap = gamemap; diff --git a/src/r_main.c b/src/r_main.c index f4054fbfd..276083778 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -159,6 +159,8 @@ void SendWeaponPref2(void); void SendWeaponPref3(void); void SendWeaponPref4(void); +static void DirLight_OnChange(void); + static void Precipstuff_OnChange(void); consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -207,7 +209,13 @@ consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // randomized directional lightning -consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, DirLight_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +// tells to reset the maplight at next map change +static void DirLight_OnChange(void) +{ + reinitmaplight = true; +} void SplitScreen_OnChange(void) { From e7c0cda77f397967f2869d965c63bc1f3155e544 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 08:52:41 +0100 Subject: [PATCH 165/418] reinit random maplight on mapchange when toggled the condition may otherwise not change the light if you restart the same map --- src/p_setup.h | 1 + src/p_spec.c | 6 +++++- src/r_main.c | 10 +++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/p_setup.h b/src/p_setup.h index 4118fb455..79acfff3f 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -93,6 +93,7 @@ void P_WriteThings(lumpnum_t lump); fixed_t P_SegLength(seg_t *seg); #endif +extern boolean reinitmaplight; void P_UpdateSegLightOffset(seg_t *li); boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector); boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector); diff --git a/src/p_spec.c b/src/p_spec.c index 1dd164f04..fbbad79ca 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5230,6 +5230,8 @@ static void P_RunLevelLoadExecutors(void) } } +// dumb thing to reset maplight on next map change when its toggled +boolean reinitmaplight = false; static void P_SetupDirectionalLight(void) { mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; @@ -5244,12 +5246,14 @@ static void P_SetupDirectionalLight(void) static INT16 oldmap = 0; // dont reset stuff when you restart a map static boolean oldencore = false; - if (gamemap != oldmap || encoremode != oldencore) + if (gamemap != oldmap || encoremode != oldencore || reinitmaplight) { maplighting.contrast = M_RandomRange(0, 58); maplighting.backlight = 0; maplighting.directional = M_RandomRange(0, 1); // either on or off maplighting.angle = M_RandomRange(-382, 382); + + reinitmaplight = false; } oldmap = gamemap; diff --git a/src/r_main.c b/src/r_main.c index f3a706f8e..408d0906a 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -161,6 +161,8 @@ void SendWeaponPref2(void); void SendWeaponPref3(void); void SendWeaponPref4(void); +static void DirLight_OnChange(void); + static void Precipstuff_OnChange(void); consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -210,7 +212,13 @@ consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // randomized directional lightning -consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, DirLight_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +// tells to reset the maplight at next map change +static void DirLight_OnChange(void) +{ + reinitmaplight = true; +} void SplitScreen_OnChange(void) { From 130c1aba67f15e982ad270aec8faab1849f6f1ef Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 18:08:14 +0100 Subject: [PATCH 166/418] put random direction light toggle into advanced video options also make it a scoll menu --- src/m_menu.c | 61 ++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 841e07e85..f54bb8269 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1363,33 +1363,30 @@ static const char* OP_MouseTooltips[] = static menuitem_t OP_VideoOptionsMenu[] = { - {IT_STRING | IT_CALL, NULL, "Set Resolution...", M_VideoModeMenu, 10}, + {IT_STRING | IT_CALL, NULL, "Set Resolution...", M_VideoModeMenu, 10}, #if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) - {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 20}, + {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 20}, #endif {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Brightness", &cv_globalgamma, 30}, + NULL, "Brightness", &cv_globalgamma, 30}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Saturation", &cv_globalsaturation , 40}, + NULL, "Saturation", &cv_globalsaturation , 40}, - {IT_SUBMENU|IT_STRING, NULL, "Advanced Color Settings...", &OP_ColorOptionsDef, 50}, + {IT_SUBMENU|IT_STRING, NULL, "Advanced Color Settings...", &OP_ColorOptionsDef, 50}, - {IT_STRING | IT_CVAR, NULL, "Randomized Directional Light",&cv_randomdirlight, 60}, + {IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 65}, + {IT_STRING | IT_CVAR, NULL, "Weather Draw Distance", &cv_drawdist_precip, 75}, - {IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 75}, - {IT_STRING | IT_CVAR, NULL, "Weather Draw Distance",&cv_drawdist_precip, 85}, - - {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 105}, - {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 115}, - {IT_STRING | IT_CVAR, NULL, "FPS Cap", &cv_fpscap, 125}, - {IT_STRING | IT_CVAR, NULL, "Drift spark pulse size",&cv_driftsparkpulse, 135}, - {IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 145}, + {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 95}, + {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 105}, + {IT_STRING | IT_CVAR, NULL, "FPS Cap", &cv_fpscap, 115}, + {IT_STRING | IT_CVAR, NULL, "Drift spark pulse size", &cv_driftsparkpulse, 125}, + {IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 135}, #ifdef HWRENDER - {IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 155}, + {IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 145}, #endif - {IT_SUBMENU|IT_STRING, NULL, "Advanced Video Options...", &OP_ExpOptionsDef, 165}, - + {IT_SUBMENU|IT_STRING, NULL, "Advanced Video Options...", &OP_ExpOptionsDef, 155}, }; static const char* OP_VideoTooltips[] = @@ -1401,7 +1398,6 @@ static const char* OP_VideoTooltips[] = "Gamma (brightness) of the game.", "Saturation of the game.", "Advanced color settings of the game.", - "Should the directional lightning be randomized each map?\nTakes effect on next map load.", "How far away objects are drawn.", "How far away weather is drawn.", "Show current game framerate and select the style.", @@ -1425,7 +1421,6 @@ enum op_video_gamma, op_video_sat, op_video_color, - op_video_dirlight, op_video_dd, op_video_wdd, op_video_fps, @@ -1487,23 +1482,25 @@ static menuitem_t OP_ColorOptionsMenu[] = static menuitem_t OP_ExpOptionsMenu[] = { - {IT_HEADER, NULL, "Advanced Video Options", NULL, 10}, - {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_maxinterpdist, 30}, - {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 40}, + {IT_HEADER, NULL, "Advanced Video Options", NULL, 15}, + {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_maxinterpdist, 25}, + {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 30}, - {IT_STRING | IT_CVAR, NULL, "Scale Weather with Mobjscale", &cv_mobjscaleprecip, 60}, - {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 70}, + {IT_STRING | IT_CVAR, NULL, "Scale Weather with Mobjscale", &cv_mobjscaleprecip, 40}, + {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 45}, - {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 80}, + {IT_STRING | IT_CVAR, NULL, "Randomized Directional Light", &cv_randomdirlight, 55}, - {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 90}, + {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 65}, + + {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 75}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 110}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 85}, #ifdef USE_FBO_OGL - {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 120}, + {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 90}, #endif - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 140}, + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 100}, #endif }; @@ -1514,6 +1511,7 @@ static const char* OP_ExpTooltips[] = "Should weather be interpolated? Weather should look about the\nsame but perform a bit better when disabled.", "Should weather be scaled with Mapobjectscale?.", "When weather is on this will cut the object amount used in half.", + "Should the directional lightning be randomized each map?\nTakes effect on next map load.", "Toggle being able to see the sky.", "Change the FPS counter sampling method\nInaccurate updates slower and might miss frame drops and such\nAccurate updates faster and is more accurate, but might be less readable", // how to ingles?? #ifdef HWRENDER @@ -1532,6 +1530,7 @@ enum op_exp_precipinter, op_exp_precipmoscale, op_exp_lessprecip, + op_exp_dirlight, op_exp_skybox, op_exp_accuratefps, #ifdef HWRENDER @@ -3114,7 +3113,7 @@ menu_t OP_MonitorToggleDef = menu_t OP_OpenGLOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30); #endif -menu_t OP_ExpOptionsDef = DEFAULTMENUSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 30); +menu_t OP_ExpOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 25); menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30); menu_t OP_ScreenshotOptionsDef = DEFAULTMENUSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30); @@ -5256,7 +5255,6 @@ static void M_DrawGenericMenu(void) DoToolTips(OP_ControlsDef, OP_ControlsTooltips); DoToolTips(OP_MouseOptionsDef, OP_MouseTooltips); DoToolTips(OP_VideoOptionsDef, OP_VideoTooltips); - DoToolTips(OP_ExpOptionsDef, OP_ExpTooltips); DoToolTips(OP_SoundOptionsDef, OP_SoundTooltips); DoToolTips(OP_SoundAdvancedDef, OP_SoundAdvancedTooltips); DoToolTips(OP_ChatOptionsDef, OP_ChatOptionsTooltips); @@ -5402,6 +5400,7 @@ static void M_DrawGenericScrollMenu(void) // dumb hack // tooltips // same macro here + DoToolTips(OP_ExpOptionsDef, OP_ExpTooltips); #ifdef HWRENDER DoToolTips(OP_OpenGLOptionsDef, OP_OpenGLTooltips); #endif From b40cb3331ab3f78dc94e30f5d9d503a9d0eb4d33 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 19:53:46 +0100 Subject: [PATCH 167/418] fix frame flag clash --- src/p_pspr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_pspr.h b/src/p_pspr.h index c5e736d91..2c173608b 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -41,12 +41,12 @@ #define FF_HORIZONTALFLIP 0x400 /// \brief Frame flags: Thin, paper-like sprite (for collision equivalent, see MF_PAPERCOLLISION) #define FF_PAPERSPRITE 0x800 +/// \brief mobj_t.lightlevel is absolute instead of relative +#define FF_ABSOLUTELIGHTLEVEL 0x2000 /// \brief Frame flags: Simple stateless animation #define FF_ANIMATE 0x4000 /// \brief Frame flags: frame always appears full bright #define FF_FULLBRIGHT 0x8000 -/// \brief mobj_t.lightlevel is absolute instead of relative -#define FF_ABSOLUTELIGHTLEVEL 0x40000 /// \brief Frame flags: 0 = no trans(opaque), 1-15 = transl. table #define FF_TRANSMASK 0xf0000 /// \brief shift for FF_TRANSMASK From ff895f32518dac61f83c88481ec239e451ef8477 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 19:53:46 +0100 Subject: [PATCH 168/418] fix frame flag clash --- src/p_pspr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_pspr.h b/src/p_pspr.h index c5e736d91..2c173608b 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -41,12 +41,12 @@ #define FF_HORIZONTALFLIP 0x400 /// \brief Frame flags: Thin, paper-like sprite (for collision equivalent, see MF_PAPERCOLLISION) #define FF_PAPERSPRITE 0x800 +/// \brief mobj_t.lightlevel is absolute instead of relative +#define FF_ABSOLUTELIGHTLEVEL 0x2000 /// \brief Frame flags: Simple stateless animation #define FF_ANIMATE 0x4000 /// \brief Frame flags: frame always appears full bright #define FF_FULLBRIGHT 0x8000 -/// \brief mobj_t.lightlevel is absolute instead of relative -#define FF_ABSOLUTELIGHTLEVEL 0x40000 /// \brief Frame flags: 0 = no trans(opaque), 1-15 = transl. table #define FF_TRANSMASK 0xf0000 /// \brief shift for FF_TRANSMASK From 86c89a47da6f4bbbadca1861526632108694c19b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 22:34:45 +0100 Subject: [PATCH 169/418] one line this --- src/hardware/hw_main.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3e8186ad0..fb3e71c09 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2384,31 +2384,19 @@ doaddline: // HWR_CheckBBox // Checks BSP node/subtree bounding box. // Returns true -// if some part of the bbox might be visible. +// if some part of the bbox might be visible. // // modified to use local variables static boolean HWR_CheckBBox(const fixed_t *bspcoord) { - INT32 boxpos; fixed_t px1, py1, px2, py2; angle_t angle1, angle2; // Find the corners of the box // that define the edges from current viewpoint. - if (viewx <= bspcoord[BOXLEFT]) - boxpos = 0; - else if (viewx < bspcoord[BOXRIGHT]) - boxpos = 1; - else - boxpos = 2; - - if (viewy >= bspcoord[BOXTOP]) - boxpos |= 0; - else if (viewy > bspcoord[BOXBOTTOM]) - boxpos |= 1<<2; - else - boxpos |= 2<<2; + const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT ] ? 1 : 2) + + (viewy >= bspcoord[BOXTOP ] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); if (boxpos == 5) return true; @@ -3137,18 +3125,18 @@ static void HWR_RenderBSPNode(INT32 bspnum) INT32 side; ps_numbspcalls.value.i++; - while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? + while (!(bspnum & NF_SUBSECTOR)) // Keep going until found a subsector { bsp = &nodes[bspnum]; // Decide which side the view point is on. side = R_PointOnSideFast(viewx, viewy, bsp); - // Recursively divide front space. + // Recursively divide front space (toward the viewer). if (HWR_PortalCheckBBox(bsp->bbox[side])) HWR_RenderBSPNode(bsp->children[side]); - // Possibly divide back space + // Possibly divide back space (away from the viewer). if (!(HWR_CheckBBox(bsp->bbox[side^1]) && HWR_PortalCheckBBox(bsp->bbox[side^1]))) return; @@ -5305,12 +5293,12 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl // Set transform. GL_SetTransform(&atransform); - validcount++; - ps_numbspcalls.value.i = 0; ps_numpolyobjects.value.i = 0; PS_START_TIMING(ps_bsptime); + validcount++; + if (cv_glbatching.value) HWR_StartBatching(); From 1237b553f72477efd152dca665f7a9625dac9176 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 00:59:47 +0100 Subject: [PATCH 170/418] toggle for camera turnaround on timeover --- src/p_local.h | 1 + src/p_user.c | 11 +++++++++-- src/r_main.c | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index b07d5e34a..2a1864cbc 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -148,6 +148,7 @@ extern consvar_t cv_cam_height[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_speed[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_rotate[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_cam_timeover[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_freecam_speed; diff --git a/src/p_user.c b/src/p_user.c index 93b78f33f..a87b8ca8c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3108,6 +3108,13 @@ consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS] = { {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; +consvar_t cv_cam_timeover[MAXSPLITSCREENPLAYERS] = { + {"cam_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam3_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam4_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; + static CV_PossibleValue_t freecam_speed_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; consvar_t cv_freecam_speed = {"freecam_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -3815,8 +3822,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall const boolean vflip = (mo->eflags & MFE_VERTICALFLIP); - if (player->pflags & PF_TIMEOVER) // 1 for momentum keep, 2 for turnaround - timeover = (player->kartstuff[k_timeovercam] > 2*TICRATE ? 2 : 1); + if (cv_cam_timeover[num].value && (player->pflags & PF_TIMEOVER)) + timeover = (player->kartstuff[k_timeovercam] > 2*TICRATE ? 2 : 1); // 1 for momentum keep, 2 for turnaround else timeover = 0; diff --git a/src/r_main.c b/src/r_main.c index 408d0906a..e302ca3ea 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1549,6 +1549,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam_speed[i]); CV_RegisterVar(&cv_cam_rotate[i]); CV_RegisterVar(&cv_cam_rotspeed[i]); + CV_RegisterVar(&cv_cam_timeover[i]); } CV_RegisterVar(&cv_freecam_speed); From 503f20a7f4b93fc5797908a8b06994806f6f9d5e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 01:51:37 +0100 Subject: [PATCH 171/418] split ra wheel and position number hud offsets kinda ass due to the preset offset, but will just not apply if either was changed from its original position --- src/g_game.h | 23 ++++++++++++----------- src/k_kart.c | 30 ++++++++++++++++-------------- src/m_menu.c | 16 ++++++++++------ 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 1f94f8640..519c23d5a 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -148,18 +148,19 @@ extern consvar_t cv_##name##_yoffset; DECL_HUD_OFFSET_X(name)\ DECL_HUD_OFFSET_Y(name) -DECL_HUD_OFFSET(item); // Item box -DECL_HUD_OFFSET(time); // Time -DECL_HUD_OFFSET(laps); // Number of laps -DECL_HUD_OFFSET(dnft); // Countdown (did not finish timer) -DECL_HUD_OFFSET(speed); // Speedometer -DECL_HUD_OFFSET(posi); // Position in race -DECL_HUD_OFFSET(face); // Mini rankings -DECL_HUD_OFFSET(stcd); // Starting countdown +DECL_HUD_OFFSET(item); // Item box +DECL_HUD_OFFSET(time); // Time +DECL_HUD_OFFSET(laps); // Number of laps +DECL_HUD_OFFSET(dnft); // Countdown (did not finish timer) +DECL_HUD_OFFSET(speed); // Speedometer +DECL_HUD_OFFSET(posi); // Position in race +DECL_HUD_OFFSET(wheel); // RA Wheel +DECL_HUD_OFFSET(face); // Mini rankings +DECL_HUD_OFFSET(stcd); // Starting countdown DECL_HUD_OFFSET_Y(chek); // Check gfx -DECL_HUD_OFFSET(mini); // Minimap -DECL_HUD_OFFSET(want); // Wanted -DECL_HUD_OFFSET(stat); // Stats +DECL_HUD_OFFSET(mini); // Minimap +DECL_HUD_OFFSET(want); // Wanted +DECL_HUD_OFFSET(stat); // Stats #undef DECL_HUD_OFFSET #undef DECL_HUD_OFFSET_X diff --git a/src/k_kart.c b/src/k_kart.c index 533086aaf..a31bc94fb 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -57,18 +57,19 @@ consvar_t cv_##name##_yoffset = {"hud_" #name "_yoffset", "0", CV_SAVE, NULL, NU IMPL_HUD_OFFSET_X(name)\ IMPL_HUD_OFFSET_Y(name) -IMPL_HUD_OFFSET(item); // Item box -IMPL_HUD_OFFSET(time); // Time -IMPL_HUD_OFFSET(laps); // Number of laps -IMPL_HUD_OFFSET(dnft); // Countdown (did not finish timer) -IMPL_HUD_OFFSET(speed); // Speedometer -IMPL_HUD_OFFSET(posi); // Position in race -IMPL_HUD_OFFSET(face); // Mini rankings -IMPL_HUD_OFFSET(stcd); // Starting countdown +IMPL_HUD_OFFSET(item); // Item box +IMPL_HUD_OFFSET(time); // Time +IMPL_HUD_OFFSET(laps); // Number of laps +IMPL_HUD_OFFSET(dnft); // Countdown (did not finish timer) +IMPL_HUD_OFFSET(speed); // Speedometer +IMPL_HUD_OFFSET(posi); // Position in race +IMPL_HUD_OFFSET(wheel); // RA Wheel +IMPL_HUD_OFFSET(face); // Mini rankings +IMPL_HUD_OFFSET(stcd); // Starting countdown IMPL_HUD_OFFSET_Y(chek); // Check gfx -IMPL_HUD_OFFSET(mini); // Minimap -IMPL_HUD_OFFSET(want); // Wanted -IMPL_HUD_OFFSET(stat); // Stats +IMPL_HUD_OFFSET(mini); // Minimap +IMPL_HUD_OFFSET(want); // Wanted +IMPL_HUD_OFFSET(stat); // Stats #undef IMPL_HUD_OFFSET #undef IMPL_HUD_OFFSET_X @@ -8425,6 +8426,7 @@ static void K_DrawKartPositionNum(INT32 num) // POSI_X = BASEVIDWIDTH - 51; // 269 // POSI_Y = BASEVIDHEIGHT- 64; // 136 + const boolean wheeloffs = (cv_showinput.value && cv_posi_xoffset.value == 0 && cv_posi_yoffset.value == 0 && cv_wheel_xoffset.value == 0 && cv_wheel_yoffset.value == 0); boolean win = (stplyr->exiting && num == 1); //INT32 X = POSI_X; INT32 W = SHORT(kp_positionnum[0][0]->width); @@ -8432,7 +8434,7 @@ static void K_DrawKartPositionNum(INT32 num) patch_t *localpatch = kp_positionnum[0][0]; //INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTORIGHT); INT32 fx = 0, fy = 0, fflags = 0; - INT32 xoffs = (cv_showinput.value) ? -48 : 0; + INT32 xoffs = wheeloffs ? -48 : 0; boolean flipdraw = false; // flip the order we draw it in for MORE splitscreen bs. fun. boolean flipvdraw = false; // used only for 2p splitscreen so overtaking doesn't make 1P's position fly off the screen. boolean overtake = false; @@ -8443,7 +8445,7 @@ static void K_DrawKartPositionNum(INT32 num) overtake = true; // this is used for splitscreen stuff in conjunction with flipdraw. } - if (splitscreen || cv_smallposnum.value || cv_showinput.value) + if (splitscreen || cv_smallposnum.value || wheeloffs) scale /= 2; W = FixedMul(W<>FRACBITS; @@ -10254,7 +10256,7 @@ static void K_drawInput(void) static INT32 pn = 0; INT32 target = 0, splitflags = (V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS); - INT32 x = (BASEVIDWIDTH - 32 + cv_posi_xoffset.value)*FRACUNIT, y = (BASEVIDHEIGHT - 24 + cv_posi_yoffset.value)*FRACUNIT; + INT32 x = (BASEVIDWIDTH - 32 + cv_wheel_xoffset.value)*FRACUNIT, y = (BASEVIDHEIGHT - 24 + cv_wheel_yoffset.value)*FRACUNIT; INT32 offs, col; const INT32 accent1 = splitflags|colortranslations[K_GetHudColor()][5]; const INT32 accent2 = splitflags|colortranslations[K_GetHudColor()][9]; diff --git a/src/m_menu.c b/src/m_menu.c index 4fabb778d..9fa7b1945 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2436,13 +2436,17 @@ static menuitem_t OP_HudOffsetMenu[] = {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_mini_xoffset, 120}, {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_mini_yoffset, 125}, - {IT_HEADER, NULL, "Position / R.A. Wheel", NULL, 135}, - {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_posi_xoffset, 140}, - {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_posi_yoffset, 145}, + {IT_HEADER, NULL, "Position Number", NULL, 135}, + {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_wheel_xoffset, 140}, + {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_wheel_yoffset, 145}, - {IT_HEADER, NULL, "Stat Display", NULL, 155}, - {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_stat_xoffset, 160}, - {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_stat_yoffset, 165}, + {IT_HEADER, NULL, "R.A. Wheel", NULL, 155}, + {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_posi_xoffset, 160}, + {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_posi_yoffset, 165}, + + {IT_HEADER, NULL, "Stat Display", NULL, 175}, + {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_stat_xoffset, 180}, + {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_stat_yoffset, 185}, }; static menuitem_t OP_SaturnCreditsMenu[] = From ba5ec70669c38448fdfa933e977838b54c734ced Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 02:00:31 +0100 Subject: [PATCH 172/418] add toggle to colour sneakertrail flames (thx neppy!) --- src/k_kart.c | 14 +++++++++++++- src/k_kart.h | 2 +- src/m_menu.c | 17 ++++++++++------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index a31bc94fb..03eaa4b03 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -75,9 +75,12 @@ IMPL_HUD_OFFSET(stat); // Stats #undef IMPL_HUD_OFFSET_X #undef IMPL_HUD_OFFSET_Y +// extra colourisation stuff static CV_PossibleValue_t colorspeedlines_cons_t[] = {{0, "Off"}, {1, "Normal"}, {2, "+Driftcharge"}, {0, NULL}}; consvar_t cv_coloredspeedlines = {"colorizedspeedlines", "Off", CV_SAVE, colorspeedlines_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_coloredsneakertrail = {"sneakertrailcolor", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + //extra hud things consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -770,7 +773,10 @@ void K_RegisterKartStuff(void) #undef REG_HUD_OFFSET_X #undef REG_HUD_OFFSET_Y + // Colored speedlines CV_RegisterVar(&cv_coloredspeedlines); + // Colored trails + CV_RegisterVar(&cv_coloredsneakertrail); CV_RegisterVar(&cv_showstats); CV_RegisterVar(&cv_showinput); @@ -828,7 +834,6 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_lessflicker); CV_RegisterVar(&cv_mouseturn); - } //} @@ -3500,6 +3505,13 @@ void K_SpawnBoostTrail(player_t *player) flame->angle = travelangle; flame->fuse = TICRATE*2; flame->destscale = player->mo->scale; + + if (cv_coloredsneakertrail.value) + { + flame->colorized = true; + flame->color = player->skincolor; + } + P_SetScale(flame, player->mo->scale); // not K_MatchGenericExtraFlags so that a stolen sneaker can be seen K_FlipFromObject(flame, player->mo); diff --git a/src/k_kart.h b/src/k_kart.h index ac860ab7e..5f0127132 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -22,7 +22,7 @@ boolean K_UseColorHud(void); void K_RegisterKartStuff(void); -extern consvar_t cv_coloredspeedlines; +extern consvar_t cv_coloredspeedlines, cv_coloredsneakertrail; extern consvar_t cv_colorizedhud, cv_colorizeditembox, cv_colorizedhudcolor; extern consvar_t cv_darkitembox; extern consvar_t cv_biglaps; diff --git a/src/m_menu.c b/src/m_menu.c index 9fa7b1945..91855b737 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2232,17 +2232,18 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 20}, {IT_STRING | IT_CVAR, NULL, "Colourized Speedlines", &cv_coloredspeedlines, 30}, + {IT_STRING | IT_CVAR, NULL, "Colourized Sneakertrails", &cv_coloredsneakertrail, 35}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 40}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 45}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 45}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 55}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 55}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 60}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 65}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 70}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 75}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 80}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 90}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 80}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 85}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 95}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -2251,6 +2252,7 @@ static const char* OP_SaturnTooltips[] = "How long can the game wait before it kicks you out from the server\nconnecting screen.", "How much speen do you want?", "Colourize the speedlines in your skincolor if you go fast enough!", + "Colourize the sneaker flame trails in your skincolor!", "Show Localskin Menus.", "Force menu to only use uppercase.", "Use your desired Keyboard Layout for Text Input\nthis is either the Default, Native or Azerty\nNative does not affect Gameplay only Text!", @@ -2266,6 +2268,7 @@ enum sm_waittime, sm_skinselspeed, sm_colorlines, + sm_colorflames, sm_showlocalskin, op_uppercase_menu, sm_nativkey, From af8637f8a4c672e1e2e2c40ab7c92f21e943b12d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 02:27:32 +0100 Subject: [PATCH 173/418] fix having saltyhop disabled forcing player spriteyoffset to be forced 0 just clear out everything on toggle --- src/k_kart.c | 83 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 20 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 03eaa4b03..b1dff759d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -103,10 +103,38 @@ consvar_t cv_newspeedometer = {"newspeedometer", "Default", CV_SAVE, speedo_cons 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}; +static void saltyhop_onchange(void); +consvar_t cv_saltyhop = {"hardcodehop", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, saltyhop_onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_saltyhopsfx = {"hardcodehopsfx", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_saltysquish = {"hardcodehopsquish", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static void saltyhop_onchange(void) +{ + // reset everything when toggling saltyhop off + if (!cv_saltyhop.value && (gamestate == GS_LEVEL)) + { + for (INT32 i = 0; i < MAXPLAYERS; i++) + { + player_t *player = &players[i]; + + if (!playeringame[i] || !player->mo) + continue; + + player->mo->spriteyoffset = 0; + player->mo->spriteyscale = 0; + player->mo->spritexscale = 0; + + player->mo->salty_jump = false; + player->mo->salty_zoffset = 0; + player->mo->salty_momz = 0; + + player->mo->salty_ready = false; + player->mo->salty_tapping = false; + player->mo->init_salty = false; + } + } +} + //Colourized HUD consvar_t cv_colorizedhud = {"colorizedhud", "Off", CV_SAVE|CV_CALL, CV_OnOff, SaturnHud_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_colorizeditembox = {"colorizeditembox", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -3345,38 +3373,55 @@ static void K_StretchPlayerGravity(player_t *p) static void K_QuiteSaltyHop(player_t *p) { + if (!cv_saltyhop.value) + return; + // what the fuck is this haya fixed_t mos = FRACUNIT; // doesnt work correctly if it isnt :/ // ready? - if (!p->kartstuff[k_jmp]) { + if (!p->kartstuff[k_jmp]) + { p->mo->salty_ready = true; p->mo->salty_tapping = false; - } else if (p->mo->salty_ready) { + } + else if (p->mo->salty_ready) + { p->mo->salty_ready = false; p->mo->salty_tapping = true; - } else { + } + else + { p->mo->salty_tapping = false; } // GO! - if (!p->mo->init_salty) { + if (!p->mo->init_salty) + { p->mo->salty_jump = false; p->mo->salty_zoffset = 0; p->mo->salty_momz = 0; p->mo->init_salty = true; } - else if ((p->mo->salty_jump)) { - if (p->mo->eflags & MFE_JUSTHITFLOOR) { + else if ((p->mo->salty_jump)) + { + if (p->mo->eflags & MFE_JUSTHITFLOOR) + { p->mo->salty_zoffset = 0; - } else if (P_IsObjectOnGround(p->mo)) { + } + else if (P_IsObjectOnGround(p->mo)) + { p->mo->salty_zoffset += p->mo->salty_momz; p->mo->salty_momz -= (mos*3/2); - } else { + } + else + { p->mo->salty_zoffset *= (49/50)*mos; p->mo->salty_momz = 0; } - if (p->mo->salty_zoffset <= 0) { + + if (p->mo->salty_zoffset <= 0) + { if (!(p->mo->eflags & MFE_JUSTHITFLOOR) && P_IsObjectOnGround(p->mo) && cv_saltyhopsfx.value) S_StartSound(p->mo, sfx_s268); p->mo->salty_jump = false; @@ -3384,18 +3429,23 @@ static void K_QuiteSaltyHop(player_t *p) p->mo->salty_momz = 0; // shlamma damma p->mo->stretchslam += cv_saltysquish.value ? (8*mos) : 0; - } else if (p->mo->salty_zoffset >= 0 && cv_saltysquish.value) { + } + else if (p->mo->salty_zoffset >= 0 && cv_saltysquish.value) + { // goofy ahh hack p->mo->spriteyscale += (mos/8); p->mo->spritexscale -= (mos/8); } + p->mo->spriteyoffset = p->mo->salty_zoffset; + if (S_SoundPlaying(p->mo, sfx_screec)) S_StopSoundByID(p->mo, sfx_screec); if (S_SoundPlaying(p->mo, sfx_drift)) S_StopSoundByID(p->mo, sfx_drift); } - else if (p->mo->salty_tapping && P_IsObjectOnGround(p->mo) && !p->kartstuff[k_spinouttimer] && !p->kartstuff[k_squishedtimer]) { + else if (p->mo->salty_tapping && P_IsObjectOnGround(p->mo) && !p->kartstuff[k_spinouttimer] && !p->kartstuff[k_squishedtimer]) + { p->mo->salty_jump = true; p->mo->salty_zoffset = 0; p->mo->salty_momz = 6*mos; @@ -6733,14 +6783,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } // salty hop! i wanna die - if (cv_saltyhop.value) - K_QuiteSaltyHop(player); - else { - player->mo->spriteyoffset = 0; - player->mo->salty_jump = false; - player->mo->salty_zoffset = 0; - player->mo->salty_momz = 0; - } + K_QuiteSaltyHop(player); } void K_CalculateBattleWanted(void) From eaad3ebeac96bcac9498e4bb24ebf52e8e11c046 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 03:07:46 +0100 Subject: [PATCH 174/418] oops fix menu stuff --- src/k_kart.c | 23 ++++++++++++----------- src/m_menu.c | 8 ++++---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index b1dff759d..d41f0eae7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -784,18 +784,19 @@ void K_RegisterKartStuff(void) REG_HUD_OFFSET_X(name)\ REG_HUD_OFFSET_Y(name) - REG_HUD_OFFSET(item); // Item box - REG_HUD_OFFSET(time); // Time - REG_HUD_OFFSET(laps); // Number of laps - REG_HUD_OFFSET(dnft); // Countdown (did not finish timer) - REG_HUD_OFFSET(speed); // Speedometer - REG_HUD_OFFSET(posi); // Position in race - REG_HUD_OFFSET(face); // Mini rankings - REG_HUD_OFFSET(stcd); // Starting countdown + REG_HUD_OFFSET(item); // Item box + REG_HUD_OFFSET(time); // Time + REG_HUD_OFFSET(laps); // Number of laps + REG_HUD_OFFSET(dnft); // Countdown (did not finish timer) + REG_HUD_OFFSET(speed); // Speedometer + REG_HUD_OFFSET(posi); // Position in race + REG_HUD_OFFSET(wheel); // Position in race + REG_HUD_OFFSET(face); // Mini rankings + REG_HUD_OFFSET(stcd); // Starting countdown REG_HUD_OFFSET_Y(chek); // Check gfx - REG_HUD_OFFSET(mini); // Minimap - REG_HUD_OFFSET(want); // Wanted - REG_HUD_OFFSET(stat); // Stats + REG_HUD_OFFSET(mini); // Minimap + REG_HUD_OFFSET(want); // Wanted + REG_HUD_OFFSET(stat); // Stats #undef REG_HUD_OFFSET #undef REG_HUD_OFFSET_X diff --git a/src/m_menu.c b/src/m_menu.c index 91855b737..f5008d649 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2440,12 +2440,12 @@ static menuitem_t OP_HudOffsetMenu[] = {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_mini_yoffset, 125}, {IT_HEADER, NULL, "Position Number", NULL, 135}, - {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_wheel_xoffset, 140}, - {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_wheel_yoffset, 145}, + {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_posi_xoffset, 140}, + {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_posi_yoffset, 145}, {IT_HEADER, NULL, "R.A. Wheel", NULL, 155}, - {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_posi_xoffset, 160}, - {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_posi_yoffset, 165}, + {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_wheel_xoffset, 160}, + {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_wheel_yoffset, 165}, {IT_HEADER, NULL, "Stat Display", NULL, 175}, {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_stat_xoffset, 180}, From bef784b32aab57e97bfeab4bbb1b294a68910b27 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 03:51:35 +0100 Subject: [PATCH 175/418] add support for multiitem patches (thx neppy!) needs new patches, unsure if we just gonna add em to the extra file or make a new one so it ambigous for now --- src/d_main.c | 35 +++++++++------- src/d_main.h | 30 ++++++++------ src/k_kart.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++---- src/k_kart.h | 1 + 4 files changed, 145 insertions(+), 35 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 44d1bb9c5..2149d42cf 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1200,19 +1200,22 @@ boolean found_extra_kart; boolean found_extra2_kart; boolean found_extra3_kart; -boolean xtra_speedo; // extra speedometer check -boolean xtra_speedo_clr; // extra speedometer colour check -boolean xtra_speedo3; // 80x 11 extra speedometer check -boolean xtra_speedo_clr3; // 80x 11 extra speedometer colour check -boolean achi_speedo; // achiiro speedometer check -boolean achi_speedo_clr; // extra speedometer colour check -boolean clr_hud; // colour hud check -boolean big_lap; // bigger lap counter -boolean big_lap_color; // bigger lap counter but colour -boolean kartzspeedo; // kartZ speedo -boolean statdp; // stat display for extended player setup -boolean nametaggfx; // Nametag stuffs -boolean driftgaugegfx; +boolean xtra_speedo; // extra speedometer check +boolean xtra_speedo_clr; // extra speedometer colour check +boolean xtra_speedo3; // 80x 11 extra speedometer check +boolean xtra_speedo_clr3; // 80x 11 extra speedometer colour check +boolean achi_speedo; // achiiro speedometer check +boolean achi_speedo_clr; // extra speedometer colour check +boolean kartzspeedo; // kartZ speedo + +boolean clr_hud; // colour hud check +boolean big_lap; // bigger lap counter +boolean big_lap_color; // bigger lap counter but colour +boolean statdp; // stat display for extended player setup +boolean nametaggfx; // Nametag stuffs +boolean driftgaugegfx; // Driftgauge stuffs +boolean multiitem_icon; // Extra icons for Sneakers, Banana and Jawz +// static void IdentifyVersion(void) { @@ -1646,9 +1649,11 @@ void D_SRB2Main(void) nametaggfx = true; if (W_CheckMultipleLumps("K_DGAU","K_DCAU","K_DGSU","K_DCSU", NULL)) - { driftgaugegfx = true; - } + + // extra item icons + if (W_CheckMultipleLumps("K_ITSHO2", "K_ITSHO3", "K_ITBAN2", "K_ITBAN3", "K_ITBAN4", "K_ITJAW2", NULL)) + multiitem_icon = true; if (found_extra3_kart) { diff --git a/src/d_main.h b/src/d_main.h index ddd6c3ab4..397aabdf8 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -27,23 +27,27 @@ extern boolean usehome; //Alam: which path? extern const char *pandf; //Alam: how to path? extern char srb2path[256]; //Alam: SRB2's Home +// extra graphic patches for saturn specific thingies extern boolean found_extra_kart; // for use in k_kart.c extern boolean found_extra2_kart; // for use in k_kart.c extern boolean found_extra3_kart; // for use in k_kart.c -extern boolean xtra_speedo; // extra speedometer check -extern boolean xtra_speedo_clr; // extra speedometer colour check -extern boolean xtra_speedo3; // 80x11 extra speedometer check -extern boolean xtra_speedo_clr3; // 80x11 extra speedometer colour check -extern boolean achi_speedo; // achiiro speedometer check -extern boolean achi_speedo_clr; // extra speedometer colour check -extern boolean clr_hud; // colour hud check -extern boolean big_lap; // bigger lap counter -extern boolean big_lap_color; // bigger lap counter but colour -extern boolean kartzspeedo; // kartZ speedo -extern boolean statdp; // stat display for extended player setup -extern boolean nametaggfx; // Nametag stuffs -extern boolean driftgaugegfx; +extern boolean xtra_speedo; // extra speedometer check +extern boolean xtra_speedo_clr; // extra speedometer colour check +extern boolean xtra_speedo3; // 80x11 extra speedometer check +extern boolean xtra_speedo_clr3; // 80x11 extra speedometer colour check +extern boolean achi_speedo; // achiiro speedometer check +extern boolean achi_speedo_clr; // extra speedometer colour check +extern boolean kartzspeedo; // kartZ speedo + +extern boolean clr_hud; // colour hud check +extern boolean big_lap; // bigger lap counter +extern boolean big_lap_color; // bigger lap counter but colour +extern boolean statdp; // stat display for extended player setup +extern boolean nametaggfx; // Nametag stuffs +extern boolean driftgaugegfx; // Driftgauge stuffs +extern boolean multiitem_icon; // Extra icons for Sneakers, Banana and Jawz +// // autoload stuff extern boolean autoloading; diff --git a/src/k_kart.c b/src/k_kart.c index d41f0eae7..7debc6aa9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -95,9 +95,11 @@ consvar_t cv_showminimapnames = {"showminimapnames", "Off", CV_SAVE, CV_OnOff, N 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 +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_multiitemicon = {"multiitemicon", "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}; consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //toggle for showing the speedometer in battlemode @@ -824,14 +826,16 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_stagetitle); - //Colourized HUD + // Colourized HUD CV_RegisterVar(&cv_colorizedhud); CV_RegisterVar(&cv_colorizedhudcolor); CV_RegisterVar(&cv_colorizeditembox); + CV_RegisterVar(&cv_biglaps); + CV_RegisterVar(&cv_darkitembox); - CV_RegisterVar(&cv_biglaps); + CV_RegisterVar(&cv_multiitemicon); CV_RegisterVar(&cv_highresportrait); @@ -7192,12 +7196,15 @@ static patch_t *kp_itemmulsticker[2]; static patch_t *kp_itemx; static patch_t *kp_sneaker[2]; +static patch_t *kp_multsneaker[2]; static patch_t *kp_rocketsneaker[2]; static patch_t *kp_invincibility[13]; static patch_t *kp_banana[2]; +static patch_t *kp_multbanana[3]; static patch_t *kp_eggman[2]; static patch_t *kp_orbinaut[5]; static patch_t *kp_jawz[2]; +static patch_t *kp_multjawz[1]; static patch_t *kp_mine[2]; static patch_t *kp_ballhog[2]; static patch_t *kp_selfpropelledbomb[2]; @@ -7459,6 +7466,11 @@ void K_LoadKartHUDGraphics(void) kp_itemx = W_CachePatchName("K_ITX", PU_HUDGFX); kp_sneaker[0] = W_CachePatchName("K_ITSHOE", PU_HUDGFX); + if (multiitem_icon) + { + kp_multsneaker[0] = W_CachePatchName("K_ITSHO2", PU_HUDGFX); + kp_multsneaker[1] = W_CachePatchName("K_ITSHO3", PU_HUDGFX); + } kp_rocketsneaker[0] = W_CachePatchName("K_ITRSHE", PU_HUDGFX); sprintf(buffer, "K_ITINVx"); @@ -7467,7 +7479,14 @@ void K_LoadKartHUDGraphics(void) buffer[7] = '1'+i; kp_invincibility[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); } + kp_banana[0] = W_CachePatchName("K_ITBANA", PU_HUDGFX); + if (multiitem_icon) + { + kp_multbanana[0] = W_CachePatchName("K_ITBAN2", PU_HUDGFX); + kp_multbanana[1] = W_CachePatchName("K_ITBAN3", PU_HUDGFX); + kp_multbanana[2] = W_CachePatchName("K_ITBAN4", PU_HUDGFX); + } kp_eggman[0] = W_CachePatchName("K_ITEGGM", PU_HUDGFX); sprintf(buffer, "K_ITORBx"); for (i = 0; i < 4; i++) @@ -7476,6 +7495,10 @@ void K_LoadKartHUDGraphics(void) kp_orbinaut[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); } kp_jawz[0] = W_CachePatchName("K_ITJAWZ", PU_HUDGFX); + if (multiitem_icon) + { + kp_multjawz[0] = W_CachePatchName("K_ITJAW2", PU_HUDGFX); + } kp_mine[0] = W_CachePatchName("K_ITMINE", PU_HUDGFX); kp_ballhog[0] = W_CachePatchName("K_ITBHOG", PU_HUDGFX); kp_selfpropelledbomb[0] = W_CachePatchName("K_ITSPB", PU_HUDGFX); @@ -8042,7 +8065,7 @@ static void K_drawKartItem(void) patch_t *localinv = ((offset) ? kp_invincibility[((leveltime % (6*3)) / 3) + 7] : kp_invincibility[(leveltime % (7*3)) / 3]); INT32 fx = 0, fy = 0, fflags = 0; // final coords for hud and flags... //INT32 splitflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); - const INT32 numberdisplaymin = ((!offset && stplyr->kartstuff[k_itemtype] == KITEM_ORBINAUT) ? 5 : 2); + INT32 numberdisplaymin = 2; // No longer a constant so other things can modify this value INT32 itembar = 0; INT32 maxl = 0; // itembar's normal highest value const INT32 barlength = (splitscreen > 1 ? 12 : 26); @@ -8053,6 +8076,8 @@ static void K_drawKartItem(void) boolean flipamount = splitscreen > 1 && stplyrnum & 1; // Used for 3P/4P splitscreen to flip item amount stuff + const boolean usemultiicon = (multiitem_icon && cv_multiitemicon.value); + if (stplyr->kartstuff[k_itemroulette]) { if (K_GetHudColor()) @@ -8191,57 +8216,132 @@ static void K_drawKartItem(void) switch(stplyr->kartstuff[k_itemtype]) { case KITEM_SNEAKER: - localpatch = kp_sneaker[offset]; + if (usemultiicon) + { + if (offset) + { + numberdisplaymin = 2; + localpatch = kp_sneaker[offset]; + } + else + { + numberdisplaymin = 4; + switch(stplyr->kartstuff[k_itemamount]) + { + case 1: + localpatch = kp_sneaker[offset]; + break; + case 2: + localpatch = kp_multsneaker[0]; + break; + default: + localpatch = kp_multsneaker[1]; + break; + } + } + + } + else + { + numberdisplaymin = 2; + localpatch = kp_sneaker[offset]; + } break; case KITEM_ROCKETSNEAKER: + numberdisplaymin = 2; localpatch = kp_rocketsneaker[offset]; break; case KITEM_INVINCIBILITY: + numberdisplaymin = 2; localpatch = localinv; dark = true; break; case KITEM_BANANA: - localpatch = kp_banana[offset]; + if (usemultiicon) + { + numberdisplaymin = 4; + switch(stplyr->kartstuff[k_itemamount]) + { + case 1: + localpatch = kp_banana[offset]; + break; + case 2: + localpatch = kp_multbanana[0]; + break; + case 10: + localpatch = kp_multbanana[2]; + break; + default: + localpatch = kp_multbanana[1]; + break; + } + } + else + { + numberdisplaymin = 2; + localpatch = kp_banana[offset]; + } break; case KITEM_EGGMAN: + numberdisplaymin = 2; localpatch = kp_eggman[offset]; break; case KITEM_ORBINAUT: + numberdisplaymin = offset ? 2 : 5; localpatch = kp_orbinaut[(offset ? 4 : min(stplyr->kartstuff[k_itemamount]-1, 3))]; break; case KITEM_JAWZ: - localpatch = kp_jawz[offset]; + if (usemultiicon) + { + numberdisplaymin = 3; + localpatch = ((stplyr->kartstuff[k_itemamount] == 1) ? kp_jawz[offset] : kp_multjawz[0]); + } + else + { + numberdisplaymin = 2; + localpatch = kp_jawz[offset]; + } break; case KITEM_MINE: + numberdisplaymin = 2; localpatch = kp_mine[offset]; break; case KITEM_BALLHOG: + numberdisplaymin = 2; localpatch = kp_ballhog[offset]; break; case KITEM_SPB: + numberdisplaymin = 2; localpatch = kp_selfpropelledbomb[offset]; dark = true; break; case KITEM_GROW: + numberdisplaymin = 2; localpatch = kp_grow[offset]; break; case KITEM_SHRINK: + numberdisplaymin = 2; localpatch = kp_shrink[offset]; break; case KITEM_THUNDERSHIELD: + numberdisplaymin = 2; localpatch = kp_thundershield[offset]; dark = true; break; case KITEM_HYUDORO: + numberdisplaymin = 2; localpatch = kp_hyudoro[offset]; break; case KITEM_POGOSPRING: + numberdisplaymin = 2; localpatch = kp_pogospring[offset]; break; case KITEM_KITCHENSINK: + numberdisplaymin = 2; localpatch = kp_kitchensink[offset]; break; case KITEM_SAD: + numberdisplaymin = 2; localpatch = kp_sadface[offset]; break; default: diff --git a/src/k_kart.h b/src/k_kart.h index 5f0127132..fadd369ce 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -31,6 +31,7 @@ extern consvar_t cv_stat_xoffset, cv_stat_yoffset; extern consvar_t cv_showstats; extern consvar_t cv_showlaptimes; extern consvar_t cv_battlespeedo; +extern consvar_t cv_multiitemicon; #define NUMSPEEDOSTUFF 6 extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; From 039018ddc9a781657815414159e042b324879718 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 04:10:11 +0100 Subject: [PATCH 176/418] change banana default patch to match lua roulette hud behaviour --- src/k_kart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7debc6aa9..4ad604361 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8268,11 +8268,11 @@ static void K_drawKartItem(void) case 2: localpatch = kp_multbanana[0]; break; - case 10: - localpatch = kp_multbanana[2]; + case 3: + localpatch = kp_multbanana[1]; break; default: - localpatch = kp_multbanana[1]; + localpatch = kp_multbanana[2]; break; } } From 137be1c7fa0b66b886771a5be3812c8975b7de6f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 17:08:16 +0100 Subject: [PATCH 177/418] slightly cleanup gravstretch stuff --- src/g_game.c | 20 --------- src/k_kart.c | 113 +++++++++++++++++++++++++++++++++++---------------- src/k_kart.h | 2 + 3 files changed, 80 insertions(+), 55 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 28f5f7dfd..7eb92b6bc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -536,26 +536,6 @@ consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS] = { static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}}; consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t stretchfactor_t[] = { - {0, "Off"}, {FRACUNIT/8, "0.125"}, {FRACUNIT/4, "0.250"}, - {3*FRACUNIT/8, "0.375"}, {FRACUNIT/2, "0.500"}, {5*FRACUNIT/8, "0.625"}, - {3*FRACUNIT/4, "0.750"}, {7*FRACUNIT/8, "0.875"}, {FRACUNIT, "Max"}, {0, NULL}}; -consvar_t cv_gravstretch = {"gravstretch", "0", CV_SAVE, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -static CV_PossibleValue_t slamsound_t[] = {{0, "Off"}, {1, "On"}, {0, NULL}}; -consvar_t cv_slamsound = {"slamsound", "1", CV_SAVE, slamsound_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -static CV_PossibleValue_t sloperolldist_cons_t[] = { - /*{256, "256"},*/ {512, "512"}, {768, "768"}, - {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, - {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; -consvar_t cv_sloperolldist = {"sloperolldist", "Infinite", CV_SAVE, sloperolldist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2, "Everything"}, {0, NULL}}; -consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 diff --git a/src/k_kart.c b/src/k_kart.c index 4ad604361..f9ee77958 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -104,6 +104,38 @@ 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 +// funn-E streeetch +static void gravstretch_onchange(void); +static CV_PossibleValue_t stretchfactor_t[] = { + {0, "Off"}, {FRACUNIT/4, "0.250"}, + {3*FRACUNIT/8, "0.375"}, {FRACUNIT/2, "0.500"}, {5*FRACUNIT/8, "0.625"}, + {3*FRACUNIT/4, "0.750"}, {7*FRACUNIT/8, "0.875"}, {FRACUNIT, "Max"}, {0, NULL}}; +consvar_t cv_gravstretch = {"gravstretch", "0", CV_SAVE|CV_CALL|CV_NOINIT, stretchfactor_t, gravstretch_onchange, 0, NULL, NULL, 0, 0, NULL}; + +static void gravstretch_onchange(void) +{ + // reset everything when toggling gravstretch off + if (cv_gravstretch.value == 0) + { + K_ResetPlayerSpriteStuff(); + } +} + +static CV_PossibleValue_t slamsound_t[] = {{0, "Off"}, {1, "On"}, {0, NULL}}; +consvar_t cv_slamsound = {"slamsound", "1", CV_SAVE, slamsound_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +// sprite rotatuer stuff +static CV_PossibleValue_t sloperolldist_cons_t[] = { + {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, + {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; +consvar_t cv_sloperolldist = {"sloperolldist", "Infinite", CV_SAVE, sloperolldist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2, "Everything"}, {0, NULL}}; +consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + //hardcode saltyhop mhhm static void saltyhop_onchange(void); consvar_t cv_saltyhop = {"hardcodehop", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, saltyhop_onchange, 0, NULL, NULL, 0, 0, NULL}; @@ -113,27 +145,9 @@ consvar_t cv_saltysquish = {"hardcodehopsquish", "On", CV_SAVE, CV_OnOff, NULL, static void saltyhop_onchange(void) { // reset everything when toggling saltyhop off - if (!cv_saltyhop.value && (gamestate == GS_LEVEL)) + if (!cv_saltyhop.value) { - for (INT32 i = 0; i < MAXPLAYERS; i++) - { - player_t *player = &players[i]; - - if (!playeringame[i] || !player->mo) - continue; - - player->mo->spriteyoffset = 0; - player->mo->spriteyscale = 0; - player->mo->spritexscale = 0; - - player->mo->salty_jump = false; - player->mo->salty_zoffset = 0; - player->mo->salty_momz = 0; - - player->mo->salty_ready = false; - player->mo->salty_tapping = false; - player->mo->init_salty = false; - } + K_ResetPlayerSpriteStuff(); } } @@ -871,6 +885,34 @@ void K_RegisterKartStuff(void) //} +void K_ResetPlayerSpriteStuff(void) +{ + if (gamestate != GS_LEVEL) + return; + + for (INT32 i = 0; i < MAXPLAYERS; i++) + { + player_t *player = &players[i]; + + if (!playeringame[i] || P_MobjWasRemoved(player->mo)) + continue; + + player->mo->spritexoffset = 0; + player->mo->spriteyoffset = 0; + player->mo->spritexscale = player->mo->realxscale; + player->mo->spriteyscale = player->mo->realyscale; + + // reset saltyhop stuffs too + player->mo->salty_jump = false; + player->mo->salty_zoffset = 0; + player->mo->salty_momz = 0; + + player->mo->salty_ready = false; + player->mo->salty_tapping = false; + player->mo->init_salty = false; + } +} + boolean K_IsPlayerLosing(player_t *player) { INT32 winningpos = 1; @@ -3307,8 +3349,17 @@ static void K_SpawnAIZDust(player_t *player) } } +#define MAXSTRETCHDIV 17476977 + static void K_StretchPlayerGravity(player_t *p) { + if (cv_gravstretch.value == 0) + { + p->mo->spritexscale = p->mo->realxscale; + p->mo->spriteyscale = p->mo->realyscale; + return; + } + I_Assert(p != NULL); I_Assert(p->mo != NULL); I_Assert(!P_MobjWasRemoved(p->mo)); @@ -3316,15 +3367,13 @@ static void K_StretchPlayerGravity(player_t *p) fixed_t mos = FRACUNIT; fixed_t rzs = abs(p->mo->momz); fixed_t zspd = abs(rzs/mos); - fixed_t stretchScaleFactor = 0; - fixed_t rzsDiv = 1; - fixed_t slamDiv = 1; + fixed_t stretchScaleFactor = FixedDiv(FRACUNIT*60, cv_gravstretch.value); + fixed_t rzsDiv, slamDiv; fixed_t dxs = p->mo->realxscale; fixed_t dys = p->mo->realyscale; - stretchScaleFactor = FixedDiv(FRACUNIT*60, cv_gravstretch.value); - if (stretchScaleFactor > 17476977) + if (stretchScaleFactor > MAXSTRETCHDIV) rzsDiv = 0; else rzsDiv = FixedDiv(rzs, stretchScaleFactor); @@ -3334,7 +3383,7 @@ static void K_StretchPlayerGravity(player_t *p) if (p->mo->slamsoundtimer) p->mo->slamsoundtimer--; - if (cv_slamsound.value && (p->mo->eflags & MFE_JUSTHITFLOOR) && p->mo->stretchslam > 4*mos && !p->mo->slamsoundtimer) + if (cv_slamsound.value && (p->mo->eflags & MFE_JUSTHITFLOOR) && !p->mo->slamsoundtimer && (p->mo->stretchslam > 4*mos)) { S_StartSound(p->mo, sfx_s3k4c); p->mo->slamsoundtimer = TICRATE; @@ -3362,7 +3411,7 @@ static void K_StretchPlayerGravity(player_t *p) } else { - if (stretchScaleFactor > 17476977) + if (stretchScaleFactor > MAXSTRETCHDIV) slamDiv = 0; else slamDiv = FixedDiv(p->mo->stretchslam, stretchScaleFactor); @@ -3408,7 +3457,7 @@ static void K_QuiteSaltyHop(player_t *p) p->mo->salty_momz = 0; p->mo->init_salty = true; } - else if ((p->mo->salty_jump)) + else if (p->mo->salty_jump) { if (p->mo->eflags & MFE_JUSTHITFLOOR) { @@ -6667,13 +6716,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->sliproll -= (4*ANG1); } - if (cv_gravstretch.value > 13107) - K_StretchPlayerGravity(player); - else - { - player->mo->spritexscale = player->mo->realxscale; - player->mo->spriteyscale = player->mo->realyscale; - } + K_StretchPlayerGravity(player); if (cv_sloperoll.value && !player->mo->salty_jump) // seeing a character rotate mid-hop looks really janky { diff --git a/src/k_kart.h b/src/k_kart.h index fadd369ce..bbce45a76 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -11,6 +11,8 @@ #define KART_FULLTURN 800 +void K_ResetPlayerSpriteStuff(void); + extern UINT8 colortranslations[MAXTRANSLATIONS][16]; extern const char *KartColor_Names[MAXSKINCOLORS]; extern const UINT8 KartColor_Opposite[MAXSKINCOLORS*2]; From f24ce61cc9ae909a4d22313f8eeab607a54acf41 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 17:22:52 +0100 Subject: [PATCH 178/418] slight cleanup minimap head stuff --- src/k_kart.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f9ee77958..df904a6d4 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9991,7 +9991,7 @@ static void K_drawKartMinimap(void) INT32 i = 0; INT32 x, y; INT32 minimaptrans, splitflags; - SINT8 localplayers[4]; + SINT8 localplayers[MAXSPLITSCREENPLAYERS]; SINT8 numlocalplayers = 0; // Draw the HUD only when playing in a level. @@ -10013,7 +10013,6 @@ static void K_drawKartMinimap(void) y = info.y - (SHORT(minimapinfo.minimap_pic->height)/2); splitflags = info.flags; - if (forceshowhud) minimaptrans = cv_kartminimap.value; else if (timeinmap > 105) @@ -10049,7 +10048,7 @@ static void K_drawKartMinimap(void) y -= SHORT(minimapinfo.minimap_pic->topoffset); // initialize - for (i = 0; i < 4; i++) + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) localplayers[i] = -1; // Player's tiny icons on the Automap. (drawn opposite direction so player 1 is drawn last in splitscreen) @@ -10065,8 +10064,7 @@ static void K_drawKartMinimap(void) if (!stplyr->mo || stplyr->spectator) // do we need the latter..? return; - localplayers[numlocalplayers] = stplyr-players; - numlocalplayers++; + localplayers[numlocalplayers++] = stplyr-players; } else { @@ -10074,31 +10072,29 @@ static void K_drawKartMinimap(void) { if (!playeringame[i]) continue; + if (!players[i].mo || players[i].spectator) continue; - if (i != displayplayers[0] || splitscreen) - { - if (G_BattleGametype() && players[i].kartstuff[k_bumper] <= 0) - continue; - - if (players[i].kartstuff[k_hyudorotimer] > 0) - { - if (!((players[i].kartstuff[k_hyudorotimer] < 1*TICRATE/2 - || players[i].kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)) - && !(leveltime & 1))) - continue; - } - } - if (P_IsDisplayPlayer(&players[i])) { // Draw display players on top of everything else - localplayers[numlocalplayers] = i; - numlocalplayers++; + localplayers[numlocalplayers++] = i; continue; } + // Now we know it's not a display player, handle non-local player exceptions. + if (G_BattleGametype() && players[i].kartstuff[k_bumper] <= 0) + continue; + + if (players[i].kartstuff[k_hyudorotimer] > 0) + { + if (!((players[i].kartstuff[k_hyudorotimer] < 1*TICRATE/2 + || players[i].kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)) + && !(leveltime & 1))) + continue; + } + K_drawKartMinimapHead(players[i].mo, x, y, splitflags); } } @@ -10109,7 +10105,7 @@ static void K_drawKartMinimap(void) for (i = 0; i < numlocalplayers; i++) { - if (i == -1) + if (localplayers[i] == -1) continue; // this doesn't interest us K_drawKartMinimapHead(players[localplayers[i]].mo, x, y, splitflags); } From 3f971fbab172993536bc602f588ce9f32a865b33 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 17:23:21 +0100 Subject: [PATCH 179/418] null check target in P_DamageMobj apparently this may be null --- src/p_inter.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_inter.c b/src/p_inter.c index ce7494ef8..0cbe6577f 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2377,6 +2377,10 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (objectplacing) return false; + // well no clue but this may happen ig + if (!target) + return false; + if (target->health <= 0) return false; @@ -2396,6 +2400,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (!metalrecording) { UINT8 shouldForce = LUA_HookShouldDamage(target, inflictor, source, damage); + if (P_MobjWasRemoved(target)) return (shouldForce == 1); // mobj was removed if (shouldForce == 1) From e320aff5dc52e048c3ac63b0ea1c982ca78d682b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 17:24:50 +0100 Subject: [PATCH 180/418] dont rumble in freecam state --- src/p_tick.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 4a46297c6..c0489d79c 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -399,7 +399,12 @@ static void P_DeviceRumbleTick(void) continue; } - if (player->mo == NULL) + if (camera[i].freecam) + { + continue; + } + + if (P_MobjWasRemoved(player->mo)) { continue; } @@ -638,10 +643,7 @@ void P_Ticker(boolean run) PS_STOP_TIMING(ps_lua_thinkframe_time); } - // Run shield positioning - //P_RunShields(); P_RunOverlays(); - P_RunShadows(); P_UpdateSpecials(); From 26902b4565649019f5d437547a33425141c77d06 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 06:29:17 +0100 Subject: [PATCH 181/418] smol cleanup localskin ranking shit --- src/k_kart.c | 16 +++++----------- src/y_inter.c | 25 ++++++++++--------------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index df904a6d4..c1ab9b053 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8915,7 +8915,6 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I continue; //ignore them. const boolean whiteplayer = _isHighlightedPlayer(&players[pnum]); - const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(players[pnum].skincolor) : 0); if (netgame // don't draw it offline @@ -8931,21 +8930,16 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (players[pnum].mo->color) { - colormap = R_GetTranslationColormap(players[pnum].skin, players[pnum].mo->color, GTC_CACHE); - if (players[pnum].mo->colorized) colormap = R_GetTranslationColormap(TC_RAINBOW, players[pnum].mo->color, GTC_CACHE); else colormap = R_GetTranslationColormap(players[pnum].skin, players[pnum].mo->color, GTC_CACHE); - { - player_t *p; - p = &players[pnum]; - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(p), colormap); - else - V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(p), colormap); - } + if (cv_highresportrait.value) + V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(&players[pnum]), colormap); + else + V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(&players[pnum]), colormap); + /*if (G_BattleGametype() && players[pnum].kartstuff[k_bumper] > 0) -- not enough space for this { INT32 bumperx = x+19; diff --git a/src/y_inter.c b/src/y_inter.c index 985057571..86072e904 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -406,24 +406,19 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) if (standings->color[i] != SKINCOLOR_NONE) { UINT8 *colormap = R_GetTranslationColormap(*standings->character[i], *standings->color[i], GTC_CACHE); + INT32 skinnum = (players[pnum].localskin ? (players[pnum].localskin - 1) : *standings->character[i]); + patch_t *faceprefix = NULL; - // i fucking hate this i fucking hate this i hate this so much if (!players[pnum].skinlocal) - { - int skinIndex = (players[pnum].localskin ? (players[pnum].localskin - 1) : *standings->character[i]); - - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x + 16, y - 4, 0, facewantprefix[skinIndex], colormap); - else - V_DrawMappedPatch(x + 16, y - 4, 0, facerankprefix[skinIndex], colormap); - } + faceprefix = (cv_highresportrait.value ? facewantprefix[skinnum] : facerankprefix[skinnum]); else - { - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x + 16, y - 4, 0, localfacewantprefix[players[pnum].localskin - 1], colormap); - else - V_DrawMappedPatch(x + 16, y - 4, 0, localfacerankprefix[players[pnum].localskin - 1], colormap); - } + faceprefix = (cv_highresportrait.value ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); + + + if (cv_highresportrait.value) + V_DrawSmallMappedPatch(x + 16, y - 4, 0, faceprefix, colormap); + else + V_DrawMappedPatch(x + 16, y - 4, 0, faceprefix, colormap); } if (pnum == whiteplayer) From 67aa31439b0d4d27fe4e0029efdd54d65ca6010a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 17:24:50 +0100 Subject: [PATCH 182/418] dont rumble in freecam state --- src/p_tick.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 8f5454ed6..ba1c8fa91 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -386,7 +386,12 @@ static void P_DeviceRumbleTick(void) continue; } - if (player->mo == NULL) + if (camera[i].freecam) + { + continue; + } + + if (P_MobjWasRemoved(player->mo)) { continue; } @@ -619,10 +624,7 @@ void P_Ticker(boolean run) PS_STOP_TIMING(ps_lua_thinkframe_time); } - // Run shield positioning - //P_RunShields(); P_RunOverlays(); - P_RunShadows(); P_UpdateSpecials(); From 24a93d107a7bbcbaf2e3687bcb4c99ee0c60db48 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 23:04:35 +0100 Subject: [PATCH 183/418] split HWR_RenderBSPNode to reduce function call overhead its only microscopicly faster lel --- src/hardware/hw_main.c | 50 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fb3e71c09..d2b162693 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3118,11 +3118,42 @@ static void HWR_Subsector(size_t num) // Renders all subsectors below a given node, // traversing subtree recursively. // Just call with BSP root. +// static void HWR_RenderBSPNode(INT32 bspnum) { - const node_t *bsp; - INT32 side; + register const node_t *bsp; + register INT32 side; + ps_numbspcalls.value.i++; + + while (!(bspnum & NF_SUBSECTOR)) // Keep going until found a subsector + { + bsp = &nodes[bspnum]; + + // Decide which side the view point is on. + side = R_PointOnSideFast(viewx, viewy, bsp); + + // Recursively divide front space (toward the viewer). + HWR_RenderBSPNode(bsp->children[side]); + + // Possibly divide back space (away from the viewer). + if (!(HWR_CheckBBox(bsp->bbox[side^1]))) + return; + + bspnum = bsp->children[side^1]; + } + + // e6y: support for extended nodes + HWR_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR); +} + +// +// Same thing but with extra portal checks +// +static void HWR_RenderPortalBSPNode(INT32 bspnum) +{ + register const node_t *bsp; + register INT32 side; ps_numbspcalls.value.i++; while (!(bspnum & NF_SUBSECTOR)) // Keep going until found a subsector @@ -3134,7 +3165,7 @@ static void HWR_RenderBSPNode(INT32 bspnum) // Recursively divide front space (toward the viewer). if (HWR_PortalCheckBBox(bsp->bbox[side])) - HWR_RenderBSPNode(bsp->children[side]); + HWR_RenderPortalBSPNode(bsp->children[side]); // Possibly divide back space (away from the viewer). if (!(HWR_CheckBBox(bsp->bbox[side^1]) && HWR_PortalCheckBBox(bsp->bbox[side^1]))) @@ -3144,7 +3175,7 @@ static void HWR_RenderBSPNode(INT32 bspnum) } // PORTAL CULLING - if (portalclipline && portalcullsector) + if (portalcullsector) { // skip all subsectors encountered before the portal // destination's front sector @@ -5262,7 +5293,11 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl validcount++; - HWR_RenderBSPNode((INT32)numnodes-1);// no actual rendering happens + // no actual rendering happens + if (portalclipline) + HWR_RenderPortalBSPNode((INT32)numnodes-1); + else + HWR_RenderBSPNode((INT32)numnodes-1); // for each found portal: // note: if necessary, could sort the portals here? @@ -5313,7 +5348,10 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl HWR_SetPortalState(GLPORTAL_INSIDE); // TURN IT OFF // Recursively "render" the BSP tree. - HWR_RenderBSPNode((INT32)numnodes-1); + if (!portalclipline) + HWR_RenderBSPNode((INT32)numnodes-1); + else + HWR_RenderPortalBSPNode((INT32)numnodes-1); // woo we back HWR_SetPortalState(oldgl_portal_state); From 5a9efff87c7629814ca9c8c1b22123cd0ad21616 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 23:27:44 +0100 Subject: [PATCH 184/418] TEST: skip prepping 3d floors for fofs without planes or if they were already checked --- src/hardware/hw_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d2b162693..d1a404ff0 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2872,6 +2872,12 @@ static void HWR_Subsector(size_t num) { for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + continue; + + if (sub->validcount == validcount) + continue; + sector_t *controlSec = §ors[rover->secnum]; if (controlSec->moved != true) From 509d26f938349b20c700ea3c0471fe97a023ec7a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 00:01:57 +0100 Subject: [PATCH 185/418] forgor about software again --- src/r_bsp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/r_bsp.c b/src/r_bsp.c index 1e5e14547..4562fe202 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -897,6 +897,9 @@ static void R_Subsector(size_t num) { for (rover = frontsector->ffloors; rover; rover = rover->next) { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + continue; + sector_t *controlSec = §ors[rover->secnum]; if (controlSec->moved != true) From 2ef360a7ac012b630fff39bdf29b1b133f20954a Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Fri, 3 Jan 2025 20:12:26 +0100 Subject: [PATCH 186/418] Update to BLUAJIT 449b76f --- src/bluajit/jit/p.lua | 4 +-- src/bluajit/lib_bit.c | 2 +- src/bluajit/lj_asm.c | 4 +-- src/bluajit/lj_bcread.c | 2 +- src/bluajit/lj_record.c | 51 ++++++++++++++++++++++++-------------- src/bluajit/lj_tab.c | 2 +- src/bluajit/luaconf.h | 1 - src/bluajit/vm_mips64.dasc | 5 ++-- 8 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/bluajit/jit/p.lua b/src/bluajit/jit/p.lua index 36f836c51..ef2ee82f5 100644 --- a/src/bluajit/jit/p.lua +++ b/src/bluajit/jit/p.lua @@ -227,9 +227,7 @@ local function prof_finish() local samples = prof_samples if samples == 0 then if prof_raw ~= true then out:write("[No samples collected]\n") end - return - end - if prof_ann then + elseif prof_ann then prof_annotate(prof_count1, samples) else prof_top(prof_count1, prof_count2, samples, "") diff --git a/src/bluajit/lib_bit.c b/src/bluajit/lib_bit.c index ce40e2983..ada9614d0 100644 --- a/src/bluajit/lib_bit.c +++ b/src/bluajit/lib_bit.c @@ -98,7 +98,7 @@ LJLIB_ASM(bit_lshift) LJLIB_REC(bit_shift IR_BSHL) x = lj_carith_shift64(x, sh, curr_func(L)->c.ffid - (int)FF_bit_lshift); return bit_result64(L, id, x); } - if (id2) setintV(L->base+1, sh); + setintV(L->base+1, sh); return FFH_RETRY; #else lj_lib_checknumber(L, 1); diff --git a/src/bluajit/lj_asm.c b/src/bluajit/lj_asm.c index 844910ad9..c31dd1dec 100644 --- a/src/bluajit/lj_asm.c +++ b/src/bluajit/lj_asm.c @@ -949,11 +949,11 @@ static int asm_sunk_store(ASMState *as, IRIns *ira, IRIns *irs) static void asm_snap_alloc1(ASMState *as, IRRef ref) { IRIns *ir = IR(ref); - if (!irref_isk(ref) && ir->r != RID_SUNK) { + if (!irref_isk(ref)) { bloomset(as->snapfilt1, ref); bloomset(as->snapfilt2, hashrot(ref, ref + HASH_BIAS)); if (ra_used(ir)) return; - if (ir->r == RID_SINK) { + if (ir->r == RID_SINK || ir->r == RID_SUNK) { ir->r = RID_SUNK; #if LJ_HASFFI if (ir->o == IR_CNEWI) { /* Allocate CNEWI value. */ diff --git a/src/bluajit/lj_bcread.c b/src/bluajit/lj_bcread.c index 637ef0679..54f483c71 100644 --- a/src/bluajit/lj_bcread.c +++ b/src/bluajit/lj_bcread.c @@ -408,7 +408,7 @@ static int bcread_header(LexState *ls) #endif } if ((flags & BCDUMP_F_STRIP)) { - ls->chunkname = lj_str_newz(ls->L, ls->chunkarg); + ls->chunkname = lj_str_newz(ls->L, *ls->chunkarg == BCDUMP_HEAD1 ? "=?" : ls->chunkarg); } else { MSize len = bcread_uleb128(ls); bcread_need(ls, len); diff --git a/src/bluajit/lj_record.c b/src/bluajit/lj_record.c index 28c725d10..81c4f2635 100644 --- a/src/bluajit/lj_record.c +++ b/src/bluajit/lj_record.c @@ -2084,25 +2084,19 @@ static TRef rec_tnew(jit_State *J, uint32_t ah) typedef struct RecCatDataCP { jit_State *J; - RecordIndex *ix; + BCReg baseslot, topslot; + TRef tr; } RecCatDataCP; static TValue *rec_mm_concat_cp(lua_State *L, lua_CFunction dummy, void *ud) { RecCatDataCP *rcd = (RecCatDataCP *)ud; - UNUSED(L); UNUSED(dummy); - rec_mm_arith(rcd->J, rcd->ix, MM_concat); /* Call __concat metamethod. */ - return NULL; -} - -static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) -{ + jit_State *J = rcd->J; + BCReg baseslot = rcd->baseslot, topslot = rcd->topslot; TRef *top = &J->base[topslot]; - TValue savetv[5+LJ_FR2]; BCReg s; RecordIndex ix; - RecCatDataCP rcd; - int errcode; + UNUSED(L); UNUSED(dummy); lj_assertJ(baseslot < topslot, "bad CAT arg"); for (s = baseslot; s <= topslot; s++) (void)getslot(J, s); /* Ensure all arguments have a reference. */ @@ -2124,7 +2118,10 @@ static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) } while (trp <= top); tr = emitir(IRTG(IR_BUFSTR, IRT_STR), tr, hdr); J->maxslot = (BCReg)(xbase - J->base); - if (xbase == base) return tr; /* Return simple concatenation result. */ + if (xbase == base) { + rcd->tr = tr; /* Return simple concatenation result. */ + return NULL; + } /* Pass partial result. */ topslot = J->maxslot--; *xbase = tr; @@ -2137,13 +2134,31 @@ static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) copyTV(J->L, &ix.tabv, &J->L->base[topslot-1]); ix.tab = top[-1]; ix.key = top[0]; - memcpy(savetv, &J->L->base[topslot-1], sizeof(savetv)); /* Save slots. */ + rec_mm_arith(J, &ix, MM_concat); /* Call __concat metamethod. */ + rcd->tr = 0; /* No result yet. */ + return NULL; +} + +static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) +{ + lua_State *L = J->L; + ptrdiff_t delta = L->top - L->base; + TValue savetv[5+LJ_FR2], errobj; + RecCatDataCP rcd; + int errcode; rcd.J = J; - rcd.ix = &ix; - errcode = lj_vm_cpcall(J->L, NULL, &rcd, rec_mm_concat_cp); - memcpy(&J->L->base[topslot-1], savetv, sizeof(savetv)); /* Restore slots. */ - if (errcode) return (TRef)(-errcode); - return 0; /* No result yet. */ + rcd.baseslot = baseslot; + rcd.topslot = topslot; + memcpy(savetv, &L->base[topslot-1], sizeof(savetv)); /* Save slots. */ + errcode = lj_vm_cpcall(L, NULL, &rcd, rec_mm_concat_cp); + if (errcode) copyTV(L, &errobj, L->top-1); + memcpy(&L->base[topslot-1], savetv, sizeof(savetv)); /* Restore slots. */ + if (errcode) { + L->top = L->base + delta; + copyTV(L, L->top++, &errobj); + return (TRef)(-errcode); + } + return rcd.tr; } /* -- Record bytecode ops ------------------------------------------------- */ diff --git a/src/bluajit/lj_tab.c b/src/bluajit/lj_tab.c index 535a69f5d..869c5f03c 100644 --- a/src/bluajit/lj_tab.c +++ b/src/bluajit/lj_tab.c @@ -635,7 +635,7 @@ LJ_NOINLINE static MSize tab_len_slow(GCtab *t, size_t hi) while ((tv = lj_tab_getint(t, (int32_t)hi)) && !tvisnil(tv)) { lo = hi; hi += hi; - if (hi > (size_t)(INT_MAX-2)) { /* Punt and do a linear search. */ + if (hi > (size_t)(0x7fffffff - 2)) { /* Punt and do a linear search. */ lo = 1; while ((tv = lj_tab_getint(t, (int32_t)lo)) && !tvisnil(tv)) lo++; return (MSize)(lo - 1); diff --git a/src/bluajit/luaconf.h b/src/bluajit/luaconf.h index 669ca8cb1..f59cc1b5f 100644 --- a/src/bluajit/luaconf.h +++ b/src/bluajit/luaconf.h @@ -9,7 +9,6 @@ #ifndef WINVER #define WINVER 0x0501 #endif -#include #include /* Default path for loading Lua and C modules with require(). */ diff --git a/src/bluajit/vm_mips64.dasc b/src/bluajit/vm_mips64.dasc index a8d204137..1f0118ecf 100644 --- a/src/bluajit/vm_mips64.dasc +++ b/src/bluajit/vm_mips64.dasc @@ -1420,9 +1420,10 @@ static void build_subroutines(BuildCtx *ctx) | sltu AT, TMP1, TMP2 | bnez AT, ->fff_fallback |. lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | daddiu NARGS8:RC, NARGS8:RC, -8 - | bltz NARGS8:RC, ->fff_fallback + | daddiu NARGS8:TMP0, NARGS8:RC, -8 + | bltz NARGS8:TMP0, ->fff_fallback |. move TMP2, BASE + | move NARGS8:RC, NARGS8:TMP0 | daddiu BASE, BASE, 16 | // Remember active hook before pcall. | srl TMP3, TMP3, HOOK_ACTIVE_SHIFT From c5fddbbb6935306bb7585835150b4d1c53da9d6a Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Fri, 3 Jan 2025 22:16:11 +0100 Subject: [PATCH 187/418] Use references instead of upvalues for original I/O functions No more unrestricted I/O through debug.getupvalue --- src/lua_baselib.c | 25 ++++++++++++++----------- src/lua_consolelib.c | 8 ++++++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 50660781e..5e21c4096 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -40,6 +40,8 @@ boolean luaL_checkboolean(lua_State *L, int narg) { return lua_toboolean(L, narg); } +static int ref_open, ref_iowrite, ref_fwrite; // original versions of io functions + #define FILELIMIT 1024*1024 // Size limit for reading/writing files static const char *whitelist[] = { // Allow scripters to write files of these types to SRB2's folder @@ -102,7 +104,7 @@ static int lib_open(lua_State *L) lua_pushstring(L, destFilename); lua_replace(L, 1); // now call the real io.open - lua_pushvalue(L, lua_upvalueindex(1)); + lua_rawgeti(L, LUA_REGISTRYINDEX, ref_open); lua_insert(L, 1); lua_call(L, lua_gettop(L)-1, LUA_MULTRET); return lua_gettop(L); @@ -114,8 +116,10 @@ static int lib_write(lua_State *L, int arg) int top = lua_gettop(L); boolean error = true; size_t len, size = 0; + int ogref = ref_iowrite; if (arg != 1) { + ogref = ref_fwrite; FILE *fp = *(FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE); if (fp == NULL) goto call; // real file:write will throw size = ftell(fp); @@ -134,7 +138,7 @@ static int lib_write(lua_State *L, int arg) error = false; call: - lua_pushvalue(L, lua_upvalueindex(1)); + lua_rawgeti(L, LUA_REGISTRYINDEX, ogref); lua_insert(L, 1); lua_call(L, lua_gettop(L)-1, LUA_MULTRET); @@ -3481,25 +3485,24 @@ int LUA_BaseLib(lua_State *L) lua_pop(L, 2); // pop metatable and dummy string // replaces an existing function with another, - // saving the original as an upvalue -#define REPLACE(name, func) \ + // saving the original as a reference +#define REPLACE(name, func, ref) \ lua_pushliteral(L, name); \ lua_rawget(L, -2); \ - lua_pushcclosure(L, &func, 1); \ + ref = luaL_ref(L, LUA_REGISTRYINDEX); \ lua_pushliteral(L, name); \ - lua_pushvalue(L, -2); \ - lua_rawset(L, -4); \ - lua_pop(L, 1); + lua_pushcclosure(L, &func, 0); \ + lua_rawset(L, -3); // replace io.open lua_getglobal(L, "io"); - REPLACE("open", lib_open) - REPLACE("write", lib_write_io) + REPLACE("open", lib_open, ref_open) + REPLACE("write", lib_write_io, ref_iowrite) lua_pop(L, 1); // replace file:write luaL_getmetatable(L, LUA_FILEHANDLE); - REPLACE("write", lib_write_f) + REPLACE("write", lib_write_f, ref_fwrite) lua_pop(L, 1); #undef REPLACE diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 131e5ac1f..12de7fd54 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -329,6 +329,7 @@ static int lib_cvRegisterVar(lua_State *L) const char* category = NULL; const char* menu_name = NULL; boolean hasfunc = false; + int funcref = 0; luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 1); // Clear out all other possible arguments, leaving only the first one. @@ -429,7 +430,9 @@ static int lib_cvRegisterVar(lua_State *L) } else if (i == 5 || (k && fasticmp(k, "func"))) { if (!lua_isfunction(L, 4)) TYPEERROR("func", LUA_TFUNCTION) - lua_setfield(L, LUA_REGISTRYINDEX, "CVFUNC"); + if (hasfunc) + luaL_unref(L, LUA_REGISTRYINDEX, funcref); // real clever, huh? + funcref = luaL_ref(L, LUA_REGISTRYINDEX); hasfunc = true; continue; } @@ -450,10 +453,11 @@ static int lib_cvRegisterVar(lua_State *L) if (hasfunc) { lua_getfield(L, LUA_REGISTRYINDEX, "CV_OnChange"); I_Assert(lua_istable(L, 3)); - lua_getfield(L, LUA_REGISTRYINDEX, "CVFUNC"); + lua_rawgeti(L, LUA_REGISTRYINDEX, funcref); lua_setfield(L, 3, cvar->name); lua_pop(L, 1); cvar->func = Lua_OnChange; + luaL_unref(L, LUA_REGISTRYINDEX, funcref); } lua_getfield(L, LUA_REGISTRYINDEX, "CV_Vars"); From d09d2dcffddde341a07765db76d0b9b9be94d91a Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 13 Jan 2025 07:55:02 +0100 Subject: [PATCH 188/418] this doesent work out breaks some textures not appearing on some maps --- src/r_segs.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 918beb873..c4b46e7f9 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1614,12 +1614,6 @@ static INT64 R_CalcSegDist(seg_t* seg, INT64 x2, INT64 y2) } } -static inline INT32 get_flat_tex (INT32 texnum) -{ - texnum = R_GetTextureNum(texnum); - return textures[texnum]->holes ? 0 : texnum; // R_DrawWallColumn cannot render holey textures -} - // // R_StoreWallRange // A wall segment will be drawn @@ -1875,7 +1869,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) { fixed_t texheight; // single sided line - midtexture = get_flat_tex(sidedef->midtexture); + midtexture = R_GetTextureNum(sidedef->midtexture); texheight = textureheight[midtexture]; // a single sided line is terminal, so it must mark ends markfloor = markceiling = true; @@ -2052,15 +2046,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) { // Special case... use offsets from 2nd side but only if it has a texture. side_t *def = &sides[linedef->sidenum[1]]; - toptexture = get_flat_tex(def->toptexture); + toptexture = R_GetTextureNum(def->toptexture); if (!toptexture) //Second side has no texture, use the first side's instead. - toptexture = get_flat_tex(sidedef->toptexture); + toptexture = R_GetTextureNum(sidedef->toptexture); texheight = textureheight[toptexture]; } else { - toptexture = get_flat_tex(sidedef->toptexture); + toptexture = R_GetTextureNum(sidedef->toptexture); texheight = textureheight[toptexture]; } if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked @@ -2085,7 +2079,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (worldlow > worldbottom || worldlowslope > worldbottomslope) // Only if VISIBLE!!! { // bottom texture - bottomtexture = get_flat_tex(sidedef->bottomtexture); + bottomtexture = R_GetTextureNum(sidedef->bottomtexture); if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked if (linedef->flags & ML_DONTPEGBOTTOM) From b5be515b9b3c3661d64c32b5c0b608e902cf8f96 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 13 Jan 2025 14:25:14 +0300 Subject: [PATCH 189/418] Clear menus when running 'map' command --- src/d_netcmd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 43ad98eb3..c43dd21e8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2709,6 +2709,8 @@ static void Command_Map_f(void) return; } + M_ClearMenus(true); + last_map_cmd = I_GetTime(); size_t first_option; @@ -2901,6 +2903,7 @@ static void Command_Map_f(void) } fromlevelselect = false; + D_MapChange(newmapnum, newgametype, newencoremode, newresetplayers, 0, false, false); Z_Free(realmapname); From 6d1b754db552de3c9d094b43b9c26dcf58b890f0 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 13 Jan 2025 15:50:36 +0100 Subject: [PATCH 190/418] remove this hooklib refactor already indirectly fixed this so this code is pointless --- src/m_menu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index f5008d649..497b99906 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6228,7 +6228,6 @@ static boolean M_AddonsRefresh(void) if ((refreshdirmenu & REFRESHDIR_ADDFILE) || (majormods && !prevmajormods)) { char *message = NULL; - boolean majormodtext = false; if (refreshdirmenu & REFRESHDIR_NOTLOADED) { @@ -6247,10 +6246,10 @@ static boolean M_AddonsRefresh(void) { S_StartSound(NULL, sfx_s221); message = va("%c%s\x80\nYou've loaded a gameplay-modifying addon.\n\nRecord Attack has been disabled, but you\ncan still play alone in local Multiplayer.\n\nIf you wish to play Record Attack mode, restart the game to disable loaded addons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); - majormodtext = prevmajormods = majormods; + prevmajormods = majormods; } - if (message && (refreshdirmenu || majormodtext)) // special case for gameplay modify text + if (message) { M_StartMessage(message,M_AddonsClearName,MM_EVENTHANDLER); return true; From bb7c217ccc63ea26c3b42e573e67fedac19ac905 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 13 Jan 2025 16:37:56 +0100 Subject: [PATCH 191/418] remove "majormods" checks from stuff that saves to savegame so its only there to throw a notice when you load an addon --- src/d_netcmd.c | 8 ++------ src/g_game.c | 12 +++--------- src/m_cond.c | 4 +--- src/m_menu.c | 11 ----------- src/p_setup.c | 4 ++-- src/y_inter.c | 2 +- 6 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b01f87e5a..3a2b90369 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5801,12 +5801,8 @@ static void Fishcake_OnChange(void) */ static void Command_Isgamemodified_f(void) { - if (majormods) - CONS_Printf("The game has been modified with major addons, so you cannot play Record Attack.\n"); - else if (savemoddata) - CONS_Printf("The game has been modified with an addon with its own save data, so you can play Record Attack and earn medals.\n"); - else if (modifiedgame) - CONS_Printf("The game has been modified with only minor addons. You can play Record Attack, earn medals and unlock extras.\n"); + if (majormods || modifiedgame) + CONS_Printf("The game has been modified, Record Attack data will be saved to a seperate savegame.\n"); else CONS_Printf("The game has not been modified. You can play Record Attack, earn medals and unlock extras.\n"); } diff --git a/src/g_game.c b/src/g_game.c index 34c1463cc..76b837dcf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -599,13 +599,12 @@ tic_t G_GetBestTime(INT16 map) return mainrecords[map-1]->time; } -// hack t +// kinda hacky way to do this, but this sets the game to use a seperate savefile if you have addons loaded static void G_SetSaveGameModified(void) { size_t filenamelen; savemoddata = true; - majormods = false; // FIXME: this breaks the menu warning screen from popping up, id still want to use it to mention the diff savefile strlcpy(gamedatafilename, "modkartdata.dat", sizeof (gamedatafilename)); strlwr(gamedatafilename); @@ -638,6 +637,7 @@ void G_SetGameModified(boolean silent, boolean major) //savemoddata = false; -- there is literally no reason to do this anymore. majormods = true; + // should this only be done when you load a "major" gameplay modifieng addon? G_SetSaveGameModified(); if (!silent) @@ -3635,6 +3635,7 @@ void G_SaveGameData(boolean force) INT32 i, j; UINT8 btemp; savebuffer_t save; + (void)force; if (!gamedataloaded) return; // If never loaded (-nodata), don't save @@ -3646,13 +3647,6 @@ void G_SaveGameData(boolean force) return; } - if (majormods && !force) - { - free(save.buffer); - save.p = save.buffer = NULL; - return; - } - // Version test WRITEUINT32(save.p, 0xFCAFE211); diff --git a/src/m_cond.c b/src/m_cond.c index fc33f36c6..f9d871969 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -385,9 +385,7 @@ UINT8 M_UpdateUnlockablesAndExtraEmblems(boolean force) INT32 i; char cechoText[992] = ""; UINT8 cechoLines = 0; - - if (majormods && !force) // SRB2Kart: for enabling unlocks online in modified servers - return false; + (void)force; M_CheckUnlockConditions(); diff --git a/src/m_menu.c b/src/m_menu.c index 36330f1b7..696cffbdd 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4100,17 +4100,6 @@ boolean M_Responder(event_t *ev) if (routine) { - if (((currentMenu->menuitems[itemOn].status & IT_TYPE)==IT_CALL - || (currentMenu->menuitems[itemOn].status & IT_TYPE)==IT_SUBMENU) - && (currentMenu->menuitems[itemOn].status & IT_CALLTYPE)) - { - if (((currentMenu->menuitems[itemOn].status & IT_CALLTYPE) & IT_CALL_NOTMODIFIED) && majormods) - { - S_StartSound(NULL, sfx_menu1); - M_StartMessage(M_GetText("This cannot be done with complex addons\nor in a cheated game.\n\n(Press a key)\n"), NULL, MM_NOTHING); - return true; - } - } S_StartSound(NULL, sfx_menu1); switch (currentMenu->menuitems[itemOn].status & IT_TYPE) { diff --git a/src/p_setup.c b/src/p_setup.c index 3b2ed7714..362cd71d0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -988,7 +988,7 @@ static inline void P_SpawnEmblems(void) static void P_SpawnSecretItems(boolean loademblems) { // Now let's spawn those funky emblem things! Tails 12-08-2002 - if (netgame || multiplayer || majormods) // No cheating!! + if (netgame || multiplayer) // No cheating!! return; if (loademblems) @@ -2976,7 +2976,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) nextmapoverride = 0; skipstats = false; - if (!(netgame || multiplayer) && !majormods) + if (!(netgame || multiplayer)) mapvisited[gamemap-1] |= MV_VISITED; levelloading = false; diff --git a/src/y_inter.c b/src/y_inter.c index 61f4a069b..cce19ad7f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -844,7 +844,7 @@ void Y_StartIntermission(void) } case int_race: // (time-only race) { - if (!majormods && !multiplayer && !demo.playback) // remove this once we have a proper time attack screen + if (!multiplayer && !demo.playback) // remove this once we have a proper time attack screen { // Update visitation flags mapvisited[gamemap-1] |= MV_BEATEN; From e2e356d0c201fb15d9883a7e65f96fec7d0029b9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 13 Jan 2025 16:41:45 +0100 Subject: [PATCH 192/418] save vanilla save when switching to modified savegame also add check so we dont rerun this everytime setgamemodified is called --- src/g_game.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 76b837dcf..7058bd215 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -604,6 +604,12 @@ static void G_SetSaveGameModified(void) { size_t filenamelen; + if (savemoddata) + return; + + // save vanilla data just to be sure + G_SaveGameData(true); + savemoddata = true; strlcpy(gamedatafilename, "modkartdata.dat", sizeof (gamedatafilename)); From cd76cc0e9f6f50c585d9c475f74126d3a0c476b4 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 13 Jan 2025 17:42:22 +0100 Subject: [PATCH 193/418] no need to strcmp just check for "savemoddata" that bool only ever gets set to true if the savegame has been switched to the modded one and unlike in srb2 this WILL never be reset to false again --- src/g_game.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 7058bd215..cc69f3510 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3548,7 +3548,7 @@ void G_LoadGameData(void) } // well no clue but dont think it would like reading garbage from vanilla files - K_ReadStats(&save, strcmp(gamedatafilename, "modkartdata.dat") != 0); + K_ReadStats(&save, !savemoddata); modded = READUINT8(save.p); @@ -3656,7 +3656,7 @@ void G_SaveGameData(boolean force) // Version test WRITEUINT32(save.p, 0xFCAFE211); - K_WriteStats(&save, strcmp(gamedatafilename, "modkartdata.dat") != 0); + K_WriteStats(&save, !savemoddata); btemp = (UINT8)(savemoddata); // what used to be here was profoundly dunderheaded WRITEUINT8(save.p, btemp); From e3adcfb62e5e331d35dbb1ad4b9c79cc60a028f6 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 13 Jan 2025 23:10:56 +0300 Subject: [PATCH 194/418] Player kartstuff's get reset in G_PlayerFinishLevel, so need to call K_StatRound earlier --- src/g_game.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index cc69f3510..52481b948 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3148,6 +3148,8 @@ static void G_DoCompleted(void) if (metalrecording) G_StopMetalRecording(); + K_StatRound(); + for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) { @@ -3174,8 +3176,6 @@ static void G_DoCompleted(void) if (demo.playback) goto demointermission; - K_StatRound(); - // go to next level // nextmap is 0-based, unlike gamemap if (nextmapoverride != 0) From 976c74d69450b826a7914c6bf4e23d2035c7ad3a Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 13 Jan 2025 23:17:51 +0300 Subject: [PATCH 195/418] G_PlayerReborn didn't work for 'respawns' stats, maybe G_DoReborn will? --- src/g_game.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 52481b948..59b5c58e1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2347,9 +2347,6 @@ void G_PlayerReborn(INT32 player) // If NiGHTS, find lowest mare to start with. p->mare = 0; - - if (!demo.playback && p == &players[consoleplayer]) - kartstats.respawns++; } // @@ -2719,6 +2716,9 @@ void G_DoReborn(INT32 playernum) G_SpawnPlayer(playernum, starpost); if (oldmo) G_ChangePlayerReferences(oldmo, players[playernum].mo); + + if (!demo.playback && playernum == consoleplayer) + kartstats.respawns++; } } From 2c3ff3a628a7902be9e927ff3aa1292024eaf0ec Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 15 Jan 2025 11:54:56 +0100 Subject: [PATCH 196/418] dont throw a warning about addons with custom gamedata just ignore it --- src/dehacked.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 6d5b8d4bc..9acf2006b 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2554,9 +2554,10 @@ static void readmaincfg(MYFILE *f) { maxXtraLife = (UINT8)get_number(word2); } - /*else if (fastcmp(word, "GAMEDATA")) + else if (fastcmp(word, "GAMEDATA")) { - size_t filenamelen; + // just ignore it but dont throw a warning + /*size_t filenamelen; // Check the data filename so that mods // can't write arbitrary files. @@ -2580,8 +2581,8 @@ static void readmaincfg(MYFILE *f) // can't use sprintf since there is %u in savegamename strcatbf(savegamename, srb2home, PATHSEP); - refreshdirmenu |= REFRESHDIR_GAMEDATA; - }*/ + refreshdirmenu |= REFRESHDIR_GAMEDATA;*/ + } else if (fastcmp(word, "RESETDATA")) { P_ResetData(value); From 6f7a52a6a6f62229afc88f58568707e6feb6469b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 15 Jan 2025 12:57:35 +0100 Subject: [PATCH 197/418] make freecam strafe be affected by freecamspeed cvar --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index d0cbc9670..698401129 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3511,7 +3511,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (cmd->sidemove != 0) // was disabled in practice anyways, since sidemove was suppressed { //False I fixed this shit - Nep - fixed_t spd = cmd->sidemove*mapobjectscale; + fixed_t spd = cmd->forwardmove*mapobjectscale*cv_freecam_speed.value; thrustangle = (cam->angle-ANGLE_90) >> ANGLETOFINESHIFT; cam->x += FixedMul(spd, FINECOSINE(thrustangle)); From 1db9bcd6c97e62160d27f97dc79488d4ef2c1a0f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 15 Jan 2025 12:59:00 +0100 Subject: [PATCH 198/418] oops --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 698401129..3068e7b67 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3511,7 +3511,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (cmd->sidemove != 0) // was disabled in practice anyways, since sidemove was suppressed { //False I fixed this shit - Nep - fixed_t spd = cmd->forwardmove*mapobjectscale*cv_freecam_speed.value; + fixed_t spd = cmd->sidemove*mapobjectscale*cv_freecam_speed.value; thrustangle = (cam->angle-ANGLE_90) >> ANGLETOFINESHIFT; cam->x += FixedMul(spd, FINECOSINE(thrustangle)); From 66b0931f076c7574177122d2741797b3b20c3ebf Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 15 Jan 2025 21:17:56 +0300 Subject: [PATCH 199/418] Fix spectator control text overlapping when showdirectorhud is off --- src/st_stuff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index d189e2c23..f99c19fd3 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -805,8 +805,8 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); } } } From 64588f8337416d553a63d60005e024f9f041a05c Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 16 Jan 2025 02:47:50 +0300 Subject: [PATCH 200/418] Add spb music to list of exceptions for keepmusic --- src/s_sound.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 7904ae90e..e5585931d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1954,10 +1954,11 @@ boolean S_FadeOutStopMusic(UINT32 ms) static boolean skipmusic = false; boolean skipintromus = false; -static const char *musicexception_list[17] = { +static const char *musicexception_list[] = { "vote", "voteea", "voteeb", "racent", "krwin", "krok", "krlose", "krfail", "kbwin", "kbok", "kblose", "kstart", "estart", "wait2j", "titles", + "SPBA_W", "SPBA_L", // SPB Attack music "CHRSHF", "CHRSHP" // no clue what those are tbh }; @@ -1975,7 +1976,7 @@ static void S_CheckEventMus(const char *newmus) if (!cv_keepmusic.value) return; - for (int i = 0; i < 17; i++) + for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) if (stricmp(music_name, musicexception_list[i]) == 0 || stricmp(newmus, musicexception_list[i]) == 0) // weird? sure! but were lucky enough newmus reflects whats being replaced { skipmusic = true; From e0d6a6ae0f6ad0e1c3978bdc3c6d01abfcbf7386 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 16 Jan 2025 00:57:39 +0100 Subject: [PATCH 201/418] dont keep music if there is no music --- src/s_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index e5585931d..e52e775a6 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2001,7 +2001,7 @@ void S_CheckMap(void) return; } - keepmusic = (!skipmusic && gamestate == GS_LEVEL && oldmap == gamemap && oldencore == encoremode); + keepmusic = (!skipmusic && (gamestate == GS_LEVEL) && (music_name[0] != 0) && (oldmap == gamemap) && (oldencore == encoremode)); //CONS_Printf("keepmusic = %s\n", keepmusic); From 72e72af6b1f207047ca514b4b6f99be24dbb60a6 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 16 Jan 2025 00:58:52 +0100 Subject: [PATCH 202/418] Clear acktosend when initializing node since it was never reset, values might been taken over from former node --- src/d_net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_net.c b/src/d_net.c index c9f80c9ee..6f43147b9 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -639,6 +639,7 @@ void Net_WaitAllAckReceived(UINT32 timeout) static void InitNode(node_t *node) { node->acktosend_head = node->acktosend_tail = 0; + memset(node->acktosend, 0, sizeof(node->acktosend)); node->firstacktosend = 0; node->nextacknum = 1; node->remotefirstack = 0; From 559b0bf45a346a0b24f67c03ea32ee3678141c8d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 15 Jan 2025 12:09:48 +0100 Subject: [PATCH 203/418] also skip invisible fofs --- src/hardware/hw_main.c | 2 +- src/r_bsp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d1a404ff0..8fed8e92d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2872,7 +2872,7 @@ static void HWR_Subsector(size_t num) { for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) continue; if (sub->validcount == validcount) diff --git a/src/r_bsp.c b/src/r_bsp.c index 4562fe202..207d5ffe2 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -897,7 +897,7 @@ static void R_Subsector(size_t num) { for (rover = frontsector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) continue; sector_t *controlSec = §ors[rover->secnum]; From 711660788130f41bdcbef47f64f6d0dd471e672b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 15 Jan 2025 12:57:53 +0100 Subject: [PATCH 204/418] ignore invisible fofs again --- src/hardware/hw_main.c | 5 ++--- src/r_bsp.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8fed8e92d..cd4b0de59 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2947,12 +2947,11 @@ static void HWR_Subsector(size_t num) if (gl_frontsector->ffloors) { /// \todo fix light, xoffs, yoffs, extracolormap ? - for (rover = gl_frontsector->ffloors; - rover; rover = rover->next) + for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { fixed_t bottomCullHeight, topCullHeight, centerHeight; - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) continue; if (sub->validcount == validcount) continue; diff --git a/src/r_bsp.c b/src/r_bsp.c index 207d5ffe2..fac04faf2 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -971,7 +971,7 @@ static void R_Subsector(size_t num) for (rover = frontsector->ffloors; rover && numffloors < MAXFFLOORS; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) continue; if (frontsector->cullheight) From c5a1513cf55b84e85e88fd4e7377fadc1062f054 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 16 Jan 2025 21:58:37 +0100 Subject: [PATCH 205/418] don use multiicon patches in 3/4p splitscreen since it uses the smoler patches also removes redundant assignments --- src/k_kart.c | 49 ++++++++++++------------------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index c1ab9b053..bffc15dc6 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8119,7 +8119,7 @@ static void K_drawKartItem(void) boolean flipamount = splitscreen > 1 && stplyrnum & 1; // Used for 3P/4P splitscreen to flip item amount stuff - const boolean usemultiicon = (multiitem_icon && cv_multiitemicon.value); + const boolean usemultiicon = (multiitem_icon && cv_multiitemicon.value && !offset); if (stplyr->kartstuff[k_itemroulette]) { @@ -8261,41 +8261,29 @@ static void K_drawKartItem(void) case KITEM_SNEAKER: if (usemultiicon) { - if (offset) + numberdisplaymin = 4; + switch(stplyr->kartstuff[k_itemamount]) { - numberdisplaymin = 2; - localpatch = kp_sneaker[offset]; + case 1: + localpatch = kp_sneaker[offset]; + break; + case 2: + localpatch = kp_multsneaker[0]; + break; + default: + localpatch = kp_multsneaker[1]; + break; } - else - { - numberdisplaymin = 4; - switch(stplyr->kartstuff[k_itemamount]) - { - case 1: - localpatch = kp_sneaker[offset]; - break; - case 2: - localpatch = kp_multsneaker[0]; - break; - default: - localpatch = kp_multsneaker[1]; - break; - } - } - } else { - numberdisplaymin = 2; localpatch = kp_sneaker[offset]; } break; case KITEM_ROCKETSNEAKER: - numberdisplaymin = 2; localpatch = kp_rocketsneaker[offset]; break; case KITEM_INVINCIBILITY: - numberdisplaymin = 2; localpatch = localinv; dark = true; break; @@ -8321,12 +8309,10 @@ static void K_drawKartItem(void) } else { - numberdisplaymin = 2; localpatch = kp_banana[offset]; } break; case KITEM_EGGMAN: - numberdisplaymin = 2; localpatch = kp_eggman[offset]; break; case KITEM_ORBINAUT: @@ -8341,50 +8327,39 @@ static void K_drawKartItem(void) } else { - numberdisplaymin = 2; localpatch = kp_jawz[offset]; } break; case KITEM_MINE: - numberdisplaymin = 2; localpatch = kp_mine[offset]; break; case KITEM_BALLHOG: - numberdisplaymin = 2; localpatch = kp_ballhog[offset]; break; case KITEM_SPB: - numberdisplaymin = 2; localpatch = kp_selfpropelledbomb[offset]; dark = true; break; case KITEM_GROW: - numberdisplaymin = 2; localpatch = kp_grow[offset]; break; case KITEM_SHRINK: - numberdisplaymin = 2; localpatch = kp_shrink[offset]; break; case KITEM_THUNDERSHIELD: - numberdisplaymin = 2; localpatch = kp_thundershield[offset]; dark = true; break; case KITEM_HYUDORO: - numberdisplaymin = 2; localpatch = kp_hyudoro[offset]; break; case KITEM_POGOSPRING: - numberdisplaymin = 2; localpatch = kp_pogospring[offset]; break; case KITEM_KITCHENSINK: - numberdisplaymin = 2; localpatch = kp_kitchensink[offset]; break; case KITEM_SAD: - numberdisplaymin = 2; localpatch = kp_sadface[offset]; break; default: From b5d027b37c6ff5bae6977b0be691788d8df7cf6e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 16 Jan 2025 22:33:17 +0100 Subject: [PATCH 206/418] fix typo lel --- src/screen.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/screen.h b/src/screen.h index be8cd9614..000957ed9 100644 --- a/src/screen.h +++ b/src/screen.h @@ -44,7 +44,7 @@ #define BASEVIDWIDTH 320 // NEVER CHANGE THIS! This is the original #define BASEVIDHEIGHT 200 // resolution of the graphics. -// max res for png capture; just here to prevent some crashes on very high resoltions; tho you should never go this high cause ogl allocs certain things with MAXVIDWIDTH and MAXVIDHEIGHT too Zzz... +// max res for png capture; just here to prevent some crashes on very high resolutions; tho you should never go this high cause ogl allocs certain things with MAXVIDWIDTH and MAXVIDHEIGHT too Zzz... #define MAXPNGWIDTH 7680 #define MAXPNGHEIGHT 4320 @@ -94,6 +94,7 @@ typedef struct INT32 vesamode; // vesa mode number plus LINEAR_MODE bit void *plinearmem; // linear address of start of frame buffer } vesa_extra_t; + // a video modes from the video modes list, // note: video mode 0 is always standard VGA320x200. typedef struct vmode_s From adf52e15204c643dcaac88c26c18087296a420d3 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 16 Jan 2025 23:33:18 +0100 Subject: [PATCH 207/418] only rumble banan when on ground --- src/p_tick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index c0489d79c..f35b3f764 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -440,7 +440,7 @@ static void P_DeviceRumbleTick(void) low = high = FRACUNIT / 64; } } - else if (player->kartstuff[k_bananadrag] > TICRATE) + else if (player->kartstuff[k_bananadrag] > TICRATE && P_IsObjectOnGround(player->mo)) { if (leveltime & 1) // this is actually funny lel high = FRACUNIT / 64; From 22b60a07e586c95c806e608f22a5ca7903f8d00e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 18:34:54 +0100 Subject: [PATCH 208/418] le funny banan drag jumpy --- src/k_kart.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index bffc15dc6..beb932f66 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4839,6 +4839,16 @@ static void K_MoveHeldObjects(player_t *player) targz -= 8*(2*FRACUNIT)/7; }*/ + cur->spriteyoffset = 0; + if (P_IsObjectOnGround(player->mo) && player->speed > 0 && player->kartstuff[k_bananadrag] > TICRATE + && M_RandomChance(min(FRACUNIT/2, FixedDiv(player->speed, K_GetKartSpeed(player, false))/2))) + { + if (leveltime & 1) + cur->spriteyoffset += 8*(2*FRACUNIT)/7; + else + cur->spriteyoffset -= 8*(2*FRACUNIT)/7; + } + if (speed > dist) P_InstaThrust(cur, cur->angle, speed-dist); From 7d621b5b1d5a89377ac8a825000c87a6cb2960bd Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 16 Jan 2025 23:42:21 +0100 Subject: [PATCH 209/418] add toggle for bananjitter --- src/k_kart.c | 8 +++++++- src/k_kart.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index beb932f66..25da361cd 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -81,6 +81,8 @@ consvar_t cv_coloredspeedlines = {"colorizedspeedlines", "Off", CV_SAVE, colorsp consvar_t cv_coloredsneakertrail = {"sneakertrailcolor", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_bananajitter = {"bananadragjitter", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + //extra hud things consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -823,6 +825,9 @@ void K_RegisterKartStuff(void) // Colored trails CV_RegisterVar(&cv_coloredsneakertrail); + // makes banans do funny jitter jumpy when dragged + CV_RegisterVar(&cv_bananajitter); + CV_RegisterVar(&cv_showstats); CV_RegisterVar(&cv_showinput); @@ -4840,7 +4845,8 @@ static void K_MoveHeldObjects(player_t *player) }*/ cur->spriteyoffset = 0; - if (P_IsObjectOnGround(player->mo) && player->speed > 0 && player->kartstuff[k_bananadrag] > TICRATE + + if (cv_bananajitter.value && P_IsObjectOnGround(player->mo) && player->speed > 0 && player->kartstuff[k_bananadrag] > TICRATE && M_RandomChance(min(FRACUNIT/2, FixedDiv(player->speed, K_GetKartSpeed(player, false))/2))) { if (leveltime & 1) diff --git a/src/k_kart.h b/src/k_kart.h index bbce45a76..8f85b5b4a 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -25,6 +25,7 @@ boolean K_UseColorHud(void); void K_RegisterKartStuff(void); extern consvar_t cv_coloredspeedlines, cv_coloredsneakertrail; +extern consvar_t cv_bananajitter; extern consvar_t cv_colorizedhud, cv_colorizeditembox, cv_colorizedhudcolor; extern consvar_t cv_darkitembox; extern consvar_t cv_biglaps; From bd489bd462ea731842432c30bc97edb948627db3 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 01:31:12 +0100 Subject: [PATCH 210/418] change how spritescales and offsets work - now theres realoffsets aswell - allows better control of changing things per lua and still do funky stuff in hardcode without conflicts - spritescales and offsets now get reset centralised before any thinkers run --- src/k_kart.c | 63 ++++++++++++++--------------------------------- src/k_kart.h | 1 - src/lua_mobjlib.c | 25 +++++++++++++++++-- src/p_mobj.c | 4 ++- src/p_mobj.h | 2 ++ src/p_saveg.c | 10 +++----- src/p_tick.c | 25 +++++++++++++++++++ 7 files changed, 76 insertions(+), 54 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 25da361cd..3e29ff4ae 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -107,21 +107,11 @@ consvar_t cv_newspeedometer = {"newspeedometer", "Default", CV_SAVE, speedo_cons consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //toggle for showing the speedometer in battlemode // funn-E streeetch -static void gravstretch_onchange(void); static CV_PossibleValue_t stretchfactor_t[] = { {0, "Off"}, {FRACUNIT/4, "0.250"}, {3*FRACUNIT/8, "0.375"}, {FRACUNIT/2, "0.500"}, {5*FRACUNIT/8, "0.625"}, {3*FRACUNIT/4, "0.750"}, {7*FRACUNIT/8, "0.875"}, {FRACUNIT, "Max"}, {0, NULL}}; -consvar_t cv_gravstretch = {"gravstretch", "0", CV_SAVE|CV_CALL|CV_NOINIT, stretchfactor_t, gravstretch_onchange, 0, NULL, NULL, 0, 0, NULL}; - -static void gravstretch_onchange(void) -{ - // reset everything when toggling gravstretch off - if (cv_gravstretch.value == 0) - { - K_ResetPlayerSpriteStuff(); - } -} +consvar_t cv_gravstretch = {"gravstretch", "0", CV_SAVE, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t slamsound_t[] = {{0, "Off"}, {1, "On"}, {0, NULL}}; consvar_t cv_slamsound = {"slamsound", "1", CV_SAVE, slamsound_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -149,7 +139,24 @@ static void saltyhop_onchange(void) // reset everything when toggling saltyhop off if (!cv_saltyhop.value) { - K_ResetPlayerSpriteStuff(); + if (gamestate != GS_LEVEL) + return; + + for (INT32 i = 0; i < MAXPLAYERS; i++) + { + player_t *player = &players[i]; + + if (!playeringame[i] || P_MobjWasRemoved(player->mo)) + continue; + + player->mo->salty_jump = false; + player->mo->salty_zoffset = 0; + player->mo->salty_momz = 0; + + player->mo->salty_ready = false; + player->mo->salty_tapping = false; + player->mo->init_salty = false; + } } } @@ -890,34 +897,6 @@ void K_RegisterKartStuff(void) //} -void K_ResetPlayerSpriteStuff(void) -{ - if (gamestate != GS_LEVEL) - return; - - for (INT32 i = 0; i < MAXPLAYERS; i++) - { - player_t *player = &players[i]; - - if (!playeringame[i] || P_MobjWasRemoved(player->mo)) - continue; - - player->mo->spritexoffset = 0; - player->mo->spriteyoffset = 0; - player->mo->spritexscale = player->mo->realxscale; - player->mo->spriteyscale = player->mo->realyscale; - - // reset saltyhop stuffs too - player->mo->salty_jump = false; - player->mo->salty_zoffset = 0; - player->mo->salty_momz = 0; - - player->mo->salty_ready = false; - player->mo->salty_tapping = false; - player->mo->init_salty = false; - } -} - boolean K_IsPlayerLosing(player_t *player) { INT32 winningpos = 1; @@ -3360,8 +3339,6 @@ static void K_StretchPlayerGravity(player_t *p) { if (cv_gravstretch.value == 0) { - p->mo->spritexscale = p->mo->realxscale; - p->mo->spriteyscale = p->mo->realyscale; return; } @@ -4844,8 +4821,6 @@ static void K_MoveHeldObjects(player_t *player) targz -= 8*(2*FRACUNIT)/7; }*/ - cur->spriteyoffset = 0; - if (cv_bananajitter.value && P_IsObjectOnGround(player->mo) && player->speed > 0 && player->kartstuff[k_bananadrag] > TICRATE && M_RandomChance(min(FRACUNIT/2, FixedDiv(player->speed, K_GetKartSpeed(player, false))/2))) { diff --git a/src/k_kart.h b/src/k_kart.h index 8f85b5b4a..e47b64e2e 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -11,7 +11,6 @@ #define KART_FULLTURN 800 -void K_ResetPlayerSpriteStuff(void); extern UINT8 colortranslations[MAXTRANSLATIONS][16]; extern const char *KartColor_Names[MAXSKINCOLORS]; diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 8cb3ecf98..b006e55e6 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -40,6 +40,7 @@ int mobj_sprev_unimplemented(lua_State *L); int mobj_angle_setter(lua_State *L); int mobj_sloperoll_noop(lua_State *L); int mobj_spritescale_setter(lua_State *L); +int mobj_spriteoffset_setter(lua_State *L); int mobj_touching_sectorlist_unimplemented(lua_State *L); int mobj_radius_setter(lua_State *L); int mobj_height_setter(lua_State *L); @@ -94,8 +95,8 @@ static const udata_field_t mobj_fields[] = { FIELD(mobj_t, anim_duration, udatalib_getter_uint16, udatalib_setter_uint16), FIELD(mobj_t, spritexscale, udatalib_getter_fixed, mobj_spritescale_setter), FIELD(mobj_t, spriteyscale, udatalib_getter_fixed, mobj_spritescale_setter), - FIELD(mobj_t, spritexoffset, udatalib_getter_fixed, udatalib_setter_fixed), - FIELD(mobj_t, spriteyoffset, udatalib_getter_fixed, udatalib_setter_fixed), + FIELD(mobj_t, spritexoffset, udatalib_getter_fixed, mobj_spriteoffset_setter), + FIELD(mobj_t, spriteyoffset, udatalib_getter_fixed, mobj_spriteoffset_setter), FIELD(mobj_t, touching_sectorlist, mobj_touching_sectorlist_unimplemented, mobj_touching_sectorlist_unimplemented), FIELD(mobj_t, lightlevel, udatalib_getter_int16, udatalib_setter_int16), FIELD(mobj_t, subsector, udatalib_getter_subsector, mobj_nosetpos_subsector), @@ -278,6 +279,26 @@ int mobj_spritescale_setter(lua_State *L) return 0; } +int mobj_spriteoffset_setter(lua_State *L) +{ + mobj_t *mo = GETMO(); + + fixed_t *spriteoffset; + UDATALIB_GETFIELD(fixed_t, spriteoffset); + + if (!mo->player) + *spriteoffset = luaL_checkfixed(L, 2); + else + { + // Mmm yea + if (spriteoffset == &mo->spritexoffset) + mo->realxoffset = luaL_checkfixed(L, 2); + else + mo->realyoffset = luaL_checkfixed(L, 2); + } + return 0; +} + int mobj_radius_setter(lua_State *L) { mobj_t *mo = GETMO(); diff --git a/src/p_mobj.c b/src/p_mobj.c index ef1f40ea3..e6359b2b7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9458,7 +9458,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->realxscale = mobj->realyscale = mobj->scale; mobj->spritexscale = mobj->realxscale; mobj->spriteyscale = mobj->realyscale; - mobj->spritexoffset = mobj->spriteyoffset = 0; + mobj->realxoffset = mobj->realyoffset = 0; + mobj->spritexoffset = mobj->realxoffset; + mobj->spriteyoffset = mobj->realyoffset; // Funni slam sound when landing mobj->slamsoundtimer = 0; diff --git a/src/p_mobj.h b/src/p_mobj.h index 0529c4891..d6ad62d91 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -296,6 +296,7 @@ typedef struct mobj_s INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch + fixed_t realxoffset, realyoffset; fixed_t stretchslam; // "squish" effect when you land @@ -449,6 +450,7 @@ typedef struct precipmobj_s INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch + fixed_t realxoffset, realyoffset; fixed_t stretchslam; // "squish" effect when you land diff --git a/src/p_saveg.c b/src/p_saveg.c index 76a363c73..571108ec4 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2147,12 +2147,10 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->mirrored = 0; // Sprite Rendering stuff - mobj->spritexoffset = 0; - mobj->spriteyoffset = 0; - mobj->spritexscale = FRACUNIT; - mobj->spriteyscale = FRACUNIT; - mobj->realxscale = FRACUNIT; - mobj->realyscale = FRACUNIT; + mobj->spritexoffset = mobj->realxoffset = 0; + mobj->spriteyoffset = mobj->realxoffset = 0; + mobj->spritexscale = mobj->realxscale = FRACUNIT; + mobj->spriteyscale = mobj->realyscale = FRACUNIT; mobj->stretchslam = 0; // Timer for slam sound effect diff --git a/src/p_tick.c b/src/p_tick.c index f35b3f764..6fbb50304 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -502,6 +502,29 @@ static void P_RunQuakes(void) --quake.time; } +static inline void P_ResetSpriteStuff(void) +{ + thinker_t *th; + + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + mobj_t *mo; + + if (th->function.acp1 != (actionf_p1)P_MobjThinker) // not a mobj + continue; + + mo = (mobj_t *)th; + + if (mo->type == MT_SHADOW || mo->sprite == SPR_NULL) + continue; + + mo->spritexscale = mo->realxscale; + mo->spriteyscale = mo->realyscale; + mo->spritexoffset = mo->realxoffset; + mo->spriteyoffset = mo->realyoffset; + } +} + // // P_Ticker // @@ -602,6 +625,8 @@ void P_Ticker(boolean run) ps_lua_mobjhooks.value.i = 0; ps_checkposition_calls.value.i = 0; + P_ResetSpriteStuff(); + PS_START_TIMING(ps_lua_prethinkframe_time); LUA_HookPreThinkFrame(); PS_STOP_TIMING(ps_lua_prethinkframe_time); From 49d295535f29fc9b575af17dea3bac4200b9cff6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 12:37:23 +0100 Subject: [PATCH 211/418] add banan jitter toggle to menu --- src/m_menu.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 497b99906..758d027cf 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2234,16 +2234,18 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Colourized Speedlines", &cv_coloredspeedlines, 30}, {IT_STRING | IT_CVAR, NULL, "Colourized Sneakertrails", &cv_coloredsneakertrail, 35}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 45}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 55}, + {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 45}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 60}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 55}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 65}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 70}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 70}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 80}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 85}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 95}, // uwu + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 80}, + + {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 90}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 95}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 105}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -2253,6 +2255,7 @@ static const char* OP_SaturnTooltips[] = "How much speen do you want?", "Colourize the speedlines in your skincolor if you go fast enough!", "Colourize the sneaker flame trails in your skincolor!", + "Makes bananas and other items jump and jitter\nwhen dragged behind.", "Show Localskin Menus.", "Force menu to only use uppercase.", "Use your desired Keyboard Layout for Text Input\nthis is either the Default, Native or Azerty\nNative does not affect Gameplay only Text!", @@ -2269,6 +2272,7 @@ enum sm_skinselspeed, sm_colorlines, sm_colorflames, + sm_bananjumpy, sm_showlocalskin, op_uppercase_menu, sm_nativkey, From 9217cd383279bcc0895e534057190e93f62b7625 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 12:58:26 +0100 Subject: [PATCH 212/418] turn on multiitemicons by default --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 3e29ff4ae..ddedf658f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -100,7 +100,7 @@ consvar_t cv_showlapemblem = {"showlapemblem", "On", CV_SAVE, CV_OnOff, NULL, 0, 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 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_multiitemicon = {"multiitemicon", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_multiitemicon = {"multiitemicon", "ON", 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}; From 75589f977015bde4a94a7a1e447c6beaf61c0dbf Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 17 Jan 2025 15:47:37 +0300 Subject: [PATCH 213/418] Fancy :D --- src/k_kart.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index ddedf658f..b608c6d32 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8394,6 +8394,16 @@ static void K_drawKartItem(void) V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, localbg, cv_colorizeditembox.value ? colormap : NULL); + fixed_t rfy = fy<kartstuff[k_itemroulette]) + { + fixed_t frac = R_UsingFrameInterpolation() ? (rendertimefrac & FRACMASK) : 0; + UINT8 fancystep = (offset ? 6 : 10); + fixed_t fancyoffset = (stplyr->kartstuff[k_itemroulette] % 3)-1; + rfy += (fancystep * fancyoffset * FRACUNIT) + FixedMul(fancystep*FRACUNIT, frac) - fancystep/2*FRACUNIT; + } + // Then, the numbers: if (stplyr->kartstuff[k_itemamount] >= numberdisplaymin && !stplyr->kartstuff[k_itemroulette]) { @@ -8412,7 +8422,7 @@ static void K_drawKartItem(void) } } else - V_DrawFixedPatch(fx< Date: Fri, 17 Jan 2025 13:58:14 +0100 Subject: [PATCH 214/418] dont fancy during respawn --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index b608c6d32..e981e2973 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8396,7 +8396,7 @@ static void K_drawKartItem(void) fixed_t rfy = fy<kartstuff[k_itemroulette]) + if (stplyr->kartstuff[k_itemroulette] && !stplyr->deadtimer) { fixed_t frac = R_UsingFrameInterpolation() ? (rendertimefrac & FRACMASK) : 0; UINT8 fancystep = (offset ? 6 : 10); From ba5e15d29b6fabe89c61fbd5b633a570381c2e45 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 13:58:29 +0100 Subject: [PATCH 215/418] add the fancy hudtrans flags --- src/k_kart.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index e981e2973..ced1fdf59 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8395,12 +8395,18 @@ static void K_drawKartItem(void) V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, localbg, cv_colorizeditembox.value ? colormap : NULL); fixed_t rfy = fy<kartstuff[k_itemroulette] && !stplyr->deadtimer) { fixed_t frac = R_UsingFrameInterpolation() ? (rendertimefrac & FRACMASK) : 0; UINT8 fancystep = (offset ? 6 : 10); fixed_t fancyoffset = (stplyr->kartstuff[k_itemroulette] % 3)-1; + if (fancyoffset != 0) + { + fancyflags &= ~V_HUDTRANS; + fancyflags |=V_HUDTRANSHALF; + } rfy += (fancystep * fancyoffset * FRACUNIT) + FixedMul(fancystep*FRACUNIT, frac) - fancystep/2*FRACUNIT; } @@ -8422,7 +8428,7 @@ static void K_drawKartItem(void) } } else - V_DrawFixedPatch(fx< Date: Fri, 17 Jan 2025 14:12:07 +0100 Subject: [PATCH 216/418] add fancyroulette toggle --- src/k_kart.c | 6 +++++- src/k_kart.h | 1 + src/m_menu.c | 22 +++++++++++++--------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ced1fdf59..4858b2785 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -91,6 +91,8 @@ 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_fancyroulette = {"animatedroulette", "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}; @@ -841,6 +843,8 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_posanim); CV_RegisterVar(&cv_smallposnum); + CV_RegisterVar(&cv_fancyroulette); + CV_RegisterVar(&cv_showlaptimes); CV_RegisterVar(&cv_newspeedometer); @@ -8397,7 +8401,7 @@ static void K_drawKartItem(void) fixed_t rfy = fy<kartstuff[k_itemroulette] && !stplyr->deadtimer) + if (cv_fancyroulette.value && stplyr->kartstuff[k_itemroulette] && !stplyr->deadtimer) { fixed_t frac = R_UsingFrameInterpolation() ? (rendertimefrac & FRACMASK) : 0; UINT8 fancystep = (offset ? 6 : 10); diff --git a/src/k_kart.h b/src/k_kart.h index e47b64e2e..a719eb3e4 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -31,6 +31,7 @@ extern consvar_t cv_biglaps; extern consvar_t cv_highresportrait; extern consvar_t cv_stat_xoffset, cv_stat_yoffset; extern consvar_t cv_showstats; +extern consvar_t cv_fancyroulette; extern consvar_t cv_showlaptimes; extern consvar_t cv_battlespeedo; extern consvar_t cv_multiitemicon; diff --git a/src/m_menu.c b/src/m_menu.c index 758d027cf..333464cbe 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2347,20 +2347,22 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 90}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 100}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 105}, + {IT_STRING | IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 100}, - {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 115}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 120}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 110}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 115}, - {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 130}, + {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 125}, + {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 130}, - {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 140}, + {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 140}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 150}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 155}, + {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 150}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 165}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 160}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 165}, + + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 175}, }; static const char* OP_SaturnHudTooltips[] = @@ -2377,6 +2379,7 @@ static const char* OP_SaturnHudTooltips[] = "Make the Postionnumber half the size.", "Disable the animation of the Positionnumber\nwhen overtaking someone.", "Flash current Lap Time when doing a Lap on the Timer.", + "Enables an animation while the roulette is active.", "Show the big 'LAP' text on a lap change.", "Show the big Cecho Messages.", "Show player names on the minimap.", @@ -2402,6 +2405,7 @@ enum sh_smolpos, sh_posanim, sh_laptime, + sh_fancy, sh_lapemblem, sh_cechotogle, sh_mapname, From 5a03428d769d33a7e716c7ed1bca2952be5732ad Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 14:12:19 +0100 Subject: [PATCH 217/418] use R_GetHudUncap --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 4858b2785..bc201c48a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8403,7 +8403,7 @@ static void K_drawKartItem(void) if (cv_fancyroulette.value && stplyr->kartstuff[k_itemroulette] && !stplyr->deadtimer) { - fixed_t frac = R_UsingFrameInterpolation() ? (rendertimefrac & FRACMASK) : 0; + fixed_t frac = R_GetHudUncap(); UINT8 fancystep = (offset ? 6 : 10); fixed_t fancyoffset = (stplyr->kartstuff[k_itemroulette] % 3)-1; if (fancyoffset != 0) From 625932e8f3673e403dc1b1d1f90c5a5f507e1916 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 14:17:44 +0100 Subject: [PATCH 218/418] cap console animation if uncappedhud is disabled since thats "how vanilla done it" before --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index f36b3b7cb..1f5e28bed 100644 --- a/src/console.c +++ b/src/console.c @@ -608,7 +608,7 @@ static void CON_MoveConsole(void) } // Not instant - Increment fracmovement fractionally - fracmovement += FixedMul(cons_speed.value*vid.fdupy, renderdeltatics); + fracmovement += FixedMul(cons_speed.value*vid.fdupy, (cv_uncappedhud.value ? renderdeltatics : FRACUNIT)); if (con_curlines < con_destlines) // Move the console downwards { From c9d0415d844cbed33344722d00318a24f85cc189 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 14:22:56 +0100 Subject: [PATCH 219/418] "Fix console text bleeding " read https://git.do.srb2.org/STJr/SRB2/-/merge_requests/1434 --- src/console.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/console.c b/src/console.c index 1f5e28bed..3212521b0 100644 --- a/src/console.c +++ b/src/console.c @@ -1466,7 +1466,10 @@ static void CON_DrawHudlines(void) { charflags = (*p & 0x7f) << V_CHARCOLORSHIFT; p++; + c++; } + if (c >= con_width) + break; if (*p < HU_FONTSTART) ;//charwidth = 4 * con_scalefactor; else @@ -1546,7 +1549,10 @@ static void CON_DrawConsole(void) { charflags = (*p & 0x7f) << V_CHARCOLORSHIFT; p++; + c++; } + if (c >= con_width) + break; V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value); } } From f50b19968ce4c19593818e54c32efc067948fb52 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 14:45:35 +0100 Subject: [PATCH 220/418] disable jit compilation for now --- src/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Makefile b/src/Makefile index 515f2d533..09b4f12af 100644 --- a/src/Makefile +++ b/src/Makefile @@ -94,9 +94,12 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... NOUPX=1 NOOBJDUMP=1 + NOBLUAJIT=1 + else # if you on the *nix NOUPX=1 + NOBLUAJIT=1 system:=$(shell uname -s) From 32b54e13465e58c9e2df3bf49884e3111826686b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 15:04:13 +0100 Subject: [PATCH 221/418] merge conflict moment --- src/d_main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 2149d42cf..4d8979307 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -772,7 +772,7 @@ void D_SRB2Loop(void) debugload--; #endif - refreshdirmenu = 0; + refreshdirmenu = 0; // not sure where to put this, here as good as any? interp = (R_UsingFrameInterpolation() && !dedicated); doDisplay = false; @@ -781,8 +781,6 @@ void D_SRB2Loop(void) if (renderisnewtic) { - refreshdirmenu = 0; // not sure where to put this, here as good as any? - // don't skip more than 10 frames at a time // (fadein / fadeout cause massive frame skip!) if (realtics > 8) @@ -866,7 +864,6 @@ void D_SRB2Loop(void) // consoleplayer -> displayplayers (hear sounds from viewpoint) S_UpdateSounds(); // move positional sounds - LUA_Step(); #ifdef HAVE_DISCORDRPC From 004f6d149542b88408da617b343ca6f69da14082 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 16:48:06 +0100 Subject: [PATCH 222/418] Revert "turn on multiitemicons by default" This reverts commit 9217cd383279bcc0895e534057190e93f62b7625. --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index bc201c48a..ce67a32e3 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -102,7 +102,7 @@ consvar_t cv_showlapemblem = {"showlapemblem", "On", CV_SAVE, CV_OnOff, NULL, 0, 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 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_multiitemicon = {"multiitemicon", "ON", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_multiitemicon = {"multiitemicon", "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}; From e82c9a71ec7bca0a3d7fbda05ef889bb915b4a3a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 17:15:00 +0100 Subject: [PATCH 223/418] add toggle for item amount number display --- src/k_kart.c | 25 ++++++++++++++++--------- src/k_kart.h | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ce67a32e3..b4fd0ddcc 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -96,17 +96,19 @@ consvar_t cv_fancyroulette = {"animatedroulette", "Off", CV_SAVE, CV_OnOff, 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_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_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 +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 -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_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_multiitemicon = {"multiitemicon", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t huditemamount_cons_t[] = {{0, "Vanilla"}, {1, "Multiple"}, {1, "Always"},{0, NULL}}; +consvar_t cv_huditemamount = {"showitemamountnumber", "Vanilla", CV_SAVE, huditemamount_cons_t, 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}; -consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //toggle for showing the speedometer in battlemode +consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // toggle for showing the speedometer in battlemode // funn-E streeetch static CV_PossibleValue_t stretchfactor_t[] = { @@ -866,6 +868,7 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_darkitembox); CV_RegisterVar(&cv_multiitemicon); + CV_RegisterVar(&cv_huditemamount); CV_RegisterVar(&cv_highresportrait); @@ -8103,7 +8106,7 @@ static void K_drawKartItem(void) patch_t *localinv = ((offset) ? kp_invincibility[((leveltime % (6*3)) / 3) + 7] : kp_invincibility[(leveltime % (7*3)) / 3]); INT32 fx = 0, fy = 0, fflags = 0; // final coords for hud and flags... //INT32 splitflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); - INT32 numberdisplaymin = 2; // No longer a constant so other things can modify this value + INT32 numberdisplaymin = cv_huditemamount.value == 2 ? 1 : 2; // No longer a constant so other things can modify this value INT32 itembar = 0; INT32 maxl = 0; // itembar's normal highest value const INT32 barlength = (splitscreen > 1 ? 12 : 26); @@ -8256,7 +8259,8 @@ static void K_drawKartItem(void) case KITEM_SNEAKER: if (usemultiicon) { - numberdisplaymin = 4; + if (!cv_huditemamount.value) + numberdisplaymin = 4; switch(stplyr->kartstuff[k_itemamount]) { case 1: @@ -8285,7 +8289,8 @@ static void K_drawKartItem(void) case KITEM_BANANA: if (usemultiicon) { - numberdisplaymin = 4; + if (!cv_huditemamount.value) + numberdisplaymin = 4; switch(stplyr->kartstuff[k_itemamount]) { case 1: @@ -8311,13 +8316,15 @@ static void K_drawKartItem(void) localpatch = kp_eggman[offset]; break; case KITEM_ORBINAUT: - numberdisplaymin = offset ? 2 : 5; + if (!cv_huditemamount.value) + numberdisplaymin = offset ? 2 : 5; localpatch = kp_orbinaut[(offset ? 4 : min(stplyr->kartstuff[k_itemamount]-1, 3))]; break; case KITEM_JAWZ: if (usemultiicon) { - numberdisplaymin = 3; + if (!cv_huditemamount.value) + numberdisplaymin = 3; localpatch = ((stplyr->kartstuff[k_itemamount] == 1) ? kp_jawz[offset] : kp_multjawz[0]); } else diff --git a/src/k_kart.h b/src/k_kart.h index a719eb3e4..bf3f4f71a 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -35,6 +35,7 @@ extern consvar_t cv_fancyroulette; extern consvar_t cv_showlaptimes; extern consvar_t cv_battlespeedo; extern consvar_t cv_multiitemicon; +extern consvar_t cv_huditemamount; #define NUMSPEEDOSTUFF 6 extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; From 2ac48f715a72e28d3700af58ea566988b242edf3 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 19:53:30 +0100 Subject: [PATCH 224/418] :chaosleep: --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index b4fd0ddcc..9289b8ede 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -103,7 +103,7 @@ consvar_t cv_biglaps = {"biglaphud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NUL 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_multiitemicon = {"multiitemicon", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t huditemamount_cons_t[] = {{0, "Vanilla"}, {1, "Multiple"}, {1, "Always"},{0, NULL}}; +static CV_PossibleValue_t huditemamount_cons_t[] = {{0, "Vanilla"}, {1, "Multiple"}, {2, "Always"},{0, NULL}}; consvar_t cv_huditemamount = {"showitemamountnumber", "Vanilla", CV_SAVE, huditemamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; From 633948e8cc64d09fc8e8f59787a355be97427afe Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 23:35:33 +0100 Subject: [PATCH 225/418] ok clang --- src/sdl/ogl_sdl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index df9e527d5..bf2861779 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -290,8 +290,8 @@ void OglSdlFinishUpdate(boolean waitvbl) #if defined (__unix__) #ifdef USE_FBO_OGL - if (loaded_config == true) - xwaylandcrap = false; + if (loaded_config == true) + xwaylandcrap = false; #endif #endif } From 92d6a541aed96c581eefc91d809f97d1e599a0f0 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 23:42:50 +0100 Subject: [PATCH 226/418] add stuff to menu --- src/m_menu.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 333464cbe..d7abc8bbb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2347,22 +2347,24 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 90}, - {IT_STRING | IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 100}, + {IT_STRING | IT_CVAR, NULL, "Multi-Item icons", &cv_multiitemicon, 100}, + {IT_STRING | IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 105}, + {IT_STRING | IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 110}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 110}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 115}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 120}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 125}, - {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 125}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 130}, + {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, + {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 140}, - {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 140}, + {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 150}, - {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 150}, + {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 160}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 160}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 165}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 170}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 175}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 175}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 185}, }; static const char* OP_SaturnHudTooltips[] = @@ -2379,6 +2381,8 @@ static const char* OP_SaturnHudTooltips[] = "Make the Postionnumber half the size.", "Disable the animation of the Positionnumber\nwhen overtaking someone.", "Flash current Lap Time when doing a Lap on the Timer.", + "Use graphics for multiple sneakers, bananas and jawz.", + "Change when the item amount is to be displayed\nMultiple will always display the number\nwhen you have multiple of the same Item\nAlways will always display the number regardless of Item amount.", "Enables an animation while the roulette is active.", "Show the big 'LAP' text on a lap change.", "Show the big Cecho Messages.", @@ -2404,6 +2408,8 @@ enum sh_highresport, sh_smolpos, sh_posanim, + sh_multicon, + sh_itamnum, sh_laptime, sh_fancy, sh_lapemblem, From d5505080cf4b0253b9d23b4754389238f75094de Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jan 2025 23:44:17 +0100 Subject: [PATCH 227/418] change tooltips slightly --- src/m_menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index d7abc8bbb..c18934f11 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2381,8 +2381,8 @@ static const char* OP_SaturnHudTooltips[] = "Make the Postionnumber half the size.", "Disable the animation of the Positionnumber\nwhen overtaking someone.", "Flash current Lap Time when doing a Lap on the Timer.", - "Use graphics for multiple sneakers, bananas and jawz.", - "Change when the item amount is to be displayed\nMultiple will always display the number\nwhen you have multiple of the same Item\nAlways will always display the number regardless of Item amount.", + "Use extra graphics for multiple sneakers, bananas and jawz.", + "Change when the item amount is to be displayed\nMultiple will always display the number.\nwhen you have multiple of the same Item.\nAlways will always display the number regardless of Item amount.", "Enables an animation while the roulette is active.", "Show the big 'LAP' text on a lap change.", "Show the big Cecho Messages.", From d80613f26f8e32576cd17794af545ebec3c3caad Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 18 Jan 2025 11:44:09 +0100 Subject: [PATCH 228/418] forgor to check for that flag --- src/p_tick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index 6fbb50304..8c31e1022 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -515,7 +515,7 @@ static inline void P_ResetSpriteStuff(void) mo = (mobj_t *)th; - if (mo->type == MT_SHADOW || mo->sprite == SPR_NULL) + if (mo->sprite == SPR_NULL || mo->flags2 & MF2_DONTDRAW || mo->type == MT_SHADOW) continue; mo->spritexscale = mo->realxscale; From b816622129bf59974a2b57ba5d48e88b2c21fa18 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 18 Jan 2025 11:45:20 +0100 Subject: [PATCH 229/418] idk why we check this --- src/r_things.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 7b4033bcc..e901302fa 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2858,9 +2858,6 @@ boolean R_ThingVisible (mobj_t *thing) if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) return false; - if (!P_MobjWasRemoved(viewmobj) && (thing == viewmobj)) - return false; - if (splitscreen) { if ((viewssnum == 0 && (thing->eflags & MFE_DRAWONLYFORP1)) From aea8cd1d62ad2424f07c5a273c998c0010f1a7eb Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 18 Jan 2025 14:29:44 +0100 Subject: [PATCH 230/418] refactor weather switching from srb2 makes this more sane and makes PRECIP_STORM_NORAIN not spawn a crapton of invisible mobjs --- src/p_mobj.c | 16 ++------ src/p_spec.c | 103 ++++++++++++++++++--------------------------------- 2 files changed, 41 insertions(+), 78 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index e6359b2b7..91878033f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10244,7 +10244,7 @@ void P_SpawnPrecipitation(void) subsector_t *precipsector = NULL; precipmobj_t *rainmo = NULL; - if (dedicated || !cv_drawdist_precip.value || curWeather == PRECIP_NONE) // SRB2Kart + if (dedicated || !cv_drawdist_precip.value || curWeather == PRECIP_NONE || curWeather == PRECIP_STORM_NORAIN) return; fixed_t density = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); @@ -10298,6 +10298,9 @@ void P_SpawnPrecipitation(void) else // everything else. rainmo = P_SpawnPrecipMobj(x, y, z, MT_RAIN); + if (curWeather == PRECIP_BLANK) + rainmo->precipflags |= PCF_INVISIBLE; + floorz = rainmo->floorz >> FRACBITS; ceilingz = rainmo->ceilingz >> FRACBITS; @@ -10313,17 +10316,6 @@ void P_SpawnPrecipitation(void) } } } - - if (curWeather == PRECIP_BLANK) - { - curWeather = PRECIP_RAIN; - P_SwitchWeather(PRECIP_BLANK); - } - else if (curWeather == PRECIP_STORM_NORAIN) - { - curWeather = PRECIP_RAIN; - P_SwitchWeather(PRECIP_STORM_NORAIN); - } } // diff --git a/src/p_spec.c b/src/p_spec.c index fbbad79ca..f28cf9ae5 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1718,6 +1718,22 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller) } } +static boolean is_rain_type (INT32 weathernum) +{ + switch (weathernum) + { + case PRECIP_SNOW: + case PRECIP_RAIN: + case PRECIP_STORM: + case PRECIP_STORM_NOSTRIKES: + case PRECIP_BLANK: + return true; + + default: + return false; + } +} + // // P_SwitchWeather // @@ -1725,53 +1741,14 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller) // void P_SwitchWeather(INT32 weathernum) { - boolean purge = false; - INT32 swap = 0; + boolean purge = true; - switch (weathernum) - { - case PRECIP_NONE: // None - if (curWeather == PRECIP_NONE) - return; // Nothing to do. - purge = true; - break; - case PRECIP_STORM: // Storm - case PRECIP_STORM_NOSTRIKES: // Storm w/ no lightning - case PRECIP_RAIN: // Rain - if (curWeather == PRECIP_SNOW || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) - swap = PRECIP_RAIN; - break; - case PRECIP_SNOW: // Snow - if (curWeather == PRECIP_SNOW) - return; // Nothing to do. - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) - swap = PRECIP_SNOW; // Need to delete the other precips. - break; - case PRECIP_STORM_NORAIN: // Storm w/o rain - if (curWeather == PRECIP_SNOW - || curWeather == PRECIP_STORM - || curWeather == PRECIP_STORM_NOSTRIKES - || curWeather == PRECIP_RAIN - || curWeather == PRECIP_BLANK) - swap = PRECIP_STORM_NORAIN; - else if (curWeather == PRECIP_STORM_NORAIN) - return; - break; - case PRECIP_BLANK: - if (curWeather == PRECIP_SNOW - || curWeather == PRECIP_STORM - || curWeather == PRECIP_STORM_NOSTRIKES - || curWeather == PRECIP_RAIN) - swap = PRECIP_BLANK; - else if (curWeather == PRECIP_STORM_NORAIN) - swap = PRECIP_BLANK; - else if (curWeather == PRECIP_BLANK) - return; - break; - default: - CONS_Debug(DBG_GAMELOGIC, "P_SwitchWeather: Unknown weather type %d.\n", weathernum); - break; - } + if (weathernum == curWeather) + return; + + if (is_rain_type(weathernum) && + is_rain_type(curWeather)) + purge = false; if (purge) { @@ -1792,7 +1769,7 @@ void P_SwitchWeather(INT32 weathernum) P_FreePrecipMobj(precipmobj); } } - else if (swap && !((swap == PRECIP_BLANK && curWeather == PRECIP_STORM_NORAIN) || (swap == PRECIP_STORM_NORAIN && curWeather == PRECIP_BLANK))) // Rather than respawn all that crap, reuse it! + else // Rather than respawn all that crap, reuse it! { thinker_t *think; precipmobj_t *precipmobj; @@ -1810,17 +1787,16 @@ void P_SwitchWeather(INT32 weathernum) mobjtype_t type = 0; INT32 z = 0; - if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. + if (weathernum == PRECIP_NONE || weathernum == PRECIP_BLANK || weathernum == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. { precipmobj->precipflags |= PCF_INVISIBLE; continue; } - - if (swap == PRECIP_RAIN) // Snow To Rain + else if (weathernum == PRECIP_RAIN || weathernum == PRECIP_STORM || weathernum == PRECIP_STORM_NOSTRIKES) // Snow To Rain { type = MT_RAIN; } - else if (swap == PRECIP_SNOW) // Rain To Snow + else if (weathernum == PRECIP_SNOW) // Rain To Snow { type = MT_SNOWFLAKE; @@ -1850,50 +1826,45 @@ void P_SwitchWeather(INT32 weathernum) } } - boolean dontspawn = false; + boolean spawnprecip = false; switch (weathernum) { case PRECIP_SNOW: // snow curWeather = PRECIP_SNOW; - break; + spawnprecip = true; + break; case PRECIP_RAIN: // rain { - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) - dontspawn = true; - curWeather = PRECIP_RAIN; + spawnprecip = true; break; } case PRECIP_STORM: // storm { - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) - dontspawn = true; - curWeather = PRECIP_STORM; + spawnprecip = true; break; } case PRECIP_STORM_NOSTRIKES: // storm w/o lightning { - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) - dontspawn = true; - curWeather = PRECIP_STORM_NOSTRIKES; + spawnprecip = true; break; } case PRECIP_STORM_NORAIN: // storm w/o rain curWeather = PRECIP_STORM_NORAIN; break; - case PRECIP_BLANK: + case PRECIP_BLANK: //preloaded curWeather = PRECIP_BLANK; - break; + spawnprecip = true; + break; default: - dontspawn = true; curWeather = PRECIP_NONE; break; } - if (!dontspawn && !swap) + if (spawnprecip && purge) P_SpawnPrecipitation(); } From c1df939ac829fb53e2371e4bb1223735bc19bea2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 18 Jan 2025 14:36:35 +0100 Subject: [PATCH 231/418] use MT_NULL instead of number --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index f28cf9ae5..539276a19 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1784,8 +1784,8 @@ void P_SwitchWeather(INT32 weathernum) precipmobj = (precipmobj_t *)think; - mobjtype_t type = 0; INT32 z = 0; + mobjtype_t type = MT_NULL; if (weathernum == PRECIP_NONE || weathernum == PRECIP_BLANK || weathernum == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. { From 4ff8b869db49eff247566057d8933be666be535b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 18 Jan 2025 21:24:47 +0100 Subject: [PATCH 232/418] fix "lessprecip" logic error lul --- src/p_mobj.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 91878033f..6c82efa71 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10239,28 +10239,26 @@ consvar_t cv_suddendeath = {"suddendeath", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHE void P_SpawnPrecipitation(void) { - INT32 i, mrand; - fixed_t basex, basey, j, x, y, z; + INT32 i, j, mrand; + fixed_t basex, basey, x, y, z; subsector_t *precipsector = NULL; precipmobj_t *rainmo = NULL; if (dedicated || !cv_drawdist_precip.value || curWeather == PRECIP_NONE || curWeather == PRECIP_STORM_NORAIN) return; - fixed_t density = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); - - if (cv_lessprecip.value) - density *= 2; // just spawn half the precip + const fixed_t precipmoscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); + const INT32 density = (cv_lessprecip.value ? 2 : 1); // only spawn half as much // Use the blockmap to narrow down our placing patterns - for (i = 0; i < bmapwidth*bmapheight; ++i) + for (i = 0; i < bmapwidth*bmapheight; i += density) { basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE; basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE; // If mobjscale < FRACUNIT, each blockmap cell covers // more area so spawn more precipitation in that area. - for (j = 0; j < FRACUNIT; j += density) + for (j = 0; j < FRACUNIT; j += precipmoscale) { INT32 floorz; INT32 ceilingz; From 9305b0a2875f6c77a71c3e407d24080fe088312b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 18 Jan 2025 21:35:22 +0100 Subject: [PATCH 233/418] ; moment --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 6c82efa71..759b012ee 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11630,7 +11630,7 @@ ML_NOCLIMB : Direction not controllable mobj_t *elecmobj; elecmobj = P_SpawnMobj(x, y, z, MT_CYBRAKDEMON_ELECTRIC_BARRIER); P_SetTarget(&elecmobj->target, mobj); - elecmobj->angle = FixedAngle(mthing->angle*FRACUNIT);; + elecmobj->angle = FixedAngle(mthing->angle*FRACUNIT); elecmobj->destscale = mobj->scale*2; P_SetScale(elecmobj, elecmobj->destscale); } From 232790836bdd03d6d8a401ecc5a0416bad4a6f1c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 19 Jan 2025 00:03:46 +0100 Subject: [PATCH 234/418] remove some code dupe in R_AddLine --- src/r_bsp.c | 80 +++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 46 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index fac04faf2..44ceb63f4 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -423,7 +423,7 @@ static void R_AddLine(seg_t *line) span = angle1 - angle2; // Back side? i.e. backface culling? - if (span >= ANGLE_180) + if (span >= ANGLE_180 || !line->linedef) return; // Global angle needed by segcalc. @@ -494,11 +494,12 @@ static void R_AddLine(seg_t *line) doorclosed = 0; + fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends + fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends + // Closed door. if (frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope) { - fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends - fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends #define SLOPEPARAMS(slope, end1, end2, normalheight) \ if (slope) { \ end1 = P_GetZAt(slope, line->v1->x, line->v1->y); \ @@ -511,57 +512,44 @@ static void R_AddLine(seg_t *line) SLOPEPARAMS( backsector->f_slope, backf1, backf2, backsector->floorheight) SLOPEPARAMS( backsector->c_slope, backc1, backc2, backsector->ceilingheight) #undef SLOPEPARAMS - if (viewsector != backsector && viewsector != frontsector) - { - if ((backc1 <= frontf1 && backc2 <= frontf2) - || (backf1 >= frontc1 && backf2 >= frontc2)) - { - goto clipsolid; - } - - // Check for automap fix. Store in doorclosed for r_segs.c - doorclosed = (backc1 <= backf1 && backc2 <= backf2 - && ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture) - && ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture) - && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum)); - - if (doorclosed) - goto clipsolid; - } - - // Window. - if (backc1 != frontc1 || backc2 != frontc2 - || backf1 != frontf1 || backf2 != frontf2) - { - goto clippass; - } } else { - if (viewsector != backsector && viewsector != frontsector) + frontf1 = frontf2 = frontsector->floorheight; + frontc1 = frontc2 = frontsector->ceilingheight; + backf1 = backf2 = backsector->floorheight; + backc1 = backc2 = backsector->ceilingheight; + } + + if (viewsector != backsector && viewsector != frontsector) + { + // here we're talking about a CEILING lower than a floor. ...yeah we don't even need to bother. + if (backc1 <= frontf1 && backc2 <= frontf2) { - if (backsector->ceilingheight <= frontsector->floorheight - || backsector->floorheight >= frontsector->ceilingheight) - { - goto clipsolid; - } - - // Check for automap fix. Store in doorclosed for r_segs.c - doorclosed = (backsector->ceilingheight <= backsector->floorheight - && (backsector->ceilingheight >= frontsector->ceilingheight || curline->sidedef->toptexture) - && (backsector->floorheight <= frontsector->floorheight || curline->sidedef->bottomtexture) - && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum)); - - if (doorclosed) - goto clipsolid; + goto clipsolid; } - // Window. - if (backsector->ceilingheight != frontsector->ceilingheight - || backsector->floorheight != frontsector->floorheight) + // here we're talking about floors higher than ceilings, don't even bother either. + if (backf1 >= frontc1 && backf2 >= frontc2) { - goto clippass; + goto clipsolid; } + + // Check for automap fix. Store in doorclosed for r_segs.c + doorclosed = (backc1 <= backf1 && backc2 <= backf2 + && ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture) + && ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture) + && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum)); + + if (doorclosed) + goto clipsolid; + } + + // Window. + if (backc1 != frontc1 || backc2 != frontc2 + || backf1 != frontf1 || backf2 != frontf2) + { + goto clippass; } // Reject empty lines used for triggers and special events. From 7991dafe644d34afb5bd2d338d1aa35dd9430b6c Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 19 Jan 2025 02:28:16 +0300 Subject: [PATCH 235/418] Make custom stats fully compatible between different versions, so new fields can be added in future without save corruptions --- src/k_stats.c | 98 +++++++++++++++++++++++++++++++++++++++++++-------- src/k_stats.h | 10 ++++++ 2 files changed, 94 insertions(+), 14 deletions(-) diff --git a/src/k_stats.c b/src/k_stats.c index 9b0c409df..590d3b8df 100644 --- a/src/k_stats.c +++ b/src/k_stats.c @@ -2,6 +2,7 @@ #include "doomstat.h" #include "g_game.h" #include "byteptr.h" +#include "z_zone.h" kartstats_t kartstats = {0}; @@ -65,6 +66,8 @@ void K_StatRound(void) if (demo.playback) return; + kartstats.somenewfield = 42; + int numplayers = 0; for (int i = 0; i < MAXPLAYERS; ++i) @@ -87,23 +90,18 @@ void K_EraseStats(void) // The only field we want to remember boolean vanilla = kartstats.vanilla; + if (kartstats.copy) + Z_Free(kartstats.copy); + memset(&kartstats, 0, sizeof(kartstats_t)); kartstats.vanilla = vanilla; } -void K_ReadStats(savebuffer_t *save, boolean vanilla) +static void K_ReadStatsCustom(savebuffer_t *save) { - memset(&kartstats, 0, sizeof(kartstats_t)); - - kartstats.vanilla = vanilla; - - kartstats.totalplaytime = READUINT32(save->p); - kartstats.matchesplayed = READUINT32(save->p); - - // Vanilla only has those 2 - if (vanilla) - return; + kartstats.size = READUINT32(save->p); + kartstats.version = READUINT32(save->p); // So many similar-looking read's... scary... kartstats.raplaytime = READUINT32(save->p); @@ -119,17 +117,51 @@ void K_ReadStats(savebuffer_t *save, boolean vanilla) kartstats.sinks = READUINT32(save->p); kartstats.sinked = READUINT32(save->p); kartstats.respawns = READUINT32(save->p); + + // If kartstats gets updated, uncomment this and read next fields after this early return. Do same on next updates, + // this way even data is read on different versions, it doesn't get corrupted (as long as fields aren't removed, which shouldn't happen) + //if (kartstats.version < 2) + // return; + // + //kartstats.somenewfield = READUINT32(save->p); } -void K_WriteStats(savebuffer_t *save, boolean vanilla) +void K_ReadStats(savebuffer_t *save, boolean vanilla) { - WRITEUINT32(save->p, kartstats.totalplaytime); - WRITEUINT32(save->p, kartstats.matchesplayed); + // Basically, free old kartstats.copy if needed and memset kartstats with zeros + K_EraseStats(); + + kartstats.vanilla = vanilla; + + kartstats.totalplaytime = READUINT32(save->p); + kartstats.matchesplayed = READUINT32(save->p); // Vanilla only has those 2 if (vanilla) return; + // Save where block of custom stats starts + UINT8 *customblockstart = save->p; + + K_ReadStatsCustom(save); + + // Make a copy of entire custom stats block, so unread values will still be written back + kartstats.copy = Z_Malloc(kartstats.size, PU_STATIC, NULL); + memcpy(kartstats.copy, customblockstart, kartstats.size); + + // If there were extra fields we couldn't read, skip them + save->p = customblockstart + kartstats.size; +} + +static void K_WriteStatsCustom(savebuffer_t *save) +{ + // Update, if needed + kartstats.version = max(kartstats.version, KARTSTATSVERSION); + + WRITEUINT32(save->p, kartstats.size); // Note: if we will end up writing more that stored in there, this field in save file would be updated + WRITEUINT32(save->p, kartstats.version); + + // Version 1 WRITEUINT32(save->p, kartstats.raplaytime); WRITEUINT32(save->p, kartstats.onlineplaytime); WRITEUINT32(save->p, kartstats.raceplaytime); @@ -143,4 +175,42 @@ void K_WriteStats(savebuffer_t *save, boolean vanilla) WRITEUINT32(save->p, kartstats.sinks); WRITEUINT32(save->p, kartstats.sinked); WRITEUINT32(save->p, kartstats.respawns); + + // No need for early returns, but please mark each new block of write's with version it corresponds to :3 + + // Version 2 + //WRITEUINT32(save->p, kartstats.somenewfield); +} + +void K_WriteStats(savebuffer_t *save, boolean vanilla) +{ + WRITEUINT32(save->p, kartstats.totalplaytime); + WRITEUINT32(save->p, kartstats.matchesplayed); + + // Vanilla only has those 2 + if (vanilla) + return; + + // Now need to be careful... We save start of custom stats block + UINT8 *customblockstart = save->p; + + // Write everything we know how to write + K_WriteStatsCustom(save); + + // Calculate size of data that we wrote + UINT32 size = (UINT32)(save->p - customblockstart); + + // Now, if we wrote less data than save originally had, that means our copy that we kept in K_ReadStats + // has stats from newer version that we need to append + if (size < kartstats.size) + { + I_Assert(kartstats.copy != NULL); // If kartstats.copy is null, kartstats.size **always** should be 0, this can only happen if we create new save + WRITEMEM(save->p, kartstats.copy + size, kartstats.size - size); + } + else if (size > kartstats.size) // No need to do anything if we wrote exactly same amount... + { + // ...but, if we wrote more, we need to update size field in header. **It's always located at start of block** + // So we can just: + WRITEUINT32(customblockstart, size); + } } diff --git a/src/k_stats.h b/src/k_stats.h index 87a173653..bd145de56 100644 --- a/src/k_stats.h +++ b/src/k_stats.h @@ -5,6 +5,8 @@ #include "d_player.h" #include "p_saveg.h" +#define KARTSTATSVERSION 1 + typedef struct kartstats_s { // Remember if stats we loaded are vanilla ones or not boolean vanilla; @@ -13,6 +15,12 @@ typedef struct kartstats_s { tic_t totalplaytime; UINT32 matchesplayed; + // Custom data, fields go in same order as they are written into game save + + // IMPORTANT: size **must be first**, so K_WriteStats can overwrite it (not that we're gonna change order, but just in case) + UINT32 size; // Size required for our stats. If older version reads save from newer one, it will just skip unread fields, avoiding reading corrupted values + UINT32 version; // Version, so we know which fields we actually can read + tic_t raplaytime; tic_t onlineplaytime; tic_t raceplaytime; @@ -26,6 +34,8 @@ typedef struct kartstats_s { UINT32 sinks; // Times hitting *others* by kitchen sink UINT32 sinked; // Times *being hit* by kitchen sink UINT32 respawns; + + UINT8 *copy; // Copy of stats block that has been read from file. In case we're older version that reads newer save, we will keep values that we couldn't read } kartstats_t; extern kartstats_t kartstats; From 7260c2c77ecdb753bd127cd1797a96034f5d2f35 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 19 Jan 2025 02:29:41 +0300 Subject: [PATCH 236/418] That was from testing a --- src/k_stats.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/k_stats.c b/src/k_stats.c index 590d3b8df..0af547780 100644 --- a/src/k_stats.c +++ b/src/k_stats.c @@ -66,8 +66,6 @@ void K_StatRound(void) if (demo.playback) return; - kartstats.somenewfield = 42; - int numplayers = 0; for (int i = 0; i < MAXPLAYERS; ++i) From 8ceda27817330d6ed938fb23606c9cb0c57e62b5 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 19 Jan 2025 02:43:18 +0300 Subject: [PATCH 237/418] Wipe kart stats on game data reload --- src/g_game.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_game.c b/src/g_game.c index 59b5c58e1..b644e2796 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3519,6 +3519,7 @@ void G_LoadGameData(void) // to new gamedata G_ClearRecords(); // main and nights records M_ClearSecrets(); // emblems, unlocks, maps visited, etc + K_EraseStats(); // stats if (M_CheckParm("-nodata")) return; // Don't load. From c589d04a324ca3bf66ce221cb3bc98631f5eb0b9 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 19 Jan 2025 02:55:39 +0300 Subject: [PATCH 238/418] New statistics menu (WIP) --- src/m_menu.c | 170 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 133 insertions(+), 37 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 696cffbdd..d9bc816f8 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8605,9 +8605,28 @@ static void M_Credits(INT32 choice) // STATISTICS MENU // =============== +static void M_DrawStatsMaps(void); +static void M_DrawStatsPlaytime(void); +static void M_DrawStatsExtra(void); // dunno how to name this one + static INT32 statsLocation; static INT32 statsMax; static INT16 statsMapList[NUMMAPS+1]; +static UINT8 statsCurrentPage = 0; + +typedef struct statpage_s { + const char *title; + void (*drawer)(void); +} statpage_t; + +static statpage_t statsPages[] = { + { "Level Statistics", M_DrawStatsMaps, }, + { "Play Time Statistics", M_DrawStatsPlaytime, }, + { "Extra Statistics", M_DrawStatsExtra, }, +}; + +#define LENSTATSPAGES (sizeof(statsPages)/sizeof(statsPages[0])) +#define NUMSTATSPAGES (kartstats.vanilla ? 2 : LENSTATSPAGES) static void M_Statistics(INT32 choice) { @@ -8634,6 +8653,7 @@ static void M_Statistics(INT32 choice) statsMapList[j] = -1; statsMax = j - 11 + numextraemblems; statsLocation = 0; + statsCurrentPage = 0; if (statsMax < 0) statsMax = 0; @@ -8641,13 +8661,45 @@ static void M_Statistics(INT32 choice) M_SetupNextMenu(&SP_LevelStatsDef); } -static void M_DrawStatsMaps(int location) +static void M_DrawStatsMaps(void) { - INT32 y = 80, i = -1; + char beststr[40]; + tic_t besttime = 0; + INT32 mapsunfinished = 0; + + int location = statsLocation; + INT32 y = 62, i = -1, j; INT16 mnum; extraemblem_t *exemblem; boolean dotopname = true, dobottomarrow = (location < statsMax); + for (j = 0; j < NUMMAPS; j++) + { + if (!mapheaderinfo[j] || !(mapheaderinfo[j]->menuflags & LF2_RECORDATTACK)) + continue; + + if (!mainrecords[j] || mainrecords[j]->time <= 0) + { + mapsunfinished++; + continue; + } + + besttime += mainrecords[j]->time; + } + + V_DrawString(20, 42, highlightflags|MENUCAPS, "Combined time records:"); + + sprintf(beststr, "%i:%02i:%02i.%02i", G_TicsToHours(besttime), G_TicsToMinutes(besttime, false), G_TicsToSeconds(besttime), G_TicsToCentiseconds(besttime)); + V_DrawRightAlignedString(BASEVIDWIDTH-16, 42, (mapsunfinished ? warningflags : 0), beststr); + + if (mapsunfinished) + V_DrawRightAlignedString(BASEVIDWIDTH-16, 50, warningflags|MENUCAPS, va("(%d unfinished)", mapsunfinished)); + else + V_DrawRightAlignedString(BASEVIDWIDTH-16, 50, recommendedflags|MENUCAPS, "(complete)"); + + V_DrawString(32, 50, MENUCAPS, va("x %d/%d", M_CountEmblems(), numemblems+numextraemblems)); + V_DrawSmallScaledPatch(20, 50, 0, W_CachePatchName("GOTITA", PU_STATIC)); + if (location) V_DrawCharacter(10, y-(skullAnimCounter/5), '\x1A' | highlightflags, false); // up arrow @@ -8736,53 +8788,74 @@ bottomarrow: '\x1B' | highlightflags, false); // down arrow } -static void M_DrawLevelStats(void) +#define DRAWTIMESTAT(y, title, field) { \ + char timebuf[80]; \ + V_DrawString(20, (y), highlightflags|MENUCAPS, title); \ + tic_t timeval = kartstats.field; \ + snprintf(timebuf, 80, "%02i:%02i:%02i", G_TicsToHours(timeval), G_TicsToMinutes(timeval, false), G_TicsToSeconds(timeval)); \ + V_DrawRightAlignedString(BASEVIDWIDTH-16, (y), MENUCAPS, timebuf); \ + } + +#define DRAWAMOUNTSTAT(y, title, field) { \ + V_DrawString(20, (y), highlightflags|MENUCAPS, title); \ + unsigned amountval = kartstats.field; \ + V_DrawRightAlignedString(BASEVIDWIDTH-16, (y), MENUCAPS, va("%u", amountval)); \ + } + +static void M_DrawStatsPlaytime(void) { - char beststr[40]; - - tic_t besttime = 0; - - INT32 i; - INT32 mapsunfinished = 0; - - M_DrawMenuTitle(); - - V_DrawString(20, 24, highlightflags|MENUCAPS, "Total Play Time:"); - V_DrawCenteredString(BASEVIDWIDTH/2, 32, MENUCAPS, va("%i hours, %i minutes, %i seconds", + V_DrawString(20, 42, highlightflags|MENUCAPS, "Total Play Time:"); + V_DrawCenteredString(BASEVIDWIDTH/2, 52, MENUCAPS, va("%i hours, %i minutes, %i seconds", G_TicsToHours(kartstats.totalplaytime), G_TicsToMinutes(kartstats.totalplaytime, false), G_TicsToSeconds(kartstats.totalplaytime))); - V_DrawString(20, 42, highlightflags|MENUCAPS, "Total Matches:"); - V_DrawRightAlignedString(BASEVIDWIDTH-16, 42, MENUCAPS, va("%i played", kartstats.matchesplayed)); + V_DrawString(20, 62, highlightflags|MENUCAPS, "Total Matches:"); + V_DrawRightAlignedString(BASEVIDWIDTH-16, 62, MENUCAPS, va("%i played", kartstats.matchesplayed)); - for (i = 0; i < NUMMAPS; i++) - { - if (!mapheaderinfo[i] || !(mapheaderinfo[i]->menuflags & LF2_RECORDATTACK)) - continue; + // Nothing else to draw + if (kartstats.vanilla) + return; - if (!mainrecords[i] || mainrecords[i]->time <= 0) - { - mapsunfinished++; - continue; - } + DRAWTIMESTAT(82, "RA Play Time:", raplaytime); + DRAWTIMESTAT(92, "Online Play Time:", onlineplaytime); + DRAWTIMESTAT(102, "Race Play Time:", raceplaytime); + DRAWTIMESTAT(112, "Battle Play Time:", battleplaytime); +} - besttime += mainrecords[i]->time; - } +// Note: only available with non-vanilla stats loaded, so it doesn't check for that +static void M_DrawStatsExtra(void) +{ + DRAWTIMESTAT(42, "Time being SPB target:", spbtargettime); + DRAWTIMESTAT(52, "Time spent in spinout:", spinouttime); - V_DrawString(20, 62, highlightflags|MENUCAPS, "Combined time records:"); + DRAWAMOUNTSTAT(72, "Total wins:", totalwins); + DRAWAMOUNTSTAT(82, "Total podium (2nd/3rd place):", totalwins); - sprintf(beststr, "%i:%02i:%02i.%02i", G_TicsToHours(besttime), G_TicsToMinutes(besttime, false), G_TicsToSeconds(besttime), G_TicsToCentiseconds(besttime)); - V_DrawRightAlignedString(BASEVIDWIDTH-16, 62, (mapsunfinished ? warningflags : 0), beststr); + DRAWAMOUNTSTAT(102, "Hits landed:", hits); + DRAWAMOUNTSTAT(112, "Self-hits landed:", selfhits); - if (mapsunfinished) - V_DrawRightAlignedString(BASEVIDWIDTH-16, 70, warningflags|MENUCAPS, va("(%d unfinished)", mapsunfinished)); - else - V_DrawRightAlignedString(BASEVIDWIDTH-16, 70, recommendedflags|MENUCAPS, "(complete)"); + DRAWAMOUNTSTAT(132, "Sinks landed:", sinks); + DRAWAMOUNTSTAT(142, "Times hit by sink:", sinked); - V_DrawString(32, 70, MENUCAPS, va("x %d/%d", M_CountEmblems(), numemblems+numextraemblems)); - V_DrawSmallScaledPatch(20, 70, 0, W_CachePatchName("GOTITA", PU_STATIC)); + DRAWAMOUNTSTAT(162, "Total respawns:", respawns); +} - M_DrawStatsMaps(statsLocation); +#undef DRAWAMOUNTSTAT +#undef DRAWTIMESTAT + +static void M_DrawLevelStats(void) +{ + M_DrawMenuTitle(); + + V_DrawCenteredString(BASEVIDWIDTH/2, 28, highlightflags|MENUCAPS, statsPages[statsCurrentPage].title); + + INT32 w = V_StringWidth(statsPages[statsCurrentPage].title, highlightflags|MENUCAPS); + V_DrawCharacter(BASEVIDWIDTH/2 - w/2 - 10 - (skullAnimCounter/5), 28, + '\x1C' | highlightflags, false); // left arrow + V_DrawCharacter(BASEVIDWIDTH/2 + w/2 + 2 + (skullAnimCounter/5), 28, + '\x1D' | highlightflags, false); // right arrow + + statsPages[statsCurrentPage].drawer(); } // Handle statistics. @@ -8793,23 +8866,46 @@ static void M_HandleLevelStats(INT32 choice) switch (choice) { case KEY_DOWNARROW: + if (statsCurrentPage != 0) // Must be on level stats page + break; S_StartSound(NULL, sfx_menu1); if (statsLocation < statsMax) ++statsLocation; break; case KEY_UPARROW: + if (statsCurrentPage != 0) // Must be on level stats page + break; S_StartSound(NULL, sfx_menu1); if (statsLocation) --statsLocation; break; + case KEY_RIGHTARROW: + S_StartSound(NULL, sfx_menu1); + statsCurrentPage++; + if (statsCurrentPage >= NUMSTATSPAGES) + statsCurrentPage = 0; + break; + + case KEY_LEFTARROW: + S_StartSound(NULL, sfx_menu1); + if (statsCurrentPage == 0) + statsCurrentPage = NUMSTATSPAGES-1; + else + --statsCurrentPage; + break; + case KEY_PGDN: + if (statsCurrentPage != 0) // Must be on level stats page + break; S_StartSound(NULL, sfx_menu1); statsLocation += (statsLocation+13 >= statsMax) ? statsMax-statsLocation : 13; break; case KEY_PGUP: + if (statsCurrentPage != 0) // Must be on level stats page + break; S_StartSound(NULL, sfx_menu1); statsLocation -= (statsLocation < 13) ? statsLocation : 13; break; From 8959d3aec408ee2c9837c562b46772045f22ef11 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 19 Jan 2025 03:04:24 +0300 Subject: [PATCH 239/418] Put playtime statistics at first page instead of RA medals --- 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 d9bc816f8..341dcdcd6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8620,8 +8620,8 @@ typedef struct statpage_s { } statpage_t; static statpage_t statsPages[] = { - { "Level Statistics", M_DrawStatsMaps, }, { "Play Time Statistics", M_DrawStatsPlaytime, }, + { "Level Statistics", M_DrawStatsMaps, }, { "Extra Statistics", M_DrawStatsExtra, }, }; From 5f3dc081b5ee35874c7c479610b12f8570b96223 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 19 Jan 2025 17:33:44 +0300 Subject: [PATCH 240/418] Don't start invinc/grow alarm sound when player uses power item It will still be started in K_UpdateInvincibilitySounds, but now if player already had invincibility, they won't get 2 overlapping sounds --- src/k_kart.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 9289b8ede..9729b84ac 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6289,8 +6289,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (P_IsLocalPlayer(player) && cv_supermusic.value == 1 && cv_birdmusic.value) S_ChangeMusicSpecial("kinvnc"); - else - S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmi : sfx_kinvnc)); P_RestoreMusic(player); K_PlayPowerGloatSound(player->mo); @@ -6495,8 +6493,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->kartstuff[k_growshrinktimer] = itemtime+(4*TICRATE); // 12 seconds if (P_IsLocalPlayer(player) && cv_growmusic.value == 1 && cv_birdmusic.value ) S_ChangeMusicSpecial("kgrow"); - else - S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow)); P_RestoreMusic(player); S_StartSound(player->mo, sfx_kc5a); } From aa0bf396e73a9937ede2ed19a28d07b1a2d5c9d9 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 15 Jan 2025 21:17:56 +0300 Subject: [PATCH 241/418] Fix spectator control text overlapping when showdirectorhud is off --- src/st_stuff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index d189e2c23..f99c19fd3 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -805,8 +805,8 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); } } } From d7c3cf7d3e733e9b595ca6c17c666dd61faa63fd Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 15:09:19 +0100 Subject: [PATCH 242/418] put this into switch looks better --- src/hardware/hw_draw.c | 2 +- src/p_mobj.c | 41 ++++++++++++++++++++--------------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index e38300309..0d90a2bde 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -595,7 +595,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) RGBA_t *palette = HWR_GetTexturePalette(); Surf.PolyColor.rgba = palette[color&0xFF].rgba; - if (HWR_ShouldUsePaletteRendering()) + if (HWR_ShouldUsePaletteRendering()) Surf.PolyColor.s.alpha = softwaretranstogl[strength]; else Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f); diff --git a/src/p_mobj.c b/src/p_mobj.c index 759b012ee..18e11cefe 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -172,20 +172,28 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) { // Start flashing, since you've landed. player->powers[pw_flashing] = K_GetKartFlashing(player)-1; - //P_DoPityCheck(player); } // Set animation state // The pflags version of this was just as convoluted. // Rewriten for SRB2kart ... though I don't know what this is. - if ((state >= S_KART_STND1 && state <= S_KART_STND2_R) || state == S_KART_SQUISH || state == S_KART_SPIN) - player->panim = PA_IDLE; - else if (state >= S_KART_WALK1 && state <= S_KART_WALK2_R) - player->panim = PA_WALK; - else if (state >= S_KART_RUN1 && state <= S_KART_DRIFT2_R) - player->panim = PA_RUN; - else - player->panim = PA_ETC; + switch(state) + { + case S_KART_STND1...S_KART_STND2_R: + case S_KART_SQUISH: + case S_KART_SPIN: + player->panim = PA_IDLE; + break; + case S_KART_WALK1...S_KART_WALK2_R: + player->panim = PA_WALK; + break; + case S_KART_RUN1...S_KART_DRIFT2_R: + player->panim = PA_RUN; + break; + default: + player->panim = PA_ETC; + break; + } if (recursion++) // if recursion detected, memset(seenstate = tempstate, 0, sizeof tempstate); // clear state table @@ -2406,9 +2414,6 @@ static void P_PlayerZMovement(mobj_t *mo) mo->player->viewheight -= (mo->z+mo->height) - mo->ceilingz; else mo->player->viewheight -= mo->floorz - mo->z; - - /*mo->player->deltaviewheight = - (FixedMul(cv_viewheight.value<scale) - mo->player->viewheight)>>3;*/ } // adjust height @@ -2474,11 +2479,6 @@ static void P_PlayerZMovement(mobj_t *mo) { mo->pmomz = 0; // We're on a new floor, don't keep doing platform movement. - // Squat down. Decrease viewheight for a moment after hitting the ground (hard), - /*if (P_MobjFlip(mo)*mo->momz < -FixedMul(8*FRACUNIT, mo->scale)) - mo->player->deltaviewheight = (P_MobjFlip(mo)*mo->momz)>>3; // make sure momz is negative - */ - if (!tmfloorthing || tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER) // Spin Attack { @@ -2586,7 +2586,6 @@ static void P_PlayerZMovement(mobj_t *mo) if (!(mo->player->pflags & PF_GLIDING)) mo->player->pflags &= ~PF_JUMPED; mo->player->pflags &= ~PF_THOKKED; - //mo->player->pflags &= ~PF_GLIDING; mo->player->jumping = 0; mo->player->secondjump = 0; mo->player->glidetime = 0; @@ -6108,9 +6107,9 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj) } return_angle = FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mobj->roll) - + FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch) - + FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll) - + FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch); + + FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch) + + FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll) + + FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch); return return_angle; } From 85a64a6c14017bf4863fcdd6e6a39cae834fe75d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 15:28:51 +0100 Subject: [PATCH 243/418] put this thing onto its original place --- src/d_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 4d8979307..2a221a29a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -772,13 +772,13 @@ void D_SRB2Loop(void) debugload--; #endif - refreshdirmenu = 0; // not sure where to put this, here as good as any? - interp = (R_UsingFrameInterpolation() && !dedicated); doDisplay = false; renderisnewtic = (realtics > 0 || singletics); + refreshdirmenu = 0; // not sure where to put this, here as good as any? + if (renderisnewtic) { // don't skip more than 10 frames at a time From cccf6449f9a1ee0a06a727b80712e259bdc43d9c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 18:04:05 +0100 Subject: [PATCH 244/418] fix freecam vertical look for the 500th thousand time truly amazing code --- src/p_local.h | 2 -- src/p_user.c | 40 ++++++++-------------------------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 8ce9568f2..4f670bc74 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -84,8 +84,6 @@ typedef struct camera_s boolean chase; boolean freecam; - boolean keyboardlook; - angle_t localangle; INT32 localaiming; diff --git a/src/p_user.c b/src/p_user.c index 3068e7b67..13c98f81e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3136,7 +3136,7 @@ fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42}; #define MAXCAMERADIST 140*FRACUNIT // Max distance the camera can be in front of the player (2D mode) static fixed_t forwardmove[2] = {25<>16, 50<>16}; -//static fixed_t sidemove[2] = {2<>16, 4<>16}; +static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn static fixed_t strafemove[2] = {25<>16, 50<>16}; // faster! @@ -3181,13 +3181,13 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) INT32 laim, forward, side, axis; // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming; + boolean turnleft, turnright; boolean strafeleft, straferight; - boolean invertmouse, usejoystick, kbl; + boolean usejoystick; angle_t lang; - INT32 player_invert; const UINT8 forplayer = num+1; - player_t *player = ((forplayer == 1) ? &players[consoleplayer] : &players[displayplayers[forplayer]]); + + SINT8 player_invert = cv_invertmouse.value ? -1 : 1; // who tf uses two mice? memset(&cameracmd[num], 0, sizeof(ticcmd_t)); // initialize cmd @@ -3195,37 +3195,27 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) lang = cam->localangle; laim = cam->localaiming; - kbl = cam->keyboardlook; switch (forplayer) { case 2: G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); - mouseaiming = player->spectator; - invertmouse = cv_invertmouse2.value; break; case 3: G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); - mouseaiming = false; - invertmouse = false; break; case 4: G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); - mouseaiming = false; - invertmouse = false; break; case 1: default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver - mouseaiming = player->spectator; - invertmouse = cv_invertmouse.value; break; } cmd->angleturn = (INT16)(lang >> 16); cmd->aiming = G_ClipAimingPitch(&laim); - const boolean lookaxis = cv_lookaxis[num].value; const boolean analogjoystickmove = cv_usejoystick[num].value && !Joystick[num].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[num].value && Joystick[num].bGamepadStyle; @@ -3255,12 +3245,12 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (turnright && !(turnleft)) { cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); - //side += sidemove[1]; + side += sidemove[1]; } else if (turnleft && !(turnright)) { cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); - //side -= sidemove[1]; + side -= sidemove[1]; } straferight = InputDown(gc_straferight, forplayer); @@ -3318,30 +3308,17 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_brake, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_BRAKE; - // spectator aiming shit, ahhhh... - player_invert = invertmouse ? -1 : 1; - - // mouse look stuff (mouse look is not the same as mouse aim) - kbl = false; - - // looking up/down - laim += (mlooky<<19)*player_invert; - axis = JoyAxis(AXISLOOK, forplayer); - // spring back if not using keyboard neither mouselookin' - if (!kbl && !lookaxis && !mouseaiming) - laim = 0; + laim += (mlooky<<19)*player_invert; if (InputDown(gc_lookup, forplayer) || (usejoystick && axis < 0)) { laim += KB_LOOKSPEED; - kbl = true; } else if (InputDown(gc_lookdown, forplayer) || (usejoystick && axis > 0)) { laim -= KB_LOOKSPEED; - kbl = true; } if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V @@ -3397,7 +3374,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { cam->localaiming = laim; } - cam->keyboardlook = kbl; return cmd; } From 8cdb920f5471e11aab9187ee021e8ae7a6b07fcb Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 19:00:10 +0100 Subject: [PATCH 245/418] dont turn 90 degrees when switching to freecam --- src/g_game.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 642449bbc..4692f84c2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -964,6 +964,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // dumbass thing so we can use a few buttons but dont accidentally drive away if (player->spectator || freecam) { + cmd->angleturn = (INT16)(lang >> 16); G_BuildLocalTiccmd(cmd, ssplayer, freecam); // let lua override everything @@ -1030,7 +1031,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) side += ((axis * sidemove[0]) >> 10); } - if (player->spectator || cv_mouseturn.value) + if (cv_mouseturn.value) { //THIS WORKS WTF???????? cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); From 24ca9fdafa3c60eb9cc1b0d719cd12317073e877 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 19:17:41 +0100 Subject: [PATCH 246/418] oops didnt init this --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 13c98f81e..722cf78a0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3239,7 +3239,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) turnright = turnright || (axis > 0); turnleft = turnleft || (axis < 0); } - forward = 0; + forward = side = 0; // let movement keys cancel each other out if (turnright && !(turnleft)) From ebfafd7b6e8d0fc234033a659db551d867385ea6 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 19:21:33 +0100 Subject: [PATCH 247/418] a --- src/p_user.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 722cf78a0..bdab2b92d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3271,7 +3271,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) straferight = straferight || (axis > 0); strafeleft = strafeleft || (axis < 0); } - side = 0; // let strafe keys cancel each other out if (straferight && !(strafeleft)) From 5dc76d07ec7df933098b1a624c4eb53ac5ee7ef9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 19:33:47 +0100 Subject: [PATCH 248/418] Hold up/down for 2 seconds while not moving to pan the camera vertically from RR --- src/doomtype.h | 3 +++ src/p_local.h | 3 +++ src/p_tick.c | 15 ++++++++++++++- src/p_user.c | 11 +++++------ src/r_main.c | 4 ---- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index 116d5cdfb..174bba5b1 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -380,6 +380,9 @@ unset_bit_array (bitarray_t * const array, const int value) array[value >> 3] &= ~(1<<(value & 7)); } +#define intsign(n) \ + ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) + typedef UINT64 precise_t; #endif //__DOOMTYPE__ diff --git a/src/p_local.h b/src/p_local.h index 4f670bc74..fb2f31485 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -95,6 +95,9 @@ typedef struct camera_s // Freecam: aiming needs to be reset after switching from chasecam boolean reset_aiming; + // Hold up/down to pan the camera vertically + SINT8 dpad_y_held; + // Things used by FS cameras. fixed_t viewheight; angle_t startangle; diff --git a/src/p_tick.c b/src/p_tick.c index 898be3efa..25934a0f1 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -469,7 +469,20 @@ void P_RunChaseCameras(void) for (i = 0; i <= splitscreen; i++) { if (camera[i].chase) - P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); + { + player_t *p = &players[displayplayers[i]]; + camera_t *cam = &camera[i]; + + if (p->mo && p->kartstuff[k_throwdir] != 0) + { + if (p->speed < 6 * p->mo->scale && abs(cam->dpad_y_held) < 2*TICRATE) + cam->dpad_y_held += intsign(p->kartstuff[k_throwdir]); + } + else + cam->dpad_y_held = 0; + + P_MoveChaseCamera(p, cam, false); + } } } diff --git a/src/p_user.c b/src/p_user.c index bdab2b92d..f31190343 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3172,10 +3172,6 @@ void P_ToggleDemoCamera(UINT8 viewnum) } static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS]; - -#define intsign(n) \ - ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) - static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { INT32 laim, forward, side, axis; @@ -3497,8 +3493,6 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) cam->subsector = R_PointInSubsector(cam->x, cam->y); } -#undef intsign - void P_ResetCamera(player_t *player, camera_t *thiscam) { tic_t tries = 0; @@ -3886,6 +3880,11 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall focusaiming = player->aiming; } + if (abs(thiscam->dpad_y_held) >= 2*TICRATE) + { + focusaiming += ANGLE_45 * intsign(thiscam->dpad_y_held) * P_MobjFlip(mo); + } + if (P_CameraThinker(player, thiscam, resetcalled)) return true; diff --git a/src/r_main.c b/src/r_main.c index 1b575dd11..20461b4a6 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -839,10 +839,6 @@ void R_ApplyViewMorph(void) vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.width); } -static inline int intsign(int n) { - return n < 0 ? -1 : n > 0 ? 1 : 0; -} - angle_t R_ViewRollAngle(const player_t *player) { angle_t roll = 0; From 18c449a9ed896ab68a9073d35f54d61d8b39dcfc Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 21:12:06 +0100 Subject: [PATCH 249/418] dont cache all those unused hud graphics --- src/hu_stuff.c | 1 - src/hu_stuff.h | 1 - src/st_stuff.c | 153 ------------------------------------------------- src/st_stuff.h | 6 -- 4 files changed, 161 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 2339fbef4..0f20b3a6c 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -101,7 +101,6 @@ patch_t *rflagico; patch_t *bflagico; patch_t *rmatcico; patch_t *bmatcico; -patch_t *tagico; patch_t *tallminus; //------------------------------------------- diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 258e16c9d..72f1a026a 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -101,7 +101,6 @@ extern patch_t *rflagico; extern patch_t *bflagico; extern patch_t *rmatcico; extern patch_t *bmatcico; -extern patch_t *tagico; extern patch_t *tallminus; // set true whenever the tab rankings are being shown for any reason diff --git a/src/st_stuff.c b/src/st_stuff.c index f99c19fd3..13bb9a007 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -80,73 +80,6 @@ char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap*/ // status bar overlay // ------------------------------------------ -// icons for overlay -patch_t *sboscore; // Score logo -patch_t *sbotime; // Time logo -patch_t *sbocolon; // Colon for time -patch_t *sboperiod; // Period for time centiseconds -patch_t *livesback; // Lives icon background -static patch_t *nrec_timer; // Timer for NiGHTS records -static patch_t *sborings; -static patch_t *sboover; -static patch_t *timeover; -static patch_t *stlivex; -static patch_t *rrings; -static patch_t *getall; // Special Stage HUD -static patch_t *timeup; // Special Stage HUD -static patch_t *hunthoming[6]; -static patch_t *itemhoming[6]; -static patch_t *race1; -static patch_t *race2; -static patch_t *race3; -static patch_t *racego; -//static patch_t *ttlnum; -static patch_t *nightslink; -static patch_t *count5; -static patch_t *count4; -static patch_t *count3; -static patch_t *count2; -static patch_t *count1; -static patch_t *count0; -static patch_t *curweapon; -static patch_t *normring; -static patch_t *bouncering; -static patch_t *infinityring; -static patch_t *autoring; -static patch_t *explosionring; -static patch_t *scatterring; -static patch_t *grenadering; -static patch_t *railring; -static patch_t *jumpshield; -static patch_t *forceshield; -static patch_t *ringshield; -static patch_t *watershield; -static patch_t *bombshield; -static patch_t *pityshield; -static patch_t *invincibility; -static patch_t *sneakers; -static patch_t *gravboots; -static patch_t *nonicon; -static patch_t *bluestat; -static patch_t *byelstat; -static patch_t *orngstat; -static patch_t *redstat; -static patch_t *yelstat; -static patch_t *nbracket; -static patch_t *nhud[12]; -static patch_t *nsshud; -static patch_t *narrow[9]; -static patch_t *nredar[8]; // Red arrow -static patch_t *drillbar; -static patch_t *drillfill[3]; -static patch_t *capsulebar; -static patch_t *capsulefill; -patch_t *ngradeletters[7]; -static patch_t *minus5sec; -static patch_t *minicaps; -static patch_t *gotrflag; -static patch_t *gotbflag; - // Midnight Channel: static patch_t *hud_tv1; static patch_t *hud_tv2; @@ -283,8 +216,6 @@ void ST_UnloadGraphics(void) void ST_LoadGraphics(void) { - int i; - // SRB2 border patch st_borderpatchnum = W_GetNumForName("GFZFLR01"); scr_borderpatch = W_CacheLumpNum(st_borderpatchnum, PU_HUDGFX); @@ -294,95 +225,11 @@ void ST_LoadGraphics(void) // but load them in R_AddSkins, that gets called // first anyway // cache the status bar overlay icons (fullscreen mode) - sborings = W_CachePatchName("SBORINGS", PU_HUDGFX); - sboscore = W_CachePatchName("SBOSCORE", PU_HUDGFX); - sboover = W_CachePatchName("SBOOVER", PU_HUDGFX); - timeover = W_CachePatchName("TIMEOVER", PU_HUDGFX); - stlivex = W_CachePatchName("STLIVEX", PU_HUDGFX); - livesback = W_CachePatchName("STLIVEBK", PU_HUDGFX); - rrings = W_CachePatchName("RRINGS", PU_HUDGFX); - sbotime = W_CachePatchName("SBOTIME", PU_HUDGFX); // Time logo - sbocolon = W_CachePatchName("SBOCOLON", PU_HUDGFX); // Colon for time - sboperiod = W_CachePatchName("SBOPERIO", PU_HUDGFX); // Period for time centiseconds - nrec_timer = W_CachePatchName("NGRTIMER", PU_HUDGFX); // Timer for NiGHTS - getall = W_CachePatchName("GETALL", PU_HUDGFX); // Special Stage HUD - timeup = W_CachePatchName("TIMEUP", PU_HUDGFX); // Special Stage HUD - race1 = W_CachePatchName("RACE1", PU_HUDGFX); - race2 = W_CachePatchName("RACE2", PU_HUDGFX); - race3 = W_CachePatchName("RACE3", PU_HUDGFX); - racego = W_CachePatchName("RACEGO", PU_HUDGFX); - nightslink = W_CachePatchName("NGHTLINK", PU_HUDGFX); - count5 = W_CachePatchName("DRWNF0", PU_HUDGFX); - count4 = W_CachePatchName("DRWNE0", PU_HUDGFX); - count3 = W_CachePatchName("DRWND0", PU_HUDGFX); - count2 = W_CachePatchName("DRWNC0", PU_HUDGFX); - count1 = W_CachePatchName("DRWNB0", PU_HUDGFX); - count0 = W_CachePatchName("DRWNA0", PU_HUDGFX); - for (i = 0; i < 6; ++i) - { - hunthoming[i] = W_CachePatchName(va("HOMING%d", i+1), PU_HUDGFX); - itemhoming[i] = W_CachePatchName(va("HOMITM%d", i+1), PU_HUDGFX); - } - - curweapon = W_CachePatchName("CURWEAP", PU_HUDGFX); - normring = W_CachePatchName("RINGIND", PU_HUDGFX); - bouncering = W_CachePatchName("BNCEIND", PU_HUDGFX); - infinityring = W_CachePatchName("INFNIND", PU_HUDGFX); - autoring = W_CachePatchName("AUTOIND", PU_HUDGFX); - explosionring = W_CachePatchName("BOMBIND", PU_HUDGFX); - scatterring = W_CachePatchName("SCATIND", PU_HUDGFX); - grenadering = W_CachePatchName("GRENIND", PU_HUDGFX); - railring = W_CachePatchName("RAILIND", PU_HUDGFX); - jumpshield = W_CachePatchName("WHTVB0", PU_HUDGFX); - forceshield = W_CachePatchName("BLTVB0", PU_HUDGFX); - ringshield = W_CachePatchName("YLTVB0", PU_HUDGFX); - watershield = W_CachePatchName("ELTVB0", PU_HUDGFX); - bombshield = W_CachePatchName("BKTVB0", PU_HUDGFX); - pityshield = W_CachePatchName("GRTVB0", PU_HUDGFX); - invincibility = W_CachePatchName("PINVB0", PU_HUDGFX); - sneakers = W_CachePatchName("SHTVB0", PU_HUDGFX); - gravboots = W_CachePatchName("GBTVB0", PU_HUDGFX); - - tagico = W_CachePatchName("TAGICO", PU_HUDGFX); rflagico = W_CachePatchName("RFLAGICO", PU_HUDGFX); bflagico = W_CachePatchName("BFLAGICO", PU_HUDGFX); rmatcico = W_CachePatchName("RMATCICO", PU_HUDGFX); bmatcico = W_CachePatchName("BMATCICO", PU_HUDGFX); - gotrflag = W_CachePatchName("GOTRFLAG", PU_HUDGFX); - gotbflag = W_CachePatchName("GOTBFLAG", PU_HUDGFX); - nonicon = W_CachePatchName("NONICON", PU_HUDGFX); - - // NiGHTS HUD things - bluestat = W_CachePatchName("BLUESTAT", PU_HUDGFX); - byelstat = W_CachePatchName("BYELSTAT", PU_HUDGFX); - orngstat = W_CachePatchName("ORNGSTAT", PU_HUDGFX); - redstat = W_CachePatchName("REDSTAT", PU_HUDGFX); - yelstat = W_CachePatchName("YELSTAT", PU_HUDGFX); - nbracket = W_CachePatchName("NBRACKET", PU_HUDGFX); - for (i = 0; i < 12; ++i) - nhud[i] = W_CachePatchName(va("NHUD%d", i+1), PU_HUDGFX); - nsshud = W_CachePatchName("NSSHUD", PU_HUDGFX); - minicaps = W_CachePatchName("MINICAPS", PU_HUDGFX); - - for (i = 0; i < 8; ++i) - { - narrow[i] = W_CachePatchName(va("NARROW%d", i+1), PU_HUDGFX); - nredar[i] = W_CachePatchName(va("NREDAR%d", i+1), PU_HUDGFX); - } - - // non-animated version - narrow[8] = W_CachePatchName("NARROW9", PU_HUDGFX); - - drillbar = W_CachePatchName("DRILLBAR", PU_HUDGFX); - for (i = 0; i < 3; ++i) - drillfill[i] = W_CachePatchName(va("DRILLFI%d", i+1), PU_HUDGFX); - capsulebar = W_CachePatchName("CAPSBAR", PU_HUDGFX); - capsulefill = W_CachePatchName("CAPSFILL", PU_HUDGFX); - minus5sec = W_CachePatchName("MINUS5", PU_HUDGFX); - - for (i = 0; i < 7; ++i) - ngradeletters[i] = W_CachePatchName(va("GRADE%d", i), PU_HUDGFX); K_LoadKartHUDGraphics(); diff --git a/src/st_stuff.h b/src/st_stuff.h index d289e64ce..54d2483ee 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -73,10 +73,6 @@ extern UINT8 stplyrnum; extern lumpnum_t st_borderpatchnum; // patches, also used in intermission extern patch_t *tallnum[10]; -extern patch_t *sboscore; -extern patch_t *sbotime; -extern patch_t *sbocolon; -extern patch_t *sboperiod; extern patch_t *facerankprefix[MAXSKINS]; // ranking extern patch_t *facewantprefix[MAXSKINS]; // wanted extern patch_t *facemmapprefix[MAXSKINS]; // minimap @@ -89,8 +85,6 @@ extern char *facemmapprefix_name[MAXSKINS]; // minimap extern char *localfacerankprefix_name[MAXLOCALSKINS]; // ranking extern char *localfacewantprefix_name[MAXLOCALSKINS]; // wanted extern char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap*/ -extern patch_t *livesback; -extern patch_t *ngradeletters[7]; /** HUD location information (don't move this comment) */ From 4e311ca279686496a5dc2078df04e7724291aefb Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 21:30:37 +0100 Subject: [PATCH 250/418] kill even more unused patches + nonexistant crosshair stuff --- src/d_netcmd.c | 4 ---- src/g_game.c | 5 ----- src/g_game.h | 1 - src/hu_stuff.c | 60 -------------------------------------------------- src/hu_stuff.h | 5 ----- src/v_video.c | 2 +- 6 files changed, 1 insertion(+), 76 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c43dd21e8..f04affa99 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -975,10 +975,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_showlocalskinmenus); - //CV_RegisterVar(&cv_crosshair); - //CV_RegisterVar(&cv_crosshair2); - //CV_RegisterVar(&cv_crosshair3); - //CV_RegisterVar(&cv_crosshair4); //CV_RegisterVar(&cv_alwaysfreelook); //CV_RegisterVar(&cv_alwaysfreelook2); //CV_RegisterVar(&cv_chasefreelook); diff --git a/src/g_game.c b/src/g_game.c index 3b3265868..2231b1148 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -396,10 +396,6 @@ static CV_PossibleValue_t powermusic_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "SFX consvar_t cv_growmusic = {"growmusic", "On", CV_SAVE, powermusic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_supermusic = {"supermusic", "On", CV_SAVE, powermusic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -/*consvar_t cv_crosshair = {"crosshair", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_crosshair2 = {"crosshair2", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_crosshair3 = {"crosshair3", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_crosshair4 = {"crosshair4", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};*/ consvar_t cv_invertmouse = {"invertmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_invertmouse2 = {"invertmouse2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /*consvar_t cv_alwaysfreelook = {"alwaysmlook", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -409,7 +405,6 @@ consvar_t cv_chasefreelook2 = {"chasemlook2", "Off", CV_SAVE, CV_OnOff, NULL, 0, consvar_t cv_mousemove = {"mousemove", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mousemove2 = {"mousemove2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};*/ -//static CV_PossibleValue_t crosshair_cons_t[] = {{0, "Off"}, {1, "Cross"}, {2, "Angle"}, {3, "Point"}, {0, NULL}}; static CV_PossibleValue_t joyaxis_cons_t[] = {{0, "None"}, {1, "Left X"}, {2, "Left Y"}, {-1, "Left X-"}, {-2, "Left Y-"}, #if JOYAXISSET > 1 diff --git a/src/g_game.h b/src/g_game.h index 519c23d5a..70f6e6ab4 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -115,7 +115,6 @@ extern consvar_t cv_songcredits; extern consvar_t cv_showfreeplay; extern consvar_t cv_growmusic, cv_supermusic; extern consvar_t cv_pauseifunfocused; -//extern consvar_t cv_crosshair, cv_crosshair2, cv_crosshair3, cv_crosshair4; extern consvar_t cv_invertmouse/*, cv_alwaysfreelook, cv_chasefreelook, cv_mousemove*/; extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2*/; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 0f20b3a6c..9dc8d0df3 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -70,7 +70,6 @@ patch_t *hu_font[HU_FONTSIZE]; patch_t *kart_font[KART_FONTSIZE]; // SRB2kart patch_t *tny_font[HU_FONTSIZE]; patch_t *tallnum[10]; // 0-9 -patch_t *nightsnum[10]; // 0-9 // Level title and credits fonts patch_t *lt_font[LT_FONTSIZE]; @@ -103,21 +102,6 @@ patch_t *rmatcico; patch_t *bmatcico; patch_t *tallminus; -//------------------------------------------- -// coop hud -//------------------------------------------- - -patch_t *emeraldpics[7]; -patch_t *tinyemeraldpics[7]; -static patch_t *emblemicon; -static patch_t *tokenicon; - -//------------------------------------------- -// misc vars -//------------------------------------------- - -// crosshair 0 = off, 1 = cross, 2 = angle, 3 = point, see m_menu.c -static patch_t *crosshair[HU_CROSSHAIRS]; // 3 precached crosshair graphics // song credits static patch_t *songcreditbg; @@ -381,8 +365,6 @@ void HU_LoadGraphics(void) { sprintf(buffer, "STTNUM%d", i); tallnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - sprintf(buffer, "NGTNUM%d", i); - nightsnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); sprintf(buffer, "PINGN%d", i); pingnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); sprintf(buffer, "OPPRNK0%d", i); @@ -392,32 +374,6 @@ void HU_LoadGraphics(void) // minus for negative tallnums tallminus = (patch_t *)W_CachePatchName("STTMINUS", PU_HUDGFX); - // cache the crosshairs, don't bother to know which one is being used, - // just cache all 3, they're so small anyway. - for (i = 0; i < HU_CROSSHAIRS; i++) - { - sprintf(buffer, "CROSHAI%c", '1'+i); - crosshair[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - } - - emblemicon = W_CachePatchName("EMBLICON", PU_HUDGFX); - tokenicon = W_CachePatchName("TOKNICON", PU_HUDGFX); - - emeraldpics[0] = W_CachePatchName("CHAOS1", PU_HUDGFX); - emeraldpics[1] = W_CachePatchName("CHAOS2", PU_HUDGFX); - emeraldpics[2] = W_CachePatchName("CHAOS3", PU_HUDGFX); - emeraldpics[3] = W_CachePatchName("CHAOS4", PU_HUDGFX); - emeraldpics[4] = W_CachePatchName("CHAOS5", PU_HUDGFX); - emeraldpics[5] = W_CachePatchName("CHAOS6", PU_HUDGFX); - emeraldpics[6] = W_CachePatchName("CHAOS7", PU_HUDGFX); - tinyemeraldpics[0] = W_CachePatchName("TEMER1", PU_HUDGFX); - tinyemeraldpics[1] = W_CachePatchName("TEMER2", PU_HUDGFX); - tinyemeraldpics[2] = W_CachePatchName("TEMER3", PU_HUDGFX); - tinyemeraldpics[3] = W_CachePatchName("TEMER4", PU_HUDGFX); - tinyemeraldpics[4] = W_CachePatchName("TEMER5", PU_HUDGFX); - tinyemeraldpics[5] = W_CachePatchName("TEMER6", PU_HUDGFX); - tinyemeraldpics[6] = W_CachePatchName("TEMER7", PU_HUDGFX); - songcreditbg = W_CachePatchName("K_SONGCR", PU_HUDGFX); // cache ping gfx: @@ -2289,22 +2245,6 @@ void HU_Drawer(void) if (gamestate != GS_LEVEL) return; - // draw the crosshair, not when viewing demos nor with chasecam - /*if (!automapactive && !demo.playback) - { - if (cv_crosshair.value && !camera[0].chase && !players[displayplayers[0]].spectator) - HU_DrawCrosshair(); - - if (cv_crosshair2.value && !camera[1].chase && !players[displayplayers[1]].spectator) - HU_DrawCrosshair2(); - - if (cv_crosshair3.value && !camera[2].chase && !players[displayplayers[2]].spectator) - HU_DrawCrosshair3(); - - if (cv_crosshair4.value && !camera[3].chase && !players[displayplayers[3]].spectator) - HU_DrawCrosshair4(); - }*/ - // draw song credits if (cv_songcredits.value) HU_DrawSongCredits(); diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 72f1a026a..e05a4136b 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -42,8 +42,6 @@ #define CRED_FONTEND 'Z' // the last font character #define CRED_FONTSIZE (CRED_FONTEND - CRED_FONTSTART + 1) -#define HU_CROSSHAIRS 3 // maximum of 9 - see HU_Init(); - extern char *shiftxform; // english translation shift table extern char english_shiftxform[]; @@ -90,13 +88,10 @@ extern patch_t *tallnum[10]; extern patch_t *pingnum[10]; extern patch_t *pinggfx[5]; extern patch_t *ranknum[10]; -extern patch_t *nightsnum[10]; extern patch_t *framecounter; extern patch_t *frameslash; extern patch_t *lt_font[LT_FONTSIZE]; extern patch_t *cred_font[CRED_FONTSIZE]; -extern patch_t *emeraldpics[7]; -extern patch_t *tinyemeraldpics[7]; extern patch_t *rflagico; extern patch_t *bflagico; extern patch_t *rmatcico; diff --git a/src/v_video.c b/src/v_video.c index 385daf232..0eca13591 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -714,7 +714,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca // TODO: make some kind of vertical version of V_FLIP, maybe by deprecating V_OFFSET in future?!? offsety = FixedMul(SHORT(patch->topoffset)< Date: Mon, 20 Jan 2025 22:02:08 +0100 Subject: [PATCH 251/418] delete nonfunctional second mouse stuff --- src/android/i_system.c | 4 - src/d_event.h | 1 - src/d_netcmd.c | 30 +--- src/d_netcmd.h | 7 - src/dummy/i_system.c | 4 - src/g_game.c | 9 +- src/g_game.h | 3 +- src/g_input.c | 40 +---- src/g_input.h | 12 +- src/hu_stuff.c | 2 +- src/i_system.h | 8 - src/m_menu.c | 29 +--- src/sdl/i_system.c | 337 ----------------------------------------- src/sdl/i_video.c | 2 - 14 files changed, 12 insertions(+), 476 deletions(-) diff --git a/src/android/i_system.c b/src/android/i_system.c index 3eddf6e20..4a598a452 100644 --- a/src/android/i_system.c +++ b/src/android/i_system.c @@ -184,8 +184,6 @@ void I_OutputMsg(const char *fmt, ...) void I_StartupMouse(void){} -void I_StartupMouse2(void){} - void I_StartupKeyboard(void){} INT32 I_GetKey(void) @@ -242,8 +240,6 @@ void I_GetJoystickEvents(void){} void I_GetJoystick2Events(void){} -void I_GetMouseEvents(void){} - char *I_GetEnv(const char *name) { LOGW("I_GetEnv() called?!"); diff --git a/src/d_event.h b/src/d_event.h index 8cbf8560d..b76e5c6a4 100644 --- a/src/d_event.h +++ b/src/d_event.h @@ -25,7 +25,6 @@ typedef enum ev_console, ev_mouse, ev_joystick, - ev_mouse2, ev_joystick2, ev_joystick3, ev_joystick4, diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f04affa99..23fe91bce 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -209,13 +209,6 @@ void SendWeaponPref3(void); void SendWeaponPref4(void); static CV_PossibleValue_t usemouse_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Force"}, {0, NULL}}; -#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) -static CV_PossibleValue_t mouse2port_cons_t[] = {{0, "/dev/gpmdata"}, {1, "/dev/ttyS0"}, - {2, "/dev/ttyS1"}, {3, "/dev/ttyS2"}, {4, "/dev/ttyS3"}, {0, NULL}}; -#else -static CV_PossibleValue_t mouse2port_cons_t[] = {{1, "COM1"}, {2, "COM2"}, {3, "COM3"}, {4, "COM4"}, - {0, NULL}}; -#endif #ifdef LJOYSTICK static CV_PossibleValue_t joyport_cons_t[] = {{1, "/dev/js0"}, {2, "/dev/js1"}, {3, "/dev/js2"}, @@ -298,7 +291,7 @@ consvar_t cv_skipmapcheck = {"skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL, 0, INT32 cv_debug; consvar_t cv_usemouse = {"use_mouse", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_usemouse2 = {"use_mouse2", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse2, 0, NULL, NULL, 0, 0, NULL}; + //WTF consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -331,12 +324,6 @@ consvar_t cv_joyscale[2] = { //Alam: Dummy for save {"joyscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL} }; #endif -#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) -consvar_t cv_mouse2port = {"mouse2port", "/dev/gpmdata", CV_SAVE, mouse2port_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mouse2opt = {"mouse2opt", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -#else -consvar_t cv_mouse2port = {"mouse2port", "COM2", CV_SAVE, mouse2port_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif consvar_t cv_matchboxes = {"matchboxes", "Normal", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, matchboxes_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_specialrings = {"specialrings", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -975,10 +962,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_showlocalskinmenus); - //CV_RegisterVar(&cv_alwaysfreelook); - //CV_RegisterVar(&cv_alwaysfreelook2); - //CV_RegisterVar(&cv_chasefreelook); - //CV_RegisterVar(&cv_chasefreelook2); CV_RegisterVar(&cv_replaysearchrate); CV_RegisterVar(&cv_showfocuslost); CV_RegisterVar(&cv_pauseifunfocused); @@ -1011,12 +994,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_addons_search_type); CV_RegisterVar(&cv_addons_search_case); - // WARNING: the order is important when initialising mouse2 - // we need the mouse2port - CV_RegisterVar(&cv_mouse2port); -#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) - CV_RegisterVar(&cv_mouse2opt); -#endif CV_RegisterVar(&cv_controlperkey); CV_RegisterVar(&cv_turnsmooth); @@ -1028,15 +1005,10 @@ void D_RegisterClientCommands(void) } CV_RegisterVar(&cv_usemouse); - CV_RegisterVar(&cv_usemouse2); CV_RegisterVar(&cv_invertmouse); - CV_RegisterVar(&cv_invertmouse2); CV_RegisterVar(&cv_mousesens); - CV_RegisterVar(&cv_mousesens2); CV_RegisterVar(&cv_mouseysens); - CV_RegisterVar(&cv_mouseysens2); //CV_RegisterVar(&cv_mousemove); - //CV_RegisterVar(&cv_mousemove2); for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 87d96b40d..3cffcf4bc 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -50,13 +50,6 @@ extern consvar_t cv_joyport2; #endif extern consvar_t cv_joyscale[4]; //MAXSPLITSCREENPLAYERS -// splitscreen with second mouse -extern consvar_t cv_mouse2port; -extern consvar_t cv_usemouse2; -#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) -extern consvar_t cv_mouse2opt; -#endif - // normally in p_mobj but the .h is not read extern consvar_t cv_itemrespawntime; extern consvar_t cv_itemrespawn; diff --git a/src/dummy/i_system.c b/src/dummy/i_system.c index a293a8d30..f5d6ca286 100644 --- a/src/dummy/i_system.c +++ b/src/dummy/i_system.c @@ -92,8 +92,6 @@ void I_OutputMsg(const char *error, ...) void I_StartupMouse(void){} -void I_StartupMouse2(void){} - void I_StartupKeyboard(void){} INT32 I_GetKey(void) @@ -146,8 +144,6 @@ void I_GetJoystickEvents(void){} void I_GetJoystick2Events(void){} -void I_GetMouseEvents(void){} - char *I_GetEnv(const char *name) { (void)name; diff --git a/src/g_game.c b/src/g_game.c index 2231b1148..0d7862564 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -397,13 +397,7 @@ consvar_t cv_growmusic = {"growmusic", "On", CV_SAVE, powermusic_cons_t, NULL, consvar_t cv_supermusic = {"supermusic", "On", CV_SAVE, powermusic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_invertmouse = {"invertmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_invertmouse2 = {"invertmouse2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -/*consvar_t cv_alwaysfreelook = {"alwaysmlook", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_alwaysfreelook2 = {"alwaysmlook2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasefreelook = {"chasemlook", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasefreelook2 = {"chasemlook2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mousemove = {"mousemove", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mousemove2 = {"mousemove2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};*/ +//consvar_t cv_mousemove = {"mousemove", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t joyaxis_cons_t[] = {{0, "None"}, {1, "Left X"}, {2, "Left Y"}, {-1, "Left X-"}, {-2, "Left Y-"}, @@ -1317,7 +1311,6 @@ static void G_DoLoadLevel(boolean resetplayer) joy4xmove[i] = joy4ymove[i] = 0; } mousex = mousey = 0; - mouse2x = mouse2y = 0; // clear hud messages remains (usually from game startup) CON_ClearHUD(); diff --git a/src/g_game.h b/src/g_game.h index 70f6e6ab4..6723e9ba6 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -115,8 +115,7 @@ extern consvar_t cv_songcredits; extern consvar_t cv_showfreeplay; extern consvar_t cv_growmusic, cv_supermusic; extern consvar_t cv_pauseifunfocused; -extern consvar_t cv_invertmouse/*, cv_alwaysfreelook, cv_chasefreelook, cv_mousemove*/; -extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2*/; +extern consvar_t cv_invertmouse; extern consvar_t cv_turnaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS]; diff --git a/src/g_input.c b/src/g_input.c index 788d50ffb..959dc5416 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -33,9 +33,7 @@ static CV_PossibleValue_t turnsmooth_cons_t[] = {{2, "Slow"}, {1, "Fast"}, {0, " // mouse values are used once consvar_t cv_mousesens = {"mousesens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mousesens2 = {"mousesens2", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mouseysens2 = {"mouseysens2", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_turnsmooth = {"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -125,8 +123,6 @@ static void led_off_handle4(void) INT32 mousex, mousey; INT32 mlooky; // like mousey but with a custom sensitivity for mlook -INT32 mouse2x, mouse2y, mlook2y; - // joystick values are repeated INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], joy2ymove[JOYAXISSET], joy3xmove[JOYAXISSET], joy3ymove[JOYAXISSET], joy4xmove[JOYAXISSET], joy4ymove[JOYAXISSET]; @@ -148,7 +144,6 @@ typedef struct } dclick_t; static dclick_t mousedclicks[MOUSEBUTTONS]; static dclick_t joydclicks[JOYBUTTONS + JOYHATS*4]; -static dclick_t mouse2dclicks[MOUSEBUTTONS]; static dclick_t joy2dclicks[JOYBUTTONS + JOYHATS*4]; static dclick_t joy3dclicks[JOYBUTTONS + JOYHATS*4]; static dclick_t joy4dclicks[JOYBUTTONS + JOYHATS*4]; @@ -233,14 +228,6 @@ void G_MapEventsToControls(event_t *ev) if (ev->data3 != INT32_MAX) joy4ymove[i] = ev->data3; break; - case ev_mouse2: // buttons are virtual keys - if (menuactive || CON_Ready() || chat_on) - break; - mouse2x = (INT32)(ev->data2*((cv_mousesens2.value*cv_mousesens2.value)/110.0f + 0.1f)); - mouse2y = (INT32)(ev->data3*((cv_mousesens2.value*cv_mousesens2.value)/110.0f + 0.1f)); - mlook2y = (INT32)(ev->data3*((cv_mouseysens2.value*cv_mousesens2.value)/110.0f + 0.1f)); - break; - default: break; } @@ -258,12 +245,6 @@ void G_MapEventsToControls(event_t *ev) gamekeydown[KEY_DBLJOY1+i] = flag; } - for (i = 0; i < MOUSEBUTTONS; i++) - { - flag = G_CheckDoubleClick(gamekeydown[KEY_2MOUSE1+i], &mouse2dclicks[i]); - gamekeydown[KEY_DBL2MOUSE1+i] = flag; - } - for (i = 0; i < JOYBUTTONS + JOYHATS*4; i++) { flag = G_CheckDoubleClick(gamekeydown[KEY_2JOY1+i], &joy2dclicks[i]); @@ -401,18 +382,8 @@ static keyname_t keynames[] = {KEY_MOUSE1+5,"MOUSE6"}, {KEY_MOUSE1+6,"MOUSE7"}, {KEY_MOUSE1+7,"MOUSE8"}, - {KEY_2MOUSE1+0,"SEC_MOUSE2"}, // BP: sorry my mouse handler swap button 1 and 2 - {KEY_2MOUSE1+1,"SEC_MOUSE1"}, - {KEY_2MOUSE1+2,"SEC_MOUSE3"}, - {KEY_2MOUSE1+3,"SEC_MOUSE4"}, - {KEY_2MOUSE1+4,"SEC_MOUSE5"}, - {KEY_2MOUSE1+5,"SEC_MOUSE6"}, - {KEY_2MOUSE1+6,"SEC_MOUSE7"}, - {KEY_2MOUSE1+7,"SEC_MOUSE8"}, {KEY_MOUSEWHEELUP, "Wheel 1 UP"}, {KEY_MOUSEWHEELDOWN, "Wheel 1 Down"}, - {KEY_2MOUSEWHEELUP, "Wheel 2 UP"}, - {KEY_2MOUSEWHEELDOWN, "Wheel 2 Down"}, {KEY_JOY1+0, "JOY1"}, {KEY_JOY1+1, "JOY2"}, @@ -423,7 +394,7 @@ static keyname_t keynames[] = {KEY_JOY1+6, "JOY7"}, {KEY_JOY1+7, "JOY8"}, {KEY_JOY1+8, "JOY9"}, - + #if !defined (NOMOREJOYBTN_1S) // we use up to 32 buttons in DirectInput {KEY_JOY1+9, "JOY10"}, @@ -476,14 +447,6 @@ static keyname_t keynames[] = {KEY_DBLMOUSE1+5, "DBLMOUSE6"}, {KEY_DBLMOUSE1+6, "DBLMOUSE7"}, {KEY_DBLMOUSE1+7, "DBLMOUSE8"}, - {KEY_DBL2MOUSE1+0, "DBLSEC_MOUSE2"}, // BP: sorry my mouse handler swap button 1 and 2 - {KEY_DBL2MOUSE1+1, "DBLSEC_MOUSE1"}, - {KEY_DBL2MOUSE1+2, "DBLSEC_MOUSE3"}, - {KEY_DBL2MOUSE1+3, "DBLSEC_MOUSE4"}, - {KEY_DBL2MOUSE1+4, "DBLSEC_MOUSE5"}, - {KEY_DBL2MOUSE1+5, "DBLSEC_MOUSE6"}, - {KEY_DBL2MOUSE1+6, "DBLSEC_MOUSE7"}, - {KEY_DBL2MOUSE1+7, "DBLSEC_MOUSE8"}, {KEY_DBLJOY1+0, "DBLJOY1"}, {KEY_DBLJOY1+1, "DBLJOY2"}, @@ -868,7 +831,6 @@ static keyname_t keynames[] = {KEY_DBL4HAT1+13, "DBLFOR_HATDOWN4"}, {KEY_DBL4HAT1+14, "DBLFOR_HATLEFT4"}, {KEY_DBL4HAT1+15, "DBLFOR_HATRIGHT4"}, - }; static const char *gamecontrolname[num_gamecontrols] = diff --git a/src/g_input.h b/src/g_input.h index 124734004..505d210f8 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -41,12 +41,10 @@ typedef enum KEY_DBLJOY1 = KEY_DBLMOUSE1 + MOUSEBUTTONS, KEY_DBLHAT1 = KEY_DBLJOY1 + JOYBUTTONS, - KEY_2MOUSE1 = KEY_DBLHAT1 + JOYHATS*4, - KEY_2JOY1 = KEY_2MOUSE1 + MOUSEBUTTONS, + KEY_2JOY1 = KEY_DBLHAT1 + MOUSEBUTTONS, KEY_2HAT1 = KEY_2JOY1 + JOYBUTTONS, - KEY_DBL2MOUSE1 = KEY_2HAT1 + JOYHATS*4, - KEY_DBL2JOY1 = KEY_DBL2MOUSE1 + MOUSEBUTTONS, + KEY_DBL2JOY1 = KEY_2HAT1 + MOUSEBUTTONS, KEY_DBL2HAT1 = KEY_DBL2JOY1 + JOYBUTTONS, KEY_3JOY1 = KEY_DBL2HAT1 + JOYHATS*4, @@ -63,10 +61,8 @@ typedef enum KEY_MOUSEWHEELUP = KEY_DBL4HAT1 + JOYHATS*4, KEY_MOUSEWHEELDOWN = KEY_MOUSEWHEELUP + 1, - KEY_2MOUSEWHEELUP = KEY_MOUSEWHEELDOWN + 1, - KEY_2MOUSEWHEELDOWN = KEY_2MOUSEWHEELUP + 1, - NUMINPUTS = KEY_2MOUSEWHEELDOWN + 1, + NUMINPUTS = KEY_MOUSEWHEELDOWN + 1, } key_input_e; typedef enum @@ -110,7 +106,6 @@ typedef enum // mouse values are used once extern consvar_t cv_mousesens, cv_mouseysens; -extern consvar_t cv_mousesens2, cv_mouseysens2; extern consvar_t cv_controlperkey, cv_turnsmooth; extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS]; @@ -118,7 +113,6 @@ extern consvar_t cv_ledpowerup[MAXSPLITSCREENPLAYERS]; extern INT32 mousex, mousey; extern INT32 mlooky; //mousey with mlookSensitivity -extern INT32 mouse2x, mouse2y, mlook2y; extern INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], joy2ymove[JOYAXISSET], joy3xmove[JOYAXISSET], joy3ymove[JOYAXISSET], joy4xmove[JOYAXISSET], joy4ymove[JOYAXISSET]; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 9dc8d0df3..6cbc76624 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1154,7 +1154,7 @@ void HU_Ticker(void) || hu_redownloadinggamestate #endif ) - resynch_ticker++; //tic tic tic tic tic + resynch_ticker++; //tic tic tic tic tic HU_TickSongCredits(); } diff --git a/src/i_system.h b/src/i_system.h index 71c78efb8..3b6913c00 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -253,10 +253,6 @@ void I_UpdateMumble(const mobj_t *mobj, const listener_t listener); */ void I_StartupMouse(void); -/** \brief Startup the second mouse -*/ -void I_StartupMouse2(void); - /** \brief setup timer irq and user timer routine. */ void I_StartupTimer(void); @@ -319,10 +315,6 @@ const char *I_LocateWad(void); */ void I_GetJoystickEvents(UINT8 index); -/** \brief Mouses events -*/ -void I_GetMouseEvents(void); - char *I_GetEnv(const char *name); INT32 I_PutEnv(char *variable); diff --git a/src/m_menu.c b/src/m_menu.c index c18934f11..b31eb7f43 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -311,7 +311,7 @@ static void M_SetupMultiHandler(INT32 choice); // Split into multiple parts due to size // Controls menu_t OP_ControlsDef, OP_AllControlsDef; -menu_t OP_MouseOptionsDef, OP_Mouse2OptionsDef; +menu_t OP_MouseOptionsDef; menu_t OP_Joystick1Def, OP_Joystick2Def, OP_Joystick3Def, OP_Joystick4Def; menu_t OP_CustomCvarMenuDef; static void M_VideoModeMenu(INT32 choice); @@ -1374,15 +1374,12 @@ static menuitem_t OP_MouseOptionsMenu[] = { {IT_STRING | IT_CVAR, NULL, "Use Mouse", &cv_usemouse, 10}, - - //{IT_STRING | IT_CVAR, NULL, "First-Person MouseLook", &cv_alwaysfreelook, 30}, - //{IT_STRING | IT_CVAR, NULL, "Third-Person MouseLook", &cv_chasefreelook, 40}, - {IT_STRING | IT_CVAR, NULL, "Mouse Turning", &cv_mouseturn, 20}, + {IT_STRING | IT_CVAR, NULL, "Mouse Turning", &cv_mouseturn, 20}, {IT_STRING | IT_CVAR, NULL, "Invert Mouse", &cv_invertmouse, 30}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Mouse X Speed", &cv_mousesens, 40}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Mouse Y Speed", &cv_mouseysens, 50}, + NULL, "Mouse Y Speed", &cv_mouseysens, 50}, }; static const char* OP_MouseTooltips[] = @@ -1394,21 +1391,6 @@ static const char* OP_MouseTooltips[] = "Mouse vertical sensitivity.", }; -/*static menuitem_t OP_Mouse2OptionsMenu[] = -{ - {IT_STRING | IT_CVAR, NULL, "Use Mouse 2", &cv_usemouse2, 10}, - {IT_STRING | IT_CVAR, NULL, "Second Mouse Serial Port", - &cv_mouse2port, 20}, - {IT_STRING | IT_CVAR, NULL, "First-Person MouseLook", &cv_alwaysfreelook2, 30}, - {IT_STRING | IT_CVAR, NULL, "Third-Person MouseLook", &cv_chasefreelook2, 40}, - {IT_STRING | IT_CVAR, NULL, "Mouse Move", &cv_mousemove2, 50}, - {IT_STRING | IT_CVAR, NULL, "Invert Mouse", &cv_invertmouse2, 60}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Mouse X Speed", &cv_mousesens2, 70}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Mouse Y Speed", &cv_mouseysens2, 80}, -};*/ - static menuitem_t OP_VideoOptionsMenu[] = { {IT_STRING | IT_CALL, NULL, "Set Resolution...", M_VideoModeMenu, 10}, @@ -4017,7 +3999,7 @@ boolean M_Responder(event_t *ev) else { // dirty hack: for customising controls, I want only buttons/keys, not moves - if (ev->type == ev_mouse || ev->type == ev_mouse2 || ev->type == ev_joystick + if (ev->type == ev_mouse || ev->type == ev_joystick || ev->type == ev_joystick2 || ev->type == ev_joystick3 || ev->type == ev_joystick4) return true; if (routine) @@ -12319,7 +12301,6 @@ static void M_ChangecontrolResponse(event_t *ev) { // ignore mouse/joy movements, just get buttons case ev_mouse: - case ev_mouse2: case ev_joystick: case ev_joystick2: case ev_joystick3: @@ -12352,8 +12333,6 @@ static void M_ChangecontrolResponse(event_t *ev) setupcontrols[control][found] = ch-KEY_MOUSE1+KEY_DBLMOUSE1; else if (ch >= KEY_JOY1 && ch <= KEY_JOY1+JOYBUTTONS) setupcontrols[control][found] = ch-KEY_JOY1+KEY_DBLJOY1; - else if (ch >= KEY_2MOUSE1 && ch <= KEY_2MOUSE1+MOUSEBUTTONS) - setupcontrols[control][found] = ch-KEY_2MOUSE1+KEY_DBL2MOUSE1; else if (ch >= KEY_2JOY1 && ch <= KEY_2JOY1+JOYBUTTONS) setupcontrols[control][found] = ch-KEY_2JOY1+KEY_DBL2JOY1; else if (ch >= KEY_3JOY1 && ch <= KEY_3JOY1+JOYBUTTONS) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 6be46fda6..fb6e54f8c 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -424,12 +424,6 @@ static INT32 joystick_started[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; */ SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS]; - -#ifdef HAVE_TERMIOS -static INT32 fdmouse2 = -1; -static INT32 mouse2_started = 0; -#endif - SDL_bool consolevent = SDL_FALSE; SDL_bool framebuffer = SDL_FALSE; @@ -1660,337 +1654,6 @@ void I_UpdateMumble(const mobj_t *mobj, const listener_t listener) #undef WINMUMBLE #endif // NOMUMBLE -#ifdef HAVE_TERMIOS - -void I_GetMouseEvents(void) -{ - static UINT8 mdata[5]; - static INT32 i = 0,om2b = 0; - INT32 di, j, mlp, button; - event_t event; - const INT32 mswap[8] = {0, 4, 1, 5, 2, 6, 3, 7}; - - if (!mouse2_started) return; - for (mlp = 0; mlp < 20; mlp++) - { - for (; i < 5; i++) - { - di = read(fdmouse2, mdata+i, 1); - if (di == -1) return; - } - if ((mdata[0] & 0xf8) != 0x80) - { - for (j = 1; j < 5; j++) - if ((mdata[j] & 0xf8) == 0x80) - for (i = 0; i < 5-j; i++) // shift - mdata[i] = mdata[i+j]; - if (i < 5) continue; - } - else - { - button = mswap[~mdata[0] & 0x07]; - for (j = 0; j < MOUSEBUTTONS; j++) - { - if (om2b & (1<> 4); - } - else if (bytenum == 3) - { - dx = (char)((combytes[0] & 3) << 6); - dy = (char)((combytes[0] & 12) << 4); - dx = (char)(dx + combytes[1]); - dy = (char)(dy + combytes[2]); - handlermouse2x+= dx; - handlermouse2y+= dy; - } - else if (bytenum == 4) // fourth UINT8 (logitech mouses) - { - if (buffer[i] & 32) - handlermouse2buttons |= 4; - else - handlermouse2buttons &= ~4; - } - } -} - -void I_GetMouseEvents(void) -{ - static UINT8 lastbuttons2 = 0; //mouse movement - event_t event; - - if (mouse2filehandle == INVALID_HANDLE_VALUE) - return; - - I_PoolMouse2(); - // post key event for buttons - if (handlermouse2buttons != lastbuttons2) - { - INT32 i, j = 1, k; - k = (handlermouse2buttons ^ lastbuttons2); // only changed bit to 1 - lastbuttons2 = (UINT8)handlermouse2buttons; - - for (i = 0; i < MOUSEBUTTONS; i++, j <<= 1) - if (k & j) - { - if (handlermouse2buttons & j) - event.type = ev_keydown; - else - event.type = ev_keyup; - event.data1 = KEY_2MOUSE1+i; - D_PostEvent(&event); - } - } - - if (handlermouse2x != 0 || handlermouse2y != 0) - { - event.type = ev_mouse2; - event.data1 = 0; -// event.data1 = buttons; // not needed - event.data2 = handlermouse2x << 1; - event.data3 = -handlermouse2y << 1; - handlermouse2x = 0; - handlermouse2y = 0; - - D_PostEvent(&event); - } -} -#else -void I_GetMouseEvents(void){}; -#endif - -// -// I_StartupMouse2 -// -void I_StartupMouse2(void) -{ -#ifdef HAVE_TERMIOS - struct termios m2tio; - size_t i; - INT32 dtr = -1, rts = -1;; - I_ShutdownMouse2(); - if (cv_usemouse2.value == 0) return; - if ((fdmouse2 = open(cv_mouse2port.string, O_RDONLY|O_NONBLOCK|O_NOCTTY)) == -1) - { - CONS_Printf(M_GetText("Error opening %s!\n"), cv_mouse2port.string); - return; - } - tcflush(fdmouse2, TCIOFLUSH); - m2tio.c_iflag = IGNBRK; - m2tio.c_oflag = 0; - m2tio.c_cflag = CREAD|CLOCAL|HUPCL|CS8|CSTOPB|B1200; - m2tio.c_lflag = 0; - m2tio.c_cc[VTIME] = 0; - m2tio.c_cc[VMIN] = 1; - tcsetattr(fdmouse2, TCSANOW, &m2tio); - for (i = 0; i < strlen(cv_mouse2opt.string); i++) - { - if (toupper(cv_mouse2opt.string[i]) == 'D') - { - if (cv_mouse2opt.string[i+1] == '-') - dtr = 0; - else - dtr = 1; - } - if (toupper(cv_mouse2opt.string[i]) == 'R') - { - if (cv_mouse2opt.string[i+1] == '-') - rts = 0; - else - rts = 1; - } - if (dtr != -1 || rts != -1) - { - INT32 c; - if (!ioctl(fdmouse2, TIOCMGET, &c)) - { - if (!dtr) - c &= ~TIOCM_DTR; - else if (dtr > 0) - c |= TIOCM_DTR; - } - if (!rts) - c &= ~TIOCM_RTS; - else if (rts > 0) - c |= TIOCM_RTS; - ioctl(fdmouse2, TIOCMSET, &c); - } - } - mouse2_started = 1; - I_AddExitFunc(I_ShutdownMouse2); -#elif defined (_WIN32) - DCB dcb; - - if (mouse2filehandle != INVALID_HANDLE_VALUE) - I_ShutdownMouse2(); - - if (cv_usemouse2.value == 0) - return; - - if (mouse2filehandle == INVALID_HANDLE_VALUE) - { - // COM file handle - mouse2filehandle = CreateFileA(cv_mouse2port.string, GENERIC_READ | GENERIC_WRITE, - 0, // exclusive access - NULL, // no security attrs - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (mouse2filehandle == INVALID_HANDLE_VALUE) - { - INT32 e = GetLastError(); - if (e == 5) - CONS_Alert(CONS_ERROR, M_GetText("Can't open %s: Access denied\n"), cv_mouse2port.string); - else - CONS_Alert(CONS_ERROR, M_GetText("Can't open %s: error %d\n"), cv_mouse2port.string, e); - return; - } - } - - // getevent when somthing happens - //SetCommMask(mouse2filehandle, EV_RXCHAR); - - // buffers - SetupComm(mouse2filehandle, MOUSECOMBUFFERSIZE, MOUSECOMBUFFERSIZE); - - // purge buffers - PurgeComm(mouse2filehandle, PURGE_TXABORT | PURGE_RXABORT - | PURGE_TXCLEAR | PURGE_RXCLEAR); - - // setup port to 1200 7N1 - dcb.DCBlength = sizeof (DCB); - - GetCommState(mouse2filehandle, &dcb); - - dcb.BaudRate = CBR_1200; - dcb.ByteSize = 7; - dcb.Parity = NOPARITY; - dcb.StopBits = ONESTOPBIT; - - dcb.fDtrControl = DTR_CONTROL_ENABLE; - dcb.fRtsControl = RTS_CONTROL_ENABLE; - - dcb.fBinary = TRUE; - dcb.fParity = TRUE; - - SetCommState(mouse2filehandle, &dcb); - I_AddExitFunc(I_ShutdownMouse2); -#endif -} - // // I_Tactile // diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 609afc30a..4f9549986 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1376,8 +1376,6 @@ void I_OsPolling(void) I_GetJoystickEvents(i); } - I_GetMouseEvents(); - I_GetEvent(); mod = SDL_GetModState(); From 543365f2961a12f1c4a00e2a63b05357037b50c2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 22:22:13 +0100 Subject: [PATCH 252/418] cv_invertmouse2 moment --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 0d7862564..572eca9ad 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -922,7 +922,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) case 2: G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); mouseaiming = player->spectator; - invertmouse = cv_invertmouse2.value; + invertmouse = false; break; case 3: G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); From 2b09e74dcf76ab49e80f1d7149f944206913158d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 18:53:26 +0100 Subject: [PATCH 253/418] kill aiming stuff in BuildTiccmd --- src/g_game.c | 67 ++++------------------------------------------------ 1 file changed, 4 insertions(+), 63 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 4692f84c2..3c511ee6d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -899,12 +899,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) INT32 laim, th, tspeed, forward, side, axis; // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming; - boolean invertmouse, usejoystick, kbl, rd; + boolean turnleft, turnright; + boolean usejoystick, rd; angle_t lang; static INT32 turnheld[MAXSPLITSCREENPLAYERS]; // for accelerative turning - static boolean keyboard_look[MAXSPLITSCREENPLAYERS]; // true if lookup/down using keyboard static boolean resetdown[MAXSPLITSCREENPLAYERS]; // don't cam reset every frame if (demo.playback) @@ -916,38 +915,28 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) camera_t *thiscam = &camera[forplayer]; const boolean freecam = camera[forplayer].freecam; - const boolean lookaxis = cv_lookaxis[forplayer].value; const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; lang = localangle[forplayer]; laim = localaiming[forplayer]; th = turnheld[forplayer]; - kbl = keyboard_look[forplayer]; rd = resetdown[forplayer]; switch (ssplayer) { case 2: G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); - mouseaiming = player->spectator; - invertmouse = cv_invertmouse2.value; break; case 3: G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); - mouseaiming = false; - invertmouse = false; break; case 4: G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); - mouseaiming = false; - invertmouse = false; break; case 1: default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver - mouseaiming = player->spectator; - invertmouse = cv_invertmouse.value; break; } @@ -957,7 +946,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching) { cmd->angleturn = (INT16)(lang >> 16); - cmd->aiming = G_ClipAimingPitch(&laim); + cmd->aiming = 0; return; } @@ -1120,54 +1109,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else rd = false; - // spectator aiming shit, ahhhh... - { - INT32 player_invert = invertmouse ? -1 : 1; - INT32 screen_invert = - (player->mo && (player->mo->eflags & MFE_VERTICALFLIP) - && (!thiscam->chase || player->pflags & PF_FLIPCAM)) // because chasecam's not inverted - ? -1 : 1; // set to -1 or 1 to multiply - - // mouse look stuff (mouse look is not the same as mouse aim) - if (mouseaiming && player->spectator) - { - kbl = false; - - // looking up/down - laim += (mlooky<<19)*player_invert*screen_invert; - } - - axis = JoyAxis(AXISLOOK, ssplayer); - if (analogjoystickmove && axis != 0 && lookaxis && player->spectator) - laim += (axis<<16) * screen_invert; - - // spring back if not using keyboard neither mouselookin' - if (!kbl && !lookaxis && !mouseaiming) - laim = 0; - - if (player->spectator) - { - if (InputDown(gc_lookup, ssplayer) || (gamepadjoystickmove && axis < 0)) - { - laim += KB_LOOKSPEED * screen_invert; - kbl = true; - } - else if (InputDown(gc_lookdown, ssplayer) || (gamepadjoystickmove && axis > 0)) - { - laim -= KB_LOOKSPEED * screen_invert; - kbl = true; - } - } - - if (InputDown(gc_centerview, ssplayer)) // No need to put a spectator limit on this one though :V - laim = 0; - - // accept no mlook for network games - if (!cv_allowmlook.value) - laim = 0; - - cmd->aiming = G_ClipAimingPitch(&laim); - } + cmd->aiming = 0; mousex = mousey = mlooky = 0; @@ -1219,7 +1161,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { localangle[forplayer] = lang; localaiming[forplayer] = laim; - keyboard_look[forplayer] = kbl; turnheld[forplayer] = th; resetdown[forplayer] = rd; axis = JoyAxis(AXISLOOKBACK, ssplayer); From 3bbdd1ea720f99d0bb64d40ed803d79bbbcc0a3c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 22:26:07 +0100 Subject: [PATCH 254/418] e better play it safe --- src/g_game.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 3c511ee6d..b527009db 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -946,7 +946,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching) { cmd->angleturn = (INT16)(lang >> 16); - cmd->aiming = 0; + cmd->aiming = G_ClipAimingPitch(&laim); return; } @@ -1109,7 +1109,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else rd = false; - cmd->aiming = 0; + cmd->aiming = G_ClipAimingPitch(&laim); mousex = mousey = mlooky = 0; From 12f5bd141daf6ff4be7baacc8c3fa991f982d624 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Jan 2025 00:50:21 +0100 Subject: [PATCH 255/418] =?UTF-8?q?use=20SRB2.2=C2=B4s=20logging=20system?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - creates a new logfile each start instead of overwriting it everytime --- src/filesrch.c | 2 +- src/m_misc.c | 91 +++++++++++++++++++++++++++++++++ src/m_misc.h | 5 ++ src/sdl/i_main.c | 123 ++++++++++++++++++++++++++++++++++++--------- src/sdl/i_system.c | 45 +++++++++++++++++ 5 files changed, 241 insertions(+), 25 deletions(-) diff --git a/src/filesrch.c b/src/filesrch.c index 84766f395..8af9118ba 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -797,7 +797,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut) } else if (ext == EXT_TXT) { - if (!strcmp(dent->d_name, "log.txt") || !strcmp(dent->d_name, "errorlog.txt")) + if (!strncmp(dent->d_name, "log-", 4) || !strcmp(dent->d_name, "errorlog.txt")) ext |= EXT_LOADED; } diff --git a/src/m_misc.c b/src/m_misc.c index a3768120d..6e6658a0a 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -2076,3 +2076,94 @@ const char *M_FileError(FILE *fp) else return "end-of-file"; } + +/** Return the number of parts of this path. +*/ +int M_PathParts(const char *path) +{ + int n; + const char *p; + const char *t; + if (path == NULL) + return 0; + for (n = 0, p = path ;; ++n) + { + t = p; + if (( p = strchr(p, PATHSEP[0]) )) + p += strspn(p, PATHSEP); + else + { + if (*t)/* there is something after the final delimiter */ + n++; + break; + } + } + return n; +} + +/** Check whether a path is an absolute path. +*/ +boolean M_IsPathAbsolute(const char *path) +{ +#ifdef _WIN32 + return ( strncmp(&path[1], ":\\", 2) == 0 ); +#else + return ( path[0] == '/' ); +#endif +} + +/** I_mkdir for each part of the path. +*/ +void M_MkdirEachUntil(const char *cpath, int start, int end, int mode) +{ + char path[MAX_WADPATH]; + char *p; + char *t; + + if (end > 0 && end <= start) + return; + + strlcpy(path, cpath, sizeof path); +#ifdef _WIN32 + if (strncmp(&path[1], ":\\", 2) == 0) + p = &path[3]; + else +#endif + p = path; + + if (end > 0) + end -= start; + + for (; start > 0; --start) + { + p += strspn(p, PATHSEP); + if (!( p = strchr(p, PATHSEP[0]) )) + return; + } + p += strspn(p, PATHSEP); + for (;;) + { + if (end > 0 && !--end) + break; + + t = p; + if (( p = strchr(p, PATHSEP[0]) )) + { + *p = '\0'; + I_mkdir(path, mode); + *p = PATHSEP[0]; + p += strspn(p, PATHSEP); + } + else + { + if (*t) + I_mkdir(path, mode); + break; + } + } +} + +void M_MkdirEach(const char *path, int start, int mode) +{ + M_MkdirEachUntil(path, start, -1, mode); +} diff --git a/src/m_misc.h b/src/m_misc.h index c858ae128..a84493ee1 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -99,6 +99,11 @@ void strcatbf(char *s1, const char *s2, const char *s3); const char *M_FileError(FILE *handle); +int M_PathParts (const char *path); +boolean M_IsPathAbsolute (const char *path); +void M_MkdirEach (const char *path, int start, int mode); +void M_MkdirEachUntil (const char *path, int start, int end, int mode); + // counting bits, for weapon ammo code, usually FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size); diff --git a/src/sdl/i_main.c b/src/sdl/i_main.c index 1d2e2395f..d6a007919 100644 --- a/src/sdl/i_main.c +++ b/src/sdl/i_main.c @@ -20,12 +20,19 @@ #include "../doomdef.h" #include "../m_argv.h" #include "../d_main.h" +#include "../m_misc.h"/* path shit */ #include "../i_system.h" -#ifdef __GNUC__ +#if defined (__GNUC__) || defined (__unix__) #include #endif +#ifdef __unix__ +#include +#endif + +#include "time.h" // For log timestamps + #ifdef HAVE_SDL #ifdef HAVE_TTF @@ -89,6 +96,93 @@ ChDirToExe (void) } #endif +#ifdef LOGMESSAGES +static void InitLogging(void) +{ + const char *logdir = NULL; + time_t my_time; + struct tm * timeinfo; + const char *format; + const char *reldir; + int left; + boolean fileabs; +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) + const char *link; +#endif + + logdir = D_Home(); + + my_time = time(NULL); + timeinfo = localtime(&my_time); + + if (M_CheckParm("-logfile") && M_IsNextParm()) + { + format = M_GetNextParm(); + fileabs = M_IsPathAbsolute(format); + } + else + { + format = "log-%Y-%m-%d_%H-%M-%S.txt"; + fileabs = false; + } + + if (fileabs) + { + strftime(logfilename, sizeof logfilename, format, timeinfo); + } + else + { + if (M_CheckParm("-logdir") && M_IsNextParm()) + reldir = M_GetNextParm(); + else + reldir = "logs"; + + if (M_IsPathAbsolute(reldir)) + { + left = snprintf(logfilename, sizeof logfilename, + "%s"PATHSEP, reldir); + } + else +#ifdef DEFAULTDIR + if (logdir) + { + left = snprintf(logfilename, sizeof logfilename, + "%s"PATHSEP DEFAULTDIR PATHSEP"%s"PATHSEP, logdir, reldir); + } + else +#endif/*DEFAULTDIR*/ + { + left = snprintf(logfilename, sizeof logfilename, + "."PATHSEP"%s"PATHSEP, reldir); + } + + strftime(&logfilename[left], sizeof logfilename - left, + format, timeinfo); + } + + M_MkdirEachUntil(logfilename, + M_PathParts(logdir) - 1, + M_PathParts(logfilename) - 1, 0755); + +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) + logstream = fopen(logfilename, "w"); +#ifdef DEFAULTDIR + if (logdir) + link = va("%s/"DEFAULTDIR"/latest-log.txt", logdir); + else +#endif/*DEFAULTDIR*/ + link = "latest-log.txt"; + unlink(link); + if (symlink(logfilename, link) == -1) + { + I_OutputMsg("Error symlinking latest-log.txt: %s\n", strerror(errno)); + } +#else/*defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)*/ + logstream = fopen("latest-log.txt", "wt+"); +#endif/*defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)*/ +} +#endif + /** \brief The main function @@ -107,7 +201,6 @@ int SDL_main(int argc, char **argv) int main(int argc, char **argv) #endif { - const char *logdir = NULL; myargc = argc; myargv = argv; /// \todo pull out path to exe from this string @@ -136,36 +229,18 @@ int main(int argc, char **argv) ChDirToExe(); #endif - logdir = D_Home(); - #ifdef LOGMESSAGES -#ifdef DEFAULTDIR - if (logdir) - strcpy(logfilename, va("%s/"DEFAULTDIR"/log.txt",logdir)); - else -#endif - strcpy(logfilename, "./log.txt"); - - logstream = fopen(logfilename, "wt"); -#endif + if (!M_CheckParm("-nolog")) + InitLogging(); +#endif/*LOGMESSAGES*/ //I_OutputMsg("I_StartupSystem() ...\n"); I_StartupSystem(); #if defined (_WIN32) { -#if 0 // just load the DLL - p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsDebuggerPresent"); - if ((!pfnIsDebuggerPresent || !pfnIsDebuggerPresent()) -#ifdef BUGTRAP - && !InitBugTrap() -#endif - ) -#endif - { #ifdef DRMINGW - ExcHndlInit(); + ExcHndlInit(); #endif - } } #endif diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index fb6e54f8c..d40359c8a 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2174,6 +2174,48 @@ void I_RemoveExitFunc(void (*func)()) } } +#if !(defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)) +static void Shittycopyerror(const char *name) +{ + I_OutputMsg( + "Error copying log file: %s: %s\n", + name, + strerror(errno) + ); +} + +static void Shittylogcopy(void) +{ + char buf[8192]; + FILE *fp; + size_t r; + if (fseek(logstream, 0, SEEK_SET) == -1) + { + Shittycopyerror("fseek"); + } + else if (( fp = fopen(logfilename, "wt") )) + { + while (( r = fread(buf, 1, sizeof buf, logstream) )) + { + if (fwrite(buf, 1, r, fp) < r) + { + Shittycopyerror("fwrite"); + break; + } + } + if (ferror(logstream)) + { + Shittycopyerror("fread"); + } + fclose(fp); + } + else + { + Shittycopyerror(logfilename); + } +} +#endif/*!(defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON))*/ + // // Closes down everything. This includes restoring the initial // palette and video mode, and removing whatever mouse, keyboard, and @@ -2196,6 +2238,9 @@ void I_ShutdownSystem(void) if (logstream) { I_OutputMsg("I_ShutdownSystem(): end of logstream.\n"); +#if !(defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)) + Shittylogcopy(); +#endif fclose(logstream); logstream = NULL; } From 81a0ba08bd0f94150e5f02369cc24d750fb224ca Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Jan 2025 01:35:10 +0100 Subject: [PATCH 256/418] use SRB2.2s general folder structure - seperate addons folder (download folder remains in home directory unlike RR) - seperate gif and screenshot folders --- src/d_main.c | 7 +++++-- src/d_netcmd.c | 2 ++ src/m_menu.c | 53 +++++++++++++++++++++++++++++--------------------- src/m_menu.h | 3 +++ src/m_misc.c | 44 ++++++++++++++++++++++++++++------------- src/m_misc.h | 2 +- 6 files changed, 72 insertions(+), 39 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 2a221a29a..f31c6bda3 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -134,6 +134,7 @@ char srb2home[256] = "."; char srb2path[256] = "."; boolean usehome = true; const char *pandf = "%s" PATHSEP "%s"; +static char addonsdir[MAX_WADPATH]; // // EVENT HANDLING @@ -1438,8 +1439,6 @@ void D_SRB2Main(void) // can't use sprintf since there is %u in savegamename strcatbf(savegamename, srb2home, PATHSEP); - - I_mkdir(srb2home, 0700); #else snprintf(srb2home, sizeof srb2home, "%s", userhome); snprintf(downloaddir, sizeof downloaddir, "%s", userhome); @@ -1476,6 +1475,10 @@ void D_SRB2Main(void) } } + // Create addons dir + snprintf(addonsdir, sizeof addonsdir, "%s%s%s", srb2home, PATHSEP, "addons"); + I_mkdir(addonsdir, 0755); + D_SetupProtocol(); // seed M_Random because it is necessary; seed P_Random for scripts that diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 23fe91bce..bcfc02a28 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -860,6 +860,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_screenshot_option); CV_RegisterVar(&cv_screenshot_folder); CV_RegisterVar(&cv_moviemode); + CV_RegisterVar(&cv_movie_option); + CV_RegisterVar(&cv_movie_folder); // PNG variables CV_RegisterVar(&cv_zlib_level); CV_RegisterVar(&cv_zlib_memory); diff --git a/src/m_menu.c b/src/m_menu.c index b31eb7f43..57a3890d3 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1770,37 +1770,40 @@ static menuitem_t OP_DataOptionsMenu[] = static menuitem_t OP_ScreenshotOptionsMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_screenshot_option, 10}, - {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 20}, + {IT_HEADER, NULL, "Screenshots (F8)", NULL, 5}, + {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_screenshot_option, 15}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 25}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 55}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 65}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 75}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 85}, - {IT_HEADER, NULL, "Screenshots (F8)", NULL, 50}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 60}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 70}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 80}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 90}, + {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 100}, + {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_movie_option, 110}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_movie_folder, 120}, + {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 150}, - {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 105}, - {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 115}, + {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 160}, + {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 170}, - {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 125}, - {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 135}, - - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 125}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 135}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 145}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 155}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 160}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 170}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 180}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 190}, }; enum { - op_screenshot_folder = 1, - op_screenshot_capture = 8, - op_screenshot_gif_start = 9, - op_screenshot_gif_end = 10, - op_screenshot_apng_start = 11, - op_screenshot_apng_end = 14, + op_screenshot_folder = 2, + op_movie_folder = 9, + op_screenshot_capture = 10, + op_screenshot_gif_start = 11, + op_screenshot_gif_end = 12, + op_screenshot_apng_start = 13, + op_screenshot_apng_end = 16, }; + static menuitem_t OP_EraseDataMenu[] = { {IT_STRING | IT_CALL, NULL, "Erase Record Data", M_EraseData, 10}, @@ -3453,6 +3456,12 @@ void Addons_option_Onchange(void) (cv_addons_option.value == 3 ? IT_CVAR|IT_STRING|IT_CV_STRING : IT_DISABLED); } +void Moviemode_option_Onchange(void) +{ + OP_ScreenshotOptionsMenu[op_movie_folder].status = + (cv_movie_option.value == 3 ? IT_CVAR|IT_STRING|IT_CV_STRING : IT_DISABLED); +} + void PDistort_menu_Onchange(void) { if (!cv_sloperoll.value) diff --git a/src/m_menu.h b/src/m_menu.h index 72864c669..4ee8615ce 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -286,6 +286,9 @@ void Screenshot_option_Onchange(void); // Addons menu updating void Addons_option_Onchange(void); +// Moviemode menu updating +void Moviemode_option_Onchange(void); + // Player distortion menu updating void PDistort_menu_Onchange(void); diff --git a/src/m_misc.c b/src/m_misc.c index 6e6658a0a..c6dd4175c 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -110,6 +110,9 @@ consvar_t cv_screenshot_folder = {"screenshot_folder", "", CV_SAVE, NULL, NULL, static CV_PossibleValue_t moviemode_cons_t[] = {{MM_GIF, "GIF"}, {MM_APNG, "aPNG"}, {MM_SCREENSHOT, "Screenshots"}, {0, NULL}}; consvar_t cv_moviemode = {"moviemode_mode", "GIF", CV_SAVE|CV_CALL, moviemode_cons_t, Moviemode_mode_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_movie_option = {"movie_option", "Default", CV_SAVE|CV_CALL, screenshot_cons_t, Moviemode_option_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_movie_folder = {"movie_folder", "", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t zlib_mem_level_t[] = { {1, "(Min Memory) 1"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"}, @@ -1144,19 +1147,25 @@ static inline moviemode_t M_StartMovieGIF(const char *pathname) void M_StartMovie(void) { #if NUMSCREENS > 2 - const char *pathname = "."; + char pathname[MAX_WADPATH]; if (moviemode) return; - if (cv_screenshot_option.value == 0) - pathname = usehome ? srb2home : srb2path; - else if (cv_screenshot_option.value == 1) - pathname = srb2home; - else if (cv_screenshot_option.value == 2) - pathname = srb2path; - else if (cv_screenshot_option.value == 3 && *cv_screenshot_folder.string != '\0') - pathname = cv_screenshot_folder.string; + if (cv_movie_option.value == 0) + strcpy(pathname, usehome ? srb2home : srb2path); + else if (cv_movie_option.value == 1) + strcpy(pathname, srb2home); + else if (cv_movie_option.value == 2) + strcpy(pathname, srb2path); + else if (cv_movie_option.value == 3 && *cv_movie_folder.string != '\0') + strcpy(pathname, cv_movie_folder.string); + + if (cv_movie_option.value != 3) + { + strcat(pathname, PATHSEP"gifs"PATHSEP); + I_mkdir(pathname, 0755); + } if (rendermode == render_none) I_Error("Can't make a movie without a render system\n"); @@ -1482,7 +1491,8 @@ void M_ScreenShot(void) void M_DoScreenShot(void) { #if NUMSCREENS > 2 - const char *freename = NULL, *pathname = "."; + const char *freename = NULL; + char pathname[MAX_WADPATH]; boolean ret = false; UINT8 *linear = NULL; @@ -1494,13 +1504,19 @@ void M_DoScreenShot(void) return; if (cv_screenshot_option.value == 0) - pathname = usehome ? srb2home : srb2path; + strcpy(pathname, usehome ? srb2home : srb2path); else if (cv_screenshot_option.value == 1) - pathname = srb2home; + strcpy(pathname, srb2home); else if (cv_screenshot_option.value == 2) - pathname = srb2path; + strcpy(pathname, srb2path); else if (cv_screenshot_option.value == 3 && *cv_screenshot_folder.string != '\0') - pathname = cv_screenshot_folder.string; + strcpy(pathname, cv_screenshot_folder.string); + + if (cv_screenshot_option.value != 3) + { + strcat(pathname, PATHSEP"screenshots"PATHSEP); + I_mkdir(pathname, 0755); + } #ifdef USE_PNG freename = Newsnapshotfile(pathname,"png"); diff --git a/src/m_misc.h b/src/m_misc.h index a84493ee1..013da2235 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -30,7 +30,7 @@ typedef enum { extern moviemode_t moviemode; extern consvar_t cv_screenshot_option, cv_screenshot_folder; -extern consvar_t cv_moviemode; +extern consvar_t cv_moviemode, cv_movie_folder, cv_movie_option; extern consvar_t cv_zlib_memory, cv_zlib_level, cv_zlib_strategy, cv_zlib_window_bits; extern consvar_t cv_zlib_memorya, cv_zlib_levela, cv_zlib_strategya, cv_zlib_window_bitsa; extern consvar_t cv_apng_delay; From 9634bc99bdbb5a2274af991b022c764a38b24532 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 21 Jan 2025 17:38:09 +0300 Subject: [PATCH 257/418] Check for spectator in K_StatRound --- src/k_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_stats.c b/src/k_stats.c index 0af547780..538b4e3e3 100644 --- a/src/k_stats.c +++ b/src/k_stats.c @@ -74,7 +74,7 @@ void K_StatRound(void) ++numplayers; } - if (numplayers > 1) + if (numplayers > 1 && !players[consoleplayer].spectator) { if (players[consoleplayer].kartstuff[k_position] == 1) kartstats.totalwins++; From f8472721ee672fc23243777550890864981f192f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Jan 2025 16:54:28 +0100 Subject: [PATCH 258/418] fix level statistics page controls --- src/m_menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 341dcdcd6..0c1882fef 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8866,7 +8866,7 @@ static void M_HandleLevelStats(INT32 choice) switch (choice) { case KEY_DOWNARROW: - if (statsCurrentPage != 0) // Must be on level stats page + if (statsCurrentPage != 1) // Must be on level stats page break; S_StartSound(NULL, sfx_menu1); if (statsLocation < statsMax) @@ -8874,7 +8874,7 @@ static void M_HandleLevelStats(INT32 choice) break; case KEY_UPARROW: - if (statsCurrentPage != 0) // Must be on level stats page + if (statsCurrentPage != 1) // Must be on level stats page break; S_StartSound(NULL, sfx_menu1); if (statsLocation) @@ -8897,14 +8897,14 @@ static void M_HandleLevelStats(INT32 choice) break; case KEY_PGDN: - if (statsCurrentPage != 0) // Must be on level stats page + if (statsCurrentPage != 1) // Must be on level stats page break; S_StartSound(NULL, sfx_menu1); statsLocation += (statsLocation+13 >= statsMax) ? statsMax-statsLocation : 13; break; case KEY_PGUP: - if (statsCurrentPage != 0) // Must be on level stats page + if (statsCurrentPage != 1) // Must be on level stats page break; S_StartSound(NULL, sfx_menu1); statsLocation -= (statsLocation < 13) ? statsLocation : 13; From 23443b26329bfcd682464a86611946e343321dcb Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 22 Jan 2025 16:46:58 +0100 Subject: [PATCH 259/418] remove redundand FTransform field --- src/hardware/hw_defs.h | 2 +- src/hardware/hw_main.c | 3 +-- src/hardware/r_opengl/r_opengl.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 85e204961..c2b0e6d85 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -140,7 +140,7 @@ typedef struct #endif FLOAT scalex, scaley, scalez; FLOAT spritexscale, spriteyscale; - FLOAT fovxangle, fovyangle; + FLOAT fovangle; UINT8 splitscreen; boolean flip; // screenflip boolean roll; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 77e36c4c8..8f31d6db9 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5250,8 +5250,7 @@ void HWR_SetTransform(float fpov) gl_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT)); gl_viewludcos = FIXED_TO_FLOAT(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT)); - atransform.fovxangle = fpov; // Tails - atransform.fovyangle = fpov; // Tails + atransform.fovangle = fpov; // Tails HWR_RollTransform(&atransform, viewroll); atransform.splitscreen = splitscreen; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 3d40f4c03..9c5ce4a0f 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2790,7 +2790,7 @@ void GL_SetTransform(FTransform *stransform) if (stransform) { - used_fov = stransform->fovxangle; + used_fov = stransform->fovangle; shearing = stransform->shearing; // keep a trace of the transformation for md2 memcpy(&md2_transform, stransform, sizeof (md2_transform)); From ea82f89b532d70955c554c9e44bba40a9de619b2 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 22 Jan 2025 17:24:03 +0100 Subject: [PATCH 260/418] bruh --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 62988ceef..062edcb2a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4453,7 +4453,7 @@ static void HWR_AddPrecipitationSprites(void) { for (by = yl; by <= yh; by++) { - for (th = precipblocklinks[(by * bmapwidth) + bx]; th; th = th->bnext) + for (th = precipblocklinks[(by * bmapwidth) + bx]; th; th = next) { // Store this beforehand because HWR_ProjectPrecipitationSprite may free th (see P_PrecipThinker) next = th->bnext; From 062caa8f53bf06486c14bdaa20ad97a83e9b5165 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 22 Jan 2025 18:04:50 +0100 Subject: [PATCH 261/418] skip some stuffs when theres no portals skip some portal checking incases wheres no portals --- src/hardware/hw_main.c | 49 +++++++++++------------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8f31d6db9..62988ceef 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2317,6 +2317,9 @@ static void HWR_AddLine(seg_t *line) gl_backsector = line->backsector; + if (!cv_glportals.value || !gl_maphasportals) + goto doaddline; + // do extra checks on the seg when rendering portals: // don't render segs that are behind the portal destination line if (portalclipline && @@ -2778,29 +2781,6 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v return false; } -static inline void HWR_PortalSubsector(seg_t *line, subsector_t *sub, INT16 count) -{ - if (line) - { - //Hurdler: at this point validcount must be the same, but is not because - // gl_frontsector doesn't point anymore to sub->sector due to - // the call gl_frontsector = R_FakeFlat(...) - // if it's not done, the sprite is drawn more than once, - // what looks really bad with translucency or dynamic light, - // without talking about the overdraw of course. - sub->sector->validcount = validcount;/// \todo fix that in a better way - - while (count--) - { - if (!line->polyseg) // ignore segs that belong to polyobjects - HWR_AddLine(line); - line++; - } - } - - sub->validcount = validcount; -} - // -----------------+ // HWR_Subsector : Determine floor/ceiling planes. // : Add sprites of things in sector. @@ -2853,8 +2833,7 @@ static void HWR_Subsector(size_t num) if (gl_portal_state == GLPORTAL_SEARCH) { - HWR_PortalSubsector(line, sub, count); - return; + goto doaddline; } floorcolormap = ceilingcolormap = gl_frontsector->extra_colormap; @@ -3090,6 +3069,7 @@ static void HWR_Subsector(size_t num) } } +doaddline: // Hurdler: here interesting things are happening! // we have just drawn the floor and ceiling // we now draw the sprites first and then the walls @@ -3110,9 +3090,9 @@ static void HWR_Subsector(size_t num) while (count--) { - if (!line->polyseg) // ignore segs that belong to polyobjects - HWR_AddLine(line); - line++; + if (!line->polyseg) // ignore segs that belong to polyobjects + HWR_AddLine(line); + line++; } } @@ -5288,6 +5268,8 @@ void HWR_SetStencilState(int state, int level) GL_SetSpecialState(HWD_SET_PORTAL_MODE, state); } +typedef void (*bspfunc)(INT32 bspnum); + // Renders the current viewpoint, though takes portal arguments for recursive portals. void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *player, int stencil_level, boolean allow_portals) { @@ -5295,6 +5277,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl const boolean skybox = (skyboxmo[0] && cv_skybox.value); const boolean useportals = cv_glportals.value && gl_maphasportals && allow_portals; + bspfunc bspFunc = portalclipline ? HWR_RenderPortalBSPNode : HWR_RenderBSPNode; portallist.base = portallist.cap = NULL; @@ -5314,10 +5297,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl validcount++; // no actual rendering happens - if (portalclipline) - HWR_RenderPortalBSPNode((INT32)numnodes-1); - else - HWR_RenderBSPNode((INT32)numnodes-1); + bspFunc((INT32)numnodes-1); // for each found portal: // note: if necessary, could sort the portals here? @@ -5368,10 +5348,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl HWR_SetPortalState(GLPORTAL_INSIDE); // TURN IT OFF // Recursively "render" the BSP tree. - if (!portalclipline) - HWR_RenderBSPNode((INT32)numnodes-1); - else - HWR_RenderPortalBSPNode((INT32)numnodes-1); + bspFunc((INT32)numnodes-1); // woo we back HWR_SetPortalState(oldgl_portal_state); From 46c53ea6797fabc773ca96b2d1128797875534d5 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 22 Jan 2025 19:05:10 +0100 Subject: [PATCH 262/418] try just passing the sector + add 50 trillion extra checks idk anymore but this is literally now how vanilla kart behaved --- src/r_main.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index f4c8719de..29d82b887 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1055,7 +1055,7 @@ void R_Init(void) mobj_t *viewmobj; -static void R_SetupCommonFrame(player_t * player, subsector_t * subsector) +static void R_SetupCommonFrame(player_t * player, sector_t * sector) { newview->player = player; @@ -1065,8 +1065,8 @@ static void R_SetupCommonFrame(player_t * player, subsector_t * subsector) newview->roll = R_ViewRollAngle(player); - if (subsector && subsector->sector) - newview->sector = subsector->sector; + if (sector != NULL) + newview->sector = sector; else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; @@ -1196,10 +1196,10 @@ void R_SkyboxFrame(int s) } #undef SETUPSKYVIEW - if (!P_MobjWasRemoved(viewmobj)) + if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && viewmobj->subsector->sector) subsector = viewmobj->subsector; - R_SetupCommonFrame(player, subsector); + R_SetupCommonFrame(player, subsector->sector); } void R_SetupFrame(int s, boolean skybox) @@ -1207,7 +1207,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); - subsector_t * subsector = NULL; + sector_t * sector = NULL; R_SetViewContext(VIEWCONTEXT_PLAYER1 + s); if (thiscam->reset) @@ -1247,10 +1247,10 @@ void R_SetupFrame(int s, boolean skybox) newview->y = viewmobj->y; newview->z = viewmobj->z + 20*FRACUNIT; - if (!P_MobjWasRemoved(viewmobj)) - subsector = viewmobj->subsector; + if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && viewmobj->subsector->sector) + sector = viewmobj->subsector->sector; - R_SetupCommonFrame(player, subsector); + R_SetupCommonFrame(player, sector); } else if (thiscam && chasecam) // use outside cam view { @@ -1260,10 +1260,10 @@ void R_SetupFrame(int s, boolean skybox) newview->y = thiscam->y; newview->z = thiscam->z + (thiscam->height>>1); - if (thiscam != NULL) - subsector = thiscam->subsector; + if (thiscam != NULL && thiscam->subsector && thiscam->subsector->sector) + sector = thiscam->subsector->sector; - R_SetupCommonFrame(player, subsector); + R_SetupCommonFrame(player, sector); } else // use the player's eyes view { @@ -1274,10 +1274,10 @@ void R_SetupFrame(int s, boolean skybox) newview->y = viewmobj->y; newview->z = player->viewz; - if (!P_MobjWasRemoved(viewmobj)) - subsector = viewmobj->subsector; + if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && viewmobj->subsector->sector) + sector = viewmobj->subsector->sector; - R_SetupCommonFrame(player, subsector); + R_SetupCommonFrame(player, sector); } } From ecd3ad40ae95b1a4cd3a78b44c18b677da65fb4d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 22 Jan 2025 19:42:01 +0100 Subject: [PATCH 263/418] fix freecam not resetting online idk local player handling is fucking awful in kart --- src/p_mobj.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 18e11cefe..72136f784 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10774,7 +10774,19 @@ void P_SpawnPlayer(INT32 playernum) { if (!p->spectator) { - camera[playernum].freecam = false; + if (playernum == consoleplayer) + camera[0].freecam = false; + else if (splitscreen) + { + for (i = 1; i <= splitscreen; i++) + { + if (playernum == displayplayers[i]) + { + camera[i].freecam = false; + break; + } + } + } } } } From f92c519d05e2dce1d6b50a31285ed88b7e5cb93d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 15:05:11 +0100 Subject: [PATCH 264/418] Prevent dropped ticcmds due to interp timing jutter kinda figured out what this does, and makes clients on uncapped listen servers alot less prone to drop gametics --- src/d_clisrv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 9485f00b3..34e83fb34 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5332,6 +5332,12 @@ static void HandlePacketFromPlayer(SINT8 node) /// \todo Use a separate cvar for that kind of timeout? freezetimeout[node] = I_GetTime() + connectiontimeout; + // If we've alredy received a ticcmd for this tic, just submit it for the next one. + tic_t faketic = maketic; + if ((!!(netcmds[maketic % TICQUEUE][netconsole].angleturn & TICCMD_RECEIVED)) + && (maketic - firstticstosend < TICQUEUE - 1)) + faketic++; + // Don't do anything for packets of type NODEKEEPALIVE? // Sryder 2018/07/01: Update the freezetimeout still! if (netbuffer->packettype == PT_NODEKEEPALIVE @@ -5339,7 +5345,7 @@ static void HandlePacketFromPlayer(SINT8 node) break; // Copy ticcmd - G_MoveTiccmd(&netcmds[maketic%TICQUEUE][netconsole], &netbuffer->u.clientpak.cmd, 1); + G_MoveTiccmd(&netcmds[faketic%TICQUEUE][netconsole], &netbuffer->u.clientpak.cmd, 1); // Check ticcmd for "speed hacks" if (CheckForSpeedHacks((UINT8)netconsole)) @@ -5351,7 +5357,7 @@ static void HandlePacketFromPlayer(SINT8 node) || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) && (nodetoplayer2[node] >= 0)) { - G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer2[node]], + G_MoveTiccmd(&netcmds[faketic%TICQUEUE][(UINT8)nodetoplayer2[node]], &netbuffer->u.client2pak.cmd2, 1); if (CheckForSpeedHacks((UINT8)nodetoplayer2[node])) @@ -5362,7 +5368,7 @@ static void HandlePacketFromPlayer(SINT8 node) || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) && (nodetoplayer3[node] >= 0)) { - G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer3[node]], + G_MoveTiccmd(&netcmds[faketic%TICQUEUE][(UINT8)nodetoplayer3[node]], &netbuffer->u.client3pak.cmd3, 1); if (CheckForSpeedHacks((UINT8)nodetoplayer3[node])) @@ -5372,7 +5378,7 @@ static void HandlePacketFromPlayer(SINT8 node) if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS) && (nodetoplayer4[node] >= 0)) { - G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer4[node]], + G_MoveTiccmd(&netcmds[faketic%TICQUEUE][(UINT8)nodetoplayer4[node]], &netbuffer->u.client4pak.cmd4, 1); if (CheckForSpeedHacks((UINT8)nodetoplayer4[node])) From 861d35e8d3c8cb0e51da7f05ebd49dd5977728a2 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 18:10:18 +0100 Subject: [PATCH 265/418] port clientsided gentlemens delay cant do the serverside stuff due to netvars --- src/d_clisrv.c | 163 ++++++++++++++++++++++++++++++++++++++++++++----- src/d_clisrv.h | 14 +++++ src/d_netcmd.c | 1 + 3 files changed, 164 insertions(+), 14 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7b20c78fe..694fa288c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -103,6 +103,17 @@ static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the UINT16 pingmeasurecount = 1; UINT32 realpingtable[MAXPLAYERS]; //the base table of ping where an average will be sent to everyone. UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values. + +#define GENTLEMANSMOOTHING (TICRATE) +static tic_t reference_lag; +static UINT8 spike_time; + +static tic_t lowest_lag; +boolean server_lagless; + +static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; +consvar_t cv_mindelay = {"mindelay", "0", CV_SAVE, mindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + SINT8 nodetoplayer[MAXNETNODES]; SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) SINT8 nodetoplayer3[MAXNETNODES]; // say the numplayer for this node if any (splitscreen == 2) @@ -140,7 +151,7 @@ static UINT8 gamestate_resend_counter[MAXNETNODES]; boolean hu_stopped = false; // Client specific -static ticcmd_t localcmds[MAXSPLITSCREENPLAYERS]; +static ticcmd_t localcmds[MAXSPLITSCREENPLAYERS][MAXGENTLEMENDELAY]; static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server @@ -456,10 +467,15 @@ static void D_Clearticcmd(tic_t tic) void D_ResetTiccmds(void) { - INT32 i; + INT32 i, j; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - memset(&localcmds[i], 0, sizeof(ticcmd_t)); + { + for (j = 0; j < MAXGENTLEMENDELAY; j++) + { + memset(&localcmds[i][j], 0, sizeof(ticcmd_t)); + } + } // Reset the net command list for (i = 0; i < TEXTCMD_HASH_SIZE; i++) @@ -4233,7 +4249,7 @@ void SV_ResetServer(void) memset(playeringame, false, sizeof playeringame); memset(playernode, UINT8_MAX, sizeof playernode); - pingmeasurecount = 1; + pingmeasurecount = 0; //Reset count memset(realpingtable, 0, sizeof realpingtable); memset(playerpingtable, 0, sizeof playerpingtable); @@ -6020,27 +6036,78 @@ static void CL_SendClientCmd(void) } else if (gamestate != GS_NULL) { + UINT8 lagDelay = 0; + + if (lowest_lag > 0) + { + // Gentlemens' ping. + lagDelay = min(lowest_lag, MAXGENTLEMENDELAY); + + // Is our connection worse than our current gentleman point? + // Make sure it stays that way for a bit before increasing delay levels. + if (lagDelay > reference_lag) + { + spike_time++; + if (spike_time >= GENTLEMANSMOOTHING) + { + // Okay, this is genuinely the new baseline delay. + reference_lag = lagDelay; + spike_time = 0; + } + else + { + // Just a temporary fluctuation, ignore it. + lagDelay = reference_lag; + } + } + else + { + reference_lag = lagDelay; // Adjust quickly if the connection improves. + spike_time = 0; + } + + /* + if (server) // Clients have to wait for the gamestate to make it back. Servers don't! + lagDelay *= 2; // Simulate the HELLFUCK NIGHTMARE of a complete round trip. + */ + + // [deep breath in] + // Plausible, elegant explanation that is WRONG AND SUPER HARMFUL. + // Clients with stable connections were adding their mindelay to network delay, + // even when their mindelay was as high or higher than network delay—which made + // client delay APPEAR slower than host mindelay, by the exact value that made + // "lmao just double it" make sense at the time. + // + // While this fix made client connections match server mindelay in our most common + // test environment, it also masked an issue that seriously affected online handling + // responsiveness, completely ruining our opportunity to further investigate it! + // + // See UpdatePingTable. + // I am taking this shitty code to my grave as an example of "never trust your brain". + // -Tyron 2024-05-15 + } + packetsize = sizeof (clientcmd_pak); - G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds[0], 1); - netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic%TICQUEUE]); + G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds[0][lagDelay], 1); + netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic % TICQUEUE]); if (splitscreen || botingame) // Send a special packet with 2 cmd for splitscreen { netbuffer->packettype = (mis ? PT_CLIENT2MIS : PT_CLIENT2CMD); packetsize = sizeof (client2cmd_pak); - G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds[1], 1); + G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds[1][lagDelay], 1); if (splitscreen > 1) { netbuffer->packettype = (mis ? PT_CLIENT3MIS : PT_CLIENT3CMD); packetsize = sizeof (client3cmd_pak); - G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds[2], 1); + G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds[2][lagDelay], 1); if (splitscreen > 2) { netbuffer->packettype = (mis ? PT_CLIENT4MIS : PT_CLIENT4CMD); packetsize = sizeof (client4cmd_pak); - G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds[3], 1); + G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds[3][lagDelay], 1); } } } @@ -6207,8 +6274,15 @@ static void SV_SendTics(void) // static inline void CreateNewLocalCMD(UINT8 p, INT32 realtics) { - G_BuildTiccmd(&localcmds[p], realtics, p+1); - localcmds[p].angleturn |= TICCMD_RECEIVED; + INT32 i; + + for (i = MAXGENTLEMENDELAY-1; i > 0; i--) + { + G_MoveTiccmd(&localcmds[p][i], &localcmds[p][i-1], 1); + } + + G_BuildTiccmd(&localcmds[p][0], realtics, p+1); + localcmds[p][0].angleturn |= TICCMD_RECEIVED; } static void Local_Maketic(INT32 realtics) @@ -6510,16 +6584,77 @@ static tic_t gametime = 0; static void UpdatePingTable(void) { + tic_t fastest; + tic_t lag; + INT32 i; + if (server) { - if (netgame && !(gametime % 35)) // update once per second. + if (Playing() && !(gametime % 8)) // Value chosen based on _my vibes man_ PingUpdate(); + + fastest = 0; + // update node latency values so we can take an average later. for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && playernode[i] != UINT8_MAX) - realpingtable[i] += GetLag(playernode[i]); + { + if (playeringame[i] && playernode[i] > 0 && playernode[i] != UINT8_MAX) + { + if (playernode[i] > 0 && !players[i].spectator) + { + lag = GetLag(playernode[i]); + realpingtable[i] += (lag); + + if (! fastest || lag < fastest) + fastest = lag; + } + else + realpingtable[i] += (GetLag(playernode[i])); + } + } + + // Don't gentleman below your mindelay + if (fastest < (tic_t)cv_mindelay.value) + fastest = (tic_t)cv_mindelay.value; + pingmeasurecount++; + + lowest_lag = fastest; + + if (fastest) + lag = fastest; + else + lag = GetLag(0); + + lag = (realpingtable[0] + lag); + + switch (playerpernode[0]) + { + case 4: + realpingtable[nodetoplayer4[0]] = lag; + /*FALLTHRU*/ + case 3: + realpingtable[nodetoplayer3[0]] = lag; + /*FALLTHRU*/ + case 2: + realpingtable[nodetoplayer2[0]] = lag; + /*FALLTHRU*/ + case 1: + realpingtable[nodetoplayer[0]] = lag; + } + } + else // We're a client, handle mindelay on the way out. + { + // Previously (neededtic - gametic) - WRONG VALUE! + // Pretty sure that's measuring jitter, not RTT. + // Stable connections would be punished by adding their mindelay to network delay! + tic_t mydelay = playerpingtable[consoleplayer]; + + if (mydelay < (tic_t)cv_mindelay.value) + lowest_lag = cv_mindelay.value - mydelay; + else + lowest_lag = 0; } } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 4e81621d9..1e86ec567 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -41,6 +41,15 @@ applications may follow different packet versions. #define BACKUPTICS 32 #define TICQUEUE 512 // more than enough for most timeouts.... #define MAXTEXTCMD 256 + +// No. of tics your controls can be delayed by. + +// TODO: Instead of storing a ton of extra cmds for gentlemens' delay, +// keep them in a linked-list, with timestamps to discard everything that's older than already sent. +// That will support any amount of lag, and be less wasteful for clients who don't use it. +// This just works as a quick implementation. +#define MAXGENTLEMENDELAY TICRATE + // // Packet structure // @@ -576,6 +585,9 @@ extern UINT32 realpingtable[MAXPLAYERS]; extern UINT32 playerpingtable[MAXPLAYERS]; extern tic_t servermaxping; +extern boolean server_lagless; +extern consvar_t cv_mindelay; + extern consvar_t #ifdef VANILLAJOINNEXTROUND cv_joinnextround, @@ -645,6 +657,8 @@ extern char motd[254], server_context[8]; extern UINT8 playernode[MAXPLAYERS]; INT32 D_NumPlayers(void); +boolean D_IsPlayerHumanAndGaming(INT32 player_number); + void D_ResetTiccmds(void); tic_t GetLag(INT32 node); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 41b9c97e9..b8efd3392 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -916,6 +916,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_rollingdemos); CV_RegisterVar(&cv_netstat); CV_RegisterVar(&cv_netticbuffer); + CV_RegisterVar(&cv_mindelay); #ifdef NETGAME_DEVMODE CV_RegisterVar(&cv_fishcake); From 1d5092cf22958b0d59af18d44575a2eb46d5162d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 16:16:46 +0100 Subject: [PATCH 266/418] smol cleanup --- src/d_clisrv.c | 35 +++++++++++++---------------------- src/d_clisrv.h | 1 - 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 694fa288c..1d10ec4c2 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -109,7 +109,6 @@ static tic_t reference_lag; static UINT8 spike_time; static tic_t lowest_lag; -boolean server_lagless; static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; consvar_t cv_mindelay = {"mindelay", "0", CV_SAVE, mindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -6601,47 +6600,39 @@ static void UpdatePingTable(void) { if (playeringame[i] && playernode[i] > 0 && playernode[i] != UINT8_MAX) { - if (playernode[i] > 0 && !players[i].spectator) - { - lag = GetLag(playernode[i]); - realpingtable[i] += (lag); + // TicsToMilliseconds can't handle pings over 1000ms lol + realpingtable[i] += GetLag(playernode[i]); + if (!players[i].spectator) + { + lag = playerpingtable[i]; if (! fastest || lag < fastest) fastest = lag; } - else - realpingtable[i] += (GetLag(playernode[i])); } } - // Don't gentleman below your mindelay - if (fastest < (tic_t)cv_mindelay.value) - fastest = (tic_t)cv_mindelay.value; - - pingmeasurecount++; - lowest_lag = fastest; - if (fastest) - lag = fastest; - else - lag = GetLag(0); + // Don't gentleman below your mindelay + if (lowest_lag < (tic_t)cv_mindelay.value) + lowest_lag = (tic_t)cv_mindelay.value; - lag = (realpingtable[0] + lag); + pingmeasurecount++; switch (playerpernode[0]) { case 4: - realpingtable[nodetoplayer4[0]] = lag; + realpingtable[nodetoplayer4[0]] = lowest_lag; /*FALLTHRU*/ case 3: - realpingtable[nodetoplayer3[0]] = lag; + realpingtable[nodetoplayer3[0]] = lowest_lag; /*FALLTHRU*/ case 2: - realpingtable[nodetoplayer2[0]] = lag; + realpingtable[nodetoplayer2[0]] = lowest_lag; /*FALLTHRU*/ case 1: - realpingtable[nodetoplayer[0]] = lag; + realpingtable[nodetoplayer[0]] = lowest_lag; } } else // We're a client, handle mindelay on the way out. diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 1e86ec567..25bbdf054 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -585,7 +585,6 @@ extern UINT32 realpingtable[MAXPLAYERS]; extern UINT32 playerpingtable[MAXPLAYERS]; extern tic_t servermaxping; -extern boolean server_lagless; extern consvar_t cv_mindelay; extern consvar_t From 064e9d58af21f250c9b586a0eb7400206c177ee1 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 18:10:53 +0100 Subject: [PATCH 267/418] add gentlemens delay to ping display + display ping even offline if you have mindelay active --- src/hu_stuff.c | 16 +++++++++++++--- src/k_kart.c | 15 ++++++++++++--- src/screen.c | 7 ++++++- src/sdl/i_video.c | 13 +++++++++---- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 6cbb46148..96ba8cec6 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2425,7 +2425,7 @@ void HU_drawPing(INT32 x, INT32 y, UINT32 lag, INT32 flags) UINT8 *colormap = NULL; INT32 measureid = cv_pingmeasurement.value ? 1 : 0; INT32 gfxnum; // gfx to draw - + //SRB2/Kart v1.0 style UINT8 numbars = 0; // how many ping bars do we draw? UINT8 barcolor = 31; // color we use for the bars (green, yellow, red or black) @@ -2522,6 +2522,7 @@ static inline void HU_DrawSpectatorTicker(void) INT32 length = 0, height = 174; INT32 totallength = 0, templength = -8; INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; + UINT32 ping = 0; for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].spectator) @@ -2595,8 +2596,17 @@ static inline void HU_DrawSpectatorTicker(void) } } - if (netgame && i != serverplayer) - HU_drawPing((templength - duptweak)+8, height-20, playerpingtable[i], V_TRANSLUCENT); + if ((netgame && i != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(&players[i]))) + { + ping = playerpingtable[i]; + + if (P_IsLocalPlayer(&players[i]) && ping <= (tic_t)cv_mindelay.value) + { + ping = cv_mindelay.value; + } + + HU_drawPing((templength - duptweak)+8, height-20, ping, V_TRANSLUCENT); + } } if ((length += len) >= dupadjust+8) diff --git a/src/k_kart.c b/src/k_kart.c index 6f7555786..5ab4481fa 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8885,6 +8885,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I INT32 i, rightoffset = 240; const UINT8 *colormap; INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; + UINT32 ping = 0; //this function is designed for 9 or less score lines only //I_Assert(scorelines <= 9); -- not today bitch, kart fixed it up @@ -8904,9 +8905,17 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (players[tab[i].num].spectator || !players[tab[i].num].mo) continue; //ignore them. - if (netgame // don't draw it offline - && tab[i].num != serverplayer) - HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[tab[i].num], 0); + if ((netgame && pnum != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(&players[pnum]))) + { + ping = playerpingtable[pnum]; + + if (P_IsLocalPlayer(&players[pnum]) && ping <= (tic_t)cv_mindelay.value) + { + ping = cv_mindelay.value; + } + + HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, ping, 0); + } STRBUFCPY(strtime, tab[i].name); diff --git a/src/screen.c b/src/screen.c index 249c7225c..9d293ec7a 100644 --- a/src/screen.c +++ b/src/screen.c @@ -521,7 +521,12 @@ void SCR_DisplayLocalPing(void) if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level { INT32 dispy = (cv_ticrate.value == 1) ? 165 : ((cv_ticrate.value == 2 || cv_ticrate.value == 4) ? 172 : ((cv_ticrate.value == 3) ? 163 : 181)); // absolute buttpain - + + if (ping <= (tic_t)cv_mindelay.value) + { + ping = cv_mindelay.value; + } + HU_drawPing(308, dispy, ping, pingflags); } } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 609afc30a..c4dec0400 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1464,11 +1464,16 @@ void I_FinishUpdate(void) if (I_SkipFrame()) return; - if (cv_ticrate.value && st_overlay) - SCR_DisplayTicRate(); + if (st_overlay) + { + if (cv_ticrate.value) + SCR_DisplayTicRate(); - if (cv_showping.value && netgame && consoleplayer != serverplayer && st_overlay) - SCR_DisplayLocalPing(); + if (cv_showping.value && netgame && consoleplayer != serverplayer) + SCR_DisplayLocalPing(); + if (cv_showping.value && cv_mindelay.value && consoleplayer == serverplayer && Playing()) + SCR_DisplayLocalPing(); + } #ifdef HAVE_DISCORDRPC if (discordRequestList != NULL) From 6b951d2773094d172de4d9edcd354ad71b0ae643 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 17:38:20 +0100 Subject: [PATCH 268/418] division by zero moment --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1d10ec4c2..e94cef84e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4248,7 +4248,7 @@ void SV_ResetServer(void) memset(playeringame, false, sizeof playeringame); memset(playernode, UINT8_MAX, sizeof playernode); - pingmeasurecount = 0; //Reset count + pingmeasurecount = 1; memset(realpingtable, 0, sizeof realpingtable); memset(playerpingtable, 0, sizeof playerpingtable); From 6ef9c0b305b295dcb9617522d5ba3ca6a0e4361b Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 18:06:06 +0100 Subject: [PATCH 269/418] colourise pingnumber when gentlemens is active --- src/hu_stuff.c | 24 ++++++++++++------------ src/hu_stuff.h | 2 +- src/k_kart.c | 10 +--------- src/screen.c | 9 ++------- src/sdl/i_video.c | 4 +--- 5 files changed, 17 insertions(+), 32 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 96ba8cec6..625668831 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2433,6 +2433,14 @@ void HU_drawPing(INT32 x, INT32 y, UINT32 lag, INT32 flags) SINT8 yoffset = 6; //INT32 dx; + UINT32 lag = playerpingtable[pnum]; + + if (P_IsLocalPlayer(&players[pnum]) && lag < (tic_t)cv_mindelay.value) + { + lag = cv_mindelay.value; + colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_PASTEL, GTC_CACHE); + } + gfxnum = Ping_gfx_num(lag); if (!cv_pingstyle.value) @@ -2452,7 +2460,7 @@ void HU_drawPing(INT32 x, INT32 y, UINT32 lag, INT32 flags) x = V_DrawPingNum(x + (measureid == 1 ? 11 - pingmeasure[measureid]->width : 10), y+9, flags, lag, colormap); if (measureid == 0) - V_DrawScaledPatch(x+1 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]); + V_DrawScaledPatch(x+1 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]); } else if (cv_pingstyle.value) // old style ping { @@ -2500,8 +2508,8 @@ void HU_drawPing(INT32 x, INT32 y, UINT32 lag, INT32 flags) } if (cv_pingicon.value) - { - for (i=0; (i<3); i++) // Draw the ping bar + { + for (i = 0; (i < 3); i++) // Draw the ping bar { V_DrawFill(x+2 *(i-1)+7, y+8+yoffset-4, 2, 8-yoffset, 31|flags); if (i < numbars) @@ -2522,7 +2530,6 @@ static inline void HU_DrawSpectatorTicker(void) INT32 length = 0, height = 174; INT32 totallength = 0, templength = -8; INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; - UINT32 ping = 0; for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].spectator) @@ -2598,14 +2605,7 @@ static inline void HU_DrawSpectatorTicker(void) if ((netgame && i != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(&players[i]))) { - ping = playerpingtable[i]; - - if (P_IsLocalPlayer(&players[i]) && ping <= (tic_t)cv_mindelay.value) - { - ping = cv_mindelay.value; - } - - HU_drawPing((templength - duptweak)+8, height-20, ping, V_TRANSLUCENT); + HU_drawPlayerPing((templength - duptweak)+8, height-20, i, V_TRANSLUCENT); } } diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 66459c716..7578ed526 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -125,7 +125,7 @@ void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_Erase(void); void HU_clearChatChars(void); -void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); // Lat': Ping drawer for scoreboard. +void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags); // Lat': Ping drawer for scoreboard. //void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer); //void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer); void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol); diff --git a/src/k_kart.c b/src/k_kart.c index 5ab4481fa..3e6c97df5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8885,7 +8885,6 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I INT32 i, rightoffset = 240; const UINT8 *colormap; INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; - UINT32 ping = 0; //this function is designed for 9 or less score lines only //I_Assert(scorelines <= 9); -- not today bitch, kart fixed it up @@ -8907,14 +8906,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if ((netgame && pnum != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(&players[pnum]))) { - ping = playerpingtable[pnum]; - - if (P_IsLocalPlayer(&players[pnum]) && ping <= (tic_t)cv_mindelay.value) - { - ping = cv_mindelay.value; - } - - HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, ping, 0); + HU_drawPlayerPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, pnum, 0); } STRBUFCPY(strtime, tab[i].name); diff --git a/src/screen.c b/src/screen.c index 9d293ec7a..5ae4f8d72 100644 --- a/src/screen.c +++ b/src/screen.c @@ -515,18 +515,13 @@ void SCR_DisplayTicRate(void) void SCR_DisplayLocalPing(void) { - UINT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P + UINT32 ping = playerpingtable[consoleplayer]; INT32 pingflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level { INT32 dispy = (cv_ticrate.value == 1) ? 165 : ((cv_ticrate.value == 2 || cv_ticrate.value == 4) ? 172 : ((cv_ticrate.value == 3) ? 163 : 181)); // absolute buttpain - if (ping <= (tic_t)cv_mindelay.value) - { - ping = cv_mindelay.value; - } - - HU_drawPing(308, dispy, ping, pingflags); + HU_drawPlayerPing(308, dispy, consoleplayer, pingflags); // consoleplayer's ping is everyone's ping in a splitnetgame :P } } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c4dec0400..e17dd87f7 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1469,9 +1469,7 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); - if (cv_showping.value && netgame && consoleplayer != serverplayer) - SCR_DisplayLocalPing(); - if (cv_showping.value && cv_mindelay.value && consoleplayer == serverplayer && Playing()) + if (cv_showping.value && ((netgame && consoleplayer != serverplayer) || (cv_mindelay.value && consoleplayer == serverplayer && Playing()))) SCR_DisplayLocalPing(); } From 9354a0ab88e72c2087b93e54960762bb1d167883 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 21:27:07 +0100 Subject: [PATCH 270/418] conflict fix --- src/hu_stuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 625668831..e94bd6598 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2420,7 +2420,7 @@ Ping_gfx_num (int lag) // HU_drawPing // -void HU_drawPing(INT32 x, INT32 y, UINT32 lag, INT32 flags) +void HU_drawPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) { UINT8 *colormap = NULL; INT32 measureid = cv_pingmeasurement.value ? 1 : 0; From f4f3f6e29c194312bfb724982bedad733c84a71c Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 21:27:42 +0100 Subject: [PATCH 271/418] slight cleanup HU_drawPlayerPing --- src/hu_stuff.c | 63 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index e94bd6598..0677bf2a6 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2416,13 +2416,43 @@ Ping_gfx_num (int lag) return 4; } +static const UINT8 * +Ping_gfx_colormap (UINT32 lag, boolean gentleman) +{ + const UINT8 *colormap = NULL; + + if (gentleman) + { + colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_PASTEL, GTC_CACHE); + } + + if (servermaxping && lag > servermaxping && hu_tick < 4) + { + // flash ping red if too high + colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE); + } + + return colormap; +} + +static UINT32 +Ping_conversion (UINT32 lag) +{ + if (cv_pingmeasurement.value) + { + lag = (INT32)(lag * (1000.00f / TICRATE)); + } + + return lag; +} + + // // HU_drawPing // void HU_drawPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) { - UINT8 *colormap = NULL; INT32 measureid = cv_pingmeasurement.value ? 1 : 0; INT32 gfxnum; // gfx to draw @@ -2434,35 +2464,29 @@ void HU_drawPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) //INT32 dx; UINT32 lag = playerpingtable[pnum]; + const boolean gentleman = (cv_mindelay.value && (lag < (tic_t)cv_mindelay.value) && P_IsLocalPlayer(&players[pnum])); - if (P_IsLocalPlayer(&players[pnum]) && lag < (tic_t)cv_mindelay.value) + if (gentleman) { lag = cv_mindelay.value; - colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_PASTEL, GTC_CACHE); } - gfxnum = Ping_gfx_num(lag); - - if (!cv_pingstyle.value) + if (cv_pingstyle.value == 0) // kart { + gfxnum = Ping_gfx_num(lag); + if (measureid == 1) V_DrawScaledPatch(x+11 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]); if (cv_pingicon.value) V_DrawScaledPatch(x+2, y, flags, pinggfx[gfxnum]); - if (servermaxping && lag > servermaxping && hu_tick < 4) - colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE); // flash ping red if too high - - if (cv_pingmeasurement.value) - lag = (INT32)(lag * (1000.00f / TICRATE)); - - x = V_DrawPingNum(x + (measureid == 1 ? 11 - pingmeasure[measureid]->width : 10), y+9, flags, lag, colormap); + x = V_DrawPingNum(x + (measureid == 1 ? 11 - pingmeasure[measureid]->width : 10), y+9, flags, Ping_conversion(lag), Ping_gfx_colormap(lag, gentleman)); if (measureid == 0) V_DrawScaledPatch(x+1 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]); } - else if (cv_pingstyle.value) // old style ping + else if (cv_pingstyle.value == 1) // old style ping { if (cv_pingicon.value) { @@ -2488,22 +2512,15 @@ void HU_drawPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) } } - if (cv_pingmeasurement.value) - lag = (INT32)(lag * (1000.00f / TICRATE)); - if (vid.width >= 640) // how sad, we're using a shit resolution. { if (measureid == 1) { - //dx = x+1 - (V_SmallStringWidth(va("%dms", lag), V_ALLOWLOWERCASE|flags)/2); - //V_DrawSmallString(dx, y+4, V_ALLOWLOWERCASE|flags, va("%dms", lag)); - V_DrawRightAlignedSmallString(x+12, y+13, V_ALLOWLOWERCASE|flags, va("%dms", lag)); + V_DrawRightAlignedSmallString(x+12, y+13, V_ALLOWLOWERCASE|flags, va("%dms", Ping_conversion(lag))); } else if (measureid == 0) { - //dx = x+1 - (V_SmallStringWidth(va("d%d", lag), flags)/2); - //V_DrawSmallString(dx, y+4, flags, va("d%d", lag)); - V_DrawRightAlignedSmallString(x+12, y+13, flags, va("d%d", lag)); + V_DrawRightAlignedSmallString(x+12, y+13, flags, va("d%d", Ping_conversion(lag))); } } From 1857ce5113d276268fd1d834480b940de2bdb9ef Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 21:29:08 +0100 Subject: [PATCH 272/418] conflict fix 2 --- src/hu_stuff.c | 2 +- src/k_kart.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 0677bf2a6..4f99ca0eb 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2451,7 +2451,7 @@ Ping_conversion (UINT32 lag) // HU_drawPing // -void HU_drawPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) +void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) { INT32 measureid = cv_pingmeasurement.value ? 1 : 0; INT32 gfxnum; // gfx to draw diff --git a/src/k_kart.c b/src/k_kart.c index 3e6c97df5..9048d1fc6 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8904,9 +8904,9 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (players[tab[i].num].spectator || !players[tab[i].num].mo) continue; //ignore them. - if ((netgame && pnum != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(&players[pnum]))) + if ((netgame && tab[i].num != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(&players[tab[i].num]))) { - HU_drawPlayerPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, pnum, 0); + HU_drawPlayerPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, tab[i].num, 0); } STRBUFCPY(strtime, tab[i].name); From ac64428abb92e7b4e66f569e076a32abafdf5e9d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 21:55:37 +0100 Subject: [PATCH 273/418] dont mess up realpingtable when serverplayer has mindelay active this was supposed to show mindelay for serverplayers but that doesent work :chaosleep: so just do not mess with it --- src/d_clisrv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e94cef84e..465a95300 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6600,7 +6600,6 @@ static void UpdatePingTable(void) { if (playeringame[i] && playernode[i] > 0 && playernode[i] != UINT8_MAX) { - // TicsToMilliseconds can't handle pings over 1000ms lol realpingtable[i] += GetLag(playernode[i]); if (!players[i].spectator) @@ -6620,6 +6619,7 @@ static void UpdatePingTable(void) pingmeasurecount++; +#if 0 switch (playerpernode[0]) { case 4: @@ -6634,6 +6634,7 @@ static void UpdatePingTable(void) case 1: realpingtable[nodetoplayer[0]] = lowest_lag; } +#endif } else // We're a client, handle mindelay on the way out. { From b97841b6fdb1814387409d403292757c49d7c61e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jan 2025 06:39:57 +0100 Subject: [PATCH 274/418] proper add server gentlemans this should be a netvar, but we cant really do that, thought not a huge deal however id wish to send some kinda message to all players but idk --- src/d_clisrv.c | 39 +++++++++++++++++++-------------------- src/d_clisrv.h | 4 +++- src/d_netcmd.c | 1 + src/g_game.c | 2 ++ src/hu_stuff.c | 4 ++-- src/sdl/i_video.c | 2 +- 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 465a95300..7c7cb7d07 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -107,11 +107,24 @@ UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values. #define GENTLEMANSMOOTHING (TICRATE) static tic_t reference_lag; static UINT8 spike_time; +tic_t lowest_lag; +boolean server_lagless; -static tic_t lowest_lag; +static void Lagless_OnChange(void) +{ + /* don't back out of dishonesty, or go lagless after playing honestly */ + if (cv_lagless.value && gamestate == GS_LEVEL) + server_lagless = true; + + /*if (cv_lagless.value) + HU_AddChatText(M_GetText("\x82*Gentlemans Delay has been enabled for Serverplayer."), false); + else + HU_AddChatText(M_GetText("\x82*Gentlemans Delay will be disabled for Serverplayer."), false);*/ +} static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; consvar_t cv_mindelay = {"mindelay", "0", CV_SAVE, mindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_lagless = {"serverlagless", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Lagless_OnChange, 0, NULL, NULL, 0, 0, NULL}; // this should be a netvar Zzz... SINT8 nodetoplayer[MAXNETNODES]; SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) @@ -6602,7 +6615,7 @@ static void UpdatePingTable(void) { realpingtable[i] += GetLag(playernode[i]); - if (!players[i].spectator) + if (!server_lagless && !players[i].spectator) { lag = playerpingtable[i]; if (! fastest || lag < fastest) @@ -6611,30 +6624,16 @@ static void UpdatePingTable(void) } } - lowest_lag = fastest; + if (server_lagless) + lowest_lag = 0; + else + lowest_lag = fastest; // Don't gentleman below your mindelay if (lowest_lag < (tic_t)cv_mindelay.value) lowest_lag = (tic_t)cv_mindelay.value; pingmeasurecount++; - -#if 0 - switch (playerpernode[0]) - { - case 4: - realpingtable[nodetoplayer4[0]] = lowest_lag; - /*FALLTHRU*/ - case 3: - realpingtable[nodetoplayer3[0]] = lowest_lag; - /*FALLTHRU*/ - case 2: - realpingtable[nodetoplayer2[0]] = lowest_lag; - /*FALLTHRU*/ - case 1: - realpingtable[nodetoplayer[0]] = lowest_lag; - } -#endif } else // We're a client, handle mindelay on the way out. { diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 25bbdf054..c24356e94 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -585,7 +585,9 @@ extern UINT32 realpingtable[MAXPLAYERS]; extern UINT32 playerpingtable[MAXPLAYERS]; extern tic_t servermaxping; -extern consvar_t cv_mindelay; +extern boolean server_lagless; +extern tic_t lowest_lag; +extern consvar_t cv_mindelay, cv_lagless; extern consvar_t #ifdef VANILLAJOINNEXTROUND diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b8efd3392..759b3b6a4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -917,6 +917,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_netstat); CV_RegisterVar(&cv_netticbuffer); CV_RegisterVar(&cv_mindelay); + CV_RegisterVar(&cv_lagless); #ifdef NETGAME_DEVMODE CV_RegisterVar(&cv_fishcake); diff --git a/src/g_game.c b/src/g_game.c index d30e07c00..fa58ca81c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1265,6 +1265,8 @@ static void G_DoLoadLevel(boolean resetplayer) // clear hud messages remains (usually from game startup) CON_ClearHUD(); + server_lagless = cv_lagless.value; + G_ResetAllDeviceRumbles(); } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4f99ca0eb..62b29de59 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2464,11 +2464,11 @@ void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) //INT32 dx; UINT32 lag = playerpingtable[pnum]; - const boolean gentleman = (cv_mindelay.value && (lag < (tic_t)cv_mindelay.value) && P_IsLocalPlayer(&players[pnum])); + const boolean gentleman = ((cv_mindelay.value && (lag < (tic_t)cv_mindelay.value) && P_IsLocalPlayer(&players[pnum])) || (pnum == serverplayer && lowest_lag != 0)); // for serverplayer lowest_lag actually reflects mindelay if (gentleman) { - lag = cv_mindelay.value; + lag = (pnum == serverplayer) ? lowest_lag : (tic_t)cv_mindelay.value; } if (cv_pingstyle.value == 0) // kart diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index e17dd87f7..934491e9c 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1469,7 +1469,7 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); - if (cv_showping.value && ((netgame && consoleplayer != serverplayer) || (cv_mindelay.value && consoleplayer == serverplayer && Playing()))) + if (cv_showping.value && ((netgame && consoleplayer != serverplayer) || ((cv_mindelay.value || (!server_lagless && lowest_lag != 0)) && consoleplayer == serverplayer && Playing()))) SCR_DisplayLocalPing(); } From b55c654a81691544f33a3c60acace0c745c8e459 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jan 2025 06:43:46 +0100 Subject: [PATCH 275/418] oop --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7c7cb7d07..ccc700325 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -117,9 +117,9 @@ static void Lagless_OnChange(void) server_lagless = true; /*if (cv_lagless.value) - HU_AddChatText(M_GetText("\x82*Gentlemans Delay has been enabled for Serverplayer."), false); + HU_AddChatText(M_GetText("\x82*Gentlemans Delay has been disabled for Serverplayer."), false); else - HU_AddChatText(M_GetText("\x82*Gentlemans Delay will be disabled for Serverplayer."), false);*/ + HU_AddChatText(M_GetText("\x82*Gentlemans Delay will be enabled for Serverplayer."), false);*/ } static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; From 5f546a3df8fb54054b646cfccee4755194ccc5b4 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 15:50:45 +0100 Subject: [PATCH 276/418] just use D_NumPlayers --- src/k_director.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index c4723d6d4..c8cf4dbeb 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -42,25 +42,6 @@ struct directorinfo INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers? } directorinfo; -static boolean K_DirectorIsPlayerAlone(void) -{ - UINT8 pingame = 0; - - // Gotta check how many players are active at this moment. - for (UINT8 i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - pingame++; - - if (pingame >= 2) // we dont need to check further - break; - } - - return (pingame <= 1); -} - static inline boolean race_rules(void) { return gametype == GT_RACE; @@ -75,7 +56,7 @@ boolean K_DirectorIsAvailable(void) { if (splitscreen || (demo.playback && demo.title) || modeattacking) return false; - return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && !K_DirectorIsPlayerAlone()))); + return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && (D_NumPlayers() > 1)))); } static boolean K_DirectorIsEnabled(void) From a1074852ddfa9f99a9d609d0ab8efce377fb81da Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 19:33:35 +0100 Subject: [PATCH 277/418] kill P_TeleportMove P_MoveOrigin literally just calls that so replace it with that --- src/p_map.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 9221a0d98..4793b4fa3 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -77,9 +77,9 @@ camera_t *mapcampointer; // // -// P_TeleportMove +// P_MoveOrigin - P_TeleportMove which KEEPS interpolation values. // -static boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) +boolean P_MoveOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) { // the move is ok, // so link the thing into its new position @@ -109,28 +109,19 @@ static boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) return true; } +// // P_SetOrigin - P_TeleportMove which RESETS interpolation values. // boolean P_SetOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) { - boolean result = P_TeleportMove(thing, x, y, z); - - if (result == true) + if (P_MoveOrigin(thing, x, y, z)) { thing->old_x = thing->x; thing->old_y = thing->y; thing->old_z = thing->z; } - return result; -} - -// -// P_MoveOrigin - P_TeleportMove which KEEPS interpolation values. -// -boolean P_MoveOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) -{ - return P_TeleportMove(thing, x, y, z); + return true; } // ========================================================================= From a513f1029629ccd544aca119a7ea3690d54e557a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 20:40:05 +0100 Subject: [PATCH 278/418] assign player later --- src/p_tick.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index a151f0b2f..72ce6e41e 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -383,8 +383,6 @@ 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; @@ -395,6 +393,8 @@ static void P_DeviceRumbleTick(void) continue; } + player_t *player = ((i == 0) ? &players[consoleplayer] : &players[displayplayers[i]]); + if (player->spectator) { continue; From 57ebb297c0f5d2c700ef5e78f5aed2206ceec501 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 19:45:23 +0100 Subject: [PATCH 279/418] simplify camtoggledelay and spectatedelay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit just make em an array and use lööp --- src/g_game.c | 59 ++++++++++++++++++++++----------------------------- src/p_local.h | 2 +- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index f1b71805b..758dd10ae 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1294,8 +1294,8 @@ static void G_DoLoadLevel(boolean resetplayer) } static INT32 pausedelay = 0; -static INT32 camtoggledelay, camtoggledelay2, camtoggledelay3, camtoggledelay4 = 0; -static INT32 spectatedelay, spectatedelay2, spectatedelay3, spectatedelay4 = 0; +static INT32 camtoggledelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; +static INT32 spectatedelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; // // G_Responder @@ -1476,72 +1476,72 @@ boolean G_Responder(event_t *ev) if (ev->data1 == gamecontrol[gc_camtoggle][0] || ev->data1 == gamecontrol[gc_camtoggle][1]) { - if (!camtoggledelay) + if (!camtoggledelay[0]) { - camtoggledelay = NEWTICRATE / 7; + camtoggledelay[0] = NEWTICRATE / 7; CV_SetValue(&cv_chasecam[0], cv_chasecam[0].value ? 0 : 1); } } if (ev->data1 == gamecontrolbis[gc_camtoggle][0] || ev->data1 == gamecontrolbis[gc_camtoggle][1]) { - if (!camtoggledelay2) + if (!camtoggledelay[1]) { - camtoggledelay2 = NEWTICRATE / 7; + camtoggledelay[1] = NEWTICRATE / 7; CV_SetValue(&cv_chasecam[1], cv_chasecam[1].value ? 0 : 1); } } if (ev->data1 == gamecontrol3[gc_camtoggle][0] || ev->data1 == gamecontrol3[gc_camtoggle][1]) { - if (!camtoggledelay3) + if (!camtoggledelay[2]) { - camtoggledelay3 = NEWTICRATE / 7; + camtoggledelay[2] = NEWTICRATE / 7; CV_SetValue(&cv_chasecam[2], cv_chasecam[2].value ? 0 : 1); } } if (ev->data1 == gamecontrol4[gc_camtoggle][0] || ev->data1 == gamecontrol4[gc_camtoggle][1]) { - if (!camtoggledelay4) + if (!camtoggledelay[3]) { - camtoggledelay4 = NEWTICRATE / 7; + camtoggledelay[3] = NEWTICRATE / 7; CV_SetValue(&cv_chasecam[3], cv_chasecam[3].value ? 0 : 1); } } if (ev->data1 == gamecontrol[gc_spectate][0] || ev->data1 == gamecontrol[gc_spectate][1]) { - if (!spectatedelay) + if (!spectatedelay[0]) { - spectatedelay = NEWTICRATE / 7; + spectatedelay[0] = NEWTICRATE / 7; COM_ImmedExecute("changeteam spectator"); } } if (ev->data1 == gamecontrolbis[gc_spectate][0] || ev->data1 == gamecontrolbis[gc_spectate][1]) { - if (!spectatedelay2) + if (!spectatedelay[1]) { - spectatedelay2 = NEWTICRATE / 7; + spectatedelay[1] = NEWTICRATE / 7; COM_ImmedExecute("changeteam2 spectator"); } } if (ev->data1 == gamecontrol3[gc_spectate][0] || ev->data1 == gamecontrol3[gc_spectate][1]) { - if (!spectatedelay3) + if (!spectatedelay[2]) { - spectatedelay3 = NEWTICRATE / 7; + spectatedelay[2] = NEWTICRATE / 7; COM_ImmedExecute("changeteam3 spectator"); } } if (ev->data1 == gamecontrol4[gc_spectate][0] || ev->data1 == gamecontrol4[gc_spectate][1]) { - if (!spectatedelay4) + if (!spectatedelay[3]) { - spectatedelay4 = NEWTICRATE / 7; + spectatedelay[3] = NEWTICRATE / 7; COM_ImmedExecute("changeteam4 spectator"); } } @@ -2000,23 +2000,14 @@ void G_Ticker(boolean run) if (pausedelay) pausedelay--; - if (camtoggledelay) - camtoggledelay--; - if (camtoggledelay2) - camtoggledelay2--; - if (camtoggledelay3) - camtoggledelay3--; - if (camtoggledelay4) - camtoggledelay4--; + for (UINT8 j = 0; j < MAXSPLITSCREENPLAYERS;j++) + { + if (camtoggledelay[i]) + camtoggledelay[i]--; - if (spectatedelay) - spectatedelay--; - if (spectatedelay2) - spectatedelay2--; - if (spectatedelay3) - spectatedelay3--; - if (spectatedelay4) - spectatedelay4--; + if (spectatedelay[i]) + spectatedelay[i]--; + } if (gametic % NAMECHANGERATE == 0) { diff --git a/src/p_local.h b/src/p_local.h index 66b08619c..6f61d9cd7 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -316,7 +316,7 @@ void P_ColorTeamMissile(mobj_t *missile, player_t *source); // Special utility to return +1 or -1 depending on mobj's gravity FUNCINLINE static ATTRINLINE SINT8 P_MobjFlip(const mobj_t *mobj) { - return (mobj && mobj->eflags & MFE_VERTICALFLIP) ? -1 : 1; + return (mobj && (mobj->eflags & MFE_VERTICALFLIP)) ? -1 : 1; } fixed_t P_GetMobjGravity(mobj_t *mo); From 55bb65034f6812a095b958d56c427dfb3739062c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jan 2025 20:16:21 +0100 Subject: [PATCH 280/418] [0] --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5731504fb..4f0e2ab53 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -541,7 +541,7 @@ void D_ResetTiccmds(void) ticcmd_t *D_LocalTiccmd(UINT8 ss) { - return &localcmds[ss]; + return &localcmds[ss][0]; } // ----------------------------------------------------------------- From 43dbaf70049c2fa1b2f611c504e3666df4189d19 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jan 2025 20:16:32 +0100 Subject: [PATCH 281/418] j moment --- src/g_game.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 758dd10ae..9e1094d29 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2002,11 +2002,11 @@ void G_Ticker(boolean run) for (UINT8 j = 0; j < MAXSPLITSCREENPLAYERS;j++) { - if (camtoggledelay[i]) - camtoggledelay[i]--; + if (camtoggledelay[j]) + camtoggledelay[j]--; - if (spectatedelay[i]) - spectatedelay[i]--; + if (spectatedelay[j]) + spectatedelay[j]--; } if (gametic % NAMECHANGERATE == 0) From 2296ef0987b00d4a7c7502a46e7bf04fa459c0ea Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 25 Jan 2025 01:09:43 +0300 Subject: [PATCH 282/418] Fix 'total podium' stat display using totalwins --- 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 6fe621446..226811a4f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8879,7 +8879,7 @@ static void M_DrawStatsExtra(void) DRAWTIMESTAT(52, "Time spent in spinout:", spinouttime); DRAWAMOUNTSTAT(72, "Total wins:", totalwins); - DRAWAMOUNTSTAT(82, "Total podium (2nd/3rd place):", totalwins); + DRAWAMOUNTSTAT(82, "Total podium (2nd/3rd place):", totalpodium); DRAWAMOUNTSTAT(102, "Hits landed:", hits); DRAWAMOUNTSTAT(112, "Self-hits landed:", selfhits); From 2b13af236772b7e29ece63771e2b64ed820351e7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 Jan 2025 08:05:51 +0100 Subject: [PATCH 283/418] setup maplight stuff earlier otherwise it doesent init early enough --- src/p_setup.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/p_spec.c | 40 ---------------------------------------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 1dbb43bac..27f8ba3a3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -596,6 +596,50 @@ boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector) return (baselightlevel < 255 && baselightlevel > 0); } +// dumb thing to reset maplight on next map change when its toggled +boolean reinitmaplight = false; +static void P_SetupDirectionalLight(void) +{ + mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; + + if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) + { + lighting = &mapheaderinfo[gamemap-1]->lighting_encore; + } + + if (cv_randomdirlight.value && lighting->use_custom_light == false) + { + static INT16 oldmap = 0; // dont reset stuff when you restart a map + static boolean oldencore = false; + + if (gamemap != oldmap || encoremode != oldencore || reinitmaplight) + { + maplighting.contrast = M_RandomRange(0, 58); + maplighting.backlight = 0; + maplighting.directional = M_RandomRange(0, 1); // either on or off + maplighting.angle = M_RandomRange(-382, 382); + + reinitmaplight = false; + } + + oldmap = gamemap; + oldencore = encoremode; + return; + } + else if (lighting->use_custom_light == false) + { + maplighting.contrast = 8; + maplighting.backlight = 0; + maplighting.directional = false; + maplighting.angle = 0; + } + + maplighting.contrast = lighting->light_contrast; + maplighting.backlight = lighting->sprite_backlight; + maplighting.directional = lighting->use_light_angle; + maplighting.angle = lighting->light_angle; +} + // Loads the SEGS resource from a level. static void P_LoadRawSegs(UINT8 *data) { @@ -605,6 +649,9 @@ static void P_LoadRawSegs(UINT8 *data) line_t *ldef; size_t i; + // Set map lighting settings. + P_SetupDirectionalLight(); + for (i = 0; i < numsegs; i++, li++, ml++) { li->v1 = &vertexes[SHORT(ml->v1)]; diff --git a/src/p_spec.c b/src/p_spec.c index 30c14fdf4..d272764be 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5225,43 +5225,6 @@ static void P_RunLevelLoadExecutors(void) } } -// dumb thing to reset maplight on next map change when its toggled -boolean reinitmaplight = false; -static void P_SetupDirectionalLight(void) -{ - mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; - - if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) - { - lighting = &mapheaderinfo[gamemap-1]->lighting_encore; - } - - if (cv_randomdirlight.value && lighting->use_custom_light == false) - { - static INT16 oldmap = 0; // dont reset stuff when you restart a map - static boolean oldencore = false; - - if (gamemap != oldmap || encoremode != oldencore || reinitmaplight) - { - maplighting.contrast = M_RandomRange(0, 58); - maplighting.backlight = 0; - maplighting.directional = M_RandomRange(0, 1); // either on or off - maplighting.angle = M_RandomRange(-382, 382); - - reinitmaplight = false; - } - - oldmap = gamemap; - oldencore = encoremode; - return; - } - - maplighting.contrast = lighting->light_contrast; - maplighting.backlight = lighting->sprite_backlight; - maplighting.directional = lighting->use_light_angle; - maplighting.angle = lighting->light_angle; -} - /** After the map has loaded, scans for specials that spawn 3Dfloors and * thinkers. * @@ -5287,9 +5250,6 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) // Set the default gravity. Custom gravity overrides this setting. gravity = (FRACUNIT*8)/10; - // Set map lighting settings. - P_SetupDirectionalLight(); - // Defaults in case levels don't have them set. sstimer = 90*TICRATE + 6; totalrings = 1; From f11dab363f79d4de5d54e09195b5206b231c4f36 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 Jan 2025 15:39:40 +0100 Subject: [PATCH 284/418] remove noshowhelp from bunch of debug cvars doesent make too much sense those are hidden tbh --- src/d_netcmd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d05baf7fc..e46026fa5 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -391,18 +391,18 @@ static CV_PossibleValue_t kartvoices_cons_t[] = {{0, "Never"}, {1, "Tasteful"}, consvar_t cv_kartvoices = {"kartvoices", "Tasteful", CV_SAVE, kartvoices_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_karthitemdialog = {"karthitemdialog", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_karteliminatelast = {"karteliminatelast", "Yes", CV_NETVAR|CV_CHEAT|CV_CALL|CV_NOSHOWHELP, CV_YesNo, KartEliminateLast_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_karteliminatelast = {"karteliminatelast", "Yes", CV_NETVAR|CV_CHEAT|CV_CALL, CV_YesNo, KartEliminateLast_OnChange, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugitem_cons_t[] = {{-1, "MIN"}, {NUMKARTITEMS-1, "MAX"}, {0, NULL}}; -consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugamount_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; -consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebugshrink = {"kartdebugshrink", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebugdistribution = {"kartdebugdistribution", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebughuddrop = {"kartdebughuddrop", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugshrink = {"kartdebugshrink", "Off", CV_NETVAR|CV_CHEAT, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugdistribution = {"kartdebugdistribution", "Off", CV_NETVAR|CV_CHEAT, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebughuddrop = {"kartdebughuddrop", "Off", CV_NETVAR|CV_CHEAT, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebugcheckpoint = {"kartdebugcheckpoint", "Off", CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebugnodes = {"kartdebugnodes", "Off", CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugcheckpoint = {"kartdebugcheckpoint", "Off", NULL, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugnodes = {"kartdebugnodes", "Off", NULL, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebugcolorize = {"kartdebugcolorize", "Off", CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t votetime_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, NULL}}; From 061201c0de01ec7fd0a408f47c19ba1bd9e773a2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 Jan 2025 16:59:31 +0100 Subject: [PATCH 285/418] "makes integer from pointer without a cast" deez nuts --- src/d_netcmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e46026fa5..bbf24e35e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -401,8 +401,8 @@ consvar_t cv_kartdebugshrink = {"kartdebugshrink", "Off", CV_NETVAR|CV_CHEAT, CV consvar_t cv_kartdebugdistribution = {"kartdebugdistribution", "Off", CV_NETVAR|CV_CHEAT, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebughuddrop = {"kartdebughuddrop", "Off", CV_NETVAR|CV_CHEAT, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebugcheckpoint = {"kartdebugcheckpoint", "Off", NULL, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebugnodes = {"kartdebugnodes", "Off", NULL, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugcheckpoint = {"kartdebugcheckpoint", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugnodes = {"kartdebugnodes", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebugcolorize = {"kartdebugcolorize", "Off", CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t votetime_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, NULL}}; From f8853ae902141b6cc7b8f0c29db4bad6e207f3ed Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jan 2025 21:19:50 +0100 Subject: [PATCH 286/418] inline G_TicsTo stuff theyre smol and get called often --- src/g_game.c | 30 ------------------------------ src/g_game.h | 31 ++++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 9e1094d29..f456b00ec 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -7845,7 +7845,6 @@ void G_DoneLevelLoad(void) // Stops metal sonic's demo. Separate from other functions because metal + replays can coexist void G_StopMetalDemo(void) { - // Metal Sonic finishing doesn't end the game, dammit. Z_Free(metalbuffer); metalbuffer = NULL; @@ -8180,32 +8179,3 @@ boolean G_GetRetryFlag(void) { return retrying; } - -// Time utility functions -INT32 G_TicsToHours(tic_t tics) -{ - return tics/(3600*TICRATE); -} - -INT32 G_TicsToMinutes(tic_t tics, boolean full) -{ - if (full) - return tics/(60*TICRATE); - else - return tics/(60*TICRATE)%60; -} - -INT32 G_TicsToSeconds(tic_t tics) -{ - return (tics/TICRATE)%60; -} - -INT32 G_TicsToCentiseconds(tic_t tics) -{ - return (INT32)((tics%TICRATE) * (100.00f/TICRATE)); -} - -INT32 G_TicsToMilliseconds(tic_t tics) -{ - return (INT32)((tics%TICRATE) * (1000.00f/TICRATE)); -} diff --git a/src/g_game.h b/src/g_game.h index 6723e9ba6..fa427b752 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -432,11 +432,32 @@ void G_ClearRecords(void); tic_t G_GetBestTime(INT16 map); -FUNCMATH INT32 G_TicsToHours(tic_t tics); -FUNCMATH INT32 G_TicsToMinutes(tic_t tics, boolean full); -FUNCMATH INT32 G_TicsToSeconds(tic_t tics); -FUNCMATH INT32 G_TicsToCentiseconds(tic_t tics); -FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics); +// Time utility functions + +FUNCINLINE static ATTRINLINE FUNCMATH INT32 G_TicsToHours(tic_t tics) +{ + return tics/(3600*TICRATE); +} + +FUNCINLINE static ATTRINLINE FUNCMATH INT32 G_TicsToMinutes(tic_t tics, boolean full) +{ + return full ? (tics/(60*TICRATE)) : (tics/(60*TICRATE)%60); +} + +FUNCINLINE static ATTRINLINE FUNCMATH INT32 G_TicsToSeconds(tic_t tics) +{ + return (tics/TICRATE)%60; +} + +FUNCINLINE static ATTRINLINE FUNCMATH INT32 G_TicsToCentiseconds(tic_t tics) +{ + return (INT32)((tics%TICRATE) * (100.00f/TICRATE)); +} + +FUNCINLINE static ATTRINLINE FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics) +{ + return (INT32)((tics%TICRATE) * (1000.00f/TICRATE)); +} // Don't split up TOL handling INT16 G_TOLFlag(INT32 pgametype); From 42f200aabd447414f8a078bc5adc47a673486ca0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 Jan 2025 21:22:19 +0100 Subject: [PATCH 287/418] inline bunch of one line HWR things --- src/hardware/hw_main.c | 52 +--------------------------------- src/hardware/hw_main.h | 64 ++++++++++++++++++++++++++++++++++-------- src/sdl/ogl_sdl.c | 4 +-- 3 files changed, 55 insertions(+), 65 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 062edcb2a..a56cd5595 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -317,26 +317,11 @@ static void CV_glpalettedepth_OnChange(void) // Lighting // ========================================================================== -boolean HWR_UseShader(void) -{ - return (cv_glshaders.value && gl_shadersavailable); -} - static void HWR_SetShaderState(void) { GL_SetSpecialState(HWD_SET_SHADERS, HWR_UseShader() ? 1 : 0); } -boolean HWR_ShouldUsePaletteRendering(void) -{ - return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader()); -} - -boolean HWR_PalRenderFlashpal(void) -{ - return (HWR_ShouldUsePaletteRendering() && cv_glflashpal.value); -} - void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite) { (void)papersprite; @@ -3188,7 +3173,7 @@ static gl_vissprite_t *gl_visspritechunks[MAXVISSPRITES >> VISSPRITECHUNKBITS] = // HWR_ClearSprites // Called at frame start. // -------------------------------------------------------------------------- -static void HWR_ClearSprites(void) +static inline void HWR_ClearSprites(void) { gl_visspritecount = 0; } @@ -5785,11 +5770,6 @@ static void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD #endif } -INT32 HWR_GetTextureUsed(void) -{ - return GL_GetTextureUsed(); -} - static void HWR_DoPostProcessor(player_t *player) { GL_UnSetShader(); @@ -5877,21 +5857,6 @@ static void HWR_DoPostProcessor(player_t *player) // Flipping of the screen isn't done here anymore } -void HWR_StartScreenWipe(void) -{ - GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_START); -} - -void HWR_EndScreenWipe(void) -{ - GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_END); -} - -void HWR_DrawIntermissionBG(void) -{ - GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); -} - void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) { static char lumpname[9] = "FADEmmss"; @@ -5926,19 +5891,4 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) GL_DoScreenWipe(HWD_SCREENTEXTURE_WIPE_START, HWD_SCREENTEXTURE_WIPE_END); } -void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) -{ - GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); -} - -void HWR_MakeScreenFinalTexture(void) -{ - GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); -} - -void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader) -{ - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height, useshader); -} - #endif // HWRENDER diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 0378fa634..40eb2d592 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -20,6 +20,7 @@ #ifndef __HWR_MAIN_H__ #define __HWR_MAIN_H__ +#include "hw_gl.h" #include "hw_glob.h" #include "hw_data.h" #include "hw_defs.h" @@ -29,6 +30,7 @@ #include "../d_player.h" #include "../r_defs.h" #include "../m_perfstats.h" +#include "../v_video.h" #define GLENCORE @@ -112,10 +114,6 @@ void HWR_SetTransform(float fpov); void HWR_ClearClipper(void); void HWR_SetStencilState(int state, int level); -boolean HWR_UseShader(void); -boolean HWR_ShouldUsePaletteRendering(void); -boolean HWR_PalRenderFlashpal(void); - // My original intention was to split hw_main.c // into files like hw_bsp.c, hw_sprites.c... @@ -124,17 +122,44 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf); -// Get amount of memory used by gpu textures in bytes -INT32 HWR_GetTextureUsed(void); +// Get amount of memory used by gpu textures in bytes; +FUNCINLINE static ATTRINLINE INT32 HWR_GetTextureUsed(void) +{ + return GL_GetTextureUsed(); +} // hw_main.c: Post-rendering -void HWR_StartScreenWipe(void); -void HWR_EndScreenWipe(void); -void HWR_DrawIntermissionBG(void); void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum); -void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); -void HWR_MakeScreenFinalTexture(void); -void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader); + +FUNCINLINE static ATTRINLINE void HWR_StartScreenWipe(void) +{ + GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_START); +} + +FUNCINLINE static ATTRINLINE void HWR_EndScreenWipe(void) +{ + GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_END); +} + +FUNCINLINE static ATTRINLINE void HWR_DrawIntermissionBG(void) +{ + GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); +} + +FUNCINLINE static ATTRINLINE void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) +{ + GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); +} + +FUNCINLINE static ATTRINLINE void HWR_MakeScreenFinalTexture(void) +{ + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); +} + +FUNCINLINE static ATTRINLINE void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader) +{ + GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height, useshader); +} // hw_main.c: Segs void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom @@ -185,4 +210,19 @@ extern consvar_t cv_glpaletterendering; extern consvar_t cv_glpalettedepth; extern consvar_t cv_glflashpal; +FUNCINLINE static ATTRINLINE boolean HWR_UseShader(void) +{ + return (cv_glshaders.value && gl_shadersavailable); +} + +FUNCINLINE static ATTRINLINE boolean HWR_ShouldUsePaletteRendering(void) +{ + return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader()); +} + +FUNCINLINE static ATTRINLINE boolean HWR_PalRenderFlashpal(void) +{ + return (HWR_ShouldUsePaletteRendering() && cv_glflashpal.value); +} + #endif diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index bf2861779..f590d2a0f 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -265,7 +265,7 @@ void OglSdlFinishUpdate(boolean waitvbl) } #endif - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, sdlw, sdlh, HWR_ShouldUsePaletteRendering()); + HWR_DrawScreenFinalTexture(sdlw, sdlh, HWR_ShouldUsePaletteRendering()); #ifdef USE_FBO_OGL if (usefbo) @@ -286,7 +286,7 @@ void OglSdlFinishUpdate(boolean waitvbl) #else if (!I_CheckNativeRes() || WipeInAction) #endif - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, realwidth, realheight, false); + HWR_DrawScreenFinalTexture(realwidth, realheight, false); #if defined (__unix__) #ifdef USE_FBO_OGL From 9cdfdf9bda65f979fcf82a421bb163ce3ab8a9f7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jan 2025 17:14:30 +0100 Subject: [PATCH 288/418] spawn speedlines with non synched rng if ur in eggbox status and well only if you have colourisation enabled --- src/k_kart.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 00ef9ec60..6e754cff9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5464,11 +5464,15 @@ void K_KartPlayerHUDUpdate(player_t *player) player->kartstuff[k_cardanimation] = 0; } -static inline void K_SpawnNormalSpeedLines(player_t *player) +typedef INT32 (*randomFunc)(INT32 min, INT32 max); + +static inline void K_SpawnNormalSpeedLines(player_t *player, boolean synched) { - mobj_t *fast = P_SpawnMobj(player->mo->x + (P_RandomRange(-36,36) * player->mo->scale), - player->mo->y + (P_RandomRange(-36,36) * player->mo->scale), - player->mo->z + (player->mo->height/2) + (P_RandomRange(-20,20) * player->mo->scale), + randomFunc randomfunc = synched ? P_RandomRange : M_RandomRange; + + mobj_t *fast = P_SpawnMobj(player->mo->x + (randomfunc(-36,36) * player->mo->scale), + player->mo->y + (randomfunc(-36,36) * player->mo->scale), + player->mo->z + (player->mo->height/2) + (randomfunc(-20,20) * player->mo->scale), MT_FASTLINE); fast->angle = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); @@ -5483,7 +5487,6 @@ static inline void K_SpawnNormalSpeedLines(player_t *player) { const boolean goodSpeed = (player->speed >= (3*K_GetKartSpeed(player, false))/4); - // cant have nice shit cause of synched rng if (player->kartstuff[k_eggmanexplode]) { // Make it red when you have the eggman speed boost @@ -5534,9 +5537,13 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) K_GetKartBoostPower(player); // Speed lines - if ((player->kartstuff[k_sneakertimer] || player->kartstuff[k_driftboost] || player->kartstuff[k_startboost] /*|| player->kartstuff[k_eggmanexplode]*/) && player->speed > 0) // gotta love the speedlines calling synched rng :chaosleep: + if ((player->kartstuff[k_sneakertimer] || player->kartstuff[k_driftboost] || player->kartstuff[k_startboost]) && player->speed > 0) { - K_SpawnNormalSpeedLines(player); + K_SpawnNormalSpeedLines(player, true); + } + else if (cv_coloredspeedlines.value && player->kartstuff[k_eggmanexplode]) // gotta love the speedlines calling synched rng :chaosleep: + { + K_SpawnNormalSpeedLines(player, false); } if (player->playerstate == PST_DEAD || player->kartstuff[k_respawn] > 1) // Ensure these are set correctly here From b7345107d76c26191a9312dfac1040fc5e6b899a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 Jan 2025 21:50:40 +0100 Subject: [PATCH 289/418] move this no need to have two conditions for same thing --- src/hu_stuff.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 24b3672a9..8332631b3 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2401,7 +2401,6 @@ void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) UINT8 barcolor = 31; // color we use for the bars (green, yellow, red or black) SINT8 i = 0; SINT8 yoffset = 6; - //INT32 dx; UINT32 lag = playerpingtable[pnum]; const boolean gentleman = ((cv_mindelay.value && (lag < (tic_t)cv_mindelay.value) && P_IsLocalPlayer(&players[pnum])) || (pnum == serverplayer && lowest_lag != 0)); // for serverplayer lowest_lag actually reflects mindelay @@ -2428,6 +2427,18 @@ void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) } else if (cv_pingstyle.value == 1) // old style ping { + if (vid.width >= 640) // how sad, we're using a shit resolution. + { + if (measureid == 1) + { + V_DrawRightAlignedSmallString(x+12, y+13, V_ALLOWLOWERCASE|flags, va("%dms", Ping_conversion(lag))); + } + else if (measureid == 0) + { + V_DrawRightAlignedSmallString(x+12, y+13, flags, va("d%d", Ping_conversion(lag))); + } + } + if (cv_pingicon.value) { if (lag < 4) @@ -2450,22 +2461,7 @@ void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) numbars = 0; barcolor = 31; } - } - if (vid.width >= 640) // how sad, we're using a shit resolution. - { - if (measureid == 1) - { - V_DrawRightAlignedSmallString(x+12, y+13, V_ALLOWLOWERCASE|flags, va("%dms", Ping_conversion(lag))); - } - else if (measureid == 0) - { - V_DrawRightAlignedSmallString(x+12, y+13, flags, va("d%d", Ping_conversion(lag))); - } - } - - if (cv_pingicon.value) - { for (i = 0; (i < 3); i++) // Draw the ping bar { V_DrawFill(x+2 *(i-1)+7, y+8+yoffset-4, 2, 8-yoffset, 31|flags); From 6d671b6576a3552cf673ca62d29995dde0df5306 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 Jan 2025 22:13:39 +0100 Subject: [PATCH 290/418] draw non widescreen anim vote bg before falling back to vanilla bg how it was before, the game just fallback to the vanila widescreen patch if there was no animated widescreen bg provided, just fall back to the non widescreen anim patch instead if it exists --- src/y_inter.c | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 8f849f1cb..f361faf1f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -300,7 +300,7 @@ static void Y_AnimatedVoteScreenCheck(void) strncpy(tmpPrefix, luaVoteScreen, 4); else { - if(G_BattleGametype()) + if (G_BattleGametype()) strcpy(tmpPrefix, "BTLS"); } @@ -919,20 +919,12 @@ static void Y_UnloadData(void) static inline void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) { char tempAnimPrefix[7]; - (widePatch) ? strcpy(tempAnimPrefix, animWidePrefix) : strcpy(tempAnimPrefix, animPrefix); - INT32 tempFoundAnimVoteFrames = (widePatch) ? foundAnimVoteWideFrames : foundAnimVoteFrames; + widePatch ? strcpy(tempAnimPrefix, animWidePrefix) : strcpy(tempAnimPrefix, animPrefix); + const INT32 tempFoundAnimVoteFrames = widePatch ? foundAnimVoteWideFrames : foundAnimVoteFrames; // Just in case someone provides LESS widescreen frames than normal frames or vice versa, reset the frame counter to 0 - if (widePatch) - { - if (currentAnimFrame > foundAnimVoteWideFrames-1) - currentAnimFrame = 0; - } - else - { - if (currentAnimFrame > foundAnimVoteFrames-1) - currentAnimFrame = 0; - } + if (currentAnimFrame > tempFoundAnimVoteFrames - 1) + currentAnimFrame = 0; patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_CACHE); V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(background->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) @@ -969,23 +961,27 @@ void Y_VoteDrawer(void) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - if (widebgpatch && vid.width / vid.dupx > 320) + const boolean widescreen = (vid.width / vid.dupx > 320); + + if (foundAnimVoteWideFrames && widescreen) { - if (foundAnimVoteWideFrames == 0) - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(widebgpatch->width)/2), - (vid.height / vid.dupy) - SHORT(widebgpatch->height), - V_SNAPTOTOP|V_SNAPTOLEFT, widebgpatch); - else - Y_DrawAnimatedVoteScreenPatch(true); + Y_DrawAnimatedVoteScreenPatch(true); + } + else if (foundAnimVoteFrames) + { + Y_DrawAnimatedVoteScreenPatch(false); + } + else if (widebgpatch && widescreen) + { + V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(widebgpatch->width)/2), + (vid.height / vid.dupy) - SHORT(widebgpatch->height), + V_SNAPTOTOP|V_SNAPTOLEFT, widebgpatch); } else { - if (foundAnimVoteFrames == 0) - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(bgpatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) - (vid.height / vid.dupy) - SHORT(bgpatch->height), - V_SNAPTOTOP|V_SNAPTOLEFT, bgpatch); - else - Y_DrawAnimatedVoteScreenPatch(false); + V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(bgpatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) + (vid.height / vid.dupy) - SHORT(bgpatch->height), + V_SNAPTOTOP|V_SNAPTOLEFT, bgpatch); } for (i = 0; i < 4; i++) // First, we need to figure out the height of this thing... From bcf713932a446c18c12929631475ca0e2b584388 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 Jan 2025 22:44:22 +0100 Subject: [PATCH 291/418] reduce scope of those makes it look slightly neater --- src/screen.c | 18 ++++++++++-------- src/y_inter.c | 3 +-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/screen.c b/src/screen.c index 5ae4f8d72..f6a94c052 100644 --- a/src/screen.c +++ b/src/screen.c @@ -443,22 +443,20 @@ void SCR_CalculateFPS(void) void SCR_DisplayTicRate(void) { - const UINT8 *ticcntcolor = NULL; UINT32 cap = R_GetFramerateCap(); UINT32 benchmark = (cap == 0) ? I_GetRefreshRate() : cap; - INT32 x = 318; double fps = round(averageFPS); INT32 fpsflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; - const char *fps_string; - - INT32 ticcntcolor2 = 0; - + if (gamestate == GS_NULL) return; // new kart counter if (cv_ticrate.value == 1 || cv_ticrate.value == 2) { + const UINT8 *ticcntcolor = NULL; + INT32 x = 318; + // draw "FPS" if (cv_ticrate.value == 1) V_DrawFixedPatch(306< (benchmark - 5)) ticcntcolor2 = V_GREENMAP; else if (fps < 20) @@ -502,7 +503,8 @@ void SCR_DisplayTicRate(void) fps_string = va("%d/%d\x82", (INT32)fps, cap); else fps_string = va("%d\x82", (INT32)fps); - + + // draw "FPS" if (cv_ticrate.value == 3) V_DrawRightAlignedString(319, 181, V_YELLOWMAP|fpsflags, "FPS"); @@ -518,7 +520,7 @@ void SCR_DisplayLocalPing(void) UINT32 ping = playerpingtable[consoleplayer]; INT32 pingflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; - if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level + if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level { INT32 dispy = (cv_ticrate.value == 1) ? 165 : ((cv_ticrate.value == 2 || cv_ticrate.value == 4) ? 172 : ((cv_ticrate.value == 3) ? 163 : 181)); // absolute buttpain diff --git a/src/y_inter.c b/src/y_inter.c index f361faf1f..422f03e6c 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -314,7 +314,7 @@ static void Y_AnimatedVoteScreenCheck(void) currentAnimFrame = 0; INT32 i = 1; - while(!stopSearching) + while (!stopSearching) { boolean normalLumpExists = W_LumpExists(va("%sC%d", tmpPrefix, i)); boolean wideLumpExists = W_LumpExists(va("%sW%d", tmpPrefix, i)); @@ -414,7 +414,6 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) else faceprefix = (cv_highresportrait.value ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); - if (cv_highresportrait.value) V_DrawSmallMappedPatch(x + 16, y - 4, 0, faceprefix, colormap); else From 2104822cac3151b1fc8e3aec6dea2a4ffecd6029 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 26 Jan 2025 16:18:41 +0100 Subject: [PATCH 292/418] forgor about the banan spin --- src/p_mobj.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 72136f784..2efecde99 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7065,8 +7065,22 @@ void P_MobjThinker(mobj_t *mobj) } break; //{ SRB2kart Items - Death States - case MT_ORBINAUT: case MT_BANANA: + { + if (cv_sloperoll.value == 2 && cv_bananthrowroll.value) + { + angle_t spin = FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); + //mobj->angle -= spin; + + if (cv_bananthrowroll.value == 1) + mobj->sloperoll += spin; // im lazy but this makes sure the banan goes back to upright when it lands lmao + else if (cv_bananthrowroll.value == 2) + mobj->rollangle += spin; + + //if (P_IsObjectOnGround(mobj) && mobj->momz * P_MobjFlip(mobj) <= 0) + } + } + case MT_ORBINAUT: case MT_EGGMANITEM: case MT_SPB: if (P_IsObjectOnGround(mobj)) @@ -7807,6 +7821,18 @@ void P_MobjThinker(mobj_t *mobj) break; } case MT_BANANA: + if (cv_sloperoll.value == 2 && cv_bananthrowroll.value && !P_IsObjectOnGround(mobj)) + { + // tilt n tumble + angle_t spin = FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); + //mobj->angle += spin; + + if (cv_bananthrowroll.value == 1) + mobj->sloperoll -= spin; // im lazy but this makes sure the banan goes back to upright when it lands lmao + else if (cv_bananthrowroll.value == 2) + mobj->rollangle -= spin; + } + case MT_EGGMANITEM: mobj->friction = ORIG_FRICTION/4; if (mobj->momx || mobj->momy) From 39c747e430e8bcb3f8b149fc805d7561bdbe998c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 26 Jan 2025 17:57:27 +0100 Subject: [PATCH 293/418] handle vote bg fallbacks more gracefully if someone doesent provide a widescreen patch it now falls back to the replaced non widescreen one and vice versa instead of just falling back to what vanilla provides --- src/p_setup.c | 41 +++++++++++++++++++++++++++++++ src/p_setup.h | 5 ++++ src/y_inter.c | 67 +++++++++++++++++++++++++++++++++------------------ 3 files changed, 90 insertions(+), 23 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 92ae9e4e3..d13a35512 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3212,6 +3212,12 @@ boolean P_AddWadFileLocal(const char *wadfilename) return true; } +// check for replacement votescreen backgrounds +boolean wideracereplaced = false; +boolean racereplaced = false; +boolean widebattlereplaced = false; +boolean battlereplaced = false; + // // Add a WAD file and do the per-WAD setup stages. // Call P_MultiSetupWadFiles as soon as possible after any number of these. @@ -3336,6 +3342,41 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) // TODO: Experimental SPRTINFO support, test first R_LoadSpriteInfoLumps(wadnum, wadfiles[wadnum]->numlumps); + // + // check for votescreen replacements + // + lumpinfo = wadfiles[wadnum]->lumpinfo; + for (i = 0; i < numlumps; i++, lumpinfo++) + { + name = lumpinfo->name; + + // widescreen patch Race + if (!wideracereplaced && !strncmp(name, "INTERSCW", 8)) + { + wideracereplaced = true; + continue; + } + + if (!racereplaced && !strncmp(name, "INTERSCR", 8)) + { + racereplaced = true; + continue; + } + + // widescreen patch Battle + if (!widebattlereplaced && !strncmp(name, "BATTLSCW", 8)) + { + widebattlereplaced = true; + continue; + } + + if (!battlereplaced && !strncmp(name, "BATTLSCR", 8)) + { + battlereplaced = true; + continue; + } + } + refreshdirmenu &= ~REFRESHDIR_GAMEDATA; // Under usual circumstances we'd wait for REFRESHDIR_GAMEDATA to disappear the next frame, but it's a bit too dangerous for that... partadd_stage = 0; return wadnum; diff --git a/src/p_setup.h b/src/p_setup.h index 79acfff3f..f2eee72c2 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -67,6 +67,11 @@ void HWR_LoadLevel(void); boolean P_AddWadFile(const char *wadfilename, boolean local); boolean P_AddWadFileLocal(const char *wadfilename); +extern boolean wideracereplaced; +extern boolean racereplaced; +extern boolean widebattlereplaced; +extern boolean battlereplaced; + // WARNING: The following functions should be grouped as follows: // any amount of PartialAdds followed by MultiSetups until returned true, // as soon as possible. diff --git a/src/y_inter.c b/src/y_inter.c index 422f03e6c..32454a685 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -915,7 +915,7 @@ static void Y_UnloadData(void) // // Draw animated patch based on frame counter on vote screen // -static inline void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) +static void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) { char tempAnimPrefix[7]; widePatch ? strcpy(tempAnimPrefix, animWidePrefix) : strcpy(tempAnimPrefix, animPrefix); @@ -934,6 +934,47 @@ static inline void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) currentAnimFrame = (currentAnimFrame + 1 > tempFoundAnimVoteFrames - 1) ? 0 : currentAnimFrame + 1; } +static void Y_DrawVoteScreenPatch(void) +{ + const boolean widescreen = (vid.width / vid.dupx > 320); + const boolean animvote = (foundAnimVoteWideFrames || foundAnimVoteFrames); + + if (animvote) + { + Y_DrawAnimatedVoteScreenPatch((foundAnimVoteWideFrames && widescreen)); + return; + } + + patch_t *votebg = bgpatch; + UINT8 prefgametype = (votelevels[0][1] & ~0x80); + const boolean widebgreplaced = (prefgametype == GT_MATCH) ? widebattlereplaced : wideracereplaced; + const boolean bgreplaced = (prefgametype == GT_MATCH) ? battlereplaced : racereplaced; + + // this is horrid + if (widescreen) + { + if (widebgreplaced) + votebg = widebgpatch; + else if (bgreplaced) + votebg = bgpatch; + else + votebg = widebgpatch; + } + else + { + if (bgreplaced) + votebg = bgpatch; + else if (widebgreplaced) + votebg = widebgpatch; + else + votebg = bgpatch; + } + + V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(votebg->width)/2), + (vid.height / vid.dupy) - SHORT(votebg->height), + V_SNAPTOTOP|V_SNAPTOLEFT, votebg); +} + // // Y_VoteDrawer // @@ -960,28 +1001,8 @@ void Y_VoteDrawer(void) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - const boolean widescreen = (vid.width / vid.dupx > 320); - - if (foundAnimVoteWideFrames && widescreen) - { - Y_DrawAnimatedVoteScreenPatch(true); - } - else if (foundAnimVoteFrames) - { - Y_DrawAnimatedVoteScreenPatch(false); - } - else if (widebgpatch && widescreen) - { - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(widebgpatch->width)/2), - (vid.height / vid.dupy) - SHORT(widebgpatch->height), - V_SNAPTOTOP|V_SNAPTOLEFT, widebgpatch); - } - else - { - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(bgpatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) - (vid.height / vid.dupy) - SHORT(bgpatch->height), - V_SNAPTOTOP|V_SNAPTOLEFT, bgpatch); - } + // decides which votebg to draw and draws it + Y_DrawVoteScreenPatch(); for (i = 0; i < 4; i++) // First, we need to figure out the height of this thing... { From b09025df08cadac4d0330420f5f5eda99d00f8d7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 26 Jan 2025 18:18:23 +0100 Subject: [PATCH 294/418] delet if else hell --- src/y_inter.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 32454a685..505c85997 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -945,29 +945,16 @@ static void Y_DrawVoteScreenPatch(void) return; } - patch_t *votebg = bgpatch; + patch_t *votebg = bgpatch; // non widescreen patch + UINT8 prefgametype = (votelevels[0][1] & ~0x80); const boolean widebgreplaced = (prefgametype == GT_MATCH) ? widebattlereplaced : wideracereplaced; const boolean bgreplaced = (prefgametype == GT_MATCH) ? battlereplaced : racereplaced; - // this is horrid - if (widescreen) + if ((widescreen && (widebgreplaced || !bgreplaced)) + || (!widescreen && (widebgreplaced && !bgreplaced))) { - if (widebgreplaced) - votebg = widebgpatch; - else if (bgreplaced) - votebg = bgpatch; - else - votebg = widebgpatch; - } - else - { - if (bgreplaced) - votebg = bgpatch; - else if (widebgreplaced) - votebg = widebgpatch; - else - votebg = bgpatch; + votebg = widebgpatch; } V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(votebg->width)/2), From 8543636576eb31c572c9603623c43c37da85060f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 26 Jan 2025 17:29:19 +0100 Subject: [PATCH 295/418] fall through deez --- src/p_mobj.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 2efecde99..a49467c00 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7066,7 +7066,6 @@ void P_MobjThinker(mobj_t *mobj) break; //{ SRB2kart Items - Death States case MT_BANANA: - { if (cv_sloperoll.value == 2 && cv_bananthrowroll.value) { angle_t spin = FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); @@ -7079,7 +7078,7 @@ void P_MobjThinker(mobj_t *mobj) //if (P_IsObjectOnGround(mobj) && mobj->momz * P_MobjFlip(mobj) <= 0) } - } + /* FALLTHRU */ case MT_ORBINAUT: case MT_EGGMANITEM: case MT_SPB: @@ -7832,7 +7831,7 @@ void P_MobjThinker(mobj_t *mobj) else if (cv_bananthrowroll.value == 2) mobj->rollangle -= spin; } - + /* FALLTHRU */ case MT_EGGMANITEM: mobj->friction = ORIG_FRICTION/4; if (mobj->momx || mobj->momy) From ccc0189e70b6a78f3d6426220c40c52cc34e4974 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 26 Jan 2025 21:17:20 +0100 Subject: [PATCH 296/418] also rotate eggboxes in air --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index a49467c00..a731bd366 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7820,6 +7820,7 @@ void P_MobjThinker(mobj_t *mobj) break; } case MT_BANANA: + case MT_EGGMANITEM: if (cv_sloperoll.value == 2 && cv_bananthrowroll.value && !P_IsObjectOnGround(mobj)) { // tilt n tumble @@ -7831,8 +7832,7 @@ void P_MobjThinker(mobj_t *mobj) else if (cv_bananthrowroll.value == 2) mobj->rollangle -= spin; } - /* FALLTHRU */ - case MT_EGGMANITEM: + mobj->friction = ORIG_FRICTION/4; if (mobj->momx || mobj->momy) P_SpawnGhostMobj(mobj); From 0dd4f3b3d32b0751c7a41eaab4ff98b2c42d9e07 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Jan 2025 09:19:25 +0100 Subject: [PATCH 297/418] make old ping bar be blue on d1 aswell as purple with mindelay --- src/hu_stuff.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 62b29de59..b22e69b2b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2490,25 +2490,33 @@ void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) { if (cv_pingicon.value) { - if (lag < 4) + switch (lag) { - numbars = 3; - barcolor = 184; + case 0 ... 1: + numbars = 3; + barcolor = 215; // Blue + break; + case 2 ... 3: + numbars = 3; + barcolor = 184; // Green + break; + case 4 ... 6: + numbars = 2; // Apparently ternaries w/ multiple statements don't look good in C so I decided against it. + barcolor = 103; // Yellow + break; + case 7 ... 9: + numbars = 1; + barcolor = 155; // Red + break; + default: // Brazil + numbars = 0; + barcolor = 31; // black + break; } - else if (lag < 7) + + if (gentleman) { - numbars = 2; // Apparently ternaries w/ multiple statements don't look good in C so I decided against it. - barcolor = 103; - } - else if (lag < 10) - { - numbars = 1; - barcolor = 155; // need a better red - } - else // brazil - { - numbars = 0; - barcolor = 31; + barcolor = 194; // make it purplish } } From 97e5de1ee54a3ec44e7ddfd0e24b28e714e32598 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Jan 2025 11:21:23 +0100 Subject: [PATCH 298/418] smol optimization comparePolygon return slightly earlier for skywalls and horizonlines --- src/hardware/hw_batching.c | 40 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 2ae7be05e..3c7a49af9 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -141,27 +141,19 @@ static int comparePolygons(const void *p1, const void *p2) PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; int diff; INT64 diff64; - UINT32 downloaded1 = 0; - UINT32 downloaded2 = 0; - int shader1 = poly1->shader; - int shader2 = poly2->shader; - // make skywalls and horizon lines first in order - if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) - shader1 = -1; - if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) - shader2 = -1; - diff = shader1 - shader2; - if (diff != 0) return diff; + int shader1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? -1 : poly1->shader; + int shader2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? -1 : poly2->shader; // skywalls and horizon lines must retain their order for horizon lines to work if (shader1 == -1 && shader2 == -1) return poly1 - poly2; - if (poly1->texture) - downloaded1 = poly1->texture->downloaded; // there should be a opengl texture name here, usable for comparisons - if (poly2->texture) - downloaded2 = poly2->texture->downloaded; + diff = shader1 - shader2; + if (diff != 0) return diff; + + UINT32 downloaded1 = poly1->texture ? poly1->texture->downloaded : 0; // there should be a opengl texture name here, usable for comparisons + UINT32 downloaded2 = poly2->texture ? poly2->texture->downloaded : 0; diff64 = downloaded1 - downloaded2; if (diff64 != 0) return diff64; @@ -194,21 +186,15 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2) int diff; INT64 diff64; - GLMipmap_t *texture1 = poly1->texture; - GLMipmap_t *texture2 = poly2->texture; - UINT32 downloaded1 = 0; - UINT32 downloaded2 = 0; - if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) - texture1 = NULL; - if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) - texture2 = NULL; - if (texture1) - downloaded1 = texture1->downloaded; // there should be a opengl texture name here, usable for comparisons - if (texture2) - downloaded2 = texture2->downloaded; + GLMipmap_t *texture1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? NULL : poly1->texture; + GLMipmap_t *texture2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? NULL : poly2->texture; + // skywalls and horizon lines must retain their order for horizon lines to work if (!texture1 && !texture2) return poly1 - poly2; + + UINT32 downloaded1 = texture1 ? texture1->downloaded : 0; // there should be a opengl texture name here, usable for comparisons + UINT32 downloaded2 = texture2 ? texture2->downloaded : 0; diff64 = downloaded1 - downloaded2; if (diff64 != 0) return diff64; From 90fd4b54b3409944fc491103f116e8e5a40c5834 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Jan 2025 14:54:49 +0100 Subject: [PATCH 299/418] i hate conditions --- src/s_sound.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 526b6c6b4..84f6350ea 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1998,7 +1998,10 @@ void S_InitMapMusic(void) { char *maptitle = G_BuildMapTitle(gamemap); // for some reason, occasionally the title screen music doesent seem to be reset in time, so skipping the intro may make it just continue playing it instead, weird.. - skipintromus = (stricmp(music_name, "titles") != 0) && (maptitle && (stricmp(maptitle, "Wandering Falls") != 0)); // thanks diggle! + skipintromus = true; + if (!stricmp(music_name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // thanks diggle! + skipintromus = false; + if (maptitle) Z_Free(maptitle); } From 9b7ec4f26646b41daa4574edb89997da13affd0d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Jan 2025 15:32:47 +0100 Subject: [PATCH 300/418] the music system is truly amazing --- src/p_spec.c | 2 +- src/s_sound.c | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index e48a304b8..2af086c57 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2080,7 +2080,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 413: // Change music - if (keepmusic && (leveltime <= MUSICSTARTTIME)) //why check for starttime? cause encore music Zzz... + if (keepmusic && (leveltime <= MUSICSTARTTIME)) // why check for starttime? cause encore music Zzz... return; //if (cv_ignoremusicchanges.value && (leveltime >= MUSICSTARTTIME) && !fromlapexec) // keep lap music intanct tho diff --git a/src/s_sound.c b/src/s_sound.c index 84f6350ea..bf736cb27 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1721,6 +1721,9 @@ static void S_ChangeMusicToQueue(void) S_ClearQueue(); } +static boolean skipmusic = false; +static boolean S_CheckMusicException(const char *music); + void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms) { char newmusic[7] = {0}; @@ -1741,6 +1744,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 strncpy(newmusic, mmusic, 6); + skipmusic = S_CheckMusicException(newmusic); + if (LUA_HookMusicChange(music_name, &hook_param)) return; @@ -1937,6 +1942,20 @@ static const char *musicexception_list[] = { "CHRSHF", "CHRSHP" // no clue what those are tbh }; +// check if the current music is smth we dont want to keep (vote music, etc) +static boolean S_CheckMusicException(const char *music) +{ + for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) + { + if (!stricmp(music, musicexception_list[i])) + { + return true; + } + } + + return false; +} + void S_ResetKeepAndSpecialMus(void) { keepmusic = skipintromus = false; @@ -1954,17 +1973,7 @@ void S_KeepMusic(void) } else if (oldmap == gamemap && oldencore == encoremode) { - keepmusic = true; - - // check if the current music is smth we dont want to keep (vote music, etc) - for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) - { - if (stricmp(music_name, musicexception_list[i]) == 0) - { - keepmusic = false; - break; - } - } + keepmusic = !skipmusic && !S_CheckMusicException(music_name); // have to recheck cause lua may have overwritten initial music_change } oldencore = encoremode; From 27fd087631aed93f89ec3ae1d3279dbf0f09955c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Jan 2025 16:11:53 +0100 Subject: [PATCH 301/418] grow an invinc music also broke stuff cant put it into the music exception list, otherwise it will always disable keepmusic when either one was used even once --- src/s_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index bf736cb27..9eff0fe83 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1973,7 +1973,7 @@ void S_KeepMusic(void) } else if (oldmap == gamemap && oldencore == encoremode) { - keepmusic = !skipmusic && !S_CheckMusicException(music_name); // have to recheck cause lua may have overwritten initial music_change + keepmusic = !skipmusic && !S_CheckMusicException(music_name) && stricmp(music_name, "kgrow") && stricmp(music_name, "kinvnc"); // have to recheck cause lua may have overwritten initial music_change } oldencore = encoremode; From 7163337a27358d1dc9a1253b2fa29692e13640c0 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Jan 2025 16:43:48 +0100 Subject: [PATCH 302/418] just keep a copy of musicchange before the lua hook keep music can check for what was it stuff changed last to --- src/s_sound.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 9eff0fe83..7061eaea3 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1721,8 +1721,9 @@ static void S_ChangeMusicToQueue(void) S_ClearQueue(); } -static boolean skipmusic = false; -static boolean S_CheckMusicException(const char *music); +// keep copy of music name before lua hook change +// for custom vote music etc +static char checkmusic[7] = {0}; void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms) { @@ -1743,8 +1744,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; strncpy(newmusic, mmusic, 6); - - skipmusic = S_CheckMusicException(newmusic); + strncpy(checkmusic, mmusic, 6); if (LUA_HookMusicChange(music_name, &hook_param)) return; @@ -1938,16 +1938,17 @@ static const char *musicexception_list[] = { "vote", "voteea", "voteeb", "racent", "krwin", "krok", "krlose", "krfail", "kbwin", "kbok", "kblose", "kstart", "estart", "wait2j", "titles", + "kinvnc", "kgrow", // grow and invinc "SPBA_W", "SPBA_L", // SPB Attack music - "CHRSHF", "CHRSHP" // no clue what those are tbh + "CHRSHF", "CHRSHP" // no clue what those are tbh }; // check if the current music is smth we dont want to keep (vote music, etc) -static boolean S_CheckMusicException(const char *music) +static boolean S_CheckMusicException(void) { for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) { - if (!stricmp(music, musicexception_list[i])) + if (!stricmp(music_name, musicexception_list[i]) || !stricmp(checkmusic, musicexception_list[i])) { return true; } @@ -1973,7 +1974,7 @@ void S_KeepMusic(void) } else if (oldmap == gamemap && oldencore == encoremode) { - keepmusic = !skipmusic && !S_CheckMusicException(music_name) && stricmp(music_name, "kgrow") && stricmp(music_name, "kinvnc"); // have to recheck cause lua may have overwritten initial music_change + keepmusic = !S_CheckMusicException(); } oldencore = encoremode; From f78b41dde36616cbe5baede4b701892489f6dc96 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Jan 2025 22:25:34 +0100 Subject: [PATCH 303/418] only recalc floorz for visible precip mobjs before it apparently recalced it a crapton for the crapton not visible precipmobjs, which even on vanilla maps led to noticable jitter --- src/p_floor.c | 28 +++---- src/p_local.h | 4 - src/p_map.c | 220 ------------------------------------------------- src/p_maputl.c | 7 -- src/p_mobj.c | 31 +------ src/r_defs.h | 14 ---- 6 files changed, 15 insertions(+), 289 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index e81dce5bc..887385035 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -327,7 +327,7 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case bounceFloorCrush: // Graue 03-27-2004 if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight) @@ -343,14 +343,14 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case crushFloorOnce: movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight; movefloor->direction = -1; movefloor->sector->soundorg.z = movefloor->sector->floorheight; S_StartSound(&movefloor->sector->soundorg,sfx_pstop); - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; default: break; @@ -376,7 +376,7 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case bounceFloorCrush: // Graue 03-27-2004 if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight) @@ -392,13 +392,13 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case crushFloorOnce: movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it P_RemoveThinker(&movefloor->thinker); movefloor->sector->floorspeed = 0; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; default: break; @@ -415,7 +415,7 @@ void T_MoveFloor(floormove_t *movefloor) else movefloor->sector->floorspeed = 0; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; } // @@ -817,7 +817,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) bouncer->sector->floorheight = bouncer->sector->ceilingheight - (halfheight*2); T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, 0, 1, -1); // update things on ceiling T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor - P_RecalcPrecipInSector(actionsector); bouncer->sector->ceilingdata = NULL; bouncer->sector->floordata = NULL; bouncer->sector->floorspeed = 0; @@ -833,7 +832,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) bouncer->sector->floorheight = floorheight; T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, 0, 1, -1); // update things on ceiling T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor - P_RecalcPrecipInSector(actionsector); bouncer->sector->ceilingdata = NULL; bouncer->sector->floordata = NULL; bouncer->sector->floorspeed = 0; @@ -913,9 +911,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) if (bouncer->distance > 0) bouncer->distance--; - - if (actionsector) - P_RecalcPrecipInSector(actionsector); } #undef speed #undef distance @@ -1102,7 +1097,6 @@ void T_StartCrumble(elevator_t *elevator) { sector = §ors[i]; sector->moved = true; - P_RecalcPrecipInSector(sector); } } @@ -1156,7 +1150,7 @@ void T_MarioBlock(levelspecthink_t *block) } for (i = -1; (i = P_FindSectorFromTag((INT16)block->vars[0], i)) >= 0 ;) - P_RecalcPrecipInSector(§ors[i]); + sectors[i].moved = true; #undef speed #undef direction @@ -1272,7 +1266,7 @@ void T_FloatSector(levelspecthink_t *floater) else if (floater->sector->crumblestate == 0 || floater->sector->crumblestate >= 3/* || floatanyway*/) EV_BounceSector(floater->sector, FRACUNIT, floater->sourceline); - P_RecalcPrecipInSector(actionsector); + actionsector->moved = true; } } @@ -1974,7 +1968,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) thwomp->sector->floorspeed = 0; } - P_RecalcPrecipInSector(actionsector); + actionsector->moved = true; #undef speed #undef direction #undef distance @@ -2503,7 +2497,7 @@ void T_RaiseSector(levelspecthink_t *raise) raise->sector->floorspeed = raise->vars[3]*raise->vars[8]; for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;) - P_RecalcPrecipInSector(§ors[i]); + sectors[i].moved = true; } void T_CameraScanner(elevator_t *elevator) diff --git a/src/p_local.h b/src/p_local.h index 6f61d9cd7..6043f794f 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -258,7 +258,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); mobj_t *P_SpawnShadowMobj(mobj_t * caster); -void P_RecalcPrecipInSector(sector_t *sector); void P_PrecipitationEffects(void); void P_RemoveMobj(mobj_t *th); @@ -373,8 +372,6 @@ extern line_t *ceilingline; extern line_t *blockingline; extern msecnode_t *sector_list; -extern mprecipsecnode_t *precipsector_list; - void P_UnsetThingPosition(mobj_t *thing); void P_SetThingPosition(mobj_t *thing); void P_SetUnderlayPosition(mobj_t *thing); @@ -398,7 +395,6 @@ void P_CheckHoopPosition(mobj_t *hoopthing, fixed_t x, fixed_t y, fixed_t z, fix boolean P_CheckSector(sector_t *sector, boolean crunch); void P_DelSeclist(msecnode_t *node); -void P_DelPrecipSeclist(mprecipsecnode_t *node); void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y); void P_Initsecnode(void); diff --git a/src/p_map.c b/src/p_map.c index 4793b4fa3..3d588a98d 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -47,9 +47,6 @@ static INT32 tmflags; fixed_t tmx; fixed_t tmy; -static precipmobj_t *tmprecipthing; -static fixed_t preciptmbbox[4]; - // If "floatok" true, move would be ok // if within "tmfloorz - tmceilingz". boolean floatok; @@ -69,7 +66,6 @@ line_t *ceilingline; line_t *blockingline; msecnode_t *sector_list = NULL; -mprecipsecnode_t *precipsector_list = NULL; camera_t *mapcampointer; // @@ -3727,8 +3723,6 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) sec->moved = true; - P_RecalcPrecipInSector(sec); - if (!sector->attachedsolid[i]) continue; @@ -3789,8 +3783,6 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) sec->moved = true; - P_RecalcPrecipInSector(sec); - if (!sector->attachedsolid[i]) continue; @@ -3841,12 +3833,10 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) */ static msecnode_t *headsecnode = NULL; -static mprecipsecnode_t *headprecipsecnode = NULL; void P_Initsecnode(void) { headsecnode = NULL; - headprecipsecnode = NULL; } // P_GetSecnode() retrieves a node from the freelist. The calling routine @@ -3866,20 +3856,6 @@ static msecnode_t *P_GetSecnode(void) return node; } -static mprecipsecnode_t *P_GetPrecipSecnode(void) -{ - mprecipsecnode_t *node; - - if (headprecipsecnode) - { - node = headprecipsecnode; - headprecipsecnode = headprecipsecnode->m_thinglist_next; - } - else - node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL); - return node; -} - // P_PutSecnode() returns a node to the freelist. static inline void P_PutSecnode(msecnode_t *node) @@ -3888,13 +3864,6 @@ static inline void P_PutSecnode(msecnode_t *node) headsecnode = node; } -// Tails 08-25-2002 -static inline void P_PutPrecipSecnode(mprecipsecnode_t *node) -{ - node->m_thinglist_next = headprecipsecnode; - headprecipsecnode = node; -} - // P_AddSecnode() searches the current list to see if this sector is // already there. If not, it adds a sector node at the head of the list of // sectors this object appears in. This is called when creating a list of @@ -3940,47 +3909,6 @@ static msecnode_t *P_AddSecnode(sector_t *s, mobj_t *thing, msecnode_t *nextnode return node; } -// More crazy crap Tails 08-25-2002 -static mprecipsecnode_t *P_AddPrecipSecnode(sector_t *s, precipmobj_t *thing, mprecipsecnode_t *nextnode) -{ - mprecipsecnode_t *node; - - node = nextnode; - while (node) - { - if (node->m_sector == s) // Already have a node for this sector? - { - node->m_thing = thing; // Yes. Setting m_thing says 'keep it'. - return nextnode; - } - node = node->m_sectorlist_next; - } - - // Couldn't find an existing node for this sector. Add one at the head - // of the list. - - node = P_GetPrecipSecnode(); - - // mark new nodes unvisited. - node->visited = 0; - - node->m_sector = s; // sector - node->m_thing = thing; // mobj - node->m_sectorlist_prev = NULL; // prev node on Thing thread - node->m_sectorlist_next = nextnode; // next node on Thing thread - if (nextnode) - nextnode->m_sectorlist_prev = node; // set back link on Thing - - // Add new node at head of sector thread starting at s->touching_thinglist - - node->m_thinglist_prev = NULL; // prev node on sector thread - node->m_thinglist_next = s->touching_preciplist; // next node on sector thread - if (s->touching_preciplist) - node->m_thinglist_next->m_thinglist_prev = node; - s->touching_preciplist = node; - return node; -} - // P_DelSecnode() deletes a sector node from the list of // sectors this object appears in. Returns a pointer to the next node // on the linked list, or NULL. @@ -4023,45 +3951,6 @@ static msecnode_t *P_DelSecnode(msecnode_t *node) return tn; } -// Tails 08-25-2002 -static mprecipsecnode_t *P_DelPrecipSecnode(mprecipsecnode_t *node) -{ - mprecipsecnode_t *tp; // prev node on thing thread - mprecipsecnode_t *tn; // next node on thing thread - mprecipsecnode_t *sp; // prev node on sector thread - mprecipsecnode_t *sn; // next node on sector thread - - if (!node) - return NULL; - - // Unlink from the Thing thread. The Thing thread begins at - // sector_list and not from mobj_t->touching_sectorlist. - - tp = node->m_sectorlist_prev; - tn = node->m_sectorlist_next; - if (tp) - tp->m_sectorlist_next = tn; - if (tn) - tn->m_sectorlist_prev = tp; - - // Unlink from the sector thread. This thread begins at - // sector_t->touching_thinglist. - - sp = node->m_thinglist_prev; - sn = node->m_thinglist_next; - if (sp) - sp->m_thinglist_next = sn; - else - node->m_sector->touching_preciplist = sn; - if (sn) - sn->m_thinglist_prev = sp; - - // Return this node to the freelist - - P_PutPrecipSecnode(node); - return tn; -} - // Delete an entire sector list void P_DelSeclist(msecnode_t *node) { @@ -4069,13 +3958,6 @@ void P_DelSeclist(msecnode_t *node) node = P_DelSecnode(node); } -// Tails 08-25-2002 -void P_DelPrecipSeclist(mprecipsecnode_t *node) -{ - while (node) - node = P_DelPrecipSecnode(node); -} - // PIT_GetSectors // Locates all the sectors the object is in by looking at the lines that // cross through it. You have already decided that the object is allowed @@ -4116,41 +3998,6 @@ static inline boolean PIT_GetSectors(line_t *ld) return true; } -// Tails 08-25-2002 -static inline boolean PIT_GetPrecipSectors(line_t *ld) -{ - if (preciptmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || - preciptmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || - preciptmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || - preciptmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - return true; - - if (P_BoxOnLineSide(preciptmbbox, ld) != -1) - return true; - - if (ld->polyobj) // line belongs to a polyobject, don't add it - return true; - - // This line crosses through the object. - - // Collect the sector(s) from the line and add to the - // sector_list you're examining. If the Thing ends up being - // allowed to move to this position, then the sector_list - // will be attached to the Thing's mobj_t at touching_sectorlist. - - precipsector_list = P_AddPrecipSecnode(ld->frontsector, tmprecipthing, precipsector_list); - - // Don't assume all lines are 2-sided, since some Things - // like MT_TFOG are allowed regardless of whether their radius takes - // them beyond an impassable linedef. - - // Use sidedefs instead of 2s flag to determine two-sidedness. - if (ld->backsector) - precipsector_list = P_AddPrecipSecnode(ld->backsector, tmprecipthing, precipsector_list); - - return true; -} - // P_CreateSecNodeList alters/creates the sector_list that shows what sectors // the object resides in. @@ -4237,73 +4084,6 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) } } -// More crazy crap Tails 08-25-2002 -void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) -{ - INT32 xl, xh, yl, yh, bx, by; - mprecipsecnode_t *node = precipsector_list; - precipmobj_t *saved_tmthing = tmprecipthing; /* cph - see comment at func end */ - - // First, clear out the existing m_thing fields. As each node is - // added or verified as needed, m_thing will be set properly. When - // finished, delete all nodes where m_thing is still NULL. These - // represent the sectors the Thing has vacated. - - while (node) - { - node->m_thing = NULL; - node = node->m_sectorlist_next; - } - - tmprecipthing = thing; - - preciptmbbox[BOXTOP] = y + 2*FRACUNIT; - preciptmbbox[BOXBOTTOM] = y - 2*FRACUNIT; - preciptmbbox[BOXRIGHT] = x + 2*FRACUNIT; - preciptmbbox[BOXLEFT] = x - 2*FRACUNIT; - - validcount++; // used to make sure we only process a line once - - xl = (unsigned)(preciptmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; - xh = (unsigned)(preciptmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; - yl = (unsigned)(preciptmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; - yh = (unsigned)(preciptmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; - - BMBOUNDFIX(xl, xh, yl, yh); - - for (bx = xl; bx <= xh; bx++) - for (by = yl; by <= yh; by++) - P_BlockLinesIterator(bx, by, PIT_GetPrecipSectors); - - // Add the sector of the (x, y) point to sector_list. - precipsector_list = P_AddPrecipSecnode(thing->subsector->sector, thing, precipsector_list); - - // Now delete any nodes that won't be used. These are the ones where - // m_thing is still NULL. - node = precipsector_list; - while (node) - { - if (!node->m_thing) - { - if (node == precipsector_list) - precipsector_list = node->m_sectorlist_next; - node = P_DelPrecipSecnode(node); - } - else - node = node->m_sectorlist_next; - } - - /* cph - - * This is the strife we get into for using global variables. tmthing - * is being used by several different functions calling - * P_BlockThingIterator, including functions that can be called *from* - * P_BlockThingIterator. Using a global tmthing is not reentrant. - * OTOH for Boom/MBF demos we have to preserve the buggy behavior. - * Fun. We restore its previous value unless we're in a Boom/MBF demo. - */ - tmprecipthing = saved_tmthing; -} - /* cphipps 2004/08/30 - * Must clear tmthing at tic end, as it might contain a pointer to a removed thinker, or the level might have ended/been ended and we clear the objects it was pointing too. Hopefully we don't need to carry this between tics for sync. */ void P_MapStart(void) diff --git a/src/p_maputl.c b/src/p_maputl.c index 13dd85592..a88545135 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -782,9 +782,6 @@ void P_UnsetPrecipThingPosition(precipmobj_t *thing) if (bprev && (*bprev = bnext) != NULL) // unlink from block map bnext->bprev = bprev; - - precipsector_list = thing->touching_sectorlist; - thing->touching_sectorlist = NULL; //to be restored by P_SetPrecipThingPosition } static void P_LinkToBlockMap(mobj_t *thing, mobj_t **bmap) @@ -929,10 +926,6 @@ void P_SetPrecipitationThingPosition(precipmobj_t *thing) { thing->subsector = R_PointInSubsector(thing->x, thing->y); - P_CreatePrecipSecNodeList(thing, thing->x, thing->y); - thing->touching_sectorlist = precipsector_list; // Attach to Thing's precipmobj_t - precipsector_list = NULL; // clear for next time - // NOTE: this works because bnext/bprev are at the same // offsets in precipmobj_t and mobj_t P_LinkToBlockMap((mobj_t*)thing, (mobj_t**)precipblocklinks); diff --git a/src/p_mobj.c b/src/p_mobj.c index a731bd366..d140b2303 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3572,7 +3572,7 @@ animonly: } } -static void CalculatePrecipFloor(precipmobj_t *mobj) +static void P_CalculatePrecipFloor(precipmobj_t *mobj) { // recalculate floorz each time const sector_t *mobjsecsubsec; @@ -3606,19 +3606,6 @@ static void CalculatePrecipFloor(precipmobj_t *mobj) } } -void P_RecalcPrecipInSector(sector_t *sector) -{ - mprecipsecnode_t *psecnode; - - if (!sector) - return; - - sector->moved = true; // Recalc lighting and things too, maybe - - for (psecnode = sector->touching_preciplist; psecnode; psecnode = psecnode->m_thinglist_next) - CalculatePrecipFloor(psecnode->m_thing); -} - // // P_NullPrecipThinker // @@ -3685,6 +3672,8 @@ boolean P_PrecipThinker(precipmobj_t *mobj) if (mobj->precipflags & PCF_SPLASH) return true; + P_CalculatePrecipFloor(mobj); + // adjust height if ((mobj->z += mobj->momz) <= mobj->floorz) { @@ -10046,7 +10035,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->thinker.function.acp1 = (actionf_p1)P_NullPrecipThinker; P_AddPrecipThinker(&mobj->thinker); - CalculatePrecipFloor(mobj); + P_CalculatePrecipFloor(mobj); if (mobj->floorz != starting_floorz) mobj->precipflags |= PCF_FOF; @@ -10206,12 +10195,6 @@ void P_FreePrecipMobj(precipmobj_t *mobj) // unlink from sector and block lists P_UnsetPrecipThingPosition(mobj); - if (precipsector_list) - { - P_DelPrecipSeclist(precipsector_list); - precipsector_list = NULL; - } - // free block // Precipmobjs don't actually think using their thinker, // so the free cannot be delayed. @@ -10225,12 +10208,6 @@ void P_RemoveSavegameMobj(mobj_t *mobj) if (((thinker_t *)mobj)->function.acp1 == (actionf_p1)P_NullPrecipThinker) { P_UnsetPrecipThingPosition((precipmobj_t *)mobj); - - if (precipsector_list) - { - P_DelPrecipSeclist(precipsector_list); - precipsector_list = NULL; - } } else { diff --git a/src/r_defs.h b/src/r_defs.h index bc95649bb..4931eb2fb 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -354,9 +354,6 @@ typedef struct sector_s // Current speed of ceiling/floor. For Knuckles to hold onto stuff. fixed_t floorspeed, ceilspeed; - // list of precipitation mobjs in sector - struct mprecipsecnode_s *touching_preciplist; - // Eternity engine slope pslope_t *f_slope; // floor slope pslope_t *c_slope; // ceiling slope @@ -492,17 +489,6 @@ typedef struct msecnode_s boolean visited; // used in search algorithms } msecnode_t; -typedef struct mprecipsecnode_s -{ - sector_t *m_sector; // a sector containing this object - struct precipmobj_s *m_thing; // this object - struct mprecipsecnode_s *m_sectorlist_prev; // prev msecnode_t for this thing - struct mprecipsecnode_s *m_sectorlist_next; // next msecnode_t for this thing - struct mprecipsecnode_s *m_thinglist_prev; // prev msecnode_t for this sector - struct mprecipsecnode_s *m_thinglist_next; // next msecnode_t for this sector - boolean visited; // used in search algorithms -} mprecipsecnode_t; - // // The lineseg. // From 49644f10f5ce32c894e38a5ea66c01fbd0f5e329 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Jan 2025 23:13:34 +0100 Subject: [PATCH 304/418] only need to recalc this once a tic precip thinker thinks slightly more often, but we really dont need that tbh --- src/p_mobj.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index d140b2303..36b13be64 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3672,7 +3672,8 @@ boolean P_PrecipThinker(precipmobj_t *mobj) if (mobj->precipflags & PCF_SPLASH) return true; - P_CalculatePrecipFloor(mobj); + if (renderisnewtic) + P_CalculatePrecipFloor(mobj); // adjust height if ((mobj->z += mobj->momz) <= mobj->floorz) From 7f864dba3aef5f3a5a2537d48b177e87b4f37913 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Jan 2025 23:24:01 +0100 Subject: [PATCH 305/418] dont recalc if precip sector didnt move forgor i can just check this --- src/p_mobj.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 36b13be64..7261e1f5b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3572,7 +3572,7 @@ animonly: } } -static void P_CalculatePrecipFloor(precipmobj_t *mobj) +static void P_CalculatePrecipFloor(precipmobj_t *mobj, boolean spawn) { // recalculate floorz each time const sector_t *mobjsecsubsec; @@ -3582,6 +3582,10 @@ static void P_CalculatePrecipFloor(precipmobj_t *mobj) else return; + // no need to recalc anything if not moved + if (!spawn && !mobjsecsubsec->moved) + return; + mobj->floorz = P_GetSectorFloorZAt(mobjsecsubsec, mobj->x, mobj->y); if (mobjsecsubsec->ffloors) @@ -3673,7 +3677,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) return true; if (renderisnewtic) - P_CalculatePrecipFloor(mobj); + P_CalculatePrecipFloor(mobj, false); // adjust height if ((mobj->z += mobj->momz) <= mobj->floorz) @@ -10036,7 +10040,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->thinker.function.acp1 = (actionf_p1)P_NullPrecipThinker; P_AddPrecipThinker(&mobj->thinker); - P_CalculatePrecipFloor(mobj); + P_CalculatePrecipFloor(mobj, true); if (mobj->floorz != starting_floorz) mobj->precipflags |= PCF_FOF; From 3f54630531bfee241fe8f45147e1a12035440a23 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 Jan 2025 16:05:20 +0100 Subject: [PATCH 306/418] fix issues with models - Sloperotation was weird, it now uses what we calculate in K_RollMobjsBySlopes - in general uses srb2s newer system - alot of cleanup of pointless variables - sprinfo pivots should now work - removed roillmodel since it was smth weird and broke rollangle --- src/hardware/hw_defs.h | 16 +--- src/hardware/hw_md2.c | 121 +++++++++---------------------- src/hardware/r_opengl/r_opengl.c | 38 ++-------- src/lua_mobjlib.c | 1 - src/p_mobj.h | 1 - 5 files changed, 41 insertions(+), 136 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index c2b0e6d85..16221acb6 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -121,38 +121,24 @@ typedef struct poly_t *planepoly; // the generated convex polygon } extrasubsector_t; -// Kart features -#define USE_FTRANSFORM_ANGLEZ -#define USE_FTRANSFORM_MIRROR - // Vanilla features //#define USE_MODEL_NEXTFRAME typedef struct { FLOAT x,y,z; // position -#ifdef USE_FTRANSFORM_ANGLEZ FLOAT anglex, angley, anglez; // aimingangle / viewangle FLOAT anglex2, anglez2; // secondaries -#else - FLOAT anglex, angley; // aimingangle / viewangle - FLOAT anglex2; // secondaries -#endif FLOAT scalex, scaley, scalez; - FLOAT spritexscale, spriteyscale; FLOAT fovangle; UINT8 splitscreen; boolean flip; // screenflip boolean roll; - boolean rollmodel; - SINT8 rollflip; FLOAT rollangle; - UINT8 rotaxis; FLOAT centerx, centery; -#ifdef USE_FTRANSFORM_MIRROR + FLOAT rollx, rollz; boolean mirror; // SRB2Kart: Encore Mode boolean mirrorflip; // Encore Mode with Flipcam -#endif boolean shearing; // 14042019 float viewaiming; // 17052019 } FTransform; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 09d2ba979..a772f2839 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1163,8 +1163,6 @@ void HWR_DrawMD2(gl_vissprite_t *spr) spritedef_t *sprdef; spriteframe_t *sprframe; spriteinfo_t *sprinfo; - INT32 rollfactor = 0; - angle_t ang; interpmobjstate_t interp; if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || R_QuickCamDist(spr->mobj->x, spr->mobj->y) < cv_maxinterpdist.value)) @@ -1343,7 +1341,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) p.x = FIXED_TO_FLOAT(interp.x); p.y = FIXED_TO_FLOAT(interp.y)+md2->offset; - if (spr->mobj->eflags & MFE_VERTICALFLIP) + if (flip) p.z = FIXED_TO_FLOAT(interp.z + spr->mobj->height); else p.z = FIXED_TO_FLOAT(interp.z); @@ -1366,109 +1364,58 @@ void HWR_DrawMD2(gl_vissprite_t *spr) const fixed_t anglef = AngleFixed((R_PointToAngle(interp.x, interp.y))-ANGLE_180); p.angley = FIXED_TO_FLOAT(anglef); } - - p.rollangle = 0.0f; - p.rollflip = 1; - p.rotaxis = 0; - - p.spritexscale = FIXED_TO_FLOAT(spr->mobj->spritexscale); - p.spriteyscale = FIXED_TO_FLOAT(spr->mobj->spriteyscale); - angle_t sliptideroll = ((cv_sloperoll.value && cv_sliptideroll.value && spr->mobj->player) ? spr->mobj->player->sliproll : 0); + const angle_t sliptideroll = ((cv_sloperoll.value && cv_sliptideroll.value && spr->mobj->player) ? spr->mobj->player->sliproll : 0); + const SINT8 flipfactor = flip ? -1 : 1; if (spr->mobj->rollangle || sliptideroll) { - angle_t rollang = 0; - rollfactor = ((spr->mobj->rollmodel == true) ? 1 : 0); + angle_t rollang = sliptideroll + ? (spr->mobj->rollangle) + (sliptideroll * spr->mobj->player->kartstuff[k_aizdriftstrat]) + : (spr->mobj->rollangle); - rollang = sliptideroll - ? (spr->mobj->rollangle * rollfactor) + (sliptideroll * spr->mobj->player->kartstuff[k_aizdriftstrat]) - : (spr->mobj->rollangle * rollfactor); - fixed_t anglef = AngleFixed(rollang); - p.rollangle = FIXED_TO_FLOAT(anglef); - p.rollmodel = (spr->mobj->rollmodel); - p.roll = true; - // rotation pivot - p.centerx = FIXED_TO_FLOAT(spr->mobj->radius/2)*(p.spritexscale); - p.centery = FIXED_TO_FLOAT(spr->mobj->height/2)*(p.spriteyscale); + p.rollangle = 0.0f; - // rotation axis - if (sprinfo->available) - p.rotaxis = (UINT8)(sprinfo->pivot[(spr->mobj->frame & FF_FRAMEMASK)].rotaxis); + if (anglef) + { + fixed_t camAngleDiff = AngleFixed(viewangle) - FLOAT_TO_FIXED(p.angley); // dumb reconversion back, I know - // for NiGHTS specifically but should work everywhere else - ang = R_PointToAngle (spr->mobj->x, spr->mobj->y) - (spr->mobj->player ? spr->mobj->player->frameangle : spr->mobj->angle); - if ((sprframe->rotate & SRF_RIGHT) && (ang < ANGLE_180)) // See from right - p.rollflip = 1; - else if ((sprframe->rotate & SRF_LEFT) && (ang >= ANGLE_180)) // See from left - p.rollflip = -1; + p.rollangle = FIXED_TO_FLOAT(anglef); + p.roll = true; + + // rotation pivot + if (sprinfo->available) + { + p.centerx = FIXED_TO_FLOAT(sprinfo->pivot[frame].x); + p.centery = FIXED_TO_FLOAT(sprinfo->pivot[frame].y); + } + else + { + p.centerx = FIXED_TO_FLOAT(spr->mobj->radius/2); + p.centery = FIXED_TO_FLOAT(spr->mobj->height/2); + } + + // rotation axes relative to camera + p.rollx = FIXED_TO_FLOAT(FINECOSINE(FixedAngle(camAngleDiff) >> ANGLETOFINESHIFT)); + p.rollz = FIXED_TO_FLOAT(FINESINE(FixedAngle(camAngleDiff) >> ANGLETOFINESHIFT)); + } } - - p.anglex = 0.0f; - p.anglex2 = 0.0f; -#ifdef USE_FTRANSFORM_ANGLEZ - // Slope rotation from Kart - p.anglez = 0.0f; - p.anglez2 = 0.0f; - - // use secondary angles for the slope rotation - if (spr->mobj->standingslope) - { - fixed_t tempz = spr->mobj->standingslope->normal.z; - fixed_t tempy = spr->mobj->standingslope->normal.y; - fixed_t tempx = spr->mobj->standingslope->normal.x; - fixed_t tempangle = AngleFixed(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx)); - p.anglez2 = FIXED_TO_FLOAT(tempangle); - tempangle = -AngleFixed(R_PointToAngle2(0, 0, tempz, tempy)); - p.anglex2 = FIXED_TO_FLOAT(tempangle); - } - else if ((spr->mobj->sloperoll || spr->mobj->slopepitch) && (!P_IsObjectOnGround(spr->mobj)) && (!paused)) - { - SINT8 flipfactor = flip ? -1 : 1; - - angle_t camang = R_PointToAngle(interp.x, interp.y); - angle_t mobjang; - - if (spr->mobj->flags & (MF_NOTHINK|MF_SCENERY)) - mobjang = spr->mobj->angle; - else - mobjang = interp.angle; - - angle_t fmoang; - fmoang = camang - mobjang; - - // slopepitch - p.anglex += flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINESINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.slopepitch)) ); - p.anglez -= flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINECOSINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.slopepitch)) ); - - // sloperoll - p.anglex += flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINECOSINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.sloperoll)) ); - p.anglez += flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINESINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.sloperoll)) ); - p.roll = true; - } + // slope pitch and roll + p.anglex += flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.sloperoll)); + p.anglez -= flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.slopepitch)); // pitch and roll - if (interp.roll || interp.pitch) - { - SINT8 flipfactor = flip ? -1 : 1; - p.anglex += flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.roll)); - p.anglez -= flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.pitch)); - p.roll = true; - } -#endif + p.anglex += flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.roll)); + p.anglez -= flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.pitch)); p.flip = atransform.flip; -#ifdef USE_FTRANSFORM_MIRROR p.mirror = atransform.mirror; // from Kart -#endif GL_SetShader(SHADER_MODEL); // model shader { - SINT8 flipfactor = flip ? -1 : 1; - float this_scale = FIXED_TO_FLOAT(interp.scale); float xs = this_scale * FIXED_TO_FLOAT(interp.spritexscale); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 9c5ce4a0f..a2e466e9f 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2617,7 +2617,6 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics pglEnable(GL_CULL_FACE); pglEnable(GL_NORMALIZE); -#ifdef USE_FTRANSFORM_MIRROR // flipped is if the object is vertically flipped // hflipped is if the object is horizontally flipped // pos->flip is if the screen is flipped vertically @@ -2630,13 +2629,6 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics else pglCullFace(GL_BACK); } -#else - // pos->flip is if the screen is flipped too - if (flipped ^ hflipped ^ pos->flip) // If one or three of these are active, but not two, invert the model's culling - pglCullFace(GL_FRONT); - else - pglCullFace(GL_BACK); -#endif pglPushMatrix(); // should be the same as glLoadIdentity pglTranslatef(pos->x, pos->z, pos->y); @@ -2644,30 +2636,15 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics scaley = -scaley; if (hflipped) scalez = -scalez; -#ifdef USE_FTRANSFORM_ANGLEZ - pglRotatef(pos->anglez2, 0.0f, 0.0f, -1.0f); // rotate by slope from Kart -#endif - pglRotatef(pos->anglex2, -1.0f, 0.0f, 0.0f); + + pglRotatef(pos->anglez, 0.0f, 0.0f, -1.0f); + pglRotatef(pos->anglex, 1.0f, 0.0f, 0.0f); pglRotatef(pos->angley, 0.0f, -1.0f, 0.0f); if (pos->roll) { - float roll = (1.0f * pos->rollflip); pglTranslatef(pos->centerx, pos->centery, 0); - - // rotate model for pitch and roll - pglRotatef(pos->anglex, 1.0f, 0.0f, 0.0f); -#ifdef USE_FTRANSFORM_ANGLEZ - pglRotatef(pos->anglez, 0.0f, 0.0f, -1.0f); -#endif - - if (pos->rotaxis == 2) // Z - pglRotatef(pos->rollangle, 0.0f, 0.0f, roll); - else if (pos->rotaxis == 1) // Y - pglRotatef(pos->rollangle, 0.0f, roll, 0.0f); - else // X - pglRotatef(pos->rollangle, roll, 0.0f, 0.0f); - + pglRotatef(pos->rollangle, pos->rollx, 0.0f, pos->rollz); pglTranslatef(-pos->centerx, -pos->centery, 0); } @@ -2795,15 +2772,12 @@ void GL_SetTransform(FTransform *stransform) // keep a trace of the transformation for md2 memcpy(&md2_transform, stransform, sizeof (md2_transform)); -#ifdef USE_FTRANSFORM_MIRROR - // mirroring from Kart + if (stransform->mirror) pglScalef(-stransform->scalex, stransform->scaley, -stransform->scalez); else if (stransform->mirrorflip) pglScalef(-stransform->scalex, -stransform->scaley, -stransform->scalez); - else -#endif - if (stransform->flip) + else if (stransform->flip) pglScalef(stransform->scalex, -stransform->scaley, -stransform->scalez); else pglScalef(stransform->scalex, stransform->scaley, -stransform->scalez); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index b006e55e6..6effb165f 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -148,7 +148,6 @@ static const udata_field_t mobj_fields[] = { FIELD(mobj_t, standingslope, udatalib_getter_slope, mobj_standingslope_noset), FIELD(mobj_t, colorized, udatalib_getter_boolean, udatalib_setter_boolean), FIELD(mobj_t, mirrored, udatalib_getter_boolean, udatalib_setter_boolean), - FIELD(mobj_t, rollmodel, udatalib_getter_boolean, udatalib_setter_boolean), { NULL, 0, NULL, NULL }, }; #undef FIELD diff --git a/src/p_mobj.h b/src/p_mobj.h index d6ad62d91..1917c4c94 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -395,7 +395,6 @@ typedef struct mobj_s boolean resetinterp; // if true, some fields should not be interpolated (see R_InterpolateMobjState implementation) boolean colorized; // Whether the mobj uses the rainbow colormap boolean mirrored; // The object's rotations will be mirrored left to right, e.g., see frame AL from the right and AR from the left - boolean rollmodel; // OpenGL: Should this model rotate? tic_t slamsoundtimer; From 7fec7f8937c05b672f95ac79b6e199c3b28d47f7 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 Jan 2025 16:09:56 +0100 Subject: [PATCH 307/418] forgor to set those oop --- src/hardware/hw_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a56cd5595..441bdf3c1 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5463,6 +5463,8 @@ static void HWR_RollTransform(FTransform *tr, angle_t roll) { tr->rollangle = roll / (float)ANG1; tr->roll = true; + tr->rollx = 1.0f; + tr->rollz = 0.0f; } } From 0f3cd28019500d5847ffe5c901236df877186119 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 Jan 2025 17:33:44 +0100 Subject: [PATCH 308/418] pass slope to K_RollMobjBySlopes removing some code dupe in the process and allows some more flexability --- src/k_kart.c | 65 ++++------------------------------------------------ src/k_kart.h | 2 +- src/p_mobj.c | 2 +- 3 files changed, 7 insertions(+), 62 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 6e754cff9..c0cc380ce 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3504,63 +3504,7 @@ static void K_QuiteSaltyHop(player_t *p) } #define SLOPEROLL_DIV 3 -void K_RollMobjBySlopes(mobj_t* mo, boolean usedistance) -{ - if (P_MobjWasRemoved(mo)) - return; - - I_Assert(mo->subsector != NULL); - I_Assert(mo->subsector->sector != NULL); - - // lifted from hw_md2 - if (mo->standingslope) - { - angle_t an; - const boolean flip = (mo->eflags & MFE_VERTICALFLIP); - const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0; - const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; - - fixed_t tempz = mo->standingslope->normal.z; - fixed_t tempy = mo->standingslope->normal.y; - fixed_t tempx = mo->standingslope->normal.x; - fixed_t tempangle = -(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx)); - - // admittedly this is a very hacky way to do the pitch and roll easing - - // pitch - if (!usedistance || (m_dist <= (rolldist))) - { - an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV; - - mo->pitch_sprite = an ? mo->pitch_sprite + an : (angle_t)tempangle; - } - else - mo->pitch_sprite = FixedAngle(0); - - mo->slopepitch = flip ? InvAngle(mo->pitch_sprite) : mo->pitch_sprite; - - // roll - tempangle = (R_PointToAngle2(0, 0, tempz, tempy)); - - if (!usedistance || (m_dist <= (rolldist))) - { - an = (INT32)((angle_t)tempangle - mo->roll_sprite) / SLOPEROLL_DIV; - - mo->roll_sprite = an ? mo->roll_sprite + an : (angle_t)tempangle; - } - else - mo->roll_sprite = FixedAngle(0); - - mo->sloperoll = flip ? InvAngle(mo->roll_sprite) : mo->roll_sprite; - } - else if (P_IsObjectOnGround(mo)) - { - mo->sloperoll = FixedAngle(0); - mo->slopepitch = FixedAngle(0); - } -} - -static void K_SetPitchRollFromSlope(mobj_t* mo, pslope_t *slope, boolean usedistance) +void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) { if (P_MobjWasRemoved(mo)) return; @@ -3573,8 +3517,9 @@ static void K_SetPitchRollFromSlope(mobj_t* mo, pslope_t *slope, boolean usedist { angle_t an; const boolean flip = (mo->eflags & MFE_VERTICALFLIP); - const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0; + const boolean usedistance = cv_sloperolldist.value && !splitscreen; const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; + const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0; fixed_t tempz = slope->normal.z; fixed_t tempy = slope->normal.y; @@ -4862,7 +4807,7 @@ static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z } //mobj->standingslope = slope; - K_SetPitchRollFromSlope(mobj, slope, (cv_sloperolldist.value && !splitscreen)); + K_RollMobjBySlopes(mobj, slope); } // Move the hnext chain! @@ -6942,7 +6887,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (cv_sloperoll.value && !player->mo->salty_jump) // seeing a character rotate mid-hop looks really janky { - K_RollMobjBySlopes(player->mo, (cv_sloperolldist.value && !splitscreen)); + K_RollMobjBySlopes(player->mo, player->mo->standingslope); } else { diff --git a/src/k_kart.h b/src/k_kart.h index c491c3477..dde5e21af 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -60,7 +60,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor); void K_StealBumper(player_t *player, player_t *victim, boolean force); void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle, boolean spawncenter, boolean ghostit, mobj_t *source); void K_SpawnMineExplosion(mobj_t *source, UINT8 color); -void K_RollMobjBySlopes(mobj_t *mo, boolean usedistance); +void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope); void K_SpawnBoostTrail(player_t *player); void K_SpawnSparkleTrail(mobj_t *mo); void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent); diff --git a/src/p_mobj.c b/src/p_mobj.c index 7261e1f5b..9bb3c32b0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6048,7 +6048,7 @@ void P_RollPitchMobj(mobj_t* mobj) return; } - K_RollMobjBySlopes(mobj, cv_sloperolldist.value && !splitscreen); + K_RollMobjBySlopes(mobj, mobj->standingslope); } angle_t P_MobjPitchAndRoll(mobj_t *mobj) From 283f4d1e37721ef7e54eb2431f34edb7289fa0d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 Jan 2025 17:37:52 +0100 Subject: [PATCH 309/418] super smol optimization --- src/k_kart.c | 17 +++++++++-------- src/p_mobj.c | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index c0cc380ce..8fb4721b5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3520,6 +3520,7 @@ void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) const boolean usedistance = cv_sloperolldist.value && !splitscreen; const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0; + const boolean usepitchnroll = (!usedistance || (m_dist <= rolldist)); fixed_t tempz = slope->normal.z; fixed_t tempy = slope->normal.y; @@ -3529,35 +3530,35 @@ void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) // admittedly this is a very hacky way to do the pitch and roll easing // pitch - if (!usedistance || (m_dist <= (rolldist))) + if (usepitchnroll) { an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV; mo->pitch_sprite = an ? mo->pitch_sprite + an : (angle_t)tempangle; } else - mo->pitch_sprite = FixedAngle(0); + mo->pitch_sprite = 0; mo->slopepitch = flip ? InvAngle(mo->pitch_sprite) : mo->pitch_sprite; // roll tempangle = (R_PointToAngle2(0, 0, tempz, tempy)); - if (!usedistance || (m_dist <= (rolldist))) + if (usepitchnroll) { an = (INT32)((angle_t)tempangle - mo->roll_sprite) / SLOPEROLL_DIV; mo->roll_sprite = an ? mo->roll_sprite + an : (angle_t)tempangle; } else - mo->roll_sprite = FixedAngle(0); + mo->roll_sprite = 0; mo->sloperoll = flip ? InvAngle(mo->roll_sprite) : mo->roll_sprite; } else if (P_IsObjectOnGround(mo)) { - mo->sloperoll = FixedAngle(0); - mo->slopepitch = FixedAngle(0); + mo->sloperoll = 0; + mo->slopepitch = 0; } } @@ -6891,8 +6892,8 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } else { - player->mo->sloperoll = FixedAngle(0); - player->mo->slopepitch = FixedAngle(0); + player->mo->sloperoll = 0; + player->mo->slopepitch = 0; } // Quick Turning diff --git a/src/p_mobj.c b/src/p_mobj.c index 9bb3c32b0..5e734a068 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6043,8 +6043,8 @@ void P_RollPitchMobj(mobj_t* mobj) if (cv_sloperoll.value != 2) { - mobj->sloperoll = FixedAngle(0); - mobj->slopepitch = FixedAngle(0); + mobj->sloperoll = 0; + mobj->slopepitch = 0; return; } From de6a078f018d040ce21dee1a015938d6f9524bfb Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 Jan 2025 18:10:10 +0100 Subject: [PATCH 310/418] inline a few hooklib functions --- src/lua_hooklib.c | 57 ++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 12c09a8ba..a0f795985 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -64,7 +64,7 @@ static UINT8 * hooksErrored; static int errorRef; -static boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type) +FUNCINLINE static ATTRINLINE boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type) { return ( @@ -73,7 +73,7 @@ static boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type) ); } -static unsigned hook_in_list +FUNCINLINE static ATTRINLINE unsigned hook_in_list ( const char * const name, const char * const * const list @@ -106,7 +106,7 @@ static void get_table(lua_State *L) lua_remove(L, -2); } -static void add_hook_to_table(lua_State *L, int n) +FUNCINLINE static ATTRINLINE void add_hook_to_table(lua_State *L, int n) { lua_pushnumber(L, nextid); lua_rawseti(L, -2, n); @@ -175,14 +175,14 @@ static void add_string_hook(lua_State *L, int type) add_hook_to_table(L, ++hook->numGeneric); } -static void add_hook(hook_t *map) +FUNCINLINE static ATTRINLINE void add_hook(hook_t *map) { Z_Realloc(map->ids, (map->numHooks + 1) * sizeof *map->ids, PU_STATIC, &map->ids); map->ids[map->numHooks++] = nextid; } -static void add_mobj_hook(lua_State *L, int hook_type) +FUNCINLINE static ATTRINLINE void add_mobj_hook(lua_State *L, int hook_type) { mobjtype_t mobj_type = luaL_optnumber(L, 3, MT_NULL); @@ -191,7 +191,7 @@ static void add_mobj_hook(lua_State *L, int hook_type) add_hook(&mobjHookIds[mobj_type][hook_type]); } -static void add_hud_hook(lua_State *L, int idx) +FUNCINLINE static ATTRINLINE void add_hud_hook(lua_State *L, int idx) { add_hook(&hudHookIds[luaL_checkoption(L, idx, "game", hudHookNames)]); @@ -263,7 +263,6 @@ int LUA_HookLib(lua_State *L) return 0; } - int lib_hudadd(lua_State *L);/* yeah compiler */ int lib_hudadd(lua_State *L) { @@ -297,24 +296,24 @@ enum { SINDEX = 2,/* string itself is pushed in case of string hook */ }; -static void push_error_handler(void) +FUNCINLINE static ATTRINLINE void push_error_handler(void) { lua_getref(gL, errorRef); } /* repush hook string */ -static void push_string(void) +FUNCINLINE static ATTRINLINE void push_string(void) { lua_pushvalue(gL, SINDEX); } -static boolean begin_hook_values(Hook_State *hook) +FUNCINLINE static ATTRINLINE boolean begin_hook_values(Hook_State *hook) { hook->top = lua_gettop(gL); return true; } -static void start_hook_stack(void) +FUNCINLINE static ATTRINLINE void start_hook_stack(void) { lua_settop(gL, 0); push_error_handler(); @@ -343,7 +342,7 @@ static boolean init_hook_type return false; } -static boolean prepare_hook +FUNCINLINE static ATTRINLINE boolean prepare_hook ( Hook_State * hook, int default_status, @@ -356,7 +355,7 @@ static boolean prepare_hook hookIds[hook_type].numHooks); } -static boolean prepare_mobj_hook +FUNCINLINE static ATTRINLINE boolean prepare_mobj_hook ( Hook_State * hook, int default_status, @@ -373,7 +372,7 @@ static boolean prepare_mobj_hook mobj_hook_available(hook_type, mobj_type)); } -static boolean prepare_string_hook +FUNCINLINE static ATTRINLINE boolean prepare_string_hook ( Hook_State * hook, int default_status, @@ -393,7 +392,7 @@ static boolean prepare_string_hook return false; } -static void init_hook_call +FUNCINLINE static ATTRINLINE void init_hook_call ( Hook_State * hook, int results, @@ -406,13 +405,13 @@ static void init_hook_call hook->results_handler = results_handler; } -static void get_hook(Hook_State *hook, const int *ids, int n) +FUNCINLINE static ATTRINLINE void get_hook(Hook_State *hook, const int *ids, int n) { hook->id = ids[n]; lua_getref(gL, hookRefs[hook->id]); } -static void get_hook_from_table(Hook_State *hook, int n) +FUNCINLINE static ATTRINLINE void get_hook_from_table(Hook_State *hook, int n) { lua_rawgeti(gL, -1, n); hook->id = lua_tonumber(gL, -1); @@ -444,7 +443,7 @@ static int call_single_hook_no_copy(Hook_State *hook) return 1; } -static int call_single_hook(Hook_State *hook) +FUNCINLINE static ATTRINLINE int call_single_hook(Hook_State *hook) { int i; @@ -454,7 +453,7 @@ static int call_single_hook(Hook_State *hook) return call_single_hook_no_copy(hook); } -static int call_hook_table_for(Hook_State *hook, int n) +FUNCINLINE static ATTRINLINE int call_hook_table_for(Hook_State *hook, int n) { int k; @@ -467,12 +466,12 @@ static int call_hook_table_for(Hook_State *hook, int n) return n; } -static int call_hook_table(Hook_State *hook) +FUNCINLINE static ATTRINLINE int call_hook_table(Hook_State *hook) { return call_hook_table_for(hook, lua_objlen(gL, -1)); } -static int call_mapped(Hook_State *hook, const hook_t *map) +FUNCINLINE static ATTRINLINE int call_mapped(Hook_State *hook, const hook_t *map) { int k; @@ -503,7 +502,7 @@ static int call_string_hooks(Hook_State *hook) return calls; } -static int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) +FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) { return call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); } @@ -546,7 +545,7 @@ static int call_hooks #define res_none NULL -static void res_true(Hook_State *hook) +FUNCINLINE static ATTRINLINE void res_true(Hook_State *hook) { if (lua_toboolean(gL, -1)) hook->status = true; @@ -558,7 +557,7 @@ static void res_true(Hook_State *hook) hook->status = false; }*/ -static void res_force(Hook_State *hook) +FUNCINLINE static ATTRINLINE void res_force(Hook_State *hook) { if (!lua_isnil(gL, -1)) { @@ -569,7 +568,7 @@ static void res_force(Hook_State *hook) } } -static void res_hud(Hook_State *hook) +FUNCINLINE static ATTRINLINE void res_hud(Hook_State *hook) { (void)hook; @@ -700,6 +699,8 @@ static void hook_think_frame(int type) const hook_t * map = &hookIds[type]; int k; + const boolean perfstats = (cv_perfstats.value >= 3); + if (prepare_hook(&hook, 0, type)) { init_hook_call(&hook, 0, res_none); @@ -708,7 +709,7 @@ static void hook_think_frame(int type) { get_hook(&hook, map->ids, k); - if (cv_perfstats.value >= 3) + if (perfstats) { lua_pushvalue(gL, -1);/* need the function again */ time_taken = I_GetPreciseTime(); @@ -716,7 +717,7 @@ static void hook_think_frame(int type) call_single_hook(&hook); - if (cv_perfstats.value >= 3) + if (perfstats) { lua_Debug ar; time_taken = I_GetPreciseTime() - time_taken; @@ -808,7 +809,7 @@ typedef struct { ticcmd_t * cmd; } BotAI_State; -static boolean checkbotkey(const char *field) +FUNCINLINE static ATTRINLINE boolean checkbotkey(const char *field) { return lua_toboolean(gL, -1) && strcmp(lua_tostring(gL, -2), field) == 0; } From 2eddddc6fcd50a4d34900e19118f5c6a83b7cdbb Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 Jan 2025 18:29:23 +0100 Subject: [PATCH 311/418] ss->touching_preciplist deez --- src/p_setup.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index d13a35512..b934d7363 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -872,8 +872,6 @@ static void P_LoadRawSectors(UINT8 *data) ss->thinglist = NULL; ss->touching_thinglist = NULL; - ss->touching_preciplist = NULL; - ss->floordata = NULL; ss->ceilingdata = NULL; ss->lightingdata = NULL; From e206ad3c0858521bdfb67dce0bd2feaf42579c2e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 00:32:04 +0100 Subject: [PATCH 312/418] better replay resynch prints --- src/g_game.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index f456b00ec..1555126fb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4648,7 +4648,7 @@ void G_ReadDemoExtraData(void) P_SetRandSeed(rng); if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (RNG)!\n")); demosynced = false; } } @@ -5272,7 +5272,7 @@ void G_ConsGhostTic(INT32 playernum) if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (health)!\n")); demosynced = false; P_DamageMobj(mobj, players[0].mo, players[0].mo, 1); } @@ -5305,7 +5305,7 @@ void G_ConsGhostTic(INT32 playernum) if (ghostext[playernum].desyncframes >= 2) { if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + CONS_Alert(CONS_WARNING, "Demo playback has desynced (player %s)!\n", player_names[playernum]); demosynced = false; P_UnsetThingPosition(testmo); @@ -5335,7 +5335,7 @@ void G_ConsGhostTic(INT32 playernum) ) { if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (item/bumpers)!\n")); demosynced = false; players[playernum].kartstuff[k_itemtype] = ghostext[playernum].kartitem; From e23d9bc3cc0bae92861a8cf074402ccb9607e337 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 00:46:16 +0100 Subject: [PATCH 313/418] also print player name for item desynch --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 1555126fb..dbf63239a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5335,7 +5335,7 @@ void G_ConsGhostTic(INT32 playernum) ) { if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (item/bumpers)!\n")); + CONS_Alert(CONS_WARNING, "Demo playback has desynced (item/bumpers)!(player %s)!\n", player_names[playernum]); demosynced = false; players[playernum].kartstuff[k_itemtype] = ghostext[playernum].kartitem; From 842a2525768101c283e766b8a6da8a8ee0599b0a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 00:08:50 +0100 Subject: [PATCH 314/418] Have replay recording of "hits" use the reference count system https://git.srb2.org/KartKrew/RingRacers/-/commit/fa8bffabfc51ea1d7be86d833190bb7dcf494fca --- src/g_game.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index dbf63239a..44c28d49f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4915,7 +4915,7 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim) ghostext[playernum].flags |= EZT_HIT; ghostext[playernum].hits++; ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, NULL); - ghostext[playernum].hitlist[ghostext[playernum].hits-1] = victim; + P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim); } void G_WriteAllGhostTics(void) @@ -5124,6 +5124,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEFIXED(demobuf.p,mo->y); WRITEFIXED(demobuf.p,mo->z); WRITEANGLE(demobuf.p,mo->angle); + P_SetTarget(ghostext[playernum].hitlist+i, NULL); } Z_Free(ghostext[playernum].hitlist); ghostext[playernum].hits = 0; From cf26092917d0ca677c5c9ea6a8b676024af9316b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 00:32:20 +0100 Subject: [PATCH 315/418] smol replay fixes from rr --- src/g_game.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 44c28d49f..c99fff965 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4926,6 +4926,7 @@ void G_WriteAllGhostTics(void) UINT8 *save_demo_p = demobuf.p; #define CHECKSPACE(num) if (demobuf.p+(num) > demoend) { demobuf.p = save_demo_p; G_CheckDemoStatus(); return; } + boolean toobig = false; INT32 i, counter = leveltime; for (i = 0; i < MAXPLAYERS; i++) @@ -4938,18 +4939,32 @@ void G_WriteAllGhostTics(void) counter++; - if (counter % cv_netdemosyncquality.value != 0) // Only write 1 in this many ghost datas per tic to cut down on multiplayer replay size. + if (multiplayer && ((counter % cv_netdemosyncquality.value) != 0)) // Only write 1 in this many ghost datas per tic to cut down on multiplayer replay size. continue; CHECKSPACE(1); WRITEUINT8(demobuf.p, i); G_WriteGhostTic(players[i].mo, i); + + // attention here for the ticcmd size! + // latest demos with mouse aiming byte in ticcmd + if (demobuf.p >= demoend - (13 + 9 + 9)) + { + toobig = true; + break; + } } CHECKSPACE(1); WRITEUINT8(demobuf.p, 0xFF); + if (toobig) + { + G_CheckDemoStatus(); // no more space + return; + } + #undef CHECKSPACE } @@ -5147,23 +5162,17 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) } *ziptic_p = ziptic; - - // attention here for the ticcmd size! - // latest demos with mouse aiming byte in ticcmd - if (demobuf.p >= demoend - (13 + 9)) - { - G_CheckDemoStatus(); // no more space - return; - } #undef CHECKSPACE } void G_ConsAllGhostTics(void) { - if (!demobuf.p) + UINT8 p; + + if (!demobuf.p || !demo.deferstart) return; - UINT8 p = READUINT8(demobuf.p); + p = READUINT8(demobuf.p); while (p != 0xFF) { @@ -5189,8 +5198,6 @@ void G_ConsGhostTic(INT32 playernum) fixed_t syncleeway; boolean nightsfail = false; - if (!demobuf.p || !demo.deferstart) - return; if (!(demoflags & DF_GHOST)) return; // No ghost data to use. From 112ca2707a0ace01bd2d934a8da55d81b1a831c6 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 12:16:38 +0100 Subject: [PATCH 316/418] even more replay deb prints lel --- src/g_game.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index c99fff965..f35d4b944 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4638,18 +4638,23 @@ void G_ReadDemoExtraData(void) while (p != DW_END) { UINT32 rng; + UINT32 checkrng; switch (p) { case DW_RNG: rng = READUINT32(demobuf.p); - if (P_GetRandSeed() != rng) + checkrng = P_GetRandSeed(); + if (checkrng != rng) { - P_SetRandSeed(rng); - if (demosynced) + { CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (RNG)!\n")); + CONS_Printf("expected rng %d got %d\n", rng, checkrng); + } demosynced = false; + + P_SetRandSeed(rng); } } @@ -5280,7 +5285,10 @@ void G_ConsGhostTic(INT32 playernum) if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { if (demosynced) + { CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (health)!\n")); + CONS_Printf("expected health %d got %d\n", health, mobj->health); + } demosynced = false; P_DamageMobj(mobj, players[0].mo, players[0].mo, 1); } @@ -5343,7 +5351,11 @@ void G_ConsGhostTic(INT32 playernum) ) { if (demosynced) + { CONS_Alert(CONS_WARNING, "Demo playback has desynced (item/bumpers)!(player %s)!\n", player_names[playernum]); + CONS_Printf("expected item type %d got %d\n", ghostext[playernum].kartitem, players[playernum].kartstuff[k_itemtype]); + CONS_Printf("expected item amount %d got %d\n", ghostext[playernum].kartamount, players[playernum].kartstuff[k_itemamount]); + } demosynced = false; players[playernum].kartstuff[k_itemtype] = ghostext[playernum].kartitem; From d764941341c850e9a6177a500040be152e74c629 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 19:05:42 +0100 Subject: [PATCH 317/418] inline V_LocalTransFlag its very smol --- src/v_video.c | 14 ++++---------- src/v_video.h | 9 +++++++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 0eca13591..f266f0209 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -589,28 +589,22 @@ static UINT8 hudplusalpha[11] = { 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0}; static UINT8 hudminusalpha[11] = { 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5}; UINT8 hudtrans = 0; -// this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol -INT32 V_LocalTransFlag(void) -{ - return ((10-cv_translucenthud.value)*V_10TRANS); -} - static const UINT8 *v_colormap = NULL; static const UINT8 *v_translevel = NULL; -static inline UINT8 standardpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) +FUNCINLINE static ATTRINLINE UINT8 standardpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) { (void)dest; return source[ofs>>FRACBITS]; } -static inline UINT8 mappedpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) +FUNCINLINE static ATTRINLINE UINT8 mappedpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) { (void)dest; return *(v_colormap + source[ofs>>FRACBITS]); } -static inline UINT8 translucentpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) +FUNCINLINE static ATTRINLINE UINT8 translucentpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) { return *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff)); } -static inline UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) +FUNCINLINE static ATTRINLINE UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) { return *(v_translevel + (((*(v_colormap + source[ofs>>FRACBITS]))<<8)&0xff00) + (*dest&0xff)); } diff --git a/src/v_video.h b/src/v_video.h index 36aa9f908..1a9497de1 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -17,6 +17,7 @@ #include "doomdef.h" #include "doomtype.h" #include "r_defs.h" +#include "r_main.h" // // VIDEO @@ -64,8 +65,6 @@ extern RGBA_t *pLocalPalette; extern UINT8 hudtrans; -extern INT32 V_LocalTransFlag(void); - void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue); // Retrieve the ARGB value from a palette color index @@ -256,6 +255,12 @@ char V_GetSkincolorChar(INT32 color); INT32 V_SkinColorToHighlightcolor(skincolors_t color); +// this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol +FUNCINLINE static ATTRINLINE INT32 V_LocalTransFlag(void) +{ + return ((10-cv_translucenthud.value)*V_10TRANS); +} + typedef struct player_s player_t; void V_DoPostProcessor(INT32 view, INT32 param); From c2b87b46fc7748f55234fde609beb99e4e7c1ee8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 19:33:57 +0100 Subject: [PATCH 318/418] refactor M_DrawSlider apparently fixes weird framerate issues with gamma slider also shows the values on sliders --- src/m_menu.c | 79 ++++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 226811a4f..82d8a454d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4972,53 +4972,60 @@ static void M_DrawSlider(INT32 x, INT32 y, const consvar_t *cv, boolean ontop) INT32 range; patch_t *p; - for (i = 0; cv->PossibleValue[i+1].strvalue; i++); - x = BASEVIDWIDTH - x - SLIDER_WIDTH; - if (ontop) - { - V_DrawCharacter(x - 16 - (skullAnimCounter/5), y, - '\x1C' | highlightflags, false); // left arrow - V_DrawCharacter(x+(SLIDER_RANGE*8) + 8 + (skullAnimCounter/5), y, - '\x1D' | highlightflags, false); // right arrow - } - - if ((range = atoi(cv->defaultvalue)) != cv->value) - { - range = ((range - cv->PossibleValue[0].value) * 100 / - (cv->PossibleValue[1].value - cv->PossibleValue[0].value)); - - if (range < 0) - range = 0; - if (range > 100) - range = 100; - - // draw the default - p = W_CachePatchName("M_SLIDEC", PU_CACHE); - V_DrawScaledPatch(x - 4 + (((SLIDER_RANGE)*8 + 4)*range)/100, y, 0, p); - } - - V_DrawScaledPatch(x - 8, y, 0, W_CachePatchName("M_SLIDEL", PU_CACHE)); + p = W_CachePatchName("M_SLIDEL", PU_CACHE); + V_DrawScaledPatch(x - 8, y, 0, p); p = W_CachePatchName("M_SLIDEM", PU_CACHE); for (i = 0; i < SLIDER_RANGE; i++) V_DrawScaledPatch (x+i*8, y, 0,p); p = W_CachePatchName("M_SLIDER", PU_CACHE); - V_DrawScaledPatch(x+SLIDER_RANGE*8, y, 0, p); - - range = ((cv->value - cv->PossibleValue[0].value) * 100 / - (cv->PossibleValue[1].value - cv->PossibleValue[0].value)); - - if (range < 0) - range = 0; - if (range > 100) - range = 100; + V_DrawScaledPatch(x+i*8, y, 0, p); // draw the slider cursor p = W_CachePatchName("M_SLIDEC", PU_CACHE); - V_DrawScaledPatch(x - 4 + (((SLIDER_RANGE)*8 + 4)*range)/100, y, 0, p); + + for (i = 0; cv->PossibleValue[i+1].strvalue; i++); + + if (cv->flags & CV_FLOAT) + range = (INT32)(atof(cv->defaultvalue)*FRACUNIT); + else + range = atoi(cv->defaultvalue); + + if (range != cv->value) + { + range = ((range - cv->PossibleValue[0].value) * 100 / + (cv->PossibleValue[i].value - cv->PossibleValue[0].value)); + + if (range < 0) + range = 0; + else if (range > 100) + range = 100; + + V_DrawMappedPatch(x - 4 + (((SLIDER_RANGE)*8 + 4)*range)/100, y, 0, p, yellowmap); + } + + range = ((cv->value - cv->PossibleValue[0].value) * 100 / + (cv->PossibleValue[i].value - cv->PossibleValue[0].value)); + + if (range < 0) + range = 0; + else if (range > 100) + range = 100; + + V_DrawMappedPatch(x - 4 + (((SLIDER_RANGE)*8 + 4)*range)/100, y, 0, p, yellowmap); + + if (ontop) + { + V_DrawCharacter(x - 16 - (skullAnimCounter/5), y, + '\x1C' | highlightflags, false); + V_DrawCharacter(x+(SLIDER_RANGE*8) + 8 + (skullAnimCounter/5), y, + '\x1D' | highlightflags, false); + V_DrawCenteredString(x + ((SLIDER_RANGE*8) + 8)/2, y, V_30TRANS, + (cv->flags & CV_FLOAT) ? va("%.2f", FIXED_TO_FLOAT(cv->value)) : va("%d", cv->value)); + } } // From 3152cddb3d17e343f6efbe0f51cb3d1527a44c97 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Wed, 29 Jan 2025 22:16:36 +0100 Subject: [PATCH 319/418] In rehashtab, do counthash before adding asize Thanks alug! --- src/bluajit/lj_tab.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bluajit/lj_tab.c b/src/bluajit/lj_tab.c index 869c5f03c..27b3021dd 100644 --- a/src/bluajit/lj_tab.c +++ b/src/bluajit/lj_tab.c @@ -359,8 +359,14 @@ static void rehashtab(lua_State *L, GCtab *t, cTValue *ek) uint32_t total, asize, na, i; for (i = 0; i < LJ_MAX_ABITS; i++) bins[i] = 0; asize = countarray(t, bins); +#if 0 total = 1 + asize; total += counthash(t, bins, &asize); +#else + /* more closely matches vanilla lua when abusing undefined behavior (frictionfix.....) */ + total = counthash(t, bins, &asize); + total += 1 + asize; +#endif asize += countint(ek, bins); na = bestasize(bins, &asize); total -= na; From 5ef8e5c4473d2da99de5ad41043e1a31263cad03 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 22:33:33 +0100 Subject: [PATCH 320/418] renable jit compile this branch is a mess lmao --- src/Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index 7945d26fc..cb71bc741 100644 --- a/src/Makefile +++ b/src/Makefile @@ -94,12 +94,9 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... NOUPX=1 NOOBJDUMP=1 - NOBLUAJIT=1 - else # if you on the *nix NOUPX=1 - NOBLUAJIT=1 system:=$(shell uname -s) From 5fb1b397421fc19b106202166f106344a1b4fe58 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 23:23:54 +0100 Subject: [PATCH 321/418] kill redundant laptime code just use the newer one --- src/d_player.h | 1 + src/doomstat.h | 1 - src/g_game.c | 2 -- src/p_setup.c | 6 +++++- src/p_spec.c | 8 ++------ src/p_user.c | 37 ++++++++++--------------------------- src/y_inter.c | 6 +++--- 7 files changed, 21 insertions(+), 40 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index b18fea1eb..d6702e2c0 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -351,6 +351,7 @@ typedef enum typedef enum { LAP_CUR, + LAP_BEST, LAP_LAST, LAP__MAX } laptime_e; diff --git a/src/doomstat.h b/src/doomstat.h index 024c0337e..441e9df3b 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -500,7 +500,6 @@ extern boolean startedInFreePlay; extern boolean legitimateexit; extern boolean comebackshowninfo; -extern tic_t curlap, bestlap; extern INT16 votelevels[4][2]; extern SINT8 votes[MAXPLAYERS]; diff --git a/src/g_game.c b/src/g_game.c index f35d4b944..ea794c574 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -280,8 +280,6 @@ boolean startedInFreePlay; // Map was started in free play // Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players) boolean legitimateexit; // Did this client actually finish the match? boolean comebackshowninfo; // Have you already seen the "ATTACK OR PROTECT" message? -tic_t curlap; // Current lap time -tic_t bestlap; // Best lap time static INT16 randmapbuffer[NUMMAPS+1]; // Buffer for maps RandMap is allowed to roll tic_t hidetime; diff --git a/src/p_setup.c b/src/p_setup.c index b934d7363..ef56316a6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2221,7 +2221,11 @@ static void P_LevelInitStuff(boolean reloadinggamestate) players[i].lives = 1; // SRB2Kart players[i].realtime = racecountdown = exitcountdown = 0; - curlap = bestlap = 0; // SRB2Kart + + for (INT32 j = 0; j < LAP__MAX; j++) + { + players[i].laptime[j] = 0; + } players[i].gotcontinue = false; diff --git a/src/p_spec.c b/src/p_spec.c index 2af086c57..8665fc382 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3913,17 +3913,13 @@ DoneSection2: CON_LogMessage(va(M_GetText("%s has finished the race.\n"), player_names[player-players])); // SRB2Kart: save best lap for record attack - if (player == &players[consoleplayer]) + if (player->laptime[LAP_CUR] < player->laptime[LAP_BEST] || player->laptime[LAP_BEST] == 0) { - if (curlap < bestlap || bestlap == 0) - bestlap = curlap; - curlap = 0; + player->laptime[LAP_BEST] = player->laptime[LAP_CUR]; } - // ONLY FOR HUD player->laptime[LAP_LAST] = player->laptime[LAP_CUR]; player->laptime[LAP_CUR] = 0; - // player->starposttime = player->realtime; player->starpostnum = 0; diff --git a/src/p_user.c b/src/p_user.c index 610be483a..5ad0d46c3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2927,24 +2927,15 @@ static void P_DeathThink(player_t *player) if (leveltime >= starttime) { player->realtime = leveltime - starttime; - if (player == &players[consoleplayer]) - { - if (player->spectator || !circuitmap) - curlap = 0; - else - curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V - } if (player->spectator) player->laptime[LAP_CUR] = 0; - else + else if (player->laptime[LAP_CUR] != UINT32_MAX) player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V } else { player->realtime = 0; - if (player == &players[consoleplayer]) - curlap = 0; player->laptime[LAP_CUR] = 0; } @@ -4680,25 +4671,15 @@ void P_PlayerThink(player_t *player) if (leveltime >= starttime) { player->realtime = leveltime - starttime; - if (player == &players[consoleplayer]) - { - if (player->spectator || !circuitmap) - curlap = 0; - else - curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V - } if (player->spectator) player->laptime[LAP_CUR] = 0; - else + else if (player->laptime[LAP_CUR] != UINT32_MAX) player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V } else { player->realtime = 0; - if (player == &players[consoleplayer]) - curlap = 0; - player->laptime[LAP_CUR] = 0; } } @@ -4808,21 +4789,23 @@ void P_PlayerThink(player_t *player) player->linkcount = 0; } - // Move around. - // Reactiontime is used to prevent movement - // for a bit after a teleport. if (player->mo->reactiontime) + { + // Reactiontime is used to prevent movement + // for a bit after a teleport. player->mo->reactiontime--; + } else if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) { - { - P_DoZoomTube(player); - } + P_DoZoomTube(player); player->rmomx = player->rmomy = 0; // no actual momentum from your controls P_ResetScore(player); } else + { + // Move around. P_MovePlayer(player); + } if (!player->mo) { diff --git a/src/y_inter.c b/src/y_inter.c index 505c85997..c359acc6b 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -716,13 +716,13 @@ static void Y_UpdateRecordReplays(void) if ((mainrecords[gamemap-1]->time == 0) || (players[consoleplayer].realtime < mainrecords[gamemap-1]->time)) mainrecords[gamemap-1]->time = players[consoleplayer].realtime; - if ((mainrecords[gamemap-1]->lap == 0) || (bestlap < mainrecords[gamemap-1]->lap)) - mainrecords[gamemap-1]->lap = bestlap; + if ((mainrecords[gamemap-1]->lap == 0) || (players[consoleplayer].laptime[LAP_BEST] < mainrecords[gamemap-1]->lap)) + mainrecords[gamemap-1]->lap = players[consoleplayer].laptime[LAP_BEST]; // Save demo! bestdemo[255] = '\0'; lastdemo[255] = '\0'; - G_SetDemoTime(players[consoleplayer].realtime, bestlap); + G_SetDemoTime(players[consoleplayer].realtime, players[consoleplayer].laptime[LAP_BEST]); G_CheckDemoStatus(); I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); From 5d2e08d12448ae47c6df9f17df6f6355a2219c01 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 23:57:25 +0100 Subject: [PATCH 322/418] turn driftsparkGrowTimer into a player field less hacky and avoids 3 loops lol --- src/d_netcmd.c | 5 ----- src/d_netcmd.h | 2 -- src/d_player.h | 2 ++ src/k_kart.c | 41 ++++------------------------------------- src/p_setup.c | 2 ++ 5 files changed, 8 insertions(+), 44 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index bbf24e35e..c255a4e42 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2434,8 +2434,6 @@ static void Command_StopMovie_f(void) INT32 mapchangepending = 0; -tic_t driftsparkGrowTimer[MAXPLAYERS]; - /** Runs a map change. * The supplied data are assumed to be good. If provided by a user, they will * have already been checked in Command_Map_f(). @@ -2469,9 +2467,6 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r CONS_Debug(DBG_GAMELOGIC, "Map change: mapnum=%d gametype=%d encoremode=%d resetplayers=%d delay=%d skipprecutscene=%d\n", mapnum, newgametype, pencoremode, resetplayers, delay, skipprecutscene); - // just gonna hack in a timer reset here... - memset(driftsparkGrowTimer, 0, sizeof(driftsparkGrowTimer)); - if (netgame || multiplayer) FLS = false; diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 3cffcf4bc..1b9bd9808 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -297,8 +297,6 @@ typedef union { #pragma pack() #endif -extern tic_t driftsparkGrowTimer[16]; - // add game commands, needs cleanup void D_RegisterServerCommands(void); void D_RegisterClientCommands(void); diff --git a/src/d_player.h b/src/d_player.h index d6702e2c0..0991144fb 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -551,6 +551,8 @@ typedef struct player_s UINT8 splitscreenindex; + tic_t driftsparkGrowTimer; + fixed_t fovadd; // adjust FOV for hw rendering } player_t; diff --git a/src/k_kart.c b/src/k_kart.c index 8fb4721b5..b9f2a8606 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3249,7 +3249,6 @@ static void K_SpawnDriftSparks(player_t *player) for (i = 0; i < 2; i++) { - UINT8 pindex; fixed_t driftExtraScale = 0; newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(32*FRACUNIT, player->mo->scale)); newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(32*FRACUNIT, player->mo->scale)); @@ -3259,16 +3258,7 @@ static void K_SpawnDriftSparks(player_t *player) spark->angle = travelangle-(ANGLE_45/5)*player->kartstuff[k_drift]; // scale increase while driftspark level gained timer is running - - // hack to find the correct player number - for (pindex = 0; pindex < MAXPLAYERS; pindex++) - { - if (player == &players[pindex]) - { - driftExtraScale = FixedDiv(driftsparkGrowTimer[pindex], DRIFTSPARKGROWTICS); - break; - } - } + driftExtraScale = FixedDiv(player->driftsparkGrowTimer, DRIFTSPARKGROWTICS); spark->destscale = FixedMul(player->mo->scale, FRACUNIT + FixedMul(driftExtraScale, cv_driftsparkpulse.value)); P_SetScale(spark, FixedMul(player->mo->scale, FRACUNIT + FixedMul(driftExtraScale, cv_driftsparkpulse.value))); @@ -6001,7 +5991,6 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_driftend] = 0; } - // Incease/decrease the drift value to continue drifting in that direction if (player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_jmp] == 1 && onground && player->kartstuff[k_drift] != 0) { @@ -6041,20 +6030,11 @@ static void K_KartDrift(player_t *player, boolean onground) || (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo) || (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree)) { - UINT8 pindex; //S_StartSound(player->mo, sfx_s3ka2); if (P_IsLocalPlayer(player)) // UGHGHGH... S_StartSoundAtVolume(player->mo, sfx_s3ka2, 192); // Ugh... - // hack to find the correct player number - for (pindex = 0; pindex < MAXPLAYERS; pindex++) - { - if (player == &players[pindex]) - { - driftsparkGrowTimer[pindex] = DRIFTSPARKGROWTICS; - break; - } - } + player->driftsparkGrowTimer = DRIFTSPARKGROWTICS; } @@ -6067,21 +6047,8 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_driftend] = 0; } - { - //im putting this in a block because i want the variables here, not at the top of the block - UINT8 pindex; - - // hack to find the correct player number - for (pindex = 0; pindex < MAXPLAYERS; pindex++) - { - if (player == &players[pindex]) - { - if (driftsparkGrowTimer[pindex]) - driftsparkGrowTimer[pindex]--; - break; - } - } - } + if (player->driftsparkGrowTimer) + player->driftsparkGrowTimer--; // Stop drifting if (player->kartstuff[k_spinouttimer] > 0 || player->speed < minspeed) diff --git a/src/p_setup.c b/src/p_setup.c index ef56316a6..7ff71b4be 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2227,6 +2227,8 @@ static void P_LevelInitStuff(boolean reloadinggamestate) players[i].laptime[j] = 0; } + players[i].driftsparkGrowTimer = 0; + players[i].gotcontinue = false; players[i].xtralife = players[i].deadtimer = players[i].numboxes = players[i].totalring = players[i].laps = 0; From 9f4b72800acab368f594beb1711c5d1b8475b591 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 23:57:42 +0100 Subject: [PATCH 323/418] lmao --- src/k_kart.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index b9f2a8606..ba58f92eb 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6055,12 +6055,6 @@ static void K_KartDrift(player_t *player, boolean onground) { player->kartstuff[k_drift] = player->kartstuff[k_driftcharge] = 0; player->kartstuff[k_aizdriftstrat] = player->kartstuff[k_brakedrift] = 0; - - if (!player->sliproll) - { - player->sliproll = 0; - } - player->kartstuff[k_getsparks] = 0; } From 0b71bc2880b034a85479f7165b69a6e39c72ff5d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 30 Jan 2025 00:04:21 +0100 Subject: [PATCH 324/418] move this after the early returns save some time when drifting --- src/k_kart.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ba58f92eb..cfe22bdce 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5862,11 +5862,6 @@ static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer) INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) { - fixed_t p_topspeed = K_GetKartSpeed(player, false); - fixed_t p_curspeed = min(player->speed, p_topspeed * 2); - fixed_t p_maxspeed = p_topspeed * 3; - fixed_t adjustangle = FixedDiv((p_maxspeed>>16) - (p_curspeed>>16), (p_maxspeed>>16) + player->kartweight); - if (player->spectator) return turnvalue; @@ -5885,6 +5880,11 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) return turnvalue; } + fixed_t p_topspeed = K_GetKartSpeed(player, false); + fixed_t p_curspeed = min(player->speed, p_topspeed * 2); + fixed_t p_maxspeed = p_topspeed * 3; + fixed_t adjustangle = FixedDiv((p_maxspeed>>16) - (p_curspeed>>16), (p_maxspeed>>16) + player->kartweight); + turnvalue = FixedMul(turnvalue, adjustangle); // Weight has a small effect on turning if (player->kartstuff[k_invincibilitytimer] || player->kartstuff[k_sneakertimer] || player->kartstuff[k_growshrinktimer] > 0) From 93a1a432d7b0eb926fd83c189219017421808da4 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 30 Jan 2025 00:07:32 +0100 Subject: [PATCH 325/418] "kill" seenames idk if anyone wants it, its still there, needed to move the netvar out of it tho lol --- src/d_netcmd.c | 6 +++--- src/doomdef.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c255a4e42..ef7846db4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -263,8 +263,8 @@ consvar_t cv_competitionboxes = {"competitionboxes", "Random", CV_NETVAR|CV_CHEA #ifdef SEENAMES static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}}; consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif +consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; // bruh // these are just meant to be saved to the config consvar_t cv_playername = {"name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -776,9 +776,9 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_showping); CV_RegisterVar(&cv_pingmeasurement); -#ifdef SEENAMES +//#ifdef SEENAMES // bruh again CV_RegisterVar(&cv_allowseenames); -#endif +//#endif CV_RegisterVar(&cv_dummyconsvar); diff --git a/src/doomdef.h b/src/doomdef.h index 297128269..3ea9fbb63 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -606,7 +606,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; //#define DUMPCONSISTENCY /// See name of player in your crosshair -#define SEENAMES +//#define SEENAMES /// Allow loading of savegames between different versions of the game. /// \note XMOD port. From e689deaa2bd7a4522cc499f871a5987072111ff4 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 30 Jan 2025 00:14:57 +0100 Subject: [PATCH 326/418] dont need to do all this crap if disabled --- src/p_user.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 5ad0d46c3..addbefbe4 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2479,7 +2479,6 @@ static void P_MovePlayer(player_t *player) K_DriftDustHandling(player->mo); - // Crush test... if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) && !(player->mo->flags & MF_NOCLIP)) @@ -4986,7 +4985,7 @@ void P_PlayerThink(player_t *player) K_KartPlayerThink(player, cmd); // SRB2kart - if (rendermode != render_none) + if (rendermode != render_none && cv_tilting.value) DoABarrelRoll(player); LUA_HookPlayer(player, HOOK(PlayerThink)); From 7ec00a279c2463dca87b1a8ed3ea5898feb66491 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 30 Jan 2025 11:45:35 +0100 Subject: [PATCH 327/418] tiny cleanup i_video --- src/sdl/i_video.c | 88 ++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 59 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index f81d8f4e6..1683ec2ea 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -420,7 +420,6 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) { SDL_Event next_event; - boolean Text_Input_Only = (chat_on || CON_Ready() || (menu_text_input && menuactive)); //only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) // Special cases, where we always return a fixed value. switch (sym->sym) @@ -431,7 +430,7 @@ static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) break; } - if (Text_Input_Only) + if (chat_on || CON_Ready() || (menu_text_input && menuactive)) //only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) { if (SDL_PeepEvents(&next_event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 1 && next_event.type == SDL_TEXTINPUT) { @@ -871,9 +870,9 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) return; } - if (cv_keyboardlayout.value == 2) + if (cv_keyboardlayout.value == 2) // "native" event.data1 = GetTypedChar(evt.keysym.scancode, &evt.keysym); - else if (cv_keyboardlayout.value == 3) + else if (cv_keyboardlayout.value == 3) // AZERTY event.data1 = Impl_SDL_Keysym_To_Keycode(evt.keysym); else event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); @@ -926,8 +925,6 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) { event_t event; - SDL_memset(&event, 0, sizeof(event_t)); - // Ignore the event if the mouse is not actually focused on the window. // This can happen if you used the mouse to restore keyboard focus; // this apparently makes a mouse button down event but not a mouse button up event, @@ -939,6 +936,8 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) /// \todo inputEvent.button.which if (USE_MOUSEINPUT) { + SDL_memset(&event, 0, sizeof(event_t)); + if (type == SDL_MOUSEBUTTONUP) { event.type = ev_keyup; @@ -969,26 +968,29 @@ static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt) { event_t event; - SDL_memset(&event, 0, sizeof(event_t)); + if (USE_MOUSEINPUT) + { + SDL_memset(&event, 0, sizeof(event_t)); - if (evt.y > 0) - { - event.data1 = KEY_MOUSEWHEELUP; - event.type = ev_keydown; - } - if (evt.y < 0) - { - event.data1 = KEY_MOUSEWHEELDOWN; - event.type = ev_keydown; - } - if (evt.y == 0) - { - event.data1 = 0; - event.type = ev_keyup; - } - if (event.type == ev_keyup || event.type == ev_keydown) - { - D_PostEvent(&event); + if (evt.y > 0) + { + event.data1 = KEY_MOUSEWHEELUP; + event.type = ev_keydown; + } + if (evt.y < 0) + { + event.data1 = KEY_MOUSEWHEELDOWN; + event.type = ev_keydown; + } + if (evt.y == 0) + { + event.data1 = 0; + event.type = ev_keyup; + } + if (event.type == ev_keyup || event.type == ev_keydown) + { + D_PostEvent(&event); + } } } @@ -1101,6 +1103,7 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint event.data1 = KEY_4JOY1; } else return; + if (type == SDL_CONTROLLERBUTTONUP) { event.type = ev_keyup; @@ -1110,6 +1113,7 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint event.type = ev_keydown; } else return; + if (evt.button < JOYBUTTONS) { event.data1 += evt.button; @@ -1416,37 +1420,6 @@ void I_UpdateNoBlit(void) exposevideo = SDL_FALSE; } -// I_SkipFrame -// -// Returns true if it thinks we can afford to skip this frame -// from PrBoom's src/SDL/i_video.c -static inline boolean I_SkipFrame(void) -{ -#if 1 - // While I fixed the FPS counter bugging out with this, - // I actually really like being able to pause and - // use perfstats to measure rendering performance - // without game logic changes. - return false; -#else - static boolean skip = false; - - skip = !skip; - - switch (gamestate) - { - case GS_LEVEL: - if (!paused) - return false; - /* FALLTHRU */ - case GS_WAITINGPLAYERS: - return skip; // Skip odd frames - default: - return false; - } -#endif -} - // // I_FinishUpdate // @@ -1459,9 +1432,6 @@ void I_FinishUpdate(void) SCR_CalculateFPS(); - if (I_SkipFrame()) - return; - if (st_overlay) { if (cv_ticrate.value) From 0db2aebfdaf7cf3ecea0e7184b249a1dc553586a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 30 Jan 2025 13:11:30 +0100 Subject: [PATCH 328/418] dont register a crapton of pointless stuff for dedi should cleanup dedi config significantly lmao --- src/d_netcmd.c | 13 +++++++++---- src/k_kart.c | 29 +++++++++++++++++------------ src/k_kart.h | 3 ++- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ef7846db4..57ba1b783 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -650,7 +650,6 @@ void D_RegisterServerCommands(void) COM_AddCommand("addfilelocal", Command_Addfilelocal); COM_AddCommand("addfile", Command_Addfile); COM_AddCommand("addskins", Command_Addskins); - COM_AddCommand("localskin", Command_GLocalSkin); COM_AddCommand("listwad", Command_ListWADS_f); COM_AddCommand("listmapthings", Command_ListDoomednums_f); COM_AddCommand("listunusedsprites", Command_ListUnusedSprites_f); @@ -715,7 +714,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_competitionboxes); CV_RegisterVar(&cv_matchboxes); - K_RegisterKartStuff(); // SRB2kart + K_RegisterServerKartStuff(); // SRB2kart CV_RegisterVar(&cv_ringslinger); @@ -794,8 +793,6 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_maxdemosize); CV_RegisterVar(&cv_demochangemap); - CV_RegisterVar(&cv_keyboardlayout); - #ifndef NOBLUAJIT CV_RegisterVar(&cv_luajit); #endif @@ -857,6 +854,10 @@ void D_RegisterClientCommands(void) COM_AddCommand("stopmovie", Command_StopMovie_f); COM_AddCommand("minigen", M_MinimapGenerate); + COM_AddCommand("localskin", Command_GLocalSkin); + + K_RegisterClientKartStuff(); // SRB2kart + CV_RegisterVar(&cv_screenshot_option); CV_RegisterVar(&cv_screenshot_folder); CV_RegisterVar(&cv_moviemode); @@ -907,7 +908,9 @@ void D_RegisterClientCommands(void) #ifdef SEENAMES CV_RegisterVar(&cv_seenames); #endif + CV_RegisterVar(&cv_rollingdemos); + CV_RegisterVar(&cv_netstat); CV_RegisterVar(&cv_netticbuffer); CV_RegisterVar(&cv_mindelay); @@ -926,6 +929,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_cechotoggle); + CV_RegisterVar(&cv_keyboardlayout); + // time attack ghost options are also saved to config CV_RegisterVar(&cv_ghost_besttime); CV_RegisterVar(&cv_ghost_bestlap); diff --git a/src/k_kart.c b/src/k_kart.c index cfe22bdce..4de71d487 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -743,19 +743,8 @@ boolean K_UseColorHud(void) //{ SRB2kart Net Variables -void K_RegisterKartStuff(void) +void K_RegisterServerKartStuff(void) { - HudColor_cons_t[0].value = 0; - HudColor_cons_t[0].strvalue = "Skin Color"; - - for (INT32 i = 1; i < MAXSKINCOLORS; i++) - { - HudColor_cons_t[i].value = i; - HudColor_cons_t[i].strvalue = KartColor_Names[i]; // SRB2kart - } - HudColor_cons_t[MAXSKINCOLORS].value = 0; - HudColor_cons_t[MAXSKINCOLORS].strvalue = NULL; - CV_RegisterVar(&cv_sneaker); CV_RegisterVar(&cv_rocketsneaker); CV_RegisterVar(&cv_invincibility); @@ -805,6 +794,22 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartdebugcheckpoint); CV_RegisterVar(&cv_kartdebugnodes); CV_RegisterVar(&cv_kartdebugcolorize); +} + +// Registers kart client commands and variables. +// Nothing needed for a dedicated server should be registered here. +void K_RegisterClientKartStuff(void) +{ + HudColor_cons_t[0].value = 0; + HudColor_cons_t[0].strvalue = "Skin Color"; + + for (INT32 i = 1; i < MAXSKINCOLORS; i++) + { + HudColor_cons_t[i].value = i; + HudColor_cons_t[i].strvalue = KartColor_Names[i]; // SRB2kart + } + HudColor_cons_t[MAXSKINCOLORS].value = 0; + HudColor_cons_t[MAXSKINCOLORS].strvalue = NULL; #define REG_HUD_OFFSET_X(name)\ CV_RegisterVar(&cv_##name##_xoffset); diff --git a/src/k_kart.h b/src/k_kart.h index dde5e21af..2fa2ab6e3 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -21,7 +21,8 @@ UINT8 K_GetKartColorByName(const char *name); UINT8 K_GetHudColor(void); boolean K_UseColorHud(void); -void K_RegisterKartStuff(void); +void K_RegisterServerKartStuff(void); +void K_RegisterClientKartStuff(void); extern consvar_t cv_coloredspeedlines, cv_coloredsneakertrail; extern consvar_t cv_bananajitter; From 15eee102fd493a5e2b00c9bdbc9f81e285c3a702 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 30 Jan 2025 13:25:12 +0100 Subject: [PATCH 329/418] partly revert this some of those "mightve" been changed at the point of the check --- src/p_floor.c | 2 +- src/p_map.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 887385035..2aa9cf0f7 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2249,7 +2249,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) continue; if (!(players[i].mo->subsector->sector == sec - || P_PlayerTouchingSectorSpecial(&players[i], 2, secspecial) == sec)) + || P_PlayerTouchingSectorSpecial(&players[i], 2, GETSECSPECIAL(sec->special, 2)) == sec)) continue; if (floortouch == true && P_IsObjectOnRealGround(players[i].mo, sec)) diff --git a/src/p_map.c b/src/p_map.c index 3d588a98d..888e92099 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2409,10 +2409,11 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { //All things are affected by their scale. fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale); - const INT32 secspecial = (thing->player) ? GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) : 0; if (thing->player) { + const INT32 secspecial = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1); + // If using type Section1:13, double the maxstep. if (P_PlayerTouchingSectorSpecial(thing->player, 1, 13) || secspecial == 13) @@ -2465,7 +2466,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (maxstep > 0 && !( thing->player && ( P_PlayerTouchingSectorSpecial(thing->player, 1, 14) - || secspecial == 14) + || GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14) )) // Step down { // If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS From 36a1662afb03157e4a01d5f080b1657a75be3658 Mon Sep 17 00:00:00 2001 From: Chearii Date: Sun, 2 Feb 2025 20:37:19 -0500 Subject: [PATCH 330/418] Add blending modes --- src/dehacked.c | 28 +++++ src/f_wipe.c | 2 +- src/hardware/hw_defs.h | 26 ++--- src/hardware/hw_draw.c | 14 ++- src/hardware/hw_main.c | 146 ++++++++++++++++++++---- src/hardware/hw_main.h | 5 +- src/hardware/hw_md2.c | 9 ++ src/hardware/r_opengl/r_opengl.c | 163 ++++++++++++++++---------- src/k_kart.c | 6 +- src/lua_hudlib.c | 23 ++-- src/lua_hudlib_drawlist.c | 19 +++- src/lua_hudlib_drawlist.h | 9 +- src/lua_mobjlib.c | 14 +++ src/m_anigif.c | 11 +- src/p_mobj.c | 1 + src/p_mobj.h | 2 + src/p_pspr.h | 28 ++++- src/p_saveg.c | 1 + src/r_data.c | 107 +++++++++++++++++ src/r_data.h | 3 + src/r_defs.h | 3 + src/r_draw.c | 190 ++++++++++++++++++++++++++++++- src/r_draw.h | 23 +++- src/r_main.c | 4 +- src/r_plane.c | 22 ++-- src/r_segs.c | 24 ++-- src/r_things.c | 84 +++++++++++--- src/r_things.h | 7 ++ src/v_video.c | 72 ++++++++---- src/v_video.h | 36 ++++-- 30 files changed, 872 insertions(+), 210 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index dc4288be5..007324764 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7721,7 +7721,18 @@ struct { {"FF_HORIZONTALFLIP",FF_HORIZONTALFLIP}, {"FF_PAPERSPRITE",FF_PAPERSPRITE}, {"FF_ANIMATE",FF_ANIMATE}, + // brightness + {"FF_BRIGHTMASK",FF_BRIGHTMASK}, {"FF_FULLBRIGHT",FF_FULLBRIGHT}, + {"FF_SEMIBRIGHT",FF_SEMIBRIGHT}, + {"FF_FULLDARK",FF_FULLDARK}, + // blending + {"FF_BLENDMASK",FF_BLENDMASK}, + {"FF_BLENDSHIFT",FF_BRIGHTMASK}, + {"FF_ADD",FF_ADD}, + {"FF_SUBTRACT",FF_SUBTRACT}, + {"FF_REVERSESUBTRACT",FF_REVERSESUBTRACT}, + {"FF_MODULATE",FF_MODULATE}, {"FF_TRANSMASK",FF_TRANSMASK}, {"FF_TRANSSHIFT",FF_TRANSSHIFT}, // new preshifted translucency (used in source) @@ -7757,6 +7768,15 @@ struct { {"tr_trans90",tr_trans90}, {"NUMTRANSMAPS",NUMTRANSMAPS}, + // Alpha styles (blend modes) + {"AST_COPY",AST_COPY}, + {"AST_TRANSLUCENT",AST_TRANSLUCENT}, + {"AST_ADD",AST_ADD}, + {"AST_SUBTRACT",AST_SUBTRACT}, + {"AST_REVERSESUBTRACT",AST_REVERSESUBTRACT}, + {"AST_MODULATE",AST_MODULATE}, + {"AST_OVERLAY",AST_OVERLAY}, + // Type of levels {"TOL_SP",TOL_SP}, {"TOL_COOP",TOL_COOP}, @@ -8121,6 +8141,14 @@ struct { {"V_CHARCOLORSHIFT",V_CHARCOLORSHIFT}, {"V_ALPHASHIFT",V_ALPHASHIFT}, + // Blending + {"V_BLENDSHIFT",V_BLENDSHIFT}, + {"V_BLENDMASK",V_BLENDMASK}, + {"B_ADD",B_ADD}, + {"B_SUBTRACT",B_SUBTRACT}, + {"B_REVERSESUBTRACT",B_REVERSESUBTRACT}, + {"B_MODULATE",B_MODULATE}, + //Kick Reasons {"KR_KICK",KR_KICK}, {"KR_PINGLIMIT",KR_PINGLIMIT}, diff --git a/src/f_wipe.c b/src/f_wipe.c index da5b9dac1..1523ca1d3 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -273,7 +273,7 @@ static void F_DoWipe(fademask_t *fademask) else { // pointer to transtable that this mask would use - transtbl = transtables + ((9 - *mask)< FlatColor PF_NoTexture = 0x00002000, // Disable texture diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index e39398ff2..b2d69861a 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -125,13 +125,14 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) HWD.pfnDrawPolygon(NULL, v, 4, flags); } -void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap) +void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags) { FOutVector v[4]; FBITFIELD flags; float cx = FIXED_TO_FLOAT(x); float cy = FIXED_TO_FLOAT(y); UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT8 blendmode = ((bflags & V_BLENDMASK) >> V_BLENDSHIFT); // 3--2 // | /| @@ -286,22 +287,27 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t v[0].t = v[1].t = 0.0f; v[2].t = v[3].t = gpatch->max_t; - flags = PF_Translucent|PF_NoDepthTest; - if (option & V_WRAPX) flags |= PF_ForceWrapX; if (option & V_WRAPY) flags |= PF_ForceWrapY; // clip it since it is used for bunny scroll in doom I + if (blendmode) + flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; + else + flags = PF_Translucent|PF_NoDepthTest; + if (alphalevel) { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; + if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[hudtrans]; else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[hudtrans]; else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans]; else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; + flags |= PF_Modulated; HWD.pfnDrawPolygon(&Surf, v, 4, flags); } @@ -455,10 +461,12 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; + if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[cv_translucenthud.value]; else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[cv_translucenthud.value]; else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value]; else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; + flags |= PF_Modulated; HWD.pfnDrawPolygon(&Surf, v, 4, flags); } diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b02730814..1fd05d947 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -654,7 +654,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool HWR_Lighting(&Surf, lightlevel, planecolormap); - if (PolyFlags & (PF_Translucent|PF_Fog)) + if (PolyFlags & (PF_Translucent|PF_Fog|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) { Surf.PolyColor.s.alpha = (UINT8)alpha; PolyFlags |= PF_Modulated; @@ -836,20 +836,67 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) } #endif -FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf) +FBITFIELD HWR_GetBlendModeFlag(INT32 ast) +{ + switch (ast) + { + case AST_TRANSLUCENT: + return PF_Translucent; + case AST_ADD: + return PF_Additive; + case AST_SUBTRACT: + return PF_Subtractive; + case AST_REVERSESUBTRACT: + return PF_ReverseSubtract; + case AST_MODULATE: + return PF_Multiplicative; + default: + return PF_Masked; + } + + return 0; +} + +UINT8 HWR_GetTranstableAlpha(INT32 transtablenum) { switch (transtablenum) { - case tr_trans10 : pSurf->PolyColor.s.alpha = 0xe6;return PF_Translucent; - case tr_trans20 : pSurf->PolyColor.s.alpha = 0xcc;return PF_Translucent; - case tr_trans30 : pSurf->PolyColor.s.alpha = 0xb3;return PF_Translucent; - case tr_trans40 : pSurf->PolyColor.s.alpha = 0x99;return PF_Translucent; - case tr_trans50 : pSurf->PolyColor.s.alpha = 0x80;return PF_Translucent; - case tr_trans60 : pSurf->PolyColor.s.alpha = 0x66;return PF_Translucent; - case tr_trans70 : pSurf->PolyColor.s.alpha = 0x4c;return PF_Translucent; - case tr_trans80 : pSurf->PolyColor.s.alpha = 0x33;return PF_Translucent; - case tr_trans90 : pSurf->PolyColor.s.alpha = 0x19;return PF_Translucent; + case 0 : return 0xff; + case tr_trans10 : return 0xe6; + case tr_trans20 : return 0xcc; + case tr_trans30 : return 0xb3; + case tr_trans40 : return 0x99; + case tr_trans50 : return 0x80; + case tr_trans60 : return 0x66; + case tr_trans70 : return 0x4c; + case tr_trans80 : return 0x33; + case tr_trans90 : return 0x19; } + + return 0xff; +} + +FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf) +{ + if (!transtablenum || style <= AST_COPY || style >= AST_OVERLAY) + { + pSurf->PolyColor.s.alpha = 0xff; + return PF_Masked; + } + + pSurf->PolyColor.s.alpha = HWR_GetTranstableAlpha(transtablenum); + return HWR_GetBlendModeFlag(style); +} + +FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf) +{ + if (!transtablenum) + { + pSurf->PolyColor.s.alpha = 0x00; + return PF_Masked; + } + + pSurf->PolyColor.s.alpha = HWR_GetTranstableAlpha(transtablenum); return PF_Translucent; } @@ -1067,8 +1114,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (cutflag & FF_FOG) HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); + else if (polyflags & (PF_Translucent|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); } @@ -3562,6 +3609,12 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // co-ordinates memcpy(wallVerts, baseWallVerts, sizeof(baseWallVerts)); + INT32 blendmode; + if (spr->mobj->frame & FF_BLENDMASK) + blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = spr->mobj->blendmode; + if (!cv_translucency.value) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; @@ -3570,10 +3623,13 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) else if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - blend = PF_Translucent; + blend = HWR_GetBlendModeFlag(blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + { + INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; + blend = HWR_SurfaceBlend(blendmode, trans, &Surf); + } else { // BP: i agree that is little better in environement but it don't @@ -3581,7 +3637,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; + blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } if (HWR_UseShader()) @@ -3599,8 +3655,10 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) i = 0; temp = FLOAT_TO_FIXED(realtop); - if (spr->mobj->frame & FF_FULLBRIGHT) + if (R_ThingIsFullBright(spr->mobj)) lightlevel = 255; + else if (R_ThingIsFullDark(spr->mobj)) + lightlevel = 0; for (i = 1; i < sector->numlights; i++) { @@ -3614,6 +3672,9 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) break; } + if (R_ThingIsSemiBright(spr->mobj)) + lightlevel = 128 + (lightlevel>>1); + for (i = 0; i < sector->numlights; i++) { if (endtop < endrealbot && top < realbot) @@ -3832,11 +3893,22 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) UINT8 lightlevel = 255; extracolormap_t *colormap = sector->extra_colormap; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (R_ThingIsFullDark(spr->mobj)) + lightlevel = 0; + else if (!(R_ThingIsFullBright(spr->mobj))) lightlevel = min(sector->lightlevel, 255); + if (R_ThingIsSemiBright(spr->mobj)) + lightlevel = 128 + (lightlevel>>1); + HWR_Lighting(&Surf, lightlevel, colormap); + INT32 blendmode; + if (spr->mobj->frame & FF_BLENDMASK) + blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = spr->mobj->blendmode; + if (!cv_translucency.value) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; @@ -3845,10 +3917,13 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - blend = PF_Translucent; + blend = HWR_GetBlendModeFlag(blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + { + INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; + blend = HWR_SurfaceBlend(blendmode, trans, &Surf); + } else { // BP: i agree that is little better in environement but it don't @@ -3856,7 +3931,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; + blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } if (HWR_UseShader()) @@ -3946,7 +4021,10 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) HWR_Lighting(&Surf, lightlevel, colormap); if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + { + INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; + blend = HWR_SurfaceBlend(AST_TRANSLUCENT, trans, &Surf); + } else { // BP: i agree that is little better in environement but it don't @@ -3954,7 +4032,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; + blend = HWR_GetBlendModeFlag(AST_TRANSLUCENT)|PF_Occlude; } if (HWR_UseShader()) @@ -4473,6 +4551,19 @@ static void HWR_ProjectSprite(mobj_t *thing) if (interp.spritexscale < 1 || interp.spriteyscale < 1) return; + INT32 blendmode; + if (thing->frame & FF_BLENDMASK) + blendmode = ((thing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = thing->blendmode; + + // Visibility check by the blend mode. + if (thing->frame & FF_TRANSMASK) + { + if (!R_BlendLevelVisible(blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT)) + return; + } + this_scale = FIXED_TO_FLOAT(interp.scale); spritexscale = FIXED_TO_FLOAT(interp.spritexscale); spriteyscale = FIXED_TO_FLOAT(interp.spriteyscale); @@ -4797,6 +4888,13 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) R_InterpolatePrecipMobjState(thing, FRACUNIT, &interp); } + // Visibility check by the blend mode. + if (thing->frame & FF_TRANSMASK) + { + if (!R_BlendLevelVisible(thing->blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT)) + return; + } + this_scale = FIXED_TO_FLOAT(interp.scale); // transform the origin point @@ -5190,7 +5288,7 @@ static void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) for (x = vid.width>>1; x < vid.width; x += pw) { for (y = vid.height>>1; y < vid.height; y += ph) - HWR_DrawStretchyFixedPatch(gpatch, (x)<mobj->flags2 & MF2_SHADOW) + { Surf.PolyColor.s.alpha = 0x40; + Surf.PolyFlags = HWR_GetBlendModeFlag(spr->mobj->blendmode); + } else if (spr->mobj->frame & FF_TRANSMASK) + { HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + Surf.PolyFlags = HWR_SurfaceBlend(spr->mobj->blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + } else + { Surf.PolyColor.s.alpha = 0xFF; + Surf.PolyFlags = 0; + } // dont forget to enabled the depth test because we can't do this like // before: polygons models are not sorted diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 4b98f332d..231f2b01e 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -490,6 +490,10 @@ static PFNglDeleteBuffers pglDeleteBuffers; typedef void (APIENTRY *PFNglColorPointer) (GLint, GLenum, GLsizei, const GLvoid*); static PFNglColorPointer pglColorPointer; +/* 2.0 functions */ +typedef void (APIENTRY * PFNglBlendEquation) (GLenum mode); +static PFNglBlendEquation pglBlendEquation; + /* 1.2 Parms */ /* GL_CLAMP_TO_EDGE_EXT */ #ifndef GL_CLAMP_TO_EDGE @@ -734,6 +738,9 @@ void SetupGLFunc4(void) pglBufferData = GetGLFunc("glBufferData"); pglDeleteBuffers = GetGLFunc("glDeleteBuffers"); pglColorPointer = GetGLFunc("glColorPointer"); + + /* 2.0 funcs */ + pglBlendEquation = GetGLFunc("glBlendEquation"); pglStencilFuncSeparate = GetGLFunc("glStencilFuncSeparate"); pglStencilOpSeparate = GetGLFunc("glStencilOpSeparate"); @@ -1397,7 +1404,11 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1, pglEnableClientState(GL_TEXTURE_COORD_ARRAY); pglEnable(GL_TEXTURE_2D); } - +// -----------------+ +// SetBlend : Set render mode +// -----------------+ +// PF_Masked - we could use an ALPHA_TEST of GL_EQUAL, and alpha ref of 0, +// is it faster when pixels are discarded ? static void Clamp2D(GLenum pname) { pglTexParameteri(GL_TEXTURE_2D, pname, GL_CLAMP); // fallback clamp @@ -1406,57 +1417,95 @@ static void Clamp2D(GLenum pname) #endif } -// -----------------+ -// SetBlend : Set render mode -// -----------------+ -// PF_Masked - we could use an ALPHA_TEST of GL_EQUAL, and alpha ref of 0, -// is it faster when pixels are discarded ? +static void SetBlendEquation(GLenum mode) +{ + if (pglBlendEquation) + pglBlendEquation(mode); +} + +static void SetBlendMode(FBITFIELD flags) +{ + // Set blending function + switch (flags) + { + case PF_Translucent & PF_Blending: + pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency + break; + case PF_Masked & PF_Blending: + // Hurdler: does that mean lighting is only made by alpha src? + // it sounds ok, but not for polygonsmooth + pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); // 0 alpha = holes in texture + break; + case PF_Additive & PF_Blending: + case PF_Subtractive & PF_Blending: + case PF_ReverseSubtract & PF_Blending: + pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest + break; + case PF_Environment & PF_Blending: + pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + break; + case PF_Multiplicative & PF_Blending: + pglBlendFunc(GL_DST_COLOR, GL_ZERO); + break; + case PF_Fog & PF_Fog: + // Sryder: Fog + // multiplies input colour by input alpha, and destination colour by input colour, then adds them + pglBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR); + break; + default: // must be 0, otherwise it's an error + // No blending + pglBlendFunc(GL_ONE, GL_ZERO); // the same as no blending + break; + } + + // Set blending equation + switch (flags) + { + case PF_Subtractive & PF_Blending: + SetBlendEquation(GL_FUNC_SUBTRACT); + break; + case PF_ReverseSubtract & PF_Blending: + // good for shadow + // not really but what else ? + SetBlendEquation(GL_FUNC_REVERSE_SUBTRACT); + break; + default: + SetBlendEquation(GL_FUNC_ADD); + break; + } + + // Alpha test + switch (flags) + { + case PF_Masked & PF_Blending: + pglAlphaFunc(GL_GREATER, 0.5f); + break; + case PF_Translucent & PF_Blending: + case PF_Additive & PF_Blending: + case PF_Subtractive & PF_Blending: + case PF_ReverseSubtract & PF_Blending: + case PF_Environment & PF_Blending: + case PF_Multiplicative & PF_Blending: + pglAlphaFunc(GL_NOTEQUAL, 0.0f); + break; + case PF_Fog & PF_Fog: + pglAlphaFunc(GL_ALWAYS, 0.0f); // Don't discard zero alpha fragments + break; + default: + pglAlphaFunc(GL_GREATER, 0.5f); + break; + } +} + EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) { FBITFIELD Xor; Xor = CurrentPolyFlags^PolyFlags; - if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Invisible|PF_NoAlphaTest)) + if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Invisible)) { - if (Xor&(PF_Blending)) // if blending mode must be changed - { - switch (PolyFlags & PF_Blending) { - case PF_Translucent & PF_Blending: - pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case PF_Masked & PF_Blending: - // Hurdler: does that mean lighting is only made by alpha src? - // it sounds ok, but not for polygonsmooth - pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); // 0 alpha = holes in texture - pglAlphaFunc(GL_GREATER, 0.5f); - break; - case PF_Additive & PF_Blending: - pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case PF_Environment & PF_Blending: - pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case PF_Substractive & PF_Blending: - // good for shadow - // not really but what else ? - pglBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case PF_Fog & PF_Fog: - // Sryder: Fog - // multiplies input colour by input alpha, and destination colour by input colour, then adds them - pglBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR); - pglAlphaFunc(GL_ALWAYS, 0.0f); // Don't discard zero alpha fragments - break; - default : // must be 0, otherwise it's an error - // No blending - pglBlendFunc(GL_ONE, GL_ZERO); // the same as no blending - pglAlphaFunc(GL_GREATER, 0.5f); - break; - } - } + if (Xor & PF_Blending) // if blending mode must be changed + SetBlendMode(PolyFlags & PF_Blending); + if (Xor & PF_NoAlphaTest) { if (PolyFlags & PF_NoAlphaTest) @@ -1472,7 +1521,8 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) else pglDisable(GL_POLYGON_OFFSET_FILL); } - if (Xor&PF_NoDepthTest) + + if (Xor & PF_NoDepthTest) { if (PolyFlags & PF_NoDepthTest) pglDepthFunc(GL_ALWAYS); //pglDisable(GL_DEPTH_TEST); @@ -1480,25 +1530,25 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) pglDepthFunc(GL_LEQUAL); //pglEnable(GL_DEPTH_TEST); } - if (Xor&PF_RemoveYWrap) + if (Xor & PF_RemoveYWrap) { if (PolyFlags & PF_RemoveYWrap) Clamp2D(GL_TEXTURE_WRAP_T); } - if (Xor&PF_ForceWrapX) + if (Xor & PF_ForceWrapX) { if (PolyFlags & PF_ForceWrapX) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); } - if (Xor&PF_ForceWrapY) + if (Xor & PF_ForceWrapY) { if (PolyFlags & PF_ForceWrapY) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } - if (Xor&PF_Modulated) + if (Xor & PF_Modulated) { #if defined (__unix__) || defined (UNIXCOMMON) if (oglflags & GLF_NOTEXENV) @@ -2721,14 +2771,11 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float poly.green = byte2float[Surface->PolyColor.s.green]; poly.blue = byte2float[Surface->PolyColor.s.blue]; poly.alpha = byte2float[Surface->PolyColor.s.alpha]; - - if (poly.alpha < 1) - SetBlend(PF_Translucent|PF_Modulated); - else - SetBlend(PF_Masked|PF_Modulated|PF_Occlude); - + pglColor4ubv((GLubyte*)&Surface->PolyColor.s); + SetBlend((poly.alpha < 1 ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated); + tint.red = byte2float[Surface->TintColor.s.red]; tint.green = byte2float[Surface->TintColor.s.green]; tint.blue = byte2float[Surface->TintColor.s.blue]; diff --git a/src/k_kart.c b/src/k_kart.c index c27ffec4c..15b649dac 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8851,10 +8851,10 @@ static void K_drawKartSpeedometer(void) if (K_UseColorHud() && xtra_speedo_clr3) //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((SPDM_X-1)<patch = patch; item->flags = flags; item->colormap = colormap; + item->blend = blend; } void LUA_HUD_AddDrawScaled( @@ -366,7 +369,8 @@ void LUA_HUD_AddDrawScaled( fixed_t scale, patch_t *patch, INT32 flags, - UINT8 *colormap + UINT8 *colormap, + INT32 blend ) { size_t i = AllocateDrawItem(list); @@ -379,6 +383,7 @@ void LUA_HUD_AddDrawScaled( item->patch = patch; item->flags = flags; item->colormap = colormap; + item->blend = blend; } void LUA_HUD_AddDrawStretched( @@ -389,7 +394,8 @@ void LUA_HUD_AddDrawStretched( fixed_t vscale, patch_t *patch, INT32 flags, - UINT8 *colormap + UINT8 *colormap, + INT32 blend ) { size_t i = AllocateDrawItem(list); @@ -403,6 +409,7 @@ void LUA_HUD_AddDrawStretched( item->patch = patch; item->flags = flags; item->colormap = colormap; + item->blend = blend; } void LUA_HUD_AddDrawNum( @@ -634,17 +641,17 @@ void LUA_HUD_DrawList(huddrawlist_h list) case DI_Draw: if (!item->patch || item->patch == NULL) return; - V_DrawFixedPatch(LERPS(x), LERPS(y), FRACUNIT, item->flags, item->patch, item->colormap); + V_DrawBlendingFixedPatch(LERPS(x), LERPS(y), FRACUNIT, item->flags, item->patch, item->colormap, item->blend); break; case DI_DrawScaled: if (!item->patch || item->patch == NULL) return; - V_DrawFixedPatch(LERPS(x), LERPS(y), LERP(scale), item->flags, item->patch, item->colormap); + V_DrawBlendingFixedPatch(LERPS(x), LERPS(y), LERP(scale), item->flags, item->patch, item->colormap, item->blend); break; case DI_DrawStretched: if (!item->patch || item->patch == NULL) return; - V_DrawStretchyFixedPatch(LERPS(x), LERPS(y), LERP(hscale), LERP(vscale), item->flags, item->patch, item->colormap); + V_DrawStretchyFixedPatch(LERPS(x), LERPS(y), LERP(hscale), LERP(vscale), item->flags, item->patch, item->colormap, item->blend); break; case DI_DrawNum: V_DrawTallNum(LERPS(x), LERPS(y), item->flags, item->num); diff --git a/src/lua_hudlib_drawlist.h b/src/lua_hudlib_drawlist.h index 4354b6f95..4d19bcae2 100644 --- a/src/lua_hudlib_drawlist.h +++ b/src/lua_hudlib_drawlist.h @@ -40,7 +40,8 @@ void LUA_HUD_AddDraw( INT32 y, patch_t *patch, INT32 flags, - UINT8 *colormap + UINT8 *colormap, + INT32 blend ); void LUA_HUD_AddDrawStretched( huddrawlist_h list, @@ -50,7 +51,8 @@ void LUA_HUD_AddDrawStretched( fixed_t vscale, patch_t *patch, INT32 flags, - UINT8 *colormap + UINT8 *colormap, + INT32 blend ); void LUA_HUD_AddDrawScaled( huddrawlist_h list, @@ -59,7 +61,8 @@ void LUA_HUD_AddDrawScaled( fixed_t scale, patch_t *patch, INT32 flags, - UINT8 *colormap + UINT8 *colormap, + INT32 blend ); void LUA_HUD_AddDrawNum( huddrawlist_h list, diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 7385cccf6..13b3a1286 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -52,6 +52,7 @@ int mobj_skin_setter(lua_State *L); int mobj_localskin_getter(lua_State *L); int mobj_localskin_setter(lua_State *L); int mobj_color_setter(lua_State *L); +int mobj_blendmode_setter(lua_State *L); int mobj_bnext_noset(lua_State *L); int mobj_bprev_unimplemented(lua_State *L); int mobj_hnext_setter(lua_State *L); @@ -114,6 +115,7 @@ static const udata_field_t mobj_fields[] = { FIELD(mobj_t, skin, mobj_skin_getter, mobj_skin_setter), FIELD(mobj_t, localskin, mobj_localskin_getter, mobj_localskin_setter), FIELD(mobj_t, color, udatalib_getter_uint8, mobj_color_setter), + FIELD(mobj_t, blendmode, udatalib_getter_int32, mobj_blendmode_setter), FIELD(mobj_t, bnext, udatalib_getter_mobj, mobj_bnext_noset), FIELD(mobj_t, bprev, mobj_bprev_unimplemented, mobj_bprev_unimplemented), FIELD(mobj_t, hnext, udatalib_getter_mobj, mobj_hnext_setter), @@ -476,6 +478,18 @@ int mobj_color_setter(lua_State *L) return 0; } +int mobj_blendmode_setter(lua_State *L) +{ + mobj_t *mo = GETMO(); + + INT32 blendmode = (INT32)luaL_checkinteger(L, 2); + if (blendmode < 0 || blendmode > AST_OVERLAY) + return luaL_error(L, "mobj.blendmode %d out of range (0 - %d).", blendmode, AST_OVERLAY); + mo->blendmode = blendmode; + + return 0; +} + int mobj_hnext_setter(lua_State *L) { mobj_t *mo = GETMO(); diff --git a/src/m_anigif.c b/src/m_anigif.c index 44b5a96c0..05b1f8287 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -32,6 +32,7 @@ consvar_t cv_gif_downscale = {"gif_downscale", "On", CV_SAVE, CV_OnOff, NULL, 0 #ifdef HAVE_ANIGIF static boolean gif_optimize = false; // So nobody can do something dumb static boolean gif_downscale = false; // like changing cvars mid output +static RGBA_t *gif_palette = NULL; static FILE *gif_out = NULL; static INT32 gif_frames = 0; @@ -461,13 +462,15 @@ static size_t gifframe_size = 8192; // converts an RGB frame to a frame with a palette. // #ifdef HWRENDER +static colorlookup_t gif_colorlookup; + static void GIF_rgbconvert(UINT8 *linear, UINT8 *scr) { UINT8 r, g, b; size_t src, dest; int x, y; - InitColorLUT(); + InitColorLUT(&gif_colorlookup, gif_palette, true); for (x = 0; x < vid.width; x += scrbuf_downscaleamt) { @@ -479,7 +482,7 @@ static void GIF_rgbconvert(UINT8 *linear, UINT8 *scr) r = (UINT8)linear[src]; g = (UINT8)linear[src + 1]; b = (UINT8)linear[src + 2]; - scr[dest] = colorlookup[r >> SHIFTCOLORBITS][g >> SHIFTCOLORBITS][b >> SHIFTCOLORBITS]; + scr[dest] = GetColorLUTDirect(&gif_colorlookup, r, g, b); } } } @@ -636,6 +639,10 @@ INT32 GIF_open(const char *filename) gif_optimize = (!!cv_gif_optimize.value); gif_downscale = (!!cv_gif_downscale.value); + + // no master palettes in SRB2Kart land + gif_palette = pLocalPalette; + GIF_headwrite(); gif_frames = 0; return 1; diff --git a/src/p_mobj.c b/src/p_mobj.c index ad296c576..a916190a9 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9413,6 +9413,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) } // Sprite rendering + mobj->blendmode = AST_TRANSLUCENT; mobj->realxscale = mobj->realyscale = mobj->scale; mobj->spritexscale = mobj->realxscale; mobj->spriteyscale = mobj->realyscale; diff --git a/src/p_mobj.h b/src/p_mobj.h index cd7c64dc1..2aecf73b5 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -289,6 +289,7 @@ typedef struct mobj_s UINT32 frame; // frame number, plus bits see p_pspr.h UINT16 anim_duration; // for FF_ANIMATE states + INT32 blendmode; // blend mode fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; @@ -441,6 +442,7 @@ typedef struct precipmobj_s UINT32 frame; // frame number, plus bits see p_pspr.h UINT16 anim_duration; // for FF_ANIMATE states + INT32 blendmode; // blend mode fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; diff --git a/src/p_pspr.h b/src/p_pspr.h index 5ac1d1d84..90cfc40fc 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -41,10 +41,18 @@ #define FF_HORIZONTALFLIP 0x400 /// \brief Frame flags: Thin, paper-like sprite (for collision equivalent, see MF_PAPERCOLLISION) #define FF_PAPERSPRITE 0x800 -/// \brief Frame flags: Simple stateless animation -#define FF_ANIMATE 0x4000 -/// \brief Frame flags: frame always appears full bright -#define FF_FULLBRIGHT 0x8000 + +/// \brief Frame flags: blend types +#define FF_BLENDMASK 0x7000 +/// \brief shift for FF_BLENDMASK +#define FF_BLENDSHIFT 12 +/// \brief preshifted blend flags minus 1 as effects don't distinguish between AST_COPY and AST_TRANSLUCENT +#define FF_ADD ((AST_ADD-1)<mirrored = 0; // Sprite Rendering stuff + mobj->blendmode = AST_TRANSLUCENT; mobj->spritexoffset = 0; mobj->spriteyoffset = 0; mobj->spritexscale = FRACUNIT; diff --git a/src/r_data.c b/src/r_data.c index 98431510d..b88554c9f 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -126,6 +126,113 @@ size_t flatmemory, spritememory, texturememory; // gotta play by 2.2 rules to ge INT16 color8to16[256]; // remap color index to highcolor rgb value INT16 *hicolormaps; // test a 32k colormap remaps high -> high +// Blends two pixels together, using the equation +// that matches the specified alpha style. +UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha) +{ + RGBA_t output; + INT16 fullalpha = (alpha - (0xFF - foreground.s.alpha)); + if (style == AST_TRANSLUCENT) + { + if (fullalpha <= 0) + output.rgba = background.rgba; + else + { + // don't go too high + if (fullalpha >= 0xFF) + fullalpha = 0xFF; + alpha = (UINT8)fullalpha; + + // if the background pixel is empty, + // match software and don't blend anything + if (!background.s.alpha) + { + // ...unless the foreground pixel ISN'T actually translucent. + if (alpha == 0xFF) + output.rgba = foreground.rgba; + else + output.rgba = 0; + } + else + { + UINT8 beta = (0xFF - alpha); + output.s.red = ((background.s.red * beta) + (foreground.s.red * alpha)) / 0xFF; + output.s.green = ((background.s.green * beta) + (foreground.s.green * alpha)) / 0xFF; + output.s.blue = ((background.s.blue * beta) + (foreground.s.blue * alpha)) / 0xFF; + output.s.alpha = 0xFF; + } + } + return output.rgba; + } +#define clamp(c) max(min(c, 0xFF), 0x00); + else + { + float falpha = ((float)alpha / 256.0f); + float fr = ((float)foreground.s.red * falpha); + float fg = ((float)foreground.s.green * falpha); + float fb = ((float)foreground.s.blue * falpha); + if (style == AST_ADD) + { + output.s.red = clamp((int)(background.s.red + fr)); + output.s.green = clamp((int)(background.s.green + fg)); + output.s.blue = clamp((int)(background.s.blue + fb)); + } + else if (style == AST_SUBTRACT) + { + output.s.red = clamp((int)(background.s.red - fr)); + output.s.green = clamp((int)(background.s.green - fg)); + output.s.blue = clamp((int)(background.s.blue - fb)); + } + else if (style == AST_REVERSESUBTRACT) + { + output.s.red = clamp((int)((-background.s.red) + fr)); + output.s.green = clamp((int)((-background.s.green) + fg)); + output.s.blue = clamp((int)((-background.s.blue) + fb)); + } + else if (style == AST_MODULATE) + { + fr = ((float)foreground.s.red / 256.0f); + fg = ((float)foreground.s.green / 256.0f); + fb = ((float)foreground.s.blue / 256.0f); + output.s.red = clamp((int)(background.s.red * fr)); + output.s.green = clamp((int)(background.s.green * fg)); + output.s.blue = clamp((int)(background.s.blue * fb)); + } + // just copy the pixel + else if (style == AST_COPY) + output.rgba = foreground.rgba; + + output.s.alpha = 0xFF; + return output.rgba; + } +#undef clamp + return 0; +} + +INT32 ASTTextureBlendingThreshold[2] = {255/11, (10*255/11)}; + +// Blends a pixel for a texture patch. +UINT32 ASTBlendTexturePixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha) +{ + // Alpha style set to translucent? + if (style == AST_TRANSLUCENT) + { + // Is the alpha small enough for translucency? + if (alpha <= ASTTextureBlendingThreshold[1]) + { + // Is the patch way too translucent? Don't blend then. + if (alpha < ASTTextureBlendingThreshold[0]) + return background.rgba; + + return ASTBlendPixel(background, foreground, style, alpha); + } + else // just copy the pixel + return foreground.rgba; + } + else + return ASTBlendPixel(background, foreground, style, alpha); +} + // Painfully simple texture id cacheing to make maps load faster. :3 static struct { char name[9]; diff --git a/src/r_data.h b/src/r_data.h index ec1146322..f27dd0822 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -56,6 +56,9 @@ extern INT32 *texturewidthmask; extern fixed_t *textureheight; // needed for texture pegging +UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha); +UINT32 ASTBlendTexturePixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha); + extern INT16 color8to16[256]; // remap color index to highcolor extern INT16 *hicolormaps; // remap high colors to high colors.. diff --git a/src/r_defs.h b/src/r_defs.h index bc95649bb..7c063505c 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -687,6 +687,9 @@ typedef struct #pragma pack() #endif +// Possible alpha types for a patch. +enum patchalphastyle {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY}; + typedef enum { SRF_SINGLE = 0, // 0-angle for all rotations diff --git a/src/r_draw.c b/src/r_draw.c index faa9ba638..d41e542a5 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -86,6 +86,7 @@ INT32 dc_sourcelength; #define NUMTRANSTABLES 9 // how many translucency tables are used UINT8 *transtables; // translucency tables +UINT8 *blendtables[NUMBLENDMAPS]; /** \brief R_DrawTransColumn uses this */ @@ -213,11 +214,11 @@ const UINT8 Color_Opposite[MAXSKINCOLORS*2] = CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; -/** \brief The R_InitTranslationTables +#define TRANSTAB_AMTMUL10 (256.0f / 10.0f) - load in color translation tables +/** \brief Initializes the translucency tables used by the Software renderer. */ -void R_InitTranslationTables(void) +void R_InitTranslucencyTables(void) { // Load here the transparency lookup tables 'TINTTAB' // NOTE: the TINTTAB resource MUST BE aligned on 64k for the asm @@ -234,6 +235,189 @@ void R_InitTranslationTables(void) W_ReadLump(W_GetNumForName("TRANS70"), transtables+0x60000); W_ReadLump(W_GetNumForName("TRANS80"), transtables+0x70000); W_ReadLump(W_GetNumForName("TRANS90"), transtables+0x80000); + + R_GenerateBlendTables(); +} + +static colorlookup_t transtab_lut; + +static void BlendTab_Translucent(UINT8 *table, int style, UINT8 blendamt) +{ + INT16 bg, fg; + + if (table == NULL) + I_Error("BlendTab_Translucent: input table was NULL!"); + + for (bg = 0; bg < 0xFF; bg++) + { + for (fg = 0; fg < 0xFF; fg++) + { + RGBA_t backrgba = V_GetColor(bg); + RGBA_t frontrgba = V_GetColor(fg); + RGBA_t result; + + result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); + result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt); + + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); + } + } +} + +static void BlendTab_Subtractive(UINT8 *table, int style, UINT8 blendamt) +{ + INT16 bg, fg; + + if (table == NULL) + I_Error("BlendTab_Subtractive: input table was NULL!"); + + if (blendamt == 0xFF) + { + memset(table, GetColorLUT(&transtab_lut, 0, 0, 0), 0x10000); + return; + } + + for (bg = 0; bg < 0xFF; bg++) + { + for (fg = 0; fg < 0xFF; fg++) + { + RGBA_t backrgba = V_GetColor(bg); + RGBA_t frontrgba = V_GetColor(fg); + RGBA_t result; + + result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); + result.s.red = max(0, result.s.red - blendamt); + result.s.green = max(0, result.s.green - blendamt); + result.s.blue = max(0, result.s.blue - blendamt); + + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); + } + } +} + +static void BlendTab_Modulative(UINT8 *table) +{ + INT16 bg, fg; + + if (table == NULL) + I_Error("BlendTab_Modulative: input table was NULL!"); + + for (bg = 0; bg < 0xFF; bg++) + { + for (fg = 0; fg < 0xFF; fg++) + { + RGBA_t backrgba = V_GetColor(bg); + RGBA_t frontrgba = V_GetColor(fg); + RGBA_t result; + result.rgba = ASTBlendPixel(backrgba, frontrgba, AST_MODULATE, 0); + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); + } + } +} + +static INT32 BlendTab_Count[NUMBLENDMAPS] = +{ + NUMTRANSTABLES, // blendtab_add + NUMTRANSTABLES+1, // blendtab_subtract + NUMTRANSTABLES+1, // blendtab_reversesubtract + 1 // blendtab_modulate +}; + +static INT32 BlendTab_FromStyle[] = +{ + 0, // AST_COPY + 0, // AST_TRANSLUCENT + blendtab_add, // AST_ADD + blendtab_subtract, // AST_SUBTRACT + blendtab_reversesubtract, // AST_REVERSESUBTRACT + blendtab_modulate, // AST_MODULATE + 0 // AST_OVERLAY +}; + +static void BlendTab_GenerateMaps(INT32 tab, INT32 style, void (*genfunc)(UINT8 *, int, UINT8)) +{ + INT32 i = 0, num = BlendTab_Count[tab]; + const float amtmul = (256.0f / (float)(NUMTRANSTABLES)); + for (; i < num; i++) + { + const size_t offs = (0x10000 * i); + const UINT16 alpha = min(amtmul * i, 0xFF); + genfunc(blendtables[tab] + offs, style, alpha); + } +} + +void R_GenerateBlendTables(void) +{ + INT32 i; + + for (i = 0; i < NUMBLENDMAPS; i++) + blendtables[i] = Z_MallocAlign(BlendTab_Count[i] * 0x10000, PU_STATIC, NULL, 16); + + InitColorLUT(&transtab_lut, pLocalPalette, false); + + // Additive + BlendTab_GenerateMaps(blendtab_add, AST_ADD, BlendTab_Translucent); + + // Subtractive +#if 1 + BlendTab_GenerateMaps(blendtab_subtract, AST_SUBTRACT, BlendTab_Subtractive); +#else + BlendTab_GenerateMaps(blendtab_subtract, AST_SUBTRACT, BlendTab_Translucent); +#endif + + // Reverse subtractive + BlendTab_GenerateMaps(blendtab_reversesubtract, AST_REVERSESUBTRACT, BlendTab_Translucent); + + // Modulative blending only requires a single table + BlendTab_Modulative(blendtables[blendtab_modulate]); +} + +#define ClipBlendLevel(style, trans) max(min((trans), BlendTab_Count[BlendTab_FromStyle[style]]-1), 0) +#define ClipTransLevel(trans) max(min((trans), NUMTRANSMAPS-2), 0) + +UINT8 *R_GetTranslucencyTable(INT32 alphalevel) +{ + return transtables + (ClipTransLevel(alphalevel-1) << FF_TRANSSHIFT); +} + +UINT8 *R_GetBlendTable(int style, INT32 alphalevel) +{ + size_t offs; + + if (style == AST_COPY || style == AST_OVERLAY) + return NULL; + + offs = (ClipBlendLevel(style, alphalevel) << FF_TRANSSHIFT); + + // Lactozilla: Returns the equivalent to AST_TRANSLUCENT + // if no alpha style matches any of the blend tables. + switch (style) + { + case AST_ADD: + return blendtables[blendtab_add] + offs; + case AST_SUBTRACT: + return blendtables[blendtab_subtract] + offs; + case AST_REVERSESUBTRACT: + return blendtables[blendtab_reversesubtract] + offs; + case AST_MODULATE: + return blendtables[blendtab_modulate]; + default: + break; + } + + // Return a normal translucency table + if (--alphalevel >= 0) + return transtables + (ClipTransLevel(alphalevel) << FF_TRANSSHIFT); + else + return NULL; +} + +boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel) +{ + if (blendmode == AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode == AST_OVERLAY) + return true; + + return (alphalevel < BlendTab_Count[BlendTab_FromStyle[blendmode]]); } /** \brief Retrieves a translation colormap from the cache. diff --git a/src/r_draw.h b/src/r_draw.h index 7dbeda7c9..39587a696 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -40,7 +40,6 @@ extern UINT8 dc_hires; extern UINT8 *dc_source; // first pixel in a column // translucency stuff here -extern UINT8 *transtables; // translucency tables, should be (*transtables)[5][256][256] extern UINT8 *dc_transmap; // translation stuff here @@ -117,7 +116,6 @@ extern lumpnum_t viewborderlump[8]; #define TC_BLINK -6 // For item blinking // Initialize color translation tables, for player rendering etc. -void R_InitTranslationTables(void); UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags); UINT8* R_GetLocalTranslationColormap(skin_t *skin, skin_t *localskin, skincolors_t color, UINT8 flags, boolean local); patch_t* R_GetSkinFaceRank(player_t* ply); @@ -126,6 +124,27 @@ patch_t* R_GetSkinFaceMini(player_t* ply); void R_FlushTranslationColormapCache(void); UINT8 R_GetColorByName(const char *name); +extern UINT8 *transtables; // translucency tables, should be (*transtables)[5][256][256] + +enum +{ + blendtab_add, + blendtab_subtract, + blendtab_reversesubtract, + blendtab_modulate, + NUMBLENDMAPS +}; + +extern UINT8 *blendtables[NUMBLENDMAPS]; + +void R_InitTranslucencyTables(void); +void R_GenerateBlendTables(void); + +UINT8 *R_GetTranslucencyTable(INT32 alphalevel); +UINT8 *R_GetBlendTable(int style, INT32 alphalevel); + +boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel); + // Custom player skin translation void R_InitViewBuffer(INT32 width, INT32 height); void R_InitViewBorder(void); diff --git a/src/r_main.c b/src/r_main.c index 1c45d4112..9c90e108f 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1036,8 +1036,8 @@ void R_Init(void) //I_OutputMsg("\nR_InitLightTables"); R_InitLightTables(); - //I_OutputMsg("\nR_InitTranslationTables\n"); - R_InitTranslationTables(); + //I_OutputMsg("\nR_InitTranslucencyTables\n"); + R_InitTranslucencyTables(); R_InitDrawNodes(); diff --git a/src/r_plane.c b/src/r_plane.c index d8d77457f..9b13bb062 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -796,7 +796,7 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->polyobj->translucency >= 10) return; // Don't even draw it else if (pl->polyobj->translucency > 0) - ds_transmap = transtables + ((pl->polyobj->translucency-1)<polyobj->translucency); else // Opaque, but allow transparent flat pixels spanfunc = splatfunc; @@ -836,23 +836,23 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->ffloor->alpha < 12) return; // Don't even draw it else if (pl->ffloor->alpha < 38) - ds_transmap = transtables + ((tr_trans90-1)<ffloor->alpha < 64) - ds_transmap = transtables + ((tr_trans80-1)<ffloor->alpha < 89) - ds_transmap = transtables + ((tr_trans70-1)<ffloor->alpha < 115) - ds_transmap = transtables + ((tr_trans60-1)<ffloor->alpha < 140) - ds_transmap = transtables + ((tr_trans50-1)<ffloor->alpha < 166) - ds_transmap = transtables + ((tr_trans40-1)<ffloor->alpha < 192) - ds_transmap = transtables + ((tr_trans30-1)<ffloor->alpha < 217) - ds_transmap = transtables + ((tr_trans20-1)<ffloor->alpha < 243) - ds_transmap = transtables + ((tr_trans10-1)<special-900)<special-899)); colfunc = fuzzcolfunc; break; case 909: @@ -343,7 +343,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (curline->polyseg->translucency >= NUMTRANSMAPS) return; - dc_transmap = transtables + ((curline->polyseg->translucency-1)<polyseg->translucency); colfunc = fuzzcolfunc; } @@ -714,23 +714,23 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (pfloor->alpha < 12) return; // Don't even draw it else if (pfloor->alpha < 38) - dc_transmap = transtables + ((tr_trans90-1)<alpha < 64) - dc_transmap = transtables + ((tr_trans80-1)<alpha < 89) - dc_transmap = transtables + ((tr_trans70-1)<alpha < 115) - dc_transmap = transtables + ((tr_trans60-1)<alpha < 140) - dc_transmap = transtables + ((tr_trans50-1)<alpha < 166) - dc_transmap = transtables + ((tr_trans40-1)<alpha < 192) - dc_transmap = transtables + ((tr_trans30-1)<alpha < 217) - dc_transmap = transtables + ((tr_trans20-1)<alpha < 243) - dc_transmap = transtables + ((tr_trans10-1)<extra_colormap = sector->lightlist[i].extra_colormap; - if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) + if (!((newsprite->cut & SC_FULLBRIGHT) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) { lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); @@ -1040,6 +1040,9 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) // Mitigate against negative xscale and arithmetic overflow lindex = CLAMP(lindex, 0, MAXLIGHTSCALE - 1); + if (newsprite->cut & SC_SEMIBRIGHT) + lindex = (MAXLIGHTSCALE/2) + (lindex >>1); + newsprite->colormap = spritelights[lindex]; } } @@ -1138,6 +1141,7 @@ static void R_ProjectSprite(mobj_t *thing) boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); INT32 lindex; + INT32 trans; vissprite_t *vis; @@ -1535,6 +1539,24 @@ static void R_ProjectSprite(mobj_t *thing) return; } + INT32 blendmode; + if (oldthing->frame & FF_BLENDMASK) + blendmode = ((oldthing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = oldthing->blendmode; + + // Determine the translucency value. + if (oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility) + trans = tr_trans80; // because now the translucency is set through FF_TRANSMASK + else if (oldthing->frame & FF_TRANSMASK) + { + trans = (oldthing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT; + if (!R_BlendLevelVisible(blendmode, trans)) + return; + } + else + trans = 0; + //SoM: 3/17/2000: Disregard sprites that are out of view.. if (thing->eflags & MFE_VERTICALFLIP) { @@ -1661,6 +1683,18 @@ static void R_ProjectSprite(mobj_t *thing) vis->scale += FixedMul(scalestep, spriteyscale) * (vis->x1 - x1); } + if ((blendmode != AST_COPY) && cv_translucency.value) + vis->transmap = R_GetBlendTable(blendmode, trans); + else + vis->transmap = NULL; + + if (R_ThingIsFullBright(oldthing) || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) + vis->cut |= SC_FULLBRIGHT; + else if (R_ThingIsSemiBright(oldthing)) + vis->cut |= SC_SEMIBRIGHT; + else if (R_ThingIsFullDark(oldthing)) + vis->cut |= SC_FULLDARK; + //Fab: lumppat is the lump number of the patch to use, this is different // than lumpid for sprites-in-pwad : the graphics are patched #ifdef ROTSPRITE @@ -1670,25 +1704,18 @@ static void R_ProjectSprite(mobj_t *thing) #endif vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); -// -// determine the colormap (lightlevel & special effects) -// - vis->transmap = NULL; + // + // determine the colormap (lightlevel & special effects) + // - // specific translucency - if (!cv_translucency.value) - ; // no translucency - else if (thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility) - vis->transmap = transtables + ((tr_trans80-1)<frame & FF_TRANSMASK) - vis->transmap = transtables + (thing->frame & FF_TRANSMASK) - 0x10000; - - if (((thing->frame & FF_FULLBRIGHT) || (thing->flags2 & MF2_SHADOW)) + if ((vis->cut & SC_FULLBRIGHT) && (!vis->extra_colormap || !(vis->extra_colormap->fog & 1))) { // full bright: goggles vis->colormap = colormaps; } + else if (vis->cut & SC_FULLDARK) + vis->colormap = scalelight[0][0]; else { // diminished light @@ -1697,6 +1724,9 @@ static void R_ProjectSprite(mobj_t *thing) // Mitigate against negative xscale and arithmetic overflow lindex = CLAMP(lindex, 0, MAXLIGHTSCALE - 1); + if (vis->cut & SC_SEMIBRIGHT) + lindex = (MAXLIGHTSCALE/2) + (lindex >> 1); + vis->colormap = spritelights[lindex]; } @@ -1738,6 +1768,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) fixed_t this_scale; INT32 dist = 1; + INT32 trans; if (cv_maxinterpdist.value) dist = R_QuickCamDist(thing->x, thing->y); @@ -1838,6 +1869,12 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; } + // Determine the translucency value. + if (thing->frame & FF_TRANSMASK) + trans = (thing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT; + else + trans = 0; + //SoM: 3/17/2000: Disregard sprites that are out of view.. gzt = interp.z + FixedMul(spritecachedinfo[lump].topoffset, this_scale); gz = gzt - FixedMul(spritecachedinfo[lump].height, this_scale); @@ -1886,8 +1923,8 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); // specific translucency - if (thing->frame & FF_TRANSMASK) - vis->transmap = (thing->frame & FF_TRANSMASK) - 0x10000 + transtables; + if ((thing->blendmode != AST_COPY) && cv_translucency.value) + vis->transmap = R_GetTranslucencyTable((thing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT); else vis->transmap = NULL; @@ -2788,6 +2825,21 @@ boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist) return true; } +boolean R_ThingIsFullBright(mobj_t *thing) +{ + return ((thing->frame & FF_BRIGHTMASK) == FF_FULLBRIGHT); +} + +boolean R_ThingIsSemiBright(mobj_t *thing) +{ + return ((thing->frame & FF_BRIGHTMASK) == FF_SEMIBRIGHT); +} + +boolean R_ThingIsFullDark(mobj_t *thing) +{ + return ((thing->frame & FF_BRIGHTMASK) == FF_FULLDARK); +} + // // R_DrawMasked // diff --git a/src/r_things.h b/src/r_things.h index 898cc7ecd..899400598 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -76,6 +76,10 @@ void R_DrawMasked(void); boolean R_ThingVisible (mobj_t *thing); boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist); +boolean R_ThingIsFullBright (mobj_t *thing); +boolean R_ThingIsSemiBright (mobj_t *thing); +boolean R_ThingIsFullDark (mobj_t *thing); + // ----------- // SKINS STUFF // ----------- @@ -128,6 +132,9 @@ typedef enum SC_BOTTOM = 2, SC_VFLIP = 3, SC_NOTVISIBLE = 4, + SC_FULLBRIGHT = 8, + SC_SEMIBRIGHT = 16, + SC_FULLDARK = 32, SC_CUTMASK = SC_TOP|SC_BOTTOM|SC_NOTVISIBLE, SC_FLAGMASK = ~SC_CUTMASK } spritecut_e; diff --git a/src/v_video.c b/src/v_video.c index d2604b5e8..02a37798e 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -635,10 +635,11 @@ static inline UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fix } // Draws a patch scaled to arbitrary size. -void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap) +void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap, INT32 bflags) { UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); - UINT32 alphalevel = 0; + UINT32 alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT32 blendmode = ((bflags & V_BLENDMASK) >> V_BLENDSHIFT); fixed_t col, ofs, colfrac, rowfrac, fdup, vdup; INT32 dupx, dupy; @@ -655,7 +656,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca //if (rendermode != render_soft && !con_startup) // Why? if (rendermode == render_opengl) { - HWR_DrawStretchyFixedPatch((GLPatch_t *)patch, x, y, pscale, vscale, scrn, colormap); + HWR_DrawStretchyFixedPatch((GLPatch_t *)patch, x, y, pscale, vscale, scrn, colormap, bflags); return; } #endif @@ -663,7 +664,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca patchdrawfunc = standardpdraw; v_translevel = NULL; - if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) + if (alphalevel || blendmode) { if (alphalevel == 13) alphalevel = hudminusalpha[hudtrans]; @@ -675,9 +676,9 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (alphalevel >= 10) return; // invis - if (alphalevel) + if (alphalevel || blendmode) { - v_translevel = transtables + ((alphalevel-1)<init || memcmp(lut->palette, palette, palsize)) { - for (r = 0; r < CLUTSIZE; r++) - for (g = 0; g < CLUTSIZE; g++) - for (b = 0; b < CLUTSIZE; b++) - colorlookup[r][g][b] = NearestColor(r << SHIFTCOLORBITS, g << SHIFTCOLORBITS, b << SHIFTCOLORBITS); - clutinit = true; - lastpalette = pLocalPalette; + INT32 i; + + lut->init = true; + memcpy(lut->palette, palette, palsize); + + for (i = 0; i < 0xFFFF; i++) + lut->table[i] = 0xFFFF; + + if (makecolors) + { + UINT8 r, g, b; + + for (r = 0; r < 0xFF; r++) + for (g = 0; g < 0xFF; g++) + for (b = 0; b < 0xFF; b++) + { + i = CLUTINDEX(r, g, b); + if (lut->table[i] == 0xFFFF) + lut->table[i] = NearestPaletteColor(r, g, b, palette); + } + } } } +UINT8 GetColorLUT(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b) +{ + INT32 i = CLUTINDEX(r, g, b); + if (lut->table[i] == 0xFFFF) + lut->table[i] = NearestPaletteColor(r, g, b, lut->palette); + return lut->table[i]; +} + +UINT8 GetColorLUTDirect(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b) +{ + INT32 i = CLUTINDEX(r, g, b); + return lut->table[i]; +} + // V_Init // old software stuff, buffers are allocated at video mode setup // here we set the screens[x] pointers accordingly diff --git a/src/v_video.h b/src/v_video.h index a06760215..6b07bbb65 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -37,17 +37,19 @@ cv_rsaturation, cv_ysaturation, cv_gsaturation, cv_csaturation, cv_bsaturation, // Allocates buffer screens, call before R_Init. void V_Init(void); -// Taken from my videos-in-SRB2 project -// Generates a color look-up table -// which has up to 64 colors at each channel +// Color look-up table +#define CLUTINDEX(r, g, b) (((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3) -#define COLORBITS 6 -#define SHIFTCOLORBITS (8-COLORBITS) -#define CLUTSIZE (1< Date: Sun, 2 Feb 2025 21:14:48 -0500 Subject: [PATCH 331/418] Prelim: Linedef alpha variable realistically this was just because I'm Lazy this makes figuring out linedef blending less of a brain twister --- src/hardware/hw_main.c | 32 +++--------------------- src/lua_maplib.c | 5 ++++ src/p_setup.c | 13 ++++++++++ src/r_defs.h | 2 ++ src/r_segs.c | 56 ++++++++++++++++++++++++++---------------- src/r_segs.h | 1 + 6 files changed, 60 insertions(+), 49 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 1fd05d947..10d3c8c23 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1208,33 +1208,6 @@ static boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) // set alpha for transparent walls switch (gl_linedef->special) { - case 900: - blendmode = HWR_TranstableToAlpha(tr_trans10, pSurf); - break; - case 901: - blendmode = HWR_TranstableToAlpha(tr_trans20, pSurf); - break; - case 902: - blendmode = HWR_TranstableToAlpha(tr_trans30, pSurf); - break; - case 903: - blendmode = HWR_TranstableToAlpha(tr_trans40, pSurf); - break; - case 904: - blendmode = HWR_TranstableToAlpha(tr_trans50, pSurf); - break; - case 905: - blendmode = HWR_TranstableToAlpha(tr_trans60, pSurf); - break; - case 906: - blendmode = HWR_TranstableToAlpha(tr_trans70, pSurf); - break; - case 907: - blendmode = HWR_TranstableToAlpha(tr_trans80, pSurf); - break; - case 908: - blendmode = HWR_TranstableToAlpha(tr_trans90, pSurf); - break; // Translucent case 102: case 121: @@ -1255,7 +1228,10 @@ static boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) blendmode = PF_Translucent; break; default: - blendmode = PF_Masked; + if (gl_linedef->alpha > 0 && gl_linedef->alpha < FRACUNIT) + blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), pSurf); + else + blendmode = PF_Masked; break; } } diff --git a/src/lua_maplib.c b/src/lua_maplib.c index a6bca2ff6..c1442b98c 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -94,6 +94,7 @@ enum line_e { line_sidenum, line_frontside, line_backside, + line_alpha, line_slopetype, line_frontsector, line_backsector, @@ -115,6 +116,7 @@ static const char *const line_opt[] = { "sidenum", "frontside", "backside", + "alpha", "slopetype", "frontsector", "backsector", @@ -652,6 +654,9 @@ static int line_get(lua_State *L) return 0; LUA_PushUserdata(L, &sides[line->sidenum[1]], META_SIDE); return 1; + case line_alpha: + lua_pushfixed(L, line->alpha); + return 1; case line_slopetype: switch(line->slopetype) { diff --git a/src/p_setup.c b/src/p_setup.c index ce1dd6efb..751ba94f0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1071,6 +1071,8 @@ static void P_SetupLines(void) ld->dx = v2->x - v1->x; ld->dy = v2->y - v1->y; + ld->alpha = FRACUNIT; + if (!ld->dx) ld->slopetype = ST_VERTICAL; else if (!ld->dy) @@ -1177,6 +1179,17 @@ static void P_LoadLineDefs2(void) M_Memcpy(ld->text+strlen(ld->text)+1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text)+1); } break; + case 900: //Translucent wall (10%) + case 901: //Translucent wall (20%) + case 902: //Translucent wall (30%) + case 903: //Translucent wall (40%) + case 904: //Translucent wall (50%) + case 905: //Translucent wall (60%) + case 906: //Translucent wall (70%) + case 907: //Translucent wall (80%) + case 908: //Translucent wall (90%) + ld->alpha = ((909 - ld->special) << FRACBITS)/10; + break; } } } diff --git a/src/r_defs.h b/src/r_defs.h index 7c063505c..58cd0f1b1 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -402,6 +402,8 @@ typedef struct line_s // Visual appearance: sidedefs. UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided + fixed_t alpha; // translucency + UINT8 blendmode; // blendmode fixed_t bbox[4]; // bounding box for the extent of the linedef diff --git a/src/r_segs.c b/src/r_segs.c index 86a1ff1cf..b0cfc494e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -287,6 +287,28 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) } } +transnum_t R_GetLinedefTransTable(fixed_t alpha) +{ + if (alpha < 9830) + return tr_trans90; + else if (alpha < 16384) + return tr_trans80; + else if (alpha < 22937) + return tr_trans70; + else if (alpha < 29491) + return tr_trans60; + else if (alpha < 36044) + return tr_trans50; + else if (alpha < 42598) + return tr_trans40; + else if (alpha < 49152) + return tr_trans30; + else if (alpha < 55705) + return tr_trans20; + else + return tr_trans10; +} + void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) { size_t pindex; @@ -314,28 +336,20 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) // hack translucent linedef types (900-909 for transtables 1-9) ldef = curline->linedef; - switch (ldef->special) + if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) { - case 900: - case 901: - case 902: - case 903: - case 904: - case 905: - case 906: - case 907: - case 908: - dc_transmap = R_GetTranslucencyTable((ldef->special-899)); - colfunc = fuzzcolfunc; - break; - case 909: - colfunc = R_DrawFogColumn_8; - windowtop = frontsector->ceilingheight; - windowbottom = frontsector->floorheight; - break; - default: - colfunc = wallcolfunc; - break; + dc_transmap = transtables + ((R_GetLinedefTransTable(ldef->alpha) - 1) << FF_TRANSSHIFT); + colfunc = fuzzcolfunc; + } + else if (ldef->special == 909) + { + colfunc = R_DrawFogColumn_8; + windowtop = frontsector->ceilingheight; + windowbottom = frontsector->floorheight; + } + else + { + colfunc = wallcolfunc; } if (curline->polyseg && curline->polyseg->translucency > 0) diff --git a/src/r_segs.h b/src/r_segs.h index 92d0100e2..006e81279 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -18,6 +18,7 @@ #pragma interface #endif +transnum_t R_GetLinedefTransTable(fixed_t alpha); void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2); void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pffloor); void R_StoreWallRange(INT32 start, INT32 stop); From d39e9447f32463e3e51d09a3250024ed262c3734 Mon Sep 17 00:00:00 2001 From: Chearii Date: Mon, 3 Feb 2025 04:46:27 -0500 Subject: [PATCH 332/418] Add line and FOF blending, fix model and shadow blending also a bit of cleanup in r_things but it's too minor to headline --- src/hardware/hw_main.c | 51 +++++++++++++++++++++++++++++------------- src/hardware/hw_md2.c | 17 ++++++++++---- src/lua_maplib.c | 8 +++++++ src/p_mobj.c | 1 + src/p_setup.c | 38 ++++++++++++++++++++----------- src/p_spec.c | 22 ++++++++++++++++-- src/r_defs.h | 1 + src/r_plane.c | 33 +++++++++------------------ src/r_segs.c | 47 +++++++++++++++++++------------------- src/r_things.c | 7 ------ 10 files changed, 138 insertions(+), 87 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 10d3c8c23..ccd292cf3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1225,10 +1225,20 @@ static boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) case 221: case 253: case 256: - blendmode = PF_Translucent; + if (gl_linedef->blendmode) + blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf); + else + blendmode = PF_Translucent; break; default: - if (gl_linedef->alpha > 0 && gl_linedef->alpha < FRACUNIT) + if (gl_linedef->blendmode) + { + if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) + blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf); + else + blendmode = HWR_GetBlendModeFlag(gl_linedef->blendmode); + } + else if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), pSurf); else blendmode = PF_Masked; @@ -1777,7 +1787,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); if (gl_frontsector->numlights) + { HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0); + } else // I don't think that solid walls can use translucent linedef types... { if (glTex->mipmap.flags & TF_TRANSPARENT) @@ -1958,7 +1970,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gl_curline); if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } @@ -1966,14 +1978,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { FBITFIELD blendmode = PF_Masked; - if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - blendmode = PF_Translucent; + blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_frontsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -2073,7 +2085,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gl_curline); if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } @@ -2081,14 +2093,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { FBITFIELD blendmode = PF_Masked; - if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - blendmode = PF_Translucent; + blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_backsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -2797,6 +2809,13 @@ static inline void HWR_PortalSubsector(seg_t *line, subsector_t *sub, INT16 coun sub->validcount = validcount; } +static FBITFIELD HWR_RippleBlend(sector_t *sector, ffloor_t *rover, boolean ceiling) +{ + (void)sector; + (void)ceiling; + return /*R_IsRipplePlane(sector, rover, ceiling)*/ (rover->flags & FF_RIPPLE) ? PF_Ripple : 0; +} + // -----------------+ // HWR_Subsector : Determine floor/ceiling planes. // : Add sprites of things in sector. @@ -2981,7 +3000,7 @@ static void HWR_Subsector(size_t num) alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } - else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) // SoM: Flags are more efficient + else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient { light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); @@ -2990,7 +3009,7 @@ static void HWR_Subsector(size_t num) false, *rover->bottomheight, *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), false, gl_frontsector->lightlist[light].extra_colormap); } else @@ -2998,7 +3017,7 @@ static void HWR_Subsector(size_t num) HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gl_frontsector, false)); light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, + HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } } @@ -3027,7 +3046,7 @@ static void HWR_Subsector(size_t num) alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } - else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); @@ -3036,7 +3055,7 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), false, gl_frontsector->lightlist[light].extra_colormap); } else @@ -3044,7 +3063,7 @@ static void HWR_Subsector(size_t num) HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gl_frontsector, true)); light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, + HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } } diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 5622497dc..1130745aa 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1178,21 +1178,30 @@ void HWR_DrawMD2(gl_vissprite_t *spr) // Apparently people don't like jump frames like that, so back it goes //if (tics > durs) //durs = tics; + + INT32 blendmode; + if (spr->mobj->frame & FF_BLENDMASK) + blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = spr->mobj->blendmode; + + blendmode = min(AST_MODULATE, blendmode); if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - Surf.PolyFlags = HWR_GetBlendModeFlag(spr->mobj->blendmode); + Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) { HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); - Surf.PolyFlags = HWR_SurfaceBlend(spr->mobj->blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + Surf.PolyFlags = HWR_SurfaceBlend(blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); } else { - Surf.PolyColor.s.alpha = 0xFF; - Surf.PolyFlags = 0; + // this hack is dumb, but the blendmodes refuse to work otherwise + Surf.PolyColor.s.alpha = (blendmode == AST_TRANSLUCENT) ? 0xFF : 0xFE; + Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); } // dont forget to enabled the depth test because we can't do this like diff --git a/src/lua_maplib.c b/src/lua_maplib.c index c1442b98c..c4718ae90 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -188,6 +188,7 @@ enum ffloor_e { ffloor_next, ffloor_prev, ffloor_alpha, + ffloor_blend, }; static const char *const ffloor_opt[] = { @@ -206,6 +207,7 @@ static const char *const ffloor_opt[] = { "next", "prev", "alpha", + "blend", NULL}; static int ffloor_fields_ref = LUA_NOREF; @@ -1173,6 +1175,9 @@ static int ffloor_get(lua_State *L) case ffloor_alpha: lua_pushinteger(L, ffloor->alpha); return 1; + case ffloor_blend: + lua_pushinteger(L, ffloor->blend); + return 1; } return 0; } @@ -1251,6 +1256,9 @@ static int ffloor_set(lua_State *L) case ffloor_alpha: ffloor->alpha = (INT32)luaL_checkinteger(L, 3); break; + case ffloor_blend: + ffloor->blend = (INT32)luaL_checkinteger(L, 3); + break; } return 0; } diff --git a/src/p_mobj.c b/src/p_mobj.c index a916190a9..ed5f0a578 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9837,6 +9837,7 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) mobj->radius = info->radius; mobj->height = info->height; mobj->flags = info->flags; + mobj->blendmode = AST_TRANSLUCENT; mobj->health = info->spawnhealth; diff --git a/src/p_setup.c b/src/p_setup.c index 751ba94f0..124b57504 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1072,6 +1072,7 @@ static void P_SetupLines(void) ld->dy = v2->y - v1->y; ld->alpha = FRACUNIT; + ld->blendmode = 0; if (!ld->dx) ld->slopetype = ST_VERTICAL; @@ -1179,18 +1180,27 @@ static void P_LoadLineDefs2(void) M_Memcpy(ld->text+strlen(ld->text)+1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text)+1); } break; - case 900: //Translucent wall (10%) - case 901: //Translucent wall (20%) - case 902: //Translucent wall (30%) - case 903: //Translucent wall (40%) - case 904: //Translucent wall (50%) - case 905: //Translucent wall (60%) - case 906: //Translucent wall (70%) - case 907: //Translucent wall (80%) - case 908: //Translucent wall (90%) - ld->alpha = ((909 - ld->special) << FRACBITS)/10; - break; } + + // Set alpha for translucent walls + if (ld->special >= 900 && ld->special < 909) + ld->alpha = ((909 - ld->special) << FRACBITS)/10; + + // Set alpha for additive/subtractive/reverse subtractive walls + if (ld->special >= 910 && ld->special <= 939) + ld->alpha = ((10 - ld->special % 10) << FRACBITS)/10; + + if (ld->special >= 910 && ld->special <= 919) // additive + ld->blendmode = AST_ADD; + + if (ld->special >= 920 && ld->special <= 929) // subtractive + ld->blendmode = AST_SUBTRACT; + + if (ld->special >= 930 && ld->special <= 939) // reverse subtractive + ld->blendmode = AST_REVERSESUBTRACT; + + if (ld->special == 940) // modulate + ld->blendmode = AST_MODULATE; } } @@ -1469,8 +1479,10 @@ static void P_LoadRawSideDefs2(void *data) if (msd->toptexture[0] == '#') { char *col = msd->toptexture; - sd->toptexture = sd->bottomtexture = - ((col[1]-'0')*100 + (col[2]-'0')*10 + col[3]-'0') + 1; + sd->toptexture = + ((col[1]-'0')*100 + (col[2]-'0')*10 + col[3]-'0')+1; + if (col[4]) // extra num for blendmode + sd->toptexture += (col[4]-'0')*1000; sd->midtexture = R_TextureNumForName(msd->midtexture); } else diff --git a/src/p_spec.c b/src/p_spec.c index 997cc437c..518a411eb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4807,16 +4807,34 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f else th = th->next; } - if (flags & FF_TRANSLUCENT) { if (sides[master->sidenum[0]].toptexture > 0) - ffloor->alpha = sides[master->sidenum[0]].toptexture; // for future reference, "#0" is 1, and "#255" is 256. Be warned + { + // for future reference, "#0" is 1, and "#255" is 256. Be warned + ffloor->alpha = sides[master->sidenum[0]].toptexture; + + if (ffloor->alpha >= 1001) // fourth digit + { + ffloor->blend = (ffloor->alpha/1000)+1; // becomes an AST + ffloor->alpha %= 1000; + } + else + { + ffloor->blend = 0; + } + } else + { ffloor->alpha = 0x80; + ffloor->blend = 0; + } } else + { ffloor->alpha = 0xff; + ffloor->blend = 0; + } ffloor->spawnalpha = ffloor->alpha; // save for netgames diff --git a/src/r_defs.h b/src/r_defs.h index 58cd0f1b1..c3f14236e 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -172,6 +172,7 @@ typedef struct ffloor_s INT32 lastlight; INT32 alpha; + UINT8 blend; // blendmode tic_t norender; // for culling // these are saved for netgames, so do not let Lua touch these! diff --git a/src/r_plane.c b/src/r_plane.c index 9b13bb062..9a3facce2 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -833,28 +833,17 @@ void R_DrawSinglePlane(visplane_t *pl) spanfunc = R_DrawTranslucentSpan_8; // Hacked up support for alpha value in software mode Tails 09-24-2002 - if (pl->ffloor->alpha < 12) - return; // Don't even draw it - else if (pl->ffloor->alpha < 38) - ds_transmap = R_GetTranslucencyTable(tr_trans90); - else if (pl->ffloor->alpha < 64) - ds_transmap = R_GetTranslucencyTable(tr_trans80); - else if (pl->ffloor->alpha < 89) - ds_transmap = R_GetTranslucencyTable(tr_trans70); - else if (pl->ffloor->alpha < 115) - ds_transmap = R_GetTranslucencyTable(tr_trans60); - else if (pl->ffloor->alpha < 140) - ds_transmap = R_GetTranslucencyTable(tr_trans50); - else if (pl->ffloor->alpha < 166) - ds_transmap = R_GetTranslucencyTable(tr_trans40); - else if (pl->ffloor->alpha < 192) - ds_transmap = R_GetTranslucencyTable(tr_trans30); - else if (pl->ffloor->alpha < 217) - ds_transmap = R_GetTranslucencyTable(tr_trans20); - else if (pl->ffloor->alpha < 243) - ds_transmap = R_GetTranslucencyTable(tr_trans10); - else // Opaque, but allow transparent flat pixels - spanfunc = splatfunc; + // ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021 + // and mercilessly shoved into saturn by chearii 02-02-2025 + { + INT32 trans = (10*((256+12) - pl->ffloor->alpha))/255; + if (trans >= 10) + return; // Don't even draw it + if (pl->ffloor->blend) // additive, (reverse) subtractive, modulative + ds_transmap = R_GetBlendTable(pl->ffloor->blend, trans); + else if (!(ds_transmap = R_GetTranslucencyTable(trans)) || trans == 0) + spanfunc = splatfunc; // Opaque, but allow transparent flat pixels + } #ifdef SHITPLANESPARENCY if (spanfunc == splatfunc || (pl->extra_colormap && pl->extra_colormap->fog)) diff --git a/src/r_segs.c b/src/r_segs.c index b0cfc494e..b9c1277ab 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -336,7 +336,19 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) // hack translucent linedef types (900-909 for transtables 1-9) ldef = curline->linedef; - if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) + + if (!ldef->alpha) + return; + + if (ldef->blendmode) + { + if (ldef->alpha == NUMTRANSMAPS || ldef->blendmode == AST_MODULATE) + dc_transmap = R_GetBlendTable(ldef->blendmode, 0); + else + dc_transmap = R_GetBlendTable(ldef->blendmode, R_GetLinedefTransTable(ldef->alpha)); + colfunc = fuzzcolfunc; + } + else if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) { dc_transmap = transtables + ((R_GetLinedefTransTable(ldef->alpha) - 1) << FF_TRANSSHIFT); colfunc = fuzzcolfunc; @@ -725,28 +737,17 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) boolean fuzzy = true; // Hacked up support for alpha value in software mode Tails 09-24-2002 - if (pfloor->alpha < 12) - return; // Don't even draw it - else if (pfloor->alpha < 38) - dc_transmap = R_GetTranslucencyTable(tr_trans90); - else if (pfloor->alpha < 64) - dc_transmap = R_GetTranslucencyTable(tr_trans80); - else if (pfloor->alpha < 89) - dc_transmap = R_GetTranslucencyTable(tr_trans70); - else if (pfloor->alpha < 115) - dc_transmap = R_GetTranslucencyTable(tr_trans60); - else if (pfloor->alpha < 140) - dc_transmap = R_GetTranslucencyTable(tr_trans50); - else if (pfloor->alpha < 166) - dc_transmap = R_GetTranslucencyTable(tr_trans40); - else if (pfloor->alpha < 192) - dc_transmap = R_GetTranslucencyTable(tr_trans30); - else if (pfloor->alpha < 217) - dc_transmap = R_GetTranslucencyTable(tr_trans20); - else if (pfloor->alpha < 243) - dc_transmap = R_GetTranslucencyTable(tr_trans10); - else - fuzzy = false; // Opaque + // ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021 + // and mercilessly shoved into saturn by chearii 02-02-2025 + { + INT32 trans = (10*((256+12) - pfloor->alpha))/255; + if (trans >= 10) + return; // Don't even draw it + if (pfloor->blend) // additive, (reverse) subtractive, modulative + dc_transmap = R_GetBlendTable(pfloor->blend, trans); + else if (!(dc_transmap = R_GetTranslucencyTable(trans)) || trans == 0) + fuzzy = false; // Opaque + } if (fuzzy) colfunc = fuzzcolfunc; diff --git a/src/r_things.c b/src/r_things.c index 410da8ec3..95b5a66ff 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1768,7 +1768,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) fixed_t this_scale; INT32 dist = 1; - INT32 trans; if (cv_maxinterpdist.value) dist = R_QuickCamDist(thing->x, thing->y); @@ -1869,12 +1868,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; } - // Determine the translucency value. - if (thing->frame & FF_TRANSMASK) - trans = (thing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT; - else - trans = 0; - //SoM: 3/17/2000: Disregard sprites that are out of view.. gzt = interp.z + FixedMul(spritecachedinfo[lump].topoffset, this_scale); gz = gzt - FixedMul(spritecachedinfo[lump].height, this_scale); From ccc1c07930001d973ca7b36686766ec6f79e9238 Mon Sep 17 00:00:00 2001 From: Chearii Date: Tue, 4 Feb 2025 16:34:17 -0500 Subject: [PATCH 333/418] Fix white pixel bug due to oversight many thanks to indev for catching this! --- src/r_draw.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/r_draw.c b/src/r_draw.c index d41e542a5..ef4496349 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -248,9 +248,9 @@ static void BlendTab_Translucent(UINT8 *table, int style, UINT8 blendamt) if (table == NULL) I_Error("BlendTab_Translucent: input table was NULL!"); - for (bg = 0; bg < 0xFF; bg++) + for (bg = 0; bg < 0x100; bg++) { - for (fg = 0; fg < 0xFF; fg++) + for (fg = 0; fg < 0x100; fg++) { RGBA_t backrgba = V_GetColor(bg); RGBA_t frontrgba = V_GetColor(fg); @@ -277,9 +277,9 @@ static void BlendTab_Subtractive(UINT8 *table, int style, UINT8 blendamt) return; } - for (bg = 0; bg < 0xFF; bg++) + for (bg = 0; bg < 0x100; bg++) { - for (fg = 0; fg < 0xFF; fg++) + for (fg = 0; fg < 0x100; fg++) { RGBA_t backrgba = V_GetColor(bg); RGBA_t frontrgba = V_GetColor(fg); @@ -302,9 +302,9 @@ static void BlendTab_Modulative(UINT8 *table) if (table == NULL) I_Error("BlendTab_Modulative: input table was NULL!"); - for (bg = 0; bg < 0xFF; bg++) + for (bg = 0; bg < 0x100; bg++) { - for (fg = 0; fg < 0xFF; fg++) + for (fg = 0; fg < 0x100; fg++) { RGBA_t backrgba = V_GetColor(bg); RGBA_t frontrgba = V_GetColor(fg); From 91856ea145cb822cf16ec695655ba2442bef0e56 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 4 Feb 2025 22:58:46 +0100 Subject: [PATCH 334/418] fix merge conflicts --- src/hardware/hw_main.c | 11 ++- src/hardware/r_opengl/r_opengl.c | 131 +++++++++++-------------------- src/k_kart.c | 4 +- src/r_things.c | 4 +- 4 files changed, 61 insertions(+), 89 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 70bfc9ded..b244b867d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -324,6 +324,8 @@ static void HWR_SetShaderState(void) void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite) { + const boolean semibright = R_ThingIsSemiBright(spr->mobj); + (void)papersprite; if (spr->mobj->frame & FF_ABSOLUTELIGHTLEVEL) @@ -371,6 +373,11 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT; } + // Semibright objects will be made slightly brighter to compensate contrast + if (semibright) + { + *lightlevel += 16; + } } void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap, const boolean directional) @@ -3896,11 +3903,11 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) sector_t *sector = spr->mobj->subsector->sector; INT32 lightlevel = 255; extracolormap_t *colormap = sector->extra_colormap; - const boolean fullbright = (spr->mobj->frame & FF_FULLBRIGHT); + const boolean fullbright = R_ThingIsFullBright(spr->mobj); if (R_ThingIsFullDark(spr->mobj)) lightlevel = 0; - else if (!(R_ThingIsFullBright(spr->mobj))) + else if (!fullbright) lightlevel = min(sector->lightlevel, 255); if (R_ThingIsSemiBright(spr->mobj)) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index a4a20b78f..bf0de1ebe 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1446,13 +1446,13 @@ static void Clamp2D(GLenum pname) #endif } -static void SetBlendEquation(GLenum mode) +static void GL_SetBlendEquation(GLenum mode) { if (pglBlendEquation) pglBlendEquation(mode); } -static void SetBlendMode(FBITFIELD flags) +static void GL_SetBlendMode(FBITFIELD flags) { // Set blending function switch (flags) @@ -1491,15 +1491,15 @@ static void SetBlendMode(FBITFIELD flags) switch (flags) { case PF_Subtractive & PF_Blending: - SetBlendEquation(GL_FUNC_SUBTRACT); + GL_SetBlendEquation(GL_FUNC_SUBTRACT); break; case PF_ReverseSubtract & PF_Blending: // good for shadow // not really but what else ? - SetBlendEquation(GL_FUNC_REVERSE_SUBTRACT); + GL_SetBlendEquation(GL_FUNC_REVERSE_SUBTRACT); break; default: - SetBlendEquation(GL_FUNC_ADD); + GL_SetBlendEquation(GL_FUNC_ADD); break; } @@ -1526,14 +1526,14 @@ static void SetBlendMode(FBITFIELD flags) } } -EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) +void GL_SetBlend(FBITFIELD PolyFlags) { FBITFIELD Xor; Xor = CurrentPolyFlags^PolyFlags; if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Invisible)) { if (Xor & PF_Blending) // if blending mode must be changed - SetBlendMode(PolyFlags & PF_Blending); + GL_SetBlendMode(PolyFlags & PF_Blending); if (Xor & PF_NoAlphaTest) { @@ -1543,45 +1543,12 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) pglEnable(GL_ALPHA_TEST); // discard 0 alpha pixels (holes in texture) } - if (Xor & PF_Blending) // if blending mode must be changed - { - switch (PolyFlags & PF_Blending) + if (Xor & PF_Decal) { - case (PF_Translucent & PF_Blending): - pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case (PF_Masked & PF_Blending): - // Hurdler: does that mean lighting is only made by alpha src? - // it sounds ok, but not for polygonsmooth - pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); // 0 alpha = holes in texture - pglAlphaFunc(GL_GREATER, 0.5f); - break; - case (PF_Additive & PF_Blending): - pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case (PF_Environment & PF_Blending): - pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case (PF_Substractive & PF_Blending): - // good for shadow - // not really but what else ? - pglBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case (PF_Fog & PF_Fog): - // Sryder: Fog - // multiplies input colour by input alpha, and destination colour by input colour, then adds them - pglBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR); - pglAlphaFunc(GL_ALWAYS, 0.0f); // Don't discard zero alpha fragments - break; - default : // must be 0, otherwise it's an error - // No blending - pglBlendFunc(GL_ONE, GL_ZERO); // the same as no blending - pglAlphaFunc(GL_GREATER, 0.5f); - break; + if (PolyFlags & PF_Decal) + pglEnable(GL_POLYGON_OFFSET_FILL); + else + pglDisable(GL_POLYGON_OFFSET_FILL); } if (Xor & PF_NoDepthTest) @@ -1613,47 +1580,45 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) if (Xor & PF_Modulated) { #if defined (__unix__) || defined (UNIXCOMMON) - if (oglflags & GLF_NOTEXENV) - { - if (!(PolyFlags & PF_Modulated)) - pglColor4ubv(white); - } - else + if (oglflags & GLF_NOTEXENV) + { + if (!(PolyFlags & PF_Modulated)) + pglColor4ubv(white); + } + else #endif - // mix texture colour with Surface->PolyColor - if (PolyFlags & PF_Modulated) - pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - // colour from texture is unchanged before blending - else - pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - } - - if (Xor & PF_Occlude) // depth test but (no) depth write - { - if (PolyFlags & PF_Occlude) - pglDepthMask(1); - else - pglDepthMask(0); - } - - ////Hurdler: not used if we don't define POLYSKY - if (Xor & PF_Invisible) - { - if (PolyFlags&PF_Invisible) - pglBlendFunc(GL_ZERO, GL_ONE); // transparent blending - else - { // big hack: (TODO: manage that better) - // we test only for PF_Masked because PF_Invisible is only used - // (for now) with it (yeah, that's crappy, sorry) - if ((PolyFlags & PF_Blending) == PF_Masked) - pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); + // mix texture colour with Surface->PolyColor + if (PolyFlags & PF_Modulated) + pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + // colour from texture is unchanged before blending + else + pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); } + + if (Xor & PF_Occlude) // depth test but (no) depth write + { + if (PolyFlags&PF_Occlude) + pglDepthMask(1); + else + pglDepthMask(0); + } + ////Hurdler: not used if we don't define POLYSKY + if (Xor & PF_Invisible) + { + if (PolyFlags&PF_Invisible) + pglBlendFunc(GL_ZERO, GL_ONE); // transparent blending + else + { // big hack: (TODO: manage that better) + // we test only for PF_Masked because PF_Invisible is only used + // (for now) with it (yeah, that's crappy, sorry) + if ((PolyFlags&PF_Blending)==PF_Masked) + pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); + } + } + if (PolyFlags & PF_NoTexture) + GL_SetNoTexture(); } - - if (PolyFlags & PF_NoTexture) - GL_SetNoTexture(); - CurrentPolyFlags = PolyFlags; } @@ -2666,7 +2631,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics pglColor4ubv((GLubyte*)&Surface->PolyColor.s); - SetBlend((poly.alpha < 1 ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated); + GL_SetBlend((poly.alpha < 1 ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated); tint.red = byte2float[Surface->TintColor.s.red]; tint.green = byte2float[Surface->TintColor.s.green]; diff --git a/src/k_kart.c b/src/k_kart.c index 8bc1f4e83..0a3d7dbb1 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9832,10 +9832,10 @@ skipcrap: if (K_UseColorHud() && xtra_speedo_clr3) // Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((basex - dup*30)<isScaled = false; if (thing->subsector->sector->numlights) - R_SplitSprite(vis, thing); + R_SplitSprite(vis); // Debug ++objectsdrawn; From 6ed7e26d861072fd64429f818b361ce1f218fa81 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Feb 2025 18:39:17 +0100 Subject: [PATCH 335/418] flag clash moment --- src/p_pspr.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/p_pspr.h b/src/p_pspr.h index 3ebe59935..89f6c1108 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -41,8 +41,6 @@ #define FF_HORIZONTALFLIP 0x400 /// \brief Frame flags: Thin, paper-like sprite (for collision equivalent, see MF_PAPERCOLLISION) #define FF_PAPERSPRITE 0x800 -/// \brief mobj_t.lightlevel is absolute instead of relative -#define FF_ABSOLUTELIGHTLEVEL 0x2000 /// \brief Frame flags: blend types #define FF_BLENDMASK 0x7000 @@ -79,6 +77,9 @@ /// \brief Frame flags: frame appears between sector bright and full bright #define FF_SEMIBRIGHT (FF_FULLBRIGHT|FF_FULLDARK) +/// \brief mobj_t.lightlevel is absolute instead of relative +#define FF_ABSOLUTELIGHTLEVEL 0x00400000 + /// \brief Frame flags: Simple stateless animation #define FF_ANIMATE 0x10000000 From f9ccacf11859fca0a57129a7dfdfebf92aa3b413 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 4 Feb 2025 23:00:16 +0100 Subject: [PATCH 336/418] handle ogl lightlevelpost similar to rr now that we have everything for it --- src/hardware/hw_main.c | 139 +++++++++++++++++-------------- src/hardware/r_opengl/r_opengl.c | 12 ++- 2 files changed, 84 insertions(+), 67 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b244b867d..de6d1c0cb 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -322,61 +322,74 @@ static void HWR_SetShaderState(void) GL_SetSpecialState(HWD_SET_SHADERS, HWR_UseShader() ? 1 : 0); } +static boolean HWR_OverrideObjectLightLevel(mobj_t *thing, INT32 *lightlevel) +{ + if (R_ThingIsFullBright(thing)) + *lightlevel = 255; + else if (R_ThingIsFullDark(thing)) + *lightlevel = 0; + else if (thing->frame & FF_ABSOLUTELIGHTLEVEL) + *lightlevel = R_ThingLightLevel(thing); + else + return false; + + return true; +} + void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite) { const boolean semibright = R_ThingIsSemiBright(spr->mobj); - (void)papersprite; - if (spr->mobj->frame & FF_ABSOLUTELIGHTLEVEL) + *lightlevel += R_ThingLightLevel(spr->mobj); + + if (maplighting.directional == true && P_SectorUsesDirectionalLighting(sector)) { - *lightlevel = R_ThingLightLevel(spr->mobj); - return; - } - else - { - *lightlevel += R_ThingLightLevel(spr->mobj); + if (model == false) // this is implemented by shader + { + fixed_t extralight = R_GetSpriteDirectionalLighting(R_PointToAngle(spr->mobj->x, spr->mobj->y)); + + // this seems to be wrong??? + /*fixed_t extralight = R_GetSpriteDirectionalLighting( + papersprite + ? R_PointToAngle(spr->mobj->x, spr->mobj->y) + (spr->flip ? -ANGLE_90 : ANGLE_90) + : R_PointToAngle(spr->mobj->x, spr->mobj->y) // fixme + );*/ + + // Less change in contrast in dark sectors + extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255); + + // NO NO BAD! WHY!? + /*if (papersprite) + { + // Papersprite contrast should match walls + *lightlevel += FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; + } + else*/ + { + // simple OGL approximation + fixed_t tr = R_PointToDist(spr->mobj->x, spr->mobj->y); + fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); + + // Less change in contrast at further distances, to counteract DOOM diminished light + fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); + extralight = FixedMul(extralight, min(n, FRACUNIT)); + + // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance + *lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT; + } + } + + // Semibright objects will be made slightly brighter to compensate contrast + if (semibright) + { + *lightlevel += 16; + } } - if (maplighting.directional == false || !P_SectorUsesDirectionalLighting(sector) || model == true) - return; - - fixed_t extralight = R_GetSpriteDirectionalLighting(R_PointToAngle(spr->mobj->x, spr->mobj->y)); - - // this seems to be wrong??? - /*fixed_t extralight = R_GetSpriteDirectionalLighting( - papersprite - ? R_PointToAngle(spr->mobj->x, spr->mobj->y) + (spr->flip ? -ANGLE_90 : ANGLE_90) - : R_PointToAngle(spr->mobj->x, spr->mobj->y) // fixme - );*/ - - // Less change in contrast in dark sectors - extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255); - - // NO NO BAD! WHY!? - /*if (papersprite) - { - // Papersprite contrast should match walls - *lightlevel += FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; - } - else*/ - { - // simple OGL approximation - fixed_t tr = R_PointToDist(spr->mobj->x, spr->mobj->y); - fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); - - // Less change in contrast at further distances, to counteract DOOM diminished light - fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); - extralight = FixedMul(extralight, min(n, FRACUNIT)); - - // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance - *lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT; - } - - // Semibright objects will be made slightly brighter to compensate contrast if (semibright) { - *lightlevel += 16; + *lightlevel = 128 + (*lightlevel >> 1); } } @@ -875,9 +888,9 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) } #endif -FBITFIELD HWR_GetBlendModeFlag(INT32 ast) +FBITFIELD HWR_GetBlendModeFlag(INT32 style) { - switch (ast) + switch (style) { case AST_TRANSLUCENT: return PF_Translucent; @@ -892,8 +905,6 @@ FBITFIELD HWR_GetBlendModeFlag(INT32 ast) default: return PF_Masked; } - - return 0; } UINT8 HWR_GetTranstableAlpha(INT32 transtablenum) @@ -3543,6 +3554,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) FSurfaceInfo Surf; extracolormap_t *colormap; INT32 lightlevel; + boolean lightset = true; FBITFIELD blend = 0; UINT8 alpha; @@ -3678,10 +3690,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) i = 0; temp = FLOAT_TO_FIXED(realtop); - if (R_ThingIsFullBright(spr->mobj)) - lightlevel = 255; - else if (R_ThingIsFullDark(spr->mobj)) - lightlevel = 0; + lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); for (i = 1; i < sector->numlights; i++) { @@ -3689,13 +3698,14 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) if (!(h <= temp)) continue; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (!lightset) lightlevel = min(*list[i-1].lightlevel, 255); colormap = list[i-1].extra_colormap; break; } - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); + if (!lightset) + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); for (i = 0; i < sector->numlights; i++) { @@ -3705,9 +3715,12 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) // even if we aren't changing colormap or lightlevel, we still need to continue drawing down the sprite if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (!lightset) + { lightlevel = min(*list[i].lightlevel, 255); - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); + } + colormap = list[i].extra_colormap; } @@ -3902,18 +3915,15 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // colormap test sector_t *sector = spr->mobj->subsector->sector; INT32 lightlevel = 255; + boolean lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); extracolormap_t *colormap = sector->extra_colormap; const boolean fullbright = R_ThingIsFullBright(spr->mobj); - if (R_ThingIsFullDark(spr->mobj)) - lightlevel = 0; - else if (!fullbright) + if (!lightset) lightlevel = min(sector->lightlevel, 255); - if (R_ThingIsSemiBright(spr->mobj)) - lightlevel = 128 + (lightlevel>>1); - - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); + if (!lightset) + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !fullbright); @@ -4586,6 +4596,7 @@ static void HWR_ProjectSprite(mobj_t *thing) return; const boolean papersprite = (thing->frame & FF_PAPERSPRITE); + INT32 blendmode; if (thing->frame & FF_BLENDMASK) blendmode = ((thing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index bf0de1ebe..ecbc52ca8 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1587,19 +1587,22 @@ void GL_SetBlend(FBITFIELD PolyFlags) } else #endif - - // mix texture colour with Surface->PolyColor if (PolyFlags & PF_Modulated) + { // mix texture colour with Surface->PolyColor pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - // colour from texture is unchanged before blending + } else + { // colour from texture is unchanged before blending pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + } } if (Xor & PF_Occlude) // depth test but (no) depth write { if (PolyFlags&PF_Occlude) + { pglDepthMask(1); + } else pglDepthMask(0); } @@ -1617,9 +1620,12 @@ void GL_SetBlend(FBITFIELD PolyFlags) } } if (PolyFlags & PF_NoTexture) + { GL_SetNoTexture(); + } } CurrentPolyFlags = PolyFlags; + } static void GL_AllocTextureBuffer(GLMipmap_t *pTexInfo) From f30cdc19333bf4e4ef322ffe3a1aa5449867ea84 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 4 Feb 2025 23:02:58 +0100 Subject: [PATCH 337/418] stuff that was missing --- src/hardware/hw_main.c | 8 ++++++++ src/r_things.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index de6d1c0cb..e5c9d3825 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2820,6 +2820,13 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v return false; } +static FBITFIELD HWR_RippleBlend(sector_t *sector, ffloor_t *rover, boolean ceiling) +{ + (void)sector; + (void)ceiling; + return /*R_IsRipplePlane(sector, rover, ceiling)*/ (rover->flags & FF_RIPPLE) ? PF_Ripple : 0; +} + // -----------------+ // HWR_Subsector : Determine floor/ceiling planes. // : Add sprites of things in sector. @@ -4957,6 +4964,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) if (!R_BlendLevelVisible(thing->blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT)) return; } + // transform the origin point tr_x = FIXED_TO_FLOAT(interp.x); tr_y = FIXED_TO_FLOAT(interp.y); diff --git a/src/r_things.c b/src/r_things.c index 1b4c905be..4703f7561 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2108,7 +2108,7 @@ void R_AddPrecipitationSprites(void) { for (th = precipblocklinks[(by * bmapwidth) + bx]; th; th = next) { - // Store this beforehand because R_ProjectPrecipitionSprite may free th (see P_PrecipThinker) + // Store this beforehand because R_ProjectPrecipitationSprite may free th (see P_PrecipThinker) next = th->bnext; if (th->precipflags & PCF_INVISIBLE) From 2de44e75634e665302a9b93d3a5903906a754a45 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Feb 2025 14:41:10 +0100 Subject: [PATCH 338/418] check for realpatch here too --- src/hardware/hw_cache.c | 7 +++++-- src/r_data.c | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index af06ecba6..ab278989b 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -384,8 +384,11 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); - HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); - Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); + if (realpatch != NULL) + { + HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); + Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); + } } //Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :( diff --git a/src/r_data.c b/src/r_data.c index 9ce03a9c5..ad084c269 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -388,6 +388,11 @@ static UINT8 *R_GenerateTexture(size_t texnum) for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL); + + // Well, it's not valid... + if (realpatch == NULL) + continue; + x1 = patch->originx; x2 = x1 + SHORT(realpatch->width); From da7d200d9279e46087bc932569c83701adcc2dfd Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 4 Feb 2025 02:12:51 +0100 Subject: [PATCH 339/418] skip intro sounds also with keepmusic lel --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 8cdd60be7..61c0a010a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2167,7 +2167,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT32 sfxnum; //dont play any funky sound intros that may interfere with the music - if (skipintromus && (leveltime < MUSICSTARTTIME)) + if ((skipintromus || keepmusic) && (leveltime < MUSICSTARTTIME)) return; sfxnum = sides[line->sidenum[0]].toptexture; //P_AproxDistance(line->dx, line->dy)>>FRACBITS; From f76a62b7d2acf0491ae0477a141a9bdd56841424 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 4 Feb 2025 02:24:08 +0100 Subject: [PATCH 340/418] save music position and try to fade back into mapmusic when the music changed from mapmusic when keepmusic is enabled uhh idk how to explain lel hope this doesent explode --- src/s_sound.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 7061eaea3..551145d75 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -120,6 +120,8 @@ consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL, boolean keepmusic = false; // keep the current music on map restart boolean skipintromus = false; // skip the intro fanfare +static boolean keepmusicresume = false; +static UINT32 keepmusposition = 0; #ifdef HAVE_OPENMPT openmpt_module *openmpt_mhandle = NULL; @@ -194,6 +196,8 @@ static INT32 numofchannels = 0; // static void S_StopChannel(INT32 cnum); +static void S_SetKeepMusicStopStuff(void); + // // S_getChannel // @@ -1821,6 +1825,8 @@ void S_StopMusic(void) mapmusresume = (cv_birdmusic.value && (strcasecmp(music_name, mapmusname) == 0)) ? I_GetSongPosition() : 0; + S_SetKeepMusicStopStuff(); + if (I_SongPaused()) I_ResumeSong(); @@ -1962,19 +1968,32 @@ void S_ResetKeepAndSpecialMus(void) keepmusic = skipintromus = false; } +// save some values +static void S_SetKeepMusicStopStuff(void) +{ + keepmusposition = 0; + + if (strcasecmp(music_name, mapmusname) == 0) + { + keepmusposition = I_GetSongPosition(); + } +} + // determine if we should keep the music on a map restart void S_KeepMusic(void) { static INT16 oldmap = 0; static boolean oldencore = false; + const boolean musicchanged = S_CheckMusicException(); + keepmusicresume = (musicchanged && keepmusposition); - if (!cv_keepmusic.value || gamestate != GS_LEVEL || music_name[0] == 0) + if (!cv_keepmusic.value) { keepmusic = false; } else if (oldmap == gamemap && oldencore == encoremode) { - keepmusic = !S_CheckMusicException(); + keepmusic = (!musicchanged || keepmusicresume); } oldencore = encoremode; @@ -1998,7 +2017,12 @@ void S_InitMapMusic(void) } if (keepmusic) + { + // this is kinda silly, but we can use it to fade back into the map song at the saved point, should the current music be different from the map music + if (keepmusicresume) + S_ChangeMusicEx(mapmusname, mapmusflags, true, keepmusposition, 0, 500); return; + } // Starting ambience should always be restarted // lug: but not when we keep the map music lol From 4795af29ea954c61d02d4d36395616893db7a464 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 4 Feb 2025 02:41:31 +0100 Subject: [PATCH 341/418] reset keepmusposition in tunes command mapmusic will be reset the moment the gamestate changes, so whatever was changed with tunes will not be kept sadly --- src/s_sound.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 551145d75..597901d85 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -196,7 +196,7 @@ static INT32 numofchannels = 0; // static void S_StopChannel(INT32 cnum); -static void S_SetKeepMusicStopStuff(void); +static void S_SetKeepMusicPosition(void); // // S_getChannel @@ -1825,7 +1825,7 @@ void S_StopMusic(void) mapmusresume = (cv_birdmusic.value && (strcasecmp(music_name, mapmusname) == 0)) ? I_GetSongPosition() : 0; - S_SetKeepMusicStopStuff(); + S_SetKeepMusicPosition(); if (I_SongPaused()) I_ResumeSong(); @@ -1969,7 +1969,7 @@ void S_ResetKeepAndSpecialMus(void) } // save some values -static void S_SetKeepMusicStopStuff(void) +static void S_SetKeepMusicPosition(void) { keepmusposition = 0; @@ -2164,6 +2164,8 @@ static void Command_Tunes_f(void) S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + keepmusposition = 0; + if (argc > 3) { float speed = (float)atof(COM_Argv(3)); From bd6b699a1e59e131d9876fa5b6ddd50c0db3032f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 4 Feb 2025 12:55:50 +0100 Subject: [PATCH 342/418] keep track of map music this is kinda horrible, but allows musicchanges which replace map music/tunes to also work with this system --- src/s_sound.c | 53 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 597901d85..b49e8e0d1 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -121,6 +121,9 @@ consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL, boolean keepmusic = false; // keep the current music on map restart boolean skipintromus = false; // skip the intro fanfare static boolean keepmusicresume = false; +static char keepmusname[7]; +static UINT32 keepmusresume = 0; +static UINT16 keepmusflags = 0; static UINT32 keepmusposition = 0; #ifdef HAVE_OPENMPT @@ -1763,6 +1766,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; } + //S_SetKeepMusicPosition(); + if (prefadems && S_MusicPlaying()) // queue music change for after fade // allow even if the music is the same { CONS_Debug(DBG_DETAILED, "Now fading out song %s\n", music_name); @@ -1971,30 +1976,49 @@ void S_ResetKeepAndSpecialMus(void) // save some values static void S_SetKeepMusicPosition(void) { - keepmusposition = 0; + if (!cv_keepmusic.value) + { + return; + } if (strcasecmp(music_name, mapmusname) == 0) { - keepmusposition = I_GetSongPosition(); + strncpy(keepmusname, mapmusname, 7); + keepmusresume = I_GetSongPosition(); + keepmusflags = mapmusflags; + keepmusposition = mapmusposition; } } +static void S_ClearKeepMusicPosition(void) +{ + memset(keepmusname, 0, sizeof(keepmusname)); + keepmusresume = 0; + keepmusflags = 0; + keepmusposition = 0; +} + // determine if we should keep the music on a map restart void S_KeepMusic(void) { static INT16 oldmap = 0; static boolean oldencore = false; const boolean musicchanged = S_CheckMusicException(); - keepmusicresume = (musicchanged && keepmusposition); if (!cv_keepmusic.value) { - keepmusic = false; + keepmusic = keepmusicresume = false; } else if (oldmap == gamemap && oldencore == encoremode) { + keepmusicresume = (musicchanged && keepmusresume); keepmusic = (!musicchanged || keepmusicresume); } + else + { + keepmusic = keepmusicresume = false; + S_ClearKeepMusicPosition(); + } oldencore = encoremode; oldmap = gamemap; @@ -2009,10 +2033,19 @@ void S_InitMapMusic(void) { if (mapmusflags & MUSIC_RELOADRESET) { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); - mapmusposition = mapheaderinfo[gamemap-1]->muspos; + if (keepmusic && keepmusicresume) + { + strncpy(mapmusname, keepmusname, 7); + mapmusflags = keepmusflags; + mapmusposition = keepmusposition; + } + else + { + strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); + mapmusname[6] = 0; + mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); + mapmusposition = mapheaderinfo[gamemap-1]->muspos; + } mapmusresume = 0; } @@ -2020,7 +2053,7 @@ void S_InitMapMusic(void) { // this is kinda silly, but we can use it to fade back into the map song at the saved point, should the current music be different from the map music if (keepmusicresume) - S_ChangeMusicEx(mapmusname, mapmusflags, true, keepmusposition, 0, 500); + S_ChangeMusicEx(mapmusname, mapmusflags, true, keepmusresume, 0, 500); return; } @@ -2164,8 +2197,6 @@ static void Command_Tunes_f(void) S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); - keepmusposition = 0; - if (argc > 3) { float speed = (float)atof(COM_Argv(3)); From 323fbb4713ae562ee3e3f347ca439727fd736896 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Feb 2025 18:10:36 +0100 Subject: [PATCH 343/418] Update position nums to use additive https://git.srb2.org/KartKrew/RingRacers/-/commit/4d108930a94f44dbc916d1116eab8421e669e4b6 --- src/dehacked.c | 8 ++++++++ src/k_kart.c | 44 +++++++++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 5189af4bb..7722d777b 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1070,6 +1070,13 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) else mapheaderinfo[num-1]->levelflags &= ~LF_SECTIONRACE; } + else if (fastcmp(word, "SUBTRACTNUM")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_SUBTRACTNUM; + else + mapheaderinfo[num-1]->levelflags &= ~LF_SUBTRACTNUM; + } // Individual triggers for menu flags else if (fastcmp(word, "HIDDEN")) @@ -7840,6 +7847,7 @@ struct { {"LF_NORELOAD",LF_NORELOAD}, {"LF_NOZONE",LF_NOZONE}, {"LF_SECTIONRACE",LF_SECTIONRACE}, + {"LF_SUBTRACTNUM",LF_SUBTRACTNUM}, // And map flags {"LF2_HIDEINMENU",LF2_HIDEINMENU}, {"LF2_HIDEINSTATS",LF2_HIDEINSTATS}, diff --git a/src/k_kart.c b/src/k_kart.c index 0a3d7dbb1..95dd0daeb 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8760,6 +8760,7 @@ static void K_DrawKartPositionNum(INT32 num) INT32 W = SHORT(kp_positionnum[0][0]->width); fixed_t scale = FRACUNIT; patch_t *localpatch = kp_positionnum[0][0]; + INT32 addOrSub = B_ADD; //INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTORIGHT); INT32 fx = 0, fy = 0, fflags = 0; INT32 xoffs = wheeloffs ? -48 : 0; @@ -8767,6 +8768,11 @@ 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 ((mapheaderinfo[gamemap - 1]->levelflags & LF_SUBTRACTNUM) == LF_SUBTRACTNUM) + { + addOrSub = B_SUBTRACT; + } + if ((cv_posanim.value && stplyr->kartstuff[k_positiondelay]) || stplyr->exiting) { scale *= 2; @@ -8774,7 +8780,9 @@ static void K_DrawKartPositionNum(INT32 num) } if (splitscreen || cv_smallposnum.value || wheeloffs) + { scale /= 2; + } W = FixedMul(W<>FRACBITS; @@ -8821,38 +8829,46 @@ static void K_DrawKartPositionNum(INT32 num) } // Special case for 0 - if (!num) + if (num <= 0) { - V_DrawFixedPatch(fx<= 0); // This function does not draw negative numbers - // Draw the number while (num) { if (win) // 1st place winner? You get rainbows!! + { localpatch = kp_winnernum[(leveltime % (NUMWINFRAMES*3)) / 3]; + } else if (stplyr->laps+1 >= cv_numlaps.value || stplyr->exiting) // Check for the final lap, or won { - // Alternate frame every three frames - switch (leveltime % 9) + boolean useRedNums = K_IsPlayerLosing(stplyr); + + if (addOrSub == B_SUBTRACT) { - case 1: case 2: case 3: - if (K_IsPlayerLosing(stplyr)) + // Subtracting RED will look BLUE, and vice versa. + useRedNums = !useRedNums; + } + + // Alternate frame every three frames + switch ((leveltime % 9) / 3) + { + case 0: + if (useRedNums == true) localpatch = kp_positionnum[num % 10][4]; else localpatch = kp_positionnum[num % 10][1]; break; - case 4: case 5: case 6: - if (K_IsPlayerLosing(stplyr)) + case 1: + if (useRedNums == true) localpatch = kp_positionnum[num % 10][5]; else localpatch = kp_positionnum[num % 10][2]; break; - case 7: case 8: case 9: - if (K_IsPlayerLosing(stplyr)) + case 2: + if (useRedNums == true) localpatch = kp_positionnum[num % 10][6]; else localpatch = kp_positionnum[num % 10][3]; @@ -8863,9 +8879,11 @@ static void K_DrawKartPositionNum(INT32 num) } } else + { localpatch = kp_positionnum[num % 10][0]; + } - V_DrawFixedPatch((fx<width)*scale/2) : 0), (fy<height)*scale/2) : 0), scale, V_HUDTRANSHALF|fflags, localpatch, NULL); + V_DrawBlendingFixedPatch((fx<width)*scale/2) : 0), (fy<height)*scale/2) : 0), scale, V_HUDTRANSHALF|fflags, localpatch, NULL, addOrSub); // ^ if we overtake as p1 or p3 in splitscren, we shift it so that it doesn't go off screen. // ^ if we overtake as p1 in 2p splits, shift vertically so that this doesn't happen either. From 18a78e2892f471678b53e25e89d725605ebbf9c1 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 4 Feb 2025 23:06:00 +0100 Subject: [PATCH 344/418] test add blendmodes to a bunch of player effects going see how it looks --- src/k_kart.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index 95dd0daeb..00b8626c1 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1667,6 +1667,7 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) fx->eflags |= MFE_VERTICALFLIP; else fx->eflags &= ~MFE_VERTICALFLIP; + fx->blendmode = AST_ADD; P_SetScale(fx, mobj1->scale); // Because this is done during collision now, rmomx and rmomy need to be recalculated @@ -3301,6 +3302,7 @@ static void K_SpawnDriftSparks(player_t *player) P_SetMobjState(spark, S_DRIFTSPARK_A1); } + spark->blendmode = AST_ADD; K_MatchGenericExtraFlags(spark, player->mo); } } @@ -3657,6 +3659,7 @@ void K_SpawnSparkleTrail(mobj_t *mo) sparkle->destscale = mo->destscale; P_SetScale(sparkle, mo->scale); sparkle->color = mo->color; + sparkle->blendmode = AST_ADD; } P_SetMobjState(sparkle, S_KARTINVULN_LARGE1); @@ -5457,6 +5460,7 @@ static inline void K_SpawnNormalSpeedLines(player_t *player, boolean synched) fast->colorized = true; } } + fast->blendmode = AST_ADD; } /** \brief Decreases various kart timers and powers per frame. Called in P_PlayerThink in p_user.c From b24a7e3faf36b093b5c959923a17f0e6a8b45ba9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Feb 2025 18:39:03 +0100 Subject: [PATCH 345/418] forgor --- src/doomstat.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/doomstat.h b/src/doomstat.h index 441e9df3b..b3290b884 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -289,6 +289,8 @@ typedef struct #define LF_NORELOAD 8 ///< Don't reload level on death #define LF_NOZONE 16 ///< Don't include "ZONE" on level title #define LF_SECTIONRACE 32 ///< Section race level +#define LF_SUBTRACTNUM 64 ///< Use subtractive position number (for bright levels) + #define LF2_HIDEINMENU 1 ///< Hide in the multiplayer menu #define LF2_HIDEINSTATS 2 ///< Hide in the statistics screen From d4c986fb8445e1c5ec8a7fe8ed92ba6ae482c312 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 2 Feb 2025 15:18:05 +0100 Subject: [PATCH 346/418] no need pass this stuff --- src/d_main.c | 2 +- src/hardware/hw_main.c | 18 ++++++++++-------- src/hardware/hw_main.h | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f31c6bda3..9a99fabec 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -507,7 +507,7 @@ static boolean D_Display(void) #ifdef HWRENDER if (rendermode == render_opengl) - HWR_RenderPlayerView(i, &players[displayplayers[i]]); + HWR_RenderPlayerView(); else #endif if (rendermode != render_none) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e5c9d3825..ab42c4b2c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5491,7 +5491,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl // ========================================================================== // Render the current frame. // ========================================================================== -static void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) +static void HWR_RenderFrame(player_t *player, boolean skybox) { const float fpov = FixedToFloat(R_GetPlayerFov(player)); @@ -5499,12 +5499,12 @@ static void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) gl_viewwindowx = gl_baseviewwindowx; gl_viewwindowy = gl_baseviewwindowy; - if ((splitscreen == 1 && viewnumber == 1) || (splitscreen > 1 && viewnumber > 1)) + if ((splitscreen == 1 && viewssnum == 1) || (splitscreen > 1 && viewssnum > 1)) { gl_viewwindowy += gl_viewheight; } - if (splitscreen > 1 && viewnumber & 1) + if (splitscreen > 1 && viewssnum & 1) { gl_viewwindowx += gl_viewwidth; } @@ -5576,12 +5576,14 @@ static void HWR_RollTransform(FTransform *tr, angle_t roll) } } -void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) +void HWR_RenderPlayerView(void) { + player_t * player = &players[displayplayers[viewssnum]]; + const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on // Clear the color buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs. - if (viewnumber == 0) // Only do it if it's the first screen being rendered + if (viewssnum == 0) // Only do it if it's the first screen being rendered { FRGBAFloat ClearColor; @@ -5606,7 +5608,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_BACKLIGHT, maplighting.backlight); } - if (viewnumber > 3) + if (viewssnum > 3) return; // Render the skybox if there is one. @@ -5615,13 +5617,13 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) if (skybox) { R_SkyboxFrame(viewssnum); - HWR_RenderFrame(viewnumber, player, true); + HWR_RenderFrame(player, true); } PS_STOP_TIMING(ps_skyboxtime); R_SetupFrame(viewssnum, false); // This can stay false because it is only used to set viewsky in r_main.c, which isn't used here framecount++; // for timedemo - HWR_RenderFrame(viewnumber, player, false); + HWR_RenderFrame(player, false); } void HWR_LoadLevel(void) diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 2ccd98491..8b1751a8e 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -104,7 +104,7 @@ boolean HWR_Screenshot(const char *lbmname); void HWR_SetViewSize(void); void HWR_AddCommands(void); -void HWR_RenderPlayerView(INT32 viewnumber, player_t *player); +void HWR_RenderPlayerView(void); void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *player, int stencil_level, boolean allow_portals); void HWR_ClearSkyDome(void); From f67815b0d3d99049ebf6cad7f175eaee746b1eea Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 5 Feb 2025 00:35:33 +0100 Subject: [PATCH 347/418] also add additive to boostflame --- src/k_kart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/k_kart.c b/src/k_kart.c index 00b8626c1..231a3093c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3608,6 +3608,7 @@ void K_SpawnBoostTrail(player_t *player) { flame->colorized = true; flame->color = player->skincolor; + flame->blendmode = AST_ADD; } P_SetScale(flame, player->mo->scale); From 0d2a1bac36880fac4df5ddb2d4c663f215b25222 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 5 Feb 2025 15:33:27 +0100 Subject: [PATCH 348/418] Revert ""kill" seenames" This reverts commit 93a1a432d7b0eb926fd83c189219017421808da4. --- src/d_netcmd.c | 6 +++--- src/doomdef.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 57ba1b783..75daeeb08 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -263,8 +263,8 @@ consvar_t cv_competitionboxes = {"competitionboxes", "Random", CV_NETVAR|CV_CHEA #ifdef SEENAMES static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}}; consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif -consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; // bruh // these are just meant to be saved to the config consvar_t cv_playername = {"name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -775,9 +775,9 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_showping); CV_RegisterVar(&cv_pingmeasurement); -//#ifdef SEENAMES // bruh again +#ifdef SEENAMES CV_RegisterVar(&cv_allowseenames); -//#endif +#endif CV_RegisterVar(&cv_dummyconsvar); diff --git a/src/doomdef.h b/src/doomdef.h index 3ea9fbb63..297128269 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -606,7 +606,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; //#define DUMPCONSISTENCY /// See name of player in your crosshair -//#define SEENAMES +#define SEENAMES /// Allow loading of savegames between different versions of the game. /// \note XMOD port. From be58dd19c15dad6f9ca69ba8c8f53a1aa3b6cc41 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Feb 2025 02:06:57 +0100 Subject: [PATCH 349/418] dont pass bogus values to I_GamepadRumble and I_SetGamepadIndicatorColor - fixes rumble and led stuff not working after hotplugging - also fixes sdl2-compat breaking - i hate karts controller code --- src/g_input.c | 41 ++++++----------------------------------- src/i_system.h | 4 ++-- src/sdl/i_system.c | 14 ++++++++++---- 3 files changed, 18 insertions(+), 41 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 959dc5416..460f21899 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -913,18 +913,12 @@ UINT16 G_GetSkinColor(INT32 playernum) void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color) { - INT32 device; UINT16 skincolor; byteColor_t byte_color; I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); if (cv_gamepadled[playernum].value == 0) - return; - - device = cv_usejoystick[playernum].value; - - if (device <= 0) { return; } @@ -932,19 +926,14 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color) 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); + I_SetGamepadIndicatorColor(playernum, byte_color.red, byte_color.green, byte_color.blue); } static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) { if (cv_gamepadled[playernum].value == 0) { - INT32 device = cv_usejoystick[playernum].value; - - if (device <= 0) - return; - - I_SetGamepadIndicatorColor(device, 0, 0, 255); + I_SetGamepadIndicatorColor(playernum, 0, 0, 255); } else G_SetPlayerGamepadIndicatorColor(playernum, 0); @@ -952,16 +941,7 @@ static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) static void G_ResetPlayerDeviceRumble(INT32 playernum) { - INT32 device_id; - - device_id = cv_usejoystick[playernum].value; - - if (device_id < 1) - { - return; - } - - I_GamepadRumble(device_id, 0, 0, 0); + I_GamepadRumble(playernum, 0, 0, 0); } void G_ResetAllDeviceRumbles(void) @@ -973,29 +953,20 @@ void G_ResetAllDeviceRumbles(void) for (i = 0; i < devices; i++) { - INT32 device_id = cv_usejoystick[i].value; - - I_GamepadRumble(device_id, 0, 0, 0); + I_GamepadRumble(devices, 0, 0, 0); } } void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { - INT32 device_id; + I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); if (cv_rumble[playernum].value == 0) { return; } - device_id = cv_usejoystick[playernum].value; - - if (device_id < 1) - { - return; - } - - I_GamepadRumble(device_id, low_strength, high_strength, duration); + I_GamepadRumble(playernum, low_strength, high_strength, duration); } // diff --git a/src/i_system.h b/src/i_system.h index 3b6913c00..1f5226fee 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -238,8 +238,8 @@ INT32 I_NumJoys(void); */ const char *I_GetJoyName(INT32 joyindex); -void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, UINT32 duration); -void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue); +void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration); +void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 blue); #ifndef NOMUMBLE #include "p_mobj.h" // mobj_t diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index d40359c8a..4a64a7c5d 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1486,7 +1486,7 @@ const char *I_GetJoyName(INT32 joyindex) return joyname; } -void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, UINT32 duration) +void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { #if !(SDL_VERSION_ATLEAST(2,0,14)) (void)device_id; @@ -1494,9 +1494,12 @@ void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, (void)high_strength; (void)duration; #else + + INT32 device_id = I_GetJoystickDeviceIndex(JoyInfo[playernum].dev); + I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); + SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id); if (controller == NULL) { return; @@ -1506,7 +1509,7 @@ void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, #endif } -void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue) +void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 blue) { #if !(SDL_VERSION_ATLEAST(2,0,14)) (void)device_id; @@ -1514,9 +1517,12 @@ void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 b (void)green; (void)blue; #else + + INT32 device_id = I_GetJoystickDeviceIndex(JoyInfo[playernum].dev); + I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); + SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id); if (controller == NULL) { return; From 1b610242bcabdd3edef8da9f09d9d319b49b660e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Feb 2025 14:43:18 +0100 Subject: [PATCH 350/418] update controller led when connecting a controller --- src/sdl/i_video.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 1683ec2ea..8a5ed8cbc 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1242,7 +1242,10 @@ void I_GetEvent(void) //////////////////////////////////////////////////////////// for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { I_InitJoystick(i); + G_SetPlayerGamepadIndicatorColor(i, G_GetSkinColor(i)); // gotta update the controller led again on reconnect + } //////////////////////////////////////////////////////////// From 9ac9db0fe042043a33198bb558cb949b9252f721 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Feb 2025 17:25:43 +0100 Subject: [PATCH 351/418] only apply additive blend to speedlines when any kind of boost is happening to emphasize that ure boosting or smth --- src/k_kart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 231a3093c..3e0aa0788 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5460,8 +5460,10 @@ static inline void K_SpawnNormalSpeedLines(player_t *player, boolean synched) fast->color = (leveltime & 1) ? player->mo->color : driftcolor; fast->colorized = true; } + + if (goodSpeed && ((player->kartstuff[k_growshrinktimer] > 0) || player->kartstuff[k_invincibilitytimer] || player->kartstuff[k_sneakertimer])) + fast->blendmode = AST_ADD; } - fast->blendmode = AST_ADD; } /** \brief Decreases various kart timers and powers per frame. Called in P_PlayerThink in p_user.c From 8f07f183dd859a92312f267001c3d4f672bd42c1 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 7 Feb 2025 04:05:10 +0100 Subject: [PATCH 352/418] just pass the controller directly simplifies this alot --- src/sdl/i_system.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 4a64a7c5d..0353d1b70 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1494,12 +1494,7 @@ void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, (void)high_strength; (void)duration; #else - - INT32 device_id = I_GetJoystickDeviceIndex(JoyInfo[playernum].dev); - - I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher - - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id); + SDL_GameController *controller = JoyInfo[playernum].dev; if (controller == NULL) { return; @@ -1517,12 +1512,7 @@ void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 b (void)green; (void)blue; #else - - INT32 device_id = I_GetJoystickDeviceIndex(JoyInfo[playernum].dev); - - I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher - - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id); + SDL_GameController *controller = JoyInfo[playernum].dev; if (controller == NULL) { return; From b42338ea3861ed2f6e352ab346f1cc62f8ff735d Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 7 Feb 2025 20:03:13 +0300 Subject: [PATCH 353/418] Don't force specific characters in M_HandleConnectIP --- 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 82d8a454d..523930a01 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10580,8 +10580,9 @@ static void M_HandleConnectIP(INT32 choice) default: // Rudimentary number and period enforcing - also allows letters so hostnames can be used instead - if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z') - || (choice >= 199 && choice <= 211 && choice != 202 && choice != 206)) //numpad too! + // ctrl-v allows to bypass that anyway, so we just remove that for now to allow stuff like shift+insert + /*if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z') + || (choice >= 199 && choice <= 211 && choice != 202 && choice != 206))*/ //numpad too! { if (M_TextInputHandle(&setupm_input_ip, choice)) S_StartSound(NULL,sfx_menu1); // Tails From 6532dacbb184b566bf8cc4999141c2b7e681ce19 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Feb 2025 15:36:33 +0100 Subject: [PATCH 354/418] change speelines blending condition uuuhh, so, if you have sneakerboost they always will apply additive blending otherwise if you go really fast (faster than sneakerboost) --- src/k_kart.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 3e0aa0788..6336bb26b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5409,6 +5409,25 @@ void K_KartPlayerHUDUpdate(player_t *player) player->kartstuff[k_cardanimation] = 0; } +static boolean K_SpeedLinesShouldBlend(player_t *player) +{ + fixed_t percentspeed = 0; + + if (!player->mo) + return false; + + if (player->kartstuff[k_sneakertimer]) + return true; + + // this is how the percentage speedometer calcs, i suck at maths so this was the easiest thing to fo lmao + percentspeed = (FixedDiv(player->speed, FixedMul(K_GetKartSpeed(player, false), ORIG_FRICTION))*100)>>FRACBITS; + + if (percentspeed > 127) // sneaker boost is around 25% + return true; + + return false; +} + typedef INT32 (*randomFunc)(INT32 min, INT32 max); static inline void K_SpawnNormalSpeedLines(player_t *player, boolean synched) @@ -5430,7 +5449,7 @@ static inline void K_SpawnNormalSpeedLines(player_t *player, boolean synched) if (cv_coloredspeedlines.value) { - const boolean goodSpeed = (player->speed >= (3*K_GetKartSpeed(player, false))/4); + const boolean colorSpeed = (player->speed >= (3*K_GetKartSpeed(player, false))/4); if (player->kartstuff[k_eggmanexplode]) { @@ -5443,7 +5462,7 @@ static inline void K_SpawnNormalSpeedLines(player_t *player, boolean synched) fast->color = player->mo->color; fast->colorized = true; } - else if (goodSpeed) + else if (colorSpeed) { UINT8 driftcolor = SKINCOLOR_NONE; @@ -5461,7 +5480,7 @@ static inline void K_SpawnNormalSpeedLines(player_t *player, boolean synched) fast->colorized = true; } - if (goodSpeed && ((player->kartstuff[k_growshrinktimer] > 0) || player->kartstuff[k_invincibilitytimer] || player->kartstuff[k_sneakertimer])) + if (colorSpeed && K_SpeedLinesShouldBlend(player)) fast->blendmode = AST_ADD; } } From 73ea95ae61c90f7b1ad0d28718ef9c7573ae68e4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 7 Feb 2025 04:05:10 +0100 Subject: [PATCH 355/418] just pass the controller directly simplifies this alot --- src/sdl/i_system.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 6ea659b70..65239b6a4 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1491,12 +1491,7 @@ void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, (void)high_strength; (void)duration; #else - - INT32 device_id = I_GetJoystickDeviceIndex(JoyInfo[playernum].dev); - - I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher - - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id); + SDL_GameController *controller = JoyInfo[playernum].dev; if (controller == NULL) { return; @@ -1514,12 +1509,7 @@ void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 b (void)green; (void)blue; #else - - INT32 device_id = I_GetJoystickDeviceIndex(JoyInfo[playernum].dev); - - I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher - - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id); + SDL_GameController *controller = JoyInfo[playernum].dev; if (controller == NULL) { return; From d3338f5d81e9c29c9dc00051b98646cc177c6a8b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Feb 2025 16:33:06 +0100 Subject: [PATCH 356/418] attemp to fix playerreborn resetting keepmusic --- src/g_game.c | 15 +++++++++++---- src/s_sound.c | 20 ++++++++++++++------ src/s_sound.h | 1 + 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ea794c574..edfab6d88 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2304,10 +2304,17 @@ void G_PlayerReborn(INT32 player) { if (mapmusflags & MUSIC_RELOADRESET) { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); - mapmusposition = mapheaderinfo[gamemap-1]->muspos; + if (keepmusic) + { + S_CopyKeepMusicStuff(); + } + else + { + strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); + mapmusname[6] = 0; + mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); + mapmusposition = mapheaderinfo[gamemap-1]->muspos; + } mapmusresume = 0; songcredit = true; } diff --git a/src/s_sound.c b/src/s_sound.c index b49e8e0d1..4f3a342d6 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1830,8 +1830,6 @@ void S_StopMusic(void) mapmusresume = (cv_birdmusic.value && (strcasecmp(music_name, mapmusname) == 0)) ? I_GetSongPosition() : 0; - S_SetKeepMusicPosition(); - if (I_SongPaused()) I_ResumeSong(); @@ -1998,6 +1996,16 @@ static void S_ClearKeepMusicPosition(void) keepmusposition = 0; } +void S_CopyKeepMusicStuff(void) +{ + strncpy(mapmusname, keepmusname, 7); + mapmusflags = keepmusflags; + if (keepmusicresume) + mapmusposition = keepmusposition; + else + mapmusposition = mapheaderinfo[gamemap-1]->muspos; +} + // determine if we should keep the music on a map restart void S_KeepMusic(void) { @@ -2005,6 +2013,8 @@ void S_KeepMusic(void) static boolean oldencore = false; const boolean musicchanged = S_CheckMusicException(); + S_SetKeepMusicPosition(); + if (!cv_keepmusic.value) { keepmusic = keepmusicresume = false; @@ -2033,11 +2043,9 @@ void S_InitMapMusic(void) { if (mapmusflags & MUSIC_RELOADRESET) { - if (keepmusic && keepmusicresume) + if (keepmusic) { - strncpy(mapmusname, keepmusname, 7); - mapmusflags = keepmusflags; - mapmusposition = keepmusposition; + S_CopyKeepMusicStuff(); } else { diff --git a/src/s_sound.h b/src/s_sound.h index a22e0aaeb..cce96add9 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -115,6 +115,7 @@ void S_InitMapMusic(void); void S_StartMapMusic(void); void S_KeepMusic(void); +void S_CopyKeepMusicStuff(void); // Stops music and restarts it from same position. Used for instant applying changes to amiga filters. void S_RestartMusic(void); From ccd2855e01284b088eb19b1eddea97c5783a44fb Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Feb 2025 16:47:41 +0100 Subject: [PATCH 357/418] always save keepmusic stuff but set keepmusresume in stopmusic Zzz... --- src/g_game.c | 2 +- src/s_sound.c | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index edfab6d88..4e2735ba1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2306,7 +2306,7 @@ void G_PlayerReborn(INT32 player) { if (keepmusic) { - S_CopyKeepMusicStuff(); + S_CopyKeepMusicStuff(); // this is horrible, why do we COMPLETELY need to reset the music on respawn?? oh well } else { diff --git a/src/s_sound.c b/src/s_sound.c index 4f3a342d6..21f65b93f 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -125,6 +125,7 @@ static char keepmusname[7]; static UINT32 keepmusresume = 0; static UINT16 keepmusflags = 0; static UINT32 keepmusposition = 0; +static void S_SetKeepMusResume(void); #ifdef HAVE_OPENMPT openmpt_module *openmpt_mhandle = NULL; @@ -1830,6 +1831,8 @@ void S_StopMusic(void) mapmusresume = (cv_birdmusic.value && (strcasecmp(music_name, mapmusname) == 0)) ? I_GetSongPosition() : 0; + S_SetKeepMusResume(); + if (I_SongPaused()) I_ResumeSong(); @@ -1971,6 +1974,14 @@ void S_ResetKeepAndSpecialMus(void) keepmusic = skipintromus = false; } +static void S_SetKeepMusResume(void) +{ + if (strcasecmp(music_name, mapmusname) == 0) + { + keepmusresume = I_GetSongPosition(); + } +} + // save some values static void S_SetKeepMusicPosition(void) { @@ -1979,13 +1990,9 @@ static void S_SetKeepMusicPosition(void) return; } - if (strcasecmp(music_name, mapmusname) == 0) - { - strncpy(keepmusname, mapmusname, 7); - keepmusresume = I_GetSongPosition(); - keepmusflags = mapmusflags; - keepmusposition = mapmusposition; - } + strncpy(keepmusname, mapmusname, 7); + keepmusflags = mapmusflags; + keepmusposition = mapmusposition; } static void S_ClearKeepMusicPosition(void) @@ -1998,12 +2005,14 @@ static void S_ClearKeepMusicPosition(void) void S_CopyKeepMusicStuff(void) { + if (!cv_keepmusic.value) + { + return; + } + strncpy(mapmusname, keepmusname, 7); mapmusflags = keepmusflags; - if (keepmusicresume) - mapmusposition = keepmusposition; - else - mapmusposition = mapheaderinfo[gamemap-1]->muspos; + mapmusposition = keepmusposition; } // determine if we should keep the music on a map restart From c1743eb18d6739af4169ae56de66b73bc03dec3c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Feb 2025 17:20:26 +0100 Subject: [PATCH 358/418] Revert "Update position nums to use additive" for now since it doesent work that well on bright maps, yes there is a mapheader , but cant expect anyone to go trough all maps and add it This reverts commit 323fbb4713ae562ee3e3f347ca439727fd736896. --- src/dehacked.c | 8 -------- src/k_kart.c | 42 ++++++++++++------------------------------ 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 7722d777b..5189af4bb 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1070,13 +1070,6 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) else mapheaderinfo[num-1]->levelflags &= ~LF_SECTIONRACE; } - else if (fastcmp(word, "SUBTRACTNUM")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_SUBTRACTNUM; - else - mapheaderinfo[num-1]->levelflags &= ~LF_SUBTRACTNUM; - } // Individual triggers for menu flags else if (fastcmp(word, "HIDDEN")) @@ -7847,7 +7840,6 @@ struct { {"LF_NORELOAD",LF_NORELOAD}, {"LF_NOZONE",LF_NOZONE}, {"LF_SECTIONRACE",LF_SECTIONRACE}, - {"LF_SUBTRACTNUM",LF_SUBTRACTNUM}, // And map flags {"LF2_HIDEINMENU",LF2_HIDEINMENU}, {"LF2_HIDEINSTATS",LF2_HIDEINSTATS}, diff --git a/src/k_kart.c b/src/k_kart.c index 6336bb26b..0d7777ef9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8786,7 +8786,6 @@ static void K_DrawKartPositionNum(INT32 num) INT32 W = SHORT(kp_positionnum[0][0]->width); fixed_t scale = FRACUNIT; patch_t *localpatch = kp_positionnum[0][0]; - INT32 addOrSub = B_ADD; //INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTORIGHT); INT32 fx = 0, fy = 0, fflags = 0; INT32 xoffs = wheeloffs ? -48 : 0; @@ -8794,11 +8793,6 @@ 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 ((mapheaderinfo[gamemap - 1]->levelflags & LF_SUBTRACTNUM) == LF_SUBTRACTNUM) - { - addOrSub = B_SUBTRACT; - } - if ((cv_posanim.value && stplyr->kartstuff[k_positiondelay]) || stplyr->exiting) { scale *= 2; @@ -8806,9 +8800,7 @@ static void K_DrawKartPositionNum(INT32 num) } if (splitscreen || cv_smallposnum.value || wheeloffs) - { scale /= 2; - } W = FixedMul(W<>FRACBITS; @@ -8855,46 +8847,38 @@ static void K_DrawKartPositionNum(INT32 num) } // Special case for 0 - if (num <= 0) + if (!num) { - V_DrawBlendingFixedPatch(fx<= 0); // This function does not draw negative numbers + // Draw the number while (num) { if (win) // 1st place winner? You get rainbows!! - { localpatch = kp_winnernum[(leveltime % (NUMWINFRAMES*3)) / 3]; - } else if (stplyr->laps+1 >= cv_numlaps.value || stplyr->exiting) // Check for the final lap, or won { - boolean useRedNums = K_IsPlayerLosing(stplyr); - - if (addOrSub == B_SUBTRACT) - { - // Subtracting RED will look BLUE, and vice versa. - useRedNums = !useRedNums; - } - // Alternate frame every three frames - switch ((leveltime % 9) / 3) + switch (leveltime % 9) { - case 0: - if (useRedNums == true) + case 1: case 2: case 3: + if (K_IsPlayerLosing(stplyr)) localpatch = kp_positionnum[num % 10][4]; else localpatch = kp_positionnum[num % 10][1]; break; - case 1: - if (useRedNums == true) + case 4: case 5: case 6: + if (K_IsPlayerLosing(stplyr)) localpatch = kp_positionnum[num % 10][5]; else localpatch = kp_positionnum[num % 10][2]; break; - case 2: - if (useRedNums == true) + case 7: case 8: case 9: + if (K_IsPlayerLosing(stplyr)) localpatch = kp_positionnum[num % 10][6]; else localpatch = kp_positionnum[num % 10][3]; @@ -8905,11 +8889,9 @@ static void K_DrawKartPositionNum(INT32 num) } } else - { localpatch = kp_positionnum[num % 10][0]; - } - V_DrawBlendingFixedPatch((fx<width)*scale/2) : 0), (fy<height)*scale/2) : 0), scale, V_HUDTRANSHALF|fflags, localpatch, NULL, addOrSub); + V_DrawFixedPatch((fx<width)*scale/2) : 0), (fy<height)*scale/2) : 0), scale, V_HUDTRANSHALF|fflags, localpatch, NULL); // ^ if we overtake as p1 or p3 in splitscren, we shift it so that it doesn't go off screen. // ^ if we overtake as p1 in 2p splits, shift vertically so that this doesn't happen either. From 0aec9a85bb8fae7105c48942d64b30881d142a7a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Feb 2025 17:25:01 +0100 Subject: [PATCH 359/418] rename this --- src/s_sound.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 21f65b93f..0ad207cb0 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -113,7 +113,6 @@ consvar_t cv_resume = {"resume", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0 consvar_t cv_fading = {"fading", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_birdmusic = {"birdmusicstuff", "No", CV_SAVE|CV_CALL, CV_YesNo, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_keepmusic = {"keepmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; //consvar_t cv_ignoremusicchanges = {"ignoremusicchanges", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -126,6 +125,7 @@ static UINT32 keepmusresume = 0; static UINT16 keepmusflags = 0; static UINT32 keepmusposition = 0; static void S_SetKeepMusResume(void); +static void S_SetKeepMusicStuff(void); #ifdef HAVE_OPENMPT openmpt_module *openmpt_mhandle = NULL; @@ -200,8 +200,6 @@ static INT32 numofchannels = 0; // static void S_StopChannel(INT32 cnum); -static void S_SetKeepMusicPosition(void); - // // S_getChannel // @@ -1767,7 +1765,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; } - //S_SetKeepMusicPosition(); + //S_SetKeepMusicStuff(); if (prefadems && S_MusicPlaying()) // queue music change for after fade // allow even if the music is the same { @@ -1983,7 +1981,7 @@ static void S_SetKeepMusResume(void) } // save some values -static void S_SetKeepMusicPosition(void) +static void S_SetKeepMusicStuff(void) { if (!cv_keepmusic.value) { @@ -2022,7 +2020,7 @@ void S_KeepMusic(void) static boolean oldencore = false; const boolean musicchanged = S_CheckMusicException(); - S_SetKeepMusicPosition(); + S_SetKeepMusicStuff(); if (!cv_keepmusic.value) { From eb512022e026910c74b66eb4a2e1be8a97d31eac Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Feb 2025 17:52:18 +0100 Subject: [PATCH 360/418] handle music reloadreset stuff in seperate function just tryin make it less ugly --- src/g_game.c | 13 +------------ src/s_sound.c | 37 ++++++++++++++++++++++--------------- src/s_sound.h | 1 + 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 4e2735ba1..5e9bc1077 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2304,18 +2304,7 @@ void G_PlayerReborn(INT32 player) { if (mapmusflags & MUSIC_RELOADRESET) { - if (keepmusic) - { - S_CopyKeepMusicStuff(); // this is horrible, why do we COMPLETELY need to reset the music on respawn?? oh well - } - else - { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); - mapmusposition = mapheaderinfo[gamemap-1]->muspos; - } - mapmusresume = 0; + S_HandleReloadResetMusic(); songcredit = true; } } diff --git a/src/s_sound.c b/src/s_sound.c index 0ad207cb0..569ba5af9 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2041,6 +2041,27 @@ void S_KeepMusic(void) oldmap = gamemap; } +void S_HandleReloadResetMusic(void) +{ + if (!(mapmusflags & MUSIC_RELOADRESET)) + return; + + if (keepmusic) + { + // this is horrible, this copies over everything about the mapmusic into temporary variables to reuse + S_CopyKeepMusicStuff(); + } + else + { + strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); + mapmusname[6] = 0; + mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); + mapmusposition = mapheaderinfo[gamemap-1]->muspos; + } + + mapmusresume = 0; +} + // // Per level startup code. // Kills playing sounds at start of level, @@ -2048,21 +2069,7 @@ void S_KeepMusic(void) // void S_InitMapMusic(void) { - if (mapmusflags & MUSIC_RELOADRESET) - { - if (keepmusic) - { - S_CopyKeepMusicStuff(); - } - else - { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); - mapmusposition = mapheaderinfo[gamemap-1]->muspos; - } - mapmusresume = 0; - } + S_HandleReloadResetMusic(); if (keepmusic) { diff --git a/src/s_sound.h b/src/s_sound.h index cce96add9..089008174 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -113,6 +113,7 @@ void S_ResetKeepAndSpecialMus(void); void S_InitMapMusic(void); void S_StartMapMusic(void); +void S_HandleReloadResetMusic(void); void S_KeepMusic(void); void S_CopyKeepMusicStuff(void); From e1a02a0729c4d9e9e2b3a49d5931f43de1fae69f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Feb 2025 17:52:44 +0100 Subject: [PATCH 361/418] throw music vars into a struct "mapmusic_t" simplifies everything, keepmusic vars use it too --- src/dehacked.c | 6 ++-- src/doomstat.h | 16 ++++++--- src/g_game.c | 9 ++---- src/p_saveg.c | 2 +- src/p_spec.c | 20 ++++++------ src/p_user.c | 10 +++--- src/s_sound.c | 88 +++++++++++++++++++++++++------------------------- src/s_sound.h | 2 +- 8 files changed, 78 insertions(+), 75 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 5189af4bb..3e64e1ed1 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9227,8 +9227,8 @@ int LUA_EnumLib(lua_State *L) PUSHGETTER(globalweather, u8); PUSHGETTER(levelskynum, i32); PUSHGETTER(globallevelskynum, i32); - PUSHGETTER(mapmusflags, u16); - PUSHGETTER(mapmusposition, u32); + PUSHGETTER(mapmusic.flags, u16); + PUSHGETTER(mapmusic.position, u32); PUSHGETTER(gravity, fxp); PUSHGETTER(gamespeed, u8); PUSHGETTER(encoremode, bool); @@ -9245,7 +9245,7 @@ int LUA_EnumLib(lua_State *L) lua_pushcfunction(L, lua_glib_new_getter); lua_pushliteral(L, "mapmusname"); - lua_glib_push_str_getter(L, mapmusname); + lua_glib_push_str_getter(L, mapmusic.name); lua_call(L, 2, 0); lua_pushcfunction(L, lua_glib_new_getter); diff --git a/src/doomstat.h b/src/doomstat.h index b3290b884..b0be7113d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -30,16 +30,22 @@ // ============================= // Selected by user. -extern INT16 gamemap; -extern char mapmusname[7]; -extern UINT16 mapmusflags; -extern UINT32 mapmusposition; -extern UINT32 mapmusresume; + +typedef struct +{ + char name[7]; // Music name + UINT16 flags; // Track and reset bit + UINT32 position; // Position to jump to + UINT32 resume; // Saved Position when music was stopped +} mapmusic_t; +extern mapmusic_t mapmusic; + #define MUSIC_TRACKMASK 0x0FFF // ----************ #define MUSIC_RELOADRESET 0x8000 // *--------------- #define MUSIC_FORCERESET 0x4000 // -*-------------- // Use other bits if necessary. +extern INT16 gamemap; extern INT16 maptol; extern UINT8 globalweather; extern INT32 curWeather; diff --git a/src/g_game.c b/src/g_game.c index 5e9bc1077..6144a500d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -85,10 +85,7 @@ static void G_DoStartVote(void); static void G_ResetDemoPlayback(char *pdemoname); -char mapmusname[7]; // Music name -UINT16 mapmusflags; // Track and reset bit -UINT32 mapmusposition; // Position to jump to -UINT32 mapmusresume; +mapmusic_t mapmusic; INT16 gamemap = 1; INT16 maptol; @@ -2302,7 +2299,7 @@ void G_PlayerReborn(INT32 player) if (p-players == consoleplayer) { - if (mapmusflags & MUSIC_RELOADRESET) + if (mapmusic.flags & MUSIC_RELOADRESET) { S_HandleReloadResetMusic(); songcredit = true; @@ -4059,7 +4056,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool globalweather = mapheaderinfo[gamemap-1]->weather; // Don't carry over custom music change to another map. - mapmusflags |= MUSIC_RELOADRESET; + mapmusic.flags |= MUSIC_RELOADRESET; automapactive = false; imcontinuing = false; diff --git a/src/p_saveg.c b/src/p_saveg.c index 4f52bf900..d7e592431 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3351,7 +3351,7 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, bool // tell the sound code to reset the music since we're skipping what // normally sets this flag if (!reloading) - mapmusflags |= MUSIC_RELOADRESET; + mapmusic.flags |= MUSIC_RELOADRESET; G_SetGamestate(READINT16(save->p)); diff --git a/src/p_spec.c b/src/p_spec.c index 61c0a010a..d64ca35fe 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2080,7 +2080,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 413: // Change music - if (keepmusic && (leveltime <= MUSICSTARTTIME)) // why check for starttime? cause encore music Zzz... + if (keepmapmusic && (leveltime <= MUSICSTARTTIME)) // why check for starttime? cause encore music Zzz... return; //if (cv_ignoremusicchanges.value && (leveltime >= MUSICSTARTTIME) && !fromlapexec) // keep lap music intanct tho @@ -2128,19 +2128,19 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Change the music and apply position/fade operations else { - strncpy(mapmusname, sides[line->sidenum[0]].text, 7); - mapmusname[6] = 0; + strncpy(mapmusic.name, sides[line->sidenum[0]].text, 7); + mapmusic.name[6] = 0; - mapmusflags = tracknum & MUSIC_TRACKMASK; + mapmusic.flags = tracknum & MUSIC_TRACKMASK; if (!(line->flags & ML_BLOCKMONSTERS)) - mapmusflags |= MUSIC_RELOADRESET; + mapmusic.flags |= MUSIC_RELOADRESET; if (line->flags & ML_BOUNCY) - mapmusflags |= MUSIC_FORCERESET; + mapmusic.flags |= MUSIC_FORCERESET; - mapmusposition = position; - mapmusresume = 0; + mapmusic.position = position; + mapmusic.resume = 0; - S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position, + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, !(line->flags & ML_EFFECT4), position, !(line->flags & ML_EFFECT2) ? prefadems : 0, !(line->flags & ML_EFFECT2) ? postfadems : 0); @@ -2167,7 +2167,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT32 sfxnum; //dont play any funky sound intros that may interfere with the music - if ((skipintromus || keepmusic) && (leveltime < MUSICSTARTTIME)) + if ((skipintromus || keepmapmusic) && (leveltime < MUSICSTARTTIME)) return; sfxnum = sides[line->sidenum[0]].toptexture; //P_AproxDistance(line->dx, line->dy)>>FRACBITS; diff --git a/src/p_user.c b/src/p_user.c index addbefbe4..852d2b6be 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -788,14 +788,14 @@ void P_RestoreMusic(player_t *player) if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1)) S_SpeedMusic(1.2f); #endif - if (mapmusresume && cv_resume.value) // mapmusresume will be 0 anyways when birdmusic stuff is disabled - position = mapmusresume; + if (mapmusic.resume && cv_resume.value) // mapmusresume will be 0 anyways when birdmusic stuff is disabled + position = mapmusic.resume; else - position = mapmusposition; + position = mapmusic.position; - S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn()); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, position, 0, S_GetRestoreMusicFadeIn()); S_ClearRestoreMusicFadeInCvar(); - mapmusresume = 0; + mapmusic.resume = 0; } } } diff --git a/src/s_sound.c b/src/s_sound.c index 569ba5af9..42efd4a01 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -117,13 +117,10 @@ consvar_t cv_keepmusic = {"keepmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, N consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; //consvar_t cv_ignoremusicchanges = {"ignoremusicchanges", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -boolean keepmusic = false; // keep the current music on map restart +boolean keepmapmusic = false; // keep the current music on map restart boolean skipintromus = false; // skip the intro fanfare static boolean keepmusicresume = false; -static char keepmusname[7]; -static UINT32 keepmusresume = 0; -static UINT16 keepmusflags = 0; -static UINT32 keepmusposition = 0; +mapmusic_t keepmusic; static void S_SetKeepMusResume(void); static void S_SetKeepMusicStuff(void); @@ -1827,7 +1824,7 @@ void S_StopMusic(void) || demo.title) // SRB2Kart: Demos don't interrupt title screen music return; - mapmusresume = (cv_birdmusic.value && (strcasecmp(music_name, mapmusname) == 0)) ? I_GetSongPosition() : 0; + mapmusic.resume = (cv_birdmusic.value && (strcasecmp(music_name, mapmusic.name) == 0)) ? I_GetSongPosition() : 0; S_SetKeepMusResume(); @@ -1956,6 +1953,9 @@ static const char *musicexception_list[] = { // check if the current music is smth we dont want to keep (vote music, etc) static boolean S_CheckMusicException(void) { + if (stricmp(music_name, mapmusic.name)) + return true; + for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) { if (!stricmp(music_name, musicexception_list[i]) || !stricmp(checkmusic, musicexception_list[i])) @@ -1969,14 +1969,14 @@ static boolean S_CheckMusicException(void) void S_ResetKeepAndSpecialMus(void) { - keepmusic = skipintromus = false; + keepmapmusic = skipintromus = false; } static void S_SetKeepMusResume(void) { - if (strcasecmp(music_name, mapmusname) == 0) + if (strcasecmp(music_name, mapmusic.name) == 0) { - keepmusresume = I_GetSongPosition(); + keepmusic.resume = I_GetSongPosition(); } } @@ -1988,17 +1988,17 @@ static void S_SetKeepMusicStuff(void) return; } - strncpy(keepmusname, mapmusname, 7); - keepmusflags = mapmusflags; - keepmusposition = mapmusposition; + strncpy(keepmusic.name, mapmusic.name, 7); + keepmusic.flags = mapmusic.flags; + keepmusic.position = mapmusic.position; } static void S_ClearKeepMusicPosition(void) { - memset(keepmusname, 0, sizeof(keepmusname)); - keepmusresume = 0; - keepmusflags = 0; - keepmusposition = 0; + memset(keepmusic.name, 0, sizeof(keepmusic.name)); + keepmusic.resume = 0; + keepmusic.flags = 0; + keepmusic.position = 0; } void S_CopyKeepMusicStuff(void) @@ -2008,9 +2008,9 @@ void S_CopyKeepMusicStuff(void) return; } - strncpy(mapmusname, keepmusname, 7); - mapmusflags = keepmusflags; - mapmusposition = keepmusposition; + strncpy(mapmusic.name, keepmusic.name, 7); + mapmusic.flags = keepmusic.flags; + mapmusic.position = keepmusic.position; } // determine if we should keep the music on a map restart @@ -2024,16 +2024,16 @@ void S_KeepMusic(void) if (!cv_keepmusic.value) { - keepmusic = keepmusicresume = false; + keepmapmusic = keepmusicresume = false; } else if (oldmap == gamemap && oldencore == encoremode) { - keepmusicresume = (musicchanged && keepmusresume); - keepmusic = (!musicchanged || keepmusicresume); + keepmusicresume = (musicchanged && keepmusic.resume); + keepmapmusic = (!musicchanged || keepmusicresume); } else { - keepmusic = keepmusicresume = false; + keepmapmusic = keepmusicresume = false; S_ClearKeepMusicPosition(); } @@ -2043,23 +2043,23 @@ void S_KeepMusic(void) void S_HandleReloadResetMusic(void) { - if (!(mapmusflags & MUSIC_RELOADRESET)) + if (!(mapmusic.flags & MUSIC_RELOADRESET)) return; - if (keepmusic) + if (keepmapmusic) { // this is horrible, this copies over everything about the mapmusic into temporary variables to reuse S_CopyKeepMusicStuff(); } else { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); - mapmusposition = mapheaderinfo[gamemap-1]->muspos; + strncpy(mapmusic.name, mapheaderinfo[gamemap-1]->musname, 7); + mapmusic.name[6] = 0; + mapmusic.flags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); + mapmusic.position = mapheaderinfo[gamemap-1]->muspos; } - mapmusresume = 0; + mapmusic.resume = 0; } // @@ -2071,11 +2071,11 @@ void S_InitMapMusic(void) { S_HandleReloadResetMusic(); - if (keepmusic) + if (keepmapmusic) { // this is kinda silly, but we can use it to fade back into the map song at the saved point, should the current music be different from the map music if (keepmusicresume) - S_ChangeMusicEx(mapmusname, mapmusflags, true, keepmusresume, 0, 500); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, keepmusic.resume, 0, 500); return; } @@ -2100,7 +2100,7 @@ void S_InitMapMusic(void) if (leveltime < MUSICSTARTTIME) // SRB2Kart S_ChangeMusicInternal((encoremode ? "estart" : "kstart"), false); //S_StopMusic(); - //S_ChangeMusicEx((encoremode ? "estart" : "kstart"), 0, false, mapmusposition, 0, 0); + //S_ChangeMusicEx((encoremode ? "estart" : "kstart"), 0, false, mapmusic.position, 0, 0); } void S_StartMapMusic(void) @@ -2109,13 +2109,13 @@ void S_StartMapMusic(void) if (leveltime > MUSICSTARTTIME) return; - if (keepmusic) + if (keepmapmusic) return; if (skipintromus) { if (leveltime < starttime) - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); if (leveltime == MUSICSTARTTIME) S_ShowMusicCredit(); return; @@ -2127,7 +2127,7 @@ void S_StartMapMusic(void) S_StopMusic(); else if (leveltime == MUSICSTARTTIME) // Plays the music after the starting countdown. { - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); S_ShowMusicCredit(); } } @@ -2177,7 +2177,7 @@ static void Command_Tunes_f(void) if (!strcasecmp(tunearg, "-show")) { CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"), - mapmusname, (mapmusflags & MUSIC_TRACKMASK)); + mapmusic.name, (mapmusic.flags & MUSIC_TRACKMASK)); return; } if (!strcasecmp(tunearg, "-none")) @@ -2205,19 +2205,19 @@ static void Command_Tunes_f(void) track = (UINT16)atoi(COM_Argv(2))-1; if (tunenum) - snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum)); + snprintf(mapmusic.name, 7, "%sM", G_BuildMapName(tunenum)); else - strncpy(mapmusname, tunearg, 7); + strncpy(mapmusic.name, tunearg, 7); if (argc > 4) position = (UINT32)atoi(COM_Argv(4)); - mapmusname[6] = 0; - mapmusflags = (track & MUSIC_TRACKMASK); - mapmusposition = position; - mapmusresume = 0; + mapmusic.name[6] = 0; + mapmusic.flags = (track & MUSIC_TRACKMASK); + mapmusic.position = position; + mapmusic.resume = 0; - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); if (argc > 3) { diff --git a/src/s_sound.h b/src/s_sound.h index 089008174..4ed52d7bb 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -71,7 +71,7 @@ extern consvar_t cv_birdmusic; extern consvar_t cv_keepmusic; extern consvar_t cv_skipintromusic; //extern consvar_t cv_ignoremusicchanges; -extern boolean keepmusic; +extern boolean keepmapmusic; extern boolean skipintromus; #define MUSICSTARTTIME (starttime + (TICRATE/2)) From 27b190cadfb435f5df4df75e289c92e548ee6fdc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Feb 2025 17:48:00 +0100 Subject: [PATCH 362/418] this should be static --- src/s_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 42efd4a01..d354dbef3 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -120,7 +120,7 @@ consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL, boolean keepmapmusic = false; // keep the current music on map restart boolean skipintromus = false; // skip the intro fanfare static boolean keepmusicresume = false; -mapmusic_t keepmusic; +static mapmusic_t keepmusic; static void S_SetKeepMusResume(void); static void S_SetKeepMusicStuff(void); From c010b7319e3398aaca97ce9b246da558506ea0d3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Feb 2025 18:09:52 +0100 Subject: [PATCH 363/418] fix oopsie with mapmusic in glib --- src/dehacked.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 3e64e1ed1..fd90c380e 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9227,8 +9227,6 @@ int LUA_EnumLib(lua_State *L) PUSHGETTER(globalweather, u8); PUSHGETTER(levelskynum, i32); PUSHGETTER(globallevelskynum, i32); - PUSHGETTER(mapmusic.flags, u16); - PUSHGETTER(mapmusic.position, u32); PUSHGETTER(gravity, fxp); PUSHGETTER(gamespeed, u8); PUSHGETTER(encoremode, bool); @@ -9243,6 +9241,16 @@ int LUA_EnumLib(lua_State *L) PUSHGETTER(racecountdown, u32); PUSHGETTER(exitcountdown, u32); + lua_pushcfunction(L, lua_glib_new_getter); + lua_pushliteral(L, "mapmusflags"); + lua_glib_push_u16_getter(L, &mapmusic.flags); + lua_call(L, 2, 0); + + lua_pushcfunction(L, lua_glib_new_getter); + lua_pushliteral(L, "mapmusposition"); + lua_glib_push_u32_getter(L, &mapmusic.position); + lua_call(L, 2, 0); + lua_pushcfunction(L, lua_glib_new_getter); lua_pushliteral(L, "mapmusname"); lua_glib_push_str_getter(L, mapmusic.name); From 29817d6627d6d534ed51159af69154f45ed1a2a2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Feb 2025 23:07:39 +0100 Subject: [PATCH 364/418] fix clang uninitialised warning --- src/hardware/hw_draw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 14a7c479d..e4db56ab5 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -288,17 +288,17 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t v[0].t = v[1].t = 0.0f; v[2].t = v[3].t = gpatch->max_t; - if (option & V_WRAPX) - flags |= PF_ForceWrapX; - if (option & V_WRAPY) - flags |= PF_ForceWrapY; - // clip it since it is used for bunny scroll in doom I if (blendmode) flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; else flags = PF_Translucent|PF_NoDepthTest; + if (option & V_WRAPX) + flags |= PF_ForceWrapX; + if (option & V_WRAPY) + flags |= PF_ForceWrapY; + if (alphalevel) { FSurfaceInfo Surf; From 5e7c12dac76da19ee8f1e3ab0522e731b86775db Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Feb 2025 23:17:43 +0100 Subject: [PATCH 365/418] optimize ogl drawer functions by avoiding excessive interger to float conversions --- src/hardware/hw_draw.c | 146 +++++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 64 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index e4db56ab5..dc363dd1a 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -62,6 +62,9 @@ static UINT8 softwaretranstogl[11] = { 0, 25, 51, 76,102,127,153,178,204,229 static UINT8 softwaretranstogl_hi[11] = { 0, 51,102,153,204,255,255,255,255,255,255}; static UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111,127}; +static const float FLOATBASEVIDWIDTH = (float)BASEVIDWIDTH; +static const float FLOATBASEVIDHEIGHT = (float)BASEVIDHEIGHT; + // // -----------------+ // HWR_DrawPatch : Draw a 'tile' graphic @@ -144,6 +147,9 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t if (alphalevel >= 10 && alphalevel < 13) return; + const float fvw = (float)vid.width; + const float fvh = (float)vid.height; + // make patch ready in hardware cache if (!colormap) HWR_GetPatch(gpatch); @@ -227,21 +233,21 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t Z_Free(realpatch); } // centre screen - if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) + if (fabsf(fvw - FLOATBASEVIDWIDTH * dupx) > 1.0E-36f) { if (option & V_SNAPTORIGHT) - cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); + cx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(option & V_SNAPTOLEFT)) - cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/2; + cx += (fvw - (FLOATBASEVIDWIDTH * dupx))/2; } - if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) + if (fabsf(fvh - FLOATBASEVIDHEIGHT * dupy) > 1.0E-36f) { if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) - cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); + cy += (fvh/2 - (FLOATBASEVIDHEIGHT/2 * dupy)); else if (option & V_SNAPTOBOTTOM) - cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); + cy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(option & V_SNAPTOTOP)) - cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/2; + cy += (fvh - (FLOATBASEVIDHEIGHT * dupy))/2; } } } @@ -258,12 +264,12 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t } // positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1 - cx = -1 + (cx / (vid.width/2)); - cy = 1 - (cy / (vid.height/2)); + cx = -1.0f + (cx / (vid.width / 2.0f)); + cy = 1.0f - (cy / (vid.height / 2.0f)); // fwidth and fheight are similar - fwidth /= vid.width / 2; - fheight /= vid.height / 2; + fwidth /= fvw / 2; + fheight /= fvh / 2; // set the polygon vertices to the right positions v[0].x = v[3].x = cx; @@ -333,6 +339,9 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal if (alphalevel >= 10 && alphalevel < 13) return; + const float fvw = (float)vid.width; + const float fvh = (float)vid.height; + // make patch ready in hardware cache HWR_GetPatch(gpatch); @@ -383,21 +392,21 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal Z_Free(realpatch); } // centre screen - if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) + if (fabsf(fvw - FLOATBASEVIDWIDTH * dupx) > 1.0E-36f) { if (option & V_SNAPTORIGHT) - cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); + cx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(option & V_SNAPTOLEFT)) - cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/2; + cx += (fvw - (FLOATBASEVIDWIDTH * dupx))/2; } - if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) + if (fabsf(fvh - FLOATBASEVIDHEIGHT * dupy) > 1.0E-36f) { if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) - cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); + cy += (fvh/2 - (FLOATBASEVIDHEIGHT/2 * dupy)); else if (option & V_SNAPTOBOTTOM) - cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); + cy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(option & V_SNAPTOTOP)) - cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/2; + cy += (fvh - (FLOATBASEVIDHEIGHT * dupy))/2; } } } @@ -429,12 +438,12 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal } // positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1 - cx = -1 + (cx / (vid.width/2)); - cy = 1 - (cy / (vid.height/2)); + cx = -1.0f + (cx / (vid.width / 2.0f)); + cy = 1.0f - (cy / (vid.height / 2.0f)); // fwidth and fheight are similar - fwidth /= vid.width / 2; - fheight /= vid.height / 2; + fwidth /= fvw / 2; + fheight /= fvh / 2; // set the polygon vertices to the right positions v[0].x = v[3].x = cx; @@ -819,6 +828,9 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) fy = (float)y; fw = fh = (float)wh; + const float fvw = (float)vid.width; + const float fvh = (float)vid.height; + if (!(color & V_NOSCALESTART)) { float dupx = (float)vid.dupx, dupy = (float)vid.dupy; @@ -828,20 +840,20 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) fw *= dupx; fh *= dupy; - if (fabsf((float)vid.width - ((float)BASEVIDWIDTH * dupx)) > 1.0E-36f) + if (fabsf(fvw - (FLOATBASEVIDWIDTH * dupx)) > 1.0E-36f) { if (color & V_SNAPTORIGHT) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(color & V_SNAPTOLEFT)) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2; + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)) / 2; } - if (fabsf((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) > 1.0E-36f) + if (fabsf(fvh - (FLOATBASEVIDHEIGHT * dupy)) > 1.0E-36f) { // same thing here if (color & V_SNAPTOBOTTOM) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(color & V_SNAPTOTOP)) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2; + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)) / 2; } } @@ -862,16 +874,16 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) return; if (fx + fw > vid.width) { - fwait = fw - ((float)vid.width - fx); - fw = (float)vid.width - fx; + fwait = fw - (fvw- fx); + fw = fvw - fx; } if (fy + fh > vid.height) - fh = (float)vid.height - fy; + fh = fvh - fy; - fx = -1 + fx / (vid.width / 2); - fy = 1 - fy / (vid.height / 2); - fw = fw / (vid.width / 2); - fh = fh / (vid.height / 2); + fx = -1.0f + fx / (vid.width / 2.0f); + fy = 1.0f - fy / (vid.height / 2.0f); + fw = fw / (fvw / 2); + fh = fh / (fvh / 2); v[0].x = v[3].x = fx; v[2].x = v[1].x = fx + fw; @@ -915,6 +927,9 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 fw = (float)w; fh = (float)h; + const float fvw = (float)vid.width; + const float fvh = (float)vid.height; + if (!(options & V_NOSCALESTART)) { float dupx = (float)vid.dupx, dupy = (float)vid.dupy; @@ -936,25 +951,25 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 fw *= dupx; fh *= dupy; - if (fabsf((float)vid.width - ((float)BASEVIDWIDTH * dupx)) > 1.0E-36f) + if (fabsf(fvw - (FLOATBASEVIDWIDTH * dupx)) > 1.0E-36f) { if (options & V_SNAPTORIGHT) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(options & V_SNAPTOLEFT)) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2; + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)) / 2; } - if (fabsf((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) > 1.0E-36f) + if (fabsf(fvh - (FLOATBASEVIDHEIGHT * dupy)) > 1.0E-36f) { // same thing here if (options & V_SNAPTOBOTTOM) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(options & V_SNAPTOTOP)) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2; + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)) / 2; } if (options & V_SPLITSCREEN) - fy += ((float)BASEVIDHEIGHT * dupy)/2; + fy += (FLOATBASEVIDHEIGHT * dupy)/2; if (options & V_HORZSCREEN) - fx += ((float)BASEVIDWIDTH * dupx)/2; + fx += (FLOATBASEVIDWIDTH * dupx)/2; } @@ -974,14 +989,14 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 if (fw <= 0 || fh <= 0) return; if (fx + fw > vid.width) - fw = (float)vid.width - fx; + fw = fvw - fx; if (fy + fh > vid.height) - fh = (float)vid.height - fy; + fh = fvh - fy; - fx = -1 + fx / (vid.width / 2); - fy = 1 - fy / (vid.height / 2); - fw = fw / (vid.width / 2); - fh = fh / (vid.height / 2); + fx = -1.0f + fx / (vid.width / 2.0f); + fy = 1.0f - fy / (vid.height / 2.0f); + fw = fw / (fvw / 2); + fh = fh / (fvh / 2); v[0].x = v[3].x = fx; v[2].x = v[1].x = fx + fw; @@ -1026,6 +1041,9 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) fw = (float)w; fh = (float)h; + const float fvw = (float)vid.width; + const float fvh = (float)vid.height; + if (!(color & V_NOSCALESTART)) { float dupx = (float)vid.dupx, dupy = (float)vid.dupy; @@ -1047,25 +1065,25 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) fw *= dupx; fh *= dupy; - if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) + if (fabsf(fvw - FLOATBASEVIDWIDTH * dupx) > 1.0E-36f) { if (color & V_SNAPTORIGHT) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(color & V_SNAPTOLEFT)) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2; + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)) / 2; } - if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) + if (fabsf(fvh - FLOATBASEVIDHEIGHT * dupy) > 1.0E-36f) { // same thing here if (color & V_SNAPTOBOTTOM) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(color & V_SNAPTOTOP)) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2; + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)) / 2; } if (color & V_SPLITSCREEN) - fy += ((float)BASEVIDHEIGHT * dupy)/2; + fy += (FLOATBASEVIDHEIGHT * dupy)/2; if (color & V_HORZSCREEN) - fx += ((float)BASEVIDWIDTH * dupx)/2; + fx += (FLOATBASEVIDWIDTH * dupx)/2; } @@ -1085,14 +1103,14 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) if (fw <= 0 || fh <= 0) return; if (fx + fw > vid.width) - fw = (float)vid.width - fx; + fw = fvw - fx; if (fy + fh > vid.height) - fh = (float)vid.height - fy; + fh = fvh - fy; - fx = -1 + fx / (vid.width / 2); - fy = 1 - fy / (vid.height / 2); - fw = fw / (vid.width / 2); - fh = fh / (vid.height / 2); + fx = -1.0f + fx / (vid.width / 2.0f); + fy = 1.0f - fy / (vid.height / 2.0f); + fw = fw / (fvw / 2); + fh = fh / (fvh / 2); v[0].x = v[3].x = fx; v[2].x = v[1].x = fx + fw; @@ -1135,7 +1153,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) #define _FILE_OFFSET_BITS 0 #endif - #include "png.h" +#include "png.h" #ifdef PNG_WRITE_SUPPORTED #define USE_PNG // PNG is only used if write is supported (see ../m_misc.c) #endif From 71805500ca14101c722006f632f3e53400d17671 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Feb 2025 18:12:54 +0100 Subject: [PATCH 366/418] clean this up a bit --- src/s_sound.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index d354dbef3..83e001afd 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1974,6 +1974,8 @@ void S_ResetKeepAndSpecialMus(void) static void S_SetKeepMusResume(void) { + keepmusic.resume = 0; + if (strcasecmp(music_name, mapmusic.name) == 0) { keepmusic.resume = I_GetSongPosition(); @@ -1988,26 +1990,25 @@ static void S_SetKeepMusicStuff(void) return; } + // always reset stuff just in case + memset(keepmusic.name, 0, sizeof(keepmusic.name)); + keepmusic.flags = 0; + keepmusic.position = 0; + strncpy(keepmusic.name, mapmusic.name, 7); + keepmusic.flags = mapmusic.flags; keepmusic.position = mapmusic.position; } -static void S_ClearKeepMusicPosition(void) -{ - memset(keepmusic.name, 0, sizeof(keepmusic.name)); - keepmusic.resume = 0; - keepmusic.flags = 0; - keepmusic.position = 0; -} - -void S_CopyKeepMusicStuff(void) +static void S_CopyKeepMusicStuff(void) { if (!cv_keepmusic.value) { return; } + strncpy(mapmusic.name, keepmusic.name, 7); mapmusic.flags = keepmusic.flags; mapmusic.position = keepmusic.position; @@ -2016,26 +2017,25 @@ void S_CopyKeepMusicStuff(void) // determine if we should keep the music on a map restart void S_KeepMusic(void) { - static INT16 oldmap = 0; + static INT16 oldmap = -1; static boolean oldencore = false; - const boolean musicchanged = S_CheckMusicException(); - S_SetKeepMusicStuff(); + keepmapmusic = keepmusicresume = false; if (!cv_keepmusic.value) { - keepmapmusic = keepmusicresume = false; + return; } - else if (oldmap == gamemap && oldencore == encoremode) + + S_SetKeepMusicStuff(); + + if (oldmap == gamemap && oldencore == encoremode) { + const boolean musicchanged = S_CheckMusicException(); + keepmusicresume = (musicchanged && keepmusic.resume); keepmapmusic = (!musicchanged || keepmusicresume); } - else - { - keepmapmusic = keepmusicresume = false; - S_ClearKeepMusicPosition(); - } oldencore = encoremode; oldmap = gamemap; From c8a629d8a57276372934ce2c91ba233dde4bfe29 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Feb 2025 06:35:03 +0100 Subject: [PATCH 367/418] extend mapmusic_t struct and rename to music_t didnt see that all the music stuff was more or less using the same things --- src/doomstat.h | 16 +++++---- src/g_game.c | 2 +- src/s_sound.c | 77 ++++++++++++++++++++----------------------- src/s_sound.h | 1 - src/sdl/mixer_sound.c | 2 +- 5 files changed, 47 insertions(+), 51 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index b0be7113d..03209185a 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -33,12 +33,16 @@ typedef struct { - char name[7]; // Music name - UINT16 flags; // Track and reset bit - UINT32 position; // Position to jump to - UINT32 resume; // Saved Position when music was stopped -} mapmusic_t; -extern mapmusic_t mapmusic; + char name[7]; // Music name, up to 6-character name + void *data; // Music lump + UINT16 flags; // Track and reset bit + boolean looping; // Is this music looping? + UINT32 position; // Position to jump to + UINT32 resume; // Saved Position when music was stopped + UINT32 fadeinms; // Fade in time in ms (used for queue) +} music_t; + +extern music_t mapmusic; #define MUSIC_TRACKMASK 0x0FFF // ----************ #define MUSIC_RELOADRESET 0x8000 // *--------------- diff --git a/src/g_game.c b/src/g_game.c index 6144a500d..89a69ab4f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -85,7 +85,7 @@ static void G_DoStartVote(void); static void G_ResetDemoPlayback(char *pdemoname); -mapmusic_t mapmusic; +music_t mapmusic; INT16 gamemap = 1; INT16 maptol; diff --git a/src/s_sound.c b/src/s_sound.c index 83e001afd..4a990f1bf 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -120,7 +120,7 @@ consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL, boolean keepmapmusic = false; // keep the current music on map restart boolean skipintromus = false; // skip the intro fanfare static boolean keepmusicresume = false; -static mapmusic_t keepmusic; +static music_t keepmusic; static void S_SetKeepMusResume(void); static void S_SetKeepMusicStuff(void); @@ -1195,17 +1195,10 @@ const char *compat_special_music_slots[16] = }; #endif -static char music_name[7]; // up to 6-character name -static void *music_data; -static UINT16 music_flags; -static boolean music_looping; -static consvar_t *music_refade_cv; +static music_t music; +static music_t queue; -static char queue_name[7]; -static UINT16 queue_flags; -static boolean queue_looping; -static UINT32 queue_position; -static UINT32 queue_fadeinms; +static consvar_t *music_refade_cv; /// ------------------------ /// Music Definitions @@ -1477,7 +1470,7 @@ void S_ShowSpecifiedMusicCredit(const char *musname) // void S_ShowMusicCredit(void) { - S_ShowSpecifiedMusicCredit(music_name); + S_ShowSpecifiedMusicCredit(music.name); } musicdef_t **soundtestdefs = NULL; @@ -1556,7 +1549,7 @@ musictype_t S_MusicType(void) const char *S_MusicName(void) { - return music_name; + return music.name; } boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) @@ -1564,10 +1557,10 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) if (!I_SongPlaying()) return false; - strncpy(mname, music_name, 7); + strncpy(mname, music.name, 7); mname[6] = 0; - *mflags = music_flags; - *looping = music_looping; + *mflags = music.flags; + *looping = music.looping; return (boolean)mname[0]; } @@ -1657,9 +1650,9 @@ static boolean S_LoadMusic(const char *mname) if (I_LoadSong(mdata, W_LumpLength(mlumpnum))) { - strncpy(music_name, mname, 7); - music_name[6] = 0; - music_data = mdata; + strncpy(music.name, mname, 7); + music.name[6] = 0; + music.data = mdata; return true; } else @@ -1671,13 +1664,13 @@ static void S_UnloadMusic(void) I_UnloadSong(); #ifndef HAVE_SDL //SDL uses RWOPS - Z_ChangeTag(music_data, PU_CACHE); + Z_ChangeTag(music.data, PU_CACHE); #endif - music_data = NULL; + music.data = NULL; - music_name[0] = 0; - music_flags = 0; - music_looping = false; + music.name[0] = 0; + music.flags = 0; + music.looping = false; music_refade_cv = 0; } @@ -1706,21 +1699,21 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) static void S_QueueMusic(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 fadeinms) { - strncpy(queue_name, mmusic, 7); - queue_flags = mflags; - queue_looping = looping; - queue_position = position; - queue_fadeinms = fadeinms; + strncpy(queue.name, mmusic, 7); + queue.flags = mflags; + queue.looping = looping; + queue.position = position; + queue.fadeinms = fadeinms; } static void S_ClearQueue(void) { - queue_name[0] = queue_flags = queue_looping = queue_position = queue_fadeinms = 0; + queue.name[0] = queue.flags = queue.looping = queue.position = queue.fadeinms = 0; } static void S_ChangeMusicToQueue(void) { - S_ChangeMusicEx(queue_name, queue_flags, queue_looping, queue_position, 0, queue_fadeinms); + S_ChangeMusicEx(queue.name, queue.flags, queue.looping, queue.position, 0, queue.fadeinms); S_ClearQueue(); } @@ -1749,7 +1742,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 strncpy(newmusic, mmusic, 6); strncpy(checkmusic, mmusic, 6); - if (LUA_HookMusicChange(music_name, &hook_param)) + if (LUA_HookMusicChange(music.name, &hook_param)) return; // No Music (empty string) @@ -1766,12 +1759,12 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 if (prefadems && S_MusicPlaying()) // queue music change for after fade // allow even if the music is the same { - CONS_Debug(DBG_DETAILED, "Now fading out song %s\n", music_name); + CONS_Debug(DBG_DETAILED, "Now fading out song %s\n", music.name); S_QueueMusic(newmusic, mflags, looping, position, fadeinms); I_FadeSong(0, prefadems, S_ChangeMusicToQueue); return; } - else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET)) + else if (strnicmp(music.name, newmusic, 6) || (mflags & MUSIC_FORCERESET)) { CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic); @@ -1783,8 +1776,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; } - music_flags = mflags; - music_looping = looping; + music.flags = mflags; + music.looping = looping; if (!S_PlayMusic(looping, fadeinms)) { @@ -1824,7 +1817,7 @@ void S_StopMusic(void) || demo.title) // SRB2Kart: Demos don't interrupt title screen music return; - mapmusic.resume = (cv_birdmusic.value && (strcasecmp(music_name, mapmusic.name) == 0)) ? I_GetSongPosition() : 0; + mapmusic.resume = (cv_birdmusic.value && (strcasecmp(music.name, mapmusic.name) == 0)) ? I_GetSongPosition() : 0; S_SetKeepMusResume(); @@ -1953,12 +1946,12 @@ static const char *musicexception_list[] = { // check if the current music is smth we dont want to keep (vote music, etc) static boolean S_CheckMusicException(void) { - if (stricmp(music_name, mapmusic.name)) + if (stricmp(music.name, mapmusic.name)) return true; for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) { - if (!stricmp(music_name, musicexception_list[i]) || !stricmp(checkmusic, musicexception_list[i])) + if (!stricmp(music.name, musicexception_list[i]) || !stricmp(checkmusic, musicexception_list[i])) { return true; } @@ -1976,7 +1969,7 @@ static void S_SetKeepMusResume(void) { keepmusic.resume = 0; - if (strcasecmp(music_name, mapmusic.name) == 0) + if (strcasecmp(music.name, mapmusic.name) == 0) { keepmusic.resume = I_GetSongPosition(); } @@ -2088,7 +2081,7 @@ void S_InitMapMusic(void) char *maptitle = G_BuildMapTitle(gamemap); // for some reason, occasionally the title screen music doesent seem to be reset in time, so skipping the intro may make it just continue playing it instead, weird.. skipintromus = true; - if (!stricmp(music_name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // thanks diggle! + if (!stricmp(music.name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // thanks diggle! skipintromus = false; if (maptitle) @@ -2265,7 +2258,7 @@ static void Command_RestartMusic_f(void) //same as RestartAudio but only music g static void Command_ShowMusicCredit_f(void) { - const char *musname = music_name; + const char *musname = music.name; if (COM_Argc() > 1) { diff --git a/src/s_sound.h b/src/s_sound.h index 4ed52d7bb..92e206e1b 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -116,7 +116,6 @@ void S_StartMapMusic(void); void S_HandleReloadResetMusic(void); void S_KeepMusic(void); -void S_CopyKeepMusicStuff(void); // Stops music and restarts it from same position. Used for instant applying changes to amiga filters. void S_RestartMusic(void); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 8059a93df..647958653 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -619,7 +619,7 @@ Countstutter (int len) else bytes = ( music_bytes - music_stutter_bytes ); - I_SetSongPosition((int)( bytes/4/44100.0*1000 )); + I_SetSongPosition((int)( (float)bytes/4/44100.0*1000 )); } } } From ab6ec6d11e759fefe4bb694e1d1f9a9c1a772495 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Feb 2025 16:51:17 +0100 Subject: [PATCH 368/418] add some comments + smol cleanup again for keepmusic --- src/s_sound.c | 55 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 4a990f1bf..2af2ee668 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -119,7 +119,7 @@ consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL, boolean keepmapmusic = false; // keep the current music on map restart boolean skipintromus = false; // skip the intro fanfare -static boolean keepmusicresume = false; +static boolean resumekeepmusic = false; static music_t keepmusic; static void S_SetKeepMusResume(void); static void S_SetKeepMusicStuff(void); @@ -1949,6 +1949,7 @@ static boolean S_CheckMusicException(void) if (stricmp(music.name, mapmusic.name)) return true; + // in case somehow the mapmusic was replaced with smth we dont want to keep for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) { if (!stricmp(music.name, musicexception_list[i]) || !stricmp(checkmusic, musicexception_list[i])) @@ -1965,6 +1966,8 @@ void S_ResetKeepAndSpecialMus(void) keepmapmusic = skipintromus = false; } +// saves the current song position everytime a song stops +// so we can resume it in some cases static void S_SetKeepMusResume(void) { keepmusic.resume = 0; @@ -1975,7 +1978,7 @@ static void S_SetKeepMusResume(void) } } -// save some values +// copy over all the mapmusic stuff into temporary vars static void S_SetKeepMusicStuff(void) { if (!cv_keepmusic.value) @@ -1994,6 +1997,7 @@ static void S_SetKeepMusicStuff(void) keepmusic.position = mapmusic.position; } +// replace mapmusic with our saved keepmusic stuff static void S_CopyKeepMusicStuff(void) { if (!cv_keepmusic.value) @@ -2008,12 +2012,13 @@ static void S_CopyKeepMusicStuff(void) } // determine if we should keep the music on a map restart +// this gets called BEFORE the level gets loaded in G_DoLoadLevel void S_KeepMusic(void) { static INT16 oldmap = -1; static boolean oldencore = false; - keepmapmusic = keepmusicresume = false; + keepmapmusic = resumekeepmusic = false; if (!cv_keepmusic.value) { @@ -2026,14 +2031,16 @@ void S_KeepMusic(void) { const boolean musicchanged = S_CheckMusicException(); - keepmusicresume = (musicchanged && keepmusic.resume); - keepmapmusic = (!musicchanged || keepmusicresume); + resumekeepmusic = (musicchanged && keepmusic.resume); + keepmapmusic = (!musicchanged || resumekeepmusic); } oldencore = encoremode; oldmap = gamemap; } +// Sets up the map music in case it should be reloaded +// Special case for keep music void S_HandleReloadResetMusic(void) { if (!(mapmusic.flags & MUSIC_RELOADRESET)) @@ -2041,7 +2048,7 @@ void S_HandleReloadResetMusic(void) if (keepmapmusic) { - // this is horrible, this copies over everything about the mapmusic into temporary variables to reuse + // this is horrible, but oh well S_CopyKeepMusicStuff(); } else @@ -2055,6 +2062,24 @@ void S_HandleReloadResetMusic(void) mapmusic.resume = 0; } +static boolean S_SkipIntroMusic(void) +{ + boolean skip = cv_skipintromusic.value; + + if (!skip) + return false; + + char *maptitle = G_BuildMapTitle(gamemap); // Zzz... + + // check if menu music is playing, otherwise it may continue playing + if (!stricmp(music.name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // wandering balls changes its song when the race starts Zzz... + skip = false; + + Z_Free(maptitle); + + return skip; +} + // // Per level startup code. // Kills playing sounds at start of level, @@ -2067,7 +2092,7 @@ void S_InitMapMusic(void) if (keepmapmusic) { // this is kinda silly, but we can use it to fade back into the map song at the saved point, should the current music be different from the map music - if (keepmusicresume) + if (resumekeepmusic) S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, keepmusic.resume, 0, 500); return; } @@ -2076,24 +2101,13 @@ void S_InitMapMusic(void) // lug: but not when we keep the map music lol S_StopMusic(); - if (cv_skipintromusic.value) - { - char *maptitle = G_BuildMapTitle(gamemap); - // for some reason, occasionally the title screen music doesent seem to be reset in time, so skipping the intro may make it just continue playing it instead, weird.. - skipintromus = true; - if (!stricmp(music.name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // thanks diggle! - skipintromus = false; - - if (maptitle) - Z_Free(maptitle); - } + skipintromus = S_SkipIntroMusic(); if (skipintromus) return; if (leveltime < MUSICSTARTTIME) // SRB2Kart S_ChangeMusicInternal((encoremode ? "estart" : "kstart"), false); //S_StopMusic(); - //S_ChangeMusicEx((encoremode ? "estart" : "kstart"), 0, false, mapmusic.position, 0, 0); } void S_StartMapMusic(void) @@ -2109,8 +2123,9 @@ void S_StartMapMusic(void) { if (leveltime < starttime) S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); - if (leveltime == MUSICSTARTTIME) + else if (leveltime == MUSICSTARTTIME) S_ShowMusicCredit(); + return; } From d5a762f35c4c070f3cc4f71a706e9fdb97690b04 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Feb 2025 17:43:33 +0100 Subject: [PATCH 369/418] account for netticbuffer in offline ping this makes it more accurately reflect how it would behave in an online game --- src/d_clisrv.c | 11 ++++++++++- src/d_clisrv.h | 1 + src/hu_stuff.c | 5 +++-- src/sdl/i_video.c | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4f0e2ab53..0c7e238dd 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -108,6 +108,7 @@ UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values. static tic_t reference_lag; static UINT8 spike_time; tic_t lowest_lag; +tic_t simulated_lag; // just for ping readout without netticbuffer added boolean server_lagless; static void Lagless_OnChange(void) @@ -6697,6 +6698,10 @@ static void UpdatePingTable(void) if (lowest_lag < (tic_t)cv_mindelay.value) lowest_lag = (tic_t)cv_mindelay.value; + simulated_lag = lowest_lag; + + lowest_lag += (tic_t)cv_netticbuffer.value; // account for netticbufffer + pingmeasurecount++; } else // We're a client, handle mindelay on the way out. @@ -6707,9 +6712,13 @@ static void UpdatePingTable(void) tic_t mydelay = playerpingtable[consoleplayer]; if (mydelay < (tic_t)cv_mindelay.value) - lowest_lag = cv_mindelay.value - mydelay; + lowest_lag = ((tic_t)cv_mindelay.value - mydelay); else lowest_lag = 0; + + simulated_lag = lowest_lag; + + lowest_lag += (tic_t)cv_netticbuffer.value; // account for netticbufffer } } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 2758e8db0..d8a1acc22 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -586,6 +586,7 @@ extern UINT32 playerpingtable[MAXPLAYERS]; extern tic_t servermaxping; extern boolean server_lagless; +extern tic_t simulated_lag; extern tic_t lowest_lag; extern consvar_t cv_mindelay, cv_lagless; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index dfb66c081..11e304ac5 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2403,11 +2403,11 @@ void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) SINT8 yoffset = 6; UINT32 lag = playerpingtable[pnum]; - const boolean gentleman = ((cv_mindelay.value && (lag < (tic_t)cv_mindelay.value) && P_IsLocalPlayer(&players[pnum])) || (pnum == serverplayer && lowest_lag != 0)); // for serverplayer lowest_lag actually reflects mindelay + const boolean gentleman = (cv_mindelay.value && (lag < (tic_t)simulated_lag)); if (gentleman) { - lag = (pnum == serverplayer) ? lowest_lag : (tic_t)cv_mindelay.value; + lag = simulated_lag; } if (cv_pingstyle.value == 0) // kart @@ -2468,6 +2468,7 @@ void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) if (gentleman) { barcolor = 194; // make it purplish + // bars get indirectly set earlier } for (i = 0; (i < 3); i++) // Draw the ping bar diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 8a5ed8cbc..064bfd25c 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1440,7 +1440,7 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); - if (cv_showping.value && ((netgame && consoleplayer != serverplayer) || ((cv_mindelay.value || (!server_lagless && lowest_lag != 0)) && consoleplayer == serverplayer && Playing()))) + if (cv_showping.value && ((netgame && consoleplayer != serverplayer) || (simulated_lag != 0 && consoleplayer == serverplayer && Playing()))) SCR_DisplayLocalPing(); } From 34c517defc8e11eaf89d6894a403a977159e6014 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Feb 2025 19:05:44 +0100 Subject: [PATCH 370/418] dont add buffer delay when local delay is disabled --- src/d_clisrv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0c7e238dd..fed263220 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6700,7 +6700,8 @@ static void UpdatePingTable(void) simulated_lag = lowest_lag; - lowest_lag += (tic_t)cv_netticbuffer.value; // account for netticbufffer + if (lowest_lag != 0) + lowest_lag += (tic_t)cv_netticbuffer.value; // account for netticbufffer pingmeasurecount++; } @@ -6718,7 +6719,8 @@ static void UpdatePingTable(void) simulated_lag = lowest_lag; - lowest_lag += (tic_t)cv_netticbuffer.value; // account for netticbufffer + if (lowest_lag != 0) + lowest_lag += (tic_t)cv_netticbuffer.value; // account for netticbufffer } } From a80f520c3890639729990a43a7723284468b437c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Feb 2025 20:47:33 +0100 Subject: [PATCH 371/418] fix some level userdata not being invalidated maybe fixed the random issues we had with the server? --- src/lua_script.c | 27 ++++++++++++++++++++++++++- src/p_slopes.c | 2 +- src/p_slopes.h | 2 ++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index 5078a22c0..4346e483e 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -557,6 +557,8 @@ void LUA_InvalidateLevel(void) { thinker_t *th; size_t i; + ffloor_t *rover = NULL; + if (!gL) return; @@ -568,32 +570,55 @@ void LUA_InvalidateLevel(void) for (i = 0; i < numsubsectors; i++) LUA_InvalidateUserdata(&subsectors[i]); for (i = 0; i < numsectors; i++) + { LUA_InvalidateUserdata(§ors[i]); + LUA_InvalidateUserdata(§ors[i].lines); + + if (sectors[i].ffloors) + { + for (rover = sectors[i].ffloors; rover; rover = rover->next) + LUA_InvalidateUserdata(rover); + } + } + for (i = 0; i < numlines; i++) { LUA_InvalidateUserdata(&lines[i]); LUA_InvalidateUserdata(lines[i].sidenum); } + for (i = 0; i < numsides; i++) LUA_InvalidateUserdata(&sides[i]); for (i = 0; i < numvertexes; i++) LUA_InvalidateUserdata(&vertexes[i]); + + for (pslope_t *slope = slopelist; slope; slope = slope->next) + { + LUA_InvalidateUserdata(slope); + LUA_InvalidateUserdata(&slope->normal); + LUA_InvalidateUserdata(&slope->o); + LUA_InvalidateUserdata(&slope->d); + } } void LUA_InvalidateMapthings(void) { size_t i; + if (!gL) return; for (i = 0; i < nummapthings; i++) + { LUA_InvalidateUserdata(&mapthings[i]); + } } void LUA_InvalidatePlayer(player_t *player) { if (!gL) return; + LUA_InvalidateUserdata(player); LUA_InvalidateUserdata(player->powers); LUA_InvalidateUserdata(player->kartstuff); @@ -639,7 +664,7 @@ static const struct { {META_SUBSECTOR,ARCH_SUBSECTOR}, {META_SECTOR, ARCH_SECTOR}, {META_SLOPE, ARCH_SLOPE}, - {META_MAPHEADER, ARCH_MAPHEADER}, + {META_MAPHEADER,ARCH_MAPHEADER}, {NULL, ARCH_NULL} }; diff --git a/src/p_slopes.c b/src/p_slopes.c index f3428d91f..81d8c54e3 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -24,7 +24,7 @@ #include "w_wad.h" -static pslope_t *slopelist = NULL; +pslope_t *slopelist = NULL; static UINT16 slopecount = 0; // Calculate light diff --git a/src/p_slopes.h b/src/p_slopes.h index 82dd90738..89cfdc343 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -33,6 +33,8 @@ void P_CopySectorSlope(line_t *line); pslope_t *P_SlopeById(UINT16 id); +extern pslope_t *slopelist; + // // P_GetZAt // From 5f0b2b0604c939a78da62add85f46b5dcca094fa Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Feb 2025 20:47:33 +0100 Subject: [PATCH 372/418] fix some level userdata not being invalidated maybe fixed the random issues we had with the server? --- src/lua_script.c | 27 ++++++++++++++++++++++++++- src/p_slopes.c | 2 +- src/p_slopes.h | 2 ++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index 7ef6f0217..12192b0b2 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -504,6 +504,8 @@ void LUA_InvalidateLevel(void) { thinker_t *th; size_t i; + ffloor_t *rover = NULL; + if (!gL) return; @@ -515,32 +517,55 @@ void LUA_InvalidateLevel(void) for (i = 0; i < numsubsectors; i++) LUA_InvalidateUserdata(&subsectors[i]); for (i = 0; i < numsectors; i++) + { LUA_InvalidateUserdata(§ors[i]); + LUA_InvalidateUserdata(§ors[i].lines); + + if (sectors[i].ffloors) + { + for (rover = sectors[i].ffloors; rover; rover = rover->next) + LUA_InvalidateUserdata(rover); + } + } + for (i = 0; i < numlines; i++) { LUA_InvalidateUserdata(&lines[i]); LUA_InvalidateUserdata(lines[i].sidenum); } + for (i = 0; i < numsides; i++) LUA_InvalidateUserdata(&sides[i]); for (i = 0; i < numvertexes; i++) LUA_InvalidateUserdata(&vertexes[i]); + + for (pslope_t *slope = slopelist; slope; slope = slope->next) + { + LUA_InvalidateUserdata(slope); + LUA_InvalidateUserdata(&slope->normal); + LUA_InvalidateUserdata(&slope->o); + LUA_InvalidateUserdata(&slope->d); + } } void LUA_InvalidateMapthings(void) { size_t i; + if (!gL) return; for (i = 0; i < nummapthings; i++) + { LUA_InvalidateUserdata(&mapthings[i]); + } } void LUA_InvalidatePlayer(player_t *player) { if (!gL) return; + LUA_InvalidateUserdata(player); LUA_InvalidateUserdata(player->powers); LUA_InvalidateUserdata(player->kartstuff); @@ -586,7 +611,7 @@ static const struct { {META_SUBSECTOR,ARCH_SUBSECTOR}, {META_SECTOR, ARCH_SECTOR}, {META_SLOPE, ARCH_SLOPE}, - {META_MAPHEADER, ARCH_MAPHEADER}, + {META_MAPHEADER,ARCH_MAPHEADER}, {NULL, ARCH_NULL} }; diff --git a/src/p_slopes.c b/src/p_slopes.c index 0ba37a816..542ce244d 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -24,7 +24,7 @@ #include "w_wad.h" -static pslope_t *slopelist = NULL; +pslope_t *slopelist = NULL; static UINT16 slopecount = 0; // Calculate light diff --git a/src/p_slopes.h b/src/p_slopes.h index 82dd90738..89cfdc343 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -33,6 +33,8 @@ void P_CopySectorSlope(line_t *line); pslope_t *P_SlopeById(UINT16 id); +extern pslope_t *slopelist; + // // P_GetZAt // From 8c9808b2d660c049d8000068f0e79458aff083b2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Feb 2025 21:00:00 +0100 Subject: [PATCH 373/418] fix online player localping display --- src/d_clisrv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index fed263220..94bc50021 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6713,11 +6713,12 @@ static void UpdatePingTable(void) tic_t mydelay = playerpingtable[consoleplayer]; if (mydelay < (tic_t)cv_mindelay.value) + { lowest_lag = ((tic_t)cv_mindelay.value - mydelay); + simulated_lag = (tic_t)cv_mindelay.value; + } else - lowest_lag = 0; - - simulated_lag = lowest_lag; + lowest_lag = simulated_lag = 0; if (lowest_lag != 0) lowest_lag += (tic_t)cv_netticbuffer.value; // account for netticbufffer From b32785f88c64b1c11e1d3a34f05a65efd808d78a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 11 Feb 2025 15:01:48 +0100 Subject: [PATCH 374/418] revert adding netbuffer to local ping dont wanna revert the commit, since i keep the new way of determining the ping display, since its less awful than before --- src/d_clisrv.c | 6 ------ src/d_net.c | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 94bc50021..0b58fbb31 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6700,9 +6700,6 @@ static void UpdatePingTable(void) simulated_lag = lowest_lag; - if (lowest_lag != 0) - lowest_lag += (tic_t)cv_netticbuffer.value; // account for netticbufffer - pingmeasurecount++; } else // We're a client, handle mindelay on the way out. @@ -6719,9 +6716,6 @@ static void UpdatePingTable(void) } else lowest_lag = simulated_lag = 0; - - if (lowest_lag != 0) - lowest_lag += (tic_t)cv_netticbuffer.value; // account for netticbufffer } } diff --git a/src/d_net.c b/src/d_net.c index 6f43147b9..403788e5a 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1349,9 +1349,9 @@ boolean D_CheckNetGame(void) I_Error("Too many nodes (%d), max:%d", doomcom->numnodes, MAXNETNODES); netbuffer = (doomdata_t *)(void *)&doomcom->data; - #ifdef HOLEPUNCH +#ifdef HOLEPUNCH holepunchpacket = (holepunch_t *)(void *)&doomcom->data; - #endif +#endif #ifdef DEBUGFILE if (M_CheckParm("-debugfile")) From fcc9cdcaef13f3d3c5f89ec2e2ee5a416db0fa3a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 12 Feb 2025 11:56:41 +0100 Subject: [PATCH 375/418] use correct type in P_InitMinimapInfo --- src/p_setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index b38fa4e63..081ae752c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2662,7 +2662,7 @@ static boolean P_CanSave(void) struct minimapinfo minimapinfo; static void P_InitMinimapInfo(void) { - INT32 lumpnum; + lumpnum_t lumpnum; fixed_t a; fixed_t b; node_t *bsp = &nodes[numnodes-1]; @@ -2671,7 +2671,7 @@ static void P_InitMinimapInfo(void) lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap))); - if (lumpnum != -1) + if (lumpnum != LUMPERROR) minimapinfo.minimap_pic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_HUDGFX); minimapinfo.min_x = bsp->bbox[0][BOXLEFT]; From 1eae8c6ea32d149edbe2ad4b835275ef61c129b3 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 12 Feb 2025 11:56:41 +0100 Subject: [PATCH 376/418] use correct type in P_InitMinimapInfo --- src/p_setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 652062079..633c4094e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2495,7 +2495,7 @@ static boolean P_CanSave(void) struct minimapinfo minimapinfo; static void P_InitMinimapInfo(void) { - INT32 lumpnum; + lumpnum_t lumpnum; fixed_t a; fixed_t b; node_t *bsp = &nodes[numnodes-1]; @@ -2504,7 +2504,7 @@ static void P_InitMinimapInfo(void) lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap))); - if (lumpnum != -1) + if (lumpnum != LUMPERROR) minimapinfo.minimap_pic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_HUDGFX); minimapinfo.min_x = bsp->bbox[0][BOXLEFT]; From 164bd182345f373c1ad687198f1f91cd0796b7e3 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 11 Feb 2025 19:21:38 +0100 Subject: [PATCH 377/418] split screentexture width and height most displays are widescreen, so their width and height differ quite significantly, this may make the overall screentexture alot smaller --- src/hardware/r_opengl/r_opengl.c | 78 ++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index ecbc52ca8..df5a627fd 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2900,7 +2900,7 @@ void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) INT32 x, y; float float_x, float_y, float_nextx, float_nexty; float xfix, yfix; - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; const float blackBack[16] = { @@ -2914,12 +2914,15 @@ void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; + + while (texsizey < screen_height) + texsizey <<= 1; // X/Y stretch fix for all resolutions(!) - xfix = (float)(texsize)/((float)((screen_width)/(float)(SCREENVERTS-1))); - yfix = (float)(texsize)/((float)((screen_height)/(float)(SCREENVERTS-1))); + xfix = (float)(texsizew)/((float)((screen_width)/(float)(SCREENVERTS-1))); + yfix = (float)(texsizey)/((float)((screen_height)/(float)(SCREENVERTS-1))); pglDisable(GL_DEPTH_TEST); pglDisable(GL_BLEND); @@ -2992,7 +2995,7 @@ void GL_FlushScreenTextures(void) void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) { float xfix, yfix; - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; const float screenVerts[12] = { @@ -3008,11 +3011,14 @@ void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); // const float screenVerts[12] @@ -3045,7 +3051,7 @@ void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) // Do screen fades! void GL_DoScreenWipe(int wipeStart, int wipeEnd) { - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; float xfix, yfix; INT32 fademaskdownloaded = tex_downloaded; // the fade mask that has been set @@ -3072,11 +3078,14 @@ void GL_DoScreenWipe(int wipeStart, int wipeEnd) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); // const float screenVerts[12] @@ -3136,7 +3145,7 @@ void GL_DoScreenWipe(int wipeStart, int wipeEnd) void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) { - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; int tex = HWD_SCREENTEXTURE_VHS; float xfix, yfix; float fix[8]; @@ -3155,11 +3164,14 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); // Slight fuzziness GL_MakeScreenTexture(tex); @@ -3243,15 +3255,18 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 // Create a texture from the screen. void GL_MakeScreenTexture(int tex) { - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; boolean firstTime = (screenTextures[tex] == 0); if (!gl_enable_screen_textures) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; + + while (texsizey < screen_height) + texsizey <<= 1; // Create screen texture if (firstTime) @@ -3264,10 +3279,10 @@ void GL_MakeScreenTexture(int tex) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); Clamp2D(GL_TEXTURE_WRAP_S); Clamp2D(GL_TEXTURE_WRAP_T); - pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texsize, texsize, 0); + pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texsizew, texsizey, 0); } else - pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texsize, texsize); + pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texsizew, texsizey); tex_downloaded = screenTextures[tex]; } @@ -3278,7 +3293,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh float origaspect, newaspect; float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen FRGBAFloat clearColour; - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; float off[12]; float fix[8]; @@ -3287,11 +3302,14 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); origaspect = (float)screen_width / screen_height; newaspect = (float)width / height; From 3509b05d1e99159c539c17ccc972b5296e055313 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 12 Feb 2025 17:32:07 +0100 Subject: [PATCH 378/418] cleanup P_SetupLevel removed bunch of pointless vars, moved some things into functions changed some stuff to be boolean --- src/p_setup.c | 445 +++++++++++++++++++++++++------------------------- src/p_setup.h | 7 +- src/w_wad.c | 3 +- 3 files changed, 224 insertions(+), 231 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 081ae752c..d8ba79d99 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -91,6 +91,9 @@ // unsigned char mapmd5[16]; +// true when level was loaded from netsave +boolean midgamejoin = false; + // // MAP related Lookup tables. // Store VERTEXES, LINEDEFS, SIDEDEFS, etc. @@ -247,8 +250,6 @@ static SINT8 partadd_stage = -1; static boolean partadd_replacescurrentmap = false; static boolean partadd_important = false; -SINT8 midgamejoin = 0; - /** Logs an error about a map being corrupt, then terminate. * This allows reporting highly technical errors for usefulness, without * confusing a novice map designer who simply needs to run ZenNode. @@ -2722,72 +2723,8 @@ static void P_InitMinimapInfo(void) minimapinfo.offs_y = FixedMul((minimapinfo.min_y + minimapinfo.map_h/2) << FRACBITS, minimapinfo.zoom); } -/** Loads a level from a lump or external wad. - * - * \param skipprecip If true, don't spawn precipitation. - * \todo Clean up, refactor, split up; get rid of the bloat. - */ -boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) +static boolean P_RunSpecialWipe(boolean reloadinggamestate) { - // use gamemap to get map number. - // 99% of the things already did, so. - // Map header should always be in place at this point - INT32 i, loadprecip = 1, ranspecialwipe = 0; - INT32 loademblems = 1; - INT32 fromnetsave = 0; - midgamejoin = 0; - sector_t *ss; - boolean chase; - - levelloading = true; - - // This is needed. Don't touch. - maptol = mapheaderinfo[gamemap-1]->typeoflevel; - - CON_Drawer(); // let the user know what we are going to do - I_FinishUpdate(); // page flip or blit buffer - - // Initialize sector node list. - P_Initsecnode(); - - if (netgame || multiplayer) - cv_debug = botskin = 0; - - if (metalplayback) - G_StopMetalDemo(); - - // Clear CECHO messages - HU_ClearCEcho(); - - if (mapheaderinfo[gamemap-1]->runsoc[0] != '#') - P_RunSOC(mapheaderinfo[gamemap-1]->runsoc); - - if (cv_runscripts.value && mapheaderinfo[gamemap-1]->scriptname[0] != '#') - P_RunLevelScript(mapheaderinfo[gamemap-1]->scriptname); - - P_LevelInitStuff(reloadinggamestate); - - if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0' - && atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255) - P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter); - - // chasecam on in chaos, race, coop - // chasecam off in match, tag, capture the flag - chase = true; // srb2kart: always on - - if (!dedicated) - { - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (!cv_chasecam[i].changed) - CV_SetValue(&cv_chasecam[i], chase); - } - } - - // Initial height of PointOfView - // will be set by player think. - players[consoleplayer].viewz = 1; - // Cancel all d_main.c fadeouts (keep fade in though). if (reloadinggamestate) wipegamestate = gamestate; // Don't fade if reloading the gamestate @@ -2820,7 +2757,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) F_RunWipe(wipedefs[wipe_speclevel_towhite], false); F_RunWipe(wipedefs[wipe_level_final], false); } - + locstarttime = nowtime = lastwipetic; endtime = locstarttime + (3*TICRATE)/2; @@ -2841,162 +2778,15 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) NetKeepAlive(); } - ranspecialwipe = 1; + return true; } - // Make sure all sounds are stopped before Z_FreeTags. - S_StopSounds(); + return false; +} - if (!S_PrecacheSound()) - S_ClearSfx(); - - // As oddly named as this is, this handles music only. - // We should be fine starting it here. - if (!reloadinggamestate) - S_InitMapMusic(); - - levelfadecol = (encoremode && !ranspecialwipe ? 122 : 120); - - // Let's fade to white here - // But only if we didn't do the encore startup wipe - if (!ranspecialwipe && !demo.rewinding && !reloadinggamestate) - { - if (rendermode != render_none) - { - F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); - - F_WipeEndScreen(); - F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); - } - else //dedicated servers - { - F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); - } - } - - // Reset the palette now all fades have been done - if (rendermode != render_none) - V_SetPaletteLump(GetPalette()); // Set the level palette - - // Print "SPEEDING OFF TO [ZONE] [ACT 1]..." - /*if (rendermode != render_none) - { - // Don't include these in the fade! - char tx[64]; - V_DrawSmallString(1, 191, V_ALLOWLOWERCASE, M_GetText("Speeding off to...")); - snprintf(tx, 63, "%s%s%s", - mapheaderinfo[gamemap-1]->lvlttl, - (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart - ((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " Zone"), - (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) ? va(", Act %s",mapheaderinfo[gamemap-1]->actnum) : ""); - V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx); - I_UpdateNoVsync(); - }*/ - - LUA_InvalidateLevel(); - - for (ss = sectors; sectors+numsectors != ss; ss++) - { - Z_Free(ss->attached); - Z_Free(ss->attachedsolid); - } - - // Clear pointers that would be left dangling by the purge - R_FlushTranslationColormapCache(); - - Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); - -#if defined (WALLSPLATS) || defined (FLOORSPLATS) - // clear the splats from previous level - R_ClearLevelSplats(); -#endif - - mobjcache = NULL; - - R_InitializeLevelInterpolators(); - - P_InitThinkers(); - R_InitMobjInterpolators(); - P_InitCachedActions(); - - /// \note for not spawning precipitation, etc. when loading netgame snapshots - if (skipprecip) - { - fromnetsave = 1; - loadprecip = 0; - loademblems = 0; - midgamejoin = 1; - } - - // internal game map - maplumpname = G_BuildMapName(gamemap); - lastloadedmaplumpnum = W_CheckNumForName(maplumpname); - if (lastloadedmaplumpnum == INT16_MAX) - I_Error("Map %s not found.\n", maplumpname); - - curmapvirt = vres_GetMap(lastloadedmaplumpnum); - - R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, - W_CheckNumForName(va("%s%c", maplumpname, (encoremode ? 'E' : 'T')))); - CON_SetupBackColormap(); - - // SRB2 determines the sky texture to be used depending on the map header. - P_SetupLevelSky(mapheaderinfo[gamemap-1]->skynum, true); - - numdmstarts = numredctfstarts = numbluectfstarts = 0; - - // reset the player starts - for (i = 0; i < MAXPLAYERS; i++) - playerstarts[i] = NULL; - for (i = 0; i < 2; i++) - skyboxmo[i] = NULL; - - P_ResetWaypoints(); - - P_MapStart(); - - if (lastloadedmaplumpnum) - P_LoadMapFromFile(); - - P_ResetDynamicSlopes(); - - P_LoadThings(); - - P_SpawnSecretItems(loademblems); - - P_InitMinimapInfo(); - - for (numcoopstarts = 0; numcoopstarts < MAXPLAYERS; numcoopstarts++) - if (!playerstarts[numcoopstarts]) - break; - - globalweather = mapheaderinfo[gamemap-1]->weather; - - // set up world state - P_SpawnSpecials(fromnetsave, reloadinggamestate); - - if (loadprecip) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) - P_SpawnPrecipitation(); - -#ifdef HWRENDER // not win32 only 19990829 by Kin - if (rendermode == render_opengl) - { - HWR_FreeExtraSubsectors(); - - // stuff like HWR_CreatePlanePolygons is called there - HWR_LoadLevel(); - } -#endif - - // oh god I hope this helps - // (addendum: apparently it does! - // none of this needs to be done because it's not the beginning of the map when - // a netgame save is being loaded, and could actively be harmful by messing with - // the client's view of the data.) - if (fromnetsave) - goto netgameskip; - // ========== +static void P_SetupPlayer(void) +{ + INT32 i; for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) @@ -3047,7 +2837,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) } } - if (realnumplayers) //this should also fix the dedicated crash bug. You only pick a player if one exists to be picked. + if (realnumplayers) // this should also fix the dedicated crash bug. You only pick a player if one exists to be picked. { i = P_RandomKey(realnumplayers); players[playersactive[i]].pflags |= PF_TAGIT; //choose our initial tagger before map starts. @@ -3116,10 +2906,213 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) startedInFreePlay = true; } } +} - // =========== - // landing point for netgames. - netgameskip: +/** Loads a level from a lump or external wad. + * + * \param fromnetsave If true, skip some stuff because we're loading a netgame snapshot. + * \todo Clean up, refactor, split up; get rid of the bloat. + */ +boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) +{ + // use gamemap to get map number. + // 99% of the things already did, so. + // Map header should always be in place at this point + INT32 i; + boolean ranspecialwipe = false; + sector_t *ss; + + midgamejoin = fromnetsave; // makes dynslopes run in P_Ticker/P_PreTicker to avoid synch issues and other stuff + + levelloading = true; + + // This is needed. Don't touch. + maptol = mapheaderinfo[gamemap-1]->typeoflevel; + + CON_Drawer(); // let the user know what we are going to do + I_FinishUpdate(); // page flip or blit buffer + + // Initialize sector node list. + P_Initsecnode(); + + if (netgame || multiplayer) + cv_debug = botskin = 0; + + if (metalplayback) + G_StopMetalDemo(); + + // Clear CECHO messages + HU_ClearCEcho(); + + if (mapheaderinfo[gamemap-1]->runsoc[0] != '#') + P_RunSOC(mapheaderinfo[gamemap-1]->runsoc); + + if (cv_runscripts.value && mapheaderinfo[gamemap-1]->scriptname[0] != '#') + P_RunLevelScript(mapheaderinfo[gamemap-1]->scriptname); + + P_LevelInitStuff(reloadinggamestate); + + if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0' + && atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255) + P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter); + + if (!dedicated) + { + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (!cv_chasecam[i].changed) + CV_SetValue(&cv_chasecam[i], true); // srb2kart: always on + } + } + + // Initial height of PointOfView + // will be set by player think. + players[consoleplayer].viewz = 1; + + ranspecialwipe = P_RunSpecialWipe(reloadinggamestate); + + // Make sure all sounds are stopped before Z_FreeTags. + S_StopSounds(); + + if (!S_PrecacheSound()) + S_ClearSfx(); + + // As oddly named as this is, this handles music only. + // We should be fine starting it here. + if (!reloadinggamestate) + S_InitMapMusic(); + + levelfadecol = (encoremode && !ranspecialwipe ? 122 : 120); + + // Let's fade to white here + // But only if we didn't do the encore startup wipe + if (!ranspecialwipe && !demo.rewinding && !reloadinggamestate) + { + if (rendermode != render_none) + { + F_WipeStartScreen(); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); + F_WipeEndScreen(); + F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); + } + else //dedicated servers + { + F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); + } + } + + // Reset the palette now all fades have been done + if (rendermode != render_none) + V_SetPaletteLump(GetPalette()); // Set the level palette + + // Print "SPEEDING OFF TO [ZONE] [ACT 1]..." + /*if (rendermode != render_none) + { + // Don't include these in the fade! + char tx[64]; + V_DrawSmallString(1, 191, V_ALLOWLOWERCASE, M_GetText("Speeding off to...")); + snprintf(tx, 63, "%s%s%s", + mapheaderinfo[gamemap-1]->lvlttl, + (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart + ((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " Zone"), + (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) ? va(", Act %s",mapheaderinfo[gamemap-1]->actnum) : ""); + V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx); + I_UpdateNoVsync(); + }*/ + + LUA_InvalidateLevel(); + + for (ss = sectors; sectors+numsectors != ss; ss++) + { + Z_Free(ss->attached); + Z_Free(ss->attachedsolid); + } + + // Clear pointers that would be left dangling by the purge + R_FlushTranslationColormapCache(); + + Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); + +#if defined (WALLSPLATS) || defined (FLOORSPLATS) + // clear the splats from previous level + R_ClearLevelSplats(); +#endif + + mobjcache = NULL; + + R_InitializeLevelInterpolators(); + + P_InitThinkers(); + R_InitMobjInterpolators(); + P_InitCachedActions(); + + // internal game map + maplumpname = G_BuildMapName(gamemap); + lastloadedmaplumpnum = W_CheckNumForName(maplumpname); + if (lastloadedmaplumpnum == INT16_MAX) + I_Error("Map %s not found.\n", maplumpname); + + curmapvirt = vres_GetMap(lastloadedmaplumpnum); + + R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, + W_CheckNumForName(va("%s%c", maplumpname, (encoremode ? 'E' : 'T')))); + CON_SetupBackColormap(); + + // SRB2 determines the sky texture to be used depending on the map header. + P_SetupLevelSky(mapheaderinfo[gamemap-1]->skynum, true); + + numdmstarts = numredctfstarts = numbluectfstarts = 0; + + // reset the player starts + for (i = 0; i < MAXPLAYERS; i++) + playerstarts[i] = NULL; + for (i = 0; i < 2; i++) + skyboxmo[i] = NULL; + + P_ResetWaypoints(); + + P_MapStart(); + + if (lastloadedmaplumpnum) + P_LoadMapFromFile(); + + P_ResetDynamicSlopes(); + + P_LoadThings(); + + P_SpawnSecretItems(!fromnetsave); + + P_InitMinimapInfo(); + + for (numcoopstarts = 0; numcoopstarts < MAXPLAYERS; numcoopstarts++) + if (!playerstarts[numcoopstarts]) + break; + + globalweather = mapheaderinfo[gamemap-1]->weather; + + // set up world state + P_SpawnSpecials(fromnetsave, reloadinggamestate); + + if (!fromnetsave) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) + P_SpawnPrecipitation(); + +#ifdef HWRENDER // not win32 only 19990829 by Kin + if (rendermode == render_opengl) + { + HWR_FreeExtraSubsectors(); + + // stuff like HWR_CreatePlanePolygons is called there + HWR_LoadLevel(); + } +#endif + + // oh god I hope this helps + // (addendum: apparently it does! + // none of this needs to be done because it's not the beginning of the map when + // a netgame save is being loaded, and could actively be harmful by messing with + // the client's view of the data.) + if (!fromnetsave) + P_SetupPlayer(); if (!reloadinggamestate) { @@ -3169,7 +3162,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) skyVisible = true; memset(skyVisiblePerPlayer, true, sizeof(skyVisiblePerPlayer)); - if (loadprecip) // uglier hack + if (!fromnetsave) // uglier hack { // to make a newly loaded level start on the second frame. INT32 buf = gametic % TICQUEUE; for (i = 0; i < MAXPLAYERS; i++) diff --git a/src/p_setup.h b/src/p_setup.h index f2eee72c2..723b48d18 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -19,11 +19,12 @@ #include "r_defs.h" #include "w_wad.h" -extern SINT8 midgamejoin; - // map md5, sent to players via PT_SERVERINFO extern unsigned char mapmd5[16]; +// true when level was loaded from netsave +extern boolean midgamejoin; + // Player spawn spots for deathmatch. #define MAX_DM_STARTS 64 extern mapthing_t *deathmatchstarts[MAX_DM_STARTS]; @@ -60,7 +61,7 @@ extern mapthing_t *mapthings; void P_SetupLevelSky(INT32 skynum, boolean global); void P_LoadThingsOnly(void); -boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate); +boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate); #ifdef HWRENDER void HWR_LoadLevel(void); #endif diff --git a/src/w_wad.c b/src/w_wad.c index ad506240d..d49eff1b6 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1021,8 +1021,7 @@ UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump) return INT16_MAX; } -UINT16 -W_CheckNumForMarkerStartPwad (const char *name, UINT16 wad, UINT16 startlump) +UINT16 W_CheckNumForMarkerStartPwad (const char *name, UINT16 wad, UINT16 startlump) { UINT16 marker; marker = W_CheckNumForNamePwad(name, wad, startlump); From 3f910824e845934b0a6b1ee21e0827314868b7b2 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 12 Feb 2025 17:55:23 +0100 Subject: [PATCH 379/418] make P_InitCamera slightly prettier --- src/p_setup.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index d8ba79d99..ed90d199d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2634,25 +2634,25 @@ static void P_InitCamera(void) { INT32 i; - if (!dedicated) + if (dedicated) + return; + + for (i = 0; i <= splitscreen; i++) { - for (i = 0; i <= splitscreen; i++) - { - if (camera[i].freecam) - continue; + if (camera[i].freecam) + continue; - P_SetupCamera(displayplayers[i], &camera[i]); - } - - // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (!cv_cam_rotate[i].changed) - CV_Set(&cv_cam_rotate[i], cv_cam_rotate[i].defaultvalue); - } - - displayplayers[0] = consoleplayer; // Start with your OWN view, please! + P_SetupCamera(displayplayers[i], &camera[i]); } + + // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (!cv_cam_rotate[i].changed) + CV_Set(&cv_cam_rotate[i], cv_cam_rotate[i].defaultvalue); + } + + displayplayers[0] = consoleplayer; // Start with your OWN view, please! } static boolean P_CanSave(void) From d156b716f619776dd42f731afa7e63870576132a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 13 Feb 2025 18:41:58 +0100 Subject: [PATCH 380/418] add toggle for blendmode player effects otherwise people will yell enabled by default for now for demonstration purposes --- src/k_kart.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 0d7777ef9..5654f7838 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -104,7 +104,7 @@ consvar_t cv_highresportrait = {"highresportrait", "Off", CV_SAVE, CV_OnOff, NUL consvar_t cv_showlapemblem = {"showlapemblem", "On", CV_SAVE, CV_OnOff, 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 -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_darkitembox = {"darkitembox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // itembox gets a dark border with specific items consvar_t cv_multiitemicon = {"multiitemicon", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t huditemamount_cons_t[] = {{0, "Vanilla"}, {1, "Multiple"}, {2, "Always"},{0, NULL}}; consvar_t cv_huditemamount = {"showitemamountnumber", "Vanilla", CV_SAVE, huditemamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -113,6 +113,8 @@ 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 +consvar_t cv_blendeffects = {"testblendeffects", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + // funn-E streeetch static CV_PossibleValue_t stretchfactor_t[] = { {0, "Off"}, {FRACUNIT/4, "0.250"}, @@ -739,6 +741,8 @@ boolean K_UseColorHud(void) return (cv_colorizedhud.value && clr_hud); } +extern consvar_t cv_blendeffects; + //} //{ SRB2kart Net Variables @@ -867,6 +871,8 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_stagetitle); + CV_RegisterVar(&cv_blendeffects); + // Colourized HUD CV_RegisterVar(&cv_colorizedhud); CV_RegisterVar(&cv_colorizedhudcolor); @@ -1667,7 +1673,10 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) fx->eflags |= MFE_VERTICALFLIP; else fx->eflags &= ~MFE_VERTICALFLIP; - fx->blendmode = AST_ADD; + + if (cv_blendeffects.value) + fx->blendmode = AST_ADD; + P_SetScale(fx, mobj1->scale); // Because this is done during collision now, rmomx and rmomy need to be recalculated @@ -3302,7 +3311,9 @@ static void K_SpawnDriftSparks(player_t *player) P_SetMobjState(spark, S_DRIFTSPARK_A1); } - spark->blendmode = AST_ADD; + if (cv_blendeffects.value) + spark->blendmode = AST_ADD; + K_MatchGenericExtraFlags(spark, player->mo); } } @@ -3608,7 +3619,8 @@ void K_SpawnBoostTrail(player_t *player) { flame->colorized = true; flame->color = player->skincolor; - flame->blendmode = AST_ADD; + if (cv_blendeffects.value) + flame->blendmode = AST_ADD; } P_SetScale(flame, player->mo->scale); @@ -3660,7 +3672,9 @@ void K_SpawnSparkleTrail(mobj_t *mo) sparkle->destscale = mo->destscale; P_SetScale(sparkle, mo->scale); sparkle->color = mo->color; - sparkle->blendmode = AST_ADD; + + if (mo->player && cv_blendeffects.value) + sparkle->blendmode = AST_ADD; } P_SetMobjState(sparkle, S_KARTINVULN_LARGE1); @@ -5413,13 +5427,16 @@ static boolean K_SpeedLinesShouldBlend(player_t *player) { fixed_t percentspeed = 0; + if (!cv_blendeffects.value) + return false; + if (!player->mo) return false; if (player->kartstuff[k_sneakertimer]) return true; - // this is how the percentage speedometer calcs, i suck at maths so this was the easiest thing to fo lmao + // this is how the percentage speedometer calcs, i suck at maths so this was the easiest thing to do lmao percentspeed = (FixedDiv(player->speed, FixedMul(K_GetKartSpeed(player, false), ORIG_FRICTION))*100)>>FRACBITS; if (percentspeed > 127) // sneaker boost is around 25% From 8cd636c2135f65fa1ab4fecae380b4610ef55273 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 14 Feb 2025 21:22:42 +0100 Subject: [PATCH 381/418] precache level flats and textures on mapload in opengl not entirely sure if this works correctly with encore, have to test a little TODO: move this into hwr file or smth --- src/r_data.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index 98431510d..59698fff7 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1618,6 +1618,79 @@ INT32 R_TextureNumForName(const char *name) return i; } +static size_t P_PrecacheHWRLevelFlats(void) +{ + lumpnum_t lump; + size_t i, flatmem = 0; + + //SoM: 4/18/2000: New flat code to make use of levelflats. + for (i = 0; i < numlevelflats; i++) + { + lump = levelflats[i].lumpnum; + if (devparm) + flatmem += W_LumpLength(lump); + HWR_GetFlat(lump, false); + } + + return flatmem; +} + +static void HWR_PrecacheLevel(void) +{ + char *texturepresent; + size_t j; + + if (demo.playback) + return; + + // do not flush the memory, Z_Malloc twice with same user will cause error in Z_CheckHeap() + if (rendermode != render_opengl) + return; + + // Precache flats. + flatmemory = P_PrecacheHWRLevelFlats(); + + // + // Precache textures. + // + // no need to precache all software textures in 3D mode + // (note they are still used with the reference software view) + texturepresent = calloc(numtextures, sizeof (*texturepresent)); + if (texturepresent == NULL) I_Error("%s: Out of memory looking up textures", "R_PrecacheLevel"); + + for (j = 0; j < numsides; j++) + { + // huh, a potential bug here???? + if (sides[j].toptexture >= 0 && sides[j].toptexture < numtextures) + texturepresent[sides[j].toptexture] = 1; + if (sides[j].midtexture >= 0 && sides[j].midtexture < numtextures) + texturepresent[sides[j].midtexture] = 1; + if (sides[j].bottomtexture >= 0 && sides[j].bottomtexture < numtextures) + texturepresent[sides[j].bottomtexture] = 1; + } + + // Sky texture is always present. + // Note that F_SKY1 is the name used to indicate a sky floor/ceiling as a flat, + // while the sky texture is stored like a wall texture, with a skynum dependent name. + texturepresent[skytexture] = 1; + + texturememory = 0; + for (j = 0; j < (unsigned)numtextures; j++) + { + if (!texturepresent[j]) + continue; + + HWR_GetTexture(j, false); + } + free(texturepresent); + + //TODO: precache sprites too + + CONS_Debug(DBG_SETUP, "Precache level done:\n" + "flatmemory: %s k\n" + "texturememory: %s k\n", sizeu1(flatmemory>>10), sizeu2(texturememory>>10)); +} + // // R_PrecacheLevel // @@ -1635,6 +1708,12 @@ void R_PrecacheLevel(void) if (demo.playback) return; + if (rendermode == render_opengl) + { + HWR_PrecacheLevel(); + return; + } + // do not flush the memory, Z_Malloc twice with same user will cause error in Z_CheckHeap() if (rendermode != render_soft) return; From 19dd5ddbaef04f84ebd7be895edf17de490c5cb1 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 14 Feb 2025 21:31:22 +0100 Subject: [PATCH 382/418] disable ogl precaching on encore mode noencore things need to be handled for now just disable it until i figure out how to check for lineflags here --- src/r_data.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index 59698fff7..997c4c4d8 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1647,6 +1647,11 @@ static void HWR_PrecacheLevel(void) if (rendermode != render_opengl) return; + // TODO: handle encoremode + // lines flagged with ML_TFERLINE should not be remapped, not sure how to properly check for that + if (encoremode) + return; + // Precache flats. flatmemory = P_PrecacheHWRLevelFlats(); From 9bed58a8634c7e08eaa152a7284c62847a032172 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 14 Feb 2025 21:57:57 +0100 Subject: [PATCH 383/418] this is incorrect, dont need it anyways --- src/r_data.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 997c4c4d8..8028bd198 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1618,21 +1618,17 @@ INT32 R_TextureNumForName(const char *name) return i; } -static size_t P_PrecacheHWRLevelFlats(void) +static void P_PrecacheHWRLevelFlats(void) { lumpnum_t lump; - size_t i, flatmem = 0; + size_t i; //SoM: 4/18/2000: New flat code to make use of levelflats. for (i = 0; i < numlevelflats; i++) { lump = levelflats[i].lumpnum; - if (devparm) - flatmem += W_LumpLength(lump); HWR_GetFlat(lump, false); } - - return flatmem; } static void HWR_PrecacheLevel(void) @@ -1653,7 +1649,7 @@ static void HWR_PrecacheLevel(void) return; // Precache flats. - flatmemory = P_PrecacheHWRLevelFlats(); + P_PrecacheHWRLevelFlats(); // // Precache textures. @@ -1679,7 +1675,6 @@ static void HWR_PrecacheLevel(void) // while the sky texture is stored like a wall texture, with a skynum dependent name. texturepresent[skytexture] = 1; - texturememory = 0; for (j = 0; j < (unsigned)numtextures; j++) { if (!texturepresent[j]) @@ -1690,10 +1685,6 @@ static void HWR_PrecacheLevel(void) free(texturepresent); //TODO: precache sprites too - - CONS_Debug(DBG_SETUP, "Precache level done:\n" - "flatmemory: %s k\n" - "texturememory: %s k\n", sizeu1(flatmemory>>10), sizeu2(texturememory>>10)); } // From 15a0b9ab930e0c9ac39860a98ce174d6db3e3523 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 14 Feb 2025 22:57:25 +0100 Subject: [PATCH 384/418] handle encore in ogl precaching thx indev for help <3 --- src/r_data.c | 82 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 8028bd198..99ec720d2 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1621,53 +1621,73 @@ INT32 R_TextureNumForName(const char *name) static void P_PrecacheHWRLevelFlats(void) { lumpnum_t lump; - size_t i; + size_t i, j; - //SoM: 4/18/2000: New flat code to make use of levelflats. - for (i = 0; i < numlevelflats; i++) + // special case for encore remapping + if (encoremode) { - lump = levelflats[i].lumpnum; - HWR_GetFlat(lump, false); + // this does not account for fofs and polyobjects + // TODO: handle atleast fofs + for (i = 0; i < numsectors; i++) + { + for (j = 0; j < 2; j++) + { + boolean ceiling = (j == 1); + INT32 pic = ceiling ? sectors[i].ceilingpic : sectors[i].floorpic; + + lump = levelflats[pic].lumpnum; + HWR_GetFlat(lump, R_NoEncore(§ors[i], ceiling)); + } + } + } + else + { + // on non encore we have it simple + // just load every flat + for (i = 0; i < numlevelflats; i++) + { + lump = levelflats[i].lumpnum; + HWR_GetFlat(lump, false); + } } } static void HWR_PrecacheLevel(void) { char *texturepresent; - size_t j; + size_t i, j; - if (demo.playback) - return; - - // do not flush the memory, Z_Malloc twice with same user will cause error in Z_CheckHeap() if (rendermode != render_opengl) return; - // TODO: handle encoremode - // lines flagged with ML_TFERLINE should not be remapped, not sure how to properly check for that - if (encoremode) - return; - // Precache flats. P_PrecacheHWRLevelFlats(); - // // Precache textures. - // - // no need to precache all software textures in 3D mode - // (note they are still used with the reference software view) texturepresent = calloc(numtextures, sizeof (*texturepresent)); - if (texturepresent == NULL) I_Error("%s: Out of memory looking up textures", "R_PrecacheLevel"); + if (texturepresent == NULL) I_Error("%s: Out of memory looking up textures", "HWR_PrecacheLevel"); - for (j = 0; j < numsides; j++) + for (i = 0; i < numlines; i++) { - // huh, a potential bug here???? - if (sides[j].toptexture >= 0 && sides[j].toptexture < numtextures) - texturepresent[sides[j].toptexture] = 1; - if (sides[j].midtexture >= 0 && sides[j].midtexture < numtextures) - texturepresent[sides[j].midtexture] = 1; - if (sides[j].bottomtexture >= 0 && sides[j].bottomtexture < numtextures) - texturepresent[sides[j].bottomtexture] = 1; + line_t *line = &lines[i]; + boolean noencoremap = (line->flags & ML_TFERLINE); + + // two sides + for (j = 0; j < 2; j++) + { + side_t *side = &sides[line->sidenum[j]]; + + // Single-side linedef + if (line->sidenum[j] == 0xffff) + continue; + + if (side->toptexture >= 0 && side->toptexture < numtextures) + texturepresent[side->toptexture] = noencoremap ? 2 : 1; + if (side->midtexture >= 0 && side->midtexture < numtextures) + texturepresent[side->midtexture] = noencoremap ? 2 : 1; + if (side->bottomtexture >= 0 && side->bottomtexture < numtextures) + texturepresent[side->bottomtexture] = noencoremap ? 2 : 1; + } } // Sky texture is always present. @@ -1675,12 +1695,12 @@ static void HWR_PrecacheLevel(void) // while the sky texture is stored like a wall texture, with a skynum dependent name. texturepresent[skytexture] = 1; - for (j = 0; j < (unsigned)numtextures; j++) + for (i = 0; i < (unsigned)numtextures; i++) { - if (!texturepresent[j]) + if (!texturepresent[i]) continue; - HWR_GetTexture(j, false); + HWR_GetTexture(i, (texturepresent[i] == 2)); } free(texturepresent); From a75bf1b2bb220ff998a684d402c9035c2d885d75 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 14 Feb 2025 23:02:13 +0100 Subject: [PATCH 385/418] move precache into hw_cache.c --- src/hardware/hw_cache.c | 91 +++++++++++++++++++++++++++++++++++++++++ src/hardware/hw_glob.h | 5 ++- src/r_data.c | 91 +---------------------------------------- 3 files changed, 97 insertions(+), 90 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index af06ecba6..7ac8aa631 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -29,6 +29,8 @@ #include "../r_draw.h" #include "../r_main.h" #include "../r_patch.h" // patch rotation +#include "../p_setup.h" // levelflats +#include "../r_sky.h" INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes INT32 textureformat = GL_TEXFMT_P_8; // use chromakey for hole @@ -546,6 +548,95 @@ void HWR_FreeTextureCache(void) gl_numtextures = 0; } +static void P_PrecacheHWRLevelFlats(void) +{ + lumpnum_t lump; + size_t i, j; + + // special case for encore remapping + if (encoremode) + { + // this does not account for fofs and polyobjects + // TODO: handle atleast fofs + for (i = 0; i < numsectors; i++) + { + for (j = 0; j < 2; j++) + { + boolean ceiling = (j == 1); + INT32 pic = ceiling ? sectors[i].ceilingpic : sectors[i].floorpic; + + lump = levelflats[pic].lumpnum; + HWR_GetFlat(lump, R_NoEncore(§ors[i], ceiling)); + } + } + } + else + { + // on non encore we have it simple + // just load every flat + for (i = 0; i < numlevelflats; i++) + { + lump = levelflats[i].lumpnum; + HWR_GetFlat(lump, false); + } + } +} + +void HWR_PrecacheLevel(void) +{ + char *texturepresent; + size_t i, j; + + if (rendermode != render_opengl) + return; + + // Precache flats. + P_PrecacheHWRLevelFlats(); + + // Precache textures. + texturepresent = calloc(numtextures, sizeof (*texturepresent)); + if (texturepresent == NULL) I_Error("%s: Out of memory looking up textures", "HWR_PrecacheLevel"); + + for (i = 0; i < numlines; i++) + { + line_t *line = &lines[i]; + boolean noencoremap = (line->flags & ML_TFERLINE); + + // two sides + for (j = 0; j < 2; j++) + { + side_t *side = &sides[line->sidenum[j]]; + + // Single-side linedef + if (line->sidenum[j] == 0xffff) + continue; + + if (side->toptexture >= 0 && side->toptexture < numtextures) + texturepresent[side->toptexture] = noencoremap ? 2 : 1; + if (side->midtexture >= 0 && side->midtexture < numtextures) + texturepresent[side->midtexture] = noencoremap ? 2 : 1; + if (side->bottomtexture >= 0 && side->bottomtexture < numtextures) + texturepresent[side->bottomtexture] = noencoremap ? 2 : 1; + } + } + + // Sky texture is always present. + // Note that F_SKY1 is the name used to indicate a sky floor/ceiling as a flat, + // while the sky texture is stored like a wall texture, with a skynum dependent name. + texturepresent[skytexture] = 1; + + for (i = 0; i < (unsigned)numtextures; i++) + { + if (!texturepresent[i]) + continue; + + HWR_GetTexture(i, (texturepresent[i] == 2)); + } + free(texturepresent); + + //TODO: precache sprites too +} + void HWR_LoadTextures(size_t pnumtextures) { // we must free it since numtextures changed diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index fe346f4c9..edba8a025 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -49,13 +49,16 @@ typedef struct gl_vissprite_s extern extrasubsector_t *extrasubsectors; extern size_t addsubsector; +void HWR_FreeExtraSubsectors(void); + // -------- // hw_cache.c // -------- void HWR_InitTextureCache(void); void HWR_FreeTextureCache(void); void HWR_FreeMipmapCache(void); -void HWR_FreeExtraSubsectors(void); + +void HWR_PrecacheLevel(void); void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap); // ^ some flats must NOT be remapped to encore, since we remap them as we cache them for ease, adding a toggle here seems wise. diff --git a/src/r_data.c b/src/r_data.c index 99ec720d2..48678863e 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1618,95 +1618,6 @@ INT32 R_TextureNumForName(const char *name) return i; } -static void P_PrecacheHWRLevelFlats(void) -{ - lumpnum_t lump; - size_t i, j; - - // special case for encore remapping - if (encoremode) - { - // this does not account for fofs and polyobjects - // TODO: handle atleast fofs - for (i = 0; i < numsectors; i++) - { - for (j = 0; j < 2; j++) - { - boolean ceiling = (j == 1); - INT32 pic = ceiling ? sectors[i].ceilingpic : sectors[i].floorpic; - - lump = levelflats[pic].lumpnum; - HWR_GetFlat(lump, R_NoEncore(§ors[i], ceiling)); - } - } - } - else - { - // on non encore we have it simple - // just load every flat - for (i = 0; i < numlevelflats; i++) - { - lump = levelflats[i].lumpnum; - HWR_GetFlat(lump, false); - } - } -} - -static void HWR_PrecacheLevel(void) -{ - char *texturepresent; - size_t i, j; - - if (rendermode != render_opengl) - return; - - // Precache flats. - P_PrecacheHWRLevelFlats(); - - // Precache textures. - texturepresent = calloc(numtextures, sizeof (*texturepresent)); - if (texturepresent == NULL) I_Error("%s: Out of memory looking up textures", "HWR_PrecacheLevel"); - - for (i = 0; i < numlines; i++) - { - line_t *line = &lines[i]; - boolean noencoremap = (line->flags & ML_TFERLINE); - - // two sides - for (j = 0; j < 2; j++) - { - side_t *side = &sides[line->sidenum[j]]; - - // Single-side linedef - if (line->sidenum[j] == 0xffff) - continue; - - if (side->toptexture >= 0 && side->toptexture < numtextures) - texturepresent[side->toptexture] = noencoremap ? 2 : 1; - if (side->midtexture >= 0 && side->midtexture < numtextures) - texturepresent[side->midtexture] = noencoremap ? 2 : 1; - if (side->bottomtexture >= 0 && side->bottomtexture < numtextures) - texturepresent[side->bottomtexture] = noencoremap ? 2 : 1; - } - } - - // Sky texture is always present. - // Note that F_SKY1 is the name used to indicate a sky floor/ceiling as a flat, - // while the sky texture is stored like a wall texture, with a skynum dependent name. - texturepresent[skytexture] = 1; - - for (i = 0; i < (unsigned)numtextures; i++) - { - if (!texturepresent[i]) - continue; - - HWR_GetTexture(i, (texturepresent[i] == 2)); - } - free(texturepresent); - - //TODO: precache sprites too -} - // // R_PrecacheLevel // @@ -1724,11 +1635,13 @@ void R_PrecacheLevel(void) if (demo.playback) return; +#ifdef HWRENDER if (rendermode == render_opengl) { HWR_PrecacheLevel(); return; } +#endif // do not flush the memory, Z_Malloc twice with same user will cause error in Z_CheckHeap() if (rendermode != render_soft) From ccefafd172a77c5f60f9c5ddb0f4a9299d1528bc Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 14 Feb 2025 23:24:58 +0100 Subject: [PATCH 386/418] load both encore and non encore tex --- src/hardware/hw_cache.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 7ac8aa631..d11a5c5e0 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -612,11 +612,20 @@ void HWR_PrecacheLevel(void) continue; if (side->toptexture >= 0 && side->toptexture < numtextures) - texturepresent[side->toptexture] = noencoremap ? 2 : 1; + { + texturepresent[side->toptexture] = 1; + texturepresent[side->toptexture] |= noencoremap ? 2 : 1; + } if (side->midtexture >= 0 && side->midtexture < numtextures) - texturepresent[side->midtexture] = noencoremap ? 2 : 1; + { + texturepresent[side->midtexture] = 1; + texturepresent[side->midtexture] |= noencoremap ? 2 : 1; + } if (side->bottomtexture >= 0 && side->bottomtexture < numtextures) - texturepresent[side->bottomtexture] = noencoremap ? 2 : 1; + { + texturepresent[side->bottomtexture] = 1; + texturepresent[side->bottomtexture] |= noencoremap ? 2 : 1; + } } } @@ -630,7 +639,11 @@ void HWR_PrecacheLevel(void) if (!texturepresent[i]) continue; - HWR_GetTexture(i, (texturepresent[i] == 2)); + if (texturepresent[j] & 1) + HWR_GetTexture(j, false); + + if (texturepresent[j] & 2) + HWR_GetTexture(j, true); } free(texturepresent); From 119b18521f4a6ffbc9ca567e4085f14156c3f9ac Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 15 Feb 2025 00:35:34 +0100 Subject: [PATCH 387/418] oops should be i --- src/hardware/hw_cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index d11a5c5e0..9a7357c0c 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -639,11 +639,11 @@ void HWR_PrecacheLevel(void) if (!texturepresent[i]) continue; - if (texturepresent[j] & 1) - HWR_GetTexture(j, false); + if (texturepresent[i] & 1) + HWR_GetTexture(i, false); - if (texturepresent[j] & 2) - HWR_GetTexture(j, true); + if (texturepresent[i] & 2) + HWR_GetTexture(i, true); } free(texturepresent); From 4417eabdc740d6a644e1d2266af6f546ca2de572 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 15 Feb 2025 01:05:44 +0100 Subject: [PATCH 388/418] move texture precache into own function unnesting stuff --- src/hardware/hw_cache.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 9a7357c0c..be6a7056e 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -548,7 +548,7 @@ void HWR_FreeTextureCache(void) gl_numtextures = 0; } -static void P_PrecacheHWRLevelFlats(void) +static void HWR_PrecacheLevelFlats(void) { lumpnum_t lump; size_t i, j; @@ -582,18 +582,11 @@ static void P_PrecacheHWRLevelFlats(void) } } -void HWR_PrecacheLevel(void) +static void HWR_PrecacheLevelTextures(void) { char *texturepresent; size_t i, j; - if (rendermode != render_opengl) - return; - - // Precache flats. - P_PrecacheHWRLevelFlats(); - - // Precache textures. texturepresent = calloc(numtextures, sizeof (*texturepresent)); if (texturepresent == NULL) I_Error("%s: Out of memory looking up textures", "HWR_PrecacheLevel"); @@ -646,6 +639,18 @@ void HWR_PrecacheLevel(void) HWR_GetTexture(i, true); } free(texturepresent); +} + +void HWR_PrecacheLevel(void) +{ + if (rendermode != render_opengl) + return; + + // Precache flats. + HWR_PrecacheLevelFlats(); + + // Precache textures. + HWR_PrecacheLevelTextures(); //TODO: precache sprites too } From 7808dc57407af130dc27f44dd72c7c644d2db5a9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 15 Feb 2025 02:07:50 +0100 Subject: [PATCH 389/418] precache (most) sprites on ogl leveload --- src/hardware/hw_cache.c | 50 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index be6a7056e..186b00c6d 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -641,6 +641,53 @@ static void HWR_PrecacheLevelTextures(void) free(texturepresent); } +static void HWR_PrecacheLevelSprites(void) +{ + char *spritepresent; + size_t i, j, k; + lumpnum_t lump; + + thinker_t *th; + mobj_t *mo; + spriteframe_t *sf; + + spritepresent = calloc(numsprites, sizeof (*spritepresent)); + if (spritepresent == NULL) I_Error("%s: Out of memory looking up sprites", "HWR_PrecacheLevel"); + + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + mo = (mobj_t *)th; + + //FIXME: cant really precache colorized sprites without a colormap + if (mo->color || mo->colorized) + continue; + + spritepresent[mo->sprite] = 1; + } + + for (i = 0; i < numsprites; i++) + { + if (!spritepresent[i]) + continue; + + for (j = 0; j < sprites[i].numframes; j++) + { + sf = &sprites[i].spriteframes[j]; + for (k = 0; k < 8; k++) + { + // see R_InitSprites for more about lumppat,lumpid + lump = sf->lumppat[k]; + + HWR_GetMappedPatch((GLPatch_t *)W_CachePatchNum(lump, PU_CACHE), NULL); + } + } + } + free(spritepresent); +} + void HWR_PrecacheLevel(void) { if (rendermode != render_opengl) @@ -652,7 +699,8 @@ void HWR_PrecacheLevel(void) // Precache textures. HWR_PrecacheLevelTextures(); - //TODO: precache sprites too + // Precache sprites. + HWR_PrecacheLevelSprites(); } void HWR_LoadTextures(size_t pnumtextures) From c1a187084d14371c4ab26c43aedaff054ed3b228 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 15 Feb 2025 02:15:04 +0100 Subject: [PATCH 390/418] dedicated server does not need to call texture precaching prob leftover from back in the day, it doesent do anything at all anyways also gives it a less ambigous name --- src/d_netcmd.c | 4 ++-- src/doomstat.h | 2 +- src/g_game.c | 2 +- src/p_setup.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 0168acc0e..0252e9916 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2969,7 +2969,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) } if (demo.playback && !demo.timing) - precache = false; + precachetextures = false; if (resetplayer) { @@ -2987,7 +2987,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) demo.savebutton = 0; G_InitNew(pencoremode, mapname, resetplayer, skipprecutscene); if (demo.playback && !demo.timing) - precache = true; + precachetextures = true; if (demo.timing) G_DoneLevelLoad(); diff --git a/src/doomstat.h b/src/doomstat.h index f70f97059..35527c581 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -542,7 +542,7 @@ extern INT32 debugload; #endif // if true, load all graphics at level load -extern boolean precache; +extern boolean precachetextures; // wipegamestate can be set to -1 // to force a wipe on the next draw diff --git a/src/g_game.c b/src/g_game.c index 86be0e159..6944565a3 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -330,7 +330,7 @@ static struct { // There is no conflict here. demoghost *ghosts = NULL; -boolean precache = true; // if true, load all graphics at start +boolean precachetextures = true; // if true, load all graphics at start INT16 prevmap, nextmap; diff --git a/src/p_setup.c b/src/p_setup.c index 633c4094e..ff4b5384d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2970,7 +2970,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) if (rendermode != render_none && !reloadinggamestate) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); - if (precache || dedicated) + if (precachetextures) R_PrecacheLevel(); nextmapoverride = 0; From a403d96204e2f292c34871487c88ce01474044cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 15 Feb 2025 14:27:52 +0100 Subject: [PATCH 391/418] also precache animated flats i have no clue how tf animated textures work --- src/hardware/hw_cache.c | 34 +++++++++++++++++++++++++++++----- src/p_setup.c | 2 ++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 186b00c6d..5a7cd8b33 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -550,14 +550,14 @@ void HWR_FreeTextureCache(void) static void HWR_PrecacheLevelFlats(void) { + levelflat_t levelflat; lumpnum_t lump; size_t i, j; + INT32 k; // special case for encore remapping if (encoremode) { - // this does not account for fofs and polyobjects - // TODO: handle atleast fofs for (i = 0; i < numsectors; i++) { for (j = 0; j < 2; j++) @@ -565,8 +565,20 @@ static void HWR_PrecacheLevelFlats(void) boolean ceiling = (j == 1); INT32 pic = ceiling ? sectors[i].ceilingpic : sectors[i].floorpic; - lump = levelflats[pic].lumpnum; + levelflat = levelflats[pic]; + + lump = levelflat.lumpnum; HWR_GetFlat(lump, R_NoEncore(§ors[i], ceiling)); + + if (levelflat.speed) // it is an animated flat + { + for (k = 0; k < levelflat.numpics; k++) + { + levelflat.lumpnum = levelflat.baselumpnum + k; + lump = levelflat.lumpnum; + HWR_GetFlat(lump, R_NoEncore(§ors[i], ceiling)); + } + } } } } @@ -576,8 +588,20 @@ static void HWR_PrecacheLevelFlats(void) // just load every flat for (i = 0; i < numlevelflats; i++) { - lump = levelflats[i].lumpnum; + levelflat = levelflats[i]; + lump = levelflat.lumpnum; + HWR_GetFlat(lump, false); + + if (levelflat.speed) // it is an animated flat + { + for (k = 0; k < levelflat.numpics; k++) + { + levelflat.lumpnum = levelflat.baselumpnum + k; + lump = levelflat.lumpnum; + HWR_GetFlat(lump, false); + } + } } } } @@ -661,7 +685,7 @@ static void HWR_PrecacheLevelSprites(void) mo = (mobj_t *)th; - //FIXME: cant really precache colorized sprites without a colormap + // ogl is weird if (mo->color || mo->colorized) continue; diff --git a/src/p_setup.c b/src/p_setup.c index ff4b5384d..92abf44b6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -624,6 +624,7 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat) // store the flat lump number levelflat->lumpnum = R_GetFlatNumForName(flatname); + levelflat->baselumpnum = LUMPERROR; #ifndef ZDEBUG CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name); @@ -668,6 +669,7 @@ INT32 P_AddLevelFlatRuntime(const char *flatname) // store the flat lump number levelflat->lumpnum = R_GetFlatNumForName(flatname); + levelflat->baselumpnum = LUMPERROR; #ifndef ZDEBUG CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name); From 29b93f63f7afdb625fb28047ef2b7f7b50fba8f7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 15 Feb 2025 16:22:16 +0100 Subject: [PATCH 392/418] precache animated textures too --- src/hardware/hw_cache.c | 32 ++++++++++++++++++++++++++++++++ src/p_spec.c | 17 ++--------------- src/p_spec.h | 16 ++++++++++++++++ 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 5a7cd8b33..991032ac5 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -30,6 +30,7 @@ #include "../r_main.h" #include "../r_patch.h" // patch rotation #include "../p_setup.h" // levelflats +#include "../p_spec.h" // anim_t #include "../r_sky.h" INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes @@ -610,6 +611,8 @@ static void HWR_PrecacheLevelTextures(void) { char *texturepresent; size_t i, j; + INT32 h; + anim_t *anim; texturepresent = calloc(numtextures, sizeof (*texturepresent)); if (texturepresent == NULL) I_Error("%s: Out of memory looking up textures", "HWR_PrecacheLevel"); @@ -646,6 +649,31 @@ static void HWR_PrecacheLevelTextures(void) } } + for (anim = anims; anim < lastanim; anim++) + { + if (!anim->istexture) + continue; + + if (!texturepresent[anim->basepic]) + continue; + + if (texturepresent[anim->basepic] & 1) + { + for (h = 0; h < anim->numpics; h++) + { + HWR_GetTexture(anim->basepic+h, false); + } + } + + if (texturepresent[anim->basepic] & 2) + { + for (h = 0; h < anim->numpics; h++) + { + HWR_GetTexture(anim->basepic+h, true); + } + } + } + // Sky texture is always present. // Note that F_SKY1 is the name used to indicate a sky floor/ceiling as a flat, // while the sky texture is stored like a wall texture, with a skynum dependent name. @@ -657,10 +685,14 @@ static void HWR_PrecacheLevelTextures(void) continue; if (texturepresent[i] & 1) + { HWR_GetTexture(i, false); + } if (texturepresent[i] & 2) + { HWR_GetTexture(i, true); + } } free(texturepresent); } diff --git a/src/p_spec.c b/src/p_spec.c index 3f9dfd626..4eb380df0 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -51,19 +51,6 @@ mobj_t *skyboxmo[2]; // This must be updated whenever we up the max flat size - quicker to assume rather than figuring out the sqrt of the specific flat's filesize. #define MAXFLATSIZE (2048<> ((j-1)*4))&15) +/** Animated texture descriptor + * This keeps track of an animated texture or an animated flat. + * \sa P_UpdateSpecials, P_InitPicAnims, animdef_t + */ +typedef struct +{ + SINT8 istexture; ///< ::true for a texture, ::false for a flat + INT32 picnum; ///< The end flat number + INT32 basepic; ///< The start flat number + INT32 numpics; ///< Number of frames in the animation + tic_t speed; ///< Number of tics for which each frame is shown +} anim_t; + +extern anim_t *lastanim; +extern anim_t *anims; + // at game start void P_InitPicAnims(void); From 4ef6c2ea349d8fbdc0aa98972f8860a0ae68d4ee Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Feb 2025 15:33:58 +0100 Subject: [PATCH 393/418] guard this in sprite precache --- src/hardware/hw_cache.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 991032ac5..48af24ca9 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -699,6 +699,7 @@ static void HWR_PrecacheLevelTextures(void) static void HWR_PrecacheLevelSprites(void) { + GLPatch_t *spritepatch; char *spritepresent; size_t i, j, k; lumpnum_t lump; @@ -718,6 +719,8 @@ static void HWR_PrecacheLevelSprites(void) mo = (mobj_t *)th; // ogl is weird + // for some reason it does not want to preload sprites with colormaps + // so just save us the work if (mo->color || mo->colorized) continue; @@ -732,12 +735,16 @@ static void HWR_PrecacheLevelSprites(void) for (j = 0; j < sprites[i].numframes; j++) { sf = &sprites[i].spriteframes[j]; + for (k = 0; k < 8; k++) { // see R_InitSprites for more about lumppat,lumpid lump = sf->lumppat[k]; + spritepatch = (GLPatch_t *)W_CachePatchNum(lump, PU_CACHE); - HWR_GetMappedPatch((GLPatch_t *)W_CachePatchNum(lump, PU_CACHE), NULL); + // yes this may be NULL + if (spritepatch != NULL) + HWR_GetPatch(spritepatch); // no colormapped sprites for us } } } From 83b242a727d2e8c9cd3c96caee24d5c4493b33de Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Feb 2025 15:34:54 +0100 Subject: [PATCH 394/418] make texture precache toggable --- src/d_netcmd.c | 6 +----- src/doomstat.h | 3 --- src/g_game.c | 2 -- src/p_setup.c | 2 +- src/r_data.c | 8 ++++---- src/r_main.c | 5 +++++ src/r_main.h | 1 + 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 0252e9916..df5670f7c 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2968,9 +2968,6 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) CON_LogMessage(M_GetText("Speeding off to level...\n")); } - if (demo.playback && !demo.timing) - precachetextures = false; - if (resetplayer) { if (!FLS || (netgame || multiplayer)) @@ -2986,8 +2983,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING; demo.savebutton = 0; G_InitNew(pencoremode, mapname, resetplayer, skipprecutscene); - if (demo.playback && !demo.timing) - precachetextures = true; + if (demo.timing) G_DoneLevelLoad(); diff --git a/src/doomstat.h b/src/doomstat.h index 35527c581..1d487d2f4 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -541,9 +541,6 @@ extern FILE *debugfile; extern INT32 debugload; #endif -// if true, load all graphics at level load -extern boolean precachetextures; - // wipegamestate can be set to -1 // to force a wipe on the next draw extern gamestate_t wipegamestate; diff --git a/src/g_game.c b/src/g_game.c index 6944565a3..9b52b8680 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -330,8 +330,6 @@ static struct { // There is no conflict here. demoghost *ghosts = NULL; -boolean precachetextures = true; // if true, load all graphics at start - INT16 prevmap, nextmap; // save if director is enabled diff --git a/src/p_setup.c b/src/p_setup.c index 92abf44b6..404b0236d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2972,7 +2972,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) if (rendermode != render_none && !reloadinggamestate) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); - if (precachetextures) + if (cv_precachetextures.value) R_PrecacheLevel(); nextmapoverride = 0; diff --git a/src/r_data.c b/src/r_data.c index 48678863e..cc832f8c9 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1632,6 +1632,10 @@ void R_PrecacheLevel(void) thinker_t *th; spriteframe_t *sf; + // do not flush the memory, Z_Malloc twice with same user will cause error in Z_CheckHeap() + if (rendermode == render_none) + return; + if (demo.playback) return; @@ -1643,10 +1647,6 @@ void R_PrecacheLevel(void) } #endif - // do not flush the memory, Z_Malloc twice with same user will cause error in Z_CheckHeap() - if (rendermode != render_soft) - return; - // Precache flats. flatmemory = P_PrecacheLevelFlats(); diff --git a/src/r_main.c b/src/r_main.c index ba60d2553..b39b58749 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -164,6 +164,9 @@ static void Precipstuff_OnChange(void); consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +// if enabled, load all graphics at level load +consvar_t cv_precachetextures = {"precachetextures", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS] = { {"chasecam", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"chasecam2", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, @@ -1532,6 +1535,8 @@ void R_RegisterEngineStuff(void) if (dedicated) return; + CV_RegisterVar(&cv_precachetextures); + CV_RegisterVar(&cv_translucency); CV_RegisterVar(&cv_drawdist); CV_RegisterVar(&cv_drawdist_precip); diff --git a/src/r_main.h b/src/r_main.h index 9a976d659..1b8d8c71c 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -174,6 +174,7 @@ extern ps_metric_t ps_numpolyobjects; // REFRESH - the actual rendering functions. // +extern consvar_t cv_precachetextures; extern consvar_t cv_showhud, cv_translucenthud, cv_uncappedhud; extern consvar_t cv_homremoval; extern consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS]; From 255c8437d7f9d0981b31e9bf4d7449dacbc8e9e8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Feb 2025 15:37:18 +0100 Subject: [PATCH 395/418] slightly optimize ogl precaching cleanup too --- src/hardware/hw_cache.c | 72 ++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 48af24ca9..dbf97a159 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -556,37 +556,42 @@ static void HWR_PrecacheLevelFlats(void) size_t i, j; INT32 k; - // special case for encore remapping + // special case for encore +#ifdef GLENCORE if (encoremode) { + // go through all sectors to determine if it should be remapped for encore for (i = 0; i < numsectors; i++) { + sector_t *sec = §ors[i]; + + // gotta check sector floor and ceiling for (j = 0; j < 2; j++) { - boolean ceiling = (j == 1); - INT32 pic = ceiling ? sectors[i].ceilingpic : sectors[i].floorpic; + const boolean ceiling = (j == 1); + INT32 pic = ceiling ? sec->ceilingpic : sec->floorpic; levelflat = levelflats[pic]; lump = levelflat.lumpnum; - HWR_GetFlat(lump, R_NoEncore(§ors[i], ceiling)); + HWR_GetFlat(lump, R_NoEncore(sec, ceiling)); if (levelflat.speed) // it is an animated flat { - for (k = 0; k < levelflat.numpics; k++) + for (k = 1; k < levelflat.numpics; k++) { - levelflat.lumpnum = levelflat.baselumpnum + k; - lump = levelflat.lumpnum; - HWR_GetFlat(lump, R_NoEncore(§ors[i], ceiling)); + lump = levelflat.baselumpnum + k; + HWR_GetFlat(lump, R_NoEncore(sec, ceiling)); } } } } } else +#endif { // on non encore we have it simple - // just load every flat + // just load every flat in the level for (i = 0; i < numlevelflats; i++) { levelflat = levelflats[i]; @@ -596,10 +601,9 @@ static void HWR_PrecacheLevelFlats(void) if (levelflat.speed) // it is an animated flat { - for (k = 0; k < levelflat.numpics; k++) + for (k = 1; k < levelflat.numpics; k++) { - levelflat.lumpnum = levelflat.baselumpnum + k; - lump = levelflat.lumpnum; + lump = levelflat.baselumpnum + k; HWR_GetFlat(lump, false); } } @@ -610,9 +614,9 @@ static void HWR_PrecacheLevelFlats(void) static void HWR_PrecacheLevelTextures(void) { char *texturepresent; + anim_t *anim; size_t i, j; INT32 h; - anim_t *anim; texturepresent = calloc(numtextures, sizeof (*texturepresent)); if (texturepresent == NULL) I_Error("%s: Out of memory looking up textures", "HWR_PrecacheLevel"); @@ -620,7 +624,11 @@ static void HWR_PrecacheLevelTextures(void) for (i = 0; i < numlines; i++) { line_t *line = &lines[i]; - boolean noencoremap = (line->flags & ML_TFERLINE); +#ifdef GLENCORE + const int noencoremap = ((line->flags & ML_TFERLINE) ? 2 : 1); +#else + const int noencoremap = 1; +#endif // two sides for (j = 0; j < 2; j++) @@ -633,45 +641,46 @@ static void HWR_PrecacheLevelTextures(void) if (side->toptexture >= 0 && side->toptexture < numtextures) { - texturepresent[side->toptexture] = 1; - texturepresent[side->toptexture] |= noencoremap ? 2 : 1; + texturepresent[side->toptexture] = 1|noencoremap; } if (side->midtexture >= 0 && side->midtexture < numtextures) { - texturepresent[side->midtexture] = 1; - texturepresent[side->midtexture] |= noencoremap ? 2 : 1; + texturepresent[side->midtexture] = 1|noencoremap; } if (side->bottomtexture >= 0 && side->bottomtexture < numtextures) { - texturepresent[side->bottomtexture] = 1; - texturepresent[side->bottomtexture] |= noencoremap ? 2 : 1; + texturepresent[side->bottomtexture] = 1|noencoremap; } } } + // check for animated textures for (anim = anims; anim < lastanim; anim++) { if (!anim->istexture) continue; - if (!texturepresent[anim->basepic]) + const char texpresent = texturepresent[anim->basepic]; + + if (!texpresent) continue; - if (texturepresent[anim->basepic] & 1) + if (texpresent & 1) { - for (h = 0; h < anim->numpics; h++) + for (h = 1; h < anim->numpics; h++) { HWR_GetTexture(anim->basepic+h, false); } } - - if (texturepresent[anim->basepic] & 2) +#ifdef GLENCORE + if (texpresent & 2) { - for (h = 0; h < anim->numpics; h++) + for (h = 1; h < anim->numpics; h++) { HWR_GetTexture(anim->basepic+h, true); } } +#endif } // Sky texture is always present. @@ -681,18 +690,21 @@ static void HWR_PrecacheLevelTextures(void) for (i = 0; i < (unsigned)numtextures; i++) { - if (!texturepresent[i]) + const char texpresent = texturepresent[i]; + + if (!texpresent) continue; - if (texturepresent[i] & 1) + if (texpresent & 1) { HWR_GetTexture(i, false); } - - if (texturepresent[i] & 2) +#ifdef GLENCORE + if (texpresent & 2) { HWR_GetTexture(i, true); } +#endif } free(texturepresent); } From 5b0a662b406b376f34538205231d7833abb16f4b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Feb 2025 15:37:43 +0100 Subject: [PATCH 396/418] skip checking sectors and lines multiple times --- src/hardware/hw_cache.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index dbf97a159..6f8b98745 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -565,6 +565,12 @@ static void HWR_PrecacheLevelFlats(void) { sector_t *sec = §ors[i]; + // sector checked already? + if (sec->validcount == validcount) + continue; + + sec->validcount = validcount; + // gotta check sector floor and ceiling for (j = 0; j < 2; j++) { @@ -630,6 +636,12 @@ static void HWR_PrecacheLevelTextures(void) const int noencoremap = 1; #endif + // line checked already? + if (line->validcount == validcount) + continue; + + line->validcount = validcount; + // two sides for (j = 0; j < 2; j++) { From fcd8cfc4d56bb88813e72e095825387788ccdc75 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Feb 2025 16:38:42 +0100 Subject: [PATCH 397/418] better handling of sprite angles in precache only cache stuff that we need --- src/hardware/hw_cache.c | 31 ++++++++++++++++++++++--------- src/r_data.c | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 6f8b98745..eccf09af4 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -760,16 +760,29 @@ static void HWR_PrecacheLevelSprites(void) { sf = &sprites[i].spriteframes[j]; - for (k = 0; k < 8; k++) - { - // see R_InitSprites for more about lumppat,lumpid - lump = sf->lumppat[k]; - spritepatch = (GLPatch_t *)W_CachePatchNum(lump, PU_CACHE); - - // yes this may be NULL - if (spritepatch != NULL) - HWR_GetPatch(spritepatch); // no colormapped sprites for us +#define cacheang(a) {\ + lump = sf->lumppat[a];\ + spritepatch = (GLPatch_t *)W_CachePatchNum(lump, PU_CACHE);\ + if (spritepatch != NULL)\ + HWR_GetPatch(spritepatch);\ } + // see R_InitSprites for more about lumppat,lumpid + switch (sf->rotate) + { + case SRF_SINGLE: + cacheang(0); + break; + case SRF_2D: + cacheang(2); + cacheang(6); + break; + default: + k = 8; + while (k--) + cacheang(k); + break; + } +#undef cacheang } } free(spritepresent); diff --git a/src/r_data.c b/src/r_data.c index cc832f8c9..1ed4b34ee 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1694,8 +1694,12 @@ void R_PrecacheLevel(void) if (spritepresent == NULL) I_Error("%s: Out of memory looking up sprites", "R_PrecacheLevel"); for (th = thinkercap.next; th != &thinkercap; th = th->next) - if (th->function.acp1 == (actionf_p1)P_MobjThinker) - spritepresent[((mobj_t *)th)->sprite] = 1; + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + spritepresent[((mobj_t *)th)->sprite] = 1; + } spritememory = 0; for (i = 0; i < numsprites; i++) @@ -1706,16 +1710,32 @@ void R_PrecacheLevel(void) for (j = 0; j < sprites[i].numframes; j++) { sf = &sprites[i].spriteframes[j]; - for (k = 0; k < 8; k++) +#define cacheang(a) {\ + lump = sf->lumppat[a];\ + if (devparm)\ + spritememory += W_LumpLength(lump);\ + W_CachePatchNum(lump, PU_CACHE);\ + } + // see R_InitSprites for more about lumppat,lumpid + switch (sf->rotate) { - // see R_InitSprites for more about lumppat,lumpid - lump = sf->lumppat[k]; - if (devparm) - spritememory += W_LumpLength(lump); - W_CachePatchNum(lump, PU_CACHE); + case SRF_SINGLE: + cacheang(0); + break; + case SRF_2D: + cacheang(2); + cacheang(6); + break; + default: + k = 8; + while (k--) + cacheang(k); + break; } +#undef cacheang } } + free(spritepresent); // FIXME: this is no longer correct with OpenGL render mode From 7bf50c69e229e788ef20251d3cd5a7f815382917 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Feb 2025 16:47:06 +0100 Subject: [PATCH 398/418] update software precache spit stuff into functions handle animated textures and flats too --- src/p_setup.c | 16 +++++++- src/r_data.c | 109 +++++++++++++++++++++++++++++++------------------- 2 files changed, 83 insertions(+), 42 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 404b0236d..a98aa594d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -586,16 +586,30 @@ levelflat_t *levelflats; //SoM: Other files want this info. size_t P_PrecacheLevelFlats(void) { + levelflat_t levelflat; lumpnum_t lump; size_t i, flatmem = 0; + INT32 k; //SoM: 4/18/2000: New flat code to make use of levelflats. for (i = 0; i < numlevelflats; i++) { - lump = levelflats[i].lumpnum; + levelflat = levelflats[i]; + lump = levelflat.lumpnum; if (devparm) flatmem += W_LumpLength(lump); R_GetFlat(lump); + + if (levelflat.speed) // it is an animated flat + { + for (k = 1; k < levelflat.numpics; k++) + { + lump = levelflat.baselumpnum + k; + if (devparm) + flatmem += W_LumpLength(lump); + R_GetFlat(lump); + } + } } return flatmem; diff --git a/src/r_data.c b/src/r_data.c index 1ed4b34ee..5070107be 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1618,41 +1618,13 @@ INT32 R_TextureNumForName(const char *name) return i; } -// -// R_PrecacheLevel -// -// Preloads all relevant graphics for the level. -// -void R_PrecacheLevel(void) +static void R_PrecacheLevelTextures(void) { - char *texturepresent, *spritepresent; - size_t i, j, k; - lumpnum_t lump; + char *texturepresent; + anim_t *anim; + size_t j; + INT32 h; - thinker_t *th; - spriteframe_t *sf; - - // do not flush the memory, Z_Malloc twice with same user will cause error in Z_CheckHeap() - if (rendermode == render_none) - return; - - if (demo.playback) - return; - -#ifdef HWRENDER - if (rendermode == render_opengl) - { - HWR_PrecacheLevel(); - return; - } -#endif - - // Precache flats. - flatmemory = P_PrecacheLevelFlats(); - - // - // Precache textures. - // // no need to precache all software textures in 3D mode // (note they are still used with the reference software view) texturepresent = calloc(numtextures, sizeof (*texturepresent)); @@ -1669,6 +1641,22 @@ void R_PrecacheLevel(void) texturepresent[sides[j].bottomtexture] = 1; } + // check for animated textures + for (anim = anims; anim < lastanim; anim++) + { + if (!anim->istexture) + continue; + + if (!texturepresent[anim->basepic]) + continue; + + for (h = 1; h < anim->numpics; h++) + { + if (!texturecache[anim->basepic+h]) + R_GenerateTexture(anim->basepic+h); + } + } + // Sky texture is always present. // Note that F_SKY1 is the name used to indicate a sky floor/ceiling as a flat, // while the sky texture is stored like a wall texture, with a skynum dependent name. @@ -1686,10 +1674,17 @@ void R_PrecacheLevel(void) // since we cache entire composite textures } free(texturepresent); +} + +static void R_PrecacheLevelSprites(void) +{ + char *spritepresent; + size_t i, j, k; + lumpnum_t lump; + + thinker_t *th; + spriteframe_t *sf; - // - // Precache sprites. - // spritepresent = calloc(numsprites, sizeof (*spritepresent)); if (spritepresent == NULL) I_Error("%s: Out of memory looking up sprites", "R_PrecacheLevel"); @@ -1711,11 +1706,11 @@ void R_PrecacheLevel(void) { sf = &sprites[i].spriteframes[j]; #define cacheang(a) {\ - lump = sf->lumppat[a];\ - if (devparm)\ - spritememory += W_LumpLength(lump);\ - W_CachePatchNum(lump, PU_CACHE);\ - } + lump = sf->lumppat[a];\ + if (devparm)\ + spritememory += W_LumpLength(lump);\ + W_CachePatchNum(lump, PU_CACHE);\ + } // see R_InitSprites for more about lumppat,lumpid switch (sf->rotate) { @@ -1737,6 +1732,38 @@ void R_PrecacheLevel(void) } free(spritepresent); +} + +// +// R_PrecacheLevel +// +// Preloads all relevant graphics for the level. +// +void R_PrecacheLevel(void) +{ + // do not flush the memory, Z_Malloc twice with same user will cause error in Z_CheckHeap() + if (rendermode == render_none) + return; + + if (demo.playback) + return; + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + HWR_PrecacheLevel(); + return; + } +#endif + + // Precache flats. + flatmemory = P_PrecacheLevelFlats(); + + // Precache textures. + R_PrecacheLevelTextures(); + + // Precache sprites. + R_PrecacheLevelSprites(); // FIXME: this is no longer correct with OpenGL render mode CONS_Debug(DBG_SETUP, "Precache level done:\n" From a9429caf099eb91c0506e33adb9e4853016a4811 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 17 Feb 2025 14:21:44 +0300 Subject: [PATCH 399/418] Fix "attempt to perform arithmetic on a number value" errors Not best fix but i don't know why setnumV breaks here --- src/bluajit/lib_table.c | 6 +++++- src/bluajit/lj_carith.c | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/bluajit/lib_table.c b/src/bluajit/lib_table.c index 97ba2847e..c1b6e40fa 100644 --- a/src/bluajit/lib_table.c +++ b/src/bluajit/lib_table.c @@ -9,6 +9,8 @@ #define lib_table_c #define LUA_LIB +#include "../console.h" + #include "lua.h" #include "lauxlib.h" #include "lualib.h" @@ -72,7 +74,9 @@ LJLIB_CF(table_maxn) lua_Number n = numberVnum(&node[i].key); if (n > m) m = n; } - setnumV(L->top-1, m); + /* This should be setnumV but for some reason it makes numbers broken, + * which causes "attempt to perform arithmetic on a number value" errors */ + setintV(L->top-1, m); return 1; } diff --git a/src/bluajit/lj_carith.c b/src/bluajit/lj_carith.c index ffda626e1..ed8fff31f 100644 --- a/src/bluajit/lj_carith.c +++ b/src/bluajit/lj_carith.c @@ -249,11 +249,11 @@ static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm) } for (i = 0; i < 2; i++) { if (ca->ct[i] && tviscdata(L->base+i)) { - if (ctype_isenum(ca->ct[i]->info)) isenum = i; - repr[i] = strdata(lj_ctype_repr(L, ctype_typeid(cts, ca->ct[i]), NULL)); + if (ctype_isenum(ca->ct[i]->info)) isenum = i; + repr[i] = strdata(lj_ctype_repr(L, ctype_typeid(cts, ca->ct[i]), NULL)); } else { - if (tvisstr(&L->base[i])) isstr = i; - repr[i] = lj_typename(&L->base[i]); + if (tvisstr(&L->base[i])) isstr = i; + repr[i] = lj_typename(&L->base[i]); } } if ((isenum ^ isstr) == 1) From a1f254a0bcc930a23856f2d2a21b5f862d9e4628 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Feb 2025 16:59:50 +0100 Subject: [PATCH 400/418] ensure proper casting for elapsedseconds --- src/i_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i_time.c b/src/i_time.c index a1ef580bd..931696379 100644 --- a/src/i_time.c +++ b/src/i_time.c @@ -61,7 +61,7 @@ void I_UpdateTime(fixed_t timescale) ticratescaled = (double)TICRATE * FIXED_TO_FLOAT(timescale); enterprecise = I_GetPreciseTime(); - elapsedseconds = (double)(enterprecise - oldenterprecise) / I_GetPrecisePrecision(); + elapsedseconds = (double)((INT64)enterprecise - oldenterprecise) / I_GetPrecisePrecision(); tictimer += elapsedseconds; while (tictimer > 1.0/ticratescaled) { From ca555e7ea6304e3e9b28bbcce8d20e5e4f264ef6 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Feb 2025 17:02:09 +0100 Subject: [PATCH 401/418] fix some typos lel --- src/lzf.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lzf.c b/src/lzf.c index f81c3ee0a..96f8973fc 100644 --- a/src/lzf.c +++ b/src/lzf.c @@ -37,9 +37,8 @@ /* * Sacrifice very little compression quality in favour of compression speed. * This gives almost the same compression as the default code, and is - * (very roughly) 15% faster. This is the preferable mode of operation. + * (very roughly) 15% faster. This is the preferred mode of operation. */ - #ifndef VERY_FAST # define VERY_FAST 1 #endif @@ -48,7 +47,7 @@ * Sacrifice some more compression quality in favour of compression speed. * (roughly 1-2% worse compression for large blocks and * 9-10% for small, redundant, blocks and >>20% better speed in both cases) - * In INT16: when in need for speed, enable this for binary data, + * In short: when in need for speed, enable this for binary data, * possibly disable this for text data. */ #ifndef ULTRA_FAST @@ -80,7 +79,8 @@ /* * You may choose to pre-set the hash table (might be faster on some - * modern cpus and large (>>64k) blocks) + * modern cpus and large (>>64k) blocks, and also makes compression + * deterministic/repeatable when the configuration otherwise is the same). */ #ifndef INIT_HTAB # define INIT_HTAB 1 @@ -88,15 +88,15 @@ /* * Avoid assigning values to errno variable? for some embedding purposes - * (linux kernel for example), this is neccessary. NOTE: this breaks - * the documentation in lzf.h. + * (linux kernel for example), this is necessary. NOTE: this breaks + * the documentation in lzf.h. Avoiding errno has no speed impact. */ #ifndef AVOID_ERRNO # define AVOID_ERRNO 0 #endif /* - * Wether to pass the LZF_STATE variable as argument, or allocate it + * Whether to pass the LZF_STATE variable as argument, or allocate it * on the stack. For small-stack environments, define this to 1. * NOTE: this breaks the prototype in lzf.h. */ @@ -105,11 +105,11 @@ #endif /* - * Wether to add extra checks for input validity in lzf_decompress + * Whether to add extra checks for input validity in lzf_decompress * and return EINVAL if the input stream has been corrupted. This * only shields against overflowing the input buffer and will not * detect most corrupted streams. - * This check is not normally noticable on modern hardware + * This check is not normally noticeable on modern hardware * (<1% slowdown), but might slow down older cpus considerably. */ #ifndef CHECK_INPUT From b61e29ef0f0c0dc6bbbdbbacac03b024e7d07d8a Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Feb 2025 17:06:36 +0100 Subject: [PATCH 402/418] die json --- src/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/.gitignore b/src/.gitignore index da5a1fff2..d1d328f14 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,2 +1,4 @@ /cscope.out /srb2wii +*.json +*.idx From c78ecd8453130718d0bde7080106988c325e78e8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Feb 2025 17:42:49 +0100 Subject: [PATCH 403/418] Revert "Fix "attempt to perform arithmetic on a number value" errors" This reverts commit a9429caf099eb91c0506e33adb9e4853016a4811. --- src/bluajit/lib_table.c | 6 +----- src/bluajit/lj_carith.c | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/bluajit/lib_table.c b/src/bluajit/lib_table.c index c1b6e40fa..97ba2847e 100644 --- a/src/bluajit/lib_table.c +++ b/src/bluajit/lib_table.c @@ -9,8 +9,6 @@ #define lib_table_c #define LUA_LIB -#include "../console.h" - #include "lua.h" #include "lauxlib.h" #include "lualib.h" @@ -74,9 +72,7 @@ LJLIB_CF(table_maxn) lua_Number n = numberVnum(&node[i].key); if (n > m) m = n; } - /* This should be setnumV but for some reason it makes numbers broken, - * which causes "attempt to perform arithmetic on a number value" errors */ - setintV(L->top-1, m); + setnumV(L->top-1, m); return 1; } diff --git a/src/bluajit/lj_carith.c b/src/bluajit/lj_carith.c index ed8fff31f..ffda626e1 100644 --- a/src/bluajit/lj_carith.c +++ b/src/bluajit/lj_carith.c @@ -249,11 +249,11 @@ static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm) } for (i = 0; i < 2; i++) { if (ca->ct[i] && tviscdata(L->base+i)) { - if (ctype_isenum(ca->ct[i]->info)) isenum = i; - repr[i] = strdata(lj_ctype_repr(L, ctype_typeid(cts, ca->ct[i]), NULL)); + if (ctype_isenum(ca->ct[i]->info)) isenum = i; + repr[i] = strdata(lj_ctype_repr(L, ctype_typeid(cts, ca->ct[i]), NULL)); } else { - if (tvisstr(&L->base[i])) isstr = i; - repr[i] = lj_typename(&L->base[i]); + if (tvisstr(&L->base[i])) isstr = i; + repr[i] = lj_typename(&L->base[i]); } } if ((isenum ^ isstr) == 1) From 13b2f6534e213648a1887bf1a60db086f4ca67f0 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Sun, 5 Jan 2025 23:41:54 +0100 Subject: [PATCH 404/418] Fix some functions leaking doubles in INTONLY --- src/bluajit/lib_base.c | 4 ++++ src/bluajit/lib_table.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/bluajit/lib_base.c b/src/bluajit/lib_base.c index e7912c729..7ffdc3dd9 100644 --- a/src/bluajit/lib_base.c +++ b/src/bluajit/lib_base.c @@ -470,7 +470,11 @@ LJLIB_CF(collectgarbage) "\4stop\7restart\7collect\5count\1\377\4step\10setpause\12setstepmul\1\377\11isrunning"); int32_t data = lj_lib_optint(L, 2, 0); if (opt == LUA_GCCOUNT) { +#if LJ_INTONLY + setintV(L->top, G(L)->gc.total/1024); +#else setnumV(L->top, (lua_Number)G(L)->gc.total/1024.0); +#endif } else { int res = lua_gc(L, opt, data); if (opt == LUA_GCSTEP || opt == LUA_GCISRUNNING) diff --git a/src/bluajit/lib_table.c b/src/bluajit/lib_table.c index 97ba2847e..f4266b2f0 100644 --- a/src/bluajit/lib_table.c +++ b/src/bluajit/lib_table.c @@ -72,7 +72,11 @@ LJLIB_CF(table_maxn) lua_Number n = numberVnum(&node[i].key); if (n > m) m = n; } +#if LJ_INTONLY + setintV(L->top-1, lj_num2int(m)); +#else setnumV(L->top-1, m); +#endif return 1; } From badb8c7914cc1adbbc7afdcc9fa820854d110902 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Mon, 6 Jan 2025 00:02:11 +0100 Subject: [PATCH 405/418] Add cleanjit target Recompiling the whole game after changing a single flag is pretty tiring --- src/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Makefile b/src/Makefile index cb71bc741..27fece775 100644 --- a/src/Makefile +++ b/src/Makefile @@ -624,6 +624,10 @@ clean: $(REMOVE) $(OBJDIR)/*.o ifndef NOBLUAJIT $(REMOVE) $(OBJDIR)/buildvm* $(OBJDIR)/minilua* $(OBJDIR)/lj_vm* $(ALL_HDRGEN) + +cleanjit: + $(REMOVE) $(LJVMCORE_O) $(ALL_GEN) + $(REMOVE) $(OBJDIR)/buildvm* $(OBJDIR)/minilua* $(OBJDIR)/lj_vm* $(ALL_HDRGEN) endif ifdef MINGW From 10f150736658bbcb4939f1be7950198754a594c9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Feb 2025 18:04:38 +0100 Subject: [PATCH 406/418] Revert "Merge pull request #151 from Indev450/fixdupeacks" This reverts commit 1fabc14ac9c4b4dd7283aca19183b8cd3ca59185, reversing changes made to d9492eee282834066bd06e9fba96fca09582f772. --- src/d_net.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 403788e5a..d6b0e2f80 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -325,10 +325,10 @@ static void RemoveAck(INT32 i) } // We have got a packet, proceed the ack request and ack return -static int Processackpak(void) +static boolean Processackpak(void) { INT32 i; - int goodpacket = 0; + boolean goodpacket = true; node_t *node = &nodes[doomcom->remotenode]; // Received an ack return, so remove the ack in the list @@ -353,7 +353,7 @@ static int Processackpak(void) { DEBFILE(va("Discard(1) ack %d (duplicated)\n", ack)); duppacket++; - goodpacket = 1; // Discard packet (duplicate) + goodpacket = false; // Discard packet (duplicate) } else { @@ -363,10 +363,10 @@ static int Processackpak(void) { DEBFILE(va("Discard(2) ack %d (duplicated)\n", ack)); duppacket++; - goodpacket = 1; // Discard packet (duplicate) + goodpacket = false; // Discard packet (duplicate) break; } - if (goodpacket == 0) + if (goodpacket) { // Is a good packet so increment the acknowledge number, // Then search for a "hole" in the queue @@ -427,13 +427,12 @@ static int Processackpak(void) else // Buffer full discard packet, sender will resend it { // We can admit the packet but we will not detect the duplication after :( DEBFILE("no more freeackret\n"); - goodpacket = 2; + goodpacket = false; } } } } } - // return values: 0 = ok, 1 = duplicate, 2 = out of order return goodpacket; } #endif @@ -1160,7 +1159,6 @@ boolean HGetPacket(void) while(true) { //nodejustjoined = I_NetGet(); - int goodpacket; I_NetGet(); if (doomcom->remotenode == -1) // No packet received @@ -1205,15 +1203,8 @@ boolean HGetPacket(void) }*/ // Proceed the ack and ackreturn field - goodpacket = Processackpak(); - if (goodpacket != 0) - { - // resend the ACK in case the previous ACK didn't reach the client. - // prevents the client's netbuffer from locking up. - if (goodpacket == 1) - Net_SendAcks(doomcom->remotenode); + if (!Processackpak()) continue; // discarded (duplicated) - } // A packet with just ackreturn if (netbuffer->packettype == PT_NOTHING) From 7322d553ba6a832868fe9c70780ee6b09e94eee2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Feb 2025 18:05:30 +0100 Subject: [PATCH 407/418] Revert "Merge pull request #151 from Indev450/fixdupeacks" This reverts commit 1fabc14ac9c4b4dd7283aca19183b8cd3ca59185, reversing changes made to d9492eee282834066bd06e9fba96fca09582f772. --- src/d_net.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 6f43147b9..16156ca06 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -325,10 +325,10 @@ static void RemoveAck(INT32 i) } // We have got a packet, proceed the ack request and ack return -static int Processackpak(void) +static boolean Processackpak(void) { INT32 i; - int goodpacket = 0; + boolean goodpacket = true; node_t *node = &nodes[doomcom->remotenode]; // Received an ack return, so remove the ack in the list @@ -353,7 +353,7 @@ static int Processackpak(void) { DEBFILE(va("Discard(1) ack %d (duplicated)\n", ack)); duppacket++; - goodpacket = 1; // Discard packet (duplicate) + goodpacket = false; // Discard packet (duplicate) } else { @@ -363,10 +363,10 @@ static int Processackpak(void) { DEBFILE(va("Discard(2) ack %d (duplicated)\n", ack)); duppacket++; - goodpacket = 1; // Discard packet (duplicate) + goodpacket = false; // Discard packet (duplicate) break; } - if (goodpacket == 0) + if (goodpacket) { // Is a good packet so increment the acknowledge number, // Then search for a "hole" in the queue @@ -427,13 +427,12 @@ static int Processackpak(void) else // Buffer full discard packet, sender will resend it { // We can admit the packet but we will not detect the duplication after :( DEBFILE("no more freeackret\n"); - goodpacket = 2; + goodpacket = false; } } } } } - // return values: 0 = ok, 1 = duplicate, 2 = out of order return goodpacket; } #endif @@ -1160,7 +1159,6 @@ boolean HGetPacket(void) while(true) { //nodejustjoined = I_NetGet(); - int goodpacket; I_NetGet(); if (doomcom->remotenode == -1) // No packet received @@ -1205,15 +1203,8 @@ boolean HGetPacket(void) }*/ // Proceed the ack and ackreturn field - goodpacket = Processackpak(); - if (goodpacket != 0) - { - // resend the ACK in case the previous ACK didn't reach the client. - // prevents the client's netbuffer from locking up. - if (goodpacket == 1) - Net_SendAcks(doomcom->remotenode); + if (!Processackpak()) continue; // discarded (duplicated) - } // A packet with just ackreturn if (netbuffer->packettype == PT_NOTHING) From 75d69dc90ddef61b0c11aac67ea17895f13cbfa4 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Feb 2025 20:54:37 +0100 Subject: [PATCH 408/418] skip a bunch of stuff in dedi/render_none --- src/d_main.c | 5 ++++- src/p_mobj.c | 4 ++++ src/p_tick.c | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index af25ae2ea..0bfda85a2 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -183,6 +183,9 @@ static void D_GamePadMenuScrollTicker(void) static SINT8 menuInputDelayTimer = 0; int key = 0; // butt-on output + if (dedicated) + return; + // wish i had a switch ono if (DPADUPSCROLL) key = KEY_UPARROW; @@ -214,7 +217,7 @@ static void D_DeviceLEDTick(void) UINT16 color[MAXSPLITSCREENPLAYERS]; UINT16 curcolor[MAXSPLITSCREENPLAYERS]; - if (I_NumJoys() == 0) + if (dedicated || I_NumJoys() == 0) { return; } diff --git a/src/p_mobj.c b/src/p_mobj.c index 77e65c24f..09f246a85 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6039,6 +6039,10 @@ static void P_KoopaThinker(mobj_t *koopa) // void P_RollPitchMobj(mobj_t* mobj) { + // we dont need this in dedi do we? + if (rendermode == render_none) + return; + if (P_MobjWasRemoved(mobj)) return; diff --git a/src/p_tick.c b/src/p_tick.c index e9ea16ed0..5a55d23e3 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -373,7 +373,7 @@ static void P_DeviceRumbleTick(void) { UINT8 i; - if (I_NumJoys() == 0 || gamestate != GS_LEVEL) + if (dedicated || I_NumJoys() == 0 || gamestate != GS_LEVEL) { return; } @@ -503,6 +503,9 @@ static inline void P_ResetSpriteStuff(void) { thinker_t *th; + if (rendermode == render_none) + return; + for (th = thinkercap.next; th != &thinkercap; th = th->next) { mobj_t *mo; From f15f24914d63fcc4e5b4b94423b0197ca69f809e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Feb 2025 21:23:55 +0100 Subject: [PATCH 409/418] initialize this --- src/d_main.c | 4 ++-- src/g_input.c | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 0bfda85a2..7c6105a28 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -214,8 +214,8 @@ static void D_GamePadMenuScrollTicker(void) static void D_DeviceLEDTick(void) { UINT8 i; - UINT16 color[MAXSPLITSCREENPLAYERS]; - UINT16 curcolor[MAXSPLITSCREENPLAYERS]; + static UINT16 color[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; + static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; if (dedicated || I_NumJoys() == 0) { diff --git a/src/g_input.c b/src/g_input.c index 168d51bf3..6f9d77cca 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -928,20 +928,17 @@ UINT16 G_GetSkinColor(INT32 playernum) { case 0: return cv_playercolor.value; - break; case 1: return cv_playercolor2.value; - break; case 2: return cv_playercolor3.value; - break; case 3: return cv_playercolor4.value; - break; default: return 0; - break; } + + return 0; } void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color) From 70a985e27444c4ce617c73c391c3faf0015caadc Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Feb 2025 21:16:12 +0100 Subject: [PATCH 410/418] dont check number of controllers every frame --- src/d_main.c | 2 +- src/i_system.h | 2 ++ src/p_tick.c | 2 +- src/sdl/i_system.c | 4 ++++ src/sdl/i_video.c | 2 ++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 7c6105a28..b167bc60a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -217,7 +217,7 @@ static void D_DeviceLEDTick(void) static UINT16 color[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; - if (dedicated || I_NumJoys() == 0) + if (dedicated || numcontrollers == 0) { return; } diff --git a/src/i_system.h b/src/i_system.h index 81cd80b68..2154d5db0 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -226,6 +226,8 @@ void I_InitJoystick4(void); */ INT32 I_NumJoys(void); +extern INT32 numcontrollers; + /** \brief The *I_GetJoyName function \param joyindex which joystick diff --git a/src/p_tick.c b/src/p_tick.c index 5a55d23e3..717bffdc0 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -373,7 +373,7 @@ static void P_DeviceRumbleTick(void) { UINT8 i; - if (dedicated || I_NumJoys() == 0 || gamestate != GS_LEVEL) + if (dedicated || numcontrollers == 0 || gamestate != GS_LEVEL) { return; } diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 65239b6a4..5e5df2c11 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -201,6 +201,8 @@ static char returnWadPath[256]; #include "../byteptr.h" #endif +INT32 numcontrollers = 0; + #ifdef HAVE_LIBBACKTRACE #include // TODO - move this to some header file instead @@ -1397,6 +1399,8 @@ void I_InitJoystick(UINT8 index) joystick_started[index] = 0; } + numcontrollers = I_NumJoys(); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { if (JoyInfo[i].dev == newcontroller) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 2ba945467..820186c0f 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1243,6 +1243,8 @@ void I_GetEvent(void) G_SetPlayerGamepadIndicatorColor(i, G_GetSkinColor(i)); // gotta update the controller led again on reconnect } + numcontrollers = I_NumJoys(); + //////////////////////////////////////////////////////////// for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) From b4269cba3e68c01b7fede2f3e997837092f6e26d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Feb 2025 21:30:36 +0100 Subject: [PATCH 411/418] properly init numcontrollers --- src/sdl/i_system.c | 12 +++++------- src/sdl/i_video.c | 7 +++++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 5e5df2c11..60d0b4cce 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1172,21 +1172,21 @@ void I_ShutdownJoystick(UINT8 index) { INT32 i; event_t event; - event.type=ev_keyup; + event.type = ev_keyup; event.data2 = 0; event.data3 = 0; lastjoybuttons[index] = lastjoyhats[index] = 0; // emulate the up of all joystick buttons - for (i=0;i Date: Tue, 18 Feb 2025 12:29:47 +0300 Subject: [PATCH 412/418] Fix compilation with old sdl --- 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 60d0b4cce..353fd0f82 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1488,7 +1488,7 @@ const char *I_GetJoyName(INT32 joyindex) void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { #if !(SDL_VERSION_ATLEAST(2,0,14)) - (void)device_id; + (void)playernum; (void)low_strength; (void)high_strength; (void)duration; @@ -1506,7 +1506,7 @@ void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 blue) { #if !(SDL_VERSION_ATLEAST(2,0,14)) - (void)device_id; + (void)playernum; (void)red; (void)green; (void)blue; From b605c8e6546556bad6dab712ae965b3db3a4ccf8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 19 Feb 2025 11:10:27 +0100 Subject: [PATCH 413/418] few instances of int float conversions i forgor --- src/hardware/hw_clip.c | 2 +- src/hardware/hw_draw.c | 21 ++++++++++----------- src/hardware/hw_main.h | 30 +++++++++++++++--------------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index e9b1bce98..7d0179dfc 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -333,7 +333,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle) // ok, this is a gross hack that barely works... // but at least it doesn't overestimate too much... - clipfov = atan(1 / projMatrix[0]) * 360 / M_PIl; + clipfov = atan(1 / projMatrix[0]) * 360.0f / M_PIl; floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * clipfov / 90.0f; if (floatangle >= 180.0) return 0xffffffff; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index dc363dd1a..c24fbdb56 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -268,8 +268,8 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t cy = 1.0f - (cy / (vid.height / 2.0f)); // fwidth and fheight are similar - fwidth /= fvw / 2; - fheight /= fvh / 2; + fwidth /= fvw / 2.0f; + fheight /= fvh / 2.0f; // set the polygon vertices to the right positions v[0].x = v[3].x = cx; @@ -442,8 +442,8 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal cy = 1.0f - (cy / (vid.height / 2.0f)); // fwidth and fheight are similar - fwidth /= fvw / 2; - fheight /= fvh / 2; + fwidth /= fvw / 2.0f; + fheight /= fvh / 2.0f; // set the polygon vertices to the right positions v[0].x = v[3].x = cx; @@ -882,8 +882,8 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) fx = -1.0f + fx / (vid.width / 2.0f); fy = 1.0f - fy / (vid.height / 2.0f); - fw = fw / (fvw / 2); - fh = fh / (fvh / 2); + fw = fw / (fvw / 2.0f); + fh = fh / (fvh / 2.0f); v[0].x = v[3].x = fx; v[2].x = v[1].x = fx + fw; @@ -995,8 +995,8 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 fx = -1.0f + fx / (vid.width / 2.0f); fy = 1.0f - fy / (vid.height / 2.0f); - fw = fw / (fvw / 2); - fh = fh / (fvh / 2); + fw = fw / (fvw / 2.0f); + fh = fh / (fvh / 2.0f); v[0].x = v[3].x = fx; v[2].x = v[1].x = fx + fw; @@ -1084,7 +1084,6 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) fy += (FLOATBASEVIDHEIGHT * dupy)/2; if (color & V_HORZSCREEN) fx += (FLOATBASEVIDWIDTH * dupx)/2; - } if (fx >= vid.width || fy >= vid.height) @@ -1109,8 +1108,8 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) fx = -1.0f + fx / (vid.width / 2.0f); fy = 1.0f - fy / (vid.height / 2.0f); - fw = fw / (fvw / 2); - fh = fh / (fvh / 2); + fw = fw / (fvw / 2.0f); + fh = fh / (fvh / 2.0f); v[0].x = v[3].x = fx; v[2].x = v[1].x = fx + fw; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 8b1751a8e..8ccb1b2a1 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -58,11 +58,11 @@ extern sector_t *gl_backsector; enum { - HWR_STENCIL_NORMAL, - HWR_STENCIL_BEGIN, - HWR_STENCIL_REVERSE, - HWR_STENCIL_DEPTH, - HWR_STENCIL_SKY + HWR_STENCIL_NORMAL, + HWR_STENCIL_BEGIN, + HWR_STENCIL_REVERSE, + HWR_STENCIL_DEPTH, + HWR_STENCIL_SKY }; // Performance stats @@ -128,7 +128,7 @@ FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf); // Get amount of memory used by gpu textures in bytes; FUNCINLINE static ATTRINLINE INT32 HWR_GetTextureUsed(void) { - return GL_GetTextureUsed(); + return GL_GetTextureUsed(); } // hw_main.c: Post-rendering @@ -136,32 +136,32 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum); FUNCINLINE static ATTRINLINE void HWR_StartScreenWipe(void) { - GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_START); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_START); } FUNCINLINE static ATTRINLINE void HWR_EndScreenWipe(void) { - GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_END); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_END); } FUNCINLINE static ATTRINLINE void HWR_DrawIntermissionBG(void) { - GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); + GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); } FUNCINLINE static ATTRINLINE void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) { - GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); + GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); } FUNCINLINE static ATTRINLINE void HWR_MakeScreenFinalTexture(void) { - GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); } FUNCINLINE static ATTRINLINE void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader) { - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height, useshader); + GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height, useshader); } // hw_main.c: Segs @@ -215,17 +215,17 @@ extern consvar_t cv_glflashpal; FUNCINLINE static ATTRINLINE boolean HWR_UseShader(void) { - return (cv_glshaders.value && gl_shadersavailable); + return (cv_glshaders.value && gl_shadersavailable); } FUNCINLINE static ATTRINLINE boolean HWR_ShouldUsePaletteRendering(void) { - return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader()); + return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader()); } FUNCINLINE static ATTRINLINE boolean HWR_PalRenderFlashpal(void) { - return (HWR_ShouldUsePaletteRendering() && cv_glflashpal.value); + return (HWR_ShouldUsePaletteRendering() && cv_glflashpal.value); } #endif From 34f5a586927f3240413b61cbf45e62a576f2a9e3 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 19 Feb 2025 11:10:51 +0100 Subject: [PATCH 414/418] reuse var --- src/hardware/hw_cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index b37e64410..c06db3891 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -897,8 +897,7 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum) glMipmap->height = (UINT16)pflatsize; // the flat raw data needn't be converted with palettized textures - W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum), - PU_HWRCACHE, &glMipmap->data)); + W_ReadLump(flatlumpnum, Z_Malloc(size, PU_HWRCACHE, &glMipmap->data)); #ifdef GLENCORE flat = glMipmap->data; @@ -1093,6 +1092,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 stepy = ((INT32)SHORT(fmheight)< Date: Wed, 19 Feb 2025 12:05:29 +0100 Subject: [PATCH 415/418] toggle for keeping driftsparks while in air --- src/k_kart.c | 6 +++++- src/k_kart.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 5654f7838..32396f1cd 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -86,6 +86,8 @@ consvar_t cv_bananajitter = {"bananadragjitter", "Off", CV_SAVE, CV_OnOff, NULL, static CV_PossibleValue_t bananthrowroll_cons_t[] = {{0, "Off"}, {1, "Throw"}, {2, "+Onground"}, {0, NULL}}; consvar_t cv_bananthrowroll = {"bananthrowroll", "0", CV_SAVE, bananthrowroll_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_airsparks = {"airdriftsparks", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + //extra hud things consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -852,6 +854,8 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_bananajitter); CV_RegisterVar(&cv_bananthrowroll); + CV_RegisterVar(&cv_airsparks); + CV_RegisterVar(&cv_showstats); CV_RegisterVar(&cv_showinput); @@ -3254,7 +3258,7 @@ static void K_SpawnDriftSparks(player_t *player) if (leveltime % 2 == 1) return; - if (!P_IsObjectOnGround(player->mo)) + if (!cv_airsparks.value && !P_IsObjectOnGround(player->mo)) return; if (!player->kartstuff[k_drift] || player->kartstuff[k_driftcharge] < K_GetKartDriftSparkValue(player)) diff --git a/src/k_kart.h b/src/k_kart.h index 2fa2ab6e3..d3d335517 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -27,6 +27,7 @@ void K_RegisterClientKartStuff(void); extern consvar_t cv_coloredspeedlines, cv_coloredsneakertrail; extern consvar_t cv_bananajitter; extern consvar_t cv_bananthrowroll; +extern consvar_t cv_airsparks; extern consvar_t cv_colorizedhud, cv_colorizeditembox, cv_colorizedhudcolor; extern consvar_t cv_darkitembox; extern consvar_t cv_biglaps; From 93b39260085c876a5c731baf1489b20a58dd5dc2 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 20 Feb 2025 23:32:05 +0300 Subject: [PATCH 416/418] Allow trailing spaces in lj_strscan_scan --- src/bluajit/lj_strscan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bluajit/lj_strscan.c b/src/bluajit/lj_strscan.c index 511e748bd..562cdf56a 100644 --- a/src/bluajit/lj_strscan.c +++ b/src/bluajit/lj_strscan.c @@ -496,6 +496,9 @@ StrScanFmt lj_strscan_scan(const uint8_t *p, MSize len, TValue *o, #endif #if LJ_INTONLY + /* Skip trailing spaces */ + while (p < pe && *p == ' ') ++p; + if (*p || p < pe) return STRSCAN_ERROR; #else From d0890c45e2b39e5ec03407b84d19ee86b957ba82 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 21 Feb 2025 20:05:35 +0100 Subject: [PATCH 417/418] use lj_char_isspace --- src/bluajit/lj_strscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bluajit/lj_strscan.c b/src/bluajit/lj_strscan.c index 562cdf56a..1bc8a79fe 100644 --- a/src/bluajit/lj_strscan.c +++ b/src/bluajit/lj_strscan.c @@ -497,7 +497,7 @@ StrScanFmt lj_strscan_scan(const uint8_t *p, MSize len, TValue *o, #if LJ_INTONLY /* Skip trailing spaces */ - while (p < pe && *p == ' ') ++p; + while (lj_char_isspace(*p)) p++; if (*p || p < pe) return STRSCAN_ERROR; From a0fc6f7e22c00d584da6ce0a6a296df894adca47 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 23 Feb 2025 14:21:24 +0300 Subject: [PATCH 418/418] Add toggle for look up/down, also don't trigger it during countdown or when player is respawning --- src/d_netcmd.c | 4 ++++ src/d_netcmd.h | 2 ++ src/m_menu.c | 10 ++++++---- src/p_tick.c | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 793c1c70d..5d316aff2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -298,6 +298,8 @@ consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, // Lagless camera! Yay! consvar_t cv_laglesscam = {"laglesscamera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_verticallook = {"verticallook", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + #if defined(HAVE_SDL) || defined(_WINDOWS) //joystick 1 and 2 consvar_t cv_usejoystick[MAXSPLITSCREENPLAYERS] = { {"use_joystick", "1", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick1, 0, NULL, NULL, 0, 0, NULL}, @@ -1075,6 +1077,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_laglesscam); + CV_RegisterVar(&cv_verticallook); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 1b9bd9808..ec58c7bfd 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -200,6 +200,8 @@ extern consvar_t cv_betainterscreen; extern consvar_t cv_laglesscam; +extern consvar_t cv_verticallook; + typedef enum { SKINMENUTYPE_SCROLL = 0, diff --git a/src/m_menu.c b/src/m_menu.c index 523930a01..51b6aa45e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1886,11 +1886,12 @@ static menuitem_t OP_CamOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 50}, {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom, 60}, + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook, 70}, - {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 80}, - {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 90}, - {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 100}, - {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 110}, + {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 90}, + {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 100}, + {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 110}, + {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 120}, }; static const char* OP_CamOptionsTooltips[] = @@ -1899,6 +1900,7 @@ static const char* OP_CamOptionsTooltips[] = "Player field of view.", "Removes Camera Lag in netgames\nMay cause Camera stutters in poor net conditions.", "Should looking back inherit the Players Momentum?\nEither inherit Player Momentum or double of it\nmay make looking back while boosting or going in high speed less jarring", + "Allows looking up/down by holding aim forward/backward while standing still.", NULL, NULL, NULL, diff --git a/src/p_tick.c b/src/p_tick.c index 92b6a1089..dbd30e181 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -474,7 +474,7 @@ void P_RunChaseCameras(void) player_t *p = &players[displayplayers[i]]; camera_t *cam = &camera[i]; - if (p->mo && p->kartstuff[k_throwdir] != 0) + if (cv_verticallook.value && leveltime > starttime && p->mo && p->kartstuff[k_respawn] == 0 && p->kartstuff[k_throwdir] != 0) { if (p->speed < 6 * p->mo->scale && abs(cam->dpad_y_held) < 2*TICRATE) cam->dpad_y_held += intsign(p->kartstuff[k_throwdir]);