mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-31 21:20:39 +00:00
- Duke/RR: cleaned up the rest of hitradius* as well
Using wallsofsector iterator plus defining local variables more locally.
This commit is contained in:
parent
63985ce6be
commit
5bb805663e
3 changed files with 42 additions and 43 deletions
|
@ -239,3 +239,14 @@ inline TArrayView<walltype> wallsofsector(int sec)
|
||||||
{
|
{
|
||||||
return wallsofsector(§or[sec]);
|
return wallsofsector(§or[sec]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// these are mainly meant as refactoring aids to mark function calls to work on.
|
||||||
|
inline int wallnum(walltype* wal)
|
||||||
|
{
|
||||||
|
return int(wal - wall);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int sectnum(sectortype* sect)
|
||||||
|
{
|
||||||
|
return int(sect - sector);
|
||||||
|
}
|
||||||
|
|
|
@ -339,18 +339,11 @@ bool ifsquished(DDukeActor* actor, int p)
|
||||||
|
|
||||||
void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4)
|
void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4)
|
||||||
{
|
{
|
||||||
walltype* wal;
|
|
||||||
int d, q, x1, y1;
|
|
||||||
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 };
|
static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC };
|
||||||
|
|
||||||
auto spri = actor->s;
|
auto spri = actor->s;
|
||||||
|
|
||||||
if(spri->picnum == RPG && spri->xrepeat < 11) goto SKIPWALLCHECK;
|
if(spri->picnum != SHRINKSPARK && !(spri->picnum == RPG && spri->xrepeat < 11))
|
||||||
|
|
||||||
if(spri->picnum != SHRINKSPARK)
|
|
||||||
{
|
{
|
||||||
BFSSearch search(numsectors, spri->sectnum);
|
BFSSearch search(numsectors, spri->sectnum);
|
||||||
|
|
||||||
|
@ -360,7 +353,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
|
||||||
if (((dasectp->ceilingz - spri->z) >> 8) < r)
|
if (((dasectp->ceilingz - spri->z) >> 8) < r)
|
||||||
{
|
{
|
||||||
auto wal = dasectp->firstWall();
|
auto wal = dasectp->firstWall();
|
||||||
d = abs(wal->x - spri->x) + abs(wal->y - spri->y);
|
int d = abs(wal->x - spri->x) + abs(wal->y - spri->y);
|
||||||
if (d < r)
|
if (d < r)
|
||||||
fi.checkhitceiling(dasect);
|
fi.checkhitceiling(dasect);
|
||||||
else
|
else
|
||||||
|
@ -372,31 +365,30 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startwall = dasectp->wallptr;
|
for (auto& wal : wallsofsector(dasectp))
|
||||||
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)
|
||||||
if ((abs(wal->x - spri->x) + abs(wal->y - spri->y)) < r)
|
|
||||||
{
|
{
|
||||||
nextsect = wal->nextsector;
|
int nextsect = wal.nextsector;
|
||||||
if (nextsect >= 0)
|
if (nextsect >= 0)
|
||||||
{
|
{
|
||||||
search.Add(nextsect);
|
search.Add(nextsect);
|
||||||
}
|
}
|
||||||
x1 = (((wal->x + wall[wal->point2].x) >> 1) + spri->x) >> 1;
|
int x1 = (((wal.x + wal.point2Wall()->x) >> 1) + spri->x) >> 1;
|
||||||
y1 = (((wal->y + wall[wal->point2].y) >> 1) + spri->y) >> 1;
|
int y1 = (((wal.y + wal.point2Wall()->y) >> 1) + spri->y) >> 1;
|
||||||
|
int sect;
|
||||||
updatesector(x1, y1, §);
|
updatesector(x1, y1, §);
|
||||||
if (sect >= 0 && cansee(x1, y1, spri->z, sect, spri->x, spri->y, spri->z, spri->sectnum))
|
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);
|
fi.checkhitwall(actor, wallnum(&wal), wal.x, wal.y, spri->z, spri->picnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SKIPWALLCHECK:
|
int q = -(16 << 8) + (krand() & ((32 << 8) - 1));
|
||||||
|
|
||||||
q = -(16 << 8) + (krand() & ((32 << 8) - 1));
|
|
||||||
|
|
||||||
auto Owner = actor->GetOwner();
|
auto Owner = actor->GetOwner();
|
||||||
for (x = 0; x < 7; x++)
|
for (int x = 0; x < 7; x++)
|
||||||
{
|
{
|
||||||
DukeStatIterator itj(statlist[x]);
|
DukeStatIterator itj(statlist[x]);
|
||||||
while (auto act2 = itj.Next())
|
while (auto act2 = itj.Next())
|
||||||
|
@ -437,7 +429,7 @@ SKIPWALLCHECK:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spri2->picnum == APLAYER) spri2->z -= gs.playerheight;
|
if (spri2->picnum == APLAYER) spri2->z -= gs.playerheight;
|
||||||
d = dist(actor, act2);
|
int d = dist(actor, act2);
|
||||||
if (spri2->picnum == APLAYER) spri2->z += gs.playerheight;
|
if (spri2->picnum == APLAYER) spri2->z += gs.playerheight;
|
||||||
|
|
||||||
if (d < r && cansee(spri2->x, spri2->y, spri2->z - (8 << 8), spri2->sectnum, spri->x, spri->y, spri->z - (12 << 8), spri->sectnum))
|
if (d < r && cansee(spri2->x, spri2->y, spri2->z - (8 << 8), spri2->sectnum, spri->x, spri->y, spri->z - (12 << 8), spri->sectnum))
|
||||||
|
@ -506,7 +498,7 @@ SKIPWALLCHECK:
|
||||||
{
|
{
|
||||||
if (spri2->picnum == APLAYER)
|
if (spri2->picnum == APLAYER)
|
||||||
{
|
{
|
||||||
p = spri2->yvel;
|
int p = spri2->yvel;
|
||||||
|
|
||||||
if (isWorldTour() && act2->picnum == FLAMETHROWERFLAME && Owner->s->picnum == APLAYER)
|
if (isWorldTour() && act2->picnum == FLAMETHROWERFLAME && Owner->s->picnum == APLAYER)
|
||||||
{
|
{
|
||||||
|
|
|
@ -217,11 +217,6 @@ void addweapon_r(struct player_struct* p, int weapon)
|
||||||
|
|
||||||
void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4)
|
void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4)
|
||||||
{
|
{
|
||||||
walltype* wal;
|
|
||||||
int d, q, x1, y1;
|
|
||||||
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 };
|
static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC };
|
||||||
|
|
||||||
auto spri = actor->s;
|
auto spri = actor->s;
|
||||||
|
@ -236,7 +231,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
|
||||||
if (((dasectp->ceilingz - spri->z) >> 8) < r)
|
if (((dasectp->ceilingz - spri->z) >> 8) < r)
|
||||||
{
|
{
|
||||||
auto wal = dasectp->firstWall();
|
auto wal = dasectp->firstWall();
|
||||||
d = abs(wal->x - spri->x) + abs(wal->y - spri->y);
|
int d = abs(wal->x - spri->x) + abs(wal->y - spri->y);
|
||||||
if (d < r)
|
if (d < r)
|
||||||
fi.checkhitceiling(dasect);
|
fi.checkhitceiling(dasect);
|
||||||
else
|
else
|
||||||
|
@ -247,30 +242,31 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
|
||||||
fi.checkhitceiling(dasect);
|
fi.checkhitceiling(dasect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startwall = dasectp->wallptr;
|
for (auto& wal : wallsofsector(dasectp))
|
||||||
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)
|
||||||
if ((abs(wal->x - spri->x) + abs(wal->y - spri->y)) < r)
|
|
||||||
{
|
{
|
||||||
nextsect = wal->nextsector;
|
int nextsect = wal.nextsector;
|
||||||
if (nextsect >= 0)
|
if (nextsect >= 0)
|
||||||
{
|
{
|
||||||
search.Add(nextsect);
|
search.Add(nextsect);
|
||||||
}
|
}
|
||||||
x1 = (((wal->x + wall[wal->point2].x) >> 1) + spri->x) >> 1;
|
int x1 = (((wal.x + wal.point2Wall()->x) >> 1) + spri->x) >> 1;
|
||||||
y1 = (((wal->y + wall[wal->point2].y) >> 1) + spri->y) >> 1;
|
int y1 = (((wal.y + wal.point2Wall()->y) >> 1) + spri->y) >> 1;
|
||||||
|
int sect;
|
||||||
updatesector(x1, y1, §);
|
updatesector(x1, y1, §);
|
||||||
if (sect >= 0 && cansee(x1, y1, spri->z, sect, spri->x, spri->y, spri->z, spri->sectnum))
|
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);
|
fi.checkhitwall(actor, wallnum(&wal), wal.x, wal.y, spri->z, spri->picnum);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
q = -(24 << 8) + (krand() & ((32 << 8) - 1));
|
int q = -(24 << 8) + (krand() & ((32 << 8) - 1));
|
||||||
|
|
||||||
auto Owner = actor->GetOwner();
|
auto Owner = actor->GetOwner();
|
||||||
for (x = 0; x < 7; x++)
|
for (int x = 0; x < 7; x++)
|
||||||
{
|
{
|
||||||
DukeStatIterator it1(statlist[x]);
|
DukeStatIterator it1(statlist[x]);
|
||||||
while (auto act2 = it1.Next())
|
while (auto act2 = it1.Next())
|
||||||
|
@ -300,7 +296,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spri2->picnum == APLAYER) spri2->z -= gs.playerheight;
|
if (spri2->picnum == APLAYER) spri2->z -= gs.playerheight;
|
||||||
d = dist(actor, act2);
|
int d = dist(actor, act2);
|
||||||
if (spri2->picnum == APLAYER) spri2->z += gs.playerheight;
|
if (spri2->picnum == APLAYER) spri2->z += gs.playerheight;
|
||||||
|
|
||||||
if (d < r && cansee(spri2->x, spri2->y, spri2->z - (8 << 8), spri2->sectnum, spri->x, spri->y, spri->z - (12 << 8), spri->sectnum))
|
if (d < r && cansee(spri2->x, spri2->y, spri2->z - (8 << 8), spri2->sectnum, spri->x, spri->y, spri->z - (12 << 8), spri->sectnum))
|
||||||
|
@ -353,7 +349,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
|
||||||
{
|
{
|
||||||
if (spri2->picnum == APLAYER)
|
if (spri2->picnum == APLAYER)
|
||||||
{
|
{
|
||||||
p = act2->PlayerIndex();
|
int p = act2->PlayerIndex();
|
||||||
if (ps[p].newOwner != nullptr)
|
if (ps[p].newOwner != nullptr)
|
||||||
{
|
{
|
||||||
clearcamera(&ps[p]);
|
clearcamera(&ps[p]);
|
||||||
|
|
Loading…
Reference in a new issue