From f4c79161adc1a4ef1efe818368a47fc08bba42b3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Oct 2020 12:10:46 +0200 Subject: [PATCH] - fixed crash when opening the first gate in RRRA's E1L1. There was some poor coding at play here that fell victim to changed execution order. Changed everything so that problem cases always get dealt with properly. --- source/games/duke/src/actors_lava.cpp | 20 ++++++++++++-------- source/games/duke/src/premap_r.cpp | 4 +++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/source/games/duke/src/actors_lava.cpp b/source/games/duke/src/actors_lava.cpp index fcd338d51..1aef39f80 100644 --- a/source/games/duke/src/actors_lava.cpp +++ b/source/games/duke/src/actors_lava.cpp @@ -147,6 +147,12 @@ void addjaildoor(int p1, int p2, int iht, int jlt, int p3, int j) if (jaildoorcnt >= 32) I_Error("Too many jaildoor sectors"); + if (jlt != 10 && jlt != 20 && jlt != 30 && jlt != 40) + { + Printf(PRINT_HIGH, "Bad direction %d for jail door with tag %d\n", iht); + return; // wouldn't work so let's skip it. + } + jaildoordist[jaildoorcnt] = p1; jaildoorspeed[jaildoorcnt] = p2; jaildoorsecthtag[jaildoorcnt] = iht; @@ -283,23 +289,21 @@ void dojaildoor(void) endwall = startwall + sector[jaildoorsect[i]].wallnum; for (j = startwall; j < endwall; j++) { + x = wall[j].x; + y = wall[j].y; switch (jaildoordir[i]) { case 10: - x = wall[j].x; - y = wall[j].y + speed; + y += speed; break; case 20: - x = wall[j].x - speed; - y = wall[j].y; + x -= speed; break; case 30: - x = wall[j].x; - y = wall[j].y - speed; + y -= speed; break; case 40: - x = wall[j].x + speed; - y = wall[j].y; + x += speed; break; } dragpoint(j,x,y); diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 2844c615c..c436db2ce 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -513,7 +513,9 @@ void prelevel_r(int g) { if (sector[i].hitag == sector[j].hitag && j != i) { - addjaildoor(dist, speed, sector[i].hitag, sector[j].lotag, sound, j); + // & 32767 to avoid some ordering issues here. + // Other code assumes that the lotag is always a sector effector type and can mask the high bit in. + addjaildoor(dist, speed, sector[i].hitag, sector[j].lotag & 32767, sound, j); } } break;