diff --git a/src/editor.c b/src/editor.c index 3e1208b364..e46b64fe43 100644 --- a/src/editor.c +++ b/src/editor.c @@ -74,7 +74,7 @@ void editor_load() window_guest_list_init_vars_b(); window_staff_list_init_vars(); gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; - RCT2_GLOBAL(0x0141F570, uint8) = 0; + gS6Info->editor_step = EDITOR_STEP_OBJECT_SELECTION; gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; window_new_ride_init_vars(); RCT2_GLOBAL(0x0141F571, uint8) = 4; @@ -108,7 +108,7 @@ void editor_convert_save_to_scenario_callback(int result) return; } - rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; + rct_s6_info *s6Info = gS6Info; if (gParkFlags & PARK_FLAGS_NO_MONEY) gParkFlags |= PARK_FLAGS_NO_MONEY_SCENARIO; @@ -169,7 +169,7 @@ void trackdesigner_load() date_reset(); window_guest_list_init_vars_b(); window_staff_list_init_vars(); - RCT2_GLOBAL(0x0141F570, uint8) = 0; + gS6Info->editor_step = EDITOR_STEP_OBJECT_SELECTION; window_new_ride_init_vars(); viewport_init_all(); news_item_init_queue(); @@ -207,7 +207,7 @@ void trackmanager_load() date_reset(); window_guest_list_init_vars_b(); window_staff_list_init_vars(); - RCT2_GLOBAL(0x0141F570, uint8) = 0; + gS6Info->editor_step = EDITOR_STEP_OBJECT_SELECTION; window_new_ride_init_vars(); viewport_init_all(); news_item_init_queue(); @@ -260,7 +260,7 @@ static int editor_load_landscape_from_sv4(const char *path) rct1_load_saved_game(path); editor_clear_map_for_editing(); - g_editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; + gS6Info->editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; gScreenAge = 0; gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; viewport_init_all(); @@ -274,7 +274,7 @@ static int editor_load_landscape_from_sc4(const char *path) rct1_load_scenario(path); editor_clear_map_for_editing(); - g_editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; + gS6Info->editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; gScreenAge = 0; gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; viewport_init_all(); @@ -292,7 +292,7 @@ static int editor_read_s6(const char *path) int i, j; SDL_RWops* rw; rct_s6_header *s6Header = (rct_s6_header*)0x009E34E4; - rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; + rct_s6_info *s6Info = gS6Info; log_verbose("loading landscape, %s", path); @@ -396,7 +396,6 @@ static int editor_read_s6(const char *path) static void editor_clear_map_for_editing() { rct_s6_header *s6Header = (rct_s6_header*)0x009E34E4; - rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; map_remove_all_rides(); @@ -475,8 +474,8 @@ static void editor_clear_map_for_editing() object_unload_chunk((rct_object_entry*)&object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].entries[0]); reset_loaded_objects(); - format_string(s6Info->details, STR_NO_DETAILS_YET, NULL); - s6Info->name[0] = 0; + format_string(gS6Info->details, STR_NO_DETAILS_YET, NULL); + gS6Info->name[0] = 0; } news_item_init_queue(); @@ -491,7 +490,7 @@ void editor_open_windows_for_current_step() if (!(gScreenFlags & SCREEN_FLAGS_EDITOR)) return; - switch (g_editor_step) { + switch (gS6Info->editor_step) { case EDITOR_STEP_OBJECT_SELECTION: if (window_find_by_class(WC_EDITOR_OBJECT_SELECTION)) return; diff --git a/src/editor.h b/src/editor.h index 1da56dad9a..c7b479812a 100644 --- a/src/editor.h +++ b/src/editor.h @@ -31,8 +31,6 @@ typedef enum { EDITOR_STEP_TRACK_DESIGNS_MANAGER // 7 } RCT2_EDITOR_STEP; -#define g_editor_step RCT2_GLOBAL(0x0141F570, uint8) - void editor_load(); void editor_convert_save_to_scenario(); void trackdesigner_load(); diff --git a/src/interface/keyboard_shortcut.c b/src/interface/keyboard_shortcut.c index f5dcb6d334..a9e2f8fa7c 100644 --- a/src/interface/keyboard_shortcut.c +++ b/src/interface/keyboard_shortcut.c @@ -17,6 +17,7 @@ #include "../addresses.h" #include "../config.h" #include "../game.h" +#include "../editor.h" #include "../interface/chat.h" #include "../input.h" #include "../localisation/localisation.h" @@ -131,7 +132,7 @@ static void shortcut_close_all_floating_windows() { if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)) window_close_all(); - else if (RCT2_GLOBAL(0x0141F570, uint8) == 1) + else if (gS6Info->editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) window_close_top(); } @@ -163,7 +164,7 @@ static void shortcut_zoom_view_out() { rct_window *window; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info->editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) { window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { @@ -178,7 +179,7 @@ static void shortcut_zoom_view_in() { rct_window *window; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info->editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) { window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { @@ -318,7 +319,7 @@ static void shortcut_adjust_land() { rct_window *window; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info->editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { @@ -333,7 +334,7 @@ static void shortcut_adjust_water() { rct_window *window; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info->editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { @@ -348,7 +349,7 @@ static void shortcut_build_scenery() { rct_window *window; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info->editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { @@ -363,7 +364,7 @@ static void shortcut_build_paths() { rct_window *window; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info->editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { @@ -466,7 +467,7 @@ static void shortcut_show_recent_messages() static void shortcut_show_map() { - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || RCT2_GLOBAL(0x0141F570, uint8) == 1) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info->editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) window_map_open(); } @@ -517,8 +518,7 @@ static void shortcut_quick_save_game() save_game(); } else if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) { - rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; - window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, s6Info->name); + window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, gS6Info->name); } } diff --git a/src/interface/viewport_interaction.c b/src/interface/viewport_interaction.c index e52c8d4e38..f4e248e391 100644 --- a/src/interface/viewport_interaction.c +++ b/src/interface/viewport_interaction.c @@ -44,7 +44,6 @@ static rct_peep *viewport_interaction_get_closest_peep(int x, int y, int maxDist */ int viewport_interaction_get_item_left(int x, int y, viewport_interaction_info *info) { - rct_s6_info *s6Info = (rct_s6_info*)0x00141F570; rct_map_element *mapElement; rct_sprite *sprite; rct_vehicle *vehicle; @@ -54,7 +53,7 @@ int viewport_interaction_get_item_left(int x, int y, viewport_interaction_info * return info->type = VIEWPORT_INTERACTION_ITEM_NONE; // - if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && s6Info->editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) + if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info->editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) return info->type = VIEWPORT_INTERACTION_ITEM_NONE; rct_xy16 mapCoord = { 0 }; @@ -164,7 +163,6 @@ int viewport_interaction_left_click(int x, int y) */ int viewport_interaction_get_item_right(int x, int y, viewport_interaction_info *info) { - rct_s6_info *s6Info = (rct_s6_info*)0x00141F570; rct_map_element *mapElement; rct_sprite *sprite; rct_scenery_entry *sceneryEntry; @@ -177,7 +175,7 @@ int viewport_interaction_get_item_right(int x, int y, viewport_interaction_info return info->type = VIEWPORT_INTERACTION_ITEM_NONE; // - if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && s6Info->editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) + if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info->editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) return info->type = VIEWPORT_INTERACTION_ITEM_NONE; rct_xy16 mapCoord = { 0 }; diff --git a/src/interface/window.c b/src/interface/window.c index 0859c421f4..78a719ca94 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -16,18 +16,19 @@ #include "../addresses.h" #include "../audio/audio.h" -#include "../game.h" +#include "../cursors.h" #include "../drawing/drawing.h" +#include "../editor.h" +#include "../game.h" #include "../input.h" +#include "../localisation/localisation.h" +#include "../localisation/string_ids.h" #include "../platform/platform.h" #include "../world/map.h" #include "../world/sprite.h" +#include "viewport.h" #include "widget.h" #include "window.h" -#include "viewport.h" -#include "../localisation/string_ids.h" -#include "../localisation/localisation.h" -#include "../cursors.h" #define RCT2_FIRST_WINDOW (g_window_list) #define RCT2_LAST_WINDOW (gWindowNextSlot - 1) @@ -757,7 +758,7 @@ void window_close_top() window_close_by_class(WC_DROPDOWN); if (gScreenFlags & 2) - if (RCT2_GLOBAL(0x0141F570, uint8) != 1) + if (gS6Info->editor_step != EDITOR_STEP_LANDSCAPE_EDITOR) return; for (w = RCT2_NEW_WINDOW - 1; w >= g_window_list; w--) { diff --git a/src/rct1/S4Importer.cpp b/src/rct1/S4Importer.cpp index 8affc62f61..a232760511 100644 --- a/src/rct1/S4Importer.cpp +++ b/src/rct1/S4Importer.cpp @@ -28,6 +28,7 @@ extern "C" { #include "../audio/audio.h" #include "../cheats.h" + #include "../editor.h" #include "../game.h" #include "../interface/window.h" #include "../localisation/date.h" @@ -123,7 +124,7 @@ void S4Importer::Initialise() date_reset(); window_guest_list_init_vars_b(); window_staff_list_init_vars(); - RCT2_GLOBAL(0x0141F570, uint8) = 0; + gS6Info->editor_step = EDITOR_STEP_OBJECT_SELECTION; gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; window_new_ride_init_vars(); RCT2_GLOBAL(0x0141F571, uint8) = 4; @@ -1022,7 +1023,7 @@ void S4Importer::ImportClimate() void S4Importer::ImportScenarioNameDetails() { - rct_s6_info * s6Info = (rct_s6_info*)0x0141F570; + rct_s6_info * s6Info = gS6Info; String::Set(s6Info->name, sizeof(s6Info->name), _s4.scenario_name); String::Set(s6Info->details, sizeof(s6Info->details), ""); diff --git a/src/rct2/S6Exporter.cpp b/src/rct2/S6Exporter.cpp index 6eeef4acae..591642f85c 100644 --- a/src/rct2/S6Exporter.cpp +++ b/src/rct2/S6Exporter.cpp @@ -226,7 +226,7 @@ void S6Exporter::Save(SDL_RWops * rw, bool isScenario) void S6Exporter::Export() { - _s6.info = *(RCT2_ADDRESS(0x0141F570, rct_s6_info)); + _s6.info = *gS6Info; for (int i = 0; i < 721; i++) { diff --git a/src/rct2/S6Importer.cpp b/src/rct2/S6Importer.cpp index 5a7b1264d0..976b8626f7 100644 --- a/src/rct2/S6Importer.cpp +++ b/src/rct2/S6Importer.cpp @@ -173,7 +173,7 @@ void S6Importer::LoadScenario(SDL_RWops *rw) void S6Importer::Import() { RCT2_GLOBAL(0x009E34E4, rct_s6_header) = _s6.header; - RCT2_GLOBAL(0x0141F570, rct_s6_info) = _s6.info; + *gS6Info = _s6.info; gDateMonthsElapsed = _s6.elapsed_months; gDateMonthTicks = _s6.current_day; diff --git a/src/ride/ride.c b/src/ride/ride.c index 321663338e..e9de3fbbcd 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -1889,13 +1889,12 @@ int sub_6CC3FB(int rideIndex) */ void ride_update_all() { - rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; rct_ride *ride; int i; // Remove all rides if scenario editor if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) { - if (s6Info->editor_step <= EDITOR_STEP_INVENTIONS_LIST_SET_UP) + if (gS6Info->editor_step <= EDITOR_STEP_INVENTIONS_LIST_SET_UP) FOR_ALL_RIDES(i, ride) ride->type = RIDE_TYPE_NULL; return; diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 135924fa36..821ee03720 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -19,6 +19,7 @@ #include "../audio/audio.h" #include "../audio/mixer.h" #include "../config.h" +#include "../editor.h" #include "../hook.h" #include "../interface/viewport.h" #include "../localisation/localisation.h" @@ -273,7 +274,7 @@ void vehicle_invalidate(rct_vehicle *vehicle) */ void vehicle_update_sound_params(rct_vehicle* vehicle) { - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && (!(gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) || RCT2_GLOBAL(0x0141F570, uint8) == 6)) { + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && (!(gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) || gS6Info->editor_step == EDITOR_STEP_ROLLERCOASTER_DESIGNER)) { if (vehicle->sound1_id != (uint8)-1 || vehicle->sound2_id != (uint8)-1) { if (vehicle->sprite_left != (sint16)0x8000) { sint16 x = RCT2_GLOBAL(0x00F438A4, rct_viewport*)->view_x; @@ -666,7 +667,7 @@ void vehicle_update_all() if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) return; - if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && RCT2_GLOBAL(0x0141F570, uint8) != 6) + if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info->editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) return; diff --git a/src/scenario.c b/src/scenario.c index 3a40ca6f9b..2130abe993 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -57,6 +57,7 @@ const rct_string_id ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT] = { static char _scenarioPath[MAX_PATH]; const char *_scenarioFileName = ""; +rct_s6_info *gS6Info = (rct_s6_info*)0x0141F570; char *gScenarioName = RCT2_ADDRESS(RCT2_ADDRESS_SCENARIO_NAME, char); char *gScenarioDetails = RCT2_ADDRESS(RCT2_ADDRESS_SCENARIO_DETAILS, char); char *gScenarioCompletedBy = RCT2_ADDRESS(RCT2_ADDRESS_SCENARIO_COMPLETED_BY, char); @@ -127,7 +128,6 @@ int scenario_load_and_play_from_path(const char *path) void scenario_begin() { - rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; rct_window *mainWindow; gScreenFlags = SCREEN_FLAGS_PLAYING; @@ -181,12 +181,12 @@ void scenario_begin() finance_update_loan_hash(); - safe_strcpy(gScenarioDetails, s6Info->details, 256); - safe_strcpy(gScenarioName, s6Info->name, 64); + safe_strcpy(gScenarioDetails, gS6Info->details, 256); + safe_strcpy(gScenarioName, gS6Info->name, 64); { utf8 normalisedName[64]; - safe_strcpy(normalisedName, s6Info->name, sizeof(normalisedName)); + safe_strcpy(normalisedName, gS6Info->name, sizeof(normalisedName)); scenario_normalise_name(normalisedName); rct_string_id localisedStringIds[3]; @@ -646,7 +646,7 @@ void scenario_prepare_rides_for_save() */ int scenario_prepare_for_save() { - rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; + rct_s6_info *s6Info = gS6Info; char buffer[256]; s6Info->entry.flags = 255; diff --git a/src/scenario.h b/src/scenario.h index 53bd3ca7a0..d2350befc1 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -437,6 +437,7 @@ extern int gScenarioListCount; extern int gScenarioListCapacity; extern scenario_index_entry *gScenarioList; +extern rct_s6_info *gS6Info; extern char *gScenarioName; extern char *gScenarioDetails; extern char *gScenarioCompletedBy; diff --git a/src/windows/editor_bottom_toolbar.c b/src/windows/editor_bottom_toolbar.c index d6ffecd5ad..697df166e1 100644 --- a/src/windows/editor_bottom_toolbar.c +++ b/src/windows/editor_bottom_toolbar.c @@ -150,7 +150,7 @@ void window_editor_bottom_toolbar_open() */ void window_editor_bottom_toolbar_jump_back_to_object_selection() { window_close_all(); - g_editor_step = EDITOR_STEP_OBJECT_SELECTION; + gS6Info->editor_step = EDITOR_STEP_OBJECT_SELECTION; gfx_invalidate_screen(); } @@ -173,7 +173,7 @@ void window_editor_bottom_toolbar_jump_back_to_landscape_editor() { window_close_all(); sub_6DFED0(); scenery_set_default_placement_configuration(); - g_editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; + gS6Info->editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; window_map_open(); gfx_invalidate_screen(); } @@ -185,7 +185,7 @@ void window_editor_bottom_toolbar_jump_back_to_landscape_editor() { void window_editor_bottom_toolbar_jump_back_to_invention_list_set_up() { window_close_all(); window_editor_inventions_list_open(); - g_editor_step = EDITOR_STEP_INVENTIONS_LIST_SET_UP; + gS6Info->editor_step = EDITOR_STEP_INVENTIONS_LIST_SET_UP; gfx_invalidate_screen(); } @@ -196,7 +196,7 @@ void window_editor_bottom_toolbar_jump_back_to_invention_list_set_up() { void window_editor_bottom_toolbar_jump_back_to_scenario_options() { window_close_all(); window_editor_scenario_options_open(); - g_editor_step = EDITOR_STEP_OPTIONS_SELECTION; + gS6Info->editor_step = EDITOR_STEP_OPTIONS_SELECTION; gfx_invalidate_screen(); } @@ -207,7 +207,7 @@ void window_editor_bottom_toolbar_jump_back_to_scenario_options() { void window_editor_bottom_toolbar_jump_back_to_options_selection() { window_close_all(); window_editor_scenario_options_open(); - g_editor_step = EDITOR_STEP_OPTIONS_SELECTION; + gS6Info->editor_step = EDITOR_STEP_OPTIONS_SELECTION; gfx_invalidate_screen(); } @@ -259,7 +259,7 @@ static void sub_66F6E3() } window_new_ride_open(); - RCT2_GLOBAL(0x0141F570, uint8) = 6; + gS6Info->editor_step = EDITOR_STEP_ROLLERCOASTER_DESIGNER; gfx_invalidate_screen(); } @@ -277,7 +277,7 @@ void window_editor_bottom_toolbar_jump_forward_from_object_selection() } else { sub_6DFED0(); scenery_set_default_placement_configuration(); - RCT2_GLOBAL(0x00141F570, uint8) = 1; + gS6Info->editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; window_map_open(); gfx_invalidate_screen(); } @@ -291,7 +291,7 @@ void window_editor_bottom_toolbar_jump_forward_to_invention_list_set_up() { if (editor_check_park()) { window_close_all(); window_editor_inventions_list_open(); - g_editor_step = EDITOR_STEP_INVENTIONS_LIST_SET_UP; + gS6Info->editor_step = EDITOR_STEP_INVENTIONS_LIST_SET_UP; } else { window_error_open(STR_CANT_ADVANCE_TO_NEXT_EDITOR_STAGE, gGameCommandErrorText); } @@ -306,7 +306,7 @@ void window_editor_bottom_toolbar_jump_forward_to_invention_list_set_up() { void window_editor_bottom_toolbar_jump_forward_to_options_selection() { window_close_all(); window_editor_scenario_options_open(); - g_editor_step = EDITOR_STEP_OPTIONS_SELECTION; + gS6Info->editor_step = EDITOR_STEP_OPTIONS_SELECTION; gfx_invalidate_screen(); } @@ -317,7 +317,7 @@ void window_editor_bottom_toolbar_jump_forward_to_options_selection() { void window_editor_bottom_toolbar_jump_forward_to_objective_selection() { window_close_all(); window_editor_objective_options_open(); - g_editor_step = EDITOR_STEP_OBJECTIVE_SELECTION; + gS6Info->editor_step = EDITOR_STEP_OBJECTIVE_SELECTION; gfx_invalidate_screen(); } @@ -327,8 +327,6 @@ void window_editor_bottom_toolbar_jump_forward_to_objective_selection() { */ void window_editor_bottom_toolbar_jump_forward_to_save_scenario() { - rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; - if (!scenario_prepare_for_save()) { window_error_open(STR_UNABLE_TO_SAVE_SCENARIO_FILE, gGameCommandErrorText); gfx_invalidate_screen(); @@ -336,7 +334,7 @@ void window_editor_bottom_toolbar_jump_forward_to_save_scenario() } window_close_all(); - window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO, s6Info->name); + window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO, gS6Info->name); } /** @@ -349,10 +347,10 @@ static void window_editor_bottom_toolbar_mouseup(rct_window *w, int widgetIndex) if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) || (gSpriteListCount[SPRITE_LIST_NULL] == MAX_SPRITES && !(gParkFlags & PARK_FLAGS_18)) ) { - previous_button_mouseup_events[g_editor_step](); + previous_button_mouseup_events[gS6Info->editor_step](); } } else if (widgetIndex == WIDX_NEXT_STEP_BUTTON) { - next_button_mouseup_events[g_editor_step](); + next_button_mouseup_events[gS6Info->editor_step](); } } @@ -389,9 +387,9 @@ void window_editor_bottom_toolbar_invalidate(rct_window *w) hide_previous_step_button(); hide_next_step_button(); } else { - if (g_editor_step == EDITOR_STEP_OBJECT_SELECTION) { + if (gS6Info->editor_step == EDITOR_STEP_OBJECT_SELECTION) { hide_previous_step_button(); - } else if (g_editor_step == EDITOR_STEP_ROLLERCOASTER_DESIGNER) { + } else if (gS6Info->editor_step == EDITOR_STEP_ROLLERCOASTER_DESIGNER) { hide_next_step_button(); } else if (!(gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)) { if (gSpriteListCount[SPRITE_LIST_NULL] != MAX_SPRITES || gParkFlags & PARK_FLAGS_18) { @@ -410,7 +408,7 @@ void window_editor_bottom_toolbar_paint(rct_window *w, rct_drawpixelinfo *dpi) bool drawPreviousButton = false; bool drawNextButton = false; - if (g_editor_step == EDITOR_STEP_OBJECT_SELECTION) { + if (gS6Info->editor_step == EDITOR_STEP_OBJECT_SELECTION) { drawNextButton = true; } else if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) { @@ -435,7 +433,7 @@ void window_editor_bottom_toolbar_paint(rct_window *w, rct_drawpixelinfo *dpi) window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].bottom + w->y, 0x2000033); } - if ((drawPreviousButton || drawNextButton) && g_editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) { + if ((drawPreviousButton || drawNextButton) && gS6Info->editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) { gfx_fill_rect(dpi, window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].left + w->x, window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].top + w->y, @@ -458,7 +456,7 @@ void window_editor_bottom_toolbar_paint(rct_window *w, rct_drawpixelinfo *dpi) w->colours[1], 0x30); } - if ((drawPreviousButton || drawNextButton) && g_editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) { + if ((drawPreviousButton || drawNextButton) && gS6Info->editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) { gfx_fill_rect_inset(dpi, window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].left + 1 + w->x, window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].top + 1 + w->y, @@ -471,7 +469,7 @@ void window_editor_bottom_toolbar_paint(rct_window *w, rct_drawpixelinfo *dpi) (window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].right + window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].left) / 2 + w->x; short stateY = w->height - 0x0C + w->y; - gfx_draw_string_centred(dpi, STR_OBJECT_SELECTION_STEP + g_editor_step, + gfx_draw_string_centred(dpi, STR_OBJECT_SELECTION_STEP + gS6Info->editor_step, stateX, stateY, (w->colours[2] & 0x7F) | 0x20, 0); if (drawPreviousButton) { @@ -490,7 +488,7 @@ void window_editor_bottom_toolbar_paint(rct_window *w, rct_drawpixelinfo *dpi) window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].right) / 2 + w->x; short textY = window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].top + 6 + w->y; - short stringId = STR_OBJECT_SELECTION_STEP + g_editor_step - 1; + short stringId = STR_OBJECT_SELECTION_STEP + gS6Info->editor_step - 1; if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) stringId = STR_OBJECT_SELECTION_STEP; @@ -498,7 +496,7 @@ void window_editor_bottom_toolbar_paint(rct_window *w, rct_drawpixelinfo *dpi) gfx_draw_string_centred(dpi, stringId, textX, textY + 10, textColour, 0); } - if ((drawPreviousButton || drawNextButton) && g_editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) { + if ((drawPreviousButton || drawNextButton) && gS6Info->editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) { gfx_draw_sprite(dpi, SPR_NEXT, window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].right - 29 + w->x, window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].top + 6 + w->y, 0); @@ -515,7 +513,7 @@ void window_editor_bottom_toolbar_paint(rct_window *w, rct_drawpixelinfo *dpi) window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].right - 30) / 2 + w->x; short textY = window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].top + 6 + w->y; - short stringId = STR_OBJECT_SELECTION_STEP + g_editor_step + 1; + short stringId = STR_OBJECT_SELECTION_STEP + gS6Info->editor_step + 1; if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) stringId = STR_ROLLERCOASTER_DESIGNER_STEP; diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index 9026b16f3b..a718fc1a6c 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -19,6 +19,7 @@ #include "../audio/audio.h" #include "../config.h" #include "../game.h" +#include "../editor.h" #include "../interface/themes.h" #include "../interface/widget.h" #include "../interface/window.h" @@ -1946,7 +1947,7 @@ static void window_editor_object_selection_manage_tracks() gResearchedRideEntries[i] = 0xFFFFFFFF; } - RCT2_GLOBAL(0x141F570, uint8) = 7; + gS6Info->editor_step = EDITOR_STEP_TRACK_DESIGNS_MANAGER; int entry_index = 0; for (; ((int)object_entry_groups[0].chunks[entry_index]) == -1; ++entry_index); diff --git a/src/windows/editor_objective_options.c b/src/windows/editor_objective_options.c index 22b7fc704f..86f520b5fd 100644 --- a/src/windows/editor_objective_options.c +++ b/src/windows/editor_objective_options.c @@ -389,8 +389,6 @@ static void window_editor_objective_options_set_objective(rct_window *w, int obj */ static void window_editor_objective_options_main_mouseup(rct_window *w, int widgetIndex) { - rct_s6_info *s6Info = (rct_s6_info*)0x00141F570; - switch (widgetIndex) { case WIDX_CLOSE: window_close(w); @@ -404,11 +402,11 @@ static void window_editor_objective_options_main_mouseup(rct_window *w, int widg window_text_input_open(w, WIDX_PARK_NAME, STR_PARK_NAME, STR_ENTER_PARK_NAME, gParkName, 0, 32); break; case WIDX_SCENARIO_NAME: - safe_strcpy((char*)0x009BC677, s6Info->name, 64); + safe_strcpy((char*)0x009BC677, gS6Info->name, 64); window_text_input_open(w, WIDX_SCENARIO_NAME, STR_SCENARIO_NAME, STR_ENTER_SCENARIO_NAME, STR_PLACEHOLDER, 0, 64); break; case WIDX_DETAILS: - safe_strcpy((char*)0x009BC677, s6Info->details, 256); + safe_strcpy((char*)0x009BC677, gS6Info->details, 256); window_text_input_open(w, WIDX_DETAILS, STR_PARK_SCENARIO_DETAILS, STR_ENTER_SCENARIO_DESCRIPTION, STR_PLACEHOLDER, 0, 256); break; } @@ -526,7 +524,6 @@ static void window_editor_objective_options_show_climate_dropdown(rct_window *w) static void window_editor_objective_options_show_category_dropdown(rct_window *w) { - rct_s6_info *s6Info = (rct_s6_info*)0x00141F570; int i; rct_widget *dropdownWidget; @@ -545,7 +542,7 @@ static void window_editor_objective_options_show_category_dropdown(rct_window *w 5, dropdownWidget->right - dropdownWidget->left - 3 ); - dropdown_set_checked(s6Info->category, true); + dropdown_set_checked(gS6Info->category, true); } static void window_editor_objective_options_arg_1_increase(rct_window *w) @@ -701,7 +698,6 @@ static void window_editor_objective_options_main_mousedown(int widgetIndex, rct_ */ static void window_editor_objective_options_main_dropdown(rct_window *w, int widgetIndex, int dropdownIndex) { - rct_s6_info *s6Info = (rct_s6_info*)0x00141F570; uint8 newObjectiveType; if (dropdownIndex == -1) @@ -720,8 +716,8 @@ static void window_editor_objective_options_main_dropdown(rct_window *w, int wid } break; case WIDX_CATEGORY_DROPDOWN: - if (s6Info->category != (uint8)dropdownIndex) { - s6Info->category = (uint8)dropdownIndex; + if (gS6Info->category != (uint8)dropdownIndex) { + gS6Info->category = (uint8)dropdownIndex; window_invalidate(w); } break; @@ -770,7 +766,7 @@ static void window_editor_objective_options_main_update(rct_window *w) */ static void window_editor_objective_options_main_textinput(rct_window *w, int widgetIndex, char *text) { - rct_s6_info *s6Info = (rct_s6_info*)0x00141F570; + rct_s6_info *s6Info = gS6Info; if (text == NULL) return; @@ -876,7 +872,6 @@ static void window_editor_objective_options_main_invalidate(rct_window *w) */ static void window_editor_objective_options_main_paint(rct_window *w, rct_drawpixelinfo *dpi) { - rct_s6_info *s6Info = (rct_s6_info*)0x00141F570; rct_stex_entry *stex; int x, y, width; rct_string_id stringId; @@ -1001,7 +996,7 @@ static void window_editor_objective_options_main_paint(rct_window *w, rct_drawpi if (stex != NULL) { set_format_arg(0, uint16, stex->scenario_name); } else { - safe_strcpy((char*)0x009BC677, s6Info->name, 64); + safe_strcpy((char*)0x009BC677, gS6Info->name, 64); set_format_arg(0, uint16, STR_PLACEHOLDER); } set_format_arg(2, uint32, gParkNameArgs); @@ -1020,7 +1015,7 @@ static void window_editor_objective_options_main_paint(rct_window *w, rct_drawpi if (stex != NULL) { set_format_arg(0, uint16, stex->details); } else { - safe_strcpy((char*)0x009BC677, s6Info->details, 256); + safe_strcpy((char*)0x009BC677, gS6Info->details, 256); set_format_arg(0, uint16, STR_PLACEHOLDER); } set_format_arg(2, uint32, gParkNameArgs); @@ -1034,7 +1029,7 @@ static void window_editor_objective_options_main_paint(rct_window *w, rct_drawpi // Scenario category value x = w->x + w->widgets[WIDX_CATEGORY].left + 1; y = w->y + w->widgets[WIDX_CATEGORY].top; - stringId = ScenarioCategoryStringIds[s6Info->category]; + stringId = ScenarioCategoryStringIds[gS6Info->category]; gfx_draw_string_left(dpi, STR_WINDOW_COLOUR_2_STRING, &stringId, 0, x, y); } diff --git a/src/windows/loadsave.c b/src/windows/loadsave.c index 11d925aee6..c068229904 100644 --- a/src/windows/loadsave.c +++ b/src/windows/loadsave.c @@ -791,10 +791,9 @@ static void window_loadsave_select(rct_window *w, const char *path) break; case (LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO) : { - rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; int parkFlagsBackup = gParkFlags; gParkFlags &= ~PARK_FLAGS_18; - s6Info->editor_step = 255; + gS6Info->editor_step = 255; rw = SDL_RWFromFile(path, "wb+"); int success = 0; if (rw != NULL) { @@ -810,7 +809,7 @@ static void window_loadsave_select(rct_window *w, const char *path) title_load(); } else { window_error_open(STR_FILE_DIALOG_TITLE_SAVE_SCENARIO, STR_SCENARIO_SAVE_FAILED); - s6Info->editor_step = EDITOR_STEP_OBJECTIVE_SELECTION; + gS6Info->editor_step = EDITOR_STEP_OBJECTIVE_SELECTION; window_loadsave_invoke_callback(MODAL_RESULT_FAIL); } break; diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 082393e1e8..00be3e412d 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -466,7 +466,7 @@ static void window_top_toolbar_mousedown(int widgetIndex, rct_window*w, rct_widg gDropdownItemsFormat[1] = 2780; numItems = 2; - if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && g_editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { + if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && gS6Info->editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { gDropdownItemsFormat[2] = 2690; numItems++; } @@ -537,8 +537,7 @@ static void window_top_toolbar_dropdown(rct_window *w, int widgetIndex, int drop break; case DDIDX_SAVE_GAME_AS: if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) { - rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; - window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, s6Info->name); + window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, gS6Info->name); } else { tool_cancel(); @@ -668,7 +667,7 @@ static void window_top_toolbar_invalidate(rct_window *w) window_top_toolbar_widgets[WIDX_NEWS].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_NETWORK].type = WWT_EMPTY; - if (g_editor_step != EDITOR_STEP_LANDSCAPE_EDITOR) { + if (gS6Info->editor_step != EDITOR_STEP_LANDSCAPE_EDITOR) { window_top_toolbar_widgets[WIDX_MAP].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_LAND].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_WATER].type = WWT_EMPTY; @@ -677,12 +676,12 @@ static void window_top_toolbar_invalidate(rct_window *w) window_top_toolbar_widgets[WIDX_CLEAR_SCENERY].type = WWT_EMPTY; } - if (g_editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) { + if (gS6Info->editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) { window_top_toolbar_widgets[WIDX_CONSTRUCT_RIDE].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_FASTFORWARD].type = WWT_EMPTY; } - if (g_editor_step != EDITOR_STEP_LANDSCAPE_EDITOR && g_editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) { + if (gS6Info->editor_step != EDITOR_STEP_LANDSCAPE_EDITOR && gS6Info->editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) { window_top_toolbar_widgets[WIDX_ZOOM_OUT].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_ZOOM_IN].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_ROTATE].type = WWT_EMPTY; diff --git a/src/world/park.c b/src/world/park.c index 6554ff40a0..364f9f22db 100644 --- a/src/world/park.c +++ b/src/world/park.c @@ -132,9 +132,8 @@ void park_init() finance_reset_history(); award_reset(); - rct_s6_info *info = (rct_s6_info*)0x0141F570; - info->name[0] = '\0'; - format_string(info->details, STR_NO_DETAILS_YET, NULL); + gS6Info->name[0] = '\0'; + format_string(gS6Info->details, STR_NO_DETAILS_YET, NULL); } /**