mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Refactor game_init_all into GameState::InitAll.
This commit is contained in:
@@ -449,9 +449,10 @@ namespace OpenRCT2
|
||||
util_srand((uint32)time(nullptr));
|
||||
input_reset_place_obj_modifier();
|
||||
viewport_init_all();
|
||||
game_init_all(150);
|
||||
|
||||
_gameState = std::make_unique<GameState>();
|
||||
_gameState->InitAll(150);
|
||||
|
||||
_titleScreen = std::make_unique<TitleScreen>(_gameState.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Editor
|
||||
audio_stop_all_music_and_sounds();
|
||||
object_manager_unload_all_objects();
|
||||
object_list_load();
|
||||
game_init_all(150);
|
||||
OpenRCT2::GetContext()->GetGameState()->InitAll(150);
|
||||
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
|
||||
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
||||
gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
@@ -141,7 +141,7 @@ namespace Editor
|
||||
|
||||
object_manager_unload_all_objects();
|
||||
object_list_load();
|
||||
game_init_all(150);
|
||||
OpenRCT2::GetContext()->GetGameState()->InitAll(150);
|
||||
SetAllLandOwned();
|
||||
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
||||
viewport_init_all();
|
||||
@@ -162,7 +162,7 @@ namespace Editor
|
||||
|
||||
object_manager_unload_all_objects();
|
||||
object_list_load();
|
||||
game_init_all(150);
|
||||
OpenRCT2::GetContext()->GetGameState()->InitAll(150);
|
||||
SetAllLandOwned();
|
||||
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
||||
viewport_init_all();
|
||||
|
||||
@@ -1420,39 +1420,6 @@ void game_load_or_quit_no_save_prompt()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the map, park etc. basically all S6 data.
|
||||
*/
|
||||
void game_init_all(sint32 mapSize)
|
||||
{
|
||||
gInMapInitCode = true;
|
||||
|
||||
map_init(mapSize);
|
||||
park_init();
|
||||
finance_init();
|
||||
reset_park_entry();
|
||||
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();
|
||||
|
||||
gInMapInitCode = false;
|
||||
|
||||
gNextGuestNumber = 1;
|
||||
|
||||
context_init();
|
||||
scenery_set_default_placement_configuration();
|
||||
|
||||
auto intent = Intent(INTENT_ACTION_CLEAR_TILE_INSPECTOR_CLIPBOARD);
|
||||
context_broadcast_intent(&intent);
|
||||
|
||||
load_palette();
|
||||
}
|
||||
|
||||
GAME_COMMAND_POINTER * new_game_command_table[GAME_COMMAND_COUNT] = {
|
||||
game_command_set_ride_appearance,
|
||||
game_command_set_land_height,
|
||||
|
||||
@@ -186,4 +186,3 @@ void game_convert_strings_to_rct2(rct_s6_data * s6);
|
||||
void utf8_to_rct2_self(char * buffer, size_t length);
|
||||
void rct2_to_utf8_self(char * buffer, size_t length);
|
||||
void game_fix_save_vars();
|
||||
void game_init_all(sint32 mapSize);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "Input.h"
|
||||
#include "interface/Screenshot.h"
|
||||
#include "localisation/Date.h"
|
||||
#include "localisation/Localisation.h"
|
||||
#include "management/NewsItem.h"
|
||||
#include "network/network.h"
|
||||
#include "OpenRCT2.h"
|
||||
@@ -28,9 +29,11 @@
|
||||
#include "scenario/Scenario.h"
|
||||
#include "title/TitleScreen.h"
|
||||
#include "title/TitleSequencePlayer.h"
|
||||
#include "windows/Intent.h"
|
||||
#include "world/Climate.h"
|
||||
#include "world/MapAnimation.h"
|
||||
#include "world/Park.h"
|
||||
#include "world/Scenery.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
@@ -39,6 +42,39 @@ GameState::GameState()
|
||||
_park = std::make_unique<Park>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the map, park etc. basically all S6 data.
|
||||
*/
|
||||
void GameState::InitAll(sint32 mapSize)
|
||||
{
|
||||
gInMapInitCode = true;
|
||||
|
||||
map_init(mapSize);
|
||||
_park->Initialise();
|
||||
finance_init();
|
||||
reset_park_entry();
|
||||
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();
|
||||
|
||||
gInMapInitCode = false;
|
||||
|
||||
gNextGuestNumber = 1;
|
||||
|
||||
context_init();
|
||||
scenery_set_default_placement_configuration();
|
||||
|
||||
auto intent = Intent(INTENT_ACTION_CLEAR_TILE_INSPECTOR_CLIPBOARD);
|
||||
context_broadcast_intent(&intent);
|
||||
|
||||
load_palette();
|
||||
}
|
||||
|
||||
void GameState::Update()
|
||||
{
|
||||
gInUpdateCode = true;
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace OpenRCT2
|
||||
Date * GetDate() { return &_date; }
|
||||
Park * GetPark() { return _park.get(); }
|
||||
|
||||
void InitAll(sint32 mapSize);
|
||||
void Update();
|
||||
void UpdateLogic();
|
||||
};
|
||||
|
||||
@@ -340,8 +340,9 @@ private:
|
||||
String::Set(gScenarioFileName, sizeof(gScenarioFileName), GetRCT1ScenarioName().c_str());
|
||||
|
||||
// Do map initialisation, same kind of stuff done when loading scenario editor
|
||||
OpenRCT2::GetContext()->GetObjectManager()->UnloadAll();
|
||||
game_init_all(mapSize);
|
||||
auto context = OpenRCT2::GetContext();
|
||||
context->GetObjectManager()->UnloadAll();
|
||||
context->GetGameState()->InitAll(mapSize);
|
||||
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
||||
gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
gS6Info.category = SCENARIO_CATEGORY_OTHER;
|
||||
|
||||
@@ -771,7 +771,7 @@ public:
|
||||
|
||||
void Initialise()
|
||||
{
|
||||
game_init_all(_s6.map_size);
|
||||
OpenRCT2::GetContext()->GetGameState()->InitAll(_s6.map_size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -130,7 +130,7 @@ void TitleScreen::Load()
|
||||
|
||||
network_close();
|
||||
audio_stop_all_music_and_sounds();
|
||||
game_init_all(150);
|
||||
GetContext()->GetGameState()->InitAll(150);
|
||||
viewport_init_all();
|
||||
context_open_window(WC_MAIN_WINDOW);
|
||||
CreateWindows();
|
||||
@@ -276,7 +276,7 @@ bool TitleScreen::TryLoadSequence(bool loadPreview)
|
||||
_loadedTitleSequenceId = SIZE_MAX;
|
||||
if (!loadPreview)
|
||||
{
|
||||
game_init_all(150);
|
||||
GetContext()->GetGameState()->InitAll(150);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1060,16 +1060,6 @@ sint32 park_is_open()
|
||||
return GetContext()->GetGameState()->GetPark()->IsOpen();
|
||||
}
|
||||
|
||||
void park_init()
|
||||
{
|
||||
auto park = GetContext()->GetGameState()->GetPark();
|
||||
if (park == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
park->Initialise();
|
||||
}
|
||||
|
||||
sint32 park_calculate_size()
|
||||
{
|
||||
auto tiles = GetContext()->GetGameState()->GetPark()->CalculateParkSize();
|
||||
|
||||
@@ -128,7 +128,6 @@ void set_forced_park_rating(sint32 rating);
|
||||
sint32 get_forced_park_rating();
|
||||
|
||||
sint32 park_is_open();
|
||||
void park_init();
|
||||
sint32 park_calculate_size();
|
||||
|
||||
void reset_park_entry();
|
||||
|
||||
Reference in New Issue
Block a user