summaryrefslogtreecommitdiff
path: root/src/rail_cmd.cpp
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2018-07-23 00:05:23 +0100
committerPeterN <peter@fuzzle.org>2018-07-26 13:27:40 +0100
commitbf8d7df7367055dcfad6cc1c21fd9c762ffc2fe4 (patch)
tree8fe03509c7d1ef6ef092521632e2cc32a36e3287 /src/rail_cmd.cpp
parent5db883fbe9b8ef6171bfafc145a80932c3920504 (diff)
downloadopenttd-bf8d7df7367055dcfad6cc1c21fd9c762ffc2fe4.tar.xz
Change: Extend rail types to 64 (6 bit storage)
Diffstat (limited to 'src/rail_cmd.cpp')
-rw-r--r--src/rail_cmd.cpp50
1 files changed, 25 insertions, 25 deletions
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;