mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use the constructor for CompanyNewsItem to fill the data instead of a separate function
parent
aa9818db90
commit
9a7750f14e
|
@ -376,8 +376,7 @@ set_name:;
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
|
|
||||||
if (c->is_ai) {
|
if (c->is_ai) {
|
||||||
CompanyNewsInformation *cni = new CompanyNewsInformation();
|
CompanyNewsInformation *cni = new CompanyNewsInformation(c);
|
||||||
cni->FillData(c);
|
|
||||||
SetDParam(0, STR_NEWS_COMPANY_LAUNCH_TITLE);
|
SetDParam(0, STR_NEWS_COMPANY_LAUNCH_TITLE);
|
||||||
SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION);
|
SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION);
|
||||||
SetDParamStr(2, cni->company_name);
|
SetDParamStr(2, cni->company_name);
|
||||||
|
@ -755,21 +754,19 @@ void CompaniesYearlyLoop()
|
||||||
* @param c the current company.
|
* @param c the current company.
|
||||||
* @param other the other company (use \c nullptr if not relevant).
|
* @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);
|
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) {
|
if (other != nullptr) {
|
||||||
*this->other_company_name = '\0';
|
|
||||||
} else {
|
|
||||||
SetDParam(0, other->index);
|
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;
|
c = other;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDParam(0, c->index);
|
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->colour = c->colour;
|
||||||
this->face = c->face;
|
this->face = c->face;
|
||||||
|
@ -888,8 +885,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
|
|
||||||
/* Delete any open window of the company */
|
/* Delete any open window of the company */
|
||||||
CloseCompanyWindows(c->index);
|
CloseCompanyWindows(c->index);
|
||||||
CompanyNewsInformation *cni = new CompanyNewsInformation();
|
CompanyNewsInformation *cni = new CompanyNewsInformation(c);
|
||||||
cni->FillData(c);
|
|
||||||
|
|
||||||
/* Show the bankrupt news */
|
/* Show the bankrupt news */
|
||||||
SetDParam(0, STR_NEWS_COMPANY_BANKRUPT_TITLE);
|
SetDParam(0, STR_NEWS_COMPANY_BANKRUPT_TITLE);
|
||||||
|
|
|
@ -580,8 +580,7 @@ static void CompanyCheckBankrupt(Company *c)
|
||||||
|
|
||||||
/* Warn about bankruptcy after 3 months */
|
/* Warn about bankruptcy after 3 months */
|
||||||
case 4: {
|
case 4: {
|
||||||
CompanyNewsInformation *cni = new CompanyNewsInformation();
|
CompanyNewsInformation *cni = new CompanyNewsInformation(c);
|
||||||
cni->FillData(c);
|
|
||||||
SetDParam(0, STR_NEWS_COMPANY_IN_TROUBLE_TITLE);
|
SetDParam(0, STR_NEWS_COMPANY_IN_TROUBLE_TITLE);
|
||||||
SetDParam(1, STR_NEWS_COMPANY_IN_TROUBLE_DESCRIPTION);
|
SetDParam(1, STR_NEWS_COMPANY_IN_TROUBLE_DESCRIPTION);
|
||||||
SetDParamStr(2, cni->company_name);
|
SetDParamStr(2, cni->company_name);
|
||||||
|
@ -1975,8 +1974,7 @@ static void DoAcquireCompany(Company *c)
|
||||||
{
|
{
|
||||||
CompanyID ci = c->index;
|
CompanyID ci = c->index;
|
||||||
|
|
||||||
CompanyNewsInformation *cni = new CompanyNewsInformation();
|
CompanyNewsInformation *cni = new CompanyNewsInformation(c, Company::Get(_current_company));
|
||||||
cni->FillData(c, Company::Get(_current_company));
|
|
||||||
|
|
||||||
SetDParam(0, STR_NEWS_COMPANY_MERGER_TITLE);
|
SetDParam(0, STR_NEWS_COMPANY_MERGER_TITLE);
|
||||||
SetDParam(1, c->bankrupt_value == 0 ? STR_NEWS_MERGER_TAKEOVER_TITLE : STR_NEWS_COMPANY_MERGER_DESCRIPTION);
|
SetDParam(1, c->bankrupt_value == 0 ? STR_NEWS_MERGER_TAKEOVER_TITLE : STR_NEWS_COMPANY_MERGER_DESCRIPTION);
|
||||||
|
|
|
@ -158,14 +158,14 @@ struct NewsStringData : NewsAllocatedData {
|
||||||
* resulting in wrong names and such.
|
* resulting in wrong names and such.
|
||||||
*/
|
*/
|
||||||
struct CompanyNewsInformation : NewsAllocatedData {
|
struct CompanyNewsInformation : NewsAllocatedData {
|
||||||
char company_name[64]; ///< The name of the company
|
std::string company_name; ///< The name of the company
|
||||||
char president_name[64]; ///< The name of the president
|
std::string president_name; ///< The name of the president
|
||||||
char other_company_name[64]; ///< The name of the company taking over this one
|
std::string other_company_name; ///< The name of the company taking over this one
|
||||||
|
|
||||||
uint32 face; ///< The face of the president
|
uint32 face; ///< The face of the president
|
||||||
byte colour; ///< The colour related to the company
|
byte colour; ///< The colour related to the company
|
||||||
|
|
||||||
void FillData(const struct Company *c, const struct Company *other = nullptr);
|
CompanyNewsInformation(const struct Company *c, const struct Company *other = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* NEWS_TYPE_H */
|
#endif /* NEWS_TYPE_H */
|
||||||
|
|
|
@ -3231,8 +3231,7 @@ static CommandCost TownActionBuyRights(Town *t, DoCommandFlag flags)
|
||||||
SetWindowClassesDirty(WC_STATION_VIEW);
|
SetWindowClassesDirty(WC_STATION_VIEW);
|
||||||
|
|
||||||
/* Spawn news message */
|
/* Spawn news message */
|
||||||
CompanyNewsInformation *cni = new CompanyNewsInformation();
|
CompanyNewsInformation *cni = new CompanyNewsInformation(Company::Get(_current_company));
|
||||||
cni->FillData(Company::Get(_current_company));
|
|
||||||
SetDParam(0, STR_NEWS_EXCLUSIVE_RIGHTS_TITLE);
|
SetDParam(0, STR_NEWS_EXCLUSIVE_RIGHTS_TITLE);
|
||||||
SetDParam(1, STR_NEWS_EXCLUSIVE_RIGHTS_DESCRIPTION);
|
SetDParam(1, STR_NEWS_EXCLUSIVE_RIGHTS_DESCRIPTION);
|
||||||
SetDParam(2, t->index);
|
SetDParam(2, t->index);
|
||||||
|
|
Loading…
Reference in New Issue