rnd-20040113-1-src
authorHolger Schemel <info@artsoft.org>
Tue, 13 Jan 2004 00:53:21 +0000 (01:53 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:45:22 +0000 (10:45 +0200)
src/conftime.h
src/editor.c
src/files.c
src/game.c
src/main.h

index 39817f16d56a70bce4f53d0b4e84932474bdf4c7..b32703b1801cb02dac03b5dc979789abc351ba65 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2004-01-12 23:04]"
+#define COMPILE_DATE_STRING "[2004-01-13 01:44]"
index c15014899d9ff269ee308e2a57caaac54939014e..07401c10e352f2342d60942f4ef2c920ae2abe42 100644 (file)
                                         ED_GADGET_DISTANCE)
 /* custom element content */
 #define ED_AREA_ELEM_CONTENT4_XPOS     (29 * MINI_TILEX)
-#define ED_AREA_ELEM_CONTENT4_YPOS     (ED_SETTINGS_YPOS(12) + \
+#define ED_AREA_ELEM_CONTENT4_YPOS     (ED_SETTINGS_YPOS(13) + \
                                         ED_GADGET_DISTANCE - MINI_TILEY)
+/* movement enter/leave element */
+#define ED_AREA_ELEM_CONTENT4a_XPOS    (29 * MINI_TILEX)
+#define ED_AREA_ELEM_CONTENT4a_YPOS    (ED_SETTINGS_YPOS(7) + \
+                                        ED_GADGET_DISTANCE)
+#define ED_AREA_ELEM_CONTENT4b_XPOS    (29 * MINI_TILEX)
+#define ED_AREA_ELEM_CONTENT4b_YPOS    (ED_SETTINGS_YPOS(7) + \
+                                        ED_GADGET_DISTANCE)
 /* custom change trigger element */
 #define ED_AREA_ELEM_CONTENT5_YPOS     (ED_SETTINGS_YPOS(6) + \
                                         ED_GADGET_DISTANCE)
 #define GADGET_ID_AMOEBA_CONTENT       (GADGET_ID_DRAWING_AREA_FIRST + 9)
 #define GADGET_ID_CUSTOM_GRAPHIC       (GADGET_ID_DRAWING_AREA_FIRST + 10)
 #define GADGET_ID_CUSTOM_CONTENT       (GADGET_ID_DRAWING_AREA_FIRST + 11)
-#define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 12)
-#define GADGET_ID_CUSTOM_CHANGE_CONTENT        (GADGET_ID_DRAWING_AREA_FIRST + 13)
-#define GADGET_ID_CUSTOM_CHANGE_TRIGGER        (GADGET_ID_DRAWING_AREA_FIRST + 14)
-#define GADGET_ID_GROUP_CONTENT                (GADGET_ID_DRAWING_AREA_FIRST + 15)
-#define GADGET_ID_RANDOM_BACKGROUND    (GADGET_ID_DRAWING_AREA_FIRST + 16)
+#define GADGET_ID_CUSTOM_MOVE_ENTER    (GADGET_ID_DRAWING_AREA_FIRST + 12)
+#define GADGET_ID_CUSTOM_MOVE_LEAVE    (GADGET_ID_DRAWING_AREA_FIRST + 13)
+#define GADGET_ID_CUSTOM_CHANGE_TARGET (GADGET_ID_DRAWING_AREA_FIRST + 14)
+#define GADGET_ID_CUSTOM_CHANGE_CONTENT        (GADGET_ID_DRAWING_AREA_FIRST + 15)
+#define GADGET_ID_CUSTOM_CHANGE_TRIGGER        (GADGET_ID_DRAWING_AREA_FIRST + 16)
+#define GADGET_ID_GROUP_CONTENT                (GADGET_ID_DRAWING_AREA_FIRST + 17)
+#define GADGET_ID_RANDOM_BACKGROUND    (GADGET_ID_DRAWING_AREA_FIRST + 18)
 
 /* text input identifiers */
-#define GADGET_ID_TEXT_INPUT_FIRST     (GADGET_ID_DRAWING_AREA_FIRST + 17)
+#define GADGET_ID_TEXT_INPUT_FIRST     (GADGET_ID_DRAWING_AREA_FIRST + 19)
 
 #define GADGET_ID_LEVEL_NAME           (GADGET_ID_TEXT_INPUT_FIRST + 0)
 #define GADGET_ID_LEVEL_AUTHOR         (GADGET_ID_TEXT_INPUT_FIRST + 1)
 #define ED_DRAWING_ID_AMOEBA_CONTENT           9
 #define ED_DRAWING_ID_CUSTOM_GRAPHIC           10
 #define ED_DRAWING_ID_CUSTOM_CONTENT           11
