From a55be25a9d9765ddd43cfad2ca82bf23caba86e1 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 8 Mar 2018 00:55:37 +0100 Subject: [PATCH] - add const qualifier on top/bottom clip arrays usage --- src/swrenderer/line/r_fogboundary.cpp | 2 +- src/swrenderer/line/r_fogboundary.h | 2 +- src/swrenderer/line/r_renderdrawsegment.cpp | 12 +++---- src/swrenderer/things/r_visiblesprite.cpp | 39 +++++++++++---------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/swrenderer/line/r_fogboundary.cpp b/src/swrenderer/line/r_fogboundary.cpp index bd6ba50aa..1b8f1c99d 100644 --- a/src/swrenderer/line/r_fogboundary.cpp +++ b/src/swrenderer/line/r_fogboundary.cpp @@ -54,7 +54,7 @@ namespace swrenderer { - void RenderFogBoundary::Render(RenderThread *thread, int x1, int x2, short *uclip, short *dclip, int wallshade, float lightleft, float lightstep, FDynamicColormap *basecolormap) + void RenderFogBoundary::Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, int wallshade, float lightleft, float lightstep, FDynamicColormap *basecolormap) { // This is essentially the same as R_MapVisPlane but with an extra step // to create new horizontal spans whenever the light changes enough that diff --git a/src/swrenderer/line/r_fogboundary.h b/src/swrenderer/line/r_fogboundary.h index 39005c039..b506ec7f8 100644 --- a/src/swrenderer/line/r_fogboundary.h +++ b/src/swrenderer/line/r_fogboundary.h @@ -31,7 +31,7 @@ namespace swrenderer class RenderFogBoundary { public: - void Render(RenderThread *thread, int x1, int x2, short *uclip, short *dclip, int wallshade, float lightleft, float lightstep, FDynamicColormap *basecolormap); + void Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, int wallshade, float lightleft, float lightstep, FDynamicColormap *basecolormap); private: void RenderSection(RenderThread *thread, int y, int y2, int x1); diff --git a/src/swrenderer/line/r_renderdrawsegment.cpp b/src/swrenderer/line/r_renderdrawsegment.cpp index 89c73455c..3550b7356 100644 --- a/src/swrenderer/line/r_renderdrawsegment.cpp +++ b/src/swrenderer/line/r_renderdrawsegment.cpp @@ -130,8 +130,8 @@ namespace swrenderer bool notrelevant = false; if (ds->bFogBoundary) { - short *mfloorclip = ds->sprbottomclip - ds->x1; - short *mceilingclip = ds->sprtopclip - ds->x1; + const short *mfloorclip = ds->sprbottomclip - ds->x1; + const short *mceilingclip = ds->sprtopclip - ds->x1; RenderFogBoundary renderfog; renderfog.Render(Thread, x1, x2, mceilingclip, mfloorclip, wallshade, rw_light, rw_lightstep, basecolormap); @@ -179,8 +179,8 @@ namespace swrenderer tex = tex->GetRawTexture(); } - short *mfloorclip = ds->sprbottomclip - ds->x1; - short *mceilingclip = ds->sprtopclip - ds->x1; + const short *mfloorclip = ds->sprbottomclip - ds->x1; + const short *mceilingclip = ds->sprtopclip - ds->x1; float *MaskedSWall = ds->swall - ds->x1; float MaskedScaleY = ds->yscale; @@ -428,8 +428,8 @@ namespace swrenderer rw_lightstep = ds->lightstep; rw_light = ds->light + (x1 - ds->x1) * rw_lightstep; - short *mfloorclip = ds->sprbottomclip - ds->x1; - short *mceilingclip = ds->sprtopclip - ds->x1; + const short *mfloorclip = ds->sprbottomclip - ds->x1; + const short *mceilingclip = ds->sprtopclip - ds->x1; //double spryscale = ds->iscale + ds->iscalestep * (x1 - ds->x1); float *MaskedSWall = ds->swall - ds->x1; diff --git a/src/swrenderer/things/r_visiblesprite.cpp b/src/swrenderer/things/r_visiblesprite.cpp index 2a1d36eeb..a128734ea 100644 --- a/src/swrenderer/things/r_visiblesprite.cpp +++ b/src/swrenderer/things/r_visiblesprite.cpp @@ -62,10 +62,8 @@ namespace swrenderer VisibleSprite *spr = this; - int i; int x1, x2; short topclip, botclip; - short *clip1, *clip2; FSWColormap *colormap = spr->Light.BaseColormap; int colormapnum = spr->Light.ColormapNum; F3DFloor *rover; @@ -108,7 +106,7 @@ namespace swrenderer } sector_t *sec = nullptr; FDynamicColormap *mybasecolormap = nullptr; - for (i = spr->sector->e->XFloor.lightlist.Size() - 1; i >= 0; i--) + for (int i = spr->sector->e->XFloor.lightlist.Size() - 1; i >= 0; i--) { if (clip3d->sclipTop <= spr->sector->e->XFloor.lightlist[i].plane.Zat0()) { @@ -281,14 +279,16 @@ namespace swrenderer return; } - i = x2 - x1; - clip1 = clipbot + x1; - clip2 = cliptop + x1; - do { - *clip1++ = botclip; - *clip2++ = topclip; - } while (--i); + int i = x2 - x1; + short *clip1 = clipbot + x1; + short *clip2 = cliptop + x1; + do + { + *clip1++ = botclip; + *clip2++ = topclip; + } while (--i); + } // Scan drawsegs from end to start for obscuring segs. // The first drawseg that is closer than the sprite is the clip seg. @@ -338,9 +338,9 @@ namespace swrenderer int r2 = MIN(group.x2, x2); // Clip bottom - clip1 = clipbot + r1; - clip2 = group.sprbottomclip + r1 - group.x1; - i = r2 - r1; + short *clip1 = clipbot + r1; + const short *clip2 = group.sprbottomclip + r1 - group.x1; + int i = r2 - r1; do { if (*clip1 > *clip2) @@ -398,9 +398,9 @@ namespace swrenderer if (ds->silhouette & SIL_BOTTOM) //bottom sil { - clip1 = clipbot + r1; - clip2 = ds->sprbottomclip + r1 - ds->x1; - i = r2 - r1; + short *clip1 = clipbot + r1; + const short *clip2 = ds->sprbottomclip + r1 - ds->x1; + int i = r2 - r1; do { if (*clip1 > *clip2) @@ -412,9 +412,9 @@ namespace swrenderer if (ds->silhouette & SIL_TOP) // top sil { - clip1 = cliptop + r1; - clip2 = ds->sprtopclip + r1 - ds->x1; - i = r2 - r1; + short *clip1 = cliptop + r1; + const short *clip2 = ds->sprtopclip + r1 - ds->x1; + int i = r2 - r1; do { if (*clip1 < *clip2) @@ -438,6 +438,7 @@ namespace swrenderer // If it is completely clipped away, don't bother drawing it. if (cliptop[x2] >= clipbot[x2]) { + int i; for (i = x1; i < x2; ++i) { if (cliptop[i] < clipbot[i])