From: Holger Schemel Date: Wed, 23 Apr 2003 21:58:57 +0000 (+0200) Subject: rnd-20030423-2-src X-Git-Tag: 3.0.0^2~84 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=fbe0eaa3234fb6a69a65136f764922e24943501d;p=rocksndiamonds.git rnd-20030423-2-src --- diff --git a/src/conftime.h b/src/conftime.h index af29e066..63ab6096 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-04-22 23:56]" +#define COMPILE_DATE_STRING "[2003-04-23 21:28]" diff --git a/src/files.c b/src/files.c index 36380f92..6038711a 100644 --- a/src/files.c +++ b/src/files.c @@ -17,6 +17,7 @@ #include "libgame/libgame.h" #include "files.h" +#include "init.h" #include "tools.h" #include "tape.h" @@ -581,6 +582,7 @@ void LoadLevel(int level_nr) char *filename = getLevelFilename(level_nr); LoadLevelFromFilename(filename); + InitElementPropertiesEngine(level.game_version); } static void SaveLevel_VERS(FILE *file, struct LevelInfo *level) diff --git a/src/game.c b/src/game.c index 17363665..25e13806 100644 --- a/src/game.c +++ b/src/game.c @@ -14,9 +14,9 @@ #include "libgame/libgame.h" #include "game.h" +#include "init.h" #include "tools.h" #include "screens.h" -#include "init.h" #include "files.h" #include "tape.h" #include "network.h" @@ -500,9 +500,13 @@ static void InitGameEngine() { int i; + /* set game engine from tape file when re-playing, else from level file */ game.engine_version = (tape.playing ? tape.engine_version : level.game_version); + /* dynamically adjust element properties according to game engine version */ + InitElementPropertiesEngine(game.engine_version); + #if 0 printf("level %d: level version == %06d\n", level_nr, level.game_version); printf(" tape version == %06d [%s] [file: %06d]\n", @@ -520,6 +524,7 @@ static void InitGameEngine() game.initial_move_delay_value = (level.double_speed ? MOVE_DELAY_HIGH_SPEED : MOVE_DELAY_NORMAL_SPEED); +#if 0 /* dynamically adjust element properties according to game engine version */ { static int ep_em_slippery_wall[] = @@ -543,6 +548,7 @@ static void InitGameEngine() (level.em_slippery_gems && game.engine_version > VERSION_IDENT(2,0,1))); } +#endif /* initialize changing elements information */ for (i=0; ijx, jy = player->jy; - int dx = x - jx, dy = y - jy; +#if 1 + int jx, jy, dx, dy, xx, yy; + + if (real_dx == 0 || real_dy == 0) /* no diagonal direction => push */ + return TRUE; + + /* diagonal direction: check alternative direction */ + jx = player->jx; + jy = player->jy; + dx = x - jx; + dy = y - jy; + xx = jx + (dx == 0 ? real_dx : 0); + yy = jy + (dy == 0 ? real_dy : 0); + + return (!IN_LEV_FIELD(xx, yy) || IS_SOLID(Feld[xx][yy])); +#else if (real_dx && real_dy) /* diagonal direction input => do check */ { /* diagonal direction: check alternative direction */ + int jx = player->jx, jy = player->jy; + int dx = x - jx, dy = y - jy; int xx = jx + (dx == 0 ? real_dx : 0); int yy = jy + (dy == 0 ? real_dy : 0); @@ -5708,17 +5740,6 @@ static boolean checkDiagonalPushing(struct PlayerInfo *player, { int element = Feld[xx][yy]; -#if 0 - if (IS_HISTORIC_SOLID(element) != - (!(IS_WALKABLE(element) || - IS_DIGGABLE(element) || - IS_COLLECTIBLE(element)))) - printf("::: %d ['%s'] [%d, %d]\n", - element, - element_info[element].token_name, - game.engine_version, tape.engine_version); -#endif - if (game.engine_version < VERSION_IDENT(2,2,0)) return IS_HISTORIC_SOLID(element); else @@ -5729,6 +5750,7 @@ static boolean checkDiagonalPushing(struct PlayerInfo *player, } return TRUE; /* no diagonal direction input => push object */ +#endif } /* diff --git a/src/init.c b/src/init.c index 8c574f39..6b6ed64e 100644 --- a/src/init.c +++ b/src/init.c @@ -1078,10 +1078,8 @@ static void ReinitializeMusic() /* currently nothing to do */ } -void InitElementProperties() +void InitElementPropertiesStatic() { - int i, j; - static int ep_amoebalive[] = { EL_AMOEBA_WET, @@ -2239,6 +2237,22 @@ void InitElementProperties() { NULL, -1 } }; + int i, j; + + /* always start with reliable default values (element has no properties) */ + for (i=0; i < MAX_NUM_ELEMENTS; i++) + for (j=0; j < NUM_ELEMENT_PROPERTIES; j++) + SET_PROPERTY(i, j, FALSE); + + /* set all base element properties from above array definitions */ + for (i=0; element_properties[i].elements != NULL; i++) + for (j=0; (element_properties[i].elements)[j] != -1; j++) + SET_PROPERTY((element_properties[i].elements)[j], + element_properties[i].property, TRUE); +} + +void InitElementPropertiesEngine(int engine_version) +{ #if 0 static int active_properties[] = { @@ -2300,24 +2314,16 @@ void InitElementProperties() -1 }; - /* always start with reliable default values (no properties) */ - for (i=0; i= EL_CHAR_START && i <= EL_CHAR_END) + SET_PROPERTY(i, EP_INACTIVE, TRUE); + + /* ---------- WALKABLE, PASSABLE, ACCESSIBLE --------------------------- */ if (IS_WALKABLE_OVER(i) || IS_WALKABLE_INSIDE(i) || IS_WALKABLE_UNDER(i)) SET_PROPERTY(i, EP_WALKABLE, TRUE); @@ -2335,13 +2341,9 @@ void InitElementProperties() if (IS_WALKABLE(i) || IS_PASSABLE(i)) SET_PROPERTY(i, EP_ACCESSIBLE, TRUE); - } - /* dynamically determine wall-like elements */ - for (i=0; i < MAX_NUM_ELEMENTS; i++) - { - /* default: element is wall-like */ - SET_PROPERTY(i, EP_WALL, TRUE); + /* ---------- WALL ----------------------------------------------------- */ + SET_PROPERTY(i, EP_WALL, TRUE); /* default: element is wall */ for (j=0; no_wall_properties[j] != -1; j++) if (HAS_PROPERTY(i, no_wall_properties[j]) || @@ -2351,12 +2353,27 @@ void InitElementProperties() if (IS_HISTORIC_WALL(i)) SET_PROPERTY(i, EP_WALL, TRUE); -#if 0 - printf("::: %d: %s '%s'\n", - i, - (IS_WALL(i) ? "IS A WALL: " : "IS NOT A WALL:"), - element_info[i].token_name); -#endif + /* ---------- SOLID ---------------------------------------------------- */ + if (engine_version < VERSION_IDENT(2,2,0)) + SET_PROPERTY(i, EP_SOLID, IS_HISTORIC_SOLID(i)); + else + SET_PROPERTY(i, EP_SOLID, (!IS_WALKABLE(i) && + !IS_DIGGABLE(i) && + !IS_COLLECTIBLE(i))); + + /* ---------- DRAGONFIRE_PROOF ----------------------------------------- */ + if (IS_HISTORIC_SOLID(i) || i == EL_EXPLOSION) + SET_PROPERTY(i, EP_DRAGONFIRE_PROOF, TRUE); + + /* ---------- EXPLOSION_PROOF ------------------------------------------ */ + if (i == EL_FLAMES) + SET_PROPERTY(i, EP_EXPLOSION_PROOF, TRUE); + else if (engine_version < VERSION_IDENT(2,2,0)) + 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))); } #if 0 @@ -2377,6 +2394,30 @@ void InitElementProperties() #endif } #endif + + /* dynamically adjust element properties according to game engine version */ + { + static int ep_em_slippery_wall[] = + { + EL_STEELWALL, + EL_WALL, + EL_EXPANDABLE_WALL, + EL_EXPANDABLE_WALL_HORIZONTAL, + EL_EXPANDABLE_WALL_VERTICAL, + EL_EXPANDABLE_WALL_ANY, + -1 + }; + + /* special EM style gems behaviour */ + for (i=0; ep_em_slippery_wall[i] != -1; i++) + SET_PROPERTY(ep_em_slippery_wall[i], EP_EM_SLIPPERY_WALL, + level.em_slippery_gems); + + /* "EL_EXPANDABLE_WALL_GROWING" wasn't slippery for EM gems in 2.0.1 */ + SET_PROPERTY(EL_EXPANDABLE_WALL_GROWING, EP_EM_SLIPPERY_WALL, + (level.em_slippery_gems && + engine_version > VERSION_IDENT(2,0,1))); + } } static void InitGlobal() @@ -2913,7 +2954,7 @@ void OpenAll() InitEventFilter(FilterMouseMotionEvents); - InitElementProperties(); + InitElementPropertiesStatic(); InitGfx(); diff --git a/src/init.h b/src/init.h index 95993d45..b8b59e64 100644 --- a/src/init.h +++ b/src/init.h @@ -16,7 +16,10 @@ #include "main.h" -void ReloadCustomArtwork(); +void InitElementPropertiesStatic(void); +void InitElementPropertiesEngine(int); + +void ReloadCustomArtwork(void); void OpenAll(void); void CloseAllAndExit(int); diff --git a/src/main.h b/src/main.h index f4243bf6..c5a79500 100644 --- a/src/main.h +++ b/src/main.h @@ -111,8 +111,11 @@ #define EP_HAS_CONTENT 45 #define EP_TUBE 46 #define EP_WALL 47 +#define EP_SOLID 48 +#define EP_DRAGONFIRE_PROOF 49 +#define EP_EXPLOSION_PROOF 50 -#define NUM_ELEMENT_PROPERTIES 48 +#define NUM_ELEMENT_PROPERTIES 51 #define NUM_EP_BITFIELDS ((NUM_ELEMENT_PROPERTIES + 31) / 32) #define EP_BITFIELD_BASE 0 @@ -177,6 +180,9 @@ #define HAS_CONTENT(e) HAS_PROPERTY(e, EP_HAS_CONTENT) #define IS_TUBE(e) HAS_PROPERTY(e, EP_TUBE) #define IS_WALL(e) HAS_PROPERTY(e, EP_WALL) +#define IS_SOLID(e) HAS_PROPERTY(e, EP_SOLID) +#define IS_DRAGONFIRE_PROOF(e) HAS_PROPERTY(e, EP_DRAGONFIRE_PROOF) +#define IS_EXPLOSION_PROOF(e) HAS_PROPERTY(e, EP_EXPLOSION_PROOF) #define IS_CUSTOM_ELEMENT(e) ((e) >= EL_CUSTOM_START && \ (e) <= EL_CUSTOM_END)