rnd-20060319-1-src
authorHolger Schemel <info@artsoft.org>
Sun, 19 Mar 2006 12:37:56 +0000 (13:37 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:51:13 +0000 (10:51 +0200)
* added option to control only the focussed player with all input

12 files changed:
ChangeLog
src/conftime.h
src/events.c
src/files.c
src/game.c
src/game.h
src/game_em/game_em.h
src/game_em/input.c
src/libgame/system.h
src/screens.c
src/screens.h
src/tape.c

index 8c7cf6391ed05c9ea6e724dd20cb0f8a1463a986..d1937675ac111a0a1435334bf621fa792e5daa8d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2006-03-18
        * fixed bug in multi-player movement with focus on both players
+       * added option to control only the focussed player with all input
 
 2006-03-14
        * added player focus switching to level tape recording and re-playing
index ec52e6ca0bb12f91255db0ca9b1a4590f201d001..aaa38b74a156e4da788e00ea895ef013ca92f602 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2006-03-18 15:44]"
+#define COMPILE_DATE_STRING "[2006-03-19 02:11]"
index 49d3b1a0eca85bf8f8ba41602d0d06cfdcb99f65..b54623d4e030fbdff367497aad6f1788bbeb3df4 100644 (file)
@@ -171,7 +171,9 @@ void EventLoop(void)
        has its own synchronization and is CPU friendly, too */
 
     if (game_status == GAME_MODE_PLAYING)
+    {
       HandleGameActions();
+    }
     else
     {
       SyncDisplay();
index c9a6cfa8a0c1b27d481ee7b53dfc4d862e8099ca..0a514169af088775ddd38262b3df6a25f10ac617 100644 (file)
@@ -4951,14 +4951,15 @@ void SaveScore(int nr)
 #define SETUP_TOKEN_ASK_ON_ESCAPE              16
 #define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR       17
 #define SETUP_TOKEN_QUICK_SWITCH               18
-#define SETUP_TOKEN_GRAPHICS_SET               19
-#define SETUP_TOKEN_SOUNDS_SET                 20
-#define SETUP_TOKEN_MUSIC_SET                  21
-#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS    22
-#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS      23
-#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC       24
+#define SETUP_TOKEN_INPUT_ON_FOCUS             19
+#define SETUP_TOKEN_GRAPHICS_SET               20
+#define SETUP_TOKEN_SOUNDS_SET                 21
+#define SETUP_TOKEN_MUSIC_SET                  22
+#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS    23
+#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS      24
+#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC       25
 
-#define NUM_GLOBAL_SETUP_TOKENS                        25
+#define NUM_GLOBAL_SETUP_TOKENS                        26
 
 /* editor setup */
 #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH      0
@@ -5068,6 +5069,7 @@ static struct TokenInfo global_setup_tokens[] =
   { TYPE_SWITCH, &si.ask_on_escape,    "ask_on_escape"                 },
   { TYPE_SWITCH, &si.ask_on_escape_editor, "ask_on_escape_editor"      },
   { TYPE_SWITCH, &si.quick_switch,     "quick_player_switch"           },
+  { TYPE_SWITCH, &si.input_on_focus,   "input_on_focus"                },
   { TYPE_STRING, &si.graphics_set,     "graphics_set"                  },
   { TYPE_STRING, &si.sounds_set,       "sounds_set"                    },
   { TYPE_STRING, &si.music_set,                "music_set"                     },
@@ -5194,6 +5196,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->ask_on_escape = TRUE;
   si->ask_on_escape_editor = TRUE;
   si->quick_switch = FALSE;
+  si->input_on_focus = FALSE;
 
   si->graphics_set = getStringCopy(GFX_CLASSIC_SUBDIR);
   si->sounds_set = getStringCopy(SND_CLASSIC_SUBDIR);
index f23555b3e7c5c00a96646b29037896f82ba986ba..98751de41aaeca52086e4695ff2c67da64730a98 100644 (file)
@@ -9051,6 +9051,79 @@ static byte PlayerActions(struct PlayerInfo *player, byte player_action)
   }
 }
 
