mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Pass NewsItem by reference. (#13898)
parent
422ff9dbd8
commit
5331389765
|
@ -1187,10 +1187,10 @@ void ShowLastNewsMessage()
|
|||
* @param colour the colour the string will be shown in
|
||||
* @param *ni NewsItem being printed
|
||||
*/
|
||||
static void DrawNewsString(uint left, uint right, int y, TextColour colour, const NewsItem *ni)
|
||||
static void DrawNewsString(uint left, uint right, int y, TextColour colour, const NewsItem &ni)
|
||||
{
|
||||
/* Get the string, replaces newlines with spaces and remove control codes from the string. */
|
||||
std::string message = StrMakeValid(ni->GetStatusText(), SVS_REPLACE_TAB_CR_NL_WITH_SPACE);
|
||||
std::string message = StrMakeValid(ni.GetStatusText(), SVS_REPLACE_TAB_CR_NL_WITH_SPACE);
|
||||
|
||||
/* Truncate and show string; postfixed by '...' if necessary */
|
||||
DrawString(left, right, y, message, colour);
|
||||
|
@ -1239,7 +1239,7 @@ struct MessageHistoryWindow : Window {
|
|||
for (auto ni = first; ni != last; ++ni) {
|
||||
DrawString(date.left, date.right, y, GetString(STR_JUST_DATE_TINY, ni->date), TC_WHITE);
|
||||
|
||||
DrawNewsString(news.left, news.right, y, TC_WHITE, &*ni);
|
||||
DrawNewsString(news.left, news.right, y, TC_WHITE, *ni);
|
||||
y += this->line_height;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
|
||||
#include "safeguards.h"
|
||||
|
||||
static bool DrawScrollingStatusText(const NewsItem *ni, int scroll_pos, int left, int right, int top, int bottom)
|
||||
static bool DrawScrollingStatusText(const NewsItem &ni, int scroll_pos, int left, int right, int top, int bottom)
|
||||
{
|
||||
/* Replace newlines and the likes with spaces. */
|
||||
std::string message = StrMakeValid(ni->GetStatusText(), SVS_REPLACE_TAB_CR_NL_WITH_SPACE);
|
||||
std::string message = StrMakeValid(ni.GetStatusText(), SVS_REPLACE_TAB_CR_NL_WITH_SPACE);
|
||||
|
||||
DrawPixelInfo tmp_dpi;
|
||||
if (!FillDrawPixelInfo(&tmp_dpi, left, top, right - left, bottom)) return true;
|
||||
|
@ -139,7 +139,7 @@ struct StatusBarWindow : Window {
|
|||
DrawString(tr, msg, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
} else if (this->ticker_scroll < TICKER_STOP && GetStatusbarNews() != nullptr && !GetStatusbarNews()->headline.empty()) {
|
||||
/* Draw the scrolling news text */
|
||||
if (!DrawScrollingStatusText(GetStatusbarNews(), ScaleGUITrad(this->ticker_scroll), tr.left, tr.right, tr.top, tr.bottom)) {
|
||||
if (!DrawScrollingStatusText(*GetStatusbarNews(), ScaleGUITrad(this->ticker_scroll), tr.left, tr.right, tr.top, tr.bottom)) {
|
||||
InvalidateWindowData(WC_STATUS_BAR, 0, SBI_NEWS_DELETED);
|
||||
if (Company::IsValidID(_local_company)) {
|
||||
/* This is the default text */
|
||||
|
|
Loading…
Reference in New Issue