Cast to long to avoid overflow when multiplying by the health
This commit is contained in:
@@ -122,7 +122,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var health = self.TraitOrDefault<Health>();
|
||||
if (health != null)
|
||||
{
|
||||
var newHP = ForceHealthPercentage > 0 ? ForceHealthPercentage : (health.HP * 100) / health.MaxHP;
|
||||
// Cast to long to avoid overflow when multiplying by the health
|
||||
var newHP = ForceHealthPercentage > 0 ? ForceHealthPercentage : (int)(health.HP * 100L / health.MaxHP);
|
||||
init.Add(new HealthInit(newHP));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user