Skip to content

Commit

Permalink
handle negative StageTokens for not-EventMode
Browse files Browse the repository at this point in the history
As the inline comment states:  This is somewhat hackish, but it serves to counteract Lua Hacks.

If ScreenGameplay was reloaded by a "gimmick" chart, then it is very possible that the Engine's concept of remaining stages will be incongruent with the Theme's.  Add stages back, Engine-side, if necessary.

This prevents us from returning to ScreenSelectMusic with negative stage tokens (engine-side) which manifests as an empty MusicWheel.
  • Loading branch information
quietly-turning committed Nov 24, 2015
1 parent cfe4e9a commit 6998088
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Scripts/SL-Branches.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ Branch.AfterProfileSave = function()
SL.Global.Stages.Remaining = SL.Global.Stages.Remaining + StagesToAddBack
end


-- This is somewhat hackish, but it serves to counteract Lua Hacks.
-- If ScreenGameplay was reloaded by a "gimmick" chart, then it is
-- very possible that the Engine's concept of remaining stages will
-- be incongruent with the Theme's. Add stages back, engine-side, if necessary.
if GAMESTATE:GetNumStagesLeft(GAMESTATE:GetMasterPlayerNumber()) < SL.Global.Stages.Remaining then
StagesToAddBack = math.abs(SL.Global.Stages.Remaining - GAMESTATE:GetNumStagesLeft(GAMESTATE:GetMasterPlayerNumber()))
local Players = GAMESTATE:GetHumanPlayers()
for pn in ivalues(Players) do
for i=1, StagesToAddBack do
GAMESTATE:AddStageToPlayer(pn)
end
end
end

-- If we don't allow players to fail out of a set early
if ThemePrefs.Get("AllowFailingOutOfSet") == false then

Expand Down

0 comments on commit 6998088

Please sign in to comment.