(svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet) noai
authortruebrain
Wed, 27 Feb 2008 21:07:31 +0000
branchnoai
changeset 9792 e1222f4674c2
parent 9791 71367fffd9e8
child 9793 c5fb53240401
(svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
bin/ai/regression/regression.nut
bin/ai/regression/regression.txt
projects/openttd_vs80.vcproj
projects/openttd_vs90.vcproj
source.list
src/ai/ai_squirrel.cpp
src/ai/api/ai_bridge.cpp
src/ai/api/ai_bridge.hpp
src/ai/api/ai_bridge.hpp.sq
src/ai/api/ai_bridgelist.cpp
src/ai/api/ai_bridgelist.hpp
src/ai/api/ai_bridgelist.hpp.sq
src/ai/api/ai_bridgelist_valuator.cpp
src/ai/api/ai_bridgelist_valuator.hpp
src/ai/api/ai_bridgelist_valuator.hpp.sq
--- a/bin/ai/regression/regression.nut	Wed Feb 27 19:58:17 2008 +0000
+++ b/bin/ai/regression/regression.nut	Wed Feb 27 21:07:31 2008 +0000
@@ -81,6 +81,76 @@
 	print("  BuildAirport():       " + AIAirport.BuildAirport(32116, 0));
 }
 
