From 3dbaa3c440b654ec995f9e0d5a0fa4ef8f38b4ec Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 15 Jun 2009 23:59:32 -0700 Subject: [PATCH] new zippy option zippyShortGame On request of Mike Adams I added a new zippy option, -zippyShortGame, to make life more difficult for abusers of abort and disconnect for cheating. --- common.h | 1 + winboard/winboard.c | 1 + xboard.c | 4 ++++ zippy.README | 9 +++++++++ zippy.c | 14 ++++++++++++++ 5 files changed, 29 insertions(+), 0 deletions(-) diff --git a/common.h b/common.h index fc3da45..62086db 100644 --- a/common.h +++ b/common.h @@ -566,6 +566,7 @@ typedef struct { char *zippyVariants; int zippyMaxGames; int zippyReplayTimeout; /*seconds*/ + int zippyShortGame; /* [HGM] aborter */ #endif char *serverMovesName; diff --git a/winboard/winboard.c b/winboard/winboard.c index fe03139..6e189db 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -1286,6 +1286,7 @@ ArgDescriptor argDescriptors[] = { { "zippyVariants", ArgString, (LPVOID) &appData.zippyVariants, FALSE }, { "zippyMaxGames", ArgInt, (LPVOID)&appData.zippyMaxGames, FALSE }, { "zippyReplayTimeout", ArgInt, (LPVOID)&appData.zippyReplayTimeout, FALSE }, + { "zippyShortGame", ArgInt, (LPVOID)&appData.zippyShortGame, FALSE }, /* Kludge to allow winboard.ini files from buggy 4.0.4 to be read: */ { "zippyReplyTimeout", ArgInt, (LPVOID)&junk, FALSE }, #endif diff --git a/xboard.c b/xboard.c index c4360fc..bae7854 100644 --- a/xboard.c +++ b/xboard.c @@ -1059,6 +1059,9 @@ XtResource clientResources[] = { { "zippyReplayTimeout", "zippyReplayTimeout", XtRInt, sizeof(int), XtOffset(AppDataPtr, zippyReplayTimeout), XtRImmediate, (XtPointer) ZIPPY_REPLAY_TIMEOUT }, + { "zippyShortGame", "zippyShortGame", XtRInt, sizeof(int), + XtOffset(AppDataPtr, zippyShortGame), XtRImmediate, + (XtPointer) 0 }, #endif { "flashCount", "flashCount", XtRInt, sizeof(int), XtOffset(AppDataPtr, flashCount), XtRImmediate, @@ -1601,6 +1604,7 @@ XrmOptionDescRec shellOptions[] = { { "-zippyVariants", "zippyVariants", XrmoptionSepArg, NULL }, { "-zippyMaxGames", "zippyMaxGames", XrmoptionSepArg, NULL }, { "-zippyReplayTimeout", "zippyReplayTimeout", XrmoptionSepArg, NULL }, + { "-zippyShortGame", "zippyShortGame", XrmoptionSepArg, NULL }, #endif { "-flashCount", "flashCount", XrmoptionSepArg, NULL }, { "-flash", "flashCount", XrmoptionNoArg, "3" }, diff --git a/zippy.README b/zippy.README index acedb9d..c659ffb 100644 --- a/zippy.README +++ b/zippy.README @@ -278,6 +278,15 @@ NEW OPTIONS starts a game between Zippy and the first opponent to respond, giving Zippy no choice about whether to accept or decline. + -zippyShortGame int + If zippyShortGame > 0, Zippy will decline all challenges + from an opponent that terminated a game before the given number + of ply (with an explanatory tell) until either someone else has + played or zippyReplayTimeout seconds have elapsed. Do not set + the number of moves to large; the number of ply during which + opponents can abort a game without rating change would be a + good setting. Default: zippyShortGame=0. + ===================== ENVIRONMENT VARIABLES ===================== diff --git a/zippy.c b/zippy.c index 8114437..b2ba7c8 100644 --- a/zippy.c +++ b/zippy.c @@ -96,6 +96,7 @@ 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; @@ -768,6 +769,8 @@ void ZippyGameEnd(result, resultDetails) SendToICS("\n"); } zippyLastGameEnd = time(0); + if(forwardMostMove < appData.zippyShortGame) + strcpy(zippyOffender, zippyLastOpp); else zippyOffender[0] = 0; // [HGM] aborter } /* @@ -835,6 +838,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", -- 1.7.0.4