Revert "- added two FAFcansee variants that take shorter parameter lists for clearer code."

This reverts commit 29da39dda0.

Something in here was wrong, so back to the start with it.
The positive effect was too small anyway.
This commit is contained in:
Christoph Oelckers 2022-01-02 17:35:12 +01:00
parent 7205319853
commit e302c45a0b
10 changed files with 38 additions and 54 deletions

View file

@ -219,7 +219,7 @@ bool CanSeePlayer(DSWActor* actor)
// if actor can still see the player
int look_height = ActorZOfTop(actor);
if (actor->user.targetActor && FAFcansee(actor, look_height, actor->user.targetActor, ActorUpperZ(actor->user.targetActor)))
if (actor->user.targetActor && FAFcansee(actor->spr.pos.X, actor->spr.pos.Y, look_height, actor->sector(), actor->user.targetActor->spr.pos.X, actor->user.targetActor->spr.pos.Y, ActorUpperZ(actor->user.targetActor), actor->user.targetActor->sector()))
return true;
else
return false;
@ -353,7 +353,7 @@ int DoActorPickClosePlayer(DSWActor* actor)
DISTANCE(actor->spr.pos.X, actor->spr.pos.Y, pp->pos.X, pp->pos.Y, dist, a, b, c);
DSWActor* plActor = pp->actor;
if (dist < near_dist && FAFcansee(actor, look_height, plActor, ActorUpperZ(plActor)))
if (dist < near_dist && FAFcansee(actor->spr.pos.X, actor->spr.pos.Y, look_height, actor->sector(), plActor->spr.pos.X, plActor->spr.pos.Y, ActorUpperZ(plActor), plActor->sector()))
{
near_dist = dist;
actor->user.targetActor = pp->actor;
@ -379,7 +379,7 @@ TARGETACTOR:
DISTANCE(actor->spr.pos.X, actor->spr.pos.Y, itActor->spr.pos.X, itActor->spr.pos.Y, dist, a, b, c);
if (dist < near_dist && FAFcansee(actor, look_height, itActor, ActorUpperZ(itActor)))
if (dist < near_dist && FAFcansee(actor->spr.pos.X, actor->spr.pos.Y, look_height, actor->sector(), itActor->spr.pos.X, itActor->spr.pos.Y, ActorUpperZ(itActor), itActor->sector()))
{
near_dist = dist;
actor->user.targetActor = itActor;

View file

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

View file

@ -1698,8 +1698,6 @@ void FAFhitscan(int32_t x, int32_t y, int32_t z, sectortype* sect,
int32_t xvect, int32_t yvect, int32_t zvect,
HitInfo& hit, int32_t clipmask);
bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, sectortype* sects, int32_t xe, int32_t ye, int32_t ze, sectortype* secte);
void FAFgetzrange(vec3_t pos, sectortype* sect,
@ -2101,21 +2099,6 @@ inline void PlaySound(int num, DSWActor* actor, int flags, int channel = 8, ECha
_PlaySound(num, actor, nullptr, nullptr, flags, channel, sndflags);
}
inline bool FAFcansee(DSWActor* source, DSWActor* dest)
{
return FAFcansee(source->spr.pos.X, source->spr.pos.Y, source->spr.pos.Z, source->sector(), dest->spr.pos.X, dest->spr.pos.Y, dest->spr.pos.Z, dest->sector());
}
inline bool FAFcansee(DSWActor* source, int srcz, DSWActor* dest, int destz)
{
return FAFcansee(source->spr.pos.X, source->spr.pos.Y, srcz, source->sector(), dest->spr.pos.X, dest->spr.pos.Y, destz, dest->sector());
}
inline bool FAFcanseeOfs(DSWActor* source, int srcz, DSWActor* dest, int destz)
{
return FAFcansee(source->spr.pos.X, source->spr.pos.Y, source->spr.pos.Z + srcz, source->sector(), dest->spr.pos.X, dest->spr.pos.Y, dest->spr.pos.Z + destz, dest->sector());
}
struct ANIM
{
int animtype, animindex;

View file

@ -1436,7 +1436,7 @@ int PlayerInitFlashBomb(PLAYER* pp)
if (!(actor->spr.cstat & CSTAT_SPRITE_BLOCK))
continue;
if (!FAFcanseeOfs(itActor, 0, actor, - ActorSizeZ(actor)))
if (!FAFcansee(itActor->spr.pos.X, itActor->spr.pos.Y, itActor->spr.pos.Z, itActor->sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - ActorSizeZ(actor), actor->sector()))
continue;
damage = GetDamage(itActor, pp->actor, DMG_FLASHBOMB);
@ -1495,7 +1495,7 @@ int InitFlashBomb(DSWActor* actor)
if (!(actor->spr.cstat & CSTAT_SPRITE_BLOCK))
continue;
if (!FAFcanseeOfs(itActor, 0, actor, -ActorSizeZ(actor)))
if (!FAFcansee(itActor->spr.pos.X, itActor->spr.pos.Y, itActor->spr.pos.Z, itActor->sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - ActorSizeZ(actor), actor->sector()))
continue;
damage = GetDamage(itActor, actor, DMG_FLASHBOMB);
@ -1897,7 +1897,7 @@ DSWActor* DoFlagRangeTest(DSWActor* actor, int range)
if (!(itActor->spr.extra & SPRX_PLAYER_OR_ENEMY))
continue;
if (!FAFcansee(itActor, actor))
if (!FAFcansee(itActor->spr.pos.X, itActor->spr.pos.Y, itActor->spr.pos.Z, itActor->sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->sector()))
continue;
dist = FindDistance3D(actor->spr.pos - itActor->spr.pos);

View file

@ -146,7 +146,7 @@ int DoToiletGirl(DSWActor* actor)
bool ICanSee = false;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,ActorZOfMiddle(actor->user.targetActor),actor->user.targetActor->sector());
if (actor->user.FlagOwner != 1)
{
@ -199,7 +199,7 @@ int NullToiletGirl(DSWActor* actor)
bool ICanSee = false;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,actor->user.targetActor->spr.pos.Z,actor->user.targetActor->sector());
if (!(actor->user.Flags & SPR_CLIMBING))
KeepActorOnFloor(actor);
@ -366,7 +366,7 @@ int DoWashGirl(DSWActor* actor)
bool ICanSee = false;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,ActorZOfMiddle(actor->user.targetActor),actor->user.targetActor->sector());
if (RandomRange(1000) > 980 && actor->user.ShellNum <= 0)
{
@ -428,7 +428,7 @@ int NullWashGirl(DSWActor* actor)
bool ICanSee = false;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,actor->user.targetActor->spr.pos.Z,actor->user.targetActor->sector());
if (!(actor->user.Flags & SPR_CLIMBING))
KeepActorOnFloor(actor);
@ -1154,7 +1154,7 @@ int DoCarGirl(DSWActor* actor)
bool ICanSee = false;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,ActorZOfMiddle(actor->user.targetActor),actor->user.targetActor->sector());
if (actor->user.FlagOwner == 1)
{
@ -1198,7 +1198,7 @@ int NullCarGirl(DSWActor* actor)
bool ICanSee = false;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,actor->user.targetActor->spr.pos.Z,actor->user.targetActor->sector());
if (!(actor->user.Flags & SPR_CLIMBING))
KeepActorOnFloor(actor);
@ -1354,7 +1354,7 @@ int DoMechanicGirl(DSWActor* actor)
bool ICanSee = false;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,ActorZOfMiddle(actor->user.targetActor),actor->user.targetActor->sector());
if (actor->user.FlagOwner == 1)
{
@ -1398,7 +1398,7 @@ int NullMechanicGirl(DSWActor* actor)
bool ICanSee = false;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,actor->user.targetActor->spr.pos.Z,actor->user.targetActor->sector());
if (!(actor->user.Flags & SPR_CLIMBING))
KeepActorOnFloor(actor);
@ -1555,7 +1555,7 @@ int DoSailorGirl(DSWActor* actor)
bool ICanSee = false;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,ActorZOfMiddle(actor->user.targetActor),actor->user.targetActor->sector());
if (actor->user.FlagOwner == 1)
{
@ -1604,7 +1604,7 @@ int NullSailorGirl(DSWActor* actor)
static short alreadythrew = 0;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,actor->user.targetActor->spr.pos.Z,actor->user.targetActor->sector());
if (!(actor->user.Flags & SPR_CLIMBING))
KeepActorOnFloor(actor);
@ -1748,7 +1748,7 @@ int DoPruneGirl(DSWActor* actor)
bool ICanSee = false;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,ActorZOfMiddle(actor->user.targetActor),actor->user.targetActor->sector());
if (actor->user.FlagOwner == 1)
{
@ -1808,7 +1808,7 @@ int NullPruneGirl(DSWActor* actor)
bool ICanSee = false;
DoActorPickClosePlayer(actor);
ICanSee = FAFcansee(actor, ActorZOfMiddle(actor), actor->user.targetActor, ActorZOfMiddle(actor->user.targetActor));
ICanSee = FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),actor->user.targetActor->spr.pos.X,actor->user.targetActor->spr.pos.Y,actor->user.targetActor->spr.pos.Z,actor->user.targetActor->sector());
if (!(actor->user.Flags & SPR_CLIMBING))
KeepActorOnFloor(actor);

