- 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 &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<DEarthquake> 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;
}
}
}

View file

@ -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 ();

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)
{
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);
}
}
}