-#define COMPILE_DATE_STRING "2009-12-02 22:23"
+#define COMPILE_DATE_STRING "2009-12-05 22:18"
/* 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[] =
{
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;
}
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;
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;
/* 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)
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;
+ }
}
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 */
{
/* 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;
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);
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;
{
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)
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);
boolean verbose;
boolean debug;
boolean debug_x11_sync;
+
+ unsigned long cmd_switches;
};
struct ScreenModeInfo
/* 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"
InitExitFunction(CloseAllAndExit);
InitPlatformDependentStuff();
- GetOptions(argv, print_usage);
+ GetOptions(argv, print_usage, get_cmd_switch);
OpenAll();
EventLoop();
#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
char *convert_leveldir;
int convert_level_nr;
- boolean convert_mode_special_1;
char *create_images_dir;