added using separate constants for tiles in EM engine caves and game logic
authorHolger Schemel <info@artsoft.org>
Wed, 19 Feb 2020 15:00:15 +0000 (16:00 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 19 May 2020 16:19:58 +0000 (18:19 +0200)
src/files.c
src/game.c
src/game_em/cave.c
src/game_em/cave.h
src/game_em/convert.c
src/game_em/export.h
src/game_em/reademc.c
src/tools.c
src/tools.h

index e94692c5edd653cda057191333b59bb3060d709f..bc076598094227a1dfece0a6d33d359ff7a2b188 100644 (file)
@@ -3539,7 +3539,7 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level)
     for (y = 0; y < 3; y++)
       for (x = 0; x < 3; x++)
        cav->eater_array[i][y * 3 + x] =
-         map_element_RND_to_EM(level->yamyam_content[i].e[x][y]);
+         map_element_RND_to_EM_cave(level->yamyam_content[i].e[x][y]);
 
   cav->amoeba_time             = level->amoeba_speed;
   cav->wonderwall_time         = level->time_magic_wall;
@@ -3567,23 +3567,23 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level)
   for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
     for (j = 0; j < 8; j++)
       cav->ball_array[i][j] =
-       map_element_RND_to_EM(level->
-                             ball_content[i].e[ball_xy[j][0]][ball_xy[j][1]]);
+       map_element_RND_to_EM_cave(level->ball_content[i].
+                                  e[ball_xy[j][0]][ball_xy[j][1]]);
 
   map_android_clone_elements_RND_to_EM(level);
 
-  // first fill the complete playfield with the default border element
+  // first fill the complete playfield with the empty space element
   for (y = 0; y < EM_MAX_CAVE_HEIGHT; y++)
     for (x = 0; x < EM_MAX_CAVE_WIDTH; x++)
-      cav->cave[x][y] = Zborder;
+      cav->cave[x][y] = Cblank;
 
   // then copy the real level contents from level file into the playfield
   for (y = 0; y < cav->height; y++) for (x = 0; x < cav->width; x++)
   {
-    int new_element = map_element_RND_to_EM(level->field[x][y]);
+    int new_element = map_element_RND_to_EM_cave(level->field[x][y]);
 
     if (level->field[x][y] == EL_AMOEBA_DEAD)
-      new_element = map_element_RND_to_EM(EL_AMOEBA_WET);
+      new_element = map_element_RND_to_EM_cave(EL_AMOEBA_WET);
 
     cav->cave[x][y] = new_element;
   }
@@ -3604,7 +3604,7 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level)
       cav->player_x[player_nr] = x;
       cav->player_y[player_nr] = y;
 
-      cav->cave[x][y] = map_element_RND_to_EM(EL_EMPTY);
+      cav->cave[x][y] = map_element_RND_to_EM_cave(EL_EMPTY);
     }
   }
 }
@@ -3651,7 +3651,7 @@ static void CopyNativeLevel_EM_to_RND(struct LevelInfo *level)
     for (y = 0; y < 3; y++)
       for (x = 0; x < 3; x++)
        level->yamyam_content[i].e[x][y] =
-         map_element_EM_to_RND(cav->eater_array[i][y * 3 + x]);
+         map_element_EM_to_RND_cave(cav->eater_array[i][y * 3 + x]);
 
   level->amoeba_speed          = cav->amoeba_time;
   level->time_magic_wall       = cav->wonderwall_time;
@@ -3677,14 +3677,14 @@ static void CopyNativeLevel_EM_to_RND(struct LevelInfo *level)
   for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
     for (j = 0; j < 8; j++)
       level->ball_content[i].e[ball_xy[j][0]][ball_xy[j][1]] =