View file

@ -1195,9 +1195,9 @@ DSWActor* DoPickTarget(DSWActor* actor, uint32_t max_delta_ang, int skip_targets
ezhl = ActorZOfBottom(itActor) - (ActorSizeZ(itActor) >> 2);
// If you can't see 'em you can't shoot 'em
if (!FAFcansee(actor, zh, itActor, ezh) &&
!FAFcansee(actor, zh, itActor, ezhm) &&
!FAFcansee(actor, zh, itActor, ezhl)
if (!FAFcansee(actor->spr.pos.X, actor->spr.pos.Y, zh, actor->sector(), itActor->spr.pos.X, itActor->spr.pos.Y, ezh, itActor->sector()) &&
!FAFcansee(actor->spr.pos.X, actor->spr.pos.Y, zh, actor->sector(), itActor->spr.pos.X, itActor->spr.pos.Y, ezhm, itActor->sector()) &&
!FAFcansee(actor->spr.pos.X, actor->spr.pos.Y, zh, actor->sector(), itActor->spr.pos.X, itActor->spr.pos.Y, ezhl, itActor->sector())
)
continue;

View file

@ -1148,7 +1148,7 @@ void WeaponExplodeSectorInRange(DSWActor* wActor)
if ((unsigned int)dist > (wActor->user.Radius/2) + radius)
continue;
if (!FAFcansee(wActor, actor))
if (!FAFcansee(wActor->spr.pos.X,wActor->spr.pos.Y,wActor->spr.pos.Z,wActor->sector(),actor->spr.pos.X,actor->spr.pos.Y,actor->spr.pos.Z,actor->sector()))
continue;

View file

@ -5915,7 +5915,7 @@ void AdjustActiveRange(PLAYER* pp, DSWActor* actor, int dist)
// if actor can still see the player
look_height = ActorZOfTop(actor);
if (FAFcansee(actor, look_height, plActor, ActorUpperZ(plActor)))
if (FAFcansee(actor->spr.pos.X, actor->spr.pos.Y, look_height, actor->sector(), plActor->spr.pos.X, plActor->spr.pos.Y, ActorUpperZ(plActor), plActor->sector()))
{
// Player is visible
// adjust update range of this sprite

View file

@ -2781,7 +2781,8 @@ void DoAutoTurretObject(SECTOR_OBJECT* sop)
if (sActor->spr.statnum == STAT_SO_SHOOT_POINT)
{
if (!FAFcansee(sActor, sActor->spr.pos.Z -Z(4), actor, ActorUpperZ(actor->user.targetActor)))
if (!FAFcansee(sActor->spr.pos.X, sActor->spr.pos.Y, sActor->spr.pos.Z-Z(4), sActor->sector(),
actor->user.targetActor->spr.pos.X, actor->user.targetActor->spr.pos.Y, ActorUpperZ(actor->user.targetActor), actor->user.targetActor->sector()))
{
return;
}

View file

@ -7033,7 +7033,7 @@ int DoDamageTest(DSWActor* actor)
// For speed's sake, try limiting check only to radius weapons!
if (actor->user.Radius > 200)
{
if (!FAFcansee(itActor, ActorUpperZ(actor), actor, actor->spr.pos.Z))
if (!FAFcansee(itActor->spr.pos.X,itActor->spr.pos.Y, ActorUpperZ(actor), itActor->sector(),actor->spr.pos.X,actor->spr.pos.Y,actor->spr.pos.Z,actor->sector()))
continue;
}
@ -7106,7 +7106,7 @@ int DoFlamesDamageTest(DSWActor* actor)
if (actor->user.Radius > 200) // Note: No weaps have bigger radius than 200 cept explosion stuff
{
if (FAFcansee(itActor, ActorZOfMiddle(actor), actor, ActorZOfMiddle(actor)))
if (FAFcansee(itActor->spr.pos.X,itActor->spr.pos.Y,ActorZOfMiddle(actor),itActor->sector(),actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector()))
{
DoDamage(itActor, actor);
}
@ -7250,8 +7250,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(actor, actor->spr.pos.Z, itActor, ActorUpperZ(actor)) &&
!FAFcansee(actor, actor->spr.pos.Z, itActor, ActorLowerZ(actor)))
if (!FAFcansee(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->sector(), itActor->spr.pos.X, itActor->spr.pos.Y, ActorUpperZ(actor), itActor->sector()) &&
!FAFcansee(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->sector(), itActor->spr.pos.X, itActor->spr.pos.Y, ActorLowerZ(actor), itActor->sector()))
continue;
DoDamage(itActor, actor);
@ -7280,7 +7280,7 @@ int DoExpDamageTest(DSWActor* actor)
if ((unsigned)dist > actor->user.Radius)
continue;
if (!FAFcansee(itActor, ActorZOfMiddle(itActor), actor, actor->spr.pos.Z))
if (!FAFcansee(itActor->spr.pos.X, itActor->spr.pos.Y, ActorZOfMiddle(itActor), itActor->sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->sector()))
continue;
if ((itActor->spr.extra & SPRX_BREAKABLE))
@ -8602,7 +8602,7 @@ int DoMineRangeTest(DSWActor* actor, int range)
if (dist > range)
continue;
if (FAFcansee(itActor, ActorUpperZ(actor), actor, actor->spr.pos.Z))
if (!FAFcansee(itActor->spr.pos.X,itActor->spr.pos.Y,ActorUpperZ(actor),itActor->sector(),actor->spr.pos.X,actor->spr.pos.Y,actor->spr.pos.Z,actor->sector()))
continue;
return true;
@ -11873,7 +11873,7 @@ int InitSwordAttack(PLAYER* pp)
{
if (SpriteOverlapZ(pp->actor, itActor, Z(20)))
{
if (FAFcansee(itActor, ActorZOfMiddle(itActor), plActor, ActorZOfMiddle(plActor)))
if (FAFcansee(itActor->spr.pos.X, itActor->spr.pos.Y, ActorZOfMiddle(itActor), itActor->sector(), plActor->spr.pos.X, plActor->spr.pos.Y, ActorZOfMiddle(plActor), plActor->sector()))
DoDamage(itActor, pp->actor);
}
}
@ -12049,7 +12049,7 @@ int InitFistAttack(PLAYER* pp)
{
if (SpriteOverlapZ(pp->actor, itActor, Z(20)) || face == 190)
{
if (FAFcansee(itActor, ActorZOfMiddle(itActor), plActor, ActorZOfMiddle(plActor)))
if (FAFcansee(itActor->spr.pos.X, itActor->spr.pos.Y, ActorZOfMiddle(itActor), itActor->sector(), plActor->spr.pos.X, plActor->spr.pos.Y, ActorZOfMiddle(plActor), plActor->sector()))
DoDamage(itActor, plActor);
if (face == 190)
{
@ -12327,7 +12327,7 @@ int InitSumoStompAttack(DSWActor* actor)
if (dist < CloseRangeDist(itActor, actor, reach))
{
if (FAFcansee(itActor, ActorZOfMiddle(itActor), actor, ActorZOfMiddle(actor)))
if (FAFcansee(itActor->spr.pos.X, itActor->spr.pos.Y, ActorZOfMiddle(itActor), itActor->sector(), actor->spr.pos.X, actor->spr.pos.Y, ActorZOfMiddle(actor), actor->sector()))
DoDamage(itActor, actor);
}
}
@ -12353,7 +12353,7 @@ int InitMiniSumoClap(DSWActor* actor)
{
if (SpriteOverlapZ(actor, targetActor, Z(20)))
{
if (FAFcansee(targetActor, ActorZOfMiddle(targetActor), actor, ActorZOfMiddle(actor)))
if (FAFcansee(targetActor->spr.pos.X, targetActor->spr.pos.Y, ActorZOfMiddle(targetActor), targetActor->sector(), actor->spr.pos.X, actor->spr.pos.Y, ActorZOfMiddle(actor), actor->sector()))
{
PlaySound(DIGI_CGTHIGHBONE, actor, v3df_follow | v3df_dontpan);
DoDamage(targetActor, actor);
@ -12362,7 +12362,7 @@ int InitMiniSumoClap(DSWActor* actor)
}
else if (dist < CloseRangeDist(targetActor, actor, reach))
{
if (FAFcansee(targetActor, ActorZOfMiddle(targetActor), actor, ActorZOfMiddle(actor)))
if (FAFcansee(targetActor->spr.pos.X, targetActor->spr.pos.Y, ActorZOfMiddle(targetActor), targetActor->sector(), actor->spr.pos.X, actor->spr.pos.Y, ActorZOfMiddle(actor), actor->sector()))
{
PlaySound(DIGI_30MMEXPLODE, actor, v3df_none);
SpawnFireballFlames(actor, targetActor);
@ -13964,7 +13964,7 @@ int DoStaticFlamesDamage(DSWActor* actor)
DoDamage(itActor, actor);
else if (actor->user.Radius > 200)
{
if (FAFcansee(actor, ActorZOfMiddle(actor), itActor, ActorZOfMiddle(itActor)))
if (FAFcansee(actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->sector(),itActor->spr.pos.X,itActor->spr.pos.Y,ActorZOfMiddle(itActor),itActor->sector()))
DoDamage(itActor, actor);
}
}