summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/station_cmd.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 12eca14d2..cfa23287d 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1099,7 +1099,11 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1,
}
}
+ byte old_specindex = IsTileType(tile, MP_STATION) ? GetCustomStationSpecIndex(tile) : 0;
MakeRailStation(tile, st->owner, st->index, axis, layout & ~1, (RailType)GB(p1, 0, 4));
+ /* Free the spec if we overbuild something */
+ DeallocateSpecFromStation(st, old_specindex);
+
SetCustomStationSpecIndex(tile, specindex);
SetStationTileRandomBits(tile, GB(Random(), 0, 4));
SetStationAnimationFrame(tile, 0);