rnd-20020930-1-src
[rocksndiamonds.git] / src / game.c
index 502d60d7b50dd68b6132b81a6ae84a0eeed3f4a7..5dd55c76ffa8391c9c2acb1af3ec3b542da531b9 100644 (file)
@@ -229,21 +229,28 @@ void GetPlayerConfig()
   InitJoysticks();
 }
 
-static int getBeltNrFromElement(int element)
+static int getBeltNrFromBeltElement(int element)
 {
   return (element < EL_CONVEYOR_BELT2_LEFT ? 0 :
          element < EL_CONVEYOR_BELT3_LEFT ? 1 :
          element < EL_CONVEYOR_BELT4_LEFT ? 2 : 3);
 }
 
-static int getBeltNrFromSwitchElement(int element)
+static int getBeltNrFromBeltActiveElement(int element)
+{
+  return (element < EL_CONVEYOR_BELT2_LEFT_ACTIVE ? 0 :
+         element < EL_CONVEYOR_BELT3_LEFT_ACTIVE ? 1 :
+         element < EL_CONVEYOR_BELT4_LEFT_ACTIVE ? 2 : 3);
+}
+
+static int getBeltNrFromBeltSwitchElement(int element)
 {
   return (element < EL_CONVEYOR_BELT2_SWITCH_LEFT ? 0 :
          element < EL_CONVEYOR_BELT3_SWITCH_LEFT ? 1 :
          element < EL_CONVEYOR_BELT4_SWITCH_LEFT ? 2 : 3);
 }
 
-static int getBeltDirNrFromSwitchElement(int element)
+static int getBeltDirNrFromBeltSwitchElement(int element)
 {
   static int belt_base_element[4] =
   {
@@ -253,13 +260,13 @@ static int getBeltDirNrFromSwitchElement(int element)
     EL_CONVEYOR_BELT4_SWITCH_LEFT
   };
 
-  int belt_nr = getBeltNrFromSwitchElement(element);
+  int belt_nr = getBeltNrFromBeltSwitchElement(element);
   int belt_dir_nr = element - belt_base_element[belt_nr];
 
   return (belt_dir_nr % 3);
 }
 
-static int getBeltDirFromSwitchElement(int element)
+static int getBeltDirFromBeltSwitchElement(int element)
 {
   static int belt_move_dir[3] =
   {
@@ -268,7 +275,7 @@ static int getBeltDirFromSwitchElement(int element)
     MV_RIGHT
   };
 
-  int belt_dir_nr = getBeltDirNrFromSwitchElement(element);
+  int belt_dir_nr = getBeltDirNrFromBeltSwitchElement(element);
 
   return belt_move_dir[belt_dir_nr];
 }
@@ -287,10 +294,6 @@ static void InitField(int x, int y, boolean init_game)
        }
       }
       /* no break! */
-    case EL_PLAYER:
-      if (init_game)
-       Feld[x][y] = EL_PLAYER1;
-      /* no break! */
     case EL_PLAYER1:
     case EL_PLAYER2:
     case EL_PLAYER3:
@@ -443,9 +446,9 @@ static void InitField(int x, int y, boolean init_game)
     case EL_CONVEYOR_BELT4_SWITCH_RIGHT:
       if (init_game)
       {
-       int belt_nr = getBeltNrFromSwitchElement(Feld[x][y]);
-       int belt_dir = getBeltDirFromSwitchElement(Feld[x][y]);
-       int belt_dir_nr = getBeltDirNrFromSwitchElement(Feld[x][y]);
+       int belt_nr = getBeltNrFromBeltSwitchElement(Feld[x][y]);
+       int belt_dir = getBeltDirFromBeltSwitchElement(Feld[x][y]);
+       int belt_dir_nr = getBeltDirNrFromBeltSwitchElement(Feld[x][y]);
 
        if (game.belt_dir_nr[belt_nr] == 3)     /* initial value */
        {
@@ -666,12 +669,14 @@ void InitGame()
 
   InitGameEngine();
 
+#if 0
 #if DEBUG
 #if USE_NEW_AMOEBA_CODE
   printf("Using new amoeba code.\n");
 #else
   printf("Using old amoeba code.\n");
 #endif
+#endif
 #endif
 
   /* don't play tapes over network */
@@ -1545,7 +1550,7 @@ void Explode(int ex, int ey, int phase, int mode)
        RemoveMovingField(x, y);
       }
 
-      if (IS_MASSIVE(element) || element == EL_DRAGON_FIRE)
+      if (IS_MASSIVE(element) || element == EL_FLAMES)
        continue;
 
       if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y)))
