summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCelestar <celestar@openttd.org>2005-01-18 09:35:31 +0000
committerCelestar <celestar@openttd.org>2005-01-18 09:35:31 +0000
commit5bcf3d2bc0620a40728ebb2c0dcbe34fcd6f5084 (patch)
tree467646e7683ed0d5f231399fd0dcc03e2443fb57
parent4559279686fd95be1d78ba3933efb76ffd476458 (diff)
downloadopenttd-5bcf3d2bc0620a40728ebb2c0dcbe34fcd6f5084.tar.xz
(svn r1556) -Fix: Vehicle list updates should now really work
-rw-r--r--aircraft_cmd.c23
-rw-r--r--aircraft_gui.c2
-rw-r--r--order_cmd.c4
-rw-r--r--ship_cmd.c23
-rw-r--r--ship_gui.c2
-rw-r--r--vehicle.h3
6 files changed, 19 insertions, 38 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 06adeca0e..85384c6c0 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -299,6 +299,7 @@ static void DoDeleteAircraft(Vehicle *v)
RebuildVehicleLists();
InvalidateWindow(WC_COMPANY, v->owner);
DeleteVehicleChain(v);
+ InvalidateWindowClasses(WC_AIRCRAFT_LIST);
}
// p1 = vehicle
@@ -343,6 +344,7 @@ int32 CmdStartStopAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
}
}
-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 @@ void OnNewDay_Aircraft(Vehicle *v)
SubtractMoneyFromPlayerFract(v->owner, cost);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
+ InvalidateWindowClasses(WC_AIRCRAFT_LIST);
}
void AircraftYearlyLoop()
@@ -1068,7 +1058,7 @@ static void ProcessAircraftOrder(Vehicle *v)
InvalidateVehicleOrder(v);
- InvalidateAircraftWindows(v);
+ InvalidateWindowClasses(WC_AIRCRAFT_LIST);
}
static void HandleAircraftLoading(Vehicle *v, int mode)
@@ -1206,6 +1196,7 @@ static void AircraftEntersTerminal(Vehicle *v)
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 @@ static void AircraftEnterHangar(Vehicle *v)
Order old_order;
ServiceAircraft(v);
+ InvalidateWindowClasses(WC_AIRCRAFT_LIST);
MaybeReplaceVehicle(v);
@@ -1229,7 +1221,7 @@ static void AircraftEnterHangar(Vehicle *v)
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 @@ static void AircraftLeaveHangar(Vehicle *v)
VehicleServiceInDepot(v);
SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
+ InvalidateWindowClasses(WC_AIRCRAFT_LIST);
}
diff --git a/aircraft_gui.c b/aircraft_gui.c
index a08957477..c06485e25 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -1034,7 +1034,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
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;
diff --git a/order_cmd.c b/order_cmd.c
index 24fe6809b..401e24499 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -343,8 +343,8 @@ int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 vehicle_id, uint32 not_use
}
/* 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;
}
diff --git a/ship_cmd.c b/ship_cmd.c
index 9b0233e93..522ba870d 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -21,19 +21,6 @@ static byte GetTileShipTrackStatus(uint tile) {
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 @@ void OnNewDay_Ship(Vehicle *v)
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 @@ static void HandleBrokenShip(Vehicle *v)
if (!(v->tick_counter & 1)) {
if (!--v->breakdown_delay) {
v->breakdown_ctr = 0;
- InvalidateShipWindows(v);
+ InvalidateWindowClasses(WC_SHIPS_LIST);
}
}
}
@@ -268,7 +257,7 @@ static void ProcessShipOrder(Vehicle *v)
InvalidateVehicleOrder(v);
- InvalidateShipWindows(v);
+ InvalidateWindowClasses(WC_SHIPS_LIST);
}
static void HandleShipLoading(Vehicle *v)
@@ -370,6 +359,7 @@ static void CheckShipLeaveDepot(Vehicle *v)
PlayShipSound(v);
VehicleServiceInDepot(v);
+ InvalidateWindowClasses(WC_SHIPS_LIST);
}
static bool ShipAccelerate(Vehicle *v)
@@ -443,6 +433,7 @@ static void ShipEnterDepot(Vehicle *v)
}
}
}
+ InvalidateWindowClasses(WC_SHIPS_LIST);
}
static void ShipArrivesAt(Vehicle *v, Station *st)
@@ -931,7 +922,7 @@ int32 CmdStartStopShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
}
- InvalidateShipWindows(v);
+ InvalidateWindowClasses(WC_SHIPS_LIST);
return 0;
}
diff --git a/ship_gui.c b/ship_gui.c
index 92b6cffd0..829a6ccf3 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -982,7 +982,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
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;
diff --git a/vehicle.h b/vehicle.h
index 8a0aae4bd..864d382cf 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -333,9 +333,6 @@ int CheckStoppedInDepot(Vehicle *v);
bool VehicleNeedsService(const Vehicle *v);
-void InvalidateAircraftWindows(const Vehicle *v);
-void InvalidateShipWindows(const Vehicle *v);
-
typedef struct GetNewVehiclePosResult {
int x,y;
uint old_tile;