- /* !!! FIX THIS (START) !!! */
- if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
- {
- byte *recorded_player_action;
- byte summarized_player_action = 0;
- byte tape_action[MAX_PLAYERS];
- int i;
-
-#if 1
- if (level.native_em_level->lev->home == 0) /* all players at home */
- {
- local_player->LevelSolved = TRUE;
- AllPlayersGone = TRUE;
-
- level.native_em_level->lev->home = -1;
- }
-
- if (local_player->LevelSolved)
- GameWon();
-
- if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
- TapeStop();
-
- if (game_status != GAME_MODE_PLAYING)
- return;
-#else
- if (level.native_em_level->lev->home == 0) /* all players at home */
- {
- if (local_player->LevelSolved)
- GameWon();
-
- if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
- TapeStop();
-
- if (game_status != GAME_MODE_PLAYING)
- return;
- }
-#endif
-
- if (level.native_em_level->ply[0]->alive == 0 &&
- level.native_em_level->ply[1]->alive == 0 &&
- level.native_em_level->ply[2]->alive == 0 &&
- level.native_em_level->ply[3]->alive == 0) /* all dead */
- AllPlayersGone = TRUE;
-
- if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
- TapeStop();
-
- /* --- game actions --- */
-
- if (tape.pausing)
- {
- /* don't use 100% CPU while in pause mode -- this should better be solved
- like in the R'n'D game engine! */
-
- Delay(10);
-
- return;
- }
-
- recorded_player_action = (tape.playing ? TapePlayAction() : NULL);
-
-#if 1
- if (tape.set_centered_player)
- {
- game.centered_player_nr_next = tape.centered_player_nr_next;
- game.set_centered_player = TRUE;
- }
-#endif
-
-#if 1
- /* !!! CHECK THIS (tape.pausing is always FALSE here!) !!! */
- if (recorded_player_action == NULL && tape.pausing)
- return;
-#endif
-
- 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;
- }
-
- if (!options.network && !setup.team_mode)
- local_player->effective_action = summarized_player_action;
-
- if (recorded_player_action != NULL)
- for (i = 0; i < MAX_PLAYERS; i++)
- stored_player[i].effective_action = recorded_player_action[i];
-
- for (i = 0; i < MAX_PLAYERS; i++)
- {
- tape_action[i] = stored_player[i].effective_action;
-
- /* !!! (this does not happen in the EM engine) !!! */
- if (tape.recording && tape_action[i] && !tape.player_participates[i])
- tape.player_participates[i] = TRUE; /* player just appeared from CE */
- }
-
- /* only save actions from input devices, but not programmed actions */
- if (tape.recording)
- TapeRecordAction(tape_action);
-
-#if 1
- {
- byte effective_action[MAX_PLAYERS];
-
- for (i = 0; i < MAX_PLAYERS; i++)
- effective_action[i] = stored_player[i].effective_action;
-
-
-#if 0
- printf("::: %s: ",
- tape.playing ? "PLAYING" :
- tape.recording ? "RECORDING" :
- "STOPPED");
-
- for (i = 1; i < MAX_PLAYERS; i++)
- if ((recorded_player_action && recorded_player_action[i] != 0) ||
- tape_action[i] != 0 ||
- effective_action[i] != 0)
- printf("::: -----------------> WARNING!\n");
-
- printf("::: %08d: %08x [%08x] [%08x]\n",
- FrameCounter,
- (recorded_player_action ? recorded_player_action[0] : -1),
- tape_action[0],
- effective_action[0]);
-#endif
-
-
- GameActions_EM(effective_action);
- }
-#else
- GameActions_EM(local_player->effective_action);
-#endif
-
- if (TimeFrames >= FRAMES_PER_SECOND)
- {
- TimeFrames = 0;
- TapeTime++;
-
- if (!level.use_step_counter)
- {
- TimePlayed++;
-
- if (TimeLeft > 0)
- {
- TimeLeft--;
-
- if (TimeLeft <= 10 && setup.time_limit)
- PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MIDDLE);
-
- DrawGameValue_Time(TimeLeft);
-
- if (!TimeLeft && setup.time_limit)
- level.native_em_level->lev->killed_out_of_time = TRUE;
- }
- else if (level.time == 0 && level.native_em_level->lev->home > 0)
- DrawGameValue_Time(TimePlayed);
-
- level.native_em_level->lev->time =
- (level.time == 0 ? TimePlayed : TimeLeft);
- }
-
- if (tape.recording || tape.playing)
- DrawVideoDisplay(VIDEO_STATE_TIME_ON, TapeTime);
- }
-
- FrameCounter++;
- TimeFrames++;
-
- BackToFront();
- }
- else
- {
- if (game.restart_level)
- StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
-
- if (local_player->LevelSolved)
- GameWon();
-
- if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
- TapeStop();
-
- GameActions();
- BackToFront();
-
- if (tape.auto_play && !tape.playing)
- AutoPlayTape(); /* continue automatically playing next tape */
- }
-}
-
-void StartGameActions(boolean init_network_game, boolean record_tape,
- long random_seed)
-{
-#if 1
- unsigned long new_random_seed = InitRND(random_seed);
-
- if (record_tape)
- TapeStartRecording(new_random_seed);
-#else
- if (record_tape)
- TapeStartRecording(random_seed);
-#endif
-
-#if defined(NETWORK_AVALIABLE)
- if (init_network_game)
- {
- SendToServer_StartPlaying();
-
- return;
- }
-#endif
-
- StopAnimation();
-
- game_status = GAME_MODE_PLAYING;
-
-#if 0
- InitRND(random_seed);
-#endif