diff options
author | rubidium42 <rubidium@openttd.org> | 2021-06-16 17:50:18 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-07-01 19:04:38 +0200 |
commit | aa9818db90b910b1b3d62d080f4a670a6a9d14af (patch) | |
tree | d3e76cefe6872f5c0b0b8edebef6cfed99f6bcab /src/subsidy.cpp | |
parent | df601b8559b3d5de179b5b9e65ab9674fbd8bf5e (diff) | |
download | openttd-aa9818db90b910b1b3d62d080f4a670a6a9d14af.tar.xz |
Codechange: create a type for the "free_data" of NewsItems and (de)allocate it with new and delete
Diffstat (limited to 'src/subsidy.cpp')
-rw-r--r-- | src/subsidy.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/subsidy.cpp b/src/subsidy.cpp index 8800da1bd..28cb0d3cc 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -43,22 +43,19 @@ void Subsidy::AwardTo(CompanyID company) this->awarded = company; this->remaining = _settings_game.difficulty.subsidy_duration * MONTHS_IN_YEAR; - char company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH]; SetDParam(0, company); - GetString(company_name, STR_COMPANY_NAME, lastof(company_name)); - - char *cn = stredup(company_name); + NewsStringData *company_name = new NewsStringData(GetString(STR_COMPANY_NAME)); /* Add a news item */ std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(this, SubsidyDecodeParamType::NewsAwarded); InjectDParam(1); - SetDParamStr(0, cn); + SetDParamStr(0, company_name->string); AddNewsItem( STR_NEWS_SERVICE_SUBSIDY_AWARDED_HALF + _settings_game.difficulty.subsidy_multiplier, NT_SUBSIDIES, NF_NORMAL, reftype.first, this->src, reftype.second, this->dst, - cn + company_name ); AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index)); Game::NewEvent(new ScriptEventSubsidyAwarded(this->index)); |