From fa899d39705c1a658f473754b6ce6efc2b64364a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 7 Jun 2026 07:07:56 +0200 Subject: [PATCH] fix a few more style issues --- src/d_netfil.c | 16 +++- src/hardware/hw_main.cpp | 193 +++++++++++++++++++-------------------- src/p_spec.c | 49 +++++----- src/p_user.c | 2 +- src/r_bsp.cpp | 21 ++++- src/r_fps.cpp | 8 +- src/r_things.cpp | 3 + 7 files changed, 159 insertions(+), 133 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 61852b436..944d9560b 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -259,9 +259,10 @@ void CL_PrepareDownloadSaveGame(const char *tmpsave) */ boolean CL_CheckDownloadable(void) { - UINT8 i,dlstatus = 0; + UINT8 i, dlstatus = 0; for (i = 0; i < fileneedednum; i++) + { if (fileneeded[i].status != FS_FOUND && fileneeded[i].status != FS_OPEN) { if (fileneeded[i].willsend == 1) @@ -272,6 +273,7 @@ boolean CL_CheckDownloadable(void) else //if (fileneeded[i].willsend == 2) dlstatus = 2; } + } // Downloading locally disabled if (!dlstatus && M_CheckParm("-nodownload")) @@ -282,15 +284,17 @@ boolean CL_CheckDownloadable(void) // not downloadable, put reason in console CONS_Alert(CONS_NOTICE, M_GetText("You need additional files to connect to this server:\n")); + for (i = 0; i < fileneedednum; i++) + { if (fileneeded[i].status != FS_FOUND && fileneeded[i].status != FS_OPEN) { CONS_Printf(" * \"%s\" (%dK)", fileneeded[i].filename, fileneeded[i].totalsize >> 10); - if (fileneeded[i].status == FS_MD5SUMBAD) - CONS_Printf(M_GetText(" wrong version, md5: ")); - else - CONS_Printf(M_GetText(" not found, md5: ")); + if (fileneeded[i].status == FS_MD5SUMBAD) + CONS_Printf(M_GetText(" wrong version, md5: ")); + else + CONS_Printf(M_GetText(" not found, md5: ")); { INT32 j; @@ -301,6 +305,7 @@ boolean CL_CheckDownloadable(void) } CONS_Printf("\n"); } + } switch (dlstatus) { @@ -314,6 +319,7 @@ boolean CL_CheckDownloadable(void) CONS_Printf(M_GetText("All files downloadable, but you have chosen to disable downloading locally.\n")); break; } + return false; } diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index c200d6682..cf5d0fda7 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1222,7 +1222,7 @@ static void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) wallVerts[0].s = wallVerts[3].s = 0; wallVerts[2].s = wallVerts[1].s = 0; - if (UNLIKELY(gl_collect_skywalls)) + if (gl_collect_skywalls) { HWR_SkyWallList_Add(wallVerts); } @@ -2323,7 +2323,7 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2) } } else - return;// dont do anything with the other side i guess? + return; // dont do anything with the other side i guess? } doaddline: @@ -2829,21 +2829,21 @@ static void HWR_Subsector(size_t num) if (anyMoved == false) { - for (rover = gl_frontsector->ffloors; rover; rover = rover->next) + if (sub->validcount != validcount) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) - continue; + for (rover = gl_frontsector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + continue; - if (sub->validcount == validcount) - continue; + const sector_t *controlSec = §ors[rover->secnum]; - const sector_t *controlSec = §ors[rover->secnum]; + if (controlSec->moved != true) + continue; - if (controlSec->moved != true) - continue; - - anyMoved = true; - break; + anyMoved = true; + break; + } } } @@ -2900,106 +2900,103 @@ static void HWR_Subsector(size_t num) PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap); } } - } - if (gl_frontsector->ffloors) - { - /// \todo fix light, xoffs, yoffs, extracolormap ? - for (rover = gl_frontsector->ffloors; rover; rover = rover->next) + if (gl_frontsector->ffloors) { - fixed_t bottomCullHeight, topCullHeight, centerHeight; - - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) - continue; - - if (sub->validcount == validcount) - continue; - - if (gl_frontsector->cullheight) + /// \todo fix light, xoffs, yoffs, extracolormap ? + for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { - if (HWR_DoCulling(gl_frontsector->cullheight, viewsector->cullheight, gl_viewz, FixedToFloat(*rover->bottomheight), FixedToFloat(*rover->topheight))) + fixed_t bottomCullHeight, topCullHeight, centerHeight; + + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) continue; - } - auto render_plane = [&](boolean bottom, fixed_t cullheight) FUNCINLINE - { - fixed_t roverheight; - lumpnum_t flatlump; - - if (bottom) + if (gl_frontsector->cullheight) { - roverheight = *rover->bottomheight; - flatlump = levelflats[*rover->bottompic].lumpnum; - } - else - { - roverheight = *rover->topheight; - flatlump = levelflats[*rover->toppic].lumpnum; + if (HWR_DoCulling(gl_frontsector->cullheight, viewsector->cullheight, gl_viewz, FixedToFloat(*rover->bottomheight), FixedToFloat(*rover->topheight))) + continue; } - if (rover->flags & FF_FOG) + auto render_fof_plane = [&](boolean bottom, boolean underside) FUNCINLINE { - UINT8 alpha; + fixed_t roverheight; + lumpnum_t flatlump; - light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); + if (bottom) + { + roverheight = *rover->bottomheight; + flatlump = levelflats[*rover->bottompic].lumpnum; + } + else + { + roverheight = *rover->topheight; + flatlump = levelflats[*rover->toppic].lumpnum; + } - alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + if (rover->flags & FF_FOG) + { + UINT8 alpha; - HWR_AddTransparentFloor(0, - &extrasubsectors[num], - !bottom, - roverheight, - *gl_frontsector->lightlist[light].lightlevel, - alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, - true, rover->master->frontsector->extra_colormap); + light = R_GetPlaneLight(gl_frontsector, centerHeight, underside); + + alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + + HWR_AddTransparentFloor(0, + &extrasubsectors[num], + !bottom, + roverheight, + *gl_frontsector->lightlist[light].lightlevel, + alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, + true, rover->master->frontsector->extra_colormap); + } + else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient + { + light = R_GetPlaneLight(gl_frontsector, centerHeight, underside); + + HWR_AddTransparentFloor(flatlump, + &extrasubsectors[num], + !bottom, + roverheight, + *gl_frontsector->lightlist[light].lightlevel, + CLAMP(rover->alpha, 0, 255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(PF_Translucent)), + false, gl_frontsector->lightlist[light].extra_colormap); + } + else + { + HWR_GetFlat(flatlump, R_NoEncore(gl_frontsector, !bottom)); + light = R_GetPlaneLight(gl_frontsector, centerHeight, underside); + + HWR_RenderPlane(sub, &extrasubsectors[num], !bottom, roverheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, flatlump, + rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); + } + }; + + // bottom plane + centerHeight = P_GetFFloorBottomZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + + if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight) + { + bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); + + if ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) + { + render_fof_plane(true, (viewz < bottomCullHeight)); + } } - else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient + + // top plane + centerHeight = P_GetFFloorTopZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + + if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight) { - light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); + topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); - HWR_AddTransparentFloor(flatlump, - &extrasubsectors[num], - !bottom, - roverheight, - *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0, 255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(PF_Translucent)), - false, gl_frontsector->lightlist[light].extra_colormap); - } - else - { - HWR_GetFlat(flatlump, R_NoEncore(gl_frontsector, !bottom)); - light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); - - HWR_RenderPlane(sub, &extrasubsectors[num], !bottom, roverheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, flatlump, - rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); - } - }; - - // bottom plane - centerHeight = P_GetFFloorBottomZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); - - if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight) - { - bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); - - if ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) - { - render_plane(true, bottomCullHeight); - } - } - - // top plane - centerHeight = P_GetFFloorTopZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); - - if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight) - { - topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); - - if ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) - { - render_plane(false, topCullHeight); + if ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) + { + render_fof_plane(false, (viewz < topCullHeight)); + } } } } diff --git a/src/p_spec.c b/src/p_spec.c index 265ff4afb..ca86f8ee4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -881,7 +881,7 @@ static boolean PolyDoor(line_t *line) pdd.polyObjNum = line->tag; // polyobject id - switch(line->special) + switch (line->special) { case 480: // Polyobj_DoorSlide pdd.doorType = POLY_DOOR_SLIDE; @@ -1597,19 +1597,21 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller) if (lines[masterline].tag != tag) continue; + const INT16 specialtype = lines[masterline].special; + // "No More Enemies" and "Level Load" take care of themselves. - if (lines[masterline].special == 313 - || lines[masterline].special == 399 - || lines[masterline].special == 328 - || lines[masterline].special == 323 + if (specialtype == 313 + || specialtype == 399 + || specialtype == 328 + || specialtype == 323 // Each-time executors handle themselves, too - || lines[masterline].special == 301 // Each time - || lines[masterline].special == 306 // Character ability - Each time - || lines[masterline].special == 310 // CTF Red team - Each time - || lines[masterline].special == 312 // CTF Blue team - Each time - || lines[masterline].special == 322 // Trigger on X calls - Each Time - || lines[masterline].special < 300 - || lines[masterline].special > 399) + || specialtype == 301 // Each time + || specialtype == 306 // Character ability - Each time + || specialtype == 310 // CTF Red team - Each time + || specialtype == 312 // CTF Blue team - Each time + || specialtype == 322 // Trigger on X calls - Each Time + || specialtype < 300 + || specialtype > 399) continue; if (!P_RunTriggerLinedef(&lines[masterline], actor, caller)) @@ -4736,7 +4738,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f P_AddSpikeThinker(sec, (INT32)sec2num); } // Should this FOF have friction? - else if(th->function == (actionf_p1)T_Friction) + else if (th->function == (actionf_p1)T_Friction) { f = (friction_t *)th; @@ -4744,7 +4746,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f Add_Friction(f->friction, f->movefactor, (INT32)(sec-sectors), f->affectee); } // Should this FOF have wind/current/pusher? - else if(th->function == (actionf_p1)T_Pusher) + else if (th->function == (actionf_p1)T_Pusher) { p = (pusher_t *)th; @@ -6946,6 +6948,7 @@ static void P_SpawnFriction(void) INT32 movefactor; // applied to each player move to simulate inertia for (i = 0; i < numlines; i++, l++) + { if (l->special == 540) { //length = P_AproxDistance(l->dx, l->dy)>>FRACBITS; @@ -6979,6 +6982,7 @@ static void P_SpawnFriction(void) for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) Add_Friction(friction, movefactor, s, -1); } + } } /* @@ -7293,13 +7297,16 @@ void T_Pusher(pusher_t *p) if (thing->flags2 & MF2_PUSHED) continue; - if (thing->player && thing->player->pflags & PF_ROPEHANG) - continue; + if (thing->player) + { + if (thing->player->pflags & PF_ROPEHANG) + continue; - if (thing->player && (thing->state == &states[thing->info->painstate]) - && (thing->player->powers[pw_flashing] > (K_GetKartFlashing(thing->player)/4)*3 - && thing->player->powers[pw_flashing] <= K_GetKartFlashing(thing->player))) - continue; + if ((thing->state == &states[thing->info->painstate]) + && (thing->player->powers[pw_flashing] > (K_GetKartFlashing(thing->player)/4)*3 + && thing->player->powers[pw_flashing] <= K_GetKartFlashing(thing->player))) + continue; + } inFOF = touching = moved = false; @@ -7429,7 +7436,7 @@ void T_Pusher(pusher_t *p) if (p->slider && thing->player) { boolean jumped = (thing->player->pflags & PF_JUMPED); - P_ResetPlayer (thing->player); + P_ResetPlayer(thing->player); if (jumped) thing->player->pflags |= PF_JUMPED; diff --git a/src/p_user.c b/src/p_user.c index 26e358cc8..11c5e0b81 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2361,7 +2361,7 @@ static void P_MovePlayer(player_t *player) if (onground && leveltime % 50 == 0 && player->kartstuff[k_drift] != 0) S_StartSound(player->mo, sfx_drift); // Leveltime being 50 might take a while at times. We'll start it up once, isntantly. - else if (onground && !S_SoundPlaying(player->mo, sfx_drift) && player->kartstuff[k_drift] != 0) + else if (onground && player->kartstuff[k_drift] != 0 && !S_SoundPlaying(player->mo, sfx_drift)) S_StartSound(player->mo, sfx_drift); // Ok, we'll stop now. else if (player->kartstuff[k_drift] == 0 || !onground) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 8fd66299c..68de16478 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -321,12 +321,19 @@ static void R_AddLine(seg_t *line) angle_t angle1, angle2, span, tspan; static sector_t tempsec; boolean bothfloorssky = false; + fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t g_portal = NULL; + v1x = line->v1->x; + v1y = line->v1->y; + + v2x = line->v2->x; + v2y = line->v2->y; + // big room fix - angle1 = R_PointToAngle64(line->v1->x, line->v1->y); - angle2 = R_PointToAngle64(line->v2->x, line->v2->y); + angle1 = R_PointToAngle64(v1x, v1y); + angle2 = R_PointToAngle64(v2x, v2y); curline = line; @@ -519,6 +526,7 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) angle_t angle1, angle2; INT32 sx1, sx2; const INT32* check; + fixed_t x1, y1, x2, y2; // Find the corners of the box // that define the edges from current viewpoint. @@ -532,9 +540,14 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) check = checkcoord[boxpos]; + x1 = bspcoord[check[0]]; + y1 = bspcoord[check[1]]; + x2 = bspcoord[check[2]]; + y2 = bspcoord[check[3]]; + // big room fix - angle1 = R_PointToAngle64(bspcoord[check[0]], bspcoord[check[1]]) - viewangle; - angle2 = R_PointToAngle64(bspcoord[check[2]], bspcoord[check[3]]) - viewangle; + angle1 = R_PointToAngle64(x1, y1) - viewangle; + angle2 = R_PointToAngle64(x2, y2) - viewangle; // cph - replaced old code, which was unclear and badly commented // Much more efficient code now diff --git a/src/r_fps.cpp b/src/r_fps.cpp index 7ccebf8e5..8372fa30f 100644 --- a/src/r_fps.cpp +++ b/src/r_fps.cpp @@ -387,10 +387,10 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst return; } - out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); - out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); - out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); - out->scale = mapobjectscale; + out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); + out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); + out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); + out->scale = mapobjectscale; } static levelinterpolator_t *CreateInterpolator(levelinterpolator_type_e type, thinker_t *thinker) diff --git a/src/r_things.cpp b/src/r_things.cpp index 52f8be112..875cb7290 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -773,6 +773,7 @@ static void R_DrawVisSprite(vissprite_t *vis) R_SetColumnFunc(BASEDRAWFUNC); // hack: this isn't resetting properly somewhere. dc.colormap = vis->colormap; + if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" { R_SetColumnFunc(COLDRAWFUNC_TRANS); // translate certain pixels to white @@ -825,6 +826,7 @@ static void R_DrawVisSprite(vissprite_t *vis) else dc.colormap = &vis->extra_colormap->colormap[dc.colormap - colormaps]; } + if (!dc.colormap) dc.colormap = colormaps; @@ -849,6 +851,7 @@ static void R_DrawVisSprite(vissprite_t *vis) vis->xiscale = FixedDiv(vis->xiscale, this_scale); vis->isScaled = true; } + dc.texturemid = FixedDiv(dc.texturemid, this_scale); }