Skip to content

Commit

Permalink
Count perfect lines instead of line perfection score
Browse files Browse the repository at this point in the history
This should reduce floating point arithmetic errors.
Fixes #844
  • Loading branch information
DeinAlptraum committed Oct 4, 2024
1 parent d816e69 commit da72b79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/base/UNote.pas
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ TPlayer = record

// Scores
Score: real;
ScoreLine: real;
PerfectLines: real;
ScoreGolden: real;

ScoreInt: integer;
Expand Down
22 changes: 11 additions & 11 deletions src/screens/controllers/UScreenSingController.pas
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function TScreenSingController.ParseInput(PressedKey: Cardinal; CharCode: UCS4Ch
with Player[i1] do
begin
Score := 0;
ScoreLine := 0;
PerfectLines := 0;
ScoreGolden := 0;

ScoreInt := 0;
Expand Down Expand Up @@ -556,7 +556,7 @@ function TScreenSingController.ParseInput(PressedKey: Cardinal; CharCode: UCS4Ch
with Player[i1] do
begin
Score := 0;
ScoreLine := 0;
PerfectLines := 0;
ScoreGolden := 0;

ScoreInt := 0;
Expand Down Expand Up @@ -838,7 +838,7 @@ procedure TScreenSingController.onShowFinish;
with Player[PlayerIndex] do
begin
Score := 0;
ScoreLine := 0;
PerfectLines := 0;
ScoreGolden := 0;

ScoreInt := 0;
Expand Down Expand Up @@ -1568,9 +1568,9 @@ procedure TScreenSingController.Finish;
PlaylistMedley.Stats[len].Player[I].Score +
PlaylistMedley.Stats[J].Player[I].Score;

PlaylistMedley.Stats[len].Player[I].ScoreLine :=
PlaylistMedley.Stats[len].Player[I].ScoreLine +
PlaylistMedley.Stats[J].Player[I].ScoreLine;
PlaylistMedley.Stats[len].Player[I].PerfectLines :=
PlaylistMedley.Stats[len].Player[I].PerfectLines +
PlaylistMedley.Stats[J].Player[I].PerfectLines;

PlaylistMedley.Stats[len].Player[I].ScoreGolden :=
PlaylistMedley.Stats[len].Player[I].ScoreGolden +
Expand Down Expand Up @@ -1600,8 +1600,8 @@ procedure TScreenSingController.Finish;
PlaylistMedley.Stats[len].Player[I].Score := round(
PlaylistMedley.Stats[len].Player[I].Score / len);

PlaylistMedley.Stats[len].Player[I].ScoreLine := round(
PlaylistMedley.Stats[len].Player[I].ScoreLine / len);
PlaylistMedley.Stats[len].Player[I].PerfectLines := round(
PlaylistMedley.Stats[len].Player[I].PerfectLines / len);

PlaylistMedley.Stats[len].Player[I].ScoreGolden := round(
PlaylistMedley.Stats[len].Player[I].ScoreGolden / len);
Expand Down Expand Up @@ -1710,9 +1710,9 @@ procedure TScreenSingController.OnSentenceEnd(Track: integer; SentenceIndex: car
LineBonus := MAX_SONG_LINE_BONUS / (Length(Tracks[Track].Lines) -
NumEmptySentences[Track]);
// apply line-bonus
CurrentPlayer.ScoreLine :=
CurrentPlayer.ScoreLine + LineBonus * LinePerfection;
CurrentPlayer.ScoreLineInt := Floor(CurrentPlayer.ScoreLine / 10) * 10;
CurrentPlayer.PerfectLines :=
CurrentPlayer.PerfectLines + LinePerfection;
CurrentPlayer.ScoreLineInt := Floor(CurrentPlayer.PerfectLines * LineBonus / 10) * 10;
// update total score
CurrentPlayer.ScoreTotalInt :=
CurrentPlayer.ScoreInt +
Expand Down

0 comments on commit da72b79

Please sign in to comment.