Codechange: create a type for the "free_data" of NewsItems and (de)allocate it with new and delete
This commit is contained in:
@@ -2020,15 +2020,13 @@ CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
SetDParam(0, t->index);
|
||||
AddTileNewsItem(STR_NEWS_NEW_TOWN_UNSPONSORED, NT_INDUSTRY_OPEN, tile);
|
||||
} else {
|
||||
char company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH];
|
||||
SetDParam(0, _current_company);
|
||||
GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
|
||||
NewsStringData *company_name = new NewsStringData(GetString(STR_COMPANY_NAME));
|
||||
|
||||
char *cn = stredup(company_name);
|
||||
SetDParamStr(0, cn);
|
||||
SetDParamStr(0, company_name->string);
|
||||
SetDParam(1, t->index);
|
||||
|
||||
AddTileNewsItem(STR_NEWS_NEW_TOWN, NT_INDUSTRY_OPEN, tile, cn);
|
||||
AddTileNewsItem(STR_NEWS_NEW_TOWN, NT_INDUSTRY_OPEN, tile, company_name);
|
||||
}
|
||||
AI::BroadcastNewEvent(new ScriptEventTownFounded(t->index));
|
||||
Game::NewEvent(new ScriptEventTownFounded(t->index));
|
||||
@@ -3090,15 +3088,13 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags)
|
||||
if (flags & DC_EXEC) {
|
||||
t->road_build_months = 6;
|
||||
|
||||
char company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH];
|
||||
SetDParam(0, _current_company);
|
||||
GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
|
||||
NewsStringData *company_name = new NewsStringData(GetString(STR_COMPANY_NAME));
|
||||
|
||||
char *cn = stredup(company_name);
|
||||
SetDParam(0, t->index);
|
||||
SetDParamStr(1, cn);
|
||||
SetDParamStr(1, company_name->string);
|
||||
|
||||
AddNewsItem(STR_NEWS_ROAD_REBUILDING, NT_GENERAL, NF_NORMAL, NR_TOWN, t->index, NR_NONE, UINT32_MAX, cn);
|
||||
AddNewsItem(STR_NEWS_ROAD_REBUILDING, NT_GENERAL, NF_NORMAL, NR_TOWN, t->index, NR_NONE, UINT32_MAX, company_name);
|
||||
AI::BroadcastNewEvent(new ScriptEventRoadReconstruction((ScriptCompany::CompanyID)(Owner)_current_company, t->index));
|
||||
Game::NewEvent(new ScriptEventRoadReconstruction((ScriptCompany::CompanyID)(Owner)_current_company, t->index));
|
||||
}
|
||||
@@ -3235,7 +3231,7 @@ static CommandCost TownActionBuyRights(Town *t, DoCommandFlag flags)
|
||||
SetWindowClassesDirty(WC_STATION_VIEW);
|
||||
|
||||
/* Spawn news message */
|
||||
CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
|
||||
CompanyNewsInformation *cni = new CompanyNewsInformation();
|
||||
cni->FillData(Company::Get(_current_company));
|
||||
SetDParam(0, STR_NEWS_EXCLUSIVE_RIGHTS_TITLE);
|
||||
SetDParam(1, STR_NEWS_EXCLUSIVE_RIGHTS_DESCRIPTION);
|
||||
|
Reference in New Issue
Block a user