@@ -196,28 +196,33 @@ procedure TPlayer.SetScoreGolden(newScoreGolden: real);
196196end ;
197197procedure TPlayer.UpdateIntScores ();
198198begin
199- // a problem if we use floor instead of round is that a score of
200- // 10000 points is only possible if the last digit of the total points
201- // for golden and normal notes is 0.
202- // if we use round, the max score is 10000 for most songs
203- // but a score of 10010 is possible if the last digit of the total
204- // points for golden and normal notes is 5
205- // the best solution is to use round for one of these scores
206- // and round the other score in the opposite direction
207- // so we assure that the highest possible score is 10000 in every case.
208- _ScoreInt := round(Score / 10 ) * 10 ;
209- if (_ScoreInt < Score) then
210- // normal score is floored so we have to ceil golden notes score
211- _ScoreGoldenInt := ceil(ScoreGolden / 10 ) * 10
212- else
213- // normal score is ceiled so we have to floor golden notes score
214- _ScoreGoldenInt := floor(ScoreGolden / 10 ) * 10 ;
215-
216- // line bonus
217- _ScoreLineInt := Floor(Round(ScoreLine) / 10 ) * 10 ;
218-
219199 // total score
220- _ScoreTotalInt := ScoreInt + ScoreGoldenInt + ScoreLineInt;
200+ _ScoreTotalInt := round(Score + ScoreGolden + ScoreLine);
201+ // components
202+ _ScoreInt := round(Score);
203+ _ScoreGoldenInt := round(ScoreGolden);
204+ _ScoreLineInt := round(ScoreLine);
205+ // _ScoreTotalInt = as close to the truth as possible, but the components might not add up to it
206+ // this can happen if:
207+ // * all the components are .2 (total is one higher than sum of components)
208+ // * all the components are .6 (total is one less than the sum of components)
209+ // in these cases we just +1/-1 a component so that it fits
210+ if (_ScoreInt + _ScoreGoldenInt + _ScoreLineInt > _ScoreTotalInt) then begin
211+ // prefer decreasing golden notes first, then regular notes, as a last resort just -1 the line bonus
212+ if (_ScoreGoldenInt > 0 ) then
213+ _ScoreGoldenInt := _ScoreGoldenInt - 1
214+ else if (_ScoreInt > 0 ) then
215+ _ScoreInt := _ScoreInt - 1
216+ else
217+ _ScoreLineInt := _ScoreLineInt - 1 ;
218+ end else if (_ScoreInt + _ScoreGoldenInt + _ScoreLineInt < _ScoreTotalInt) then begin
219+ // if the very first note(s) is golden AND this is the very beginning of the song, this might (temporarily) increase the wrong one.
220+ // it is estimated that there are way more songs that simply don't have golden notes at all and where it thus would pick the correct one.
221+ if (_ScoreInt > 0 ) or (_ScoreGoldenInt = 0 ) then
222+ _ScoreInt := _ScoreInt + 1
223+ else
224+ _ScoreGoldenInt := _ScoreGoldenInt + 1 ;
225+ end ;
221226end ;
222227procedure TPlayer.ResetScores ();
223228begin
0 commit comments