src/ai/api/ai_tunnel.cpp
branchnoai
changeset 10088 922c6e6a8d3e
parent 9833 89a64246458f
child 10249 58810805030e
equal deleted inserted replaced
10087:0cb23b9abbf7 10088:922c6e6a8d3e
    26 	return _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile;
    26 	return _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile;
    27 }
    27 }
    28 
    28 
    29 /* static */ bool AITunnel::BuildTunnel(AIVehicle::VehicleType vehicle_type, TileIndex start)
    29 /* static */ bool AITunnel::BuildTunnel(AIVehicle::VehicleType vehicle_type, TileIndex start)
    30 {
    30 {
    31 	if (!::IsValidTile(start)) return false;
    31 	EnforcePrecondition(false, ::IsValidTile(start));
    32 	if (vehicle_type != AIVehicle::VEHICLE_RAIL && vehicle_type != AIVehicle::VEHICLE_ROAD) return false;
    32 	EnforcePrecondition(false, vehicle_type == AIVehicle::VEHICLE_RAIL || vehicle_type == AIVehicle::VEHICLE_ROAD);
    33 
    33 
    34 	uint type = 0;
    34 	uint type = 0;
    35 	if (vehicle_type == AIVehicle::VEHICLE_ROAD) {
    35 	if (vehicle_type == AIVehicle::VEHICLE_ROAD) {
    36 		type |= (TRANSPORT_ROAD << 9);
    36 		type |= (TRANSPORT_ROAD << 9);
    37 		type |= ROADTYPES_ROAD;
    37 		type |= ROADTYPES_ROAD;
    43 	return AIObject::DoCommand(start, type, 0, CMD_BUILD_TUNNEL);
    43 	return AIObject::DoCommand(start, type, 0, CMD_BUILD_TUNNEL);
    44 }
    44 }
    45 
    45 
    46 /* static */ bool AITunnel::RemoveTunnel(TileIndex tile)
    46 /* static */ bool AITunnel::RemoveTunnel(TileIndex tile)
    47 {
    47 {
    48 	if (!IsTunnelTile(tile)) return false;
    48 	EnforcePrecondition(false, IsTunnelTile(tile));
    49 
    49 
    50 	return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
    50 	return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
    51 }
    51 }