From: Holger Schemel Date: Fri, 6 Feb 2004 18:40:05 +0000 (+0100) Subject: rnd-20040206-B-src X-Git-Tag: 3.1.0^2~76 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=1c636a51bb573815d24a27dcc20b3283d89d1b8b;p=rocksndiamonds.git rnd-20040206-B-src --- diff --git a/Makefile b/Makefile index e97587db..1ea92b07 100644 --- 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 diff --git a/src/Makefile b/src/Makefile index 976f86bc..ef1f52af 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 \ diff --git a/src/conftime.h b/src/conftime.h index e52d0627..c477c00c 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-02-05 03:42]" +#define COMPILE_DATE_STRING "[2004-02-06 15:14]" diff --git a/src/files.c b/src/files.c index c2767d32..59adf524 100644 --- a/src/files.c +++ b/src/files.c @@ -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; diff --git a/src/game.c b/src/game.c index f5dc4186..0efc0328 100644 --- a/src/game.c +++ b/src/game.c @@ -107,7 +107,7 @@ (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)); } diff --git a/src/init.c b/src/init.c index ac93ee50..85358813 100644 --- a/src/init.c +++ b/src/init.c @@ -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)) { diff --git a/src/libgame/image.c b/src/libgame/image.c index e4ec9ebf..108fd39c 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -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) diff --git a/src/libgame/system.h b/src/libgame/system.h index 086f01c2..f39eb1b1 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -116,6 +116,11 @@ (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 diff --git a/src/libgame/x11.c b/src/libgame/x11.c index ce520f64..2a21abcc 100644 --- a/src/libgame/x11.c +++ b/src/libgame/x11.c @@ -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 */ diff --git a/src/libgame/x11.h b/src/libgame/x11.h index 99dc4c9c..7c69a323 100644 --- a/src/libgame/x11.h +++ b/src/libgame/x11.h @@ -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 *); diff --git a/src/main.h b/src/main.h index f11fc730..d09b3278 100644 --- a/src/main.h +++ b/src/main.h @@ -397,10 +397,21 @@ #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 */ diff --git a/src/netserv.c b/src/netserv.c index 71834c3b..7343be62 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -24,6 +24,7 @@ #include #include #include +#include /* apparently needed by OS/2 */ #include "libgame/libgame.h"