|
OpenTTD Source 20251117-master-g7398d2e290
|
Base class for groups and group functions. More...
#include "group_type.h"#include "core/flatset_type.hpp"#include "core/pool_type.hpp"#include "company_type.h"#include "vehicle_type.h"#include "engine_type.h"#include "livery.h"Go to the source code of this file.
Data Structures | |
| struct | GroupStatistics |
| Statistics and caches on the vehicles in a group. More... | |
| struct | Group |
| Group data. More... | |
Typedefs | |
| using | GroupPool = Pool< Group, GroupID, 16 > |
| using | GroupFlags = EnumBitSet< GroupFlag, uint8_t > |
Enumerations | |
| enum class | GroupFlag : uint8_t { ReplaceProtection = 0 , ReplaceWagonRemoval = 1 } |
Functions | |
| bool | IsDefaultGroupID (GroupID index) |
| bool | IsAllGroupID (GroupID id_g) |
| Checks if a GroupID stands for all vehicles of a company. | |
| void | UpdateGroupChildren () |
| Update children list for each group. | |
| uint | GetGroupNumEngines (CompanyID company, GroupID id_g, EngineID id_e) |
| Get the number of engines with EngineID id_e in the group with GroupID id_g and its sub-groups. | |
| uint | GetGroupNumVehicle (CompanyID company, GroupID id_g, VehicleType type) |
| Get the number of vehicles in the group with GroupID id_g and its sub-groups. | |
| uint | GetGroupNumVehicleMinAge (CompanyID company, GroupID id_g, VehicleType type) |
| Get the number of vehicles above profit minimum age in the group with GroupID id_g and its sub-groups. | |
| Money | GetGroupProfitLastYearMinAge (CompanyID company, GroupID id_g, VehicleType type) |
| Get last year's profit of vehicles above minimum age for the group with GroupID id_g and its sub-groups. | |
| void | SetTrainGroupID (Train *v, GroupID grp) |
| Affect the groupID of a train to new_g. | |
| void | UpdateTrainGroupID (Train *v) |
| Recalculates the groupID of a train. | |
| void | RemoveAllGroupsForCompany (const CompanyID company) |
| bool | GroupIsInGroup (GroupID search, GroupID group) |
| Test if GroupID group is a descendant of (or is) GroupID search. | |
| void | UpdateCompanyGroupLiveries (const Company *c) |
| Update group liveries for a company. | |
Variables | |
| GroupPool | _group_pool |
| Pool of groups. | |
Base class for groups and group functions.
Definition in file group.h.
| using GroupFlags = EnumBitSet<GroupFlag, uint8_t> |
|
strong |
Get the number of engines with EngineID id_e in the group with GroupID id_g and its sub-groups.
| company | The company the group belongs to |
| id_g | The GroupID of the group used |
| id_e | The EngineID of the engine to count |
Definition at line 809 of file group_cmd.cpp.
References Group::children, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), GroupStatistics::Get(), GetGroupNumEngines(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::GetIfValid(), and GroupStatistics::GetNumEngines().
Referenced by DrawEngineList(), ReplaceVehicleWindow::GenerateReplaceVehList(), GetGroupNumEngines(), InvalidateAutoreplaceWindow(), NewVehicleAvailable(), ReplaceVehicleWindow::OnClick(), and GroupStatistics::UpdateAutoreplace().
| uint GetGroupNumVehicle | ( | CompanyID | company, |
| GroupID | id_g, | ||
| VehicleType | type | ||
| ) |
Get the number of vehicles in the group with GroupID id_g and its sub-groups.
| company | The company the group belongs to |
| id_g | The GroupID of the group used |
| type | The vehicle type of the group |
Definition at line 830 of file group_cmd.cpp.
References Group::children, GroupStatistics::Get(), GetGroupNumVehicle(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::GetIfValid(), and GroupStatistics::num_vehicle.
Referenced by VehicleGroupWindow::ComputeGroupInfoSize(), VehicleGroupWindow::DrawGroupInfo(), GetGroupNumVehicle(), and VehicleGroupWindow::GetWidgetString().
| uint GetGroupNumVehicleMinAge | ( | CompanyID | company, |
| GroupID | id_g, | ||
| VehicleType | type | ||
| ) |
Get the number of vehicles above profit minimum age in the group with GroupID id_g and its sub-groups.
| company | The company the group belongs to |
| id_g | The GroupID of the group used |
| type | The vehicle type of the group |
Definition at line 851 of file group_cmd.cpp.
References Group::children, GroupStatistics::Get(), GetGroupNumVehicleMinAge(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::GetIfValid(), and GroupStatistics::num_vehicle_min_age.
Referenced by VehicleGroupWindow::DrawGroupInfo(), and GetGroupNumVehicleMinAge().
| Money GetGroupProfitLastYearMinAge | ( | CompanyID | company, |
| GroupID | id_g, | ||
| VehicleType | type | ||
| ) |
Get last year's profit of vehicles above minimum age for the group with GroupID id_g and its sub-groups.
| company | The company the group belongs to |
| id_g | The GroupID of the group used |
| type | The vehicle type of the group |
Definition at line 872 of file group_cmd.cpp.
References Group::children, GroupStatistics::Get(), GetGroupProfitLastYearMinAge(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::GetIfValid(), and GroupStatistics::profit_last_year_min_age.
Referenced by VehicleGroupWindow::DrawGroupInfo(), and GetGroupProfitLastYearMinAge().
Test if GroupID group is a descendant of (or is) GroupID search.
| search | The GroupID to search in |
| group | The GroupID to search for |
Definition at line 899 of file group_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::Get(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::IsValidID().
Referenced by CmdAlterGroup(), GenerateVehicleSortList(), and GetEngineReplacement().
|
inline |
Checks if a GroupID stands for all vehicles of a company.
| id_g | The GroupID to check |
Definition at line 103 of file group.h.
References ALL_GROUP.
Referenced by CmdSetAutoReplace(), VehicleGroupWindow::DirtyHighlightedGroupWidget(), VehicleGroupWindow::DrawGroupInfo(), GroupStatistics::Get(), VehicleGroupWindow::GetWidgetString(), VehicleGroupWindow::OnClick(), VehicleGroupWindow::OnInvalidateData(), and VehicleGroupWindow::OnPaint().
| void RemoveAllGroupsForCompany | ( | const CompanyID | company | ) |
Definition at line 885 of file group_cmd.cpp.
Affect the groupID of a train to new_g.
| v | First vehicle of the chain. |
| new_g | index of array group |
Definition at line 755 of file group_cmd.cpp.
References Vehicle::IsFrontEngine(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::IsValidID(), SpecializedVehicle< T, Type >::Next(), Vehicle::owner, SetWindowDirty(), GroupStatistics::UpdateAutoreplace(), UpdateNumEngineGroup(), VEH_TRAIN, and WC_REPLACE_VEHICLE.
Referenced by AddVehicleToGroup(), and CmdMoveRailVehicle().
| void UpdateCompanyGroupLiveries | ( | const Company * | c | ) |
Update group liveries for a company.
This is called when the LS_DEFAULT scheme is changed, to update groups with colours set to default.
| c | Company to update. |
Definition at line 320 of file group_cmd.cpp.
References Livery::colour1, Livery::colour2, Livery::in_use, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::Iterate(), Group::livery, Group::owner, Group::parent, Livery::Primary, PropagateChildLivery(), Livery::Secondary, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
Referenced by UpdateCompanyLiveries().
| void UpdateGroupChildren | ( | ) |
Update children list for each group.
Definition at line 47 of file group_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::Get(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::Iterate().
Referenced by AfterLoadGame().
| void UpdateTrainGroupID | ( | Train * | v | ) |
Recalculates the groupID of a train.
Should be called each time a vehicle is added to/removed from the chain,.
| v | First vehicle of the chain. |
Definition at line 783 of file group_cmd.cpp.
References DEFAULT_GROUP, Vehicle::group_id, GroundVehicle< T, Type >::IsFreeWagon(), Vehicle::IsFrontEngine(), SpecializedVehicle< T, Type >::Next(), Vehicle::owner, SetWindowDirty(), GroupStatistics::UpdateAutoreplace(), UpdateNumEngineGroup(), VEH_TRAIN, and WC_REPLACE_VEHICLE.
Referenced by CmdBuildRailVehicle(), CmdBuildRailWagon(), and NormaliseTrainHead().