mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-02 04:22:34 +02:00
Fix divide-by-zero error
... when displaying save buttons that have zero votes.
This commit is contained in:
@@ -68,19 +68,27 @@ SaveButton::SaveButton(Point position, Point size, SaveInfo * save):
|
|||||||
votesString = votes;
|
votesString = votes;
|
||||||
|
|
||||||
int voteMax = std::max(save->GetVotesUp(),save->GetVotesDown());
|
int voteMax = std::max(save->GetVotesUp(),save->GetVotesDown());
|
||||||
if (voteMax < 34)
|
if (voteMax)
|
||||||
{
|
{
|
||||||
float ry = 33.0f/voteMax;
|
if (voteMax < 34)
|
||||||
if (voteMax<8)
|
{
|
||||||
ry = ry/(8-voteMax);
|
float ry = 33.0f/voteMax;
|
||||||
voteBarHeightUp = (int)(save->GetVotesUp()*ry)-1;
|
if (voteMax<8)
|
||||||
voteBarHeightDown = (int)(save->GetVotesDown()*ry)-1;
|
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
|
else
|
||||||
{
|
{
|
||||||
float ry = voteMax/33.0f;
|
voteBarHeightUp = 0;
|
||||||
voteBarHeightUp = (int)(save->GetVotesUp()/ry)-1;
|
voteBarHeightDown = 0;
|
||||||
voteBarHeightDown = (int)(save->GetVotesDown()/ry)-1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user