- made the same changes to hitradius_r

Also had to do some reformatting to get rid of the goto in there.
This commit is contained in:
Christoph Oelckers 2021-11-16 00:23:18 +01:00
parent 821f341e03
commit 68d653efe9

View file

@ -218,65 +218,53 @@ void addweapon_r(struct player_struct* p, int weapon)
void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4)
{
walltype* wal;
sectortype* dasectp;
int d, q, x1, y1;
int sectcnt, sectend, dasect, startwall, endwall, nextsect;
int startwall, endwall, nextsect;
int p, x;
int sect;
static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC };
int tempsect[128]; // originally hijacked a global buffer which is bad. Q: How many do we really need? RedNukem says 64.
auto spri = actor->s;
if (spri->xrepeat < 11)
if (spri->xrepeat >= 11 || !(spri->picnum == RPG || ((isRRRA()) && spri->picnum == RPG2)))
{
if (spri->picnum == RPG || ((isRRRA()) && spri->picnum == RPG2)) goto SKIPWALLCHECK;
}
BFSSearch search(numsectors, spri->sectnum);
tempsect[0] = spri->sectnum;
dasect = spri->sectnum;
dasectp = spri->sector();
sectcnt = 0; sectend = 1;
do
{
dasect = tempsect[sectcnt++];
dasectp = &sector[dasect];
if (((dasectp->ceilingz - spri->z) >> 8) < r)
for (unsigned dasect; (dasect = search.GetNext()) != BFSSearch::EOL;)
{
d = abs(wall[dasectp->wallptr].x - spri->x) + abs(wall[dasectp->wallptr].y - spri->y);
if (d < r)
fi.checkhitceiling(dasect);
else
auto dasectp = &sector[dasect];
if (((dasectp->ceilingz - spri->z) >> 8) < r)
{
// ouch...
d = abs(wall[wall[wall[dasectp->wallptr].point2].point2].x - spri->x) + abs(wall[wall[wall[dasectp->wallptr].point2].point2].y - spri->y);
d = abs(wall[dasectp->wallptr].x - spri->x) + abs(wall[dasectp->wallptr].y - spri->y);
if (d < r)
fi.checkhitceiling(dasect);
}
}
startwall = dasectp->wallptr;
endwall = startwall + dasectp->wallnum;
for (x = startwall, wal = &wall[startwall]; x < endwall; x++, wal++)
if ((abs(wal->x - spri->x) + abs(wal->y - spri->y)) < r)
{
nextsect = wal->nextsector;
if (nextsect >= 0)
else
{
for (dasect = sectend - 1; dasect >= 0; dasect--)
if (tempsect[dasect] == nextsect) break;
if (dasect < 0) tempsect[sectend++] = nextsect;
// ouch...
d = abs(wall[wall[wall[dasectp->wallptr].point2].point2].x - spri->x) + abs(wall[wall[wall[dasectp->wallptr].point2].point2].y - spri->y);
if (d < r)
fi.checkhitceiling(dasect);
}
x1 = (((wal->x + wall[wal->point2].x) >> 1) + spri->x) >> 1;
y1 = (((wal->y + wall[wal->point2].y) >> 1) + spri->y) >> 1;
updatesector(x1, y1, &sect);
if (sect >= 0 && cansee(x1, y1, spri->z, sect, spri->x, spri->y, spri->z, spri->sectnum))
fi.checkhitwall(actor, x, wal->x, wal->y, spri->z, spri->picnum);
}
} while (sectcnt < sectend && sectcnt < (int)countof(tempsect));
SKIPWALLCHECK:
startwall = dasectp->wallptr;
endwall = startwall + dasectp->wallnum;
for (x = startwall, wal = &wall[startwall]; x < endwall; x++, wal++)
if ((abs(wal->x - spri->x) + abs(wal->y - spri->y)) < r)
{
nextsect = wal->nextsector;
if (nextsect >= 0)
{
search.Add(nextsect);
}
x1 = (((wal->x + wall[wal->point2].x) >> 1) + spri->x) >> 1;
y1 = (((wal->y + wall[wal->point2].y) >> 1) + spri->y) >> 1;
updatesector(x1, y1, &sect);
if (sect >= 0 && cansee(x1, y1, spri->z, sect, spri->x, spri->y, spri->z, spri->sectnum))
fi.checkhitwall(actor, x, wal->x, wal->y, spri->z, spri->picnum);
}
}
}
q = -(24 << 8) + (krand() & ((32 << 8) - 1));