--- a/aircraft_cmd.c Tue Aug 22 16:59:51 2006 +0000
+++ b/aircraft_cmd.c Tue Aug 22 17:13:49 2006 +0000
@@ -1179,6 +1179,8 @@
break;
case OT_LOADING: return;
+
+ default: break;
}
if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0;
--- a/depot.c Tue Aug 22 16:59:51 2006 +0000
+++ b/depot.c Tue Aug 22 17:13:49 2006 +0000
@@ -79,7 +79,6 @@
*/
void DoDeleteDepot(TileIndex tile)
{
- Order order;
Depot *depot;
/* Get the depot */
@@ -92,9 +91,7 @@
depot->xy = 0;
/* Clear the depot from all order-lists */
- order.type = OT_GOTO_DEPOT;
- order.station = depot->index;
- DeleteDestinationFromVehicleOrder(order);
+ RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, depot->index);
/* Delete the depot-window */
DeleteWindowById(WC_VEHICLE_DEPOT, tile);
--- a/order.h Tue Aug 22 16:59:51 2006 +0000
+++ b/order.h Tue Aug 22 17:13:49 2006 +0000
@@ -10,7 +10,7 @@
#include "pool.h"
/* Order types */
-enum {
+typedef enum OrderTypes {
OT_NOTHING = 0,
OT_GOTO_STATION = 1,
OT_GOTO_DEPOT = 2,
@@ -18,7 +18,7 @@
OT_LEAVESTATION = 4,
OT_DUMMY = 5,
OT_GOTO_WAYPOINT = 6
-};
+} OrderType;
/* Order flags -- please use OFB instead OF and use HASBIT/SETBIT/CLEARBIT */
@@ -77,7 +77,7 @@
* - REF_SHEDULE (all REFs are currently limited to 16 bits!!)
*/
typedef struct Order {
- uint8 type;
+ OrderType type;
uint8 flags;
StationID station;
@@ -162,7 +162,7 @@
static inline Order UnpackOrder(uint32 packed)
{
Order order;
- order.type = GB(packed, 0, 8);
+ order.type = (OrderType)GB(packed, 0, 8);
order.flags = GB(packed, 8, 8);
order.station = GB(packed, 16, 16);
order.next = NULL;
@@ -173,7 +173,7 @@
/* Functions */
void BackupVehicleOrders(const Vehicle *v, BackuppedOrders *order);
void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* order);
-void DeleteDestinationFromVehicleOrder(Order dest);
+void RemoveOrderFromAllVehicles(OrderType type, StationID destination);
void InvalidateVehicleOrder(const Vehicle *v);
bool VehicleHasDepotOrders(const Vehicle *v);
void CheckOrders(const Vehicle*);
--- a/order_cmd.c Tue Aug 22 16:59:51 2006 +0000
+++ b/order_cmd.c Tue Aug 22 17:13:49 2006 +0000
@@ -953,13 +953,11 @@
}
/**
- *
- * Delete a destination (like station, waypoint, ..) from the orders of vehicles
- *
- * @param dest type and station has to be set. This order will be removed from all orders of vehicles
- *
+ * Removes an order from all vehicles. Triggers when, say, a station is removed.
+ * @param type The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]).
+ * @param destination The destination. Can be a StationID, DepotID or WaypointID.
*/
-void DeleteDestinationFromVehicleOrder(Order dest)
+void RemoveOrderFromAllVehicles(OrderType type, StationID destination)
{
Vehicle *v;
Order *order;
@@ -970,12 +968,11 @@
if (v->orders == NULL) continue;
/* Forget about this station if this station is removed */
- if (v->last_station_visited == dest.station && dest.type == OT_GOTO_STATION)
+ if (v->last_station_visited == destination && type == OT_GOTO_STATION)
v->last_station_visited = INVALID_STATION;
/* Check the current order */
- if (v->current_order.type == dest.type &&
- v->current_order.station == dest.station) {
+ if (v->current_order.type == type && v->current_order.station == destination) {
/* Mark the order as DUMMY */
v->current_order.type = OT_DUMMY;
v->current_order.flags = 0;
@@ -985,7 +982,7 @@
/* Clear the order from the order-list */
need_invalidate = false;
FOR_VEHICLE_ORDERS(v, order) {
- if (order->type == dest.type && order->station == dest.station) {
+ if (order->type == type && order->station == destination) {
/* Mark the order as DUMMY */
order->type = OT_DUMMY;
order->flags = 0;
--- a/order_gui.c Tue Aug 22 16:59:51 2006 +0000
+++ b/order_gui.c Tue Aug 22 17:13:49 2006 +0000
@@ -164,6 +164,8 @@
SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
SetDParam(2, order->station);
break;
+
+ default: break;
}
color = (i == WP(w,order_d).sel) ? 0xC : 0x10;
--- a/roadveh_cmd.c Tue Aug 22 16:59:51 2006 +0000
+++ b/roadveh_cmd.c Tue Aug 22 17:13:49 2006 +0000
@@ -631,6 +631,8 @@
case OT_LOADING:
case OT_LEAVESTATION:
return;
+
+ default: break;
}
if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0;
--- a/ship_cmd.c Tue Aug 22 16:59:51 2006 +0000
+++ b/ship_cmd.c Tue Aug 22 17:13:49 2006 +0000
@@ -212,6 +212,8 @@
case OT_LOADING:
case OT_LEAVESTATION:
return;
+
+ default: break;
}
if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0;
--- a/station_cmd.c Tue Aug 22 16:59:51 2006 +0000
+++ b/station_cmd.c Tue Aug 22 17:13:49 2006 +0000
@@ -2399,7 +2399,6 @@
*/
static void DeleteStation(Station *st)
{
- Order order;
StationID index;
Vehicle *v;
st->xy = 0;
@@ -2412,10 +2411,8 @@
index = st->index;
DeleteWindowById(WC_STATION_VIEW, index);
- //Now delete all orders that go to the station
- order.type = OT_GOTO_STATION;
- order.station = index;
- DeleteDestinationFromVehicleOrder(order);
+ /* Now delete all orders that go to the station */
+ RemoveOrderFromAllVehicles(OT_GOTO_STATION, index);
//And do the same with aircraft that have the station as a hangar-stop
FOR_ALL_VEHICLES(v) {
--- a/train_cmd.c Tue Aug 22 16:59:51 2006 +0000
+++ b/train_cmd.c Tue Aug 22 17:13:49 2006 +0000
@@ -2397,6 +2397,8 @@
case OT_LOADING:
case OT_LEAVESTATION:
return false;
+
+ default: break;
}
// check if we've reached the waypoint?
--- a/waypoint.c Tue Aug 22 16:59:51 2006 +0000
+++ b/waypoint.c Tue Aug 22 17:13:49 2006 +0000
@@ -247,13 +247,9 @@
/* Internal handler to delete a waypoint */
static void DoDeleteWaypoint(Waypoint *wp)
{
- Order order;
-
wp->xy = 0;
- order.type = OT_GOTO_WAYPOINT;
- order.station = wp->index;
- DeleteDestinationFromVehicleOrder(order);
+ RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, wp->index);
if (wp->string != STR_NULL) DeleteName(wp->string);