diff --git a/DroidFish/src/org/petero/droidfish/DroidFish.java b/DroidFish/src/org/petero/droidfish/DroidFish.java index b121e10..d51f910 100644 --- a/DroidFish/src/org/petero/droidfish/DroidFish.java +++ b/DroidFish/src/org/petero/droidfish/DroidFish.java @@ -2852,9 +2852,8 @@ public class DroidFish extends Activity implements GUIInterface { blackTitleText.setText(headers.get("Black")); } handlerTimer.removeCallbacks(r); - if (nextUpdate > 0) { + if (nextUpdate > 0) handlerTimer.postDelayed(r, nextUpdate); - } } /** PngTokenReceiver implementation that renders PGN data for screen display. */ diff --git a/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java b/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java index 555855d..c02ed82 100644 --- a/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java +++ b/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java @@ -489,7 +489,7 @@ public class DroidChessController { long nextUpdate = 0; if (game.timeController.clockRunning()) { long t = game.currPos().whiteMove ? wTime : bTime; - nextUpdate = (t % 1000); + nextUpdate = t % 1000; if (nextUpdate < 0) nextUpdate += 1000; nextUpdate += 1; } diff --git a/DroidFish/src/org/petero/droidfish/gamelogic/Game.java b/DroidFish/src/org/petero/droidfish/gamelogic/Game.java index 197085e..4f1a6f6 100644 --- a/DroidFish/src/org/petero/droidfish/gamelogic/Game.java +++ b/DroidFish/src/org/petero/droidfish/gamelogic/Game.java @@ -169,8 +169,9 @@ public class Game { } private final void updateTimeControl(boolean discardElapsed) { - int move = currPos().fullMoveCounter; - boolean wtm = currPos().whiteMove; + Position currPos = currPos(); + int move = currPos.fullMoveCounter; + boolean wtm = currPos.whiteMove; if (discardElapsed || (move != timeController.currentMove) || (wtm != timeController.whiteToMove)) { int initialTime = timeController.getInitialTime(); int whiteBaseTime = tree.getRemainingTime(true, initialTime); @@ -178,7 +179,15 @@ public class Game { timeController.setCurrentMove(move, wtm, whiteBaseTime, blackBaseTime); } long now = System.currentTimeMillis(); - if (gamePaused || (getGameState() != GameState.ALIVE)) { + boolean stopTimer = gamePaused || (getGameState() != GameState.ALIVE); + if (!stopTimer) { + try { + if (TextIO.readFEN(TextIO.startPosFEN).equals(currPos)) + stopTimer = true; + } catch (ChessParseError e) { + } + } + if (stopTimer) { timeController.stopTimer(now); } else { timeController.startTimer(now);