@@ -1734,7 +1739,7 @@ void DynaExplode(int ex, int ey)
 
   if (IS_ACTIVE_BOMB(Feld[ex][ey]))
   {
-    player = &stored_player[Feld[ex][ey] - EL_DYNABOMB_ACTIVE_1];
+    player = &stored_player[Feld[ex][ey] - EL_DYNABOMB_PLAYER1_ACTIVE];
     dynabomb_size = player->dynabomb_size;
     dynabomb_xl = player->dynabomb_xl;
     player->dynabombs_left++;
@@ -1798,10 +1803,10 @@ void Bang(int x, int y)
       RaiseScoreElement(element);
       Explode(x, y, EX_PHASE_START, EX_NORMAL);
       break;
-    case EL_DYNABOMB_ACTIVE_1:
-    case EL_DYNABOMB_ACTIVE_2:
-    case EL_DYNABOMB_ACTIVE_3:
-    case EL_DYNABOMB_ACTIVE_4:
+    case EL_DYNABOMB_PLAYER1_ACTIVE:
+    case EL_DYNABOMB_PLAYER2_ACTIVE:
+    case EL_DYNABOMB_PLAYER3_ACTIVE:
+    case EL_DYNABOMB_PLAYER4_ACTIVE:
     case EL_DYNABOMB_NR:
     case EL_DYNABOMB_SZ:
     case EL_DYNABOMB_XL:
@@ -1868,6 +1873,20 @@ void Blurb(int x, int y)
 static void ToggleBeltSwitch(int x, int y)
 {
   static int belt_base_element[4] =
+  {
+    EL_CONVEYOR_BELT1_LEFT,
+    EL_CONVEYOR_BELT2_LEFT,
+    EL_CONVEYOR_BELT3_LEFT,
+    EL_CONVEYOR_BELT4_LEFT
+  };
+  static int belt_base_active_element[4] =
+  {
+    EL_CONVEYOR_BELT1_LEFT_ACTIVE,
+    EL_CONVEYOR_BELT2_LEFT_ACTIVE,
+    EL_CONVEYOR_BELT3_LEFT_ACTIVE,
+    EL_CONVEYOR_BELT4_LEFT_ACTIVE
+  };
+  static int belt_base_switch_element[4] =
   {
     EL_CONVEYOR_BELT1_SWITCH_LEFT,
     EL_CONVEYOR_BELT2_SWITCH_LEFT,
@@ -1883,7 +1902,7 @@ static void ToggleBeltSwitch(int x, int y)
   };
 
   int element = Feld[x][y];
-  int belt_nr = getBeltNrFromSwitchElement(element);
+  int belt_nr = getBeltNrFromBeltSwitchElement(element);
   int belt_dir_nr = (game.belt_dir_nr[belt_nr] + 1) % 4;
   int belt_dir = belt_move_dir[belt_dir_nr];
   int xx, yy;
@@ -1905,20 +1924,37 @@ static void ToggleBeltSwitch(int x, int y)
 
       if (IS_BELT_SWITCH(element))
       {
-       int e_belt_nr = getBeltNrFromSwitchElement(element);
+       int e_belt_nr = getBeltNrFromBeltSwitchElement(element);
+
+       if (e_belt_nr == belt_nr)
+       {
+         Feld[xx][yy] = belt_base_switch_element[belt_nr] + belt_dir_nr;
+         DrawLevelField(xx, yy);
+       }
+      }
+      else if (IS_BELT(element) && belt_dir != MV_NO_MOVING)
+      {
+       int e_belt_nr = getBeltNrFromBeltElement(element);
 
        if (e_belt_nr == belt_nr)
        {
-         Feld[xx][yy] = belt_base_element[belt_nr] + belt_dir_nr;
+         int belt_part = Feld[xx][yy] - belt_base_element[belt_nr];
+
+         Feld[xx][yy] = belt_base_active_element[belt_nr] + belt_part;
          DrawLevelField(xx, yy);
        }
       }
-      else if (belt_dir == MV_NO_MOVING && IS_BELT(element))
+      else if (IS_BELT_ACTIVE(element) && belt_dir == MV_NO_MOVING)
       {
-       int e_belt_nr = getBeltNrFromElement(element);
+       int e_belt_nr = getBeltNrFromBeltActiveElement(element);
 
        if (e_belt_nr == belt_nr)
-         DrawLevelField(xx, yy);    /* set belt to parking position */
+       {
+         int belt_part = Feld[xx][yy] - belt_base_active_element[belt_nr];
+
+         Feld[xx][yy] = belt_base_element[belt_nr] + belt_part;
+         DrawLevelField(xx, yy);
+       }
       }
     }
   }
