From 234283ca8a9d744c8ce7b9c7fed29931f4b91b28 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Nov 2019 23:04:22 +0100 Subject: [PATCH] - SW: added validation checks to WallSetup. This code wrote to array index -1. With this change the level finally gets rendered, although it still doesn't work. --- source/sw/src/sector.cpp | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/source/sw/src/sector.cpp b/source/sw/src/sector.cpp index 2b62da57e..85bf8e668 100644 --- a/source/sw/src/sector.cpp +++ b/source/sw/src/sector.cpp @@ -185,7 +185,8 @@ WallSetup(void) // set first wall SET(wp->extra, WALLFX_LOOP_DONT_SPIN); - SET(wall[wp->nextwall].extra, WALLFX_LOOP_DONT_SPIN); + if (wp->nextwall >= 0) + SET(wall[wp->nextwall].extra, WALLFX_LOOP_DONT_SPIN); // move the the next wall start_wall = wp->point2; @@ -196,7 +197,8 @@ WallSetup(void) wall_num = wall[wall_num].point2) { SET(wall[wall_num].extra, WALLFX_LOOP_DONT_SPIN); - SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_DONT_SPIN); + if (wall[wall_num].nextwall >= 0) + SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_DONT_SPIN); } break; @@ -208,7 +210,8 @@ WallSetup(void) // set first wall SET(wp->extra, WALLFX_DONT_SCALE); - SET(wall[wp->nextwall].extra, WALLFX_DONT_SCALE); + if (wp->nextwall >= 0) + SET(wall[wp->nextwall].extra, WALLFX_DONT_SCALE); // move the the next wall start_wall = wp->point2; @@ -237,7 +240,8 @@ WallSetup(void) // set first wall SET(wp->extra, WALLFX_LOOP_OUTER|WALLFX_LOOP_OUTER_SECONDARY); - SET(wall[wp->nextwall].extra, WALLFX_LOOP_OUTER|WALLFX_LOOP_OUTER_SECONDARY); + if (wp->nextwall >= 0) + SET(wall[wp->nextwall].extra, WALLFX_LOOP_OUTER|WALLFX_LOOP_OUTER_SECONDARY); // move the the next wall start_wall = wp->point2; @@ -248,7 +252,8 @@ WallSetup(void) wall_num = wall[wall_num].point2) { SET(wall[wall_num].extra, WALLFX_LOOP_OUTER|WALLFX_LOOP_OUTER_SECONDARY); - SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_OUTER|WALLFX_LOOP_OUTER_SECONDARY); + if (wall[wall_num].nextwall >= 0) + SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_OUTER|WALLFX_LOOP_OUTER_SECONDARY); } break; @@ -263,7 +268,8 @@ WallSetup(void) // set first wall SET(wp->extra, WALLFX_LOOP_OUTER); - SET(wall[wp->nextwall].extra, WALLFX_LOOP_OUTER); + if (wp->nextwall >= 0) + SET(wall[wp->nextwall].extra, WALLFX_LOOP_OUTER); // move the the next wall start_wall = wp->point2; @@ -274,7 +280,8 @@ WallSetup(void) wall_num = wall[wall_num].point2) { SET(wall[wall_num].extra, WALLFX_LOOP_OUTER); - SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_OUTER); + if (wall[wall_num].nextwall >= 0) + SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_OUTER); } wp->lotag = 0; @@ -295,7 +302,8 @@ WallSetup(void) // set first wall SET(wp->extra, WALLFX_LOOP_SPIN_2X); - SET(wall[wp->nextwall].extra, WALLFX_LOOP_SPIN_2X); + if (wp->nextwall >= 0) + SET(wall[wp->nextwall].extra, WALLFX_LOOP_SPIN_2X); // move the the next wall start_wall = wp->point2; @@ -306,7 +314,8 @@ WallSetup(void) wall_num = wall[wall_num].point2) { SET(wall[wall_num].extra, WALLFX_LOOP_SPIN_2X); - SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_SPIN_2X); + if (wall[wall_num].nextwall >= 0) + SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_SPIN_2X); } break; @@ -318,7 +327,8 @@ WallSetup(void) // set first wall SET(wp->extra, WALLFX_LOOP_SPIN_4X); - SET(wall[wp->nextwall].extra, WALLFX_LOOP_SPIN_4X); + if (wp->nextwall >= 0) + SET(wall[wp->nextwall].extra, WALLFX_LOOP_SPIN_4X); // move the the next wall start_wall = wp->point2; @@ -329,7 +339,8 @@ WallSetup(void) wall_num = wall[wall_num].point2) { SET(wall[wall_num].extra, WALLFX_LOOP_SPIN_4X); - SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_SPIN_4X); + if (wall[wall_num].nextwall >= 0) + SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_SPIN_4X); } break; @@ -341,7 +352,8 @@ WallSetup(void) // set first wall SET(wp->extra, WALLFX_LOOP_REVERSE_SPIN); - SET(wall[wp->nextwall].extra, WALLFX_LOOP_REVERSE_SPIN); + if (wp->nextwall >= 0) + SET(wall[wp->nextwall].extra, WALLFX_LOOP_REVERSE_SPIN); // move the the next wall start_wall = wp->point2; @@ -352,7 +364,8 @@ WallSetup(void) wall_num = wall[wall_num].point2) { SET(wall[wall_num].extra, WALLFX_LOOP_REVERSE_SPIN); - SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_REVERSE_SPIN); + if (wall[wall_num].nextwall >= 0) + SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_REVERSE_SPIN); } break;