/* static */ int32 ScriptEngine::GetWeight(EngineID engine_id) { if (!IsValidEngine(engine_id)) return -1; if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1; return ::Engine::Get(engine_id)->GetDisplayWeight(); }
/* static */ bool ScriptEngine::IsArticulated(EngineID engine_id) { if (!IsValidEngine(engine_id)) return false; if (GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD && GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false; return CountArticulatedParts(engine_id, true) != 0; }
/* static */ int32 ScriptEngine::GetPower(EngineID engine_id) { if (!IsValidEngine(engine_id)) return -1; if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1; if (IsWagon(engine_id)) return -1; return ::Engine::Get(engine_id)->GetPower(); }
/* static */ int32 ScriptEngine::GetMaxTractiveEffort(EngineID engine_id) { if (!IsValidEngine(engine_id)) return -1; if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1; if (IsWagon(engine_id)) return -1; return ::Engine::Get(engine_id)->GetDisplayMaxTractiveEffort(); }
/* static */ bool AIVehicle::IsArticulated(VehicleID vehicle_id) { if (!IsValidVehicle(vehicle_id)) return false; if (GetVehicleType(vehicle_id) != VT_ROAD && GetVehicleType(vehicle_id) != VT_RAIL) return false; const Vehicle *v = ::Vehicle::Get(vehicle_id); switch (v->type) { case VEH_ROAD: return ::RoadVehicle::From(v)->HasArticulatedPart(); case VEH_TRAIN: return ::Train::From(v)->HasArticulatedPart(); default: NOT_REACHED(); } }
/* static */ ScriptRail::RailType ScriptEngine::GetRailType(EngineID engine_id) { if (!IsValidEngine(engine_id)) return ScriptRail::RAILTYPE_INVALID; if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return ScriptRail::RAILTYPE_INVALID; return (ScriptRail::RailType)(uint)::RailVehInfo(engine_id)->railtype; }
/* static */ ScriptRoad::RoadType ScriptEngine::GetRoadType(EngineID engine_id) { if (!IsValidEngine(engine_id)) return ScriptRoad::ROADTYPE_INVALID; if (GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return ScriptRoad::ROADTYPE_INVALID; return HasBit(::EngInfo(engine_id)->misc_flags, EF_ROAD_TRAM) ? ScriptRoad::ROADTYPE_TRAM : ScriptRoad::ROADTYPE_ROAD; }
/* static */ bool ScriptEngine::IsWagon(EngineID engine_id) { if (!IsValidEngine(engine_id)) return false; if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false; return ::RailVehInfo(engine_id)->power == 0; }
/* static */ AIRail::RailType AIEngine::GetRailType(EngineID engine_id) { if (!IsValidEngine(engine_id)) return AIRail::RAILTYPE_INVALID; if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return AIRail::RAILTYPE_INVALID; return (AIRail::RailType)(uint)::RailVehInfo(engine_id)->railtype; }
/* static */ int32 ScriptEngine::GetMaxAge(EngineID engine_id) { if (!IsValidEngine(engine_id)) return -1; if (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL && IsWagon(engine_id)) return -1; return ::Engine::Get(engine_id)->GetLifeLengthInDays(); }
/* static */ int32 ScriptEngine::GetReliability(EngineID engine_id) { if (!IsValidEngine(engine_id)) return -1; if (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL && IsWagon(engine_id)) return -1; return ::ToPercent16(::Engine::Get(engine_id)->reliability); }
/* static */ AIRoad::RoadType AIVehicle::GetRoadType(VehicleID vehicle_id) { if (!IsValidVehicle(vehicle_id)) return AIRoad::ROADTYPE_INVALID; if (GetVehicleType(vehicle_id) != VT_ROAD) return AIRoad::ROADTYPE_INVALID; return (AIRoad::RoadType)(::RoadVehicle::Get(vehicle_id))->roadtype; }
/* static */ AIAirport::PlaneType AIEngine::GetPlaneType(EngineID engine_id) { if (!IsValidEngine(engine_id)) return AIAirport::PT_INVALID; if (GetVehicleType(engine_id) != AIVehicle::VT_AIR) return AIAirport::PT_INVALID; return (AIAirport::PlaneType)::AircraftVehInfo(engine_id)->subtype; }
/* static */ ScriptAirport::PlaneType ScriptEngine::GetPlaneType(EngineID engine_id) { if (!IsValidEngine(engine_id)) return ScriptAirport::PT_INVALID; if (GetVehicleType(engine_id) != ScriptVehicle::VT_AIR) return ScriptAirport::PT_INVALID; return (ScriptAirport::PlaneType)::AircraftVehInfo(engine_id)->subtype; }
/* static */ bool ScriptEngine::HasPowerOnRail(EngineID engine_id, ScriptRail::RailType track_rail_type) { if (!IsValidEngine(engine_id)) return false; if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false; if (!ScriptRail::IsRailTypeAvailable(track_rail_type)) return false; return ::HasPowerOnRail((::RailType)::RailVehInfo(engine_id)->railtype, (::RailType)track_rail_type); }
/* static */ bool AIEngine::CanRunOnRail(EngineID engine_id, AIRail::RailType track_rail_type) { if (!IsValidEngine(engine_id)) return false; if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return false; if (!AIRail::IsRailTypeAvailable(track_rail_type)) return false; return ::IsCompatibleRail((::RailType)::RailVehInfo(engine_id)->railtype, (::RailType)track_rail_type); }
/* static */ bool ScriptEngine::CanPullCargo(EngineID engine_id, CargoID cargo_id) { if (!IsValidEngine(engine_id)) return false; if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false; if (!ScriptCargo::IsValidCargo(cargo_id)) return false; return (::RailVehInfo(engine_id)->ai_passenger_only != 1) || ScriptCargo::HasCargoClass(cargo_id, ScriptCargo::CC_PASSENGERS); }
/* static */ uint ScriptEngine::GetMaximumOrderDistance(EngineID engine_id) { if (!IsValidEngine(engine_id)) return 0; switch (GetVehicleType(engine_id)) { case ScriptVehicle::VT_WATER: return _settings_game.pf.pathfinder_for_ships != VPF_NPF ? 129 : 0; case ScriptVehicle::VT_AIR: return ::Engine::Get(engine_id)->GetRange() * ::Engine::Get(engine_id)->GetRange(); default: return 0; } }
bool CVehicleManager::HasDamageModel ( unsigned short usModel ) { return HasDamageModel ( GetVehicleType ( usModel ) ); }