@@ -1958,6 +1994,20 @@ static void ToggleSwitchgateSwitch(int x, int y)
   }
 }
 
+static int getInvisibleActiveFromInvisibleElement(int element)
+{
+  return (element == EL_INVISIBLE_STEELWALL ? EL_INVISIBLE_STEELWALL_ACTIVE :
+         element == EL_INVISIBLE_WALL      ? EL_INVISIBLE_WALL_ACTIVE :
+         EL_INVISIBLE_SAND_ACTIVE);
+}
+
+static int getInvisibleFromInvisibleActiveElement(int element)
+{
+  return (element == EL_INVISIBLE_STEELWALL_ACTIVE ? EL_INVISIBLE_STEELWALL :
+         element == EL_INVISIBLE_WALL_ACTIVE      ? EL_INVISIBLE_WALL :
+         EL_INVISIBLE_SAND);
+}
+
 static void RedrawAllLightSwitchesAndInvisibleElements()
 {
   int x, y;
@@ -1980,11 +2030,24 @@ static void RedrawAllLightSwitchesAndInvisibleElements()
        Feld[x][y] = EL_LIGHT_SWITCH;
        DrawLevelField(x, y);
       }
+      else if (element == EL_INVISIBLE_STEELWALL ||
+              element == EL_INVISIBLE_WALL ||
+              element == EL_INVISIBLE_SAND)
+      {
+       if (game.light_time_left > 0)
+         Feld[x][y] = getInvisibleActiveFromInvisibleElement(element);
+
+       DrawLevelField(x, y);
+      }
+      else if (element == EL_INVISIBLE_STEELWALL_ACTIVE ||
+              element == EL_INVISIBLE_WALL_ACTIVE ||
+              element == EL_INVISIBLE_SAND_ACTIVE)
+      {
+       if (game.light_time_left == 0)
+         Feld[x][y] = getInvisibleFromInvisibleActiveElement(element);
 
-      if (element == EL_INVISIBLE_STEELWALL ||
-         element == EL_INVISIBLE_WALL ||
-         element == EL_INVISIBLE_SAND)
        DrawLevelField(x, y);
+      }
     }
   }
 }
