projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20040512-1-src
[rocksndiamonds.git]
/
src
/
game.c
diff --git
a/src/game.c
b/src/game.c
index 467603a896db9d65bcd5dd2e4875e11c0f8ccf79..13089ad43e1b2f21a018cef525fae6b8c47d893b 100644
(file)
--- a/
src/game.c
+++ b/
src/game.c
@@
-114,8
+114,11
@@
((e) == EL_TRIGGER_ELEMENT ? (ch)->actual_trigger_element : \
(e) == EL_TRIGGER_PLAYER ? (ch)->actual_trigger_player : (e))
((e) == EL_TRIGGER_ELEMENT ? (ch)->actual_trigger_element : \
(e) == EL_TRIGGER_PLAYER ? (ch)->actual_trigger_player : (e))
+#define GET_VALID_PLAYER_ELEMENT(e) \
+ ((e) >= EL_PLAYER_1 && (e) <= EL_PLAYER_4 ? (e) : EL_PLAYER_1)
+
#define CAN_GROW_INTO(e) \
#define CAN_GROW_INTO(e) \
- (
e
== EL_SAND || (IS_DIGGABLE(e) && level.grow_into_diggable))
+ (
(e)
== EL_SAND || (IS_DIGGABLE(e) && level.grow_into_diggable))
#define ELEMENT_CAN_ENTER_FIELD_BASE_X(x, y, condition) \
(IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \
#define ELEMENT_CAN_ENTER_FIELD_BASE_X(x, y, condition) \
(IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \
@@
-2109,7
+2112,7
@@
void InitMovDir(int x, int y)
{
#if 1
/* use random direction as default start direction */
{
#if 1
/* use random direction as default start direction */
- if (game.engine_version >= VERSION_IDENT(3,1,0,
2
))
+ if (game.engine_version >= VERSION_IDENT(3,1,0,
0
))
MovDir[x][y] = 1 << RND(4);
#endif
MovDir[x][y] = 1 << RND(4);
#endif
@@
-2818,7
+2821,11
@@
void DrawRelocatePlayer(struct PlayerInfo *player)
void RelocatePlayer(int jx, int jy, int el_player_raw)
{
void RelocatePlayer(int jx, int jy, int el_player_raw)
{
+#if 1
+ int el_player = GET_VALID_PLAYER_ELEMENT(el_player_raw);
+#else
int el_player = (el_player_raw == EL_SP_MURPHY ? EL_PLAYER_1 :el_player_raw);
int el_player = (el_player_raw == EL_SP_MURPHY ? EL_PLAYER_1 :el_player_raw);
+#endif
struct PlayerInfo *player = &stored_player[el_player - EL_PLAYER_1];
boolean ffwd_delay = (tape.playing && tape.fast_forward);
boolean no_delay = (tape.warp_forward);
struct PlayerInfo *player = &stored_player[el_player - EL_PLAYER_1];
boolean ffwd_delay = (tape.playing && tape.fast_forward);
boolean no_delay = (tape.warp_forward);
@@
-2916,10
+2923,20
@@
void RelocatePlayer(int jx, int jy, int el_player_raw)
TestIfPlayerTouchesCustomElement(jx, jy);
#endif
TestIfPlayerTouchesCustomElement(jx, jy);
#endif
-#if 1
+#if 0
+ printf("::: %d,%d: %d\n", jx, jy-1, Changed[jx][jy-1]);
+#endif
+
+#if 0
+#if 0
+ /* needed to allow change of walkable custom element by entering player */
+ if (!(Changed[jx][jy] & CH_EVENT_BIT(CE_ENTERED_BY_PLAYER)))
+ Changed[jx][jy] = 0; /* allow another change (but prevent loop) */
+#else
/* needed to allow change of walkable custom element by entering player */
Changed[jx][jy] = 0; /* allow another change */
#endif
/* needed to allow change of walkable custom element by entering player */
Changed[jx][jy] = 0; /* allow another change */
#endif
+#endif
#if 0
printf("::: player entering %d, %d from %s ...\n", jx, jy,
#if 0
printf("::: player entering %d, %d from %s ...\n", jx, jy,
@@
-3052,10
+3069,17
@@
void Explode(int ex, int ey, int phase, int mode)
continue;
#else
/* indestructible elements can only explode in center (but not flames) */
continue;
#else
/* indestructible elements can only explode in center (but not flames) */
+#if 1
+ if ((IS_EXPLOSION_PROOF(element) && (x != ex || y != ey ||
+ mode == EX_TYPE_BORDER)) ||
+ element == EL_FLAMES)
+ continue;
+#else
if ((IS_EXPLOSION_PROOF(element) && (x != ex || y != ey)) ||
element == EL_FLAMES)
continue;
#endif
if ((IS_EXPLOSION_PROOF(element) && (x != ex || y != ey)) ||
element == EL_FLAMES)
continue;
#endif
+#endif
#else
if ((IS_INDESTRUCTIBLE(element) &&
#else
if ((IS_INDESTRUCTIBLE(element) &&
@@
-3068,7
+3092,7
@@
void Explode(int ex, int ey, int phase, int mode)
#if 1
if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y)) &&
(game.engine_version < VERSION_IDENT(3,1,0,0) ||
#if 1
if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y)) &&
(game.engine_version < VERSION_IDENT(3,1,0,0) ||
- (x == ex && y == ey)))
+ (x == ex && y == ey
&& mode != EX_TYPE_BORDER
)))
#else
if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y)))
#endif
#else
if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y)))
#endif
@@
-3083,6
+3107,12
@@
void Explode(int ex, int ey, int phase, int mode)
Feld[x][y] = (Store[x][y] ? Store[x][y] : EL_EMPTY);
Store[x][y] = 0;
#endif
Feld[x][y] = (Store[x][y] ? Store[x][y] : EL_EMPTY);
Store[x][y] = 0;
#endif
+
+#if 0
+ printf("::: %d,%d: %d %s [%d, %d]\n", x, y, Feld[x][y],
+ element_info[Feld[x][y]].token_name,
+ Store[x][y], Store2[x][y]);
+#endif
}
continue;
}
continue;
@@
-3093,10
+3123,16
@@
void Explode(int ex, int ey, int phase, int mode)
if (IS_INDESTRUCTIBLE(element))
Back[x][y] = element;
#else
if (IS_INDESTRUCTIBLE(element))
Back[x][y] = element;
#else
+#if 1
#if 1
#if 1
+ if (IS_WALKABLE(element) && IS_INDESTRUCTIBLE(element) &&
+ (x != ex || y != ey || mode == EX_TYPE_BORDER))
+ Back[x][y] = element;
+#else
if (IS_WALKABLE(element) && IS_INDESTRUCTIBLE(element) &&
(x != ex || y != ey))
Back[x][y] = element;
if (IS_WALKABLE(element) && IS_INDESTRUCTIBLE(element) &&
(x != ex || y != ey))
Back[x][y] = element;
+#endif
#else
if (IS_WALKABLE(element) && IS_INDESTRUCTIBLE(element))
Back[x][y] = element;
#else
if (IS_WALKABLE(element) && IS_INDESTRUCTIBLE(element))
Back[x][y] = element;
@@
-3185,10
+3221,15
@@
void Explode(int ex, int ey, int phase, int mode)
else
Store[x][y] = EL_EMPTY;
else
Store[x][y] = EL_EMPTY;
- if (x != ex || y != ey ||
- center_element == EL_AMOEBA_TO_DIAMOND
|| mode == EX_TYPE_BORDER
)
+ if (x != ex || y != ey ||
mode == EX_TYPE_BORDER ||
+ center_element == EL_AMOEBA_TO_DIAMOND)
Store2[x][y] = element;
Store2[x][y] = element;
+#if 0
+ printf("::: %d,%d: %d %s\n", x, y, Store2[x][y],
+ element_info[Store2[x][y]].token_name);
+#endif
+
#if 0
if (AmoebaNr[x][y] &&
(element == EL_AMOEBA_FULL ||
#if 0
if (AmoebaNr[x][y] &&
(element == EL_AMOEBA_FULL ||
@@
-3235,6
+3276,11
@@
void Explode(int ex, int ey, int phase, int mode)
game.yamyam_content_nr =
(game.yamyam_content_nr + 1) % level.num_yamyam_contents;
game.yamyam_content_nr =
(game.yamyam_content_nr + 1) % level.num_yamyam_contents;
+#if 0
+ printf("::: %d,%d: %d %s [%d]\n", ex + 1, ey, Feld[ex + 1][ey],
+ element_info[Feld[ex + 1][ey]].token_name, Store2[ex + 1][ey]);
+#endif
+
return;
}
return;
}
@@
-3288,6
+3334,11
@@
void Explode(int ex, int ey, int phase, int mode)
border_element = StorePlayer[x][y];
#endif
border_element = StorePlayer[x][y];
#endif
+#if 0
+ printf("::: %d,%d: %d %s [%d]\n", x, y, border_element,
+ element_info[border_element].token_name, Store2[x][y]);
+#endif
+
#if 0
printf("::: phase == %d\n", phase);
#endif
#if 0
printf("::: phase == %d\n", phase);
#endif
@@
-3318,6
+3369,11
@@
void Explode(int ex, int ey, int phase, int mode)
}
else if (CAN_EXPLODE_BY_EXPLOSION(border_element))
{
}
else if (CAN_EXPLODE_BY_EXPLOSION(border_element))
{
+#if 0
+ printf("::: %d,%d: %d %s\n", x, y, border_element,
+ element_info[border_element].token_name);
+#endif
+
Feld[x][y] = Store2[x][y];
Store2[x][y] = 0;
Bang(x, y);
Feld[x][y] = Store2[x][y];
Store2[x][y] = 0;
Bang(x, y);
@@
-5380,7
+5436,7
@@
void StartMoving(int x, int y)
#if 1
if (game.engine_version >= VERSION_IDENT(3,1,0,0) &&
#if 1
if (game.engine_version >= VERSION_IDENT(3,1,0,0) &&
- CheckCollision[x][y] &&
IN_LEV_FIELD_AND_NOT
_FREE(newx, newy))
+ CheckCollision[x][y] &&
!IN_LEV_FIELD_AND_IS
_FREE(newx, newy))
#else
if (game.engine_version >= VERSION_IDENT(3,1,0,0) &&
WasJustMoving[x][y] && IN_LEV_FIELD(newx, newy) &&
#else
if (game.engine_version >= VERSION_IDENT(3,1,0,0) &&
WasJustMoving[x][y] && IN_LEV_FIELD(newx, newy) &&
@@
-7417,7
+7473,9
@@
static void ChangeElementNowExt(int x, int y, int target_element)
DrawLevelFieldCrumbledSandNeighbours(x, y);
}
DrawLevelFieldCrumbledSandNeighbours(x, y);
}
+#if 0
Changed[x][y] |= ChangeEvent[x][y]; /* ignore same changes in this frame */
Changed[x][y] |= ChangeEvent[x][y]; /* ignore same changes in this frame */
+#endif
#if 0
TestIfBadThingTouchesHero(x, y);
#if 0
TestIfBadThingTouchesHero(x, y);
@@
-7425,9
+7483,14
@@
static void ChangeElementNowExt(int x, int y, int target_element)
TestIfElementTouchesCustomElement(x, y);
#endif
TestIfElementTouchesCustomElement(x, y);
#endif
+ /* "Changed[][]" not set yet to allow "entered by player" change one time */
if (ELEM_IS_PLAYER(target_element))
RelocatePlayer(x, y, target_element);
if (ELEM_IS_PLAYER(target_element))
RelocatePlayer(x, y, target_element);
+#if 1
+ Changed[x][y] |= ChangeEvent[x][y]; /* ignore same changes in this frame */
+#endif
+
#if 1
TestIfBadThingTouchesHero(x, y);
TestIfPlayerTouchesCustomElement(x, y);
#if 1
TestIfBadThingTouchesHero(x, y);
TestIfPlayerTouchesCustomElement(x, y);
@@
-7514,6
+7577,16
@@
static boolean ChangeElementNow(int x, int y, int element, int page)
continue;
}
continue;
}
+#if 0
+ if (Changed[ex][ey]) /* do not change already changed elements */
+ {
+ can_replace[xx][yy] = FALSE;
+ complete_replace = FALSE;
+
+ continue;
+ }
+#endif
+
e = Feld[ex][ey];
if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey))
e = Feld[ex][ey];
if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey))
@@
-9077,7
+9150,9
@@
static boolean canMoveToValidFieldWithGravity(int x, int y, int move_dir)
#if 1
return (IN_LEV_FIELD(newx, newy) && !IS_FREE_OR_PLAYER(newx, newy) &&
IS_GRAVITY_REACHABLE(Feld[newx][newy]) &&
#if 1
return (IN_LEV_FIELD(newx, newy) && !IS_FREE_OR_PLAYER(newx, newy) &&
IS_GRAVITY_REACHABLE(Feld[newx][newy]) &&
+#if 0
(!IS_SP_PORT(Feld[newx][newy]) || move_dir == MV_UP) &&
(!IS_SP_PORT(Feld[newx][newy]) || move_dir == MV_UP) &&
+#endif
(IS_DIGGABLE(Feld[newx][newy]) ||
IS_WALKABLE_FROM(Feld[newx][newy], opposite_dir) ||
canPassField(newx, newy, move_dir)));
(IS_DIGGABLE(Feld[newx][newy]) ||
IS_WALKABLE_FROM(Feld[newx][newy], opposite_dir) ||
canPassField(newx, newy, move_dir)));
@@
-9769,7
+9844,12
@@
void ScrollPlayer(struct PlayerInfo *player, int mode)
TestIfHeroTouchesBadThing(jx, jy);
TestIfPlayerTouchesCustomElement(jx, jy);
#if 1
TestIfHeroTouchesBadThing(jx, jy);
TestIfPlayerTouchesCustomElement(jx, jy);
#if 1
- TestIfElementTouchesCustomElement(jx, jy); /* for empty space */
+#if 1
+ /* needed because pushed element has not yet reached its destination,
+ so it would trigger a change event at its previous field location */
+ if (!player->is_pushing)
+#endif
+ TestIfElementTouchesCustomElement(jx, jy); /* for empty space */
#endif
if (!player->active)
#endif
if (!player->active)
@@
-11709,11
+11789,11
@@
boolean DropElement(struct PlayerInfo *player)
nexty = dropy + GET_DY_FROM_DIR(move_direction);
#if 1
nexty = dropy + GET_DY_FROM_DIR(move_direction);
#if 1
-
Changed[dropx][dropy] = 0;
/* allow another change */
-
CheckCollision[dropx][dropy] = 2;
+
Changed[dropx][dropy] = 0;
/* allow another change */
+ CheckCollision[dropx][dropy] = 2;
#else
#else
- if (IN_LEV_FIELD
(nextx, nexty) &&
IS_FREE(nextx, nexty))
+ if (IN_LEV_FIELD
_AND_
IS_FREE(nextx, nexty))
{
#if 0
WasJustMoving[dropx][dropy] = 3;
{
#if 0
WasJustMoving[dropx][dropy] = 3;
@@
-11724,7
+11804,8
@@
boolean DropElement(struct PlayerInfo *player)
#endif
#endif
}
#endif
#endif
}
-#if 1
+#if 0
+ /* !!! commented out from 3.1.0-4 to 3.1.0-5 !!! */
else
{
Changed[dropx][dropy] = 0; /* allow another change */
else
{
Changed[dropx][dropy] = 0; /* allow another change */