From d6b90f0ec7640d6f31d0ee28f12162c2858a788e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:06:53 +0200 Subject: [PATCH] few more smaller cleanups --- src/g_game.c | 5 +++-- src/hu_stuff.c | 1 + src/p_map.c | 4 ++-- src/p_maputl.cpp | 3 +++ src/p_setup.c | 16 +++++++++++----- src/r_segs.cpp | 31 ++++++++++++++++++------------- src/s_sound.c | 1 + 7 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 0fd936768..17d1ea981 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -858,7 +858,8 @@ static void G_HandleLocalDriftturn(ticcmd_t *cmd, UINT8 ssplayer) static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) { INT32 axis = 0; - const boolean usejoystick = cv_usejoystick[(ssplayer-1)].value; + const UINT8 forplayer = (ssplayer-1); + const boolean usejoystick = cv_usejoystick[forplayer].value; // check for inputs and return button commands // for stuff like joining with item button, saltyhop, honking, etc. @@ -894,7 +895,7 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) #undef CHECKINPUT axis = JoyAxis(AXISLOOKBACK, ssplayer); - camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); + camspin[forplayer] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); // Reset to our spec player if we watch someone else. if ((cmd->driftturn || cmd->buttons) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4a149f927..17245b5d4 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1135,6 +1135,7 @@ static void HU_SendChatMessage(void) return; } } + // I'm very bad at C, I swear I am, additional checks eww! if (spc != 0) { diff --git a/src/p_map.c b/src/p_map.c index 76e9ada59..2311e0c44 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1579,13 +1579,13 @@ static boolean PIT_CheckLine(line_t *ld) tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - return true; + return true; // didn't hit it if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return true; if (P_BoxOnLineSide(tmbbox, ld) != -1) - return true; + return true; // didn't hit it if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. { diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 5beee5f36..041bad1db 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -1004,11 +1004,13 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) for (mobj = blocklinks[y*bmapwidth + x]; mobj; mobj = bnext) { P_SetTarget(&bnext, mobj->bnext); // We want to note our reference to bnext here incase it is MF_NOTHINK and gets removed! + if (!func(mobj)) { P_SetTarget(&bnext, NULL); return false; } + if (P_MobjWasRemoved(tmthing) // func just popped our tmthing, cannot continue. || (bnext && P_MobjWasRemoved(bnext))) // func just broke blockmap chain, cannot continue. { @@ -1016,6 +1018,7 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) return true; } } + P_SetTarget(&bnext, NULL); return true; } diff --git a/src/p_setup.c b/src/p_setup.c index 672f56879..e5e7a30c2 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1157,6 +1157,7 @@ static void P_InitializeLinedef(line_t *ld) CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has two-sided flag set, but no second sidedef\n", sizeu1((size_t)(ld - lines))); } + // killough 4/4/98: support special sidedef interpretation below if (ld->sidenum[0] != NO_INDEX && ld->special) sides[ld->sidenum[0]].special = ld->special; if (ld->sidenum[1] != NO_INDEX && ld->special) @@ -2483,7 +2484,9 @@ static void P_LoadRecordGhosts(void) if (!gpath) return; - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); + const char *mapname = G_BuildMapName(gamemap); + + sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, mapname); // Best Time ghost if (cv_ghost_besttime.value) @@ -2533,9 +2536,10 @@ static void P_LoadRecordGhosts(void) { lumpnum_t l; UINT8 j = 1; - while (j <= 99 && (l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(gamemap),j))) != LUMPERROR) + + while (j <= 99 && (l = W_CheckNumForName(va("%sS%02u", mapname, j))) != LUMPERROR) { - G_AddGhost(va("%sS%02u",G_BuildMapName(gamemap),j)); + G_AddGhost(va("%sS%02u", mapname, j)); j++; } } @@ -2577,10 +2581,12 @@ static void P_InitMinimapInfo(void) Patch_Free(minimapinfo.minimap_pic); minimapinfo.minimap_pic = NULL; - lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap))); + const char *mapname = G_BuildMapName(gamemap); + + lumpnum = W_CheckNumForName(va("%sR", mapname)); if (lumpnum != LUMPERROR) - minimapinfo.minimap_pic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_PATCH); + minimapinfo.minimap_pic = W_CachePatchName(va("%sR", mapname), PU_PATCH); minimapinfo.min_x = bsp->bbox[0][BOXLEFT]; minimapinfo.max_x = bsp->bbox[0][BOXRIGHT]; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index afc2757c9..8460d4679 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -311,6 +311,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 { rw_scalestep = drawseg->scalestep; spryscale = drawseg->scale1 + (x1 - drawseg->x1)*rw_scalestep; + if (dc->numlights) { // reset all lights to their starting heights for (i = 0; i < dc->numlights; i++) @@ -435,6 +436,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 windowtop = windowbottom + 1; set_colormap_below_light(); } + windowbottom = realbot; if (windowtop < windowbottom) colfunc_2s(dc, col); @@ -2615,8 +2617,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) auto set_topstep_normal = [&] { - topstep = -FixedMul (rw_scalestep, worldtop); - topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); + topstep = -FixedMul(rw_scalestep, worldtop); + topfrac = (centeryfrac>>4) - FixedMul(worldtop, rw_scale); }; // untextured seg @@ -2625,7 +2627,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) const bool tophigh = (worldhigh <= worldtop && worldhighslope <= worldtopslope); // if we cant see the goddamn skyplane, well there wont be any skybox - // we could kill skyVisible instead, but i want to keep the performance improvemnts it yields + // we could kill skyVisible instead, but i want to keep the performance improvements it yields // so we do this absolute trash if ((tophigh && (frontsector->floorpic != skyflatnum && frontsector->ceilingpic != skyflatnum)) // try to guess if its a "window" @@ -2637,14 +2639,16 @@ void R_StoreWallRange(INT32 start, INT32 stop) // this is an attempt to fix issues with textureless single sided lines drawing nothing where they should just draw sky instead if (tophigh && !backsector && frontsector->ceilingpic == skyflatnum) { - topstep = -FixedMul (rw_scalestep, worldbottom); - topfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); - // account for slopes to try and get rid of sharp edges from the black void if (frontsector->f_slope || (backsector && backsector->f_slope)) { - topstep = -FixedMul (rw_scalestep, worldbottomslope); - topfrac = (centeryfrac>>4) - FixedMul (worldbottomslope, rw_scale); + topstep = -FixedMul(rw_scalestep, worldbottomslope); + topfrac = (centeryfrac>>4) - FixedMul(worldbottomslope, rw_scale); + } + else + { + topstep = -FixedMul(rw_scalestep, worldbottom); + topfrac = (centeryfrac>>4) - FixedMul(worldbottom, rw_scale); } } else @@ -2653,18 +2657,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) else set_topstep_normal(); - bottomstep = -FixedMul (rw_scalestep, worldbottom); - bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); + bottomstep = -FixedMul(rw_scalestep, worldbottom); + bottomfrac = (centeryfrac>>4) - FixedMul(worldbottom, rw_scale); if (frontsector->c_slope) { - fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2); + fixed_t topfracend = (centeryfrac>>4) - FixedMul(worldtopslope, ds_p->scale2); topstep = (topfracend-topfrac)/(range); } if (frontsector->f_slope) { - fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2); + fixed_t bottomfracend = (centeryfrac>>4) - FixedMul(worldbottomslope, ds_p->scale2); bottomstep = (bottomfracend-bottomfrac)/(range); } } @@ -2782,7 +2786,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (bottomtexture) { - fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2); + fixed_t bottomfracend = (centeryfrac>>4) - FixedMul(worldlowslope, ds_p->scale2); pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); pixlowstep = (bottomfracend-pixlow)/(range); @@ -3045,6 +3049,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->silhouette |= SIL_BOTTOM; ds_p->bsilheight = backsector->f_slope ? INT32_MAX : backsector->floorheight; } + if (!(ds_p->silhouette & SIL_TOP)) { ds_p->silhouette |= SIL_TOP; diff --git a/src/s_sound.c b/src/s_sound.c index 10266d986..ce18af163 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -903,6 +903,7 @@ static boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, listener_t listensource; INT32 i; + // e6y if (!listener) return false;