added using separate level structures (initial and runtime) for EM engine
[rocksndiamonds.git] / src / game_em / convert.c
index 4ce1611104a57311201cfde05918c1e517ec4ee0..aef209c25b6bb201eab78c4196bf3f710950076f 100644 (file)
@@ -13,6 +13,9 @@ void prepare_em_level(void)
   int players_left;
   boolean team_mode;
 
+  /* initialize runtime level structure */
+  lev = cav;
+
   /* reset all runtime variables to their initial values */
 
   game_init_cave_buffers();
@@ -38,7 +41,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] = native_em_level.cave[x][y];
+      lev.cave[lev.left + x][lev.top + y] = lev.cave_raw[x][y];
 
   for (x = lev.left; x < lev.right; x++)
     for (y = lev.top; y < lev.bottom; y++)
@@ -83,7 +86,8 @@ void prepare_em_level(void)
     ply[i].exists = 0;
     ply[i].alive_initial = FALSE;
 
-    if (ply[i].x_initial != -1 && ply[i].y_initial != -1)
+    if (lev.player_x[i] != -1 &&
+       lev.player_y[i] != -1)
     {
       ply[i].exists = 1;
 
@@ -110,10 +114,10 @@ void prepare_em_level(void)
       }
       else
       {
-       int x = ply[i].x_initial;
-       int y = ply[i].y_initial;
+       int x = lev.player_x[i];
+       int y = lev.player_y[i];
 
-       native_em_level.cave[x][y] = Xblank;
+       lev.cave_raw[x][y] = Xblank;
 
        lev.cave[lev.left + x][lev.top + y] = Xblank;
        lev.next[lev.left + x][lev.top + y] = Xblank;
@@ -130,8 +134,8 @@ void prepare_em_level(void)
     ply[i].dynamite_cnt = 0;
     ply[i].keys = 0;
     ply[i].anim = 0;
-    ply[i].oldx = ply[i].x = ply[i].x_initial + lev.left;
-    ply[i].oldy = ply[i].y = ply[i].y_initial + lev.top;
+    ply[i].oldx = ply[i].x = lev.player_x[i] + lev.left;
+    ply[i].oldy = ply[i].y = lev.player_y[i] + lev.top;
     ply[i].last_move_dir = MV_NONE;
     ply[i].joy_n = ply[i].joy_e = ply[i].joy_s = ply[i].joy_w = 0;
     ply[i].joy_snap  = ply[i].joy_drop = 0;