- made AActor::gravity and FMapThing::gravity floats.

This commit is contained in:
Christoph Oelckers 2016-03-21 00:51:19 +01:00
parent 7ebb96f15c
commit 1ff4bb419c
18 changed files with 43 additions and 43 deletions

View file

@ -1217,7 +1217,7 @@ public:
fixed_t bouncefactor; // Strife's grenades use 50%, Hexen's Flechettes 70.
fixed_t wallbouncefactor; // The bounce factor for walls can be different.
int bouncecount; // Strife's grenades only bounce twice before exploding
fixed_t gravity; // [GRB] Gravity factor
double Gravity; // [GRB] Gravity factor
fixed_t Friction;
int FastChaseStrafeCount;
fixed_t pushfactor;

View file

@ -1215,7 +1215,7 @@ static int PatchThing (int thingy)
}
if (value[1] & 0x00000001)
{
info->gravity = FRACUNIT/4;
info->Gravity = 1./4;
value[1] &= ~0x00000001;
}
info->flags2 = ActorFlags2::FromInt (value[1]);

View file

@ -358,7 +358,7 @@ struct FMapThing
int special;
int args[5];
int Conversation;
fixed_t gravity;
double Gravity;
fixed_t alpha;
DWORD fillcolor;
DVector2 Scale;

View file

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

View file

@ -199,9 +199,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact)
if (self->Z() <= self->floorz)
{
self->flags |= MF_NOGRAVITY;
self->gravity = FRACUNIT;
self->_f_AddZ(28*FRACUNIT);
//self->Vel.Z = 3*FRACUNIT;
self->Gravity = 1;
self->AddZ(28);
//self->Vel.Z = 3;
}
P_RadiusAttack (self, self->target, 25, 25, NAME_Fire, RADF_HURTSOURCE);
for (i = 0; i < 4; i++)

View file

@ -472,13 +472,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_MacePL1Check)
}
self->special1 = 0;
self->flags &= ~MF_NOGRAVITY;
self->gravity = FRACUNIT/8;
self->Gravity = 1. / 8;;
// [RH] Avoid some precision loss by scaling the velocity directly
#if 0
// This is the original code, for reference.
a.ngle_t angle = self->_f_angle()>>ANGLETOF.INESHIFT;
self->vel.x = F.ixedMul(7*F.RACUNIT, f.inecosine[angle]);
self->vel.y = F.ixedMul(7*F.RACUNIT, f.inesine[angle]);
a.ngle_t angle = self->angle>>ANGLETOF.INESHIFT;
self->velx = F.ixedMul(7*F.RACUNIT, f.inecosine[angle]);
self->vely = F.ixedMul(7*F.RACUNIT, f.inesine[angle]);
#else
double velscale = 7 / self->Vel.XY().Length();
self->Vel.X *= velscale;
@ -510,7 +510,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact)
{ // Explode
self->Vel.Zero();
self->flags |= MF_NOGRAVITY;
self->gravity = FRACUNIT;
self->Gravity = 1;
S_Sound (self, CHAN_BODY, "weapons/macehit", 1, ATTN_NORM);
}
return 0;
@ -564,7 +564,7 @@ boom:
self->Vel.Zero();
self->flags |= MF_NOGRAVITY;
self->BounceFlags = BOUNCE_None;
self->gravity = FRACUNIT;
self->Gravity = 1;
}
return 0;
}
@ -680,7 +680,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact)
boom:
self->Vel.Zero();
self->flags |= MF_NOGRAVITY;
self->gravity = FRACUNIT;
self->Gravity = 1;
S_Sound (self, CHAN_BODY, "weapons/maceexplode", 1, ATTN_NORM);
}
return 0;

View file

@ -30,7 +30,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DripBlood)
mo = Spawn ("Blood", self->Vec3Offset(xo, yo, 0.), ALLOW_REPLACE);
mo->Vel.X = pr_dripblood.Random2 () / 64.;
mo->Vel.Y = pr_dripblood.Random2() / 64.;
mo->gravity = FRACUNIT/8;
mo->Gravity = 1./8;
return 0;
}

View file

@ -942,8 +942,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallPop)
S_Sound (self, CHAN_BODY, "SorcererBallPop", 1, ATTN_NONE);
self->flags &= ~MF_NOGRAVITY;
self->gravity = FRACUNIT/8;
self->Gravity = 1. / 8;;
self->Vel.X = ((pr_heresiarch()%10)-5);
self->Vel.Y = ((pr_heresiarch()%10)-5);
self->Vel.Z = (2+(pr_heresiarch()%3));

