mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-07 07:04:36 +01:00
Create constants for sizes of NewsItem queues
This commit is contained in:
@@ -150,7 +150,7 @@ static void window_news_update(rct_window* w)
|
||||
|
||||
j = w->news.var_480;
|
||||
w->news.var_480 = -1;
|
||||
for (i = 11; i < 61; i++)
|
||||
for (i = MAX_RECENT_NEWS_ITEMS; i < MAX_NEWS_ITEMS; i++)
|
||||
{
|
||||
if (news_item_is_empty(i))
|
||||
return;
|
||||
@@ -188,7 +188,7 @@ static void window_news_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_
|
||||
int32_t itemHeight = window_news_get_item_height();
|
||||
|
||||
*height = 0;
|
||||
for (int32_t i = 11; i < 61; i++)
|
||||
for (int32_t i = MAX_RECENT_NEWS_ITEMS; i < MAX_NEWS_ITEMS; i++)
|
||||
{
|
||||
if (news_item_is_empty(i))
|
||||
break;
|
||||
@@ -208,7 +208,7 @@ static void window_news_scrollmousedown(rct_window* w, int32_t scrollIndex, cons
|
||||
|
||||
buttonIndex = 0;
|
||||
auto mutableScreenCoords = screenCoords;
|
||||
for (i = 11; i < 61; i++)
|
||||
for (i = MAX_RECENT_NEWS_ITEMS; i < MAX_NEWS_ITEMS; i++)
|
||||
{
|
||||
if (news_item_is_empty(i))
|
||||
break;
|
||||
@@ -266,7 +266,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32
|
||||
int32_t i, x, y, yy, press;
|
||||
|
||||
y = 0;
|
||||
for (i = 11; i < 61; i++)
|
||||
for (i = MAX_RECENT_NEWS_ITEMS; i < MAX_NEWS_ITEMS; i++)
|
||||
{
|
||||
NewsItem* const newsItem = news_item_get(i);
|
||||
if (news_item_is_empty(i))
|
||||
|
||||
@@ -164,11 +164,11 @@ void news_item_close_current()
|
||||
window_invalidate_by_class(WC_RECENT_NEWS);
|
||||
|
||||
// Dequeue the current news item, shift news up
|
||||
for (i = 0; i < NEWS_ITEM_HISTORY_START - 1; i++)
|
||||
for (i = 0; i < MAX_RECENT_NEWS_ITEMS - 1; i++)
|
||||
{
|
||||
newsItems[i] = newsItems[i + 1];
|
||||
}
|
||||
newsItems[NEWS_ITEM_HISTORY_START - 1].Type = NEWS_ITEM_NULL;
|
||||
newsItems[MAX_RECENT_NEWS_ITEMS - 1].Type = NEWS_ITEM_NULL;
|
||||
|
||||
// Invalidate current news item bar
|
||||
auto intent = Intent(INTENT_ACTION_INVALIDATE_TICKER_NEWS);
|
||||
@@ -190,7 +190,7 @@ static void news_item_shift_history_up()
|
||||
static int32_t news_item_get_new_history_slot()
|
||||
{
|
||||
// Find an available history news item slot
|
||||
for (int32_t i = NEWS_ITEM_HISTORY_START; i < MAX_NEWS_ITEMS; i++)
|
||||
for (int32_t i = MAX_RECENT_NEWS_ITEMS; i < MAX_NEWS_ITEMS; i++)
|
||||
{
|
||||
if (news_item_is_empty(i))
|
||||
return i;
|
||||
@@ -301,7 +301,7 @@ static NewsItem* news_item_first_open_queue_slot()
|
||||
|
||||
while (newsItem->Type != NEWS_ITEM_NULL)
|
||||
{
|
||||
if (newsItem + 1 >= &gNewsItems[NEWS_ITEM_HISTORY_START - 1])
|
||||
if (newsItem + 1 >= &gNewsItems[MAX_RECENT_NEWS_ITEMS - 1])
|
||||
news_item_close_current();
|
||||
else
|
||||
newsItem++;
|
||||
@@ -438,7 +438,7 @@ void news_item_open_subject(int32_t type, int32_t subject)
|
||||
void news_item_disable_news(uint8_t type, uint32_t assoc)
|
||||
{
|
||||
// TODO: write test invalidating windows
|
||||
for (int32_t i = 0; i < NEWS_ITEM_HISTORY_START; i++)
|
||||
for (int32_t i = 0; i < MAX_RECENT_NEWS_ITEMS; i++)
|
||||
{
|
||||
if (!news_item_is_empty(i))
|
||||
{
|
||||
@@ -459,7 +459,7 @@ void news_item_disable_news(uint8_t type, uint32_t assoc)
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t i = NEWS_ITEM_HISTORY_START; i < MAX_NEWS_ITEMS; i++)
|
||||
for (int32_t i = MAX_RECENT_NEWS_ITEMS; i < MAX_NEWS_ITEMS; i++)
|
||||
{
|
||||
if (!news_item_is_empty(i))
|
||||
{
|
||||
|
||||
@@ -54,8 +54,9 @@ struct NewsItem
|
||||
utf8 Text[256];
|
||||
};
|
||||
|
||||
constexpr int32_t NEWS_ITEM_HISTORY_START = 11;
|
||||
constexpr int32_t MAX_NEWS_ITEMS = 61;
|
||||
constexpr int32_t MAX_RECENT_NEWS_ITEMS = 11;
|
||||
constexpr int32_t MAX_OLD_NEWS_ITEMS = 50;
|
||||
constexpr int32_t MAX_NEWS_ITEMS = MAX_RECENT_NEWS_ITEMS + MAX_OLD_NEWS_ITEMS;
|
||||
|
||||
extern const uint8_t news_type_properties[10];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user