(svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
authorcelestar
Sun, 20 Mar 2005 08:43:29 +0000
changeset 1530 caa16c506a22
parent 1529 be4a2259d2ff
child 1531 4ee3c51e2b32
(svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
aircraft_cmd.c
order.h
order_gui.c
roadveh_cmd.c
ship_cmd.c
train_cmd.c
--- a/aircraft_cmd.c	Sun Mar 20 00:32:26 2005 +0000
+++ b/aircraft_cmd.c	Sun Mar 20 08:43:29 2005 +0000
@@ -575,7 +575,7 @@
 		return;
 
 	if (v->current_order.type == OT_GOTO_DEPOT &&
-			v->current_order.flags & OF_FULL_LOAD)
+			v->current_order.flags & OF_HALT_IN_DEPOT)
 		return;
 
 	if (_patches.gotodepot && VehicleHasDepotOrders(v))
@@ -1313,9 +1313,9 @@
 		v->current_order.type = OT_NOTHING;
 		v->current_order.flags = 0;
 
-		if (old_order.flags & OF_UNLOAD) {
+		if (HASBIT(old_order.flags, OFB_PART_OF_ORDERS)) {
 			v->cur_order_index++;
-		} else if (old_order.flags & OF_FULL_LOAD) { // force depot visit
+		} else if (HASBIT(old_order.flags, OFB_HALT_IN_DEPOT)) { // force depot visit
 			v->vehstatus |= VS_STOPPED;
 			InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 
--- a/order.h	Sun Mar 20 00:32:26 2005 +0000
+++ b/order.h	Sun Mar 20 08:43:29 2005 +0000
@@ -16,16 +16,25 @@
 
 /* Order flags -- please use OFB instead OF and use HASBIT/SETBIT/CLEARBIT */
 enum {
-	OF_UNLOAD    = 0x2,
-	OF_FULL_LOAD = 0x4, // Also used when to force an aircraft into a depot
+	//Flags for stations:
+	OF_UNLOAD         = 0x2,
+	OF_FULL_LOAD      = 0x4, // Also used when to force an aircraft into a depot
+
+	//Flags for depots:
+	OF_PART_OF_ORDERS	= 0x2,
+	OF_HALT_IN_DEPOT  = 0x4,
+
+	//Common flags
 	OF_NON_STOP  = 0x8
 };
 
 /* Order flags bits */
 enum {
-	OFB_UNLOAD    = 1,
-	OFB_FULL_LOAD = 2,
-	OFB_NON_STOP  = 3
+	OFB_UNLOAD         = 1,
+	OFB_FULL_LOAD      = 2,
+	OFB_PART_OF_ORDERS = 1,
+	OFB_HALT_IN_DEPOT  = 2,
+	OFB_NON_STOP       = 3
 };
 
 /* Possible clone options */
--- a/order_gui.c	Sun Mar 20 00:32:26 2005 +0000
+++ b/order_gui.c	Sun Mar 20 08:43:29 2005 +0000
@@ -167,7 +167,7 @@
 			if (v->type == VEH_Train && _map_owner[tile] == _local_player) {
 				if ((_map5[tile]&0xFC)==0xC0) {
 					order.type = OT_GOTO_DEPOT;
-					order.flags = OF_UNLOAD;
+					order.flags = OF_PART_OF_ORDERS;
 					order.station = GetDepotByTile(tile)->index;
 					return order;
 				}
@@ -177,7 +177,7 @@
 		case MP_STREET:
 			if ((_map5[tile] & 0xF0) == 0x20 && v->type == VEH_Road && _map_owner[tile] == _local_player) {
 				order.type = OT_GOTO_DEPOT;
-				order.flags = OF_UNLOAD;
+				order.flags = OF_PART_OF_ORDERS;
 				order.station = GetDepotByTile(tile)->index;
 				return order;
 			}
@@ -187,7 +187,7 @@
 			if (v->type != VEH_Aircraft) break;
 			if ( IsAircraftHangarTile(tile) && _map_owner[tile] == _local_player) {
 				order.type = OT_GOTO_DEPOT;
-				order.flags = OF_UNLOAD | OF_NON_STOP;
+				order.flags = OF_PART_OF_ORDERS | OF_NON_STOP;	//XXX - whats the nonstop stuff doing here?
 				order.station = _map2[tile];
 				return order;
 			}
@@ -202,7 +202,7 @@
 				case 0x83: tile-= TILE_XY(0,1); break;
 				}
 				order.type = OT_GOTO_DEPOT;
-				order.flags = OF_UNLOAD;
+				order.flags = OF_PART_OF_ORDERS;
 				order.station = GetDepotByTile(tile)->index;
 				return order;
 			}
--- a/roadveh_cmd.c	Sun Mar 20 00:32:26 2005 +0000
+++ b/roadveh_cmd.c	Sun Mar 20 08:43:29 2005 +0000
@@ -334,8 +334,10 @@
 
 	if (v->current_order.type == OT_GOTO_DEPOT) {
 		if (flags & DC_EXEC) {
-			if (v->current_order.flags & OF_UNLOAD)
+
+			if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS))
 				v->cur_order_index++;
+
 			v->current_order.type = OT_DUMMY;
 			v->current_order.flags = 0;
 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
@@ -349,7 +351,7 @@
 
 	if (flags & DC_EXEC) {
 		v->current_order.type = OT_GOTO_DEPOT;
-		v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD;
+		v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT;
 		v->current_order.station = depot->index;
 		v->dest_tile = depot->xy;
 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
@@ -1531,9 +1533,9 @@
 		v->current_order.flags = 0;
 
 		// Part of the orderlist?
-		if (t.flags & OF_UNLOAD) {
+		if (HASBIT(t.flags, OFB_PART_OF_ORDERS)) {
 			v->cur_order_index++;
-		} else if (t.flags & OF_FULL_LOAD) {
+		} else if (HASBIT(t.flags, OFB_HALT_IN_DEPOT)) {
 			v->vehstatus |= VS_STOPPED;
 			if (v->owner == _local_player) {
 				SetDParam(0, v->unitnumber);
@@ -1583,7 +1585,7 @@
 	// Don't interfere with a depot visit scheduled by the user, or a
 	// depot visit by the order list.
 	if (v->current_order.type == OT_GOTO_DEPOT &&
-			(v->current_order.flags & (OF_FULL_LOAD | OF_UNLOAD)) != 0)
+			(v->current_order.flags & (OF_HALT_IN_DEPOT | OF_PART_OF_ORDERS)) != 0)
 		return;
 
 	//If we already got a slot at a stop, use that FIRST, and go to a depot later
--- a/ship_cmd.c	Sun Mar 20 00:32:26 2005 +0000
+++ b/ship_cmd.c	Sun Mar 20 08:43:29 2005 +0000
@@ -108,7 +108,7 @@
 		return;
 
 	if (v->current_order.type == OT_GOTO_DEPOT &&
-			v->current_order.flags & OF_FULL_LOAD)
+			v->current_order.flags & OF_HALT_IN_DEPOT)
 		return;
 
 	if (_patches.gotodepot && VehicleHasDepotOrders(v))
@@ -430,9 +430,9 @@
 		v->current_order.type = OT_DUMMY;
 		v->current_order.flags = 0;
 
-		if (t.flags & OF_UNLOAD) {
+		if (HASBIT(t.flags, OFB_PART_OF_ORDERS)) {
 			v->cur_order_index++;
-		} else if (t.flags & OF_FULL_LOAD) {
+		} else if (HASBIT(t.flags, OFB_HALT_IN_DEPOT)) {
 			v->vehstatus |= VS_STOPPED;
 			if (v->owner == _local_player) {
 				SetDParam(0, v->unitnumber);
@@ -993,7 +993,10 @@
 
 	if (v->current_order.type == OT_GOTO_DEPOT) {
 		if (flags & DC_EXEC) {
-			if (v->current_order.flags & OF_UNLOAD) v->cur_order_index++;
+
+			if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS))
+				v->cur_order_index++;
+
 			v->current_order.type = OT_DUMMY;
 			v->current_order.flags = 0;
 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
@@ -1006,7 +1009,7 @@
 		if (flags & DC_EXEC) {
 			v->dest_tile = depot->xy;
 			v->current_order.type = OT_GOTO_DEPOT;
-			v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD;
+			v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT;
 			v->current_order.station = depot->index;
 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		}
--- a/train_cmd.c	Sun Mar 20 00:32:26 2005 +0000
+++ b/train_cmd.c	Sun Mar 20 08:43:29 2005 +0000
@@ -1353,7 +1353,7 @@
 
 	if (v->current_order.type == OT_GOTO_DEPOT) {
 		if (flags & DC_EXEC) {
-			if (v->current_order.flags & OF_UNLOAD) {
+			if (HASBIT(v->current_order.flags, OF_PART_OF_ORDERS)) {
 				v->u.rail.days_since_order_progr = 0;
 				v->cur_order_index++;
 			}
@@ -2956,10 +2956,10 @@
 		v->current_order.type = OT_DUMMY;
 		v->current_order.flags = 0;
 
-		if (t.flags & OF_UNLOAD) { // Part of the orderlist?
+		if (HASBIT(t.flags, OFB_PART_OF_ORDERS)) { // Part of the orderlist?
 			v->u.rail.days_since_order_progr = 0;
 			v->cur_order_index++;
-		} else if (t.flags & OF_FULL_LOAD) { // User initiated?
+		} else if (HASBIT(t.flags, OFB_HALT_IN_DEPOT)) { // User initiated?
 			v->vehstatus |= VS_STOPPED;
 			if (v->owner == _local_player) {
 				SetDParam(0, v->unitnumber);
@@ -2995,7 +2995,7 @@
 	// Don't interfere with a depot visit scheduled by the user, or a
 	// depot visit by the order list.
 	if (v->current_order.type == OT_GOTO_DEPOT &&
-			(v->current_order.flags & (OF_FULL_LOAD | OF_UNLOAD)) != 0)
+			(v->current_order.flags & (OF_HALT_IN_DEPOT | OF_PART_OF_ORDERS)) != 0)
 		return;
 
 	tfdd = FindClosestTrainDepot(v);