Mercurial > hg > openttd
changeset 4351:de3ee63f64c0 draft
(svn r6052) -Codechange: change OrderType (order->type) in a typedef
-Codechange: renamed DeleteDestinationFromVehicleOrder to RemoveOrderFromAllVehicles to reflect his function better
-Codechange: changed the params of RemoveOrderFromAllVehicles, to avoid unneeded variable-creation
author | truelight <truelight@openttd.org> |
---|---|
date | Tue, 22 Aug 2006 17:13:49 +0000 |
parents | 5c73f683aa63 |
children | 8ee35b76f02e |
files | aircraft_cmd.c depot.c order.h order_cmd.c order_gui.c roadveh_cmd.c ship_cmd.c station_cmd.c train_cmd.c waypoint.c |
diffstat | 10 files changed, 26 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -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 +++ b/depot.c @@ -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 +++ b/order.h @@ -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 +++ b/order_cmd.c @@ -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 +++ b/order_gui.c @@ -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 +++ b/roadveh_cmd.c @@ -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 +++ b/ship_cmd.c @@ -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 +++ b/station_cmd.c @@ -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 +++ b/train_cmd.c @@ -2397,6 +2397,8 @@ case OT_LOADING: case OT_LEAVESTATION: return false; + + default: break; } // check if we've reached the waypoint?
--- a/waypoint.c +++ b/waypoint.c @@ -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);