View file

@ -612,7 +612,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Gravity)
PARAM_ACTION_PROLOGUE;
self->flags &= ~MF_NOGRAVITY;
self->gravity = FRACUNIT;
self->Gravity = 1;
return 0;
}
@ -627,7 +627,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LowGravity)
PARAM_ACTION_PROLOGUE;
self->flags &= ~MF_NOGRAVITY;
self->gravity = FRACUNIT/8;
self->Gravity = 1. / 8;;
return 0;
}

View file

@ -3918,7 +3918,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value)
break;
case APROP_Gravity:
actor->gravity = value;
actor->Gravity = ACSToDouble(value);
break;
case APROP_SeeSound:
@ -4050,7 +4050,7 @@ int DLevelScript::GetActorProperty (int tid, int property)
// The current render style isn't expressable as a legacy style,
// so pretends it's normal.
return STYLE_Normal;
case APROP_Gravity: return actor->gravity;
case APROP_Gravity: return DoubleToACS(actor->Gravity);
case APROP_Invulnerable:return !!(actor->flags2 & MF2_INVULNERABLE);
case APROP_Ambush: return !!(actor->flags & MF_AMBUSH);
case APROP_Dropped: return !!(actor->flags & MF_DROPPED);

View file

@ -705,7 +705,7 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites,
mapthings[count].SkillFilter = 0xffff;
mapthings[count].flags = MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH;
mapthings[count].special = 0;
mapthings[count].gravity = FRACUNIT;
mapthings[count].Gravity = 1.;
mapthings[count].RenderStyle = STYLE_Count;
mapthings[count].alpha = -1;
mapthings[count].health = -1;

View file

@ -2464,11 +2464,11 @@ FUNC(LS_Sector_SetDamage)
FUNC(LS_Sector_SetGravity)
// Sector_SetGravity (tag, intpart, fracpart)
{
float gravity;
double gravity;
if (arg2 > 99)
arg2 = 99;
gravity = (float)arg1 + (float)arg2 * 0.01f;
gravity = (double)arg1 + (double)arg2 * 0.01;
FSectorTagIterator itr(arg0);
int secnum;

View file

@ -388,7 +388,7 @@ void AActor::Serialize(FArchive &arc)
<< PainType
<< DeathType;
}
arc << gravity
arc << Gravity
<< FastChaseStrafeCount
<< master
<< smokecounter
@ -3807,7 +3807,7 @@ void AActor::Tick ()
{
if (player)
{
if (_f_velz() < (fixed_t)(level.gravity * Sector->gravity * -655.36f)
if (Vel.Z < level.gravity * Sector->gravity * (-1./100)// -655.36f)
&& !(flags&MF_NOGRAVITY))
{
PlayerLandedOnThing (this, onmo);
@ -4165,7 +4165,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t
actor->health = actor->SpawnHealth();
// Actors with zero gravity need the NOGRAVITY flag set.
if (actor->gravity == 0) actor->flags |= MF_NOGRAVITY;
if (actor->Gravity == 0) actor->flags |= MF_NOGRAVITY;
FRandom &rng = bglobal.m_Thinking ? pr_botspawnmobj : pr_spawnmobj;
@ -5137,8 +5137,8 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
mobj->SpawnAngle = mthing->angle;
mobj->SpawnFlags = mthing->flags;
if (mthing->FloatbobPhase >= 0 && mthing->FloatbobPhase < 64) mobj->FloatBobPhase = mthing->FloatbobPhase;
if (mthing->gravity < 0) mobj->gravity = -mthing->gravity;
else if (mthing->gravity > 0) mobj->gravity = FixedMul(mobj->gravity, mthing->gravity);
if (mthing->Gravity < 0) mobj->Gravity = -mthing->Gravity;
else if (mthing->Gravity > 0) mobj->Gravity *= mthing->Gravity;
else mobj->flags &= ~MF_NOGRAVITY;
// For Hexen floatbob 'compatibility' we do not really want to alter the floorz.
@ -6561,7 +6561,7 @@ DDropItem *AActor::GetDropItems() const
double AActor::GetGravity() const
{
if (flags & MF_NOGRAVITY) return 0;
return level.gravity * Sector->gravity * FIXED2DBL(gravity) * 0.00125;
return level.gravity * Sector->gravity * Gravity * 0.00125;
}
// killough 11/98:

View file

@ -1755,7 +1755,7 @@ void P_LoadThings (MapData * map)
memset (&mti[i], 0, sizeof(mti[i]));
mti[i].gravity = FRACUNIT;
mti[i].Gravity = 1;
mti[i].Conversation = 0;
mti[i].SkillFilter = MakeSkill(flags);
mti[i].ClassFilter = 0xffff; // Doom map format doesn't have class flags so spawn for all player classes
@ -1854,7 +1854,7 @@ void P_LoadThings2 (MapData * map)
mti[i].flags &= 0x7ff; // mask out Strife flags if playing an original Hexen map.
}
mti[i].gravity = FRACUNIT;
mti[i].Gravity = 1;
mti[i].RenderStyle = STYLE_Count;
mti[i].alpha = -1;
mti[i].health = 1;

View file

@ -246,7 +246,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
mobj->flags &= ~MF_NOGRAVITY;
if (!(mobj->flags3 & MF3_ISMONSTER) && gravity == 1)
{
mobj->gravity = FRACUNIT/8;
mobj->Gravity = 1./8;
}
}
else

View file

@ -471,7 +471,7 @@ public:
FString arg0str, arg1str;
memset(th, 0, sizeof(*th));
th->gravity = FRACUNIT;
th->Gravity = 1;
th->RenderStyle = STYLE_Count;
th->alpha = -1;
th->health = 1;
@ -519,7 +519,7 @@ public:
case NAME_Gravity:
CHECK_N(Zd | Zdt)
th->gravity = CheckFixed(key);
th->Gravity = CheckFloat(key);
break;
case NAME_Arg0:

View file

@ -3531,9 +3531,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayerSkinCheck)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetGravity)
{
PARAM_ACTION_PROLOGUE;
PARAM_FIXED(gravity);
PARAM_FLOAT(gravity);
self->gravity = clamp<fixed_t>(gravity, 0, FRACUNIT*10);
self->Gravity = clamp(gravity, 0., 10.);
return 0;
}

