- SW: some inline cleanup.

This commit is contained in:
Christoph Oelckers 2021-12-23 23:22:29 +01:00
parent 810ab29898
commit 8d5bffc280
7 changed files with 32 additions and 42 deletions

View file

@ -232,7 +232,7 @@ bool CanSeePlayer(DSWActor* actor)
// if actor can still see the player
int look_height = GetSpriteZOfTop(sp);
if (u->targetActor && FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y, ActorUpper(u->targetActor), u->targetActor->spr.sector()))
if (u->targetActor && FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y, ActorUpperZ(u->targetActor), u->targetActor->spr.sector()))
return true;
else
return false;
@ -376,7 +376,7 @@ int DoActorPickClosePlayer(DSWActor* actor)
DISTANCE(sp->pos.X, sp->pos.Y, pp->pos.X, pp->pos.Y, dist, a, b, c);
auto plActor = pp->actor;
if (dist < near_dist && FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), plActor->spr.pos.X, plActor->spr.pos.Y, ActorUpper(plActor), plActor->spr.sector()))
if (dist < near_dist && FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), plActor->spr.pos.X, plActor->spr.pos.Y, ActorUpperZ(plActor), plActor->spr.sector()))
{
near_dist = dist;
u->targetActor = pp->actor;
@ -402,7 +402,7 @@ TARGETACTOR:
DISTANCE(sp->pos.X, sp->pos.Y, itActor->spr.pos.X, itActor->spr.pos.Y, dist, a, b, c);
if (dist < near_dist && FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), itActor->spr.pos.X, itActor->spr.pos.Y, ActorUpper(itActor), itActor->spr.sector()))
if (dist < near_dist && FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), itActor->spr.pos.X, itActor->spr.pos.Y, ActorUpperZ(itActor), itActor->spr.sector()))
{
near_dist = dist;
u->targetActor = itActor;
@ -1005,7 +1005,7 @@ int FindTrackToPlayer(DSWActor* actor)
BIT(TT_SCAN)
};
zdiff = ActorUpper(u->targetActor) - (sp->pos.Z - GetSpriteSizeZ(sp) + Z(8));
zdiff = ActorUpperZ(u->targetActor) - (sp->pos.Z - GetSpriteSizeZ(sp) + Z(8));
if (labs(zdiff) <= Z(20))
{

View file

@ -927,7 +927,7 @@ void DoPickCloseBunny(DSWActor* actor)
if (dist > near_dist) continue;
ICanSee = FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), tsp->pos.X, tsp->pos.Y, GetSpriteUpperZ(tsp), tsp->sector());
ICanSee = FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), tsp->pos.X, tsp->pos.Y, ActorUpperZ(itActor), tsp->sector());
if (ICanSee && dist < near_dist && tu->ID == BUNNY_RUN_R0)
{

View file

@ -289,16 +289,6 @@ inline int GetSpriteZOfMiddle(const spritetypebase* sp)
return (GetSpriteZOfTop(sp) + GetSpriteZOfBottom(sp)) >> 1;
}
inline int GetSpriteUpperZ(const spritetypebase* sp)
{
return (GetSpriteZOfTop(sp) + (GetSpriteSizeZ(sp) >> 2));
}
int GetSpriteLowerZ(const spritetypebase* sp)
{
return (GetSpriteZOfBottom(sp) - (GetSpriteSizeZ(sp) >> 2));
}
constexpr int Z(int value)
{
return value << 8;
@ -2129,14 +2119,14 @@ END_SW_NS
BEGIN_SW_NS
inline int ActorUpper(DSWActor* actor)
inline int ActorUpperZ(DSWActor* actor)
{
return GetSpriteUpperZ(&actor->s());
return (GetSpriteZOfTop(&actor->spr) + (GetSpriteSizeZ(&actor->spr) >> 2));
}
inline int ActorLower(DSWActor* actor)
inline int ActorLowerZ(DSWActor* actor)
{
return GetSpriteLowerZ(&actor->s());
return (GetSpriteZOfBottom(&actor->spr) - (GetSpriteSizeZ(&actor->spr) >> 2));
}
inline int ActorMid(DSWActor* actor)

View file

@ -357,7 +357,6 @@ int DoHornetMatchPlayerZ(DSWActor* actor)
// actor does a sine wave about u->sz - this is the z mid point
//zdiff = (GetSpriteLowerZ(tsp) - Z(8)) - u->sz;
zdiff = (GetSpriteZOfMiddle(tsp)) - u->sz;
// check z diff of the player and the sprite

View file

@ -3835,7 +3835,7 @@ int ActorCoughItem(DSWActor* actor)
np->extra = 0;
np->pos.X = sp->pos.X;
np->pos.Y = sp->pos.Y;
np->pos.Z = GetSpriteLowerZ(sp)+Z(10);
np->pos.Z = ActorLowerZ(actor) + Z(10);
np->ang = sp->ang;
// vel
@ -6074,7 +6074,8 @@ void AdjustActiveRange(PLAYERp pp, DSWActor* actor, int dist)
{
USERp u = actor->u();
SPRITEp sp = &actor->s();
SPRITEp psp = &pp->Actor()->s();
auto plActor = pp->actor;
SPRITEp psp = &plActor->s();
int look_height;
@ -6099,7 +6100,7 @@ void AdjustActiveRange(PLAYERp pp, DSWActor* actor, int dist)
// if actor can still see the player
look_height = GetSpriteZOfTop(sp);
if (FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), psp->pos.X, psp->pos.Y, GetSpriteUpperZ(psp), psp->sector()))
if (FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), psp->pos.X, psp->pos.Y, ActorUpperZ(plActor), psp->sector()))
{
// Player is visible
// adjust update range of this sprite

View file

@ -2871,7 +2871,7 @@ void DoAutoTurretObject(SECTOR_OBJECTp sop)
if (shootp->statnum == STAT_SO_SHOOT_POINT)
{
if (!FAFcansee(shootp->pos.X, shootp->pos.Y, shootp->pos.Z-Z(4), shootp->sector(),
u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y, ActorUpper(u->targetActor), u->targetActor->spr.sector()))
u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y, ActorUpperZ(u->targetActor), u->targetActor->spr.sector()))
{
return;
}

