Skip to content

Commit

Permalink
Add Sfall AutoQuickSave (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
c6-dev authored Jun 16, 2023
1 parent 0ffcb10 commit cf98070
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/loadsave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "sfall_config.h"
#include "sfall_global_scripts.h"
#include "sfall_global_vars.h"
#include "skill.h"
Expand Down Expand Up @@ -328,6 +329,9 @@ static int gLoadSaveWindowOldFont;

static FrmImage _loadsaveFrmImages[LOAD_SAVE_FRM_COUNT];

static int quickSaveSlots = 0;
static bool autoQuickSaveSlots = false;

// 0x47B7E4
void _InitLoadSave()
{
Expand All @@ -338,6 +342,11 @@ void _InitLoadSave()
_MapDirErase("MAPS\\", "SAV");
_MapDirErase(PROTO_DIR_NAME "\\" CRITTERS_DIR_NAME "\\", PROTO_FILE_EXT);
_MapDirErase(PROTO_DIR_NAME "\\" ITEMS_DIR_NAME "\\", PROTO_FILE_EXT);

configGetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_AUTO_QUICK_SAVE, &quickSaveSlots);
if (quickSaveSlots > 0 && quickSaveSlots <= 10) {
autoQuickSaveSlots = true;
}
}

// 0x47B85C
Expand All @@ -359,7 +368,18 @@ int lsgSaveGame(int mode)
_ls_error_code = 0;
_patches = settings.system.master_patches_path.c_str();

// SFALL: skip slot selection if auto quicksave is enabled
if (autoQuickSaveSlots) {
_quick_done = true;
}

if (mode == LOAD_SAVE_MODE_QUICK && _quick_done) {
// SFALL: cycle through first N slots for quicksaving
if (autoQuickSaveSlots) {
if (++_slot_cursor >= quickSaveSlots) {
_slot_cursor = 0;
}
}
snprintf(_gmpath, sizeof(_gmpath), "%s\\%s%.2d\\", "SAVEGAME", "SLOT", _slot_cursor + 1);
strcat(_gmpath, "SAVE.DAT");

Expand Down
1 change: 1 addition & 0 deletions src/sfall_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ bool sfallConfigInit(int argc, char** argv)
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_MOVIE_TIMER_ARTIMER2, 180);
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_MOVIE_TIMER_ARTIMER3, 270);
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_MOVIE_TIMER_ARTIMER4, 360);
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_AUTO_QUICK_SAVE, 0);

configSetString(&gSfallConfig, SFALL_CONFIG_SCRIPTS_KEY, SFALL_CONFIG_INI_CONFIG_FOLDER, "");
configSetString(&gSfallConfig, SFALL_CONFIG_SCRIPTS_KEY, SFALL_CONFIG_GLOBAL_SCRIPT_PATHS, "");
Expand Down
1 change: 1 addition & 0 deletions src/sfall_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ namespace fallout {
#define SFALL_CONFIG_NUMBERS_IS_DIALOG_KEY "NumbersInDialogue"
#define SFALL_CONFIG_INI_CONFIG_FOLDER "IniConfigFolder"
#define SFALL_CONFIG_GLOBAL_SCRIPT_PATHS "GlobalScriptPaths"
#define SFALL_CONFIG_AUTO_QUICK_SAVE "AutoQuickSave"

#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_MULTIPLIER 1
#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_DIVISOR 3
Expand Down

0 comments on commit cf98070

Please sign in to comment.