No clearing of Engine-Output memos on stat01
[xboard.git] / engineoutput.c
index 22b008c..f37b9c2 100644 (file)
@@ -28,7 +28,6 @@
 #include "config.h"
 
 #include <stdio.h>
-#include <malloc.h>
 
 #if STDC_HEADERS
 # include <stdlib.h>
@@ -70,6 +69,7 @@ static void UpdateControls( EngineOutputData * ed );
 static int  lastDepth[2] = { -1, -1 };
 static int  lastForwardMostMove[2] = { -1, -1 };
 static int  engineState[2] = { -1, -1 };
+static char lastLine[2][MSG_SIZ];
 
 #define MAX_VAR 400
 static int scores[MAX_VAR], textEnd[MAX_VAR], curDepth[2], nrVariations[2];
@@ -154,8 +154,14 @@ void SetProgramStats( FrontEndProgramStats * stats ) // now directly called by b
         ed.name = second.tidy;
     }
 
+    if( ed.pv != 0 && ed.pv[0] == ' ' ) {
+        if( strncmp( ed.pv, " no PV", 6 ) == 0 ) { /* Hack on hack! :-O */
+            ed.pv = "";
+        }
+    }
+
     /* Clear memo if needed */
-    if( lastDepth[which] > depth || (lastDepth[which] == depth && depth <= 1) ) {
+    if( lastDepth[which] > depth || (lastDepth[which] == depth && depth <= 1 && ed.pv[0]) ) { // no reason to clear if we won't add line
         clearMemo = TRUE;
     }
 
@@ -163,18 +169,18 @@ void SetProgramStats( FrontEndProgramStats * stats ) // now directly called by b
         clearMemo = TRUE;
     }
 
-    if( clearMemo ) { DoClearMemo(which); nrVariations[which] = 0; }
+    if( clearMemo ) {
+        DoClearMemo(which); nrVariations[which] = 0;
+        if(appData.ponderNextMove && lastLine[which][0]) {
+            InsertIntoMemo( which, lastLine[which], 0 );
+            InsertIntoMemo( which, "\n", 0 );
+        }
+    }
 
     /* Update */
     lastDepth[which] = depth == 1 && ed.nodes == 0 ? 0 : depth; // [HGM] info-line kudge
     lastForwardMostMove[which] = forwardMostMove;
 
-    if( ed.pv != 0 && ed.pv[0] == ' ' ) {
-        if( strncmp( ed.pv, " no PV", 6 ) == 0 ) { /* Hack on hack! :-O */
-            ed.pv = "";
-        }
-    }
-
     UpdateControls( &ed );
 }
 
@@ -476,6 +482,7 @@ static void UpdateControls( EngineOutputData * ed )
 
         /* Update memo */
         InsertIntoMemo( ed->which, buf, InsertionPoint(strlen(buf), ed) );
+        strncpy(lastLine[ed->which], buf, MSG_SIZ);
     }
 
     /* Colors */