Merge branch 'master' into jgrpp
# Conflicts: # src/aircraft_cmd.cpp # src/autoreplace_cmd.cpp # src/pathfinder/follow_track.hpp # src/pathfinder/yapf/yapf_rail.cpp # src/saveload/afterload.cpp # src/saveload/saveload.cpp # src/script/api/ai/ai_station.hpp.sq # src/script/api/game/game_station.hpp.sq # src/script/api/script_station.hpp # src/track_func.h # src/vehicle_base.h
This commit is contained in:
@@ -213,40 +213,27 @@ static inline const PalSpriteID *GetBridgeSpriteTable(int index, BridgePieces ta
|
||||
|
||||
|
||||
/**
|
||||
* Determines the foundation for the north bridge head, and tests if the resulting slope is valid.
|
||||
* Determines the foundation for the bridge head, and tests if the resulting slope is valid.
|
||||
*
|
||||
* @param bridge_piece Direction of the bridge head.
|
||||
* @param axis Axis of the bridge
|
||||
* @param tileh Slope of the tile under the north bridge head; returns slope on top of foundation
|
||||
* @param z TileZ corresponding to tileh, gets modified as well
|
||||
* @return Error or cost for bridge foundation
|
||||
*/
|
||||
static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope *tileh, int *z)
|
||||
static CommandCost CheckBridgeSlope(BridgePieces bridge_piece, Axis axis, Slope *tileh, int *z)
|
||||
{
|
||||
assert(bridge_piece == BRIDGE_PIECE_NORTH || bridge_piece == BRIDGE_PIECE_SOUTH);
|
||||
|
||||
Foundation f = GetBridgeFoundation(*tileh, axis);
|
||||
*z += ApplyFoundationToSlope(f, tileh);
|
||||
|
||||
Slope valid_inclined = (axis == AXIS_X ? SLOPE_NE : SLOPE_NW);
|
||||
if ((*tileh != SLOPE_FLAT) && (*tileh != valid_inclined)) return CMD_ERROR;
|
||||
|
||||
if (f == FOUNDATION_NONE) return CommandCost();
|
||||
|
||||
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the foundation for the south bridge head, and tests if the resulting slope is valid.
|
||||
*
|
||||
* @param axis Axis of the bridge
|
||||
* @param tileh Slope of the tile under the south bridge head; returns slope on top of foundation
|
||||
* @param z TileZ corresponding to tileh, gets modified as well
|
||||
* @return Error or cost for bridge foundation
|
||||
*/
|
||||
static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, int *z)
|
||||
{
|
||||
Foundation f = GetBridgeFoundation(*tileh, axis);
|
||||
*z += ApplyFoundationToSlope(f, tileh);
|
||||
|
||||
Slope valid_inclined = (axis == AXIS_X ? SLOPE_SW : SLOPE_SE);
|
||||
Slope valid_inclined;
|
||||
if (bridge_piece == BRIDGE_PIECE_NORTH) {
|
||||
valid_inclined = (axis == AXIS_X ? SLOPE_NE : SLOPE_NW);
|
||||
} else {
|
||||
valid_inclined = (axis == AXIS_X ? SLOPE_SW : SLOPE_SE);
|
||||
}
|
||||
if ((*tileh != SLOPE_FLAT) && (*tileh != valid_inclined)) return CMD_ERROR;
|
||||
|
||||
if (f == FOUNDATION_NONE) return CommandCost();
|
||||
@@ -258,6 +245,7 @@ static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, int *z)
|
||||
* Is a bridge of the specified type and length available?
|
||||
* @param bridge_type Wanted type of bridge.
|
||||
* @param bridge_len Wanted length of the bridge.
|
||||
* @param flags Type of operation.
|
||||
* @return A succeeded (the requested bridge is available) or failed (it cannot be built) command.
|
||||
*/
|
||||
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags)
|
||||
@@ -368,8 +356,8 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
Slope tileh_start = GetTileSlope(tile_start, &z_start);
|
||||
Slope tileh_end = GetTileSlope(tile_end, &z_end);
|
||||
|
||||
CommandCost terraform_cost_north = CheckBridgeSlopeNorth(direction, &tileh_start, &z_start);
|
||||
CommandCost terraform_cost_south = CheckBridgeSlopeSouth(direction, &tileh_end, &z_end);
|
||||
CommandCost terraform_cost_north = CheckBridgeSlope(BRIDGE_PIECE_NORTH, direction, &tileh_start, &z_start);
|
||||
CommandCost terraform_cost_south = CheckBridgeSlope(BRIDGE_PIECE_SOUTH, direction, &tileh_end, &z_end);
|
||||
|
||||
/* Aqueducts can't be built of flat land. */
|
||||
if (transport_type == TRANSPORT_WATER && (tileh_start == SLOPE_FLAT || tileh_end == SLOPE_FLAT)) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||
@@ -2513,11 +2501,11 @@ static CommandCost TerraformTile_TunnelBridge(TileIndex tile, DoCommandFlag flag
|
||||
|
||||
/* Check if new slope is valid for bridges in general (so we can safely call GetBridgeFoundation()) */
|
||||
if ((direction == DIAGDIR_NW) || (direction == DIAGDIR_NE)) {
|
||||
CheckBridgeSlopeSouth(axis, &tileh_old, &z_old);
|
||||
res = CheckBridgeSlopeSouth(axis, &tileh_new, &z_new);
|
||||
CheckBridgeSlope(BRIDGE_PIECE_SOUTH, axis, &tileh_old, &z_old);
|
||||
res = CheckBridgeSlope(BRIDGE_PIECE_SOUTH, axis, &tileh_new, &z_new);
|
||||
} else {
|
||||
CheckBridgeSlopeNorth(axis, &tileh_old, &z_old);
|
||||
res = CheckBridgeSlopeNorth(axis, &tileh_new, &z_new);
|
||||
CheckBridgeSlope(BRIDGE_PIECE_NORTH, axis, &tileh_old, &z_old);
|
||||
res = CheckBridgeSlope(BRIDGE_PIECE_NORTH, axis, &tileh_new, &z_new);
|
||||
}
|
||||
|
||||
/* Surface slope is valid and remains unchanged? */
|
||||
|
Reference in New Issue
Block a user