OpenTTD Source
20240915-master-g3784a3d3d6
|
Go to the documentation of this file.
45 #include "table/strings.h"
68 this->name_1 = name_1;
132 if (switching_company) {
163 DrawSprite(SPR_COMPANY_ICON, COMPANY_SPRITE_COLOUR(c), x, y);
182 for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
184 case CMFV_MOUSTACHE:
if (!has_moustache)
continue;
break;
186 case CMFV_NOSE:
if (has_moustache)
continue;
break;
187 case CMFV_TIE_EARRING:
if (!has_tie_earring)
continue;
break;
188 case CMFV_GLASSES:
if (!has_glasses)
continue;
break;
243 if (cost.
GetCost() <= 0)
return true;
249 cost.
MakeError(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY);
262 if (cost.
GetCost() == 0)
return;
312 static constexpr
void UpdateLandscapingLimit(uint32_t &limit, uint64_t per_64k_frames, uint64_t burst)
314 limit =
static_cast<uint32_t
>(std::min<uint64_t>(limit + per_64k_frames, burst << 16));
400 if (c->
name_1 != STR_SV_UNNAMED)
return;
408 if (t->
name.empty() &&
IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1)) {
409 str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_COMPANY_NAME_START;
410 strp = t->townnameparts;
415 if (cc->name_1 == str && cc->name_2 == strp)
goto bad_town_name;
430 SetDParam(0, STR_NEWS_COMPANY_LAUNCH_TITLE);
431 SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION);
441 str = SPECSTR_ANDCO_NAME;
445 str = SPECSTR_ANDCO_NAME;
452 static const uint8_t
_colour_sort[COLOUR_END] = {2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 1, 1, 1};
455 { COLOUR_BLUE, COLOUR_LIGHT_BLUE },
456 { COLOUR_GREEN, COLOUR_DARK_GREEN },
457 { INVALID_COLOUR, INVALID_COLOUR },
458 { COLOUR_ORANGE, INVALID_COLOUR },
459 { INVALID_COLOUR, INVALID_COLOUR },
460 { COLOUR_DARK_BLUE, COLOUR_BLUE },
461 { COLOUR_PALE_GREEN, COLOUR_DARK_GREEN },
462 { COLOUR_PALE_GREEN, COLOUR_GREEN },
463 { COLOUR_DARK_BLUE, COLOUR_LIGHT_BLUE },
464 { COLOUR_BROWN, COLOUR_ORANGE },
465 { COLOUR_PURPLE, INVALID_COLOUR },
466 { COLOUR_MAUVE, INVALID_COLOUR },
467 { COLOUR_YELLOW, COLOUR_CREAM },
468 { COLOUR_CREAM, INVALID_COLOUR },
469 { COLOUR_WHITE, INVALID_COLOUR },
470 { COLOUR_GREY, INVALID_COLOUR },
479 Colours colours[COLOUR_END];
482 for (uint i = 0; i < COLOUR_END; i++) colours[i] = static_cast<Colours>(i);
485 for (uint i = 0; i < 100; i++) {
487 Swap(colours[
GB(r, 0, 4)], colours[
GB(r, 4, 4)]);
491 for (uint i = 0; i < COLOUR_END; i++) {
492 for (uint j = 1; j < COLOUR_END; j++) {
494 Swap(colours[j - 1], colours[j]);
501 Colours pcolour = c->colour;
503 for (uint i = 0; i < COLOUR_END; i++) {
504 if (colours[i] == pcolour) {
505 colours[i] = INVALID_COLOUR;
510 for (uint j = 0; j < 2; j++) {
512 if (similar == INVALID_COLOUR)
break;
514 for (uint i = 1; i < COLOUR_END; i++) {
515 if (colours[i - 1] == similar)
Swap(colours[i - 1], colours[i]);
521 for (uint i = 0; i < COLOUR_END; i++) {
522 if (colours[i] != INVALID_COLOUR)
return colours[i];
548 std::string other_name =
GetString(STR_PRESIDENT_NAME);
549 if (
name == other_name)
goto restart;
563 for (
LiveryScheme scheme = LS_BEGIN; scheme < LS_END; scheme++) {
564 c->livery[scheme].
in_use = 0;
570 if (g->owner == c->
index) {
571 g->livery.in_use = 0;
572 g->livery.colour1 = c->
colour;
573 g->livery.colour2 = c->
colour;
594 c =
new Company(STR_SV_UNNAMED, is_ai);
597 c =
new (company)
Company(STR_SV_UNNAMED, is_ai);
722 int32_t best_performance = -1;
726 if (c2->bankrupt_asked == 0 &&
728 best_performance < c2->old_economy[1].performance_history &&
736 if (best_performance == -1) {
754 if (_game_mode == GM_EDITOR)
return;
780 timeout += ScriptObject::GetRandomizer(
OWNER_NONE).Next(timeout / 4) - timeout / 8;
782 _new_competitor_timeout.Reset({ TimerGameTick::Priority::COMPETITOR_TIMEOUT,
static_cast<uint
>(std::max(1, timeout)) });
797 std::rotate(std::rbegin(c->yearly_expenses), std::rbegin(c->yearly_expenses) + 1, std::rend(c->yearly_expenses));
798 c->yearly_expenses[0] = {};
823 if (other !=
nullptr) {
952 SetDParam(0, STR_NEWS_COMPANY_BANKRUPT_TITLE);
953 SetDParam(1, STR_NEWS_COMPANY_BANKRUPT_DESCRIPTION);
955 AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, cni);
1022 if (ExecuteAllowListCtrlAction(action, c, public_key)) {
1055 for (
int i = 1; i < LS_END; i++) {
1072 if (scheme >= LS_END || (colour >= COLOUR_END && colour != INVALID_COLOUR))
return CMD_ERROR;
1075 if (scheme == LS_DEFAULT && colour == INVALID_COLOUR)
return CMD_ERROR;
1080 if (scheme == LS_DEFAULT && primary) {
1088 if (scheme != LS_DEFAULT)
AssignBit(c->livery[scheme].
in_use, 0, colour != INVALID_COLOUR);
1089 if (colour == INVALID_COLOUR) colour = c->livery[LS_DEFAULT].
colour1;
1090 c->livery[scheme].
colour1 = colour;
1094 if (scheme == LS_DEFAULT) {
1101 if (scheme != LS_DEFAULT)
AssignBit(c->livery[scheme].
in_use, 1, colour != INVALID_COLOUR);
1102 if (colour == INVALID_COLOUR) colour = c->livery[LS_DEFAULT].
colour2;
1103 c->livery[scheme].
colour2 = colour;
1105 if (scheme == LS_DEFAULT) {
1110 if (c->livery[scheme].
in_use != 0) {
1112 c->livery[LS_DEFAULT].
in_use = 1;
1116 c->livery[LS_DEFAULT].
in_use = 0;
1117 for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
1118 if (c->livery[scheme].
in_use != 0) {
1119 c->livery[LS_DEFAULT].
in_use = 1;
1125 ResetVehicleColourMap();
1171 bool reset = text.empty();
1214 bool reset = text.empty();
1229 if (c->
name_1 == STR_SV_UNNAMED && c->
name.empty()) {
1252 default: NOT_REACHED();
1268 if (RoadTypeIsRoad(rt)) total += this->
road[rt];
1281 if (RoadTypeIsTram(rt)) total += this->
road[rt];
1315 std::string dest_company_name =
GetString(STR_COMPANY_NAME);
1318 std::string from_company_name =
GetString(STR_COMPANY_NAME);
bool give_money
allow giving other companies money
uint8_t GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
static void HandleBankruptcyTakeover(Company *c)
Handle the bankruptcy take over of a company.
void BuildOwnerLegend()
Completes the array for the owned property legend.
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
UnitID max_aircraft
max planes in game per company
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
static Titem * Get(size_t index)
Returns Titem with given index.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
GroupStatistics group_all[VEH_COMPANY_END]
NOSAVE: Statistics for the ALL_GROUP group.
void CompanyAdminUpdate(const Company *company)
Called whenever company related information changes in order to notify admins.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
uint32_t tree_per_64k_frames
how many trees may, over a long period, be planted per 65536 frames?
constexpr void Swap(T &a, T &b)
Type safe swap operation.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
RailTypes avail_railtypes
Rail types available to this company.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
static void GenerateCompanyName(Company *c)
Generate the name of a company from the last build coordinate.
Class to backup a specific variable and restore it later.
@ NR_TILE
Reference tile. Scroll to tile when clicking on the news.
void SetDefaultCompanySettings(CompanyID cid)
Set the company settings for a new company to their default values.
@ EXPENSES_TRAIN_REVENUE
Revenue from trains.
RoadTypes avail_roadtypes
Road types available to this company.
static const Colours _similar_colour[COLOUR_END][2]
Similar colours, so we can try to prevent same coloured companies.
void UpdateObjectColours(const Company *c)
Updates the colour of the object whenever a company changes.
CompanyID client_playas
As which company is this client playing (CompanyID)
static const int LOAN_INTERVAL
The "steps" in loan size, in British Pounds!
@ INVALID_EXPENSES
Invalid expense type.
@ INVALID_COMPANY
An invalid company.
@ INVALID_OWNER
An invalid owner.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
uint16_t tree_frame_burst
how many trees may, over a short period, be planted?
bool _network_server
network-server is active
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, [[maybe_unused]] GenderEthnicity ge)
Make sure the table's size is right.
@ WC_CLIENT_LIST
Client list; Window numbers:
An interval timer will fire every interval, and will continue to fire until it is deleted.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
GenderEthnicity
The gender/race combinations that we have faces for.
Owner
Enum for all companies/owners.
Tindex index
Index of this pool item.
@ VEH_TRAIN
Train vehicle type.
void NetworkUpdateClientInfo(ClientID client_id)
Send updated client info of a particular client.
static void PostDestructor(size_t index)
Invalidating some stuff after removing item from the pool.
@ WC_PERFORMANCE_HISTORY
Performance history graph; Window numbers:
DifficultySettings difficulty
settings related to the difficulty
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ ROADTYPE_BEGIN
Used for iterations.
@ WC_SIGN_LIST
Sign list; Window numbers:
@ EXPENSES_SHIP_RUN
Running costs ships.
VehicleDefaultSettings vehicle
default settings for vehicles
void SetLocalCompany(CompanyID new_company)
Sets the local company and updates the settings that are set on a per-company basis to reflect the co...
static bool CanStartNew()
Is it possible to start a new AI company?
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
int16_t bankrupt_timeout
If bigger than 0, amount of time to wait for an answer on an offer to buy this company.
@ VEH_ROAD
Road vehicle type.
CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id)
Control the companies: add, delete, etc.
std::string name
Name of the company if the user changed it.
Randomizer _random
Random used in the game state calculations.
Money max_loan
NOSAVE: Maximum possible loan.
ClientSettings _settings_client
The current settings for this game.
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
void CloseCompanyWindows(CompanyID company)
Close all windows of a company.
@ WC_COMPANY
Company view; Window numbers:
bool new_year
Play sound on new year, summarising the performance during the last year.
TileIndex last_build_coordinate
Coordinate of the last build thing by this company.
CompanyManagerFace face
Face description of the president.
@ WC_GOALS_LIST
Goals list; Window numbers:
uint32_t president_name_2
Parameter of president_name_1.
uint32_t build_object_per_64k_frames
how many tiles may, over a long period, be purchased or have objects built on them per 65536 frames?
@ DC_EXEC
execute the given command
CommandCost CmdSetCompanyColour(DoCommandFlag flags, LiveryScheme scheme, bool primary, Colours colour)
Change the company's company-colour.
@ WC_COMPANY_LEAGUE
Company league window; Window numbers:
DoCommandFlag
List of flags for a command.
Money current_loan
Amount of money borrowed from the bank.
uint _cur_company_tick_index
used to generate a name for one company that doesn't have a name yet per tick
void InitializeCompanies()
Initialize the pool of companies.
void ClearEnginesHiddenFlagOfCompany(CompanyID cid)
Clear the 'hidden' flag for all engines of a new company.
bool Add(std::string_view key)
Add the given key to the authorized keys, when it is not already contained.
static const uint MAX_LENGTH_COMPANY_NAME_CHARS
The maximum length of a company name in characters including '\0'.
static void StartNew(CompanyID company)
Start a new AI company.
CommandCost CmdSetCompanyManagerFace(DoCommandFlag flags, CompanyManagerFace cmf)
Change the company manager's face.
@ GENDER_FEMALE
This bit set means a female, otherwise male.
@ WC_DELIVERED_CARGO
Delivered cargo graph; Window numbers:
bool Remove(std::string_view key)
Remove the given key from the authorized keys, when it is exists.
@ EXPENSES_TRAIN_RUN
Running costs trains.
@ WC_GRAPH_LEGEND
Legend for graphs; Window numbers:
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
size_t Utf8StringLength(const char *s)
Get the length of an UTF-8 encoded string in number of characters and thus not the number of bytes th...
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
Colours _company_colours[MAX_COMPANIES]
NOSAVE: can be determined from company structs.
@ COMPANY_FIRST
First company, same as owner.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
void StartupCompanies()
Start of a new game.
CommandCost CmdGiveMoney(DoCommandFlag flags, Money money, CompanyID dest_company)
Transfer funds (money) from one company to another.
Money GetAvailableMoneyForCommand()
This functions returns the money which can be used to execute a command.
static void NewEvent(CompanyID company, ScriptEvent *event)
Queue a new event for an AI.
Common return value for all commands.
static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS
The maximum length of a president name in characters including '\0'.
TimeoutTimer< TimerGameTick > _new_competitor_timeout({ TimerGameTick::Priority::COMPETITOR_TIMEOUT, 0 }, []() { if(_game_mode==GM_MENU||!AI::CanStartNew()) return;if(_networking &&Company::GetNumItems() >=_settings_client.network.max_companies) return;uint8_t n=0;for(const Company *c :Company::Iterate()) { if(c->is_ai) n++;} if(n >=_settings_game.difficulty.max_no_competitors) return;Command< CMD_COMPANY_CTRL >::Post(CCA_NEW_AI, INVALID_COMPANY, CRR_NONE, INVALID_CLIENT_ID);})
Start a new competitor company if possible.
SoundSettings sound
sound effect settings
@ OWNER_NONE
The tile has no ownership.
ExpensesType GetExpensesType() const
The expense type of the cost.
bool AreCompanyManagerFaceBitsValid(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Checks whether the company manager's face bits have a valid range.
uint8_t in_use
Bit 0 set if this livery should override the default livery first colour, Bit 1 for the second colour...
@ CALCA_REMOVE
Remove a public key.
uint16_t competitors_interval
the interval (in minutes) between adding competitors
@ CCA_NEW_AI
Create a new AI company.
UnitID max_ships
max ships in game per company
bool CheckTakeoverVehicleLimit(CompanyID cbig, CompanyID csmall)
Can company cbig buy company csmall without exceeding vehicle limits?
void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cst)
Subtract money from a company, including the money fraction.
@ EXPENSES_AIRCRAFT_RUN
Running costs aircraft.
@ NT_COMPANY_INFO
Company info (new companies, bankruptcy messages)
static void GeneratePresidentName(Company *c)
Generate a random president name of a company.
uint16_t clear_frame_burst
how many tiles may, over a short period, be cleared?
void MakeError(StringID message, StringID extra_message=INVALID_STRING_ID)
Makes this CommandCost behave like an error command.
Colours colour
Company colour.
Money money
Money owned by the company.
void InvalidateCompanyWindows(const Company *company)
Refresh all windows owned by a company.
LiveryScheme
List of different livery schemes.
CompanyAllowListCtrlAction
The action to do with CMD_COMPANY_ALLOW_LIST_CTRL.
@ VEH_SHIP
Ship vehicle type.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ TC_IS_PALETTE_COLOUR
Colour value is already a real palette colour index, not an index of a StringColour.
CompanySettings settings
settings specific for each company
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
RoadType
The different roadtypes we support.
uint32_t name_2
Parameter of name_1.
EconomySettings economy
settings to change the economy
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
void SyncCompanySettings()
Sync all company settings in a multiplayer game.
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company=MAX_COMPANIES)
Broadcast a new event to all active AIs.
@ EXPENSES_ROADVEH_REVENUE
Revenue from road vehicles.
Money GetCost() const
The costs as made up to this moment.
uint32_t CompanyManagerFace
Company manager face bits, info see in company_manager_face.h.
uint16_t servint_aircraft
service interval for aircraft
bool _networking
are we in networking mode?
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
std::string president_name
Name of the president if the user changed it.
void SetDParamsForOwnedBy(Owner owner, TileIndex tile)
Set the right DParams for STR_ERROR_OWNED_BY.
static bool IsValidCompanyManagerFace(CompanyManagerFace cmf)
Checks whether a company manager's face is a valid encoding.
Default settings for vehicles.
@ DESTTYPE_TEAM
Send message/notice to everyone playing the same company (Team)
AdminCompanyRemoveReason
Reasons for removing a company - communicated to admins.
static const uint8_t _colour_sort[COLOUR_END]
Sorting weights for the company colours.
Money GetMaxLoan() const
Calculate the max allowed loan for this company.
@ OWNER_END
Last + 1 owner.
void ShowBuyCompanyDialog(CompanyID company, bool hostile_takeover)
Show the query to buy another company.
@ WC_INCOME_GRAPH
Income graph; Window numbers:
static bool IsHumanID(size_t index)
Is this company a company not controlled by a NoAI program?
void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr)
Notify the admin network of a company to be removed (including the reason why).
uint16_t num_vehicle
Number of vehicles.
@ WC_LINKGRAPH_LEGEND
Linkgraph legend; Window numbers:
@ EXPENSES_OTHER
Other expenses.
bool CheckCompanyHasMoney(CommandCost &cost)
Verify whether the company can pay the bill.
void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
Called whenever a company is removed in order to notify admins.
CompanyMask bankrupt_asked
which companies were asked about buying it?
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
ClientID client_id
Client identifier (same as ClientState->client_id)
uint8_t max_no_competitors
the number of competitors (AIs)
@ EXPENSES_LOAN_INTEREST
Interest payments over the loan.
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
static IntervalTimer< TimerGameEconomy > _economy_companies_yearly({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::COMPANY}, [](auto) { for(Company *c :Company::Iterate()) { std::rotate(std::rbegin(c->yearly_expenses), std::rbegin(c->yearly_expenses)+1, std::rend(c->yearly_expenses));c->yearly_expenses[0]={};SetWindowDirty(WC_FINANCES, c->index);} if(_settings_client.gui.show_finances &&_local_company !=COMPANY_SPECTATOR) { ShowCompanyFinances(_local_company);Company *c=Company::Get(_local_company);if(c->num_valid_stat_ent > 5 &&c->old_economy[0].performance_history< c->old_economy[4].performance_history) { if(_settings_client.sound.new_year) SndPlayFx(SND_01_BAD_YEAR);} else { if(_settings_client.sound.new_year) SndPlayFx(SND_00_GOOD_YEAR);} } })
A year has passed, update the economic data of all companies, and perhaps show the financial overview...
ClientID _network_own_client_id
Our client identifier.
TimerGameCalendar::Year inaugurated_year_calendar
Calendar year of starting the company. Used to display proper Inauguration year while in wallclock mo...
void NetworkAdminCompanyUpdate(const Company *company)
Notify the admin network of company updates.
constexpr T AssignBit(T &x, const uint8_t y, bool value)
Assigns a bit in a variable.
@ ROADTYPE_END
Used for iterations.
CompanyPool _company_pool("Company")
Pool of companies.
@ WC_COMPANY_VALUE
Company value graph; Window numbers:
static bool IsUniqueCompanyName(const std::string &name)
Is the given name in use as name of a company?
@ CCA_NEW
Create a new company.
Money expenses
The amount of expenses.
TimerGameEconomy::Year inaugurated_year
Economy year of starting the company.
CompanyID _current_company
Company currently doing an action.
@ WC_GAME_OPTIONS
Game options window; Window numbers:
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
@ EXPENSES_AIRCRAFT_REVENUE
Revenue from aircraft.
A timeout timer will fire once after the interval.
int32_t performance_history
Company score (scale 0-1000)
static Year year
Current year, starting at 0.
Base class for all pools.
uint32_t GetTramTotal() const
Get total sum of all owned tram bits.
CompanyEconomyEntry cur_economy
Economic data of the company of this quarter.
static const uint NETWORK_PUBLIC_KEY_LENGTH
The maximum length of the hexadecimal encoded public keys, in bytes including '\0'.
ClientID
'Unique' identifier to be given to clients
@ WC_PERFORMANCE_DETAIL
Performance detail window; Window numbers:
UnitID max_trains
max trains in game per company
static size_t GetNumItems()
Returns number of valid items in the pool.
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
uint64_t inflation_prices
Cumulated inflation of prices since game start; 16 bit fractional part.
bool infinite_money
whether spending money despite negative balance is allowed
void Restore()
Restore the variable.
std::array< Expenses, 3 > yearly_expenses
Expenses of the company for the last three years.
bool show_finances
show finances at end of year
TextColour GetDrawStringCompanyColour(CompanyID company)
Get the colour for DrawString-subroutines which matches the colour of the company.
CompanyManagerFace _company_manager_face
for company manager face storage in openttd.cfg
@ CRR_NONE
Dummy reason for actions that don't need one.
@ NF_COMPANY
Company news item. (Newspaper with face)
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
int CompanyServiceInterval(const Company *c, VehicleType type)
Get the service interval for the given company and vehicle type.
@ EXPENSES_ROADVEH_RUN
Running costs road vehicles.
@ EXPENSES_PROPERTY
Property costs.
void NetworkServerNewCompany(const Company *company, NetworkClientInfo *ci)
Perform all the server specific administration of a new company.
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers:
Colours colour1
First colour, for all vehicles.
static bool CleaningPool()
Returns current state of pool cleaning - yes or no.
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1=NR_NONE, uint32_t ref1=UINT32_MAX, NewsReferenceType reftype2=NR_NONE, uint32_t ref2=UINT32_MAX, const NewsAllocatedData *data=nullptr)
Add a new newsitem to be shown.
std::array< uint32_t, ROADTYPE_END > road
Count of company owned track bits for each road type.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
uint32_t GetRoadTotal() const
Get total sum of all owned road bits.
uint8_t max_companies
maximum amount of companies
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
std::string name
Full name of the script.
CompanyID GetFirstPlayableCompanyID()
Get the index of the first available company.
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
CompanyCtrlAction
The action to do with CMD_COMPANY_CTRL.
uint8_t num_valid_stat_ent
Number of valid statistical entries in old_economy.
static void SubtractMoneyFromAnyCompany(Company *c, const CommandCost &cost)
Deduct costs of a command from the money of a company.
@ INVALID_CLIENT_ID
Client is not part of anything.
Company * DoStartupNewCompany(bool is_ai, CompanyID company=INVALID_COMPANY)
Create a new company and sets all company variables default values.
uint16_t build_object_frame_burst
how many tiles may, over a short period, be purchased or have objects built on them?
uint16_t servint_trains
service interval for trains
UnitID max_roadveh
max trucks in game per company
uint32_t clear_per_64k_frames
how many tiles may, over a long period, be cleared per 65536 frames?
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
static constexpr TimerGameTick::Ticks TICKS_PER_SECOND
Estimation of how many ticks fit in a single second.
void NetworkAdminCompanyNew(const Company *company)
Notify the admin network of a new company.
NetworkAuthorizedKeys allow_list
Public keys of clients that are allowed to join this company.
Money income
The amount of income.
StringID president_name_1
Name of the president if the user did not change it.
uint16_t servint_ships
service interval for ships
CommandCost CheckTileOwnership(TileIndex tile)
Check whether the current owner owns the stuff on the given tile.
@ WC_SEND_NETWORK_MSG
Chatbox; Window numbers:
@ SND_01_BAD_YEAR
40 == 0x28 New year: performance declined
@ CALCA_ADD
Create a public key.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
NetworkSettings network
settings related to the network
@ COMPANY_SPECTATOR
The client is spectating.
void UpdateCompanyLiveries(Company *c)
Update liveries for a company.
VehicleType
Available vehicle types.
@ CRR_END
Sentinel for end.
bool IsInteractiveCompany(CompanyID company)
Is the user representing company?
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ SND_00_GOOD_YEAR
39 == 0x27 New year: performance improved
static const int64_t INITIAL_LOAN
The size of loan for a new company, in British Pounds!
CompanySettings company
default values for per-company settings
ConstructionSettings construction
construction of things in-game
VehicleSettings vehicle
options for vehicles
static bool IsUniquePresidentName(const std::string &name)
Is the given name in use as president name of a company?
static constexpr TimerGameTick::Ticks DAY_TICKS
1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16_t and incremented by 885.
@ MAX_COMPANIES
Maximum number of companies.
Money GetAvailableMoney(CompanyID company)
Get the amount of money that a company has available, or INT64_MAX if there is no such valid company.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
uint16_t terraform_frame_burst
how many tile heights may, over a short period, be terraformed?
@ GE_WM
A male of Caucasian origin (white)
void SubtractMoneyFromCompany(const CommandCost &cost)
Subtract money from the _current_company, if the company is valid.
void CloseConstructionWindows()
Close all windows that are used for construction of vehicle etc.
static void Stop(CompanyID company)
Stop a company to be controlled by an AI.
@ WC_FINANCES
Finances of a company; Window numbers:
void OnTick_Companies()
Called every tick for updating some company info.
@ EXPENSES_SHIP_REVENUE
Revenue from ships.
@ WN_NETWORK_STATUS_WINDOW_JOIN
Network join status.
static Colours GenerateCompanyColour()
Generate a company colour.
@ WC_ERRMSG
Error message; Window numbers:
@ WC_OPERATING_PROFIT
Operating profit graph; Window numbers:
@ WC_SCRIPT_SETTINGS
Script settings; Window numbers:
CommandCost CmdCompanyAllowListCtrl(DoCommandFlag flags, CompanyAllowListCtrlAction action, const std::string &public_key)
Add or remove the given public key to the allow list of this company.
@ CCA_DELETE
Delete a company.
@ WC_SCRIPT_LIST
Scripts list; Window numbers:
bool IsLocalCompany()
Is the current company the local company?
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
Change the ownership of all the items of a company.
std::string name
Custom town name. If empty, the town was not renamed and uses the generated name.
Colours colour2
Second colour, for vehicles with 2CC support.
void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv, Randomizer &randomizer)
Make a random new face.
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, WidgetID widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting)
static const int OWNED_BY_OWNER_IN_PARAMETERS_OFFSET
The index in the parameters for the owner information.
uint16_t servint_roadveh
service interval for road vehicles
@ WC_SMALLMAP
Small map; Window numbers:
void UpdateLandscapingLimits()
Update the landscaping limits per company.
void UpdateCompanyGroupLiveries(const Company *c)
Update group liveries for a company.
Container for all information known about a client.
@ NR_NONE
Empty reference.
CompanyRemoveReason
The reason why the company was removed.
uint8_t money_fraction
Fraction of money of the company, too small to represent in money.
void ResetCompanyLivery(Company *c)
Reset the livery schemes to the company's primary colour.
GUISettings gui
settings related to the GUI
CommandCost CmdRenameCompany(DoCommandFlag flags, const std::string &text)
Change the name of the company.
StringID name_1
Name of the company if the user did not change it.
Money max_loan
Max allowed amount of the loan or COMPANY_MAX_LOAN_DEFAULT.
CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text)
Change the name of the president.
uint32_t terraform_per_64k_frames
how many tile heights may, over a long period, be terraformed per 65536 frames?
static Year year
Current year, starting at 0.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.