summaryrefslogtreecommitdiff
path: root/src/depot_gui.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-06-06 16:54:22 +0000
committersmatz <smatz@openttd.org>2009-06-06 16:54:22 +0000
commit0c10006907b7d149f91d277a0c28a79b40eaa4c0 (patch)
treedc8cb6a7a9315a10688af00187db94be8911acef /src/depot_gui.cpp
parentc90819ff6d8d49ac25aa9194bdf04e8dfd7149ea (diff)
downloadopenttd-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/depot_gui.cpp')
-rw-r--r--src/depot_gui.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 06fab5c8f..ed415d6c9 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -272,7 +272,7 @@ struct DepotWindow : Window {
DrawTrainImage(v, x + 21, sprite_y, this->sel, this->hscroll.cap + 4, this->hscroll.pos);
/* Number of wagons relative to a standard length wagon (rounded up) */
- SetDParam(0, (((const Train *)v)->tcache.cached_total_length + 7) / 8);
+ SetDParam(0, (Train::From(v)->tcache.cached_total_length + 7) / 8);
DrawString(this->widget[DEPOT_WIDGET_MATRIX].left, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING, SA_RIGHT); // Draw the counter
break;
@@ -328,7 +328,7 @@ struct DepotWindow : Window {
hnum = 8;
for (uint num = 0; num < this->vehicle_list.Length(); num++) {
const Vehicle *v = this->vehicle_list[num];
- hnum = max(hnum, ((const Train *)v)->tcache.cached_total_length);
+ hnum = max(hnum, Train::From(v)->tcache.cached_total_length);
}
/* Always have 1 empty row, so people can change the setting of the train */
SetVScrollCount(w, this->vehicle_list.Length() + this->wagon_list.Length() + 1);
@@ -450,7 +450,7 @@ struct DepotWindow : Window {
x += skip;
/* find the vehicle in this row that was clicked */
- while (v != NULL && (x -= ((const Train *)v)->tcache.cached_veh_length) >= 0) v = v->Next();
+ while (v != NULL && (x -= Train::From(v)->tcache.cached_veh_length) >= 0) v = v->Next();
/* if an articulated part was selected, find its parent */
while (v != NULL && IsArticulatedPart(v)) v = v->Previous();
@@ -514,11 +514,11 @@ struct DepotWindow : Window {
switch (v->type) {
case VEH_TRAIN:
- _cursor.short_vehicle_offset = 16 - ((const Train *)v)->tcache.cached_veh_length * 2;
+ _cursor.short_vehicle_offset = 16 - Train::From(v)->tcache.cached_veh_length * 2;
break;
case VEH_ROAD:
- _cursor.short_vehicle_offset = 16 - ((const RoadVehicle *)v)->rcache.cached_veh_length * 2;
+ _cursor.short_vehicle_offset = 16 - RoadVehicle::From(v)->rcache.cached_veh_length * 2;
break;
default: