diff --git a/src/news_gui.cpp b/src/news_gui.cpp index ce4da6ba96..a030672533 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -280,7 +280,7 @@ struct NewsWindow : Window { this->CreateNestedTree(); /* For company news with a face we have a separate headline in param[0] */ - if (desc == &_company_news_desc) this->GetWidget(WID_N_TITLE)->widget_data = this->ni->params[0]; + if (desc == &_company_news_desc) this->GetWidget(WID_N_TITLE)->widget_data = this->ni->params[0].data; NWidgetCore *nwid = this->GetWidget(WID_N_SHOW_GROUP); if (ni->reftype1 == NR_VEHICLE && nwid != nullptr) { @@ -361,7 +361,7 @@ struct NewsWindow : Window { break; case WID_N_MESSAGE: - CopyInDParam(this->ni->params, lengthof(this->ni->params)); + CopyInDParam(this->ni->params); str = this->ni->string_id; break; @@ -429,7 +429,7 @@ struct NewsWindow : Window { break; case WID_N_MESSAGE: - CopyInDParam(this->ni->params, lengthof(this->ni->params)); + CopyInDParam(this->ni->params); DrawStringMultiLine(r.left, r.right, r.top, r.bottom, this->ni->string_id, TC_FROMSTRING, SA_CENTER); break; @@ -582,8 +582,8 @@ private: StringID GetCompanyMessageString() const { /* Company news with a face have a separate headline, so the normal message is shifted by two params */ - CopyInDParam(this->ni->params + 2, lengthof(this->ni->params) - 2); - return this->ni->params[1]; + CopyInDParam(span(this->ni->params.data() + 2, this->ni->params.size() - 2)); + return this->ni->params[1].data; } StringID GetNewVehicleMessageString(int widget) const @@ -804,7 +804,7 @@ NewsItem::NewsItem(StringID string_id, NewsType type, NewsFlag flags, NewsRefere { /* show this news message in colour? */ if (TimerGameCalendar::year >= _settings_client.gui.coloured_news_year) this->flags |= NF_INCOLOUR; - CopyOutDParam(this->params, lengthof(this->params)); + CopyOutDParam(this->params, 10); } /** @@ -998,7 +998,7 @@ void ChangeVehicleNews(VehicleID from_index, VehicleID to_index) for (NewsItem *ni = _oldest_news; ni != nullptr; ni = ni->next) { if (ni->reftype1 == NR_VEHICLE && ni->ref1 == from_index) ni->ref1 = to_index; if (ni->reftype2 == NR_VEHICLE && ni->ref2 == from_index) ni->ref2 = to_index; - if (ni->flags & NF_VEHICLE_PARAM0 && ni->params[0] == from_index) ni->params[0] = to_index; + if (ni->flags & NF_VEHICLE_PARAM0 && ni->params[0].data == from_index) ni->params[0] = to_index; } } @@ -1099,7 +1099,7 @@ void ShowLastNewsMessage() */ static void DrawNewsString(uint left, uint right, int y, TextColour colour, const NewsItem *ni) { - CopyInDParam(ni->params, lengthof(ni->params)); + CopyInDParam(ni->params); /* Get the string, replaces newlines with spaces and remove control codes from the string. */ std::string message = StrMakeValid(GetString(ni->string_id), SVS_REPLACE_TAB_CR_NL_WITH_SPACE); diff --git a/src/news_type.h b/src/news_type.h index c1e4586004..c4b6076b24 100644 --- a/src/news_type.h +++ b/src/news_type.h @@ -138,7 +138,7 @@ struct NewsItem { std::unique_ptr data; ///< Custom data for the news item that will be deallocated (deleted) when the news item has reached its end. - uint64 params[10]; ///< Parameters for string resolving. + std::vector params; ///< Parameters for string resolving. NewsItem(StringID string_id, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32 ref1, NewsReferenceType reftype2, uint32 ref2, const NewsAllocatedData *data); }; diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index ce8acf86ef..0a56a0c816 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -39,7 +39,7 @@ static bool DrawScrollingStatusText(const NewsItem *ni, int scroll_pos, int left, int right, int top, int bottom) { - CopyInDParam(ni->params, lengthof(ni->params)); + CopyInDParam(ni->params); /* Replace newlines and the likes with spaces. */ std::string message = StrMakeValid(GetString(ni->string_id), SVS_REPLACE_TAB_CR_NL_WITH_SPACE);