|
@@ -18,22 +18,31 @@
|
|
|
#include "vehicle_type.h"
|
|
|
#include "engine_type.h"
|
|
|
|
|
|
typedef Pool<Group, GroupID, 16, 64000> GroupPool;
|
|
|
extern GroupPool _group_pool; ///< Pool of groups.
|
|
|
|
|
|
/** Statistics and caches on the vehicles in a group. */
|
|
|
struct GroupStatistics {
|
|
|
uint16 num_vehicle; ///< Number of vehicles.
|
|
|
uint16 *num_engines; ///< Caches the number of engines of each type the company owns.
|
|
|
|
|
|
GroupStatistics();
|
|
|
~GroupStatistics();
|
|
|
|
|
|
void Clear();
|
|
|
};
|
|
|
|
|
|
/** Group data. */
|
|
|
struct Group : GroupPool::PoolItem<&_group_pool> {
|
|
|
char *name; ///< Group Name
|
|
|
|
|
|
uint16 num_vehicle; ///< Number of vehicles in the group
|
|
|
OwnerByte owner; ///< Group Owner
|
|
|
VehicleTypeByte vehicle_type; ///< Vehicle type of the group
|
|
|
|
|
|
bool replace_protection; ///< If set to true, the global autoreplace have no effect on the group
|
|
|
uint16 *num_engines; ///< Caches the number of engines of each type the company owns (no need to save this)
|
|
|
GroupStatistics statistics; ///< NOSAVE: Statistics and caches on the vehicles in the group.
|
|
|
|
|
|
Group(CompanyID owner = INVALID_COMPANY);
|
|
|
~Group();
|
|
|
};
|
|
|
|
|
|
|
|
@@ -74,23 +83,23 @@ uint GetGroupNumEngines(CompanyID compan
|
|
|
* Increase the number of vehicles by one in a group.
|
|
|
* @param id_g Group id.
|
|
|
*/
|
|
|
static inline void IncreaseGroupNumVehicle(GroupID id_g)
|
|
|
{
|
|
|
Group *g = Group::GetIfValid(id_g);
|
|
|
if (g != NULL) g->num_vehicle++;
|
|
|
if (g != NULL) g->statistics.num_vehicle++;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Decrease the number of vehicles by one in a group.
|
|
|
* @param id_g Group id.
|
|
|
*/
|
|
|
static inline void DecreaseGroupNumVehicle(GroupID id_g)
|
|
|
{
|
|
|
Group *g = Group::GetIfValid(id_g);
|
|
|
if (g != NULL) g->num_vehicle--;
|
|
|
if (g != NULL) g->statistics.num_vehicle--;
|
|
|
}
|
|
|
|
|
|
|
|
|
void SetTrainGroupID(Train *v, GroupID grp);
|
|
|
void UpdateTrainGroupID(Train *v);
|
|
|
void RemoveVehicleFromGroup(const Vehicle *v);
|