rnd-20140224-1-src
authorHolger Schemel <info@artsoft.org>
Mon, 24 Feb 2014 16:50:31 +0000 (17:50 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 09:00:57 +0000 (11:00 +0200)
src/conf_gfx.c
src/conf_gfx.h
src/conf_var.c
src/conftime.h
src/events.c
src/init.c
src/libgame/system.h
src/main.h
src/tools.c
src/tools.h

index 12da9382a181511194f545b340208d962905bbce..b0065b9e7f2848ee0f66b0535334b4ccc4918652 100644 (file)
@@ -5324,6 +5324,72 @@ struct ConfigInfo image_config[] =
   { "titlescreen_4",                           UNDEFINED_FILENAME      },
   { "titlescreen_5",                           UNDEFINED_FILENAME      },
 
+  { "door_1.gfx.part_1",                       "RocksDoor.png"         },
+  { "door_1.gfx.part_1.x",                     "0"                     },
+  { "door_1.gfx.part_1.y",                     "0"                     },
+  { "door_1.gfx.part_1.width",                 "100"                   },
+  { "door_1.gfx.part_1.height",                        "77"                    },
+  { "door_1.gfx.part_2",                       "RocksDoor.png"         },
+  { "door_1.gfx.part_2.x",                     "0"                     },
+  { "door_1.gfx.part_2.y",                     "77"                    },
+  { "door_1.gfx.part_2.width",                 "100"                   },
+  { "door_1.gfx.part_2.height",                        "63"                    },
+  { "door_1.gfx.part_3",                       "RocksDoor.png"         },
+  { "door_1.gfx.part_3.x",                     "0"                     },
+  { "door_1.gfx.part_3.y",                     "140"                   },
+  { "door_1.gfx.part_3.width",                 "100"                   },
+  { "door_1.gfx.part_3.height",                        "63"                    },
+  { "door_1.gfx.part_4",                       "RocksDoor.png"         },
+  { "door_1.gfx.part_4.x",                     "0"                     },
+  { "door_1.gfx.part_4.y",                     "203"                   },
+  { "door_1.gfx.part_4.width",                 "100"                   },
+  { "door_1.gfx.part_4.height",                        "77"                    },
+  { "door_1.gfx.part_5",                       "RocksDoor.png"         },
+  { "door_1.gfx.part_5.x",                     "100"                   },
+  { "door_1.gfx.part_5.y",                     "0"                     },
+  { "door_1.gfx.part_5.width",                 "100"                   },
+  { "door_1.gfx.part_5.height",                        "77"                    },
+  { "door_1.gfx.part_6",                       "RocksDoor.png"         },
+  { "door_1.gfx.part_6.x",                     "100"                   },
+  { "door_1.gfx.part_6.y",                     "77"                    },
+  { "door_1.gfx.part_6.width",                 "100"                   },
+  { "door_1.gfx.part_6.height",                        "63"                    },
+  { "door_1.gfx.part_7",                       "RocksDoor.png"         },
+  { "door_1.gfx.part_7.x",                     "100"                   },
+  { "door_1.gfx.part_7.y",                     "140"                   },
+  { "door_1.gfx.part_7.width",                 "100"                   },
+  { "door_1.gfx.part_7.height",                        "63"                    },
+  { "door_1.gfx.part_8",                       "RocksDoor.png"         },
+  { "door_1.gfx.part_8.x",                     "100"                   },
+  { "door_1.gfx.part_8.y",                     "203"                   },
+  { "door_1.gfx.part_8.width",                 "100"                   },
+  { "door_1.gfx.part_8.height",                        "77"                    },
+
+  { "door_2.gfx.part_1",                       "RocksDoor.png"         },
+  { "door_2.gfx.part_1.x",                     "0"                     },
+  { "door_2.gfx.part_1.y",                     "280"                   },
+  { "door_2.gfx.part_1.width",                 "100"                   },
+  { "door_2.gfx.part_1.height",                        "50"                    },
+  { "door_2.gfx.part_2",                       "RocksDoor.png"         },
+  { "door_2.gfx.part_2.x",                     "0"                     },
+  { "door_2.gfx.part_2.y",                     "330"                   },
+  { "door_2.gfx.part_2.width",                 "100"                   },
+  { "door_2.gfx.part_2.height",                        "50"                    },
+  { "door_2.gfx.part_3",                       "RocksDoor.png"         },
+  { "door_2.gfx.part_3.x",                     "100"                   },
+  { "door_2.gfx.part_3.y",                     "280"                   },
+  { "door_2.gfx.part_3.width",                 "100"                   },
+  { "door_2.gfx.part_3.height",                        "50"                    },
+  { "door_2.gfx.part_4",                       "RocksDoor.png"         },
+  { "door_2.gfx.part_4.x",                     "100"                   },
+  { "door_2.gfx.part_4.y",                     "330"                   },
+  { "door_2.gfx.part_4.width",                 "100"                   },
+  { "door_2.gfx.part_4.height",                        "50"                    },
+  { "door_2.gfx.part_5",                       UNDEFINED_FILENAME      },
+  { "door_2.gfx.part_6",                       UNDEFINED_FILENAME      },
+  { "door_2.gfx.part_7",                       UNDEFINED_FILENAME      },
+  { "door_2.gfx.part_8",                       UNDEFINED_FILENAME      },
+
   { "door_1.wing_left",                                "RocksDoor.png"         },
   { "door_1.wing_left.x",                      "0"                     },
   { "door_1.wing_left.y",                      "0"                     },
@@ -5902,6 +5968,72 @@ struct ConfigInfo image_config[] =
   { "preview.step_delay",                      "50"                    },
   { "preview.anim_mode",                       "default"               },
 
+  { "door_1.part_1.x",                         "0"                     },
+  { "door_1.part_1.y",                         "0"                     },
+  { "door_1.part_1.draw_masked",               "true"                  },
+  { "door_1.part_1.draw_order",                        "3"                     },
+  { "door_1.part_2.x",                         "0"                     },
+  { "door_1.part_2.y",                         "77"                    },
+  { "door_1.part_2.draw_masked",               "true"                  },
+  { "door_1.part_2.draw_order",                        "5"                     },
+  { "door_1.part_3.x",                         "0"                     },
+  { "door_1.part_3.y",                         "140"                   },
+  { "door_1.part_3.draw_masked",               "true"                  },
+  { "door_1.part_3.draw_order",                        "4"                     },
+  { "door_1.part_4.x",                         "0"                     },
+  { "door_1.part_4.y",                         "203"                   },
+  { "door_1.part_4.draw_masked",               "true"                  },
+  { "door_1.part_4.draw_order",                        "6"                     },
+  { "door_1.part_5.x",                         "0"                     },
+  { "door_1.part_5.y",                         "0"                     },
+  { "door_1.part_5.draw_masked",               "true"                  },
+  { "door_1.part_5.draw_order",                        "1"                     },
+  { "door_1.part_6.x",                         "0"                     },
+  { "door_1.part_6.y",                         "77"                    },
+  { "door_1.part_6.draw_masked",               "true"                  },
+  { "door_1.part_6.draw_order",                        "7"                     },
+  { "door_1.part_7.x",                         "0"                     },
+  { "door_1.part_7.y",                         "140"                   },
+  { "door_1.part_7.draw_masked",               "true"                  },
+  { "door_1.part_7.draw_order",                        "2"                     },
+  { "door_1.part_8.x",                         "0"                     },
+  { "door_1.part_8.y",                         "203"                   },
+  { "door_1.part_8.draw_masked",               "true"                  },
+  { "door_1.part_8.draw_order",                        "8"                     },
+
+  { "door_2.part_1.x",                         "0"                     },
+  { "door_2.part_1.y",                         "0"                     },
+  { "door_2.part_1.draw_masked",               "true"                  },
+  { "door_2.part_1.draw_order",                        "2"                     },
+  { "door_2.part_2.x",                         "0"                     },
+  { "door_2.part_2.y",                         "50"                    },
+  { "door_2.part_2.draw_masked",               "true"                  },
+  { "door_2.part_2.draw_order",                        "3"                     },
+  { "door_2.part_3.x",                         "0"                     },
+  { "door_2.part_3.y",                         "0"                     },
+  { "door_2.part_3.draw_masked",               "true"                  },
+  { "door_2.part_3.draw_order",                        "1"                     },
+  { "door_2.part_4.x",                         "0"                     },
+  { "door_2.part_4.y",                         "50"                    },
+  { "door_2.part_4.draw_masked",               "true"                  },
+  { "door_2.part_4.draw_order",                        "4"                     },
+  { "door_2.part_5.x",                         "-1"                    },
+  { "door_2.part_5.y",                         "-1"                    },
+  { "door_2.part_5.draw_masked",               "true"                  },
+  { "door_2.part_5.draw_order",                        "0"                     },
+  { "door_2.part_6.x",                         "-1"                    },
+  { "door_2.part_6.y",                         "-1"                    },
+  { "door_2.part_6.draw_masked",               "true"                  },
+  { "door_2.part_6.draw_order",                        "0"                     },
+  { "door_2.part_7.x",                         "-1"                    },
+  { "door_2.part_7.y",                         "-1"                    },
+  { "door_2.part_7.draw_masked",               "true"                  },
+  { "door_2.part_7.draw_order",                        "0"                     },
+  { "door_2.part_8.x",                         "-1"                    },
+  { "door_2.part_8.y",                         "-1"                    },
+  { "door_2.part_8.draw_masked",               "true"                  },
+  { "door_2.part_8.draw_order",                        "0"                     },
+
   { "door_1.width",                            "-1"                    },
   { "door_1.height",                           "-1"                    },
   { "door_1.step_offset",                      "2"                     },
index 015040f97ce606c8a7b41eaa2188b5fb7dd044c1..a2970b37510dc69a34a45c5dba811e08f1b84189 100644 (file)
 #define IMG_TITLESCREEN_3                              1847
 #define IMG_TITLESCREEN_4                              1848
 #define IMG_TITLESCREEN_5                              1849
-#define IMG_DOOR_1_WING_LEFT                           1850
-#define IMG_DOOR_1_WING_RIGHT                          1851
-#define IMG_DOOR_2_WING_LEFT                           1852
-#define IMG_DOOR_2_WING_RIGHT                          1853
-#define IMG_DOOR_2_TOP_BORDER_CORRECTION               1854
-#define IMG_LAST_IMAGE_ENTRY_BUG                       1855
+#define IMG_DOOR_1_GFX_PART_1                          1850
+#define IMG_DOOR_1_GFX_PART_2                          1851
+#define IMG_DOOR_1_GFX_PART_3                          1852
+#define IMG_DOOR_1_GFX_PART_4                          1853
+#define IMG_DOOR_1_GFX_PART_5                          1854
+#define IMG_DOOR_1_GFX_PART_6                          1855
+#define IMG_DOOR_1_GFX_PART_7                          1856
+#define IMG_DOOR_1_GFX_PART_8                          1857
+#define IMG_DOOR_2_GFX_PART_1                          1858
+#define IMG_DOOR_2_GFX_PART_2                          1859
+#define IMG_DOOR_2_GFX_PART_3                          1860
+#define IMG_DOOR_2_GFX_PART_4                          1861
+#define IMG_DOOR_2_GFX_PART_5                          1862
+#define IMG_DOOR_2_GFX_PART_6                          1863
+#define IMG_DOOR_2_GFX_PART_7                          1864
+#define IMG_DOOR_2_GFX_PART_8                          1865
+#define IMG_DOOR_1_WING_LEFT                           1866
+#define IMG_DOOR_1_WING_RIGHT                          1867
+#define IMG_DOOR_2_WING_LEFT                           1868
+#define IMG_DOOR_2_WING_RIGHT                          1869
+#define IMG_DOOR_2_TOP_BORDER_CORRECTION               1870
+#define IMG_LAST_IMAGE_ENTRY_BUG                       1871
 
-#define NUM_IMAGE_FILES                                        1856
+#define NUM_IMAGE_FILES                                        1872
 
 #endif /* CONF_GFX_H */
index 0c543d8a4898600f561f3227bd6af9f4381d5c91..7089c113c039e275fc555717c9db41ab171c74cd 100644 (file)
@@ -2092,6 +2092,262 @@ struct TokenIntPtrInfo image_config_vars[] =
     "preview.anim_mode",
     &preview.anim_mode
   },
