Skip to content

Commit

Permalink
Fixed getting min/max drop values from deconstruction when modifier i…
Browse files Browse the repository at this point in the history
…s NULL (#75325)

* Fixed getting min/max drop values from deconstruction when modifier is NULL

* Astyle

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fixed readability-braces-around-statements error

---------

Co-authored-by: Anton Simakov <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 2, 2024
1 parent 1c3f49f commit 56ce45a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/item_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,15 @@ std::map<const itype *, std::pair<int, int>> Single_item_creator::every_item_min
i->charges_default() : modifier->charges.second;
return { std::make_pair( i, std::make_pair( modifier->count.first * min_charges, modifier->count.second * max_charges ) ) };
}
return { std::make_pair( i, modifier->count ) };

// since modifier is std::optional it might not be present
// if not - we return [0,1] if item has probability to spawn less than a hundred
// and [1,1] otherwise
if( modifier ) {
return { std::make_pair( i, modifier->count ) };
} else {
return { std::make_pair( i, std::make_pair( probability < 100 ? 0 : 1, 1 ) ) };
}
}
case S_ITEM_GROUP: {
Item_spawn_data *isd = item_controller->get_group( item_group_id( id ) );
Expand Down

0 comments on commit 56ce45a

Please sign in to comment.