@@ -2094,8 +2157,8 @@ void Impact(int x, int y)
     {
       int xx, yy;
       int activated_magic_wall =
-       (smashed == EL_MAGIC_WALL ? EL_MAGIC_WALL_EMPTY :
-        EL_BD_MAGIC_WALL_EMPTY);
+       (smashed == EL_MAGIC_WALL ? EL_MAGIC_WALL_ACTIVE :
+        EL_BD_MAGIC_WALL_ACTIVE);
 
       /* activate magic wall / mill */
       for (yy=0; yy<lev_fieldy; yy++)
@@ -2195,12 +2258,12 @@ void Impact(int x, int y)
 
   /* play sound of magic wall / mill */
   if (!lastline &&
-      (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY ||
-       Feld[x][y+1] == EL_BD_MAGIC_WALL_EMPTY))
+      (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE ||
+       Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE))
   {
-    if (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY)
+    if (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE)
       PlaySoundLevel(x, y, SND_MAGIC_WALL_CHANGING);
-    else if (Feld[x][y+1] == EL_BD_MAGIC_WALL_EMPTY)
+    else if (Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE)
       PlaySoundLevel(x, y, SND_BD_MAGIC_WALL_CHANGING);
 
     return;
@@ -2710,7 +2773,7 @@ void StartMoving(int x, int y)
        Feld[x][y] = EL_MAGIC_WALL_EMPTYING;
        Store[x][y] = EL_CHANGED(Store[x][y]);
       }
-      else if (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY)
+      else if (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE)
       {
        if (!MovDelay[x][y])
          MovDelay[x][y] = TILEY/4 + 1;
@@ -2722,7 +2785,7 @@ void StartMoving(int x, int y)
            return;
        }
 
-       Feld[x][y] = EL_MAGIC_WALL_EMPTY;
+       Feld[x][y] = EL_MAGIC_WALL_ACTIVE;
        Feld[x][y+1] = EL_MAGIC_WALL_FULL;
        Store[x][y+1] = EL_CHANGED(Store[x][y]);
        Store[x][y] = 0;
@@ -2736,7 +2799,7 @@ void StartMoving(int x, int y)
        Feld[x][y] = EL_BD_MAGIC_WALL_EMPTYING;
        Store[x][y] = EL_CHANGED2(Store[x][y]);
       }
-      else if (Feld[x][y+1] == EL_BD_MAGIC_WALL_EMPTY)
+      else if (Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE)
       {
        if (!MovDelay[x][y])
          MovDelay[x][y] = TILEY/4 + 1;
@@ -2748,19 +2811,19 @@ void StartMoving(int x, int y)
            return;
        }
 
-       Feld[x][y] = EL_BD_MAGIC_WALL_EMPTY;
+       Feld[x][y] = EL_BD_MAGIC_WALL_ACTIVE;
        Feld[x][y+1] = EL_BD_MAGIC_WALL_FULL;
        Store[x][y+1] = EL_CHANGED2(Store[x][y]);
        Store[x][y] = 0;
       }
     }
     else if (CAN_CHANGE(element) &&
-            (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY ||
-             Feld[x][y+1] == EL_BD_MAGIC_WALL_EMPTY))
+            (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE ||
+             Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE))
     {
       InitMovingField(x, y, MV_DOWN);
       Feld[x][y] =
-       (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY ? EL_MAGIC_WALL_FILLING :
+       (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE ? EL_MAGIC_WALL_FILLING :
         EL_BD_MAGIC_WALL_FILLING);
       Store[x][y] = element;
     }
@@ -2817,11 +2880,11 @@ void StartMoving(int x, int y)
        InitMovingField(x, y, left ? MV_LEFT : MV_RIGHT);
       }
     }
