added full compatibility for wrap-around levels in EM engine
[rocksndiamonds.git] / src / game_em / logic.c
index ba9c05e5301b331f4cb64afc8398aff3d84190ca..5055be5a11ca930b75d19ddb7f9d42270177d90b 100644 (file)
@@ -12,6 +12,8 @@
 #define ACID_ROLL      /* rolling objects go into acid rather than remove it */
 #define ACID_PLAYER    /* player gets killed by acid, but without explosion */
 
+#define RANDOM_BUG     /* handle problem with old tapes using 64-bit random */
+
 #define RANDOM(x)      ((seed = seed << 31 | seed >> 1) % x)
 
 static short **cave, **next, **boom;
@@ -165,7 +167,7 @@ static void Lboom_eater(int x, int y)
   boom[x][y+1]   = lev.eater_array[lev.eater_pos][7];
   boom[x+1][y+1] = lev.eater_array[lev.eater_pos][8];
 
-  lev.eater_pos = (lev.eater_pos + 1) % 8;
+  lev.eater_pos = (lev.eater_pos + 1) % lev.num_eater_arrays;
 
 #if PLAY_ELEMENT_SOUND
   play_element_sound(x, y, SOUND_boom, Xeater_n);
@@ -7411,6 +7413,9 @@ static void logic_players(void)
     {
       ply[i].x = (ply[i].x < lev.left ? lev.right - 1 : lev.left);
 
+      if (!lev.infinite_true)
+       ply[i].y += (ply[i].x == lev.left ? 1 : -1);
+
       game.centered_player_nr_next = i;
       game.set_centered_player = TRUE;
       game.set_centered_player_wrap = TRUE;
@@ -7485,7 +7490,11 @@ static void logic_globals(void)
   int x;
   int y;
   int count;
-  unsigned int random;
+#ifdef RANDOM_BUG
+  uint64_t random;
+#else
+  uint32_t random;
+#endif
 
   cave = lev.cave;
   next = lev.next;
@@ -7531,6 +7540,11 @@ static void logic_globals(void)
       Lamoeba(x, y);
 
     random = random * 129 + 1;
+
+#ifdef RANDOM_BUG
+    if (!game_em.use_random_bug)
+      random = (uint32_t)random;
+#endif
   }
 
   game_em.random = random;