OpenTTD
|
Statistics and caches on the vehicles in a group. More...
#include <group.h>
Public Member Functions | |
void | Clear () |
Clear all caches. | |
void | ClearProfits () |
void | ClearAutoreplace () |
Static Public Member Functions | |
static GroupStatistics & | Get (CompanyID company, GroupID id_g, VehicleType type) |
Returns the GroupStatistics for a specific group. | |
static GroupStatistics & | Get (const Vehicle *v) |
Returns the GroupStatistic for the group of a vehicle. | |
static GroupStatistics & | GetAllGroup (const Vehicle *v) |
Returns the GroupStatistic for the ALL_GROUPO of a vehicle type. | |
static void | CountVehicle (const Vehicle *v, int delta) |
Update num_vehicle when adding or removing a vehicle. | |
static void | CountEngine (const Vehicle *v, int delta) |
Update num_engines when adding/removing an engine. | |
static void | VehicleReachedProfitAge (const Vehicle *v) |
Add a vehicle to the profit sum of its group. | |
static void | UpdateProfits () |
Recompute the profits for all groups. | |
static void | UpdateAfterLoad () |
Update all caches after loading a game, changing NewGRF etc. | |
static void | UpdateAutoreplace (CompanyID company) |
Update autoreplace_defined and autoreplace_finished of all statistics of a company. |
Data Fields | |
uint16 | num_vehicle |
Number of vehicles. | |
uint16 * | num_engines |
Caches the number of engines of each type the company owns. | |
bool | autoreplace_defined |
Are any autoreplace rules set? | |
bool | autoreplace_finished |
Have all autoreplacement finished? | |
uint16 | num_profit_vehicle |
Number of vehicles considered for profit statistics;. | |
Money | profit_last_year |
Sum of profits for all vehicles. |
|
static |
Update num_engines when adding/removing an engine.
v | Engine to count. |
delta | +1 to add, -1 to remove. |
Definition at line 161 of file group_cmd.cpp.
References Vehicle::engine_type, Get(), GetAllGroup(), and num_engines.
Referenced by ChangeOwnershipOfCompanyItems(), CmdBuildVehicle(), Vehicle::PreDestructor(), and UpdateAfterLoad().
|
static |
Update num_vehicle when adding or removing a vehicle.
v | Vehicle to count. |
delta | +1 to add, -1 to remove. |
Definition at line 138 of file group_cmd.cpp.
References Vehicle::age, Get(), GetAllGroup(), Vehicle::GetDisplayProfitLastYear(), num_profit_vehicle, num_vehicle, profit_last_year, and VEHICLE_PROFIT_MIN_AGE.
Referenced by AddVehicleToGroup(), ChangeOwnershipOfCompanyItems(), CmdBuildVehicle(), CmdMoveRailVehicle(), CmdSellRailWagon(), Vehicle::PreDestructor(), RemoveVehicleFromGroup(), and UpdateAfterLoad().
|
static |
Returns the GroupStatistics for a specific group.
company | Owner of the group. |
id_g | GroupID of the group. |
type | VehicleType of the vehicles in the group. |
Definition at line 65 of file group_cmd.cpp.
References IsAllGroupID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::IsValidID(), Group::owner, Group::statistics, and Group::vehicle_type.
Referenced by VehicleGroupWindow::ComputeGroupInfoSize(), CountEngine(), CountVehicle(), VehicleGroupWindow::DrawGroupInfo(), Get(), GetAllGroup(), GetGroupNumEngines(), UpdateAutoreplace(), UpdateNumEngineGroup(), and VehicleReachedProfitAge().
|
static |
Returns the GroupStatistic for the group of a vehicle.
v | Vehicle. |
Definition at line 85 of file group_cmd.cpp.
References Get(), Vehicle::group_id, Vehicle::owner, and BaseVehicle::type.
|
static |
Returns the GroupStatistic for the ALL_GROUPO of a vehicle type.
v | Vehicle. |
Definition at line 95 of file group_cmd.cpp.
References ALL_GROUP, Get(), Vehicle::owner, and BaseVehicle::type.
Referenced by CountEngine(), CountVehicle(), and VehicleReachedProfitAge().
|
static |
Update all caches after loading a game, changing NewGRF etc.
Definition at line 103 of file group_cmd.cpp.
References Clear(), CountEngine(), CountVehicle(), FOR_ALL_VEHICLES, Company::group_all, Company::group_default, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::IsEngineCountable(), Vehicle::IsPrimaryVehicle(), Group::statistics, UpdateAutoreplace(), and VEH_COMPANY_END.
Referenced by InitializeWindowsAndCaches(), and ReloadNewGRFData().
|
static |
Update autoreplace_defined and autoreplace_finished of all statistics of a company.
company | Company to update statistics for. |
Definition at line 212 of file group_cmd.cpp.
References autoreplace_defined, autoreplace_finished, Company::engine_renew_list, Get(), Company::group_all, Company::group_default, num_engines, Group::owner, Group::statistics, Engine::type, and VEH_COMPANY_END.
Referenced by ChangeOwnershipOfCompanyItems(), CmdAddVehicleGroup(), CmdBuildVehicle(), CmdSetAutoReplace(), Vehicle::PreDestructor(), SetTrainGroupID(), UpdateAfterLoad(), and UpdateTrainGroupID().