Mercurial > hg > openttd
changeset 15038:80e8104bac11 draft
(svn r19655) -Codechange: Reduce usage magic p1 parameter.
author | frosch <frosch@openttd.org> |
---|---|
date | Sat, 17 Apr 2010 13:45:48 +0000 |
parents | ae5f1c6f349c |
children | 53c099f9a3a9 |
files | src/economy.cpp |
diffstat | 1 files changed, 11 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/economy.cpp +++ b/src/economy.cpp @@ -1490,12 +1490,12 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { CommandCost cost(EXPENSES_OTHER); - - Company *c = Company::GetIfValid(p1); + CompanyID target_company = (CompanyID)p1; + Company *c = Company::GetIfValid(target_company); /* Check if buying shares is allowed (protection against modified clients) * Cannot buy own shares */ - if (c == NULL || !_settings_game.economy.allow_shares || _current_company == (CompanyID)p1) return CMD_ERROR; + if (c == NULL || !_settings_game.economy.allow_shares || _current_company == target_company) return CMD_ERROR; /* Protect new companies from hostile takeovers */ if (_cur_year - c->inaugurated_year < 6) return_cmd_error(STR_ERROR_PROTECTED); @@ -1521,7 +1521,7 @@ break; } } - SetWindowDirty(WC_COMPANY, p1); + SetWindowDirty(WC_COMPANY, target_company); } return cost; } @@ -1536,11 +1536,12 @@ */ CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { - Company *c = Company::GetIfValid(p1); + CompanyID target_company = (CompanyID)p1; + Company *c = Company::GetIfValid(target_company); /* Check if selling shares is allowed (protection against modified clients) * Cannot sell own shares */ - if (c == NULL || !_settings_game.economy.allow_shares || _current_company == (CompanyID)p1) return CMD_ERROR; + if (c == NULL || !_settings_game.economy.allow_shares || _current_company == target_company) return CMD_ERROR; /* Those lines are here for network-protection (clients can be slow) */ if (GetAmountOwnedBy(c, _current_company) == 0) return CommandCost(); @@ -1553,7 +1554,7 @@ OwnerByte *b = c->share_owners; while (*b != _current_company) b++; // share owners is guaranteed to contain company *b = COMPANY_SPECTATOR; - SetWindowDirty(WC_COMPANY, p1); + SetWindowDirty(WC_COMPANY, target_company); } return CommandCost(EXPENSES_OTHER, cost); } @@ -1571,7 +1572,8 @@ */ CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { - Company *c = Company::GetIfValid(p1); + CompanyID target_company = (CompanyID)p1; + Company *c = Company::GetIfValid(target_company); if (c == NULL) return CMD_ERROR; /* Disable takeovers when not asked */ @@ -1581,7 +1583,7 @@ if (!_networking && _local_company == c->index) return CMD_ERROR; /* Do not allow companies to take over themselves */ - if ((CompanyID)p1 == _current_company) return CMD_ERROR; + if (target_company == _current_company) return CMD_ERROR; /* Get the cost here as the company is deleted in DoAcquireCompany. */ CommandCost cost(EXPENSES_OTHER, c->bankrupt_value);