Signals on bridges: Shrink M2 simulated signal states field

This commit is contained in:
Jonathan G Rennison
2018-07-02 18:29:10 +01:00
parent 814f9f7e0f
commit 5770f1407a
6 changed files with 70 additions and 18 deletions

View File

@@ -55,6 +55,7 @@
#include "../order_backup.h"
#include "../error.h"
#include "../disaster_vehicle.h"
#include "../bridge_signal_map.h"
#include "saveload_internal.h"
@@ -3013,6 +3014,17 @@ bool AfterLoadGame()
}
}
}
if (SlXvIsFeaturePresent(XSLFI_SIG_TUNNEL_BRIDGE, 1, 6)) {
/* m2 signal state bit allocation has shrunk */
for (TileIndex t = 0; t < map_size; t++) {
if (IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL && IsBridge(t) && IsTunnelBridgeSignalSimulationEntrance(t)) {
extern void ShiftBridgeEntranceSimulatedSignalsExtended(TileIndex t, int shift, uint64 in);
const uint shift = 15 - BRIDGE_M2_SIGNAL_STATE_COUNT;
ShiftBridgeEntranceSimulatedSignalsExtended(t, shift, GB(_m[t].m2, BRIDGE_M2_SIGNAL_STATE_COUNT, shift));
SB(_m[t].m2, 0, 15, GB(_m[t].m2, 0, 15) << shift);
}
}
}
/* Station acceptance is some kind of cache */
if (IsSavegameVersionBefore(127)) {