OpenTTD Source
20241108-master-g80f628063a
|
Handling of companies. More...
#include "stdafx.h"
#include "company_base.h"
#include "company_func.h"
#include "company_gui.h"
#include "core/backup_type.hpp"
#include "town.h"
#include "news_func.h"
#include "command_func.h"
#include "network/network.h"
#include "network/network_func.h"
#include "network/network_base.h"
#include "network/network_admin.h"
#include "ai/ai.hpp"
#include "ai/ai_instance.hpp"
#include "ai/ai_config.hpp"
#include "company_manager_face.h"
#include "window_func.h"
#include "strings_func.h"
#include "sound_func.h"
#include "rail.h"
#include "core/pool_func.hpp"
#include "settings_func.h"
#include "vehicle_base.h"
#include "vehicle_func.h"
#include "smallmap_gui.h"
#include "game/game.hpp"
#include "goal_base.h"
#include "story_base.h"
#include "company_cmd.h"
#include "timer/timer.h"
#include "timer/timer_game_economy.h"
#include "timer/timer_game_tick.h"
#include "widgets/statusbar_widget.h"
#include "table/strings.h"
#include "safeguards.h"
Go to the source code of this file.
Functions | |
void | ClearEnginesHiddenFlagOfCompany (CompanyID cid) |
Clear the 'hidden' flag for all engines of a new company. More... | |
void | UpdateObjectColours (const Company *c) |
Updates the colour of the object whenever a company changes. More... | |
void | SetLocalCompany (CompanyID new_company) |
Sets the local company and updates the settings that are set on a per-company basis to reflect the core's state in the GUI. More... | |
TextColour | GetDrawStringCompanyColour (CompanyID company) |
Get the colour for DrawString-subroutines which matches the colour of the company. More... | |
void | DrawCompanyIcon (CompanyID c, int x, int y) |
Draw the icon of a company. More... | |
static bool | IsValidCompanyManagerFace (CompanyManagerFace cmf) |
Checks whether a company manager's face is a valid encoding. More... | |
void | InvalidateCompanyWindows (const Company *company) |
Refresh all windows owned by a company. More... | |
Money | GetAvailableMoney (CompanyID company) |
Get the amount of money that a company has available, or INT64_MAX if there is no such valid company. More... | |
Money | GetAvailableMoneyForCommand () |
This functions returns the money which can be used to execute a command. More... | |
bool | CheckCompanyHasMoney (CommandCost &cost) |
Verify whether the company can pay the bill. More... | |
static void | SubtractMoneyFromAnyCompany (Company *c, const CommandCost &cost) |
Deduct costs of a command from the money of a company. More... | |
void | SubtractMoneyFromCompany (const CommandCost &cost) |
Subtract money from the _current_company, if the company is valid. More... | |
void | SubtractMoneyFromCompanyFract (CompanyID company, const CommandCost &cst) |
Subtract money from a company, including the money fraction. More... | |
static constexpr void | UpdateLandscapingLimit (uint32_t &limit, uint64_t per_64k_frames, uint64_t burst) |
void | UpdateLandscapingLimits () |
Update the landscaping limits per company. | |
void | SetDParamsForOwnedBy (Owner owner, TileIndex tile) |
Set the right DParams for STR_ERROR_OWNED_BY. More... | |
CommandCost | CheckOwnership (Owner owner, TileIndex tile) |
Check whether the current owner owns something. More... | |
CommandCost | CheckTileOwnership (TileIndex tile) |
Check whether the current owner owns the stuff on the given tile. More... | |
static void | GenerateCompanyName (Company *c) |
Generate the name of a company from the last build coordinate. More... | |
static Colours | GenerateCompanyColour () |
Generate a company colour. More... | |
static void | GeneratePresidentName (Company *c) |
Generate a random president name of a company. More... | |
void | ResetCompanyLivery (Company *c) |
Reset the livery schemes to the company's primary colour. More... | |
Company * | DoStartupNewCompany (bool is_ai, CompanyID company=INVALID_COMPANY) |
Create a new company and sets all company variables default values. More... | |
void | StartupCompanies () |
Start of a new game. | |
void | InitializeCompanies () |
Initialize the pool of companies. | |
bool | CheckTakeoverVehicleLimit (CompanyID cbig, CompanyID csmall) |
Can company cbig buy company csmall without exceeding vehicle limits? More... | |
static void | HandleBankruptcyTakeover (Company *c) |
Handle the bankruptcy take over of a company. More... | |
void | OnTick_Companies () |
Called every tick for updating some company info. | |
void | CompanyAdminUpdate (const Company *company) |
Called whenever company related information changes in order to notify admins. More... | |
void | CompanyAdminRemove (CompanyID company_id, CompanyRemoveReason reason) |
Called whenever a company is removed in order to notify admins. More... | |
CommandCost | CmdCompanyCtrl (DoCommandFlag flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id) |
Control the companies: add, delete, etc. More... | |
static bool | ExecuteAllowListCtrlAction (CompanyAllowListCtrlAction action, Company *c, const std::string &public_key) |
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. More... | |
CommandCost | CmdSetCompanyManagerFace (DoCommandFlag flags, CompanyManagerFace cmf) |
Change the company manager's face. More... | |
void | UpdateCompanyLiveries (Company *c) |
Update liveries for a company. More... | |
CommandCost | CmdSetCompanyColour (DoCommandFlag flags, LiveryScheme scheme, bool primary, Colours colour) |
Change the company's company-colour. More... | |
static bool | IsUniqueCompanyName (const std::string &name) |
Is the given name in use as name of a company? More... | |
CommandCost | CmdRenameCompany (DoCommandFlag flags, const std::string &text) |
Change the name of the company. More... | |
static bool | IsUniquePresidentName (const std::string &name) |
Is the given name in use as president name of a company? More... | |
CommandCost | CmdRenamePresident (DoCommandFlag flags, const std::string &text) |
Change the name of the president. More... | |
int | CompanyServiceInterval (const Company *c, VehicleType type) |
Get the service interval for the given company and vehicle type. More... | |
CommandCost | CmdGiveMoney (DoCommandFlag flags, Money money, CompanyID dest_company) |
Transfer funds (money) from one company to another. More... | |
CompanyID | GetFirstPlayableCompanyID () |
Get the index of the first available company. More... | |
Variables | |
CompanyID | _local_company |
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR. | |
CompanyID | _current_company |
Company currently doing an action. | |
Colours | _company_colours [MAX_COMPANIES] |
NOSAVE: can be determined from company structs. | |
CompanyManagerFace | _company_manager_face |
for company manager face storage in openttd.cfg | |
uint | _cur_company_tick_index |
used to generate a name for one company that doesn't have a name yet per tick | |
CompanyPool | _company_pool ("Company") |
Pool of companies. | |
static const uint8_t | _colour_sort [COLOUR_END] = {2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 1, 1, 1} |
Sorting weights for the company colours. | |
static const Colours | _similar_colour [COLOUR_END][2] |
Similar colours, so we can try to prevent same coloured companies. More... | |
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. | |
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 window of the local company. | |
Handling of companies.
Definition in file company_cmd.cpp.
bool CheckCompanyHasMoney | ( | CommandCost & | cost | ) |
Verify whether the company can pay the bill.
[in,out] | cost | Money to pay, is changed to an error if the company does not have enough money. |
true
if the company has enough money or infinite money is enabled, else it returns false
. Definition at line 241 of file company_cmd.cpp.
References _current_company, _settings_game, GameSettings::difficulty, CommandCost::GetCost(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), DifficultySettings::infinite_money, CommandCost::MakeError(), CompanyProperties::money, and SetDParam().
Referenced by CommandHelperBase::InternalDoAfter(), and CommandHelperBase::InternalExecuteValidateTestAndPrepExec().
CommandCost CheckOwnership | ( | Owner | owner, |
TileIndex | tile | ||
) |
Check whether the current owner owns something.
If that isn't the case an appropriate error will be given.
owner | the owner of the thing to check. |
tile | optional tile to get the right town. |
Definition at line 363 of file company_cmd.cpp.
References _current_company, OWNER_END, OWNER_TOWN, return_cmd_error, and SetDParamsForOwnedBy().
Referenced by CmdAutofillTimetable(), CmdAutoreplaceVehicle(), CmdCloneOrder(), CmdCloneVehicle(), CmdDeleteOrder(), CmdForceTrainProceed(), CmdInsertOrder(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdOpenCloseAirport(), CmdOrderRefit(), CmdRefitVehicle(), CmdRenameStation(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdReverseTrainDirection(), CmdSellVehicle(), CmdSetTimetableStart(), CmdSetVehicleOnTime(), CmdSkipToOrder(), CmdStartStopVehicle(), CmdTurnRoadVeh(), RemoveAirport(), RemoveDock(), RemoveRoadStop(), RemoveRoadWaypointStop(), and Vehicle::SendToDepot().
Can company cbig buy company csmall without exceeding vehicle limits?
true
if it is allowed. Definition at line 677 of file company_cmd.cpp.
References _settings_game, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Company::group_all, VehicleSettings::max_aircraft, VehicleSettings::max_roadveh, VehicleSettings::max_ships, VehicleSettings::max_trains, GroupStatistics::num_vehicle, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and GameSettings::vehicle.
Referenced by CmdBuyCompany(), and HandleBankruptcyTakeover().
CommandCost CheckTileOwnership | ( | TileIndex | tile | ) |
Check whether the current owner owns the stuff on the given tile.
If that isn't the case an appropriate error will be given.
tile | the tile to check. |
Definition at line 381 of file company_cmd.cpp.
References _current_company, GetTileOwner(), IsLocalCompany(), OWNER_END, return_cmd_error, and SetDParamsForOwnedBy().
Referenced by CmdConvertRail(), CmdRenameDepot(), and RemoveLock().
void ClearEnginesHiddenFlagOfCompany | ( | CompanyID | cid | ) |
Clear the 'hidden' flag for all engines of a new company.
cid | Company being created. |
Definition at line 969 of file engine.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Iterate(), and SB().
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.
flags | Operation to perform. |
action | The action to perform. |
public_key | The public key of the client to add or remove. |
Definition at line 1004 of file company_cmd.cpp.
References _current_company, CALCA_ADD, CALCA_REMOVE, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), and NETWORK_PUBLIC_KEY_LENGTH.
CommandCost CmdCompanyCtrl | ( | DoCommandFlag | flags, |
CompanyCtrlAction | cca, | ||
CompanyID | company_id, | ||
CompanyRemoveReason | reason, | ||
ClientID | client_id | ||
) |
Control the companies: add, delete, etc.
flags | operation to perform |
cca | action to perform |
company_id | company to perform the action on |
client_id | ClientID |
Definition at line 864 of file company_cmd.cpp.
References _company_manager_face, _local_company, _network_own_client_id, _network_server, _networking, CCA_DELETE, CCA_NEW, CCA_NEW_AI, NetworkClientInfo::client_id, NetworkClientInfo::client_playas, CloseWindowById(), CMD_ERROR, CompanyNewsInformation::company_name, COMPANY_SPECTATOR, CRR_END, DC_EXEC, DoStartupNewCompany(), NetworkClientInfo::GetByClientID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_COMPANY, InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), MarkWholeScreenDirty(), MAX_COMPANIES, NetworkAdminCompanyNew(), NetworkServerNewCompany(), NetworkUpdateClientInfo(), SetDParam(), SetDParamStr(), SetLocalCompany(), SyncCompanySettings(), WC_COMPANY_LEAGUE, WC_NETWORK_STATUS_WINDOW, and WN_NETWORK_STATUS_WINDOW_JOIN.
CommandCost CmdGiveMoney | ( | DoCommandFlag | flags, |
Money | money, | ||
CompanyID | dest_company | ||
) |
Transfer funds (money) from one company to another.
To prevent abuse in multiplayer games you can only send money to other companies if you have paid off your loan (either explicitly, or implicitly given the fact that you have more money than loan).
flags | operation to perform |
money | the amount of money to transfer; max 20.000.000 |
dest_company | the company to transfer the money to |
Definition at line 1296 of file company_cmd.cpp.
References _current_company, _networking, _settings_game, CMD_ERROR, CompanyProperties::current_loan, DC_EXEC, GameSettings::economy, EXPENSES_OTHER, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), CommandCost::GetCost(), GetString(), EconomySettings::give_money, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), CompanyProperties::money, Backup< T >::Restore(), return_cmd_error, SetDParam(), and SubtractMoneyFromCompany().
CommandCost CmdRenameCompany | ( | DoCommandFlag | flags, |
const std::string & | text | ||
) |
Change the name of the company.
flags | operation to perform |
text | the new name or an empty string when resetting to the default |
Definition at line 1169 of file company_cmd.cpp.
References _current_company, CMD_ERROR, CompanyAdminUpdate(), DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), IsUniqueCompanyName(), MarkWholeScreenDirty(), MAX_LENGTH_COMPANY_NAME_CHARS, CompanyProperties::name, return_cmd_error, and Utf8StringLength().
CommandCost CmdRenamePresident | ( | DoCommandFlag | flags, |
const std::string & | text | ||
) |
Change the name of the president.
flags | operation to perform |
text | the new name or an empty string when resetting to the default |
Definition at line 1212 of file company_cmd.cpp.
References _current_company, CMD_ERROR, CompanyAdminUpdate(), DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), InvalidateWindowClassesData(), IsUniquePresidentName(), MarkWholeScreenDirty(), MAX_LENGTH_PRESIDENT_NAME_CHARS, CompanyProperties::name, CompanyProperties::name_1, CompanyProperties::president_name, return_cmd_error, Utf8StringLength(), and WC_COMPANY.
CommandCost CmdSetCompanyColour | ( | DoCommandFlag | flags, |
LiveryScheme | scheme, | ||
bool | primary, | ||
Colours | colour | ||
) |
Change the company's company-colour.
flags | operation to perform |
scheme | scheme to set |
primary | set first/second colour |
colour | new colour for vehicles, property, etc. |
Definition at line 1070 of file company_cmd.cpp.
CommandCost CmdSetCompanyManagerFace | ( | DoCommandFlag | flags, |
CompanyManagerFace | cmf | ||
) |
Change the company manager's face.
flags | operation to perform |
cmf | face bitmasked |
Definition at line 1037 of file company_cmd.cpp.
References _current_company, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), IsValidCompanyManagerFace(), and MarkWholeScreenDirty().
void CompanyAdminRemove | ( | CompanyID | company_id, |
CompanyRemoveReason | reason | ||
) |
Called whenever a company is removed in order to notify admins.
company_id | The company that was removed. |
reason | The reason the company was removed. |
Definition at line 851 of file company_cmd.cpp.
References _network_server, and NetworkAdminCompanyRemove().
void CompanyAdminUpdate | ( | const Company * | company | ) |
Called whenever company related information changes in order to notify admins.
company | The company data changed of. |
Definition at line 841 of file company_cmd.cpp.
References _network_server, and NetworkAdminCompanyUpdate().
Referenced by CmdRenameCompany(), CmdRenamePresident(), and CompanyCheckBankrupt().
int CompanyServiceInterval | ( | const Company * | c, |
VehicleType | type | ||
) |
Get the service interval for the given company and vehicle type.
c | The company, or nullptr for client-default settings. |
type | The vehicle type to get the interval for. |
Definition at line 1248 of file company_cmd.cpp.
References _settings_client, ClientSettings::company, CompanyProperties::settings, and CompanySettings::vehicle.
Company* DoStartupNewCompany | ( | bool | is_ai, |
CompanyID | company = INVALID_COMPANY |
||
) |
Create a new company and sets all company variables default values.
is_ai | is an AI company? |
company | CompanyID to use for the new company |
Definition at line 585 of file company_cmd.cpp.
References _company_colours, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::CanAllocateItem(), CompanyProperties::colour, CompanyProperties::current_loan, GenerateCompanyColour(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INITIAL_LOAN, INVALID_COMPANY, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), CompanyProperties::money, and ResetCompanyLivery().
Referenced by CmdCompanyCtrl().
void DrawCompanyIcon | ( | CompanyID | c, |
int | x, | ||
int | y | ||
) |
Draw the icon of a company.
c | Company that needs its icon drawn. |
x | Horizontal coordinate of the icon. |
y | Vertical coordinate of the icon. |
Definition at line 161 of file company_cmd.cpp.
Referenced by TownAuthorityWindow::DrawRatings().
|
static |
Generate a company colour.
Definition at line 477 of file company_cmd.cpp.
Referenced by DoStartupNewCompany().
|
static |
Generate the name of a company from the last build coordinate.
c | Company to give a name. |
Definition at line 398 of file company_cmd.cpp.
References ClosestTownFromTile(), IsInsideMM(), CompanyProperties::last_build_coordinate, Town::name, and CompanyProperties::name_1.
|
static |
Generate a random president name of a company.
c | Company that needs a new president name. |
Definition at line 532 of file company_cmd.cpp.
References CompanyProperties::president_name_2.
Get the amount of money that a company has available, or INT64_MAX if there is no such valid company.
company | Company to check |
Definition at line 216 of file company_cmd.cpp.
References _settings_game, GameSettings::difficulty, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), DifficultySettings::infinite_money, and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID().
Referenced by GetAvailableMoneyForCommand(), GetMaskOfTownActions(), and Vehicle::NeedsServicing().
Money GetAvailableMoneyForCommand | ( | ) |
This functions returns the money which can be used to execute a command.
This is either the money of the current company, or INT64_MAX if infinite money is enabled or there is no such a company "at the moment" like the server itself.
Definition at line 230 of file company_cmd.cpp.
References _current_company, and GetAvailableMoney().
Referenced by CmdBuildObjectArea(), CmdClearArea(), CmdLevelLand(), and CmdRemoveLongRoad().
TextColour GetDrawStringCompanyColour | ( | CompanyID | company | ) |
Get the colour for DrawString-subroutines which matches the colour of the company.
company | Company to get the colour of. |
Definition at line 149 of file company_cmd.cpp.
References GetColourGradient(), and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID().
CompanyID GetFirstPlayableCompanyID | ( | ) |
Get the index of the first available company.
It attempts, from first to last, and as soon as the attempt succeeds, to get the index of the company: 1st - get the first existing human company. 2nd - get the first non-existing company. 3rd - get COMPANY_FIRST.
Definition at line 1337 of file company_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::CanAllocateItem(), COMPANY_FIRST, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Company::IsHumanID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Iterate(), and MAX_COMPANIES.
Referenced by NetworkOnGameStart(), and OnStartGame().
|
static |
Handle the bankruptcy take over of a company.
Companies going bankrupt will ask the other companies in order of their performance rating, so better performing companies get the 'do you want to merge with Y' question earlier. The question will then stay till either the company has gone bankrupt or got merged with a company.
c | the company that is going bankrupt. |
Definition at line 698 of file company_cmd.cpp.
References CompanyProperties::bankrupt_asked, CompanyProperties::bankrupt_timeout, CheckTakeoverVehicleLimit(), Ticks::DAY_TICKS, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsInteractiveCompany(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Iterate(), MAX_COMPANIES, MAX_UVALUE, AI::NewEvent(), CompanyProperties::old_economy, CompanyEconomyEntry::performance_history, SetBit(), and ShowBuyCompanyDialog().
void InvalidateCompanyWindows | ( | const Company * | company | ) |
Refresh all windows owned by a company.
company | Company that changed, and needs its windows refreshed. |
Definition at line 201 of file company_cmd.cpp.
References _local_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SetWindowDirty(), SetWindowWidgetDirty(), WC_FINANCES, WC_STATUS_BAR, and WID_S_RIGHT.
Referenced by SubtractMoneyFromAnyCompany().
|
static |
Is the given name in use as name of a company?
name | Name to search. |
true
if the name us unique (that is, not in use), else false
. Definition at line 1154 of file company_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Iterate(), and CompanyProperties::name.
Referenced by CmdRenameCompany().
|
static |
Is the given name in use as president name of a company?
name | Name to search. |
true
if the name us unique (that is, not in use), else false
. Definition at line 1197 of file company_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Iterate(), and CompanyProperties::president_name.
Referenced by CmdRenamePresident().
|
static |
Checks whether a company manager's face is a valid encoding.
Unused bits are not enforced to be 0.
cmf | the fact to check |
Definition at line 172 of file company_cmd.cpp.
References AreCompanyManagerFaceBitsValid(), GE_WM, GENDER_FEMALE, GetCompanyManagerFaceBits(), and HasBit().
Referenced by CmdSetCompanyManagerFace().
void ResetCompanyLivery | ( | Company * | c | ) |
Reset the livery schemes to the company's primary colour.
This is used on loading games without livery information and on new company start up.
c | Company to reset. |
Definition at line 561 of file company_cmd.cpp.
Referenced by DoStartupNewCompany().
Set the right DParams for STR_ERROR_OWNED_BY.
owner | the owner to get the name of. |
tile | optional tile to get the right town. |
Definition at line 334 of file company_cmd.cpp.
References ClosestTownFromTile(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), OWNED_BY_OWNER_IN_PARAMETERS_OFFSET, OWNER_TOWN, and SetDParam().
Referenced by CheckOwnership(), and CheckTileOwnership().
void SetLocalCompany | ( | CompanyID | new_company | ) |
Sets the local company and updates the settings that are set on a per-company basis to reflect the core's state in the GUI.
new_company | the new company |
Definition at line 117 of file company_cmd.cpp.
References _current_company, _local_company, CloseConstructionWindows(), COMPANY_SPECTATOR, DESTTYPE_TEAM, InvalidateWindowClassesData(), InvalidateWindowData(), IsLocalCompany(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), MarkWholeScreenDirty(), OWNER_NONE, WC_COMPANY, WC_GOALS_LIST, WC_SEND_NETWORK_MSG, and WC_SIGN_LIST.
Referenced by ChangeOwnershipOfCompanyItems(), ClickChangeCompanyCheat(), CmdCompanyCtrl(), GenerateWorld(), NetworkClientsToSpectators(), NetworkServerDoMove(), and OnStartGame().
|
static |
Deduct costs of a command from the money of a company.
c | Company to pay the bill. |
cost | Money to pay. |
Definition at line 260 of file company_cmd.cpp.
References CompanyProperties::cur_economy, CompanyEconomyEntry::expenses, EXPENSES_AIRCRAFT_REVENUE, EXPENSES_AIRCRAFT_RUN, EXPENSES_LOAN_INTEREST, EXPENSES_PROPERTY, EXPENSES_ROADVEH_REVENUE, EXPENSES_ROADVEH_RUN, EXPENSES_SHIP_REVENUE, EXPENSES_SHIP_RUN, EXPENSES_TRAIN_REVENUE, EXPENSES_TRAIN_RUN, CommandCost::GetCost(), CommandCost::GetExpensesType(), HasBit(), CompanyEconomyEntry::income, INVALID_EXPENSES, InvalidateCompanyWindows(), CompanyProperties::money, and CompanyProperties::yearly_expenses.
Referenced by SubtractMoneyFromCompany(), and SubtractMoneyFromCompanyFract().
void SubtractMoneyFromCompany | ( | const CommandCost & | cost | ) |
Subtract money from the _current_company, if the company is valid.
cost | Money to pay. |
Definition at line 289 of file company_cmd.cpp.
References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), and SubtractMoneyFromAnyCompany().
Referenced by CmdChangeBankBalance(), CmdGiveMoney(), CommandHelperBase::InternalDoAfter(), and CommandHelperBase::InternalExecuteProcessResult().
void SubtractMoneyFromCompanyFract | ( | CompanyID | company, |
const CommandCost & | cst | ||
) |
Subtract money from a company, including the money fraction.
company | Company paying the bill. |
cst | Cost of a command. |
Definition at line 300 of file company_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), CommandCost::GetCost(), CommandCost::GetExpensesType(), CompanyProperties::money_fraction, and SubtractMoneyFromAnyCompany().
void UpdateCompanyLiveries | ( | Company * | c | ) |
Update liveries for a company.
This is called when the LS_DEFAULT scheme is changed, to update schemes with colours set to default.
c | Company to update. |
Definition at line 1053 of file company_cmd.cpp.
void UpdateObjectColours | ( | const Company * | c | ) |
Updates the colour of the object whenever a company changes.
c | The company the company colour changed of. |
Definition at line 183 of file object_cmd.cpp.
References ObjectSpec::callback_mask, CBM_OBJ_COLOUR, Livery::colour1, Livery::colour2, ObjectSpec::flags, ObjectSpec::GetByTile(), GetTileOwner(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::Iterate(), and OBJECT_FLAG_2CC_COLOUR.
|
static |
Similar colours, so we can try to prevent same coloured companies.
Definition at line 454 of file company_cmd.cpp.