diff options
Diffstat (limited to 'src/economy.cpp')
-rw-r--r-- | src/economy.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index 19bf6346b..e4b9eb623 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -973,7 +973,6 @@ static void FindSubsidyPassengerRoute(FoundRoute *fr) static void FindSubsidyCargoRoute(FoundRoute *fr) { Industry *i; - const IndustrySpec *ind; int trans, total; CargoID cargo; @@ -981,15 +980,14 @@ static void FindSubsidyCargoRoute(FoundRoute *fr) fr->from = i = GetRandomIndustry(); if (i == NULL) return; - ind = GetIndustrySpec(i->type); /* Randomize cargo type */ - if (HASBIT(Random(), 0) && ind->produced_cargo[1] != CT_INVALID) { - cargo = ind->produced_cargo[1]; + if (HASBIT(Random(), 0) && i->produced_cargo[1] != CT_INVALID) { + cargo = i->produced_cargo[1]; trans = i->last_month_pct_transported[1]; total = i->last_month_production[1]; } else { - cargo = ind->produced_cargo[0]; + cargo = i->produced_cargo[0]; trans = i->last_month_pct_transported[0]; total = i->last_month_production[0]; } @@ -1016,17 +1014,12 @@ static void FindSubsidyCargoRoute(FoundRoute *fr) } else { /* The destination is an industry */ Industry *i2 = GetRandomIndustry(); - if (i2 == NULL) { - return; - } - - ind = GetIndustrySpec(i2->type); /* The industry must accept the cargo */ - if (i == i2 || - (cargo != ind->accepts_cargo[0] && - cargo != ind->accepts_cargo[1] && - cargo != ind->accepts_cargo[2])) { + if (i2 == NULL || i == i2 || + (cargo != i2->accepts_cargo[0] && + cargo != i2->accepts_cargo[1] && + cargo != i2->accepts_cargo[2])) { return; } fr->distance = DistanceManhattan(i->xy, i2->xy); @@ -1227,12 +1220,12 @@ static void DeliverGoodsToIndustry(TileIndex xy, CargoID cargo_type, int num_pie indspec = GetIndustrySpec(ind->type); uint i; - for (i = 0; i < lengthof(indspec->accepts_cargo); i++) { - if (cargo_type == indspec->accepts_cargo[i]) break; + for (i = 0; i < lengthof(ind->accepts_cargo); i++) { + if (cargo_type == ind->accepts_cargo[i]) break; } /* Check if matching cargo has been found */ - if (i == lengthof(indspec->accepts_cargo)) continue; + if (i == lengthof(ind->accepts_cargo)) continue; 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); |