Skip to content

Commit 40967f0

Browse files
committed
Engine: implemented "max_save" override option in config
This option is purposed to increase number of save slots available when playing older games. It affects standard save/restore dialogs filled with list of saves. It won't (and technically cannot) affect any custom made save system.
1 parent c205aa7 commit 40967f0

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

Engine/ac/game.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,16 @@ ScriptDateTime* Game_GetSaveSlotTime(int slnum)
426426
return sdt;
427427
}
428428

429-
void restore_game_dialog() {
429+
void restore_game_dialog()
430+
{
430431
restore_game_dialog2(1, LEGACY_TOP_BUILTINDIALOGSAVESLOT);
431432
}
432433

433-
void restore_game_dialog2(int min_slot, int max_slot) {
434+
void restore_game_dialog2(int min_slot, int max_slot)
435+
{
436+
// Optionally override the max slot
437+
max_slot = usetup.max_save_slot > 0 ? usetup.max_save_slot : max_slot;
438+
434439
can_run_delayed_command();
435440
if (thisroom.Options.SaveLoadDisabled == 1) {
436441
DisplayMessage(983);
@@ -443,7 +448,8 @@ void restore_game_dialog2(int min_slot, int max_slot) {
443448
do_restore_game_dialog(min_slot, max_slot);
444449
}
445450

446-
bool do_restore_game_dialog(int min_slot, int max_slot) {
451+
bool do_restore_game_dialog(int min_slot, int max_slot)
452+
{
447453
setup_for_dialog();
448454
int toload = loadgamedialog(min_slot, max_slot);
449455
restore_after_dialog();
@@ -452,11 +458,16 @@ bool do_restore_game_dialog(int min_slot, int max_slot) {
452458
return toload >= 0;
453459
}
454460

455-
void save_game_dialog() {
461+
void save_game_dialog()
462+
{
456463
save_game_dialog2(1, LEGACY_TOP_BUILTINDIALOGSAVESLOT);
457464
}
458465

459-
void save_game_dialog2(int min_slot, int max_slot) {
466+
void save_game_dialog2(int min_slot, int max_slot)
467+
{
468+
// Optionally override the max slot
469+
max_slot = usetup.max_save_slot > 0 ? usetup.max_save_slot : max_slot;
470+
460471
if (thisroom.Options.SaveLoadDisabled == 1) {
461472
DisplayMessage(983);
462473
return;

Engine/ac/gamesetup.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ struct GameSetup
121121
// is not implemented (or does not work correctly).
122122
int key_save_game = 0;
123123
int key_restore_game = 0;
124+
// Optional override for the max save slot
125+
int max_save_slot = 0;
124126

125127
// Accessibility settings and overrides;
126128
// these are meant to make playing the game easier, by modifying certain

Engine/ac/listbox.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <allegro.h> // find files
1818
#include "ac/common.h"
1919
#include "ac/game.h"
20+
#include "ac/gamesetup.h"
2021
#include "ac/gamesetupstruct.h"
2122
#include "ac/gamestate.h"
2223
#include "ac/global_game.h"
@@ -163,6 +164,9 @@ int ListBox_GetSaveGameSlots(GUIListBox *listbox, int index) {
163164

164165
int ListBox_FillSaveGameList2(GUIListBox *listbox, int min_slot, int max_slot)
165166
{
167+
// Optionally override the max slot
168+
max_slot = usetup.max_save_slot > 0 ? usetup.max_save_slot : max_slot;
169+
166170
max_slot = std::min(max_slot, TOP_SAVESLOT);
167171
min_slot = std::min(max_slot, std::max(0, min_slot));
168172

Engine/main/config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ void apply_config(const ConfigTree &cfg)
412412
usetup.override_upscale = CfgReadBoolInt(cfg, "override", "upscale", usetup.override_upscale);
413413
usetup.key_save_game = CfgReadInt(cfg, "override", "save_game_key", 0);
414414
usetup.key_restore_game = CfgReadInt(cfg, "override", "restore_game_key", 0);
415+
usetup.max_save_slot = CfgReadInt(cfg, "override", "max_save", 0);
415416

416417
// Accessibility settings
417418
usetup.access_speechskip = parse_speechskip_style(CfgReadString(cfg, "access", "speechskip"));

OPTIONS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Locations of two latter files differ between running platforms:
128128
* mac - MacOS.
129129
* legacysave_assume_dataver = \[integer\] - when restoring a save of a legacy format, lets engine assume certain game data version ID. This may be necessary because of a mistake in pre-3.5.0 save formats, where contents depended on a game data version rather than a save version.
130130
* legacysave_let_gui_diff = \[0; 1\] - when restoring a save of a legacy format, lets engine read less gui elements than are registered by the current game. This was a (possibly unintended) effect in pre-3.5.0 save format.
131+
* max_save = \[integer\] - topmost save slot that may be used in a standard save/restore dialog in game. This affects only built-in dialogs and listboxes filled by FillSaveGameList() script command. This does not and cannot affect any other custom scripted save systems.
131132
* restore_game_key = \[integer\] - key for calling built-in restore game dialog. Key value corresponds to the [AGS script keycode](https://github.com/adventuregamestudio/ags-manual/wiki/Keycodes).
132133
* save_game_key = \[integer\] - key for calling built-in save game dialog.
133134
* upscale = \[0; 1\] - run game in the "upscale mode". The earlier versions of AGS provided support for "upscaling" low-res games to hi-res. The script API has means for detecting if the game is running upscaled, and game developer could use this opportunity to setup game accordingly (e.g. assign hi-res fonts, etc). This options works **only** for games created before AGS 3.1.0 with low-res native resolution, such as 320x200 or 320x240, and it may somewhat improve

0 commit comments

Comments
 (0)