mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 07:43:01 +01:00
try to fix to scenario complete issues
This commit is contained in:
@@ -2769,7 +2769,7 @@ STR_2762 :Pay For Rides
|
||||
STR_2763 :???
|
||||
STR_2764 :Happy Guests
|
||||
STR_2765 :Large Tram
|
||||
STR_2766 :???
|
||||
STR_2766 :Win scenario
|
||||
STR_2767 :Freeze Climate
|
||||
STR_2768 :Unfreeze Climate
|
||||
STR_2769 :Open Park
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
#include "world/park.h"
|
||||
#include "world/sprite.h"
|
||||
|
||||
static char _scenarioPath[MAX_PATH];
|
||||
static const char *_scenarioFileName;
|
||||
|
||||
static int scenario_create_ducks();
|
||||
|
||||
/**
|
||||
@@ -210,6 +213,9 @@ int scenario_load_and_play_from_path(const char *path)
|
||||
if (!scenario_load(path))
|
||||
return 0;
|
||||
|
||||
strcpy(_scenarioPath, path);
|
||||
_scenarioFileName = path_get_filename(_scenarioPath);
|
||||
|
||||
log_verbose("starting scenario, %s", path);
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_PLAYING;
|
||||
@@ -351,18 +357,20 @@ void scenario_end()
|
||||
window_park_objective_open();
|
||||
}
|
||||
|
||||
/*
|
||||
* rct2: 0x0066A752
|
||||
**/
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066A752
|
||||
**/
|
||||
void scenario_failure()
|
||||
{
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) = 0x80000001;
|
||||
scenario_end();
|
||||
}
|
||||
|
||||
/*
|
||||
* rct2: 0x0066A75E
|
||||
**/
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066A75E
|
||||
*/
|
||||
void scenario_success()
|
||||
{
|
||||
int i;
|
||||
@@ -373,18 +381,19 @@ void scenario_success()
|
||||
peep_applause();
|
||||
|
||||
for (i = 0; i < gScenarioListCount; i++) {
|
||||
char *cur_scenario_name = RCT2_ADDRESS(0x135936C, char);
|
||||
scenario = &gScenarioList[i];
|
||||
|
||||
if (0 == strncmp(cur_scenario_name, scenario->path, 256)){
|
||||
if (scenario->flags & SCENARIO_FLAGS_COMPLETED && scenario->company_value < current_val)
|
||||
break; // not a new high score -> no glory
|
||||
if (strequals(scenario->path, _scenarioFileName, 256, true)) {
|
||||
// Check if record company value has been broken
|
||||
if ((scenario->flags & SCENARIO_FLAGS_COMPLETED) && scenario->company_value >= current_val)
|
||||
break;
|
||||
|
||||
// Allow name entry
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) |= PARK_FLAGS_SCENARIO_COMPLETE_NAME_INPUT;
|
||||
scenario->company_value = current_val;
|
||||
scenario->flags |= SCENARIO_FLAGS_COMPLETED;
|
||||
scenario->completed_by[0] = 0;
|
||||
RCT2_GLOBAL(0x013587C0, uint32) = current_val; // value used in window for score?
|
||||
RCT2_GLOBAL(0x013587C0, uint32) = current_val;
|
||||
scenario_scores_save();
|
||||
break;
|
||||
}
|
||||
@@ -392,6 +401,33 @@ void scenario_success()
|
||||
scenario_end();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006695E8
|
||||
*/
|
||||
void scenario_success_submit_name(const char *name)
|
||||
{
|
||||
int i;
|
||||
rct_scenario_basic* scenario;
|
||||
uint32 scenarioWinCompanyValue;
|
||||
|
||||
for (i = 0; i < gScenarioListCount; i++) {
|
||||
scenario = &gScenarioList[i];
|
||||
|
||||
if (strequals(scenario->path, _scenarioFileName, 256, true)) {
|
||||
scenarioWinCompanyValue = RCT2_GLOBAL(0x013587C0, uint32);
|
||||
if (scenario->company_value == scenarioWinCompanyValue) {
|
||||
strncpy(scenario->completed_by, name, 64);
|
||||
strncpy((char*)0x013587D8, name, 32);
|
||||
scenario_scores_save();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) &= ~PARK_FLAGS_SCENARIO_COMPLETE_NAME_INPUT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are 10 rollercoasters of different subtype with
|
||||
* excitement >= 600 .
|
||||
@@ -1061,27 +1097,3 @@ int scenario_save(char *path, int flags)
|
||||
RCT2_GLOBAL(0x009DEA66, uint16) = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void scenario_success_submit_name(const char *name)
|
||||
{
|
||||
int i;
|
||||
rct_scenario_basic* scenario;
|
||||
uint32 scenarioWinCompanyValue;
|
||||
|
||||
for (i = 0; i < gScenarioListCount; i++) {
|
||||
char *cur_scenario_name = RCT2_ADDRESS(0x135936C, char);
|
||||
scenario = &gScenarioList[i];
|
||||
|
||||
if (strncmp(cur_scenario_name, scenario->path, 256) == 0) {
|
||||
scenarioWinCompanyValue = RCT2_GLOBAL(0x013587C0, uint32);
|
||||
if (scenario->company_value == scenarioWinCompanyValue) {
|
||||
strncpy(scenario->completed_by, name, 64);
|
||||
strncpy((char*)0x013587D8, name, 32);
|
||||
scenario_scores_save();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) &= ~PARK_FLAGS_SCENARIO_COMPLETE_NAME_INPUT;
|
||||
}
|
||||
|
||||
@@ -407,6 +407,8 @@ void scenario_update();
|
||||
unsigned int scenario_rand();
|
||||
int scenario_prepare_for_save();
|
||||
int scenario_save(char *path, int flags);
|
||||
void scenario_failure();
|
||||
void scenario_success();
|
||||
void scenario_success_submit_name(const char *name);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -41,6 +41,21 @@ int mph_to_kmph(int mph)
|
||||
return (mph * 1648) / 1024;
|
||||
}
|
||||
|
||||
const char *path_get_filename(const char *path)
|
||||
{
|
||||
const char *result, *ch;
|
||||
|
||||
result = path;
|
||||
for (ch = path; *ch != 0; ch++) {
|
||||
if (*ch == '/' || *ch == '\\') {
|
||||
if (*(ch + 1) != 0)
|
||||
result = ch + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void path_set_extension(char *path, const char *extension)
|
||||
{
|
||||
char *ch = path;
|
||||
@@ -77,6 +92,13 @@ int bitscanforward(int source)
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool strequals(const char *a, const char *b, int length, bool caseInsensitive)
|
||||
{
|
||||
return caseInsensitive ?
|
||||
_strnicmp(a, b, length) == 0 :
|
||||
strncmp(a, b, length) == 0;
|
||||
}
|
||||
|
||||
/* case insensitve compare */
|
||||
int strcicmp(char const *a, char const *b)
|
||||
{
|
||||
|
||||
@@ -27,10 +27,12 @@ int squaredmetres_to_squaredfeet(int squaredMetres);
|
||||
int metres_to_feet(int metres);
|
||||
int mph_to_kmph(int mph);
|
||||
|
||||
const char *path_get_filename(const char *path);
|
||||
void path_set_extension(char *path, const char *extension);
|
||||
long fsize(FILE *fp);
|
||||
|
||||
int bitscanforward(int source);
|
||||
bool strequals(const char *a, const char *b, int length, bool caseInsensitive);
|
||||
int strcicmp(char const *a, char const *b);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -65,7 +65,8 @@ enum WINDOW_CHEATS_WIDGET_IDX {
|
||||
WIDX_MOWED_GRASS,
|
||||
WIDX_WATER_PLANTS,
|
||||
WIDX_FIX_VANDALISM,
|
||||
WIDX_REMOVE_LITTER
|
||||
WIDX_REMOVE_LITTER,
|
||||
WIDX_WIN_SCENARIO
|
||||
};
|
||||
|
||||
#pragma region MEASUREMENTS
|
||||
@@ -134,6 +135,8 @@ static rct_widget window_cheats_misc_widgets[] = {
|
||||
{ WWT_CLOSEBOX, 1, XPL(0), WPL(0), YPL(6), HPL(6), 2754, STR_NONE}, // Water plants
|
||||
{ WWT_CLOSEBOX, 1, XPL(1), WPL(1), YPL(6), HPL(6), 2755, STR_NONE}, // Fix vandalism
|
||||
{ WWT_CLOSEBOX, 1, XPL(1), WPL(1), YPL(7), HPL(7), 2756, STR_NONE}, // Remove litter
|
||||
|
||||
{ WWT_CLOSEBOX, 1, XPL(1), WPL(1), YPL(0), HPL(0), 2766, STR_NONE}, // Win scenario
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
@@ -147,8 +150,8 @@ static void window_cheats_emptysub() { }
|
||||
static void window_cheats_money_mouseup();
|
||||
static void window_cheats_guests_mouseup();
|
||||
static void window_cheats_misc_mouseup();
|
||||
void window_cheats_misc_tool_update();
|
||||
void window_cheats_misc_tool_down();
|
||||
static void window_cheats_misc_tool_update();
|
||||
static void window_cheats_misc_tool_down();
|
||||
static void window_cheats_update(rct_window *w);
|
||||
static void window_cheats_invalidate();
|
||||
static void window_cheats_paint();
|
||||
@@ -256,7 +259,7 @@ static void* window_cheats_page_events[] = {
|
||||
static uint32 window_cheats_page_enabled_widgets[] = {
|
||||
(1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | (1 << WIDX_TAB_3) | (1 << WIDX_HIGH_MONEY) | (1 << WIDX_PARK_ENTRANCE_FEE),
|
||||
(1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | (1 << WIDX_TAB_3) | (1 << WIDX_HAPPY_GUESTS) | (1 << WIDX_TRAM_GUESTS),
|
||||
(1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | (1 << WIDX_TAB_3) | (1 << WIDX_FREEZE_CLIMATE) | (1 << WIDX_OPEN_CLOSE_PARK) | (1 << WIDX_DECREASE_GAME_SPEED) | (1 << WIDX_INCREASE_GAME_SPEED) | (1 << WIDX_ZERO_CLEARANCE) | (1 << WIDX_WEATHER_SUN) | (1 << WIDX_WEATHER_THUNDER) | (1 << WIDX_CLEAR_GRASS) | (1 << WIDX_MOWED_GRASS) | (1 << WIDX_WATER_PLANTS) | (1 << WIDX_FIX_VANDALISM) | (1 << WIDX_REMOVE_LITTER)
|
||||
(1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | (1 << WIDX_TAB_3) | (1 << WIDX_FREEZE_CLIMATE) | (1 << WIDX_OPEN_CLOSE_PARK) | (1 << WIDX_DECREASE_GAME_SPEED) | (1 << WIDX_INCREASE_GAME_SPEED) | (1 << WIDX_ZERO_CLEARANCE) | (1 << WIDX_WEATHER_SUN) | (1 << WIDX_WEATHER_THUNDER) | (1 << WIDX_CLEAR_GRASS) | (1 << WIDX_MOWED_GRASS) | (1 << WIDX_WATER_PLANTS) | (1 << WIDX_FIX_VANDALISM) | (1 << WIDX_REMOVE_LITTER) | (1 << WIDX_WIN_SCENARIO)
|
||||
};
|
||||
|
||||
static void window_cheats_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w);
|
||||
@@ -513,6 +516,9 @@ static void window_cheats_misc_mouseup()
|
||||
case WIDX_REMOVE_LITTER:
|
||||
cheat_remove_litter();
|
||||
break;
|
||||
case WIDX_WIN_SCENARIO:
|
||||
scenario_success();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,7 +633,8 @@ static void window_cheats_set_page(rct_window *w, int page)
|
||||
window_invalidate(w);
|
||||
}
|
||||
|
||||
void window_cheats_misc_tool_update(){
|
||||
static void window_cheats_misc_tool_update()
|
||||
{
|
||||
short widgetIndex;
|
||||
rct_window* w;
|
||||
short x, y;
|
||||
@@ -656,7 +663,8 @@ void window_cheats_misc_tool_update(){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_SPRITE, sint32) = -1;
|
||||
}
|
||||
|
||||
void window_cheats_misc_tool_down(){
|
||||
static void window_cheats_misc_tool_down()
|
||||
{
|
||||
short widgetIndex;
|
||||
rct_window* w;
|
||||
short x, y;
|
||||
|
||||
Reference in New Issue
Block a user