-    else if (IS_BELT(Feld[x][y+1]))
+    else if (IS_BELT_ACTIVE(Feld[x][y+1]))
     {
       boolean left_is_free  = (x>0 && IS_FREE(x-1, y));
       boolean right_is_free = (x<lev_fieldx-1 && IS_FREE(x+1, y));
-      int belt_nr = getBeltNrFromElement(Feld[x][y+1]);
+      int belt_nr = getBeltNrFromBeltActiveElement(Feld[x][y+1]);
       int belt_dir = game.belt_dir[belt_nr];
 
       if ((belt_dir == MV_LEFT  && left_is_free) ||
@@ -2916,13 +2979,13 @@ void StartMoving(int x, int y)
            else
              RemoveMovingField(xx, yy);
 
-           Feld[xx][yy] = EL_DRAGON_FIRE;
+           Feld[xx][yy] = EL_FLAMES;
            if (IN_SCR_FIELD(sx, sy))
              DrawGraphic(sx, sy, graphic + phase*3 + i-1);
          }
          else
          {
-           if (Feld[xx][yy] == EL_DRAGON_FIRE)
+           if (Feld[xx][yy] == EL_FLAMES)
              Feld[xx][yy] = EL_EMPTY;
            DrawLevelField(xx, yy);
          }
@@ -3044,7 +3107,7 @@ void StartMoving(int x, int y)
 
        if ((wanna_flame || IS_ENEMY(element1) || IS_ENEMY(element2)) &&
            element1 != EL_DRAGON && element2 != EL_DRAGON &&
-           element1 != EL_DRAGON_FIRE && element2 != EL_DRAGON_FIRE)
+           element1 != EL_FLAMES && element2 != EL_FLAMES)
        {
          if (IS_PLAYER(x, y))
            DrawPlayerField(x, y);
@@ -3054,11 +3117,11 @@ void StartMoving(int x, int y)
          PlaySoundLevel(x, y, SND_DRAGON_ATTACKING);
 
          MovDelay[x][y] = 50;
-         Feld[newx][newy] = EL_DRAGON_FIRE;
+         Feld[newx][newy] = EL_FLAMES;
          if (IN_LEV_FIELD(newx1, newy1) && Feld[newx1][newy1] == EL_EMPTY)
-           Feld[newx1][newy1] = EL_DRAGON_FIRE;
+           Feld[newx1][newy1] = EL_FLAMES;
          if (IN_LEV_FIELD(newx2, newy2) && Feld[newx2][newy2] == EL_EMPTY)
-           Feld[newx2][newy2] = EL_DRAGON_FIRE;
+           Feld[newx2][newy2] = EL_FLAMES;
          return;
        }
       }
@@ -3071,7 +3134,7 @@ void StartMoving(int x, int y)
       else
       {
        Feld[newx][newy] = EL_EMPTY;
-       DrawLevelField(newx, newy);
+       DrawNewLevelField(newx, newy);
       }
 
       PlaySoundLevel(x, y, SND_YAMYAM_EATING);
@@ -3092,7 +3155,7 @@ void StartMoving(int x, int y)
       else
       {
        Feld[newx][newy] = EL_EMPTY;
-       DrawLevelField(newx, newy);
+       DrawNewLevelField(newx, newy);
       }
 
       PlaySoundLevel(x, y, SND_DARK_YAMYAM_EATING);
@@ -3144,7 +3207,7 @@ void StartMoving(int x, int y)
 #endif
       else if (element == EL_BUG || element == EL_SPACESHIP ||
               element == EL_SP_SNIKSNAK || element == EL_MOLE)
-#if 1
+#if 0
        DrawLevelField(x, y);
 #else
        DrawNewLevelField(x, y);
@@ -3206,7 +3269,7 @@ void ContinueMoving(int x, int y)
           element == EL_BD_MAGIC_WALL_EMPTYING)
     step /= 2;
   else if (CAN_FALL(element) && horiz_move &&
-          y < lev_fieldy-1 && IS_BELT(Feld[x][y+1]))
+          y < lev_fieldy-1 && IS_BELT_ACTIVE(Feld[x][y+1]))
     step /= 2;
   else if (element == EL_SPRING_MOVING)
     step*=2;
@@ -3235,7 +3298,7 @@ void ContinueMoving(int x, int y)
       };
 
       Feld[x][y] = EL_SAND;
-      DrawLevelField(x, y);
+      DrawNewLevelField(x, y);
 
       for(i=0; i<4; i++)
       {
@@ -3245,7 +3308,7 @@ void ContinueMoving(int x, int y)
        yy = y + xy[i][1];
 
        if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == EL_SAND)
-         DrawLevelField(xx, yy);       /* for "ErdreichAnbroeckeln()" */
+         DrawNewLevelField(xx, yy);    /* for "ErdreichAnbroeckeln()" */
       }
     }
 
@@ -3304,18 +3367,8 @@ void ContinueMoving(int x, int y)
     if (!CAN_MOVE(element))
       MovDir[newx][newy] = 0;
 