View file

@ -242,7 +242,7 @@ void HandleDeprecatedFlags(AActor *defaults, PClassActor *info, bool set, int in
defaults->DamageType = set? NAME_Ice : NAME_None;
break;
case DEPF_LOWGRAVITY:
defaults->gravity = set? FRACUNIT/8 : FRACUNIT;
defaults->Gravity = set ? 1. / 8 : 1.;
break;
case DEPF_SHORTMISSILERANGE:
defaults->maxtargetrange = set? 896*FRACUNIT : 0;
@ -251,7 +251,7 @@ void HandleDeprecatedFlags(AActor *defaults, PClassActor *info, bool set, int in
defaults->meleethreshold = set? 196*FRACUNIT : 0;
break;
case DEPF_QUARTERGRAVITY:
defaults->gravity = set? FRACUNIT/4 : FRACUNIT;
defaults->Gravity = set ? 1. / 4 : 1.;
break;
case DEPF_FIRERESIST:
info->SetDamageFactor(NAME_Fire, set? FRACUNIT/2 : FRACUNIT);
@ -312,13 +312,13 @@ bool CheckDeprecatedFlags(const AActor *actor, PClassActor *info, int index)
case DEPF_ICEDAMAGE:
return actor->DamageType == NAME_Ice;
case DEPF_LOWGRAVITY:
return actor->gravity == FRACUNIT/8;
return actor->Gravity == 1./8;
case DEPF_SHORTMISSILERANGE:
return actor->maxtargetrange == 896*FRACUNIT;
case DEPF_LONGMELEERANGE:
return actor->meleethreshold == 196*FRACUNIT;
case DEPF_QUARTERGRAVITY:
return actor->gravity == FRACUNIT/4;
return actor->Gravity == 1./4;
case DEPF_FIRERESIST:
if (info->DamageFactors)
{
@ -1339,10 +1339,10 @@ DEFINE_PROPERTY(vspeed, F, Actor)
//==========================================================================
DEFINE_PROPERTY(gravity, F, Actor)
{
PROP_FIXED_PARM(i, 0);
PROP_DOUBLE_PARM(i, 0);
if (i < 0) I_Error ("Gravity must not be negative.");
defaults->gravity = i;
defaults->Gravity = i;
}
//==========================================================================