- ifhitbyweapon cleanup.

Variables renamed and array accesses replaced with pointers in RR version.
This commit is contained in:
Christoph Oelckers 2020-10-24 10:45:30 +02:00
parent 28d0bc7477
commit 92c21e7259
2 changed files with 67 additions and 66 deletions

View file

@ -862,20 +862,20 @@ int ifhitsectors_d(int sectnum)
int ifhitbyweapon_d(int sn) int ifhitbyweapon_d(int sn)
{ {
short j, p; short j, p;
auto spr = &sprite[sn]; auto spri = &sprite[sn];
auto ht = &hittype[sn]; auto actor = &hittype[sn];
auto htowner = ht->owner < 0? nullptr : &sprite[ht->owner]; auto htowner = actor->owner < 0? nullptr : &sprite[actor->owner];
if (ht->extra >= 0) if (actor->extra >= 0)
{ {
if (spr->extra >= 0) if (spri->extra >= 0)
{ {
if (spr->picnum == APLAYER) if (spri->picnum == APLAYER)
{ {
if (ud.god && ht->picnum != SHRINKSPARK) return -1; if (ud.god && actor->picnum != SHRINKSPARK) return -1;
p = spr->yvel; p = spri->yvel;
j = ht->owner; j = actor->owner;
if (j >= 0 && if (j >= 0 &&
sprite[j].picnum == APLAYER && sprite[j].picnum == APLAYER &&
@ -883,13 +883,13 @@ int ifhitbyweapon_d(int sn)
ud.ffire == 0) ud.ffire == 0)
return -1; return -1;
spr->extra -= ht->extra; spri->extra -= actor->extra;
if (j >= 0) if (j >= 0)
{ {
if (spr->extra <= 0 && ht->picnum != FREEZEBLAST) if (spri->extra <= 0 && actor->picnum != FREEZEBLAST)
{ {
spr->extra = 0; spri->extra = 0;
ps[p].wackedbyactor = &hittype[j]; ps[p].wackedbyactor = &hittype[j];
@ -899,11 +899,11 @@ int ifhitbyweapon_d(int sn)
ps[p].frag_ps = sprite[j].yvel; ps[p].frag_ps = sprite[j].yvel;
} }
ht->owner = ps[p].i; actor->owner = ps[p].i;
} }
} }
switch(ht->picnum) switch(actor->picnum)
{ {
case RADIUSEXPLOSION: case RADIUSEXPLOSION:
case RPG: case RPG:
@ -913,63 +913,63 @@ int ifhitbyweapon_d(int sn)
case OOZFILTER: case OOZFILTER:
case EXPLODINGBARREL: case EXPLODINGBARREL:
ps[p].posxv += ps[p].posxv +=
ht->extra*(sintable[(ht->ang+512)&2047]) << 2; actor->extra*(sintable[(actor->ang+512)&2047]) << 2;
ps[p].posyv += ps[p].posyv +=
ht->extra*(sintable[ht->ang&2047]) << 2; actor->extra*(sintable[actor->ang&2047]) << 2;
break; break;
default: default:
ps[p].posxv += ps[p].posxv +=
ht->extra*(sintable[(ht->ang+512)&2047]) << 1; actor->extra*(sintable[(actor->ang+512)&2047]) << 1;
ps[p].posyv += ps[p].posyv +=
ht->extra*(sintable[ht->ang&2047]) << 1; actor->extra*(sintable[actor->ang&2047]) << 1;
break; break;
} }
} }
else else
{ {
if (ht->extra == 0) if (actor->extra == 0)
if (ht->picnum == SHRINKSPARK && spr->xrepeat < 24) if (actor->picnum == SHRINKSPARK && spri->xrepeat < 24)
return -1; return -1;
if (isWorldTour() && ht->picnum == FIREFLY && spr->xrepeat < 48) if (isWorldTour() && actor->picnum == FIREFLY && spri->xrepeat < 48)
{ {
if (ht->picnum != RADIUSEXPLOSION && ht->picnum != RPG) if (actor->picnum != RADIUSEXPLOSION && actor->picnum != RPG)
return -1; return -1;
} }
spr->extra -= ht->extra; spri->extra -= actor->extra;
if (spr->picnum != RECON && spr->owner >= 0 && sprite[spr->owner].statnum < MAXSTATUS) if (spri->picnum != RECON && spri->owner >= 0 && sprite[spri->owner].statnum < MAXSTATUS)
spr->owner = ht->owner; spri->owner = actor->owner;
} }
ht->extra = -1; actor->extra = -1;
return ht->picnum; return actor->picnum;
} }
} }
if (ud.multimode < 2 || !isWorldTour() if (ud.multimode < 2 || !isWorldTour()
|| ht->picnum != FLAMETHROWERFLAME || actor->picnum != FLAMETHROWERFLAME
|| ht->extra >= 0 || actor->extra >= 0
|| spr->extra > 0 || spri->extra > 0
|| spr->picnum != APLAYER || spri->picnum != APLAYER
|| ps[spr->yvel].numloogs > 0 || ps[spri->yvel].numloogs > 0
|| ht->owner < 0) || actor->owner < 0)
{ {
ht->extra = -1; actor->extra = -1;
return -1; return -1;
} }
else else
{ {
p = spr->yvel; p = spri->yvel;
spr->extra = 0; spri->extra = 0;
ps[p].wackedbyactor = ht->GetHitOwner(); ps[p].wackedbyactor = actor->GetHitOwner();
if (htowner->picnum == APLAYER && p != ht->owner) if (htowner->picnum == APLAYER && p != actor->owner)
ps[p].frag_ps = (short)ht->owner; ps[p].frag_ps = (short)actor->owner;
ht->owner = ps[p].i; actor->owner = ps[p].i;
ht->extra = -1; actor->extra = -1;
return FLAMETHROWERFLAME; return FLAMETHROWERFLAME;
} }

