+ }
+}
+
+void GameActions()
+{
+ static unsigned long action_delay = 0;
+ unsigned long action_delay_value;
+ int sieb_x = 0, sieb_y = 0;
+ int i, x, y, element;
+ byte *recorded_player_action;
+ byte summarized_player_action = 0;
+
+ if (game_status != PLAYING)
+ return;
+
+ action_delay_value =
+ (tape.playing && tape.fast_forward ? FfwdFrameDelay : GameFrameDelay);
+
+ /*
+ if (tape.playing && tape.fast_forward)
+ {
+ char buf[100];
+
+ sprintf(buf, "FFWD: %ld ms", action_delay_value);
+ print_debug(buf);
+ }
+ */
+
+
+ /* main game synchronization point */
+
+
+
+
+#if 1
+ WaitUntilDelayReached(&action_delay, action_delay_value);
+#else
+
+ while (!DelayReached(&action_delay, action_delay_value))
+ {
+ char buf[100];
+
+ sprintf(buf, "%ld %ld %ld",
+ Counter(), action_delay, action_delay_value);
+ print_debug(buf);
+ }
+ print_debug("done");
+
+#endif
+
+
+
+
+ if (network_playing && !network_player_action_received)
+ {
+ /*
+#ifdef DEBUG
+ printf("DEBUG: try to get network player actions in time\n");
+#endif
+ */
+
+#ifndef MSDOS
+ /* last chance to get network player actions without main loop delay */
+ HandleNetworking();
+#endif
+
+ if (game_status != PLAYING)
+ return;
+
+ if (!network_player_action_received)
+ {
+ /*
+#ifdef DEBUG
+ printf("DEBUG: failed to get network player actions in time\n");
+#endif
+ */
+ return;
+ }
+ }
+
+
+ /*
+ if (tape.pausing || (tape.playing && !TapePlayDelay()))
+ return;
+ else if (tape.recording)
+ TapeRecordDelay();
+ */
+
+ if (tape.pausing)
+ return;
+
+ if (tape.playing)
+ TapePlayDelay();
+ else if (tape.recording)
+ TapeRecordDelay();
+
+ recorded_player_action = (tape.playing ? TapePlayAction() : NULL);
+
+ for (i=0; i<MAX_PLAYERS; i++)
+ {
+ summarized_player_action |= stored_player[i].action;
+
+ if (!network_playing)
+ stored_player[i].effective_action = stored_player[i].action;
+ }
+
+#ifndef MSDOS
+ if (network_playing)
+ SendToServer_MovePlayer(summarized_player_action);
+#endif
+
+ if (!options.network && !setup.team_mode)
+ local_player->effective_action = summarized_player_action;
+
+ for (i=0; i<MAX_PLAYERS; i++)
+ {
+ int actual_player_action = stored_player[i].effective_action;
+
+ if (recorded_player_action)
+ actual_player_action = recorded_player_action[i];
+
+ PlayerActions(&stored_player[i], actual_player_action);
+ ScrollFigure(&stored_player[i], SCROLL_GO_ON);
+ }
+
+ network_player_action_received = FALSE;
+
+ ScrollScreen(NULL, SCROLL_GO_ON);
+
+
+ /*
+ if (tape.pausing || (tape.playing && !TapePlayDelay()))
+ return;
+ else if (tape.recording)
+ TapeRecordDelay();
+ */
+
+
+
+
+
+#ifdef DEBUG
+ /*
+ if (TimeFrames == 0 && !local_player->gone)
+ {
+ extern unsigned int last_RND();
+
+ printf("DEBUG: %03d last RND was %d \t [state checksum is %d]\n",
+ level.time - TimeLeft,
+ last_RND(),
+ getStateCheckSum(level.time - TimeLeft));
+ }
+ */
+#endif
+
+
+
+#ifdef DEBUG
+ /*
+ if (GameFrameDelay >= 500)
+ printf("FrameCounter == %d\n", FrameCounter);
+ */
+#endif
+
+
+
+
+
+ FrameCounter++;
+ TimeFrames++;
+
+ for (y=0; y<lev_fieldy; y++) for (x=0; x<lev_fieldx; x++)
+ {
+ Stop[x][y] = FALSE;
+ if (JustHit[x][y]>0)
+ JustHit[x][y]--;
+
+#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 ||
+ element == EL_MAUER_X ||
+ element == EL_MAUER_Y ||
+ element == EL_MAUER_XY)
+ MauerAbleger(x, y);
+ else if (element == EL_BURNING)
+ CheckForDragon(x, y);
+ else if (element == EL_SP_TERMINAL)
+ DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL, 7, 12, ANIM_NORMAL);
+ else if (element == EL_SP_TERMINAL_ACTIVE)
+ DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 4, ANIM_NORMAL);