diff --git a/src/openrct2-ui/input/Shortcuts.cpp b/src/openrct2-ui/input/Shortcuts.cpp index 662f692f3f..087009bdcc 100644 --- a/src/openrct2-ui/input/Shortcuts.cpp +++ b/src/openrct2-ui/input/Shortcuts.cpp @@ -189,7 +189,7 @@ static void ShortcutAdjustLand() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { @@ -208,7 +208,7 @@ static void ShortcutAdjustWater() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { @@ -227,7 +227,7 @@ static void ShortcutBuildScenery() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { @@ -246,7 +246,7 @@ static void ShortcutBuildPaths() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { @@ -353,7 +353,7 @@ static void ShortcutShowMap() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor) if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) context_open_window(WC_MAP); } @@ -396,7 +396,7 @@ static void ShortcutClearScenery() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { @@ -422,7 +422,7 @@ static void ShortcutQuickSaveGame() { auto intent = Intent(WC_LOADSAVE); intent.putExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE); - intent.putExtra(INTENT_EXTRA_PATH, std::string{ gS6Info.name }); + intent.putExtra(INTENT_EXTRA_PATH, gScenarioName); context_open_intent(&intent); } } @@ -439,7 +439,7 @@ static void ShortcutLoadGame() static void ShortcutOpenSceneryPicker() { if ((gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) - || (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && gS6Info.editor_step != EditorStep::LandscapeEditor)) + || (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && gEditorStep != EditorStep::LandscapeEditor)) return; rct_window* window_scenery = window_find_by_class(WC_SCENERY); @@ -729,7 +729,7 @@ void ShortcutManager::RegisterDefaultShortcuts() { window_close_all(); } - else if (gS6Info.editor_step == EditorStep::LandscapeEditor) + else if (gEditorStep == EditorStep::LandscapeEditor) { window_close_top(); } diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index eb1628903d..24f5914c2e 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -63,7 +63,7 @@ InteractionInfo ViewportInteractionGetItemLeft(const ScreenCoordsXY& screenCoord return info; // - if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) + if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gEditorStep != EditorStep::RollercoasterDesigner) return info; info = get_map_coordinates_from_pos( @@ -250,7 +250,7 @@ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoor return info; // - if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) + if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gEditorStep != EditorStep::RollercoasterDesigner) return info; constexpr auto flags = static_cast( diff --git a/src/openrct2-ui/windows/EditorBottomToolbar.cpp b/src/openrct2-ui/windows/EditorBottomToolbar.cpp index 62f4d61997..4301a10584 100644 --- a/src/openrct2-ui/windows/EditorBottomToolbar.cpp +++ b/src/openrct2-ui/windows/EditorBottomToolbar.cpp @@ -126,7 +126,7 @@ rct_window* window_editor_bottom_toolbar_open() void window_editor_bottom_toolbar_jump_back_to_object_selection() { window_close_all(); - gS6Info.editor_step = EditorStep::ObjectSelection; + gEditorStep = EditorStep::ObjectSelection; gfx_invalidate_screen(); } @@ -139,7 +139,7 @@ void window_editor_bottom_toolbar_jump_back_to_landscape_editor() window_close_all(); set_all_scenery_items_invented(); scenery_set_default_placement_configuration(); - gS6Info.editor_step = EditorStep::LandscapeEditor; + gEditorStep = EditorStep::LandscapeEditor; context_open_window(WC_MAP); gfx_invalidate_screen(); } @@ -152,7 +152,7 @@ static void window_editor_bottom_toolbar_jump_back_to_invention_list_set_up() { window_close_all(); context_open_window(WC_EDITOR_INVENTION_LIST); - gS6Info.editor_step = EditorStep::InventionsListSetUp; + gEditorStep = EditorStep::InventionsListSetUp; gfx_invalidate_screen(); } @@ -164,7 +164,7 @@ void window_editor_bottom_toolbar_jump_back_to_options_selection() { window_close_all(); context_open_window(WC_EDITOR_SCENARIO_OPTIONS); - gS6Info.editor_step = EditorStep::OptionsSelection; + gEditorStep = EditorStep::OptionsSelection; gfx_invalidate_screen(); } @@ -224,7 +224,7 @@ void window_editor_bottom_toolbar_jump_forward_to_invention_list_set_up() { window_close_all(); context_open_window(WC_EDITOR_INVENTION_LIST); - gS6Info.editor_step = EditorStep::InventionsListSetUp; + gEditorStep = EditorStep::InventionsListSetUp; } else { @@ -242,7 +242,7 @@ void window_editor_bottom_toolbar_jump_forward_to_options_selection() { window_close_all(); context_open_window(WC_EDITOR_SCENARIO_OPTIONS); - gS6Info.editor_step = EditorStep::OptionsSelection; + gEditorStep = EditorStep::OptionsSelection; gfx_invalidate_screen(); } @@ -254,7 +254,7 @@ void window_editor_bottom_toolbar_jump_forward_to_objective_selection() { window_close_all(); context_open_window(WC_EDITOR_OBJECTIVE_OPTIONS); - gS6Info.editor_step = EditorStep::ObjectiveSelection; + gEditorStep = EditorStep::ObjectiveSelection; gfx_invalidate_screen(); } @@ -274,7 +274,7 @@ void window_editor_bottom_toolbar_jump_forward_to_save_scenario() window_close_all(); auto intent = Intent(WC_LOADSAVE); intent.putExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO); - intent.putExtra(INTENT_EXTRA_PATH, std::string{ gS6Info.name }); + intent.putExtra(INTENT_EXTRA_PATH, gScenarioName); context_open_intent(&intent); } @@ -289,12 +289,12 @@ static void window_editor_bottom_toolbar_mouseup([[maybe_unused]] rct_window* w, if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) || (GetNumFreeEntities() == MAX_ENTITIES && !(gParkFlags & PARK_FLAGS_SPRITES_INITIALISED))) { - previous_button_mouseup_events[EnumValue(gS6Info.editor_step)](); + previous_button_mouseup_events[EnumValue(gEditorStep)](); } } else if (widgetIndex == WIDX_NEXT_STEP_BUTTON) { - next_button_mouseup_events[EnumValue(gS6Info.editor_step)](); + next_button_mouseup_events[EnumValue(gEditorStep)](); } } @@ -337,11 +337,11 @@ void window_editor_bottom_toolbar_invalidate(rct_window* w) } else { - if (gS6Info.editor_step == EditorStep::ObjectSelection) + if (gEditorStep == EditorStep::ObjectSelection) { hide_previous_step_button(); } - else if (gS6Info.editor_step == EditorStep::RollercoasterDesigner) + else if (gEditorStep == EditorStep::RollercoasterDesigner) { hide_next_step_button(); } @@ -364,7 +364,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) bool drawPreviousButton = false; bool drawNextButton = false; - if (gS6Info.editor_step == EditorStep::ObjectSelection) + if (gEditorStep == EditorStep::ObjectSelection) { drawNextButton = true; } @@ -396,7 +396,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].bottom + w->windowPos.y, FilterPaletteID::Palette51); } - if ((drawPreviousButton || drawNextButton) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) + if ((drawPreviousButton || drawNextButton) && gEditorStep != EditorStep::RollercoasterDesigner) { gfx_filter_rect( dpi, window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].left + w->windowPos.x, @@ -421,7 +421,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) gfx_fill_rect_inset(dpi, { topLeft, bottomRight }, w->colours[1], INSET_RECT_F_30); } - if ((drawPreviousButton || drawNextButton) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) + if ((drawPreviousButton || drawNextButton) && gEditorStep != EditorStep::RollercoasterDesigner) { gfx_fill_rect_inset(dpi, { topLeft, bottomRight }, w->colours[1], INSET_RECT_F_30); } @@ -432,7 +432,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) + w->windowPos.x; int16_t stateY = w->height - 0x0C + w->windowPos.y; DrawTextBasic( - dpi, { stateX, stateY }, EditorStepNames[EnumValue(gS6Info.editor_step)], {}, + dpi, { stateX, stateY }, EditorStepNames[EnumValue(gEditorStep)], {}, { static_cast(NOT_TRANSLUCENT(w->colours[2]) | COLOUR_FLAG_OUTLINE), TextAlignment::CENTRE }); if (drawPreviousButton) @@ -456,7 +456,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) + w->windowPos.x; int16_t textY = window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].top + 6 + w->windowPos.y; - rct_string_id stringId = EditorStepNames[EnumValue(gS6Info.editor_step) - 1]; + rct_string_id stringId = EditorStepNames[EnumValue(gEditorStep) - 1]; if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) stringId = STR_EDITOR_STEP_OBJECT_SELECTION; @@ -464,7 +464,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) DrawTextBasic(dpi, { textX, textY + 10 }, stringId, {}, { textColour, TextAlignment::CENTRE }); } - if ((drawPreviousButton || drawNextButton) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) + if ((drawPreviousButton || drawNextButton) && gEditorStep != EditorStep::RollercoasterDesigner) { gfx_draw_sprite( dpi, ImageId(SPR_NEXT), @@ -485,7 +485,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) + w->windowPos.x; int16_t textY = window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].top + 6 + w->windowPos.y; - rct_string_id stringId = EditorStepNames[EnumValue(gS6Info.editor_step) + 1]; + rct_string_id stringId = EditorStepNames[EnumValue(gEditorStep) + 1]; if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) stringId = STR_EDITOR_STEP_ROLLERCOASTER_DESIGNER; diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 53d6b67516..86f7cd248d 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -1336,7 +1336,7 @@ static void window_editor_object_selection_manage_tracks() set_every_ride_type_invented(); set_every_ride_entry_invented(); - gS6Info.editor_step = EditorStep::DesignsManager; + gEditorStep = EditorStep::DesignsManager; int32_t entry_index = 0; for (; object_entry_get_chunk(ObjectType::Ride, entry_index) == nullptr; entry_index++) diff --git a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp index b13a2ffcf3..60fac3b0ee 100644 --- a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp +++ b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp @@ -375,11 +375,12 @@ static void window_editor_objective_options_main_mouseup(rct_window* w, rct_widg break; } case WIDX_SCENARIO_NAME: - window_text_input_raw_open(w, WIDX_SCENARIO_NAME, STR_SCENARIO_NAME, STR_ENTER_SCENARIO_NAME, gS6Info.name, 64); + window_text_input_raw_open( + w, WIDX_SCENARIO_NAME, STR_SCENARIO_NAME, STR_ENTER_SCENARIO_NAME, gScenarioName.c_str(), 64); break; case WIDX_DETAILS: window_text_input_raw_open( - w, WIDX_DETAILS, STR_PARK_SCENARIO_DETAILS, STR_ENTER_SCENARIO_DESCRIPTION, gS6Info.details, 256); + w, WIDX_DETAILS, STR_PARK_SCENARIO_DETAILS, STR_ENTER_SCENARIO_DESCRIPTION, gScenarioDetails.c_str(), 256); break; } } @@ -448,7 +449,7 @@ static void window_editor_objective_options_show_category_dropdown(rct_window* w WindowDropdownShowTextCustomWidth( { w->windowPos.x + dropdownWidget->left, w->windowPos.y + dropdownWidget->top }, dropdownWidget->height() + 1, w->colours[1], 0, Dropdown::Flag::StayOpen, 5, dropdownWidget->width() - 3); - Dropdown::SetChecked(gS6Info.category, true); + Dropdown::SetChecked(gScenarioCategory, true); } static void window_editor_objective_options_arg_1_increase(rct_window* w) @@ -654,9 +655,9 @@ static void window_editor_objective_options_main_dropdown(rct_window* w, rct_wid window_editor_objective_options_set_objective(w, newObjectiveType); break; case WIDX_CATEGORY_DROPDOWN: - if (gS6Info.category != static_cast(dropdownIndex)) + if (gScenarioCategory != static_cast(dropdownIndex)) { - gS6Info.category = static_cast(dropdownIndex); + gScenarioCategory = static_cast(dropdownIndex); w->Invalidate(); } break; @@ -708,19 +709,19 @@ static void window_editor_objective_options_main_textinput(rct_window* w, rct_wi auto action = ParkSetNameAction(text); GameActions::Execute(&action); - if (gS6Info.name[0] == '\0') + if (gScenarioName.empty()) { auto& park = OpenRCT2::GetContext()->GetGameState()->GetPark(); - String::Set(gS6Info.name, sizeof(gS6Info.name), park.Name.c_str()); + gScenarioName = park.Name; } break; } case WIDX_SCENARIO_NAME: - safe_strcpy(gS6Info.name, text, std::size(gS6Info.name)); + gScenarioName = text; w->Invalidate(); break; case WIDX_DETAILS: - safe_strcpy(gS6Info.details, text, std::size(gS6Info.details)); + gScenarioDetails = text; w->Invalidate(); break; } @@ -901,7 +902,7 @@ static void window_editor_objective_options_main_paint(rct_window* w, rct_drawpi ft = Formatter(); ft.Add(STR_STRING); - ft.Add(gS6Info.name); + ft.Add(gScenarioName.c_str()); DrawTextEllipsised(dpi, screenCoords, width, STR_WINDOW_SCENARIO_NAME, ft); // Scenario details label @@ -914,7 +915,7 @@ static void window_editor_objective_options_main_paint(rct_window* w, rct_drawpi ft = Formatter(); ft.Add(STR_STRING); - ft.Add(gS6Info.details); + ft.Add(gScenarioDetails.c_str()); DrawTextWrapped(dpi, screenCoords, width, STR_BLACK_STRING, ft); // Scenario category label @@ -924,7 +925,7 @@ static void window_editor_objective_options_main_paint(rct_window* w, rct_drawpi // Scenario category value screenCoords = w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_CATEGORY].left + 1, w->widgets[WIDX_CATEGORY].top }; ft = Formatter(); - ft.Add(ScenarioCategoryStringIds[gS6Info.category]); + ft.Add(ScenarioCategoryStringIds[gScenarioCategory]); DrawTextBasic(dpi, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft); } diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index 67d1376a6d..7a26d65808 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -1061,7 +1061,7 @@ static void window_loadsave_select(rct_window* w, const char* path) save_path(&gConfigGeneral.last_save_scenario_directory, pathBuffer); int32_t parkFlagsBackup = gParkFlags; gParkFlags &= ~PARK_FLAGS_SPRITES_INITIALISED; - gS6Info.editor_step = EditorStep::Invalid; + gEditorStep = EditorStep::Invalid; safe_strcpy(gScenarioFileName, pathBuffer, sizeof(gScenarioFileName)); int32_t success = scenario_save(pathBuffer, gConfigGeneral.save_plugin_data ? 3 : 2); gParkFlags = parkFlagsBackup; @@ -1075,7 +1075,7 @@ static void window_loadsave_select(rct_window* w, const char* path) else { context_show_error(STR_FILE_DIALOG_TITLE_SAVE_SCENARIO, STR_SCENARIO_SAVE_FAILED, {}); - gS6Info.editor_step = EditorStep::ObjectiveSelection; + gEditorStep = EditorStep::ObjectiveSelection; window_loadsave_invoke_callback(MODAL_RESULT_FAIL, pathBuffer); } break; diff --git a/src/openrct2-ui/windows/SavePrompt.cpp b/src/openrct2-ui/windows/SavePrompt.cpp index cb320b9d40..96e8b886ea 100644 --- a/src/openrct2-ui/windows/SavePrompt.cpp +++ b/src/openrct2-ui/windows/SavePrompt.cpp @@ -220,7 +220,7 @@ static void window_save_prompt_mouseup(rct_window* w, rct_widgetindex widgetInde { intent = new Intent(WC_LOADSAVE); intent->putExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE); - intent->putExtra(INTENT_EXTRA_PATH, std::string{ gS6Info.name }); + intent->putExtra(INTENT_EXTRA_PATH, gScenarioName); } else { diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 62368c5da4..1f4f1f08b1 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -561,7 +561,7 @@ static void window_top_toolbar_dropdown(rct_window* w, rct_widgetindex widgetInd { auto intent = Intent(WC_LOADSAVE); intent.putExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE); - intent.putExtra(INTENT_EXTRA_PATH, std::string{ gS6Info.name }); + intent.putExtra(INTENT_EXTRA_PATH, gScenarioName); context_open_intent(&intent); } else @@ -685,20 +685,20 @@ static void window_top_toolbar_invalidate(rct_window* w) window_top_toolbar_widgets[WIDX_NEWS].type = WindowWidgetType::Empty; window_top_toolbar_widgets[WIDX_NETWORK].type = WindowWidgetType::Empty; - if (gS6Info.editor_step != EditorStep::LandscapeEditor) + if (gEditorStep != EditorStep::LandscapeEditor) { window_top_toolbar_widgets[WIDX_LAND].type = WindowWidgetType::Empty; window_top_toolbar_widgets[WIDX_WATER].type = WindowWidgetType::Empty; } - if (gS6Info.editor_step != EditorStep::RollercoasterDesigner) + if (gEditorStep != EditorStep::RollercoasterDesigner) { window_top_toolbar_widgets[WIDX_RIDES].type = WindowWidgetType::Empty; window_top_toolbar_widgets[WIDX_CONSTRUCT_RIDE].type = WindowWidgetType::Empty; window_top_toolbar_widgets[WIDX_FASTFORWARD].type = WindowWidgetType::Empty; } - if (gS6Info.editor_step != EditorStep::LandscapeEditor && gS6Info.editor_step != EditorStep::RollercoasterDesigner) + if (gEditorStep != EditorStep::LandscapeEditor && gEditorStep != EditorStep::RollercoasterDesigner) { window_top_toolbar_widgets[WIDX_MAP].type = WindowWidgetType::Empty; window_top_toolbar_widgets[WIDX_SCENERY].type = WindowWidgetType::Empty; @@ -3273,7 +3273,7 @@ static void top_toolbar_init_map_menu(rct_window* w, rct_widget* widget) auto i = 0; gDropdownItemsFormat[i++] = STR_SHORTCUT_SHOW_MAP; gDropdownItemsFormat[i++] = STR_EXTRA_VIEWPORT; - if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && gS6Info.editor_step == EditorStep::LandscapeEditor) + if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && gEditorStep == EditorStep::LandscapeEditor) { gDropdownItemsFormat[i++] = STR_MAPGEN_WINDOW_TITLE; } @@ -3301,7 +3301,7 @@ static void top_toolbar_init_map_menu(rct_window* w, rct_widget* widget) static void top_toolbar_map_menu_dropdown(int16_t dropdownIndex) { int32_t customStartIndex = 3; - if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && gS6Info.editor_step == EditorStep::LandscapeEditor) + if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && gEditorStep == EditorStep::LandscapeEditor) { customStartIndex++; } diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index af4a1fbe30..96444bb90e 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -47,6 +47,8 @@ using namespace OpenRCT2; +EditorStep gEditorStep; + namespace Editor { static std::array, EnumValue(ObjectType::Count)> _editorSelectedObjectFlags; @@ -84,9 +86,9 @@ namespace Editor object_list_load(); OpenRCT2::GetContext()->GetGameState()->InitAll(150); gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; - gS6Info.editor_step = EditorStep::ObjectSelection; + gEditorStep = EditorStep::ObjectSelection; gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; - gS6Info.category = SCENARIO_CATEGORY_OTHER; + gScenarioCategory = SCENARIO_CATEGORY_OTHER; viewport_init_all(); rct_window* mainWindow = context_open_window_view(WV_EDITOR_MAIN); mainWindow->SetLocation(TileCoordsXYZ{ 75, 75, 14 }.ToCoordsXYZ()); @@ -130,17 +132,11 @@ namespace Editor } gParkFlags |= PARK_FLAGS_NO_MONEY; - safe_strcpy(gS6Info.name, gScenarioName.c_str(), sizeof(gS6Info.name)); - safe_strcpy(gS6Info.details, gScenarioDetails.c_str(), sizeof(gS6Info.details)); - gS6Info.objective_type = gScenarioObjective.Type; - gS6Info.objective_arg_1 = gScenarioObjective.Year; - gS6Info.objective_arg_2 = gScenarioObjective.Currency; - gS6Info.objective_arg_3 = gScenarioObjective.NumGuests; climate_reset(gClimate); gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; - gS6Info.editor_step = EditorStep::ObjectiveSelection; - gS6Info.category = SCENARIO_CATEGORY_OTHER; + gEditorStep = EditorStep::ObjectiveSelection; + gScenarioCategory = SCENARIO_CATEGORY_OTHER; viewport_init_all(); News::InitQueue(); context_open_window_view(WV_EDITOR_MAIN); @@ -162,7 +158,7 @@ namespace Editor object_list_load(); OpenRCT2::GetContext()->GetGameState()->InitAll(150); SetAllLandOwned(); - gS6Info.editor_step = EditorStep::ObjectSelection; + gEditorStep = EditorStep::ObjectSelection; viewport_init_all(); rct_window* mainWindow = context_open_window_view(WV_EDITOR_MAIN); mainWindow->SetLocation(TileCoordsXYZ{ 75, 75, 14 }.ToCoordsXYZ()); @@ -183,7 +179,7 @@ namespace Editor object_list_load(); OpenRCT2::GetContext()->GetGameState()->InitAll(150); SetAllLandOwned(); - gS6Info.editor_step = EditorStep::ObjectSelection; + gEditorStep = EditorStep::ObjectSelection; viewport_init_all(); rct_window* mainWindow = context_open_window_view(WV_EDITOR_MAIN); mainWindow->SetLocation(TileCoordsXYZ{ 75, 75, 14 }.ToCoordsXYZ()); @@ -242,7 +238,7 @@ namespace Editor load_from_sv4(path); ClearMapForEditing(true); - gS6Info.editor_step = EditorStep::LandscapeEditor; + gEditorStep = EditorStep::LandscapeEditor; gScreenAge = 0; gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; viewport_init_all(); @@ -256,7 +252,7 @@ namespace Editor load_from_sc4(path); ClearMapForEditing(false); - gS6Info.editor_step = EditorStep::LandscapeEditor; + gEditorStep = EditorStep::LandscapeEditor; gScreenAge = 0; gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; viewport_init_all(); @@ -285,7 +281,7 @@ namespace Editor ClearMapForEditing(loadedFromSave); - gS6Info.editor_step = EditorStep::LandscapeEditor; + gEditorStep = EditorStep::LandscapeEditor; gScreenAge = 0; gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; viewport_init_all(); @@ -371,7 +367,7 @@ namespace Editor return; } - switch (gS6Info.editor_step) + switch (gEditorStep) { case EditorStep::ObjectSelection: if (window_find_by_class(WC_EDITOR_OBJECT_SELECTION)) diff --git a/src/openrct2/Editor.h b/src/openrct2/Editor.h index cc617791b0..8a7499f2d8 100644 --- a/src/openrct2/Editor.h +++ b/src/openrct2/Editor.h @@ -44,6 +44,8 @@ enum class EditorStep : uint8_t Invalid = 255, // 255 }; +extern EditorStep gEditorStep; + void editor_open_windows_for_current_step(); #endif diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index cd13e2f396..687233c39f 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -448,14 +448,14 @@ void finish_object_selection() { set_every_ride_type_invented(); set_every_ride_entry_invented(); - gS6Info.editor_step = EditorStep::RollercoasterDesigner; + gEditorStep = EditorStep::RollercoasterDesigner; gfx_invalidate_screen(); } else { set_all_scenery_items_invented(); scenery_set_default_placement_configuration(); - gS6Info.editor_step = EditorStep::LandscapeEditor; + gEditorStep = EditorStep::LandscapeEditor; gfx_invalidate_screen(); } } diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index 2722987872..6d54804b2c 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -349,7 +349,7 @@ void window_close_top() if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) { - if (gS6Info.editor_step != EditorStep::LandscapeEditor) + if (gEditorStep != EditorStep::LandscapeEditor) return; } @@ -1082,7 +1082,7 @@ void main_window_zoom(bool zoomIn, bool atCursor) { if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor) { if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) { diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index ecfa41ca63..c0e9c05d26 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -349,9 +349,9 @@ private: auto context = OpenRCT2::GetContext(); context->GetObjectManager().UnloadAll(); context->GetGameState()->InitAll(mapSize); - gS6Info.editor_step = EditorStep::ObjectSelection; + gEditorStep = EditorStep::ObjectSelection; gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; - gS6Info.category = SCENARIO_CATEGORY_OTHER; + gScenarioCategory = SCENARIO_CATEGORY_OTHER; } std::string GetRCT1ScenarioName() @@ -2284,8 +2284,6 @@ private: } } - String::Set(gS6Info.name, sizeof(gS6Info.name), name.c_str()); - String::Set(gS6Info.details, sizeof(gS6Info.details), details.c_str()); gScenarioName = name; gScenarioDetails = details; } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index adfd8c04f4..206dabcd4a 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -9,6 +9,7 @@ #include "../Context.h" #include "../Diagnostic.h" +#include "../Editor.h" #include "../Game.h" #include "../GameState.h" #include "../OpenRCT2.h" @@ -204,21 +205,19 @@ public: { Initialise(); - // _s6.header - gS6Info = _s6.info; + gEditorStep = _s6.info.editor_step; + gScenarioCategory = static_cast(_s6.info.category); // Some scenarios have their scenario details in UTF-8, due to earlier bugs in OpenRCT2. if (!IsLikelyUTF8(_s6.info.name) && !IsLikelyUTF8(_s6.info.details)) { - auto temp = rct2_to_utf8(_s6.info.name, RCT2LanguageId::EnglishUK); - safe_strcpy(gS6Info.name, temp.data(), sizeof(gS6Info.name)); - auto temp2 = rct2_to_utf8(_s6.info.details, RCT2LanguageId::EnglishUK); - safe_strcpy(gS6Info.details, temp2.data(), sizeof(gS6Info.details)); + gScenarioName = rct2_to_utf8(_s6.info.name, RCT2LanguageId::EnglishUK); + gScenarioDetails = rct2_to_utf8(_s6.info.details, RCT2LanguageId::EnglishUK); } else { - safe_strcpy(gS6Info.name, _s6.info.name, sizeof(gS6Info.name)); - safe_strcpy(gS6Info.details, _s6.info.details, sizeof(gS6Info.details)); + gScenarioName = _s6.info.name; + gScenarioDetails = _s6.info.details; } gDateMonthsElapsed = static_cast(_s6.elapsed_months); diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index dc14648a8e..222f02ab3a 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -912,7 +912,7 @@ void Ride::UpdateAll() // Remove all rides if scenario editor if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) { - switch (gS6Info.editor_step) + switch (gEditorStep) { case EditorStep::ObjectSelection: case EditorStep::LandscapeEditor: diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index c256d30f82..50f1c0c22d 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -960,7 +960,7 @@ bool Vehicle::SoundCanPlay() const if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) return false; - if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) + if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gEditorStep != EditorStep::RollercoasterDesigner) return false; if (sound1_id == OpenRCT2::Audio::SoundId::Null && sound2_id == OpenRCT2::Audio::SoundId::Null) @@ -1404,7 +1404,7 @@ void vehicle_update_all() if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) return; - if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) + if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gEditorStep != EditorStep::RollercoasterDesigner) return; for (auto vehicle : TrainManager::View()) diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 4f74f49195..8f840df3f9 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -58,7 +58,7 @@ const rct_string_id ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT] = { STR_DLC_PARKS, STR_BUILD_YOUR_OWN_PARKS, }; -rct_s6_info gS6Info; +SCENARIO_CATEGORY gScenarioCategory; std::string gScenarioName; std::string gScenarioDetails; std::string gScenarioCompletedBy; @@ -108,12 +108,9 @@ void scenario_begin() gHistoricalProfit = gInitialCash - gBankLoan; gCash = gInitialCash; - gScenarioDetails = std::string_view(gS6Info.details, 256); - gScenarioName = std::string_view(gS6Info.name, 64); - { utf8 normalisedName[64]; - ScenarioSources::NormaliseName(normalisedName, sizeof(normalisedName), gS6Info.name); + ScenarioSources::NormaliseName(normalisedName, sizeof(normalisedName), gScenarioName.c_str()); rct_string_id localisedStringIds[3]; if (language_get_localised_scenario_strings(normalisedName, localisedStringIds)) @@ -586,18 +583,6 @@ static bool scenario_prepare_rides_for_save() */ bool scenario_prepare_for_save() { - auto& park = GetContext()->GetGameState()->GetPark(); - auto parkName = park.Name.c_str(); - - gS6Info.entry.flags = 255; - if (gS6Info.name[0] == 0) - String::Set(gS6Info.name, sizeof(gS6Info.name), parkName); - - gS6Info.objective_type = gScenarioObjective.Type; - gS6Info.objective_arg_1 = gScenarioObjective.Year; - gS6Info.objective_arg_2 = gScenarioObjective.Currency; - gS6Info.objective_arg_3 = gScenarioObjective.NumGuests; - // This can return false if the goal is 'Finish 5 roller coaster' and there are too few. if (!scenario_prepare_rides_for_save()) { diff --git a/src/openrct2/scenario/Scenario.h b/src/openrct2/scenario/Scenario.h index e3a74c6977..26e7f177ed 100644 --- a/src/openrct2/scenario/Scenario.h +++ b/src/openrct2/scenario/Scenario.h @@ -436,7 +436,7 @@ extern uint16_t gScenarioParkRatingWarningDays; extern money64 gScenarioCompletedCompanyValue; extern money64 gScenarioCompanyValueRecord; -extern rct_s6_info gS6Info; +extern SCENARIO_CATEGORY gScenarioCategory; extern std::string gScenarioName; extern std::string gScenarioDetails; extern std::string gScenarioCompletedBy; diff --git a/src/openrct2/scripting/ScPark.hpp b/src/openrct2/scripting/ScPark.hpp index 18be4cb1f2..202f06de4c 100644 --- a/src/openrct2/scripting/ScPark.hpp +++ b/src/openrct2/scripting/ScPark.hpp @@ -227,7 +227,7 @@ namespace OpenRCT2::Scripting } }; - static const DukEnumMap ParkFlagMap({ + static const DukEnumMap ParkFlagMap({ { "open", PARK_FLAGS_PARK_OPEN }, { "scenarioCompleteNameInput", PARK_FLAGS_SCENARIO_COMPLETE_NAME_INPUT }, { "forbidLandscapeChanges", PARK_FLAGS_FORBID_LANDSCAPE_CHANGES }, diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index 91c2f07206..98745ca80a 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -18,6 +18,7 @@ #include "../actions/ParkSetParameterAction.h" #include "../config/Config.h" #include "../core/Memory.hpp" +#include "../core/String.hpp" #include "../interface/Colour.h" #include "../interface/Window.h" #include "../localisation/Localisation.h" @@ -303,8 +304,8 @@ void Park::Initialise() finance_reset_history(); award_reset(); - gS6Info.name[0] = '\0'; - format_string(gS6Info.details, 256, STR_NO_DETAILS_YET, nullptr); + gScenarioName = ""; + gScenarioDetails = String::ToStd(language_get_string(STR_NO_DETAILS_YET)); } void Park::Update(const Date& date)