summaryrefslogtreecommitdiff
path: root/train_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
commit5693f22f187fc3a909ff6ac8ee41a56f5c4957f6 (patch)
tree200e057011df0475fd5c514b242f7105fc989644 /train_cmd.c
parent5285d0983262907f1cd96ae7124dada8176fdb1b (diff)
downloadopenttd-5693f22f187fc3a909ff6ac8ee41a56f5c4957f6.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 'train_cmd.c')
-rw-r--r--train_cmd.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 6d571bb25..75552704f 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -1481,20 +1481,21 @@ int32 CmdTrainGotoDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/** Change the service interval for trains.
* @param x,y unused
* @param p1 vehicle ID that is being service-interval-changed
- * @param p2 new service interval (0 - 65536)
+ * @param p2 new service interval
*/
int32 CmdChangeTrainServiceInt(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_Train || !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, 8);
}
@@ -3134,7 +3135,7 @@ static void CheckIfTrainNeedsService(Vehicle *v)
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
-int32 GetTrainRunningCost(Vehicle *v)
+int32 GetTrainRunningCost(const Vehicle *v)
{
int32 cost = 0;