- refactoring complete. The source compiles again with the renamed position variable.

This commit is contained in:
Christoph Oelckers 2016-01-20 15:12:51 +01:00
parent 13e25faea7
commit 68c0f929dc
7 changed files with 128 additions and 136 deletions

View file

@ -844,12 +844,6 @@ public:
return (flags & MF_COUNTKILL) && !(flags & MF_FRIENDLY); return (flags & MF_COUNTKILL) && !(flags & MF_FRIENDLY);
} }
bool intersects(AActor *other) const
{
fixed_t blockdist = radius + other->radius;
return ( abs(x - other->x) < blockdist && abs(y - other->y) < blockdist);
}
PalEntry GetBloodColor() const PalEntry GetBloodColor() const
{ {
return (PalEntry)GetClass()->Meta.GetMetaInt(AMETA_BloodColor); return (PalEntry)GetClass()->Meta.GetMetaInt(AMETA_BloodColor);
@ -884,103 +878,109 @@ public:
return bloodcls; return bloodcls;
} }
bool intersects(AActor *other) const
{
fixed_t blockdist = radius + other->radius;
return ( abs(X() - other->Y()) < blockdist && abs(Y() - other->Y()) < blockdist);
}
// 'absolute' is reserved for a linked portal implementation which needs // 'absolute' is reserved for a linked portal implementation which needs
// to distinguish between portal-aware and portal-unaware distance calculation. // to distinguish between portal-aware and portal-unaware distance calculation.
fixed_t AproxDistance(AActor *other, bool absolute = false) fixed_t AproxDistance(AActor *other, bool absolute = false)
{ {
return P_AproxDistance(x - other->x, y - other->y); return P_AproxDistance(X() - other->X(), Y() - other->Y());
} }
// same with 'ref' here. // same with 'ref' here.
fixed_t AproxDistance(fixed_t otherx, fixed_t othery, AActor *ref = NULL) fixed_t AproxDistance(fixed_t otherx, fixed_t othery, AActor *ref = NULL)
{ {
return P_AproxDistance(x - otherx, y - othery); return P_AproxDistance(X() - otherx, Y() - othery);
} }
fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false) fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false)
{ {
return P_AproxDistance(x - other->x + xadd, y - other->y + yadd); return P_AproxDistance(X() - other->X() + xadd, Y() - other->Y() + yadd);
} }
fixed_t AproxDistance3D(AActor *other, bool absolute = false) fixed_t AproxDistance3D(AActor *other, bool absolute = false)
{ {
return P_AproxDistance(AproxDistance(other), z - other->z); return P_AproxDistance(AproxDistance(other), Z() - other->Z());
} }
// more precise, but slower version, being used in a few places // more precise, but slower version, being used in a few places
fixed_t Distance2D(AActor *other, bool absolute = false) fixed_t Distance2D(AActor *other, bool absolute = false)
{ {
return xs_RoundToInt(FVector2(x - other->x, y - other->y).Length()); return xs_RoundToInt(FVector2(X() - other->X(), Y() - other->Y()).Length());
} }
// a full 3D version of the above // a full 3D version of the above
fixed_t Distance3D(AActor *other, bool absolute = false) fixed_t Distance3D(AActor *other, bool absolute = false)
{ {
return xs_RoundToInt(FVector3(x - other->x, y - other->y, z - other->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 angle_t AngleTo(AActor *other, bool absolute = false) const
{ {
return R_PointToAngle2(x, y, other->x, other->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 angle_t AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const
{ {
return R_PointToAngle2(x, y, other->x + oxofs, other->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) fixed_t AngleTo(fixed_t otherx, fixed_t othery, AActor *ref = NULL)
{ {
return R_PointToAngle2(x, y, otherx, othery); return R_PointToAngle2(X(), Y(), otherx, othery);
} }
fixed_t AngleXYTo(fixed_t myx, fixed_t myy, AActor *other, bool absolute = false) fixed_t AngleXYTo(fixed_t myx, fixed_t myy, AActor *other, bool absolute = false)
{ {
return R_PointToAngle2(myx, myy, other->x, other->y); return R_PointToAngle2(myx, myy, other->X(), other->Y());
} }
fixedvec2 Vec2To(AActor *other) const fixedvec2 Vec2To(AActor *other) const
{ {
fixedvec2 ret = { other->x - x, other->y - y }; fixedvec2 ret = { other->X() - X(), other->Y() - Y() };
return ret; return ret;
} }
fixedvec3 Vec3To(AActor *other) const fixedvec3 Vec3To(AActor *other) const
{ {
fixedvec3 ret = { other->x - x, other->y - y, other->z - z }; fixedvec3 ret = { other->X() - X(), other->Y() - Y(), other->Z() - Z() };
return ret; return ret;
} }
fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false) const fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false) const
{ {
fixedvec2 ret = { x + dx, y + dy }; fixedvec2 ret = { X() + dx, Y() + dy };
return ret; return ret;
} }
fixedvec2 Vec2Angle(fixed_t length, angle_t angle, bool absolute = false) const fixedvec2 Vec2Angle(fixed_t length, angle_t angle, bool absolute = false) const
{ {
fixedvec2 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), fixedvec2 ret = { X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) }; Y() + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) };
return ret; return ret;
} }
fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) const fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) const
{ {
fixedvec3 ret = { x + dx, y + dy, z + dz }; fixedvec3 ret = { X() + dx, Y() + dy, Z() + dz };
return ret; return ret;
} }
fixedvec3 Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false) const fixedvec3 Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false) const
{ {
fixedvec3 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), fixedvec3 ret = { X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), z + dz }; Y() + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), Z() + dz };
return ret; return ret;
} }
void Move(fixed_t dx, fixed_t dy, fixed_t dz) void Move(fixed_t dx, fixed_t dy, fixed_t dz)
{ {
SetOrigin(x + dx, y + dy, z + dz, true); SetOrigin(X() + dx, Y() + dy, Z() + dz, true);
} }
void SetOrigin(const fixedvec3 & npos, bool moving) void SetOrigin(const fixedvec3 & npos, bool moving)
@ -1006,9 +1006,10 @@ public:
void CheckSectorTransition(sector_t *oldsec); void CheckSectorTransition(sector_t *oldsec);
// info for drawing // info for drawing
// NOTE: The first member variable *must* be x. // NOTE: The first member variable *must* be snext.
AActor *snext, **sprev; // links in sector (if needed) AActor *snext, **sprev; // links in sector (if needed)
fixed_t x,y,z; fixedvec3 __pos; // double underscores so that it won't get used by accident. Access to this should be exclusively through the designated access functions.
angle_t angle; angle_t angle;
WORD sprite; // used to find patch_t and flip value WORD sprite; // used to find patch_t and flip value
BYTE frame; // sprite frame to draw BYTE frame; // sprite frame to draw
@ -1237,15 +1238,15 @@ public:
fixed_t X() const fixed_t X() const
{ {
return x; return __pos.x;
} }
fixed_t Y() const fixed_t Y() const
{ {
return y; return __pos.y;
} }
fixed_t Z() const fixed_t Z() const
{ {
return z; return __pos.z;
} }
fixedvec3 Pos() const fixedvec3 Pos() const
{ {
@ -1295,39 +1296,39 @@ public:
} }
fixed_t Top() const fixed_t Top() const
{ {
return z + height; return Z() + height;
} }
void SetZ(fixed_t newz, bool moving = true) void SetZ(fixed_t newz, bool moving = true)
{ {
z = newz; __pos.z = newz;
} }
void AddZ(fixed_t newz, bool moving = true) void AddZ(fixed_t newz, bool moving = true)
{ {
z += newz; __pos.z += newz;
} }
// These are not for general use as they do not link the actor into the world! // These are not for general use as they do not link the actor into the world!
void SetXY(fixed_t xx, fixed_t yy) void SetXY(fixed_t xx, fixed_t yy)
{ {
x = xx; __pos.x = xx;
y = yy; __pos.y = yy;
} }
void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz) void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz)
{ {
x = xx; __pos.x = xx;
y = yy; __pos.y = yy;
z = zz; __pos.z = zz;
} }
void SetXY(const fixedvec2 &npos) void SetXY(const fixedvec2 &npos)
{ {
x = npos.x; __pos.x = npos.x;
y = npos.y; __pos.y = npos.y;
} }
void SetXYZ(const fixedvec3 &npos) void SetXYZ(const fixedvec3 &npos)
{ {
x = npos.x; __pos.x = npos.x;
y = npos.y; __pos.y = npos.y;
z = npos.z; __pos.z = npos.z;
} }
void SetMovement(fixed_t x, fixed_t y, fixed_t z) void SetMovement(fixed_t x, fixed_t y, fixed_t z)
{ {

View file

@ -156,9 +156,9 @@ void AActor::Serialize (FArchive &arc)
sprite = arc.ReadSprite (); sprite = arc.ReadSprite ();
} }
arc << x arc << __pos.x
<< y << __pos.y
<< z << __pos.z
<< angle << angle
<< frame << frame
<< scaleX << scaleX

View file

@ -101,9 +101,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
{ {
bool predicting = (thing->player && (thing->player->cheats & CF_PREDICTING)); bool predicting = (thing->player && (thing->player->cheats & CF_PREDICTING));
fixed_t oldx; fixedvec3 old;
fixed_t oldy;
fixed_t oldz;
fixed_t aboveFloor; fixed_t aboveFloor;
player_t *player; player_t *player;
angle_t an; angle_t an;
@ -112,10 +110,8 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
fixed_t floorheight, ceilingheight; fixed_t floorheight, ceilingheight;
fixed_t missilespeed; fixed_t missilespeed;
oldx = thing->x; old = thing->Pos();
oldy = thing->y; aboveFloor = thing->Z() - thing->floorz;
oldz = thing->z;
aboveFloor = thing->z - thing->floorz;
destsect = P_PointInSector (x, y); destsect = P_PointInSector (x, y);
// killough 5/12/98: exclude voodoo dolls: // killough 5/12/98: exclude voodoo dolls:
player = thing->player; player = thing->player;
@ -171,7 +167,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
} }
if (player) if (player)
{ {
player->viewz = thing->z + player->viewheight; player->viewz = thing->Z() + player->viewheight;
if (resetpitch) if (resetpitch)
{ {
player->mo->pitch = 0; player->mo->pitch = 0;
@ -188,7 +184,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
// Spawn teleport fog at source and destination // Spawn teleport fog at source and destination
if (sourceFog && !predicting) if (sourceFog && !predicting)
{ {
P_SpawnTeleportFog(thing, oldx, oldy, oldz, true, true); //Passes the actor through which then pulls the TeleFog metadata types based on properties. P_SpawnTeleportFog(thing, old, true, true); //Passes the actor through which then pulls the TeleFog metadata types based on properties.
} }
if (useFog) if (useFog)
{ {
@ -196,7 +192,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
{ {
fixed_t fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT; fixed_t fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT;
an = angle >> ANGLETOFINESHIFT; an = angle >> ANGLETOFINESHIFT;
P_SpawnTeleportFog(thing, x + 20 * finecosine[an], y + 20 * finesine[an], thing->z + fogDelta, false, true); P_SpawnTeleportFog(thing, x + 20 * finecosine[an], y + 20 * finesine[an], thing->Z() + fogDelta, false, true);
} }
if (thing->player) if (thing->player)
@ -372,11 +368,11 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, bool
velx = thing->velx; velx = thing->velx;
vely = thing->vely; vely = thing->vely;
z = searcher->z; z = searcher->Z();
} }
else if (searcher->IsKindOf (PClass::FindClass(NAME_TeleportDest2))) else if (searcher->IsKindOf (PClass::FindClass(NAME_TeleportDest2)))
{ {
z = searcher->z; z = searcher->Z();
} }
else else
{ {
@ -386,7 +382,7 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, bool
{ {
badangle = 1 << ANGLETOFINESHIFT; badangle = 1 << ANGLETOFINESHIFT;
} }
if (P_Teleport (thing, searcher->x, searcher->y, z, searcher->angle + badangle, fog, sourceFog, keepOrientation, haltVelocity, keepHeight)) if (P_Teleport (thing, searcher->X(), searcher->Y(), z, searcher->angle + badangle, fog, sourceFog, keepOrientation, haltVelocity, keepHeight))
{ {
// [RH] Lee Killough's changes for silent teleporters from BOOM // [RH] Lee Killough's changes for silent teleporters from BOOM
if (!fog && line && keepOrientation) if (!fog && line && keepOrientation)
@ -447,8 +443,8 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO
} }
else else
{ {
SQWORD num = (SQWORD)(thing->x-line->v1->x)*line->dx + SQWORD num = (SQWORD)(thing->X()-line->v1->x)*line->dx +
(SQWORD)(thing->y-line->v1->y)*line->dy; (SQWORD)(thing->Y()-line->v1->y)*line->dy;
if (num <= 0) if (num <= 0)
{ {
pos = 0; pos = 0;
@ -461,8 +457,8 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO
{ {
pos = (SDWORD)(num / (den>>30)); pos = (SDWORD)(num / (den>>30));
} }
nposx = thing->x - line->v1->x - MulScale30 (line->dx, pos); nposx = thing->X() - line->v1->x - MulScale30 (line->dx, pos);
nposy = thing->y - line->v1->y - MulScale30 (line->dy, pos); nposy = thing->Y() - line->v1->y - MulScale30 (line->dy, pos);
} }
} }
@ -502,7 +498,7 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO
bool stepdown = l->frontsector->floorplane.ZatPoint(x, y) < l->backsector->floorplane.ZatPoint(x, y); bool stepdown = l->frontsector->floorplane.ZatPoint(x, y) < l->backsector->floorplane.ZatPoint(x, y);
// Height of thing above ground // Height of thing above ground
fixed_t z = thing->z - thing->floorz; fixed_t z = thing->Z() - thing->floorz;
// Side to exit the linedef on positionally. // Side to exit the linedef on positionally.
// //
@ -615,16 +611,16 @@ bool EV_TeleportOther (int other_tid, int dest_tid, bool fog)
static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool floorz, bool fog) static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool floorz, bool fog)
{ {
int an = (dest->angle - source->angle) >> ANGLETOFINESHIFT; int an = (dest->angle - source->angle) >> ANGLETOFINESHIFT;
fixed_t offX = victim->x - source->x; fixed_t offX = victim->X() - source->X();
fixed_t offY = victim->y - source->y; fixed_t offY = victim->Y() - source->Y();
angle_t offAngle = victim->angle - source->angle; angle_t offAngle = victim->angle - source->angle;
fixed_t newX = DMulScale16 (offX, finecosine[an], -offY, finesine[an]); fixed_t newX = DMulScale16 (offX, finecosine[an], -offY, finesine[an]);
fixed_t newY = DMulScale16 (offX, finesine[an], offY, finecosine[an]); fixed_t newY = DMulScale16 (offX, finesine[an], offY, finecosine[an]);
bool res = bool res =
P_Teleport (victim, dest->x + newX, P_Teleport (victim, dest->X() + newX,
dest->y + newY, dest->Y() + newY,
floorz ? ONFLOORZ : dest->z + victim->z - source->z, floorz ? ONFLOORZ : dest->Z() + victim->Z() - source->Z(),
0, fog, fog, !fog); 0, fog, fog, !fog);
// P_Teleport only changes angle if fog is true // P_Teleport only changes angle if fog is true
victim->angle = dest->angle + offAngle; victim->angle = dest->angle + offAngle;
@ -692,8 +688,8 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t
if (moveSource && didSomething) if (moveSource && didSomething)
{ {
didSomething |= didSomething |=
P_Teleport (sourceOrigin, destOrigin->x, destOrigin->y, P_Teleport (sourceOrigin, destOrigin->X(), destOrigin->Y(),
floorz ? ONFLOORZ : destOrigin->z, 0, false, false, true); floorz ? ONFLOORZ : destOrigin->Z(), 0, false, false, true);
sourceOrigin->angle = destOrigin->angle; sourceOrigin->angle = destOrigin->angle;
} }

View file

@ -691,9 +691,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs,
caller = temp; caller = temp;
} }
fixed_t oldx = caller->X(); fixedvec3 old = caller->Pos();
fixed_t oldy = caller->Y();
fixed_t oldz = caller->z;
zofs += FixedMul(reference->height, heightoffset); zofs += FixedMul(reference->height, heightoffset);
@ -725,18 +723,18 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs,
// now the caller's floorz should be appropriate for the assigned xy-position // now the caller's floorz should be appropriate for the assigned xy-position
// assigning position again with. // assigning position again with.
// extra unlink, link and environment calculation // extra unlink, link and environment calculation
caller->SetOrigin( caller->SetOrigin(reference->Vec3Offset(
reference->x + xofs + FixedMul(rad, finecosine[fineangle]), xofs + FixedMul(rad, finecosine[fineangle]),
reference->y + yofs + FixedMul(rad, finesine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]),
reference->z); 0), true);
caller->z = caller->floorz + zofs; caller->SetZ(caller->floorz + zofs);
} }
else else
{ {
caller->SetOrigin( caller->SetOrigin(reference->Vec3Offset(
reference->x + xofs + FixedMul(rad, finecosine[fineangle]), xofs + FixedMul(rad, finecosine[fineangle]),
reference->y + yofs + FixedMul(rad, finesine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]),
reference->z + zofs); zofs), true);
} }
} }
else // [MC] The idea behind "absolute" is meant to be "absolute". Override everything, just like A_SpawnItemEx's. else // [MC] The idea behind "absolute" is meant to be "absolute". Override everything, just like A_SpawnItemEx's.
@ -744,7 +742,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs,
if (flags & WARPF_TOFLOOR) if (flags & WARPF_TOFLOOR)
{ {
caller->SetOrigin(xofs + FixedMul(rad, finecosine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]), zofs); caller->SetOrigin(xofs + FixedMul(rad, finecosine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]), zofs);
caller->z = caller->floorz + zofs; caller->SetZ(caller->floorz + zofs);
} }
else else
{ {
@ -756,7 +754,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs,
{ {
if (flags & WARPF_TESTONLY) if (flags & WARPF_TESTONLY)
{ {
caller->SetOrigin(oldx, oldy, oldz); caller->SetOrigin(old, true);
} }
else else
{ {
@ -783,29 +781,29 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs,
if (flags & WARPF_WARPINTERPOLATION) if (flags & WARPF_WARPINTERPOLATION)
{ {
caller->PrevX += caller->x - oldx; caller->PrevX += caller->X() - old.x;
caller->PrevY += caller->y - oldy; caller->PrevY += caller->Y() - old.y;
caller->PrevZ += caller->z - oldz; caller->PrevZ += caller->Z() - old.z;
} }
else if (flags & WARPF_COPYINTERPOLATION) else if (flags & WARPF_COPYINTERPOLATION)
{ {
caller->PrevX = caller->x + reference->PrevX - reference->x; caller->PrevX = caller->X() + reference->PrevX - reference->X();
caller->PrevY = caller->y + reference->PrevY - reference->y; caller->PrevY = caller->Y() + reference->PrevY - reference->Y();
caller->PrevZ = caller->z + reference->PrevZ - reference->z; caller->PrevZ = caller->Z() + reference->PrevZ - reference->Z();
} }
else if (!(flags & WARPF_INTERPOLATE)) else if (!(flags & WARPF_INTERPOLATE))
{ {
caller->PrevX = caller->x; caller->PrevX = caller->X();
caller->PrevY = caller->y; caller->PrevY = caller->Y();
caller->PrevZ = caller->z; caller->PrevZ = caller->Z();
} }
if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB)) if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB))
{ {
caller->z += reference->GetBobOffset(); caller->AddZ(reference->GetBobOffset());
} }
} }
return true; return true;
} }
caller->SetOrigin(oldx, oldy, oldz); caller->SetOrigin(old, true);
return false; return false;
} }

