File diff r17631:d53d44231b21 → r17632:92f095eb81a2
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -80,24 +80,30 @@ int CalcBridgeLenCostFactor(int length)
 

	
 
	length -= 2;
 
	int sum = 2;
 
	for (int delta = 1;; delta++) {
 
		for (int count = 0; count < delta; count++) {
 
			if (length == 0) return sum;
 
			sum += delta;
 
			length--;
 
		}
 
	}
 
}
 

	
 
/**
 
 * Get the foundation for a bridge.
 
 * @param tileh The slope to build the bridge on.
 
 * @param axis The axis of the bridge entrace.
 
 * @return The foundatiton required.
 
 */
 
Foundation GetBridgeFoundation(Slope tileh, Axis axis)
 
{
 
	if (tileh == SLOPE_FLAT ||
 
			((tileh == SLOPE_NE || tileh == SLOPE_SW) && axis == AXIS_X) ||
 
			((tileh == SLOPE_NW || tileh == SLOPE_SE) && axis == AXIS_Y)) return FOUNDATION_NONE;
 

	
 
	return (HasSlopeHighestCorner(tileh) ? InclinedFoundation(axis) : FlatteningFoundation(tileh));
 
}
 

	
 
/**
 
 * Determines if the track on a bridge ramp is flat or goes up/down.
 
 *
 
@@ -1199,25 +1205,28 @@ static BridgePieces CalcBridgePiece(uint
 
		return BRIDGE_PIECE_NORTH;
 
	} else if (south == 1) {
 
		return BRIDGE_PIECE_SOUTH;
 
	} else if (north < south) {
 
		return north & 1 ? BRIDGE_PIECE_INNER_SOUTH : BRIDGE_PIECE_INNER_NORTH;
 
	} else if (north > south) {
 
		return south & 1 ? BRIDGE_PIECE_INNER_NORTH : BRIDGE_PIECE_INNER_SOUTH;
 
	} else {
 
		return north & 1 ? BRIDGE_PIECE_MIDDLE_EVEN : BRIDGE_PIECE_MIDDLE_ODD;
 
	}
 
}
 

	
 

	
 
/**
 
 * Draw the middle bits of a bridge.
 
 * @param ti Tile information of the tile to draw it on.
 
 */
 
void DrawBridgeMiddle(const TileInfo *ti)
 
{
 
	/* Sectional view of bridge bounding boxes:
 
	 *
 
	 *  1           2                                1,2 = SpriteCombine of Bridge front/(back&floor) and TramCatenary
 
	 *  1           2                                  3 = empty helper BB
 
	 *  1     7     2                                4,5 = pillars under higher bridges
 
	 *  1 6 88888 6 2                                  6 = elrail-pylons
 
	 *  1 6 88888 6 2                                  7 = elrail-wire
 
	 *  1 6 88888 6 2  <- TILE_HEIGHT                  8 = rail-vehicle on bridge
 
	 *  3333333333333  <- BB_Z_SEPARATOR
 
	 *                 <- unused