diff --git a/src/actor.h b/src/actor.h index af5ca12be..8fb48cf37 100644 --- a/src/actor.h +++ b/src/actor.h @@ -590,7 +590,7 @@ public: DDropItem *GetDropItems() const; // Return true if the monster should use a missile attack, false for melee - bool SuggestMissileAttack (fixed_t dist); + bool SuggestMissileAttack (double dist); // Adjusts the angle for deflection/reflection of incoming missiles // Returns true if the missile should be allowed to explode anyway @@ -837,25 +837,20 @@ public: // to distinguish between portal-aware and portal-unaware distance calculation. fixed_t AproxDistance(AActor *other, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->_f_Pos() : other->PosRelative(this); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_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->_f_Pos() : other->PosRelative(this); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_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), _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->_f_Pos() : other->PosRelative(this); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this); return (DVector2(_f_X() - otherpos.x, _f_Y() - otherpos.y).Length())/FRACUNIT; } @@ -867,13 +862,13 @@ public: // a full 3D version of the above fixed_t Distance3D(AActor *other, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->_f_Pos() : other->PosRelative(this); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_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->_f_Pos() : other->PosRelative(this); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this); return R_PointToAngle2(_f_X(), _f_Y(), otherpos.x, otherpos.y); } @@ -884,13 +879,13 @@ public: DAngle AngleTo(AActor *other, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->_f_Pos() : other->PosRelative(this); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_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->_f_Pos() : other->PosRelative(this); + fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this); return VecToAngle(otherpos.y + oxofs - _f_Y(), otherpos.x + oyofs - _f_X()); } @@ -901,27 +896,27 @@ public: fixedvec2 _f_Vec2To(AActor *other) const { - fixedvec3 otherpos = other->PosRelative(this); + fixedvec3 otherpos = other->_f_PosRelative(this); fixedvec2 ret = { otherpos.x - _f_X(), otherpos.y - _f_Y() }; return ret; } fixedvec3 _f_Vec3To(AActor *other) const { - fixedvec3 otherpos = other->PosRelative(this); + fixedvec3 otherpos = other->_f_PosRelative(this); 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); + fixedvec3 otherpos = other->_f_PosRelative(this); return{ FIXED2DBL(otherpos.x - _f_X()), FIXED2DBL(otherpos.y - _f_Y()) }; } DVector3 Vec3To(AActor *other) const { - fixedvec3 otherpos = other->PosRelative(this); + fixedvec3 otherpos = other->_f_PosRelative(this); return { FIXED2DBL(otherpos.x - _f_X()), FIXED2DBL(otherpos.y - _f_Y()), FIXED2DBL(otherpos.z - _f_Z()) }; } @@ -1235,18 +1230,18 @@ public: SBYTE LastLookPlayerNumber;// Player number last looked for (if TIDtoHate == 0) ActorBounceFlags BounceFlags; // which bouncing type? DWORD SpawnFlags; // Increased to DWORD because of Doom 64 - fixed_t meleerange; // specifies how far a melee attack reaches. - fixed_t meleethreshold; // Distance below which a monster doesn't try to shoot missiles anynore + double meleerange; // specifies how far a melee attack reaches. + double meleethreshold; // Distance below which a monster doesn't try to shoot missiles anynore // but instead tries to come closer for a melee attack. // This is not the same as meleerange - fixed_t maxtargetrange; // any target farther away cannot be attacked - fixed_t bouncefactor; // Strife's grenades use 50%, Hexen's Flechettes 70. - fixed_t wallbouncefactor; // The bounce factor for walls can be different. + double maxtargetrange; // any target farther away cannot be attacked + double bouncefactor; // Strife's grenades use 50%, Hexen's Flechettes 70. + double wallbouncefactor; // The bounce factor for walls can be different. int bouncecount; // Strife's grenades only bounce twice before exploding double Gravity; // [GRB] Gravity factor - fixed_t Friction; + double Friction; int FastChaseStrafeCount; - fixed_t pushfactor; + double pushfactor; int lastpush; int activationtype; // How the thing behaves when activated with USESPECIAL or BUMPSPECIAL int lastbump; // Last time the actor was bumped, used to control BUMPSPECIAL @@ -1419,10 +1414,10 @@ public: return DVector3(X(), Y(), Z()); } - fixedvec3 PosRelative(int grp) const; - fixedvec3 PosRelative(const AActor *other) const; - fixedvec3 PosRelative(sector_t *sec) const; - fixedvec3 PosRelative(line_t *line) const; + fixedvec3 _f_PosRelative(int grp) const; + fixedvec3 _f_PosRelative(const AActor *other) const; + fixedvec3 _f_PosRelative(sector_t *sec) const; + fixedvec3 _f_PosRelative(line_t *line) const; fixed_t SoundX() const { @@ -1478,14 +1473,6 @@ public: { return Z() + Height/2; } - double _pushfactor() const - { - return FIXED2DBL(pushfactor); - } - double _bouncefactor() const - { - return FIXED2DBL(bouncefactor); - } void SetZ(double newz, bool moving = true) { __pos.z = FLOAT2FIXED(newz); diff --git a/src/am_map.cpp b/src/am_map.cpp index a8076550c..65cc1c583 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2732,7 +2732,7 @@ void AM_drawPlayers () if (p->mo != NULL) { - fixedvec3 pos = p->mo->PosRelative(MapPortalGroup); + fixedvec3 pos = p->mo->_f_PosRelative(MapPortalGroup); pt.x = pos.x >> FRACTOMAPBITS; pt.y = pos.y >> FRACTOMAPBITS; @@ -2766,7 +2766,7 @@ void AM_drawKeys () while ((key = it.Next()) != NULL) { - fixedvec3 pos = key->PosRelative(MapPortalGroup); + fixedvec3 pos = key->_f_PosRelative(MapPortalGroup); p.x = pos.x >> FRACTOMAPBITS; p.y = pos.y >> FRACTOMAPBITS; @@ -2813,7 +2813,7 @@ void AM_drawThings () { if (am_cheat > 0 || !(t->flags6 & MF6_NOTONAUTOMAP)) { - fixedvec3 pos = t->PosRelative(MapPortalGroup); + fixedvec3 pos = t->_f_PosRelative(MapPortalGroup); p.x = pos.x >> FRACTOMAPBITS; p.y = pos.y >> FRACTOMAPBITS; diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index a9188411d..02237944e 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -1141,14 +1141,12 @@ static int PatchThing (int thingy) } // MBF bounce factors depend on flag combos: - enum - { - MBF_BOUNCE_NOGRAVITY = FRACUNIT, // With NOGRAVITY: full momentum - MBF_BOUNCE_FLOATDROPOFF = (FRACUNIT * 85) / 100,// With FLOAT and DROPOFF: 85% - MBF_BOUNCE_FLOAT = (FRACUNIT * 70) / 100,// With FLOAT alone: 70% - MBF_BOUNCE_DEFAULT = (FRACUNIT * 45) / 100,// Without the above flags: 45% - MBF_BOUNCE_WALL = (FRACUNIT * 50) / 100,// Bouncing off walls: 50% - }; + const double MBF_BOUNCE_NOGRAVITY = 1; // With NOGRAVITY: full momentum + const double MBF_BOUNCE_FLOATDROPOFF = 0.85; // With FLOAT and DROPOFF: 85% + const double MBF_BOUNCE_FLOAT = 0.7; // With FLOAT alone: 70% + const double MBF_BOUNCE_DEFAULT = 0.45; // Without the above flags: 45% + const double MBF_BOUNCE_WALL = 0.5; // Bouncing off walls: 50% + info->bouncefactor = ((value[0] & MF_NOGRAVITY) ? MBF_BOUNCE_NOGRAVITY : (value[0] & MF_FLOAT) ? (value[0] & MF_DROPOFF) ? MBF_BOUNCE_FLOATDROPOFF : MBF_BOUNCE_FLOAT : MBF_BOUNCE_DEFAULT); diff --git a/src/d_player.h b/src/d_player.h index 2a2c99027..598ccdd48 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -150,17 +150,17 @@ public: // [GRB] Player class properties double JumpZ; - fixed_t GruntSpeed; - fixed_t FallingScreamMinSpeed, FallingScreamMaxSpeed; + double GruntSpeed; + double FallingScreamMinSpeed, FallingScreamMaxSpeed; double ViewHeight; double ForwardMove1, ForwardMove2; double SideMove1, SideMove2; FTextureID ScoreIcon; int SpawnMask; FNameNoInit MorphWeapon; - fixed_t AttackZOffset; // attack height, relative to player center - fixed_t UseRange; // [NS] Distance at which player can +use - fixed_t AirCapacity; // Multiplier for air supply underwater. + double AttackZOffset; // attack height, relative to player center + double UseRange; // [NS] Distance at which player can +use + double AirCapacity; // Multiplier for air supply underwater. PClassActor *FlechetteType; diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 609ec1721..1e9a1c655 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -80,7 +80,6 @@ PSound *TypeSound; PColor *TypeColor; PStatePointer *TypeState; PFixed *TypeFixed; -PAngle *TypeAngle; // PRIVATE DATA DEFINITIONS ------------------------------------------------ @@ -507,7 +506,6 @@ void PType::StaticInit() RUNTIME_CLASS(PClass)->TypeTableType = RUNTIME_CLASS(PClass); RUNTIME_CLASS(PStatePointer)->TypeTableType = RUNTIME_CLASS(PStatePointer); RUNTIME_CLASS(PFixed)->TypeTableType = RUNTIME_CLASS(PFixed); - RUNTIME_CLASS(PAngle)->TypeTableType = RUNTIME_CLASS(PAngle); // Create types and add them type the type table. TypeTable.AddType(TypeError = new PErrorType); @@ -527,7 +525,6 @@ void PType::StaticInit() TypeTable.AddType(TypeColor = new PColor); TypeTable.AddType(TypeState = new PStatePointer); TypeTable.AddType(TypeFixed = new PFixed); - TypeTable.AddType(TypeAngle = new PAngle); GlobalSymbols.AddSymbol(new PSymbolType(NAME_sByte, TypeSInt8)); GlobalSymbols.AddSymbol(new PSymbolType(NAME_Byte, TypeUInt8)); @@ -546,7 +543,6 @@ void PType::StaticInit() GlobalSymbols.AddSymbol(new PSymbolType(NAME_Color, TypeColor)); GlobalSymbols.AddSymbol(new PSymbolType(NAME_State, TypeState)); GlobalSymbols.AddSymbol(new PSymbolType(NAME_Fixed, TypeFixed)); - GlobalSymbols.AddSymbol(new PSymbolType(NAME_Angle, TypeAngle)); } @@ -1146,67 +1142,6 @@ int PFixed::GetLoadOp() const return OP_LX; } -/* PAngle *****************************************************************/ - -IMPLEMENT_CLASS(PAngle) - -//========================================================================== -// -// PAngle Default Constructor -// -//========================================================================== - -PAngle::PAngle() -: PFloat(sizeof(angle_t)) -{ -} - -//========================================================================== -// -// PAngle :: SetValue -// -//========================================================================== - -void PAngle::SetValue(void *addr, int val) -{ - assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address"); - *(angle_t *)addr = Scale(val, ANGLE_90, 90); -} - -//========================================================================== -// -// PAngle :: GetValueInt -// -//========================================================================== - -int PAngle::GetValueInt(void *addr) const -{ - assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address"); - return *(angle_t *)addr / ANGLE_1; -} - -//========================================================================== -// -// PAngle :: GetStoreOp -// -//========================================================================== - -int PAngle::GetStoreOp() const -{ - return OP_SANG; -} - -//========================================================================== -// -// PAngle :: GetLoadOp -// -//========================================================================== - -int PAngle::GetLoadOp() const -{ - return OP_LANG; -} - /* PStatePointer **********************************************************/ IMPLEMENT_CLASS(PStatePointer) diff --git a/src/dobjtype.h b/src/dobjtype.h index b482efe45..6c25d4a2c 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -415,18 +415,6 @@ public: virtual int GetLoadOp() const; }; -class PAngle : public PFloat -{ - DECLARE_CLASS(PAngle, PFloat); -public: - PAngle(); - - virtual void SetValue(void *addr, int val); - virtual int GetValueInt(void *addr) const; - virtual int GetStoreOp() const; - virtual int GetLoadOp() const; -}; - // Pointers ----------------------------------------------------------------- class PStatePointer : public PBasicType @@ -784,7 +772,6 @@ extern PSound *TypeSound; extern PColor *TypeColor; extern PStatePointer *TypeState; extern PFixed *TypeFixed; -extern PAngle *TypeAngle; // A constant value --------------------------------------------------------- diff --git a/src/doomdef.h b/src/doomdef.h index 346a73f0f..67c43787c 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -366,13 +366,10 @@ enum // magnetized floors, etc. Less friction can create ice. #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 ORIG_FRICTION (0xE800/65536.) // original value +#define ORIG_FRICTION_FACTOR (2048/65536.) // original value +#define FRICTION_LOW (0xf900/65536.) +#define FRICTION_FLY (0xeb00/65536.) #define BLINKTHRESHOLD (4*32) diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 936574570..53f757223 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -122,8 +122,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; } PARAM_INT_OPT (flags) { flags = 0; } PARAM_FLOAT_OPT (range) { range = 0; } - PARAM_DANGLE_OPT(spread_xy) { spread_xy = 2.8125; } - PARAM_DANGLE_OPT(spread_z) { spread_z = 0.; } + PARAM_ANGLE_OPT (spread_xy) { spread_xy = 2.8125; } + PARAM_ANGLE_OPT (spread_z) { spread_z = 0.; } PARAM_FLOAT_OPT (lifesteal) { lifesteal = 0; } PARAM_INT_OPT (lifestealmax) { lifestealmax = 0; } PARAM_CLASS_OPT (armorbonustype, ABasicArmorBonus) { armorbonustype = NULL; } @@ -564,7 +564,11 @@ static void FireRailgun(AActor *self, int offset_xy, bool fromweapon) damage = deathmatch ? 100 : 150; - P_RailAttack (self, damage, offset_xy); + FRailParams p; + p.source = self; + p.damage = damage; + p.offset_xy = offset_xy; + P_RailAttack (&p); } @@ -632,9 +636,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) PARAM_CLASS_OPT (spraytype, AActor) { spraytype = NULL; } PARAM_INT_OPT (numrays) { numrays = 0; } PARAM_INT_OPT (damagecnt) { damagecnt = 0; } - PARAM_DANGLE_OPT(angle) { angle = 0.; } + PARAM_ANGLE_OPT (angle) { angle = 0.; } PARAM_FLOAT_OPT (distance) { distance = 0; } - PARAM_DANGLE_OPT(vrange) { vrange = 0.; } + PARAM_ANGLE_OPT (vrange) { vrange = 0.; } PARAM_INT_OPT (defdamage) { defdamage = 0; } int i; diff --git a/src/g_doom/a_painelemental.cpp b/src/g_doom/a_painelemental.cpp index ead3ed91d..3620b88db 100644 --- a/src/g_doom/a_painelemental.cpp +++ b/src/g_doom/a_painelemental.cpp @@ -153,7 +153,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PainAttack) return 0; PARAM_CLASS_OPT (spawntype, AActor) { spawntype = NULL; } - PARAM_DANGLE_OPT (angle) { angle = 0.; } + PARAM_ANGLE_OPT (angle) { angle = 0.; } PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (limit) { limit = -1; } diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index 89b2690e1..c82e0874b 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -73,7 +73,7 @@ void AFastProjectile::Tick () if (tm.ceilingline && tm.ceilingline->backsector && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - Z() >= tm.ceilingline->backsector->ceilingplane.ZatPointF(PosRelative(tm.ceilingline))) + Z() >= tm.ceilingline->backsector->ceilingplane.ZatPointF(_f_PosRelative(tm.ceilingline))) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index e16b7e480..a970f8969 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -238,9 +238,8 @@ double DEarthquake::GetFalloff(double dist) const else if ((dist > m_Falloff) && (dist < m_TremorRadius)) { //Player inside the radius, and outside the min distance for falloff. double tremorsize = m_TremorRadius - m_Falloff; - double tremordist = dist - m_Falloff; assert(tremorsize > 0); - return (1. - tremordist) / tremorsize; + return (1. - ((dist - m_Falloff) / tremorsize)); } else { //Shouldn't happen. diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index 9c866011b..7fc4a105f 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -690,7 +690,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade) { PARAM_ACTION_PROLOGUE; PARAM_CLASS(grenadetype, AActor); - PARAM_DANGLE(angleofs); + PARAM_ANGLE(angleofs); PARAM_STATE(flash) player_t *player = self->player; diff --git a/src/info.cpp b/src/info.cpp index 68488e0f2..e997d9717 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -230,7 +230,7 @@ PClassActor::PClassActor() WoundHealth = 6; PoisonDamage = 0; FastSpeed = -1.; - RDFactor = FRACUNIT; + RDFactor = 1.; CameraHeight = INT_MIN; DropItems = NULL; diff --git a/src/info.h b/src/info.h index f0a08048c..decfd72df 100644 --- a/src/info.h +++ b/src/info.h @@ -250,7 +250,7 @@ public: int WoundHealth; // Health needed to enter wound state int PoisonDamage; // Amount of poison damage double FastSpeed; // speed in fast mode - fixed_t RDFactor; // Radius damage factor + double RDFactor; // Radius damage factor double CameraHeight; // Height of camera when used as such FSoundID HowlSound; // Sound being played when electrocuted or poisoned FName BloodType; // Blood replacement type diff --git a/src/p_acs.cpp b/src/p_acs.cpp index ffb854575..1f28ed636 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3998,7 +3998,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) break; case APROP_MeleeRange: - actor->meleerange = value; + actor->meleerange = ACSToDouble(value); break; case APROP_ViewHeight: @@ -4014,7 +4014,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) case APROP_AttackZOffset: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn))) - static_cast(actor)->AttackZOffset = value; + static_cast(actor)->AttackZOffset = ACSToDouble(value); break; case APROP_StencilColor: @@ -4022,7 +4022,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) break; case APROP_Friction: - actor->Friction = value; + actor->Friction = ACSToDouble(value); default: // do nothing. @@ -4093,10 +4093,10 @@ int DLevelScript::GetActorProperty (int tid, int property) case APROP_Mass: return actor->Mass; case APROP_Accuracy: return actor->accuracy; case APROP_Stamina: return actor->stamina; - case APROP_Height: return actor->_f_height(); - case APROP_Radius: return actor->_f_radius(); + case APROP_Height: return DoubleToACS(actor->Height); + case APROP_Radius: return DoubleToACS(actor->radius); case APROP_ReactionTime:return actor->reactiontime; - case APROP_MeleeRange: return actor->meleerange; + case APROP_MeleeRange: return DoubleToACS(actor->meleerange); case APROP_ViewHeight: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn))) { return DoubleToACS(static_cast(actor)->ViewHeight); @@ -4108,7 +4108,7 @@ int DLevelScript::GetActorProperty (int tid, int property) case APROP_AttackZOffset: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn))) { - return static_cast(actor)->AttackZOffset; + return DoubleToACS(static_cast(actor)->AttackZOffset); } else { @@ -4123,7 +4123,7 @@ int DLevelScript::GetActorProperty (int tid, int property) case APROP_Species: return GlobalACSStrings.AddString(actor->GetSpecies()); case APROP_NameTag: return GlobalACSStrings.AddString(actor->GetTag()); case APROP_StencilColor:return actor->fillcolor; - case APROP_Friction: return actor->Friction; + case APROP_Friction: return DoubleToACS(actor->Friction); default: return 0; } @@ -5990,7 +5990,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) if (activator == NULL || !reference) return false; - if (P_Thing_Warp(activator, reference, xofs, yofs, zofs, angle, flags, heightoffset, radiusoffset, pitch)) + if (P_Thing_Warp(activator, reference, ACSToDouble(xofs), ACSToDouble(yofs), ACSToDouble(zofs), ACSToAngle(angle), flags, ACSToDouble(heightoffset), ACSToDouble(radiusoffset), ACSToAngle(pitch))) { if (state && argCount > 6) { diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 442d5fd4c..ba994d4e2 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -313,7 +313,7 @@ void P_ThinkParticles () } } -void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t vx, fixed_t vy, fixed_t vz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, WORD size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz) +void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t vx, fixed_t vy, fixed_t vz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, int size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz) { particle_t *particle = NewParticle(); @@ -334,7 +334,7 @@ void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t vx, fixed_t vy, fi particle->accy = accely; particle->accz = accelz; particle->bright = fullbright; - particle->size = size; + particle->size = (WORD)size; } } diff --git a/src/p_effect.h b/src/p_effect.h index 4d246af83..856f0d824 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -83,7 +83,12 @@ particle_t *JitterParticle (int ttl); particle_t *JitterParticle (int ttl, double drift); void P_ThinkParticles (void); -void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t vx, fixed_t vy, fixed_t vz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, WORD size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz); +void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t vx, fixed_t vy, fixed_t vz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, int size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz); +inline void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, bool fullbright, double startalpha, int lifetime, WORD size, double fadestep) +{ + P_SpawnParticle(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), FLOAT2FIXED(vel.X), FLOAT2FIXED(vel.Y), FLOAT2FIXED(vel.Z), + color, fullbright, BYTE(startalpha * 255), BYTE(lifetime), WORD(size), fadestep < 0 ? -1 : int(fadestep * 255), FLOAT2FIXED(accel.X), FLOAT2FIXED(accel.Y), FLOAT2FIXED(accel.Z)); +} void P_InitEffects (void); void P_RunEffects (void); diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index e9e0e66d4..904b41bf9 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -264,14 +264,14 @@ bool AActor::CheckMeleeRange () { AActor *pl = target; - fixed_t dist; + double dist; if (!pl) return false; - dist = AproxDistance (pl); + dist = Distance2D (pl); - if (dist >= meleerange + pl->_f_radius()) + if (dist >= meleerange + pl->radius) return false; // [RH] If moving toward goal, then we've reached it. @@ -306,7 +306,7 @@ bool AActor::CheckMeleeRange () bool P_CheckMeleeRange2 (AActor *actor) { AActor *mo; - fixed_t dist; + double dist; if (!actor->target) @@ -314,8 +314,8 @@ bool P_CheckMeleeRange2 (AActor *actor) return false; } mo = actor->target; - dist = mo->AproxDistance (actor); - if (dist >= (128 << FRACBITS) || dist < actor->meleerange + mo->_f_radius()) + dist = mo->Distance2D (actor); + if (dist >= 128 || dist < actor->meleerange + mo->radius) { return false; } @@ -348,7 +348,7 @@ bool P_CheckMeleeRange2 (AActor *actor) //============================================================================= bool P_CheckMissileRange (AActor *actor) { - fixed_t dist; + double dist; if (!P_CheckSight (actor, actor->target, SF_SEEPASTBLOCKEVERYTHING)) return false; @@ -387,15 +387,15 @@ bool P_CheckMissileRange (AActor *actor) // OPTIMIZE: get this from a global checksight // [RH] What? - dist = actor->AproxDistance (actor->target) - 64*FRACUNIT; + dist = actor->Distance2D (actor->target) - 64; if (actor->MeleeState == NULL) - dist -= 128*FRACUNIT; // no melee attack, so fire more + dist -= 128; // no melee attack, so fire more return actor->SuggestMissileAttack (dist); } -bool AActor::SuggestMissileAttack (fixed_t dist) +bool AActor::SuggestMissileAttack (double dist) { // new version encapsulates the different behavior in flags instead of virtual functions // The advantage is that this allows inheriting the missile attack attributes from the @@ -407,11 +407,11 @@ bool AActor::SuggestMissileAttack (fixed_t dist) if (MeleeState != NULL && dist < meleethreshold) return false; // From the Revenant: close enough for fist attack - if (flags4 & MF4_MISSILEMORE) dist >>= 1; - if (flags4 & MF4_MISSILEEVENMORE) dist >>= 3; + if (flags4 & MF4_MISSILEMORE) dist *= 0.5; + if (flags4 & MF4_MISSILEEVENMORE) dist *= 0.125; int mmc = int(MinMissileChance * G_SkillProperty(SKILLP_Aggressiveness)); - return pr_checkmissilerange() >= MIN (dist >> FRACBITS, mmc); + return pr_checkmissilerange() >= MIN (int(dist), mmc); } //============================================================================= @@ -453,9 +453,9 @@ bool P_Move (AActor *actor) fixed_t tryx, tryy, deltax, deltay, origx, origy; bool try_ok; - int speed = actor->_f_speed(); - int movefactor = ORIG_FRICTION_FACTOR; - int friction = ORIG_FRICTION; + fixed_t speed = actor->_f_speed(); + double movefactor = ORIG_FRICTION_FACTOR; + double friction = ORIG_FRICTION; int dropoff = 0; if (actor->flags2 & MF2_BLASTED) @@ -503,8 +503,7 @@ bool P_Move (AActor *actor) if (friction < ORIG_FRICTION) { // sludge - speed = ((ORIG_FRICTION_FACTOR - (ORIG_FRICTION_FACTOR-movefactor)/2) - * speed) / ORIG_FRICTION_FACTOR; + speed = fixed_t(speed * ((ORIG_FRICTION_FACTOR - (ORIG_FRICTION_FACTOR-movefactor)/2)) / ORIG_FRICTION_FACTOR); if (speed == 0) { // always give the monster a little bit of speed speed = ksgn(actor->_f_speed()); @@ -564,9 +563,9 @@ bool P_Move (AActor *actor) if (try_ok && friction > ORIG_FRICTION) { actor->SetOrigin(origx, origy, actor->_f_Z(), false); - movefactor *= FRACUNIT / ORIG_FRICTION_FACTOR / 4; - actor->Vel.X += FIXED2DBL(FixedMul (deltax, movefactor)); - actor->Vel.Y += FIXED2DBL(FixedMul (deltay, movefactor)); + movefactor *= 1.f / ORIG_FRICTION_FACTOR / 4; + actor->Vel.X += FIXED2DBL(deltax * movefactor); + actor->Vel.Y += FIXED2DBL(deltay * movefactor); } // [RH] If a walking monster is no longer on the floor, move it down @@ -589,7 +588,7 @@ bool P_Move (AActor *actor) else { // The monster just hit the floor, so trigger any actions. if (actor->floorsector->SecActTarget != NULL && - actor->_f_floorz() == actor->floorsector->floorplane.ZatPoint(actor->PosRelative(actor->floorsector))) + actor->_f_floorz() == actor->floorsector->floorplane.ZatPoint(actor->_f_PosRelative(actor->floorsector))) { actor->floorsector->SecActTarget->TriggerAction(actor, SECSPAC_HitFloor); } @@ -899,8 +898,8 @@ void P_NewChaseDir(AActor * actor) box.Bottom() < line->bbox[BOXTOP] && box.BoxOnLineSide(line) == -1) { - double front = line->frontsector->floorplane.ZatPointF(actor->PosRelative(line)); - double back = line->backsector->floorplane.ZatPointF(actor->PosRelative(line)); + double front = line->frontsector->floorplane.ZatPointF(actor->_f_PosRelative(line)); + double back = line->backsector->floorplane.ZatPointF(actor->_f_PosRelative(line)); DAngle angle; // The monster must contact one of the two floors, @@ -965,16 +964,16 @@ void P_NewChaseDir(AActor * actor) if (actor->flags3 & MF3_AVOIDMELEE) { bool ismeleeattacker = false; - fixed_t dist = actor->AproxDistance(target); + double dist = actor->Distance2D(target); if (target->player == NULL) { - ismeleeattacker = (target->MissileState == NULL && dist < (target->meleerange + target->_f_radius())*2); + ismeleeattacker = (target->MissileState == NULL && dist < (target->meleerange + target->radius)*2); } else if (target->player->ReadyWeapon != NULL) { // melee range of player weapon is a parameter of the action function and cannot be checked here. // Add a new weapon property? - ismeleeattacker = (target->player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON && dist < (192 << FRACBITS)); + ismeleeattacker = ((target->player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON) && dist < 192); } if (ismeleeattacker) { @@ -1166,23 +1165,23 @@ void P_RandomChaseDir (AActor *actor) bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams *params) { - fixed_t maxdist; - fixed_t mindist; - angle_t fov; + double maxdist; + double mindist; + DAngle fov; if (params != NULL) { - maxdist = params->maxdist; - mindist = params->mindist; - fov = params->fov; + maxdist = params->maxDist; + mindist = params->minDist; + fov = params->Fov; } else { mindist = maxdist = 0; - fov = allaround ? 0 : ANGLE_180; + fov = allaround ? 0. : 180.; } - fixed_t dist = lookee->AproxDistance (other); + double dist = lookee->Distance2D (other); if (maxdist && dist > maxdist) return false; // [KS] too far @@ -1190,15 +1189,15 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams if (mindist && dist < mindist) return false; // [KS] too close - if (fov && fov < ANGLE_MAX) + if (fov != 0) { - angle_t an = lookee->__f_AngleTo(other) - lookee->_f_angle(); + DAngle an = absangle(lookee->AngleTo(other), lookee->Angles.Yaw); - if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) + if (an > (fov / 2)) { // if real close, react anyway // [KS] but respect minimum distance rules - if (mindist || dist > lookee->meleerange + lookee->_f_radius()) + if (mindist || dist > lookee->meleerange + lookee->radius) return false; // outside of fov } } @@ -1888,15 +1887,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) { PARAM_ACTION_PROLOGUE; PARAM_INT_OPT (flags) { flags = 0; } - PARAM_FIXED_OPT (minseedist) { minseedist = 0; } - PARAM_FIXED_OPT (maxseedist) { maxseedist = 0; } - PARAM_FIXED_OPT (maxheardist) { maxheardist = 0; } - PARAM_FLOAT_OPT (fov_f) { fov_f = 0; } + PARAM_FLOAT_OPT (minseedist) { minseedist = 0; } + PARAM_FLOAT_OPT (maxseedist) { maxseedist = 0; } + PARAM_FLOAT_OPT (maxheardist) { maxheardist = 0; } + PARAM_ANGLE_OPT (fov) { fov = 0.; } PARAM_STATE_OPT (seestate) { seestate = NULL; } AActor *targ = NULL; // Shuts up gcc fixed_t dist; - angle_t fov = (fov_f == 0) ? ANGLE_180 : FLOAT2ANGLE(fov_f); + if (fov == 0) fov = 180.; FLookExParams params = { fov, minseedist, maxseedist, maxheardist, flags, seestate }; if (self->flags5 & MF5_INCONVERSATION) @@ -2818,7 +2817,7 @@ enum FAF_Flags FAF_TOP = 4, FAF_NODISTFACTOR = 8, // deprecated }; -void A_Face (AActor *self, AActor *other, angle_t _max_turn, angle_t _max_pitch, angle_t _ang_offset, angle_t _pitch_offset, int flags, fixed_t z_add) +void A_Face(AActor *self, AActor *other, DAngle max_turn, DAngle max_pitch, DAngle ang_offset, DAngle pitch_offset, int flags, double z_add) { if (!other) return; @@ -2831,12 +2830,7 @@ void A_Face (AActor *self, AActor *other, angle_t _max_turn, angle_t _max_pitch, self->flags &= ~MF_AMBUSH; - DAngle max_turn = ANGLE2DBL(_max_turn); - DAngle ang_offset = ANGLE2DBL(_ang_offset); - DAngle max_pitch = ANGLE2DBL(_max_pitch); - DAngle pitch_offset = ANGLE2DBL(_pitch_offset); DAngle other_angle = self->AngleTo(other); - DAngle delta = deltaangle(self->Angles.Yaw, other_angle); // 0 means no limit. Also, if we turn in a single step anyways, no need to go through the algorithms. @@ -2883,7 +2877,7 @@ void A_Face (AActor *self, AActor *other, angle_t _max_turn, angle_t _max_pitch, if (flags & FAF_TOP) target_z = other->Top() + other->GetBobOffset(); - target_z += FIXED2FLOAT(z_add); + target_z += z_add; double dist_z = target_z - source_z; double ddist = g_sqrt(dist.X*dist.X + dist.Y*dist.Y + dist_z*dist_z); @@ -2927,12 +2921,12 @@ void A_FaceTarget(AActor *self) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceTarget) { PARAM_ACTION_PROLOGUE; - PARAM_ANGLE_OPT(max_turn) { max_turn = 0; } - PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270; } - PARAM_ANGLE_OPT(ang_offset) { ang_offset = 0; } - PARAM_ANGLE_OPT(pitch_offset) { pitch_offset = 0; } + PARAM_ANGLE_OPT(max_turn) { max_turn = 0.; } + PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270.; } + PARAM_ANGLE_OPT(ang_offset) { ang_offset = 0.; } + PARAM_ANGLE_OPT(pitch_offset) { pitch_offset = 0.; } PARAM_INT_OPT(flags) { flags = 0; } - PARAM_FIXED_OPT(z_add) { z_add = 0; } + PARAM_FLOAT_OPT(z_add) { z_add = 0; } A_Face(self, self->target, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_add); return 0; @@ -2941,12 +2935,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceTarget) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMaster) { PARAM_ACTION_PROLOGUE; - PARAM_ANGLE_OPT(max_turn) { max_turn = 0; } - PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270; } - PARAM_ANGLE_OPT(ang_offset) { ang_offset = 0; } - PARAM_ANGLE_OPT(pitch_offset) { pitch_offset = 0; } - PARAM_INT_OPT(flags) { flags = 0; } - PARAM_FIXED_OPT(z_add) { z_add = 0; } + PARAM_ANGLE_OPT(max_turn) { max_turn = 0.; } + PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270.; } + PARAM_ANGLE_OPT(ang_offset) { ang_offset = 0.; } + PARAM_ANGLE_OPT(pitch_offset) { pitch_offset = 0.; } + PARAM_INT_OPT(flags) { flags = 0; } + PARAM_FLOAT_OPT(z_add) { z_add = 0; } A_Face(self, self->master, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_add); return 0; @@ -2955,12 +2949,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMaster) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceTracer) { PARAM_ACTION_PROLOGUE; - PARAM_ANGLE_OPT(max_turn) { max_turn = 0; } - PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270; } - PARAM_ANGLE_OPT(ang_offset) { ang_offset = 0; } - PARAM_ANGLE_OPT(pitch_offset) { pitch_offset = 0; } - PARAM_INT_OPT(flags) { flags = 0; } - PARAM_FIXED_OPT(z_add) { z_add = 0; } + PARAM_ANGLE_OPT(max_turn) { max_turn = 0.; } + PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270.; } + PARAM_ANGLE_OPT(ang_offset) { ang_offset = 0.; } + PARAM_ANGLE_OPT(pitch_offset) { pitch_offset = 0.; } + PARAM_INT_OPT(flags) { flags = 0; } + PARAM_FLOAT_OPT(z_add) { z_add = 0; } A_Face(self, self->tracer, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_add); return 0; @@ -3010,7 +3004,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail) self->Angles.Yaw += pr_railface.Random2() * 45./256; } - P_RailAttack (self, self->GetMissileDamage (0, 1), 0); + FRailParams p; + + p.source = self; + p.damage = self->GetMissileDamage(0, 1); + P_RailAttack (&p); self->Angles.Pitch = saved_pitch; return 0; } diff --git a/src/p_enemy.h b/src/p_enemy.h index 467e74eba..2912f847f 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -38,10 +38,10 @@ enum LO_Flags struct FLookExParams { - angle_t fov; - fixed_t mindist; - fixed_t maxdist; - fixed_t maxheardist; + DAngle Fov; + double minDist; + double maxDist; + double maxHeardist; int flags; FState *seestate; }; @@ -78,7 +78,7 @@ void A_BossDeath(AActor *self); void A_Wander(AActor *self, int flags = 0); void A_Chase(VMFrameStack *stack, AActor *self); void A_FaceTarget(AActor *actor); -void A_Face(AActor *self, AActor *other, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270, angle_t ang_offset = 0, angle_t pitch_offset = 0, int flags = 0, fixed_t z_add = 0); +void A_Face(AActor *self, AActor *other, DAngle max_turn = 0., DAngle max_pitch = 270., DAngle ang_offset = 0., DAngle pitch_offset = 0., int flags = 0, double z_add = 0); bool A_RaiseMobj (AActor *, double speed); bool A_SinkMobj (AActor *, double speed); diff --git a/src/p_local.h b/src/p_local.h index bea8d9d20..367f54b3a 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -221,7 +221,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser); bool P_Thing_CanRaise(AActor *thing); PClassActor *P_GetSpawnableType(int spawnnum); void InitSpawnablesFromMapinfo(); -int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, fixed_t zofs, angle_t angle, int flags, fixed_t heightoffset, fixed_t radiusoffset, angle_t pitch); +int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, double zofs, DAngle angle, int flags, double heightoffset, double radiusoffset, DAngle pitch); enum WARPF { @@ -302,6 +302,10 @@ inline bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const sec return P_TryMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), dropoff, onfloor, tm, missileCheck); } bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y); +inline bool P_CheckMove(AActor *thing, double x, double y) +{ + return P_CheckMove(thing, FLOAT2FIXED(x), FLOAT2FIXED(y)); +} void P_ApplyTorque(AActor *mo); bool P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters inline bool P_TeleportMove(AActor* thing, const fixedvec3 &pos, bool telefrag, bool modifyactor = true) @@ -394,7 +398,28 @@ inline bool P_HitWater(AActor *thing, sector_t *sec, const fixedvec3 &pos, bool return P_HitWater(thing, sec, fpos, checkabove, alert, force); } void P_CheckSplash(AActor *self, double distance); -void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z = 0, int color1 = 0, int color2 = 0, double maxdiff = 0, int flags = 0, PClassActor *puff = NULL, angle_t angleoffset = 0, angle_t pitchoffset = 0, fixed_t distance = 8192*FRACUNIT, int duration = 0, double sparsity = 1.0, double drift = 1.0, PClassActor *spawnclass = NULL, int SpiralOffset = 270); // [RH] Shoot a railgun + +struct FRailParams +{ + AActor *source = nullptr; + int damage = 0; + double offset_xy = 0; + double offset_z = 0; + int color1 = 0, color2 = 0; + double maxdiff = 0; + int flags = 0; + PClassActor *puff = nullptr; + DAngle angleoffset = 0.; + DAngle pitchoffset = 0.; + double distance = 8192; + int duration = 0; + double sparsity = 1.0; + double drift = 1.0; + PClassActor *spawnclass = nullptr; + int SpiralOffset = 270; +}; // [RH] Shoot a railgun + +void P_RailAttack(FRailParams *params); enum // P_RailAttack / A_RailAttack / A_CustomRailgun / P_DrawRailTrail flags { @@ -428,16 +453,8 @@ void P_DelSector_List(); 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); +double P_GetMoveFactor(const AActor *mo, double *frictionp); // phares 3/6/98 +double P_GetFriction(const AActor *mo, double *frictionfactor); bool Check_Sides(AActor *, int, int); // phares // [RH] diff --git a/src/p_map.cpp b/src/p_map.cpp index fb341f285..77fceae4e 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -587,14 +587,15 @@ void P_PlayerStartStomp(AActor *actor, bool mononly) // //========================================================================== -int P_GetFriction(const AActor *mo, int *frictionfactor) +double P_GetFriction(const AActor *mo, double *frictionfactor) { - int friction = ORIG_FRICTION; - int movefactor = ORIG_FRICTION_FACTOR; - fixed_t newfriction; + double friction = ORIG_FRICTION; + double movefactor = ORIG_FRICTION_FACTOR; + double newfriction; + double newmf; + const msecnode_t *m; sector_t *sec; - fixed_t newmf; if (mo->IsNoClip2()) { @@ -608,7 +609,7 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) (mo->waterlevel == 1 && mo->Z() > mo->floorz+ 6)) { friction = mo->Sector->GetFriction(sector_t::floor, &movefactor); - movefactor >>= 1; + movefactor *= 0.5; // Check 3D floors -- might be the source of the waterlevel for (unsigned i = 0; i < mo->Sector->e->XFloor.ffloors.Size(); i++) @@ -625,7 +626,7 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) if (newfriction < friction || friction == ORIG_FRICTION) { friction = newfriction; - movefactor = newmf >> 1; + movefactor = newmf * 0.5; } } } @@ -637,7 +638,7 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) for (m = mo->touching_sectorlist; m; m = m->m_tnext) { sec = m->m_sector; - fixedvec3 pos = mo->PosRelative(sec); + fixedvec3 pos = mo->_f_PosRelative(sec); // 3D floors must be checked, too for (unsigned i = 0; i < sec->e->XFloor.ffloors.Size(); i++) @@ -648,13 +649,13 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) if (rover->flags & FF_SOLID) { // Must be standing on a solid floor - if (mo->_f_Z() != rover->top.plane->ZatPoint(pos)) continue; + if (mo->Z() != rover->top.plane->ZatPointF(pos)) continue; } else if (rover->flags & FF_SWIMMABLE) { // Or on or inside a swimmable floor (e.g. in shallow water) - if (mo->_f_Z() > rover->top.plane->ZatPoint(pos) || - (mo->_f_Top()) < rover->bottom.plane->ZatPoint(pos)) + if (mo->Z() > rover->top.plane->ZatPointF(pos) || + (mo->Top()) < rover->bottom.plane->ZatPointF(pos)) continue; } else @@ -664,7 +665,7 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) if (newfriction < friction || friction == ORIG_FRICTION) { friction = newfriction; - movefactor = newmf >> 1; + movefactor = newmf * 0.5; } } @@ -675,9 +676,9 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) } newfriction = sec->GetFriction(sector_t::floor, &newmf); if ((newfriction < friction || friction == ORIG_FRICTION) && - (mo->_f_Z() <= sec->floorplane.ZatPoint(pos) || + (mo->Z() <= sec->floorplane.ZatPointF(pos) || (sec->GetHeightSec() != NULL && - mo->_f_Z() <= sec->heightsec->floorplane.ZatPoint(pos)))) + mo->Z() <= sec->heightsec->floorplane.ZatPointF(pos)))) { friction = newfriction; movefactor = newmf; @@ -685,9 +686,9 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) } } - if (mo->Friction != FRACUNIT) + if (mo->Friction != 1) { - friction = clamp(FixedMul(friction, mo->Friction), 0, FRACUNIT); + friction = clamp((friction * mo->Friction), 0., 1.); movefactor = FrictionToMoveFactor(friction); } @@ -707,9 +708,9 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) // //========================================================================== -int P_GetMoveFactor(const AActor *mo, int *frictionp) +double P_GetMoveFactor(const AActor *mo, double *frictionp) { - int movefactor, friction; + double movefactor, friction; // If the floor is icy or muddy, it's harder to get moving. This is where // the different friction factors are applied to 'trying to move'. In @@ -723,11 +724,11 @@ int P_GetMoveFactor(const AActor *mo, int *frictionp) double velocity = mo->VelXYToSpeed(); if (velocity > MORE_FRICTION_VELOCITY * 4) - movefactor <<= 3; + movefactor *= 8; else if (velocity > MORE_FRICTION_VELOCITY * 2) - movefactor <<= 2; + movefactor *= 4; else if (velocity > MORE_FRICTION_VELOCITY) - movefactor <<= 1; + movefactor *= 2; } if (frictionp) @@ -808,7 +809,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec spechit_t spec; spec.line = ld; spec.refpos = cres.position; - spec.oldrefpos = tm.thing->PosRelative(ld); + spec.oldrefpos = tm.thing->_f_PosRelative(ld); portalhit.Push(spec); return true; } @@ -976,14 +977,14 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec { spec.line = ld; spec.refpos = cres.position; - spec.oldrefpos = tm.thing->PosRelative(ld); + spec.oldrefpos = tm.thing->_f_PosRelative(ld); spechit.Push(spec); } if (ld->isLinePortal()) { spec.line = ld; spec.refpos = cres.position; - spec.oldrefpos = tm.thing->PosRelative(ld); + spec.oldrefpos = tm.thing->_f_PosRelative(ld); portalhit.Push(spec); } @@ -1241,7 +1242,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch if (((tm.FromPMove || tm.thing->player != NULL) && thing->flags&MF_SOLID)) { - fixedvec3 oldpos = tm.thing->PosRelative(thing); + fixedvec3 oldpos = tm.thing->_f_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->_f_X() && oldpos.y == thing->_f_Y()) @@ -1477,7 +1478,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch { // Push thing if (thing->lastpush != tm.PushTime) { - thing->Vel += tm.thing->Vel.XY() * thing->_pushfactor(); + thing->Vel += tm.thing->Vel.XY() * thing->pushfactor; thing->lastpush = tm.PushTime; } } @@ -1535,7 +1536,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch { // Push thing if (thing->lastpush != tm.PushTime) { - thing->Vel += tm.thing->Vel.XY() * thing->_pushfactor(); + thing->Vel += tm.thing->Vel.XY() * thing->pushfactor; thing->lastpush = tm.PushTime; } } @@ -1962,7 +1963,7 @@ static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, fixedvec2 if (posforwindowcheck && !(ib_compatflags & BCOMPATF_NOWINDOWCHECK) && line->backsector != NULL) { // Make sure this line actually blocks us and is not a window // or similar construct we are standing inside of. - fixedvec3 pos = mobj->PosRelative(line); + fixedvec3 pos = mobj->_f_PosRelative(line); fixed_t fzt = line->frontsector->ceilingplane.ZatPoint(*posforwindowcheck); fixed_t fzb = line->frontsector->floorplane.ZatPoint(*posforwindowcheck); fixed_t bzt = line->backsector->ceilingplane.ZatPoint(*posforwindowcheck); @@ -2697,7 +2698,7 @@ void FSlide::HitSlideLine(line_t* ld) // The wall is angled. Bounce if the angle of approach is // phares // less than 45 degrees. // phares - fixedvec3 pos = slidemo->PosRelative(ld); + fixedvec3 pos = slidemo->_f_PosRelative(ld); side = P_PointOnLineSide(pos.x, pos.y, ld); lineangle = R_PointToAngle2(0, 0, ld->dx, ld->dy); @@ -2803,7 +2804,7 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t if (!(li->flags & ML_TWOSIDED) || !li->backsector) { - fixedvec3 pos = slidemo->PosRelative(li); + fixedvec3 pos = slidemo->_f_PosRelative(li); if (P_PointOnLineSide(pos.x, pos.y, li)) { // don't hit the back side @@ -3019,7 +3020,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov return NULL; } - fixedvec3 pos = actor->PosRelative(actor->floorsector); + fixedvec3 pos = actor->_f_PosRelative(actor->floorsector); const secplane_t *plane = &actor->floorsector->floorplane; fixed_t planezhere = plane->ZatPoint(pos); @@ -3099,7 +3100,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov sector_t *sec = node->m_sector; if (sec->floorplane.c >= STEEPSLOPE) { - fixedvec3 pos = actor->PosRelative(sec); + fixedvec3 pos = actor->_f_PosRelative(sec); pos.x += xmove; pos.y += ymove; @@ -3296,7 +3297,7 @@ bool FSlide::BounceWall(AActor *mo) deltaangle >>= ANGLETOFINESHIFT; movelen = fixed_t(g_sqrt(double(mo->_f_velx())*mo->_f_velx() + double(mo->_f_vely())*mo->_f_vely())); - movelen = FixedMul(movelen, mo->wallbouncefactor); + movelen = fixed_t(movelen * mo->wallbouncefactor); FBoundingBox box(mo->_f_X(), mo->_f_Y(), mo->_f_radius()); if (box.BoxOnLineSide(line) == -1) @@ -3356,7 +3357,7 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop) if (!ontop) { DAngle angle = BlockingMobj->AngleTo(mo) + ((pr_bounce() % 16) - 8); - double speed = mo->VelXYToSpeed() * FIXED2DBL(mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent + double speed = mo->VelXYToSpeed() * mo->wallbouncefactor; // [GZ] was 0.75, using wallbouncefactor seems more consistent mo->Angles.Yaw = ANGLE2DBL(angle); mo->VelFromAngle(speed); mo->PlayBounceSound(true); @@ -3393,13 +3394,13 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop) } else { - 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 = (mo->Vel.Z - 2. / dot) * mo->_bouncefactor(); + mo->Vel.Z = (mo->Vel.Z - 2. / dot) * mo->bouncefactor; } mo->PlayBounceSound(true); @@ -4026,7 +4027,7 @@ DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLin fixed_t shootz = t1->_f_Z() + (t1->_f_height() >> 1) - t1->_f_floorclip(); if (t1->player != NULL) { - shootz += fixed_t(t1->player->mo->AttackZOffset * t1->player->crouchfactor); + shootz += FLOAT2FIXED(t1->player->mo->AttackZOffset * t1->player->crouchfactor); } else { @@ -4171,7 +4172,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, shootz = t1->_f_Z() - t1->_f_floorclip() + (t1->_f_height() >> 1); if (t1->player != NULL) { - shootz += fixed_t(t1->player->mo->AttackZOffset * t1->player->crouchfactor); + shootz += FLOAT2FIXED(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, @@ -4432,7 +4433,7 @@ AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch, shootz = t1->_f_Z() - t1->_f_floorclip() + (t1->_f_height() >> 1); if (t1->player != NULL) { - shootz += fixed_t(t1->player->mo->AttackZOffset * t1->player->crouchfactor); + shootz += FLOAT2FIXED(t1->player->mo->AttackZOffset * t1->player->crouchfactor); } else { @@ -4680,51 +4681,45 @@ static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) // // //========================================================================== -void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, int color1, int color2, double maxdiff, int railflags, PClassActor *puffclass, angle_t angleoffset, angle_t pitchoffset, fixed_t distance, int duration, double sparsity, double drift, PClassActor *spawnclass, int SpiralOffset) +void P_RailAttack(FRailParams *p) { - fixed_t vx, vy, vz; - angle_t angle, pitch; - DVector3 start, end; + DVector3 start; FTraceResults trace; - fixed_t shootz; + PClassActor *puffclass = p->puff; if (puffclass == NULL) { puffclass = PClass::FindActor(NAME_BulletPuff); } - pitch = ((angle_t)(-source->_f_pitch()) + pitchoffset) >> ANGLETOFINESHIFT; - angle = (source->_f_angle() + angleoffset) >> ANGLETOFINESHIFT; + AActor *source = p->source; + DAngle pitch = -source->Angles.Pitch + p->pitchoffset; + DAngle angle = source->Angles.Yaw + p->angleoffset; - vx = FixedMul(finecosine[pitch], finecosine[angle]); - vy = FixedMul(finecosine[pitch], finesine[angle]); - vz = finesine[pitch]; + DVector3 vec(DRotator(pitch, angle, angle)); + double shootz = source->Center() - source->FloatSpeed + p->offset_z; - shootz = source->_f_Z() - source->_f_floorclip() + (source->_f_height() >> 1) + offset_z; - - if (!(railflags & RAF_CENTERZ)) + if (!(p->flags & RAF_CENTERZ)) { if (source->player != NULL) { - shootz += fixed_t(source->player->mo->AttackZOffset * source->player->crouchfactor); + shootz += source->player->mo->AttackZOffset * source->player->crouchfactor; } else { - shootz += 8 * FRACUNIT; + shootz += 8; } } - angle = ((source->_f_angle() + angleoffset) - ANG90) >> ANGLETOFINESHIFT; - - fixedvec2 xy = source->Vec2Offset(offset_xy * finecosine[angle], offset_xy * finesine[angle]); + DVector2 xy = source->Vec2Angle(p->offset_xy, angle - 90.); RailData rail_data; rail_data.Caller = source; - rail_data.StopAtOne = !!(railflags & RAF_NOPIERCE); - start.X = FIXED2DBL(xy.x); - start.Y = FIXED2DBL(xy.y); - start.Z = FIXED2DBL(shootz); + rail_data.StopAtOne = !!(p->flags & RAF_NOPIERCE); + start.X = xy.X; + start.Y = xy.Y; + start.Z = shootz; int flags; @@ -4734,9 +4729,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? 0 : TRACE_PCross | TRACE_Impact; rail_data.StopAtInvul = (puffDefaults->flags3 & MF3_FOILINVUL) ? false : true; rail_data.ThruSpecies = (puffDefaults->flags6 & MF6_MTHRUSPECIES) ? true : false; - Trace(xy.x, xy.y, shootz, source->Sector, vx, vy, vz, - distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING, source, trace, - flags, ProcessRailHit, &rail_data); + Trace(start, source->Sector, vec, p->distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING, source, trace, flags, ProcessRailHit, &rail_data); // Hurt anything the trace hit unsigned int i; @@ -4749,8 +4742,6 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i for (i = 0; i < rail_data.RailHits.Size(); i++) { - - bool spawnpuff; bool bleed = false; @@ -4788,12 +4779,12 @@ 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, p->damage, damagetype, dmgFlagPass|DMG_USEANGLE, hitangle); if (bleed) { - P_SpawnBlood(hitpos, hitangle, newdam > 0 ? newdam : damage, hitactor); - P_TraceBleed(newdam > 0 ? newdam : damage, hitpos, hitactor, hitangle, ANGLE2DBL(pitch)); + P_SpawnBlood(hitpos, hitangle, newdam > 0 ? newdam : p->damage, hitactor); + P_TraceBleed(newdam > 0 ? newdam : p->damage, hitpos, hitactor, hitangle, ANGLE2DBL(pitch)); } } @@ -4842,8 +4833,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i } // Draw the slug's trail. - end = trace.HitPos; - P_DrawRailTrail(source, start, end, color1, color2, maxdiff, railflags, spawnclass, source->_f_angle() + angleoffset, duration, sparsity, drift, SpiralOffset); + P_DrawRailTrail(source, start, trace.HitPos, p->color1, p->color2, p->maxdiff, p->flags, p->spawnclass, angle.BAMs(), p->duration, p->sparsity, p->drift, p->SpiralOffset); } //========================================================================== @@ -5091,8 +5081,6 @@ bool P_NoWayTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t e // //========================================================================== -CVAR(Int, userange, 0, 0); - void P_UseLines(player_t *player) { bool foundline = false; @@ -5100,7 +5088,7 @@ void P_UseLines(player_t *player) // If the player is transitioning a portal, use the group that is at its vertical center. fixedvec2 start = player->mo->GetPortalTransition(player->mo->_f_height() / 2); // [NS] Now queries the Player's UseRange. - fixedvec2 end = start + Vec2Angle(userange > 0? fixed_t(userange<mo->UseRange, player->mo->_f_angle()); + fixedvec2 end = start + Vec2Angle(FLOAT2FIXED(player->mo->UseRange), player->mo->_f_angle()); // old code: // @@ -5140,7 +5128,7 @@ bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) // [NS] If it's a Player, get their UseRange. if (PuzzleItemUser->player) - usedist = PuzzleItemUser->player->mo->UseRange; + usedist = FLOAT2FIXED(PuzzleItemUser->player->mo->UseRange); else usedist = USERANGE; @@ -5328,7 +5316,7 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo { points = points * splashfactor; } - points *= thing->GetClass()->RDFactor / (float)FRACUNIT; + points *= thing->GetClass()->RDFactor; // points and bombdamage should be the same sign if (((points * bombdamage) > 0) && P_CheckSight(thing, bombspot, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) @@ -5400,9 +5388,9 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo { // OK to damage; target is in direct path dist = clamp(dist - fulldamagedistance, 0, dist); int damage = Scale(bombdamage, bombdistance - dist, bombdistance); - damage = (int)((double)damage * splashfactor); - damage = Scale(damage, thing->GetClass()->RDFactor, FRACUNIT); + double factor = splashfactor * thing->GetClass()->RDFactor; + damage = int(damage * factor); if (damage > 0) { int newdam = P_DamageMobj(thing, bombspot, bombsource, damage, bombmod); diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 51c79358d..488260a7f 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -497,7 +497,7 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) for (int i = -1; i < (int)check.Size(); i++) { - fixedvec3 pos = i==-1? _f_Pos() : PosRelative(check[i]); + fixedvec3 pos = i==-1? _f_Pos() : _f_PosRelative(check[i]); int x1 = GetSafeBlockX(pos.x - _f_radius() - bmaporgx); int x2 = GetSafeBlockX(pos.x + _f_radius() - bmaporgx); diff --git a/src/p_maputl.h b/src/p_maputl.h index 6556029cd..96053dc90 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -356,6 +356,10 @@ public: FMultiBlockThingsIterator(FPortalGroupArray &check, AActor *origin, fixed_t checkradius = -1, bool ignorerestricted = false); FMultiBlockThingsIterator(FPortalGroupArray &check, fixed_t checkx, fixed_t checky, fixed_t checkz, fixed_t checkh, fixed_t checkradius, bool ignorerestricted, sector_t *newsec); + FMultiBlockThingsIterator(FPortalGroupArray &check, double checkx, double checky, double checkz, double checkh, double checkradius, bool ignorerestricted, sector_t *newsec) + : FMultiBlockThingsIterator(check, FLOAT2FIXED(checkx), FLOAT2FIXED(checky), FLOAT2FIXED(checkz), FLOAT2FIXED(checkh), FLOAT2FIXED(checkradius), ignorerestricted, newsec) + { + } bool Next(CheckResult *item); void Reset(); const FBoundingBox &Box() const diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 06cd8606c..17b529ca9 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1388,7 +1388,7 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) if (line != NULL && cl_missiledecals) { - fixedvec3 pos = mo->PosRelative(line); + fixedvec3 pos = mo->_f_PosRelative(line); int side = P_PointOnLineSidePrecise (pos.x, pos.y, line); if (line->sidedef[side] == NULL) side ^= 1; @@ -1583,12 +1583,12 @@ bool AActor::FloorBounceMissile (secplane_t &plane) flags &= ~MF_INBOUNCE; return false; } - else 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 = (Vel - plane.Normal() * dot) * _bouncefactor(); + Vel = (Vel - plane.Normal() * dot) * bouncefactor; AngleFromVel(); } @@ -2116,7 +2116,7 @@ explode: if (tm.ceilingline && tm.ceilingline->backsector && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - mo->_f_Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(mo->PosRelative(tm.ceilingline))) + mo->_f_Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(mo->_f_PosRelative(tm.ceilingline))) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. @@ -2269,7 +2269,7 @@ explode: // Reducing player velocity is no longer needed to reduce // bobbing, so ice works much better now. - double friction = FIXED2DBL(P_GetFriction (mo, NULL)); + double friction = P_GetFriction (mo, NULL); mo->Vel.X *= friction; mo->Vel.Y *= friction; @@ -2280,8 +2280,8 @@ explode: if (player && player->mo == mo) // Not voodoo dolls { - player->Vel.X *= fORIG_FRICTION; - player->Vel.Y *= fORIG_FRICTION; + player->Vel.X *= ORIG_FRICTION; + player->Vel.Y *= ORIG_FRICTION; } // Don't let the velocity become less than the smallest representable fixed point value. @@ -2452,11 +2452,11 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) { mo->_f_AddZ(finesine[(FINEANGLES/80*level.maptime)&FINEMASK]/8); } - mo->Vel.Z *= fFRICTION_FLY; + mo->Vel.Z *= FRICTION_FLY; } if (mo->waterlevel && !(mo->flags & MF_NOGRAVITY)) { - fixed_t friction = FIXED_MIN; + double friction = -1; // Check 3D floors -- might be the source of the waterlevel for (auto rover : mo->Sector->e->XFloor.ffloors) @@ -2464,17 +2464,17 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) 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->_f_height()/2 < rover->bottom.plane->ZatPoint(mo)) + if (mo->Z() >= rover->top.plane->ZatPointF(mo) || + mo->Center() < rover->bottom.plane->ZatPointF(mo)) continue; friction = rover->model->GetFriction(rover->top.isceiling); break; } - if (friction == FIXED_MIN) + if (friction < 0) friction = mo->Sector->GetFriction(); // get real friction, even if from a terrain definition - mo->Vel.Z *= FIXED2DBL(friction); + mo->Vel.Z *= friction; } // @@ -2716,7 +2716,7 @@ static void PlayerLandedOnThing (AActor *mo, AActor *onmobj) { grunted = false; // Why should this number vary by gravity? - if (mo->health > 0 && mo->_f_velz() < -mo->player->mo->GruntSpeed) + if (mo->health > 0 && mo->Vel.Z < -mo->player->mo->GruntSpeed) { S_Sound (mo, CHAN_VOICE, "*grunt", 1, ATTN_NORM); grunted = true; @@ -3263,7 +3263,7 @@ fixedvec3 AActor::GetPortalTransition(fixed_t byoffset, sector_t **pSec) AActor *port = sec->SkyBoxes[sector_t::ceiling]; if (testz > port->specialf1) { - pos = PosRelative(port->Sector); + pos = _f_PosRelative(port->Sector); sec = P_PointInSector(pos.x, pos.y); moved = true; } @@ -3276,7 +3276,7 @@ fixedvec3 AActor::GetPortalTransition(fixed_t byoffset, sector_t **pSec) AActor *port = sec->SkyBoxes[sector_t::floor]; if (testz <= port->specialf1) { - pos = PosRelative(port->Sector); + pos = _f_PosRelative(port->Sector); sec = P_PointInSector(pos.x, pos.y); } else break; @@ -3298,7 +3298,7 @@ void AActor::CheckPortalTransition(bool islinked) { fixedvec3 oldpos = _f_Pos(); if (islinked && !moved) UnlinkFromWorld(); - SetXYZ(PosRelative(port->Sector)); + SetXYZ(_f_PosRelative(port->Sector)); PrevX += _f_X() - oldpos.x; PrevY += _f_Y() - oldpos.y; PrevZ += _f_Z() - oldpos.z; @@ -3317,7 +3317,7 @@ void AActor::CheckPortalTransition(bool islinked) { fixedvec3 oldpos = _f_Pos(); if (islinked && !moved) UnlinkFromWorld(); - SetXYZ(PosRelative(port->Sector)); + SetXYZ(_f_PosRelative(port->Sector)); PrevX += _f_X() - oldpos.x; PrevY += _f_Y() - oldpos.y; PrevZ += _f_Z() - oldpos.z; @@ -3681,7 +3681,7 @@ void AActor::Tick () { continue; } - fixedvec3 pos = PosRelative(sec); + fixedvec3 pos = _f_PosRelative(sec); height = sec->floorplane.ZatPoint (pos); if (_f_Z() > height) { @@ -3731,7 +3731,7 @@ void AActor::Tick () floorplane = P_FindFloorPlane(floorsector, _f_X(), _f_Y(), _f_floorz()); if (floorplane.c < STEEPSLOPE && - floorplane.ZatPoint (PosRelative(floorsector)) <= _f_floorz()) + floorplane.ZatPoint (_f_PosRelative(floorsector)) <= _f_floorz()) { const msecnode_t *node; bool dopush = true; @@ -3743,7 +3743,7 @@ void AActor::Tick () const sector_t *sec = node->m_sector; if (sec->floorplane.c >= STEEPSLOPE) { - if (floorplane.ZatPointF (PosRelative(node->m_sector)) >= Z() - MaxStepHeight) + if (floorplane.ZatPointF (_f_PosRelative(node->m_sector)) >= Z() - MaxStepHeight) { dopush = false; break; @@ -4517,7 +4517,7 @@ void AActor::AdjustFloorClip () // do the floorclipping instead of the terrain type. for (m = touching_sectorlist; m; m = m->m_tnext) { - fixedvec3 pos = PosRelative(m->m_sector); + fixedvec3 pos = _f_PosRelative(m->m_sector); sector_t *hsec = m->m_sector->GetHeightSec(); if (hsec == NULL && m->m_sector->floorplane.ZatPoint (pos) == _f_Z()) { @@ -5684,7 +5684,7 @@ bool P_HitFloor (AActor *thing) fixedvec3 pos; for (m = thing->touching_sectorlist; m; m = m->m_tnext) { - pos = thing->PosRelative(m->m_sector); + pos = thing->_f_PosRelative(m->m_sector); if (thing->_f_Z() == m->m_sector->floorplane.ZatPoint(pos.x, pos.y)) { break; @@ -5729,7 +5729,7 @@ void P_CheckSplash(AActor *self, double distance) // 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 // behavior. - fixedvec3 pos = self->PosRelative(floorsec); + fixedvec3 pos = self->_f_PosRelative(floorsec); pos.z = self->_f_floorz(); P_HitWater (self, floorsec, pos, false, false); } @@ -6144,7 +6144,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, double x, double y, double z, // [XA] If MaxTargetRange is defined in the spawned projectile, use this as the // maximum range for the P_AimLineAttack call later; this allows MaxTargetRange // to function as a "maximum tracer-acquisition range" for seeker missiles. - double linetargetrange = defaultobject->maxtargetrange > 0 ? FIXED2DBL(defaultobject->maxtargetrange*64) : 16*64.; + double linetargetrange = defaultobject->maxtargetrange > 0 ? defaultobject->maxtargetrange*64 : 16*64.; int i = 2; do @@ -6177,7 +6177,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, double x, double y, double z, z += source->Center() - source->Floorclip; if (source->player != NULL) // Considering this is for player missiles, it better not be NULL. { - z += ((FIXED2DBL(source->player->mo->AttackZOffset) - 4) * source->player->crouchfactor); + z += ((source->player->mo->AttackZOffset - 4) * source->player->crouchfactor); } else { @@ -6672,8 +6672,8 @@ void PrintMiscActorInfo(AActor *query) for (flagi = 0; flagi <= 31; flagi++) if (query->flags7 & ActorFlags7::FromInt(1<BounceFlags.GetValue(), FIXED2DBL(query->bouncefactor), - FIXED2DBL(query->wallbouncefactor)); + query->BounceFlags.GetValue(), query->bouncefactor, + query->wallbouncefactor); /*for (flagi = 0; flagi < 31; flagi++) if (query->BounceFlags & 1<bob * Rangex); float boby = float(player->bob * Rangey); - switch (level.levelnum)//bobstyle) + switch (bobstyle) { case AWeapon::BobNormal: *x = bobx * angle.Cos(); diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 6a91d7072..10a8aedd7 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -1027,7 +1027,7 @@ 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 + double sector_t::GetFriction(int plane, double *pMoveFac) const { if (Flags & SECF_FRICTION) { diff --git a/src/p_sight.cpp b/src/p_sight.cpp index d9652cb01..20d7d2113 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -112,8 +112,8 @@ public: void init(AActor * t1, AActor * t2, sector_t *startsector, SightTask *task, int flags) { - sightstart = t1->PosRelative(task->portalgroup); - sightend = t2->PosRelative(task->portalgroup); + sightstart = t1->_f_PosRelative(task->portalgroup); + sightend = t2->_f_PosRelative(task->portalgroup); sightstart.z += t1->_f_height() - (t1->_f_height() >> 2); startfrac = task->frac; diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 97fbcb8bc..bd49e311e 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1224,12 +1224,12 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) break; case dSector_DoorRaiseIn5Mins: - new DDoor (sector, DDoor::doorWaitRaise, 2*FRACUNIT, TICRATE*30/7, 5*60*TICRATE, 0); + new DDoor (sector, DDoor::doorWaitRaise, 2*FRACUNIT, TICRATE*30/7, 0, 5*60*TICRATE); break; case dFriction_Low: sector->friction = FRICTION_LOW; - sector->movefactor = 0x269; + sector->movefactor = 0x269/65536.; sector->Flags |= SECF_FRICTION; break; @@ -2076,7 +2076,7 @@ static void P_SpawnFriction(void) } else { - length = P_AproxDistance(l->dx,l->dy)>>FRACBITS; + length = int(l->Delta().Length()); } P_SetSectorFriction (l->args[0], length, false); @@ -2088,14 +2088,14 @@ static void P_SpawnFriction(void) void P_SetSectorFriction (int tag, int amount, bool alterFlag) { int s; - fixed_t friction, movefactor; + double friction, movefactor; // An amount of 100 should result in a friction of // ORIG_FRICTION (0xE800) - friction = (0x1EB8*amount)/0x80 + 0xD001; + friction = ((0x1EB8 * amount) / 0x80 + 0xD001) / 65536.; // killough 8/28/98: prevent odd situations - friction = clamp(friction, 0, FRACUNIT); + friction = clamp(friction, 0., 1.); // The following check might seem odd. At the time of movement, // the move distance is multiplied by 'friction/0x10000', so a @@ -2133,6 +2133,26 @@ void P_SetSectorFriction (int tag, int amount, bool alterFlag) } } +double FrictionToMoveFactor(double friction) +{ + double movefactor; + + // [RH] Twiddled these values so that velocity on ice (with + // friction 0xf900) is the same as in Heretic/Hexen. + if (friction >= ORIG_FRICTION) // ice + //movefactor = ((0x10092 - friction)*(0x70))/0x158; + movefactor = (((0x10092 - friction * 65536) * 1024) / 4352 + 568) / 65536.; + else + movefactor = (((friction*65536. - 0xDB34)*(0xA)) / 0x80) / 65536.; + + // killough 8/28/98: prevent odd situations + if (movefactor < 1 / 2048.) + movefactor = 1 / 2048.; + + return movefactor; +} + + // // phares 3/12/98: End of friction effects // @@ -2314,7 +2334,7 @@ void DPusher::Tick () continue; sector_t *hsec = sec->GetHeightSec(); - fixedvec3 pos = thing->PosRelative(sec); + fixedvec3 pos = thing->_f_PosRelative(sec); DVector2 pushvel; if (m_Type == p_wind) { diff --git a/src/p_spec.h b/src/p_spec.h index 771558455..cfdbd5241 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -170,26 +170,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector=NULL); void P_PlayerOnSpecialFlat (player_t *player, int floorType); void P_SectorDamage(int tag, int amount, FName type, PClassActor *protectClass, int flags); void P_SetSectorFriction (int tag, int amount, bool alterFlag); - -inline fixed_t FrictionToMoveFactor(fixed_t friction) -{ - fixed_t movefactor; - - // [RH] Twiddled these values so that velocity on ice (with - // friction 0xf900) is the same as in Heretic/Hexen. - if (friction >= ORIG_FRICTION) // ice -// movefactor = ((0x10092 - friction)*(0x70))/0x158; - movefactor = ((0x10092 - friction) * 1024) / 4352 + 568; - else - movefactor = ((friction - 0xDB34)*(0xA))/0x80; - - // killough 8/28/98: prevent odd situations - if (movefactor < 32) - movefactor = 32; - - return movefactor; -} - +double FrictionToMoveFactor(double friction); void P_GiveSecret(AActor *actor, bool printmessage, bool playsound, int sectornum); // @@ -532,7 +513,7 @@ public: }; DDoor (sector_t *sector); - DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int topcountdown, int lightTag); + DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTag, int topcountdown); void Serialize (FArchive &arc); void Tick (); diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 2c0c8c2f6..2e5649d8e 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -140,7 +140,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo P_MakeDivline (line, &dll); - fixedvec3 pos = optpos? *optpos : user->PosRelative(line); + fixedvec3 pos = optpos? *optpos : user->_f_PosRelative(line); dlu.x = pos.x; dlu.y = pos.y; dlu.dx = finecosine[user->_f_angle() >> ANGLETOFINESHIFT]; diff --git a/src/p_terrain.cpp b/src/p_terrain.cpp index a91d7fe92..f99652758 100644 --- a/src/p_terrain.cpp +++ b/src/p_terrain.cpp @@ -488,15 +488,15 @@ static void ParseDamage (FScanner &sc, int keyword, void *fields) static void ParseFriction (FScanner &sc, int keyword, void *fields) { FTerrainDef *def = (FTerrainDef *)fields; - fixed_t friction, movefactor; + double friction, movefactor; sc.MustGetFloat (); // These calculations should match those in P_SetSectorFriction(). // A friction of 1.0 is equivalent to ORIG_FRICTION. - friction = (fixed_t)(0x1EB8*(sc.Float*100))/0x80 + 0xD001; - friction = clamp (friction, 0, FRACUNIT); + friction = (0x1EB8*(sc.Float*100))/0x80 + 0xD001; + friction = clamp (friction, 0, 65536.); if (friction > ORIG_FRICTION) // ice movefactor = ((0x10092 - friction) * 1024) / 4352 + 568; @@ -506,8 +506,8 @@ static void ParseFriction (FScanner &sc, int keyword, void *fields) if (movefactor < 32) movefactor = 32; - def->Friction = friction; - def->MoveFactor = movefactor; + def->Friction = friction / 65536.; + def->MoveFactor = movefactor / 65536.; } //========================================================================== diff --git a/src/p_terrain.h b/src/p_terrain.h index b9217b45e..e8e6544d0 100644 --- a/src/p_terrain.h +++ b/src/p_terrain.h @@ -115,8 +115,8 @@ struct FTerrainDef FSoundID RightStepSound; bool IsLiquid; bool AllowProtection; - fixed_t Friction; - fixed_t MoveFactor; + double Friction; + double MoveFactor; }; extern TArray Splashes; diff --git a/src/p_things.cpp b/src/p_things.cpp index 1866c079e..1fa0905b1 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -670,7 +670,7 @@ void InitSpawnablesFromMapinfo() } -int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, fixed_t zofs, angle_t angle, int flags, fixed_t heightoffset, fixed_t radiusoffset, angle_t pitch) +int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, double zofs, DAngle angle, int flags, double heightoffset, double radiusoffset, DAngle pitch) { if (flags & WARPF_MOVEPTR) { @@ -679,32 +679,33 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, caller = temp; } - fixedvec3 old = caller->_f_Pos(); + DVector3 old = caller->Pos(); int oldpgroup = caller->Sector->PortalGroup; - zofs += FixedMul(reference->_f_height(), heightoffset); + zofs += reference->Height * heightoffset; if (!(flags & WARPF_ABSOLUTEANGLE)) { - angle += (flags & WARPF_USECALLERANGLE) ? caller->_f_angle() : reference->_f_angle(); + angle += (flags & WARPF_USECALLERANGLE) ? caller->Angles.Yaw: reference->Angles.Yaw; } - const fixed_t rad = FixedMul(radiusoffset, reference->_f_radius()); - const angle_t fineangle = angle >> ANGLETOFINESHIFT; + const double rad = radiusoffset * reference->radius; + const double s = angle.Sin(); + const double c = angle.Cos(); if (!(flags & WARPF_ABSOLUTEPOSITION)) { if (!(flags & WARPF_ABSOLUTEOFFSET)) { - fixed_t xofs1 = xofs; + double xofs1 = xofs; // (borrowed from A_SpawnItemEx, assumed workable) // in relative mode negative y values mean 'left' and positive ones mean 'right' // This is the inverse orientation of the absolute mode! - xofs = FixedMul(xofs1, finecosine[fineangle]) + FixedMul(yofs, finesine[fineangle]); - yofs = FixedMul(xofs1, finesine[fineangle]) - FixedMul(yofs, finecosine[fineangle]); + xofs = xofs1 * c + yofs * s; + yofs = xofs1 * s - yofs * c; } if (flags & WARPF_TOFLOOR) @@ -713,30 +714,21 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, // now the caller's floorz should be appropriate for the assigned xy-position // assigning position again with. // extra unlink, link and environment calculation - caller->SetOrigin(reference->Vec3Offset( - xofs + FixedMul(rad, finecosine[fineangle]), - yofs + FixedMul(rad, finesine[fineangle]), - 0), true); - caller->_f_SetZ(caller->_f_floorz() + zofs); + caller->SetOrigin(reference->Vec3Offset(xofs + rad * c, yofs + rad * s, 0.), true); + // The two-step process is important. + caller->SetZ(caller->floorz + zofs); } else { - caller->SetOrigin(reference->Vec3Offset( - xofs + FixedMul(rad, finecosine[fineangle]), - yofs + FixedMul(rad, finesine[fineangle]), - zofs), true); + caller->SetOrigin(reference->Vec3Offset(xofs + rad * c, yofs + rad * s, zofs), true); } } else // [MC] The idea behind "absolute" is meant to be "absolute". Override everything, just like A_SpawnItemEx's. { + caller->SetOrigin(xofs + rad * c, yofs + rad * s, zofs, true); if (flags & WARPF_TOFLOOR) { - caller->SetOrigin(xofs + FixedMul(rad, finecosine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]), zofs, true); - caller->_f_SetZ(caller->_f_floorz() + zofs); - } - else - { - caller->SetOrigin(xofs + FixedMul(rad, finecosine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]), zofs, true); + caller->SetZ(caller->floorz + zofs); } } @@ -748,13 +740,13 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, } else { - caller->Angles.Yaw = ANGLE2DBL(angle); + caller->Angles.Yaw = angle; if (flags & WARPF_COPYPITCH) caller->SetPitch(reference->Angles.Pitch, false); - if (pitch) - caller->SetPitch(caller->Angles.Pitch + ANGLE2DBL(pitch), false); + if (pitch != 0) + caller->SetPitch(caller->Angles.Pitch + pitch, false); if (flags & WARPF_COPYVELOCITY) { @@ -765,6 +757,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, caller->Vel.Zero(); } +#if 0 // needs fixing // this is no fun with line portals if (flags & WARPF_WARPINTERPOLATION) { @@ -789,9 +782,11 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, { caller->ClearInterpolation(); } +#endif + if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB)) { - caller->_f_AddZ(reference->_f_GetBobOffset()); + caller->AddZ(reference->GetBobOffset()); } } return true; diff --git a/src/p_user.cpp b/src/p_user.cpp index 1eee21935..8783bac99 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -648,9 +648,9 @@ void APlayerPawn::Serialize (FArchive &arc) << FlechetteType; if (SaveVersion < 3829) { - GruntSpeed = 12*FRACUNIT; - FallingScreamMinSpeed = 35*FRACUNIT; - FallingScreamMaxSpeed = 40*FRACUNIT; + GruntSpeed = 12; + FallingScreamMinSpeed = 35; + FallingScreamMaxSpeed = 40; } else { @@ -1265,7 +1265,7 @@ bool APlayerPawn::ResetAirSupply (bool playgasp) { S_Sound (this, CHAN_VOICE, "*gasp", 1, ATTN_NORM); } - if (level.airsupply> 0 && player->mo->AirCapacity > 0) player->air_finished = level.time + FixedMul(level.airsupply, player->mo->AirCapacity); + if (level.airsupply> 0 && player->mo->AirCapacity > 0) player->air_finished = level.time + int(level.airsupply * player->mo->AirCapacity); else player->air_finished = INT_MAX; return wasdrowning; } @@ -1967,7 +1967,7 @@ void P_MovePlayer (player_t *player) double fm, sm; movefactor = P_GetMoveFactor (mo, &friction); - bobfactor = friction < ORIG_FRICTION ? movefactor : fORIG_FRICTION_FACTOR; + bobfactor = friction < ORIG_FRICTION ? movefactor : ORIG_FRICTION_FACTOR; if (!player->onground && !(player->mo->flags & MF_NOGRAVITY) && !player->mo->waterlevel) { // [RH] allow very limited movement if not on ground. @@ -2618,8 +2618,8 @@ void P_PlayerThink (player_t *player) // Player must be touching the floor P_PlayerOnSpecialFlat(player, P_GetThingFloorType(player->mo)); } - if (player->mo->_f_velz() <= -player->mo->FallingScreamMinSpeed && - player->mo->_f_velz() >= -player->mo->FallingScreamMaxSpeed && !player->morphTics && + if (player->mo->Vel.Z <= -player->mo->FallingScreamMinSpeed && + player->mo->Vel.Z >= -player->mo->FallingScreamMaxSpeed && !player->morphTics && player->mo->waterlevel == 0) { int id = S_FindSkinnedSound (player->mo, "*falling"); diff --git a/src/portal.cpp b/src/portal.cpp index af0f96b33..91a24e2e3 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -156,6 +156,8 @@ static void BuildBlockmap() void FLinePortalTraverse::AddLineIntercepts(int bx, int by) { + if (by < 0 || by >= bmapheight || bx < 0 || bx >= bmapwidth) return; + FPortalBlock &block = PortalBlockmap(bx, by); for (unsigned i = 0; isector; } -inline fixedvec3 AActor::PosRelative(int portalgroup) const +inline fixedvec3 AActor::_f_PosRelative(int portalgroup) const { return __pos + Displacements.getOffset(Sector->PortalGroup, portalgroup); } -inline fixedvec3 AActor::PosRelative(const AActor *other) const +inline fixedvec3 AActor::_f_PosRelative(const AActor *other) const { return __pos + Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup); } -inline fixedvec3 AActor::PosRelative(sector_t *sec) const +inline fixedvec3 AActor::_f_PosRelative(sector_t *sec) const { return __pos + Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup); } -inline fixedvec3 AActor::PosRelative(line_t *line) const +inline fixedvec3 AActor::_f_PosRelative(line_t *line) const { return __pos + Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup); } -inline fixedvec3 PosRelative(const fixedvec3 &pos, line_t *line, sector_t *refsec = NULL) +inline fixedvec3 _f_PosRelative(const fixedvec3 &pos, line_t *line, sector_t *refsec = NULL) { return pos + Displacements.getOffset(refsec->PortalGroup, line->frontsector->PortalGroup); } diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 7e7e4cd4f..c62647355 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1243,7 +1243,7 @@ void R_DrawSkyBoxes () viewx = viewpos.x; viewy = viewpos.y; viewz = viewpos.z; - viewangle = savedangle + FLOAT2ANGLE(sky->PrevAngles.Yaw.Degrees) + FixedMul(r_TicFrac, sky->_f_angle() - FLOAT2ANGLE(sky->PrevAngles.Yaw.Degrees)); + viewangle = savedangle + (sky->PrevAngles.Yaw + (sky->Angles.Yaw * r_TicFracF) - sky->PrevAngles.Yaw).BAMs(); R_CopyStackedViewParameters(); } diff --git a/src/sc_man_scanner.re b/src/sc_man_scanner.re index 7e82f19c1..3b05c5b72 100644 --- a/src/sc_man_scanner.re +++ b/src/sc_man_scanner.re @@ -193,7 +193,6 @@ std2: /* other DECORATE top level keywords */ '#include' { RET(TK_Include); } 'fixed_t' { RET(TK_Fixed_t); } - 'angle_t' { RET(TK_Angle_t); } L (L|D)* { RET(TK_Identifier); } diff --git a/src/sc_man_tokens.h b/src/sc_man_tokens.h index 7fda91330..ac69c153e 100644 --- a/src/sc_man_tokens.h +++ b/src/sc_man_tokens.h @@ -112,7 +112,6 @@ xx(TK_Self, "'self'") xx(TK_Stop, "'stop'") xx(TK_Include, "'include'") xx(TK_Fixed_t, "'fixed_t'") -xx(TK_Angle_t, "'angle_t'") xx(TK_Is, "'is'") xx(TK_Replaces, "'replaces'") diff --git a/src/textures/textures.h b/src/textures/textures.h index f730d7693..85a8c2f16 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -228,7 +228,7 @@ public: int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); } int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); } - int GetScaledHeight(double scale) { return GetScaledHeight(FLOAT2FIXED(scale)); } + int GetScaledHeight(double scale) { int foo = (Height << 17) / FLOAT2FIXED(scale); return (foo >> 1) + (foo & 1); } double GetScaledWidthDouble () { return (Width * 65536.) / xScale; } double GetScaledHeightDouble () { return (Height * 65536.) / yScale; } double GetScaleY() const { return FIXED2DBL(yScale); } diff --git a/src/thingdef/thingdef.h b/src/thingdef/thingdef.h index d990b05f0..d522ad573 100644 --- a/src/thingdef/thingdef.h +++ b/src/thingdef/thingdef.h @@ -326,9 +326,6 @@ int MatchString (const char *in, const char **strings); #define PROP_DOUBLE_PARM(var, no) \ double var = params[(no)+1].d; -#define PROP_FIXED_PARM(var, no) \ - fixed_t var = FLOAT2FIXED(params[(no)+1].d); - #define PROP_COLOR_PARM(var, no) \ int var = params[(no)+1].i== 0? params[(no)+2].i : V_GetColor(NULL, params[(no)+2].s); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 5ce83f757..6591525af 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -313,12 +313,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetDistance) } else { - fixedvec3 diff = self->_f_Vec3To(target); + DVector3 diff = self->Vec3To(target); if (checkz) - diff.z += (target->_f_height() - self->_f_height()) / 2; + diff.Z += (target->Height - self->Height) / 2; - const double length = DVector3(FIXED2DBL(diff.x), FIXED2DBL(diff.y), (checkz) ? FIXED2DBL(diff.z) : 0).Length(); - ret->SetFloat(length); + ret->SetFloat(diff.Length()); } return 1; } @@ -664,7 +663,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BasicAttack) PARAM_INT (melee_damage); PARAM_SOUND (melee_sound); PARAM_CLASS (missile_type, AActor); - PARAM_FIXED (missile_height); + PARAM_FLOAT (missile_height); if (missile_type != NULL) { @@ -928,7 +927,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInsideMeleeRange) static int DoJumpIfCloser(AActor *target, VM_ARGS) { PARAM_ACTION_PROLOGUE; - PARAM_FIXED (dist); + PARAM_FLOAT (dist); PARAM_STATE (jump); PARAM_BOOL_OPT(noz) { noz = false; } @@ -936,7 +935,7 @@ static int DoJumpIfCloser(AActor *target, VM_ARGS) { // No target - no jump ACTION_RETURN_STATE(NULL); } - if (self->AproxDistance(target) < dist && + if (self->Distance2D(target) < dist && (noz || ((self->Z() > target->Z() && self->Z() - target->Top() < dist) || (self->Z() <= target->Z() && target->Z() - self->Top() < dist)))) @@ -1199,9 +1198,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) PARAM_CLASS (ti, AActor); PARAM_FLOAT_OPT (Spawnheight) { Spawnheight = 32; } PARAM_FLOAT_OPT (Spawnofs_xy) { Spawnofs_xy = 0; } - PARAM_DANGLE_OPT(Angle) { Angle = 0.; } + PARAM_ANGLE_OPT (Angle) { Angle = 0.; } PARAM_INT_OPT (flags) { flags = 0; } - PARAM_DANGLE_OPT(Pitch) { Pitch = 0.; } + PARAM_ANGLE_OPT (Pitch) { Pitch = 0.; } PARAM_INT_OPT (ptr) { ptr = AAPTR_TARGET; } AActor *ref = COPY_AAPTR(self, ptr); @@ -1340,8 +1339,8 @@ enum CBA_Flags DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) { PARAM_ACTION_PROLOGUE; - PARAM_DANGLE (spread_xy); - PARAM_DANGLE (spread_z); + PARAM_ANGLE (spread_xy); + PARAM_ANGLE (spread_z); PARAM_INT (numbullets); PARAM_INT (damageperbullet); PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindActor(NAME_BulletPuff); } @@ -1525,8 +1524,8 @@ enum FB_Flags DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) { PARAM_ACTION_PROLOGUE; - PARAM_DANGLE (spread_xy); - PARAM_DANGLE (spread_z); + PARAM_ANGLE (spread_xy); + PARAM_ANGLE (spread_z); PARAM_INT (numbullets); PARAM_INT (damageperbullet); PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; } @@ -1549,16 +1548,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) return 0; // out of ammo } - if (range == 0) - range = PLAYERMISSILERANGE; + if (range == 0) range = PLAYERMISSILERANGE; if (!(flags & FBF_NOFLASH)) static_cast(self)->PlayAttacking2 (); if (!(flags & FBF_NOPITCH)) bslope = P_BulletSlope(self); bangle = self->Angles.Yaw; - if (pufftype == NULL) - pufftype = PClass::FindActor(NAME_BulletPuff); + if (pufftype == NULL) pufftype = PClass::FindActor(NAME_BulletPuff); if (weapon != NULL) { @@ -1621,12 +1618,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) { PARAM_ACTION_PROLOGUE; PARAM_CLASS (ti, AActor); - PARAM_DANGLE_OPT(angle) { angle = 0.; } + PARAM_ANGLE_OPT (angle) { angle = 0.; } PARAM_BOOL_OPT (useammo) { useammo = true; } PARAM_FLOAT_OPT (spawnofs_xy) { spawnofs_xy = 0; } PARAM_FLOAT_OPT (spawnheight) { spawnheight = 0; } PARAM_INT_OPT (flags) { flags = 0; } - PARAM_DANGLE_OPT(pitch) { pitch = 0.; } + PARAM_ANGLE_OPT (pitch) { pitch = 0.; } if (!self->player) return 0; @@ -1702,7 +1699,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) PARAM_INT_OPT (flags) { flags = CPF_USEAMMO; } PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; } PARAM_FLOAT_OPT (range) { range = 0; } - PARAM_FIXED_OPT (lifesteal) { lifesteal = 0; } + PARAM_FLOAT_OPT (lifesteal) { lifesteal = 0; } PARAM_INT_OPT (lifestealmax) { lifestealmax = 0; } PARAM_CLASS_OPT (armorbonustype, ABasicArmorBonus) { armorbonustype = NULL; } PARAM_SOUND_OPT (MeleeSound) { MeleeSound = ""; } @@ -1746,7 +1743,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) } else { - if (lifesteal && !(t.linetarget->flags5 & MF5_DONTDRAIN)) + if (lifesteal > 0 && !(t.linetarget->flags5 & MF5_DONTDRAIN)) { if (flags & CPF_STEALARMOR) { @@ -1758,7 +1755,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) { assert(armorbonustype->IsDescendantOf(RUNTIME_CLASS(ABasicArmorBonus))); ABasicArmorBonus *armorbonus = static_cast(Spawn(armorbonustype)); - armorbonus->SaveAmount *= (actualdamage * lifesteal) >> FRACBITS; + armorbonus->SaveAmount *= int(actualdamage * lifesteal); armorbonus->MaxSaveAmount = lifestealmax <= 0 ? armorbonus->MaxSaveAmount : lifestealmax; armorbonus->flags |= MF_DROPPED; armorbonus->ClearCounters(); @@ -1771,7 +1768,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) } else { - P_GiveBody (self, (actualdamage * lifesteal) >> FRACBITS, lifestealmax); + P_GiveBody (self, int(actualdamage * lifesteal), lifestealmax); } } if (weapon != NULL) @@ -1809,17 +1806,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack) PARAM_INT_OPT (flags) { flags = 0; } PARAM_FLOAT_OPT (maxdiff) { maxdiff = 0; } PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindActor(NAME_BulletPuff); } - PARAM_ANGLE_OPT (spread_xy) { spread_xy = 0; } - PARAM_ANGLE_OPT (spread_z) { spread_z = 0; } - PARAM_FIXED_OPT (range) { range = 0; } + PARAM_ANGLE_OPT (spread_xy) { spread_xy = 0.; } + PARAM_ANGLE_OPT (spread_z) { spread_z = 0.; } + PARAM_FLOAT_OPT (range) { range = 0; } PARAM_INT_OPT (duration) { duration = 0; } PARAM_FLOAT_OPT (sparsity) { sparsity = 1; } PARAM_FLOAT_OPT (driftspeed) { driftspeed = 1; } PARAM_CLASS_OPT (spawnclass, AActor){ spawnclass = NULL; } - PARAM_FIXED_OPT (spawnofs_z) { spawnofs_z = 0; } + PARAM_FLOAT_OPT (spawnofs_z) { spawnofs_z = 0; } PARAM_INT_OPT (SpiralOffset) { SpiralOffset = 270; } - if (range == 0) range = 8192*FRACUNIT; + if (range == 0) range = 8192; if (sparsity == 0) sparsity=1.0; if (self->player == NULL) @@ -1834,21 +1831,31 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack) return 0; // out of ammo } - angle_t angle; - angle_t slope; - - if (flags & RAF_EXPLICITANGLE) + if (!(flags & RAF_EXPLICITANGLE)) { - angle = spread_xy; - slope = spread_z; - } - else - { - angle = pr_crailgun.Random2() * (spread_xy / 255); - slope = pr_crailgun.Random2() * (spread_z / 255); + spread_xy = spread_xy * pr_crailgun.Random2() / 255; + spread_z = spread_z * pr_crailgun.Random2() / 255; } - P_RailAttack (self, damage, spawnofs_xy, spawnofs_z, color1, color2, maxdiff, flags, pufftype, angle, slope, range, duration, sparsity, driftspeed, spawnclass, SpiralOffset); + FRailParams p; + p.source = self; + p.damage = damage; + p.offset_xy = spawnofs_xy; + p.offset_z = spawnofs_z; + p.color1 = color1; + p.color2 = color2; + p.maxdiff = maxdiff; + p.flags = flags; + p.puff = pufftype; + p.angleoffset = spread_xy; + p.pitchoffset = spread_z; + p.distance = range; + p.duration = duration; + p.sparsity = sparsity; + p.drift = driftspeed; + p.spawnclass = spawnclass; + p.SpiralOffset = SpiralOffset; + P_RailAttack(&p); return 0; } @@ -1876,17 +1883,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) PARAM_INT_OPT (aim) { aim = CRF_DONTAIM; } PARAM_FLOAT_OPT (maxdiff) { maxdiff = 0; } PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindActor(NAME_BulletPuff); } - PARAM_ANGLE_OPT (spread_xy) { spread_xy = 0; } - PARAM_ANGLE_OPT (spread_z) { spread_z = 0; } - PARAM_FIXED_OPT (range) { range = 0; } + PARAM_ANGLE_OPT (spread_xy) { spread_xy = 0.; } + PARAM_ANGLE_OPT (spread_z) { spread_z = 0.; } + PARAM_FLOAT_OPT (range) { range = 0; } PARAM_INT_OPT (duration) { duration = 0; } PARAM_FLOAT_OPT (sparsity) { sparsity = 1; } PARAM_FLOAT_OPT (driftspeed) { driftspeed = 1; } PARAM_CLASS_OPT (spawnclass, AActor){ spawnclass = NULL; } - PARAM_FIXED_OPT (spawnofs_z) { spawnofs_z = 0; } + PARAM_FLOAT_OPT (spawnofs_z) { spawnofs_z = 0; } PARAM_INT_OPT (SpiralOffset) { SpiralOffset = 270; } - if (range == 0) range = 8192*FRACUNIT; + if (range == 0) range = 8192.; if (sparsity == 0) sparsity = 1; FTranslatedLineTarget t; @@ -1930,8 +1937,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) // Tricky: We must offset to the angle of the current position // but then change the angle again to ensure proper aim. self->SetXY(self->Vec2Offset( - FLOAT2FIXED(spawnofs_xy * self->Angles.Yaw.Cos()), - FLOAT2FIXED(spawnofs_xy * self->Angles.Yaw.Sin()))); + spawnofs_xy * self->Angles.Yaw.Cos(), + 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); } @@ -1943,23 +1950,31 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) } } - angle_t angle = (self->_f_angle() - ANG90) >> ANGLETOFINESHIFT; - - angle_t angleoffset; - angle_t slopeoffset; - - if (flags & CRF_EXPLICITANGLE) + if (!(flags & CRF_EXPLICITANGLE)) { - angleoffset = spread_xy; - slopeoffset = spread_z; - } - else - { - angleoffset = pr_crailgun.Random2() * (spread_xy / 255); - slopeoffset = pr_crailgun.Random2() * (spread_z / 255); + spread_xy = spread_xy * pr_crailgun.Random2() / 255; + spread_z = spread_z * pr_crailgun.Random2() / 255; } - P_RailAttack (self, damage, spawnofs_xy, spawnofs_z, color1, color2, maxdiff, flags, pufftype, angleoffset, slopeoffset, range, duration, sparsity, driftspeed, spawnclass,SpiralOffset); + FRailParams p; + p.source = self; + p.damage = damage; + p.offset_xy = spawnofs_xy; + p.offset_z = spawnofs_z; + p.color1 = color1; + p.color2 = color2; + p.maxdiff = maxdiff; + p.flags = flags; + p.puff = pufftype; + p.angleoffset = spread_xy; + p.pitchoffset = spread_z; + p.distance = range; + p.duration = duration; + p.sparsity = sparsity; + p.drift = driftspeed; + p.spawnclass = spawnclass; + p.SpiralOffset = SpiralOffset; + P_RailAttack(&p); self->SetXYZ(savedpos); self->Angles.Yaw = saved_angle; @@ -2239,7 +2254,7 @@ static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) } if (flags & SIXF_TELEFRAG) { - P_TeleportMove(mo, mo->_f_Pos(), true); + P_TeleportMove(mo, mo->Pos(), true); // This is needed to ensure consistent behavior. // Otherwise it will only spawn if nothing gets telefragged flags |= SIXF_NOCHECKPOSITION; @@ -2378,7 +2393,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) { PARAM_ACTION_PROLOGUE; PARAM_CLASS_OPT (missile, AActor) { missile = PClass::FindActor("Unknown"); } - PARAM_FIXED_OPT (distance) { distance = 0; } + PARAM_FLOAT_OPT (distance) { distance = 0; } PARAM_FLOAT_OPT (zheight) { zheight = 0; } PARAM_BOOL_OPT (useammo) { useammo = true; } PARAM_BOOL_OPT (transfer_translation) { transfer_translation = false; } @@ -2397,7 +2412,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) if (distance == 0) { // use the minimum distance that does not result in an overlap - distance = (self->_f_radius() + GetDefaultByType(missile)->_f_radius()) >> FRACBITS; + distance = (self->radius + GetDefaultByType(missile)->radius); } if (ACTION_CALL_FROM_WEAPON()) @@ -2438,7 +2453,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) 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_ANGLE_OPT (angle) { angle = 0.; } PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (chance) { chance = 0; } PARAM_INT_OPT (tid) { tid = 0; } @@ -2516,9 +2531,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) { PARAM_ACTION_PROLOGUE; PARAM_CLASS (missile, AActor); - PARAM_FIXED_OPT (zheight) { zheight = 0; } + PARAM_FLOAT_OPT (zheight) { zheight = 0; } PARAM_FLOAT_OPT (xyvel) { xyvel = 0; } - PARAM_FIXED_OPT (zvel) { zvel = 0; } + PARAM_FLOAT_OPT (zvel) { zvel = 0; } PARAM_BOOL_OPT (useammo) { useammo = true; } if (missile == NULL) @@ -2980,51 +2995,51 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle) PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (lifetime) { lifetime = 35; } PARAM_INT_OPT (size) { size = 1; } - PARAM_ANGLE_OPT (angle) { angle = 0; } - PARAM_FIXED_OPT (xoff) { xoff = 0; } - PARAM_FIXED_OPT (yoff) { yoff = 0; } - PARAM_FIXED_OPT (zoff) { zoff = 0; } - PARAM_FIXED_OPT (xvel) { xvel = 0; } - PARAM_FIXED_OPT (yvel) { yvel = 0; } - PARAM_FIXED_OPT (zvel) { zvel = 0; } - PARAM_FIXED_OPT (accelx) { accelx = 0; } - PARAM_FIXED_OPT (accely) { accely = 0; } - PARAM_FIXED_OPT (accelz) { accelz = 0; } - PARAM_FIXED_OPT (startalphaf) { startalphaf = FRACUNIT; } - PARAM_FIXED_OPT (fadestepf) { fadestepf = -FRACUNIT; } + PARAM_ANGLE_OPT (angle) { angle = 0.; } + PARAM_FLOAT_OPT (xoff) { xoff = 0; } + PARAM_FLOAT_OPT (yoff) { yoff = 0; } + PARAM_FLOAT_OPT (zoff) { zoff = 0; } + PARAM_FLOAT_OPT (xvel) { xvel = 0; } + PARAM_FLOAT_OPT (yvel) { yvel = 0; } + PARAM_FLOAT_OPT (zvel) { zvel = 0; } + PARAM_FLOAT_OPT (accelx) { accelx = 0; } + PARAM_FLOAT_OPT (accely) { accely = 0; } + PARAM_FLOAT_OPT (accelz) { accelz = 0; } + PARAM_FLOAT_OPT (startalpha) { startalpha = 1.; } + PARAM_FLOAT_OPT (fadestep) { fadestep = -1.; } - BYTE startalpha = (BYTE)(clamp(startalphaf, 0, FRACUNIT) * 255 / FRACUNIT); - int fadestep = fadestepf < 0 ? -1 : clamp(fadestepf, 0, FRACUNIT) * 255 / FRACUNIT; - lifetime = clamp(lifetime, 0, 255); // Clamp to byte + startalpha = clamp(startalpha, 0., 1.); + if (fadestep > 0) fadestep = clamp(fadestep, 0., 1.); size = clamp(size, 0, 65535); // Clamp to word if (lifetime != 0) { - const angle_t ang = (angle + ((flags & SPF_RELANG) ? self->_f_angle() : 0)) >> ANGLETOFINESHIFT; - fixedvec3 pos; + if (flags & SPF_RELANG) angle += self->Angles.Yaw; + double s = angle.Sin(); + double c = angle.Cos(); + DVector3 pos(xoff, yoff, zoff); + DVector3 vel(xvel, yvel, zvel); + DVector3 acc(accelx, accely, accelz); //[MC] Code ripped right out of A_SpawnItemEx. if (flags & SPF_RELPOS) { // in relative mode negative y values mean 'left' and positive ones mean 'right' // This is the inverse orientation of the absolute mode! - const fixed_t xof1 = xoff; - xoff = FixedMul(xof1, finecosine[ang]) + FixedMul(yoff, finesine[ang]); - yoff = FixedMul(xof1, finesine[ang]) - FixedMul(yoff, finecosine[ang]); + pos.X = xoff * c + yoff * s; + pos.Y = xoff * s - yoff * c; } if (flags & SPF_RELVEL) { - const fixed_t newxvel = FixedMul(xvel, finecosine[ang]) + FixedMul(yvel, finesine[ang]); - yvel = FixedMul(xvel, finesine[ang]) - FixedMul(yvel, finecosine[ang]); - xvel = newxvel; + vel.X = xvel * c + yvel * s; + vel.Y = xvel * s - yvel * c; } if (flags & SPF_RELACCEL) { - fixed_t newaccelx = FixedMul(accelx, finecosine[ang]) + FixedMul(accely, finesine[ang]); - accely = FixedMul(accelx, finesine[ang]) - FixedMul(accely, finecosine[ang]); - accelx = newaccelx; + acc.X = accelx * c + accely * s; + acc.Y = accelx * s - accely * c; } pos = self->Vec3Offset(xoff, yoff, zoff); - P_SpawnParticle(pos.x, pos.y, pos.z, xvel, yvel, zvel, color, !!(flags & SPF_FULLBRIGHT), startalpha, lifetime, size, fadestep, accelx, accely, accelz); + P_SpawnParticle(self->Vec3Offset(pos), vel, acc, color, !!(flags & SPF_FULLBRIGHT), startalpha, lifetime, size, fadestep); } return 0; } @@ -3067,36 +3082,37 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSight) // Useful for maps with many multi-actor special effects. // //=========================================================================== -static bool DoCheckSightOrRange(AActor *self, AActor *camera, double range, bool twodi) +static bool DoCheckSightOrRange(AActor *self, AActor *camera, double range, bool twodi, bool checksight) { if (camera == NULL) { return false; } // Check distance first, since it's cheaper than checking sight. - fixedvec2 pos = camera->_f_Vec2To(self); - fixed_t dz; - fixed_t eyez = (camera->_f_Top() - (camera->_f_height()>>2)); // same eye height as P_CheckSight - if (eyez > self->_f_Top()) + DVector2 pos = camera->Vec2To(self); + double dz; + double eyez = camera->Center(); + if (eyez > self->Top()) { - dz = self->_f_Top() - eyez; + dz = self->Top() - eyez; } - else if (eyez < self->_f_Z()) + else if (eyez < self->Z()) { - dz = self->_f_Z() - eyez; + dz = self->Z() - eyez; } else { dz = 0; } - double distance = ((double)pos.x * pos.x) + ((double)pos.y * pos.y) + (twodi == 0? ((double)dz * dz) : 0); - if (distance <= range){ + double distance = DVector3(pos, twodi? 0. : dz).LengthSquared(); + if (distance <= range*range) + { // Within range return true; } // Now check LOS. - if (P_CheckSight(camera, self, SF_IGNOREVISIBILITY)) + if (checksight && P_CheckSight(camera, self, SF_IGNOREVISIBILITY)) { // Visible return true; } @@ -3110,19 +3126,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSightOrRange) PARAM_STATE(jump); PARAM_BOOL_OPT(twodi) { twodi = false; } - range = range * range * (double(FRACUNIT) * FRACUNIT); // no need for square roots + range *= range; for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) { // Always check from each player. - if (DoCheckSightOrRange(self, players[i].mo, range, twodi)) + if (DoCheckSightOrRange(self, players[i].mo, range, twodi, true)) { ACTION_RETURN_STATE(NULL); } // If a player is viewing from a non-player, check that too. if (players[i].camera != NULL && players[i].camera->player == NULL && - DoCheckSightOrRange(self, players[i].camera, range, twodi)) + DoCheckSightOrRange(self, players[i].camera, range, twodi, true)) { ACTION_RETURN_STATE(NULL); } @@ -3131,42 +3147,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSightOrRange) ACTION_RETURN_STATE(jump); } -//=========================================================================== -// -// A_CheckRange -// Jumps if this actor is out of range of all players. -// -//=========================================================================== -static bool DoCheckRange(AActor *self, AActor *camera, double range, bool twodi) -{ - if (camera == NULL) - { - return false; - } - // Check distance first, since it's cheaper than checking sight. - fixedvec2 pos = camera->_f_Vec2To(self); - fixed_t dz; - fixed_t eyez = (camera->_f_Top() - (camera->_f_height()>>2)); // same eye height as P_CheckSight - if (eyez > self->_f_Top()) - { - dz = self->_f_Top() - eyez; - } - else if (eyez < self->_f_Z()) - { - dz = self->_f_Z() - eyez; - } - else - { - dz = 0; - } - double distance = ((double)pos.x * pos.x) + ((double)pos.y * pos.y) + (twodi == 0? ((double)dz * dz) : 0); - - if (distance <= range){ - // Within range - return true; - } - return false; -} DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckRange) { @@ -3175,19 +3155,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckRange) PARAM_STATE(jump); PARAM_BOOL_OPT(twodi) { twodi = false; } - range = range * range * (double(FRACUNIT) * FRACUNIT); // no need for square roots + range *= range; for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) { // Always check from each player. - if (DoCheckRange(self, players[i].mo, range, twodi)) + if (DoCheckSightOrRange(self, players[i].mo, range, twodi, false)) { ACTION_RETURN_STATE(NULL); } // If a player is viewing from a non-player, check that too. if (players[i].camera != NULL && players[i].camera->player == NULL && - DoCheckRange(self, players[i].camera, range, twodi)) + DoCheckSightOrRange(self, players[i].camera, range, twodi, false)) { ACTION_RETURN_STATE(NULL); } @@ -3691,56 +3671,57 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) */ AActor *target; - fixedvec3 pos; - fixed_t vx, vy, vz; + DVector3 pos; + DVector3 vel; PARAM_ACTION_PROLOGUE; PARAM_STATE (jump); PARAM_INT_OPT (flags) { flags = 0; } PARAM_FLOAT_OPT (range) { range = 0; } PARAM_FLOAT_OPT (minrange) { minrange = 0; } + PARAM_ANGLE_OPT (angle) { angle = 0.; } + PARAM_ANGLE_OPT (pitch) { pitch = 0.; } + PARAM_FLOAT_OPT (offsetheight) { offsetheight = 0; } + PARAM_FLOAT_OPT (offsetwidth) { offsetwidth = 0; } + PARAM_INT_OPT (ptr_target) { ptr_target = AAPTR_DEFAULT; } + PARAM_FLOAT_OPT (offsetforward) { offsetforward = 0; } + + DAngle ang; + + target = COPY_AAPTR(self, ptr_target == AAPTR_DEFAULT ? AAPTR_TARGET|AAPTR_PLAYER_GETTARGET|AAPTR_NULL : ptr_target); // no player-support by default + + if (flags & CLOFF_MUL_HEIGHT) { - PARAM_DANGLE_OPT(angle) { angle = 0.; } - PARAM_DANGLE_OPT(pitch) { pitch = 0.; } - PARAM_FIXED_OPT (offsetheight) { offsetheight = 0; } - PARAM_FIXED_OPT (offsetwidth) { offsetwidth = 0; } - PARAM_INT_OPT (ptr_target) { ptr_target = AAPTR_DEFAULT; } - PARAM_FIXED_OPT (offsetforward) { offsetforward = 0; } - - target = COPY_AAPTR(self, ptr_target == AAPTR_DEFAULT ? AAPTR_TARGET|AAPTR_PLAYER_GETTARGET|AAPTR_NULL : ptr_target); // no player-support by default - - if (flags & CLOFF_MUL_HEIGHT) + if (self->player != NULL) { - if (self->player != NULL) - { - // Synced with hitscan: self->player->mo->_f_height() is strangely conscientious about getting the right actor for player - offsetheight = FixedMul(offsetheight, fixed_t(self->player->mo->_f_height() * self->player->crouchfactor)); - } - else - { - offsetheight = FixedMul(offsetheight, self->_f_height()); - } + // Synced with hitscan: self->player->mo->height is strangely conscientious about getting the right actor for player + offsetheight *= self->player->mo->Height * self->player->crouchfactor; } - if (flags & CLOFF_MUL_WIDTH) + else { - offsetforward = FixedMul(self->_f_radius(), offsetforward); - offsetwidth = FixedMul(self->_f_radius(), offsetwidth); + offsetheight *= self->Height; } + } + if (flags & CLOFF_MUL_WIDTH) + { + offsetforward *= self->radius; + offsetwidth *= self->radius; + } - pos = self->PosPlusZ(offsetheight - self->_f_floorclip()); + pos = self->PosPlusZ(offsetheight - self->Floorclip); if (!(flags & CLOFF_FROMBASE)) { // default to hitscan origin // Synced with hitscan: self->_f_height() is strangely NON-conscientious about getting the right actor for player - pos.z += (self->_f_height() >> 1); + pos.Z += self->Height *0.5; if (self->player != NULL) { - pos.z += fixed_t (self->player->mo->AttackZOffset * self->player->crouchfactor); + pos.Z += self->player->mo->AttackZOffset * self->player->crouchfactor; } else { - pos.z += 8*FRACUNIT; + pos.Z += 8; } } @@ -3755,25 +3736,21 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) } } + if (flags & CLOFF_NOAIM_HORZ) { - DAngle ang; - - if (flags & CLOFF_NOAIM_HORZ) - { - ang = self->Angles.Yaw; - } - else ang = self->AngleTo (target); - - angle += ang; - - double s = ang.Sin(); - double c = ang.Cos(); - - fixedvec2 xy = self->Vec2Offset(fixed_t(offsetforward * c + offsetwidth * s), fixed_t(offsetforward * s - offsetwidth * c)); - - pos.x = xy.x; - pos.y = xy.y; + ang = self->Angles.Yaw; } + else ang = self->AngleTo (target); + + angle += ang; + + double s = ang.Sin(); + double c = ang.Cos(); + + DVector2 xy = self->Vec2Offset(offsetforward * c + offsetwidth * s, offsetforward * s - offsetwidth * c); + + pos.X = xy.X; + pos.Y = xy.Y; double xydist = self->Distance2D(target); if (flags & CLOFF_NOAIM_VERT) @@ -3782,11 +3759,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) } else if (flags & CLOFF_AIM_VERT_NOOFFSET) { - pitch -= VecToAngle(xydist, FIXED2FLOAT(target->_f_Z() - pos.z + offsetheight + target->_f_height() / 2)); + pitch -= VecToAngle(xydist, target->Center() - pos.Z + offsetheight); } else { - pitch -= VecToAngle(xydist, FIXED2FLOAT(target->_f_Z() - pos.z + target->_f_height() / 2)); + pitch -= VecToAngle(xydist, target->Center()); } } else if (flags & CLOFF_ALLOWNULL) @@ -3797,10 +3774,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) double s = angle.Sin(); double c = angle.Cos(); - fixedvec2 xy = self->Vec2Offset(fixed_t(offsetforward * c + offsetwidth * s), fixed_t(offsetforward * s - offsetwidth * c)); + DVector2 xy = self->Vec2Offset(offsetforward * c + offsetwidth * s, offsetforward * s - offsetwidth * c); - pos.x = xy.x; - pos.y = xy.y; + pos.X = xy.X; + pos.Y = xy.Y; } else { @@ -3809,20 +3786,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) double cp = pitch.Cos(); - vx = FLOAT2FIXED(cp * angle.Cos()); - vy = FLOAT2FIXED(cp * angle.Sin()); - vz = FLOAT2FIXED(-pitch.Sin()); - } + vel = { cp * angle.Cos(), cp * angle.Sin(), -pitch.Sin() }; /* Variable set: jump, flags, target - x1,y1,z1 (trace point of origin) - vx,vy,vz (trace unit vector) + pos (trace point of origin) + vel (trace unit vector) range */ - sector_t *sec = P_PointInSector(pos.x, pos.y); + sector_t *sec = P_PointInSector(pos); if (range == 0) { @@ -3837,7 +3811,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) lof_data.Flags = flags; lof_data.BadActor = false; - Trace(pos.x, pos.y, pos.z, sec, vx, vy, vz, FLOAT2FIXED(range), ActorFlags::FromInt(0xFFFFFFFF), ML_BLOCKEVERYTHING, self, trace, TRACE_PortalRestrict, + Trace(pos, sec, vel, range, ActorFlags::FromInt(0xFFFFFFFF), ML_BLOCKEVERYTHING, self, trace, TRACE_PortalRestrict, CheckLOFTraceFunc, &lof_data); if (trace.HitType == TRACE_HitActor || @@ -3894,12 +3868,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) { PARAM_ACTION_PROLOGUE; PARAM_STATE (jump); - PARAM_ANGLE_OPT (fov) { fov = 0; } + PARAM_ANGLE_OPT (fov) { fov = 0.; } PARAM_INT_OPT (flags) { flags = 0; } - PARAM_FIXED_OPT (dist_max) { dist_max = 0; } - PARAM_FIXED_OPT (dist_close) { dist_close = 0; } + PARAM_FLOAT_OPT (dist_max) { dist_max = 0; } + PARAM_FLOAT_OPT (dist_close) { dist_close = 0; } - angle_t an; AActor *target, *viewport; FTranslatedLineTarget t; @@ -3949,14 +3922,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) { case JLOSF_TARGETLOS|JLOSF_FLIPFOV: // target makes sight check, player makes fov check; player has verified fov - fov = 0; + fov = 0.; // fall-through case JLOSF_TARGETLOS: doCheckSight = !(flags & JLOSF_NOSIGHT); // The target is responsible for sight check and fov break; default: // player has verified sight and fov - fov = 0; + fov = 0.; // fall-through case JLOSF_FLIPFOV: // Player has verified sight, but target must verify fov doCheckSight = false; @@ -3974,7 +3947,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) { ACTION_RETURN_STATE(NULL); } - fixed_t distance = self->AproxDistance3D(target); + double distance = self->Distance3D(target); if (dist_max && (distance > dist_max)) { @@ -3987,7 +3960,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) ACTION_RETURN_STATE(NULL); } if (flags & JLOSF_CLOSENOFOV) - fov = 0; + fov = 0.; if (flags & JLOSF_CLOSENOSIGHT) doCheckSight = false; @@ -4007,11 +3980,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) else { target = viewport; viewport = self; } } - if (fov && (fov < ANGLE_MAX)) + if (fov > 0 && (fov < 360.)) { - an = viewport->__f_AngleTo(target) - viewport->_f_angle(); + DAngle an = absangle(viewport->AngleTo(target), viewport->Angles.Yaw); - if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) + if (an > (fov / 2)) { ACTION_RETURN_STATE(NULL); // [KS] Outside of FOV - return } @@ -4031,12 +4004,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS) { PARAM_ACTION_PROLOGUE; PARAM_STATE (jump); - PARAM_ANGLE_OPT (fov) { fov = 0; } + PARAM_ANGLE_OPT (fov) { fov = 0.; } PARAM_INT_OPT (flags) { flags = 0; } - PARAM_FIXED_OPT (dist_max) { dist_max = 0; } - PARAM_FIXED_OPT (dist_close) { dist_close = 0; } + PARAM_FLOAT_OPT (dist_max) { dist_max = 0; } + PARAM_FLOAT_OPT (dist_close) { dist_close = 0; } - angle_t an; AActor *target; if (flags & JLOSF_CHECKMASTER) @@ -4065,7 +4037,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS) ACTION_RETURN_STATE(NULL); } - fixed_t distance = self->AproxDistance3D(target); + double distance = self->Distance3D(target); if (dist_max && (distance > dist_max)) { @@ -4081,17 +4053,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS) ACTION_RETURN_STATE(NULL); } if (flags & JLOSF_CLOSENOFOV) - fov = 0; + fov = 0.; if (flags & JLOSF_CLOSENOSIGHT) doCheckSight = false; } - if (fov && (fov < ANGLE_MAX)) + if (fov > 0 && (fov < 360.)) { - an = target->__f_AngleTo(self) - target->_f_angle(); + DAngle an = absangle(target->AngleTo(self), target->Angles.Yaw); - if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) + if (an > (fov / 2)) { ACTION_RETURN_STATE(NULL); // [KS] Outside of FOV - return } @@ -4372,8 +4344,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_FaceConsolePlayer) { - PARAM_ACTION_PROLOGUE; - PARAM_ANGLE_OPT(max_turn_angle) { max_turn_angle = 0; } // NOTE: It does nothing for zdoom. return 0; } @@ -5041,12 +5011,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) PARAM_ACTION_PROLOGUE; PARAM_INT_OPT (flags) { flags = 0; } PARAM_SOUND_OPT (sound) { sound = "weapons/pistol"; } - PARAM_FIXED_OPT (snipe) { snipe = FRACUNIT; } + PARAM_FLOAT_OPT (snipe) { snipe = 1.; } PARAM_INT_OPT (maxdamage) { maxdamage = 64; } PARAM_INT_OPT (blocksize) { blocksize = 128; } PARAM_INT_OPT (pointblank) { pointblank = 2; } PARAM_INT_OPT (longrange) { longrange = 4; } - PARAM_FIXED_OPT (runspeed) { runspeed = 160*FRACUNIT; } + PARAM_FLOAT_OPT (runspeed) { runspeed = 160; } PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindActor(NAME_BulletPuff); } if (!self->target) @@ -5059,31 +5029,27 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) A_FaceTarget (self); // Target can dodge if it can see enemy - angle_t angle = self->target->__f_AngleTo(self) - self->target->_f_angle(); - angle >>= 24; - bool dodge = (P_CheckSight(self->target, self) && (angle>226 || angle<30)); + DAngle angle = absangle(self->target->Angles.Yaw, self->target->AngleTo(self)); + bool dodge = (P_CheckSight(self->target, self) && angle < 30. * 256. / 360.); // 30 byteangles ~ 21° // Distance check is simplistic - 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; + DVector2 vec = self->Vec2To(self->target); + double dx = fabs (vec.X); + double dy = fabs (vec.Y); + double dist = dx > dy ? dx : dy; // Some enemies are more precise - dist = FixedMul(dist, snipe); + dist *= snipe; // Convert distance into integer number of blocks - dist >>= FRACBITS; - dist /= blocksize; + int idist = int(dist / blocksize); // Now for the speed accuracy thingie - 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()); + double speed = self->target->Vel.LengthSquared(); int hitchance = speed < runspeed ? 256 : 160; // Distance accuracy (factoring dodge) - hitchance -= dist * (dodge ? 16 : 8); + hitchance -= idist * (dodge ? 16 : 8); // While we're here, we may as well do something for this: if (self->target->flags & MF_SHADOW) @@ -5095,9 +5061,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) if (pr_cabullet() < hitchance) { // Compute position for spawning blood/puff - angle = self->target->__f_AngleTo(self); - - DVector3 BloodPos = self->target->Vec3Angle(self->target->radius, ANGLE2DBL(angle), self->target->Height/2); + DAngle angle = self->target->AngleTo(self); + DVector3 BloodPos = self->target->Vec3Angle(self->target->radius, angle, self->target->Height/2); int damage = flags & WAF_NORANDOM ? maxdamage : (1 + (pr_cabullet() % maxdamage)); if (dist >= pointblank) @@ -5118,7 +5083,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) if ((0 && dpuff->flags3 & MF3_PUFFONACTORS) || !spawnblood) { spawnblood = false; - P_SpawnPuff(self, pufftype, BloodPos, ANGLE2DBL(angle), ANGLE2DBL(angle), 0); + P_SpawnPuff(self, pufftype, BloodPos, angle, angle, 0); } } else if (self->target->flags3 & MF3_GHOST) @@ -5128,7 +5093,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) int newdam = P_DamageMobj(self->target, self, self, damage, mod, DMG_THRUSTLESS); if (spawnblood) { - P_SpawnBlood(BloodPos, ANGLE2DBL(angle), newdam > 0 ? newdam : damage, self->target); + P_SpawnBlood(BloodPos, angle, newdam > 0 ? newdam : damage, self->target); P_TraceBleed(newdam > 0 ? newdam : damage, self->target, self); } } @@ -5150,15 +5115,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp) { PARAM_ACTION_PROLOGUE; PARAM_INT(destination_selector); - PARAM_FIXED_OPT(xofs) { xofs = 0; } - PARAM_FIXED_OPT(yofs) { yofs = 0; } - PARAM_FIXED_OPT(zofs) { zofs = 0; } - PARAM_ANGLE_OPT(angle) { angle = 0; } + PARAM_FLOAT_OPT(xofs) { xofs = 0; } + PARAM_FLOAT_OPT(yofs) { yofs = 0; } + PARAM_FLOAT_OPT(zofs) { zofs = 0; } + PARAM_ANGLE_OPT(angle) { angle = 0.; } PARAM_INT_OPT(flags) { flags = 0; } PARAM_STATE_OPT(success_state) { success_state = NULL; } - PARAM_FIXED_OPT(heightoffset) { heightoffset = 0; } - PARAM_FIXED_OPT(radiusoffset) { radiusoffset = 0; } - PARAM_ANGLE_OPT(pitch) { pitch = 0; } + PARAM_FLOAT_OPT(heightoffset) { heightoffset = 0; } + PARAM_FLOAT_OPT(radiusoffset) { radiusoffset = 0; } + PARAM_ANGLE_OPT(pitch) { pitch = 0.; } AActor *reference; @@ -5359,7 +5324,7 @@ enum RadiusGiveFlags RGF_CORPSES | RGF_MISSILES, }; -static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amount, fixed_t distance, int flags, PClassActor *filter, FName species, fixed_t mindist) +static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amount, double distance, int flags, PClassActor *filter, FName species, double mindist) { // [MC] We only want to make an exception for missiles here. Nothing else. bool missilePass = !!((flags & RGF_MISSILES) && thing->flags & MF_MISSILE); @@ -5433,26 +5398,22 @@ static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amo if (selfPass || monsterPass || corpsePass || killedPass || itemPass || objectPass || missilePass || playerPass || voodooPass) { - fixedvec3 diff = self->_f_Vec3To(thing); - diff.z += (thing->_f_height() - self->_f_height()) / 2; + DVector3 diff = self->Vec3To(thing); + diff.Z += thing->Height *0.5; if (flags & RGF_CUBE) { // check if inside a cube - double dx = fabs((double)(diff.x)); - double dy = fabs((double)(diff.y)); - double dz = fabs((double)(diff.z)); - double dist = (double)distance; - double min = (double)mindist; - if ((dx > dist || dy > dist || dz > dist) || (min && (dx < min && dy < min && dz < min))) + double dx = fabs(diff.X); + double dy = fabs(diff.Y); + double dz = fabs(diff.Z); + if ((dx > distance || dy > distance || dz > distance) || (mindist && (dx < mindist && dy < mindist && dz < mindist))) { return false; } } else { // check if inside a sphere - double distsquared = double(distance) * double(distance); - double minsquared = double(mindist) * double(mindist); - double lengthsquared = DVector3(diff.x, diff.y, diff.z).LengthSquared(); - if (lengthsquared > distsquared || (minsquared && (lengthsquared < minsquared))) + double lengthsquared = diff.LengthSquared(); + if (lengthsquared > distance*distance || (mindist && (lengthsquared < mindist*mindist))) { return false; } @@ -5489,12 +5450,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive) { PARAM_ACTION_PROLOGUE; PARAM_CLASS (item, AInventory); - PARAM_FIXED (distance); + PARAM_FLOAT (distance); PARAM_INT (flags); PARAM_INT_OPT (amount) { amount = 0; } PARAM_CLASS_OPT (filter, AActor) { filter = NULL; } PARAM_NAME_OPT (species) { species = NAME_None; } - PARAM_FIXED_OPT (mindist) { mindist = 0; } + PARAM_FLOAT_OPT (mindist) { mindist = 0; } // We need a valid item, valid targets, and a valid range if (item == NULL || (flags & RGF_MASK) == 0 || !flags || distance <= 0 || mindist >= distance) @@ -5519,8 +5480,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive) else { FPortalGroupArray check(FPortalGroupArray::PGA_Full3d); - fixed_t mid = self->_f_Z() + self->_f_height() / 2; - FMultiBlockThingsIterator it(check, self->_f_X(), self->_f_Y(), mid-distance, mid+distance, distance, false, self->Sector); + double mid = self->Center(); + FMultiBlockThingsIterator it(check, self->X(), self->Y(), mid-distance, mid+distance, distance, false, self->Sector); FMultiBlockThingsIterator::CheckResult cres; while ((it.Next(&cres))) @@ -6341,8 +6302,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHigherOrLower) PARAM_ACTION_PROLOGUE; PARAM_STATE(high); PARAM_STATE(low); - PARAM_FIXED_OPT(offsethigh) { offsethigh = 0; } - PARAM_FIXED_OPT(offsetlow) { offsetlow = 0; } + PARAM_FLOAT_OPT(offsethigh) { offsethigh = 0; } + PARAM_FLOAT_OPT(offsetlow) { offsetlow = 0; } PARAM_BOOL_OPT(includeHeight) { includeHeight = true; } PARAM_INT_OPT(ptr) { ptr = AAPTR_TARGET; } @@ -6351,11 +6312,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHigherOrLower) if (mobj != NULL && mobj != self) //AAPTR_DEFAULT is completely useless in this regard. { - if ((high) && (mobj->_f_Z() > ((includeHeight ? self->_f_height() : 0) + self->_f_Z() + offsethigh))) + if ((high) && (mobj->Z() > ((includeHeight ? self->Height : 0) + self->Z() + offsethigh))) { ACTION_RETURN_STATE(high); } - else if ((low) && (mobj->_f_Z() + (includeHeight ? mobj->_f_height() : 0)) < (self->_f_Z() + offsetlow)) + else if ((low) && (mobj->Z() + (includeHeight ? mobj->Height : 0)) < (self->Z() + offsetlow)) { ACTION_RETURN_STATE(low); } @@ -6482,7 +6443,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckProximity) PARAM_ACTION_PROLOGUE; PARAM_STATE(jump); PARAM_CLASS(classname, AActor); - PARAM_FIXED(distance); + PARAM_FLOAT(distance); PARAM_INT_OPT(count) { count = 1; } PARAM_INT_OPT(flags) { flags = 0; } PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } @@ -6503,7 +6464,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckProximity) } int counter = 0; bool result = false; - fixed_t closer = distance, farther = 0, current = distance; + double closer = distance, farther = 0, current = distance; const bool ptrWillChange = !!(flags & (CPXF_SETTARGET | CPXF_SETMASTER | CPXF_SETTRACER)); const bool ptrDistPref = !!(flags & (CPXF_CLOSEST | CPXF_FARTHEST)); @@ -6534,10 +6495,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckProximity) //[MC]Make sure it's in range and respect the desire for Z or not. The function forces it to use //Z later for ensuring CLOSEST and FARTHEST flags are respected perfectly. //Ripped from sphere checking in A_RadiusGive (along with a number of things). - if ((ref->AproxDistance(mo) < distance && + if ((ref->Distance2D(mo) < distance && ((flags & CPXF_NOZ) || - ((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))))) + ((ref->Z() > mo->Z() && ref->Z() - mo->Top() < distance) || + (ref->Z() <= mo->Z() && mo->Z() - ref->Top() < distance))))) { if ((flags & CPXF_CHECKSIGHT) && !(P_CheckSight(mo, ref, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY))) continue; @@ -6641,10 +6602,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock) PARAM_STATE(block) PARAM_INT_OPT(flags) { flags = 0; } PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } - PARAM_FIXED_OPT(xofs) { xofs = 0; } - PARAM_FIXED_OPT(yofs) { yofs = 0; } - PARAM_FIXED_OPT(zofs) { zofs = 0; } - PARAM_ANGLE_OPT(angle) { angle = 0; } + PARAM_FLOAT_OPT(xofs) { xofs = 0; } + PARAM_FLOAT_OPT(yofs) { yofs = 0; } + PARAM_FLOAT_OPT(zofs) { zofs = 0; } + PARAM_ANGLE_OPT(angle) { angle = 0.; } AActor *mobj = COPY_AAPTR(self, ptr); @@ -6654,28 +6615,23 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock) ACTION_RETURN_STATE(NULL); } -#if 0 // this needs some work. if (!(flags & CBF_ABSOLUTEANGLE)) { - angle += self->angle; + angle += self->Angles.Yaw; } - angle_t ang = angle >> ANGLETOFINESHIFT; - fixedvec3 oldpos = mobj->Pos(); - fixedvec3 pos; + DVector3 oldpos = mobj->Pos(); + DVector3 pos; if (flags & CBF_ABSOLUTEPOS) { - pos.x = xofs; - pos.y = yofs; - pos.z = zofs; + pos = { xofs, yofs, zofs }; } else { - pos = mobj->Vec3Offset( - FixedMul(xofs, finecosine[ang]) + FixedMul(yofs, finesine[ang]), - FixedMul(xofs, finesine[ang]) - FixedMul(yofs, finecosine[ang]), - mobj->Z() + zofs); + double s = angle.Sin(); + double c = angle.Cos(); + pos = mobj->Vec3Offset(xofs * c + yofs * s, xofs * s - yofs * c, zofs); } // Next, try checking the position based on the sensitivity desired. @@ -6685,9 +6641,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock) bool checker = false; if (flags & CBF_DROPOFF) { - mobj->SetZ(pos.z); - checker = P_CheckMove(mobj, pos.x, pos.y); - mobj->SetZ(oldpos.z); + mobj->SetZ(pos.Z); + checker = P_CheckMove(mobj, pos.X, pos.Y); + mobj->SetZ(oldpos.Z); } else { @@ -6695,10 +6651,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock) checker = P_TestMobjLocation(mobj); mobj->SetOrigin(oldpos, true); } -#endif - //Nothing to block it so skip the rest. - bool checker = (flags & CBF_DROPOFF) ? P_CheckMove(mobj, mobj->_f_X(), mobj->_f_Y()) : P_TestMobjLocation(mobj); if (checker) { ACTION_RETURN_STATE(NULL); @@ -6747,9 +6700,9 @@ enum FMDFlags DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection) { PARAM_ACTION_PROLOGUE; - PARAM_ANGLE_OPT(offset) { offset = 0; } - PARAM_ANGLE_OPT(anglelimit) { anglelimit = 0; } - PARAM_ANGLE_OPT(pitchlimit) { pitchlimit = 0; } + PARAM_ANGLE_OPT(offset) { offset = 0.; } + PARAM_ANGLE_OPT(anglelimit) { anglelimit = 0.; } + PARAM_ANGLE_OPT(pitchlimit) { pitchlimit = 0.; } PARAM_INT_OPT(flags) { flags = 0; } PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } @@ -6764,78 +6717,65 @@ 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)) { - angle_t current = mobj->_f_angle(); - const angle_t angle = R_PointToAngle2(0, 0, mobj->_f_velx(), mobj->_f_vely()); + DAngle current = mobj->Angles.Yaw; + DAngle angle = mobj->Vel.Angle(); //Done because using anglelimit directly causes a signed/unsigned mismatch. - const angle_t limit = anglelimit; //Code borrowed from A_Face*. - if (limit > 0 && (absangle(current - angle) > limit)) + if (anglelimit > 0) { - if (current < angle) + DAngle delta = deltaangle(current, angle); + if (fabs(delta) > anglelimit) { - // [MC] This may appear backwards, but I assure any who - // reads this, it works. - if (current - angle > ANGLE_180) - current += limit + offset; - else - current -= limit + offset; - mobj->SetAngle(ANGLE2DBL(current), !!(flags & FMDF_INTERPOLATE)); + if (delta < 0) + { + current += anglelimit + offset; + } + else if (delta > 0) + { + current -= anglelimit + offset; + } + else // huh??? + { + current = angle + 180. + offset; + } + mobj->SetAngle(current, !!(flags & FMDF_INTERPOLATE)); } - else if (current > angle) - { - if (angle - current > ANGLE_180) - current -= limit + offset; - else - current += limit + offset; - mobj->SetAngle(ANGLE2DBL(current), !!(flags & FMDF_INTERPOLATE)); - } - else - mobj->SetAngle(ANGLE2DBL(angle + ANGLE_180 + offset), !!(flags & FMDF_INTERPOLATE)); } else - mobj->SetAngle(ANGLE2DBL(angle + offset), !!(flags & FMDF_INTERPOLATE)); + mobj->SetAngle(angle + offset, !!(flags & FMDF_INTERPOLATE)); } if (!(flags & FMDF_NOPITCH)) { - fixed_t current = mobj->_f_pitch(); - const DVector2 velocity(mobj->_f_velx(), mobj->_f_vely()); - const fixed_t pitch = R_PointToAngle2(0, 0, xs_CRoundToInt(velocity.Length()), -mobj->_f_velz()); + DAngle current = mobj->Angles.Pitch; + const DVector2 velocity = mobj->Vel.XY(); + DAngle pitch = VecToAngle(velocity.Length(), -mobj->Vel.Z); if (pitchlimit > 0) { - // [MC] angle_t for pitchlimit was required because otherwise - // we would wind up with less than desirable turn rates that didn't - // match that of A_SetPitch. We want consistency. Also, I didn't know - // of a better way to convert from angle_t to fixed_t properly so I - // used this instead. - fixed_t plimit = fixed_t(pitchlimit); + DAngle pdelta = deltaangle(current, pitch); - if (abs(current - pitch) > plimit) + if (fabs(pdelta) > pitchlimit) { - fixed_t max = 0; - - if (current > pitch) + if (pdelta > 0) { - max = MIN(plimit, (current - pitch)); - current -= max; + current -= MIN(pitchlimit, pdelta); } - else //if (current > pitch) + else //if (pdelta < 0) { - max = MIN(plimit, (pitch - current)); - current += max; + current += MIN(pitchlimit, -pdelta); } - mobj->SetPitch(ANGLE2DBL(current), !!(flags & FMDF_INTERPOLATE)); + mobj->SetPitch(current, !!(flags & FMDF_INTERPOLATE)); } else { - mobj->SetPitch(ANGLE2DBL(pitch), !!(flags & FMDF_INTERPOLATE)); + mobj->SetPitch(pitch, !!(flags & FMDF_INTERPOLATE)); } } else { - mobj->SetPitch(ANGLE2DBL(pitch), !!(flags & FMDF_INTERPOLATE)); + mobj->SetPitch(pitch, !!(flags & FMDF_INTERPOLATE)); } } ACTION_RETURN_BOOL(true); diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index e9686532d..1531b46f7 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -649,7 +649,7 @@ void InitThingdef() symt.AddSymbol(new PField(NAME_Height, TypeFloat64, VARF_Native, myoffsetof(AActor,Height))); symt.AddSymbol(new PField(NAME_Radius, TypeFloat64, 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_MeleeRange, TypeFloat64, VARF_Native, myoffsetof(AActor,meleerange))); 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_parse.cpp b/src/thingdef/thingdef_parse.cpp index e0b19d19c..d68ab6fdb 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -486,10 +486,6 @@ static void ParseNativeFunction(FScanner &sc, PClassActor *cls) rets.Push(TypeFloat64); break; - case TK_Angle_t: - rets.Push(TypeAngle); - break; - case TK_Fixed_t: rets.Push(TypeFixed); break; diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 4ac179305..63e74cb24 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1,7 +1,7 @@ /* ** thingdef-properties.cpp ** -** Actor definitions - properties and flags handling +** Actor denitions - properties and flags handling ** **--------------------------------------------------------------------------- ** Copyright 2002-2007 Christoph Oelckers @@ -245,10 +245,10 @@ void HandleDeprecatedFlags(AActor *defaults, PClassActor *info, bool set, int in defaults->Gravity = set ? 1. / 8 : 1.; break; case DEPF_SHORTMISSILERANGE: - defaults->maxtargetrange = set? 896*FRACUNIT : 0; + defaults->maxtargetrange = set? 896. : 0.; break; case DEPF_LONGMELEERANGE: - defaults->meleethreshold = set? 196*FRACUNIT : 0; + defaults->meleethreshold = set? 196. : 0.; break; case DEPF_QUARTERGRAVITY: defaults->Gravity = set ? 1. / 4 : 1.; @@ -314,9 +314,9 @@ bool CheckDeprecatedFlags(const AActor *actor, PClassActor *info, int index) case DEPF_LOWGRAVITY: return actor->Gravity == 1./8; case DEPF_SHORTMISSILERANGE: - return actor->maxtargetrange == 896*FRACUNIT; + return actor->maxtargetrange == 896.; case DEPF_LONGMELEERANGE: - return actor->meleethreshold == 196*FRACUNIT; + return actor->meleethreshold == 196.; case DEPF_QUARTERGRAVITY: return actor->Gravity == 1./4; case DEPF_FIRERESIST: @@ -936,7 +936,7 @@ DEFINE_PROPERTY(burnheight, F, Actor) //========================================================================== DEFINE_PROPERTY(maxtargetrange, F, Actor) { - PROP_FIXED_PARM(id, 0); + PROP_DOUBLE_PARM(id, 0); defaults->maxtargetrange = id; } @@ -945,7 +945,7 @@ DEFINE_PROPERTY(maxtargetrange, F, Actor) //========================================================================== DEFINE_PROPERTY(meleethreshold, F, Actor) { - PROP_FIXED_PARM(id, 0); + PROP_DOUBLE_PARM(id, 0); defaults->meleethreshold = id; } @@ -964,7 +964,7 @@ DEFINE_PROPERTY(meleedamage, I, Actor) //========================================================================== DEFINE_PROPERTY(meleerange, F, Actor) { - PROP_FIXED_PARM(id, 0); + PROP_DOUBLE_PARM(id, 0); defaults->meleerange = id; } @@ -1003,7 +1003,7 @@ DEFINE_PROPERTY(missileheight, F, Actor) //========================================================================== DEFINE_PROPERTY(pushfactor, F, Actor) { - PROP_FIXED_PARM(id, 0); + PROP_DOUBLE_PARM(id, 0); defaults->pushfactor = id; } @@ -1132,8 +1132,8 @@ DEFINE_PROPERTY(bouncetype, S, Actor) //========================================================================== DEFINE_PROPERTY(bouncefactor, F, Actor) { - PROP_FIXED_PARM(id, 0); - defaults->bouncefactor = clamp(id, 0, FRACUNIT); + PROP_DOUBLE_PARM(id, 0); + defaults->bouncefactor = clamp(id, 0, 1); } //========================================================================== @@ -1141,8 +1141,8 @@ DEFINE_PROPERTY(bouncefactor, F, Actor) //========================================================================== DEFINE_PROPERTY(wallbouncefactor, F, Actor) { - PROP_FIXED_PARM(id, 0); - defaults->wallbouncefactor = clamp(id, 0, FRACUNIT); + PROP_DOUBLE_PARM(id, 0); + defaults->wallbouncefactor = clamp(id, 0, 1); } //========================================================================== @@ -1310,7 +1310,7 @@ DEFINE_PROPERTY(fastspeed, F, Actor) //========================================================================== DEFINE_PROPERTY(radiusdamagefactor, F, Actor) { - PROP_FIXED_PARM(i, 0); + PROP_DOUBLE_PARM(i, 0); assert(info->IsKindOf(RUNTIME_CLASS(PClassActor))); static_cast(info)->RDFactor = i; } @@ -1350,7 +1350,7 @@ DEFINE_PROPERTY(gravity, F, Actor) //========================================================================== DEFINE_PROPERTY(friction, F, Actor) { - PROP_FIXED_PARM(i, 0); + PROP_DOUBLE_PARM(i, 0); if (i < 0) I_Error ("Friction must not be negative."); defaults->Friction = i; @@ -2093,9 +2093,9 @@ DEFINE_CLASS_PROPERTY(slotnumber, I, Weapon) //========================================================================== DEFINE_CLASS_PROPERTY(slotpriority, F, Weapon) { - PROP_FIXED_PARM(i, 0); + PROP_DOUBLE_PARM(i, 0); assert(info->IsKindOf(RUNTIME_CLASS(PClassWeapon))); - static_cast(info)->SlotPriority = i; + static_cast(info)->SlotPriority = int(i*65536); } //========================================================================== @@ -2504,7 +2504,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, clearcolorset, I, PlayerPawn) //========================================================================== DEFINE_CLASS_PROPERTY_PREFIX(player, attackzoffset, F, PlayerPawn) { - PROP_FIXED_PARM(z, 0); + PROP_DOUBLE_PARM(z, 0); defaults->AttackZOffset = z; } @@ -2522,7 +2522,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, jumpz, F, PlayerPawn) //========================================================================== DEFINE_CLASS_PROPERTY_PREFIX(player, GruntSpeed, F, PlayerPawn) { - PROP_FIXED_PARM(z, 0); + PROP_DOUBLE_PARM(z, 0); defaults->GruntSpeed = z; } @@ -2531,8 +2531,8 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, GruntSpeed, F, PlayerPawn) //========================================================================== DEFINE_CLASS_PROPERTY_PREFIX(player, FallingScreamSpeed, FF, PlayerPawn) { - PROP_FIXED_PARM(minz, 0); - PROP_FIXED_PARM(maxz, 1); + PROP_DOUBLE_PARM(minz, 0); + PROP_DOUBLE_PARM(maxz, 1); defaults->FallingScreamMinSpeed = minz; defaults->FallingScreamMaxSpeed = maxz; } @@ -2582,7 +2582,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, viewheight, F, PlayerPawn) //========================================================================== DEFINE_CLASS_PROPERTY_PREFIX(player, userange, F, PlayerPawn) { - PROP_FIXED_PARM(z, 0); + PROP_DOUBLE_PARM(z, 0); defaults->UseRange = z; } @@ -2591,7 +2591,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, userange, F, PlayerPawn) //========================================================================== DEFINE_CLASS_PROPERTY_PREFIX(player, aircapacity, F, PlayerPawn) { - PROP_FIXED_PARM(z, 0); + PROP_DOUBLE_PARM(z, 0); defaults->AirCapacity = z; } diff --git a/src/zscript/vm.h b/src/zscript/vm.h index 1f5c8d95b..317a69846 100644 --- a/src/zscript/vm.h +++ b/src/zscript/vm.h @@ -894,9 +894,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction #define PARAM_SOUND_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); FSoundID x = param[p].i; #define PARAM_COLOR_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); PalEntry x; x.d = param[p].i; #define PARAM_FLOAT_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); double x = param[p].f; -#define PARAM_FIXED_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); fixed_t x = FLOAT2FIXED(param[p].f); -#define PARAM_ANGLE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); angle_t x = FLOAT2ANGLE(param[p].f); -#define PARAM_DANGLE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); DAngle x = param[p].f; +#define PARAM_ANGLE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); DAngle x = param[p].f; #define PARAM_STRING_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_STRING); FString x = param[p].s(); #define PARAM_STATE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_STATE || param[p].a == NULL)); FState *x = (FState *)param[p].a; #define PARAM_POINTER_AT(p,x,type) assert((p) < numparam); assert(param[p].Type == REGT_POINTER); type *x = (type *)param[p].a; @@ -913,9 +911,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction #define PARAM_SOUND_OPT_AT(p,x) FSoundID x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_INT); x = FSoundID(param[p].i); } else #define PARAM_COLOR_OPT_AT(p,x) PalEntry x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_INT); x.d = param[p].i; } else #define PARAM_FLOAT_OPT_AT(p,x) double x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = param[p].f; } else -#define PARAM_FIXED_OPT_AT(p,x) fixed_t x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = FLOAT2FIXED(param[p].f); } else -#define PARAM_ANGLE_OPT_AT(p,x) angle_t x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = FLOAT2ANGLE(param[p].f); } else -#define PARAM_DANGLE_OPT_AT(p,x) DAngle x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = param[p].f; } else +#define PARAM_ANGLE_OPT_AT(p,x) DAngle x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = param[p].f; } else #define PARAM_STRING_OPT_AT(p,x) FString x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_STRING); x = param[p].s(); } else #define PARAM_STATE_OPT_AT(p,x) FState *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_STATE || param[p].a == NULL)); x = (FState *)param[p].a; } else #define PARAM_POINTER_OPT_AT(p,x,type) type *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER); x = (type *)param[p].a; } else @@ -931,9 +927,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction #define PARAM_SOUND(x) ++paramnum; PARAM_SOUND_AT(paramnum,x) #define PARAM_COLOR(x) ++paramnum; PARAM_COLOR_AT(paramnum,x) #define PARAM_FLOAT(x) ++paramnum; PARAM_FLOAT_AT(paramnum,x) -#define PARAM_FIXED(x) ++paramnum; PARAM_FIXED_AT(paramnum,x) #define PARAM_ANGLE(x) ++paramnum; PARAM_ANGLE_AT(paramnum,x) -#define PARAM_DANGLE(x) ++paramnum; PARAM_DANGLE_AT(paramnum,x) #define PARAM_STRING(x) ++paramnum; PARAM_STRING_AT(paramnum,x) #define PARAM_STATE(x) ++paramnum; PARAM_STATE_AT(paramnum,x) #define PARAM_POINTER(x,type) ++paramnum; PARAM_POINTER_AT(paramnum,x,type) @@ -946,9 +940,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction #define PARAM_SOUND_OPT(x) ++paramnum; PARAM_SOUND_OPT_AT(paramnum,x) #define PARAM_COLOR_OPT(x) ++paramnum; PARAM_COLOR_OPT_AT(paramnum,x) #define PARAM_FLOAT_OPT(x) ++paramnum; PARAM_FLOAT_OPT_AT(paramnum,x) -#define PARAM_FIXED_OPT(x) ++paramnum; PARAM_FIXED_OPT_AT(paramnum,x) #define PARAM_ANGLE_OPT(x) ++paramnum; PARAM_ANGLE_OPT_AT(paramnum,x) -#define PARAM_DANGLE_OPT(x) ++paramnum; PARAM_DANGLE_OPT_AT(paramnum,x) #define PARAM_STRING_OPT(x) ++paramnum; PARAM_STRING_OPT_AT(paramnum,x) #define PARAM_STATE_OPT(x) ++paramnum; PARAM_STATE_OPT_AT(paramnum,x) #define PARAM_POINTER_OPT(x,type) ++paramnum; PARAM_POINTER_OPT_AT(paramnum,x,type) diff --git a/src/zscript/vmexec.h b/src/zscript/vmexec.h index 954a8cde8..e75e7a9eb 100644 --- a/src/zscript/vmexec.h +++ b/src/zscript/vmexec.h @@ -220,16 +220,6 @@ begin: GETADDR(PB,RC,X_READ_NIL); reg.f[a] = *(VM_SWORD *)ptr / 65536.0; NEXTOP; - OP(LANG): - ASSERTF(a); ASSERTA(B); ASSERTKD(C); - GETADDR(PB,KC,X_READ_NIL); - reg.f[a] = (*(VM_UWORD *)ptr >> 1) * (180.0 / 0x40000000); // BAM -> deg - NEXTOP; - OP(LANG_R): - ASSERTF(a); ASSERTA(B); ASSERTD(C); - GETADDR(PB,RC,X_READ_NIL); - reg.f[a] = (*(VM_UWORD *)ptr >> 1) * (180.0 / 0x40000000); - NEXTOP; OP(LBIT): ASSERTD(a); ASSERTA(B); GETADDR(PB,0,X_READ_NIL); @@ -336,16 +326,6 @@ begin: GETADDR(PA,RC,X_WRITE_NIL); *(VM_SWORD *)ptr = (VM_SWORD)(reg.f[B] * 65536.0); NEXTOP; - OP(SANG): - ASSERTA(a); ASSERTF(B); ASSERTKD(C); - GETADDR(PA,KC,X_WRITE_NIL); - *(VM_UWORD *)ptr = (VM_UWORD)(xs_CRoundToInt((reg.f[B]) * (0x40000000/90.))); // deg -> BAM - NEXTOP; - OP(SANG_R): - ASSERTA(a); ASSERTF(B); ASSERTD(C); - GETADDR(PA,RC,X_WRITE_NIL); - *(VM_UWORD *)ptr = (VM_UWORD)(xs_CRoundToInt((reg.f[B]) * (0x40000000/90.))); - NEXTOP; OP(SBIT): ASSERTA(a); ASSERTD(B); GETADDR(PA,0,X_WRITE_NIL); diff --git a/src/zscript/vmops.h b/src/zscript/vmops.h index 36924d6bb..e1b230984 100644 --- a/src/zscript/vmops.h +++ b/src/zscript/vmops.h @@ -37,8 +37,6 @@ xx(LV, lv, RVRPKI), // load vector xx(LV_R, lv, RVRPRI), xx(LX, lx, RFRPKI), // load fixed point xx(LX_R, lx, RFRPRI), -xx(LANG, lang, RFRPKI), // load angle -xx(LANG_R, lang, RFRPRI), xx(LBIT, lbit, RIRPI8), // rA = !!(*rB & C) -- *rB is a byte @@ -61,8 +59,6 @@ xx(SV, sv, RPRVKI), // store vector xx(SV_R, sv, RPRVRI), xx(SX, sx, RPRFKI), // store fixed point xx(SX_R, sx, RPRFRI), -xx(SANG, sang, RPRFKI), // store angle -xx(SANG_R, sang, RPRFRI), xx(SBIT, sbit, RPRII8), // *rA |= C if rB is true, *rA &= ~C otherwise