rnd-20060318-1-src
authorHolger Schemel <info@artsoft.org>
Sat, 18 Mar 2006 15:07:22 +0000 (16:07 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:51:11 +0000 (10:51 +0200)
* fixed bug in multi-player movement with focus on both players

ChangeLog
src/conftime.h
src/game_em/graphics.c
src/game_em/synchro_1.c

index 817ca24ac44e0e43e8409853247159c6394e5db8..8c7cf6391ed05c9ea6e724dd20cb0f8a1463a986 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2006-03-18
+       * fixed bug in multi-player movement with focus on both players
+
 2006-03-14
        * added player focus switching to level tape recording and re-playing
 
index 46e25f2b3bfcb53bc26945d05d8502f92f781de2..ec52e6ca0bb12f91255db0ca9b1a4590f201d001 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2006-03-14 01:37]"
+#define COMPILE_DATE_STRING "[2006-03-18 15:44]"
index 3b18584c1b02312000e0f4220491cc887e7d4a5c..fbddeb2b9e685f76aa55be1c2b46893e2d7c75fc 100644 (file)
@@ -578,6 +578,34 @@ void DrawRelocatePlayer(struct PlayerInfo *player, boolean quick_relocation)
 }
 #endif
 
+static int getMaxCenterDistancePlayerNr(int center_x, int center_y)
+{
+  int max_dx = 0, max_dy = 0;
+  int player_nr = game_em.last_moving_player;
+  int i;
+
+  for (i = 0; i < MAX_PLAYERS; i++)
+  {
+    if (ply[i].alive)
+    {
+      int sx = PLAYER_SCREEN_X(i);
+      int sy = PLAYER_SCREEN_Y(i);
+
+      if (game_em.last_player_direction[i] != MV_NONE &&
+         (ABS(sx - center_x) > max_dx ||
+          ABS(sy - center_y) > max_dy))
+      {
+       max_dx = MAX(max_dx, ABS(sx - center_x));
+       max_dy = MAX(max_dy, ABS(sy - center_y));
+
+       player_nr = i;
+      }
+    }
+  }
+
+  return player_nr;
+}
+
 static void setMinimalPlayerBoundaries(int *sx1, int *sy1, int *sx2, int *sy2)
 {
   boolean num_checked_players = 0;
@@ -662,6 +690,11 @@ void RedrawPlayfield_EM(boolean force_redraw)
 #if 0
   boolean game.set_centered_player = getSetCenteredPlayer_EM();
   int game.centered_player_nr_next = getCenteredPlayerNr_EM();
+#endif
+#if 1
+  int player_nr = getMaxCenterDistancePlayerNr(screen_x, screen_y);
+#else
+  int player_nr = game_em.last_moving_player;
 #endif
   int offset = (setup.scroll_delay ? 3 : 0) * TILEX;
   int offset_x = offset;
@@ -720,8 +753,13 @@ void RedrawPlayfield_EM(boolean force_redraw)
     }
     else
     {
+#if 1
+      sx = PLAYER_SCREEN_X(player_nr);
+      sy = PLAYER_SCREEN_Y(player_nr);
+#else
       sx = PLAYER_SCREEN_X(game_em.last_moving_player);
       sy = PLAYER_SCREEN_Y(game_em.last_moving_player);
+#endif
     }
   }
   else
@@ -918,7 +956,9 @@ void RedrawPlayfield_EM(boolean force_redraw)
   else
   {
     /* prevent scrolling against the players move direction */
+#if 0
     int player_nr = game_em.last_moving_player;
+#endif
     int player_move_dir = game_em.last_player_direction[player_nr];
     int dx = SIGN(screen_x - screen_x_old);
     int dy = SIGN(screen_y - screen_y_old);
index c6f0067428dc59360b0189fab5b8d8acc594568d..48bccb9ba55e6b778b08c88a2743eb2b14473d9d 100644 (file)
@@ -452,6 +452,8 @@ static void check_player(struct PLAYER *ply)
   int anim = 0;
   int dx = 0, dy = 0;
 
+  game_em.last_player_direction[ply->num] = MV_NONE;
+
 #if 0
   printf("::: up == %d, down == %d, left == %d, right == %d, fire == %d [spin == %d, stick == %d]\n",
         ply->joy_n, ply->joy_s, ply->joy_w, ply->joy_e, ply->joy_fire,