diff --git a/src/subsidy.cpp b/src/subsidy.cpp index 89885c8e61..7841b7354b 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -201,12 +201,7 @@ static bool CheckSubsidyDistance(Source src, Source dst) */ void CreateSubsidy(CargoType cargo_type, Source src, Source dst) { - Subsidy *s = new Subsidy(); - s->cargo_type = cargo_type; - s->src = src; - s->dst = dst; - s->remaining = SUBSIDY_OFFER_MONTHS; - s->awarded = CompanyID::Invalid(); + Subsidy *s = new Subsidy(cargo_type, src, dst, SUBSIDY_OFFER_MONTHS); std::pair references = SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::NewsOffered); AddNewsItem(STR_NEWS_SERVICE_SUBSIDY_OFFERED, NewsType::Subsidies, NewsStyle::Normal, {}, references.first, references.second); diff --git a/src/subsidy_base.h b/src/subsidy_base.h index 62c2bca180..dbf9d85b23 100644 --- a/src/subsidy_base.h +++ b/src/subsidy_base.h @@ -21,21 +21,22 @@ extern SubsidyPool _subsidy_pool; /** Struct about subsidies, offered and awarded */ struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> { - CargoType cargo_type; ///< Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy - uint16_t remaining; ///< Remaining months when this subsidy is valid - CompanyID awarded; ///< Subsidy is awarded to this company; CompanyID::Invalid() if it's not awarded to anyone - Source src; ///< Source of subsidised path - Source dst; ///< Destination of subsidised path + CargoType cargo_type = INVALID_CARGO; ///< Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy + uint16_t remaining = 0; ///< Remaining months when this subsidy is valid + CompanyID awarded = CompanyID::Invalid(); ///< Subsidy is awarded to this company; CompanyID::Invalid() if it's not awarded to anyone + Source src{}; ///< Source of subsidised path + Source dst{}; ///< Destination of subsidised path /** * We need an (empty) constructor so struct isn't zeroed (as C++ standard states) */ - inline Subsidy() { } + Subsidy() { } + Subsidy(CargoType cargo_type, Source src, Source dst, uint16_t remaining) : cargo_type(cargo_type), remaining(remaining), src(src), dst(dst) {} /** * (Empty) destructor has to be defined else operator delete might be called with nullptr parameter */ - inline ~Subsidy() { } + ~Subsidy() { } /** * Tests whether this subsidy has been awarded to someone