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

View file

@ -691,20 +691,21 @@ int ifhitsectors_r(int sectnum)
int ifhitbyweapon_r(int sn)
{
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;
p = npc->yvel;
j = hittype[sn].owner;
p = spri->yvel;
j = actor->owner;
if (j >= 0 &&
sprite[j].picnum == APLAYER &&
@ -712,27 +713,27 @@ int ifhitbyweapon_r(int sn)
ud.ffire == 0)
return -1;
npc->extra -= hittype[sn].extra;
spri->extra -= actor->extra;
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];
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
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.
switch (pn)
{
@ -746,35 +747,35 @@ int ifhitbyweapon_r(int sn)
case TRIPBOMBSPRITE:
case RPG2:
ps[p].posxv +=
hittype[sn].extra * (sintable[(hittype[sn].ang + 512) & 2047]) << 2;
actor->extra * (sintable[(actor->ang + 512) & 2047]) << 2;
ps[p].posyv +=
hittype[sn].extra * (sintable[hittype[sn].ang & 2047]) << 2;
actor->extra * (sintable[actor->ang & 2047]) << 2;
break;
default:
ps[p].posxv +=
hittype[sn].extra * (sintable[(hittype[sn].ang + 512) & 2047]) << 1;
actor->extra * (sintable[(actor->ang + 512) & 2047]) << 1;
ps[p].posyv +=
hittype[sn].extra * (sintable[hittype[sn].ang & 2047]) << 1;
actor->extra * (sintable[actor->ang & 2047]) << 1;
break;
}
}
else
{
if (hittype[sn].extra == 0)
if (npc->xrepeat < 24)
if (actor->extra == 0)
if (spri->xrepeat < 24)
return -1;
npc->extra -= hittype[sn].extra;
if (npc->picnum != RECON && npc->owner >= 0 && sprite[npc->owner].statnum < MAXSTATUS)
npc->owner = hittype[sn].owner;
spri->extra -= actor->extra;
if (spri->picnum != RECON && spri->owner >= 0 && sprite[spri->owner].statnum < MAXSTATUS)
spri->owner = actor->owner;
}
hittype[sn].extra = -1;
return hittype[sn].picnum;
actor->extra = -1;
return actor->picnum;
}
}
hittype[sn].extra = -1;
actor->extra = -1;
return -1;
}