From b1dfa05992e8a461f7f10bf219ee53c36276c432 Mon Sep 17 00:00:00 2001 From: Sergey Alirzaev Date: Sat, 24 Aug 2024 22:05:29 +0200 Subject: [PATCH] Fixed clamping in trading inventory fixes #75742 Found due to -D_GLIBCXX_ASSERTIONS, consider enabling it for experimental builds maybe? this reverts d84cb31b1a66d684710b3c42cb2cc284dc4bbf35 --- src/inventory_ui.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/inventory_ui.cpp b/src/inventory_ui.cpp index 732fb821acd1e..ca45c87b48a1e 100644 --- a/src/inventory_ui.cpp +++ b/src/inventory_ui.cpp @@ -3943,9 +3943,9 @@ void inventory_multiselector::on_input( const inventory_input &input ) if( entry.is_selectable() ) { size_t const count = entry.chosen_count; size_t const max = entry.get_available_count(); - size_t const newcount = std::clamp( 0, - count + ( input.action == "INCREASE_COUNT" ? +1 : -1 ), - max ); + size_t const newcount = input.action == "INCREASE_COUNT" + ? count < max ? count + 1 : max + : count > 1 ? count - 1 : 0; toggle_entry( entry, newcount ); } } else if( input.action == "VIEW_CATEGORY_MODE" ) {