+static void CheckLevelTime()
+{
+  int i;
+
+  if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
+  {
+    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 (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 (TimeFrames >= FRAMES_PER_SECOND)
+  {
+    TimeFrames = 0;
+    TapeTime++;
+
+    for (i = 0; i < MAX_PLAYERS; i++)
+    {
+      struct PlayerInfo *player = &stored_player[i];
+
+      if (SHIELD_ON(player))
+      {
+       player->shield_normal_time_left--;
+
+       if (player->shield_deadly_time_left > 0)
+         player->shield_deadly_time_left--;
+      }
+    }
+
+    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)
+       {
+         if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
+           level.native_em_level->lev->killed_out_of_time = TRUE;
+         else
+           for (i = 0; i < MAX_PLAYERS; i++)
+             KillPlayer(&stored_player[i]);
+       }
+      }
+      else if (level.time == 0 && !AllPlayersGone) /* level w/o time limit */
+       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);
+  }
+}
+
 void AdvanceFrameAndPlayerCounters(int player_nr)
 {
   int i;
@@ -9102,108 +9175,86 @@ void AdvanceFrameAndPlayerCounters(int player_nr)
   }
 }
 
-void GameActions()
+void StartGameActions(boolean init_network_game, boolean record_tape,
+                     long random_seed)
 {
-  static unsigned long game_frame_delay = 0;
-  unsigned long game_frame_delay_value;
-  int magic_wall_x = 0, magic_wall_y = 0;
-  int i, x, y, element, graphic;
-  byte *recorded_player_action;
-  byte summarized_player_action = 0;
-  byte tape_action[MAX_PLAYERS];
-
-  if (game_status != GAME_MODE_PLAYING)
-    return;
+#if 1
+  unsigned long new_random_seed = InitRND(random_seed);
 
-  game_frame_delay_value =
-    (tape.playing && tape.fast_forward ? FfwdFrameDelay : GameFrameDelay);
+  if (record_tape)
+    TapeStartRecording(new_random_seed);
+#else
+  if (record_tape)
+    TapeStartRecording(random_seed);
+#endif
 
-  if (tape.playing && tape.warp_forward && !tape.pausing)
-    game_frame_delay_value = 0;
+#if defined(NETWORK_AVALIABLE)
+  if (init_network_game)
+  {
+    SendToServer_StartPlaying();
 
-  /* ---------- main game synchronization point ---------- */
+    return;
+  }
+#endif
 
-  WaitUntilDelayReached(&game_frame_delay, game_frame_delay_value);
+  StopAnimation();
 
-  InitPlayfieldScanModeVars();
+  game_status = GAME_MODE_PLAYING;
 
 #if 0
-  if (game.set_centered_player)
-  {
-    boolean all_players_fit_to_screen = checkIfAllPlayersFitToScreen_RND();
+  InitRND(random_seed);
+#endif
 
-    /* switching to "all players" only possible if all players fit to screen */
-    if (game.centered_player_nr_next == -1 && !all_players_fit_to_screen)
-    {
-      game.centered_player_nr_next = game.centered_player_nr;
-      game.set_centered_player = FALSE;
-    }
+  InitGame();
+}
 
-    /* do not switch focus to non-existing (or non-active) player */
-    if (game.centered_player_nr_next >= 0 &&
-       !stored_player[game.centered_player_nr_next].active)
-    {
-      game.centered_player_nr_next = game.centered_player_nr;
-      game.set_centered_player = FALSE;
-    }
-  }
+void GameActions()
+{
+  static unsigned long game_frame_delay = 0;
+  unsigned long game_frame_delay_value;
+  byte *recorded_player_action;
+  byte summarized_player_action = 0;
+  byte tape_action[MAX_PLAYERS];
+  int i;
 
-  if (game.set_centered_player &&
-      ScreenMovPos == 0)       /* screen currently aligned at tile position */
-  {
-#if 0
-    struct PlayerInfo *player;
-    int player_nr = game.centered_player_nr_next;
-#endif
-    int sx, sy;
+  if (game.restart_level)
+    StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
 
-    if (game.centered_player_nr_next == -1)
-    {
-      setScreenCenteredToAllPlayers(&sx, &sy);
-    }
-    else
+  if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
+  {
+    if (level.native_em_level->lev->home == 0) /* all players at home */
     {
-      sx = stored_player[game.centered_player_nr_next].jx;
-      sy = stored_player[game.centered_player_nr_next].jy;
+      local_player->LevelSolved = TRUE;
+      AllPlayersGone = TRUE;
+
+      level.native_em_level->lev->home = -1;
     }
 
-#if 0
-    player = &stored_player[player_nr];
+    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 (!player->active)
-      game.centered_player_nr_next = game.centered_player_nr;
+  if (local_player->LevelSolved)
+    GameWon();
 
-    sx = player->jx;
-    sy = player->jy;
-#endif
+  if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
+    TapeStop();
 
-#if 0
-    if (game.centered_player_nr != game.centered_player_nr_next)
-#endif
-    {
-#if 1
-      DrawRelocateScreen(sx, sy, MV_NONE, TRUE, setup.quick_switch);
-#else
-      DrawRelocatePlayer(player, setup.quick_switch);
-#endif
+  if (game_status != GAME_MODE_PLAYING)                /* status might have changed */
+    return;
 
-      game.centered_player_nr = game.centered_player_nr_next;
-    }
+  game_frame_delay_value =
+    (tape.playing && tape.fast_forward ? FfwdFrameDelay : GameFrameDelay);
 
-    game.set_centered_player = FALSE;
-  }
-#endif
+  if (tape.playing && tape.warp_forward && !tape.pausing)
+    game_frame_delay_value = 0;
 
-#if USE_ONE_MORE_CHANGE_PER_FRAME
-  if (game.engine_version >= VERSION_IDENT(3,2,0,7))
-  {
-    SCAN_PLAYFIELD(x, y)
-    {
-      ChangeCount[x][y] = 0;
-      ChangeEvent[x][y] = -1;
-    }
-  }
-#endif
+  /* ---------- main game synchronization point ---------- */
+
+  WaitUntilDelayReached(&game_frame_delay, game_frame_delay_value);
 
   if (network_playing && !network_player_action_received)
   {
@@ -9227,13 +9278,97 @@ void GameActions()
 
   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;
   }
 
+  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 defined(NETWORK_AVALIABLE)
+  if (network_playing)
+    SendToServer_MovePlayer(summarized_player_action);
+#endif
+
+  if (!options.network && !setup.team_mode)
+    local_player->effective_action = summarized_player_action;
+
+  if (setup.team_mode && setup.input_on_focus && game.centered_player_nr != -1)
+  {
+    for (i = 0; i < MAX_PLAYERS; i++)
+      stored_player[i].effective_action =
+       (i == game.centered_player_nr ? summarized_player_action : 0);
+  }
+
+  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 can only happen in the R'n'D game engine) */
+    if (tape.recording && tape_action[i] && !tape.player_participates[i])
+      tape.player_participates[i] = TRUE;    /* player just appeared from CE */
+  }
+
+  /* only record actions from input devices, but not programmed actions */
+  if (tape.recording)
+    TapeRecordAction(tape_action);
+
+  if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
+  {
+    GameActions_EM_Main();
+  }
+  else
+  {
+    GameActions_RND();
+  }
+}
+
+void GameActions_EM_Main()
+{
+  byte effective_action[MAX_PLAYERS];
+  boolean warp_mode = (tape.playing && tape.warp_forward && !tape.pausing);
+  int i;
+
+  for (i = 0; i < MAX_PLAYERS; i++)
+    effective_action[i] = stored_player[i].effective_action;
+
+  GameActions_EM(effective_action, warp_mode);
+
+  CheckLevelTime();
+
+  AdvanceFrameAndPlayerCounters(-1);   /* advance counters for all players */
+}
+
+void GameActions_RND()
+{
+  int magic_wall_x = 0, magic_wall_y = 0;
+  int i, x, y, element, graphic;
+
+  InitPlayfieldScanModeVars();
+
+#if USE_ONE_MORE_CHANGE_PER_FRAME
+  if (game.engine_version >= VERSION_IDENT(3,2,0,7))
+  {
+    SCAN_PLAYFIELD(x, y)
+    {
+      ChangeCount[x][y] = 0;
+      ChangeEvent[x][y] = -1;
+    }
+  }
+#endif
+
+#if 1
   if (game.set_centered_player)
   {
     boolean all_players_fit_to_screen = checkIfAllPlayersFitToScreen_RND();
@@ -9257,10 +9392,6 @@ void GameActions()
   if (game.set_centered_player &&
       ScreenMovPos == 0)       /* screen currently aligned at tile position */
   {
-#if 0
-    struct PlayerInfo *player;
-    int player_nr = game.centered_player_nr_next;
-#endif
     int sx, sy;
 
     if (game.centered_player_nr_next == -1)
@@ -9273,71 +9404,13 @@ void GameActions()
       sy = stored_player[game.centered_player_nr_next].jy;
     }
 
-#if 0
-    player = &stored_player[player_nr];
-
-    if (!player->active)
-      game.centered_player_nr_next = game.centered_player_nr;
-
-    sx = player->jx;
-    sy = player->jy;
-#endif
-
-#if 0
-    if (game.centered_player_nr != game.centered_player_nr_next)
-#endif
-    {
-#if 1
-      DrawRelocateScreen(sx, sy, MV_NONE, TRUE, setup.quick_switch);
-#else
-      DrawRelocatePlayer(player, setup.quick_switch);
-#endif
-
-      game.centered_player_nr = game.centered_player_nr_next;
-    }
+    DrawRelocateScreen(sx, sy, MV_NONE, TRUE, setup.quick_switch);
 
+    game.centered_player_nr = game.centered_player_nr_next;
     game.set_centered_player = FALSE;
   }
 #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 defined(NETWORK_AVALIABLE)
-  if (network_playing)
-    SendToServer_MovePlayer(summarized_player_action);
-#endif
-
-  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;
-
-    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);
-
   for (i = 0; i < MAX_PLAYERS; i++)
   {
     int actual_player_action = stored_player[i].effective_action;
@@ -9816,48 +9889,7 @@ void GameActions()
     }
   }
 
