(svn r6295) -Feature: using goto depot with a different control selection will now alter the service/stopping in depot flag instead of cancelling the goto depot order
authorbjarni
Fri, 01 Sep 2006 12:37:03 +0000
changeset 4510 071bca98c577
parent 4509 ad99f5ff4e8d
child 4511 111a4b4f2143
(svn r6295) -Feature: using goto depot with a different control selection will now alter the service/stopping in depot flag instead of cancelling the goto depot order
aircraft_cmd.c
roadveh_cmd.c
ship_cmd.c
train_cmd.c
--- a/aircraft_cmd.c	Fri Sep 01 11:01:44 2006 +0000
+++ b/aircraft_cmd.c	Fri Sep 01 12:37:03 2006 +0000
@@ -512,6 +512,17 @@
 	if (v->type != VEH_Aircraft || !CheckOwnership(v->owner)) return CMD_ERROR;
 
 	if (v->current_order.type == OT_GOTO_DEPOT && !(p2 & DEPOT_LOCATE_HANGAR)) {
+		if ((p2 & DEPOT_SERVICE) == (bool)HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
+			/* We called with a different DEPOT_SERVICE setting.
+			 * Now we change the setting to apply the new one and let the vehicle head for the same hangar.
+			 * Note: the if is (true for requesting service == true for ordered to stop in hangar)          */
+			if (flags & DC_EXEC) {
+				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
+				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
+			}
+			return 0;
+		}
+
 		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of hangar orders
 		if (flags & DC_EXEC) {
 			if (v->current_order.flags & OF_UNLOAD) v->cur_order_index++;
--- a/roadveh_cmd.c	Fri Sep 01 11:01:44 2006 +0000
+++ b/roadveh_cmd.c	Fri Sep 01 12:37:03 2006 +0000
@@ -382,6 +382,17 @@
 
 	/* If the current orders are already goto-depot */
 	if (v->current_order.type == OT_GOTO_DEPOT) {
+		if ((p2 & DEPOT_SERVICE) == (bool)HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
+			/* We called with a different DEPOT_SERVICE setting.
+			* Now we change the setting to apply the new one and let the vehicle head for the same depot.
+			* Note: the if is (true for requesting service == true for ordered to stop in depot)          */
+			if (flags & DC_EXEC) {
+				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
+				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
+			}
+			return 0;
+		}
+
 		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
 		if (flags & DC_EXEC) {
 			/* If the orders to 'goto depot' are in the orders list (forced servicing),
--- a/ship_cmd.c	Fri Sep 01 11:01:44 2006 +0000
+++ b/ship_cmd.c	Fri Sep 01 12:37:03 2006 +0000
@@ -1020,6 +1020,17 @@
 
 	/* If the current orders are already goto-depot */
 	if (v->current_order.type == OT_GOTO_DEPOT) {
+		if ((p2 & DEPOT_SERVICE) == (bool)HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
+			/* We called with a different DEPOT_SERVICE setting.
+			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
+			 * Note: the if is (true for requesting service == true for ordered to stop in depot)          */
+			if (flags & DC_EXEC) {
+				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
+				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
+			}
+			return 0;
+		}
+
 		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
 		if (flags & DC_EXEC) {
 			/* If the orders to 'goto depot' are in the orders list (forced servicing),
--- a/train_cmd.c	Fri Sep 01 11:01:44 2006 +0000
+++ b/train_cmd.c	Fri Sep 01 12:37:03 2006 +0000
@@ -1948,6 +1948,17 @@
 	if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
 
 	if (v->current_order.type == OT_GOTO_DEPOT) {
+		if ((p2 & DEPOT_SERVICE) == (bool)HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
+			/* We called with a different DEPOT_SERVICE setting.
+			* Now we change the setting to apply the new one and let the vehicle head for the same depot.
+			* Note: the if is (true for requesting service == true for ordered to stop in depot)          */
+			if (flags & DC_EXEC) {
+				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
+				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
+			}
+			return 0;
+		}
+
 		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
 		if (flags & DC_EXEC) {
 			if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS)) {