diff options
author | rubidium <rubidium@openttd.org> | 2008-12-26 21:49:00 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-12-26 21:49:00 +0000 |
commit | 027e431b9932fb720b0f5da4248839c1f487874c (patch) | |
tree | fedf6853b37e67988f5e8b0ca7fb9cd9f5f086d6 /src | |
parent | 931bdb9626a6f56e26558ac818b0caee00879f32 (diff) | |
download | openttd-027e431b9932fb720b0f5da4248839c1f487874c.tar.xz |
(svn r14750) -Fix [FS#1993]: in an MP game in SP mode no company would go bankrupt. Furthermore companies that passed the "bankrupt" period (4 quarters) wouldn't go bankrupt when loading the game back in MP. Now any company that is in MP or not "currently controlled by the player" in SP will bankrupt.
Diffstat (limited to 'src')
-rw-r--r-- | src/economy.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index 22d20f2d1..f3039b46d 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -490,7 +490,8 @@ static void CompanyCheckBankrupt(Company *c) cni->FillData(c); switch (c->quarters_of_bankrupcy) { - default: + case 0: + case 1: free(cni); break; @@ -523,7 +524,18 @@ static void CompanyCheckBankrupt(Company *c) } /* Else, falltrue to case 4... */ } - case 4: { + default: + case 4: + if (!_networking && _local_company == c->index) { + /* If we are in offline mode, leave the company playing. Eg. there + * is no THE-END, otherwise mark the client as spectator to make sure + * he/she is no long in control of this company. However... when you + * join another company (cheat) the "unowned" company can bankrupt. */ + c->bankrupt_asked = MAX_UVALUE(CompanyMask); + c->bankrupt_timeout = 0x456; + break; + } + /* Close everything the owner has open */ DeleteCompanyWindows(c->index); @@ -533,28 +545,16 @@ static void CompanyCheckBankrupt(Company *c) SetDParamStr(2, cni->company_name); AddNewsItem(STR_02B6, NS_COMPANY_BANKRUPT, 0, 0, cni); - if (IsHumanCompany(c->index)) { - /* XXX - If we are in offline mode, leave the company playing. Eg. there - * is no THE-END, otherwise mark the client as spectator to make sure - * he/she is no long in control of this company */ - if (!_networking) { - c->bankrupt_asked = MAX_UVALUE(CompanyMask); - c->bankrupt_timeout = 0x456; - break; - } - - ChangeNetworkOwner(c->index, COMPANY_SPECTATOR); - } - /* Remove the company */ + ChangeNetworkOwner(c->index, COMPANY_SPECTATOR); ChangeOwnershipOfCompanyItems(c->index, INVALID_OWNER); - /* Register the company as not-active */ - if (!IsHumanCompany(c->index) && (!_networking || _network_server) && _ai.enabled) + /* Register the company as not-active */ + if (!IsHumanCompany(c->index) && (!_networking || _network_server) && _ai.enabled) { AI_CompanyDied(c->index); + } delete c; - } } } |