Skip to content

Commit

Permalink
Merge pull request #76966 from cknight828/fix-only-wildlife
Browse files Browse the repository at this point in the history
Fix the infinite loop of trying to spawn a blacklisted monster
  • Loading branch information
Anton Burmistrov authored Oct 28, 2024
2 parents bc43970 + 19b98e6 commit c6e6192
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/mongroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,43 +237,45 @@ std::vector<MonsterGroupResult> MonsterGroupManager::GetResultFromGroup(
// Check for monsters within subgroup
for( int i = 0; i < pack_size; i++ ) {
std::vector<MonsterGroupResult> tmp_grp =
GetResultFromGroup( entry.group, quantity, mon_found, true );
GetResultFromGroup( entry.group, quantity, &monster_found, true );
spawn_details.insert( spawn_details.end(), tmp_grp.begin(), tmp_grp.end() );
}
} else if( use_pack_size ) {
for( int i = 0; i < pack_size; i++ ) {
} else {
if( use_pack_size ) {
for( int i = 0; i < pack_size; i++ ) {
spawn_details.emplace_back( entry.name, pack_size, entry.data );
// And if a quantity pointer with remaining value was passed, will modify the external
// value as a side effect. We will reduce it by the spawn rule's cost multiplier.
if( quantity ) {
*quantity -= std::max( 1, entry.cost_multiplier * pack_size );
}
}
} else {
spawn_details.emplace_back( entry.name, pack_size, entry.data );
// And if a quantity pointer with remaining value was passed, will modify the external
// value as a side effect. We will reduce it by the spawn rule's cost multiplier.
if( quantity ) {
*quantity -= std::max( 1, entry.cost_multiplier * pack_size );
}
}
} else {
spawn_details.emplace_back( entry.name, pack_size, entry.data );
// And if a quantity pointer with remaining value was passed, will modify the external
// value as a side effect. We will reduce it by the spawn rule's cost multiplier.
if( quantity ) {
*quantity -= std::max( 1, entry.cost_multiplier * pack_size );
}
monster_found = true;
}
monster_found = true;
break;
}

// Force quantity to decrement regardless of whether we found a monster.
if( quantity && !monster_found && !is_recursive ) {
( *quantity )--;
}
if( mon_found ) {
( *mon_found ) = monster_found;
}

if( !is_recursive && spawn_details.empty() ) {
if( !is_recursive && !monster_found ) {
spawn_details.emplace_back( group.defaultMonster, 1, spawn_data() );
if( returned_default ) {
( *returned_default ) = true;
}
// Force quantity to decrement regardless of whether we found a monster.
if( quantity ) {
( *quantity )--;
}
}

return spawn_details;
Expand Down

0 comments on commit c6e6192

Please sign in to comment.