- 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.
This commit is contained in:
MajorCooke 2015-02-20 08:26:45 -06:00
parent d6e4a7a081
commit 49d9482363
3 changed files with 34 additions and 31 deletions

View file

@ -153,15 +153,14 @@ void DEarthquake::Tick ()
// //
//========================================================================== //==========================================================================
int DEarthquake::StaticGetQuakeIntensities(AActor *victim, int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop)
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)) if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP))
{ {
return 0; return 0;
} }
x = y = z = relx = rely = relz = 0; qprop.intensityX = qprop.intensityY = qprop.intensityZ = qprop.relIntensityX = qprop.relIntensityY = qprop.relIntensityZ = 0;
TThinkerIterator<DEarthquake> iterator(STAT_EARTHQUAKE); TThinkerIterator<DEarthquake> iterator(STAT_EARTHQUAKE);
DEarthquake *quake; DEarthquake *quake;
@ -178,24 +177,24 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim,
++count; ++count;
if (quake->m_Flags & QF_RELATIVE) if (quake->m_Flags & QF_RELATIVE)
{ {
relx = MAX(relx, quake->m_IntensityX); qprop.relIntensityX = MAX(qprop.relIntensityX, quake->m_IntensityX);
rely = MAX(rely, quake->m_IntensityY); qprop.relIntensityY = MAX(qprop.relIntensityY, quake->m_IntensityY);
relz = MAX(relz, quake->m_IntensityZ); qprop.relIntensityZ = MAX(qprop.relIntensityZ, quake->m_IntensityZ);
} }
else else
{ {
x = MAX(x, quake->m_IntensityX); qprop.intensityX = MAX(qprop.intensityX, quake->m_IntensityX);
y = MAX(y, quake->m_IntensityY); qprop.intensityY = MAX(qprop.intensityY, quake->m_IntensityY);
z = MAX(z, quake->m_IntensityZ); qprop.intensityZ = MAX(qprop.intensityZ, quake->m_IntensityZ);
} }
if (quake->m_Flags & QF_SCALEDOWN) if (quake->m_Flags & QF_SCALEDOWN)
{ {
scaleDownStart = quake->m_CountdownStart; qprop.scaleDownStart = quake->m_CountdownStart;
scaleDown = (double)quake->m_Countdown; qprop.scaleDown = quake->m_Countdown;
} }
else else
{ {
scaleDownStart = scaleDown = 0.0; qprop.scaleDownStart = qprop.scaleDown = 0.0;
} }
} }
} }

View file

@ -138,6 +138,12 @@ enum
QF_SCALEUP = 1 << 2, QF_SCALEUP = 1 << 2,
}; };
struct quakeInfo
{
int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ;
double scaleDown, scaleDownStart;
};
class DEarthquake : public DThinker class DEarthquake : public DThinker
{ {
DECLARE_CLASS (DEarthquake, DThinker) DECLARE_CLASS (DEarthquake, DThinker)
@ -155,7 +161,7 @@ public:
int m_Flags; int m_Flags;
int m_IntensityX, m_IntensityY, m_IntensityZ; 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: private:
DEarthquake (); DEarthquake ();

View file

@ -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) if (intensity == 0)
{ {
return 0; return 0;
@ -902,41 +903,38 @@ void R_SetupFrame (AActor *actor)
if (!paused) if (!paused)
{ {
int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; quakeInfo quake;
double scaleDown, scaleDownStart; if (DEarthquake::StaticGetQuakeIntensities(camera, quake) > 0)
if (DEarthquake::StaticGetQuakeIntensities(camera,
intensityX, intensityY, intensityZ,
relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart) > 0)
{ {
double quakefactor = r_quakeintensity; double quakefactor = r_quakeintensity;
if (relIntensityX != 0) if (quake.relIntensityX != 0)
{ {
int ang = (camera->angle) >> ANGLETOFINESHIFT; 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); viewx += FixedMul(finecosine[ang], power);
viewy += FixedMul(finesine[ang], power); viewy += FixedMul(finesine[ang], power);
} }
if (relIntensityY != 0) if (quake.relIntensityY != 0)
{ {
int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; 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); viewx += FixedMul(finecosine[ang], power);
viewy += FixedMul(finesine[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 // FIXME: Relative Z is not relative
intensityZ = MAX(intensityZ, relIntensityZ); quake.intensityZ = MAX(quake.intensityZ, quake.relIntensityZ);
if (intensityZ != 0) if (quake.intensityZ != 0)
{ {
viewz += QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart); viewz += QuakePower(quakefactor, quake.intensityZ, quake);
} }
} }
} }