@@ -1064,7 +1064,7 @@ monster *create_monster( const mtype_id &mon_type, const tripoint &p )
{
monster new_monster( mon_type, p );
if( !g->add_zombie( new_monster ) ) {
return NULL;
return nullptr;
} else {
return g->critter_at<monster>( p );
}
@@ -1311,7 +1311,7 @@ static const struct luaL_Reg global_funcs [] = {
{"dofile", game_dofile},
{"get_monster_types", game_get_monster_types},
{"get_item_groups", game_get_item_groups},
{NULL, NULL}
{nullptr, nullptr}
};

// Lua initialization.
@@ -1342,7 +1342,7 @@ void game::init_lua()
for( auto x = global_funcs; x->name != nullptr; ++x ) {
lib_funcs.push_back( *x );
}
lib_funcs.push_back( luaL_Reg { NULL, NULL } );
lib_funcs.push_back( luaL_Reg { nullptr, nullptr } );
luaL_newmetatable( lua_state, "game" );
lua_pushvalue( lua_state, -1 );
luaL_setfuncs( lua_state, &lib_funcs.front(), 0 );
@@ -1024,7 +1024,7 @@ units::mass Character::weight_carried_with_tweaks( const item_tweaks &tweaks ) c
const std::map<const item *, int> empty;
const auto &without = tweaks.without_items ? tweaks.without_items->get() : empty;

units::mass ret = 0;
units::mass ret = 0_gram;
if( !without.count( &weapon ) ) {
ret += weapon.weight();
}
@@ -1088,15 +1088,15 @@ units::mass Character::weight_capacity() const
if( has_bionic( bionic_id( "bio_weight" ) ) ) {
ret += 20_kilogram;
}
if( ret < 0 ) {
ret = 0;
if( ret < 0_gram ) {
ret = 0_gram;
}
return ret;
}

units::volume Character::volume_capacity() const
{
return volume_capacity_reduced_by( 0 );
return volume_capacity_reduced_by( 0_ml );
}

units::volume Character::volume_capacity_reduced_by(
@@ -1501,8 +1501,8 @@ std::array<encumbrance_data, num_bp> Character::calc_encumbrance( const item &ne

units::mass Character::get_weight() const
{
units::mass ret = 0;
units::mass wornWeight = std::accumulate( worn.begin(), worn.end(), units::mass( 0 ),
units::mass ret = 0_gram;
units::mass wornWeight = std::accumulate( worn.begin(), worn.end(), 0_gram,
[]( units::mass sum, const item &itm ) {
return sum + itm.weight();
} );
@@ -2672,7 +2672,7 @@ body_part Character::get_random_body_part( bool main ) const
return random_body_part( main );
}

std::vector<body_part> Character::get_all_body_parts( bool main ) const
std::vector<body_part> Character::get_all_body_parts( bool only_main ) const
{
// @todo: Remove broken parts, parts removed by mutations etc.
static const std::vector<body_part> all_bps = {{
@@ -2701,7 +2701,7 @@ std::vector<body_part> Character::get_all_body_parts( bool main ) const
}
};

return main ? main_bps : all_bps;
return only_main ? main_bps : all_bps;
}

std::string Character::extended_description() const
@@ -148,7 +148,7 @@ class Character : public Creature, public visitable<Character>
field_id bloodType() const override;
field_id gibType() const override;
bool is_warm() const override;
virtual const std::string &symbol() const override;
const std::string &symbol() const override;

// Character stats
// TODO: Make those protected
@@ -270,7 +270,7 @@ class Character : public Creature, public visitable<Character>
/** Picks a random body part, adjusting for mutations, broken body parts etc. */
body_part get_random_body_part( bool main ) const override;
/** Returns all body parts this character has, in order they should be displayed. */
std::vector<body_part> get_all_body_parts( bool main = false ) const override;
std::vector<body_part> get_all_body_parts( bool only_main = false ) const override;

/** Recalculates encumbrance cache. */
void reset_encumbrance();
@@ -698,7 +698,7 @@ class Character : public Creature, public visitable<Character>
/** Color's character's tile's background */
nc_color symbol_color() const override;

virtual std::string extended_description() const override;
std::string extended_description() const override;

// In newcharacter.cpp
void empty_skills();
@@ -822,8 +822,8 @@ void zone_manager::zone_edited( zone_data &zone )
{
if( zone.get_is_vehicle() ) {
//Check if this zone has already been stored
for( auto it = changed_vzones.begin(); it != changed_vzones.end(); ++it ) {
if( &zone == it->second ) {
for( auto &changed_vzone : changed_vzones ) {
if( &zone == changed_vzone.second ) {
return;
}
}
@@ -44,9 +44,7 @@ void color_manager::finalize()
}
};

for( size_t i = 0; i < color_array.size(); i++ ) {
color_struct &entry = color_array[i];

for( auto &entry : color_array ) {
entry.invert = get( entry.invert_id );

if( !entry.name_custom.empty() ) {
@@ -67,8 +65,7 @@ void color_manager::finalize()
}

// Highlights in a next run, to make sure custom colors are set
for( size_t i = 0; i < color_array.size(); i++ ) {
color_struct &entry = color_array[i];
for( auto &entry : color_array ) {
const std::string my_name = get_name( entry.color );
const std::string root = my_name.substr( 2, my_name.length() - 2 );
const size_t underscore_num = std::count( root.begin(), root.end(), '_' ) -
@@ -115,10 +112,10 @@ color_id color_manager::color_to_id( const nc_color &color ) const
}

// Optimally this shouldn't happen, but allow for now
for( size_t i = 0; i < color_array.size(); i++ ) {
if( color_array[i].color == color ) {
for( const auto &entry : color_array ) {
if( entry.color == color ) {
debugmsg( "Couldn't find color %d", color.operator int() );
return color_array[i].col_id;
return entry.col_id;
}
}

@@ -552,13 +549,13 @@ nc_color color_from_string( const std::string &color )
}

const std::pair<std::string, std::string> pSearch[2] = { { "light_", "lt" }, { "dark_", "dk" } };
for( int i = 0; i < 2; ++i ) {
for( const auto &i : pSearch ) {
size_t pos = 0;
while( ( pos = new_color.find( pSearch[i].second, pos ) ) != std::string::npos ) {
new_color.replace( pos, pSearch[i].second.length(), pSearch[i].first );
pos += pSearch[i].first.length();
while( ( pos = new_color.find( i.second, pos ) ) != std::string::npos ) {
new_color.replace( pos, i.second.length(), i.first );
pos += i.first.length();
DebugLog( D_WARNING, DC_ALL ) << "Deprecated foreground color suffix was used: (" <<
pSearch[i].second << ") in (" << color << "). Please update mod that uses that.";
i.second << ") in (" << color << "). Please update mod that uses that.";
}
}

@@ -597,13 +594,13 @@ nc_color bgcolor_from_string( const std::string &color )
std::string new_color = "i_" + color;

const std::pair<std::string, std::string> pSearch[2] = { { "light_", "lt" }, { "dark_", "dk" } };
for( int i = 0; i < 2; ++i ) {
for( const auto &i : pSearch ) {
size_t pos = 0;
while( ( pos = new_color.find( pSearch[i].second, pos ) ) != std::string::npos ) {
new_color.replace( pos, pSearch[i].second.length(), pSearch[i].first );
pos += pSearch[i].first.length();
while( ( pos = new_color.find( i.second, pos ) ) != std::string::npos ) {
new_color.replace( pos, i.second.length(), i.first );
pos += i.first.length();
DebugLog( D_WARNING, DC_ALL ) << "Deprecated background color suffix was used: (" <<
pSearch[i].second << ") in (" << color << "). Please update mod that uses that.";
i.second << ") in (" << color << "). Please update mod that uses that.";
}
}

@@ -402,13 +402,12 @@ void computer::activate_function( computer_action action )
bool found_item = false;
item sewage( "sewage", calendar::turn );
auto candidates = g->m.i_at( x1, y1 );
for( auto candidate = candidates.begin();
candidate != candidates.end(); ++candidate ) {
long capa = candidate->get_remaining_capacity_for_liquid( sewage );
for( auto &candidate : candidates ) {
long capa = candidate.get_remaining_capacity_for_liquid( sewage );
if( capa <= 0 ) {
continue;
}
item &elem = *candidate;
item &elem = candidate;
capa = std::min( sewage.charges, capa );
if( elem.contents.empty() ) {
elem.put_in( sewage );
@@ -222,7 +222,7 @@ class Creature
* Does not call @ref check_dead_state.
* @param source The attacking creature, can be null.
* @param bp The attacked body part
* @param d The damage dealt
* @param dam The damage dealt
*/
virtual dealt_damage_instance deal_damage( Creature *source, body_part bp,
const damage_instance &dam );
@@ -409,9 +409,9 @@ class Creature
virtual body_part get_random_body_part( bool main = false ) const = 0;
/**
* Returns body parts in order in which they should be displayed.
* @param main If true, only displays parts that can have hit points
* @param only_main If true, only displays parts that can have hit points
*/
virtual std::vector<body_part> get_all_body_parts( bool main = false ) const = 0;
virtual std::vector<body_part> get_all_body_parts( bool only_main = false ) const = 0;

virtual int get_speed_base() const;
virtual int get_speed_bonus() const;
@@ -127,7 +127,7 @@ bool game::dump_stats( const std::string &what, dump_mode mode,
}
auto dump = [&rows]( const item & obj ) {
std::vector<std::string> r;
r.push_back( obj.tname( false ) );
r.push_back( obj.tname( 1, false ) );
r.push_back( to_string( obj.volume() / units::legacy_volume_factor ) );
r.push_back( to_string( to_gram( obj.weight() ) ) );
r.push_back( to_string( obj.type->stack_size ) );
@@ -204,7 +204,7 @@ bool game::dump_stats( const std::string &what, dump_mode mode,

dump( test_npcs[ "S1" ], gun );

if( gun.type->gun->barrel_length > 0 ) {
if( gun.type->gun->barrel_length > 0_ml ) {
gun.emplace_back( "barrel_small" );
dump( test_npcs[ "S1" ], gun );
}
@@ -1868,8 +1868,7 @@ bool editmap::mapgen_set( std::string om_name, tripoint &omt_tgt, int r, bool ch
}

destsm->delete_vehicles();
for( size_t i = 0; i < srcsm->vehicles.size(); i++ ) { // copy vehicles to real map
vehicle *veh1 = srcsm->vehicles[i];
for( auto veh1 : srcsm->vehicles ) { // copy vehicles to real map
veh1->smx = target_sub.x + x;
veh1->smy = target_sub.y + y;
veh1->smz = target.z;
@@ -1880,8 +1879,8 @@ bool editmap::mapgen_set( std::string om_name, tripoint &omt_tgt, int r, bool ch
g->m.update_vehicle_list( destsm, target.z );

int spawns_todo = 0;
for( size_t i = 0; i < srcsm->spawns.size(); i++ ) { // copy spawns
destsm->spawns.push_back( srcsm->spawns[i] );
for( const auto &spawn : srcsm->spawns ) { // copy spawns
destsm->spawns.push_back( spawn );
spawns_todo++;
}

@@ -1951,8 +1950,8 @@ vehicle *editmap::mapgen_veh_query( const tripoint &omt_tgt )
for( int x = 0; x < 2; x++ ) {
for( int y = 0; y < 2; y++ ) {
submap *destsm = target_bay.get_submap_at_grid( { x, y, target.z } );
for( size_t z = 0; z < destsm->vehicles.size(); z++ ) {
possible_vehicles.push_back( destsm->vehicles[z] );
for( auto vehicle : destsm->vehicles ) {
possible_vehicles.push_back( vehicle );
}
}
}
@@ -1997,9 +1996,9 @@ bool editmap::mapgen_veh_destroy( const tripoint &omt_tgt, vehicle *car_target )
for( int x = 0; x < 2; x++ ) {
for( int y = 0; y < 2; y++ ) {
submap *destsm = target_bay.get_submap_at_grid( { x, y, target.z } );
for( size_t z = 0; z < destsm->vehicles.size(); z++ ) {
if( destsm->vehicles[z] == car_target ) {
auto veh = destsm->vehicles[z];
for( auto &z : destsm->vehicles ) {
if( z == car_target ) {
auto veh = z;
std::unique_ptr<vehicle> old_veh = target_bay.detach_vehicle( veh );
g->m.clear_vehicle_cache( omt_tgt.z );
g->m.reset_vehicle_cache( omt_tgt.z );
@@ -1082,7 +1082,8 @@ bool effect::activated( const time_point &when, std::string arg, int val, bool r
// mod multiplies the overall percentage chances

// has to be an && here to avoid undefined behavior of turn % 0
if( tick > 0 && ( when - calendar::time_of_cataclysm ) % time_duration::from_turns( tick ) == 0 ) {
if( tick > 0 &&
( when - calendar::time_of_cataclysm ) % time_duration::from_turns( tick ) == 0_turns ) {
if( bot_base != 0 && bot_scale != 0 ) {
if( bot_base + bot_scale == 0 ) {
// Special crash avoidance case, in most effect fields 0 = "nothing happens"
@@ -1443,11 +1443,11 @@ void basecamp::craft_construction( npc &p, const std::string &cur_id, const std:
const std::string &type, const std::string &miss_id )
{
std::map<std::string, std::string> recipes = recipe_deck( type );
for( auto it = recipes.begin(); it != recipes.end(); ++it ) {
if( cur_id != cur_dir + it->first ) {
for( auto &r : recipes ) {
if( cur_id != cur_dir + r.first ) {
continue;
}
const recipe &making = recipe_id( it->second ).obj();
const recipe &making = recipe_id( r.second ).obj();
inventory total_inv = g->u.crafting_inventory();

if( !making.requirements().can_make_with_inventory( total_inv, 1 ) ) {
@@ -1546,7 +1546,7 @@ static std::pair<size_t, std::string> farm_action( const tripoint &omt_tgt, farm
seed_inv.push_back( tmp_seed );
}
}
used_seed.front().set_age( 0 );
used_seed.front().set_age( 0_turns );
farm_map.add_item_or_charges( pos, used_seed.front() );
farm_map.set( pos, t_dirt, f_plant_seed );
}
@@ -1816,9 +1816,9 @@ bool basecamp::menial_return( npc &p )
tripoint p_ammo = sort_points[ static_cast<size_t>( sort_pt_ids::ammo ) ];

//This prevents the loop from getting stuck on the piles in the open
for( size_t spi = 0; spi < sort_points.size() ; spi++ ) {
if( g->m.furn( sort_points[ spi ] ) == f_null ) {
g->m.furn_set( sort_points[ spi ], f_ash );
for( tripoint &sort_point : sort_points ) {
if( g->m.furn( sort_point ) == f_null ) {
g->m.furn_set( sort_point, f_ash );
}
}
for( const tripoint &tmp : g->m.points_in_radius( g->u.pos(), 72 ) ) {
@@ -1860,9 +1860,9 @@ bool basecamp::menial_return( npc &p )
g->m.i_clear( tmp );
}
//Undo our hack!
for( size_t spi = 0; spi < sort_points.size() ; spi++ ) {
if( g->m.furn( sort_points[ spi ] ) == f_ash ) {
g->m.furn_set( sort_points[ spi ], f_null );
for( tripoint &sort_point : sort_points ) {
if( g->m.furn( sort_point ) == f_ash ) {
g->m.furn_set( sort_point, f_null );
}
}
return true;
@@ -1960,7 +1960,7 @@ void basecamp::fortifications_return( npc &p )
if( om_i == "forest_thick" ) {
om_i = "forest";
}
edit.mapgen_set( om_i, pt, false );
edit.mapgen_set( om_i, pt, 0, false );
}
}
//Add fences
@@ -2529,10 +2529,10 @@ mass_volume om_harvest_itm( npc_ptr comp, const tripoint &omt_tgt, int chance, b
{
tinymap target_bay;
target_bay.load( omt_tgt.x * 2, omt_tgt.y * 2, omt_tgt.z, false );
units::mass harvested_m = 0;
units::volume harvested_v = 0;
units::mass total_m = 0;
units::volume total_v = 0;
units::mass harvested_m = 0_gram;
units::volume harvested_v = 0_ml;
units::mass total_m = 0_gram;
units::volume total_v = 0_ml;
tripoint mapmin = tripoint( 0, 0, omt_tgt.z );
tripoint mapmax = tripoint( 2 * SEEX - 1, 2 * SEEY - 1, omt_tgt.z );
for( const tripoint &p : target_bay.points_in_rectangle( mapmin, mapmax ) ) {
@@ -2749,8 +2749,8 @@ int om_carry_weight_to_trips( units::mass mass, units::volume volume,

int om_carry_weight_to_trips( const std::vector<item *> &itms, npc_ptr comp )
{
units::mass total_m = 0;
units::volume total_v = 0;
units::mass total_m = 0_gram;
units::volume total_v = 0_ml;
for( auto &i : itms ) {
total_m += i->weight( true );
total_v += i->volume( true );
@@ -3139,11 +3139,11 @@ std::string camp_car_description( vehicle *car )
}
std::map<itype_id, long> fuels = car->fuels_left();
entry += _( "---- Fuel Storage & Battery ----\n" );
for( std::map<itype_id, long>::iterator it = fuels.begin(); it != fuels.end(); ++it ) {
std::string fuel_entry = string_format( "%d/%d", car->fuel_left( it->first ),
car->fuel_capacity( it->first ) );
entry += string_format( ">%s:%*s\n", item( it->first ).tname(),
33 - item( it->first ).tname().length(), fuel_entry );
for( auto &fuel : fuels ) {
std::string fuel_entry = string_format( "%d/%d", car->fuel_left( fuel.first ),
car->fuel_capacity( fuel.first ) );
entry += string_format( ">%s:%*s\n", item( fuel.first ).tname(),
33 - item( fuel.first ).tname().length(), fuel_entry );
}
for( auto &pt : car->parts ) {
if( pt.is_battery() ) {
@@ -1081,8 +1081,8 @@ bool map::process_fields_in_submap( submap *const current_submap,
if( cur.getFieldAge() < -500_minutes ) {
maximum_density = 3;
} else {
for( size_t i = 0; i < neighs.size(); i++ ) {
if( neighs[i].get_field().findField( fd_fire ) != nullptr ) {
for( auto &neigh : neighs ) {
if( neigh.get_field().findField( fd_fire ) != nullptr ) {
adjacent_fires++;
}
}
@@ -1682,8 +1682,8 @@ void map::player_in_field( player &u )
// Iterate through all field effects on this tile.
// Do not remove the field with removeField, instead set it's density to 0. It will be removed
// later by the field processing, which will also adjust field_count accordingly.
for( auto field_list_it = curfield.begin(); field_list_it != curfield.end(); ++field_list_it ) {
field_entry &cur = field_list_it->second;
for( auto &field_list_it : curfield ) {
field_entry &cur = field_list_it.second;
if( !cur.isAlive() ) {
continue;
}
@@ -2162,8 +2162,8 @@ void map::monster_in_field( monster &z )
// Iterate through all field effects on this tile.
// Do not remove the field with removeField, instead set it's density to 0. It will be removed
// later by the field processing, which will also adjust field_count accordingly.
for( auto field_list_it = curfield.begin(); field_list_it != curfield.end(); ++field_list_it ) {
field_entry &cur = field_list_it->second;
for( auto &field_list_it : curfield ) {
field_entry &cur = field_list_it.second;
if( !cur.isAlive() ) {
continue;
}
@@ -341,7 +341,7 @@ std::vector<std::string> get_files_from_path( const std::string &pattern,
* Find directories which containing pattern.
* @param pattern Search pattern.
* @param root_path Search root.
* @param recurse Be recurse or not.
* @param recursive_search Be recurse or not.
* @return vector or directories without pattern filename at end.
*/
std::vector<std::string> get_directories_with( const std::string &pattern,
@@ -47,7 +47,7 @@ std::vector<std::string> get_directories_with( const std::vector<std::string> &p
const std::string &root_path = "", bool recursive_search = false );

std::vector<std::string> get_directories_with( const std::string &pattern,
const std::string &root_path = "", const bool recurse = false );
const std::string &root_path = "", const bool recursive_search = false );

bool copy_file( const std::string &source_path, const std::string &dest_path );

@@ -6023,7 +6023,7 @@ bool pet_menu( monster *z )

if( attach_bag == choice ) {
int pos = g->inv_for_filter( _( "Bag item" ), []( const item & it ) {
return it.is_armor() && it.get_storage() > 0;
return it.is_armor() && it.get_storage() > 0_ml;
} );

if( pos == INT_MIN ) {
@@ -6086,12 +6086,12 @@ bool pet_menu( monster *z )
}
}

if( max_weight <= 0 ) {
if( max_weight <= 0_gram ) {
add_msg( _( "%1$s is overburdened. You can't transfer your %2$s." ),
pet_name.c_str(), it.tname( 1 ).c_str() );
return true;
}
if( max_cap <= 0 ) {
if( max_cap <= 0_ml ) {
add_msg( _( "There's no room in your %1$s's %2$s for that, it's too bulky!" ),
pet_name.c_str(), it.tname( 1 ).c_str() );
return true;
@@ -6301,7 +6301,7 @@ const std::string get_fire_fuel_string( const tripoint &examp )
// half-life inclusion
int mod = 5 - g->u.get_skill_level( skill_survival );
mod = std::max( mod, 0 );
if( fire_age >= 0 ) {
if( fire_age >= 0_turns ) {
if( mod >= 4 ) { // = survival level 0-1
ss << string_format( _( "It's going to go out soon without extra fuel." ) );
return ss.str();
@@ -8252,7 +8252,7 @@ game::vmenu_ret game::list_items( const std::vector<map_item_stack> &item_list )
}

const bool bDrawLeft = ground_items.empty() || filtered_items.empty();
draw_custom_border( w_item_info, bDrawLeft, true, false, true, LINE_XOXO, LINE_XOXO, true, true );
draw_custom_border( w_item_info, bDrawLeft, 1, 0, 1, LINE_XOXO, LINE_XOXO, 1, 1 );
wrefresh( w_items );
wrefresh( w_item_info );
catacurses::refresh();
@@ -10576,9 +10576,9 @@ bool game::walk_move( const tripoint &dest_loc )
if( u.is_hauling() ) {
u.assign_activity( activity_id( "ACT_MOVE_ITEMS" ) );
// Whether the source is inside a vehicle (not supported)
u.activity.values.push_back( false );
u.activity.values.push_back( 0 );
// Whether the destination is inside a vehicle (not supported)
u.activity.values.push_back( false );
u.activity.values.push_back( 0 );
// Source relative to the player
u.activity.placement = u.pos() - dest_loc;
// Destination relative to the player
@@ -11008,7 +11008,7 @@ bool game::grabbed_furn_move( const tripoint &dp )

int str_req = furntype.move_str_req;
// Factor in weight of items contained in the furniture.
units::mass furniture_contents_weight = 0;
units::mass furniture_contents_weight = 0_gram;
for( auto &contained_item : m.i_at( fpos ) ) {
furniture_contents_weight += contained_item.weight();
}
@@ -789,7 +789,7 @@ class game
* These are helper functions for transfer liquid, for times when you just want to
* get the target of the transfer, or know the target and just want to transfer the
* liquid. They take the same arguments as handle_liquid, plus
* @param liquid_target structure containing information about the target
* @param target structure containing information about the target
*/
bool get_liquid_target( item &liquid, item *const source, const int radius,
const tripoint *source_pos, const vehicle *const source_veh,
@@ -149,7 +149,7 @@ class armor_inventory_preset: public inventory_selector_preset
}, _( "ENCUMBRANCE" ) );

append_cell( [ this ]( const item_location & loc ) {
return loc->get_storage() > 0 ? string_format( "<%s>%s</color>", color,
return loc->get_storage() > 0_ml ? string_format( "<%s>%s</color>", color,
format_volume( loc->get_storage() ) ) : std::string();
}, _( "STORAGE" ) );

@@ -380,7 +380,7 @@ class comestible_inventory_preset : public inventory_selector_preset

append_cell( [ this ]( const item_location & loc ) {
const time_duration spoils = get_edible_comestible( loc ).spoils;
if( spoils > 0 ) {
if( spoils > 0_turns ) {
return to_string_clipped( spoils );
}
//~ Used for permafood shelf life in the Eat menu
@@ -390,7 +390,7 @@ class comestible_inventory_preset : public inventory_selector_preset
append_cell( [this]( const item_location & loc ) {
if( g->u.can_estimate_rot() ) {
const islot_comestible item = get_edible_comestible( loc );
if( item.spoils > 0 ) {
if( item.spoils > 0_turns ) {
return get_freshness( loc );
}
return std::string( "---" );
@@ -401,7 +401,7 @@ class comestible_inventory_preset : public inventory_selector_preset
append_cell( [ this ]( const item_location & loc ) {
if( g->u.can_estimate_rot() ) {
const islot_comestible item = get_edible_comestible( loc );
if( item.spoils > 0 ) {
if( item.spoils > 0_turns ) {
if( !get_comestible_item( loc ).rotten() ) {
return get_time_left_rounded( loc );
}
@@ -169,8 +169,8 @@ void gates::open_gate( const tripoint &pos )
continue;
}

for( int j = 0; j < 4; ++j ) {
const tripoint gate_pos = wall_pos + dir[j];
for( auto j : dir ) {
const tripoint gate_pos = wall_pos + j;

if( gate_pos == pos ) {
continue; // Never comes back
@@ -181,7 +181,7 @@ void gates::open_gate( const tripoint &pos )
while( g->m.ter( cur_pos ) == gate.floor.id() ) {
fail = !g->forced_door_closing( cur_pos, gate.door.id(), gate.bash_dmg ) || fail;
close = !fail;
cur_pos += dir[j];
cur_pos += j;
}
}

@@ -196,7 +196,7 @@ void gates::open_gate( const tripoint &pos )
} else if( ter != gate.floor.id() ) {
break;
}
cur_pos += dir[j];
cur_pos += j;
}
}
}
@@ -1754,7 +1754,7 @@ void iexamine::plant_seed( player &p, const tripoint &examp, const itype_id &see
} else {
used_seed = p.use_amount( seed_id, 1 );
}
used_seed.front().set_age( 0 );
used_seed.front().set_age( 0_turns );
g->m.add_item_or_charges( examp, used_seed.front() );
g->m.set( examp, t_dirt, f_plant_seed );
p.moves -= 500;
@@ -2059,7 +2059,7 @@ void iexamine::kiln_empty(player &p, const tripoint &examp)
int loss = 60 - 2 * skill; // We can afford to be inefficient - logs and skeletons are cheap, charcoal isn't

// Burn stuff that should get charred, leave out the rest
units::volume total_volume = 0;
units::volume total_volume = 0_ml;
for( const item &i : items ) {
total_volume += i.volume();
}
@@ -2115,7 +2115,7 @@ void iexamine::kiln_full(player &, const tripoint &examp)
add_msg( _("There's a charcoal kiln there.") );
const time_duration firing_time = 6_hours; // 5 days in real life
const time_duration time_left = firing_time - items[0].age();
if( time_left > 0 ) {
if( time_left > 0_turns ) {
int hours = to_hours<int>( time_left );
int minutes = to_minutes<int>( time_left ) + 1;
if( minutes > 60 ) {
@@ -2130,7 +2130,7 @@ void iexamine::kiln_full(player &, const tripoint &examp)
return;
}

units::volume total_volume = 0;
units::volume total_volume = 0_ml;
// Burn stuff that should get charred, leave out the rest
for( auto item_it = items.begin(); item_it != items.end(); ) {
if( item_it->typeId() == "unfinished_charcoal" || item_it->typeId() == "charcoal" ) {
@@ -2266,7 +2266,7 @@ void iexamine::fvat_empty(player &p, const tripoint &examp)
}
}
if (vat_full || ferment) {
g->m.i_at( examp ).front().set_age( 0 );
g->m.i_at( examp ).front().set_age( 0_turns );
g->m.furn_set(examp, f_fvat_full);
if (vat_full) {
add_msg(_("The vat is full, so you close the lid and start the fermenting cycle."));
@@ -2357,15 +2357,15 @@ static units::volume get_keg_capacity( const tripoint &pos ) {
if( furn.id == "f_standing_tank" ) { return units::from_liter( 300 ); }
else if( furn.id == "f_wood_keg" ) { return units::from_liter( 125 ); }
//add additional cases above
else { return 0; }
else { return 0_ml; }
}

/**
* Check whether there is a keg on the map that can be filled via @ref pour_into_keg.
*/
bool iexamine::has_keg( const tripoint &pos )
{
return get_keg_capacity( pos ) > 0;
return get_keg_capacity( pos ) > 0_ml;
}

void iexamine::keg(player &p, const tripoint &examp)
@@ -2531,7 +2531,7 @@ void iexamine::keg(player &p, const tripoint &examp)
bool iexamine::pour_into_keg( const tripoint &pos, item &liquid )
{
const units::volume keg_cap = get_keg_capacity( pos );
if( keg_cap <= 0 ) {
if( keg_cap <= 0_ml ) {
return false;
}
const auto keg_name = g->m.name( pos );
@@ -2824,24 +2824,24 @@ void iexamine::recycle_compactor( player &, const tripoint &examp )

// check inputs and tally total mass
auto inputs = g->m.i_at( examp );
units::mass sum_weight = 0;
units::mass sum_weight = 0_gram;
auto ca = m.compact_accepts();
std::set<material_id> accepts( ca.begin(), ca.end() );
accepts.insert( m.id );
for( auto it = inputs.begin(); it != inputs.end(); ++it ) {
if( !it->only_made_of( accepts ) ) {
for( auto &input : inputs ) {
if( !input.only_made_of( accepts ) ) {
//~ %1$s: an item in the compactor , %2$s: desired compactor output material
add_msg( _( "You realize this isn't going to work because %1$s is not made purely of %2$s." ),
it->tname().c_str(), m.name().c_str() );
input.tname().c_str(), m.name().c_str() );
return;
}
if( it->is_container() && !it->is_container_empty() ) {
if( input.is_container() && !input.is_container_empty() ) {
//~ %1$s: an item in the compactor
add_msg( _( "You realize this isn't going to work because %1$s has not been emptied of its contents." ),
it->tname().c_str() );
input.tname().c_str() );
return;
}
sum_weight += it->weight();
sum_weight += input.weight();
}
if( sum_weight <= 0 ) {
//~ %1$s: desired compactor output material
@@ -3585,8 +3585,7 @@ player &best_installer( player &p, player &null_player, int difficulty )
{
float player_skill = p.bionics_adjusted_skill( skill_firstaid,
skill_computer,
skill_electronics,
true );
skill_electronics );

std::vector< std::pair<float, long>> ally_skills;
ally_skills.reserve( g->allies().size() );
@@ -3598,8 +3597,7 @@ player &best_installer( player &p, player &null_player, int difficulty )
ally_skill.second = i;
ally_skill.first = ally.bionics_adjusted_skill( skill_firstaid,
skill_computer,
skill_electronics,
true );
skill_electronics );
ally_skills.push_back( ally_skill );
}
std::sort( ally_skills.begin(), ally_skills.end(), [&]( const std::pair<float, long> &lhs,
@@ -3824,7 +3822,7 @@ void smoker_activate(player &p, const tripoint &examp)
bool food_present = false;
bool charcoal_present = false;
auto items = g->m.i_at( examp );
units::volume food_volume = 0;
units::volume food_volume = 0_ml;
item *charcoal = nullptr;

for( size_t i = 0; i < items.size(); i++ ) {
@@ -4128,10 +4126,10 @@ void iexamine::smoker_options( player &p, const tripoint &examp )

bool rem_f_opt = false;
std::stringstream pop;
time_duration time_left = 0;
time_duration time_left = 0_turns;
int hours_left = 0;
int minutes_left = 0;
units::volume f_volume = 0;
units::volume f_volume = 0_ml;
bool f_check = false;

for( size_t i = 0; i < items_here.size(); i++ ) {
@@ -4147,7 +4145,7 @@ void iexamine::smoker_options( player &p, const tripoint &examp )
}
}

const bool empty = f_volume == 0;
const bool empty = f_volume == 0_ml;
const bool full = f_volume >= sm_rack::MAX_FOOD_VOLUME;
const auto remaining_capacity = sm_rack::MAX_FOOD_VOLUME - f_volume;
const auto has_coal_in_inventory = p.charges_of( "charcoal" ) > 0;
@@ -4204,7 +4202,7 @@ void iexamine::smoker_options( player &p, const tripoint &examp )
{
if ( active ) {
pop << "<color_green>" << _( "There's a smoking rack here. It is lit and smoking." ) << "</color>" << "\n";
if( time_left > 0 ) {
if( time_left > 0_turns ) {
if( minutes_left > 60 ) {
pop << string_format( ngettext( "It will finish smoking in about %d hour.",
"It will finish smoking in about %d hours.",
@@ -108,8 +108,8 @@ invslice inventory::slice()
const_invslice inventory::const_slice() const
{
const_invslice stacks;
for( auto iter = items.cbegin(); iter != items.cend(); ++iter ) {
stacks.push_back( &*iter );
for( const auto &item : items ) {
stacks.push_back( &item );
}
return stacks;
}
@@ -309,9 +309,8 @@ void inventory::restack( player &p )
const int ipos = p.invlet_to_position( topmost.invlet );
if( !inv_chars.valid( topmost.invlet ) || ( ipos != INT_MIN && ipos != idx ) ) {
assign_empty_invlet( topmost, p );
for( std::list<item>::iterator stack_iter = stack.begin();
stack_iter != stack.end(); ++stack_iter ) {
stack_iter->invlet = topmost.invlet;
for( auto &stack_iter : stack ) {
stack_iter.invlet = topmost.invlet;
}
}

@@ -600,9 +599,9 @@ item inventory::remove_item( const int position )
std::list<item> inventory::remove_randomly_by_volume( const units::volume &volume )
{
std::list<item> result;
units::volume volume_dropped = 0;
units::volume volume_dropped = 0_ml;
while( volume_dropped < volume ) {
units::volume cumulative_volume = 0;
units::volume cumulative_volume = 0_ml;
auto chosen_stack = items.begin();
auto chosen_item = chosen_stack->begin();
for( auto stack = items.begin(); stack != items.end(); ++stack ) {
@@ -870,7 +869,7 @@ void inventory::rust_iron_items()

units::mass inventory::weight() const
{
units::mass ret = 0;
units::mass ret = 0_gram;
for( const auto &elem : items ) {
for( const auto &elem_stack_iter : elem ) {
ret += elem_stack_iter.weight();
@@ -933,7 +932,7 @@ units::mass inventory::weight_without( const std::map<const item *, int> &withou

units::volume inventory::volume() const
{
units::volume ret = 0;
units::volume ret = 0_ml;
for( const auto &elem : items ) {
for( const auto &elem_stack_iter : elem ) {
ret += elem_stack_iter.volume();
@@ -77,7 +77,7 @@ class selection_column_preset: public inventory_selector_preset
public:
selection_column_preset() {}

virtual std::string get_caption( const inventory_entry &entry ) const override {
std::string get_caption( const inventory_entry &entry ) const override {
std::ostringstream res;
const size_t available_count = entry.get_available_count();
if( entry.chosen_count > 0 && entry.chosen_count < available_count ) {
@@ -101,7 +101,7 @@ class selection_column_preset: public inventory_selector_preset
return res.str();
}

virtual nc_color get_color( const inventory_entry &entry ) const override {
nc_color get_color( const inventory_entry &entry ) const override {
if( &*entry.location == &g->u.weapon ) {
return c_light_blue;
} else if( g->u.is_worn( *entry.location ) ) {
@@ -1983,5 +1983,5 @@ inventory_selector::stats inventory_drop_selector::get_raw_stats() const
u.weight_carried_with_tweaks( { dropping } ),
u.weight_capacity(),
u.volume_carried_with_tweaks( { dropping } ),
u.volume_capacity_reduced_by( 0, dropping ) );
u.volume_capacity_reduced_by( 0_ml, dropping ) );
}
@@ -395,18 +395,18 @@ class selection_column : public inventory_column
selection_column( const std::string &id, const std::string &name );
~selection_column() override;

virtual bool activatable() const override {
bool activatable() const override {
return inventory_column::activatable() && pages_count() > 1;
}

virtual bool allows_selecting() const override {
bool allows_selecting() const override {
return false;
}

virtual void prepare_paging( const std::string &filter = "" ) override;
void prepare_paging( const std::string &filter = "" ) override;

virtual void on_change( const inventory_entry &entry ) override;
virtual void on_mode_change( navigation_mode ) override {
void on_change( const inventory_entry &entry ) override;
void on_mode_change( navigation_mode ) override {
// Intentionally ignore mode change.
}

@@ -604,8 +604,8 @@ class inventory_multiselector : public inventory_selector
inventory_multiselector( const player &p, const inventory_selector_preset &preset = default_preset,
const std::string &selection_column_title = "" );
protected:
virtual void rearrange_columns( size_t client_width ) override;
virtual void on_entry_add( const inventory_entry &entry ) override;
void rearrange_columns( size_t client_width ) override;
void on_entry_add( const inventory_entry &entry ) override;

private:
std::unique_ptr<inventory_column> selection_col;
@@ -182,7 +182,7 @@ item::item( const itype *type, time_point turn, long qty ) : type( type ), bday(
}

if( ( type->gun || type->tool ) && !magazine_integral() ) {
set_var( "magazine_converted", true );
set_var( "magazine_converted", 1 );
}

if( !type->snippet_category.empty() ) {
@@ -531,7 +531,7 @@ item item::in_container( const itype_id &cont ) const

long item::charges_per_volume( const units::volume &vol ) const
{
if( type->volume == 0 ) {
if( type->volume == 0_ml ) {
return INFINITE_CHARGES; // TODO: items should not have 0 volume at all!
}
// Type cast to prevent integer overflow with large volume containers like the cargo dimension
@@ -2489,8 +2489,8 @@ std::map<gunmod_location, int> item::get_mod_locations() const
if( !mod->type->gunmod->add_mod.empty() ) {
std::map<gunmod_location, int> add_locations = mod->type->gunmod->add_mod;

for( auto it = add_locations.begin(); it != add_locations.end(); ++it ) {
mod_locations[it->first] += it->second;
for( auto &add_location : add_locations ) {
mod_locations[add_location.first] += add_location.second;
}
}
}
@@ -3106,12 +3106,12 @@ int item::price( bool practical ) const
units::mass item::weight( bool include_contents ) const
{
if( is_null() ) {
return 0;
return 0_gram;
}

// Items that don't drop aren't really there, they're items just for ease of implementation
if( has_flag( "NO_DROP" ) ) {
return 0;
return 0_gram;
}

units::mass ret = units::from_gram( get_var( "weight", to_gram( type->weight ) ) );
@@ -3179,17 +3179,17 @@ units::volume item::corpse_volume( const mtype *corpse ) const
if( has_flag( "GIBBED" ) ) {
corpse_volume *= 0.85;
}
if( corpse_volume > 0 ) {
if( corpse_volume > 0_ml ) {
return corpse_volume;
}
debugmsg( "invalid monster volume for corpse" );
return 0;
return 0_ml;
}

units::volume item::base_volume() const
{
if( is_null() ) {
return 0;
return 0_ml;
}
if( is_corpse() ) {
return corpse_volume( corpse );
@@ -3209,7 +3209,7 @@ units::volume item::base_volume() const
units::volume item::volume( bool integral ) const
{
if( is_null() ) {
return 0;
return 0_ml;
}

if( is_corpse() ) {
@@ -3243,7 +3243,7 @@ units::volume item::volume( bool integral ) const

// Some magazines sit (partly) flush with the item so add less extra volume
if( magazine_current() != nullptr ) {
ret += std::max( magazine_current()->volume() - type->magazine_well, units::volume( 0 ) );
ret += std::max( magazine_current()->volume() - type->magazine_well, 0_ml );
}

if( is_gun() ) {
@@ -3537,7 +3537,7 @@ std::set<matec_id> item::get_techniques() const

bool item::goes_bad() const
{
return is_food() && type->comestible->spoils != 0;
return is_food() && type->comestible->spoils != 0_turns;
}

double item::get_relative_rot() const
@@ -3636,7 +3636,7 @@ units::volume item::get_storage() const
{
auto t = find_armor_data();
if( t == nullptr ) {
return 0;
return 0_ml;
}

return t->storage;
@@ -3676,7 +3676,7 @@ bool item::is_power_armor() const

int item::get_encumber( const Character &p ) const
{
units::volume contents_volume( 0 );
units::volume contents_volume( 0_ml );
for( const auto &e : contents ) {
contents_volume += e.volume();
}
@@ -5852,7 +5852,7 @@ bool item::burn( fire_data &frd )
!mt->burn_into.is_null() && mt->burn_into.is_valid() ) {
corpse = &get_mtype()->burn_into.obj();
// Delay rezing
set_age( 0 );
set_age( 0_turns );
burnt = 0;
return false;
}
@@ -5881,7 +5881,7 @@ bool item::flammable( int threshold ) const
}

int flammability = 0;
units::volume volume_per_turn = 0;
units::volume volume_per_turn = 0_ml;
for( const auto &m : mats ) {
const auto &bd = m->burn_data( 1 );
if( bd.immune ) {
@@ -5899,7 +5899,7 @@ bool item::flammable( int threshold ) const

volume_per_turn /= mats.size();
units::volume vol = base_volume();
if( volume_per_turn > 0 && volume_per_turn < vol ) {
if( volume_per_turn > 0_ml && volume_per_turn < vol ) {
flammability = flammability * volume_per_turn / vol;
} else {
// If it burns well, it provides a bonus here
@@ -5955,7 +5955,7 @@ int item::getlight_emit() const
units::volume item::get_container_capacity() const
{
if( !is_container() ) {
return 0;
return 0_ml;
}
return type->container->contains;
}
@@ -6035,7 +6035,7 @@ long item::get_remaining_capacity_for_liquid( const item &liquid, const Characte

if( res > 0 && !type->rigid && p.inv.has_item( *this ) ) {
const units::volume volume_to_expand = std::max( p.volume_capacity() - p.volume_carried(),
units::volume( 0 ) );
0_ml );

res = std::min( liquid.charges_per_volume( volume_to_expand ), res );

@@ -6290,14 +6290,14 @@ const item_category &item::get_category() const
}

iteminfo::iteminfo( const std::string &Type, const std::string &Name, const std::string &Fmt,
flags f, double Value )
flags Flags, double Value )
{
sType = Type;
sName = replace_colors( Name );
sFmt = replace_colors( Fmt );
is_int = !( f & is_decimal );
is_int = !( Flags & is_decimal );
dValue = Value;
bShowPlus = static_cast<bool>( f & show_plus );
bShowPlus = static_cast<bool>( Flags & show_plus );
std::stringstream convert;
if( bShowPlus ) {
convert << std::showpos;
@@ -6309,9 +6309,9 @@ iteminfo::iteminfo( const std::string &Type, const std::string &Name, const std:
}
convert << std::fixed << Value;
sValue = convert.str();
bNewLine = !( f & no_newline );
bLowerIsBetter = static_cast<bool>( f & lower_is_better );
bDrawName = !( f & no_name );
bNewLine = !( Flags & no_newline );
bLowerIsBetter = static_cast<bool>( Flags & lower_is_better );
bDrawName = !( Flags & no_name );
}

iteminfo::iteminfo( const std::string &Type, const std::string &Name, double Value )
@@ -7198,7 +7198,7 @@ bool item::is_seed() const
time_duration item::get_plant_epoch() const
{
if( !type->seed ) {
return 0;
return 0_turns;
}
// Growing times have been based around real world season length rather than
// the default in-game season length to give
@@ -153,11 +153,11 @@ struct iteminfo {
* @param Type The item type of the item this iteminfo belongs to.
* @param Name The name of the property this iteminfo describes.
* @param Fmt Formatting text desired between item name and value
* @param flags Additional flags to customize this entry
* @param Flags Additional flags to customize this entry
* @param Value Numerical value of this property, -999 for none.
*/
iteminfo( const std::string &Type, const std::string &Name, const std::string &Fmt = "",
flags = no_flags, double Value = -999 );
flags Flags = no_flags, double Value = -999 );
iteminfo( const std::string &Type, const std::string &Name, double Value );
};

@@ -727,7 +727,7 @@ class item : public visitable<item>
* It is compared to shelf life (@ref islot_comestible::spoils) to decide if
* the item is rotten.
*/
time_duration rot = 0;
time_duration rot = 0_turns;
/** Time when the rot calculation was last performed. */
time_point last_rot_check = calendar::time_of_cataclysm;

@@ -167,7 +167,7 @@ void Item_factory::finalize_pre( itype &obj )
obj.price_post = obj.price;
}
// use base volume if integral volume unspecified
if( obj.integral_volume < 0 ) {
if( obj.integral_volume < 0_ml ) {
obj.integral_volume = obj.volume;
}
// for ammo and comestibles stack size defaults to count of initial charges
@@ -184,7 +184,7 @@ void Item_factory::finalize_pre( itype &obj )
// Items always should have some volume.
// TODO: handle possible exception software?
// TODO: make items with 0 volume an error during loading?
if( obj.volume <= 0 ) {
if( obj.volume <= 0_ml ) {
obj.volume = units::from_milliliter( 1 );
}
for( const auto &tag : obj.item_tags ) {
@@ -811,10 +811,10 @@ void Item_factory::check_definitions() const
msg << "undefined category " << type->category_force << "\n";
}

if( type->weight < 0 ) {
if( type->weight < 0_gram ) {
msg << "negative weight" << "\n";
}
if( type->volume < 0 ) {
if( type->volume < 0_ml ) {
msg << "negative volume" << "\n";
}
if( type->price < 0 ) {
@@ -952,7 +952,7 @@ void Item_factory::check_definitions() const
msg << "specified magazine but none provided for default ammo type" << "\n";
}
}
if( type->gun->barrel_length < 0 ) {
if( type->gun->barrel_length < 0_ml ) {
msg << "gun barrel length cannot be negative" << "\n";
}

@@ -1077,7 +1077,7 @@ void Item_factory::check_definitions() const
msg << string_format( "Resealable container unseals_into %s",
type->container->unseals_into.c_str() ) << "\n";
}
if( type->container->contains <= 0 ) {
if( type->container->contains <= 0_ml ) {
msg << string_format( "\"contains\" (%d) must be >0", type->container->contains.value() ) << "\n";
}
if( !has_template( type->container->unseals_into ) ) {
@@ -1388,7 +1388,7 @@ void Item_factory::load( islot_gun &slot, JsonObject &jo, const std::string &src
assign( jo, "reload", slot.reload_time, strict, 0 );
assign( jo, "reload_noise", slot.reload_noise, strict );
assign( jo, "reload_noise_volume", slot.reload_noise_volume, strict, 0 );
assign( jo, "barrel_length", slot.barrel_length, strict, 0 );
assign( jo, "barrel_length", slot.barrel_length, strict, 0_ml );
assign( jo, "built_in_mods", slot.built_in_mods, strict );
assign( jo, "default_mods", slot.default_mods, strict );
assign( jo, "ups_charges", slot.ups_charges, strict, 0 );
@@ -1434,7 +1434,7 @@ void Item_factory::load( islot_armor &slot, JsonObject &jo, const std::string &s
assign( jo, "environmental_protection", slot.env_resist, strict, 0 );
assign( jo, "environmental_protection_with_filter", slot.env_resist_w_filter, strict, 0 );
assign( jo, "warmth", slot.warmth, strict, 0 );
assign( jo, "storage", slot.storage, strict, 0 );
assign( jo, "storage", slot.storage, strict, 0_ml );
assign( jo, "power_armor", slot.power_armor, strict );

assign_coverage_from_json( jo, "covers", slot.covers, slot.sided );
@@ -1871,7 +1871,7 @@ void Item_factory::load_basic_info( JsonObject &jo, itype &def, const std::strin
bool strict = src == "dda";

assign( jo, "category", def.category_force, strict );
assign( jo, "weight", def.weight, strict, 0 );
assign( jo, "weight", def.weight, strict, 0_gram );
assign( jo, "volume", def.volume );
assign( jo, "price", def.price );
assign( jo, "price_postapoc", def.price_post );
@@ -220,7 +220,7 @@ class Single_item_creator : public Item_spawn_data

void inherit_ammo_mag_chances( const int ammo, const int mag );

virtual ItemList create( const time_point &birthday, RecursionList &rec ) const override;
ItemList create( const time_point &birthday, RecursionList &rec ) const override;
item create_single( const time_point &birthday, RecursionList &rec ) const override;
void check_consistency() const override;
bool remove_item( const Item_tag &itemid ) override;
@@ -263,7 +263,7 @@ class Item_group : public Item_spawn_data
*/
void add_entry( std::unique_ptr<Item_spawn_data> ptr );

virtual ItemList create( const time_point &birthday, RecursionList &rec ) const override;
ItemList create( const time_point &birthday, RecursionList &rec ) const override;
item create_single( const time_point &birthday, RecursionList &rec ) const override;
void check_consistency() const override;
bool remove_item( const Item_tag &itemid ) override;
@@ -46,7 +46,7 @@ std::function<bool( const item & )> basic_item_filter( std::string filter )
case 'd'://disassembled components
return [filter]( const item & i ) {
const auto &components = i.get_uncraft_components();
for( auto component : components ) {
for( auto &component : components ) {
if( lcmatch( component.to_string(), filter ) ) {
return true;
}
@@ -76,7 +76,7 @@ item &item_stack::operator[]( size_t index )

units::volume item_stack::stored_volume() const
{
units::volume ret = 0;
units::volume ret = 0_ml;
for( const item &it : *mystack ) {
ret += it.volume();
}
@@ -25,7 +25,7 @@ std::string itype::nname( unsigned int quantity ) const

long itype::charges_per_volume( const units::volume &vol ) const
{
if( volume == 0 ) {
if( volume == 0_ml ) {
return item::INFINITE_CHARGES; // TODO: items should not have 0 volume at all!
}
return ( stackable ? stack_size : 1 ) * vol / volume;
@@ -140,7 +140,7 @@ struct islot_comestible {
int nutr = 0;

/** Time until becomes rotten at standard temperature, or zero if never spoils */
time_duration spoils = 0;
time_duration spoils = 0_turns;

/** addiction potential */
int addict = 0;
@@ -184,14 +184,14 @@ struct islot_brewable {
std::vector<std::string> results;

/** How long for this brew to ferment. */
time_duration time = 0;
time_duration time = 0_turns;
};

struct islot_container {
/**
* Inner volume of the container.
*/
units::volume contains = 0;
units::volume contains = 0_ml;
/**
* Can be resealed.
*/
@@ -249,7 +249,7 @@ struct islot_armor {
/**
* How much storage this items provides when worn.
*/
units::volume storage = 0;
units::volume storage = 0_ml;
/**
* Whether this is a power armor item.
*/
@@ -442,7 +442,7 @@ struct islot_gun : common_ranged_data {
/**
* Length of gun barrel, if positive allows sawing down of the barrel
*/
units::volume barrel_length = 0;
units::volume barrel_length = 0_ml;
/**
* Effects that are applied to the ammo when fired.
*/
@@ -649,7 +649,7 @@ struct islot_seed {
/**
* Time it takes for a seed to grow (based of off a season length of 91 days).
*/
time_duration grow = 0;
time_duration grow = 0_turns;
/**
* Amount of harvested charges of fruits is divided by this number.
*/
@@ -792,14 +792,14 @@ struct itype {
/**@{*/

/** Weight of item ( or each stack member ) */
units::mass weight = 0;
units::mass weight = 0_gram;

/**
* Space occupied by items of this type
* CAUTION: value given is for a default-sized stack. Avoid using where @ref stackable items may be encountered; see @ref item::volume instead.
* To determine how many of an item can fit in a given space, use @ref charges_per_volume.
*/
units::volume volume = 0;
units::volume volume = 0_ml;
/**
* Space consumed when integrated as part of another item (defaults to volume)
* CAUTION: value given is for a default-sized stack. Avoid using this. In general, see @ref item::volume instead.
@@ -847,7 +847,7 @@ struct itype {
std::map< ammotype, itype_id > magazine_default;

/** Volume above which the magazine starts to protrude from the item and add extra volume */
units::volume magazine_well = 0;
units::volume magazine_well = 0_ml;

layer_level layer;

@@ -1818,7 +1818,7 @@ int iuse::fish_trap( player *p, item *it, bool t, const tripoint &pos )
return 0;
}
it->active = true;
it->set_age( 0 );
it->set_age( 0_turns );
g->m.add_item_or_charges( pnt, *it );
p->i_rem( it );
p->add_msg_if_player( m_info,
@@ -3293,7 +3293,7 @@ int iuse::firecracker_pack( player *p, item *it, bool, const tripoint & )
p->add_msg_if_player( _( "You light the pack of firecrackers." ) );
it->convert( "firecracker_pack_act" );
it->charges = 26;
it->set_age( 0 );
it->set_age( 0_turns );
it->active = true;
return 0; // don't use any charges at all. it has became a new item
}
@@ -7643,7 +7643,7 @@ int iuse::washclothes( player *p, item *, bool, const tripoint & )
auto make_raw_stats = [available_water, available_cleanser](
const std::map<const item *, int> &items
) {
units::volume total_volume = 0;
units::volume total_volume = 0_ml;
for( const auto &p : items ) {
total_volume += p.first->volume() * p.second;
}
@@ -7676,7 +7676,7 @@ int iuse::washclothes( player *p, item *, bool, const tripoint & )
}

// Determine if we have enough water and cleanser for all the items.
units::volume total_volume = 0;
units::volume total_volume = 0_ml;
for( std::pair<int, int> pair : to_clean ) {
item i = p->i_at( pair.first );
if( pair.first == INT_MIN ) {
@@ -418,11 +418,11 @@ long unfold_vehicle_iuse::use( player &p, item &it, bool /*t*/, const tripoint &
return 0;
}

for( auto tool = tools_needed.cbegin(); tool != tools_needed.cend(); ++tool ) {
for( const auto &tool : tools_needed ) {
// Amount == -1 means need one, but don't consume it.
if( !p.has_amount( tool->first, 1 ) ) {
if( !p.has_amount( tool.first, 1 ) ) {
p.add_msg_if_player( _( "You need %s to do it!" ),
item::nname( tool->first ).c_str() );
item::nname( tool.first ).c_str() );
return 0;
}
}
@@ -553,24 +553,23 @@ long consume_drug_iuse::use( player &p, item &it, bool, const tripoint & ) const
need_these.erase( "syringe" ); // no need for a syringe with bionics like these!
}
// Check prerequisites first.
for( auto tool = need_these.cbegin(); tool != need_these.cend(); ++tool ) {
for( const auto &tool : need_these ) {
// Amount == -1 means need one, but don't consume it.
if( !p.has_amount( tool->first, 1 ) ) {
if( !p.has_amount( tool.first, 1 ) ) {
p.add_msg_player_or_say( _( "You need %1$s to consume %2$s!" ),
_( "I need a %1$s to consume %2$s!" ),
item::nname( tool->first ).c_str(),
item::nname( tool.first ).c_str(),
it.type_name( 1 ).c_str() );
return -1;
}
}
for( auto consumable = charges_needed.cbegin(); consumable != charges_needed.cend();
++consumable ) {
for( const auto &consumable : charges_needed ) {
// Amount == -1 means need one, but don't consume it.
if( !p.has_charges( consumable->first, ( consumable->second == -1 ) ?
1 : consumable->second ) ) {
if( !p.has_charges( consumable.first, ( consumable.second == -1 ) ?
1 : consumable.second ) ) {
p.add_msg_player_or_say( _( "You need %1$s to consume %2$s!" ),
_( "I need a %1$s to consume %2$s!" ),
item::nname( consumable->first ).c_str(),
item::nname( consumable.first ).c_str(),
it.type_name( 1 ).c_str() );
return -1;
}
@@ -585,14 +584,14 @@ long consume_drug_iuse::use( player &p, item &it, bool, const tripoint & ) const
}
p.add_effect( eff.id, dur, eff.bp, eff.permanent );
}
for( auto stat = stat_adjustments.cbegin(); stat != stat_adjustments.cend(); ++stat ) {
p.mod_stat( stat->first, stat->second );
for( const auto &stat_adjustment : stat_adjustments ) {
p.mod_stat( stat_adjustment.first, stat_adjustment.second );
}
for( auto field = fields_produced.cbegin(); field != fields_produced.cend(); ++field ) {
const field_id fid = field_from_ident( field->first );
for( const auto &field : fields_produced ) {
const field_id fid = field_from_ident( field.first );
for( int i = 0; i < 3; i++ ) {
g->m.add_field( {p.posx() + int( rng( -2, 2 ) ), p.posy() + int( rng( -2, 2 ) ), p.posz()}, fid,
field->second );
field.second );
}
}

@@ -606,10 +605,9 @@ long consume_drug_iuse::use( player &p, item &it, bool, const tripoint & ) const
// Output message.
p.add_msg_if_player( _( activation_message.c_str() ), it.type_name( 1 ) );
// Consume charges.
for( auto consumable = charges_needed.cbegin(); consumable != charges_needed.cend();
++consumable ) {
if( consumable->second != -1 ) {
p.use_charges( consumable->first, consumable->second );
for( const auto &consumable : charges_needed ) {
if( consumable.second != -1 ) {
p.use_charges( consumable.first, consumable.second );
}
}

@@ -2075,7 +2073,7 @@ bool holster_actor::can_holster( const item &obj ) const
if( obj.volume() > max_volume || obj.volume() < min_volume ) {
return false;
}
if( max_weight > 0 && obj.weight() > max_weight ) {
if( max_weight > 0_gram && obj.weight() > max_weight ) {
return false;
}
if( obj.active ) {
@@ -2107,7 +2105,7 @@ bool holster_actor::store( player &p, item &holster, item &obj ) const
return false;
}

if( max_weight > 0 && obj.weight() > max_weight ) {
if( max_weight > 0_gram && obj.weight() > max_weight ) {
p.add_msg_if_player( m_info, _( "Your %1$s is too heavy to fit in your %2$s" ),
obj.tname().c_str(), holster.tname().c_str() );
return false;
@@ -2132,7 +2130,7 @@ bool holster_actor::store( player &p, item &holster, item &obj ) const
obj.tname().c_str(), holster.tname().c_str() );

// holsters ignore penalty effects (e.g. GRABBED) when determining number of moves to consume
p.store( holster, obj, draw_cost, false );
p.store( holster, obj, false, draw_cost );
return true;
}

@@ -2209,7 +2207,7 @@ void holster_actor::info( const item &, std::vector<iteminfo> &dump ) const
iteminfo::is_decimal,
convert_volume( max_volume.value() ) );

if( max_weight > 0 ) {
if( max_weight > 0_gram ) {
dump.emplace_back( "TOOL", "Max item weight: ",
string_format( _( "<num> %s" ), weight_units() ),
iteminfo::is_decimal,
@@ -3558,7 +3556,7 @@ ret_val<bool> saw_barrel_actor::can_use_on( const player &, const item &, const
return ret_val<bool>::make_failure( _( "It's not a gun." ) );
}

if( target.type->gun->barrel_length <= 0 ) {
if( target.type->gun->barrel_length <= 0_ml ) {
return ret_val<bool>::make_failure( _( "The barrel is too short." ) );
}

@@ -645,7 +645,7 @@ class musical_instrument_actor : public iuse_actor
/**
* Display description once per this duration (@ref calendar::once_every).
*/
time_duration description_frequency = 0;
time_duration description_frequency = 0_turns;

musical_instrument_actor( const std::string &type = "musical_instrument" ) : iuse_actor( type ) {}

@@ -128,7 +128,7 @@ void minesweeper_game::new_level( const catacurses::window &w_minesweeper )

mvwputch( w_minesweeper, iOffsetY, iOffsetX, hilite( c_white ), "#" );

draw_custom_border( w_minesweeper, true, true, true, true, true, true, true, true,
draw_custom_border( w_minesweeper, 1, 1, 1, 1, 1, 1, 1, 1,
BORDER_COLOR, iOffsetY - 1, iLevelY + 2, iOffsetX - 1, iLevelX + 2 );
}

@@ -93,7 +93,7 @@ void map_stack::insert_at( std::list<item>::iterator index,
units::volume map_stack::max_volume() const
{
if( !myorigin->inbounds( location ) ) {
return 0;
return 0_ml;
} else if( myorigin->has_furn( location ) ) {
return myorigin->furn( location ).obj().max_volume;
}
@@ -4391,7 +4391,7 @@ static void process_vehicle_items( vehicle &cur_veh, int part )
const time_duration washing_time = 90_minutes;
const time_duration time_left = washing_time - n.age();
static const std::string filthy( "FILTHY" );
if( time_left <= 0 ) {
if( time_left <= 0_turns ) {
n.item_tags.erase( filthy );
washing_machine_finished = true;
cur_veh.parts[part].enabled = false;
@@ -5319,8 +5319,8 @@ void map::remove_field( const tripoint &p, const field_id field_to_remove )
// Only adjust the count if the field actually existed.
current_submap->field_count--;
const auto &fdata = fieldlist[ field_to_remove ];
for( int i = 0; i < 3; ++i ) {
if( !fdata.transparent[i] ) {
for( bool i : fdata.transparent ) {
if( !i ) {
set_transparency_cache_dirty( p.z );
break;
}
@@ -6622,7 +6622,7 @@ void map::fill_funnels( const tripoint &p, const time_point &since )
return;
}
auto items = i_at( p );
units::volume maxvolume = 0;
units::volume maxvolume = 0_ml;
auto biggest_container = items.end();
for( auto candidate = items.begin(); candidate != items.end(); ++candidate ) {
if( candidate->is_funnel_container( maxvolume ) ) {
@@ -6711,7 +6711,7 @@ void map::restock_fruits( const tripoint &p, const time_duration &time_since_las

void map::produce_sap( const tripoint &p, const time_duration &time_since_last_actualize )
{
if( time_since_last_actualize <= 0 ) {
if( time_since_last_actualize <= 0_turns ) {
return;
}

@@ -6728,7 +6728,7 @@ void map::produce_sap( const tripoint &p, const time_duration &time_since_last_a
const time_duration turns_to_produce = producing_length / ( maple_sap_per_season * 4 );

// How long of this time_since_last_actualize have we been in the producing period (late winter, early spring)?
time_duration time_producing = 0;
time_duration time_producing = 0_turns;

if( time_since_last_actualize >= calendar::year_length() ) {
time_producing = producing_length;
@@ -1063,7 +1063,7 @@ class map
/**
* Set age of field entry at point.
* @param p Location of field
* @param t ID of field
* @param type ID of field
* @param age New age of specified field
* @param isoffset If true, the given age value is added to the existing value,
* if false, the existing age is ignored and overridden.
@@ -1075,7 +1075,7 @@ class map
* Set density of field entry at point, creating if not present,
* removing if density becomes 0.
* @param p Location of field
* @param t ID of field
* @param type ID of field
* @param str New strength of field
* @param isoffset If true, the given str value is added to the existing value,
* if false, the existing density is ignored and overridden.
@@ -358,7 +358,7 @@ void mx_roadblock( map &m, const tripoint &abs_sub )

int splatter_range = rng( 1, 3 );
for( int j = 0; j <= splatter_range; j++ ) {
m.add_field( {p->x - ( j * 1 ), p->y + ( j * 1 ), p->z}, fd_blood, 1, 0 );
m.add_field( {p->x - ( j * 1 ), p->y + ( j * 1 ), p->z}, fd_blood, 1, 0_turns );
}
}
}
@@ -381,7 +381,7 @@ void mx_roadblock( map &m, const tripoint &abs_sub )

int splatter_range = rng( 1, 3 );
for( int j = 0; j <= splatter_range; j++ ) {
m.add_field( {p->x + ( j * 1 ), p->y - ( j * 1 ), p->z}, fd_blood, 1, 0 );
m.add_field( {p->x + ( j * 1 ), p->y - ( j * 1 ), p->z}, fd_blood, 1, 0_turns );
}
}
}
@@ -454,7 +454,7 @@ void mx_drugdeal( map &m, const tripoint &abs_sub )
int splatter_range = rng( 1, 3 );
for( int j = 0; j <= splatter_range; j++ ) {
m.add_field( {x + ( j * x_offset ), y + ( j * y_offset ), abs_sub.z},
fd_blood, 1, 0 );
fd_blood, 1, 0_turns );
}
}
if( a_has_drugs && num_drugs > 0 ) {
@@ -496,7 +496,7 @@ void mx_drugdeal( map &m, const tripoint &abs_sub )
int splatter_range = rng( 1, 3 );
for( int j = 0; j <= splatter_range; j++ ) {
m.add_field( {x + ( j * x_offset ), y + ( j * y_offset ), abs_sub.z},
fd_blood, 1, 0 );
fd_blood, 1, 0_turns );
}
if( !a_has_drugs && num_drugs > 0 ) {
int drugs_placed = rng( 2, 6 );
@@ -654,7 +654,7 @@ void mx_portal_in( map &m, const tripoint &abs_sub )
}
};
int x = rng( 5, SEEX * 2 - 6 ), y = rng( 5, SEEY * 2 - 6 );
m.add_field( {x, y, abs_sub.z}, fd_fatigue, 3, 0 );
m.add_field( {x, y, abs_sub.z}, fd_fatigue, 3, 0_turns );
fungal_effects fe( *g, m );
for( int i = x - 5; i <= x + 5; i++ ) {
for( int j = y - 5; j <= y + 5; j++ ) {
@@ -702,7 +702,7 @@ void mx_spider( map &m, const tripoint &abs_sub )
bool should_web_tree = m.has_flag_ter( "TREE", location ) && !one_in( 4 );

if( should_web_flat || should_web_shrub || should_web_tree ) {
m.add_field( location, fd_web, rng( 1, 3 ), 0 );
m.add_field( location, fd_web, rng( 1, 3 ), 0_turns );
}
}
}
@@ -48,10 +48,10 @@ class map_memory
void memorize_tile( int limit, const tripoint &pos, const std::string &ter,
const int subtile, const int rotation );
/** Returns last stored map tile in given location */
memorized_terrain_tile get_tile( const tripoint &p ) const;
memorized_terrain_tile get_tile( const tripoint &pos ) const;

void memorize_symbol( int limit, const tripoint &pos, const long symbol );
long get_symbol( const tripoint &p ) const;
long get_symbol( const tripoint &pos ) const;
private:
lru_cache<memorized_terrain_tile> tile_cache;
lru_cache<long> symbol_cache;
@@ -1392,9 +1392,9 @@ class jmapgen_nested : public jmapgen_piece
}
};

jmapgen_objects::jmapgen_objects( int off_x, int off_y, size_t mapsize_x, size_t mapsize_y )
: offset_x( off_x )
, offset_y( off_y )
jmapgen_objects::jmapgen_objects( int offset_x, int offset_y, size_t mapsize_x, size_t mapsize_y )
: offset_x( offset_x )
, offset_y( offset_y )
, mapgensize_x( mapsize_x )
, mapgensize_y( mapsize_y )
{}
@@ -50,7 +50,7 @@ class mapgen_function_builtin : public virtual mapgen_function
mapgen_function_builtin( building_gen_pointer ptr, int w = 1000 ) : mapgen_function( w ),
fptr( ptr ) {
}
void generate( map *m, const oter_id &o, const mapgendata &mgd, const time_point &i,
void generate( map *m, const oter_id &terrain_type, const mapgendata &mgd, const time_point &t,
float d ) override;
};

@@ -68,12 +68,12 @@ struct jmapgen_int {
/**
* Throws as usually if the json is invalid or missing.
*/
jmapgen_int( JsonObject &jso, const std::string &key );
jmapgen_int( JsonObject &jo, const std::string &tag );
/**
* Throws is the json is malformed (e.g. a string not an integer, but does not throw
* if the member is just missing (the default values are used instead).
*/
jmapgen_int( JsonObject &jso, const std::string &key, short def_val, short def_valmax );
jmapgen_int( JsonObject &jo, const std::string &tag, short def_val, short def_valmax );

int get() const;
};
@@ -163,7 +163,7 @@ class jmapgen_place
jmapgen_place() : x( 0, 0 ), y( 0, 0 ), repeat( 1, 1 ) { }
jmapgen_place( const int a, const int b ) : x( a ), y( b ), repeat( 1, 1 ) { }
jmapgen_place( JsonObject &jsi );
void offset( const int x, const int y );
void offset( const int x_offset, const int y_offset );
jmapgen_int x;
jmapgen_int y;
jmapgen_int repeat;
@@ -191,7 +191,7 @@ class mapgen_palette
* Load (append to format_placings) the places that should be put there.
* member_name is the name of an optional object / array in the json object jsi.
*/
void load_place_mapings( JsonObject &jsi, const std::string &member_name,
void load_place_mapings( JsonObject &jo, const std::string &member_name,
placing_map &format_placings );
/**
* Loads a palette object and returns it. Doesn't save it anywhere.
@@ -222,7 +222,7 @@ class mapgen_palette

struct jmapgen_objects {

jmapgen_objects( int offset_x, int offset_y, size_t size_x, size_t size_y );
jmapgen_objects( int offset_x, int offset_y, size_t mapsize_x, size_t mapsize_x_y );

bool check_bounds( const jmapgen_place place, JsonObject &jso );

@@ -348,7 +348,7 @@ std::shared_ptr<mapgen_function> load_mapgen_function( JsonObject &jio, const st
* Load the above directly from a file via init, as opposed to riders attached to overmap_terrain. Added check
* for oter_mapgen / oter_mapgen_weights key, multiple possible ( ie, [ "house", "house_base" ] )
*/
void load_mapgen( JsonObject &jio );
void load_mapgen( JsonObject &jo );
void reset_mapgens();
/*
* stores function ref and/or required data
@@ -4324,7 +4324,7 @@ void mtrap_set( map *m, int x, int y, trap_id type )
void madd_field( map *m, int x, int y, field_id type, int density )
{
tripoint actual_location( x, y, m->get_abs_sub().z );
m->add_field( actual_location, type, density, 0 );
m->add_field( actual_location, type, density, 0_turns );
}

bool is_suitable_for_stairs( const map *const m, const tripoint &p )
@@ -40,8 +40,8 @@ class format_effect
std::vector<ID> determiners;

public:
format_effect( std::string characters,
std::vector<ID> determiners );
format_effect( std::string chars,
std::vector<ID> dets );

ID translate( char c ) const;
};
@@ -33,7 +33,7 @@ mission mission_type::create( const int npc_id ) const
ret.monster_type = monster_type;
ret.monster_kill_goal = monster_kill_goal;

if( deadline_low != 0 || deadline_high != 0 ) {
if( deadline_low != 0_turns || deadline_high != 0_turns ) {
ret.deadline = calendar::turn + rng( deadline_low, deadline_high );
} else {
ret.deadline = 0;
@@ -957,7 +957,7 @@ void talk_function::field_plant( npc &p, const std::string &place )
} else {
used_seed = g->u.use_amount( seed_id, 1 );
}
used_seed.front().set_age( 0 );
used_seed.front().set_age( 0_turns );
bay.add_item_or_charges( x, y, used_seed.front() );
bay.set( x, y, t_dirt, f_plant_seed );
limiting_number--;
@@ -77,14 +77,15 @@ void companion_mission( npc & );
* Send a companion on an individual mission or attaches them to a group to depart later
* Set @ref submap_coords and @ref pos.
* @param desc is the description in the popup window
* @param id is the value stored with the NPC when it is offloaded
* @param miss_id is the value stored with the NPC when it is offloaded
* @param group is whether the NPC is waiting for additional members before departing together
* @param equipment is placed in the NPC's special inventory and dropped when they return
* @param skill_tested is the main skill for the quest
* @param skill_level is checked to prevent lower level NPCs from going on missions
*/
///Send a companion on an individual mission or attaches them to a group to depart later
std::shared_ptr<npc> individual_mission( npc &p, const std::string &desc, const std::string &id,
std::shared_ptr<npc> individual_mission( npc &p, const std::string &desc,
const std::string &miss_id,
bool group = false, const std::vector<item *> &equipment = {},
const std::string &skill_tested = "", int skill_level = 0 );

@@ -265,7 +265,7 @@ void mission_start::infect_npc( mission *miss )
debugmsg( "couldn't find an NPC!" );
return;
}
p->add_effect( effect_infection, 1_turns, num_bp, true, true );
p->add_effect( effect_infection, 1_turns, num_bp, true, 1 );
// make sure they don't have any antibiotics
p->remove_items_with( []( const item & it ) {
return it.typeId() == "antibiotics";
@@ -381,8 +381,8 @@ void MonsterGroupManager::LoadMonsterGroup( JsonObject &jo )
pack_max = packarr.next_int();
}
static const time_duration tdfactor = 1_hours;
time_duration starts = 0;
time_duration ends = 0;
time_duration starts = 0_turns;
time_duration ends = 0_turns;
if( mon.has_member( "starts" ) ) {
starts = tdfactor * mon.get_int( "starts" ) * ( mon_upgrade_factor > 0 ? mon_upgrade_factor : 1 );
}
@@ -41,7 +41,7 @@ struct MonsterGroupEntry {
time_duration starts;
time_duration ends;
bool lasts_forever() const {
return ( ends <= 0 );
return ( ends <= 0_turns );
}

MonsterGroupEntry( const mtype_id &id, int new_freq, int new_cost,
@@ -77,7 +77,7 @@ struct MonsterGroup {
// time when exploring an unexplored portion of the map
bool replace_monster_group;
mongroup_id new_monster_group;
time_duration monster_group_time = 0;
time_duration monster_group_time = 0_turns;
bool is_safe; /// Used for @ref mongroup::is_safe()
int freq_total; // Default 1000 unless specified - max number to roll for spawns
};
@@ -2056,7 +2056,7 @@ void monster::process_one_effect( effect &it, bool is_new )
if( dam > 0 ) {
apply_damage( nullptr, bp_torso, dam );
} else {
it.set_duration( 0 );
it.set_duration( 0_turns );
}
} else if( id == effect_run ) {
effect_cache[FLEEING] = true;
@@ -2507,7 +2507,7 @@ void monster::on_load()
// Possible TODO: Integrate monster upgrade
const time_duration dt = calendar::turn - last_updated;
last_updated = calendar::turn;
if( dt <= 0 ) {
if( dt <= 0_turns ) {
return;
}

@@ -340,7 +340,7 @@ class monster : public Creature
// Get torso - monsters don't have body parts (yet?)
body_part get_random_body_part( bool main ) const override;
/** Returns vector containing all body parts this monster has. That is, { bp_torso } */
std::vector<body_part> get_all_body_parts( bool main = false ) const override;
std::vector<body_part> get_all_body_parts( bool only_main = false ) const override;

/** Resets a given special to its monster type cooldown value */
void reset_special( const std::string &special_name );
@@ -154,7 +154,7 @@ void player_morale::morale_point::add( const int new_bonus, const int new_max_bo
}

bonus = normalize_bonus( get_net_bonus() + new_bonus, new_max_bonus, new_cap );
age = 0; // Brand new. The assignment should stay below get_net_bonus() and pick_time().
age = 0_turns; // Brand new. The assignment should stay below get_net_bonus() and pick_time().
}

time_duration player_morale::morale_point::pick_time( const time_duration current_time,
@@ -431,7 +431,7 @@ void player_morale::display( double focus_gain )
const morale_mult mult = get_temper_mult();

int line = 0;
for( size_t i = offset; i < static_cast<unsigned int>( rows_total ); ++i ) {
for( size_t i = offset; i < static_cast<size_t>( rows_total ); ++i ) {
const std::string name = points[i].get_name();
const int bonus = points[i].get_net_bonus( mult );

@@ -1416,7 +1416,7 @@ void npc::shop_restock()
units::volume total_space = volume_capacity();
std::list<item> ret;

while( total_space > 0 && !one_in( 50 ) ) {
while( total_space > 0_ml && !one_in( 50 ) ) {
item tmpit = item_group::item_from( from, 0 );
if( !tmpit.is_null() && total_space >= tmpit.volume() ) {
ret.push_back( tmpit );
@@ -2077,7 +2077,7 @@ void npc::on_load()
update_body( cur, cur + 1_turns );
}

if( dt > 0 ) {
if( dt > 0_turns ) {
// This ensures food is properly rotten at load
// Otherwise NPCs try to eat rotten food and fail
process_active_items();
@@ -492,7 +492,7 @@ class npc : public player

// Save & load
void load_info( std::string data ) override; // Overloaded from player
virtual std::string save_info() const override;
std::string save_info() const override;

void deserialize( JsonIn &jsin ) override;
void serialize( JsonOut &jsout ) const override;
@@ -1903,7 +1903,7 @@ void npc::find_item()

const bool whitelisting = has_item_whitelist();

if( volume_allowed <= 0 || weight_allowed <= 0 ) {
if( volume_allowed <= 0_ml || weight_allowed <= 0_gram ) {
return;
}

@@ -2296,7 +2296,7 @@ bool npc::find_corpse_to_pulp()
if( it.can_revive() ) {
// If the first encountered corpse bleeds something dangerous then
// it is not safe to bash.
if( is_dangerous_field( field_entry( it.get_mtype()->bloodType(), 1, 0 ) ) ) {
if( is_dangerous_field( field_entry( it.get_mtype()->bloodType(), 1, 0_turns ) ) ) {
return nullptr;
}

@@ -3142,7 +3142,7 @@ std::string give_item_to( npc &p, bool allow_use, bool allow_carry )
reason << std::endl;
reason << string_format( _( "I have no space to store it." ) );
reason << std::endl;
if( free_space > 0 ) {
if( free_space > 0_ml ) {
reason << string_format( _( "I can only store %s %s more." ),
format_volume( free_space ), volume_units_long() );
} else {
@@ -34,7 +34,6 @@ void buy_shave( npc & );
void morale_chat( npc & );
void buy_10_logs( npc & );
void buy_100_logs( npc & );
void give_equipment( npc & );
void start_trade( npc & );
void assign_base( npc & );
void assign_guard( npc & );
@@ -56,9 +55,6 @@ void stranger_neutral( npc & ); // p is now neutral towards you
void start_mugging( npc & );
void player_leaving( npc & );

void start_mugging( npc & );
void player_leaving( npc & );

void drop_weapon( npc & );
void player_weapon_away( npc & );
void player_weapon_drop( npc & );
@@ -225,7 +225,7 @@ TAB key to switch lists, letters to pick items, Enter to finalize, Esc to quit,\

volume_left = p.volume_capacity() - p.volume_carried_with_tweaks( { temp } );
weight_left = p.weight_capacity() - p.weight_carried_with_tweaks( { temp } );
mvwprintz( w_head, 3, 2, ( volume_left < 0 || weight_left < 0 ) ? c_red : c_green,
mvwprintz( w_head, 3, 2, ( volume_left < 0_ml || weight_left < 0_gram ) ? c_red : c_green,
_( "Volume: %s %s, Weight: %.1f %s" ),
format_volume( volume_left ).c_str(), volume_units_abbr(),
convert_weight( weight_left ), weight_units() );
@@ -343,7 +343,7 @@ TAB key to switch lists, letters to pick items, Enter to finalize, Esc to quit,\
format_money( -cash ) );
update = true;
ch = ' ';
} else if( volume_left < 0 || weight_left < 0 ) {
} else if( volume_left < 0_ml || weight_left < 0_gram ) {
// Make sure NPC doesn't go over allowed volume
popup( _( "%s can't carry all that." ), p.name.c_str() );
update = true;
@@ -144,7 +144,7 @@ bool get_scent_glyph( const tripoint &pos, nc_color &ter_color, long &ter_sym )
color_manager &color_list = get_all_colors();
int i = 0;
time_duration scent_age = calendar::turn - possible_scent.creation_time;
while( i < num_colors && scent_age > 0 ) {
while( i < num_colors && scent_age > 0_turns ) {
i++;
scent_age /= 10;
}
@@ -23,7 +23,7 @@ void set_standard_filenames();
* @param extension File name extension, is automatically added to the path
* of the translated file. Can be empty, but must otherwise include the
* initial '.', e.g. ".json"
* @param defaultid The path id of the fallback filename. As like pathid it's
* @param fallbackid The path id of the fallback filename. As like pathid it's
* the key into the @ref FILENAMES map. It is used if no translated file can be
* found.
*/
@@ -993,7 +993,7 @@ void Pickup::pick_up( const tripoint &p, int min )

draw_item_info( w_item_info, "", "", vThisItem, vDummy, iScrollPos, true, true );
}
draw_custom_border( w_item_info, false );
draw_custom_border( w_item_info, 0 );
mvwprintw( w_item_info, 0, 2, "< " );
trim_and_print( w_item_info, 0, 4, itemsW - 8, c_white, "%s >",
selected_item.display_name().c_str() );
@@ -1109,8 +1109,8 @@ void Pickup::pick_up( const tripoint &p, int min )
for( int i = 9; i < pickupW; ++i ) {
mvwaddch( w_pickup, 0, i, ' ' );
}
units::mass weight_picked_up = 0;
units::volume volume_picked_up = 0;
units::mass weight_picked_up = 0_gram;
units::volume volume_picked_up = 0_ml;
for( size_t i = 0; i < getitem.size(); i++ ) {
if( getitem[i].pick ) {
item temp = stacked_here[i].begin()->_item;
@@ -85,6 +85,8 @@
#include <sstream>
#include <limits>

constexpr double SQRT_2 = 1.41421356237309504880;

const double MAX_RECOIL = 3000;

const mtype_id mon_player_blob( "mon_player_blob" );
@@ -1867,7 +1869,7 @@ int player::run_cost( int base_cost, bool diag ) const
movecost /= stamina_modifier;

if( diag ) {
movecost *= 1.4142;
movecost *= SQRT_2;
}

return int( movecost );
@@ -6390,7 +6392,7 @@ void player::vomit()
}

if( !has_effect( effect_nausea ) ) { // Prevents never-ending nausea
const effect dummy_nausea( &effect_nausea.obj(), 0, num_bp, false, 1, calendar::turn );
const effect dummy_nausea( &effect_nausea.obj(), 0_turns, num_bp, false, 1, calendar::turn );
add_effect( effect_nausea, std::max( dummy_nausea.get_max_duration() * stomach_contents / 21,
dummy_nausea.get_int_dur_factor() ) );
}
@@ -967,7 +967,7 @@ void player::hardcoded_effects( effect &it )
body_part_name( bp ).c_str() );
add_effect( effect_recover, 4 * dur );
// Set ourselves up for removal
it.set_duration( 0 );
it.set_duration( 0_turns );
recovered = true;
}
}
@@ -997,7 +997,7 @@ void player::hardcoded_effects( effect &it )
if( can_sleep() ) {
fall_asleep();
// Set ourselves up for removal
it.set_duration( 0 );
it.set_duration( 0_turns );
}
if( dur == 1_turns && !sleeping ) {
add_msg_if_player( _( "You try to sleep, but can't..." ) );
@@ -1118,7 +1118,7 @@ void player::hardcoded_effects( effect &it )
one_in( get_fatigue() / 2 ) ) ) {
add_msg_if_player( _( "It's too bright to sleep." ) );
// Set ourselves up for removal
it.set_duration( 0 );
it.set_duration( 0_turns );
woke_up = true;
}
// Ursine hibernators would likely do so indoors. Plants, though, might be in the sun.
@@ -1127,22 +1127,22 @@ void player::hardcoded_effects( effect &it )
one_in( get_fatigue() / 2 ) ) ) {
add_msg_if_player( _( "It's too bright to sleep." ) );
// Set ourselves up for removal
it.set_duration( 0 );
it.set_duration( 0_turns );
woke_up = true;
}
} else if( tirednessVal < g->m.ambient_light_at( pos() ) && ( get_fatigue() < 10 ||
one_in( get_fatigue() / 2 ) ) ) {
add_msg_if_player( _( "It's too bright to sleep." ) );
// Set ourselves up for removal
it.set_duration( 0 );
it.set_duration( 0_turns );
woke_up = true;
}
} else if( has_active_mutation( trait_id( "SEESLEEP" ) ) ) {
Creature *hostile_critter = g->is_hostile_very_close();
if( hostile_critter != nullptr ) {
add_msg_if_player( _( "You see %s approaching!" ),
hostile_critter->disp_name().c_str() );
it.set_duration( 0 );
it.set_duration( 0_turns );
woke_up = true;
}
}
@@ -1161,7 +1161,7 @@ void player::hardcoded_effects( effect &it )
one_in( temp_cur[bp] + 5000 ) ) {
add_msg_if_player( m_bad, _( "It's too cold to sleep." ) );
// Set ourselves up for removal
it.set_duration( 0 );
it.set_duration( 0_turns );
woke_up = true;
break;
}
@@ -1173,7 +1173,7 @@ void player::hardcoded_effects( effect &it )
one_in( 15000 - temp_cur[bp] ) ) {
add_msg_if_player( m_bad, _( "It's too hot to sleep." ) );
// Set ourselves up for removal
it.set_duration( 0 );
it.set_duration( 0_turns );
woke_up = true;
break;
}
@@ -1199,7 +1199,7 @@ void player::hardcoded_effects( effect &it )
}
}
}
it.set_duration( 0 );
it.set_duration( 0_turns );
woke_up = true;
}
}
@@ -1218,7 +1218,7 @@ void player::hardcoded_effects( effect &it )
} else {
add_msg_if_player( m_warning, _( "It looks like you've slept through the alarm..." ) );
}
get_effect( effect_slept_through_alarm ).set_duration( 0 );
get_effect( effect_slept_through_alarm ).set_duration( 0_turns );
}
}
} else if( id == effect_alarm_clock ) {
@@ -1272,7 +1272,7 @@ void player::hardcoded_effects( effect &it )
} else if( id == effect_mending ) {
// @todo: Remove this and encapsulate hp_cur instead
if( hp_cur[bp_to_hp( bp )] > 0 ) {
it.set_duration( 0 );
it.set_duration( 0_turns );
}
} else if( id == effect_disabled ) {
// @todo: Remove this and encapsulate hp_cur instead
@@ -356,7 +356,7 @@ void recipe_dictionary::finalize()
const recipe_id rid = recipe_id( id );

// books that don't already have an uncrafting recipe
if( e->book && !recipe_dict.uncraft.count( rid ) && e->volume > 0 ) {
if( e->book && !recipe_dict.uncraft.count( rid ) && e->volume > 0_ml ) {
int pages = e->volume / units::from_milliliter( 12.5 );
auto &bk = recipe_dict.uncraft[rid];
bk.ident_ = rid;
@@ -66,7 +66,7 @@ extern recipe_dictionary recipe_dict;
class recipe_subset
{
public:
recipe_subset( void ) = default;
recipe_subset() = default;
recipe_subset( const recipe_subset &src, const std::vector<const recipe *> &recipes );
/**
* Include a recipe to the subset.
@@ -160,7 +160,7 @@ std::vector<item> item::magazine_convert()
// normalize the base item and mark it as converted
charges = 0;
curammo = nullptr;
set_var( "magazine_converted", true );
set_var( "magazine_converted", 1 );

return res;
}
@@ -1716,7 +1716,7 @@ time_duration time_duration::read_from_json_string( JsonIn &jsin )
if( skip_spaces() ) {
error( "invalid time duration string: empty string" );
}
time_duration result = 0;
time_duration result = 0_turns;
do {
int sign_value = +1;
if( s[i] == '-' ) {
@@ -2889,12 +2889,12 @@ void basecamp::serialize( JsonOut &json ) const
json.end_array();
json.member( "expansions" );
json.start_array();
for( auto it = expansions.begin(); it != expansions.end(); ++it ) {
for( const auto &expansion : expansions ) {
json.start_object();
json.member( "dir", it->first );
json.member( "type", it->second.type );
json.member( "cur_level", it->second.cur_level );
json.member( "pos", it->second.pos );
json.member( "dir", expansion.first );
json.member( "type", expansion.second.type );
json.member( "cur_level", expansion.second.cur_level );
json.member( "pos", expansion.second.pos );
json.end_object();
}
json.end_array();
@@ -117,7 +117,7 @@ class CachedTTFFont : public Font {
CachedTTFFont( int w, int h, std::string typeface, int fontsize, bool fontblending );
~CachedTTFFont() override = default;

virtual void OutputChar(const std::string &ch, int x, int y, unsigned char color) override;
void OutputChar(const std::string &ch, int x, int y, unsigned char color) override;
protected:
SDL_Texture_Ptr create_glyph( const std::string &ch, int color );

@@ -153,9 +153,9 @@ class BitmapFont : public Font {
BitmapFont( int w, int h, const std::string &typeface_path );
~BitmapFont() override = default;

virtual void OutputChar(const std::string &ch, int x, int y, unsigned char color) override;
void OutputChar(const std::string &ch, int x, int y, unsigned char color) override;
void OutputChar(long t, int x, int y, unsigned char color);
virtual void draw_ascii_lines(unsigned char line_id, int drawx, int drawy, int FG) const override;
void draw_ascii_lines(unsigned char line_id, int drawx, int drawy, int FG) const override;
protected:
std::array<SDL_Texture_Ptr, color_loader<SDL_Color>::COLOR_NAMES_COUNT> ascii;
int tilewidth;
@@ -3115,12 +3115,12 @@ BitmapFont::BitmapFont( const int w, const int h, const std::string &typeface_pa
SDL_SetColorKey( asciiload.get(),SDL_TRUE,key );
SDL_Surface_Ptr ascii_surf[std::tuple_size<decltype( ascii )>::value];
ascii_surf[0].reset( SDL_ConvertSurface( asciiload.get(), format.get(), 0 ) );
SDL_SetSurfaceRLE( ascii_surf[0].get(), true );
SDL_SetSurfaceRLE( ascii_surf[0].get(), 1 );
asciiload.reset();

for (size_t a = 1; a < std::tuple_size<decltype( ascii )>::value; ++a) {
ascii_surf[a].reset( SDL_ConvertSurface( ascii_surf[0].get(), format.get(), 0 ) );
SDL_SetSurfaceRLE( ascii_surf[a].get(), true );
SDL_SetSurfaceRLE( ascii_surf[a].get(), 1 );
}

for (size_t a = 0; a < std::tuple_size<decltype( ascii )>::value - 1; ++a) {
@@ -159,9 +159,9 @@ class Trait_group : public Trait_creation_data
*/
virtual void add_entry( std::unique_ptr<Trait_creation_data> &ptr ) = 0;

virtual void check_consistency() const override;
virtual bool remove_trait( const trait_id &tid ) override;
virtual bool has_trait( const trait_id &tid ) const override;
void check_consistency() const override;
bool remove_trait( const trait_id &tid ) override;
bool has_trait( const trait_id &tid ) const override;

protected:
// Links to all entries in this group.
@@ -180,8 +180,8 @@ class Trait_group_collection : public Trait_group
Trait_group_collection( int probability );
~Trait_group_collection() override = default;

virtual trait_group::Trait_list create( RecursionList &rec ) const override;
virtual void add_entry( std::unique_ptr<Trait_creation_data> &ptr ) override;
trait_group::Trait_list create( RecursionList &rec ) const override;
void add_entry( std::unique_ptr<Trait_creation_data> &ptr ) override;
};

/**
@@ -196,8 +196,8 @@ class Trait_group_distribution : public Trait_group
Trait_group( probability ) {}
~Trait_group_distribution() override = default;

virtual trait_group::Trait_list create( RecursionList &rec ) const override;
virtual void add_entry( std::unique_ptr<Trait_creation_data> &ptr ) override;
trait_group::Trait_list create( RecursionList &rec ) const override;
void add_entry( std::unique_ptr<Trait_creation_data> &ptr ) override;
};

#endif
@@ -37,7 +37,7 @@ static const trait_id trait_WINGS_BUTTERFLY( "WINGS_BUTTERFLY" );
// A pit becomes less effective as it fills with corpses.
float pit_effectiveness( const tripoint &p )
{
units::volume corpse_volume = 0;
units::volume corpse_volume = 0_ml;
for( auto &pit_content : g->m.i_at( p ) ) {
if( pit_content.is_corpse() ) {
corpse_volume += pit_content.volume();
@@ -144,6 +144,7 @@ void tutorial_game::pre_action( action_id &act )
case ACTION_QUICKSAVE:
popup( _( "You're saving a tutorial - the tutorial world lacks certain features of normal worlds. "
"Weird things might happen when you load this save. You have been warned." ) );
act = ACTION_NULL;
break;
default:
// Other actions are fine.