diff --git a/src/goal.cpp b/src/goal.cpp index 0902bf2607..3e1f565cfd 100644 --- a/src/goal.cpp +++ b/src/goal.cpp @@ -85,12 +85,7 @@ std::tuple 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); diff --git a/src/goal_base.h b/src/goal_base.h index 217dda5426..af15e86fee 100644 --- a/src/goal_base.h +++ b/src/goal_base.h @@ -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); };