From 045ab9fd5b3f1012698aff929cbe73f3e6837cb8 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 19 Feb 2015 21:42:32 -0600 Subject: [PATCH 1/8] Initial groundwork for QF_SCALEDOWN. --- src/g_shared/a_quake.cpp | 17 ++++++++++++++++- src/g_shared/a_sharedglobal.h | 8 ++++++-- src/r_utility.cpp | 25 ++++++++++++++++--------- wadsrc/static/actors/constants.txt | 4 +++- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 044d51643..368d65c53 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -46,6 +46,8 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in m_IntensityY = intensityY; m_IntensityZ = intensityZ; m_Countdown = duration; + m_Countup = 0; + m_ScaleDownStart = duration; m_Flags = flags; } @@ -131,6 +133,7 @@ void DEarthquake::Tick () } } } + ++m_Countup; if (--m_Countdown == 0) { if (S_IsActorPlayingSomething(m_Spot, CHAN_BODY, m_QuakeSFX)) @@ -151,7 +154,7 @@ void DEarthquake::Tick () //========================================================================== int DEarthquake::StaticGetQuakeIntensities(AActor *victim, - int &x, int &y, int &z, int &relx, int &rely, int &relz) + int &x, int &y, int &z, int &relx, int &rely, int &relz, int &scaleDown, int &scaleDownStart, int &scaleUp) { if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) { @@ -185,6 +188,18 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, y = MAX(y, quake->m_IntensityY); z = MAX(z, quake->m_IntensityZ); } + scaleDownStart = scaleDown = scaleUp = 1; + if (quake->m_Flags & QF_SCALEDOWN) + { + scaleDown = quake->m_Countdown; + } + else + { + scaleDownStart = 0; + scaleDown = 0; + } + if (quake->m_Flags & QF_SCALEUP) + scaleUp = quake->m_Countup; } } } diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index e153f7070..025582323 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -133,7 +133,9 @@ protected: enum { - QF_RELATIVE = 1, + QF_RELATIVE = 1, + QF_SCALEDOWN = 1 << 1, + QF_SCALEUP = 1 << 2, }; class DEarthquake : public DThinker @@ -147,12 +149,14 @@ public: void Tick (); TObjPtr m_Spot; fixed_t m_TremorRadius, m_DamageRadius; + int m_ScaleDownStart; int m_Countdown; + int m_Countup; FSoundID m_QuakeSFX; int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz); + static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, int &scaleDown, int &scaleDownStart, int &scaleUp); private: DEarthquake (); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index a65c90d93..006ce8b3f 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -770,16 +770,23 @@ bool R_GetViewInterpolationStatus() // //========================================================================== -static fixed_t QuakePower(fixed_t factor, int intensity) +static fixed_t QuakePower(fixed_t factor, int intensity, int scaleDown, int scaleDownStart, int scaleUp) { + //if (!scaledown) scaledown = 1; + //if (!scaleup) scaleup = 1; + //double sd = (scaledown / ((!scaledownstart) ? 1 : scaledownstart)); if (intensity == 0) { return 0; } - else + else if (!scaleDownStart) { return factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); } + else + { + return (factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)) * ((scaleDown / scaleDownStart) >> 3)); + } } //========================================================================== @@ -892,40 +899,40 @@ void R_SetupFrame (AActor *actor) if (!paused) { - int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; + int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp; if (DEarthquake::StaticGetQuakeIntensities(camera, intensityX, intensityY, intensityZ, - relIntensityX, relIntensityY, relIntensityZ) > 0) + relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp) > 0) { fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity); if (relIntensityX != 0) { int ang = (camera->angle) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityX); + fixed_t power = QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart, scaleUp); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (relIntensityY != 0) { int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityY); + fixed_t power = QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart, scaleUp); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (intensityX != 0) { - viewx += QuakePower(quakefactor, intensityX); + viewx += QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp); } if (intensityY != 0) { - viewy += QuakePower(quakefactor, intensityY); + viewy += QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp); } // FIXME: Relative Z is not relative intensityZ = MAX(intensityZ, relIntensityZ); if (intensityZ != 0) { - viewz += QuakePower(quakefactor, intensityZ); + viewz += QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp); } } } diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 3df42e0f8..19845b91d 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -461,7 +461,9 @@ enum // Flags for A_QuakeEx enum { - QF_RELATIVE = 1, + QF_RELATIVE = 1, + QF_SCALEDOWN = 1 << 1, + QF_SCALEUP = 1 << 2, }; // This is only here to provide one global variable for testing. From 0948b95e081d472ceca6aa5db022a3e89c2788f4 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 19 Feb 2015 23:19:24 -0600 Subject: [PATCH 2/8] - Changed QuakePower to take doubles on everything but intensity. This lets the camera shake until it truly reaches 0 as the limitations of integers were actually cutting it short. --- src/g_shared/a_quake.cpp | 10 +++++----- src/g_shared/a_sharedglobal.h | 2 +- src/r_utility.cpp | 26 +++++++++++++------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 368d65c53..d8e7a13a0 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -154,7 +154,7 @@ void DEarthquake::Tick () //========================================================================== int DEarthquake::StaticGetQuakeIntensities(AActor *victim, - int &x, int &y, int &z, int &relx, int &rely, int &relz, int &scaleDown, int &scaleDownStart, int &scaleUp) + int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart, double &scaleUp) { if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) { @@ -191,15 +191,15 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, scaleDownStart = scaleDown = scaleUp = 1; if (quake->m_Flags & QF_SCALEDOWN) { - scaleDown = quake->m_Countdown; + scaleDown = (double)quake->m_Countdown; } else { - scaleDownStart = 0; - scaleDown = 0; + scaleDownStart = 0.0; + scaleDown = 0.0; } if (quake->m_Flags & QF_SCALEUP) - scaleUp = quake->m_Countup; + scaleUp = (double)quake->m_Countup; } } } diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 025582323..3a8a2c011 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -156,7 +156,7 @@ public: int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, int &scaleDown, int &scaleDownStart, int &scaleUp); + static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart, double &scaleUp); private: DEarthquake (); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 006ce8b3f..bd3cd40e6 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -770,22 +770,20 @@ bool R_GetViewInterpolationStatus() // //========================================================================== -static fixed_t QuakePower(fixed_t factor, int intensity, int scaleDown, int scaleDownStart, int scaleUp) +static double QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart, double scaleUp) { - //if (!scaledown) scaledown = 1; - //if (!scaleup) scaleup = 1; - //double sd = (scaledown / ((!scaledownstart) ? 1 : scaledownstart)); + double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); if (intensity == 0) { return 0; } else if (!scaleDownStart) { - return factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); + return factor * ss; } else { - return (factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)) * ((scaleDown / scaleDownStart) >> 3)); + return ((factor * ss) * ((scaleDown / scaleDownStart) / 256.0f)); } } @@ -899,40 +897,42 @@ void R_SetupFrame (AActor *actor) if (!paused) { - int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp; + int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; + double scaleDown, scaleDownStart, scaleUp; + //double sdown = (double)scaleDown; double sdownstart = (double)scaleDownStart; if (DEarthquake::StaticGetQuakeIntensities(camera, intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp) > 0) { - fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity); + double quakefactor = r_quakeintensity; if (relIntensityX != 0) { int ang = (camera->angle) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart, scaleUp); + fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart, scaleUp)); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (relIntensityY != 0) { int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart, scaleUp); + fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart, scaleUp)); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (intensityX != 0) { - viewx += QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp); + viewx += FLOAT2FIXED(QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp)); } if (intensityY != 0) { - viewy += QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp); + viewy += FLOAT2FIXED(QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp)); } // FIXME: Relative Z is not relative intensityZ = MAX(intensityZ, relIntensityZ); if (intensityZ != 0) { - viewz += QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp); + viewz += FLOAT2FIXED(QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp)); } } } From 9c5d90e4cbee1c10e3168938fc591862ffe12f86 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 01:33:30 -0600 Subject: [PATCH 3/8] - Removed QF_SCALEUP until I can figure out a proper way to implement it. --- src/g_shared/a_quake.cpp | 13 ++++--------- src/g_shared/a_sharedglobal.h | 6 +++--- src/r_utility.cpp | 33 +++++++++++++++++++-------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index d8e7a13a0..1f13ffd61 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -45,9 +45,8 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in m_IntensityX = intensityX; m_IntensityY = intensityY; m_IntensityZ = intensityZ; + m_CountdownStart = (double)duration; m_Countdown = duration; - m_Countup = 0; - m_ScaleDownStart = duration; m_Flags = flags; } @@ -133,7 +132,6 @@ void DEarthquake::Tick () } } } - ++m_Countup; if (--m_Countdown == 0) { if (S_IsActorPlayingSomething(m_Spot, CHAN_BODY, m_QuakeSFX)) @@ -154,7 +152,7 @@ void DEarthquake::Tick () //========================================================================== int DEarthquake::StaticGetQuakeIntensities(AActor *victim, - int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart, double &scaleUp) + int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart) { if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) { @@ -188,18 +186,15 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, y = MAX(y, quake->m_IntensityY); z = MAX(z, quake->m_IntensityZ); } - scaleDownStart = scaleDown = scaleUp = 1; if (quake->m_Flags & QF_SCALEDOWN) { + scaleDownStart = quake->m_CountdownStart; scaleDown = (double)quake->m_Countdown; } else { - scaleDownStart = 0.0; - scaleDown = 0.0; + scaleDownStart = scaleDown = 0.0; } - if (quake->m_Flags & QF_SCALEUP) - scaleUp = (double)quake->m_Countup; } } } diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 3a8a2c011..f45005856 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -149,14 +149,14 @@ public: void Tick (); TObjPtr m_Spot; fixed_t m_TremorRadius, m_DamageRadius; - int m_ScaleDownStart; int m_Countdown; - int m_Countup; + double m_CountdownStart; + double m_Countup; FSoundID m_QuakeSFX; int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart, double &scaleUp); + static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart); private: DEarthquake (); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index bd3cd40e6..ca602a745 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -770,21 +770,26 @@ bool R_GetViewInterpolationStatus() // //========================================================================== -static double QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart, double scaleUp) +static double QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart) { - double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); + if (intensity == 0) { return 0; } - else if (!scaleDownStart) - { - return factor * ss; - } else { - return ((factor * ss) * ((scaleDown / scaleDownStart) / 256.0f)); + double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); + if (scaleDownStart == 0) + { + return factor * ss; + } + else + { + return ((factor * ss) * ((scaleDown / scaleDownStart))); + } } + } //========================================================================== @@ -898,41 +903,41 @@ void R_SetupFrame (AActor *actor) if (!paused) { int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; - double scaleDown, scaleDownStart, scaleUp; + double scaleDown, scaleDownStart; //double sdown = (double)scaleDown; double sdownstart = (double)scaleDownStart; if (DEarthquake::StaticGetQuakeIntensities(camera, intensityX, intensityY, intensityZ, - relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp) > 0) + relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart) > 0) { double quakefactor = r_quakeintensity; if (relIntensityX != 0) { int ang = (camera->angle) >> ANGLETOFINESHIFT; - fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart, scaleUp)); + fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart)); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (relIntensityY != 0) { int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart, scaleUp)); + fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart)); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (intensityX != 0) { - viewx += FLOAT2FIXED(QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp)); + viewx += FLOAT2FIXED(QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart)); } if (intensityY != 0) { - viewy += FLOAT2FIXED(QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp)); + viewy += FLOAT2FIXED(QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart)); } // FIXME: Relative Z is not relative intensityZ = MAX(intensityZ, relIntensityZ); if (intensityZ != 0) { - viewz += FLOAT2FIXED(QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp)); + viewz += FLOAT2FIXED(QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart)); } } } From 2939194ae34f81e3d1f1abe6bac3eed1f2b8e47d Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 01:36:53 -0600 Subject: [PATCH 4/8] - Forgot this tiny little one. --- src/g_shared/a_sharedglobal.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index f45005856..270f3102a 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -151,7 +151,6 @@ public: fixed_t m_TremorRadius, m_DamageRadius; int m_Countdown; double m_CountdownStart; - double m_Countup; FSoundID m_QuakeSFX; int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; From 3bf24204d838d87bc7f96a907c872a4a5871eea7 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 01:41:59 -0600 Subject: [PATCH 5/8] - Ensure save games don't break. --- src/g_shared/a_quake.cpp | 2 ++ src/version.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 1f13ffd61..8fe060cd7 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -68,6 +68,8 @@ void DEarthquake::Serialize (FArchive &arc) m_IntensityZ = 0; m_Flags = 0; } + if (SaveVersion < 4520) + m_CountdownStart = 0; else { arc << m_IntensityY << m_IntensityZ << m_Flags; diff --git a/src/version.h b/src/version.h index 2be4787ee..794bdcec8 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4519 +#define SAVEVER 4520 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) From d6e4a7a0816daad6366c403122470244fe52dd74 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 07:36:37 -0600 Subject: [PATCH 6/8] - Changed QuakePower back to fixed_t and just had it return FLOAT2FIXED instead. --- src/r_utility.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/r_utility.cpp b/src/r_utility.cpp index ca602a745..585d6e573 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -770,7 +770,7 @@ bool R_GetViewInterpolationStatus() // //========================================================================== -static double QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart) +static fixed_t QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart) { if (intensity == 0) @@ -782,11 +782,11 @@ static double QuakePower(double factor, int intensity, double scaleDown, double double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); if (scaleDownStart == 0) { - return factor * ss; + return FLOAT2FIXED(factor * ss); } else { - return ((factor * ss) * ((scaleDown / scaleDownStart))); + return FLOAT2FIXED(((factor * ss) * ((scaleDown / scaleDownStart)))); } } @@ -904,7 +904,6 @@ void R_SetupFrame (AActor *actor) { int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; double scaleDown, scaleDownStart; - //double sdown = (double)scaleDown; double sdownstart = (double)scaleDownStart; if (DEarthquake::StaticGetQuakeIntensities(camera, intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart) > 0) @@ -914,30 +913,30 @@ void R_SetupFrame (AActor *actor) if (relIntensityX != 0) { int ang = (camera->angle) >> ANGLETOFINESHIFT; - fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart)); + fixed_t power = QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (relIntensityY != 0) { int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart)); + fixed_t power = QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (intensityX != 0) { - viewx += FLOAT2FIXED(QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart)); + viewx += QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart); } if (intensityY != 0) { - viewy += FLOAT2FIXED(QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart)); + viewy += QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart); } // FIXME: Relative Z is not relative intensityZ = MAX(intensityZ, relIntensityZ); if (intensityZ != 0) { - viewz += FLOAT2FIXED(QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart)); + viewz += QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart); } } } From 49d948236327f2799136806e5cee5373daa1bcf9 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 08:26:45 -0600 Subject: [PATCH 7/8] - Cleaned out of the code and converted it to taking a struct instead. - This will make it much easier on me to add future changes. Big thanks to Graf for the idea. --- src/g_shared/a_quake.cpp | 23 +++++++++++------------ src/g_shared/a_sharedglobal.h | 8 +++++++- src/r_utility.cpp | 34 ++++++++++++++++------------------ 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 8fe060cd7..c7290830b 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -153,15 +153,14 @@ void DEarthquake::Tick () // //========================================================================== -int DEarthquake::StaticGetQuakeIntensities(AActor *victim, - int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart) +int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop) { if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) { return 0; } - x = y = z = relx = rely = relz = 0; + qprop.intensityX = qprop.intensityY = qprop.intensityZ = qprop.relIntensityX = qprop.relIntensityY = qprop.relIntensityZ = 0; TThinkerIterator iterator(STAT_EARTHQUAKE); DEarthquake *quake; @@ -178,24 +177,24 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, ++count; if (quake->m_Flags & QF_RELATIVE) { - relx = MAX(relx, quake->m_IntensityX); - rely = MAX(rely, quake->m_IntensityY); - relz = MAX(relz, quake->m_IntensityZ); + qprop.relIntensityX = MAX(qprop.relIntensityX, quake->m_IntensityX); + qprop.relIntensityY = MAX(qprop.relIntensityY, quake->m_IntensityY); + qprop.relIntensityZ = MAX(qprop.relIntensityZ, quake->m_IntensityZ); } else { - x = MAX(x, quake->m_IntensityX); - y = MAX(y, quake->m_IntensityY); - z = MAX(z, quake->m_IntensityZ); + qprop.intensityX = MAX(qprop.intensityX, quake->m_IntensityX); + qprop.intensityY = MAX(qprop.intensityY, quake->m_IntensityY); + qprop.intensityZ = MAX(qprop.intensityZ, quake->m_IntensityZ); } if (quake->m_Flags & QF_SCALEDOWN) { - scaleDownStart = quake->m_CountdownStart; - scaleDown = (double)quake->m_Countdown; + qprop.scaleDownStart = quake->m_CountdownStart; + qprop.scaleDown = quake->m_Countdown; } else { - scaleDownStart = scaleDown = 0.0; + qprop.scaleDownStart = qprop.scaleDown = 0.0; } } } diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 270f3102a..9a6f3925d 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -138,6 +138,12 @@ enum QF_SCALEUP = 1 << 2, }; +struct quakeInfo +{ + int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; + double scaleDown, scaleDownStart; +}; + class DEarthquake : public DThinker { DECLARE_CLASS (DEarthquake, DThinker) @@ -155,7 +161,7 @@ public: int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart); + static int StaticGetQuakeIntensities(AActor *viewer, quakeInfo &a); private: DEarthquake (); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 585d6e573..d27eeaca8 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -770,9 +770,10 @@ bool R_GetViewInterpolationStatus() // //========================================================================== -static fixed_t QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart) +static fixed_t QuakePower(double factor, int intensity, quakeInfo quake) { - + double scaleDownStart = quake.scaleDownStart; + double scaleDown = quake.scaleDown; if (intensity == 0) { return 0; @@ -902,41 +903,38 @@ void R_SetupFrame (AActor *actor) if (!paused) { - int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; - double scaleDown, scaleDownStart; - if (DEarthquake::StaticGetQuakeIntensities(camera, - intensityX, intensityY, intensityZ, - relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart) > 0) + quakeInfo quake; + if (DEarthquake::StaticGetQuakeIntensities(camera, quake) > 0) { double quakefactor = r_quakeintensity; - if (relIntensityX != 0) + if (quake.relIntensityX != 0) { int ang = (camera->angle) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart); + fixed_t power = QuakePower(quakefactor, quake.relIntensityX, quake); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } - if (relIntensityY != 0) + if (quake.relIntensityY != 0) { int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart); + fixed_t power = QuakePower(quakefactor, quake.relIntensityY, quake); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } - if (intensityX != 0) + if (quake.intensityX != 0) { - viewx += QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart); + viewx += QuakePower(quakefactor, quake.intensityX, quake); } - if (intensityY != 0) + if (quake.intensityY != 0) { - viewy += QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart); + viewy += QuakePower(quakefactor, quake.intensityY, quake); } // FIXME: Relative Z is not relative - intensityZ = MAX(intensityZ, relIntensityZ); - if (intensityZ != 0) + quake.intensityZ = MAX(quake.intensityZ, quake.relIntensityZ); + if (quake.intensityZ != 0) { - viewz += QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart); + viewz += QuakePower(quakefactor, quake.intensityZ, quake); } } } From 475bc65eba3bd587b34d59e6e981c8336b17ae78 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 08:35:42 -0600 Subject: [PATCH 8/8] - Better safe than sorry, even if it apparently had no effect. --- src/g_shared/a_sharedglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 9a6f3925d..3ae80040e 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -161,7 +161,7 @@ public: int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeIntensities(AActor *viewer, quakeInfo &a); + static int StaticGetQuakeIntensities(AActor *viewer, quakeInfo &qprop); private: DEarthquake ();