X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ffiles.c;h=4de97c6c89736aeba2381600806ef3fae9fe8d85;hb=b81f28710057e7d84528b65b92e9b4d1aaadab6c;hp=5da89a735d83216a0e8d023ec966ecaa29204d3b;hpb=b59a0eedca464cba38e8a6bcfae54db32ac6b15e;p=rocksndiamonds.git diff --git a/src/files.c b/src/files.c index 5da89a73..4de97c6c 100644 --- a/src/files.c +++ b/src/files.c @@ -152,8 +152,8 @@ static int LoadLevel_HEAD(FILE *file, int chunk_size, struct LevelInfo *level) lev_fieldx = level->fieldx = fgetc(file); lev_fieldy = level->fieldy = fgetc(file); - level->time = getFile16BitInteger(file, BYTE_ORDER_BIG_ENDIAN); - level->gems_needed = getFile16BitInteger(file, BYTE_ORDER_BIG_ENDIAN); + level->time = getFile16BitBE(file); + level->gems_needed = getFile16BitBE(file); for(i=0; iname[i] = fgetc(file); @@ -229,8 +229,7 @@ static int LoadLevel_CONT(FILE *file, int chunk_size, struct LevelInfo *level) for(x=0; x<3; x++) level->yam_content[i][x][y] = checkLevelElement(level->encoding_16bit_field ? - getFile16BitInteger(file, BYTE_ORDER_BIG_ENDIAN) : - fgetc(file)); + getFile16BitBE(file) : fgetc(file)); return chunk_size; } @@ -257,8 +256,7 @@ static int LoadLevel_BODY(FILE *file, int chunk_size, struct LevelInfo *level) for(x=0; xfieldx; x++) Feld[x][y] = Ur[x][y] = checkLevelElement(level->encoding_16bit_field ? - getFile16BitInteger(file, BYTE_ORDER_BIG_ENDIAN) : - fgetc(file)); + getFile16BitBE(file) : fgetc(file)); return chunk_size; } @@ -269,7 +267,7 @@ static int LoadLevel_CNT2(FILE *file, int chunk_size, struct LevelInfo *level) int num_contents, content_xsize, content_ysize; int content_array[MAX_ELEMENT_CONTENTS][3][3]; - element = checkLevelElement(getFile16BitInteger(file,BYTE_ORDER_BIG_ENDIAN)); + element = checkLevelElement(getFile16BitBE(file)); num_contents = fgetc(file); content_xsize = fgetc(file); content_ysize = fgetc(file); @@ -278,8 +276,7 @@ static int LoadLevel_CNT2(FILE *file, int chunk_size, struct LevelInfo *level) for(i=0; i MAX_ELEMENT_CONTENTS) @@ -323,12 +320,12 @@ void LoadLevel(int level_nr) return; } - getFileChunk(file, chunk_name, NULL, BYTE_ORDER_BIG_ENDIAN); + getFileChunkBE(file, chunk_name, NULL); if (strcmp(chunk_name, "RND1") == 0) { - getFile32BitInteger(file, BYTE_ORDER_BIG_ENDIAN); /* not used */ + getFile32BitBE(file); /* not used */ - getFileChunk(file, chunk_name, NULL, BYTE_ORDER_BIG_ENDIAN); + getFileChunkBE(file, chunk_name, NULL); if (strcmp(chunk_name, "CAVE") != 0) { Error(ERR_WARN, "unknown format of level file '%s'", filename); @@ -386,7 +383,7 @@ void LoadLevel(int level_nr) { NULL, 0, NULL } }; - while (getFileChunk(file, chunk_name, &chunk_size, BYTE_ORDER_BIG_ENDIAN)) + while (getFileChunkBE(file, chunk_name, &chunk_size)) { int i = 0; @@ -481,8 +478,8 @@ static void SaveLevel_HEAD(FILE *file, struct LevelInfo *level) fputc(level->fieldx, file); fputc(level->fieldy, file); - putFile16BitInteger(file, level->time, BYTE_ORDER_BIG_ENDIAN); - putFile16BitInteger(file, level->gems_needed, BYTE_ORDER_BIG_ENDIAN); + putFile16BitBE(file, level->time); + putFile16BitBE(file, level->gems_needed); for(i=0; iname[i], file); @@ -531,8 +528,7 @@ static void SaveLevel_CONT(FILE *file, struct LevelInfo *level) for(y=0; y<3; y++) for(x=0; x<3; x++) if (level->encoding_16bit_field) - putFile16BitInteger(file, level->yam_content[i][x][y], - BYTE_ORDER_BIG_ENDIAN); + putFile16BitBE(file, level->yam_content[i][x][y]); else fputc(level->yam_content[i][x][y], file); } @@ -545,7 +541,7 @@ static void SaveLevel_BODY(FILE *file, struct LevelInfo *level) for(y=0; yfieldy; y++) for(x=0; xfieldx; x++) if (level->encoding_16bit_field) - putFile16BitInteger(file, Ur[x][y], BYTE_ORDER_BIG_ENDIAN); + putFile16BitBE(file, Ur[x][y]); else fputc(Ur[x][y], file); } @@ -588,7 +584,7 @@ static void SaveLevel_CNT2(FILE *file, struct LevelInfo *level, int element) return; } - putFile16BitInteger(file, element, BYTE_ORDER_BIG_ENDIAN); + putFile16BitBE(file, element); fputc(num_contents, file); fputc(content_xsize, file); fputc(content_ysize, file); @@ -598,8 +594,7 @@ static void SaveLevel_CNT2(FILE *file, struct LevelInfo *level, int element) for(i=0; irandom_seed = getFile32BitInteger(file, BYTE_ORDER_BIG_ENDIAN); - tape->date = getFile32BitInteger(file, BYTE_ORDER_BIG_ENDIAN); - tape->length = getFile32BitInteger(file, BYTE_ORDER_BIG_ENDIAN); + 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) @@ -840,12 +835,12 @@ void LoadTape(int level_nr) if (!(file = fopen(filename, MODE_READ))) return; - getFileChunk(file, chunk_name, NULL, BYTE_ORDER_BIG_ENDIAN); + getFileChunkBE(file, chunk_name, NULL); if (strcmp(chunk_name, "RND1") == 0) { - getFile32BitInteger(file, BYTE_ORDER_BIG_ENDIAN); /* not used */ + getFile32BitBE(file); /* not used */ - getFileChunk(file, chunk_name, NULL, BYTE_ORDER_BIG_ENDIAN); + getFileChunkBE(file, chunk_name, NULL); if (strcmp(chunk_name, "TAPE") != 0) { Error(ERR_WARN, "unknown format of tape file '%s'", filename); @@ -900,7 +895,7 @@ void LoadTape(int level_nr) { NULL, 0, NULL } }; - while (getFileChunk(file, chunk_name, &chunk_size, BYTE_ORDER_BIG_ENDIAN)) + while (getFileChunkBE(file, chunk_name, &chunk_size)) { int i = 0; @@ -954,9 +949,9 @@ static void SaveTape_HEAD(FILE *file, struct TapeInfo *tape) if (tape->player_participates[i]) store_participating_players |= (1 << i); - putFile32BitInteger(file, tape->random_seed, BYTE_ORDER_BIG_ENDIAN); - putFile32BitInteger(file, tape->date, BYTE_ORDER_BIG_ENDIAN); - putFile32BitInteger(file, tape->length, BYTE_ORDER_BIG_ENDIAN); + putFile32BitBE(file, tape->random_seed); + putFile32BitBE(file, tape->date); + putFile32BitBE(file, tape->length); fputc(store_participating_players, file); @@ -1009,16 +1004,16 @@ void SaveTape(int level_nr) body_chunk_size = (num_participating_players + 1) * tape.length; - putFileChunk(file, "RND1", CHUNK_SIZE_UNDEFINED, BYTE_ORDER_BIG_ENDIAN); - putFileChunk(file, "TAPE", CHUNK_SIZE_NONE, BYTE_ORDER_BIG_ENDIAN); + putFileChunkBE(file, "RND1", CHUNK_SIZE_UNDEFINED); + putFileChunkBE(file, "TAPE", CHUNK_SIZE_NONE); - putFileChunk(file, "VERS", FILE_VERS_CHUNK_SIZE, BYTE_ORDER_BIG_ENDIAN); + putFileChunkBE(file, "VERS", FILE_VERS_CHUNK_SIZE); WriteChunk_VERS(file, FILE_VERSION_ACTUAL, GAME_VERSION_ACTUAL); - putFileChunk(file, "HEAD", TAPE_HEADER_SIZE, BYTE_ORDER_BIG_ENDIAN); + putFileChunkBE(file, "HEAD", TAPE_HEADER_SIZE); SaveTape_HEAD(file, &tape); - putFileChunk(file, "BODY", body_chunk_size, BYTE_ORDER_BIG_ENDIAN); + putFileChunkBE(file, "BODY", body_chunk_size); SaveTape_BODY(file, &tape); fclose(file); @@ -1162,52 +1157,60 @@ void SaveScore(int level_nr) /* setup file functions */ /* ========================================================================= */ -#define TOKEN_STR_PLAYER_PREFIX "player_" +#define TOKEN_STR_PLAYER_PREFIX "player_" /* global setup */ -#define SETUP_TOKEN_PLAYER_NAME 0 -#define SETUP_TOKEN_SOUND 1 -#define SETUP_TOKEN_SOUND_LOOPS 2 -#define SETUP_TOKEN_SOUND_MUSIC 3 -#define SETUP_TOKEN_SOUND_SIMPLE 4 -#define SETUP_TOKEN_TOONS 5 -#define SETUP_TOKEN_SCROLL_DELAY 6 -#define SETUP_TOKEN_SOFT_SCROLLING 7 -#define SETUP_TOKEN_FADING 8 -#define SETUP_TOKEN_AUTORECORD 9 -#define SETUP_TOKEN_QUICK_DOORS 10 -#define SETUP_TOKEN_TEAM_MODE 11 -#define SETUP_TOKEN_HANDICAP 12 -#define SETUP_TOKEN_TIME_LIMIT 13 -#define SETUP_TOKEN_FULLSCREEN 14 - -#define NUM_GLOBAL_SETUP_TOKENS 15 +#define SETUP_TOKEN_PLAYER_NAME 0 +#define SETUP_TOKEN_SOUND 1 +#define SETUP_TOKEN_SOUND_LOOPS 2 +#define SETUP_TOKEN_SOUND_MUSIC 3 +#define SETUP_TOKEN_SOUND_SIMPLE 4 +#define SETUP_TOKEN_TOONS 5 +#define SETUP_TOKEN_SCROLL_DELAY 6 +#define SETUP_TOKEN_SOFT_SCROLLING 7 +#define SETUP_TOKEN_FADING 8 +#define SETUP_TOKEN_AUTORECORD 9 +#define SETUP_TOKEN_QUICK_DOORS 10 +#define SETUP_TOKEN_TEAM_MODE 11 +#define SETUP_TOKEN_HANDICAP 12 +#define SETUP_TOKEN_TIME_LIMIT 13 +#define SETUP_TOKEN_FULLSCREEN 14 +#define SETUP_TOKEN_ASK_ON_ESCAPE 15 +#define SETUP_TOKEN_GRAPHICS_SET 16 +#define SETUP_TOKEN_SOUNDS_SET 17 +#define SETUP_TOKEN_MUSIC_SET 18 +#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 19 +#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 20 +#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 21 + +#define NUM_GLOBAL_SETUP_TOKENS 22 /* shortcut setup */ -#define SETUP_TOKEN_SAVE_GAME 0 -#define SETUP_TOKEN_LOAD_GAME 1 +#define SETUP_TOKEN_SAVE_GAME 0 +#define SETUP_TOKEN_LOAD_GAME 1 +#define SETUP_TOKEN_TOGGLE_PAUSE 2 -#define NUM_SHORTCUT_SETUP_TOKENS 2 +#define NUM_SHORTCUT_SETUP_TOKENS 3 /* player setup */ -#define SETUP_TOKEN_USE_JOYSTICK 0 -#define SETUP_TOKEN_JOY_DEVICE_NAME 1 -#define SETUP_TOKEN_JOY_XLEFT 2 -#define SETUP_TOKEN_JOY_XMIDDLE 3 -#define SETUP_TOKEN_JOY_XRIGHT 4 -#define SETUP_TOKEN_JOY_YUPPER 5 -#define SETUP_TOKEN_JOY_YMIDDLE 6 -#define SETUP_TOKEN_JOY_YLOWER 7 -#define SETUP_TOKEN_JOY_SNAP 8 -#define SETUP_TOKEN_JOY_BOMB 9 -#define SETUP_TOKEN_KEY_LEFT 10 -#define SETUP_TOKEN_KEY_RIGHT 11 -#define SETUP_TOKEN_KEY_UP 12 -#define SETUP_TOKEN_KEY_DOWN 13 -#define SETUP_TOKEN_KEY_SNAP 14 -#define SETUP_TOKEN_KEY_BOMB 15 - -#define NUM_PLAYER_SETUP_TOKENS 16 +#define SETUP_TOKEN_USE_JOYSTICK 0 +#define SETUP_TOKEN_JOY_DEVICE_NAME 1 +#define SETUP_TOKEN_JOY_XLEFT 2 +#define SETUP_TOKEN_JOY_XMIDDLE 3 +#define SETUP_TOKEN_JOY_XRIGHT 4 +#define SETUP_TOKEN_JOY_YUPPER 5 +#define SETUP_TOKEN_JOY_YMIDDLE 6 +#define SETUP_TOKEN_JOY_YLOWER 7 +#define SETUP_TOKEN_JOY_SNAP 8 +#define SETUP_TOKEN_JOY_BOMB 9 +#define SETUP_TOKEN_KEY_LEFT 10 +#define SETUP_TOKEN_KEY_RIGHT 11 +#define SETUP_TOKEN_KEY_UP 12 +#define SETUP_TOKEN_KEY_DOWN 13 +#define SETUP_TOKEN_KEY_SNAP 14 +#define SETUP_TOKEN_KEY_BOMB 15 + +#define NUM_PLAYER_SETUP_TOKENS 16 static struct SetupInfo si; static struct SetupShortcutInfo ssi; @@ -1230,14 +1233,22 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_SWITCH, &si.team_mode, "team_mode" }, { TYPE_SWITCH, &si.handicap, "handicap" }, { TYPE_SWITCH, &si.time_limit, "time_limit" }, - { TYPE_SWITCH, &si.fullscreen, "fullscreen" } + { TYPE_SWITCH, &si.fullscreen, "fullscreen" }, + { TYPE_SWITCH, &si.ask_on_escape, "ask_on_escape" }, + { TYPE_STRING, &si.graphics_set, "graphics_set" }, + { TYPE_STRING, &si.sounds_set, "sounds_set" }, + { TYPE_STRING, &si.music_set, "music_set" }, + { TYPE_SWITCH, &si.override_level_graphics, "override_level_graphics" }, + { TYPE_SWITCH, &si.override_level_sounds, "override_level_sounds" }, + { TYPE_SWITCH, &si.override_level_music, "override_level_music" }, }; static struct TokenInfo shortcut_setup_tokens[] = { /* shortcut setup */ - { TYPE_KEY_X11, &ssi.save_game, "shortcut.save_game" }, - { TYPE_KEY_X11, &ssi.load_game, "shortcut.load_game" } + { TYPE_KEY_X11, &ssi.save_game, "shortcut.save_game" }, + { TYPE_KEY_X11, &ssi.load_game, "shortcut.load_game" }, + { TYPE_KEY_X11, &ssi.toggle_pause, "shortcut.toggle_pause" } }; static struct TokenInfo player_setup_tokens[] = @@ -1283,9 +1294,18 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->handicap = TRUE; si->time_limit = TRUE; si->fullscreen = FALSE; + si->ask_on_escape = TRUE; + + si->graphics_set = getStringCopy(GRAPHICS_SUBDIR); + si->sounds_set = getStringCopy(SOUNDS_SUBDIR); + si->music_set = getStringCopy(MUSIC_SUBDIR); + si->override_level_graphics = FALSE; + si->override_level_sounds = FALSE; + si->override_level_music = FALSE; si->shortcut.save_game = DEFAULT_KEY_SAVE_GAME; si->shortcut.load_game = DEFAULT_KEY_LOAD_GAME; + si->shortcut.toggle_pause = DEFAULT_KEY_TOGGLE_PAUSE; for (i=0; i