MP in sidebar show crazy number when max_MP is 0

It was a division by 0 when evaluating the <r,g,b> tag graying these
numbers
This commit is contained in:
Ali El Gariani 2008-01-08 12:06:25 +00:00
parent 84a7ce8155
commit 9309dedcbb

View file

@ -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<int>(128 + (255-128) *
(static_cast<float>(movement_left)/u->second.total_movement()));
}
str << "<" << x << "," << x << "," << x <<">";
int grey = 128 + static_cast<int>((255-128) *
(movement_left / maximum<float>(1.0, u->second.total_movement())));
str << "<" << grey << "," << grey << "," << grey <<">";
str << movement_left << "/" << u->second.total_movement();
break;
}