-       map_element_EM_to_RND(cav->ball_array[i][j]);
+       map_element_EM_to_RND_cave(cav->ball_array[i][j]);
 
   map_android_clone_elements_EM_to_RND(level);
 
   // convert the playfield (some elements need special treatment)
   for (y = 0; y < level->fieldy; y++) for (x = 0; x < level->fieldx; x++)
   {
-    int new_element = map_element_EM_to_RND(cav->cave[x][y]);
+    int new_element = map_element_EM_to_RND_cave(cav->cave[x][y]);
 
     if (new_element == EL_AMOEBA_WET && level->amoeba_speed == 0)
       new_element = EL_AMOEBA_DEAD;
index 888e1ebf0af64304339a0e2e48c41c2fa74c83a5..5164505efa8a7e7d0dd81b163095a7fd3335756e 100644 (file)
@@ -14706,7 +14706,7 @@ static void PlayLevelMusic(void)
 
 void PlayLevelSound_EM(int xx, int yy, int element_em, int sample)
 {
-  int element = (element_em > -1 ? map_element_EM_to_RND(element_em) : 0);
+  int element = (element_em > -1 ? map_element_EM_to_RND_game(element_em) : 0);
   int offset = (BorderElement == EL_STEELWALL ? 1 : 0);
   int x = xx - 1 - offset;
   int y = yy - 1 - offset;
index 42d2eb0aa63cad7c031188a39e63261472fb95e3..ed5dc9426101925efaffd6877b8bdf66d5fd8960 100644 (file)
@@ -70,18 +70,18 @@ void setLevelInfoToDefaults_EM(void)
 
   for (i = 0; i < 8; i++)
     for (j = 0; j < 9; j++)
-      cav.eater_array[i][j] = Xblank;
+      cav.eater_array[i][j] = Cblank;
 
   for (i = 0; i < 8; i++)
     for (j = 0; j < 8; j++)
-      cav.ball_array[i][j] = Xblank;
+      cav.ball_array[i][j] = Cblank;
 
   for (i = 0; i < TILE_MAX; i++)
-    cav.android_array[i] = Xblank;
+    cav.android_array[i] = Cblank;
 
   for (x = 0; x < CAVE_WIDTH; x++)
     for (y = 0; y < CAVE_HEIGHT; y++)
-      cav.cave[x][y] = Zborder;
+      cav.cave[x][y] = Cblank;
 }
 
 
index 28984d6de1f8be6b6549a29984f776bf695518ba..59b795d81700e776885f2e1e7bd04e3ffdf470b3 100644 (file)
@@ -6,6 +6,212 @@
 #ifndef CAVE_H
 #define CAVE_H
 
+enum
+{
+  Cblank,
+  Cgrass,
+  Cdirt,
+  Cplant,
+  Cwall_1,
+  Cwall_2,
+  Cwall_3,
+  Cwall_4,
+  Croundwall_1,
+  Croundwall_2,
+  Croundwall_3,
+  Croundwall_4,
+  Csteel_1,
+  Csteel_2,
+  Csteel_3,
+  Csteel_4,
+  Candroid,
+  Ceater_n,
+  Ceater_e,
+  Ceater_s,
+  Ceater_w,
+  Calien,
+  Cbug_1_n,
+  Cbug_1_e,
+  Cbug_1_s,
+  Cbug_1_w,
+  Cbug_2_n,
+  Cbug_2_e,
+  Cbug_2_s,
+  Cbug_2_w,
+  Ctank_1_n,
+  Ctank_1_e,
+  Ctank_1_s,
+  Ctank_1_w,
+  Ctank_2_n,
+  Ctank_2_e,
+  Ctank_2_s,
+  Ctank_2_w,
+  Cemerald,
+  Cdiamond,
+  Cstone,
+  Cbomb,
+  Cnut,
+  Cspring,
+  Cpush_emerald_e,
+  Cpush_emerald_w,
+  Cpush_diamond_e,
+  Cpush_diamond_w,
+  Cpush_stone_e,
+  Cpush_stone_w,
+  Cpush_bomb_e,
+  Cpush_bomb_w,
+  Cpush_nut_e,
+  Cpush_nut_w,
+  Cpush_spring_e,
+  Cpush_spring_w,
+  Cdynamite,
+  Cdynamite_1,
+  Cdynamite_2,
+  Cdynamite_3,
+  Cdynamite_4,
+  Ckey_1,
+  Ckey_2,
+  Ckey_3,
+  Ckey_4,
+  Ckey_5,
+  Ckey_6,
+  Ckey_7,
+  Ckey_8,
+  Cdoor_1,
+  Cdoor_2,
+  Cdoor_3,
+  Cdoor_4,
+  Cdoor_5,
+  Cdoor_6,
+  Cdoor_7,
+  Cdoor_8,
+  Cfake_door_1,
+  Cfake_door_2,
+  Cfake_door_3,
+  Cfake_door_4,
+  Cfake_door_5,
+  Cfake_door_6,
+  Cfake_door_7,
+  Cfake_door_8,
+  Cballoon,
+  Cball_1,
+  Cball_2,
+  Camoeba_1,
+  Camoeba_2,
+  Camoeba_3,
+  Camoeba_4,
+  Camoeba_5,
+  Camoeba_6,
+  Camoeba_7,
+  Camoeba_8,
+  Cdrip,
+  Cwonderwall,
+  Cwheel,
+  Cswitch,
+  Cbumper,
+  Cacid_nw,
+  Cacid_ne,
+  Cacid_sw,
+  Cacid_s,
+  Cacid_se,
+  Cacid_1,
+  Cacid_2,
+  Cacid_3,
+  Cacid_4,
+  Cacid_5,
+  Cacid_6,
+  Cacid_7,
+  Cacid_8,
+  Cfake_acid_1,
+  Cfake_acid_2,
+  Cfake_acid_3,
+  Cfake_acid_4,
+  Cfake_acid_5,
+  Cfake_acid_6,
+  Cfake_acid_7,
+  Cfake_acid_8,
+  Cfake_blank,
+  Cfake_grass,
+  Cfake_amoeba,
+  Clenses,
+  Cmagnify,
+  Csand,
+  Csand_stone,
+  Cslide_ns,
+  Cslide_ew,
+  Cwind_n,
+  Cwind_e,
+  Cwind_s,
+  Cwind_w,
+  Cwind_any,
+  Cwind_stop,
+  Cexit,
+  Cexit_1,
+  Cexit_2,
+  Cexit_3,
+  Cpause,
+  Cdecor_1,
+  Cdecor_2,
+  Cdecor_3,
+  Cdecor_4,
+  Cdecor_5,
+  Cdecor_6,
+  Cdecor_7,
+  Cdecor_8,
+  Cdecor_9,
+  Cdecor_10,
+  Cdecor_11,
+  Cdecor_12,
+  Calpha_0,
+  Calpha_1,
+  Calpha_2,
+  Calpha_3,
+  Calpha_4,
+  Calpha_5,
+  Calpha_6,
+  Calpha_7,
+  Calpha_8,
+  Calpha_9,
+  Calpha_excla,
+  Calpha_apost,
+  Calpha_comma,
+  Calpha_minus,
+  Calpha_perio,
+  Calpha_colon,
+  Calpha_quest,
+  Calpha_a,
+  Calpha_b,
+  Calpha_c,
+  Calpha_d,
+  Calpha_e,
+  Calpha_f,
+  Calpha_g,
+  Calpha_h,
+  Calpha_i,
+  Calpha_j,
+  Calpha_k,
+  Calpha_l,
+  Calpha_m,
+  Calpha_n,
+  Calpha_o,
+  Calpha_p,
+  Calpha_q,
+  Calpha_r,
+  Calpha_s,
+  Calpha_t,
+  Calpha_u,
+  Calpha_v,
+  Calpha_w,
+  Calpha_x,
+  Calpha_y,
+  Calpha_z,
+  Calpha_arrow_e,
+  Calpha_arrow_w,
+  Calpha_copyr,
+
+  CAVE_TILE_MAX
+};
+
 struct CAVE
 {
   int width;                   /* cave width */
index 00768b5b96a54aa3b87797426136a8a1dcc8350f..9b4b75682c7c02f3b995750434769fef8a0b9b7b 100644 (file)
@@ -7,6 +7,254 @@
 #include "main_em.h"
 
 
+static const short map[CAVE_TILE_MAX] =
+{
+  [Cblank]             = Xblank,
+  [Cgrass]             = Xgrass,
+  [Cdirt]              = Xdirt,
+  [Cplant]             = Xplant,
+  [Cwall_1]            = Xwall_1,
+  [Cwall_2]            = Xwall_2,
+  [Cwall_3]            = Xwall_3,
+  [Cwall_4]            = Xwall_4,
+  [Croundwall_1]       = Xroundwall_1,
+  [Croundwall_2]       = Xroundwall_2,
+  [Croundwall_3]       = Xroundwall_3,
+  [Croundwall_4]       = Xroundwall_4,
+  [Csteel_1]           = Xsteel_1,
+  [Csteel_2]           = Xsteel_2,
+  [Csteel_3]           = Xsteel_3,
+  [Csteel_4]           = Xsteel_4,
+  [Candroid]           = Xandroid,
+  [Ceater_n]           = Xeater_n,
+  [Ceater_e]           = Xeater_e,
+  [Ceater_s]           = Xeater_s,
+  [Ceater_w]           = Xeater_w,
+  [Calien]             = Xalien,
+  [Cbug_1_n]           = Xbug_1_n,
+  [Cbug_1_e]           = Xbug_1_e,
+  [Cbug_1_s]           = Xbug_1_s,
+  [Cbug_1_w]           = Xbug_1_w,
+  [Cbug_2_n]           = Xbug_2_n,
+  [Cbug_2_e]           = Xbug_2_e,
+  [Cbug_2_s]           = Xbug_2_s,
+  [Cbug_2_w]           = Xbug_2_w,
+  [Ctank_1_n]          = Xtank_1_n,
+  [Ctank_1_e]          = Xtank_1_e,
+  [Ctank_1_s]          = Xtank_1_s,
+  [Ctank_1_w]          = Xtank_1_w,
+  [Ctank_2_n]          = Xtank_2_n,
+  [Ctank_2_e]          = Xtank_2_e,
+  [Ctank_2_s]          = Xtank_2_s,
+  [Ctank_2_w]          = Xtank_2_w,
+  [Cemerald]           = Xemerald,
+  [Cdiamond]           = Xdiamond,
+  [Cstone]             = Xstone,
+  [Cbomb]              = Xbomb,
+  [Cnut]               = Xnut,
+  [Cspring]            = Xspring,
+  [Cpush_emerald_e]    = Xpush_emerald_e,
+  [Cpush_emerald_w]    = Xpush_emerald_w,
+  [Cpush_diamond_e]    = Xpush_diamond_e,
+  [Cpush_diamond_w]    = Xpush_diamond_w,
+  [Cpush_stone_e]      = Xpush_stone_e,
+  [Cpush_stone_w]      = Xpush_stone_w,
+  [Cpush_bomb_e]       = Xpush_bomb_e,
+  [Cpush_bomb_w]       = Xpush_bomb_w,
+  [Cpush_nut_e]                = Xpush_nut_e,
+  [Cpush_nut_w]                = Xpush_nut_w,
+  [Cpush_spring_e]     = Xpush_spring_e,
+  [Cpush_spring_w]     = Xpush_spring_w,
+  [Cdynamite]          = Xdynamite,
+  [Cdynamite_1]                = Xdynamite_1,
+  [Cdynamite_2]                = Xdynamite_2,
+  [Cdynamite_3]                = Xdynamite_3,
+  [Cdynamite_4]                = Xdynamite_4,
+  [Ckey_1]             = Xkey_1,
+  [Ckey_2]             = Xkey_2,
+  [Ckey_3]             = Xkey_3,
+  [Ckey_4]             = Xkey_4,
+  [Ckey_5]             = Xkey_5,
+  [Ckey_6]             = Xkey_6,
+  [Ckey_7]             = Xkey_7,
+  [Ckey_8]             = Xkey_8,
+  [Cdoor_1]            = Xdoor_1,
+  [Cdoor_2]            = Xdoor_2,
+  [Cdoor_3]            = Xdoor_3,
+  [Cdoor_4]            = Xdoor_4,
+  [Cdoor_5]            = Xdoor_5,
+  [Cdoor_6]            = Xdoor_6,
+  [Cdoor_7]            = Xdoor_7,
+  [Cdoor_8]            = Xdoor_8,
+  [Cfake_door_1]       = Xfake_door_1,
+  [Cfake_door_2]       = Xfake_door_2,
+  [Cfake_door_3]       = Xfake_door_3,
+  [Cfake_door_4]       = Xfake_door_4,
+  [Cfake_door_5]       = Xfake_door_5,
+  [Cfake_door_6]       = Xfake_door_6,
+  [Cfake_door_7]       = Xfake_door_7,
+  [Cfake_door_8]       = Xfake_door_8,
+  [Cballoon]           = Xballoon,
+  [Cball_1]            = Xball_1,
+  [Cball_2]            = Xball_2,
+  [Camoeba_1]          = Xamoeba_1,
+  [Camoeba_2]          = Xamoeba_2,
+  [Camoeba_3]          = Xamoeba_3,
+  [Camoeba_4]          = Xamoeba_4,
+  [Camoeba_5]          = Xamoeba_5,
+  [Camoeba_6]          = Xamoeba_6,
+  [Camoeba_7]          = Xamoeba_7,
+  [Camoeba_8]          = Xamoeba_8,
+  [Cdrip]              = Xdrip,
+  [Cwonderwall]                = Xwonderwall,
+  [Cwheel]             = Xwheel,
+  [Cswitch]            = Xswitch,
+  [Cbumper]            = Xbumper,
+  [Cacid_nw]           = Xacid_nw,
+  [Cacid_ne]           = Xacid_ne,
+  [Cacid_sw]           = Xacid_sw,
+  [Cacid_s]            = Xacid_s,
+  [Cacid_se]           = Xacid_se,
+  [Cacid_1]            = Xacid_1,
+  [Cacid_2]            = Xacid_2,
+  [Cacid_3]            = Xacid_3,
+  [Cacid_4]            = Xacid_4,
+  [Cacid_5]            = Xacid_5,
+  [Cacid_6]            = Xacid_6,
+  [Cacid_7]            = Xacid_7,
+  [Cacid_8]            = Xacid_8,
+  [Cfake_acid_1]       = Xfake_acid_1,
+  [Cfake_acid_2]       = Xfake_acid_2,
+  [Cfake_acid_3]       = Xfake_acid_3,
+  [Cfake_acid_4]       = Xfake_acid_4,
+  [Cfake_acid_5]       = Xfake_acid_5,
+  [Cfake_acid_6]       = Xfake_acid_6,
+  [Cfake_acid_7]       = Xfake_acid_7,
+  [Cfake_acid_8]       = Xfake_acid_8,
+  [Cfake_blank]                = Xfake_blank,
+  [Cfake_grass]                = Xfake_grass,
+  [Cfake_amoeba]       = Xfake_amoeba,
+  [Clenses]            = Xlenses,
+  [Cmagnify]           = Xmagnify,
+  [Csand]              = Xsand,
+  [Csand_stone]                = Xsand_stone,
+  [Cslide_ns]          = Xslide_ns,
+  [Cslide_ew]          = Xslide_ew,
+  [Cwind_n]            = Xwind_n,
+  [Cwind_e]            = Xwind_e,
+  [Cwind_s]            = Xwind_s,
+  [Cwind_w]            = Xwind_w,
+  [Cwind_any]          = Xwind_any,
+  [Cwind_stop]         = Xwind_stop,
+  [Cexit]              = Xexit,
+  [Cexit_1]            = Xexit_1,
+  [Cexit_2]            = Xexit_2,
+  [Cexit_3]            = Xexit_3,
+  [Cpause]             = Xpause,
+  [Cdecor_1]           = Xdecor_1,
+  [Cdecor_2]           = Xdecor_2,
+  [Cdecor_3]           = Xdecor_3,
+  [Cdecor_4]           = Xdecor_4,
+  [Cdecor_5]           = Xdecor_5,
+  [Cdecor_6]           = Xdecor_6,
+  [Cdecor_7]           = Xdecor_7,
+  [Cdecor_8]           = Xdecor_8,
+  [Cdecor_9]           = Xdecor_9,
+  [Cdecor_10]          = Xdecor_10,
+  [Cdecor_11]          = Xdecor_11,
+  [Cdecor_12]          = Xdecor_12,
+  [Calpha_0]           = Xalpha_0,
+  [Calpha_1]           = Xalpha_1,
+  [Calpha_2]           = Xalpha_2,
+  [Calpha_3]           = Xalpha_3,
+  [Calpha_4]           = Xalpha_4,
+  [Calpha_5]           = Xalpha_5,
+  [Calpha_6]           = Xalpha_6,
+  [Calpha_7]           = Xalpha_7,
+  [Calpha_8]           = Xalpha_8,
+  [Calpha_9]           = Xalpha_9,
+  [Calpha_excla]       = Xalpha_excla,
+  [Calpha_apost]       = Xalpha_apost,
+  [Calpha_comma]       = Xalpha_comma,
+  [Calpha_minus]       = Xalpha_minus,
+  [Calpha_perio]       = Xalpha_perio,
+  [Calpha_colon]       = Xalpha_colon,
+  [Calpha_quest]       = Xalpha_quest,
+  [Calpha_a]           = Xalpha_a,
+  [Calpha_b]           = Xalpha_b,
+  [Calpha_c]           = Xalpha_c,
+  [Calpha_d]           = Xalpha_d,
+  [Calpha_e]           = Xalpha_e,
+  [Calpha_f]           = Xalpha_f,
+  [Calpha_g]           = Xalpha_g,
+  [Calpha_h]           = Xalpha_h,
+  [Calpha_i]           = Xalpha_i,
+  [Calpha_j]           = Xalpha_j,
+  [Calpha_k]           = Xalpha_k,
+  [Calpha_l]           = Xalpha_l,
+  [Calpha_m]           = Xalpha_m,
+  [Calpha_n]           = Xalpha_n,
+  [Calpha_o]           = Xalpha_o,
+  [Calpha_p]           = Xalpha_p,
+  [Calpha_q]           = Xalpha_q,
+  [Calpha_r]           = Xalpha_r,
+  [Calpha_s]           = Xalpha_s,
+  [Calpha_t]           = Xalpha_t,
+  [Calpha_u]           = Xalpha_u,
+  [Calpha_v]           = Xalpha_v,
+  [Calpha_w]           = Xalpha_w,
+  [Calpha_x]           = Xalpha_x,
+  [Calpha_y]           = Xalpha_y,
+  [Calpha_z]           = Xalpha_z,
+  [Calpha_arrow_e]     = Xalpha_arrow_e,
+  [Calpha_arrow_w]     = Xalpha_arrow_w,
+  [Calpha_copyr]       = Xalpha_copyr
+};
+
+int map_em_element_C_to_X(int element_em_cave)
+{
+  if (element_em_cave >= 0 && element_em_cave < CAVE_TILE_MAX)
+    return map[element_em_cave];
+
+  Error(ERR_WARN, "invalid EM cave element %d", element_em_cave);
+
+  return Xblank;
+}
+
+int map_em_element_X_to_C(int element_em_game)
+{
+  static unsigned short map_reverse[TILE_MAX];
+  static boolean map_reverse_initialized = FALSE;
+
+  if (!map_reverse_initialized)
+  {
+    int i;
+
+    // return "Cblank" for all undefined elements in mapping array
+    for (i = 0; i < TILE_MAX; i++)
+      map_reverse[i] = Cblank;
+
+    for (i = 0; i < CAVE_TILE_MAX; i++)
+      map_reverse[map[i]] = i;
+
+    map_reverse_initialized = TRUE;
+  }
+
+  if (element_em_game >= 0 && element_em_game < TILE_MAX)
+  {
+    int element_em_cave = map_reverse[element_em_game];
+
+    if (element_em_cave == Cblank && element_em_game != Xblank)
+      Error(ERR_WARN, "unknown EM game element %d", element_em_game);
+
+    return element_em_cave;
+  }
+
+  Error(ERR_WARN, "invalid EM game element %d", element_em_game);
+
+  return Cblank;
+}
+
 void prepare_em_level(void)
 {
   int i, j, x, y;
@@ -41,7 +289,7 @@ void prepare_em_level(void)
 
   for (x = 0; x < lev.width; x++)
     for (y = 0; y < lev.height; y++)
-      lev.cave[lev.left + x][lev.top + y] = cav.cave[x][y];
+      lev.cave[lev.left + x][lev.top + y] = map[cav.cave[x][y]];
 
   for (x = lev.left; x < lev.right; x++)
     for (y = lev.top; y < lev.bottom; y++)
@@ -106,14 +354,14 @@ void prepare_em_level(void)
 
   for (i = 0; i < 8; i++)
     for (j = 0; j < 9; j++)
-      lev.eater_array[i][j] = cav.eater_array[i][j];
+      lev.eater_array[i][j] = map[cav.eater_array[i][j]];
 
   for (i = 0; i < 8; i++)
     for (j = 0; j < 8; j++)
-      lev.ball_array[i][j] = cav.ball_array[i][j];
+      lev.ball_array[i][j] = map[cav.ball_array[i][j]];
 
   for (i = 0; i < TILE_MAX; i++)
-    lev.android_array[i] = cav.android_array[i];
+    lev.android_array[i] = map[cav.android_array[i]];
 
   /* determine number of players in this level */
   lev.home_initial = 0;
index a79a14866f545c3880544dd011375a087e27147f..b769d9dc10fba0cf64c3d5cc0b7fada874369aa7 100644 (file)
@@ -121,4 +121,7 @@ void SaveEngineSnapshotValues_EM(void);
 
 boolean checkIfAllPlayersFitToScreen(void);
 
+int map_em_element_C_to_X(int);
+int map_em_element_X_to_C(int);
+
 #endif // EXPORT_H
index f93e495b276d411bea86e66f7fcf5963d36d1494..58733ee79cd13814828fa740b4d1de73fe92224b 100644 (file)
 
 static const short map_emc[256] =
 {
-  Xstone,              Xstone,         Xdiamond,       Xdiamond,
-  Xalien,              Xalien,         Xblank,         Xblank,
-  Xtank_1_n,           Xtank_1_e,      Xtank_1_s,      Xtank_1_w,
-  Xtank_2_n,           Xtank_2_e,      Xtank_2_s,      Xtank_2_w,
-
-  Xbomb,               Xbomb,          Xemerald,       Xemerald,
-  Xbug_1_n,            Xbug_1_e,       Xbug_1_s,       Xbug_1_w,
-  Xbug_2_n,            Xbug_2_e,       Xbug_2_s,       Xbug_2_w,
-  Xdrip,               Xdrip,          Xdrip,          Xdrip,
-
-  Xstone,              Xbomb,          Xdiamond,       Xemerald,
-  Xwonderwall,         Xnut,           Xnut,           Xnut,
-  Xwheel,              Xeater_n,       Xeater_s,       Xeater_w,
-  Xeater_e,            Xsand_stone,    Xblank,         Xblank,
-
-  Xblank,              Xsand,          Xsand,          Xsand,
-  Xsand_stone,         Xsand_stone,    Xsand_stone,    Xsand,
-  Xstone,              Xslide_ew,      Xslide_ns,      Xdynamite_1,
-  Xdynamite_2,         Xdynamite_3,    Xdynamite_4,    Xacid_s,
-
-  Xexit_1,             Xexit_2,        Xexit_3,        Xballoon,
-  Xplant,              Xspring,        Xspring,        Xpush_spring_w,
-  Xpush_spring_e,      Xball_1,        Xball_2,        Xandroid,
-  Xblank,              Xandroid,       Xandroid,       Xandroid,
-
-  Xandroid,            Xandroid,       Xandroid,       Xandroid,
-  Xandroid,            Xblank,         Xblank,         Xblank,
-  Xblank,              Xblank,         Xblank,         Xblank,
-  Xblank,              Xblank,         Xblank,         Xblank,
-
-  Xblank,              Xblank,         Xblank,         Xpush_spring_w,
-  Xpush_spring_e,      Xacid_1,        Xacid_2,        Xacid_3,
-  Xacid_4,             Xacid_5,        Xacid_6,        Xacid_7,
-  Xacid_8,             Xblank,         Xblank,         Xblank,
-
-  Xblank,              Xblank,         Xpush_nut_w,    Xpush_nut_e,
-  Xsteel_1,            Xblank,         Xblank,         Xpush_bomb_w,
-  Xpush_bomb_e,                Xpush_stone_w,  Xpush_stone_e,  Xblank,
-  Xblank,              Xblank,         Xblank,         Xblank,
-
-  Xblank,              Xroundwall_1,   Xgrass,         Xsteel_1,
-  Xwall_1,             Xkey_1,         Xkey_2,         Xkey_3,
-  Xkey_4,              Xdoor_1,        Xdoor_2,        Xdoor_3,
-  Xdoor_4,             Xfake_amoeba,   Xfake_door_1,   Xfake_door_2,
-
-  Xfake_door_3,                Xfake_door_4,   Xwonderwall,    Xwheel,
-  Xsand,               Xacid_nw,       Xacid_ne,       Xacid_sw,
-  Xacid_se,            Xfake_blank,    Xamoeba_1,      Xamoeba_2,
-  Xamoeba_3,           Xamoeba_4,      Xexit,          Xalpha_arrow_w,
-
-  Xfake_grass,         Xlenses,        Xmagnify,       Xfake_blank,
-  Xfake_grass,         Xswitch,        Xswitch,        Xblank,
-  Xdecor_8,            Xdecor_9,       Xdecor_10,      Xdecor_5,
-  Xalpha_comma,                Xalpha_apost,   Xalpha_minus,   Xdynamite,
-
-  Xsteel_3,            Xdecor_6,       Xdecor_7,       Xsteel_2,
-  Xroundwall_2,                Xdecor_2,       Xdecor_4,       Xdecor_3,
-  Xwind_any,           Xwind_e,        Xwind_s,        Xwind_w,
-  Xwind_n,             Xdirt,          Xplant,         Xkey_5,
-
-  Xkey_6,              Xkey_7,         Xkey_8,         Xdoor_5,
-  Xdoor_6,             Xdoor_7,        Xdoor_8,        Xbumper,
-  Xalpha_a,            Xalpha_b,       Xalpha_c,       Xalpha_d,
-  Xalpha_e,            Xalpha_f,       Xalpha_g,       Xalpha_h,
-
-  Xalpha_i,            Xalpha_j,       Xalpha_k,       Xalpha_l,
-  Xalpha_m,            Xalpha_n,       Xalpha_o,       Xalpha_p,
-  Xalpha_q,            Xalpha_r,       Xalpha_s,       Xalpha_t,
-  Xalpha_u,            Xalpha_v,       Xalpha_w,       Xalpha_x,
-
-  Xalpha_y,            Xalpha_z,       Xalpha_0,       Xalpha_1,
-  Xalpha_2,            Xalpha_3,       Xalpha_4,       Xalpha_5,
-  Xalpha_6,            Xalpha_7,       Xalpha_8,       Xalpha_9,
-  Xalpha_perio,                Xalpha_excla,   Xalpha_colon,   Xalpha_quest,
-
-  Xalpha_arrow_e,      Xdecor_1,       Xfake_door_5,   Xfake_door_6,
-  Xfake_door_7,                Xfake_door_8,   Xblank,         Xblank,
-  Xblank,              Xblank,         Xblank,         Xblank,
-  Xblank,              Xblank,         Xalpha_copyr,   Xfake_acid_1
+  Cstone,              Cstone,         Cdiamond,       Cdiamond,
+  Calien,              Calien,         Cblank,         Cblank,
+  Ctank_1_n,           Ctank_1_e,      Ctank_1_s,      Ctank_1_w,
+  Ctank_2_n,           Ctank_2_e,      Ctank_2_s,      Ctank_2_w,
+
+  Cbomb,               Cbomb,          Cemerald,       Cemerald,
+  Cbug_1_n,            Cbug_1_e,       Cbug_1_s,       Cbug_1_w,
+  Cbug_2_n,            Cbug_2_e,       Cbug_2_s,       Cbug_2_w,
+  Cdrip,               Cdrip,          Cdrip,          Cdrip,
+
+  Cstone,              Cbomb,          Cdiamond,       Cemerald,
+  Cwonderwall,         Cnut,           Cnut,           Cnut,
+  Cwheel,              Ceater_n,       Ceater_s,       Ceater_w,
+  Ceater_e,            Csand_stone,    Cblank,         Cblank,
+
+  Cblank,              Csand,          Csand,          Csand,
+  Csand_stone,         Csand_stone,    Csand_stone,    Csand,
+  Cstone,              Cslide_ew,      Cslide_ns,      Cdynamite_1,
+  Cdynamite_2,         Cdynamite_3,    Cdynamite_4,    Cacid_s,
+
+  Cexit_1,             Cexit_2,        Cexit_3,        Cballoon,
+  Cplant,              Cspring,        Cspring,        Cpush_spring_w,
+  Cpush_spring_e,      Cball_1,        Cball_2,        Candroid,
+  Cblank,              Candroid,       Candroid,       Candroid,
+
+  Candroid,            Candroid,       Candroid,       Candroid,
+  Candroid,            Cblank,         Cblank,         Cblank,
+  Cblank,              Cblank,         Cblank,         Cblank,
+  Cblank,              Cblank,         Cblank,         Cblank,
+
+  Cblank,              Cblank,         Cblank,         Cpush_spring_w,
+  Cpush_spring_e,      Cacid_1,        Cacid_2,        Cacid_3,
+  Cacid_4,             Cacid_5,        Cacid_6,        Cacid_7,
+  Cacid_8,             Cblank,         Cblank,         Cblank,
+
+  Cblank,              Cblank,         Cpush_nut_w,    Cpush_nut_e,
+  Csteel_1,            Cblank,         Cblank,         Cpush_bomb_w,
+  Cpush_bomb_e,                Cpush_stone_w,  Cpush_stone_e,  Cblank,
+  Cblank,              Cblank,         Cblank,         Cblank,
+
+  Cblank,              Croundwall_1,   Cgrass,         Csteel_1,
+  Cwall_1,             Ckey_1,         Ckey_2,         Ckey_3,
+  Ckey_4,              Cdoor_1,        Cdoor_2,        Cdoor_3,
+  Cdoor_4,             Cfake_amoeba,   Cfake_door_1,   Cfake_door_2,
+
+  Cfake_door_3,                Cfake_door_4,   Cwonderwall,    Cwheel,
+  Csand,               Cacid_nw,       Cacid_ne,       Cacid_sw,
+  Cacid_se,            Cfake_blank,    Camoeba_1,      Camoeba_2,
+  Camoeba_3,           Camoeba_4,      Cexit,          Calpha_arrow_w,
+
+  Cfake_grass,         Clenses,        Cmagnify,       Cfake_blank,
+  Cfake_grass,         Cswitch,        Cswitch,        Cblank,
+  Cdecor_8,            Cdecor_9,       Cdecor_10,      Cdecor_5,
+  Calpha_comma,                Calpha_apost,   Calpha_minus,   Cdynamite,
+
+  Csteel_3,            Cdecor_6,       Cdecor_7,       Csteel_2,
+  Croundwall_2,                Cdecor_2,       Cdecor_4,       Cdecor_3,
+  Cwind_any,           Cwind_e,        Cwind_s,        Cwind_w,
+  Cwind_n,             Cdirt,          Cplant,         Ckey_5,
+
+  Ckey_6,              Ckey_7,         Ckey_8,         Cdoor_5,
+  Cdoor_6,             Cdoor_7,        Cdoor_8,        Cbumper,
+  Calpha_a,            Calpha_b,       Calpha_c,       Calpha_d,
+  Calpha_e,            Calpha_f,       Calpha_g,       Calpha_h,
+
+  Calpha_i,            Calpha_j,       Calpha_k,       Calpha_l,
+  Calpha_m,            Calpha_n,       Calpha_o,       Calpha_p,
+  Calpha_q,            Calpha_r,       Calpha_s,       Calpha_t,
+  Calpha_u,            Calpha_v,       Calpha_w,       Calpha_x,
+
+  Calpha_y,            Calpha_z,       Calpha_0,       Calpha_1,
+  Calpha_2,            Calpha_3,       Calpha_4,       Calpha_5,
+  Calpha_6,            Calpha_7,       Calpha_8,       Calpha_9,
+  Calpha_perio,                Calpha_excla,   Calpha_colon,   Calpha_quest,
+
+  Calpha_arrow_e,      Cdecor_1,       Cfake_door_5,   Cfake_door_6,
+  Cfake_door_7,                Cfake_door_8,   Cblank,         Cblank,
+  Cblank,              Cblank,         Cblank,         Cblank,
+  Cblank,              Cblank,         Calpha_copyr,   Cfake_acid_1
 };
 
 static void init_android_clone_table(short android_clone_bits)
@@ -143,177 +143,177 @@ static void init_android_clone_table(short android_clone_bits)
   int i;
 
   for (i = 0; i < TILE_MAX; i++)
-    cav.android_array[i] = Xblank;
+    cav.android_array[i] = Cblank;
 
   if (android_eater)
   {
-    cav.android_array[Xeater_n]                = Xeater_n;
-    cav.android_array[Yeater_nB]       = Xeater_n;
+    cav.android_array[Xeater_n]                = Ceater_n;
+    cav.android_array[Yeater_nB]       = Ceater_n;
 
-    cav.android_array[Xeater_e]                = Xeater_e;
-    cav.android_array[Yeater_eB]       = Xeater_e;
+    cav.android_array[Xeater_e]                = Ceater_e;
+    cav.android_array[Yeater_eB]       = Ceater_e;
 
-    cav.android_array[Xeater_s]                = Xeater_s;
-    cav.android_array[Yeater_sB]       = Xeater_s;
+    cav.android_array[Xeater_s]                = Ceater_s;
+    cav.android_array[Yeater_sB]       = Ceater_s;
 
-    cav.android_array[Xeater_w]                = Xeater_w;
-    cav.android_array[Yeater_wB]       = Xeater_w;
+    cav.android_array[Xeater_w]                = Ceater_w;
+    cav.android_array[Yeater_wB]       = Ceater_w;
   }
 
   if (android_alien)
   {
-    cav.android_array[Xalien]          = Xalien;
-    cav.android_array[Xalien_pause]    = Xalien;
-    cav.android_array[Yalien_nB]       = Xalien;
-    cav.android_array[Yalien_eB]       = Xalien;
-    cav.android_array[Yalien_sB]       = Xalien;
-    cav.android_array[Yalien_wB]       = Xalien;
+    cav.android_array[Xalien]          = Calien;
+    cav.android_array[Xalien_pause]    = Calien;
+    cav.android_array[Yalien_nB]       = Calien;
+    cav.android_array[Yalien_eB]       = Calien;
+    cav.android_array[Yalien_sB]       = Calien;
+    cav.android_array[Yalien_wB]       = Calien;
   }
 
   if (android_bug)
   {
-    cav.android_array[Xbug_1_n]                = Xbug_2_n;
-    cav.android_array[Xbug_2_n]                = Xbug_2_n;
-    cav.android_array[Ybug_nB]         = Xbug_2_n;
-    cav.android_array[Ybug_n_e]                = Xbug_2_n;
-    cav.android_array[Ybug_n_w]                = Xbug_2_n;
-
-    cav.android_array[Xbug_1_e]                = Xbug_2_e;
-    cav.android_array[Xbug_2_e]                = Xbug_2_e;
-    cav.android_array[Ybug_eB]         = Xbug_2_e;
-    cav.android_array[Ybug_e_s]                = Xbug_2_e;
-    cav.android_array[Ybug_e_n]                = Xbug_2_e;
-
-    cav.android_array[Xbug_1_s]                = Xbug_2_s;
-    cav.android_array[Xbug_2_s]                = Xbug_2_s;
-    cav.android_array[Ybug_sB]         = Xbug_2_s;
-    cav.android_array[Ybug_s_w]                = Xbug_2_s;
-    cav.android_array[Ybug_s_e]                = Xbug_2_s;
-
-    cav.android_array[Xbug_1_w]                = Xbug_2_w;
-    cav.android_array[Xbug_2_w]                = Xbug_2_w;
-    cav.android_array[Ybug_wB]         = Xbug_2_w;
-    cav.android_array[Ybug_w_n]                = Xbug_2_w;
-    cav.android_array[Ybug_w_s]                = Xbug_2_w;
+    cav.android_array[Xbug_1_n]                = Cbug_2_n;
+    cav.android_array[Xbug_2_n]                = Cbug_2_n;
+    cav.android_array[Ybug_nB]         = Cbug_2_n;
+    cav.android_array[Ybug_n_e]                = Cbug_2_n;
+    cav.android_array[Ybug_n_w]                = Cbug_2_n;
+
+    cav.android_array[Xbug_1_e]                = Cbug_2_e;
+    cav.android_array[Xbug_2_e]                = Cbug_2_e;
+    cav.android_array[Ybug_eB]         = Cbug_2_e;
+    cav.android_array[Ybug_e_s]                = Cbug_2_e;
+    cav.android_array[Ybug_e_n]                = Cbug_2_e;
+
+    cav.android_array[Xbug_1_s]                = Cbug_2_s;
+    cav.android_array[Xbug_2_s]                = Cbug_2_s;
+    cav.android_array[Ybug_sB]         = Cbug_2_s;
+    cav.android_array[Ybug_s_w]                = Cbug_2_s;
+    cav.android_array[Ybug_s_e]                = Cbug_2_s;
+
+    cav.android_array[Xbug_1_w]                = Cbug_2_w;
+    cav.android_array[Xbug_2_w]                = Cbug_2_w;
+    cav.android_array[Ybug_wB]         = Cbug_2_w;
+    cav.android_array[Ybug_w_n]                = Cbug_2_w;
+    cav.android_array[Ybug_w_s]                = Cbug_2_w;
   }
 
   if (android_tank)
   {
-    cav.android_array[Xtank_1_n]       = Xtank_1_n;
-    cav.android_array[Xtank_2_n]       = Xtank_1_n;
-    cav.android_array[Ytank_nB]                = Xtank_1_n;
-    cav.android_array[Ytank_n_e]       = Xtank_1_n;
-    cav.android_array[Ytank_n_w]       = Xtank_1_n;
-
-    cav.android_array[Xtank_1_e]       = Xtank_1_e;
-    cav.android_array[Xtank_2_e]       = Xtank_1_e;
-    cav.android_array[Ytank_eB]                = Xtank_1_e;
-    cav.android_array[Ytank_e_s]       = Xtank_1_e;
-    cav.android_array[Ytank_e_n]       = Xtank_1_e;
-
-    cav.android_array[Xtank_1_s]       = Xtank_1_s;
-    cav.android_array[Xtank_2_s]       = Xtank_1_s;
-    cav.android_array[Ytank_sB]                = Xtank_1_s;
-    cav.android_array[Ytank_s_w]       = Xtank_1_s;
-    cav.android_array[Ytank_s_e]       = Xtank_1_s;
-
-    cav.android_array[Xtank_1_w]       = Xtank_1_w;
-    cav.android_array[Xtank_2_w]       = Xtank_1_w;
-    cav.android_array[Ytank_wB]                = Xtank_1_w;
-    cav.android_array[Ytank_w_n]       = Xtank_1_w;
-    cav.android_array[Ytank_w_s]       = Xtank_1_w;
+    cav.android_array[Xtank_1_n]       = Ctank_1_n;
+    cav.android_array[Xtank_2_n]       = Ctank_1_n;
+    cav.android_array[Ytank_nB]                = Ctank_1_n;
+    cav.android_array[Ytank_n_e]       = Ctank_1_n;
+    cav.android_array[Ytank_n_w]       = Ctank_1_n;
+
+    cav.android_array[Xtank_1_e]       = Ctank_1_e;
+    cav.android_array[Xtank_2_e]       = Ctank_1_e;
+    cav.android_array[Ytank_eB]                = Ctank_1_e;
+    cav.android_array[Ytank_e_s]       = Ctank_1_e;
+    cav.android_array[Ytank_e_n]       = Ctank_1_e;
+
+    cav.android_array[Xtank_1_s]       = Ctank_1_s;
+    cav.android_array[Xtank_2_s]       = Ctank_1_s;
+    cav.android_array[Ytank_sB]                = Ctank_1_s;
+    cav.android_array[Ytank_s_w]       = Ctank_1_s;
+    cav.android_array[Ytank_s_e]       = Ctank_1_s;
+
+    cav.android_array[Xtank_1_w]       = Ctank_1_w;
+    cav.android_array[Xtank_2_w]       = Ctank_1_w;
+    cav.android_array[Ytank_wB]                = Ctank_1_w;
+    cav.android_array[Ytank_w_n]       = Ctank_1_w;
+    cav.android_array[Ytank_w_s]       = Ctank_1_w;
   }
 
   if (android_emerald)
   {
-    cav.android_array[Xemerald]                = Xemerald;
-    cav.android_array[Xemerald_pause]  = Xemerald;
-    cav.android_array[Xemerald_fall]   = Xemerald;
-    cav.android_array[Yemerald_sB]     = Xemerald;
-    cav.android_array[Yemerald_eB]     = Xemerald;
-    cav.android_array[Yemerald_wB]     = Xemerald;
+    cav.android_array[Xemerald]                = Cemerald;
+    cav.android_array[Xemerald_pause]  = Cemerald;
+    cav.android_array[Xemerald_fall]   = Cemerald;
+    cav.android_array[Yemerald_sB]     = Cemerald;
+    cav.android_array[Yemerald_eB]     = Cemerald;
+    cav.android_array[Yemerald_wB]     = Cemerald;
   }
 
   if (android_diamond)
   {
-    cav.android_array[Xdiamond]                = Xdiamond;
-    cav.android_array[Xdiamond_pause]  = Xdiamond;
-    cav.android_array[Xdiamond_fall]   = Xdiamond;
-    cav.android_array[Ydiamond_sB]     = Xdiamond;
-    cav.android_array[Ydiamond_eB]     = Xdiamond;
-    cav.android_array[Ydiamond_wB]     = Xdiamond;
+    cav.android_array[Xdiamond]                = Cdiamond;
+    cav.android_array[Xdiamond_pause]  = Cdiamond;
+    cav.android_array[Xdiamond_fall]   = Cdiamond;
+    cav.android_array[Ydiamond_sB]     = Cdiamond;
+    cav.android_array[Ydiamond_eB]     = Cdiamond;
+    cav.android_array[Ydiamond_wB]     = Cdiamond;
   }
 
   if (android_stone)
   {
-    cav.android_array[Xstone]          = Xstone;
-    cav.android_array[Xstone_pause]    = Xstone;
-    cav.android_array[Xstone_fall]     = Xstone;
-    cav.android_array[Ystone_sB]       = Xstone;
-    cav.android_array[Ystone_eB]       = Xstone;
-    cav.android_array[Ystone_wB]       = Xstone;
+    cav.android_array[Xstone]          = Cstone;
+    cav.android_array[Xstone_pause]    = Cstone;
+    cav.android_array[Xstone_fall]     = Cstone;
+    cav.android_array[Ystone_sB]       = Cstone;
+    cav.android_array[Ystone_eB]       = Cstone;
+    cav.android_array[Ystone_wB]       = Cstone;
   }
 
   if (android_bomb)
   {
-    cav.android_array[Xbomb]           = Xbomb;
-    cav.android_array[Xbomb_pause]     = Xbomb;
-    cav.android_array[Xbomb_fall]      = Xbomb;
-    cav.android_array[Ybomb_sB]                = Xbomb;
-    cav.android_array[Ybomb_eB]                = Xbomb;
-    cav.android_array[Ybomb_wB]                = Xbomb;
+    cav.android_array[Xbomb]           = Cbomb;
+    cav.android_array[Xbomb_pause]     = Cbomb;
+    cav.android_array[Xbomb_fall]      = Cbomb;
+    cav.android_array[Ybomb_sB]                = Cbomb;
+    cav.android_array[Ybomb_eB]                = Cbomb;
+    cav.android_array[Ybomb_wB]                = Cbomb;
   }
 
   if (android_nut)
   {
-    cav.android_array[Xnut]            = Xnut;
-    cav.android_array[Xnut_pause]      = Xnut;
-    cav.android_array[Xnut_fall]       = Xnut;
-    cav.android_array[Ynut_sB]         = Xnut;
-    cav.android_array[Ynut_eB]         = Xnut;
-    cav.android_array[Ynut_wB]         = Xnut;
+    cav.android_array[Xnut]            = Cnut;
+    cav.android_array[Xnut_pause]      = Cnut;
+    cav.android_array[Xnut_fall]       = Cnut;
+    cav.android_array[Ynut_sB]         = Cnut;
+    cav.android_array[Ynut_eB]         = Cnut;
+    cav.android_array[Ynut_wB]         = Cnut;
   }
 
   if (android_spring)
   {
-    cav.android_array[Xspring]         = Xspring;
-    cav.android_array[Xspring_pause]   = Xspring;
-    cav.android_array[Xspring_fall]    = Xspring;
-    cav.android_array[Xspring_e]       = Xspring;
-    cav.android_array[Xspring_w]       = Xspring;
-    cav.android_array[Yspring_sB]      = Xspring;
-    cav.android_array[Yspring_eB]      = Xspring;
-    cav.android_array[Yspring_wB]      = Xspring;
-    cav.android_array[Yspring_alien_eB]        = Xspring;
-    cav.android_array[Yspring_alien_wB]        = Xspring;
+    cav.android_array[Xspring]         = Cspring;
+    cav.android_array[Xspring_pause]   = Cspring;
+    cav.android_array[Xspring_fall]    = Cspring;
+    cav.android_array[Xspring_e]       = Cspring;
+    cav.android_array[Xspring_w]       = Cspring;
+    cav.android_array[Yspring_sB]      = Cspring;
+    cav.android_array[Yspring_eB]      = Cspring;
+    cav.android_array[Yspring_wB]      = Cspring;
+    cav.android_array[Yspring_alien_eB]        = Cspring;
+    cav.android_array[Yspring_alien_wB]        = Cspring;
   }
 
   if (android_dynamite)
   {
-    cav.android_array[Xdynamite]       = Xdynamite;
+    cav.android_array[Xdynamite]       = Cdynamite;
   }
 
   if (android_balloon)
   {
-    cav.android_array[Xballoon]                = Xballoon;
-    cav.android_array[Yballoon_nB]     = Xballoon;
-    cav.android_array[Yballoon_eB]     = Xballoon;
-    cav.android_array[Yballoon_sB]     = Xballoon;
-    cav.android_array[Yballoon_wB]     = Xballoon;
+    cav.android_array[Xballoon]                = Cballoon;
+    cav.android_array[Yballoon_nB]     = Cballoon;
+    cav.android_array[Yballoon_eB]     = Cballoon;
+    cav.android_array[Yballoon_sB]     = Cballoon;
+    cav.android_array[Yballoon_wB]     = Cballoon;
   }
 
   if (android_amoeba)
   {
-    cav.android_array[Xfake_amoeba]    = Xdrip;
-    cav.android_array[Yfake_amoeba]    = Xdrip;
-    cav.android_array[Xamoeba_1]       = Xdrip;
-    cav.android_array[Xamoeba_2]       = Xdrip;
-    cav.android_array[Xamoeba_3]       = Xdrip;
-    cav.android_array[Xamoeba_4]       = Xdrip;
-    cav.android_array[Xamoeba_5]       = Xdrip;
-    cav.android_array[Xamoeba_6]       = Xdrip;
-    cav.android_array[Xamoeba_7]       = Xdrip;
-    cav.android_array[Xamoeba_8]       = Xdrip;
+    cav.android_array[Xfake_amoeba]    = Cdrip;
+    cav.android_array[Yfake_amoeba]    = Cdrip;
+    cav.android_array[Xamoeba_1]       = Cdrip;
+    cav.android_array[Xamoeba_2]       = Cdrip;
+    cav.android_array[Xamoeba_3]       = Cdrip;
+    cav.android_array[Xamoeba_4]       = Cdrip;
+    cav.android_array[Xamoeba_5]       = Cdrip;
+    cav.android_array[Xamoeba_6]       = Cdrip;
+    cav.android_array[Xamoeba_7]       = Cdrip;
+    cav.android_array[Xamoeba_8]       = Cdrip;
   }
 }
 
@@ -421,14 +421,14 @@ void convert_em_level(unsigned char *src, int file_version)
     }
     else
     {
-      cav.ball_array[y][1] = (src[2163] & 1)  ? temp : Xblank; /* north */
-      cav.ball_array[y][6] = (src[2163] & 2)  ? temp : Xblank; /* south */
-      cav.ball_array[y][3] = (src[2163] & 4)  ? temp : Xblank; /* west */
-      cav.ball_array[y][4] = (src[2163] & 8)  ? temp : Xblank; /* east */
-      cav.ball_array[y][7] = (src[2163] & 16) ? temp : Xblank; /* southeast */
-      cav.ball_array[y][5] = (src[2163] & 32) ? temp : Xblank; /* southwest */
-      cav.ball_array[y][2] = (src[2163] & 64) ? temp : Xblank; /* northeast */
-      cav.ball_array[y][0] = (src[2163] & 128)? temp : Xblank; /* northwest */
+      cav.ball_array[y][1] = (src[2163] & 1)  ? temp : Cblank; /* north */
+      cav.ball_array[y][6] = (src[2163] & 2)  ? temp : Cblank; /* south */
+      cav.ball_array[y][3] = (src[2163] & 4)  ? temp : Cblank; /* west */
+      cav.ball_array[y][4] = (src[2163] & 8)  ? temp : Cblank; /* east */
+      cav.ball_array[y][7] = (src[2163] & 16) ? temp : Cblank; /* southeast */
+      cav.ball_array[y][5] = (src[2163] & 32) ? temp : Cblank; /* southwest */
+      cav.ball_array[y][2] = (src[2163] & 64) ? temp : Cblank; /* northeast */
+      cav.ball_array[y][0] = (src[2163] & 128)? temp : Cblank; /* northwest */
     }
   }
 
