summaryrefslogtreecommitdiff
path: root/src/company_cmd.cpp
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-06-16 17:54:08 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-07-01 19:04:38 +0200
commit9a7750f14eccd8afb6e8bb608ec421c09a486d53 (patch)
treee77f49a9225f414939961fd5b2794147b2aa25f6 /src/company_cmd.cpp
parentaa9818db90b910b1b3d62d080f4a670a6a9d14af (diff)
downloadopenttd-9a7750f14eccd8afb6e8bb608ec421c09a486d53.tar.xz
Codechange: use the constructor for CompanyNewsItem to fill the data instead of a separate function
Diffstat (limited to 'src/company_cmd.cpp')
-rw-r--r--src/company_cmd.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 3c5e5f5c7..754921284 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -376,8 +376,7 @@ set_name:;
MarkWholeScreenDirty();
if (c->is_ai) {
- CompanyNewsInformation *cni = new CompanyNewsInformation();
- cni->FillData(c);
+ CompanyNewsInformation *cni = new CompanyNewsInformation(c);
SetDParam(0, STR_NEWS_COMPANY_LAUNCH_TITLE);
SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION);
SetDParamStr(2, cni->company_name);
@@ -755,21 +754,19 @@ void CompaniesYearlyLoop()
* @param c the current company.
* @param other the other company (use \c nullptr if not relevant).
*/
-void CompanyNewsInformation::FillData(const Company *c, const Company *other)
+CompanyNewsInformation::CompanyNewsInformation(const Company *c, const Company *other)
{
SetDParam(0, c->index);
- GetString(this->company_name, STR_COMPANY_NAME, lastof(this->company_name));
+ this->company_name = GetString(STR_COMPANY_NAME);
- if (other == nullptr) {
- *this->other_company_name = '\0';
- } else {
+ if (other != nullptr) {
SetDParam(0, other->index);
- GetString(this->other_company_name, STR_COMPANY_NAME, lastof(this->other_company_name));
+ this->other_company_name = GetString(STR_COMPANY_NAME);
c = other;
}
SetDParam(0, c->index);
- GetString(this->president_name, STR_PRESIDENT_NAME_MANAGER, lastof(this->president_name));
+ this->president_name = GetString(STR_PRESIDENT_NAME_MANAGER);
this->colour = c->colour;
this->face = c->face;
@@ -888,8 +885,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
/* Delete any open window of the company */
CloseCompanyWindows(c->index);
- CompanyNewsInformation *cni = new CompanyNewsInformation();
- cni->FillData(c);
+ CompanyNewsInformation *cni = new CompanyNewsInformation(c);
/* Show the bankrupt news */
SetDParam(0, STR_NEWS_COMPANY_BANKRUPT_TITLE);