mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r21952) -Codechange: unify the company clearing code for bankruptcy with the command to remove companies
This commit is contained in:
parent
c70ee16ecf
commit
732a0d069a
@ -481,22 +481,22 @@ static void CompanyCheckBankrupt(Company *c)
|
|||||||
|
|
||||||
c->quarters_of_bankruptcy++;
|
c->quarters_of_bankruptcy++;
|
||||||
|
|
||||||
CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
|
|
||||||
cni->FillData(c);
|
|
||||||
|
|
||||||
switch (c->quarters_of_bankruptcy) {
|
switch (c->quarters_of_bankruptcy) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
free(cni);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2: {
|
||||||
|
CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
|
||||||
|
cni->FillData(c);
|
||||||
SetDParam(0, STR_NEWS_COMPANY_IN_TROUBLE_TITLE);
|
SetDParam(0, STR_NEWS_COMPANY_IN_TROUBLE_TITLE);
|
||||||
SetDParam(1, STR_NEWS_COMPANY_IN_TROUBLE_DESCRIPTION);
|
SetDParam(1, STR_NEWS_COMPANY_IN_TROUBLE_DESCRIPTION);
|
||||||
SetDParamStr(2, cni->company_name);
|
SetDParamStr(2, cni->company_name);
|
||||||
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_TROUBLE, cni);
|
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_TROUBLE, cni);
|
||||||
AI::BroadcastNewEvent(new AIEventCompanyInTrouble(c->index));
|
AI::BroadcastNewEvent(new AIEventCompanyInTrouble(c->index));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 3: {
|
case 3: {
|
||||||
/* Check if the company has any value.. if not, declare it bankrupt
|
/* Check if the company has any value.. if not, declare it bankrupt
|
||||||
* right now */
|
* right now */
|
||||||
@ -505,7 +505,6 @@ static void CompanyCheckBankrupt(Company *c)
|
|||||||
c->bankrupt_value = val;
|
c->bankrupt_value = val;
|
||||||
c->bankrupt_asked = 1 << c->index; // Don't ask the owner
|
c->bankrupt_asked = 1 << c->index; // Don't ask the owner
|
||||||
c->bankrupt_timeout = 0;
|
c->bankrupt_timeout = 0;
|
||||||
free(cni);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FALL THROUGH to case 4... */
|
/* FALL THROUGH to case 4... */
|
||||||
@ -518,27 +517,12 @@ static void CompanyCheckBankrupt(Company *c)
|
|||||||
* he/she is no long in control of this company. However... when you
|
* he/she is no long in control of this company. However... when you
|
||||||
* join another company (cheat) the "unowned" company can bankrupt. */
|
* join another company (cheat) the "unowned" company can bankrupt. */
|
||||||
c->bankrupt_asked = MAX_UVALUE(CompanyMask);
|
c->bankrupt_asked = MAX_UVALUE(CompanyMask);
|
||||||
free(cni);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close everything the owner has open */
|
/* Actually remove the company. */
|
||||||
DeleteCompanyWindows(c->index);
|
DoCommand(0, 2 | (c->index << 16), 0, DC_EXEC, CMD_COMPANY_CTRL);
|
||||||
|
break;
|
||||||
/* Show bankrupt news */
|
|
||||||
SetDParam(0, STR_NEWS_COMPANY_BANKRUPT_TITLE);
|
|
||||||
SetDParam(1, STR_NEWS_COMPANY_BANKRUPT_DESCRIPTION);
|
|
||||||
SetDParamStr(2, cni->company_name);
|
|
||||||
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_BANKRUPT, cni);
|
|
||||||
|
|
||||||
ChangeOwnershipOfCompanyItems(c->index, INVALID_OWNER);
|
|
||||||
|
|
||||||
if (c->is_ai) AI::Stop(c->index);
|
|
||||||
|
|
||||||
CompanyID c_index = c->index;
|
|
||||||
delete c;
|
|
||||||
AI::BroadcastNewEvent(new AIEventCompanyBankrupt(c_index));
|
|
||||||
CompanyAdminBankrupt(c_index);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user