X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame_em%2Fconvert.c;h=d61e33eec5db472f1f55df60d9bad4b77221fe8b;hp=a3553a791009571aa57043c5aadcf3a3d7baae19;hb=99261bc36a147246e39cdc6d5ce9b098257c4d1b;hpb=7c0b78ef65acbe880d7f905a5e38fb7bdac8f007 diff --git a/src/game_em/convert.c b/src/game_em/convert.c index a3553a79..d61e33ee 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -150,9 +150,6 @@ int cleanup_em_level(unsigned char *src, int length, char *filename) for (i = 2112; i < 2148; i++) src[i] = src[i - 64]; } - -#if 1 /* ================================================================== */ - else if (length >= 2106 && (src[1983] == 27 || /* encrypted (only EM I/II/III) */ src[1983] == 116 || /* unencrypted (usual case) */ @@ -237,93 +234,6 @@ int cleanup_em_level(unsigned char *src, int length, char *filename) return FILE_VERSION_EM_UNKNOWN; } -#else /* ================================================================== */ - -#if 0 - else if (length >= 2106) /* !!! TEST ONLY: SHOW BROKEN LEVELS !!! */ -#else - else if (length >= 2106 && - src[1983] == 116) -#endif - { - /* ---------- this cave has V4 file format ---------- */ - file_version = FILE_VERSION_EM_V4; - - /* remap elements to internal EMC level format */ - for (i = 0; i < 2048; i++) - src[i] = remap_v4[src[i]]; - for (i = 2048; i < 2084; i++) - src[i] = remap_v4eater[src[i] >= 28 ? 0 : src[i]]; - for (i = 2112; i < 2148; i++) - src[i] = src[i - 64]; - } - else if (length >= 2106 && - src[0] == 241 && /* <-- Emerald Mine I and III levels */ - src[1983] == 27) - { - unsigned char j = 94; - - /* ---------- this cave has V3 file format ---------- */ - file_version = FILE_VERSION_EM_V3; - - /* decrypt encrypted level file */ - for (i = 0; i < 2106; i++) - src[i] = (src[i] ^ (j += 7)) - 0x11; - - src[1] = 131; - - /* remap elements to internal EMC level format */ - for (i = 0; i < 2048; i++) - src[i] = remap_v4[src[i]]; - for (i = 2048; i < 2084; i++) - src[i] = remap_v4eater[src[i] >= 28 ? 0 : src[i]]; - for (i = 2112; i < 2148; i++) - src[i] = src[i - 64]; - } -#if 1 - else if (length >= 2106 && - src[0] == 245 && /* <-- Emerald Mine II levels */ - src[1983] == 27) - { - unsigned char j = 94; - - /* ---------- this cave has V3 file format ---------- */ - file_version = FILE_VERSION_EM_V3; - - /* decrypt encrypted level file */ - for (i = 0; i < 2106; i++) - src[i] = (src[i] ^ (j += 7)) - 0x11; - - src[0] = 131; /* needed for Emerald Mine II levels */ - src[1] = 131; - - /* remap elements to internal EMC level format */ - for (i = 0; i < 2048; i++) - src[i] = remap_v4[src[i]]; - for (i = 2048; i < 2084; i++) - src[i] = remap_v4eater[src[i] >= 28 ? 0 : src[i]]; - for (i = 2112; i < 2148; i++) - src[i] = src[i - 64]; - - /* fix copyright sign in Emerald Mine II levels */ - for (i = 0; i < 2048; i++) - if (src[i] == 241) - src[i] = 254; /* replace 'Xdecor_1' with 'Xalpha_copyr' */ - } -#endif - else - { - /* ---------- this cave has unknown file format ---------- */ - -#if 0 - printf("::: %d, %d\n", src[0], src[1983]); -#endif - - return 0; - } - -#endif /* ================================================================== */ - if (file_version < FILE_VERSION_EM_V6) { /* id */ @@ -347,17 +257,7 @@ int cleanup_em_level(unsigned char *src, int length, char *filename) /* ball data */ src[2159] = 128; - -#if 0 - printf("::: STORED TIME (< V6): %d s\n", src[2094] * 10); -#endif - } -#if 0 - else - { - printf("::: STORED TIME (>= V6): %d s\n", src[2110] * 256 + src[2111]); } -#endif /* ---------- at this stage, the cave data always has V6 format ---------- */ @@ -554,11 +454,9 @@ int cleanup_em_level(unsigned char *src, int length, char *filename) /* size of v6 cave */ length = 2172; -#if 1 -#if 1 +#if 0 if (options.debug) -#endif - printf("::: EM level file version: %d\n", file_version); + Error(ERR_DEBUG, "EM level file version: %d", file_version); #endif return file_version; @@ -1093,14 +991,8 @@ void convert_em_level(unsigned char *src, int file_version) /* at last, set the two players at their positions in the playfield */ /* (native EM[C] levels always have exactly two players in a level) */ -#if 1 for (i = 0; i < 2; i++) native_em_level.cave[ply[i].x_initial][ply[i].y_initial] = Zplayer; -#else - for (i = 0; i < 2; i++) - if (ply[i].alive_initial) - native_em_level.cave[ply[i].x_initial][ply[i].y_initial] = Zplayer; -#endif native_em_level.file_version = file_version; } @@ -1109,7 +1001,7 @@ void prepare_em_level(void) { int i, x, y; int players_left; - int num_tape_players; + boolean team_mode; /* reset all runtime variables to their initial values */ @@ -1125,11 +1017,7 @@ void prepare_em_level(void) for (x = 0; x < WIDTH; x++) Draw[y][x] = Cave[y][x]; -#if 1 lev.time_initial = lev.time_seconds; -#else - lev.time_initial = (lev.time_seconds * 50 + 7) / 8; -#endif lev.time = lev.time_initial; lev.required = lev.required_initial; @@ -1176,12 +1064,10 @@ void prepare_em_level(void) } } - num_tape_players = getNumActivePlayers_EM(); + team_mode = getTeamMode_EM(); - if (num_tape_players != -1) - lev.home_initial = MIN(lev.home_initial, num_tape_players); - else if (!setup.team_mode) - lev.home_initial = MIN(lev.home_initial, 1); + if (!team_mode) + lev.home_initial = 1; lev.home = lev.home_initial; players_left = lev.home_initial; @@ -1221,14 +1107,20 @@ void prepare_em_level(void) ply[i].joy_n = ply[i].joy_e = ply[i].joy_s = ply[i].joy_w = 0; ply[i].joy_snap = ply[i].joy_drop = 0; ply[i].joy_stick = ply[i].joy_spin = 0; - -#if 0 - printf("player %d: x/y == %d/%d, alive == %d\n", - i, ply[i].x_initial, ply[i].y_initial, ply[i].alive); -#endif } + // the following engine variables are initialized to version-specific values + // in function InitGameEngine() (src/game.c): + // + // - game_em.use_single_button (default: TRUE) + // - game_em.use_snap_key_bug (default: FALSE) + + game_em.level_solved = FALSE; + game_em.game_over = FALSE; + game_em.any_player_moving = FALSE; + game_em.any_player_snapping = FALSE; + game_em.last_moving_player = 0; /* default: first player */ for (i = 0; i < MAX_PLAYERS; i++)