diff options
author | smatz <smatz@openttd.org> | 2008-04-07 12:36:50 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-04-07 12:36:50 +0000 |
commit | ac389e16d2407b16b57ef7071d4546ed6616cada (patch) | |
tree | d2fd2aad17d2b6452497489fdbb02b4d92e6c076 /src/train_gui.cpp | |
parent | f46ae97d8e973d6432e981eef86de37d4eb93baf (diff) | |
download | openttd-ac389e16d2407b16b57ef7071d4546ed6616cada.tar.xz |
(svn r12605) -Cleanup: variable scope and coding style in train*
Diffstat (limited to 'src/train_gui.cpp')
-rw-r--r-- | src/train_gui.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 41aceb61a..97680a8be 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -24,12 +24,11 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2) { - Vehicle *v, *found; - if (!success) return; /* find a locomotive in the depot. */ - found = NULL; + Vehicle *found = NULL; + Vehicle *v; FOR_ALL_VEHICLES(v) { if (v->type == VEH_TRAIN && IsFrontEngine(v) && v->tile == tile && @@ -50,11 +49,9 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2) void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2) { - const Vehicle *v; - if (!success) return; - v = GetVehicle(_new_vehicle_id); + const Vehicle *v = GetVehicle(_new_vehicle_id); if (tile == _backup_orders_tile) { _backup_orders_tile = 0; RestoreVehicleOrders(v); @@ -197,8 +194,6 @@ void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vs for (;;) { if (--vscroll_pos < 0 && vscroll_pos >= -vscroll_cap) { int dx = 0; - int px; - int py; u = v; do { @@ -208,8 +203,8 @@ void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vs u = u->Next(); } while (u != NULL && IsArticulatedPart(u) && u->cargo_cap == 0); - px = x + WagonLengthToPixels(dx) + 2; - py = y + 2; + int px = x + WagonLengthToPixels(dx) + 2; + int py = y + 2; switch (det_tab) { default: NOT_REACHED(); case 0: TrainDetailsCargoTab( v, px, py); break; |