if (HasBit(indspec->callback_flags, CBM_IND_REFUSE_CARGO)) {
uint16 res = GetIndustryCallback(CBID_INDUSTRY_REFUSE_CARGO, 0, GetReverseCargoTranslation(cargo_type, indspec->grf_prop.grffile), ind, ind->type, ind->xy);
if (res == 0) continue;
}
uint cargo_index;
for (cargo_index = 0; cargo_index < lengthof(ind->accepts_cargo); cargo_index++) {
if (cargo_type == ind->accepts_cargo[cargo_index]) break;
}
/* Check if matching cargo has been found */
if (cargo_index >= lengthof(ind->accepts_cargo)) return false;
uint dist = DistanceManhattan(ind->xy, xy);
if (dist < best_dist) {
best = ind;
best_dist = dist;
accepted_cargo_index = i;
}
/* Check if industry temporarly refuses acceptance */
if (HasBit(indspec->callback_flags, CBM_IND_REFUSE_CARGO)) {
uint16 res = GetIndustryCallback(CBID_INDUSTRY_REFUSE_CARGO, 0, GetReverseCargoTranslation(cargo_type, indspec->grf_prop.grffile), ind, ind->type, ind->xy);
if (res == 0) return false;
}
/* Found one? */
if (best != NULL) {
indspec = GetIndustrySpec(best->type);
/* Found industry accepting the cargo */
callback_data->ind = ind;
callback_data->indspec = indspec;
callback_data->cargo_index = cargo_index;
return true;
}
/**
* Transfer goods from station to industry.
* All cargo is delivered to the nearest (Manhattan) industry to the station sign, which is inside the acceptance rectangle and actually accepts the cargo.
* @param st The station that accepted the cargo
* @param cargo_type Type of cargo delivered
* @param nun_pieces Amount of cargo delivered
*/
static void DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, int num_pieces)