src/vehicle.cpp
changeset 7063 f8b804793df0
parent 7061 81d3a68972b5
child 7064 4c448d454ee6
equal deleted inserted replaced
7062:383e83c8d519 7063:f8b804793df0
   741 	/* continue loading if there is a non full cargo type and no cargo type that is full */
   741 	/* 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);
   742 	return keep_loading || (not_full && (full & ~not_full) == 0);
   743 }
   743 }
   744 
   744 
   745 
   745 
   746 bool CanFillVehicle(Vehicle *v)
   746 bool CanFillVehicle(Vehicle *front_v)
   747 {
   747 {
   748 	TileIndex tile = v->tile;
   748 	TileIndex tile = front_v->tile;
   749 
   749 
   750 	if (IsTileType(tile, MP_STATION) ||
   750 	assert(IsTileType(tile, MP_STATION) ||
   751 			(v->type == VEH_SHIP && (
   751 			(front_v->type == VEH_SHIP && (
   752 				IsTileType(TILE_ADDXY(tile,  1,  0), MP_STATION) ||
   752 				IsTileType(TILE_ADDXY(tile,  1,  0), MP_STATION) ||
   753 				IsTileType(TILE_ADDXY(tile, -1,  0), MP_STATION) ||
   753 				IsTileType(TILE_ADDXY(tile, -1,  0), MP_STATION) ||
   754 				IsTileType(TILE_ADDXY(tile,  0,  1), MP_STATION) ||
   754 				IsTileType(TILE_ADDXY(tile,  0,  1), MP_STATION) ||
   755 				IsTileType(TILE_ADDXY(tile,  0, -1), MP_STATION) ||
   755 				IsTileType(TILE_ADDXY(tile,  0, -1), MP_STATION) ||
   756 				IsTileType(TILE_ADDXY(tile, -2,  0), MP_STATION)
   756 				IsTileType(TILE_ADDXY(tile, -2,  0), MP_STATION)
   757 			))) {
   757 			)));
   758 
   758 
   759 		/* If patch is active, use alternative CanFillVehicle-function */
   759 	bool full_load = front_v->current_order.flags & OF_FULL_LOAD;
   760 		if (_patches.full_load_any && v->current_order.flags & OF_FULL_LOAD) return CanFillVehicle_FullLoadAny(v);
   760 
   761 
   761 	/* If patch is active, use alternative CanFillVehicle-function */
   762 		do {
   762 	if (_patches.full_load_any && full_load) return CanFillVehicle_FullLoadAny(front_v);
   763 			if (v->cargo_count != v->cargo_cap) return true;
   763 
   764 		} while ((v = v->next) != NULL);
   764 	Vehicle *v = front_v;
   765 	}
   765 	do {
   766 	return false;
   766 		if (HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING) || (full_load && v->cargo_count != v->cargo_cap)) return true;
       
   767 	} while ((v = v->next) != NULL);
       
   768 
       
   769 	return !HASBIT(front_v->vehicle_flags, VF_LOADING_FINISHED);
   767 }
   770 }
   768 
   771 
   769 /** Check if a given engine type can be refitted to a given cargo
   772 /** Check if a given engine type can be refitted to a given cargo
   770  * @param engine_type Engine type to check
   773  * @param engine_type Engine type to check
   771  * @param cid_to check refit to this cargo-type
   774  * @param cid_to check refit to this cargo-type