From daa2dde19e2b1d27477eaa618157551d3fcd84bb Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 22 Oct 2011 00:25:26 +0000 Subject: Fix percentage output to match that of statdump.exe. Subversion-branch: /branches/v2-branch Subversion-revision: 2452 --- src/doom/statdump.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/doom/statdump.c b/src/doom/statdump.c index 0e83df8d..e80641c8 100644 --- a/src/doom/statdump.c +++ b/src/doom/statdump.c @@ -152,7 +152,12 @@ static void PrintPercentage(FILE *stream, int amount, int total) { fprintf(stream, "%i / %i", amount, total); - fprintf(stream, " (%i%%)", (amount * 100) / total); + // statdump.exe is a 16-bit program, so very occasionally an + // integer overflow can occur when doing this calculation with + // a large value. Therefore, cast to short to give the same + // output. + + fprintf(stream, " (%i%%)", (short) (amount * 100) / total); } } -- cgit v1.2.3