Merge commit 'v4.3.16'
[xboard.git] / zippy.c
diff --git a/zippy.c b/zippy.c
index c77276f..9170000 100644 (file)
--- a/zippy.c
+++ b/zippy.c
@@ -88,13 +88,16 @@ extern char *getenv();
 #include "backend.h"\r
 #include "backendz.h"\r
 \r
-char *SendMoveToBookUser P((int nr, ChessProgramState *cps, int initial)); // [HGM] book
-
+char *SendMoveToBookUser P((int nr, ChessProgramState *cps, int initial)); // [HGM] book\r
+\r
 static char zippyPartner[MSG_SIZ];\r
 static char zippyLastOpp[MSG_SIZ];\r
 static int zippyConsecGames;\r
 static time_t zippyLastGameEnd;\r
 \r
+extern void mysrandom(unsigned int seed);\r
+extern int myrandom(void);\r
+\r
 void ZippyInit()\r
 {\r
     char *p;\r
@@ -229,7 +232,8 @@ char *swifties[] = {
     "i enthuses:", "i entreats:", "i enunciates:", "i eulogizes:",\r
     "i exclaims:", "i execrates:", "i exhorts:", "i expatiates:",\r
     "i explains:", "i explicates:", "i explodes:", "i exposes:",\r
-    "i exposits:", "i expounds:", "i expresses:", "i extols:",\r
+    "i exposits:", "i expostulates: ",\r
+    "i expounds:", "i expresses:", "i extols:",\r
     "i exults:", "i fantasizes:", "i fibs:", "i filibusters:",\r
     "i flatters:", "i flutes:", "i fools:", "i free-associates:",\r
     "i fulminates:", "i gabbles:", "i gabs:", "i gasps:",\r
@@ -781,6 +785,9 @@ void ZippyHandleChallenge(srated, swild, sbase, sincrement, opponent)
     base = atoi(sbase);\r
     increment = atoi(sincrement);\r
 \r
+    /* [DM] If icsAnalyzeEngine active we don't accept automatic games */\r
+    if (appData.icsActive && appData.icsEngineAnalyze) return;\r
+\r
     /* If desired, you can insert more code here to decline matches\r
        based on rated, variant, base, and increment, but it is\r
        easier to use the ICS formula feature instead. */\r
@@ -877,8 +884,7 @@ int ZippyMatch(buf, i)
           before our own name. */\r
        if(star_match[8] == NULL || star_match[8][0] == 0) // [HGM] chessd: open-source ICS has file on next line\r
             ZippyHandleChallenge(star_match[4], star_match[5],\r
-                            star_match[6], star_match[7],\r
-                            StripHighlightAndTitle(star_match[0]));\r
+                            star_match[6], star_match[7],                           StripHighlightAndTitle(star_match[0]));\r
        else ZippyHandleChallenge(star_match[4], star_match[8],\r
                             star_match[6], star_match[7],\r
                             StripHighlightAndTitle(star_match[0]));\r
@@ -915,11 +921,20 @@ int ZippyMatch(buf, i)
        return TRUE;\r
     }\r
 \r
-    if (looking_at(buf, i, "offers you a draw")) {\r
-        if (first.sendDrawOffers && first.initDone) {\r
-           SendToProgram("draw\n", &first);\r
-       }\r
-       return TRUE;\r
+\r
+    if (ics_type == ICS_ICC) { // [DM]\r
+        if (looking_at(buf, i, "Your opponent offers you a draw")) {\r
+            if (first.sendDrawOffers && first.initDone)\r
+                SendToProgram("draw\n", &first);\r
+            return TRUE;\r
+        }\r
+    } else {\r
+        if (looking_at(buf, i, "offers you a draw")) {\r
+            if (first.sendDrawOffers && first.initDone) {\r
+                SendToProgram("draw\n", &first);\r
+            }\r
+            return TRUE;\r
+        }\r
     }\r
 \r
     if (looking_at(buf, i, "requests that the game be aborted") ||\r
@@ -966,7 +981,7 @@ void ZippyFirstBoard(moveNum, basetime, increment)
     char buf[MSG_SIZ];\r
     int w, b;\r
     char *opp = (gameMode==IcsPlayingWhite ? gameInfo.black : gameInfo.white);\r
-    Boolean sentPos = FALSE;
+    Boolean sentPos = FALSE;\r
     char *bookHit = NULL; // [HGM] book\r
 \r
     if (!first.initDone) {\r
@@ -1108,18 +1123,18 @@ void ZippyFirstBoard(moveNum, basetime, increment)
            /* Nothing needs to be done here */\r
        }       \r
     }\r
-
-    if(bookHit) { // [HGM] book: simulate book reply
-       static char bookMove[MSG_SIZ]; // a bit generous?
-
-       programStats.depth = programStats.nodes = programStats.time = 
-       programStats.score = programStats.got_only_move = 0;
-       sprintf(programStats.movelist, "%s (xbook)", bookHit);
-
-       strcpy(bookMove, "move ");
-       strcat(bookMove, bookHit);
-       HandleMachineMove(bookMove, &first);
-    }
+\r
+    if(bookHit) { // [HGM] book: simulate book reply\r
+       static char bookMove[MSG_SIZ]; // a bit generous?\r
+\r
+       programStats.depth = programStats.nodes = programStats.time = \r
+       programStats.score = programStats.got_only_move = 0;\r
+       sprintf(programStats.movelist, "%s (xbook)", bookHit);\r
+\r
+       strcpy(bookMove, "move ");\r
+       strcat(bookMove, bookHit);\r
+       HandleMachineMove(bookMove, &first);\r
+    }\r
 }\r
 \r
 \r