From d2d9edb7e3c1e128b0776ef789dbd47f26b3560b Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 2 Mar 2024 22:25:46 -0800 Subject: [PATCH] R_MapPlane, R_MapTiltedPlane: return on invalid coordinates, debug print in devmode render --- src/r_plane.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index fba7de8a3..0d0dd68e8 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -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 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) { ZoneScoped; @@ -133,13 +145,8 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *spanfunc, INT32 y, IN fixed_t distance = 0, span; size_t pindex; -#ifdef RANGECHECK - if (x2 < x1 || x1 < 0 || x2 >= viewwidth || y > viewheight) - I_Error("R_MapPlane: %d, %d at %d", x1, x2, y); -#endif - - if (x1 >= vid.width) - x1 = vid.width - 1; + if (!R_CheckMapPlane(__func__, y, x1, x2)) + return; angle = (ds->currentplane->viewangle + ds->currentplane->plangle)>>ANGLETOFINESHIFT; 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) { 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) - x1 = vid.width - 1; + if (!R_CheckMapPlane(__func__, y, x1, x2)) + return; // Water ripple effect if (ds->planeripple.active)