-  if (TimeFrames >= FRAMES_PER_SECOND)
-  {
-    TimeFrames = 0;
-    TapeTime++;
-
-    for (i = 0; i < MAX_PLAYERS; i++)
-    {
-      struct PlayerInfo *player = &stored_player[i];
-
-      if (SHIELD_ON(player))
-      {
-       player->shield_normal_time_left--;
-
-       if (player->shield_deadly_time_left > 0)
-         player->shield_deadly_time_left--;
-      }
-    }
-
-    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)
-         for (i = 0; i < MAX_PLAYERS; i++)
-           KillPlayer(&stored_player[i]);
-      }
-      else if (level.time == 0 && !AllPlayersGone) /* level w/o time limit */
-       DrawGameValue_Time(TimePlayed);
-    }
-
-    if (tape.recording || tape.playing)
-      DrawVideoDisplay(VIDEO_STATE_TIME_ON, TapeTime);
-  }
+  CheckLevelTime();
 
   DrawAllPlayers();
   PlayAllPlayersSound();
index 927dade7f9365ca0316091e9fedcc68e2ca04427..dadb6735f86859b5aaa45d834090444c74254c80 100644 (file)
@@ -203,7 +203,12 @@ void Moving2Blocked(int, int, int *, int *);
 void Blocked2Moving(int, int, int *, int *);
 void DrawDynamite(int, int);
 
