From 1ff4bb419c0965d6f3e2f775696cf981378ecd7b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 21 Mar 2016 00:51:19 +0100 Subject: [PATCH] - made AActor::gravity and FMapThing::gravity floats. --- src/actor.h | 2 +- src/d_dehacked.cpp | 2 +- src/doomdata.h | 2 +- src/g_heretic/a_chicken.cpp | 2 +- src/g_heretic/a_hereticmisc.cpp | 6 +++--- src/g_heretic/a_hereticweaps.cpp | 14 +++++++------- src/g_heretic/a_knight.cpp | 2 +- src/g_hexen/a_heresiarch.cpp | 4 ++-- src/g_shared/a_action.cpp | 4 ++-- src/p_acs.cpp | 4 ++-- src/p_buildmap.cpp | 2 +- src/p_lnspec.cpp | 4 ++-- src/p_mobj.cpp | 12 ++++++------ src/p_setup.cpp | 4 ++-- src/p_things.cpp | 2 +- src/p_udmf.cpp | 4 ++-- src/thingdef/thingdef_codeptr.cpp | 4 ++-- src/thingdef/thingdef_properties.cpp | 12 ++++++------ 18 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/actor.h b/src/actor.h index 97afb14aa..b92b6a973 100644 --- a/src/actor.h +++ b/src/actor.h @@ -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; diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index bf6edaee0..7a0ce0d88 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -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]); diff --git a/src/doomdata.h b/src/doomdata.h index 4f372a58e..ddbf899d5 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -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; diff --git a/src/g_heretic/a_chicken.cpp b/src/g_heretic/a_chicken.cpp index debecd1e1..ee154dc38 100644 --- a/src/g_heretic/a_chicken.cpp +++ b/src/g_heretic/a_chicken.cpp @@ -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.; diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp index ef4136f52..927d13dc4 100644 --- a/src/g_heretic/a_hereticmisc.cpp +++ b/src/g_heretic/a_hereticmisc.cpp @@ -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++) diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index 0b7615c14..f1e660ed8 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -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; diff --git a/src/g_heretic/a_knight.cpp b/src/g_heretic/a_knight.cpp index f8f79bb67..9f42a328a 100644 --- a/src/g_heretic/a_knight.cpp +++ b/src/g_heretic/a_knight.cpp @@ -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; } diff --git a/src/g_hexen/a_heresiarch.cpp b/src/g_hexen/a_heresiarch.cpp index 624c029c6..87a3d17ae 100644 --- a/src/g_hexen/a_heresiarch.cpp +++ b/src/g_hexen/a_heresiarch.cpp @@ -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)); diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index c18e529d8..dbb50445f 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -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; } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 4ff38795a..db588efba 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -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); diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 6460397b0..d2258eb53 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -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; diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 0b4dd023b..b0e5ad5d1 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -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; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 96fe0dad1..4b665bf53 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -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: diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 4470d6fa1..eeab02133 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -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; diff --git a/src/p_things.cpp b/src/p_things.cpp index ed8338d51..35560af6c 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -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 diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index e332ff77b..49b4779eb 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -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: diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index f39ba447a..5ca8bbdb9 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -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(gravity, 0, FRACUNIT*10); + self->Gravity = clamp(gravity, 0., 10.); return 0; } diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 1325dcc42..e8c83fe40 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -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; } //==========================================================================