Merge branch 'auto_timetables' into auto_timetables-sx

# Conflicts:
#	src/saveload/saveload.h
This commit is contained in:
Jonathan G Rennison 2016-01-30 16:05:56 +00:00
commit b43c08857b
2 changed files with 10 additions and 12 deletions

View File

@ -315,6 +315,9 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1,
ClrBit(w->vehicle_flags, VF_TIMETABLE_STARTED); ClrBit(w->vehicle_flags, VF_TIMETABLE_STARTED);
/* Do multiplication, then division to reduce rounding errors. */ /* Do multiplication, then division to reduce rounding errors. */
w->timetable_start = start_date + idx * total_duration / num_vehs / DAY_TICKS; 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); 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 < 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); 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)) { } else if (timetabled == 0 && HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)) {
/* Add times for orders that are not yet timetabled, even while not autofilling */ /* Add times for orders that are not yet timetabled, even while not autofilling */
if (travelling) if (travelling) {
ChangeTimetable(v, v->cur_real_order_index, time_taken, travelling ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true); ChangeTimetable(v, v->cur_real_order_index, time_taken, MTF_TRAVEL_TIME, true);
else } else {
ChangeTimetable(v, v->cur_real_order_index, time_loading, travelling ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true); 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 /* Vehicles will wait at stations if they arrive early even if they are not

View File

@ -192,12 +192,8 @@ public:
CargoPayment *cargo_payment; ///< The cargo payment we're currently in CargoPayment *cargo_payment; ///< The cargo payment we're currently in
/* Used for timetabling. */ /* 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. 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. 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_this_year = src->profit_this_year;
this->profit_last_year = src->profit_last_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->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_TIMETABLE_STARTED)) SetBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
if (HasBit(src->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(this->vehicle_flags, VF_AUTOFILL_TIMETABLE); if (HasBit(src->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(this->vehicle_flags, VF_AUTOFILL_TIMETABLE);