rnd-20040206-B-src
authorHolger Schemel <info@artsoft.org>
Fri, 6 Feb 2004 18:40:05 +0000 (19:40 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:45:47 +0000 (10:45 +0200)
12 files changed:
Makefile
src/Makefile
src/conftime.h
src/files.c
src/game.c
src/init.c
src/libgame/image.c
src/libgame/system.h
src/libgame/x11.c
src/libgame/x11.h
src/main.h
src/netserv.c

index e97587dbc3f9ecddf1c6850dda2a833c463ae470..1ea92b071143a8f34b3ef39b687194fc893a8a00 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -50,8 +50,8 @@ CROSS_PATH_WIN32=/usr/local/cross-tools/i386-mingw32msvc
 SRC_DIR = src
 MAKE_CMD = $(MAKE) -C $(SRC_DIR)
 
-DEFAULT_TARGET = x11
-DEFAULT_TARGET = sdl
+DEFAULT_TARGET = x11
+DEFAULT_TARGET = sdl
 
 
 # -----------------------------------------------------------------------------
@@ -79,6 +79,9 @@ mac:
 msdos:
        @$(MAKE_CMD) PLATFORM=msdos
 
+os2:
+       @$(MAKE_CMD) PLATFORM=os2
+
 cross-msdos:
        @PATH=$(CROSS_PATH_MSDOS)/bin:${PATH} $(MAKE_CMD) PLATFORM=cross-msdos
 
index 976f86bc60b6322e923e014760a404ff605caf0c..ef1f52af1cd9b8b1be223b2036c4533f0076c8b3 100644 (file)
@@ -58,6 +58,15 @@ PLATFORM = unix
 TARGET=sdl
 endif
 
+ifeq ($(PLATFORM),os2)
+RANLIB = echo
+PROGNAME = ../$(PROGBASE).exe
+EXTRA_CFLAGS = -Zbin-files -D__ST_MT_ERRNO__ -Zmtd -fomit-frame-pointer
+EXTRA_LDFLAGS = -lsocket
+PLATFORM = unix
+TARGET=x11
+endif
+
 ifeq ($(PLATFORM),unix)
 PROFILING_FLAGS = -pg
 endif
@@ -76,7 +85,8 @@ endif
 
 ifeq ($(TARGET),x11)
 SYS_CFLAGS  = -DTARGET_X11 $(X11_INCL)
-SYS_LDFLAGS = $(X11_LIBS) -lX11
+# SYS_LDFLAGS = $(X11_LIBS) -lX11
+SYS_LDFLAGS = $(XLIB_PATH)/libX11.a
 endif
 
 ifeq ($(TARGET),sdl)
@@ -128,8 +138,8 @@ ifdef BUILD_DIST                            # distribution build
 OPTIONS = -O3 -Wall
 endif
 
-CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(CONFIG)
-LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm
+CFLAGS = $(OPTIONS) $(SYS_CFLAGS)  $(EXTRA_CFLAGS) $(CONFIG)
+LDFLAGS =           $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm
 
 
 SRCS = main.c          \
index e52d062799c3dd933275242759545d8ed283181d..c477c00c411febc994a7660c3eb93d3d3aca2354 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2004-02-05 03:42]"
+#define COMPILE_DATE_STRING "[2004-02-06 15:14]"
index c2767d325b663eaad396dfedb7ec145ac0177bf2..59adf524c7fc7460b17d1e45039f9f43806a4d76 100644 (file)
@@ -225,6 +225,9 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
 
       element_info[element].slippery_type = SLIPPERY_ANY_RANDOM;
 
+      element_info[element].explosion_delay = 0;
+      element_info[element].ignition_delay = 0;
+
       for (x = 0; x < 3; x++)
        for (y = 0; y < 3; y++)
          element_info[element].content[x][y] = EL_EMPTY_SPACE;
index f5dc4186379d4a9063acd9b4441139d286ba1797..0efc0328827c6ce3f65b309b3a1c92356c8ddea4 100644 (file)
                                        (condition) ||                  \
                                        (DONT_COLLIDE_WITH(e) &&        \
                                         IS_PLAYER(x, y) &&             \
-                                        !PLAYER_PROTECTED(x, y))))
+                                        !PLAYER_ENEMY_PROTECTED(x, y))))
 #else
 #define ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, condition)            \
                (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) ||                \
@@ -216,7 +216,8 @@ static void ScrollScreen(struct PlayerInfo *, int);
 static void InitBeltMovement(void);
 static void CloseAllOpenTimegates(void);
 static void CheckGravityMovement(struct PlayerInfo *);
-static void KillHeroUnlessProtected(int, int);
+static void KillHeroUnlessEnemyProtected(int, int);
+static void KillHeroUnlessExplosionProtected(int, int);
 
 static void TestIfPlayerTouchesCustomElement(int, int);
 static void TestIfElementTouchesCustomElement(int, int);
