Prevent division by zero by also checking iWalkSpeed for 0

This commit is contained in:
dongresource 2020-12-15 02:11:18 +01:00
parent 442d7853a5
commit f74c40cf69

View File

@ -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