From 9cc9b73021b6c6a20b17ee81b4b8129089550281 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 2 Apr 2023 22:17:01 -0700 Subject: [PATCH] Convert r_segs.c to r_segs.cpp --- src/CMakeLists.txt | 2 +- src/{r_segs.c => r_segs.cpp} | 60 ++++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 28 deletions(-) rename src/{r_segs.c => r_segs.cpp} (97%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 53a506b25..21ef13ce9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -71,7 +71,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 r_fps.c r_main.c r_plane.c - r_segs.c + r_segs.cpp r_skins.c r_sky.c r_splats.c diff --git a/src/r_segs.c b/src/r_segs.cpp similarity index 97% rename from src/r_segs.c rename to src/r_segs.cpp index 74800fb21..99e4c842e 100644 --- a/src/r_segs.c +++ b/src/r_segs.cpp @@ -138,7 +138,7 @@ transnum_t R_GetLinedefTransTable(fixed_t alpha) { if (alpha >= FRACUNIT) { - return 0; + return static_cast(0); } else if (alpha <= 0) { @@ -146,7 +146,7 @@ transnum_t R_GetLinedefTransTable(fixed_t alpha) } else { - return (20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1); + return static_cast((20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1)); } } @@ -177,7 +177,7 @@ static void R_RenderMaskedSegLoop(drawseg_t *ds, INT32 x1, INT32 x2, INT32 texnu ldef = curline->linedef; tripwire = P_IsLineTripWire(ldef); - range = max(ds->x2-ds->x1, 1); + range = std::max(ds->x2-ds->x1, 1); // Setup lighting based on the presence/lack-of 3D floors. dc_numlights = 0; @@ -187,7 +187,9 @@ static void R_RenderMaskedSegLoop(drawseg_t *ds, INT32 x1, INT32 x2, INT32 texnu if (dc_numlights >= dc_maxlights) { dc_maxlights = dc_numlights; - dc_lightlist = Z_Realloc(dc_lightlist, sizeof (*dc_lightlist) * dc_maxlights, PU_STATIC, NULL); + dc_lightlist = static_cast( + Z_Realloc(dc_lightlist, sizeof (*dc_lightlist) * dc_maxlights, PU_STATIC, NULL) + ); } for (i = 0; i < dc_numlights; i++) @@ -209,7 +211,7 @@ static void R_RenderMaskedSegLoop(drawseg_t *ds, INT32 x1, INT32 x2, INT32 texnu rlight->startheight = rlight->height; // keep starting value here to reset for each repeat rlight->lightlevel = *light->lightlevel; rlight->extra_colormap = *light->extra_colormap; - rlight->flags = light->flags; + rlight->flags = static_cast(light->flags); if ((R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == false) || (rlight->flags & FOF_FOG) @@ -561,7 +563,7 @@ static INT32 R_GetTwoSidedMidTexture(seg_t *line) static boolean R_CheckBlendMode(const line_t *ldef, INT32 bmnum) { transnum_t transtable = NUMTRANSMAPS; - patchalphastyle_t blendmode = 0; + patchalphastyle_t blendmode = AST_COPY; transtable = R_GetLinedefTransTable(ldef->alpha); if (transtable == NUMTRANSMAPS) @@ -570,11 +572,11 @@ static boolean R_CheckBlendMode(const line_t *ldef, INT32 bmnum) return false; } - blendmode = ldef->blendmode; + blendmode = static_cast(ldef->blendmode); if (blendmode == AST_MODULATE || blendmode == AST_FOG) { // These blend modes don't use translucency - transtable = 0; + transtable = static_cast(0); } if (blendmode == AST_FOG) @@ -790,7 +792,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) R_SetColumnFunc(COLDRAWFUNC_FOG, bmnum != 0); } - range = max(ds->x2-ds->x1, 1); + range = std::max(ds->x2-ds->x1, 1); //SoM: Moved these up here so they are available for my lightlist calculations rw_scalestep = ds->scalestep; spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; @@ -802,7 +804,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (dc_numlights > dc_maxlights) { dc_maxlights = dc_numlights; - dc_lightlist = Z_Realloc(dc_lightlist, sizeof (*dc_lightlist) * dc_maxlights, PU_STATIC, NULL); + dc_lightlist = static_cast( + Z_Realloc(dc_lightlist, sizeof (*dc_lightlist) * dc_maxlights, PU_STATIC, NULL) + ); } for (i = p = 0; i < dc_numlights; i++) @@ -849,7 +853,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else if (overflow_test > (INT64)CLAMPMIN) rlight->heightstep = (fixed_t)overflow_test; else rlight->heightstep = CLAMPMIN; rlight->heightstep = (rlight->heightstep-rlight->height)/(range); - rlight->flags = light->flags; + rlight->flags = static_cast(light->flags); if (light->flags & FOF_CUTLEVEL) { SLOPEPARAMS(*light->caster->b_slope, leftheight, rightheight, *light->caster->bottomheight) @@ -1674,8 +1678,8 @@ static void R_RenderSegLoop (void) if (maskedtextureheight != NULL) { maskedtextureheight[rw_x] = (curline->linedef->flags & ML_MIDPEG) ? - max(rw_midtexturemid, rw_midtextureback) : - min(rw_midtexturemid, rw_midtextureback); + std::max(rw_midtexturemid, rw_midtextureback) : + std::min(rw_midtexturemid, rw_midtextureback); } } @@ -1766,7 +1770,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) size_t newmax = maxdrawsegs ? maxdrawsegs*2 : 128; if (firstseg) firstseg = (drawseg_t *)(firstseg - drawsegs); - drawsegs = Z_Realloc(drawsegs, newmax*sizeof (*drawsegs), PU_STATIC, NULL); + drawsegs = static_cast(Z_Realloc(drawsegs, newmax*sizeof (*drawsegs), PU_STATIC, NULL)); ds_p = drawsegs + pos; maxdrawsegs = newmax; curdrawsegs = drawsegs + curpos; @@ -1813,7 +1817,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) do maxopenings = maxopenings ? maxopenings*2 : 16384; while (need > maxopenings); - openings = Z_Realloc(openings, maxopenings * sizeof (*openings), PU_STATIC, NULL); + openings = static_cast(Z_Realloc(openings, maxopenings * sizeof (*openings), PU_STATIC, NULL)); lastopening = openings + pos; // borrowed fix from *cough* zdoom *cough* @@ -2294,10 +2298,10 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->thicksidecol = maskedtexturecol = lastopening - rw_x; lastopening += rw_stopx - rw_x; - lowcut = max(worldbottom, worldlow) + viewz; - highcut = min(worldtop, worldhigh) + viewz; - lowcutslope = max(worldbottomslope, worldlowslope) + viewz; - highcutslope = min(worldtopslope, worldhighslope) + viewz; + lowcut = std::max(worldbottom, worldlow) + viewz; + highcut = std::min(worldtop, worldhigh) + viewz; + lowcutslope = std::max(worldbottomslope, worldlowslope) + viewz; + highcutslope = std::min(worldtopslope, worldhighslope) + viewz; if (frontsector->ffloors && backsector->ffloors) { @@ -2487,9 +2491,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) { // use REAL front and back floors please, so midtexture rendering isn't mucked up rw_midtextureslide = rw_midtexturebackslide = 0; if (linedef->flags & ML_MIDPEG) - rw_midtexturemid = rw_midtextureback = max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz; + rw_midtexturemid = rw_midtextureback = std::max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz; else - rw_midtexturemid = rw_midtextureback = min(curline->frontsector->ceilingheight, curline->backsector->ceilingheight) - viewz; + rw_midtexturemid = rw_midtextureback = std::min(curline->frontsector->ceilingheight, curline->backsector->ceilingheight) - viewz; } else { @@ -2498,9 +2502,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) { // Ignore slopes when texturing rw_midtextureslide = rw_midtexturebackslide = 0; if (linedef->flags & ML_MIDPEG) - rw_midtexturemid = rw_midtextureback = max(frontsector->floorheight, backsector->floorheight) - viewz; + rw_midtexturemid = rw_midtextureback = std::max(frontsector->floorheight, backsector->floorheight) - viewz; else - rw_midtexturemid = rw_midtextureback = min(frontsector->ceilingheight, backsector->ceilingheight) - viewz; + rw_midtexturemid = rw_midtextureback = std::min(frontsector->ceilingheight, backsector->ceilingheight) - viewz; } else if (linedef->flags & ML_MIDPEG) @@ -2642,7 +2646,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (dc_numlights >= dc_maxlights) { dc_maxlights = dc_numlights; - dc_lightlist = Z_Realloc(dc_lightlist, sizeof (*dc_lightlist) * dc_maxlights, PU_STATIC, NULL); + dc_lightlist = static_cast( + Z_Realloc(dc_lightlist, sizeof (*dc_lightlist) * dc_maxlights, PU_STATIC, NULL) + ); } for (i = p = 0; i < dc_numlights; i++) @@ -2677,7 +2683,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) rlight->height = (centeryfrac>>4) - FixedMul(leftheight, rw_scale); rlight->heightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2); rlight->heightstep = (rlight->heightstep-rlight->height)/(range); - rlight->flags = light->flags; + rlight->flags = static_cast(light->flags); if (light->caster && light->caster->fofflags & FOF_CUTSOLIDS) { @@ -2743,7 +2749,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) pixhighstep = (topfracend-pixhigh)/(range); // If the lowest part of a ceiling stretching down covers the entire screen - if (min(pixhigh, topfracend)>>HEIGHTBITS >= viewheight-1) + if (std::min(pixhigh, topfracend)>>HEIGHTBITS >= viewheight-1) g_walloffscreen = true; } @@ -2755,7 +2761,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) pixlowstep = (bottomfracend-pixlow)/(range); // If the highest part of a floor stretching up covers the entire screen - if ((max(pixlow, bottomfracend)+HEIGHTUNIT-1)>>HEIGHTBITS <= 0) + if ((std::max(pixlow, bottomfracend)+HEIGHTUNIT-1)>>HEIGHTBITS <= 0) g_walloffscreen = true; }