From a4f5846c7c36b4eedb7c71f3938d36d594471134 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 20 Mar 2016 01:25:47 +0100 Subject: [PATCH] - replaced all uses of P_ThrustMobj with the already implemented AActor::Thrust method and deleted this function. - for quakes, making a distinction between circular and elliptic thrust is pointless, so the checks were removed and both paths consolidated. The elliptic code will do exactly the same for circles and there isn't even a performance difference. --- src/fragglescript/t_func.cpp | 7 +++---- src/g_heretic/a_hereticmisc.cpp | 2 +- src/g_hexen/a_bishop.cpp | 6 +++--- src/g_hexen/a_clericholy.cpp | 2 +- src/g_hexen/a_fighteraxe.cpp | 6 +++--- src/g_hexen/a_fighterhammer.cpp | 4 +--- src/g_hexen/a_fighterplayer.cpp | 10 ++++------ src/g_hexen/a_hexenspecialdecs.cpp | 8 ++++---- src/g_hexen/a_magelightning.cpp | 13 ++++++------- src/g_shared/a_quake.cpp | 11 ++--------- src/g_strife/a_strifeweapons.cpp | 2 +- src/p_lnspec.cpp | 2 +- src/p_local.h | 6 ------ src/p_mobj.cpp | 24 +++++------------------- 14 files changed, 35 insertions(+), 68 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 3fd222170..a7182cb87 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -1254,10 +1254,9 @@ void FParser::SF_PushThing(void) AActor * mo = actorvalue(t_argv[0]); if(!mo) return; - angle_t angle = (angle_t)FixedToAngle(fixedvalue(t_argv[1])); - fixed_t force = fixedvalue(t_argv[2]); - - P_ThrustMobj(mo, angle, force); + DAngle angle = floatvalue(t_argv[1]); + double force = floatvalue(t_argv[2]); + mo->Thrust(angle, force); } } diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp index 81643faf3..b60cfdb69 100644 --- a/src/g_heretic/a_hereticmisc.cpp +++ b/src/g_heretic/a_hereticmisc.cpp @@ -120,7 +120,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MakePod) return 0; } mo->SetState (mo->FindState("Grow")); - P_ThrustMobj (mo, pr_makepod()<<24, (fixed_t)(4.5*FRACUNIT)); + mo->Thrust(pr_makepod() * (360. / 256), 4.5); S_Sound (mo, CHAN_BODY, self->AttackSound, 1, ATTN_IDLE); self->special1++; // Increment generated pod count mo->master = self; // Link the generator to the pod diff --git a/src/g_hexen/a_bishop.cpp b/src/g_hexen/a_bishop.cpp index 95b668b82..319c2b53d 100644 --- a/src/g_hexen/a_bishop.cpp +++ b/src/g_hexen/a_bishop.cpp @@ -118,15 +118,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopDoBlur) self->special1 = (pr_doblur() & 3) + 3; // Random number of blurs if (pr_doblur() < 120) { - P_ThrustMobj (self, self->_f_angle() + ANG90, 11*FRACUNIT); + self->Thrust(self->Angles.Yaw + 90, 11); } else if (pr_doblur() > 125) { - P_ThrustMobj (self, self->_f_angle() - ANG90, 11*FRACUNIT); + self->Thrust(self->Angles.Yaw - 90, 11); } else { // Thrust forward - P_ThrustMobj (self, self->_f_angle(), 11*FRACUNIT); + self->Thrust(11); } S_Sound (self, CHAN_BODY, "BishopBlur", 1, ATTN_NORM); return 0; diff --git a/src/g_hexen/a_clericholy.cpp b/src/g_hexen/a_clericholy.cpp index 6e6dccd97..5d972dbfc 100644 --- a/src/g_hexen/a_clericholy.cpp +++ b/src/g_hexen/a_clericholy.cpp @@ -161,7 +161,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack2) } mo->_f_SetZ(self->_f_Z()); mo->Angles.Yaw = self->Angles.Yaw + 67.5 - 45.*j; - P_ThrustMobj(mo, mo->_f_angle(), mo->_f_speed()); + mo->Thrust(); mo->target = self->target; mo->args[0] = 10; // initial turn value mo->args[1] = 0; // initial look angle diff --git a/src/g_hexen/a_fighteraxe.cpp b/src/g_hexen/a_fighteraxe.cpp index 7fb047846..c83726b44 100644 --- a/src/g_hexen/a_fighteraxe.cpp +++ b/src/g_hexen/a_fighteraxe.cpp @@ -200,7 +200,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack) PARAM_ACTION_PROLOGUE; DAngle angle; - fixed_t power; + int power; int damage; DAngle slope; int i; @@ -223,7 +223,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack) if (player->ReadyWeapon->Ammo1->Amount > 0) { damage <<= 1; - power = 6*FRACUNIT; + power = 6; pufftype = PClass::FindActor ("AxePuffGlow"); useMana = 1; } @@ -245,7 +245,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack) { if (t.linetarget->flags3&MF3_ISMONSTER || t.linetarget->player) { - P_ThrustMobj(t.linetarget, t.angleFromSource, power); + t.linetarget->Thrust(t.angleFromSource, power); } AdjustPlayerAngle(pmo, &t); useMana++; diff --git a/src/g_hexen/a_fighterhammer.cpp b/src/g_hexen/a_fighterhammer.cpp index 3cf375712..c33737bfd 100644 --- a/src/g_hexen/a_fighterhammer.cpp +++ b/src/g_hexen/a_fighterhammer.cpp @@ -29,7 +29,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) DAngle angle; int damage; - fixed_t power; DAngle slope; int i; player_t *player; @@ -43,7 +42,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) AActor *pmo=player->mo; damage = 60+(pr_hammeratk()&63); - power = 10*FRACUNIT; hammertime = PClass::FindActor("HammerPuff"); for (i = 0; i < 16; i++) { @@ -59,7 +57,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) AdjustPlayerAngle(pmo, &t); if (t.linetarget->flags3 & MF3_ISMONSTER || t.linetarget->player) { - P_ThrustMobj(t.linetarget, t.angleFromSource, power); + t.linetarget->Thrust(t.angleFromSource, 10); } pmo->weaponspecial = false; // Don't throw a hammer goto hammerdone; diff --git a/src/g_hexen/a_fighterplayer.cpp b/src/g_hexen/a_fighterplayer.cpp index fcb58ff86..607a9a88a 100644 --- a/src/g_hexen/a_fighterplayer.cpp +++ b/src/g_hexen/a_fighterplayer.cpp @@ -53,7 +53,7 @@ void AdjustPlayerAngle (AActor *pmo, FTranslatedLineTarget *t) // //============================================================================ -static bool TryPunch(APlayerPawn *pmo, DAngle angle, int damage, fixed_t power) +static bool TryPunch(APlayerPawn *pmo, DAngle angle, int damage, int power) { PClassActor *pufftype; FTranslatedLineTarget t; @@ -78,7 +78,7 @@ static bool TryPunch(APlayerPawn *pmo, DAngle angle, int damage, fixed_t power) if (t.linetarget->player != NULL || (t.linetarget->Mass != INT_MAX && (t.linetarget->flags3 & MF3_ISMONSTER))) { - P_ThrustMobj (t.linetarget, t.angleFromSource, power); + t.linetarget->Thrust(t.angleFromSource, power); } AdjustPlayerAngle (pmo, &t); return true; @@ -98,7 +98,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack) PARAM_ACTION_PROLOGUE; int damage; - fixed_t power; int i; player_t *player; @@ -109,11 +108,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack) APlayerPawn *pmo = player->mo; damage = 40+(pr_fpatk()&15); - power = 2*FRACUNIT; for (i = 0; i < 16; i++) { - if (TryPunch(pmo, pmo->Angles.Yaw + i*(45./16), damage, power) || - TryPunch(pmo, pmo->Angles.Yaw - i*(45./16), damage, power)) + if (TryPunch(pmo, pmo->Angles.Yaw + i*(45./16), damage, 2) || + TryPunch(pmo, pmo->Angles.Yaw - i*(45./16), damage, 2)) { // hit something if (pmo->weaponspecial >= 3) { diff --git a/src/g_hexen/a_hexenspecialdecs.cpp b/src/g_hexen/a_hexenspecialdecs.cpp index ea4e77d1b..b24ffd214 100644 --- a/src/g_hexen/a_hexenspecialdecs.cpp +++ b/src/g_hexen/a_hexenspecialdecs.cpp @@ -222,7 +222,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafSpawn) if (mo) { - P_ThrustMobj (mo, self->_f_angle(), (pr_leaf()<<9)+3*FRACUNIT); + mo->Thrust(pr_leaf() / 128. + 3); mo->target = self; mo->special1 = 0; } @@ -263,18 +263,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafCheck) self->SetState (NULL); return 0; } - angle_t ang = self->target ? self->target->_f_angle() : self->_f_angle(); + DAngle ang = self->target ? self->target->Angles.Yaw : self->Angles.Yaw; if (pr_leafcheck() > 64) { if (self->Vel.X == 0 && self->Vel.Y == 0) { - P_ThrustMobj (self, ang, (pr_leafcheck()<<9)+FRACUNIT); + self->Thrust(ang, pr_leafcheck() / 128. + 1); } return 0; } self->SetState (self->SpawnState + 7); self->Vel.Z = pr_leafcheck() / 128. + 1; - P_ThrustMobj (self, ang, (pr_leafcheck()<<9)+2*FRACUNIT); + self->Thrust(ang, pr_leafcheck() / 128. + 2); self->flags |= MF_MISSILE; return 0; } diff --git a/src/g_hexen/a_magelightning.cpp b/src/g_hexen/a_magelightning.cpp index f2050d20e..39f992225 100644 --- a/src/g_hexen/a_magelightning.cpp +++ b/src/g_hexen/a_magelightning.cpp @@ -14,7 +14,7 @@ #include "g_level.h" */ -#define ZAGSPEED FRACUNIT +#define ZAGSPEED 1. static FRandom pr_lightningready ("LightningReady"); static FRandom pr_lightningclip ("LightningClip"); @@ -170,19 +170,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) zigZag = pr_lightningclip(); if((zigZag > 128 && self->special1 < 2) || self->special1 < -2) { - P_ThrustMobj(self, self->_f_angle()+ANG90, ZAGSPEED); + self->Thrust(self->Angles.Yaw + 90, ZAGSPEED); if(cMo) { - P_ThrustMobj(cMo, self->_f_angle()+ANG90, ZAGSPEED); + cMo->Thrust(self->Angles.Yaw + 90, ZAGSPEED); } self->special1++; } else { - P_ThrustMobj(self, self->_f_angle()-ANG90, ZAGSPEED); + self->Thrust(self->Angles.Yaw - 90, ZAGSPEED); if(cMo) { - P_ThrustMobj(cMo, cMo->_f_angle()-ANG90, ZAGSPEED); + cMo->Thrust(self->Angles.Yaw - 90, ZAGSPEED); } self->special1--; } @@ -196,8 +196,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) else { self->Angles.Yaw = self->AngleTo(target); - self->Vel.X = self->Vel.Y = 0; - P_ThrustMobj (self, self->Angles.Yaw, self->_f_speed()>>1); + self->VelFromAngle(self->Speed / 2); } } return 0; diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 02a89bf84..68f62527c 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -141,15 +141,8 @@ void DEarthquake::Tick () } // Thrust player around DAngle an = victim->Angles.Yaw + pr_quake(); - if (m_IntensityX == m_IntensityY) - { // Thrust in a circle - P_ThrustMobj (victim, an, m_IntensityX/2); - } - else - { // Thrust in an ellipse - victim->Vel.X += FIXED2DBL(m_IntensityX) * an.Cos() * 0.5; - victim->Vel.Y += FIXED2DBL(m_IntensityY) * an.Sin() * 0.5; - } + victim->Vel.X += FIXED2DBL(m_IntensityX) * an.Cos() * 0.5; + victim->Vel.Y += FIXED2DBL(m_IntensityY) * an.Sin() * 0.5; } } } diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index 9febf1e35..5159ac2d1 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -530,7 +530,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMauler2) } P_SpawnPlayerMissile (self, PClass::FindActor("MaulerTorpedo")); P_DamageMobj (self, self, NULL, 20, self->DamageType); - P_ThrustMobj (self, self->_f_angle() + ANGLE_180, 0x7D000); + self->Thrust(self->Angles.Yaw+180., 7.8125); return 0; } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 8c59eec78..0b4dd023b 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -3215,7 +3215,7 @@ FUNC(LS_ForceField) if (it != NULL) { P_DamageMobj (it, NULL, NULL, 16, NAME_None); - P_ThrustMobj (it, it->_f_angle() + ANGLE_180, 0x7D000); + it->Thrust(it->Angles.Yaw + 180, 7.8125); } return true; } diff --git a/src/p_local.h b/src/p_local.h index 9eada6863..5f8d8244d 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -127,12 +127,6 @@ void P_PredictionLerpReset(); APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags=0); -void P_ThrustMobj (AActor *mo, angle_t angle, fixed_t move); -inline void P_ThrustMobj(AActor *mo, DAngle angle, fixed_t move) -{ - P_ThrustMobj(mo, FLOAT2ANGLE(angle.Degrees), move); -} - int P_FaceMobj (AActor *source, AActor *target, DAngle *delta); bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool precise = false, bool usecurspeed=false); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 2ad651073..b38765067 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1621,20 +1621,6 @@ bool AActor::FloorBounceMissile (secplane_t &plane) return false; } -//---------------------------------------------------------------------------- -// -// PROC P_ThrustMobj -// -//---------------------------------------------------------------------------- - -void P_ThrustMobj (AActor *mo, angle_t _angle, fixed_t _move) -{ - DAngle angle = ANGLE2DBL(_angle); - double move = FIXED2DBL(_move); - - mo->Vel += angle.ToVector(move); -} - //---------------------------------------------------------------------------- // // FUNC P_FaceMobj @@ -1785,7 +1771,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) player_t *player; fixed_t xmove, ymove; const secplane_t * walkplane; - static const int windTab[3] = {2048*5, 2048*10, 2048*25}; + static const double windTab[3] = { 5 / 32., 10 / 32., 25 / 32. }; int steps, step, totalsteps; fixed_t startx, starty; fixed_t oldfloorz = mo->floorz; @@ -1800,16 +1786,16 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) switch (special) { case 40: case 41: case 42: // Wind_East - P_ThrustMobj (mo, 0, windTab[special-40]); + mo->Thrust(0., windTab[special-40]); break; case 43: case 44: case 45: // Wind_North - P_ThrustMobj (mo, ANG90, windTab[special-43]); + mo->Thrust(90., windTab[special-43]); break; case 46: case 47: case 48: // Wind_South - P_ThrustMobj (mo, ANG270, windTab[special-46]); + mo->Thrust(270., windTab[special-46]); break; case 49: case 50: case 51: // Wind_West - P_ThrustMobj (mo, ANG180, windTab[special-49]); + mo->Thrust(180., windTab[special-49]); break; } }