+void StartGameActions(boolean, boolean, long);
+
 void GameActions(void);
+void GameActions_EM_Main();
+void GameActions_RND();
+
 void ScrollLevel(int, int);
 
 void InitPlayLevelSound();
index 84fcfee62b57260c10b0db8ffebaf5abcaa67da8..7c512235f7004324f59a9f5915abf5e6d21559b8 100644 (file)
@@ -33,7 +33,7 @@ extern void em_close_all();
 
 extern void InitGameEngine_EM();
 #if 1
-extern void GameActions_EM(byte *);
+extern void GameActions_EM(byte *, boolean);
 #else
 extern void GameActions_EM(byte);
 #endif
index 172d69890351a55bcd60b84279d6911a071e3ea8..b54f5526f810ab557f9395b0880c9c5b9eafdade 100644 (file)
@@ -66,25 +66,10 @@ void InitGameEngine_EM()
   game_animscreen();
 }
 
-#if 1
-
-void GameActions_EM(byte action[MAX_PLAYERS])
+void GameActions_EM(byte action[MAX_PLAYERS], boolean warp_mode)
 {
-  static unsigned long game_frame_delay = 0;
-#if 1
-  unsigned long game_frame_delay_value = getGameFrameDelay_EM(20);
-#else
-  unsigned long game_frame_delay_value = getGameFrameDelay_EM(25);
-#endif
   int i;
 
-#if 0
-  /* this is done in screens.c/HandleGameActions() by calling BackToFront() */
-  XSync(display, False);       /* block until all graphics are drawn */
-#endif
-
-  WaitUntilDelayReached(&game_frame_delay, game_frame_delay_value);
-
   game_animscreen();
 
   RandomEM = RandomEM * 129 + 1;
@@ -107,88 +92,13 @@ void GameActions_EM(byte action[MAX_PLAYERS])
     synchro_3();
     sound_play();
 
-    if (game_frame_delay_value > 0)    /* do not redraw values in warp mode */
+    if (!warp_mode)            /* do not redraw values in warp mode */
       DrawGameDoorValues_EM();
   }
