Loading

Paste #pqaeqlsvi

  1. function FMainClass::FindSourceDestination(cargo_id, desired_distance) {
  2.     local cargo_entry = cargoes[cargo_id];
  3.     if (cargo_entry.freight) { // Freight cargo, find an industry accepting it.
  4.         local accept_inds = GSIndustryList_CargoAccepting(cargo_id);
  5.         local prod_inds = GSIndustryList_CargoProducing(cargo_id);
  6.  
  7.         local accept_ind, prod_ind;
  8.         foreach (accept_ind in accept_inds) {
  9.             GSLog.Info("accept " + GSCargo.GetCargoLabel(cargo_entry.cid) + GSIndustry.GetName(accept_ind));
  10.             local accept_tile = GSIndustry.GetLocation(accept_ind);
  11.  
  12.             foreach (prod_ind in prod_inds) {
  13.                 if (prod_ind == accept_ind) continue;
  14.                 local prod_tile = GSIndustry.GetLocation(prod_ind);
  15.                 local dist = GSTile.GetDistanceManhattanToTile(accept_tile, prod_tile);
  16.  
  17.                 GSLog.Info("produce " + GSCargo.GetCargoLabel(cargo_entry.cid) + GSIndustry.GetName(prod_ind) + "@" + dist);
  18.                 // GSIndustry.GetDistanceManhattan(accept_tile)
  19.             }
  20.  
  21.         }
  22.     }
  23. }

Comments