Skip to content

Commit

Permalink
fix: negative retval -1confuses uilist
Browse files Browse the repository at this point in the history
prevent exciting magic numbers from happening

Co-authored-by: andrei <[email protected]>
  • Loading branch information
scarf005 and andrei8l committed Sep 16, 2023
1 parent 51a12e2 commit 6077363
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/iexamine_elevator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ auto dest( const elevator::tiles &elevator_here,
auto choose_floor( const tripoint &examp, const tripoint_abs_omt &this_omt,
const tripoint &sm_orig ) -> int
{
constexpr int retval_offset = 10000; // workaround for uilist retval autoassign when retval == -1
const auto this_floor = _( " (this floor)" );

map &here = get_map();
Expand All @@ -79,10 +80,10 @@ auto choose_floor( const tripoint &examp, const tripoint_abs_omt &this_omt,
const auto floor_name = z == examp.z ? this_floor : "";
const std::string name = string_format( "%3iF %s%s", z, omt_name, floor_name );

choice.addentry( z, z != examp.z, MENU_AUTOASSIGN, name );
choice.addentry( z + retval_offset, z != examp.z, MENU_AUTOASSIGN, name );
}
choice.query();
return choice.ret;
return choice.ret - retval_offset;
}

enum class overlap_status { outside, inside, overlap };
Expand Down

0 comments on commit 6077363

Please sign in to comment.