@@ -444,10 +444,10 @@ void convert_em_level(unsigned char *src, int file_version)
 
   /* cave */
 
-  /* first fill the complete playfield with the default border element */
+  /* first fill the complete playfield with the empty space element */
   for (y = 0; y < CAVE_HEIGHT; y++)
     for (x = 0; x < CAVE_WIDTH; x++)
-      cav.cave[x][y] = Zborder;
+      cav.cave[x][y] = Cblank;
 
   /* then copy the real level contents from level file into the playfield */
   temp = 0;
@@ -455,11 +455,6 @@ void convert_em_level(unsigned char *src, int file_version)
     for (x = 0; x < cav.width; x++)
       cav.cave[x][y] = map_emc[src[temp++]];
 
-  /* at last, set the two players at their positions in the playfield */
-  /* (native EM[C] levels always have exactly two players in a level) */
-  for (i = 0; i < 2; i++)
-    cav.cave[cav.player_x[i]][cav.player_y[i]] = Zplayer;
-
   native_em_level.file_version = file_version;
 }
 
@@ -695,7 +690,7 @@ int cleanup_em_level(unsigned char *src, int length, char *filename)
     {
       for (i = 0; i < 2048; i++)
        if (src[i] == 241)
-         src[i] = 254;         /* replace 'Xdecor_1' with 'Xalpha_copyr' */
+         src[i] = 254;         /* replace 'Cdecor_1' with 'Calpha_copyr' */
     }
   }
   else
