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