{
Event event;
- if (NextValidEvent(&event))
+ while (NextValidEvent(&event))
{
switch(event.type)
{
case GAME_MODE_PLAYING:
#ifdef DEBUG
- if (button == MB_RELEASED)
- {
- if (IN_GFX_SCREEN(mx, my))
- {
- int sx = (mx - SX) / TILEX;
- int sy = (my - SY) / TILEY;
- int x = LEVELX(sx);
- int y = LEVELY(sy);
-
- printf("INFO: SCREEN(%d, %d), LEVEL(%d, %d)\n", sx, sy, x, y);
-
- if (!IN_LEV_FIELD(x, y))
- break;
-
- printf(" Feld[%d][%d] == %d ('%s')\n", x,y, Feld[x][y],
- element_info[Feld[x][y]].token_name);
- printf(" Back[%d][%d] == %d\n", x,y, Back[x][y]);
- printf(" Store[%d][%d] == %d\n", x,y, Store[x][y]);
- printf(" Store2[%d][%d] == %d\n", x,y, Store2[x][y]);
- printf(" StorePlayer[%d][%d] == %d\n", x,y, StorePlayer[x][y]);
- printf(" MovPos[%d][%d] == %d\n", x,y, MovPos[x][y]);
- printf(" MovDir[%d][%d] == %d\n", x,y, MovDir[x][y]);
- printf(" MovDelay[%d][%d] == %d\n", x,y, MovDelay[x][y]);
- printf(" ChangeDelay[%d][%d] == %d\n", x,y, ChangeDelay[x][y]);
- printf(" GfxElement[%d][%d] == %d\n", x,y, GfxElement[x][y]);
- printf(" GfxAction[%d][%d] == %d\n", x,y, GfxAction[x][y]);
- printf(" GfxFrame[%d][%d] == %d\n", x,y, GfxFrame[x][y]);
- printf("\n");
- }
- }
+ if (button == MB_PRESSED && !motion_status && IN_GFX_SCREEN(mx, my))
+ DumpTile(LEVELX((mx - SX) / TILEX), LEVELY((my - SY) / TILEY));
#endif
break;
#define GET_MAX_MOVE_DELAY(e) ( (element_info[e].move_delay_fixed) + \
(element_info[e].move_delay_random))
+#define ELEMENT_CAN_ENTER_FIELD_BASE(e, x, y, condition) \
+ (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \
+ (CAN_MOVE_INTO_ACID(e) && \
+ Feld[x][y] == EL_ACID) || \
+ (condition)))
+
+#if 0
#define ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, condition) \
(IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \
(condition) || \
(DONT_COLLIDE_WITH(e) && \
IS_PLAYER(x, y) && \
!PLAYER_ENEMY_PROTECTED(x, y))))
-
-#define ELEMENT_CAN_ENTER_FIELD_GENERIC_X(e, x, y, condition) \
+#else
+#define ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, condition) \
(IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \
(condition) || \
(CAN_MOVE_INTO_ACID(e) && \
(DONT_COLLIDE_WITH(e) && \
IS_PLAYER(x, y) && \
!PLAYER_ENEMY_PROTECTED(x, y))))
+#endif
#define ELEMENT_CAN_ENTER_FIELD_GENERIC_2(x, y, condition) \
(IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \
#define ELEMENT_CAN_ENTER_FIELD_OR_ACID_2(x, y) \
ELEMENT_CAN_ENTER_FIELD_GENERIC_2(x, y, (Feld[x][y] == EL_ACID))
-#define ENEMY_CAN_ENTER_FIELD(x, y) (IN_LEV_FIELD(x, y) && IS_FREE(x, y))
+#if 0
+#define ENEMY_CAN_ENTER_FIELD(e, x, y) (IN_LEV_FIELD(x, y) && IS_FREE(x, y))
+#else
+#define ENEMY_CAN_ENTER_FIELD(e, x, y) ELEMENT_CAN_ENTER_FIELD_BASE(e, x, y, 0)
+#endif
#define YAMYAM_CAN_ENTER_FIELD(x, y) \
(IN_LEV_FIELD(x, y) && (IS_FREE_OR_PLAYER(x, y) || \
#define IS_EQUAL_OR_IN_GROUP(e, ge) \
(IS_GROUP_ELEMENT(ge) ? IS_IN_GROUP(e, GROUP_NR(ge)) : (e) == (ge))
+#if 0
#define CE_ENTER_FIELD_COND(e, x, y) \
(!IS_PLAYER(x, y) && \
(Feld[x][y] == EL_ACID || \
IS_EQUAL_OR_IN_GROUP(Feld[x][y], MOVE_ENTER_EL(e))))
-
-#define CE_ENTER_FIELD_COND_X(e, x, y) \
+#else
+#define CE_ENTER_FIELD_COND(e, x, y) \
(!IS_PLAYER(x, y) && \
IS_EQUAL_OR_IN_GROUP(Feld[x][y], MOVE_ENTER_EL(e)))
+#endif
#define CUSTOM_ELEMENT_CAN_ENTER_FIELD(e, x, y) \
- ELEMENT_CAN_ENTER_FIELD_GENERIC_X(e, x, y, CE_ENTER_FIELD_COND_X(e, x, y))
+ ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, CE_ENTER_FIELD_COND(e, x, y))
#define MOLE_CAN_ENTER_FIELD(x, y, condition) \
(IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || (condition)))
if (IS_MOVING(x, y))
{
Moving2Blocked(x, y, &newx, &newy);
+#if 0
if (Feld[newx][newy] != EL_BLOCKED)
return;
+#else
+ if (Feld[newx][newy] != EL_BLOCKED)
+ {
+ /* element is moving, but target field is not free (blocked), but
+ already occupied by something different (example: acid pool);
+ in this case, only remove the moving field, but not the target */
+
+ RemoveField(oldx, oldy);
+
+ Store[oldx][oldy] = Store2[oldx][oldy] = 0;
+
+ DrawLevelField(oldx, oldy);
+
+ return;
+ }
+#endif
}
else if (element == EL_BLOCKED)
{
void SplashAcid(int x, int y)
{
+#if 1
+ if (IN_LEV_FIELD(x - 1, y - 1) && IS_FREE(x - 1, y - 1) &&
+ (!IN_LEV_FIELD(x - 1, y - 2) ||
+ !CAN_FALL(MovingOrBlocked2Element(x - 1, y - 2))))
+ Feld[x - 1][y - 1] = EL_ACID_SPLASH_LEFT;
+
+ if (IN_LEV_FIELD(x + 1, y - 1) && IS_FREE(x + 1, y - 1) &&
+ (!IN_LEV_FIELD(x + 1, y - 2) ||
+ !CAN_FALL(MovingOrBlocked2Element(x + 1, y - 2))))
+ Feld[x + 1][y - 1] = EL_ACID_SPLASH_RIGHT;
+
+ PlayLevelSound(x, y, SND_ACID_SPLASHING);
+#else
+ /* input: position of element entering acid (obsolete) */
+
int element = Feld[x][y];
+ if (!IN_LEV_FIELD(x, y + 1) || Feld[x][y + 1] != EL_ACID)
+ return;
+
if (element != EL_ACID_SPLASH_LEFT &&
element != EL_ACID_SPLASH_RIGHT)
{
PlayLevelSound(x, y, SND_ACID_SPLASHING);
- if (IN_LEV_FIELD(x-1, y) && IS_FREE(x-1, y) &&
- (!IN_LEV_FIELD(x-1, y-1) ||
- !CAN_FALL(MovingOrBlocked2Element(x-1, y-1))))
- Feld[x-1][y] = EL_ACID_SPLASH_LEFT;
+ if (IN_LEV_FIELD(x - 1, y) && IS_FREE(x - 1, y) &&
+ (!IN_LEV_FIELD(x - 1, y - 1) ||
+ !CAN_FALL(MovingOrBlocked2Element(x - 1, y - 1))))
+ Feld[x - 1][y] = EL_ACID_SPLASH_LEFT;
- if (IN_LEV_FIELD(x+1, y) && IS_FREE(x+1, y) &&
- (!IN_LEV_FIELD(x+1, y-1) ||
- !CAN_FALL(MovingOrBlocked2Element(x+1, y-1))))
- Feld[x+1][y] = EL_ACID_SPLASH_RIGHT;
+ if (IN_LEV_FIELD(x + 1, y) && IS_FREE(x + 1, y) &&
+ (!IN_LEV_FIELD(x + 1, y - 1) ||
+ !CAN_FALL(MovingOrBlocked2Element(x + 1, y - 1))))
+ Feld[x + 1][y] = EL_ACID_SPLASH_RIGHT;
}
+#endif
}
static void InitBeltMovement()
if (!lastline && smashed == EL_ACID) /* element falls into acid */
{
- SplashAcid(x, y);
+ SplashAcid(x, y + 1);
return;
}
{
TestIfBadThingTouchesOtherBadThing(x, y);
- if (ENEMY_CAN_ENTER_FIELD(right_x, right_y))
+ if (ENEMY_CAN_ENTER_FIELD(element, right_x, right_y))
MovDir[x][y] = right_dir;
- else if (!ENEMY_CAN_ENTER_FIELD(move_x, move_y))
+ else if (!ENEMY_CAN_ENTER_FIELD(element, move_x, move_y))
MovDir[x][y] = left_dir;
if (element == EL_BUG && MovDir[x][y] != old_move_dir)
{
TestIfBadThingTouchesOtherBadThing(x, y);
- if (ENEMY_CAN_ENTER_FIELD(left_x, left_y))
+ if (ENEMY_CAN_ENTER_FIELD(element, left_x, left_y))
MovDir[x][y] = left_dir;
- else if (!ENEMY_CAN_ENTER_FIELD(move_x, move_y))
+ else if (!ENEMY_CAN_ENTER_FIELD(element, move_x, move_y))
MovDir[x][y] = right_dir;
if ((element == EL_SPACESHIP ||
else if (CAN_FALL(element) && Feld[x][y + 1] == EL_ACID)
#endif
{
- SplashAcid(x, y);
+ SplashAcid(x, y + 1);
InitMovingField(x, y, MV_DOWN);
started_moving = TRUE;
}
#if 1
+#if 1
+ else if (CAN_MOVE_INTO_ACID(element) &&
+ IN_LEV_FIELD(newx, newy) && Feld[newx][newy] == EL_ACID &&
+ (MovDir[x][y] == MV_DOWN ||
+ game.engine_version > VERSION_IDENT(3,0,8,0)))
+#else
else if (CAN_MOVE_INTO_ACID(element) && MovDir[x][y] == MV_DOWN &&
IN_LEV_FIELD(newx, newy) && Feld[newx][newy] == EL_ACID)
-
+#endif
#else
else if ((element == EL_PENGUIN ||
MovDir[x][y] == MV_DOWN && Feld[newx][newy] == EL_ACID)
#endif
{
- SplashAcid(x, y);
+ SplashAcid(newx, newy);
Store[x][y] = EL_ACID;
}
else if (element == EL_PENGUIN && IN_LEV_FIELD(newx, newy))
AmoebaCnt[AmoebaNr[newx][newy]]--;
}
+#if 0
+ /* !!! test !!! */
+ if (IS_MOVING(newx, newy) || IS_BLOCKED(newx, newy))
+#else
if (IS_MOVING(newx, newy))
+#endif
+ {
RemoveMovingField(newx, newy);
+ }
else
{
Feld[newx][newy] = EL_EMPTY;
{
if (element == EL_ACID && dx == 0 && dy == 1)
{
- SplashAcid(jx, jy);
+ SplashAcid(new_jx, new_jy);
Feld[jx][jy] = EL_PLAYER_1;
InitMovingField(jx, jy, MV_DOWN);
Store[jx][jy] = EL_ACID;
InitElementPropertiesStatic();
#endif
+ /* important: after initialization in InitElementPropertiesStatic(), the
+ elements are not again initialized to a default value; therefore all
+ changes have to make sure that they leave the element with a defined
+ property (which means that conditional property changes must be set to
+ a reliable default value before) */
+
/* set all special, combined or engine dependent element properties */
for (i = 0; i < MAX_NUM_ELEMENTS; i++)
{
#endif
/* ---------- INACTIVE ------------------------------------------------- */
- if (i >= EL_CHAR_START && i <= EL_CHAR_END)
- SET_PROPERTY(i, EP_INACTIVE, TRUE);
+ SET_PROPERTY(i, EP_INACTIVE, (i >= EL_CHAR_START && i <= EL_CHAR_END));
/* ---------- WALKABLE, PASSABLE, ACCESSIBLE --------------------------- */
SET_PROPERTY(i, EP_WALKABLE, (IS_WALKABLE_OVER(i) ||
!IS_DIGGABLE(i) &&
!IS_COLLECTIBLE(i)));
+#if 1
/* ---------- PROTECTED ------------------------------------------------ */
if (IS_ACCESSIBLE_INSIDE(i))
SET_PROPERTY(i, EP_PROTECTED, TRUE);
+#endif
/* ---------- DRAGONFIRE_PROOF ----------------------------------------- */
if (IS_CUSTOM_ELEMENT(i))
{
+ /* these are additional properties which are initially false when set */
+
/* ---------- DONT_COLLIDE_WITH / DONT_RUN_INTO ---------------------- */
if (DONT_TOUCH(i))
SET_PROPERTY(i, EP_DONT_COLLIDE_WITH, TRUE);
IS_CUSTOM_ELEMENT(i)));
/* ---------- CAN_MOVE_INTO_ACID --------------------------------------- */
- if (getMoveIntoAcidProperty(&level, i))
- SET_PROPERTY(i, EP_CAN_MOVE_INTO_ACID, TRUE);
+ if (!IS_CUSTOM_ELEMENT(i))
+ SET_PROPERTY(i, EP_CAN_MOVE_INTO_ACID,getMoveIntoAcidProperty(&level,i));
/* ---------- SP_PORT -------------------------------------------------- */
SET_PROPERTY(i, EP_SP_PORT, (IS_SP_ELEMENT(i) &&
static struct GadgetInfo *tool_gadget[NUM_TOOL_BUTTONS];
static int request_gadget_id = -1;
+void DumpTile(int x, int y)
+{
+ int sx = SCREENX(x);
+ int sy = SCREENX(y);
+
+ printf_line("-", 79);
+ printf("Field Info: SCREEN(%d, %d), LEVEL(%d, %d)\n", sx, sy, x, y);
+ printf_line("-", 79);
+
+ if (!IN_LEV_FIELD(x, y))
+ {
+ printf("(not in level field)\n");
+ printf("\n");
+
+ return;
+ }
+
+ printf(" Feld: %d ['%s']\n", Feld[x][y],
+ element_info[Feld[x][y]].token_name);
+ printf(" Back: %d\n", Back[x][y]);
+ printf(" Store: %d\n", Store[x][y]);
+ printf(" Store2: %d\n", Store2[x][y]);
+ printf(" StorePlayer: %d\n", StorePlayer[x][y]);
+ printf(" MovPos: %d\n", MovPos[x][y]);
+ printf(" MovDir: %d\n", MovDir[x][y]);
+ printf(" MovDelay: %d\n", MovDelay[x][y]);
+ printf(" ChangeDelay: %d\n", ChangeDelay[x][y]);
+ printf(" GfxElement: %d\n", GfxElement[x][y]);
+ printf(" GfxAction: %d\n", GfxAction[x][y]);
+ printf(" GfxFrame: %d\n", GfxFrame[x][y]);
+ printf("\n");
+}
+
void SetDrawtoField(int mode)
{
if (mode == DRAW_BUFFERED && setup.soft_scrolling)
DrawScreenElementShifted(x, y, 0, MovPos[lx][ly], content, cut_mode);
if (content == EL_ACID)
- DrawLevelElementThruMask(lx, ly + 1, EL_ACID);
+ {
+ int dir = MovDir[lx][ly];
+ int newlx = lx + (dir == MV_LEFT ? -1 : dir == MV_RIGHT ? +1 : 0);
+ int newly = ly + (dir == MV_UP ? -1 : dir == MV_DOWN ? +1 : 0);
+
+ DrawLevelElementThruMask(newlx, newly, EL_ACID);
+ }
}
else if (IS_BLOCKED(lx, ly))
{