added setup value for maximum allowed engine snapshot memory usage
authorHolger Schemel <info@artsoft.org>
Sun, 12 Jun 2016 12:00:23 +0000 (14:00 +0200)
committerHolger Schemel <info@artsoft.org>
Sun, 12 Jun 2016 12:00:23 +0000 (14:00 +0200)
src/files.c
src/libgame/snapshot.c
src/libgame/snapshot.h
src/libgame/system.h

index edc1358edc4386ce944e6f6f3ecd84fbbf4cb9c1..97934c17f5dc1d13397c4aab2257310a3993f06a 100644 (file)
@@ -7900,41 +7900,42 @@ void SaveScore(int nr)
 #define SETUP_TOKEN_SCROLL_DELAY               6
 #define SETUP_TOKEN_SCROLL_DELAY_VALUE         7
 #define SETUP_TOKEN_ENGINE_SNAPSHOT_MODE       8
-#define SETUP_TOKEN_FADE_SCREENS               9
-#define SETUP_TOKEN_AUTORECORD                 10
-#define SETUP_TOKEN_SHOW_TITLESCREEN           11
-#define SETUP_TOKEN_QUICK_DOORS                        12
-#define SETUP_TOKEN_TEAM_MODE                  13
-#define SETUP_TOKEN_HANDICAP                   14
-#define SETUP_TOKEN_SKIP_LEVELS                        15
-#define SETUP_TOKEN_TIME_LIMIT                 16
-#define SETUP_TOKEN_FULLSCREEN                 17
-#define SETUP_TOKEN_WINDOW_SCALING_PERCENT     18
-#define SETUP_TOKEN_WINDOW_SCALING_QUALITY     19
-#define SETUP_TOKEN_SCREEN_RENDERING_MODE      20
-#define SETUP_TOKEN_ASK_ON_ESCAPE              21
-#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR       22
-#define SETUP_TOKEN_QUICK_SWITCH               23
-#define SETUP_TOKEN_INPUT_ON_FOCUS             24
-#define SETUP_TOKEN_PREFER_AGA_GRAPHICS                25
-#define SETUP_TOKEN_GAME_FRAME_DELAY           26
-#define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS    27
-#define SETUP_TOKEN_SMALL_GAME_GRAPHICS                28
-#define SETUP_TOKEN_SHOW_SNAPSHOT_BUTTONS      29
-#define SETUP_TOKEN_GRAPHICS_SET               30
-#define SETUP_TOKEN_SOUNDS_SET                 31
-#define SETUP_TOKEN_MUSIC_SET                  32
-#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS    33
-#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS      34
-#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC       35
-#define SETUP_TOKEN_VOLUME_SIMPLE              36
-#define SETUP_TOKEN_VOLUME_LOOPS               37
-#define SETUP_TOKEN_VOLUME_MUSIC               38
-#define SETUP_TOKEN_TOUCH_CONTROL_TYPE         39
-#define SETUP_TOKEN_TOUCH_MOVE_DISTANCE                40
-#define SETUP_TOKEN_TOUCH_DROP_DISTANCE                41
-
-#define NUM_GLOBAL_SETUP_TOKENS                        42
+#define SETUP_TOKEN_ENGINE_SNAPSHOT_MEMORY     9
+#define SETUP_TOKEN_FADE_SCREENS               10
+#define SETUP_TOKEN_AUTORECORD                 11
+#define SETUP_TOKEN_SHOW_TITLESCREEN           12
+#define SETUP_TOKEN_QUICK_DOORS                        13
+#define SETUP_TOKEN_TEAM_MODE                  14
+#define SETUP_TOKEN_HANDICAP                   15
+#define SETUP_TOKEN_SKIP_LEVELS                        16
+#define SETUP_TOKEN_TIME_LIMIT                 17
+#define SETUP_TOKEN_FULLSCREEN                 18
+#define SETUP_TOKEN_WINDOW_SCALING_PERCENT     19
+#define SETUP_TOKEN_WINDOW_SCALING_QUALITY     20
+#define SETUP_TOKEN_SCREEN_RENDERING_MODE      21
+#define SETUP_TOKEN_ASK_ON_ESCAPE              22
+#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR       23
+#define SETUP_TOKEN_QUICK_SWITCH               24
+#define SETUP_TOKEN_INPUT_ON_FOCUS             25
+#define SETUP_TOKEN_PREFER_AGA_GRAPHICS                26
+#define SETUP_TOKEN_GAME_FRAME_DELAY           27
+#define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS    28
+#define SETUP_TOKEN_SMALL_GAME_GRAPHICS                29
+#define SETUP_TOKEN_SHOW_SNAPSHOT_BUTTONS      30
+#define SETUP_TOKEN_GRAPHICS_SET               31
+#define SETUP_TOKEN_SOUNDS_SET                 32
+#define SETUP_TOKEN_MUSIC_SET                  33
+#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS    34
+#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS      35
+#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC       36
+#define SETUP_TOKEN_VOLUME_SIMPLE              37
+#define SETUP_TOKEN_VOLUME_LOOPS               38
+#define SETUP_TOKEN_VOLUME_MUSIC               39
+#define SETUP_TOKEN_TOUCH_CONTROL_TYPE         40
+#define SETUP_TOKEN_TOUCH_MOVE_DISTANCE                41
+#define SETUP_TOKEN_TOUCH_DROP_DISTANCE                42
+
+#define NUM_GLOBAL_SETUP_TOKENS                        43
 
 /* editor setup */
 #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH      0
