summaryrefslogtreecommitdiff
path: root/ship_cmd.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-05-11 16:17:03 +0000
committerDarkvater <darkvater@openttd.org>2005-05-11 16:17:03 +0000
commit729066e407731ca323a9b368b108c100c37044e3 (patch)
tree200e057011df0475fd5c514b242f7105fc989644 /ship_cmd.c
parentaa4f2d2db2e69a62914391d6e6f497302dc47391 (diff)
downloadopenttd-729066e407731ca323a9b368b108c100c37044e3.tar.xz
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Diffstat (limited to 'ship_cmd.c')
-rw-r--r--ship_cmd.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/ship_cmd.c b/ship_cmd.c
index 90810ad96..675b1ed05 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -51,7 +51,7 @@ void DrawShipEngineInfo(int engine, int x, int y, int maxw)
DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
}
-int GetShipImage(Vehicle *v, byte direction)
+int GetShipImage(const Vehicle *v, byte direction)
{
int spritenum = v->spritenum;
@@ -1032,19 +1032,24 @@ int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return 0;
}
+/** Change the service interval for ships.
+ * @param x,y unused
+ * @param p1 vehicle ID that is being service-interval-changed
+ * @param p2 new service interval
+ */
int32 CmdChangeShipServiceInt(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 (!IsVehicleIndex(p1)) return CMD_ERROR;
+ if (serv_int != p2 || !IsVehicleIndex(p1)) return CMD_ERROR;
v = GetVehicle(p1);
- if (v->type != VEH_Ship || !CheckOwnership(v->owner))
- return CMD_ERROR;
+ if (v->type != VEH_Ship || !CheckOwnership(v->owner)) return CMD_ERROR;
if (flags & DC_EXEC) {
- v->service_interval = (uint16)p2;
+ v->service_interval = serv_int;
InvalidateWindowWidget(WC_VEHICLE_DETAILS, v->index, 7);
}