Loading

Paste #px4pxjaj8

  1. function MainClass::IsTownGrowing() {
  2.     local townList = GSTownList();
  3.     for (local town = townList.Begin(); !townList.IsEnd(); town = townList.Next()) {
  4.         local cargoList = GSCargoList();
  5.         cargoList.Sort(GSList.SORT_BY_ITEM, GSList.SORT_ASCENDING);
  6.         local cargoRequired = GSList();
  7.         for (local cargo_type = cargoList.Begin(); !cargoList.IsEnd(); cargo_type = cargoList.Next()) {
  8.             local town_effect = GSCargo.GetTownEffect(cargo_type);
  9.             local class_name = "";
  10.             for (local cc = 0; cc <= 15; cc++) {
  11.                 local cargo_class = 1 << cc;
  12.                 if (GSCargo.HasCargoClass(cargo_type, cargo_class)) {
  13.                     if (class_name != "") class_name += ", ";
  14.                     switch(cargo_class) {
  15.                         case GSCargo.CC_PASSENGERS: class_name += "CC_PASSENGERS"; break;
  16.                         case GSCargo.CC_MAIL: class_name += "CC_MAIL"; break;
  17.                         case GSCargo.CC_EXPRESS: class_name += "CC_EXPRESS"; break;
  18.                         case GSCargo.CC_ARMOURED: class_name += "CC_ARMOURED"; break;
  19.                         case GSCargo.CC_BULK: class_name += "CC_BULK"; break;
  20.                         case GSCargo.CC_PIECE_GOODS: class_name += "CC_PIECE_GOODS"; break;
  21.                         case GSCargo.CC_LIQUID: class_name += "CC_LIQUID"; break;
  22.                         case GSCargo.CC_REFRIGERATED: class_name += "CC_REFRIGERATED"; break;
  23.                         case GSCargo.CC_HAZARDOUS: class_name += "CC_HAZARDOUS"; break;
  24.                         case GSCargo.CC_COVERED: class_name += "CC_COVERED"; break;
  25.                         case 1 << 15: class_name += "CC_SPECIAL"; break;
  26.                         default: class_name += "unknown (" + cargo_class + ")"; break;
  27.                     }
  28.                 }
  29.             }
  30.             GSLog.Info("Cargo " + cargo_type + ": " + GSCargo.GetCargoLabel(cargo_type) + (class_name == "" ? "" : "; CargoClass = " + class_name));
  31.             if (town_effect != GSCargo.TE_NONE) {
  32.                 local effect_name;
  33.                 switch(town_effect) {
  34.                     case GSCargo.TE_PASSENGERS: effect_name = "TE_PASSENGERS"; break;
  35.                     case GSCargo.TE_MAIL: effect_name = "TE_MAIL"; break;
  36.                     case GSCargo.TE_GOODS: effect_name = "TE_GOODS"; break;
  37.                     case GSCargo.TE_WATER: effect_name = "TE_WATER"; break;
  38.                     case GSCargo.TE_FOOD: effect_name = "TE_FOOD"; break;
  39.                 }
  40.                 GSLog.Info(" - Effect of " + GSCargo.GetCargoLabel(cargo_type) + " in " + GSTown.GetName(town) + " is " + effect_name);
  41.                 local cargo_goal = GSTown.GetCargoGoal(town, town_effect);
  42.                 if (cargo_goal != 0) {
  43.                     GSLog.Info(" - An amount of " + cargo_goal + " " + GSCargo.GetCargoLabel(cargo_type) + " is required to grow " + GSTown.GetName(town));
  44.                     cargoRequired.AddItem(cargo_type, cargo_goal);
  45.                 }
  46.             }
  47.         }
  48.         GSLog.Info(" ");
  49.     }
  50. }

Version history

Revision # Author Created at
pidxg1mfb Anonymous 06 Sep 2019, 15:50:15 UTC Diff

Comments