OpenTTD
|
Handling of companies. More...
#include "stdafx.h"
#include "company_base.h"
#include "company_func.h"
#include "company_gui.h"
#include "town.h"
#include "news_func.h"
#include "cmd_helper.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 "company_manager_face.h"
#include "window_func.h"
#include "strings_func.h"
#include "date_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 "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. | |
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. | |
TextColour | GetDrawStringCompanyColour (CompanyID company) |
Get the colour for DrawString-subroutines which matches the colour of the company. | |
void | DrawCompanyIcon (CompanyID c, int x, int y) |
Draw the icon of a company. | |
static bool | IsValidCompanyManagerFace (CompanyManagerFace cmf) |
Checks whether a company manager's face is a valid encoding. | |
void | InvalidateCompanyWindows (const Company *company) |
Refresh all windows owned by a company. | |
bool | CheckCompanyHasMoney (CommandCost &cost) |
Verify whether the company can pay the bill. | |
static void | SubtractMoneyFromAnyCompany (Company *c, CommandCost cost) |
Deduct costs of a command from the money of a company. | |
void | SubtractMoneyFromCompany (CommandCost cost) |
Subtract money from the _current_company, if the company is valid. | |
void | SubtractMoneyFromCompanyFract (CompanyID company, CommandCost cst) |
Subtract money from a company, including the money fraction. | |
void | UpdateLandscapingLimits () |
Update the landscaping limits per company. | |
void | GetNameOfOwner (Owner owner, TileIndex tile) |
Set the right DParams to get the name of an owner. | |
CommandCost | CheckOwnership (Owner owner, TileIndex tile) |
Check whether the current owner owns something. | |
CommandCost | CheckTileOwnership (TileIndex tile) |
Check whether the current owner owns the stuff on the given tile. | |
static void | GenerateCompanyName (Company *c) |
Generate the name of a company from the last build coordinate. | |
static Colours | GenerateCompanyColour () |
Generate a company colour. | |
static void | GeneratePresidentName (Company *c) |
Generate a random president name of a company. | |
void | ResetCompanyLivery (Company *c) |
Reset the livery schemes to the company's primary colour. | |
Company * | DoStartupNewCompany (bool is_ai, CompanyID company=INVALID_COMPANY) |
Create a new company and sets all company variables default values. | |
void | StartupCompanies () |
Start the next competitor now. | |
static void | MaybeStartNewCompany () |
Start a new competitor company if possible. | |
void | InitializeCompanies () |
Initialize the pool of companies. | |
bool | MayCompanyTakeOver (CompanyID cbig, CompanyID csmall) |
May company cbig buy company csmall? | |
static void | HandleBankruptcyTakeover (Company *c) |
Handle the bankruptcy take over of a company. | |
void | OnTick_Companies () |
Called every tick for updating some company info. | |
void | CompaniesYearlyLoop () |
A year has passed, update the economic data of all companies, and perhaps show the financial overview window of the local company. | |
void | CompanyAdminUpdate (const Company *company) |
Called whenever company related information changes in order to notify admins. | |
void | CompanyAdminRemove (CompanyID company_id, CompanyRemoveReason reason) |
Called whenever a company is removed in order to notify admins. | |
CommandCost | CmdCompanyCtrl (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Control the companies: add, delete, etc. | |
CommandCost | CmdSetCompanyManagerFace (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Change the company manager's face. | |
CommandCost | CmdSetCompanyColour (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Change the company's company-colour. | |
static bool | IsUniqueCompanyName (const char *name) |
Is the given name in use as name of a company? | |
CommandCost | CmdRenameCompany (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Change the name of the company. | |
static bool | IsUniquePresidentName (const char *name) |
Is the given name in use as president name of a company? | |
CommandCost | CmdRenamePresident (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Change the name of the president. | |
int | CompanyServiceInterval (const Company *c, VehicleType type) |
Get the service interval for the given company and vehicle type. |
Variables | |
CompanyByte | _local_company |
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR. | |
CompanyByte | _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 | _next_competitor_start |
the number of ticks before the next AI is started | |
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 byte | _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. |
Handling of companies.
Definition in file company_cmd.cpp.
bool CheckCompanyHasMoney | ( | CommandCost & | cost | ) |
Verify whether the company can pay the bill.
cost | [inout] Money to pay, is changed to an error if the company does not have enough money. |
true
if the company has enough money, else it returns false
. Definition at line 194 of file company_cmd.cpp.
References CommandCost::GetCost(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), CommandCost::MakeError(), CompanyProperties::money, and SetDParam().
Referenced by CmdCloneVehicle(), DoCommand(), and DoCommandPInternal().
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 310 of file company_cmd.cpp.
References GetNameOfOwner(), OWNER_END, OWNER_TOWN, and return_cmd_error.
Referenced by CanRemoveRoadWithStop(), CheckAllowRemoveRoad(), CheckAllowRemoveTunnelBridge(), CheckFlatLandRoadStop(), CmdAutofillTimetable(), CmdAutoreplaceVehicle(), CmdBuildObject(), CmdBuildRoad(), CmdBuildSingleRail(), CmdChangeServiceInt(), CmdChangeTimetable(), CmdCloneOrder(), CmdCloneVehicle(), CmdDeleteOrder(), CmdForceTrainProceed(), CmdInsertOrder(), CmdModifyOrder(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdOpenCloseAirport(), CmdOrderRefit(), CmdRefitVehicle(), CmdRenameStation(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdReverseTrainDirection(), CmdSellVehicle(), CmdSetTimetableStart(), CmdSetVehicleOnTime(), CmdSkipToOrder(), CmdStartStopVehicle(), CmdTurnRoadVeh(), IsValidTileForWaypoint(), RemoveAirport(), RemoveDock(), RemoveFromRailBaseStation(), RemoveRailStation(), RemoveRoadStop(), and Vehicle::SendToDepot().
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 328 of file company_cmd.cpp.
References GetNameOfOwner(), GetTileOwner(), IsLocalCompany(), OWNER_END, and return_cmd_error.
Referenced by CheckAllowRemoveTunnelBridge(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), 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 861 of file engine.cpp.
References Engine::company_hidden, and SB().
Referenced by DoStartupNewCompany().
CommandCost CmdCompanyCtrl | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Control the companies: add, delete, etc.
tile | unused |
flags | operation to perform |
p1 | various functionality
|
p2 | ClientID |
text | unused |
Definition at line 807 of file company_cmd.cpp.
References _network_own_client_id, _network_server, _networking, _settings_client, AI::BroadcastNewEvent(), ChangeOwnershipOfCompanyItems(), NetworkClientInfo::client_id, NetworkClientInfo::client_playas, CMD_ERROR, CompanyNewsInformation::company_name, COMPANY_SPECTATOR, CompanyAdminRemove(), CRR_END, DC_EXEC, NetworkSettings::default_company_pass, DeleteCompanyWindows(), DeleteWindowById(), DoStartupNewCompany(), CompanyNewsInformation::FillData(), GB(), 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<&_goal_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_COMPANY, INVALID_OWNER, InvalidateWindowClassesData(), InvalidateWindowData(), CompanyProperties::is_ai, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), MarkWholeScreenDirty(), MAX_COMPANIES, ClientSettings::network, NetworkChangeCompanyPassword(), NetworkServerNewCompany(), NetworkUpdateClientInfo(), Game::NewEvent(), SetDParam(), SetDParamStr(), SetLocalCompany(), AI::Stop(), StrEmpty(), SyncCompanySettings(), WC_AI_LIST, WC_AI_SETTINGS, WC_COMPANY_LEAGUE, WC_GAME_OPTIONS, WC_MAIN_TOOLBAR, WC_NETWORK_STATUS_WINDOW, and WN_NETWORK_STATUS_WINDOW_JOIN.
CommandCost CmdRenameCompany | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Change the name of the company.
tile | unused |
flags | operation to perform |
p1 | unused |
p2 | unused |
text | the new name or an empty string when resetting to the default |
Definition at line 1070 of file company_cmd.cpp.
References CMD_ERROR, CompanyAdminUpdate(), DC_EXEC, free(), 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, stredup(), StrEmpty(), and Utf8StringLength().
CommandCost CmdRenamePresident | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Change the name of the president.
tile | unused |
flags | operation to perform |
p1 | unused |
p2 | unused |
text | the new name or an empty string when resetting to the default |
Definition at line 1115 of file company_cmd.cpp.
References CMD_ERROR, CMD_RENAME_COMPANY, CompanyAdminUpdate(), DC_EXEC, DoCommand(), free(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), IsUniquePresidentName(), lastof, MarkWholeScreenDirty(), MAX_LENGTH_PRESIDENT_NAME_CHARS, CompanyProperties::name, CompanyProperties::name_1, CompanyProperties::president_name, return_cmd_error, seprintf(), stredup(), StrEmpty(), and Utf8StringLength().
CommandCost CmdSetCompanyColour | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Change the company's company-colour.
tile | unused |
flags | operation to perform |
p1 | bitstuffed: p1 bits 0-7 scheme to set p1 bits 8-9 set in use state or first/second colour |
p2 | new colour for vehicles, property, etc. |
text | unused |
Definition at line 954 of file company_cmd.cpp.
References _company_colours, _current_company, BuildOwnerLegend(), CMD_ERROR, CompanyProperties::colour, Livery::colour1, Livery::colour2, CompanyAdminUpdate(), DC_EXEC, FOR_ALL_VEHICLES, GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Livery::in_use, Vehicle::InvalidateNewGRFCache(), InvalidateWindowData(), MarkWholeScreenDirty(), Vehicle::owner, UpdateObjectColours(), WC_COMPANY_VALUE, WC_DELIVERED_CARGO, WC_INCOME_GRAPH, WC_LINKGRAPH_LEGEND, WC_OPERATING_PROFIT, WC_PERFORMANCE_HISTORY, and WC_SMALLMAP.
CommandCost CmdSetCompanyManagerFace | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Change the company manager's face.
tile | unused |
flags | operation to perform |
p1 | unused |
p2 | face bitmasked |
text | unused |
Definition at line 930 of file company_cmd.cpp.
References 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 786 of file company_cmd.cpp.
References _network_server, and NetworkAdminCompanyRemove().
Referenced by CmdCompanyCtrl().
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 774 of file company_cmd.cpp.
References _network_server, and NetworkAdminCompanyUpdate().
Referenced by CmdBuyShareInCompany(), CmdRenameCompany(), CmdRenamePresident(), CmdSellShareInCompany(), and CmdSetCompanyColour().
int CompanyServiceInterval | ( | const Company * | c, |
VehicleType | type | ||
) |
Get the service interval for the given company and vehicle type.
c | The company, or NULL for client-default settings. |
type | The vehicle type to get the interval for. |
Definition at line 1154 of file company_cmd.cpp.
References _settings_client, ClientSettings::company, VehicleDefaultSettings::servint_aircraft, VehicleDefaultSettings::servint_roadveh, VehicleDefaultSettings::servint_ships, VehicleDefaultSettings::servint_trains, Company::settings, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and CompanySettings::vehicle.
Referenced by AfterLoadVehicles(), ChangeOwnershipOfCompanyItems(), and CmdChangeServiceInt().
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 533 of file company_cmd.cpp.
References _company_colours, _cur_year, _network_server, _networking, CompanyProperties::avail_railtypes, Company::avail_roadtypes, AI::BroadcastNewEvent(), BuildOwnerLegend(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::CanAllocateItem(), ClearEnginesHiddenFlagOfCompany(), CompanyProperties::colour, CompanyProperties::current_loan, CompanyProperties::face, GenerateCompanyColour(), GeneratePresidentName(), GetCompanyRailtypes(), GetCompanyRoadtypes(), CompanyProperties::inaugurated_year, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Economy::inflation_prices, INVALID_COMPANY, INVALID_OWNER, InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), CompanyProperties::money, Game::NewEvent(), RandomCompanyManagerFaceBits(), ResetCompanyLivery(), SetDefaultCompanySettings(), SetWindowClassesDirty(), SetWindowDirty(), CompanyProperties::share_owners, AI::StartNew(), WC_CLIENT_LIST, WC_CLIENT_LIST_POPUP, WC_GRAPH_LEGEND, WC_LINKGRAPH_LEGEND, and WC_SMALLMAP.
Referenced by AfterLoadGame(), and 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 141 of file company_cmd.cpp.
References DrawSprite().
Referenced by TownAuthorityWindow::DrawRatings(), GraphLegendWindow::DrawWidget(), LinkGraphLegendWindow::DrawWidget(), SignListWindow::DrawWidget(), CheatWindow::DrawWidget(), CompanyLeagueWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), NetworkClientListWindow::DrawWidget(), and AIDebugWindow::OnPaint().
|
static |
Generate a company colour.
Definition at line 428 of file company_cmd.cpp.
References _colour_sort, _similar_colour, CompanyProperties::colour, GB(), and Swap().
Referenced by DoStartupNewCompany().
|
static |
Generate the name of a company from the last build coordinate.
c | Company to give a name. |
Definition at line 345 of file company_cmd.cpp.
References AddNewsItem(), ClosestTownFromTile(), CompanyNewsInformation::company_name, CompanyNewsInformation::FillData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, CompanyProperties::is_ai, IsInsideMM(), CompanyProperties::last_build_coordinate, lastof, MarkWholeScreenDirty(), MAX_CHAR_LENGTH, MAX_LENGTH_COMPANY_NAME_CHARS, Town::name, CompanyProperties::name_1, CompanyProperties::name_2, NF_COMPANY, NR_NONE, NR_TILE, NT_COMPANY_INFO, CompanyProperties::president_name_1, CompanyProperties::president_name_2, SetDParam(), SetDParamStr(), and Utf8StringLength().
Referenced by OnTick_Companies().
|
static |
Generate a random president name of a company.
c | Company that needs a new president name. |
Definition at line 484 of file company_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, lastof, MAX_CHAR_LENGTH, MAX_LENGTH_PRESIDENT_NAME_CHARS, CompanyProperties::president_name_1, CompanyProperties::president_name_2, SetDParam(), and Utf8StringLength().
Referenced by DoStartupNewCompany().
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 129 of file company_cmd.cpp.
References _colour_gradient, _company_colours, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), and TC_IS_PALETTE_COLOUR.
Referenced by NetworkServerSendChat(), and ClientNetworkGameSocketHandler::Receive_SERVER_CHAT().
Set the right DParams to get the name of an owner.
owner | the owner to get the name of. |
tile | optional tile to get the right town. |
Definition at line 281 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(), OWNER_TOWN, and SetDParam().
Referenced by CheckOwnership(), CheckTileOwnership(), and LandInfoWindow::OnInit().
|
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 643 of file company_cmd.cpp.
References CompanyProperties::bankrupt_asked, CompanyProperties::bankrupt_timeout, ClampToI32(), DAY_TICKS, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, CompanyProperties::is_ai, IsInteractiveCompany(), MAX_COMPANIES, MAX_UVALUE, MayCompanyTakeOver(), AI::NewEvent(), CompanyProperties::old_economy, CompanyEconomyEntry::performance_history, SetBit(), and ShowBuyCompanyDialog().
Referenced by OnTick_Companies().
void InitializeCompanies | ( | ) |
Initialize the pool of companies.
Definition at line 611 of file company_cmd.cpp.
References _cur_company_tick_index.
void InvalidateCompanyWindows | ( | const Company * | company | ) |
Refresh all windows owned by a company.
company | Company that changed, and needs its windows refreshed. |
Definition at line 181 of file company_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SetWindowDirty(), WC_FINANCES, and WC_STATUS_BAR.
Referenced by CmdDecreaseLoan(), CmdIncreaseLoan(), and 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 1050 of file company_cmd.cpp.
References 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 1095 of file company_cmd.cpp.
References 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 152 of file company_cmd.cpp.
References AreCompanyManagerFaceBitsValid(), GE_WM, GENDER_FEMALE, GetCompanyManagerFaceBits(), and HasBit().
Referenced by CmdSetCompanyManagerFace().
|
static |
Start a new competitor company if possible.
Definition at line 589 of file company_cmd.cpp.
References _networking, _settings_client, _settings_game, CMD_COMPANY_CTRL, GameSettings::difficulty, DoCommandP(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetNumItems(), INVALID_COMPANY, CompanyProperties::is_ai, NetworkSettings::max_companies, DifficultySettings::max_no_competitors, and ClientSettings::network.
Referenced by OnTick_Companies().
May company cbig buy company csmall?
true
if it is allowed. Definition at line 622 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(), CmdBuyShareInCompany(), and HandleBankruptcyTakeover().
void OnTick_Companies | ( | ) |
Called every tick for updating some company info.
Definition at line 697 of file company_cmd.cpp.
References _cur_company_tick_index, _next_competitor_start, CompanyProperties::bankrupt_asked, AI::CanStartNew(), DAY_TICKS, GenerateCompanyName(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), AI::GetStartNextTime(), HandleBankruptcyTakeover(), MAX_COMPANIES, MaybeStartNewCompany(), and CompanyProperties::name_1.
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 517 of file company_cmd.cpp.
References CompanyProperties::colour, Livery::colour1, Livery::colour2, and Livery::in_use.
Referenced by AfterLoadGame(), and DoStartupNewCompany().
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 102 of file company_cmd.cpp.
References COMPANY_SPECTATOR, DeleteConstructionWindows(), DESTTYPE_TEAM, InvalidateWindowClassesData(), InvalidateWindowData(), IsLocalCompany(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), MarkWholeScreenDirty(), OWNER_NONE, WC_SEND_NETWORK_MSG, and WC_SIGN_LIST.
Referenced by ChangeOwnershipOfCompanyItems(), ClickChangeCompanyCheat(), CmdCompanyCtrl(), GenerateWorld(), LoadIntroGame(), NetworkClientsToSpectators(), NetworkServerDoMove(), ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(), and ClientNetworkGameSocketHandler::Receive_SERVER_MOVE().
void StartupCompanies | ( | ) |
Start the next competitor now.
Definition at line 583 of file company_cmd.cpp.
References _next_competitor_start.
Referenced by _GenerateWorld().
|
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 212 of file company_cmd.cpp.
References CompanyProperties::cur_economy, CompanyEconomyEntry::expenses, EXPENSES_AIRCRAFT_INC, EXPENSES_AIRCRAFT_RUN, EXPENSES_LOAN_INT, EXPENSES_PROPERTY, EXPENSES_ROADVEH_INC, EXPENSES_ROADVEH_RUN, EXPENSES_SHIP_INC, EXPENSES_SHIP_RUN, EXPENSES_TRAIN_INC, 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 | ( | CommandCost | cost | ) |
Subtract money from the _current_company, if the company is valid.
cost | Money to pay. |
Definition at line 241 of file company_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), and SubtractMoneyFromAnyCompany().
Referenced by ChangeOwnershipOfCompanyItems(), CmdChangeBankBalance(), CmdGiveMoney(), CompaniesGenStatistics(), CompaniesPayInterest(), DoCommand(), and DoCommandPInternal().
void SubtractMoneyFromCompanyFract | ( | CompanyID | company, |
CommandCost | cst | ||
) |
Subtract money from a company, including the money fraction.
company | Company paying the bill. |
cst | Cost of a command. |
Definition at line 252 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().
Referenced by Ship::OnNewDay(), Aircraft::OnNewDay(), RoadVehicle::OnNewDay(), and Train::OnNewDay().
void UpdateLandscapingLimits | ( | ) |
Update the landscaping limits per company.
Definition at line 265 of file company_cmd.cpp.
References _settings_game, ConstructionSettings::clear_frame_burst, CompanyProperties::clear_limit, ConstructionSettings::clear_per_64k_frames, GameSettings::construction, min(), ConstructionSettings::terraform_frame_burst, CompanyProperties::terraform_limit, ConstructionSettings::terraform_per_64k_frames, ConstructionSettings::tree_frame_burst, CompanyProperties::tree_limit, and ConstructionSettings::tree_per_64k_frames.
Referenced by StateGameLoop().
|
static |
Sorting weights for the company colours.
Definition at line 403 of file company_cmd.cpp.
Referenced by GenerateCompanyColour().
|
static |
Similar colours, so we can try to prevent same coloured companies.
Definition at line 405 of file company_cmd.cpp.
Referenced by GenerateCompanyColour().