From: Holger Schemel Date: Sun, 17 Jun 2018 09:23:55 +0000 (+0200) Subject: fixed selecting correct player in single player mode (after network gaming) X-Git-Tag: 4.1.1.0~112 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=7466541c01db2ed673eee2302cd3ede5a5fbdf5e;p=rocksndiamonds.git fixed selecting correct player in single player mode (after network gaming) When playing levels that contain more than one player in single player mode, selecting the actual player when starting the level worked correctly before only if the game was always played in single player mode since it was started. It did not work correctly in the following special case: There was a network multi-player game played before, but the other (remote) client has disconnected (quit the game), leaving the other client with a local player that might not be the first player. In this case, using the first active player (which could be the first player in the level) for the local player (which could be the second player, because the network client was started after the now disconnected client) would result in a broken player mapping, so the player in the game cannot be moved. This bugfix solves the problem by not using the first active player, but the local player. --- diff --git a/src/game.c b/src/game.c index 13634a2c..d37dee3a 100644 --- a/src/game.c +++ b/src/game.c @@ -3962,26 +3962,21 @@ void InitGame() } else if (!network.enabled && !game.team_mode) /* && !tape.playing */ { - /* when in single player mode, eliminate all but the first active player */ + /* when in single player mode, eliminate all but the local player */ for (i = 0; i < MAX_PLAYERS; i++) { - if (stored_player[i].active) + struct PlayerInfo *player = &stored_player[i]; + + if (player->active && player != local_player) { - for (j = i + 1; j < MAX_PLAYERS; j++) - { - if (stored_player[j].active) - { - struct PlayerInfo *player = &stored_player[j]; - int jx = player->jx, jy = player->jy; + int jx = player->jx, jy = player->jy; - player->active = FALSE; - player->present = FALSE; + player->active = FALSE; + player->present = FALSE; - StorePlayer[jx][jy] = 0; - Feld[jx][jy] = EL_EMPTY; - } - } + StorePlayer[jx][jy] = 0; + Feld[jx][jy] = EL_EMPTY; } } }