@@ -8075,6 +8076,7 @@ static struct TokenInfo global_setup_tokens[] =
   { TYPE_SWITCH, &si.scroll_delay,            "scroll_delay"           },
   { TYPE_INTEGER,&si.scroll_delay_value,      "scroll_delay_value"     },
   { TYPE_STRING, &si.engine_snapshot_mode,    "engine_snapshot_mode"   },
+  { TYPE_INTEGER,&si.engine_snapshot_memory,  "engine_snapshot_memory" },
   { TYPE_SWITCH, &si.fade_screens,            "fade_screens"           },
   { TYPE_SWITCH, &si.autorecord,              "automatic_tape_recording"},
   { TYPE_SWITCH, &si.show_titlescreen,        "show_titlescreen"       },
@@ -8257,6 +8259,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->scroll_delay = TRUE;
   si->scroll_delay_value = STD_SCROLL_DELAY;
   si->engine_snapshot_mode = getStringCopy(STR_SNAPSHOT_MODE_DEFAULT);
+  si->engine_snapshot_memory = SNAPSHOT_MEMORY_DEFAULT;
   si->fade_screens = TRUE;
   si->autorecord = TRUE;
   si->show_titlescreen = TRUE;
index 1059eb954fc858616754b7f4722467fafd644400..a3c2162da54a73215557bdd025b9af5792f65db1 100644 (file)
 #define DEBUG_SNAPSHOTS                        0
 #endif
 
-#if DEBUG_SNAPSHOTS
-#define MAX_SNAPSHOT_BYTES             (50 * 1024 * 1024)
-#else
-#define MAX_SNAPSHOT_BYTES             (500 * 1024 * 1024)
-#endif
-
 static ListNode *snapshot_single = NULL;
 static ListNode *snapshot_list = NULL;
 static ListNode *snapshot_current = NULL;
@@ -204,7 +198,7 @@ void SaveSnapshotToList(ListNode *snapshot_buffers)
   num_snapshots++;
   next_snapshot_key++;
 
-  if (num_snapshot_bytes > MAX_SNAPSHOT_BYTES)
+  if (num_snapshot_bytes > setup.engine_snapshot_memory)
     ReduceSnapshotList();
 }
 
index 44afa7b045bd2533a76fac1b0fba9916c0ec540b..54ce381adda79421f8dfa7b273fc08c5d81a3c9b 100644 (file)
 #include "misc.h"
 
 
+#define SNAPSHOT_MEMORY_DEFAULT                (512 * 1024 * 1024)
+
 /* needed for comfortably saving engine snapshot buffers */
-#define ARGS_ADDRESS_AND_SIZEOF(x)             (&(x)), (sizeof(x))
+#define ARGS_ADDRESS_AND_SIZEOF(x)     (&(x)), (sizeof(x))
 
 struct SnapshotNodeInfo
 {
index 97fed8a27063cefca1b2c2b7729e1b8f5ecfcecb..4710ea17d0962de0101021f129a623ba1ff996a9 100644 (file)
@@ -1022,6 +1022,7 @@ struct SetupInfo
   boolean scroll_delay;
   boolean scroll_delay_value;
   char *engine_snapshot_mode;
+  int engine_snapshot_memory;
   boolean fade_screens;
   boolean autorecord;
   boolean show_titlescreen;