-    if (element == EL_BUG || element == EL_SPACESHIP ||
-       element == EL_SP_SNIKSNAK || element == EL_PACMAN ||
-       element == EL_SP_ELECTRON)
-    {
-      DrawNewLevelField(x, y);
-      DrawNewLevelField(newx, newy);
-    }
-    else
-    {
-      DrawLevelField(x, y);
-      DrawLevelField(newx, newy);
-    }
+    DrawNewLevelField(x, y);
+    DrawNewLevelField(newx, newy);
 
     Stop[newx][newy] = TRUE;
     JustStopped[newx][newy] = 3;
@@ -3335,12 +3388,7 @@ void ContinueMoving(int x, int y)
   }
   else                         /* still moving on */
   {
-    if (element == EL_BUG || element == EL_SPACESHIP ||
-       element == EL_SP_SNIKSNAK || element == EL_PACMAN ||
-       element == EL_SP_ELECTRON)
-      DrawNewLevelField(x, y);
-    else
-      DrawLevelField(x, y);
+    DrawNewLevelField(x, y);
   }
 }
 
@@ -4296,7 +4344,7 @@ void CheckForDragon(int x, int y)
       int xx = x + j*xy[i][0], yy = y + j*xy[i][1];
 
       if (IN_LEV_FIELD(xx, yy) &&
-         (Feld[xx][yy] == EL_DRAGON_FIRE || Feld[xx][yy] == EL_DRAGON))
+         (Feld[xx][yy] == EL_FLAMES || Feld[xx][yy] == EL_DRAGON))
       {
        if (Feld[xx][yy] == EL_DRAGON)
          dragon_found = TRUE;
@@ -4314,7 +4362,7 @@ void CheckForDragon(int x, int y)
       {
        int xx = x + j*xy[i][0], yy = y + j*xy[i][1];
   
-       if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == EL_DRAGON_FIRE)
+       if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == EL_FLAMES)
        {
          Feld[xx][yy] = EL_EMPTY;
          DrawLevelField(xx, yy);
@@ -4374,7 +4422,7 @@ static void CheckBuggyBase(int x, int y)
 
          if (IS_PLAYER(xx, yy))
          {
-           PlaySoundLevel(x, y, SND_SP_BUGGY_BASE_ACTIVATING);
+           PlaySoundLevel(x, y, SND_SP_BUGGY_BASE_ACTIVE);
            break;
          }
        }
@@ -4446,7 +4494,7 @@ static void CheckTrap(int x, int y)
 
 static void DrawBeltAnimation(int x, int y, int element)
 {
-  int belt_nr = getBeltNrFromElement(element);
+  int belt_nr = getBeltNrFromBeltActiveElement(element);
   int belt_dir = game.belt_dir[belt_nr];
 
   if (belt_dir != MV_NO_MOVING)
@@ -4803,7 +4851,7 @@ void GameActions()
             element == EL_WALL_GROWING_Y ||
             element == EL_WALL_GROWING_XY)
       MauerAbleger(x, y);
-    else if (element == EL_DRAGON_FIRE)
+    else if (element == EL_FLAMES)
       CheckForDragon(x, y);
     else if (element == EL_SP_BUGGY_BASE || element == EL_SP_BUGGY_BASE_ACTIVE)
       CheckBuggyBase(x, y);
@@ -4819,7 +4867,7 @@ void GameActions()
        PlaySoundLevel(x, y, SND_SP_TERMINAL_ACTIVE);
 #endif
     }
-    else if (IS_BELT(element))
+    else if (IS_BELT_ACTIVE(element))
       DrawBeltAnimation(x, y, element);
     else if (element == EL_SWITCHGATE_OPENING)
       OpenSwitchgate(x, y);
