mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-17 17:32:45 +01:00
Codechange: Remove redundant NewsStringData data. (#12983)
Since SetDParamStr() always owns a copy of the string, there is no need to make another copy of it to keep it around while the news item exists. This also fixes a leak in `CmdIndustrySetProduction` as the allocated data wasn't passed to AddIndustryNewsItem.
This commit is contained in:
@@ -48,17 +48,16 @@ void Subsidy::AwardTo(CompanyID company)
|
||||
this->remaining = _settings_game.difficulty.subsidy_duration * CalendarTime::MONTHS_IN_YEAR;
|
||||
|
||||
SetDParam(0, company);
|
||||
NewsStringData *company_name = new NewsStringData(GetString(STR_COMPANY_NAME));
|
||||
std::string company_name = GetString(STR_COMPANY_NAME);
|
||||
|
||||
/* Add a news item */
|
||||
std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(this, SubsidyDecodeParamType::NewsAwarded, 1);
|
||||
|
||||
SetDParamStr(0, company_name->string);
|
||||
SetDParamStr(0, company_name);
|
||||
AddNewsItem(
|
||||
STR_NEWS_SERVICE_SUBSIDY_AWARDED_HALF + _settings_game.difficulty.subsidy_multiplier,
|
||||
NT_SUBSIDIES, NF_NORMAL,
|
||||
reftype.first, this->src, reftype.second, this->dst,
|
||||
company_name
|
||||
reftype.first, this->src, reftype.second, this->dst
|
||||
);
|
||||
AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index));
|
||||
Game::NewEvent(new ScriptEventSubsidyAwarded(this->index));
|
||||
|
||||
Reference in New Issue
Block a user