src/ai/api/ai_order.cpp
branchnoai
changeset 10095 7483ad241067
parent 10093 b3849a19d137
child 10142 56ee7da4ad56
equal deleted inserted replaced
10094:e737405b06dd 10095:7483ad241067
   110 
   110 
   111 /* static */ bool AIOrder::InsertOrder(VehicleID vehicle_id, uint32 order_id, TileIndex destination, AIOrder::AIOrderFlags order_flags)
   111 /* static */ bool AIOrder::InsertOrder(VehicleID vehicle_id, uint32 order_id, TileIndex destination, AIOrder::AIOrderFlags order_flags)
   112 {
   112 {
   113 	/* IsValidVehicleOrder is not good enough because it does not allow appending. */
   113 	/* IsValidVehicleOrder is not good enough because it does not allow appending. */
   114 	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
   114 	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
   115        EnforcePrecondition(false, order_id <= ::GetVehicle(vehicle_id)->num_orders);
   115 	EnforcePrecondition(false, order_id <= ::GetVehicle(vehicle_id)->num_orders);
   116 	EnforcePrecondition(false, AreOrderFlagsValid(destination, order_flags));
   116 	EnforcePrecondition(false, AreOrderFlagsValid(destination, order_flags));
   117 
   117 
   118 	Order order;
   118 	Order order;
   119 	switch (::GetOrderTypeByTile(destination)) {
   119 	switch (::GetOrderTypeByTile(destination)) {
   120 		case OT_GOTO_DEPOT:
   120 		case OT_GOTO_DEPOT:
   166 }
   166 }
   167 
   167 
   168 /* static */ bool AIOrder::MoveOrder(VehicleID vehicle_id, uint32 order_id_move, uint32 order_id_target)
   168 /* static */ bool AIOrder::MoveOrder(VehicleID vehicle_id, uint32 order_id_move, uint32 order_id_target)
   169 {
   169 {
   170 	EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_id_move));
   170 	EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_id_move));
   171        EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_id_target));
   171 	EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_id_target));
   172 
   172 
   173 	return AIObject::DoCommand(0, vehicle_id, order_id_move | (order_id_target << 16), CMD_MOVE_ORDER);
   173 	return AIObject::DoCommand(0, vehicle_id, order_id_move | (order_id_target << 16), CMD_MOVE_ORDER);
   174 }
   174 }
   175 
   175 
   176 /* static */ bool AIOrder::CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id)
   176 /* static */ bool AIOrder::CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id)
   177 {
   177 {
   178 	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
   178 	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
   179        EnforcePrecondition(false, AIVehicle::IsValidVehicle(main_vehicle_id));
   179 	EnforcePrecondition(false, AIVehicle::IsValidVehicle(main_vehicle_id));
   180 
   180 
   181 	return AIObject::DoCommand(0, vehicle_id | (main_vehicle_id << 16), CO_COPY, CMD_CLONE_ORDER);
   181 	return AIObject::DoCommand(0, vehicle_id | (main_vehicle_id << 16), CO_COPY, CMD_CLONE_ORDER);
   182 }
   182 }
   183 
   183 
   184 /* static */ bool AIOrder::ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id)
   184 /* static */ bool AIOrder::ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id)
   185 {
   185 {
   186 	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
   186 	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
   187        EnforcePrecondition(false, AIVehicle::IsValidVehicle(main_vehicle_id));
   187 	EnforcePrecondition(false, AIVehicle::IsValidVehicle(main_vehicle_id));
   188 
   188 
   189 	return AIObject::DoCommand(0, vehicle_id | (main_vehicle_id << 16), CO_SHARE, CMD_CLONE_ORDER);
   189 	return AIObject::DoCommand(0, vehicle_id | (main_vehicle_id << 16), CO_SHARE, CMD_CLONE_ORDER);
   190 }
   190 }
   191 
   191 
   192 /* static */ bool AIOrder::UnshareOrders(VehicleID vehicle_id)
   192 /* static */ bool AIOrder::UnshareOrders(VehicleID vehicle_id)