fixed compiler warnings (after adding "-Wmissing-prototypes")
[rocksndiamonds.git] / src / files.c
index 266ef708c43fe0db8c4936612b92bd0f8a3a40a9..4ca23663e68e4bfbd4101ec9aa522a6e57a94b37 100644 (file)
@@ -251,6 +251,12 @@ static struct LevelFileConfigInfo chunk_config_INFO[] =
     &li.auto_count_gems,               FALSE
   },
 
+  {
+    -1,                                        -1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(11),
+    &li.solved_by_one_player,          FALSE
+  },
+
   {
     -1,                                        -1,
     -1,                                        -1,
@@ -1398,7 +1404,7 @@ static boolean check_special_flags(char *flag)
   return FALSE;
 }
 
-static struct DateInfo getCurrentDate()
+static struct DateInfo getCurrentDate(void)
 {
   time_t epoch_seconds = time(NULL);
   struct tm *now = localtime(&epoch_seconds);
@@ -1421,7 +1427,7 @@ static void resetEventFlags(struct ElementChangeInfo *change)
     change->has_event[i] = FALSE;
 }
 
-static void resetEventBits()
+static void resetEventBits(void)
 {
   int i;
 
@@ -1862,7 +1868,7 @@ static void setFileInfoToDefaults(struct LevelFileInfo *level_file_info)
 
 int getMappedElement_SB(int, boolean);
 
-static void ActivateLevelTemplate()
+static void ActivateLevelTemplate(void)
 {
   int x, y;
 
@@ -2153,12 +2159,12 @@ static int getFiletypeFromID(char *filetype_id)
   return filetype;
 }
 
-char *getLocalLevelTemplateFilename()
+char *getLocalLevelTemplateFilename(void)
 {
   return getDefaultLevelFilename(-1);
 }
 
-char *getGlobalLevelTemplateFilename()
+char *getGlobalLevelTemplateFilename(void)
 {
   /* global variable "leveldir_current" must be modified in the loop below */
   LevelDirTree *leveldir_current_last = leveldir_current;
@@ -2305,7 +2311,7 @@ static void copyLevelFileInfo(struct LevelFileInfo *lfi_from,
 /* functions for loading R'n'D level                                         */
 /* ------------------------------------------------------------------------- */
 
-int getMappedElement(int element)
+static int getMappedElement(int element)
 {
   /* remap some (historic, now obsolete) elements */
 
@@ -2356,7 +2362,7 @@ int getMappedElement(int element)
   return element;
 }
 
-int getMappedElementByVersion(int element, int game_version)
+static int getMappedElementByVersion(int element, int game_version)
 {
   /* remap some elements due to certain game version */
 
@@ -3478,7 +3484,7 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level,
 /* functions for loading EM level                                            */
 /* ------------------------------------------------------------------------- */
 
-void CopyNativeLevel_RND_to_EM(struct LevelInfo *level)
+static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level)
 {
   static int ball_xy[8][2] =
   {
@@ -3606,7 +3612,7 @@ void CopyNativeLevel_RND_to_EM(struct LevelInfo *level)
   }
 }
 
-void CopyNativeLevel_EM_to_RND(struct LevelInfo *level)
+static void CopyNativeLevel_EM_to_RND(struct LevelInfo *level)
 {
   static int ball_xy[8][2] =
   {
@@ -3707,7 +3713,7 @@ void CopyNativeLevel_EM_to_RND(struct LevelInfo *level)
 /* functions for loading SP level                                            */
 /* ------------------------------------------------------------------------- */
 
-void CopyNativeLevel_RND_to_SP(struct LevelInfo *level)
+static void CopyNativeLevel_RND_to_SP(struct LevelInfo *level)
 {
   struct LevelInfo_SP *level_sp = level->native_sp_level;
   LevelInfoType *header = &level_sp->header;
@@ -3791,7 +3797,7 @@ void CopyNativeLevel_RND_to_SP(struct LevelInfo *level)
   }
 }
 
-void CopyNativeLevel_SP_to_RND(struct LevelInfo *level)
+static void CopyNativeLevel_SP_to_RND(struct LevelInfo *level)
 {
   struct LevelInfo_SP *level_sp = level->native_sp_level;
   LevelInfoType *header = &level_sp->header;
@@ -3951,7 +3957,7 @@ static void CopyNativeTape_RND_to_SP(struct LevelInfo *level)
   demo->is_available = TRUE;
 }
 
-static void setTapeInfoToDefaults();
+static void setTapeInfoToDefaults(void);
 
 static void CopyNativeTape_SP_to_RND(struct LevelInfo *level)
 {
@@ -4004,7 +4010,7 @@ static void CopyNativeTape_SP_to_RND(struct LevelInfo *level)
 /* functions for loading MM level                                            */
 /* ------------------------------------------------------------------------- */
 
-void CopyNativeLevel_RND_to_MM(struct LevelInfo *level)
+static void CopyNativeLevel_RND_to_MM(struct LevelInfo *level)
 {
   struct LevelInfo_MM *level_mm = level->native_mm_level;
   int x, y;
@@ -4041,7 +4047,7 @@ void CopyNativeLevel_RND_to_MM(struct LevelInfo *level)
        level_mm->field[x][y] = map_element_RND_to_MM(level->field[x][y]);
 }
 
-void CopyNativeLevel_MM_to_RND(struct LevelInfo *level)
+static void CopyNativeLevel_MM_to_RND(struct LevelInfo *level)
 {
   struct LevelInfo_MM *level_mm = level->native_mm_level;
   int x, y;
@@ -4087,7 +4093,8 @@ void CopyNativeLevel_MM_to_RND(struct LevelInfo *level)
 
 #define DC_LEVEL_HEADER_SIZE           344
 
-unsigned short getDecodedWord_DC(unsigned short data_encoded, boolean init)
+static unsigned short getDecodedWord_DC(unsigned short data_encoded,
+                                       boolean init)
 {
   static int last_data_encoded;
   static int offset1;
@@ -4126,7 +4133,7 @@ unsigned short getDecodedWord_DC(unsigned short data_encoded, boolean init)
   return data_decoded;
 }
 
-int getMappedElement_DC(int element)
+static int getMappedElement_DC(int element)
 {
   switch (element)
   {
@@ -6395,6 +6402,10 @@ static void LoadLevel_InitVersion(struct LevelInfo *level)
   /* EM style elements always chain-exploded in R'n'D engine before 3.2.6 */
   if (level->game_version < VERSION_IDENT(3,2,6,0))
     level->em_explodes_by_fire = TRUE;
+
+  /* levels were solved by the first player entering an exit up to 4.1.0.0 */
+  if (level->game_version <= VERSION_IDENT(4,1,0,0))
+    level->solved_by_one_player = TRUE;
 }
 
 static void LoadLevel_InitStandardElements(struct LevelInfo *level)
@@ -6596,7 +6607,7 @@ static void LoadLevel_InitNativeEngines(struct LevelInfo *level)
     CopyNativeLevel_RND_to_Native(level);
 }
 
-static void LoadLevelTemplate_LoadAndInit()
+static void LoadLevelTemplate_LoadAndInit(void)
 {
   LoadLevelFromFileInfo(&level_template, &level_template.file_info, FALSE);
 
@@ -6620,21 +6631,21 @@ void LoadLevelTemplate(int nr)
   LoadLevelTemplate_LoadAndInit();
 }
 
-static void LoadLevelTemplateFromNetwork(struct LevelFileInfo *lfi_network_template)
+static void LoadNetworkLevelTemplate(struct NetworkLevelInfo *network_level)
 {
-  copyLevelFileInfo(lfi_network_template, &level_template.file_info);
+  copyLevelFileInfo(&network_level->tmpl_info, &level_template.file_info);
 
   LoadLevelTemplate_LoadAndInit();
 }
 
-static void LoadLevel_LoadAndInit(struct LevelFileInfo *lfi_network_template)
+static void LoadLevel_LoadAndInit(struct NetworkLevelInfo *network_level)
 {
   LoadLevelFromFileInfo(&level, &level.file_info, FALSE);
 
   if (level.use_custom_template)
   {
-    if (lfi_network_template != NULL)
-      LoadLevelTemplateFromNetwork(lfi_network_template);
+    if (network_level != NULL)
+      LoadNetworkLevelTemplate(network_level);
     else
       LoadLevelTemplate(-1);
   }
@@ -6662,12 +6673,14 @@ void LoadLevelInfoOnly(int nr)
   LoadLevelFromFileInfo(&level, &level.file_info, TRUE);
 }
 
-void LoadLevelFromNetwork(struct LevelFileInfo *lfi_network_level,
-                         struct LevelFileInfo *lfi_network_template)
+void LoadNetworkLevel(struct NetworkLevelInfo *network_level)
 {
-  copyLevelFileInfo(lfi_network_level, &level.file_info);
+  SetLevelSetInfo(network_level->leveldir_identifier,
+                 network_level->file_info.nr);
+
+  copyLevelFileInfo(&network_level->file_info, &level.file_info);
 
-  LoadLevel_LoadAndInit(lfi_network_template);
+  LoadLevel_LoadAndInit(network_level);
 }
 
 static int SaveLevel_VERS(FILE *file, struct LevelInfo *level)
@@ -7502,7 +7515,7 @@ void SaveLevel(int nr)
   SaveLevelFromFilename(&level, filename, FALSE);
 }
 
-void SaveLevelTemplate()
+void SaveLevelTemplate(void)
 {
   char *filename = getLocalLevelTemplateFilename();
 
@@ -7572,7 +7585,7 @@ void DumpLevel(struct LevelInfo *level)
 /* tape file functions                                                       */
 /* ========================================================================= */
 
-static void setTapeInfoToDefaults()
+static void setTapeInfoToDefaults(void)
 {
   int i;
 
@@ -7772,7 +7785,7 @@ static int LoadTape_BODY(File *file, int chunk_size, struct TapeInfo *tape)
   return chunk_size;
 }
 
-void LoadTape_SokobanSolution(char *filename)
+static void LoadTape_SokobanSolution(char *filename)
 {
   File *file;
   int move_delay = TILESIZE / level.initial_player_stepsize[0];
@@ -9266,7 +9279,7 @@ void LoadSetupFromFilename(char *filename)
   }
 }
 
-static void LoadSetup_SpecialPostProcessing()
+static void LoadSetup_SpecialPostProcessing(void)
 {
   char *player_name_new;
 
@@ -9287,7 +9300,7 @@ static void LoadSetup_SpecialPostProcessing()
     MIN(MAX(MIN_SCROLL_DELAY, setup.scroll_delay_value), MAX_SCROLL_DELAY);
 }
 
-void LoadSetup()
+void LoadSetup(void)
 {
   char *filename;
 
@@ -9308,7 +9321,7 @@ void LoadSetup()
   LoadSetup_SpecialPostProcessing();
 }
 
-void LoadSetup_AutoSetup()
+void LoadSetup_AutoSetup(void)
 {
   char *filename = getPath2(getSetupDir(), AUTOSETUP_FILENAME);
   SetupFileHash *setup_file_hash = NULL;
@@ -9328,7 +9341,7 @@ void LoadSetup_AutoSetup()
   free(filename);
 }
 
-void LoadSetup_EditorCascade()
+void LoadSetup_EditorCascade(void)
 {
   char *filename = getPath2(getSetupDir(), EDITORCASCADE_FILENAME);
   SetupFileHash *setup_file_hash = NULL;
@@ -9397,7 +9410,7 @@ static void LoadSetup_ReadGameControllerMappings(SetupFileHash *mappings_hash,
   fclose(file);
 }
 
-void SaveSetup()
+void SaveSetup(void)
 {
   char *filename = getSetupFilename();
   FILE *file;
@@ -9510,7 +9523,7 @@ void SaveSetup()
   SetFilePermissions(filename, PERMS_PRIVATE);
 }
 
-void SaveSetup_AutoSetup()
+void SaveSetup_AutoSetup(void)
 {
   char *filename = getPath2(getSetupDir(), AUTOSETUP_FILENAME);
   FILE *file;
@@ -9538,7 +9551,7 @@ void SaveSetup_AutoSetup()
   free(filename);
 }
 
-void SaveSetup_EditorCascade()
+void SaveSetup_EditorCascade(void)
 {
   char *filename = getPath2(getSetupDir(), EDITORCASCADE_FILENAME);
   FILE *file;
@@ -9607,7 +9620,7 @@ void SaveSetup_AddGameControllerMapping(char *mapping)
   free(filename);
 }
 
-void LoadCustomElementDescriptions()
+void LoadCustomElementDescriptions(void)
 {
   char *filename = getCustomArtworkConfigFilename(ARTWORK_TYPE_GRAPHICS);
   SetupFileHash *setup_file_hash;
@@ -9669,7 +9682,7 @@ static int get_token_parameter_value(char *token, char *value_raw)
   return get_parameter_value(value_raw, suffix, TYPE_INTEGER);
 }
 
-void InitMenuDesignSettings_Static()
+void InitMenuDesignSettings_Static(void)
 {
   int i;
 
@@ -9684,7 +9697,7 @@ void InitMenuDesignSettings_Static()
   }
 }
 
-static void InitMenuDesignSettings_SpecialPreProcessing()
+static void InitMenuDesignSettings_SpecialPreProcessing(void)
 {
   int i;
 
@@ -9776,7 +9789,7 @@ static void InitMenuDesignSettings_SpecialPreProcessing()
   }
 }
 
-static void InitMenuDesignSettings_SpecialPostProcessing()
+static void InitMenuDesignSettings_SpecialPostProcessing(void)
 {
   static struct
   {
@@ -9805,7 +9818,7 @@ static void InitMenuDesignSettings_SpecialPostProcessing()
       *game_buttons_xy[i].dst = *game_buttons_xy[i].src;
 }
 
-static void InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics()
+static void InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics(void)
 {
   static struct
   {
@@ -10239,7 +10252,7 @@ static void LoadMenuDesignSettingsFromFilename(char *filename)
   freeSetupFileHash(setup_file_hash);
 }
 
-void LoadMenuDesignSettings()
+void LoadMenuDesignSettings(void)
 {
   char *filename_base = UNDEFINED_FILENAME, *filename_local;
 
@@ -10263,7 +10276,7 @@ void LoadMenuDesignSettings()
   InitMenuDesignSettings_SpecialPostProcessing();
 }
 
-void LoadMenuDesignSettings_AfterGraphics()
+void LoadMenuDesignSettings_AfterGraphics(void)
 {
   InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics();
 }
@@ -10465,7 +10478,7 @@ static boolean sound_info_listed(struct MusicFileInfo *list, char *basename)
   return music_info_listed_ext(list, basename, TRUE);
 }
 
-void LoadMusicInfo()
+void LoadMusicInfo(void)
 {
   char *music_directory = getCustomMusicDirectory();
   int num_music = getMusicListSize();
@@ -10592,8 +10605,8 @@ void LoadMusicInfo()
   }
 }
 
-void add_helpanim_entry(int element, int action, int direction, int delay,
-                       int *num_list_entries)
+static void add_helpanim_entry(int element, int action, int direction,
+                              int delay, int *num_list_entries)
 {
   struct HelpAnimInfo *new_list_entry;
   (*num_list_entries)++;
@@ -10609,7 +10622,7 @@ void add_helpanim_entry(int element, int action, int direction, int delay,
   new_list_entry->delay = delay;
 }
 
-void print_unknown_token(char *filename, char *token, int token_nr)
+static void print_unknown_token(char *filename, char *token, int token_nr)
 {
   if (token_nr == 0)
   {
@@ -10621,13 +10634,13 @@ void print_unknown_token(char *filename, char *token, int token_nr)
   Error(ERR_INFO, "- token: '%s'", token);
 }
 
-void print_unknown_token_end(int token_nr)
+static void print_unknown_token_end(int token_nr)
 {
   if (token_nr > 0)
     Error(ERR_INFO_LINE, "-");
 }
 
-void LoadHelpAnimInfo()
+void LoadHelpAnimInfo(void)
 {
   char *filename = getHelpAnimFilename();
   SetupFileList *setup_file_list = NULL, *list;
@@ -10837,7 +10850,7 @@ void LoadHelpAnimInfo()
 #endif
 }
 
-void LoadHelpTextInfo()
+void LoadHelpTextInfo(void)
 {
   char *filename = getHelpTextFilename();
   int i;
@@ -10879,7 +10892,7 @@ void LoadHelpTextInfo()
 
 #define MAX_NUM_CONVERT_LEVELS         1000
 
-void ConvertLevels()
+void ConvertLevels(void)
 {
   static LevelDirTree *convert_leveldir = NULL;
   static int convert_level_nr = -1;
@@ -10991,7 +11004,7 @@ void ConvertLevels()
 /* create and save images for use in level sketches (raw BMP format)         */
 /* ------------------------------------------------------------------------- */
 
-void CreateLevelSketchImages()
+void CreateLevelSketchImages(void)
 {
 #if defined(TARGET_SDL)
   Bitmap *bitmap1;