From: Holger Schemel Date: Sun, 12 Jun 2016 12:00:23 +0000 (+0200) Subject: added setup value for maximum allowed engine snapshot memory usage X-Git-Tag: 4.0.0.0-rc3~15 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=e73cc9fa0feac62a97f7bb0bf0346cdf2134c249;p=rocksndiamonds.git added setup value for maximum allowed engine snapshot memory usage --- diff --git a/src/files.c b/src/files.c index edc1358e..97934c17 100644 --- a/src/files.c +++ b/src/files.c @@ -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; diff --git a/src/libgame/snapshot.c b/src/libgame/snapshot.c index 1059eb95..a3c2162d 100644 --- a/src/libgame/snapshot.c +++ b/src/libgame/snapshot.c @@ -16,12 +16,6 @@ #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(); } diff --git a/src/libgame/snapshot.h b/src/libgame/snapshot.h index 44afa7b0..54ce381a 100644 --- a/src/libgame/snapshot.h +++ b/src/libgame/snapshot.h @@ -16,8 +16,10 @@ #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 { diff --git a/src/libgame/system.h b/src/libgame/system.h index 97fed8a2..4710ea17 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -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;