- 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.
This commit is contained in:
Christoph Oelckers 2020-10-18 12:10:46 +02:00
parent 4d3135f4b8
commit f4c79161ad
2 changed files with 15 additions and 9 deletions

View File

@ -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);

View File

@ -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;