From 3ea57bdf2ff2eea76e6619851bfec7dc1dfa8a4a Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 2 Mar 2024 22:23:42 -0800 Subject: [PATCH 1/3] CONS_Printf: lock more of the function behind mutex --- src/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index bf2dd069f..282f833a4 100644 --- a/src/console.c +++ b/src/console.c @@ -1512,6 +1512,8 @@ void CONS_Printf(const char *fmt, ...) vsprintf(txt, fmt, argptr); va_end(argptr); + Lock_state(); + // echo console prints to log file DEBFILE(txt); @@ -1521,8 +1523,6 @@ void CONS_Printf(const char *fmt, ...) CON_LogMessage(txt); - Lock_state(); - // make sure new text is visible con_scrollup = 0; From 45aef83fc1be48cb971f8b544daa6ad8c5c724e1 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 2 Mar 2024 22:24:27 -0800 Subject: [PATCH 2/3] debugrender_portal, debugrender_visplanes: fix in splitscreen - Fix debugrender_visplanes crashing - Fix debugrender_portal drawing everything on P1 viewport --- src/r_main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index 365bd6674..e82da5cc6 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1617,7 +1617,11 @@ void R_RenderPlayerView(void) { if (top > bot) std::swap(top, bot); - UINT8* p = &screens[0][x + top * vid.width]; + if (top < 0) + top = 0; + if (bot > viewheight-1) + bot = viewheight-1; + UINT8* p = &topleft[x + top * vid.width]; while (top <= bot) { *p = 35; @@ -1634,7 +1638,7 @@ void R_RenderPlayerView(void) INT32 bottom = pl->bottom[pl->minx]; span(pl->minx, top, bottom); span(pl->maxx, pl->top[pl->maxx], pl->bottom[pl->maxx]); - for (INT32 x = pl->minx + 1; x < pl->maxx; ++x) + for (INT32 x = pl->minx + 1; x < std::min(pl->maxx, viewwidth); ++x) { INT32 new_top = pl->top[x]; INT32 new_bottom = pl->bottom[x]; @@ -1668,14 +1672,14 @@ void R_RenderPlayerView(void) INT32 width = (portal->end - portal->start); INT32 i; - for (i = 0; i < width; ++i) + for (i = 0; i < std::min(width, viewwidth); ++i) { INT32 yl = std::max(portal->ceilingclip[i] + 1, 0); INT32 yh = std::min(static_cast(portal->floorclip[i]), viewheight); for (; yl < yh; ++yl) { - screens[0][portal->start + i + (yl * vid.width)] = pal; + topleft[portal->start + i + (yl * vid.width)] = pal; } } From d2d9edb7e3c1e128b0776ef789dbd47f26b3560b Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 2 Mar 2024 22:25:46 -0800 Subject: [PATCH 3/3] 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)