mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 20:13:07 +01:00
Move scores.dat structs to rct2.h
This commit is contained in:
@@ -363,9 +363,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) {
|
||||
|
||||
@@ -29,6 +29,44 @@ typedef struct rct2_install_info {
|
||||
uint32 activeExpansionPacks; //0xB10
|
||||
} rct2_install_info;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
enum {
|
||||
// Although this is labeled a flag it actually means when
|
||||
// zero the screen is in playing mode.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,18 +66,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 +77,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
|
||||
|
||||
Reference in New Issue
Block a user