rnd-20070219-1-src
authorHolger Schemel <info@artsoft.org>
Mon, 19 Feb 2007 10:19:48 +0000 (11:19 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:54:28 +0000 (10:54 +0200)
src/conftime.h
src/editor.c
src/game.c
src/init.c
src/main.h
src/tools.c
src/tools.h

index 442791da3558f2bbe70a920c6a841bab021ca51a..2bd0057a42078017d6e1fb5d7c3eda86f8b66a37 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2007-02-17 17:39"
+#define COMPILE_DATE_STRING "2007-02-19 11:17"
index 3030dc091fbf1179425f40ca2edd8f18633804b1..2b4c4ff28cefd684ca554f0ff406ad00afc03da5 100644 (file)
@@ -8403,7 +8403,25 @@ static int getTubeFromDirectionNotEmpty(int direction, int element_old)
   return (element_new != EL_EMPTY ? element_new : element_old);
 }
 
-static int getMinimalConnectedTube(int x, int y)
+static int getOpenDirectionFromBelt(int element)
+{
+  int belt_dir = getBeltDirFromBeltElement(element);
+
+  return (belt_dir == MV_LEFT ? MV_RIGHT :
+         belt_dir == MV_RIGHT ? MV_LEFT :
+         belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
+}
+
+static int getBeltFromNrAndOpenDirection(int nr, int direction)
+{
+  int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
+                 direction == MV_RIGHT ? MV_LEFT :
+                 direction == MV_HORIZONTAL ? MV_NONE : direction);
+
+  return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
+}
+
+static int getClosedTube(int x, int y)
 {
   static int xy[4][2] =
   {
@@ -8433,6 +8451,35 @@ static int getMinimalConnectedTube(int x, int y)
   return getTubeFromDirectionNotEmpty(tube_direction_new, element_old);
 }
 
+static int getClosedBelt(int x, int y)
+{
+  static int xy[2][2] =
+  {
+    { -1, 0 },
+    { +1, 0 },
+  };
+  int element_old = IntelliDrawBuffer[x][y];
+  int belt_nr = getBeltNrFromBeltElement(element_old);
+  int belt_direction_old = getOpenDirectionFromBelt(element_old);
+  int belt_direction_new = MV_NONE;
+  int i;
+
+  for (i = 0; i < 2; i++)
+  {
+    int xx = x + xy[i][0];
+    int yy = y + xy[i][1];
+    int dir = MV_DIR_FROM_BIT(i);
+    int dir_opposite = MV_DIR_OPPOSITE(dir);
+
+    if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
+       (belt_direction_old & dir) &&
+       (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
+      belt_direction_new |= dir;
+  }
+
+  return getBeltFromNrAndOpenDirection(belt_nr, belt_direction_new);
+}
+
 static void SetElementSimple(int x, int y, int element, boolean change_level)
 {
   if (change_level)
@@ -8470,12 +8517,12 @@ static void SetElementIntelliDraw(int x, int y, int new_element,
     };
     boolean last_element_is_neighbour = FALSE;
     int last_element_new;
-    int tube_direction = MV_NONE;
+    int direction = MV_NONE;
     int i;
 
     /* if existing element is tube, keep all existing tube directions */
     if (IS_TUBE(old_element))
-      tube_direction |= getDirectionFromTube(old_element);
+      direction |= getDirectionFromTube(old_element);
 
     for (i = 0; i < NUM_DIRECTIONS; i++)
     {
@@ -8494,11 +8541,11 @@ static void SetElementIntelliDraw(int x, int y, int new_element,
        last_element_new = getTubeFromDirection(last_direction_new);
        last_element_is_neighbour = TRUE;
 
-       tube_direction |= dir;
+       direction |= dir;
       }
     }
 
-    new_element = getTubeFromDirectionNotEmpty(tube_direction, new_element);
+    new_element = getTubeFromDirectionNotEmpty(direction, new_element);
 
     /* reduce connections of neighbour tube elements to minimal connections */
     if (last_element_is_neighbour)
@@ -8508,14 +8555,235 @@ static void SetElementIntelliDraw(int x, int y, int new_element,
       SetElementSimple(last_x, last_y, last_element_new, change_level);
 
       /* remove all open tube connections of neighbour tube elements */
-      new_element = getMinimalConnectedTube(x, y);
-      last_element_new = getMinimalConnectedTube(last_x, last_y);
+      new_element = getClosedTube(x, y);
+      last_element_new = getClosedTube(last_x, last_y);
 
       /* set neighbour tube elements to new, minimized tube connections */
       SetElementSimple(x, y, new_element, change_level);
       SetElementSimple(last_x, last_y, last_element_new, change_level);
     }
   }
+  else if (IS_ACID_POOL(new_element))
+  {
+    int last_element_new = EL_UNDEFINED;
+
+    if (IS_ACID_POOL(old_element))
+    {
+      new_element = old_element;
+    }
+
+    if (last_x == x - 1 && last_y == y && IN_LEV_FIELD(last_x, last_y) &&
+       IS_ACID_POOL(IntelliDrawBuffer[last_x][last_y]))
+    {
+      if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_TOPLEFT)
+      {
+       new_element = EL_ACID_POOL_TOPRIGHT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_TOPRIGHT)
+      {
+       last_element_new = EL_ACID;
+       new_element = EL_ACID_POOL_TOPRIGHT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_BOTTOMLEFT)
+      {
+       new_element = EL_ACID_POOL_BOTTOMRIGHT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_BOTTOMRIGHT)
+      {
+       last_element_new = EL_ACID_POOL_BOTTOM;
+       new_element = EL_ACID_POOL_BOTTOMRIGHT;
+      }
+    }
+    else if (last_x == x + 1 && last_y == y && IN_LEV_FIELD(last_x, last_y) &&
+            IS_ACID_POOL(IntelliDrawBuffer[last_x][last_y]))
+    {
+      if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_TOPLEFT)
+      {
+       last_element_new = EL_ACID;
+       new_element = EL_ACID_POOL_TOPLEFT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_TOPRIGHT)
+      {
+       new_element = EL_ACID_POOL_TOPLEFT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_BOTTOMLEFT)
+      {
+       last_element_new = EL_ACID_POOL_BOTTOM;
+       new_element = EL_ACID_POOL_BOTTOMLEFT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_BOTTOMRIGHT)
+      {
+       new_element = EL_ACID_POOL_BOTTOMLEFT;
+      }
+    }
+    else if (last_x == x && last_y == y - 1 && IN_LEV_FIELD(last_x, last_y) &&
+            IS_ACID_POOL(IntelliDrawBuffer[last_x][last_y]))
+    {
+      if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_TOPLEFT)
+      {
+       new_element = EL_ACID_POOL_BOTTOMLEFT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_TOPRIGHT)
+      {
+       new_element = EL_ACID_POOL_BOTTOMRIGHT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_BOTTOMLEFT)
+      {
+       last_element_new = EL_ACID_POOL_TOPLEFT;
+       new_element = EL_ACID_POOL_BOTTOMLEFT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_BOTTOMRIGHT)
+      {
+       last_element_new = EL_ACID_POOL_TOPRIGHT;
+       new_element = EL_ACID_POOL_BOTTOMRIGHT;
+      }
+      else
+      {
+       last_element_new = EL_ACID;
+       new_element = EL_ACID_POOL_BOTTOM;
+      }
+    }
+    else if (last_x == x && last_y == y + 1 && IN_LEV_FIELD(last_x, last_y) &&
+            IS_ACID_POOL(IntelliDrawBuffer[last_x][last_y]))
+    {
+      if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_TOPLEFT)
+      {
+       new_element = EL_ACID_POOL_TOPLEFT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_TOPRIGHT)
+      {
+       new_element = EL_ACID_POOL_TOPRIGHT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_BOTTOMLEFT)
+      {
+       new_element = EL_ACID_POOL_TOPLEFT;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == EL_ACID_POOL_BOTTOMRIGHT)
+      {
+       new_element = EL_ACID_POOL_TOPRIGHT;
+      }
+      else
+      {
+       last_element_new = EL_ACID;
+       new_element = EL_ACID;
+      }
+    }
+
+    if (last_element_new != EL_UNDEFINED)
+      SetElementSimple(last_x, last_y, last_element_new, change_level);
+  }
+  else if (IS_BELT(new_element))
+  {
+    int last_element_new = EL_UNDEFINED;
+    int belt_nr = getBeltNrFromBeltElement(new_element);
+    int belt_left  = getBeltElementFromBeltNrAndBeltDir(belt_nr, MV_LEFT);
+    int belt_none  = getBeltElementFromBeltNrAndBeltDir(belt_nr, MV_NONE);
+    int belt_right = getBeltElementFromBeltNrAndBeltDir(belt_nr, MV_RIGHT);
+    boolean last_element_is_neighbour = FALSE;
+
+    if (IS_BELT(old_element))
+    {
+      new_element = old_element;
+    }
+
+    if (last_x == x - 1 && last_y == y && IN_LEV_FIELD(last_x, last_y) &&
+       IS_BELT(IntelliDrawBuffer[last_x][last_y]))
+    {
+      last_element_new = IntelliDrawBuffer[last_x][last_y];
+
+      if (IntelliDrawBuffer[last_x][last_y] == belt_left)
+      {
+       new_element = belt_right;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == belt_right)
+      {
+       last_element_new = belt_none;
+       new_element = belt_right;
+      }
+
+      last_element_is_neighbour = TRUE;
+    }
+    else if (last_x == x + 1 && last_y == y && IN_LEV_FIELD(last_x, last_y) &&
+            IS_BELT(IntelliDrawBuffer[last_x][last_y]))
+    {
+      last_element_new = IntelliDrawBuffer[last_x][last_y];
+
+      if (IntelliDrawBuffer[last_x][last_y] == belt_left)
+      {
+       last_element_new = belt_none;
+       new_element = belt_left;
+      }
+      else if (IntelliDrawBuffer[last_x][last_y] == belt_right)
+      {
+       new_element = belt_left;
+      }
+
+      last_element_is_neighbour = TRUE;
+    }
+
+    if (last_element_new != EL_UNDEFINED)
+      SetElementSimple(last_x, last_y, last_element_new, change_level);
+
+    /* reduce connections of neighbour belt elements to minimal connections */
+    if (last_element_is_neighbour)
+    {
+      /* set neighbour belt elements to newly determined belt connections */
+      SetElementSimple(x, y, new_element, change_level);
+      SetElementSimple(last_x, last_y, last_element_new, change_level);
+
+      /* remove all open belt connections of neighbour belt elements */
+      new_element = getClosedBelt(x, y);
+      last_element_new = getClosedBelt(last_x, last_y);
+
+      /* set neighbour belt elements to new, minimized belt connections */
+      SetElementSimple(x, y, new_element, change_level);
+      SetElementSimple(last_x, last_y, last_element_new, change_level);
+    }
+  }
+  else if (new_element == EL_EMC_WALL_1 ||
+          new_element == EL_EMC_WALL_2 ||
+          new_element == EL_EMC_WALL_3)
+  {
+    int last_element_new = EL_UNDEFINED;
+
+    if (last_x == x && last_y == y - 1 && IN_LEV_FIELD(last_x, last_y) &&
+       (IntelliDrawBuffer[last_x][last_y] == EL_EMC_WALL_1 ||
+        IntelliDrawBuffer[last_x][last_y] == EL_EMC_WALL_2 ||
+        IntelliDrawBuffer[last_x][last_y] == EL_EMC_WALL_3))
+    {
+      if (IN_LEV_FIELD(last_x, last_y - 1))
+      {
+       if (IntelliDrawBuffer[last_x][last_y - 1] != EL_EMC_WALL_1 &&
+           IntelliDrawBuffer[last_x][last_y - 1] != EL_EMC_WALL_2)
+         last_element_new = EL_EMC_WALL_1;
+       else if (IntelliDrawBuffer[last_x][last_y - 1] == EL_EMC_WALL_1 ||
+                IntelliDrawBuffer[last_x][last_y - 1] == EL_EMC_WALL_2)
+         last_element_new = EL_EMC_WALL_2;
+      }
+
+      new_element = EL_EMC_WALL_3;
+    }
+    else if (last_x == x && last_y == y + 1 && IN_LEV_FIELD(last_x, last_y) &&
+            (IntelliDrawBuffer[last_x][last_y] == EL_EMC_WALL_1 ||
+             IntelliDrawBuffer[last_x][last_y] == EL_EMC_WALL_2 ||
+             IntelliDrawBuffer[last_x][last_y] == EL_EMC_WALL_3))
+    {
+      if (IN_LEV_FIELD(last_x, last_y + 1))
+      {
+       if (IntelliDrawBuffer[last_x][last_y + 1] != EL_EMC_WALL_2 &&
+           IntelliDrawBuffer[last_x][last_y + 1] != EL_EMC_WALL_3)
+         last_element_new = EL_EMC_WALL_3;
+       else if (IntelliDrawBuffer[last_x][last_y + 1] == EL_EMC_WALL_2 ||
+                IntelliDrawBuffer[last_x][last_y + 1] == EL_EMC_WALL_3)
+         last_element_new = EL_EMC_WALL_2;
+      }
+
+      new_element = EL_EMC_WALL_1;
+    }
+
+    if (last_element_new != EL_UNDEFINED)
+      SetElementSimple(last_x, last_y, last_element_new, change_level);
+  }
 
   SetElementSimple(x, y, new_element, change_level);
 