-#define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET     12
-#define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT    13
-#define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER    14
-#define ED_DRAWING_ID_GROUP_CONTENT            15
-#define ED_DRAWING_ID_RANDOM_BACKGROUND                16
+#define ED_DRAWING_ID_CUSTOM_MOVE_ENTER                12
+#define ED_DRAWING_ID_CUSTOM_MOVE_LEAVE                13
+#define ED_DRAWING_ID_CUSTOM_CHANGE_TARGET     14
+#define ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT    15
+#define ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER    16
+#define ED_DRAWING_ID_GROUP_CONTENT            17
+#define ED_DRAWING_ID_RANDOM_BACKGROUND                18
 
-#define ED_NUM_DRAWING_AREAS                   17
+#define ED_NUM_DRAWING_AREAS                   19
 
 
 /*
@@ -947,7 +958,7 @@ static struct
     NULL,                              "+random", NULL
   },
   {
-    ED_SETTINGS_XPOS(1),               ED_SETTINGS_YPOS(7),
+    ED_SETTINGS_XPOS(1),               ED_SETTINGS_YPOS(9),
     0,                                 999,
     GADGET_ID_MOVE_DELAY_FIX_DOWN,     GADGET_ID_MOVE_DELAY_FIX_UP,
     GADGET_ID_MOVE_DELAY_FIX_TEXT,     GADGET_ID_NONE,
@@ -955,7 +966,7 @@ static struct
     NULL,                              "move delay", NULL
   },
   {
-    -1,                                        ED_SETTINGS_YPOS(7),
+    -1,                                        ED_SETTINGS_YPOS(9),
     0,                                 999,
     GADGET_ID_MOVE_DELAY_RND_DOWN,     GADGET_ID_MOVE_DELAY_RND_UP,
     GADGET_ID_MOVE_DELAY_RND_TEXT,     GADGET_ID_MOVE_DELAY_FIX_UP,
@@ -1296,7 +1307,7 @@ static struct
     "move/fall speed", NULL,           "speed of element movement"
   },
   {
-    -1,                                        ED_SETTINGS_YPOS(9),
+    -1,                                        ED_SETTINGS_YPOS(10),
     GADGET_ID_CUSTOM_SMASH_TARGETS,    GADGET_ID_CUSTOM_CAN_SMASH,
     -1,
     options_smash_targets,
@@ -1304,7 +1315,7 @@ static struct
     "can smash", NULL,                 "elements that can be smashed"
   },
   {
-    ED_SETTINGS_XPOS(1),               ED_SETTINGS_YPOS(10),
+    ED_SETTINGS_XPOS(1),               ED_SETTINGS_YPOS(11),
     GADGET_ID_CUSTOM_SLIPPERY_TYPE,    GADGET_ID_NONE,
     -1,
     options_slippery_type,
@@ -1312,7 +1323,7 @@ static struct
     "slippery", NULL,                  "where other elements fall down"
   },
   {
-    ED_SETTINGS_XPOS(1),               ED_SETTINGS_YPOS(11),
+    ED_SETTINGS_XPOS(1),               ED_SETTINGS_YPOS(12),
     GADGET_ID_CUSTOM_DEADLINESS,       GADGET_ID_NONE,
     -1,
     options_deadliness,
@@ -1320,7 +1331,7 @@ static struct
     "deadly when", NULL,               "deadliness of element"
   },
   {
-    ED_SETTINGS_XPOS(1),               ED_SETTINGS_YPOS(12),
+    ED_SETTINGS_XPOS(1),               ED_SETTINGS_YPOS(13),
     GADGET_ID_CUSTOM_CONSISTENCY,      GADGET_ID_NONE,
     -1,
     options_consistency,
@@ -1632,49 +1643,49 @@ static struct
     NULL, NULL,                                "element can move in some direction"
   },
   {
-    ED_SETTINGS_XPOS(0),               ED_SETTINGS_YPOS(9),
+    ED_SETTINGS_XPOS(0),               ED_SETTINGS_YPOS(10),
     GADGET_ID_CUSTOM_CAN_FALL,         GADGET_ID_NONE,
     &custom_element_properties[EP_CAN_FALL],
     NULL, "can fall",                  "element can fall down"
   },
   {
-    -1,                                        ED_SETTINGS_YPOS(9),
+    -1,                                        ED_SETTINGS_YPOS(10),
     GADGET_ID_CUSTOM_CAN_SMASH,                GADGET_ID_CUSTOM_CAN_FALL,
     &custom_element_properties[EP_CAN_SMASH],
     " ", NULL,                         "element can smash other elements"
   },
   {
-    ED_SETTINGS_XPOS(0),               ED_SETTINGS_YPOS(10),
+    ED_SETTINGS_XPOS(0),               ED_SETTINGS_YPOS(11),
     GADGET_ID_CUSTOM_SLIPPERY,         GADGET_ID_NONE,
     &custom_element_properties[EP_SLIPPERY],
     NULL, NULL,                                "other elements can fall down from it"
   },
   {
-    ED_SETTINGS_XPOS(0),               ED_SETTINGS_YPOS(11),
+    ED_SETTINGS_XPOS(0),               ED_SETTINGS_YPOS(12),
     GADGET_ID_CUSTOM_DEADLY,           GADGET_ID_NONE,
     &custom_element_properties[EP_DEADLY],
     NULL, NULL,                                "element can kill the player"
   },
   {
-    ED_SETTINGS_XPOS(0),               ED_SETTINGS_YPOS(12),
+    ED_SETTINGS_XPOS(0),               ED_SETTINGS_YPOS(13),
     GADGET_ID_CUSTOM_EXPLODE_RESULT,   GADGET_ID_NONE,
     &custom_element_properties[EP_EXPLODE_RESULT],
     NULL, NULL,                                "set consistency/destructibility"
   },
   {
-    ED_SETTINGS_XPOS(1),               ED_SETTINGS_YPOS(13),
+    ED_SETTINGS_XPOS(1),               ED_SETTINGS_YPOS(14),
     GADGET_ID_CUSTOM_EXPLODE_FIRE,     GADGET_ID_NONE,
     &custom_element.can_explode_by_fire,
     NULL, "by fire",                   "element can explode by fire/explosion"
   },
   {
-    -1,                                        ED_SETTINGS_YPOS(13),
+    -1,                                        ED_SETTINGS_YPOS(14),
     GADGET_ID_CUSTOM_EXPLODE_SMASH,    GADGET_ID_CUSTOM_EXPLODE_FIRE,
     &custom_element.can_explode_smashed,
     " ", "smashed",                    "element can explode when smashed"
   },
   {
-    -1,                                        ED_SETTINGS_YPOS(13),
+    -1,                                        ED_SETTINGS_YPOS(14),
     GADGET_ID_CUSTOM_EXPLODE_IMPACT,   GADGET_ID_CUSTOM_EXPLODE_SMASH,
     &custom_element.can_explode_impact,
     " ", "impact",                     "element can explode on impact"
@@ -1840,6 +1851,22 @@ static struct
     "content:", NULL,                  NULL
   },
 
+  /* ---------- custom enter and leave element (when moving) --------------- */
+
+  {
+    ED_SETTINGS_XPOS(1),               ED_AREA_ELEM_CONTENT4a_YPOS,
+    1, 1,
+    GADGET_ID_CUSTOM_MOVE_ENTER,       GADGET_ID_NONE,
+    "can dig:", " ",                   NULL
+  },
+
+  {
+    -1,                                        ED_AREA_ELEM_CONTENT4b_YPOS,
+    1, 1,
+    GADGET_ID_CUSTOM_MOVE_LEAVE,       GADGET_ID_CUSTOM_MOVE_ENTER,
+    "can leave behind:", NULL,         NULL
+  },
+
   /* ---------- custom change target --------------------------------------- */
 
   {
@@ -3381,6 +3408,12 @@ static void DrawDrawingArea(int id)
        DrawMiniGraphicExt(drawto,
                           gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
                           el2edimg(custom_element.content[x][y]));
+  else if (id == ED_DRAWING_ID_CUSTOM_MOVE_ENTER)
+    DrawMiniGraphicExt(drawto, gi->x, gi->y,
+                      el2edimg(custom_element.move_enter_element));
+  else if (id == ED_DRAWING_ID_CUSTOM_MOVE_LEAVE)
+    DrawMiniGraphicExt(drawto, gi->x, gi->y,
+                      el2edimg(custom_element.move_leave_element));
   else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_TARGET)
     DrawMiniGraphicExt(drawto, gi->x, gi->y,
                       el2edimg(custom_element_change.target_element));