@@ -747,8 +742,8 @@ int cleanup_em_level(unsigned char *src, int length, char *filename)
 
   /* fix acid */
   for (i = 64; i < 2048; i++)
-    if (src[i] == 63)          /* replace element above 'Xacid_s' ... */
-      src[i - 64] = 101;       /* ... with 'Xacid_1' */
+    if (src[i] == 63)          /* replace element above 'Cacid_s' ... */
+      src[i - 64] = 101;       /* ... with 'Cacid_1' */
 
   /* fix acid with no base beneath it (see below for details (*)) */
   for (i = 64; i < 2048 - 1; i++)
@@ -758,9 +753,9 @@ int cleanup_em_level(unsigned char *src, int length, char *filename)
     {
       if (src[i - 1] == 101 ||                 /* remove acid over acid row */
          src[i + 1] == 101)
-       src[i - 64] = 6;        /* replace element above with 'Xblank' */
+       src[i - 64] = 6;        /* replace element above with 'Cblank' */
       else
-       src[i - 64] = 255;      /* replace element above with 'Xfake_acid_1' */
+       src[i - 64] = 255;      /* replace element above with 'Cfake_acid_1' */
     }
   }
 
index 03ba73b79cb3ae617a4c5987a1f93d8a2015c0bd..a5638485e4b365b529d8f697d37fe8e56f6c73ae 100644 (file)
@@ -5736,7 +5736,7 @@ static struct Mapping_EM_to_RND_object
   int action;
   int direction;
 }
