From f74c40cf69517bb7b1a500f93bd4957ed5072365 Mon Sep 17 00:00:00 2001 From: dongresource Date: Tue, 15 Dec 2020 02:11:18 +0100 Subject: [PATCH] Prevent division by zero by also checking iWalkSpeed for 0 --- src/MobManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MobManager.cpp b/src/MobManager.cpp index 380e4c1..9c2b627 100644 --- a/src/MobManager.cpp +++ b/src/MobManager.cpp @@ -632,10 +632,6 @@ void MobManager::roamingStep(Mob *mob, time_t currTime) { return; } - // some mobs don't move (and we mustn't divide/modulus by zero) - if (mob->idleRange == 0) - return; - // no random roaming if the mob already has a set path if (mob->staticPath) return; @@ -656,6 +652,10 @@ void MobManager::roamingStep(Mob *mob, time_t currTime) { int yStart = mob->spawnY - mob->idleRange/2; int speed = mob->data["m_iWalkSpeed"]; + // some mobs don't move (and we mustn't divide/modulus by zero) + if (mob->idleRange == 0 || speed == 0) + return; + int farX, farY; int distance; // for short walk detection