src/order_cmd.cpp
changeset 8845 f9ef3bb70e47
parent 8843 45fdf630deaa
child 8847 426dd2d582e7
equal deleted inserted replaced
8844:acb298434295 8845:f9ef3bb70e47
   300 					break;
   300 					break;
   301 
   301 
   302 				default: return CMD_ERROR;
   302 				default: return CMD_ERROR;
   303 			}
   303 			}
   304 
   304 
       
   305 			if (new_order.GetNonStopType() != OFB_NO_NON_STOP && v->type != VEH_TRAIN) return CMD_ERROR;
       
   306 
   305 			/* Order flags can be any of the following for stations:
   307 			/* Order flags can be any of the following for stations:
   306 			 * [full-load | unload] [+ transfer] [+ non-stop]
   308 			 * [full-load | unload] [+ transfer] [+ non-stop]
   307 			 * non-stop orders (if any) are only valid for trains */
   309 			 * non-stop orders (if any) are only valid for trains */
   308 			switch (new_order.flags) {
   310 			switch (new_order.GetLoadType() | new_order.GetUnloadType()) {
   309 				case 0:
   311 				case 0:
   310 				case OFB_FULL_LOAD:
   312 				case OFB_FULL_LOAD:
   311 				case OFB_FULL_LOAD | OFB_TRANSFER:
   313 				case OFB_FULL_LOAD | OFB_TRANSFER:
   312 				case OFB_UNLOAD:
   314 				case OFB_UNLOAD:
   313 				case OFB_UNLOAD | OFB_TRANSFER:
   315 				case OFB_UNLOAD | OFB_TRANSFER:
   314 				case OFB_TRANSFER:
   316 				case OFB_TRANSFER:
   315 					break;
       
   316 
       
   317 				case OFB_NON_STOP:
       
   318 				case OFB_NON_STOP | OFB_FULL_LOAD:
       
   319 				case OFB_NON_STOP | OFB_FULL_LOAD | OFB_TRANSFER:
       
   320 				case OFB_NON_STOP | OFB_UNLOAD:
       
   321 				case OFB_NON_STOP | OFB_UNLOAD | OFB_TRANSFER:
       
   322 				case OFB_NON_STOP | OFB_TRANSFER:
       
   323 					if (v->type != VEH_TRAIN) return CMD_ERROR;
       
   324 					break;
   317 					break;
   325 
   318 
   326 				default: return CMD_ERROR;
   319 				default: return CMD_ERROR;
   327 			}
   320 			}
   328 			break;
   321 			break;
   362 
   355 
   363 					default: return CMD_ERROR;
   356 					default: return CMD_ERROR;
   364 				}
   357 				}
   365 			}
   358 			}
   366 
   359 
       
   360 			if (new_order.GetNonStopType() != OFB_NO_NON_STOP && v->type != VEH_TRAIN) return CMD_ERROR;
       
   361 
   367 			/* Order flags can be any of the following for depots:
   362 			/* Order flags can be any of the following for depots:
   368 			 * order [+ halt] [+ non-stop]
   363 			 * order [+ halt] [+ non-stop]
   369 			 * non-stop orders (if any) are only valid for trains */
   364 			 * non-stop orders (if any) are only valid for trains */
   370 			switch (new_order.flags) {
   365 			switch (new_order.GetDepotOrderType() | new_order.GetDepotActionType()) {
   371 				case OFB_PART_OF_ORDERS:
   366 				case OFB_PART_OF_ORDERS:
   372 				case OFB_PART_OF_ORDERS | OFB_HALT_IN_DEPOT:
   367 				case OFB_PART_OF_ORDERS | OFB_HALT_IN_DEPOT:
   373 					break;
       
   374 
       
   375 				case OFB_NON_STOP | OFB_PART_OF_ORDERS:
       
   376 				case OFB_NON_STOP | OFB_PART_OF_ORDERS | OFB_HALT_IN_DEPOT:
       
   377 					if (v->type != VEH_TRAIN) return CMD_ERROR;
       
   378 					break;
   368 					break;
   379 
   369 
   380 				default: return CMD_ERROR;
   370 				default: return CMD_ERROR;
   381 			}
   371 			}
   382 			break;
   372 			break;
   766 		return CMD_ERROR;
   756 		return CMD_ERROR;
   767 	}
   757 	}
   768 
   758 
   769 	if (flags & DC_EXEC) {
   759 	if (flags & DC_EXEC) {
   770 		switch (p2) {
   760 		switch (p2) {
   771 		case OF_FULL_LOAD:
   761 			case OF_FULL_LOAD:
   772 			ToggleBit(order->flags, OF_FULL_LOAD);
   762 				if (order->IsType(OT_GOTO_DEPOT)) {
   773 			if (!order->IsType(OT_GOTO_DEPOT)) ClrBit(order->flags, OF_UNLOAD);
   763 					order->SetDepotOrderType(order->GetDepotOrderType() ^ OFB_SERVICE_IF_NEEDED);
   774 			break;
   764 				} else {
   775 		case OF_UNLOAD:
   765 					order->SetLoadType(order->GetUnloadType() ^ OFB_FULL_LOAD);
   776 			ToggleBit(order->flags, OF_UNLOAD);
   766 					order->SetUnloadType(order->GetUnloadType() & ~OFB_UNLOAD);
   777 			ClrBit(order->flags, OF_FULL_LOAD);
   767 				}
   778 			break;
   768 				break;
   779 		case OF_NON_STOP:
   769 			case OF_UNLOAD:
   780 			ToggleBit(order->flags, OF_NON_STOP);
   770 				order->SetUnloadType(order->GetUnloadType() ^ OFB_UNLOAD);
   781 			break;
   771 				order->SetLoadType(0);
   782 		case OF_TRANSFER:
   772 				break;
   783 			ToggleBit(order->flags, OF_TRANSFER);
   773 			case OF_NON_STOP:
   784 			break;
   774 				order->SetNonStopType(order->GetNonStopType() ^ OFB_NON_STOP);
   785 		default: NOT_REACHED();
   775 				break;
       
   776 			case OF_TRANSFER:
       
   777 				order->SetUnloadType(order->GetUnloadType() ^ OFB_TRANSFER);
       
   778 				break;
       
   779 			default: NOT_REACHED();
   786 		}
   780 		}
   787 
   781 
   788 		/* Update the windows and full load flags, also for vehicles that share the same order list */
   782 		/* Update the windows and full load flags, also for vehicles that share the same order list */
   789 		{
   783 		{
   790 			Vehicle* u;
   784 			Vehicle* u;