index 13981e4272118059f4b4433d70024b97f9a677cf..e17ce2ddff7d823192da707d32ea568c83c9ca51 100644 (file)
@@ -940,57 +940,6 @@ void GetPlayerConfig()
   InitJoysticks();
 }
 
-static int getBeltNrFromBeltElement(int element)
-{
-  return (element < EL_CONVEYOR_BELT_2_LEFT ? 0 :
-         element < EL_CONVEYOR_BELT_3_LEFT ? 1 :
-         element < EL_CONVEYOR_BELT_4_LEFT ? 2 : 3);
-}
-
-static int getBeltNrFromBeltActiveElement(int element)
-{
-  return (element < EL_CONVEYOR_BELT_2_LEFT_ACTIVE ? 0 :
-         element < EL_CONVEYOR_BELT_3_LEFT_ACTIVE ? 1 :
-         element < EL_CONVEYOR_BELT_4_LEFT_ACTIVE ? 2 : 3);
-}
-
-static int getBeltNrFromBeltSwitchElement(int element)
-{
-  return (element < EL_CONVEYOR_BELT_2_SWITCH_LEFT ? 0 :
-         element < EL_CONVEYOR_BELT_3_SWITCH_LEFT ? 1 :
-         element < EL_CONVEYOR_BELT_4_SWITCH_LEFT ? 2 : 3);
-}
-
-static int getBeltDirNrFromBeltSwitchElement(int element)
-{
-  static int belt_base_element[4] =
-  {
-    EL_CONVEYOR_BELT_1_SWITCH_LEFT,
-    EL_CONVEYOR_BELT_2_SWITCH_LEFT,
-    EL_CONVEYOR_BELT_3_SWITCH_LEFT,
-    EL_CONVEYOR_BELT_4_SWITCH_LEFT
-  };
-
-  int belt_nr = getBeltNrFromBeltSwitchElement(element);
-  int belt_dir_nr = element - belt_base_element[belt_nr];
-
-  return (belt_dir_nr % 3);
-}
-
-static int getBeltDirFromBeltSwitchElement(int element)
-{
-  static int belt_move_dir[3] =
-  {
-    MV_LEFT,
-    MV_NONE,
-    MV_RIGHT
-  };
-
-  int belt_dir_nr = getBeltDirNrFromBeltSwitchElement(element);
-
-  return belt_move_dir[belt_dir_nr];
-}
-
 static int get_element_from_group_element(int element)
 {
   if (IS_GROUP_ELEMENT(element))
index ae1ada3a53b39b2488baf49d300e846436e7c24d..0521c3b7d5b3852e5d2ae4ade8c3589b7b6ea622 100644 (file)
@@ -3457,6 +3457,17 @@ void InitElementPropertiesStatic()
     -1
   };
 
