Merge branch 'auto_timetables' into auto_timetables-sx

# Conflicts:
#	src/saveload/saveload.h
pull/6/merge
Jonathan G Rennison 9 years ago
commit b43c08857b

@ -315,6 +315,9 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1,
ClrBit(w->vehicle_flags, VF_TIMETABLE_STARTED);
/* Do multiplication, then division to reduce rounding errors. */
w->timetable_start = start_date + idx * total_duration / num_vehs / DAY_TICKS;
if (w->timetable_start < _date && idx < 0) {
w->timetable_start += (total_duration / DAY_TICKS);
}
SetWindowDirty(WC_VEHICLE_TIMETABLE, w->index);
}
@ -696,14 +699,16 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
}
if (new_time < 1) new_time = 1;
if (new_time != (int32)timetabled)
if (new_time != (int32)timetabled) {
ChangeTimetable(v, v->cur_real_order_index, new_time, travelling ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true);
}
} else if (timetabled == 0 && HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)) {
/* Add times for orders that are not yet timetabled, even while not autofilling */
if (travelling)
ChangeTimetable(v, v->cur_real_order_index, time_taken, travelling ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true);
else
ChangeTimetable(v, v->cur_real_order_index, time_loading, travelling ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true);
if (travelling) {
ChangeTimetable(v, v->cur_real_order_index, time_taken, MTF_TRAVEL_TIME, true);
} else {
ChangeTimetable(v, v->cur_real_order_index, time_loading, MTF_WAIT_TIME, true);
}
}
/* Vehicles will wait at stations if they arrive early even if they are not

@ -192,12 +192,8 @@ public:
CargoPayment *cargo_payment; ///< The cargo payment we're currently in
/* Used for timetabling. */
uint32 current_order_time; ///< How many ticks have passed since this order started.
uint32 current_loading_time; ///< How long loading took. Less than current_order_time if vehicle is early.
int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is.
Date timetable_start; ///< When the vehicle is supposed to start the timetable.
Rect coord; ///< NOSAVE: Graphical bounding box of the vehicle, i.e. what to redraw on moves.
@ -709,10 +705,7 @@ public:
this->profit_this_year = src->profit_this_year;
this->profit_last_year = src->profit_last_year;
this->current_order_time = src->current_order_time;
this->current_loading_time = src->current_loading_time;
this->lateness_counter = src->lateness_counter;
this->timetable_start = src->timetable_start;
if (HasBit(src->vehicle_flags, VF_TIMETABLE_STARTED)) SetBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
if (HasBit(src->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(this->vehicle_flags, VF_AUTOFILL_TIMETABLE);

Loading…
Cancel
Save