station_cmd.c
changeset 243 9a40daa560ae
parent 222 b88456001397
child 313 0c7cac001d1a
--- a/station_cmd.c	Tue Sep 14 08:13:15 2004 +0000
+++ b/station_cmd.c	Tue Sep 14 14:19:53 2004 +0000
@@ -313,7 +313,8 @@
 		ge->last_speed = 0;
 		ge->last_age = 0xFF;
 	}
-	_station_sort_dirty = true;
+
+	_global_station_sort_dirty = true; // build a new station
 }
 
 // Update the virtual coords needed to draw the station sign.
@@ -2026,7 +2027,7 @@
 
 	DeleteName(st->string_id);
 	MarkStationDirty(st);
-	_station_sort_dirty = true;
+	_global_station_sort_dirty = true; // delete station, remove sign
 	InvalidateWindowClasses(WC_STATION_LIST);
 
 	index = st->index;
@@ -2247,7 +2248,7 @@
 		st->string_id = str;
 		UpdateStationVirtCoord(st);
 		DeleteName(old_str);
-		_station_sort_dirty = true;
+		_station_sort_dirty[st->owner] = true; // rename a station
 		MarkWholeScreenDirty();
 	} else {
 		DeleteName(str);
@@ -2426,7 +2427,7 @@
 		Station *st = DEREF_STATION(_map2[tile]);
 		_map_owner[tile] = new_player;
 		st->owner = new_player;
-		_station_sort_dirty = true;
+		_global_station_sort_dirty = true; // transfer ownership of station to another player
 		InvalidateWindowClasses(WC_STATION_LIST);
 	} else {
 		DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
@@ -2476,11 +2477,16 @@
 void InitializeStations()
 {
 	int i;
+	
 	memset(_stations, 0, sizeof(_stations));
-	for(i=0;i!=lengthof(_stations); i++)
+	for(i = 0; i != lengthof(_stations); i++)
 		_stations[i].index=i;
+
 	_station_tick_ctr = 0;
-	_station_sort_dirty = true;	// set stations to be sorted on first load
+
+	// set stations to be sorted on load of savegame
+	memset(_station_sort_dirty, true, sizeof(_station_sort_dirty));
+	_global_station_sort_dirty = true; // load of savegame
 }