diff --git a/src/goal.cpp b/src/goal.cpp --- a/src/goal.cpp +++ b/src/goal.cpp @@ -84,8 +84,7 @@ std::tuple CmdCreat g->type = type; g->dst = dest; g->company = company; - g->text = stredup(text.c_str()); - g->progress = nullptr; + g->text = text; g->completed = false; if (g->company == INVALID_COMPANY) { @@ -143,8 +142,7 @@ CommandCost CmdSetGoalText(DoCommandFlag if (flags & DC_EXEC) { Goal *g = Goal::Get(goal); - free(g->text); - g->text = stredup(text.c_str()); + g->text = text; if (g->company == INVALID_COMPANY) { InvalidateWindowClassesData(WC_GOALS_LIST); @@ -170,12 +168,7 @@ CommandCost CmdSetGoalProgress(DoCommand if (flags & DC_EXEC) { Goal *g = Goal::Get(goal); - free(g->progress); - if (text.empty()) { - g->progress = nullptr; - } else { - g->progress = stredup(text.c_str()); - } + g->progress = text; if (g->company == INVALID_COMPANY) { InvalidateWindowClassesData(WC_GOALS_LIST); @@ -255,7 +248,7 @@ CommandCost CmdGoalQuestion(DoCommandFla if (company == INVALID_COMPANY && !Company::IsValidID(_local_company)) return CommandCost(); if (company != INVALID_COMPANY && company != _local_company) return CommandCost(); } - ShowGoalQuestion(uniqueid, type, button_mask, text.c_str()); + ShowGoalQuestion(uniqueid, type, button_mask, text); } return CommandCost();