- let's make some use of AActor::Pos and get rid of some of those X() and Y() calls...

- restore proper actor.h file.
This commit is contained in:
Christoph Oelckers 2016-01-18 21:01:52 +01:00
parent 460751653d
commit c1b44a5694
18 changed files with 81 additions and 66 deletions

View File

@ -847,7 +847,7 @@ public:
bool intersects(AActor *other) const
{
fixed_t blockdist = radius + other->radius;
return ( abs(pos.x - other->pos.x) < blockdist && abs(pos.y - other->pos.y) < blockdist);
return ( abs(x - other->x) < blockdist && abs(y - other->y) < blockdist);
}
PalEntry GetBloodColor() const
@ -888,99 +888,99 @@ public:
// to distinguish between portal-aware and portal-unaware distance calculation.
fixed_t AproxDistance(AActor *other, bool absolute = false)
{
return P_AproxDistance(pos.x - other->pos.x, pos.y - other->pos.y);
return P_AproxDistance(x - other->x, y - other->y);
}
// same with 'ref' here.
fixed_t AproxDistance(fixed_t otherx, fixed_t othery, AActor *ref = NULL)
{
return P_AproxDistance(pos.x - otherx, pos.y - othery);
return P_AproxDistance(x - otherx, y - othery);
}
fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false)
{
return P_AproxDistance(pos.x - other->pos.x + xadd, pos.y - other->pos.y + yadd);
return P_AproxDistance(x - other->x + xadd, y - other->y + yadd);
}
fixed_t AproxDistance3D(AActor *other, bool absolute = false)
{
return P_AproxDistance(AproxDistance(other), pos.z - other->pos.z);
return P_AproxDistance(AproxDistance(other), z - other->z);
}
// more precise, but slower version, being used in a few places
fixed_t Distance2D(AActor *other, bool absolute = false)
{
return xs_RoundToInt(FVector2(pos.x - other->pos.x, pos.y - other->pos.y).Length());
return xs_RoundToInt(FVector2(x - other->x, y - other->y).Length());
}
// a full 3D version of the above
fixed_t Distance3D(AActor *other, bool absolute = false)
{
return xs_RoundToInt(FVector3(pos.x - other->pos.x, pos.y - other->pos.y, pos.z - other->pos.z).Length());
return xs_RoundToInt(FVector3(x - other->x, y - other->y, z - other->z).Length());
}
angle_t AngleTo(AActor *other, bool absolute = false) const
{
return R_PointToAngle2(pos.x, pos.y, other->pos.x, other->pos.y);
return R_PointToAngle2(x, y, other->x, other->y);
}
angle_t AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const
{
return R_PointToAngle2(pos.x, pos.y, other->pos.x + oxofs, other->pos.y + oyofs);
return R_PointToAngle2(x, y, other->x + oxofs, other->y + oyofs);
}
fixed_t AngleTo(fixed_t otherx, fixed_t othery, AActor *ref = NULL)
{
return R_PointToAngle2(pos.x, pos.y, otherx, othery);
return R_PointToAngle2(x, y, otherx, othery);
}
fixed_t AngleXYTo(fixed_t myx, fixed_t myy, AActor *other, bool absolute = false)
{
return R_PointToAngle2(myx, myy, other->pos.x, other->pos.y);
return R_PointToAngle2(myx, myy, other->x, other->y);
}
fixedvec2 Vec2To(AActor *other) const
{
fixedvec2 ret = { other->pos.x - pos.x, other->pos.y - pos.y };
fixedvec2 ret = { other->x - x, other->y - y };
return ret;
}
fixedvec3 Vec3To(AActor *other) const
{
fixedvec3 ret = { other->pos.x - pos.x, other->pos.y - pos.y, other->pos.z - pos.z };
fixedvec3 ret = { other->x - x, other->y - y, other->z - z };
return ret;
}
fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false) const
{
fixedvec2 ret = { pos.x + dx, pos.y + dy };
fixedvec2 ret = { x + dx, y + dy };
return ret;
}
fixedvec2 Vec2Angle(fixed_t length, angle_t angle, bool absolute = false) const
{
fixedvec2 ret = { pos.x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
pos.y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) };
fixedvec2 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) };
return ret;
}
fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) const
{
fixedvec3 ret = { pos.x + dx, pos.y + dy, pos.z + dz };
fixedvec3 ret = { x + dx, y + dy, z + dz };
return ret;
}
fixedvec3 Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false) const
{
fixedvec3 ret = { pos.x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
pos.y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), pos.z + dz };
fixedvec3 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), z + dz };
return ret;
}
void Move(fixed_t dx, fixed_t dy, fixed_t dz)
{
SetOrigin(pos.x + dx, pos.y + dy, pos.z + dz, true);
SetOrigin(x + dx, y + dy, z + dz, true);
}
void SetOrigin(const fixedvec3 & npos, bool moving)
@ -1007,10 +1007,7 @@ public:
// info for drawing
// NOTE: The first member variable *must* be x.
private:
fixedvec3 pos;
public:
//fixed_t x,y,z;
fixed_t x,y,z;
AActor *snext, **sprev; // links in sector (if needed)
angle_t angle;
WORD sprite; // used to find patch_t and flip value
@ -1208,7 +1205,7 @@ public:
void LinkToWorld (sector_t *sector);
void UnlinkFromWorld ();
void AdjustFloorClip ();
void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving);
void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving = false);
bool InStateSequence(FState * newstate, FState * basestate);
int GetTics(FState * newstate);
bool SetState (FState *newstate, bool nofunction=false);
@ -1240,41 +1237,46 @@ public:
fixed_t X() const
{
return pos.x;
return x;
}
fixed_t Y() const
{
return pos.y;
return y;
}
fixed_t Z() const
{
return pos.z;
return z;
}
fixedvec3 Pos() const
{
fixedvec3 ret = { X(), Y(), Z() };
return ret;
}
fixedvec3 PosPlusZ(fixed_t zadd) const
{
fixedvec3 ret = { X(), Y(), Z() + zadd };
return ret;
}
fixed_t Top() const
{
return pos.z + height;
return z + height;
}
void SetZ(fixed_t newz, bool moving = true)
{
pos.z = newz;
z = newz;
}
// These are not for general use as they do not link the actor into the world!
void SetXY(fixed_t x, fixed_t y)
void SetXY(fixed_t xx, fixed_t yy)
{
pos.x = x;
pos.y = y;
x = xx;
y = yy;
}
void SetXYZ(fixed_t x, fixed_t y, fixed_t z)
void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz)
{
pos.x = x;
pos.y = y;
pos.z = z;
x = xx;
y = yy;
z = zz;
}
};

