From cac5b8bf79c791c890337305f7eb269ef029fcb7 Mon Sep 17 00:00:00 2001 From: yexo Date: Wed, 6 May 2009 21:40:51 +0000 Subject: [PATCH] (svn r16244) -Fix [NoAI]: Make sure AITunnel::BuildTunnel returns what the documentation says it does --- src/ai/api/ai_tunnel.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/ai/api/ai_tunnel.cpp b/src/ai/api/ai_tunnel.cpp index ea103ce4ef..37877f1c91 100644 --- a/src/ai/api/ai_tunnel.cpp +++ b/src/ai/api/ai_tunnel.cpp @@ -43,7 +43,6 @@ static void _DoCommandReturnBuildTunnel2(class AIInstance *instance) { if (!AITunnel::_BuildTunnelRoad2()) { - AIObject::SetLastCommandRes(false); AIInstance::DoCommandReturn(instance); return; } @@ -56,7 +55,6 @@ static void _DoCommandReturnBuildTunnel2(class AIInstance *instance) static void _DoCommandReturnBuildTunnel1(class AIInstance *instance) { if (!AITunnel::_BuildTunnelRoad1()) { - AIObject::SetLastCommandRes(false); AIInstance::DoCommandReturn(instance); return; } @@ -75,7 +73,7 @@ static void _DoCommandReturnBuildTunnel1(class AIInstance *instance) uint type = 0; if (vehicle_type == AIVehicle::VT_ROAD) { type |= (TRANSPORT_ROAD << 9); - type |= RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType()); + type |= ::RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType()); } else { type |= (TRANSPORT_RAIL << 9); type |= AIRail::GetCurrentRailType(); @@ -87,10 +85,7 @@ static void _DoCommandReturnBuildTunnel1(class AIInstance *instance) } AIObject::SetCallbackVariable(0, start); - if (!AIObject::DoCommand(start, type, 0, CMD_BUILD_TUNNEL, NULL, &_DoCommandReturnBuildTunnel1)) return false; - - /* In case of test-mode, test if we can build both road pieces */ - return _BuildTunnelRoad1(); + return AIObject::DoCommand(start, type, 0, CMD_BUILD_TUNNEL, NULL, &_DoCommandReturnBuildTunnel1); } /* static */ bool AITunnel::_BuildTunnelRoad1() @@ -102,10 +97,7 @@ static void _DoCommandReturnBuildTunnel1(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, &_DoCommandReturnBuildTunnel2)) return false; - - /* In case of test-mode, test the other road piece too */ - return _BuildTunnelRoad2(); + return AIObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD, NULL, &_DoCommandReturnBuildTunnel2); } /* static */ bool AITunnel::_BuildTunnelRoad2()