moved setting android clone data back to previous function
authorHolger Schemel <info@artsoft.org>
Wed, 12 Feb 2020 22:17:55 +0000 (23:17 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 19 May 2020 16:19:18 +0000 (18:19 +0200)
This commit effectively revokes commit ccae7930.

(The old behaviour is needed when splitting the EM level structure
into static level data and runtime game data, because levels converted
from R'n'D to EM allow for more android clone elements than the
original EM engine would handle, so the android clone data array must
be part of the upcoming level data structure.)

src/game_em/convert.c
src/game_em/emerald.h
src/game_em/reademc.c

index 12deb93096808ffbb2dff4d8c63d8844c3676aac..4ce1611104a57311201cfde05918c1e517ec4ee0 100644 (file)
@@ -75,177 +75,6 @@ void prepare_em_level(void)
 
   lev.killed_out_of_time = FALSE;
 
-  if (lev.android_eater)
-  {
-    lev.android_array[Xeater_n]                = Xeater_n;
-    lev.android_array[Yeater_nB]       = Xeater_n;
-
-    lev.android_array[Xeater_e]                = Xeater_e;
-    lev.android_array[Yeater_eB]       = Xeater_e;
-
-    lev.android_array[Xeater_s]                = Xeater_s;
-    lev.android_array[Yeater_sB]       = Xeater_s;
-
-    lev.android_array[Xeater_w]                = Xeater_w;
-    lev.android_array[Yeater_wB]       = Xeater_w;
-  }
-
-  if (lev.android_alien)
-  {
-    lev.android_array[Xalien]          = Xalien;
-    lev.android_array[Xalien_pause]    = Xalien;
-    lev.android_array[Yalien_nB]       = Xalien;
-    lev.android_array[Yalien_eB]       = Xalien;
-    lev.android_array[Yalien_sB]       = Xalien;
-    lev.android_array[Yalien_wB]       = Xalien;
-  }
-
-  if (lev.android_bug)
-  {
-    lev.android_array[Xbug_1_n]                = Xbug_2_n;
-    lev.android_array[Xbug_2_n]                = Xbug_2_n;
-    lev.android_array[Ybug_nB]         = Xbug_2_n;
-    lev.android_array[Ybug_n_e]                = Xbug_2_n;
-    lev.android_array[Ybug_n_w]                = Xbug_2_n;
-
-    lev.android_array[Xbug_1_e]                = Xbug_2_e;
-    lev.android_array[Xbug_2_e]                = Xbug_2_e;
-    lev.android_array[Ybug_eB]         = Xbug_2_e;
-    lev.android_array[Ybug_e_s]                = Xbug_2_e;
-    lev.android_array[Ybug_e_n]                = Xbug_2_e;
-
-    lev.android_array[Xbug_1_s]                = Xbug_2_s;
-    lev.android_array[Xbug_2_s]                = Xbug_2_s;
-    lev.android_array[Ybug_sB]         = Xbug_2_s;
-    lev.android_array[Ybug_s_w]                = Xbug_2_s;
-    lev.android_array[Ybug_s_e]                = Xbug_2_s;
-
-    lev.android_array[Xbug_1_w]                = Xbug_2_w;
-    lev.android_array[Xbug_2_w]                = Xbug_2_w;
-    lev.android_array[Ybug_wB]         = Xbug_2_w;
-    lev.android_array[Ybug_w_n]                = Xbug_2_w;
-    lev.android_array[Ybug_w_s]                = Xbug_2_w;
-  }
-
-  if (lev.android_tank)
-  {
-    lev.android_array[Xtank_1_n]       = Xtank_1_n;
-    lev.android_array[Xtank_2_n]       = Xtank_1_n;
-    lev.android_array[Ytank_nB]                = Xtank_1_n;
-    lev.android_array[Ytank_n_e]       = Xtank_1_n;
-    lev.android_array[Ytank_n_w]       = Xtank_1_n;
-
-    lev.android_array[Xtank_1_e]       = Xtank_1_e;
-    lev.android_array[Xtank_2_e]       = Xtank_1_e;
-    lev.android_array[Ytank_eB]                = Xtank_1_e;
-    lev.android_array[Ytank_e_s]       = Xtank_1_e;
-    lev.android_array[Ytank_e_n]       = Xtank_1_e;
-
-    lev.android_array[Xtank_1_s]       = Xtank_1_s;
-    lev.android_array[Xtank_2_s]       = Xtank_1_s;
-    lev.android_array[Ytank_sB]                = Xtank_1_s;
-    lev.android_array[Ytank_s_w]       = Xtank_1_s;
-    lev.android_array[Ytank_s_e]       = Xtank_1_s;
-
-    lev.android_array[Xtank_1_w]       = Xtank_1_w;
-    lev.android_array[Xtank_2_w]       = Xtank_1_w;
-    lev.android_array[Ytank_wB]                = Xtank_1_w;
-    lev.android_array[Ytank_w_n]       = Xtank_1_w;
-    lev.android_array[Ytank_w_s]       = Xtank_1_w;
-  }
-
-  if (lev.android_emerald)
-  {
-    lev.android_array[Xemerald]                = Xemerald;
-    lev.android_array[Xemerald_pause]  = Xemerald;
-    lev.android_array[Xemerald_fall]   = Xemerald;
-    lev.android_array[Yemerald_sB]     = Xemerald;
-    lev.android_array[Yemerald_eB]     = Xemerald;
-    lev.android_array[Yemerald_wB]     = Xemerald;
-  }
-
-  if (lev.android_diamond)
-  {
-    lev.android_array[Xdiamond]                = Xdiamond;
-    lev.android_array[Xdiamond_pause]  = Xdiamond;
-    lev.android_array[Xdiamond_fall]   = Xdiamond;
-    lev.android_array[Ydiamond_sB]     = Xdiamond;
-    lev.android_array[Ydiamond_eB]     = Xdiamond;
-    lev.android_array[Ydiamond_wB]     = Xdiamond;
-  }
-
-  if (lev.android_stone)
-  {
-    lev.android_array[Xstone]          = Xstone;
-    lev.android_array[Xstone_pause]    = Xstone;
-    lev.android_array[Xstone_fall]     = Xstone;
-    lev.android_array[Ystone_sB]       = Xstone;
-    lev.android_array[Ystone_eB]       = Xstone;
-    lev.android_array[Ystone_wB]       = Xstone;
-  }
-
-  if (lev.android_bomb)
-  {
-    lev.android_array[Xbomb]           = Xbomb;
-    lev.android_array[Xbomb_pause]     = Xbomb;
-    lev.android_array[Xbomb_fall]      = Xbomb;
-    lev.android_array[Ybomb_sB]                = Xbomb;
-    lev.android_array[Ybomb_eB]                = Xbomb;
-    lev.android_array[Ybomb_wB]                = Xbomb;
-  }
-
-  if (lev.android_nut)
-  {
-    lev.android_array[Xnut]            = Xnut;
-    lev.android_array[Xnut_pause]      = Xnut;
-    lev.android_array[Xnut_fall]       = Xnut;
-    lev.android_array[Ynut_sB]         = Xnut;
-    lev.android_array[Ynut_eB]         = Xnut;
-    lev.android_array[Ynut_wB]         = Xnut;
-  }
-
-  if (lev.android_spring)
-  {
-    lev.android_array[Xspring]         = Xspring;
-    lev.android_array[Xspring_pause]   = Xspring;
-    lev.android_array[Xspring_fall]    = Xspring;
-    lev.android_array[Xspring_e]       = Xspring;
-    lev.android_array[Xspring_w]       = Xspring;
-    lev.android_array[Yspring_sB]      = Xspring;
-    lev.android_array[Yspring_eB]      = Xspring;
-    lev.android_array[Yspring_wB]      = Xspring;
-    lev.android_array[Yspring_alien_eB]        = Xspring;
-    lev.android_array[Yspring_alien_wB]        = Xspring;
-  }
-
-  if (lev.android_dynamite)
-  {
-    lev.android_array[Xdynamite]       = Xdynamite;
-  }
-
-  if (lev.android_balloon)
-  {
-    lev.android_array[Xballoon]                = Xballoon;
-    lev.android_array[Yballoon_nB]     = Xballoon;
-    lev.android_array[Yballoon_eB]     = Xballoon;
-    lev.android_array[Yballoon_sB]     = Xballoon;
-    lev.android_array[Yballoon_wB]     = Xballoon;
-  }
-
-  if (lev.android_amoeba)
-  {
-    lev.android_array[Xfake_amoeba]    = Xdrip;
-    lev.android_array[Yfake_amoeba]    = Xdrip;
-    lev.android_array[Xamoeba_1]       = Xdrip;
-    lev.android_array[Xamoeba_2]       = Xdrip;
-    lev.android_array[Xamoeba_3]       = Xdrip;
-    lev.android_array[Xamoeba_4]       = Xdrip;
-    lev.android_array[Xamoeba_5]       = Xdrip;
-    lev.android_array[Xamoeba_6]       = Xdrip;
-    lev.android_array[Xamoeba_7]       = Xdrip;
-    lev.android_array[Xamoeba_8]       = Xdrip;
-  }
-
   /* determine number of players in this level */
   lev.home_initial = 0;
 
index 509f2f6939b4705f46b4cefc5760a264383095c0..37b75c66e4be259c95280bcb399c2eb87f05b814 100644 (file)
@@ -702,20 +702,6 @@ struct LEVEL
 
   int exit_x, exit_y;          /* kludge for playing player exit sound */
 
-  boolean android_eater;       /* android clone data */
-  boolean android_alien;
-  boolean android_bug;
-  boolean android_tank;
-  boolean android_emerald;
-  boolean android_diamond;
-  boolean android_stone;
-  boolean android_bomb;
-  boolean android_nut;
-  boolean android_spring;
-  boolean android_dynamite;
-  boolean android_balloon;
-  boolean android_amoeba;
-
   short cavebuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
   short nextbuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
   short drawbuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
index c1af429dfe7687e17182482908c40cb04e499381..0c9e663e9ecc448676b24da36fa193f97af72ccd 100644 (file)
@@ -126,6 +126,198 @@ static const short map_emc[256] =
   Xblank,              Xblank,         Xalpha_copyr,   Xfake_acid_1
 };
 
