+ // default values (also for pre-1.2 tapes) with only the first player
+ tape.player_participates[0] = TRUE;
+ for (i = 1; i < MAX_PLAYERS; i++)
+ tape.player_participates[i] = FALSE;
+
+ // at least one (default: the first) player participates in every tape
+ tape.num_participating_players = 1;
+
+ tape.level_nr = level_nr;
+ tape.counter = 0;
+ tape.changed = FALSE;
+
+ tape.recording = FALSE;
+ tape.playing = FALSE;
+ tape.pausing = FALSE;
+
+ tape.no_valid_file = FALSE;
+}
+
+static int LoadTape_VERS(File *file, int chunk_size, struct TapeInfo *tape)
+{
+ tape->file_version = getFileVersion(file);
+ tape->game_version = getFileVersion(file);
+
+ return chunk_size;
+}
+
+static int LoadTape_HEAD(File *file, int chunk_size, struct TapeInfo *tape)
+{
+ int i;
+
+ tape->random_seed = getFile32BitBE(file);
+ tape->date = getFile32BitBE(file);
+ tape->length = getFile32BitBE(file);
+
+ // read header fields that are new since version 1.2
+ if (tape->file_version >= FILE_VERSION_1_2)
+ {
+ byte store_participating_players = getFile8Bit(file);
+ int engine_version;
+
+ // since version 1.2, tapes store which players participate in the tape
+ tape->num_participating_players = 0;
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ tape->player_participates[i] = FALSE;
+
+ if (store_participating_players & (1 << i))
+ {
+ tape->player_participates[i] = TRUE;
+ tape->num_participating_players++;
+ }
+ }
+
+ tape->use_mouse = (getFile8Bit(file) == 1 ? TRUE : FALSE);
+
+ ReadUnusedBytesFromFile(file, TAPE_CHUNK_HEAD_UNUSED);
+
+ engine_version = getFileVersion(file);
+ if (engine_version > 0)
+ tape->engine_version = engine_version;
+ else
+ tape->engine_version = tape->game_version;
+ }
+
+ return chunk_size;
+}
+
+static int LoadTape_INFO(File *file, int chunk_size, struct TapeInfo *tape)
+{
+ int level_identifier_size;
+ int i;
+
+ level_identifier_size = getFile16BitBE(file);
+
+ tape->level_identifier =
+ checked_realloc(tape->level_identifier, level_identifier_size);
+
+ for (i = 0; i < level_identifier_size; i++)
+ tape->level_identifier[i] = getFile8Bit(file);
+
+ tape->level_nr = getFile16BitBE(file);
+
+ chunk_size = 2 + level_identifier_size + 2;
+
+ return chunk_size;
+}
+
+static int LoadTape_BODY(File *file, int chunk_size, struct TapeInfo *tape)
+{
+ int i, j;
+ int tape_pos_size =
+ (tape->use_mouse ? 3 : tape->num_participating_players) + 1;
+ int chunk_size_expected = tape_pos_size * tape->length;
+
+ if (chunk_size_expected != chunk_size)
+ {
+ ReadUnusedBytesFromFile(file, chunk_size);
+ return chunk_size_expected;
+ }
+
+ for (i = 0; i < tape->length; i++)
+ {
+ if (i >= MAX_TAPE_LEN)
+ {
+ Error(ERR_WARN, "tape truncated -- size exceeds maximum tape size %d",
+ MAX_TAPE_LEN);
+
+ // tape too large; read and ignore remaining tape data from this chunk
+ for (;i < tape->length; i++)
+ ReadUnusedBytesFromFile(file, tape->num_participating_players + 1);
+
+ break;
+ }
+
+ if (tape->use_mouse)
+ {
+ tape->pos[i].action[TAPE_ACTION_LX] = getFile8Bit(file);
+ tape->pos[i].action[TAPE_ACTION_LY] = getFile8Bit(file);
+ tape->pos[i].action[TAPE_ACTION_BUTTON] = getFile8Bit(file);
+
+ tape->pos[i].action[TAPE_ACTION_UNUSED] = 0;
+ }
+ else
+ {
+ for (j = 0; j < MAX_PLAYERS; j++)
+ {
+ tape->pos[i].action[j] = MV_NONE;
+
+ if (tape->player_participates[j])
+ tape->pos[i].action[j] = getFile8Bit(file);
+ }
+ }
+
+ tape->pos[i].delay = getFile8Bit(file);
+
+ if (tape->file_version == FILE_VERSION_1_0)
+ {
+ // eliminate possible diagonal moves in old tapes
+ // this is only for backward compatibility
+
+ byte joy_dir[4] = { JOY_LEFT, JOY_RIGHT, JOY_UP, JOY_DOWN };
+ byte action = tape->pos[i].action[0];
+ int k, num_moves = 0;
+
+ for (k = 0; k<4; k++)
+ {
+ if (action & joy_dir[k])
+ {
+ tape->pos[i + num_moves].action[0] = joy_dir[k];
+ if (num_moves > 0)
+ tape->pos[i + num_moves].delay = 0;
+ num_moves++;
+ }
+ }
+
+ if (num_moves > 1)
+ {
+ num_moves--;
+ i += num_moves;
+ tape->length += num_moves;
+ }
+ }
+ else if (tape->file_version < FILE_VERSION_2_0)
+ {
+ // convert pre-2.0 tapes to new tape format
+
+ if (tape->pos[i].delay > 1)
+ {
+ // action part
+ tape->pos[i + 1] = tape->pos[i];
+ tape->pos[i + 1].delay = 1;
+
+ // delay part
+ for (j = 0; j < MAX_PLAYERS; j++)
+ tape->pos[i].action[j] = MV_NONE;
+ tape->pos[i].delay--;
+
+ i++;
+ tape->length++;
+ }
+ }
+
+ if (checkEndOfFile(file))
+ break;
+ }
+
+ if (i != tape->length)
+ chunk_size = tape_pos_size * i;
+
+ return chunk_size;
+}
+
+static void LoadTape_SokobanSolution(char *filename)
+{
+ File *file;
+ int move_delay = TILESIZE / level.initial_player_stepsize[0];
+
+ if (!(file = openFile(filename, MODE_READ)))
+ {
+ tape.no_valid_file = TRUE;
+
+ return;
+ }
+
+ while (!checkEndOfFile(file))
+ {
+ unsigned char c = getByteFromFile(file);
+
+ if (checkEndOfFile(file))
+ break;
+
+ switch (c)
+ {
+ case 'u':
+ case 'U':
+ tape.pos[tape.length].action[0] = MV_UP;
+ tape.pos[tape.length].delay = move_delay + (c < 'a' ? 2 : 0);
+ tape.length++;
+ break;
+
+ case 'd':
+ case 'D':
+ tape.pos[tape.length].action[0] = MV_DOWN;
+ tape.pos[tape.length].delay = move_delay + (c < 'a' ? 2 : 0);
+ tape.length++;
+ break;
+
+ case 'l':
+ case 'L':
+ tape.pos[tape.length].action[0] = MV_LEFT;
+ tape.pos[tape.length].delay = move_delay + (c < 'a' ? 2 : 0);
+ tape.length++;
+ break;
+
+ case 'r':
+ case 'R':
+ tape.pos[tape.length].action[0] = MV_RIGHT;
+ tape.pos[tape.length].delay = move_delay + (c < 'a' ? 2 : 0);
+ tape.length++;
+ break;
+
+ case '\n':
+ case '\r':
+ case '\t':
+ case ' ':
+ // ignore white-space characters
+ break;
+
+ default:
+ tape.no_valid_file = TRUE;
+
+ Error(ERR_WARN, "unsupported Sokoban solution file '%s' ['%d']", filename, c);
+
+ break;
+ }
+ }
+
+ closeFile(file);
+
+ if (tape.no_valid_file)
+ return;
+
+ tape.length_frames = GetTapeLengthFrames();
+ tape.length_seconds = GetTapeLengthSeconds();
+}
+
+void LoadTapeFromFilename(char *filename)
+{
+ char cookie[MAX_LINE_LEN];
+ char chunk_name[CHUNK_ID_LEN + 1];
+ File *file;
+ int chunk_size;
+
+ // always start with reliable default values
+ setTapeInfoToDefaults();
+
+ if (strSuffix(filename, ".sln"))
+ {
+ LoadTape_SokobanSolution(filename);
+
+ return;
+ }
+
+ if (!(file = openFile(filename, MODE_READ)))
+ {
+ tape.no_valid_file = TRUE;
+
+ return;
+ }
+
+ getFileChunkBE(file, chunk_name, NULL);
+ if (strEqual(chunk_name, "RND1"))
+ {
+ getFile32BitBE(file); // not used
+
+ getFileChunkBE(file, chunk_name, NULL);
+ if (!strEqual(chunk_name, "TAPE"))
+ {
+ tape.no_valid_file = TRUE;
+
+ Error(ERR_WARN, "unknown format of tape file '%s'", filename);
+
+ closeFile(file);
+
+ return;
+ }
+ }
+ else // check for pre-2.0 file format with cookie string
+ {
+ strcpy(cookie, chunk_name);
+ if (getStringFromFile(file, &cookie[4], MAX_LINE_LEN - 4) == NULL)
+ cookie[4] = '\0';
+ if (strlen(cookie) > 0 && cookie[strlen(cookie) - 1] == '\n')
+ cookie[strlen(cookie) - 1] = '\0';
+
+ if (!checkCookieString(cookie, TAPE_COOKIE_TMPL))
+ {
+ tape.no_valid_file = TRUE;
+
+ Error(ERR_WARN, "unknown format of tape file '%s'", filename);
+
+ closeFile(file);
+
+ return;
+ }
+
+ if ((tape.file_version = getFileVersionFromCookieString(cookie)) == -1)
+ {
+ tape.no_valid_file = TRUE;
+
+ Error(ERR_WARN, "unsupported version of tape file '%s'", filename);
+
+ closeFile(file);
+
+ return;
+ }
+
+ // pre-2.0 tape files have no game version, so use file version here
+ tape.game_version = tape.file_version;
+ }
+
+ if (tape.file_version < FILE_VERSION_1_2)
+ {
+ // tape files from versions before 1.2.0 without chunk structure
+ LoadTape_HEAD(file, TAPE_CHUNK_HEAD_SIZE, &tape);
+ LoadTape_BODY(file, 2 * tape.length, &tape);
+ }
+ else
+ {
+ static struct
+ {
+ char *name;
+ int size;
+ int (*loader)(File *, int, struct TapeInfo *);
+ }
+ chunk_info[] =
+ {
+ { "VERS", TAPE_CHUNK_VERS_SIZE, LoadTape_VERS },
+ { "HEAD", TAPE_CHUNK_HEAD_SIZE, LoadTape_HEAD },
+ { "INFO", -1, LoadTape_INFO },
+ { "BODY", -1, LoadTape_BODY },
+ { NULL, 0, NULL }
+ };
+
+ while (getFileChunkBE(file, chunk_name, &chunk_size))
+ {
+ int i = 0;
+
+ while (chunk_info[i].name != NULL &&
+ !strEqual(chunk_name, chunk_info[i].name))
+ i++;
+
+ if (chunk_info[i].name == NULL)
+ {
+ Error(ERR_WARN, "unknown chunk '%s' in tape file '%s'",
+ chunk_name, filename);
+ ReadUnusedBytesFromFile(file, chunk_size);
+ }
+ else if (chunk_info[i].size != -1 &&
+ chunk_info[i].size != chunk_size)
+ {
+ Error(ERR_WARN, "wrong size (%d) of chunk '%s' in tape file '%s'",
+ chunk_size, chunk_name, filename);
+ ReadUnusedBytesFromFile(file, chunk_size);
+ }
+ else
+ {
+ // call function to load this tape chunk
+ int chunk_size_expected =
+ (chunk_info[i].loader)(file, chunk_size, &tape);
+
+ // the size of some chunks cannot be checked before reading other
+ // chunks first (like "HEAD" and "BODY") that contain some header
+ // information, so check them here
+ if (chunk_size_expected != chunk_size)
+ {
+ Error(ERR_WARN, "wrong size (%d) of chunk '%s' in tape file '%s'",
+ chunk_size, chunk_name, filename);
+ }
+ }
+ }
+ }
+
+ closeFile(file);
+
+ tape.length_frames = GetTapeLengthFrames();
+ tape.length_seconds = GetTapeLengthSeconds();
+
+#if 0
+ printf("::: tape file version: %d\n", tape.file_version);
+ printf("::: tape game version: %d\n", tape.game_version);
+ printf("::: tape engine version: %d\n", tape.engine_version);
+#endif
+}
+
+void LoadTape(int nr)
+{
+ char *filename = getTapeFilename(nr);
+
+ LoadTapeFromFilename(filename);
+}
+
+void LoadSolutionTape(int nr)
+{
+ char *filename = getSolutionTapeFilename(nr);
+
+ LoadTapeFromFilename(filename);
+
+ if (TAPE_IS_EMPTY(tape) &&
+ level.game_engine_type == GAME_ENGINE_TYPE_SP &&
+ level.native_sp_level->demo.is_available)
+ CopyNativeTape_SP_to_RND(&level);
+}
+
+static void SaveTape_VERS(FILE *file, struct TapeInfo *tape)
+{
+ putFileVersion(file, tape->file_version);
+ putFileVersion(file, tape->game_version);
+}
+
+static void SaveTape_HEAD(FILE *file, struct TapeInfo *tape)
+{
+ int i;
+ byte store_participating_players = 0;
+
+ // set bits for participating players for compact storage
+ for (i = 0; i < MAX_PLAYERS; i++)
+ if (tape->player_participates[i])
+ store_participating_players |= (1 << i);
+
+ putFile32BitBE(file, tape->random_seed);
+ putFile32BitBE(file, tape->date);
+ putFile32BitBE(file, tape->length);
+
+ putFile8Bit(file, store_participating_players);
+
+ putFile8Bit(file, (tape->use_mouse ? 1 : 0));
+
+ // unused bytes not at the end here for 4-byte alignment of engine_version
+ WriteUnusedBytesToFile(file, TAPE_CHUNK_HEAD_UNUSED);
+
+ putFileVersion(file, tape->engine_version);
+}
+
+static void SaveTape_INFO(FILE *file, struct TapeInfo *tape)
+{
+ int level_identifier_size = strlen(tape->level_identifier) + 1;
+ int i;
+
+ putFile16BitBE(file, level_identifier_size);
+
+ for (i = 0; i < level_identifier_size; i++)
+ putFile8Bit(file, tape->level_identifier[i]);
+
+ putFile16BitBE(file, tape->level_nr);
+}
+
+static void SaveTape_BODY(FILE *file, struct TapeInfo *tape)
+{
+ int i, j;
+
+ for (i = 0; i < tape->length; i++)
+ {
+ if (tape->use_mouse)
+ {
+ putFile8Bit(file, tape->pos[i].action[TAPE_ACTION_LX]);
+ putFile8Bit(file, tape->pos[i].action[TAPE_ACTION_LY]);
+ putFile8Bit(file, tape->pos[i].action[TAPE_ACTION_BUTTON]);
+ }
+ else
+ {
+ for (j = 0; j < MAX_PLAYERS; j++)
+ if (tape->player_participates[j])
+ putFile8Bit(file, tape->pos[i].action[j]);
+ }
+
+ putFile8Bit(file, tape->pos[i].delay);
+ }
+}
+
+void SaveTape(int nr)
+{
+ char *filename = getTapeFilename(nr);
+ FILE *file;
+ int num_participating_players = 0;
+ int tape_pos_size;
+ int info_chunk_size;
+ int body_chunk_size;
+ int i;
+
+ InitTapeDirectory(leveldir_current->subdir);
+
+ if (!(file = fopen(filename, MODE_WRITE)))
+ {
+ Error(ERR_WARN, "cannot save level recording file '%s'", filename);
+ return;
+ }
+
+ tape.file_version = FILE_VERSION_ACTUAL;
+ tape.game_version = GAME_VERSION_ACTUAL;
+
+ // count number of participating players
+ for (i = 0; i < MAX_PLAYERS; i++)
+ if (tape.player_participates[i])
+ num_participating_players++;
+
+ tape_pos_size = (tape.use_mouse ? 3 : num_participating_players) + 1;
+
+ info_chunk_size = 2 + (strlen(tape.level_identifier) + 1) + 2;
+ body_chunk_size = tape_pos_size * tape.length;
+
+ putFileChunkBE(file, "RND1", CHUNK_SIZE_UNDEFINED);
+ putFileChunkBE(file, "TAPE", CHUNK_SIZE_NONE);
+
+ putFileChunkBE(file, "VERS", TAPE_CHUNK_VERS_SIZE);
+ SaveTape_VERS(file, &tape);
+
+ putFileChunkBE(file, "HEAD", TAPE_CHUNK_HEAD_SIZE);
+ SaveTape_HEAD(file, &tape);
+
+ putFileChunkBE(file, "INFO", info_chunk_size);
+ SaveTape_INFO(file, &tape);
+
+ putFileChunkBE(file, "BODY", body_chunk_size);
+ SaveTape_BODY(file, &tape);
+
+ fclose(file);
+
+ SetFilePermissions(filename, PERMS_PRIVATE);
+
+ tape.changed = FALSE;
+}
+
+static boolean SaveTapeCheckedExt(int nr, char *msg_replace, char *msg_saved,
+ unsigned int req_state_added)
+{
+ char *filename = getTapeFilename(nr);
+ boolean new_tape = !fileExists(filename);
+ boolean tape_saved = FALSE;
+
+ if (new_tape || Request(msg_replace, REQ_ASK | req_state_added))
+ {
+ SaveTape(nr);
+
+ if (new_tape)
+ Request(msg_saved, REQ_CONFIRM | req_state_added);
+
+ tape_saved = TRUE;
+ }
+
+ return tape_saved;
+}
+
+boolean SaveTapeChecked(int nr)
+{
+ return SaveTapeCheckedExt(nr, "Replace old tape?", "Tape saved!", 0);
+}
+
+boolean SaveTapeChecked_LevelSolved(int nr)
+{
+ return SaveTapeCheckedExt(nr, "Level solved! Replace old tape?",
+ "Level solved! Tape saved!", REQ_STAY_OPEN);
+}
+
+void DumpTape(struct TapeInfo *tape)
+{
+ int tape_frame_counter;
+ int i, j;
+
+ if (tape->no_valid_file)
+ {
+ Error(ERR_WARN, "cannot dump -- no valid tape file found");
+
+ return;
+ }
+
+ PrintLine("-", 79);
+ Print("Tape of Level %03d (file version %08d, game version %08d)\n",
+ tape->level_nr, tape->file_version, tape->game_version);
+ Print(" (effective engine version %08d)\n",
+ tape->engine_version);
+ Print("Level series identifier: '%s'\n", tape->level_identifier);
+ PrintLine("-", 79);
+
+ tape_frame_counter = 0;
+
+ for (i = 0; i < tape->length; i++)
+ {
+ if (i >= MAX_TAPE_LEN)
+ break;
+
+ Print("%04d: ", i);
+
+ for (j = 0; j < MAX_PLAYERS; j++)
+ {
+ if (tape->player_participates[j])
+ {
+ int action = tape->pos[i].action[j];
+
+ Print("%d:%02x ", j, action);
+ Print("[%c%c%c%c|%c%c] - ",
+ (action & JOY_LEFT ? '<' : ' '),
+ (action & JOY_RIGHT ? '>' : ' '),
+ (action & JOY_UP ? '^' : ' '),
+ (action & JOY_DOWN ? 'v' : ' '),
+ (action & JOY_BUTTON_1 ? '1' : ' '),
+ (action & JOY_BUTTON_2 ? '2' : ' '));
+ }
+ }
+
+ Print("(%03d) ", tape->pos[i].delay);
+ Print("[%05d]\n", tape_frame_counter);
+
+ tape_frame_counter += tape->pos[i].delay;
+ }
+
+ PrintLine("-", 79);
+}
+
+
+// ============================================================================
+// score file functions
+// ============================================================================
+
+void LoadScore(int nr)
+{
+ int i;
+ char *filename = getScoreFilename(nr);
+ char cookie[MAX_LINE_LEN];
+ char line[MAX_LINE_LEN];
+ char *line_ptr;
+ FILE *file;
+
+ // always start with reliable default values
+ for (i = 0; i < MAX_SCORE_ENTRIES; i++)
+ {
+ strcpy(highscore[i].Name, EMPTY_PLAYER_NAME);
+ highscore[i].Score = 0;
+ }
+
+ if (!(file = fopen(filename, MODE_READ)))
+ return;
+
+ // check file identifier
+ if (fgets(cookie, MAX_LINE_LEN, file) == NULL)
+ cookie[0] = '\0';
+ if (strlen(cookie) > 0 && cookie[strlen(cookie) - 1] == '\n')
+ cookie[strlen(cookie) - 1] = '\0';
+
+ if (!checkCookieString(cookie, SCORE_COOKIE))
+ {
+ Error(ERR_WARN, "unknown format of score file '%s'", filename);
+ fclose(file);
+ return;
+ }
+
+ for (i = 0; i < MAX_SCORE_ENTRIES; i++)
+ {
+ if (fscanf(file, "%d", &highscore[i].Score) == EOF)
+ Error(ERR_WARN, "fscanf() failed; %s", strerror(errno));
+ if (fgets(line, MAX_LINE_LEN, file) == NULL)
+ line[0] = '\0';
+
+ if (strlen(line) > 0 && line[strlen(line) - 1] == '\n')
+ line[strlen(line) - 1] = '\0';
+
+ for (line_ptr = line; *line_ptr; line_ptr++)
+ {
+ if (*line_ptr != ' ' && *line_ptr != '\t' && *line_ptr != '\0')
+ {
+ strncpy(highscore[i].Name, line_ptr, MAX_PLAYER_NAME_LEN);
+ highscore[i].Name[MAX_PLAYER_NAME_LEN] = '\0';
+ break;
+ }
+ }
+ }
+
+ fclose(file);
+}
+
+void SaveScore(int nr)
+{
+ int i;
+ int permissions = (program.global_scores ? PERMS_PUBLIC : PERMS_PRIVATE);
+ char *filename = getScoreFilename(nr);
+ FILE *file;
+
+ // used instead of "leveldir_current->subdir" (for network games)
+ InitScoreDirectory(levelset.identifier);
+
+ if (!(file = fopen(filename, MODE_WRITE)))
+ {
+ Error(ERR_WARN, "cannot save score for level %d", nr);
+ return;
+ }
+
+ fprintf(file, "%s\n\n", SCORE_COOKIE);
+
+ for (i = 0; i < MAX_SCORE_ENTRIES; i++)
+ fprintf(file, "%d %s\n", highscore[i].Score, highscore[i].Name);
+
+ fclose(file);
+
+ SetFilePermissions(filename, permissions);
+}
+
+
+// ============================================================================
+// setup file functions
+// ============================================================================
+
+#define TOKEN_STR_PLAYER_PREFIX "player_"
+
+
+static struct TokenInfo global_setup_tokens[] =
+{
+ {
+ TYPE_STRING,
+ &setup.player_name, "player_name"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.sound, "sound"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.sound_loops, "repeating_sound_loops"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.sound_music, "background_music"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.sound_simple, "simple_sound_effects"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.toons, "toons"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.scroll_delay, "scroll_delay"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.scroll_delay_value, "scroll_delay_value"
+ },
+ {
+ TYPE_STRING,
+ &setup.engine_snapshot_mode, "engine_snapshot_mode"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.engine_snapshot_memory, "engine_snapshot_memory"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.fade_screens, "fade_screens"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.autorecord, "automatic_tape_recording"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.show_titlescreen, "show_titlescreen"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.quick_doors, "quick_doors"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.team_mode, "team_mode"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.handicap, "handicap"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.skip_levels, "skip_levels"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.increment_levels, "increment_levels"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.auto_play_next_level, "auto_play_next_level"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.skip_scores_after_game, "skip_scores_after_game"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.time_limit, "time_limit"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.fullscreen, "fullscreen"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.window_scaling_percent, "window_scaling_percent"
+ },
+ {
+ TYPE_STRING,
+ &setup.window_scaling_quality, "window_scaling_quality"
+ },
+ {
+ TYPE_STRING,
+ &setup.screen_rendering_mode, "screen_rendering_mode"
+ },
+ {
+ TYPE_STRING,
+ &setup.vsync_mode, "vsync_mode"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_on_escape, "ask_on_escape"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_on_escape_editor, "ask_on_escape_editor"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_on_game_over, "ask_on_game_over"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.quick_switch, "quick_player_switch"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.input_on_focus, "input_on_focus"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.prefer_aga_graphics, "prefer_aga_graphics"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.game_speed_extended, "game_speed_extended"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.game_frame_delay, "game_frame_delay"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.sp_show_border_elements, "sp_show_border_elements"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.small_game_graphics, "small_game_graphics"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.show_snapshot_buttons, "show_snapshot_buttons"
+ },
+ {
+ TYPE_STRING,
+ &setup.graphics_set, "graphics_set"
+ },
+ {
+ TYPE_STRING,
+ &setup.sounds_set, "sounds_set"
+ },
+ {
+ TYPE_STRING,
+ &setup.music_set, "music_set"
+ },
+ {
+ TYPE_SWITCH3,
+ &setup.override_level_graphics, "override_level_graphics"
+ },
+ {
+ TYPE_SWITCH3,
+ &setup.override_level_sounds, "override_level_sounds"
+ },
+ {
+ TYPE_SWITCH3,
+ &setup.override_level_music, "override_level_music"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.volume_simple, "volume_simple"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.volume_loops, "volume_loops"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.volume_music, "volume_music"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.network_mode, "network_mode"
+ },
+ {
+ TYPE_PLAYER,
+ &setup.network_player_nr, "network_player"
+ },
+ {
+ TYPE_STRING,
+ &setup.network_server_hostname, "network_server_hostname"
+ },
+ {
+ TYPE_STRING,
+ &setup.touch.control_type, "touch.control_type"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.move_distance, "touch.move_distance"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.drop_distance, "touch.drop_distance"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.transparency, "touch.transparency"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.draw_outlined, "touch.draw_outlined"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.draw_pressed, "touch.draw_pressed"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.grid_xsize[0], "touch.virtual_buttons.0.xsize"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.grid_ysize[0], "touch.virtual_buttons.0.ysize"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.grid_xsize[1], "touch.virtual_buttons.1.xsize"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.grid_ysize[1], "touch.virtual_buttons.1.ysize"
+ },
+};
+
+static struct TokenInfo auto_setup_tokens[] =
+{
+ {
+ TYPE_INTEGER,
+ &setup.auto_setup.editor_zoom_tilesize, "editor.zoom_tilesize"
+ },
+};
+
+static struct TokenInfo editor_setup_tokens[] =
+{
+ {
+ TYPE_SWITCH,
+ &setup.editor.el_classic, "editor.el_classic"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor.el_custom, "editor.el_custom"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor.el_user_defined, "editor.el_user_defined"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor.el_dynamic, "editor.el_dynamic"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor.el_headlines, "editor.el_headlines"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor.show_element_token, "editor.show_element_token"
+ },
+};
+
+static struct TokenInfo editor_cascade_setup_tokens[] =
+{
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_bd, "editor.cascade.el_bd"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_em, "editor.cascade.el_em"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_emc, "editor.cascade.el_emc"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_rnd, "editor.cascade.el_rnd"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_sb, "editor.cascade.el_sb"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_sp, "editor.cascade.el_sp"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_dc, "editor.cascade.el_dc"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_dx, "editor.cascade.el_dx"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_mm, "editor.cascade.el_mm"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_df, "editor.cascade.el_df"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_chars, "editor.cascade.el_chars"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_steel_chars, "editor.cascade.el_steel_chars"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_ce, "editor.cascade.el_ce"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_ge, "editor.cascade.el_ge"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_ref, "editor.cascade.el_ref"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_user, "editor.cascade.el_user"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_dynamic, "editor.cascade.el_dynamic"
+ },
+};
+
+static struct TokenInfo shortcut_setup_tokens[] =
+{
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.save_game, "shortcut.save_game"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.load_game, "shortcut.load_game"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.toggle_pause, "shortcut.toggle_pause"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.focus_player[0], "shortcut.focus_player_1"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.focus_player[1], "shortcut.focus_player_2"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.focus_player[2], "shortcut.focus_player_3"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.focus_player[3], "shortcut.focus_player_4"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.focus_player_all, "shortcut.focus_player_all"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_eject, "shortcut.tape_eject"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_extra, "shortcut.tape_extra"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_stop, "shortcut.tape_stop"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_pause, "shortcut.tape_pause"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_record, "shortcut.tape_record"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_play, "shortcut.tape_play"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.sound_simple, "shortcut.sound_simple"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.sound_loops, "shortcut.sound_loops"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.sound_music, "shortcut.sound_music"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.snap_left, "shortcut.snap_left"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.snap_right, "shortcut.snap_right"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.snap_up, "shortcut.snap_up"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.snap_down, "shortcut.snap_down"
+ },
+};
+
+static struct SetupInputInfo setup_input;
+static struct TokenInfo player_setup_tokens[] =
+{
+ {
+ TYPE_BOOLEAN,
+ &setup_input.use_joystick, ".use_joystick"
+ },
+ {
+ TYPE_STRING,
+ &setup_input.joy.device_name, ".joy.device_name"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.xleft, ".joy.xleft"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.xmiddle, ".joy.xmiddle"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.xright, ".joy.xright"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.yupper, ".joy.yupper"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.ymiddle, ".joy.ymiddle"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.ylower, ".joy.ylower"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.snap, ".joy.snap_field"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.drop, ".joy.place_bomb"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.left, ".key.move_left"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.right, ".key.move_right"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.up, ".key.move_up"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.down, ".key.move_down"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.snap, ".key.snap_field"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.drop, ".key.place_bomb"
+ },
+};
+
+static struct TokenInfo system_setup_tokens[] =
+{
+ {
+ TYPE_STRING,
+ &setup.system.sdl_videodriver, "system.sdl_videodriver"
+ },
+ {
+ TYPE_STRING,
+ &setup.system.sdl_audiodriver, "system.sdl_audiodriver"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.system.audio_fragment_size, "system.audio_fragment_size"
+ },
+};
+
+static struct TokenInfo internal_setup_tokens[] =
+{
+ {
+ TYPE_STRING,
+ &setup.internal.program_title, "program_title"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_version, "program_version"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_author, "program_author"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_email, "program_email"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_website, "program_website"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_copyright, "program_copyright"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_company, "program_company"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_icon_file, "program_icon_file"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.default_graphics_set, "default_graphics_set"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.default_sounds_set, "default_sounds_set"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.default_music_set, "default_music_set"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.fallback_graphics_file, "fallback_graphics_file"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.fallback_sounds_file, "fallback_sounds_file"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.fallback_music_file, "fallback_music_file"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.default_level_series, "default_level_series"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.internal.default_window_width, "default_window_width"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.internal.default_window_height, "default_window_height"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.choose_from_top_leveldir, "choose_from_top_leveldir"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.show_scaling_in_title, "show_scaling_in_title"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_game, "menu_game"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_editor, "menu_editor"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_graphics, "menu_graphics"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_sound, "menu_sound"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_artwork, "menu_artwork"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_input, "menu_input"
+ },