+  {
+    "door_1.part_1.x",
+    &door_1.part_1.x
+  },
+  {
+    "door_1.part_1.y",
+    &door_1.part_1.y
+  },
+  {
+    "door_1.part_1.draw_masked",
+    &door_1.part_1.draw_masked
+  },
+  {
+    "door_1.part_1.draw_order",
+    &door_1.part_1.sort_priority
+  },
+  {
+    "door_1.part_2.x",
+    &door_1.part_2.x
+  },
+  {
+    "door_1.part_2.y",
+    &door_1.part_2.y
+  },
+  {
+    "door_1.part_2.draw_masked",
+    &door_1.part_2.draw_masked
+  },
+  {
+    "door_1.part_2.draw_order",
+    &door_1.part_2.sort_priority
+  },
+  {
+    "door_1.part_3.x",
+    &door_1.part_3.x
+  },
+  {
+    "door_1.part_3.y",
+    &door_1.part_3.y
+  },
+  {
+    "door_1.part_3.draw_masked",
+    &door_1.part_3.draw_masked
+  },
+  {
+    "door_1.part_3.draw_order",
+    &door_1.part_3.sort_priority
+  },
+  {
+    "door_1.part_4.x",
+    &door_1.part_4.x
+  },
+  {
+    "door_1.part_4.y",
+    &door_1.part_4.y
+  },
+  {
+    "door_1.part_4.draw_masked",
+    &door_1.part_4.draw_masked
+  },
+  {
+    "door_1.part_4.draw_order",
+    &door_1.part_4.sort_priority
+  },
+  {
+    "door_1.part_5.x",
+    &door_1.part_5.x
+  },
+  {
+    "door_1.part_5.y",
+    &door_1.part_5.y
+  },
+  {
+    "door_1.part_5.draw_masked",
+    &door_1.part_5.draw_masked
+  },
+  {
+    "door_1.part_5.draw_order",
+    &door_1.part_5.sort_priority
+  },
+  {
+    "door_1.part_6.x",
+    &door_1.part_6.x
+  },
+  {
+    "door_1.part_6.y",
+    &door_1.part_6.y
+  },
+  {
+    "door_1.part_6.draw_masked",
+    &door_1.part_6.draw_masked
+  },
+  {
+    "door_1.part_6.draw_order",
+    &door_1.part_6.sort_priority
+  },
+  {
+    "door_1.part_7.x",
+    &door_1.part_7.x
+  },
+  {
+    "door_1.part_7.y",
+    &door_1.part_7.y
+  },
+  {
+    "door_1.part_7.draw_masked",
+    &door_1.part_7.draw_masked
+  },
+  {
+    "door_1.part_7.draw_order",
+    &door_1.part_7.sort_priority
+  },
+  {
+    "door_1.part_8.x",
+    &door_1.part_8.x
+  },
+  {
+    "door_1.part_8.y",
+    &door_1.part_8.y
+  },
+  {
+    "door_1.part_8.draw_masked",
+    &door_1.part_8.draw_masked
+  },
+  {
+    "door_1.part_8.draw_order",
+    &door_1.part_8.sort_priority
+  },
+  {
+    "door_2.part_1.x",
+    &door_2.part_1.x
+  },
+  {
+    "door_2.part_1.y",
+    &door_2.part_1.y
+  },
+  {
+    "door_2.part_1.draw_masked",
+    &door_2.part_1.draw_masked
+  },
+  {
+    "door_2.part_1.draw_order",
+    &door_2.part_1.sort_priority
+  },
+  {
+    "door_2.part_2.x",
+    &door_2.part_2.x
+  },
+  {
+    "door_2.part_2.y",
+    &door_2.part_2.y
+  },
+  {
+    "door_2.part_2.draw_masked",
+    &door_2.part_2.draw_masked
+  },
+  {
+    "door_2.part_2.draw_order",
+    &door_2.part_2.sort_priority
+  },
+  {
+    "door_2.part_3.x",
+    &door_2.part_3.x
+  },
+  {
+    "door_2.part_3.y",
+    &door_2.part_3.y
+  },
+  {
+    "door_2.part_3.draw_masked",
+    &door_2.part_3.draw_masked
+  },
+  {
+    "door_2.part_3.draw_order",
+    &door_2.part_3.sort_priority
+  },
+  {
+    "door_2.part_4.x",
+    &door_2.part_4.x
+  },
+  {
+    "door_2.part_4.y",
+    &door_2.part_4.y
+  },
+  {
+    "door_2.part_4.draw_masked",
+    &door_2.part_4.draw_masked
+  },
+  {
+    "door_2.part_4.draw_order",
+    &door_2.part_4.sort_priority
+  },
+  {
+    "door_2.part_5.x",
+    &door_2.part_5.x
+  },
+  {
+    "door_2.part_5.y",
+    &door_2.part_5.y
+  },
+  {
+    "door_2.part_5.draw_masked",
+    &door_2.part_5.draw_masked
+  },
+  {
+    "door_2.part_5.draw_order",
+    &door_2.part_5.sort_priority
+  },
+  {
+    "door_2.part_6.x",
+    &door_2.part_6.x
+  },
+  {
+    "door_2.part_6.y",
+    &door_2.part_6.y
+  },
+  {
+    "door_2.part_6.draw_masked",
+    &door_2.part_6.draw_masked
+  },
+  {
+    "door_2.part_6.draw_order",
+    &door_2.part_6.sort_priority
+  },
+  {
+    "door_2.part_7.x",
+    &door_2.part_7.x
+  },
+  {
+    "door_2.part_7.y",
+    &door_2.part_7.y
+  },
+  {
+    "door_2.part_7.draw_masked",
+    &door_2.part_7.draw_masked
+  },
+  {
+    "door_2.part_7.draw_order",
+    &door_2.part_7.sort_priority
+  },
+  {
+    "door_2.part_8.x",
+    &door_2.part_8.x
+  },
+  {
+    "door_2.part_8.y",
+    &door_2.part_8.y
+  },
+  {
+    "door_2.part_8.draw_masked",
+    &door_2.part_8.draw_masked
+  },
+  {
+    "door_2.part_8.draw_order",
+    &door_2.part_8.sort_priority
+  },
   {
     "door_1.width",
     &door_1.width
index 14ad688f47dee6d9e5c053ddacb2ca983225fa05..efafec1c691a5c4f0fe4ebf1bfbfb813b28457c6 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2014-02-22 14:10"
+#define COMPILE_DATE_STRING "2014-02-24 17:29"
index 9fb4ef03e124a204a77e688668ac0a7ab27852c4..d261a4db45f368f1ff27c8a4f8424a5662845a4a 100644 (file)
@@ -1146,7 +1146,7 @@ void HandleButton(int mx, int my, int button, int button_nr)
 
     case GAME_MODE_PLAYING:
 #ifdef DEBUG
-      if (button == MB_PRESSED && !motion_status && IN_GFX_FIELD(mx, my))
+      if (button == MB_PRESSED && !motion_status && IN_GFX_FIELD_PLAY(mx, my))
        DumpTile(LEVELX((mx - SX) / TILEX), LEVELY((my - SY) / TILEY));
 #endif
       break;
index bd28fdc1cfe07352177a2f4bbb2185936e0eb13c..522b1b40110374ac2e5fe93d399ef8a7e55f53bc 100644 (file)
@@ -2469,6 +2469,8 @@ static void ReinitializeGraphics()
   print_timestamp_time("InitGadgets");
   InitToons();
   print_timestamp_time("InitToons");
+  InitDoors();
+  print_timestamp_time("InitDoors");
 
   print_timestamp_done("ReinitializeGraphics");
 }
