mirror of https://github.com/OpenTTD/OpenTTD
Codechange: explicitly initialise Subsidy member variables
parent
be01c2cd2a
commit
ce2ae07233
|
@ -201,12 +201,7 @@ static bool CheckSubsidyDistance(Source src, Source dst)
|
||||||
*/
|
*/
|
||||||
void CreateSubsidy(CargoType cargo_type, Source src, Source dst)
|
void CreateSubsidy(CargoType cargo_type, Source src, Source dst)
|
||||||
{
|
{
|
||||||
Subsidy *s = new Subsidy();
|
Subsidy *s = new Subsidy(cargo_type, src, dst, SUBSIDY_OFFER_MONTHS);
|
||||||
s->cargo_type = cargo_type;
|
|
||||||
s->src = src;
|
|
||||||
s->dst = dst;
|
|
||||||
s->remaining = SUBSIDY_OFFER_MONTHS;
|
|
||||||
s->awarded = CompanyID::Invalid();
|
|
||||||
|
|
||||||
std::pair<NewsReference, NewsReference> references = SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::NewsOffered);
|
std::pair<NewsReference, NewsReference> references = SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::NewsOffered);
|
||||||
AddNewsItem(STR_NEWS_SERVICE_SUBSIDY_OFFERED, NewsType::Subsidies, NewsStyle::Normal, {}, references.first, references.second);
|
AddNewsItem(STR_NEWS_SERVICE_SUBSIDY_OFFERED, NewsType::Subsidies, NewsStyle::Normal, {}, references.first, references.second);
|
||||||
|
|
|
@ -21,21 +21,22 @@ extern SubsidyPool _subsidy_pool;
|
||||||
|
|
||||||
/** Struct about subsidies, offered and awarded */
|
/** Struct about subsidies, offered and awarded */
|
||||||
struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
|
struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
|
||||||
CargoType cargo_type; ///< Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy
|
CargoType cargo_type = INVALID_CARGO; ///< Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy
|
||||||
uint16_t remaining; ///< Remaining months when this subsidy is valid
|
uint16_t remaining = 0; ///< Remaining months when this subsidy is valid
|
||||||
CompanyID awarded; ///< Subsidy is awarded to this company; CompanyID::Invalid() if it's not awarded to anyone
|
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 src{}; ///< Source of subsidised path
|
||||||
Source dst; ///< Destination of subsidised path
|
Source dst{}; ///< Destination of subsidised path
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
|
* 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
|
* (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
|
* Tests whether this subsidy has been awarded to someone
|
||||||
|
|
Loading…
Reference in New Issue