From 07e2b61e6b2f2e1fd57456c90a776398abe3604f Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Sat, 20 Feb 2010 10:47:50 +0000 Subject: reduce crashes caused by errors in songs in challenge and medley mode git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2112 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSing.pas | 74 +++++++++++++++++++++++++++++++-------- Game/Code/Screens/UScreenSong.pas | 14 ++++---- 2 files changed, 67 insertions(+), 21 deletions(-) (limited to 'Game/Code/Screens') diff --git a/Game/Code/Screens/UScreenSing.pas b/Game/Code/Screens/UScreenSing.pas index 034eba5f..d2f1a1a4 100644 --- a/Game/Code/Screens/UScreenSing.pas +++ b/Game/Code/Screens/UScreenSing.pas @@ -102,6 +102,7 @@ type //OnSentenceChange (for Golden Notes) procedure onSentenceChange(S: Cardinal); + procedure SongError(); procedure LoadNextSong; procedure UpdateMedleyStats(medley_end: boolean); procedure DrawMedleyCountdown(); @@ -723,10 +724,63 @@ begin Log.LogStatus('End', 'onShow'); end; +procedure TScreenSing.SongError; +var + I, K, len: integer; + +begin + if (not ScreenSong.PartyMedley) and (ScreenSong.Mode <> smMedley) then + begin + //Error Loading Song -> Go back to Song Screen and Show some Error Message + + FadeTo(@ScreenSong); + ScreenSong.SongIndex := -1; + ScreenSong.onShow; + if (ScreenSong.Mode = smParty) then + ScreenSong.SelectRandomSong; + + ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); + Exit; + end else if (ScreenSong.PartyMedley or (ScreenSong.Mode = smMedley)) then + begin + if (PlaylistMedley.CurrentMedleySong skip actual Medley Song an go on if possible + len := Length(PlaylistMedley.Song); + for I := PlaylistMedley.CurrentMedleySong-1 to len - 1 do + PlaylistMedley.Song[I] := PlaylistMedley.Song[I+1]; + + SetLength(PlaylistMedley.Song, Len-1); + Dec(PlaylistMedley.NumMedleySongs); + LoadNextSong; + Exit; + end else + begin + if (PlaylistMedley.NumMedleySongs=1) then + begin + //Error Loading Song in Medley Mode -> Go back to Song Screen and Show some Error Message + FadeTo(@ScreenSong); + ScreenSong.SongIndex := -1; + ScreenSong.onShow; + ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); + Exit; + end else + begin + //Error Loading Song in Medley Mode -> Finish actual round + len := Length(PlaylistMedley.Song); + SetLength(PlaylistMedley.Song, len-1); + Dec(PlaylistMedley.NumMedleySongs); + Finish; + Exit; + end; + end; + end; +end; + procedure TScreenSing.LoadNextSong; var - P: integer; - numNotes: integer; + P: integer; + numNotes: integer; begin // load notes ResetSingTemp; @@ -741,23 +795,15 @@ begin try if not LoadSong(CatSongs.Song[CatSongs.Selected].Path + CatSongs.Song[CatSongs.Selected].FileName, SONG_LOAD_COMPLETE) then begin - //Error Loading Song -> Go back to Song Screen and Show some Error Message - FadeTo(@ScreenSong); - //Select New Song in Party Mode - if ScreenSong.Mode = smParty then - ScreenSong.SelectRandomSong; - ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); + SongError; Exit; end; + except - //Error Loading Song -> Go back to Song Screen and Show some Error Message - FadeTo(@ScreenSong); - //Select New Song in Party Mode - if ScreenSong.Mode = smParty then - ScreenSong.SelectRandomSong; - ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); + SongError; Exit; end; + AktSong.Path := CatSongs.Song[CatSongs.Selected].Path; // AktSong.GAP := AktSong.GAP + 40 {4096 = 100ms for buffer} + 20 {microphone} + 60000 / AktSong.BPM[0].BPM / 2; // temporary until UMain will be fixed diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 28541ac0..51e6a1ee 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -18,8 +18,8 @@ type TScreenSong = class(TMenu) private - SkippedSongs: array of integer; //for M2-MOD - ChooseableSongs: integer; //for M2-MOD + SkippedSongs: array of integer; + ChooseableSongs: integer; public TextArtist: integer; @@ -1814,9 +1814,6 @@ begin PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); end; - if (CatSongs.VisibleSongs - PartySessionM2.GetSongsPlayed(CatSongs.CatNumShow))=0 then - PartySessionM2.ResetSongsPlayed(CatSongs.CatNumShow); - RandomSongChallenge; //SkipTo(Random(CatSongs.VisibleSongs - PartySessionM2.GetSongsPlayed(CatSongs.CatNumShow))); @@ -1855,7 +1852,6 @@ begin SongIndex := -1; SetScroll; - UpdateLCD; end; SetJoker; @@ -1867,6 +1863,9 @@ var VisArr: array of integer; I: integer; begin + if (CatSongs.VisibleSongs - PartySessionM2.GetSongsPlayed(CatSongs.CatNumShow))=0 then + PartySessionM2.ResetSongsPlayed(CatSongs.CatNumShow); + SetLength(VisArr, 0); for I := 0 to Length(CatSongs.Song) - 1 do begin @@ -1910,7 +1909,8 @@ begin Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); //When hide then Stop Music (For Party Mode Popup on Exit) - if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) and (Music <> nil) then + if (Display.NextScreen <> @ScreenSong) and (Display.NextScreen <> @ScreenSing) and + (Display.NextScreen <> @ScreenSingModi) and (Music <> nil) then Music.Stop; end; -- cgit v1.2.3