-em_object_mapping_list[] =
+em_object_mapping_list[TILE_MAX + 1] =
 {
   {
     Zborder,                           FALSE,  FALSE,
@@ -7492,7 +7492,7 @@ static struct Mapping_EM_to_RND_player
   int action;
   int direction;
 }
-em_player_mapping_list[] =
+em_player_mapping_list[MAX_PLAYERS * PLY_MAX + 1] =
 {
   {
     PLY_walk_n,                                0,
@@ -7709,7 +7709,7 @@ em_player_mapping_list[] =
   }
 };
 
-int map_element_RND_to_EM(int element_rnd)
+int map_element_RND_to_EM_cave(int element_rnd)
 {
   static unsigned short mapping_RND_to_EM[NUM_FILE_ELEMENTS];
   static boolean mapping_initialized = FALSE;
@@ -7731,14 +7731,14 @@ int map_element_RND_to_EM(int element_rnd)
   }
 
   if (element_rnd >= 0 && element_rnd < NUM_FILE_ELEMENTS)
-    return mapping_RND_to_EM[element_rnd];
+    return map_em_element_X_to_C(mapping_RND_to_EM[element_rnd]);
 
   Error(ERR_WARN, "invalid RND level element %d", element_rnd);
 
   return EL_UNKNOWN;
 }
 
