diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 431ae548531a0..6ab5e9cb6964d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -5313,6 +5313,26 @@ void vehicle::idle( bool on_map ) update_time( calendar::turn ); } + map &here = get_map(); + // Parts emitting fields + const std::pair exhaust_and_muffle = get_exhaust_part(); + for( const int emitter_idx : emitters ) { + const vehicle_part &pt = parts[emitter_idx]; + if( pt.is_unavailable() || !pt.enabled ) { + continue; + } + for( const emit_id &e : pt.info().emissions ) { + here.emit_field( global_part_pos3( pt ), e ); + } + for( const emit_id &e : pt.info().exhaust ) { + if( exhaust_and_muffle.first == -1 ) { + here.emit_field( global_part_pos3( pt ), e ); + } else { + here.emit_field( exhaust_dest( exhaust_and_muffle.first ), e ); + } + } + } + if( has_part( "STEREO", true ) ) { play_music(); } @@ -7458,34 +7478,6 @@ void vehicle::update_time( const time_point &update_to ) } map &here = get_map(); - // Parts emitting fields - const std::pair exhaust_and_muffle = get_exhaust_part(); - for( const int emitter_idx : emitters ) { - const vehicle_part &pt = parts[emitter_idx]; - if( pt.is_unavailable() || !pt.enabled ) { - continue; - } - for( const emit_id &e : pt.info().emissions ) { - here.emit_field( global_part_pos3( pt ), e ); - } - for( const emit_id &e : pt.info().exhaust ) { - if( exhaust_and_muffle.first == -1 ) { - here.emit_field( global_part_pos3( pt ), e ); - } else { - here.emit_field( exhaust_dest( exhaust_and_muffle.first ), e ); - } - } - // reduce interval of parts with VPFLAG_ENABLED_DRAINS_EPOWER, otherwise their epower - // get charged twice - once by power_parts in vehicle::idle and once here - const time_duration interval = pt.info().has_flag( VPFLAG_ENABLED_DRAINS_EPOWER ) - ? update_to - last_update - 1_seconds - : update_to - last_update; - if( interval < 0_seconds ) { - debugmsg( "emitter simulating negative time interval, something is fishy / buggy" ); - break; - } - discharge_battery( power_to_energy_bat( -pt.info().epower, interval ) ); - } if( sm_pos.z < 0 ) { last_update = update_to;