Browse Source

fix health bar edge case

Laserlicht 7 months ago
parent
commit
ff2d45673b
1 changed files with 1 additions and 1 deletions
  1. 1 1
      client/battle/BattleStacksController.cpp

+ 1 - 1
client/battle/BattleStacksController.cpp

@@ -320,7 +320,7 @@ void BattleStacksController::showStackAmountBox(Canvas & canvas, const CStack *
 	if(settings["battle"]["showHealthBar"].Bool())
 	{
 		float health = stack->getMaxHealth();
-		float healthRemaining = std::max(stack->getAvailableHealth() - (stack->getCount() - 1) * health, .0f);
+		float healthRemaining = std::min(std::max(stack->getAvailableHealth() - (stack->getCount() - 1) * health, .0f), health);
 		Rect r(boxPosition.x, boxPosition.y - 3, amountBG->width(), 4);
 		canvas.drawColor(r, Colors::RED);
 		canvas.drawColor(Rect(r.x, r.y, (r.w / health) * healthRemaining, r.h), Colors::GREEN);