OpenTTD Source 20241224-master-gf74b0cf984
company_base.h File Reference

Definition of stuff that is very close to a company, like the company struct itself. More...

#include "road_type.h"
#include "livery.h"
#include "autoreplace_type.h"
#include "tile_type.h"
#include "timer/timer_game_economy.h"
#include "settings_type.h"
#include "group.h"

Go to the source code of this file.

Data Structures

struct  CompanyEconomyEntry
 Statistics about the economy. More...
 
struct  CompanyInfrastructure
 
class  FreeUnitIDGenerator
 
struct  CompanyProperties
 Statically loadable part of Company pool item. More...
 
struct  Company
 

Typedefs

typedef Pool< Company, CompanyID, 1, MAX_COMPANIESCompanyPool
 

Functions

Money CalculateCompanyValue (const Company *c, bool including_loan=true)
 Calculate the value of the company.
 
Money CalculateHostileTakeoverValue (const Company *c)
 Calculate what you have to pay to take over a company.
 

Variables

static const Money COMPANY_MAX_LOAN_DEFAULT = INT64_MIN
 
CompanyPool _company_pool
 
uint _cur_company_tick_index
 used to generate a name for one company that doesn't have a name yet per tick
 

Detailed Description

Definition of stuff that is very close to a company, like the company struct itself.

Definition in file company_base.h.

Typedef Documentation

◆ CompanyPool

Definition at line 65 of file company_base.h.

Function Documentation

◆ CalculateCompanyValue()

Money CalculateCompanyValue ( const Company c,
bool  including_loan 
)

Calculate the value of the company.

That is the value of all assets (vehicles, stations) and money (including loan), except when including_loan is false which is useful when we want to calculate the value for bankruptcy.

Parameters
cthe company to get the value of.
including_loaninclude the loan in the company value.
Returns
the value of the company.

Definition at line 149 of file economy.cpp.

References CalculateCompanyAssetValue(), CompanyProperties::current_loan, and CompanyProperties::money.

Referenced by CompanyCheckBankrupt(), CompanyWindow::SetStringParameters(), and UpdateCompanyRatingAndValue().

◆ CalculateHostileTakeoverValue()

Money CalculateHostileTakeoverValue ( const Company c)

Calculate what you have to pay to take over a company.

This is different from bankruptcy and company value, and involves a few more parameters to make it more realistic.

You have to pay for:

  • The value of all the assets in the company.
  • The loan the company has (the investors really want their money back).
  • The profit for the next two years (if positive) based on the last four quarters.

And on top of that, they walk away with all the money they have in the bank.

Parameters
cthe company to get the value of.
Returns
The value of the company.

Definition at line 176 of file economy.cpp.

References CalculateCompanyAssetValue(), CompanyProperties::current_loan, CompanyEconomyEntry::expenses, CompanyEconomyEntry::income, CompanyProperties::money, and CompanyProperties::old_economy.

Referenced by CmdBuyCompany().

Variable Documentation

◆ _cur_company_tick_index

uint _cur_company_tick_index
extern

used to generate a name for one company that doesn't have a name yet per tick

Definition at line 56 of file company_cmd.cpp.

Referenced by InitializeCompanies(), and OnTick_Companies().

◆ COMPANY_MAX_LOAN_DEFAULT

const Money COMPANY_MAX_LOAN_DEFAULT = INT64_MIN
static

Definition at line 21 of file company_base.h.