fixed solving level when playing multi-player games
authorHolger Schemel <info@artsoft.org>
Fri, 17 Aug 2018 09:08:37 +0000 (11:08 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 17 Aug 2018 09:25:14 +0000 (11:25 +0200)
Before, solving a level was broken in both local and network
multi-player games:

In local multi-player games, the level was only solved if the player
marked as "local player" (which is only one of all players in a level)
entered the exit (but not if any other player entered the exit). As an
additional bug, the level was *always* solved as soon as the "local
player" entered the exit, regardless if any other player was still on
the playfield.

In network multi-player games, the level was always solved for the
first player entering the exit (as this player is always the "local
player" in one of the participating network clients), while the game
was frozen on all other network clients (and had to be manually ended
by using the Escape key or stop button).

With this fix, multi-player games will always be solved (locally or on
all network clients) if the last player on the playfield has entered
the exit.

src/game.c

index 7076d52c6c70bfbb809c435d9ecd83d94929f8a7..4edcf7e8c16fe8cf0e9f902014b4f35c45a6832a 100644 (file)
@@ -12644,9 +12644,10 @@ void ScrollPlayer(struct PlayerInfo *player, int mode)
     {
       RemovePlayerWithCleanup(player);
 
     {
       RemovePlayerWithCleanup(player);
 
-      if (local_player->friends_still_needed == 0 ||
-         IS_SP_ELEMENT(Feld[jx][jy]))
-       PlayerWins(player);
+      if ((local_player->friends_still_needed == 0 ||
+          IS_SP_ELEMENT(Feld[jx][jy])) &&
+         AllPlayersGone)
+       PlayerWins(local_player);
     }
 
     /* this breaks one level: "machine", level 000 */
     }
 
     /* this breaks one level: "machine", level 000 */