index b10232fe63d19593fb51fd8a4ad2d810260141d5..5179c03bb81e81d98e27fb9652c9ddf1222e4bdf 100644 (file)
 #define REDRAWTILES_THRESHOLD  0
 #endif
 
-#define IN_GFX_FIELD(x, y)     (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
+#define IN_GFX_FIELD_PLAY(x, y)        (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
                                 y >= gfx.sy && y < gfx.sy + gfx.sysize)
 #define IN_GFX_FIELD_FULL(x, y)        (x >= gfx.real_sx && \
                                 x <  gfx.real_sx + gfx.full_sxsize && \
index 44d3f73cedfe478d62055555d4c994d6d84a473f..10e48258dc6d9510f13bbe0f74273e97a3c1c1e0 100644 (file)
@@ -2300,6 +2300,15 @@ struct MenuInfo
 
 struct DoorInfo
 {
+  struct TextPosInfo part_1;
+  struct TextPosInfo part_2;
+  struct TextPosInfo part_3;
+  struct TextPosInfo part_4;
+  struct TextPosInfo part_5;
+  struct TextPosInfo part_6;
+  struct TextPosInfo part_7;
+  struct TextPosInfo part_8;
+
   int width;
   int height;
   int step_offset;
index 022677d47f83f1baa17e2c4ee41d497e59e6f78f..59edb3d23075cdf0dfa5533d33abd99f4c142976 100644 (file)
 
 #define NUM_TOOL_BUTTONS       7
 
+/* constants for number of doors and door parts */
+#define NUM_DOORS              2
+#define MAX_NUM_DOOR_PARTS     8
+
+
+struct DoorPartOrderInfo
+{
+  int nr;
+  int sort_priority;
+};
+
+static struct DoorPartOrderInfo door_part_order[NUM_DOORS * MAX_NUM_DOOR_PARTS];
+
+struct DoorPartControlInfo
+{
+  int door_nr;
+  int graphic;
+  struct TextPosInfo *pos;
+};
+
+static struct DoorPartControlInfo door_part_controls[] =
+{
+  {
+    DOOR_1,
+    IMG_DOOR_1_GFX_PART_1,
+    &door_1.part_1
+  },
+  {
+    DOOR_1,
+    IMG_DOOR_1_GFX_PART_2,
+    &door_1.part_2
+  },
+  {
+    DOOR_1,
+    IMG_DOOR_1_GFX_PART_3,
+    &door_1.part_3
+  },
+  {
+    DOOR_1,
+    IMG_DOOR_1_GFX_PART_4,
+    &door_1.part_4
+  },
+  {
+    DOOR_1,
+    IMG_DOOR_1_GFX_PART_5,
+    &door_1.part_5
+  },
+  {
+    DOOR_1,
+    IMG_DOOR_1_GFX_PART_6,
+    &door_1.part_6
+  },
+  {
+    DOOR_1,
+    IMG_DOOR_1_GFX_PART_7,
+    &door_1.part_7
+  },
+  {
+    DOOR_1,
+    IMG_DOOR_1_GFX_PART_8,
+    &door_1.part_8
+  },
+  {
+    DOOR_2,
+    IMG_DOOR_2_GFX_PART_1,
+    &door_2.part_1
+  },
+  {
+    DOOR_2,
+    IMG_DOOR_2_GFX_PART_2,
+    &door_2.part_2
+  },
+  {
+    DOOR_2,
+    IMG_DOOR_2_GFX_PART_3,
+    &door_2.part_3
+  },
+  {
+    DOOR_2,
+    IMG_DOOR_2_GFX_PART_4,
+    &door_2.part_4
+  },
+  {
+    DOOR_2,
+    IMG_DOOR_2_GFX_PART_5,
+    &door_2.part_5
+  },
+  {
+    DOOR_2,
+    IMG_DOOR_2_GFX_PART_6,
+    &door_2.part_6
+  },
+  {
+    DOOR_2,
+    IMG_DOOR_2_GFX_PART_7,
+    &door_2.part_7
+  },
+  {
+    DOOR_2,
+    IMG_DOOR_2_GFX_PART_8,
+    &door_2.part_8
+  },
+
+  {
+    -1,
+    -1,
+    NULL
+  }
+};
+
+
 /* forward declaration for internal use */
 static void UnmapToolButtons();
 static void HandleToolButtons(struct GadgetInfo *);
@@ -1088,6 +1199,17 @@ void DrawBackground(int x, int y, int width, int height)
 #endif
 
 #if 1
+
+#if 1
+  if (IN_GFX_FIELD_FULL(x, y))
+    redraw_mask |= REDRAW_FIELD;
+  else if (IN_GFX_DOOR_1(x, y))
+    redraw_mask |= REDRAW_DOOR_1;
+  else if (IN_GFX_DOOR_2(x, y))
+    redraw_mask |= REDRAW_DOOR_2;
+  else if (IN_GFX_DOOR_3(x, y))
+    redraw_mask |= REDRAW_DOOR_3;
+#else
   /* (this only works for the current arrangement of playfield and panels) */
   if (x < gfx.dx)
     redraw_mask |= REDRAW_FIELD;
@@ -1095,6 +1217,8 @@ void DrawBackground(int x, int y, int width, int height)
     redraw_mask |= REDRAW_DOOR_1;
   else
     redraw_mask |= REDRAW_DOOR_2;
+#endif
+
 #else
   /* (this is just wrong (when drawing to one of the two door panel areas)) */
   redraw_mask |= REDRAW_FIELD;
@@ -5170,6 +5294,39 @@ boolean Request(char *text, unsigned int req_state)
 
 #endif
 
+static int compareDoorPartOrderInfo(const void *object1, const void *object2)
+{
+  const struct DoorPartOrderInfo *dpo1 = (struct DoorPartOrderInfo *)object1;
+  const struct DoorPartOrderInfo *dpo2 = (struct DoorPartOrderInfo *)object2;
+  int compare_result;
+
+  if (dpo1->sort_priority != dpo2->sort_priority)
+    compare_result = dpo1->sort_priority - dpo2->sort_priority;
+  else
+    compare_result = dpo1->nr - dpo2->nr;
+
+  return compare_result;
+}
+
+void InitDoors()
+{
+  int i;
+
+  for (i = 0; door_part_controls[i].door_nr != -1; i++)
+  {
+    struct DoorPartControlInfo *dpc = &door_part_controls[i];
+    struct DoorPartOrderInfo *dpo = &door_part_order[i];
+
+    /* fill structure for door part draw order */
+    dpo->nr = i;
+    dpo->sort_priority = dpc->pos->sort_priority;
+  }
+
+  /* sort door part controls according to sort_priority and graphic number */
+  qsort(door_part_order, NUM_DOORS * MAX_NUM_DOOR_PARTS,
+        sizeof(struct DoorPartOrderInfo), compareDoorPartOrderInfo);
+}
+
 unsigned int OpenDoor(unsigned int door_state)
 {
   if (door_state & DOOR_COPY_BACK)
@@ -5220,6 +5377,158 @@ unsigned int SetDoorState(unsigned int door_state)
   return MoveDoor(door_state | DOOR_SET_STATE);
 }
 
+#if 1
+
+// ========== TEST 1 ===========================================================
+
+unsigned int MoveDoor(unsigned int door_state)
+{
+  static int door1 = DOOR_OPEN_1;
+  static int door2 = DOOR_CLOSE_2;
+#if 0
+  unsigned int door_delay = 0;
+  unsigned int door_delay_value;
+  int stepsize = 1;
+#endif
+  int i, j;
+
+#if 1
+  if (door_1.width < 0 || door_1.width > DXSIZE)
+    door_1.width = DXSIZE;
+  if (door_1.height < 0 || door_1.height > DYSIZE)
+    door_1.height = DYSIZE;
+  if (door_2.width < 0 || door_2.width > VXSIZE)
+    door_2.width = VXSIZE;
+  if (door_2.height < 0 || door_2.height > VYSIZE)
+    door_2.height = VYSIZE;
+#endif
+
+  if (door_state == DOOR_GET_STATE)
+    return (door1 | door2);
+
+  if (door_state & DOOR_SET_STATE)
+  {
+    if (door_state & DOOR_ACTION_1)
+      door1 = door_state & DOOR_ACTION_1;
+    if (door_state & DOOR_ACTION_2)
+      door2 = door_state & DOOR_ACTION_2;
+
+    return (door1 | door2);
+  }
+
+  if (!(door_state & DOOR_FORCE_REDRAW))
+  {
+    if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1)
+      door_state &= ~DOOR_OPEN_1;
+    else if (door1 == DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1)
+      door_state &= ~DOOR_CLOSE_1;
+    if (door2 == DOOR_OPEN_2 && door_state & DOOR_OPEN_2)
+      door_state &= ~DOOR_OPEN_2;
+    else if (door2 == DOOR_CLOSE_2 && door_state & DOOR_CLOSE_2)
+      door_state &= ~DOOR_CLOSE_2;
+  }
+
+#if 0
+  door_delay_value = (door_state & DOOR_ACTION_1 ? door_1.step_delay :
+                     door_2.step_delay);
+
+  if (setup.quick_doors)
+  {
+    stepsize = 20;             /* must be chosen to always draw last frame */
+    door_delay_value = 0;
+  }
+#endif
+
+  if (global.autoplay_leveldir)
+  {
+    door_state |= DOOR_NO_DELAY;
+    door_state &= ~DOOR_CLOSE_ALL;
+  }
+
+#if 1
+  if (game_status == GAME_MODE_EDITOR)
+    door_state |= DOOR_NO_DELAY;
+#endif
+
+  if (door_state & DOOR_ACTION)
+  {
+    for (i = 0; i < NUM_DOORS * MAX_NUM_DOOR_PARTS; i++)
+    {
+      int nr = door_part_order[i].nr;
+      struct DoorPartControlInfo *dpc = &door_part_controls[nr];
+      int door_token = dpc->door_nr;
+      int door_index = DOOR_INDEX_FROM_TOKEN(door_token);
+      int graphic = dpc->graphic;
+      struct GraphicInfo *g = &graphic_info[graphic];
+      struct TextPosInfo *pos = dpc->pos;
+      int panel_src_x, panel_src_y;
+      int dx, dy, dxsize, dysize;
+      static boolean door_panel_drawn[NUM_DOORS];
+
+      if (i == 0)
+       for (j = 0; j < NUM_DOORS; j++)
+         door_panel_drawn[j] = FALSE;
+
+      if (door_token == DOOR_1)
+      {
+       panel_src_x = DOOR_GFX_PAGEX1;
+       panel_src_y = DOOR_GFX_PAGEY1;
+       dx = DX;
+       dy = DY;
+       dxsize = DXSIZE;
+       dysize = DYSIZE;
+      }
+      else     // DOOR_2
+      {
+       panel_src_x = DOOR_GFX_PAGEX1;
+       panel_src_y = DOOR_GFX_PAGEY2;
+       dx = VX;
+       dy = VY;
+       dxsize = VXSIZE;
+       dysize = VYSIZE;
+      }
+
+      if (!(door_state & door_token))
+       continue;
+
+      if (!g->bitmap)
+       continue;
+
+      if (!door_panel_drawn[door_index])
+      {
+       BlitBitmap(bitmap_db_door, drawto, panel_src_x, panel_src_y,
+                  dxsize, dysize, dx, dy);
+
+       door_panel_drawn[door_index] = TRUE;
+      }
+
+#if 1
+      // !!! TEST !!!
+      if (!((door_state & door_token) & DOOR_CLOSE))
+       continue;
+#endif
+
+      BlitBitmapMasked(g->bitmap, drawto, g->src_x, g->src_y,
+                      g->width, g->height, dx + pos->x, dy + pos->y);
+
+      redraw_mask |= REDRAW_DOOR_FROM_TOKEN(door_token);
+    }
+  }
+
+  redraw_mask |= REDRAW_ALL;
+
+  if (door_state & DOOR_ACTION_1)
+    door1 = door_state & DOOR_ACTION_1;
+  if (door_state & DOOR_ACTION_2)
+    door2 = door_state & DOOR_ACTION_2;
+
+  return (door1 | door2);
+}
+
+#else
+
+// ========== OLD ==============================================================
+
 unsigned int MoveDoor(unsigned int door_state)
 {
   static int door1 = DOOR_OPEN_1;
@@ -5817,6 +6126,8 @@ unsigned int MoveDoor(unsigned int door_state)
   return (door1 | door2);
 }
 