-
-#if 0
-  if (lev.time_initial == 0)
-    lev.time++;
-  else if (lev.time > 0)
-    lev.time--;
-#endif
-
-#if 0
-  if (lev.time_initial > 0 &&
-      lev.time > 0 && lev.time <= 50 && lev.time % 5 == 0 && setup.time_limit)
-    play_sound(-1, -1, SAMPLE_time);
-#endif
 }
 
-#else
-
-void GameActions_EM(byte action)
-{
-  static unsigned long game_frame_delay = 0;
-#if 1
-  unsigned long game_frame_delay_value = getGameFrameDelay_EM(20);
-#else
-  unsigned long game_frame_delay_value = getGameFrameDelay_EM(25);
-#endif
-
-#if 0
-  /* this is done in screens.c/HandleGameActions() by calling BackToFront() */
-  XSync(display, False);       /* block until all graphics are drawn */
-#endif
-
-  WaitUntilDelayReached(&game_frame_delay, game_frame_delay_value);
-
-  game_animscreen();
-
-  RandomEM = RandomEM * 129 + 1;
-
-  frame = (frame - 1) & 7;
-
-  readjoy(action);
-
-  UpdateEngineValues(screen_x / TILEX, screen_y / TILEY);
-
-  if (frame == 7)
-  {
-    synchro_1();
-    synchro_2();
-  }
-
-  if (frame == 6)
-  {
-    synchro_3();
-    sound_play();
-
-    if (game_frame_delay_value > 0)    /* do not redraw values in warp mode */
-      DrawGameDoorValues_EM();
-  }
-
-#if 0
-  if (lev.time_initial == 0)
-    lev.time++;
-  else if (lev.time > 0)
-    lev.time--;
-#endif
-
-#if 0
-  if (lev.time_initial > 0 &&
-      lev.time > 0 && lev.time <= 50 && lev.time % 5 == 0 && setup.time_limit)
-    play_sound(-1, -1, SAMPLE_time);
-#endif
-}
-
-#endif
-
-
 /* read input device for players */
 
-#if 1
-
 void readjoy(byte action, struct PLAYER *ply)
 {
   int north = 0, east = 0, south = 0, west = 0;
@@ -223,55 +133,3 @@ void readjoy(byte action, struct PLAYER *ply)
     ply->joy_w = west;
   }
 }
-
-#else
-
-void readjoy(byte action)
-{
-  int north = 0, east = 0, south = 0, west = 0;
-  int snap = 0, drop = 0;
-
-  if (action & JOY_LEFT)
-    west = 1;
-
-  if (action & JOY_RIGHT)
-    east = 1;
-
-  if (action & JOY_UP)
-    north = 1;
-
-  if (action & JOY_DOWN)
-    south = 1;
-
-  if (action & JOY_BUTTON_1)
-    snap = 1;
-
-  if (action & JOY_BUTTON_2)
-    drop = 1;
-
-#if 1
-  ply1.joy_snap = snap;
-  ply1.joy_drop = drop;
-  if (ply1.joy_stick || (north | east | south | west))
-  {
-    ply1.joy_n = north;
-    ply1.joy_e = east;
-    ply1.joy_s = south;
-    ply1.joy_w = west;
-  }
-
-#else
-
-  ply2.joy_snap = snap;
-  ply2.joy_drop = drop;
-  if (ply2.joy_stick || (north | east | south | west))
-  {
-    ply2.joy_n = north;
-    ply2.joy_e = east;
-    ply2.joy_s = south;
-    ply2.joy_w = west;
-  }
-#endif
-}
-
-#endif
index 128726a610b96312960353c8baac1594b04e4fcf..fd34af8218c44be51e8e78d797d8b385d5147e89 100644 (file)
 #define KEY_BUTTON             (KEY_BUTTON_1 | KEY_BUTTON_2)
 #define KEY_ACTION             (KEY_MOTION | KEY_BUTTON)
 
