mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-31 10:29:10 +00:00
Fix: [Script] Make compat layers fool proof (#13680)
This commit is contained in:
@@ -96,158 +96,158 @@ AIEngine.IsValidEngine <- function(engine_id)
|
||||
return AIEngine.IsBuildable(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetName <- AIEngine.GetName;
|
||||
AIEngine.GetNameCompat0_7 <- AIEngine.GetName;
|
||||
AIEngine.GetName <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return null;
|
||||
return AIEngine._GetName(engine_id);
|
||||
return AIEngine.GetNameCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetCargoType <- AIEngine.GetCargoType;
|
||||
AIEngine.GetCargoTypeCompat0_7 <- AIEngine.GetCargoType;
|
||||
AIEngine.GetCargoType <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return 255;
|
||||
return AIEngine._GetCargoType(engine_id);
|
||||
return AIEngine.GetCargoTypeCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._CanRefitCargo <- AIEngine.CanRefitCargo;
|
||||
AIEngine.CanRefitCargoCompat0_7 <- AIEngine.CanRefitCargo;
|
||||
AIEngine.CanRefitCargo <- function(engine_id, cargo_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return false;
|
||||
return AIEngine._CanRefitCargo(engine_id, cargo_id);
|
||||
return AIEngine.CanRefitCargoCompat0_7(engine_id, cargo_id);
|
||||
}
|
||||
|
||||
AIEngine._CanPullCargo <- AIEngine.CanPullCargo;
|
||||
AIEngine.CanPullCargoCompat0_7 <- AIEngine.CanPullCargo;
|
||||
AIEngine.CanPullCargo <- function(engine_id, cargo_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return false;
|
||||
return AIEngine._CanPullCargo(engine_id, cargo_id);
|
||||
return AIEngine.CanPullCargoCompat0_7(engine_id, cargo_id);
|
||||
}
|
||||
|
||||
AIEngine._GetCapacity <- AIEngine.GetCapacity;
|
||||
AIEngine.GetCapacityCompat0_7 <- AIEngine.GetCapacity;
|
||||
AIEngine.GetCapacity <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return -1;
|
||||
return AIEngine._GetCapacity(engine_id);
|
||||
return AIEngine.GetCapacityCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetReliability <- AIEngine.GetReliability;
|
||||
AIEngine.GetReliabilityCompat0_7 <- AIEngine.GetReliability;
|
||||
AIEngine.GetReliability <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return -1;
|
||||
return AIEngine._GetReliability(engine_id);
|
||||
return AIEngine.GetReliabilityCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetMaxSpeed <- AIEngine.GetMaxSpeed;
|
||||
AIEngine.GetMaxSpeedCompat0_7 <- AIEngine.GetMaxSpeed;
|
||||
AIEngine.GetMaxSpeed <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return -1;
|
||||
return AIEngine._GetMaxSpeed(engine_id);
|
||||
return AIEngine.GetMaxSpeedCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetPrice <- AIEngine.GetPrice;
|
||||
AIEngine.GetPriceCompat0_7 <- AIEngine.GetPrice;
|
||||
AIEngine.GetPrice <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return -1;
|
||||
return AIEngine._GetPrice(engine_id);
|
||||
return AIEngine.GetPriceCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetMaxAge <- AIEngine.GetMaxAge;
|
||||
AIEngine.GetMaxAgeCompat0_7 <- AIEngine.GetMaxAge;
|
||||
AIEngine.GetMaxAge <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return -1;
|
||||
return AIEngine._GetMaxAge(engine_id);
|
||||
return AIEngine.GetMaxAgeCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetRunningCost <- AIEngine.GetRunningCost;
|
||||
AIEngine.GetRunningCostCompat0_7 <- AIEngine.GetRunningCost;
|
||||
AIEngine.GetRunningCost <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return -1;
|
||||
return AIEngine._GetRunningCost(engine_id);
|
||||
return AIEngine.GetRunningCostCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetPower <- AIEngine.GetPower;
|
||||
AIEngine.GetPowerCompat0_7 <- AIEngine.GetPower;
|
||||
AIEngine.GetPower <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return -1;
|
||||
return AIEngine._GetPower(engine_id);
|
||||
return AIEngine.GetPowerCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetWeight <- AIEngine.GetWeight;
|
||||
AIEngine.GetWeightCompat0_7 <- AIEngine.GetWeight;
|
||||
AIEngine.GetWeight <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return -1;
|
||||
return AIEngine._GetWeight(engine_id);
|
||||
return AIEngine.GetWeightCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetMaxTractiveEffort <- AIEngine.GetMaxTractiveEffort;
|
||||
AIEngine.GetMaxTractiveEffortCompat0_7 <- AIEngine.GetMaxTractiveEffort;
|
||||
AIEngine.GetMaxTractiveEffort <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return -1;
|
||||
return AIEngine._GetMaxTractiveEffort(engine_id);
|
||||
return AIEngine.GetMaxTractiveEffortCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetDesignDate <- AIEngine.GetDesignDate;
|
||||
AIEngine.GetDesignDateCompat0_7 <- AIEngine.GetDesignDate;
|
||||
AIEngine.GetDesignDate <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return -1;
|
||||
return AIEngine._GetDesignDate(engine_id);
|
||||
return AIEngine.GetDesignDateCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetVehicleType <- AIEngine.GetVehicleType;
|
||||
AIEngine.GetVehicleTypeCompat0_7 <- AIEngine.GetVehicleType;
|
||||
AIEngine.GetVehicleType <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return AIVehicle.VT_INVALID;
|
||||
return AIEngine._GetVehicleType(engine_id);
|
||||
return AIEngine.GetVehicleTypeCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._IsWagon <- AIEngine.IsWagon;
|
||||
AIEngine.IsWagonCompat0_7 <- AIEngine.IsWagon;
|
||||
AIEngine.IsWagon <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return false;
|
||||
return AIEngine._IsWagon(engine_id);
|
||||
return AIEngine.IsWagonCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._CanRunOnRail <- AIEngine.CanRunOnRail;
|
||||
AIEngine.CanRunOnRailCompat0_7 <- AIEngine.CanRunOnRail;
|
||||
AIEngine.CanRunOnRail <- function(engine_id, track_rail_type)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return false;
|
||||
return AIEngine._CanRunOnRail(engine_id, track_rail_type);
|
||||
return AIEngine.CanRunOnRailCompat0_7(engine_id, track_rail_type);
|
||||
}
|
||||
|
||||
AIEngine._HasPowerOnRail <- AIEngine.HasPowerOnRail;
|
||||
AIEngine.HasPowerOnRailCompat0_7 <- AIEngine.HasPowerOnRail;
|
||||
AIEngine.HasPowerOnRail <- function(engine_id, track_rail_type)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return false;
|
||||
return AIEngine._HasPowerOnRail(engine_id, track_rail_type);
|
||||
return AIEngine.HasPowerOnRailCompat0_7(engine_id, track_rail_type);
|
||||
}
|
||||
|
||||
AIEngine._GetRoadType <- AIEngine.GetRoadType;
|
||||
AIEngine.GetRoadTypeCompat0_7 <- AIEngine.GetRoadType;
|
||||
AIEngine.GetRoadType <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return AIRoad.ROADTYPE_INVALID;
|
||||
return AIEngine._GetRoadType(engine_id);
|
||||
return AIEngine.GetRoadTypeCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetRailType <- AIEngine.GetRailType;
|
||||
AIEngine.GetRailTypeCompat0_7 <- AIEngine.GetRailType;
|
||||
AIEngine.GetRailType <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return AIRail.RAILTYPE_INVALID;
|
||||
return AIEngine._GetRailType(engine_id);
|
||||
return AIEngine.GetRailTypeCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._IsArticulated <- AIEngine.IsArticulated;
|
||||
AIEngine.IsArticulatedCompat0_7 <- AIEngine.IsArticulated;
|
||||
AIEngine.IsArticulated <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return false;
|
||||
return AIEngine._IsArticulated(engine_id);
|
||||
return AIEngine.IsArticulatedCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
AIEngine._GetPlaneType <- AIEngine.GetPlaneType;
|
||||
AIEngine.GetPlaneTypeCompat0_7 <- AIEngine.GetPlaneType;
|
||||
AIEngine.GetPlaneType <- function(engine_id)
|
||||
{
|
||||
if (!AIEngine.IsBuildable(engine_id)) return -1;
|
||||
return AIEngine._GetPlaneType(engine_id);
|
||||
return AIEngine.GetPlaneTypeCompat0_7(engine_id);
|
||||
}
|
||||
|
||||
_AIWaypointList <- AIWaypointList;
|
||||
|
@@ -7,20 +7,20 @@
|
||||
|
||||
/* This file contains code to downgrade the API from 1.1 to 1.0. */
|
||||
|
||||
AIRoad._BuildRoadStation <- AIRoad.BuildRoadStation;
|
||||
AIRoad.BuildRoadStationCompat1_0 <- AIRoad.BuildRoadStation;
|
||||
AIRoad.BuildRoadStation <- function(tile, front, road_veh_type, station_id)
|
||||
{
|
||||
if (AIRoad.IsRoadStationTile(tile) && AICompany.IsMine(AITile.GetOwner(tile))) return false;
|
||||
|
||||
return AIRoad._BuildRoadStation(tile, front, road_veh_type, station_id);
|
||||
return AIRoad.BuildRoadStationCompat1_0(tile, front, road_veh_type, station_id);
|
||||
}
|
||||
|
||||
AIRoad._BuildDriveThroughRoadStation <- AIRoad.BuildDriveThroughRoadStation;
|
||||
AIRoad.BuildDriveThroughRoadStationCompat1_0 <- AIRoad.BuildDriveThroughRoadStation;
|
||||
AIRoad.BuildDriveThroughRoadStation <- function(tile, front, road_veh_type, station_id)
|
||||
{
|
||||
if (AIRoad.IsRoadStationTile(tile) && AICompany.IsMine(AITile.GetOwner(tile))) return false;
|
||||
|
||||
return AIRoad._BuildDriveThroughRoadStation(tile, front, road_veh_type, station_id);
|
||||
return AIRoad.BuildDriveThroughRoadStationCompat1_0(tile, front, road_veh_type, station_id);
|
||||
}
|
||||
|
||||
AIBridgeList.HasNext <-
|
||||
@@ -59,10 +59,10 @@ function()
|
||||
return !this.IsEnd();
|
||||
}
|
||||
|
||||
AIIndustry._IsCargoAccepted <- AIIndustry.IsCargoAccepted;
|
||||
AIIndustry.IsCargoAcceptedCompat1_0 <- AIIndustry.IsCargoAccepted;
|
||||
AIIndustry.IsCargoAccepted <- function(industry_id, cargo_id)
|
||||
{
|
||||
return AIIndustry._IsCargoAccepted(industry_id, cargo_id) != AIIndustry.CAS_NOT_ACCEPTED;
|
||||
return AIIndustry.IsCargoAcceptedCompat1_0(industry_id, cargo_id) != AIIndustry.CAS_NOT_ACCEPTED;
|
||||
}
|
||||
|
||||
AIAbstractList <- AIList;
|
||||
|
@@ -7,14 +7,14 @@
|
||||
|
||||
/* This file contains code to downgrade the API from 1.9 to 1.8. */
|
||||
|
||||
AIBridge._GetName <- AIBridge.GetName;
|
||||
AIBridge.GetNameCompat1_8 <- AIBridge.GetName;
|
||||
AIBridge.GetName <- function(bridge_id)
|
||||
{
|
||||
return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
|
||||
return AIBridge.GetNameCompat1_8(bridge_id, AIVehicle.VT_RAIL);
|
||||
}
|
||||
|
||||
AIGroup._CreateGroup <- AIGroup.CreateGroup;
|
||||
AIGroup.CreateGroupCompat1_8 <- AIGroup.CreateGroup;
|
||||
AIGroup.CreateGroup <- function(vehicle_type)
|
||||
{
|
||||
return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
|
||||
return AIGroup.CreateGroupCompat1_8(vehicle_type, AIGroup.GROUP_INVALID);
|
||||
}
|
||||
|
@@ -7,12 +7,12 @@
|
||||
|
||||
/* This file contains code to downgrade the API from 13 to 12. */
|
||||
|
||||
AIRoad._HasRoadType <- AIRoad.HasRoadType;
|
||||
AIRoad.HasRoadTypeCompat12 <- AIRoad.HasRoadType;
|
||||
AIRoad.HasRoadType <- function(tile, road_type)
|
||||
{
|
||||
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
|
||||
foreach (rt, _ in list) {
|
||||
if (AIRoad._HasRoadType(tile, rt)) {
|
||||
if (AIRoad.HasRoadTypeCompat12(tile, rt)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -17,22 +17,22 @@ class AICompat14 {
|
||||
}
|
||||
}
|
||||
|
||||
AIBaseStation._SetName <- AIBaseStation.SetName;
|
||||
AIBaseStation.SetName <- function(id, name) { return AIBaseStation._SetName(id, AICompat14.Text(name)); }
|
||||
AIBaseStation.SetNameCompat14 <- AIBaseStation.SetName;
|
||||
AIBaseStation.SetName <- function(id, name) { return AIBaseStation.SetNameCompat14(id, AICompat14.Text(name)); }
|
||||
|
||||
AICompany._SetName <- AICompany.SetName;
|
||||
AICompany.SetName <- function(name) { return AICompany._SetName(AICompat14.Text(name)); }
|
||||
AICompany._SetPresidentName <- AICompany.SetPresidentName;
|
||||
AICompany.SetPresidentName <- function(name) { return AICompany._SetPresidentName(AICompat14.Text(name)); }
|
||||
AICompany.SetNameCompat14 <- AICompany.SetName;
|
||||
AICompany.SetName <- function(name) { return AICompany.SetNameCompat14(AICompat14.Text(name)); }
|
||||
AICompany.SetPresidentNameCompat14 <- AICompany.SetPresidentName;
|
||||
AICompany.SetPresidentName <- function(name) { return AICompany.SetPresidentNameCompat14(AICompat14.Text(name)); }
|
||||
|
||||
AIGroup._SetName <- AIGroup.SetName;
|
||||
AIGroup.SetName <- function(id, name) { return AIGroup._SetName(id, AICompat14.Text(name)); }
|
||||
AIGroup.SetNameCompat14 <- AIGroup.SetName;
|
||||
AIGroup.SetName <- function(id, name) { return AIGroup.SetNameCompat14(id, AICompat14.Text(name)); }
|
||||
|
||||
AISign._BuildSign <- AISign.BuildSign;
|
||||
AISign.BuildSign <- function(id, name) { return AISign._BuildSign(id, AICompat14.Text(name)); }
|
||||
AISign.BuildSignCompat14 <- AISign.BuildSign;
|
||||
AISign.BuildSign <- function(id, name) { return AISign.BuildSignCompat14(id, AICompat14.Text(name)); }
|
||||
|
||||
AITown._FoundTown <- AITown.FoundTown;
|
||||
AITown.FoundTown <- function(tile, size, city, layout, name) { return AITown._FoundTown(tile, size, city, layout, AICompat14.Text(name)); }
|
||||
AITown.FoundTownCompat14 <- AITown.FoundTown;
|
||||
AITown.FoundTown <- function(tile, size, city, layout, name) { return AITown.FoundTownCompat14(tile, size, city, layout, AICompat14.Text(name)); }
|
||||
|
||||
AIVehicle._SetName <- AIVehicle.SetName;
|
||||
AIVehicle.SetName <- function(id, name) { return AIVehicle._SetName(id, AICompat14.Text(name)); }
|
||||
AIVehicle.SetNameCompat14 <- AIVehicle.SetName;
|
||||
AIVehicle.SetName <- function(id, name) { return AIVehicle.SetNameCompat14(id, AICompat14.Text(name)); }
|
||||
|
Reference in New Issue
Block a user