Fixed index assignment

Thanks to @Everade
This commit is contained in:
Lemongrass3110 2021-05-29 17:11:05 +02:00
parent 6ddf1a3224
commit 3e43860efc

View File

@ -4240,13 +4240,22 @@ bool MobDatabase::parseDropNode(const std::string& nodeName, const YAML::Node& n
} }
} }
} else { } 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()); this->invalidWarning(dropit, "Maximum of %d monster %s met, skipping.\n", max, nodeName.c_str());
continue; continue;
} }
// Use free index and increment it for the next entry
index = i++;
if( this->nodeExists( dropit, "Clear" ) ){ if( this->nodeExists( dropit, "Clear" ) ){
bool clear; bool clear;
@ -4256,10 +4265,13 @@ bool MobDatabase::parseDropNode(const std::string& nodeName, const YAML::Node& n
if( clear ){ if( clear ){
// Clear all // Clear all
for( uint8 i = 0; i < max; i++ ){ for( uint8 j = 0; j < max; j++ ){
drops[i] = {}; drops[j] = {};
} }
// Reset current index for next entry
i = 0;
if( !this->nodeExists( dropit, "Item" ) ){ if( !this->nodeExists( dropit, "Item" ) ){
// Continue with next yaml node // Continue with next yaml node
continue; continue;