Merge pull request #5085 from IntelOrca/refactor/structs/various

Create new OpenRCT2 news item struct
This commit is contained in:
Ted John 2017-01-22 16:15:42 +00:00 committed by GitHub
commit 8d959fa519
17 changed files with 283 additions and 225 deletions

View File

@ -731,10 +731,10 @@ void game_convert_strings_to_utf8()
// News items
for (sint32 i = 0; i < MAX_NEWS_ITEMS; i++) {
rct_news_item *newsItem = news_item_get(i);
NewsItem *newsItem = news_item_get(i);
if (!str_is_null_or_empty(newsItem->text)) {
rct2_to_utf8_self(newsItem->text, 256);
if (!str_is_null_or_empty(newsItem->Text)) {
rct2_to_utf8_self(newsItem->Text, sizeof(newsItem->Text));
}
}
}
@ -760,10 +760,10 @@ void game_convert_strings_to_rct2(rct_s6_data *s6)
// News items
for (sint32 i = 0; i < MAX_NEWS_ITEMS; i++) {
rct_news_item *newsItem = &s6->news_items[i];
rct12_news_item *newsItem = &s6->news_items[i];
if (!str_is_null_or_empty(newsItem->text)) {
utf8_to_rct2_self(newsItem->text, 256);
if (!str_is_null_or_empty(newsItem->Text)) {
utf8_to_rct2_self(newsItem->Text, sizeof(newsItem->Text));
}
}
}

View File

