diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-09-06 09:46:24 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-09-06 09:46:24 +0000 |
commit | f5ea14a97fe530ff7670645c3c6e5051b961d2a7 (patch) | |
tree | f0b317dd82226b7b027f447302c886ffc6e00f63 | |
parent | baa8e6ee782197a75038d0ab39c53f231bb66ba7 (diff) | |
download | usdx-f5ea14a97fe530ff7670645c3c6e5051b961d2a7.tar.gz usdx-f5ea14a97fe530ff7670645c3c6e5051b961d2a7.tar.xz usdx-f5ea14a97fe530ff7670645c3c6e5051b961d2a7.zip |
- fixed out-of-range error. In NewNote() CurrentPlayer.Note[CurrentPlayer.HighNote] was accessed although CurrentPlayer.Note is empty (always the case at the beginning of a song).
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1346 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r-- | src/base/UMain.pas | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/base/UMain.pas b/src/base/UMain.pas index 5dacd5f8..08b9cc4a 100644 --- a/src/base/UMain.pas +++ b/src/base/UMain.pas @@ -769,7 +769,7 @@ var PlayerIndex: integer; CurrentSound: TCaptureBuffer; CurrentPlayer: PPlayer; - LastPlayerNote: PPLayerNote; + LastPlayerNote: PPlayerNote; Line: PLine; SentenceIndex: integer; SentenceMin: integer; @@ -823,7 +823,12 @@ begin begin CurrentPlayer := @Player[PlayerIndex]; CurrentSound := AudioInputProcessor.Sound[PlayerIndex]; - LastPlayerNote := @CurrentPlayer.Note[CurrentPlayer.HighNote]; + + // At the beginning of the song there is no previous note + if (Length(CurrentPlayer.Note) > 0) then + LastPlayerNote := @CurrentPlayer.Note[CurrentPlayer.HighNote] + else + LastPlayerNote := nil; // analyze buffer CurrentSound.AnalyzeBuffer; @@ -902,8 +907,10 @@ begin begin // we will add a new note NewNote := true; - // if last has the same tone + + // if previous note (if any) was the same, extend prrevious note if ((CurrentPlayer.LengthNote > 0) and + (LastPlayerNote <> nil) and (LastPlayerNote.Tone = CurrentSound.Tone) and ((LastPlayerNote.Start + LastPlayerNote.Length) = LyricsState.CurrentBeatD)) then begin @@ -939,7 +946,8 @@ begin else begin // extend note length - Inc(LastPlayerNote.Length); + if (LastPlayerNote <> nil) then + Inc(LastPlayerNote.Length); end; // check for perfect note and then lit the star (on Draw) |