Add console command to offer a company for sale
This commit is contained in:
@@ -943,6 +943,18 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case CCA_SALE: {
|
||||||
|
Company *c = Company::GetIfValid(company_id);
|
||||||
|
if (c == nullptr) return CMD_ERROR;
|
||||||
|
|
||||||
|
if (!(flags & DC_EXEC)) return CommandCost();
|
||||||
|
|
||||||
|
c->bankrupt_value = CalculateCompanyValue(c, false);
|
||||||
|
c->bankrupt_asked = 1 << c->index; // Don't ask the owner
|
||||||
|
c->bankrupt_timeout = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default: return CMD_ERROR;
|
default: return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,6 +65,7 @@ enum CompanyCtrlAction {
|
|||||||
CCA_NEW, ///< Create a new company.
|
CCA_NEW, ///< Create a new company.
|
||||||
CCA_NEW_AI, ///< Create a new AI company.
|
CCA_NEW_AI, ///< Create a new AI company.
|
||||||
CCA_DELETE, ///< Delete a company.
|
CCA_DELETE, ///< Delete a company.
|
||||||
|
CCA_SALE, ///< Offer a company for sale.
|
||||||
|
|
||||||
CCA_END, ///< Sentinel for end.
|
CCA_END, ///< Sentinel for end.
|
||||||
};
|
};
|
||||||
|
@@ -962,6 +962,30 @@ DEF_CONSOLE_CMD(ConResetCompany)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEF_CONSOLE_CMD(ConOfferCompanySale)
|
||||||
|
{
|
||||||
|
if (argc == 0) {
|
||||||
|
IConsoleHelp("Offer a company for sale. Usage: 'offer_company_sale <company-id>'");
|
||||||
|
IConsoleHelp("For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc != 2) return false;
|
||||||
|
|
||||||
|
CompanyID index = (CompanyID)(atoi(argv[1]) - 1);
|
||||||
|
|
||||||
|
/* Check valid range */
|
||||||
|
if (!Company::IsValidID(index)) {
|
||||||
|
IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DoCommandP(0, CCA_SALE | index << 16, 0, CMD_COMPANY_CTRL);
|
||||||
|
IConsolePrint(CC_DEFAULT, "Company offered for sale.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
DEF_CONSOLE_CMD(ConNetworkClients)
|
DEF_CONSOLE_CMD(ConNetworkClients)
|
||||||
{
|
{
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
@@ -3447,6 +3471,7 @@ void IConsoleStdLibRegister()
|
|||||||
IConsole::CmdRegister("move", ConMoveClient, ConHookServerOnly);
|
IConsole::CmdRegister("move", ConMoveClient, ConHookServerOnly);
|
||||||
IConsole::CmdRegister("reset_company", ConResetCompany, ConHookServerOnly);
|
IConsole::CmdRegister("reset_company", ConResetCompany, ConHookServerOnly);
|
||||||
IConsole::AliasRegister("clean_company", "reset_company %A");
|
IConsole::AliasRegister("clean_company", "reset_company %A");
|
||||||
|
IConsole::CmdRegister("offer_company_sale", ConOfferCompanySale, ConHookServerOrNoNetwork);
|
||||||
IConsole::CmdRegister("client_name", ConClientNickChange, ConHookServerOnly);
|
IConsole::CmdRegister("client_name", ConClientNickChange, ConHookServerOnly);
|
||||||
IConsole::CmdRegister("kick", ConKick, ConHookServerOnly);
|
IConsole::CmdRegister("kick", ConKick, ConHookServerOnly);
|
||||||
IConsole::CmdRegister("ban", ConBan, ConHookServerOnly);
|
IConsole::CmdRegister("ban", ConBan, ConHookServerOnly);
|
||||||
|
Reference in New Issue
Block a user