From 3e43860efca857ca7ed52fc4b4134c789150e4db Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Sat, 29 May 2021 17:11:05 +0200 Subject: [PATCH] Fixed index assignment Thanks to @Everade --- src/map/mob.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/map/mob.cpp b/src/map/mob.cpp index c9e341145b..553d2d2c96 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -4240,13 +4240,22 @@ bool MobDatabase::parseDropNode(const std::string& nodeName, const YAML::Node& n } } } else { - index = i++; + // Find next empty slot + for( ; i < max; i++ ){ + if( drops[i].nameid == 0 ){ + break; + } + } - if (index >= max) { + // No empty slots anymore + if (i >= max) { this->invalidWarning(dropit, "Maximum of %d monster %s met, skipping.\n", max, nodeName.c_str()); continue; } + // Use free index and increment it for the next entry + index = i++; + if( this->nodeExists( dropit, "Clear" ) ){ bool clear; @@ -4256,10 +4265,13 @@ bool MobDatabase::parseDropNode(const std::string& nodeName, const YAML::Node& n if( clear ){ // Clear all - for( uint8 i = 0; i < max; i++ ){ - drops[i] = {}; + for( uint8 j = 0; j < max; j++ ){ + drops[j] = {}; } + // Reset current index for next entry + i = 0; + if( !this->nodeExists( dropit, "Item" ) ){ // Continue with next yaml node continue;