+  static int ep_acid_pool[] =
+  {
+    EL_ACID_POOL_TOPLEFT,
+    EL_ACID_POOL_TOPRIGHT,
+    EL_ACID_POOL_BOTTOMLEFT,
+    EL_ACID_POOL_BOTTOM,
+    EL_ACID_POOL_BOTTOMRIGHT,
+
+    -1
+  };
+
   static int ep_keygate[] =
   {
     EL_GATE_1,
@@ -3926,6 +3937,7 @@ void InitElementPropertiesStatic()
     { ep_belt_active,                  EP_BELT_ACTIVE                  },
     { ep_belt_switch,                  EP_BELT_SWITCH                  },
     { ep_tube,                         EP_TUBE                         },
+    { ep_acid_pool,                    EP_ACID_POOL                    },
     { ep_keygate,                      EP_KEYGATE                      },
     { ep_amoeboid,                     EP_AMOEBOID                     },
     { ep_amoebalive,                   EP_AMOEBALIVE                   },
index ab14f1415fdf059969128d2351caa49fd86bc603..7a1e8bebc7b22c504a83732dfd2c742351cb506b 100644 (file)
 #define EP_BELT_ACTIVE                 47
 #define EP_BELT_SWITCH                 48
 #define EP_TUBE                                49
-#define EP_KEYGATE                     50
-#define EP_AMOEBOID                    51
-#define EP_AMOEBALIVE                  52
-#define EP_HAS_EDITOR_CONTENT          53
-#define EP_CAN_TURN_EACH_MOVE          54
-#define EP_CAN_GROW                    55
-#define EP_ACTIVE_BOMB                 56
-#define EP_INACTIVE                    57
+#define EP_ACID_POOL                   50
+#define EP_KEYGATE                     51
+#define EP_AMOEBOID                    52
+#define EP_AMOEBALIVE                  53
+#define EP_HAS_EDITOR_CONTENT          54
+#define EP_CAN_TURN_EACH_MOVE          55
+#define EP_CAN_GROW                    56
+#define EP_ACTIVE_BOMB                 57
+#define EP_INACTIVE                    58
 
 /* values for special configurable properties (depending on level settings) */
-#define EP_EM_SLIPPERY_WALL            58
+#define EP_EM_SLIPPERY_WALL            59
 
 /* values for special graphics properties (no effect on game engine) */
-#define EP_GFX_CRUMBLED                        59
+#define EP_GFX_CRUMBLED                        60
 
 /* values for derived properties (determined from properties above) */
-#define EP_ACCESSIBLE_OVER             60
-#define EP_ACCESSIBLE_INSIDE           61
-#define EP_ACCESSIBLE_UNDER            62
-#define EP_WALKABLE                    63
-#define EP_PASSABLE                    64
-#define EP_ACCESSIBLE                  65
-#define EP_COLLECTIBLE                 66
-#define EP_SNAPPABLE                   67
-#define EP_WALL                                68
-#define EP_SOLID_FOR_PUSHING           69
-#define EP_DRAGONFIRE_PROOF            70
-#define EP_EXPLOSION_PROOF             71
-#define EP_CAN_SMASH                   72
-#define EP_EXPLODES_3X3_OLD            73
-#define EP_CAN_EXPLODE_BY_FIRE         74
-#define EP_CAN_EXPLODE_SMASHED         75
-#define EP_CAN_EXPLODE_IMPACT          76
-#define EP_SP_PORT                     77
-#define EP_CAN_EXPLODE_BY_DRAGONFIRE   78
-#define EP_CAN_EXPLODE_BY_EXPLOSION    79
-#define EP_COULD_MOVE_INTO_ACID                80
-#define EP_MAYBE_DONT_COLLIDE_WITH     81
-#define EP_CAN_BE_CLONED_BY_ANDROID    82
+#define EP_ACCESSIBLE_OVER             61
+#define EP_ACCESSIBLE_INSIDE           62
+#define EP_ACCESSIBLE_UNDER            63
+#define EP_WALKABLE                    64
+#define EP_PASSABLE                    65
+#define EP_ACCESSIBLE                  66
+#define EP_COLLECTIBLE                 67
+#define EP_SNAPPABLE                   68
+#define EP_WALL                                69
+#define EP_SOLID_FOR_PUSHING           70
+#define EP_DRAGONFIRE_PROOF            71
+#define EP_EXPLOSION_PROOF             72
+#define EP_CAN_SMASH                   73
+#define EP_EXPLODES_3X3_OLD            74
+#define EP_CAN_EXPLODE_BY_FIRE         75
+#define EP_CAN_EXPLODE_SMASHED         76
+#define EP_CAN_EXPLODE_IMPACT          77
+#define EP_SP_PORT                     78
+#define EP_CAN_EXPLODE_BY_DRAGONFIRE   79
+#define EP_CAN_EXPLODE_BY_EXPLOSION    80
+#define EP_COULD_MOVE_INTO_ACID                81
+#define EP_MAYBE_DONT_COLLIDE_WITH     82
+#define EP_CAN_BE_CLONED_BY_ANDROID    83
 
 /* values for internal purpose only (level editor) */
-#define EP_WALK_TO_OBJECT              83
-#define EP_DEADLY                      84
-#define EP_EDITOR_CASCADE              85
-#define EP_EDITOR_CASCADE_ACTIVE       86
-#define EP_EDITOR_CASCADE_INACTIVE     87
+#define EP_WALK_TO_OBJECT              84
+#define EP_DEADLY                      85
+#define EP_EDITOR_CASCADE              86
+#define EP_EDITOR_CASCADE_ACTIVE       87
+#define EP_EDITOR_CASCADE_INACTIVE     88
 
 /* values for internal purpose only (game engine) */
-#define EP_HAS_ACTION                  88
-#define EP_CAN_CHANGE_OR_HAS_ACTION    89
+#define EP_HAS_ACTION                  89
+#define EP_CAN_CHANGE_OR_HAS_ACTION    90
 
 /* values for internal purpose only (other) */
-#define EP_OBSOLETE                    90
+#define EP_OBSOLETE                    91
 
-#define NUM_ELEMENT_PROPERTIES         91
+#define NUM_ELEMENT_PROPERTIES         92
 
 #define NUM_EP_BITFIELDS               ((NUM_ELEMENT_PROPERTIES + 31) / 32)
 #define EP_BITFIELD_BASE_NR            0
 #define IS_BELT_ACTIVE(e)      HAS_PROPERTY(e, EP_BELT_ACTIVE)
 #define IS_BELT_SWITCH(e)      HAS_PROPERTY(e, EP_BELT_SWITCH)
 #define IS_TUBE(e)             HAS_PROPERTY(e, EP_TUBE)
+#define IS_ACID_POOL(e)                HAS_PROPERTY(e, EP_ACID_POOL)
 #define IS_KEYGATE(e)          HAS_PROPERTY(e, EP_KEYGATE)
 #define IS_AMOEBOID(e)         HAS_PROPERTY(e, EP_AMOEBOID)
 #define IS_AMOEBALIVE(e)       HAS_PROPERTY(e, EP_AMOEBALIVE)
index 88c813441050f05ac9595b2a56261e3d586b1866..cf0457b68d0e26e937c3d69cd0a2b01f22982266 100644 (file)
@@ -5578,6 +5578,101 @@ int font2baseimg(int font_nr)
   return font_info[font_nr].special_graphic[GFX_SPECIAL_ARG_DEFAULT];
 }
 
