From b6847742a0713d8ed21bb6104476db54f8c1a4b9 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 5 Dec 2009 22:22:45 +0100 Subject: [PATCH] rnd-20091205-1-src --- src/conftime.h | 2 +- src/files.c | 33 ++++++++++++++++++++------------- src/init.c | 6 ++---- src/libgame/misc.c | 22 +++++++++++++++++++++- src/libgame/misc.h | 3 ++- src/libgame/system.h | 2 ++ src/main.c | 12 +++++++++++- src/main.h | 4 +++- 8 files changed, 62 insertions(+), 22 deletions(-) diff --git a/src/conftime.h b/src/conftime.h index a3e35460..2506dc70 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2009-12-02 22:23" +#define COMPILE_DATE_STRING "2009-12-05 22:18" diff --git a/src/files.c b/src/files.c index 78ef9ed7..36939ac7 100644 --- a/src/files.c +++ b/src/files.c @@ -6331,13 +6331,13 @@ static void LoadLevelFromFileInfo_DC(struct LevelInfo *level, /* functions for loading SB level */ /* ------------------------------------------------------------------------- */ -int getMappedElement_SB(int element_ascii, boolean use_special_1) +int getMappedElement_SB(int element_ascii, boolean use_ces) { static struct { int ascii; - int rnd; - int special_1; + int sb; + int ce; } sb_element_mapping[] = { @@ -6357,9 +6357,7 @@ int getMappedElement_SB(int element_ascii, boolean use_special_1) for (i = 0; sb_element_mapping[i].ascii != 0; i++) if (element_ascii == sb_element_mapping[i].ascii) - return (use_special_1 ? - sb_element_mapping[i].special_1 : - sb_element_mapping[i].rnd); + return (use_ces ? sb_element_mapping[i].ce : sb_element_mapping[i].sb); return EL_UNDEFINED; } @@ -6378,8 +6376,7 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, boolean reading_playfield = FALSE; boolean got_valid_playfield_line = FALSE; boolean invalid_playfield_char = FALSE; - boolean convert_mode_special_1 = (global.convert_leveldir && - global.convert_mode_special_1); + boolean load_xsb_to_ces = options.cmd_switches & CMD_SWITCH_LOAD_XSB_TO_CES; int file_level_nr = 0; int line_nr = 0; int x, y; @@ -6522,7 +6519,7 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, for (x = 0; x < MAX_LEV_FIELDX; x++) for (y = 0; y < MAX_LEV_FIELDY; y++) - level->field[x][y] = EL_EMPTY; + level->field[x][y] = getMappedElement_SB(' ', load_xsb_to_ces); level->fieldx = 0; level->fieldy = 0; @@ -6541,8 +6538,7 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, /* read playfield elements from line */ for (line_ptr = line; *line_ptr; line_ptr++) { - int mapped_sb_element = getMappedElement_SB(*line_ptr, - convert_mode_special_1); + int mapped_sb_element = getMappedElement_SB(*line_ptr, load_xsb_to_ces); /* stop parsing playfield line if larger column than allowed */ if (x >= MAX_LEV_FIELDX) @@ -6615,14 +6611,25 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, sprintf(level->name, "--> Level %d <--", level_file_info->nr); } + /* set all empty fields beyond the border walls to invisible steel wall */ for (y = 0; y < level->fieldy; y++) for (x = 0; x < level->fieldx; x++) { if ((x == 0 || x == level->fieldx - 1 || y == 0 || y == level->fieldy - 1) && - level->field[x][y] == getMappedElement_SB(' ', convert_mode_special_1)) - FloodFillLevel(x, y, getMappedElement_SB('_', convert_mode_special_1), + level->field[x][y] == getMappedElement_SB(' ', load_xsb_to_ces)) + FloodFillLevel(x, y, getMappedElement_SB('_', load_xsb_to_ces), level->field, level->fieldx, level->fieldy); } + + if (load_xsb_to_ces) + { + level->time = 0; + level->use_step_counter = TRUE; + + level->initial_player_stepsize[0] = STEPSIZE_SLOW; + + level->use_custom_template = TRUE; + } } diff --git a/src/init.c b/src/init.c index c3c14af2..f9ae5996 100644 --- a/src/init.c +++ b/src/init.c @@ -5192,15 +5192,13 @@ void Execute_Command(char *command) str_ptr++; } } - else if (strPrefix(command, "convert ") || - strPrefix(command, "convert_special_1 ")) + else if (strPrefix(command, "convert ")) { - char *str_copy = getStringCopy(&command[8]); + char *str_copy = getStringCopy(strchr(command, ' ') + 1); char *str_ptr = strchr(str_copy, ' '); global.convert_leveldir = str_copy; global.convert_level_nr = -1; - global.convert_mode_special_1 = strPrefix(command, "convert_special_1 "); if (str_ptr != NULL) /* level number follows */ { diff --git a/src/libgame/misc.c b/src/libgame/misc.c index f3e19104..d21363ca 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -662,7 +662,8 @@ boolean strSuffixLower(char *s, char *suffix) /* command line option handling functions */ /* ------------------------------------------------------------------------- */ -void GetOptions(char *argv[], void (*print_usage_function)(void)) +void GetOptions(char *argv[], void (*print_usage_function)(void), + unsigned long (*get_cmd_switch_function)(char *)) { char *ro_base_path = RO_BASE_PATH; char *rw_base_path = RW_BASE_PATH; @@ -685,6 +686,7 @@ void GetOptions(char *argv[], void (*print_usage_function)(void)) options.display_name = NULL; options.server_host = NULL; options.server_port = 0; + options.ro_base_directory = ro_base_path; options.rw_base_directory = rw_base_path; options.level_directory = getPath2(ro_base_path, LEVELS_DIRECTORY); @@ -693,12 +695,15 @@ void GetOptions(char *argv[], void (*print_usage_function)(void)) options.music_directory = getPath2(ro_base_path, MUSIC_DIRECTORY); options.docs_directory = getPath2(ro_base_path, DOCS_DIRECTORY); options.execute_command = NULL; + options.serveronly = FALSE; options.network = FALSE; options.verbose = 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; @@ -827,6 +832,21 @@ void GetOptions(char *argv[], void (*print_usage_function)(void)) { options.debug_x11_sync = TRUE; } + else if (strPrefix(option, "-D")) + { + char *switch_string = &option[2]; + unsigned long switch_value; + + if (*switch_string == '\0') + Error(ERR_EXIT_HELP, "empty switch ignored"); + + switch_value = get_cmd_switch_function(switch_string); + + if (switch_value == 0) + Error(ERR_EXIT_HELP, "unknown switch '%s'", switch_string); + + options.cmd_switches |= switch_value; + } else if (strncmp(option, "-execute", option_len) == 0) { if (option_arg == NULL) diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 6ac3d994..8732a8cd 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -113,7 +113,8 @@ boolean strSuffix(char *, char *); boolean strPrefixLower(char *, char *); boolean strSuffixLower(char *, char *); -void GetOptions(char **, void (*print_usage_function)(void)); +void GetOptions(char **, void (*print_usage_function)(void), + unsigned long (*get_cmd_switch_function)(char *)); void SetError(char *, ...); char *GetError(void); diff --git a/src/libgame/system.h b/src/libgame/system.h index aa1057fd..73b5472f 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -657,6 +657,8 @@ struct OptionInfo boolean verbose; boolean debug; boolean debug_x11_sync; + + unsigned long cmd_switches; }; struct ScreenModeInfo diff --git a/src/main.c b/src/main.c index f1ea104e..5acf09fe 100644 --- a/src/main.c +++ b/src/main.c @@ -5509,6 +5509,16 @@ 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" @@ -5557,7 +5567,7 @@ int main(int argc, char *argv[]) InitExitFunction(CloseAllAndExit); InitPlatformDependentStuff(); - GetOptions(argv, print_usage); + GetOptions(argv, print_usage, get_cmd_switch); OpenAll(); EventLoop(); diff --git a/src/main.h b/src/main.h index 0e8871c9..0adf9f70 100644 --- a/src/main.h +++ b/src/main.h @@ -30,6 +30,9 @@ #include "conf_snd.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 @@ -2415,7 +2418,6 @@ struct GlobalInfo char *convert_leveldir; int convert_level_nr; - boolean convert_mode_special_1; char *create_images_dir; -- 2.34.1