View file

@ -7173,7 +7173,7 @@ int DoDamageTest(DSWActor* actor)
// For speed's sake, try limiting check only to radius weapons!
if (wu->Radius > 200)
{
if (!FAFcansee(sp->pos.X,sp->pos.Y, GetSpriteUpperZ(sp), sp->sector(),wp->pos.X,wp->pos.Y,wp->pos.Z,wp->sector()))
if (!FAFcansee(sp->pos.X,sp->pos.Y, ActorUpperZ(actor), sp->sector(),wp->pos.X,wp->pos.Y,wp->pos.Z,wp->sector()))
continue;
}
@ -7406,8 +7406,8 @@ int DoExpDamageTest(DSWActor* actor)
// Second parameter MUST have blocking bits set or cansee won't work
// added second check for FAF water - hitscans were hitting ceiling
if (!FAFcansee(wp->pos.X, wp->pos.Y, wp->pos.Z, wp->sector(), sp->pos.X, sp->pos.Y, GetSpriteUpperZ(sp), sp->sector()) &&
!FAFcansee(wp->pos.X, wp->pos.Y, wp->pos.Z, wp->sector(), sp->pos.X, sp->pos.Y, GetSpriteLowerZ(sp), sp->sector()))
if (!FAFcansee(wp->pos.X, wp->pos.Y, wp->pos.Z, wp->sector(), sp->pos.X, sp->pos.Y, ActorUpperZ(actor), sp->sector()) &&
!FAFcansee(wp->pos.X, wp->pos.Y, wp->pos.Z, wp->sector(), sp->pos.X, sp->pos.Y, ActorLowerZ(actor), sp->sector()))
continue;
DoDamage(itActor, actor);
@ -8870,7 +8870,7 @@ int DoMineRangeTest(DSWActor* actor, int range)
if (dist > range)
continue;
if (!FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteUpperZ(sp),sp->sector(),wp->pos.X,wp->pos.Y,wp->pos.Z,wp->sector()))
if (!FAFcansee(sp->pos.X,sp->pos.Y,ActorUpperZ(actor),sp->sector(),wp->pos.X,wp->pos.Y,wp->pos.Z,wp->sector()))
continue;
return true;
@ -12028,7 +12028,7 @@ int InitLavaThrow(DSWActor* actor)
dist = Distance(wp->pos.X, wp->pos.Y, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
wu->zchange = wp->zvel = (wp->xvel * (ActorUpper(u->targetActor) - wp->pos.Z)) / dist;
wu->zchange = wp->zvel = (wp->xvel * (ActorUpperZ(u->targetActor) - wp->pos.Z)) / dist;
return 0;
}
@ -12338,7 +12338,7 @@ int InitEnemyNapalm(DSWActor* actor)
dist = Distance(wp->pos.X, wp->pos.Y, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
wp->zvel = (wp->xvel * (ActorUpper(u->targetActor) - wp->pos.Z)) / dist;
wp->zvel = (wp->xvel * (ActorUpperZ(u->targetActor) - wp->pos.Z)) / dist;
wu->xchange = MOVEx(wp->xvel, wp->ang);
wu->ychange = MOVEy(wp->xvel, wp->ang);
@ -12440,7 +12440,7 @@ int InitEnemyMirv(DSWActor* actor)
dist = Distance(wp->pos.X, wp->pos.Y, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
wu->zchange = wp->zvel = (wp->xvel * (ActorUpper(u->targetActor) - wp->pos.Z)) / dist;
wu->zchange = wp->zvel = (wp->xvel * (ActorUpperZ(u->targetActor) - wp->pos.Z)) / dist;
return 0;
}
@ -12899,7 +12899,7 @@ int InitSumoNapalm(DSWActor* actor)
dist = Distance(wp->pos.X, wp->pos.Y, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
wp->zvel = (wp->xvel * (ActorUpper(u->targetActor) - wp->pos.Z)) / dist;
wp->zvel = (wp->xvel * (ActorUpperZ(u->targetActor) - wp->pos.Z)) / dist;
wu->xchange = MOVEx(wp->xvel, wp->ang);
wu->ychange = MOVEy(wp->xvel, wp->ang);
@ -13199,7 +13199,7 @@ DSWActor* AimHitscanToTarget(DSWActor* actor, int *z, short *ang, int z_ratio)
if (dist != 0)
{
zh = GetSpriteUpperZ(hp);
zh = ActorUpperZ(hitActor);
xvect = bcos(*ang);
yvect = bsin(*ang);
@ -14950,7 +14950,7 @@ int InitSerpSpell(DSWActor* actor)
// find the distance to the target (player)
dist = Distance(np->pos.X, np->pos.Y, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
np->zvel = (np->xvel * (ActorUpper(u->targetActor) - np->pos.Z)) / dist;
np->zvel = (np->xvel * (ActorUpperZ(u->targetActor) - np->pos.Z)) / dist;
np->ang = NORM_ANGLE(np->ang + delta_ang[i]);
@ -15062,7 +15062,7 @@ int InitSerpMonstSpell(DSWActor* actor)
// find the distance to the target (player)
dist = Distance(np->pos.X, np->pos.Y, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
np->zvel = (np->xvel * (ActorUpper(u->targetActor) - np->pos.Z)) / dist;
np->zvel = (np->xvel * (ActorUpperZ(u->targetActor) - np->pos.Z)) / dist;
np->ang = NORM_ANGLE(np->ang + delta_ang[i]);
@ -15148,7 +15148,7 @@ int InitEnemyRocket(DSWActor* actor)
dist = Distance(wp->pos.X, wp->pos.Y, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
wu->zchange = wp->zvel = (wp->xvel * (ActorUpper(u->targetActor) - wp->pos.Z)) / dist;
wu->zchange = wp->zvel = (wp->xvel * (ActorUpperZ(u->targetActor) - wp->pos.Z)) / dist;
return 0;
}
@ -15237,7 +15237,7 @@ int InitEnemyRail(DSWActor* actor)
dist = Distance(wp->pos.X, wp->pos.Y, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
wu->zchange = wp->zvel = (wp->xvel * (ActorUpper(u->targetActor) - wp->pos.Z)) / dist;
wu->zchange = wp->zvel = (wp->xvel * (ActorUpperZ(u->targetActor) - wp->pos.Z)) / dist;
return 0;
}
@ -15323,7 +15323,7 @@ int InitZillaRocket(DSWActor* actor)
dist = Distance(wp->pos.X, wp->pos.Y, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
wu->zchange = wp->zvel = (wp->xvel * (ActorUpper(u->targetActor) - wp->pos.Z)) / dist;
wu->zchange = wp->zvel = (wp->xvel * (ActorUpperZ(u->targetActor) - wp->pos.Z)) / dist;
}
return 0;
@ -15368,7 +15368,7 @@ int InitEnemyStar(DSWActor* actor)
dist = Distance(wp->pos.X, wp->pos.Y, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
wu->zchange = wp->zvel = (wp->xvel * (ActorUpper(u->targetActor) - wp->pos.Z)) / dist;
wu->zchange = wp->zvel = (wp->xvel * (ActorUpperZ(u->targetActor) - wp->pos.Z)) / dist;
PlaySound(DIGI_STAR, actor, v3df_none);
return 0;
@ -15418,7 +15418,7 @@ int InitEnemyCrossbow(DSWActor* actor)
dist = Distance(wp->pos.X, wp->pos.Y, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
wu->zchange = wp->zvel = (wp->xvel * (ActorUpper(u->targetActor) - wp->pos.Z)) / dist;
wu->zchange = wp->zvel = (wp->xvel * (ActorUpperZ(u->targetActor) - wp->pos.Z)) / dist;
PlaySound(DIGI_STAR, actor, v3df_none);
@ -15462,7 +15462,7 @@ int InitSkelSpell(DSWActor* actor)
dist = Distance(nx, ny, u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y);
if (dist != 0)
wp->zvel = (wp->xvel * (ActorUpper(u->targetActor) - nz)) / dist;
wp->zvel = (wp->xvel * (ActorUpperZ(u->targetActor) - nz)) / dist;
wu->xchange = MOVEx(wp->xvel, wp->ang);
wu->ychange = MOVEy(wp->xvel, wp->ang);
@ -15523,7 +15523,7 @@ int InitCoolgFire(DSWActor* actor)
if (dist != 0)
// (velocity * difference between the target and the throwing star) /
// distance
wp->zvel = (wp->xvel * (ActorUpper(u->targetActor) - nz)) / dist;
wp->zvel = (wp->xvel * (ActorUpperZ(u->targetActor) - nz)) / dist;
wu->xchange = MOVEx(wp->xvel, wp->ang);
wu->ychange = MOVEy(wp->xvel, wp->ang);