added optional button to restart game (door, panel and touch variants)
[rocksndiamonds.git] / src / game_sp / file.c
index a1ff3e80cc7769d03aa9e38c67a1dca064c936bf..a66187c582f5d04f6b13dcbaea72a6d8036eec63 100644 (file)
@@ -19,8 +19,6 @@ void setLevelInfoToDefaults_SP(void)
   char *empty_title = "-------- EMPTY --------";
   int i, x, y;
 
-  native_sp_level.game_sp = &game_sp;
-
   native_sp_level.width  = SP_STD_PLAYFIELD_WIDTH;
   native_sp_level.height = SP_STD_PLAYFIELD_HEIGHT;
 
@@ -142,8 +140,8 @@ static void LoadNativeLevelFromFileStream_SP(File *file, int width, int height,
   LevelInfoType *header = &native_sp_level.header;
   int i, x, y;
 
-  /* for details of the Supaplex level format, see Herman Perk's Supaplex
-     documentation file "SPFIX63.DOC" from his Supaplex "SpeedFix" package */
+  // for details of the Supaplex level format, see Herman Perk's Supaplex
+  // documentation file "SPFIX63.DOC" from his Supaplex "SpeedFix" package
 
   native_sp_level.width  = MIN(width,  SP_MAX_PLAYFIELD_WIDTH);
   native_sp_level.height = MIN(height, SP_MAX_PLAYFIELD_HEIGHT);
@@ -179,9 +177,9 @@ static void LoadNativeLevelFromFileStream_SP(File *file, int width, int height,
   // initial "freeze zonks": 2 == "on", anything else (0, 1) == "off"
   header->InitialFreezeZonks = getFile8Bit(file);
 
-  /* number of infotrons needed; 0 means that Supaplex will count the total
-     amount of infotrons in the level and use the low byte of that number
-     (a multiple of 256 infotrons will result in "0 infotrons needed"!) */
+  // number of infotrons needed; 0 means that Supaplex will count the total
+  // amount of infotrons in the level and use the low byte of that number
+  // (a multiple of 256 infotrons will result in "0 infotrons needed"!)
   header->InfotronsNeeded = getFile8Bit(file);
 
   // number of special ("gravity") port entries below (maximum 10 allowed)
@@ -258,7 +256,7 @@ static void LoadNativeLevelFromFileStream_SP(File *file, int width, int height,
     }
 
     if (i >= SP_MAX_TAPE_LEN)
-      Error(ERR_WARN, "SP demo truncated: size exceeds maximum SP demo size %d",
+      Warn("SP demo truncated: size exceeds maximum SP demo size %d",
            SP_MAX_TAPE_LEN);
 
     native_sp_level.demo.length = i;
@@ -294,7 +292,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos,
   if (!(file = openFile(filename, MODE_READ)))
   {
     if (!level_info_only)
-      Error(ERR_WARN, "cannot open file '%s' -- using empty level", filename);
+      Warn("cannot open file '%s' -- using empty level", filename);
 
     return FALSE;
   }
@@ -310,8 +308,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos,
 
     if (!strEqual(mpx_chunk_name, "MPX "))
     {
-      Error(ERR_WARN, "cannot find MPX ID in file '%s' -- using empty level",
-           filename);
+      Warn("cannot find MPX ID in file '%s' -- using empty level", filename);
 
       return FALSE;
     }
@@ -320,8 +317,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos,
 
     if (mpx_version != 1)
     {
-      Error(ERR_WARN, "unknown MPX version in file '%s' -- using empty level",
-           filename);
+      Warn("unknown MPX version in file '%s' -- using empty level", filename);
 
       return FALSE;
     }
@@ -330,16 +326,14 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos,
 
     if (mpx_level_count < 1)
     {
-      Error(ERR_WARN, "no MPX levels found in file '%s' -- using empty level",
-           filename);
+      Warn("no MPX levels found in file '%s' -- using empty level", filename);
 
       return FALSE;
     }
 
     if (level_pos >= mpx_level_count)
     {
-      Error(ERR_WARN, "MPX level not found in file '%s' -- using empty level",
-           filename);
+      Warn("MPX level not found in file '%s' -- using empty level", filename);
 
       return FALSE;
     }
@@ -365,7 +359,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos,
   // position file stream to the requested level (in case of level package)
   if (seekFile(file, file_seek_pos, SEEK_SET) != 0)
   {
-    Error(ERR_WARN, "cannot fseek in file '%s' -- using empty level", filename);
+    Warn("cannot fseek in file '%s' -- using empty level", filename);
 
     return FALSE;
   }
@@ -418,8 +412,8 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos,
 
     if (!reading_multipart_level && !is_multipart_level)
     {
-      /* the current level is simply a normal single-part level, and we are
-        not reading a multi-part level yet, so return the level as it is */
+      // the current level is simply a normal single-part level, and we are
+      // not reading a multi-part level yet, so return the level as it is
 
       break;
     }
@@ -428,9 +422,9 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos,
 
     if (!reading_multipart_level && is_multipart_level && !is_first_part)
     {
-      /* this is a part of a multi-part level, but not the first part
-        (and we are not already reading parts of a multi-part level);
-        in this case, use an empty level instead of the single part */
+      // this is a part of a multi-part level, but not the first part
+      // (and we are not already reading parts of a multi-part level);
+      // in this case, use an empty level instead of the single part
 
       use_empty_level = TRUE;
 
@@ -444,9 +438,9 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos,
         !strEqualN(header->LevelTitle, multipart_level.header.LevelTitle,
                    SP_LEVEL_NAME_LEN)))
     {
-      /* we are already reading parts of a multi-part level, but this level is
-        either not a multi-part level, or a part of a different multi-part
-        level; in both cases, the multi-part level seems to be complete */
+      // we are already reading parts of a multi-part level, but this level is
+      // either not a multi-part level, or a part of a different multi-part
+      // level; in both cases, the multi-part level seems to be complete
 
       break;
     }
@@ -477,7 +471,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos,
     if (multipart_xpos * SP_STD_PLAYFIELD_WIDTH  > SP_MAX_PLAYFIELD_WIDTH ||
        multipart_ypos * SP_STD_PLAYFIELD_HEIGHT > SP_MAX_PLAYFIELD_HEIGHT)
     {
-      Error(ERR_WARN, "multi-part level is too big -- ignoring part of it");
+      Warn("multi-part level is too big -- ignoring part of it");
 
       break;
     }
@@ -507,7 +501,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos,
   {
     setLevelInfoToDefaults_SP();
 
-    Error(ERR_WARN, "single part of multi-part level -- using empty level");
+    Warn("single part of multi-part level -- using empty level");
   }
 
   if (reading_multipart_level)
@@ -526,7 +520,7 @@ void SaveNativeLevel_SP(char *filename)
 
   if (!(file = fopen(filename, MODE_WRITE)))
   {
-    Error(ERR_WARN, "cannot save native level file '%s'", filename);
+    Warn("cannot save native level file '%s'", filename);
 
     return;
   }