View File

@ -459,7 +459,7 @@ void FCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum)
//Emulates missile travel. Returns distance travelled.
fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd)
{
AActor *th = Spawn ("CajunTrace", source->X(), source->Y(), source->Z() + 4*8*FRACUNIT, NO_REPLACE);
AActor *th = Spawn ("CajunTrace", source->PosPlusZ(4*8*FRACUNIT), NO_REPLACE);
th->target = source; // where it came from

View File

@ -3056,7 +3056,7 @@ bool ADehackedPickup::TryPickup (AActor *&toucher)
{
return false;
}
RealPickup = static_cast<AInventory *>(Spawn (type, X(), Y(), Z(), NO_REPLACE));
RealPickup = static_cast<AInventory *>(Spawn (type, Pos(), NO_REPLACE));
if (RealPickup != NULL)
{
// The internally spawned item should never count towards statistics.

View File

@ -4281,7 +4281,7 @@ void FParser::SF_SpawnShot2(void)
t_return.type = svt_mobj;
AActor *mo = Spawn (PClass, source->X(), source->Y(), source->Z()+z, ALLOW_REPLACE);
AActor *mo = Spawn (PClass, source->PosPlusZ(z), ALLOW_REPLACE);
if (mo)
{
S_Sound (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM);

View File

@ -275,7 +275,7 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound)
if (!(newmobj->ObjectFlags & OF_EuthanizeMe))
{
// telefrag anything in this spot
P_TeleportMove (newmobj, newmobj->X(), newmobj->Y(), newmobj->Z(), true);
P_TeleportMove (newmobj, newmobj->Pos(), true);
}
newmobj->flags4 |= MF4_BOSSSPAWNED;
}

View File

@ -612,8 +612,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
if (linetarget != NULL)
{
AActor *spray = Spawn(spraytype, linetarget->X(), linetarget->Y(),
linetarget->Z() + (linetarget->height >> 2), ALLOW_REPLACE);
AActor *spray = Spawn(spraytype, linetarget->PosPlusZ(linetarget->height >> 2), ALLOW_REPLACE);
int dmgFlags = 0;
FName dmgType = NAME_BFGSplash;

View File

@ -145,7 +145,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom)
P_CheckSplash(self, 128<<FRACBITS);
// Now launch mushroom cloud
AActor *target = Spawn("Mapspot", self->X(), self->Y(), self->Z(), NO_REPLACE); // We need something to aim at.
AActor *target = Spawn("Mapspot", self->Pos(), NO_REPLACE); // We need something to aim at.
AActor *master = (flags & MSF_DontHurt) ? (AActor*)(self->target) : self;
target->height = self->height;
for (i = -n; i <= n; i += 8)

View File

@ -80,7 +80,7 @@ void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype, int
fixedvec2 dist = Vec2Angle(prestep, angle);
fixedvec3 pos = self->Vec3Offset(dist.x, dist.y, 8 * FRACUNIT, true);
fixedvec3 src = { self->X(), self->Y(), self->Z() };
fixedvec3 src = self->Pos();
for (int i = 0; i < 2; i++)
{
@ -142,7 +142,7 @@ void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype, int
// Check for movements.
if (!P_CheckPosition (other, other->X(), other->Y()))
if (!P_CheckPosition (other, other->Pos()))
{
// kill it immediately
P_DamageMobj (other, self, self, TELEFRAG_DAMAGE, NAME_None);

View File

@ -31,7 +31,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkelMissile)
if (missile != NULL)
{
missile->SetOrigin(missile->X() + missile->velx, missile->Y() + missile->vely, missile->Z(), false);
missile->SetOrigin(missile->Vec3Offset(missile->velx, missile->vely, 0), false);
missile->tracer = self->target;
}
}

View File

@ -100,7 +100,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Feathers)
}
for (i = 0; i < count; i++)
{
mo = Spawn("Feather", self->X(), self->Y(), self->Z()+20*FRACUNIT, NO_REPLACE);
mo = Spawn("Feather", self->PosPlusZ(20*FRACUNIT), NO_REPLACE);
mo->target = self;
mo->velx = pr_feathers.Random2() << 8;
mo->vely = pr_feathers.Random2() << 8;

View File

@ -146,7 +146,7 @@ void P_DSparilTeleport (AActor *actor)
prevX = actor->X();
prevY = actor->Y();
prevZ = actor->Z();
if (P_TeleportMove (actor, spot->X(), spot->Y(), spot->Z(), false))
if (P_TeleportMove (actor, spot->Pos(), false))
{
mo = Spawn("Sorcerer2Telefade", prevX, prevY, prevZ, ALLOW_REPLACE);
if (mo) mo->Translation = actor->Translation;
@ -254,7 +254,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard)
{
AActor *mo;
mo = Spawn("Wizard", self->X(), self->Y(), self->Z(), ALLOW_REPLACE);
mo = Spawn("Wizard", self->Pos(), ALLOW_REPLACE);
if (mo != NULL)
{
mo->SetZ(mo->Z() - mo->GetDefault()->height / 2, false);
@ -272,7 +272,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard)
self->flags &= ~MF_MISSILE;
mo->master = self->target;
// Heretic did not offset it by TELEFOGHEIGHT, so I won't either.
Spawn<ATeleportFog> (self->X(), self->Y(), self->Z(), ALLOW_REPLACE);
Spawn<ATeleportFog> (self->Pos(), ALLOW_REPLACE);
}
}
}

