diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 63f808a32..f3d80317f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ D1X-Rebirth Changelog 20100719 -------- misc/hmp.c: Did not close hmp after MIDI conversion which caused some unfree memory - fixed +main/gameseq.c, main/state.c, main/state.h: Introduced state_quick_item so we can safly check if there is a valid quicksave slot wihtout messing around with state_Default_item which is supposed to always show a valid slot in the first place 20100718 -------- diff --git a/main/gameseq.c b/main/gameseq.c index 73d34e2ee..27ab29e2f 100644 --- a/main/gameseq.c +++ b/main/gameseq.c @@ -731,12 +731,11 @@ void InitPlayerObject() } extern void game_disable_cheats(); -extern int state_default_item; //starts a new game on the given level void StartNewGame(int start_level) { - state_default_item = -2; // for first blind save, pick slot to save in + state_quick_item = -1; // for first blind save, pick slot to save in Game_mode = GM_NORMAL; diff --git a/main/state.c b/main/state.c index f5065d02b..f7f9031d4 100644 --- a/main/state.c +++ b/main/state.c @@ -147,7 +147,10 @@ void rpad_string( char * string, int max_chars ) } #endif -int state_default_item = 0; +static int state_default_item = 0; +//Since state_default_item should ALWAYS point to a valid savegame slot, we use this to check if we once already actually SAVED a game. If yes, state_quick_item will be equal state_default_item, otherwise it should be -1 on every new mission and tell us we need to select a slot for quicksave. +int state_quick_item = -1; + /* Present a menu for selection of a savegame filename. * For saving, dsc should be a pre-allocated buffer into which the new @@ -212,11 +215,8 @@ int state_get_savegame_filename(char * fname, char * dsc, char * caption, int bl sc_last_item = -1; - if (blind_save && state_default_item < 0) - { + if (blind_save && state_quick_item < 0) blind_save = 0; // haven't picked a slot yet - state_default_item = 0; - } if (blind_save) choice = state_default_item + 1; @@ -231,7 +231,7 @@ int state_get_savegame_filename(char * fname, char * dsc, char * caption, int bl if (choice > 0) { strcpy( fname, filename[choice-1] ); if ( dsc != NULL ) strcpy( dsc, desc[choice-1] ); - state_default_item = choice - 1; + state_quick_item = state_default_item = choice - 1; return choice; } return 0; diff --git a/main/state.h b/main/state.h index 9bdf63638..e73f5e21f 100644 --- a/main/state.h +++ b/main/state.h @@ -32,6 +32,7 @@ int state_save_all_sub(char *filename, char *desc, int between_levels); int state_restore_all_sub(char *filename); extern uint state_game_id; +extern int state_quick_item; int state_get_save_file(char * fname, char * dsc, int blind_save); int state_get_restore_file(char * fname );