R_MapPlane, R_MapTiltedPlane: return on invalid coordinates, debug print in devmode render

This commit is contained in:
James R 2024-03-02 22:25:46 -08:00
parent 45aef83fc1
commit d2d9edb7e3

View file

@ -126,6 +126,18 @@ static void R_UpdatePlaneRipple(drawspandata_t* ds)
static void R_SetSlopePlaneVectors(drawspandata_t* ds, visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff); static void R_SetSlopePlaneVectors(drawspandata_t* ds, visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff);
static bool R_CheckMapPlane(const char* funcname, INT32 y, INT32 x1, INT32 x2)
{
if (x1 == x2)
return true;
if (x1 < x2 && x1 >= 0 && x2 < viewwidth && y >= 0 && y < viewheight)
return true;
CONS_Debug(DBG_RENDER, "%s: x1=%d, x2=%d at y=%d\n", funcname, x1, x2, y);
return false;
}
static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *spanfunc, INT32 y, INT32 x1, INT32 x2, boolean allow_parallel) static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *spanfunc, INT32 y, INT32 x1, INT32 x2, boolean allow_parallel)
{ {
ZoneScoped; ZoneScoped;
@ -133,13 +145,8 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *spanfunc, INT32 y, IN
fixed_t distance = 0, span; fixed_t distance = 0, span;
size_t pindex; size_t pindex;
#ifdef RANGECHECK if (!R_CheckMapPlane(__func__, y, x1, x2))
if (x2 < x1 || x1 < 0 || x2 >= viewwidth || y > viewheight) return;
I_Error("R_MapPlane: %d, %d at %d", x1, x2, y);
#endif
if (x1 >= vid.width)
x1 = vid.width - 1;
angle = (ds->currentplane->viewangle + ds->currentplane->plangle)>>ANGLETOFINESHIFT; angle = (ds->currentplane->viewangle + ds->currentplane->plangle)>>ANGLETOFINESHIFT;
planecos = FINECOSINE(angle); planecos = FINECOSINE(angle);
@ -216,13 +223,9 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *spanfunc, INT32 y, IN
static void R_MapTiltedPlane(drawspandata_t *ds, void(*spanfunc)(drawspandata_t*), INT32 y, INT32 x1, INT32 x2, boolean allow_parallel) static void R_MapTiltedPlane(drawspandata_t *ds, void(*spanfunc)(drawspandata_t*), INT32 y, INT32 x1, INT32 x2, boolean allow_parallel)
{ {
ZoneScoped; ZoneScoped;
#ifdef RANGECHECK
if (x2 < x1 || x1 < 0 || x2 >= viewwidth || y >= viewheight || y < 0)
I_Error("R_MapTiltedPlane: %d, %d at %d", x1, x2, y);
#endif
if (x1 >= vid.width) if (!R_CheckMapPlane(__func__, y, x1, x2))
x1 = vid.width - 1; return;
// Water ripple effect // Water ripple effect
if (ds->planeripple.active) if (ds->planeripple.active)