- RR: deal with wall[] in actor_lava.cpp

This commit is contained in:
Christoph Oelckers 2021-11-17 22:46:17 +01:00
parent 399f254629
commit 2fa027a686

View file

@ -190,7 +190,6 @@ void dotorch(void)
{ {
int ds; int ds;
int j; int j;
int startwall, endwall;
uint8_t shade; uint8_t shade;
ds = krand()&8; ds = krand()&8;
for (int i = 0; i < torchcnt; i++) for (int i = 0; i < torchcnt; i++)
@ -216,25 +215,23 @@ void dotorch(void)
sect->floorshade = shade; sect->floorshade = shade;
break; break;
} }
startwall = sect->wallptr; for (auto& wal : wallsofsector(sect))
endwall = startwall + sect->wallnum;
for (j = startwall; j < endwall; j++)
{ {
if (wall[j].lotag != 1) if (wal.lotag != 1)
{ {
switch (torchtype[i]) switch (torchtype[i])
{ {
case 0: case 0:
wall[j].shade = shade; wal.shade = shade;
break; break;
case 1: case 1:
wall[j].shade = shade; wal.shade = shade;
break; break;
case 2: case 2:
wall[j].shade = shade; wal.shade = shade;
break; break;
case 3: case 3:
wall[j].shade = shade; wal.shade = shade;
break; break;
} }
} }
@ -250,12 +247,9 @@ void dotorch(void)
void dojaildoor(void) void dojaildoor(void)
{ {
int j;
int startwall, endwall;
int x, y;
int speed;
for (int i = 0; i < jaildoorcnt; i++) for (int i = 0; i < jaildoorcnt; i++)
{ {
int speed;
auto sectp = &sector[jaildoorsect[i]]; auto sectp = &sector[jaildoorsect[i]];
if (numplayers > 2) if (numplayers > 2)
speed = jaildoorspeed[i]; speed = jaildoorspeed[i];
@ -288,12 +282,10 @@ void dojaildoor(void)
} }
else else
{ {
startwall = sectp->wallptr; for (auto& wal : wallsofsector(sectp))
endwall = startwall + sectp->wallnum;
for (j = startwall; j < endwall; j++)
{ {
x = wall[j].x; int x = wal.x;
y = wall[j].y; int y = wal.y;
switch (jaildoordir[i]) switch (jaildoordir[i])
{ {
case 10: case 10:
@ -309,7 +301,7 @@ void dojaildoor(void)
x += speed; x += speed;
break; break;
} }
dragpoint(j,x,y); dragpoint(&wal, x, y);
} }
} }
} }
@ -338,35 +330,33 @@ void dojaildoor(void)
} }
else else
{ {
startwall = sectp->wallptr; for (auto& wal : wallsofsector(sectp))
endwall = startwall + sectp->wallnum;
for (j = startwall; j < endwall; j++)
{ {
auto wal = &wall[j]; int x, y;
switch (jaildoordir[i]) switch (jaildoordir[i])
{ {
default: // make case of bad parameters well defined. default: // make case of bad parameters well defined.
x = wal->x; x = wal.x;
y = wal->y; y = wal.y;
break; break;
case 10: case 10:
x = wal->x; x = wal.x;
y = wal->y + speed; y = wal.y + speed;
break; break;
case 20: case 20:
x = wal->x - speed; x = wal.x - speed;
y = wal->y; y = wal.y;
break; break;
case 30: case 30:
x = wal->x; x = wal.x;
y = wal->y - speed; y = wal.y - speed;
break; break;
case 40: case 40:
x = wal->x + speed; x = wal.x + speed;
y = wal->y; y = wal.y;
break; break;
} }
dragpoint(j,x,y); dragpoint(&wal, x, y);
} }
} }
} }
@ -427,35 +417,32 @@ void moveminecart(void)
} }
else else
{ {
startwall = sectp->wallptr; for (auto& wal : wallsofsector(sectp))
endwall = startwall + sectp->wallnum;
for (j = startwall; j < endwall; j++)
{ {
auto wal = &wall[j];
switch (minecartdir[i]) switch (minecartdir[i])
{ {
default: // make case of bad parameters well defined. default: // make case of bad parameters well defined.
x = wal->x; x = wal.x;
y = wal->y; y = wal.y;
break; break;
case 10: case 10:
x = wal->x; x = wal.x;
y = wal->y + speed; y = wal.y + speed;
break; break;
case 20: case 20:
x = wal->x - speed; x = wal.x - speed;
y = wal->y; y = wal.y;
break; break;
case 30: case 30:
x = wal->x; x = wal.x;
y = wal->y - speed; y = wal.y - speed;
break; break;
case 40: case 40:
x = wal->x + speed; x = wal.x + speed;
y = wal->y; y = wal.y;
break; break;
} }
dragpoint(j,x,y); dragpoint(&wal, x, y);
} }
} }
} }
@ -484,47 +471,42 @@ void moveminecart(void)
} }
else else
{ {
startwall = sectp->wallptr; for (auto& wal : wallsofsector(sectp))
endwall = startwall + sectp->wallnum;
for (j = startwall; j < endwall; j++)
{ {
auto wal = &wall[j];
switch (minecartdir[i]) switch (minecartdir[i])
{ {
default: // make case of bad parameters well defined. default: // make case of bad parameters well defined.
x = wal->x; x = wal.x;
y = wal->y; y = wal.y;
break; break;
case 10: case 10:
x = wal->x; x = wal.x;
y = wal->y + speed; y = wal.y + speed;
break; break;
case 20: case 20:
x = wal->x - speed; x = wal.x - speed;
y = wal->y; y = wal.y;
break; break;
case 30: case 30:
x = wal->x; x = wal.x;
y = wal->y - speed; y = wal.y - speed;
break; break;
case 40: case 40:
x = wal->x + speed; x = wal.x + speed;
y = wal->y; y = wal.y;
break; break;
} }
dragpoint(j,x,y); dragpoint(&wal, x, y);
} }
} }
} }
csect = minecartchildsect[i]; csect = minecartchildsect[i];
startwall = sector[csect].wallptr;
endwall = startwall + sector[csect].wallnum;
max_x = max_y = -0x20000; max_x = max_y = -0x20000;
min_x = min_y = 0x20000; min_x = min_y = 0x20000;
for (j = startwall; j < endwall; j++) for (auto& wal : wallsofsector(csect))
{ {
x = wall[j].x; x = wal.x;
y = wall[j].y; y = wal.y;
if (x > max_x) if (x > max_x)
max_x = x; max_x = x;
if (y > max_y) if (y > max_y)
@ -629,12 +611,10 @@ void thunder(void)
for (i = 0; i < lightnincnt; i++) for (i = 0; i < lightnincnt; i++)
{ {
auto sectp = &sector[lightninsector[i]]; auto sectp = &sector[lightninsector[i]];
startwall = sectp->wallptr;
endwall = startwall + sectp->wallnum;
sectp->floorshade = (int8_t)lightninsectorshade[i]; sectp->floorshade = (int8_t)lightninsectorshade[i];
sectp->ceilingshade = (int8_t)lightninsectorshade[i]; sectp->ceilingshade = (int8_t)lightninsectorshade[i];
for (j = startwall; j < endwall; j++) for (auto& wal : wallsofsector(sectp))
wall[j].shade = (int8_t)lightninsectorshade[i]; wal.shade = (int8_t)lightninsectorshade[i];
} }
} }
} }
@ -671,12 +651,10 @@ void thunder(void)
for (i = 0; i < lightnincnt; i++) for (i = 0; i < lightnincnt; i++)
{ {
auto sectp = &sector[lightninsector[i]]; auto sectp = &sector[lightninsector[i]];
startwall = sectp->wallptr;
endwall = startwall + sectp->wallnum;
sectp->floorshade = lightninsectorshade[i] - shade; sectp->floorshade = lightninsectorshade[i] - shade;
sectp->ceilingshade = lightninsectorshade[i] - shade; sectp->ceilingshade = lightninsectorshade[i] - shade;
for (j = startwall; j < endwall; j++) for (auto& wal : wallsofsector(sectp))
wall[j].shade = lightninsectorshade[i] - shade; wal.shade = lightninsectorshade[i] - shade;
} }
} }
} }