-#define SET_FOCUS              (1 << BIT_SET_FOCUS)
+#define KEY_SET_FOCUS          (1 << BIT_SET_FOCUS)
 
 #define MV_DIR_FROM_BIT(x)     ((x) < NUM_DIRECTIONS ? 1 << (x) :        \
                                 (x) == MV_BIT_UPLEFT    ? MV_UPLEFT    : \
@@ -704,6 +704,7 @@ struct SetupInfo
   boolean ask_on_escape;
   boolean ask_on_escape_editor;
   boolean quick_switch;
+  boolean input_on_focus;
 
   char *graphics_set;
   char *sounds_set;
index fd78deb5d491bdd1122b4b9e70f2410bf15f3cdc..e5f0e6da1eecaee7f7a72b41ac23dea97efab15a 100644 (file)
@@ -2052,6 +2052,7 @@ static struct TokenInfo setup_info_main[] =
 static struct TokenInfo setup_info_game[] =
 {
   { TYPE_SWITCH,       &setup.team_mode,       "Team-Mode (Multi-Player):" },
+  { TYPE_YES_NO,       &setup.input_on_focus,  "Only Move Focussed Player:" },
   { TYPE_SWITCH,       &setup.handicap,        "Handicap:"             },
   { TYPE_SWITCH,       &setup.skip_levels,     "Skip Unsolved Levels:" },
   { TYPE_SWITCH,       &setup.time_limit,      "Time Limit:"           },
@@ -3131,231 +3132,10 @@ void HandleGameActions()
   if (game_status != GAME_MODE_PLAYING)
     return;
 
-  /* !!! 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
+  GameActions();       /* main game loop */
 
-  InitGame();
+  if (tape.auto_play && !tape.playing)
+    AutoPlayTape();    /* continue automatically playing next tape */
 }
 
 /* ---------- new screen button stuff -------------------------------------- */
index 58ea5ddbb4cff8b88b54e85b90d6058032749ece..949267f001e0586a8b9e2ffd078ca0648785d53a 100644 (file)
@@ -32,8 +32,6 @@ void HandleSetupScreen(int, int, int, int, int);
 void HandleTypeName(int, Key);
 void HandleGameActions(void);
 
-void StartGameActions(boolean, boolean, long);
-
 void CreateScreenGadgets();
 void FreeScreenGadgets();
 
index becd0ad9affd199b714e7c3c663ede2383c65331..2f912cff26e45a63c98338504939b5d6e0a9d964 100644 (file)
@@ -613,7 +613,7 @@ void TapeRecordAction(byte action_raw[MAX_PLAYERS])
     for (i = 0; i < MAX_PLAYERS; i++)
       if (tape.centered_player_nr_next == i ||
          tape.centered_player_nr_next == -1)
-       action[i] |= SET_FOCUS;
+       action[i] |= KEY_SET_FOCUS;
 
     tape.set_centered_player = FALSE;
   }
@@ -803,14 +803,14 @@ byte *TapePlayAction()
 
   for (i = 0; i < MAX_PLAYERS; i++)
   {
-    if (action[i] & SET_FOCUS)
+    if (action[i] & KEY_SET_FOCUS)
     {
       tape.set_centered_player = TRUE;
       tape.centered_player_nr_next =
        (tape.centered_player_nr_next == -999 ? i : -1);
     }
 
-    action[i] &= ~SET_FOCUS;
+    action[i] &= ~KEY_SET_FOCUS;
   }
 
   tape.delay_played++;