Merge branch 'floatcvt' of https://github.com/rheit/zdoom into floatcvt

This commit is contained in:
Christoph Oelckers 2016-03-25 14:56:40 +01:00
commit ad74493d5e
48 changed files with 671 additions and 855 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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 ---------------------------------------------------------

View File

@ -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)

View File

@ -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;

View File

@ -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; }

View File

@ -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.

View File

@ -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.

View File

@ -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;

View File

@ -230,7 +230,7 @@ PClassActor::PClassActor()
WoundHealth = 6;
PoisonDamage = 0;
FastSpeed = -1.;
RDFactor = FRACUNIT;
RDFactor = 1.;
CameraHeight = INT_MIN;
DropItems = NULL;

View File

@ -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

View File

@ -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<APlayerPawn *>(actor)->AttackZOffset = value;
static_cast<APlayerPawn *>(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<APlayerPawn *>(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<APlayerPawn *>(actor)->AttackZOffset;
return DoubleToACS(static_cast<APlayerPawn *>(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)
{

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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<int> (dist >> FRACBITS, mmc);
return pr_checkmissilerange() >= MIN<int> (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;
}

View File

@ -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);

View File

@ -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]

View File

@ -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<<FRACBITS) : player->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<int>(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);

View File

@ -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);

View File

@ -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

View File

@ -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<<flagi)) Printf(" %s", FLAG_NAME(1<<flagi, flags7));
Printf("\nBounce flags: %x\nBounce factors: f:%f, w:%f",
query->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<<flagi) Printf(" %s", flagnamesb[flagi]);*/
Printf("\nRender style = %i:%s, alpha %f\nRender flags: %x",

View File

@ -419,7 +419,7 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y)
{
float bobx = float(player->bob * Rangex);
float boby = float(player->bob * Rangey);
switch (level.levelnum)//bobstyle)
switch (bobstyle)
{
case AWeapon::BobNormal:
*x = bobx * angle.Cos();

View File

@ -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)
{

View File

@ -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;

View File

@ -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)
{

View File

@ -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 ();

View File

@ -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];

View File

@ -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<fixed_t> (friction, 0, FRACUNIT);
friction = (0x1EB8*(sc.Float*100))/0x80 + 0xD001;
friction = clamp<double> (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.;
}
//==========================================================================

View File

@ -115,8 +115,8 @@ struct FTerrainDef
FSoundID RightStepSound;
bool IsLiquid;
bool AllowProtection;
fixed_t Friction;
fixed_t MoveFactor;
double Friction;
double MoveFactor;
};
extern TArray<FSplashDef> Splashes;

View File

@ -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;

View File

@ -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");

View File

@ -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; i<block.portallines.Size(); i++)

View File

@ -624,7 +624,7 @@ struct sector_t
int GetFloorLight () const;
int GetCeilingLight () const;
sector_t *GetHeightSec() const;
fixed_t GetFriction(int plane = sector_t::floor, fixed_t *movefac = NULL) const;
double GetFriction(int plane = sector_t::floor, double *movefac = NULL) const;
DInterpolation *SetInterpolation(int position, bool attach);
@ -959,7 +959,7 @@ struct sector_t
// killough 8/28/98: friction is a sector property, not an mobj property.
// these fields used to be in AActor, but presented performance problems
// when processed as mobj properties. Fix is to make them sector properties.
fixed_t friction, movefactor;
double friction, movefactor;
int terrainnum[2];
@ -1445,27 +1445,27 @@ inline sector_t *P_PointInSector(const DVector2 &pos)
return P_PointInSubsector(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y))->sector;
}
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);
}

View File

@ -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();
}

View File

@ -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); }

View File

@ -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'")

View File

@ -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); }

View File

@ -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);

File diff suppressed because it is too large Load Diff

View File

@ -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)));

View File

@ -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;

View File

@ -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<fixed_t>(id, 0, FRACUNIT);
PROP_DOUBLE_PARM(id, 0);
defaults->bouncefactor = clamp<double>(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<fixed_t>(id, 0, FRACUNIT);
PROP_DOUBLE_PARM(id, 0);
defaults->wallbouncefactor = clamp<double>(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<PClassActor *>(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<PClassWeapon *>(info)->SlotPriority = i;
static_cast<PClassWeapon *>(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;
}

View File

@ -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)

View File

@ -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);

View File

@ -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