rnd-20060319-2-src
[rocksndiamonds.git] / src / game_em / convert.c
index e695f3735497af8c8443d68c97a0c2f010bcd19f..281cd25bfec5527ba9701d61fcca6ea549fab45b 100644 (file)
@@ -8,9 +8,7 @@
  * inconsequential, but no doubt it will break some caves.
  */
 
-#include "global.h"
-#include "tile.h"
-#include "level.h"
+#include "main_em.h"
 
 
 static unsigned char remap_v6[256] =
@@ -151,7 +149,7 @@ int cleanup_em_level(unsigned char *src, int length)
     for (i = 2112; i < 2148; i++) src[i] = src[i - 64];
   }
   else if (length >= 2106 &&
-          src[0] == 241 &&
+          src[0] == 241 &&     /* <-- Emerald Mine I levels */
           src[1983] == 27)
   {
     unsigned char j = 94;
@@ -171,7 +169,7 @@ int cleanup_em_level(unsigned char *src, int length)
   }
 #if 1
   else if (length >= 2106 &&
-          src[0] == 245 &&
+          src[0] == 245 &&     /* <-- Emerald Mine II levels */
           src[1983] == 27)
   {
     unsigned char j = 94;
@@ -188,6 +186,11 @@ int cleanup_em_level(unsigned char *src, int length)
       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
@@ -538,7 +541,7 @@ static unsigned short remap_emerald[256] =
   Xblank,              Xblank,         Xblank,         Xblank,
 #else
   /* special elements added to solve compatibility problems */
-  Xblank,              Xblank,         Xblank,         Xfake_acid_1
+  Xblank,              Xblank,         Xalpha_copyr,   Xfake_acid_1
 #endif
 };
 
@@ -903,6 +906,7 @@ void prepare_em_level(void)
 {
   int i, x, y;
   int players_left;
+  int num_tape_players;
 
   /* reset all runtime variables to their initial values */
 
@@ -969,7 +973,11 @@ void prepare_em_level(void)
     }
   }
 
-  if (!setup.team_mode)
+  num_tape_players = getNumActivePlayers_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);
 
   lev.home = lev.home_initial;
@@ -986,7 +994,12 @@ void prepare_em_level(void)
       }
       else
       {
-       native_em_level.cave[ply[i].x_initial][ply[i].y_initial] = Xblank;
+       int x = ply[i].x_initial;
+       int y = ply[i].y_initial;
+
+       native_em_level.cave[x][y] = Xblank;
+
+       Cave[y][x] = Next[y][x] = Draw[y][x] = Xblank;
       }
     }
   }
@@ -1011,4 +1024,10 @@ void prepare_em_level(void)
           i, ply[i].x_initial, ply[i].y_initial, ply[i].alive);
 #endif
   }
+
+  game_em.any_player_moving = FALSE;
+  game_em.last_moving_player = 0;      /* default: first player */
+
+  for (i = 0; i < MAX_PLAYERS; i++)
+    game_em.last_player_direction[i] = MV_NONE;
 }