From 336010e61649b4818f74d8a25b97239397847a81 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 18 Mar 2022 20:44:07 +0000 Subject: [PATCH] Fix portals - Resetting portalcullsector fixes the major visual glitches - Using 32 bits for nummasks and i fixes crashes when rendering lots of portals # Conflicts: # src/r_main.c --- src/r_main.c | 4 +--- src/r_portal.c | 1 + src/r_things.c | 4 ++-- src/r_things.h | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 5b1ade842..f71c6b255 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1500,8 +1500,7 @@ static void Mask_Post (maskcount_t* m) void R_RenderPlayerView(void) { player_t * player = &players[displayplayers[viewssnum]]; - - UINT8 nummasks = 1; + INT32 nummasks = 1; maskcount_t* masks = malloc(sizeof(maskcount_t)); // if this is display player 1 @@ -1572,7 +1571,6 @@ void R_RenderPlayerView(void) R_ClipSprites(drawsegs, NULL); ps_sw_spritecliptime = I_GetPreciseTime() - ps_sw_spritecliptime; - // Add skybox portals caused by sky visplanes. if (cv_skybox.value && player->skybox.viewpoint) Portal_AddSkyboxPortals(player); diff --git a/src/r_portal.c b/src/r_portal.c index 66763dff3..f3ae2524c 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -132,6 +132,7 @@ static portal_t* Portal_Add (const INT16 x1, const INT16 x2) void Portal_Remove (portal_t* portal) { + portalcullsector = NULL; portal_base = portal->next; Z_Free(portal->ceilingclip); Z_Free(portal->floorclip); diff --git a/src/r_things.c b/src/r_things.c index 3828ce2f1..5c966f9d0 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3274,10 +3274,10 @@ static void R_DrawMaskedList (drawnode_t* head) } } -void R_DrawMasked(maskcount_t* masks, UINT8 nummasks) +void R_DrawMasked(maskcount_t* masks, INT32 nummasks) { drawnode_t *heads; /**< Drawnode lists; as many as number of views/portals. */ - SINT8 i; + INT32 i; heads = calloc(nummasks, sizeof(drawnode_t)); diff --git a/src/r_things.h b/src/r_things.h index f0389303d..c34af2ef4 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -99,7 +99,7 @@ typedef struct sector_t* viewsector; } maskcount_t; -void R_DrawMasked(maskcount_t* masks, UINT8 nummasks); +void R_DrawMasked(maskcount_t* masks, INT32 nummasks); // ---------- // VISSPRITES