void overmapbuffer::move_vehicle( vehicle *veh, const point &old_msp )
{
    const point new_msp = veh->real_global_pos();
    point old_omt = ms_to_omt_copy( old_msp );
    point new_omt = ms_to_omt_copy( new_msp );
    overmap &old_om = get_om_global( old_omt.x, old_omt.y );
    overmap &new_om = get_om_global( new_omt.x, new_omt.y );
    // *_omt is now local to the overmap, and it's in overmap terrain system
    if( &old_om == &new_om ) {
        new_om.vehicles[veh->om_id].x = new_omt.x;
        new_om.vehicles[veh->om_id].y = new_omt.y;
    } else {
        old_om.vehicles.erase( veh->om_id );
        add_vehicle( veh );
    }
}
void overmapbuffer::add_vehicle( vehicle *veh )
{
    point omt = ms_to_omt_copy( veh->real_global_pos() );
    overmap &om = get_om_global( omt.x, omt.y );
    int id = om.vehicles.size() + 1;
    // this *should* be unique but just in case
    while( om.vehicles.count( id ) > 0 ) {
        id++;
    }
    om_vehicle &tracked_veh = om.vehicles[id];
    tracked_veh.x = omt.x;
    tracked_veh.y = omt.y;
    tracked_veh.name = veh->name;
    veh->om_id = id;
}
Beispiel #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 = 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;
}
void overmapbuffer::remove_vehicle( const vehicle *veh )
{
    const point omt = ms_to_omt_copy( veh->real_global_pos() );
    overmap &om = get_om_global( omt );
    om.vehicles.erase( veh->om_id );
}
void overmapbuffer::remove_vehicle( const vehicle *veh )
{
    const point omt = ms_to_omt_copy( g->m.getabs( veh->global_pos3().x, veh->global_pos3().y ) );
    overmap &om = get_om_global( omt );
    om.vehicles.erase( veh->om_id );
}