diff --git a/src/group.h b/src/group.h index e398ea49f6..fabbaf3137 100644 --- a/src/group.h +++ b/src/group.h @@ -22,13 +22,13 @@ extern GroupPool _group_pool; ///< Pool of groups. /** Statistics and caches on the vehicles in a group. */ struct GroupStatistics { - Money profit_last_year; ///< Sum of profits for all vehicles. - Money profit_last_year_min_age; ///< Sum of profits for vehicles considered for profit statistics. - std::map num_engines; ///< Caches the number of engines of each type the company owns. - uint16_t num_vehicle; ///< Number of vehicles. - uint16_t num_vehicle_min_age; ///< Number of vehicles considered for profit statistics; - bool autoreplace_defined; ///< Are any autoreplace rules set? - bool autoreplace_finished; ///< Have all autoreplacement finished? + Money profit_last_year = 0; ///< Sum of profits for all vehicles. + Money profit_last_year_min_age = 0; ///< Sum of profits for vehicles considered for profit statistics. + std::map num_engines{}; ///< Caches the number of engines of each type the company owns. + uint16_t num_vehicle = 0; ///< Number of vehicles. + uint16_t num_vehicle_min_age = 0; ///< Number of vehicles considered for profit statistics; + bool autoreplace_defined = false; ///< Are any autoreplace rules set? + bool autoreplace_finished = false; ///< Have all autoreplacement finished? void Clear(); @@ -70,20 +70,21 @@ using GroupFlags = EnumBitSet; /** Group data. */ struct Group : GroupPool::PoolItem<&_group_pool> { - std::string name; ///< Group Name - Owner owner; ///< Group Owner - VehicleType vehicle_type; ///< Vehicle type of the group + std::string name{}; ///< Group Name + Owner owner = INVALID_OWNER; ///< Group Owner + VehicleType vehicle_type = VEH_INVALID; ///< Vehicle type of the group GroupFlags flags{}; ///< Group flags - Livery livery; ///< Custom colour scheme for vehicles in this group - GroupStatistics statistics; ///< NOSAVE: Statistics and caches on the vehicles in the group. + Livery livery{}; ///< Custom colour scheme for vehicles in this group + GroupStatistics statistics{}; ///< NOSAVE: Statistics and caches on the vehicles in the group. - bool folded; ///< NOSAVE: Is this group folded in the group view? + bool folded = false; ///< NOSAVE: Is this group folded in the group view? - GroupID parent; ///< Parent group - uint16_t number; ///< Per-company group number. + GroupID parent = GroupID::Invalid(); ///< Parent group + uint16_t number = 0; ///< Per-company group number. - Group(CompanyID owner = CompanyID::Invalid()); + Group() {} + Group(CompanyID owner, VehicleType vehicle_type) : owner(owner), vehicle_type(vehicle_type) {} }; diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 5c1efbd389..2ccbfe2420 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -319,12 +319,6 @@ void UpdateCompanyGroupLiveries(const Company *c) } } -Group::Group(Owner owner) -{ - this->owner = owner; - this->folded = false; -} - /** * Create a new vehicle group. @@ -346,9 +340,7 @@ std::tuple CmdCreateGroup(DoCommandFlags flags, VehicleTyp } if (flags.Test(DoCommandFlag::Execute)) { - Group *g = new Group(_current_company); - g->vehicle_type = vt; - g->parent = GroupID::Invalid(); + Group *g = new Group(_current_company, vt); Company *c = Company::Get(g->owner); g->number = c->freegroups.UseID(c->freegroups.NextID());