Make 32 instead of 16 rail types possible. by using one free bit of m1 in the map array.
(cherry picked from commit b44843800880cdc186f5183301ee0f42afbb5f84) Also set non-rail type M3 bits to 0 where applicable. Change savegame versioning to SLXI format.
This commit is contained in:

committed by
Jonathan G Rennison

parent
59677d5c6f
commit
5cc56d6ad9
@@ -438,7 +438,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, 5>(p1);
|
||||
Track track = Extract<Track, 0, 3>(p2);
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
|
||||
@@ -852,19 +852,20 @@ 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-4) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building
|
||||
* - p2 = (bit 5-7) - track-orientation, valid values: 0-5 (Track enum)
|
||||
* - p2 = (bit 8) - 0 = build, 1 = remove tracks
|
||||
* - p2 = (bit 9) - 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);
|
||||
RailType railtype = Extract<RailType, 0, 5>(p2);
|
||||
Track track = Extract<Track, 5, 3>(p2);
|
||||
bool remove = HasBit(p2, 8);
|
||||
bool fail_if_obstacle = HasBit(p2, 9);
|
||||
|
||||
if ((!remove && !ValParamRailtype(railtype)) || !ValParamTrackOrientation(track)) return CMD_ERROR;
|
||||
if (p1 >= MapSize()) return CMD_ERROR;
|
||||
@@ -882,7 +883,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 (fail_if_obstacle) return last_error;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -912,16 +913,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-4) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
|
||||
* - p2 = (bit 5-7) - track-orientation, valid values: 0-5 (Track enum)
|
||||
* - p2 = (bit 8) - 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, 8), text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -931,16 +932,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-4) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev), only used for building
|
||||
* - p2 = (bit 5-7) - track-orientation, valid values: 0-5 (Track enum)
|
||||
* - p2 = (bit 8) - 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, 8), text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -958,7 +959,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, 5>(p1);
|
||||
if (!ValParamRailtype(railtype)) return CMD_ERROR;
|
||||
|
||||
Slope tileh = GetTileSlope(tile);
|
||||
@@ -1675,17 +1676,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 - 4) new railtype to convert to.
|
||||
* - p2 = (bit 5) 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, 5>(p2);
|
||||
TileIndex area_start = p1;
|
||||
TileIndex area_end = tile;
|
||||
bool diagonal = HasBit(p2, 4);
|
||||
bool diagonal = HasBit(p2, 5);
|
||||
|
||||
if (!ValParamRailtype(totype)) return CMD_ERROR;
|
||||
if (area_start >= MapSize()) return CMD_ERROR;
|
||||
|
Reference in New Issue
Block a user