aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-02-28 20:56:12 +0000
committerwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-02-28 20:56:12 +0000
commit8f2fc12d58f248a7b548c4919c640500c7a4524d (patch)
tree68548fb01c7aab766a61c4fd501fd33ca0253c2b /src
parent10181f2a4db7b9f6a27e6343ac33c69562684623 (diff)
downloadusdx-8f2fc12d58f248a7b548c4919c640500c7a4524d.tar.gz
usdx-8f2fc12d58f248a7b548c4919c640500c7a4524d.tar.xz
usdx-8f2fc12d58f248a7b548c4919c640500c7a4524d.zip
Some cleanup done
moved ScoreFactor to UMusic removed unused field TLines.LyricWidth removed unused field TSong.Category removed some weird and useless code from songloading procedures songloading simplified, commented parts that are difficult to understand some changes to score calculation that assure not more nor less than 10000 Points are gainable. after many tests I could not find any bug in score calculation, at least after these changes. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1610 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src')
-rw-r--r--src/base/UFiles.pas1
-rw-r--r--src/base/UMain.pas43
-rw-r--r--src/base/UMusic.pas11
-rw-r--r--src/base/USong.pas178
-rw-r--r--src/screens/UScreenEditSub.pas13
-rw-r--r--src/screens/UScreenSingModi.pas1
6 files changed, 110 insertions, 137 deletions
diff --git a/src/base/UFiles.pas b/src/base/UFiles.pas
index add81f23..d639c304 100644
--- a/src/base/UFiles.pas
+++ b/src/base/UFiles.pas
@@ -73,7 +73,6 @@ begin
SetLength(Lines[Count].Line, 1);
SetLength(Lines[Count].Line[0].Note, 0);
Lines[Count].Line[0].Lyric := '';
- Lines[Count].Line[0].LyricWidth := 0;
Player[Count].Score := 0;
Player[Count].LengthNote := 0;
Player[Count].HighNote := -1;
diff --git a/src/base/UMain.pas b/src/base/UMain.pas
index 65e55c1d..ededb6e5 100644
--- a/src/base/UMain.pas
+++ b/src/base/UMain.pas
@@ -828,12 +828,8 @@ var
Range: integer;
NoteHit: boolean;
MaxSongPoints: integer; // max. points for the song (without line bonus)
- MaxLinePoints: real; // max. points for the current line
- ScoreFactor: array[TNoteType] of integer;
+ CurNotePoints: real; // Points for the cur. Note (PointsperNote * ScoreFactor[CurNote])
begin
- ScoreFactor[ntFreestyle] := 0;
- ScoreFactor[ntNormal] := 1;
- ScoreFactor[ntGolden] := 2;
// TODO: add duet mode support
// use Lines[LineSetIndex] with LineSetIndex depending on the current player
@@ -924,6 +920,9 @@ begin
begin
// adjust the players tone to the correct one
// TODO: do we need to do this?
+ // Philipp: I think we do, at least when we draw the notes.
+ // Otherwise the notehit thing would be shifted to the
+ // correct unhit note. I think this will look kind of strange.
CurrentSound.Tone := CurrentLineFragment.Tone;
// half size notes patch
@@ -935,17 +934,35 @@ begin
MaxSongPoints := MAX_SONG_SCORE;
// Note: ScoreValue is the sum of all note values of the song
- MaxLinePoints := MaxSongPoints / Lines[0].ScoreValue * ScoreFactor[CurrentLineFragment.NoteType];
-
- // FIXME: is this correct? Why do we add the points for a whole line
- // if just one note is correct?
+ // (MaxSongPoints / ScoreValue) is the points that a player
+ // gets for a hit of one beat of a normal note
+ // CurNotePoints is the amount of points that is meassured
+ // for a hit of the note per full beat
+ CurNotePoints := (MaxSongPoints / Lines[0].ScoreValue) * ScoreFactor[CurrentLineFragment.NoteType];
+
case CurrentLineFragment.NoteType of
- ntNormal: CurrentPlayer.Score := CurrentPlayer.Score + MaxLinePoints;
- ntGolden: CurrentPlayer.ScoreGolden := CurrentPlayer.ScoreGolden + MaxLinePoints;
+ ntNormal: CurrentPlayer.Score := CurrentPlayer.Score + CurNotePoints;
+ ntGolden: CurrentPlayer.ScoreGolden := CurrentPlayer.ScoreGolden + CurNotePoints;
end;
- CurrentPlayer.ScoreInt := Floor(CurrentPlayer.Score / 10) * 10;
- CurrentPlayer.ScoreGoldenInt := Floor(CurrentPlayer.ScoreGolden / 10) * 10;
+ // a problem if we use floor instead of round is that a score of
+ // 10000 points is only possible if the last digit of the total points
+ // for golden and normal notes is 0.
+ // if we use round, the max score is 10000 for most songs
+ // but a score of 10010 is possible if the last digit of the total
+ // points for golden and normal notes is 5
+ // the best solution is to use round for one of these scores
+ // and round the other score in the opposite direction
+ // so we assure that the highest possible score is 10000 in every case.
+ CurrentPlayer.ScoreInt := round(CurrentPlayer.Score / 10) * 10;
+
+ if (CurrentPlayer.ScoreInt < CurrentPlayer.Score) then
+ //normal score is floored so we have to ceil golden notes score
+ CurrentPlayer.ScoreGoldenInt := ceil(CurrentPlayer.ScoreGolden / 10) * 10
+ else
+ //normal score is ceiled so we have to floor golden notes score
+ CurrentPlayer.ScoreGoldenInt := floor(CurrentPlayer.ScoreGolden / 10) * 10;
+
CurrentPlayer.ScoreTotalInt := CurrentPlayer.ScoreInt +
CurrentPlayer.ScoreGoldenInt +
diff --git a/src/base/UMusic.pas b/src/base/UMusic.pas
index 10f789d7..09d73331 100644
--- a/src/base/UMusic.pas
+++ b/src/base/UMusic.pas
@@ -39,8 +39,13 @@ uses
Classes;
type
- TNoteType = (ntFreestyle, ntNormal, ntGolden);
+ TNoteType = (ntFreestyle = 0, ntNormal = 1, ntGolden = 2);
+const
+ //Score Factor
+ ScoreFactor: array[TNoteType] of integer = (0, 1, 2);
+
+type
(**
* TLineFragment represents a fragment of a lyrics line.
* This is a text-fragment (e.g. a syllable) assigned to a note pitch,
@@ -64,7 +69,7 @@ type
TLine = record
Start: integer; // the start beat of this line (<> start beat of the first note of this line)
Lyric: string;
- LyricWidth: real; // @deprecated: width of the line in pixels.
+ //LyricWidth: real; // @deprecated: width of the line in pixels.
// Do not use this as the width is not correct.
// Use TLyricsEngine.GetUpperLine().Width instead.
End_: integer;
@@ -82,7 +87,7 @@ type
*)
TLines = record
Current: integer; // for drawing of current line
- High: integer; // (= High(Line)?)
+ High: integer; // = High(Line)!
Number: integer;
Resolution: integer;
NotesGAP: integer;
diff --git a/src/base/USong.pas b/src/base/USong.pas
index b1458e69..ef0768c5 100644
--- a/src/base/USong.pas
+++ b/src/base/USong.pas
@@ -88,7 +88,7 @@ type
FileName: WideString;
// sorting methods
- Category: array of WideString; // TODO: do we need this?
+ //Category: array of WideString; // TODO: do we need this?
Genre: WideString;
Edition: WideString;
Language: WideString;
@@ -185,6 +185,11 @@ begin
end;
end;
+{function TSong.LoadSong(): boolean;
+begin
+
+end; }
+
//Load TXT Song
function TSong.LoadSong(): boolean;
@@ -213,8 +218,6 @@ begin
MultBPM := 4; // multiply beat-count of note by 4
Mult := 1; // accuracy of measurement of note
- Base[0] := 100; // high number
- Lines[0].ScoreValue := 0;
self.Relative := false;
Rel[0] := 0;
CP := 0;
@@ -255,19 +258,23 @@ begin
SetLength(Lines, 2);
for Count := 0 to High(Lines) do
begin
- SetLength(Lines[Count].Line, 1);
Lines[Count].High := 0;
Lines[Count].Number := 1;
Lines[Count].Current := 0;
Lines[Count].Resolution := self.Resolution;
Lines[Count].NotesGAP := self.NotesGAP;
+ Lines[Count].ScoreValue := 0;
+
+ //Add first line and set some standard values to fields
+ //see procedure NewSentence for further explantation
+ //concerning most of these values
+ SetLength(Lines[Count].Line, 1);
Lines[Count].Line[0].HighNote := -1;
Lines[Count].Line[0].LastLine := false;
+ Lines[Count].Line[0].BaseNote := High(Integer);
+ Lines[Count].Line[0].TotalNotes := 0;
end;
- //TempC := ':';
- //TempC := Text[1]; // read from backup variable, don't use default ':' value
-
while (TempC <> 'E') and (not EOF(SongFile)) do
begin
@@ -327,41 +334,6 @@ begin
self.BPM[High(self.BPM)].BPM := self.BPM[High(self.BPM)].BPM * Mult * MultBPM;
end;
-
- if not Both then
- begin
- Lines[CP].Line[Lines[CP].High].BaseNote := Base[CP];
- Lines[CP].Line[Lines[CP].High].LyricWidth := glTextWidth(Lines[CP].Line[Lines[CP].High].Lyric);
- //Total Notes Patch
- Lines[CP].Line[Lines[CP].High].TotalNotes := 0;
- for I := low(Lines[CP].Line[Lines[CP].High].Note) to high(Lines[CP].Line[Lines[CP].High].Note) do
- begin
- if (Lines[CP].Line[Lines[CP].High].Note[I].NoteType = ntGolden) then
- Lines[CP].Line[Lines[CP].High].TotalNotes := Lines[CP].Line[Lines[CP].High].TotalNotes + Lines[CP].Line[Lines[CP].High].Note[I].Length;
-
- if (Lines[CP].Line[Lines[CP].High].Note[I].NoteType <> ntFreestyle) then
- Lines[CP].Line[Lines[CP].High].TotalNotes := Lines[CP].Line[Lines[CP].High].TotalNotes + Lines[CP].Line[Lines[CP].High].Note[I].Length;
- end;
- //Total Notes Patch End
- end
- else
- begin
- for Count := 0 to High(Lines) do
- begin
- Lines[Count].Line[Lines[Count].High].BaseNote := Base[Count];
- Lines[Count].Line[Lines[Count].High].LyricWidth := glTextWidth(Lines[Count].Line[Lines[Count].High].Lyric);
- //Total Notes Patch
- Lines[Count].Line[Lines[Count].High].TotalNotes := 0;
- for I := low(Lines[Count].Line[Lines[Count].High].Note) to high(Lines[Count].Line[Lines[Count].High].Note) do
- begin
- if (Lines[Count].Line[Lines[Count].High].Note[I].NoteType = ntGolden) then
- Lines[Count].Line[Lines[Count].High].TotalNotes := Lines[Count].Line[Lines[Count].High].TotalNotes + Lines[Count].Line[Lines[Count].High].Note[I].Length;
- if (Lines[Count].Line[Lines[Count].High].Note[I].NoteType <> ntFreestyle) then
- Lines[Count].Line[Lines[Count].High].TotalNotes := Lines[Count].Line[Lines[Count].High].TotalNotes + Lines[Count].Line[Lines[Count].High].Note[I].Length;
- end;
- //Total Notes Patch End
- end;
- end;
ReadLn(SongFile); //Jump to next line in File, otherwise the next Read would catch the linebreak(e.g. #13 #10 on win32)
Read(SongFile, TempC);
@@ -443,7 +415,6 @@ begin
MultBPM := 4; // multiply beat-count of note by 4
Mult := 1; // accuracy of measurement of note
- Base[0] := 100; // high number
Lines[0].ScoreValue := 0;
self.Relative := false;
Rel[0] := 0;
@@ -458,14 +429,21 @@ begin
for Count := 0 to High(Lines) do
begin
- SetLength(Lines[Count].Line, 1);
Lines[Count].High := 0;
- Lines[Count].Number := 1;
- Lines[Count].Current := 0;
- Lines[Count].Resolution := self.Resolution;
- Lines[Count].NotesGAP := self.NotesGAP;
- Lines[Count].Line[0].HighNote := -1;
- Lines[Count].Line[0].LastLine := false;
+ Lines[Count].Number := 1;
+ Lines[Count].Current := 0;
+ Lines[Count].Resolution := self.Resolution;
+ Lines[Count].NotesGAP := self.NotesGAP;
+ Lines[Count].ScoreValue := 0;
+
+ //Add first line and set some standard values to fields
+ //see procedure NewSentence for further explantation
+ //concerning most of these values
+ SetLength(Lines[Count].Line, 1);
+ Lines[Count].Line[0].HighNote := -1;
+ Lines[Count].Line[0].LastLine := false;
+ Lines[Count].Line[0].BaseNote := High(Integer);
+ Lines[Count].Line[0].TotalNotes := 0;
end;
//Try to Parse the Song
@@ -502,42 +480,6 @@ begin
ParseNote(1, NoteType, (Param1+Rel[1]) * Mult, Param2 * Mult, Param3, ParamS);
end;
- if not Both then
- begin
- Lines[CP].Line[Lines[CP].High].BaseNote := Base[CP];
- Lines[CP].Line[Lines[CP].High].LyricWidth := glTextWidth(Lines[CP].Line[Lines[CP].High].Lyric);
- //Total Notes Patch
- Lines[CP].Line[Lines[CP].High].TotalNotes := 0;
- for NoteIndex := 0 to high(Lines[CP].Line[Lines[CP].High].Note) do
- begin
- if (Lines[CP].Line[Lines[CP].High].Note[NoteIndex].NoteType = ntGolden) then
- Lines[CP].Line[Lines[CP].High].TotalNotes := Lines[CP].Line[Lines[CP].High].TotalNotes + Lines[CP].Line[Lines[CP].High].Note[NoteIndex].Length;
-
- if (Lines[CP].Line[Lines[CP].High].Note[NoteIndex].NoteType <> ntFreestyle) then
- Lines[CP].Line[Lines[CP].High].TotalNotes := Lines[CP].Line[Lines[CP].High].TotalNotes + Lines[CP].Line[Lines[CP].High].Note[NoteIndex].Length;
- end;
- //Total Notes Patch End
- end
- else
- begin
- for Count := 0 to High(Lines) do
- begin
- Lines[Count].Line[Lines[Count].High].BaseNote := Base[Count];
- Lines[Count].Line[Lines[Count].High].LyricWidth := glTextWidth(Lines[Count].Line[Lines[Count].High].Lyric);
- //Total Notes Patch
- Lines[Count].Line[Lines[Count].High].TotalNotes := 0;
- for NoteIndex := 0 to high(Lines[Count].Line[Lines[Count].High].Note) do
- begin
- if (Lines[Count].Line[Lines[Count].High].Note[NoteIndex].NoteType = ntGolden) then
- Lines[Count].Line[Lines[Count].High].TotalNotes := Lines[Count].Line[Lines[Count].High].TotalNotes + Lines[Count].Line[Lines[Count].High].Note[NoteIndex].Length;
- if (Lines[Count].Line[Lines[Count].High].Note[NoteIndex].NoteType <> ntFreestyle) then
- Lines[Count].Line[Lines[Count].High].TotalNotes := Lines[Count].Line[Lines[Count].High].TotalNotes + Lines[Count].Line[Lines[Count].High].Note[NoteIndex].Length;
-
- end;
- //Total Notes Patch End
- end;
- end; { end of for loop }
-
end; //J Forloop
//Add Sentence break
@@ -964,17 +906,28 @@ begin
'*': Note[HighNote].NoteType := ntGolden;
end;
- if (Note[HighNote].NoteType = ntGolden) then
- Lines[LineNumber].ScoreValue := Lines[LineNumber].ScoreValue + Note[HighNote].Length;
+ //add this notes value ("notes length" * "notes scorefactor") to the current songs entire value
+ Inc(Lines[LineNumber].ScoreValue, Note[HighNote].Length * ScoreFactor[Note[HighNote].NoteType]);
+
+ //and to the current lines entire value
+ Inc(TotalNotes, Note[HighNote].Length * ScoreFactor[Note[HighNote].NoteType]);
- if (Note[HighNote].NoteType <> ntFreestyle) then
- Lines[LineNumber].ScoreValue := Lines[LineNumber].ScoreValue + Note[HighNote].Length;
Note[HighNote].Tone := NoteP;
- if Note[HighNote].Tone < Base[LineNumber] then
- Base[LineNumber] := Note[HighNote].Tone;
- Note[HighNote].Text := Copy(LyricS, 2, 100);
+ //if a note w/ a deeper pitch then the current basenote is found
+ //we replace the basenote w/ the current notes pitch
+ if Note[HighNote].Tone < BaseNote then
+ BaseNote := Note[HighNote].Tone;
+
+ //delete the space that seperates the notes pitch from its lyrics
+ //it is left in the LyricS string because Read("some ordinal type") will
+ //set the files pointer to the first whitespace character after the
+ //ordinal string. Trim is no solution because it would cut the spaces
+ //that seperate the words of the lyrics, too.
+ Delete(LyricS, 1, 1);
+
+ Note[HighNote].Text := LyricS;
Lyric := Lyric + Note[HighNote].Text;
End_ := Note[HighNote].Start + Note[HighNote].Length;
@@ -989,36 +942,29 @@ var
begin
if (Lines[LineNumberP].Line[Lines[LineNumberP].High].HighNote <> -1) then
- begin //Update old Sentence if it has notes and create a new sentence
- // Update old part
- Lines[LineNumberP].Line[Lines[LineNumberP].High].BaseNote := Base[LineNumberP];
- Lines[LineNumberP].Line[Lines[LineNumberP].High].LyricWidth := glTextWidth(Lines[LineNumberP].Line[Lines[LineNumberP].High].Lyric);
-
- //Total Notes Patch
- Lines[LineNumberP].Line[Lines[LineNumberP].High].TotalNotes := 0;
- for I := low(Lines[LineNumberP].Line[Lines[LineNumberP].High].Note) to high(Lines[LineNumberP].Line[Lines[LineNumberP].High].Note) do
- begin
- if (Lines[LineNumberP].Line[Lines[LineNumberP].High].Note[I].NoteType = ntGolden) then
- Lines[LineNumberP].Line[Lines[LineNumberP].High].TotalNotes := Lines[LineNumberP].Line[Lines[LineNumberP].High].TotalNotes + Lines[LineNumberP].Line[Lines[LineNumberP].High].Note[I].Length;
-
- if (Lines[LineNumberP].Line[Lines[LineNumberP].High].Note[I].NoteType <> ntFreestyle) then
- Lines[LineNumberP].Line[Lines[LineNumberP].High].TotalNotes := Lines[LineNumberP].Line[Lines[LineNumberP].High].TotalNotes + Lines[LineNumberP].Line[Lines[LineNumberP].High].Note[I].Length;
- end;
- //Total Notes Patch End
-
-
- // Update new part
+ begin //create a new line
SetLength(Lines[LineNumberP].Line, Lines[LineNumberP].Number + 1);
- Lines[LineNumberP].High := Lines[LineNumberP].High + 1;
- Lines[LineNumberP].Number := Lines[LineNumberP].Number + 1;
+ Inc(Lines[LineNumberP].High);
+ Inc(Lines[LineNumberP].Number);
end
else
- begin //Use old Sentence if it has no notes
+ begin //use old line if it there were no notes added since last call of NewSentence
Log.LogError('Error loading Song, sentence w/o note found in line ' + InttoStr(FileLineNo) + ': ' + Filename);
end;
Lines[LineNumberP].Line[Lines[LineNumberP].High].HighNote := -1;
+ //set the current lines value to zero
+ //it will be incremented w/ the value of every added note
+ Lines[LineNumberP].Line[Lines[LineNumberP].High].TotalNotes := 0;
+
+ //basenote is the pitch of the deepest note, it is used for note drawing.
+ //if a note with a less value than the current sentences basenote is found,
+ //basenote will be set to this notes pitch. Therefore the initial value of
+ //this field has to be very high.
+ Lines[LineNumberP].Line[Lines[LineNumberP].High].BaseNote := High(Integer);
+
+
if self.Relative then
begin
Lines[LineNumberP].Line[Lines[LineNumberP].High].Start := Param1;
@@ -1028,8 +974,6 @@ begin
Lines[LineNumberP].Line[Lines[LineNumberP].High].Start := Param1;
Lines[LineNumberP].Line[Lines[LineNumberP].High].LastLine := false;
-
- Base[LineNumberP] := 100; // high number
end;
procedure TSong.clear();
diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas
index 07113363..d30781fe 100644
--- a/src/screens/UScreenEditSub.pas
+++ b/src/screens/UScreenEditSub.pas
@@ -876,9 +876,8 @@ begin
NStart := CurrentNote;
Lines[0].Line[CNew].Start := Lines[0].Line[CStart].Note[NStart].Start;
Lines[0].Line[CNew].Lyric := '';
- Lines[0].Line[CNew].LyricWidth := 0;
Lines[0].Line[CNew].End_ := 0;
- Lines[0].Line[CNew].BaseNote := 0; // 0.5.0: we modify it later in this procedure
+ Lines[0].Line[CNew].BaseNote := 0;//High(Integer); // TODO: High (Integer) will causes a memory exception later in this procedure. Weird!
Lines[0].Line[CNew].HighNote := -1;
SetLength(Lines[0].Line[CNew].Note, 0);
@@ -905,6 +904,16 @@ begin
Lines[0].Line[CStart].Note[NStart-1].Length;
SetLength(Lines[0].Line[CStart].Note, Lines[0].Line[CStart].HighNote + 1);
+ //recalculate BaseNote of the divided Sentence
+ with Lines[0].Line[CStart] do
+ begin
+ BaseNote := High(Integer);
+
+ For N := 0 to HighNote do
+ if Note[N].Tone < BaseNote then
+ BaseNote := Note[N].Tone;
+ end;
+
Lines[0].Current := Lines[0].Current + 1;
CurrentNote := 0;
Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1;
diff --git a/src/screens/UScreenSingModi.pas b/src/screens/UScreenSingModi.pas
index 525e06a3..75c7195e 100644
--- a/src/screens/UScreenSingModi.pas
+++ b/src/screens/UScreenSingModi.pas
@@ -167,7 +167,6 @@ begin
Result.Sentence[I].Start := Lines.Line[I].Start;
Result.Sentence[I].StartNote := Lines.Line[I].Note[0].Start;
Result.Sentence[I].Lyric := Lines.Line[I].Lyric;
- Result.Sentence[I].LyricWidth := Lines.Line[I].LyricWidth;
Result.Sentence[I].End_ := Lines.Line[I].End_;
Result.Sentence[I].BaseNote := Lines.Line[I].BaseNote;
Result.Sentence[I].HighNote := Lines.Line[I].HighNote;