+function Regression::Bridge()
+{
+	local j = 0;
+
+	print("");
+	print("--Bridge--");
+	for (local i = -1; i < 14; i++) {
+		if (AIBridge.IsValidBridge(i)) j++;
+		print("  Bridge " + i);
+		print("    IsValidBridge():    " + AIBridge.IsValidBridge(i));
+		print("    GetName():          " + AIBridge.GetName(i));
+		print("    GetMaxSpeed():      " + AIBridge.GetMaxSpeed(i));
+		print("    GetPrice():         " + AIBridge.GetPrice(i, 5));
+		print("    GetMaxLength():     " + AIBridge.GetMaxLength(i));
+		print("    GetMinLength():     " + AIBridge.GetMinLength(i));
+		print("    GetYearAvailable(): " + AIBridge.GetYearAvailable(i));
+	}
+	print("  Valid Bridges:        " + j);
+}
+
+function Regression::BridgeList()
+{
+	local list = AIBridgeList();
+
+	print("");
+	print("--BridgeList--");
+	print("  Count():             " + list.Count());
+	list.Valuate(AIBridgeList_vMaxSpeed());
+	print("  MaxSpeed ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+	list.Valuate(AIBridgeList_vPrice(5));
+	print("  Price ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+	list.Valuate(AIBridgeList_vMaxLength());
+	print("  MaxLength ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+	list.Valuate(AIBridgeList_vMinLength());
+	print("  MinLength ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+	list.Valuate(AIBridgeList_vYearAvailable());
+	print("  YearAvailable ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+
+	local list = AIBridgeList_Length(14);
+
+	print("");
+	print("--BridgeList_Length--");
+	print("  Count():             " + list.Count());
+	list.Valuate(AIBridgeList_vMaxSpeed());
+	print("  MaxSpeed ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+	list.Valuate(AIBridgeList_vPrice(14));
+	print("  Price ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+}
+
 function Regression::Cargo()
 {
 	print("");
@@ -997,6 +1067,8 @@
 	this.Base();
 	this.List();
 	this.Airport();
+	this.Bridge();
+	this.BridgeList();
 	this.Cargo();
 	this.CargoList();
 	this.Company();
--- a/bin/ai/regression/regression.txt	Wed Feb 27 19:58:17 2008 +0000
+++ b/bin/ai/regression/regression.txt	Wed Feb 27 21:07:31 2008 +0000
@@ -339,6 +339,198 @@
   GetBankBalance():     89836
   BuildAirport():       true
 
+--Bridge--
+  Bridge -1
+    IsValidBridge():    false
+    GetName():          (null : 0x00000000)
+    GetMaxSpeed():      0
+    GetPrice():         0
+    GetMaxLength():     0
+    GetMinLength():     0
+    GetYearAvailable(): 0
+  Bridge 0
+    IsValidBridge():    true
+    GetName():          Wooden rail bridge
+    GetMaxSpeed():      32
+    GetPrice():         321
+    GetMaxLength():     102
+    GetMinLength():     2
+    GetYearAvailable(): 0
+  Bridge 1
+    IsValidBridge():    true
+    GetName():          Concrete rail bridge
+    GetMaxSpeed():      48
+    GetPrice():         450
+    GetMaxLength():     4
+    GetMinLength():     2
+    GetYearAvailable(): 0
+  Bridge 2
+    IsValidBridge():    true
+    GetName():          Steel girder rail bridge
+    GetMaxSpeed():      64
+    GetPrice():         579
+    GetMaxLength():     7
+    GetMinLength():     2
+    GetYearAvailable(): 1930
+  Bridge 3
+    IsValidBridge():    true
+    GetName():          Reinforced concrete suspension rail bridge
+    GetMaxSpeed():      80
+    GetPrice():         675
+    GetMaxLength():     12
+    GetMinLength():     4
+    GetYearAvailable(): 0
+  Bridge 4
+    IsValidBridge():    true
+    GetName():          Steel suspension rail bridge
+    GetMaxSpeed():      96
+    GetPrice():         744
+    GetMaxLength():     102
+    GetMinLength():     5
+    GetYearAvailable(): 1930
+  Bridge 5
+    IsValidBridge():    true
+    GetName():          Steel suspension rail bridge
+    GetMaxSpeed():      112
+    GetPrice():         772
+    GetMaxLength():     102
+    GetMinLength():     5
+    GetYearAvailable(): 1930
+  Bridge 6
+    IsValidBridge():    true
+    GetName():          Steel cantilever rail bridge
+    GetMaxSpeed():      160
+    GetPrice():         901
+    GetMaxLength():     9
+    GetMinLength():     5
+    GetYearAvailable(): 1930
+  Bridge 7
+    IsValidBridge():    true
+    GetName():          Steel cantilever rail bridge
+    GetMaxSpeed():      208
+    GetPrice():         933
+    GetMaxLength():     10
+    GetMinLength():     5
+    GetYearAvailable(): 1930
+  Bridge 8
+    IsValidBridge():    true
+    GetName():          Steel cantilever rail bridge
+    GetMaxSpeed():      240
+    GetPrice():         997
+    GetMaxLength():     11
+    GetMinLength():     5
+    GetYearAvailable(): 1930
+  Bridge 9
+    IsValidBridge():    true
+    GetName():          Steel girder rail bridge
+    GetMaxSpeed():      256
+    GetPrice():         965
+    GetMaxLength():     4
+    GetMinLength():     2
+    GetYearAvailable(): 1930
+  Bridge 10
+    IsValidBridge():    true
+    GetName():          Tubular rail bridge
+    GetMaxSpeed():      320
+    GetPrice():         1025
+    GetMaxLength():     102
+    GetMinLength():     4
+    GetYearAvailable(): 1995
+  Bridge 11
+    IsValidBridge():    true
+    GetName():          Tubular rail bridge
+    GetMaxSpeed():      512
+    GetPrice():         1528
+    GetMaxLength():     102
+    GetMinLength():     4
+    GetYearAvailable(): 2005
+  Bridge 12
+    IsValidBridge():    true
+    GetName():          Tubular rail bridge
+    GetMaxSpeed():      608
+    GetPrice():         2051
+    GetMaxLength():     102
+    GetMinLength():     4
+    GetYearAvailable(): 2010
+  Bridge 13
+    IsValidBridge():    false
+    GetName():          (null : 0x00000000)
+    GetMaxSpeed():      0
+    GetPrice():         0
+    GetMaxLength():     0
+    GetMinLength():     0
+    GetYearAvailable(): 0
+  Valid Bridges:        13
+
+--BridgeList--
+  Count():             10
+  MaxSpeed ListDump:
+    9 => 256
+    8 => 240
+    7 => 208
+    6 => 160
+    5 => 112
+    4 => 96
+    3 => 80
+    2 => 64
+    1 => 48
+    0 => 32
+  Price ListDump:
+    8 => 997
+    9 => 965
+    7 => 933
+    6 => 901
+    5 => 772
+    4 => 744
+    3 => 675
+    2 => 579
+    1 => 450
+    0 => 321
+  MaxLength ListDump:
+    5 => 102
+    4 => 102
+    0 => 102
+    3 => 12
+    8 => 11
+    7 => 10
+    6 => 9
+    2 => 7
+    9 => 4
+    1 => 4
+  MinLength ListDump:
+    8 => 5
+    7 => 5
+    6 => 5
+    5 => 5
+    4 => 5
+    3 => 4
+    9 => 2
+    2 => 2
+    1 => 2
+    0 => 2
+  YearAvailable ListDump:
+    9 => 1930
+    8 => 1930
+    7 => 1930
+    6 => 1930
+    5 => 1930
+    4 => 1930
+    2 => 1930
+    3 => 0
+    1 => 0
+    0 => 0
+
+--BridgeList_Length--
+  Count():             3
+  MaxSpeed ListDump:
+    5 => 112
+    4 => 96
+    0 => 32
+  Price ListDump:
+    5 => 2163
+    4 => 2084
+    0 => 901
+
 --AICargo--
   Cargo -1
     IsValidCargo():          false
--- a/projects/openttd_vs80.vcproj	Wed Feb 27 19:58:17 2008 +0000
+++ b/projects/openttd_vs80.vcproj	Wed Feb 27 21:07:31 2008 +0000
@@ -1944,6 +1944,18 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_bridge.hpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\ai\api\ai_bridgelist.hpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\ai\api\ai_bridgelist_valuator.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_cargo.hpp"
 				>
 			</File>
@@ -2120,6 +2132,18 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_bridge.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\ai\api\ai_bridgelist.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\ai\api\ai_bridgelist_valuator.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_cargo.cpp"
 				>
 			</File>
--- a/projects/openttd_vs90.vcproj	Wed Feb 27 19:58:17 2008 +0000
+++ b/projects/openttd_vs90.vcproj	Wed Feb 27 21:07:31 2008 +0000
@@ -1941,6 +1941,18 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_bridge.hpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\ai\api\ai_bridgelist.hpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\ai\api\ai_bridgelist_valuator.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_cargo.hpp"
 				>
 			</File>
@@ -2117,6 +2129,18 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_bridge.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\ai\api\ai_bridgelist.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\..\src\ai\api\ai_bridgelist_valuator.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_cargo.cpp"
 				>
 			</File>
--- a/source.list	Wed Feb 27 19:58:17 2008 +0000
+++ b/source.list	Wed Feb 27 21:07:31 2008 +0000
@@ -402,6 +402,9 @@
 ai/api/ai_accounting.hpp
 ai/api/ai_airport.hpp
 ai/api/ai_base.hpp
+ai/api/ai_bridge.hpp
+ai/api/ai_bridgelist.hpp
+ai/api/ai_bridgelist_valuator.hpp
 ai/api/ai_cargo.hpp
 ai/api/ai_cargolist.hpp
 ai/api/ai_cargolist_valuator.hpp
@@ -447,6 +450,9 @@
 ai/api/ai_accounting.cpp
 ai/api/ai_airport.cpp
 ai/api/ai_base.cpp
+ai/api/ai_bridge.cpp
+ai/api/ai_bridgelist.cpp
+ai/api/ai_bridgelist_valuator.cpp
 ai/api/ai_cargo.cpp
 ai/api/ai_cargolist.cpp
 ai/api/ai_cargolist_valuator.cpp
--- a/src/ai/ai_squirrel.cpp	Wed Feb 27 19:58:17 2008 +0000
+++ b/src/ai/ai_squirrel.cpp	Wed Feb 27 21:07:31 2008 +0000
@@ -26,6 +26,9 @@
 #include "api/ai_accounting.hpp.sq"
 #include "api/ai_airport.hpp.sq"
 #include "api/ai_base.hpp.sq"
+#include "api/ai_bridge.hpp.sq"
+#include "api/ai_bridgelist.hpp.sq"
+#include "api/ai_bridgelist_valuator.hpp.sq"
 #include "api/ai_cargo.hpp.sq"
 #include "api/ai_cargolist.hpp.sq"
 #include "api/ai_cargolist_valuator.hpp.sq"
@@ -220,6 +223,14 @@
 	SQAIAccounting_Register(this->engine);
 	SQAIAirport_Register(this->engine);
 	SQAIBase_Register(this->engine);
+	SQAIBridge_Register(this->engine);
+	SQAIBridgeList_Register(this->engine);
+	SQAIBridgeList_Length_Register(this->engine);
+	SQAIBridgeList_vMaxLength_Register(this->engine);
+	SQAIBridgeList_vMaxSpeed_Register(this->engine);
+	SQAIBridgeList_vMinLength_Register(this->engine);
+	SQAIBridgeList_vPrice_Register(this->engine);
+	SQAIBridgeList_vYearAvailable_Register(this->engine);
 	SQAICargo_Register(this->engine);
 	SQAICargoList_Register(this->engine);
 	SQAICargoList_vCargoIncomes_Register(this->engine);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_bridge.cpp	Wed Feb 27 21:07:31 2008 +0000
@@ -0,0 +1,64 @@
+/* $Id$ */
+
+/** @file ai_bridge.cpp handles the functions of the AIBridge class */
+
+#include "ai_bridge.hpp"
+#include "../../bridge.h"
+#include "../../strings_func.h"
+#include "../../core/alloc_func.hpp"
+#include "../../economy_func.h"
+#include "../../settings_type.h"
+#include "table/strings.h"
+
+/* static */ bool AIBridge::IsValidBridge(BridgeID bridge_id)
+{
+	return bridge_id < MAX_BRIDGES;
+}
+
+/* static */ char *AIBridge::GetName(BridgeID bridge_id)
+{
+	if (!IsValidBridge(bridge_id)) return NULL;
+
+	static const int len = 64;
+	char *bridge_name = MallocT<char>(len);
+
+	::GetString(bridge_name, ::GetBridgeSpec(bridge_id)->transport_name[0], &bridge_name[len - 1]);
+	return bridge_name;
+}
+
+/* static */ uint32 AIBridge::GetMaxSpeed(BridgeID bridge_id)
+{
+	if (!IsValidBridge(bridge_id)) return 0;
+
+	return ::GetBridgeSpec(bridge_id)->speed;
+}
+
+/* static */ uint32 AIBridge::GetPrice(BridgeID bridge_id, uint length)
+{
+	if (!IsValidBridge(bridge_id)) return 0;
+
+	return length * _price.build_bridge * ::GetBridgeSpec(bridge_id)->price >> 8;
+}
+
+/* static */ uint32 AIBridge::GetMaxLength(BridgeID bridge_id)
+{
+	if (!IsValidBridge(bridge_id)) return 0;
+
+	uint max = ::GetBridgeSpec(bridge_id)->max_length;
+	if (max >= 16 && _patches.longbridges) max = 100;
+	return max + 2;
+}
+
+/* static */ uint32 AIBridge::GetMinLength(BridgeID bridge_id)
+{
+	if (!IsValidBridge(bridge_id)) return 0;
+
+	return ::GetBridgeSpec(bridge_id)->min_length + 2;
+}
+
+/* static */ int32 AIBridge::GetYearAvailable(BridgeID bridge_id)
+{
+	if (!IsValidBridge(bridge_id)) return 0;
+
+	return ::GetBridgeSpec(bridge_id)->avail_year;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_bridge.hpp	Wed Feb 27 21:07:31 2008 +0000
@@ -0,0 +1,82 @@
+/* $Id$ */
+
+/** @file ai_bridge.hpp Everything to query and build bridges */
+
+#ifndef AI_BRIDGE_HPP
+#define AI_BRIDGE_HPP
+
+#include "ai_object.hpp"
+#include "../../bridge.h"
+
+typedef BridgeType BridgeID;
+
+/**
+ * Class that handles all bridge related functions.
+ */
+class AIBridge : public AIObject {
+public:
+	/**
+	 * The name of the class, needed by several sub-processes.
+	 */
+	static const char *GetClassName() { return "AIBridge"; }
+
+	/**
+	 * Checks whether the given bridge type is valid.
+	 * @param bridge_id The bridge to check.
+	 * @return True if and only if the bridge type is valid.
+	 */
+	static bool IsValidBridge(BridgeID bridge_id);
+
+	/**
+	 * Get the name of a bridge.
+	 * @param bridge_id The bridge to get the name of.
+	 * @pre IsValidBridge(bridge_id).
+	 * @return The name the bridge has.
+	 * @note the returned name must be free'd (C++ only).
+	 */
+	static char *GetName(BridgeID bridge_id);
+
+	/**
+	 * Get the maximum speed of a bridge (in km/h).
+	 * @param bridge_id The bridge to get the maximum speed of.
+	 * @pre IsValidBridge(bridge_id).
+	 * @return The maximum speed the bridge has.
+	 */
+	static uint32 GetMaxSpeed(BridgeID bridge_id);
+
+	/**
+	 * Get the new cost of a bridge.
+	 * @param bridge_id The bridge to get the new cost of.
+	 * @param length The length of the bridge.
+	 * @pre IsValidBridge(bridge_id).
+	 * @return The new cost the bridge has.
+	 */
+	static uint32 GetPrice(BridgeID bridge_id, uint length);
+
+	/**
+	 * Get the maximum length of a bridge.
+	 * @param bridge_id The bridge to get the maximum length of.
+	 * @pre IsValidBridge(bridge_id).
+	 * @returns The maximum length the bridge has.
+	 */
+	static uint32 GetMaxLength(BridgeID bridge_id);
+
+	/**
+	 * Get the minimum length of a bridge.
+	 * @param bridge_id The bridge to get the minimum length of.
+	 * @pre IsValidBridge(bridge_id).
+	 * @returns The minimum length the bridge has.
+	 */
+	static uint32 GetMinLength(BridgeID bridge_id);
+
+	/**
+	 * Get the year in which a bridge becomes available.
+	 * @note Years are like 2010, -10 (10 B.C.), 1950, ..
+	 * @param bridge_id The bridge to get the year of availability of.
+	 * @pre IsValidBridge(bridge_id).
+	 * @returns The year of availability the bridge has.
+	 */
+	static int32 GetYearAvailable(BridgeID bridge_id);
+};
+
+#endif /* AI_BRIDGE_HPP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_bridge.hpp.sq	Wed Feb 27 21:07:31 2008 +0000
@@ -0,0 +1,27 @@
+#include "ai_bridge.hpp"
+
+namespace SQConvert {
+	/* Allow AIBridge to be used as Squirrel parameter */
+	template <> AIBridge *GetParam(ForceType<AIBridge *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridge *)instance; }
+	template <> AIBridge &GetParam(ForceType<AIBridge &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridge *)instance; }
+	template <> const AIBridge *GetParam(ForceType<const AIBridge *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridge *)instance; }
+	template <> const AIBridge &GetParam(ForceType<const AIBridge &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridge *)instance; }
+	template <> int Return<AIBridge *>(HSQUIRRELVM vm, AIBridge *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIBridge", res, NULL, DefSQDestructorCallback<AIBridge>); return 1; }
+}; // namespace SQConvert
+
+void SQAIBridge_Register(Squirrel *engine) {
+	DefSQClass <AIBridge> SQAIBridge("AIBridge");
+	SQAIBridge.PreRegister(engine);
+	SQAIBridge.AddConstructor<void (AIBridge::*)(), 1>(engine, "x");
+
+	SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetClassName,     "GetClassName",     1, "x");
+	SQAIBridge.DefSQStaticMethod(engine, &AIBridge::IsValidBridge,    "IsValidBridge",    2, "xi");
+	SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetName,          "GetName",          2, "xi");
+	SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetMaxSpeed,      "GetMaxSpeed",      2, "xi");
+	SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetPrice,         "GetPrice",         3, "xii");
+	SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetMaxLength,     "GetMaxLength",     2, "xi");
+	SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetMinLength,     "GetMinLength",     2, "xi");
+	SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetYearAvailable, "GetYearAvailable", 2, "xi");
+
+	SQAIBridge.PostRegister(engine);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_bridgelist.cpp	Wed Feb 27 21:07:31 2008 +0000
@@ -0,0 +1,19 @@
+#include "ai_bridgelist.hpp"
+#include "../../bridge.h"
+#include "../../date_func.h"
+
+AIBridgeList::AIBridgeList()
+{
+	/* Add all bridges, no matter if they are available or not */
+	for (byte j = 0; j < MAX_BRIDGES; j++)
+		if (::GetBridgeSpec(j)->avail_year <= _cur_year)
+			this->AddItem(j);
+}
+
+AIBridgeList_Length::AIBridgeList_Length(uint length)
+{
+	for (byte j = 0; j < MAX_BRIDGES; j++)
+		if (::GetBridgeSpec(j)->avail_year <= _cur_year)
+			if (length >= ::GetBridgeSpec(j)->min_length && length <= ::GetBridgeSpec(j)->max_length)
+				this->AddItem(j);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_bridgelist.hpp	Wed Feb 27 21:07:31 2008 +0000
@@ -0,0 +1,37 @@
+/* $Id$ */
+
+/** @file ai_bridgelist.hpp list all the bridges */
+/** @defgroup AIBridgeList AIBridgeList - Valuators and lists working on/with AIBridgeList */
+
+#ifndef AI_BRIDGELIST_HPP
+#define AI_BRIDGELIST_HPP
+
+#include "ai_abstractlist.hpp"
+
+/**
+ * Create a list of bridges.
+ * @ingroup AIBridgeList
+ */
+class AIBridgeList : public AIAbstractList {
+public:
+	static const char *GetClassName() { return "AIBridgeList"; }
+	AIBridgeList();
+
+private:
+	const char *GetListName() const { return "AIBridgeList"; }
+};
+
+/**
+ * Create a list of bridges that can be built on a specific length.
+ * @ingroup AIBridgeList
+ */
+class AIBridgeList_Length : public AIAbstractList {
+public:
+	static const char *GetClassName() { return "AIBridgeList_Length"; }
+	AIBridgeList_Length(uint length);
+
+private:
+	const char *GetListName() const { return "AIBridgeList"; }
+};
+
+#endif /* AI_BRIDGELIST_HPP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_bridgelist.hpp.sq	Wed Feb 27 21:07:31 2008 +0000
@@ -0,0 +1,39 @@
+#include "ai_bridgelist.hpp"
+
+namespace SQConvert {
+	/* Allow AIBridgeList to be used as Squirrel parameter */
+	template <> AIBridgeList *GetParam(ForceType<AIBridgeList *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList *)instance; }
+	template <> AIBridgeList &GetParam(ForceType<AIBridgeList &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList *)instance; }
+	template <> const AIBridgeList *GetParam(ForceType<const AIBridgeList *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList *)instance; }
+	template <> const AIBridgeList &GetParam(ForceType<const AIBridgeList &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList *)instance; }
+	template <> int Return<AIBridgeList *>(HSQUIRRELVM vm, AIBridgeList *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIBridgeList", res, NULL, DefSQDestructorCallback<AIBridgeList>); return 1; }
+}; // namespace SQConvert
+
+void SQAIBridgeList_Register(Squirrel *engine) {
+	DefSQClass <AIBridgeList> SQAIBridgeList("AIBridgeList");
+	SQAIBridgeList.PreRegister(engine, "AIAbstractList");
+	SQAIBridgeList.AddConstructor<void (AIBridgeList::*)(), 1>(engine, "x");
+
+	SQAIBridgeList.DefSQStaticMethod(engine, &AIBridgeList::GetClassName, "GetClassName", 1, "x");
+
+	SQAIBridgeList.PostRegister(engine);
+}
+
+namespace SQConvert {
+	/* Allow AIBridgeList_Length to be used as Squirrel parameter */
+	template <> AIBridgeList_Length *GetParam(ForceType<AIBridgeList_Length *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_Length *)instance; }
+	template <> AIBridgeList_Length &GetParam(ForceType<AIBridgeList_Length &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_Length *)instance; }
+	template <> const AIBridgeList_Length *GetParam(ForceType<const AIBridgeList_Length *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_Length *)instance; }
+	template <> const AIBridgeList_Length &GetParam(ForceType<const AIBridgeList_Length &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_Length *)instance; }
+	template <> int Return<AIBridgeList_Length *>(HSQUIRRELVM vm, AIBridgeList_Length *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIBridgeList_Length", res, NULL, DefSQDestructorCallback<AIBridgeList_Length>); return 1; }
+}; // namespace SQConvert
+
+void SQAIBridgeList_Length_Register(Squirrel *engine) {
+	DefSQClass <AIBridgeList_Length> SQAIBridgeList_Length("AIBridgeList_Length");
+	SQAIBridgeList_Length.PreRegister(engine, "AIAbstractList");
+	SQAIBridgeList_Length.AddConstructor<void (AIBridgeList_Length::*)(uint length), 2>(engine, "xi");
+
+	SQAIBridgeList_Length.DefSQStaticMethod(engine, &AIBridgeList_Length::GetClassName, "GetClassName", 1, "x");
+
+	SQAIBridgeList_Length.PostRegister(engine);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_bridgelist_valuator.cpp	Wed Feb 27 21:07:31 2008 +0000
@@ -0,0 +1,28 @@
+#include "ai_bridgelist_valuator.hpp"
+#include "ai_bridge.hpp"
+
+int32 AIBridgeList_vMaxSpeed::Valuate(int32 bridge_id) const
+{
+	return AIBridge::GetMaxSpeed(bridge_id);
+}
+
+int32 AIBridgeList_vPrice::Valuate(int32 bridge_id) const
+{
+	return AIBridge::GetPrice(bridge_id, this->length);
+}
+
+int32 AIBridgeList_vMaxLength::Valuate(int32 bridge_id) const
+{
+	return AIBridge::GetMaxLength(bridge_id);
+}
+
+int32 AIBridgeList_vMinLength::Valuate(int32 bridge_id) const
+{
+	return AIBridge::GetMinLength(bridge_id);
+}
+
+int32 AIBridgeList_vYearAvailable::Valuate(int32 bridge_id) const
+{
+	return AIBridge::GetYearAvailable(bridge_id);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_bridgelist_valuator.hpp	Wed Feb 27 21:07:31 2008 +0000
@@ -0,0 +1,95 @@
+/* $Id$ */
+
+/** @file ai_bridgelist_valuator.hpp all the valuators for AIBridgeList */
+
+#ifndef AI_BRIDGELIST_VALUATOR_HPP
+#define AI_BRIDGELIST_VALUATOR_HPP
+
+#include "ai_abstractlist.hpp"
+
+/**
+ * Get the maximum speed for entries in an AIBridgeList instance.
+ * @note Resulting items are of the type int32.
+ * @note Can only operate on an AIBridgeList instance.
+ * @ingroup AIBridgeList
+ */
+class AIBridgeList_vMaxSpeed : public AIAbstractList::Valuator {
+public:
+	static const char *GetClassName() { return "AIBridgeList_vMaxSpeed"; }
+
+private:
+	const char *GetListName() const { return "AIBridgeList"; }
+	int32 Valuate(int32 bridge_id) const;
+};
+
+/**
+ * Get the price for entries in an AIBridgeList instance.
+ * @note Resulting items are of the type int32.
+ * @note Can only operate on an AIBridgeList instance.
+ * @ingroup AIBridgeList
+ */
+class AIBridgeList_vPrice : public AIAbstractList::Valuator {
+public:
+	static const char *GetClassName() { return "AIBridgeList_vPrice"; }
+
+	/**
+	 * @param length The length of the bridge you want to build.
+	 */
+	AIBridgeList_vPrice(uint length) :
+		length(length)
+	{}
+
+private:
+	uint length;
+
+	const char *GetListName() const { return "AIBridgeList"; }
+	int32 Valuate(int32 bridge_id) const;
+};
+
+/**
+ * Get the maximum bridge length for entries in an AIBridgeList instance.
+ * @note Resulting items are of the type int32.
+ * @note Can only operate on an AIBridgeList instance.
+ * @ingroup AIBridgeList
+ */
+class AIBridgeList_vMaxLength : public AIAbstractList::Valuator {
+public:
+	static const char *GetClassName() { return "AIBridgeList_vMaxLength"; }
+
+private:
+	const char *GetListName() const { return "AIBridgeList"; }
+	int32 Valuate(int32 bridge_id) const;
+};
+
+/**
+ * Get the minimum bridge length for entries in an AIBridgeList instance.
+ * @note Resulting items are of the type int32.
+ * @note Can only operate on an AIBridgeList instance.
+ * @ingroup AIBridgeList
+ */
+class AIBridgeList_vMinLength : public AIAbstractList::Valuator {
+public:
+	static const char *GetClassName() { return "AIBridgeList_vMinLength"; }
+
+private:
+	const char *GetListName() const { return "AIBridgeList"; }
+	int32 Valuate(int32 bridge_id) const;
+};
+
+/**
+ * Get the year in which the bridge will be available for all entries in an
+ *  AIBridgeList instance.
+ * @note Resulting items are of the type int32.
+ * @note Can only operate on an AIBridgeList instance.
+ * @ingroup AIBridgeList
+ */
+class AIBridgeList_vYearAvailable : public AIAbstractList::Valuator {
+public:
+	static const char *GetClassName() { return "AIBridgeList_vYearAvailable"; }
+
+private:
+	const char *GetListName() const { return "AIBridgeList"; }
+	int32 Valuate(int32 bridge_id) const;
+};
+
+#endif /* AI_BRIDGELIST_VALUATOR_HPP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_bridgelist_valuator.hpp.sq	Wed Feb 27 21:07:31 2008 +0000
@@ -0,0 +1,96 @@
+#include "ai_bridgelist_valuator.hpp"
+
+namespace SQConvert {
+	/* Allow AIBridgeList_vMaxSpeed to be used as Squirrel parameter */
+	template <> AIBridgeList_vMaxSpeed *GetParam(ForceType<AIBridgeList_vMaxSpeed *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_vMaxSpeed *)instance; }
+	template <> AIBridgeList_vMaxSpeed &GetParam(ForceType<AIBridgeList_vMaxSpeed &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_vMaxSpeed *)instance; }
+	template <> const AIBridgeList_vMaxSpeed *GetParam(ForceType<const AIBridgeList_vMaxSpeed *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_vMaxSpeed *)instance; }
+	template <> const AIBridgeList_vMaxSpeed &GetParam(ForceType<const AIBridgeList_vMaxSpeed &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_vMaxSpeed *)instance; }
+	template <> int Return<AIBridgeList_vMaxSpeed *>(HSQUIRRELVM vm, AIBridgeList_vMaxSpeed *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIBridgeList_vMaxSpeed", res, NULL, DefSQDestructorCallback<AIBridgeList_vMaxSpeed>); return 1; }
+}; // namespace SQConvert
+
+void SQAIBridgeList_vMaxSpeed_Register(Squirrel *engine) {
+	DefSQClass <AIBridgeList_vMaxSpeed> SQAIBridgeList_vMaxSpeed("AIBridgeList_vMaxSpeed");
+	SQAIBridgeList_vMaxSpeed.PreRegister(engine);
+	SQAIBridgeList_vMaxSpeed.AddConstructor<void (AIBridgeList_vMaxSpeed::*)(), 1>(engine, "x");
+
+	SQAIBridgeList_vMaxSpeed.DefSQStaticMethod(engine, &AIBridgeList_vMaxSpeed::GetClassName, "GetClassName", 1, "x");
+
+	SQAIBridgeList_vMaxSpeed.PostRegister(engine);
+}
+
+namespace SQConvert {
+	/* Allow AIBridgeList_vPrice to be used as Squirrel parameter */
+	template <> AIBridgeList_vPrice *GetParam(ForceType<AIBridgeList_vPrice *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_vPrice *)instance; }
+	template <> AIBridgeList_vPrice &GetParam(ForceType<AIBridgeList_vPrice &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_vPrice *)instance; }
+	template <> const AIBridgeList_vPrice *GetParam(ForceType<const AIBridgeList_vPrice *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_vPrice *)instance; }
+	template <> const AIBridgeList_vPrice &GetParam(ForceType<const AIBridgeList_vPrice &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_vPrice *)instance; }
+	template <> int Return<AIBridgeList_vPrice *>(HSQUIRRELVM vm, AIBridgeList_vPrice *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIBridgeList_vPrice", res, NULL, DefSQDestructorCallback<AIBridgeList_vPrice>); return 1; }
+}; // namespace SQConvert
+
+void SQAIBridgeList_vPrice_Register(Squirrel *engine) {
+	DefSQClass <AIBridgeList_vPrice> SQAIBridgeList_vPrice("AIBridgeList_vPrice");
+	SQAIBridgeList_vPrice.PreRegister(engine);
+	SQAIBridgeList_vPrice.AddConstructor<void (AIBridgeList_vPrice::*)(uint length), 2>(engine, "xi");
+
+	SQAIBridgeList_vPrice.DefSQStaticMethod(engine, &AIBridgeList_vPrice::GetClassName, "GetClassName", 1, "x");
+
+	SQAIBridgeList_vPrice.PostRegister(engine);
+}
+
+namespace SQConvert {
+	/* Allow AIBridgeList_vMaxLength to be used as Squirrel parameter */
+	template <> AIBridgeList_vMaxLength *GetParam(ForceType<AIBridgeList_vMaxLength *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_vMaxLength *)instance; }
+	template <> AIBridgeList_vMaxLength &GetParam(ForceType<AIBridgeList_vMaxLength &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_vMaxLength *)instance; }
+	template <> const AIBridgeList_vMaxLength *GetParam(ForceType<const AIBridgeList_vMaxLength *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_vMaxLength *)instance; }
+	template <> const AIBridgeList_vMaxLength &GetParam(ForceType<const AIBridgeList_vMaxLength &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_vMaxLength *)instance; }
+	template <> int Return<AIBridgeList_vMaxLength *>(HSQUIRRELVM vm, AIBridgeList_vMaxLength *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIBridgeList_vMaxLength", res, NULL, DefSQDestructorCallback<AIBridgeList_vMaxLength>); return 1; }
+}; // namespace SQConvert
+
+void SQAIBridgeList_vMaxLength_Register(Squirrel *engine) {
+	DefSQClass <AIBridgeList_vMaxLength> SQAIBridgeList_vMaxLength("AIBridgeList_vMaxLength");
+	SQAIBridgeList_vMaxLength.PreRegister(engine);
+	SQAIBridgeList_vMaxLength.AddConstructor<void (AIBridgeList_vMaxLength::*)(), 1>(engine, "x");
+
+	SQAIBridgeList_vMaxLength.DefSQStaticMethod(engine, &AIBridgeList_vMaxLength::GetClassName, "GetClassName", 1, "x");
+
+	SQAIBridgeList_vMaxLength.PostRegister(engine);
+}
+
+namespace SQConvert {
+	/* Allow AIBridgeList_vMinLength to be used as Squirrel parameter */
+	template <> AIBridgeList_vMinLength *GetParam(ForceType<AIBridgeList_vMinLength *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_vMinLength *)instance; }
+	template <> AIBridgeList_vMinLength &GetParam(ForceType<AIBridgeList_vMinLength &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_vMinLength *)instance; }
+	template <> const AIBridgeList_vMinLength *GetParam(ForceType<const AIBridgeList_vMinLength *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_vMinLength *)instance; }
+	template <> const AIBridgeList_vMinLength &GetParam(ForceType<const AIBridgeList_vMinLength &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_vMinLength *)instance; }
+	template <> int Return<AIBridgeList_vMinLength *>(HSQUIRRELVM vm, AIBridgeList_vMinLength *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIBridgeList_vMinLength", res, NULL, DefSQDestructorCallback<AIBridgeList_vMinLength>); return 1; }
+}; // namespace SQConvert
+
+void SQAIBridgeList_vMinLength_Register(Squirrel *engine) {
+	DefSQClass <AIBridgeList_vMinLength> SQAIBridgeList_vMinLength("AIBridgeList_vMinLength");
+	SQAIBridgeList_vMinLength.PreRegister(engine);
+	SQAIBridgeList_vMinLength.AddConstructor<void (AIBridgeList_vMinLength::*)(), 1>(engine, "x");
+
+	SQAIBridgeList_vMinLength.DefSQStaticMethod(engine, &AIBridgeList_vMinLength::GetClassName, "GetClassName", 1, "x");
+
+	SQAIBridgeList_vMinLength.PostRegister(engine);
+}
+
+namespace SQConvert {
+	/* Allow AIBridgeList_vYearAvailable to be used as Squirrel parameter */
+	template <> AIBridgeList_vYearAvailable *GetParam(ForceType<AIBridgeList_vYearAvailable *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_vYearAvailable *)instance; }
+	template <> AIBridgeList_vYearAvailable &GetParam(ForceType<AIBridgeList_vYearAvailable &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_vYearAvailable *)instance; }
+	template <> const AIBridgeList_vYearAvailable *GetParam(ForceType<const AIBridgeList_vYearAvailable *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIBridgeList_vYearAvailable *)instance; }
+	template <> const AIBridgeList_vYearAvailable &GetParam(ForceType<const AIBridgeList_vYearAvailable &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBridgeList_vYearAvailable *)instance; }
+	template <> int Return<AIBridgeList_vYearAvailable *>(HSQUIRRELVM vm, AIBridgeList_vYearAvailable *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIBridgeList_vYearAvailable", res, NULL, DefSQDestructorCallback<AIBridgeList_vYearAvailable>); return 1; }
+}; // namespace SQConvert
+
+void SQAIBridgeList_vYearAvailable_Register(Squirrel *engine) {
+	DefSQClass <AIBridgeList_vYearAvailable> SQAIBridgeList_vYearAvailable("AIBridgeList_vYearAvailable");
+	SQAIBridgeList_vYearAvailable.PreRegister(engine);
+	SQAIBridgeList_vYearAvailable.AddConstructor<void (AIBridgeList_vYearAvailable::*)(), 1>(engine, "x");
+
+	SQAIBridgeList_vYearAvailable.DefSQStaticMethod(engine, &AIBridgeList_vYearAvailable::GetClassName, "GetClassName", 1, "x");
+
+	SQAIBridgeList_vYearAvailable.PostRegister(engine);
+}