(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
authorpeter1138
Thu, 26 Oct 2006 19:16:10 +0000
changeset 4953 2a33d1ff2ab7
parent 4952 9c45131d0657
child 4954 c1f059faa899
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
newgrf.c
--- a/newgrf.c	Thu Oct 26 13:18:12 2006 +0000
+++ b/newgrf.c	Thu Oct 26 19:16:10 2006 +0000
@@ -3068,6 +3068,21 @@
 	}
 }
 
+static void ResetNewGRF(void)
+{
+	GRFFile *f, *next;
+
+	for (f = _first_grffile; f != NULL; f = next) {
+		next = f->next;
+
+		free(f->filename);
+		free(f);
+	}
+
+	_first_grffile = NULL;
+	_cur_grffile   = NULL;
+}
+
 /**
  * Reset all NewGRF loaded data
  * TODO
@@ -3118,6 +3133,9 @@
 	ResetStationClasses();
 	ResetCustomStations();
 
+	/* Reset NewGRF files */
+	ResetNewGRF();
+
 	// Add engine type to engine data. This is needed for the refit precalculation.
 	AddTypeToEngines();