summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2005-01-15 09:28:08 +0000
committercelestar <celestar@openttd.org>2005-01-15 09:28:08 +0000
commit02ed8410a24c1bb1619f0e13a97bd78265355cbd (patch)
treec6a836c94525b32278cec41cf3492cfdb6d8c481
parent3279a7c9a26242f5f0a8e4b41ae6e2d9e24ee169 (diff)
downloadopenttd-02ed8410a24c1bb1619f0e13a97bd78265355cbd.tar.xz
(svn r1521) -Fix: Ship Vehicle Lists are now redrawn correctly
-Codechange: added some const to last commit -Codechange: Ship and Aircraft lists are now update on order change, not on new day
-rw-r--r--aircraft_cmd.c10
-rw-r--r--order_cmd.c11
-rw-r--r--ship_cmd.c20
-rw-r--r--vehicle.h3
4 files changed, 35 insertions, 9 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 5157e5f61..4fa94a345 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -508,13 +508,13 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
}
}
-void InvalidateAircraftWindows(Vehicle *v)
+void InvalidateAircraftWindows(const Vehicle *v)
{
- Order *o;
+ const Order *o;
InvalidateWindow(WC_AIRCRAFT_LIST, v->owner);
- for ( o = v->schedule_ptr; o->type != OT_NOTHING; o++, i++) {
+ for ( o = v->schedule_ptr; o->type != OT_NOTHING; o++) {
if (o->type == OT_GOTO_STATION ) {
InvalidateWindow(WC_AIRCRAFT_LIST, o->station << 16 | v->owner);
}
@@ -548,8 +548,6 @@ void OnNewDay_Aircraft(Vehicle *v)
SubtractMoneyFromPlayerFract(v->owner, cost);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
-
- InvalidateAircraftWindows(v);
}
void AircraftYearlyLoop()
@@ -1084,6 +1082,8 @@ static void ProcessAircraftOrder(Vehicle *v)
}
InvalidateVehicleOrderWidget(v);
+
+ InvalidateAircraftWindows(v);
}
static void HandleAircraftLoading(Vehicle *v, int mode)
diff --git a/order_cmd.c b/order_cmd.c
index d7a7abb3c..7332b0513 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -140,9 +140,9 @@ int32 CmdDeleteOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* p1 = vehicle */
int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
- if (flags & DC_EXEC) {
- Vehicle *v = GetVehicle(p1);
+ Vehicle *v = GetVehicle(p1);
+ if (flags & DC_EXEC) {
{
byte b = v->cur_order_index + 1;
if (b >= v->num_orders) b = 0;
@@ -159,6 +159,13 @@ int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
InvalidateWindow(WC_VEHICLE_ORDERS, v->index);
}
+
+ //we have an aircraft, they have a mini-schedule, so update them all
+ if (v->type == VEH_Aircraft) InvalidateAircraftWindows(v);
+
+ //same goes for ships
+ if (v->type == VEH_Ship) InvalidateShipWindows(v);
+
return 0;
}
diff --git a/ship_cmd.c b/ship_cmd.c
index dc6587a30..3ed827fa1 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -21,6 +21,19 @@ static byte GetTileShipTrackStatus(uint tile) {
return r | r >> 8;
}
+void InvalidateShipWindows(const Vehicle *v)
+{
+ const Order *o;
+
+ InvalidateWindow(WC_SHIPS_LIST, v->owner);
+
+ for ( o = v->schedule_ptr; o->type != OT_NOTHING; o++) {
+ if (o->type == OT_GOTO_STATION ) {
+ InvalidateWindow(WC_SHIPS_LIST, o->station << 16 | v->owner);
+ }
+ }
+}
+
void DrawShipEngine(int x, int y, int engine, uint32 image_ormod)
{
int spritenum = ShipVehInfo(engine)->image_index;
@@ -146,7 +159,6 @@ void OnNewDay_Ship(Vehicle *v)
SubtractMoneyFromPlayerFract(v->owner, cost);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
- InvalidateWindow(WC_SHIPS_LIST, v->owner);
}
static void HandleBrokenShip(Vehicle *v)
@@ -174,7 +186,7 @@ static void HandleBrokenShip(Vehicle *v)
if (!(v->tick_counter & 1)) {
if (!--v->breakdown_delay) {
v->breakdown_ctr = 0;
- InvalidateWindow(WC_VEHICLE_VIEW, v->index);
+ InvalidateShipWindows(v);
}
}
}
@@ -253,6 +265,8 @@ static void ProcessShipOrder(Vehicle *v)
v->dest_tile = 0;
}
InvalidateVehicleOrderWidget(v);
+
+ InvalidateShipWindows(v);
}
static void HandleShipLoading(Vehicle *v)
@@ -918,6 +932,8 @@ int32 CmdStartStopShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
}
+ InvalidateShipWindows(v);
+
return 0;
}
diff --git a/vehicle.h b/vehicle.h
index 0ac1ceaf0..bdc9ca853 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -402,6 +402,9 @@ int CheckOrders(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;