(svn r16244) -Fix [NoAI]: Make sure AITunnel::BuildTunnel returns what the documentation says it does

This commit is contained in:
yexo 2009-05-06 21:40:51 +00:00
parent eb162ef55d
commit cac5b8bf79

View File

@ -43,7 +43,6 @@
static void _DoCommandReturnBuildTunnel2(class AIInstance *instance) static void _DoCommandReturnBuildTunnel2(class AIInstance *instance)
{ {
if (!AITunnel::_BuildTunnelRoad2()) { if (!AITunnel::_BuildTunnelRoad2()) {
AIObject::SetLastCommandRes(false);
AIInstance::DoCommandReturn(instance); AIInstance::DoCommandReturn(instance);
return; return;
} }
@ -56,7 +55,6 @@ static void _DoCommandReturnBuildTunnel2(class AIInstance *instance)
static void _DoCommandReturnBuildTunnel1(class AIInstance *instance) static void _DoCommandReturnBuildTunnel1(class AIInstance *instance)
{ {
if (!AITunnel::_BuildTunnelRoad1()) { if (!AITunnel::_BuildTunnelRoad1()) {
AIObject::SetLastCommandRes(false);
AIInstance::DoCommandReturn(instance); AIInstance::DoCommandReturn(instance);
return; return;
} }
@ -75,7 +73,7 @@ static void _DoCommandReturnBuildTunnel1(class AIInstance *instance)
uint type = 0; uint type = 0;
if (vehicle_type == AIVehicle::VT_ROAD) { if (vehicle_type == AIVehicle::VT_ROAD) {
type |= (TRANSPORT_ROAD << 9); type |= (TRANSPORT_ROAD << 9);
type |= RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType()); type |= ::RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType());
} else { } else {
type |= (TRANSPORT_RAIL << 9); type |= (TRANSPORT_RAIL << 9);
type |= AIRail::GetCurrentRailType(); type |= AIRail::GetCurrentRailType();
@ -87,10 +85,7 @@ static void _DoCommandReturnBuildTunnel1(class AIInstance *instance)
} }
AIObject::SetCallbackVariable(0, start); AIObject::SetCallbackVariable(0, start);
if (!AIObject::DoCommand(start, type, 0, CMD_BUILD_TUNNEL, NULL, &_DoCommandReturnBuildTunnel1)) return false; return AIObject::DoCommand(start, type, 0, CMD_BUILD_TUNNEL, NULL, &_DoCommandReturnBuildTunnel1);
/* In case of test-mode, test if we can build both road pieces */
return _BuildTunnelRoad1();
} }
/* static */ bool AITunnel::_BuildTunnelRoad1() /* static */ bool AITunnel::_BuildTunnelRoad1()
@ -102,10 +97,7 @@ static void _DoCommandReturnBuildTunnel1(class AIInstance *instance)
DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start); DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start);
DiagDirection dir_2 = ::ReverseDiagDir(dir_1); 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; return AIObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD, NULL, &_DoCommandReturnBuildTunnel2);
/* In case of test-mode, test the other road piece too */
return _BuildTunnelRoad2();
} }
/* static */ bool AITunnel::_BuildTunnelRoad2() /* static */ bool AITunnel::_BuildTunnelRoad2()