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;
|
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)) {
|
if (IsInteractiveCompany(best->index)) {
|
||||||
ShowBuyCompanyDialog(c->index, false);
|
ShowBuyCompanyDialog(c->index, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
* \li GSEventDisasterZeppelinerCleared
|
* \li GSEventDisasterZeppelinerCleared
|
||||||
* \li GSEventAircraftDestTooFar
|
* \li GSEventAircraftDestTooFar
|
||||||
* \li GSEventVehicleAutoReplaced
|
* \li GSEventVehicleAutoReplaced
|
||||||
|
* \li GSEventCompanyAskMerger
|
||||||
*
|
*
|
||||||
* Other changes:
|
* Other changes:
|
||||||
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
||||||
|
|
|
@ -113,6 +113,7 @@ bool ScriptEventEnginePreview::AcceptPreview()
|
||||||
bool ScriptEventCompanyAskMerger::AcceptMerger()
|
bool ScriptEventCompanyAskMerger::AcceptMerger()
|
||||||
{
|
{
|
||||||
EnforceCompanyModeValid(false);
|
EnforceCompanyModeValid(false);
|
||||||
|
EnforcePrecondition(false, ScriptObject::GetCompany() == ScriptCompany::FromScriptCompanyID(this->buyer));
|
||||||
return ScriptObject::Command<CMD_BUY_COMPANY>::Do(ScriptCompany::FromScriptCompanyID(this->owner), false);
|
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.
|
* Event Company Ask Merger, indicating a company can be bought (cheaply) by you.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventCompanyAskMerger : public ScriptEvent {
|
class ScriptEventCompanyAskMerger : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
#ifndef DOXYGEN_API
|
#ifndef DOXYGEN_API
|
||||||
/**
|
/**
|
||||||
|
* @param buyer The company that can buy.
|
||||||
* @param owner The company that can be bought.
|
* @param owner The company that can be bought.
|
||||||
* @param value The value/costs of buying the company.
|
* @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),
|
ScriptEvent(ET_COMPANY_ASK_MERGER),
|
||||||
|
buyer(ScriptCompany::ToScriptCompanyID(buyer)),
|
||||||
owner(ScriptCompany::ToScriptCompanyID(owner)),
|
owner(ScriptCompany::ToScriptCompanyID(owner)),
|
||||||
value(value)
|
value(value)
|
||||||
{}
|
{}
|
||||||
|
@ -462,6 +464,14 @@ public:
|
||||||
*/
|
*/
|
||||||
static ScriptEventCompanyAskMerger *Convert(ScriptEvent *instance) { return (ScriptEventCompanyAskMerger *)instance; }
|
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.
|
* Get the CompanyID of the company that can be bought.
|
||||||
* @return 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();
|
bool AcceptMerger();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ScriptCompany::CompanyID buyer; ///< The company that is buying.
|
||||||
ScriptCompany::CompanyID owner; ///< The company that is in trouble.
|
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