diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-11-15 13:01:25 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-11-15 13:01:25 (GMT) |
| commit | 785fbcefdf8e2e71063f947abf307becc0bf8c26 (patch) | |
| tree | c54876ca4b3de12c946bbe9823356610eb909a23 /src/interface/SaveButton.cpp | |
| parent | 51a5af6d5d30c6d15877314d6973d841fad7bc74 (diff) | |
| download | powder-785fbcefdf8e2e71063f947abf307becc0bf8c26.zip powder-785fbcefdf8e2e71063f947abf307becc0bf8c26.tar.gz | |
Fix divide-by-zero error
... when displaying save buttons that have zero votes.
Diffstat (limited to 'src/interface/SaveButton.cpp')
| -rw-r--r-- | src/interface/SaveButton.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/interface/SaveButton.cpp b/src/interface/SaveButton.cpp index 93a22f7..eb2640b 100644 --- a/src/interface/SaveButton.cpp +++ b/src/interface/SaveButton.cpp @@ -68,19 +68,27 @@ SaveButton::SaveButton(Point position, Point size, SaveInfo * save): votesString = votes; int voteMax = std::max(save->GetVotesUp(),save->GetVotesDown()); - if (voteMax < 34) + if (voteMax) { - float ry = 33.0f/voteMax; - if (voteMax<8) - ry = ry/(8-voteMax); - voteBarHeightUp = (int)(save->GetVotesUp()*ry)-1; - voteBarHeightDown = (int)(save->GetVotesDown()*ry)-1; + if (voteMax < 34) + { + float ry = 33.0f/voteMax; + if (voteMax<8) + ry = ry/(8-voteMax); + voteBarHeightUp = (int)(save->GetVotesUp()*ry)-1; + voteBarHeightDown = (int)(save->GetVotesDown()*ry)-1; + } + else + { + float ry = voteMax/33.0f; + voteBarHeightUp = (int)(save->GetVotesUp()/ry)-1; + voteBarHeightDown = (int)(save->GetVotesDown()/ry)-1; + } } else { - float ry = voteMax/33.0f; - voteBarHeightUp = (int)(save->GetVotesUp()/ry)-1; - voteBarHeightDown = (int)(save->GetVotesDown()/ry)-1; + voteBarHeightUp = 0; + voteBarHeightDown = 0; } } } |
