Changeset - r17210:893afe086e22
[Not reviewed]
master
0 10 0
rubidium - 14 years ago 2011-02-04 15:37:23
rubidium@openttd.org
(svn r21959) -Change: replace longbridges with custom maximum bridge and tunnel length setting
10 files changed with 37 insertions and 34 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_bridge.cpp
Show inline comments
 
@@ -152,9 +152,7 @@ static void _DoCommandReturnBuildBridge1
 
{
 
	if (!IsValidBridge(bridge_id)) return -1;
 

	
 
	uint max = ::GetBridgeSpec(bridge_id)->max_length;
 
	if (max >= MAX_BRIDGE_LENGTH && _settings_game.construction.longbridges) max = MAX_BRIDGE_LENGTH_LONGBRIDGES;
 
	return max + 2;
 
	return min(::GetBridgeSpec(bridge_id)->max_length, _settings_game.construction.max_bridge_length) + 2;
 
}
 

	
 
/* static */ int32 AIBridge::GetMinLength(BridgeID bridge_id)
src/bridge.h
Show inline comments
 
@@ -43,7 +43,7 @@ typedef uint BridgeType; ///< Bridge spe
 
struct BridgeSpec {
 
	Year avail_year;             ///< the year where it becomes available
 
	byte min_length;             ///< the minimum length (not counting start and end tile)
 
	byte max_length;             ///< the maximum length (not counting start and end tile)
 
	uint16 max_length;           ///< the maximum length (not counting start and end tile)
 
	uint16 price;                ///< the price multiplier
 
	uint16 speed;                ///< maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
 
