mirror of https://github.com/OpenRCT2/OpenRCT2.git
fix #2279, make game remember save path rather than filename
This commit is contained in:
parent
e857f2d3c8
commit
7f541240e2
18
src/game.c
18
src/game.c
|
@ -886,8 +886,7 @@ int game_load_save(const char *path)
|
|||
safe_strncpy((char*)0x0141EF68, path, MAX_PATH);
|
||||
safe_strncpy((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, path, MAX_PATH);
|
||||
|
||||
safe_strncpy(gScenarioSaveName, path_get_filename(path), MAX_PATH);
|
||||
path_remove_extension(gScenarioSaveName);
|
||||
safe_strncpy(gScenarioSavePath, path, MAX_PATH);
|
||||
|
||||
SDL_RWops* rw = SDL_RWFromFile(path, "rb");
|
||||
if (rw == NULL) {
|
||||
|
@ -1033,19 +1032,12 @@ static int show_save_game_dialog(char *resultPath)
|
|||
void save_game()
|
||||
{
|
||||
if (!gFirstTimeSave) {
|
||||
utf8 path[MAX_PATH];
|
||||
log_verbose("Saving to %s", gScenarioSavePath);
|
||||
|
||||
log_verbose("Saving to %s", gScenarioSaveName);
|
||||
|
||||
platform_get_user_directory(path, "save");
|
||||
|
||||
strcat(path, gScenarioSaveName);
|
||||
strcat(path, ".sv6");
|
||||
|
||||
SDL_RWops* rw = SDL_RWFromFile(path, "wb+");
|
||||
SDL_RWops* rw = SDL_RWFromFile(gScenarioSavePath, "wb+");
|
||||
if (rw != NULL) {
|
||||
scenario_save(rw, 0x80000000);
|
||||
log_verbose("Saved to %s", gScenarioSaveName);
|
||||
log_verbose("Saved to %s", gScenarioSavePath);
|
||||
SDL_RWclose(rw);
|
||||
}
|
||||
} else {
|
||||
|
@ -1055,7 +1047,7 @@ void save_game()
|
|||
}
|
||||
void save_game_as()
|
||||
{
|
||||
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME, gScenarioSaveName);
|
||||
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME, gScenarioSavePath);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
static char _scenarioPath[MAX_PATH];
|
||||
static const char *_scenarioFileName = "";
|
||||
|
||||
char gScenarioSaveName[MAX_PATH];
|
||||
char gScenarioSavePath[MAX_PATH];
|
||||
int gFirstTimeSave = 1;
|
||||
|
||||
static int scenario_create_ducks();
|
||||
|
@ -354,9 +354,15 @@ void scenario_begin()
|
|||
}
|
||||
|
||||
// Set the last saved game path
|
||||
format_string(gScenarioSaveName, RCT2_GLOBAL(RCT2_ADDRESS_PARK_NAME, rct_string_id), (void*)RCT2_ADDRESS_PARK_NAME_ARGS);
|
||||
char parkName[128];
|
||||
format_string(parkName, RCT2_GLOBAL(RCT2_ADDRESS_PARK_NAME, rct_string_id), (void*)RCT2_ADDRESS_PARK_NAME_ARGS);
|
||||
|
||||
platform_get_user_directory(gScenarioSavePath, "save");
|
||||
strncat(gScenarioSavePath, parkName, sizeof(gScenarioSavePath));
|
||||
strncat(gScenarioSavePath, ".sv6", sizeof(gScenarioSavePath));
|
||||
|
||||
strcpy((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, (char*)RCT2_ADDRESS_SAVED_GAMES_PATH);
|
||||
strcpy((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2 + strlen((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2), gScenarioSaveName);
|
||||
strcpy((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2 + strlen((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2), gScenarioSavePath);
|
||||
strcat((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, ".SV6");
|
||||
|
||||
memset((void*)0x001357848, 0, 56);
|
||||
|
|
|
@ -412,7 +412,7 @@ extern int gScenarioListCount;
|
|||
extern int gScenarioListCapacity;
|
||||
extern rct_scenario_basic *gScenarioList;
|
||||
|
||||
extern char gScenarioSaveName[MAX_PATH];
|
||||
extern char gScenarioSavePath[MAX_PATH];
|
||||
extern int gFirstTimeSave;
|
||||
|
||||
int scenario_scores_save();
|
||||
|
|
|
@ -131,7 +131,7 @@ loadsave_list_item *_listItems = NULL;
|
|||
char _directory[MAX_PATH];
|
||||
char _shortenedDirectory[MAX_PATH];
|
||||
char _extension[32];
|
||||
char *_defaultName = NULL;
|
||||
char _defaultName[MAX_PATH];
|
||||
int _loadsaveType;
|
||||
int _type;
|
||||
|
||||
|
@ -153,7 +153,12 @@ rct_window *window_loadsave_open(int type, char *defaultName)
|
|||
int includeNewItem;
|
||||
rct_window* w;
|
||||
_type = type;
|
||||
_defaultName = defaultName;
|
||||
_defaultName[0] = 0;
|
||||
|
||||
if (!str_is_null_or_empty(defaultName)) {
|
||||
safe_strncpy(_defaultName, path_get_filename(defaultName), sizeof(_defaultName));
|
||||
path_remove_extension(_defaultName);
|
||||
}
|
||||
|
||||
w = window_bring_to_front_by_class(WC_LOADSAVE);
|
||||
if (w == NULL) {
|
||||
|
@ -769,8 +774,7 @@ static void window_loadsave_select(rct_window *w, const char *path)
|
|||
network_begin_server(gConfigNetwork.default_port);
|
||||
}
|
||||
|
||||
safe_strncpy(gScenarioSaveName, path_get_filename(path), MAX_PATH);
|
||||
path_remove_extension(gScenarioSaveName);
|
||||
safe_strncpy(gScenarioSavePath, path, MAX_PATH);
|
||||
gFirstTimeSave = 0;
|
||||
|
||||
window_close(w);
|
||||
|
@ -791,8 +795,7 @@ static void window_loadsave_select(rct_window *w, const char *path)
|
|||
SDL_RWclose(rw);
|
||||
if (success) {
|
||||
|
||||
safe_strncpy(gScenarioSaveName, path_get_filename(path), MAX_PATH);
|
||||
path_remove_extension(gScenarioSaveName);
|
||||
safe_strncpy(gScenarioSavePath, path, MAX_PATH);
|
||||
gFirstTimeSave = 0;
|
||||
|
||||
window_close_by_class(WC_LOADSAVE);
|
||||
|
|
Loading…
Reference in New Issue