changeset 17768:9461da980e62 draft

(svn r22552) -Fix: Clear airport persistent storage on construction/removal of airports.
author frosch <frosch@openttd.org>
date Sat, 11 Jun 2011 20:47:31 +0000
parents 6a3cc2837af9
children fc23ab1c0733
files src/newgrf_storage.h src/station_cmd.cpp
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf_storage.h
+++ b/src/newgrf_storage.h
@@ -62,6 +62,12 @@
 		free(this->prev_storage);
 	}
 
+	/** Resets all values to zero. */
+	void ResetToZero()
+	{
+		memset(this->storage, 0, sizeof(this->storage));
+	}
+
 	/**
 	 * Stores some value at a given position.
 	 * If there is no backup of the data that backup is made and then
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2191,6 +2191,7 @@
 		st->airport.layout = layout;
 		st->airport.flags = 0;
 		st->airport.rotation = rotation;
+		st->airport.psa.ResetToZero();
 
 		st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
 
@@ -2287,6 +2288,7 @@
 
 		st->airport.Clear();
 		st->facilities &= ~FACIL_AIRPORT;
+		st->airport.psa.ResetToZero();
 
 		SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_PLANES);