mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Implement news_item_add_to_queue and some bugfixes.
This commit is contained in:
@@ -20,9 +20,11 @@
|
||||
|
||||
#include "addresses.h"
|
||||
#include "audio.h"
|
||||
#include "date.h"
|
||||
#include "news_item.h"
|
||||
#include "rct2.h"
|
||||
#include "ride.h"
|
||||
#include "strings.h"
|
||||
#include "sprite.h"
|
||||
#include "window.h"
|
||||
|
||||
@@ -248,3 +250,43 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int *
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* rct2: 0x0066DF55
|
||||
*
|
||||
* @param a (al)
|
||||
* @param string_id (ebx)
|
||||
* @param c (ecx)
|
||||
**/
|
||||
void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc)
|
||||
{
|
||||
int i = 0;
|
||||
rct_news_item *newsItem = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item);
|
||||
|
||||
// find first open slot
|
||||
while (newsItem->type != NEWS_ITEM_NULL) {
|
||||
if (newsItem + sizeof(newsItem) >= 0x13CB1CC)
|
||||
news_item_close_current();
|
||||
else
|
||||
newsItem++;
|
||||
}
|
||||
|
||||
//now we have found an item slot to place the new news in
|
||||
newsItem->type = type;
|
||||
newsItem->flags = 0;
|
||||
newsItem->assoc = assoc;
|
||||
newsItem->ticks = 0;
|
||||
newsItem->month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
|
||||
newsItem->day = (days_in_month[(newsItem->month & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16;
|
||||
|
||||
format_string(0x0141EF68, string_id, 0x013CE952); // overflows possible?
|
||||
newsItem->colour = ((char*)0x0141EF68)[0];
|
||||
strncpy(newsItem->text, 0x0141EF68, 255);
|
||||
newsItem->text[254] = 0;
|
||||
|
||||
// blatant disregard for what happens on the last element.
|
||||
// Change this when we implement the queue ourselves.
|
||||
newsItem++;
|
||||
newsItem->type = 0;
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
#define _NEWS_ITEM_H_
|
||||
|
||||
#include "rct2.h"
|
||||
#include "strings.h"
|
||||
|
||||
enum {
|
||||
NEWS_ITEM_NULL,
|
||||
@@ -57,5 +58,6 @@ void news_item_init_queue();
|
||||
void news_item_update_current();
|
||||
void news_item_close_current();
|
||||
void news_item_get_subject_location(int type, int subject, int *x, int *y, int *z);
|
||||
void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -730,7 +730,7 @@ void scneario_entrance_fee_too_high_check()
|
||||
}
|
||||
|
||||
packed_xy = (y << 16) | x;
|
||||
RCT2_CALLPROC_X(0x0066DF55, 5, STR_ENTRANCE_FEE_TOO_HI, packed_xy, 0, 0, 0, 0); // dispatch news
|
||||
news_item_add_to_queue(NEWS_ITEM_BLANK, STR_ENTRANCE_FEE_TOO_HI, packed_xy);
|
||||
}
|
||||
|
||||
|
||||
@@ -739,16 +739,16 @@ void scneario_entrance_fee_too_high_check()
|
||||
**/
|
||||
void scenario_marketing_update()
|
||||
{
|
||||
int base_str = STR_MARKETING_FINISHED_BASE;
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
uint8 campaign_weeks_left = RCT2_ADDRESS(0x01358102, uint8)[i];
|
||||
int campaign_item = 0;
|
||||
|
||||
if (!campaign_weeks_left)
|
||||
continue;
|
||||
|
||||
window_invalidate_by_id(WC_FINANCES, 0);
|
||||
|
||||
// high bit marks the campaign as inactive, on first check the campaign is set actice
|
||||
// this makes campaigns run a full x weeks even when started in the middle of a week
|
||||
RCT2_ADDRESS(0x01358102, uint8)[i] &= ~(1 << 7);
|
||||
if (campaign_weeks_left & (1 << 7))
|
||||
continue;
|
||||
@@ -765,12 +765,12 @@ void scenario_marketing_update()
|
||||
RCT2_GLOBAL(0x013CE954, uint32) = RCT2_GLOBAL(0x01362944 + 152 * campaign_item, uint32);
|
||||
} else if (i == 3) { // free food/merch
|
||||
campaign_item += 2016;
|
||||
if (campaign_item < 2048)
|
||||
if (campaign_item >= 2048)
|
||||
campaign_item += 96;
|
||||
RCT2_GLOBAL(0x013CE952, uint16) = campaign_item;
|
||||
}
|
||||
|
||||
RCT2_CALLPROC_X(0x0066DF55, 4, base_str + i, 0, 0, 0, 0, 0); // dispatch news
|
||||
news_item_add_to_queue(NEWS_ITEM_MONEY, STR_MARKETING_FINISHED_BASE + i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user