(svn r13035) -Codechange: remove two needless global-ish variables.
authorrubidium
Sat, 10 May 2008 22:43:33 +0000
changeset 9172 4488ce29544f
parent 9171 fd16812424c1
child 9173 b38373e203a9
(svn r13035) -Codechange: remove two needless global-ish variables.
src/autoreplace_gui.cpp
--- a/src/autoreplace_gui.cpp	Sat May 10 21:35:20 2008 +0000
+++ b/src/autoreplace_gui.cpp	Sat May 10 22:43:33 2008 +0000
@@ -40,9 +40,6 @@
 
 static RailType _railtype_selected_in_replace_gui;
 
-static bool _rebuild_left_list;
-static bool _rebuild_right_list;
-
 static const StringID _rail_types_list[] = {
 	STR_RAIL_VEHICLES,
 	STR_ELRAIL_VEHICLES,
@@ -99,19 +96,14 @@
 void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
 {
 	Player *p = GetPlayer(_local_player);
-	VehicleType type = GetEngine(e)->type;
 	uint num_engines = GetGroupNumEngines(_local_player, id_g, e);
 
 	if (num_engines == 0 || p->num_engines[e] == 0) {
 		/* We don't have any of this engine type.
 		 * Either we just sold the last one, we build a new one or we stopped replacing it.
 		 * In all cases, we need to update the left list */
-		_rebuild_left_list = true;
-	} else {
-		_rebuild_left_list = false;
+		InvalidateWindowData(WC_REPLACE_VEHICLE, GetEngine(e)->type, true);
 	}
-	_rebuild_right_list = false;
-	InvalidateWindowData(WC_REPLACE_VEHICLE, type);
 }
 
 /** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
@@ -119,9 +111,7 @@
  */
 void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
 {
-	_rebuild_left_list = false; // left list is only for the vehicles the player owns and is not related to being buildable
-	_rebuild_right_list = true;
-	InvalidateWindowData(WC_REPLACE_VEHICLE, type); // Update the autoreplace window
+	InvalidateWindowData(WC_REPLACE_VEHICLE, type, false); // Update the autoreplace window
 	InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
 }
 
@@ -470,9 +460,11 @@
 		} break;
 
 		case WE_INVALIDATE_DATA:
-			if (_rebuild_left_list) WP(w, replaceveh_d).update_left = true;
-			if (_rebuild_right_list) WP(w, replaceveh_d).update_right = true;
-			w->SetDirty();
+			if (e->we.invalidate.data == true) {
+				WP(w, replaceveh_d).update_left = true;
+			} else {
+				WP(w, replaceveh_d).update_right = true;
+			}
 			break;
 
 		case WE_DESTROY: