Skip to content

Commit 70843e6

Browse files
authored
Merge pull request #82556 from sparr/query_int_default_values
Set and show default values for most query_int
2 parents 843bbb3 + e929161 commit 70843e6

File tree

11 files changed

+141
-116
lines changed

11 files changed

+141
-116
lines changed

src/activity_actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4527,7 +4527,7 @@ bool workout_activity_actor::query_keep_training( player_activity &act, Characte
45274527
act.moves_left = act.moves_total;
45284528
return true;
45294529
}
4530-
int length;
4530+
int length = 0;
45314531
uilist workout_query;
45324532
workout_query.text = _( "You have finished your training cycle, keep training?" );
45334533
workout_query.addentry( 1, true, 'S', _( "Stop training." ) );

src/character.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11474,7 +11474,7 @@ bool Character::has_weapon() const
1147411474
int Character::get_lowest_hp() const
1147511475
{
1147611476
// Set lowest_hp to an arbitrarily large number.
11477-
int lowest_hp = 999;
11477+
int lowest_hp = INT_MAX;
1147811478
for( const std::pair<const bodypart_str_id, bodypart> &elem : get_body() ) {
1147911479
const int cur_hp = elem.second.get_hp_cur();
1148011480
if( cur_hp < lowest_hp ) {
@@ -11484,6 +11484,19 @@ int Character::get_lowest_hp() const
1148411484
return lowest_hp;
1148511485
}
1148611486

11487+
int Character::get_highest_hp() const
11488+
{
11489+
// Set lowest_hp to an arbitrarily large number.
11490+
int highest_hp = INT_MIN;
11491+
for( const std::pair<const bodypart_str_id, bodypart> &elem : get_body() ) {
11492+
const int cur_hp = elem.second.get_hp_cur();
11493+
if( cur_hp > highest_hp ) {
11494+
highest_hp = cur_hp;
11495+
}
11496+
}
11497+
return highest_hp;
11498+
}
11499+
1148711500
Creature::Attitude Character::attitude_to( const Creature &other ) const
1148811501
{
1148911502
const monster *m = dynamic_cast<const monster *>( &other );

src/character.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3858,6 +3858,8 @@ class Character : public Creature, public visitable
38583858

38593859
// used in debugging all health
38603860
int get_lowest_hp() const;
3861+
// used in debugging all health
3862+
int get_highest_hp() const;
38613863
bool has_weapon() const override;
38623864
void shift_destination( const point_rel_ms &shift );
38633865
// Auto move methods

src/debug_menu.cpp

Lines changed: 100 additions & 82 deletions
Large diffs are not rendered by default.

src/editmap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,8 +1222,8 @@ void editmap::setup_fmenu( uilist &fmenu )
12221222
void editmap::edit_rads() const
12231223
{
12241224
map &here = get_map();
1225-
int value = 0;
1226-
if( query_int( value, false, _( "Set rads to? Currently: %d" ), here.get_radiation( target ) ) ) {
1225+
int value = here.get_radiation( target );
1226+
if( query_int( value, true, _( "Set rads to?" ) ) ) {
12271227
here.set_radiation( target, value );
12281228
}
12291229
}

src/faction_camp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,13 +2458,13 @@ void basecamp::job_assignment_ui()
24582458
if( smenu.ret == 0 ) {
24592459
cur_npc->job.clear_all_priorities();
24602460
} else if( smenu.ret == 1 ) {
2461-
int priority;
2461+
int priority = 0;
24622462
query_int( priority, false, _( "Priority for all jobs " ) );
24632463
cur_npc->job.set_all_priorities( priority );
24642464
} else if( smenu.ret > 1 && smenu.ret <= static_cast<int>( job_vec.size() ) + 1 ) {
24652465
activity_id sel_job = job_vec[size_t( smenu.ret - 2 )];
24662466
player_activity test_act = player_activity( sel_job );
2467-
int priority;
2467+
int priority = 0;
24682468
query_int( priority, false, _( "Priority for %s " ), test_act.get_verb() );
24692469
cur_npc->job.set_task_priority( sel_job, priority );
24702470
} else {

src/iuse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3672,8 +3672,8 @@ std::optional<int> iuse::firecracker( Character *p, item *it, const tripoint_bub
36723672

36733673
std::optional<int> iuse::mininuke( Character *p, item *it, const tripoint_bub_ms & )
36743674
{
3675-
int time;
3676-
bool got_value = query_int( time, false, _( "Set the timer to ___ turns (0 to cancel)?" ) );
3675+
int time = 0;
3676+
bool got_value = query_int( time, false, _( "Set the timer to how many seconds (0 to cancel)?" ) );
36773677
if( !got_value || time <= 0 ) {
36783678
p->add_msg_if_player( _( "Never mind." ) );
36793679
return std::nullopt;

src/newcharacter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4757,14 +4757,14 @@ void set_description( tab_manager &tabs, avatar &you, const bool allow_reroll,
47574757
}
47584758
case char_creation::AGE: {
47594759
int result = you.base_age();
4760-
if( query_int( result, false, _( "Enter age in years. Minimum 16, maximum 55" ) ) && result > 0 ) {
4760+
if( query_int( result, true, _( "Enter age in years. Minimum 16, maximum 55" ) ) && result > 0 ) {
47614761
you.set_base_age( clamp( result, 16, 55 ) );
47624762
}
47634763
break;
47644764
}
47654765
case char_creation::HEIGHT: {
47664766
int result = you.base_height();
4767-
if( query_int( result, false, _( "Enter height in centimeters. Minimum %d, maximum %d" ),
4767+
if( query_int( result, true, _( "Enter height in centimeters. Minimum %d, maximum %d" ),
47684768
min_allowed_height, max_allowed_height ) && result > 0 ) {
47694769
you.set_base_height( clamp( result, min_allowed_height, max_allowed_height ) );
47704770
}

src/overmap_ui.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,8 +1818,7 @@ static void modify_horde_func( tripoint_abs_omt &curs )
18181818
switch( smenu.ret ) {
18191819
case 0:
18201820
new_value = chosen_group.interest;
1821-
if( query_int( new_value, false, _( "Set interest to what value? Currently %d" ),
1822-
chosen_group.interest ) ) {
1821+
if( query_int( new_value, true, _( "Set interest to what value?" ) ) ) {
18231822
chosen_group.set_interest( new_value );
18241823
}
18251824
break;
@@ -1833,8 +1832,7 @@ static void modify_horde_func( tripoint_abs_omt &curs )
18331832
break;
18341833
case 2:
18351834
new_value = chosen_group.population;
1836-
if( query_int( new_value, false, _( "Set population to what value? Currently %d" ),
1837-
chosen_group.population ) ) {
1835+
if( query_int( new_value, true, _( "Set population to what value?" ) ) ) {
18381836
chosen_group.population = new_value;
18391837
}
18401838
break;
@@ -1844,9 +1842,8 @@ static void modify_horde_func( tripoint_abs_omt &curs )
18441842
case 4:
18451843
new_value = static_cast<int>( chosen_group.behaviour );
18461844
// Screw it we hardcode a popup, if you really want to use this you're welcome to improve it
1847-
popup( _( "Set behavior to which enum value? Currently %d. \nAccepted values:\n0 = none,\n1 = city,\n2=roam,\n3=nemesis" ),
1848-
static_cast<int>( chosen_group.behaviour ) );
1849-
query_int( new_value, false, "" );
1845+
query_int( new_value, true,
1846+
_( "Set behavior to which enum value?\nAccepted values:\n0 = none,\n1 = city,\n2=roam,\n3=nemesis" ) );
18501847
chosen_group.behaviour = static_cast<mongroup::horde_behaviour>( new_value );
18511848
break;
18521849
case 5:

src/vehicle_use.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,8 @@ void vehicle::reload_seeds( map *here, const tripoint_bub_ms &pos )
907907

908908
if( seed_index > 0 && seed_index < static_cast<int>( seed_entries.size() ) ) {
909909
const int count = std::get<2>( seed_entries[seed_index] );
910-
int amount = 0;
911-
query_int( amount, false, _( "Move how many? [Have %d] (0 to cancel)" ), count );
910+
int amount = count;
911+
query_int( amount, true, _( "Move how many? (0 to cancel)" ) );
912912

913913
if( amount > 0 ) {
914914
int actual_amount = std::min( amount, count );

0 commit comments

Comments
 (0)