Fix saving of analyzed game
authorH.G. Muller <h.g.muller@hccnet.nl>
Thu, 7 Mar 2013 16:52:02 +0000 (17:52 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Thu, 2 May 2013 12:54:30 +0000 (14:54 +0200)
Anotated games after batch-mode Analyze Game were not auto-saved,
because the GameEnds() call supposed to do that was called with a NULL
argument for resultDetails. Now it is called with the resultDetails as
pre-existing in the gameInfo, or an empty string if none exist. This bug
was masked by the fact that in standard game ends (mate, etc.) the
analyzing engine would declare game end and supply a message.
 Also makes a distinction between Analyze Game and regular Analyze mode
when resuming analysis after loading a game; only the former now would
trigger a batch analysis.

backend.c

index 0c555f9..b3c152e 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -11193,7 +11193,7 @@ AutoPlayOneMove ()
     if (currentMove >= forwardMostMove) {
       if(gameMode == AnalyzeFile) {
          if(appData.loadGameIndex == -1) {
-           GameEnds(EndOfFile, NULL, GE_FILE);
+           GameEnds(gameInfo.result, gameInfo.resultDetails ? gameInfo.resultDetails : "", GE_FILE);
           ScheduleDelayedEvent(AnalyzeNextGame, 10);
          } else {
           ExitAnalyzeMode(); SendToProgram("force\n", &first);
@@ -12439,10 +12439,12 @@ LoadGame (FILE *f, int gameNumber, char *title, int useList)
 
     HistorySet(parseList, backwardMostMove, forwardMostMove, currentMove-1);
 
-    if (oldGameMode == AnalyzeFile ||
-       oldGameMode == AnalyzeMode) {
+    if (oldGameMode == AnalyzeFile) {
       appData.loadGameIndex = -1; // [HGM] order auto-stepping through games
       AnalyzeFileEvent();
+    } else
+    if (oldGameMode == AnalyzeMode) {
+      AnalyzeFileEvent();
     }
 
     if(creatingBook) return TRUE;