diff options
author | tron <tron@openttd.org> | 2006-02-13 21:15:00 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-02-13 21:15:00 +0000 |
commit | ea73b466844a048f9f55b933f243ec19bdaaa18c (patch) | |
tree | 19340b96ef341c9784a27b719a1a90c2c691ca56 /economy.c | |
parent | 235e72829e55cbb1e7632fe1b2d1429f6f3be054 (diff) | |
download | openttd-ea73b466844a048f9f55b933f243ec19bdaaa18c.tar.xz |
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
Diffstat (limited to 'economy.c')
-rw-r--r-- | economy.c | 33 |
1 files changed, 19 insertions, 14 deletions
@@ -1121,10 +1121,11 @@ int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, b if (transit_days > _cargoc.transit_days_2[cargo]) { transit_days -= _cargoc.transit_days_2[cargo]; - if (f < transit_days) + if (f < transit_days) { f = 0; - else + } else { f -= transit_days; + } } } if (f < 31) f = 31; @@ -1134,19 +1135,23 @@ int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, b static void DeliverGoodsToIndustry(TileIndex xy, byte cargo_type, int num_pieces) { - Industry *ind, *best; - int t, u; + Industry* best = NULL; + Industry* ind; + uint u; - /* Check if there's an industry close to the station that accepts - * the cargo */ - best = NULL; + // Check if there's an industry close to the station that accepts the cargo u = _patches.station_spread + 8; FOR_ALL_INDUSTRIES(ind) { - if (ind->xy != 0 && (cargo_type == ind->accepts_cargo[0] || cargo_type - == ind->accepts_cargo[1] || cargo_type == ind->accepts_cargo[2]) && - ind->produced_cargo[0] != CT_INVALID && - ind->produced_cargo[0] != cargo_type && - (t = DistanceManhattan(ind->xy, xy)) < 2 * u) { + uint t; + + if (ind->xy != 0 && ( + cargo_type == ind->accepts_cargo[0] || + cargo_type == ind->accepts_cargo[1] || + cargo_type == ind->accepts_cargo[2] + ) && + ind->produced_cargo[0] != CT_INVALID && + ind->produced_cargo[0] != cargo_type && + (t = DistanceManhattan(ind->xy, xy)) < 2 * u) { u = t; best = ind; } @@ -1595,7 +1600,7 @@ int32 CmdBuyShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2) break; } } - InvalidateWindow(WC_COMPANY, (int)p1); + InvalidateWindow(WC_COMPANY, p1); } return cost; } @@ -1627,7 +1632,7 @@ int32 CmdSellShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2) PlayerID* b = p->share_owners; while (*b != _current_player) b++; /* share owners is guaranteed to contain player */ *b = OWNER_SPECTATOR; - InvalidateWindow(WC_COMPANY, (int)p1); + InvalidateWindow(WC_COMPANY, p1); } return cost; } |