mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
This commit is contained in:
parent
870149406a
commit
9f63b9f65d
@ -668,12 +668,12 @@ void InitializeCompanies()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* May company \a cbig buy company \a csmall?
|
* Can company \a cbig buy company \a csmall without exceeding vehicle limits?
|
||||||
* @param cbig Company buying \a csmall.
|
* @param cbig Company buying \a csmall.
|
||||||
* @param csmall Company getting bought.
|
* @param csmall Company getting bought.
|
||||||
* @return Return \c true if it is allowed.
|
* @return Return \c true if it is allowed.
|
||||||
*/
|
*/
|
||||||
bool MayCompanyTakeOver(CompanyID cbig, CompanyID csmall)
|
bool CheckTakeoverVehicleLimit(CompanyID cbig, CompanyID csmall)
|
||||||
{
|
{
|
||||||
const Company *c1 = Company::Get(cbig);
|
const Company *c1 = Company::Get(cbig);
|
||||||
const Company *c2 = Company::Get(csmall);
|
const Company *c2 = Company::Get(csmall);
|
||||||
@ -725,7 +725,7 @@ static void HandleBankruptcyTakeover(Company *c)
|
|||||||
if (c2->bankrupt_asked == 0 && // Don't ask companies going bankrupt themselves
|
if (c2->bankrupt_asked == 0 && // Don't ask companies going bankrupt themselves
|
||||||
!HasBit(c->bankrupt_asked, c2->index) &&
|
!HasBit(c->bankrupt_asked, c2->index) &&
|
||||||
best_performance < c2->old_economy[1].performance_history &&
|
best_performance < c2->old_economy[1].performance_history &&
|
||||||
MayCompanyTakeOver(c2->index, c->index)) {
|
CheckTakeoverVehicleLimit(c2->index, c->index)) {
|
||||||
best_performance = c2->old_economy[1].performance_history;
|
best_performance = c2->old_economy[1].performance_history;
|
||||||
best = c2;
|
best = c2;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include "gfx_type.h"
|
#include "gfx_type.h"
|
||||||
#include "vehicle_type.h"
|
#include "vehicle_type.h"
|
||||||
|
|
||||||
bool MayCompanyTakeOver(CompanyID cbig, CompanyID small);
|
bool CheckTakeoverVehicleLimit(CompanyID cbig, CompanyID small);
|
||||||
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner);
|
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner);
|
||||||
static const int OWNED_BY_OWNER_IN_PARAMETERS_OFFSET = 2; ///< The index in the parameters for the owner information.
|
static const int OWNED_BY_OWNER_IN_PARAMETERS_OFFSET = 2; ///< The index in the parameters for the owner information.
|
||||||
void SetDParamsForOwnedBy(Owner owner, TileIndex tile);
|
void SetDParamsForOwnedBy(Owner owner, TileIndex tile);
|
||||||
|
@ -2066,8 +2066,8 @@ CommandCost CmdBuyCompany(DoCommandFlag flags, CompanyID target_company, bool ho
|
|||||||
/* Do not allow companies to take over themselves */
|
/* Do not allow companies to take over themselves */
|
||||||
if (target_company == _current_company) return CMD_ERROR;
|
if (target_company == _current_company) return CMD_ERROR;
|
||||||
|
|
||||||
/* Disable taking over when not allowed. */
|
/* Do not allow takeover if the resulting company would have too many vehicles. */
|
||||||
if (!MayCompanyTakeOver(_current_company, target_company)) return CMD_ERROR;
|
if (!CheckTakeoverVehicleLimit(_current_company, target_company)) return_cmd_error(STR_ERROR_TOO_MANY_VEHICLES_IN_GAME);
|
||||||
|
|
||||||
/* Get the cost here as the company is deleted in DoAcquireCompany.
|
/* Get the cost here as the company is deleted in DoAcquireCompany.
|
||||||
* For bankruptcy this amount is calculated when the offer was made;
|
* For bankruptcy this amount is calculated when the offer was made;
|
||||||
|
Loading…
Reference in New Issue
Block a user