Codechange: Store the rail type of rail engines as a RailTypes bitmask.

This commit is contained in:
Michael Lutz
2025-06-13 21:01:31 +02:00
parent 0715903b24
commit 3ac1a2f1e4
27 changed files with 184 additions and 87 deletions
+2 -2
View File
@@ -1605,7 +1605,7 @@ CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_
Track track;
while ((track = RemoveFirstTrack(&reserved)) != INVALID_TRACK) {
Train *v = GetTrainForReservation(tile, track);
if (v != nullptr && !HasPowerOnRail(v->railtype, totype)) {
if (v != nullptr && !HasPowerOnRail(v->railtypes, totype)) {
/* No power on new rail type, reroute. */
FreeTrainTrackReservation(v);
vehicles_affected.push_back(v);
@@ -1691,7 +1691,7 @@ CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_
Track track = DiagDirToDiagTrack(GetTunnelBridgeDirection(tile));
if (HasTunnelBridgeReservation(tile)) {
Train *v = GetTrainForReservation(tile, track);
if (v != nullptr && !HasPowerOnRail(v->railtype, totype)) {
if (v != nullptr && !HasPowerOnRail(v->railtypes, totype)) {
/* No power on new rail type, reroute. */
FreeTrainTrackReservation(v);
vehicles_affected.push_back(v);