From 027e431b9932fb720b0f5da4248839c1f487874c Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 26 Dec 2008 21:49:00 +0000 Subject: (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. --- src/economy.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src') 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; - } } } -- cgit v1.2.3-70-g09d2