* Fixed a problem with UNDO/rollback setting the wrong active player (fixes #2046).

This commit is contained in:
LevelX2 2016-07-03 18:14:18 +02:00
parent 1c0a4a7532
commit fd60e43a03
2 changed files with 4 additions and 3 deletions

View file

@ -558,6 +558,7 @@ public abstract class GameImpl implements Game, Serializable {
public void saveState(boolean bookmark) { public void saveState(boolean bookmark) {
if (!simulation && gameStates != null) { if (!simulation && gameStates != null) {
if (bookmark || saveGame) { if (bookmark || saveGame) {
state.getPlayerList().setCurrent(playerList.get());
gameStates.save(state); gameStates.save(state);
} }
} }
@ -663,7 +664,7 @@ public abstract class GameImpl implements Game, Serializable {
GameState restore = gameStates.rollback(stateNum); GameState restore = gameStates.rollback(stateNum);
if (restore != null) { if (restore != null) {
state.restore(restore); state.restore(restore);
playerList.setCurrent(state.getActivePlayerId()); playerList.setCurrent(state.getPlayerList().get());
} }
} }
} }
@ -2778,7 +2779,7 @@ public abstract class GameImpl implements Game, Serializable {
if (restore != null) { if (restore != null) {
informPlayers(GameLog.getPlayerRequestColoredText("Player request: Rolling back to start of turn " + restore.getTurnNum())); informPlayers(GameLog.getPlayerRequestColoredText("Player request: Rolling back to start of turn " + restore.getTurnNum()));
state.restoreForRollBack(restore); state.restoreForRollBack(restore);
playerList.setCurrent(state.getActivePlayerId()); playerList.setCurrent(state.getPlayerList().get());
// because restore uses the objects without copy each copy the state again // because restore uses the objects without copy each copy the state again
gameStatesRollBack.put(getTurnNum(), state.copy()); gameStatesRollBack.put(getTurnNum(), state.copy());
executingRollback = true; executingRollback = true;

View file

@ -204,7 +204,7 @@ public class GameState implements Serializable, Copyable<GameState> {
public void restore(GameState state) { public void restore(GameState state) {
this.activePlayerId = state.activePlayerId; this.activePlayerId = state.activePlayerId;
this.playerList.setCurrent(state.activePlayerId); this.playerList.setCurrent(state.playerList.get());
this.priorityPlayerId = state.priorityPlayerId; this.priorityPlayerId = state.priorityPlayerId;
this.stack = state.stack; this.stack = state.stack;
this.command = state.command; this.command = state.command;