+#if DEBUG
+ if (IS_BLOCKED(x,y))
+ {
+ int oldx,oldy;
+
+ Blocked2Moving(x,y,&oldx,&oldy);
+ if (!IS_MOVING(oldx,oldy))
+ {
+ printf("GameActions(): (BLOCKED=>MOVING) context corrupted!\n");
+ printf("GameActions(): BLOCKED: x = %d, y = %d\n",x,y);
+ printf("GameActions(): !MOVING: oldx = %d, oldy = %d\n",oldx,oldy);
+ printf("GameActions(): This should never happen!\n");
+ }
+ }
+#endif
+ }
+
+ for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
+ {
+ element = Feld[x][y];
+
+ if (IS_INACTIVE(element))
+ continue;
+
+ if (!IS_MOVING(x,y) && (CAN_FALL(element) || CAN_MOVE(element)))
+ {
+ StartMoving(x,y);
+
+ if (IS_GEM(element))
+ EdelsteinFunkeln(x,y);
+ }
+ else if (IS_MOVING(x,y))
+ ContinueMoving(x,y);
+ else if (element==EL_DYNAMIT || element==EL_DYNABOMB)
+ CheckDynamite(x,y);
+ else if (element==EL_EXPLODING)
+ Explode(x,y,Frame[x][y],EX_NORMAL);
+ else if (element==EL_AMOEBING)
+ AmoebeWaechst(x,y);
+ else if (IS_AMOEBALIVE(element))
+ AmoebeAbleger(x,y);
+ else if (element==EL_LIFE || element==EL_LIFE_ASYNC)
+ Life(x,y);
+ else if (element==EL_ABLENK_EIN)
+ Ablenk(x,y);
+ else if (element==EL_SALZSAEURE)
+ Blubber(x,y);
+ else if (element==EL_BLURB_LEFT || element==EL_BLURB_RIGHT)
+ Blurb(x,y);
+ else if (element==EL_CRACKINGNUT)
+ NussKnacken(x,y);
+ else if (element==EL_AUSGANG_ZU)
+ AusgangstuerPruefen(x,y);
+ else if (element==EL_AUSGANG_ACT)
+ AusgangstuerOeffnen(x,y);
+ else if (element==EL_AUSGANG_AUF)
+ AusgangstuerBlinken(x,y);
+ else if (element==EL_MAUERND)
+ MauerWaechst(x,y);
+ else if (element==EL_MAUER_LEBT)
+ MauerAbleger(x,y);
+ else if (element==EL_BURNING)
+ CheckForDragon(x,y);
+
+ if (SiebAktiv)
+ {
+ BOOL sieb = FALSE;
+ int jx = local_player->jx, jy = local_player->jy;
+
+ if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL ||
+ Store[x][y]==EL_SIEB_LEER)
+ {
+ SiebAktivieren(x, y, 1);
+ sieb = TRUE;
+ }
+ else if (element==EL_SIEB2_LEER || element==EL_SIEB2_VOLL ||
+ Store[x][y]==EL_SIEB2_LEER)
+ {
+ SiebAktivieren(x, y, 2);
+ sieb = TRUE;
+ }
+
+ /* play the element sound at the position nearest to the player */
+ if (sieb && ABS(x-jx)+ABS(y-jy) < ABS(sieb_x-jx)+ABS(sieb_y-jy))
+ {
+ sieb_x = x;
+ sieb_y = y;
+ }
+ }
+ }
+
+ if (SiebAktiv)
+ {
+ if (!(SiebAktiv%4))
+ PlaySoundLevel(sieb_x,sieb_y,SND_MIEP);
+ SiebAktiv--;
+ if (!SiebAktiv)
+ {
+ for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
+ {
+ element = Feld[x][y];
+ if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL)
+ {
+ Feld[x][y] = EL_SIEB_TOT;
+ DrawLevelField(x,y);
+ }
+ else if (element==EL_SIEB2_LEER || element==EL_SIEB2_VOLL)
+ {
+ Feld[x][y] = EL_SIEB2_TOT;
+ DrawLevelField(x,y);
+ }
+ }
+ }
+ }
+
+ if (TimeLeft>0 && TimeFrames>=(1000/GameFrameDelay) && !tape.pausing)
+ {
+ TimeFrames = 0;
+ TimeLeft--;
+
+ if (tape.recording || tape.playing)
+ DrawVideoDisplay(VIDEO_STATE_TIME_ON,level.time-TimeLeft);
+
+ if (TimeLeft<=10)
+ PlaySoundStereo(SND_GONG,PSND_MAX_RIGHT);
+
+ DrawText(DX_TIME,DY_TIME,int2str(TimeLeft,3),FS_SMALL,FC_YELLOW);
+
+ if (!TimeLeft)
+ for(i=0; i<MAX_PLAYERS; i++)
+ KillHero(&stored_player[i]);
+ }
+
+ DrawAllPlayers();
+}
+
+static BOOL AllPlayersInSight(struct PlayerInfo *player, int x, int y)
+{
+ int min_x = x, min_y = y, max_x = x, max_y = y;
+ int i;
+
+ for(i=0; i<MAX_PLAYERS; i++)
+ {
+ int jx = stored_player[i].jx, jy = stored_player[i].jy;
+
+ if (!stored_player[i].active || stored_player[i].gone ||
+ &stored_player[i] == player)
+ continue;
+
+ min_x = MIN(min_x, jx);
+ min_y = MIN(min_y, jy);
+ max_x = MAX(max_x, jx);
+ max_y = MAX(max_y, jy);
+ }
+
+ return(max_x - min_x < SCR_FIELDX && max_y - min_y < SCR_FIELDY);
+}
+
+static BOOL AllPlayersInVisibleScreen()
+{
+ int i;
+
+ for(i=0; i<MAX_PLAYERS; i++)
+ {
+ int jx = stored_player[i].jx, jy = stored_player[i].jy;
+
+ if (!stored_player[i].active || stored_player[i].gone)
+ continue;
+
+ if (!IN_VIS_FIELD(SCREENX(jx), SCREENY(jy)))
+ return(FALSE);
+ }
+
+ return(TRUE);
+}
+
+void ScrollLevel(int dx, int dy)
+{
+ int softscroll_offset = (soft_scrolling_on ? TILEX : 0);
+ int x,y;
+
+ /*
+ ScreenGfxPos = local_player->GfxPos;
+ */
+
+ XCopyArea(display,drawto_field,drawto_field,gc,
+ FX + TILEX*(dx==-1) - softscroll_offset,
+ FY + TILEY*(dy==-1) - softscroll_offset,
+ SXSIZE - TILEX*(dx!=0) + 2*softscroll_offset,
+ SYSIZE - TILEY*(dy!=0) + 2*softscroll_offset,
+ FX + TILEX*(dx==1) - softscroll_offset,
+ FY + TILEY*(dy==1) - softscroll_offset);
+
+ if (dx)
+ {
+ x = (dx==1 ? BX1 : BX2);
+ for(y=BY1; y<=BY2; y++)
+ DrawScreenField(x,y);
+ }
+ if (dy)
+ {
+ y = (dy==1 ? BY1 : BY2);
+ for(x=BX1; x<=BX2; x++)
+ DrawScreenField(x,y);
+ }
+
+ redraw_mask |= REDRAW_FIELD;
+}
+
+BOOL MoveFigureOneStep(struct PlayerInfo *player,
+ int dx, int dy, int real_dx, int real_dy)
+{
+ int jx = player->jx, jy = player->jy;
+ int new_jx = jx+dx, new_jy = jy+dy;
+ int element;
+ int can_move;
+
+ if (player->gone || (!dx && !dy))
+ return(MF_NO_ACTION);
+
+ player->MovDir = (dx < 0 ? MV_LEFT :
+ dx > 0 ? MV_RIGHT :
+ dy < 0 ? MV_UP :
+ dy > 0 ? MV_DOWN : MV_NO_MOVING);
+
+ if (!IN_LEV_FIELD(new_jx,new_jy))
+ return(MF_NO_ACTION);
+
+ if (!networking && !AllPlayersInSight(player, new_jx,new_jy))
+ return(MF_NO_ACTION);
+
+ element = MovingOrBlocked2Element(new_jx,new_jy);
+
+ if (DONT_GO_TO(element))
+ {
+ if (element==EL_SALZSAEURE && dx==0 && dy==1)
+ {
+ Blurb(jx,jy);
+ Feld[jx][jy] = EL_SPIELFIGUR;
+ InitMovingField(jx,jy,MV_DOWN);
+ Store[jx][jy] = EL_SALZSAEURE;
+ ContinueMoving(jx,jy);
+ BuryHero(player);
+ }
+ else
+ KillHero(player);
+
+ return(MF_MOVING);
+ }
+
+ can_move = DigField(player, new_jx,new_jy, real_dx,real_dy, DF_DIG);
+ if (can_move != MF_MOVING)
+ return(can_move);
+
+ StorePlayer[jx][jy] = 0;
+ player->last_jx = jx;
+ player->last_jy = jy;
+ jx = player->jx = new_jx;
+ jy = player->jy = new_jy;
+ StorePlayer[jx][jy] = EL_SPIELER1 + player->nr;
+
+ player->MovPos = (dx > 0 || dy > 0 ? -1 : 1) * 7*TILEX/8;
+
+ ScrollFigure(player, SCROLL_INIT);
+
+ return(MF_MOVING);