(svn r1556) -Fix: Vehicle list updates should now really work
authorCelestar
Tue, 18 Jan 2005 09:35:31 +0000
changeset 1055 3aae1d6f12aa
parent 1054 1757eb9df0f6
child 1056 ff3cfd9042a3
(svn r1556) -Fix: Vehicle list updates should now really work
aircraft_cmd.c
aircraft_gui.c
order_cmd.c
ship_cmd.c
ship_gui.c
vehicle.h
--- a/aircraft_cmd.c	Mon Jan 17 22:44:33 2005 +0000
+++ b/aircraft_cmd.c	Tue Jan 18 09:35:31 2005 +0000
@@ -299,6 +299,7 @@
 	RebuildVehicleLists();
 	InvalidateWindow(WC_COMPANY, v->owner);
 	DeleteVehicleChain(v);
+	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 }
 
 // p1 = vehicle
@@ -343,6 +344,7 @@
 		v->vehstatus ^= VS_STOPPED;
 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
+		InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 	}
 
 	return 0;
@@ -505,19 +507,6 @@
 	}
 }
 
-void InvalidateAircraftWindows(const Vehicle *v)
-{
-	const Order *order;
-
-	InvalidateWindow(WC_AIRCRAFT_LIST, v->owner);
-
-	FOR_VEHICLE_ORDERS(v, order) {
-		if (order->type == OT_GOTO_STATION ) {
-			InvalidateWindow(WC_AIRCRAFT_LIST, (order->station << 16) | v->owner);
-		}
-	}
-}
-
 void OnNewDay_Aircraft(Vehicle *v)
 {
 	int32 cost;
@@ -545,6 +534,7 @@
 	SubtractMoneyFromPlayerFract(v->owner, cost);
 
 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
+	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 }
 
 void AircraftYearlyLoop()
@@ -1068,7 +1058,7 @@
 
 	InvalidateVehicleOrder(v);
 
-	InvalidateAircraftWindows(v);
+	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 }
 
 static void HandleAircraftLoading(Vehicle *v, int mode)
@@ -1206,6 +1196,7 @@
 	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_INC);
 	LoadUnloadVehicle(v);
 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
+	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 }
 
 static void AircraftEnterHangar(Vehicle *v)
@@ -1213,6 +1204,7 @@
 	Order old_order;
 
 	ServiceAircraft(v);
+	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 
 	MaybeReplaceVehicle(v);
 
@@ -1229,7 +1221,7 @@
 			v->cur_order_index++;
 		} else if (old_order.flags & OF_FULL_LOAD) { // force depot visit
 			v->vehstatus |= VS_STOPPED;
-			InvalidateAircraftWindows(v);
+			InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 
 			if (v->owner == _local_player) {
 				SetDParam(0, v->unitnumber);
@@ -1291,6 +1283,7 @@
 	VehicleServiceInDepot(v);
 	SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
 	InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
+	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 }
 
 
--- a/aircraft_gui.c	Mon Jan 17 22:44:33 2005 +0000
+++ b/aircraft_gui.c	Tue Jan 18 09:35:31 2005 +0000
@@ -1034,7 +1034,7 @@
 			DrawVehicleProfitButton(v, x, y + 13);
 
 			SetDParam(0, v->unitnumber);
-			if (IsAircraftHangarTile(v->tile))
+			if (IsAircraftHangarTile(v->tile) && (v->vehstatus & VS_HIDDEN))
 				str = STR_021F;
 			else
 				str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
--- a/order_cmd.c	Mon Jan 17 22:44:33 2005 +0000
+++ b/order_cmd.c	Tue Jan 18 09:35:31 2005 +0000
@@ -343,8 +343,8 @@
 	}
 
 	/* We have an aircraft/ship, they have a mini-schedule, so update them all */
-	if (v->type == VEH_Aircraft) InvalidateAircraftWindows(v);
-	if (v->type == VEH_Ship) InvalidateShipWindows(v);
+	if (v->type == VEH_Aircraft) InvalidateWindowClasses(WC_AIRCRAFT_LIST);
+	if (v->type == VEH_Ship) InvalidateWindowClasses(WC_SHIPS_LIST);
 
 	return 0;
 }
--- a/ship_cmd.c	Mon Jan 17 22:44:33 2005 +0000
+++ b/ship_cmd.c	Tue Jan 18 09:35:31 2005 +0000
@@ -21,19 +21,6 @@
 	return r | r >> 8;
 }
 
-void InvalidateShipWindows(const Vehicle *v)
-{
-	const Order *order;
-
-	InvalidateWindow(WC_SHIPS_LIST, v->owner);
-
-	FOR_VEHICLE_ORDERS(v, order) {
-			if (order->type == OT_GOTO_STATION ) {
-			InvalidateWindow(WC_SHIPS_LIST, (order->station << 16) | v->owner);
-		}
-	}
-}
-
 void DrawShipEngine(int x, int y, int engine, uint32 image_ormod)
 {
 	int spritenum = ShipVehInfo(engine)->image_index;
@@ -159,6 +146,8 @@
 	SubtractMoneyFromPlayerFract(v->owner, cost);
 
 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
+	//we need this for the profit
+	InvalidateWindowClasses(WC_SHIPS_LIST);
 }
 
 static void HandleBrokenShip(Vehicle *v)
@@ -186,7 +175,7 @@
 	if (!(v->tick_counter & 1)) {
 		if (!--v->breakdown_delay) {
 			v->breakdown_ctr = 0;
-			InvalidateShipWindows(v);
+			InvalidateWindowClasses(WC_SHIPS_LIST);
 		}
 	}
 }
@@ -268,7 +257,7 @@
 
 	InvalidateVehicleOrder(v);
 
-	InvalidateShipWindows(v);
+	InvalidateWindowClasses(WC_SHIPS_LIST);
 }
 
 static void HandleShipLoading(Vehicle *v)
@@ -370,6 +359,7 @@
 
 	PlayShipSound(v);
 	VehicleServiceInDepot(v);
+	InvalidateWindowClasses(WC_SHIPS_LIST);
 }
 
 static bool ShipAccelerate(Vehicle *v)
@@ -443,6 +433,7 @@
 			}
 		}
 	}
+	InvalidateWindowClasses(WC_SHIPS_LIST);
 }
 
 static void ShipArrivesAt(Vehicle *v, Station *st)
@@ -931,7 +922,7 @@
 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 	}
 
-	InvalidateShipWindows(v);
+	InvalidateWindowClasses(WC_SHIPS_LIST);
 
 	return 0;
 }
--- a/ship_gui.c	Mon Jan 17 22:44:33 2005 +0000
+++ b/ship_gui.c	Tue Jan 18 09:35:31 2005 +0000
@@ -982,7 +982,7 @@
 			DrawVehicleProfitButton(v, x, y + 13);
 
 			SetDParam(0, v->unitnumber);
-			if (IsShipDepotTile(v->tile))
+			if (IsShipDepotTile(v->tile) && (v->vehstatus & VS_HIDDEN))
 				str = STR_021F;
 			else
 				str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
--- a/vehicle.h	Mon Jan 17 22:44:33 2005 +0000
+++ b/vehicle.h	Tue Jan 18 09:35:31 2005 +0000
@@ -333,9 +333,6 @@
 
 bool VehicleNeedsService(const Vehicle *v);
 
-void InvalidateAircraftWindows(const Vehicle *v);
-void InvalidateShipWindows(const Vehicle *v);
-
 typedef struct GetNewVehiclePosResult {
 	int x,y;
 	uint old_tile;