summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-09-01 12:57:04 +0000
committerrubidium <rubidium@openttd.org>2009-09-01 12:57:04 +0000
commit4c84db16361c17e6c3def857b400b9a974f90d44 (patch)
tree57d6185c490b3a04178e78f6bbcca714ac1b3824 /src/economy.cpp
parent4abf4602e7a0b624de9836b5a58d3d606612c2fa (diff)
downloadopenttd-4c84db16361c17e6c3def857b400b9a974f90d44.tar.xz
(svn r17345) -Fix [FS#2769]: one wasn't offered to take over bankrupt companies anymore; caused by the introduction NoAI, although NewAI had the same problem too.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r--src/economy.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index 997c882d8..335889d83 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -506,16 +506,6 @@ static void CompanyCheckBankrupt(Company *c)
AI::BroadcastNewEvent(new AIEventCompanyInTrouble(c->index));
break;
case 3: {
- /* XXX - In multiplayer, should we ask other companies if it wants to take
- over when it is a human company? -- TrueLight */
- if (!c->is_ai) {
- SetDParam(0, STR_NEWS_COMPANY_IN_TROUBLE_TITLE);
- SetDParam(1, STR_NEWS_COMPANY_IN_TROUBLE_DESCRIPTION);
- SetDParamStr(2, cni->company_name);
- AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_TROUBLE, cni);
- break;
- }
-
/* Check if the company has any value.. if not, declare it bankrupt
* right now */
Money val = CalculateCompanyValue(c);
@@ -1560,15 +1550,17 @@ CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1
CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
Company *c = Company::GetIfValid(p1);
+ if (c == NULL) return CMD_ERROR;
- /* Disable takeovers in multiplayer games */
- if (c == NULL || _networking) return CMD_ERROR;
+ /* Disable takeovers when not asked */
+ if (!HasBit(c->bankrupt_asked, _current_company)) return CMD_ERROR;
+
+ /* Disable taking over the local company in single player */
+ 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 (!c->is_ai) return CMD_ERROR;
-
if (flags & DC_EXEC) {
DoAcquireCompany(c);
}