Skip to content

Commit

Permalink
fix crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
EyeDaleHim committed Mar 19, 2023
1 parent fa1db72 commit 42bc3af
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 53 deletions.
96 changes: 49 additions & 47 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ class PlayState extends MusicBeatState

if (playMode == STORY && !_finishedCutscene)
{
trace(DialogueBox.songs.contains(Song.currentSong.song.formatToReadable()));
if (DialogueBox.songs.contains(Song.currentSong.song.formatToReadable()))
{
player.active = false;
Expand Down Expand Up @@ -1016,62 +1015,65 @@ class PlayState extends MusicBeatState
{score: gameInfo.score, misses: gameInfo.misses, accuracy: gameInfo.accuracy});

_finishedCutscene = false;
if (PlayState.playMode != CHARTING)
try
{
switch (PlayState.playMode)
if (PlayState.playMode != CHARTING)
{
case STORY:
CurrentGame.weekScores.push({score: gameInfo.score, misses: gameInfo.misses, accuracy: gameInfo.accuracy});
PlayState.storyPlaylist.shift();
trace('playmode');
switch (PlayState.playMode)
{
case STORY:
trace('story');
CurrentGame.weekScores.push({score: gameInfo.score, misses: gameInfo.misses, accuracy: gameInfo.accuracy});
PlayState.storyPlaylist.shift();

if (PlayState.storyPlaylist.length > 0)
{
Transitions.transIn = false;
Transitions.transOut = false;
if (PlayState.storyPlaylist.length > 0)
{
trace('existing playlist');
Transitions.transIn = false;
Transitions.transOut = false;

if (CacheManager.cachedAssets[AUDIO].exists(Paths.instPath(Song.currentSong.song)))
CacheManager.cachedAssets[AUDIO].get(Paths.instPath(Song.currentSong.song)).special = false;
if (CacheManager.cachedAssets[AUDIO].exists(Paths.vocalsPath(Song.currentSong.song)))
CacheManager.cachedAssets[AUDIO].get(Paths.vocalsPath(Song.currentSong.song)).special = false;
if (CacheManager.cachedAssets[AUDIO].exists(Paths.instPath(Song.currentSong.song)))
CacheManager.cachedAssets[AUDIO].get(Paths.instPath(Song.currentSong.song)).special = false;
if (CacheManager.cachedAssets[AUDIO].exists(Paths.vocalsPath(Song.currentSong.song)))
CacheManager.cachedAssets[AUDIO].get(Paths.vocalsPath(Song.currentSong.song)).special = false;

Song.loadSong(PlayState.storyPlaylist[0].formatToReadable(), songDiff);
MusicBeatState.switchState(new PlayState());
}
else
{
ScoreContainer.setWeek(Paths.currentLibrary, PlayState.songDiff, CurrentGame.weekScores);
trace('set week');
CurrentGame.weekScores = [];
trace('killed week');
MusicBeatState.switchState(new states.menus.StoryMenuState());
}
case FREEPLAY:
MusicBeatState.switchState(new states.menus.FreeplayState());
default:
MusicBeatState.switchState(new states.menus.MainMenuState());
}
Song.loadSong(PlayState.storyPlaylist[0].formatToReadable(), songDiff);
MusicBeatState.switchState(new PlayState());
}
else
{
ScoreContainer.setWeek(Paths.currentLibrary, PlayState.songDiff, CurrentGame.weekScores);
CurrentGame.weekScores = [];

if (PlayState.playMode == FREEPLAY)
{
FlxG.sound.playMusic(Paths.music('freakyMenu'));
Conductor.changeBPM(102);
FlxG.sound.playMusic(Paths.music('freakyMenu'));
Conductor.changeBPM(102);

MusicBeatState.switchState(new states.menus.StoryMenuState());
}
case FREEPLAY:
MusicBeatState.switchState(new states.menus.FreeplayState());
default:
MusicBeatState.switchState(new states.menus.MainMenuState());
}

if (PlayState.playMode == FREEPLAY)
{
FlxG.sound.playMusic(Paths.music('freakyMenu'));
Conductor.changeBPM(102);
}
else
{
FlxG.sound.music.volume = 0;
FlxG.sound.music.stop();
}
}
else
{
FlxG.sound.music.volume = 0;
FlxG.sound.music.stop();
{ // i dont have a fucking charting state yet moron
PlayState.playMode = FREEPLAY;
endSong();
}
}
else
{ // i dont have a fucking charting state yet moron
PlayState.playMode = FREEPLAY;
endSong();
}
}

private function getPlaylist()
{
return PlayState.storyPlaylist;
}

override function openSubState(state:FlxSubState)
Expand Down
16 changes: 11 additions & 5 deletions source/states/menus/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ class FreeplayState extends MusicBeatState

// no you dingdong don't judge me
private static var lastSelected:Int = 0;
private static var lastPlayed:String = '';

private var lastPlayed:String = '';

override public function update(elapsed:Float)
{
Expand All @@ -154,10 +155,13 @@ class FreeplayState extends MusicBeatState
canPress = false;
MusicBeatState.switchState(new MainMenuState());

FlxG.sound.music.fadeOut(0.5, 0.0, function(twn)
if (lastPlayed != '')
{
FlxG.sound.playMusic(Paths.music('freakyMenu'));
});
FlxG.sound.music.fadeOut(0.5, 0.0, function(twn)
{
FlxG.sound.playMusic(Paths.music('freakyMenu'));
});
}
}
else if (controls.getKey('ACCEPT', JUST_PRESSED))
{
Expand Down Expand Up @@ -352,7 +356,9 @@ class FreeplayState extends MusicBeatState

changeSelection();
}
} class SongMetadata
}

class SongMetadata
{
public var name:String;
public var weekName:String;
Expand Down
6 changes: 6 additions & 0 deletions source/states/menus/StoryMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ class StoryMenuState extends MusicBeatState
{
CacheManager.freeMemory(BITMAP, true);

if (FlxG.sound.music != null &&!FlxG.sound.music.playing)
{
FlxG.sound.music.play();
FlxG.sound.music.volume = 0.6;
}

backgroundBox = new FlxSprite(0, 56).makeGraphic(FlxG.width, 386, 0xFFF9CF51);

for (i in 0...3)
Expand Down
2 changes: 1 addition & 1 deletion source/weeks/ScoreContainer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class ScoreContainer
}
else
{
weekScores.set(week, []);
weekScores[week].set(diff, {addedScore: 0, averageAccuracy: 0.00, addedMisses: 0});
return setWeek(week, diff, results);
}
}
Expand Down

0 comments on commit 42bc3af

Please sign in to comment.