From cd34ce6d324bdfdf21f96b874beca5df7663fbc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Wed, 3 Apr 2013 21:32:39 +0200 Subject: [PATCH] XmlWriter: avoid a division by zero --- game/xml_writer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/game/xml_writer.cpp b/game/xml_writer.cpp index c6d55dd..fe76965 100644 --- a/game/xml_writer.cpp +++ b/game/xml_writer.cpp @@ -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;