Codechange: Pass WindowDesc by reference instead of pointer. (#12771)

WindowDesc as passed to Windows is not optional so don't allow to it to be nullptr.
This commit is contained in:
Peter Nelson
2024-06-11 08:58:03 +01:00
committed by GitHub
parent 18bce69623
commit 4cf6d1dd79
68 changed files with 293 additions and 301 deletions

View File

@@ -234,11 +234,11 @@ static WindowDesc *_news_window_layout[] = {
&_company_news_desc, ///< NF_COMPANY
};
WindowDesc *GetNewsWindowLayout(NewsFlag flags)
WindowDesc &GetNewsWindowLayout(NewsFlag flags)
{
uint layout = GB(flags, NFB_WINDOW_LAYOUT, NFB_WINDOW_LAYOUT_COUNT);
assert(layout < lengthof(_news_window_layout));
return _news_window_layout[layout];
return *_news_window_layout[layout];
}
/**
@@ -284,7 +284,7 @@ struct NewsWindow : Window {
const NewsItem *ni; ///< News item to display.
static int duration; ///< Remaining time for showing the current news message (may only be access while a news item is displayed).
NewsWindow(WindowDesc *desc, const NewsItem *ni) : Window(desc), ni(ni)
NewsWindow(WindowDesc &desc, const NewsItem *ni) : Window(desc), ni(ni)
{
NewsWindow::duration = 16650;
const Window *w = FindWindowByClass(WC_SEND_NETWORK_MSG);
@@ -296,7 +296,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<NWidgetCore>(WID_N_TITLE)->widget_data = this->ni->params[0].data;
if (&desc == &_company_news_desc) this->GetWidget<NWidgetCore>(WID_N_TITLE)->widget_data = this->ni->params[0].data;
NWidgetCore *nwid = this->GetWidget<NWidgetCore>(WID_N_SHOW_GROUP);
if (ni->reftype1 == NR_VEHICLE && nwid != nullptr) {
@@ -1103,7 +1103,7 @@ struct MessageHistoryWindow : Window {
Scrollbar *vscroll;
MessageHistoryWindow(WindowDesc *desc) : Window(desc)
MessageHistoryWindow(WindowDesc &desc) : Window(desc)
{
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_MH_SCROLLBAR);
@@ -1208,5 +1208,5 @@ static WindowDesc _message_history_desc(
void ShowMessageHistory()
{
CloseWindowById(WC_MESSAGE_HISTORY, 0);
new MessageHistoryWindow(&_message_history_desc);
new MessageHistoryWindow(_message_history_desc);
}