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 (flags.Test(DoCommandFlag::Execute)) {
|
||||
Goal *g = new Goal();
|
||||
g->type = type;
|
||||
g->dst = dest;
|
||||
g->company = company;
|
||||
g->text = text;
|
||||
g->completed = false;
|
||||
Goal *g = new Goal(type, dest, company, text);
|
||||
|
||||
if (g->company == CompanyID::Invalid()) {
|
||||
InvalidateWindowClassesData(WC_GOALS_LIST);
|
||||
|
|
|
@ -19,22 +19,23 @@ extern GoalPool _goal_pool;
|
|||
|
||||
/** Struct about goals, current and completed */
|
||||
struct Goal : GoalPool::PoolItem<&_goal_pool> {
|
||||
CompanyID company; ///< Goal is for a specific company; CompanyID::Invalid() if it is global
|
||||
GoalType type; ///< Type of the goal
|
||||
GoalTypeID dst; ///< Index of type
|
||||
std::string text; ///< Text of the goal.
|
||||
std::string progress; ///< Progress text of the goal.
|
||||
bool completed; ///< Is the goal completed or not?
|
||||
CompanyID company = CompanyID::Invalid(); ///< Goal is for a specific company; CompanyID::Invalid() if it is global
|
||||
GoalType type = GT_NONE; ///< Type of the goal
|
||||
GoalTypeID dst = 0; ///< Index of type
|
||||
std::string text{}; ///< Text of the goal.
|
||||
std::string progress{}; ///< Progress text of the goal.
|
||||
bool completed = false; ///< Is the goal completed or not?
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
inline ~Goal() { }
|
||||
~Goal() { }
|
||||
|
||||
static bool IsValidGoalDestination(CompanyID company, GoalType type, GoalTypeID dest);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue