diff options
Diffstat (limited to 'src/vehicle_cmd.cpp')
-rw-r--r-- | src/vehicle_cmd.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index d1e5b4df3..a7ff57e53 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -67,7 +67,7 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, switch (v->type) { case VEH_TRAIN: - if ((v->vehstatus & VS_STOPPED) && ((Train *)v)->tcache.cached_power == 0) return_cmd_error(STR_TRAIN_START_NO_CATENARY); + if ((v->vehstatus & VS_STOPPED) && Train::From(v)->tcache.cached_power == 0) return_cmd_error(STR_TRAIN_START_NO_CATENARY); break; case VEH_SHIP: @@ -75,7 +75,7 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, break; case VEH_AIRCRAFT: { - Aircraft *a = (Aircraft *)v; + Aircraft *a = Aircraft::From(v); /* cannot stop airplane when in flight, or when taking off / landing */ if (a->state >= STARTTAKEOFF && a->state < TERM7) return_cmd_error(STR_ERROR_AIRCRAFT_IS_IN_FLIGHT); } break; @@ -152,7 +152,7 @@ CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 if (!vehicle_list_window) { if (vehicle_type == VEH_TRAIN) { - if (CheckTrainInDepot((const Train *)v, false) == -1) continue; + if (CheckTrainInDepot(Train::From(v), false) == -1) continue; } else { if (!(v->vehstatus & VS_HIDDEN)) continue; } @@ -349,7 +349,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint if (!CheckOwnership(v->owner)) return CMD_ERROR; - if (v->type == VEH_TRAIN && (!IsFrontEngine(v) || ((Train *)v)->crash_anim_pos >= 4400)) return CMD_ERROR; + if (v->type == VEH_TRAIN && (!IsFrontEngine(v) || Train::From(v)->crash_anim_pos >= 4400)) return CMD_ERROR; /* check that we can allocate enough vehicles */ if (!(flags & DC_EXEC)) { @@ -381,8 +381,8 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint if (flags & DC_EXEC) { w = Vehicle::Get(_new_vehicle_id); - if (v->type == VEH_TRAIN && HasBit(((Train *)v)->flags, VRF_REVERSE_DIRECTION)) { - SetBit(((Train *)w)->flags, VRF_REVERSE_DIRECTION); + if (v->type == VEH_TRAIN && HasBit(Train::From(v)->flags, VRF_REVERSE_DIRECTION)) { + SetBit(Train::From(w)->flags, VRF_REVERSE_DIRECTION); } if (v->type == VEH_TRAIN && !IsFrontEngine(v)) { @@ -403,7 +403,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint } w_rear = w; // trains needs to know the last car in the train, so they can add more in next loop } - } while (v->type == VEH_TRAIN && (v = GetNextVehicle((Train *)v)) != NULL); + } while (v->type == VEH_TRAIN && (v = GetNextVehicle(Train::From(v))) != NULL); if ((flags & DC_EXEC) && v_front->type == VEH_TRAIN) { /* for trains this needs to be the front engine due to the callback function */ @@ -437,7 +437,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint } if (w->type == VEH_TRAIN && EngineHasArticPart(w)) { - w = GetNextArticPart((Train *)w); + w = GetNextArticPart(Train::From(w)); } else if (w->type == VEH_ROAD && RoadVehHasArticPart(w)) { w = w->Next(); } else { @@ -453,7 +453,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint } if (v->type == VEH_TRAIN && EngineHasArticPart(v)) { - v = GetNextArticPart((Train *)v); + v = GetNextArticPart(Train::From(v)); } else if (v->type == VEH_ROAD && RoadVehHasArticPart(v)) { v = v->Next(); } else { @@ -461,8 +461,8 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint } } while (v != NULL); - if ((flags & DC_EXEC) && v->type == VEH_TRAIN) w = GetNextVehicle((Train *)w); - } while (v->type == VEH_TRAIN && (v = GetNextVehicle((Train *)v)) != NULL); + if ((flags & DC_EXEC) && v->type == VEH_TRAIN) w = GetNextVehicle(Train::From(w)); + } while (v->type == VEH_TRAIN && (v = GetNextVehicle(Train::From(v))) != NULL); if (flags & DC_EXEC) { /* |