View file

@ -524,12 +524,12 @@ cont:
hity = StartY + FixedMul (Vy, dist); hity = StartY + FixedMul (Vy, dist);
hitz = StartZ + FixedMul (Vz, dist); hitz = StartZ + FixedMul (Vz, dist);
if (hitz > in->d.thing->z + in->d.thing->height) if (hitz > in->d.thing->Top())
{ // trace enters above actor { // trace enters above actor
if (Vz >= 0) continue; // Going up: can't hit if (Vz >= 0) continue; // Going up: can't hit
// Does it hit the top of the actor? // Does it hit the top of the actor?
dist = FixedDiv(in->d.thing->z + in->d.thing->height - StartZ, Vz); dist = FixedDiv(in->d.thing->Top() - StartZ, Vz);
if (dist > MaxDist) continue; if (dist > MaxDist) continue;
in->frac = FixedDiv(dist, MaxDist); in->frac = FixedDiv(dist, MaxDist);
@ -539,15 +539,15 @@ cont:
hitz = StartZ + FixedMul (Vz, dist); hitz = StartZ + FixedMul (Vz, dist);
// calculated coordinate is outside the actor's bounding box // calculated coordinate is outside the actor's bounding box
if (abs(hitx - in->d.thing->x) > in->d.thing->radius || if (abs(hitx - in->d.thing->X()) > in->d.thing->radius ||
abs(hity - in->d.thing->y) > in->d.thing->radius) continue; abs(hity - in->d.thing->Y()) > in->d.thing->radius) continue;
} }
else if (hitz < in->d.thing->z) else if (hitz < in->d.thing->Z())
{ // trace enters below actor { // trace enters below actor
if (Vz <= 0) continue; // Going down: can't hit if (Vz <= 0) continue; // Going down: can't hit
// Does it hit the bottom of the actor? // Does it hit the bottom of the actor?
dist = FixedDiv(in->d.thing->z - StartZ, Vz); dist = FixedDiv(in->d.thing->Z() - StartZ, Vz);
if (dist > MaxDist) continue; if (dist > MaxDist) continue;
in->frac = FixedDiv(dist, MaxDist); in->frac = FixedDiv(dist, MaxDist);
@ -556,8 +556,8 @@ cont:
hitz = StartZ + FixedMul (Vz, dist); hitz = StartZ + FixedMul (Vz, dist);
// calculated coordinate is outside the actor's bounding box // calculated coordinate is outside the actor's bounding box
if (abs(hitx - in->d.thing->x) > in->d.thing->radius || if (abs(hitx - in->d.thing->X()) > in->d.thing->radius ||
abs(hity - in->d.thing->y) > in->d.thing->radius) continue; abs(hity - in->d.thing->Y()) > in->d.thing->radius) continue;
} }
// check for extrafloors first // check for extrafloors first

