summaryrefslogtreecommitdiff
path: root/src/station.cpp
diff options
context:
space:
mode:
authorKUDr <KUDr@openttd.org>2007-01-18 09:34:44 +0000
committerKUDr <KUDr@openttd.org>2007-01-18 09:34:44 +0000
commitf0e463eccaeee1262b57466f67d7736017a79bfd (patch)
tree27b6f6857e67b835eddc042d6dd1fdb286c4862a /src/station.cpp
parentf6d68ab378f92e249f417f97fad86eda1e449ed7 (diff)
downloadopenttd-f0e463eccaeee1262b57466f67d7736017a79bfd.tar.xz
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
Diffstat (limited to 'src/station.cpp')
-rw-r--r--src/station.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/station.cpp b/src/station.cpp
index b718a0aac..80b039d78 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -50,7 +50,7 @@ Station::Station(TileIndex tile)
last_vehicle_type = VEH_Invalid;
- random_bits = Random();
+ random_bits = 0; // Random() must be called when station is really built (DC_EXEC)
waiting_triggers = 0;
}
@@ -105,6 +105,19 @@ void Station::operator delete(void *p, int st_idx)
{
}
+/** Called when new facility is built on the station. If it is the first facility
+ * it initializes also 'xy' and 'random_bits' members */
+void Station::AddFacility(byte new_facility_bit, TileIndex facil_xy)
+{
+ if (facilities == 0) {
+ xy = facil_xy;
+ random_bits = Random();
+ }
+ facilities |= new_facility_bit;
+ owner = _current_player;
+ build_date = _date;
+}
+
void Station::MarkDirty() const
{
if (sign.width_1 != 0) {