+static void init_android_clone_table(short android_clone_bits)
+{
+  boolean android_emerald      = (android_clone_bits & 1)      != 0;
+  boolean android_diamond      = (android_clone_bits & 2)      != 0;
+  boolean android_stone                = (android_clone_bits & 4)      != 0;
+  boolean android_bomb         = (android_clone_bits & 8)      != 0;
+  boolean android_nut          = (android_clone_bits & 16)     != 0;
+  boolean android_tank         = (android_clone_bits & 32)     != 0;
+  boolean android_eater                = (android_clone_bits & 64)     != 0;
+  boolean android_bug          = (android_clone_bits & 128)    != 0;
+  boolean android_alien                = (android_clone_bits & 256)    != 0;
+  boolean android_spring       = (android_clone_bits & 512)    != 0;
+  boolean android_balloon      = (android_clone_bits & 1024)   != 0;
+  boolean android_amoeba       = (android_clone_bits & 2048)   != 0;
+  boolean android_dynamite     = (android_clone_bits & 4096)   != 0;
+  int i;
+
+  for (i = 0; i < TILE_MAX; i++)
+    lev.android_array[i] = Xblank;
+
+  if (android_eater)
+  {
+    lev.android_array[Xeater_n]                = Xeater_n;
+    lev.android_array[Yeater_nB]       = Xeater_n;
+
+    lev.android_array[Xeater_e]                = Xeater_e;
+    lev.android_array[Yeater_eB]       = Xeater_e;
+
+    lev.android_array[Xeater_s]                = Xeater_s;
+    lev.android_array[Yeater_sB]       = Xeater_s;
+
+    lev.android_array[Xeater_w]                = Xeater_w;
+    lev.android_array[Yeater_wB]       = Xeater_w;
+  }
+
+  if (android_alien)
+  {
+    lev.android_array[Xalien]          = Xalien;
+    lev.android_array[Xalien_pause]    = Xalien;
+    lev.android_array[Yalien_nB]       = Xalien;
+    lev.android_array[Yalien_eB]       = Xalien;
+    lev.android_array[Yalien_sB]       = Xalien;
+    lev.android_array[Yalien_wB]       = Xalien;
+  }
+
+  if (android_bug)
+  {
+    lev.android_array[Xbug_1_n]                = Xbug_2_n;
+    lev.android_array[Xbug_2_n]                = Xbug_2_n;
+    lev.android_array[Ybug_nB]         = Xbug_2_n;
+    lev.android_array[Ybug_n_e]                = Xbug_2_n;
+    lev.android_array[Ybug_n_w]                = Xbug_2_n;
+
+    lev.android_array[Xbug_1_e]                = Xbug_2_e;
+    lev.android_array[Xbug_2_e]                = Xbug_2_e;
+    lev.android_array[Ybug_eB]         = Xbug_2_e;
+    lev.android_array[Ybug_e_s]                = Xbug_2_e;
+    lev.android_array[Ybug_e_n]                = Xbug_2_e;
+
+    lev.android_array[Xbug_1_s]                = Xbug_2_s;
+    lev.android_array[Xbug_2_s]                = Xbug_2_s;
+    lev.android_array[Ybug_sB]         = Xbug_2_s;
+    lev.android_array[Ybug_s_w]                = Xbug_2_s;
+    lev.android_array[Ybug_s_e]                = Xbug_2_s;
+
+    lev.android_array[Xbug_1_w]                = Xbug_2_w;
+    lev.android_array[Xbug_2_w]                = Xbug_2_w;
+    lev.android_array[Ybug_wB]         = Xbug_2_w;
+    lev.android_array[Ybug_w_n]                = Xbug_2_w;
+    lev.android_array[Ybug_w_s]                = Xbug_2_w;
+  }
+
+  if (android_tank)
+  {
+    lev.android_array[Xtank_1_n]       = Xtank_1_n;
+    lev.android_array[Xtank_2_n]       = Xtank_1_n;
+    lev.android_array[Ytank_nB]                = Xtank_1_n;
+    lev.android_array[Ytank_n_e]       = Xtank_1_n;
+    lev.android_array[Ytank_n_w]       = Xtank_1_n;
+
+    lev.android_array[Xtank_1_e]       = Xtank_1_e;
+    lev.android_array[Xtank_2_e]       = Xtank_1_e;
+    lev.android_array[Ytank_eB]                = Xtank_1_e;
+    lev.android_array[Ytank_e_s]       = Xtank_1_e;
+    lev.android_array[Ytank_e_n]       = Xtank_1_e;
+
+    lev.android_array[Xtank_1_s]       = Xtank_1_s;
+    lev.android_array[Xtank_2_s]       = Xtank_1_s;
+    lev.android_array[Ytank_sB]                = Xtank_1_s;
+    lev.android_array[Ytank_s_w]       = Xtank_1_s;
+    lev.android_array[Ytank_s_e]       = Xtank_1_s;
+
+    lev.android_array[Xtank_1_w]       = Xtank_1_w;
+    lev.android_array[Xtank_2_w]       = Xtank_1_w;
+    lev.android_array[Ytank_wB]                = Xtank_1_w;
+    lev.android_array[Ytank_w_n]       = Xtank_1_w;
+    lev.android_array[Ytank_w_s]       = Xtank_1_w;
+  }
+
+  if (android_emerald)
+  {
+    lev.android_array[Xemerald]                = Xemerald;
+    lev.android_array[Xemerald_pause]  = Xemerald;
+    lev.android_array[Xemerald_fall]   = Xemerald;
+    lev.android_array[Yemerald_sB]     = Xemerald;
+    lev.android_array[Yemerald_eB]     = Xemerald;
+    lev.android_array[Yemerald_wB]     = Xemerald;
+  }
+
+  if (android_diamond)
+  {
+    lev.android_array[Xdiamond]                = Xdiamond;
+    lev.android_array[Xdiamond_pause]  = Xdiamond;
+    lev.android_array[Xdiamond_fall]   = Xdiamond;
+    lev.android_array[Ydiamond_sB]     = Xdiamond;
+    lev.android_array[Ydiamond_eB]     = Xdiamond;
+    lev.android_array[Ydiamond_wB]     = Xdiamond;
+  }
+
+  if (android_stone)
+  {
+    lev.android_array[Xstone]          = Xstone;
+    lev.android_array[Xstone_pause]    = Xstone;
+    lev.android_array[Xstone_fall]     = Xstone;
+    lev.android_array[Ystone_sB]       = Xstone;
+    lev.android_array[Ystone_eB]       = Xstone;
+    lev.android_array[Ystone_wB]       = Xstone;
+  }
+
+  if (android_bomb)
+  {
+    lev.android_array[Xbomb]           = Xbomb;
+    lev.android_array[Xbomb_pause]     = Xbomb;
+    lev.android_array[Xbomb_fall]      = Xbomb;
+    lev.android_array[Ybomb_sB]                = Xbomb;
+    lev.android_array[Ybomb_eB]                = Xbomb;
+    lev.android_array[Ybomb_wB]                = Xbomb;
+  }
+
+  if (android_nut)
+  {
+    lev.android_array[Xnut]            = Xnut;
+    lev.android_array[Xnut_pause]      = Xnut;
+    lev.android_array[Xnut_fall]       = Xnut;
+    lev.android_array[Ynut_sB]         = Xnut;
+    lev.android_array[Ynut_eB]         = Xnut;
+    lev.android_array[Ynut_wB]         = Xnut;
+  }
+
+  if (android_spring)
+  {
+    lev.android_array[Xspring]         = Xspring;
+    lev.android_array[Xspring_pause]   = Xspring;
+    lev.android_array[Xspring_fall]    = Xspring;
+    lev.android_array[Xspring_e]       = Xspring;
+    lev.android_array[Xspring_w]       = Xspring;
+    lev.android_array[Yspring_sB]      = Xspring;
+    lev.android_array[Yspring_eB]      = Xspring;
+    lev.android_array[Yspring_wB]      = Xspring;
+    lev.android_array[Yspring_alien_eB]        = Xspring;
+    lev.android_array[Yspring_alien_wB]        = Xspring;
+  }
+
+  if (android_dynamite)
+  {
+    lev.android_array[Xdynamite]       = Xdynamite;
+  }
+
+  if (android_balloon)
+  {
+    lev.android_array[Xballoon]                = Xballoon;
+    lev.android_array[Yballoon_nB]     = Xballoon;
+    lev.android_array[Yballoon_eB]     = Xballoon;
+    lev.android_array[Yballoon_sB]     = Xballoon;
+    lev.android_array[Yballoon_wB]     = Xballoon;
+  }
+
+  if (android_amoeba)
+  {
+    lev.android_array[Xfake_amoeba]    = Xdrip;
+    lev.android_array[Yfake_amoeba]    = Xdrip;
+    lev.android_array[Xamoeba_1]       = Xdrip;
+    lev.android_array[Xamoeba_2]       = Xdrip;
+    lev.android_array[Xamoeba_3]       = Xdrip;
+    lev.android_array[Xamoeba_4]       = Xdrip;
+    lev.android_array[Xamoeba_5]       = Xdrip;
+    lev.android_array[Xamoeba_6]       = Xdrip;
+    lev.android_array[Xamoeba_7]       = Xdrip;
+    lev.android_array[Xamoeba_8]       = Xdrip;
+  }
+}
+
 void convert_em_level(unsigned char *src, int file_version)
 {
   static int eater_offset[8] =
@@ -217,19 +409,7 @@ void convert_em_level(unsigned char *src, int file_version)
 
   temp = GET_BE16(src[2168]);
 
-  lev.android_emerald  = (temp & 1)    != 0;
-  lev.android_diamond  = (temp & 2)    != 0;
-  lev.android_stone    = (temp & 4)    != 0;
-  lev.android_bomb     = (temp & 8)    != 0;
-  lev.android_nut      = (temp & 16)   != 0;
-  lev.android_tank     = (temp & 32)   != 0;
-  lev.android_eater    = (temp & 64)   != 0;
-  lev.android_bug      = (temp & 128)  != 0;
-  lev.android_alien    = (temp & 256)  != 0;
-  lev.android_spring   = (temp & 512)  != 0;
-  lev.android_balloon  = (temp & 1024) != 0;
-  lev.android_amoeba   = (temp & 2048) != 0;
-  lev.android_dynamite = (temp & 4096) != 0;
+  init_android_clone_table(temp);
 
   /* eaters */