Merge branch 'master' into jgrpp
# Conflicts: # src/articulated_vehicles.cpp # src/articulated_vehicles.h # src/base_media_base.h # src/base_media_func.h # src/build_vehicle_gui.cpp # src/dock_gui.cpp # src/main_gui.cpp # src/music_gui.cpp # src/network/network_chat_gui.cpp # src/network/network_content.cpp # src/newgrf.cpp # src/newgrf_roadstop.cpp # src/os/windows/string_uniscribe.h # src/os/windows/win32.cpp # src/rail_gui.cpp # src/road.cpp # src/road_gui.cpp # src/settings.cpp # src/settings_gui.cpp # src/smallmap_gui.cpp # src/strings.cpp # src/terraform_gui.cpp # src/tests/test_script_admin.cpp # src/tests/test_window_desc.cpp # src/timer/timer_game_calendar.h # src/vehicle.cpp # src/vehicle_base.h # src/viewport.cpp # src/widget_type.h # src/window.cpp # src/window_gui.h
This commit is contained in:
@@ -389,6 +389,10 @@ CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||
Vehicle *v = Vehicle::GetIfValid(veh);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle() || v->orders == nullptr) return CMD_ERROR;
|
||||
|
||||
/* A vehicle can't be late if its timetable hasn't started.
|
||||
* If we're setting all vehicles in the group, we handle that below. */
|
||||
if (!apply_to_group && !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) return CommandCost(STR_ERROR_TIMETABLE_NOT_STARTED);
|
||||
|
||||
CommandCost ret = CheckOwnership(v->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
@@ -396,12 +400,18 @@ CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||
if (apply_to_group) {
|
||||
int32 most_late = 0;
|
||||
for (Vehicle *u = v->FirstShared(); u != nullptr; u = u->NextShared()) {
|
||||
/* A vehicle can't be late if its timetable hasn't started. */
|
||||
if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) continue;
|
||||
|
||||
if (u->lateness_counter > most_late) {
|
||||
most_late = u->lateness_counter;
|
||||
}
|
||||
}
|
||||
if (most_late > 0) {
|
||||
for (Vehicle *u = v->FirstShared(); u != nullptr; u = u->NextShared()) {
|
||||
/* A vehicle can't be late if its timetable hasn't started. */
|
||||
if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) continue;
|
||||
|
||||
u->lateness_counter -= most_late;
|
||||
SetWindowDirty(WC_VEHICLE_TIMETABLE, u->index);
|
||||
}
|
||||
|
Reference in New Issue
Block a user