Ejemplo n.º 1
0
int get_rot_since( const int since, const int endturn ) {
    int ret = 0;
    int tbegin = since;
    int tend = endturn;
    // todo; hourly quick lookback, select weather_log from climate zone
    std::map<int, weather_segment>::iterator wit = g->weather_log.lower_bound( endturn );
    if ( wit == g->weather_log.end() ) { // missing wlog, debugmsg?
       return endturn-since;
    } else if ( wit->first > endturn ) { // incomplete wlog
       return ( (endturn-since) * get_hourly_rotpoints_at_temp(wit->second.temperature) ) / 600;
    }

    for( ;
         wit != g->weather_log.begin(); --wit
       ) {
       if ( wit->first <= endturn ) {
           tbegin = wit->first;
           if ( tbegin < since ) {
               tbegin = since;
               ret += ( (tend-tbegin) * get_hourly_rotpoints_at_temp(wit->second.temperature) );// / 600 ;
               tend = wit->first;
               break;
           }
           ret += ( (tend-tbegin) * get_hourly_rotpoints_at_temp(wit->second.temperature) );// / 600 ;
           tend = wit->first;
       }
    }
    if ( since < tbegin ) { // incomplete wlog
       ret += ( (tbegin-since) * get_hourly_rotpoints_at_temp(65) );
    }
    return ret / 600;
};
Ejemplo n.º 2
0
time_duration get_rot_since( const time_point &start, const time_point &end,
                             const tripoint &pos )
{
    time_duration ret = 0_turns;
    const auto &wgen = g->get_cur_weather_gen();
    /* Hoisting loop invariants */
    const auto location_temp = g->get_temperature( pos );
    const auto local = g->m.getlocal( pos );
    const auto local_mod = g->new_game ? 0 : g->m.temperature( local );
    const auto seed = g->get_seed();

    const auto temp_modify = ( !g->new_game ) && ( g->m.ter( local ) == t_rootcellar );

    for( time_point i = start; i < end; i += 1_hours ) {
        w_point w = wgen.get_weather( pos, i, seed );

        //Use weather if above ground, use map temp if below
        double temperature = ( pos.z >= 0 ? w.temperature : location_temp ) + local_mod;
        // If in a root celler: use AVERAGE_ANNUAL_TEMPERATURE
        // If not: use calculated temperature
        temperature = ( temp_modify * AVERAGE_ANNUAL_TEMPERATURE ) + ( !temp_modify * temperature );

        ret += std::min( 1_hours, end - i ) / 1_hours * get_hourly_rotpoints_at_temp(
                   temperature ) * 1_turns;
    }
    return ret;
}
Ejemplo n.º 3
0
int get_rot_since( const int startturn, const int endturn, const tripoint &location )
{
    // Ensure food doesn't rot in ice labs, where the
    // temperature is much less than the weather specifies.
    tripoint const omt_pos = overmapbuffer::ms_to_omt_copy( location );
    oter_id const & oter = overmap_buffer.ter( omt_pos );
    // TODO: extract this into a property of the overmap terrain
    if (is_ot_type("ice_lab", oter)) {
        return 0;
    }
    // TODO: maybe have different rotting speed when underground?
    int ret = 0;
    for (calendar i(startturn); i.get_turn() < endturn; i += 600) {
        w_point w = g->weather_gen->get_weather(location, i);
        ret += std::min(600, endturn - i.get_turn()) * get_hourly_rotpoints_at_temp(w.temperature) / 600;
    }
    return ret;
}
Ejemplo n.º 4
0
/**
 * Retroactively determine weather-related rotting effects.
 * Applies rot based on the temperatures incurred between a turn range.
 */
int get_rot_since( const int since, const int endturn, const point &location )
{
    // Hack: Ensure food doesn't rot in ice labs, where the
    // temperature is much less than the weather specifies.
    // http://github.com/CleverRaven/Cataclysm-DDA/issues/9162
    // Bug with this hack: Rot is prevented even when it's above
    // freezing on the ground floor.
    oter_id oter = overmap_buffer.ter(g->om_global_location());
    if (is_ot_type("ice_lab", oter)) {
        return 0;
    }
    int ret = 0;
    for (calendar i(since); i.get_turn() < endturn; i += 600) {
        w_point w = g->weatherGen.get_weather(location, i);
        ret += std::min(600, endturn - i.get_turn()) * get_hourly_rotpoints_at_temp(w.temperature) / 600;
    }
    return ret;
}