diff options
author | smatz <smatz@openttd.org> | 2009-06-06 16:54:22 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-06-06 16:54:22 +0000 |
commit | 0c10006907b7d149f91d277a0c28a79b40eaa4c0 (patch) | |
tree | dc8cb6a7a9315a10688af00187db94be8911acef /src/economy.cpp | |
parent | c90819ff6d8d49ac25aa9194bdf04e8dfd7149ea (diff) | |
download | openttd-0c10006907b7d149f91d277a0c28a79b40eaa4c0.tar.xz |
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
Diffstat (limited to 'src/economy.cpp')
-rw-r--r-- | src/economy.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index b7ce214e6..dd925a380 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1314,7 +1314,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left) /* update stats */ int t; switch (u->type) { - case VEH_TRAIN: t = ((Train *)u)->tcache.cached_max_speed; break; + case VEH_TRAIN: t = Train::From(u)->tcache.cached_max_speed; break; case VEH_ROAD: t = u->max_speed / 2; break; default: t = u->max_speed; break; } @@ -1423,7 +1423,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left) if (v->type == VEH_TRAIN) { /* Each platform tile is worth 2 rail vehicles. */ - int overhang = ((Train *)v)->tcache.cached_total_length - st->GetPlatformLength(v->tile) * TILE_SIZE; + int overhang = Train::From(v)->tcache.cached_total_length - st->GetPlatformLength(v->tile) * TILE_SIZE; if (overhang > 0) { unloading_time <<= 1; unloading_time += (overhang * unloading_time) / 8; |