From a312d80612bb9a448cdc1abbde690b296fa92b17 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 11 Dec 2009 00:16:30 +0100 Subject: [PATCH] rnd-20091211-1-src * 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) --- ChangeLog | 6 ++++++ src/conftime.h | 2 +- src/files.c | 40 +++++++++++++++++++++++++++++++++++++++- src/game_sp/init.c | 2 +- src/game_sp/main.c | 2 ++ src/libgame/misc.c | 27 +++++++++++++++------------ src/libgame/misc.h | 3 +-- src/libgame/setup.c | 16 +++++++++++++--- src/libgame/system.h | 7 +++++-- src/main.c | 12 +----------- src/main.h | 2 -- src/screens.c | 2 ++ 12 files changed, 86 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 70d30446..467d8ca2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,17 @@ 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 + 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) diff --git a/src/conftime.h b/src/conftime.h index 468766a0..d58b141b 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2009-12-10 14:59" +#define COMPILE_DATE_STRING "2009-12-11 00:08" diff --git a/src/files.c b/src/files.c index 80037699..b16bc6ca 100644 --- a/src/files.c +++ b/src/files.c @@ -6331,6 +6331,40 @@ static void LoadLevelFromFileInfo_DC(struct LevelInfo *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 @@ -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 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; diff --git a/src/game_sp/init.c b/src/game_sp/init.c index ee703424..b3a1acb8 100644 --- a/src/game_sp/init.c +++ b/src/game_sp/init.c @@ -19,7 +19,7 @@ static void init_struct_functions() static void init_global_values() { - menBorder.Checked = True * 0; + menBorder.Checked = False; menPanel.Checked = True; menAutoScroll.Checked = True; diff --git a/src/game_sp/main.c b/src/game_sp/main.c index bd24db8b..d63d32a0 100644 --- a/src/game_sp/main.c +++ b/src/game_sp/main.c @@ -11,6 +11,8 @@ void InitGameEngine_SP() game_sp_info.LevelSolved = FALSE; game_sp_info.GameOver = FALSE; + menBorder.Checked = setup.sp_show_border_elements; + InitScrollPlayfield(); #if 1 diff --git a/src/libgame/misc.c b/src/libgame/misc.c index d21363ca..d4ebcda7 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -662,8 +662,7 @@ boolean strSuffixLower(char *s, char *suffix) /* 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; @@ -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.execute_command = NULL; + options.special_flags = NULL; 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.cmd_switches = 0; - #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")) { - 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) { diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 8732a8cd..6ac3d994 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -113,8 +113,7 @@ boolean strSuffix(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); diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 3e539249..9e35b4db 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -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_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; @@ -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.special_flags, "special_flags" }, { 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->special_flags = NULL; + 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->special_flags = getStringCopy(parent->special_flags); + 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->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; @@ -2665,6 +2673,8 @@ static void freeTreeInfo(TreeInfo *ti) checked_free(ti->level_filename); checked_free(ti->level_filetype); + + checked_free(ti->special_flags); } checked_free(ti); diff --git a/src/libgame/system.h b/src/libgame/system.h index 42d0ee32..26d192e3 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -650,15 +650,16 @@ struct OptionInfo char *sounds_directory; char *music_directory; char *docs_directory; + char *execute_command; + char *special_flags; + boolean serveronly; boolean network; boolean verbose; boolean debug; boolean debug_x11_sync; - - unsigned long cmd_switches; }; 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 *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) */ diff --git a/src/main.c b/src/main.c index 5acf09fe..f1ea104e 100644 --- a/src/main.c +++ b/src/main.c @@ -5509,16 +5509,6 @@ struct MusicPrefixInfo music_prefix_info[NUM_MUSIC_PREFIXES + 1] = /* 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" @@ -5567,7 +5557,7 @@ int main(int argc, char *argv[]) InitExitFunction(CloseAllAndExit); InitPlatformDependentStuff(); - GetOptions(argv, print_usage, get_cmd_switch); + GetOptions(argv, print_usage); OpenAll(); EventLoop(); diff --git a/src/main.h b/src/main.h index 0adf9f70..e826e6d8 100644 --- a/src/main.h +++ b/src/main.h @@ -31,8 +31,6 @@ #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 diff --git a/src/screens.c b/src/screens.c index a9071d43..34eec746 100644 --- a/src/screens.c +++ b/src/screens.c @@ -757,10 +757,12 @@ static void InitializeTitleControls(boolean show_title_initial) 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 + /* 2nd step: initialize title screens for current level set */ InitializeTitleControls_CheckTitleInfo(FALSE); /* sort title screens according to sort_priority and title number */ -- 2.34.1