From d7e651c2ec916316892d02cb859d4ab731a4201a Mon Sep 17 00:00:00 2001 From: Jack Wallace Date: Sun, 8 Apr 2018 03:26:18 +0100 Subject: [PATCH] Fixed GadgetModifierEW and modifier QuantumHiggsNet. --- DarkSpace/GadgetModifierEW.cpp | 15 ++++++--------- DarkSpace/GadgetModifierEW.h | 2 +- DarkSpaceClient/DarkSpaceClient.cpp | 22 +++++++++++----------- Gadgets/Gadgets.vcxproj | 1 + Gadgets/Gadgets.vcxproj.filters | 3 +++ Gadgets/QuantumHiggsNet.h | 10 +++++----- Gadgets/ReduceWeaponRange.h | 12 ++++++------ 7 files changed, 33 insertions(+), 32 deletions(-) diff --git a/DarkSpace/GadgetModifierEW.cpp b/DarkSpace/GadgetModifierEW.cpp index be309b19..f0af3f66 100644 --- a/DarkSpace/GadgetModifierEW.cpp +++ b/DarkSpace/GadgetModifierEW.cpp @@ -47,9 +47,6 @@ bool GadgetModifierEW::usable(Noun * pTarget, bool shift) const if (((NounShip *)pTarget)->isDestroyed()) return false; - if (!isEnemy(pTargetShip)) - return false; - if (pTargetShip->testFlags( NounShip::FLAG_CLOAKED|NounShip::FLAG_IN_SAFE_ZONE ) ) return false; @@ -73,8 +70,8 @@ void GadgetModifierEW::use(dword when, Noun * pTarget, bool shift) if (active() && m_Target.valid()) { NounGadget::use(when, pTarget, shift); - for (std::vector::iterator iList = modifiersType().begin(); iList != modifiersType().end(); ++iList) - m_Target->addModifier(*iList, strength()); + for (int i=0; isubtractModifier(m_Modifiers[i], strength()); if (isServer()) { @@ -90,8 +87,8 @@ void GadgetModifierEW::use(dword when, Noun * pTarget, bool shift) { m_Target = pShipTarget; - for (std::vector::iterator iList = modifiersType().begin(); iList != modifiersType().end(); ++iList) - m_Target->subtractModifier(*iList, strength()); + for (int i = 0; iaddModifier(m_Modifiers[i], strength()); if (isServer()) { @@ -136,8 +133,8 @@ void GadgetModifierEW::release() if(m_Target.valid()) { - for (std::vector::iterator iList = modifiersType().begin(); iList != modifiersType().end(); ++iList) - m_Target->addModifier(*iList, strength()); + for (int i = 0; isubtractModifier(m_Modifiers[i], strength()); m_Target = NULL; } diff --git a/DarkSpace/GadgetModifierEW.h b/DarkSpace/GadgetModifierEW.h index 4c6bad37..c7c23643 100644 --- a/DarkSpace/GadgetModifierEW.h +++ b/DarkSpace/GadgetModifierEW.h @@ -26,13 +26,13 @@ class DLL GadgetModifierEW : public NounGadget virtual int energyCost() const = 0; virtual float strength() const = 0; virtual float range() const = 0; - virtual std::vector modifiersType() const = 0; void release(); bool active() const; protected: NounShip::wRef m_Target; + Array< ModifierType > m_Modifiers; }; inline bool GadgetModifierEW::active() const { diff --git a/DarkSpaceClient/DarkSpaceClient.cpp b/DarkSpaceClient/DarkSpaceClient.cpp index 59262fed..3a9712e2 100644 --- a/DarkSpaceClient/DarkSpaceClient.cpp +++ b/DarkSpaceClient/DarkSpaceClient.cpp @@ -114,24 +114,24 @@ void CClientApp::RunGame( InterfaceContext * pInterface ) #ifndef _DEBUG __try { #endif - float fSVolume, fMVolume = 0.0f; - HWND hwnd = NULL; + GameDocument * pDoc = WidgetCast(pInterface->document()); + float fSVolume = 0.0f; + int fMVolume = 0; + HWND hWnd = NULL; // THE MAIN GAME LOOP while (pInterface->render()) - { - if (hwnd == NULL ) - hwnd = GetForegroundWindow(); + { + // get our main window + hWnd = FindWindowA("DarkSpace",NULL); - // track any changes in volume so we can return back to them - if (fSVolume != pInterface->audio()->volume() && pInterface->audio()->volume() > 0.0) + // update our saved values if the volume is changed + if (pInterface->audio()->volume() > 0) fSVolume = pInterface->audio()->volume(); - - GameDocument * pDoc = WidgetCast(pInterface->document()); - if (fMVolume != pDoc->jukeBox()->volume() && pDoc->jukeBox()->volume() > 0.0) + if (pDoc->jukeBox()->volume() > 0) fMVolume = pDoc->jukeBox()->volume(); // mute our device if we lose focus - if (hwnd != GetForegroundWindow()) + if (hWnd != GetForegroundWindow()) { pInterface->audio()->setVolume(0.0f); pDoc->jukeBox()->setVolume(0.0f); diff --git a/Gadgets/Gadgets.vcxproj b/Gadgets/Gadgets.vcxproj index 1c7153e7..d51a228a 100644 --- a/Gadgets/Gadgets.vcxproj +++ b/Gadgets/Gadgets.vcxproj @@ -369,6 +369,7 @@ + diff --git a/Gadgets/Gadgets.vcxproj.filters b/Gadgets/Gadgets.vcxproj.filters index b0cff939..43bb4ab3 100644 --- a/Gadgets/Gadgets.vcxproj.filters +++ b/Gadgets/Gadgets.vcxproj.filters @@ -752,6 +752,9 @@ Header Files + + Header Files + diff --git a/Gadgets/QuantumHiggsNet.h b/Gadgets/QuantumHiggsNet.h index e92bfa40..b200be48 100644 --- a/Gadgets/QuantumHiggsNet.h +++ b/Gadgets/QuantumHiggsNet.h @@ -9,6 +9,10 @@ class QuantumHiggsNet : public GadgetModifierEW { public: DECLARE_WIDGET_CLASS(); + QuantumHiggsNet() + { + m_Modifiers.push(MT_MASS); + } Type type() const { return SPECIAL_OFFENSIVE; @@ -39,7 +43,7 @@ class QuantumHiggsNet : public GadgetModifierEW } float strength() const { - return 100.0f; + return -100.0f; } float range() const { @@ -49,10 +53,6 @@ class QuantumHiggsNet : public GadgetModifierEW { return TICKS_PER_SECOND * 30; } - ModifierType modifierType() const - { - return MT_MASS; - } }; //---------------------------------------------------------------------------- diff --git a/Gadgets/ReduceWeaponRange.h b/Gadgets/ReduceWeaponRange.h index 7c2badbb..a966030f 100644 --- a/Gadgets/ReduceWeaponRange.h +++ b/Gadgets/ReduceWeaponRange.h @@ -9,6 +9,11 @@ class ReduceWeaponRange : public GadgetModifierEW { public: DECLARE_WIDGET_CLASS(); + ReduceWeaponRange() + { + m_Modifiers.push(MT_WEAPON_RANGE); + m_Modifiers.push(MT_BEAM_RANGE); + } Type type() const { return SPECIAL_OFFENSIVE; @@ -39,7 +44,7 @@ class ReduceWeaponRange : public GadgetModifierEW } float strength() const { - return 10.0f; + return -10.0f; } float range() const { @@ -49,11 +54,6 @@ class ReduceWeaponRange : public GadgetModifierEW { return TICKS_PER_SECOND * 30; } - std::vector modifiersType() const - { - std::vector modifiers = { MT_WEAPON_RANGE, MT_BEAM_RANGE }; - return modifiers; - } }; //----------------------------------------------------------------------------