(svn r4772) - Newstations: when allocating a custom station (via action 0x03) check if the station has already been allocated. (Fixes duplicate waypoints in newstatsw in non-temperate climate)
authorpeter1138
Sun, 07 May 2006 12:58:45 +0000
changeset 3780 4c785f28b1dd
parent 3779 8159f95872dc
child 3781 d93f51a199fd
(svn r4772) - Newstations: when allocating a custom station (via action 0x03) check if the station has already been allocated. (Fixes duplicate waypoints in newstatsw in non-temperate climate)
newgrf_station.c
newgrf_station.h
--- a/newgrf_station.c	Sun May 07 11:55:28 2006 +0000
+++ b/newgrf_station.c	Sun May 07 12:58:45 2006 +0000
@@ -137,6 +137,9 @@
 	StationClass *station_class;
 	int i;
 
+	/* If the station has already been allocated, don't reallocate it. */
+	if (statspec->allocated) return;
+
 	assert(statspec->sclass < STAT_CLASS_MAX);
 	station_class = &station_classes[statspec->sclass];
 
@@ -144,6 +147,7 @@
 	station_class->spec = realloc(station_class->spec, station_class->stations * sizeof(*station_class->spec));
 
 	station_class->spec[i] = statspec;
+	statspec->allocated = true;
 }
 
 /**
--- a/newgrf_station.h	Sun May 07 11:55:28 2006 +0000
+++ b/newgrf_station.h	Sun May 07 12:58:45 2006 +0000
@@ -21,6 +21,8 @@
 	uint32 grfid; ///< ID of GRF file station belongs to.
 	int localidx; ///< Index within GRF file of station.
 
+	bool allocated; ///< Flag whether this station has been added to a station class list
+
 	StationClassID sclass; ///< The class to which this spec belongs.
 	StringID name; ///< Name of this station.