summaryrefslogtreecommitdiff
path: root/regression/stationlist
diff options
context:
space:
mode:
Diffstat (limited to 'regression/stationlist')
-rw-r--r--regression/stationlist/info.nut13
-rw-r--r--regression/stationlist/main.nut214
-rw-r--r--regression/stationlist/result.txt127
-rw-r--r--regression/stationlist/test.savbin0 -> 94728 bytes
4 files changed, 354 insertions, 0 deletions
diff --git a/regression/stationlist/info.nut b/regression/stationlist/info.nut
new file mode 100644
index 000000000..42e5072fd
--- /dev/null
+++ b/regression/stationlist/info.nut
@@ -0,0 +1,13 @@
+class StationList extends AIInfo {
+ function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
+ function GetName() { return "StationList"; }
+ function GetShortName() { return "REGS"; }
+ function GetDescription() { return "This runs stationlist-tests on some commands. On the same map the result should always be the same."; }
+ function GetVersion() { return 1; }
+ function GetAPIVersion() { return "1.11"; }
+ function GetDate() { return "2007-03-18"; }
+ function CreateInstance() { return "StationList"; }
+}
+
+RegisterAI(StationList());
+
diff --git a/regression/stationlist/main.nut b/regression/stationlist/main.nut
new file mode 100644
index 000000000..b639c5404
--- /dev/null
+++ b/regression/stationlist/main.nut
@@ -0,0 +1,214 @@
+class StationList extends AIController {
+ function Start();
+};
+
+
+function StationList::StationList()
+{
+ local list = AIStationList(AIStation.STATION_BUS_STOP + AIStation.STATION_TRUCK_STOP);
+
+ print("");
+ print("--StationList--");
+ print(" Count(): " + list.Count());
+ list.Valuate(AIStation.GetLocation);
+ print(" Location ListDump:");
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+ list.Valuate(AIStation.GetCargoWaiting, 0);
+ print(" CargoWaiting(0) ListDump:");
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+ list.Valuate(AIStation.GetCargoWaiting, 1);
+ print(" CargoWaiting(1) ListDump:");
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+};
+
+function StationList::StationList_Cargo()
+{
+ print("");
+ print("--StationList_Cargo--");
+
+ for (local mode = AIStationList_Cargo.CM_WAITING; mode <= AIStationList_Cargo.CM_PLANNED; ++mode) {
+ print(" " + mode);
+ for (local selector = AIStationList_Cargo.CS_BY_FROM; selector <= AIStationList_Cargo.CS_FROM_BY_VIA ; ++selector) {
+ print(" " + selector);
+ local list = AIStationList_Cargo(mode, selector, 6, 0, 7);
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+ }
+ }
+};
+
+function StationList::StationList_CargoPlanned()
+{
+ print("");
+ print("--StationList_CargoPlanned--");
+
+ for (local selector = AIStationList_Cargo.CS_BY_FROM; selector <= AIStationList_Cargo.CS_FROM_BY_VIA; ++selector) {
+ print(" " + selector);
+ local list = AIStationList_CargoPlanned(selector, 6, 0, 7);
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+ }
+};
+
+function StationList::StationList_CargoPlannedByFrom()
+{
+ print("");
+ print("--StationList_CargoPlannedByFrom--");
+ local list = AIStationList_CargoPlannedByFrom(2, 0);
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+};
+
+function StationList::StationList_CargoPlannedByVia()
+{
+ print("");
+ print("--StationList_CargoPlannedByVia--");
+ local list = AIStationList_CargoPlannedByVia(2, 0);
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+};
+
+function StationList::StationList_CargoPlannedViaByFrom()
+{
+ print("");
+ print("--StationList_CargoPlannedViaByFrom--");
+ local list = AIStationList_CargoPlannedViaByFrom(6, 0, 7);
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+};
+
+function StationList::StationList_CargoPlannedFromByVia()
+{
+ print("");
+ print("--StationList_CargoPlannedFromByVia--");
+ local list = AIStationList_CargoPlannedFromByVia(6, 0, 7);
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+};
+
+function StationList::StationList_CargoWaiting()
+{
+ print("");
+ print("--StationList_CargoWaiting--");
+
+ for (local selector = AIStationList_Cargo.CS_BY_FROM; selector <= AIStationList_Cargo.CS_FROM_BY_VIA; ++selector) {
+ print(" " + selector);
+ local list = AIStationList_CargoWaiting(selector, 6, 0, 7);
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+ }
+};
+
+function StationList::StationList_CargoWaitingByFrom()
+{
+ print("");
+ print("--StationList_CargoWaitingByFrom--");
+ local list = AIStationList_CargoWaitingByFrom(2, 0);
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+};
+
+function StationList::StationList_CargoWaitingByVia()
+{
+ print("");
+ print("--StationList_CargoWaitingByVia--");
+ local list = AIStationList_CargoWaitingByVia(2, 0);
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+};
+
+function StationList::StationList_CargoWaitingViaByFrom()
+{
+ print("");
+ print("--StationList_CargoWaitingViaByFrom--");
+ local list = AIStationList_CargoWaitingViaByFrom(6, 0, 7);
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+};
+
+function StationList::StationList_CargoWaitingFromByVia()
+{
+ print("");
+ print("--StationList_CargoWaitingFromByVia--");
+ local list = AIStationList_CargoWaitingFromByVia(2, 0, 2);
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+};
+
+function StationList::StationList_Vehicle()
+{
+ local list = AIStationList_Vehicle(12);
+
+ print("");
+ print("--StationList_Vehicle--");
+ print(" Count(): " + list.Count());
+ list.Valuate(AIStation.GetLocation);
+ print(" Location ListDump:");
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+ list.Valuate(AIStation.GetCargoWaiting, 0);
+ print(" CargoWaiting(0) ListDump:");
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+ list.Valuate(AIStation.GetCargoWaiting, 1);
+ print(" CargoWaiting(1) ListDump:");
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+ list.Valuate(AIStation.GetCargoRating, 1);
+ print(" CargoRating(1) ListDump:");
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+ list.Valuate(AIStation.GetDistanceManhattanToTile, 30000);
+ print(" DistanceManhattanToTile(30000) ListDump:");
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+ list.Valuate(AIStation.GetDistanceSquareToTile, 30000);
+ print(" DistanceSquareToTile(30000) ListDump:");
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+ list.Valuate(AIStation.IsWithinTownInfluence, 0);
+ print(" IsWithinTownInfluence(0) ListDump:");
+ for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
+ print(" " + i + " => " + list.GetValue(i));
+ }
+}
+
+function StationList::Start()
+{
+ StationList();
+ StationList_Cargo();
+ StationList_CargoPlanned();
+ StationList_CargoPlannedByFrom();
+ StationList_CargoPlannedByVia();
+ StationList_CargoPlannedViaByFrom();
+ StationList_CargoPlannedFromByVia();
+ StationList_CargoWaiting();
+ StationList_CargoWaitingByFrom();
+ StationList_CargoWaitingByVia();
+ StationList_CargoWaitingViaByFrom();
+ StationList_CargoWaitingFromByVia();
+ StationList_Vehicle();
+}
diff --git a/regression/stationlist/result.txt b/regression/stationlist/result.txt
new file mode 100644
index 000000000..20e594766
--- /dev/null
+++ b/regression/stationlist/result.txt
@@ -0,0 +1,127 @@
+
+--StationList--
+ Count(): 5
+ Location ListDump:
+ 6 => 42341
+ 2 => 41831
+ 7 => 41825
+ 5 => 33421
+ 4 => 33411
+ CargoWaiting(0) ListDump:
+ 7 => 6
+ 6 => 6
+ 2 => 3
+ 5 => 0
+ 4 => 0
+ CargoWaiting(1) ListDump:
+ 7 => 0
+ 6 => 0
+ 5 => 0
+ 4 => 0
+ 2 => 0
+
+--StationList_Cargo--
+ 0
+ 0
+ 6 => 6
+ 1
+ 6 => 2
+ 2
+ 2 => 4
+ 7 => 2
+ 3
+ 1
+ 0
+ 7 => 18
+ 6 => 16
+ 2 => 7
+ 1
+ 6 => 8
+ 2 => 3
+ 2
+ 2 => 16
+ 6 => 14
+ 7 => 11
+ 3
+ 6 => 10
+ 2 => 8
+
+--StationList_CargoPlanned--
+ 0
+ 7 => 18
+ 6 => 16
+ 2 => 7
+ 1
+ 6 => 8
+ 2 => 3
+ 2
+ 2 => 16
+ 6 => 14
+ 7 => 11
+ 3
+ 6 => 10
+ 2 => 8
+
+--StationList_CargoPlannedByFrom--
+ 7 => 8
+ 6 => 8
+ 2 => 7
+
+--StationList_CargoPlannedByVia--
+ 2 => 16
+ 6 => 7
+
+--StationList_CargoPlannedViaByFrom--
+ 6 => 8
+ 2 => 3
+
+--StationList_CargoPlannedFromByVia--
+ 6 => 10
+ 2 => 8
+
+--StationList_CargoWaiting--
+ 0
+ 6 => 6
+ 1
+ 6 => 2
+ 2
+ 2 => 4
+ 7 => 2
+ 3
+
+--StationList_CargoWaitingByFrom--
+ 2 => 3
+
+--StationList_CargoWaitingByVia--
+ 6 => 3
+
+--StationList_CargoWaitingViaByFrom--
+ 6 => 2
+
+--StationList_CargoWaitingFromByVia--
+ 6 => 3
+
+--StationList_Vehicle--
+ Count(): 2
+ Location ListDump:
+ 5 => 33421
+ 4 => 33411
+ CargoWaiting(0) ListDump:
+ 5 => 0
+ 4 => 0
+ CargoWaiting(1) ListDump:
+ 5 => 0
+ 4 => 0
+ CargoRating(1) ListDump:
+ 5 => -1
+ 4 => -1
+ DistanceManhattanToTile(30000) ListDump:
+ 5 => 106
+ 4 => 96
+ DistanceSquareToTile(30000) ListDump:
+ 5 => 8818
+ 4 => 7058
+ IsWithinTownInfluence(0) ListDump:
+ 5 => 0
+ 4 => 0
+ERROR: The script died unexpectedly.
diff --git a/regression/stationlist/test.sav b/regression/stationlist/test.sav
new file mode 100644
index 000000000..959f77638
--- /dev/null
+++ b/regression/stationlist/test.sav
Binary files differ