View File

@ -57,7 +57,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PodPain)
}
for (count = chance > 240 ? 2 : 1; count; count--)
{
goo = Spawn(gootype, self->X(), self->Y(), self->Z() + 48*FRACUNIT, ALLOW_REPLACE);
goo = Spawn(gootype, self->PosPlusZ(48*FRACUNIT), ALLOW_REPLACE);
goo->target = self;
goo->velx = pr_podpain.Random2() << 9;
goo->vely = pr_podpain.Random2() << 9;
@ -100,15 +100,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MakePod)
AActor *mo;
fixed_t x;
fixed_t y;
fixed_t z;
if (self->special1 == MAX_GEN_PODS)
{ // Too many generated pods
return;
}
x = self->x;
y = self->y;
z = self->z;
x = self->X();
y = self->Y();
mo = Spawn(podtype, x, y, ONFLOORZ, ALLOW_REPLACE);
if (!P_CheckPosition (mo, x, y))
{ // Didn't fit
@ -191,17 +189,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact)
AActor *tiny;
angle_t angle;
if (self->z <= self->floorz)
if (self->Z() <= self->floorz)
{
self->flags |= MF_NOGRAVITY;
self->gravity = FRACUNIT;
self->z += 28*FRACUNIT;
self->SetZ(self->Z() + 28*FRACUNIT);
//self->velz = 3*FRACUNIT;
}
P_RadiusAttack (self, self->target, 25, 25, NAME_Fire, RADF_HURTSOURCE);
for (i = 0; i < 4; i++)
{
tiny = Spawn("VolcanoTBlast", self->x, self->y, self->z, ALLOW_REPLACE);
tiny = Spawn("VolcanoTBlast", self->Pos(), ALLOW_REPLACE);
tiny->target = self;
angle = i*ANG90;
tiny->angle = angle;

View File

@ -382,7 +382,7 @@ void FireMacePL1B (AActor *actor)
if (!weapon->DepleteAmmo (weapon->bAltFire))
return;
}
ball = Spawn("MaceFX2", actor->X(), actor->Y(), actor->Z() + 28*FRACUNIT - actor->floorclip, ALLOW_REPLACE);
ball = Spawn("MaceFX2", actor->PosPlusZ(28*FRACUNIT - actor->floorclip), ALLOW_REPLACE);
ball->velz = 2*FRACUNIT+/*((player->lookdir)<<(FRACBITS-5))*/
finetangent[FINEANGLES/4-(actor->pitch>>ANGLETOFINESHIFT)];
angle = actor->angle;

