1209 best_dist = (_patches.station_spread + 8) * 2; |
1209 best_dist = (_patches.station_spread + 8) * 2; |
1210 FOR_ALL_INDUSTRIES(ind) { |
1210 FOR_ALL_INDUSTRIES(ind) { |
1211 indspec = GetIndustrySpec(ind->type); |
1211 indspec = GetIndustrySpec(ind->type); |
1212 uint i; |
1212 uint i; |
1213 |
1213 |
1214 if (indspec->produced_cargo[0] == CT_INVALID) continue; |
|
1215 |
|
1216 for (i = 0; i < lengthof(indspec->accepts_cargo); i++) { |
1214 for (i = 0; i < lengthof(indspec->accepts_cargo); i++) { |
1217 if (cargo_type == indspec->accepts_cargo[i] && |
1215 if (cargo_type == indspec->accepts_cargo[i]) break; |
1218 (indspec->input_cargo_multiplier[i][0] != 0 || indspec->input_cargo_multiplier[i][1] != 0)) { |
|
1219 break; |
|
1220 } |
|
1221 } |
1216 } |
1222 |
1217 |
1223 /* Check if matching cargo has been found */ |
1218 /* Check if matching cargo has been found */ |
1224 if (i == lengthof(indspec->accepts_cargo)) continue; |
1219 if (i == lengthof(indspec->accepts_cargo)) continue; |
|
1220 |
|
1221 if (HASBIT(indspec->callback_flags, CBM_IND_REFUSE_CARGO)) { |
|
1222 uint16 res = GetIndustryCallback(CBID_INDUSTRY_REFUSE_CARGO, 0, GetReverseCargoTranslation(cargo_type, indspec->grf_prop.grffile), ind, ind->type, ind->xy); |
|
1223 if (res == 0) continue; |
|
1224 } |
1225 |
1225 |
1226 uint dist = DistanceManhattan(ind->xy, xy); |
1226 uint dist = DistanceManhattan(ind->xy, xy); |
1227 |
1227 |
1228 if (dist < best_dist) { |
1228 if (dist < best_dist) { |
1229 best = ind; |
1229 best = ind; |