updated copyright to reflect A. Scotte as copyright holder
[xboard.git] / zippy.c
diff --git a/zippy.c b/zippy.c
index 6d61ff7..9f5b2a8 100644 (file)
--- a/zippy.c
+++ b/zippy.c
@@ -1,11 +1,13 @@
 /*\r
  * zippy.c -- Implements Zippy the Pinhead chess player on ICS in XBoard\r
- * $Id: zippy.c,v 2.2 2003/11/25 05:25:20 mann Exp $\r
  *\r
  * Copyright 1991 by Digital Equipment Corporation, Maynard,\r
- * Massachusetts.  Enhancements Copyright\r
- * 1992-2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software\r
- * Foundation, Inc.\r
+ * Massachusetts. \r
+ *\r
+ * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,\r
+ * 2007, 2008, 2009 Free Software Foundation, Inc.\r
+ *\r
+ * Enhancements Copyright 2005 Alessandro Scotti\r
  *\r
  * The following terms apply to Digital Equipment Corporation's copyright\r
  * interest in XBoard:\r
@@ -92,9 +94,11 @@ extern char *getenv();
 #include "backendz.h"\r
 \r
 char *SendMoveToBookUser P((int nr, ChessProgramState *cps, int initial)); // [HGM] book\r
+void HandleMachineMove P((char *message, ChessProgramState *cps));\r
 \r
 static char zippyPartner[MSG_SIZ];\r
 static char zippyLastOpp[MSG_SIZ];\r
+static char zippyOffender[MSG_SIZ]; // [HGM] aborter\r
 static int zippyConsecGames;\r
 static time_t zippyLastGameEnd;\r
 \r
@@ -767,6 +771,8 @@ void ZippyGameEnd(result, resultDetails)
       SendToICS("\n");\r
     }\r
     zippyLastGameEnd = time(0);\r
+    if(forwardMostMove < appData.zippyShortGame) \r
+       strcpy(zippyOffender, zippyLastOpp); else zippyOffender[0] = 0; // [HGM] aborter\r
 }\r
 \r
 /*\r
@@ -803,7 +809,7 @@ void ZippyHandleChallenge(srated, swild, sbase, sincrement, opponent)
        return;\r
     }\r
     if (StrStr(appData.zippyVariants, varname) == NULL ||\r
-                (i=first.protocolVersion) != 1 && StrStr(first.variants, varname) == NULL /* [HGM] zippyvar */\r
+              ((i=first.protocolVersion) != 1 && StrStr(first.variants, varname) == NULL) /* [HGM] zippyvar */\r
                                                           ) {\r
         sprintf(buf,\r
         "%stell %s This computer can't play %s [%s], only %s\n%sdecline %s\n",\r
@@ -834,6 +840,17 @@ void ZippyHandleChallenge(srated, swild, sbase, sincrement, opponent)
       return;\r
     }\r
 \r
+    /* [HGM] aborter: opponent is cheater that aborts games he doesn't like on first move. Make him wait */\r
+    if (strcmp(opponent, zippyOffender) == 0 &&\r
+       difftime(time(0), zippyLastGameEnd) < appData.zippyReplayTimeout) {\r
+      sprintf(buf, "%stell %s Sorry, your previous game against %s was rather short. "\r
+                  " It will wait %d seconds to see if a tougher opponent comes along.\n%sdecline %s\n",\r
+             ics_prefix, opponent, ics_handle,\r
+             appData.zippyReplayTimeout, ics_prefix, opponent);\r
+      SendToICS(buf);\r
+      return;\r
+    }\r
+\r
     /* Engine not yet initialized or still thinking about last game? */\r
     if (!first.initDone || first.lastPing != first.lastPong) {\r
       sprintf(buf, "%stell %s I'm not quite ready for a new game yet; try again soon.\n%sdecline %s\n",\r