aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authors_alexander <s_alexander@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-03 00:02:02 +0000
committers_alexander <s_alexander@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-03 00:02:02 +0000
commit9ceadd2532207fcb512fcfecbd2895055422ad99 (patch)
tree09bddc76fecf74f29a438c402e163d882c430ba9 /src
parent2a4ac753add63ad2dedba6aa7c58c6afaa13f502 (diff)
downloadusdx-9ceadd2532207fcb512fcfecbd2895055422ad99.tar.gz
usdx-9ceadd2532207fcb512fcfecbd2895055422ad99.tar.xz
usdx-9ceadd2532207fcb512fcfecbd2895055422ad99.zip
fixed possible division by zero bug, if line has only 1 oder 2 points
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1845 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src')
-rw-r--r--src/screens/UScreenSing.pas12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/screens/UScreenSing.pas b/src/screens/UScreenSing.pas
index 9dd25cd1..9a620320 100644
--- a/src/screens/UScreenSing.pas
+++ b/src/screens/UScreenSing.pas
@@ -898,10 +898,14 @@ begin
// points for this line
LineScore := CurrentScore - CurrentPlayer.ScoreLast;
- // determine LinePerfection
- // Note: the "-2" extra points are a little bonus so the player does not
- // have to be that perfect to reach the bonus steps.
- LinePerfection := LineScore / (MaxLineScore - 2);
+ // check for lines with low points
+ if (MaxLineScore <= 2) then
+ LinePerfection := 1
+ else
+ // determine LinePerfection
+ // Note: the "+2" extra points are a little bonus so the player does not
+ // have to be that perfect to reach the bonus steps.
+ LinePerfection := LineScore / (MaxLineScore - 2);
// clamp LinePerfection to range [0..1]
if (LinePerfection < 0) then