From f72f45d93ab530af40fb05b10be4a52a5c3db256 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Fri, 14 Jan 2022 19:53:03 +0200 Subject: [PATCH] Fix software splats breaking and crashing in skyboxes --- src/r_things.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index accd1e2b3..423276a59 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3001,13 +3001,25 @@ void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, drawseg_t* dsstart, p if (portal) { - for (x = x1; x <= x2; x++) + INT32 start_index = max(portal->start, x1); + INT32 end_index = min(portal->start + portal->end - portal->start, x2); + for (x = x1; x < start_index; x++) + { + spr->clipbot[x] = -1; + spr->cliptop[x] = -1; + } + for (x = start_index; x <= end_index; x++) { if (spr->clipbot[x] > portal->floorclip[x - portal->start]) spr->clipbot[x] = portal->floorclip[x - portal->start]; if (spr->cliptop[x] < portal->ceilingclip[x - portal->start]) spr->cliptop[x] = portal->ceilingclip[x - portal->start]; } + for (x = end_index + 1; x <= x2; x++) + { + spr->clipbot[x] = -1; + spr->cliptop[x] = -1; + } } }