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