View File

@ -200,7 +200,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichIceImpact)
DEFINE_ACTION_FUNCTION(AActor, A_LichFireGrow)
{
self->health--;
self->SetZ(self->Z + 9*FRACUNIT);
self->SetZ(self->Z() + 9*FRACUNIT);
if (self->health == 0)
{
self->Damage = self->GetDefault()->Damage;

View File

@ -144,6 +144,10 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li
secplane_t P_FindFloorPlane(sector_t * sector, fixed_t x, fixed_t y, fixed_t z);
int P_Find3DFloor(sector_t * sec, fixed_t x, fixed_t y, fixed_t z, bool above, bool floor, fixed_t &cmpz);
inline int P_Find3DFloor(sector_t * sec, const fixedvec3 &pos, bool above, bool floor, fixed_t &cmpz)
{
return P_Find3DFloor(sec, pos.x, pos.y, pos.z, above, floor, cmpz);
}
#endif

View File

@ -2547,8 +2547,8 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates)
if (testsec)
{
fixed_t zdist1, zdist2;
if (P_Find3DFloor(testsec, corpsehit->X(), corpsehit->Y(), corpsehit->Z(), false, true, zdist1)
!= P_Find3DFloor(testsec, self->X(), self->Y(), self->Z(), false, true, zdist2))
if (P_Find3DFloor(testsec, corpsehit->Pos(), false, true, zdist1)
!= P_Find3DFloor(testsec, self->Pos(), false, true, zdist2))
{
// Not on same floor
if (vilesec == corpsec || abs(zdist1 - self->Z()) > self->height)
@ -2565,7 +2565,7 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates)
corpsehit->flags |= MF_SOLID;
corpsehit->height = corpsehit->GetDefault()->height;
bool check = P_CheckPosition(corpsehit, corpsehit->X(), corpsehit->Y());
bool check = P_CheckPosition(corpsehit, corpsehit->Pos());
corpsehit->flags = oldflags;
corpsehit->radius = oldradius;
corpsehit->height = oldheight;

View File

@ -134,6 +134,10 @@ enum EPuffFlags
};
AActor *P_SpawnPuff (AActor *source, const PClass *pufftype, fixed_t x, fixed_t y, fixed_t z, angle_t dir, int updown, int flags = 0, AActor *vict = NULL);
inline AActor *P_SpawnPuff(AActor *source, const PClass *pufftype, const fixedvec3 &pos, angle_t dir, int updown, int flags = 0, AActor *vict = NULL)
{
return P_SpawnPuff(source, pufftype, pos.x, pos.y, pos.z, dir, updown, flags, vict);
}
void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AActor *originator);
void P_BloodSplatter (fixed_t x, fixed_t y, fixed_t z, AActor *originator);
void P_BloodSplatter2 (fixed_t x, fixed_t y, fixed_t z, AActor *originator);
@ -458,6 +462,10 @@ bool P_TestMobjLocation (AActor *mobj);
bool P_TestMobjZ (AActor *mobj, bool quick=true, AActor **pOnmobj = NULL);
bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bool actorsonly=false);
bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, bool actorsonly=false);
inline bool P_CheckPosition(AActor *thing, const fixedvec3 &pos, bool actorsonly = false)
{
return P_CheckPosition(thing, pos.x, pos.y, actorsonly);
}
AActor *P_CheckOnmobj (AActor *thing);
void P_FakeZMovement (AActor *mo);
bool P_TryMove (AActor* thing, fixed_t x, fixed_t y, int dropoff, const secplane_t * onfloor, FCheckPosition &tm, bool missileCheck = false);
@ -465,6 +473,10 @@ bool P_TryMove (AActor* thing, fixed_t x, fixed_t y, int dropoff, const secplane
bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y);
void P_ApplyTorque(AActor *mo);
bool P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters
inline bool P_TeleportMove(AActor* thing, const fixedvec3 &pos, bool telefrag, bool modifyactor = true)
{
return P_TeleportMove(thing, pos.x, pos.y, pos.z, telefrag, modifyactor);
}
void P_PlayerStartStomp (AActor *actor); // [RH] Stomp on things for a newly spawned player
void P_SlideMove (AActor* mo, fixed_t tryx, fixed_t tryy, int numsteps);
bool P_BounceWall (AActor *mo);

View File

@ -436,7 +436,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser)
thing->flags |= MF_SOLID;
thing->height = info->height; // [RH] Use real height
thing->radius = info->radius; // [RH] Use real radius
if (!P_CheckPosition (thing, thing->X(), thing->Y()))
if (!P_CheckPosition (thing, thing->Pos()))
{
thing->flags = oldflags;
thing->radius = oldradius;
@ -478,7 +478,7 @@ bool P_Thing_CanRaise(AActor *thing)
thing->height = info->height;
thing->radius = info->radius;
bool check = P_CheckPosition (thing, thing->X(), thing->Y());
bool check = P_CheckPosition (thing, thing->Pos());
// Restore checked properties
thing->flags = oldflags;