summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-02-04 15:37:23 +0000
committerrubidium <rubidium@openttd.org>2011-02-04 15:37:23 +0000
commit46b3d114a828916226d66ec7536af9f62948759a (patch)
treeb85595b42c2c58187284ee89452b8e71709ceeae
parent4355231f677b2ad779daaab701444c5b003cdaed (diff)
downloadopenttd-46b3d114a828916226d66ec7536af9f62948759a.tar.xz
(svn r21959) -Change: replace longbridges with custom maximum bridge and tunnel length setting
-rw-r--r--src/ai/api/ai_bridge.cpp4
-rw-r--r--src/bridge.h5
-rw-r--r--src/dock_gui.cpp2
-rw-r--r--src/lang/english.txt4
-rw-r--r--src/newgrf.cpp3
-rw-r--r--src/settings_gui.cpp3
-rw-r--r--src/settings_type.h3
-rw-r--r--src/table/bridge_land.h34
-rw-r--r--src/table/settings.h4
-rw-r--r--src/tunnelbridge_cmd.cpp9
10 files changed, 37 insertions, 34 deletions
diff --git a/src/ai/api/ai_bridge.cpp b/src/ai/api/ai_bridge.cpp
index ab2156737..a051e85a2 100644
--- a/src/ai/api/ai_bridge.cpp
+++ b/src/ai/api/ai_bridge.cpp
@@ -152,9 +152,7 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
{
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)
diff --git a/src/bridge.h b/src/bridge.h
index 69462e450..521c3f128 100644
--- a/src/bridge.h
+++ b/src/bridge.h
@@ -43,7 +43,7 @@ typedef uint BridgeType; ///< Bridge spec number.
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 */
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 833fa5899..8e667ec3c 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -71,7 +71,7 @@ static TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to = N
/* 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++) {
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 4aa37d747..215d699f1 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1113,7 +1113,8 @@ STR_CONFIG_SETTING_IMPROVEDLOAD :{LTBLUE}Use imp
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 :{WHITE}Must dem
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
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 68ed5ca1b..ed1d08d1b 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1426,6 +1426,7 @@ static ChangeInfoResult BridgeChangeInfo(uint brid, int numinfo, int prop, ByteR
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
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index aafefc2c9..f89614e0a 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1334,7 +1334,8 @@ static SettingEntry _settings_construction[] = {
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"),
diff --git a/src/settings_type.h b/src/settings_type.h
index 7629d83a4..cf89662f5 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -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
diff --git a/src/table/bridge_land.h b/src/table/bridge_land.h
index d1c6fefc5..9bc0738d5 100644
--- a/src/table/bridge_land.h
+++ b/src/table/bridge_land.h
@@ -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)
};
diff --git a/src/table/settings.h b/src/table/settings.h
index 594082f4a..07ff7ca8e 100644
--- a/src/table/settings.h
+++ b/src/table/settings.h
@@ -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),
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 9c1bb6ca9..e27d62e17 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -175,7 +175,7 @@ static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, uint *z)
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(BridgeType bridge_type, uint bridge_len, DoC
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_tile, DoCommandFlag flags, uint32 p1, u
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 start_tile, DoCommandFlag flags, uint32 p1,
/* 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 */