rnd-20070917-1-src
[rocksndiamonds.git] / src / tools.c
index d950959c53d4e723912185e7a23f32ff4b22c9df..23be2acbf3a7e03f1171bbbe36bcbb9254d65a81 100644 (file)
@@ -4813,6 +4813,14 @@ em_object_mapping_list[] =
     Xsand_stonesand_4,                 FALSE,  FALSE,
     EL_QUICKSAND_EMPTYING,             -1, -1
   },
+  {
+    Xsand_stonesand_quickout_1,                FALSE,  FALSE,
+    EL_QUICKSAND_EMPTYING,             -1, -1
+  },
+  {
+    Xsand_stonesand_quickout_2,                FALSE,  FALSE,
+    EL_QUICKSAND_EMPTYING,             -1, -1
+  },
 #else
   {
     Xsand_stonesand_1,                 FALSE,  FALSE,
@@ -6024,7 +6032,10 @@ inline static boolean check_linear_animation_EM(int tile)
   switch (tile)
   {
     case Xsand_stonesand_1:
+    case Xsand_stonesand_quickout_1:
     case Xsand_sandstone_1:
+    case Xsand_stonein_1:
+    case Xsand_stoneout_1:
     case Xboom_1:
     case Xdynamite_1:
     case Ybug_w_n:
@@ -6091,9 +6102,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);
@@ -6107,10 +6128,29 @@ void SetGfxAnimation_EM(int tile, int frame_em, int x, int y)
                             action == ACTION_FILLING ||
                             action == ACTION_EMPTYING);
 
+#if 0
+  if (tile == Xsand_stonesand_1 ||
+      tile == Xsand_stonesand_2 ||
+      tile == Xsand_stonesand_3 ||
+      tile == Xsand_stonesand_4)
+    printf("::: 1: quicksand frame %d [%d]\n", GfxFrame[x][y], tile);
+#endif
+
+#if 1
+  if ((action_removing || check_linear_animation_EM(tile)) && frame_em == 0)
+  {
+    GfxFrame[x][y] = 0;
+
+    // printf("::: resetting... [%d]\n", tile);
+  }
+#else
   if (action_removing || check_linear_animation_EM(tile))
   {
     GfxFrame[x][y] = frame_em;
+
+    // printf("::: resetting... [%d]\n", tile);
   }
+#endif
   else if (action_moving)
   {
     boolean is_backside = object_mapping[tile].is_backside;
@@ -6135,14 +6175,47 @@ void SetGfxAnimation_EM(int tile, int frame_em, int x, int y)
   else
   {
     GfxFrame[x][y]++;
+
+    /* special case: animation for Xsand_stonesand_quickout_1/2 twice as fast */
+    if (tile == Xsand_stonesand_quickout_1 ||
+       tile == Xsand_stonesand_quickout_2)
+      GfxFrame[x][y]++;
   }
+
+#if 0
+  if (tile == Xsand_stonesand_1 ||
+      tile == Xsand_stonesand_2 ||
+      tile == Xsand_stonesand_3 ||
+      tile == Xsand_stonesand_4)
+    printf("::: 2: quicksand frame %d [%d]\n", GfxFrame[x][y], tile);
+#endif
+
+#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) :