mirror of https://github.com/OpenTTD/OpenTTD
Change: Allow GS access to ScriptEventCompanyAskMerger
parent
08ec7f5503
commit
62ee9029a1
|
@ -730,7 +730,7 @@ static void HandleBankruptcyTakeover(Company *c)
|
|||
|
||||
c->bankrupt_timeout = TAKE_OVER_TIMEOUT;
|
||||
|
||||
AI::NewEvent(best->index, new ScriptEventCompanyAskMerger(c->index, c->bankrupt_value));
|
||||
ScriptTrigger::NewEvent<ScriptEventCompanyAskMerger>(best->index, best->index, c->index, c->bankrupt_value);
|
||||
if (IsInteractiveCompany(best->index)) {
|
||||
ShowBuyCompanyDialog(c->index, false);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
* \li GSEventDisasterZeppelinerCleared
|
||||
* \li GSEventAircraftDestTooFar
|
||||
* \li GSEventVehicleAutoReplaced
|
||||
* \li GSEventCompanyAskMerger
|
||||
*
|
||||
* Other changes:
|
||||
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
||||
|
|
|
@ -113,6 +113,7 @@ bool ScriptEventEnginePreview::AcceptPreview()
|
|||
bool ScriptEventCompanyAskMerger::AcceptMerger()
|
||||
{
|
||||
EnforceCompanyModeValid(false);
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == ScriptCompany::FromScriptCompanyID(this->buyer));
|
||||
return ScriptObject::Command<CMD_BUY_COMPANY>::Do(ScriptCompany::FromScriptCompanyID(this->owner), false);
|
||||
}
|
||||
|
||||
|
|
|
@ -439,17 +439,19 @@ private:
|
|||
|
||||
/**
|
||||
* Event Company Ask Merger, indicating a company can be bought (cheaply) by you.
|
||||
* @api ai
|
||||
* @api ai game
|
||||
*/
|
||||
class ScriptEventCompanyAskMerger : public ScriptEvent {
|
||||
public:
|
||||
#ifndef DOXYGEN_API
|
||||
/**
|
||||
* @param buyer The company that can buy.
|
||||
* @param owner The company that can be bought.
|
||||
* @param value The value/costs of buying the company.
|
||||
*/
|
||||
ScriptEventCompanyAskMerger(Owner owner, Money value) :
|
||||
ScriptEventCompanyAskMerger(Owner buyer, Owner owner, Money value) :
|
||||
ScriptEvent(ET_COMPANY_ASK_MERGER),
|
||||
buyer(ScriptCompany::ToScriptCompanyID(buyer)),
|
||||
owner(ScriptCompany::ToScriptCompanyID(owner)),
|
||||
value(value)
|
||||
{}
|
||||
|
@ -462,6 +464,14 @@ public:
|
|||
*/
|
||||
static ScriptEventCompanyAskMerger *Convert(ScriptEvent *instance) { return (ScriptEventCompanyAskMerger *)instance; }
|
||||
|
||||
/**
|
||||
* Get the CompanyID of the company that can purchase the other.
|
||||
* @return The CompanyID of the company that can purchase.
|
||||
* @note If the company is bought this will become invalid.
|
||||
* @api -ai
|
||||
*/
|
||||
ScriptCompany::CompanyID GetBuyerID() { return this->buyer; }
|
||||
|
||||
/**
|
||||
* Get the CompanyID of the company that can be bought.
|
||||
* @return The CompanyID of the company that can be bought.
|
||||
|
@ -483,8 +493,9 @@ public:
|
|||
bool AcceptMerger();
|
||||
|
||||
private:
|
||||
ScriptCompany::CompanyID buyer; ///< The company that is buying.
|
||||
ScriptCompany::CompanyID owner; ///< The company that is in trouble.
|
||||
Money value; ///< The value of the company, i.e. the amount you would pay.
|
||||
Money value; ///< The value of the company in trouble, i.e. the amount the buyer would pay.
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue