Skip to content

Commit

Permalink
Fixed clamping in trading inventory
Browse files Browse the repository at this point in the history
fixes CleverRaven#75742
Found due to -D_GLIBCXX_ASSERTIONS, consider enabling it for experimental builds maybe?
this reverts d84cb31
  • Loading branch information
l29ah committed Aug 24, 2024
1 parent de745ea commit b1dfa05
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/inventory_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t>( 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" ) {
Expand Down

0 comments on commit b1dfa05

Please sign in to comment.