summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bridge_gui.cpp2
-rw-r--r--src/rail_cmd.cpp50
-rw-r--r--src/rail_gui.cpp10
-rw-r--r--src/rail_map.h4
-rw-r--r--src/rail_type.h6
-rw-r--r--src/saveload/saveload.cpp2
-rw-r--r--src/script/api/script_rail.cpp10
-rw-r--r--src/station_cmd.cpp8
-rw-r--r--src/tunnelbridge_cmd.cpp8
9 files changed, 50 insertions, 50 deletions
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index 797ead1f5..768691f08 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -55,7 +55,7 @@ typedef GUIList<BuildBridgeData> GUIBridgeList; ///< List of bridges, used in #B
* @param p1 packed start tile coords (~ dx)
* @param p2 various bitstuffed elements
* - p2 = (bit 0- 7) - bridge type (hi bh)
- * - p2 = (bit 8-11) - rail type or road types.
+ * - p2 = (bit 8-13) - rail type or road types.
* - p2 = (bit 15-16) - transport type.
*/
void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2)
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 5bc97a58d..d21c1468c 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -166,11 +166,11 @@ RailType AllocateRailType(RailTypeLabel label)
rti->alternate_labels.Clear();
/* Make us compatible with ourself. */
- rti->powered_railtypes = (RailTypes)(1 << rt);
- rti->compatible_railtypes = (RailTypes)(1 << rt);
+ rti->powered_railtypes = (RailTypes)(1LL << rt);
+ rti->compatible_railtypes = (RailTypes)(1LL << rt);
/* We also introduce ourself. */
- rti->introduces_railtypes = (RailTypes)(1 << rt);
+ rti->introduces_railtypes = (RailTypes)(1LL << rt);
/* Default sort order; order of allocation, but with some
* offsets so it's easier for NewGRF to pick a spot without
@@ -441,7 +441,7 @@ static inline bool ValParamTrackOrientation(Track track)
*/
CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
- RailType railtype = Extract<RailType, 0, 4>(p1);
+ RailType railtype = Extract<RailType, 0, 6>(p1);
Track track = Extract<Track, 0, 3>(p2);
CommandCost cost(EXPENSES_CONSTRUCTION);
@@ -854,19 +854,19 @@ static CommandCost ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileInd
* @param flags operation to perform
* @param p1 end tile of drag
* @param p2 various bitstuffed elements
- * - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building
- * - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
- * - p2 = (bit 7) - 0 = build, 1 = remove tracks
- * - p2 = (bit 8) - 0 = build up to an obstacle, 1 = fail if an obstacle is found (used for AIs).
+ * - p2 = (bit 0-5) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building
+ * - p2 = (bit 6-8) - track-orientation, valid values: 0-5 (Track enum)
+ * - p2 = (bit 9) - 0 = build, 1 = remove tracks
+ * - p2 = (bit 10) - 0 = build up to an obstacle, 1 = fail if an obstacle is found (used for AIs).
* @param text unused
* @return the cost of this operation or an error
*/
static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
CommandCost total_cost(EXPENSES_CONSTRUCTION);
- Track track = Extract<Track, 4, 3>(p2);
- bool remove = HasBit(p2, 7);
- RailType railtype = Extract<RailType, 0, 4>(p2);
+ Track track = Extract<Track, 6, 3>(p2);
+ bool remove = HasBit(p2, 9);
+ RailType railtype = Extract<RailType, 0, 6>(p2);
if ((!remove && !ValParamRailtype(railtype)) || !ValParamTrackOrientation(track)) return CMD_ERROR;
if (p1 >= MapSize()) return CMD_ERROR;
@@ -884,7 +884,7 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3
if (ret.Failed()) {
last_error = ret;
if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT && !remove) {
- if (HasBit(p2, 8)) return last_error;
+ if (HasBit(p2, 10)) return last_error;
break;
}
@@ -914,16 +914,16 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3
* @param flags operation to perform
* @param p1 end tile of drag
* @param p2 various bitstuffed elements
- * - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
- * - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
- * - p2 = (bit 7) - 0 = build, 1 = remove tracks
+ * - p2 = (bit 0-5) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
+ * - p2 = (bit 6-8) - track-orientation, valid values: 0-5 (Track enum)
+ * - p2 = (bit 9) - 0 = build, 1 = remove tracks
* @param text unused
* @return the cost of this operation or an error
* @see CmdRailTrackHelper
*/
CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
- return CmdRailTrackHelper(tile, flags, p1, ClrBit(p2, 7), text);
+ return CmdRailTrackHelper(tile, flags, p1, ClrBit(p2, 9), text);
}
/**
@@ -933,16 +933,16 @@ CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1
* @param flags operation to perform
* @param p1 end tile of drag
* @param p2 various bitstuffed elements
- * - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building
- * - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
- * - p2 = (bit 7) - 0 = build, 1 = remove tracks
+ * - p2 = (bit 0-5) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building
+ * - p2 = (bit 6-8) - track-orientation, valid values: 0-5 (Track enum)
+ * - p2 = (bit 9) - 0 = build, 1 = remove tracks
* @param text unused
* @return the cost of this operation or an error
* @see CmdRailTrackHelper
*/
CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
- return CmdRailTrackHelper(tile, flags, p1, SetBit(p2, 7), text);
+ return CmdRailTrackHelper(tile, flags, p1, SetBit(p2, 9), text);
}
/**
@@ -960,7 +960,7 @@ CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p
CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
/* check railtype and valid direction for depot (0 through 3), 4 in total */
- RailType railtype = Extract<RailType, 0, 4>(p1);
+ RailType railtype = Extract<RailType, 0, 6>(p1);
if (!ValParamRailtype(railtype)) return CMD_ERROR;
Slope tileh = GetTileSlope(tile);
@@ -1540,17 +1540,17 @@ static Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data)
* @param flags operation to perform
* @param p1 start tile of drag
* @param p2 various bitstuffed elements:
- * - p2 = (bit 0- 3) new railtype to convert to.
- * - p2 = (bit 4) build diagonally or not.
+ * - p2 = (bit 0- 5) new railtype to convert to.
+ * - p2 = (bit 6) build diagonally or not.
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
- RailType totype = Extract<RailType, 0, 4>(p2);
+ RailType totype = Extract<RailType, 0, 6>(p2);
TileIndex area_start = p1;
TileIndex area_end = tile;
- bool diagonal = HasBit(p2, 4);
+ bool diagonal = HasBit(p2, 6);
if (!ValParamRailtype(totype)) return CMD_ERROR;
if (area_start >= MapSize()) return CMD_ERROR;
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index de8d43474..5a533e5c5 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -192,7 +192,7 @@ static void PlaceRail_Station(TileIndex tile)
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
VpSetPlaceSizingLimit(_settings_game.station.station_spread);
} else {
- uint32 p1 = _cur_railtype | _railstation.orientation << 4 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | _ctrl_pressed << 24;
+ uint32 p1 = _cur_railtype | _railstation.orientation << 6 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | _ctrl_pressed << 24;
uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
int w = _settings_client.gui.station_numtracks;
@@ -352,7 +352,7 @@ static void BuildRailClick_Remove(Window *w)
static void DoRailroadTrack(int mode)
{
- DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4),
+ DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 6),
_remove_button_clicked ?
CMD_REMOVE_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
CMD_BUILD_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK),
@@ -711,7 +711,7 @@ struct BuildRailToolbarWindow : Window {
break;
case DDSP_CONVERT_RAIL:
- DoCommandP(end_tile, start_tile, _cur_railtype | (_ctrl_pressed ? 0x10 : 0), CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound_SPLAT_RAIL);
+ DoCommandP(end_tile, start_tile, _cur_railtype | (_ctrl_pressed ? 1 << 6 : 0), CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound_SPLAT_RAIL);
break;
case DDSP_REMOVE_STATION:
@@ -729,7 +729,7 @@ struct BuildRailToolbarWindow : Window {
DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound_SPLAT_RAIL);
} else {
TileArea ta(start_tile, end_tile);
- uint32 p1 = _cur_railtype | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 4 | ta.w << 8 | ta.h << 16 | _ctrl_pressed << 24;
+ uint32 p1 = _cur_railtype | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 6 | ta.w << 8 | ta.h << 16 | _ctrl_pressed << 24;
uint32 p2 = STAT_CLASS_WAYP | _cur_waypoint_type << 8 | INVALID_STATION << 16;
CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT), CcPlaySound_SPLAT_RAIL, "" };
@@ -886,7 +886,7 @@ static void HandleStationPlacement(TileIndex start, TileIndex end)
if (_railstation.orientation == AXIS_X) Swap(numtracks, platlength);
- uint32 p1 = _cur_railtype | _railstation.orientation << 4 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24;
+ uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24;
uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
diff --git a/src/rail_map.h b/src/rail_map.h
index bd580d32a..74afe5ace 100644
--- a/src/rail_map.h
+++ b/src/rail_map.h
@@ -115,7 +115,7 @@ static inline bool IsRailDepotTile(TileIndex t)
*/
static inline RailType GetRailType(TileIndex t)
{
- return (RailType)GB(_me[t].m8, 0, 4);
+ return (RailType)GB(_me[t].m8, 0, 6);
}
/**
@@ -125,7 +125,7 @@ static inline RailType GetRailType(TileIndex t)
*/
static inline void SetRailType(TileIndex t, RailType r)
{
- SB(_me[t].m8, 0, 4, r);
+ SB(_me[t].m8, 0, 6, r);
}
diff --git a/src/rail_type.h b/src/rail_type.h
index ee589898b..ebca7ec35 100644
--- a/src/rail_type.h
+++ b/src/rail_type.h
@@ -32,7 +32,7 @@ enum RailType {
RAILTYPE_ELECTRIC = 1, ///< Electric rails
RAILTYPE_MONO = 2, ///< Monorail
RAILTYPE_MAGLEV = 3, ///< Maglev
- RAILTYPE_END = 16, ///< Used for iterations
+ RAILTYPE_END = 64, ///< Used for iterations
INVALID_RAILTYPE = 0xFF, ///< Flag for invalid railtype
DEF_RAILTYPE_FIRST = RAILTYPE_END, ///< Default railtype: first available
@@ -43,7 +43,7 @@ enum RailType {
/** Allow incrementing of Track variables */
DECLARE_POSTFIX_INCREMENT(RailType)
/** Define basic enum properties */
-template <> struct EnumPropsT<RailType> : MakeEnumPropsT<RailType, byte, RAILTYPE_BEGIN, RAILTYPE_END, INVALID_RAILTYPE, 4> {};
+template <> struct EnumPropsT<RailType> : MakeEnumPropsT<RailType, byte, RAILTYPE_BEGIN, RAILTYPE_END, INVALID_RAILTYPE, 6> {};
typedef TinyEnumT<RailType> RailTypeByte;
/**
@@ -55,7 +55,7 @@ enum RailTypes {
RAILTYPES_ELECTRIC = 1 << RAILTYPE_ELECTRIC, ///< Electrified rails
RAILTYPES_MONO = 1 << RAILTYPE_MONO, ///< Monorail!
RAILTYPES_MAGLEV = 1 << RAILTYPE_MAGLEV, ///< Ever fast maglev
- INVALID_RAILTYPES = UINT_MAX, ///< Invalid railtypes
+ INVALID_RAILTYPES = UINT64_MAX, ///< Invalid railtypes
};
DECLARE_ENUM_AS_BIT_SET(RailTypes)
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index d02dfcbc6..e06523769 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -267,7 +267,7 @@
* 197 27978 1.8.x
* 198
* 199
- * 200
+ * 200 #6805 Extend railtypes to 64, adding uint16 to map array.
*/
extern const uint16 SAVEGAME_VERSION = 200; ///< Current savegame version of OpenTTD.
diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp
index af68a3edc..25ad2ec13 100644
--- a/src/script/api/script_rail.cpp
+++ b/src/script/api/script_rail.cpp
@@ -157,7 +157,7 @@
EnforcePrecondition(false, station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id));
uint32 p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8);
- if (direction == RAILTRACK_NW_SE) p1 |= (1 << 4);
+ if (direction == RAILTRACK_NW_SE) p1 |= (1 << 6);
if (station_id != ScriptStation::STATION_JOIN_ADJACENT) p1 |= (1 << 24);
return ScriptObject::DoCommand(tile, p1, (ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16, CMD_BUILD_RAIL_STATION);
}
@@ -176,7 +176,7 @@
EnforcePrecondition(false, goal_industry == ScriptIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == ScriptIndustryType::INDUSTRYTYPE_TOWN || ScriptIndustryType::IsValidIndustryType(goal_industry));
uint32 p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8);
- if (direction == RAILTRACK_NW_SE) p1 |= 1 << 4;
+ if (direction == RAILTRACK_NW_SE) p1 |= 1 << 6;
if (station_id != ScriptStation::STATION_JOIN_ADJACENT) p1 |= (1 << 24);
const GRFFile *file;
@@ -244,7 +244,7 @@
EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0);
EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
- return ScriptObject::DoCommand(tile, tile, GetCurrentRailType() | (FindFirstTrack((::TrackBits)rail_track) << 4), CMD_BUILD_RAILROAD_TRACK);
+ return ScriptObject::DoCommand(tile, tile, GetCurrentRailType() | (FindFirstTrack((::TrackBits)rail_track) << 6), CMD_BUILD_RAILROAD_TRACK);
}
/* static */ bool ScriptRail::RemoveRailTrack(TileIndex tile, RailTrack rail_track)
@@ -255,7 +255,7 @@
EnforcePrecondition(false, GetRailTracks(tile) & rail_track);
EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0);
- return ScriptObject::DoCommand(tile, tile, FindFirstTrack((::TrackBits)rail_track) << 4, CMD_REMOVE_RAILROAD_TRACK);
+ return ScriptObject::DoCommand(tile, tile, FindFirstTrack((::TrackBits)rail_track) << 6, CMD_REMOVE_RAILROAD_TRACK);
}
/* static */ bool ScriptRail::AreTilesConnected(TileIndex from, TileIndex tile, TileIndex to)
@@ -355,7 +355,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
(::TileX(from) == ::TileX(tile) && ::TileX(tile) == ::TileX(to)) ||
(::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to)));
- uint32 p2 = SimulateDrag(from, tile, &to) | 1 << 8 | ScriptRail::GetCurrentRailType();;
+ uint32 p2 = SimulateDrag(from, tile, &to) | 1 << 10 | ScriptRail::GetCurrentRailType();;
return ScriptObject::DoCommand(tile, to, p2, CMD_BUILD_RAILROAD_TRACK);
}
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 07db05856..6dd7bb2fd 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1173,8 +1173,8 @@ static void RestoreTrainReservation(Train *v)
* @param tile_org northern most position of station dragging/placement
* @param flags operation to perform
* @param p1 various bitstuffed elements
- * - p1 = (bit 0- 3) - railtype
- * - p1 = (bit 4) - orientation (Axis)
+ * - p1 = (bit 0- 5) - railtype
+ * - p1 = (bit 6) - orientation (Axis)
* - p1 = (bit 8-15) - number of tracks
* - p1 = (bit 16-23) - platform length
* - p1 = (bit 24) - allow stations directly adjacent to other stations.
@@ -1188,8 +1188,8 @@ static void RestoreTrainReservation(Train *v)
CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
/* Unpack parameters */
- RailType rt = Extract<RailType, 0, 4>(p1);
- Axis axis = Extract<Axis, 4, 1>(p1);
+ RailType rt = Extract<RailType, 0, 6>(p1);
+ Axis axis = Extract<Axis, 6, 1>(p1);
byte numtracks = GB(p1, 8, 8);
byte plat_len = GB(p1, 16, 8);
bool adjacent = HasBit(p1, 24);
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 5f194a319..ce14188fd 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -232,7 +232,7 @@ CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoC
* @param p1 packed start tile coords (~ dx)
* @param p2 various bitstuffed elements
* - p2 = (bit 0- 7) - bridge type (hi bh)
- * - p2 = (bit 8-11) - rail type or road types.
+ * - p2 = (bit 8-13) - rail type or road types.
* - p2 = (bit 15-16) - transport type.
* @param text unused
* @return the cost of this operation or an error
@@ -259,7 +259,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
break;
case TRANSPORT_RAIL:
- railtype = Extract<RailType, 8, 4>(p2);
+ railtype = Extract<RailType, 8, 6>(p2);
if (!ValParamRailtype(railtype)) return CMD_ERROR;
break;
@@ -574,7 +574,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
* Build Tunnel.
* @param start_tile start tile of tunnel
* @param flags type of operation
- * @param p1 bit 0-3 railtype or roadtypes
+ * @param p1 bit 0-5 railtype or roadtypes
* bit 8-9 transport type
* @param p2 unused
* @param text unused
@@ -591,7 +591,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
_build_tunnel_endtile = 0;
switch (transport_type) {
case TRANSPORT_RAIL:
- railtype = Extract<RailType, 0, 4>(p1);
+ railtype = Extract<RailType, 0, 6>(p1);
if (!ValParamRailtype(railtype)) return CMD_ERROR;
break;