@@ -6218,6 +6251,8 @@ static void DrawPropertiesConfig()
 
     /* draw drawing area gadgets */
     DrawCustomContentArea();
+    MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
+    MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
 
     /* draw text input gadgets */
     MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
@@ -7161,6 +7196,18 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
 
          CopyCustomElementPropertiesToGame(properties_element);
        }
+       else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
+       {
+         custom_element.move_enter_element = new_element;
+
+         CopyCustomElementPropertiesToGame(properties_element);
+       }
+       else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
+       {
+         custom_element.move_leave_element = new_element;
+
+         CopyCustomElementPropertiesToGame(properties_element);
+       }
        else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
        {
          custom_element_change.target_element = new_element;
@@ -7295,6 +7342,10 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
        PickDrawingElement(button, custom_element.gfx_element);
       else if (id == GADGET_ID_CUSTOM_CONTENT)
        PickDrawingElement(button, custom_element.content[sx][sy]);
+      else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
+       PickDrawingElement(button, custom_element.move_enter_element);
+      else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
+       PickDrawingElement(button, custom_element.move_leave_element);
       else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
        PickDrawingElement(button, custom_element_change.target_element);
       else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
@@ -8218,6 +8269,10 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
       text = getElementInfoText(custom_element.gfx_element);
     else if (id == GADGET_ID_CUSTOM_CONTENT)
       text = getElementInfoText(custom_element.content[sx][sy]);
+    else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
+      text = getElementInfoText(custom_element.move_enter_element);
+    else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
+      text = getElementInfoText(custom_element.move_leave_element);
     else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
       text = getElementInfoText(custom_element_change.target_element);
     else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
@@ -8247,6 +8302,10 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
       strcpy(infotext, "Custom graphic element");
     else if (id == GADGET_ID_CUSTOM_CONTENT)
       sprintf(infotext, "Custom element content position: %d, %d", sx, sy);
+    else if (id == GADGET_ID_CUSTOM_MOVE_ENTER)
+      strcpy(infotext, "Element that can be digged");
+    else if (id == GADGET_ID_CUSTOM_MOVE_LEAVE)
+      strcpy(infotext, "Element that can be left behind");
     else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
       strcpy(infotext, "New element after change");
     else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
index 214c50af2ccfde08b83c316295d5876cb831af46..2f8ca7c166c3ff7ee57b65317efc0642ecb7dcf2 100644 (file)
@@ -212,6 +212,8 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
       element_info[element].move_pattern = MV_ALL_DIRECTIONS;
       element_info[element].move_direction_initial = MV_NO_MOVING;
       element_info[element].move_stepsize = TILEX / 8;
+      element_info[element].move_enter_element = EL_EMPTY_SPACE;
+      element_info[element].move_leave_element = EL_EMPTY_SPACE;
 
       element_info[element].slippery_type = SLIPPERY_ANY_RANDOM;
 
@@ -870,8 +872,11 @@ static int LoadLevel_CUS4(FILE *file, int chunk_size, struct LevelInfo *level)
     for (x = 0; x < 3; x++)
       ei->content[x][y] = checkLevelElement(getFile16BitBE(file));
 
+  ei->move_enter_element = checkLevelElement(getFile16BitBE(file));
+  ei->move_leave_element = checkLevelElement(getFile16BitBE(file));
+
   /* some free bytes for future custom property values and padding */
-  ReadUnusedBytesFromFile(file, 12);
+  ReadUnusedBytesFromFile(file, 8);
 
   /* read change property values */
 
@@ -2034,8 +2039,11 @@ static void SaveLevel_CUS4(FILE *file, struct LevelInfo *level, int element)
     for (x = 0; x < 3; x++)
       putFile16BitBE(file, ei->content[x][y]);
 
+  putFile16BitBE(file, ei->move_enter_element);
+  putFile16BitBE(file, ei->move_leave_element);
+
   /* some free bytes for future custom property values and padding */
-  WriteUnusedBytesToFile(file, 12);
+  WriteUnusedBytesToFile(file, 8);
 
   /* write change property values */
 
index f29584b4be06e36a1a0807689abb5dc35555826b..1f3b8e02fb64939b490c64c05318e8f3220ce748 100644 (file)
@@ -763,6 +763,15 @@ static void InitField(int x, int y, boolean init_game)
     default:
       if (IS_CUSTOM_ELEMENT(element) && CAN_MOVE(element))
        InitMovDir(x, y);
+      else if (IS_GROUP_ELEMENT(element))
+      {
+       struct ElementGroupInfo *group = element_info[element].group;
+       int random_pos = RND(group->num_elements_resolved);
+
+       Feld[x][y] = group->element_resolved[random_pos];
+
+       InitField(x, y, init_game);
+      }
       break;
   }
 }
