src/ai/api/ai_bridge.cpp
branchnoai
changeset 10977 6c1a6657c7db
parent 10776 07203fc29812
child 11102 aacdde10b4ad
equal deleted inserted replaced
10976:5cbf268679ae 10977:6c1a6657c7db
    36 	} else {
    36 	} else {
    37 		type |= (TRANSPORT_RAIL << 15);
    37 		type |= (TRANSPORT_RAIL << 15);
    38 		type |= (RAILTYPES_RAIL << 8);
    38 		type |= (RAILTYPES_RAIL << 8);
    39 	}
    39 	}
    40 
    40 
    41 	return AIObject::DoCommand(end, start, type | bridge_id, CMD_BUILD_BRIDGE);
    41 	if (!AIObject::DoCommand(end, start, type | bridge_id, CMD_BUILD_BRIDGE)) return false;
       
    42 	if (vehicle_type == AIVehicle::VEHICLE_RAIL) return true;
       
    43 
       
    44 	/* Build 2 road-pieces at both ends of the bridge */
       
    45 	DiagDirection dir_1 = (DiagDirection)((::TileX(start) == ::TileX(end)) ? (::TileY(start) < ::TileY(end) ? DIAGDIR_NW : DIAGDIR_SE) : (::TileX(start) < ::TileX(end) ? DIAGDIR_NE : DIAGDIR_SW));
       
    46 	DiagDirection dir_2 = ::ReverseDiagDir(dir_1);
       
    47 
       
    48 	AIObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD);
       
    49 	AIObject::DoCommand(end + ::TileOffsByDiagDir(dir_2), ::DiagDirToRoadBits(dir_1) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD);
       
    50 
       
    51 	return true;
    42 }
    52 }
    43 
    53 
    44 /* static */ bool AIBridge::RemoveBridge(TileIndex tile)
    54 /* static */ bool AIBridge::RemoveBridge(TileIndex tile)
    45 {
    55 {
    46 	EnforcePrecondition(false, IsBridgeTile(tile));
    56 	EnforcePrecondition(false, IsBridgeTile(tile));