rnd-19981130-1
[rocksndiamonds.git] / src / game.c
index e9f9d041c82b9475046f91eb1b1d7560e27b2006..8b5d2a79f7a5cc4bc6e2f5305540b9c45ad61c51 100644 (file)
@@ -238,9 +238,11 @@ void InitGame()
 
   network_player_action_received = FALSE;
 
+#ifndef MSDOS
   /* initial null action */
   if (network_playing)
     SendToServer_MovePlayer(MV_NO_MOVING);
+#endif
 
   ZX = ZY = -1;
 
@@ -427,20 +429,38 @@ void InitGame()
     }
   }
 
-  /* when in single player mode, eliminate all but the first active player */
-  if (!options.network && !setup.team_mode)
+  if (tape.playing)
+  {
+    /* when playing a tape, eliminate all players who do not participate */
+
+    for (i=0; i<MAX_PLAYERS; i++)
+    {
+      if (stored_player[i].active && !tape.player_participates[i])
+      {
+       struct PlayerInfo *player = &stored_player[i];
+       int jx = player->jx, jy = player->jy;
+
+       player->active = FALSE;
+       StorePlayer[jx][jy] = 0;
+       Feld[jx][jy] = EL_LEERRAUM;
+      }
+    }
+  }
+  else if (!options.network && !setup.team_mode)       /* && !tape.playing */
   {
+    /* when in single player mode, eliminate all but the first active player */
+
     for (i=0; i<MAX_PLAYERS; i++)
     {
       if (stored_player[i].active)
       {
        for (j=i+1; j<MAX_PLAYERS; j++)
        {
-         struct PlayerInfo *player = &stored_player[j];
-         int jx = player->jx, jy = player->jy;
-
-         if (player->active)
+         if (stored_player[j].active)
          {
+           struct PlayerInfo *player = &stored_player[j];
+           int jx = player->jx, jy = player->jy;
+
            player->active = FALSE;
            StorePlayer[jx][jy] = 0;
            Feld[jx][jy] = EL_LEERRAUM;
@@ -450,6 +470,14 @@ void InitGame()
     }
   }
 
+  /* when recording the game, store which players take part in the game */
+  if (tape.recording)
+  {
+    for (i=0; i<MAX_PLAYERS; i++)
+      if (stored_player[i].active)
+       tape.player_participates[i] = TRUE;
+  }
+
   if (options.verbose)
   {
     for (i=0; i<MAX_PLAYERS; i++)
@@ -713,8 +741,8 @@ boolean NewHiScore()
 
   LoadScore(level_nr);
 
-  if (!strcmp(setup.player_name, EMPTY_ALIAS) ||
-      local_player->score < highscore[MAX_SCORE_ENTRIES-1].Score) 
+  if (strcmp(setup.player_name, EMPTY_PLAYER_NAME) == 0 ||
+      local_player->score < highscore[MAX_SCORE_ENTRIES - 1].Score) 
     return -1;
 
   for (k=0; k<MAX_SCORE_ENTRIES; k++) 
@@ -3096,8 +3124,44 @@ void GameActions()
   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));
+  */
+
+  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)
   {
@@ -3107,8 +3171,10 @@ void GameActions()
 #endif
     */
 
+#ifndef MSDOS
     /* last chance to get network player actions without main loop delay */
     HandleNetworking();
+#endif
 
     if (game_status != PLAYING)
       return;
@@ -3150,8 +3216,10 @@ void GameActions()
       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;