src/order_cmd.cpp
branchnoai
changeset 9722 ebf0ece7d8f6
parent 9704 197cb8c6ae17
child 9723 eee46cb39750
equal deleted inserted replaced
9721:9a27928bcd5e 9722:ebf0ece7d8f6
   505 			assert(v->orders == u->orders);
   505 			assert(v->orders == u->orders);
   506 
   506 
   507 			/* NON-stop flag is misused to see if a train is in a station that is
   507 			/* NON-stop flag is misused to see if a train is in a station that is
   508 			 * on his order list or not */
   508 			 * on his order list or not */
   509 			if (sel_ord == u->cur_order_index && u->current_order.type == OT_LOADING &&
   509 			if (sel_ord == u->cur_order_index && u->current_order.type == OT_LOADING &&
   510 					HASBIT(u->current_order.flags, OFB_NON_STOP)) {
   510 					HasBit(u->current_order.flags, OFB_NON_STOP)) {
   511 				u->current_order.flags = 0;
   511 				u->current_order.flags = 0;
   512 			}
   512 			}
   513 
   513 
   514 			/* Update any possible open window of the vehicle */
   514 			/* Update any possible open window of the vehicle */
   515 			InvalidateVehicleOrder(u);
   515 			InvalidateVehicleOrder(u);
   547 
   547 
   548 		if (v->current_order.type == OT_LOADING) {
   548 		if (v->current_order.type == OT_LOADING) {
   549 			v->LeaveStation();
   549 			v->LeaveStation();
   550 			/* NON-stop flag is misused to see if a train is in a station that is
   550 			/* NON-stop flag is misused to see if a train is in a station that is
   551 			 * on his order list or not */
   551 			 * on his order list or not */
   552 			if (HASBIT(v->current_order.flags, OFB_NON_STOP)) v->current_order.flags = 0;
   552 			if (HasBit(v->current_order.flags, OFB_NON_STOP)) v->current_order.flags = 0;
   553 		}
   553 		}
   554 
   554 
   555 		InvalidateVehicleOrder(v);
   555 		InvalidateVehicleOrder(v);
   556 	}
   556 	}
   557 
   557 
   683 	}
   683 	}
   684 
   684 
   685 	if (flags & DC_EXEC) {
   685 	if (flags & DC_EXEC) {
   686 		switch (p2) {
   686 		switch (p2) {
   687 		case OFB_FULL_LOAD:
   687 		case OFB_FULL_LOAD:
   688 			TOGGLEBIT(order->flags, OFB_FULL_LOAD);
   688 			ToggleBit(order->flags, OFB_FULL_LOAD);
   689 			if (order->type != OT_GOTO_DEPOT) CLRBIT(order->flags, OFB_UNLOAD);
   689 			if (order->type != OT_GOTO_DEPOT) ClrBit(order->flags, OFB_UNLOAD);
   690 			break;
   690 			break;
   691 		case OFB_UNLOAD:
   691 		case OFB_UNLOAD:
   692 			TOGGLEBIT(order->flags, OFB_UNLOAD);
   692 			ToggleBit(order->flags, OFB_UNLOAD);
   693 			CLRBIT(order->flags, OFB_FULL_LOAD);
   693 			ClrBit(order->flags, OFB_FULL_LOAD);
   694 			break;
   694 			break;
   695 		case OFB_NON_STOP:
   695 		case OFB_NON_STOP:
   696 			TOGGLEBIT(order->flags, OFB_NON_STOP);
   696 			ToggleBit(order->flags, OFB_NON_STOP);
   697 			break;
   697 			break;
   698 		case OFB_TRANSFER:
   698 		case OFB_TRANSFER:
   699 			TOGGLEBIT(order->flags, OFB_TRANSFER);
   699 			ToggleBit(order->flags, OFB_TRANSFER);
   700 			break;
   700 			break;
   701 		default: NOT_REACHED();
   701 		default: NOT_REACHED();
   702 		}
   702 		}
   703 
   703 
   704 		/* Update the windows and full load flags, also for vehicles that share the same order list */
   704 		/* Update the windows and full load flags, also for vehicles that share the same order list */
   717 				 * so do not care and those orders should not be active
   717 				 * so do not care and those orders should not be active
   718 				 * when this function is called.
   718 				 * when this function is called.
   719 				 */
   719 				 */
   720 				if (sel_ord == u->cur_order_index &&
   720 				if (sel_ord == u->cur_order_index &&
   721 						u->current_order.type != OT_GOTO_DEPOT &&
   721 						u->current_order.type != OT_GOTO_DEPOT &&
   722 						HASBIT(u->current_order.flags, OFB_FULL_LOAD) != HASBIT(order->flags, OFB_FULL_LOAD)) {
   722 						HasBit(u->current_order.flags, OFB_FULL_LOAD) != HasBit(order->flags, OFB_FULL_LOAD)) {
   723 					TOGGLEBIT(u->current_order.flags, OFB_FULL_LOAD);
   723 					ToggleBit(u->current_order.flags, OFB_FULL_LOAD);
   724 				}
   724 				}
   725 				InvalidateVehicleOrder(u);
   725 				InvalidateVehicleOrder(u);
   726 			}
   726 			}
   727 		}
   727 		}
   728 	}
   728 	}
   900 		for (; u != NULL; u = u->next_shared) {
   900 		for (; u != NULL; u = u->next_shared) {
   901 			/* Update any possible open window of the vehicle */
   901 			/* Update any possible open window of the vehicle */
   902 			InvalidateVehicleOrder(u);
   902 			InvalidateVehicleOrder(u);
   903 
   903 
   904 			/* If the vehicle already got the current depot set as current order, then update current order as well */
   904 			/* If the vehicle already got the current depot set as current order, then update current order as well */
   905 			if (u->cur_order_index == order_number && HASBIT(u->current_order.flags, OFB_PART_OF_ORDERS)) {
   905 			if (u->cur_order_index == order_number && HasBit(u->current_order.flags, OFB_PART_OF_ORDERS)) {
   906 				u->current_order.refit_cargo = cargo;
   906 				u->current_order.refit_cargo = cargo;
   907 				u->current_order.refit_subtype = subtype;
   907 				u->current_order.refit_subtype = subtype;
   908 			}
   908 			}
   909 		}
   909 		}
   910 	}
   910 	}
   982 	}
   982 	}
   983 
   983 
   984 	/* If we had shared orders, recover that */
   984 	/* If we had shared orders, recover that */
   985 	if (bak->clone != INVALID_VEHICLE) {
   985 	if (bak->clone != INVALID_VEHICLE) {
   986 		DoCommandP(0, v->index | (bak->clone << 16), 0, NULL, CMD_CLONE_ORDER);
   986 		DoCommandP(0, v->index | (bak->clone << 16), 0, NULL, CMD_CLONE_ORDER);
   987 		return;
   987 	} else {
   988 	}
   988 
   989 
   989 		/* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the
   990 	/* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the
   990 		 *  order number is one more than the current amount of orders, and because
   991 	 *  order number is one more than the current amount of orders, and because
   991 		 *  in network the commands are queued before send, the second insert always
   992 	 *  in network the commands are queued before send, the second insert always
   992 		 *  fails in test mode. By bypassing the test-mode, that no longer is a problem. */
   993 	 *  fails in test mode. By bypassing the test-mode, that no longer is a problem. */
   993 		for (uint i = 0; bak->order[i].IsValid(); i++) {
   994 	for (uint i = 0; bak->order[i].IsValid(); i++) {
   994 			if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL,
   995 		if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK))
   995 					CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK))
   996 			break;
   996 				break;
       
   997 		}
   997 	}
   998 	}
   998 
   999 
   999 	/* Restore vehicle order-index and service interval */
  1000 	/* Restore vehicle order-index and service interval */
  1000 	DoCommandP(0, v->index, bak->orderindex | (bak->service_interval << 16) , NULL, CMD_RESTORE_ORDER_INDEX);
  1001 	DoCommandP(0, v->index, bak->orderindex | (bak->service_interval << 16) , NULL, CMD_RESTORE_ORDER_INDEX);
  1001 }
  1002 }