diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 77d2820fce95b..405303a1a33bc 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -5643,14 +5643,8 @@ void map::place_spawns( const mongroup_id &group, const int chance, // Pick a monster type MonsterGroupResult spawn_details = MonsterGroupManager::GetResultFromGroup( group, &num ); - const MonsterGroup &mg = group.obj(); - auto mon_selected = std::find_if( mg.monsters.begin(), mg.monsters.end(), - [spawn_details]( const MonsterGroupEntry & mon ) { - return mon.name == spawn_details.name; - } ); - add_spawn( spawn_details.name, spawn_details.pack_size, { x, y, abs_sub.z }, - friendly, -1, mission_id, name, mon_selected->data ); + friendly, -1, mission_id, name, spawn_details.data ); } } diff --git a/src/mongroup.cpp b/src/mongroup.cpp index 989810fd5200e..21b22101cdea0 100644 --- a/src/mongroup.cpp +++ b/src/mongroup.cpp @@ -101,7 +101,7 @@ MonsterGroupResult MonsterGroupManager::GetResultFromGroup( auto &group = GetUpgradedMonsterGroup( group_name ); int spawn_chance = rng( 1, group.freq_total ); //Default 1000 unless specified //Our spawn details specify, by default, a single instance of the default monster - MonsterGroupResult spawn_details = MonsterGroupResult( group.defaultMonster, 1 ); + MonsterGroupResult spawn_details = MonsterGroupResult( group.defaultMonster, 1, spawn_data() ); bool monster_found = false; // Loop invariant values @@ -174,9 +174,9 @@ MonsterGroupResult MonsterGroupManager::GetResultFromGroup( //If the monsters frequency is greater than the spawn_chance, select this spawn rule if( it->frequency >= spawn_chance ) { if( it->pack_maximum > 1 ) { - spawn_details = MonsterGroupResult( it->name, rng( it->pack_minimum, it->pack_maximum ) ); + spawn_details = MonsterGroupResult( it->name, rng( it->pack_minimum, it->pack_maximum ), it->data ); } else { - spawn_details = MonsterGroupResult( it->name, 1 ); + spawn_details = MonsterGroupResult( it->name, 1, it->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 diff --git a/src/mongroup.h b/src/mongroup.h index 40a81ecd65a6c..a19e581e79187 100644 --- a/src/mongroup.h +++ b/src/mongroup.h @@ -55,12 +55,13 @@ struct MonsterGroupEntry { struct MonsterGroupResult { mtype_id name; int pack_size; + spawn_data data; MonsterGroupResult() : name( mtype_id::NULL_ID() ), pack_size( 0 ) { } - MonsterGroupResult( const mtype_id &id, int new_pack_size ) - : name( id ), pack_size( new_pack_size ) { + MonsterGroupResult( const mtype_id &id, int new_pack_size, spawn_data new_data ) + : name( id ), pack_size( new_pack_size ), data( new_data ) { } };