summaryrefslogtreecommitdiff
path: root/vehicle.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-01-05 21:35:54 +0000
committertron <tron@openttd.org>2006-01-05 21:35:54 +0000
commitaf70b49bf737b03d83e239f5af1fdbc83c3674dc (patch)
tree36adc599aa918a785fc38a75ba97172dcddffef5 /vehicle.c
parent5ac1a89f924345f6c75a81423a41f95656070cc0 (diff)
downloadopenttd-af70b49bf737b03d83e239f5af1fdbc83c3674dc.tar.xz
(svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
As side effect this is a -Fix: The default AI tried to change the service intervals of vehicles via the CMD_CHANGE_TRAIN_SERVICE_INT command - regardless of the type of the vehicle - which of course failed for non-trains
Diffstat (limited to 'vehicle.c')
-rw-r--r--vehicle.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/vehicle.c b/vehicle.c
index 1193d2ebd..444bfaa10 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -1844,6 +1844,30 @@ int32 CmdNameVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
+/** Change the service interval of a vehicle
+ * @param x,y unused
+ * @param p1 vehicle ID that is being service-interval-changed
+ * @param p2 new service interval
+ */
+int32 CmdChangeServiceInt(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+{
+ Vehicle* v;
+ uint16 serv_int = GetServiceIntervalClamped(p2); /* Double check the service interval from the user-input */
+
+ if (serv_int != p2 || !IsVehicleIndex(p1)) return CMD_ERROR;
+
+ v = GetVehicle(p1);
+
+ if (v->type == 0 || !CheckOwnership(v->owner)) return CMD_ERROR;
+
+ if (flags & DC_EXEC) {
+ v->service_interval = serv_int;
+ InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
+ }
+
+ return 0;
+}
+
static Rect _old_vehicle_coords;