mirror of https://github.com/OpenTTD/OpenTTD
(svn r15875) -Add: AIBridge::GetBridgeID() so AIs can get the type of bridge that are already build.
parent
e02d31cd3a
commit
400208ee0a
|
@ -256,12 +256,15 @@ function Regression::Bridge()
|
||||||
print(" Valid Bridges: " + j);
|
print(" Valid Bridges: " + j);
|
||||||
|
|
||||||
print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33160));
|
print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33160));
|
||||||
|
print(" GetBridgeID(): " + AIBridge.GetBridgeID(33160));
|
||||||
print(" RemoveBridge(): " + AIBridge.RemoveBridge(33155));
|
print(" RemoveBridge(): " + AIBridge.RemoveBridge(33155));
|
||||||
print(" GetLastErrorString(): " + AIError.GetLastErrorString());
|
print(" GetLastErrorString(): " + AIError.GetLastErrorString());
|
||||||
print(" GetOtherBridgeEnd(): " + AIBridge.GetOtherBridgeEnd(33160));
|
print(" GetOtherBridgeEnd(): " + AIBridge.GetOtherBridgeEnd(33160));
|
||||||
print(" BuildBridge(): " + AIBridge.BuildBridge(AIVehicle.VT_ROAD, 5, 33160, 33155));
|
print(" BuildBridge(): " + AIBridge.BuildBridge(AIVehicle.VT_ROAD, 5, 33160, 33155));
|
||||||
print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33160));
|
print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33160));
|
||||||
|
print(" GetBridgeID(): " + AIBridge.GetBridgeID(33160));
|
||||||
print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33155));
|
print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33155));
|
||||||
|
print(" GetBridgeID(): " + AIBridge.GetBridgeID(33155));
|
||||||
print(" GetOtherBridgeEnd(): " + AIBridge.GetOtherBridgeEnd(33160));
|
print(" GetOtherBridgeEnd(): " + AIBridge.GetOtherBridgeEnd(33160));
|
||||||
print(" BuildBridge(): " + AIBridge.BuildBridge(AIVehicle.VT_ROAD, 5, 33160, 33155));
|
print(" BuildBridge(): " + AIBridge.BuildBridge(AIVehicle.VT_ROAD, 5, 33160, 33155));
|
||||||
print(" GetLastErrorString(): " + AIError.GetLastErrorString());
|
print(" GetLastErrorString(): " + AIError.GetLastErrorString());
|
||||||
|
|
|
@ -743,12 +743,15 @@
|
||||||
GetMinLength(): -1
|
GetMinLength(): -1
|
||||||
Valid Bridges: 10
|
Valid Bridges: 10
|
||||||
IsBridgeTile(): false
|
IsBridgeTile(): false
|
||||||
|
GetBridgeID(): -1
|
||||||
RemoveBridge(): false
|
RemoveBridge(): false
|
||||||
GetLastErrorString(): ERR_PRECONDITION_FAILED
|
GetLastErrorString(): ERR_PRECONDITION_FAILED
|
||||||
GetOtherBridgeEnd(): -1
|
GetOtherBridgeEnd(): -1
|
||||||
BuildBridge(): true
|
BuildBridge(): true
|
||||||
IsBridgeTile(): true
|
IsBridgeTile(): true
|
||||||
|
GetBridgeID(): 5
|
||||||
IsBridgeTile(): true
|
IsBridgeTile(): true
|
||||||
|
GetBridgeID(): 5
|
||||||
GetOtherBridgeEnd(): 33155
|
GetOtherBridgeEnd(): 33155
|
||||||
BuildBridge(): false
|
BuildBridge(): false
|
||||||
GetLastErrorString(): ERR_ALREADY_BUILT
|
GetLastErrorString(): ERR_ALREADY_BUILT
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
return ::IsBridgeTile(tile);
|
return ::IsBridgeTile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ BridgeID AIBridge::GetBridgeID(TileIndex tile)
|
||||||
|
{
|
||||||
|
if (!IsBridgeTile(tile)) return -1;
|
||||||
|
return (BridgeID)::GetBridgeType(tile);
|
||||||
|
}
|
||||||
|
|
||||||
static void _DoCommandReturnBuildBridge2(class AIInstance *instance)
|
static void _DoCommandReturnBuildBridge2(class AIInstance *instance)
|
||||||
{
|
{
|
||||||
if (!AIBridge::_BuildBridgeRoad2()) {
|
if (!AIBridge::_BuildBridgeRoad2()) {
|
||||||
|
|
|
@ -51,6 +51,14 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool IsBridgeTile(TileIndex tile);
|
static bool IsBridgeTile(TileIndex tile);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the BridgeID of a bridge at a given tile.
|
||||||
|
* @param tile The tile to get the BridgeID from.
|
||||||
|
* @pre IsBridgeTile(tile).
|
||||||
|
* @return The BridgeID from the bridge at tile 'tile'.
|
||||||
|
*/
|
||||||
|
static BridgeID GetBridgeID(TileIndex tile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of a bridge.
|
* Get the name of a bridge.
|
||||||
* @param bridge_id The bridge to get the name of.
|
* @param bridge_id The bridge to get the name of.
|
||||||
|
|
|
@ -36,6 +36,7 @@ void SQAIBridge_Register(Squirrel *engine) {
|
||||||
|
|
||||||
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::IsValidBridge, "IsValidBridge", 2, ".i");
|
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::IsValidBridge, "IsValidBridge", 2, ".i");
|
||||||
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::IsBridgeTile, "IsBridgeTile", 2, ".i");
|
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::IsBridgeTile, "IsBridgeTile", 2, ".i");
|
||||||
|
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetBridgeID, "GetBridgeID", 2, ".i");
|
||||||
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetName, "GetName", 2, ".i");
|
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetName, "GetName", 2, ".i");
|
||||||
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetMaxSpeed, "GetMaxSpeed", 2, ".i");
|
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetMaxSpeed, "GetMaxSpeed", 2, ".i");
|
||||||
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetPrice, "GetPrice", 3, ".ii");
|
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetPrice, "GetPrice", 3, ".ii");
|
||||||
|
|
Loading…
Reference in New Issue