-int map_element_EM_to_RND(int element_em)
+int map_element_EM_to_RND_cave(int element_em_cave)
 {
   static unsigned short mapping_EM_to_RND[TILE_MAX];
   static boolean mapping_initialized = FALSE;
@@ -7758,10 +7758,38 @@ int map_element_EM_to_RND(int element_em)
     mapping_initialized = TRUE;
   }
 
-  if (element_em >= 0 && element_em < TILE_MAX)
-    return mapping_EM_to_RND[element_em];
+  if (element_em_cave >= 0 && element_em_cave < CAVE_TILE_MAX)
+    return mapping_EM_to_RND[map_em_element_C_to_X(element_em_cave)];
 
-  Error(ERR_WARN, "invalid EM level element %d", element_em);
+  Error(ERR_WARN, "invalid EM cave element %d", element_em_cave);
+
+  return EL_UNKNOWN;
+}
+
+int map_element_EM_to_RND_game(int element_em_game)
+{
+  static unsigned short mapping_EM_to_RND[TILE_MAX];
+  static boolean mapping_initialized = FALSE;
+
+  if (!mapping_initialized)
+  {
+    int i;
+
+    // return "EL_UNKNOWN" for all undefined elements in mapping array
+    for (i = 0; i < TILE_MAX; i++)
+      mapping_EM_to_RND[i] = EL_UNKNOWN;
+
+    for (i = 0; em_object_mapping_list[i].element_em != -1; i++)
+      mapping_EM_to_RND[em_object_mapping_list[i].element_em] =
+       em_object_mapping_list[i].element_rnd;
+
+    mapping_initialized = TRUE;
+  }
+
+  if (element_em_game >= 0 && element_em_game < TILE_MAX)
+    return mapping_EM_to_RND[element_em_game];
+
+  Error(ERR_WARN, "invalid EM game element %d", element_em_game);
 
   return EL_UNKNOWN;
 }