+#endif
+
 void DrawSpecialEditorDoor()
 {
 #if 1
index dfe2e5728776a6fd8421f2d11d6dc3ab2c082ca4..8f6289633cb1d42f82bae14171a9bb4c1fd4ffe0 100644 (file)
 #define USE_MASKING            1
  
 /* for MoveDoor */
+#if 0
+#define DOOR_1                 (1 << 0)
+#define DOOR_2                 (1 << 1)
+#define DOOR_OPEN              (1 << 2)
+#define DOOR_CLOSE             (1 << 3)
+#define DOOR_OPEN_1            (DOOR_1 | DOOR_OPEN)
+#define DOOR_OPEN_2            (DOOR_2 | DOOR_OPEN)
+#define DOOR_CLOSE_1           (DOOR_1 | DOOR_CLOSE)
+#define DOOR_CLOSE_2           (DOOR_2 | DOOR_CLOSE)
+#else
 #define DOOR_OPEN_1            (1 << 0)
 #define DOOR_OPEN_2            (1 << 1)
 #define DOOR_CLOSE_1           (1 << 2)
 #define DOOR_CLOSE_2           (1 << 3)
+#endif
 #define DOOR_OPEN_ALL          (DOOR_OPEN_1 | DOOR_OPEN_2)
 #define DOOR_CLOSE_ALL         (DOOR_CLOSE_1 | DOOR_CLOSE_2)
 #define DOOR_ACTION_1          (DOOR_OPEN_1 | DOOR_CLOSE_1)
 #define DOOR_GET_STATE         (1 << 8)
 #define DOOR_SET_STATE         (1 << 9)
 
+#define DOOR_1                 (DOOR_ACTION_1)
+#define DOOR_2                 (DOOR_ACTION_2)
+#define DOOR_OPEN              (DOOR_OPEN_ALL)
+#define DOOR_CLOSE             (DOOR_CLOSE_ALL)
+
+#define DOOR_INDEX_FROM_TOKEN(x)       ((x) == DOOR_1 ? 0 : 1)
+#define DOOR_TOKEN_FROM_INDEX(x)       ((x) == 0 ? DOOR_1 ? : DOOR_2)
+#define REDRAW_DOOR_FROM_TOKEN(x)      ((x) == DOOR_1 ? REDRAW_DOOR_1 : \
+                                        REDRAW_DOOR_2)
+
 /* for Request */
 #define REQ_ASK                        (1 << 0)
 #define REQ_CONFIRM            (1 << 1)
@@ -173,6 +194,7 @@ void DrawPreviewLevelAnimation(void);
 
 void WaitForEventToContinue();
 boolean Request(char *, unsigned int);
+void InitDoors(void);
 unsigned int OpenDoor(unsigned int);
 unsigned int CloseDoor(unsigned int);
 unsigned int GetDoorState(void);