View file

@ -691,20 +691,21 @@ int ifhitsectors_r(int sectnum)
int ifhitbyweapon_r(int sn) int ifhitbyweapon_r(int sn)
{ {
short j, p; short j, p;
spritetype* npc; auto actor = &hittype[sn];
auto spri = &actor->s;
if (hittype[sn].extra >= 0) if (actor->extra >= 0)
{ {
if (sprite[sn].extra >= 0) if (spri->extra >= 0)
{ {
npc = &sprite[sn]; spri = &sprite[sn];
if (npc->picnum == APLAYER) if (spri->picnum == APLAYER)
{ {
if (ud.god) return -1; if (ud.god) return -1;
p = npc->yvel; p = spri->yvel;
j = hittype[sn].owner; j = actor->owner;
if (j >= 0 && if (j >= 0 &&
sprite[j].picnum == APLAYER && sprite[j].picnum == APLAYER &&
@ -712,27 +713,27 @@ int ifhitbyweapon_r(int sn)
ud.ffire == 0) ud.ffire == 0)
return -1; return -1;
npc->extra -= hittype[sn].extra; spri->extra -= actor->extra;
if (j >= 0) if (j >= 0)
{ {
if (npc->extra <= 0 && hittype[sn].picnum != FREEZEBLAST) if (spri->extra <= 0 && actor->picnum != FREEZEBLAST)
{ {
npc->extra = 0; spri->extra = 0;
ps[p].wackedbyactor = &hittype[j]; ps[p].wackedbyactor = &hittype[j];
if (sprite[hittype[sn].owner].picnum == APLAYER && p != sprite[hittype[sn].owner].yvel) if (sprite[actor->owner].picnum == APLAYER && p != sprite[actor->owner].yvel)
{ {
// yvel contains player ID // yvel contains player ID
ps[p].frag_ps = sprite[j].yvel; ps[p].frag_ps = sprite[j].yvel;
} }
hittype[sn].owner = ps[p].i; actor->owner = ps[p].i;
} }
} }
int pn = hittype[sn].picnum; int pn = actor->picnum;
if (pn == RPG2 && !isRRRA()) pn = 0; // avoid messing around with gotos. if (pn == RPG2 && !isRRRA()) pn = 0; // avoid messing around with gotos.
switch (pn) switch (pn)
{ {
@ -746,35 +747,35 @@ int ifhitbyweapon_r(int sn)
case TRIPBOMBSPRITE: case TRIPBOMBSPRITE:
case RPG2: case RPG2:
ps[p].posxv += ps[p].posxv +=
hittype[sn].extra * (sintable[(hittype[sn].ang + 512) & 2047]) << 2; actor->extra * (sintable[(actor->ang + 512) & 2047]) << 2;
ps[p].posyv += ps[p].posyv +=
hittype[sn].extra * (sintable[hittype[sn].ang & 2047]) << 2; actor->extra * (sintable[actor->ang & 2047]) << 2;
break; break;
default: default:
ps[p].posxv += ps[p].posxv +=
hittype[sn].extra * (sintable[(hittype[sn].ang + 512) & 2047]) << 1; actor->extra * (sintable[(actor->ang + 512) & 2047]) << 1;
ps[p].posyv += ps[p].posyv +=
hittype[sn].extra * (sintable[hittype[sn].ang & 2047]) << 1; actor->extra * (sintable[actor->ang & 2047]) << 1;
break; break;
} }
} }
else else
{ {
if (hittype[sn].extra == 0) if (actor->extra == 0)
if (npc->xrepeat < 24) if (spri->xrepeat < 24)
return -1; return -1;
npc->extra -= hittype[sn].extra; spri->extra -= actor->extra;
if (npc->picnum != RECON && npc->owner >= 0 && sprite[npc->owner].statnum < MAXSTATUS) if (spri->picnum != RECON && spri->owner >= 0 && sprite[spri->owner].statnum < MAXSTATUS)
npc->owner = hittype[sn].owner; spri->owner = actor->owner;
} }
hittype[sn].extra = -1; actor->extra = -1;
return hittype[sn].picnum; return actor->picnum;
} }
} }
hittype[sn].extra = -1; actor->extra = -1;
return -1; return -1;
} }