src/vehicle.cpp
changeset 7071 80d45870637a
parent 7069 9c50360195ff
child 7076 3bc104d72eef
equal deleted inserted replaced
7070:e12be4319af5 7071:80d45870637a
   702 }
   702 }
   703 
   703 
   704 static bool CanFillVehicle_FullLoadAny(Vehicle *v)
   704 static bool CanFillVehicle_FullLoadAny(Vehicle *v)
   705 {
   705 {
   706 	uint32 full = 0, not_full = 0;
   706 	uint32 full = 0, not_full = 0;
   707 	bool keep_loading = false;
       
   708 	const GoodsEntry *ge = GetStation(v->last_station_visited)->goods;
   707 	const GoodsEntry *ge = GetStation(v->last_station_visited)->goods;
   709 
   708 
   710 	/* special handling of aircraft */
   709 	/* special handling of aircraft */
   711 
   710 
   712 	/* if the aircraft carries passengers and is NOT full, then
   711 	/* if the aircraft carries passengers and is NOT full, then
   723 		assert(v->cargo_type<32);
   722 		assert(v->cargo_type<32);
   724 
   723 
   725 		if (v->cargo_cap != 0) {
   724 		if (v->cargo_cap != 0) {
   726 			uint32 mask = 1 << v->cargo_type;
   725 			uint32 mask = 1 << v->cargo_type;
   727 
   726 
   728 			if (v->cargo_cap == v->cargo_count) {
   727 			if (!HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING) && v->cargo_cap == v->cargo_count) {
   729 				full |= mask;
   728 				full |= mask;
   730 			} else if (GB(ge[v->cargo_type].waiting_acceptance, 0, 12) > 0 ||
   729 			} else if (GB(ge[v->cargo_type].waiting_acceptance, 0, 12) > 0 ||
   731 					(HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING) && (ge[v->cargo_type].waiting_acceptance & 0x8000))) {
   730 					(HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING) && (ge[v->cargo_type].waiting_acceptance & 0x8000))) {
   732 				/* If there is any cargo waiting, or this vehicle is still unloading
   731 				/* If there is any cargo waiting, or this vehicle is still unloading
   733 				 * and the station accepts the cargo, don't leave the station. */
   732 				 * and the station accepts the cargo, don't leave the station. */
   734 				keep_loading = true;
   733 				return true;
   735 			} else {
   734 			} else {
   736 				not_full |= mask;
   735 				not_full |= mask;
   737 			}
   736 			}
   738 		}
   737 		}
   739 	} while ((v = v->next) != NULL);
   738 	} while ((v = v->next) != NULL);
   740 
   739 
   741 	/* continue loading if there is a non full cargo type and no cargo type that is full */
   740 	/* continue loading if there is a non full cargo type and no cargo type that is full */
   742 	return keep_loading || (not_full && (full & ~not_full) == 0);
   741 	return not_full && (full & ~not_full) == 0;
   743 }
   742 }
   744 
   743 
   745 
   744 
   746 bool CanFillVehicle(Vehicle *front_v)
   745 bool CanFillVehicle(Vehicle *front_v)
   747 {
   746 {