mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-06-19 03:29:26 +01:00
Change: Extend rail types to 64 (6 bit storage)
This commit is contained in:
parent
5db883fbe9
commit
bf8d7df736
@ -226,7 +226,7 @@
|
|||||||
<li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the tile</li>
|
<li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the tile</li>
|
||||||
<li>m2: see signals</li>
|
<li>m2: see signals</li>
|
||||||
<li>m3 bits 7..4: see signals</li>
|
<li>m3 bits 7..4: see signals</li>
|
||||||
<li>m8 bits 3..0 = <a name="TrackType">track type</a>:
|
<li>m8 bits 5..0 = <a name="TrackType">track type</a>:
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><tt>0</tt> </td>
|
<td><tt>0</tt> </td>
|
||||||
@ -641,7 +641,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</li>
|
</li>
|
||||||
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li>
|
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li>
|
||||||
<li>m8 bits 3..0: <a href="#TrackType">railway track type</a></li>
|
<li>m8 bits 5..0: <a href="#TrackType">railway track type</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -978,7 +978,7 @@
|
|||||||
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road (road stops)</li>
|
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road (road stops)</li>
|
||||||
<li>m7 bits 7..6: present road types (road stops)</li>
|
<li>m7 bits 7..6: present road types (road stops)</li>
|
||||||
<li>m7: animation frame (railway stations/waypoints, airports)</li>
|
<li>m7: animation frame (railway stations/waypoints, airports)</li>
|
||||||
<li>m8 bits 3..0: <a href="#TrackType">track type</a> for railway stations/waypoints</li>
|
<li>m8 bits 5..0: <a href="#TrackType">track type</a> for railway stations/waypoints</li>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -1581,7 +1581,7 @@
|
|||||||
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road</li>
|
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road</li>
|
||||||
<li>m7 bit 5 set = on snow or desert</li>
|
<li>m7 bit 5 set = on snow or desert</li>
|
||||||
<li>m7 bits 7..6: present road types for road</li>
|
<li>m7 bits 7..6: present road types for road</li>
|
||||||
<li>m8 bits 3..0: <a href="#TrackType">track type</a> for railway</li>
|
<li>m8 bits 5..0: <a href="#TrackType">track type</a> for railway</li>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -107,7 +107,7 @@ the array so you can quickly see what is used and what is not.
|
|||||||
<td class="bits">XXXX XXXX</td>
|
<td class="bits">XXXX XXXX</td>
|
||||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||||
<td class="bits"><span class="free">OOOO OOOO OOOO</span> XXXX</td>
|
<td class="bits"><span class="free">OOOO OOOO OO</span>XX XXXX</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="caption">rail with signals</td>
|
<td class="caption">rail with signals</td>
|
||||||
@ -160,7 +160,7 @@ the array so you can quickly see what is used and what is not.
|
|||||||
<td class="bits">XXXX <span class="free">OOO</span>X</td>
|
<td class="bits">XXXX <span class="free">OOO</span>X</td>
|
||||||
<td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td>
|
<td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td>
|
||||||
<td class="bits">XXXX XXXX</td>
|
<td class="bits">XXXX XXXX</td>
|
||||||
<td class="bits"><span class="free">OOOO OOOO OOOO</span> XXXX</td>
|
<td class="bits"><span class="free">OOOO OOOO OO</span>XX XXXX</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="caption">road depot</td>
|
<td class="caption">road depot</td>
|
||||||
@ -215,7 +215,7 @@ the array so you can quickly see what is used and what is not.
|
|||||||
<td class="bits">XXXX XXXX</td>
|
<td class="bits">XXXX XXXX</td>
|
||||||
<td class="bits"><span class="free">OO</span>XX XX<span class="free">OO</span></td>
|
<td class="bits"><span class="free">OO</span>XX XX<span class="free">OO</span></td>
|
||||||
<td class="bits">XXXX XXXX</td>
|
<td class="bits">XXXX XXXX</td>
|
||||||
<td class="bits"><span class="free">OOOO OOOO OOOO</span> XXXX</td>
|
<td class="bits"><span class="free">OOOO OOOO OO</span>XX XXXX</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="caption">rail waypoint</td>
|
<td class="caption">rail waypoint</td>
|
||||||
@ -361,7 +361,7 @@ the array so you can quickly see what is used and what is not.
|
|||||||
<td class="bits">X<span class="free">OO</span>X XXXX</td>
|
<td class="bits">X<span class="free">OO</span>X XXXX</td>
|
||||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||||
<td class="bits">XXXX XXXX</td>
|
<td class="bits">XXXX XXXX</td>
|
||||||
<td class="bits"><span class="free">OOOO OOOO OOOO</span> XXXX</td>
|
<td class="bits"><span class="free">OOOO OOOO OO</span>XX XXXX</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>bridge ramp</td>
|
<td>bridge ramp</td>
|
||||||
|
@ -55,7 +55,7 @@ typedef GUIList<BuildBridgeData> GUIBridgeList; ///< List of bridges, used in #B
|
|||||||
* @param p1 packed start tile coords (~ dx)
|
* @param p1 packed start tile coords (~ dx)
|
||||||
* @param p2 various bitstuffed elements
|
* @param p2 various bitstuffed elements
|
||||||
* - p2 = (bit 0- 7) - bridge type (hi bh)
|
* - 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.
|
* - p2 = (bit 15-16) - transport type.
|
||||||
*/
|
*/
|
||||||
void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2)
|
void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2)
|
||||||
|
@ -166,11 +166,11 @@ RailType AllocateRailType(RailTypeLabel label)
|
|||||||
rti->alternate_labels.Clear();
|
rti->alternate_labels.Clear();
|
||||||
|
|
||||||
/* Make us compatible with ourself. */
|
/* Make us compatible with ourself. */
|
||||||
rti->powered_railtypes = (RailTypes)(1 << rt);
|
rti->powered_railtypes = (RailTypes)(1LL << rt);
|
||||||
rti->compatible_railtypes = (RailTypes)(1 << rt);
|
rti->compatible_railtypes = (RailTypes)(1LL << rt);
|
||||||
|
|
||||||
/* We also introduce ourself. */
|
/* 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
|
/* Default sort order; order of allocation, but with some
|
||||||
* offsets so it's easier for NewGRF to pick a spot without
|
* 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)
|
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);
|
Track track = Extract<Track, 0, 3>(p2);
|
||||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
@ -854,19 +854,19 @@ static CommandCost ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileInd
|
|||||||
* @param flags operation to perform
|
* @param flags operation to perform
|
||||||
* @param p1 end tile of drag
|
* @param p1 end tile of drag
|
||||||
* @param p2 various bitstuffed elements
|
* @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 0-5) - 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 6-8) - track-orientation, valid values: 0-5 (Track enum)
|
||||||
* - p2 = (bit 7) - 0 = build, 1 = remove tracks
|
* - p2 = (bit 9) - 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 10) - 0 = build up to an obstacle, 1 = fail if an obstacle is found (used for AIs).
|
||||||
* @param text unused
|
* @param text unused
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
*/
|
*/
|
||||||
static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||||
{
|
{
|
||||||
CommandCost total_cost(EXPENSES_CONSTRUCTION);
|
CommandCost total_cost(EXPENSES_CONSTRUCTION);
|
||||||
Track track = Extract<Track, 4, 3>(p2);
|
Track track = Extract<Track, 6, 3>(p2);
|
||||||
bool remove = HasBit(p2, 7);
|
bool remove = HasBit(p2, 9);
|
||||||
RailType railtype = Extract<RailType, 0, 4>(p2);
|
RailType railtype = Extract<RailType, 0, 6>(p2);
|
||||||
|
|
||||||
if ((!remove && !ValParamRailtype(railtype)) || !ValParamTrackOrientation(track)) return CMD_ERROR;
|
if ((!remove && !ValParamRailtype(railtype)) || !ValParamTrackOrientation(track)) return CMD_ERROR;
|
||||||
if (p1 >= MapSize()) return CMD_ERROR;
|
if (p1 >= MapSize()) return CMD_ERROR;
|
||||||
@ -884,7 +884,7 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3
|
|||||||
if (ret.Failed()) {
|
if (ret.Failed()) {
|
||||||
last_error = ret;
|
last_error = ret;
|
||||||
if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT && !remove) {
|
if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT && !remove) {
|
||||||
if (HasBit(p2, 8)) return last_error;
|
if (HasBit(p2, 10)) return last_error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -914,16 +914,16 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3
|
|||||||
* @param flags operation to perform
|
* @param flags operation to perform
|
||||||
* @param p1 end tile of drag
|
* @param p1 end tile of drag
|
||||||
* @param p2 various bitstuffed elements
|
* @param p2 various bitstuffed elements
|
||||||
* - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
|
* - p2 = (bit 0-5) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
|
||||||
* - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
|
* - p2 = (bit 6-8) - track-orientation, valid values: 0-5 (Track enum)
|
||||||
* - p2 = (bit 7) - 0 = build, 1 = remove tracks
|
* - p2 = (bit 9) - 0 = build, 1 = remove tracks
|
||||||
* @param text unused
|
* @param text unused
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
* @see CmdRailTrackHelper
|
* @see CmdRailTrackHelper
|
||||||
*/
|
*/
|
||||||
CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
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 flags operation to perform
|
||||||
* @param p1 end tile of drag
|
* @param p1 end tile of drag
|
||||||
* @param p2 various bitstuffed elements
|
* @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 0-5) - 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 6-8) - track-orientation, valid values: 0-5 (Track enum)
|
||||||
* - p2 = (bit 7) - 0 = build, 1 = remove tracks
|
* - p2 = (bit 9) - 0 = build, 1 = remove tracks
|
||||||
* @param text unused
|
* @param text unused
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
* @see CmdRailTrackHelper
|
* @see CmdRailTrackHelper
|
||||||
*/
|
*/
|
||||||
CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
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)
|
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 */
|
/* 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;
|
if (!ValParamRailtype(railtype)) return CMD_ERROR;
|
||||||
|
|
||||||
Slope tileh = GetTileSlope(tile);
|
Slope tileh = GetTileSlope(tile);
|
||||||
@ -1540,17 +1540,17 @@ static Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data)
|
|||||||
* @param flags operation to perform
|
* @param flags operation to perform
|
||||||
* @param p1 start tile of drag
|
* @param p1 start tile of drag
|
||||||
* @param p2 various bitstuffed elements:
|
* @param p2 various bitstuffed elements:
|
||||||
* - p2 = (bit 0- 3) new railtype to convert to.
|
* - p2 = (bit 0- 5) new railtype to convert to.
|
||||||
* - p2 = (bit 4) build diagonally or not.
|
* - p2 = (bit 6) build diagonally or not.
|
||||||
* @param text unused
|
* @param text unused
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
*/
|
*/
|
||||||
CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
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_start = p1;
|
||||||
TileIndex area_end = tile;
|
TileIndex area_end = tile;
|
||||||
bool diagonal = HasBit(p2, 4);
|
bool diagonal = HasBit(p2, 6);
|
||||||
|
|
||||||
if (!ValParamRailtype(totype)) return CMD_ERROR;
|
if (!ValParamRailtype(totype)) return CMD_ERROR;
|
||||||
if (area_start >= MapSize()) return CMD_ERROR;
|
if (area_start >= MapSize()) return CMD_ERROR;
|
||||||
|
@ -192,7 +192,7 @@ static void PlaceRail_Station(TileIndex tile)
|
|||||||
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
|
||||||
VpSetPlaceSizingLimit(_settings_game.station.station_spread);
|
VpSetPlaceSizingLimit(_settings_game.station.station_spread);
|
||||||
} else {
|
} 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;
|
uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
|
||||||
|
|
||||||
int w = _settings_client.gui.station_numtracks;
|
int w = _settings_client.gui.station_numtracks;
|
||||||
@ -352,7 +352,7 @@ static void BuildRailClick_Remove(Window *w)
|
|||||||
|
|
||||||
static void DoRailroadTrack(int mode)
|
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 ?
|
_remove_button_clicked ?
|
||||||
CMD_REMOVE_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
|
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),
|
CMD_BUILD_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK),
|
||||||
@ -711,7 +711,7 @@ struct BuildRailToolbarWindow : Window {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DDSP_CONVERT_RAIL:
|
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;
|
break;
|
||||||
|
|
||||||
case DDSP_REMOVE_STATION:
|
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);
|
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 {
|
} else {
|
||||||
TileArea ta(start_tile, end_tile);
|
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;
|
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, "" };
|
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);
|
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;
|
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, "" };
|
CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
|
||||||
|
@ -115,7 +115,7 @@ static inline bool IsRailDepotTile(TileIndex t)
|
|||||||
*/
|
*/
|
||||||
static inline RailType GetRailType(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)
|
static inline void SetRailType(TileIndex t, RailType r)
|
||||||
{
|
{
|
||||||
SB(_me[t].m8, 0, 4, r);
|
SB(_me[t].m8, 0, 6, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ enum RailType {
|
|||||||
RAILTYPE_ELECTRIC = 1, ///< Electric rails
|
RAILTYPE_ELECTRIC = 1, ///< Electric rails
|
||||||
RAILTYPE_MONO = 2, ///< Monorail
|
RAILTYPE_MONO = 2, ///< Monorail
|
||||||
RAILTYPE_MAGLEV = 3, ///< Maglev
|
RAILTYPE_MAGLEV = 3, ///< Maglev
|
||||||
RAILTYPE_END = 16, ///< Used for iterations
|
RAILTYPE_END = 64, ///< Used for iterations
|
||||||
INVALID_RAILTYPE = 0xFF, ///< Flag for invalid railtype
|
INVALID_RAILTYPE = 0xFF, ///< Flag for invalid railtype
|
||||||
|
|
||||||
DEF_RAILTYPE_FIRST = RAILTYPE_END, ///< Default railtype: first available
|
DEF_RAILTYPE_FIRST = RAILTYPE_END, ///< Default railtype: first available
|
||||||
@ -43,7 +43,7 @@ enum RailType {
|
|||||||
/** Allow incrementing of Track variables */
|
/** Allow incrementing of Track variables */
|
||||||
DECLARE_POSTFIX_INCREMENT(RailType)
|
DECLARE_POSTFIX_INCREMENT(RailType)
|
||||||
/** Define basic enum properties */
|
/** 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;
|
typedef TinyEnumT<RailType> RailTypeByte;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +55,7 @@ enum RailTypes {
|
|||||||
RAILTYPES_ELECTRIC = 1 << RAILTYPE_ELECTRIC, ///< Electrified rails
|
RAILTYPES_ELECTRIC = 1 << RAILTYPE_ELECTRIC, ///< Electrified rails
|
||||||
RAILTYPES_MONO = 1 << RAILTYPE_MONO, ///< Monorail!
|
RAILTYPES_MONO = 1 << RAILTYPE_MONO, ///< Monorail!
|
||||||
RAILTYPES_MAGLEV = 1 << RAILTYPE_MAGLEV, ///< Ever fast maglev
|
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)
|
DECLARE_ENUM_AS_BIT_SET(RailTypes)
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@
|
|||||||
* 197 27978 1.8.x
|
* 197 27978 1.8.x
|
||||||
* 198
|
* 198
|
||||||
* 199
|
* 199
|
||||||
* 200
|
* 200 #6805 Extend railtypes to 64, adding uint16 to map array.
|
||||||
*/
|
*/
|
||||||
extern const uint16 SAVEGAME_VERSION = 200; ///< Current savegame version of OpenTTD.
|
extern const uint16 SAVEGAME_VERSION = 200; ///< Current savegame version of OpenTTD.
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@
|
|||||||
EnforcePrecondition(false, station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id));
|
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);
|
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);
|
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);
|
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));
|
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);
|
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);
|
if (station_id != ScriptStation::STATION_JOIN_ADJACENT) p1 |= (1 << 24);
|
||||||
|
|
||||||
const GRFFile *file;
|
const GRFFile *file;
|
||||||
@ -244,7 +244,7 @@
|
|||||||
EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0);
|
EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0);
|
||||||
EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
|
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)
|
/* static */ bool ScriptRail::RemoveRailTrack(TileIndex tile, RailTrack rail_track)
|
||||||
@ -255,7 +255,7 @@
|
|||||||
EnforcePrecondition(false, GetRailTracks(tile) & rail_track);
|
EnforcePrecondition(false, GetRailTracks(tile) & rail_track);
|
||||||
EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0);
|
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)
|
/* 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)) ||
|
(::TileX(from) == ::TileX(tile) && ::TileX(tile) == ::TileX(to)) ||
|
||||||
(::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(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);
|
return ScriptObject::DoCommand(tile, to, p2, CMD_BUILD_RAILROAD_TRACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1173,8 +1173,8 @@ static void RestoreTrainReservation(Train *v)
|
|||||||
* @param tile_org northern most position of station dragging/placement
|
* @param tile_org northern most position of station dragging/placement
|
||||||
* @param flags operation to perform
|
* @param flags operation to perform
|
||||||
* @param p1 various bitstuffed elements
|
* @param p1 various bitstuffed elements
|
||||||
* - p1 = (bit 0- 3) - railtype
|
* - p1 = (bit 0- 5) - railtype
|
||||||
* - p1 = (bit 4) - orientation (Axis)
|
* - p1 = (bit 6) - orientation (Axis)
|
||||||
* - p1 = (bit 8-15) - number of tracks
|
* - p1 = (bit 8-15) - number of tracks
|
||||||
* - p1 = (bit 16-23) - platform length
|
* - p1 = (bit 16-23) - platform length
|
||||||
* - p1 = (bit 24) - allow stations directly adjacent to other stations.
|
* - 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)
|
CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||||
{
|
{
|
||||||
/* Unpack parameters */
|
/* Unpack parameters */
|
||||||
RailType rt = Extract<RailType, 0, 4>(p1);
|
RailType rt = Extract<RailType, 0, 6>(p1);
|
||||||
Axis axis = Extract<Axis, 4, 1>(p1);
|
Axis axis = Extract<Axis, 6, 1>(p1);
|
||||||
byte numtracks = GB(p1, 8, 8);
|
byte numtracks = GB(p1, 8, 8);
|
||||||
byte plat_len = GB(p1, 16, 8);
|
byte plat_len = GB(p1, 16, 8);
|
||||||
bool adjacent = HasBit(p1, 24);
|
bool adjacent = HasBit(p1, 24);
|
||||||
|
@ -232,7 +232,7 @@ CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoC
|
|||||||
* @param p1 packed start tile coords (~ dx)
|
* @param p1 packed start tile coords (~ dx)
|
||||||
* @param p2 various bitstuffed elements
|
* @param p2 various bitstuffed elements
|
||||||
* - p2 = (bit 0- 7) - bridge type (hi bh)
|
* - 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.
|
* - p2 = (bit 15-16) - transport type.
|
||||||
* @param text unused
|
* @param text unused
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
@ -259,7 +259,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TRANSPORT_RAIL:
|
case TRANSPORT_RAIL:
|
||||||
railtype = Extract<RailType, 8, 4>(p2);
|
railtype = Extract<RailType, 8, 6>(p2);
|
||||||
if (!ValParamRailtype(railtype)) return CMD_ERROR;
|
if (!ValParamRailtype(railtype)) return CMD_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -574,7 +574,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
|||||||
* Build Tunnel.
|
* Build Tunnel.
|
||||||
* @param start_tile start tile of tunnel
|
* @param start_tile start tile of tunnel
|
||||||
* @param flags type of operation
|
* @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
|
* bit 8-9 transport type
|
||||||
* @param p2 unused
|
* @param p2 unused
|
||||||
* @param text unused
|
* @param text unused
|
||||||
@ -591,7 +591,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
|
|||||||
_build_tunnel_endtile = 0;
|
_build_tunnel_endtile = 0;
|
||||||
switch (transport_type) {
|
switch (transport_type) {
|
||||||
case TRANSPORT_RAIL:
|
case TRANSPORT_RAIL:
|
||||||
railtype = Extract<RailType, 0, 4>(p1);
|
railtype = Extract<RailType, 0, 6>(p1);
|
||||||
if (!ValParamRailtype(railtype)) return CMD_ERROR;
|
if (!ValParamRailtype(railtype)) return CMD_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user