rnd-19981101-1
authorHolger Schemel <info@artsoft.org>
Sun, 1 Nov 1998 22:11:34 +0000 (23:11 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:31:29 +0000 (10:31 +0200)
src/events.c
src/files.c
src/game.c

index a967230e3bb0f3d39c6bb2bb3341c0918a8e0a58..2eadeee60757b0a3e7d47ef6c30e82e30dfd9e50 100644 (file)
@@ -409,14 +409,14 @@ void HandleKey(KeySym key, int key_status)
       if (key_status == KEY_PRESSED)
       {
        if (network_playing)
       if (key_status == KEY_PRESSED)
       {
        if (network_playing)
-         local_player->potential_action |= key_action;
+         stored_player[pnr].potential_action |= key_action;
        else
          stored_player[pnr].action |= key_action;
       }
       else
       {
        if (network_playing)
        else
          stored_player[pnr].action |= key_action;
       }
       else
       {
        if (network_playing)
-         local_player->potential_action &= ~key_action;
+         stored_player[pnr].potential_action &= ~key_action;
        else
          stored_player[pnr].action &= ~key_action;
       }
        else
          stored_player[pnr].action &= ~key_action;
       }
@@ -894,9 +894,9 @@ static int HandleJoystickForAllPlayers()
     result |= joy_action;
 
     if (network_playing)
     result |= joy_action;
 
     if (network_playing)
-      local_player->potential_action |= joy_action;
+      stored_player[i].potential_action = joy_action;
     else
     else
-      stored_player[i].action |= joy_action;
+      stored_player[i].action = joy_action;
   }
 
   return result;
   }
 
   return result;