@@ -4854,14 +4902,14 @@ void GameActions()
       int jx = local_player->jx, jy = local_player->jy;
 
       if (element == EL_MAGIC_WALL_FULL ||
-         element == EL_MAGIC_WALL_EMPTY ||
+         element == EL_MAGIC_WALL_ACTIVE ||
          element == EL_MAGIC_WALL_EMPTYING)
       {
        SiebAktivieren(x, y, 1);
        sieb = TRUE;
       }
       else if (element == EL_BD_MAGIC_WALL_FULL ||
-              element == EL_BD_MAGIC_WALL_EMPTY ||
+              element == EL_BD_MAGIC_WALL_ACTIVE ||
               element == EL_BD_MAGIC_WALL_EMPTYING)
       {
        SiebAktivieren(x, y, 2);
@@ -4943,7 +4991,7 @@ void GameActions()
       int element = Feld[sieb_x][sieb_y];
 
       if (element == EL_BD_MAGIC_WALL_FULL ||
-         element == EL_BD_MAGIC_WALL_EMPTY ||
+         element == EL_BD_MAGIC_WALL_ACTIVE ||
          element == EL_BD_MAGIC_WALL_EMPTYING)
        PlaySoundLevel(sieb_x, sieb_y, SND_BD_MAGIC_WALL_ACTIVE);
       else
@@ -4959,13 +5007,13 @@ void GameActions()
        {
          element = Feld[x][y];
 
-         if (element == EL_MAGIC_WALL_EMPTY ||
+         if (element == EL_MAGIC_WALL_ACTIVE ||
              element == EL_MAGIC_WALL_FULL)
          {
            Feld[x][y] = EL_MAGIC_WALL_DEAD;
            DrawLevelField(x, y);
          }
-         else if (element == EL_BD_MAGIC_WALL_EMPTY ||
+         else if (element == EL_BD_MAGIC_WALL_ACTIVE ||
                   element == EL_BD_MAGIC_WALL_FULL)
          {
            Feld[x][y] = EL_BD_MAGIC_WALL_DEAD;
@@ -4983,22 +5031,7 @@ void GameActions()
     game.light_time_left--;
 
     if (game.light_time_left == 0)
-    {
-      for (y=0; y<lev_fieldy; y++) for (x=0; x<lev_fieldx; x++)
-      {
-       element = Feld[x][y];
-
-       if (element == EL_LIGHT_SWITCH_ACTIVE)
-       {
-         Feld[x][y] = EL_LIGHT_SWITCH;
-         DrawLevelField(x, y);
-       }
-       else if (element == EL_INVISIBLE_STEELWALL ||
-                element == EL_INVISIBLE_WALL ||
-                element == EL_INVISIBLE_SAND)
-         DrawLevelField(x, y);
-      }
-    }
+      RedrawAllLightSwitchesAndInvisibleElements();
   }
 
   if (game.timegate_time_left > 0)
@@ -5211,7 +5244,7 @@ boolean MoveFigureOneStep(struct PlayerInfo *player,
     if (element == EL_ACID && dx == 0 && dy == 1)
     {
       Blurb(jx, jy);
-      Feld[jx][jy] = EL_PLAYER;
+      Feld[jx][jy] = EL_PLAYER1;
       InitMovingField(jx, jy, MV_DOWN);
       Store[jx][jy] = EL_ACID;
       ContinueMoving(jx, jy);
@@ -5847,6 +5880,7 @@ int DigField(struct PlayerInfo *player,
     case EL_EMPTY:
     case EL_SAND:
     case EL_INVISIBLE_SAND:
+    case EL_INVISIBLE_SAND_ACTIVE:
     case EL_TRAP:
     case EL_SP_BASE:
     case EL_SP_BUGGY_BASE:
@@ -6504,7 +6538,8 @@ boolean PlaceBomb(struct PlayerInfo *player)
   }
   else
   {
-    Feld[jx][jy] = EL_DYNABOMB_ACTIVE_1 + (player->element_nr - EL_PLAYER1);
+    Feld[jx][jy] =
+      EL_DYNABOMB_PLAYER1_ACTIVE + (player->element_nr - EL_PLAYER1);
     MovDelay[jx][jy] = 96;
     player->dynabombs_left--;
     if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy)))