1
0
Fork 0

Fix effect crashes (#4530)

* Fix effect crashes

* Change according to suggestion
This commit is contained in:
Mat 2020-03-22 17:34:24 +02:00 committed by GitHub
parent c968f1f7da
commit 0b0d6b23d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -373,7 +373,7 @@ void cEntityEffectRegeneration::OnTick(cPawn & a_Target)
}
// Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks)
int frequency = FloorC(50.0 / static_cast<double>(m_Intensity + 1));
int frequency = std::max(1, FloorC(50.0 / static_cast<double>(m_Intensity + 1)));
if ((m_Ticks % frequency) != 0)
{
@ -462,7 +462,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
}
// Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks)
int frequency = FloorC(25.0 / static_cast<double>(m_Intensity + 1));
int frequency = std::max(1, FloorC(25.0 / static_cast<double>(m_Intensity + 1)));
if ((m_Ticks % frequency) == 0)
{
@ -486,7 +486,7 @@ void cEntityEffectWither::OnTick(cPawn & a_Target)
super::OnTick(a_Target);
// Damage frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
int frequency = FloorC(25.0 / static_cast<double>(m_Intensity + 1));
int frequency = std::max(1, FloorC(40.0 / static_cast<double>(m_Intensity + 1)));
if ((m_Ticks % frequency) == 0)
{