fixed bug with shifted global playfield animations during envelope requests
[rocksndiamonds.git] / src / anim.c
index 710383f3c608c03e4e3832fea3b13e6ab6cc3bbf..4d67b458378eb27206df6d91bd7a12344a32edff 100644 (file)
@@ -1732,12 +1732,17 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part,
   if (c->position == POS_CE)
   {
     // calculate playfield position (with scrolling) for related CE tile
+    // (do not use FX/FY, which are incorrect during envelope requests)
+    int FX0 = 2 * TILEX_VAR;   // same as FX during DRAW_TO_FIELDBUFFER
+    int FY0 = 2 * TILEY_VAR;   // same as FY during DRAW_TO_FIELDBUFFER
     int fx = getFieldbufferOffsetX_RND(ScreenMovDir, ScreenGfxPos);
     int fy = getFieldbufferOffsetY_RND(ScreenMovDir, ScreenGfxPos);
-    int sx = FX + SCREENX(part->tile_x) * TILEX_VAR;
-    int sy = FY + SCREENY(part->tile_y) * TILEY_VAR;
-    int x = sx - fx;
-    int y = sy - fy;
+    int sx = FX0 + SCREENX(part->tile_x) * TILEX_VAR;
+    int sy = FY0 + SCREENY(part->tile_y) * TILEY_VAR;
+    int cx = SX - REAL_SX;
+    int cy = SY - REAL_SY;
+    int x = sx - fx + cx;
+    int y = sy - fy + cy;
 
     part->tile_xoffset += part->step_xoffset;
     part->tile_yoffset += part->step_yoffset;
@@ -2164,6 +2169,11 @@ void RestartGlobalAnimsByStatus(int status)
   global.anim_status = anim_status_last;
 }
 
+void SetAnimStatusBeforeFading(int status)
+{
+  anim_status_last_before_fading = status;
+}
+
 boolean HandleGlobalAnimClicks(int mx, int my, int button, boolean force_click)
 {
   static boolean click_consumed = FALSE;