File diff r25561:3defb050f30b → r25562:30716ba6a396
src/economy.cpp
Show inline comments
 
@@ -2008,25 +2008,25 @@ static void DoAcquireCompany(Company *c)
 

	
 
extern int GetAmountOwnedBy(const Company *c, Owner owner);
 

	
 
/**
 
 * Acquire shares in an opposing company.
 
 * @param tile unused
 
 * @param flags type of operation
 
 * @param p1 company to buy the shares from
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CommandCost cost(EXPENSES_OTHER);
 
	CompanyID target_company = (CompanyID)p1;
 
	Company *c = Company::GetIfValid(target_company);
 

	
 
	/* Check if buying shares is allowed (protection against modified clients)
 
	 * Cannot buy own shares */
 
	if (c == nullptr || !_settings_game.economy.allow_shares || _current_company == target_company) return CMD_ERROR;
 

	
 
	/* Protect new companies from hostile takeovers */
 
	if (_cur_year - c->inaugurated_year < _settings_game.economy.min_years_for_shares) return_cmd_error(STR_ERROR_PROTECTED);
 

	
 
@@ -2060,25 +2060,25 @@ CommandCost CmdBuyShareInCompany(TileInd
 
	return cost;
 
}
 

	
 
/**
 
 * Sell shares in an opposing company.
 
 * @param tile unused
 
 * @param flags type of operation
 
 * @param p1 company to sell the shares from
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CompanyID target_company = (CompanyID)p1;
 
	Company *c = Company::GetIfValid(target_company);
 

	
 
	/* Cannot sell own shares */
 
	if (c == nullptr || _current_company == target_company) return CMD_ERROR;
 

	
 
	/* Check if selling shares is allowed (protection against modified clients).
 
	 * However, we must sell shares of companies being closed down. */
 
	if (!_settings_game.economy.allow_shares && !(flags & DC_BANKRUPT)) return CMD_ERROR;
 

	
 
	/* Those lines are here for network-protection (clients can be slow) */
 
@@ -2101,25 +2101,25 @@ CommandCost CmdSellShareInCompany(TileIn
 
/**
 
 * Buy up another company.
 
 * When a competing company is gone bankrupt you get the chance to purchase
 
 * that company.
 
 * @todo currently this only works for AI companies
 
 * @param tile unused
 
 * @param flags type of operation
 
 * @param p1 company to buy up
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CompanyID target_company = (CompanyID)p1;
 
	Company *c = Company::GetIfValid(target_company);
 
	if (c == nullptr) return CMD_ERROR;
 

	
 
	/* Disable takeovers when not asked */
 
	if (!HasBit(c->bankrupt_asked, _current_company)) return CMD_ERROR;
 

	
 
	/* Disable taking over the local company in singleplayer mode */
 
	if (!_networking && _local_company == c->index) return CMD_ERROR;
 

	
 
	/* Do not allow companies to take over themselves */