From 49d948236327f2799136806e5cee5373daa1bcf9 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 08:26:45 -0600 Subject: [PATCH] - 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); } } }