@ -25,7 +25,7 @@
#include "../world/sprite.h"
#include "news_item.h"
rct_news_item gNewsItems[MAX_NEWS_ITEMS];
NewsItem gNewsItems[MAX_NEWS_ITEMS];
/** rct2: 0x0097BE7C */
const uint8 news_type_properties[] = {
@ -52,7 +52,7 @@ bool news_item_is_valid_idx(sint32 index)
return true;
}
rct_news_item *news_item_get(sint32 index)
NewsItem *news_item_get(sint32 index)
{
if (news_item_is_valid_idx(index)) {
return &gNewsItems[index];
@ -63,7 +63,7 @@ rct_news_item *news_item_get(sint32 index)
bool news_item_is_empty(sint32 index)
{
return news_item_get(index)->type == NEWS_ITEM_NULL;
return news_item_get(index)->Type == NEWS_ITEM_NULL;
}
bool news_item_is_queue_empty()
@ -79,8 +79,8 @@ void news_item_init_queue()
{
sint32 i;
news_item_get(0)->type = NEWS_ITEM_NULL;
news_item_get(11)->type = NEWS_ITEM_NULL;
news_item_get(0)->Type = NEWS_ITEM_NULL;
news_item_get(11)->Type = NEWS_ITEM_NULL;
// Throttles for warning types (PEEP_*_WARNING)
for (i = 0; i < 16; i++) {
@ -93,7 +93,7 @@ void news_item_init_queue()
static void news_item_tick_current()
{
sint32 ticks;
ticks = ++news_item_get(0)->ticks;
ticks = ++news_item_get(0)->Ticks;
// Only play news item sound when in normal playing mode
if (ticks == 1 && (gScreenFlags == SCREEN_FLAGS_PLAYING)) {
// Play sound
@ -110,7 +110,7 @@ static bool news_item_is_current_old()
!news_item_is_empty(2))
remove_time = 256;
if (news_item_get(0)->ticks >= remove_time)
if (news_item_get(0)->Ticks >= remove_time)
return true;
return false;
@ -143,7 +143,7 @@ void news_item_update_current()
void news_item_close_current()
{
sint32 i;
rct_news_item *newsItems = gNewsItems;
NewsItem *newsItems = gNewsItems;
// Check if there is a current message
if (news_item_is_queue_empty())
@ -157,7 +157,7 @@ void news_item_close_current()
// Set the end of the end of the history list
if (i < MAX_NEWS_ITEMS - 1)
newsItems[i + 1].type = NEWS_ITEM_NULL;
newsItems[i + 1].Type = NEWS_ITEM_NULL;
// Invalidate the news window
window_invalidate_by_class(WC_RECENT_NEWS);
@ -165,7 +165,7 @@ void news_item_close_current()
// Dequeue the current news item, shift news up
for (i = 0; i < 10; i++)
newsItems[i] = newsItems[i + 1];
newsItems[10].type = NEWS_ITEM_NULL;
newsItems[10].Type = NEWS_ITEM_NULL;
// Invalidate current news item bar
window_game_bottom_toolbar_invalidate_news_item();
@ -174,8 +174,8 @@ void news_item_close_current()
static void news_item_shift_history_up()
{
const sint32 history_idx = 11;
rct_news_item *history_start = news_item_get(history_idx);
const size_t count = sizeof(rct_news_item) * (MAX_NEWS_ITEMS - 1 - history_idx);
NewsItem *history_start = news_item_get(history_idx);
const size_t count = sizeof(NewsItem) * (MAX_NEWS_ITEMS - 1 - history_idx);
memmove(history_start, history_start + 1, count);
}
@ -288,10 +288,10 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc)
void news_item_add_to_queue_raw(uint8 type, const utf8 *text, uint32 assoc)
{
rct_news_item *newsItem = gNewsItems;
NewsItem *newsItem = gNewsItems;
// find first open slot
while (newsItem->type != NEWS_ITEM_NULL) {
while (newsItem->Type != NEWS_ITEM_NULL) {
if (newsItem + 1 >= &gNewsItems[10]) // &news_list[10]
news_item_close_current();
else
@ -299,19 +299,18 @@ void news_item_add_to_queue_raw(uint8 type, const utf8 *text, uint32 assoc)
}
//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_year = gDateMonthsElapsed;
newsItem->day = ((days_in_month[(newsItem->month_year & 7)] * gDateMonthTicks) >> 16) + 1;
safe_strcpy(newsItem->text, text, 255);
newsItem->text[254] = 0;
newsItem->Type = type;
newsItem->Flags = 0;
newsItem->Assoc = assoc;
newsItem->Ticks = 0;
newsItem->MonthYear = gDateMonthsElapsed;
newsItem->Day = ((days_in_month[(newsItem->MonthYear & 7)] * gDateMonthTicks) >> 16) + 1;
safe_strcpy(newsItem->Text, text, sizeof(newsItem->Text));
// blatant disregard for what happens on the last element.
// Change this when we implement the queue ourselves.
newsItem++;
newsItem->type = 0;
newsItem->Type = NEWS_ITEM_NULL;
}
/**
@ -389,9 +388,9 @@ void news_item_disable_news(uint8 type, uint32 assoc)
// TODO: write test invalidating windows
for (sint32 i = 0; i < 11; i++) {
if (!news_item_is_empty(i)) {
rct_news_item * const newsItem = news_item_get(i);
if (type == newsItem->type && assoc == newsItem->assoc) {
newsItem->flags |= 0x1;
NewsItem * const newsItem = news_item_get(i);
if (type == newsItem->Type && assoc == newsItem->Assoc) {
newsItem->Flags |= NEWS_FLAG_HAS_BUTTON;
if (i == 0) {
window_game_bottom_toolbar_invalidate_news_item();
}
@ -403,9 +402,9 @@ void news_item_disable_news(uint8 type, uint32 assoc)
for (sint32 i = 11; i < MAX_NEWS_ITEMS; i++) {
if (!news_item_is_empty(i)) {
rct_news_item * const newsItem = news_item_get(i);
if (type == newsItem->type && assoc == newsItem->assoc) {
newsItem->flags |= 0x1;
NewsItem * const newsItem = news_item_get(i);
if (type == newsItem->Type && assoc == newsItem->Assoc) {
newsItem->Flags |= NEWS_FLAG_HAS_BUTTON;
window_invalidate_by_class(WC_RECENT_NEWS);
}
} else {
@ -414,12 +413,12 @@ void news_item_disable_news(uint8 type, uint32 assoc)
}
}
void news_item_add_to_queue_custom(rct_news_item *newNewsItem)
void news_item_add_to_queue_custom(NewsItem *newNewsItem)
{
rct_news_item *newsItem = gNewsItems;
NewsItem *newsItem = gNewsItems;
// Find first open slot
while (newsItem->type != NEWS_ITEM_NULL) {
while (newsItem->Type != NEWS_ITEM_NULL) {
if (newsItem + 1 >= &gNewsItems[10])
news_item_close_current();
else
@ -428,5 +427,5 @@ void news_item_add_to_queue_custom(rct_news_item *newNewsItem)
*newsItem = *newNewsItem;
newsItem++;
newsItem->type = 0;
newsItem->Type = NEWS_ITEM_NULL;
}

View File

@ -37,29 +37,28 @@ enum {
NEWS_TYPE_HAS_SUBJECT = 2,
};
enum {
NEWS_FLAG_HAS_BUTTON = 1 << 0,
};
extern const uint8 news_type_properties[10];
#pragma pack(push, 1)
/**
* News item structure.
* size: 0x10C
* A single news item / message.
*/
typedef struct rct_news_item {
uint8 type; // 0x00
uint8 flags; // 0x01
uint32 assoc; // 0x02
uint16 ticks; // 0x06
uint16 month_year; // 0x08
uint8 day; // 0x0A
uint8 pad_0B; // 0x0B
utf8 text[256]; // 0x0C
} rct_news_item;
assert_struct_size(rct_news_item, 12 + 256);
#pragma pack(pop)
typedef struct NewsItem {
uint8 Type;
uint8 Flags;
uint32 Assoc;
uint16 Ticks;
uint16 MonthYear;
uint8 Day;
utf8 Text[256];
} NewsItem;
#define MAX_NEWS_ITEMS 61
extern rct_news_item gNewsItems[MAX_NEWS_ITEMS];
extern NewsItem gNewsItems[MAX_NEWS_ITEMS];
void news_item_init_queue();
void news_item_update_current();
@ -69,11 +68,11 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc);
void news_item_add_to_queue_raw(uint8 type, const utf8 *text, uint32 assoc);
void news_item_open_subject(sint32 type, sint32 subject);
void news_item_disable_news(uint8 type, uint32 assoc);
rct_news_item *news_item_get(sint32 index);
NewsItem *news_item_get(sint32 index);
bool news_item_is_empty(sint32 index);
bool news_item_is_queue_empty();
bool news_item_is_valid_idx(sint32 index);
void news_item_add_to_queue_custom(rct_news_item *newNewsItem);
void news_item_add_to_queue_custom(NewsItem *newNewsItem);
#endif

View File

@ -590,7 +590,7 @@ typedef struct rct1_s4 {
uint8 target_weather_gloom;
uint8 rain;
uint8 target_rain;
rct_news_item messages[61];
rct12_news_item messages[RCT12_MAX_NEWS_ITEMS];
char scenario_name[62];
uint16 scenario_slot_index;
uint32 scenario_flags;

View File

@ -1465,10 +1465,18 @@ private:
}
// News items
rct_news_item *newsItems = gNewsItems;
for (size_t i = 0; i < MAX_NEWS_ITEMS; i++)
for (size_t i = 0; i < RCT12_MAX_NEWS_ITEMS; i++)
{
newsItems[i] = _s4.messages[i];
const rct12_news_item * src = &_s4.messages[i];
NewsItem * dst = &gNewsItems[i];
dst->Type = src->Type;
dst->Flags = src->Flags;
dst->Assoc = src->Assoc;
dst->Ticks = src->Ticks;
dst->MonthYear = src->MonthYear;
dst->Day = src->Day;
memcpy(dst->Text, src->Text, sizeof(src->Text));
}
// Initial guest status

View File

@ -21,6 +21,7 @@
#include "common.h"
#define RCT12_MAX_AWARDS 4
#define RCT12_MAX_NEWS_ITEMS 61
#pragma pack(push, 1)
@ -31,4 +32,21 @@ typedef struct rct12_award
} rct12_award;
assert_struct_size(rct12_award, 4);
/**
* A single news item / message.
* size: 0x10C
*/
typedef struct rct12_news_item
{
uint8 Type;
uint8 Flags;
uint32 Assoc;
uint16 Ticks;
uint16 MonthYear;
uint8 Day;
uint8 pad_0B;
char Text[256];
} rct12_news_item;
assert_struct_size(rct12_news_item, 0x10C);
#pragma pack(pop)

View File

@ -355,9 +355,7 @@ bool rct2_open_file(const char *path)
}
} else if (_stricmp(extension, "sc6") == 0) {
// TODO scenario install
rct_scenario_basic scenarioBasic;
safe_strcpy(scenarioBasic.path, path, sizeof(scenarioBasic.path));
if (scenario_load_and_play_from_path(scenarioBasic.path)) {
if (scenario_load_and_play_from_path(path)) {
return true;
}
} else if (_stricmp(extension, "td6") == 0 || _stricmp(extension, "td4") == 0) {

View File

@ -20,91 +20,133 @@
#include "common.h"
typedef struct rct2_install_info {
uint32 installLevel;
char title[260];
char path[260];
uint32 var_20C;
uint8 pad_210[256];
char expansionPackNames[16][128];
uint32 activeExpansionPacks; //0xB10
uint32 installLevel;
char title[260];
char path[260];
uint32 var_20C;
uint8 pad_210[256];
char expansionPackNames[16][128];
uint32 activeExpansionPacks; //0xB10
} rct2_install_info;
#pragma pack(push, 1)
#ifdef __cplusplus
/**
* scores.dat file header.
* size: 0x10
*/
struct rct_scores_header
{
uint32 var_0;
uint32 var_4;
uint32 var_8;
uint32 ScenarioCount;
};
assert_struct_size(rct_scores_header, 0x10);
/**
* An entry of scores.dat
* size: 0x02B0
*/
struct rct_scores_entry
{
char Path[256];
uint8 Category;
uint8 pad_0101[0x1F];
sint8 ObjectiveType;
sint8 ObjectiveArg1;
sint32 objectiveArg2;
sint16 objectiveArg3;
char Name[64];
char Details[256];
sint32 Flags;
money32 CompanyValue;
char CompletedBy[64];
};
assert_struct_size(rct_scores_entry, 0x02B0);
#endif // __cplusplus
#pragma pack(pop)
enum {
// Although this is labeled a flag it actually means when
// zero the screen is in playing mode.
SCREEN_FLAGS_PLAYING = 0,
SCREEN_FLAGS_TITLE_DEMO = 1,
SCREEN_FLAGS_SCENARIO_EDITOR = 2,
SCREEN_FLAGS_TRACK_DESIGNER = 4,
SCREEN_FLAGS_TRACK_MANAGER = 8,
// Although this is labeled a flag it actually means when
// zero the screen is in playing mode.
SCREEN_FLAGS_PLAYING = 0,
SCREEN_FLAGS_TITLE_DEMO = 1,
SCREEN_FLAGS_SCENARIO_EDITOR = 2,
SCREEN_FLAGS_TRACK_DESIGNER = 4,
SCREEN_FLAGS_TRACK_MANAGER = 8,
};
#define SCREEN_FLAGS_EDITOR (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)
enum {
PATH_ID_G1,
PATH_ID_PLUGIN,
PATH_ID_CSS1,
PATH_ID_CSS2,
PATH_ID_CSS4,
PATH_ID_CSS5,
PATH_ID_CSS6,
PATH_ID_CSS7,
PATH_ID_CSS8,
PATH_ID_CSS9,
PATH_ID_CSS11,
PATH_ID_CSS12,
PATH_ID_CSS13,
PATH_ID_CSS14,
PATH_ID_CSS15,
PATH_ID_CSS3,
PATH_ID_CSS17,
PATH_ID_CSS18,
PATH_ID_CSS19,
PATH_ID_CSS20,
PATH_ID_CSS21,
PATH_ID_CSS22,
PATH_ID_SCORES,
PATH_ID_CSS23,
PATH_ID_CSS24,
PATH_ID_CSS25,
PATH_ID_CSS26,
PATH_ID_CSS27,
PATH_ID_CSS28,
PATH_ID_CSS29,
PATH_ID_CSS30,
PATH_ID_CSS31,
PATH_ID_CSS32,
PATH_ID_CSS33,
PATH_ID_CSS34,
PATH_ID_CSS35,
PATH_ID_CSS36,
PATH_ID_CSS37,
PATH_ID_CSS38,
PATH_ID_CUSTOM1,
PATH_ID_CUSTOM2,
PATH_ID_CSS39,
PATH_ID_CSS40,
PATH_ID_CSS41,
PATH_ID_SIXFLAGS_MAGICMOUNTAIN,
PATH_ID_CSS42,
PATH_ID_CSS43,
PATH_ID_CSS44,
PATH_ID_CSS45,
PATH_ID_CSS46,
PATH_ID_CSS50,
PATH_ID_END
PATH_ID_G1,
PATH_ID_PLUGIN,
PATH_ID_CSS1,
PATH_ID_CSS2,
PATH_ID_CSS4,
PATH_ID_CSS5,
PATH_ID_CSS6,
PATH_ID_CSS7,
PATH_ID_CSS8,
PATH_ID_CSS9,
PATH_ID_CSS11,
PATH_ID_CSS12,
PATH_ID_CSS13,
PATH_ID_CSS14,
PATH_ID_CSS15,
PATH_ID_CSS3,
PATH_ID_CSS17,
PATH_ID_CSS18,
PATH_ID_CSS19,
PATH_ID_CSS20,
PATH_ID_CSS21,
PATH_ID_CSS22,
PATH_ID_SCORES,
PATH_ID_CSS23,
PATH_ID_CSS24,
PATH_ID_CSS25,
PATH_ID_CSS26,
PATH_ID_CSS27,
PATH_ID_CSS28,
PATH_ID_CSS29,
PATH_ID_CSS30,
PATH_ID_CSS31,
PATH_ID_CSS32,
PATH_ID_CSS33,
PATH_ID_CSS34,
PATH_ID_CSS35,
PATH_ID_CSS36,
PATH_ID_CSS37,
PATH_ID_CSS38,
PATH_ID_CUSTOM1,
PATH_ID_CUSTOM2,
PATH_ID_CSS39,
PATH_ID_CSS40,
PATH_ID_CSS41,
PATH_ID_SIXFLAGS_MAGICMOUNTAIN,
PATH_ID_CSS42,
PATH_ID_CSS43,
PATH_ID_CSS44,
PATH_ID_CSS45,
PATH_ID_CSS46,
PATH_ID_CSS50,
PATH_ID_END
};
enum {
FILE_EXTENSION_UNKNOWN,
FILE_EXTENSION_DAT,
FILE_EXTENSION_SC4,
FILE_EXTENSION_SV4,
FILE_EXTENSION_TD4,
FILE_EXTENSION_SC6,
FILE_EXTENSION_SV6,
FILE_EXTENSION_TD6,
FILE_EXTENSION_UNKNOWN,
FILE_EXTENSION_DAT,
FILE_EXTENSION_SC4,
FILE_EXTENSION_SV4,
FILE_EXTENSION_TD4,
FILE_EXTENSION_SC6,
FILE_EXTENSION_SV6,
FILE_EXTENSION_TD6,
};
#ifdef __cplusplus

View File

@ -435,7 +435,22 @@ void S6Exporter::Export()
_s6.next_weather_gloom = gClimateNextWeatherGloom;
_s6.current_rain_level = gClimateCurrentRainLevel;
_s6.next_rain_level = gClimateNextRainLevel;
memcpy(_s6.news_items, gNewsItems, sizeof(_s6.news_items));
// News items
for (size_t i = 0; i < RCT12_MAX_NEWS_ITEMS; i++)
{
const NewsItem * src = &gNewsItems[i];
rct12_news_item * dst = &_s6.news_items[i];
dst->Type = src->Type;
dst->Flags = src->Flags;
dst->Assoc = src->Assoc;
dst->Ticks = src->Ticks;
dst->MonthYear = src->MonthYear;
dst->Day = src->Day;
memcpy(dst->Text, src->Text, sizeof(dst->Text));
}
// pad_13CE730
// rct1_scenario_flags
_s6.wide_path_tile_loop_x = gWidePathTileLoopX;

View File

@ -352,7 +352,22 @@ void S6Importer::Import()
gClimateNextWeatherGloom = _s6.next_weather_gloom;
gClimateCurrentRainLevel = _s6.current_rain_level;
gClimateNextRainLevel = _s6.next_rain_level;
memcpy(gNewsItems, _s6.news_items, sizeof(_s6.news_items));
// News items
for (size_t i = 0; i < RCT12_MAX_NEWS_ITEMS; i++)
{
const rct12_news_item * src = &_s6.news_items[i];
NewsItem * dst = &gNewsItems[i];
dst->Type = src->Type;
dst->Flags = src->Flags;
dst->Assoc = src->Assoc;
dst->Ticks = src->Ticks;
dst->MonthYear = src->MonthYear;
dst->Day = src->Day;
memcpy(dst->Text, src->Text, sizeof(src->Text));
}
// pad_13CE730
// rct1_scenario_flags
gWidePathTileLoopX = _s6.wide_path_tile_loop_x;

View File

@ -21,6 +21,7 @@
#include "../game.h"
#include "../interface/viewport.h"
#include "../localisation/localisation.h"
#include "../management/news_item.h"
#include "../OpenRCT2.h"
#include "../rct2/hook.h"
#include "../scenario/scenario.h"

View File

@ -434,29 +434,29 @@ private:
}
// Load header
auto header = fs.ReadValue<rct_scenario_scores_header>();
for (uint32 i = 0; i < header.scenario_count; i++)
auto header = fs.ReadValue<rct_scores_header>();
for (uint32 i = 0; i < header.ScenarioCount; i++)
{
// Read legacy entry
auto scBasic = fs.ReadValue<rct_scenario_basic>();
auto scBasic = fs.ReadValue<rct_scores_entry>();
// Ignore non-completed scenarios
if (scBasic.flags & SCENARIO_FLAGS_COMPLETED)
if (scBasic.Flags & SCENARIO_FLAGS_COMPLETED)
{
bool notFound = true;
for (size_t j = 0; j < _highscores.size(); j++)
{
scenario_highscore_entry * highscore = _highscores[j];
if (String::Equals(scBasic.path, highscore->fileName, true))
if (String::Equals(scBasic.Path, highscore->fileName, true))
{
notFound = false;
// Check if legacy highscore is better
if (scBasic.company_value > highscore->company_value)
if (scBasic.CompanyValue > highscore->company_value)
{
SafeFree(highscore->name);
highscore->name = win1252_to_utf8_alloc(scBasic.completed_by, Util::CountOf(scBasic.completed_by));
highscore->company_value = scBasic.company_value;
highscore->name = win1252_to_utf8_alloc(scBasic.CompletedBy, Util::CountOf(scBasic.CompletedBy));
highscore->company_value = scBasic.CompanyValue;
highscore->timestamp = DATETIME64_MIN;
break;
}
@ -465,9 +465,9 @@ private:
if (notFound)
{
scenario_highscore_entry * highscore = InsertHighscore();
highscore->fileName = String::Duplicate(scBasic.path);
highscore->name = win1252_to_utf8_alloc(scBasic.completed_by, Util::CountOf(scBasic.completed_by));
highscore->company_value = scBasic.company_value;
highscore->fileName = String::Duplicate(scBasic.Path);
highscore->name = win1252_to_utf8_alloc(scBasic.CompletedBy, Util::CountOf(scBasic.CompletedBy));
highscore->company_value = scBasic.CompanyValue;
highscore->timestamp = DATETIME64_MIN;
}
}

View File

@ -19,7 +19,6 @@
#include "../common.h"
#include "../management/finance.h"
#include "../management/news_item.h"
#include "../management/research.h"
#include "../object.h"
#include "../platform/platform.h"
@ -66,18 +65,6 @@ typedef struct rct_s6_info {
} rct_s6_info;
assert_struct_size(rct_s6_info, 0x198);
/**
* Scenario scores file header.
* size: 0x10
*/
typedef struct rct_scenario_scores_header {
uint32 var_0;
uint32 var_4;
uint32 var_8;
uint32 scenario_count; // 0x0C
} rct_scenario_scores_header;
assert_struct_size(rct_scenario_scores_header, 16);
typedef enum scenario_source {
SCENARIO_SOURCE_RCT1,
SCENARIO_SOURCE_RCT1_AA,
@ -89,28 +76,6 @@ typedef enum scenario_source {
SCENARIO_SOURCE_OTHER
} scenario_source;
/**
* Scenario basic structure, mainly for scenario select
* size: 0x02B0
*/
typedef struct rct_scenario_basic {
char path[256]; // 0x0000
uint8 category; // 0x0100
uint8 pad_0101[0x1F];
sint8 objective_type; // 0x0120
sint8 objective_arg_1; // 0x0121
sint32 objective_arg_2; // 0x0122
sint16 objective_arg_3; // 0x0126
char name[64]; // 0x0128
char details[256]; // 0x0168
sint32 flags; // 0x0268
money32 company_value; // 0x026C
char completed_by[64]; // 0x0270
// uint8 source_game; // new in OpenRCT2
// sint16 source_index; // new in OpenRCT2
} rct_scenario_basic;
assert_struct_size(rct_scenario_basic, 0x02B0);
typedef struct rct_stex_entry {
rct_string_id scenario_name; // 0x00
rct_string_id park_name; // 0x02
@ -324,7 +289,7 @@ typedef struct rct_s6_data {
uint8 next_weather_gloom;
uint8 current_rain_level;
uint8 next_rain_level;
rct_news_item news_items[MAX_NEWS_ITEMS];
rct12_news_item news_items[RCT12_MAX_NEWS_ITEMS];
uint8 pad_13CE730[64];
uint32 rct1_scenario_flags;
uint16 wide_path_tile_loop_x;

View File

@ -33,6 +33,7 @@ extern "C"
#include "../interface/viewport.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../management/news_item.h"
#include "../peep/staff.h"
#include "../world/climate.h"
#include "../world/scenery.h"

View File

@ -32,6 +32,7 @@ extern "C"
#include "../game.h"
#include "../interface/viewport.h"
#include "../interface/window.h"
#include "../management/news_item.h"
#include "../world/scenery.h"
}

View File

@ -164,7 +164,7 @@ void window_game_bottom_toolbar_open()
*/
static void window_game_bottom_toolbar_mouseup(rct_window *w, sint32 widgetIndex)
{
rct_news_item *newsItem;
NewsItem *newsItem;
switch (widgetIndex) {
case WIDX_LEFT_OUTSET:
@ -183,7 +183,7 @@ static void window_game_bottom_toolbar_mouseup(rct_window *w, sint32 widgetIndex
break;
case WIDX_NEWS_SUBJECT:
newsItem = news_item_get(0);
news_item_open_subject(newsItem->type, newsItem->assoc);
news_item_open_subject(newsItem->Type, newsItem->Assoc);
break;
case WIDX_NEWS_LOCATE:
if (news_item_is_queue_empty())
@ -192,9 +192,9 @@ static void window_game_bottom_toolbar_mouseup(rct_window *w, sint32 widgetIndex
{
newsItem = news_item_get(0);
sint32 x, y, z;
sint32 subject = newsItem->assoc;
sint32 subject = newsItem->Assoc;
news_item_get_subject_location(newsItem->type, subject, &x, &y, &z);
news_item_get_subject_location(newsItem->Type, subject, &x, &y, &z);
if (x == SPRITE_LOCATION_NULL)
break;
@ -240,7 +240,7 @@ static void window_game_bottom_toolbar_tooltip(rct_window* w, sint32 widgetIndex
static void window_game_bottom_toolbar_invalidate(rct_window *w)
{
sint32 x;
rct_news_item *newsItem;
NewsItem *newsItem;
colour_scheme_update(w);
@ -285,18 +285,18 @@ static void window_game_bottom_toolbar_invalidate(rct_window *w)
// Find out if the news item is no longer valid
sint32 y, z;
sint32 subject = newsItem->assoc;
news_item_get_subject_location(newsItem->type, subject, &x, &y, &z);
sint32 subject = newsItem->Assoc;
news_item_get_subject_location(newsItem->Type, subject, &x, &y, &z);
if (x == SPRITE_LOCATION_NULL)
w->disabled_widgets |= (1 << WIDX_NEWS_LOCATE);
if (!(news_type_properties[newsItem->type] & NEWS_TYPE_HAS_SUBJECT)) {
if (!(news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_SUBJECT)) {
w->disabled_widgets |= (1 << WIDX_NEWS_SUBJECT);
window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].type = WWT_EMPTY;
}
if (newsItem->flags & 1) {
if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON) {
w->disabled_widgets |= (1 << WIDX_NEWS_SUBJECT);
w->disabled_widgets |= (1 << WIDX_NEWS_LOCATE);
}
@ -508,7 +508,7 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi,
static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rct_window *w)
{
sint32 x, y, width;
rct_news_item *newsItem;
NewsItem *newsItem;
rct_widget *middleOutsetWidget;
middleOutsetWidget = &window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET];
@ -526,21 +526,21 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc
);
// Text
utf8 *newsItemText = newsItem->text;
utf8 *newsItemText = newsItem->Text;
x = w->x + (middleOutsetWidget->left + middleOutsetWidget->right) / 2;
y = w->y + middleOutsetWidget->top + 11;
width = middleOutsetWidget->right - middleOutsetWidget->left - 62;
gfx_draw_string_centred_wrapped_partial(dpi, x, y, width, COLOUR_BRIGHT_GREEN, STR_BOTTOM_TOOLBAR_NEWS_TEXT, &newsItemText, newsItem->ticks);
gfx_draw_string_centred_wrapped_partial(dpi, x, y, width, COLOUR_BRIGHT_GREEN, STR_BOTTOM_TOOLBAR_NEWS_TEXT, &newsItemText, newsItem->Ticks);
x = w->x + window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].left;
y = w->y + window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].top;
switch (newsItem->type) {
switch (newsItem->Type) {
case NEWS_ITEM_RIDE:
gfx_draw_sprite(dpi, SPR_RIDE, x, y, 0);
break;
case NEWS_ITEM_PEEP_ON_RIDE:
case NEWS_ITEM_PEEP:
if (newsItem->flags & 1)
if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON)
break;
rct_drawpixelinfo cliped_dpi;
@ -548,7 +548,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc
break;
}
rct_peep* peep = GET_PEEP(newsItem->assoc);
rct_peep* peep = GET_PEEP(newsItem->Assoc);
sint32 clip_x = 10, clip_y = 19;
if (peep->type == PEEP_TYPE_STAFF){
@ -589,7 +589,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc
gfx_draw_sprite(dpi, SPR_FINANCE, x, y, 0);
break;
case NEWS_ITEM_RESEARCH:
gfx_draw_sprite(dpi, (newsItem->assoc < 0x10000 ? SPR_NEW_SCENERY : SPR_NEW_RIDE), x, y, 0);
gfx_draw_sprite(dpi, (newsItem->Assoc < 0x10000 ? SPR_NEW_SCENERY : SPR_NEW_RIDE), x, y, 0);
break;
case NEWS_ITEM_PEEPS:
gfx_draw_sprite(dpi, SPR_GUESTS, x, y, 0);

View File

@ -156,15 +156,15 @@ static void window_news_update(rct_window *w)
return;
if (j == 0) {
rct_news_item * const newsItem = news_item_get(i);
if (newsItem->flags & 1)
NewsItem * const newsItem = news_item_get(i);
if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON)
return;
if (w->news.var_482 == 1) {
news_item_open_subject(newsItem->type, newsItem->assoc);
news_item_open_subject(newsItem->Type, newsItem->Assoc);
return;
}
else if (w->news.var_482 > 1) {
news_item_get_subject_location(newsItem->type, newsItem->assoc, &x, &y, &z);
news_item_get_subject_location(newsItem->Type, newsItem->Assoc, &x, &y, &z);
if (x != SPRITE_LOCATION_NULL)
if ((w = window_get_main()) != NULL)
window_scroll_to_location(w, x, y, z);
@ -206,8 +206,8 @@ static void window_news_scrollmousedown(rct_window *w, sint32 scrollIndex, sint3
break;
if (y < 42) {
rct_news_item * const newsItem = news_item_get(i);
if (newsItem->flags & 1) {
NewsItem * const newsItem = news_item_get(i);
if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON) {
buttonIndex = 0;
break;
} else if (y < 14) {
@ -220,12 +220,12 @@ static void window_news_scrollmousedown(rct_window *w, sint32 scrollIndex, sint3
buttonIndex = 0;
break;
} else if (x < 351) {
if (news_type_properties[newsItem->type] & NEWS_TYPE_HAS_SUBJECT) {
if (news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_SUBJECT) {
buttonIndex = 1;
break;
}
} else if (x < 376) {
if (news_type_properties[newsItem->type] & NEWS_TYPE_HAS_LOCATION) {
if (news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_LOCATION) {
buttonIndex = 2;
break;
}
@ -276,7 +276,7 @@ static void window_news_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint3
y = 0;
for (i = 11; i < 61; i++) {
rct_news_item * const newsItem = news_item_get(i);
NewsItem * const newsItem = news_item_get(i);
if (news_item_is_empty(i))
break;
if (y >= dpi->y + dpi->height)
@ -290,20 +290,16 @@ static void window_news_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint3
gfx_fill_rect_inset(dpi, -1, y, 383, y + 41, w->colours[1], (INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_GREY));
// Date text
set_format_arg(0, rct_string_id, DateDayNames[newsItem->day - 1]);
set_format_arg(2, rct_string_id, DateGameMonthNames[(newsItem->month_year % 8)]);
set_format_arg(0, rct_string_id, DateDayNames[newsItem->Day - 1]);
set_format_arg(2, rct_string_id, DateGameMonthNames[(newsItem->MonthYear % 8)]);
gfx_draw_string_left(dpi, STR_NEWS_DATE_FORMAT, gCommonFormatArgs, COLOUR_WHITE, 4, y);
// Item text
utf8 buffer[400];
utf8 *ch = buffer;
ch = utf8_write_codepoint(ch, FORMAT_SMALLFONT);
memcpy(ch, newsItem->text, 256);
ch = buffer;
gfx_draw_string_left_wrapped(dpi, &ch, 2, y + 10, 325, STR_STRING, COLOUR_BRIGHT_GREEN);
utf8 *text = newsItem->Text;
gfx_draw_string_left_wrapped(dpi, &text, 2, y + 10, 325, STR_BOTTOM_TOOLBAR_NEWS_TEXT, COLOUR_BRIGHT_GREEN);
// Subject button
if ((news_type_properties[newsItem->type] & NEWS_TYPE_HAS_SUBJECT) && !(newsItem->flags & 1)) {
if ((news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_SUBJECT) && !(newsItem->Flags & NEWS_FLAG_HAS_BUTTON)) {
x = 328;
yy = y + 14;
@ -316,7 +312,7 @@ static void window_news_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint3
}
gfx_fill_rect_inset(dpi, x, yy, x + 23, yy + 23, w->colours[2], press);
switch (newsItem->type) {
switch (newsItem->Type) {
case NEWS_ITEM_RIDE:
gfx_draw_sprite(dpi, SPR_RIDE, x, yy, 0);
break;
@ -328,7 +324,7 @@ static void window_news_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint3
break;
}
rct_peep* peep = GET_PEEP(newsItem->assoc);
rct_peep* peep = GET_PEEP(newsItem->Assoc);
sint32 clip_x = 10, clip_y = 19;
// If normal peep set sprite to normal (no food)
@ -352,7 +348,7 @@ static void window_news_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint3
gfx_draw_sprite(dpi, SPR_FINANCE, x, yy, 0);
break;
case NEWS_ITEM_RESEARCH:
gfx_draw_sprite(dpi, newsItem->assoc < 0x10000 ? SPR_NEW_SCENERY : SPR_NEW_RIDE, x, yy, 0);
gfx_draw_sprite(dpi, newsItem->Assoc < 0x10000 ? SPR_NEW_SCENERY : SPR_NEW_RIDE, x, yy, 0);
break;
case NEWS_ITEM_PEEPS:
gfx_draw_sprite(dpi, SPR_GUESTS, x, yy, 0);
@ -367,7 +363,7 @@ static void window_news_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint3
}
// Location button
if ((news_type_properties[newsItem->type] & NEWS_TYPE_HAS_LOCATION) && !(newsItem->flags & 1)) {
if ((news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_LOCATION) && !(newsItem->Flags & NEWS_FLAG_HAS_BUTTON)) {
x = 352;
yy = y + 14;