	SpriteID sprite;             ///< the sprite which is used in the GUI
 
@@ -72,7 +72,4 @@ int CalcBridgeLenCostFactor(int x);
 

	
 
void ResetBridges();
 

	
 
static const uint MAX_BRIDGE_LENGTH             =  16; ///< Maximum length of the bridge
 
static const uint MAX_BRIDGE_LENGTH_LONGBRIDGES = 100; ///< Maximum length of the bridge with longbridges enabled
 

	
 
#endif /* BRIDGE_H */
src/dock_gui.cpp
Show inline comments
 
@@ -71,7 +71,7 @@ static TileIndex GetOtherAqueductEnd(Til
 
	/* Direction the aqueduct is built to. */
 
	TileIndexDiff offset = TileOffsByDiagDir(ReverseDiagDir(dir));
 
	/* The maximum length of the aqueduct. */
 
	int max_length = min(_settings_game.construction.longbridges ? MAX_BRIDGE_LENGTH_LONGBRIDGES : MAX_BRIDGE_LENGTH, DistanceFromEdgeDir(tile_from, ReverseDiagDir(dir)) - 1);
 
	int max_length = min(_settings_game.construction.max_bridge_length, DistanceFromEdgeDir(tile_from, ReverseDiagDir(dir)) - 1);
 

	
 
	TileIndex endtile = tile_from;
 
	for (int length = 0; IsValidTile(endtile) && TileX(endtile) != 0 && TileY(endtile) != 0; length++) {
src/lang/english.txt
Show inline comments
 
@@ -1113,7 +1113,8 @@ STR_CONFIG_SETTING_IMPROVEDLOAD         
 
STR_CONFIG_SETTING_GRADUAL_LOADING                              :{LTBLUE}Load vehicles gradually: {ORANGE}{STRING1}
 
STR_CONFIG_SETTING_INFLATION                                    :{LTBLUE}Inflation: {ORANGE}{STRING1}
 
STR_CONFIG_SETTING_SELECTGOODS                                  :{LTBLUE}Deliver cargo to a station only when there is a demand: {ORANGE}{STRING1}
 
STR_CONFIG_SETTING_LONGBRIDGES                                  :{LTBLUE}Allow building very long bridges: {ORANGE}{STRING1}
 
STR_CONFIG_SETTING_MAX_BRIDGE_LENGTH                            :{LTBLUE}Maximum bridge length: {ORANGE}{STRING1} tile{P 0:1 "" s}
 
STR_CONFIG_SETTING_MAX_TUNNEL_LENGTH                            :{LTBLUE}Maximum tunnel length: {ORANGE}{STRING1} tile{P 0:1 "" s}
 
STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD             :{LTBLUE}Manual primary industry construction method: {ORANGE}{STRING1}
 
STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD_NONE        :none
 
STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD_NORMAL      :as other industries
 
@@ -3668,6 +3669,7 @@ STR_ERROR_MUST_DEMOLISH_TUNNEL_FIRST    
 
STR_ERROR_ANOTHER_TUNNEL_IN_THE_WAY                             :{WHITE}Another tunnel in the way
 
STR_ERROR_TUNNEL_THROUGH_MAP_BORDER                             :{WHITE}Tunnel would end out of the map
 
STR_ERROR_UNABLE_TO_EXCAVATE_LAND                               :{WHITE}Unable to excavate land for other end of tunnel
 
STR_ERROR_TUNNEL_TOO_LONG                                       :{WHITE}... tunnel too long
 

	
 
# Object related errors
 
STR_ERROR_TOO_MANY_OBJECTS                                      :{WHITE}... too many objects
src/newgrf.cpp
Show inline comments
 
@@ -1426,6 +1426,7 @@ static ChangeInfoResult BridgeChangeInfo
 

	
 
			case 0x0A: // Maximum length
 
				bridge->max_length = buf->ReadByte();
 
				if (bridge->max_length > 16) bridge->max_length = 0xFFFF;
 
				break;
 

	
 
			case 0x0B: // Cost factor
 
@@ -6901,7 +6902,7 @@ static void InitializeGRFSpecial()
 
	_ttdpatch_flags[0] = ((_settings_game.station.never_expire_airports ? 1 : 0) << 0x0C)  // keepsmallairport
 
	                   |                                                      (1 << 0x0D)  // newairports
 
	                   |                                                      (1 << 0x0E)  // largestations
 
	                   |      ((_settings_game.construction.longbridges ? 1 : 0) << 0x0F)  // longbridges
 
	                   | ((_settings_game.construction.max_bridge_length > 16 ? 1 : 0) << 0x0F)  // longbridges
 
	                   |                                                      (0 << 0x10)  // loadtime
 
	                   |                                                      (1 << 0x12)  // presignals
 
	                   |                                                      (1 << 0x13)  // extpresignals
src/settings_gui.cpp
Show inline comments
 
@@ -1334,7 +1334,8 @@ static SettingEntry _settings_constructi
 
	SettingEntry("construction.build_on_slopes"),
 
	SettingEntry("construction.autoslope"),
 
	SettingEntry("construction.extra_dynamite"),
 
	SettingEntry("construction.longbridges"),
 
	SettingEntry("construction.max_bridge_length"),
 
	SettingEntry("construction.max_tunnel_length"),
 
	SettingEntry("station.never_expire_airports"),
 
	SettingEntry("construction.freeform_edges"),
 
	SettingEntry("construction.extra_tree_placement"),
src/settings_type.h
Show inline comments
 
@@ -201,7 +201,8 @@ struct GameCreationSettings {
 
struct ConstructionSettings {
 
	bool   build_on_slopes;                  ///< allow building on slopes
 
	bool   autoslope;                        ///< allow terraforming under things
 
	bool   longbridges;                      ///< allow 100 tile long bridges
 
	uint16 max_bridge_length;                ///< maximum length of bridges
 
	uint16 max_tunnel_length;                ///< maximum length of tunnels
 
	bool   signal_side;                      ///< show signals on right side
 
	bool   extra_dynamite;                   ///< extra dynamite
 
	bool   road_stop_on_town_road;           ///< allow building of drive-through road stops on town owned roads
src/table/bridge_land.h
Show inline comments
 
@@ -748,49 +748,49 @@ const BridgeSpec _orig_bridge[] = {
 
	       year of availablity
 
	       |  minimum length
 
	       |  |   maximum length
 
	       |  |   |    price multiplier
 
	       |  |   |    |    maximum speed
 
	       |  |   |    |    |  sprite to use in GUI
 
	       |  |   |    |    |  |      palette in GUI
 
	       |  |   |        price multiplier
 
	       |  |   |        |    maximum speed
 
	       |  |   |        |    |  sprite to use in GUI
 
	       |  |   |        |    |  |      palette in GUI
 
	   string with description               name on rail                                         name on road
 
	   |                              |      |                                                    | */
 
	MBR(   0, 0, 16,  80,  32, 0xA24, PAL_NONE,
 
	MBR(   0, 0, 0xFFFF,  80,  32, 0xA24, PAL_NONE,
 
	   STR_BRIDGE_NAME_WOODEN,               STR_LAI_BRIDGE_DESCRIPTION_RAIL_WOODEN,              STR_LAI_BRIDGE_DESCRIPTION_ROAD_WOODEN),
 

	
 
	MBR(   0, 0,  2, 112,  48, 0xA26, PALETTE_TO_STRUCT_RED,
 
	MBR(   0, 0,      2, 112,  48, 0xA26, PALETTE_TO_STRUCT_RED,
 
	   STR_BRIDGE_NAME_CONCRETE,             STR_LAI_BRIDGE_DESCRIPTION_RAIL_CONCRETE,            STR_LAI_BRIDGE_DESCRIPTION_ROAD_CONCRETE),
 

	
 
	MBR(1930, 0,  5, 144,  64, 0xA25, PAL_NONE,
 
	MBR(1930, 0,      5, 144,  64, 0xA25, PAL_NONE,
 
	   STR_BRIDGE_NAME_GIRDER_STEEL,         STR_LAI_BRIDGE_DESCRIPTION_RAIL_GIRDER_STEELE,       STR_LAI_BRIDGE_DESCRIPTION_ROAD_GIRDER_STEEL),
 

	
 
	MBR(   0, 2, 10, 168,  80, 0xA22, PALETTE_TO_STRUCT_CONCRETE,
 
	MBR(   0, 2,     10, 168,  80, 0xA22, PALETTE_TO_STRUCT_CONCRETE,
 
	   STR_BRIDGE_NAME_SUSPENSION_CONCRETE,  STR_LAI_BRIDGE_DESCRIPTION_RAIL_SUSPENSION_CONCRETE, STR_LAI_BRIDGE_DESCRIPTION_ROAD_SUSPENSION_CONCRETE),
 

	
 
	MBR(1930, 3, 16, 185,  96, 0xA22, PAL_NONE,
 
	MBR(1930, 3, 0xFFFF, 185,  96, 0xA22, PAL_NONE,
 
	   STR_BRIDGE_NAME_SUSPENSION_STEEL,     STR_LAI_BRIDGE_DESCRIPTION_RAIL_SUSPENSION_STEEL,    STR_LAI_BRIDGE_DESCRIPTION_ROAD_SUSPENSION_STEEL),
 

	
 
	MBR(1930, 3, 16, 192, 112, 0xA22, PALETTE_TO_STRUCT_YELLOW,
 
	MBR(1930, 3, 0xFFFF, 192, 112, 0xA22, PALETTE_TO_STRUCT_YELLOW,
 
	   STR_BRIDGE_NAME_SUSPENSION_STEEL,     STR_LAI_BRIDGE_DESCRIPTION_RAIL_SUSPENSION_STEEL,    STR_LAI_BRIDGE_DESCRIPTION_ROAD_SUSPENSION_STEEL),
 

	
 
	MBR(1930, 3,  7, 224, 160, 0xA23, PAL_NONE,
 
	MBR(1930, 3,      7, 224, 160, 0xA23, PAL_NONE,
 
	   STR_BRIDGE_NAME_CANTILEVER_STEEL,     STR_LAI_BRIDGE_DESCRIPTION_RAIL_CANTILEVER_STEEL,    STR_LAI_BRIDGE_DESCRIPTION_ROAD_CANTILEVER_STEEL),
 

	
 
	MBR(1930, 3,  8, 232, 208, 0xA23, PALETTE_TO_STRUCT_BROWN,
 
	MBR(1930, 3,      8, 232, 208, 0xA23, PALETTE_TO_STRUCT_BROWN,
 
	   STR_BRIDGE_NAME_CANTILEVER_STEEL,     STR_LAI_BRIDGE_DESCRIPTION_RAIL_CANTILEVER_STEEL,    STR_LAI_BRIDGE_DESCRIPTION_ROAD_CANTILEVER_STEEL),
 

	
 
	MBR(1930, 3,  9, 248, 240, 0xA23, PALETTE_TO_STRUCT_RED,
 
	MBR(1930, 3,      9, 248, 240, 0xA23, PALETTE_TO_STRUCT_RED,
 
	   STR_BRIDGE_NAME_CANTILEVER_STEEL,     STR_LAI_BRIDGE_DESCRIPTION_RAIL_CANTILEVER_STEEL,    STR_LAI_BRIDGE_DESCRIPTION_ROAD_CANTILEVER_STEEL),
 

	
 
	MBR(1930, 0,  2, 240, 256, 0xA27, PAL_NONE,
 
	MBR(1930, 0,      2, 240, 256, 0xA27, PAL_NONE,
 
	   STR_BRIDGE_NAME_GIRDER_STEEL,         STR_LAI_BRIDGE_DESCRIPTION_RAIL_GIRDER_STEELE,       STR_LAI_BRIDGE_DESCRIPTION_ROAD_GIRDER_STEEL),
 

	
 
	MBR(1995, 2, 16, 255, 320, 0xA28, PAL_NONE,
 
	MBR(1995, 2, 0xFFFF, 255, 320, 0xA28, PAL_NONE,
 
	   STR_BRIDGE_NAME_TUBULAR_STEEL,        STR_LAI_BRIDGE_DESCRIPTION_RAIL_TUBULAR_STEEL,       STR_LAI_BRIDGE_DESCRIPTION_ROAD_TUBULAR_STEEL),
 

	
 
	MBR(2005, 2, 32, 380, 512, 0xA28, PALETTE_TO_STRUCT_YELLOW,
 
	MBR(2005, 2, 0xFFFF, 380, 512, 0xA28, PALETTE_TO_STRUCT_YELLOW,
 
	   STR_BRIDGE_NAME_TUBULAR_STEEL,        STR_LAI_BRIDGE_DESCRIPTION_RAIL_TUBULAR_STEEL,       STR_LAI_BRIDGE_DESCRIPTION_ROAD_TUBULAR_STEEL),
 

	
 
	MBR(2010, 2, 32, 510, 608, 0xA28, PALETTE_TO_STRUCT_GREY,
 
	MBR(2010, 2, 0xFFFF, 510, 608, 0xA28, PALETTE_TO_STRUCT_GREY,
 
	   STR_BRIDGE_TUBULAR_SILICON,           STR_LAI_BRIDGE_DESCRIPTION_RAIL_TUBULAR_STEEL,       STR_LAI_BRIDGE_DESCRIPTION_ROAD_TUBULAR_STEEL)
 
};
 

	
src/table/settings.h
Show inline comments
 
@@ -378,7 +378,9 @@ const SettingDesc _settings[] = {
 
	 SDT_CONDVAR(GameSettings, construction.clear_frame_burst,      SLE_UINT16,156, SL_MAX_VERSION, 0, 0, 4096,     0,  1 << 30, 1, STR_NULL, NULL),
 
	SDT_CONDBOOL(GameSettings, construction.autoslope,                          75, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_SETTING_AUTOSLOPE,              NULL),
 
	    SDT_BOOL(GameSettings, construction.extra_dynamite,                                         0, 0,  true,                    STR_CONFIG_SETTING_EXTRADYNAMITE,          NULL),
 
	    SDT_BOOL(GameSettings, construction.longbridges,                                            0,NN,  true,                    STR_CONFIG_SETTING_LONGBRIDGES,            NULL),
 
	 SDT_CONDVAR(GameSettings, construction.max_bridge_length,      SLE_UINT16,159, SL_MAX_VERSION, 0,NN,    64,    1,     2048, 1, STR_CONFIG_SETTING_MAX_BRIDGE_LENGTH,      NULL),
 
	 SDT_CONDVAR(GameSettings, construction.max_tunnel_length,      SLE_UINT16,159, SL_MAX_VERSION, 0,NN,    64,    1,     2048, 1, STR_CONFIG_SETTING_MAX_TUNNEL_LENGTH,      NULL),
 
	SDT_CONDNULL(                                                            1,  0, 158), // construction.longbridges
 
	    SDT_BOOL(GameSettings, construction.signal_side,                                            N,NN,  true,                    STR_CONFIG_SETTING_SIGNALSIDE,             RedrawScreen),
 
	    SDT_BOOL(GameSettings, station.never_expire_airports,                                       0,NN, false,                    STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS,  NULL),
 
	 SDT_CONDVAR(GameSettings, economy.town_layout,                  SLE_UINT8, 59, SL_MAX_VERSION, 0,MS,TL_ORIGINAL,TL_BEGIN,NUM_TLS - 1, 1, STR_CONFIG_SETTING_TOWN_LAYOUT,  TownFoundingChanged),
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -175,7 +175,7 @@ static CommandCost CheckBridgeSlopeSouth
 
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags)
 
{
 
	if (flags & DC_QUERY_COST) {
 
		if (bridge_len <= (_settings_game.construction.longbridges ? MAX_BRIDGE_LENGTH_LONGBRIDGES : MAX_BRIDGE_LENGTH)) return CommandCost();
 
		if (bridge_len <= _settings_game.construction.max_bridge_length) return CommandCost();
 
		return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
 
	}
 

	
 
@@ -184,8 +184,7 @@ CommandCost CheckBridgeAvailability(Brid
 
	const BridgeSpec *b = GetBridgeSpec(bridge_type);
 
	if (b->avail_year > _cur_year) return CMD_ERROR;
 

	
 
	uint max = b->max_length;
 
	if (max >= MAX_BRIDGE_LENGTH && _settings_game.construction.longbridges) max = MAX_BRIDGE_LENGTH_LONGBRIDGES;
 
	uint max = min(b->max_length, _settings_game.construction.max_bridge_length);
 

	
 
	if (b->min_length > bridge_len) return CMD_ERROR;
 
	if (bridge_len <= max) return CommandCost();
 
@@ -259,7 +258,7 @@ CommandCost CmdBuildBridge(TileIndex end
 
		CommandCost ret = CheckBridgeAvailability(bridge_type, bridge_len, flags);
 
		if (ret.Failed()) return ret;
 
	} else {
 
		if (bridge_len > (_settings_game.construction.longbridges ? MAX_BRIDGE_LENGTH_LONGBRIDGES : MAX_BRIDGE_LENGTH)) return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
 
		if (bridge_len > _settings_game.construction.max_bridge_length) return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
 
	}
 

	
 
	uint z_start;
 
@@ -583,6 +582,8 @@ CommandCost CmdBuildTunnel(TileIndex sta
 
	/* if the command fails from here on we want the end tile to be highlighted */
 
	_build_tunnel_endtile = end_tile;
 

	
 
	if (tiles > _settings_game.construction.max_tunnel_length) return_cmd_error(STR_ERROR_TUNNEL_TOO_LONG);
 

	
 
	if (HasTileWaterGround(end_tile)) return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER);
 

	
 
	/* Clear the tile in any case */
0 comments (0 inline, 0 general)