From c3bc581f75b798e6a9904f5511bfee083f598701 Mon Sep 17 00:00:00 2001 From: Fedosov Alexander Date: Tue, 30 Jul 2024 13:38:30 +0300 Subject: [PATCH 1/3] Fixed getting min/max drop values from deconstruction when modifier is NULL --- src/item_group.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/item_group.cpp b/src/item_group.cpp index bccb398d6e424..6e537adfda88a 100644 --- a/src/item_group.cpp +++ b/src/item_group.cpp @@ -501,7 +501,14 @@ std::map> 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 ) ); From 9e49547ad888cba41bc75b7d03b92be2065ba19b Mon Sep 17 00:00:00 2001 From: Anton Simakov <67688115+GuardianDll@users.noreply.github.com> Date: Tue, 30 Jul 2024 12:47:59 +0200 Subject: [PATCH 2/3] Astyle Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/item_group.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item_group.cpp b/src/item_group.cpp index 6e537adfda88a..b07a661dc786f 100644 --- a/src/item_group.cpp +++ b/src/item_group.cpp @@ -505,7 +505,7 @@ std::map> Single_item_creator::every_item_min // 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 ) + if( modifier ) return { std::make_pair( i, modifier->count ) }; else return { std::make_pair( i, std::make_pair( probability < 100 ? 0 : 1, 1 ) ) }; From 86eed9a64aef7100c3d11a64b127fa269bdc2ab1 Mon Sep 17 00:00:00 2001 From: Fedosov Alexander Date: Tue, 30 Jul 2024 14:03:50 +0300 Subject: [PATCH 3/3] Fixed readability-braces-around-statements error --- src/item_group.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/item_group.cpp b/src/item_group.cpp index b07a661dc786f..2de7f563de4dd 100644 --- a/src/item_group.cpp +++ b/src/item_group.cpp @@ -505,10 +505,11 @@ std::map> Single_item_creator::every_item_min // 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 ) + if( modifier ) { return { std::make_pair( i, modifier->count ) }; - else + } 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 ) );