Changeset - r14944:29599fab3827
[Not reviewed]
master
0 4 0
alberth - 15 years ago 2010-04-04 14:22:55
alberth@openttd.org
(svn r19561) -Feature: Give more detailed error message when trying to build a too long bridge.
4 files changed with 16 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/bridge.h
Show inline comments
 
@@ -67,7 +67,7 @@ static inline const BridgeSpec *GetBridg
 

	
 
void DrawBridgeMiddle(const TileInfo *ti);
 

	
 
bool CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE);
 
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE);
 
int CalcBridgeLenCostFactor(int x);
 

	
 
void ResetBridges();
src/bridge_gui.cpp
Show inline comments
 
@@ -375,7 +375,7 @@ void ShowBuildBridgeWindow(TileIndex sta
 
		case TRANSPORT_RAIL: last_bridge_type = _last_railbridge_type; break;
 
		default: break; // water ways and air routes don't have bridge types
 
	}
 
	if (_ctrl_pressed && CheckBridgeAvailability(last_bridge_type, bridge_len)) {
 
	if (_ctrl_pressed && CheckBridgeAvailability(last_bridge_type, bridge_len).Succeeded()) {
 
		DoCommandP(end, start, type | last_bridge_type, CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge);
 
		return;
 
	}
 
@@ -396,7 +396,7 @@ void ShowBuildBridgeWindow(TileIndex sta
 

	
 
		/* loop for all bridgetypes */
 
		for (BridgeType brd_type = 0; brd_type != MAX_BRIDGES; brd_type++) {
 
			if (CheckBridgeAvailability(brd_type, bridge_len)) {
 
			if (CheckBridgeAvailability(brd_type, bridge_len).Succeeded()) {
 
				/* bridge is accepted, add to list */
 
				BuildBridgeData *item = bl->Append();
 
				item->index = brd_type;
src/lang/english.txt
Show inline comments
 
@@ -3539,6 +3539,7 @@ STR_ERROR_BRIDGEHEADS_NOT_SAME_HEIGHT   
 
STR_ERROR_BRIDGE_TOO_LOW_FOR_TERRAIN                            :{WHITE}Bridge is too low for the terrain
 
STR_ERROR_START_AND_END_MUST_BE_IN                              :{WHITE}Start and end must be in line
 
STR_ERROR_ENDS_OF_BRIDGE_MUST_BOTH                              :{WHITE}... ends of bridge must both be on land
 
STR_ERROR_BRIDGE_TOO_LONG                                       :{WHITE}... bridge too long
 

	
 
# Tunnel related errors
 
STR_ERROR_CAN_T_BUILD_TUNNEL_HERE                               :{WHITE}Can't build tunnel here...
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -166,23 +166,26 @@ static CommandCost CheckBridgeSlopeSouth
 
/** 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.
 
 * @return The requested bridge is available.
 
 * @return A succeeded (the requested bridge is available) or failed (it cannot be built) command.
 
 */
 
bool CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags)
 
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags)
 
{
 
	if (flags & DC_QUERY_COST) {
 
		return bridge_len <= (_settings_game.construction.longbridges ? 100U : 16U);
 
		if (bridge_len <= (_settings_game.construction.longbridges ? 100U : 16U)) return CommandCost();
 
		return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
 
	}
 

	
 
	if (bridge_type >= MAX_BRIDGES) return false;
 
	if (bridge_type >= MAX_BRIDGES) return CMD_ERROR;
 

	
 
	const BridgeSpec *b = GetBridgeSpec(bridge_type);
 
	if (b->avail_year > _cur_year) return false;
 
	if (b->avail_year > _cur_year) return CMD_ERROR;
 

	
 
	uint max = b->max_length;
 
	if (max >= 16 && _settings_game.construction.longbridges) max = 100;
 

	
 
	return b->min_length <= bridge_len && bridge_len <= max;
 
	if (b->min_length > bridge_len) return CMD_ERROR;
 
	if (bridge_len <= max) return CommandCost();
 
	return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
 
}
 

	
 
/** Build a Bridge
 
@@ -248,9 +251,10 @@ CommandCost CmdBuildBridge(TileIndex end
 
	uint bridge_len = GetTunnelBridgeLength(tile_start, tile_end);
 
	if (transport_type != TRANSPORT_WATER) {
 
		/* set and test bridge length, availability */
 
		if (!CheckBridgeAvailability(bridge_type, bridge_len, flags)) return CMD_ERROR;
 
		CommandCost ret = CheckBridgeAvailability(bridge_type, bridge_len, flags);
 
		if (ret.Failed()) return ret;
 
	} else {
 
		if (bridge_len > (_settings_game.construction.longbridges ? 100U : 16U)) return CMD_ERROR;
 
		if (bridge_len > (_settings_game.construction.longbridges ? 100U : 16U)) return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
 
	}
 

	
 
	/* retrieve landscape height and ensure it's on land */
0 comments (0 inline, 0 general)