added removing existing McDuffin when drawing new one in level editor
authorHolger Schemel <info@artsoft.org>
Fri, 31 Mar 2023 14:04:48 +0000 (16:04 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 31 Mar 2023 14:04:48 +0000 (16:04 +0200)
src/editor.c

index 52df4dfacefce6feeb3f311cf2cb39f4ac3f60ec..21cee41c214c29dd28865f24a8ce8b9bd6bd3221 100644 (file)
@@ -13227,7 +13227,7 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
        {
          SetDrawModeHiRes(new_element);
 
-         if (IS_PLAYER_ELEMENT(new_element))
+         if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
          {
            // remove player at old position
            for (y = 0; y < lev_fieldy; y++)
@@ -13236,7 +13236,8 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
              {
                int old_element = Tile[x][y];
 
-               if (IS_PLAYER_ELEMENT(old_element))
+               if (IS_PLAYER_ELEMENT(old_element) &&
+                   IS_PLAYER_ELEMENT(new_element))
                {
                  int replaced_with_element =
                    (old_element == EL_SOKOBAN_FIELD_PLAYER &&
@@ -13256,6 +13257,12 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
 
                  SetElement(x, y, replaced_with_element);
                }
+               else if (IS_MM_MCDUFFIN(old_element) &&
+                        IS_MM_MCDUFFIN(new_element))
+               {
+                 // remove McDuffin at old position
+                 SetElement(x, y, EL_EMPTY);
+               }
              }
            }
          }