+ int i, j;
+
+ /* important: after initialization in InitElementPropertiesStatic(), the
+ elements are not again initialized to a default value; therefore all
+ changes have to make sure that they leave the element with a defined
+ property (which means that conditional property changes must be set to
+ a reliable default value before) */
+
+ // resolve group elements
+ for (i = 0; i < NUM_GROUP_ELEMENTS; i++)
+ ResolveGroupElement(EL_GROUP_START + i);
+
+ // set all special, combined or engine dependent element properties
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ {
+ // do not change (already initialized) clipboard elements here
+ if (IS_CLIPBOARD_ELEMENT(i))
+ continue;
+
+ // ---------- INACTIVE ----------------------------------------------------
+ SET_PROPERTY(i, EP_INACTIVE, ((i >= EL_CHAR_START &&
+ i <= EL_CHAR_END) ||
+ (i >= EL_STEEL_CHAR_START &&
+ i <= EL_STEEL_CHAR_END)));
+
+ // ---------- WALKABLE, PASSABLE, ACCESSIBLE ------------------------------
+ SET_PROPERTY(i, EP_WALKABLE, (IS_WALKABLE_OVER(i) ||
+ IS_WALKABLE_INSIDE(i) ||
+ IS_WALKABLE_UNDER(i)));
+
+ SET_PROPERTY(i, EP_PASSABLE, (IS_PASSABLE_OVER(i) ||
+ IS_PASSABLE_INSIDE(i) ||
+ IS_PASSABLE_UNDER(i)));
+
+ SET_PROPERTY(i, EP_ACCESSIBLE_OVER, (IS_WALKABLE_OVER(i) ||
+ IS_PASSABLE_OVER(i)));
+
+ SET_PROPERTY(i, EP_ACCESSIBLE_INSIDE, (IS_WALKABLE_INSIDE(i) ||
+ IS_PASSABLE_INSIDE(i)));
+
+ SET_PROPERTY(i, EP_ACCESSIBLE_UNDER, (IS_WALKABLE_UNDER(i) ||
+ IS_PASSABLE_UNDER(i)));
+
+ SET_PROPERTY(i, EP_ACCESSIBLE, (IS_WALKABLE(i) ||
+ IS_PASSABLE(i)));
+
+ // ---------- COLLECTIBLE -------------------------------------------------
+ SET_PROPERTY(i, EP_COLLECTIBLE, (IS_COLLECTIBLE_ONLY(i) ||
+ IS_DROPPABLE(i) ||
+ IS_THROWABLE(i)));
+
+ // ---------- SNAPPABLE ---------------------------------------------------
+ SET_PROPERTY(i, EP_SNAPPABLE, (IS_DIGGABLE(i) ||
+ IS_COLLECTIBLE(i) ||
+ IS_SWITCHABLE(i) ||
+ i == EL_BD_ROCK));
+
+ // ---------- WALL --------------------------------------------------------
+ SET_PROPERTY(i, EP_WALL, TRUE); // default: element is wall
+
+ for (j = 0; no_wall_properties[j] != -1; j++)
+ if (HAS_PROPERTY(i, no_wall_properties[j]) ||
+ i >= EL_FIRST_RUNTIME_UNREAL)
+ SET_PROPERTY(i, EP_WALL, FALSE);
+
+ if (IS_HISTORIC_WALL(i))
+ SET_PROPERTY(i, EP_WALL, TRUE);
+
+ // ---------- SOLID_FOR_PUSHING -------------------------------------------
+ if (engine_version < VERSION_IDENT(2,2,0,0))
+ SET_PROPERTY(i, EP_SOLID_FOR_PUSHING, IS_HISTORIC_SOLID(i));
+ else
+ SET_PROPERTY(i, EP_SOLID_FOR_PUSHING, (!IS_WALKABLE(i) &&
+ !IS_DIGGABLE(i) &&
+ !IS_COLLECTIBLE(i)));
+
+ // ---------- DRAGONFIRE_PROOF --------------------------------------------
+ if (IS_HISTORIC_SOLID(i) || i == EL_EXPLOSION)
+ SET_PROPERTY(i, EP_DRAGONFIRE_PROOF, TRUE);
+ else
+ SET_PROPERTY(i, EP_DRAGONFIRE_PROOF, (IS_INDESTRUCTIBLE(i) &&
+ i != EL_ACID));
+
+ // ---------- EXPLOSION_PROOF ---------------------------------------------
+ if (i == EL_FLAMES)
+ SET_PROPERTY(i, EP_EXPLOSION_PROOF, TRUE);
+ else if (engine_version < VERSION_IDENT(2,2,0,0))
+ SET_PROPERTY(i, EP_EXPLOSION_PROOF, IS_INDESTRUCTIBLE(i));
+ else
+ SET_PROPERTY(i, EP_EXPLOSION_PROOF, (IS_INDESTRUCTIBLE(i) &&
+ (!IS_WALKABLE(i) ||
+ IS_PROTECTED(i))));
+
+ if (IS_CUSTOM_ELEMENT(i))
+ {
+ // these are additional properties which are initially false when set
+
+ // ---------- DONT_COLLIDE_WITH / DONT_RUN_INTO -------------------------
+ if (DONT_TOUCH(i))
+ SET_PROPERTY(i, EP_DONT_COLLIDE_WITH, TRUE);
+ if (DONT_COLLIDE_WITH(i))
+ SET_PROPERTY(i, EP_DONT_RUN_INTO, TRUE);
+
+ // ---------- CAN_SMASH_ENEMIES / CAN_SMASH_PLAYER ----------------------
+ if (CAN_SMASH_EVERYTHING(i))
+ SET_PROPERTY(i, EP_CAN_SMASH_ENEMIES, TRUE);
+ if (CAN_SMASH_ENEMIES(i))
+ SET_PROPERTY(i, EP_CAN_SMASH_PLAYER, TRUE);
+ }
+
+ // ---------- CAN_SMASH ---------------------------------------------------
+ SET_PROPERTY(i, EP_CAN_SMASH, (CAN_SMASH_PLAYER(i) ||
+ CAN_SMASH_ENEMIES(i) ||
+ CAN_SMASH_EVERYTHING(i)));
+
+ // ---------- CAN_EXPLODE_BY_FIRE -----------------------------------------
+ SET_PROPERTY(i, EP_CAN_EXPLODE_BY_FIRE, (CAN_EXPLODE(i) &&
+ EXPLODES_BY_FIRE(i)));
+
+ // ---------- CAN_EXPLODE_SMASHED -----------------------------------------
+ SET_PROPERTY(i, EP_CAN_EXPLODE_SMASHED, (CAN_EXPLODE(i) &&
+ EXPLODES_SMASHED(i)));
+
+ // ---------- CAN_EXPLODE_IMPACT ------------------------------------------
+ SET_PROPERTY(i, EP_CAN_EXPLODE_IMPACT, (CAN_EXPLODE(i) &&
+ EXPLODES_IMPACT(i)));
+
+ // ---------- CAN_EXPLODE_BY_DRAGONFIRE -----------------------------------
+ SET_PROPERTY(i, EP_CAN_EXPLODE_BY_DRAGONFIRE, CAN_EXPLODE_BY_FIRE(i));
+
+ // ---------- CAN_EXPLODE_BY_EXPLOSION ------------------------------------
+ SET_PROPERTY(i, EP_CAN_EXPLODE_BY_EXPLOSION, (CAN_EXPLODE_BY_FIRE(i) ||
+ i == EL_BLACK_ORB));
+
+ // ---------- COULD_MOVE_INTO_ACID ----------------------------------------
+ SET_PROPERTY(i, EP_COULD_MOVE_INTO_ACID, (IS_PLAYER_ELEMENT(i) ||
+ CAN_MOVE(i) ||
+ IS_CUSTOM_ELEMENT(i)));
+
+ // ---------- MAYBE_DONT_COLLIDE_WITH -------------------------------------
+ SET_PROPERTY(i, EP_MAYBE_DONT_COLLIDE_WITH, (i == EL_SP_SNIKSNAK ||
+ i == EL_SP_ELECTRON));
+
+ // ---------- CAN_MOVE_INTO_ACID ------------------------------------------
+ if (COULD_MOVE_INTO_ACID(i) && !IS_CUSTOM_ELEMENT(i))
+ SET_PROPERTY(i, EP_CAN_MOVE_INTO_ACID,
+ getMoveIntoAcidProperty(&level, i));
+
+ // ---------- DONT_COLLIDE_WITH -------------------------------------------
+ if (MAYBE_DONT_COLLIDE_WITH(i))
+ SET_PROPERTY(i, EP_DONT_COLLIDE_WITH,
+ getDontCollideWithProperty(&level, i));
+
+ // ---------- SP_PORT -----------------------------------------------------
+ SET_PROPERTY(i, EP_SP_PORT, (IS_SP_ELEMENT(i) &&
+ IS_PASSABLE_INSIDE(i)));
+
+ // ---------- CAN_BE_CLONED_BY_ANDROID ------------------------------------
+ for (j = 0; j < level.num_android_clone_elements; j++)
+ SET_PROPERTY(i, EP_CAN_BE_CLONED_BY_ANDROID,
+ (i != EL_EMPTY &&
+ IS_EQUAL_OR_IN_GROUP(i, level.android_clone_element[j])));
+
+ // ---------- CAN_CHANGE --------------------------------------------------
+ SET_PROPERTY(i, EP_CAN_CHANGE, FALSE); // default: cannot change
+ for (j = 0; j < element_info[i].num_change_pages; j++)
+ if (element_info[i].change_page[j].can_change)
+ SET_PROPERTY(i, EP_CAN_CHANGE, TRUE);
+
+ // ---------- HAS_ACTION --------------------------------------------------
+ SET_PROPERTY(i, EP_HAS_ACTION, FALSE); // default: has no action
+ for (j = 0; j < element_info[i].num_change_pages; j++)
+ if (element_info[i].change_page[j].has_action)
+ SET_PROPERTY(i, EP_HAS_ACTION, TRUE);
+
+ // ---------- CAN_CHANGE_OR_HAS_ACTION ------------------------------------
+ SET_PROPERTY(i, EP_CAN_CHANGE_OR_HAS_ACTION, (CAN_CHANGE(i) ||
+ HAS_ACTION(i)));
+
+ // ---------- GFX_CRUMBLED ------------------------------------------------
+ SET_PROPERTY(i, EP_GFX_CRUMBLED,
+ element_info[i].crumbled[ACTION_DEFAULT] !=
+ element_info[i].graphic[ACTION_DEFAULT]);
+
+ // ---------- EDITOR_CASCADE ----------------------------------------------
+ SET_PROPERTY(i, EP_EDITOR_CASCADE, (IS_EDITOR_CASCADE_ACTIVE(i) ||
+ IS_EDITOR_CASCADE_INACTIVE(i)));
+ }
+
+ // dynamically adjust element properties according to game engine version
+ {
+ static int ep_em_slippery_wall[] =
+ {
+ EL_WALL,
+ EL_STEELWALL,
+ EL_EXPANDABLE_WALL,
+ EL_EXPANDABLE_WALL_HORIZONTAL,
+ EL_EXPANDABLE_WALL_VERTICAL,
+ EL_EXPANDABLE_WALL_ANY,
+ EL_EXPANDABLE_STEELWALL_HORIZONTAL,
+ EL_EXPANDABLE_STEELWALL_VERTICAL,
+ EL_EXPANDABLE_STEELWALL_ANY,
+ EL_EXPANDABLE_STEELWALL_GROWING,
+ -1
+ };
+
+ static int ep_em_explodes_by_fire[] =
+ {
+ EL_EM_DYNAMITE,
+ EL_EM_DYNAMITE_ACTIVE,
+ EL_MOLE,
+ -1
+ };
+
+ // special EM style gems behaviour
+ for (i = 0; ep_em_slippery_wall[i] != -1; i++)
+ SET_PROPERTY(ep_em_slippery_wall[i], EP_EM_SLIPPERY_WALL,
+ level.em_slippery_gems);
+
+ // "EL_EXPANDABLE_WALL_GROWING" wasn't slippery for EM gems in 2.0.1
+ SET_PROPERTY(EL_EXPANDABLE_WALL_GROWING, EP_EM_SLIPPERY_WALL,
+ (level.em_slippery_gems &&
+ engine_version > VERSION_IDENT(2,0,1,0)));
+
+ // special EM style explosion behaviour regarding chain reactions
+ for (i = 0; ep_em_explodes_by_fire[i] != -1; i++)
+ SET_PROPERTY(ep_em_explodes_by_fire[i], EP_EXPLODES_BY_FIRE,
+ level.em_explodes_by_fire);
+ }
+
+ // this is needed because some graphics depend on element properties
+ if (game_status == GAME_MODE_PLAYING)
+ InitElementGraphicInfo();
+}
+
+void InitElementPropertiesGfxElement(void)
+{
+ int i;
+
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ {
+ struct ElementInfo *ei = &element_info[i];
+
+ ei->gfx_element = (ei->use_gfx_element ? ei->gfx_element_initial : i);
+ }
+}
+
+static void InitGlobal(void)
+{
+ int graphic;
+ int i;
+
+ for (i = 0; i < MAX_NUM_ELEMENTS + 1; i++)
+ {
+ // check if element_name_info entry defined for each element in "main.h"
+ if (i < MAX_NUM_ELEMENTS && element_name_info[i].token_name == NULL)
+ Fail("undefined 'element_name_info' entry for element %d", i);
+
+ element_info[i].token_name = element_name_info[i].token_name;
+ element_info[i].class_name = element_name_info[i].class_name;
+ element_info[i].editor_description= element_name_info[i].editor_description;
+ }
+
+ for (i = 0; i < NUM_GLOBAL_ANIM_TOKENS + 1; i++)
+ {
+ // check if global_anim_name_info defined for each entry in "main.h"
+ if (i < NUM_GLOBAL_ANIM_TOKENS &&
+ global_anim_name_info[i].token_name == NULL)
+ Fail("undefined 'global_anim_name_info' entry for anim %d", i);
+
+ global_anim_info[i].token_name = global_anim_name_info[i].token_name;
+ }
+
+ // create hash from image config list
+ image_config_hash = newSetupFileHash();
+ for (i = 0; image_config[i].token != NULL; i++)
+ setHashEntry(image_config_hash,
+ image_config[i].token,
+ image_config[i].value);
+
+ // create hash from element token list
+ element_token_hash = newSetupFileHash();
+ for (i = 0; element_name_info[i].token_name != NULL; i++)
+ setHashEntry(element_token_hash,
+ element_name_info[i].token_name,
+ int2str(i, 0));
+
+ // create hash from graphic token list
+ graphic_token_hash = newSetupFileHash();
+ for (graphic = 0, i = 0; image_config[i].token != NULL; i++)
+ if (strSuffix(image_config[i].value, ".png") ||
+ strSuffix(image_config[i].value, ".pcx") ||
+ strSuffix(image_config[i].value, ".wav") ||
+ strEqual(image_config[i].value, UNDEFINED_FILENAME))
+ setHashEntry(graphic_token_hash,
+ image_config[i].token,
+ int2str(graphic++, 0));
+
+ // create hash from font token list
+ font_token_hash = newSetupFileHash();
+ for (i = 0; font_info[i].token_name != NULL; i++)
+ setHashEntry(font_token_hash,
+ font_info[i].token_name,
+ int2str(i, 0));
+
+ // set default filenames for all cloned graphics in static configuration
+ for (i = 0; image_config[i].token != NULL; i++)
+ {
+ if (strEqual(image_config[i].value, UNDEFINED_FILENAME))
+ {
+ char *token = image_config[i].token;
+ char *token_clone_from = getStringCat2(token, ".clone_from");
+ char *token_cloned = getHashEntry(image_config_hash, token_clone_from);
+
+ if (token_cloned != NULL)
+ {
+ char *value_cloned = getHashEntry(image_config_hash, token_cloned);
+
+ if (value_cloned != NULL)
+ {
+ // set default filename in static configuration
+ image_config[i].value = value_cloned;
+
+ // set default filename in image config hash
+ setHashEntry(image_config_hash, token, value_cloned);
+ }
+ }
+
+ free(token_clone_from);
+ }
+ }
+
+ // always start with reliable default values (all elements)
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ ActiveElement[i] = i;
+
+ // now add all entries that have an active state (active elements)
+ for (i = 0; element_with_active_state[i].element != -1; i++)
+ {
+ int element = element_with_active_state[i].element;
+ int element_active = element_with_active_state[i].element_active;
+
+ ActiveElement[element] = element_active;
+ }
+
+ // always start with reliable default values (all buttons)
+ for (i = 0; i < NUM_IMAGE_FILES; i++)
+ ActiveButton[i] = i;
+
+ // now add all entries that have an active state (active buttons)
+ for (i = 0; button_with_active_state[i].button != -1; i++)
+ {
+ int button = button_with_active_state[i].button;
+ int button_active = button_with_active_state[i].button_active;
+
+ ActiveButton[button] = button_active;
+ }
+
+ // always start with reliable default values (all fonts)
+ for (i = 0; i < NUM_FONTS; i++)
+ ActiveFont[i] = i;
+
+ // now add all entries that have an active state (active fonts)
+ for (i = 0; font_with_active_state[i].font_nr != -1; i++)
+ {
+ int font = font_with_active_state[i].font_nr;
+ int font_active = font_with_active_state[i].font_nr_active;
+
+ ActiveFont[font] = font_active;
+ }
+
+ global.autoplay_leveldir = NULL;
+ global.patchtapes_leveldir = NULL;
+ global.convert_leveldir = NULL;
+ global.dumplevel_leveldir = NULL;
+ global.dumptape_leveldir = NULL;
+ global.create_sketch_images_dir = NULL;
+ global.create_collect_images_dir = NULL;
+
+ global.frames_per_second = 0;
+ global.show_frames_per_second = FALSE;
+
+ global.border_status = GAME_MODE_LOADING;
+ global.anim_status = global.anim_status_next = GAME_MODE_LOADING;
+
+ global.use_envelope_request = FALSE;
+
+ global.user_names = NULL;
+}
+
+static void Execute_Command(char *command)
+{
+ int i;
+
+ if (strEqual(command, "print graphicsinfo.conf"))
+ {
+ Print("# You can configure additional/alternative image files here.\n");
+ Print("# (The entries below are default and therefore commented out.)\n");
+ Print("\n");
+ Print("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
+ Print("\n");
+ Print("%s\n", getFormattedSetupEntry("sort_priority", "100"));
+ Print("\n");
+
+ for (i = 0; image_config[i].token != NULL; i++)
+ Print("# %s\n", getFormattedSetupEntry(image_config[i].token,
+ image_config[i].value));
+
+ exit(0);
+ }
+ else if (strEqual(command, "print soundsinfo.conf"))
+ {
+ Print("# You can configure additional/alternative sound files here.\n");
+ Print("# (The entries below are default and therefore commented out.)\n");
+ Print("\n");
+ Print("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
+ Print("\n");
+ Print("%s\n", getFormattedSetupEntry("sort_priority", "100"));
+ Print("\n");
+
+ for (i = 0; sound_config[i].token != NULL; i++)
+ Print("# %s\n", getFormattedSetupEntry(sound_config[i].token,
+ sound_config[i].value));
+
+ exit(0);
+ }
+ else if (strEqual(command, "print musicinfo.conf"))
+ {
+ Print("# You can configure additional/alternative music files here.\n");
+ Print("# (The entries below are default and therefore commented out.)\n");
+ Print("\n");
+ Print("%s\n", getFormattedSetupEntry("name", "Classic Music"));
+ Print("\n");
+ Print("%s\n", getFormattedSetupEntry("sort_priority", "100"));
+ Print("\n");
+
+ for (i = 0; music_config[i].token != NULL; i++)
+ Print("# %s\n", getFormattedSetupEntry(music_config[i].token,
+ music_config[i].value));
+
+ exit(0);
+ }
+ else if (strEqual(command, "print editorsetup.conf"))
+ {
+ Print("# You can configure your personal editor element list here.\n");
+ Print("# (The entries below are default and therefore commented out.)\n");
+ Print("\n");
+
+ // this is needed to be able to check element list for cascade elements
+ InitElementPropertiesStatic();
+ InitElementPropertiesEngine(GAME_VERSION_ACTUAL);
+
+ PrintEditorElementList();
+
+ exit(0);
+ }
+ else if (strEqual(command, "print helpanim.conf"))
+ {
+ Print("# You can configure different element help animations here.\n");
+ Print("# (The entries below are default and therefore commented out.)\n");
+ Print("\n");
+
+ for (i = 0; helpanim_config[i].token != NULL; i++)
+ {
+ Print("# %s\n", getFormattedSetupEntry(helpanim_config[i].token,
+ helpanim_config[i].value));
+
+ if (strEqual(helpanim_config[i].token, "end"))
+ Print("#\n");
+ }
+
+ exit(0);
+ }
+ else if (strEqual(command, "print helptext.conf"))
+ {
+ Print("# You can configure different element help text here.\n");
+ Print("# (The entries below are default and therefore commented out.)\n");
+ Print("\n");
+
+ for (i = 0; helptext_config[i].token != NULL; i++)
+ Print("# %s\n", getFormattedSetupEntry(helptext_config[i].token,
+ helptext_config[i].value));
+
+ exit(0);
+ }
+ else if (strPrefix(command, "dump level "))
+ {
+ char *filename = &command[11];
+
+ if (fileExists(filename))
+ {
+ LoadLevelFromFilename(&level, filename);
+ DumpLevel(&level);
+
+ exit(0);
+ }
+
+ char *leveldir = getStringCopy(filename); // read command parameters
+ char *level_nr = strchr(leveldir, ' ');
+
+ if (level_nr == NULL)
+ Fail("cannot open file '%s'", filename);
+
+ *level_nr++ = '\0';
+
+ global.dumplevel_leveldir = leveldir;
+ global.dumplevel_level_nr = atoi(level_nr);
+
+ program.headless = TRUE;
+ }
+ else if (strPrefix(command, "dump tape "))
+ {
+ char *filename = &command[10];
+
+ if (fileExists(filename))
+ {
+ LoadTapeFromFilename(filename);
+ DumpTape(&tape);
+
+ exit(0);
+ }
+
+ char *leveldir = getStringCopy(filename); // read command parameters
+ char *level_nr = strchr(leveldir, ' ');
+
+ if (level_nr == NULL)
+ Fail("cannot open file '%s'", filename);
+
+ *level_nr++ = '\0';
+
+ global.dumptape_leveldir = leveldir;
+ global.dumptape_level_nr = atoi(level_nr);
+
+ program.headless = TRUE;
+ }
+ else if (strPrefix(command, "autoplay ") ||
+ strPrefix(command, "autoffwd ") ||
+ strPrefix(command, "autowarp ") ||
+ strPrefix(command, "autotest ") ||
+ strPrefix(command, "autosave ") ||
+ strPrefix(command, "autoupload ") ||
+ strPrefix(command, "autofix "))
+ {
+ char *arg_ptr = strchr(command, ' ');
+ char *str_ptr = getStringCopy(arg_ptr); // read command parameters
+
+ global.autoplay_mode =
+ (strPrefix(command, "autoplay") ? AUTOPLAY_MODE_PLAY :
+ strPrefix(command, "autoffwd") ? AUTOPLAY_MODE_FFWD :
+ strPrefix(command, "autowarp") ? AUTOPLAY_MODE_WARP :
+ strPrefix(command, "autotest") ? AUTOPLAY_MODE_TEST :
+ strPrefix(command, "autosave") ? AUTOPLAY_MODE_SAVE :
+ strPrefix(command, "autoupload") ? AUTOPLAY_MODE_UPLOAD :
+ strPrefix(command, "autofix") ? AUTOPLAY_MODE_FIX :
+ AUTOPLAY_MODE_NONE);
+
+ while (*str_ptr != '\0') // continue parsing string
+ {
+ // cut leading whitespace from string, replace it by string terminator
+ while (*str_ptr == ' ' || *str_ptr == '\t')
+ *str_ptr++ = '\0';
+
+ if (*str_ptr == '\0') // end of string reached
+ break;
+
+ if (global.autoplay_leveldir == NULL) // read level set string
+ {
+ global.autoplay_leveldir = str_ptr;
+ global.autoplay_all = TRUE; // default: play all tapes
+
+ for (i = 0; i < MAX_TAPES_PER_SET; i++)
+ global.autoplay_level[i] = FALSE;
+ }
+ else // read level number string
+ {
+ int level_nr = atoi(str_ptr); // get level_nr value
+
+ if (level_nr >= 0 && level_nr < MAX_TAPES_PER_SET)
+ global.autoplay_level[level_nr] = TRUE;
+
+ global.autoplay_all = FALSE;
+ }
+
+ // advance string pointer to the next whitespace (or end of string)
+ while (*str_ptr != ' ' && *str_ptr != '\t' && *str_ptr != '\0')
+ str_ptr++;
+ }
+
+ if (global.autoplay_mode & AUTOPLAY_WARP_NO_DISPLAY)
+ program.headless = TRUE;
+ }
+ else if (strPrefix(command, "patch tapes "))
+ {
+ char *str_ptr = getStringCopy(&command[12]); // read command parameters
+
+ // skip leading whitespace
+ while (*str_ptr == ' ' || *str_ptr == '\t')
+ str_ptr++;
+
+ if (*str_ptr == '\0')
+ Fail("cannot find MODE in command '%s'", command);
+
+ global.patchtapes_mode = str_ptr; // store patch mode
+
+ // advance to next whitespace (or end of string)
+ while (*str_ptr != ' ' && *str_ptr != '\t' && *str_ptr != '\0')
+ str_ptr++;
+
+ while (*str_ptr != '\0') // continue parsing string
+ {
+ // cut leading whitespace from string, replace it by string terminator
+ while (*str_ptr == ' ' || *str_ptr == '\t')
+ *str_ptr++ = '\0';
+
+ if (*str_ptr == '\0') // end of string reached
+ break;
+
+ if (global.patchtapes_leveldir == NULL) // read level set string
+ {
+ global.patchtapes_leveldir = str_ptr;
+ global.patchtapes_all = TRUE; // default: patch all tapes
+
+ for (i = 0; i < MAX_TAPES_PER_SET; i++)
+ global.patchtapes_level[i] = FALSE;
+ }
+ else // read level number string
+ {
+ int level_nr = atoi(str_ptr); // get level_nr value
+
+ if (level_nr >= 0 && level_nr < MAX_TAPES_PER_SET)
+ global.patchtapes_level[level_nr] = TRUE;
+
+ global.patchtapes_all = FALSE;
+ }
+
+ // advance string pointer to the next whitespace (or end of string)
+ while (*str_ptr != ' ' && *str_ptr != '\t' && *str_ptr != '\0')
+ str_ptr++;
+ }
+
+ if (global.patchtapes_leveldir == NULL)
+ {
+ if (strEqual(global.patchtapes_mode, "help"))
+ global.patchtapes_leveldir = UNDEFINED_LEVELSET;
+ else
+ Fail("cannot find LEVELDIR in command '%s'", command);
+ }
+
+ program.headless = TRUE;
+ }
+ else if (strPrefix(command, "convert "))