Merge branch 'master' into releases
[rocksndiamonds.git] / src / tools.c
index c0d20d549539de195fcaa79c31bac8813111b0b3..7e2c3752d3a63f193abf5f86c2d66bdb1d659797 100644 (file)
@@ -4796,6 +4796,24 @@ em_object_mapping_list[] =
     Xsand_stonein_4,                   FALSE,  TRUE,
     EL_ROCK,                           ACTION_FILLING, -1
   },
+#if 1
+  {
+    Xsand_stonesand_1,                 FALSE,  FALSE,
+    EL_QUICKSAND_EMPTYING,             -1, -1
+  },
+  {
+    Xsand_stonesand_2,                 FALSE,  FALSE,
+    EL_QUICKSAND_EMPTYING,             -1, -1
+  },
+  {
+    Xsand_stonesand_3,                 FALSE,  FALSE,
+    EL_QUICKSAND_EMPTYING,             -1, -1
+  },
+  {
+    Xsand_stonesand_4,                 FALSE,  FALSE,
+    EL_QUICKSAND_EMPTYING,             -1, -1
+  },
+#else
   {
     Xsand_stonesand_1,                 FALSE,  FALSE,
     EL_QUICKSAND_FULL,                 -1, -1
@@ -4812,6 +4830,7 @@ em_object_mapping_list[] =
     Xsand_stonesand_4,                 FALSE,  FALSE,
     EL_QUICKSAND_FULL,                 -1, -1
   },
+#endif
   {
     Xsand_stoneout_1,                  FALSE,  FALSE,
     EL_ROCK,                           ACTION_EMPTYING, -1
@@ -4820,6 +4839,24 @@ em_object_mapping_list[] =
     Xsand_stoneout_2,                  FALSE,  FALSE,
     EL_ROCK,                           ACTION_EMPTYING, -1
   },
+#if 1
+  {
+    Xsand_sandstone_1,                 FALSE,  FALSE,
+    EL_QUICKSAND_FILLING,              -1, -1
+  },
+  {
+    Xsand_sandstone_2,                 FALSE,  FALSE,
+    EL_QUICKSAND_FILLING,              -1, -1
+  },
+  {
+    Xsand_sandstone_3,                 FALSE,  FALSE,
+    EL_QUICKSAND_FILLING,              -1, -1
+  },
+  {
+    Xsand_sandstone_4,                 FALSE,  FALSE,
+    EL_QUICKSAND_FILLING,              -1, -1
+  },
+#else
   {
     Xsand_sandstone_1,                 FALSE,  FALSE,
     EL_QUICKSAND_FULL,                 -1, -1
@@ -4836,6 +4873,7 @@ em_object_mapping_list[] =
     Xsand_sandstone_4,                 FALSE,  FALSE,
     EL_QUICKSAND_FULL,                 -1, -1
   },
+#endif
   {
     Xplant,                            TRUE,   FALSE,
     EL_EMC_PLANT,                      -1, -1
@@ -5985,6 +6023,8 @@ inline static boolean check_linear_animation_EM(int tile)
 {
   switch (tile)
   {
+    case Xsand_stonesand_1:
+    case Xsand_sandstone_1:
     case Xboom_1:
     case Xdynamite_1:
     case Ybug_w_n:
@@ -6051,9 +6091,19 @@ void ResetGfxAnimation_EM(int x, int y, int tile)
   GfxFrame[x][y] = 0;
 }
 
-void SetGfxAnimation_EM(int tile, int frame_em, int x, int y)
+void SetGfxAnimation_EM(struct GraphicInfo_EM *g_em,
+                       int tile, int frame_em, int x, int y)
 {
   int action = object_mapping[tile].action;
+#if 1
+  int direction = object_mapping[tile].direction;
+  int effective_element = get_effective_element_EM(tile, frame_em);
+  int graphic = (direction == MV_NONE ?
+                el_act2img(effective_element, action) :
+                el_act_dir2img(effective_element, action, direction));
+  struct GraphicInfo *g = &graphic_info[graphic];
+  int sync_frame;
+#endif
   boolean action_removing = (action == ACTION_DIGGING ||
                             action == ACTION_SNAPPING ||
                             action == ACTION_COLLECTING);
@@ -6096,13 +6146,33 @@ void SetGfxAnimation_EM(int tile, int frame_em, int x, int y)
   {
     GfxFrame[x][y]++;
   }
+
+#if 1
+  if (graphic_info[graphic].anim_global_sync)
+    sync_frame = FrameCounter;
+  else if (IN_FIELD(x, y, MAX_LEV_FIELDX, MAX_LEV_FIELDY))
+    sync_frame = GfxFrame[x][y];
+  else
+    sync_frame = 0;    /* playfield border (pseudo steel) */
+
+  SetRandomAnimationValue(x, y);
+
+  int frame = getAnimationFrame(g->anim_frames,
+                               g->anim_delay,
+                               g->anim_mode,
+                               g->anim_start_frame,
+                               sync_frame);
+
+  g_em->unique_identifier =
+    (graphic << 16) | ((frame % 8) << 12) | (g_em->width << 6) | g_em->height;
+#endif
 }
 
 void getGraphicSourceObjectExt_EM(struct GraphicInfo_EM *g_em,
                                  int tile, int frame_em, int x, int y)
 {
-  int action          = object_mapping[tile].action;
-  int direction       = object_mapping[tile].direction;
+  int action = object_mapping[tile].action;
+  int direction = object_mapping[tile].direction;
   int effective_element = get_effective_element_EM(tile, frame_em);
   int graphic = (direction == MV_NONE ?
                 el_act2img(effective_element, action) :