index 0de480e07354cc44929749acb9861785716a9b21..31ef77420ab43b6313fa39ce2c5f80db45fb62dd 100644 (file)
@@ -262,7 +262,7 @@ void LoadLevelTape(int level_nr)
 
     for(j=0; j<MAX_PLAYERS; j++)
     {
 
     for(j=0; j<MAX_PLAYERS; j++)
     {
-      if (levelrec_10 && j>0)
+      if (levelrec_10 && j > 0)
       {
        tape.pos[i].action[j] = MV_NO_MOVING;
        continue;
       {
        tape.pos[i].action[j] = MV_NO_MOVING;
        continue;
@@ -272,6 +272,34 @@ void LoadLevelTape(int level_nr)
 
     tape.pos[i].delay = fgetc(file);
 
 
     tape.pos[i].delay = fgetc(file);
 
+    if (levelrec_10)
+    {
+      /* eliminate possible diagonal moves in old tapes */
+      /* this is only for backward compatibility */
+
+      byte joy_dir[4] = { JOY_LEFT, JOY_RIGHT, JOY_UP, JOY_DOWN };
+      byte action = tape.pos[i].action[0];
+      int k, num_moves = 0;
+
+      for (k=0; k<4; k++)
+      {
+       if (action & joy_dir[k])
+       {
+         tape.pos[i + num_moves].action[0] = joy_dir[k];
+         if (num_moves > 0)
+           tape.pos[i + num_moves].delay = 0;
+         num_moves++;
+       }
+      }
+
+      if (num_moves > 1)
+      {
+       num_moves--;
+       i += num_moves;
+       tape.length += num_moves;
+      }
+    }
+
     if (feof(file))
       break;
   }
     if (feof(file))
       break;
   }
index 6d4c3da63f690c1609a5312b8785d0f0ff949774..08d980b2a3efae544677aaf7596e2cdb8eab1912 100644 (file)
@@ -156,7 +156,12 @@ void InitGame()
        int jx = player->jx, jy = player->jy;
 
        player->present = TRUE;
        int jx = player->jx, jy = player->jy;
 
        player->present = TRUE;
+
+       /*
        if (!network_playing || player->connected)
        if (!network_playing || player->connected)
+       */
+
+       if (!options.network || player->connected)
        {
          player->active = TRUE;
 
        {
          player->active = TRUE;
 
@@ -260,9 +265,6 @@ void InitGame()
 
     if (player->connected && !player->present)
     {
 
     if (player->connected && !player->present)
     {
-      printf("Oops!\n");
-
-
       for(j=0; j<MAX_PLAYERS; j++)
       {
        struct PlayerInfo *some_player = &stored_player[j];
       for(j=0; j<MAX_PLAYERS; j++)
       {
        struct PlayerInfo *some_player = &stored_player[j];
@@ -477,6 +479,9 @@ void GameWon()
   int hi_pos;
   int bumplevel = FALSE;
 
   int hi_pos;
   int bumplevel = FALSE;
 
+  if (local_player->MovPos)
+    return;
+
   local_player->LevelSolved = FALSE;
 
   if (TimeLeft)
   local_player->LevelSolved = FALSE;
 
   if (TimeLeft)
@@ -2809,6 +2814,7 @@ void PlayerActions(struct PlayerInfo *player, byte player_action)
 {
   static byte stored_player_action[MAX_PLAYERS];
   static int num_stored_actions = 0;
 {
   static byte stored_player_action[MAX_PLAYERS];
   static int num_stored_actions = 0;
+  static boolean save_tape_entry = FALSE;
   boolean moved = FALSE, snapped = FALSE, bombed = FALSE;
   int jx = player->jx, jy = player->jy;
   int left     = player_action & JOY_LEFT;
   boolean moved = FALSE, snapped = FALSE, bombed = FALSE;
   int jx = player->jx, jy = player->jy;
   int left     = player_action & JOY_LEFT;
@@ -2828,6 +2834,7 @@ void PlayerActions(struct PlayerInfo *player, byte player_action)
 
   if (player_action)
   {
 
   if (player_action)
   {
+    save_tape_entry = TRUE;
     player->frame_reset_delay = 0;
 
     if (button1)
     player->frame_reset_delay = 0;
 
     if (button1)
@@ -2846,12 +2853,15 @@ void PlayerActions(struct PlayerInfo *player, byte player_action)
 
       stored_player_action[player->index_nr] = player_action;
 
 
       stored_player_action[player->index_nr] = player_action;
 
+#if 0
       /* this allows cycled sequences of PlayerActions() */
       if (num_stored_actions >= MAX_PLAYERS)
       {
        TapeRecordAction(stored_player_action);
        num_stored_actions = 0;
       }
       /* this allows cycled sequences of PlayerActions() */
       if (num_stored_actions >= MAX_PLAYERS)
       {
        TapeRecordAction(stored_player_action);
        num_stored_actions = 0;
       }
+#endif
+
     }
     else if (tape.playing && snapped)
       SnapField(player, 0,0);                  /* stop snapping */
     }
     else if (tape.playing && snapped)
       SnapField(player, 0,0);                  /* stop snapping */
@@ -2864,13 +2874,21 @@ void PlayerActions(struct PlayerInfo *player, byte player_action)
       player->Frame = 0;
   }
 
       player->Frame = 0;
   }
 
+  if (tape.recording && num_stored_actions >= MAX_PLAYERS && save_tape_entry)
+  {
+    TapeRecordAction(stored_player_action);
+    num_stored_actions = 0;
+    save_tape_entry = FALSE;
+  }
+
   if (tape.playing && !tape.pausing && !player_action &&
       tape.counter < tape.length)
   {
     int next_joy =
       tape.pos[tape.counter].action[player->index_nr] & (JOY_LEFT|JOY_RIGHT);
 
   if (tape.playing && !tape.pausing && !player_action &&
       tape.counter < tape.length)
   {
     int next_joy =
       tape.pos[tape.counter].action[player->index_nr] & (JOY_LEFT|JOY_RIGHT);
 
-    if (next_joy == JOY_LEFT || next_joy == JOY_RIGHT)
+    if ((next_joy == JOY_LEFT || next_joy == JOY_RIGHT) &&
+       (player->MovDir != JOY_UP && player->MovDir != JOY_DOWN))
     {
       int dx = (next_joy == JOY_LEFT ? -1 : +1);
 
     {
       int dx = (next_joy == JOY_LEFT ? -1 : +1);
 
@@ -2933,15 +2951,32 @@ void GameActions()
   }
 
 
   }
 
 
+  /*
   if (tape.pausing || (tape.playing && !TapePlayDelay()))
     return;
   else if (tape.recording)
     TapeRecordDelay();
   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);
 
   if (network_playing)
 
   recorded_player_action = (tape.playing ? TapePlayAction() : NULL);
 
   if (network_playing)
-    SendToServer_MovePlayer(local_player->potential_action);
+  {
+    byte local_potential_action = 0;
+
+    for(i=0; i<MAX_PLAYERS; i++)
+      local_potential_action |= stored_player[i].potential_action;
+
+    SendToServer_MovePlayer(local_potential_action);
+  }
 
   for(i=0; i<MAX_PLAYERS; i++)
   {
 
   for(i=0; i<MAX_PLAYERS; i++)
   {
@@ -2958,6 +2993,15 @@ void GameActions()
 
   ScrollScreen(NULL, SCROLL_GO_ON);
 
 
   ScrollScreen(NULL, SCROLL_GO_ON);
 
+
+  /*
+  if (tape.pausing || (tape.playing && !TapePlayDelay()))
+    return;
+  else if (tape.recording)
+    TapeRecordDelay();
+  */
+
+
   FrameCounter++;
   TimeFrames++;
 
   FrameCounter++;
   TimeFrames++;
 
@@ -3246,6 +3290,25 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy)
   if (!FrameReached(&player->move_delay,MoveSpeed) && !tape.playing)
     return(FALSE);
 
   if (!FrameReached(&player->move_delay,MoveSpeed) && !tape.playing)
     return(FALSE);
 
+  if (player->MovPos)
+  {
+    /* should only happen if pre-1.0 tape recordings are played */
+    /* this is only for backward compatibility */
+
+#ifdef DEBUG
+    printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.0 LEVEL TAPES.\n");
+#endif
+
+    while (player->MovPos)
+    {
+      ScrollFigure(player, SCROLL_GO_ON);
+      ScrollScreen(NULL, SCROLL_GO_ON);
+      FrameCounter++;
+      DrawAllPlayers();
+      BackToFront();
+    }
+  }
+
   if (player->last_move_dir & (MV_LEFT | MV_RIGHT))
   {
     if (!(moved |= MoveFigureOneStep(player, 0,dy, dx,dy)))
   if (player->last_move_dir & (MV_LEFT | MV_RIGHT))
   {
     if (!(moved |= MoveFigureOneStep(player, 0,dy, dx,dy)))