XmlWriter: avoid a division by zero

This commit is contained in:
Olivier Teulière 2013-04-03 21:32:39 +02:00
parent 8437316c36
commit cd34ce6d32

View file

@ -344,7 +344,9 @@ void XmlWriter::write(const Game &iGame, const string &iFileName)
const int playerTotal = player.getTotalScore();
// Compute the percentage, compared to the top
long int percentage = lround((double)100 * playerTotal / gameTotal);
long int percentage = 0;
if (gameTotal != 0)
percentage = lround((double)100 * playerTotal / gameTotal);
// Compute the rank of the player (naive algorithm)
int rank = 1;