fixed bug with using too large scroll delay value on smaller playfields
[rocksndiamonds.git] / src / game.c
index 2dcc07a496969b3782f16f9908c60e1d5106cc65..ad2f231f641f92cc86eb124e2e8a91c4eed6eede 100644 (file)
@@ -12180,12 +12180,17 @@ void GameActions_RND(void)
   DrawAllPlayers();
   PlayAllPlayersSound();
 
-  if (local_player->show_envelope != 0 && (!local_player->active ||
-                                          local_player->MovPos == 0))
+  for (i = 0; i < MAX_PLAYERS; i++)
   {
-    ShowEnvelope(local_player->show_envelope - EL_ENVELOPE_1);
+    struct PlayerInfo *player = &stored_player[i];
 
-    local_player->show_envelope = 0;
+    if (player->show_envelope != 0 && (!player->active ||
+                                      player->MovPos == 0))
+    {
+      ShowEnvelope(player->show_envelope - EL_ENVELOPE_1);
+
+      player->show_envelope = 0;
+    }
   }
 
   // use random number generator in every frame to make it less predictable
@@ -12527,10 +12532,11 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy)
     }
     else
     {
-      int offset = game.scroll_delay_value;
+      int offset_raw = game.scroll_delay_value;
 
       if (jx != old_jx)                // player has moved horizontally
       {
+       int offset = MIN(offset_raw, (SCR_FIELDX - 2) / 2);
        int offset_x = offset * (player->MovDir == MV_LEFT ? +1 : -1);
        int new_scroll_x = jx - MIDPOSX + offset_x;
 
@@ -12551,6 +12557,7 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy)
       }
       else                     // player has moved vertically
       {
+       int offset = MIN(offset_raw, (SCR_FIELDY - 2) / 2);
        int offset_y = offset * (player->MovDir == MV_UP ? +1 : -1);
        int new_scroll_y = jy - MIDPOSY + offset_y;