diff --git a/src/mission.cpp b/src/mission.cpp index 08467b17dd7ec..9563ea1410d8f 100644 --- a/src/mission.cpp +++ b/src/mission.cpp @@ -259,6 +259,7 @@ bool mission::on_creature_fusion( Creature &fuser, Creature &fused ) return false; } bool mission_transfered = false; + std::vector mission_ids_to_remove; for( const int mission_id : mon_fused->mission_ids ) { const mission *const found_mission = mission::find( mission_id ); if( !found_mission ) { @@ -269,10 +270,13 @@ bool mission::on_creature_fusion( Creature &fuser, Creature &fused ) if( type->goal == MGOAL_KILL_MONSTER || type->goal == MGOAL_KILL_MONSTERS ) { // the fuser has to be killed now! mon_fuser->mission_ids.emplace( mission_id ); - mon_fused->mission_ids.erase( mission_id ); + mission_ids_to_remove.push_back( mission_id ); mission_transfered = true; } } + for( const int mission_id : mission_ids_to_remove ) { + mon_fused->mission_ids.erase( mission_id ); + } return mission_transfered; }