|
|
@@ -4591,8 +4591,8 @@ void map::make_active( item_location &loc ) |
|
|
|
static void apply_in_fridge(item &it) |
|
|
|
{ |
|
|
|
if (it.is_food()) { |
|
|
|
if (it.fridge == 0) { |
|
|
|
it.fridge = (int) calendar::turn; |
|
|
|
if( it.fridge == calendar::before_time_starts ) { |
|
|
|
it.fridge = calendar::turn; |
|
|
|
} |
|
|
|
// cool down of the HOT flag, is unsigned, don't go below 1 |
|
|
|
if ((it.has_flag("HOT")) && (it.item_counter > 10)) { |
|
|
@@ -6590,7 +6590,7 @@ void map::saven( const int gridx, const int gridy, const int gridz ) |
|
|
|
|
|
|
|
dbg( D_INFO ) << "map::saven abs_x: " << abs_x << " abs_y: " << abs_y << " abs_z: " << abs_z |
|
|
|
<< " gridn: " << gridn; |
|
|
|
submap_to_save->turn_last_touched = int(calendar::turn); |
|
|
|
submap_to_save->last_touched = calendar::turn; |
|
|
|
MAPBUFFER.add_submap( abs_x, abs_y, abs_z, submap_to_save ); |
|
|
|
} |
|
|
|
|
|
|
@@ -6630,7 +6630,7 @@ static void generate_uniform( const int x, const int y, const int z, const ter_i |
|
|
|
submap *sm = new submap(); |
|
|
|
sm->is_uniform = true; |
|
|
|
std::uninitialized_fill_n( &sm->ter[0][0], block_size, terrain_type ); |
|
|
|
sm->turn_last_touched = int(calendar::turn); |
|
|
|
sm->last_touched = calendar::turn; |
|
|
|
MAPBUFFER.add_submap( x + xd, y + yd, z, sm ); |
|
|
|
} |
|
|
|
} |
|
|
@@ -6779,7 +6779,7 @@ void map::remove_rotten_items( Container &items, const tripoint &pnt ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void map::fill_funnels( const tripoint &p, int since_turn ) |
|
|
|
void map::fill_funnels( const tripoint &p, const time_point &since ) |
|
|
|
{ |
|
|
|
const auto &tr = tr_at( p ); |
|
|
|
if( !tr.is_funnel() ) { |
|
|
@@ -6798,7 +6798,7 @@ void map::fill_funnels( const tripoint &p, int since_turn ) |
|
|
|
} |
|
|
|
} |
|
|
|
if( biggest_container != items.end() ) { |
|
|
|
retroactively_fill_from_funnel( *biggest_container, tr, since_turn, calendar::turn, getabs( p ) ); |
|
|
|
retroactively_fill_from_funnel( *biggest_container, tr, since, calendar::turn, getabs( p ) ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -6838,21 +6838,21 @@ void map::grow_plant( const tripoint &p ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void map::restock_fruits( const tripoint &p, int time_since_last_actualize ) |
|
|
|
void map::restock_fruits( const tripoint &p, const time_duration &time_since_last_actualize ) |
|
|
|
{ |
|
|
|
const auto &ter = this->ter( p ).obj(); |
|
|
|
if( !ter.has_flag( TFLAG_HARVESTED ) ) { |
|
|
|
return; // Already harvestable. Do nothing. |
|
|
|
} |
|
|
|
// Make it harvestable again if the last actualization was during a different season or year. |
|
|
|
const calendar last_touched = calendar::turn - time_since_last_actualize; |
|
|
|
const time_point last_touched = calendar::turn - time_since_last_actualize; |
|
|
|
if( season_of_year( calendar::turn ) != season_of_year( last_touched ) || |
|
|
|
time_since_last_actualize >= to_turns<int>( calendar::season_length() ) ) { |
|
|
|
time_since_last_actualize >= calendar::season_length() ) { |
|
|
|
ter_set( p, ter.transforms_into ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void map::produce_sap( const tripoint &p, int time_since_last_actualize ) |
|
|
|
void map::produce_sap( const tripoint &p, const time_duration &time_since_last_actualize ) |
|
|
|
{ |
|
|
|
if( time_since_last_actualize <= 0 ) { |
|
|
|
return; |
|
|
@@ -6866,34 +6866,33 @@ void map::produce_sap( const tripoint &p, int time_since_last_actualize ) |
|
|
|
static const int maple_sap_per_season = 56; |
|
|
|
|
|
|
|
// How many turns to produce 1 charge (250 ml) of sap? |
|
|
|
const int turns_season = to_turns<int>( calendar::season_length() ); |
|
|
|
const int producing_length = int( 0.75f * turns_season ); |
|
|
|
const time_duration producing_length = 0.75 * calendar::season_length(); |
|
|
|
|
|
|
|
const int turns_to_produce = producing_length / ( maple_sap_per_season * 4 ); |
|
|
|
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)? |
|
|
|
int time_producing = 0; |
|
|
|
time_duration time_producing = 0; |
|
|
|
|
|
|
|
if( time_since_last_actualize >= to_turns<int>( calendar::year_length() ) ) { |
|
|
|
if( time_since_last_actualize >= calendar::year_length() ) { |
|
|
|
time_producing = producing_length; |
|
|
|
} else { |
|
|
|
// We are only producing sap on the intersection with the sap producing season. |
|
|
|
int early_spring_end = int( 0.5f * turns_season ); |
|
|
|
int late_winter_start = int( 3.75f * turns_season ); |
|
|
|
const time_duration early_spring_end = 0.5f * calendar::season_length(); |
|
|
|
const time_duration late_winter_start = 3.75f * calendar::season_length(); |
|
|
|
|
|
|
|
calendar last_actualize = calendar::turn - time_since_last_actualize; |
|
|
|
int last_actualize_tof = last_actualize.turn_of_year(); |
|
|
|
const time_point last_actualize = calendar::turn - time_since_last_actualize; |
|
|
|
const time_duration last_actualize_tof = time_past_new_year( last_actualize ); |
|
|
|
bool last_producing = ( |
|
|
|
last_actualize_tof >= late_winter_start || |
|
|
|
last_actualize_tof < early_spring_end |
|
|
|
); |
|
|
|
int current_tof = calendar::turn.turn_of_year(); |
|
|
|
const time_duration current_tof = time_past_new_year( calendar::turn ); |
|
|
|
bool current_producing = ( |
|
|
|
current_tof >= late_winter_start || |
|
|
|
current_tof < early_spring_end |
|
|
|
); |
|
|
|
|
|
|
|
int non_producing_length = int( 3.25f * turns_season ); |
|
|
|
const time_duration non_producing_length = 3.25 * calendar::season_length(); |
|
|
|
|
|
|
|
if( last_producing && current_producing ) { |
|
|
|
if( time_since_last_actualize < non_producing_length ) { |
|
|
@@ -6910,19 +6909,19 @@ void map::produce_sap( const tripoint &p, int time_since_last_actualize ) |
|
|
|
if( last_actualize_tof < early_spring_end ) { |
|
|
|
time_producing = early_spring_end - last_actualize_tof; |
|
|
|
} else { |
|
|
|
time_producing = to_turns<int>( calendar::year_length() ) - last_actualize_tof + early_spring_end; |
|
|
|
time_producing = calendar::year_length() - last_actualize_tof + early_spring_end; |
|
|
|
} |
|
|
|
} else if ( !last_producing && current_producing ) { |
|
|
|
// We hit the start of late winter |
|
|
|
if( current_tof >= late_winter_start ) { |
|
|
|
time_producing = current_tof - late_winter_start; |
|
|
|
} else { |
|
|
|
time_producing = int( 0.25f * turns_season ) + current_tof; |
|
|
|
time_producing = 0.25f * calendar::season_length() + current_tof; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
long new_charges = roll_remainder( (double)time_producing / turns_to_produce ); |
|
|
|
long new_charges = roll_remainder( time_producing / turns_to_produce ); |
|
|
|
// Not enough time to produce 1 charge of sap |
|
|
|
if( new_charges <= 0 ) { |
|
|
|
return; |
|
|
@@ -6950,15 +6949,15 @@ void map::produce_sap( const tripoint &p, int time_since_last_actualize ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void map::rad_scorch( const tripoint &p, int time_since_last_actualize ) |
|
|
|
void map::rad_scorch( const tripoint &p, const time_duration &time_since_last_actualize ) |
|
|
|
{ |
|
|
|
const int rads = get_radiation( p ); |
|
|
|
if( rads == 0 ) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: More interesting rad scorch chance - base on season length? |
|
|
|
if( !x_in_y( 1.0 * rads * rads * time_since_last_actualize, DAYS(91) ) ) { |
|
|
|
if( !x_in_y( 1.0 * rads * rads * time_since_last_actualize, 91_days ) ) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@@ -6996,16 +6995,16 @@ void map::rad_scorch( const tripoint &p, int time_since_last_actualize ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void map::decay_cosmetic_fields( const tripoint &p, int time_since_last_actualize ) |
|
|
|
void map::decay_cosmetic_fields( const tripoint &p, const time_duration &time_since_last_actualize ) |
|
|
|
{ |
|
|
|
for( auto &pr : field_at( p ) ) { |
|
|
|
auto &fd = pr.second; |
|
|
|
if( !fd.decays_on_actualize() ) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
const int added_age = 2 * time_since_last_actualize / rng( 2, 4 ); |
|
|
|
fd.mod_age( added_age ); |
|
|
|
const time_duration added_age = 2 * time_since_last_actualize / rng( 2, 4 ); |
|
|
|
fd.mod_age( to_turns<int>( added_age ) ); |
|
|
|
const int hl = fieldlist[ fd.getFieldType() ].halflife; |
|
|
|
const int density_drop = fd.getFieldAge() / hl; |
|
|
|
if( density_drop > 0 ) { |
|
|
@@ -7023,7 +7022,7 @@ void map::actualize( const int gridx, const int gridy, const int gridz ) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const auto time_since_last_actualize = calendar::turn - tmpsub->turn_last_touched; |
|
|
|
const time_duration time_since_last_actualize = calendar::turn - tmpsub->last_touched; |
|
|
|
const bool do_funnels = ( gridz >= 0 ); |
|
|
|
|
|
|
|
// check spoiled stuff, and fill up funnels while we're at it |
|
|
@@ -7047,7 +7046,7 @@ void map::actualize( const int gridx, const int gridy, const int gridz ) |
|
|
|
} |
|
|
|
|
|
|
|
if( do_funnels ) { |
|
|
|
fill_funnels( pnt, tmpsub->turn_last_touched ); |
|
|
|
fill_funnels( pnt, tmpsub->last_touched ); |
|
|
|
} |
|
|
|
|
|
|
|
grow_plant( pnt ); |
|
|
@@ -7064,13 +7063,13 @@ void map::actualize( const int gridx, const int gridy, const int gridz ) |
|
|
|
|
|
|
|
//Check for Merchants to restock |
|
|
|
for( npc &guy : g->all_npcs() ) { |
|
|
|
if( guy.restock > 0 && calendar::turn > guy.restock ) { |
|
|
|
if( guy.restock != calendar::before_time_starts && calendar::turn > guy.restock ) { |
|
|
|
guy.shop_restock(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// the last time we touched the submap, is right now. |
|
|
|
tmpsub->turn_last_touched = calendar::turn; |
|
|
|
tmpsub->last_touched = calendar::turn; |
|
|
|
} |
|
|
|
|
|
|
|
void map::add_roofs( const int gridx, const int gridy, const int gridz ) |
|
|
|
@BevapDin: People say weather became somewhat colder (https://discourse.cataclysmdda.org/t/15260) and this line is likely candidate.
Shouldn't it be
const double now( ( time_past_new_year( t ) + calendar::season_length() / 2 ) / calendar::year_length() ), actually?