From: Holger Schemel Date: Sat, 17 Jan 2004 15:15:36 +0000 (+0100) Subject: rnd-20040117-2-src X-Git-Tag: 3.1.0^2~94 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c77e984eb41ae3473b474e9051b0a71afffeb73c;p=rocksndiamonds.git rnd-20040117-2-src --- diff --git a/src/conftime.h b/src/conftime.h index 4339cf6f..95c1f875 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-01-17 14:58]" +#define COMPILE_DATE_STRING "[2004-01-17 15:38]" diff --git a/src/editor.c b/src/editor.c index 6dd5fd3f..4877a8bc 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1116,11 +1116,13 @@ static struct ValueTextInfo options_move_pattern[] = static struct ValueTextInfo options_move_direction[] = { - { MV_NO_MOVING, "automatic" }, + { MV_AUTOMATIC, "automatic" }, { MV_LEFT, "left" }, { MV_RIGHT, "right" }, { MV_UP, "up" }, { MV_DOWN, "down" }, + { MV_RANDOM, "random" }, + { MV_PREVIOUS, "previous" }, { -1, NULL } }; diff --git a/src/files.c b/src/files.c index 5c1786f7..c447bba9 100644 --- a/src/files.c +++ b/src/files.c @@ -210,7 +210,7 @@ static void setLevelInfoToDefaults(struct LevelInfo *level) element_info[element].move_delay_random = 0; element_info[element].move_pattern = MV_ALL_DIRECTIONS; - element_info[element].move_direction_initial = MV_NO_MOVING; + element_info[element].move_direction_initial = MV_AUTOMATIC; 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; diff --git a/src/game.c b/src/game.c index ecf2ca0f..dfad329e 100644 --- a/src/game.c +++ b/src/game.c @@ -1723,23 +1723,36 @@ void InitMovDir(int x, int y) default: if (IS_CUSTOM_ELEMENT(element)) { - if (element_info[element].move_direction_initial != MV_NO_MOVING) - MovDir[x][y] = element_info[element].move_direction_initial; - else if (element_info[element].move_pattern == MV_ALL_DIRECTIONS || - element_info[element].move_pattern == MV_TURNING_LEFT || - element_info[element].move_pattern == MV_TURNING_RIGHT || - element_info[element].move_pattern == MV_TURNING_LEFT_RIGHT || - element_info[element].move_pattern == MV_TURNING_RIGHT_LEFT || - element_info[element].move_pattern == MV_TURNING_RANDOM) + struct ElementInfo *ei = &element_info[element]; + int move_direction_initial = ei->move_direction_initial; + int move_pattern = ei->move_pattern; + + if (move_direction_initial == MV_PREVIOUS) + { + if (MovDir[x][y] != MV_NO_MOVING) + return; + + move_direction_initial = MV_AUTOMATIC; + } + + if (move_direction_initial & MV_ANY_DIRECTION) + MovDir[x][y] = move_direction_initial; + else if (move_direction_initial == MV_RANDOM || + move_pattern == MV_ALL_DIRECTIONS || + move_pattern == MV_TURNING_LEFT || + move_pattern == MV_TURNING_RIGHT || + move_pattern == MV_TURNING_LEFT_RIGHT || + move_pattern == MV_TURNING_RIGHT_LEFT || + move_pattern == MV_TURNING_RANDOM) MovDir[x][y] = 1 << RND(4); - else if (element_info[element].move_pattern == MV_HORIZONTAL) + else if (move_pattern == MV_HORIZONTAL) MovDir[x][y] = (RND(2) ? MV_LEFT : MV_RIGHT); - else if (element_info[element].move_pattern == MV_VERTICAL) + else if (move_pattern == MV_VERTICAL) MovDir[x][y] = (RND(2) ? MV_UP : MV_DOWN); - else if (element_info[element].move_pattern & MV_ANY_DIRECTION) + else if (move_pattern & MV_ANY_DIRECTION) MovDir[x][y] = element_info[element].move_pattern; - else if (element_info[element].move_pattern == MV_ALONG_LEFT_SIDE || - element_info[element].move_pattern == MV_ALONG_RIGHT_SIDE) + else if (move_pattern == MV_ALONG_LEFT_SIDE || + move_pattern == MV_ALONG_RIGHT_SIDE) { for (i = 0; i < 4; i++) { @@ -1748,7 +1761,7 @@ void InitMovDir(int x, int y) if (!IN_LEV_FIELD(x1, y1) || !IS_FREE(x1, y1)) { - if (element_info[element].move_pattern == MV_ALONG_RIGHT_SIDE) + if (move_pattern == MV_ALONG_RIGHT_SIDE) MovDir[x][y] = direction[0][i]; else MovDir[x][y] = direction[1][i]; @@ -6126,6 +6139,8 @@ static void ChangeActiveTrap(int x, int y) static void ChangeElementNowExt(int x, int y, int target_element) { + int previous_move_direction = MovDir[x][y]; + /* 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) && @@ -6143,6 +6158,9 @@ static void ChangeElementNowExt(int x, int y, int target_element) ResetGfxAnimation(x, y); ResetRandomAnimationValue(x, y); + if (element_info[Feld[x][y]].move_direction_initial == MV_PREVIOUS) + MovDir[x][y] = previous_move_direction; + InitField(x, y, FALSE); if (CAN_MOVE(Feld[x][y])) InitMovDir(x, y); @@ -9386,7 +9404,7 @@ boolean DropElement(struct PlayerInfo *player) int move_stepsize = element_info[new_element].move_stepsize; int direction, dx, dy, nextx, nexty; - if (element_info[new_element].move_direction_initial == MV_NO_MOVING) + if (element_info[new_element].move_direction_initial == MV_AUTOMATIC) MovDir[jx][jy] = player->MovDir; direction = MovDir[jx][jy]; diff --git a/src/main.h b/src/main.h index 734db18f..64cd7bdc 100644 --- a/src/main.h +++ b/src/main.h @@ -234,12 +234,15 @@ #define MV_BIT_TURNING_LEFT_RIGHT 14 #define MV_BIT_TURNING_RIGHT_LEFT 15 #define MV_BIT_TURNING_RANDOM 16 +#define MV_BIT_PREVIOUS 17 /* values for special move patterns for custom elements */ #define MV_HORIZONTAL (MV_LEFT | MV_RIGHT) #define MV_VERTICAL (MV_UP | MV_DOWN) #define MV_ALL_DIRECTIONS (MV_HORIZONTAL | MV_VERTICAL) #define MV_ANY_DIRECTION (MV_ALL_DIRECTIONS) +#define MV_RANDOM (MV_ALL_DIRECTIONS) +#define MV_AUTOMATIC (MV_NO_MOVING) #define MV_TOWARDS_PLAYER (1 << MV_BIT_TOWARDS_PLAYER) #define MV_AWAY_FROM_PLAYER (1 << MV_BIT_AWAY_FROM_PLAYER) #define MV_ALONG_LEFT_SIDE (1 << MV_BIT_ALONG_LEFT_SIDE) @@ -254,6 +257,7 @@ #define MV_TURNING_LEFT_RIGHT (1 << MV_BIT_TURNING_LEFT_RIGHT) #define MV_TURNING_RIGHT_LEFT (1 << MV_BIT_TURNING_RIGHT_LEFT) #define MV_TURNING_RANDOM (1 << MV_BIT_TURNING_RANDOM) +#define MV_PREVIOUS (1 << MV_BIT_PREVIOUS) /* values for slippery property for custom elements */ #define SLIPPERY_ANY_RANDOM 0