X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_em%2Freademc.c;fp=src%2Fgame_em%2Freademc.c;h=3f366227a6785c7d0cee3010ac22f8c723c66209;hb=d4c19f2f629758803f62f52809c889052ddf3ccf;hp=a8449a04dd4113b1ffb03b1bcc3498e2e3f4d62c;hpb=e8bfe523ee2136ad29a1c3534142883540e29e35;p=rocksndiamonds.git diff --git a/src/game_em/reademc.c b/src/game_em/reademc.c index a8449a04..3f366227 100644 --- a/src/game_em/reademc.c +++ b/src/game_em/reademc.c @@ -42,7 +42,7 @@ #define GET_BE16(x) ((&x)[0] << 8 | (&x)[1]) -static const short map_emc[256] = +static const short map_emc_raw[256] = { Cstone, Cstone, Cdiamond, Cdiamond, // 0 Calien, Calien, Cpause, Cpause, // 4 @@ -113,6 +113,21 @@ static const short map_emc[256] = Cwall_1, Cblank, Calpha_copyr, Cfake_acid_1 // 252 }; +static const short swap_emc[CAVE_TILE_MAX] = +{ + [Cdirt] = Cgrass, + [Cgrass] = Cdirt, + + [Csteel_1] = Csteel_2, + [Csteel_2] = Csteel_1, + + [Cwall_1] = Cwall_2, + [Cwall_2] = Cwall_1, + + [Croundwall_1] = Croundwall_2, + [Croundwall_2] = Croundwall_1 +}; + static struct { int bit_nr; @@ -256,6 +271,19 @@ static int eater_offset[8] = void convert_em_level(unsigned char *src, int file_version) { int i, x, y, temp; + short map_emc[256]; + + /* initialize element mapping */ + + for (i = 0; i < 256; i++) + map_emc[i] = map_emc_raw[i]; + + /* swap tiles for pre-EMC caves (older than V5/V6), if needed */ + + if (swapTiles_EM(file_version < FILE_VERSION_EM_V5)) + for (i = 0; i < 256; i++) + if (swap_emc[map_emc[i]] != 0) + map_emc[i] = swap_emc[map_emc[i]]; /* common to all emc caves */