Skip to content

Commit

Permalink
Manual voting: don't restart timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Regynate committed Oct 12, 2023
1 parent 7413ce0 commit 185a5e8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
44 changes: 31 additions & 13 deletions ChaosMod/Components/TwitchVoting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void TwitchVoting::RestartVoting()
}
}

void TwitchVoting::EndVotingRound()
void TwitchVoting::EndVotingRound(bool resetTimer = true)
{
if (!m_pChosenEffectIdentifier)
{
Expand Down Expand Up @@ -206,7 +206,11 @@ void TwitchVoting::EndVotingRound()
{
GetComponent<EffectDispatcher>()->DispatchEffect(*m_pChosenEffectIdentifier);
}
GetComponent<EffectDispatcher>()->ResetTimer();

if (resetTimer)
{
GetComponent<EffectDispatcher>()->ResetTimer();
}

if (MetaModifiers::m_ucAdditionalEffectsToDispatch > 0)
{
Expand Down Expand Up @@ -428,21 +432,33 @@ void TwitchVoting::OnRun()
MetaModifiers::m_sCurrentVotingMode = "";
}

if (GetComponent<EffectDispatcher>()->GetRemainingTimerTime() <= 1 && !m_bHasReceivedResult)
if (!m_bEnableManualVoting)
{
// Get vote result 1 second before effect is supposed to dispatch

if (m_bIsVotingRunning)
if (GetComponent<EffectDispatcher>()->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<EffectDispatcher>()->ShouldDispatchEffectNow())
{
EndVotingRound();
m_bIsVotingRunning = false;

if (!m_bIsVotingRoundDone)
{
EndVotingRound();
}
else
{
GetComponent<EffectDispatcher>()->ResetTimer();
}
}
else if (!m_bIsVotingRunning && m_bReceivedFirstPing
&& (m_iTwitchSecsBeforeVoting == 0
Expand All @@ -465,6 +481,11 @@ void TwitchVoting::Vote(int option)
return;
}

if (m_bIsVotingRoundDone)
{
return;
}

if (option != 3)
{
m_pChosenEffectIdentifier = std::make_unique<EffectIdentifier>(m_rgEffectChoices[option]->m_EffectIdentifier);
Expand All @@ -476,10 +497,7 @@ void TwitchVoting::Vote(int option)
}

m_rgEffectChoices[option]->m_iChanceVotes = 1;

EndVotingRound();
StartNewVotingRound();
GetComponent<EffectDispatcher>()->ResetTimer();
EndVotingRound(false);
}

_NODISCARD bool TwitchVoting::IsEnabled() const
Expand Down
2 changes: 1 addition & 1 deletion ChaosMod/Components/TwitchVoting.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TwitchVoting : public Component

void RestartVoting();

void EndVotingRound();
void EndVotingRound(bool);
void StartNewVotingRound();
void DisplayVotes();

Expand Down

0 comments on commit 185a5e8

Please sign in to comment.