+int getBeltNrFromBeltElement(int element)
+{
+  return (element < EL_CONVEYOR_BELT_2_LEFT ? 0 :
+         element < EL_CONVEYOR_BELT_3_LEFT ? 1 :
+         element < EL_CONVEYOR_BELT_4_LEFT ? 2 : 3);
+}
+
+int getBeltNrFromBeltActiveElement(int element)
+{
+  return (element < EL_CONVEYOR_BELT_2_LEFT_ACTIVE ? 0 :
+         element < EL_CONVEYOR_BELT_3_LEFT_ACTIVE ? 1 :
+         element < EL_CONVEYOR_BELT_4_LEFT_ACTIVE ? 2 : 3);
+}
+
+int getBeltNrFromBeltSwitchElement(int element)
+{
+  return (element < EL_CONVEYOR_BELT_2_SWITCH_LEFT ? 0 :
+         element < EL_CONVEYOR_BELT_3_SWITCH_LEFT ? 1 :
+         element < EL_CONVEYOR_BELT_4_SWITCH_LEFT ? 2 : 3);
+}
+
+int getBeltDirNrFromBeltElement(int element)
+{
+  static int belt_base_element[4] =
+  {
+    EL_CONVEYOR_BELT_1_LEFT,
+    EL_CONVEYOR_BELT_2_LEFT,
+    EL_CONVEYOR_BELT_3_LEFT,
+    EL_CONVEYOR_BELT_4_LEFT
+  };
+
+  int belt_nr = getBeltNrFromBeltElement(element);
+  int belt_dir_nr = element - belt_base_element[belt_nr];
+
+  return (belt_dir_nr % 3);
+}
+
+int getBeltDirNrFromBeltSwitchElement(int element)
+{
+  static int belt_base_element[4] =
+  {
+    EL_CONVEYOR_BELT_1_SWITCH_LEFT,
+    EL_CONVEYOR_BELT_2_SWITCH_LEFT,
+    EL_CONVEYOR_BELT_3_SWITCH_LEFT,
+    EL_CONVEYOR_BELT_4_SWITCH_LEFT
+  };
+
+  int belt_nr = getBeltNrFromBeltSwitchElement(element);
+  int belt_dir_nr = element - belt_base_element[belt_nr];
+
+  return (belt_dir_nr % 3);
+}
+
+int getBeltDirFromBeltElement(int element)
+{
+  static int belt_move_dir[3] =
+  {
+    MV_LEFT,
+    MV_NONE,
+    MV_RIGHT
+  };
+
+  int belt_dir_nr = getBeltDirNrFromBeltElement(element);
+
+  return belt_move_dir[belt_dir_nr];
+}
+
+int getBeltDirFromBeltSwitchElement(int element)
+{
+  static int belt_move_dir[3] =
+  {
+    MV_LEFT,
+    MV_NONE,
+    MV_RIGHT
+  };
+
+  int belt_dir_nr = getBeltDirNrFromBeltSwitchElement(element);
+
+  return belt_move_dir[belt_dir_nr];
+}
+
+int getBeltElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir)
+{
+  static int belt_base_element[4] =
+  {
+    EL_CONVEYOR_BELT_1_LEFT,
+    EL_CONVEYOR_BELT_2_LEFT,
+    EL_CONVEYOR_BELT_3_LEFT,
+    EL_CONVEYOR_BELT_4_LEFT
+  };
+  int belt_dir_nr = (belt_dir == MV_LEFT ? 0 : belt_dir == MV_RIGHT ? 2 : 1);
+
+  return belt_base_element[belt_nr] + belt_dir_nr;
+}
+
 int getNumActivePlayers_EM()
 {
   int num_players = 0;
index 8c839520a4d95f9a454e5a1e799dc95f1c40d53f..2949115c55f26fa0762d4910851e24410510a71f 100644 (file)
@@ -176,6 +176,15 @@ int el2edimg(int);
 int el2preimg(int);
 int font2baseimg(int);
 
+int getBeltNrFromBeltElement(int);
+int getBeltNrFromBeltActiveElement(int);
+int getBeltNrFromBeltSwitchElement(int);
+int getBeltDirNrFromBeltElement(int);
+int getBeltDirNrFromBeltSwitchElement(int);
+int getBeltDirFromBeltElement(int);
+int getBeltDirFromBeltSwitchElement(int);
+int getBeltElementFromBeltNrAndBeltDir(int, int);
+
 unsigned int InitRND(long);
 void InitGraphicInfo_EM(void);