summaryrefslogtreecommitdiff
path: root/bin/ai
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-08-18 18:51:42 +0000
committeryexo <yexo@openttd.org>2009-08-18 18:51:42 +0000
commit67106dc0633c50ef6545d0ab6253384b276ab40e (patch)
tree09964556afb30a650b4549b0a919ba38230e363a /bin/ai
parent58a0ff945c4025e20e30868c8774c8528909600c (diff)
downloadopenttd-67106dc0633c50ef6545d0ab6253384b276ab40e.tar.xz
(svn r17214) -Add [NoAI]: GetAPIVersion() as optional function in info.nut. Return "0.7" to get an api compatible (as much as possible) with the 0.7 api or "0.8" to get the latest api.
-Change [NoAI]: move all deprecated functions to a separate squirrel script that is only loaded if an AI requests an old API version.
Diffstat (limited to 'bin/ai')
-rw-r--r--bin/ai/compat_0.7.nut71
-rw-r--r--bin/ai/compat_0.8.nut1
-rw-r--r--bin/ai/regression/regression.nut2
-rw-r--r--bin/ai/regression/regression_info.nut1
4 files changed, 74 insertions, 1 deletions
diff --git a/bin/ai/compat_0.7.nut b/bin/ai/compat_0.7.nut
new file mode 100644
index 000000000..c38234a3a
--- /dev/null
+++ b/bin/ai/compat_0.7.nut
@@ -0,0 +1,71 @@
+/* $Id$ */
+
+AISign.GetMaxSignID <- function()
+{
+ AILog.Warning("AISign::GetMaxSignID is deprecated and will be removed soon, please use AISignList instead.");
+ local list = AISignList();
+ local max_id = 0;
+ foreach (id, d in list) {
+ if (id > max_id) max_id = id;
+ }
+ return max_id;
+}
+
+AITile.GetHeight <- function(tile)
+{
+ AILog.Warning("AITile::GetHeight is deprecated and will be removed soon, please use GetMinHeight/GetMaxHeight/GetCornerHeight instead.");
+ if (!AIMap.IsValidTile(tile)) return -1;
+
+ return AITile.GetCornerHeight(tile, AITile.CORNER_N);
+}
+
+AIOrder.ChangeOrder <- function(vehicle_id, order_position, order_flags)
+{
+ AILog.Warning("AIOrder::ChangeOrder is deprecated and will be removed soon, please use AIOrder::SetOrderFlags instead.")
+
+ return AIOrder.SetOrderFlags(vehicle_id, order_position, order_flags);
+}
+
+AIWaypoint.WAYPOINT_INVALID <- 0xFFFF;
+
+AISubsidy.SourceIsTown <- function(subsidy_id)
+{
+ AILog.Warning("AISubsidy::SourceIsTown is deprecated and will be removed soon, please use AISubsidy::GetSourceType instead.");
+ if (!AISubsidy.IsValidSubsidy(subsidy_id) || AISubsidy.IsAwarded(subsidy_id)) return false;
+
+ return AISubsidy.GetSourceType(subsidy_id) == AISubsidy.SPT_TOWN;
+}
+
+AISubsidy.GetSource <- function(subsidy_id)
+{
+ AILog.Warning("AISubsidy::GetSource is deprecated and will be removed soon, please use AISubsidy::GetSourceIndex instead.");
+ if (!AISubsidy.IsValidSubsidy(subsidy_id)) return AIBaseStation.INVALID_STATION;
+
+ if (AISubsidy.IsAwarded(subsidy_id)) {
+ AILog.Error("AISubsidy::GetSource returned INVALID_STATION due to internal changes in the Subsidy logic.");
+ return AIBaseStation.INVALID_STATION;
+ }
+
+ return AISubsidy.GetSourceIndex(subsidy_id);
+}
+
+AISubsidy.DestinationIsTown <- function(subsidy_id)
+{
+ AILog.Warning("AISubsidy::DestinationIsTown is deprecated and will be removed soon, please use AISubsidy::GetDestinationType instead.");
+ if (!AISubsidy.IsValidSubsidy(subsidy_id) || AISubsidy.IsAwarded(subsidy_id)) return false;
+
+ return AISubsidy.GetDestinationType(subsidy_id) == AISubsidy.SPT_TOWN;
+}
+
+AISubsidy.GetDestination <- function(subsidy_id)
+{
+ AILog.Warning("AISubsidy::GetDestination is deprecated and will be removed soon, please use AISubsidy::GetDestinationIndex instead.");
+ if (!AISubsidy.IsValidSubsidy(subsidy_id)) return AIBaseStation.INVALID_STATION;
+
+ if (AISubsidy.IsAwarded(subsidy_id)) {
+ AILog.Error("AISubsidy::GetDestination returned INVALID_STATION due to internal changes in the Subsidy logic.");
+ return AIBaseStation.INVALID_STATION;
+ }
+
+ return AISubsidy.GetDestinationIndex(subsidy_id);
+}
diff --git a/bin/ai/compat_0.8.nut b/bin/ai/compat_0.8.nut
new file mode 100644
index 000000000..a0749a0c2
--- /dev/null
+++ b/bin/ai/compat_0.8.nut
@@ -0,0 +1 @@
+/* $Id$ */
diff --git a/bin/ai/regression/regression.nut b/bin/ai/regression/regression.nut
index 5e1ab100a..c5b7d2cfb 100644
--- a/bin/ai/regression/regression.nut
+++ b/bin/ai/regression/regression.nut
@@ -1204,7 +1204,7 @@ function Regression::TileList()
list.AddRectangle(34436, 256 * 2 + 34436 + 8);
print(" Count(): " + list.Count());
- list.Valuate(AITile.GetHeight);
+ list.Valuate(AITile.GetCornerHeight, AITile.CORNER_N);
print(" Height(): done");
print(" Count(): " + list.Count());
print(" ListDump:");
diff --git a/bin/ai/regression/regression_info.nut b/bin/ai/regression/regression_info.nut
index 5eb8201c7..8c870c571 100644
--- a/bin/ai/regression/regression_info.nut
+++ b/bin/ai/regression/regression_info.nut
@@ -6,6 +6,7 @@ class Regression extends AIInfo {
function GetShortName() { return "REGR"; }
function GetDescription() { return "This runs regression-tests on all commands. On the same map the result should always be the same."; }
function GetVersion() { return 1; }
+ function GetAPIVersion() { return "0.8"; }
function GetDate() { return "2007-03-18"; }
function CreateInstance() { return "Regression"; }
}