From 9309dedcbb92975557a2dad0d8eb3900112a7d1c Mon Sep 17 00:00:00 2001 From: Ali El Gariani Date: Tue, 8 Jan 2008 12:06:25 +0000 Subject: [PATCH] fix bug #10710: MP in sidebar show crazy number when max_MP is 0 It was a division by 0 when evaluating the tag graying these numbers --- src/generate_report.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/generate_report.cpp b/src/generate_report.cpp index c8a71e0deaf..edb47e0a97b 100644 --- a/src/generate_report.cpp +++ b/src/generate_report.cpp @@ -200,14 +200,9 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP movement_left = u->second.total_movement(); } - int x = 180; - if(utils::string_bool(u->second.get_state("stoned"))){ - x = 128; - }else{ - x = static_cast(128 + (255-128) * - (static_cast(movement_left)/u->second.total_movement())); - } - str << "<" << x << "," << x << "," << x <<">"; + int grey = 128 + static_cast((255-128) * + (movement_left / maximum(1.0, u->second.total_movement()))); + str << "<" << grey << "," << grey << "," << grey <<">"; str << movement_left << "/" << u->second.total_movement(); break; }