rnd-20091211-1-src
authorHolger Schemel <info@artsoft.org>
Thu, 10 Dec 2009 23:16:30 +0000 (00:16 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:58:09 +0000 (10:58 +0200)
* added token "special_flags" to "levelinfo.conf" (currently with the
  only recognized value "load_xsb_to_ces", doing the same as the flag
  "-Dload_xsb_to_ces" on the command line, but as a permanent flag for
  converting all elements in native (XSB) Sokoban level files to CEs)

12 files changed:
ChangeLog
src/conftime.h
src/files.c
src/game_sp/init.c
src/game_sp/main.c
src/libgame/misc.c
src/libgame/misc.h
src/libgame/setup.c
src/libgame/system.h
src/main.c
src/main.h
src/screens.c

index 70d304461e8b04e5fe568e8ec4d441e3462de1ab..467d8ca2da1d1d080c6a37efb679ed44c9aca8b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,17 @@
 2009-12-10
        * fixed bug with steel exit being destructible during opening phase
 2009-12-10
        * fixed bug with steel exit being destructible during opening phase
+       * added token "special_flags" to "levelinfo.conf" (currently with the
+         only recognized value "load_xsb_to_ces", doing the same as the flag
+         "-Dload_xsb_to_ces" on the command line, but as a permanent flag for
+         converting all elements in native (XSB) Sokoban level files to CEs)
 
 2009-12-08
        * fixed some problems with Supaplex engine when compiling for Windows
 
 2009-12-05
        * added special mode to convert elements of Sokoban XSB levels to CEs
 
 2009-12-08
        * fixed some problems with Supaplex engine when compiling for Windows
 
 2009-12-05
        * added special mode to convert elements of Sokoban XSB levels to CEs
+         by adding "-Dload_xsb_to_ces" to the command line starting the game
+         (also adding a dependency to a template level file "template.level")
 
 2009-12-01
        * added reading native Sokoban levels and level packages (XSB files)
 
 2009-12-01
        * added reading native Sokoban levels and level packages (XSB files)
index 468766a0c3052ecfa9a25a116cd540ce1a6cd402..d58b141b1a03d57d0a9b3518ae9093855ea8965e 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2009-12-10 14:59"
+#define COMPILE_DATE_STRING "2009-12-11 00:08"
index 80037699fc8ae90aacadcca7c13d8fc04d1cb747..b16bc6ca5162f709f799680056cdc331ca62ba17 100644 (file)
@@ -6331,6 +6331,40 @@ static void LoadLevelFromFileInfo_DC(struct LevelInfo *level,
 /* functions for loading SB level                                            */
 /* ------------------------------------------------------------------------- */
 
 /* functions for loading SB level                                            */
 /* ------------------------------------------------------------------------- */
 
+#if 1
+
+static boolean check_special_flags(char *flag)
+{
+#if 0
+  printf("::: '%s', '%s', '%s'\n",
+        flag,
+        options.special_flags,
+        leveldir_current->special_flags);
+#endif
+
+  if (strEqual(options.special_flags, flag) ||
+      strEqual(leveldir_current->special_flags, flag))
+    return TRUE;
+
+  return FALSE;
+}
+
+#else
+
+#define SPECIAL_FLAG_LOAD_XSB_TO_CES   (1 << 0)
+
+static unsigned long get_special_flags(char *flags_string)
+{
+  unsigned long flags_value = 0;
+
+  if (strEqual(flags_string, "load_xsb_to_ces"))
+    flags_value = SPECIAL_FLAG_LOAD_XSB_TO_CES;
+
+  return flags_value;
+}
+
+#endif
+
 int getMappedElement_SB(int element_ascii, boolean use_ces)
 {
   static struct
 int getMappedElement_SB(int element_ascii, boolean use_ces)
 {
   static struct
@@ -6376,7 +6410,11 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level,
   boolean reading_playfield = FALSE;
   boolean got_valid_playfield_line = FALSE;
   boolean invalid_playfield_char = FALSE;
   boolean reading_playfield = FALSE;
   boolean got_valid_playfield_line = FALSE;
   boolean invalid_playfield_char = FALSE;
-  boolean load_xsb_to_ces = options.cmd_switches & CMD_SWITCH_LOAD_XSB_TO_CES;
+#if 1
+  boolean load_xsb_to_ces = check_special_flags("load_xsb_to_ces");
+#else
+  boolean load_xsb_to_ces = options.special_flags & SPECIAL_FLAG_LOAD_XSB_TO_CES;
+#endif
   int file_level_nr = 0;
   int line_nr = 0;
   int x, y;
   int file_level_nr = 0;
   int line_nr = 0;
   int x, y;
index ee7034247ef27228fa77cc6e585a50d00b10412b..b3a1acb802bfb6bc60057ebb25c70b1908976cfa 100644 (file)
@@ -19,7 +19,7 @@ static void init_struct_functions()
 
 static void init_global_values()
 {
 
 static void init_global_values()
 {
-  menBorder.Checked = True * 0;
+  menBorder.Checked = False;
   menPanel.Checked = True;
   menAutoScroll.Checked = True;
 
   menPanel.Checked = True;
   menAutoScroll.Checked = True;
 
index bd24db8b62810a1bc20f1ee720b92263c1ba0988..d63d32a0f2966b9c6d1f18ddfa728c604ef51ecf 100644 (file)
@@ -11,6 +11,8 @@ void InitGameEngine_SP()
   game_sp_info.LevelSolved = FALSE;
   game_sp_info.GameOver = FALSE;
 
   game_sp_info.LevelSolved = FALSE;
   game_sp_info.GameOver = FALSE;
 
+  menBorder.Checked = setup.sp_show_border_elements;
+
   InitScrollPlayfield();
 
 #if 1
   InitScrollPlayfield();
 
 #if 1
index d21363cad99665ff029ee48bb9c94ec2739c59af..d4ebcda7025599fbaa0ae685b558685d60ef2311 100644 (file)
@@ -662,8 +662,7 @@ boolean strSuffixLower(char *s, char *suffix)
 /* command line option handling functions                                    */
 /* ------------------------------------------------------------------------- */
 
 /* command line option handling functions                                    */
 /* ------------------------------------------------------------------------- */
 
-void GetOptions(char *argv[], void (*print_usage_function)(void),
-               unsigned long (*get_cmd_switch_function)(char *))
+void GetOptions(char *argv[], void (*print_usage_function)(void))
 {
   char *ro_base_path = RO_BASE_PATH;
   char *rw_base_path = RW_BASE_PATH;
 {
   char *ro_base_path = RO_BASE_PATH;
   char *rw_base_path = RW_BASE_PATH;
@@ -694,7 +693,9 @@ void GetOptions(char *argv[], void (*print_usage_function)(void),
   options.sounds_directory   = getPath2(ro_base_path, SOUNDS_DIRECTORY);
   options.music_directory    = getPath2(ro_base_path, MUSIC_DIRECTORY);
   options.docs_directory     = getPath2(ro_base_path, DOCS_DIRECTORY);
   options.sounds_directory   = getPath2(ro_base_path, SOUNDS_DIRECTORY);
   options.music_directory    = getPath2(ro_base_path, MUSIC_DIRECTORY);
   options.docs_directory     = getPath2(ro_base_path, DOCS_DIRECTORY);
+
   options.execute_command = NULL;
   options.execute_command = NULL;
+  options.special_flags = NULL;
 
   options.serveronly = FALSE;
   options.network = FALSE;
 
   options.serveronly = FALSE;
   options.network = FALSE;
@@ -702,8 +703,6 @@ void GetOptions(char *argv[], void (*print_usage_function)(void),
   options.debug = FALSE;
   options.debug_x11_sync = FALSE;
 
   options.debug = FALSE;
   options.debug_x11_sync = FALSE;
 
-  options.cmd_switches = 0;
-
 #if !defined(PLATFORM_UNIX)
   if (*options_left == NULL)   /* no options given -- enable verbose mode */
     options.verbose = TRUE;
 #if !defined(PLATFORM_UNIX)
   if (*options_left == NULL)   /* no options given -- enable verbose mode */
     options.verbose = TRUE;
@@ -834,18 +833,22 @@ void GetOptions(char *argv[], void (*print_usage_function)(void),
     }
     else if (strPrefix(option, "-D"))
     {
     }
     else if (strPrefix(option, "-D"))
     {
-      char *switch_string = &option[2];
-      unsigned long switch_value;
+#if 1
+      options.special_flags = getStringCopy(&option[2]);
+#else
+      char *flags_string = &option[2];
+      unsigned long flags_value;
 
 
-      if (*switch_string == '\0')
-       Error(ERR_EXIT_HELP, "empty switch ignored");
+      if (*flags_string == '\0')
+       Error(ERR_EXIT_HELP, "empty flag ignored");
 
 
-      switch_value = get_cmd_switch_function(switch_string);
+      flags_value = get_special_flags_function(flags_string);
 
 
-      if (switch_value == 0)
-       Error(ERR_EXIT_HELP, "unknown switch '%s'", switch_string);
+      if (flags_value == 0)
+       Error(ERR_EXIT_HELP, "unknown flag '%s'", flags_string);
 
 
-      options.cmd_switches |= switch_value;
+      options.special_flags |= flags_value;
+#endif
     }
     else if (strncmp(option, "-execute", option_len) == 0)
     {
     }
     else if (strncmp(option, "-execute", option_len) == 0)
     {
index 8732a8cddf0a5c8ec500b13c66a937913475709d..6ac3d994c990a9fe74348168d3675b04b8b816bb 100644 (file)
@@ -113,8 +113,7 @@ boolean strSuffix(char *, char *);
 boolean strPrefixLower(char *, char *);
 boolean strSuffixLower(char *, char *);
 
 boolean strPrefixLower(char *, char *);
 boolean strSuffixLower(char *, char *);
 
-void GetOptions(char **, void (*print_usage_function)(void),
-               unsigned long (*get_cmd_switch_function)(char *));
+void GetOptions(char **, void (*print_usage_function)(void));
 
 void SetError(char *, ...);
 char *GetError(void);
 
 void SetError(char *, ...);
 char *GetError(void);
index 3e5392498dbdb63474df4b3e75b19c22488452d5..9e35b4dbe240b10e2ab93b8aaf7fc5b6c88429de 100644 (file)
@@ -2375,10 +2375,11 @@ void checkSetupFileHashIdentifier(SetupFileHash *setup_file_hash,
 #define LEVELINFO_TOKEN_MUSIC_SET              18
 #define LEVELINFO_TOKEN_FILENAME               19
 #define LEVELINFO_TOKEN_FILETYPE               20
 #define LEVELINFO_TOKEN_MUSIC_SET              18
 #define LEVELINFO_TOKEN_FILENAME               19
 #define LEVELINFO_TOKEN_FILETYPE               20
-#define LEVELINFO_TOKEN_HANDICAP               21
-#define LEVELINFO_TOKEN_SKIP_LEVELS            22
+#define LEVELINFO_TOKEN_SPECIAL_FLAGS          21
+#define LEVELINFO_TOKEN_HANDICAP               22
+#define LEVELINFO_TOKEN_SKIP_LEVELS            23
 
 
-#define NUM_LEVELINFO_TOKENS                   23
+#define NUM_LEVELINFO_TOKENS                   24
 
 static LevelDirTree ldi;
 
 
 static LevelDirTree ldi;
 
@@ -2406,6 +2407,7 @@ static struct TokenInfo levelinfo_tokens[] =
   { TYPE_STRING,       &ldi.music_set,         "music_set"             },
   { TYPE_STRING,       &ldi.level_filename,    "filename"              },
   { TYPE_STRING,       &ldi.level_filetype,    "filetype"              },
   { TYPE_STRING,       &ldi.music_set,         "music_set"             },
   { TYPE_STRING,       &ldi.level_filename,    "filename"              },
   { TYPE_STRING,       &ldi.level_filetype,    "filetype"              },
+  { TYPE_STRING,       &ldi.special_flags,     "special_flags"         },
   { TYPE_BOOLEAN,      &ldi.handicap,          "handicap"              },
   { TYPE_BOOLEAN,      &ldi.skip_levels,       "skip_levels"           }
 };
   { TYPE_BOOLEAN,      &ldi.handicap,          "handicap"              },
   { TYPE_BOOLEAN,      &ldi.skip_levels,       "skip_levels"           }
 };
@@ -2482,6 +2484,8 @@ static void setTreeInfoToDefaults(TreeInfo *ti, int type)
     ti->level_filename = NULL;
     ti->level_filetype = NULL;
 
     ti->level_filename = NULL;
     ti->level_filetype = NULL;
 
+    ti->special_flags = NULL;
+
     ti->levels = 0;
     ti->first_level = 0;
     ti->last_level = 0;
     ti->levels = 0;
     ti->first_level = 0;
     ti->last_level = 0;
@@ -2553,6 +2557,8 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ti, TreeInfo *parent)
     ti->level_filename = NULL;
     ti->level_filetype = NULL;
 
     ti->level_filename = NULL;
     ti->level_filetype = NULL;
 
+    ti->special_flags = getStringCopy(parent->special_flags);
+
     ti->levels = 0;
     ti->first_level = 0;
     ti->last_level = 0;
     ti->levels = 0;
     ti->first_level = 0;
     ti->last_level = 0;
@@ -2604,6 +2610,8 @@ static TreeInfo *getTreeInfoCopy(TreeInfo *ti)
   ti_copy->level_filename      = getStringCopy(ti->level_filename);
   ti_copy->level_filetype      = getStringCopy(ti->level_filetype);
 
   ti_copy->level_filename      = getStringCopy(ti->level_filename);
   ti_copy->level_filetype      = getStringCopy(ti->level_filetype);
 
+  ti_copy->special_flags       = getStringCopy(ti->special_flags);
+
   ti_copy->levels              = ti->levels;
   ti_copy->first_level         = ti->first_level;
   ti_copy->last_level          = ti->last_level;
   ti_copy->levels              = ti->levels;
   ti_copy->first_level         = ti->first_level;
   ti_copy->last_level          = ti->last_level;
@@ -2665,6 +2673,8 @@ static void freeTreeInfo(TreeInfo *ti)
 
     checked_free(ti->level_filename);
     checked_free(ti->level_filetype);
 
     checked_free(ti->level_filename);
     checked_free(ti->level_filetype);
+
+    checked_free(ti->special_flags);
   }
 
   checked_free(ti);
   }
 
   checked_free(ti);
index 42d0ee32b2972fb03fbcfbec79dc01c26396e129..26d192e396054a31b6341b8813328c0bf6e72bbe 100644 (file)
@@ -650,15 +650,16 @@ struct OptionInfo
   char *sounds_directory;
   char *music_directory;
   char *docs_directory;
   char *sounds_directory;
   char *music_directory;
   char *docs_directory;
+
   char *execute_command;
 
   char *execute_command;
 
+  char *special_flags;
+
   boolean serveronly;
   boolean network;
   boolean verbose;
   boolean debug;
   boolean debug_x11_sync;
   boolean serveronly;
   boolean network;
   boolean verbose;
   boolean debug;
   boolean debug_x11_sync;
-
-  unsigned long cmd_switches;
 };
 
 struct ScreenModeInfo
 };
 
 struct ScreenModeInfo
@@ -925,6 +926,8 @@ struct TreeInfo
   char *level_filename;        /* filename of level file (for packed level file) */
   char *level_filetype;        /* type of levels in level directory or level file */
 
   char *level_filename;        /* filename of level file (for packed level file) */
   char *level_filetype;        /* type of levels in level directory or level file */
 
+  char *special_flags; /* flags for special actions performed on level file */
+
   int levels;          /* number of levels in level series */
   int first_level;     /* first level number (to allow start with 0 or 1) */
   int last_level;      /* last level number (automatically calculated) */
   int levels;          /* number of levels in level series */
   int first_level;     /* first level number (to allow start with 0 or 1) */
   int last_level;      /* last level number (automatically calculated) */
index 5acf09fe627d151743b3beb5362c25cde2ce455d..f1ea104e361ad855d33dc45b9977f49fb2bac73f 100644 (file)
@@ -5509,16 +5509,6 @@ struct MusicPrefixInfo music_prefix_info[NUM_MUSIC_PREFIXES + 1] =
 /* main()                                                                    */
 /* ========================================================================= */
 
 /* main()                                                                    */
 /* ========================================================================= */
 
-static unsigned long get_cmd_switch(char *switch_string)
-{
-  unsigned long switch_value = 0;
-
-  if (strEqual(switch_string, "load_xsb_to_ces"))
-    switch_value = CMD_SWITCH_LOAD_XSB_TO_CES;
-
-  return switch_value;
-}
-
 static void print_usage()
 {
   printf("\n"
 static void print_usage()
 {
   printf("\n"
@@ -5567,7 +5557,7 @@ int main(int argc, char *argv[])
   InitExitFunction(CloseAllAndExit);
   InitPlatformDependentStuff();
 
   InitExitFunction(CloseAllAndExit);
   InitPlatformDependentStuff();
 
-  GetOptions(argv, print_usage, get_cmd_switch);
+  GetOptions(argv, print_usage);
   OpenAll();
 
   EventLoop();
   OpenAll();
 
   EventLoop();
index 0adf9f70bb298dce0858735fd43d2017f33611c9..e826e6d8589ae37908b45e41186660cc020a05fa 100644 (file)
@@ -31,8 +31,6 @@
 #include "conf_mus.h"  /* include auto-generated data structure definitions */
 
 
 #include "conf_mus.h"  /* include auto-generated data structure definitions */
 
 
-#define CMD_SWITCH_LOAD_XSB_TO_CES     (1 << 0)
-
 #define IMG_UNDEFINED                  (-1)
 #define IMG_EMPTY                      IMG_EMPTY_SPACE
 #define IMG_SP_EMPTY                   IMG_SP_EMPTY_SPACE
 #define IMG_UNDEFINED                  (-1)
 #define IMG_EMPTY                      IMG_EMPTY_SPACE
 #define IMG_SP_EMPTY                   IMG_SP_EMPTY_SPACE
index a9071d43b03806786e4247ec364ca38703436b61..34eec7468caa7ca501ff2a903757a82f8aa1a1b7 100644 (file)
@@ -757,10 +757,12 @@ static void InitializeTitleControls(boolean show_title_initial)
   num_title_screens = 0;
 
 #if 1
   num_title_screens = 0;
 
 #if 1
+  /* 1st step: initialize title screens for game start (only when starting) */
   if (show_title_initial)
     InitializeTitleControls_CheckTitleInfo(TRUE);
 #endif
 
   if (show_title_initial)
     InitializeTitleControls_CheckTitleInfo(TRUE);
 #endif
 
+  /* 2nd step: initialize title screens for current level set */
   InitializeTitleControls_CheckTitleInfo(FALSE);
 
   /* sort title screens according to sort_priority and title number */
   InitializeTitleControls_CheckTitleInfo(FALSE);
 
   /* sort title screens according to sort_priority and title number */