+
+ /* always start with reliable default values (no properties) */
+ for (i=0; i<MAX_NUM_ELEMENTS; i++)
+ for (j=0; j<NUM_EP_BITFIELDS; j++)
+ Properties[i][j] = EP_BITMASK_DEFAULT;
+
+ /* set all predefined element properties from above arrays */
+ for (i=0; element_properties[i].elements != NULL; i++)
+ for (j=0; (element_properties[i].elements)[j] >= 0; j++)
+ SET_PROPERTY((element_properties[i].elements)[j],
+ element_properties[i].property, TRUE);
+
+ /* set properties of character elements */
+ for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
+ {
+ SET_PROPERTY(i, EP_CHAR, TRUE);
+ SET_PROPERTY(i, EP_INACTIVE, TRUE);
+ }
+}
+
+static void InitGlobal()
+{
+ global.autoplay_leveldir = NULL;
+
+ global.frames_per_second = 0;
+ global.fps_slowdown = FALSE;
+ global.fps_slowdown_factor = 1;
+}
+
+void Execute_Command(char *command)
+{
+ if (strcmp(command, "print graphicsinfo.conf") == 0)
+ {
+ int i;
+
+ printf("# You can configure additional/alternative image files here.\n");
+ printf("# (The images below are default and therefore commented out.)\n");
+ printf("\n");
+ printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
+ printf("\n");
+ printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
+ printf("\n");
+
+ for (i=0; image_config[i].token != NULL; i++)
+ printf("# %s\n",
+ getFormattedSetupEntry(image_config[i].token,
+ image_config[i].value));
+
+ exit(0);
+ }
+ else if (strcmp(command, "print soundsinfo.conf") == 0)
+ {
+ int i;
+
+ printf("# You can configure additional/alternative sound files here.\n");
+ printf("# (The sounds below are default and therefore commented out.)\n");
+ printf("\n");
+ printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
+ printf("\n");
+ printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
+ printf("\n");
+
+ for (i=0; sound_config[i].token != NULL; i++)
+ printf("# %s\n",
+ getFormattedSetupEntry(sound_config[i].token,
+ sound_config[i].value));
+
+ exit(0);
+ }
+ else if (strcmp(command, "print musicinfo.conf") == 0)
+ {
+ printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
+ printf("\n");
+ printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
+ printf("\n");
+ printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
+
+ exit(0);
+ }
+ else if (strncmp(command, "dump level ", 11) == 0)
+ {
+ char *filename = &command[11];
+
+ if (access(filename, F_OK) != 0)
+ Error(ERR_EXIT, "cannot open file '%s'", filename);
+
+ LoadLevelFromFilename(filename);
+ DumpLevel(&level);
+
+ exit(0);
+ }
+ else if (strncmp(command, "dump tape ", 10) == 0)
+ {
+ char *filename = &command[10];
+
+ if (access(filename, F_OK) != 0)
+ Error(ERR_EXIT, "cannot open file '%s'", filename);
+
+ LoadTapeFromFilename(filename);
+ DumpTape(&tape);
+
+ exit(0);
+ }
+ else if (strncmp(command, "autoplay ", 9) == 0)
+ {
+ char *str_copy = getStringCopy(&command[9]);
+ char *str_ptr = strchr(str_copy, ' ');
+
+ global.autoplay_leveldir = str_copy;
+ global.autoplay_level_nr = -1;
+
+ if (str_ptr != NULL)
+ {
+ *str_ptr++ = '\0'; /* terminate leveldir string */
+ global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
+ }
+ }
+ else
+ {
+ Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
+ }
+}
+
+static void InitSetup()
+{
+ LoadSetup(); /* global setup info */
+
+ /* set some options from setup file */
+
+ if (setup.options.verbose)
+ options.verbose = TRUE;
+}
+
+static void InitPlayerInfo()
+{
+ int i;
+
+ /* choose default local player */
+ local_player = &stored_player[0];
+
+ for (i=0; i<MAX_PLAYERS; i++)
+ stored_player[i].connected = FALSE;
+
+ local_player->connected = TRUE;
+}
+
+static void InitArtworkInfo()
+{
+ LoadArtworkInfo();
+}
+
+static char *get_element_class_token(int element)
+{
+ char *element_class_name = element_info[element].class_name;
+ char *element_class_token = checked_malloc(strlen(element_class_name) + 3);
+
+ sprintf(element_class_token, "[%s]", element_class_name);
+
+ return element_class_token;
+}
+
+static void InitArtworkConfig()
+{
+ static char *image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + 1];
+ static char *sound_id_prefix[MAX_NUM_ELEMENTS + MAX_NUM_ELEMENTS + 1];
+ static char *action_id_suffix[NUM_ACTIONS + 1];
+ static char *direction_id_suffix[NUM_DIRECTIONS + 1];
+ static char *special_id_suffix[NUM_SPECIAL_GFX_ARGS + 1];
+ static char *dummy[1] = { NULL };
+ static char *ignore_image_tokens[] =
+ {
+ "name",
+ "sort_priority",
+ "global.num_toons",
+ "menu.draw_xoffset",
+ "menu.draw_yoffset",
+ "menu.draw_xoffset.MAIN",
+ "menu.draw_yoffset.MAIN",
+ "door.step_offset",
+ "door.step_delay",
+ NULL