summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-06-05 17:36:39 +0000
committeryexo <yexo@openttd.org>2009-06-05 17:36:39 +0000
commitad5f01819598ccf787d5f146d49dbccf16d6f947 (patch)
treeb7599c4866e1108f14eeba2dc84aff6ee81933be /src/ai
parentec5db12adc1825a144b6f39e9290076414d4acd6 (diff)
downloadopenttd-ad5f01819598ccf787d5f146d49dbccf16d6f947.tar.xz
(svn r16520) -Fix [NoAI]: Make sure AIBridge::BuildBridge returns what the documentation says it does (r16244 for AIBridge)
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/api/ai_bridge.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/ai/api/ai_bridge.cpp b/src/ai/api/ai_bridge.cpp
index 5f28ff51c..916fd6d7a 100644
--- a/src/ai/api/ai_bridge.cpp
+++ b/src/ai/api/ai_bridge.cpp
@@ -32,7 +32,6 @@
static void _DoCommandReturnBuildBridge2(class AIInstance *instance)
{
if (!AIBridge::_BuildBridgeRoad2()) {
- AIObject::SetLastCommandRes(false);
AIInstance::DoCommandReturn(instance);
return;
}
@@ -45,7 +44,6 @@ static void _DoCommandReturnBuildBridge2(class AIInstance *instance)
static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
{
if (!AIBridge::_BuildBridgeRoad1()) {
- AIObject::SetLastCommandRes(false);
AIInstance::DoCommandReturn(instance);
return;
}
@@ -67,7 +65,7 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
switch (vehicle_type) {
case AIVehicle::VT_ROAD:
type |= (TRANSPORT_ROAD << 15);
- type |= (RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType()) << 8);
+ type |= (::RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType()) << 8);
break;
case AIVehicle::VT_RAIL:
type |= (TRANSPORT_RAIL << 15);
@@ -86,10 +84,7 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
AIObject::SetCallbackVariable(0, start);
AIObject::SetCallbackVariable(1, end);
- if (!AIObject::DoCommand(end, start, type | bridge_id, CMD_BUILD_BRIDGE, NULL, &_DoCommandReturnBuildBridge1)) return false;
-
- /* In case of test-mode, test if we can build both road pieces */
- return _BuildBridgeRoad1();
+ return AIObject::DoCommand(end, start, type | bridge_id, CMD_BUILD_BRIDGE, NULL, &_DoCommandReturnBuildBridge1);
}
/* static */ bool AIBridge::_BuildBridgeRoad1()
@@ -101,10 +96,7 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start);
DiagDirection dir_2 = ::ReverseDiagDir(dir_1);
- if (!AIObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD, NULL, &_DoCommandReturnBuildBridge2)) return false;
-
- /* In case of test-mode, test the other road piece too */
- return _BuildBridgeRoad2();
+ return AIObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD, NULL, &_DoCommandReturnBuildBridge2);
}
/* static */ bool AIBridge::_BuildBridgeRoad2()