From 0370f77dfe4e33652f16d97134edd8d219c35c08 Mon Sep 17 00:00:00 2001 From: MtH Date: Tue, 30 Mar 2021 18:43:07 +0200 Subject: [PATCH] fixed bugs where game would crash if pressing R during cutscene or state transition --- source/PlayState.hx | 73 +++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index dd5610578..505d9267e 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -941,7 +941,7 @@ class PlayState extends MusicBeatState }); } - var startTimer:FlxTimer; + var startTimer:FlxTimer = new FlxTimer(); var perfectMode:Bool = false; function startCountdown():Void @@ -958,7 +958,7 @@ class PlayState extends MusicBeatState var swagCounter:Int = 0; - startTimer = new FlxTimer().start(Conductor.crochet / 1000, function(tmr:FlxTimer) + startTimer.start(Conductor.crochet / 1000, function(tmr:FlxTimer) { // this just based on beatHit stuff but compact if (swagCounter % gfSpeed == 0) @@ -1563,42 +1563,45 @@ class PlayState extends MusicBeatState } // better streaming of shit - // RESET = Quick Game Over Screen - if (controls.RESET) + if (!inCutscene && !_exiting) { - health = 0; - trace("RESET = True"); - } + // RESET = Quick Game Over Screen + if (controls.RESET) + { + health = 0; + trace("RESET = True"); + } - #if CAN_CHEAT // brandon's a pussy - if (controls.CHEAT) - { - health += 1; - trace("User is cheating!"); - } - #end - - if (health <= 0 && !practiceMode) - { - boyfriend.stunned = true; - - persistentUpdate = false; - persistentDraw = false; - paused = true; - - vocals.stop(); - FlxG.sound.music.stop(); - - deathCounter += 1; - - openSubState(new GameOverSubstate(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); - - // FlxG.switchState(new GameOverState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); - - #if discord_rpc - // Game Over doesn't get his own variable because it's only used here - DiscordClient.changePresence("Game Over - " + detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC); + #if CAN_CHEAT // brandon's a pussy + if (controls.CHEAT) + { + health += 1; + trace("User is cheating!"); + } #end + + if (health <= 0 && !practiceMode) + { + boyfriend.stunned = true; + + persistentUpdate = false; + persistentDraw = false; + paused = true; + + vocals.stop(); + FlxG.sound.music.stop(); + + deathCounter += 1; + + openSubState(new GameOverSubstate(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); + + // FlxG.switchState(new GameOverState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); + + #if discord_rpc + // Game Over doesn't get his own variable because it's only used here + DiscordClient.changePresence("Game Over - " + detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC); + #end + } } if (unspawnNotes[0] != null)