summaryrefslogtreecommitdiff
path: root/train_gui.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 /train_gui.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 'train_gui.c')
-rw-r--r--train_gui.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/train_gui.c b/train_gui.c
index e95b7ca87..c6bcf66cd 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -280,7 +280,7 @@ static void ShowBuildTrainWindow(uint tile)
}
}
-static void DrawTrainImage(Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
+static void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
{
do {
if (--skip < 0) {
@@ -980,7 +980,7 @@ void ShowTrainViewWindow(Vehicle *v)
}
}
-static void TrainDetailsCargoTab(Vehicle *v, int x, int y)
+static void TrainDetailsCargoTab(const Vehicle *v, int x, int y)
{
int num;
StringID str;
@@ -998,7 +998,7 @@ static void TrainDetailsCargoTab(Vehicle *v, int x, int y)
}
}
-static void TrainDetailsInfoTab(Vehicle *v, int x, int y)
+static void TrainDetailsInfoTab(const Vehicle *v, int x, int y)
{
const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
@@ -1014,7 +1014,7 @@ static void TrainDetailsInfoTab(Vehicle *v, int x, int y)
}
}
-static void TrainDetailsCapacityTab(Vehicle *v, int x, int y)
+static void TrainDetailsCapacityTab(const Vehicle *v, int x, int y)
{
if (v->cargo_cap != 0) {
SetDParam(1, v->cargo_cap);
@@ -1023,7 +1023,7 @@ static void TrainDetailsCapacityTab(Vehicle *v, int x, int y)
}
}
-typedef void TrainDetailsDrawerProc(Vehicle *v, int x, int y);
+typedef void TrainDetailsDrawerProc(const Vehicle *v, int x, int y);
static TrainDetailsDrawerProc * const _train_details_drawer_proc[3] = {
TrainDetailsCargoTab,
@@ -1033,7 +1033,7 @@ static TrainDetailsDrawerProc * const _train_details_drawer_proc[3] = {
static void DrawTrainDetailsWindow(Window *w)
{
- Vehicle *v, *u;
+ const Vehicle *v, *u;
uint16 tot_cargo[NUM_CARGO][2]; // count total cargo ([0]-actual cargo, [1]-total cargo)
int max_speed = 0xFFFF;
int i,num,x,y,sel;
@@ -1151,14 +1151,14 @@ static void DrawTrainDetailsWindow(Window *w)
static void TrainDetailsWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
DrawTrainDetailsWindow(w);
break;
case WE_CLICK: {
int mod;
- Vehicle *v;
- switch(e->click.widget) {
+ const Vehicle *v;
+ switch (e->click.widget) {
case 2: /* name train */
v = GetVehicle(w->window_number);
SetDParam(0, v->unitnumber);
@@ -1172,13 +1172,9 @@ static void TrainDetailsWndProc(Window *w, WindowEvent *e)
mod = _ctrl_pressed? -5 : -10;
do_change_service_int:
v = GetVehicle(w->window_number);
- mod += v->service_interval;
- /* %-based service interval max 5%-90%
- day-based service interval max 30-800 days */
- mod = _patches.servint_ispercent ? clamp(mod, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(mod, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS+1);
- if (mod == v->service_interval)
- return;
+ mod = GetServiceIntervalClamped(mod + v->service_interval);
+ if (mod == v->service_interval) return;
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_TRAIN_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
break;