@@ -7773,16 +7801,17 @@ void map_android_clone_elements_RND_to_EM(struct LevelInfo *level)
   int i, j;
 
   for (i = 0; i < TILE_MAX; i++)
-    cav->android_array[i] = Xblank;
+    cav->android_array[i] = Cblank;
 
   for (i = 0; i < level->num_android_clone_elements; i++)
   {
     int element_rnd = level->android_clone_element[i];
-    int element_em = map_element_RND_to_EM(element_rnd);
+    int element_em_cave = map_element_RND_to_EM_cave(element_rnd);
 
     for (j = 0; em_object_mapping_list[j].element_em != -1; j++)
       if (em_object_mapping_list[j].element_rnd == element_rnd)
-       cav->android_array[em_object_mapping_list[j].element_em] = element_em;
+       cav->android_array[em_object_mapping_list[j].element_em] =
+         element_em_cave;
   }
 }
 
@@ -7796,14 +7825,14 @@ void map_android_clone_elements_EM_to_RND(struct LevelInfo *level)
 
   for (i = 0; i < TILE_MAX; i++)
   {
-    int element_em = cav->android_array[i];
+    int element_em_cave = cav->android_array[i];
     int element_rnd;
     boolean element_found = FALSE;
 
-    if (element_em == Xblank)
+    if (element_em_cave == Cblank)
       continue;
 
-    element_rnd = map_element_EM_to_RND(element_em);
+    element_rnd = map_element_EM_to_RND_cave(element_em_cave);
 
     for (j = 0; j < level->num_android_clone_elements; j++)
       if (level->android_clone_element[j] == element_rnd)
index 84bd6a38eeed9f47327c5e3da1afd75225a86c78..937e27d38bd08e96a829d29a35fef17e7a38f83e 100644 (file)
@@ -221,8 +221,9 @@ void UndrawSpecialEditorDoor(void);
 void CreateToolButtons(void);
 void FreeToolButtons(void);
 
-int map_element_RND_to_EM(int);
-int map_element_EM_to_RND(int);
+int map_element_RND_to_EM_cave(int);
+int map_element_EM_to_RND_cave(int);
+int map_element_EM_to_RND_game(int);
 int map_direction_RND_to_EM(int);
 int map_direction_EM_to_RND(int);