From ea73b466844a048f9f55b933f243ec19bdaaa18c Mon Sep 17 00:00:00 2001 From: tron Date: Mon, 13 Feb 2006 21:15:00 +0000 Subject: (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 --- economy.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'economy.c') diff --git a/economy.c b/economy.c index 311bc0d7e..b4b38e985 100644 --- a/economy.c +++ b/economy.c @@ -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; } -- cgit v1.2.3-54-g00ecf