@@ -787,10 +796,9 @@ void DrawGameDoorValues()
           int2str(TimeLeft, 3), FONT_TEXT_2);
 }
 
-#if 1
-
 static void resolve_group_element(int group_element, int recursion_depth)
 {
+  static int group_nr;
   static struct ElementGroupInfo *group;
   struct ElementGroupInfo *actual_group = element_info[group_element].group;
   int i;
@@ -810,6 +818,7 @@ static void resolve_group_element(int group_element, int recursion_depth)
   {
     group = element_info[group_element].group;
     group->num_elements_resolved = 0;
+    group_nr = group_element - EL_GROUP_START;
   }
 
   for (i = 0; i < actual_group->num_elements; i++)
@@ -822,10 +831,13 @@ static void resolve_group_element(int group_element, int recursion_depth)
     if (IS_GROUP_ELEMENT(element))
       resolve_group_element(element, recursion_depth + 1);
     else
+    {
       group->element_resolved[group->num_elements_resolved++] = element;
+      element_info[element].in_group[group_nr] = TRUE;
+    }
   }
 
-#if 1
+#if 0
   if (recursion_depth == 0 && group_element <= EL_GROUP_4)
   {
     printf("::: group %d: %d resolved elements\n",
@@ -837,58 +849,6 @@ static void resolve_group_element(int group_element, int recursion_depth)
 #endif
 }
 
-#else
-
-static void resolve_group_element(int group_element, int recursion_depth)
-{
-  static short element_list_count[NUM_FILE_ELEMENTS];
-  struct ElementGroupInfo *group = element_info[group_element].group;
-  int i, j;
-
-  if (group == NULL)
-    return;
-
-  if (recursion_depth > NUM_GROUP_ELEMENTS)    /* recursion too deep */
-    return;
-
-  if (recursion_depth == 0)                    /* initialization */
-    for (i = 0; i < NUM_FILE_ELEMENTS; i++)
-      element_list_count[i] = 0;
-
-  for (i = 0; i < group->num_elements; i++)
-  {
-    int element = group->element[i];
-
-    if (IS_GROUP_ELEMENT(element))
-      resolve_group_element(element, recursion_depth + 1);
-    else if (element < NUM_FILE_ELEMENTS)
-      element_list_count[group->element[i]]++;
-  }
-
-  if (recursion_depth == 0)                    /* finalization */
-  {
-    group->num_elements_resolved = 0;
-
-    for (i = 0; i < NUM_FILE_ELEMENTS; i++)
-      for (j = 0; j < element_list_count[i]; j++)
-       if (group->num_elements_resolved < NUM_FILE_ELEMENTS)
-         group->element_resolved[group->num_elements_resolved++] = i;
-
-#if 1
-    if (group_element <= EL_GROUP_8)
-    {
-      printf("::: group %d: %d resolved elements\n",
-            group_element - EL_GROUP_START, group->num_elements_resolved);
-      for (i = 0; i < group->num_elements_resolved; i++)
-       printf("::: - %d ['%s']\n", group->element_resolved[i],
-              element_info[group->element_resolved[i]].token_name);
-    }
-#endif
-  }
-}
-
-#endif
-
 
 /*
   =============================================================================
@@ -919,6 +879,10 @@ static void InitGameEngine()
 
   /* ---------- recursively resolve group elements ------------------------- */
 
+  for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+    for (j = 0; j < NUM_GROUP_ELEMENTS; j++)
+      element_info[i].in_group[j] = FALSE;
+
   for (i = 0; i < NUM_GROUP_ELEMENTS; i++)
     resolve_group_element(EL_GROUP_START + i, 0);
 
index 387c69b4b63982e08ead3999523af0b78045ee11..4dee3226237e971b65afff0a85b2a9940e8a1cd5 100644 (file)
@@ -1513,6 +1513,8 @@ struct ElementInfo
   int move_pattern;            /* direction movable element moves to */
   int move_direction_initial;  /* initial direction element moves to */
   int move_stepsize;           /* step size element moves with */
+  int move_enter_element;      /* element that can be entered (and removed) */
+  int move_leave_element;      /* element that can be left behind */
 
   int slippery_type;           /* how/where other elements slip away */
 
@@ -1533,6 +1535,8 @@ struct ElementInfo
   int event_page_nr[NUM_CHANGE_EVENTS]; /* page number for each event */
   struct ElementChangeInfo *event_page[NUM_CHANGE_EVENTS]; /* page for event */
 
+  boolean in_group[NUM_GROUP_ELEMENTS];
+
   /* ---------- internal values used in level editor ---------- */
 
   int access_type;             /* walkable or passable */