summaryrefslogtreecommitdiff
path: root/train_gui.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-02-06 10:18:47 +0000
committertruelight <truelight@openttd.org>2005-02-06 10:18:47 +0000
commite9c93f9c0ca76117ac1315b6aff03f1f138f62e4 (patch)
tree0b6bfe4dfd7abf3e94d0f7210b1b842e429c4a02 /train_gui.c
parent6493e12bfbb147e41fc0f533bb3618b2931fed1f (diff)
downloadopenttd-e9c93f9c0ca76117ac1315b6aff03f1f138f62e4.tar.xz
(svn r1817) -Codechange: Moved depot-functions to depot.c
-Codechange: Added wrappers around depot-access (GetDepot no exists) -Codechange: Made depot-functions a bit more logic (no longer GetDepotByTile crashes your game when you request it on a non-depot tile) -Add: made depots dynamic (yes, 64k depots are possible now)
Diffstat (limited to 'train_gui.c')
-rw-r--r--train_gui.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/train_gui.c b/train_gui.c
index f6656cb42..85a5e8ee0 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -13,7 +13,7 @@
#include "player.h"
#include "engine.h"
#include "vehicle_gui.h"
-
+#include "depot.h"
int _traininfo_vehicle_pitch = 0;
@@ -303,7 +303,7 @@ static void DrawTrainDepotWindow(Window *w)
uint tile;
Vehicle *v, *u;
int num,x,y,i, hnum;
- Depot *d;
+ Depot *depot;
tile = w->window_number;
@@ -336,11 +336,10 @@ static void DrawTrainDepotWindow(Window *w)
SetHScrollCount(w, hnum);
/* locate the depot struct */
- for (d = _depots; d->xy != (TileIndex)tile; d++) {
- assert(d < endof(_depots));
- }
+ depot = GetDepotByTile(tile);
+ assert(depot != NULL);
- SetDParam(0, d->town_index);
+ SetDParam(0, depot->town_index);
DrawWindowWidgets(w);
x = 2;
@@ -850,7 +849,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
} break;
case OT_GOTO_DEPOT: {
- Depot *dep = &_depots[v->current_order.station];
+ Depot *dep = GetDepot(v->current_order.station);
SetDParam(0, dep->town_index);
str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed;
SetDParam(1, v->u.rail.last_speed * 10 >> 4);
@@ -927,7 +926,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
v = GetVehicle(w->window_number);
assert(v->type == VEH_Train);
- h = CheckStoppedInDepot(v) >= 0 ? (1 << 9) : (1 << 12);
+ h = CheckTrainStoppedInDepot(v) >= 0 ? (1 << 9) : (1 << 12);
if (h != w->hidden_state) {
w->hidden_state = h;
SetWindowDirty(w);