From 284fd3e20f73103d431c88a60d26731954f702e7 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 19 Feb 2015 16:30:00 -0600 Subject: [PATCH 01/14] - Fixed: relz was never initialized. - This could cause problems in places like the GZDoom renderer in the odd circumstance, causing the camera to become stuck in the floor or ceiling until the quake expires. --- src/g_shared/a_quake.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 874ecbb51..044d51643 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -158,7 +158,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, return 0; } - x = y = z = relx = rely = 0; + x = y = z = relx = rely = relz = 0; TThinkerIterator iterator(STAT_EARTHQUAKE); DEarthquake *quake; From 51688fe1604eea45bba5d12b164067845769b211 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Fri, 20 Feb 2015 16:20:39 +1300 Subject: [PATCH 02/14] Cleanup Compatflags to make options easier to find --- wadsrc/static/menudef.txt | 72 ++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 58240440d..f84c3ceff 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1276,42 +1276,60 @@ OptionMenu "CompatibilityOptions" { Title "COMPATIBILITY OPTIONS" Option "Compatibility mode", "compatmode", "CompatModes", "", 1 + StaticText " " + StaticText "Actor Behavior",1 + Option "Crushed monsters can be resurrected", "compat_CORPSEGIBS", "YesNo" + Option "Friendly monsters aren't blocked", "compat_NOBLOCKFRIENDS", "YesNo" + Option "Limit Pain Elementals' Lost Souls", "compat_LIMITPAIN", "YesNo" + Option "Monster movement is affected by effects", "compat_MBFMONSTERMOVE", "YesNo" + Option "Monsters cannot cross dropoffs", "compat_CROSSDROPOFF", "YesNo" + Option "Monsters get stuck over dropoffs", "compat_DROPOFF", "YesNo" + Option "Monsters see invisible players", "compat_INVISIBILITY", "YesNo" + Option "No Minotaur floor flames in water", "compat_MINOTAUR", "YesNo" + Option "Spawn item drops on the floor", "compat_NOTOSSDROPS", "YesNo" + + StaticText " " + StaticText "DehackEd Behavior",1 + Option "DEH health settings like Doom2.exe", "compat_DEHHEALTH", "YesNo" + Option "Original A_Mushroom speed in DEH mods", "compat_MUSHROOM", "YesNo" + + StaticText " " + StaticText "Map/Action Behavior",1 + Option "All special lines can block ", "compat_USEBLOCKING", "YesNo" + Option "Allow any bossdeath for level special", "compat_ANYBOSSDEATH", "YesNo" + Option "Disable BOOM door light effect", "compat_NODOORLIGHT", "YesNo" + Option "Find neighboring light like Doom", "compat_LIGHT", "YesNo" Option "Find shortest textures like Doom", "compat_SHORTTEX", "YesNo" Option "Use buggier stair building", "compat_stairs", "YesNo" - Option "Find neighboring light like Doom", "compat_LIGHT", "YesNo" - Option "Limit Pain Elementals' Lost Souls", "compat_LIMITPAIN", "YesNo" - Option "Don't let others hear your pickups", "compat_SILENTPICKUP", "YesNo" + Option "Use Doom's floor motion behavior", "compat_floormove", "YesNo" + + StaticText " " + StaticText "Physics Behavior",1 Option "Actors are infinitely tall", "compat_nopassover", "YesNo" - Option "Enable wall running", "compat_WALLRUN", "YesNo" - Option "Spawn item drops on the floor", "compat_NOTOSSDROPS", "YesNo" - Option "All special lines can block ", "compat_USEBLOCKING", "YesNo" - Option "Disable BOOM door light effect", "compat_NODOORLIGHT", "YesNo" - Option "Raven scrollers use original speed", "compat_RAVENSCROLL", "YesNo" - Option "Use original sound target handling", "compat_SOUNDTARGET", "YesNo" - Option "DEH health settings like Doom2.exe", "compat_DEHHEALTH", "YesNo" - Option "Self ref. sectors don't block shots", "compat_TRACE", "YesNo" - Option "Monsters get stuck over dropoffs", "compat_DROPOFF", "YesNo" - Option "Monsters cannot cross dropoffs", "compat_CROSSDROPOFF", "YesNo" - Option "Monsters see invisible players", "compat_INVISIBILITY", "YesNo" Option "Boom scrollers are additive", "compat_BOOMSCROLL", "YesNo" - Option "Inst. moving floors are not silent", "compat_silentinstantfloors", "YesNo" - Option "Sector sounds use center as source", "compat_SECTORSOUNDS", "YesNo" - Option "Use Doom heights for missile clipping", "compat_MISSILECLIP", "YesNo" - Option "Allow any bossdeath for level special", "compat_ANYBOSSDEATH", "YesNo" - Option "No Minotaur floor flames in water", "compat_MINOTAUR", "YesNo" - Option "Original A_Mushroom speed in DEH mods", "compat_MUSHROOM", "YesNo" - Option "Monster movement is affected by effects", "compat_MBFMONSTERMOVE", "YesNo" - Option "Crushed monsters can be resurrected", "compat_CORPSEGIBS", "YesNo" - Option "Friendly monsters aren't blocked", "compat_NOBLOCKFRIENDS", "YesNo" - Option "Invert sprite sorting", "compat_SPRITESORT", "YesNo" + Option "Cannot travel straight NSEW", "compat_badangles", "YesNo" + Option "Enable wall running", "compat_WALLRUN", "YesNo" + Option "Raven scrollers use original speed", "compat_RAVENSCROLL", "YesNo" + Option "Self ref. sectors don't block shots", "compat_TRACE", "YesNo" Option "Use Doom code for hitscan checks", "compat_HITSCAN", "YesNo" - Option "Cripple sound for silent BFG trick", "compat_soundslots", "YesNo" + Option "Use Doom heights for missile clipping", "compat_MISSILECLIP", "YesNo" + + + StaticText " " + StaticText "Rendering Behavior",1 Option "Draw polyobjects like Hexen", "compat_POLYOBJ", "YesNo" Option "Ignore Y offsets on masked midtextures", "compat_MASKEDMIDTEX", "YesNo" - Option "Cannot travel straight NSEW", "compat_badangles", "YesNo" - Option "Use Doom's floor motion behavior", "compat_floormove", "YesNo" + Option "Invert sprite sorting", "compat_SPRITESORT", "YesNo" + + StaticText " " + StaticText "Sound Behavior",1 + Option "Cripple sound for silent BFG trick", "compat_soundslots", "YesNo" + Option "Don't let others hear your pickups", "compat_SILENTPICKUP", "YesNo" + Option "Inst. moving floors are not silent", "compat_silentinstantfloors", "YesNo" + Option "Sector sounds use center as source", "compat_SECTORSOUNDS", "YesNo" Option "Sounds stop when actor vanishes", "compat_soundcutoff", "YesNo" + Option "Use original sound target handling", "compat_SOUNDTARGET", "YesNo" Class "CompatibilityMenu" } From 045ab9fd5b3f1012698aff929cbe73f3e6837cb8 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 19 Feb 2015 21:42:32 -0600 Subject: [PATCH 03/14] 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 04/14] - 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 05/14] - 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 06/14] - 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 07/14] - 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 08/14] - 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 09/14] - 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 10/14] - 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 (); From 3019f2cc237af2be6c6bee260910cc93130a2608 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Feb 2015 16:50:03 +0100 Subject: [PATCH 11/14] - fixed savegame code for quakes. --- src/g_shared/a_quake.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index c7290830b..38cff2d2d 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -68,12 +68,19 @@ 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; } + if (SaveVersion < 4520) + { + m_CountdownStart = 0; + } + else + { + arc << m_CountdownStart; + } + } //========================================================================== From 140a6504424429908557f366921ea8a72564b3ba Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 10:46:37 -0600 Subject: [PATCH 12/14] - Added QF_SCALEUP and QF_MAX. - QF_SCALEUP behaves like QF_SCALEDOWN: it gradually scales the tremors, only going upwards. - QF_SCALEUP and QF_SCALEDOWN can be combined to make an earthquake that gradually smoothes in and out. - QF_MAX can be used to invert this behavior, where it starts at the peak of the amplitude, fades out half way, and then grows back to maximum. --- src/g_shared/a_quake.cpp | 11 +++++++---- src/g_shared/a_sharedglobal.h | 2 ++ src/r_utility.cpp | 24 +++++++++++++++++++++--- wadsrc/static/actors/constants.txt | 1 + 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 38cff2d2d..91d654d02 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -80,7 +80,6 @@ void DEarthquake::Serialize (FArchive &arc) { arc << m_CountdownStart; } - } //========================================================================== @@ -101,7 +100,7 @@ void DEarthquake::Tick () Destroy (); return; } - + if (!S_IsActorPlayingSomething (m_Spot, CHAN_BODY, m_QuakeSFX)) { S_Sound (m_Spot, CHAN_BODY | CHAN_LOOP, m_QuakeSFX, 1, ATTN_NORM); @@ -141,6 +140,7 @@ void DEarthquake::Tick () } } } + if (--m_Countdown == 0) { if (S_IsActorPlayingSomething(m_Spot, CHAN_BODY, m_QuakeSFX)) @@ -166,7 +166,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop) { return 0; } - + qprop.isScalingDown = qprop.isScalingUp = false, qprop.preferMaximum = false; qprop.intensityX = qprop.intensityY = qprop.intensityZ = qprop.relIntensityX = qprop.relIntensityY = qprop.relIntensityZ = 0; TThinkerIterator iterator(STAT_EARTHQUAKE); @@ -194,10 +194,13 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop) qprop.intensityY = MAX(qprop.intensityY, quake->m_IntensityY); qprop.intensityZ = MAX(qprop.intensityZ, quake->m_IntensityZ); } - if (quake->m_Flags & QF_SCALEDOWN) + if (quake->m_Flags) { qprop.scaleDownStart = quake->m_CountdownStart; qprop.scaleDown = quake->m_Countdown; + qprop.isScalingDown = (quake->m_Flags & QF_SCALEDOWN) ? true : false; + qprop.isScalingUp = (quake->m_Flags & QF_SCALEUP) ? true : false; + qprop.preferMaximum = (quake->m_Flags & QF_MAX) ? true : false; } else { diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 3ae80040e..2f34f9f5a 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -136,12 +136,14 @@ enum QF_RELATIVE = 1, QF_SCALEDOWN = 1 << 1, QF_SCALEUP = 1 << 2, + QF_MAX = 1 << 3, }; struct quakeInfo { int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; double scaleDown, scaleDownStart; + bool isScalingDown, isScalingUp, preferMaximum; }; class DEarthquake : public DThinker diff --git a/src/r_utility.cpp b/src/r_utility.cpp index d27eeaca8..42581add5 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -781,13 +781,31 @@ static fixed_t QuakePower(double factor, int intensity, quakeInfo quake) else { double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); - if (scaleDownStart == 0) + + if (quake.isScalingDown || quake.isScalingUp) { - return FLOAT2FIXED(factor * ss); + fixed_t result; + if (scaleDownStart == 0) scaleDownStart = 1; + + if (quake.isScalingDown && quake.isScalingUp) + { + if (quake.preferMaximum) + result = FLOAT2FIXED((factor * ss) * MAX((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart)); + else + result = FLOAT2FIXED((factor * ss) * MIN((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart)); + } + else if (quake.isScalingDown) + result = FLOAT2FIXED((factor * ss) * (scaleDown / scaleDownStart)); + else if (quake.isScalingUp) + result = FLOAT2FIXED((factor * ss) * ((scaleDownStart - scaleDown) / scaleDownStart)); + else + result = FLOAT2FIXED(factor * ss); + + return result; } else { - return FLOAT2FIXED(((factor * ss) * ((scaleDown / scaleDownStart)))); + return FLOAT2FIXED(factor * ss); } } diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 19845b91d..e245c37ef 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -464,6 +464,7 @@ enum QF_RELATIVE = 1, QF_SCALEDOWN = 1 << 1, QF_SCALEUP = 1 << 2, + QF_MAX = 1 << 3, }; // This is only here to provide one global variable for testing. From aa3c3d65461fd846442333026a128af718e0fabf Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 10:55:06 -0600 Subject: [PATCH 13/14] - Fixed: Smoothing in to out reached only half strength. --- src/r_utility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 42581add5..5d5dab2b8 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -792,7 +792,7 @@ static fixed_t QuakePower(double factor, int intensity, quakeInfo quake) if (quake.preferMaximum) result = FLOAT2FIXED((factor * ss) * MAX((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart)); else - result = FLOAT2FIXED((factor * ss) * MIN((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart)); + result = FLOAT2FIXED((factor * ss) * MIN(((scaleDown*2) / scaleDownStart), ((scaleDownStart - scaleDown)*2) / scaleDownStart)); } else if (quake.isScalingDown) result = FLOAT2FIXED((factor * ss) * (scaleDown / scaleDownStart)); From fb9231a38db2025eb77bfd246f36d985cbbccd2e Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 11:06:41 -0600 Subject: [PATCH 14/14] - Added QF_FULLINTENSITY. - When using both scaling flags, by default, the effect only reaches half peak going either way. This forces it to go all the way to the top (or bottom if using QF_MAX) before scaling back to its original height.. --- src/g_shared/a_quake.cpp | 3 ++- src/g_shared/a_sharedglobal.h | 11 ++++++----- src/r_utility.cpp | 6 +++--- wadsrc/static/actors/constants.txt | 1 + 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 91d654d02..5cce4c371 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -166,7 +166,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop) { return 0; } - qprop.isScalingDown = qprop.isScalingUp = false, qprop.preferMaximum = false; + qprop.isScalingDown = qprop.isScalingUp = qprop.preferMaximum = qprop.fullIntensity = false; qprop.intensityX = qprop.intensityY = qprop.intensityZ = qprop.relIntensityX = qprop.relIntensityY = qprop.relIntensityZ = 0; TThinkerIterator iterator(STAT_EARTHQUAKE); @@ -201,6 +201,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop) qprop.isScalingDown = (quake->m_Flags & QF_SCALEDOWN) ? true : false; qprop.isScalingUp = (quake->m_Flags & QF_SCALEUP) ? true : false; qprop.preferMaximum = (quake->m_Flags & QF_MAX) ? true : false; + qprop.fullIntensity = (quake->m_Flags & QF_FULLINTENSITY) ? true : false; } else { diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 2f34f9f5a..00247c224 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -133,17 +133,18 @@ protected: enum { - QF_RELATIVE = 1, - QF_SCALEDOWN = 1 << 1, - QF_SCALEUP = 1 << 2, - QF_MAX = 1 << 3, + QF_RELATIVE = 1, + QF_SCALEDOWN = 1 << 1, + QF_SCALEUP = 1 << 2, + QF_MAX = 1 << 3, + QF_FULLINTENSITY = 1 << 4, }; struct quakeInfo { int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; double scaleDown, scaleDownStart; - bool isScalingDown, isScalingUp, preferMaximum; + bool isScalingDown, isScalingUp, preferMaximum, fullIntensity; }; class DEarthquake : public DThinker diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 5d5dab2b8..ebcff8af5 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -781,7 +781,7 @@ static fixed_t QuakePower(double factor, int intensity, quakeInfo quake) else { double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); - + double mtp = (quake.fullIntensity) ? 2.0 : 1.0; if (quake.isScalingDown || quake.isScalingUp) { fixed_t result; @@ -790,9 +790,9 @@ static fixed_t QuakePower(double factor, int intensity, quakeInfo quake) if (quake.isScalingDown && quake.isScalingUp) { if (quake.preferMaximum) - result = FLOAT2FIXED((factor * ss) * MAX((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart)); + result = FLOAT2FIXED((factor * ss) * MAX(((scaleDown*mtp) / scaleDownStart), ((scaleDownStart - scaleDown)*mtp) / scaleDownStart)); else - result = FLOAT2FIXED((factor * ss) * MIN(((scaleDown*2) / scaleDownStart), ((scaleDownStart - scaleDown)*2) / scaleDownStart)); + result = FLOAT2FIXED((factor * ss) * MIN(((scaleDown*mtp) / scaleDownStart), ((scaleDownStart - scaleDown)*mtp) / scaleDownStart)); } else if (quake.isScalingDown) result = FLOAT2FIXED((factor * ss) * (scaleDown / scaleDownStart)); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index e245c37ef..78149430a 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -465,6 +465,7 @@ enum QF_SCALEDOWN = 1 << 1, QF_SCALEUP = 1 << 2, QF_MAX = 1 << 3, + QF_FULLINTENSITY = 1 << 4, }; // This is only here to provide one global variable for testing.