From 185a5e829fcd086d23535091085d9d262ccbefb0 Mon Sep 17 00:00:00 2001 From: Reguas <64607261+Reguas@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:13:27 +0300 Subject: [PATCH] Manual voting: don't restart timer --- ChaosMod/Components/TwitchVoting.cpp | 44 ++++++++++++++++++++-------- ChaosMod/Components/TwitchVoting.h | 2 +- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/ChaosMod/Components/TwitchVoting.cpp b/ChaosMod/Components/TwitchVoting.cpp index 5627501ba..77ac0760b 100644 --- a/ChaosMod/Components/TwitchVoting.cpp +++ b/ChaosMod/Components/TwitchVoting.cpp @@ -173,7 +173,7 @@ void TwitchVoting::RestartVoting() } } -void TwitchVoting::EndVotingRound() +void TwitchVoting::EndVotingRound(bool resetTimer = true) { if (!m_pChosenEffectIdentifier) { @@ -206,7 +206,11 @@ void TwitchVoting::EndVotingRound() { GetComponent()->DispatchEffect(*m_pChosenEffectIdentifier); } - GetComponent()->ResetTimer(); + + if (resetTimer) + { + GetComponent()->ResetTimer(); + } if (MetaModifiers::m_ucAdditionalEffectsToDispatch > 0) { @@ -428,21 +432,33 @@ void TwitchVoting::OnRun() MetaModifiers::m_sCurrentVotingMode = ""; } - if (GetComponent()->GetRemainingTimerTime() <= 1 && !m_bHasReceivedResult) + if (!m_bEnableManualVoting) { - // Get vote result 1 second before effect is supposed to dispatch - - if (m_bIsVotingRunning) + if (GetComponent()->GetRemainingTimerTime() <= 1 && !m_bHasReceivedResult) { - m_bIsVotingRunning = false; + // Get vote result 1 second before effect is supposed to dispatch + + if (m_bIsVotingRunning) + { + m_bIsVotingRunning = false; - SendToPipe("getvoteresult"); + SendToPipe("getvoteresult"); + } } } if (GetComponent()->ShouldDispatchEffectNow()) { - EndVotingRound(); + m_bIsVotingRunning = false; + + if (!m_bIsVotingRoundDone) + { + EndVotingRound(); + } + else + { + GetComponent()->ResetTimer(); + } } else if (!m_bIsVotingRunning && m_bReceivedFirstPing && (m_iTwitchSecsBeforeVoting == 0 @@ -465,6 +481,11 @@ void TwitchVoting::Vote(int option) return; } + if (m_bIsVotingRoundDone) + { + return; + } + if (option != 3) { m_pChosenEffectIdentifier = std::make_unique(m_rgEffectChoices[option]->m_EffectIdentifier); @@ -476,10 +497,7 @@ void TwitchVoting::Vote(int option) } m_rgEffectChoices[option]->m_iChanceVotes = 1; - - EndVotingRound(); - StartNewVotingRound(); - GetComponent()->ResetTimer(); + EndVotingRound(false); } _NODISCARD bool TwitchVoting::IsEnabled() const diff --git a/ChaosMod/Components/TwitchVoting.h b/ChaosMod/Components/TwitchVoting.h index bffab580c..f0d0a08f8 100644 --- a/ChaosMod/Components/TwitchVoting.h +++ b/ChaosMod/Components/TwitchVoting.h @@ -77,7 +77,7 @@ class TwitchVoting : public Component void RestartVoting(); - void EndVotingRound(); + void EndVotingRound(bool); void StartNewVotingRound(); void DisplayVotes();