View file

@ -671,10 +671,10 @@ void APlayerPawn::PostBeginPlay()
// Voodoo dolls: restore original floorz/ceilingz logic // Voodoo dolls: restore original floorz/ceilingz logic
if (player == NULL || player->mo != this) if (player == NULL || player->mo != this)
{ {
dropoffz = floorz = Sector->floorplane.ZatPoint(x, y); dropoffz = floorz = Sector->floorplane.ZatPoint(this);
ceilingz = Sector->ceilingplane.ZatPoint(x, y); ceilingz = Sector->ceilingplane.ZatPoint(this);
P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS); P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS);
z = floorz; SetZ(floorz);
} }
else else
{ {
@ -1553,7 +1553,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop)
} }
self->flags &= ~MF_SOLID; self->flags &= ~MF_SOLID;
mo = (APlayerPawn *)Spawn (spawntype, self->x, self->y, self->z + 48*FRACUNIT, NO_REPLACE); mo = (APlayerPawn *)Spawn (spawntype, self->PosPlusZ(48*FRACUNIT), NO_REPLACE);
//mo->target = self; //mo->target = self;
mo->velx = pr_skullpop.Random2() << 9; mo->velx = pr_skullpop.Random2() << 9;
mo->vely = pr_skullpop.Random2() << 9; mo->vely = pr_skullpop.Random2() << 9;
@ -1762,7 +1762,7 @@ void P_CalcHeight (player_t *player)
if (player->cheats & CF_NOVELOCITY) if (player->cheats & CF_NOVELOCITY)
{ {
player->viewz = player->mo->z + defaultviewheight; player->viewz = player->mo->Z() + defaultviewheight;
if (player->viewz > player->mo->ceilingz-4*FRACUNIT) if (player->viewz > player->mo->ceilingz-4*FRACUNIT)
player->viewz = player->mo->ceilingz-4*FRACUNIT; player->viewz = player->mo->ceilingz-4*FRACUNIT;
@ -1818,9 +1818,9 @@ void P_CalcHeight (player_t *player)
{ {
bob = 0; bob = 0;
} }
player->viewz = player->mo->z + player->viewheight + bob; player->viewz = player->mo->Z() + player->viewheight + bob;
if (player->mo->floorclip && player->playerstate != PST_DEAD if (player->mo->floorclip && player->playerstate != PST_DEAD
&& player->mo->z <= player->mo->floorz) && player->mo->Z() <= player->mo->floorz)
{ {
player->viewz -= player->mo->floorclip; player->viewz -= player->mo->floorclip;
} }
@ -1863,7 +1863,7 @@ void P_MovePlayer (player_t *player)
mo->angle += cmd->ucmd.yaw << 16; mo->angle += cmd->ucmd.yaw << 16;
} }
player->onground = (mo->z <= mo->floorz) || (mo->flags2 & MF2_ONMOBJ) || (mo->BounceFlags & BOUNCE_MBF) || (player->cheats & CF_NOCLIP2); player->onground = (mo->Z() <= mo->floorz) || (mo->flags2 & MF2_ONMOBJ) || (mo->BounceFlags & BOUNCE_MBF) || (player->cheats & CF_NOCLIP2);
// killough 10/98: // killough 10/98:
// //
@ -1920,7 +1920,7 @@ void P_MovePlayer (player_t *player)
{ {
fprintf (debugfile, "move player for pl %d%c: (%d,%d,%d) (%d,%d) %d %d w%d [", int(player-players), fprintf (debugfile, "move player for pl %d%c: (%d,%d,%d) (%d,%d) %d %d w%d [", int(player-players),
player->cheats&CF_PREDICTING?'p':' ', player->cheats&CF_PREDICTING?'p':' ',
player->mo->x, player->mo->y, player->mo->z,forwardmove, sidemove, movefactor, friction, player->mo->waterlevel); player->mo->X(), player->mo->Y(), player->mo->Z(),forwardmove, sidemove, movefactor, friction, player->mo->waterlevel);
msecnode_t *n = player->mo->touching_sectorlist; msecnode_t *n = player->mo->touching_sectorlist;
while (n != NULL) while (n != NULL)
{ {
@ -2052,7 +2052,7 @@ void P_DeathThink (player_t *player)
P_MovePsprites (player); P_MovePsprites (player);
player->onground = (player->mo->z <= player->mo->floorz); player->onground = (player->mo->Z() <= player->mo->floorz);
if (player->mo->IsKindOf (RUNTIME_CLASS(APlayerChunk))) if (player->mo->IsKindOf (RUNTIME_CLASS(APlayerChunk)))
{ // Flying bloody skull or flying ice chunk { // Flying bloody skull or flying ice chunk
player->viewheight = 6 * FRACUNIT; player->viewheight = 6 * FRACUNIT;
@ -2165,7 +2165,7 @@ void P_CrouchMove(player_t * player, int direction)
// check whether the move is ok // check whether the move is ok
player->mo->height = FixedMul(defaultheight, player->crouchfactor); player->mo->height = FixedMul(defaultheight, player->crouchfactor);
if (!P_TryMove(player->mo, player->mo->x, player->mo->y, false, NULL)) if (!P_TryMove(player->mo, player->mo->X(), player->mo->Y(), false, NULL))
{ {
player->mo->height = savedheight; player->mo->height = savedheight;
if (direction > 0) if (direction > 0)
@ -2182,7 +2182,7 @@ void P_CrouchMove(player_t * player, int direction)
player->crouchviewdelta = player->viewheight - player->mo->ViewHeight; player->crouchviewdelta = player->viewheight - player->mo->ViewHeight;
// Check for eyes going above/below fake floor due to crouching motion. // Check for eyes going above/below fake floor due to crouching motion.
P_CheckFakeFloorTriggers(player->mo, player->mo->z + oldheight, true); P_CheckFakeFloorTriggers(player->mo, player->mo->Z() + oldheight, true);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2203,7 +2203,7 @@ void P_PlayerThink (player_t *player)
if (debugfile && !(player->cheats & CF_PREDICTING)) if (debugfile && !(player->cheats & CF_PREDICTING))
{ {
fprintf (debugfile, "tic %d for pl %td: (%d, %d, %d, %u) b:%02x p:%d y:%d f:%d s:%d u:%d\n", fprintf (debugfile, "tic %d for pl %td: (%d, %d, %d, %u) b:%02x p:%d y:%d f:%d s:%d u:%d\n",
gametic, player-players, player->mo->x, player->mo->y, player->mo->z, gametic, player-players, player->mo->X(), player->mo->Y(), player->mo->Z(),
player->mo->angle>>ANGLETOFINESHIFT, player->cmd.ucmd.buttons, player->mo->angle>>ANGLETOFINESHIFT, player->cmd.ucmd.buttons,
player->cmd.ucmd.pitch, player->cmd.ucmd.yaw, player->cmd.ucmd.forwardmove, player->cmd.ucmd.pitch, player->cmd.ucmd.yaw, player->cmd.ucmd.forwardmove,
player->cmd.ucmd.sidemove, player->cmd.ucmd.upmove); player->cmd.ucmd.sidemove, player->cmd.ucmd.upmove);
@ -2329,7 +2329,7 @@ void P_PlayerThink (player_t *player)
player->crouching = 0; player->crouching = 0;
} }
if (crouchdir == 1 && player->crouchfactor < FRACUNIT && if (crouchdir == 1 && player->crouchfactor < FRACUNIT &&
player->mo->z + player->mo->height < player->mo->ceilingz) player->mo->Top() < player->mo->ceilingz)
{ {
P_CrouchMove(player, 1); P_CrouchMove(player, 1);
} }
@ -2542,8 +2542,7 @@ void P_PlayerThink (player_t *player)
P_PlayerOnSpecial3DFloor (player); P_PlayerOnSpecial3DFloor (player);
P_PlayerInSpecialSector (player); P_PlayerInSpecialSector (player);
if (player->mo->z <= player->mo->Sector->floorplane.ZatPoint( if (player->mo->Z() <= player->mo->Sector->floorplane.ZatPoint(player->mo) ||
player->mo->x, player->mo->y) ||
player->mo->waterlevel) player->mo->waterlevel)
{ {
// Player must be touching the floor // Player must be touching the floor
@ -2697,7 +2696,7 @@ void P_PredictPlayer (player_t *player)
PredictionPlayerBackup = *player; PredictionPlayerBackup = *player;
APlayerPawn *act = player->mo; APlayerPawn *act = player->mo;
memcpy(PredictionActorBackup, &act->x, sizeof(APlayerPawn) - ((BYTE *)&act->x - (BYTE *)act)); memcpy(PredictionActorBackup, &act->snext, sizeof(APlayerPawn) - ((BYTE *)&act->snext - (BYTE *)act));
act->flags &= ~MF_PICKUP; act->flags &= ~MF_PICKUP;
act->flags2 &= ~MF2_PUSHWALL; act->flags2 &= ~MF2_PUSHWALL;
@ -2769,16 +2768,16 @@ void P_PredictPlayer (player_t *player)
{ {
// Z is not compared as lifts will alter this with no apparent change // Z is not compared as lifts will alter this with no apparent change
// Make lerping less picky by only testing whole units // Make lerping less picky by only testing whole units
DoLerp = ((PredictionLast.x >> 16) != (player->mo->x >> 16) || DoLerp = ((PredictionLast.x >> 16) != (player->mo->X() >> 16) ||
(PredictionLast.y >> 16) != (player->mo->y >> 16)); (PredictionLast.y >> 16) != (player->mo->Y() >> 16));
// Aditional Debug information // Aditional Debug information
if (developer && DoLerp) if (developer && DoLerp)
{ {
DPrintf("Lerp! Ltic (%d) && Ptic (%d) | Lx (%d) && Px (%d) | Ly (%d) && Py (%d)\n", DPrintf("Lerp! Ltic (%d) && Ptic (%d) | Lx (%d) && Px (%d) | Ly (%d) && Py (%d)\n",
PredictionLast.gametic, i, PredictionLast.gametic, i,
(PredictionLast.x >> 16), (player->mo->x >> 16), (PredictionLast.x >> 16), (player->mo->X() >> 16),
(PredictionLast.y >> 16), (player->mo->y >> 16)); (PredictionLast.y >> 16), (player->mo->Y() >> 16));
} }
} }
} }
@ -2796,9 +2795,9 @@ void P_PredictPlayer (player_t *player)
} }
PredictionLast.gametic = maxtic - 1; PredictionLast.gametic = maxtic - 1;
PredictionLast.x = player->mo->x; PredictionLast.x = player->mo->X();
PredictionLast.y = player->mo->y; PredictionLast.y = player->mo->Y();
PredictionLast.z = player->mo->z; PredictionLast.z = player->mo->Z();
if (PredictionLerptics > 0) if (PredictionLerptics > 0)
{ {
@ -2806,9 +2805,7 @@ void P_PredictPlayer (player_t *player)
P_LerpCalculate(PredictionLerpFrom, PredictionLast, PredictionLerpResult, (float)PredictionLerptics * cl_predict_lerpscale)) P_LerpCalculate(PredictionLerpFrom, PredictionLast, PredictionLerpResult, (float)PredictionLerptics * cl_predict_lerpscale))
{ {
PredictionLerptics++; PredictionLerptics++;
player->mo->x = PredictionLerpResult.x; player->mo->SetXYZ(PredictionLerpResult.x, PredictionLerpResult.y, PredictionLerpResult.z);
player->mo->y = PredictionLerpResult.y;
player->mo->z = PredictionLerpResult.z;
} }
else else
{ {
@ -2840,7 +2837,7 @@ void P_UnPredictPlayer ()
player->camera = savedcamera; player->camera = savedcamera;
act->UnlinkFromWorld(); act->UnlinkFromWorld();
memcpy(&act->x, PredictionActorBackup, sizeof(APlayerPawn) - ((BYTE *)&act->x - (BYTE *)act)); memcpy(&act->snext, PredictionActorBackup, sizeof(APlayerPawn) - ((BYTE *)&act->snext - (BYTE *)act));
// The blockmap ordering needs to remain unchanged, too. // The blockmap ordering needs to remain unchanged, too.
// Restore sector links and refrences. // Restore sector links and refrences.
@ -3114,7 +3111,7 @@ void player_t::Serialize (FArchive &arc)
} }
else else
{ {
onground = (mo->z <= mo->floorz) || (mo->flags2 & MF2_ONMOBJ) || (mo->BounceFlags & BOUNCE_MBF) || (cheats & CF_NOCLIP2); onground = (mo->Z() <= mo->floorz) || (mo->flags2 & MF2_ONMOBJ) || (mo->BounceFlags & BOUNCE_MBF) || (cheats & CF_NOCLIP2);
} }
if (SaveVersion < 4514 && IsBot) if (SaveVersion < 4514 && IsBot)

View file

@ -69,9 +69,9 @@ DEFINE_MEMBER_VARIABLE(special2, AActor)
DEFINE_MEMBER_VARIABLE(tid, AActor) DEFINE_MEMBER_VARIABLE(tid, AActor)
DEFINE_MEMBER_VARIABLE(TIDtoHate, AActor) DEFINE_MEMBER_VARIABLE(TIDtoHate, AActor)
DEFINE_MEMBER_VARIABLE(waterlevel, AActor) DEFINE_MEMBER_VARIABLE(waterlevel, AActor)
DEFINE_MEMBER_VARIABLE(x, AActor) DEFINE_MEMBER_VARIABLE_ALIAS(x, __pos.x, AActor)
DEFINE_MEMBER_VARIABLE(y, AActor) DEFINE_MEMBER_VARIABLE_ALIAS(y, __pos.y, AActor)
DEFINE_MEMBER_VARIABLE(z, AActor) DEFINE_MEMBER_VARIABLE_ALIAS(z, __pos.z, AActor)
DEFINE_MEMBER_VARIABLE(velx, AActor) DEFINE_MEMBER_VARIABLE(velx, AActor)
DEFINE_MEMBER_VARIABLE(vely, AActor) DEFINE_MEMBER_VARIABLE(vely, AActor)
DEFINE_MEMBER_VARIABLE(velz, AActor) DEFINE_MEMBER_VARIABLE(velz, AActor)