- function FMainClass::FindSourceDestination(cargo_id, desired_distance) {
- local cargo_entry = cargoes[cargo_id];
- if (cargo_entry.freight) { // Freight cargo, find an industry accepting it.
- local accept_inds = GSIndustryList_CargoAccepting(cargo_id);
- local prod_inds = GSIndustryList_CargoProducing(cargo_id);
- local accept_ind, prod_ind;
- foreach (accept_ind in accept_inds) {
- GSLog.Info("accept " + GSCargo.GetCargoLabel(cargo_entry.cid) + GSIndustry.GetName(accept_ind));
- local accept_tile = GSIndustry.GetLocation(accept_ind);
- foreach (prod_ind in prod_inds) {
- if (prod_ind == accept_ind) continue;
- local prod_tile = GSIndustry.GetLocation(prod_ind);
- local dist = GSTile.GetDistanceManhattanToTile(accept_tile, prod_tile);
- GSLog.Info("produce " + GSCargo.GetCargoLabel(cargo_entry.cid) + GSIndustry.GetName(prod_ind) + "@" + dist);
- // GSIndustry.GetDistanceManhattan(accept_tile)
- }
- }
- }
- }