From 701c1e26c481af0502f51e7285ef7302ccef74a6 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 18 Jun 2022 23:35:22 -0500 Subject: [PATCH 01/17] Implement epicenter and radius support for quakes. --- src/p_tick.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index 28ace9288..c8c927ae1 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -23,6 +23,7 @@ #include "lua_hook.h" #include "m_perfstats.h" #include "i_system.h" // I_GetPreciseTime +#include "r_main.h" // Object place #include "m_cheat.h" @@ -740,7 +741,22 @@ void P_Ticker(boolean run) if (quake.time) { fixed_t ir = quake.intensity>>1; - /// \todo Calculate distance from epicenter if set and modulate the intensity accordingly based on radius. + + if (quake.epicenter) { + // Calculate 3D distance from epicenter, using camera. + // Uses only player 1 camera because only one quake variable exists. + fixed_t xydist = R_PointToDist2(camera.x, camera.y, quake.epicenter->x, quake.epicenter->y); + fixed_t dist = R_PointToDist2(0, camera.z, xydist, quake.epicenter->z); + + CONS_Printf("%d\n", dist / FRACUNIT); + + // More effect closer to epicenter, outside of radius = no effect + if (!quake.radius || dist > quake.radius) + ir = 0; + else + ir = FixedMul(ir, FRACUNIT - FixedDiv(dist, quake.radius)); + } + quake.x = M_RandomRange(-ir,ir); quake.y = M_RandomRange(-ir,ir); quake.z = M_RandomRange(-ir,ir); From a546b553c42f14e1f0128b1e63cc9718b9f4477e Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 18 Jun 2022 23:37:53 -0500 Subject: [PATCH 02/17] Oops, forgot to remove a debug print. --- src/p_tick.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index c8c927ae1..4915c5df2 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -748,8 +748,6 @@ void P_Ticker(boolean run) fixed_t xydist = R_PointToDist2(camera.x, camera.y, quake.epicenter->x, quake.epicenter->y); fixed_t dist = R_PointToDist2(0, camera.z, xydist, quake.epicenter->z); - CONS_Printf("%d\n", dist / FRACUNIT); - // More effect closer to epicenter, outside of radius = no effect if (!quake.radius || dist > quake.radius) ir = 0; From 90a93a516e8fe5658dc960277fab74f6232ed6d3 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 6 Sep 2022 18:42:12 -0500 Subject: [PATCH 03/17] Move quake calculation code to r_main.c, keep timer in p_tick.c --- src/p_tick.c | 22 ---------------------- src/r_main.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 4915c5df2..5430e651c 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -739,29 +739,7 @@ void P_Ticker(boolean run) countdown2--; if (quake.time) - { - fixed_t ir = quake.intensity>>1; - - if (quake.epicenter) { - // Calculate 3D distance from epicenter, using camera. - // Uses only player 1 camera because only one quake variable exists. - fixed_t xydist = R_PointToDist2(camera.x, camera.y, quake.epicenter->x, quake.epicenter->y); - fixed_t dist = R_PointToDist2(0, camera.z, xydist, quake.epicenter->z); - - // More effect closer to epicenter, outside of radius = no effect - if (!quake.radius || dist > quake.radius) - ir = 0; - else - ir = FixedMul(ir, FRACUNIT - FixedDiv(dist, quake.radius)); - } - - quake.x = M_RandomRange(-ir,ir); - quake.y = M_RandomRange(-ir,ir); - quake.z = M_RandomRange(-ir,ir); --quake.time; - } - else - quake.x = quake.y = quake.z = 0; if (metalplayback) G_ReadMetalTic(metalplayback); diff --git a/src/r_main.c b/src/r_main.c index f19962d41..f5992f98b 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1123,6 +1123,7 @@ void R_SetupFrame(player_t *player) { camera_t *thiscam; boolean chasecam = false; + boolean ispaused = paused || P_AutoPause(); if (splitscreen && player == &players[secondarydisplayplayer] && player != &players[consoleplayer]) @@ -1191,6 +1192,30 @@ void R_SetupFrame(player_t *player) } } } + + if (quake.time && !ispaused) + { + fixed_t ir = quake.intensity>>1; + + if (quake.epicenter) { + // Calculate 3D distance from epicenter, using the camera. + fixed_t xydist = R_PointToDist2(thiscam->x, thiscam->y, quake.epicenter->x, quake.epicenter->y); + fixed_t dist = R_PointToDist2(0, thiscam->z, xydist, quake.epicenter->z); + + // More effect closer to epicenter, outside of radius = no effect + if (!quake.radius || dist > quake.radius) + ir = 0; + else + ir = FixedMul(ir, FRACUNIT - FixedDiv(dist, quake.radius)); + } + + quake.x = M_RandomRange(-ir,ir); + quake.y = M_RandomRange(-ir,ir); + quake.z = M_RandomRange(-ir,ir); + } + else if (!ispaused) + quake.x = quake.y = quake.z = 0; + viewz += quake.z; viewplayer = player; From c907c20480719e908e3aa3d3fff65fb9eb4e9f43 Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 5 Apr 2023 23:59:37 +0200 Subject: [PATCH 04/17] Do not apply pmomz when jumping through a platform --- src/p_map.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index a7d1f4abd..33d599a6c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3065,11 +3065,14 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (!rover || ((rover->fofflags & FOF_EXISTS) && (rover->fofflags & FOF_SOLID))) { hitfloor = bouncing; - if (thing->eflags & MFE_VERTICALFLIP) - thing->pmomz = thing->ceilingz - (thing->z + thing->height); - else - thing->pmomz = thing->floorz - thing->z; - thing->eflags |= MFE_APPLYPMOMZ; + if (!(thing->player) || !(thing->player->pflags & PF_JUMPED || bouncing)) + { + if (thing->eflags & MFE_VERTICALFLIP) + thing->pmomz = thing->ceilingz - (thing->z + thing->height); + else + thing->pmomz = thing->floorz - thing->z; + thing->eflags |= MFE_APPLYPMOMZ; + } if (thing->eflags & MFE_VERTICALFLIP) thing->z = thing->ceilingz - thing->height; From aaced79b41db8aea3e56b38ef3857aa836b3b6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Tue, 25 Jul 2023 16:37:20 +0200 Subject: [PATCH 05/17] Fix segfaults on some systems due to polyvertex being NULL --- src/hardware/hw_main.c | 96 +++++++++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 16 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 36ff86abd..c650ecb51 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -582,10 +582,26 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool P_ClosestPointOnLine(viewx, viewy, line->linedef, &v); dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y)); - x1 = ((polyvertex_t *)line->pv1)->x; - y1 = ((polyvertex_t *)line->pv1)->y; - xd = ((polyvertex_t *)line->pv2)->x - x1; - yd = ((polyvertex_t *)line->pv2)->y - y1; + if (line->pv1) + { + x1 = ((polyvertex_t *)line->pv1)->x; + y1 = ((polyvertex_t *)line->pv1)->y; + } + else + { + x1 = FIXED_TO_FLOAT(line->v1->x); + y1 = FIXED_TO_FLOAT(line->v1->x); + } + if (line->pv2) + { + xd = ((polyvertex_t *)line->pv2)->x - x1; + yd = ((polyvertex_t *)line->pv2)->y - y1; + } + else + { + xd = FIXED_TO_FLOAT(line->v2->x) - x1; + yd = FIXED_TO_FLOAT(line->v2->y) - y1; + } // Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f; @@ -1068,10 +1084,26 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom gl_sidedef = gl_curline->sidedef; gl_linedef = gl_curline->linedef; - vs.x = ((polyvertex_t *)gl_curline->pv1)->x; - vs.y = ((polyvertex_t *)gl_curline->pv1)->y; - ve.x = ((polyvertex_t *)gl_curline->pv2)->x; - ve.y = ((polyvertex_t *)gl_curline->pv2)->y; + if (gl_curline->pv1) + { + vs.x = ((polyvertex_t *)gl_curline->pv1)->x; + vs.y = ((polyvertex_t *)gl_curline->pv1)->y; + } + else + { + vs.x = FIXED_TO_FLOAT(gl_curline->v1->x); + vs.y = FIXED_TO_FLOAT(gl_curline->v1->y); + } + if (gl_curline->pv2) + { + ve.x = ((polyvertex_t *)gl_curline->pv2)->x; + ve.y = ((polyvertex_t *)gl_curline->pv2)->y; + } + else + { + ve.x = FIXED_TO_FLOAT(gl_curline->v2->x); + ve.y = FIXED_TO_FLOAT(gl_curline->v2->y); + } v1x = FLOAT_TO_FIXED(vs.x); v1y = FLOAT_TO_FIXED(vs.y); @@ -1866,10 +1898,26 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks if (afrontsector->f_slope || afrontsector->c_slope || abacksector->f_slope || abacksector->c_slope) { fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t - v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); - v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); - v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); - v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); + if (gl_curline->pv1) + { + v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); + v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); + } + else + { + v1x = gl_curline->v1->x; + v1y = gl_curline->v1->y; + } + if (gl_curline->pv2) + { + v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); + v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); + } + else + { + v2x = gl_curline->v2->x; + v2y = gl_curline->v2->y; + } #define SLOPEPARAMS(slope, end1, end2, normalheight) \ end1 = P_GetZAt(slope, v1x, v1y, normalheight); \ end2 = P_GetZAt(slope, v2x, v2y, normalheight); @@ -2242,10 +2290,26 @@ static void HWR_AddLine(seg_t * line) gl_curline = line; - v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); - v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); - v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); - v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); + if (gl_curline->pv1) + { + v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); + v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); + } + else + { + v1x = gl_curline->v1->x; + v1y = gl_curline->v1->y; + } + if (gl_curline->pv2) + { + v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); + v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); + } + else + { + v2x = gl_curline->v2->x; + v2y = gl_curline->v2->y; + } // OPTIMIZE: quickly reject orthogonal back sides. angle1 = R_PointToAngle64(v1x, v1y); From 5e501bae0767124adee00f8f0db0334b32422342 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 21 Sep 2023 13:19:38 +0100 Subject: [PATCH 06/17] v.getSpritePatch/v.getSprite2Patch fix: Fix offset inconsistency between rotated sprites and non-rotated sprites This was caused by rotated sprites having FEETADJUST offsets applied, when non-rotated sprites did not. FEETADJUST is not actually needed in the HUD, so I've removed it from the rotated sprites (thankfully this is also the easiest way to fix it too) --- src/lua_hudlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 6eec91273..899e5a2dc 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -517,7 +517,7 @@ static int libd_getSpritePatch(lua_State *L) INT32 rot = R_GetRollAngle(rollangle); if (rot) { - patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<flip & (1<flip & (1<flip & (1< Date: Thu, 21 Sep 2023 15:50:30 +0100 Subject: [PATCH 07/17] Remove adjustfeet parameter from Patch_GetRotatedSprite, remove [2] from spriteframe_t's rotated array. Following from my previous commit, these things are no longer needed: they existed ONLY for adding FEETADJUST offsets to rotated sprites in Lua HUD code. --- src/hardware/hw_main.c | 2 +- src/lua_hudlib.c | 4 ++-- src/r_defs.h | 2 +- src/r_patch.h | 2 +- src/r_patchrotation.c | 11 +++-------- src/r_things.c | 2 +- 6 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 59af61753..4a000f83a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5259,7 +5259,7 @@ static void HWR_ProjectSprite(mobj_t *thing) rollangle = R_GetRollAngle(spriterotangle); } - rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle); if (rotsprite != NULL) { diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 899e5a2dc..cf03776e0 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -517,7 +517,7 @@ static int libd_getSpritePatch(lua_State *L) INT32 rot = R_GetRollAngle(rollangle); if (rot) { - patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<flip & (1<flip & (1<flip & (1<= ROTANGLES) return NULL; - rotsprite = sprite->rotated[type][spriteangle]; + rotsprite = sprite->rotated[spriteangle]; if (rotsprite == NULL) { rotsprite = RotatedPatch_Create(ROTANGLES); - sprite->rotated[type][spriteangle] = rotsprite; + sprite->rotated[spriteangle] = rotsprite; } if (flip) @@ -111,10 +110,6 @@ patch_t *Patch_GetRotatedSprite( } RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip); - - //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer - if (adjustfeet) - ((patch_t *)rotsprite->patches[idx])->topoffset += FEETADJUST>>FRACBITS; } return rotsprite->patches[idx]; diff --git a/src/r_things.c b/src/r_things.c index 89c4f35eb..85d76fecd 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1794,7 +1794,7 @@ static void R_ProjectSprite(mobj_t *thing) rollangle = R_GetRollAngle(spriterotangle); } - rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle); if (rotsprite != NULL) { From 340eee8691697e2dd55f7eab84da0da0e83feb46 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 21 Sep 2023 16:13:55 +0100 Subject: [PATCH 08/17] Added some notes related to FEETADJUST for reference, made another tweak --- src/r_patchrotation.c | 6 ++---- src/r_things.c | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 0cf4a9841..b91069849 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -10,7 +10,7 @@ /// \brief Patch rotation. #include "r_patchrotation.h" -#include "r_things.h" // FEETADJUST +#include "r_things.h" // FEETADJUST (todo: is this needed anymore? -- Monster Iestyn 21 Sep 2023 ) #include "z_zone.h" #include "w_wad.h" #include "r_main.h" // R_PointToAngle @@ -69,15 +69,13 @@ patch_t *Patch_GetRotatedSprite( boolean flip, void *info, INT32 rotationangle) { - rotsprite_t *rotsprite; + rotsprite_t *rotsprite = sprite->rotated[spriteangle]; spriteinfo_t *sprinfo = (spriteinfo_t *)info; INT32 idx = rotationangle; if (rotationangle < 1 || rotationangle >= ROTANGLES) return NULL; - rotsprite = sprite->rotated[spriteangle]; - if (rotsprite == NULL) { rotsprite = RotatedPatch_Create(ROTANGLES); diff --git a/src/r_things.c b/src/r_things.c index 85d76fecd..0d4b9a1e5 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -337,6 +337,11 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 spritecachedinfo[numspritelumps].height = height< Date: Wed, 25 Oct 2023 08:00:04 -0400 Subject: [PATCH 09/17] spriteframe_t only gave 1D array, not 2D for rotated --- src/r_things.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 0d4b9a1e5..66a637b13 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -138,8 +138,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch #ifdef ROTSPRITE for (r = 0; r < 16; r++) { - sprtemp[frame].rotated[0][r] = NULL; - sprtemp[frame].rotated[1][r] = NULL; + sprtemp[frame].rotated[r] = NULL; } #endif From 36e20ac619a7da0d8b640d36b5ff46cabc825539 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Thu, 2 Feb 2023 15:47:42 +0100 Subject: [PATCH 10/17] Tiny caption loop optimisation --- src/screen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/screen.c b/src/screen.c index 0719da83c..61e63cdf4 100644 --- a/src/screen.c +++ b/src/screen.c @@ -552,7 +552,7 @@ void SCR_ClosedCaptions(void) { UINT8 i; boolean gamestopped = (paused || P_AutoPause()); - INT32 basey = BASEVIDHEIGHT; + INT32 basey = BASEVIDHEIGHT - 20; if (gamestate != wipegamestate) return; @@ -585,7 +585,7 @@ void SCR_ClosedCaptions(void) continue; flags = V_SNAPTORIGHT|V_SNAPTOBOTTOM|V_ALLOWLOWERCASE; - y = basey-((i + 2)*10); + y = basey-(i*10); if (closedcaptions[i].b) { From c2aa6d4c74d50d239cbe264bd7eddec2bc9db4d7 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Thu, 2 Feb 2023 15:49:54 +0100 Subject: [PATCH 11/17] Fix captions being over-affected by GUI scale Captions' pop-in animation now starts 8 GUI pixels above the resting position, instead of (2 x GUI scale) GUI above it --- src/screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screen.c b/src/screen.c index 61e63cdf4..73e09963c 100644 --- a/src/screen.c +++ b/src/screen.c @@ -589,7 +589,7 @@ void SCR_ClosedCaptions(void) if (closedcaptions[i].b) { - y -= closedcaptions[i].b * vid.dup; + y -= closedcaptions[i].b * 4; if (renderisnewtic) { closedcaptions[i].b--; From 8cf6e8252c4c7b9bc5b79e4e7f780364ce0418aa Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Thu, 2 Feb 2023 15:50:40 +0100 Subject: [PATCH 12/17] Interpolate captions --- src/s_sound.c | 2 +- src/screen.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index ada1a0fd2..a579292ff 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -513,7 +513,7 @@ void S_StartCaption(sfxenum_t sfx_id, INT32 cnum, UINT16 lifespan) closedcaptions[set].c = ((cnum == -1) ? NULL : &channels[cnum]); closedcaptions[set].s = sfx; closedcaptions[set].t = lifespan; - closedcaptions[set].b = 2; // bob + closedcaptions[set].b = 3; // bob } void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) diff --git a/src/screen.c b/src/screen.c index 73e09963c..3c50ec67e 100644 --- a/src/screen.c +++ b/src/screen.c @@ -572,7 +572,8 @@ void SCR_ClosedCaptions(void) for (i = 0; i < NUMCAPTIONS; i++) { - INT32 flags, y; + INT32 flags; + fixed_t y; char dot; boolean music; @@ -585,14 +586,19 @@ void SCR_ClosedCaptions(void) continue; flags = V_SNAPTORIGHT|V_SNAPTOBOTTOM|V_ALLOWLOWERCASE; - y = basey-(i*10); + y = (basey-(i*10)) * FRACUNIT; if (closedcaptions[i].b) { - y -= closedcaptions[i].b * 4; if (renderisnewtic) - { closedcaptions[i].b--; + + if (closedcaptions[i].b) // If the caption hasn't reached its final destination... + { + y -= closedcaptions[i].b * 4 * FRACUNIT; // ...move it per tic... + y += (rendertimefrac % FRACUNIT) * 4; // ...and interpolate it per frame + // We have to modulo it by FRACUNIT, so that it won't be a tic ahead with interpolation disabled + // Unlike everything else, captions are (intentionally) interpolated from T to T+1 instead of T-1 to T } } @@ -606,7 +612,7 @@ void SCR_ClosedCaptions(void) else dot = ' '; - V_DrawRightAlignedString(BASEVIDWIDTH - 20, y, flags, + V_DrawRightAlignedStringAtFixed((BASEVIDWIDTH-20) * FRACUNIT, y, flags, va("%c [%s]", dot, (closedcaptions[i].s->caption[0] ? closedcaptions[i].s->caption : closedcaptions[i].s->name))); } } From 2062553d22a5c4a544f11080e17a09addf93cd1b Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Thu, 9 Nov 2023 20:21:04 -0500 Subject: [PATCH 13/17] Update i_system.c Add a check for overflowing the TERIOS buffer --- src/sdl/i_system.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 2a26f3f50..9dd80e6ef 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -607,6 +607,7 @@ void I_GetConsoleEvents(void) return; ev.type = ev_console; + ev.key = 0; if (read(STDIN_FILENO, &key, 1) == -1 || !key) return; @@ -633,7 +634,7 @@ void I_GetConsoleEvents(void) } else return; } - else + else if (tty_con.cursor < sizeof (tty_con.buffer)) { // push regular character ev.key = tty_con.buffer[tty_con.cursor] = key; From 977cd0db24e4af2770b3b168dfefee741e8ea5f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Wed, 22 Nov 2023 19:41:35 +0100 Subject: [PATCH 14/17] Fix LAN discovery for SRB2 servers --- src/netcode/i_tcp.c | 95 ++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 53 deletions(-) diff --git a/src/netcode/i_tcp.c b/src/netcode/i_tcp.c index 698234579..9c0e8eb2b 100644 --- a/src/netcode/i_tcp.c +++ b/src/netcode/i_tcp.c @@ -154,6 +154,8 @@ typedef union #define ERRSOCKET (-1) #endif +#define IPV6_MULTICAST_ADDRESS "ff15::57e1:1a12" + // define socklen_t in DOS/Windows if it is not already defined #ifdef USE_WINSOCK1 typedef int socklen_t; @@ -621,6 +623,7 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr socklen_t d6 = (socklen_t)sizeof(struct sockaddr_in6); #endif socklen_t d, da = (socklen_t)sizeof(mysockaddr_t); + ssize_t status; switch (sockaddr->any.sa_family) { @@ -631,7 +634,12 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr default: d = da; break; } - return sendto(socket, (char *)&doomcom->data, doomcom->datalength, 0, &sockaddr->any, d); + status = sendto(socket, (char *)&doomcom->data, doomcom->datalength, 0, &sockaddr->any, d); + if (status == -1) + { + CONS_Alert(CONS_WARNING, "Unable to send packet to %s: %s\n", SOCK_AddrToStr(sockaddr), strerror(errno)); + } + return status; } static void SOCK_Send(void) @@ -770,6 +778,24 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen return (SOCKET_TYPE)ERRSOCKET; } +#ifdef HAVE_IPV6 + if (family == AF_INET6) + { + // we need to set all of this *after* binding to an address! + if (memcmp(&straddr.ip6.sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0) //IN6_ARE_ADDR_EQUAL + { + struct ipv6_mreq maddr; + + inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &maddr.ipv6mr_multiaddr); + maddr.ipv6mr_interface = 0; + if (setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP, &maddr, sizeof(maddr)) != 0) + { + CONS_Alert(CONS_WARNING, M_GetText("Could not register multicast address\n")); + } + } + } +#endif + #ifdef FIONBIO // make it non blocking opt = true; @@ -950,65 +976,28 @@ static boolean UDP_Socket(void) // ip + udp packetheaderlength = 20 + 8; // for stats - hints.ai_family = AF_INET; - gaie = I_getaddrinfo("127.0.0.1", "0", &hints, &ai); - if (gaie == 0) - { - runp = ai; - while (runp != NULL && s < MAXNETNODES+1) - { - memcpy(&clientaddress[s], runp->ai_addr, runp->ai_addrlen); - s++; - runp = runp->ai_next; - } - I_freeaddrinfo(ai); - } - else - { - clientaddress[s].any.sa_family = AF_INET; - clientaddress[s].ip4.sin_port = htons(0); - clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip - s++; - } + clientaddress[s].any.sa_family = AF_INET; + clientaddress[s].ip4.sin_port = htons(0); + clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip + s++; s = 0; // setup broadcast adress to BROADCASTADDR entry - gaie = I_getaddrinfo("255.255.255.255", "0", &hints, &ai); - if (gaie == 0) - { - runp = ai; - while (runp != NULL && s < MAXNETNODES+1) - { - memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen); - s++; - runp = runp->ai_next; - } - I_freeaddrinfo(ai); - } - else - { - broadcastaddress[s].any.sa_family = AF_INET; - broadcastaddress[s].ip4.sin_port = htons(0); - broadcastaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_BROADCAST); - s++; - } + broadcastaddress[s].any.sa_family = AF_INET; + broadcastaddress[s].ip4.sin_port = htons(atoi(DEFAULTPORT)); + broadcastaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_BROADCAST); + s++; + #ifdef HAVE_IPV6 if (b_ipv6) { - hints.ai_family = AF_INET6; - gaie = I_getaddrinfo("ff02::1", "0", &hints, &ai); - if (gaie == 0) - { - runp = ai; - while (runp != NULL && s < MAXNETNODES+1) - { - memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen); - s++; - runp = runp->ai_next; - } - I_freeaddrinfo(ai); - } + broadcastaddress[s].any.sa_family = AF_INET6; + broadcastaddress[s].ip6.sin6_port = htons(atoi(DEFAULTPORT)); + broadcastaddress[s].ip6.sin6_flowinfo = 0; + inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &broadcastaddress[s].ip6.sin6_addr); + broadcastaddress[s].ip6.sin6_scope_id = 0; + s++; } #endif From 3c921044a35734e1c1326f7008c4049f7fce5b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Wed, 22 Nov 2023 20:26:55 +0100 Subject: [PATCH 15/17] Fix Windows build --- src/netcode/i_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netcode/i_tcp.c b/src/netcode/i_tcp.c index 9c0e8eb2b..0b650de49 100644 --- a/src/netcode/i_tcp.c +++ b/src/netcode/i_tcp.c @@ -788,7 +788,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &maddr.ipv6mr_multiaddr); maddr.ipv6mr_interface = 0; - if (setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP, &maddr, sizeof(maddr)) != 0) + if (setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP, (const char *)&maddr, sizeof(maddr)) != 0) { CONS_Alert(CONS_WARNING, M_GetText("Could not register multicast address\n")); } From 40f57de187896d241f67e810f859c3c7f431e102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Sun, 26 Nov 2023 21:30:54 +0100 Subject: [PATCH 16/17] Add indicator for IPv6-enabled servers --- src/m_menu.c | 2 ++ src/netcode/d_net.h | 1 + src/netcode/i_tcp.c | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index 629f53d24..e863bc40f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -11254,6 +11254,8 @@ static void M_DrawConnectMenu(void) V_DrawSmallString(currentMenu->x+202, S_LINEY(i)+8, globalflags, "\x85" "Mod"); if (serverlist[slindex].info.cheatsenabled) V_DrawSmallString(currentMenu->x+222, S_LINEY(i)+8, globalflags, "\x83" "Cheats"); + if (Net_IsNodeIPv6(serverlist[slindex].node)) + V_DrawSmallString(currentMenu->x+252, S_LINEY(i)+8, globalflags, "\x84" "IPv6"); V_DrawSmallString(currentMenu->x, S_LINEY(i)+8, globalflags, va("Ping: %u", (UINT32)LONG(serverlist[slindex].info.time))); diff --git a/src/netcode/d_net.h b/src/netcode/d_net.h index 549f2b93c..2f83939f8 100644 --- a/src/netcode/d_net.h +++ b/src/netcode/d_net.h @@ -70,6 +70,7 @@ boolean HGetPacket(void); void D_SetDoomcom(void); boolean D_CheckNetGame(void); void D_CloseConnection(void); +boolean Net_IsNodeIPv6(INT32 node); void Net_UnAcknowledgePacket(INT32 node); void Net_CloseConnection(INT32 node); void Net_ConnectionTimeout(INT32 node); diff --git a/src/netcode/i_tcp.c b/src/netcode/i_tcp.c index 0b650de49..b6d7724a4 100644 --- a/src/netcode/i_tcp.c +++ b/src/netcode/i_tcp.c @@ -1362,4 +1362,9 @@ boolean I_InitTcpNetwork(void) return ret; } +boolean Net_IsNodeIPv6(INT32 node) +{ + return clientaddress[node].any.sa_family == AF_INET6; +} + #include "i_addrinfo.c" From 2e885d4e6fd69b66c1c5cfd2a973f2353f0840ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Thu, 30 Nov 2023 16:03:44 +0100 Subject: [PATCH 17/17] Add NO_IPV6 check --- src/netcode/i_tcp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/netcode/i_tcp.c b/src/netcode/i_tcp.c index b6d7724a4..c70290e54 100644 --- a/src/netcode/i_tcp.c +++ b/src/netcode/i_tcp.c @@ -1364,7 +1364,11 @@ boolean I_InitTcpNetwork(void) boolean Net_IsNodeIPv6(INT32 node) { +#ifdef NO_IPV6 + return false; +#else return clientaddress[node].any.sa_family == AF_INET6; +#endif } #include "i_addrinfo.c"