@@ -2536,7 +2537,7 @@ void Explode(int ex, int ey, int phase, int mode)
       RemoveField(x, y);
 #endif
 
-      if (IS_PLAYER(ex, ey) && !PLAYER_PROTECTED(ex, ey))
+      if (IS_PLAYER(ex, ey) && !PLAYER_EXPLOSION_PROTECTED(ex, ey))
       {
        switch(StorePlayer[ex][ey])
        {
@@ -2679,7 +2680,7 @@ void Explode(int ex, int ey, int phase, int mode)
     int element = Store2[x][y];
 
     if (IS_PLAYER(x, y))
-      KillHeroUnlessProtected(x, y);
+      KillHeroUnlessExplosionProtected(x, y);
     else if (CAN_EXPLODE_BY_FIRE(element))
     {
       Feld[x][y] = Store2[x][y];
@@ -2836,7 +2837,7 @@ void Bang(int x, int y)
 #endif
 
 #if 1
-  if (IS_PLAYER(x, y) && !PLAYER_PROTECTED(x, y))
+  if (IS_PLAYER(x, y) && !PLAYER_EXPLOSION_PROTECTED(x, y))
 #else
   if (IS_PLAYER(x, y))
 #endif
@@ -3327,7 +3328,7 @@ void Impact(int x, int y)
   if (impact && element == EL_AMOEBA_DROP)
   {
     if (object_hit && IS_PLAYER(x, y + 1))
-      KillHeroUnlessProtected(x, y + 1);
+      KillHeroUnlessEnemyProtected(x, y + 1);
     else if (object_hit && smashed == EL_PENGUIN)
       Bang(x, y + 1);
     else
@@ -3369,7 +3370,7 @@ void Impact(int x, int y)
     {
       if (CAN_SMASH_PLAYER(element))
       {
-       KillHeroUnlessProtected(x, y + 1);
+       KillHeroUnlessEnemyProtected(x, y + 1);
        return;
       }
     }
@@ -4710,7 +4711,7 @@ void StartMoving(int x, int y)
 
     if (DONT_COLLIDE_WITH(element) &&
        IN_LEV_FIELD(newx, newy) && IS_PLAYER(newx, newy) &&
-       !PLAYER_PROTECTED(newx, newy))
+       !PLAYER_ENEMY_PROTECTED(newx, newy))
     {
 #if 1
       TestIfBadThingRunsIntoHero(x, y, MovDir[x][y]);
@@ -5261,15 +5262,7 @@ void ContinueMoving(int x, int y)
 #if 0
     if (IN_LEV_FIELD(nextx, nexty))
     {
-      static int opposite_directions[] =
-      {
-       MV_RIGHT,
-       MV_LEFT,
-       MV_DOWN,
-       MV_UP
-      };
-      int move_dir_bit = MV_DIR_BIT(direction);
-      int opposite_direction = opposite_directions[move_dir_bit];
+      int opposite_direction = MV_DIR_OPPOSITE(direction);
       int hitting_side = direction;
       int touched_side = opposite_direction;
       int touched_element = MovingOrBlocked2Element(nextx, nexty);
@@ -6232,7 +6225,7 @@ static void ChangeElementNowExt(int x, int y, int target_element)
 
   /* check if element under player changes from accessible to unaccessible
      (needed for special case of dropping element which then changes) */
-  if (IS_PLAYER(x, y) && !PLAYER_PROTECTED(x, y) &&
+  if (IS_PLAYER(x, y) && !PLAYER_EXPLOSION_PROTECTED(x, y) &&
       IS_ACCESSIBLE(Feld[x][y]) && !IS_ACCESSIBLE(target_element))
   {
     Bang(x, y);
@@ -8337,15 +8330,7 @@ void TestIfElementHitsCustomElement(int x, int y, int direction)
 
   if (IN_LEV_FIELD(hitx, hity))
   {
-    static int opposite_directions[] =
-    {
-      MV_RIGHT,
-      MV_LEFT,
-      MV_DOWN,
-      MV_UP
-    };
-    int move_dir_bit = MV_DIR_BIT(direction);
-    int opposite_direction = opposite_directions[move_dir_bit];
+    int opposite_direction = MV_DIR_OPPOSITE(direction);
     int hitting_side = direction;
     int touched_side = opposite_direction;
     int touched_element = MovingOrBlocked2Element(hitx, hity);
@@ -8474,7 +8459,7 @@ void TestIfGoodThingHitsBadThing(int good_x, int good_y, int good_move_dir)
 
       if (player->shield_deadly_time_left > 0)
        Bang(kill_x, kill_y);
-      else if (!PLAYER_PROTECTED(good_x, good_y))
+      else if (!PLAYER_ENEMY_PROTECTED(good_x, good_y))
        KillHero(player);
     }
     else
@@ -8566,7 +8551,7 @@ void TestIfBadThingHitsGoodThing(int bad_x, int bad_y, int bad_move_dir)
 
       if (player->shield_deadly_time_left > 0)
        Bang(bad_x, bad_y);
-      else if (!PLAYER_PROTECTED(kill_x, kill_y))
+      else if (!PLAYER_ENEMY_PROTECTED(kill_x, kill_y))
        KillHero(player);
     }
     else
@@ -8656,9 +8641,15 @@ void KillHero(struct PlayerInfo *player)
   BuryHero(player);
 }
 
-static void KillHeroUnlessProtected(int x, int y)
+static void KillHeroUnlessEnemyProtected(int x, int y)
+{
+  if (!PLAYER_ENEMY_PROTECTED(x, y))
+    KillHero(PLAYERINFO(x, y));
+}
+
+static void KillHeroUnlessExplosionProtected(int x, int y)
 {
-  if (!PLAYER_PROTECTED(x, y))
+  if (!PLAYER_EXPLOSION_PROTECTED(x, y))
     KillHero(PLAYERINFO(x, y));
 }
 
index ac93ee5086da9c6f0d20b6f5d6818a48e5c85f8c..853588131e640718f8e6a5a81f073f7505d4367b 100644 (file)
@@ -2084,6 +2084,11 @@ void InitElementPropertiesStatic()
     -1
   };
 
+  static int ep_protected[] =
+  {
+    -1
+  };
+
   static int ep_player[] =
   {
     EL_PLAYER_1,
@@ -2857,6 +2862,7 @@ void InitElementPropertiesStatic()
     { ep_can_explode_1x1,      EP_CAN_EXPLODE_1X1      },
     { ep_pushable,             EP_PUSHABLE             },
     { ep_can_explode_dyna,     EP_CAN_EXPLODE_DYNA     },
+    { ep_protected,            EP_PROTECTED            },
 
     { ep_player,               EP_PLAYER               },
     { ep_can_pass_magic_wall,  EP_CAN_PASS_MAGIC_WALL  },
@@ -3081,6 +3087,10 @@ void InitElementPropertiesEngine(int engine_version)
       SET_PROPERTY(i, EP_DRAGONFIRE_PROOF, (IS_CUSTOM_ELEMENT(i) &&
                                            IS_INDESTRUCTIBLE(i)));
 
+    /* ---------- PROTECTED ------------------------------------------------ */
+    if (IS_ACCESSIBLE_INSIDE(i))
+      SET_PROPERTY(i, EP_PROTECTED, TRUE);
+
     /* ---------- EXPLOSION_PROOF ------------------------------------------ */
     if (i == EL_FLAMES)
       SET_PROPERTY(i, EP_EXPLOSION_PROOF, TRUE);
@@ -3088,8 +3098,7 @@ void InitElementPropertiesEngine(int engine_version)
       SET_PROPERTY(i, EP_EXPLOSION_PROOF, IS_INDESTRUCTIBLE(i));
     else
       SET_PROPERTY(i, EP_EXPLOSION_PROOF, (IS_INDESTRUCTIBLE(i) &&
-                                          !IS_WALKABLE_OVER(i) &&
-                                          !IS_WALKABLE_UNDER(i)));
+                                          IS_PROTECTED(i)));
 
     if (IS_CUSTOM_ELEMENT(i))
     {
index e4ec9ebfd58437dda03fa25974c6e111241674eb..108fd39c3fc4d80033e2748b64170bc1ee5f88a1 100644 (file)
@@ -560,7 +560,7 @@ XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual,
   XPutImage(ximageinfo->display, ximageinfo->pixmap, gc,
            ximage, 0, 0, 0, 0, ximage->width, ximage->height);
 
-  XDestroyImage(ximage);
+  X11DestroyImage(ximage);
 
   return ximageinfo;
 }
@@ -621,8 +621,8 @@ void ZoomPixmap(Display *display, GC gc, Pixmap src_pixmap, Pixmap dst_pixmap,
            dst_width, dst_height);
 
   /* free temporary images */
-  XDestroyImage(src_ximage);
-  XDestroyImage(dst_ximage);
+  X11DestroyImage(src_ximage);
+  X11DestroyImage(dst_ximage);
 }
 
 void freeXImage(Image *image, XImageInfo *ximageinfo)
index 086f01c2aa11a5a73627878f7fca9f54c1831e82..f39eb1b1a546d4ab450160a008819f5562a0a2f3 100644 (file)
                                 (x) == MV_RIGHT ? MV_BIT_RIGHT :       \
                                 (x) == MV_UP    ? MV_BIT_UP    : MV_BIT_DOWN)
 
+#define MV_DIR_OPPOSITE(x)     ((x) == MV_LEFT  ? MV_RIGHT :           \
+                                (x) == MV_RIGHT ? MV_LEFT  :           \
+                                (x) == MV_UP    ? MV_DOWN  :           \
+                                (x) == MV_DOWN  ? MV_UP    : MV_NO_MOVING)
+
 
 /* values for animation mode (frame order and direction) */
 #define ANIM_NONE              0
