diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp --- a/src/ai/api/ai_vehicle.cpp +++ b/src/ai/api/ai_vehicle.cpp @@ -46,11 +46,11 @@ case VEH_ROAD: { uint total_length = 0; for (const Vehicle *u = v; u != NULL; u = u->Next()) { - total_length += ((const RoadVehicle *)u)->rcache.cached_veh_length; + total_length += ::RoadVehicle::From(u)->rcache.cached_veh_length; } return total_length; } - case VEH_TRAIN: return ((const Train *)v)->tcache.cached_total_length; + case VEH_TRAIN: return ::Train::From(v)->tcache.cached_total_length; default: return -1; } } @@ -86,11 +86,11 @@ EnforcePrecondition(false, ::Vehicle::Get(source_vehicle_id)->type == VEH_TRAIN); EnforcePrecondition(false, dest_vehicle_id == -1 || ::Vehicle::Get(dest_vehicle_id)->type == VEH_TRAIN); - const Train *v = (const Train *)::Vehicle::Get(source_vehicle_id); + const Train *v = ::Train::Get(source_vehicle_id); while (source_wagon-- > 0) v = GetNextUnit(v); const Train *w = NULL; if (dest_vehicle_id != -1) { - w = (const Train *)::Vehicle::Get(dest_vehicle_id); + w = ::Train::Get(dest_vehicle_id); while (dest_wagon-- > 0) w = GetNextUnit(w); } @@ -137,7 +137,7 @@ EnforcePrecondition(false, IsValidVehicle(vehicle_id) && wagon < GetNumWagons(vehicle_id)); EnforcePrecondition(false, ::Vehicle::Get(vehicle_id)->type == VEH_TRAIN); - const Train *v = (const Train *)::Vehicle::Get(vehicle_id); + const Train *v = ::Train::Get(vehicle_id); while (wagon-- > 0) v = GetNextUnit(v); return AIObject::DoCommand(0, v->index, sell_attached_wagons ? 1 : 0, CMD_SELL_RAIL_WAGON); @@ -244,7 +244,7 @@ const Vehicle *v = ::Vehicle::Get(vehicle_id); if (v->type == VEH_TRAIN) { - while (wagon-- > 0) v = GetNextUnit((const Train *)v); + while (wagon-- > 0) v = GetNextUnit(::Train::From(v)); } return v->engine_type; } @@ -282,7 +282,7 @@ const Vehicle *v = ::Vehicle::Get(vehicle_id); if (v->type == VEH_TRAIN) { - while (wagon-- > 0) v = GetNextUnit((const Train *)v); + while (wagon-- > 0) v = GetNextUnit(::Train::From(v)); } return v->age; } @@ -369,7 +369,7 @@ if (!IsValidVehicle(vehicle_id)) return AIRoad::ROADTYPE_INVALID; if (GetVehicleType(vehicle_id) != VT_ROAD) return AIRoad::ROADTYPE_INVALID; - return (AIRoad::RoadType)((RoadVehicle*)::Vehicle::Get(vehicle_id))->roadtype; + return (AIRoad::RoadType)(::RoadVehicle::Get(vehicle_id))->roadtype; } /* static */ int32 AIVehicle::GetCapacity(VehicleID vehicle_id, CargoID cargo) @@ -412,8 +412,8 @@ const Vehicle *v = ::Vehicle::Get(vehicle_id); switch (v->type) { - case VEH_ROAD: return RoadVehHasArticPart(v); - case VEH_TRAIN: return EngineHasArticPart(v); + case VEH_ROAD: return ::RoadVehHasArticPart(v); + case VEH_TRAIN: return ::EngineHasArticPart(v); default: NOT_REACHED(); } }