mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 03:53:07 +01:00
Make scenario_save just take a path
This commit is contained in:
@@ -948,12 +948,8 @@ void save_game()
|
||||
{
|
||||
if (!gFirstTimeSave) {
|
||||
log_verbose("Saving to %s", gScenarioSavePath);
|
||||
|
||||
SDL_RWops* rw = SDL_RWFromFile(gScenarioSavePath, "wb+");
|
||||
if (rw != NULL) {
|
||||
scenario_save(rw, 0x80000000 | (gConfigGeneral.save_plugin_data ? 1 : 0));
|
||||
if (scenario_save(gScenarioSavePath, 0x80000000 | (gConfigGeneral.save_plugin_data ? 1 : 0))) {
|
||||
log_verbose("Saved to %s", gScenarioSavePath);
|
||||
SDL_RWclose(rw);
|
||||
|
||||
// Setting screen age to zero, so no prompt will pop up when closing the
|
||||
// game shortly after saving.
|
||||
@@ -1077,11 +1073,7 @@ void game_autosave()
|
||||
platform_file_copy(path, backupPath, true);
|
||||
}
|
||||
|
||||
SDL_RWops* rw = SDL_RWFromFile(path, "wb+");
|
||||
if (rw != NULL) {
|
||||
scenario_save(rw, saveFlags);
|
||||
SDL_RWclose(rw);
|
||||
}
|
||||
scenario_save(path, saveFlags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -409,7 +409,7 @@ extern "C"
|
||||
* rct2: 0x006754F5
|
||||
* @param flags bit 0: pack objects, 1: save as scenario
|
||||
*/
|
||||
sint32 scenario_save(SDL_RWops* rw, sint32 flags)
|
||||
sint32 scenario_save(const utf8 * path, sint32 flags)
|
||||
{
|
||||
if (flags & S6_SAVE_FLAG_SCENARIO)
|
||||
{
|
||||
@@ -434,8 +434,6 @@ extern "C"
|
||||
auto s6exporter = new S6Exporter();
|
||||
try
|
||||
{
|
||||
auto rwStream = FileStream(rw, FILE_MODE_WRITE);
|
||||
|
||||
if (flags & S6_SAVE_FLAG_EXPORT)
|
||||
{
|
||||
IObjectManager * objManager = GetObjectManager();
|
||||
@@ -445,11 +443,11 @@ extern "C"
|
||||
s6exporter->Export();
|
||||
if (flags & S6_SAVE_FLAG_SCENARIO)
|
||||
{
|
||||
s6exporter->SaveScenario(&rwStream);
|
||||
s6exporter->SaveScenario(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
s6exporter->SaveGame(&rwStream);
|
||||
s6exporter->SaveGame(path);
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ void scenario_update();
|
||||
uint32 scenario_rand();
|
||||
uint32 scenario_rand_max(uint32 max);
|
||||
sint32 scenario_prepare_for_save();
|
||||
sint32 scenario_save(SDL_RWops* rw, sint32 flags);
|
||||
sint32 scenario_save(const utf8 * path, sint32 flags);
|
||||
void scenario_remove_trackless_rides(rct_s6_data *s6);
|
||||
void scenario_fix_ghosts(rct_s6_data *s6);
|
||||
void scenario_set_filename(const char *value);
|
||||
|
||||
@@ -718,7 +718,6 @@ static void window_loadsave_select(rct_window *w, const char *path)
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_RWops* rw;
|
||||
switch (_type & 0x0F) {
|
||||
case (LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME) :
|
||||
save_path(&gConfigGeneral.last_save_game_directory, path);
|
||||
@@ -729,22 +728,14 @@ static void window_loadsave_select(rct_window *w, const char *path)
|
||||
break;
|
||||
case (LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME) :
|
||||
save_path(&gConfigGeneral.last_save_game_directory, path);
|
||||
rw = SDL_RWFromFile(path, "wb+");
|
||||
if (rw != NULL) {
|
||||
sint32 success = scenario_save(rw, gConfigGeneral.save_plugin_data ? 1 : 0);
|
||||
SDL_RWclose(rw);
|
||||
if (success) {
|
||||
safe_strcpy(gScenarioSavePath, path, MAX_PATH);
|
||||
gFirstTimeSave = 0;
|
||||
if (scenario_save(path, gConfigGeneral.save_plugin_data ? 1 : 0)) {
|
||||
safe_strcpy(gScenarioSavePath, path, MAX_PATH);
|
||||
gFirstTimeSave = 0;
|
||||
|
||||
window_close_by_class(WC_LOADSAVE);
|
||||
gfx_invalidate_screen();
|
||||
window_close_by_class(WC_LOADSAVE);
|
||||
gfx_invalidate_screen();
|
||||
|
||||
window_loadsave_invoke_callback(MODAL_RESULT_OK, path);
|
||||
} else {
|
||||
window_error_open(STR_SAVE_GAME, STR_GAME_SAVE_FAILED);
|
||||
window_loadsave_invoke_callback(MODAL_RESULT_FAIL, path);
|
||||
}
|
||||
window_loadsave_invoke_callback(MODAL_RESULT_OK, path);
|
||||
} else {
|
||||
window_error_open(STR_SAVE_GAME, STR_GAME_SAVE_FAILED);
|
||||
window_loadsave_invoke_callback(MODAL_RESULT_FAIL, path);
|
||||
@@ -763,19 +754,11 @@ static void window_loadsave_select(rct_window *w, const char *path)
|
||||
break;
|
||||
case (LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE) :
|
||||
save_path(&gConfigGeneral.last_save_landscape_directory, path);
|
||||
rw = SDL_RWFromFile(path, "wb+");
|
||||
if (rw != NULL) {
|
||||
scenario_set_filename(path);
|
||||
sint32 success = scenario_save(rw, gConfigGeneral.save_plugin_data ? 3 : 2);
|
||||
SDL_RWclose(rw);
|
||||
if (success) {
|
||||
window_close_by_class(WC_LOADSAVE);
|
||||
gfx_invalidate_screen();
|
||||
window_loadsave_invoke_callback(MODAL_RESULT_OK, path);
|
||||
} else {
|
||||
window_error_open(STR_SAVE_LANDSCAPE, STR_LANDSCAPE_SAVE_FAILED);
|
||||
window_loadsave_invoke_callback(MODAL_RESULT_FAIL, path);
|
||||
}
|
||||
scenario_set_filename(path);
|
||||
if (scenario_save(path, gConfigGeneral.save_plugin_data ? 3 : 2)) {
|
||||
window_close_by_class(WC_LOADSAVE);
|
||||
gfx_invalidate_screen();
|
||||
window_loadsave_invoke_callback(MODAL_RESULT_OK, path);
|
||||
} else {
|
||||
window_error_open(STR_SAVE_LANDSCAPE, STR_LANDSCAPE_SAVE_FAILED);
|
||||
window_loadsave_invoke_callback(MODAL_RESULT_FAIL, path);
|
||||
@@ -787,13 +770,8 @@ static void window_loadsave_select(rct_window *w, const char *path)
|
||||
sint32 parkFlagsBackup = gParkFlags;
|
||||
gParkFlags &= ~PARK_FLAGS_SPRITES_INITIALISED;
|
||||
gS6Info.editor_step = 255;
|
||||
rw = SDL_RWFromFile(path, "wb+");
|
||||
sint32 success = 0;
|
||||
if (rw != NULL) {
|
||||
scenario_set_filename(path);
|
||||
success = scenario_save(rw, gConfigGeneral.save_plugin_data ? 3 : 2);
|
||||
SDL_RWclose(rw);
|
||||
}
|
||||
scenario_set_filename(path);
|
||||
sint32 success = scenario_save(path, gConfigGeneral.save_plugin_data ? 3 : 2);
|
||||
gParkFlags = parkFlagsBackup;
|
||||
|
||||
if (success) {
|
||||
|
||||
Reference in New Issue
Block a user