diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eb190f8b0..da2f319e1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1373,6 +1373,7 @@ source_group("Games\\Hexen Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR source_group("Games\\Raven Shared" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_raven/.+") source_group("Games\\Strife Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_strife/.+") source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+") +source_group("Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/math/.+") source_group("Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/menu/.+") source_group("Render Core\\Render Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_.+\\.h$") source_group("Render Core\\Render Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_.+\\.cpp$") diff --git a/src/actor.h b/src/actor.h index 88e6d5db4..15599aff3 100644 --- a/src/actor.h +++ b/src/actor.h @@ -25,6 +25,7 @@ // Basics. #include "tables.h" +#include "templates.h" // We need the thinker_t stuff. #include "dthinker.h" @@ -571,6 +572,7 @@ public: fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); // since we cannot include p_local here... angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2); // same reason here with r_defs.h +const double MinVel = 1. / 65536; // Map Object definition. class AActor : public DThinker @@ -815,97 +817,109 @@ public: fixed_t AproxDistance(fixed_t otherx, fixed_t othery) { - return P_AproxDistance(X() - otherx, Y() - othery); + return P_AproxDistance(_f_X() - otherx, _f_Y() - othery); } fixed_t __f_AngleTo(fixed_t otherx, fixed_t othery) { - return R_PointToAngle2(X(), Y(), otherx, othery); + return R_PointToAngle2(_f_X(), _f_Y(), otherx, othery); } fixed_t __f_AngleTo(fixedvec2 other) { - return R_PointToAngle2(X(), Y(), other.x, other.y); + return R_PointToAngle2(_f_X(), _f_Y(), other.x, other.y); } // 'absolute' is reserved for a linked portal implementation which needs // to distinguish between portal-aware and portal-unaware distance calculation. fixed_t AproxDistance(AActor *other, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); - return P_AproxDistance(X() - otherpos.x, Y() - otherpos.y); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->PosRelative(this); + return P_AproxDistance(_f_X() - otherpos.x, _f_Y() - otherpos.y); } fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); - return P_AproxDistance(X() - otherpos.x + xadd, Y() - otherpos.y + yadd); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->PosRelative(this); + return P_AproxDistance(_f_X() - otherpos.x + xadd, _f_Y() - otherpos.y + yadd); } fixed_t AproxDistance3D(AActor *other, bool absolute = false) { - return P_AproxDistance(AproxDistance(other), Z() - other->Z()); + return P_AproxDistance(AproxDistance(other), _f_Z() - other->_f_Z()); } // more precise, but slower version, being used in a few places double Distance2D(AActor *other, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); - return (DVector2(X() - otherpos.x, Y() - otherpos.y).Length())/FRACUNIT; + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->PosRelative(this); + return (DVector2(_f_X() - otherpos.x, _f_Y() - otherpos.y).Length())/FRACUNIT; } // a full 3D version of the above fixed_t Distance3D(AActor *other, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); - return xs_RoundToInt(DVector3(X() - otherpos.x, Y() - otherpos.y, Z() - otherpos.z).Length()); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->PosRelative(this); + return xs_RoundToInt(DVector3(_f_X() - otherpos.x, _f_Y() - otherpos.y, _f_Z() - otherpos.z).Length()); } angle_t __f_AngleTo(AActor *other, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); - return R_PointToAngle2(X(), Y(), otherpos.x, otherpos.y); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->PosRelative(this); + return R_PointToAngle2(_f_X(), _f_Y(), otherpos.x, otherpos.y); } angle_t __f_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(_f_X(), _f_Y(), other->_f_X() + oxofs, other->_f_Y() + oyofs); } DAngle AngleTo(AActor *other, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); - return VecToAngle(otherpos.x - X(), otherpos.y - Y()); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->PosRelative(this); + return VecToAngle(otherpos.x - _f_X(), otherpos.y - _f_Y()); } DAngle AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const { - fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); - return VecToAngle(otherpos.y + oxofs - Y(), otherpos.x + oyofs - X()); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->PosRelative(this); + return VecToAngle(otherpos.y + oxofs - _f_Y(), otherpos.x + oyofs - _f_X()); } - fixedvec2 Vec2To(AActor *other) const + fixedvec2 _f_Vec2To(AActor *other) const { fixedvec3 otherpos = other->PosRelative(this); - fixedvec2 ret = { otherpos.x - X(), otherpos.y - Y() }; + fixedvec2 ret = { otherpos.x - _f_X(), otherpos.y - _f_Y() }; return ret; } - fixedvec3 Vec3To(AActor *other) const + fixedvec3 _f_Vec3To(AActor *other) const { fixedvec3 otherpos = other->PosRelative(this); - fixedvec3 ret = { otherpos.x - X(), otherpos.y - Y(), otherpos.z - Z() }; + fixedvec3 ret = { otherpos.x - _f_X(), otherpos.y - _f_Y(), otherpos.z - _f_Z() }; return ret; } + DVector2 Vec2To(AActor *other) const + { + fixedvec3 otherpos = other->PosRelative(this); + return{ FIXED2DBL(otherpos.x - _f_X()), FIXED2DBL(otherpos.y - _f_Y()) }; + } + + DVector3 Vec3To(AActor *other) const + { + fixedvec3 otherpos = other->PosRelative(this); + return { FIXED2DBL(otherpos.x - _f_X()), FIXED2DBL(otherpos.y - _f_Y()), FIXED2DBL(otherpos.z - _f_Z()) }; + } + fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false) { if (absolute) { - fixedvec2 ret = { X() + dx, Y() + dy }; + fixedvec2 ret = { _f_X() + dx, _f_Y() + dy }; return ret; } - else return P_GetOffsetPosition(X(), Y(), dx, dy); + else return P_GetOffsetPosition(_f_X(), _f_Y(), dx, dy); } @@ -913,44 +927,57 @@ public: { if (absolute) { - fixedvec2 ret = { X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), - Y() + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) }; + fixedvec2 ret = { _f_X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), + _f_Y() + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) }; return ret; } - else return P_GetOffsetPosition(X(), Y(), FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), FixedMul(length, finesine[angle >> ANGLETOFINESHIFT])); + else return P_GetOffsetPosition(_f_X(), _f_Y(), FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), FixedMul(length, finesine[angle >> ANGLETOFINESHIFT])); } fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) { if (absolute) { - fixedvec3 ret = { X() + dx, Y() + dy, Z() + dz }; + fixedvec3 ret = { _f_X() + dx, _f_Y() + dy, _f_Z() + dz }; return ret; } else { - fixedvec2 op = P_GetOffsetPosition(X(), Y(), dx, dy); - fixedvec3 pos = { op.x, op.y, Z() + dz }; + fixedvec2 op = P_GetOffsetPosition(_f_X(), _f_Y(), dx, dy); + fixedvec3 pos = { op.x, op.y, _f_Z() + dz }; return pos; } } - fixedvec3 Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false) + fixedvec3 _f_Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false) { if (absolute) { - fixedvec3 ret = { X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), - Y() + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), Z() + dz }; + fixedvec3 ret = { _f_X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), + _f_Y() + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), _f_Z() + dz }; return ret; } else { - fixedvec2 op = P_GetOffsetPosition(X(), Y(), FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), FixedMul(length, finesine[angle >> ANGLETOFINESHIFT])); - fixedvec3 pos = { op.x, op.y, Z() + dz }; + fixedvec2 op = P_GetOffsetPosition(_f_X(), _f_Y(), FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), FixedMul(length, finesine[angle >> ANGLETOFINESHIFT])); + fixedvec3 pos = { op.x, op.y, _f_Z() + dz }; return pos; } } + DVector3 Vec3Angle(double length, DAngle angle, double dz, bool absolute = false) + { + if (absolute) + { + return{ X() + length * angle.Cos(), Y() + length * angle.Sin(), Z() + dz }; + } + else + { + fixedvec2 op = P_GetOffsetPosition(_f_X(), _f_Y(), FLOAT2FIXED(length*angle.Cos()), FLOAT2FIXED(length*angle.Sin())); + return{ FIXED2DBL(op.x), FIXED2DBL(op.y), Z() + dz }; + } + } + double AccuracyFactor() { return 1. / (1 << (accuracy * 5 / 100)); @@ -960,7 +987,7 @@ public: void Move(fixed_t dx, fixed_t dy, fixed_t dz) { - SetOrigin(X() + dx, Y() + dy, Z() + dz, true); + SetOrigin(_f_X() + dx, _f_Y() + dy, _f_Z() + dz, true); } void SetOrigin(const fixedvec3 & npos, bool moving) @@ -968,6 +995,11 @@ public: SetOrigin(npos.x, npos.y, npos.z, moving); } + void SetOrigin(const DVector3 & npos, bool moving) + { + SetOrigin(FLOAT2FIXED(npos.X), FLOAT2FIXED(npos.Y), FLOAT2FIXED(npos.Z), moving); + } + inline void SetFriendPlayer(player_t *player); bool IsVisibleToPlayer() const; @@ -977,7 +1009,7 @@ public: bool CanSeek(AActor *target) const; - fixed_t GetGravity() const; + double GetGravity() const; bool IsSentient() const; const char *GetTag(const char *def = NULL) const; void SetTag(const char *def); @@ -994,14 +1026,23 @@ public: angle_t angle; fixed_t pitch; angle_t roll; // This was fixed_t before, which is probably wrong + fixedvec3 vel; */ DRotator Angles; + DVector3 Vel; + double Speed; + double FloatSpeed; // intentionally stange names so that searching for them is easier. angle_t _f_angle() { return FLOAT2ANGLE(Angles.Yaw.Degrees); } int _f_pitch() { return FLOAT2ANGLE(Angles.Pitch.Degrees); } angle_t _f_roll() { return FLOAT2ANGLE(Angles.Roll.Degrees); } + fixed_t _f_velx() { return FLOAT2FIXED(Vel.X); } + fixed_t _f_vely() { return FLOAT2FIXED(Vel.Y); } + fixed_t _f_velz() { return FLOAT2FIXED(Vel.Z); } + fixed_t _f_speed() { return FLOAT2FIXED(Speed); } + fixed_t _f_floatspeed() { return FLOAT2FIXED(FloatSpeed); } WORD sprite; // used to find patch_t and flip value @@ -1028,7 +1069,6 @@ public: FTextureID ceilingpic; // contacted sec ceilingpic fixed_t radius, height; // for movement checking fixed_t projectilepassheight; // height for clipping projectile movement against this actor - fixedvec3 vel; SDWORD tics; // state tic counter FState *state; VMFunction *Damage; // For missiles and monster railgun @@ -1143,8 +1183,6 @@ public: FSoundIDNoInit WallBounceSound; FSoundIDNoInit CrushPainSound; - fixed_t Speed; - fixed_t FloatSpeed; fixed_t MaxDropOffHeight, MaxStepHeight; SDWORD Mass; SWORD PainChance; @@ -1229,23 +1267,40 @@ public: bool HasSpecialDeathStates () const; - fixed_t X() const + fixed_t _f_X() const { return __pos.x; } - fixed_t Y() const + fixed_t _f_Y() const { return __pos.y; } - fixed_t Z() const + fixed_t _f_Z() const { return __pos.z; } - fixedvec3 Pos() const + fixedvec3 _f_Pos() const { return __pos; } + double X() const + { + return FIXED2DBL(__pos.x); + } + double Y() const + { + return FIXED2DBL(__pos.y); + } + double Z() const + { + return FIXED2DBL(__pos.z); + } + DVector3 Pos() const + { + return DVector3(X(), Y(), Z()); + } + fixedvec3 PosRelative(int grp) const; fixedvec3 PosRelative(const AActor *other) const; fixedvec3 PosRelative(sector_t *sec) const; @@ -1253,42 +1308,74 @@ public: fixed_t SoundX() const { - return X(); + return _f_X(); } fixed_t SoundY() const { - return Y(); + return _f_Y(); } fixed_t SoundZ() const { - return Z(); + return _f_Z(); } fixedvec3 InterpolatedPosition(fixed_t ticFrac) const { fixedvec3 ret; - ret.x = PrevX + FixedMul (ticFrac, X() - PrevX); - ret.y = PrevY + FixedMul (ticFrac, Y() - PrevY); - ret.z = PrevZ + FixedMul (ticFrac, Z() - PrevZ); + ret.x = PrevX + FixedMul (ticFrac, _f_X() - PrevX); + ret.y = PrevY + FixedMul (ticFrac, _f_Y() - PrevY); + ret.z = PrevZ + FixedMul (ticFrac, _f_Z() - PrevZ); return ret; } fixedvec3 PosPlusZ(fixed_t zadd) const { - fixedvec3 ret = { X(), Y(), Z() + zadd }; + fixedvec3 ret = { _f_X(), _f_Y(), _f_Z() + zadd }; return ret; } - fixed_t Top() const + fixed_t _f_Top() const { - return Z() + height; + return _f_Z() + height; } - void SetZ(fixed_t newz, bool moving = true) + void _f_SetZ(fixed_t newz, bool moving = true) { __pos.z = newz; } - void AddZ(fixed_t newz, bool moving = true) + void _f_AddZ(fixed_t newz, bool moving = true) { __pos.z += newz; } + double Top() const + { + return Z() + FIXED2DBL(height); + } + double Center() const + { + return Z() + FIXED2DBL(height/2); + } + double _Height() const + { + return FIXED2DBL(height); + } + double _Radius() const + { + return FIXED2DBL(radius); + } + double _pushfactor() const + { + return FIXED2DBL(pushfactor); + } + double _bouncefactor() const + { + return FIXED2DBL(bouncefactor); + } + void SetZ(double newz, bool moving = true) + { + __pos.z = FLOAT2FIXED(newz); + } + void AddZ(double newz, bool moving = true) + { + __pos.z += FLOAT2FIXED(newz); + } // These are not for general use as they do not link the actor into the world! void SetXY(fixed_t xx, fixed_t yy) @@ -1314,53 +1401,78 @@ public: __pos.z = npos.z; } - fixed_t VelXYToSpeed() const + double VelXYToSpeed() const { - return xs_CRoundToInt(sqrt((double)vel.x * vel.x + (double)vel.y*vel.y)); + return DVector2(Vel.X, Vel.Y).Length(); } - fixed_t VelToSpeed() const + double VelToSpeed() const { - return xs_CRoundToInt(sqrt((double)vel.x * vel.x + (double)vel.y*vel.y + (double)vel.z*vel.z)); + return Vel.Length(); } void AngleFromVel() { - Angles.Yaw = VecToAngle(vel.x, vel.y); + Angles.Yaw = VecToAngle(Vel.X, Vel.Y); } void VelFromAngle() { - vel.x = xs_CRoundToInt(Speed * Angles.Yaw.Cos()); - vel.y = xs_CRoundToInt(Speed * Angles.Yaw.Sin()); + Vel.X = Speed * Angles.Yaw.Cos(); + Vel.Y = Speed * Angles.Yaw.Sin(); } - void VelFromAngle(fixed_t speed) + void VelFromAngle(double speed) { - vel.x = xs_CRoundToInt(speed * Angles.Yaw.Cos()); - vel.y = xs_CRoundToInt(speed * Angles.Yaw.Sin()); + Vel.X = speed * Angles.Yaw.Cos(); + Vel.Y = speed * Angles.Yaw.Sin(); } - void VelFromAngle(DAngle angle, fixed_t speed) + void VelFromAngle(DAngle angle, double speed) { - vel.x = xs_CRoundToInt(speed * angle.Cos()); - vel.y = xs_CRoundToInt(speed * angle.Sin()); + Vel.X = speed * angle.Cos(); + Vel.Y = speed * angle.Sin(); } - void Vel3DFromAngle(DAngle angle, DAngle pitch, fixed_t speed) + void Thrust() + { + Vel.X += Speed * Angles.Yaw.Cos(); + Vel.Y += Speed * Angles.Yaw.Sin(); + } + + void Thrust(double speed) + { + Vel.X += speed * Angles.Yaw.Cos(); + Vel.Y += speed * Angles.Yaw.Sin(); + } + + void Thrust(DAngle angle, double speed) + { + Vel.X += speed * angle.Cos(); + Vel.Y += speed * angle.Sin(); + } + + void Vel3DFromAngle(DAngle angle, DAngle pitch, double speed) { double cospitch = pitch.Cos(); - vel.x = xs_CRoundToInt(speed * cospitch * angle.Cos()); - vel.y = xs_CRoundToInt(speed * cospitch * angle.Sin()); - vel.z = xs_CRoundToInt(speed * -pitch.Sin()); + Vel.X = speed * cospitch * angle.Cos(); + Vel.Y = speed * cospitch * angle.Sin(); + Vel.Z = speed * -pitch.Sin(); } - void Vel3DFromAngle(DAngle pitch, fixed_t speed) + void Vel3DFromAngle(DAngle pitch, double speed) { double cospitch = pitch.Cos(); - vel.x = xs_CRoundToInt(speed * cospitch * Angles.Yaw.Cos()); - vel.y = xs_CRoundToInt(speed * cospitch * Angles.Yaw.Sin()); - vel.z = xs_CRoundToInt(speed * -pitch.Sin()); + Vel.X = speed * cospitch * Angles.Yaw.Cos(); + Vel.Y = speed * cospitch * Angles.Yaw.Sin(); + Vel.Z = speed * -pitch.Sin(); + } + + // This is used by many vertical velocity calculations. + // Better have it in one place, if something needs to be changed about the formula. + double DistanceBySpeed(AActor *dest, double speed) + { + return MAX(1., Distance2D(dest) / speed); } }; @@ -1440,6 +1552,11 @@ inline AActor *Spawn (PClassActor *type, const fixedvec3 &pos, replace_t allowre return AActor::StaticSpawn (type, pos.x, pos.y, pos.z, allowreplacement); } +inline AActor *Spawn(PClassActor *type, const DVector3 &pos, replace_t allowreplacement) +{ + return Spawn(type, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), allowreplacement); +} + AActor *Spawn (const char *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement); AActor *Spawn (FName classname, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement); @@ -1448,11 +1565,21 @@ inline AActor *Spawn (const char *type, const fixedvec3 &pos, replace_t allowrep return Spawn (type, pos.x, pos.y, pos.z, allowreplacement); } +inline AActor *Spawn(const char *type, const DVector3 &pos, replace_t allowreplacement) +{ + return Spawn(type, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), allowreplacement); +} + inline AActor *Spawn (FName classname, const fixedvec3 &pos, replace_t allowreplacement) { return Spawn (classname, pos.x, pos.y, pos.z, allowreplacement); } +inline AActor *Spawn(FName type, const DVector3 &pos, replace_t allowreplacement) +{ + return Spawn(type, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), allowreplacement); +} + template inline T *Spawn (fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) @@ -1466,7 +1593,13 @@ inline T *Spawn (const fixedvec3 &pos, replace_t allowreplacement) return static_cast(AActor::StaticSpawn (RUNTIME_TEMPLATE_CLASS(T), pos.x, pos.y, pos.z, allowreplacement)); } -inline fixedvec2 Vec2Angle(fixed_t length, angle_t angle) +template +inline T *Spawn(const DVector3 &pos, replace_t allowreplacement) +{ + return static_cast(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), allowreplacement)); +} + +inline fixedvec2 Vec2Angle(fixed_t length, angle_t angle) { fixedvec2 ret = { FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) }; diff --git a/src/am_map.cpp b/src/am_map.cpp index 02b34b9cf..18a711fc9 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1012,8 +1012,8 @@ void AM_restoreScaleAndLoc () } else { - m_x = (players[consoleplayer].camera->X() >> FRACTOMAPBITS) - m_w/2; - m_y = (players[consoleplayer].camera->Y() >> FRACTOMAPBITS)- m_h/2; + m_x = (players[consoleplayer].camera->_f_X() >> FRACTOMAPBITS) - m_w/2; + m_y = (players[consoleplayer].camera->_f_Y() >> FRACTOMAPBITS)- m_h/2; } m_x2 = m_x + m_w; m_y2 = m_y + m_h; @@ -1263,8 +1263,8 @@ void AM_initVariables () if (playeringame[pnum]) break; assert(pnum >= 0 && pnum < MAXPLAYERS); - m_x = (players[pnum].camera->X() >> FRACTOMAPBITS) - m_w/2; - m_y = (players[pnum].camera->Y() >> FRACTOMAPBITS) - m_h/2; + m_x = (players[pnum].camera->_f_X() >> FRACTOMAPBITS) - m_w/2; + m_y = (players[pnum].camera->_f_Y() >> FRACTOMAPBITS) - m_h/2; AM_changeWindowLoc(); // for saving & restoring @@ -1585,25 +1585,25 @@ void AM_doFollowPlayer () fixed_t sx, sy; if (players[consoleplayer].camera != NULL && - (f_oldloc.x != players[consoleplayer].camera->X() || - f_oldloc.y != players[consoleplayer].camera->Y())) + (f_oldloc.x != players[consoleplayer].camera->_f_X() || + f_oldloc.y != players[consoleplayer].camera->_f_Y())) { - m_x = (players[consoleplayer].camera->X() >> FRACTOMAPBITS) - m_w/2; - m_y = (players[consoleplayer].camera->Y() >> FRACTOMAPBITS) - m_h/2; + m_x = (players[consoleplayer].camera->_f_X() >> FRACTOMAPBITS) - m_w/2; + m_y = (players[consoleplayer].camera->_f_Y() >> FRACTOMAPBITS) - m_h/2; m_x2 = m_x + m_w; m_y2 = m_y + m_h; // do the parallax parchment scrolling. - sx = (players[consoleplayer].camera->X() - f_oldloc.x) >> FRACTOMAPBITS; - sy = (f_oldloc.y - players[consoleplayer].camera->Y()) >> FRACTOMAPBITS; + sx = (players[consoleplayer].camera->_f_X() - f_oldloc.x) >> FRACTOMAPBITS; + sy = (f_oldloc.y - players[consoleplayer].camera->_f_Y()) >> FRACTOMAPBITS; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotate (&sx, &sy, players[consoleplayer].camera->_f_angle() - ANG90); } AM_ScrollParchment (sx, sy); - f_oldloc.x = players[consoleplayer].camera->X(); - f_oldloc.y = players[consoleplayer].camera->Y(); + f_oldloc.x = players[consoleplayer].camera->_f_X(); + f_oldloc.y = players[consoleplayer].camera->_f_Y(); } } @@ -2668,7 +2668,7 @@ void AM_drawPlayers () mline_t *arrow; int numarrowlines; - fixedvec2 pos = am_portaloverlay? players[consoleplayer].camera->GetPortalTransition(players[consoleplayer].viewheight) : (fixedvec2)players[consoleplayer].camera->Pos(); + fixedvec2 pos = am_portaloverlay? players[consoleplayer].camera->GetPortalTransition(players[consoleplayer].viewheight) : (fixedvec2)players[consoleplayer].camera->_f_Pos(); pt.x = pos.x >> FRACTOMAPBITS; pt.y = pos.y >> FRACTOMAPBITS; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) @@ -3041,7 +3041,7 @@ void AM_drawAuthorMarkers () marked->subsector->flags & SSECF_DRAWN : marked->Sector->MoreFlags & SECF_DRAWN))) { - DrawMarker (tex, marked->X() >> FRACTOMAPBITS, marked->Y() >> FRACTOMAPBITS, 0, + DrawMarker (tex, marked->_f_X() >> FRACTOMAPBITS, marked->_f_Y() >> FRACTOMAPBITS, 0, flip, mark->scaleX, mark->scaleY, mark->Translation, mark->alpha, mark->fillcolor, mark->RenderStyle); } diff --git a/src/b_func.cpp b/src/b_func.cpp index a84da259c..b9dbf4cba 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -44,7 +44,7 @@ bool DBot::Reachable (AActor *rtarget) fixed_t estimated_dist = player->mo->AproxDistance(rtarget); bool reachable = true; - FPathTraverse it(player->mo->X()+player->mo->vel.x, player->mo->Y()+player->mo->vel.y, rtarget->X(), rtarget->Y(), PT_ADDLINES|PT_ADDTHINGS); + FPathTraverse it(player->mo->_f_X()+player->mo->_f_velx(), player->mo->_f_Y()+player->mo->_f_vely(), rtarget->_f_X(), rtarget->_f_Y(), PT_ADDLINES|PT_ADDTHINGS); intercept_t *in; while ((in = it.Next())) { @@ -58,8 +58,8 @@ bool DBot::Reachable (AActor *rtarget) frac = in->frac - FixedDiv (4*FRACUNIT, MAX_TRAVERSE_DIST); dist = FixedMul (frac, MAX_TRAVERSE_DIST); - hitx = it.Trace().x + FixedMul (player->mo->vel.x, frac); - hity = it.Trace().y + FixedMul (player->mo->vel.y, frac); + hitx = it.Trace().x + FixedMul (player->mo->_f_velx(), frac); + hity = it.Trace().y + FixedMul (player->mo->_f_vely(), frac); if (in->isaline) { @@ -170,7 +170,7 @@ void DBot::Dofire (ticcmd_t *cmd) no_fire = true; //Distance to enemy. - dist = player->mo->AproxDistance(enemy, player->mo->vel.x - enemy->vel.x, player->mo->vel.y - enemy->vel.y); + dist = player->mo->AproxDistance(enemy, player->mo->_f_velx() - enemy->_f_velx(), player->mo->_f_vely() - enemy->_f_vely()); //FIRE EACH TYPE OF WEAPON DIFFERENT: Here should all the different weapons go. if (player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON) @@ -222,8 +222,8 @@ void DBot::Dofire (ticcmd_t *cmd) // prediction aiming shootmissile: dist = player->mo->AproxDistance (enemy); - m = dist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->Speed; - bglobal.SetBodyAt (enemy->X() + enemy->vel.x*m*2, enemy->Y() + enemy->vel.y*m*2, enemy->Z(), 1); + m = dist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->_f_speed(); + bglobal.SetBodyAt (enemy->_f_X() + enemy->_f_velx()*m*2, enemy->_f_Y() + enemy->_f_vely()*m*2, enemy->_f_Z(), 1); angle = player->mo->__f_AngleTo(bglobal.body1); if (Check_LOS (enemy, SHOOTFOV)) no_fire = false; @@ -467,22 +467,16 @@ fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd) th->target = source; // where it came from - float speed = (float)th->Speed; - fixedvec3 fixvel = source->Vec3To(dest); - DVector3 velocity(fixvel.x, fixvel.y, fixvel.z); - velocity.MakeUnit(); - th->vel.x = FLOAT2FIXED(velocity[0] * speed); - th->vel.y = FLOAT2FIXED(velocity[1] * speed); - th->vel.z = FLOAT2FIXED(velocity[2] * speed); + th->Vel = source->Vec3To(dest).Resized(th->Speed); fixed_t dist = 0; while (dist < SAFE_SELF_MISDIST) { - dist += th->Speed; - th->Move(th->vel.x, th->vel.y, th->vel.z); - if (!CleanAhead (th, th->X(), th->Y(), cmd)) + dist += th->_f_speed(); + th->Move(th->_f_velx(), th->_f_vely(), th->_f_velz()); + if (!CleanAhead (th, th->_f_X(), th->_f_Y(), cmd)) break; } th->Destroy (); @@ -496,9 +490,9 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd) AActor *actor; int m; - bglobal.SetBodyAt (player->mo->X() + FixedMul(player->mo->vel.x, 5*FRACUNIT), - player->mo->Y() + FixedMul(player->mo->vel.y, 5*FRACUNIT), - player->mo->Z() + (player->mo->height / 2), 2); + bglobal.SetBodyAt (player->mo->_f_X() + FixedMul(player->mo->_f_velx(), 5*FRACUNIT), + player->mo->_f_Y() + FixedMul(player->mo->_f_vely(), 5*FRACUNIT), + player->mo->_f_Z() + (player->mo->height / 2), 2); actor = bglobal.body2; @@ -506,16 +500,16 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd) if (dist < SAFE_SELF_MISDIST) return 0; //Predict. - m = (((dist+1)/FRACUNIT) / GetDefaultByName("Rocket")->Speed); + m = (((dist+1)/FRACUNIT) / GetDefaultByName("Rocket")->_f_speed()); - bglobal.SetBodyAt (enemy->X() + FixedMul(enemy->vel.x, (m+2*FRACUNIT)), - enemy->Y() + FixedMul(enemy->vel.y, (m+2*FRACUNIT)), ONFLOORZ, 1); + bglobal.SetBodyAt (enemy->_f_X() + FixedMul(enemy->_f_velx(), (m+2*FRACUNIT)), + enemy->_f_Y() + FixedMul(enemy->_f_vely(), (m+2*FRACUNIT)), ONFLOORZ, 1); //try the predicted location if (P_CheckSight (actor, bglobal.body1, SF_IGNOREVISIBILITY)) //See the predicted location, so give a test missile { FCheckPosition tm; - if (bglobal.SafeCheckPosition (player->mo, actor->X(), actor->Y(), tm)) + if (bglobal.SafeCheckPosition (player->mo, actor->_f_X(), actor->_f_Y(), tm)) { if (bglobal.FakeFire (actor, bglobal.body1, cmd) >= SAFE_SELF_MISDIST) { diff --git a/src/b_move.cpp b/src/b_move.cpp index 94b15ecfb..78fc1c916 100644 --- a/src/b_move.cpp +++ b/src/b_move.cpp @@ -71,8 +71,8 @@ bool DBot::Move (ticcmd_t *cmd) if ((unsigned)player->mo->movedir >= 8) I_Error ("Weird bot movedir!"); - tryx = player->mo->X() + 8*xspeed[player->mo->movedir]; - tryy = player->mo->Y() + 8*yspeed[player->mo->movedir]; + tryx = player->mo->_f_X() + 8*xspeed[player->mo->movedir]; + tryy = player->mo->_f_Y() + 8*yspeed[player->mo->movedir]; try_ok = bglobal.CleanAhead (player->mo, tryx, tryy, cmd); @@ -148,7 +148,7 @@ void DBot::NewChaseDir (ticcmd_t *cmd) olddir = (dirtype_t)player->mo->movedir; turnaround = opposite[olddir]; - fixedvec2 delta = player->mo->Vec2To(dest); + fixedvec2 delta = player->mo->_f_Vec2To(dest); if (delta.x > 10*FRACUNIT) d[1] = DI_EAST; @@ -284,7 +284,7 @@ bool FCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cm if ( !(thing->flags & MF_TELEPORT) && - tm.ceilingz - thing->Z() < thing->height) + tm.ceilingz - thing->_f_Z() < thing->height) return false; // mobj must lower itself to fit // jump out of water @@ -292,7 +292,7 @@ bool FCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cm // maxstep=37*FRACUNIT; if ( !(thing->flags & MF_TELEPORT) && - (tm.floorz - thing->Z() > maxstep ) ) + (tm.floorz - thing->_f_Z() > maxstep ) ) return false; // too big a step up @@ -348,7 +348,7 @@ void DBot::Pitch (AActor *target) double aim; double diff; - diff = target->Z() - player->mo->Z(); + diff = target->_f_Z() - player->mo->_f_Z(); aim = g_atan(diff / (double)player->mo->AproxDistance(target)); player->mo->Angles.Pitch = ToDegrees(aim); } diff --git a/src/b_think.cpp b/src/b_think.cpp index eb86d5af6..0d02f76f8 100644 --- a/src/b_think.cpp +++ b/src/b_think.cpp @@ -87,7 +87,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd) dist = dest ? player->mo->AproxDistance(dest) : 0; if (missile && - ((!missile->vel.x || !missile->vel.y) || !Check_LOS(missile, SHOOTFOV*3/2))) + ((!missile->_f_velx() || !missile->_f_vely()) || !Check_LOS(missile, SHOOTFOV*3/2))) { sleft = !sleft; missile = NULL; //Probably ended its travel. @@ -306,8 +306,8 @@ void DBot::ThinkForMove (ticcmd_t *cmd) if (t_fight<(AFTERTICS/2)) player->mo->flags |= MF_DROPOFF; - oldx = player->mo->X(); - oldy = player->mo->Y(); + oldx = player->mo->_f_X(); + oldy = player->mo->_f_Y(); } //BOT_WhatToGet diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 4880519cf..e6fa0d5e2 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -943,9 +943,8 @@ static void PrintFilteredActorList(const ActorTypeChecker IsActorType, const cha { if ((FilterClass == NULL || mo->IsA(FilterClass)) && IsActorType(mo)) { - Printf ("%s at (%d,%d,%d)\n", - mo->GetClass()->TypeName.GetChars(), - mo->X() >> FRACBITS, mo->Y() >> FRACBITS, mo->Z() >> FRACBITS); + Printf ("%s at (%f,%f,%f)\n", + mo->GetClass()->TypeName.GetChars(), mo->X(), mo->Y(), mo->Z()); } } } @@ -1087,7 +1086,7 @@ CCMD(currentpos) if(mo) { Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, lightlevel: %d\n", - FIXED2DBL(mo->X()), FIXED2DBL(mo->Y()), FIXED2DBL(mo->Z()), ANGLE2DBL(mo->_f_angle()), FIXED2DBL(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel); + mo->X(), mo->Y(), mo->Z(), mo->Angles.Yaw, FIXED2DBL(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel); } else { diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 6ad966682..40abf1961 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -915,7 +915,7 @@ static int PatchThing (int thingy) { if (stricmp (Line1, "Speed") == 0) { - info->Speed = val; + info->Speed = val; // handle fixed point later. } else if (stricmp (Line1, "Width") == 0) { @@ -1278,9 +1278,9 @@ static int PatchThing (int thingy) } // If this thing's speed is really low (i.e. meant to be a monster), // bump it up, because all speeds are fixed point now. - if (abs(info->Speed) < 256) + if (fabs(info->Speed) >= 256) { - info->Speed <<= FRACBITS; + info->Speed /= FRACUNIT; } if (info->flags & MF_SPECIAL) diff --git a/src/d_net.cpp b/src/d_net.cpp index 7206b7d4c..2dac938aa 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2321,7 +2321,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) else { const AActor *def = GetDefaultByType (typeinfo); - fixedvec3 spawnpos = source->Vec3Angle(def->radius * 2 + source->radius, source->_f_angle(), 8 * FRACUNIT); + fixedvec3 spawnpos = source->_f_Vec3Angle(def->radius * 2 + source->radius, source->_f_angle(), 8 * FRACUNIT); AActor *spawned = Spawn (typeinfo, spawnpos, ALLOW_REPLACE); if (spawned != NULL) @@ -2374,8 +2374,8 @@ void Net_DoCommand (int type, BYTE **stream, int player) s = ReadString (stream); - if (Trace (players[player].mo->X(), players[player].mo->Y(), - players[player].mo->Top() - (players[player].mo->height>>2), + if (Trace (players[player].mo->_f_X(), players[player].mo->_f_Y(), + players[player].mo->_f_Top() - (players[player].mo->height>>2), players[player].mo->Sector, vx, vy, vz, 172*FRACUNIT, 0, ML_BLOCKEVERYTHING, players[player].mo, trace, TRACE_NoSky)) diff --git a/src/d_player.h b/src/d_player.h index dfb1b58d5..66af66e96 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -114,7 +114,7 @@ public: virtual void PlayIdle (); virtual void PlayRunning (); virtual void ThrowPoisonBag (); - virtual void TweakSpeeds (int &forwardmove, int &sidemove); + virtual void TweakSpeeds (double &forwardmove, double &sidemove); virtual void MorphPlayerThink (); virtual void ActivateMorphWeapon (); AWeapon *PickNewWeapon (PClassAmmo *ammotype); @@ -149,12 +149,12 @@ public: TObjPtr InvSel; // selected inventory item // [GRB] Player class properties - fixed_t JumpZ; + double JumpZ; fixed_t GruntSpeed; fixed_t FallingScreamMinSpeed, FallingScreamMaxSpeed; fixed_t ViewHeight; - fixed_t ForwardMove1, ForwardMove2; - fixed_t SideMove1, SideMove2; + double ForwardMove1, ForwardMove2; + double SideMove1, SideMove2; FTextureID ScoreIcon; int SpawnMask; FNameNoInit MorphWeapon; @@ -329,13 +329,13 @@ struct userinfo_t : TMap { return *static_cast(*CheckKey(NAME_NeverSwitchOnPickup)); } - fixed_t GetMoveBob() const + double GetMoveBob() const { - return FLOAT2FIXED(*static_cast(*CheckKey(NAME_MoveBob))); + return *static_cast(*CheckKey(NAME_MoveBob)); } - fixed_t GetStillBob() const + double GetStillBob() const { - return FLOAT2FIXED(*static_cast(*CheckKey(NAME_StillBob))); + return *static_cast(*CheckKey(NAME_StillBob)); } int GetPlayerClassNum() const { @@ -405,13 +405,13 @@ public: fixed_t viewz; // focal origin above r.z fixed_t viewheight; // base height above floor for viewz fixed_t deltaviewheight; // squat speed. - fixed_t bob; // bounded/scaled total velocity + double bob; // bounded/scaled total velocity // killough 10/98: used for realistic bobbing (i.e. not simply overall speed) - // mo->vel.x and mo->vel.y represent true velocity experienced by player. + // mo->velx and mo->vely represent true velocity experienced by player. // This only represents the thrust that the player applies himself. // This avoids anomalies with such things as Boom ice and conveyors. - fixedvec2 vel; + DVector2 Vel; bool centering; BYTE turnticks; @@ -491,7 +491,7 @@ public: DAngle MinPitch; // Viewpitch limits (negative is up, positive is down) DAngle MaxPitch; - fixed_t crouchfactor; + double crouchfactor; fixed_t crouchoffset; fixed_t crouchviewdelta; @@ -509,9 +509,9 @@ public: void Uncrouch() { - if (crouchfactor != FRACUNIT) + if (crouchfactor != 1) { - crouchfactor = FRACUNIT; + crouchfactor = 1; crouchoffset = 0; crouchdir = 0; crouching = 0; @@ -556,7 +556,7 @@ inline bool AActor::IsNoClip2() const return false; } -#define CROUCHSPEED (FRACUNIT/12) +#define CROUCHSPEED (1./12) bool P_IsPlayerTotallyFrozen(const player_t *player); diff --git a/src/doomdef.h b/src/doomdef.h index 627efe391..18b1b8bbb 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -365,11 +365,14 @@ enum // linedefs. More friction can create mud, sludge, // magnetized floors, etc. Less friction can create ice. -#define MORE_FRICTION_VELOCITY 15000 // mud factor based on velocity +#define MORE_FRICTION_VELOCITY (15000/65536.) // mud factor based on velocity #define ORIG_FRICTION 0xE800 // original value +#define fORIG_FRICTION (ORIG_FRICTION/65536.) #define ORIG_FRICTION_FACTOR 2048 // original value +#define fORIG_FRICTION_FACTOR (2048/65536.) // original value #define FRICTION_LOW 0xf900 #define FRICTION_FLY 0xeb00 +#define fFRICTION_FLY (0xeb00/65536.) #define BLINKTHRESHOLD (4*32) diff --git a/src/farchive.cpp b/src/farchive.cpp index c47c98cf1..93ec269d7 100644 --- a/src/farchive.cpp +++ b/src/farchive.cpp @@ -1535,15 +1535,18 @@ FArchive &operator<< (FArchive &arc, side_t *&side) FArchive &operator<<(FArchive &arc, DAngle &ang) { - if (SaveVersion >= 4534) - { - arc << ang.Degrees; - } - else - { - angle_t an; - arc << an; - ang.Degrees = ANGLE2DBL(an); - } + arc << ang.Degrees; + return arc; +} + +FArchive &operator<<(FArchive &arc, DVector3 &vec) +{ + arc << vec.X << vec.Y << vec.Z; + return arc; +} + +FArchive &operator<<(FArchive &arc, DVector2 &vec) +{ + arc << vec.X << vec.Y; return arc; } diff --git a/src/farchive.h b/src/farchive.h index c08ba525f..a3f38ff47 100644 --- a/src/farchive.h +++ b/src/farchive.h @@ -325,6 +325,8 @@ FArchive &operator<< (FArchive &arc, vertex_t *&vert); FArchive &operator<< (FArchive &arc, side_t *&side); FArchive &operator<<(FArchive &arc, DAngle &ang); +FArchive &operator<<(FArchive &arc, DVector3 &vec); +FArchive &operator<<(FArchive &arc, DVector2 &vec); diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 4d9c8775a..3fd222170 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -983,8 +983,7 @@ void FParser::SF_ObjX(void) mo = Script->trigger; } - t_return.type = svt_fixed; // haleyjd: SoM's fixed-point fix - t_return.value.f = mo ? mo->X() : 0; // null ptr check + t_return.setDouble(mo ? mo->X() : 0.); } //========================================================================== @@ -1006,8 +1005,7 @@ void FParser::SF_ObjY(void) mo = Script->trigger; } - t_return.type = svt_fixed; // haleyjd - t_return.value.f = mo ? mo->Y() : 0; // null ptr check + t_return.setDouble(mo ? mo->Y() : 0.); } //========================================================================== @@ -1029,8 +1027,7 @@ void FParser::SF_ObjZ(void) mo = Script->trigger; } - t_return.type = svt_fixed; // haleyjd - t_return.value.f = mo ? mo->Z() : 0; // null ptr check + t_return.setDouble(mo ? mo->Z() : 0.); } @@ -1334,11 +1331,10 @@ void FParser::SF_MobjMomx(void) if(t_argc > 1) { if(mo) - mo->vel.x = fixedvalue(t_argv[1]); + mo->Vel.X = floatvalue(t_argv[1]); } - t_return.type = svt_fixed; - t_return.value.f = mo ? mo->vel.x : 0; + t_return.setDouble(mo ? mo->Vel.X : 0.); } } @@ -1357,12 +1353,11 @@ void FParser::SF_MobjMomy(void) mo = actorvalue(t_argv[0]); if(t_argc > 1) { - if(mo) - mo->vel.y = fixedvalue(t_argv[1]); + if(mo) + mo->Vel.Y = floatvalue(t_argv[1]); } - t_return.type = svt_fixed; - t_return.value.f = mo ? mo->vel.y : 0; + t_return.setDouble(mo ? mo->Vel.Y : 0.); } } @@ -1379,14 +1374,13 @@ void FParser::SF_MobjMomz(void) if (CheckArgs(1)) { mo = actorvalue(t_argv[0]); - if(t_argc > 1) + if (t_argc > 1) { - if(mo) - mo->vel.z = fixedvalue(t_argv[1]); + if (mo) + mo->Vel.Z = floatvalue(t_argv[1]); } - - t_return.type = svt_fixed; - t_return.value.f = mo ? mo->vel.z : 0; + + t_return.setDouble(mo ? mo->Vel.Z : 0.); } } @@ -1467,8 +1461,8 @@ void FParser::SF_SetCamera(void) angle = t_argc < 2 ? newcamera->Angles.Yaw : floatvalue(t_argv[1]); newcamera->special1 = newcamera->Angles.Yaw.BAMs(); - newcamera->special2=newcamera->Z(); - newcamera->SetZ(t_argc < 3 ? (newcamera->Z() + (41 << FRACBITS)) : (intvalue(t_argv[2]) << FRACBITS)); + newcamera->special2=newcamera->_f_Z(); + newcamera->_f_SetZ(t_argc < 3 ? (newcamera->_f_Z() + (41 << FRACBITS)) : (intvalue(t_argv[2]) << FRACBITS)); newcamera->Angles.Yaw = angle; if (t_argc < 4) newcamera->Angles.Pitch = 0.; else newcamera->Angles.Pitch = clamp(floatvalue(t_argv[3]), -50., 50.) * (20. / 32.); @@ -1493,7 +1487,7 @@ void FParser::SF_ClearCamera(void) { player->camera=player->mo; cam->Angles.Yaw = ANGLE2DBL(cam->special1); - cam->SetZ(cam->special2); + cam->_f_SetZ(cam->special2); } } @@ -3100,8 +3094,8 @@ void FParser::SF_MoveCamera(void) anglespeed = (angle_t)FixedToAngle(fixedvalue(t_argv[5])); // figure out how big one step will be - fixedvec2 dist = cam->Vec2To(target); - zdist = targetheight - cam->Z(); + fixedvec2 dist = cam->_f_Vec2To(target); + zdist = targetheight - cam->_f_Z(); // Angle checking... // 90 @@ -3174,18 +3168,18 @@ void FParser::SF_MoveCamera(void) anglestep = anglespeed; if(abs(xstep) >= (abs(dist.x) - 1)) - x = cam->X() + dist.x; + x = cam->_f_X() + dist.x; else { - x = cam->X() + xstep; + x = cam->_f_X() + xstep; moved = 1; } if(abs(ystep) >= (abs(dist.y) - 1)) - y = cam->Y() + dist.y; + y = cam->_f_Y() + dist.y; else { - y = cam->Y() + ystep; + y = cam->_f_Y() + ystep; moved = 1; } @@ -3193,7 +3187,7 @@ void FParser::SF_MoveCamera(void) z = targetheight; else { - z = cam->Z() + zstep; + z = cam->_f_Z() + zstep; moved = 1; } @@ -3215,12 +3209,12 @@ void FParser::SF_MoveCamera(void) cam->radius=8; cam->height=8; - if ((x != cam->X() || y != cam->Y()) && !P_TryMove(cam, x, y, true)) + if ((x != cam->_f_X() || y != cam->_f_Y()) && !P_TryMove(cam, x, y, true)) { Printf("Illegal camera move to (%f, %f)\n", x/65536.f, y/65536.f); return; } - cam->SetZ(z); + cam->_f_SetZ(z); t_return.type = svt_int; t_return.value.i = moved; @@ -3415,8 +3409,8 @@ void FParser::SF_SetObjPosition() mobj->SetOrigin( fixedvalue(t_argv[1]), - (t_argc >= 3)? fixedvalue(t_argv[2]) : mobj->Y(), - (t_argc >= 4)? fixedvalue(t_argv[3]) : mobj->Z(), false); + (t_argc >= 3)? fixedvalue(t_argv[2]) : mobj->_f_Y(), + (t_argc >= 4)? fixedvalue(t_argv[3]) : mobj->_f_Z(), false); } } @@ -4285,7 +4279,8 @@ void FParser::SF_SpawnShot2(void) { S_Sound (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM); mo->target = source; - P_ThrustMobj(mo, (mo->Angles.Yaw = source->Angles.Yaw), mo->Speed); + mo->Angles.Yaw = source->Angles.Yaw; + mo->Thrust(); if (!P_CheckMissileSpawn(mo, source->radius)) mo = NULL; } t_return.value.mobj = mo; diff --git a/src/g_doom/a_archvile.cpp b/src/g_doom/a_archvile.cpp index bf1ff0bde..9f72e9f64 100644 --- a/src/g_doom/a_archvile.cpp +++ b/src/g_doom/a_archvile.cpp @@ -68,7 +68,7 @@ void A_Fire(AActor *self, int height) if (!P_CheckSight (self->target, dest, 0) ) return; - fixedvec3 newpos = dest->Vec3Angle(24 * FRACUNIT, dest->_f_angle(), height); + DVector3 newpos = dest->Vec3Angle(24., dest->Angles.Yaw, height); self->SetOrigin(newpos, true); } @@ -147,14 +147,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileAttack) if (fire != NULL) { // move the fire between the vile and the player - fixedvec3 pos = target->Vec3Angle(-24 * FRACUNIT, self->_f_angle(), 0); + DVector3 pos = target->Vec3Angle(-24., self->Angles.Yaw, 0); fire->SetOrigin (pos, true); P_RadiusAttack (fire, self, blastdmg, blastrad, dmgtype, 0); } if (!(target->flags7 & MF7_DONTTHRUST)) { - target->vel.z = Scale(thrust, 1000, target->Mass); + target->Vel.Z = FIXED2FLOAT(Scale(thrust, 1000, target->Mass)); } return 0; } diff --git a/src/g_doom/a_bossbrain.cpp b/src/g_doom/a_bossbrain.cpp index f752b7334..46ef7e782 100644 --- a/src/g_doom/a_bossbrain.cpp +++ b/src/g_doom/a_bossbrain.cpp @@ -37,7 +37,7 @@ static void BrainishExplosion (fixed_t x, fixed_t y, fixed_t z) if (boom != NULL) { boom->DeathSound = "misc/brainexplode"; - boom->vel.z = pr_brainscream() << 9; + boom->Vel.Z = pr_brainscream() /128.; PClassActor *cls = PClass::FindActor("BossBrain"); if (cls != NULL) @@ -59,9 +59,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_BrainScream) PARAM_ACTION_PROLOGUE; fixed_t x; - for (x = self->X() - 196*FRACUNIT; x < self->X() + 320*FRACUNIT; x += 8*FRACUNIT) + for (x = self->_f_X() - 196*FRACUNIT; x < self->_f_X() + 320*FRACUNIT; x += 8*FRACUNIT) { - BrainishExplosion (x, self->Y() - 320*FRACUNIT, + BrainishExplosion (x, self->_f_Y() - 320*FRACUNIT, 128 + (pr_brainscream() << (FRACBITS + 1))); } S_Sound (self, CHAN_VOICE, "brain/death", 1, ATTN_NONE); @@ -71,9 +71,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_BrainScream) DEFINE_ACTION_FUNCTION(AActor, A_BrainExplode) { PARAM_ACTION_PROLOGUE; - fixed_t x = self->X() + pr_brainexplode.Random2()*2048; + fixed_t x = self->_f_X() + pr_brainexplode.Random2()*2048; fixed_t z = 128 + pr_brainexplode()*2*FRACUNIT; - BrainishExplosion (x, self->Y(), z); + BrainishExplosion (x, self->_f_Y(), z); return 0; } @@ -144,17 +144,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BrainSpit) spit->master = self; // [RH] Do this correctly for any trajectory. Doom would divide by 0 // if the target had the same y coordinate as the spitter. - if ((spit->vel.x | spit->vel.y) == 0) + if (spit->Vel.X == 0 && spit->Vel.Y == 0) { spit->special2 = 0; } - else if (abs(spit->vel.y) > abs(spit->vel.x)) + else if (fabs(spit->Vel.X) > fabs(spit->Vel.Y)) { - spit->special2 = (targ->Y() - self->Y()) / spit->vel.y; + spit->special2 = int((targ->Y() - self->Y()) / spit->Vel.Y); } else { - spit->special2 = (targ->X() - self->X()) / spit->vel.x; + spit->special2 = int((targ->X() - self->X()) / spit->Vel.X); } // [GZ] Calculates when the projectile will have reached destination spit->special2 += level.maptime; @@ -286,7 +286,7 @@ static void SpawnFly(AActor *self, PClassActor *spawntype, FSoundID sound) if (!(newmobj->ObjectFlags & OF_EuthanizeMe)) { // telefrag anything in this spot - P_TeleportMove (newmobj, newmobj->Pos(), true); + P_TeleportMove (newmobj, newmobj->_f_Pos(), true); } newmobj->flags4 |= MF4_BOSSSPAWNED; } diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 14536b989..b75fd30ff 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -694,7 +694,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) damage = defdamage; } - int newdam = P_DamageMobj(t.linetarget, self->target, self->target, damage, dmgType, dmgFlags|DMG_USEANGLE, FLOAT2ANGLE(t.angleFromSource.Degrees)); + int newdam = P_DamageMobj(t.linetarget, self->target, self->target, damage, dmgType, dmgFlags|DMG_USEANGLE, t.angleFromSource.Degrees); P_TraceBleed(newdam > 0 ? newdam : damage, &t, self); } } diff --git a/src/g_doom/a_fatso.cpp b/src/g_doom/a_fatso.cpp index f55686aeb..ffc313c35 100644 --- a/src/g_doom/a_fatso.cpp +++ b/src/g_doom/a_fatso.cpp @@ -127,7 +127,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom) PARAM_INT_OPT (n) { n = 0; } PARAM_INT_OPT (flags) { flags = 0; } PARAM_FIXED_OPT (vrange) { vrange = 4*FRACUNIT; } - PARAM_FIXED_OPT (hrange) { hrange = FRACUNIT/2; } + PARAM_FLOAT_OPT (hrange) { hrange = 0.5; } int i, j; @@ -153,9 +153,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom) { AActor *mo; target->SetXYZ( - self->X() + (i << FRACBITS), // Aim in many directions from source - self->Y() + (j << FRACBITS), - self->Z() + (P_AproxDistance(i,j) * vrange)); // Aim up fairly high + self->_f_X() + (i << FRACBITS), // Aim in many directions from source + self->_f_Y() + (j << FRACBITS), + self->_f_Z() + (P_AproxDistance(i,j) * vrange)); // Aim up fairly high if ((flags & MSF_Classic) || // Flag explicitely set, or no flags and compat options (flags == 0 && (self->state->DefineFlags & SDF_DEHACKED) && (i_compatflags & COMPATF_MUSHROOM))) { // Use old function for MBF compatibility @@ -167,9 +167,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom) } if (mo != NULL) { // Slow it down a bit - mo->vel.x = FixedMul(mo->vel.x, hrange); - mo->vel.y = FixedMul(mo->vel.y, hrange); - mo->vel.z = FixedMul(mo->vel.z, hrange); + mo->Vel *= hrange; mo->flags &= ~MF_NOGRAVITY; // Make debris fall under gravity } } diff --git a/src/g_doom/a_lostsoul.cpp b/src/g_doom/a_lostsoul.cpp index cfbaf1870..056802fe0 100644 --- a/src/g_doom/a_lostsoul.cpp +++ b/src/g_doom/a_lostsoul.cpp @@ -19,11 +19,9 @@ // Fly at the player like a missile. // -void A_SkullAttack(AActor *self, fixed_t speed) +void A_SkullAttack(AActor *self, double speed) { AActor *dest; - int dist; - if (!self->target) return; @@ -33,18 +31,13 @@ void A_SkullAttack(AActor *self, fixed_t speed) S_Sound (self, CHAN_VOICE, self->AttackSound, 1, ATTN_NORM); A_FaceTarget (self); self->VelFromAngle(speed); - dist = self->AproxDistance (dest); - dist = dist / speed; - - if (dist < 1) - dist = 1; - self->vel.z = (dest->Z() + (dest->height>>1) - self->Z()) / dist; + self->Vel.Z = (dest->Center() - self->Z()) / self->DistanceBySpeed(dest, speed); } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullAttack) { PARAM_ACTION_PROLOGUE; - PARAM_FIXED_OPT(speed) { speed = SKULLSPEED; } + PARAM_FLOAT_OPT(speed) { speed = SKULLSPEED; } if (speed <= 0) speed = SKULLSPEED; diff --git a/src/g_doom/a_painelemental.cpp b/src/g_doom/a_painelemental.cpp index e06a159ec..5575a2ec1 100644 --- a/src/g_doom/a_painelemental.cpp +++ b/src/g_doom/a_painelemental.cpp @@ -31,11 +31,11 @@ void A_PainShootSkull (AActor *self, angle_t angle, PClassActor *spawntype, int if (self->DamageType == NAME_Massacre) return; // [RH] check to make sure it's not too close to the ceiling - if (self->Top() + 8*FRACUNIT > self->ceilingz) + if (self->_f_Top() + 8*FRACUNIT > self->ceilingz) { if (self->flags & MF_FLOAT) { - self->vel.z -= 2*FRACUNIT; + self->Vel.Z -= 2; self->flags |= MF_INFLOAT; self->flags4 |= MF4_VFRICTION; } @@ -69,7 +69,7 @@ void A_PainShootSkull (AActor *self, angle_t angle, PClassActor *spawntype, int fixedvec2 dist = Vec2Angle(prestep, angle); fixedvec3 pos = self->Vec3Offset(dist.x, dist.y, 8 * FRACUNIT, true); - fixedvec3 src = self->Pos(); + fixedvec3 src = self->_f_Pos(); for (int i = 0; i < 2; i++) { @@ -120,9 +120,9 @@ void A_PainShootSkull (AActor *self, angle_t angle, PClassActor *spawntype, int // Check to see if the new Lost Soul's z value is above the // ceiling of its new sector, or below the floor. If so, kill it. - if ((other->Top() > + if ((other->_f_Top() > (other->Sector->HighestCeilingAt(other))) || - (other->Z() < other->Sector->LowestFloorAt(other))) + (other->_f_Z() < other->Sector->LowestFloorAt(other))) { // kill it immediately P_DamageMobj (other, self, self, TELEFRAG_DAMAGE, NAME_None);// ^ @@ -131,7 +131,7 @@ void A_PainShootSkull (AActor *self, angle_t angle, PClassActor *spawntype, int // Check for movements. - if (!P_CheckPosition (other, other->Pos())) + if (!P_CheckPosition (other, other->_f_Pos())) { // kill it immediately P_DamageMobj (other, self, self, TELEFRAG_DAMAGE, NAME_None); diff --git a/src/g_doom/a_revenant.cpp b/src/g_doom/a_revenant.cpp index 44dedfe2c..293fb56f8 100644 --- a/src/g_doom/a_revenant.cpp +++ b/src/g_doom/a_revenant.cpp @@ -28,12 +28,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkelMissile) return 0; A_FaceTarget (self); - missile = P_SpawnMissileZ (self, self->Z() + 48*FRACUNIT, + missile = P_SpawnMissileZ (self, self->_f_Z() + 48*FRACUNIT, self->target, PClass::FindActor("RevenantTracer")); if (missile != NULL) { - missile->SetOrigin(missile->Vec3Offset(missile->vel.x, missile->vel.y, 0), false); + missile->SetOrigin(missile->Vec3Offset(missile->_f_velx(), missile->_f_vely(), 0), false); missile->tracer = self->target; } return 0; @@ -45,8 +45,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer) { PARAM_ACTION_PROLOGUE; - fixed_t dist; - fixed_t slope; + double dist; + double slope; AActor *dest; AActor *smoke; @@ -63,11 +63,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer) return 0; // spawn a puff of smoke behind the rocket - P_SpawnPuff (self, PClass::FindActor(NAME_BulletPuff), self->Pos(), self->_f_angle(), self->_f_angle(), 3); + P_SpawnPuff (self, PClass::FindActor(NAME_BulletPuff), self->_f_Pos(), self->_f_angle(), self->_f_angle(), 3); - smoke = Spawn ("RevenantTracerSmoke", self->Vec3Offset(-self->vel.x, -self->vel.y, 0), ALLOW_REPLACE); + smoke = Spawn ("RevenantTracerSmoke", self->Vec3Offset(-self->_f_velx(), -self->_f_vely(), 0), ALLOW_REPLACE); - smoke->vel.z = FRACUNIT; + smoke->Vel.Z = 1.; smoke->tics -= pr_tracer()&3; if (smoke->tics < 1) smoke->tics = 1; @@ -100,24 +100,21 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer) if (!(self->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) { // change slope - dist = self->AproxDistance (dest) / self->Speed; + dist = self->DistanceBySpeed(dest, self->Speed); - if (dist < 1) - dist = 1; - - if (dest->height >= 56*FRACUNIT) + if (dest->_Height() >= 56.) { - slope = (dest->Z()+40*FRACUNIT - self->Z()) / dist; + slope = (dest->Z() + 40. - self->Z()) / dist; } else { - slope = (dest->Z() + self->height*2/3 - self->Z()) / dist; + slope = (dest->Z() + self->_Height()*(2./3) - self->Z()) / dist; } - if (slope < self->vel.z) - self->vel.z -= FRACUNIT/8; + if (slope < self->Vel.Z) + self->Vel.Z -= 1. / 8; else - self->vel.z += FRACUNIT/8; + self->Vel.Z += 1. / 8; } return 0; } diff --git a/src/g_game.cpp b/src/g_game.cpp index 1ff95537e..cc5afc1b0 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1182,7 +1182,7 @@ void G_Ticker () } if (players[i].mo) { - DWORD sum = rngsum + players[i].mo->X() + players[i].mo->Y() + players[i].mo->Z() + DWORD sum = rngsum + players[i].mo->_f_X() + players[i].mo->_f_Y() + players[i].mo->_f_Z() + players[i].mo->_f_angle() + players[i].mo->_f_pitch(); sum ^= players[i].health; consistancy[i][buf] = sum; @@ -1443,13 +1443,13 @@ bool G_CheckSpot (int playernum, FPlayerStart *mthing) if (!players[playernum].mo) { // first spawn of level, before corpses for (i = 0; i < playernum; i++) - if (players[i].mo && players[i].mo->X() == x && players[i].mo->Y() == y) + if (players[i].mo && players[i].mo->_f_X() == x && players[i].mo->_f_Y() == y) return false; return true; } - oldz = players[playernum].mo->Z(); // [RH] Need to save corpse's z-height - players[playernum].mo->SetZ(z); // [RH] Checks are now full 3-D + oldz = players[playernum].mo->_f_Z(); // [RH] Need to save corpse's z-height + players[playernum].mo->_f_SetZ(z); // [RH] Checks are now full 3-D // killough 4/2/98: fix bug where P_CheckPosition() uses a non-solid // corpse to detect collisions with other players in DM starts @@ -1461,7 +1461,7 @@ bool G_CheckSpot (int playernum, FPlayerStart *mthing) players[playernum].mo->flags |= MF_SOLID; i = P_CheckPosition(players[playernum].mo, x, y); players[playernum].mo->flags &= ~MF_SOLID; - players[playernum].mo->SetZ(oldz); // [RH] Restore corpse's height + players[playernum].mo->_f_SetZ(oldz); // [RH] Restore corpse's height if (!i) return false; diff --git a/src/g_heretic/a_chicken.cpp b/src/g_heretic/a_chicken.cpp index 8e3e3ec74..ca38e2074 100644 --- a/src/g_heretic/a_chicken.cpp +++ b/src/g_heretic/a_chicken.cpp @@ -41,13 +41,13 @@ void AChickenPlayer::MorphPlayerThink () { return; } - if (!(vel.x | vel.y) && pr_chickenplayerthink () < 160) + if (Vel.X == 0 && Vel.Y == 0 && pr_chickenplayerthink () < 160) { // Twitch view angle Angles.Yaw += pr_chickenplayerthink.Random2() * (360. / 256. / 32.); } - if ((Z() <= floorz) && (pr_chickenplayerthink() < 32)) + if ((_f_Z() <= floorz) && (pr_chickenplayerthink() < 32)) { // Jump and noise - vel.z += JumpZ; + Vel.Z += JumpZ; FState * painstate = FindState(NAME_Pain); if (painstate != NULL) SetState (painstate); @@ -107,9 +107,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Feathers) { mo = Spawn("Feather", self->PosPlusZ(20*FRACUNIT), NO_REPLACE); mo->target = self; - mo->vel.x = pr_feathers.Random2() << 8; - mo->vel.y = pr_feathers.Random2() << 8; - mo->vel.z = FRACUNIT + (pr_feathers() << 9); + mo->Vel.X = pr_feathers.Random2() / 256.; + mo->Vel.Y = pr_feathers.Random2() / 256.; + mo->Vel.Z = 1. + pr_feathers() / 128.; mo->SetState (mo->SpawnState + (pr_feathers()&7)); } return 0; diff --git a/src/g_heretic/a_dsparil.cpp b/src/g_heretic/a_dsparil.cpp index 3c35a794a..2e85e071a 100644 --- a/src/g_heretic/a_dsparil.cpp +++ b/src/g_heretic/a_dsparil.cpp @@ -86,17 +86,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr1Attack) PClassActor *fx = PClass::FindActor("SorcererFX1"); if (self->health > (self->SpawnHealth()/3)*2) { // Spit one fireball - P_SpawnMissileZ (self, self->Z() + 48*FRACUNIT, self->target, fx ); + P_SpawnMissileZ (self, self->_f_Z() + 48*FRACUNIT, self->target, fx ); } else { // Spit three fireballs - mo = P_SpawnMissileZ (self, self->Z() + 48*FRACUNIT, self->target, fx); + mo = P_SpawnMissileZ (self, self->_f_Z() + 48*FRACUNIT, self->target, fx); if (mo != NULL) { - vz = mo->vel.z; + vz = mo->_f_velz(); angle = mo->_f_angle(); - P_SpawnMissileAngleZ (self, self->Z() + 48*FRACUNIT, fx, angle-ANGLE_1*3, vz); - P_SpawnMissileAngleZ (self, self->Z() + 48*FRACUNIT, fx, angle+ANGLE_1*3, vz); + P_SpawnMissileAngleZ (self, self->_f_Z() + 48*FRACUNIT, fx, angle-ANGLE_1*3, vz); + P_SpawnMissileAngleZ (self, self->_f_Z() + 48*FRACUNIT, fx, angle+ANGLE_1*3, vz); } if (self->health < self->SpawnHealth()/3) { // Maybe attack again @@ -152,22 +152,22 @@ void P_DSparilTeleport (AActor *actor) DSpotState *state = DSpotState::GetSpotState(); if (state == NULL) return; - spot = state->GetSpotWithMinMaxDistance(PClass::FindClass("BossSpot"), actor->X(), actor->Y(), 128*FRACUNIT, 0); + spot = state->GetSpotWithMinMaxDistance(PClass::FindClass("BossSpot"), actor->_f_X(), actor->_f_Y(), 128*FRACUNIT, 0); if (spot == NULL) return; - prevX = actor->X(); - prevY = actor->Y(); - prevZ = actor->Z(); - if (P_TeleportMove (actor, spot->Pos(), false)) + prevX = actor->_f_X(); + prevY = actor->_f_Y(); + prevZ = actor->_f_Z(); + if (P_TeleportMove (actor, spot->_f_Pos(), false)) { mo = Spawn("Sorcerer2Telefade", prevX, prevY, prevZ, ALLOW_REPLACE); if (mo) mo->Translation = actor->Translation; S_Sound (mo, CHAN_BODY, "misc/teleport", 1, ATTN_NORM); actor->SetState (actor->FindState("Teleport")); S_Sound (actor, CHAN_BODY, "misc/teleport", 1, ATTN_NORM); - actor->SetZ(actor->floorz, false); + actor->_f_SetZ(actor->floorz, false); actor->Angles.Yaw = spot->Angles.Yaw; - actor->vel.x = actor->vel.y = actor->vel.z = 0; + actor->Vel.Zero(); } } @@ -257,9 +257,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_BlueSpark) for (i = 0; i < 2; i++) { mo = Spawn("Sorcerer2FXSpark", self->Pos(), ALLOW_REPLACE); - mo->vel.x = pr_bluespark.Random2() << 9; - mo->vel.y = pr_bluespark.Random2() << 9; - mo->vel.z = FRACUNIT + (pr_bluespark()<<8); + mo->Vel.X = pr_bluespark.Random2() / 128.; + mo->Vel.Y = pr_bluespark.Random2() / 128.; + mo->Vel.Z = 1. + pr_bluespark() / 256.; } return 0; } @@ -279,7 +279,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard) mo = Spawn("Wizard", self->Pos(), ALLOW_REPLACE); if (mo != NULL) { - mo->AddZ(-mo->GetDefault()->height / 2, false); + mo->_f_AddZ(-mo->GetDefault()->height / 2, false); if (!P_TestMobjLocation (mo)) { // Didn't fit mo->ClearCounters(); @@ -289,7 +289,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard) { // [RH] Make the new wizards inherit D'Sparil's target mo->CopyFriendliness (self->target, true); - self->vel.x = self->vel.y = self->vel.z = 0; + self->Vel.Zero(); self->SetState (self->FindState(NAME_Death)); self->flags &= ~MF_MISSILE; mo->master = self->target; diff --git a/src/g_heretic/a_hereticartifacts.cpp b/src/g_heretic/a_hereticartifacts.cpp index 3eb4de206..42a787580 100644 --- a/src/g_heretic/a_hereticartifacts.cpp +++ b/src/g_heretic/a_hereticartifacts.cpp @@ -49,8 +49,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_TimeBomb) { PARAM_ACTION_PROLOGUE; - self->AddZ(32*FRACUNIT, false); - self->PrevZ = self->Z(); // no interpolation! + self->_f_AddZ(32*FRACUNIT, false); + self->PrevZ = self->_f_Z(); // no interpolation! self->RenderStyle = STYLE_Add; self->alpha = FRACUNIT; P_RadiusAttack (self, self->target, 128, 128, self->DamageType, RADF_HURTSOURCE); @@ -72,7 +72,7 @@ bool AArtiTimeBomb::Use (bool pickup) { angle_t angle = Owner->_f_angle() >> ANGLETOFINESHIFT; AActor *mo = Spawn("ActivatedTimeBomb", - Owner->Vec3Angle(24*FRACUNIT, Owner->_f_angle(), - Owner->floorclip), ALLOW_REPLACE); + Owner->_f_Vec3Angle(24*FRACUNIT, Owner->_f_angle(), - Owner->floorclip), ALLOW_REPLACE); mo->target = Owner; return true; } diff --git a/src/g_heretic/a_hereticimp.cpp b/src/g_heretic/a_hereticimp.cpp index d2d40bed4..81185c0c1 100644 --- a/src/g_heretic/a_hereticimp.cpp +++ b/src/g_heretic/a_hereticimp.cpp @@ -28,7 +28,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ImpMsAttack) self->SetState (self->SeeState); return 0; } - A_SkullAttack(self, 12 * FRACUNIT); + A_SkullAttack(self, 12.); return 0; } @@ -47,14 +47,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_ImpExplode) self->flags &= ~MF_NOGRAVITY; chunk = Spawn("HereticImpChunk1", self->Pos(), ALLOW_REPLACE); - chunk->vel.x = pr_imp.Random2 () << 10; - chunk->vel.y = pr_imp.Random2 () << 10; - chunk->vel.z = 9*FRACUNIT; + chunk->Vel.X = pr_imp.Random2() / 64.; + chunk->Vel.Y = pr_imp.Random2() / 64.; + chunk->Vel.Z = 9; chunk = Spawn("HereticImpChunk2", self->Pos(), ALLOW_REPLACE); - chunk->vel.x = pr_imp.Random2 () << 10; - chunk->vel.y = pr_imp.Random2 () << 10; - chunk->vel.z = 9*FRACUNIT; + chunk->Vel.X = pr_imp.Random2() / 64.; + chunk->Vel.Y = pr_imp.Random2() / 64.; + chunk->Vel.Z = 9; if (self->special1 == 666) { // Extreme death crash self->SetState (self->FindState("XCrash")); diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp index d42167fbe..81643faf3 100644 --- a/src/g_heretic/a_hereticmisc.cpp +++ b/src/g_heretic/a_hereticmisc.cpp @@ -61,9 +61,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PodPain) { goo = Spawn(gootype, self->PosPlusZ(48*FRACUNIT), ALLOW_REPLACE); goo->target = self; - goo->vel.x = pr_podpain.Random2() << 9; - goo->vel.y = pr_podpain.Random2() << 9; - goo->vel.z = FRACUNIT/2 + (pr_podpain() << 9); + goo->Vel.X = pr_podpain.Random2() / 128.; + goo->Vel.Y = pr_podpain.Random2() / 128.; + goo->Vel.Z = 0.5 + pr_podpain() / 128.; } return 0; } @@ -111,8 +111,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MakePod) { // Too many generated pods return 0; } - x = self->X(); - y = self->Y(); + x = self->_f_X(); + y = self->_f_Y(); mo = Spawn(podtype, x, y, ONFLOORZ, ALLOW_REPLACE); if (!P_CheckPosition (mo, x, y)) { // Didn't fit @@ -139,7 +139,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_AccTeleGlitter) if (++self->health > 35) { - self->vel.z += self->vel.z/2; + self->Vel.Z *= 1.5; } return 0; } @@ -179,8 +179,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcanoBlast) blast = Spawn("VolcanoBlast", self->PosPlusZ(44*FRACUNIT), ALLOW_REPLACE); blast->target = self; blast->Angles.Yaw = pr_blast() * (360 / 256.f); - blast->VelFromAngle(1 * FRACUNIT); - blast->vel.z = (FRACUNIT*5/2) + (pr_blast() << 10); + blast->VelFromAngle(1.); + blast->Vel.Z = 2.5 + pr_blast() / 64.; S_Sound (blast, CHAN_BODY, "world/volcano/shoot", 1, ATTN_NORM); P_CheckMissileSpawn (blast, self->radius); } @@ -200,12 +200,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact) unsigned int i; AActor *tiny; - if (self->Z() <= self->floorz) + if (self->_f_Z() <= self->floorz) { self->flags |= MF_NOGRAVITY; self->gravity = FRACUNIT; - self->AddZ(28*FRACUNIT); - //self->vel.z = 3*FRACUNIT; + self->_f_AddZ(28*FRACUNIT); + //self->Vel.Z = 3*FRACUNIT; } P_RadiusAttack (self, self->target, 25, 25, NAME_Fire, RADF_HURTSOURCE); for (i = 0; i < 4; i++) @@ -213,8 +213,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact) tiny = Spawn("VolcanoTBlast", self->Pos(), ALLOW_REPLACE); tiny->target = self; tiny->Angles.Yaw = 90.*i; - tiny->VelFromAngle(FRACUNIT * 7 / 10); - tiny->vel.z = FRACUNIT + (pr_volcimpact() << 9); + tiny->VelFromAngle(0.7); + tiny->Vel.Z = 1. + pr_volcimpact() / 128.; P_CheckMissileSpawn (tiny, self->radius); } return 0; diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index 29a782422..92d21b5c9 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -166,7 +166,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL2) DAngle pitch = P_BulletSlope(self); //momz = GetDefault()->Speed * tan(-bulletpitch); - vz = fixed_t(GetDefaultByName("GoldWandFX2")->Speed * (-pitch).Tan()); + vz = fixed_t(GetDefaultByName("GoldWandFX2")->_f_speed() * -pitch.TanClamped()); P_SpawnMissileAngle (self, PClass::FindActor("GoldWandFX2"), self->_f_angle()-(ANG45/8), vz); P_SpawnMissileAngle (self, PClass::FindActor("GoldWandFX2"), self->_f_angle()+(ANG45/8), vz); angle = self->Angles.Yaw - (45. / 8); @@ -403,13 +403,12 @@ void FireMacePL1B (AActor *actor) return; } ball = Spawn("MaceFX2", actor->PosPlusZ(28*FRACUNIT - actor->floorclip), ALLOW_REPLACE); - ball->vel.z = FLOAT2FIXED(2 - actor->Angles.Pitch.Tan()); + ball->Vel.Z = 2 - player->mo->Angles.Pitch.TanClamped(); ball->target = actor; ball->Angles.Yaw = actor->Angles.Yaw; - ball->AddZ(ball->vel.z); + ball->_f_AddZ(ball->_f_velz()); ball->VelFromAngle(); - ball->vel.x += (actor->vel.x>>1); - ball->vel.y += (actor->vel.y>>1); + ball->Vel += actor->Vel.XY()/2; S_Sound (ball, CHAN_BODY, "weapons/maceshoot", 1, ATTN_NORM); P_CheckMissileSpawn (ball, actor->radius); } @@ -482,13 +481,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_MacePL1Check) self->vel.x = FixedMul(7*FRACUNIT, finecosine[angle]); self->vel.y = FixedMul(7*FRACUNIT, finesine[angle]); #else - double velscale = g_sqrt ((double)self->vel.x * (double)self->vel.x + - (double)self->vel.y * (double)self->vel.y); - velscale = 458752 / velscale; - self->vel.x = (int)(self->vel.x * velscale); - self->vel.y = (int)(self->vel.y * velscale); + double velscale = 7 / self->Vel.XY().Length(); + self->Vel.X *= velscale; + self->Vel.Y *= velscale; #endif - self->vel.z -= self->vel.z >> 1; + self->Vel.Z *= 0.5; return 0; } @@ -505,14 +502,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact) if ((self->health != MAGIC_JUNK) && (self->flags & MF_INBOUNCE)) { // Bounce self->health = MAGIC_JUNK; - self->vel.z = (self->vel.z * 192) >> 8; + self->Vel.Z *= 0.75; self->BounceFlags = BOUNCE_None; self->SetState (self->SpawnState); S_Sound (self, CHAN_BODY, "weapons/macebounce", 1, ATTN_NORM); } else { // Explode - self->vel.x = self->vel.y = self->vel.z = 0; + self->Vel.Zero(); self->flags |= MF_NOGRAVITY; self->gravity = FRACUNIT; S_Sound (self, CHAN_BODY, "weapons/macehit", 1, ATTN_NORM); @@ -532,44 +529,40 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact2) AActor *tiny; - if ((self->Z() <= self->floorz) && P_HitFloor (self)) + if ((self->_f_Z() <= self->floorz) && P_HitFloor (self)) { // Landed in some sort of liquid self->Destroy (); return 0; } if (self->flags & MF_INBOUNCE) { - if (self->vel.z < 2*FRACUNIT) + if (self->Vel.Z < 2) { goto boom; } // Bounce - self->vel.z = (self->vel.z * 192) >> 8; + self->Vel.Z *= 0.75; self->SetState (self->SpawnState); tiny = Spawn("MaceFX3", self->Pos(), ALLOW_REPLACE); tiny->target = self->target; tiny->Angles.Yaw = self->Angles.Yaw + 90.; - tiny->VelFromAngle(self->vel.z - FRACUNIT); - tiny->vel.x += (self->vel.x >> 1); - tiny->vel.y += (self->vel.y >> 1); - tiny->vel.z = self->vel.z; + tiny->VelFromAngle(self->Vel.Z - 1.); + tiny->Vel += { self->Vel.X * .5, self->Vel.Y * .5, self->Vel.Z }; P_CheckMissileSpawn (tiny, self->radius); tiny = Spawn("MaceFX3", self->Pos(), ALLOW_REPLACE); tiny->target = self->target; tiny->Angles.Yaw = self->Angles.Yaw - 90.; - tiny->VelFromAngle(self->vel.z - FRACUNIT); - tiny->vel.x += (self->vel.x >> 1); - tiny->vel.y += (self->vel.y >> 1); - tiny->vel.z = self->vel.z; + tiny->VelFromAngle(self->Vel.Z - 1.); + tiny->Vel += { self->Vel.X * .5, self->Vel.Y * .5, self->Vel.Z }; P_CheckMissileSpawn (tiny, self->radius); } else { // Explode boom: - self->vel.x = self->vel.y = self->vel.z = 0; + self->Vel.Zero(); self->flags |= MF_NOGRAVITY; self->BounceFlags = BOUNCE_None; self->gravity = FRACUNIT; @@ -605,10 +598,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL2) mo = P_SpawnPlayerMissile (self, 0,0,0, RUNTIME_CLASS(AMaceFX4), self->Angles.Yaw, &t); if (mo) { - mo->vel.x += self->vel.x; - mo->vel.y += self->vel.y; - mo->vel.z = 2*FRACUNIT+ - clamp(finetangent[FINEANGLES/4-(self->_f_pitch()>>ANGLETOFINESHIFT)], -5*FRACUNIT, 5*FRACUNIT); + mo->Vel += self->Vel.XY(); + mo->Vel.Z = 2 - player->mo->Angles.Pitch.TanClamped(); if (t.linetarget && !t.unlinked) { mo->tracer = t.linetarget; @@ -634,14 +625,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact) bool newAngle; FTranslatedLineTarget t; - if ((self->Z() <= self->floorz) && P_HitFloor (self)) + if ((self->_f_Z() <= self->floorz) && P_HitFloor (self)) { // Landed in some sort of liquid self->Destroy (); return 0; } if (self->flags & MF_INBOUNCE) { - if (self->vel.z < 2*FRACUNIT) + if (self->Vel.Z < 2) { goto boom; } @@ -688,7 +679,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact) else { // Explode boom: - self->vel.x = self->vel.y = self->vel.z = 0; + self->Vel.Zero(); self->flags |= MF_NOGRAVITY; self->gravity = FRACUNIT; S_Sound (self, CHAN_BODY, "weapons/maceexplode", 1, ATTN_NORM); @@ -730,7 +721,7 @@ void ABlasterFX1::Effect () { if (pr_bfx1t() < 64) { - Spawn("BlasterSmoke", X(), Y(), MAX (Z() - 8 * FRACUNIT, floorz), ALLOW_REPLACE); + Spawn("BlasterSmoke", _f_X(), _f_Y(), MAX (_f_Z() - 8 * FRACUNIT, floorz), ALLOW_REPLACE); } } @@ -1081,12 +1072,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm) newz = self->Sector->ceilingplane.ZatPoint(mo); int moceiling = P_Find3DFloor(NULL, pos.x, pos.y, newz, false, false, newz); if (moceiling >= 0) - mo->SetZ(newz - mo->height, false); + mo->_f_SetZ(newz - mo->height, false); mo->Translation = multiplayer ? TRANSLATION(TRANSLATION_RainPillar,self->special2) : 0; mo->target = self->target; - mo->vel.x = 1; // Force collision detection - mo->vel.z = -mo->Speed; + mo->Vel.X = MinVel; // Force collision detection + mo->Vel.Z = -mo->Speed; mo->special2 = self->special2; // Transfer player number P_CheckMissileSpawn (mo, self->radius); if (self->special1 != -1 && !S_IsActorPlayingSomething (self, CHAN_BODY, -1)) @@ -1105,7 +1096,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm) DEFINE_ACTION_FUNCTION(AActor, A_RainImpact) { PARAM_ACTION_PROLOGUE; - if (self->Z() > self->floorz) + if (self->_f_Z() > self->floorz) { self->SetState (self->FindState("NotFloor")); } @@ -1133,15 +1124,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_HideInCeiling) F3DFloor * rover = self->Sector->e->XFloor.ffloors[i]; if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - if ((foo = rover->bottom.plane->ZatPoint(self)) >= (self->Top())) + if ((foo = rover->bottom.plane->ZatPoint(self)) >= (self->_f_Top())) { - self->SetZ(foo + 4*FRACUNIT, false); + self->_f_SetZ(foo + 4*FRACUNIT, false); self->bouncecount = i; return 0; } } self->bouncecount = -1; - self->SetZ(self->ceilingz + 4*FRACUNIT, false); + self->_f_SetZ(self->ceilingz + 4*FRACUNIT, false); return 0; } @@ -1228,7 +1219,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL1) { PARAM_ACTION_PROLOGUE; - angle_t angle; player_t *player; if (NULL == (player = self->player)) @@ -1243,10 +1233,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL1) return 0; } P_SpawnPlayerMissile (self, RUNTIME_CLASS(APhoenixFX1)); - angle = self->_f_angle() + ANG180; - angle >>= ANGLETOFINESHIFT; - self->vel.x += FixedMul (4*FRACUNIT, finecosine[angle]); - self->vel.y += FixedMul (4*FRACUNIT, finesine[angle]); + self->Thrust(self->Angles.Yaw + 180, 4); return 0; } @@ -1261,22 +1248,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_PhoenixPuff) PARAM_ACTION_PROLOGUE; AActor *puff; - angle_t angle; + DAngle angle; //[RH] Heretic never sets the target for seeking //P_SeekerMissile (self, ANGLE_1*5, ANGLE_1*10); puff = Spawn("PhoenixPuff", self->Pos(), ALLOW_REPLACE); - angle = self->_f_angle() + ANG90; - angle >>= ANGLETOFINESHIFT; - puff->vel.x = FixedMul (FRACUNIT*13/10, finecosine[angle]); - puff->vel.y = FixedMul (FRACUNIT*13/10, finesine[angle]); - puff->vel.z = 0; + angle = self->Angles.Yaw + 90; + puff->Vel = DVector3(angle.ToVector(1.3), 0); + puff = Spawn("PhoenixPuff", self->Pos(), ALLOW_REPLACE); - angle = self->_f_angle() - ANG90; - angle >>= ANGLETOFINESHIFT; - puff->vel.x = FixedMul (FRACUNIT*13/10, finecosine[angle]); - puff->vel.y = FixedMul (FRACUNIT*13/10, finesine[angle]); - puff->vel.z = 0; + angle = self->Angles.Yaw - 90; + puff->Vel = DVector3(angle.ToVector(1.3), 0); return 0; } @@ -1315,7 +1297,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) AActor *mo; - fixed_t slope; + double slope; FSoundID soundid; player_t *player; APhoenixRod *flamethrower; @@ -1336,20 +1318,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) return 0; } - slope = FLOAT2FIXED(-self->Angles.Pitch.Tan()); + slope = -self->Angles.Pitch.TanClamped(); fixed_t xo = (pr_fp2.Random2() << 9); fixed_t yo = (pr_fp2.Random2() << 9); fixedvec3 pos = self->Vec3Offset(xo, yo, - 26*FRACUNIT + slope - self->floorclip); + 26*FRACUNIT + FLOAT2FIXED(slope) - self->floorclip); - slope += (FRACUNIT/10); + slope += 0.1; mo = Spawn("PhoenixFX2", pos, ALLOW_REPLACE); mo->target = self; mo->Angles.Yaw = self->Angles.Yaw; mo->VelFromAngle(); - mo->vel.x += self->vel.x; - mo->vel.y += self->vel.y; - mo->vel.z = FixedMul (mo->Speed, slope); + mo->Vel += self->Vel.XY(); + mo->Vel.Z = mo->Speed * slope; if (!player->refire || !S_IsActorPlayingSomething (self, CHAN_WEAPON, -1)) { S_Sound (self, CHAN_WEAPON|CHAN_LOOP, soundid, 1, ATTN_NORM); @@ -1394,7 +1375,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlameEnd) { PARAM_ACTION_PROLOGUE; - self->vel.z += FRACUNIT*3/2; + self->Vel.Z += 1.5; return 0; } @@ -1408,7 +1389,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FloatPuff) { PARAM_ACTION_PROLOGUE; - self->vel.z += FRACUNIT*18/10; + self->Vel.Z += 1.8; return 0; } diff --git a/src/g_heretic/a_ironlich.cpp b/src/g_heretic/a_ironlich.cpp index cdab04b27..d019357fc 100644 --- a/src/g_heretic/a_ironlich.cpp +++ b/src/g_heretic/a_ironlich.cpp @@ -31,8 +31,8 @@ int AWhirlwind::DoSpecialDamage (AActor *target, int damage, FName damagetype) if (!(target->flags7 & MF7_DONTTHRUST)) { target->Angles.Yaw += pr_foo.Random2() * (360 / 4096.); - target->vel.x += pr_foo.Random2() << 10; - target->vel.y += pr_foo.Random2() << 10; + target->Vel.X += pr_foo.Random2() / 64.; + target->Vel.Y += pr_foo.Random2() / 64.; } if ((level.time & 16) && !(target->flags2 & MF2_BOSS) && !(target->flags7 & MF7_DONTTHRUST)) @@ -42,10 +42,10 @@ int AWhirlwind::DoSpecialDamage (AActor *target, int damage, FName damagetype) { randVal = 160; } - target->vel.z += randVal << 11; - if (target->vel.z > 12*FRACUNIT) + target->Vel.Z += randVal / 32.; + if (target->Vel.Z > 12) { - target->vel.z = 12*FRACUNIT; + target->Vel.Z = 12; } } if (!(level.time & 7)) @@ -115,7 +115,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack) } fire->target = baseFire->target; fire->Angles.Yaw = baseFire->Angles.Yaw; - fire->vel = baseFire->vel; + fire->Vel = baseFire->Vel; fire->Damage = NULL; fire->health = (i+1) * 2; P_CheckMissileSpawn (fire, self->radius); @@ -127,7 +127,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack) mo = P_SpawnMissile (self, target, RUNTIME_CLASS(AWhirlwind)); if (mo != NULL) { - mo->AddZ(-32*FRACUNIT, false); + mo->_f_AddZ(-32*FRACUNIT, false); mo->tracer = target; mo->health = 20*TICRATE; // Duration S_Sound (self, CHAN_BODY, "ironlich/attack3", 1, ATTN_NORM); @@ -149,7 +149,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WhirlwindSeek) self->health -= 3; if (self->health < 0) { - self->vel.x = self->vel.y = self->vel.z = 0; + self->Vel.Zero(); self->SetState (self->FindState(NAME_Death)); self->flags &= ~MF_MISSILE; return 0; @@ -186,7 +186,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichIceImpact) shard->target = self->target; shard->Angles.Yaw = i*45.; shard->VelFromAngle(); - shard->vel.z = -FRACUNIT*6/10; + shard->Vel.Z = -.6; P_CheckMissileSpawn (shard, self->radius); } return 0; @@ -203,7 +203,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichFireGrow) PARAM_ACTION_PROLOGUE; self->health--; - self->AddZ(9*FRACUNIT); + self->_f_AddZ(9*FRACUNIT); if (self->health == 0) { self->Damage = self->GetDefault()->Damage; diff --git a/src/g_heretic/a_knight.cpp b/src/g_heretic/a_knight.cpp index a2b2cc45b..f8b8700d7 100644 --- a/src/g_heretic/a_knight.cpp +++ b/src/g_heretic/a_knight.cpp @@ -28,8 +28,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_DripBlood) fixed_t xo = (pr_dripblood.Random2() << 11); fixed_t yo = (pr_dripblood.Random2() << 11); mo = Spawn ("Blood", self->Vec3Offset(xo, yo, 0), ALLOW_REPLACE); - mo->vel.x = pr_dripblood.Random2 () << 10; - mo->vel.y = pr_dripblood.Random2 () << 10; + mo->Vel.X = pr_dripblood.Random2 () / 64.; + mo->Vel.Y = pr_dripblood.Random2() / 64.; mo->gravity = FRACUNIT/8; return 0; } @@ -60,11 +60,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_KnightAttack) S_Sound (self, CHAN_BODY, self->AttackSound, 1, ATTN_NORM); if (self->flags & MF_SHADOW || pr_knightatk () < 40) { // Red axe - P_SpawnMissileZ (self, self->Z() + 36*FRACUNIT, self->target, PClass::FindActor("RedAxe")); + P_SpawnMissileZ (self, self->_f_Z() + 36*FRACUNIT, self->target, PClass::FindActor("RedAxe")); return 0; } // Green axe - P_SpawnMissileZ (self, self->Z() + 36*FRACUNIT, self->target, PClass::FindActor("KnightAxe")); + P_SpawnMissileZ (self, self->_f_Z() + 36*FRACUNIT, self->target, PClass::FindActor("KnightAxe")); return 0; } diff --git a/src/g_heretic/a_wizard.cpp b/src/g_heretic/a_wizard.cpp index 42ae691cd..9fa858098 100644 --- a/src/g_heretic/a_wizard.cpp +++ b/src/g_heretic/a_wizard.cpp @@ -88,8 +88,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_WizAtk3) mo = P_SpawnMissile (self, self->target, fx); if (mo != NULL) { - P_SpawnMissileAngle(self, fx, mo->_f_angle()-(ANG45/8), mo->vel.z); - P_SpawnMissileAngle(self, fx, mo->_f_angle()+(ANG45/8), mo->vel.z); + P_SpawnMissileAngle(self, fx, mo->_f_angle()-(ANG45/8), mo->_f_velz()); + P_SpawnMissileAngle(self, fx, mo->_f_angle()+(ANG45/8), mo->_f_velz()); } return 0; } diff --git a/src/g_hexen/a_bats.cpp b/src/g_hexen/a_bats.cpp index 5ef7d0427..507af8011 100644 --- a/src/g_hexen/a_bats.cpp +++ b/src/g_hexen/a_bats.cpp @@ -64,7 +64,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BatMove) { PARAM_ACTION_PROLOGUE; - angle_t newangle; + DAngle newangle; if (self->special2 < 0) { @@ -74,17 +74,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_BatMove) if (pr_batmove()<128) { - newangle = self->_f_angle() + ANGLE_1*self->args[4]; + newangle = self->Angles.Yaw + self->args[4]; } else { - newangle = self->_f_angle() - ANGLE_1*self->args[4]; + newangle = self->Angles.Yaw - self->args[4]; } // Adjust velocity vector to new direction - newangle >>= ANGLETOFINESHIFT; - self->vel.x = FixedMul (self->Speed, finecosine[newangle]); - self->vel.y = FixedMul (self->Speed, finesine[newangle]); + self->VelFromAngle(newangle, self->Speed); if (pr_batmove()<15) { @@ -92,7 +90,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BatMove) } // Handle Z movement - self->SetZ(self->target->Z() + 16*finesine[self->args[0] << BOBTOFINESHIFT]); + self->SetZ(self->target->Z() + 16 * g_sin(BOBTORAD(self->args[0]))); self->args[0] = (self->args[0]+3)&63; return 0; } diff --git a/src/g_hexen/a_bishop.cpp b/src/g_hexen/a_bishop.cpp index 3ef2e19a8..95b668b82 100644 --- a/src/g_hexen/a_bishop.cpp +++ b/src/g_hexen/a_bishop.cpp @@ -146,8 +146,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopSpawnBlur) if (!--self->special1) { - self->vel.x = 0; - self->vel.y = 0; + self->Vel.X = self->Vel.Y = 0; if (pr_sblur() > 96) { self->SetState (self->SeeState); @@ -175,10 +174,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopChase) { PARAM_ACTION_PROLOGUE; - fixed_t newz = self->Z() - finesine[self->special2 << BOBTOFINESHIFT] * 4; + fixed_t newz = self->_f_Z() - finesine[self->special2 << BOBTOFINESHIFT] * 4; self->special2 = (self->special2 + 4) & 63; newz += finesine[self->special2 << BOBTOFINESHIFT] * 4; - self->SetZ(newz); + self->_f_SetZ(newz); return 0; } @@ -197,7 +196,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopPuff) mo = Spawn ("BishopPuff", self->PosPlusZ(40*FRACUNIT), ALLOW_REPLACE); if (mo) { - mo->vel.z = FRACUNIT/2; + mo->Vel.Z = -.5; } return 0; } diff --git a/src/g_hexen/a_blastradius.cpp b/src/g_hexen/a_blastradius.cpp index b587122e3..d9138a62b 100644 --- a/src/g_hexen/a_blastradius.cpp +++ b/src/g_hexen/a_blastradius.cpp @@ -22,9 +22,9 @@ // //========================================================================== -void BlastActor (AActor *victim, fixed_t strength, fixed_t speed, AActor *Owner, PClassActor *blasteffect, bool dontdamage) +void BlastActor (AActor *victim, fixed_t strength, double speed, AActor *Owner, PClassActor *blasteffect, bool dontdamage) { - angle_t angle,ang; + DAngle angle; AActor *mo; fixedvec3 pos; @@ -33,36 +33,34 @@ void BlastActor (AActor *victim, fixed_t strength, fixed_t speed, AActor *Owner, return; } - angle = Owner->__f_AngleTo(victim); - angle >>= ANGLETOFINESHIFT; - victim->vel.x = FixedMul (speed, finecosine[angle]); - victim->vel.y = FixedMul (speed, finesine[angle]); + angle = Owner->AngleTo(victim); + DVector2 move = angle.ToVector(speed); + victim->Vel.X = move.X; + victim->Vel.Y = move.Y; // Spawn blast puff - ang = victim->__f_AngleTo(Owner); - ang >>= ANGLETOFINESHIFT; + angle -= 180.; pos = victim->Vec3Offset( - FixedMul (victim->radius+FRACUNIT, finecosine[ang]), - FixedMul (victim->radius+FRACUNIT, finesine[ang]), + fixed_t((victim->radius + FRACUNIT) * angle.Cos()), + fixed_t((victim->radius + FRACUNIT) * angle.Sin()), -victim->floorclip + (victim->height>>1)); mo = Spawn (blasteffect, pos, ALLOW_REPLACE); if (mo) { - mo->vel.x = victim->vel.x; - mo->vel.y = victim->vel.y; + mo->Vel.X = victim->Vel.X; + mo->Vel.Y = victim->Vel.Y; } if (victim->flags & MF_MISSILE) { // [RH] Floor and ceiling huggers should not be blasted vertically. if (!(victim->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) { - victim->vel.z = 8*FRACUNIT; - mo->vel.z = victim->vel.z; + mo->Vel.Z = victim->Vel.Z = 8; } } else { - victim->vel.z = (1000 / victim->Mass) << FRACBITS; + victim->Vel.Z = 1000. / victim->Mass; } if (victim->player) { @@ -101,7 +99,7 @@ DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_Blast) PARAM_INT_OPT (blastflags) { blastflags = 0; } PARAM_FIXED_OPT (strength) { strength = 255*FRACUNIT; } PARAM_FIXED_OPT (radius) { radius = 255*FRACUNIT; } - PARAM_FIXED_OPT (speed) { speed = 20*FRACUNIT; } + PARAM_FLOAT_OPT (speed) { speed = 20; } PARAM_CLASS_OPT (blasteffect, AActor) { blasteffect = PClass::FindActor("BlastEffect"); } PARAM_SOUND_OPT (blastsound) { blastsound = "BlastRadius"; } diff --git a/src/g_hexen/a_clericflame.cpp b/src/g_hexen/a_clericflame.cpp index 04ee1235c..e14b4855e 100644 --- a/src/g_hexen/a_clericflame.cpp +++ b/src/g_hexen/a_clericflame.cpp @@ -13,9 +13,9 @@ #include "thingdef/thingdef.h" */ -const fixed_t FLAMESPEED = fixed_t(0.45*FRACUNIT); +const double FLAMESPEED = 0.45; const fixed_t CFLAMERANGE = 12*64*FRACUNIT; -const fixed_t FLAMEROTSPEED = 2*FRACUNIT; +const double FLAMEROTSPEED = 2.; static FRandom pr_missile ("CFlameMissile"); @@ -48,12 +48,12 @@ void ACFlameMissile::Effect () if (!--special1) { special1 = 4; - newz = Z()-12*FRACUNIT; + newz = _f_Z()-12*FRACUNIT; if (newz < floorz) { newz = floorz; } - AActor *mo = Spawn ("CFlameFloor", X(), Y(), newz, ALLOW_REPLACE); + AActor *mo = Spawn ("CFlameFloor", _f_X(), _f_Y(), newz, ALLOW_REPLACE); if (mo) { mo->Angles.Yaw = Angles.Yaw; @@ -99,9 +99,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlamePuff) PARAM_ACTION_PROLOGUE; self->renderflags &= ~RF_INVISIBLE; - self->vel.x = 0; - self->vel.y = 0; - self->vel.z = 0; + self->Vel.Zero(); S_Sound (self, CHAN_BODY, "ClericFlameExplode", 1, ATTN_NORM); return 0; } @@ -138,8 +136,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile) mo->Angles.Yaw = an; mo->target = self->target; mo->VelFromAngle(FLAMESPEED); - mo->special1 = mo->vel.x; - mo->special2 = mo->vel.y; + mo->special1 = FLOAT2FIXED(mo->Vel.X); + mo->special2 = FLOAT2FIXED(mo->Vel.Y); mo->tics -= pr_missile()&3; } mo = Spawn ("CircleFlame", BlockingMobj->Vec3Offset( @@ -150,8 +148,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile) mo->Angles.Yaw = an + 180.; mo->target = self->target; mo->VelFromAngle(-FLAMESPEED); - mo->special1 = mo->vel.x; - mo->special2 = mo->vel.y; + mo->special1 = FLOAT2FIXED(mo->Vel.X); + mo->special2 = FLOAT2FIXED(mo->Vel.Y); mo->tics -= pr_missile()&3; } } @@ -172,8 +170,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameRotate) DAngle an = self->Angles.Yaw + 90.; self->VelFromAngle(an, FLAMEROTSPEED); - self->vel.x += self->special1; - self->vel.y += self->special2; + self->Vel += DVector2(FIXED2DBL(self->special1), FIXED2DBL(self->special2)); self->Angles.Yaw += 6.; return 0; diff --git a/src/g_hexen/a_clericholy.cpp b/src/g_hexen/a_clericholy.cpp index fe0e8a907..6e6dccd97 100644 --- a/src/g_hexen/a_clericholy.cpp +++ b/src/g_hexen/a_clericholy.cpp @@ -159,9 +159,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack2) mo->special2 = ((FINEANGLES/2 + i) << 16) + FINEANGLES/2 + pr_holyatk2(8 << BOBTOFINESHIFT); break; } - mo->SetZ(self->Z()); + mo->_f_SetZ(self->_f_Z()); mo->Angles.Yaw = self->Angles.Yaw + 67.5 - 45.*j; - P_ThrustMobj(mo, mo->_f_angle(), mo->Speed); + P_ThrustMobj(mo, mo->_f_angle(), mo->_f_speed()); mo->target = self->target; mo->args[0] = 10; // initial turn value mo->args[1] = 0; // initial look angle @@ -276,24 +276,24 @@ static void CHolyTailFollow (AActor *actor, fixed_t dist) { an = actor->__f_AngleTo(child) >> ANGLETOFINESHIFT; oldDistance = child->AproxDistance (actor); - if (P_TryMove (child, actor->X()+FixedMul(dist, finecosine[an]), - actor->Y()+FixedMul(dist, finesine[an]), true)) + if (P_TryMove (child, actor->_f_X()+FixedMul(dist, finecosine[an]), + actor->_f_Y()+FixedMul(dist, finesine[an]), true)) { newDistance = child->AproxDistance (actor)-FRACUNIT; if (oldDistance < FRACUNIT) { if (child->Z() < actor->Z()) { - child->SetZ(actor->Z()-dist); + child->_f_SetZ(actor->_f_Z()-dist); } else { - child->SetZ(actor->Z()+dist); + child->_f_SetZ(actor->_f_Z()+dist); } } else { - child->SetZ(actor->Z() + Scale (newDistance, child->Z()-actor->Z(), oldDistance)); + child->_f_SetZ(actor->_f_Z() + Scale (newDistance, child->_f_Z()-actor->_f_Z(), oldDistance)); } } } @@ -342,10 +342,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyTail) else { if (P_TryMove (self, - parent->X() - 14*finecosine[parent->_f_angle()>>ANGLETOFINESHIFT], - parent->Y() - 14*finesine[parent->_f_angle()>>ANGLETOFINESHIFT], true)) + parent->_f_X() - 14*finecosine[parent->_f_angle()>>ANGLETOFINESHIFT], + parent->_f_Y() - 14*finesine[parent->_f_angle()>>ANGLETOFINESHIFT], true)) { - self->SetZ(parent->Z()-5*FRACUNIT); + self->_f_SetZ(parent->_f_Z()-5*FRACUNIT); } CHolyTailFollow (self, 10*FRACUNIT); } @@ -423,8 +423,8 @@ static void CHolySeekerMissile (AActor *actor, DAngle thresh, DAngle turnMax) || actor->Z() > target->Top() || actor->Top() < target->Z()) { - newZ = target->Z()+((pr_holyseeker()*target->height)>>8); - deltaZ = newZ - actor->Z(); + newZ = target->_f_Z()+((pr_holyseeker()*target->height)>>8); + deltaZ = newZ - actor->_f_Z(); if (abs(deltaZ) > 15*FRACUNIT) { if (deltaZ > 0) @@ -437,12 +437,12 @@ static void CHolySeekerMissile (AActor *actor, DAngle thresh, DAngle turnMax) } } dist = actor->AproxDistance (target); - dist = dist / actor->Speed; + dist = dist / actor->_f_speed(); if (dist < 1) { dist = 1; } - actor->vel.z = deltaZ / dist; + actor->Vel.Z = FIXED2DBL(deltaZ / dist); } return; } @@ -462,17 +462,17 @@ void CHolyWeave (AActor *actor, FRandom &pr_random) weaveXY = actor->special2 >> 16; weaveZ = actor->special2 & FINEMASK; angle = (actor->_f_angle() + ANG90) >> ANGLETOFINESHIFT; - newX = actor->X() - FixedMul(finecosine[angle], finesine[weaveXY] * 32); - newY = actor->Y() - FixedMul(finesine[angle], finesine[weaveXY] * 32); + newX = actor->_f_X() - FixedMul(finecosine[angle], finesine[weaveXY] * 32); + newY = actor->_f_Y() - FixedMul(finesine[angle], finesine[weaveXY] * 32); weaveXY = (weaveXY + pr_random(5 << BOBTOFINESHIFT)) & FINEMASK; newX += FixedMul(finecosine[angle], finesine[weaveXY] * 32); newY += FixedMul(finesine[angle], finesine[weaveXY] * 32); P_TryMove(actor, newX, newY, true); - newZ = actor->Z(); + newZ = actor->_f_Z(); newZ -= finesine[weaveZ] * 16; weaveZ = (weaveZ + pr_random(5 << BOBTOFINESHIFT)) & FINEMASK; newZ += finesine[weaveZ] * 16; - actor->SetZ(newZ); + actor->_f_SetZ(newZ); actor->special2 = weaveZ + (weaveXY << 16); } @@ -489,9 +489,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolySeek) self->health--; if (self->health <= 0) { - self->vel.x >>= 2; - self->vel.y >>= 2; - self->vel.z = 0; + self->Vel.X /= 4; + self->Vel.Y /= 4; + self->Vel.Z = 0; self->SetState (self->FindState(NAME_Death)); self->tics -= pr_holyseek()&3; return 0; @@ -543,7 +543,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClericAttack) if (!self->target) return 0; - AActor * missile = P_SpawnMissileZ (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindActor ("HolyMissile")); + AActor * missile = P_SpawnMissileZ (self, self->_f_Z() + 40*FRACUNIT, self->target, PClass::FindActor ("HolyMissile")); if (missile != NULL) missile->tracer = NULL; // No initial target S_Sound (self, CHAN_WEAPON, "HolySymbolFire", 1, ATTN_NORM); return 0; diff --git a/src/g_hexen/a_dragon.cpp b/src/g_hexen/a_dragon.cpp index 61141a65a..e11cc4bf0 100644 --- a/src/g_hexen/a_dragon.cpp +++ b/src/g_hexen/a_dragon.cpp @@ -25,7 +25,7 @@ DECLARE_ACTION(A_DragonFlight) static void DragonSeek (AActor *actor, DAngle thresh, DAngle turnMax) { int dir; - int dist; + double dist; DAngle delta; AActor *target; int i; @@ -57,15 +57,11 @@ static void DragonSeek (AActor *actor, DAngle thresh, DAngle turnMax) } actor->VelFromAngle(); - dist = actor->AproxDistance (target) / actor->Speed; + dist = actor->DistanceBySpeed(target, actor->Speed); if (actor->Top() < target->Z() || target->Top() < actor->Z()) { - if (dist < 1) - { - dist = 1; - } - actor->vel.z = (target->Z() - actor->Z())/dist; + actor->Vel.Z = (target->Z() - actor->Z()) / dist; } if (target->flags&MF_SHOOTABLE && pr_dragonseek() < 64) { // attack the destination mobj if it's attackable @@ -306,7 +302,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonCheckCrash) { PARAM_ACTION_PROLOGUE; - if (self->Z() <= self->floorz) + if (self->_f_Z() <= self->floorz) { self->SetState (self->FindState ("Crash")); } diff --git a/src/g_hexen/a_fighterquietus.cpp b/src/g_hexen/a_fighterquietus.cpp index 9c42f8c1d..abc8cf0c9 100644 --- a/src/g_hexen/a_fighterquietus.cpp +++ b/src/g_hexen/a_fighterquietus.cpp @@ -31,19 +31,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropWeaponPieces) PARAM_CLASS(p2, AActor); PARAM_CLASS(p3, AActor); - for (int i = 0, j = 0, fineang = 0; i < 3; ++i) + for (int i = 0, j = 0; i < 3; ++i) { PClassActor *cls = j == 0 ? p1 : j == 1 ? p2 : p3; if (cls) { - AActor *piece = Spawn (cls, self->Pos(), ALLOW_REPLACE); + AActor *piece = Spawn (cls, self->_f_Pos(), ALLOW_REPLACE); if (piece != NULL) { - piece->vel.x = self->vel.x + finecosine[fineang]; - piece->vel.y = self->vel.y + finesine[fineang]; - piece->vel.z = self->vel.z; + piece->Vel = self->Vel + DAngle(i*120.).ToVector(1); piece->flags |= MF_DROPPED; - fineang += FINEANGLES/3; j = (j == 0) ? (pr_quietusdrop() & 1) + 1 : 3-j; } } diff --git a/src/g_hexen/a_firedemon.cpp b/src/g_hexen/a_firedemon.cpp index 175048a2c..729c7fed2 100644 --- a/src/g_hexen/a_firedemon.cpp +++ b/src/g_hexen/a_firedemon.cpp @@ -61,9 +61,9 @@ void A_FiredSpawnRock (AActor *actor) if (mo) { mo->target = actor; - mo->vel.x = (pr_firedemonrock() - 128) <<10; - mo->vel.y = (pr_firedemonrock() - 128) <<10; - mo->vel.z = (pr_firedemonrock() << 10); + mo->Vel.X = (pr_firedemonrock() - 128) / 64.; + mo->Vel.Y = (pr_firedemonrock() - 128) / 64.; + mo->Vel.Z = (pr_firedemonrock() / 64.); mo->special1 = 2; // Number bounces } @@ -101,10 +101,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SmBounce) PARAM_ACTION_PROLOGUE; // give some more velocity (x,y,&z) - self->SetZ(self->floorz + FRACUNIT); - self->vel.z = (2*FRACUNIT) + (pr_smbounce() << 10); - self->vel.x = pr_smbounce()%3<vel.y = pr_smbounce()%3<_f_SetZ(self->floorz + FRACUNIT); + self->Vel.Z = 2. + pr_smbounce() / 64.; + self->Vel.X = pr_smbounce() % 3; + self->Vel.Y = pr_smbounce() % 3; return 0; } @@ -137,20 +137,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase) int weaveindex = self->special1; AActor *target = self->target; - angle_t ang; + DAngle ang; fixed_t dist; if (self->reactiontime) self->reactiontime--; if (self->threshold) self->threshold--; // Float up and down - self->AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 8); + self->_f_AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 8); self->special1 = (weaveindex + 2) & 63; // Ensure it stays above certain height - if (self->Z() < self->floorz + (64*FRACUNIT)) + if (self->_f_Z() < self->floorz + (64*FRACUNIT)) { - self->AddZ(2*FRACUNIT); + self->_f_AddZ(2*FRACUNIT); } if(!self->target || !(self->target->flags&MF_SHOOTABLE)) @@ -167,20 +167,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase) else { self->special2 = 0; - self->vel.x = self->vel.y = 0; + self->Vel.X = self->Vel.Y = 0; dist = self->AproxDistance (target); if (dist < FIREDEMON_ATTACK_RANGE) { if (pr_firedemonchase() < 30) { - ang = self->__f_AngleTo(target); + ang = self->AngleTo(target); if (pr_firedemonchase() < 128) - ang += ANGLE_90; + ang += 90; else - ang -= ANGLE_90; - ang >>= ANGLETOFINESHIFT; - self->vel.x = finecosine[ang] << 3; //FixedMul (8*FRACUNIT, finecosine[ang]); - self->vel.y = finesine[ang] << 3; //FixedMul (8*FRACUNIT, finesine[ang]); + ang -= 90; + self->Thrust(ang, 8); self->special2 = 3; // strafe time } } @@ -235,16 +233,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredSplotch) mo = Spawn ("FireDemonSplotch1", self->Pos(), ALLOW_REPLACE); if (mo) { - mo->vel.x = (pr_firedemonsplotch() - 128) << 11; - mo->vel.y = (pr_firedemonsplotch() - 128) << 11; - mo->vel.z = (pr_firedemonsplotch() << 10) + FRACUNIT*3; + mo->Vel.X = (pr_firedemonsplotch() - 128) / 32.; + mo->Vel.Y = (pr_firedemonsplotch() - 128) / 32.; + mo->Vel.Z = (pr_firedemonsplotch() / 64.) + 3; } mo = Spawn ("FireDemonSplotch2", self->Pos(), ALLOW_REPLACE); if (mo) { - mo->vel.x = (pr_firedemonsplotch() - 128) << 11; - mo->vel.y = (pr_firedemonsplotch() - 128) << 11; - mo->vel.z = (pr_firedemonsplotch() << 10) + FRACUNIT*3; + mo->Vel.X = (pr_firedemonsplotch() - 128) / 32.; + mo->Vel.Y = (pr_firedemonsplotch() - 128) / 32.; + mo->Vel.Z = (pr_firedemonsplotch() / 64.) + 3; } return 0; } diff --git a/src/g_hexen/a_flechette.cpp b/src/g_hexen/a_flechette.cpp index 0a691a64e..9f13611c1 100644 --- a/src/g_hexen/a_flechette.cpp +++ b/src/g_hexen/a_flechette.cpp @@ -114,16 +114,16 @@ bool AArtiPoisonBag3::Use (bool pickup) // is as set by the projectile. To accommodate this with a proper trajectory, we // aim the projectile ~20 degrees higher than we're looking at and increase the // speed we fire at accordingly. - angle_t orgpitch = angle_t(-Owner->_f_pitch()) >> ANGLETOFINESHIFT; - angle_t modpitch = angle_t(0xDC00000 - Owner->_f_pitch()) >> ANGLETOFINESHIFT; - angle_t angle = mo->_f_angle() >> ANGLETOFINESHIFT; - fixed_t speed = fixed_t(g_sqrt((double)mo->Speed*mo->Speed + (4.0*65536*4*65536))); - fixed_t xyscale = FixedMul(speed, finecosine[modpitch]); + DAngle orgpitch = -Owner->Angles.Pitch; + DAngle modpitch = clamp(-Owner->Angles.Pitch + 20, -89., 89.); + DAngle angle = mo->Angles.Yaw; + double speed = DVector2(mo->Speed, 4.).Length(); + double xyscale = speed * modpitch.Cos(); - mo->vel.z = FixedMul(speed, finesine[modpitch]); - mo->vel.x = FixedMul(xyscale, finecosine[angle]) + (Owner->vel.x >> 1); - mo->vel.y = FixedMul(xyscale, finesine[angle]) + (Owner->vel.y >> 1); - mo->AddZ(FixedMul(mo->Speed, finesine[orgpitch])); + mo->Vel.Z = speed * modpitch.Sin(); + mo->Vel.X = xyscale * angle.Cos() + Owner->Vel.X / 2; + mo->Vel.Y = xyscale * angle.Sin() + Owner->Vel.Y / 2; + mo->AddZ(mo->Speed * orgpitch.Sin()); mo->target = Owner; mo->tics -= pr_poisonbag()&3; @@ -306,7 +306,7 @@ IMPLEMENT_CLASS (APoisonCloud) void APoisonCloud::BeginPlay () { - vel.x = 1; // missile objects must move to impact other objects + Vel.X = MinVel; // missile objects must move to impact other objects special1 = 24+(pr_poisoncloud()&7); special2 = 0; } @@ -419,7 +419,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagDamage) P_RadiusAttack (self, self->target, 4, 40, self->DamageType, RADF_HURTSOURCE); bobIndex = self->special2; - self->AddZ(finesine[bobIndex << BOBTOFINESHIFT] >> 1); + self->_f_AddZ(finesine[bobIndex << BOBTOFINESHIFT] >> 1); self->special2 = (bobIndex + 1) & 63; return 0; } @@ -454,13 +454,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckThrowBomb2) // [RH] Check using actual velocity, although the vel.z < 2 check still stands //if (abs(self->vel.x) < FRACUNIT*3/2 && abs(self->vel.y) < FRACUNIT*3/2 // && self->vel.z < 2*FRACUNIT) - if (self->vel.z < 2*FRACUNIT && - TMulScale32 (self->vel.x, self->vel.x, self->vel.y, self->vel.y, self->vel.z, self->vel.z) - < (3*3)/(2*2)) + if (self->Vel.Z < 2 && self->Vel.LengthSquared() < (9./4.)) { self->SetState (self->SpawnState + 6); - self->SetZ(self->floorz); - self->vel.z = 0; + self->_f_SetZ(self->floorz); + self->Vel.Z = 0; self->BounceFlags = BOUNCE_None; self->flags &= ~MF_MISSILE; } diff --git a/src/g_hexen/a_flies.cpp b/src/g_hexen/a_flies.cpp index b9127e9c3..9714f6a72 100644 --- a/src/g_hexen/a_flies.cpp +++ b/src/g_hexen/a_flies.cpp @@ -88,22 +88,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlyBuzz) self->args[0]++; angle_t ang = self->__f_AngleTo(targ); ang >>= ANGLETOFINESHIFT; - if (!P_TryMove(self, self->X() + 6 * finecosine[ang], self->Y() + 6 * finesine[ang], true)) + if (!P_TryMove(self, self->_f_X() + 6 * finecosine[ang], self->_f_Y() + 6 * finesine[ang], true)) { self->SetIdle(true); return 0; } if (self->args[0] & 2) { - self->vel.x += (pr_fly() - 128) << BOBTOFINESHIFT; - self->vel.y += (pr_fly() - 128) << BOBTOFINESHIFT; + self->Vel.X += (pr_fly() - 128) / 512.; + self->Vel.Y += (pr_fly() - 128) / 512.; } int zrand = pr_fly(); - if (targ->Z() + 5*FRACUNIT < self->Z() && zrand > 150) + if (targ->Z() + 5. < self->Z() && zrand > 150) { zrand = -zrand; } - self->vel.z = zrand << BOBTOFINESHIFT; + self->Vel.Z = zrand / 512.; if (pr_fly() < 40) { S_Sound(self, CHAN_VOICE, self->ActiveSound, 0.5f, ATTN_STATIC); diff --git a/src/g_hexen/a_fog.cpp b/src/g_hexen/a_fog.cpp index 9815c2449..90c069223 100644 --- a/src/g_hexen/a_fog.cpp +++ b/src/g_hexen/a_fog.cpp @@ -89,7 +89,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogMove) if ((self->args[3] % 4) == 0) { weaveindex = self->special2; - self->AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 4); + self->_f_AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 4); self->special2 = (weaveindex + 1) & 63; } diff --git a/src/g_hexen/a_heresiarch.cpp b/src/g_hexen/a_heresiarch.cpp index ed6608c24..f1e69aaea 100644 --- a/src/g_hexen/a_heresiarch.cpp +++ b/src/g_hexen/a_heresiarch.cpp @@ -658,7 +658,7 @@ void A_SorcOffense2(AActor *actor) int delta, index; AActor *parent = actor->target; AActor *dest = parent->target; - int dist; + double dist; // [RH] If no enemy, then don't try to shoot. if (dest == NULL) @@ -675,9 +675,8 @@ void A_SorcOffense2(AActor *actor) if (mo) { mo->special2 = 35*5/2; // 5 seconds - dist = mo->AproxDistance(dest) / mo->Speed; - if(dist < 1) dist = 1; - mo->vel.z = (dest->Z() - mo->Z()) / dist; + dist = mo->DistanceBySpeed(dest, mo->Speed); + mo->Vel.Z = (dest->Z() - mo->Z()) / dist; } } @@ -710,21 +709,21 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnFizzle) { PARAM_ACTION_PROLOGUE; fixed_t dist = 5*FRACUNIT; - fixed_t speed = self->Speed; - angle_t rangle; + int speed = (int)self->Speed; + DAngle rangle; AActor *mo; int ix; - fixedvec3 pos = self->Vec3Angle(dist, self->_f_angle(), -self->floorclip + (self->height >> 1)); + fixedvec3 pos = self->_f_Vec3Angle(dist, self->_f_angle(), -self->floorclip + (self->height >> 1)); for (ix=0; ix<5; ix++) { mo = Spawn("SorcSpark1", pos, ALLOW_REPLACE); if (mo) { - rangle = (self->_f_angle() >> ANGLETOFINESHIFT) + ((pr_heresiarch()%5) << 1); - mo->vel.x = FixedMul(pr_heresiarch()%speed, finecosine[rangle]); - mo->vel.y = FixedMul(pr_heresiarch()%speed, finesine[rangle]); - mo->vel.z = FRACUNIT*2; + rangle = self->Angles.Yaw + (pr_heresiarch() % 5) * (4096 / 360.); + mo->Vel.X = (pr_heresiarch() % speed) * rangle.Cos(); + mo->Vel.Y = (pr_heresiarch() % speed) * rangle.Sin(); + mo->Vel.Z = 2; } } return 0; @@ -944,9 +943,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallPop) S_Sound (self, CHAN_BODY, "SorcererBallPop", 1, ATTN_NONE); self->flags &= ~MF_NOGRAVITY; self->gravity = FRACUNIT/8; - self->vel.x = ((pr_heresiarch()%10)-5) << FRACBITS; - self->vel.y = ((pr_heresiarch()%10)-5) << FRACBITS; - self->vel.z = (2+(pr_heresiarch()%3)) << FRACBITS; + + self->Vel.X = ((pr_heresiarch()%10)-5); + self->Vel.Y = ((pr_heresiarch()%10)-5); + self->Vel.Z = (2+(pr_heresiarch()%3)); self->special2 = 4*FRACUNIT; // Initial bounce factor self->args[4] = BOUNCE_TIME_UNIT; // Bounce time unit self->args[3] = 5; // Bounce time in seconds diff --git a/src/g_hexen/a_hexenspecialdecs.cpp b/src/g_hexen/a_hexenspecialdecs.cpp index 13cc8e669..ea4e77d1b 100644 --- a/src/g_hexen/a_hexenspecialdecs.cpp +++ b/src/g_hexen/a_hexenspecialdecs.cpp @@ -66,9 +66,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryExplode) if (mo) { mo->SetState (mo->SpawnState + (pr_pottery()%5)); - mo->vel.z = ((pr_pottery()&7)+5)*(3*FRACUNIT/4); - mo->vel.x = (pr_pottery.Random2())<<(FRACBITS-6); - mo->vel.y = (pr_pottery.Random2())<<(FRACBITS-6); + mo->Vel.X = pr_pottery.Random2() / 64.; + mo->Vel.Y = pr_pottery.Random2() / 64.; + mo->Vel.Z = ((pr_pottery() & 7) + 5) * 0.75; } } S_Sound (mo, CHAN_BODY, "PotteryExplode", 1, ATTN_NORM); @@ -141,7 +141,7 @@ IMPLEMENT_CLASS (AZCorpseLynchedNoHeart) void AZCorpseLynchedNoHeart::PostBeginPlay () { Super::PostBeginPlay (); - Spawn ("BloodPool", X(), Y(), floorz, ALLOW_REPLACE); + Spawn ("BloodPool", _f_X(), _f_Y(), floorz, ALLOW_REPLACE); } //============================================================================ @@ -180,19 +180,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_CorpseExplode) if (mo) { mo->SetState (mo->SpawnState + (pr_foo()%3)); - mo->vel.z = ((pr_foo()&7)+5)*(3*FRACUNIT/4); - mo->vel.x = pr_foo.Random2()<<(FRACBITS-6); - mo->vel.y = pr_foo.Random2()<<(FRACBITS-6); + mo->Vel.X = pr_foo.Random2() / 64.; + mo->Vel.Y = pr_foo.Random2() / 64.; + mo->Vel.Z = ((pr_foo() & 7) + 5) * 0.75; } } // Spawn a skull - mo = Spawn ("CorpseBit", self->Pos(), ALLOW_REPLACE); + mo = Spawn ("CorpseBit", self->_f_Pos(), ALLOW_REPLACE); if (mo) { mo->SetState (mo->SpawnState + 3); - mo->vel.z = ((pr_foo()&7)+5)*(3*FRACUNIT/4); - mo->vel.x = pr_foo.Random2()<<(FRACBITS-6); - mo->vel.y = pr_foo.Random2()<<(FRACBITS-6); + mo->Vel.X = pr_foo.Random2() / 64.; + mo->Vel.Y = pr_foo.Random2() / 64.; + mo->Vel.Z = ((pr_foo() & 7) + 5) * 0.75; } S_Sound (self, CHAN_BODY, self->DeathSound, 1, ATTN_IDLE); self->Destroy (); @@ -242,7 +242,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafThrust) if (pr_leafthrust() <= 96) { - self->vel.z += (pr_leafthrust()<<9)+FRACUNIT; + self->Vel.Z += pr_leafthrust() / 128. + 1; } return 0; } @@ -266,14 +266,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafCheck) angle_t ang = self->target ? self->target->_f_angle() : self->_f_angle(); if (pr_leafcheck() > 64) { - if (!self->vel.x && !self->vel.y) + if (self->Vel.X == 0 && self->Vel.Y == 0) { P_ThrustMobj (self, ang, (pr_leafcheck()<<9)+FRACUNIT); } return 0; } self->SetState (self->SpawnState + 7); - self->vel.z = (pr_leafcheck()<<9)+FRACUNIT; + self->Vel.Z = pr_leafcheck() / 128. + 1; P_ThrustMobj (self, ang, (pr_leafcheck()<<9)+2*FRACUNIT); self->flags |= MF_MISSILE; return 0; @@ -315,9 +315,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_SoAExplode) if (mo) { mo->SetState (mo->SpawnState + i); - mo->vel.z = ((pr_soaexplode()&7)+5)*FRACUNIT; - mo->vel.x = pr_soaexplode.Random2()<<(FRACBITS-6); - mo->vel.y = pr_soaexplode.Random2()<<(FRACBITS-6); + mo->Vel.X = pr_soaexplode.Random2() / 64.; + mo->Vel.Y = pr_soaexplode.Random2() / 64.; + mo->Vel.Z = (pr_soaexplode() & 7) + 5; } } // Spawn an item? diff --git a/src/g_hexen/a_iceguy.cpp b/src/g_hexen/a_iceguy.cpp index 699c50ca5..ecaf31e14 100644 --- a/src/g_hexen/a_iceguy.cpp +++ b/src/g_hexen/a_iceguy.cpp @@ -71,9 +71,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyChase) 60 * FRACUNIT), ALLOW_REPLACE); if (mo) { - mo->vel.x = self->vel.x; - mo->vel.y = self->vel.y; - mo->vel.z = self->vel.z; + mo->Vel = self->Vel; mo->target = self; } } @@ -94,8 +92,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyAttack) { return 0; } - P_SpawnMissileXYZ(self->Vec3Angle(self->radius>>1, self->_f_angle()+ANG90, 40*FRACUNIT), self, self->target, PClass::FindActor ("IceGuyFX")); - P_SpawnMissileXYZ(self->Vec3Angle(self->radius>>1, self->_f_angle()-ANG90, 40*FRACUNIT), self, self->target, PClass::FindActor ("IceGuyFX")); + P_SpawnMissileXYZ(self->_f_Vec3Angle(self->radius>>1, self->_f_angle()+ANG90, 40*FRACUNIT), self, self->target, PClass::FindActor ("IceGuyFX")); + P_SpawnMissileXYZ(self->_f_Vec3Angle(self->radius>>1, self->_f_angle()-ANG90, 40*FRACUNIT), self, self->target, PClass::FindActor ("IceGuyFX")); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); return 0; } @@ -110,9 +108,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyDie) { PARAM_ACTION_PROLOGUE; - self->vel.x = 0; - self->vel.y = 0; - self->vel.z = 0; + self->Vel.Zero(); self->height = self->GetDefault()->height; CALL_ACTION(A_FreezeDeathChunks, self); return 0; @@ -133,7 +129,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyMissileExplode) for (i = 0; i < 8; i++) { - mo = P_SpawnMissileAngleZ (self, self->Z()+3*FRACUNIT, + mo = P_SpawnMissileAngleZ (self, self->_f_Z()+3*FRACUNIT, PClass::FindActor("IceGuyFX2"), i*ANG45, (fixed_t)(-0.3*FRACUNIT)); if (mo) { diff --git a/src/g_hexen/a_korax.cpp b/src/g_hexen/a_korax.cpp index e420105bd..a431b97a3 100644 --- a/src/g_hexen/a_korax.cpp +++ b/src/g_hexen/a_korax.cpp @@ -99,7 +99,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) spot = iterator.Next (); if (spot != NULL) { - P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->Angles.Yaw, TELF_SOURCEFOG | TELF_DESTFOG); + P_Teleport (self, spot->_f_X(), spot->_f_Y(), ONFLOORZ, spot->Angles.Yaw, TELF_SOURCEFOG | TELF_DESTFOG); } P_StartScript (self, NULL, 249, NULL, NULL, 0, 0); @@ -141,7 +141,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) self->tracer = spot; if (spot) { - P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->Angles.Yaw, TELF_SOURCEFOG | TELF_DESTFOG); + P_Teleport (self, spot->_f_X(), spot->_f_Y(), ONFLOORZ, spot->Angles.Yaw, TELF_SOURCEFOG | TELF_DESTFOG); } } } @@ -388,11 +388,11 @@ static void A_KSpiritSeeker (AActor *actor, DAngle thresh, DAngle turnMax) actor->VelFromAngle(); if (!(level.time&15) - || actor->Z() > target->Z()+(target->GetDefault()->height) - || actor->Top() < target->Z()) + || actor->_f_Z() > target->_f_Z()+(target->GetDefault()->height) + || actor->_f_Top() < target->_f_Z()) { - newZ = target->Z()+((pr_kspiritseek()*target->GetDefault()->height)>>8); - deltaZ = newZ-actor->Z(); + newZ = target->_f_Z()+((pr_kspiritseek()*target->GetDefault()->height)>>8); + deltaZ = newZ-actor->_f_Z(); if (abs(deltaZ) > 15*FRACUNIT) { if(deltaZ > 0) @@ -404,12 +404,12 @@ static void A_KSpiritSeeker (AActor *actor, DAngle thresh, DAngle turnMax) deltaZ = -15*FRACUNIT; } } - dist = actor->AproxDistance (target) / actor->Speed; + dist = actor->AproxDistance (target) / actor->_f_speed(); if (dist < 1) { dist = 1; } - actor->vel.z = deltaZ/dist; + actor->Vel.Z = FIXED2DBL(deltaZ/dist); } return; } @@ -476,11 +476,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_KBoltRaise) fixed_t z; // Spawn a child upward - z = self->Z() + KORAX_BOLT_HEIGHT; + z = self->_f_Z() + KORAX_BOLT_HEIGHT; if ((z + KORAX_BOLT_HEIGHT) < self->ceilingz) { - mo = Spawn("KoraxBolt", self->X(), self->Y(), z, ALLOW_REPLACE); + mo = Spawn("KoraxBolt", self->_f_X(), self->_f_Y(), z, ALLOW_REPLACE); if (mo) { mo->special1 = KORAX_BOLT_LIFETIME; @@ -516,11 +516,11 @@ AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z, } th->Angles.Yaw = an; th->VelFromAngle(); - dist = dest->AproxDistance (th) / th->Speed; + dist = dest->AproxDistance (th) / th->_f_speed(); if (dist < 1) { dist = 1; } - th->vel.z = (dest->Z()-z+(30*FRACUNIT))/dist; + th->Vel.Z = FIXED2DBL((dest->_f_Z()-z+(30*FRACUNIT))/dist); return (P_CheckMissileSpawn(th, source->radius) ? th : NULL); } diff --git a/src/g_hexen/a_magecone.cpp b/src/g_hexen/a_magecone.cpp index 54e301d40..2346cb26a 100644 --- a/src/g_hexen/a_magecone.cpp +++ b/src/g_hexen/a_magecone.cpp @@ -82,7 +82,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireConePL1) slope = P_AimLineAttack (self, angle, MELEERANGE, &t, 0., ALF_CHECK3D); if (t.linetarget) { - P_DamageMobj (t.linetarget, self, self, damage, NAME_Ice, DMG_USEANGLE, FLOAT2ANGLE(t.angleFromSource.Degrees)); + P_DamageMobj (t.linetarget, self, self, damage, NAME_Ice, DMG_USEANGLE, t.angleFromSource.Degrees); conedone = true; break; } @@ -128,35 +128,35 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) // every so many calls, spawn a new missile in its set directions if (spawndir & SHARDSPAWN_LEFT) { - mo = P_SpawnMissileAngleZSpeed (self, self->Z(), RUNTIME_CLASS(AFrostMissile), self->_f_angle()+(ANG45/9), + mo = P_SpawnMissileAngleZSpeed (self, self->_f_Z(), RUNTIME_CLASS(AFrostMissile), self->_f_angle()+(ANG45/9), 0, (20+2*spermcount)<target); if (mo) { mo->special1 = SHARDSPAWN_LEFT; mo->special2 = spermcount; - mo->vel.z = self->vel.z; + mo->Vel.Z = self->Vel.Z; mo->args[0] = (spermcount==3)?2:0; } } if (spawndir & SHARDSPAWN_RIGHT) { - mo = P_SpawnMissileAngleZSpeed (self, self->Z(), RUNTIME_CLASS(AFrostMissile), self->_f_angle()-(ANG45/9), + mo = P_SpawnMissileAngleZSpeed (self, self->_f_Z(), RUNTIME_CLASS(AFrostMissile), self->_f_angle()-(ANG45/9), 0, (20+2*spermcount)<target); if (mo) { mo->special1 = SHARDSPAWN_RIGHT; mo->special2 = spermcount; - mo->vel.z = self->vel.z; + mo->Vel.Z = self->Vel.Z; mo->args[0] = (spermcount==3)?2:0; } } if (spawndir & SHARDSPAWN_UP) { - mo = P_SpawnMissileAngleZSpeed (self, self->Z()+8*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->_f_angle(), + mo = P_SpawnMissileAngleZSpeed (self, self->_f_Z()+8*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->_f_angle(), 0, (15+2*spermcount)<target); if (mo) { - mo->vel.z = self->vel.z; + mo->Vel.Z = self->Vel.Z; if (spermcount & 1) // Every other reproduction mo->special1 = SHARDSPAWN_UP | SHARDSPAWN_LEFT | SHARDSPAWN_RIGHT; else @@ -167,11 +167,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) } if (spawndir & SHARDSPAWN_DOWN) { - mo = P_SpawnMissileAngleZSpeed (self, self->Z()-4*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->_f_angle(), + mo = P_SpawnMissileAngleZSpeed (self, self->_f_Z()-4*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->_f_angle(), 0, (15+2*spermcount)<target); if (mo) { - mo->vel.z = self->vel.z; + mo->Vel.Z = self->Vel.Z; if (spermcount & 1) // Every other reproduction mo->special1 = SHARDSPAWN_DOWN | SHARDSPAWN_LEFT | SHARDSPAWN_RIGHT; else diff --git a/src/g_hexen/a_magelightning.cpp b/src/g_hexen/a_magelightning.cpp index 1fa343d2d..f2050d20e 100644 --- a/src/g_hexen/a_magelightning.cpp +++ b/src/g_hexen/a_magelightning.cpp @@ -42,8 +42,8 @@ int ALightning::SpecialMissileHit (AActor *thing) { if (thing->Mass != INT_MAX) { - thing->vel.x += vel.x>>4; - thing->vel.y += vel.y>>4; + thing->Vel.X += Vel.X / 16; + thing->Vel.Y += Vel.Y / 16; } if ((!thing->player && !(thing->flags2&MF2_BOSS)) || !(level.time&1)) @@ -156,12 +156,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) { return 0; } - self->SetZ(self->floorz); + self->_f_SetZ(self->floorz); target = self->lastenemy->tracer; } else if (self->flags3 & MF3_CEILINGHUGGER) { - self->SetZ(self->ceilingz-self->height); + self->_f_SetZ(self->ceilingz-self->height); target = self->tracer; } if (self->flags3 & MF3_FLOORHUGGER) @@ -196,9 +196,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) else { self->Angles.Yaw = self->AngleTo(target); - self->vel.x = 0; - self->vel.y = 0; - P_ThrustMobj (self, self->Angles.Yaw, self->Speed>>1); + self->Vel.X = self->Vel.Y = 0; + P_ThrustMobj (self, self->Angles.Yaw, self->_f_speed()>>1); } } return 0; @@ -247,16 +246,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningZap) if (mo) { mo->lastenemy = self; - mo->vel.x = self->vel.x; - mo->vel.y = self->vel.y; + mo->Vel.X = self->Vel.X; + mo->Vel.Y = self->Vel.Y; mo->target = self->target; if (self->flags3 & MF3_FLOORHUGGER) { - mo->vel.z = 20*FRACUNIT; + mo->Vel.Z = 20; } else { - mo->vel.z = -20*FRACUNIT; + mo->Vel.Z = -20; } } if ((self->flags3 & MF3_FLOORHUGGER) && pr_zapf() < 160) @@ -328,8 +327,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_ZapMimic) } else { - self->vel.x = mo->vel.x; - self->vel.y = mo->vel.y; + self->Vel.X = mo->Vel.X; + self->Vel.Y = mo->Vel.Y; } } return 0; @@ -356,7 +355,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LastZap) if (mo) { mo->SetState (mo->FindState (NAME_Death)); - mo->vel.z = 40*FRACUNIT; + mo->Vel.Z = 40; mo->Damage = NULL; } return 0; diff --git a/src/g_hexen/a_magestaff.cpp b/src/g_hexen/a_magestaff.cpp index efddccae9..dff795dcd 100644 --- a/src/g_hexen/a_magestaff.cpp +++ b/src/g_hexen/a_magestaff.cpp @@ -144,8 +144,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffAttack) P_AimLineAttack (self, angle, PLAYERMISSILERANGE, &t, 32.); if (t.linetarget == NULL) { - BlockCheckLine.x = self->X(); - BlockCheckLine.y = self->Y(); + BlockCheckLine.x = self->_f_X(); + BlockCheckLine.y = self->_f_Y(); BlockCheckLine.dx = FLOAT2FIXED(-angle.Sin()); BlockCheckLine.dy = FLOAT2FIXED(-angle.Cos()); t.linetarget = P_BlockmapSearch (self, 10, FrontBlockCheck); @@ -213,7 +213,7 @@ static AActor *FrontBlockCheck (AActor *mo, int index, void *) { if (link->Me != mo) { - if (P_PointOnDivlineSide (link->Me->X(), link->Me->Y(), &BlockCheckLine) == 0 && + if (P_PointOnDivlineSide (link->Me->_f_X(), link->Me->_f_Y(), &BlockCheckLine) == 0 && mo->IsOkayToAttack (link->Me)) { return link->Me; @@ -233,7 +233,7 @@ void MStaffSpawn2 (AActor *actor, angle_t angle) { AActor *mo; - mo = P_SpawnMissileAngleZ (actor, actor->Z()+40*FRACUNIT, + mo = P_SpawnMissileAngleZ (actor, actor->_f_Z()+40*FRACUNIT, RUNTIME_CLASS(AMageStaffFX2), angle, 0); if (mo) { diff --git a/src/g_hexen/a_pig.cpp b/src/g_hexen/a_pig.cpp index 44d64377b..ffd4d7e29 100644 --- a/src/g_hexen/a_pig.cpp +++ b/src/g_hexen/a_pig.cpp @@ -35,7 +35,7 @@ void APigPlayer::MorphPlayerThink () { return; } - if(!(vel.x | vel.y) && pr_pigplayerthink() < 64) + if(Vel.X == 0 && Vel.Y == 0 && pr_pigplayerthink() < 64) { // Snout sniff if (player->ReadyWeapon != NULL) { @@ -99,9 +99,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_PigPain) PARAM_ACTION_PROLOGUE; CALL_ACTION(A_Pain, self); - if (self->Z() <= self->floorz) + if (self->_f_Z() <= self->floorz) { - self->vel.z = FRACUNIT*7/2; + self->Vel.Z = 3.5; } return 0; } diff --git a/src/g_hexen/a_serpent.cpp b/src/g_hexen/a_serpent.cpp index 07863edd7..70acee4ce 100644 --- a/src/g_hexen/a_serpent.cpp +++ b/src/g_hexen/a_serpent.cpp @@ -236,8 +236,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentSpawnGibs) self->floorz+FRACUNIT, ALLOW_REPLACE); if (mo) { - mo->vel.x = (pr_serpentgibs()-128)<<6; - mo->vel.y = (pr_serpentgibs()-128)<<6; + mo->Vel.X = (pr_serpentgibs() - 128) / 1024.f; + mo->Vel.Y = (pr_serpentgibs() - 128) / 1024.f; mo->floorclip = 6*FRACUNIT; } } @@ -296,7 +296,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentHeadCheck) { PARAM_ACTION_PROLOGUE; - if (self->Z() <= self->floorz) + if (self->_f_Z() <= self->floorz) { if (Terrains[P_GetThingFloorType(self)].IsLiquid) { diff --git a/src/g_hexen/a_spike.cpp b/src/g_hexen/a_spike.cpp index 3943bee30..81612d4ca 100644 --- a/src/g_hexen/a_spike.cpp +++ b/src/g_hexen/a_spike.cpp @@ -161,7 +161,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustImpale) while (it.Next(&cres)) { fixed_t blockdist = self->radius + cres.thing->radius; - if (abs(cres.thing->X() - cres.position.x) >= blockdist || abs(cres.thing->Y() - cres.position.y) >= blockdist) + if (abs(cres.thing->_f_X() - cres.position.x) >= blockdist || abs(cres.thing->_f_Y() - cres.position.y) >= blockdist) continue; // Q: Make this z-aware for everything? It never was before. diff --git a/src/g_hexen/a_summon.cpp b/src/g_hexen/a_summon.cpp index d50682dc9..61df3fb2d 100644 --- a/src/g_hexen/a_summon.cpp +++ b/src/g_hexen/a_summon.cpp @@ -36,7 +36,7 @@ bool AArtiDarkServant::Use (bool pickup) { mo->target = Owner; mo->tracer = Owner; - mo->vel.z = 5*FRACUNIT; + mo->Vel.Z = 5; } return true; } @@ -59,7 +59,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Summon) if (P_TestMobjLocation(mo) == false || !self->tracer) { // Didn't fit - change back to artifact mo->Destroy (); - AActor *arti = Spawn (self->Pos(), ALLOW_REPLACE); + AActor *arti = Spawn (self->_f_Pos(), ALLOW_REPLACE); if (arti) arti->flags |= MF_DROPPED; return 0; } diff --git a/src/g_hexen/a_teleportother.cpp b/src/g_hexen/a_teleportother.cpp index 3b276a092..8903d47e0 100644 --- a/src/g_hexen/a_teleportother.cpp +++ b/src/g_hexen/a_teleportother.cpp @@ -57,9 +57,7 @@ static void TeloSpawn (AActor *source, const char *type) fx->special1 = TELEPORT_LIFE; // Lifetime countdown fx->Angles.Yaw = source->Angles.Yaw; fx->target = source->target; - fx->vel.x = source->vel.x >> 1; - fx->vel.y = source->vel.y >> 1; - fx->vel.z = source->vel.z >> 1; + fx->Vel = source->Vel / 2; } } diff --git a/src/g_hexen/a_wraith.cpp b/src/g_hexen/a_wraith.cpp index 94dd17570..c71c1851d 100644 --- a/src/g_hexen/a_wraith.cpp +++ b/src/g_hexen/a_wraith.cpp @@ -31,12 +31,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithInit) { PARAM_ACTION_PROLOGUE; - self->AddZ(48<_f_AddZ(48<Top() > self->ceilingz) + if (self->_f_Top() > self->ceilingz) { - self->SetZ(self->ceilingz - self->height); + self->_f_SetZ(self->ceilingz - self->height); } self->special1 = 0; // index into floatbob @@ -119,7 +119,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithFX2) PARAM_ACTION_PROLOGUE; AActor *mo; - angle_t angle; + DAngle angle; int i; for (i = 2; i; --i) @@ -127,19 +127,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithFX2) mo = Spawn ("WraithFX2", self->Pos(), ALLOW_REPLACE); if(mo) { - if (pr_wraithfx2 ()<128) + angle = pr_wraithfx2() * (360 / 1024.f); + if (pr_wraithfx2() >= 128) { - angle = self->_f_angle()+(pr_wraithfx2()<<22); + angle = -angle; } - else - { - angle = self->_f_angle()-(pr_wraithfx2()<<22); - } - mo->vel.z = 0; - mo->vel.x = FixedMul((pr_wraithfx2()<<7)+FRACUNIT, - finecosine[angle>>ANGLETOFINESHIFT]); - mo->vel.y = FixedMul((pr_wraithfx2()<<7)+FRACUNIT, - finesine[angle>>ANGLETOFINESHIFT]); + angle += self->Angles.Yaw; + mo->Vel.X = ((pr_wraithfx2() << 7) + 1) * angle.Cos(); + mo->Vel.Y = ((pr_wraithfx2() << 7) + 1) * angle.Sin(); + mo->Vel.Z = 0; mo->target = self; mo->floorclip = 10*FRACUNIT; } @@ -255,7 +251,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithChase) PARAM_ACTION_PROLOGUE; int weaveindex = self->special1; - self->AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 8); + self->_f_AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 8); self->special1 = (weaveindex + 2) & 63; // if (self->floorclip > 0) // { diff --git a/src/g_level.cpp b/src/g_level.cpp index e283d86f8..3316d0fdc 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1228,7 +1228,7 @@ void G_FinishTravel () { Printf(TEXTCOLOR_RED "No player %d start to travel to!\n", pnum + 1); // Move to the coordinates this player had when they left the level. - pawn->SetXYZ(pawndup->X(), pawndup->Y(), pawndup->Z()); + pawn->SetXYZ(pawndup->_f_X(), pawndup->_f_Y(), pawndup->_f_Z()); } } oldpawn = pawndup; @@ -1242,10 +1242,8 @@ void G_FinishTravel () { pawn->Angles = pawndup->Angles; } - pawn->SetXYZ(pawndup->X(), pawndup->Y(), pawndup->Z()); - pawn->vel.x = pawndup->vel.x; - pawn->vel.y = pawndup->vel.y; - pawn->vel.z = pawndup->vel.z; + pawn->SetXYZ(pawndup->_f_X(), pawndup->_f_Y(), pawndup->_f_Z()); + pawn->Vel = pawndup->Vel; pawn->Sector = pawndup->Sector; pawn->floorz = pawndup->floorz; pawn->ceilingz = pawndup->ceilingz; @@ -1315,7 +1313,7 @@ void G_InitLevelLocals () NormalLight.ChangeColor (PalEntry (255, 255, 255), 0); level.gravity = sv_gravity * 35/TICRATE; - level.aircontrol = (fixed_t)(sv_aircontrol * 65536.f); + level.aircontrol = sv_aircontrol; level.teamdamage = teamdamage; level.flags = 0; level.flags2 = 0; @@ -1356,7 +1354,7 @@ void G_InitLevelLocals () } if (info->aircontrol != 0.f) { - level.aircontrol = (fixed_t)(info->aircontrol * 65536.f); + level.aircontrol = info->aircontrol; } if (info->teamdamage != 0.f) { @@ -1461,15 +1459,14 @@ FString CalcMapName (int episode, int level) void G_AirControlChanged () { - if (level.aircontrol <= 256) + if (level.aircontrol <= 1/256.) { - level.airfriction = FRACUNIT; + level.airfriction = 1.; } else { // Friction is inversely proportional to the amount of control - float fric = ((float)level.aircontrol/65536.f) * -0.0941f + 1.0004f; - level.airfriction = (fixed_t)(fric * 65536.f); + level.airfriction = level.aircontrol * -0.0941 + 1.0004; } } diff --git a/src/g_level.h b/src/g_level.h index ca70b654b..8de66974c 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -304,8 +304,8 @@ struct level_info_t DWORD outsidefog; int cdtrack; unsigned int cdid; - float gravity; - float aircontrol; + double gravity; + double aircontrol; int WarpTrans; int airsupply; DWORD compatflags, compatflags2; @@ -429,9 +429,9 @@ struct FLevelLocals int total_monsters; int killed_monsters; - float gravity; - fixed_t aircontrol; - fixed_t airfriction; + double gravity; + double aircontrol; + double airfriction; int airsupply; int DefaultEnvironment; // Default sound environment. diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index fb1ae933f..4d5bfeb99 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -989,14 +989,14 @@ DEFINE_MAP_OPTION(gravity, true) { parse.ParseAssign(); parse.sc.MustGetFloat(); - info->gravity = float(parse.sc.Float); + info->gravity = parse.sc.Float; } DEFINE_MAP_OPTION(aircontrol, true) { parse.ParseAssign(); parse.sc.MustGetFloat(); - info->aircontrol = float(parse.sc.Float); + info->aircontrol = parse.sc.Float; } DEFINE_MAP_OPTION(airsupply, true) diff --git a/src/g_raven/a_minotaur.cpp b/src/g_raven/a_minotaur.cpp index 9dea5856a..31019f918 100644 --- a/src/g_raven/a_minotaur.cpp +++ b/src/g_raven/a_minotaur.cpp @@ -175,14 +175,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk1) // //---------------------------------------------------------------------------- -#define MNTR_CHARGE_SPEED (13*FRACUNIT) +#define MNTR_CHARGE_SPEED (13.) DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide) { PARAM_ACTION_PROLOGUE; bool friendly = !!(self->flags5 & MF5_SUMMONEDMONSTER); - angle_t angle; AActor *target; int dist; @@ -210,12 +209,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide) self->flags2 |= MF2_INVULNERABLE; } A_FaceTarget (self); - angle = self->_f_angle()>>ANGLETOFINESHIFT; - self->vel.x = FixedMul (MNTR_CHARGE_SPEED, finecosine[angle]); - self->vel.y = FixedMul (MNTR_CHARGE_SPEED, finesine[angle]); + self->VelFromAngle(MNTR_CHARGE_SPEED); self->special1 = TICRATE/2; // Charge duration } - else if (target->Z() == target->floorz + else if (target->_f_Z() == target->floorz && dist < 9*64*FRACUNIT && pr_minotaurdecide() < (friendly ? 100 : 220)) { // Floor fire attack @@ -260,7 +257,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurCharge) type = PClass::FindActor("PunchPuff"); } puff = Spawn (type, self->Pos(), ALLOW_REPLACE); - puff->vel.z = 2*FRACUNIT; + puff->Vel.Z = 2; self->special1--; } else @@ -303,7 +300,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk2) P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self); return 0; } - z = self->Z() + 40*FRACUNIT; + z = self->_f_Z() + 40*FRACUNIT; PClassActor *fx = PClass::FindActor("MinotaurFX1"); if (fx) { @@ -311,7 +308,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk2) if (mo != NULL) { // S_Sound (mo, CHAN_WEAPON, "minotaur/attack2", 1, ATTN_NORM); - vz = mo->vel.z; + vz = mo->_f_velz(); angle = mo->_f_angle(); P_SpawnMissileAngleZ (self, z, fx, angle-(ANG45/8), vz); P_SpawnMissileAngleZ (self, z, fx, angle+(ANG45/8), vz); @@ -392,13 +389,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_MntrFloorFire) AActor *mo; - self->SetZ(self->floorz); + self->_f_SetZ(self->floorz); fixedvec2 pos = self->Vec2Offset( (pr_fire.Random2 () << 10), (pr_fire.Random2 () << 10)); mo = Spawn("MinotaurFX3", pos.x, pos.y, self->floorz, ALLOW_REPLACE); mo->target = self->target; - mo->vel.x = 1; // Force block checking + mo->Vel.X = MinVel; // Force block checking P_CheckMissileSpawn (mo, self->radius); return 0; } @@ -411,18 +408,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_MntrFloorFire) void P_MinotaurSlam (AActor *source, AActor *target) { - angle_t angle; - fixed_t thrust; + DAngle angle; + double thrust; int damage; - angle = source->__f_AngleTo(target); - angle >>= ANGLETOFINESHIFT; - thrust = 16*FRACUNIT+(pr_minotaurslam()<<10); - target->vel.x += FixedMul (thrust, finecosine[angle]); - target->vel.y += FixedMul (thrust, finesine[angle]); + angle = source->AngleTo(target); + thrust = 16 + pr_minotaurslam() / 64.; + target->VelFromAngle(angle, thrust); damage = pr_minotaurslam.HitDice (static_cast(source) ? 4 : 6); int newdam = P_DamageMobj (target, NULL, NULL, damage, NAME_Melee); - P_TraceBleed (newdam > 0 ? newdam : damage, target, angle, 0); + P_TraceBleed (newdam > 0 ? newdam : damage, target, angle, 0.); if (target->player) { target->reactiontime = 14+(pr_minotaurslam()&7); diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index e9c9a36ba..a94715142 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -274,12 +274,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) int numChunks; AActor *mo; - if ((self->vel.x || self->vel.y || self->vel.z) && !(self->flags6 & MF6_SHATTERING)) + if (!self->Vel.isZero() && !(self->flags6 & MF6_SHATTERING)) { self->tics = 3*TICRATE; return 0; } - self->vel.x = self->vel.y = self->vel.z = 0; + self->Vel.Zero(); S_Sound (self, CHAN_BODY, "misc/icebreak", 1, ATTN_NORM); // [RH] In Hexen, this creates a random number of shards (range [24,56]) @@ -297,10 +297,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) mo = Spawn("IceChunk", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { - mo->SetState (mo->SpawnState + (pr_freeze()%3)); - mo->vel.z = FixedDiv(mo->Z() - self->Z(), self->height)<<2; - mo->vel.x = pr_freeze.Random2 () << (FRACBITS-7); - mo->vel.y = pr_freeze.Random2 () << (FRACBITS-7); + mo->SetState (mo->SpawnState + (pr_freeze()%3)); + mo->Vel.X = pr_freeze.Random2() / 128.; + mo->Vel.Y = pr_freeze.Random2() / 128.; + mo->Vel.Z = (mo->Z() - self->Z()) / self->_Height() * 4; CALL_ACTION(A_IceSetTics, mo); // set a random tic wait mo->RenderStyle = self->RenderStyle; mo->alpha = self->alpha; @@ -311,9 +311,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) AActor *head = Spawn("IceChunkHead", self->PosPlusZ(self->player->mo->ViewHeight), ALLOW_REPLACE); if (head != NULL) { - head->vel.z = FixedDiv(head->Z() - self->Z(), self->height)<<2; - head->vel.x = pr_freeze.Random2 () << (FRACBITS-7); - head->vel.y = pr_freeze.Random2 () << (FRACBITS-7); + head->Vel.X = pr_freeze.Random2() / 128.; + head->Vel.Y = pr_freeze.Random2() / 128.; + head->Vel.Z = (mo->Z() - self->Z()) / self->_Height() * 4; + head->health = self->health; head->Angles.Yaw = self->Angles.Yaw; if (head->IsKindOf(RUNTIME_CLASS(APlayerPawn))) diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 6397b9f72..28b4082d3 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -979,11 +979,11 @@ void APowerFlight::InitEffect () Super::InitEffect(); Owner->flags2 |= MF2_FLY; Owner->flags |= MF_NOGRAVITY; - if (Owner->Z() <= Owner->floorz) + if (Owner->_f_Z() <= Owner->floorz) { - Owner->vel.z = 4*FRACUNIT; // thrust the player in the air a bit + Owner->Vel.Z = 4;; // thrust the player in the air a bit } - if (Owner->vel.z <= -35*FRACUNIT) + if (Owner->Vel.Z <= -35) { // stop falling scream S_StopSound (Owner, CHAN_VOICE); } @@ -1026,7 +1026,7 @@ void APowerFlight::EndEffect () if (!(Owner->flags7 & MF7_FLYCHEAT)) { - if (Owner->Z() != Owner->floorz) + if (Owner->_f_Z() != Owner->floorz) { Owner->player->centering = true; } @@ -1220,10 +1220,10 @@ void APowerSpeed::Serialize(FArchive &arc) // //=========================================================================== -fixed_t APowerSpeed ::GetSpeedFactor () +double APowerSpeed ::GetSpeedFactor () { if (Inventory != NULL) - return FixedMul(Speed, Inventory->GetSpeedFactor()); + return Speed * Inventory->GetSpeedFactor(); else return Speed; } @@ -1261,10 +1261,10 @@ void APowerSpeed::DoEffect () } } - if (P_AproxDistance (Owner->vel.x, Owner->vel.y) <= 12*FRACUNIT) + if (P_AproxDistance (Owner->_f_velx(), Owner->_f_vely()) <= 12*FRACUNIT) return; - AActor *speedMo = Spawn (Owner->Pos(), NO_REPLACE); + AActor *speedMo = Spawn (Owner->_f_Pos(), NO_REPLACE); if (speedMo) { speedMo->Angles.Yaw = Owner->Angles.Yaw; diff --git a/src/g_shared/a_artifacts.h b/src/g_shared/a_artifacts.h index a355cb924..23ff347d3 100644 --- a/src/g_shared/a_artifacts.h +++ b/src/g_shared/a_artifacts.h @@ -158,7 +158,7 @@ class APowerSpeed : public APowerup protected: void DoEffect (); void Serialize(FArchive &arc); - fixed_t GetSpeedFactor(); + double GetSpeedFactor(); public: int SpeedFlags; }; diff --git a/src/g_shared/a_bridge.cpp b/src/g_shared/a_bridge.cpp index 5f9409f90..f1b479140 100644 --- a/src/g_shared/a_bridge.cpp +++ b/src/g_shared/a_bridge.cpp @@ -112,7 +112,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit) if (self->target->args[4]) rotationradius = ((self->target->args[4] * self->target->radius) / 100); self->Angles.Yaw += rotationspeed; - self->SetOrigin(self->target->Vec3Angle(rotationradius*FRACUNIT, self->_f_angle(), 0), true); + self->SetOrigin(self->target->Vec3Angle(rotationradius*FRACUNIT, self->Angles.Yaw, 0), true); self->floorz = self->target->floorz; self->ceilingz = self->target->ceilingz; return 0; diff --git a/src/g_shared/a_camera.cpp b/src/g_shared/a_camera.cpp index bb23d4f4f..0808d0b9a 100644 --- a/src/g_shared/a_camera.cpp +++ b/src/g_shared/a_camera.cpp @@ -173,9 +173,9 @@ void AAimingCamera::Tick () } if (MaxPitchChange != 0) { // Aim camera's pitch; use floats for precision - fixedvec2 fv3 = tracer->Vec2To(this); + fixedvec2 fv3 = tracer->_f_Vec2To(this); DVector2 vect(fv3.x, fv3.y); - double dz = Z() - tracer->Z() - tracer->height/2; + double dz = _f_Z() - tracer->_f_Z() - tracer->height/2; double dist = vect.Length(); DAngle desiredPitch = dist != 0.f ? VecToAngle(dist, dz) : 0.; DAngle diff = deltaangle(Angles.Pitch, desiredPitch); diff --git a/src/g_shared/a_debris.cpp b/src/g_shared/a_debris.cpp index b5785eb9e..0aea2258d 100644 --- a/src/g_shared/a_debris.cpp +++ b/src/g_shared/a_debris.cpp @@ -15,7 +15,7 @@ public: { if (!Super::FloorBounceMissile (plane)) { - if (abs (vel.z) < (FRACUNIT/2)) + if (fabs (Vel.Z) < 0.5) { Destroy (); } @@ -35,7 +35,7 @@ void P_SpawnDirt (AActor *actor, fixed_t radius) AActor *mo; fixed_t zo = (pr_dirt() << 9) + FRACUNIT; - fixedvec3 pos = actor->Vec3Angle(radius, pr_dirt() << 24, zo); + fixedvec3 pos = actor->_f_Vec3Angle(radius, pr_dirt() << 24, zo); char fmt[8]; mysnprintf(fmt, countof(fmt), "Dirt%d", 1 + pr_dirt()%6); @@ -45,7 +45,7 @@ void P_SpawnDirt (AActor *actor, fixed_t radius) mo = Spawn (dtype, pos, ALLOW_REPLACE); if (mo) { - mo->vel.z = pr_dirt()<<10; + mo->Vel.Z = pr_dirt() / 64.; } } } diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index c823e33d7..24056b36e 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -92,7 +92,7 @@ DBaseDecal::DBaseDecal (int statnum, fixed_t z) DBaseDecal::DBaseDecal (const AActor *basis) : DThinker(STAT_DECAL), - WallNext(0), WallPrev(0), LeftDistance(0), Z(basis->Z()), ScaleX(basis->scaleX), ScaleY(basis->scaleY), + WallNext(0), WallPrev(0), LeftDistance(0), Z(basis->_f_Z()), ScaleX(basis->scaleX), ScaleY(basis->scaleY), Alpha(basis->alpha), AlphaColor(basis->fillcolor), Translation(basis->Translation), PicNum(basis->picnum), RenderFlags(basis->renderflags), RenderStyle(basis->RenderStyle) { @@ -820,22 +820,22 @@ void ADecal::BeginPlay () { if (!tpl->PicNum.Exists()) { - Printf("Decal actor at (%d,%d) does not have a valid texture\n", X()>>FRACBITS, Y()>>FRACBITS); + Printf("Decal actor at (%f,%f) does not have a valid texture\n", X(), Y()); } else { // Look for a wall within 64 units behind the actor. If none can be // found, then no decal is created, and this actor is destroyed // without effectively doing anything. - if (NULL == ShootDecal(tpl, this, Sector, X(), Y(), Z(), FLOAT2ANGLE(Angles.Yaw.Degrees) + ANGLE_180, 64*FRACUNIT, true)) + if (NULL == ShootDecal(tpl, this, Sector, _f_X(), _f_Y(), _f_Z(), FLOAT2ANGLE(Angles.Yaw.Degrees) + ANGLE_180, 64*FRACUNIT, true)) { - DPrintf ("Could not find a wall to stick decal to at (%d,%d)\n", X()>>FRACBITS, Y()>>FRACBITS); + DPrintf ("Could not find a wall to stick decal to at (%f,%f)\n", X(), Y()); } } } else { - DPrintf ("Decal actor at (%d,%d) does not have a good template\n", X()>>FRACBITS, Y()>>FRACBITS); + DPrintf ("Decal actor at (%f,%f) does not have a good template\n", X(), Y()); } // This actor doesn't need to stick around anymore. Destroy(); diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index 16d7601c9..ba11ac59e 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -28,7 +28,7 @@ void AFastProjectile::Tick () int changexy; ClearInterpolation(); - fixed_t oldz = Z(); + fixed_t oldz = _f_Z(); if (!(flags5 & MF5_NOTIMEFREEZE)) { @@ -47,7 +47,7 @@ void AFastProjectile::Tick () int count = 8; if (radius > 0) { - while ( ((abs(vel.x) >> shift) > radius) || ((abs(vel.y) >> shift) > radius)) + while ( ((abs(_f_velx()) >> shift) > radius) || ((abs(_f_vely()) >> shift) > radius)) { // we need to take smaller steps. shift++; @@ -56,11 +56,11 @@ void AFastProjectile::Tick () } // Handle movement - if (vel.x || vel.y || (Z() != floorz) || vel.z) + if (Vel.X != 0 || Vel.Y != 0 || (_f_Z() != floorz) || _f_velz()) { - xfrac = vel.x >> shift; - yfrac = vel.y >> shift; - zfrac = vel.z >> shift; + xfrac = _f_velx() >> shift; + yfrac = _f_vely() >> shift; + zfrac = _f_velz() >> shift; changexy = xfrac || yfrac; int ripcount = count >> 3; for (i = 0; i < count; i++) @@ -72,14 +72,14 @@ void AFastProjectile::Tick () tm.LastRipped.Clear(); // [RH] Do rip damage each step, like Hexen } - if (!P_TryMove (this, X() + xfrac,Y() + yfrac, true, NULL, tm)) + if (!P_TryMove (this, _f_X() + xfrac,_f_Y() + yfrac, true, NULL, tm)) { // Blocked move if (!(flags3 & MF3_SKYEXPLODE)) { if (tm.ceilingline && tm.ceilingline->backsector && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(PosRelative(tm.ceilingline))) + _f_Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(PosRelative(tm.ceilingline))) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. @@ -98,10 +98,10 @@ void AFastProjectile::Tick () return; } } - AddZ(zfrac); + _f_AddZ(zfrac); UpdateWaterLevel (oldz); - oldz = Z(); - if (Z() <= floorz) + oldz = _f_Z(); + if (_f_Z() <= floorz) { // Hit the floor if (floorpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE)) @@ -112,12 +112,12 @@ void AFastProjectile::Tick () return; } - SetZ(floorz); + _f_SetZ(floorz); P_HitFloor (this); P_ExplodeMissile (this, NULL, NULL); return; } - if (Top() > ceilingz) + if (_f_Top() > ceilingz) { // Hit the ceiling if (ceilingpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE)) @@ -126,7 +126,7 @@ void AFastProjectile::Tick () return; } - SetZ(ceilingz - height); + _f_SetZ(ceilingz - height); P_ExplodeMissile (this, NULL, NULL); return; } @@ -161,7 +161,7 @@ void AFastProjectile::Effect() FName name = GetClass()->MissileName; if (name != NAME_None) { - fixed_t hitz = Z()-8*FRACUNIT; + fixed_t hitz = _f_Z()-8*FRACUNIT; if (hitz < floorz) { @@ -173,7 +173,7 @@ void AFastProjectile::Effect() PClassActor *trail = PClass::FindActor(name); if (trail != NULL) { - AActor *act = Spawn (trail, X(), Y(), hitz, ALLOW_REPLACE); + AActor *act = Spawn (trail, _f_X(), _f_Y(), hitz, ALLOW_REPLACE); if (act != NULL) { act->Angles.Yaw = Angles.Yaw; diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index a72615d45..33d25e638 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -120,7 +120,7 @@ bool P_MorphPlayer (player_t *activator, player_t *p, PClassPlayerPawn *spawntyp p->MorphExitFlash = (exit_flash) ? exit_flash : RUNTIME_CLASS(ATeleportFog); p->health = morphed->health; p->mo = morphed; - p->vel.x = p->vel.y = 0; + p->Vel.X = p->Vel.Y = 0; morphed->ObtainInventory (actor); // Remove all armor for (item = morphed->Inventory; item != NULL; ) @@ -227,11 +227,9 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag, mo->player = player; mo->reactiontime = 18; mo->flags = ActorFlags::FromInt (pmo->special2) & ~MF_JUSTHIT; - mo->vel.x = 0; - mo->vel.y = 0; - player->vel.x = 0; - player->vel.y = 0; - mo->vel.z = pmo->vel.z; + mo->Vel.X = mo->Vel.Y = 0; + player->Vel.Zero(); + mo->Vel.Z = pmo->Vel.Z; if (!(pmo->special2 & MF_JUSTHIT)) { mo->renderflags &= ~RF_INVISIBLE; @@ -461,9 +459,7 @@ bool P_UndoMonsterMorph (AMorphedMonster *beast, bool force) if (!(beast->FlagsSave & MF_JUSTHIT)) actor->renderflags &= ~RF_INVISIBLE; actor->health = actor->SpawnHealth(); - actor->vel.x = beast->vel.x; - actor->vel.y = beast->vel.y; - actor->vel.z = beast->vel.z; + actor->Vel = beast->Vel; actor->tid = beast->tid; actor->special = beast->special; actor->Score = beast->Score; diff --git a/src/g_shared/a_movingcamera.cpp b/src/g_shared/a_movingcamera.cpp index dff298035..d7284fec5 100644 --- a/src/g_shared/a_movingcamera.cpp +++ b/src/g_shared/a_movingcamera.cpp @@ -298,7 +298,7 @@ void APathFollower::Tick () if (CurrNode->args[2]) { HoldTime = level.time + CurrNode->args[2] * TICRATE / 8; - SetXYZ(CurrNode->X(), CurrNode->Y(), CurrNode->Z()); + SetXYZ(CurrNode->_f_X(), CurrNode->_f_Y(), CurrNode->_f_Z()); } } @@ -356,9 +356,9 @@ bool APathFollower::Interpolate () if ((args[2] & 8) && Time > 0.f) { - dx = X(); - dy = Y(); - dz = Z(); + dx = _f_X(); + dy = _f_Y(); + dz = _f_Z(); } if (CurrNode->Next==NULL) return false; @@ -367,20 +367,20 @@ bool APathFollower::Interpolate () fixed_t x, y, z; if (args[2] & 1) { // linear - x = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->X()), FIXED2DBL(CurrNode->Next->X()))); - y = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->Y()), FIXED2DBL(CurrNode->Next->Y()))); - z = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->Z()), FIXED2DBL(CurrNode->Next->Z()))); + x = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->_f_X()), FIXED2DBL(CurrNode->Next->_f_X()))); + y = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->_f_Y()), FIXED2DBL(CurrNode->Next->_f_Y()))); + z = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->_f_Z()), FIXED2DBL(CurrNode->Next->_f_Z()))); } else { // spline if (CurrNode->Next->Next==NULL) return false; - x = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->X()), FIXED2DBL(CurrNode->X()), - FIXED2DBL(CurrNode->Next->X()), FIXED2DBL(CurrNode->Next->Next->X()))); - y = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->Y()), FIXED2DBL(CurrNode->Y()), - FIXED2DBL(CurrNode->Next->Y()), FIXED2DBL(CurrNode->Next->Next->Y()))); - z = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->Z()), FIXED2DBL(CurrNode->Z()), - FIXED2DBL(CurrNode->Next->Z()), FIXED2DBL(CurrNode->Next->Next->Z()))); + x = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->_f_X()), FIXED2DBL(CurrNode->_f_X()), + FIXED2DBL(CurrNode->Next->_f_X()), FIXED2DBL(CurrNode->Next->Next->_f_X()))); + y = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->_f_Y()), FIXED2DBL(CurrNode->_f_Y()), + FIXED2DBL(CurrNode->Next->_f_Y()), FIXED2DBL(CurrNode->Next->Next->_f_Y()))); + z = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->_f_Z()), FIXED2DBL(CurrNode->_f_Z()), + FIXED2DBL(CurrNode->Next->_f_Z()), FIXED2DBL(CurrNode->Next->Next->_f_Z()))); } SetXYZ(x, y, z); LinkToWorld (); @@ -391,9 +391,9 @@ bool APathFollower::Interpolate () { if (args[2] & 1) { // linear - dx = CurrNode->Next->X() - CurrNode->X(); - dy = CurrNode->Next->Y() - CurrNode->Y(); - dz = CurrNode->Next->Z() - CurrNode->Z(); + dx = CurrNode->Next->_f_X() - CurrNode->_f_X(); + dy = CurrNode->Next->_f_Y() - CurrNode->_f_Y(); + dz = CurrNode->Next->_f_Z() - CurrNode->_f_Z(); } else if (Time > 0.f) { // spline @@ -517,11 +517,11 @@ bool AActorMover::Interpolate () if (Super::Interpolate ()) { - fixed_t savedz = tracer->Z(); - tracer->SetZ(Z()); - if (!P_TryMove (tracer, X(), Y(), true)) + fixed_t savedz = tracer->_f_Z(); + tracer->_f_SetZ(_f_Z()); + if (!P_TryMove (tracer, _f_X(), _f_Y(), true)) { - tracer->SetZ(savedz); + tracer->_f_SetZ(savedz); return false; } @@ -637,9 +637,9 @@ bool AMovingCamera::Interpolate () if (args[2] & 4) { // Also aim camera's pitch; use floats for precision - double dx = FIXED2DBL(X() - tracer->X()); - double dy = FIXED2DBL(Y() - tracer->Y()); - double dz = FIXED2DBL(Z() - tracer->Z() - tracer->height/2); + double dx = FIXED2DBL(_f_X() - tracer->_f_X()); + double dy = FIXED2DBL(_f_Y() - tracer->_f_Y()); + double dz = FIXED2DBL(_f_Z() - tracer->_f_Z() - tracer->height/2); double dist = g_sqrt (dx*dx + dy*dy); Angles.Pitch = dist != 0.f ? VecToAngle(dist, dz) : 0.; } diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index b2a80cbc2..55292868c 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -421,12 +421,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) self->UnlinkFromWorld(); self->SetXY(_x, _y); self->LinkToWorld(true); - self->SetZ(self->Sector->floorplane.ZatPoint(_x, _y)); + self->_f_SetZ(self->Sector->floorplane.ZatPoint(_x, _y)); P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS | FFCF_NOPORTALS); // no portal checks here so that things get spawned in this sector. if (self->flags & MF_SPAWNCEILING) { - self->SetZ(self->ceilingz - self->height - self->SpawnPoint[2]); + self->_f_SetZ(self->ceilingz - self->height - self->SpawnPoint[2]); } else if (self->flags2 & MF2_SPAWNFLOAT) { @@ -434,27 +434,27 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) if (space > 48*FRACUNIT) { space -= 40*FRACUNIT; - self->SetZ(((space * pr_restore())>>8) + self->floorz + 40*FRACUNIT); + self->_f_SetZ(((space * pr_restore())>>8) + self->floorz + 40*FRACUNIT); } else { - self->SetZ(self->floorz); + self->_f_SetZ(self->floorz); } } else { - self->SetZ(self->SpawnPoint[2] + self->floorz); + self->_f_SetZ(self->SpawnPoint[2] + self->floorz); } // Redo floor/ceiling check, in case of 3D floors and portals P_FindFloorCeiling(self, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); - if (self->Z() < self->floorz) + if (self->_f_Z() < self->floorz) { // Do not reappear under the floor, even if that's where we were for the // initial spawn. - self->SetZ(self->floorz); + self->_f_SetZ(self->floorz); } - if ((self->flags & MF_SOLID) && (self->Top() > self->ceilingz)) + if ((self->flags & MF_SOLID) && (self->_f_Top() > self->ceilingz)) { // Do the same for the ceiling. - self->SetZ(self->ceilingz - self->height); + self->_f_SetZ(self->ceilingz - self->height); } // Do not interpolate from the position the actor was at when it was // picked up, in case that is different from where it is now. @@ -790,7 +790,7 @@ AInventory *AInventory::CreateTossable () flags &= ~(MF_SPECIAL|MF_SOLID); return this; } - copy = static_cast(Spawn (GetClass(), Owner->Pos(), NO_REPLACE)); + copy = static_cast(Spawn (GetClass(), Owner->_f_Pos(), NO_REPLACE)); if (copy != NULL) { copy->MaxAmount = MaxAmount; @@ -902,7 +902,7 @@ void AInventory::ModifyDamage (int damage, FName damageType, int &newdamage, boo // //=========================================================================== -fixed_t AInventory::GetSpeedFactor () +double AInventory::GetSpeedFactor () { if (Inventory != NULL) { @@ -910,7 +910,7 @@ fixed_t AInventory::GetSpeedFactor () } else { - return FRACUNIT; + return 1.; } } @@ -1354,7 +1354,7 @@ bool AInventory::DoRespawn () if (spot != NULL) { SetOrigin (spot->Pos(), false); - SetZ(floorz); + _f_SetZ(floorz); } } return true; diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 933b235dd..67ec3d8c9 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -207,7 +207,7 @@ public: virtual void AbsorbDamage (int damage, FName damageType, int &newdamage); virtual void ModifyDamage (int damage, FName damageType, int &newdamage, bool passive); - virtual fixed_t GetSpeedFactor(); + virtual double GetSpeedFactor(); virtual bool GetNoTeleportFreeze(); virtual int AlterWeaponSprite (visstyle_t *vis); diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 51c022195..c694bfa6a 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -133,25 +133,22 @@ void DEarthquake::Tick () dist = m_Spot->AproxDistance (victim, true); // Check if in damage radius - if (dist < m_DamageRadius && victim->Z() <= victim->floorz) + if (dist < m_DamageRadius && victim->_f_Z() <= victim->floorz) { if (pr_quake() < 50) { P_DamageMobj (victim, NULL, NULL, pr_quake.HitDice (1), NAME_None); } // Thrust player around - angle_t an = victim->_f_angle() + ANGLE_1*pr_quake(); + DAngle an = victim->Angles.Yaw + pr_quake(); if (m_IntensityX == m_IntensityY) { // Thrust in a circle P_ThrustMobj (victim, an, m_IntensityX << (FRACBITS-1)); } else { // Thrust in an ellipse - an >>= ANGLETOFINESHIFT; - // So this is actually completely wrong, but it ought to be good - // enough. Otherwise, I'd have to use tangents and square roots. - victim->vel.x += FixedMul(m_IntensityX << (FRACBITS-1), finecosine[an]); - victim->vel.y += FixedMul(m_IntensityY << (FRACBITS-1), finesine[an]); + victim->Vel.X += FIXED2DBL(m_IntensityX) * an.Cos() * 0.5; + victim->Vel.Y += FIXED2DBL(m_IntensityY) * an.Sin() * 0.5; } } } diff --git a/src/g_shared/a_randomspawner.cpp b/src/g_shared/a_randomspawner.cpp index 83102aeda..0566cf0f5 100644 --- a/src/g_shared/a_randomspawner.cpp +++ b/src/g_shared/a_randomspawner.cpp @@ -114,7 +114,7 @@ class ARandomSpawner : public AActor { Species = cls->TypeName; AActor *defmobj = GetDefaultByType(cls); - this->Speed = defmobj->Speed; + this->Speed = defmobj->Speed; this->flags |= (defmobj->flags & MF_MISSILE); this->flags2 |= (defmobj->flags2 & MF2_SEEKERMISSILE); this->flags4 |= (defmobj->flags4 & MF4_SPECTRAL); @@ -151,7 +151,7 @@ class ARandomSpawner : public AActor { tracer = target->target; } - newmobj = P_SpawnMissileXYZ(Pos(), target, target->target, cls, false); + newmobj = P_SpawnMissileXYZ(_f_Pos(), target, target->target, cls, false); } else { @@ -176,9 +176,7 @@ class ARandomSpawner : public AActor newmobj->SpawnFlags = SpawnFlags; newmobj->tid = tid; newmobj->AddToHash(); - newmobj->vel.x = vel.x; - newmobj->vel.y = vel.y; - newmobj->vel.z = vel.z; + newmobj->Vel = Vel; newmobj->master = master; // For things such as DamageMaster/DamageChildren, transfer mastery. newmobj->target = target; newmobj->tracer = tracer; @@ -190,7 +188,7 @@ class ARandomSpawner : public AActor // Handle special altitude flags if (newmobj->flags & MF_SPAWNCEILING) { - newmobj->SetZ(newmobj->ceilingz - newmobj->height - SpawnPoint[2]); + newmobj->_f_SetZ(newmobj->ceilingz - newmobj->height - SpawnPoint[2]); } else if (newmobj->flags2 & MF2_SPAWNFLOAT) { @@ -198,9 +196,9 @@ class ARandomSpawner : public AActor if (space > 48*FRACUNIT) { space -= 40*FRACUNIT; - newmobj->SetZ(MulScale8 (space, pr_randomspawn()) + newmobj->floorz + 40*FRACUNIT); + newmobj->_f_SetZ(MulScale8 (space, pr_randomspawn()) + newmobj->floorz + 40*FRACUNIT); } - newmobj->AddZ(SpawnPoint[2]); + newmobj->_f_AddZ(SpawnPoint[2]); } if (newmobj->flags & MF_MISSILE) P_CheckMissileSpawn(newmobj, 0); diff --git a/src/g_shared/a_spark.cpp b/src/g_shared/a_spark.cpp index 17e2ba3bd..557abe5a2 100644 --- a/src/g_shared/a_spark.cpp +++ b/src/g_shared/a_spark.cpp @@ -50,6 +50,6 @@ IMPLEMENT_CLASS (ASpark) void ASpark::Activate (AActor *activator) { Super::Activate (activator); - P_DrawSplash (args[0] ? args[0] : 32, X(), Y(), Z(), FLOAT2ANGLE(Angles.Yaw.Degrees), 1); + P_DrawSplash (args[0] ? args[0] : 32, _f_X(), _f_Y(), _f_Z(), FLOAT2ANGLE(Angles.Yaw.Degrees), 1); S_Sound (this, CHAN_AUTO, "world/spark", 1, ATTN_STATIC); } diff --git a/src/g_shared/a_specialspot.cpp b/src/g_shared/a_specialspot.cpp index 8dfefb311..bdbedae09 100644 --- a/src/g_shared/a_specialspot.cpp +++ b/src/g_shared/a_specialspot.cpp @@ -429,7 +429,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem) if (spawned) { spawned->SetOrigin (spot->Pos(), false); - spawned->SetZ(spawned->floorz); + spawned->_f_SetZ(spawned->floorz); // We want this to respawn. if (!(self->flags & MF_DROPPED)) { diff --git a/src/g_shared/sbar_mugshot.cpp b/src/g_shared/sbar_mugshot.cpp index 347ec3fc4..b26541c99 100644 --- a/src/g_shared/sbar_mugshot.cpp +++ b/src/g_shared/sbar_mugshot.cpp @@ -338,7 +338,6 @@ bool FMugShot::SetState(const char *state_name, bool wait_till_done, bool reset) CVAR(Bool,st_oldouch,false,CVAR_ARCHIVE) int FMugShot::UpdateState(player_t *player, StateFlags stateflags) { - int i; FString full_state_name; if (player->health > 0) diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 821008456..e6f3420b0 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -828,9 +828,9 @@ static void DrawCoordinates(player_t * CPlayer) if (!map_point_coordinates || !automapactive) { - x=CPlayer->mo->X(); - y=CPlayer->mo->Y(); - z=CPlayer->mo->Z(); + x=CPlayer->mo->_f_X(); + y=CPlayer->mo->_f_Y(); + z=CPlayer->mo->_f_Z(); } else { diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index d0153a98f..781ca915e 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -1286,7 +1286,7 @@ void DBaseStatusBar::Draw (EHudState state) y -= height * 2; } - fixedvec3 pos = CPlayer->mo->Pos(); + fixedvec3 pos = CPlayer->mo->_f_Pos(); for (i = 2, value = &pos.z; i >= 0; y -= height, --value, --i) { mysnprintf (line, countof(line), "%c: %d", labels[i], *value >> FRACBITS); diff --git a/src/g_strife/a_alienspectres.cpp b/src/g_strife/a_alienspectres.cpp index e45a442b4..de95de431 100644 --- a/src/g_strife/a_alienspectres.cpp +++ b/src/g_strife/a_alienspectres.cpp @@ -29,12 +29,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkSmall) int t; t = pr_spectrechunk() & 15; - foo->vel.x = (t - (pr_spectrechunk() & 7)) << FRACBITS; + foo->Vel.X = (t - (pr_spectrechunk() & 7)); t = pr_spectrechunk() & 15; - foo->vel.y = (t - (pr_spectrechunk() & 7)) << FRACBITS; + foo->Vel.Y = (t - (pr_spectrechunk() & 7)); - foo->vel.z = (pr_spectrechunk() & 15) << FRACBITS; + foo->Vel.Z = (pr_spectrechunk() & 15); } return 0; } @@ -50,12 +50,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkLarge) int t; t = pr_spectrechunk() & 7; - foo->vel.x = (t - (pr_spectrechunk() & 15)) << FRACBITS; + foo->Vel.X = (t - (pr_spectrechunk() & 15)); t = pr_spectrechunk() & 7; - foo->vel.y = (t - (pr_spectrechunk() & 15)) << FRACBITS; + foo->Vel.Y = (t - (pr_spectrechunk() & 15)); - foo->vel.z = (pr_spectrechunk() & 7) << FRACBITS; + foo->Vel.Z = (pr_spectrechunk() & 7); } return 0; } @@ -69,7 +69,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Spectre3Attack) AActor *foo = Spawn("SpectralLightningV2", self->PosPlusZ(32*FRACUNIT), ALLOW_REPLACE); - foo->vel.z = -12*FRACUNIT; + foo->Vel.Z = -12; foo->target = self; foo->FriendPlayer = 0; foo->tracer = self->target; diff --git a/src/g_strife/a_crusader.cpp b/src/g_strife/a_crusader.cpp index 1b03ea650..9fef47f09 100644 --- a/src/g_strife/a_crusader.cpp +++ b/src/g_strife/a_crusader.cpp @@ -29,18 +29,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderChoose) { A_FaceTarget (self); self->Angles.Yaw -= 180./16; - P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindActor("FastFlameMissile")); + P_SpawnMissileZAimed (self, self->_f_Z() + 40*FRACUNIT, self->target, PClass::FindActor("FastFlameMissile")); } else { if (P_CheckMissileRange (self)) { A_FaceTarget (self); - P_SpawnMissileZAimed (self, self->Z() + 56*FRACUNIT, self->target, PClass::FindActor("CrusaderMissile")); + P_SpawnMissileZAimed (self, self->_f_Z() + 56*FRACUNIT, self->target, PClass::FindActor("CrusaderMissile")); self->Angles.Yaw -= 45./32; - P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindActor("CrusaderMissile")); + P_SpawnMissileZAimed (self, self->_f_Z() + 40*FRACUNIT, self->target, PClass::FindActor("CrusaderMissile")); self->Angles.Yaw += 45./16; - P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindActor("CrusaderMissile")); + P_SpawnMissileZAimed (self, self->_f_Z() + 40*FRACUNIT, self->target, PClass::FindActor("CrusaderMissile")); self->Angles.Yaw -= 45./16; self->reactiontime += 15; } @@ -54,10 +54,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepLeft) PARAM_ACTION_PROLOGUE; self->Angles.Yaw += 90./16; - AActor *misl = P_SpawnMissileZAimed (self, self->Z() + 48*FRACUNIT, self->target, PClass::FindActor("FastFlameMissile")); + AActor *misl = P_SpawnMissileZAimed (self, self->_f_Z() + 48*FRACUNIT, self->target, PClass::FindActor("FastFlameMissile")); if (misl != NULL) { - misl->vel.z += FRACUNIT; + misl->Vel.Z += 1; } return 0; } @@ -67,10 +67,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepRight) PARAM_ACTION_PROLOGUE; self->Angles.Yaw -= 90./16; - AActor *misl = P_SpawnMissileZAimed (self, self->Z() + 48*FRACUNIT, self->target, PClass::FindActor("FastFlameMissile")); + AActor *misl = P_SpawnMissileZAimed (self, self->_f_Z() + 48*FRACUNIT, self->target, PClass::FindActor("FastFlameMissile")); if (misl != NULL) { - misl->vel.z += FRACUNIT; + misl->Vel.Z += 1; } return 0; } diff --git a/src/g_strife/a_entityboss.cpp b/src/g_strife/a_entityboss.cpp index 390a75ac4..aa1543d46 100644 --- a/src/g_strife/a_entityboss.cpp +++ b/src/g_strife/a_entityboss.cpp @@ -83,7 +83,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnEntity) { entity->Angles.Yaw = self->Angles.Yaw; entity->CopyFriendliness(self, true); - entity->vel.z = 5*FRACUNIT; + entity->Vel.Z = 5; entity->tracer = self; } return 0; @@ -94,39 +94,23 @@ DEFINE_ACTION_FUNCTION(AActor, A_EntityDeath) PARAM_ACTION_PROLOGUE; AActor *second; - fixed_t secondRadius = GetDefaultByName("EntitySecond")->radius * 2; - angle_t an; + double secondRadius = FIXED2DBL(GetDefaultByName("EntitySecond")->radius * 2); + + static const double turns[3] = { 0, 90, -90 }; + const double velmul[3] = { 4.8828125f, secondRadius*4, secondRadius*4 }; AActor *spot = self->tracer; if (spot == NULL) spot = self; - fixedvec3 pos = spot->Vec3Angle(secondRadius, self->_f_angle(), self->tracer? 70*FRACUNIT : 0); - - an = self->_f_angle() >> ANGLETOFINESHIFT; - second = Spawn("EntitySecond", pos, ALLOW_REPLACE); - second->CopyFriendliness(self, true); - //second->target = self->target; - A_FaceTarget (second); - an = second->_f_angle() >> ANGLETOFINESHIFT; - second->vel.x += FixedMul (finecosine[an], 320000); - second->vel.y += FixedMul (finesine[an], 320000); + for (int i = 0; i < 3; i++) + { + DAngle an = self->Angles.Yaw + turns[i]; + DVector3 pos = spot->Vec3Angle(secondRadius, an, self->tracer ? 70. : 0.); - pos = spot->Vec3Angle(secondRadius, self->_f_angle() + ANGLE_90, self->tracer? 70*FRACUNIT : 0); - an = (self->_f_angle() + ANGLE_90) >> ANGLETOFINESHIFT; - second = Spawn("EntitySecond", pos, ALLOW_REPLACE); - second->CopyFriendliness(self, true); - //second->target = self->target; - second->vel.x = FixedMul (secondRadius, finecosine[an]) << 2; - second->vel.y = FixedMul (secondRadius, finesine[an]) << 2; - A_FaceTarget (second); - - pos = spot->Vec3Angle(secondRadius, self->_f_angle() - ANGLE_90, self->tracer? 70*FRACUNIT : 0); - an = (self->_f_angle() - ANGLE_90) >> ANGLETOFINESHIFT; - second = Spawn("EntitySecond", pos, ALLOW_REPLACE); - second->CopyFriendliness(self, true); - //second->target = self->target; - second->vel.x = FixedMul (secondRadius, finecosine[an]) << 2; - second->vel.y = FixedMul (secondRadius, finesine[an]) << 2; - A_FaceTarget (second); + second = Spawn("EntitySecond", pos, ALLOW_REPLACE); + second->CopyFriendliness(self, true); + A_FaceTarget(second); + second->VelFromAngle(an, velmul[i]); + } return 0; } diff --git a/src/g_strife/a_inquisitor.cpp b/src/g_strife/a_inquisitor.cpp index dd30a7e88..f43278e31 100644 --- a/src/g_strife/a_inquisitor.cpp +++ b/src/g_strife/a_inquisitor.cpp @@ -42,7 +42,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorDecide) } if (self->target->Z() != self->Z()) { - if (self->Top() + 54*FRACUNIT < self->ceilingz) + if (self->_f_Top() + 54*FRACUNIT < self->ceilingz) { self->SetState (self->FindState("Jump")); } @@ -61,20 +61,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorAttack) A_FaceTarget (self); - self->AddZ(32*FRACUNIT); + self->_f_AddZ(32*FRACUNIT); self->Angles.Yaw -= 45./32; - proj = P_SpawnMissileZAimed (self, self->Z(), self->target, PClass::FindActor("InquisitorShot")); + proj = P_SpawnMissileZAimed (self, self->_f_Z(), self->target, PClass::FindActor("InquisitorShot")); if (proj != NULL) { - proj->vel.z += 9*FRACUNIT; + proj->Vel.Z += 9; } self->Angles.Yaw += 45./16; - proj = P_SpawnMissileZAimed (self, self->Z(), self->target, PClass::FindActor("InquisitorShot")); + proj = P_SpawnMissileZAimed (self, self->_f_Z(), self->target, PClass::FindActor("InquisitorShot")); if (proj != NULL) { - proj->vel.z += 16*FRACUNIT; + proj->Vel.Z += 16; } - self->AddZ(-32*FRACUNIT); + self->_f_AddZ(-32*FRACUNIT); return 0; } @@ -82,27 +82,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump) { PARAM_ACTION_PROLOGUE; - fixed_t dist; - fixed_t speed; - angle_t an; + double dist; + double speed; if (self->target == NULL) return 0; S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM); - self->AddZ(64*FRACUNIT); + self->_f_AddZ(64*FRACUNIT); A_FaceTarget (self); - an = self->_f_angle() >> ANGLETOFINESHIFT; - speed = self->Speed * 2/3; - self->vel.x += FixedMul (speed, finecosine[an]); - self->vel.y += FixedMul (speed, finesine[an]); - dist = self->AproxDistance (self->target); - dist /= speed; - if (dist < 1) - { - dist = 1; - } - self->vel.z = (self->target->Z() - self->Z()) / dist; + speed = self->Speed * (2./3); + self->VelFromAngle(speed); + dist = self->DistanceBySpeed(self->target, speed); + self->Vel.Z = (self->target->Z() - self->Z()) / dist; self->reactiontime = 60; self->flags |= MF_NOGRAVITY; return 0; @@ -114,9 +106,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorCheckLand) self->reactiontime--; if (self->reactiontime < 0 || - self->vel.x == 0 || - self->vel.y == 0 || - self->Z() <= self->floorz) + self->Vel.X == 0 || + self->Vel.Y == 0 || + self->_f_Z() <= self->floorz) { self->SetState (self->SeeState); self->reactiontime = 0; @@ -138,7 +130,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossArm) AActor *foo = Spawn("InquisitorArm", self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE); foo->Angles.Yaw = self->Angles.Yaw - 90. + pr_inq.Random2() * (360./1024.); foo->VelFromAngle(foo->Speed / 8); - foo->vel.z = pr_inq() << 10; + foo->Vel.Z = pr_inq() / 64.; return 0; } diff --git a/src/g_strife/a_loremaster.cpp b/src/g_strife/a_loremaster.cpp index 5b2f7fd90..85ef0ba2b 100644 --- a/src/g_strife/a_loremaster.cpp +++ b/src/g_strife/a_loremaster.cpp @@ -24,15 +24,9 @@ int ALoreShot::DoSpecialDamage (AActor *victim, int damage, FName damagetype) if (victim != NULL && target != NULL && !(victim->flags7 & MF7_DONTTHRUST)) { - fixedvec3 fixthrust = victim->Vec3To(target); - DVector3 thrust(fixthrust.x, fixthrust.y, fixthrust.z); - - thrust.MakeUnit(); - thrust *= double((255*50*FRACUNIT) / (victim->Mass ? victim->Mass : 1)); - - victim->vel.x += fixed_t(thrust.X); - victim->vel.y += fixed_t(thrust.Y); - victim->vel.z += fixed_t(thrust.Z); + DVector3 thrust = victim->Vec3To(target); + thrust.MakeResize(255. * 50 / MAX(victim->Mass, 1)); + victim->Vel += thrust; } return damage; } @@ -43,7 +37,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LoremasterChain) S_Sound (self, CHAN_BODY, "loremaster/active", 1, ATTN_NORM); Spawn("LoreShot2", self->Pos(), ALLOW_REPLACE); - Spawn("LoreShot2", self->Vec3Offset(-(self->vel.x >> 1), -(self->vel.y >> 1), -(self->vel.z >> 1)), ALLOW_REPLACE); - Spawn("LoreShot2", self->Vec3Offset(-self->vel.x, -self->vel.y, -self->vel.z), ALLOW_REPLACE); + Spawn("LoreShot2", self->Vec3Offset(-(self->_f_velx() >> 1), -(self->_f_vely() >> 1), -(self->_f_velz() >> 1)), ALLOW_REPLACE); + Spawn("LoreShot2", self->Vec3Offset(-self->_f_velx(), -self->_f_vely(), -self->_f_velz()), ALLOW_REPLACE); return 0; } diff --git a/src/g_strife/a_programmer.cpp b/src/g_strife/a_programmer.cpp index 010fe7935..a99d5c3cc 100644 --- a/src/g_strife/a_programmer.cpp +++ b/src/g_strife/a_programmer.cpp @@ -109,7 +109,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpotLightning) if (self->target == NULL) return 0; - spot = Spawn("SpectralLightningSpot", self->target->X(), self->target->Y(), self->target->floorz, ALLOW_REPLACE); + spot = Spawn("SpectralLightningSpot", self->target->_f_X(), self->target->_f_Y(), self->target->floorz, ALLOW_REPLACE); if (spot != NULL) { spot->threshold = 25; @@ -135,7 +135,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnProgrammerBase) { foo->Angles.Yaw = self->Angles.Yaw + 180. + pr_prog.Random2() * (360. / 1024.); foo->VelFromAngle(); - foo->vel.z = pr_prog() << 9; + foo->Vel.Z = pr_prog() / 128.; } return 0; } diff --git a/src/g_strife/a_rebels.cpp b/src/g_strife/a_rebels.cpp index 92467d34c..9f87596ef 100644 --- a/src/g_strife/a_rebels.cpp +++ b/src/g_strife/a_rebels.cpp @@ -80,8 +80,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon) AActor *rebel; angle_t an; - rebel = Spawn("Rebel1", self->X(), self->Y(), self->floorz, ALLOW_REPLACE); - if (!P_TryMove (rebel, rebel->X(), rebel->Y(), true)) + rebel = Spawn("Rebel1", self->_f_X(), self->_f_Y(), self->floorz, ALLOW_REPLACE); + if (!P_TryMove (rebel, rebel->_f_X(), rebel->_f_Y(), true)) { rebel->Destroy (); return 0; diff --git a/src/g_strife/a_sentinel.cpp b/src/g_strife/a_sentinel.cpp index 189fefdc8..ca0142825 100644 --- a/src/g_strife/a_sentinel.cpp +++ b/src/g_strife/a_sentinel.cpp @@ -17,7 +17,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelBob) if (self->flags & MF_INFLOAT) { - self->vel.z = 0; + self->Vel.Z = 0; return 0; } if (self->threshold != 0) @@ -29,15 +29,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelBob) { minz = maxz; } - if (minz < self->Z()) + if (minz < self->_f_Z()) { - self->vel.z -= FRACUNIT; + self->Vel.Z -= 1; } else { - self->vel.z += FRACUNIT; + self->Vel.Z += 1; } - self->reactiontime = (minz >= self->Z()) ? 4 : 0; + self->reactiontime = (minz >= self->_f_Z()) ? 4 : 0; return 0; } @@ -53,24 +53,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack) return 0; } - missile = P_SpawnMissileZAimed (self, self->Z() + 32*FRACUNIT, self->target, PClass::FindActor("SentinelFX2")); + missile = P_SpawnMissileZAimed (self, self->_f_Z() + 32*FRACUNIT, self->target, PClass::FindActor("SentinelFX2")); - if (missile != NULL && (missile->vel.x | missile->vel.y) != 0) + if (missile != NULL && (missile->Vel.X != 0 || missile->Vel.Y != 0)) { for (int i = 8; i > 1; --i) { trail = Spawn("SentinelFX1", - self->Vec3Angle(missile->radius*i, missile->_f_angle(), (missile->vel.z / 4 * i)), ALLOW_REPLACE); + self->_f_Vec3Angle(missile->radius*i, missile->_f_angle(), (missile->_f_velz() / 4 * i)), ALLOW_REPLACE); if (trail != NULL) { trail->target = self; - trail->vel.x = missile->vel.x; - trail->vel.y = missile->vel.y; - trail->vel.z = missile->vel.z; + trail->Vel = missile->Vel; P_CheckMissileSpawn (trail, self->radius); } } - missile->AddZ(missile->vel.z >> 2); + missile->_f_AddZ(missile->_f_velz() >> 2); } return 0; } diff --git a/src/g_strife/a_spectral.cpp b/src/g_strife/a_spectral.cpp index 491c231d3..0901726b9 100644 --- a/src/g_strife/a_spectral.cpp +++ b/src/g_strife/a_spectral.cpp @@ -28,7 +28,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightningTail) { PARAM_ACTION_PROLOGUE; - AActor *foo = Spawn("SpectralLightningHTail", self->Vec3Offset(-self->vel.x, -self->vel.y, 0), ALLOW_REPLACE); + AActor *foo = Spawn("SpectralLightningHTail", self->Vec3Offset(-self->_f_velx(), -self->_f_vely(), 0), ALLOW_REPLACE); foo->Angles.Yaw = self->Angles.Yaw; foo->FriendPlayer = self->FriendPlayer; @@ -63,8 +63,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightning) if (self->threshold != 0) --self->threshold; - self->vel.x += pr_zap5.Random2(3) << FRACBITS; - self->vel.y += pr_zap5.Random2(3) << FRACBITS; + self->Vel.X += pr_zap5.Random2(3); + self->Vel.Y += pr_zap5.Random2(3); fixedvec2 pos = self->Vec2Offset( pr_zap5.Random2(3) * FRACUNIT * 50, @@ -74,13 +74,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightning) PClass::FindActor(NAME_SpectralLightningV1), pos.x, pos.y, ONCEILINGZ, ALLOW_REPLACE); flash->target = self->target; - flash->vel.z = -18*FRACUNIT; + flash->Vel.Z = -18*FRACUNIT; flash->FriendPlayer = self->FriendPlayer; - flash = Spawn(NAME_SpectralLightningV2, self->X(), self->Y(), ONCEILINGZ, ALLOW_REPLACE); + flash = Spawn(NAME_SpectralLightningV2, self->_f_X(), self->_f_Y(), ONCEILINGZ, ALLOW_REPLACE); flash->target = self->target; - flash->vel.z = -18*FRACUNIT; + flash->Vel.Z = -18 * FRACUNIT; flash->FriendPlayer = self->FriendPlayer; return 0; } @@ -123,7 +123,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer2) if (!(self->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) { // change slope - dist = self->AproxDistance (dest) / self->Speed; + dist = self->AproxDistance (dest) / self->_f_speed(); if (dist < 1) { @@ -131,19 +131,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer2) } if (dest->height >= 56*FRACUNIT) { - slope = (dest->Z()+40*FRACUNIT - self->Z()) / dist; + slope = (dest->_f_Z()+40*FRACUNIT - self->_f_Z()) / dist; } else { - slope = (dest->Z() + self->height*2/3 - self->Z()) / dist; + slope = (dest->_f_Z() + self->height*2/3 - self->_f_Z()) / dist; } - if (slope < self->vel.z) + if (slope < self->_f_velz()) { - self->vel.z -= FRACUNIT/8; + self->Vel.Z -= 1 / 8.; } else { - self->vel.z += FRACUNIT/8; + self->Vel.Z += 1 / 8.; } } return 0; diff --git a/src/g_strife/a_stalker.cpp b/src/g_strife/a_stalker.cpp index 8ee07de8a..27cb388f1 100644 --- a/src/g_strife/a_stalker.cpp +++ b/src/g_strife/a_stalker.cpp @@ -19,7 +19,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_StalkerChaseDecide) { self->SetState (self->FindState("SeeFloor")); } - else if (self->ceilingz > self->Top()) + else if (self->ceilingz > self->_f_Top()) { self->SetState (self->FindState("Drop")); } diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index 4f1282209..aff0672cd 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -600,7 +600,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossGib) const char *gibtype = (self->flags & MF_NOBLOOD) ? "Junk" : "Meat"; AActor *gib = Spawn (gibtype, self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE); - int speed; if (gib == NULL) { @@ -608,9 +607,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossGib) } gib->Angles.Yaw = pr_gibtosser() * (360 / 256.f); - speed = pr_gibtosser() & 15; - gib->VelFromAngle(speed); - gib->vel.z = (pr_gibtosser() & 15) << FRACBITS; + gib->VelFromAngle(pr_gibtosser() & 15); + gib->Vel.Z = pr_gibtosser() & 15; return 0; } @@ -656,7 +654,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) sector_t *sec = self->Sector; - if (self->Z() == sec->floorplane.ZatPoint(self) && sec->PortalBlocksMovement(sector_t::floor)) + if (self->_f_Z() == sec->floorplane.ZatPoint(self) && sec->PortalBlocksMovement(sector_t::floor)) { if (sec->special == Damage_InstantDeath) { @@ -665,11 +663,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) else if (sec->special == Scroll_StrifeCurrent) { int anglespeed = tagManager.GetFirstSectorTag(sec) - 100; - fixed_t speed = (anglespeed % 10) << (FRACBITS - 4); - angle_t finean = (anglespeed / 10) << (32-3); - finean >>= ANGLETOFINESHIFT; - self->vel.x += FixedMul (speed, finecosine[finean]); - self->vel.y += FixedMul (speed, finesine[finean]); + double speed = (anglespeed % 10) / 16.; + DAngle an = (anglespeed / 10) * (360 / 8.); + self->VelFromAngle(an, speed); } } return 0; @@ -719,7 +715,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DropFire) PARAM_ACTION_PROLOGUE; AActor *drop = Spawn("FireDroplet", self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE); - drop->vel.z = -FRACUNIT; + drop->Vel.Z = -FRACUNIT; P_RadiusAttack (self, self, 64, 64, NAME_Fire, 0); return 0; } diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index d6a56939f..9febf1e35 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -379,11 +379,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_RocketInFlight) AActor *trail; S_Sound (self, CHAN_VOICE, "misc/missileinflight", 1, ATTN_NORM); - P_SpawnPuff (self, PClass::FindActor("MiniMissilePuff"), self->Pos(), self->_f_angle() - ANGLE_180, 2, PF_HITTHING); - trail = Spawn("RocketTrail", self->Vec3Offset(-self->vel.x, -self->vel.y, 0), ALLOW_REPLACE); + P_SpawnPuff (self, PClass::FindActor("MiniMissilePuff"), self->_f_Pos(), self->_f_angle() - ANGLE_180, 2, PF_HITTHING); + trail = Spawn("RocketTrail", self->Vec3Offset(-self->_f_velx(), -self->_f_vely(), 0), ALLOW_REPLACE); if (trail != NULL) { - trail->vel.z = FRACUNIT; + trail->Vel.Z = 1; } return 0; } @@ -401,7 +401,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlameDie) PARAM_ACTION_PROLOGUE; self->flags |= MF_NOGRAVITY; - self->vel.z = (pr_flamedie() & 3) << FRACBITS; + self->Vel.Z = pr_flamedie() & 3; return 0; } @@ -432,7 +432,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireFlamer) self = P_SpawnPlayerMissile (self, PClass::FindActor("FlameMissile")); if (self != NULL) { - self->vel.z += 5*FRACUNIT; + self->Vel.Z += 5; } return 0; } @@ -551,10 +551,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaulerTorpedoWave) self->Angles.Yaw += 180.; // If the torpedo hit the ceiling, it should still spawn the wave - savedz = self->Z(); - if (wavedef && self->ceilingz - self->Z() < wavedef->height) + savedz = self->_f_Z(); + if (wavedef && self->ceilingz - self->_f_Z() < wavedef->height) { - self->SetZ(self->ceilingz - wavedef->height); + self->_f_SetZ(self->ceilingz - wavedef->height); } for (int i = 0; i < 80; ++i) @@ -562,13 +562,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaulerTorpedoWave) self->Angles.Yaw += 4.5; P_SpawnSubMissile (self, PClass::FindActor("MaulerTorpedoWave"), self->target); } - self->SetZ(savedz); + self->_f_SetZ(savedz); return 0; } AActor *P_SpawnSubMissile (AActor *source, PClassActor *type, AActor *target) { - AActor *other = Spawn (type, source->Pos(), ALLOW_REPLACE); + AActor *other = Spawn (type, source->_f_Pos(), ALLOW_REPLACE); if (other == NULL) { @@ -594,7 +594,7 @@ AActor *P_SpawnSubMissile (AActor *source, PClassActor *type, AActor *target) if (P_CheckMissileSpawn (other, source->radius)) { DAngle pitch = P_AimLineAttack (source, source->Angles.Yaw, 1024.); - other->vel.z = fixed_t(-other->Speed * pitch.Cos()); + other->Vel.Z = -other->Speed * pitch.Cos(); return other; } return NULL; @@ -630,9 +630,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination) { PARAM_ACTION_PROLOGUE; - self->vel.z -= 8*FRACUNIT; - self->vel.x += (pr_phburn.Random2 (3)) << FRACBITS; - self->vel.y += (pr_phburn.Random2 (3)) << FRACBITS; + self->Vel.Z -= 8; + self->Vel.X += (pr_phburn.Random2 (3)); + self->Vel.Y += (pr_phburn.Random2 (3)); S_Sound (self, CHAN_VOICE, "world/largefire", 1, ATTN_NORM); // Only the main fire spawns more. @@ -662,20 +662,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination) sector_t * sector = P_PointInSector(pos.x, pos.y); // The sector's floor is too high so spawn the flame elsewhere. - if (sector->floorplane.ZatPoint(pos.x, pos.y) > self->Z() + self->MaxStepHeight) + if (sector->floorplane.ZatPoint(pos.x, pos.y) > self->_f_Z() + self->MaxStepHeight) { - pos.x = self->X(); - pos.y = self->Y(); + pos.x = self->_f_X(); + pos.y = self->_f_Y(); } AActor *drop = Spawn ( pos.x, pos.y, - self->Z() + 4*FRACUNIT, ALLOW_REPLACE); + self->_f_Z() + 4*FRACUNIT, ALLOW_REPLACE); if (drop != NULL) { - drop->vel.x = self->vel.x + ((pr_phburn.Random2 (7)) << FRACBITS); - drop->vel.y = self->vel.y + ((pr_phburn.Random2 (7)) << FRACBITS); - drop->vel.z = self->vel.z - FRACUNIT; + drop->Vel.X = self->Vel.X + pr_phburn.Random2 (7); + drop->Vel.Y = self->Vel.Y + pr_phburn.Random2 (7); + drop->Vel.Z = self->Vel.Z - 1; drop->reactiontime = (pr_phburn() & 3) + 2; drop->flags |= MF_DROPPED; } @@ -715,9 +715,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade) if (grenadetype != NULL) { - self->AddZ(32*FRACUNIT); + self->_f_AddZ(32*FRACUNIT); grenade = P_SpawnSubMissile (self, grenadetype, self); - self->AddZ(-32*FRACUNIT); + self->_f_AddZ(-32*FRACUNIT); if (grenade == NULL) return 0; @@ -726,7 +726,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade) S_Sound (grenade, CHAN_VOICE, grenade->SeeSound, 1, ATTN_NORM); } - grenade->vel.z = FixedMul (finetangent[FINEANGLES/4-(self->_f_pitch()>>ANGLETOFINESHIFT)], grenade->Speed) + 8*FRACUNIT; + grenade->Vel.Z = (-self->Angles.Pitch.TanClamped()) * grenade->Speed + 8; fixedvec2 offset; @@ -741,7 +741,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade) offset.y += FixedMul (finesine[an], 15*FRACUNIT); fixedvec2 newpos = grenade->Vec2Offset(offset.x, offset.y); - grenade->SetOrigin(newpos.x, newpos.y, grenade->Z(), false); + grenade->SetOrigin(newpos.x, newpos.y, grenade->_f_Z(), false); } return 0; } @@ -987,7 +987,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1) P_BulletSlope (self, &t, ALF_PORTALRESTRICT); if (t.linetarget != NULL) { - spot = Spawn("SpectralLightningSpot", t.linetarget->X(), t.linetarget->Y(), t.linetarget->floorz, ALLOW_REPLACE); + spot = Spawn("SpectralLightningSpot", t.linetarget->_f_X(), t.linetarget->_f_Y(), t.linetarget->floorz, ALLOW_REPLACE); if (spot != NULL) { spot->tracer = t.linetarget; @@ -995,11 +995,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1) } else { - spot = Spawn("SpectralLightningSpot", self->Pos(), ALLOW_REPLACE); + spot = Spawn("SpectralLightningSpot", self->_f_Pos(), ALLOW_REPLACE); if (spot != NULL) { - spot->vel.x += 28 * finecosine[self->_f_angle() >> ANGLETOFINESHIFT]; - spot->vel.y += 28 * finesine[self->_f_angle() >> ANGLETOFINESHIFT]; + spot->VelFromAngle(self->Angles.Yaw, 28.); } } if (spot != NULL) @@ -1059,7 +1058,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil3) spot = P_SpawnSubMissile (self, PClass::FindActor("SpectralLightningBall1"), self); if (spot != NULL) { - spot->SetZ(self->Z() + 32*FRACUNIT); + spot->_f_SetZ(self->_f_Z() + 32*FRACUNIT); } } self->Angles.Yaw -= 90.; @@ -1100,8 +1099,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil4) spot = P_SpawnPlayerMissile (self, PClass::FindActor("SpectralLightningBigV1")); if (spot != NULL) { - spot->vel.x += FixedMul (spot->Speed, finecosine[self->_f_angle() >> ANGLETOFINESHIFT]); - spot->vel.y += FixedMul (spot->Speed, finesine[self->_f_angle() >> ANGLETOFINESHIFT]); + spot->VelFromAngle(self->Angles.Yaw, spot->Speed); } } return 0; diff --git a/src/g_strife/a_thingstoblowup.cpp b/src/g_strife/a_thingstoblowup.cpp index 55b00e6b9..d98488e26 100644 --- a/src/g_strife/a_thingstoblowup.cpp +++ b/src/g_strife/a_thingstoblowup.cpp @@ -112,9 +112,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightGoesOut) if (foo != NULL) { int t = pr_lightout() & 15; - foo->vel.x = (t - (pr_lightout() & 7)) << FRACBITS; - foo->vel.y = (pr_lightout.Random2() & 7) << FRACBITS; - foo->vel.z = (7 + (pr_lightout() & 3)) << FRACBITS; + foo->Vel.X = t - (pr_lightout() & 7); + foo->Vel.Y = pr_lightout.Random2() & 7; + foo->Vel.Z = 7 + (pr_lightout() & 3); } } return 0; diff --git a/src/info.cpp b/src/info.cpp index 40a600884..eec1cd415 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -229,7 +229,7 @@ PClassActor::PClassActor() GibHealth = INT_MIN; WoundHealth = 6; PoisonDamage = 0; - FastSpeed = FIXED_MIN; + FastSpeed = -1.; RDFactor = FRACUNIT; CameraHeight = FIXED_MIN; diff --git a/src/info.h b/src/info.h index 1f2537d47..157c099f5 100644 --- a/src/info.h +++ b/src/info.h @@ -248,7 +248,7 @@ public: int GibHealth; // Negative health below which this monster dies an extreme death int WoundHealth; // Health needed to enter wound state int PoisonDamage; // Amount of poison damage - fixed_t FastSpeed; // Speed in fast mode + double FastSpeed; // speed in fast mode fixed_t RDFactor; // Radius damage factor fixed_t CameraHeight; // Height of camera when used as such FSoundID HowlSound; // Sound being played when electrocuted or poisoned diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index a74c77364..fbfb95a50 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -138,7 +138,7 @@ void cht_DoCheat (player_t *player, int cheat) player->cheats &= ~CF_NOCLIP; msg = GStrings("STSTR_NCOFF"); } - if (player->mo->vel.x == 0) player->mo->vel.x = 1; // force some lateral movement so that internal variables are up to date + if (player->mo->Vel.X == 0) player->mo->Vel.X = MinVel; // force some lateral movement so that internal variables are up to date break; case CHT_NOVELOCITY: @@ -583,7 +583,7 @@ void GiveSpawner (player_t *player, PClassInventory *type, int amount) } AInventory *item = static_cast - (Spawn (type, player->mo->X(), player->mo->Y(), player->mo->Z(), NO_REPLACE)); + (Spawn (type, player->mo->Pos(), NO_REPLACE)); if (item != NULL) { if (amount > 0) diff --git a/src/math/fastsin.cpp b/src/math/fastsin.cpp index 1c25955b0..6220585f9 100644 --- a/src/math/fastsin.cpp +++ b/src/math/fastsin.cpp @@ -53,7 +53,7 @@ __forceinline double FFastTrig::sinq1(unsigned bangle) { unsigned int index = bangle >> BITSHIFT; - if ((bangle &= (REMAINDER - 1)) == 0) // This is to avoid precision problems at 180° + if ((bangle &= (REMAINDER)) == 0) // This is to avoid precision problems at 180° { return double(sinetable[index]); } diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index ab47c1e47..70269c3fa 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -337,13 +337,13 @@ void P_PlayerOnSpecial3DFloor(player_t* player) if(rover->flags & FF_SOLID) { // Player must be on top of the floor to be affected... - if(player->mo->Z() != rover->top.plane->ZatPoint(player->mo)) continue; + if(player->mo->_f_Z() != rover->top.plane->ZatPoint(player->mo)) continue; } else { //Water and DEATH FOG!!! heh - if (player->mo->Z() > rover->top.plane->ZatPoint(player->mo) || - player->mo->Top() < rover->bottom.plane->ZatPoint(player->mo)) + if (player->mo->_f_Z() > rover->top.plane->ZatPoint(player->mo) || + player->mo->_f_Top() < rover->bottom.plane->ZatPoint(player->mo)) continue; } @@ -759,7 +759,7 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li { fixed_t thingbot, thingtop; - thingbot = thing->Z(); + thingbot = thing->_f_Z(); thingtop = thingbot + (thing->height==0? 1:thing->height); extsector_t::xfloor *xf[2] = {&linedef->frontsector->e->XFloor, &linedef->backsector->e->XFloor}; @@ -803,7 +803,7 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li lowestceilingsec = j == 0 ? linedef->frontsector : linedef->backsector; } - if(ff_top > highestfloor && delta1 < delta2 && (!restrict || thing->Z() >= ff_top)) + if(ff_top > highestfloor && delta1 < delta2 && (!restrict || thing->_f_Z() >= ff_top)) { highestfloor = ff_top; highestfloorpic = *rover->top.texture; @@ -811,7 +811,7 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li highestfloorsec = j == 0 ? linedef->frontsector : linedef->backsector; highestfloorplanes[j] = rover->top.plane; } - if(ff_top > lowestfloor[j] && ff_top <= thing->Z() + thing->MaxStepHeight) lowestfloor[j] = ff_top; + if(ff_top > lowestfloor[j] && ff_top <= thing->_f_Z() + thing->MaxStepHeight) lowestfloor[j] = ff_top; } } diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index 1fc741915..b49880a17 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -278,7 +278,7 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & open.abovemidtex = false; if (P_GetMidTexturePosition(linedef, 0, &tt, &tb)) { - if (thing->Z() + (thing->height/2) < (tt + tb)/2) + if (thing->_f_Z() + (thing->height/2) < (tt + tb)/2) { if (tb < open.top) { @@ -288,7 +288,7 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & } else { - if (tt > open.bottom && (!restrict || thing->Z() >= tt)) + if (tt > open.bottom && (!restrict || thing->_f_Z() >= tt)) { open.bottom = tt; open.abovemidtex = true; @@ -299,7 +299,7 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & } // returns true if it touches the midtexture - return (abs(thing->Z() - tt) <= thing->MaxStepHeight); + return (abs(thing->_f_Z() - tt) <= thing->MaxStepHeight); } } return false; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index b368bedbd..49adf744f 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3487,12 +3487,12 @@ int DLevelScript::DoSpawnSpot (int type, int spot, int tid, int angle, bool forc while ( (aspot = iterator.Next ()) ) { - spawned += DoSpawn (type, aspot->X(), aspot->Y(), aspot->Z(), tid, angle, force); + spawned += DoSpawn (type, aspot->_f_X(), aspot->_f_Y(), aspot->_f_Z(), tid, angle, force); } } else if (activator != NULL) { - spawned += DoSpawn (type, activator->X(), activator->Y(), activator->Z(), tid, angle, force); + spawned += DoSpawn (type, activator->_f_X(), activator->_f_Y(), activator->_f_Z(), tid, angle, force); } return spawned; } @@ -3508,12 +3508,12 @@ int DLevelScript::DoSpawnSpotFacing (int type, int spot, int tid, bool force) while ( (aspot = iterator.Next ()) ) { - spawned += DoSpawn (type, aspot->X(), aspot->Y(), aspot->Z(), tid, aspot->_f_angle() >> 24, force); + spawned += DoSpawn (type, aspot->_f_X(), aspot->_f_Y(), aspot->_f_Z(), tid, aspot->_f_angle() >> 24, force); } } else if (activator != NULL) { - spawned += DoSpawn (type, activator->X(), activator->Y(), activator->Z(), tid, activator->_f_angle() >> 24, force); + spawned += DoSpawn (type, activator->_f_X(), activator->_f_Y(), activator->_f_Z(), tid, activator->_f_angle() >> 24, force); } return spawned; } @@ -3805,7 +3805,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) break; case APROP_Speed: - actor->Speed = value; + actor->Speed = FIXED2DBL(value); break; case APROP_Damage: @@ -3849,7 +3849,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) case APROP_JumpZ: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn))) - static_cast(actor)->JumpZ = value; + static_cast(actor)->JumpZ = FIXED2DBL(value); break; // [GRB] case APROP_ChaseGoal: @@ -4005,7 +4005,7 @@ int DLevelScript::GetActorProperty (int tid, int property) switch (property) { case APROP_Health: return actor->health; - case APROP_Speed: return actor->Speed; + case APROP_Speed: return FLOAT2FIXED(actor->Speed); case APROP_Damage: return actor->GetMissileDamage(0,1); case APROP_DamageFactor:return actor->DamageFactor; case APROP_DamageMultiplier: return actor->DamageMultiply; @@ -4041,7 +4041,7 @@ int DLevelScript::GetActorProperty (int tid, int property) case APROP_JumpZ: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn))) { - return static_cast(actor)->JumpZ; // [GRB] + return FLOAT2FIXED(static_cast(actor)->JumpZ); // [GRB] } else { @@ -4184,12 +4184,12 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b if (floor) { - actor->Sector->NextLowestFloorAt(actor->X(), actor->Y(), actor->Z(), 0, actor->MaxStepHeight, &resultsec, &resffloor); + actor->Sector->NextLowestFloorAt(actor->_f_X(), actor->_f_Y(), actor->_f_Z(), 0, actor->MaxStepHeight, &resultsec, &resffloor); secpic = resffloor ? *resffloor->top.texture : resultsec->planes[sector_t::floor].Texture; } else { - actor->Sector->NextHighestCeilingAt(actor->X(), actor->Y(), actor->Z(), actor->Top(), 0, &resultsec, &resffloor); + actor->Sector->NextHighestCeilingAt(actor->_f_X(), actor->_f_Y(), actor->_f_Z(), actor->_f_Top(), 0, &resultsec, &resffloor); secpic = resffloor ? *resffloor->bottom.texture : resultsec->planes[sector_t::ceiling].Texture; } return tex == TexMan[secpic]; @@ -4738,8 +4738,8 @@ static bool DoSpawnDecal(AActor *actor, const FDecalTemplate *tpl, int flags, an { angle += actor->_f_angle(); } - return NULL != ShootDecal(tpl, actor, actor->Sector, actor->X(), actor->Y(), - actor->Z() + (actor->height>>1) - actor->floorclip + actor->GetBobOffset() + zofs, + return NULL != ShootDecal(tpl, actor, actor->Sector, actor->_f_X(), actor->_f_Y(), + actor->_f_Z() + (actor->height>>1) - actor->floorclip + actor->GetBobOffset() + zofs, angle, distance, !!(flags & SDF_PERMANENT)); } @@ -4900,15 +4900,15 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args) case ACSF_GetActorVelX: actor = SingleActorFromTID(args[0], activator); - return actor != NULL? actor->vel.x : 0; + return actor != NULL? FLOAT2FIXED(actor->Vel.X) : 0; case ACSF_GetActorVelY: actor = SingleActorFromTID(args[0], activator); - return actor != NULL? actor->vel.y : 0; + return actor != NULL? FLOAT2FIXED(actor->Vel.Y) : 0; case ACSF_GetActorVelZ: actor = SingleActorFromTID(args[0], activator); - return actor != NULL? actor->vel.z : 0; + return actor != NULL? FLOAT2FIXED(actor->Vel.Z) : 0; case ACSF_SetPointer: if (activator) @@ -5078,20 +5078,23 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args) return (CheckActorProperty(args[0], args[1], args[2])); case ACSF_SetActorVelocity: - if (args[0] == 0) - { - P_Thing_SetVelocity(activator, args[1], args[2], args[3], !!args[4], !!args[5]); - } - else - { - TActorIterator iterator (args[0]); - - while ( (actor = iterator.Next ()) ) - { - P_Thing_SetVelocity(actor, args[1], args[2], args[3], !!args[4], !!args[5]); - } - } - return 0; + { + DVector3 vel(FIXED2DBL(args[1]), FIXED2DBL(args[2]), FIXED2DBL(args[3])); + if (args[0] == 0) + { + P_Thing_SetVelocity(activator, vel, !!args[4], !!args[5]); + } + else + { + TActorIterator iterator(args[0]); + + while ((actor = iterator.Next())) + { + P_Thing_SetVelocity(actor, vel, !!args[4], !!args[5]); + } + } + return 0; + } case ACSF_SetUserVariable: { @@ -8349,23 +8352,23 @@ scriptwait: break; case PCD_SETGRAVITY: - level.gravity = (float)STACK(1) / 65536.f; + level.gravity = FIXED2DBL(STACK(1)); sp--; break; case PCD_SETGRAVITYDIRECT: - level.gravity = (float)uallong(pc[0]) / 65536.f; + level.gravity = FIXED2DBL(uallong(pc[0])); pc++; break; case PCD_SETAIRCONTROL: - level.aircontrol = STACK(1); + level.aircontrol = FIXED2DBL(STACK(1)); sp--; G_AirControlChanged (); break; case PCD_SETAIRCONTROLDIRECT: - level.aircontrol = uallong(pc[0]); + level.aircontrol = FIXED2DBL(uallong(pc[0])); pc++; G_AirControlChanged (); break; @@ -8663,11 +8666,11 @@ scriptwait: } else if (pcd == PCD_GETACTORZ) { - STACK(1) = actor->Z() + actor->GetBobOffset(); + STACK(1) = actor->_f_Z() + actor->GetBobOffset(); } else { - STACK(1) = pcd == PCD_GETACTORX ? actor->X() : pcd == PCD_GETACTORY ? actor->Y() : actor->Z(); + STACK(1) = pcd == PCD_GETACTORX ? actor->_f_X() : pcd == PCD_GETACTORY ? actor->_f_Y() : actor->_f_Z(); } } break; @@ -9224,8 +9227,8 @@ scriptwait: case PLAYERINFO_COLOR: STACK(2) = userinfo->GetColor(); break; case PLAYERINFO_GENDER: STACK(2) = userinfo->GetGender(); break; case PLAYERINFO_NEVERSWITCH: STACK(2) = userinfo->GetNeverSwitch(); break; - case PLAYERINFO_MOVEBOB: STACK(2) = userinfo->GetMoveBob(); break; - case PLAYERINFO_STILLBOB: STACK(2) = userinfo->GetStillBob(); break; + case PLAYERINFO_MOVEBOB: STACK(2) = FLOAT2FIXED(userinfo->GetMoveBob()); break; + case PLAYERINFO_STILLBOB: STACK(2) = FLOAT2FIXED(userinfo->GetStillBob()); break; case PLAYERINFO_PLAYERCLASS: STACK(2) = userinfo->GetPlayerClassNum(); break; case PLAYERINFO_DESIREDFOV: STACK(2) = (int)pl->DesiredFOV; break; case PLAYERINFO_FOV: STACK(2) = (int)pl->FOV; break; diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 8df47366a..79cb3385d 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -1091,8 +1091,8 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang return; } - pc->vel.x = pc->vel.y = 0; // Stop moving - pc->player->vel.x = pc->player->vel.y = 0; + pc->Vel.Zero(); + pc->player->Vel.Zero(); static_cast(pc)->PlayIdle (); pc->player->ConversationPC = pc; diff --git a/src/p_effect.cpp b/src/p_effect.cpp index cbdc00222..1619f7503 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -431,17 +431,7 @@ static void MakeFountain (AActor *actor, int color1, int color2) void P_RunEffect (AActor *actor, int effects) { - angle_t moveangle; - - // 512 is the limit below which R_PointToAngle2 does no longer returns usable values. - if (abs(actor->vel.x) > 512 || abs(actor->vel.y) > 512) - { - moveangle = R_PointToAngle2(0,0,actor->vel.x,actor->vel.y); - } - else - { - moveangle = actor->_f_angle(); - } + DAngle moveangle = actor->Vel.Angle(); particle_t *particle; int i; @@ -449,28 +439,26 @@ void P_RunEffect (AActor *actor, int effects) if ((effects & FX_ROCKET) && (cl_rockettrails & 1)) { // Rocket trail + double backx = -actor->_Radius() * 2 * moveangle.Cos(); + double backy = -actor->_Radius() * 2 * moveangle.Sin(); + double backz = actor->_Height() * ((2. / 3) - actor->Vel.Z / 8); - - fixed_t backx = - FixedMul (finecosine[(moveangle)>>ANGLETOFINESHIFT], actor->radius*2); - fixed_t backy = - FixedMul (finesine[(moveangle)>>ANGLETOFINESHIFT], actor->radius*2); - fixed_t backz = - (actor->height>>3) * (actor->vel.z>>16) + (2*actor->height)/3; - - angle_t an = (moveangle + ANG90) >> ANGLETOFINESHIFT; + DAngle an = moveangle + 90.; int speed; particle = JitterParticle (3 + (M_Random() & 31)); if (particle) { fixed_t pathdist = M_Random()<<8; fixedvec3 pos = actor->Vec3Offset( - backx - FixedMul(actor->vel.x, pathdist), - backy - FixedMul(actor->vel.y, pathdist), - backz - FixedMul(actor->vel.z, pathdist)); + FLOAT2FIXED(backx) - fixed_t(actor->Vel.X * pathdist), + FLOAT2FIXED(backy) - fixed_t(actor->Vel.Y * pathdist), + FLOAT2FIXED(backz) - fixed_t(actor->Vel.Z * pathdist)); particle->x = pos.x; particle->y = pos.y; particle->z = pos.z; speed = (M_Random () - 128) * (FRACUNIT/200); - particle->vel.x += FixedMul (speed, finecosine[an]); - particle->vel.y += FixedMul (speed, finesine[an]); + particle->vel.x += fixed_t(speed * an.Cos()); + particle->vel.y += fixed_t(speed * an.Sin()); particle->vel.z -= FRACUNIT/36; particle->accz -= FRACUNIT/20; particle->color = yellow; @@ -481,15 +469,15 @@ void P_RunEffect (AActor *actor, int effects) if (particle) { fixed_t pathdist = M_Random()<<8; fixedvec3 pos = actor->Vec3Offset( - backx - FixedMul(actor->vel.x, pathdist), - backy - FixedMul(actor->vel.y, pathdist), - backz - FixedMul(actor->vel.z, pathdist) + (M_Random() << 10)); + FLOAT2FIXED(backx) - fixed_t(actor->Vel.X * pathdist), + FLOAT2FIXED(backy) - fixed_t(actor->Vel.Y * pathdist), + FLOAT2FIXED(backz) - fixed_t(actor->Vel.Z * pathdist) + (M_Random() << 10)); particle->x = pos.x; particle->y = pos.y; particle->z = pos.z; speed = (M_Random () - 128) * (FRACUNIT/200); - particle->vel.x += FixedMul (speed, finecosine[an]); - particle->vel.y += FixedMul (speed, finesine[an]); + particle->vel.x += fixed_t(speed * an.Cos()); + particle->vel.y += fixed_t(speed * an.Sin()); particle->vel.z += FRACUNIT/80; particle->accz += FRACUNIT/40; if (M_Random () & 7) @@ -505,11 +493,11 @@ void P_RunEffect (AActor *actor, int effects) { // Grenade trail - fixedvec3 pos = actor->Vec3Angle(-actor->radius * 2, moveangle, - -(actor->height >> 3) * (actor->vel.z >> 16) + (2 * actor->height) / 3); + fixedvec3 pos = actor->_f_Vec3Angle(-actor->radius * 2, moveangle.BAMs(), + fixed_t(-(actor->height >> 3) * (actor->Vel.Z) + (2 * actor->height) / 3)); P_DrawSplash2 (6, pos.x, pos.y, pos.z, - moveangle + ANG180, 2, 2); + moveangle.BAMs() + ANG180, 2, 2); } if (effects & FX_FOUNTAINMASK) { @@ -685,8 +673,8 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, double r; double dirz; - if (abs(mo->X() - FLOAT2FIXED(start.X)) < 20 * FRACUNIT - && (mo->Y() - FLOAT2FIXED(start.Y)) < 20 * FRACUNIT) + if (fabs(mo->X() - start.X) < 20 + && fabs(mo->Y() - start.Y) < 20) { // This player (probably) fired the railgun S_Sound (mo, CHAN_WEAPON, sound, 1, ATTN_NORM); } @@ -696,7 +684,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, // Only consider sound in 2D (for now, anyway) // [BB] You have to divide by lengthsquared here, not multiply with it. - r = ((start.Y - FIXED2DBL(mo->Y())) * (-dir.Y) - (start.X - FIXED2DBL(mo->X())) * (dir.X)) / lengthsquared; + r = ((start.Y - mo->Y()) * (-dir.Y) - (start.X - mo->X()) * (dir.X)) / lengthsquared; r = clamp(r, 0., 1.); dirz = dir.Z; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index e76397d5b..f9d71b49e 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -453,7 +453,7 @@ bool P_Move (AActor *actor) fixed_t tryx, tryy, deltax, deltay, origx, origy; bool try_ok; - int speed = actor->Speed; + int speed = actor->_f_speed(); int movefactor = ORIG_FRICTION_FACTOR; int friction = ORIG_FRICTION; int dropoff = 0; @@ -473,7 +473,7 @@ bool P_Move (AActor *actor) // it difficult to thrust them vertically in a reasonable manner. // [GZ] Let jumping actors jump. if (!((actor->flags & MF_NOGRAVITY) || (actor->flags6 & MF6_CANJUMP)) - && actor->Z() > actor->floorz && !(actor->flags2 & MF2_ONMOBJ)) + && actor->_f_Z() > actor->floorz && !(actor->flags2 & MF2_ONMOBJ)) { return false; } @@ -507,13 +507,13 @@ bool P_Move (AActor *actor) * speed) / ORIG_FRICTION_FACTOR; if (speed == 0) { // always give the monster a little bit of speed - speed = ksgn(actor->Speed); + speed = ksgn(actor->_f_speed()); } } } - tryx = (origx = actor->X()) + (deltax = FixedMul (speed, xspeed[actor->movedir])); - tryy = (origy = actor->Y()) + (deltay = FixedMul (speed, yspeed[actor->movedir])); + tryx = (origx = actor->_f_X()) + (deltax = FixedMul (speed, xspeed[actor->movedir])); + tryy = (origy = actor->_f_Y()) + (deltay = FixedMul (speed, yspeed[actor->movedir])); // Like P_XYMovement this should do multiple moves if the step size is too large @@ -563,10 +563,10 @@ bool P_Move (AActor *actor) if (try_ok && friction > ORIG_FRICTION) { - actor->SetOrigin(origx, origy, actor->Z(), false); + actor->SetOrigin(origx, origy, actor->_f_Z(), false); movefactor *= FRACUNIT / ORIG_FRICTION_FACTOR / 4; - actor->vel.x += FixedMul (deltax, movefactor); - actor->vel.y += FixedMul (deltay, movefactor); + actor->Vel.X += FIXED2DBL(FixedMul (deltax, movefactor)); + actor->Vel.Y += FIXED2DBL(FixedMul (deltay, movefactor)); } // [RH] If a walking monster is no longer on the floor, move it down @@ -574,17 +574,17 @@ bool P_Move (AActor *actor) // actually walking down a step. if (try_ok && !((actor->flags & MF_NOGRAVITY) || (actor->flags6 & MF6_CANJUMP)) - && actor->Z() > actor->floorz && !(actor->flags2 & MF2_ONMOBJ)) + && actor->_f_Z() > actor->floorz && !(actor->flags2 & MF2_ONMOBJ)) { - if (actor->Z() <= actor->floorz + actor->MaxStepHeight) + if (actor->_f_Z() <= actor->floorz + actor->MaxStepHeight) { - fixed_t savedz = actor->Z(); - actor->SetZ(actor->floorz); + fixed_t savedz = actor->_f_Z(); + actor->_f_SetZ(actor->floorz); // Make sure that there isn't some other actor between us and // the floor we could get stuck in. The old code did not do this. if (!P_TestMobjZ(actor)) { - actor->SetZ(savedz); + actor->_f_SetZ(savedz); } else { // The monster just hit the floor, so trigger any actions. @@ -602,12 +602,12 @@ bool P_Move (AActor *actor) { if (((actor->flags6 & MF6_CANJUMP)||(actor->flags & MF_FLOAT)) && tm.floatok) { // must adjust height - fixed_t savedz = actor->Z(); + fixed_t savedz = actor->_f_Z(); - if (actor->Z() < tm.floorz) - actor->AddZ(actor->FloatSpeed); + if (actor->_f_Z() < tm.floorz) + actor->_f_AddZ(actor->_f_floatspeed()); else - actor->AddZ(-actor->FloatSpeed); + actor->_f_AddZ(-actor->_f_floatspeed()); // [RH] Check to make sure there's nothing in the way of the float @@ -616,7 +616,7 @@ bool P_Move (AActor *actor) actor->flags |= MF_INFLOAT; return true; } - actor->SetZ(savedz); + actor->_f_SetZ(savedz); } if (!spechit.Size ()) @@ -854,11 +854,11 @@ void P_NewChaseDir(AActor * actor) if ((actor->flags5&MF5_CHASEGOAL || actor->goal == actor->target) && actor->goal!=NULL) { - delta = actor->Vec2To(actor->goal); + delta = actor->_f_Vec2To(actor->goal); } else if (actor->target != NULL) { - delta = actor->Vec2To(actor->target); + delta = actor->_f_Vec2To(actor->target); if (!(actor->flags6 & MF6_NOFEAR)) { @@ -880,11 +880,11 @@ void P_NewChaseDir(AActor * actor) // Try to move away from a dropoff if (actor->floorz - actor->dropoffz > actor->MaxDropOffHeight && - actor->Z() <= actor->floorz && !(actor->flags & MF_DROPOFF) && + actor->_f_Z() <= actor->floorz && !(actor->flags & MF_DROPOFF) && !(actor->flags2 & MF2_ONMOBJ) && !(actor->flags & MF_FLOAT) && !(i_compatflags & COMPATF_DROPOFF)) { - FBoundingBox box(actor->X(), actor->Y(), actor->radius); + FBoundingBox box(actor->_f_X(), actor->_f_Y(), actor->radius); FBlockLinesIterator it(box); line_t *line; @@ -906,11 +906,11 @@ void P_NewChaseDir(AActor * actor) // The monster must contact one of the two floors, // and the other must be a tall dropoff. - if (back == actor->Z() && front < actor->Z() - actor->MaxDropOffHeight) + if (back == actor->_f_Z() && front < actor->_f_Z() - actor->MaxDropOffHeight) { angle = R_PointToAngle2(0,0,line->dx,line->dy); // front side dropoff } - else if (front == actor->Z() && back < actor->Z() - actor->MaxDropOffHeight) + else if (front == actor->_f_Z() && back < actor->_f_Z() - actor->MaxDropOffHeight) { angle = R_PointToAngle2(line->dx,line->dy,0,0); // back side dropoff } @@ -1038,7 +1038,7 @@ void P_RandomChaseDir (AActor *actor) { if (pr_newchasedir() & 1 || !P_CheckSight (actor, player)) { - delta = actor->Vec2To(player); + delta = actor->_f_Vec2To(player); if (delta.x>128*FRACUNIT) d[1]= DI_EAST; @@ -1734,7 +1734,7 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params) player->mo->flags3 & MF3_GHOST) { if ((player->mo->AproxDistance (actor) > (128 << FRACBITS)) - && P_AproxDistance (player->mo->vel.x, player->mo->vel.y) < 5*FRACUNIT) + && P_AproxDistance (player->mo->_f_velx(), player->mo->_f_vely()) < 5*FRACUNIT) { // Player is sneaking - can't detect continue; } @@ -2456,18 +2456,16 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele else { actor->FastChaseStrafeCount = 0; - actor->vel.x = 0; - actor->vel.y = 0; + actor->Vel.X = actor->Vel.Y = 0; fixed_t dist = actor->AproxDistance (actor->target); if (dist < CLASS_BOSS_STRAFE_RANGE) { if (pr_chase() < 100) { - angle_t ang = actor->__f_AngleTo(actor->target); - if (pr_chase() < 128) ang += ANGLE_90; - else ang -= ANGLE_90; - actor->vel.x = 13 * finecosine[ang>>ANGLETOFINESHIFT]; - actor->vel.y = 13 * finesine[ang>>ANGLETOFINESHIFT]; + DAngle ang = actor->AngleTo(actor->target); + if (pr_chase() < 128) ang += 90.; + else ang -= 90.; + actor->VelFromAngle(ang, 13.); actor->FastChaseStrafeCount = 3; // strafe time } } @@ -2548,8 +2546,8 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele if ((!fastchase || !actor->FastChaseStrafeCount) && !dontmove) { // CANTLEAVEFLOORPIC handling was completely missing in the non-serpent functions. - fixed_t oldX = actor->X(); - fixed_t oldY = actor->Y(); + fixed_t oldX = actor->_f_X(); + fixed_t oldY = actor->_f_Y(); int oldgroup = actor->PrevPortalGroup; FTextureID oldFloor = actor->floorpic; @@ -2601,14 +2599,14 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) if (self->movedir != DI_NODIR) { - const fixed_t absSpeed = abs (self->Speed); + const fixed_t absSpeed = abs (self->_f_speed()); fixedvec2 viletry = self->Vec2Offset( FixedMul (absSpeed, xspeed[self->movedir]), FixedMul (absSpeed, yspeed[self->movedir]), true); FPortalGroupArray check(FPortalGroupArray::PGA_Full3d); - FMultiBlockThingsIterator it(check, viletry.x, viletry.y, self->Z() - 64* FRACUNIT, self->Top() + 64 * FRACUNIT, 32 * FRACUNIT, false, NULL); + FMultiBlockThingsIterator it(check, viletry.x, viletry.y, self->_f_Z() - 64* FRACUNIT, self->_f_Top() + 64 * FRACUNIT, 32 * FRACUNIT, false, NULL); FMultiBlockThingsIterator::CheckResult cres; while (it.Next(&cres)) { @@ -2619,8 +2617,8 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) // use the current actor's radius instead of the Arch Vile's default. fixed_t maxdist = corpsehit->GetDefault()->radius + self->radius; - if (abs(corpsehit->Pos().x - cres.position.x) > maxdist || - abs(corpsehit->Pos().y - cres.position.y) > maxdist) + if (abs(corpsehit->_f_Pos().x - cres.position.x) > maxdist || + abs(corpsehit->_f_Pos().y - cres.position.y) > maxdist) continue; // not actually touching // Let's check if there are floors in between the archvile and its target @@ -2640,17 +2638,17 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) if (testsec) { fixed_t zdist1, zdist2; - if (P_Find3DFloor(testsec, corpsehit->Pos(), false, true, zdist1) - != P_Find3DFloor(testsec, self->Pos(), false, true, zdist2)) + if (P_Find3DFloor(testsec, corpsehit->_f_Pos(), false, true, zdist1) + != P_Find3DFloor(testsec, self->_f_Pos(), false, true, zdist2)) { // Not on same floor - if (vilesec == corpsec || abs(zdist1 - self->Z()) > self->height) + if (vilesec == corpsec || abs(zdist1 - self->_f_Z()) > self->height) continue; } } } - corpsehit->vel.x = corpsehit->vel.y = 0; + corpsehit->Vel.X = corpsehit->Vel.Y = 0; // [RH] Check against real height and radius fixed_t oldheight = corpsehit->height; @@ -2659,7 +2657,7 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) corpsehit->flags |= MF_SOLID; corpsehit->height = corpsehit->GetDefault()->height; - bool check = P_CheckPosition(corpsehit, corpsehit->Pos()); + bool check = P_CheckPosition(corpsehit, corpsehit->_f_Pos()); corpsehit->flags = oldflags; corpsehit->radius = oldradius; corpsehit->height = oldheight; @@ -2863,28 +2861,28 @@ void A_Face (AActor *self, AActor *other, angle_t _max_turn, angle_t _max_pitch, // disabled and is so by default. if (max_pitch <= 180.) { - fixedvec2 pos = self->Vec2To(other); + fixedvec2 pos = self->_f_Vec2To(other); DVector2 dist(pos.x, pos.y); // Positioning ala missile spawning, 32 units above foot level - fixed_t source_z = self->Z() + 32*FRACUNIT + self->GetBobOffset(); - fixed_t target_z = other->Z() + 32*FRACUNIT + other->GetBobOffset(); + fixed_t source_z = self->_f_Z() + 32*FRACUNIT + self->GetBobOffset(); + fixed_t target_z = other->_f_Z() + 32*FRACUNIT + other->GetBobOffset(); // If the target z is above the target's head, reposition to the middle of // its body. - if (target_z >= other->Top()) + if (target_z >= other->_f_Top()) { - target_z = other->Z() + (other->height / 2); + target_z = other->_f_Z() + (other->height / 2); } //Note there is no +32*FRACUNIT on purpose. This is for customization sake. //If one doesn't want this behavior, just don't use FAF_BOTTOM. if (flags & FAF_BOTTOM) - target_z = other->Z() + other->GetBobOffset(); + target_z = other->_f_Z() + other->GetBobOffset(); if (flags & FAF_MIDDLE) - target_z = other->Z() + (other->height / 2) + other->GetBobOffset(); + target_z = other->_f_Z() + (other->height / 2) + other->GetBobOffset(); if (flags & FAF_TOP) - target_z = other->Z() + (other->height) + other->GetBobOffset(); + target_z = other->_f_Z() + (other->height) + other->GetBobOffset(); target_z += z_add; @@ -3000,14 +2998,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail) if (t.linetarget == NULL) { // We probably won't hit the target, but aim at it anyway so we don't look stupid. - fixedvec2 pos = self->Vec2To(self->target); + fixedvec2 pos = self->_f_Vec2To(self->target); DVector2 xydiff(pos.x, pos.y); - double zdiff = (self->target->Z() + (self->target->height>>1)) - (self->Z() + (self->height>>1) - self->floorclip); + double zdiff = (self->target->_f_Z() + (self->target->height>>1)) - (self->_f_Z() + (self->height>>1) - self->floorclip); self->Angles.Pitch = -VecToAngle(xydiff.Length(), zdiff); } // Let the aim trail behind the player - self->Angles.Yaw = self->AngleTo(self->target, -self->target->vel.x * 3, -self->target->vel.y * 3); + self->Angles.Yaw = self->AngleTo(self->target, -self->target->_f_velx() * 3, -self->target->_f_vely() * 3); if (self->target->flags & MF_SHADOW && !(self->flags6 & MF6_SEEINVISIBLE)) { @@ -3166,7 +3164,7 @@ AInventory *P_DropItem (AActor *source, PClassActor *type, int dropamount, int c AActor *mo; fixed_t spawnz; - spawnz = source->Z(); + spawnz = source->_f_Z(); if (!(i_compatflags & COMPATF_NOTOSSDROPS)) { int style = sv_dropstyle; @@ -3183,7 +3181,7 @@ AInventory *P_DropItem (AActor *source, PClassActor *type, int dropamount, int c spawnz += source->height / 2; } } - mo = Spawn(type, source->X(), source->Y(), spawnz, ALLOW_REPLACE); + mo = Spawn(type, source->_f_X(), source->_f_Y(), spawnz, ALLOW_REPLACE); if (mo != NULL) { mo->flags |= MF_DROPPED; @@ -3224,14 +3222,14 @@ void P_TossItem (AActor *item) if (style==2) { - item->vel.x += pr_dropitem.Random2(7) << FRACBITS; - item->vel.y += pr_dropitem.Random2(7) << FRACBITS; + item->Vel.X += pr_dropitem.Random2(7); + item->Vel.Y += pr_dropitem.Random2(7); } else { - item->vel.x = pr_dropitem.Random2() << 8; - item->vel.y = pr_dropitem.Random2() << 8; - item->vel.z = FRACUNIT*5 + (pr_dropitem() << 10); + item->Vel.X += pr_dropitem.Random2() / 256.; + item->Vel.Y += pr_dropitem.Random2() / 256.; + item->Vel.Z = 5. + pr_dropitem() / 64.; } } diff --git a/src/p_enemy.h b/src/p_enemy.h index 7535f13a3..e2029104a 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -82,7 +82,7 @@ bool CheckBossDeath (AActor *); int P_Massacre (); bool P_CheckMissileRange (AActor *actor); -#define SKULLSPEED (20*FRACUNIT) -void A_SkullAttack(AActor *self, fixed_t speed); +#define SKULLSPEED (20.) +void A_SkullAttack(AActor *self, double speed); #endif //__P_ENEMY_H__ diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 79fa3868d..da6b36783 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -85,7 +85,7 @@ FName MeansOfDeath; // void P_TouchSpecialThing (AActor *special, AActor *toucher) { - fixed_t delta = special->Z() - toucher->Z(); + fixed_t delta = special->_f_Z() - toucher->_f_Z(); // The pickup is at or above the toucher's feet OR // The pickup is below the toucher. @@ -927,9 +927,9 @@ static inline bool isFakePain(AActor *target, AActor *inflictor, int damage) // Returns the amount of damage actually inflicted upon the target, or -1 if // the damage was cancelled. -int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags, angle_t angle) +int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags, DAngle angle) { - unsigned ang; + DAngle ang; player_t *player = NULL; fixed_t thrust; int temp; @@ -974,7 +974,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, { target->tics = 1; target->flags6 |= MF6_SHATTERING; - target->vel.x = target->vel.y = target->vel.z = 0; + target->Vel.Zero(); } return -1; } @@ -1029,7 +1029,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, } if (target->flags & MF_SKULLFLY) { - target->vel.x = target->vel.y = target->vel.z = 0; + target->Vel.Zero(); } player = target->player; @@ -1160,11 +1160,11 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, // If the origin and target are in exactly the same spot, choose a random direction. // (Most likely cause is from telefragging somebody during spawning because they // haven't moved from their spawn spot at all.) - ang = pr_kickbackdir.GenRand32(); + ang = pr_kickbackdir.GenRand_Real2() * 360.; } else { - ang = origin->__f_AngleTo(target); + ang = origin->AngleTo(target); } // Calculate this as float to avoid overflows so that the @@ -1184,7 +1184,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, // make fall forwards sometimes if ((damage < 40) && (damage > target->health) - && (target->Z() - origin->Z() > 64*FRACUNIT) + && (target->Z() - origin->Z() > 64) && (pr_damagemobj()&1) // [RH] But only if not too fast and not flying && thrust < 10*FRACUNIT @@ -1192,26 +1192,23 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, && (inflictor == NULL || !(inflictor->flags5 & MF5_NOFORWARDFALL)) ) { - ang += ANG180; + ang += 180.; thrust *= 4; } - ang >>= ANGLETOFINESHIFT; if (source && source->player && (flags & DMG_INFLICTOR_IS_PUFF) && source->player->ReadyWeapon != NULL && (source->player->ReadyWeapon->WeaponFlags & WIF_STAFF2_KICKBACK)) { // Staff power level 2 - target->vel.x += FixedMul (10*FRACUNIT, finecosine[ang]); - target->vel.y += FixedMul (10*FRACUNIT, finesine[ang]); + target->Thrust(ang, 10); if (!(target->flags & MF_NOGRAVITY)) { - target->vel.z += 5*FRACUNIT; + target->Vel.Z += 5.; } } else { - target->vel.x += FixedMul (thrust, finecosine[ang]); - target->vel.y += FixedMul (thrust, finesine[ang]); + target->Thrust(ang, FIXED2DBL(thrust)); } } } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 86bd19ee7..8c59eec78 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -168,7 +168,7 @@ FUNC(LS_Polyobj_MoveToSpot) FActorIterator iterator (arg2); AActor *spot = iterator.Next(); if (spot == NULL) return false; - return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->X(), spot->Y(), false); + return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->_f_X(), spot->_f_Y(), false); } FUNC(LS_Polyobj_DoorSwing) @@ -219,7 +219,7 @@ FUNC(LS_Polyobj_OR_MoveToSpot) FActorIterator iterator (arg2); AActor *spot = iterator.Next(); if (spot == NULL) return false; - return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->X(), spot->Y(), true); + return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->_f_X(), spot->_f_Y(), true); } FUNC(LS_Polyobj_Stop) @@ -1101,7 +1101,16 @@ FUNC(LS_Teleport_Line) return EV_SilentLineTeleport (ln, backSide, it, arg1, arg2); } -static void ThrustThingHelper (AActor *it, DAngle angle, int force, INTBOOL nolimit); +static void ThrustThingHelper(AActor *it, DAngle angle, double force, INTBOOL nolimit) +{ + it->VelFromAngle(angle, force); + if (!nolimit) + { + it->Vel.X = clamp(it->Vel.X, -MAXMOVE, MAXMOVE); + it->Vel.Y = clamp(it->Vel.Y, -MAXMOVE, MAXMOVE); + } +} + FUNC(LS_ThrustThing) // ThrustThing (angle, force, nolimit, tid) { @@ -1126,21 +1135,11 @@ FUNC(LS_ThrustThing) return false; } -static void ThrustThingHelper (AActor *it, DAngle angle, int force, INTBOOL nolimit) -{ - it->VelFromAngle(angle, force << FRACBITS); - if (!nolimit) - { - it->vel.x = clamp (it->vel.x, -MAXMOVE, MAXMOVE); - it->vel.y = clamp (it->vel.y, -MAXMOVE, MAXMOVE); - } -} - FUNC(LS_ThrustThingZ) // [BC] // ThrustThingZ (tid, zthrust, down/up, set) { AActor *victim; - fixed_t thrust = arg1*FRACUNIT/4; + double thrust = arg1/4.; // [BC] Up is default if (arg2) @@ -1153,18 +1152,18 @@ FUNC(LS_ThrustThingZ) // [BC] while ( (victim = iterator.Next ()) ) { if (!arg3) - victim->vel.z = thrust; + victim->Vel.Z = thrust; else - victim->vel.z += thrust; + victim->Vel.Z += thrust; } return true; } else if (it) { if (!arg3) - it->vel.z = thrust; + it->Vel.Z = thrust; else - it->vel.z += thrust; + it->Vel.Z += thrust; return true; } return false; @@ -1695,8 +1694,8 @@ FUNC(LS_Thing_Stop) { if (it != NULL) { - it->vel.x = it->vel.y = it->vel.z = 0; - if (it->player != NULL) it->player->vel.x = it->player->vel.y = 0; + it->Vel.Zero(); + if (it->player != NULL) it->player->Vel.Zero(); ok = true; } } @@ -1706,8 +1705,8 @@ FUNC(LS_Thing_Stop) while ( (target = iterator.Next ()) ) { - target->vel.x = target->vel.y = target->vel.z = 0; - if (target->player != NULL) target->player->vel.x = target->player->vel.y = 0; + target->Vel.Zero(); + if (target->player != NULL) target->player->Vel.Zero(); ok = true; } } @@ -3281,12 +3280,12 @@ FUNC(LS_GlassBreak) { glass = Spawn("GlassJunk", x, y, ONFLOORZ, ALLOW_REPLACE); - glass->AddZ(24 * FRACUNIT); + glass->_f_AddZ(24 * FRACUNIT); glass->SetState (glass->SpawnState + (pr_glass() % glass->health)); glass->Angles.Yaw = pr_glass() * (360 / 256.); glass->VelFromAngle(pr_glass() & 3); - glass->vel.z = (pr_glass() & 7) << FRACBITS; + glass->Vel.Z = (pr_glass() & 7); // [RH] Let the shards stick around longer than they did in Strife. glass->tics += pr_glass(); } diff --git a/src/p_local.h b/src/p_local.h index 4dab4ca8c..9eada6863 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -81,7 +81,8 @@ inline int GetSafeBlockY(long long blocky) } //#define GRAVITY FRACUNIT -#define MAXMOVE (30*FRACUNIT) +#define _f_MAXMOVE (30*FRACUNIT) +#define MAXMOVE (30.) #define TALKRANGE (128.) #define USERANGE (64*FRACUNIT) @@ -197,7 +198,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char * type_na bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog); bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog); int P_Thing_Damage (int tid, AActor *whofor0, int amount, FName type); -void P_Thing_SetVelocity(AActor *actor, fixed_t vx, fixed_t vy, fixed_t vz, bool add, bool setbob); +void P_Thing_SetVelocity(AActor *actor, const DVector3 &vec, bool add, bool setbob); void P_RemoveThing(AActor * actor); bool P_Thing_Raise(AActor *thing, AActor *raiser); bool P_Thing_CanRaise(AActor *thing); @@ -337,6 +338,10 @@ inline void P_TraceBleed(int damage, const fixedvec3 &pos, AActor *target, angle P_TraceBleed(damage, pos.x, pos.y, pos.z, target, angle, pitch); } void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch); +inline void P_TraceBleed(int damage, AActor *target, DAngle angle, DAngle pitch) +{ + P_TraceBleed(damage, target, angle.BAMs(), pitch.BAMs()); +} void P_TraceBleed (int damage, AActor *target, AActor *missile); // missile version void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff); // hitscan version void P_TraceBleed (int damage, AActor *target); // random direction version @@ -381,6 +386,14 @@ void P_DelSeclist(msecnode_t *); // phares 3/16/98 msecnode_t* P_DelSecnode(msecnode_t *); void P_CreateSecNodeList(AActor*,fixed_t,fixed_t); // phares 3/14/98 int P_GetMoveFactor(const AActor *mo, int *frictionp); // phares 3/6/98 +inline double P_GetMoveFactor(const AActor *mo, double *frictionp) +{ + int rv, fp; + rv = P_GetMoveFactor(mo, &fp); + *frictionp = FIXED2DBL(fp); + return FIXED2DBL(rv); +} + int P_GetFriction(const AActor *mo, int *frictionfactor); bool Check_Sides(AActor *, int, int); // phares @@ -398,7 +411,7 @@ extern BYTE* rejectmatrix; // for fast sight rejection // P_INTER // void P_TouchSpecialThing (AActor *special, AActor *toucher); -int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags=0, angle_t angle = 0); +int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags=0, DAngle angle = 0.); void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period, FName type); bool P_GiveBody (AActor *actor, int num, int max=0); bool P_PoisonPlayer (player_t *player, AActor *poisoner, AActor *source, int poison); diff --git a/src/p_map.cpp b/src/p_map.cpp index 6df1aa6e9..dcbc1b637 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -320,9 +320,9 @@ void P_FindFloorCeiling(AActor *actor, int flags) FCheckPosition tmf; tmf.thing = actor; - tmf.x = actor->X(); - tmf.y = actor->Y(); - tmf.z = actor->Z(); + tmf.x = actor->_f_X(); + tmf.y = actor->_f_Y(); + tmf.z = actor->_f_Z(); if (flags & FFCF_ONLYSPAWNPOS) { @@ -365,7 +365,7 @@ void P_FindFloorCeiling(AActor *actor, int flags) if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; - bool usetmf = !(flags & FFCF_ONLYSPAWNPOS) || (tmf.abovemidtex && (tmf.floorz <= actor->Z())); + bool usetmf = !(flags & FFCF_ONLYSPAWNPOS) || (tmf.abovemidtex && (tmf.floorz <= actor->_f_Z())); // when actual floor or ceiling are beyond a portal plane we also need to use the result of the blockmap iterator, regardless of the flags being specified. if (usetmf || tmf.floorsector->PortalGroup != actor->Sector->PortalGroup) @@ -430,8 +430,8 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra bool StompAlwaysFrags = ((thing->flags2 & MF2_TELESTOMP) || (level.flags & LEVEL_MONSTERSTELEFRAG) || telefrag) && !(thing->flags7 & MF7_NOTELESTOMP); // P_LineOpening requires the thing's z to be the destination z in order to work. - fixed_t savedz = thing->Z(); - thing->SetZ(z); + fixed_t savedz = thing->_f_Z(); + thing->_f_SetZ(z); sector_t *sector = P_PointInSector(x, y); FPortalGroupArray grouplist; @@ -442,7 +442,7 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra { PIT_FindFloorCeiling(mit, cres, mit.Box(), tmf, 0); } - thing->SetZ(savedz); + thing->_f_SetZ(savedz); if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; @@ -461,7 +461,7 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra continue; fixed_t blockdist = th->radius + tmf.thing->radius; - if (abs(th->X() - cres2.position.x) >= blockdist || abs(th->Y() - cres2.position.y) >= blockdist) + if (abs(th->_f_X() - cres2.position.x) >= blockdist || abs(th->_f_Y() - cres2.position.y) >= blockdist) continue; if ((th->flags2 | tmf.thing->flags2) & MF2_THRUACTORS) @@ -477,8 +477,8 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra { if (!(th->flags3 & thing->flags3 & MF3_DONTOVERLAP)) { - if (z > th->Top() || // overhead - z + thing->height < th->Z()) // underneath + if (z > th->_f_Top() || // overhead + z + thing->height < th->_f_Z()) // underneath continue; } } @@ -558,7 +558,7 @@ void P_PlayerStartStomp(AActor *actor, bool mononly) continue; fixed_t blockdist = th->radius + actor->radius; - if (abs(th->X() - cres.position.x) >= blockdist || abs(th->Y() - cres.position.y) >= blockdist) + if (abs(th->_f_X() - cres.position.x) >= blockdist || abs(th->_f_Y() - cres.position.y) >= blockdist) continue; // only kill monsters and other players @@ -577,26 +577,6 @@ void P_PlayerStartStomp(AActor *actor, bool mononly) } } -//========================================================================== -// -// -// -//========================================================================== - -inline fixed_t secfriction(const sector_t *sec, int plane = sector_t::floor) -{ - if (sec->Flags & SECF_FRICTION) return sec->friction; - fixed_t friction = Terrains[sec->GetTerrain(plane)].Friction; - return friction != 0 ? friction : ORIG_FRICTION; -} - -inline fixed_t secmovefac(const sector_t *sec, int plane = sector_t::floor) -{ - if (sec->Flags & SECF_FRICTION) return sec->movefactor; - fixed_t movefactor = Terrains[sec->GetTerrain(plane)].MoveFactor; - return movefactor != 0 ? movefactor : ORIG_FRICTION_FACTOR; -} - //========================================================================== // // killough 8/28/98: @@ -614,6 +594,7 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) fixed_t newfriction; const msecnode_t *m; sector_t *sec; + fixed_t newmf; if (mo->IsNoClip2()) { @@ -624,29 +605,29 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) friction = FRICTION_FLY; } else if ((!(mo->flags & MF_NOGRAVITY) && mo->waterlevel > 1) || - (mo->waterlevel == 1 && mo->Z() > mo->floorz + 6 * FRACUNIT)) + (mo->waterlevel == 1 && mo->_f_Z() > mo->floorz + 6 * FRACUNIT)) { - friction = secfriction(mo->Sector); - movefactor = secmovefac(mo->Sector) >> 1; + friction = mo->Sector->GetFriction(sector_t::floor, &movefactor); + movefactor >>= 1; - // Check 3D floors -- might be the source of the waterlevel - for (unsigned i = 0; i < mo->Sector->e->XFloor.ffloors.Size(); i++) + // Check 3D floors -- might be the source of the waterlevel + for (unsigned i = 0; i < mo->Sector->e->XFloor.ffloors.Size(); i++) + { + F3DFloor *rover = mo->Sector->e->XFloor.ffloors[i]; + if (!(rover->flags & FF_EXISTS)) continue; + if (!(rover->flags & FF_SWIMMABLE)) continue; + + if (mo->_f_Z() > rover->top.plane->ZatPoint(mo) || + mo->_f_Z() < rover->bottom.plane->ZatPoint(mo)) + continue; + + newfriction = rover->model->GetFriction(rover->top.isceiling, &newmf); + if (newfriction < friction || friction == ORIG_FRICTION) { - F3DFloor *rover = mo->Sector->e->XFloor.ffloors[i]; - if (!(rover->flags & FF_EXISTS)) continue; - if (!(rover->flags & FF_SWIMMABLE)) continue; - - if (mo->Z() > rover->top.plane->ZatPoint(mo) || - mo->Z() < rover->bottom.plane->ZatPoint(mo)) - continue; - - newfriction = secfriction(rover->model, rover->top.isceiling); - if (newfriction < friction || friction == ORIG_FRICTION) - { - friction = newfriction; - movefactor = secmovefac(rover->model, rover->top.isceiling) >> 1; - } + friction = newfriction; + movefactor = newmf >> 1; } + } } else if (var_friction && !(mo->flags & (MF_NOCLIP | MF_NOGRAVITY))) { // When the object is straddling sectors with the same @@ -667,23 +648,23 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) if (rover->flags & FF_SOLID) { // Must be standing on a solid floor - if (mo->Z() != rover->top.plane->ZatPoint(pos)) continue; + if (mo->_f_Z() != rover->top.plane->ZatPoint(pos)) continue; } else if (rover->flags & FF_SWIMMABLE) { // Or on or inside a swimmable floor (e.g. in shallow water) - if (mo->Z() > rover->top.plane->ZatPoint(pos) || - (mo->Top()) < rover->bottom.plane->ZatPoint(pos)) + if (mo->_f_Z() > rover->top.plane->ZatPoint(pos) || + (mo->_f_Top()) < rover->bottom.plane->ZatPoint(pos)) continue; } else continue; - newfriction = secfriction(rover->model, rover->top.isceiling); + newfriction = rover->model->GetFriction(rover->top.isceiling, &newmf); if (newfriction < friction || friction == ORIG_FRICTION) { friction = newfriction; - movefactor = secmovefac(rover->model, rover->top.isceiling); + movefactor = newmf >> 1; } } @@ -692,14 +673,14 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) { continue; } - newfriction = secfriction(sec); + newfriction = sec->GetFriction(sector_t::floor, &newmf); if ((newfriction < friction || friction == ORIG_FRICTION) && - (mo->Z() <= sec->floorplane.ZatPoint(pos) || + (mo->_f_Z() <= sec->floorplane.ZatPoint(pos) || (sec->GetHeightSec() != NULL && - mo->Z() <= sec->heightsec->floorplane.ZatPoint(pos)))) + mo->_f_Z() <= sec->heightsec->floorplane.ZatPoint(pos)))) { friction = newfriction; - movefactor = secmovefac(sec); + movefactor = newmf; } } } @@ -739,11 +720,11 @@ int P_GetMoveFactor(const AActor *mo, int *frictionp) // phares 3/11/98: you start off slowly, then increase as // you get better footing - int velocity = P_AproxDistance(mo->vel.x, mo->vel.y); + double velocity = mo->VelXYToSpeed(); - if (velocity > MORE_FRICTION_VELOCITY << 2) + if (velocity > MORE_FRICTION_VELOCITY * 4) movefactor <<= 3; - else if (velocity > MORE_FRICTION_VELOCITY << 1) + else if (velocity > MORE_FRICTION_VELOCITY * 2) movefactor <<= 2; else if (velocity > MORE_FRICTION_VELOCITY) movefactor <<= 1; @@ -770,14 +751,14 @@ static int LineIsAbove(line_t *line, AActor *actor) { AActor *point = line->frontsector->SkyBoxes[sector_t::floor]; if (point == NULL) return -1; - return point->threshold >= actor->Top(); + return point->threshold >= actor->_f_Top(); } static int LineIsBelow(line_t *line, AActor *actor) { AActor *point = line->frontsector->SkyBoxes[sector_t::ceiling]; if (point == NULL) return -1; - return point->threshold <= actor->Z(); + return point->threshold <= actor->_f_Z(); } // @@ -1048,7 +1029,7 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera // fudge a bit with the portal line so that this gets included in the checks that normally only get run on two-sided lines sector_t *sec = lp->backsector; if (lp->backsector == NULL) lp->backsector = lp->frontsector; - tm.thing->AddZ(zofs); + tm.thing->_f_AddZ(zofs); FBoundingBox pbox(cres.position.x, cres.position.y, tm.thing->radius); FBlockLinesIterator it(pbox); @@ -1105,7 +1086,7 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera if (open.lowfloor - zofs < tm.dropoffz) tm.dropoffz = open.lowfloor - zofs; } - tm.thing->AddZ(-zofs); + tm.thing->_f_AddZ(-zofs); lp->backsector = sec; return ret; @@ -1219,7 +1200,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch return true; // can't hit thing fixed_t blockdist = thing->radius + tm.thing->radius; - if (abs(thing->X() - cres.position.x) >= blockdist || abs(thing->Y() - cres.position.y) >= blockdist) + if (abs(thing->_f_X() - cres.position.x) >= blockdist || abs(thing->_f_Y() - cres.position.y) >= blockdist) return true; if ((thing->flags2 | tm.thing->flags2) & MF2_THRUACTORS) @@ -1229,7 +1210,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch return true; tm.thing->BlockingMobj = thing; - topz = thing->Top(); + topz = thing->_f_Top(); // Both things overlap in x or y direction bool unblocking = false; @@ -1242,7 +1223,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch { // [RH] Let monsters walk on actors as well as floors if ((tm.thing->flags3 & MF3_ISMONSTER) && - topz >= tm.floorz && topz <= tm.thing->Z() + tm.thing->MaxStepHeight) + topz >= tm.floorz && topz <= tm.thing->_f_Z() + tm.thing->MaxStepHeight) { // The commented-out if is an attempt to prevent monsters from walking off a // thing further than they would walk off a ledge. I can't think of an easy @@ -1263,12 +1244,12 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch fixedvec3 oldpos = tm.thing->PosRelative(thing); // Both actors already overlap. To prevent them from remaining stuck allow the move if it // takes them further apart or the move does not change the position (when called from P_ChangeSector.) - if (oldpos.x == thing->X() && oldpos.y == thing->Y()) + if (oldpos.x == thing->_f_X() && oldpos.y == thing->_f_Y()) { unblocking = true; } - else if (abs(thing->X() - oldpos.x) < (thing->radius + tm.thing->radius) && - abs(thing->Y() - oldpos.y) < (thing->radius + tm.thing->radius)) + else if (abs(thing->_f_X() - oldpos.x) < (thing->radius + tm.thing->radius) && + abs(thing->_f_Y() - oldpos.y) < (thing->radius + tm.thing->radius)) { fixed_t newdist = thing->AproxDistance(cres.position.x, cres.position.y); @@ -1277,7 +1258,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch if (newdist > olddist) { // unblock only if there's already a vertical overlap (or both actors are flagged not to overlap) - unblocking = (tm.thing->Top() > thing->Z() && tm.thing->Z() < topz) || (tm.thing->flags3 & thing->flags3 & MF3_DONTOVERLAP); + unblocking = (tm.thing->_f_Top() > thing->_f_Z() && tm.thing->_f_Z() < topz) || (tm.thing->flags3 & thing->flags3 & MF3_DONTOVERLAP); } } } @@ -1296,7 +1277,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch { // Some things prefer not to overlap each other, if possible return unblocking; } - if ((tm.thing->Z() >= topz) || (tm.thing->Top() <= thing->Z())) + if ((tm.thing->_f_Z() >= topz) || (tm.thing->_f_Top() <= thing->_f_Z())) return true; } } @@ -1312,7 +1293,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch // or different species if DONTHARMSPECIES (!(thing->flags6 & MF6_DONTHARMSPECIES) || thing->GetSpecies() != tm.thing->GetSpecies()) && // touches vertically - topz >= tm.thing->Z() && tm.thing->Top() >= thing->Z() && + topz >= tm.thing->_f_Z() && tm.thing->_f_Top() >= thing->_f_Z() && // prevents lost souls from exploding when fired by pain elementals (thing->master != tm.thing && tm.thing->master != thing)) // Difference with MBF: MBF hardcodes the LS/PE check and lets actors of the same species @@ -1359,9 +1340,8 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch if (!(thing->flags2 & MF2_BOSS) && (thing->flags3 & MF3_ISMONSTER) && !(thing->flags3 & MF3_DONTBLAST)) { // ideally this should take the mass factor into account - thing->vel.x += tm.thing->vel.x; - thing->vel.y += tm.thing->vel.y; - if ((thing->vel.x + thing->vel.y) > 3 * FRACUNIT) + thing->Vel += tm.thing->Vel.XY(); + if ((thing->Vel.X + thing->Vel.Y) > 3.) { int newdam; damage = (tm.thing->Mass / 100) + 1; @@ -1415,7 +1395,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch } // Check if it went over / under - if (tm.thing->Z() > thing->Z() + clipheight) + if (tm.thing->_f_Z() > thing->_f_Z() + clipheight) { // Over thing return true; } @@ -1497,8 +1477,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch { // Push thing if (thing->lastpush != tm.PushTime) { - thing->vel.x += FixedMul(tm.thing->vel.x, thing->pushfactor); - thing->vel.y += FixedMul(tm.thing->vel.y, thing->pushfactor); + thing->Vel += tm.thing->Vel.XY() * thing->_pushfactor(); thing->lastpush = tm.PushTime; } } @@ -1528,7 +1507,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch !(tm.thing->flags3 & MF3_BLOODLESSIMPACT) && (pr_checkthing() < 192)) { - P_BloodSplatter(tm.thing->Pos(), thing); + P_BloodSplatter(tm.thing->_f_Pos(), thing); } if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT)) { @@ -1556,8 +1535,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch { // Push thing if (thing->lastpush != tm.PushTime) { - thing->vel.x += FixedMul(tm.thing->vel.x, thing->pushfactor); - thing->vel.y += FixedMul(tm.thing->vel.y, thing->pushfactor); + thing->Vel += tm.thing->Vel.XY() * thing->_pushfactor(); thing->lastpush = tm.PushTime; } } @@ -1570,7 +1548,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch // [RH] The next condition is to compensate for the extra height // that gets added by P_CheckPosition() so that you cannot pick // up things that are above your true height. - && thing->Z() < tm.thing->Top() - tm.thing->MaxStepHeight) + && thing->_f_Z() < tm.thing->_f_Top() - tm.thing->MaxStepHeight) { // Can be picked up by tmthing P_TouchSpecialThing(thing, tm.thing); // can remove thing } @@ -1632,7 +1610,7 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo tm.x = x; tm.y = y; - tm.z = thing->Z(); + tm.z = thing->_f_Z(); newsec = tm.sector = P_PointInSector(x, y); tm.ceilingline = thing->BlockingLine = NULL; @@ -1672,7 +1650,7 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo FBoundingBox box(x, y, thing->radius); FPortalGroupArray pcheck; - FMultiBlockThingsIterator it2(pcheck, x, y, thing->Z(), thing->height, thing->radius, false, newsec); + FMultiBlockThingsIterator it2(pcheck, x, y, thing->_f_Z(), thing->height, thing->radius, false, newsec); FMultiBlockThingsIterator::CheckResult tcres; while ((it2.Next(&tcres))) @@ -1691,17 +1669,17 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo return false; } else if (!BlockingMobj->player && !(thing->flags & (MF_FLOAT | MF_MISSILE | MF_SKULLFLY)) && - BlockingMobj->Top() - thing->Z() <= thing->MaxStepHeight) + BlockingMobj->_f_Top() - thing->_f_Z() <= thing->MaxStepHeight) { if (thingblocker == NULL || - BlockingMobj->Z() > thingblocker->Z()) + BlockingMobj->_f_Z() > thingblocker->_f_Z()) { thingblocker = BlockingMobj; } thing->BlockingMobj = NULL; } else if (thing->player && - thing->Top() - BlockingMobj->Z() <= thing->MaxStepHeight) + thing->_f_Top() - BlockingMobj->_f_Z() <= thing->MaxStepHeight) { if (thingblocker) { // There is something to step up on. Return this thing as @@ -1742,7 +1720,7 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo spechit.Clear(); portalhit.Clear(); - FMultiBlockLinesIterator it(pcheck, x, y, thing->Z(), thing->height, thing->radius, newsec); + FMultiBlockLinesIterator it(pcheck, x, y, thing->_f_Z(), thing->height, thing->radius, newsec); FMultiBlockLinesIterator::CheckResult lcres; fixed_t thingdropoffz = tm.floorz; @@ -1811,10 +1789,10 @@ bool P_TestMobjLocation(AActor *mobj) flags = mobj->flags; mobj->flags &= ~MF_PICKUP; - if (P_CheckPosition(mobj, mobj->X(), mobj->Y())) + if (P_CheckPosition(mobj, mobj->_f_X(), mobj->_f_Y())) { // XY is ok, now check Z mobj->flags = flags; - if ((mobj->Z() < mobj->floorz) || (mobj->Top() > mobj->ceilingz)) + if ((mobj->_f_Z() < mobj->floorz) || (mobj->_f_Top() > mobj->ceilingz)) { // Bad Z return false; } @@ -1838,10 +1816,10 @@ AActor *P_CheckOnmobj(AActor *thing) bool good; AActor *onmobj; - oldz = thing->Z(); + oldz = thing->_f_Z(); P_FakeZMovement(thing); good = P_TestMobjZ(thing, false, &onmobj); - thing->SetZ(oldz); + thing->_f_SetZ(oldz); return good ? NULL : onmobj; } @@ -1870,7 +1848,7 @@ bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) AActor *thing = cres.thing; fixed_t blockdist = thing->radius + actor->radius; - if (abs(thing->X() - cres.position.x) >= blockdist || abs(thing->Y() - cres.position.y) >= blockdist) + if (abs(thing->_f_X() - cres.position.x) >= blockdist || abs(thing->_f_Y() - cres.position.y) >= blockdist) { continue; } @@ -1915,7 +1893,7 @@ bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) { // under thing continue; } - else if (!quick && onmobj != NULL && thing->Top() < onmobj->Top()) + else if (!quick && onmobj != NULL && thing->_f_Top() < onmobj->_f_Top()) { // something higher is in the way continue; } @@ -1939,35 +1917,35 @@ void P_FakeZMovement(AActor *mo) // // adjust height // - mo->AddZ(mo->vel.z); + mo->_f_AddZ(mo->_f_velz()); if ((mo->flags&MF_FLOAT) && mo->target) { // float down towards target if too close if (!(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT)) { fixed_t dist = mo->AproxDistance(mo->target); - fixed_t delta = (mo->target->Z() + (mo->height >> 1)) - mo->Z(); + fixed_t delta = (mo->target->_f_Z() + (mo->height >> 1)) - mo->_f_Z(); if (delta < 0 && dist < -(delta * 3)) - mo->AddZ(-mo->FloatSpeed); + mo->_f_AddZ(-mo->_f_floatspeed()); else if (delta > 0 && dist < (delta * 3)) - mo->AddZ(mo->FloatSpeed); + mo->_f_AddZ(mo->_f_floatspeed()); } } - if (mo->player && mo->flags&MF_NOGRAVITY && (mo->Z() > mo->floorz) && !mo->IsNoClip2()) + if (mo->player && mo->flags&MF_NOGRAVITY && (mo->_f_Z() > mo->floorz) && !mo->IsNoClip2()) { - mo->AddZ(finesine[(FINEANGLES / 80 * level.maptime)&FINEMASK] / 8); + mo->_f_AddZ(finesine[(FINEANGLES / 80 * level.maptime)&FINEMASK] / 8); } // // clip movement // - if (mo->Z() <= mo->floorz) + if (mo->_f_Z() <= mo->floorz) { // hit the floor - mo->SetZ(mo->floorz); + mo->_f_SetZ(mo->floorz); } - if (mo->Top() > mo->ceilingz) + if (mo->_f_Top() > mo->ceilingz) { // hit the ceiling - mo->SetZ(mo->ceilingz - mo->height); + mo->_f_SetZ(mo->ceilingz - mo->height); } } @@ -1989,8 +1967,8 @@ static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, fixedvec2 fixed_t fzb = line->frontsector->floorplane.ZatPoint(*posforwindowcheck); fixed_t bzt = line->backsector->ceilingplane.ZatPoint(*posforwindowcheck); fixed_t bzb = line->backsector->floorplane.ZatPoint(*posforwindowcheck); - if (fzt >= mobj->Top() && bzt >= mobj->Top() && - fzb <= mobj->Z() && bzb <= mobj->Z()) + if (fzt >= mobj->_f_Top() && bzt >= mobj->_f_Top() && + fzb <= mobj->_f_Z() && bzb <= mobj->_f_Z()) { // we must also check if some 3D floor in the backsector may be blocking for (unsigned int i = 0; ibacksector->e->XFloor.ffloors.Size(); i++) @@ -2002,7 +1980,7 @@ static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, fixedvec2 fixed_t ff_bottom = rover->bottom.plane->ZatPoint(*posforwindowcheck); fixed_t ff_top = rover->top.plane->ZatPoint(*posforwindowcheck); - if (ff_bottom < mobj->Top() && ff_top > mobj->Z()) + if (ff_bottom < mobj->_f_Top() && ff_top > mobj->_f_Z()) { goto isblocking; } @@ -2054,10 +2032,10 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, sector_t* newsec; tm.floatok = false; - oldz = thing->Z(); + oldz = thing->_f_Z(); if (onfloor) { - thing->SetZ(onfloor->ZatPoint(x, y)); + thing->_f_SetZ(onfloor->ZatPoint(x, y)); } thing->flags6 |= MF6_INTRYMOVE; if (!P_CheckPosition(thing, x, y, tm)) @@ -2074,16 +2052,16 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { goto pushline; } - else if (BlockingMobj->Top() - thing->Z() > thing->MaxStepHeight - || (BlockingMobj->Sector->ceilingplane.ZatPoint(x, y) - (BlockingMobj->Top()) < thing->height) - || (tm.ceilingz - (BlockingMobj->Top()) < thing->height)) + else if (BlockingMobj->_f_Top() - thing->_f_Z() > thing->MaxStepHeight + || (BlockingMobj->Sector->ceilingplane.ZatPoint(x, y) - (BlockingMobj->_f_Top()) < thing->height) + || (tm.ceilingz - (BlockingMobj->_f_Top()) < thing->height)) { goto pushline; } } if (!(tm.thing->flags2 & MF2_PASSMOBJ) || (i_compatflags & COMPATF_NO_PASSMOBJ)) { - thing->SetZ(oldz); + thing->_f_SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2091,16 +2069,16 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (thing->flags3 & MF3_FLOORHUGGER) { - thing->SetZ(tm.floorz); + thing->_f_SetZ(tm.floorz); } else if (thing->flags3 & MF3_CEILINGHUGGER) { - thing->SetZ(tm.ceilingz - thing->height); + thing->_f_SetZ(tm.ceilingz - thing->height); } if (onfloor && tm.floorsector == thing->floorsector) { - thing->SetZ(tm.floorz); + thing->_f_SetZ(tm.floorz); } if (!(thing->flags & MF_NOCLIP)) { @@ -2112,7 +2090,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, tm.floatok = true; if (!(thing->flags & MF_TELEPORT) - && tm.ceilingz - thing->Z() < thing->height + && tm.ceilingz - thing->_f_Z() < thing->height && !(thing->flags3 & MF3_CEILINGHUGGER) && (!(thing->flags2 & MF2_FLY) || !(thing->flags & MF_NOGRAVITY))) { @@ -2121,49 +2099,49 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (thing->flags2 & MF2_FLY && thing->flags & MF_NOGRAVITY) { #if 1 - if (thing->Top() > tm.ceilingz) + if (thing->_f_Top() > tm.ceilingz) goto pushline; #else // When flying, slide up or down blocking lines until the actor // is not blocked. - if (thing->Top() > tm.ceilingz) + if (thing->_f_Top() > tm.ceilingz) { - thing->vel.z = -8 * FRACUNIT; + thing->_f_velz() = -8 * FRACUNIT; goto pushline; } - else if (thing->Z() < tm.floorz && tm.floorz - tm.dropoffz > thing->MaxDropOffHeight) + else if (thing->_f_Z() < tm.floorz && tm.floorz - tm.dropoffz > thing->MaxDropOffHeight) { - thing->vel.z = 8 * FRACUNIT; + thing->_f_velz() = 8 * FRACUNIT; goto pushline; } #endif } if (!(thing->flags & MF_TELEPORT) && !(thing->flags3 & MF3_FLOORHUGGER)) { - if ((thing->flags & MF_MISSILE) && !(thing->flags6 & MF6_STEPMISSILE) && tm.floorz > thing->Z()) + if ((thing->flags & MF_MISSILE) && !(thing->flags6 & MF6_STEPMISSILE) && tm.floorz > thing->_f_Z()) { // [RH] Don't let normal missiles climb steps goto pushline; } - if (tm.floorz - thing->Z() > thing->MaxStepHeight) + if (tm.floorz - thing->_f_Z() > thing->MaxStepHeight) { // too big a step up goto pushline; } - else if (thing->Z() < tm.floorz) + else if (thing->_f_Z() < tm.floorz) { // [RH] Check to make sure there's nothing in the way for the step up - fixed_t savedz = thing->Z(); + fixed_t savedz = thing->_f_Z(); bool good; - thing->SetZ(tm.floorz); + thing->_f_SetZ(tm.floorz); good = P_TestMobjZ(thing); - thing->SetZ(savedz); + thing->_f_SetZ(savedz); if (!good) { goto pushline; } if (thing->flags6 & MF6_STEPMISSILE) { - thing->SetZ(tm.floorz); + thing->_f_SetZ(tm.floorz); // If moving down, cancel vertical component of the velocity - if (thing->vel.z < 0) + if (thing->_f_velz() < 0) { // If it's a bouncer, let it bounce off its new floor, too. if (thing->BounceFlags & BOUNCE_Floors) @@ -2172,7 +2150,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } else { - thing->vel.z = 0; + thing->Vel.Z = 0; } } } @@ -2187,7 +2165,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } if (dropoff == 2 && // large jump down (e.g. dogs) - (tm.floorz - tm.dropoffz > 128 * FRACUNIT || thing->target == NULL || thing->target->Z() >tm.dropoffz)) + (tm.floorz - tm.dropoffz > 128 * FRACUNIT || thing->target == NULL || thing->target->_f_Z() >tm.dropoffz)) { dropoff = false; } @@ -2203,14 +2181,14 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // This is so that it does not walk off of things onto a drop off. if (thing->flags2 & MF2_ONMOBJ) { - floorz = MAX(thing->Z(), tm.floorz); + floorz = MAX(thing->_f_Z(), tm.floorz); } if (floorz - tm.dropoffz > thing->MaxDropOffHeight && !(thing->flags2 & MF2_BLASTED) && !missileCheck) { // Can't move over a dropoff unless it's been blasted // [GZ] Or missile-spawned - thing->SetZ(oldz); + thing->_f_SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2229,9 +2207,9 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } if (thing->flags2 & MF2_CANTLEAVEFLOORPIC && (tm.floorpic != thing->floorpic - || tm.floorz - thing->Z() != 0)) + || tm.floorz - thing->_f_Z() != 0)) { // must stay within a sector of a certain floor type - thing->SetZ(oldz); + thing->_f_SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2244,9 +2222,8 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { thing->player->Bot->prev = thing->player->Bot->dest; thing->player->Bot->dest = NULL; - thing->vel.x = 0; - thing->vel.y = 0; - thing->SetZ(oldz); + thing->Vel.X = thing->Vel.Y = 0; + thing->_f_SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2273,7 +2250,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // Borrowed from MBF: if (thing->BounceFlags & BOUNCE_MBF && // killough 8/13/98 !(thing->flags & (MF_MISSILE | MF_NOGRAVITY)) && - !thing->IsSentient() && tm.floorz - thing->Z() > 16 * FRACUNIT) + !thing->IsSentient() && tm.floorz - thing->_f_Z() > 16 * FRACUNIT) { // too big a step up for MBF bouncers under gravity thing->flags6 &= ~MF6_INTRYMOVE; return false; @@ -2331,8 +2308,8 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } else if (!portalcrossed) { - fixedvec3 pos = { tm.x, tm.y, thing->Z() }; - fixedvec3 oldthingpos = thing->Pos(); + fixedvec3 pos = { tm.x, tm.y, thing->_f_Z() }; + fixedvec3 oldthingpos = thing->_f_Pos(); fixedvec2 thingpos = oldthingpos; P_TranslatePortalXY(ld, pos.x, pos.y); @@ -2347,7 +2324,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } thing->UnlinkFromWorld(); thing->SetXYZ(pos); - P_TranslatePortalVXVY(ld, thing->vel.x, thing->vel.y); + P_TranslatePortalVXVY(ld, thing->Vel.X, thing->Vel.Y); P_TranslatePortalAngle(ld, thing->Angles.Yaw); thing->LinkToWorld(); P_FindFloorCeiling(thing); @@ -2391,7 +2368,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // the move is ok, so link the thing into its new position thing->UnlinkFromWorld(); - oldpos = thing->Pos(); + oldpos = thing->_f_Pos(); oldsector = thing->Sector; thing->floorz = tm.floorz; thing->ceilingz = tm.ceilingz; @@ -2415,7 +2392,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (!(thing->flags & (MF_TELEPORT | MF_NOCLIP))) { spechit_t spec; - fixedvec3 lastpos = thing->Pos(); + fixedvec3 lastpos = thing->_f_Pos(); while (spechit.Pop(spec)) { line_t *ld = spec.line; @@ -2426,7 +2403,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // we use the thing's actual position, including all the side effects of the original. // If some portal transition has to be considered here, we cannot do that and use the reference position stored with the spechit. bool posisoriginal = (spec.refpos.x == lastpos.x && spec.refpos.y == lastpos.y); - side = posisoriginal? P_PointOnLineSide(thing->X(), thing->Y(), ld) : P_PointOnLineSide(spec.refpos.x, spec.refpos.y, ld); + side = posisoriginal? P_PointOnLineSide(thing->_f_X(), thing->_f_Y(), ld) : P_PointOnLineSide(spec.refpos.x, spec.refpos.y, ld); oldside = P_PointOnLineSide(spec.oldrefpos.x, spec.oldrefpos.y, ld); if (side != oldside && ld->special && !(thing->flags6 & MF6_NOTRIGGER)) { @@ -2472,7 +2449,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (newsec->heightsec && oldsec->heightsec && newsec->SecActTarget) { const sector_t *hs = newsec->heightsec; - fixed_t eyez = thing->Z() + viewheight; + fixed_t eyez = thing->_f_Z() + viewheight; fixed_t fakez = hs->floorplane.ZatPoint(x, y); if (!oldAboveFakeFloor && eyez > fakez) @@ -2512,7 +2489,7 @@ pushline: return false; } - thing->SetZ(oldz); + thing->_f_SetZ(oldz); if (!(thing->flags&(MF_TELEPORT | MF_NOCLIP))) { int numSpecHitTemp; @@ -2553,7 +2530,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) { FCheckPosition tm; - fixed_t newz = thing->Z(); + fixed_t newz = thing->_f_Z(); if (!P_CheckPosition(thing, x, y, tm)) { @@ -2585,7 +2562,7 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) } if (thing->flags2 & MF2_FLY && thing->flags & MF_NOGRAVITY) { - if (thing->Top() > tm.ceilingz) + if (thing->_f_Top() > tm.ceilingz) return false; } if (!(thing->flags & MF_TELEPORT) && !(thing->flags3 & MF3_FLOORHUGGER)) @@ -2600,10 +2577,10 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) } else if (newz < tm.floorz) { // [RH] Check to make sure there's nothing in the way for the step up - fixed_t savedz = thing->Z(); - thing->SetZ(newz = tm.floorz); + fixed_t savedz = thing->_f_Z(); + thing->_f_SetZ(newz = tm.floorz); bool good = P_TestMobjZ(thing); - thing->SetZ(savedz); + thing->_f_SetZ(savedz); if (!good) { return false; @@ -2684,7 +2661,7 @@ void FSlide::HitSlideLine(line_t* ld) icyfloor = (P_AproxDistance(tmxmove, tmymove) > 4 * FRACUNIT) && var_friction && // killough 8/28/98: calc friction on demand - slidemo->Z() <= slidemo->floorz && + slidemo->_f_Z() <= slidemo->floorz && P_GetFriction(slidemo, NULL) > ORIG_FRICTION; if (ld->dx == 0) @@ -2856,19 +2833,19 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t if (open.range < slidemo->height) goto isblocking; // doesn't fit - if (open.top - slidemo->Z() < slidemo->height) + if (open.top - slidemo->_f_Z() < slidemo->height) goto isblocking; // mobj is too high - if (open.bottom - slidemo->Z() > slidemo->MaxStepHeight) + if (open.bottom - slidemo->_f_Z() > slidemo->MaxStepHeight) { goto isblocking; // too big a step up } - else if (slidemo->Z() < open.bottom) + else if (slidemo->_f_Z() < open.bottom) { // [RH] Check to make sure there's nothing in the way for the step up - fixed_t savedz = slidemo->Z(); - slidemo->SetZ(open.bottom); + fixed_t savedz = slidemo->_f_Z(); + slidemo->_f_SetZ(open.bottom); bool good = P_TestMobjZ(slidemo); - slidemo->SetZ(savedz); + slidemo->_f_SetZ(savedz); if (!good) { goto isblocking; @@ -2929,24 +2906,24 @@ retry: // trace along the three leading corners if (tryx > 0) { - leadx = mo->X() + mo->radius; - trailx = mo->X() - mo->radius; + leadx = mo->_f_X() + mo->radius; + trailx = mo->_f_X() - mo->radius; } else { - leadx = mo->X() - mo->radius; - trailx = mo->X() + mo->radius; + leadx = mo->_f_X() - mo->radius; + trailx = mo->_f_X() + mo->radius; } if (tryy > 0) { - leady = mo->Y() + mo->radius; - traily = mo->Y() - mo->radius; + leady = mo->_f_Y() + mo->radius; + traily = mo->_f_Y() - mo->radius; } else { - leady = mo->Y() - mo->radius; - traily = mo->Y() + mo->radius; + leady = mo->_f_Y() - mo->radius; + traily = mo->_f_Y() + mo->radius; } bestslidefrac = FRACUNIT + 1; @@ -2963,11 +2940,11 @@ retry: // killough 3/15/98: Allow objects to drop off ledges xmove = 0, ymove = tryy; walkplane = P_CheckSlopeWalk(mo, xmove, ymove); - if (!P_TryMove(mo, mo->X() + xmove, mo->Y() + ymove, true, walkplane)) + if (!P_TryMove(mo, mo->_f_X() + xmove, mo->_f_Y() + ymove, true, walkplane)) { xmove = tryx, ymove = 0; walkplane = P_CheckSlopeWalk(mo, xmove, ymove); - P_TryMove(mo, mo->X() + xmove, mo->Y() + ymove, true, walkplane); + P_TryMove(mo, mo->_f_X() + xmove, mo->_f_Y() + ymove, true, walkplane); } return; } @@ -2980,14 +2957,14 @@ retry: newy = FixedMul(tryy, bestslidefrac); // [BL] We need to abandon this function if we end up going through a teleporter - const fixed_t startvelx = mo->vel.x; - const fixed_t startvely = mo->vel.y; + const fixed_t startvelx = mo->_f_velx(); + const fixed_t startvely = mo->_f_vely(); // killough 3/15/98: Allow objects to drop off ledges - if (!P_TryMove(mo, mo->X() + newx, mo->Y() + newy, true)) + if (!P_TryMove(mo, mo->_f_X() + newx, mo->_f_Y() + newy, true)) goto stairstep; - if (mo->vel.x != startvelx || mo->vel.y != startvely) + if (mo->_f_velx() != startvelx || mo->_f_vely() != startvely) return; } @@ -3003,22 +2980,22 @@ retry: HitSlideLine(bestslideline); // clip the moves - mo->vel.x = tmxmove * numsteps; - mo->vel.y = tmymove * numsteps; + mo->Vel.X = FIXED2DBL(tmxmove * numsteps); + mo->Vel.Y = FIXED2DBL(tmymove * numsteps); // killough 10/98: affect the bobbing the same way (but not voodoo dolls) if (mo->player && mo->player->mo == mo) { - if (abs(mo->player->vel.x) > abs(mo->vel.x)) - mo->player->vel.x = mo->vel.x; - if (abs(mo->player->vel.y) > abs(mo->vel.y)) - mo->player->vel.y = mo->vel.y; + if (fabs(mo->player->Vel.X) > fabs(mo->Vel.X)) + mo->player->Vel.X = mo->Vel.X; + if (fabs(mo->player->Vel.Y) > fabs(mo->Vel.Y)) + mo->player->Vel.Y = mo->Vel.Y; } walkplane = P_CheckSlopeWalk(mo, tmxmove, tmymove); // killough 3/15/98: Allow objects to drop off ledges - if (!P_TryMove(mo, mo->X() + tmxmove, mo->Y() + tmymove, true, walkplane)) + if (!P_TryMove(mo, mo->_f_X() + tmxmove, mo->_f_Y() + tmymove, true, walkplane)) { goto retry; } @@ -3055,7 +3032,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov fixed_t thisplanez = rover->top.plane->ZatPoint(pos); - if (thisplanez>planezhere && thisplanez <= actor->Z() + actor->MaxStepHeight) + if (thisplanez>planezhere && thisplanez <= actor->_f_Z() + actor->MaxStepHeight) { copyplane = *rover->top.plane; if (copyplane.c<0) copyplane.FlipVert(); @@ -3073,7 +3050,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov fixed_t thisplanez = rover->top.plane->ZatPoint(actor); - if (thisplanez>planezhere && thisplanez <= actor->Z() + actor->MaxStepHeight) + if (thisplanez>planezhere && thisplanez <= actor->_f_Z() + actor->MaxStepHeight) { copyplane = *rover->top.plane; if (copyplane.c<0) copyplane.FlipVert(); @@ -3090,7 +3067,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov return NULL; } - if (actor->Z() - planezhere > FRACUNIT) + if (actor->_f_Z() - planezhere > FRACUNIT) { // not on floor return NULL; } @@ -3100,9 +3077,9 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov fixed_t destx, desty; fixed_t t; - destx = actor->X() + xmove; - desty = actor->Y() + ymove; - t = TMulScale16(plane->a, destx, plane->b, desty, plane->c, actor->Z()) + plane->d; + destx = actor->_f_X() + xmove; + desty = actor->_f_Y() + ymove; + t = TMulScale16(plane->a, destx, plane->b, desty, plane->c, actor->_f_Z()) + plane->d; if (t < 0) { // Desired location is behind (below) the plane // (i.e. Walking up the plane) @@ -3128,7 +3105,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov pos.x += xmove; pos.y += ymove; - if (sec->floorplane.ZatPoint(pos) >= actor->Z() - actor->MaxStepHeight) + if (sec->floorplane.ZatPoint(pos) >= actor->_f_Z() - actor->MaxStepHeight) { dopush = false; break; @@ -3138,8 +3115,10 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov } if (dopush) { - xmove = actor->vel.x = plane->a * 2; - ymove = actor->vel.y = plane->b * 2; + xmove = plane->a * 2; + ymove = plane->b * 2; + actor->Vel.X = FIXED2DBL(xmove); + actor->Vel.Y = FIXED2DBL(ymove); } return (actor->floorsector == actor->Sector) ? plane : NULL; } @@ -3148,19 +3127,19 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov // so that it lies on the plane's surface destx -= FixedMul(plane->a, t); desty -= FixedMul(plane->b, t); - xmove = destx - actor->X(); - ymove = desty - actor->Y(); + xmove = destx - actor->_f_X(); + ymove = desty - actor->_f_Y(); return (actor->floorsector == actor->Sector) ? plane : NULL; } else if (t > 0) { // Desired location is in front of (above) the plane - if (planezhere == actor->Z()) + if (planezhere == actor->_f_Z()) { // Actor's current spot is on/in the plane, so walk down it // Same principle as walking up, except reversed destx += FixedMul(plane->a, t); desty += FixedMul(plane->b, t); - xmove = destx - actor->X(); - ymove = desty - actor->Y(); + xmove = destx - actor->_f_X(); + ymove = desty - actor->_f_Y(); return (actor->floorsector == actor->Sector) ? plane : NULL; } } @@ -3199,7 +3178,7 @@ bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_ } if (!(li->flags&ML_TWOSIDED) || !li->backsector) { - if (P_PointOnLineSide(slidemo->X(), slidemo->Y(), li)) + if (P_PointOnLineSide(slidemo->_f_X(), slidemo->_f_Y(), li)) continue; // don't hit the back side goto bounceblocking; } @@ -3209,10 +3188,10 @@ bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_ if (open.range < slidemo->height) goto bounceblocking; // doesn't fit - if (open.top - slidemo->Z() < slidemo->height) + if (open.top - slidemo->_f_Z() < slidemo->height) goto bounceblocking; // mobj is too high - if (open.bottom > slidemo->Z()) + if (open.bottom > slidemo->_f_Z()) goto bounceblocking; // mobj is too low continue; // this line doesn't block movement @@ -3254,28 +3233,28 @@ bool FSlide::BounceWall(AActor *mo) // // trace along the three leading corners // - if (mo->vel.x > 0) + if (mo->Vel.X > 0) { - leadx = mo->X() + mo->radius; + leadx = mo->_f_X() + mo->radius; } else { - leadx = mo->X() - mo->radius; + leadx = mo->_f_X() - mo->radius; } - if (mo->vel.y > 0) + if (mo->Vel.Y > 0) { - leady = mo->Y() + mo->radius; + leady = mo->_f_Y() + mo->radius; } else { - leady = mo->Y() - mo->radius; + leady = mo->_f_Y() - mo->radius; } bestslidefrac = FRACUNIT + 1; bestslideline = mo->BlockingLine; - if (BounceTraverse(leadx, leady, leadx + mo->vel.x, leady + mo->vel.y) && mo->BlockingLine == NULL) + if (BounceTraverse(leadx, leady, leadx + mo->_f_velx(), leady + mo->_f_vely()) && mo->BlockingLine == NULL) { // Could not find a wall, so bounce off the floor/ceiling instead. - fixed_t floordist = mo->Z() - mo->floorz; - fixed_t ceildist = mo->ceilingz - mo->Z(); + fixed_t floordist = mo->_f_Z() - mo->floorz; + fixed_t ceildist = mo->ceilingz - mo->_f_Z(); if (floordist <= ceildist) { mo->FloorBounceMissile(mo->Sector->floorplane); @@ -3306,22 +3285,22 @@ bool FSlide::BounceWall(AActor *mo) return true; } - side = P_PointOnLineSide(mo->X(), mo->Y(), line); + side = P_PointOnLineSide(mo->_f_X(), mo->_f_Y(), line); lineangle = R_PointToAngle2(0, 0, line->dx, line->dy); if (side == 1) { lineangle += ANG180; } - moveangle = R_PointToAngle2(0, 0, mo->vel.x, mo->vel.y); + moveangle = R_PointToAngle2(0, 0, mo->_f_velx(), mo->_f_vely()); deltaangle = (2 * lineangle) - moveangle; mo->Angles.Yaw = ANGLE2DBL(deltaangle); deltaangle >>= ANGLETOFINESHIFT; - movelen = fixed_t(g_sqrt(double(mo->vel.x)*mo->vel.x + double(mo->vel.y)*mo->vel.y)); + movelen = fixed_t(g_sqrt(double(mo->_f_velx())*mo->_f_velx() + double(mo->_f_vely())*mo->_f_vely())); movelen = FixedMul(movelen, mo->wallbouncefactor); - FBoundingBox box(mo->X(), mo->Y(), mo->radius); + FBoundingBox box(mo->_f_X(), mo->_f_Y(), mo->radius); if (box.BoxOnLineSide(line) == -1) { fixedvec3 pos = mo->Vec3Offset( @@ -3334,8 +3313,8 @@ bool FSlide::BounceWall(AActor *mo) { movelen = 2 * FRACUNIT; } - mo->vel.x = FixedMul(movelen, finecosine[deltaangle]); - mo->vel.y = FixedMul(movelen, finesine[deltaangle]); + mo->Vel.X = FIXED2DBL(FixedMul(movelen, finecosine[deltaangle])); + mo->Vel.Y = FIXED2DBL(FixedMul(movelen, finesine[deltaangle])); if (mo->BounceFlags & BOUNCE_UseBounceState) { FState *bouncestate = mo->FindState(NAME_Bounce, NAME_Wall); @@ -3378,10 +3357,8 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop) if (!ontop) { - fixed_t speed; DAngle angle = BlockingMobj->AngleTo(mo) + ((pr_bounce() % 16) - 8); - speed = P_AproxDistance(mo->vel.x, mo->vel.y); - speed = FixedMul(speed, mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent + double speed = mo->VelXYToSpeed() * FIXED2DBL(mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent mo->Angles.Yaw = ANGLE2DBL(angle); mo->VelFromAngle(speed); mo->PlayBounceSound(true); @@ -3404,11 +3381,11 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop) } else { - fixed_t dot = mo->vel.z; + double dot = mo->Vel.Z; if (mo->BounceFlags & (BOUNCE_HereticType | BOUNCE_MBF)) { - mo->vel.z -= MulScale15(FRACUNIT, dot); + mo->Vel.Z -= 2. / dot; if (!(mo->BounceFlags & BOUNCE_MBF)) // Heretic projectiles die, MBF projectiles don't. { mo->flags |= MF_INBOUNCE; @@ -3418,24 +3395,24 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop) } else { - mo->vel.z = FixedMul(mo->vel.z, mo->bouncefactor); + mo->Vel.Z *= mo->_bouncefactor(); } } else // Don't run through this for MBF-style bounces { // The reflected velocity keeps only about 70% of its original speed - mo->vel.z = FixedMul(mo->vel.z - MulScale15(FRACUNIT, dot), mo->bouncefactor); + mo->Vel.Z = (mo->Vel.Z - 2. / dot) * mo->_bouncefactor(); } mo->PlayBounceSound(true); if (mo->BounceFlags & BOUNCE_MBF) // Bring it to rest below a certain speed { - if (abs(mo->vel.z) < (fixed_t)(mo->Mass * mo->GetGravity() / 64)) - mo->vel.z = 0; + if (fabs(mo->Vel.Z) < mo->Mass * mo->GetGravity() / 64) + mo->Vel.Z = 0; } else if (mo->BounceFlags & (BOUNCE_AutoOff | BOUNCE_AutoOffFloorOnly)) { - if (!(mo->flags & MF_NOGRAVITY) && (mo->vel.z < 3 * FRACUNIT)) + if (!(mo->flags & MF_NOGRAVITY) && (mo->Vel.Z < 3.)) mo->BounceFlags &= ~BOUNCE_TypeMask; } } @@ -3531,7 +3508,7 @@ struct aim_t { res.linetarget = th; res.pitch = pitch; - res.angleFromSource = VecToAngle(th->X() - startpos.x, th->Y() - startpos.y); + res.angleFromSource = VecToAngle(th->_f_X() - startpos.x, th->_f_Y() - startpos.y); res.unlinked = unlinked; res.frac = frac; } @@ -3937,12 +3914,12 @@ struct aim_t // check angles to see if the thing can be aimed at - thingtoppitch = -(int)R_PointToAngle2(0, shootz, dist, th->Z() + th->height); + thingtoppitch = -(int)R_PointToAngle2(0, shootz, dist, th->_f_Z() + th->height); if (thingtoppitch > bottompitch) continue; // shot over the thing - thingbottompitch = -(int)R_PointToAngle2(0, shootz, dist, th->Z()); + thingbottompitch = -(int)R_PointToAngle2(0, shootz, dist, th->_f_Z()); if (thingbottompitch < toppitch) continue; // shot under the thing @@ -4006,7 +3983,7 @@ struct aim_t { // friends don't aim at friends (except players), at least not first if (aimdebug) - Printf("Hit friend %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X() / 65536., th->Y() / 65536., th->Z() / 65536.); + Printf("Hit friend %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X(), th->Y(), th->Z()); SetResult(thing_friend, in->frac, th, thingpitch); } } @@ -4016,14 +3993,14 @@ struct aim_t { // don't autoaim at barrels and other shootable stuff unless no monsters have been found if (aimdebug) - Printf("Hit other %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X() / 65536., th->Y() / 65536., th->Z() / 65536.); + Printf("Hit other %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X(), th->Y(), th->Z()); SetResult(thing_other, in->frac, th, thingpitch); } } else { if (aimdebug) - Printf("Hit target %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X() / 65536., th->Y() / 65536., th->Z() / 65536.); + Printf("Hit target %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X(), th->Y(), th->Z()); SetResult(linetarget, in->frac, th, thingpitch); return; } @@ -4031,7 +4008,7 @@ struct aim_t else { if (aimdebug) - Printf("Hit target %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X() / 65536., th->Y() / 65536., th->Z() / 65536.); + Printf("Hit target %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X(), th->Y(), th->Z()); SetResult(linetarget, in->frac, th, thingpitch); return; } @@ -4048,10 +4025,10 @@ struct aim_t DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLineTarget *pLineTarget, DAngle vrange, int flags, AActor *target, AActor *friender) { - fixed_t shootz = t1->Z() + (t1->height >> 1) - t1->floorclip; + fixed_t shootz = t1->_f_Z() + (t1->height >> 1) - t1->floorclip; if (t1->player != NULL) { - shootz += FixedMul(t1->player->mo->AttackZOffset, t1->player->crouchfactor); + shootz += fixed_t(t1->player->mo->AttackZOffset * t1->player->crouchfactor); } else { @@ -4090,7 +4067,7 @@ DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLin aim.shootthing = t1; aim.friender = (friender == NULL) ? t1 : friender; aim.aimdir = aim_t::aim_up | aim_t::aim_down; - aim.startpos = t1->Pos(); + aim.startpos = t1->_f_Pos(); aim.aimtrace = Vec2Angle(FLOAT2FIXED(distance), angle); aim.limitz = aim.shootz = shootz; aim.toppitch = (t1->Angles.Pitch - vrange).BAMs(); @@ -4193,10 +4170,10 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, vy = FLOAT2FIXED(pc * angle.Sin()); vz = FLOAT2FIXED(-pitch.Sin()); - shootz = t1->Z() - t1->floorclip + (t1->height >> 1); + shootz = t1->_f_Z() - t1->floorclip + (t1->height >> 1); if (t1->player != NULL) { - shootz += FixedMul(t1->player->mo->AttackZOffset, t1->player->crouchfactor); + shootz += fixed_t(t1->player->mo->AttackZOffset * t1->player->crouchfactor); if (damageType == NAME_Melee || damageType == NAME_Hitscan) { // this is coming from a weapon attack function which needs to transfer information to the obituary code, @@ -4231,7 +4208,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, if (puffDefaults != NULL && puffDefaults->flags6 & MF6_NOTRIGGER) tflags = TRACE_NoSky; else tflags = TRACE_NoSky | TRACE_Impact; - if (!Trace(t1->X(), t1->Y(), shootz, t1->Sector, vx, vy, vz, FLOAT2FIXED(distance), + if (!Trace(t1->_f_X(), t1->_f_Y(), shootz, t1->Sector, vx, vy, vz, FLOAT2FIXED(distance), MF_SHOOTABLE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, t1, trace, tflags, CheckForActor, &TData)) { // hit nothing @@ -4356,7 +4333,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, puff = P_SpawnPuff(t1, pufftype, bleedpos, 0, 0, 2, puffFlags | PF_HITTHING | PF_TEMPORARY); killPuff = true; } - newdam = P_DamageMobj(trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags|DMG_USEANGLE, trace.SrcAngleToTarget); + newdam = P_DamageMobj(trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags|DMG_USEANGLE, ANGLE2DBL(trace.SrcAngleToTarget)); if (actualdamage != NULL) { *actualdamage = newdam; @@ -4455,10 +4432,10 @@ AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch, vy = FixedMul(finecosine[pitch], finesine[angle]); vz = -finesine[pitch]; - shootz = t1->Z() - t1->floorclip + (t1->height >> 1); + shootz = t1->_f_Z() - t1->floorclip + (t1->height >> 1); if (t1->player != NULL) { - shootz += FixedMul(t1->player->mo->AttackZOffset, t1->player->crouchfactor); + shootz += fixed_t(t1->player->mo->AttackZOffset * t1->player->crouchfactor); } else { @@ -4471,7 +4448,7 @@ AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch, TData.Caller = t1; TData.hitGhosts = true; - if (Trace(t1->X(), t1->Y(), shootz, t1->Sector, vx, vy, vz, distance, + if (Trace(t1->_f_X(), t1->_f_Y(), shootz, t1->Sector, vx, vy, vz, distance, actorMask, wallMask, t1, trace, TRACE_NoSky | TRACE_PortalRestrict, CheckForActor, &TData)) { if (trace.HitType == TRACE_HitActor) @@ -4572,7 +4549,7 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an void P_TraceBleed(int damage, AActor *target, angle_t angle, int pitch) { - P_TraceBleed(damage, target->X(), target->Y(), target->Z() + target->height / 2, + P_TraceBleed(damage, target->_f_X(), target->_f_Y(), target->_f_Z() + target->height / 2, target, angle, pitch); } @@ -4591,18 +4568,18 @@ void P_TraceBleed(int damage, AActor *target, AActor *missile) return; } - if (missile->vel.z != 0) + if (missile->Vel.Z != 0) { double aim; - aim = g_atan((double)missile->vel.z / (double)target->AproxDistance(missile)); + aim = g_atan((double)missile->_f_velz() / (double)target->AproxDistance(missile)); pitch = -(int)(aim * ANGLE_180 / PI); } else { pitch = 0; } - P_TraceBleed(damage, target->X(), target->Y(), target->Z() + target->height / 2, + P_TraceBleed(damage, target->_f_X(), target->_f_Y(), target->_f_Z() + target->height / 2, target, missile->__f_AngleTo(target), pitch); } @@ -4621,7 +4598,7 @@ void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff) } fixed_t randpitch = (pr_tracebleed() - 128) << 16; - P_TraceBleed(damage, t->linetarget->X(), t->linetarget->Y(), t->linetarget->Z() + t->linetarget->height / 2, + P_TraceBleed(damage, t->linetarget->_f_X(), t->linetarget->_f_Y(), t->linetarget->_f_Z() + t->linetarget->height / 2, t->linetarget, FLOAT2ANGLE(t->angleFromSource.Degrees), 0); } @@ -4638,7 +4615,7 @@ void P_TraceBleed(int damage, AActor *target) fixed_t one = pr_tracebleed() << 24; fixed_t two = (pr_tracebleed() - 128) << 16; - P_TraceBleed(damage, target->X(), target->Y(), target->Z() + target->height / 2, + P_TraceBleed(damage, target->_f_X(), target->_f_Y(), target->_f_Z() + target->height / 2, target, one, two); } } @@ -4726,13 +4703,13 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i vy = FixedMul(finecosine[pitch], finesine[angle]); vz = finesine[pitch]; - shootz = source->Z() - source->floorclip + (source->height >> 1) + offset_z; + shootz = source->_f_Z() - source->floorclip + (source->height >> 1) + offset_z; if (!(railflags & RAF_CENTERZ)) { if (source->player != NULL) { - shootz += FixedMul(source->player->mo->AttackZOffset, source->player->crouchfactor); + shootz += fixed_t(source->player->mo->AttackZOffset * source->player->crouchfactor); } else { @@ -4771,7 +4748,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i // used as damage inflictor AActor *thepuff = NULL; - if (puffclass != NULL) thepuff = Spawn(puffclass, source->Pos(), ALLOW_REPLACE); + if (puffclass != NULL) thepuff = Spawn(puffclass, source->_f_Pos(), ALLOW_REPLACE); for (i = 0; i < rail_data.RailHits.Size(); i++) { @@ -4814,7 +4791,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i if (puffDefaults->flags3 & MF3_FOILINVUL) dmgFlagPass |= DMG_FOILINVUL; if (puffDefaults->flags7 & MF7_FOILBUDDHA) dmgFlagPass |= DMG_FOILBUDDHA; } - int newdam = P_DamageMobj(hitactor, thepuff ? thepuff : source, source, damage, damagetype, dmgFlagPass|DMG_USEANGLE, hitangle); + int newdam = P_DamageMobj(hitactor, thepuff ? thepuff : source, source, damage, damagetype, dmgFlagPass|DMG_USEANGLE, ANGLE2DBL(hitangle)); if (bleed) { @@ -4895,16 +4872,16 @@ void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &Camera vy = FixedMul(finecosine[pitch], finesine[angle]); vz = finesine[pitch]; - sz = t1->Z() - t1->floorclip + t1->height + (fixed_t)(clamp(chase_height, -1000, 1000) * FRACUNIT); + sz = t1->_f_Z() - t1->floorclip + t1->height + (fixed_t)(clamp(chase_height, -1000, 1000) * FRACUNIT); - if (Trace(t1->X(), t1->Y(), sz, t1->Sector, + if (Trace(t1->_f_X(), t1->_f_Y(), sz, t1->Sector, vx, vy, vz, distance, 0, 0, NULL, trace) && trace.Distance > 10 * FRACUNIT) { // Position camera slightly in front of hit thing fixed_t dist = trace.Distance - 5 * FRACUNIT; - CameraX = t1->X() + FixedMul(vx, dist); - CameraY = t1->Y() + FixedMul(vy, dist); + CameraX = t1->_f_X() + FixedMul(vx, dist); + CameraY = t1->_f_Y() + FixedMul(vy, dist); CameraZ = sz + FixedMul(vz, dist); } else @@ -4962,7 +4939,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end { FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES | PT_ADDTHINGS); intercept_t *in; - fixedvec3 xpos = { startx, starty, usething->Z() }; + fixedvec3 xpos = { startx, starty, usething->_f_Z() }; while ((in = it.Next())) { @@ -5107,8 +5084,8 @@ bool P_NoWayTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t e if (ld->flags&(ML_BLOCKING | ML_BLOCKEVERYTHING | ML_BLOCK_PLAYERS)) return true; P_LineOpening(open, NULL, ld, it.InterceptPoint(in)); if (open.range <= 0 || - open.bottom > usething->Z() + usething->MaxStepHeight || - open.top < usething->Top()) return true; + open.bottom > usething->_f_Z() + usething->MaxStepHeight || + open.top < usething->_f_Top()) return true; } return false; } @@ -5165,8 +5142,8 @@ bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) fixed_t x1, y1, x2, y2, usedist; angle = PuzzleItemUser->_f_angle() >> ANGLETOFINESHIFT; - x1 = PuzzleItemUser->X(); - y1 = PuzzleItemUser->Y(); + x1 = PuzzleItemUser->_f_X(); + y1 = PuzzleItemUser->_f_Y(); // [NS] If it's a Player, get their UseRange. if (PuzzleItemUser->player) @@ -5196,7 +5173,7 @@ bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) } continue; } - if (P_PointOnLineSide(PuzzleItemUser->X(), PuzzleItemUser->Y(), in->d.line) == 1) + if (P_PointOnLineSide(PuzzleItemUser->_f_X(), PuzzleItemUser->_f_Y(), in->d.line) == 1) { // Don't use back sides return false; } @@ -5265,7 +5242,7 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo double bombdamagefloat = (double)bombdamage; FPortalGroupArray grouplist(FPortalGroupArray::PGA_Full3d); - FMultiBlockThingsIterator it(grouplist, bombspot->X(), bombspot->Y(), bombspot->Z() - bombdistfix, bombspot->height + bombdistfix*2, bombdistfix, false, bombspot->Sector); + FMultiBlockThingsIterator it(grouplist, bombspot->_f_X(), bombspot->_f_Y(), bombspot->_f_Z() - bombdistfix, bombspot->height + bombdistfix*2, bombdistfix, false, bombspot->Sector); FMultiBlockThingsIterator::CheckResult cres; if (flags & RADF_SOURCEISSPOT) @@ -5315,7 +5292,7 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo fixed_t dx, dy; double boxradius; - fixedvec2 vec = bombspot->Vec2To(thing); + fixedvec2 vec = bombspot->_f_Vec2To(thing); dx = abs(vec.x); dy = abs(vec.y); boxradius = double(thing->radius); @@ -5323,17 +5300,17 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo // The damage pattern is square, not circular. len = double(dx > dy ? dx : dy); - if (bombspot->Z() < thing->Z() || bombspot->Z() >= thing->Top()) + if (bombspot->_f_Z() < thing->_f_Z() || bombspot->_f_Z() >= thing->_f_Top()) { double dz; - if (bombspot->Z() > thing->Z()) + if (bombspot->_f_Z() > thing->_f_Z()) { - dz = double(bombspot->Z() - thing->Top()); + dz = double(bombspot->_f_Z() - thing->_f_Top()); } else { - dz = double(thing->Z() - bombspot->Z()); + dz = double(thing->_f_Z() - bombspot->_f_Z()); } if (len <= boxradius) { @@ -5385,25 +5362,23 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo if (!(thing->flags7 & MF7_DONTTHRUST)) { - thrust = points * 0.5f / (double)thing->Mass; + thrust = points * 0.5 / (double)thing->Mass; if (bombsource == thing) { thrust *= selfthrustscale; } - vz = (double)(thing->Z() + (thing->height >> 1) - bombspot->Z()) * thrust; + vz = (thing->Center() - bombspot->Z()) * thrust; if (bombsource != thing) { - vz *= 0.5f; + vz *= 0.5; } else { - vz *= 0.8f; + vz *= 0.8; } - angle_t ang = bombspot->__f_AngleTo(thing) >> ANGLETOFINESHIFT; - thing->vel.x += fixed_t(finecosine[ang] * thrust); - thing->vel.y += fixed_t(finesine[ang] * thrust); + thing->Thrust(bombspot->AngleTo(thing), thrust); if (!(flags & RADF_NODAMAGE)) - thing->vel.z += (fixed_t)vz; // this really doesn't work well + thing->Vel.Z += vz; // this really doesn't work well } } } @@ -5415,7 +5390,7 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo // [RH] Old code just for barrels fixed_t dx, dy, dist; - fixedvec2 vec = bombspot->Vec2To(thing); + fixedvec2 vec = bombspot->_f_Vec2To(thing); dx = abs(vec.x); dy = abs(vec.y); @@ -5504,7 +5479,7 @@ bool P_AdjustFloorCeil(AActor *thing, FChangePosition *cpos) thing->flags2 |= MF2_PASSMOBJ; } - bool isgood = P_CheckPosition(thing, thing->X(), thing->Y(), tm); + bool isgood = P_CheckPosition(thing, thing->_f_X(), thing->_f_Y(), tm); thing->floorz = tm.floorz; thing->ceilingz = tm.ceilingz; thing->dropoffz = tm.dropoffz; // killough 11/98: remember dropoffs @@ -5541,7 +5516,7 @@ void P_FindAboveIntersectors(AActor *actor) { AActor *thing = cres.thing; fixed_t blockdist = actor->radius + thing->radius; - if (abs(thing->X() - cres.position.x) >= blockdist || abs(thing->Y() - cres.position.y) >= blockdist) + if (abs(thing->_f_X() - cres.position.x) >= blockdist || abs(thing->_f_Y() - cres.position.y) >= blockdist) continue; if (!(thing->flags & MF_SOLID)) @@ -5597,7 +5572,7 @@ void P_FindBelowIntersectors(AActor *actor) { AActor *thing = cres.thing; fixed_t blockdist = actor->radius + thing->radius; - if (abs(thing->X() - cres.position.x) >= blockdist || abs(thing->Y() - cres.position.y) >= blockdist) + if (abs(thing->_f_X() - cres.position.x) >= blockdist || abs(thing->_f_Y() - cres.position.y) >= blockdist) continue; if (!(thing->flags & MF_SOLID)) @@ -5662,8 +5637,8 @@ void P_DoCrunch(AActor *thing, FChangePosition *cpos) mo = Spawn(bloodcls, thing->PosPlusZ(thing->height / 2), ALLOW_REPLACE); - mo->vel.x = pr_crunch.Random2() << 12; - mo->vel.y = pr_crunch.Random2() << 12; + mo->Vel.X = pr_crunch.Random2() / 16.; + mo->Vel.Y = pr_crunch.Random2() / 16.; if (bloodcolor != 0 && !(mo->flags2 & MF2_DONTTRANSLATE)) { mo->Translation = TRANSLATION(TRANSLATION_Blood, bloodcolor.a); @@ -5676,7 +5651,7 @@ void P_DoCrunch(AActor *thing, FChangePosition *cpos) an = (M_Random() - 128) << 24; if (cl_bloodtype >= 1) { - P_DrawSplash2(32, thing->X(), thing->Y(), thing->Z() + thing->height / 2, an, 2, bloodcolor); + P_DrawSplash2(32, thing->_f_X(), thing->_f_Y(), thing->_f_Z() + thing->height / 2, an, 2, bloodcolor); } } if (thing->CrushPainSound != 0 && !S_GetSoundPlayingInfo(thing, thing->CrushPainSound)) @@ -5704,7 +5679,7 @@ int P_PushUp(AActor *thing, FChangePosition *cpos) unsigned int lastintersect; int mymass = thing->Mass; - if (thing->Top() > thing->ceilingz) + if (thing->_f_Top() > thing->ceilingz) { return 1; } @@ -5733,13 +5708,13 @@ int P_PushUp(AActor *thing, FChangePosition *cpos) return 2; } fixed_t oldz; - oldz = intersect->Z(); + oldz = intersect->_f_Z(); P_AdjustFloorCeil(intersect, cpos); - intersect->SetZ(thing->Top() + 1); + intersect->_f_SetZ(thing->_f_Top() + 1); if (P_PushUp(intersect, cpos)) { // Move blocked P_DoCrunch(intersect, cpos); - intersect->SetZ(oldz); + intersect->_f_SetZ(oldz); return 2; } } @@ -5761,7 +5736,7 @@ int P_PushDown(AActor *thing, FChangePosition *cpos) unsigned int lastintersect; int mymass = thing->Mass; - if (thing->Z() <= thing->floorz) + if (thing->_f_Z() <= thing->floorz) { return 1; } @@ -5778,15 +5753,15 @@ int P_PushDown(AActor *thing, FChangePosition *cpos) // Can't push bridges or things more massive than ourself return 2; } - fixed_t oldz = intersect->Z(); + fixed_t oldz = intersect->_f_Z(); P_AdjustFloorCeil(intersect, cpos); - if (oldz > thing->Z() - intersect->height) + if (oldz > thing->_f_Z() - intersect->height) { // Only push things down, not up. - intersect->SetZ(thing->Z() - intersect->height); + intersect->_f_SetZ(thing->_f_Z() - intersect->height); if (P_PushDown(intersect, cpos)) { // Move blocked P_DoCrunch(intersect, cpos); - intersect->SetZ(oldz); + intersect->_f_SetZ(oldz); return 2; } } @@ -5804,39 +5779,39 @@ int P_PushDown(AActor *thing, FChangePosition *cpos) void PIT_FloorDrop(AActor *thing, FChangePosition *cpos) { fixed_t oldfloorz = thing->floorz; - fixed_t oldz = thing->Z(); + fixed_t oldz = thing->_f_Z(); P_AdjustFloorCeil(thing, cpos); if (oldfloorz == thing->floorz) return; if (thing->flags4 & MF4_ACTLIKEBRIDGE) return; // do not move bridge things - if (thing->vel.z == 0 && + if (thing->_f_velz() == 0 && (!(thing->flags & MF_NOGRAVITY) || - (thing->Z() == oldfloorz && !(thing->flags & MF_NOLIFTDROP)))) + (thing->_f_Z() == oldfloorz && !(thing->flags & MF_NOLIFTDROP)))) { - fixed_t oldz = thing->Z(); + fixed_t oldz = thing->_f_Z(); if ((thing->flags & MF_NOGRAVITY) || (thing->flags5 & MF5_MOVEWITHSECTOR) || (((cpos->sector->Flags & SECF_FLOORDROP) || cpos->moveamt < 9 * FRACUNIT) - && thing->Z() - thing->floorz <= cpos->moveamt)) + && thing->_f_Z() - thing->floorz <= cpos->moveamt)) { - thing->SetZ(thing->floorz); + thing->_f_SetZ(thing->floorz); P_CheckFakeFloorTriggers(thing, oldz); } } - else if ((thing->Z() != oldfloorz && !(thing->flags & MF_NOLIFTDROP))) + else if ((thing->_f_Z() != oldfloorz && !(thing->flags & MF_NOLIFTDROP))) { - fixed_t oldz = thing->Z(); + fixed_t oldz = thing->_f_Z(); if ((thing->flags & MF_NOGRAVITY) && (thing->flags6 & MF6_RELATIVETOFLOOR)) { - thing->AddZ(-oldfloorz + thing->floorz); + thing->_f_AddZ(-oldfloorz + thing->floorz); P_CheckFakeFloorTriggers(thing, oldz); } } if (thing->player && thing->player->mo == thing) { - //thing->player->viewz += thing->Z() - oldz; + //thing->player->viewz += thing->_f_Z() - oldz; } } @@ -5849,14 +5824,14 @@ void PIT_FloorDrop(AActor *thing, FChangePosition *cpos) void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) { fixed_t oldfloorz = thing->floorz; - fixed_t oldz = thing->Z(); + fixed_t oldz = thing->_f_Z(); P_AdjustFloorCeil(thing, cpos); if (oldfloorz == thing->floorz) return; // Move things intersecting the floor up - if (thing->Z() <= thing->floorz) + if (thing->_f_Z() <= thing->floorz) { if (thing->flags4 & MF4_ACTLIKEBRIDGE) { @@ -5864,14 +5839,14 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) return; // do not move bridge things } intersectors.Clear(); - thing->SetZ(thing->floorz); + thing->_f_SetZ(thing->floorz); } else { if ((thing->flags & MF_NOGRAVITY) && (thing->flags6 & MF6_RELATIVETOFLOOR)) { intersectors.Clear(); - thing->AddZ(-oldfloorz + thing->floorz); + thing->_f_AddZ(-oldfloorz + thing->floorz); } else return; } @@ -5886,12 +5861,12 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) break; case 2: P_DoCrunch(thing, cpos); - thing->SetZ(oldz); + thing->_f_SetZ(oldz); break; } if (thing->player && thing->player->mo == thing) { - thing->player->viewz += thing->Z() - oldz; + thing->player->viewz += thing->_f_Z() - oldz; } } @@ -5904,12 +5879,12 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) { bool onfloor; - fixed_t oldz = thing->Z(); + fixed_t oldz = thing->_f_Z(); - onfloor = thing->Z() <= thing->floorz; + onfloor = thing->_f_Z() <= thing->floorz; P_AdjustFloorCeil(thing, cpos); - if (thing->Top() > thing->ceilingz) + if (thing->_f_Top() > thing->ceilingz) { if (thing->flags4 & MF4_ACTLIKEBRIDGE) { @@ -5917,14 +5892,14 @@ void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) return; // do not move bridge things } intersectors.Clear(); - fixed_t oldz = thing->Z(); + fixed_t oldz = thing->_f_Z(); if (thing->ceilingz - thing->height >= thing->floorz) { - thing->SetZ(thing->ceilingz - thing->height); + thing->_f_SetZ(thing->ceilingz - thing->height); } else { - thing->SetZ(thing->floorz); + thing->_f_SetZ(thing->floorz); } switch (P_PushDown(thing, cpos)) { @@ -5932,7 +5907,7 @@ void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) // intentional fall-through case 1: if (onfloor) - thing->SetZ(thing->floorz); + thing->_f_SetZ(thing->floorz); P_DoCrunch(thing, cpos); P_CheckFakeFloorTriggers(thing, oldz); break; @@ -5943,7 +5918,7 @@ void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) } if (thing->player && thing->player->mo == thing) { - thing->player->viewz += thing->Z() - oldz; + thing->player->viewz += thing->_f_Z() - oldz; } } @@ -5956,36 +5931,36 @@ void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos) { bool isgood = P_AdjustFloorCeil(thing, cpos); - fixed_t oldz = thing->Z(); + fixed_t oldz = thing->_f_Z(); if (thing->flags4 & MF4_ACTLIKEBRIDGE) return; // do not move bridge things // For DOOM compatibility, only move things that are inside the floor. // (or something else?) Things marked as hanging from the ceiling will // stay where they are. - if (thing->Z() < thing->floorz && - thing->Top() >= thing->ceilingz - cpos->moveamt && + if (thing->_f_Z() < thing->floorz && + thing->_f_Top() >= thing->ceilingz - cpos->moveamt && !(thing->flags & MF_NOLIFTDROP)) { - fixed_t oldz = thing->Z(); - thing->SetZ(thing->floorz); - if (thing->Top() > thing->ceilingz) + fixed_t oldz = thing->_f_Z(); + thing->_f_SetZ(thing->floorz); + if (thing->_f_Top() > thing->ceilingz) { - thing->SetZ(thing->ceilingz - thing->height); + thing->_f_SetZ(thing->ceilingz - thing->height); } P_CheckFakeFloorTriggers(thing, oldz); } - else if ((thing->flags2 & MF2_PASSMOBJ) && !isgood && thing->Top() < thing->ceilingz) + else if ((thing->flags2 & MF2_PASSMOBJ) && !isgood && thing->_f_Top() < thing->ceilingz) { AActor *onmobj; - if (!P_TestMobjZ(thing, true, &onmobj) && onmobj->Z() <= thing->Z()) + if (!P_TestMobjZ(thing, true, &onmobj) && onmobj->_f_Z() <= thing->_f_Z()) { - thing->SetZ( MIN(thing->ceilingz - thing->height, onmobj->Top())); + thing->_f_SetZ( MIN(thing->ceilingz - thing->height, onmobj->_f_Top())); } } if (thing->player && thing->player->mo == thing) { - thing->player->viewz += thing->Z() - oldz; + thing->player->viewz += thing->_f_Z() - oldz; } } @@ -6144,8 +6119,8 @@ bool P_ChangeSector(sector_t *sector, int crunch, int amt, int floorOrCeil, bool { n->visited = true; // mark thing as processed - n->m_thing->UpdateWaterLevel(n->m_thing->Z(), false); - P_CheckFakeFloorTriggers(n->m_thing, n->m_thing->Z() - amt); + n->m_thing->UpdateWaterLevel(n->m_thing->_f_Z(), false); + P_CheckFakeFloorTriggers(n->m_thing, n->m_thing->_f_Z() - amt); } } } while (n); // repeat from scratch until all things left are marked valid @@ -6365,7 +6340,7 @@ void P_CreateSecNodeList(AActor *thing, fixed_t x, fixed_t y) node = node->m_tnext; } - FBoundingBox box(thing->X(), thing->Y(), thing->radius); + FBoundingBox box(thing->_f_X(), thing->_f_Y(), thing->radius); FBlockLinesIterator it(box); line_t *ld; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index d6ad04d4c..20e24dffa 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -351,10 +351,10 @@ void AActor::UnlinkFromWorld () bool AActor::FixMapthingPos() { - sector_t *secstart = P_PointInSectorBuggy(X(), Y()); + sector_t *secstart = P_PointInSectorBuggy(_f_X(), _f_Y()); - int blockx = GetSafeBlockX(X() - bmaporgx); - int blocky = GetSafeBlockY(Y() - bmaporgy); + int blockx = GetSafeBlockX(_f_X() - bmaporgx); + int blocky = GetSafeBlockY(_f_Y() - bmaporgy); bool success = false; if ((unsigned int)blockx < (unsigned int)bmapwidth && @@ -380,10 +380,10 @@ bool AActor::FixMapthingPos() } // Not inside the line's bounding box - if (X() + radius <= ldef->bbox[BOXLEFT] - || X() - radius >= ldef->bbox[BOXRIGHT] - || Y() + radius <= ldef->bbox[BOXBOTTOM] - || Y() - radius >= ldef->bbox[BOXTOP]) + if (_f_X() + radius <= ldef->bbox[BOXLEFT] + || _f_X() - radius >= ldef->bbox[BOXRIGHT] + || _f_Y() + radius <= ldef->bbox[BOXBOTTOM] + || _f_Y() - radius >= ldef->bbox[BOXTOP]) continue; // Get the exact distance to the line @@ -392,8 +392,8 @@ bool AActor::FixMapthingPos() P_MakeDivline(ldef, &dll); - dlv.x = X(); - dlv.y = Y(); + dlv.x = _f_X(); + dlv.y = _f_Y(); dlv.dx = FixedDiv(dll.dy, linelen); dlv.dy = -FixedDiv(dll.dx, linelen); @@ -402,7 +402,7 @@ bool AActor::FixMapthingPos() if (distance < radius) { DPrintf("%s at (%d,%d) lies on %s line %td, distance = %f\n", - this->GetClass()->TypeName.GetChars(), X() >> FRACBITS, Y() >> FRACBITS, + this->GetClass()->TypeName.GetChars(), _f_X() >> FRACBITS, _f_Y() >> FRACBITS, ldef->dx == 0 ? "vertical" : ldef->dy == 0 ? "horizontal" : "diagonal", ldef - lines, FIXED2DBL(distance)); angle_t finean = R_PointToAngle2(0, 0, ldef->dx, ldef->dy); @@ -418,7 +418,7 @@ bool AActor::FixMapthingPos() // Get the distance we have to move the object away from the wall distance = radius - distance; - SetXY(X() + FixedMul(distance, finecosine[finean]), Y() + FixedMul(distance, finesine[finean])); + SetXY(_f_X() + FixedMul(distance, finecosine[finean]), _f_Y() + FixedMul(distance, finesine[finean])); ClearInterpolation(); success = true; } @@ -446,16 +446,16 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) { if (!spawningmapthing || numgamenodes == 0) { - sector = P_PointInSector(X(), Y()); + sector = P_PointInSector(_f_X(), _f_Y()); } else { - sector = P_PointInSectorBuggy(X(), Y()); + sector = P_PointInSectorBuggy(_f_X(), _f_Y()); } } Sector = sector; - subsector = R_PointInSubsector(X(), Y()); // this is from the rendering nodes, not the gameplay nodes! + subsector = R_PointInSubsector(_f_X(), _f_Y()); // this is from the rendering nodes, not the gameplay nodes! if (!(flags & MF_NOSECTOR)) { @@ -482,7 +482,7 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) // When a node is deleted, its sector links (the links starting // at sector_t->touching_thinglist) are broken. When a node is // added, new sector links are created. - P_CreateSecNodeList(this, X(), Y()); + P_CreateSecNodeList(this, _f_X(), _f_Y()); touching_sectorlist = sector_list; // Attach to thing sector_list = NULL; // clear for next time } @@ -493,11 +493,11 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) { FPortalGroupArray check(FPortalGroupArray::PGA_NoSectorPortals); - P_CollectConnectedGroups(Sector->PortalGroup, Pos(), Top(), radius, check); + P_CollectConnectedGroups(Sector->PortalGroup, _f_Pos(), _f_Top(), radius, check); for (int i = -1; i < (int)check.Size(); i++) { - fixedvec3 pos = i==-1? Pos() : PosRelative(check[i]); + fixedvec3 pos = i==-1? _f_Pos() : PosRelative(check[i]); int x1 = GetSafeBlockX(pos.x - radius - bmaporgx); int x2 = GetSafeBlockX(pos.x + radius - bmaporgx); @@ -737,8 +737,8 @@ line_t *FBlockLinesIterator::Next() FMultiBlockLinesIterator::FMultiBlockLinesIterator(FPortalGroupArray &check, AActor *origin, fixed_t checkradius) : checklist(check) { - checkpoint = origin->Pos(); - if (!check.inited) P_CollectConnectedGroups(origin->Sector->PortalGroup, checkpoint, origin->Top(), checkradius, checklist); + checkpoint = origin->_f_Pos(); + if (!check.inited) P_CollectConnectedGroups(origin->Sector->PortalGroup, checkpoint, origin->_f_Top(), checkradius, checklist); checkpoint.z = checkradius == -1? origin->radius : checkradius; basegroup = origin->Sector->PortalGroup; startsector = origin->Sector; @@ -1007,8 +1007,8 @@ AActor *FBlockThingsIterator::Next(bool centeronly) fixed_t blocktop = blockbottom + MAPBLOCKSIZE; // only return actors with the center in this block - if (me->X() >= blockleft && me->X() < blockright && - me->Y() >= blockbottom && me->Y() < blocktop) + if (me->_f_X() >= blockleft && me->_f_X() < blockright && + me->_f_Y() >= blockbottom && me->_f_Y() < blocktop) { return me; } @@ -1072,8 +1072,8 @@ AActor *FBlockThingsIterator::Next(bool centeronly) FMultiBlockThingsIterator::FMultiBlockThingsIterator(FPortalGroupArray &check, AActor *origin, fixed_t checkradius, bool ignorerestricted) : checklist(check) { - checkpoint = origin->Pos(); - if (!check.inited) P_CollectConnectedGroups(origin->Sector->PortalGroup, checkpoint, origin->Top(), checkradius, checklist); + checkpoint = origin->_f_Pos(); + if (!check.inited) P_CollectConnectedGroups(origin->Sector->PortalGroup, checkpoint, origin->_f_Top(), checkradius, checklist); checkpoint.z = checkradius == -1? origin->radius : checkradius; basegroup = origin->Sector->PortalGroup; Reset(); @@ -1260,29 +1260,29 @@ void FPathTraverse::AddThingIntercepts (int bx, int by, FBlockThingsIterator &it switch (i) { case 0: // Top edge - line.x = thing->X() + thing->radius; - line.y = thing->Y() + thing->radius; + line.x = thing->_f_X() + thing->radius; + line.y = thing->_f_Y() + thing->radius; line.dx = -thing->radius * 2; line.dy = 0; break; case 1: // Right edge - line.x = thing->X() + thing->radius; - line.y = thing->Y() - thing->radius; + line.x = thing->_f_X() + thing->radius; + line.y = thing->_f_Y() - thing->radius; line.dx = 0; line.dy = thing->radius * 2; break; case 2: // Bottom edge - line.x = thing->X() - thing->radius; - line.y = thing->Y() - thing->radius; + line.x = thing->_f_X() - thing->radius; + line.y = thing->_f_Y() - thing->radius; line.dx = thing->radius * 2; line.dy = 0; break; case 3: // Left edge - line.x = thing->X() - thing->radius; - line.y = thing->Y() + thing->radius; + line.x = thing->_f_X() - thing->radius; + line.y = thing->_f_Y() + thing->radius; line.dx = 0; line.dy = thing->radius * -2; break; @@ -1363,19 +1363,19 @@ void FPathTraverse::AddThingIntercepts (int bx, int by, FBlockThingsIterator &it // check a corner to corner crossection for hit if (tracepositive) { - x1 = thing->X() - thing->radius; - y1 = thing->Y() + thing->radius; + x1 = thing->_f_X() - thing->radius; + y1 = thing->_f_Y() + thing->radius; - x2 = thing->X() + thing->radius; - y2 = thing->Y() - thing->radius; + x2 = thing->_f_X() + thing->radius; + y2 = thing->_f_Y() - thing->radius; } else { - x1 = thing->X() - thing->radius; - y1 = thing->Y() - thing->radius; + x1 = thing->_f_X() - thing->radius; + y1 = thing->_f_Y() - thing->radius; - x2 = thing->X() + thing->radius; - y2 = thing->Y() + thing->radius; + x2 = thing->_f_X() + thing->radius; + y2 = thing->_f_Y() + thing->radius; } s1 = P_PointOnDivlineSide (x1, y1, &trace); @@ -1725,8 +1725,8 @@ AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, in int count; AActor *target; - startX = GetSafeBlockX(mo->X()-bmaporgx); - startY = GetSafeBlockY(mo->Y()-bmaporgy); + startX = GetSafeBlockX(mo->_f_X()-bmaporgx); + startY = GetSafeBlockY(mo->_f_Y()-bmaporgy); validcount++; if (startX >= 0 && startX < bmapwidth && startY >= 0 && startY < bmapheight) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 3b655ceef..2ad651073 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -73,10 +73,10 @@ // MACROS ------------------------------------------------------------------ -#define WATER_SINK_FACTOR 3 -#define WATER_SINK_SMALL_FACTOR 4 -#define WATER_SINK_SPEED (FRACUNIT/2) -#define WATER_JUMP_SPEED (FRACUNIT*7/2) +#define WATER_SINK_FACTOR 0.125 +#define WATER_SINK_SMALL_FACTOR 0.25 +#define WATER_SINK_SPEED 0.5 +#define WATER_JUMP_SPEED 3.5 // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- @@ -221,17 +221,17 @@ static VMFunction *UncalcDamageValue(int dmg, VMFunction *def) // //========================================================================== -void AActor::Serialize (FArchive &arc) +void AActor::Serialize(FArchive &arc) { - Super::Serialize (arc); + Super::Serialize(arc); - if (arc.IsStoring ()) + if (arc.IsStoring()) { - arc.WriteSprite (sprite); + arc.WriteSprite(sprite); } else { - sprite = arc.ReadSprite (); + sprite = arc.ReadSprite(); } arc << __pos.x @@ -263,9 +263,7 @@ void AActor::Serialize (FArchive &arc) << radius << height << projectilepassheight - << vel.x - << vel.y - << vel.z + << Vel << tics << state; if (arc.IsStoring()) @@ -474,7 +472,7 @@ void AActor::Serialize (FArchive &arc) } } ClearInterpolation(); - UpdateWaterLevel(Z(), false); + UpdateWaterLevel(_f_Z(), false); } } @@ -840,9 +838,9 @@ AInventory *AActor::DropInventory (AInventory *item) } drop->SetOrigin(PosPlusZ(10*FRACUNIT), false); drop->Angles.Yaw = Angles.Yaw; - drop->VelFromAngle(5*FRACUNIT); - drop->vel.z = FRACUNIT; - drop->vel += vel; + drop->VelFromAngle(5.); + drop->Vel.Z = 1.; + drop->Vel += Vel; drop->flags &= ~MF_NOGRAVITY; // Don't float drop->ClearCounters(); // do not count for statistics again return drop; @@ -1283,7 +1281,7 @@ bool AActor::Grind(bool items) if (flags & MF_ICECORPSE) { tics = 1; - vel.x = vel.y = vel.z = 0; + Vel.Zero(); } else if (player) { @@ -1360,7 +1358,7 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) return; } } - mo->vel.x = mo->vel.y = mo->vel.z = 0; + mo->Vel.Zero(); mo->effects = 0; // [RH] mo->flags &= ~MF_SHOOTABLE; @@ -1528,7 +1526,7 @@ void AActor::PlayBounceSound(bool onfloor) bool AActor::FloorBounceMissile (secplane_t &plane) { - if (Z() <= floorz && P_HitFloor (this)) + if (_f_Z() <= floorz && P_HitFloor (this)) { // Landed in some sort of liquid if (BounceFlags & BOUNCE_ExplodeOnWater) @@ -1567,13 +1565,11 @@ bool AActor::FloorBounceMissile (secplane_t &plane) return true; } - fixed_t dot = TMulScale16 (vel.x, plane.a, vel.y, plane.b, vel.z, plane.c); + double dot = (Vel | plane.Normal()) * 2; if (BounceFlags & (BOUNCE_HereticType | BOUNCE_MBF)) { - vel.x -= MulScale15 (plane.a, dot); - vel.y -= MulScale15 (plane.b, dot); - vel.z -= MulScale15 (plane.c, dot); + Vel -= plane.Normal() * dot; AngleFromVel(); if (!(BounceFlags & BOUNCE_MBF)) // Heretic projectiles die, MBF projectiles don't. { @@ -1582,14 +1578,12 @@ bool AActor::FloorBounceMissile (secplane_t &plane) flags &= ~MF_INBOUNCE; return false; } - else vel.z = FixedMul(vel.z, bouncefactor); + else Vel.Z *= _bouncefactor(); } else // Don't run through this for MBF-style bounces { // The reflected velocity keeps only about 70% of its original speed - vel.x = FixedMul (vel.x - MulScale15 (plane.a, dot), bouncefactor); - vel.y = FixedMul (vel.y - MulScale15 (plane.b, dot), bouncefactor); - vel.z = FixedMul (vel.z - MulScale15 (plane.c, dot), bouncefactor); + Vel = (Vel - plane.Normal() * dot) * _bouncefactor(); AngleFromVel(); } @@ -1612,15 +1606,15 @@ bool AActor::FloorBounceMissile (secplane_t &plane) if (BounceFlags & BOUNCE_MBF) // Bring it to rest below a certain speed { - if (abs(vel.z) < (fixed_t)(Mass * GetGravity() / 64)) - vel.z = 0; + if (fabs(Vel.Z) < Mass * GetGravity() / 64) + Vel.Z = 0; } else if (BounceFlags & (BOUNCE_AutoOff|BOUNCE_AutoOffFloorOnly)) { if (plane.c > 0 || (BounceFlags & BOUNCE_AutoOff)) { // AutoOff only works when bouncing off a floor, not a ceiling (or in compatibility mode.) - if (!(flags & MF_NOGRAVITY) && (vel.z < 3*FRACUNIT)) + if (!(flags & MF_NOGRAVITY) && (Vel.Z < 3)) BounceFlags &= ~BOUNCE_TypeMask; } } @@ -1633,11 +1627,12 @@ bool AActor::FloorBounceMissile (secplane_t &plane) // //---------------------------------------------------------------------------- -void P_ThrustMobj (AActor *mo, angle_t angle, fixed_t move) +void P_ThrustMobj (AActor *mo, angle_t _angle, fixed_t _move) { - angle >>= ANGLETOFINESHIFT; - mo->vel.x += FixedMul (move, finecosine[angle]); - mo->vel.y += FixedMul (move, finesine[angle]); + DAngle angle = ANGLE2DBL(_angle); + double move = FIXED2DBL(_move); + + mo->Vel += angle.ToVector(move); } //---------------------------------------------------------------------------- @@ -1702,10 +1697,9 @@ bool P_SeekerMissile (AActor *actor, angle_t _thresh, angle_t _turnMax, bool pre DAngle turnMax = ANGLE2DBL(_turnMax); int dir; - int dist; DAngle delta; AActor *target; - fixed_t speed; + double speed; speed = !usecurspeed ? actor->Speed : actor->VelToSpeed(); target = actor->tracer; @@ -1749,12 +1743,7 @@ bool P_SeekerMissile (AActor *actor, angle_t _thresh, angle_t _turnMax, bool pre if (actor->Top() < target->Z() || target->Top() < actor->Z()) { // Need to seek vertically - dist = actor->AproxDistance (target) / speed; - if (dist < 1) - { - dist = 1; - } - actor->vel.z = ((target->Z() + target->height / 2) - (actor->Z() + actor->height / 2)) / dist; + actor->Vel.Z = (target->Center() - actor->Center()) / actor->DistanceBySpeed(target, speed); } } } @@ -1770,7 +1759,7 @@ bool P_SeekerMissile (AActor *actor, angle_t _thresh, angle_t _turnMax, bool pre { aimheight = static_cast(target)->ViewHeight; } - pitch = ANGLE2DBL(R_PointToAngle2(0, actor->Z() + actor->height/2, dist, target->Z() + aimheight)); + pitch = ANGLE2DBL(R_PointToAngle2(0, actor->_f_Z() + actor->height/2, dist, target->_f_Z() + aimheight)); } actor->Vel3DFromAngle(pitch, speed); } @@ -1784,8 +1773,8 @@ bool P_SeekerMissile (AActor *actor, angle_t _thresh, angle_t _turnMax, bool pre // // Returns the actor's old floorz. // -#define STOPSPEED 0x1000 -#define CARRYSTOPSPEED (STOPSPEED*32/3) +#define STOPSPEED (0x1000/65536.) +#define CARRYSTOPSPEED (0x1000*32/3) fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { @@ -1800,9 +1789,9 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) int steps, step, totalsteps; fixed_t startx, starty; fixed_t oldfloorz = mo->floorz; - fixed_t oldz = mo->Z(); + fixed_t oldz = mo->_f_Z(); - fixed_t maxmove = (mo->waterlevel < 1) || (mo->flags & MF_MISSILE) || + double maxmove = (mo->waterlevel < 1) || (mo->flags & MF_MISSILE) || (mo->player && mo->player->crouchoffset<-10*FRACUNIT) ? MAXMOVE : MAXMOVE/4; if (mo->flags2 & MF2_WINDTHRUST && mo->waterlevel < 2 && !(mo->flags & MF_NOCLIP)) @@ -1830,24 +1819,18 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // running depends on the player's original movement continuing even after // it gets blocked. if ((mo->player != NULL && (i_compatflags & COMPATF_WALLRUN)) || (mo->waterlevel >= 1) || - (mo->player != NULL && mo->player->crouchfactor < FRACUNIT*3/4)) + (mo->player != NULL && mo->player->crouchfactor < 0.75)) { // preserve the direction instead of clamping x and y independently. - xmove = clamp (mo->vel.x, -maxmove, maxmove); - ymove = clamp (mo->vel.y, -maxmove, maxmove); + double cx = mo->Vel.X == 0 ? 1. : clamp(mo->Vel.X, -maxmove, maxmove) / mo->Vel.X; + double cy = mo->Vel.Y == 0 ? 1. : clamp(mo->Vel.Y, -maxmove, maxmove) / mo->Vel.Y; + double fac = MIN(cx, cy); - fixed_t xfac = FixedDiv(xmove, mo->vel.x); - fixed_t yfac = FixedDiv(ymove, mo->vel.y); - fixed_t fac = MIN(xfac, yfac); - - xmove = mo->vel.x = FixedMul(mo->vel.x, fac); - ymove = mo->vel.y = FixedMul(mo->vel.y, fac); - } - else - { - xmove = mo->vel.x; - ymove = mo->vel.y; + mo->Vel.X *= fac; + mo->Vel.Y *= fac; } + xmove = mo->_f_velx(); + ymove = mo->_f_vely(); // [RH] Carrying sectors didn't work with low speeds in BOOM. This is // because BOOM relied on the speed being fast enough to accumulate // despite friction. If the speed is too low, then its movement will get @@ -1855,14 +1838,14 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) mo->flags4 &= ~MF4_SCROLLMOVE; if (abs(scrollx) > CARRYSTOPSPEED) { - scrollx = FixedMul (scrollx, CARRYFACTOR); - mo->vel.x += scrollx; + scrollx = FixedMul (scrollx, _f_CARRYFACTOR); + mo->Vel.X += FIXED2DBL(scrollx); mo->flags4 |= MF4_SCROLLMOVE; } if (abs(scrolly) > CARRYSTOPSPEED) { - scrolly = FixedMul (scrolly, CARRYFACTOR); - mo->vel.y += scrolly; + scrolly = FixedMul (scrolly, _f_CARRYFACTOR); + mo->Vel.Y += FIXED2DBL(scrolly); mo->flags4 |= MF4_SCROLLMOVE; } xmove += scrollx; @@ -1874,7 +1857,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { // the skull slammed into something mo->flags &= ~MF_SKULLFLY; - mo->vel.x = mo->vel.y = mo->vel.z = 0; + mo->Vel.Zero(); if (!(mo->flags2 & MF2_DORMANT)) { if (mo->SeeState != NULL) mo->SetState (mo->SeeState); @@ -1903,11 +1886,11 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // through the actor. { - maxmove = mo->radius - FRACUNIT; + fixed_t maxmove = mo->radius - FRACUNIT; if (maxmove <= 0) { // gibs can have radius 0, so don't divide by zero below! - maxmove = MAXMOVE; + maxmove = _f_MAXMOVE; } const fixed_t xspeed = abs (xmove); @@ -1936,8 +1919,8 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) fixed_t onestepx = startxmove / steps; fixed_t onestepy = startymove / steps; - startx = mo->X(); - starty = mo->Y(); + startx = mo->_f_X(); + starty = mo->_f_Y(); step = 1; totalsteps = steps; @@ -1968,7 +1951,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) */ // [RH] If walking on a slope, stay on the slope // killough 3/15/98: Allow objects to drop off - fixed_t startvelx = mo->vel.x, startvely = mo->vel.y; + fixed_t startvelx = mo->_f_velx(), startvely = mo->_f_vely(); if (!P_TryMove (mo, ptryx, ptryy, true, walkplane, tm)) { @@ -1991,11 +1974,11 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) (mo->player->cmd.ucmd.forwardmove | mo->player->cmd.ucmd.sidemove) && mo->BlockingLine->sidedef[1] != NULL) { - mo->vel.z = WATER_JUMP_SPEED; + mo->Vel.Z = WATER_JUMP_SPEED; } // If the blocked move executed any push specials that changed the // actor's velocity, do not attempt to slide. - if (mo->vel.x == startvelx && mo->vel.y == startvely) + if (mo->_f_velx() == startvelx && mo->_f_vely() == startvely) { if (player && (i_compatflags & COMPATF_WALLRUN)) { @@ -2003,13 +1986,13 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // If the move is done a second time (because it was too fast for one move), it // is still clipped against the wall at its full speed, so you effectively // execute two moves in one tic. - P_SlideMove (mo, mo->vel.x, mo->vel.y, 1); + P_SlideMove (mo, mo->_f_velx(), mo->_f_vely(), 1); } else { P_SlideMove (mo, onestepx, onestepy, totalsteps); } - if ((mo->vel.x | mo->vel.y) == 0) + if ((mo->_f_velx() | mo->_f_vely()) == 0) { steps = 0; } @@ -2017,14 +2000,14 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { if (!player || !(i_compatflags & COMPATF_WALLRUN)) { - xmove = mo->vel.x; - ymove = mo->vel.y; + xmove = mo->_f_velx(); + ymove = mo->_f_vely(); onestepx = xmove / steps; onestepy = ymove / steps; P_CheckSlopeWalk (mo, xmove, ymove); } - startx = mo->X() - Scale (xmove, step, steps); - starty = mo->Y() - Scale (ymove, step, steps); + startx = mo->_f_X() - Scale (xmove, step, steps); + starty = mo->_f_Y() - Scale (ymove, step, steps); } } else @@ -2037,29 +2020,29 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) fixed_t tx, ty; tx = 0, ty = onestepy; walkplane = P_CheckSlopeWalk (mo, tx, ty); - if (P_TryMove (mo, mo->X() + tx, mo->Y() + ty, true, walkplane, tm)) + if (P_TryMove (mo, mo->_f_X() + tx, mo->_f_Y() + ty, true, walkplane, tm)) { - mo->vel.x = 0; + mo->Vel.X = 0; } else { tx = onestepx, ty = 0; walkplane = P_CheckSlopeWalk (mo, tx, ty); - if (P_TryMove (mo, mo->X() + tx, mo->Y() + ty, true, walkplane, tm)) + if (P_TryMove (mo, mo->_f_X() + tx, mo->_f_Y() + ty, true, walkplane, tm)) { - mo->vel.y = 0; + mo->Vel.Y = 0; } else { - mo->vel.x = mo->vel.y = 0; + mo->Vel.X = mo->Vel.Y = 0; } } if (player && player->mo == mo) { - if (mo->vel.x == 0) - player->vel.x = 0; - if (mo->vel.y == 0) - player->vel.y = 0; + if (mo->Vel.X == 0) + player->Vel.X = 0; + if (mo->Vel.Y == 0) + player->Vel.Y = 0; } steps = 0; } @@ -2106,30 +2089,23 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { AActor *origin = tg ? mo->target : BlockingMobj->target; - float speed = (float)(mo->Speed); //dest->x - source->x - fixedvec3 vect = mo->Vec3To(origin); - vect.z += origin->height / 2; - DVector3 velocity(vect.x, vect.y, vect.z); - velocity.Resize(speed); - mo->vel.x = (fixed_t)(velocity.X); - mo->vel.y = (fixed_t)(velocity.Y); - mo->vel.z = (fixed_t)(velocity.Z); + DVector3 vect = mo->Vec3To(origin); + vect.Z += origin->_Height() / 2; + mo->Vel = vect.Resized(mo->Speed); } else { if ((BlockingMobj->flags7 & MF7_MIRRORREFLECT) && (tg | blockingtg)) { mo->Angles.Yaw += 180.; - mo->vel.x = -mo->vel.x / 2; - mo->vel.y = -mo->vel.y / 2; - mo->vel.z = -mo->vel.z / 2; + mo->Vel *= -.5; } else { mo->Angles.Yaw = angle; mo->VelFromAngle(mo->Speed / 2); - mo->vel.z = -mo->vel.z / 2; + mo->Vel.Z *= -.5; } } } @@ -2152,7 +2128,7 @@ explode: if (tm.ceilingline && tm.ceilingline->backsector && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - mo->Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(mo->PosRelative(tm.ceilingline))) + mo->_f_Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(mo->PosRelative(tm.ceilingline))) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. @@ -2171,19 +2147,19 @@ explode: } else { - mo->vel.x = mo->vel.y = 0; + mo->Vel.X = mo->Vel.Y = 0; steps = 0; } } else { - if (mo->X() != ptryx || mo->Y() != ptryy) + if (mo->_f_X() != ptryx || mo->_f_Y() != ptryy) { // If the new position does not match the desired position, the player // must have gone through a teleporter, so stop moving right now if it // was a regular teleporter. If it was a line-to-line or fogless teleporter, // the move should continue, but startx, starty and xmove, ymove need to change. - if (mo->vel.x == 0 && mo->vel.y == 0) + if (mo->Vel.X == 0 && mo->Vel.Y == 0) { step = steps; } @@ -2201,8 +2177,8 @@ explode: oldangle = mo->_f_angle(); // in case more moves are needed this needs to be updated. } - startx = mo->X() - Scale (xmove, step, steps); - starty = mo->Y() - Scale (ymove, step, steps); + startx = mo->_f_X() - Scale (xmove, step, steps); + starty = mo->_f_Y() - Scale (ymove, step, steps); } } } @@ -2212,8 +2188,8 @@ explode: if (player && player->mo == mo && player->cheats & CF_NOVELOCITY) { // debug option for no sliding at all - mo->vel.x = mo->vel.y = 0; - player->vel.x = player->vel.y = 0; + mo->Vel.X = mo->Vel.Y = 0; + player->Vel.X = player->Vel.Y = 0; return oldfloorz; } @@ -2222,20 +2198,20 @@ explode: return oldfloorz; } - if (mo->Z() > mo->floorz && !(mo->flags2 & MF2_ONMOBJ) && + if (mo->_f_Z() > mo->floorz && !(mo->flags2 & MF2_ONMOBJ) && !mo->IsNoClip2() && (!(mo->flags2 & MF2_FLY) || !(mo->flags & MF_NOGRAVITY)) && !mo->waterlevel) { // [RH] Friction when falling is available for larger aircontrols - if (player != NULL && level.airfriction != FRACUNIT) + if (player != NULL && level.airfriction != 1.) { - mo->vel.x = FixedMul (mo->vel.x, level.airfriction); - mo->vel.y = FixedMul (mo->vel.y, level.airfriction); + mo->Vel.X *= level.airfriction; + mo->Vel.Y *= level.airfriction; if (player->mo == mo) // Not voodoo dolls { - player->vel.x = FixedMul (player->vel.x, level.airfriction); - player->vel.y = FixedMul (player->vel.y, level.airfriction); + player->Vel.X *= level.airfriction; + player->Vel.Y *= level.airfriction; } } return oldfloorz; @@ -2244,9 +2220,9 @@ explode: // killough 8/11/98: add bouncers // killough 9/15/98: add objects falling off ledges // killough 11/98: only include bouncers hanging off ledges - if ((mo->flags & MF_CORPSE) || (mo->BounceFlags & BOUNCE_MBF && mo->Z() > mo->dropoffz) || (mo->flags6 & MF6_FALLING)) + if ((mo->flags & MF_CORPSE) || (mo->BounceFlags & BOUNCE_MBF && mo->_f_Z() > mo->dropoffz) || (mo->flags6 & MF6_FALLING)) { // Don't stop sliding if halfway off a step with some velocity - if (mo->vel.x > FRACUNIT/4 || mo->vel.x < -FRACUNIT/4 || mo->vel.y > FRACUNIT/4 || mo->vel.y < -FRACUNIT/4) + if (mo->_f_velx() > FRACUNIT/4 || mo->_f_velx() < -FRACUNIT/4 || mo->_f_vely() > FRACUNIT/4 || mo->_f_vely() < -FRACUNIT/4) { if (mo->floorz > mo->Sector->floorplane.ZatPoint(mo)) { @@ -2271,8 +2247,7 @@ explode: // killough 11/98: // Stop voodoo dolls that have come to rest, despite any // moving corresponding player: - if (mo->vel.x > -STOPSPEED && mo->vel.x < STOPSPEED - && mo->vel.y > -STOPSPEED && mo->vel.y < STOPSPEED + if (fabs(mo->Vel.X) < STOPSPEED && fabs(mo->Vel.Y) < STOPSPEED && (!player || (player->mo != mo) || !(player->cmd.ucmd.forwardmove | player->cmd.ucmd.sidemove))) { @@ -2284,12 +2259,12 @@ explode: player->mo->PlayIdle (); } - mo->vel.x = mo->vel.y = 0; + mo->Vel.X = mo->Vel.Y = 0; mo->flags4 &= ~MF4_SCROLLMOVE; // killough 10/98: kill any bobbing velocity too (except in voodoo dolls) if (player && player->mo == mo) - player->vel.x = player->vel.y = 0; + player->Vel.X = player->Vel.Y = 0; } else { @@ -2306,10 +2281,10 @@ explode: // Reducing player velocity is no longer needed to reduce // bobbing, so ice works much better now. - fixed_t friction = P_GetFriction (mo, NULL); + double friction = FIXED2DBL(P_GetFriction (mo, NULL)); - mo->vel.x = FixedMul (mo->vel.x, friction); - mo->vel.y = FixedMul (mo->vel.y, friction); + mo->Vel.X *= friction; + mo->Vel.Y *= friction; // killough 10/98: Always decrease player bobbing by ORIG_FRICTION. // This prevents problems with bobbing on ice, where it was not being @@ -2317,8 +2292,17 @@ explode: if (player && player->mo == mo) // Not voodoo dolls { - player->vel.x = FixedMul (player->vel.x, ORIG_FRICTION); - player->vel.y = FixedMul (player->vel.y, ORIG_FRICTION); + player->Vel.X *= fORIG_FRICTION; + player->Vel.Y *= fORIG_FRICTION; + } + + // Don't let the velocity become less than the smallest representable fixed point value. + if (fabs(mo->Vel.X) < MinVel) mo->Vel.X = 0; + if (fabs(mo->Vel.Y) < MinVel) mo->Vel.Y = 0; + if (player && player->mo == mo) // Not voodoo dolls + { + if (fabs(player->Vel.X) < MinVel) player->Vel.X = 0; + if (fabs(player->Vel.Y) < MinVel) player->Vel.Y = 0; } } return oldfloorz; @@ -2335,7 +2319,7 @@ void P_MonsterFallingDamage (AActor *mo) if (mo->floorsector->Flags & SECF_NOFALLINGDAMAGE) return; - vel = abs(mo->vel.z); + vel = abs(mo->_f_velz()); if (vel > 35*FRACUNIT) { // automatic death damage = TELEFRAG_DAMAGE; @@ -2356,46 +2340,46 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) { fixed_t dist; fixed_t delta; - fixed_t oldz = mo->Z(); - fixed_t grav = mo->GetGravity(); + fixed_t oldz = mo->_f_Z(); + double grav = mo->GetGravity(); // // check for smooth step up // - if (mo->player && mo->player->mo == mo && mo->Z() < mo->floorz) + if (mo->player && mo->player->mo == mo && mo->_f_Z() < mo->floorz) { - mo->player->viewheight -= mo->floorz - mo->Z(); + mo->player->viewheight -= mo->floorz - mo->_f_Z(); mo->player->deltaviewheight = mo->player->GetDeltaViewHeight(); } - mo->AddZ(mo->vel.z); + mo->AddZ(mo->Vel.Z); // // apply gravity // - if (mo->Z() > mo->floorz && !(mo->flags & MF_NOGRAVITY)) + if (mo->_f_Z() > mo->floorz && !(mo->flags & MF_NOGRAVITY)) { - fixed_t startvelz = mo->vel.z; + double startvelz = mo->Vel.Z; if (mo->waterlevel == 0 || (mo->player && !(mo->player->cmd.ucmd.forwardmove | mo->player->cmd.ucmd.sidemove))) { // [RH] Double gravity only if running off a ledge. Coming down from // an upward thrust (e.g. a jump) should not double it. - if (mo->vel.z == 0 && oldfloorz > mo->floorz && mo->Z() == oldfloorz) + if (mo->_f_velz() == 0 && oldfloorz > mo->floorz && mo->_f_Z() == oldfloorz) { - mo->vel.z -= grav + grav; + mo->Vel.Z -= grav + grav; } else { - mo->vel.z -= grav; + mo->Vel.Z -= grav; } } if (mo->player == NULL) { if (mo->waterlevel >= 1) { - fixed_t sinkspeed; + double sinkspeed; if ((mo->flags & MF_SPECIAL) && !(mo->flags3 & MF3_ISMONSTER)) { // Pickup items don't sink if placed and drop slowly if dropped @@ -2409,23 +2393,23 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) // 100 being equivalent to a player. if (mo->player == NULL) { - sinkspeed = Scale(sinkspeed, clamp(mo->Mass, 1, 4000), 100); + sinkspeed = sinkspeed * clamp(mo->Mass, 1, 4000) / 100; } } - if (mo->vel.z < sinkspeed) + if (mo->Vel.Z < sinkspeed) { // Dropping too fast, so slow down toward sinkspeed. - mo->vel.z -= MAX(sinkspeed*2, -FRACUNIT*8); - if (mo->vel.z > sinkspeed) + mo->Vel.Z -= MAX(sinkspeed*2, -8.); + if (mo->Vel.Z > sinkspeed) { - mo->vel.z = sinkspeed; + mo->Vel.Z = sinkspeed; } } - else if (mo->vel.z > sinkspeed) + else if (mo->Vel.Z > sinkspeed) { // Dropping too slow/going up, so trend toward sinkspeed. - mo->vel.z = startvelz + MAX(sinkspeed/3, -FRACUNIT*8); - if (mo->vel.z < sinkspeed) + mo->Vel.Z = startvelz + MAX(sinkspeed/3, -8.); + if (mo->Vel.Z < sinkspeed) { - mo->vel.z = sinkspeed; + mo->Vel.Z = sinkspeed; } } } @@ -2434,15 +2418,15 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) { if (mo->waterlevel > 1) { - fixed_t sinkspeed = -WATER_SINK_SPEED; + double sinkspeed = -WATER_SINK_SPEED; - if (mo->vel.z < sinkspeed) + if (mo->Vel.Z < sinkspeed) { - mo->vel.z = (startvelz < sinkspeed) ? startvelz : sinkspeed; + mo->Vel.Z = (startvelz < sinkspeed) ? startvelz : sinkspeed; } else { - mo->vel.z = startvelz + ((mo->vel.z - startvelz) >> + mo->Vel.Z = startvelz + ((mo->Vel.Z - startvelz) * (mo->waterlevel == 1 ? WATER_SINK_SMALL_FACTOR : WATER_SINK_FACTOR)); } } @@ -2455,7 +2439,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) // Do this only if the item was actually spawned by the map above ground to avoid problems. if (mo->special1 > 0 && (mo->flags2 & MF2_FLOATBOB) && (ib_compatflags & BCOMPATF_FLOATBOB)) { - mo->SetZ(mo->floorz + mo->special1); + mo->_f_SetZ(mo->floorz + mo->special1); } @@ -2467,30 +2451,48 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) if (!(mo->flags & (MF_SKULLFLY | MF_INFLOAT))) { dist = mo->AproxDistance (mo->target); - delta = (mo->target->Z() + (mo->height>>1)) - mo->Z(); + delta = (mo->target->_f_Z() + (mo->height>>1)) - mo->_f_Z(); if (delta < 0 && dist < -(delta*3)) - mo->AddZ(-mo->FloatSpeed); + mo->_f_AddZ(-mo->_f_floatspeed()); else if (delta > 0 && dist < (delta*3)) - mo->AddZ(mo->FloatSpeed); + mo->_f_AddZ(mo->_f_floatspeed()); } } - if (mo->player && (mo->flags & MF_NOGRAVITY) && (mo->Z() > mo->floorz)) + if (mo->player && (mo->flags & MF_NOGRAVITY) && (mo->_f_Z() > mo->floorz)) { if (!mo->IsNoClip2()) { - mo->AddZ(finesine[(FINEANGLES/80*level.maptime)&FINEMASK]/8); + mo->_f_AddZ(finesine[(FINEANGLES/80*level.maptime)&FINEMASK]/8); } - mo->vel.z = FixedMul (mo->vel.z, FRICTION_FLY); + mo->Vel.Z *= fFRICTION_FLY; } if (mo->waterlevel && !(mo->flags & MF_NOGRAVITY)) { - mo->vel.z = FixedMul (mo->vel.z, mo->Sector->friction); + fixed_t friction = FIXED_MIN; + + // Check 3D floors -- might be the source of the waterlevel + for (auto rover : mo->Sector->e->XFloor.ffloors) + { + if (!(rover->flags & FF_EXISTS)) continue; + if (!(rover->flags & FF_SWIMMABLE)) continue; + + if (mo->_f_Z() >= rover->top.plane->ZatPoint(mo) || + mo->_f_Z() + mo->height/2 < rover->bottom.plane->ZatPoint(mo)) + continue; + + friction = rover->model->GetFriction(rover->top.isceiling); + break; + } + if (friction == FIXED_MIN) + friction = mo->Sector->GetFriction(); // get real friction, even if from a terrain definition + + mo->Vel.Z *= FIXED2DBL(friction); } // // clip movement // - if (mo->Z() <= mo->floorz) + if (mo->_f_Z() <= mo->floorz) { // Hit the floor if ((!mo->player || !(mo->player->cheats & CF_PREDICTING)) && mo->Sector->SecActTarget != NULL && @@ -2501,11 +2503,11 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) P_CheckFor3DFloorHit(mo); // [RH] Need to recheck this because the sector action might have // teleported the actor so it is no longer below the floor. - if (mo->Z() <= mo->floorz) + if (mo->_f_Z() <= mo->floorz) { if ((mo->flags & MF_MISSILE) && !(mo->flags & MF_NOCLIP)) { - mo->SetZ(mo->floorz); + mo->_f_SetZ(mo->floorz); if (mo->BounceFlags & BOUNCE_Floors) { mo->FloorBounceMissile (mo->floorsector->floorplane); @@ -2514,7 +2516,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) else if (mo->flags3 & MF3_NOEXPLODEFLOOR) { P_HitFloor (mo); - mo->vel.z = 0; + mo->Vel.Z = 0; return; } else if (mo->flags3 & MF3_FLOORHUGGER) @@ -2535,41 +2537,39 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) return; } } - else if (mo->BounceFlags & BOUNCE_MBF && mo->vel.z) // check for MBF-like bounce on non-missiles + else if (mo->BounceFlags & BOUNCE_MBF && mo->_f_velz()) // check for MBF-like bounce on non-missiles { mo->FloorBounceMissile(mo->floorsector->floorplane); } if (mo->flags3 & MF3_ISMONSTER) // Blasted mobj falling { - if (mo->vel.z < -(23*FRACUNIT)) + if (mo->_f_velz() < -(23*FRACUNIT)) { P_MonsterFallingDamage (mo); } } - mo->SetZ(mo->floorz); - if (mo->vel.z < 0) + mo->_f_SetZ(mo->floorz); + if (mo->_f_velz() < 0) { const fixed_t minvel = -8*FRACUNIT; // landing speed from a jump with normal gravity // Spawn splashes, etc. P_HitFloor (mo); - if (mo->DamageType == NAME_Ice && mo->vel.z < minvel) + if (mo->DamageType == NAME_Ice && mo->_f_velz() < minvel) { mo->tics = 1; - mo->vel.x = 0; - mo->vel.y = 0; - mo->vel.z = 0; + mo->Vel.Zero(); return; } // Let the actor do something special for hitting the floor mo->HitFloor (); if (mo->player) { - if (mo->player->jumpTics < 0 || mo->vel.z < minvel) + if (mo->player->jumpTics < 0 || mo->_f_velz() < minvel) { // delay any jumping for a short while mo->player->jumpTics = 7; } - if (mo->vel.z < minvel && !(mo->flags & MF_NOGRAVITY)) + if (mo->_f_velz() < minvel && !(mo->flags & MF_NOGRAVITY)) { // Squat down. // Decrease viewheight for a moment after hitting the ground (hard), @@ -2577,11 +2577,11 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) PlayerLandedOnThing (mo, NULL); } } - mo->vel.z = 0; + mo->Vel.Z = 0; } if (mo->flags & MF_SKULLFLY) { // The skull slammed into something - mo->vel.z = -mo->vel.z; + mo->Vel.Z = -mo->Vel.Z; } mo->Crash(); } @@ -2592,7 +2592,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) mo->AdjustFloorClip (); } - if (mo->Top() > mo->ceilingz) + if (mo->_f_Top() > mo->ceilingz) { // hit the ceiling if ((!mo->player || !(mo->player->cheats & CF_PREDICTING)) && mo->Sector->SecActTarget != NULL && @@ -2603,9 +2603,9 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) P_CheckFor3DCeilingHit(mo); // [RH] Need to recheck this because the sector action might have // teleported the actor so it is no longer above the ceiling. - if (mo->Top() > mo->ceilingz) + if (mo->_f_Top() > mo->ceilingz) { - mo->SetZ(mo->ceilingz - mo->height); + mo->_f_SetZ(mo->ceilingz - mo->height); if (mo->BounceFlags & BOUNCE_Ceilings) { // ceiling bounce mo->FloorBounceMissile (mo->ceilingsector->ceilingplane); @@ -2613,10 +2613,10 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) } if (mo->flags & MF_SKULLFLY) { // the skull slammed into something - mo->vel.z = -mo->vel.z; + mo->Vel.Z = -mo->Vel.Z; } - if (mo->vel.z > 0) - mo->vel.z = 0; + if (mo->Vel.Z > 0) + mo->Vel.Z = 0; if ((mo->flags & MF_MISSILE) && !(mo->flags & MF_NOCLIP)) { if (mo->flags3 & MF3_CEILINGHUGGER) @@ -2664,12 +2664,12 @@ void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheigh viewheight = mo->height / 2; } - if (oldz > waterz && mo->Z() <= waterz) + if (oldz > waterz && mo->_f_Z() <= waterz) { // Feet hit fake floor sec->SecActTarget->TriggerAction (mo, SECSPAC_HitFakeFloor); } - newz = mo->Z() + viewheight; + newz = mo->_f_Z() + viewheight; if (!oldz_has_viewheight) { oldz += viewheight; @@ -2714,7 +2714,7 @@ static void PlayerLandedOnThing (AActor *mo, AActor *onmobj) if (mo->player->mo == mo) { - mo->player->deltaviewheight = mo->vel.z >> 3; + mo->player->deltaviewheight = mo->_f_velz() >> 3; } if (mo->player->cheats & CF_PREDICTING) @@ -2727,7 +2727,7 @@ static void PlayerLandedOnThing (AActor *mo, AActor *onmobj) { grunted = false; // Why should this number vary by gravity? - if (mo->health > 0 && mo->vel.z < -mo->player->mo->GruntSpeed) + if (mo->health > 0 && mo->_f_velz() < -mo->player->mo->GruntSpeed) { S_Sound (mo, CHAN_VOICE, "*grunt", 1, ATTN_NORM); grunted = true; @@ -2771,22 +2771,22 @@ void P_NightmareRespawn (AActor *mobj) if (z == ONFLOORZ) { - mo->AddZ(mobj->SpawnPoint[2]); - if (mo->Z() < mo->floorz) + mo->_f_AddZ(mobj->SpawnPoint[2]); + if (mo->_f_Z() < mo->floorz) { // Do not respawn monsters in the floor, even if that's where they // started. The initial P_ZMovement() call would have put them on // the floor right away, but we need them on the floor now so we // can use P_CheckPosition() properly. - mo->SetZ(mo->floorz); + mo->_f_SetZ(mo->floorz); } - if (mo->Top() > mo->ceilingz) + if (mo->_f_Top() > mo->ceilingz) { - mo->SetZ(mo->ceilingz - mo->height); + mo->_f_SetZ(mo->ceilingz - mo->height); } } else if (z == ONCEILINGZ) { - mo->AddZ(-mobj->SpawnPoint[2]); + mo->_f_AddZ(-mobj->SpawnPoint[2]); } // If there are 3D floors, we need to find floor/ceiling again. @@ -2794,21 +2794,21 @@ void P_NightmareRespawn (AActor *mobj) if (z == ONFLOORZ) { - if (mo->Z() < mo->floorz) + if (mo->_f_Z() < mo->floorz) { // Do not respawn monsters in the floor, even if that's where they // started. The initial P_ZMovement() call would have put them on // the floor right away, but we need them on the floor now so we // can use P_CheckPosition() properly. - mo->SetZ(mo->floorz); + mo->_f_SetZ(mo->floorz); } - if (mo->Top() > mo->ceilingz) + if (mo->_f_Top() > mo->ceilingz) { // Do the same for the ceiling. - mo->SetZ(mo->ceilingz - mo->height); + mo->_f_SetZ(mo->ceilingz - mo->height); } } // something is occupying its position? - if (!P_CheckPosition(mo, mo->X(), mo->Y(), true)) + if (!P_CheckPosition(mo, mo->_f_X(), mo->_f_Y(), true)) { //[GrafZahl] MF_COUNTKILL still needs to be checked here. mo->ClearCounters(); @@ -2816,7 +2816,7 @@ void P_NightmareRespawn (AActor *mobj) return; // no respawn } - z = mo->Z(); + z = mo->_f_Z(); // inherit attributes from deceased one mo->SpawnPoint[0] = mobj->SpawnPoint[0]; @@ -3054,7 +3054,7 @@ void AActor::HitFloor () bool AActor::Slam (AActor *thing) { flags &= ~MF_SKULLFLY; - vel.x = vel.y = vel.z = 0; + Vel.Zero(); if (health > 0) { if (!(flags2 & MF2_DORMANT)) @@ -3270,8 +3270,8 @@ fixedvec3 AActor::GetPortalTransition(fixed_t byoffset, sector_t **pSec) { bool moved = false; sector_t *sec = Sector; - fixed_t testz = Z() + byoffset; - fixedvec3 pos = Pos(); + fixed_t testz = _f_Z() + byoffset; + fixedvec3 pos = _f_Pos(); while (!sec->PortalBlocksMovement(sector_t::ceiling)) { @@ -3309,15 +3309,15 @@ void AActor::CheckPortalTransition(bool islinked) while (!Sector->PortalBlocksMovement(sector_t::ceiling)) { AActor *port = Sector->SkyBoxes[sector_t::ceiling]; - if (Z() > port->threshold) + if (_f_Z() > port->threshold) { - fixedvec3 oldpos = Pos(); + fixedvec3 oldpos = _f_Pos(); if (islinked && !moved) UnlinkFromWorld(); SetXYZ(PosRelative(port->Sector)); - PrevX += X() - oldpos.x; - PrevY += Y() - oldpos.y; - PrevZ += Z() - oldpos.z; - Sector = P_PointInSector(X(), Y()); + PrevX += _f_X() - oldpos.x; + PrevY += _f_Y() - oldpos.y; + PrevZ += _f_Z() - oldpos.z; + Sector = P_PointInSector(_f_X(), _f_Y()); PrevPortalGroup = Sector->PortalGroup; moved = true; } @@ -3328,15 +3328,15 @@ void AActor::CheckPortalTransition(bool islinked) while (!Sector->PortalBlocksMovement(sector_t::floor)) { AActor *port = Sector->SkyBoxes[sector_t::floor]; - if (Z() < port->threshold && floorz < port->threshold) + if (_f_Z() < port->threshold && floorz < port->threshold) { - fixedvec3 oldpos = Pos(); + fixedvec3 oldpos = _f_Pos(); if (islinked && !moved) UnlinkFromWorld(); SetXYZ(PosRelative(port->Sector)); - PrevX += X() - oldpos.x; - PrevY += Y() - oldpos.y; - PrevZ += Z() - oldpos.z; - Sector = P_PointInSector(X(), Y()); + PrevX += _f_X() - oldpos.x; + PrevY += _f_Y() - oldpos.y; + PrevZ += _f_Z() - oldpos.z; + Sector = P_PointInSector(_f_X(), _f_Y()); PrevPortalGroup = Sector->PortalGroup; moved = true; } @@ -3376,8 +3376,7 @@ void AActor::Tick () //assert (state != NULL); if (state == NULL) { - Printf("Actor of type %s at (%f,%f) left without a state\n", GetClass()->TypeName.GetChars(), - X()/65536., Y()/65536.); + Printf("Actor of type %s at (%f,%f) left without a state\n", GetClass()->TypeName.GetChars(), X(), Y()); Destroy(); return; } @@ -3409,7 +3408,7 @@ void AActor::Tick () UnlinkFromWorld (); flags |= MF_NOBLOCKMAP; - SetXYZ(Vec3Offset(vel.x, vel.y, vel.z)); + SetXYZ(Vec3Offset(_f_velx(), _f_vely(), _f_velz())); CheckPortalTransition(false); LinkToWorld (); } @@ -3457,7 +3456,7 @@ void AActor::Tick () { // add some smoke behind the rocket smokecounter = 0; - AActor *th = Spawn("RocketSmokeTrail", Vec3Offset(-vel.x, -vel.y, -vel.z), ALLOW_REPLACE); + AActor *th = Spawn("RocketSmokeTrail", Vec3Offset(-_f_velx(), -_f_vely(), -_f_velz()), ALLOW_REPLACE); if (th) { th->tics -= pr_rockettrail()&3; @@ -3471,10 +3470,10 @@ void AActor::Tick () if (++smokecounter == 8) { smokecounter = 0; - angle_t moveangle = R_PointToAngle2(0,0,vel.x,vel.y); + angle_t moveangle = R_PointToAngle2(0,0,_f_velx(),_f_vely()); fixed_t xo = -FixedMul(finecosine[(moveangle) >> ANGLETOFINESHIFT], radius * 2) + (pr_rockettrail() << 10); fixed_t yo = -FixedMul(finesine[(moveangle) >> ANGLETOFINESHIFT], radius * 2) + (pr_rockettrail() << 10); - AActor * th = Spawn("GrenadeSmokeTrail", Vec3Offset(xo, yo, - (height>>3) * (vel.z>>16) + (2*height)/3), ALLOW_REPLACE); + AActor * th = Spawn("GrenadeSmokeTrail", Vec3Offset(xo, yo, - (height>>3) * (_f_velz()>>16) + (2*height)/3), ALLOW_REPLACE); if (th) { th->tics -= pr_rockettrail()&3; @@ -3484,7 +3483,7 @@ void AActor::Tick () } } - fixed_t oldz = Z(); + fixed_t oldz = _f_Z(); // [RH] Give the pain elemental vertical friction // This used to be in APainElemental::Tick but in order to use @@ -3493,14 +3492,14 @@ void AActor::Tick () { if (health >0) { - if (abs (vel.z) < FRACUNIT/4) + if (abs (_f_velz()) < FRACUNIT/4) { - vel.z = 0; + Vel.Z = 0; flags4 &= ~MF4_VFRICTION; } else { - vel.z = FixedMul (vel.z, 0xe800); + Vel.Z *= (0xe800 / 65536.); } } } @@ -3639,7 +3638,7 @@ void AActor::Tick () if (i_compatflags&COMPATF_RAVENSCROLL) { angle_t fineangle = HexenScrollDirs[scrolltype / 3] * 32; - fixed_t carryspeed = DivScale32 (HexenSpeedMuls[scrolltype % 3], 32*CARRYFACTOR); + fixed_t carryspeed = DivScale32 (HexenSpeedMuls[scrolltype % 3], 32*_f_CARRYFACTOR); scrollx += FixedMul (carryspeed, finecosine[fineangle]); scrolly += FixedMul (carryspeed, finesine[fineangle]); } @@ -3655,7 +3654,7 @@ void AActor::Tick () { // Heretic scroll special scrolltype -= Carry_East5; BYTE dir = HereticScrollDirs[scrolltype / 5]; - fixed_t carryspeed = DivScale32 (HereticSpeedMuls[scrolltype % 5], 32*CARRYFACTOR); + fixed_t carryspeed = DivScale32 (HereticSpeedMuls[scrolltype % 5], 32*_f_CARRYFACTOR); if (scrolltype<=Carry_East35 && !(i_compatflags&COMPATF_RAVENSCROLL)) { // Use speeds that actually match the scrolling textures! @@ -3668,18 +3667,18 @@ void AActor::Tick () { // Special Heretic scroll special if (i_compatflags&COMPATF_RAVENSCROLL) { - scrollx += DivScale32 (28, 32*CARRYFACTOR); + scrollx += DivScale32 (28, 32*_f_CARRYFACTOR); } else { // Use a speed that actually matches the scrolling texture! - scrollx += DivScale32 (12, 32*CARRYFACTOR); + scrollx += DivScale32 (12, 32*_f_CARRYFACTOR); } } else if (scrolltype == Scroll_StrifeCurrent) { // Strife scroll special int anglespeed = tagManager.GetFirstSectorTag(sec) - 100; - fixed_t carryspeed = DivScale32 (anglespeed % 10, 16*CARRYFACTOR); + fixed_t carryspeed = DivScale32 (anglespeed % 10, 16*_f_CARRYFACTOR); angle_t fineangle = (anglespeed / 10) << (32-3); fineangle >>= ANGLETOFINESHIFT; scrollx += FixedMul (carryspeed, finecosine[fineangle]); @@ -3698,7 +3697,7 @@ void AActor::Tick () } fixedvec3 pos = PosRelative(sec); height = sec->floorplane.ZatPoint (pos); - if (Z() > height) + if (_f_Z() > height) { if (heightsec == NULL) { @@ -3706,7 +3705,7 @@ void AActor::Tick () } waterheight = heightsec->floorplane.ZatPoint (pos); - if (waterheight > height && Z() >= waterheight) + if (waterheight > height && _f_Z() >= waterheight) { continue; } @@ -3737,13 +3736,13 @@ void AActor::Tick () // [RH] If standing on a steep slope, fall down it if ((flags & MF_SOLID) && !(flags & (MF_NOCLIP|MF_NOGRAVITY)) && !(flags & MF_NOBLOCKMAP) && - vel.z <= 0 && - floorz == Z()) + _f_velz() <= 0 && + floorz == _f_Z()) { secplane_t floorplane; // Check 3D floors as well - floorplane = P_FindFloorPlane(floorsector, X(), Y(), floorz); + floorplane = P_FindFloorPlane(floorsector, _f_X(), _f_Y(), floorz); if (floorplane.c < STEEPSLOPE && floorplane.ZatPoint (PosRelative(floorsector)) <= floorz) @@ -3758,7 +3757,7 @@ void AActor::Tick () const sector_t *sec = node->m_sector; if (sec->floorplane.c >= STEEPSLOPE) { - if (floorplane.ZatPoint (PosRelative(node->m_sector)) >= Z() - MaxStepHeight) + if (floorplane.ZatPoint (PosRelative(node->m_sector)) >= _f_Z() - MaxStepHeight) { dopush = false; break; @@ -3768,8 +3767,7 @@ void AActor::Tick () } if (dopush) { - vel.x += floorplane.a; - vel.y += floorplane.b; + Vel += floorplane.Normal().XY(); } } } @@ -3779,19 +3777,21 @@ void AActor::Tick () // still have missiles that go straight up and down through actors without // damaging anything. // (for backwards compatibility this must check for lack of damage function, not for zero damage!) - if ((flags & MF_MISSILE) && (vel.x|vel.y) == 0 && Damage != NULL) + if ((flags & MF_MISSILE) && Vel.X == 0 && Vel.Y == 0 && Damage != NULL) { - vel.x = 1; + Vel.X = MinVel; } // Handle X and Y velocities BlockingMobj = NULL; + assert(!player || !isnan(Vel.X)); fixed_t oldfloorz = P_XYMovement (this, cummx, cummy); + assert(!player || !isnan(Vel.X)); if (ObjectFlags & OF_EuthanizeMe) { // actor was destroyed return; } - if ((vel.x | vel.y) == 0) // Actors at rest + if (Vel.X == 0 && Vel.Y == 0) // Actors at rest { if (flags2 & MF2_BLASTED) { // Reset to not blasted when velocities are gone @@ -3803,7 +3803,7 @@ void AActor::Tick () } } - if (vel.z || BlockingMobj || Z() != floorz) + if (Vel.Z != 0 || BlockingMobj || _f_Z() != floorz) { // Handle Z velocity and gravity if (((flags2 & MF2_PASSMOBJ) || (flags & MF_SPECIAL)) && !(i_compatflags & COMPATF_NO_PASSMOBJ)) { @@ -3816,24 +3816,24 @@ void AActor::Tick () { if (player) { - if (vel.z < (fixed_t)(level.gravity * Sector->gravity * -655.36f) + if (_f_velz() < (fixed_t)(level.gravity * Sector->gravity * -655.36f) && !(flags&MF_NOGRAVITY)) { PlayerLandedOnThing (this, onmo); } } - if (onmo->Top() - Z() <= MaxStepHeight) + if (onmo->_f_Top() - _f_Z() <= MaxStepHeight) { if (player && player->mo == this) { - player->viewheight -= onmo->Top() - Z(); + player->viewheight -= onmo->_f_Top() - _f_Z(); fixed_t deltaview = player->GetDeltaViewHeight(); if (deltaview > player->deltaviewheight) { player->deltaviewheight = deltaview; } } - SetZ(onmo->Top()); + _f_SetZ(onmo->_f_Top()); } // Check for MF6_BUMPSPECIAL // By default, only players can activate things by bumping into them @@ -3852,14 +3852,14 @@ void AActor::Tick () onmo->lastbump = level.maptime + TICRATE; } } - if (vel.z != 0 && (BounceFlags & BOUNCE_Actors)) + if (_f_velz() != 0 && (BounceFlags & BOUNCE_Actors)) { P_BounceActor(this, onmo, true); } else { flags2 |= MF2_ONMOBJ; - vel.z = 0; + Vel.Z = 0; Crash(); } } @@ -3872,7 +3872,7 @@ void AActor::Tick () if (ObjectFlags & OF_EuthanizeMe) return; // actor was destroyed } - else if (Z() <= floorz) + else if (_f_Z() <= floorz) { Crash(); } @@ -3999,25 +3999,25 @@ void AActor::CheckSectorTransition(sector_t *oldsec) if (Sector->SecActTarget != NULL) { int act = SECSPAC_Enter; - if (Z() <= Sector->floorplane.ZatPoint(this)) + if (_f_Z() <= Sector->floorplane.ZatPoint(this)) { act |= SECSPAC_HitFloor; } - if (Z() + height >= Sector->ceilingplane.ZatPoint(this)) + if (_f_Z() + height >= Sector->ceilingplane.ZatPoint(this)) { act |= SECSPAC_HitCeiling; } - if (Sector->heightsec != NULL && Z() == Sector->heightsec->floorplane.ZatPoint(this)) + if (Sector->heightsec != NULL && _f_Z() == Sector->heightsec->floorplane.ZatPoint(this)) { act |= SECSPAC_HitFakeFloor; } Sector->SecActTarget->TriggerAction(this, act); } - if (Z() == floorz) + if (_f_Z() == floorz) { P_CheckFor3DFloorHit(this); } - if (Top() == ceilingz) + if (_f_Top() == ceilingz) { P_CheckFor3DCeilingHit(this); } @@ -4057,20 +4057,20 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) fh = hsec->floorplane.ZatPoint (this); //if (hsec->MoreFlags & SECF_UNDERWATERMASK) // also check Boom-style non-swimmable sectors { - if (Z() < fh) + if (_f_Z() < fh) { waterlevel = 1; - if (Z() + height/2 < fh) + if (_f_Z() + height/2 < fh) { waterlevel = 2; - if ((player && Z() + player->viewheight <= fh) || - (Z() + height <= fh)) + if ((player && _f_Z() + player->viewheight <= fh) || + (_f_Z() + height <= fh)) { waterlevel = 3; } } } - else if (!(hsec->MoreFlags & SECF_FAKEFLOORONLY) && (Top() > hsec->ceilingplane.ZatPoint (this))) + else if (!(hsec->MoreFlags & SECF_FAKEFLOORONLY) && (_f_Top() > hsec->ceilingplane.ZatPoint (this))) { waterlevel = 3; } @@ -4099,17 +4099,17 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) fixed_t ff_bottom=rover->bottom.plane->ZatPoint(this); fixed_t ff_top=rover->top.plane->ZatPoint(this); - if(ff_top <= Z() || ff_bottom > (Z() + (height >> 1))) continue; + if(ff_top <= _f_Z() || ff_bottom > (_f_Z() + (height >> 1))) continue; fh=ff_top; - if (Z() < fh) + if (_f_Z() < fh) { waterlevel = 1; - if (Z() + height/2 < fh) + if (_f_Z() + height/2 < fh) { waterlevel = 2; - if ((player && Z() + player->viewheight <= fh) || - (Z() + height <= fh)) + if ((player && _f_Z() + player->viewheight <= fh) || + (_f_Z() + height <= fh)) { waterlevel = 3; } @@ -4199,7 +4199,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t actor->renderflags = (actor->renderflags & ~RF_FULLBRIGHT) | ActorRenderFlags::FromInt (st->GetFullbright()); actor->touching_sectorlist = NULL; // NULL head of sector list // phares 3/13/98 if (G_SkillProperty(SKILLP_FastMonsters) && actor->GetClass()->FastSpeed >= 0) - actor->Speed = actor->GetClass()->FastSpeed; + actor->Speed = actor->GetClass()->FastSpeed; actor->DamageMultiply = FRACUNIT; // set subsector and/or block links @@ -4214,11 +4214,11 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t // For FLOATRANDZ just use the floor here. if (iz == ONFLOORZ || iz == FLOATRANDZ) { - actor->SetZ(actor->floorz, false); + actor->_f_SetZ(actor->floorz, false); } else if (iz == ONCEILINGZ) { - actor->SetZ(actor->ceilingz - actor->height); + actor->_f_SetZ(actor->ceilingz - actor->height); } if (SpawningMapThing || !type->IsDescendantOf (RUNTIME_CLASS(APlayerPawn))) @@ -4257,11 +4257,11 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t if (iz == ONFLOORZ) { - actor->SetZ(actor->floorz); + actor->_f_SetZ(actor->floorz); } else if (iz == ONCEILINGZ) { - actor->SetZ(actor->ceilingz - actor->height); + actor->_f_SetZ(actor->ceilingz - actor->height); } else if (iz == FLOATRANDZ) { @@ -4269,16 +4269,16 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t if (space > 48*FRACUNIT) { space -= 40*FRACUNIT; - actor->SetZ(MulScale8 (space, rng()) + actor->floorz + 40*FRACUNIT); + actor->_f_SetZ(MulScale8 (space, rng()) + actor->floorz + 40*FRACUNIT); } else { - actor->SetZ(actor->floorz); + actor->_f_SetZ(actor->floorz); } } else { - actor->SpawnPoint[2] = (actor->Z() - actor->Sector->floorplane.ZatPoint(actor)); + actor->SpawnPoint[2] = (actor->_f_Z() - actor->Sector->floorplane.ZatPoint(actor)); } if (actor->FloatBobPhase == (BYTE)-1) actor->FloatBobPhase = rng(); // Don't make everything bob in sync (unless deliberately told to do) @@ -4290,7 +4290,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t { actor->floorclip = 0; } - actor->UpdateWaterLevel (actor->Z(), false); + actor->UpdateWaterLevel (actor->_f_Z(), false); if (!SpawningMapThing) { actor->BeginPlay (); @@ -4534,7 +4534,7 @@ void AActor::AdjustFloorClip () const msecnode_t *m; // possibly standing on a 3D-floor - if (Sector->e->XFloor.ffloors.Size() && Z() > Sector->floorplane.ZatPoint(this)) floorclip = 0; + if (Sector->e->XFloor.ffloors.Size() && _f_Z() > Sector->floorplane.ZatPoint(this)) floorclip = 0; // [RH] clip based on shallowest floor player is standing on // If the sector has a deep water effect, then let that effect @@ -4543,7 +4543,7 @@ void AActor::AdjustFloorClip () { fixedvec3 pos = PosRelative(m->m_sector); sector_t *hsec = m->m_sector->GetHeightSec(); - if (hsec == NULL && m->m_sector->floorplane.ZatPoint (pos) == Z()) + if (hsec == NULL && m->m_sector->floorplane.ZatPoint (pos) == _f_Z()) { fixed_t clip = Terrains[m->m_sector->GetTerrain(sector_t::floor)].FootClip; if (clip < shallowestclip) @@ -4637,9 +4637,9 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) ( NULL != p->attacker ) && // don't respawn on damaging floors ( p->mo->Sector->damageamount < TELEFRAG_DAMAGE )) // this really should be a bit smarter... { - spawn_x = p->mo->X(); - spawn_y = p->mo->Y(); - spawn_z = p->mo->Z(); + spawn_x = p->mo->_f_X(); + spawn_y = p->mo->_f_Y(); + spawn_z = p->mo->_f_Z(); SpawnAngle = p->mo->Angles.Yaw; } @@ -4669,9 +4669,9 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) if (level.flags & LEVEL_USEPLAYERSTARTZ) { if (spawn_z == ONFLOORZ) - mobj->AddZ(mthing->z); + mobj->_f_AddZ(mthing->z); else if (spawn_z == ONCEILINGZ) - mobj->AddZ(-mthing->z); + mobj->_f_AddZ(-mthing->z); P_FindFloorCeiling(mobj, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); } @@ -4739,7 +4739,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) p->MUSINFOactor = NULL; p->MUSINFOtics = -1; - p->vel.x = p->vel.y = 0; // killough 10/98: initialize bobbing to 0. + p->Vel.Zero(); // killough 10/98: initialize bobbing to 0. for (int ii = 0; ii < MAXPLAYERS; ++ii) { @@ -4797,9 +4797,9 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) // "Fix" for one of the starts on exec.wad MAP01: If you start inside the ceiling, // drop down below it, even if that means sinking into the floor. - if (mobj->Top() > mobj->ceilingz) + if (mobj->_f_Top() > mobj->ceilingz) { - mobj->SetZ(mobj->ceilingz - mobj->height, false); + mobj->_f_SetZ(mobj->ceilingz - mobj->height, false); } // [BC] Do script stuff @@ -5130,14 +5130,14 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) if (z == ONFLOORZ) { - mobj->AddZ(mthing->z); + mobj->_f_AddZ(mthing->z); if ((mobj->flags2 & MF2_FLOATBOB) && (ib_compatflags & BCOMPATF_FLOATBOB)) { mobj->special1 = mthing->z; } } else if (z == ONCEILINGZ) - mobj->AddZ(-mthing->z); + mobj->_f_AddZ(-mthing->z); mobj->SpawnPoint[0] = mthing->x; mobj->SpawnPoint[1] = mthing->y; @@ -5322,7 +5322,7 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc { z += pr_spawnblood.Random2 () << 10; th = Spawn (bloodcls, x, y, z, NO_REPLACE); // GetBloodType already performed the replacement - th->vel.z = FRACUNIT*2; + th->Vel.Z = 2; th->Angles.Yaw = ANGLE2DBL(dir); // [NG] Applying PUFFGETSOWNER to the blood will make it target the owner if (th->flags5 & MF5_PUFFGETSOWNER) th->target = originator; @@ -5418,9 +5418,9 @@ void P_BloodSplatter (fixedvec3 pos, AActor *originator) mo = Spawn(bloodcls, pos, NO_REPLACE); // GetBloodType already performed the replacement mo->target = originator; - mo->vel.x = pr_splatter.Random2 () << 10; - mo->vel.y = pr_splatter.Random2 () << 10; - mo->vel.z = 3*FRACUNIT; + mo->Vel.X = pr_splatter.Random2 () / 64.; + mo->Vel.Y = pr_splatter.Random2() / 64.; + mo->Vel.Z = 3; // colorize the blood! if (bloodcolor!=0 && !(mo->flags2 & MF2_DONTTRANSLATE)) @@ -5505,8 +5505,8 @@ void P_RipperBlood (AActor *mo, AActor *bleeder) if (th->flags5 & MF5_PUFFGETSOWNER) th->target = bleeder; if (gameinfo.gametype == GAME_Heretic) th->flags |= MF_NOGRAVITY; - th->vel.x = mo->vel.x >> 1; - th->vel.y = mo->vel.y >> 1; + th->Vel.X = mo->Vel.X / 2; + th->Vel.Y = mo->Vel.Y / 2; th->tics += pr_ripperblood () & 3; // colorize the blood! @@ -5561,17 +5561,17 @@ bool P_HitWater (AActor * thing, sector_t * sec, fixed_t x, fixed_t y, fixed_t z int terrainnum; sector_t *hsec = NULL; - if (x == FIXED_MIN) x = thing->X(); - if (y == FIXED_MIN) y = thing->Y(); - if (z == FIXED_MIN) z = thing->Z(); + if (x == FIXED_MIN) x = thing->_f_X(); + if (y == FIXED_MIN) y = thing->_f_Y(); + if (z == FIXED_MIN) z = thing->_f_Z(); // don't splash above the object if (checkabove) { - fixed_t compare_z = thing->Z() + (thing->height >> 1); + fixed_t compare_z = thing->_f_Z() + (thing->height >> 1); // Missiles are typically small and fast, so they might // end up submerged by the move that calls P_HitWater. if (thing->flags & MF_MISSILE) - compare_z -= thing->vel.z; + compare_z -= thing->_f_velz(); if (z > compare_z) return false; } @@ -5635,7 +5635,7 @@ foundone: // Don't splash for living things with small vertical velocities. // There are levels where the constant splashing from the monsters gets extremely annoying - if (((thing->flags3&MF3_ISMONSTER || thing->player) && thing->vel.z >= -6*FRACUNIT) && !force) + if (((thing->flags3&MF3_ISMONSTER || thing->player) && thing->_f_velz() >= -6*FRACUNIT) && !force) return Terrains[terrainnum].IsLiquid; splash = &Splashes[splashnum]; @@ -5657,13 +5657,13 @@ foundone: mo->target = thing; if (splash->ChunkXVelShift != 255) { - mo->vel.x = pr_chunk.Random2() << splash->ChunkXVelShift; + mo->Vel.X = (pr_chunk.Random2() << splash->ChunkXVelShift) / 65536.; } if (splash->ChunkYVelShift != 255) { - mo->vel.y = pr_chunk.Random2() << splash->ChunkYVelShift; + mo->Vel.Y = (pr_chunk.Random2() << splash->ChunkYVelShift) / 65536.; } - mo->vel.z = splash->ChunkBaseZVel + (pr_chunk() << splash->ChunkZVelShift); + mo->Vel.Z = splash->ChunkBaseZVel + (pr_chunk() << splash->ChunkZVelShift) / 65536.; } if (splash->SplashBase) { @@ -5704,7 +5704,7 @@ bool P_HitFloor (AActor *thing) // killough 11/98: touchy objects explode on impact // Allow very short drops to be safe, so that a touchy can be summoned without exploding. - if (thing->flags6 & MF6_TOUCHY && ((thing->flags6 & MF6_ARMED) || thing->IsSentient()) && ((thing->vel.z) < (-5 * FRACUNIT))) + if (thing->flags6 & MF6_TOUCHY && ((thing->flags6 & MF6_ARMED) || thing->IsSentient()) && ((thing->_f_velz()) < (-5 * FRACUNIT))) { thing->flags6 &= ~MF6_ARMED; // Disarm P_DamageMobj (thing, NULL, NULL, thing->health, NAME_Crush, DMG_FORCED); // kill object @@ -5719,7 +5719,7 @@ bool P_HitFloor (AActor *thing) for (m = thing->touching_sectorlist; m; m = m->m_tnext) { pos = thing->PosRelative(m->m_sector); - if (thing->Z() == m->m_sector->floorplane.ZatPoint(pos.x, pos.y)) + if (thing->_f_Z() == m->m_sector->floorplane.ZatPoint(pos.x, pos.y)) { break; } @@ -5731,7 +5731,7 @@ bool P_HitFloor (AActor *thing) if (!(rover->flags & FF_EXISTS)) continue; if (rover->flags & (FF_SOLID|FF_SWIMMABLE)) { - if (rover->top.plane->ZatPoint(pos.x, pos.y) == thing->Z()) + if (rover->top.plane->ZatPoint(pos.x, pos.y) == thing->_f_Z()) { return P_HitWater (thing, m->m_sector, pos); } @@ -5758,7 +5758,7 @@ void P_CheckSplash(AActor *self, fixed_t distance) { sector_t *floorsec; self->Sector->LowestFloorAt(self, &floorsec); - if (self->Z() <= self->floorz + distance && self->floorsector == floorsec && self->Sector->GetHeightSec() == NULL && floorsec->heightsec == NULL) + if (self->_f_Z() <= self->floorz + distance && self->floorsector == floorsec && self->Sector->GetHeightSec() == NULL && floorsec->heightsec == NULL) { // Explosion splashes never alert monsters. This is because A_Explode has // a separate parameter for that so this would get in the way of proper @@ -5790,7 +5790,7 @@ bool P_CheckMissileSpawn (AActor* th, fixed_t maxdist) if (maxdist > 0) { // move a little forward so an angle can be computed if it immediately explodes - DVector3 advance(FIXED2DBL(th->vel.x), FIXED2DBL(th->vel.y), FIXED2DBL(th->vel.z)); + DVector3 advance(FIXED2DBL(th->_f_velx()), FIXED2DBL(th->_f_vely()), FIXED2DBL(th->_f_velz())); double maxsquared = FIXED2DBL(maxdist); maxsquared *= maxsquared; @@ -5802,9 +5802,9 @@ bool P_CheckMissileSpawn (AActor* th, fixed_t maxdist) } while (DVector2(advance).LengthSquared() >= maxsquared); th->SetXYZ( - th->X() + FLOAT2FIXED(advance.X), - th->Y() + FLOAT2FIXED(advance.Y), - th->Z() + FLOAT2FIXED(advance.Z)); + th->_f_X() + FLOAT2FIXED(advance.X), + th->_f_Y() + FLOAT2FIXED(advance.Y), + th->_f_Z() + FLOAT2FIXED(advance.Z)); } FCheckPosition tm(!!(th->flags2 & MF2_RIP)); @@ -5828,7 +5828,7 @@ bool P_CheckMissileSpawn (AActor* th, fixed_t maxdist) bool MBFGrenade = (!(th->flags & MF_MISSILE) || (th->BounceFlags & BOUNCE_MBF)); // killough 3/15/98: no dropoff (really = don't care for missiles) - if (!(P_TryMove (th, th->X(), th->Y(), false, NULL, tm, true))) + if (!(P_TryMove (th, th->_f_X(), th->_f_Y(), false, NULL, tm, true))) { // [RH] Don't explode ripping missiles that spawn inside something if (th->BlockingMobj == NULL || !(th->flags2 & MF2_RIP) || (th->BlockingMobj->flags5 & MF5_DONTRIP)) @@ -5882,7 +5882,7 @@ void P_PlaySpawnSound(AActor *missile, AActor *spawner) // If there is no spawner use the spawn position. // But not in a silenced sector. if (!(missile->Sector->Flags & SECF_SILENT)) - S_Sound (missile->X(), missile->Y(), missile->Z(), CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM); + S_Sound (missile->_f_X(), missile->_f_Y(), missile->_f_Z(), CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM); } } } @@ -5892,9 +5892,9 @@ static fixed_t GetDefaultSpeed(PClassActor *type) if (type == NULL) return 0; else if (G_SkillProperty(SKILLP_FastMonsters) && type->FastSpeed >= 0) - return type->FastSpeed; + return FLOAT2FIXED(type->FastSpeed); else - return GetDefaultByType(type)->Speed; + return GetDefaultByType(type)->_f_speed(); } //--------------------------------------------------------------------------- @@ -5912,7 +5912,7 @@ AActor *P_SpawnMissile (AActor *source, AActor *dest, PClassActor *type, AActor { return NULL; } - return P_SpawnMissileXYZ (source->X(), source->Y(), source->Z() + 32*FRACUNIT + source->GetBobOffset(), + return P_SpawnMissileXYZ (source->_f_X(), source->_f_Y(), source->_f_Z() + 32*FRACUNIT + source->GetBobOffset(), source, dest, type, true, owner); } @@ -5922,7 +5922,7 @@ AActor *P_SpawnMissileZ (AActor *source, fixed_t z, AActor *dest, PClassActor *t { return NULL; } - return P_SpawnMissileXYZ (source->X(), source->Y(), z, source, dest, type); + return P_SpawnMissileXYZ (source->_f_X(), source->_f_Y(), z, source, dest, type); } AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, @@ -5953,7 +5953,7 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, if (owner == NULL) owner = source; th->target = owner; - float speed = (float)(th->Speed); + double speed = th->Speed; // [RH] // Hexen calculates the missile velocity based on the source's location. @@ -5961,34 +5961,32 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, // missile? // Answer: No, because this way, you can set up sets of parallel missiles. - fixedvec3 fixvel = source->Vec3To(dest); - DVector3 velocity(fixvel.x, fixvel.y, fixvel.z); + DVector3 velocity = source->Vec3To(dest); // Floor and ceiling huggers should never have a vertical component to their velocity if (th->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)) { velocity.Z = 0; } // [RH] Adjust the trajectory if the missile will go over the target's head. - else if (z - source->Z() >= dest->height) + else if (FIXED2FLOAT(z) - source->Z() >= dest->_Height()) { - velocity.Z += (dest->height - z + source->Z()); + velocity.Z += (dest->_Height() - FIXED2FLOAT(z) + source->Z()); } - velocity.Resize (speed); - th->vel.x = xs_CRoundToInt(velocity.X); - th->vel.y = xs_CRoundToInt(velocity.Y); - th->vel.z = xs_CRoundToInt(velocity.Z); + th->Vel = velocity.Resized(speed); // invisible target: rotate velocity vector in 2D // [RC] Now monsters can aim at invisible player as if they were fully visible. if (dest->flags & MF_SHADOW && !(source->flags6 & MF6_SEEINVISIBLE)) { - angle_t an = pr_spawnmissile.Random2 () << 20; - an >>= ANGLETOFINESHIFT; + DAngle an = pr_spawnmissile.Random2() * (22.5 / 256); + double c = an.Cos(); + double s = an.Sin(); - fixed_t newx = DMulScale16 (th->vel.x, finecosine[an], -th->vel.y, finesine[an]); - fixed_t newy = DMulScale16 (th->vel.x, finesine[an], th->vel.y, finecosine[an]); - th->vel.x = newx; - th->vel.y = newy; + double newx = th->Vel.X * c - th->Vel.Y * s; + double newy = th->Vel.X * s + th->Vel.Y * c; + + th->Vel.X = newx; + th->Vel.Y = newy; } th->AngleFromVel(); @@ -6007,7 +6005,6 @@ AActor *P_OldSpawnMissile(AActor *source, AActor *owner, AActor *dest, PClassAct { return NULL; } - fixed_t dist; AActor *th = Spawn (type, source->PosPlusZ(4*8*FRACUNIT), ALLOW_REPLACE); P_PlaySpawnSound(th, source); @@ -6016,13 +6013,9 @@ AActor *P_OldSpawnMissile(AActor *source, AActor *owner, AActor *dest, PClassAct th->Angles.Yaw = source->AngleTo(dest); th->VelFromAngle(); - dist = source->AproxDistance (dest); - if (th->Speed) dist = dist / th->Speed; - if (dist < 1) - dist = 1; - - th->vel.z = (dest->Z() - source->Z()) / dist; + double dist = source->DistanceBySpeed(dest, MAX(1., th->Speed)); + th->Vel.Z = (dest->Z() - source->Z()) / dist; if (th->flags4 & MF4_SPECTRAL) { @@ -6049,7 +6042,7 @@ AActor *P_SpawnMissileAngle (AActor *source, PClassActor *type, { return NULL; } - return P_SpawnMissileAngleZSpeed (source, source->Z() + 32*FRACUNIT + source->GetBobOffset(), + return P_SpawnMissileAngleZSpeed (source, source->_f_Z() + 32*FRACUNIT + source->GetBobOffset(), type, angle, vz, GetDefaultSpeed (type)); } @@ -6080,7 +6073,7 @@ AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, PClassAct dist = source->AproxDistance (dest); speed = GetDefaultSpeed (type); dist /= speed; - vz = dist != 0 ? (dest->Z() - source->Z())/dist : speed; + vz = dist != 0 ? (dest->_f_Z() - source->_f_Z())/dist : speed; return P_SpawnMissileAngleZSpeed (source, z, type, an, vz, speed); } @@ -6100,7 +6093,7 @@ AActor *P_SpawnMissileAngleSpeed (AActor *source, PClassActor *type, { return NULL; } - return P_SpawnMissileAngleZSpeed (source, source->Z() + 32*FRACUNIT + source->GetBobOffset(), + return P_SpawnMissileAngleZSpeed (source, source->_f_Z() + 32*FRACUNIT + source->GetBobOffset(), type, angle, vz, speed); } @@ -6118,14 +6111,14 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, z -= source->floorclip; } - mo = Spawn (type, source->X(), source->Y(), z, ALLOW_REPLACE); + mo = Spawn (type, source->_f_X(), source->_f_Y(), z, ALLOW_REPLACE); P_PlaySpawnSound(mo, source); if (owner == NULL) owner = source; mo->target = owner; mo->Angles.Yaw = ANGLE2DBL(angle); - mo->VelFromAngle(speed); - mo->vel.z = vz; + mo->VelFromAngle(FIXED2DBL(speed)); + mo->Vel.Z = FIXED2DBL(vz); if (mo->flags4 & MF4_SPECTRAL) { @@ -6217,10 +6210,10 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, if (z != ONFLOORZ && z != ONCEILINGZ) { // Doom spawns missiles 4 units lower than hitscan attacks for players. - z += source->Z() + (source->height>>1) - source->floorclip; + z += source->_f_Z() + (source->height>>1) - source->floorclip; if (source->player != NULL) // Considering this is for player missiles, it better not be NULL. { - z += FixedMul (source->player->mo->AttackZOffset - 4*FRACUNIT, source->player->crouchfactor); + z += fixed_t ((source->player->mo->AttackZOffset - 4*FRACUNIT) * source->player->crouchfactor); } else { @@ -6577,10 +6570,10 @@ DDropItem *AActor::GetDropItems() const return GetClass()->DropItems; } -fixed_t AActor::GetGravity() const +double AActor::GetGravity() const { if (flags & MF_NOGRAVITY) return 0; - return fixed_t(level.gravity * Sector->gravity * FIXED2DBL(gravity) * 81.92); + return level.gravity * Sector->gravity * FIXED2DBL(gravity) * 0.00125; } // killough 11/98: @@ -6719,10 +6712,9 @@ void PrintMiscActorInfo(AActor *query) query->args[4], query->special1, query->special2); Printf("\nTID: %d", query->tid); Printf("\nCoord= x: %f, y: %f, z:%f, floor:%f, ceiling:%f.", - FIXED2DBL(query->X()), FIXED2DBL(query->Y()), FIXED2DBL(query->Z()), + query->X(), query->Y(), query->Z(), FIXED2DBL(query->floorz), FIXED2DBL(query->ceilingz)); Printf("\nSpeed= %f, velocity= x:%f, y:%f, z:%f, combined:%f.\n", - FIXED2DBL(query->Speed), FIXED2DBL(query->vel.x), FIXED2DBL(query->vel.y), FIXED2DBL(query->vel.z), - g_sqrt(pow(FIXED2DBL(query->vel.x), 2) + pow(FIXED2DBL(query->vel.y), 2) + pow(FIXED2DBL(query->vel.z), 2))); + query->Speed, query->Vel.X, query->Vel.Y, query->Vel.Z, query->Vel.Length()); } } diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index c33938d76..2fef1b625 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -394,7 +394,7 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y) // [RH] Smooth transitions between bobbing and not-bobbing frames. // This also fixes the bug where you can "stick" a weapon off-center by // shooting it when it's at the peak of its swing. - bobtarget = (player->WeaponState & WF_WEAPONBOBBING) ? player->bob : 0; + bobtarget = (player->WeaponState & WF_WEAPONBOBBING) ? FLOAT2FIXED(player->bob) : 0; if (curbob != bobtarget) { if (abs (bobtarget - curbob) <= 1*FRACUNIT) @@ -417,8 +417,8 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y) if (curbob != 0) { - fixed_t bobx = FixedMul(player->bob, rangex); - fixed_t boby = FixedMul(player->bob, rangey); + fixed_t bobx = fixed_t(player->bob * rangex); + fixed_t boby = fixed_t(player->bob * rangey); switch (bobstyle) { case AWeapon::BobNormal: diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 27c8493ea..43560b516 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -1027,6 +1027,32 @@ fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags, // //=========================================================================== +fixed_t sector_t::GetFriction(int plane, fixed_t *pMoveFac) const +{ + if (Flags & SECF_FRICTION) + { + if (pMoveFac) *pMoveFac = movefactor; + return friction; + } + FTerrainDef *terrain = &Terrains[GetTerrain(plane)]; + if (terrain->Friction != 0) + { + if (pMoveFac) *pMoveFac = terrain->MoveFactor; + return terrain->Friction; + } + else + { + if (pMoveFac) *pMoveFac = ORIG_FRICTION_FACTOR; + return ORIG_FRICTION; + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + FArchive &operator<< (FArchive &arc, secspecial_t &p) { if (SaveVersion < 4529) diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 7669ac888..27ee0db34 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -863,16 +863,16 @@ sightcounts[0]++; if (!(flags & SF_IGNOREWATERBOUNDARY)) { if ((s1->GetHeightSec() && - ((t1->Z() + t1->height <= s1->heightsec->floorplane.ZatPoint(t1) && - t2->Z() >= s1->heightsec->floorplane.ZatPoint(t2)) || - (t1->Z() >= s1->heightsec->ceilingplane.ZatPoint(t1) && - t2->Z() + t1->height <= s1->heightsec->ceilingplane.ZatPoint(t2)))) + ((t1->_f_Z() + t1->height <= s1->heightsec->floorplane.ZatPoint(t1) && + t2->_f_Z() >= s1->heightsec->floorplane.ZatPoint(t2)) || + (t1->_f_Z() >= s1->heightsec->ceilingplane.ZatPoint(t1) && + t2->_f_Z() + t1->height <= s1->heightsec->ceilingplane.ZatPoint(t2)))) || (s2->GetHeightSec() && - ((t2->Z() + t2->height <= s2->heightsec->floorplane.ZatPoint(t2) && - t1->Z() >= s2->heightsec->floorplane.ZatPoint(t1)) || - (t2->Z() >= s2->heightsec->ceilingplane.ZatPoint(t2) && - t1->Z() + t2->height <= s2->heightsec->ceilingplane.ZatPoint(t1))))) + ((t2->_f_Z() + t2->height <= s2->heightsec->floorplane.ZatPoint(t2) && + t1->_f_Z() >= s2->heightsec->floorplane.ZatPoint(t1)) || + (t2->_f_Z() >= s2->heightsec->ceilingplane.ZatPoint(t2) && + t1->_f_Z() + t2->height <= s2->heightsec->ceilingplane.ZatPoint(t1))))) { res = false; goto done; @@ -889,7 +889,7 @@ sightcounts[0]++; fixed_t lookheight = t1->height - (t1->height >> 2); t1->GetPortalTransition(lookheight, &sec); - fixed_t bottomslope = t2->Z() - (t1->Z() + lookheight); + fixed_t bottomslope = t2->_f_Z() - (t1->_f_Z() + lookheight); fixed_t topslope = bottomslope + t2->height; SightTask task = { 0, topslope, bottomslope, -1, sec->PortalGroup }; diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 72cdc140b..baa8034ad 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -139,12 +139,9 @@ void DPusher::Serialize (FArchive &arc) Super::Serialize (arc); arc << m_Type << m_Source - << m_Xmag - << m_Ymag + << m_PushVec << m_Magnitude << m_Radius - << m_X - << m_Y << m_Affectee; } @@ -439,7 +436,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector) { // Falling, not all the way down yet? sector = player->mo->Sector; - if (player->mo->Z() != sector->LowestFloorAt(player->mo) + if (player->mo->_f_Z() != sector->LowestFloorAt(player->mo) && !player->mo->waterlevel) { return; @@ -516,7 +513,7 @@ static void DoSectorDamage(AActor *actor, sector_t *sec, int amount, FName type, if (!(flags & DAMAGE_PLAYERS) && actor->player != NULL) return; - if (!(flags & DAMAGE_IN_AIR) && actor->Z() != sec->floorplane.ZatPoint(actor) && !actor->waterlevel) + if (!(flags & DAMAGE_IN_AIR) && actor->_f_Z() != sec->floorplane.ZatPoint(actor) && !actor->waterlevel) return; if (protectClass != NULL) @@ -562,12 +559,12 @@ void P_SectorDamage(int tag, int amount, FName type, PClassActor *protectClass, z1 = z2; z2 = zz; } - if (actor->Z() + actor->height > z1) + if (actor->_f_Z() + actor->height > z1) { // If DAMAGE_IN_AIR is used, anything not beneath the 3D floor will be // damaged (so, anything touching it or above it). Other 3D floors between // the actor and this one will not stop this effect. - if ((flags & DAMAGE_IN_AIR) || actor->Z() <= z2) + if ((flags & DAMAGE_IN_AIR) || actor->_f_Z() <= z2) { // Here we pass the DAMAGE_IN_AIR flag to disable the floor check, since it // only works with the real sector's floor. We did the appropriate height checks @@ -1078,7 +1075,7 @@ void P_SpawnSkybox(ASkyViewpoint *origin) if (Sector == NULL) { Printf("Sector not initialized for SkyCamCompat\n"); - origin->Sector = Sector = P_PointInSector(origin->X(), origin->Y()); + origin->Sector = Sector = P_PointInSector(origin->_f_X(), origin->_f_Y()); } if (Sector) { @@ -1466,7 +1463,7 @@ void P_SpawnSpecials (void) { case Init_Gravity: { - float grav = ((float)P_AproxDistance (lines[i].dx, lines[i].dy)) / (FRACUNIT * 100.0f); + double grav = lines[i].Delta().Length() / 100.; FSectorTagIterator itr(lines[i].args[0]); while ((s = itr.Next()) >= 0) sectors[s].gravity = grav; @@ -2162,7 +2159,7 @@ void P_SetSectorFriction (int tag, int amount, bool alterFlag) // types 1 & 2 is the sector containing the MT_PUSH/MT_PULL Thing. -#define PUSH_FACTOR 7 +#define PUSH_FACTOR 128 ///////////////////////////// // @@ -2175,9 +2172,8 @@ DPusher::DPusher (DPusher::EPusher type, line_t *l, int magnitude, int angle, m_Type = type; if (l) { - m_Xmag = l->dx>>FRACBITS; - m_Ymag = l->dy>>FRACBITS; - m_Magnitude = P_AproxDistance (m_Xmag, m_Ymag); + m_PushVec = l->Delta(); + m_Magnitude = m_PushVec.Length(); } else { // [RH] Allow setting magnitude and angle with parameters @@ -2185,9 +2181,7 @@ DPusher::DPusher (DPusher::EPusher type, line_t *l, int magnitude, int angle, } if (source) // point source exist? { - m_Radius = (m_Magnitude) << (FRACBITS+1); // where force goes to zero - m_X = m_Source->X(); - m_Y = m_Source->Y(); + m_Radius = m_Magnitude * 2; // where force goes to zero } m_Affectee = affectee; } @@ -2211,7 +2205,6 @@ void DPusher::Tick () sector_t *sec; AActor *thing; msecnode_t *node; - int xspeed,yspeed; int ht; if (!var_pushers) @@ -2250,7 +2243,7 @@ void DPusher::Tick () // point pusher. Crosses sectors, so use blockmap. FPortalGroupArray check(FPortalGroupArray::PGA_NoSectorPortals); // no sector portals because this thing is utterly z-unaware. - FMultiBlockThingsIterator it(check, m_X, m_Y, 0, 0, m_Radius, false, m_Source->Sector); + FMultiBlockThingsIterator it(check, m_Source, FLOAT2FIXED(m_Radius)); FMultiBlockThingsIterator::CheckResult cres; @@ -2269,22 +2262,18 @@ void DPusher::Tick () if ((pusharound) ) { - int sx = m_X; - int sy = m_Y; - int dist = thing->AproxDistance (sx, sy); - int speed = (m_Magnitude - ((dist>>FRACBITS)>>1))<<(FRACBITS-PUSH_FACTOR-1); + DVector2 pos = m_Source->Vec2To(thing); + double dist = pos.Length(); + double speed = (m_Magnitude - (dist/2)) / (PUSH_FACTOR * 2); // If speed <= 0, you're outside the effective radius. You also have // to be able to see the push/pull source point. if ((speed > 0) && (P_CheckSight (thing, m_Source, SF_IGNOREVISIBILITY))) { - angle_t pushangle = thing->__f_AngleTo(sx, sy); - if (m_Source->GetClass()->TypeName == NAME_PointPusher) - pushangle += ANG180; // away - pushangle >>= ANGLETOFINESHIFT; - thing->vel.x += FixedMul (speed, finecosine[pushangle]); - thing->vel.y += FixedMul (speed, finesine[pushangle]); + DAngle pushangle = pos.Angle(); + if (m_Source->GetClass()->TypeName == NAME_PointPuller) pushangle += 180; + thing->Thrust(pushangle, speed); } } } @@ -2302,37 +2291,34 @@ void DPusher::Tick () sector_t *hsec = sec->GetHeightSec(); fixedvec3 pos = thing->PosRelative(sec); + DVector2 pushvel; if (m_Type == p_wind) { if (hsec == NULL) { // NOT special water sector - if (thing->Z() > thing->floorz) // above ground + if (thing->_f_Z() > thing->floorz) // above ground { - xspeed = m_Xmag; // full force - yspeed = m_Ymag; + pushvel = m_PushVec; // full force } else // on ground { - xspeed = (m_Xmag)>>1; // half force - yspeed = (m_Ymag)>>1; + pushvel = m_PushVec / 2; // half force } } else // special water sector { ht = hsec->floorplane.ZatPoint(pos); - if (thing->Z() > ht) // above ground + if (thing->_f_Z() > ht) // above ground { - xspeed = m_Xmag; // full force - yspeed = m_Ymag; + pushvel = m_PushVec; // full force } else if (thing->player->viewz < ht) // underwater { - xspeed = yspeed = 0; // no force + pushvel.Zero(); // no force } else // wading in water { - xspeed = (m_Xmag)>>1; // half force - yspeed = (m_Ymag)>>1; + pushvel = m_PushVec / 2; // full force } } } @@ -2348,18 +2334,16 @@ void DPusher::Tick () { // special water sector floor = &hsec->floorplane; } - if (thing->Z() > floor->ZatPoint(pos)) + if (thing->_f_Z() > floor->ZatPoint(pos)) { // above ground - xspeed = yspeed = 0; // no force + pushvel.Zero(); // no force } else { // on ground/underwater - xspeed = m_Xmag; // full force - yspeed = m_Ymag; + pushvel = m_PushVec; // full force } } - thing->vel.x += xspeed<<(FRACBITS-PUSH_FACTOR); - thing->vel.y += yspeed<<(FRACBITS-PUSH_FACTOR); + thing->Vel += pushvel / PUSH_FACTOR; } } diff --git a/src/p_spec.h b/src/p_spec.h index fe4f39ec5..0c0624b87 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -95,7 +95,8 @@ private: // Factor to scale scrolling effect into mobj-carrying properties = 3/32. // (This is so scrolling floors and objects on them can move at same speed.) -enum { CARRYFACTOR = (3*FRACUNIT >> 5) }; +enum { _f_CARRYFACTOR = (3*FRACUNIT >> 5) }; +const double CARRYFACTOR = 3 / 32.; // phares 3/20/98: added new model of Pushers for push/pull effects @@ -118,9 +119,8 @@ public: int CheckForSectorMatch (EPusher type, int tag); void ChangeValues (int magnitude, int angle) { - angle_t ang = ((angle_t)(angle<<24)) >> ANGLETOFINESHIFT; - m_Xmag = (magnitude * finecosine[ang]) >> FRACBITS; - m_Ymag = (magnitude * finesine[ang]) >> FRACBITS; + DAngle ang = angle * (360. / 256.); + m_PushVec = ang.ToVector(magnitude); m_Magnitude = magnitude; } @@ -129,12 +129,9 @@ public: protected: EPusher m_Type; TObjPtr m_Source;// Point source if point pusher - int m_Xmag; // X Strength - int m_Ymag; // Y Strength - int m_Magnitude; // Vector strength for point pusher - int m_Radius; // Effective radius for point pusher - int m_X; // X of point source if point pusher - int m_Y; // Y of point source if point pusher + DVector2 m_PushVec; + double m_Magnitude; // Vector strength for point pusher + double m_Radius; // Effective radius for point pusher int m_Affectee; // Number of affected sector friend bool PIT_PushThing (AActor *thing); diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 13b29e6de..7871b8aaa 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -170,7 +170,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo onesided: fixed_t sectorc = front->ceilingplane.ZatPoint(checkx, checky); fixed_t sectorf = front->floorplane.ZatPoint(checkx, checky); - return (user->Top() >= sectorf && user->Z() <= sectorc); + return (user->_f_Top() >= sectorf && user->_f_Z() <= sectorc); } // Now get the information from the line. @@ -190,8 +190,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_UPPERTEXTURE)) continue; - if (user->Z() > rover->top.plane->ZatPoint(checkx, checky) || - user->Top() < rover->bottom.plane->ZatPoint(checkx, checky)) + if (user->_f_Z() > rover->top.plane->ZatPoint(checkx, checky) || + user->_f_Top() < rover->bottom.plane->ZatPoint(checkx, checky)) continue; // This 3D floor depicts a switch texture in front of the player's eyes @@ -199,7 +199,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo } } - return (user->Top() > open.top); + return (user->_f_Top() > open.top); } else if ((TexMan.FindSwitch(side->GetTexture(side_t::bottom))) != NULL) { @@ -212,8 +212,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_LOWERTEXTURE)) continue; - if (user->Z() > rover->top.plane->ZatPoint(checkx, checky) || - user->Top() < rover->bottom.plane->ZatPoint(checkx, checky)) + if (user->_f_Z() > rover->top.plane->ZatPoint(checkx, checky) || + user->_f_Top() < rover->bottom.plane->ZatPoint(checkx, checky)) continue; // This 3D floor depicts a switch texture in front of the player's eyes @@ -221,7 +221,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo } } - return (user->Z() < open.bottom); + return (user->_f_Z() < open.bottom); } else if ((flags & ML_3DMIDTEX) || (TexMan.FindSwitch(side->GetTexture(side_t::mid))) != NULL) { @@ -229,12 +229,12 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo // to keep compatibility with Eternity's implementation. if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot)) return false; - return user->Z() < checktop && user->Top() > checkbot; + return user->_f_Z() < checktop && user->_f_Top() > checkbot; } else { // no switch found. Check whether the player can touch either top or bottom texture - return (user->Top() > open.top) || (user->Z() < open.bottom); + return (user->_f_Top() > open.top) || (user->_f_Z() < open.bottom); } } diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 2d91b197a..b60afea2a 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -109,10 +109,10 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i sector_t *destsect; bool resetpitch = false; fixed_t floorheight, ceilingheight; - fixed_t missilespeed = 0; + double missilespeed = 0; - old = thing->Pos(); - aboveFloor = thing->Z() - thing->floorz; + old = thing->_f_Pos(); + aboveFloor = thing->_f_Z() - thing->floorz; destsect = P_PointInSector (x, y); // killough 5/12/98: exclude voodoo dolls: player = thing->player; @@ -122,7 +122,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i ceilingheight = destsect->ceilingplane.ZatPoint (x, y); if (thing->flags & MF_MISSILE) { // We don't measure z velocity, because it doesn't change. - missilespeed = xs_CRoundToInt(DVector2(thing->vel.x, thing->vel.y).Length()); + missilespeed = thing->VelXYToSpeed(); } if (flags & TELF_KEEPHEIGHT) { @@ -168,7 +168,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i } if (player) { - player->viewz = thing->Z() + player->viewheight; + player->viewz = thing->_f_Z() + player->viewheight; if (resetpitch) { player->mo->Angles.Pitch = 0.; @@ -194,7 +194,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i fixed_t fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT; fixedvec2 vector = Vec2Angle(20 * FRACUNIT, angle); fixedvec2 fogpos = P_GetOffsetPosition(x, y, vector.x, vector.y); - P_SpawnTeleportFog(thing, fogpos.x, fogpos.y, thing->Z() + fogDelta, false, true); + P_SpawnTeleportFog(thing, fogpos.x, fogpos.y, thing->_f_Z() + fogDelta, false, true); } if (thing->player) @@ -219,10 +219,9 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i // [BC] && bHaltVelocity. else if (!(flags & TELF_KEEPORIENTATION) && !(flags & TELF_KEEPVELOCITY)) { // no fog doesn't alter the player's momentum - thing->vel.x = thing->vel.y = thing->vel.z = 0; + thing->Vel.Zero(); // killough 10/98: kill all bobbing velocity too - if (player) - player->vel.x = player->vel.y = 0; + if (player) player->Vel.Zero(); } return true; } @@ -327,8 +326,8 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f AActor *searcher; fixed_t z; DAngle angle = 0.; - fixed_t s = 0, c = 0; - fixed_t vx = 0, vy = 0; + double s = 0, c = 0; + double vx = 0, vy = 0; DAngle badangle = 0.; if (thing == NULL) @@ -359,18 +358,18 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f angle = VecToAngle(line->dx, line->dy) - searcher->Angles.Yaw + 90; // Sine, cosine of angle adjustment - s = FLOAT2FIXED(angle.Sin()); - c = FLOAT2FIXED(angle.Cos()); + s = angle.Sin(); + c = angle.Cos(); // Velocity of thing crossing teleporter linedef - vx = thing->vel.x; - vy = thing->vel.y; + vx = thing->Vel.X; + vy = thing->Vel.Y; - z = searcher->Z(); + z = searcher->_f_Z(); } else if (searcher->IsKindOf (PClass::FindClass(NAME_TeleportDest2))) { - z = searcher->Z(); + z = searcher->_f_Z(); } else { @@ -380,7 +379,7 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f { badangle = 0.01; } - if (P_Teleport (thing, searcher->X(), searcher->Y(), z, searcher->Angles.Yaw + badangle, flags)) + if (P_Teleport (thing, searcher->_f_X(), searcher->_f_Y(), z, searcher->Angles.Yaw + badangle, flags)) { // [RH] Lee Killough's changes for silent teleporters from BOOM if (!(flags & TELF_DESTFOG) && line && (flags & TELF_KEEPORIENTATION)) @@ -389,10 +388,10 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f thing->Angles.Yaw += angle; // Rotate thing's velocity to come out of exit just like it entered - thing->vel.x = FixedMul(vx, c) - FixedMul(vy, s); - thing->vel.y = FixedMul(vy, c) + FixedMul(vx, s); + thing->Vel.X = vx*c - vy*s; + thing->Vel.Y = vy*c + vx*s; } - if ((vx | vy) == 0 && thing->player != NULL && thing->player->mo == thing && !predicting) + if (vx == 0 && vy == 0 && thing->player != NULL && thing->player->mo == thing && !predicting) { thing->player->mo->PlayIdle (); } @@ -427,65 +426,57 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO if ((l=lines+i) != line && l->backsector) { // Get the thing's position along the source linedef - SDWORD pos; // 30.2 fixed - fixed_t nposx, nposy; // offsets from line - { - SQWORD den; + double pos; + DVector2 npos; // offsets from line + double den; - den = (SQWORD)line->dx*line->dx + (SQWORD)line->dy*line->dy; - if (den == 0) + den = line->Delta().LengthSquared(); + if (den == 0) + { + pos = 0; + npos.Zero(); + } + else + { + double num = (thing->Pos().XY() - line->V1()) | line->Delta(); + if (num <= 0) { pos = 0; - nposx = 0; - nposy = 0; + } + else if (num >= den) + { + pos = 1; } else { - SQWORD num = (SQWORD)(thing->X()-line->v1->x)*line->dx + - (SQWORD)(thing->Y()-line->v1->y)*line->dy; - if (num <= 0) - { - pos = 0; - } - else if (num >= den) - { - pos = 1<<30; - } - else - { - pos = (SDWORD)(num / (den>>30)); - } - nposx = thing->X() - line->v1->x - MulScale30 (line->dx, pos); - nposy = thing->Y() - line->v1->y - MulScale30 (line->dy, pos); + pos = num / den; } + npos = thing->Pos().XY() - line->V1() - line->Delta() * pos; } // Get the angle between the two linedefs, for rotating // orientation and velocity. Rotate 180 degrees, and flip // the position across the exit linedef, if reversed. - angle_t angle = - R_PointToAngle2(0, 0, l->dx, l->dy) - - R_PointToAngle2(0, 0, line->dx, line->dy); + DAngle angle = VecToAngle(l->Delta()) - VecToAngle(line->Delta()); if (!reverse) { - angle += ANGLE_180; - pos = (1<<30) - pos; + angle += 180.; + pos = 1 - pos; } // Sine, cosine of angle adjustment - fixed_t s = finesine[angle>>ANGLETOFINESHIFT]; - fixed_t c = finecosine[angle>>ANGLETOFINESHIFT]; + double s = angle.Sin(); + double c = angle.Cos(); - fixed_t x, y; + DVector2 p; // Rotate position along normal to match exit linedef - x = DMulScale16 (nposx, c, -nposy, s); - y = DMulScale16 (nposy, c, nposx, s); + p.X = npos.X*c - npos.Y*s; + p.Y = npos.Y*c + npos.X*s; // Interpolate position across the exit linedef - x += l->v1->x + MulScale30 (pos, l->dx); - y += l->v1->y + MulScale30 (pos, l->dy); + p += l->V1() + pos*l->Delta(); // Whether this is a player, and if so, a pointer to its player_t. // Voodoo dolls are excluded by making sure thing->player->mo==thing. @@ -493,10 +484,12 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO thing->player : NULL; // Whether walking towards first side of exit linedef steps down + fixed_t x = FLOAT2FIXED(p.X); + fixed_t y = FLOAT2FIXED(p.Y); bool stepdown = l->frontsector->floorplane.ZatPoint(x, y) < l->backsector->floorplane.ZatPoint(x, y); // Height of thing above ground - fixed_t z = thing->Z() - thing->floorz; + fixed_t z = thing->_f_Z() - thing->floorz; // Side to exit the linedef on positionally. // @@ -549,24 +542,22 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO } // Rotate thing's orientation according to difference in linedef angles - thing->Angles.Yaw += ANGLE2DBL(angle); + thing->Angles.Yaw += angle; // Velocity of thing crossing teleporter linedef - x = thing->vel.x; - y = thing->vel.y; + p = thing->Vel.XY(); // Rotate thing's velocity to come out of exit just like it entered - thing->vel.x = DMulScale16 (x, c, -y, s); - thing->vel.y = DMulScale16 (y, c, x, s); + thing->Vel.X = p.X*c - p.Y*s; + thing->Vel.Y = p.Y*c + p.X*s; // Adjust a player's view, in case there has been a height change if (player && player->mo == thing) { // Adjust player's local copy of velocity - x = player->vel.x; - y = player->vel.y; - player->vel.x = DMulScale16 (x, c, -y, s); - player->vel.y = DMulScale16 (y, c, x, s); + p = player->Vel; + player->Vel.X = p.X*c - p.Y*s; + player->Vel.Y = p.Y*c + p.X*s; // Save the current deltaviewheight, used in stepping fixed_t deltaviewheight = player->deltaviewheight; @@ -610,15 +601,15 @@ bool EV_TeleportOther (int other_tid, int dest_tid, bool fog) static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool floorz, bool fog) { int an = (dest->_f_angle() - source->_f_angle()) >> ANGLETOFINESHIFT; - fixed_t offX = victim->X() - source->X(); - fixed_t offY = victim->Y() - source->Y(); + fixed_t offX = victim->_f_X() - source->_f_X(); + fixed_t offY = victim->_f_Y() - source->_f_Y(); fixed_t newX = DMulScale16 (offX, finecosine[an], -offY, finesine[an]); fixed_t newY = DMulScale16 (offX, finesine[an], offY, finecosine[an]); bool res = - P_Teleport (victim, dest->X() + newX, - dest->Y() + newY, - floorz ? ONFLOORZ : dest->Z() + victim->Z() - source->Z(), + P_Teleport (victim, dest->_f_X() + newX, + dest->_f_Y() + newY, + floorz ? ONFLOORZ : dest->_f_Z() + victim->_f_Z() - source->_f_Z(), 0., fog ? (TELF_DESTFOG | TELF_SOURCEFOG) : TELF_KEEPORIENTATION); // P_Teleport only changes angle if fog is true victim->Angles.Yaw = (dest->Angles.Yaw + victim->Angles.Yaw - source->Angles.Yaw).Normalized360(); @@ -686,8 +677,8 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t if (moveSource && didSomething) { didSomething |= - P_Teleport (sourceOrigin, destOrigin->X(), destOrigin->Y(), - floorz ? ONFLOORZ : destOrigin->Z(), 0., TELF_KEEPORIENTATION); + P_Teleport (sourceOrigin, destOrigin->_f_X(), destOrigin->_f_Y(), + floorz ? ONFLOORZ : destOrigin->_f_Z(), 0., TELF_KEEPORIENTATION); sourceOrigin->Angles.Yaw = destOrigin->Angles.Yaw; } diff --git a/src/p_terrain.cpp b/src/p_terrain.cpp index 3c6519393..df2662421 100644 --- a/src/p_terrain.cpp +++ b/src/p_terrain.cpp @@ -95,6 +95,7 @@ enum EGenericType GEN_Class, GEN_Splash, GEN_Float, + GEN_Double, GEN_Time, GEN_Bool, GEN_Int, @@ -201,7 +202,7 @@ static FGenericParse SplashParser[] = { GEN_Byte, {myoffsetof(FSplashDef, ChunkXVelShift)} }, { GEN_Byte, {myoffsetof(FSplashDef, ChunkYVelShift)} }, { GEN_Byte, {myoffsetof(FSplashDef, ChunkZVelShift)} }, - { GEN_Fixed, {myoffsetof(FSplashDef, ChunkBaseZVel)} }, + { GEN_Double, {myoffsetof(FSplashDef, ChunkBaseZVel)} }, { GEN_Bool, {myoffsetof(FSplashDef, NoAlert)} } }; @@ -360,7 +361,7 @@ static void SetSplashDefaults (FSplashDef *splashdef) splashdef->ChunkXVelShift = splashdef->ChunkYVelShift = splashdef->ChunkZVelShift = 8; - splashdef->ChunkBaseZVel = FRACUNIT; + splashdef->ChunkBaseZVel = 1; splashdef->SmallSplashClip = 12*FRACUNIT; splashdef->NoAlert = false; } @@ -595,6 +596,11 @@ static void GenericParse (FScanner &sc, FGenericParse *parser, const char **keyw SET_FIELD (float, float(sc.Float)); break; + case GEN_Double: + sc.MustGetFloat(); + SET_FIELD(double, sc.Float); + break; + case GEN_Time: sc.MustGetFloat (); SET_FIELD (int, (int)(sc.Float * TICRATE)); diff --git a/src/p_terrain.h b/src/p_terrain.h index 43d445c7e..b0cd74dad 100644 --- a/src/p_terrain.h +++ b/src/p_terrain.h @@ -95,9 +95,9 @@ struct FSplashDef BYTE ChunkXVelShift; BYTE ChunkYVelShift; BYTE ChunkZVelShift; - fixed_t ChunkBaseZVel; - fixed_t SmallSplashClip; bool NoAlert; + double ChunkBaseZVel; + fixed_t SmallSplashClip; }; struct FTerrainDef diff --git a/src/p_things.cpp b/src/p_things.cpp index 674a64bd4..3273e4f24 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -86,7 +86,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, i } while (spot != NULL) { - mobj = Spawn (kind, spot->Pos(), ALLOW_REPLACE); + mobj = Spawn (kind, spot->_f_Pos(), ALLOW_REPLACE); if (mobj != NULL) { @@ -98,7 +98,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, i mobj->Angles.Yaw = (angle != 1000000. ? angle : spot->Angles.Yaw); if (fog) { - P_SpawnTeleportFog(mobj, spot->X(), spot->Y(), spot->Z() + TELEFOGHEIGHT, false, true); + P_SpawnTeleportFog(mobj, spot->_f_X(), spot->_f_Y(), spot->_f_Z() + TELEFOGHEIGHT, false, true); } if (mobj->flags & MF_SPECIAL) mobj->flags |= MF_DROPPED; // Don't respawn @@ -127,9 +127,9 @@ bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog) { fixed_t oldx, oldy, oldz; - oldx = source->X(); - oldy = source->Y(); - oldz = source->Z(); + oldx = source->_f_X(); + oldy = source->_f_Y(); + oldz = source->_f_Z(); source->SetOrigin (x, y, z, true); if (P_TestMobjLocation (source)) @@ -167,20 +167,21 @@ bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog) if (source != NULL && target != NULL) { - return P_MoveThing(source, target->X(), target->Y(), target->Z(), fog); + return P_MoveThing(source, target->_f_X(), target->_f_Y(), target->_f_Z(), fog); } return false; } bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_name, DAngle angle, - fixed_t speed, fixed_t vspeed, int dest, AActor *forcedest, int gravity, int newtid, + fixed_t _speed, fixed_t _vspeed, int dest, AActor *forcedest, int gravity, int newtid, bool leadTarget) { int rtn = 0; PClassActor *kind; AActor *spot, *mobj, *targ = forcedest; FActorIterator iterator (tid); - double fspeed = speed; + double speed = FIXED2DBL(_speed); + double vspeed = FIXED2DBL(_vspeed); int defflags3; if (type_name == NULL) @@ -220,7 +221,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam { do { - fixed_t z = spot->Z(); + fixed_t z = spot->_f_Z(); if (defflags3 & MF3_FLOORHUGGER) { z = ONFLOORZ; @@ -233,7 +234,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam { z -= spot->floorclip; } - mobj = Spawn (kind, spot->X(), spot->Y(), z, ALLOW_REPLACE); + mobj = Spawn (kind, spot->_f_X(), spot->_f_Y(), z, ALLOW_REPLACE); if (mobj) { @@ -256,11 +257,10 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam if (targ != NULL) { - fixedvec3 vect = mobj->Vec3To(targ); - vect.z += targ->height / 2; - DVector3 aim(vect.x, vect.y, vect.z); + DVector3 aim = mobj->Vec3To(targ); + aim.Z += targ->_Height() / 2; - if (leadTarget && speed > 0 && (targ->vel.x | targ->vel.y | targ->vel.z)) + if (leadTarget && speed > 0 && !targ->Vel.isZero()) { // Aiming at the target's position some time in the future // is basically just an application of the law of sines: @@ -269,14 +269,14 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam // with the math. I don't think I would have thought of using // trig alone had I been left to solve it by myself. - DVector3 tvel(targ->vel.x, targ->vel.y, targ->vel.z); + DVector3 tvel = targ->Vel; if (!(targ->flags & MF_NOGRAVITY) && targ->waterlevel < 3) { // If the target is subject to gravity and not underwater, // assume that it isn't moving vertically. Thanks to gravity, // even if we did consider the vertical component of the target's // velocity, we would still miss more often than not. tvel.Z = 0.0; - if ((targ->vel.x | targ->vel.y) == 0) + if (targ->Vel.X == 0 && targ->Vel.Y == 0) { goto nolead; } @@ -286,7 +286,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam double ydotx = -aim | tvel; double a = g_acos (clamp (ydotx / targspeed / dist, -1.0, 1.0)); double multiplier = double(pr_leadtarget.Random2())*0.1/255+1.1; - double sinb = -clamp (targspeed*multiplier * g_sin(a) / fspeed, -1.0, 1.0); + double sinb = -clamp (targspeed*multiplier * g_sin(a) / speed, -1.0, 1.0); // Use the cross product of two of the triangle's sides to get a // rotation vector. @@ -299,20 +299,14 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam // new aim vector that leads the target. DVector3 aimvec = rm * aim; // And make the projectile follow that vector at the desired speed. - double aimscale = fspeed / dist; - mobj->vel.x = fixed_t (aimvec[0] * aimscale); - mobj->vel.y = fixed_t (aimvec[1] * aimscale); - mobj->vel.z = fixed_t (aimvec[2] * aimscale); + mobj->Vel = aimvec * (speed / dist); mobj->AngleFromVel(); } else { nolead: mobj->Angles.Yaw = mobj->AngleTo(targ); - aim.Resize (fspeed); - mobj->vel.x = fixed_t(aim[0]); - mobj->vel.y = fixed_t(aim[1]); - mobj->vel.z = fixed_t(aim[2]); + mobj->Vel = aim.Resized (speed); } if (mobj->flags2 & MF2_SEEKERMISSILE) { @@ -322,18 +316,18 @@ nolead: else { mobj->Angles.Yaw = angle; - mobj->VelFromAngle(); - mobj->vel.z = vspeed; + mobj->VelFromAngle(speed); + mobj->Vel.Z = vspeed; } // Set the missile's speed to reflect the speed it was spawned at. if (mobj->flags & MF_MISSILE) { - mobj->Speed = fixed_t (g_sqrt (double(mobj->vel.x)*mobj->vel.x + double(mobj->vel.y)*mobj->vel.y + double(mobj->vel.z)*mobj->vel.z)); + mobj->Speed = mobj->VelToSpeed(); } // Hugger missiles don't have any vertical velocity if (mobj->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)) { - mobj->vel.z = 0; + mobj->Vel.Z = 0; } if (mobj->flags & MF_SPECIAL) { @@ -427,7 +421,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser) AActor *info = thing->GetDefault (); - thing->vel.x = thing->vel.y = 0; + thing->Vel.X = thing->Vel.Y = 0; // [RH] Check against real height and radius fixed_t oldheight = thing->height; @@ -437,7 +431,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->Pos())) + if (!P_CheckPosition (thing, thing->_f_Pos())) { thing->flags = oldflags; thing->radius = oldradius; @@ -479,7 +473,7 @@ bool P_Thing_CanRaise(AActor *thing) thing->height = info->height; thing->radius = info->radius; - bool check = P_CheckPosition (thing, thing->Pos()); + bool check = P_CheckPosition (thing, thing->_f_Pos()); // Restore checked properties thing->flags = oldflags; @@ -494,22 +488,19 @@ bool P_Thing_CanRaise(AActor *thing) return true; } -void P_Thing_SetVelocity(AActor *actor, fixed_t vx, fixed_t vy, fixed_t vz, bool add, bool setbob) +void P_Thing_SetVelocity(AActor *actor, const DVector3 &vec, bool add, bool setbob) { if (actor != NULL) { if (!add) { - actor->vel.x = actor->vel.y = actor->vel.z = 0; - if (actor->player != NULL) actor->player->vel.x = actor->player->vel.y = 0; + actor->Vel.Zero(); + if (actor->player != NULL) actor->player->Vel.Zero(); } - actor->vel.x += vx; - actor->vel.y += vy; - actor->vel.z += vz; + actor->Vel += vec; if (setbob && actor->player != NULL) { - actor->player->vel.x += vx; - actor->player->vel.y += vy; + actor->player->Vel += vec.XY(); } } } @@ -692,7 +683,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, caller = temp; } - fixedvec3 old = caller->Pos(); + fixedvec3 old = caller->_f_Pos(); int oldpgroup = caller->Sector->PortalGroup; zofs += FixedMul(reference->height, heightoffset); @@ -730,7 +721,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, xofs + FixedMul(rad, finecosine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]), 0), true); - caller->SetZ(caller->floorz + zofs); + caller->_f_SetZ(caller->floorz + zofs); } else { @@ -745,7 +736,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, if (flags & WARPF_TOFLOOR) { caller->SetOrigin(xofs + FixedMul(rad, finecosine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]), zofs, true); - caller->SetZ(caller->floorz + zofs); + caller->_f_SetZ(caller->floorz + zofs); } else { @@ -771,15 +762,11 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, if (flags & WARPF_COPYVELOCITY) { - caller->vel.x = reference->vel.x; - caller->vel.y = reference->vel.y; - caller->vel.z = reference->vel.z; + caller->Vel = reference->Vel; } if (flags & WARPF_STOP) { - caller->vel.x = 0; - caller->vel.y = 0; - caller->vel.z = 0; + caller->Vel.Zero(); } // this is no fun with line portals @@ -787,9 +774,9 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, { // This just translates the movement but doesn't change the vector fixedvec3 displacedold = old + Displacements.getOffset(oldpgroup, caller->Sector->PortalGroup); - caller->PrevX += caller->X() - displacedold.x; - caller->PrevY += caller->Y() - displacedold.y; - caller->PrevZ += caller->Z() - displacedold.z; + caller->PrevX += caller->_f_X() - displacedold.x; + caller->PrevY += caller->_f_Y() - displacedold.y; + caller->PrevZ += caller->_f_Z() - displacedold.z; caller->PrevPortalGroup = caller->Sector->PortalGroup; } else if (flags & WARPF_COPYINTERPOLATION) @@ -797,9 +784,9 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, // Map both positions of the reference actor to the current portal group fixedvec3 displacedold = old + Displacements.getOffset(reference->PrevPortalGroup, caller->Sector->PortalGroup); fixedvec3 displacedref = old + Displacements.getOffset(reference->Sector->PortalGroup, caller->Sector->PortalGroup); - caller->PrevX = caller->X() + displacedold.x - displacedref.x; - caller->PrevY = caller->Y() + displacedold.y - displacedref.y; - caller->PrevZ = caller->Z() + displacedold.z - displacedref.z; + caller->PrevX = caller->_f_X() + displacedold.x - displacedref.x; + caller->PrevY = caller->_f_Y() + displacedold.y - displacedref.y; + caller->PrevZ = caller->_f_Z() + displacedold.z - displacedref.z; caller->PrevPortalGroup = caller->Sector->PortalGroup; } else if (!(flags & WARPF_INTERPOLATE)) @@ -808,7 +795,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, } if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB)) { - caller->AddZ(reference->GetBobOffset()); + caller->_f_AddZ(reference->GetBobOffset()); } } return true; diff --git a/src/p_trace.cpp b/src/p_trace.cpp index 1de5e7059..a28eb46e8 100644 --- a/src/p_trace.cpp +++ b/src/p_trace.cpp @@ -698,13 +698,13 @@ bool FTraceInfo::ThingCheck(intercept_t *in) fixed_t hity = StartY + FixedMul(Vy, dist); fixed_t hitz = StartZ + FixedMul(Vz, dist); - if (hitz > in->d.thing->Top()) + if (hitz > in->d.thing->_f_Top()) { // trace enters above actor if (Vz >= 0) return true; // Going up: can't hit // Does it hit the top of the actor? - dist = FixedDiv(in->d.thing->Top() - StartZ, Vz); + dist = FixedDiv(in->d.thing->_f_Top() - StartZ, Vz); if (dist > MaxDist) return true; in->frac = FixedDiv(dist, MaxDist); @@ -714,15 +714,15 @@ bool FTraceInfo::ThingCheck(intercept_t *in) hitz = StartZ + FixedMul(Vz, dist); // calculated coordinate is outside the actor's bounding box - if (abs(hitx - in->d.thing->X()) > in->d.thing->radius || - abs(hity - in->d.thing->Y()) > in->d.thing->radius) return true; + if (abs(hitx - in->d.thing->_f_X()) > in->d.thing->radius || + abs(hity - in->d.thing->_f_Y()) > in->d.thing->radius) return true; } - else if (hitz < in->d.thing->Z()) + else if (hitz < in->d.thing->_f_Z()) { // trace enters below actor if (Vz <= 0) return true; // Going down: can't hit // Does it hit the bottom of the actor? - dist = FixedDiv(in->d.thing->Z() - StartZ, Vz); + dist = FixedDiv(in->d.thing->_f_Z() - StartZ, Vz); if (dist > MaxDist) return true; in->frac = FixedDiv(dist, MaxDist); @@ -731,8 +731,8 @@ bool FTraceInfo::ThingCheck(intercept_t *in) hitz = StartZ + FixedMul(Vz, dist); // calculated coordinate is outside the actor's bounding box - if (abs(hitx - in->d.thing->X()) > in->d.thing->radius || - abs(hity - in->d.thing->Y()) > in->d.thing->radius) return true; + if (abs(hitx - in->d.thing->_f_X()) > in->d.thing->radius || + abs(hity - in->d.thing->_f_Y()) > in->d.thing->radius) return true; } if (CurSector->e->XFloor.ffloors.Size()) diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 778e99adf..bde7c256e 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1306,7 +1306,7 @@ public: if (floordrop) sec->Flags = SECF_FLOORDROP; // killough 3/7/98: end changes - sec->gravity = 1.f; // [RH] Default sector gravity of 1.0 + sec->gravity = 1.; // [RH] Default sector gravity of 1.0 sec->ZoneNumber = 0xFFFF; // killough 8/28/98: initialize all sectors to normal friction @@ -1444,7 +1444,7 @@ public: continue; case NAME_Gravity: - sec->gravity = float(CheckFloat(key)); + sec->gravity = CheckFloat(key); continue; case NAME_Lightcolor: diff --git a/src/p_user.cpp b/src/p_user.cpp index b06ca0e7d..f8b3fa828 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -238,7 +238,7 @@ CCMD (playerclasses) // // 16 pixels of bob -#define MAXBOB 0x100000 +#define MAXBOB 16. FArchive &operator<< (FArchive &arc, player_t *&p) { @@ -257,7 +257,7 @@ player_t::player_t() viewheight(0), deltaviewheight(0), bob(0), - vel({ 0,0 }), + Vel(0, 0), centering(0), turnticks(0), attackdown(0), @@ -336,8 +336,7 @@ player_t &player_t::operator=(const player_t &p) viewheight = p.viewheight; deltaviewheight = p.deltaviewheight; bob = p.bob; - vel.x = p.vel.x; - vel.y = p.vel.y; + Vel = p.Vel; centering = p.centering; turnticks = p.turnticks; attackdown = p.attackdown; @@ -745,7 +744,7 @@ void APlayerPawn::Tick() { if (player != NULL && player->mo == this && player->CanCrouch() && player->playerstate != PST_DEAD) { - height = FixedMul(GetDefault()->height, player->crouchfactor); + height = fixed_t(GetDefault()->height * player->crouchfactor); } else { @@ -769,7 +768,7 @@ void APlayerPawn::PostBeginPlay() if (player == NULL || player->mo != this) { P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS|FFCF_NOPORTALS); - SetZ(floorz); + _f_SetZ(floorz); P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS); } else @@ -1512,38 +1511,40 @@ void APlayerPawn::Die (AActor *source, AActor *inflictor, int dmgflags) // //=========================================================================== -void APlayerPawn::TweakSpeeds (int &forward, int &side) +void APlayerPawn::TweakSpeeds (double &forward, double &side) { - // Strife's player can't run when its healh is below 10 + // Strife's player can't run when its health is below 10 if (health <= RunHealth) { - forward = clamp(forward, -0x1900, 0x1900); - side = clamp(side, -0x1800, 0x1800); + forward = clamp(forward, -0x1900, 0x1900); + side = clamp(side, -0x1800, 0x1800); } // [GRB] - if ((unsigned int)(forward + 0x31ff) < 0x63ff) + if (fabs(forward) < 0x3200) { - forward = FixedMul (forward, ForwardMove1); + forward *= ForwardMove1; } else { - forward = FixedMul (forward, ForwardMove2); + forward *= ForwardMove2; } + + if (fabs(side) < 0x2800) if ((unsigned int)(side + 0x27ff) < 0x4fff) { - side = FixedMul (side, SideMove1); + side *= SideMove1; } else { - side = FixedMul (side, SideMove2); + side *= SideMove2; } if (!player->morphTics && Inventory != NULL) { - fixed_t factor = Inventory->GetSpeedFactor (); - forward = FixedMul(forward, factor); - side = FixedMul(side, factor); + double factor = Inventory->GetSpeedFactor (); + forward *= factor; + side *= factor; } } @@ -1579,7 +1580,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream) // Handle the different player death screams if ((((level.flags >> 15) | (dmflags)) & (DF_FORCE_FALLINGZD | DF_FORCE_FALLINGHX)) && - self->vel.z <= -39*FRACUNIT) + self->Vel.Z <= -39) { sound = S_FindSkinnedSound (self, "*splat"); chan = CHAN_BODY; @@ -1651,9 +1652,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop) self->flags &= ~MF_SOLID; mo = (APlayerPawn *)Spawn (spawntype, self->PosPlusZ(48*FRACUNIT), NO_REPLACE); //mo->target = self; - mo->vel.x = pr_skullpop.Random2() << 9; - mo->vel.y = pr_skullpop.Random2() << 9; - mo->vel.z = 2*FRACUNIT + (pr_skullpop() << 6); + mo->Vel.X = pr_skullpop.Random2() / 128.; + mo->Vel.Y = pr_skullpop.Random2() / 128.; + mo->Vel.Z = 2. + (pr_skullpop() / 1024.); // Attach player mobj to bloody skull player = self->player; self->player = NULL; @@ -1717,7 +1718,7 @@ void P_CheckPlayerSprite(AActor *actor, int &spritenum, fixed_t &scalex, fixed_t } // Set the crouch sprite? - if (player->crouchfactor < FRACUNIT*3/4) + if (player->crouchfactor < 0.75) { if (spritenum == actor->SpawnState->sprite || spritenum == player->mo->crouchsprite) { @@ -1738,7 +1739,7 @@ void P_CheckPlayerSprite(AActor *actor, int &spritenum, fixed_t &scalex, fixed_t { spritenum = crouchspriteno; } - else if (player->playerstate != PST_DEAD && player->crouchfactor < FRACUNIT*3/4) + else if (player->playerstate != PST_DEAD && player->crouchfactor < 0.75) { scaley /= 2; } @@ -1755,30 +1756,23 @@ void P_CheckPlayerSprite(AActor *actor, int &spritenum, fixed_t &scalex, fixed_t ================== */ -void P_SideThrust (player_t *player, angle_t angle, fixed_t move) +void P_SideThrust (player_t *player, DAngle angle, double move) { - angle = (angle - ANGLE_90) >> ANGLETOFINESHIFT; - - player->mo->vel.x += FixedMul (move, finecosine[angle]); - player->mo->vel.y += FixedMul (move, finesine[angle]); + player->mo->Thrust(angle-90, move); } -void P_ForwardThrust (player_t *player, angle_t angle, fixed_t move) +void P_ForwardThrust (player_t *player, DAngle angle, double move) { - angle >>= ANGLETOFINESHIFT; - if ((player->mo->waterlevel || (player->mo->flags & MF_NOGRAVITY)) - && player->mo->_f_pitch() != 0) + && player->mo->Angles.Pitch != 0) { - angle_t pitch = (angle_t)player->mo->_f_pitch() >> ANGLETOFINESHIFT; - fixed_t zpush = FixedMul (move, finesine[pitch]); + double zpush = move * player->mo->Angles.Pitch.Sin(); if (player->mo->waterlevel && player->mo->waterlevel < 2 && zpush < 0) zpush = 0; - player->mo->vel.z -= zpush; - move = FixedMul (move, finecosine[pitch]); + player->mo->Vel.Z -= zpush; + move *= player->mo->Angles.Pitch.Cos(); } - player->mo->vel.x += FixedMul (move, finecosine[angle]); - player->mo->vel.y += FixedMul (move, finesine[angle]); + player->mo->Thrust(angle, move); } // @@ -1792,20 +1786,15 @@ void P_ForwardThrust (player_t *player, angle_t angle, fixed_t move) // reduced at a regular rate, even on ice (where the player coasts). // -void P_Bob (player_t *player, angle_t angle, fixed_t move, bool forward) +void P_Bob (player_t *player, DAngle angle, double move, bool forward) { if (forward && (player->mo->waterlevel || (player->mo->flags & MF_NOGRAVITY)) - && player->mo->_f_pitch() != 0) + && player->mo->Angles.Pitch != 0) { - angle_t pitch = (angle_t)player->mo->_f_pitch() >> ANGLETOFINESHIFT; - move = FixedMul (move, finecosine[pitch]); + move *= player->mo->Angles.Pitch.Cos(); } - - angle >>= ANGLETOFINESHIFT; - - player->vel.x += FixedMul(move, finecosine[angle]); - player->vel.y += FixedMul(move, finesine[angle]); + player->Vel += angle.ToVector(move); } /* @@ -1821,8 +1810,8 @@ Calculate the walking / running height adjustment void P_CalcHeight (player_t *player) { - int angle; - fixed_t bob; + DAngle angle; + double bob; bool still = false; // Regular movement bobbing @@ -1840,18 +1829,18 @@ void P_CalcHeight (player_t *player) } else if ((player->mo->flags & MF_NOGRAVITY) && !player->onground) { - player->bob = FRACUNIT / 2; + player->bob = 0.5; } else { - player->bob = DMulScale16 (player->vel.x, player->vel.x, player->vel.y, player->vel.y); + player->bob = player->Vel.LengthSquared(); if (player->bob == 0) { still = true; } else { - player->bob = FixedMul (player->bob, player->userinfo.GetMoveBob()); + player->bob *= player->userinfo.GetMoveBob(); if (player->bob > MAXBOB) player->bob = MAXBOB; @@ -1862,7 +1851,7 @@ void P_CalcHeight (player_t *player) if (player->cheats & CF_NOVELOCITY) { - player->viewz = player->mo->Z() + defaultviewheight; + player->viewz = player->mo->_f_Z() + defaultviewheight; if (player->viewz > player->mo->ceilingz-4*FRACUNIT) player->viewz = player->mo->ceilingz-4*FRACUNIT; @@ -1874,8 +1863,8 @@ void P_CalcHeight (player_t *player) { if (player->health > 0) { - angle = DivScale13 (level.time, 120*TICRATE/35) & FINEMASK; - bob = FixedMul (player->userinfo.GetStillBob(), finesine[angle]); + angle = level.time / (120 * TICRATE / 35.) * 360.; + bob = player->userinfo.GetStillBob() * angle.Sin(); } else { @@ -1884,9 +1873,8 @@ void P_CalcHeight (player_t *player) } else { - // DivScale 13 because FINEANGLES == (1<<13) - angle = DivScale13 (level.time, 20*TICRATE/35) & FINEMASK; - bob = FixedMul (player->bob>>(player->mo->waterlevel > 1 ? 2 : 1), finesine[angle]); + angle = level.time / (20 * TICRATE / 35.) * 360.; + bob = player->bob * angle.Sin() * (player->mo->waterlevel > 1 ? 0.25f : 0.5f); } // move viewheight @@ -1918,9 +1906,9 @@ void P_CalcHeight (player_t *player) { bob = 0; } - player->viewz = player->mo->Z() + player->viewheight + bob; + player->viewz = player->mo->_f_Z() + player->viewheight + FLOAT2FIXED(bob); if (player->mo->floorclip && player->playerstate != PST_DEAD - && player->mo->Z() <= player->mo->floorz) + && player->mo->_f_Z() <= player->mo->floorz) { player->viewz -= player->mo->floorclip; } @@ -1943,7 +1931,7 @@ void P_CalcHeight (player_t *player) */ CUSTOM_CVAR (Float, sv_aircontrol, 0.00390625f, CVAR_SERVERINFO|CVAR_NOSAVE) { - level.aircontrol = (fixed_t)(self * 65536.f); + level.aircontrol = self; G_AirControlChanged (); } @@ -1963,7 +1951,7 @@ void P_MovePlayer (player_t *player) mo->Angles.Yaw += cmd->ucmd.yaw * (360./65536.); } - player->onground = (mo->Z() <= mo->floorz) || (mo->flags2 & MF2_ONMOBJ) || (mo->BounceFlags & BOUNCE_MBF) || (player->cheats & CF_NOCLIP2); + player->onground = (mo->_f_Z() <= mo->floorz) || (mo->flags2 & MF2_ONMOBJ) || (mo->BounceFlags & BOUNCE_MBF) || (player->cheats & CF_NOCLIP2); // killough 10/98: // @@ -1974,51 +1962,51 @@ void P_MovePlayer (player_t *player) if (cmd->ucmd.forwardmove | cmd->ucmd.sidemove) { - fixed_t forwardmove, sidemove; - int bobfactor; - int friction, movefactor; - int fm, sm; + double forwardmove, sidemove; + double bobfactor; + double friction, movefactor; + double fm, sm; movefactor = P_GetMoveFactor (mo, &friction); - bobfactor = friction < ORIG_FRICTION ? movefactor : ORIG_FRICTION_FACTOR; + bobfactor = friction < ORIG_FRICTION ? movefactor : fORIG_FRICTION_FACTOR; if (!player->onground && !(player->mo->flags & MF_NOGRAVITY) && !player->mo->waterlevel) { // [RH] allow very limited movement if not on ground. - movefactor = FixedMul (movefactor, level.aircontrol); - bobfactor = FixedMul (bobfactor, level.aircontrol); + movefactor *= level.aircontrol; + bobfactor*= level.aircontrol; } fm = cmd->ucmd.forwardmove; sm = cmd->ucmd.sidemove; mo->TweakSpeeds (fm, sm); - fm = FixedMul (fm, player->mo->Speed); - sm = FixedMul (sm, player->mo->Speed); + fm *= player->mo->Speed / 256; + sm *= player->mo->Speed / 256; // When crouching, speed and bobbing have to be reduced - if (player->CanCrouch() && player->crouchfactor != FRACUNIT) + if (player->CanCrouch() && player->crouchfactor != 1) { - fm = FixedMul(fm, player->crouchfactor); - sm = FixedMul(sm, player->crouchfactor); - bobfactor = FixedMul(bobfactor, player->crouchfactor); + fm *= player->crouchfactor; + sm *= player->crouchfactor; + bobfactor *= player->crouchfactor; } - forwardmove = Scale (fm, movefactor * 35, TICRATE << 8); - sidemove = Scale (sm, movefactor * 35, TICRATE << 8); + forwardmove = fm * movefactor * (35 / TICRATE); + sidemove = sm * movefactor * (35 / TICRATE); if (forwardmove) { - P_Bob (player, mo->_f_angle(), (cmd->ucmd.forwardmove * bobfactor) >> 8, true); - P_ForwardThrust (player, mo->_f_angle(), forwardmove); + P_Bob(player, mo->Angles.Yaw, cmd->ucmd.forwardmove * bobfactor / 256., true); + P_ForwardThrust(player, mo->Angles.Yaw, forwardmove); } if (sidemove) { - P_Bob (player, mo->_f_angle()-ANG90, (cmd->ucmd.sidemove * bobfactor) >> 8, false); - P_SideThrust (player, mo->_f_angle(), sidemove); + P_Bob(player, mo->Angles.Yaw - 90, cmd->ucmd.sidemove * bobfactor / 256., false); + P_SideThrust(player, mo->Angles.Yaw, sidemove); } if (debugfile) { - 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: (%f,%f,%f) (%f,%f) %f %f w%d [", int(player-players), player->cheats&CF_PREDICTING?'p':' ', player->mo->X(), player->mo->Y(), player->mo->Z(),forwardmove, sidemove, movefactor, friction, player->mo->waterlevel); msecnode_t *n = player->mo->touching_sectorlist; @@ -2030,7 +2018,7 @@ void P_MovePlayer (player_t *player) fprintf (debugfile, "]\n"); } - if (!(player->cheats & CF_PREDICTING) && (forwardmove|sidemove)) + if (!(player->cheats & CF_PREDICTING) && (forwardmove != 0 || sidemove != 0)) { player->mo->PlayRunning (); } @@ -2064,7 +2052,7 @@ void P_FallingDamage (AActor *actor) if (actor->floorsector->Flags & SECF_NOFALLINGDAMAGE) return; - vel = abs(actor->vel.z); + vel = abs(actor->_f_velz()); // Since Hexen falling damage is stronger than ZDoom's, it takes // precedence. ZDoom falling damage may not be as strong, but it @@ -2085,7 +2073,7 @@ void P_FallingDamage (AActor *actor) { vel = FixedMul (vel, 16*FRACUNIT/23); damage = ((FixedMul (vel, vel) / 10) >> FRACBITS) - 24; - if (actor->vel.z > -39*FRACUNIT && damage > actor->health + if (actor->_f_velz() > -39*FRACUNIT && damage > actor->health && actor->health != 1) { // No-death threshold damage = actor->health-1; @@ -2151,7 +2139,7 @@ void P_DeathThink (player_t *player) P_MovePsprites (player); - player->onground = (player->mo->Z() <= player->mo->floorz); + player->onground = (player->mo->_f_Z() <= player->mo->floorz); if (player->mo->IsKindOf (RUNTIME_CLASS(APlayerChunk))) { // Flying bloody skull or flying ice chunk player->viewheight = 6 * FRACUNIT; @@ -2256,15 +2244,15 @@ void P_CrouchMove(player_t * player, int direction) { fixed_t defaultheight = player->mo->GetDefault()->height; fixed_t savedheight = player->mo->height; - fixed_t crouchspeed = direction * CROUCHSPEED; + double crouchspeed = direction * CROUCHSPEED; fixed_t oldheight = player->viewheight; player->crouchdir = (signed char) direction; player->crouchfactor += crouchspeed; // check whether the move is ok - player->mo->height = FixedMul(defaultheight, player->crouchfactor); - if (!P_TryMove(player->mo, player->mo->X(), player->mo->Y(), false, NULL)) + player->mo->height = fixed_t(defaultheight * player->crouchfactor); + if (!P_TryMove(player->mo, player->mo->_f_X(), player->mo->_f_Y(), false, NULL)) { player->mo->height = savedheight; if (direction > 0) @@ -2276,12 +2264,12 @@ void P_CrouchMove(player_t * player, int direction) } player->mo->height = savedheight; - player->crouchfactor = clamp(player->crouchfactor, FRACUNIT/2, FRACUNIT); - player->viewheight = FixedMul(player->mo->ViewHeight, player->crouchfactor); + player->crouchfactor = clamp(player->crouchfactor, 0.5, 1.); + player->viewheight = fixed_t(player->mo->ViewHeight * player->crouchfactor); player->crouchviewdelta = player->viewheight - player->mo->ViewHeight; // 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->_f_Z() + oldheight, true); } //---------------------------------------------------------------------------- @@ -2302,7 +2290,7 @@ void P_PlayerThink (player_t *player) if (debugfile && !(player->cheats & CF_PREDICTING)) { fprintf (debugfile, "tic %d for pl %d: (%d, %d, %d, %u) b:%02x p:%d y:%d f:%d s:%d u:%d\n", - gametic, (int)(player-players), player->mo->X(), player->mo->Y(), player->mo->Z(), + gametic, (int)(player-players), player->mo->_f_X(), player->mo->_f_Y(), player->mo->_f_Z(), player->mo->_f_angle()>>ANGLETOFINESHIFT, player->cmd.ucmd.buttons, player->cmd.ucmd.pitch, player->cmd.ucmd.yaw, player->cmd.ucmd.forwardmove, player->cmd.ucmd.sidemove, player->cmd.ucmd.upmove); @@ -2427,12 +2415,12 @@ void P_PlayerThink (player_t *player) { player->crouching = 0; } - if (crouchdir == 1 && player->crouchfactor < FRACUNIT && - player->mo->Top() < player->mo->ceilingz) + if (crouchdir == 1 && player->crouchfactor < 1 && + player->mo->_f_Top() < player->mo->ceilingz) { P_CrouchMove(player, 1); } - else if (crouchdir == -1 && player->crouchfactor > FRACUNIT/2) + else if (crouchdir == -1 && player->crouchfactor > 0.5) { P_CrouchMove(player, -1); } @@ -2443,7 +2431,7 @@ void P_PlayerThink (player_t *player) player->Uncrouch(); } - player->crouchoffset = -FixedMul(player->mo->ViewHeight, (FRACUNIT - player->crouchfactor)); + player->crouchoffset = -fixed_t(player->mo->ViewHeight * (1 - player->crouchfactor)); // MUSINFO stuff if (player->MUSINFOtics >= 0 && player->MUSINFOactor != NULL) @@ -2557,20 +2545,20 @@ void P_PlayerThink (player_t *player) } else if (player->mo->waterlevel >= 2) { - player->mo->vel.z = FixedMul(4*FRACUNIT, player->mo->Speed); + player->mo->Vel.Z = 4 * player->mo->Speed; } else if (player->mo->flags & MF_NOGRAVITY) { - player->mo->vel.z = 3*FRACUNIT; + player->mo->Vel.Z = 3.; } else if (level.IsJumpingAllowed() && player->onground && player->jumpTics == 0) { - fixed_t jumpvelz = player->mo->JumpZ * 35 / TICRATE; + double jumpvelz = player->mo->JumpZ * 35 / TICRATE; // [BC] If the player has the high jump power, double his jump velocity. if ( player->cheats & CF_HIGHJUMP ) jumpvelz *= 2; - player->mo->vel.z += jumpvelz; + player->mo->Vel.Z += jumpvelz; player->mo->flags2 &= ~MF2_ONMOBJ; player->jumpTics = -1; if (!(player->cheats & CF_PREDICTING)) @@ -2596,12 +2584,12 @@ void P_PlayerThink (player_t *player) } if (player->mo->waterlevel >= 2 || (player->mo->flags2 & MF2_FLY) || (player->cheats & CF_NOCLIP2)) { - player->mo->vel.z = FixedMul(player->mo->Speed, cmd->ucmd.upmove << 9); + player->mo->Vel.Z = player->mo->Speed * cmd->ucmd.upmove / 128.; if (player->mo->waterlevel < 2 && !(player->mo->flags & MF_NOGRAVITY)) { player->mo->flags2 |= MF2_FLY; player->mo->flags |= MF_NOGRAVITY; - if ((player->mo->vel.z <= -39 * FRACUNIT) && !(player->cheats & CF_PREDICTING)) + if ((player->mo->Vel.Z <= -39) && !(player->cheats & CF_PREDICTING)) { // Stop falling scream S_StopSound (player->mo, CHAN_VOICE); } @@ -2625,14 +2613,14 @@ void P_PlayerThink (player_t *player) P_PlayerOnSpecial3DFloor (player); P_PlayerInSpecialSector (player); - if (player->mo->Z() <= player->mo->Sector->floorplane.ZatPoint(player->mo) || + if (player->mo->_f_Z() <= player->mo->Sector->floorplane.ZatPoint(player->mo) || player->mo->waterlevel) { // Player must be touching the floor P_PlayerOnSpecialFlat(player, P_GetThingFloorType(player->mo)); } - if (player->mo->vel.z <= -player->mo->FallingScreamMinSpeed && - player->mo->vel.z >= -player->mo->FallingScreamMaxSpeed && !player->morphTics && + if (player->mo->_f_velz() <= -player->mo->FallingScreamMinSpeed && + player->mo->_f_velz() >= -player->mo->FallingScreamMaxSpeed && !player->morphTics && player->mo->waterlevel == 0) { int id = S_FindSkinnedSound (player->mo, "*falling"); @@ -2851,16 +2839,16 @@ void P_PredictPlayer (player_t *player) { // Z is not compared as lifts will alter this with no apparent change // Make lerping less picky by only testing whole units - DoLerp = ((PredictionLast.x >> 16) != (player->mo->X() >> 16) || - (PredictionLast.y >> 16) != (player->mo->Y() >> 16)); + DoLerp = ((PredictionLast.x >> 16) != (player->mo->_f_X() >> 16) || + (PredictionLast.y >> 16) != (player->mo->_f_Y() >> 16)); // Aditional Debug information if (developer && DoLerp) { DPrintf("Lerp! Ltic (%d) && Ptic (%d) | Lx (%d) && Px (%d) | Ly (%d) && Py (%d)\n", PredictionLast.gametic, i, - (PredictionLast.x >> 16), (player->mo->X() >> 16), - (PredictionLast.y >> 16), (player->mo->Y() >> 16)); + (PredictionLast.x >> 16), (player->mo->_f_X() >> 16), + (PredictionLast.y >> 16), (player->mo->_f_Y() >> 16)); } } } @@ -2878,9 +2866,9 @@ void P_PredictPlayer (player_t *player) } PredictionLast.gametic = maxtic - 1; - PredictionLast.x = player->mo->X(); - PredictionLast.y = player->mo->Y(); - PredictionLast.z = player->mo->Z(); + PredictionLast.x = player->mo->_f_X(); + PredictionLast.y = player->mo->_f_Y(); + PredictionLast.z = player->mo->_f_Z(); if (PredictionLerptics > 0) { @@ -3054,8 +3042,7 @@ void player_t::Serialize (FArchive &arc) << viewheight << deltaviewheight << bob - << vel.x - << vel.y + << Vel << centering << health << inventorytics; @@ -3194,7 +3181,7 @@ void player_t::Serialize (FArchive &arc) } else { - onground = (mo->Z() <= mo->floorz) || (mo->flags2 & MF2_ONMOBJ) || (mo->BounceFlags & BOUNCE_MBF) || (cheats & CF_NOCLIP2); + onground = (mo->_f_Z() <= mo->floorz) || (mo->flags2 & MF2_ONMOBJ) || (mo->BounceFlags & BOUNCE_MBF) || (cheats & CF_NOCLIP2); } if (SaveVersion < 4514 && IsBot) diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index c8712a07d..a9ae49f12 100644 --- a/src/p_writemap.cpp +++ b/src/p_writemap.cpp @@ -100,8 +100,8 @@ static int WriteTHINGS (FILE *file) mapthinghexen_t mt = { 0, 0, 0, 0, 0, 0, 0, 0, {0} }; AActor *mo = players[consoleplayer].mo; - mt.x = LittleShort(short(mo->X() >> FRACBITS)); - mt.y = LittleShort(short(mo->Y() >> FRACBITS)); + mt.x = LittleShort(short(mo->X())); + mt.y = LittleShort(short(mo->Y())); mt.angle = LittleShort(short(MulScale32 (mo->_f_angle() >> ANGLETOFINESHIFT, 360))); mt.type = LittleShort((short)1); mt.flags = LittleShort((short)(7|224|MTF_SINGLE)); diff --git a/src/po_man.cpp b/src/po_man.cpp index f2ca3c185..911bb97b4 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -856,9 +856,7 @@ int FPolyObj::GetMirror() void FPolyObj::ThrustMobj (AActor *actor, side_t *side) { - int thrustAngle; - int thrustX; - int thrustY; + DAngle thrustAngle; DPolyAction *pe; int force; @@ -869,7 +867,7 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side) } vertex_t *v1 = side->V1(); vertex_t *v2 = side->V2(); - thrustAngle = (R_PointToAngle2 (v1->x, v1->y, v2->x, v2->y) - ANGLE_90) >> ANGLETOFINESHIFT; + thrustAngle = VecToAngle(v2->x - v1->x, v2->y - v1->y) - 90.; pe = static_cast(specialdata); if (pe) @@ -896,13 +894,12 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side) force = FRACUNIT; } - thrustX = FixedMul (force, finecosine[thrustAngle]); - thrustY = FixedMul (force, finesine[thrustAngle]); - actor->vel.x += thrustX; - actor->vel.y += thrustY; + DVector2 thrust = thrustAngle.ToVector(FIXED2FLOAT(force)); + actor->Vel += thrust; + if (crush) { - fixedvec2 pos = actor->Vec2Offset(thrustX, thrustY); + fixedvec2 pos = actor->Vec2Offset(FLOAT2FIXED(thrust.X), FLOAT2FIXED(thrust.Y)); if (bHurtOnTouch || !P_CheckMove (actor, pos.x, pos.y)) { int newdam = P_DamageMobj (actor, NULL, NULL, crush, NAME_Crush); @@ -1204,8 +1201,8 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) && !((mobj->flags & MF_FLOAT) && (ld->flags & ML_BLOCK_FLOATERS)) && (!(ld->flags & ML_3DMIDTEX) || (!P_LineOpening_3dMidtex(mobj, ld, open) && - (mobj->Top() < open.top) - ) || (open.abovemidtex && mobj->Z() > mobj->floorz)) + (mobj->_f_Top() < open.top) + ) || (open.abovemidtex && mobj->_f_Z() > mobj->floorz)) ) { // [BL] We can't just continue here since we must @@ -1218,7 +1215,7 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) performBlockingThrust = true; } - FBoundingBox box(mobj->X(), mobj->Y(), mobj->radius); + FBoundingBox box(mobj->_f_X(), mobj->_f_Y(), mobj->radius); if (box.Right() <= ld->bbox[BOXLEFT] || box.Left() >= ld->bbox[BOXRIGHT] @@ -1236,15 +1233,15 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) // Best use the one facing the player and ignore the back side. if (ld->sidedef[1] != NULL) { - int side = P_PointOnLineSidePrecise(mobj->X(), mobj->Y(), ld); + int side = P_PointOnLineSidePrecise(mobj->_f_X(), mobj->_f_Y(), ld); if (ld->sidedef[side] != sd) { continue; } // [BL] See if we hit below the floor/ceiling of the poly. else if(!performBlockingThrust && ( - mobj->Z() < ld->sidedef[!side]->sector->GetSecPlane(sector_t::floor).ZatPoint(mobj) || - mobj->Top() > ld->sidedef[!side]->sector->GetSecPlane(sector_t::ceiling).ZatPoint(mobj) + mobj->_f_Z() < ld->sidedef[!side]->sector->GetSecPlane(sector_t::floor).ZatPoint(mobj) || + mobj->_f_Top() > ld->sidedef[!side]->sector->GetSecPlane(sector_t::ceiling).ZatPoint(mobj) )) { performBlockingThrust = true; diff --git a/src/portal.cpp b/src/portal.cpp index 86fe880c2..d7f3d217d 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -1118,7 +1118,7 @@ void P_CreateLinkedPortals() if (!(actor->flags & MF_NOBLOCKMAP)) { FPortalGroupArray check(FPortalGroupArray::PGA_NoSectorPortals); - P_CollectConnectedGroups(actor->Sector->PortalGroup, actor->Pos(), actor->Top(), actor->radius, check); + P_CollectConnectedGroups(actor->Sector->PortalGroup, actor->_f_Pos(), actor->_f_Top(), actor->radius, check); if (check.Size() > 0) { actor->UnlinkFromWorld(); diff --git a/src/portal.h b/src/portal.h index c99a87b28..4fe89a3c6 100644 --- a/src/portal.h +++ b/src/portal.h @@ -203,6 +203,14 @@ inline int P_NumPortalGroups() bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t viewy, bool partial = true, bool samebehind = true); void P_TranslatePortalXY(line_t* src, fixed_t& x, fixed_t& y); void P_TranslatePortalVXVY(line_t* src, fixed_t& vx, fixed_t& vy); +inline void P_TranslatePortalVXVY(line_t* src, double& vx, double& vy) +{ + fixed_t x = FLOAT2FIXED(vx); + fixed_t y = FLOAT2FIXED(vy); + P_TranslatePortalVXVY(src, x, y); + vx = FIXED2DBL(x); + vx = FIXED2DBL(y); +} void P_TranslatePortalAngle(line_t* src, DAngle& angle); void P_TranslatePortalZ(line_t* src, fixed_t& z); void P_NormalizeVXVY(fixed_t& vx, fixed_t& vy); diff --git a/src/r_defs.h b/src/r_defs.h index 953695801..ff5ce96e3 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -230,6 +230,11 @@ struct secplane_t fixed_t a, b, c, d, ic; + DVector3 Normal() const + { + return{ FIXED2FLOAT(a), FIXED2FLOAT(b), FIXED2FLOAT(c) }; + } + // Returns < 0 : behind; == 0 : on; > 0 : in front int PointOnSide (fixed_t x, fixed_t y, fixed_t z) const { @@ -272,7 +277,7 @@ struct secplane_t fixed_t ZatPoint (const AActor *ac) const { - return FixedMul (ic, -d - DMulScale16 (a, ac->X(), b, ac->Y())); + return FixedMul (ic, -d - DMulScale16 (a, ac->_f_X(), b, ac->_f_Y())); } // Returns the value of z at (x,y) if d is equal to dist @@ -544,6 +549,7 @@ struct sector_t int GetFloorLight () const; int GetCeilingLight () const; sector_t *GetHeightSec() const; + fixed_t GetFriction(int plane = sector_t::floor, fixed_t *movefac = NULL) const; DInterpolation *SetInterpolation(int position, bool attach); @@ -812,12 +818,12 @@ struct sector_t fixed_t HighestCeilingAt(AActor *a, sector_t **resultsec = NULL) { - return HighestCeilingAt(a->X(), a->Y(), resultsec); + return HighestCeilingAt(a->_f_X(), a->_f_Y(), resultsec); } fixed_t LowestFloorAt(AActor *a, sector_t **resultsec = NULL) { - return LowestFloorAt(a->X(), a->Y(), resultsec); + return LowestFloorAt(a->_f_X(), a->_f_Y(), resultsec); } fixed_t NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fixed_t topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL); @@ -888,7 +894,7 @@ struct sector_t // thinglist is a subset of touching_thinglist struct msecnode_t *touching_thinglist; // phares 3/14/98 - float gravity; // [RH] Sector gravity (1.0 is normal) + double gravity; // [RH] Sector gravity (1.0 is normal) FNameNoInit damagetype; // [RH] Means-of-death for applied damage int damageamount; // [RH] Damage to do while standing on floor short damageinterval; // Interval for damage application @@ -1086,6 +1092,21 @@ struct line_t int locknumber; // [Dusk] lock number for special unsigned portalindex; + DVector2 V1() const + { + return{ FIXED2DBL(v1->x), FIXED2DBL(v1->y) }; + } + + DVector2 V2() const + { + return{ FIXED2DBL(v2->x), FIXED2DBL(v2->y) }; + } + + DVector2 Delta() const + { + return{ FIXED2DBL(dx), FIXED2DBL(dy) }; + } + FLinePortal *getPortal() const { return portalindex >= linePortals.Size() ? (FLinePortal*)NULL : &linePortals[portalindex]; @@ -1284,13 +1305,14 @@ inline fixedvec3 PosRelative(const fixedvec3 &pos, line_t *line, sector_t *refse inline void AActor::ClearInterpolation() { - PrevX = X(); - PrevY = Y(); - PrevZ = Z(); + PrevX = _f_X(); + PrevY = _f_Y(); + PrevZ = _f_Z(); PrevAngles = Angles; if (Sector) PrevPortalGroup = Sector->PortalGroup; else PrevPortalGroup = 0; } + #endif diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 465ecf8e0..bbf63333e 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1251,8 +1251,8 @@ void R_DrawSkyBoxes () { extralight = pl->extralight; R_SetVisibility (pl->visibility); - viewx = pl->viewx - sky->Mate->X() + sky->X(); - viewy = pl->viewy - sky->Mate->Y() + sky->Y(); + viewx = pl->viewx - sky->Mate->_f_X() + sky->_f_X(); + viewy = pl->viewy - sky->Mate->_f_Y() + sky->_f_Y(); viewz = pl->viewz; viewangle = pl->viewangle; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 1c1bfe209..ce2652250 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -763,7 +763,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor // [ZZ] Or less definitely not visible (hue) // [ZZ] 10.01.2016: don't try to clip stuff inside a skybox against the current portal. - if (!CurrentPortalInSkybox && CurrentPortal && !!P_PointOnLineSidePrecise(thing->X(), thing->Y(), CurrentPortal->dst)) + if (!CurrentPortalInSkybox && CurrentPortal && !!P_PointOnLineSidePrecise(thing->_f_X(), thing->_f_Y(), CurrentPortal->dst)) return; // [RH] Interpolate the sprite's position to make it look smooth @@ -1254,12 +1254,12 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) { if(!(rover->top.plane->a) && !(rover->top.plane->b)) { - if(rover->top.plane->Zat0() <= thing->Z()) fakefloor = rover; + if(rover->top.plane->Zat0() <= thing->_f_Z()) fakefloor = rover; } } if(!(rover->bottom.plane->a) && !(rover->bottom.plane->b)) { - if(rover->bottom.plane->Zat0() >= thing->Top()) fakeceiling = rover; + if(rover->bottom.plane->Zat0() >= thing->_f_Top()) fakeceiling = rover; } } R_ProjectSprite (thing, fakeside, fakefloor, fakeceiling); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index fa44d2add..78b7e8464 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -661,8 +661,8 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi player - players == consoleplayer && camera == player->mo && !demoplayback && - iview->nviewx == camera->X() && - iview->nviewy == camera->Y() && + iview->nviewx == camera->_f_X() && + iview->nviewy == camera->_f_Y() && !(player->cheats & (CF_TOTALLYFROZEN|CF_FROZEN)) && player->playerstate == PST_LIVE && player->mo->reactiontime == 0 && @@ -983,9 +983,9 @@ void R_SetupFrame (AActor *actor) } else { - iview->nviewx = camera->X(); - iview->nviewy = camera->Y(); - iview->nviewz = camera->player ? camera->player->viewz : camera->Z() + camera->GetCameraHeight(); + iview->nviewx = camera->_f_X(); + iview->nviewy = camera->_f_Y(); + iview->nviewz = camera->player ? camera->player->viewz : camera->_f_Z() + camera->GetCameraHeight(); viewsector = camera->Sector; r_showviewer = false; } diff --git a/src/s_sound.cpp b/src/s_sound.cpp index fee5f3383..100773e06 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -736,9 +736,9 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, // Only actors maintain velocity information. if (type == SOURCE_Actor && actor != NULL) { - vel->X = FIXED2FLOAT(actor->vel.x) * TICRATE; - vel->Y = FIXED2FLOAT(actor->vel.z) * TICRATE; - vel->Z = FIXED2FLOAT(actor->vel.y) * TICRATE; + vel->X = float(actor->Vel.X * TICRATE); + vel->Y = float(actor->Vel.Y * TICRATE); + vel->Z = float(actor->Vel.Z * TICRATE); } else { diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index 548dd7201..9b7de9e43 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -1357,7 +1357,7 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener if(dir.DoesNotApproximatelyEqual(FVector3(0.f, 0.f, 0.f))) { float gain = GetRolloff(rolloff, sqrtf(dist_sqr) * distscale); - dir.Resize((gain > 0.00001f) ? 1.f/gain : 100000.f); + dir.MakeResize((gain > 0.00001f) ? 1.f/gain : 100000.f); } if((chanflags&SNDF_AREA) && dist_sqr < AREA_SOUND_RADIUS*AREA_SOUND_RADIUS) { @@ -1596,7 +1596,7 @@ void OpenALSoundRenderer::UpdateSoundParams3D(SoundListener *listener, FISoundCh if(dir.DoesNotApproximatelyEqual(FVector3(0.f, 0.f, 0.f))) { float gain = GetRolloff(&chan->Rolloff, sqrtf(chan->DistanceSqr) * chan->DistanceScale); - dir.Resize((gain > 0.00001f) ? 1.f/gain : 100000.f); + dir.MakeResize((gain > 0.00001f) ? 1.f/gain : 100000.f); } if(areasound && chan->DistanceSqr < AREA_SOUND_RADIUS*AREA_SOUND_RADIUS) { diff --git a/src/tables.h b/src/tables.h index 6fe767a4f..790deed5f 100644 --- a/src/tables.h +++ b/src/tables.h @@ -53,6 +53,7 @@ #define ANGLETOFINESHIFT 19 #define BOBTOFINESHIFT (FINEANGLEBITS - 6) +#define BOBTORAD(v) ((v) * (M_PI/32)) // from FloatBobTable to radians. // Effective size is 10240. extern fixed_t finesine[5*FINEANGLES/4]; diff --git a/src/thingdef/olddecorations.cpp b/src/thingdef/olddecorations.cpp index c1610a521..0fa34344d 100644 --- a/src/thingdef/olddecorations.cpp +++ b/src/thingdef/olddecorations.cpp @@ -514,7 +514,7 @@ static void ParseInsideDecoration (Baggage &bag, AActor *defaults, else if (def == DEF_Projectile && sc.Compare ("Speed")) { sc.MustGetFloat (); - defaults->Speed = fixed_t(sc.Float * 65536.f); + defaults->Speed = sc.Float; } else if (sc.Compare ("Mass")) { diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index cd7882847..baf5b3dc5 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -313,7 +313,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetDistance) } else { - fixedvec3 diff = self->Vec3To(target); + fixedvec3 diff = self->_f_Vec3To(target); if (checkz) diff.z += (target->height - self->height) / 2; @@ -614,9 +614,9 @@ static void DoAttack (AActor *self, bool domelee, bool domissile, else if (domissile && MissileType != NULL) { // This seemingly senseless code is needed for proper aiming. - self->AddZ(MissileHeight + self->GetBobOffset() - 32*FRACUNIT); + self->_f_AddZ(MissileHeight + self->GetBobOffset() - 32*FRACUNIT); AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32*FRACUNIT), self, self->target, MissileType, false); - self->AddZ(-(MissileHeight + self->GetBobOffset() - 32*FRACUNIT)); + self->_f_AddZ(-(MissileHeight + self->GetBobOffset() - 32*FRACUNIT)); if (missile) { @@ -939,8 +939,8 @@ static int DoJumpIfCloser(AActor *target, VM_ARGS) } if (self->AproxDistance(target) < dist && (noz || - ((self->Z() > target->Z() && self->Z() - target->Top() < dist) || - (self->Z() <= target->Z() && target->Z() - self->Top() < dist)))) + ((self->_f_Z() > target->_f_Z() && self->_f_Z() - target->_f_Top() < dist) || + (self->_f_Z() <= target->_f_Z() && target->_f_Z() - self->_f_Top() < dist)))) { ACTION_RETURN_STATE(jump); } @@ -1221,7 +1221,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) fixed_t y = spawnofs_xy * finesine[ang]; fixed_t z = spawnheight + self->GetBobOffset() - 32*FRACUNIT + (self->player? self->player->crouchoffset : 0); - fixedvec3 pos = self->Pos(); + fixedvec3 pos = self->_f_Pos(); switch (aimmode) { case 0: @@ -1238,7 +1238,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) case 2: self->SetXYZ(self->Vec3Offset(x, y, 0)); - missile = P_SpawnMissileAngleZSpeed(self, self->Z() + self->GetBobOffset() + spawnheight, ti, self->_f_angle(), 0, GetDefaultByType(ti)->Speed, self, false); + missile = P_SpawnMissileAngleZSpeed(self, self->_f_Z() + self->GetBobOffset() + spawnheight, ti, self->_f_angle(), 0, GetDefaultByType(ti)->_f_speed(), self, false); self->SetXYZ(pos); flags |= CMF_ABSOLUTEPITCH; @@ -1252,22 +1252,20 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) // so that this can handle missiles with a high vertical velocity // component properly. - fixed_t missilespeed; + double missilespeed; if ( (CMF_ABSOLUTEPITCH|CMF_OFFSETPITCH) & flags) { if (CMF_OFFSETPITCH & flags) { - DVector2 velocity (missile->vel.x, missile->vel.y); - Pitch += VecToAngle(velocity.Length(), missile->vel.z); + Pitch += missile->Vel.Pitch(); } - missilespeed = abs(fixed_t(Pitch.Cos() * missile->Speed)); - missile->vel.z = fixed_t(Pitch.Sin() * missile->Speed); + missilespeed = fabs(Pitch.Cos() * missile->Speed); + missile->Vel.Z = Pitch.Sin() * missile->Speed; } else { - DVector2 velocity (missile->vel.x, missile->vel.y); - missilespeed = xs_CRoundToInt(velocity.Length()); + missilespeed = missile->VelXYToSpeed(); } if (CMF_SAVEPITCH & flags) @@ -1278,8 +1276,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) // otherwise affecting the spawned actor. } - missile->Angles.Yaw = (CMF_ABSOLUTEANGLE & flags) ? Angle : missile->Angles.Yaw + Angle ; - + missile->Angles.Yaw = (CMF_ABSOLUTEANGLE & flags) ? Angle : missile->Angles.Yaw + Angle; missile->VelFromAngle(missilespeed); // handle projectile shooting projectiles - track the @@ -1470,9 +1467,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack) else if (ti) { // This seemingly senseless code is needed for proper aiming. - self->AddZ(spawnheight + self->GetBobOffset() - 32*FRACUNIT); + self->_f_AddZ(spawnheight + self->GetBobOffset() - 32*FRACUNIT); AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32*FRACUNIT), self, self->target, ti, false); - self->AddZ(-(spawnheight + self->GetBobOffset() - 32*FRACUNIT)); + self->_f_AddZ(-(spawnheight + self->GetBobOffset() - 32*FRACUNIT)); if (missile) { @@ -1672,10 +1669,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) { // This original implementation is to aim straight ahead and then offset // the angle from the resulting direction. - DVector3 velocity(misl->vel.x, misl->vel.y, 0); - fixed_t missilespeed = xs_CRoundToInt(velocity.Length()); misl->Angles.Yaw += angle; - misl->VelFromAngle(); + misl->VelFromAngle(misl->VelXYToSpeed()); } } } @@ -1898,7 +1893,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) FTranslatedLineTarget t; - fixedvec3 savedpos = self->Pos(); + fixedvec3 savedpos = self->_f_Pos(); DAngle saved_angle = self->Angles.Yaw; DAngle saved_pitch = self->Angles.Pitch; @@ -1923,16 +1918,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) if (t.linetarget == NULL && aim) { // We probably won't hit the target, but aim at it anyway so we don't look stupid. - fixedvec2 pos = self->Vec2To(self->target); + fixedvec2 pos = self->_f_Vec2To(self->target); DVector2 xydiff(pos.x, pos.y); - double zdiff = (self->target->Z() + (self->target->height>>1)) - - (self->Z() + (self->height>>1) - self->floorclip); + double zdiff = (self->target->_f_Z() + (self->target->height>>1)) - + (self->_f_Z() + (self->height>>1) - self->floorclip); self->Angles.Pitch = VecToAngle(xydiff.Length(), zdiff); } // Let the aim trail behind the player if (aim) { - saved_angle = self->Angles.Yaw = self->AngleTo(self->target, -self->target->vel.x * 3, -self->target->vel.y * 3); + saved_angle = self->Angles.Yaw = self->AngleTo(self->target, -self->target->_f_velx() * 3, -self->target->_f_vely() * 3); if (aim == CRF_AIMDIRECT) { @@ -1942,7 +1937,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) FLOAT2FIXED(spawnofs_xy * self->Angles.Yaw.Cos()), FLOAT2FIXED(spawnofs_xy * self->Angles.Yaw.Sin()))); spawnofs_xy = 0; - self->Angles.Yaw = self->AngleTo(self->target,- self->target->vel.x * 3, -self->target->vel.y * 3); + self->Angles.Yaw = self->AngleTo(self->target,- self->target->_f_velx() * 3, -self->target->_f_vely() * 3); } if (self->target->flags & MF_SHADOW) @@ -2248,7 +2243,7 @@ static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) } if (flags & SIXF_TELEFRAG) { - P_TeleportMove(mo, mo->Pos(), true); + P_TeleportMove(mo, mo->_f_Pos(), true); // This is needed to ensure consistent behavior. // Otherwise it will only spawn if nothing gets telefragged flags |= SIXF_NOCHECKPOSITION; @@ -2425,7 +2420,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) } } - AActor *mo = Spawn( missile, self->Vec3Angle(distance, self->_f_angle(), -self->floorclip + self->GetBobOffset() + zheight), ALLOW_REPLACE); + AActor *mo = Spawn( missile, self->_f_Vec3Angle(distance, self->_f_angle(), -self->floorclip + self->GetBobOffset() + zheight), ALLOW_REPLACE); int flags = (transfer_translation ? SIXF_TRANSFERTRANSLATION : 0) + (useammo ? SIXF_SETMASTER : 0); ACTION_RETURN_BOOL(InitSpawnedItem(self, mo, flags)); // for an inventory item's use state @@ -2445,9 +2440,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) PARAM_FIXED_OPT (xofs) { xofs = 0; } PARAM_FIXED_OPT (yofs) { yofs = 0; } PARAM_FIXED_OPT (zofs) { zofs = 0; } - PARAM_FIXED_OPT (xvel) { xvel = 0; } - PARAM_FIXED_OPT (yvel) { yvel = 0; } - PARAM_FIXED_OPT (zvel) { zvel = 0; } + PARAM_FLOAT_OPT (xvel) { xvel = 0; } + PARAM_FLOAT_OPT (yvel) { yvel = 0; } + PARAM_FLOAT_OPT (zvel) { zvel = 0; } PARAM_DANGLE_OPT(angle) { angle = 0.; } PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (chance) { chance = 0; } @@ -2490,12 +2485,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) if (!(flags & SIXF_ABSOLUTEVELOCITY)) { // Same orientation issue here! - fixed_t newxvel = fixed_t(xvel * c + yvel * s); - yvel = fixed_t(xvel * s - yvel * c); + double newxvel = xvel * c + yvel * s; + yvel = xvel * s - yvel * c; xvel = newxvel; } - AActor *mo = Spawn(missile, pos.x, pos.y, self->Z() - self->floorclip + self->GetBobOffset() + zofs, ALLOW_REPLACE); + AActor *mo = Spawn(missile, pos.x, pos.y, self->_f_Z() - self->floorclip + self->GetBobOffset() + zofs, ALLOW_REPLACE); bool res = InitSpawnedItem(self, mo, flags); if (res) { @@ -2505,17 +2500,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) mo->tid = tid; mo->AddToHash(); } + mo->Vel = {xvel, yvel, zvel}; if (flags & SIXF_MULTIPLYSPEED) { - mo->vel.x = FixedMul(xvel, mo->Speed); - mo->vel.y = FixedMul(yvel, mo->Speed); - mo->vel.z = FixedMul(zvel, mo->Speed); - } - else - { - mo->vel.x = xvel; - mo->vel.y = yvel; - mo->vel.z = zvel; + mo->Vel *= mo->Speed; } mo->Angles.Yaw = angle; } @@ -2534,7 +2522,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) PARAM_ACTION_PROLOGUE; PARAM_CLASS (missile, AActor); PARAM_FIXED_OPT (zheight) { zheight = 0; } - PARAM_FIXED_OPT (xyvel) { xyvel = 0; } + PARAM_FLOAT_OPT (xyvel) { xyvel = 0; } PARAM_FIXED_OPT (zvel) { zvel = 0; } PARAM_BOOL_OPT (useammo) { useammo = true; } @@ -2569,27 +2557,27 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) bo->Speed = xyvel; bo->Angles.Yaw = self->Angles.Yaw + (((pr_grenade()&7) - 4) * (360./256.)); - angle_t pitch = angle_t(-self->_f_pitch()) >> ANGLETOFINESHIFT; - angle_t angle = bo->_f_angle() >> ANGLETOFINESHIFT; + DAngle pitch = -self->Angles.Pitch; + DAngle angle = bo->Angles.Yaw; // There are two vectors we are concerned about here: xy and z. We rotate // them separately according to the shooter's pitch and then sum them to // get the final velocity vector to shoot with. - fixed_t xy_xyscale = FixedMul(bo->Speed, finecosine[pitch]); - fixed_t xy_velz = FixedMul(bo->Speed, finesine[pitch]); - fixed_t xy_velx = FixedMul(xy_xyscale, finecosine[angle]); - fixed_t xy_vely = FixedMul(xy_xyscale, finesine[angle]); + double xy_xyscale = bo->Speed * pitch.Cos(); + double xy_velz = bo->Speed * pitch.Sin(); + double xy_velx = xy_xyscale * angle.Cos(); + double xy_vely = xy_xyscale * angle.Sin(); - pitch = angle_t(self->_f_pitch()) >> ANGLETOFINESHIFT; - fixed_t z_xyscale = FixedMul(zvel, finesine[pitch]); - fixed_t z_velz = FixedMul(zvel, finecosine[pitch]); - fixed_t z_velx = FixedMul(z_xyscale, finecosine[angle]); - fixed_t z_vely = FixedMul(z_xyscale, finesine[angle]); + pitch = self->Angles.Pitch; + double z_xyscale = zvel * pitch.Sin(); + double z_velz = zvel * pitch.Cos(); + double z_velx = z_xyscale * angle.Cos(); + double z_vely = z_xyscale * angle.Sin(); - bo->vel.x = xy_velx + z_velx + (self->vel.x >> 1); - bo->vel.y = xy_vely + z_vely + (self->vel.y >> 1); - bo->vel.z = xy_velz + z_velz; + bo->Vel.X = xy_velx + z_velx + self->Vel.X / 2; + bo->Vel.Y = xy_vely + z_vely + self->Vel.Y / 2; + bo->Vel.Z = xy_velz + z_velz; bo->target = self; P_CheckMissileSpawn (bo, self->radius); @@ -2610,12 +2598,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Recoil) { PARAM_ACTION_PROLOGUE; - PARAM_FIXED(xyvel); + PARAM_FLOAT(xyvel); - angle_t angle = self->_f_angle() + ANG180; - angle >>= ANGLETOFINESHIFT; - self->vel.x += FixedMul(xyvel, finecosine[angle]); - self->vel.y += FixedMul(xyvel, finesine[angle]); + self->Thrust(self->Angles.Yaw + 180., xyvel); return 0; } @@ -2944,8 +2929,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris) PARAM_ACTION_PROLOGUE; PARAM_CLASS (debris, AActor); PARAM_BOOL_OPT (transfer_translation) { transfer_translation = false; } - PARAM_FIXED_OPT (mult_h) { mult_h = FRACUNIT; } - PARAM_FIXED_OPT (mult_v) { mult_v = FRACUNIT; } + PARAM_FLOAT_OPT (mult_h) { mult_h = 1; } + PARAM_FLOAT_OPT (mult_v) { mult_v = 1; } int i; AActor *mo; @@ -2953,10 +2938,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris) return 0; // only positive values make sense here - if (mult_v <= 0) - mult_v = FRACUNIT; - if (mult_h <= 0) - mult_h = FRACUNIT; + if (mult_v <= 0) mult_v = 1; + if (mult_h <= 0) mult_h = 1; for (i = 0; i < GetDefaultByType(debris)->health; i++) { @@ -2974,9 +2957,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris) { mo->SetState (mo->GetClass()->OwnedStates + i); } - mo->vel.z = FixedMul(mult_v, ((pr_spawndebris()&7)+5)*FRACUNIT); - mo->vel.x = FixedMul(mult_h, pr_spawndebris.Random2()<<(FRACBITS-6)); - mo->vel.y = FixedMul(mult_h, pr_spawndebris.Random2()<<(FRACBITS-6)); + mo->Vel.X = mult_h * pr_spawndebris.Random2() / 64.; + mo->Vel.Y = mult_h * pr_spawndebris.Random2() / 64.; + mo->Vel.Z = mult_v * ((pr_spawndebris() & 7) + 5); } } return 0; @@ -3097,16 +3080,16 @@ static bool DoCheckSightOrRange(AActor *self, AActor *camera, double range, bool return false; } // Check distance first, since it's cheaper than checking sight. - fixedvec2 pos = camera->Vec2To(self); + fixedvec2 pos = camera->_f_Vec2To(self); fixed_t dz; - fixed_t eyez = (camera->Top() - (camera->height>>2)); // same eye height as P_CheckSight - if (eyez > self->Top()) + fixed_t eyez = (camera->_f_Top() - (camera->height>>2)); // same eye height as P_CheckSight + if (eyez > self->_f_Top()) { - dz = self->Top() - eyez; + dz = self->_f_Top() - eyez; } - else if (eyez < self->Z()) + else if (eyez < self->_f_Z()) { - dz = self->Z() - eyez; + dz = self->_f_Z() - eyez; } else { @@ -3167,16 +3150,16 @@ static bool DoCheckRange(AActor *self, AActor *camera, double range, bool twodi) return false; } // Check distance first, since it's cheaper than checking sight. - fixedvec2 pos = camera->Vec2To(self); + fixedvec2 pos = camera->_f_Vec2To(self); fixed_t dz; - fixed_t eyez = (camera->Top() - (camera->height>>2)); // same eye height as P_CheckSight - if (eyez > self->Top()) + fixed_t eyez = (camera->_f_Top() - (camera->height>>2)); // same eye height as P_CheckSight + if (eyez > self->_f_Top()) { - dz = self->Top() - eyez; + dz = self->_f_Top() - eyez; } - else if (eyez < self->Z()) + else if (eyez < self->_f_Z()) { - dz = self->Z() - eyez; + dz = self->_f_Z() - eyez; } else { @@ -3333,7 +3316,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst) return 0; } - self->vel.x = self->vel.y = self->vel.z = 0; + self->Vel.Zero(); self->height = self->GetDefault()->height; // [RH] In Hexen, this creates a random number of shards (range [24,56]) @@ -3352,9 +3335,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst) if (mo) { - mo->vel.z = FixedDiv(mo->Z() - self->Z(), self->height)<<2; - mo->vel.x = pr_burst.Random2 () << (FRACBITS-7); - mo->vel.y = pr_burst.Random2 () << (FRACBITS-7); + mo->Vel.Z = 4 * (mo->Z() - self->Z()) * self->_Height(); + mo->Vel.X = pr_burst.Random2() / 128.; + mo->Vel.Y = pr_burst.Random2() / 128.; mo->RenderStyle = self->RenderStyle; mo->alpha = self->alpha; mo->CopyFriendliness(self, true); @@ -3383,7 +3366,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFloor) PARAM_ACTION_PROLOGUE; PARAM_STATE(jump); - if (self->Z() <= self->floorz) + if (self->_f_Z() <= self->floorz) { ACTION_RETURN_STATE(jump); } @@ -3402,7 +3385,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckCeiling) PARAM_ACTION_PROLOGUE; PARAM_STATE(jump); - if (self->Top() >= self->ceilingz) // Height needs to be counted + if (self->_f_Top() >= self->ceilingz) // Height needs to be counted { ACTION_RETURN_STATE(jump); } @@ -3418,11 +3401,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckCeiling) DEFINE_ACTION_FUNCTION(AActor, A_Stop) { PARAM_ACTION_PROLOGUE; - self->vel.x = self->vel.y = self->vel.z = 0; + self->Vel.Zero(); if (self->player && self->player->mo == self && !(self->player->cheats & CF_PREDICTING)) { self->player->mo->PlayIdle(); - self->player->vel.x = self->player->vel.y = 0; + self->player->Vel.Zero(); } return 0; } @@ -3431,11 +3414,10 @@ static void CheckStopped(AActor *self) { if (self->player != NULL && self->player->mo == self && - !(self->player->cheats & CF_PREDICTING) && - !(self->vel.x | self->vel.y | self->vel.z)) + !(self->player->cheats & CF_PREDICTING) && !self->Vel.isZero()) { self->player->mo->PlayIdle(); - self->player->vel.x = self->player->vel.y = 0; + self->player->Vel.Zero(); } } @@ -3460,7 +3442,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) PARAM_INT_OPT(flags) { flags = RSF_FOG; } bool oktorespawn = false; - fixedvec3 pos = self->Pos(); + fixedvec3 pos = self->_f_Pos(); self->flags |= MF_SOLID; self->height = self->GetDefault()->height; @@ -3470,11 +3452,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) if (flags & RSF_TELEFRAG) { // [KS] DIE DIE DIE DIE erm *ahem* =) - oktorespawn = P_TeleportMove(self, self->Pos(), true, false); + oktorespawn = P_TeleportMove(self, self->_f_Pos(), true, false); } else { - oktorespawn = P_CheckPosition(self, self->X(), self->Y(), true); + oktorespawn = P_CheckPosition(self, self->_f_X(), self->_f_Y(), true); } if (oktorespawn) @@ -3512,7 +3494,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) if (flags & RSF_FOG) { P_SpawnTeleportFog(self, pos, true, true); - P_SpawnTeleportFog(self, self->Pos(), false, true); + P_SpawnTeleportFog(self, self->_f_Pos(), false, true); } if (self->CountsAsKill()) { @@ -3738,7 +3720,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) if (self->player != NULL) { // Synced with hitscan: self->player->mo->height is strangely conscientious about getting the right actor for player - offsetheight = FixedMul(offsetheight, FixedMul (self->player->mo->height, self->player->crouchfactor)); + offsetheight = FixedMul(offsetheight, fixed_t(self->player->mo->height * self->player->crouchfactor)); } else { @@ -3760,7 +3742,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) pos.z += (self->height >> 1); if (self->player != NULL) { - pos.z += FixedMul (self->player->mo->AttackZOffset, self->player->crouchfactor); + pos.z += fixed_t (self->player->mo->AttackZOffset * self->player->crouchfactor); } else { @@ -3806,11 +3788,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) } else if (flags & CLOFF_AIM_VERT_NOOFFSET) { - pitch -= VecToAngle(xydist, FIXED2FLOAT(target->Z() - pos.z + offsetheight + target->height / 2)); + pitch -= VecToAngle(xydist, FIXED2FLOAT(target->_f_Z() - pos.z + offsetheight + target->height / 2)); } else { - pitch -= VecToAngle(xydist, FIXED2FLOAT(target->Z() - pos.z + target->height / 2)); + pitch -= VecToAngle(xydist, FIXED2FLOAT(target->_f_Z() - pos.z + target->height / 2)); } } else if (flags & CLOFF_ALLOWNULL) @@ -4520,7 +4502,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetRoll) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ScaleVelocity) { PARAM_ACTION_PROLOGUE; - PARAM_FIXED(scale); + PARAM_FLOAT(scale); PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } AActor *ref = COPY_AAPTR(self, ptr); @@ -4530,11 +4512,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ScaleVelocity) return 0; } - INTBOOL was_moving = ref->vel.x | ref->vel.y | ref->vel.z; + bool was_moving = !ref->Vel.isZero(); - ref->vel.x = FixedMul(ref->vel.x, scale); - ref->vel.y = FixedMul(ref->vel.y, scale); - ref->vel.z = FixedMul(ref->vel.z, scale); + ref->Vel *= scale; // If the actor was previously moving but now is not, and is a player, // update its player variables. (See A_Stop.) @@ -4554,9 +4534,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ScaleVelocity) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity) { PARAM_ACTION_PROLOGUE; - PARAM_FIXED_OPT (x) { x = 0; } - PARAM_FIXED_OPT (y) { y = 0; } - PARAM_FIXED_OPT (z) { z = 0; } + PARAM_FLOAT_OPT (x) { x = 0; } + PARAM_FLOAT_OPT (y) { y = 0; } + PARAM_FLOAT_OPT (z) { z = 0; } PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (ptr) { ptr = AAPTR_DEFAULT; } @@ -4567,28 +4547,24 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity) return 0; } - INTBOOL was_moving = ref->vel.x | ref->vel.y | ref->vel.z; + INTBOOL was_moving = !ref->Vel.isZero(); - fixed_t vx = x, vy = y, vz = z; - fixed_t sina = finesine[ref->_f_angle() >> ANGLETOFINESHIFT]; - fixed_t cosa = finecosine[ref->_f_angle() >> ANGLETOFINESHIFT]; + DVector3 vel(x, y, z); + double sina = ref->Angles.Yaw.Sin(); + double cosa = ref->Angles.Yaw.Cos(); if (flags & 1) // relative axes - make x, y relative to actor's current angle { - vx = DMulScale16(x, cosa, -y, sina); - vy = DMulScale16(x, sina, y, cosa); + vel.X = x*cosa - y*sina; + vel.Y = x*sina + y*cosa; } if (flags & 2) // discard old velocity - replace old velocity with new velocity { - ref->vel.x = vx; - ref->vel.y = vy; - ref->vel.z = vz; + ref->Vel = vel; } else // add new velocity to old velocity { - ref->vel.x += vx; - ref->vel.y += vy; - ref->vel.z += vz; + ref->Vel += vel; } if (was_moving) @@ -4797,7 +4773,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport) target_type = PClass::FindActor("BossSpot"); } - AActor *spot = state->GetSpotWithMinMaxDistance(target_type, ref->X(), ref->Y(), mindist, maxdist); + AActor *spot = state->GetSpotWithMinMaxDistance(target_type, ref->_f_X(), ref->_f_Y(), mindist, maxdist); if (spot == NULL) { return numret; @@ -4809,28 +4785,28 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport) // of the spot. if (flags & TF_SENSITIVEZ) { - fixed_t posz = (flags & TF_USESPOTZ) ? spot->Z() : spot->floorz; + fixed_t posz = (flags & TF_USESPOTZ) ? spot->_f_Z() : spot->floorz; if ((posz + ref->height > spot->ceilingz) || (posz < spot->floorz)) { return numret; } } - fixedvec3 prev = ref->Pos(); - fixed_t aboveFloor = spot->Z() - spot->floorz; + fixedvec3 prev = ref->_f_Pos(); + fixed_t aboveFloor = spot->_f_Z() - spot->floorz; fixed_t finalz = spot->floorz + aboveFloor; - if (spot->Z() + ref->height > spot->ceilingz) + if (spot->_f_Z() + ref->height > spot->ceilingz) finalz = spot->ceilingz - ref->height; - else if (spot->Z() < spot->floorz) + else if (spot->_f_Z() < spot->floorz) finalz = spot->floorz; //Take precedence and cooperate with telefragging first. - bool tele_result = P_TeleportMove(ref, spot->X(), spot->Y(), finalz, !!(flags & TF_TELEFRAG)); + bool tele_result = P_TeleportMove(ref, spot->_f_X(), spot->_f_Y(), finalz, !!(flags & TF_TELEFRAG)); if (!tele_result && (flags & TF_FORCED)) { //If for some reason the original move didn't work, regardless of telefrag, force it to move. - ref->SetOrigin(spot->X(), spot->Y(), finalz, false); + ref->SetOrigin(spot->_f_X(), spot->_f_Y(), finalz, false); tele_result = true; } @@ -4855,23 +4831,22 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport) if (!(flags & TF_NODESTFOG)) { if (flags & TF_USEACTORFOG) - P_SpawnTeleportFog(ref, ref->Pos(), false, true); + P_SpawnTeleportFog(ref, ref->_f_Pos(), false, true); else { - fog2 = Spawn(fog_type, ref->Pos(), ALLOW_REPLACE); + fog2 = Spawn(fog_type, ref->_f_Pos(), ALLOW_REPLACE); if (fog2 != NULL) fog2->target = ref; } } } - ref->SetZ((flags & TF_USESPOTZ) ? spot->Z() : ref->floorz, false); + ref->_f_SetZ((flags & TF_USESPOTZ) ? spot->_f_Z() : ref->floorz, false); if (!(flags & TF_KEEPANGLE)) ref->Angles.Yaw = spot->Angles.Yaw; - if (!(flags & TF_KEEPVELOCITY)) - ref->vel.x = ref->vel.y = ref->vel.z = 0; + if (!(flags & TF_KEEPVELOCITY)) ref->Vel.Zero(); if (!(flags & TF_NOJUMP)) //The state jump should only happen with the calling actor. { @@ -4978,8 +4953,8 @@ void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdis if (xydist != 0 && xyspeed != 0) { dist = MulScale13(finesine[weaveXY << BOBTOFINESHIFT], xydist); - newX = self->X() - FixedMul (finecosine[angle], dist); - newY = self->Y() - FixedMul (finesine[angle], dist); + newX = self->_f_X() - FixedMul (finecosine[angle], dist); + newY = self->_f_Y() - FixedMul (finesine[angle], dist); weaveXY = (weaveXY + xyspeed) & 63; dist = MulScale13(finesine[weaveXY << BOBTOFINESHIFT], xydist); newX += FixedMul (finecosine[angle], dist); @@ -4993,8 +4968,8 @@ void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdis self->UnlinkFromWorld (); self->flags |= MF_NOBLOCKMAP; // We need to do portal offsetting here explicitly, because SetXY cannot do that. - newX -= self->X(); - newY -= self->Y(); + newX -= self->_f_X(); + newY -= self->_f_Y(); self->SetXY(self->Vec2Offset(newX, newY)); self->LinkToWorld (); } @@ -5002,9 +4977,9 @@ void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdis } if (zdist != 0 && zspeed != 0) { - self->AddZ(-MulScale13(finesine[weaveZ << BOBTOFINESHIFT], zdist)); + self->_f_AddZ(-MulScale13(finesine[weaveZ << BOBTOFINESHIFT], zdist)); weaveZ = (weaveZ + zspeed) & 63; - self->AddZ(MulScale13(finesine[weaveZ << BOBTOFINESHIFT], zdist)); + self->_f_AddZ(MulScale13(finesine[weaveZ << BOBTOFINESHIFT], zdist)); self->WeaveIndexZ = weaveZ; } } @@ -5094,7 +5069,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) bool dodge = (P_CheckSight(self->target, self) && (angle>226 || angle<30)); // Distance check is simplistic - fixedvec2 vec = self->Vec2To(self->target); + fixedvec2 vec = self->_f_Vec2To(self->target); fixed_t dx = abs (vec.x); fixed_t dy = abs (vec.y); fixed_t dist = dx > dy ? dx : dy; @@ -5107,9 +5082,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) dist /= blocksize; // Now for the speed accuracy thingie - fixed_t speed = FixedMul(self->target->vel.x, self->target->vel.x) - + FixedMul(self->target->vel.y, self->target->vel.y) - + FixedMul(self->target->vel.z, self->target->vel.z); + fixed_t speed = FixedMul(self->target->_f_velx(), self->target->_f_velx()) + + FixedMul(self->target->_f_vely(), self->target->_f_vely()) + + FixedMul(self->target->_f_velz(), self->target->_f_velz()); int hitchance = speed < runspeed ? 256 : 160; // Distance accuracy (factoring dodge) @@ -5127,7 +5102,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) // Compute position for spawning blood/puff angle = self->target->__f_AngleTo(self); - fixedvec3 bloodpos = self->target->Vec3Angle(self->target->radius, angle, self->target->height >> 1); + fixedvec3 bloodpos = self->target->_f_Vec3Angle(self->target->radius, angle, self->target->height >> 1); int damage = flags & WAF_NORANDOM ? maxdamage : (1 + (pr_cabullet() % maxdamage)); @@ -5464,7 +5439,7 @@ static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amo if (selfPass || monsterPass || corpsePass || killedPass || itemPass || objectPass || missilePass || playerPass || voodooPass) { - fixedvec3 diff = self->Vec3To(thing); + fixedvec3 diff = self->_f_Vec3To(thing); diff.z += (thing->height - self->height) / 2; if (flags & RGF_CUBE) { // check if inside a cube @@ -5550,8 +5525,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive) else { FPortalGroupArray check(FPortalGroupArray::PGA_Full3d); - fixed_t mid = self->Z() + self->height / 2; - FMultiBlockThingsIterator it(check, self->X(), self->Y(), mid-distance, mid+distance, distance, false, self->Sector); + fixed_t mid = self->_f_Z() + self->height / 2; + FMultiBlockThingsIterator it(check, self->_f_X(), self->_f_Y(), mid-distance, mid+distance, distance, false, self->Sector); FMultiBlockThingsIterator::CheckResult cres; while ((it.Next(&cres))) @@ -5650,7 +5625,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropItem) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpeed) { PARAM_ACTION_PROLOGUE; - PARAM_FIXED(speed); + PARAM_FLOAT(speed); PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } AActor *ref = COPY_AAPTR(self, ptr); @@ -5670,7 +5645,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpeed) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetFloatSpeed) { PARAM_ACTION_PROLOGUE; - PARAM_FIXED(speed); + PARAM_FLOAT(speed); PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } AActor *ref = COPY_AAPTR(self, ptr); @@ -6382,11 +6357,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHigherOrLower) if (mobj != NULL && mobj != self) //AAPTR_DEFAULT is completely useless in this regard. { - if ((high) && (mobj->Z() > ((includeHeight ? self->height : 0) + self->Z() + offsethigh))) + if ((high) && (mobj->_f_Z() > ((includeHeight ? self->height : 0) + self->_f_Z() + offsethigh))) { ACTION_RETURN_STATE(high); } - else if ((low) && (mobj->Z() + (includeHeight ? mobj->height : 0)) < (self->Z() + offsetlow)) + else if ((low) && (mobj->_f_Z() + (includeHeight ? mobj->height : 0)) < (self->_f_Z() + offsetlow)) { ACTION_RETURN_STATE(low); } @@ -6567,8 +6542,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckProximity) //Ripped from sphere checking in A_RadiusGive (along with a number of things). if ((ref->AproxDistance(mo) < distance && ((flags & CPXF_NOZ) || - ((ref->Z() > mo->Z() && ref->Z() - mo->Top() < distance) || - (ref->Z() <= mo->Z() && mo->Z() - ref->Top() < distance))))) + ((ref->_f_Z() > mo->_f_Z() && ref->_f_Z() - mo->_f_Top() < distance) || + (ref->_f_Z() <= mo->_f_Z() && mo->_f_Z() - ref->_f_Top() < distance))))) { if ((flags & CPXF_CHECKSIGHT) && !(P_CheckSight(mo, ref, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY))) continue; @@ -6680,7 +6655,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock) } //Nothing to block it so skip the rest. - bool checker = (flags & CBF_DROPOFF) ? P_CheckMove(mobj, mobj->X(), mobj->Y()) : P_TestMobjLocation(mobj); + bool checker = (flags & CBF_DROPOFF) ? P_CheckMove(mobj, mobj->_f_X(), mobj->_f_Y()) : P_TestMobjLocation(mobj); if (checker) { ACTION_RETURN_STATE(NULL); @@ -6744,10 +6719,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection) } //Don't bother calculating this if we don't have any horizontal movement. - if (!(flags & FMDF_NOANGLE) && (mobj->vel.x != 0 || mobj->vel.y != 0)) + if (!(flags & FMDF_NOANGLE) && (mobj->Vel.X != 0 || mobj->Vel.Y != 0)) { angle_t current = mobj->_f_angle(); - const angle_t angle = R_PointToAngle2(0, 0, mobj->vel.x, mobj->vel.y); + const angle_t angle = R_PointToAngle2(0, 0, mobj->_f_velx(), mobj->_f_vely()); //Done because using anglelimit directly causes a signed/unsigned mismatch. const angle_t limit = anglelimit; @@ -6782,8 +6757,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection) if (!(flags & FMDF_NOPITCH)) { fixed_t current = mobj->_f_pitch(); - const DVector2 velocity(mobj->vel.x, mobj->vel.y); - const fixed_t pitch = R_PointToAngle2(0, 0, xs_CRoundToInt(velocity.Length()), -mobj->vel.z); + const DVector2 velocity(mobj->_f_velx(), mobj->_f_vely()); + const fixed_t pitch = R_PointToAngle2(0, 0, xs_CRoundToInt(velocity.Length()), -mobj->_f_velz()); if (pitchlimit > 0) { // [MC] angle_t for pitchlimit was required because otherwise diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 60fe737bf..cca433fff 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -635,12 +635,12 @@ void InitThingdef() symt.AddSymbol(new PField(NAME_X, TypeFixed, VARF_Native, myoffsetof(AActor,__pos.x))); // must remain read-only! symt.AddSymbol(new PField(NAME_Y, TypeFixed, VARF_Native, myoffsetof(AActor,__pos.y))); // must remain read-only! symt.AddSymbol(new PField(NAME_Z, TypeFixed, VARF_Native, myoffsetof(AActor,__pos.z))); // must remain read-only! - symt.AddSymbol(new PField(NAME_VelX, TypeFixed, VARF_Native, myoffsetof(AActor,vel.x))); - symt.AddSymbol(new PField(NAME_VelY, TypeFixed, VARF_Native, myoffsetof(AActor,vel.y))); - symt.AddSymbol(new PField(NAME_VelZ, TypeFixed, VARF_Native, myoffsetof(AActor,vel.z))); - symt.AddSymbol(new PField(NAME_MomX, TypeFixed, VARF_Native, myoffsetof(AActor,vel.x))); - symt.AddSymbol(new PField(NAME_MomY, TypeFixed, VARF_Native, myoffsetof(AActor,vel.y))); - symt.AddSymbol(new PField(NAME_MomZ, TypeFixed, VARF_Native, myoffsetof(AActor,vel.z))); + symt.AddSymbol(new PField(NAME_VelX, TypeFloat64, VARF_Native, myoffsetof(AActor,Vel.X))); + symt.AddSymbol(new PField(NAME_VelY, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Y))); + symt.AddSymbol(new PField(NAME_VelZ, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Z))); + symt.AddSymbol(new PField(NAME_MomX, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.X))); + symt.AddSymbol(new PField(NAME_MomY, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Y))); + symt.AddSymbol(new PField(NAME_MomZ, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Z))); symt.AddSymbol(new PField(NAME_ScaleX, TypeFixed, VARF_Native, myoffsetof(AActor,scaleX))); symt.AddSymbol(new PField(NAME_ScaleY, TypeFixed, VARF_Native, myoffsetof(AActor,scaleY))); symt.AddSymbol(new PField(NAME_Score, TypeSInt32, VARF_Native, myoffsetof(AActor,Score))); @@ -650,7 +650,7 @@ void InitThingdef() symt.AddSymbol(new PField(NAME_Radius, TypeFixed, VARF_Native, myoffsetof(AActor,radius))); symt.AddSymbol(new PField(NAME_ReactionTime,TypeSInt32, VARF_Native, myoffsetof(AActor,reactiontime))); symt.AddSymbol(new PField(NAME_MeleeRange, TypeFixed, VARF_Native, myoffsetof(AActor,meleerange))); - symt.AddSymbol(new PField(NAME_Speed, TypeFixed, VARF_Native, myoffsetof(AActor,Speed))); + symt.AddSymbol(new PField(NAME_Speed, TypeFloat64, VARF_Native, myoffsetof(AActor,Speed))); symt.AddSymbol(new PField(NAME_Threshold, TypeSInt32, VARF_Native, myoffsetof(AActor,threshold))); symt.AddSymbol(new PField(NAME_DefThreshold,TypeSInt32, VARF_Native, myoffsetof(AActor,DefThreshold))); } diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index d84e10493..51b8dee54 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -606,7 +606,7 @@ DEFINE_PROPERTY(projectilekickback, I, Actor) //========================================================================== DEFINE_PROPERTY(speed, F, Actor) { - PROP_FIXED_PARM(id, 0); + PROP_DOUBLE_PARM(id, 0); defaults->Speed = id; } @@ -615,8 +615,8 @@ DEFINE_PROPERTY(speed, F, Actor) //========================================================================== DEFINE_PROPERTY(floatspeed, F, Actor) { - PROP_FIXED_PARM(id, 0); - defaults->FloatSpeed=id; + PROP_DOUBLE_PARM(id, 0); + defaults->FloatSpeed = id; } //========================================================================== @@ -1300,7 +1300,7 @@ DEFINE_PROPERTY(poisondamagetype, S, Actor) //========================================================================== DEFINE_PROPERTY(fastspeed, F, Actor) { - PROP_FIXED_PARM(i, 0); + PROP_DOUBLE_PARM(i, 0); assert(info->IsKindOf(RUNTIME_CLASS(PClassActor))); static_cast(info)->FastSpeed = i; } @@ -1330,8 +1330,8 @@ DEFINE_PROPERTY(cameraheight, F, Actor) //========================================================================== DEFINE_PROPERTY(vspeed, F, Actor) { - PROP_FIXED_PARM(i, 0); - defaults->vel.z = i; + PROP_DOUBLE_PARM(i, 0); + defaults->Vel.Z = i; } //========================================================================== @@ -2513,7 +2513,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, attackzoffset, F, PlayerPawn) //========================================================================== DEFINE_CLASS_PROPERTY_PREFIX(player, jumpz, F, PlayerPawn) { - PROP_FIXED_PARM(z, 0); + PROP_DOUBLE_PARM(z, 0); defaults->JumpZ = z; } @@ -2600,11 +2600,11 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, aircapacity, F, PlayerPawn) //========================================================================== DEFINE_CLASS_PROPERTY_PREFIX(player, forwardmove, F_f, PlayerPawn) { - PROP_FIXED_PARM(m, 0); + PROP_DOUBLE_PARM(m, 0); defaults->ForwardMove1 = defaults->ForwardMove2 = m; if (PROP_PARM_COUNT > 1) { - PROP_FIXED_PARM(m2, 1); + PROP_DOUBLE_PARM(m2, 1); defaults->ForwardMove2 = m2; } } @@ -2614,11 +2614,11 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, forwardmove, F_f, PlayerPawn) //========================================================================== DEFINE_CLASS_PROPERTY_PREFIX(player, sidemove, F_f, PlayerPawn) { - PROP_FIXED_PARM(m, 0); + PROP_DOUBLE_PARM(m, 0); defaults->SideMove1 = defaults->SideMove2 = m; if (PROP_PARM_COUNT > 1) { - PROP_FIXED_PARM(m2, 1); + PROP_DOUBLE_PARM(m2, 1); defaults->SideMove2 = m2; } } diff --git a/src/vectors.h b/src/vectors.h index 6c171317a..9eaa375cf 100644 --- a/src/vectors.h +++ b/src/vectors.h @@ -257,11 +257,8 @@ struct TVector2 return X*other.X + Y*other.Y; } - // Returns the angle (in radians) that the ray (0,0)-(X,Y) faces - double Angle() const - { - return g_atan2 (X, Y); - } + // Returns the angle that the ray (0,0)-(X,Y) faces + TAngle Angle() const; // Returns a rotated vector. angle is in degrees. TVector2 Rotated (double angle) @@ -326,6 +323,11 @@ struct TVector3 Z = Y = X = 0; } + bool isZero() const + { + return X == 0 && Y == 0 && Z == 0; + } + TVector3 &operator= (const TVector3 &other) { Z = other.Z, Y = other.Y, X = other.X; @@ -470,11 +472,16 @@ struct TVector3 return *this; } - // Add a 3D vector and a 2D vector. - // Discards the Z component of the 3D vector and returns a 2D vector. - friend Vector2 operator+ (const TVector3 &v3, const Vector2 &v2) + // returns the XY fields as a 2D-vector. + Vector2 XY() const { - return Vector2(v3.X + v2.X, v3.Y + v2.Y); + return{ X, Y }; + } + + // Add a 3D vector and a 2D vector. + friend TVector3 operator+ (const TVector3 &v3, const Vector2 &v2) + { + return TVector3(v3.X + v2.X, v3.Y + v2.Y, v3.Z); } friend Vector2 operator+ (const Vector2 &v2, const TVector3 &v3) @@ -494,6 +501,12 @@ struct TVector3 return Vector2(v2.X - v3.X, v2.Y - v3.Y); } + + + // Returns the angle (in radians) that the ray (0,0)-(X,Y) faces + TAngle Angle() const; + TAngle Pitch() const; + // Vector length double Length() const { @@ -522,15 +535,21 @@ struct TVector3 } // Resizes this vector to be the specified length (if it is not 0) - TVector3 &Resize(double len) + TVector3 &MakeResize(double len) { - double nowlen = Length(); - X = vec_t(X * (len /= nowlen)); - Y = vec_t(Y * len); - Z = vec_t(Z * len); + double scale = len / Length(); + X = vec_t(X * scale); + Y = vec_t(Y * scale); + Z = vec_t(Z * scale); return *this; } + TVector3 Resized(double len) + { + double scale = len / Length(); + return{ vec_t(X * scale), vec_t(Y * scale), vec_t(Z * scale) }; + } + // Dot product double operator | (const TVector3 &other) const { @@ -1014,7 +1033,7 @@ struct TAngle TVector2 ToVector(vec_t length) const { - return TVector2(length * Cos(), length * Sin()); + return TVector2(length * Cos(), length * Sin()); } int FixedAngle() // for ACS. This must be normalized so it just converts to BAM first and then shifts 16 bits right. @@ -1037,6 +1056,12 @@ struct TAngle return g_tan(Degrees * (M_PI / 180.)); } + // This is for calculating vertical velocity. For high pitches the tangent will become too large to be useful. + double TanClamped(double max = 5.) const + { + return clamp(Tan(), -max, max); + } + }; template @@ -1104,6 +1129,24 @@ inline TAngle VecToAngle (const TVector3 &vec) return (T)g_atan2(vec.Y, vec.X) * (180.0 / M_PI); } +template +TAngle TVector2::Angle() const +{ + return VecToAngle(X, Y); +} + +template +TAngle TVector3::Angle() const +{ + return VecToAngle(X, Y); +} + +template +TAngle TVector3::Pitch() const +{ + return VecToAngle(TVector2(X, Y).Length(), Z); +} + // Much of this is copied from TVector3. Is all that functionality really appropriate? template struct TRotator diff --git a/src/version.h b/src/version.h index 17fd288b1..1d0e7506c 100644 --- a/src/version.h +++ b/src/version.h @@ -72,11 +72,11 @@ const char *GetVersionString(); // SAVESIG should match SAVEVER. // MINSAVEVER is the minimum level snapshot version that can be loaded. -#define MINSAVEVER 3100 +#define MINSAVEVER 4535 // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4534 +#define SAVEVER 4535 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index f33532e29..bdfd9f958 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -727,7 +727,7 @@ void CalculateCPUSpeed() PerfToMillisec = PerfToSec * 1000.0; } - if (!batchrun) Printf ("CPU Speed: %.0f MHz\n", 0.001 / PerfToMillisec); + if (!batchrun) Printf ("CPU _f_speed(): %.0f MHz\n", 0.001 / PerfToMillisec); } //========================================================================== diff --git a/wadsrc/static/actors/strife/strifeweapons.txt b/wadsrc/static/actors/strife/strifeweapons.txt index 4e4990e98..b807f110a 100644 --- a/wadsrc/static/actors/strife/strifeweapons.txt +++ b/wadsrc/static/actors/strife/strifeweapons.txt @@ -740,7 +740,7 @@ ACTOR StrifeGrenadeLauncher : StrifeWeapon Tag "$TAG_GLAUNCHER1" Inventory.PickupMessage "$TXT_GLAUNCHER" - action native A_FireGrenade (class grenadetype, int angleofs, state flash); + action native A_FireGrenade (class grenadetype, float angleofs, state flash); States {