mirror of https://github.com/OpenTTD/OpenTTD
Codechange: explicitly initialise Goal member variables
parent
8682f39966
commit
0a285e1a86
|
@ -85,12 +85,7 @@ std::tuple<CommandCost, GoalID> CmdCreateGoal(DoCommandFlags flags, CompanyID co
|
||||||
if (!Goal::IsValidGoalDestination(company, type, dest)) return { CMD_ERROR, GoalID::Invalid() };
|
if (!Goal::IsValidGoalDestination(company, type, dest)) return { CMD_ERROR, GoalID::Invalid() };
|
||||||
|
|
||||||
if (flags.Test(DoCommandFlag::Execute)) {
|
if (flags.Test(DoCommandFlag::Execute)) {
|
||||||
Goal *g = new Goal();
|
Goal *g = new Goal(type, dest, company, text);
|
||||||
g->type = type;
|
|
||||||
g->dst = dest;
|
|
||||||
g->company = company;
|
|
||||||
g->text = text;
|
|
||||||
g->completed = false;
|
|
||||||
|
|
||||||
if (g->company == CompanyID::Invalid()) {
|
if (g->company == CompanyID::Invalid()) {
|
||||||
InvalidateWindowClassesData(WC_GOALS_LIST);
|
InvalidateWindowClassesData(WC_GOALS_LIST);
|
||||||
|
|
|
@ -19,22 +19,23 @@ extern GoalPool _goal_pool;
|
||||||
|
|
||||||
/** Struct about goals, current and completed */
|
/** Struct about goals, current and completed */
|
||||||
struct Goal : GoalPool::PoolItem<&_goal_pool> {
|
struct Goal : GoalPool::PoolItem<&_goal_pool> {
|
||||||
CompanyID company; ///< Goal is for a specific company; CompanyID::Invalid() if it is global
|
CompanyID company = CompanyID::Invalid(); ///< Goal is for a specific company; CompanyID::Invalid() if it is global
|
||||||
GoalType type; ///< Type of the goal
|
GoalType type = GT_NONE; ///< Type of the goal
|
||||||
GoalTypeID dst; ///< Index of type
|
GoalTypeID dst = 0; ///< Index of type
|
||||||
std::string text; ///< Text of the goal.
|
std::string text{}; ///< Text of the goal.
|
||||||
std::string progress; ///< Progress text of the goal.
|
std::string progress{}; ///< Progress text of the goal.
|
||||||
bool completed; ///< Is the goal completed or not?
|
bool completed = false; ///< Is the goal completed or not?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 Goal() { }
|
Goal() { }
|
||||||
|
Goal(GoalType type, GoalTypeID dst, CompanyID company, const std::string &text) : company(company), type(type), dst(dst), text(text) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (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 ~Goal() { }
|
~Goal() { }
|
||||||
|
|
||||||
static bool IsValidGoalDestination(CompanyID company, GoalType type, GoalTypeID dest);
|
static bool IsValidGoalDestination(CompanyID company, GoalType type, GoalTypeID dest);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue