rnd-20060818-1-src
[rocksndiamonds.git] / src / files.c
index 152d6528b6648dcb164d9f1b7f41a4ca66f104a5..16fbe2bcfc8d79e111dd8bc012bb0eb3d1ea043a 100644 (file)
@@ -4743,7 +4743,7 @@ void LoadLevelFromFilename(struct LevelInfo *level, char *filename)
 
 static void LoadLevel_InitVersion(struct LevelInfo *level, char *filename)
 {
-  int i;
+  int i, j;
 
   if (leveldir_current == NULL)                /* only when dumping level */
     return;
@@ -4840,8 +4840,6 @@ static void LoadLevel_InitVersion(struct LevelInfo *level, char *filename)
   /* trigger settings did not exist before 3.1.0; set to default "any" */
   if (level->game_version < VERSION_IDENT(3,1,0,0))
   {
-    int i, j;
-
     /* correct "can move into acid" settings (all zero in old levels) */
 
     level->can_move_into_acid_bits = 0; /* nothing can move into acid */
@@ -4871,6 +4869,30 @@ static void LoadLevel_InitVersion(struct LevelInfo *level, char *filename)
       }
     }
   }
+
+#if 1
+  /* try to detect and fix "Snake Bite" levels, which are broken with 3.2.0 */
+  {
+    int element = EL_CUSTOM_START + 255;
+    struct ElementInfo *ei = &element_info[element];
+    struct ElementChangeInfo *change = &ei->change_page[0];
+
+    /* This is needed to fix a problem that was caused by a bugfix in function
+       game.c/CreateFieldExt() introduced with 3.2.0 that corrects the behaviour
+       when a custom element changes to EL_SOKOBAN_FIELD_PLAYER (before, it did
+       not replace walkable elements, but instead just placed the player on it,
+       without placing the Sokoban field under the player). Unfortunately, this
+       breaks "Snake Bite" style levels when the snake is halfway through a door
+       that just closes (the snake head is still alive and can be moved in this
+       case). This can be fixed by replacing the EL_SOKOBAN_FIELD_PLAYER by the
+       player (without Sokoban element) which then gets killed as designed). */
+
+    if ((strncmp(leveldir_current->identifier, "snake_bite", 10) == 0 ||
+        strncmp(ei->description, "pause b4 death", 14) == 0) &&
+       change->target_element == EL_SOKOBAN_FIELD_PLAYER)
+      change->target_element = EL_PLAYER_1;
+  }
+#endif
 }
 
 static void LoadLevel_InitElements(struct LevelInfo *level, char *filename)
@@ -6853,19 +6875,20 @@ void SaveScore(int nr)
 #define SETUP_TOKEN_SKIP_LEVELS                        14
 #define SETUP_TOKEN_TIME_LIMIT                 15
 #define SETUP_TOKEN_FULLSCREEN                 16
-#define SETUP_TOKEN_ASK_ON_ESCAPE              17
-#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR       18
-#define SETUP_TOKEN_QUICK_SWITCH               19
-#define SETUP_TOKEN_INPUT_ON_FOCUS             20
-#define SETUP_TOKEN_PREFER_AGA_GRAPHICS                21
-#define SETUP_TOKEN_GRAPHICS_SET               22
-#define SETUP_TOKEN_SOUNDS_SET                 23
-#define SETUP_TOKEN_MUSIC_SET                  24
-#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS    25
-#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS      26
-#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC       27
-
-#define NUM_GLOBAL_SETUP_TOKENS                        28
+#define SETUP_TOKEN_FULLSCREEN_MODE            17
+#define SETUP_TOKEN_ASK_ON_ESCAPE              18
+#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR       19
+#define SETUP_TOKEN_QUICK_SWITCH               20
+#define SETUP_TOKEN_INPUT_ON_FOCUS             21
+#define SETUP_TOKEN_PREFER_AGA_GRAPHICS                22
+#define SETUP_TOKEN_GRAPHICS_SET               23
+#define SETUP_TOKEN_SOUNDS_SET                 24
+#define SETUP_TOKEN_MUSIC_SET                  25
+#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS    26
+#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS      27
+#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC       28
+
+#define NUM_GLOBAL_SETUP_TOKENS                        29
 
 /* editor setup */
 #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH      0
@@ -6976,6 +6999,7 @@ static struct TokenInfo global_setup_tokens[] =
   { TYPE_SWITCH, &si.skip_levels,      "skip_levels"                   },
   { TYPE_SWITCH, &si.time_limit,       "time_limit"                    },
   { TYPE_SWITCH, &si.fullscreen,       "fullscreen"                    },
+  { TYPE_STRING, &si.fullscreen_mode,  "fullscreen_mode"               },
   { TYPE_SWITCH, &si.ask_on_escape,    "ask_on_escape"                 },
   { TYPE_SWITCH, &si.ask_on_escape_editor, "ask_on_escape_editor"      },
   { TYPE_SWITCH, &si.quick_switch,     "quick_player_switch"           },
@@ -7116,7 +7140,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->direct_draw = !si->double_buffering;
   si->scroll_delay = TRUE;
   si->soft_scrolling = TRUE;
-  si->fading = FALSE;
+  si->fading = TRUE;
   si->autorecord = TRUE;
   si->show_titlescreen = TRUE;
   si->quick_doors = FALSE;
@@ -7125,6 +7149,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->skip_levels = TRUE;
   si->time_limit = TRUE;
   si->fullscreen = FALSE;
+  si->fullscreen_mode = getStringCopy(DEFAULT_FULLSCREEN_MODE);
   si->ask_on_escape = TRUE;
   si->ask_on_escape_editor = TRUE;
   si->quick_switch = FALSE;