X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=zippy.c;h=564140e1251a22affbc5e4fac19920b253f3c335;hb=c3790f0d51cada3077e31626098a0de1f7c52df3;hp=c29545979c2a0ef6a013cc621f15a948e7ad4a44;hpb=de42af2c838bd38f306bc2c67d0c74dd1125d86b;p=xboard.git diff --git a/zippy.c b/zippy.c index c295459..564140e 100644 --- a/zippy.c +++ b/zippy.c @@ -93,6 +93,9 @@ static char zippyLastOpp[MSG_SIZ]; static int zippyConsecGames; static time_t zippyLastGameEnd; +extern void mysrandom(unsigned int seed); +extern int myrandom(void); + void ZippyInit() { char *p; @@ -134,7 +137,7 @@ void ZippyInit() if ( p != NULL ) { appData.zippyAcceptOnly = p; } - + /* Should Zippy use "i" command? */ /* Defaults to 1=true */ p = getenv("ZIPPYUSEI"); @@ -197,7 +200,7 @@ void ZippyInit() */ -char *swifties[] = { +char *swifties[] = { "i acclaims:", "i admonishes:", "i advertises:", "i advises:", "i advocates:", "i affirms:", "i alleges:", "i anathematizes:", "i animadverts:", "i announces:", "i apostrophizes:", @@ -227,7 +230,8 @@ char *swifties[] = { "i enthuses:", "i entreats:", "i enunciates:", "i eulogizes:", "i exclaims:", "i execrates:", "i exhorts:", "i expatiates:", "i explains:", "i explicates:", "i explodes:", "i exposes:", - "i exposits:", "i expounds:", "i expresses:", "i extols:", + "i exposits:", "i expostulates: ", + "i expounds:", "i expresses:", "i extols:", "i exults:", "i fantasizes:", "i fibs:", "i filibusters:", "i flatters:", "i flutes:", "i fools:", "i free-associates:", "i fulminates:", "i gabbles:", "i gabs:", "i gasps:", @@ -238,7 +242,7 @@ char *swifties[] = { "i hosannas:", "i howls:", "i hums:", "i hypothecates:", "i hypothesizes:", "i imagines:", "i implies:", "i implores:", "i imprecates:", "i indicates:", "i infers:", - "i informs everyone:", "i instructs:", "i interjects:", + "i informs everyone:", "i instructs:", "i interjects:", "i interposes:", "i intimates:", "i intones:", "i introspects:", "i inveighs:", "i jabbers:", "i japes:", "i jests:", "i jibes:", "i jives:", "i jokes:", "i joshes:", "i keens:", "i laments:", @@ -291,7 +295,7 @@ char *swifties[] = { #define MAX_SPEECH 250 -void Speak(how, whom) +void Speak(how, whom) char *how, *whom; { static FILE *zipfile = NULL; @@ -302,7 +306,7 @@ void Speak(how, whom) char *p; int c, speechlen; Boolean done; - + if (strcmp(how, "shout") == 0) { now = time((time_t *) NULL); if (now - lastShout < 1*60) return; @@ -321,7 +325,7 @@ void Speak(how, whom) } fstat(fileno(zipfile), &zipstat); } - + for (;;) { fseek(zipfile, (unsigned) random() % zipstat.st_size, 0); do { @@ -406,7 +410,7 @@ int ZippyControl(buf, i) /* If this is a computer, save the name. Then later, once the */ /* game is really started, we will send the "computer" notice to */ - /* the engine. */ + /* the engine. */ if (appData.zippyPlay && looking_at(buf, i, "* is in the computer list")) { int i; @@ -422,7 +426,7 @@ int ZippyControl(buf, i) } /* Tells and says */ - if (appData.zippyPlay && + if (appData.zippyPlay && (looking_at(buf, i, "* offers to be your bughouse partner") || looking_at(buf, i, "* tells you: [automatic message] I chose you"))) { player = StripHighlightAndTitle(star_match[0]); @@ -667,7 +671,7 @@ int ZippyConverse(buf, i) SendToICS(reply); Speak("tell", player); } - } + } if (looking_at(buf, i, "Notification: * has departed")) { if (((unsigned) random() % 3) == 0) { @@ -675,7 +679,7 @@ int ZippyConverse(buf, i) sprintf(reply, "farewell %s\n", player); SendToICS(reply); } - } + } if (looking_at(buf, i, "Not sent -- * is censoring you")) { char *player = StripHighlightAndTitle(star_match[0]); @@ -683,7 +687,7 @@ int ZippyConverse(buf, i) sprintf(reply, "%s-notify %s\n", ics_prefix, player); SendToICS(reply); } - } + } if (looking_at(buf, i, "command is currently turned off")) { appData.zippyUseI = 0; @@ -741,6 +745,11 @@ void ZippyHandleChallenge(srated, swild, sbase, sincrement, opponent) base = atoi(sbase); increment = atoi(sincrement); + /* If icsAnalyzeEngine active + we don't accept automatic games */ + if (appData.icsActive) + if (appData.icsEngineAnalyze) return; + /* If desired, you can insert more code here to decline matches based on rated, variant, base, and increment, but it is easier to use the ICS formula feature instead. */ @@ -767,7 +776,7 @@ void ZippyHandleChallenge(srated, swild, sbase, sincrement, opponent) /* Yes, and this isn't him. Ignore challenge. */ return; } - + /* Too many consecutive games with same opponent? If so, make him wait until someone else has played or a timeout has elapsed. */ if (appData.zippyMaxGames && @@ -868,12 +877,20 @@ int ZippyMatch(buf, i) return TRUE; } - if (looking_at(buf, i, "offers you a draw")) { - if (first.sendDrawOffers && first.initDone) { - SendToProgram("draw\n", &first); + if (ics_type == ICS_ICC) { + if (looking_at(buf, i, "Your opponent offers you a draw")) { + if (first.sendDrawOffers && first.initDone) + SendToProgram("draw\n", &first); + return TRUE; + } + } else { + if (looking_at(buf, i, "offers you a draw")) { + if (first.sendDrawOffers && first.initDone) { + SendToProgram("draw\n", &first); + } + return TRUE; + } } - return TRUE; - } if (looking_at(buf, i, "requests that the game be aborted") || looking_at(buf, i, "would like to abort")) { @@ -910,7 +927,7 @@ int ZippyMatch(buf, i) return FALSE; } -/* Initialize chess program with data from the first board +/* Initialize chess program with data from the first board * of a new or resumed game. */ void ZippyFirstBoard(moveNum, basetime, increment) @@ -967,7 +984,7 @@ void ZippyFirstBoard(moveNum, basetime, increment) message from ICS." Send 0 in that case */ w = (gameInfo.whiteRating >= 0) ? gameInfo.whiteRating : 0; b = (gameInfo.blackRating >= 0) ? gameInfo.blackRating : 0; - + firstMove = FALSE; if (gameMode == IcsPlayingWhite) { if (first.sendName) { @@ -1056,7 +1073,7 @@ void ZippyFirstBoard(moveNum, basetime, increment) } else { /* Position not sent above, move list might be sent later */ /* Nothing needs to be done here */ - } + } } }