index ce520f6452ed70613d8fc664aec436669293541e..2a21abcc89af91b55eb78c2c134cb0d1042bb5d6 100644 (file)
@@ -399,7 +399,7 @@ inline Pixel X11GetPixel(Bitmap *bitmap, int x, int y)
                          AllPlanes, ZPixmap);
   pixel_value = XGetPixel(pixel_image, 0, 0);
 
-  XDestroyImage(pixel_image);
+  X11DestroyImage(pixel_image);
 
   return pixel_value;
 }
@@ -423,6 +423,18 @@ inline Pixel X11GetPixelFromRGB(unsigned int color_r, unsigned int color_g,
 }
 #endif /* TARGET_X11_NATIVE */
 
+inline void X11DestroyImage(XImage *ximage)
+{
+  /* this seems to be needed for OS/2, but does not hurt on other platforms */
+  if (ximage->data != NULL)
+  {
+    free(ximage->data);
+    ximage->data = NULL;
+  }
+
+  XDestroyImage(ximage);
+}
+
 
 /* ------------------------------------------------------------------------- */
 /* mouse pointer functions                                                   */
index 99dc4c9cf6cdb0f4f909a5ab64f67cd6a492bd00..7c69a323c0cd6f67a92c2c6973956d948e25f435 100644 (file)
@@ -347,6 +347,7 @@ inline void X11FillRectangle(Bitmap *, int, int, int, int, Pixel);
 inline void X11DrawSimpleLine(Bitmap *, int, int, int, int, Pixel);
 inline Pixel X11GetPixel(Bitmap *, int, int);
 inline Pixel X11GetPixelFromRGB(unsigned int, unsigned int, unsigned int);
