Revert rollback changes, fix rollback when extra turn was taken during an opponent's turn.

This commit is contained in:
Quercitron 2016-10-31 02:51:40 +03:00
parent 43581cafa3
commit 75432f5b61
3 changed files with 53 additions and 7 deletions

View file

@ -572,7 +572,6 @@ public abstract class GameImpl implements Game, Serializable {
public void saveState(boolean bookmark) {
if (!simulation && gameStates != null) {
if (bookmark || saveGame) {
state.getPlayerList().setCurrent(playerList.get());
gameStates.save(state);
}
}
@ -678,7 +677,7 @@ public abstract class GameImpl implements Game, Serializable {
GameState restore = gameStates.rollback(stateNum);
if (restore != null) {
state.restore(restore);
playerList.setCurrent(state.getPlayerList().get());
playerList.setCurrent(state.getPlayerByOrderId());
}
}
}
@ -758,6 +757,7 @@ public abstract class GameImpl implements Game, Serializable {
if (!isPaused() && !gameOver(null)) {
playerList = state.getPlayerList(nextPlayerId);
Player playerByOrder = getPlayer(playerList.get());
state.setPlayerByOrderId(playerByOrder.getId());
while (!isPaused() && !gameOver(null)) {
playExtraTurns();
GameEvent event = new GameEvent(GameEvent.EventType.PLAY_TURN, null, null, playerByOrder.getId());
@ -768,6 +768,7 @@ public abstract class GameImpl implements Game, Serializable {
}
playExtraTurns();
playerByOrder = playerList.getNext(this);
state.setPlayerByOrderId(playerByOrder.getId());
}
}
if (gameOver(null) && !isSimulation()) {
@ -2820,7 +2821,7 @@ public abstract class GameImpl implements Game, Serializable {
if (restore != null) {
informPlayers(GameLog.getPlayerRequestColoredText("Player request: Rolling back to start of turn " + restore.getTurnNum()));
state.restoreForRollBack(restore);
playerList.setCurrent(state.getPlayerList().get());
playerList.setCurrent(state.getPlayerByOrderId());
// because restore uses the objects without copy each copy the state again
gameStatesRollBack.put(getTurnNum(), state.copy());
executingRollback = true;