From b285a130801aee625fa888df27382e843bf12f84 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Mon, 9 Nov 2020 04:24:16 -0500 Subject: [PATCH] Make time_point( int ) constructor explicit Resolves a TODO on that constructor, and one more TODO elsewhere due to the resulting refactoring. time_point was implicitly convertible from int. This led to unclear code. In particular, the item constructor took a time_point and a quantity, and these two ints appeared adjacent with no obvious way to see what they meant at call sites. Make the constructor explicit, so the conversion is no longer implicit. Update the rest of the code accordingly. In most cases switched from 0 to calendar::turn_zero, which is equivalent. In a couple of places, used start_of_cataclysm instead, when it seemed more appropriate (such as birthday of toilet water). It's possible there are more cases which should have been something other than turn_zero. --- src/activity_item_handling.cpp | 6 ++-- src/basecamp.cpp | 6 ++-- src/bionics.cpp | 6 ++-- src/calendar.h | 3 +- src/cata_tiles.cpp | 4 +-- src/character.cpp | 12 ++++---- src/computer_session.cpp | 4 +-- src/condition.cpp | 2 +- src/game.cpp | 28 +++++++++--------- src/game.h | 2 +- src/gamemode_defense.cpp | 14 +++++---- src/gamemode_tutorial.cpp | 6 ++-- src/handle_action.cpp | 8 +++--- src/iexamine.cpp | 16 +++++------ src/inventory.cpp | 2 +- src/item_group.cpp | 4 +-- src/iuse.cpp | 17 +++++++---- src/iuse_actor.cpp | 2 +- src/map.cpp | 6 ++-- src/map_extras.cpp | 6 ++-- src/mapgen.cpp | 10 +++---- src/material.cpp | 3 +- src/messages.cpp | 8 +++--- src/mission.cpp | 8 +++--- src/mission_end.cpp | 2 +- src/mission_start.cpp | 7 +++-- src/monattack.cpp | 4 +-- src/monexamine.cpp | 2 +- src/monster.cpp | 16 +++++------ src/npc.cpp | 2 +- src/npctalk_funcs.cpp | 4 +-- src/panels.cpp | 2 +- src/savegame.cpp | 4 +-- src/savegame_json.cpp | 16 +++++------ src/vehicle.cpp | 6 ++-- src/vehicle_use.cpp | 8 +++--- src/weather.cpp | 2 +- src/weather_gen.cpp | 2 +- src/wish.cpp | 4 +-- tests/active_item_cache_test.cpp | 2 +- tests/active_item_test.cpp | 4 +-- tests/bionics_test.cpp | 4 +-- tests/crafting_test.cpp | 20 +++++++------ tests/item_test.cpp | 4 +-- tests/itemname_test.cpp | 2 +- tests/iuse_actor_test.cpp | 3 +- tests/iuse_test.cpp | 22 +++++++------- tests/morale_test.cpp | 16 +++++------ tests/npc_talk_test.cpp | 4 +-- tests/npc_test.cpp | 4 +-- tests/overmap_test.cpp | 8 ++++-- tests/player_test.cpp | 2 +- tests/pocket_test.cpp | 24 +++++++++------- tests/reload_option_test.cpp | 25 +++++++++------- tests/reloading_test.cpp | 48 ++++++++++++++++--------------- tests/temperature_test.cpp | 48 +++++++++++++++---------------- tests/vehicle_drag_test.cpp | 2 +- tests/vehicle_efficiency_test.cpp | 2 +- tests/vehicle_interact_test.cpp | 8 +++--- tests/vehicle_ramp_test.cpp | 2 +- tests/visitable_test.cpp | 2 +- tests/weather_test.cpp | 4 +-- 62 files changed, 275 insertions(+), 249 deletions(-) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 7fec3d197f332..f4992e489ce35 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -967,11 +967,11 @@ static bool are_requirements_nearby( const std::vector &loot_spots, if( vp ) { const int veh_battery = vp->vehicle().fuel_left( itype_battery, true ); - item welder( itype_welder, 0 ); + item welder( itype_welder, calendar::turn_zero ); welder.charges = veh_battery; welder.set_flag( flag_PSEUDO ); temp_inv.add_item( welder ); - item soldering_iron( itype_soldering_iron, 0 ); + item soldering_iron( itype_soldering_iron, calendar::turn_zero ); soldering_iron.charges = veh_battery; soldering_iron.set_flag( flag_PSEUDO ); temp_inv.add_item( soldering_iron ); @@ -1597,7 +1597,7 @@ static std::vector> requirements_map( player for( auto it = requirement_map.begin(); it != requirement_map.end(); ) { tripoint pos_here = std::get<0>( *it ); itype_id item_here = std::get<1>( *it ); - item test_item = item( item_here, 0 ); + item test_item = item( item_here, calendar::turn_zero ); if( test_item.has_quality( tool_qual, qual_level ) ) { // it's just this spot that can fulfil the requirement on its own final_map.push_back( std::make_tuple( pos_here, item_here, 1 ) ); diff --git a/src/basecamp.cpp b/src/basecamp.cpp index f1d294449131e..22331e68d7c47 100644 --- a/src/basecamp.cpp +++ b/src/basecamp.cpp @@ -395,7 +395,7 @@ void basecamp::add_resource( const itype_id &camp_resource ) { basecamp_resource bcp_r; bcp_r.fake_id = camp_resource; - item camp_item( bcp_r.fake_id, 0 ); + item camp_item( bcp_r.fake_id, calendar::turn_zero ); bcp_r.ammo_id = camp_item.ammo_default(); resources.emplace_back( bcp_r ); fuel_types.insert( bcp_r.ammo_id ); @@ -589,7 +589,7 @@ std::list basecamp::use_charges( const itype_id &fake_id, int &quantity ) } for( basecamp_resource &bcp_r : resources ) { if( bcp_r.fake_id == fake_id ) { - item camp_item( bcp_r.fake_id, 0 ); + item camp_item( bcp_r.fake_id, calendar::turn_zero ); camp_item.charges = std::min( bcp_r.available, quantity ); quantity -= camp_item.charges; bcp_r.available -= camp_item.charges; @@ -646,7 +646,7 @@ void basecamp::form_crafting_inventory( map &target_map ) } for( basecamp_resource &bcp_r : resources ) { bcp_r.consumed = 0; - item camp_item( bcp_r.fake_id, 0 ); + item camp_item( bcp_r.fake_id, calendar::turn_zero ); camp_item.set_flag( STATIC( flag_str_id( "PSEUDO" ) ) ); if( !bcp_r.ammo_id.is_null() ) { for( basecamp_fuel &bcp_f : fuels ) { diff --git a/src/bionics.cpp b/src/bionics.cpp index 9505b41b9e169..3c84eb12ffea0 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -933,9 +933,9 @@ bool Character::activate_bionic( int b, bool eff_only, bool *close_bionics_ui ) if( choice >= 0 && choice <= 1 ) { item ctr; if( choice == 0 ) { - ctr = item( "remotevehcontrol", 0 ); + ctr = item( "remotevehcontrol", calendar::turn_zero ); } else { - ctr = item( "radiocontrol", 0 ); + ctr = item( "radiocontrol", calendar::turn_zero ); } ctr.charges = units::to_kilojoule( get_power_level() ); int power_use = invoke_item( &ctr ); @@ -2246,7 +2246,7 @@ bool Character::uninstall_bionic( const bionic &target_cbm, monster &installer, return false; } - item bionic_to_uninstall = item( target_cbm.id.str(), 0 ); + item bionic_to_uninstall = item( target_cbm.id.str(), calendar::turn_zero ); const itype *itemtype = bionic_to_uninstall.type; int difficulty = itemtype->bionic->difficulty; int chance_of_success = bionic_manip_cos( adjusted_skill, difficulty + 2 ); diff --git a/src/calendar.h b/src/calendar.h index 22c8c936a1c85..a837bbe7fb008 100644 --- a/src/calendar.h +++ b/src/calendar.h @@ -434,8 +434,7 @@ class time_point public: time_point(); // TODO: make private - // TODO: make explicit - constexpr time_point( const int t ) : turn_( t ) { } + explicit constexpr time_point( const int t ) : turn_( t ) { } public: // TODO: remove this, nobody should need it, one should use a constant `time_point` diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 486d9460bd3dd..f92f23237fa8e 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -1768,9 +1768,9 @@ bool cata_tiles::draw_from_id_string( const std::string &id, TILE_CATEGORY categ } else if( category == C_ITEM ) { item tmp; if( string_starts_with( found_id, "corpse_" ) ) { - tmp = item( itype_corpse, 0 ); + tmp = item( itype_corpse, calendar::turn_zero ); } else { - tmp = item( found_id, 0 ); + tmp = item( found_id, calendar::turn_zero ); } sym = tmp.symbol().empty() ? ' ' : tmp.symbol().front(); col = tmp.color(); diff --git a/src/character.cpp b/src/character.cpp index 81ec80fefbc7b..566777e40cdb1 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -4081,7 +4081,7 @@ void Character::normalize() weary.clear(); martial_arts_data->reset_style(); - weapon = item( "null", 0 ); + weapon = item( "null", calendar::turn_zero ); set_body(); recalc_hp(); @@ -4094,15 +4094,15 @@ void Character::die( Creature *nkiller ) set_killer( nkiller ); set_time_died( calendar::turn ); if( has_effect( effect_lightsnare ) ) { - inv->add_item( item( "string_36", 0 ) ); - inv->add_item( item( "snare_trigger", 0 ) ); + inv->add_item( item( "string_36", calendar::turn_zero ) ); + inv->add_item( item( "snare_trigger", calendar::turn_zero ) ); } if( has_effect( effect_heavysnare ) ) { - inv->add_item( item( "rope_6", 0 ) ); - inv->add_item( item( "snare_trigger", 0 ) ); + inv->add_item( item( "rope_6", calendar::turn_zero ) ); + inv->add_item( item( "snare_trigger", calendar::turn_zero ) ); } if( has_effect( effect_beartrap ) ) { - inv->add_item( item( "beartrap", 0 ) ); + inv->add_item( item( "beartrap", calendar::turn_zero ) ); } mission::on_creature_death( *this ); } diff --git a/src/computer_session.cpp b/src/computer_session.cpp index 45de56afbf86e..5b8fe2f216a95 100644 --- a/src/computer_session.cpp +++ b/src/computer_session.cpp @@ -799,7 +799,7 @@ void computer_session::action_download_software() return; } get_player_character().moves -= 30; - item software( miss->get_item_id(), 0 ); + item software( miss->get_item_id(), calendar::turn_zero ); software.mission_id = comp.mission_id; usb->contents.clear_items(); usb->put_in( software, item_pocket::pocket_type::SOFTWARE ); @@ -840,7 +840,7 @@ void computer_session::action_blood_anal() print_line( _( "Pathogen bonded to erythrocytes and leukocytes." ) ); if( query_bool( _( "Download data?" ) ) ) { if( item *const usb = pick_usb() ) { - item software( "software_blood_data", 0 ); + item software( "software_blood_data", calendar::turn_zero ); usb->contents.clear_items(); usb->put_in( software, item_pocket::pocket_type::SOFTWARE ); print_line( _( "Software downloaded." ) ); diff --git a/src/condition.cpp b/src/condition.cpp index b1a0e9324631d..f0c4d8d2e4edc 100644 --- a/src/condition.cpp +++ b/src/condition.cpp @@ -530,7 +530,7 @@ void conditional_t::set_days_since( const JsonObject &jo ) { const unsigned int days = jo.get_int( "days_since_cataclysm" ); condition = [days]( const T & ) { - return to_turn( calendar::turn ) >= calendar::start_of_cataclysm + 1_days * days; + return calendar::turn >= calendar::start_of_cataclysm + 1_days * days; }; } diff --git a/src/game.cpp b/src/game.cpp index c8d86d1947867..1efaca7b3626b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -622,7 +622,7 @@ void game::setup() weather.nextweather = calendar::start_of_cataclysm + time_duration::from_hours( get_option( "INITIAL_TIME" ) ) + 30_minutes; - turnssincelastmon = 0; //Auto safe mode init + turnssincelastmon = 0_turns; //Auto safe mode init sounds::reset_sounds(); clear_zombies(); @@ -4294,10 +4294,9 @@ void game::mon_info_update( ) const tripoint view = u.pos() + u.view_offset; new_seen_mon.clear(); - static int previous_turn = 0; - // TODO: change current_turn to time_point - const int current_turn = to_turns( calendar::turn - calendar::turn_zero ); - const int sm_ignored_turns = get_option( "SAFEMODEIGNORETURNS" ); + static time_point previous_turn = calendar::turn_zero; + const time_duration sm_ignored_turns = + time_duration::from_turns( get_option( "SAFEMODEIGNORETURNS" ) ); for( Creature *c : u.get_visible_creatures( MAPSIZE_X ) ) { monster *m = dynamic_cast( c ); @@ -4385,12 +4384,13 @@ void game::mon_info_update( ) if( critter.ignoring > 0 ) { if( safe_mode != SAFE_MODE_ON ) { critter.ignoring = 0; - } else if( ( sm_ignored_turns == 0 || ( critter.lastseen_turn && - to_turn( *critter.lastseen_turn ) > current_turn - sm_ignored_turns ) ) && + } else if( ( sm_ignored_turns == time_duration() || + ( critter.lastseen_turn && + *critter.lastseen_turn > calendar::turn - sm_ignored_turns ) ) && ( mon_dist > critter.ignoring / 2 || mon_dist < 6 ) ) { passmon = true; } - critter.lastseen_turn = current_turn; + critter.lastseen_turn = calendar::turn; } if( !passmon ) { @@ -4449,14 +4449,16 @@ void game::mon_info_update( ) } else { cancel_activity_or_ignore_query( distraction_type::hostile_spotted_far, _( "Monsters spotted!" ) ); } - turnssincelastmon = 0; + turnssincelastmon = 0_turns; if( safe_mode == SAFE_MODE_ON ) { set_safe_mode( SAFE_MODE_STOP ); } - } else if( current_turn > previous_turn && get_option( "AUTOSAFEMODE" ) && + } else if( calendar::turn > previous_turn && get_option( "AUTOSAFEMODE" ) && newseen == 0 ) { // Auto-safe mode, but only if it's a new turn - turnssincelastmon += current_turn - previous_turn; - if( turnssincelastmon >= get_option( "AUTOSAFEMODETURNS" ) && safe_mode == SAFE_MODE_OFF ) { + turnssincelastmon += calendar::turn - previous_turn; + time_duration auto_safe_mode = + time_duration::from_turns( get_option( "AUTOSAFEMODETURNS" ) ); + if( turnssincelastmon >= auto_safe_mode && safe_mode == SAFE_MODE_OFF ) { set_safe_mode( SAFE_MODE_ON ); add_msg( m_info, _( "Safe mode ON!" ) ); } @@ -4466,7 +4468,7 @@ void game::mon_info_update( ) set_safe_mode( SAFE_MODE_ON ); } - previous_turn = current_turn; + previous_turn = calendar::turn; mostseen = newseen; } diff --git a/src/game.h b/src/game.h index 8536ef82274db..fd8d8412a546b 100644 --- a/src/game.h +++ b/src/game.h @@ -1020,7 +1020,7 @@ class game //pixel minimap management int pixel_minimap_option = 0; - int turnssincelastmon = 0; // needed for auto run mode + time_duration turnssincelastmon = 0_turns; // needed for auto run mode weather_manager weather; diff --git a/src/gamemode_defense.cpp b/src/gamemode_defense.cpp index 583cab41dcfcd..3e33067a6c21d 100644 --- a/src/gamemode_defense.cpp +++ b/src/gamemode_defense.cpp @@ -979,7 +979,8 @@ void defense_game::caravan() if( current_window == 1 && !items[category_selected].empty() ) { item_count[category_selected][item_selected]++; itype_id tmp_itm = items[category_selected][item_selected]; - total_price += caravan_price( player_character, item( tmp_itm, 0 ).price( false ) ); + total_price += caravan_price( player_character, + item( tmp_itm, calendar::turn_zero ).price( false ) ); if( category_selected == CARAVAN_CART ) { // Find the item in its category for( int i = 1; i < NUM_CARAVAN_CATEGORIES; i++ ) { for( size_t j = 0; j < items[i].size(); j++ ) { @@ -1007,7 +1008,8 @@ void defense_game::caravan() item_count[category_selected][item_selected] > 0 ) { item_count[category_selected][item_selected]--; itype_id tmp_itm = items[category_selected][item_selected]; - total_price -= caravan_price( player_character, item( tmp_itm, 0 ).price( false ) ); + total_price -= caravan_price( player_character, + item( tmp_itm, calendar::turn_zero ).price( false ) ); if( category_selected == CARAVAN_CART ) { // Find the item in its category for( int i = 1; i < NUM_CARAVAN_CATEGORIES; i++ ) { for( size_t j = 0; j < items[i].size(); j++ ) { @@ -1245,7 +1247,7 @@ void draw_caravan_items( const catacurses::window &w, std::vector *ite } // THEN print it--if item_selected is valid if( item_selected < static_cast( items->size() ) ) { - item tmp( ( *items )[item_selected], 0 ); // Dummy item to get info + item tmp( ( *items )[item_selected], calendar::turn_zero ); // Dummy item to get info fold_and_print( w, point( 1, 12 ), 38, c_white, tmp.info() ); } // Next, clear the item list on the right @@ -1260,8 +1262,10 @@ void draw_caravan_items( const catacurses::window &w, std::vector *ite item::nname( ( *items )[i], ( *counts )[i] ) ); wprintz( w, c_white, " x %2d", ( *counts )[i] ); if( ( *counts )[i] > 0 ) { - int price = caravan_price( player_character, item( ( *items )[i], - 0 ).price( false ) * ( *counts )[i] ); + int price = + caravan_price( + player_character, + item( ( *items )[i], calendar::turn_zero ).price( false ) * ( *counts )[i] ); wprintz( w, ( price > player_character.cash ? c_red : c_green ), " (%s)", format_money( price ) ); } } diff --git a/src/gamemode_tutorial.cpp b/src/gamemode_tutorial.cpp index 9b9b6d1021c4c..ae9e80d39596a 100644 --- a/src/gamemode_tutorial.cpp +++ b/src/gamemode_tutorial.cpp @@ -145,7 +145,7 @@ bool tutorial_game::init() starting_om.clear_mon_groups(); player_character.toggle_trait( trait_QUICK ); - item lighter( "lighter", 0 ); + item lighter( "lighter", calendar::turn_zero ); lighter.invlet = 'e'; player_character.inv->add_item( lighter, true, false ); player_character.set_skill_level( skill_gun, 5 ); @@ -279,7 +279,7 @@ void tutorial_game::post_action( action_id act ) break; case ACTION_WEAR: { - item it( player_character.last_item, 0 ); + item it( player_character.last_item, calendar::turn_zero ); if( it.is_armor() ) { if( it.get_avg_coverage() >= 2 || it.get_thickness() >= 2 ) { add_message( tut_lesson::LESSON_WORE_ARMOR ); @@ -301,7 +301,7 @@ void tutorial_game::post_action( action_id act ) add_message( tut_lesson::LESSON_INTERACT ); /* fallthrough */ case ACTION_PICKUP: { - item it( player_character.last_item, 0 ); + item it( player_character.last_item, calendar::turn_zero ); if( it.is_armor() ) { add_message( tut_lesson::LESSON_GOT_ARMOR ); } else if( it.is_gun() ) { diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 9dbf514290245..3ac93d5f9444b 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -919,16 +919,16 @@ static void wait() add_menu_item( 7, 'd', setting_alarm ? _( "Set alarm for dawn" ) : _( "Wait till daylight" ), - diurnal_time_before( to_turns( daylight_time( calendar::turn ) - calendar::turn_zero ) ) ); + diurnal_time_before( daylight_time( calendar::turn ) ) ); add_menu_item( 8, 'n', setting_alarm ? _( "Set alarm for noon" ) : _( "Wait till noon" ), diurnal_time_before( last_midnight + 12_hours ) ); add_menu_item( 9, 'k', setting_alarm ? _( "Set alarm for dusk" ) : _( "Wait till night" ), - diurnal_time_before( to_turns( night_time( calendar::turn ) - calendar::turn_zero ) ) ); + diurnal_time_before( night_time( calendar::turn ) ) ); add_menu_item( 10, 'm', setting_alarm ? _( "Set alarm for midnight" ) : _( "Wait till midnight" ), - diurnal_time_before( last_midnight + 0_hours ) ); + diurnal_time_before( last_midnight ) ); if( setting_alarm ) { if( player_character.has_effect( effect_alarm_clock ) ) { add_menu_item( 11, 'x', _( "Cancel the currently set alarm." ), @@ -2255,7 +2255,7 @@ bool game::handle_action() mostseen = 0; add_msg( m_info, _( "Safe mode ON!" ) ); } else { - turnssincelastmon = 0; + turnssincelastmon = 0_turns; set_safe_mode( SAFE_MODE_OFF ); add_msg( m_info, get_option( "AUTOSAFEMODE" ) ? _( "Safe mode OFF! (Auto safe mode still enabled!)" ) : _( "Safe mode OFF!" ) ); diff --git a/src/iexamine.cpp b/src/iexamine.cpp index aefae5214f1b2..6fe473b15199b 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -3138,7 +3138,7 @@ void iexamine::fvat_empty( player &p, const tripoint &examp ) } } if( to_deposit ) { - item brew( brew_type, 0 ); + item brew( brew_type, calendar::turn_zero ); int charges_held = p.charges_of( brew_type ); brew.charges = charges_on_ground; for( int i = 0; i < charges_held && !vat_full; i++ ) { @@ -3346,7 +3346,7 @@ void iexamine::keg( player &p, const tripoint &examp ) //Store liquid chosen in the keg itype_id drink_type = drink_types[ drink_index ]; int charges_held = p.charges_of( drink_type ); - item drink( drink_type, 0 ); + item drink( drink_type, calendar::turn_zero ); drink.set_relative_rot( drink_rot[ drink_index ] ); drink.charges = 0; bool keg_full = false; @@ -3538,7 +3538,7 @@ void iexamine::tree_hickory( player &p, const tripoint &examp ) static item_location maple_tree_sap_container() { - const item maple_sap = item( "maple_sap", 0 ); + const item maple_sap = item( "maple_sap", calendar::turn_zero ); return g->inv_map_splice( [&]( const item & it ) { return it.get_remaining_capacity_for_liquid( maple_sap, true ) > 0; }, _( "Which container?" ), PICKUP_RANGE ); @@ -3797,7 +3797,7 @@ void iexamine::recycle_compactor( player &, const tripoint &examp ) choose_output.text = string_format( _( "Compact %1$.3f %2$s of %3$s into:" ), convert_weight( sum_weight ), weight_units(), m.name() ); for( const itype_id &ci : m.compacts_into() ) { - item it = item( ci, 0, item::solitary_tag{} ); + item it = item( ci, calendar::turn_zero, item::solitary_tag{} ); const int amount = norm_recover_weight / it.weight(); //~ %1$d: number of, %2$s: output item choose_output.addentry( string_format( _( "about %1$d %2$s" ), amount, @@ -3822,7 +3822,7 @@ void iexamine::recycle_compactor( player &, const tripoint &examp ) bool out_desired = false; bool out_any = false; for( auto it = m.compacts_into().begin() + o_idx; it != m.compacts_into().end(); ++it ) { - const units::mass ow = item( *it, 0, item::solitary_tag{} ).weight(); + const units::mass ow = item( *it, calendar::turn_zero, item::solitary_tag{} ).weight(); int count = sum_weight / ow; sum_weight -= count * ow; if( count > 0 ) { @@ -3966,7 +3966,7 @@ void iexamine::water_source( player &p, const tripoint &examp ) void iexamine::clean_water_source( player &, const tripoint &examp ) { - item water = item( "water_clean", 0, item::INFINITE_CHARGES ); + item water = item( "water_clean", calendar::turn_zero, item::INFINITE_CHARGES ); liquid_handler::handle_liquid( water, nullptr, 0, &examp ); } @@ -5016,9 +5016,9 @@ void iexamine::autodoc( player &p, const tripoint &examp ) if( !patient.worn_with_flag( flag_SPLINT, part ) ) { item splint; if( part == bodypart_id( "arm_l" ) || part == bodypart_id( "arm_r" ) ) { - splint = item( "arm_splint", 0 ); + splint = item( "arm_splint", calendar::turn_zero ); } else if( part == bodypart_id( "leg_l" ) || part == bodypart_id( "leg_r" ) ) { - splint = item( "leg_splint", 0 ); + splint = item( "leg_splint", calendar::turn_zero ); } patient.wear_item( splint, false ); } diff --git a/src/inventory.cpp b/src/inventory.cpp index def6b5fecc00b..dd76c64d10dc5 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -346,7 +346,7 @@ item *inventory::provide_pseudo_item( const itype_id &id, int battery ) return ⁢ } item it_batt( it.magazine_default() ); - item it_ammo = item( it_batt.ammo_default(), 0 ); + item it_ammo = item( it_batt.ammo_default(), calendar::turn_zero ); if( it_ammo.is_null() || it_ammo.typeId() != itype_id( "battery" ) ) { return ⁢ } diff --git a/src/item_group.cpp b/src/item_group.cpp index 8533687325bee..b093859215707 100644 --- a/src/item_group.cpp +++ b/src/item_group.cpp @@ -739,7 +739,7 @@ item_group::ItemList item_group::items_from( const item_group_id &group_id, item_group::ItemList item_group::items_from( const item_group_id &group_id ) { - return items_from( group_id, 0 ); + return items_from( group_id, calendar::turn_zero ); } item item_group::item_from( const item_group_id &group_id, const time_point &birthday ) @@ -753,7 +753,7 @@ item item_group::item_from( const item_group_id &group_id, const time_point &bir item item_group::item_from( const item_group_id &group_id ) { - return item_from( group_id, 0 ); + return item_from( group_id, calendar::turn_zero ); } bool item_group::group_is_defined( const item_group_id &group_id ) diff --git a/src/iuse.cpp b/src/iuse.cpp index cf2cfdf2c5399..38f9a08c84b12 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -4200,7 +4200,7 @@ int iuse::tazer2( player *p, item *it, bool b, const tripoint &pos ) if( it->ammo_remaining() >= 100 ) { // Instead of having a ctrl+c+v of the function above, spawn a fake tazer and use it // Ugly, but less so than copied blocks - item fake( "tazer", 0 ); + item fake( "tazer", calendar::turn_zero ); fake.charges = 100; return tazer( p, &fake, b, pos ); } else { @@ -8626,11 +8626,16 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos ) std::vector dishes; inventory crafting_inv = p->crafting_inventory(); - //add some tools and qualities. we can't add this qualities to json, because multicook must be used only by activating, not as component other crafts. - crafting_inv.push_back( item( "hotplate", 0 ) ); //hotplate inside - crafting_inv.push_back( item( "tongs", 0 ) ); //some recipes requires tongs - crafting_inv.push_back( item( "toolset", 0 ) ); //toolset with CUT and other qualities inside - crafting_inv.push_back( item( "pot", 0 ) ); //good COOK, BOIL, CONTAIN qualities inside + // add some tools and qualities. we can't add this qualities to + // json, because multicook must be used only by activating, not as + // component other crafts. + crafting_inv.push_back( item( "hotplate", calendar::turn_zero ) ); //hotplate inside + // some recipes requires tongs + crafting_inv.push_back( item( "tongs", calendar::turn_zero ) ); + // toolset with CUT and other qualities inside + crafting_inv.push_back( item( "toolset", calendar::turn_zero ) ); + // good COOK, BOIL, CONTAIN qualities inside + crafting_inv.push_back( item( "pot", calendar::turn_zero ) ); int counter = 0; diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 81c6e7fa27fc0..d8603cca52149 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -907,7 +907,7 @@ int place_monster_iuse::use( player &p, item &it, bool, const tripoint & ) const newmon.ammo = newmon.type->starting_ammo; if( !newmon.has_flag( MF_INTERIOR_AMMO ) ) { for( std::pair &amdef : newmon.ammo ) { - item ammo_item( amdef.first, 0 ); + item ammo_item( amdef.first, calendar::turn_zero ); const int available = p.charges_of( amdef.first ); if( available == 0 ) { amdef.second = 0; diff --git a/src/map.cpp b/src/map.cpp index 5fafd23e9bed2..de8c93142cd56 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -5040,7 +5040,7 @@ static void use_charges_from_furn( const furn_t &f, const itype_id &type, int &q return i.typeId() == ammo; } ); if( iter != stack.end() ) { - item furn_item( itt, -1, iter->charges ); + item furn_item( itt, calendar::turn_zero, iter->charges ); if( !filter( furn_item ) ) { return; } @@ -8308,9 +8308,9 @@ void map::add_corpse( const tripoint &p ) body.set_flag( flag_REVIVE_SPECIAL ); } - put_items_from_loc( item_group_id( "default_zombie_clothes" ), p, 0 ); + put_items_from_loc( item_group_id( "default_zombie_clothes" ), p, calendar::turn_zero ); if( one_in( 3 ) ) { - put_items_from_loc( item_group_id( "default_zombie_items" ), p, 0 ); + put_items_from_loc( item_group_id( "default_zombie_items" ), p, calendar::turn_zero ); } add_item_or_charges( p, body ); diff --git a/src/map_extras.cpp b/src/map_extras.cpp index fe7036b75b0ee..cd6b593509958 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -1594,9 +1594,11 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //Place beds in a tent m.furn_set( { 21, 5, abs_sub.z }, f_makeshift_bed ); - m.put_items_from_loc( item_group_id( "army_bed" ), { 21, 5, abs_sub.z }, 0 ); + m.put_items_from_loc( item_group_id( "army_bed" ), { 21, 5, abs_sub.z }, + calendar::turn_zero ); m.furn_set( { 22, 6, abs_sub.z }, f_makeshift_bed ); - m.put_items_from_loc( item_group_id( "army_bed" ), { 22, 6, abs_sub.z }, 0 ); + m.put_items_from_loc( item_group_id( "army_bed" ), { 22, 6, abs_sub.z }, + calendar::turn_zero ); //Spawn 6-20 mines in the leftmost submap. //Spawn ordinary mine on asphalt, otherwise spawn buried mine diff --git a/src/mapgen.cpp b/src/mapgen.cpp index ebe199629f5d0..75812b10b5241 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -4205,7 +4205,7 @@ void map::draw_lab( mapgendata &dat ) int marker_y = center.y + rng( -2, 2 ); if( one_in( 4 ) ) { spawn_item( point( marker_x, marker_y ), - "mininuke", 1, 1, 0, rng( 2, 4 ) ); + "mininuke", 1, 1, calendar::turn_zero, rng( 2, 4 ) ); } else { item newliquid( "plut_slurry_dense", calendar::start_of_cataclysm ); newliquid.charges = 1; @@ -5328,7 +5328,7 @@ void map::draw_spiral( const mapgendata &dat ) ter_set( point( orx + 3, ory + 3 ), t_rock ); ter_set( point( orx + 2, ory + 3 ), t_rock_floor ); place_items( item_group_id( "spiral" ), 60, point( orx + 2, ory + 3 ), - point( orx + 2, ory + 3 ), false, 0 ); + point( orx + 2, ory + 3 ), false, calendar::turn_zero ); } } } @@ -5771,7 +5771,7 @@ void map::place_spawns( const mongroup_id &group, const int chance, void map::place_gas_pump( const point &p, int charges, const std::string &fuel_type ) { - item fuel( fuel_type, 0 ); + item fuel( fuel_type, calendar::start_of_cataclysm ); fuel.charges = charges; add_item( p, fuel ); ter_set( p, ter_id( fuel.fuel_pump_terrain() ) ); @@ -5779,7 +5779,7 @@ void map::place_gas_pump( const point &p, int charges, const std::string &fuel_t void map::place_toilet( const point &p, int charges ) { - item water( "water", 0 ); + item water( "water", calendar::start_of_cataclysm ); water.charges = charges; add_item( p, water ); furn_set( p, f_toilet ); @@ -6599,7 +6599,7 @@ void science_room( map *m, const point &p1, const point &p2, int z, int rotate ) mapf::ter_bind( "- | =", t_concrete_wall, t_concrete_wall, t_reinforced_glass ), mapf::furn_bind( "c", f_counter ) ); m->place_items( item_group_id( "bionics_common" ), 70, point( biox, bioy ), - point( biox, bioy ), false, 0 ); + point( biox, bioy ), false, calendar::turn_zero ); m->furn_set( point( biox - 2, bioy ), furn_str_id( "f_console" ) ); computer *tmpcomp2 = m->add_computer( tripoint( biox - 2, bioy, z ), _( "Bionic access" ), 2 ); diff --git a/src/material.cpp b/src/material.cpp index 9058aa4901ccd..6a6b9f57dad88 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -128,7 +128,8 @@ void material_type::check() const } } for( const itype_id &ci : _compacts_into ) { - if( !item::type_is_defined( ci ) || !item( ci, 0 ).only_made_of( std::set { id } ) ) { + if( !item::type_is_defined( ci ) || + !item( ci, calendar::turn_zero ).only_made_of( std::set { id } ) ) { debugmsg( "invalid \"compacts_into\" %s for %s.", ci.c_str(), id.c_str() ); } } diff --git a/src/messages.cpp b/src/messages.cpp index ca8d723ba3e3a..2b189a061bd1b 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -35,7 +35,7 @@ namespace struct game_message : public JsonDeserializer, public JsonSerializer { std::string message; - time_point timestamp_in_turns = 0; + time_point timestamp_in_turns = calendar::turn_zero; int timestamp_in_user_actions = 0; int count = 1; // number of times this message has been seen while it was in cooldown. @@ -116,7 +116,7 @@ class messages_impl public: std::deque messages; // Messages to be printed std::vector cooldown_templates; // Message cooldown - time_point curmes = 0; // The last-seen message. + time_point curmes = calendar::turn_zero; // The last-seen message. bool active = true; bool has_undisplayed_messages() const { @@ -201,7 +201,7 @@ class messages_impl void hide_message_in_cooldown( game_message &message ) { message.cooldown_hidden = false; - if( message_cooldown <= 0 || message.turn() <= 0 ) { + if( message_cooldown <= 0 || message.turn() <= calendar::turn_zero ) { return; } @@ -262,7 +262,7 @@ class messages_impl */ void refresh_cooldown( const game_message &message, const game_message_flags flags ) { // is cooldown used? (also checks for messages arriving here at game initialization: we don't care about them). - if( message_cooldown <= 0 || message.turn() <= 0 ) { + if( message_cooldown <= 0 || message.turn() <= calendar::turn_zero ) { return; } diff --git a/src/mission.cpp b/src/mission.cpp index 66bd9637ede24..1772ed4077c1a 100644 --- a/src/mission.cpp +++ b/src/mission.cpp @@ -53,7 +53,7 @@ mission mission_type::create( const character_id &npc_id ) const if( deadline_low != 0_turns || deadline_high != 0_turns ) { ret.deadline = calendar::turn + rng( deadline_low, deadline_high ); } else { - ret.deadline = 0; + ret.deadline = calendar::turn_zero; } return ret; @@ -236,7 +236,7 @@ void mission::assign( avatar &u ) if( type->deadline_low != 0_turns || type->deadline_high != 0_turns ) { deadline = calendar::turn + rng( type->deadline_low, type->deadline_high ); } else { - deadline = 0; + deadline = calendar::turn_zero; } type->start( this ); status = mission_status::in_progress; @@ -547,7 +547,7 @@ void mission::get_all_item_group_matches( std::vector &items, bool mission::has_deadline() const { - return deadline != 0; + return deadline != calendar::turn_zero; } time_point mission::get_deadline() const @@ -621,7 +621,7 @@ void mission::process() return; } - if( deadline > 0 && calendar::turn > deadline ) { + if( has_deadline() && calendar::turn > deadline ) { fail(); } else if( !npc_id.is_valid() && is_complete( npc_id ) ) { // No quest giver. wrap_up(); diff --git a/src/mission_end.cpp b/src/mission_end.cpp index e0956e85a5efd..3f62fda6af581 100644 --- a/src/mission_end.cpp +++ b/src/mission_end.cpp @@ -26,6 +26,6 @@ void mission_end::deposit_box( mission *miss ) } else if( one_in( 3 ) ) { itemName = "m4a1"; } - get_player_character().i_add( item( itemName, 0 ) ); + get_player_character().i_add( item( itemName, calendar::turn_zero ) ); add_msg( m_good, _( "%s gave you an item from the deposit box." ), p->name ); } diff --git a/src/mission_start.cpp b/src/mission_start.cpp index 37e2d0f46a7fb..94d5d6466ce58 100644 --- a/src/mission_start.cpp +++ b/src/mission_start.cpp @@ -59,7 +59,7 @@ void mission_start::place_dog( mission *miss ) debugmsg( "Couldn't find NPC! %d", miss->npc_id.get_value() ); return; } - get_player_character().i_add( item( "dog_whistle", 0 ) ); + get_player_character().i_add( item( "dog_whistle", calendar::turn_zero ) ); add_msg( _( "%s gave you a dog whistle." ), dev->name ); miss->target = house; @@ -192,7 +192,7 @@ void mission_start::place_npc_software( mission *miss ) debugmsg( "Couldn't find NPC! %d", miss->npc_id.get_value() ); return; } - get_player_character().i_add( item( "usb_drive", 0 ) ); + get_player_character().i_add( item( "usb_drive", calendar::turn_zero ) ); add_msg( _( "%s gave you a USB drive." ), dev->name ); std::string type = "house"; @@ -549,7 +549,8 @@ void mission_start::ranch_scavenger_1( mission *miss ) site = mission_util::target_om_ter_random( "ranch_camp_49", 1, miss, false, RANCH_SIZE ); bay.load( project_to( site ), false ); - bay.place_items( item_group_id( "mechanics" ), 65, point( 9, 13 ), point( 10, 16 ), true, 0 ); + bay.place_items( item_group_id( "mechanics" ), 65, point( 9, 13 ), point( 10, 16 ), true, + calendar::turn_zero ); bay.draw_square_ter( t_chainfence, point( 0, 22 ), point( 7, 22 ) ); bay.draw_square_ter( t_dirt, point( 2, 22 ), point( 3, 22 ) ); bay.spawn_item( point( 7, 19 ), "30gal_drum" ); diff --git a/src/monattack.cpp b/src/monattack.cpp index a2471b863e2e6..fc154c140fedd 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -3498,7 +3498,7 @@ bool mattack::searchlight( monster *z ) for( int i = 0; i < max_lamp_count; i++ ) { - item settings( "processor", 0 ); + item settings( "processor", calendar::turn_zero ); settings.set_var( "SL_PREFER_UP", "TRUE" ); settings.set_var( "SL_PREFER_DOWN", "TRUE" ); @@ -4771,7 +4771,7 @@ bool mattack::riotbot( monster *z ) if( choice == ur_arrest ) { z->anger = 0; - item handcuffs( "e_handcuffs", 0 ); + item handcuffs( "e_handcuffs", calendar::turn_zero ); handcuffs.charges = handcuffs.type->maximum_charges(); handcuffs.active = true; handcuffs.set_var( "HANDCUFFS_X", foe->posx() ); diff --git a/src/monexamine.cpp b/src/monexamine.cpp index 0a05e0096f5c1..1bd2e065c6ff4 100644 --- a/src/monexamine.cpp +++ b/src/monexamine.cpp @@ -704,7 +704,7 @@ void monexamine::kill_zslave( monster &z ) if( !one_in( 3 ) ) { player_character.add_msg_if_player( _( "You tear out the pheromone ball from the zombie slave." ) ); - item ball( "pheromone", 0 ); + item ball( "pheromone", calendar::turn_zero ); iuse::pheromone( &player_character, &ball, true, player_character.pos() ); } } diff --git a/src/monster.cpp b/src/monster.cpp index 6c15964f74e5d..e4e5f1d8d93f3 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -217,8 +217,8 @@ monster::monster() ignoring = 0; upgrades = false; upgrade_time = -1; - last_updated = 0; - biosig_timer = -1; + last_updated = calendar::turn_zero; + biosig_timer = calendar::before_time_starts; udder_timer = calendar::turn; horde_attraction = MHA_NULL; set_anatomy( anatomy_id( "default_anatomy" ) ); @@ -248,7 +248,7 @@ monster::monster( const mtype_id &id ) : monster() itype_id mech_bat = itype_id( type->mech_battery ); const itype &type = *item::find_type( mech_bat ); int max_charge = type.magazine->capacity; - item mech_bat_item = item( mech_bat, 0 ); + item mech_bat_item = item( mech_bat, calendar::turn_zero ); mech_bat_item.ammo_consume( rng( 0, max_charge ), tripoint_zero ); battery_item = cata::make_value( mech_bat_item ); } @@ -2228,15 +2228,15 @@ void monster::die( Creature *nkiller ) move_special_item_to_inv( tied_item ); if( has_effect( effect_lightsnare ) ) { - add_item( item( "string_36", 0 ) ); - add_item( item( "snare_trigger", 0 ) ); + add_item( item( "string_36", calendar::turn_zero ) ); + add_item( item( "snare_trigger", calendar::turn_zero ) ); } if( has_effect( effect_heavysnare ) ) { - add_item( item( "rope_6", 0 ) ); - add_item( item( "snare_trigger", 0 ) ); + add_item( item( "rope_6", calendar::turn_zero ) ); + add_item( item( "snare_trigger", calendar::turn_zero ) ); } if( has_effect( effect_beartrap ) ) { - add_item( item( "beartrap", 0 ) ); + add_item( item( "beartrap", calendar::turn_zero ) ); } map &here = get_map(); if( has_effect( effect_grabbing ) ) { diff --git a/src/npc.cpp b/src/npc.cpp index ee7ec3b492085..a6ac6b3df588b 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -322,7 +322,7 @@ void npc::randomize( const npc_class_id &type ) setID( g->assign_npc_id() ); } - weapon = item( "null", 0 ); + weapon = item( "null", calendar::turn_zero ); inv->clear(); personality.aggression = rng( -10, 10 ); personality.bravery = rng( -3, 10 ); diff --git a/src/npctalk_funcs.cpp b/src/npctalk_funcs.cpp index 77163079dd365..4602e1caf79c1 100644 --- a/src/npctalk_funcs.cpp +++ b/src/npctalk_funcs.cpp @@ -489,7 +489,7 @@ void talk_function::bionic_remove( npc &p ) bio.id != bio_power_storage_mkII ) { bionic_types.push_back( bio.info().itype() ); if( item::type_is_defined( bio.info().itype() ) ) { - item tmp = item( bio.id.str(), 0 ); + item tmp = item( bio.id.str(), calendar::turn_zero ); bionic_names.push_back( tmp.tname() + " - " + format_money( 50000 + ( tmp.price( true ) / 4 ) ) ); } else { bionic_names.push_back( bio.id.str() + " - " + format_money( 50000 ) ); @@ -508,7 +508,7 @@ void talk_function::bionic_remove( npc &p ) signed int price; if( item::type_is_defined( bionic_types[bionic_index] ) ) { - price = 50000 + ( item( bionic_types[bionic_index], 0 ).price( true ) / 4 ); + price = 50000 + ( item( bionic_types[bionic_index], calendar::turn_zero ).price( true ) / 4 ); } else { price = 50000; } diff --git a/src/panels.cpp b/src/panels.cpp index 151ca73f36879..29d68fe570ec5 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -866,7 +866,7 @@ static nc_color safe_color() { nc_color s_color = g->safe_mode ? c_green : c_red; if( g->safe_mode == SAFE_MODE_OFF && get_option( "AUTOSAFEMODE" ) ) { - int s_return = get_option( "AUTOSAFEMODETURNS" ); + time_duration s_return = time_duration::from_turns( get_option( "AUTOSAFEMODETURNS" ) ); int iPercent = g->turnssincelastmon * 100 / s_return; if( iPercent >= 100 ) { s_color = c_green; diff --git a/src/savegame.cpp b/src/savegame.cpp index d004aa365473f..d99e8616416fc 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -186,8 +186,8 @@ void game::unserialize( std::istream &fin ) data.read( "om_x", com.x() ); data.read( "om_y", com.y() ); - calendar::turn = tmpturn; - calendar::start_of_cataclysm = tmpcalstart; + calendar::turn = time_point( tmpturn ); + calendar::start_of_cataclysm = time_point( tmpcalstart ); if( !data.read( "game_start", calendar::start_of_game ) ) { calendar::start_of_game = calendar::start_of_cataclysm; diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 1c9875ad8ab70..d8d62cfc88b78 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -1637,8 +1637,8 @@ void npc::load( const JsonObject &data ) tripoint_abs_omt comp_miss_pt; std::string classid; std::string companion_mission_role; - time_point companion_mission_t = 0; - time_point companion_mission_t_r = 0; + time_point companion_mission_t = calendar::turn_zero; + time_point companion_mission_t_r = calendar::turn_zero; std::string act_id; data.read( "name", name ); @@ -1836,7 +1836,7 @@ void npc::load( const JsonObject &data ) complaints.clear(); for( const JsonMember member : data.get_object( "complaints" ) ) { // TODO: time_point does not have a default constructor, need to read in the map manually - time_point p = 0; + time_point p = calendar::turn_zero; member.read( p ); complaints.emplace( member.name(), p ); } @@ -2112,7 +2112,7 @@ void monster::load( const JsonObject &data ) } biosignatures = data.get_bool( "biosignatures", type->biosignatures ); - biosig_timer = data.get_int( "biosig_timer", -1 ); + biosig_timer = time_point( data.get_int( "biosig_timer", -1 ) ); data.read( "udder_timer", udder_timer ); @@ -2422,7 +2422,7 @@ void item::io( Archive &archive ) // (item::charges -1 or 0 or anything else) to comestible (and thereby counted by charges), // old saves still have invalid charges, this fixes the charges value to the default charges. if( count_by_charges() && charges <= 0 ) { - charges = item( type, 0 ).charges; + charges = item( type, calendar::turn_zero ).charges; } if( is_food() ) { active = true; @@ -3972,7 +3972,7 @@ void submap::load( JsonIn &jsin, const std::string &member_name, int version ) { bool rubpow_update = version < 22; if( member_name == "turn_last_touched" ) { - last_touched = jsin.get_int(); + last_touched = time_point( jsin.get_int() ); } else if( member_name == "temperature" ) { temperature = jsin.get_int(); } else if( member_name == "terrain" ) { @@ -3980,8 +3980,8 @@ void submap::load( JsonIn &jsin, const std::string &member_name, int version ) jsin.start_array(); // Small duplication here so that the update check is only performed once if( rubpow_update ) { - item rock = item( "rock", 0 ); - item chunk = item( "steel_chunk", 0 ); + item rock = item( "rock", calendar::turn_zero ); + item chunk = item( "steel_chunk", calendar::turn_zero ); for( int j = 0; j < SEEY; j++ ) { for( int i = 0; i < SEEX; i++ ) { const ter_str_id tid( jsin.get_string() ); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 5745522ff2f63..6b5fe1170b6c6 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -408,7 +408,7 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) bool destroyAlarm = false; // More realistically it should be -5 days old - last_update = 0; + last_update = calendar::turn_zero; // veh_fuel_multiplier is percentage of fuel // 0 is empty, 100 is full tank, -1 is random 7% to 35% @@ -6871,7 +6871,7 @@ std::list vehicle::use_charges( const vpart_position &vp, const itype_id & const cata::optional cargo_vp = vp.part_with_feature( "CARGO", true ); const auto tool_wants_battery = []( const itype_id & type ) { - item tool( type, 0 ), mag( tool.magazine_default() ); + item tool( type, calendar::turn_zero ), mag( tool.magazine_default() ); mag.contents.clear_items(); return tool.contents.insert_item( mag, item_pocket::pocket_type::MAGAZINE_WELL ).success() && @@ -6880,7 +6880,7 @@ std::list vehicle::use_charges( const vpart_position &vp, const itype_id & if( tool_vp ) { // handle vehicle tools itype_id fuel_type = tool_wants_battery( type ) ? itype_battery : type; - item tmp( type, 0 ); // TODO: add a sane birthday arg + item tmp( type, calendar::turn_zero ); // TODO: add a sane birthday arg // TODO: Handle water poison when crafting starts respecting it tmp.charges = tool_vp->vehicle().drain( fuel_type, quantity ); quantity -= tmp.charges; diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 1d5332a0b9c2c..d8df3beefa479 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -1961,7 +1961,7 @@ void vpart_position::form_inventory( inventory &inv ) // HACK: water_faucet pseudo tool gives access to liquids in tanks if( vp_faucet && inv.provide_pseudo_item( itype_water_faucet, 0 ) ) { for( const std::pair &it : vehicle().fuels_left() ) { - item fuel( it.first, 0 ); + item fuel( it.first, calendar::turn_zero ); if( fuel.made_of( phase_id::LIQUID ) ) { fuel.charges = it.second; inv.add_item( fuel ); @@ -2113,7 +2113,7 @@ void vehicle::interact_with( const vpart_position &vp ) } auto tool_wants_battery = []( const itype_id & type ) { - item tool( type, 0 ); + item tool( type, calendar::turn_zero ); item mag( tool.magazine_default() ); mag.contents.clear_items(); @@ -2122,7 +2122,7 @@ void vehicle::interact_with( const vpart_position &vp ) }; auto use_vehicle_tool = [&]( const itype_id & tool_type ) { - item pseudo( tool_type, 0 ); + item pseudo( tool_type, calendar::turn_zero ); pseudo.set_flag( STATIC( flag_str_id( "PSEUDO" ) ) ); if( !tool_wants_battery( tool_type ) ) { player_character.invoke_item( &pseudo ); @@ -2188,7 +2188,7 @@ void vehicle::interact_with( const vpart_position &vp ) return; } case DRINK: { - item water( itype_water_clean, 0 ); + item water( itype_water_clean, calendar::turn_zero ); if( player_character.can_consume( water ) ) { player_character.assign_activity( player_activity( consume_activity_actor( water ) ) ); drain( itype_water_clean, 1 ); diff --git a/src/weather.cpp b/src/weather.cpp index f29312167f86a..7fe66c1faaad6 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -309,7 +309,7 @@ double funnel_charges_per_turn( const double surface_area_mm2, const double rain } // Calculate once, because that part is expensive - static const item water( "water", 0 ); + static const item water( "water", calendar::turn_zero ); // 250ml static const double charge_ml = static_cast( to_gram( water.weight() ) ) / water.charges; diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index cefd108a96894..ef34f2405fedf 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -307,7 +307,7 @@ void weather_generator::test_weather( unsigned seed, const time_point begin = calendar::turn; const time_point end = begin + 2 * calendar::year_length(); for( time_point i = begin; i < end; i += 20_minutes ) { - w_point w = get_weather( tripoint_zero, to_turn( i ), seed ); + w_point w = get_weather( tripoint_zero, i, seed ); weather_type_id conditions = get_weather_conditions( w, next_instance_allowed ); int year = to_turns( i - calendar::turn_zero ) / to_turns diff --git a/src/wish.cpp b/src/wish.cpp index d12cc73c9f5d3..b58e631394b86 100644 --- a/src/wish.cpp +++ b/src/wish.cpp @@ -562,7 +562,7 @@ void debug_menu::wishitem( player *p, const tripoint &pos ) } std::vector> opts; for( const itype *i : item_controller->all() ) { - opts.emplace_back( item( i, 0 ).tname( 1, false ), i ); + opts.emplace_back( item( i, calendar::turn_zero ).tname( 1, false ), i ); } std::sort( opts.begin(), opts.end(), localized_compare ); std::vector itypes; @@ -592,7 +592,7 @@ void debug_menu::wishitem( player *p, const tripoint &pos ) wmenu.callback = &cb; for( size_t i = 0; i < opts.size(); i++ ) { - item ity( opts[i].second, 0 ); + item ity( opts[i].second, calendar::turn_zero ); wmenu.addentry( i, true, 0, opts[i].first ); mvwzstr &entry_extra_text = wmenu.entries[i].extratxt; entry_extra_text.txt = ity.symbol(); diff --git a/tests/active_item_cache_test.cpp b/tests/active_item_cache_test.cpp index 9b96172b340cb..c2c004f601f78 100644 --- a/tests/active_item_cache_test.cpp +++ b/tests/active_item_cache_test.cpp @@ -21,7 +21,7 @@ TEST_CASE( "place_active_item_at_various_coordinates", "[item]" ) } REQUIRE( here.get_submaps_with_active_items().empty() ); // An arbitrary active item. - item active( "firecracker_act", 0, item::default_charges_tag() ); + item active( "firecracker_act", calendar::turn_zero, item::default_charges_tag() ); active.activate(); // For each space in a wide area place the item and check if the cache has been updated. diff --git a/tests/active_item_test.cpp b/tests/active_item_test.cpp index b08112548aaf9..2b58b9324d9a6 100644 --- a/tests/active_item_test.cpp +++ b/tests/active_item_test.cpp @@ -16,10 +16,10 @@ TEST_CASE( "active_items_processed_regularly", "[item]" ) avatar &player_character = get_avatar(); map &here = get_map(); // An arbitrary active item that ticks every turn. - item active_item( "firecracker_act", 0, 5 ); + item active_item( "firecracker_act", calendar::turn_zero, 5 ); active_item.activate(); const int active_item_ticks = active_item.charges; - item storage( "backpack", 0 ); + item storage( "backpack", calendar::turn_zero ); cata::optional::iterator> wear_success = player_character.wear_item( storage ); REQUIRE( wear_success ); diff --git a/tests/bionics_test.cpp b/tests/bionics_test.cpp index 1976b1b39d7fa..064a288fddebf 100644 --- a/tests/bionics_test.cpp +++ b/tests/bionics_test.cpp @@ -26,7 +26,7 @@ static void clear_bionics( player &p ) static void test_consumable_charges( player &p, std::string &itemname, bool when_none, bool when_max ) { - item it = item( itemname, 0, 0 ); + item it = item( itemname, calendar::turn_zero, 0 ); INFO( "\'" + it.tname() + "\' is count-by-charges" ); CHECK( it.count_by_charges() ); @@ -43,7 +43,7 @@ static void test_consumable_charges( player &p, std::string &itemname, bool when static void test_consumable_ammo( player &p, std::string &itemname, bool when_empty, bool when_full ) { - item it = item( itemname, 0, 0 ); + item it = item( itemname, calendar::turn_zero, 0 ); it.ammo_unset(); INFO( "consume \'" + it.tname() + "\' with " + std::to_string( it.ammo_remaining() ) + " charges" ); diff --git a/tests/crafting_test.cpp b/tests/crafting_test.cpp index d8247018db44e..df75fd73a61d8 100644 --- a/tests/crafting_test.cpp +++ b/tests/crafting_test.cpp @@ -377,7 +377,7 @@ TEST_CASE( "UPS shows as a crafting component", "[crafting][ups]" ) avatar dummy; clear_character( dummy ); dummy.worn.push_back( item( "backpack" ) ); - item &ups = dummy.i_add( item( "UPS_off", -1, 500 ) ); + item &ups = dummy.i_add( item( "UPS_off", calendar::turn_zero, 500 ) ); REQUIRE( dummy.has_item( ups ) ); REQUIRE( ups.charges == 500 ); REQUIRE( dummy.charges_of( itype_id( "UPS_off" ) ) == 500 ); @@ -467,7 +467,7 @@ TEST_CASE( "tools use charge to craft", "[crafting][charge]" ) item soldering_iron( "soldering_iron" ); soldering_iron.put_in( item( "battery_ups" ), item_pocket::pocket_type::MOD ); tools.push_back( soldering_iron ); - tools.emplace_back( "UPS_off", -1, 10 ); + tools.emplace_back( "UPS_off", calendar::turn_zero, 10 ); THEN( "crafting fails, and no charges are used" ) { prep_craft( recipe_id( "carver_off" ), tools, false ); @@ -483,7 +483,8 @@ TEST_CASE( "tool_use", "[crafting][tool]" ) std::vector tools; tools.push_back( tool_with_ammo( "hotplate", 20 ) ); item plastic_bottle( "bottle_plastic" ); - plastic_bottle.put_in( item( "water", -1, 2 ), item_pocket::pocket_type::CONTAINER ); + plastic_bottle.put_in( + item( "water", calendar::turn_zero, 2 ), item_pocket::pocket_type::CONTAINER ); tools.push_back( plastic_bottle ); tools.emplace_back( "pot" ); @@ -494,12 +495,13 @@ TEST_CASE( "tool_use", "[crafting][tool]" ) std::vector tools; tools.push_back( tool_with_ammo( "hotplate", 20 ) ); item plastic_bottle( "bottle_plastic" ); - plastic_bottle.put_in( item( "water", -1, 2 ), item_pocket::pocket_type::CONTAINER ); + plastic_bottle.put_in( + item( "water", calendar::turn_zero, 2 ), item_pocket::pocket_type::CONTAINER ); tools.push_back( plastic_bottle ); item jar( "jar_glass_sealed" ); // If it's not watertight the water will spill. REQUIRE( jar.is_watertight_container() ); - jar.put_in( item( "water", -1, 2 ), item_pocket::pocket_type::CONTAINER ); + jar.put_in( item( "water", calendar::turn_zero, 2 ), item_pocket::pocket_type::CONTAINER ); tools.push_back( jar ); prep_craft( recipe_id( "water_clean" ), tools, false ); @@ -570,8 +572,8 @@ TEST_CASE( "total crafting time with or without interruption", "[crafting][time] int actual_turns_taken; WHEN( "crafting begins, and continues until the craft is completed" ) { - tools.emplace_back( "razor_blade", -1, 1 ); - tools.emplace_back( "plastic_chunk", -1, 1 ); + tools.emplace_back( "razor_blade", calendar::turn_zero, 1 ); + tools.emplace_back( "plastic_chunk", calendar::turn_zero, 1 ); actual_turns_taken = actually_test_craft( test_recipe, tools, INT_MAX ); THEN( "it should take the expected number of turns" ) { @@ -584,8 +586,8 @@ TEST_CASE( "total crafting time with or without interruption", "[crafting][time] } WHEN( "crafting begins, but is interrupted after 2 turns" ) { - tools.emplace_back( "razor_blade", -1, 1 ); - tools.emplace_back( "plastic_chunk", -1, 1 ); + tools.emplace_back( "razor_blade", calendar::turn_zero, 1 ); + tools.emplace_back( "plastic_chunk", calendar::turn_zero, 1 ); actual_turns_taken = actually_test_craft( test_recipe, tools, 2 ); REQUIRE( actual_turns_taken == 3 ); diff --git a/tests/item_test.cpp b/tests/item_test.cpp index 061600bf39d7f..609943ac43339 100644 --- a/tests/item_test.cpp +++ b/tests/item_test.cpp @@ -24,7 +24,7 @@ TEST_CASE( "item_volume", "[item]" ) { // Need to pick some item here which is count_by_charges and for which each // charge is at least 1_ml. Battery works for now. - item i( "battery", 0, item::default_charges_tag() ); + item i( "battery", calendar::turn_zero, item::default_charges_tag() ); REQUIRE( i.count_by_charges() ); // Would be better with Catch2 generators const units::volume big_volume = units::from_milliliter( std::numeric_limits::max() / 2 ); @@ -237,7 +237,7 @@ static void assert_minimum_length_to_volume_ratio( const item &target ) TEST_CASE( "item length sanity check", "[item]" ) { for( const itype *type : item_controller->all() ) { - const item sample( type, 0, item::solitary_tag {} ); + const item sample( type, calendar::turn_zero, item::solitary_tag {} ); assert_minimum_length_to_volume_ratio( sample ); } } diff --git a/tests/itemname_test.cpp b/tests/itemname_test.cpp index 1790a62ff4ad2..9f552f2249c1b 100644 --- a/tests/itemname_test.cpp +++ b/tests/itemname_test.cpp @@ -126,7 +126,7 @@ TEST_CASE( "display name includes item contents", "[item][display_name][contents { clear_avatar(); - item arrow( "test_arrow_wood", 0, item::default_charges_tag{} ); + item arrow( "test_arrow_wood", calendar::turn_zero, item::default_charges_tag{} ); // Arrows are ammo with a default count of 10 REQUIRE( arrow.is_ammo() ); REQUIRE( arrow.count() == 10 ); diff --git a/tests/iuse_actor_test.cpp b/tests/iuse_actor_test.cpp index 69ae9f47b30ee..2cdbd655b755b 100644 --- a/tests/iuse_actor_test.cpp +++ b/tests/iuse_actor_test.cpp @@ -39,7 +39,8 @@ TEST_CASE( "manhack", "[iuse_actor][manhack]" ) player &player_character = get_avatar(); g->clear_zombies(); - item &test_item = player_character.i_add( item( "bot_manhack", 0, item::default_charges_tag{} ) ); + item &test_item = player_character.i_add( item( "bot_manhack", calendar::turn_zero, + item::default_charges_tag{} ) ); REQUIRE( player_character.has_item( test_item ) ); diff --git a/tests/iuse_test.cpp b/tests/iuse_test.cpp index e0e073360c5e3..011a5559d5e45 100644 --- a/tests/iuse_test.cpp +++ b/tests/iuse_test.cpp @@ -17,7 +17,7 @@ TEST_CASE( "eyedrops", "[iuse][eyedrops]" ) { avatar dummy; - item eyedrops( "saline", 0, item::default_charges_tag{} ); + item eyedrops( "saline", calendar::turn_zero, item::default_charges_tag{} ); int charges_before = eyedrops.charges; REQUIRE( charges_before > 0 ); @@ -55,7 +55,7 @@ TEST_CASE( "eyedrops", "[iuse][eyedrops]" ) TEST_CASE( "antifungal", "[iuse][antifungal]" ) { avatar dummy; - item antifungal( "antifungal", 0, item::default_charges_tag{} ); + item antifungal( "antifungal", calendar::turn_zero, item::default_charges_tag{} ); int charges_before = antifungal.charges; REQUIRE( charges_before > 0 ); @@ -106,7 +106,7 @@ TEST_CASE( "antifungal", "[iuse][antifungal]" ) TEST_CASE( "antiparasitic", "[iuse][antiparasitic]" ) { avatar dummy; - item antiparasitic( "antiparasitic", 0, item::default_charges_tag{} ); + item antiparasitic( "antiparasitic", calendar::turn_zero, item::default_charges_tag{} ); int charges_before = antiparasitic.charges; REQUIRE( charges_before > 0 ); @@ -162,7 +162,7 @@ TEST_CASE( "antiparasitic", "[iuse][antiparasitic]" ) TEST_CASE( "anticonvulsant", "[iuse][anticonvulsant]" ) { avatar dummy; - item anticonvulsant( "diazepam", 0, item::default_charges_tag{} ); + item anticonvulsant( "diazepam", calendar::turn_zero, item::default_charges_tag{} ); int charges_before = anticonvulsant.charges; REQUIRE( charges_before > 0 ); @@ -309,14 +309,14 @@ TEST_CASE( "caffeine and atomic caffeine", "[iuse][caff][atomic_caff]" ) REQUIRE( dummy.get_rad() == 0 ); SECTION( "coffee reduces fatigue, but does not give stimulant effect" ) { - item coffee( "coffee", 0, item::default_charges_tag{} ); + item coffee( "coffee", calendar::turn_zero, item::default_charges_tag{} ); dummy.consume( coffee ); CHECK( dummy.get_fatigue() == fatigue_before - coffee.get_comestible()->fatigue_mod ); CHECK( dummy.get_stim() == coffee.get_comestible()->stim ); } SECTION( "atomic caffeine greatly reduces fatigue, and increases stimulant effect" ) { - item atomic_coffee( "atomic_coffee", 0, item::default_charges_tag{} ); + item atomic_coffee( "atomic_coffee", calendar::turn_zero, item::default_charges_tag{} ); dummy.consume( atomic_coffee ); CHECK( dummy.get_fatigue() == fatigue_before - atomic_coffee.get_comestible()->fatigue_mod ); CHECK( dummy.get_stim() == atomic_coffee.get_comestible()->stim ); @@ -327,7 +327,7 @@ TEST_CASE( "towel", "[iuse][towel]" ) { avatar dummy; dummy.set_body(); - item towel( "towel", 0, item::default_charges_tag{} ); + item towel( "towel", calendar::turn_zero, item::default_charges_tag{} ); GIVEN( "avatar is wet" ) { // Saturate torso, head, and both arms @@ -447,7 +447,7 @@ TEST_CASE( "thorazine", "[iuse][thorazine]" ) { avatar dummy; dummy.set_fatigue( 0 ); - item thorazine( "thorazine", 0, item::default_charges_tag{} ); + item thorazine( "thorazine", calendar::turn_zero, item::default_charges_tag{} ); int charges_before = thorazine.charges; REQUIRE( charges_before >= 2 ); @@ -495,7 +495,7 @@ TEST_CASE( "thorazine", "[iuse][thorazine]" ) TEST_CASE( "prozac", "[iuse][prozac]" ) { avatar dummy; - item prozac( "prozac", 0, item::default_charges_tag{} ); + item prozac( "prozac", calendar::turn_zero, item::default_charges_tag{} ); SECTION( "prozac gives prozac and visible prozac effect" ) { REQUIRE_FALSE( dummy.has_effect( efftype_id( "took_prozac" ) ) ); @@ -557,7 +557,7 @@ TEST_CASE( "inhaler", "[iuse][inhaler]" ) TEST_CASE( "panacea", "[iuse][panacea]" ) { avatar dummy; - item panacea( "panacea", 0, item::default_charges_tag{} ); + item panacea( "panacea", calendar::turn_zero, item::default_charges_tag{} ); SECTION( "panacea gives cure-all effect" ) { REQUIRE_FALSE( dummy.has_effect( efftype_id( "cureall" ) ) ); @@ -570,7 +570,7 @@ TEST_CASE( "panacea", "[iuse][panacea]" ) TEST_CASE( "xanax", "[iuse][xanax]" ) { avatar dummy; - item xanax( "xanax", 0, item::default_charges_tag{} ); + item xanax( "xanax", calendar::turn_zero, item::default_charges_tag{} ); SECTION( "xanax gives xanax and visible xanax effects" ) { REQUIRE_FALSE( dummy.has_effect( efftype_id( "took_xanax" ) ) ); diff --git a/tests/morale_test.cpp b/tests/morale_test.cpp index 851f637dc533d..63b3ed21649c1 100644 --- a/tests/morale_test.cpp +++ b/tests/morale_test.cpp @@ -178,9 +178,9 @@ TEST_CASE( "player_morale_fancy_clothes", "[player_morale]" ) player_morale m; GIVEN( "a set of super fancy bride's clothes" ) { - const item dress_wedding( "dress_wedding", 0 ); // legs, torso | 8 + 2 | 10 - const item veil_wedding( "veil_wedding", 0 ); // eyes, mouth | 4 + 2 | 6 - const item heels( "heels", 0 ); // feet | 1 + 2 | 3 + const item dress_wedding( "dress_wedding", calendar::turn_zero ); // legs, torso | 8 + 2 | 10 + const item veil_wedding( "veil_wedding", calendar::turn_zero ); // eyes, mouth | 4 + 2 | 6 + const item heels( "heels", calendar::turn_zero ); // feet | 1 + 2 | 3 m.on_item_wear( dress_wedding ); m.on_item_wear( veil_wedding ); @@ -218,7 +218,7 @@ TEST_CASE( "player_morale_fancy_clothes", "[player_morale]" ) } } AND_WHEN( "tries to be even fancier" ) { - const item watch( "sf_watch", 0 ); + const item watch( "sf_watch", calendar::turn_zero ); m.on_item_wear( watch ); THEN( "there's a limit" ) { CHECK( m.get_level() == 20 ); @@ -352,7 +352,7 @@ TEST_CASE( "player_morale_plant", "[player_morale]" ) CHECK( m.has( MORALE_PERM_CONSTRAINED ) == 0 ); WHEN( "wearing a hat" ) { - const item hat( "tinfoil_hat", 0 ); + const item hat( "tinfoil_hat", calendar::turn_zero ); m.on_item_wear( hat ); THEN( "the flowers need sunlight" ) { @@ -366,7 +366,7 @@ TEST_CASE( "player_morale_plant", "[player_morale]" ) } WHEN( "wearing a legpouch" ) { - item legpouch( "legpouch", 0 ); + item legpouch( "legpouch", calendar::turn_zero ); legpouch.set_side( side::LEFT ); m.on_item_wear( legpouch ); @@ -376,7 +376,7 @@ TEST_CASE( "player_morale_plant", "[player_morale]" ) } WHEN( "wearing a pair of boots" ) { - const item boots( "boots", 0 ); + const item boots( "boots", calendar::turn_zero ); m.on_item_wear( boots ); THEN( "all of the roots are suffering" ) { @@ -384,7 +384,7 @@ TEST_CASE( "player_morale_plant", "[player_morale]" ) } AND_WHEN( "even more constrains" ) { - const item hat( "tinfoil_hat", 0 ); + const item hat( "tinfoil_hat", calendar::turn_zero ); m.on_item_wear( hat ); THEN( "it can't be worse" ) { diff --git a/tests/npc_talk_test.cpp b/tests/npc_talk_test.cpp index 2b355bd3ed66e..e3ac483e01dcd 100644 --- a/tests/npc_talk_test.cpp +++ b/tests/npc_talk_test.cpp @@ -459,12 +459,12 @@ TEST_CASE( "npc_talk_time", "[npc_talk]" ) prep_test( d ); const time_point old_calendar = calendar::turn; - calendar::turn = to_turn( sunrise( calendar::turn ) + 4_hours ); + calendar::turn = sunrise( calendar::turn ) + 4_hours; d.add_topic( "TALK_TEST_TIME" ); gen_response_lines( d, 2 ); CHECK( d.responses[0].text == "This is a basic test response." ); CHECK( d.responses[1].text == "This is a is day test response." ); - calendar::turn = to_turn( sunset( calendar::turn ) + 2_hours ); + calendar::turn = sunset( calendar::turn ) + 2_hours; gen_response_lines( d, 2 ); CHECK( d.responses[0].text == "This is a basic test response." ); CHECK( d.responses[1].text == "This is a is night test response." ); diff --git a/tests/npc_test.cpp b/tests/npc_test.cpp index 8b72a4cabb681..287e10dfec53a 100644 --- a/tests/npc_test.cpp +++ b/tests/npc_test.cpp @@ -35,9 +35,9 @@ class Creature; static void on_load_test( npc &who, const time_duration &from, const time_duration &to ) { - calendar::turn = to_turn( calendar::turn_zero + from ); + calendar::turn = calendar::turn_zero + from; who.on_unload(); - calendar::turn = to_turn( calendar::turn_zero + to ); + calendar::turn = calendar::turn_zero + to; who.on_load(); } diff --git a/tests/overmap_test.cpp b/tests/overmap_test.cpp index 7d801013b1c8f..ae24b6a8c3553 100644 --- a/tests/overmap_test.cpp +++ b/tests/overmap_test.cpp @@ -23,14 +23,16 @@ TEST_CASE( "set_and_get_overmap_scents" ) for( int x = 0; x < 180; ++x ) { for( int y = 0; y < 180; ++y ) { for( int z = -10; z < 10; ++z ) { - REQUIRE( test_overmap->scent_at( { x, y, z } ).creation_time == -1 ); + REQUIRE( test_overmap->scent_at( { x, y, z } ).creation_time == + calendar::before_time_starts ); } } } - scent_trace test_scent( 50, 90 ); + time_point creation_time = calendar::turn_zero + 50_turns; + scent_trace test_scent( creation_time, 90 ); test_overmap->set_scent( { 75, 85, 0 }, test_scent ); - REQUIRE( test_overmap->scent_at( { 75, 85, 0} ).creation_time == 50 ); + REQUIRE( test_overmap->scent_at( { 75, 85, 0} ).creation_time == creation_time ); REQUIRE( test_overmap->scent_at( { 75, 85, 0} ).initial_strength == 90 ); } diff --git a/tests/player_test.cpp b/tests/player_test.cpp index db85f583a2020..dffe46954050d 100644 --- a/tests/player_test.cpp +++ b/tests/player_test.cpp @@ -37,7 +37,7 @@ static void temperature_check( Character *p, const int ambient_temp, const int t static void equip_clothing( Character *p, const std::string &clothing ) { - const item article( clothing, 0 ); + const item article( clothing, calendar::turn_zero ); p->wear_item( article ); } diff --git a/tests/pocket_test.cpp b/tests/pocket_test.cpp index 3865f214343df..2efb22a7f96cd 100644 --- a/tests/pocket_test.cpp +++ b/tests/pocket_test.cpp @@ -341,13 +341,13 @@ TEST_CASE( "magazine with ammo restriction", "[pocket][magazine][ammo_restrictio REQUIRE( pocket_mag.empty() ); THEN( "it can contain a full clip of 9mm ammo" ) { - const item ammo_9mm( "test_9mm_ammo", 0, full_clip_qty ); + const item ammo_9mm( "test_9mm_ammo", calendar::turn_zero, full_clip_qty ); expect_can_contain( pocket_mag, ammo_9mm ); } THEN( "it cannot contain items of the wrong ammo type" ) { item rock( "test_rock" ); - item ammo_45( "test_45_ammo", 0, 1 ); + item ammo_45( "test_45_ammo", calendar::turn_zero, 1 ); expect_cannot_contain( pocket_mag, rock, "item is not the correct ammo type", item_pocket::contain_code::ERR_AMMO ); expect_cannot_contain( pocket_mag, ammo_45, "item is not the correct ammo type", @@ -363,16 +363,18 @@ TEST_CASE( "magazine with ammo restriction", "[pocket][magazine][ammo_restrictio WHEN( "it is partly full of ammo" ) { const int half_clip_qty = full_clip_qty / 2; - item ammo_9mm_half_clip( "test_9mm_ammo", 0, half_clip_qty ); + item ammo_9mm_half_clip( "test_9mm_ammo", calendar::turn_zero, half_clip_qty ); expect_can_insert( pocket_mag, ammo_9mm_half_clip ); THEN( "it can contain more of the same ammo" ) { - item ammo_9mm_refill( "test_9mm_ammo", 0, full_clip_qty - half_clip_qty ); + item ammo_9mm_refill( "test_9mm_ammo", calendar::turn_zero, + full_clip_qty - half_clip_qty ); expect_can_contain( pocket_mag, ammo_9mm_refill ); } THEN( "it cannot contain more ammo than ammo_restriction allows" ) { - item ammo_9mm_overfill( "test_9mm_ammo", 0, full_clip_qty - half_clip_qty + 1 ); + item ammo_9mm_overfill( "test_9mm_ammo", calendar::turn_zero, + full_clip_qty - half_clip_qty + 1 ); expect_cannot_contain( pocket_mag, ammo_9mm_overfill, "tried to put too many charges of ammo in item", item_pocket::contain_code::ERR_NO_SPACE ); @@ -380,11 +382,11 @@ TEST_CASE( "magazine with ammo restriction", "[pocket][magazine][ammo_restrictio } WHEN( "it is completely full of ammo" ) { - item ammo_9mm_full_clip( "test_9mm_ammo", 0, full_clip_qty ); + item ammo_9mm_full_clip( "test_9mm_ammo", calendar::turn_zero, full_clip_qty ); expect_can_insert( pocket_mag, ammo_9mm_full_clip ); THEN( "it cannot contain any more of the same ammo" ) { - item ammo_9mm_bullet( "test_9mm_ammo", 0, 1 ); + item ammo_9mm_bullet( "test_9mm_ammo", calendar::turn_zero, 1 ); expect_cannot_contain( pocket_mag, ammo_9mm_bullet, "tried to put too many charges of ammo in item", item_pocket::contain_code::ERR_NO_SPACE ); @@ -625,8 +627,8 @@ TEST_CASE( "holster can contain one fitting item", "[pocket][holster]" ) TEST_CASE( "pockets containing liquids", "[pocket][watertight][liquid]" ) { // Liquids - item ketchup( "ketchup", 0, item::default_charges_tag{} ); - item mustard( "mustard", 0, item::default_charges_tag{} ); + item ketchup( "ketchup", calendar::turn_zero, item::default_charges_tag{} ); + item mustard( "mustard", calendar::turn_zero, item::default_charges_tag{} ); // Non-liquids item rock( "test_rock" ); @@ -724,7 +726,7 @@ TEST_CASE( "pockets containing liquids", "[pocket][watertight][liquid]" ) // TEST_CASE( "pockets containing gases", "[pocket][airtight][gas]" ) { - item gas( "test_gas", 0, item::default_charges_tag{} ); + item gas( "test_gas", calendar::turn_zero, item::default_charges_tag{} ); // A potentially airtight container pocket_data data_balloon( item_pocket::pocket_type::CONTAINER ); @@ -1092,7 +1094,7 @@ TEST_CASE( "best pocket in item contents", "[pocket][item][best]" ) REQUIRE( util_belt.can_contain( halligan ) ); // It can contain liquid and gas item liquid( "test_liquid" ); - item gas( "test_gas", 0, item::default_charges_tag{} ); + item gas( "test_gas", calendar::turn_zero, item::default_charges_tag{} ); REQUIRE( util_belt.can_contain( liquid ) ); REQUIRE( util_belt.can_contain( gas ) ); diff --git a/tests/reload_option_test.cpp b/tests/reload_option_test.cpp index ed1807b273baf..fa3564e4a70a3 100644 --- a/tests/reload_option_test.cpp +++ b/tests/reload_option_test.cpp @@ -17,9 +17,10 @@ TEST_CASE( "revolver_reload_option", "[reload],[reload_option],[gun]" ) avatar dummy; dummy.worn.push_back( item( "backpack" ) ); - item &gun = dummy.i_add( item( "sw_619", 0, 0 ) ); + item &gun = dummy.i_add( item( "sw_619", calendar::turn_zero, 0 ) ); const ammotype &gun_ammo_type = item::find_type( gun.ammo_default() )->ammo->type; - item &ammo = dummy.i_add( item( "38_special", 0, gun.ammo_capacity( gun_ammo_type ) ) ); + item &ammo = dummy.i_add( item( "38_special", calendar::turn_zero, + gun.ammo_capacity( gun_ammo_type ) ) ); item_location ammo_location( dummy, &ammo ); REQUIRE( gun.has_flag( flag_id( "RELOAD_ONE" ) ) ); REQUIRE( gun.ammo_remaining() == 0 ); @@ -28,7 +29,7 @@ TEST_CASE( "revolver_reload_option", "[reload],[reload_option],[gun]" ) REQUIRE( gun_option.qty() == 1 ); ammo_location = item_location( dummy, &ammo ); - item &speedloader = dummy.i_add( item( "38_speedloader", 0, 0 ) ); + item &speedloader = dummy.i_add( item( "38_speedloader", calendar::turn_zero, 0 ) ); REQUIRE( speedloader.ammo_remaining() == 0 ); const item::reload_option speedloader_option( &dummy, &speedloader, &speedloader, @@ -47,9 +48,10 @@ TEST_CASE( "magazine_reload_option", "[reload],[reload_option],[gun]" ) avatar dummy; dummy.worn.push_back( item( "backpack" ) ); - item &magazine = dummy.i_add( item( "glockmag", 0, 0 ) ); + item &magazine = dummy.i_add( item( "glockmag", calendar::turn_zero, 0 ) ); const ammotype &mag_ammo_type = item::find_type( magazine.ammo_default() )->ammo->type; - item &ammo = dummy.i_add( item( "9mm", 0, magazine.ammo_capacity( mag_ammo_type ) ) ); + item &ammo = dummy.i_add( item( "9mm", calendar::turn_zero, + magazine.ammo_capacity( mag_ammo_type ) ) ); item_location ammo_location( dummy, &ammo ); const item::reload_option magazine_option( &dummy, &magazine, &magazine, @@ -58,7 +60,7 @@ TEST_CASE( "magazine_reload_option", "[reload],[reload_option],[gun]" ) magazine.put_in( ammo, item_pocket::pocket_type::MAGAZINE ); item_location magazine_location( dummy, &magazine ); - item &gun = dummy.i_add( item( "glock_19", 0, 0 ) ); + item &gun = dummy.i_add( item( "glock_19", calendar::turn_zero, 0 ) ); const item::reload_option gun_option( &dummy, &gun, &gun, magazine_location ); CHECK( gun_option.qty() == 1 ); } @@ -69,10 +71,11 @@ TEST_CASE( "belt_reload_option", "[reload],[reload_option],[gun]" ) dummy.set_body(); dummy.worn.push_back( item( "backpack" ) ); - item &belt = dummy.i_add( item( "belt308", 0, 0 ) ); + item &belt = dummy.i_add( item( "belt308", calendar::turn_zero, 0 ) ); const ammotype &belt_ammo_type = item::find_type( belt.ammo_default() )->ammo->type; - item &ammo = dummy.i_add( item( "308", 0, belt.ammo_capacity( belt_ammo_type ) ) ); - dummy.i_add( item( "ammolink308", 0, belt.ammo_capacity( belt_ammo_type ) ) ); + item &ammo = dummy.i_add( item( "308", calendar::turn_zero, + belt.ammo_capacity( belt_ammo_type ) ) ); + dummy.i_add( item( "ammolink308", calendar::turn_zero, belt.ammo_capacity( belt_ammo_type ) ) ); item_location ammo_location( dummy, &ammo ); // Belt is populated with "charges" rounds by the item constructor. belt.ammo_unset(); @@ -83,7 +86,7 @@ TEST_CASE( "belt_reload_option", "[reload],[reload_option],[gun]" ) belt.put_in( ammo, item_pocket::pocket_type::MAGAZINE ); item_location belt_location( dummy, &ammo ); - item &gun = dummy.i_add( item( "m134", 0, 0 ) ); + item &gun = dummy.i_add( item( "m134", calendar::turn_zero, 0 ) ); const item::reload_option gun_option( &dummy, &gun, &gun, belt_location ); @@ -96,7 +99,7 @@ TEST_CASE( "canteen_reload_option", "[reload],[reload_option],[liquid]" ) dummy.worn.push_back( item( "backpack" ) ); item &bottle = dummy.i_add( item( "bottle_plastic" ) ); - item water( "water_clean", 0, 2 ); + item water( "water_clean", calendar::turn_zero, 2 ); // add an extra bottle with water item_location water_bottle( dummy, &dummy.i_add( bottle ) ); water_bottle->put_in( water, item_pocket::pocket_type::CONTAINER ); diff --git a/tests/reloading_test.cpp b/tests/reloading_test.cpp index c4f14bb78a0b0..5eb5317842d43 100644 --- a/tests/reloading_test.cpp +++ b/tests/reloading_test.cpp @@ -27,10 +27,10 @@ TEST_CASE( "reload_gun_with_integral_magazine", "[reload],[gun]" ) clear_avatar(); // Make sure the player doesn't drop anything :P - dummy.wear_item( item( "backpack", 0 ) ); + dummy.wear_item( item( "backpack", calendar::turn_zero ) ); - item &ammo = dummy.i_add( item( "40sw", 0, item::default_charges_tag{} ) ); - item &gun = dummy.i_add( item( "sw_610", 0, item::default_charges_tag{} ) ); + item &ammo = dummy.i_add( item( "40sw", calendar::turn_zero, item::default_charges_tag{} ) ); + item &gun = dummy.i_add( item( "sw_610", calendar::turn_zero, item::default_charges_tag{} ) ); REQUIRE( dummy.has_item( ammo ) ); REQUIRE( gun.ammo_remaining() == 0 ); @@ -48,11 +48,12 @@ TEST_CASE( "reload_gun_with_integral_magazine_using_speedloader", "[reload],[gun clear_avatar(); // Make sure the player doesn't drop anything :P - dummy.wear_item( item( "backpack", 0 ) ); + dummy.wear_item( item( "backpack", calendar::turn_zero ) ); - item &ammo = dummy.i_add( item( "38_special", 0, item::default_charges_tag{} ) ); - item &speedloader = dummy.i_add( item( "38_speedloader", 0, false ) ); - item &gun = dummy.i_add( item( "sw_619", 0, false ) ); + item &ammo = dummy.i_add( item( "38_special", calendar::turn_zero, + item::default_charges_tag{} ) ); + item &speedloader = dummy.i_add( item( "38_speedloader", calendar::turn_zero, false ) ); + item &gun = dummy.i_add( item( "sw_619", calendar::turn_zero, false ) ); REQUIRE( dummy.has_item( ammo ) ); REQUIRE( gun.ammo_remaining() == 0 ); @@ -81,13 +82,13 @@ TEST_CASE( "reload_gun_with_swappable_magazine", "[reload],[gun]" ) clear_avatar(); // Make sure the player doesn't drop anything :P - dummy.wear_item( item( "backpack", 0 ) ); + dummy.wear_item( item( "backpack", calendar::turn_zero ) ); - item &ammo = dummy.i_add( item( "9mm", 0, item::default_charges_tag{} ) ); + item &ammo = dummy.i_add( item( "9mm", calendar::turn_zero, item::default_charges_tag{} ) ); const cata::value_ptr &ammo_type = ammo.type->ammo; REQUIRE( ammo_type ); - const item mag( "glockmag", 0, 0 ); + const item mag( "glockmag", calendar::turn_zero, 0 ); const cata::value_ptr &magazine_type = mag.type->magazine; REQUIRE( magazine_type ); REQUIRE( magazine_type->type.count( ammo_type->type ) != 0 ); @@ -157,7 +158,7 @@ TEST_CASE( "automatic_reloading_action", "[reload],[gun]" ) clear_avatar(); // Make sure the player doesn't drop anything :P - dummy.wear_item( item( "backpack", 0 ) ); + dummy.wear_item( item( "backpack", calendar::turn_zero ) ); GIVEN( "an unarmed player" ) { REQUIRE( !dummy.is_armed() ); @@ -170,10 +171,10 @@ TEST_CASE( "automatic_reloading_action", "[reload],[gun]" ) } GIVEN( "a player armed with a revolver and ammo for it" ) { - item &ammo = dummy.i_add( item( "40sw", 0, 100 ) ); + item &ammo = dummy.i_add( item( "40sw", calendar::turn_zero, 100 ) ); REQUIRE( ammo.is_ammo() ); - dummy.weapon = item( "sw_610", 0, 0 ); + dummy.weapon = item( "sw_610", calendar::turn_zero, 0 ); REQUIRE( dummy.weapon.ammo_remaining() == 0 ); REQUIRE( dummy.weapon.can_reload_with( ammo.type->get_id() ) ); @@ -187,7 +188,7 @@ TEST_CASE( "automatic_reloading_action", "[reload],[gun]" ) } } GIVEN( "the player has another gun with ammo" ) { - item &gun2 = dummy.i_add( item( "sw_610", 0, 0 ) ); + item &gun2 = dummy.i_add( item( "sw_610", calendar::turn_zero, 0 ) ); REQUIRE( gun2.ammo_remaining() == 0 ); REQUIRE( gun2.can_reload_with( ammo.type->get_id() ) ); WHEN( "the player triggers auto reload until the first revolver is full" ) { @@ -208,17 +209,17 @@ TEST_CASE( "automatic_reloading_action", "[reload],[gun]" ) GIVEN( "a player wielding an unloaded gun, carrying an unloaded magazine, and carrying ammo for the magazine" ) { dummy.worn.clear(); dummy.worn.push_back( item( "backpack" ) ); - item &ammo = dummy.i_add( item( "9mm", 0, 50 ) ); + item &ammo = dummy.i_add( item( "9mm", calendar::turn_zero, 50 ) ); const cata::value_ptr &ammo_type = ammo.type->ammo; REQUIRE( ammo_type ); - item &mag = dummy.i_add( item( "glockmag", 0, 0 ) ); + item &mag = dummy.i_add( item( "glockmag", calendar::turn_zero, 0 ) ); const cata::value_ptr &magazine_type = mag.type->magazine; REQUIRE( magazine_type ); REQUIRE( magazine_type->type.count( ammo_type->type ) != 0 ); REQUIRE( mag.ammo_remaining() == 0 ); - dummy.weapon = item( "glock_19", 0, 0 ); + dummy.weapon = item( "glock_19", calendar::turn_zero, 0 ); REQUIRE( dummy.weapon.ammo_remaining() == 0 ); WHEN( "the player triggers auto reload" ) { @@ -251,7 +252,7 @@ TEST_CASE( "automatic_reloading_action", "[reload],[gun]" ) } } GIVEN( "the player also has an extended magazine" ) { - item &mag2 = dummy.i_add( item( "glockbigmag", 0, 0 ) ); + item &mag2 = dummy.i_add( item( "glockbigmag", calendar::turn_zero, 0 ) ); const cata::value_ptr &magazine_type2 = mag2.type->magazine; REQUIRE( magazine_type2 ); REQUIRE( magazine_type2->type.count( ammo_type->type ) != 0 ); @@ -316,7 +317,8 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" ) REQUIRE( dummy.wield( canteen ) ) ; item &ammo_jug = dummy.i_add( item( "jug_plastic" ) ); - ammo_jug.put_in( item( "water_clean", 0, 2 ), item_pocket::pocket_type::CONTAINER ); + ammo_jug.put_in( item( "water_clean", calendar::turn_zero, 2 ), + item_pocket::pocket_type::CONTAINER ); units::volume ammo_volume = ammo_jug.contents.total_contained_volume(); SECTION( "reload liquid into empty container" ) { @@ -328,7 +330,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" ) } SECTION( "reload liquid into partially filled container with same type liquid" ) { - item water_one( "water_clean", 0, 1 ); + item water_one( "water_clean", calendar::turn_zero, 1 ); units::volume initial_volume = water_one.volume(); dummy.weapon.put_in( water_one, item_pocket::pocket_type::CONTAINER ); g->reload_wielded(); @@ -339,7 +341,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" ) } SECTION( "reload liquid into partially filled container with different type liquid" ) { - item milk_one( "milk", 0, 1 ); + item milk_one( "milk", calendar::turn_zero, 1 ); units::volume initial_volume = milk_one.volume(); dummy.weapon.put_in( milk_one, item_pocket::pocket_type::CONTAINER ); g->reload_wielded(); @@ -351,7 +353,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" ) } SECTION( "reload liquid into container containing a non-liquid" ) { - item pebble( "pebble", 0, 1 ); + item pebble( "pebble", calendar::turn_zero, 1 ); units::volume initial_volume = pebble.volume(); dummy.weapon.put_in( pebble, item_pocket::pocket_type::CONTAINER ); g->reload_wielded(); @@ -363,7 +365,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" ) } SECTION( "reload liquid container with more liquid than it can hold" ) { - ammo_jug.fill_with( item( "water_clean", 0, 1 ) ); + ammo_jug.fill_with( item( "water_clean", calendar::turn_zero, 1 ) ); ammo_volume = ammo_jug.contents.total_contained_volume(); g->reload_wielded(); REQUIRE( dummy.activity ); diff --git a/tests/temperature_test.cpp b/tests/temperature_test.cpp index f581be206678a..a9ea748f1f765 100644 --- a/tests/temperature_test.cpp +++ b/tests/temperature_test.cpp @@ -85,17 +85,17 @@ TEST_CASE( "Rate of temperature change" ) set_map_temperature( 68 ); // 20C - calendar::turn = to_turn( calendar::turn + 11_minutes ); + calendar::turn += 11_minutes; water1.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 20_minutes ); + calendar::turn += 20_minutes; water1.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 29_minutes ); + calendar::turn += 29_minutes; water1.process_temperature_rot( 1, tripoint_zero, nullptr ); water2.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 15_minutes ); + calendar::turn += 15_minutes; water1.process_temperature_rot( 1, tripoint_zero, nullptr ); water2.process_temperature_rot( 1, tripoint_zero, nullptr ); @@ -126,7 +126,7 @@ TEST_CASE( "Rate of temperature change" ) set_map_temperature( -4 ); // -20 C - calendar::turn = to_turn( calendar::turn + 15_minutes ); + calendar::turn += 15_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); meat2.process_temperature_rot( 1, tripoint_zero, nullptr ); @@ -134,12 +134,12 @@ TEST_CASE( "Rate of temperature change" ) CHECK( is_nearly( meat1.temperature, 30673432 ) ); CHECK( !meat1.has_own_flag( flag_HOT ) ); - calendar::turn = to_turn( calendar::turn + 11_minutes ); + calendar::turn += 11_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 11_minutes ); + calendar::turn += 11_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 30_minutes ); + calendar::turn += 30_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); meat2.process_temperature_rot( 1, tripoint_zero, nullptr ); // 0C @@ -149,10 +149,10 @@ TEST_CASE( "Rate of temperature change" ) CHECK( !meat1.has_own_flag( flag_FROZEN ) ); CHECK( !meat2.has_own_flag( flag_FROZEN ) ); - calendar::turn = to_turn( calendar::turn + 60_minutes ); + calendar::turn += 60_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); meat2.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 60_minutes ); + calendar::turn += 60_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); meat2.process_temperature_rot( 1, tripoint_zero, nullptr ); @@ -164,12 +164,12 @@ TEST_CASE( "Rate of temperature change" ) CHECK( meat2.has_own_flag( flag_FROZEN ) ); CHECK( is_nearly( meat1.specific_energy, meat2.specific_energy ) ); - calendar::turn = to_turn( calendar::turn + 11_minutes ); + calendar::turn += 11_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 20_minutes ); + calendar::turn += 20_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 20_minutes ); + calendar::turn += 20_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); meat2.process_temperature_rot( 1, tripoint_zero, nullptr ); @@ -208,18 +208,18 @@ TEST_CASE( "Rate of temperature change" ) set_map_temperature( 68 ); // 20 C - calendar::turn = to_turn( calendar::turn + 11_minutes ); + calendar::turn += 11_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); // -5.2 C CHECK( is_nearly( meat1.temperature, 26789608 ) ); - calendar::turn = to_turn( calendar::turn + 11_minutes ); + calendar::turn += 11_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 11_minutes ); + calendar::turn += 11_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 20_minutes ); + calendar::turn += 20_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); meat2.process_temperature_rot( 1, tripoint_zero, nullptr ); @@ -231,11 +231,11 @@ TEST_CASE( "Rate of temperature change" ) CHECK( meat1.has_own_flag( flag_FROZEN ) ); CHECK( meat2.has_own_flag( flag_FROZEN ) ); - calendar::turn = to_turn( calendar::turn + 45_minutes ); + calendar::turn += 45_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); meat2.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 45_minutes ); + calendar::turn += 45_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); meat2.process_temperature_rot( 1, tripoint_zero, nullptr ); @@ -246,12 +246,12 @@ TEST_CASE( "Rate of temperature change" ) CHECK( is_nearly( meat2.temperature, meat1.temperature ) ); CHECK( !meat1.has_own_flag( flag_FROZEN ) ); - calendar::turn = to_turn( calendar::turn + 11_minutes ); + calendar::turn += 11_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 20_minutes ); + calendar::turn += 20_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); - calendar::turn = to_turn( calendar::turn + 20_minutes ); + calendar::turn += 20_minutes; meat1.process_temperature_rot( 1, tripoint_zero, nullptr ); meat2.process_temperature_rot( 1, tripoint_zero, nullptr ); // 13.3 C @@ -277,13 +277,13 @@ TEST_CASE( "Temperature controlled location" ) CHECK( is_nearly( water1.temperature, 100000 * temp_to_kelvin( temperatures::normal ) ) ); - calendar::turn = to_turn( calendar::turn + 15_minutes ); + calendar::turn += 15_minutes; water1.process_temperature_rot( 1, tripoint_zero, nullptr, temperature_flag::HEATER ); CHECK( is_nearly( water1.temperature, 100000 * temp_to_kelvin( temperatures::normal ) ) ); - calendar::turn = to_turn( calendar::turn + 2_hours + 3_minutes ); + calendar::turn += 2_hours + 3_minutes; water1.process_temperature_rot( 1, tripoint_zero, nullptr, temperature_flag::HEATER ); diff --git a/tests/vehicle_drag_test.cpp b/tests/vehicle_drag_test.cpp index 408e1341b54c5..dea289b7be047 100644 --- a/tests/vehicle_drag_test.cpp +++ b/tests/vehicle_drag_test.cpp @@ -22,7 +22,7 @@ static const efftype_id effect_blind( "blind" ); static void clear_game_drag( const ter_id &terrain ) { // Set to turn 0 to prevent solars from producing power - calendar::turn = 0; + calendar::turn = calendar::turn_zero; clear_creatures(); clear_npcs(); diff --git a/tests/vehicle_efficiency_test.cpp b/tests/vehicle_efficiency_test.cpp index 85853ade1bf82..37a5794ab6617 100644 --- a/tests/vehicle_efficiency_test.cpp +++ b/tests/vehicle_efficiency_test.cpp @@ -37,7 +37,7 @@ static const efftype_id effect_blind( "blind" ); static void clear_game( const ter_id &terrain ) { // Set to turn 0 to prevent solars from producing power - calendar::turn = 0; + calendar::turn = calendar::turn_zero; clear_creatures(); clear_npcs(); clear_vehicles(); diff --git a/tests/vehicle_interact_test.cpp b/tests/vehicle_interact_test.cpp index 55d2732310f3f..61e61db47921e 100644 --- a/tests/vehicle_interact_test.cpp +++ b/tests/vehicle_interact_test.cpp @@ -71,10 +71,10 @@ TEST_CASE( "repair_vehicle_part" ) } SECTION( "UPS_modded_welder" ) { std::vector tools; - item welder( "welder", -1, 0 ); + item welder( "welder", calendar::turn_zero, 0 ); welder.put_in( item( "battery_ups" ), item_pocket::pocket_type::MOD ); tools.push_back( welder ); - tools.emplace_back( "UPS_off", -1, 500 ); + tools.emplace_back( "UPS_off", calendar::turn_zero, 500 ); tools.emplace_back( "goggles_welding" ); test_repair( tools, true ); } @@ -91,10 +91,10 @@ TEST_CASE( "repair_vehicle_part" ) } SECTION( "UPS_modded_welder_missing_charges" ) { std::vector tools; - item welder( "welder", -1, 0 ); + item welder( "welder", calendar::turn_zero, 0 ); welder.put_in( item( "battery_ups" ), item_pocket::pocket_type::MOD ); tools.push_back( welder ); - tools.emplace_back( "UPS_off", -1, 5 ); + tools.emplace_back( "UPS_off", calendar::turn_zero, 5 ); tools.emplace_back( "goggles_welding" ); test_repair( tools, false ); } diff --git a/tests/vehicle_ramp_test.cpp b/tests/vehicle_ramp_test.cpp index 68a546a3ad857..7a587923f91a9 100644 --- a/tests/vehicle_ramp_test.cpp +++ b/tests/vehicle_ramp_test.cpp @@ -24,7 +24,7 @@ static void clear_game_and_set_ramp( const int transit_x, bool use_ramp, bool up ) { // Set to turn 0 to prevent solars from producing power - calendar::turn = 0; + calendar::turn = calendar::turn_zero; clear_map(); clear_vehicles(); diff --git a/tests/visitable_test.cpp b/tests/visitable_test.cpp index 840309c47ada4..0bcfd78eee6d0 100644 --- a/tests/visitable_test.cpp +++ b/tests/visitable_test.cpp @@ -17,7 +17,7 @@ TEST_CASE( "visitable_summation" ) bottle_of_water.put_in( water_in_bottle, item_pocket::pocket_type::CONTAINER ); test_inv.add_item( bottle_of_water ); - const item unlimited_water( "water", 0, item::INFINITE_CHARGES ); + const item unlimited_water( "water", calendar::turn_zero, item::INFINITE_CHARGES ); test_inv.add_item( unlimited_water ); CHECK( test_inv.charges_of( itype_id( "water" ), item::INFINITE_CHARGES ) > 1 ); diff --git a/tests/weather_test.cpp b/tests/weather_test.cpp index cec3b9623b639..1886785f5f11a 100644 --- a/tests/weather_test.cpp +++ b/tests/weather_test.cpp @@ -52,7 +52,7 @@ TEST_CASE( "weather realism" ) const std::vector seeds = {317'024'741, 870'078'684, 1'192'447'748}; const weather_generator &wgen = get_weather().get_cur_weather_gen(); - const time_point begin = 0; + const time_point begin = calendar::turn_zero; const time_point end = begin + calendar::year_length(); const int n_days = to_days( end - begin ); const int n_hours = to_hours( 1_days ); @@ -66,7 +66,7 @@ TEST_CASE( "weather realism" ) // Collect generated weather data for a single year. for( time_point i = begin ; i < end ; i += 1_minutes ) { - w_point w = wgen.get_weather( tripoint_zero, to_turn( i ), seed ); + w_point w = wgen.get_weather( tripoint_zero, i, seed ); int day = to_days( time_past_new_year( i ) ); int minute = to_minutes( time_past_midnight( i ) ); temperature[day][minute] = w.temperature;