+inline void X11DestroyImage(XImage *);
 
 #if defined(TARGET_X11_NATIVE)
 void X11SetMouseCursor(struct MouseCursorInfo *);
index f11fc730d582ea0a2781c2e3b7dfecd5fdf5fdb8..d09b3278e5eea8ba321998d87e74035acee18c83 100644 (file)
 
 #define PLAYERINFO(x,y)                (&stored_player[StorePlayer[x][y]-EL_PLAYER_1])
 #define SHIELD_ON(p)           ((p)->shield_normal_time_left > 0)
+
+#if 1
+#define ENEMY_PROTECTED_FIELD(x,y)     (IS_PROTECTED(Feld[x][y]) ||       \
+                                        IS_PROTECTED(Back[x][y]))
+#define EXPLOSION_PROTECTED_FIELD(x,y)  (IS_EXPLOSION_PROOF(Feld[x][y]))
+#define PLAYER_ENEMY_PROTECTED(x,y)     (SHIELD_ON(PLAYERINFO(x, y)) ||           \
+                                        ENEMY_PROTECTED_FIELD(x, y))
+#define PLAYER_EXPLOSION_PROTECTED(x,y) (SHIELD_ON(PLAYERINFO(x, y)) ||           \
+                                        EXPLOSION_PROTECTED_FIELD(x, y))
+#else
 #define PROTECTED_FIELD(x,y)   (IS_ACCESSIBLE_INSIDE(Feld[x][y]) &&    \
                                 IS_INDESTRUCTIBLE(Feld[x][y]))
 #define PLAYER_PROTECTED(x,y)  (SHIELD_ON(PLAYERINFO(x, y)) ||         \
                                 PROTECTED_FIELD(x, y))
+#endif
 
 #define PLAYER_SWITCHING(p,x,y)        ((p)->is_switching &&                   \
                                 (p)->switch_x == (x) && (p)->switch_y == (y))
@@ -1563,6 +1574,9 @@ struct ElementInfo
 
   int content[3][3];           /* new elements after explosion */
 
+  int explosion_delay;         /* duration of explosion of this element */
+  int ignition_delay;          /* delay for explosion by other explosion */
+
   struct ElementChangeInfo *change_page; /* actual list of change pages */
   struct ElementChangeInfo *change;     /* pointer to current change page */
 
index 71834c3b1f17dbc8be3a778149e0db9ea569570e..7343be6272fd4b431c259328a79d988061348eb8 100644 (file)
@@ -24,6 +24,7 @@
 #include <netinet/tcp.h>
 #include <arpa/inet.h>
 #include <netdb.h>
+#include <sys/select.h>                /* apparently needed by OS/2 */
 
 #include "libgame/libgame.h"