diff options
author | truebrain <truebrain@openttd.org> | 2011-11-23 16:05:19 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2011-11-23 16:05:19 +0000 |
commit | 229e572663158d8fd37cabf3c2a3cb06811ff0a1 (patch) | |
tree | e27f01fdf1de01262be29bb795b0be8d54b04f5e /src/town_cmd.cpp | |
parent | 4e09cde6495f35a6d56cacc0dbf636df7bc94dbd (diff) | |
download | openttd-229e572663158d8fd37cabf3c2a3cb06811ff0a1.tar.xz |
(svn r23298) -Add: track statistics of all incoming and outgoing goods. Incoming based on TownEffect, outgoing based on CargoType (based on patch by Terkhen)
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r-- | src/town_cmd.cpp | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index cc66e3ae8..6774292a9 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -485,36 +485,24 @@ static void TileLoop_Town(TileIndex tile) uint moved = MoveGoodsToStation(cargo, amt, ST_TOWN, t->index, stations.GetStations()); const CargoSpec *cs = CargoSpec::Get(cargo); - switch (cs->town_effect) { - case TE_PASSENGERS: - t->pass.new_max += amt; - t->pass.new_act += moved; - break; - - case TE_MAIL: - t->mail.new_max += amt; - t->mail.new_act += moved; - break; - - default: - break; - } + t->supplied[cs->Index()].new_max += amt; + t->supplied[cs->Index()].new_act += moved; } } else { if (GB(r, 0, 8) < hs->population) { uint amt = GB(r, 0, 8) / 8 + 1; if (EconomyIsInRecession()) amt = (amt + 1) >> 1; - t->pass.new_max += amt; - t->pass.new_act += MoveGoodsToStation(CT_PASSENGERS, amt, ST_TOWN, t->index, stations.GetStations()); + t->supplied[CT_PASSENGERS].new_max += amt; + t->supplied[CT_PASSENGERS].new_act += MoveGoodsToStation(CT_PASSENGERS, amt, ST_TOWN, t->index, stations.GetStations()); } if (GB(r, 8, 8) < hs->mail_generation) { uint amt = GB(r, 8, 8) / 8 + 1; if (EconomyIsInRecession()) amt = (amt + 1) >> 1; - t->mail.new_max += amt; - t->mail.new_act += MoveGoodsToStation(CT_MAIL, amt, ST_TOWN, t->index, stations.GetStations()); + t->supplied[CT_MAIL].new_max += amt; + t->supplied[CT_MAIL].new_act += MoveGoodsToStation(CT_MAIL, amt, ST_TOWN, t->index, stations.GetStations()); } } @@ -1401,8 +1389,8 @@ void UpdateTownRadius(Town *t) void UpdateTownMaxPass(Town *t) { - t->pass.old_max = t->population >> 3; - t->mail.old_max = t->population >> 4; + t->supplied[CT_PASSENGERS].old_max = t->population >> 3; + t->supplied[CT_MAIL].old_max = t->population >> 4; } /** @@ -2771,10 +2759,10 @@ static void UpdateTownGrowRate(Town *t) } if (_settings_game.game_creation.landscape == LT_ARCTIC) { - if (TileHeight(t->xy) >= GetSnowLine() && t->food.old_act == 0 && t->population > 90) return; + if (TileHeight(t->xy) >= GetSnowLine() && t->received[TE_FOOD].old_act == 0 && t->population > 90) return; } else if (_settings_game.game_creation.landscape == LT_TROPIC) { - if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->food.old_act == 0 || t->water.old_act == 0) && t->population > 60) return; + if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->received[TE_FOOD].old_act == 0 || t->received[TE_WATER].old_act == 0) && t->population > 60) return; } /* Use the normal growth rate values if new buildings have been funded in @@ -2794,10 +2782,8 @@ static void UpdateTownGrowRate(Town *t) static void UpdateTownAmounts(Town *t) { - t->pass.NewMonth(); - t->mail.NewMonth(); - t->food.NewMonth(); - t->water.NewMonth(); + for (CargoID i = 0; i < NUM_CARGO; i++) t->supplied[i].NewMonth(); + for (int i = TE_BEGIN; i < TE_END; i++) t->received[i].NewMonth(); SetWindowDirty(WC_TOWN_VIEW, t->index); } |