- Make sure we clear the additional railtype bit only for the correct tiles.

- Backup and restore the correct railtype for tiles when newGRFs are reloaded during a game.

(cherry picked from commit f5bf8e69b4fe95519513b934dc1057dc304ce3da)
This commit is contained in:
keldorkatarn
2016-04-02 18:41:04 +02:00
committed by Jonathan G Rennison
parent 4c37aad393
commit 75396c9b5f
2 changed files with 47 additions and 5 deletions

View File

@@ -3217,11 +3217,12 @@ bool AfterLoadGame()
// So set it to 0 just in case there was garbage in there.
if (SlXvIsFeatureMissing(XSLFI_MORE_RAIL_TYPES)) {
for (TileIndex t = 0; t < map_size; t++) {
if (_m[t].type == MP_RAILWAY ||
_m[t].type == MP_ROAD ||
_m[t].type == MP_STATION ||
_m[t].type == MP_TUNNELBRIDGE) {
SB(_m[t].m1, 7, 1, 0);
if (GetTileType(t) == MP_RAILWAY ||
IsLevelCrossingTile(t) ||
IsRailStationTile(t) ||
IsRailWaypointTile(t) ||
IsRailTunnelBridgeTile(t)) {
ClrBit(_m[t].m1, 7);
}
}
}
@@ -3263,6 +3264,21 @@ bool AfterLoadGame()
*/
void ReloadNewGRFData()
{
TileIndex map_size = MapSize();
/* Backup railtype labels for all rail tiles. The railtype info array will be resorted. */
std::map<TileIndex, RailTypeLabel> rail_type_label_backups;
for (TileIndex t = 0; t < map_size; t++) {
if (GetTileType(t) == MP_RAILWAY ||
IsLevelCrossingTile(t) ||
IsRailStationTile(t) ||
IsRailWaypointTile(t) ||
IsRailTunnelBridgeTile(t)) {
rail_type_label_backups[t] = GetRailTypeInfo(GetRailType(t))->label;
}
}
/* reload grf data */
GfxLoadSprites();
LoadStringWidthTable();
@@ -3288,4 +3304,16 @@ void ReloadNewGRFData()
MarkWholeScreenDirty();
CheckTrainsLengths();
AfterLoadTemplateVehiclesUpdateImage();
/* Restore correct railtype for all rail tiles.*/
for (TileIndex t = 0; t < map_size; t++) {
if (GetTileType(t) == MP_RAILWAY ||
IsLevelCrossingTile(t) ||
IsRailStationTile(t) ||
IsRailWaypointTile(t) ||
IsRailTunnelBridgeTile(t)) {
RailType old_type = GetRailTypeByLabel(rail_type_label_backups[t]);
SetRailType(t, (old_type == INVALID_RAILTYPE) ? RAILTYPE_RAIL : old_type);
}
}
}