worked on premove bug
[xboard.git] / winboard / wengineo.c
index 942f593..1c3238f 100644 (file)
@@ -3,22 +3,26 @@
  *\r
  * Author: Alessandro Scotti (Dec 2005)\r
  *\r
+ * Copyright 2005 Alessandro Scotti\r
+ *\r
  * ------------------------------------------------------------------------\r
- * This program is free software; you can redistribute it and/or modify\r
+ *\r
+ * GNU XBoard is free software: you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
+ * the Free Software Foundation, either version 3 of the License, or (at\r
+ * your option) any later version.\r
  *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
+ * GNU XBoard is distributed in the hope that it will be useful, but\r
+ * WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * General Public License for more details.\r
  *\r
  * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
- * ------------------------------------------------------------------------\r
- */\r
+ * along with this program. If not, see http://www.gnu.org/licenses/.  *\r
+ *\r
+ *------------------------------------------------------------------------\r
+ ** See the file ChangeLog for a revision history.  */\r
+\r
 #include "config.h"\r
 \r
 #include <windows.h> /* required for all Windows applications */\r
@@ -76,6 +80,8 @@ extern HWND hwndMain;
 \r
 extern WindowPlacement wpEngineOutput;\r
 \r
+extern BoardSize boardSize;\r
+\r
 /* Module variables */\r
 #define H_MARGIN            2\r
 #define V_MARGIN            2\r
@@ -117,9 +123,9 @@ typedef struct {
     int an_move_count;\r
 } EngineOutputData;\r
 \r
-static VerifyDisplayMode();\r
+static void VerifyDisplayMode();\r
 static void UpdateControls( EngineOutputData * ed );\r
-static SetEngineState( int which, int state, char * state_data );\r
+static void SetEngineState( int which, int state, char * state_data );\r
 \r
 // front end\r
 static HICON LoadIconEx( int id )\r
@@ -246,9 +252,9 @@ static void ResizeWindowControls( HWND hDlg, int mode )
 {\r
     RECT rc;\r
     int headerHeight = GetHeaderHeight();\r
-    int labelHeight = GetControlHeight( hDlg, IDC_EngineLabel1 );\r
-    int labelOffset = H_MARGIN + ICON_SIZE + H_MARGIN;\r
-    int labelDeltaY = ICON_SIZE - labelHeight;\r
+//    int labelHeight = GetControlHeight( hDlg, IDC_EngineLabel1 );\r
+//    int labelOffset = H_MARGIN + ICON_SIZE + H_MARGIN;\r
+//    int labelDeltaY = ICON_SIZE - labelHeight;\r
     int clientWidth;\r
     int clientHeight;\r
     int maxControlWidth;\r
@@ -337,6 +343,10 @@ LRESULT CALLBACK EngineOutputProc( HWND hDlg, UINT message, WPARAM wParam, LPARA
 \r
             ResizeWindowControls( hDlg, windowMode );\r
 \r
+           /* Set font */\r
+           SendDlgItemMessage( engineOutputDialog, IDC_EngineMemo1, WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0 ));\r
+           SendDlgItemMessage( engineOutputDialog, IDC_EngineMemo2, WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0 ));\r
+\r
             SetEngineState( 0, STATE_IDLE, "" );\r
             SetEngineState( 1, STATE_IDLE, "" );\r
         }\r
@@ -446,7 +456,7 @@ void DoClearMemo(int which)
 \r
 \r
 // back end, due to front-end wrapper for SetWindowText, and new SetIcon arguments\r
-static SetEngineState( int which, int state, char * state_data )\r
+static void SetEngineState( int which, int state, char * state_data )\r
 {\r
     int x_which = 1 - which;\r
 \r
@@ -537,7 +547,7 @@ void EngineOutputUpdate( FrontEndProgramStats * stats )
     if( clearMemo ) DoClearMemo(which);\r
 \r
     /* Update */\r
-    lastDepth[which] = depth;\r
+    lastDepth[which] = depth == 1 && ed.nodes == 0 ? 0 : depth; // [HGM] info-line kudge\r
     lastForwardMostMove[which] = forwardMostMove;\r
 \r
     if( ed.pv != 0 && ed.pv[0] == ' ' ) {\r
@@ -579,6 +589,7 @@ char GetEngineColor( int which )
             result = cps->twoMachinesColor[0];\r
             result = result == 'w' ? ENGINE_COLOR_WHITE : ENGINE_COLOR_BLACK;\r
             break;\r
+        default: ; // does not happen, but suppresses pedantic warnings\r
         }\r
     }\r
 \r
@@ -616,6 +627,7 @@ static int IsEnginePondering( int which )
             if( GetEngineColor( which ) != GetActiveEngineColor() ) result = TRUE;\r
         }\r
         break;\r
+    default: ; // does not happen, but suppresses pedantic warnings\r
     }\r
 \r
     return result;\r
@@ -632,7 +644,7 @@ static void SetDisplayMode( int mode )
 }\r
 \r
 // pure back end\r
-static VerifyDisplayMode()\r
+static void VerifyDisplayMode()\r
 {\r
     int mode;\r
 \r
@@ -682,7 +694,7 @@ static void SetEngineColorIcon( int which )
 // pure back end, now SetWindowText is called via wrapper DoSetWindowText\r
 static void UpdateControls( EngineOutputData * ed )\r
 {\r
-    int isPondering = FALSE;\r
+//    int isPondering = FALSE;\r
 \r
     char s_label[MAX_NAME_LENGTH + 32];\r
     \r
@@ -725,7 +737,7 @@ static void UpdateControls( EngineOutputData * ed )
         SetEngineState( ed->which, STATE_THINKING, "" );\r
     }\r
     else if( gameMode == AnalyzeMode || gameMode == AnalyzeFile\r
-         || gameMode == IcsObserving && appData.icsEngineAnalyze) { // [HGM] ICS-analyze\r
+         || (gameMode == IcsObserving && appData.icsEngineAnalyze)) { // [HGM] ICS-analyze\r
         char buf[64];\r
         int time_secs = ed->time / 100;\r
         int time_mins = time_secs / 60;\r
@@ -795,7 +807,8 @@ static void UpdateControls( EngineOutputData * ed )
         sprintf( s_time, "%d:%02d.%02d", time_secs / 60, time_secs % 60, time_cent );\r
 \r
         /* Put all together... */\r
-        sprintf( buf, "%3d\t%s\t%s\t%s\t", ed->depth, s_score, s_nodes, s_time );\r
+       if(ed->nodes == 0 && ed->score == 0 && ed->time == 0) sprintf( buf, "%3d\t", ed->depth ); else \r
+       sprintf( buf, "%3d\t%s\t%s\t%s\t", ed->depth, s_score, s_nodes, s_time );\r
 \r
         /* Add PV */\r
         buflen = strlen(buf);\r