mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-16 19:43:06 +01:00
Merge pull request #5108 from IntelOrca/refactor/game-init
Refactor game initialisation
This commit is contained in:
@@ -82,38 +82,19 @@ static void editor_clear_map_for_editing(bool fromSave);
|
||||
*/
|
||||
void editor_load()
|
||||
{
|
||||
rct_window *mainWindow;
|
||||
|
||||
audio_stop_all_music_and_sounds();
|
||||
object_manager_unload_all_objects();
|
||||
object_list_load();
|
||||
map_init(150);
|
||||
banner_init();
|
||||
reset_park_entrances();
|
||||
user_string_clear_all();
|
||||
reset_sprite_list();
|
||||
ride_init_all();
|
||||
window_guest_list_init_vars_a();
|
||||
staff_reset_modes();
|
||||
park_init();
|
||||
finance_init();
|
||||
date_reset();
|
||||
window_guest_list_init_vars_b();
|
||||
window_staff_list_init_vars();
|
||||
game_init_all(150);
|
||||
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
|
||||
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
||||
gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
window_new_ride_init_vars();
|
||||
gS6Info.category = SCENARIO_CATEGORY_OTHER;
|
||||
viewport_init_all();
|
||||
news_item_init_queue();
|
||||
window_editor_main_open();
|
||||
mainWindow = window_get_main();
|
||||
window_scroll_to_location(mainWindow, 2400, 2400, 112);
|
||||
mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||
rct_window *mainWindow = window_editor_main_open();
|
||||
window_set_location(mainWindow, 2400, 2400, 112);
|
||||
load_palette();
|
||||
gfx_invalidate_screen();
|
||||
window_tile_inspector_clear_clipboard();
|
||||
gScreenAge = 0;
|
||||
|
||||
safe_strcpy(gScenarioName, language_get_string(STR_MY_NEW_SCENARIO), 64);
|
||||
@@ -170,39 +151,20 @@ static void editor_convert_save_to_scenario_callback(sint32 result, const utf8 *
|
||||
*/
|
||||
void trackdesigner_load()
|
||||
{
|
||||
rct_window *mainWindow;
|
||||
|
||||
audio_stop_all_music_and_sounds();
|
||||
gScreenFlags = SCREEN_FLAGS_TRACK_DESIGNER;
|
||||
gScreenAge = 0;
|
||||
|
||||
object_manager_unload_all_objects();
|
||||
object_list_load();
|
||||
map_init(150);
|
||||
game_init_all(150);
|
||||
set_all_land_owned();
|
||||
banner_init();
|
||||
reset_park_entrances();
|
||||
user_string_clear_all();
|
||||
reset_sprite_list();
|
||||
ride_init_all();
|
||||
window_guest_list_init_vars_a();
|
||||
staff_reset_modes();
|
||||
park_init();
|
||||
finance_init();
|
||||
date_reset();
|
||||
window_guest_list_init_vars_b();
|
||||
window_staff_list_init_vars();
|
||||
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
||||
window_new_ride_init_vars();
|
||||
viewport_init_all();
|
||||
news_item_init_queue();
|
||||
window_editor_main_open();
|
||||
mainWindow = window_get_main();
|
||||
window_scroll_to_location(mainWindow, 2400, 2400, 112);
|
||||
mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||
rct_window * mainWindow = window_editor_main_open();
|
||||
window_set_location(mainWindow, 2400, 2400, 112);
|
||||
load_palette();
|
||||
gfx_invalidate_screen();
|
||||
window_tile_inspector_clear_clipboard();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,39 +173,20 @@ void trackdesigner_load()
|
||||
*/
|
||||
void trackmanager_load()
|
||||
{
|
||||
rct_window *mainWindow;
|
||||
|
||||
audio_stop_all_music_and_sounds();
|
||||
gScreenFlags = SCREEN_FLAGS_TRACK_MANAGER;
|
||||
gScreenAge = 0;
|
||||
|
||||
object_manager_unload_all_objects();
|
||||
object_list_load();
|
||||
map_init(150);
|
||||
game_init_all(150);
|
||||
set_all_land_owned();
|
||||
banner_init();
|
||||
reset_park_entrances();
|
||||
user_string_clear_all();
|
||||
reset_sprite_list();
|
||||
ride_init_all();
|
||||
window_guest_list_init_vars_a();
|
||||
staff_reset_modes();
|
||||
park_init();
|
||||
finance_init();
|
||||
date_reset();
|
||||
window_guest_list_init_vars_b();
|
||||
window_staff_list_init_vars();
|
||||
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
||||
window_new_ride_init_vars();
|
||||
viewport_init_all();
|
||||
news_item_init_queue();
|
||||
window_editor_main_open();
|
||||
mainWindow = window_get_main();
|
||||
window_scroll_to_location(mainWindow, 2400, 2400, 112);
|
||||
mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||
rct_window *mainWindow = window_editor_main_open();
|
||||
window_set_location(mainWindow, 2400, 2400, 112);
|
||||
load_palette();
|
||||
gfx_invalidate_screen();
|
||||
window_tile_inspector_clear_clipboard();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1161,6 +1161,32 @@ void game_load_or_quit_no_save_prompt()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the map, park etc. basically all S6 data.
|
||||
*/
|
||||
void game_init_all(sint32 mapSize)
|
||||
{
|
||||
map_init(mapSize);
|
||||
park_init();
|
||||
finance_init();
|
||||
reset_park_entrances();
|
||||
banner_init();
|
||||
ride_init_all();
|
||||
reset_sprite_list();
|
||||
staff_reset_modes();
|
||||
date_reset();
|
||||
climate_reset(CLIMATE_COOL_AND_WET);
|
||||
news_item_init_queue();
|
||||
user_string_clear_all();
|
||||
|
||||
window_new_ride_init_vars();
|
||||
window_guest_list_init_vars_a();
|
||||
window_guest_list_init_vars_b();
|
||||
window_staff_list_init_vars();
|
||||
scenery_set_default_placement_configuration();
|
||||
window_tile_inspector_clear_clipboard();
|
||||
}
|
||||
|
||||
GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = {
|
||||
game_command_set_ride_appearance,
|
||||
game_command_set_land_height,
|
||||
|
||||
@@ -184,5 +184,6 @@ void game_convert_strings_to_utf8();
|
||||
void game_convert_strings_to_rct2(rct_s6_data *s6);
|
||||
void game_fix_save_vars();
|
||||
bool game_load_save_or_scenario(const utf8 * path);
|
||||
void game_init_all(sint32 mapSize);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -879,8 +879,7 @@ static sint32 cc_set(const utf8 **argv, sint32 argc)
|
||||
sint32 x = (sint16)(int_val[0] * 32 + 16);
|
||||
sint32 y = (sint16)(int_val[1] * 32 + 16);
|
||||
sint32 z = map_element_height(x, y);
|
||||
window_scroll_to_location(w, x, y, z);
|
||||
w->flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||
window_set_location(w, x, y, z);
|
||||
viewport_update_position(w);
|
||||
console_execute_silent("get location");
|
||||
}
|
||||
|
||||
@@ -1312,6 +1312,12 @@ void window_scroll_to_viewport(rct_window *w)
|
||||
window_scroll_to_location(mainWindow, x, y, z);
|
||||
}
|
||||
|
||||
void window_set_location(rct_window *w, sint32 x, sint32 y, sint32 z)
|
||||
{
|
||||
window_scroll_to_location(w, x, y, z);
|
||||
w->flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E7C9C
|
||||
|
||||
@@ -596,6 +596,7 @@ void window_push_others_below(rct_window *w1);
|
||||
|
||||
rct_window *window_get_main();
|
||||
|
||||
void window_set_location(rct_window *w, sint32 x, sint32 y, sint32 z);
|
||||
void window_scroll_to_viewport(rct_window *w);
|
||||
void window_scroll_to_location(rct_window *w, sint32 x, sint32 y, sint32 z);
|
||||
void window_rotate_camera(rct_window *w, sint32 direction);
|
||||
@@ -720,7 +721,7 @@ rct_window *window_loadsave_open(sint32 type, char *defaultName);
|
||||
rct_window *window_changelog_open();
|
||||
void window_debug_paint_open();
|
||||
|
||||
void window_editor_main_open();
|
||||
rct_window * window_editor_main_open();
|
||||
void window_editor_bottom_toolbar_open();
|
||||
void window_editor_object_selection_open();
|
||||
void window_editor_inventions_list_open();
|
||||
|
||||
@@ -179,27 +179,12 @@ private:
|
||||
uint16 mapSize = _s4.map_size == 0 ? 128 : _s4.map_size;
|
||||
|
||||
// Do map initialisation, same kind of stuff done when loading scenario editor
|
||||
audio_pause_sounds();
|
||||
audio_unpause_sounds();
|
||||
audio_stop_all_music_and_sounds();
|
||||
GetObjectManager()->UnloadAll();
|
||||
map_init(mapSize);
|
||||
banner_init();
|
||||
reset_park_entrances();
|
||||
user_string_clear_all();
|
||||
reset_sprite_list();
|
||||
ride_init_all();
|
||||
window_guest_list_init_vars_a();
|
||||
staff_reset_modes();
|
||||
park_init();
|
||||
finance_init();
|
||||
date_reset();
|
||||
window_guest_list_init_vars_b();
|
||||
window_staff_list_init_vars();
|
||||
game_init_all(mapSize);
|
||||
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
||||
gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
window_new_ride_init_vars();
|
||||
gS6Info.category = SCENARIO_CATEGORY_OTHER;
|
||||
news_item_init_queue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1449,7 +1434,6 @@ private:
|
||||
}
|
||||
|
||||
// Awards
|
||||
award_reset();
|
||||
for (sint32 i = 0; i < RCT12_MAX_AWARDS; i++)
|
||||
{
|
||||
rct12_award * src = &_s4.awards[i];
|
||||
|
||||
@@ -170,23 +170,10 @@ bool rct2_init()
|
||||
audio_init_ride_sounds_and_info();
|
||||
}
|
||||
viewport_init_all();
|
||||
news_item_init_queue();
|
||||
reset_park_entrances();
|
||||
user_string_clear_all();
|
||||
reset_sprite_list();
|
||||
ride_init_all();
|
||||
window_guest_list_init_vars_a();
|
||||
staff_reset_modes();
|
||||
map_init(150);
|
||||
park_init();
|
||||
|
||||
game_init_all(150);
|
||||
if (!gOpenRCT2Headless)
|
||||
window_title_menu_open();
|
||||
date_reset();
|
||||
climate_reset(CLIMATE_COOL_AND_WET);
|
||||
scenery_set_default_placement_configuration();
|
||||
window_new_ride_init_vars();
|
||||
window_guest_list_init_vars_b();
|
||||
window_staff_list_init_vars();
|
||||
load_palette();
|
||||
|
||||
#ifdef __ENABLE_LIGHTFX__
|
||||
|
||||
@@ -161,6 +161,8 @@ void S6Importer::LoadScenario(SDL_RWops *rw)
|
||||
|
||||
void S6Importer::Import()
|
||||
{
|
||||
Initialise();
|
||||
|
||||
// _s6.header
|
||||
gS6Info = _s6.info;
|
||||
|
||||
@@ -267,7 +269,6 @@ void S6Importer::Import()
|
||||
memcpy(gPeepWarningThrottle, _s6.peep_warning_throttle, sizeof(_s6.peep_warning_throttle));
|
||||
|
||||
// Awards
|
||||
award_reset();
|
||||
for (sint32 i = 0; i < RCT12_MAX_AWARDS; i++)
|
||||
{
|
||||
rct12_award * src = &_s6.awards[i];
|
||||
@@ -389,6 +390,11 @@ void S6Importer::Import()
|
||||
}
|
||||
}
|
||||
|
||||
void S6Importer::Initialise()
|
||||
{
|
||||
game_init_all(_s6.map_size);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -43,4 +43,6 @@ private:
|
||||
const utf8 * _s6Path = nullptr;
|
||||
rct_s6_data _s6;
|
||||
uint8 _gameVersion = 0;
|
||||
|
||||
void Initialise();
|
||||
};
|
||||
|
||||
@@ -122,25 +122,9 @@ extern "C"
|
||||
#ifndef DISABLE_NETWORK
|
||||
network_close();
|
||||
#endif
|
||||
reset_park_entrances();
|
||||
user_string_clear_all();
|
||||
reset_sprite_list();
|
||||
ride_init_all();
|
||||
window_guest_list_init_vars_a();
|
||||
staff_reset_modes();
|
||||
map_init(150);
|
||||
park_init();
|
||||
date_reset();
|
||||
climate_reset(CLIMATE_COOL_AND_WET);
|
||||
scenery_set_default_placement_configuration();
|
||||
window_new_ride_init_vars();
|
||||
window_guest_list_init_vars_b();
|
||||
window_staff_list_init_vars();
|
||||
map_update_tile_pointers();
|
||||
reset_sprite_spatial_index();
|
||||
audio_stop_all_music_and_sounds();
|
||||
game_init_all(150);
|
||||
viewport_init_all();
|
||||
news_item_init_queue();
|
||||
window_main_open();
|
||||
title_create_windows();
|
||||
TitleInitialise();
|
||||
|
||||
@@ -425,8 +425,7 @@ private:
|
||||
if (w != nullptr)
|
||||
{
|
||||
sint32 z = map_element_height(x, y);
|
||||
window_scroll_to_location(w, x, y, z);
|
||||
w->flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||
window_set_location(w, x, y, z);
|
||||
viewport_update_position(w);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,13 +63,11 @@ static rct_widget window_editor_main_widgets[] = {
|
||||
* Creates the main editor window that holds the main viewport.
|
||||
* rct2: 0x0066EF38
|
||||
*/
|
||||
void window_editor_main_open()
|
||||
rct_window * window_editor_main_open()
|
||||
{
|
||||
rct_window* window;
|
||||
|
||||
window_editor_main_widgets[0].right = gScreenWidth;
|
||||
window_editor_main_widgets[0].bottom = gScreenHeight;
|
||||
window = window_create(0, 0, window_editor_main_widgets[0].right, window_editor_main_widgets[0].bottom,
|
||||
rct_window *window = window_create(0, 0, window_editor_main_widgets[0].right, window_editor_main_widgets[0].bottom,
|
||||
&window_editor_main_events, WC_MAIN_WINDOW, WF_STICK_TO_BACK);
|
||||
window->widgets = window_editor_main_widgets;
|
||||
|
||||
@@ -84,6 +82,8 @@ void window_editor_main_open()
|
||||
|
||||
window_top_toolbar_open();
|
||||
window_editor_bottom_toolbar_open();
|
||||
|
||||
return window_get_main();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -368,7 +368,6 @@ rct_map_element* map_get_banner_element_at(sint32 x, sint32 y, sint32 z, uint8 p
|
||||
*/
|
||||
void map_init(sint32 size)
|
||||
{
|
||||
date_reset();
|
||||
gNumMapAnimations = 0;
|
||||
gNextFreeMapElementPointerIndex = 0;
|
||||
|
||||
@@ -397,7 +396,6 @@ void map_init(sint32 size)
|
||||
gMapBaseZ = 7;
|
||||
map_update_tile_pointers();
|
||||
map_remove_out_of_range_elements();
|
||||
climate_reset(CLIMATE_WARM);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user