/*
* zippy.c -- Implements Zippy the Pinhead chess player on ICS in XBoard
- * $Id$
+ * $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 Free Software Foundation, Inc.
if (now - lastShout < 1*60) return;
lastShout = now;
if (appData.zippyUseI) {
- how = swifties[random() % (sizeof(swifties)/sizeof(char *))];
+ how = swifties[(unsigned) random() %
+ (sizeof(swifties)/sizeof(char *))];
}
}
}
for (;;) {
- fseek(zipfile, random() % zipstat.st_size, 0);
+ fseek(zipfile, (unsigned) random() % zipstat.st_size, 0);
do {
c = getc(zipfile);
} while (c != NULLCHAR && c != '^' && c != EOF);
static char opp_name[128][32];
static int num_opps=0;
+extern ColorClass curColor;
+
+static void SetCurColor( ColorClass color )
+{
+ curColor = color;
+}
+
+static void ColorizeEx( ColorClass color, int cont )
+{
+ if( appData.colorize ) {
+ Colorize( color, cont );
+ SetCurColor( color );
+ }
+}
+
int ZippyControl(buf, i)
char *buf;
int *i;
/* Possibly reject Crafty as opponent */
if (appData.zippyPlay && appData.zippyNoplayCrafty && forwardMostMove < 4
- && looking_at(buf, i, "* kibitzes: Hello from Crafty")) {
+ && looking_at(buf, i, "* kibitzes: Hello from Crafty"))
+ {
player = StripHighlightAndTitle(star_match[0]);
if ((gameMode == IcsPlayingWhite &&
StrCaseCmp(player, gameInfo.black) == 0) ||
}
if (looking_at(buf, i, "* tells you: *") ||
- looking_at(buf, i, "* says: *")) {
+ looking_at(buf, i, "* says: *"))
+ {
player = StripHighlightAndTitle(star_match[0]);
if (appData.zippyPassword[0] != NULLCHAR &&
strncmp(star_match[1], appData.zippyPassword,
sprintf(reply, "%stell %s %s\n", ics_prefix,
player, programVersion);
SendToICS(reply);
- } else if (appData.zippyTalk && ((random() % 10) < 9)) {
+ } else if (appData.zippyTalk && (((unsigned) random() % 10) < 9)) {
if (strcmp(player, ics_handle) != 0) {
Speak("tell", player);
}
}
+
+ ColorizeEx( ColorTell, FALSE );
+
return TRUE;
}
+ if( appData.colorize && looking_at(buf, i, "* (*) seeking") ) {
+ ColorizeEx(ColorSeek, FALSE);
+ return FALSE;
+ }
+
if (looking_at(buf, i, "* spoofs you:")) {
player = StripHighlightAndTitle(star_match[0]);
sprintf(reply, "spoofedby %s\n", player);
SendToICS(reply);
}
+
return FALSE;
}
/* Shouts and emotes */
if (looking_at(buf, i, "--> * *") ||
- looking_at(buf, i, "* shouts: *")) {
+ looking_at(buf, i, "* shouts: *"))
+ {
if (appData.zippyTalk) {
char *player = StripHighlightAndTitle(star_match[0]);
if (strcmp(player, ics_handle) == 0) {
Speak("shout", NULL);
}
}
+
+ ColorizeEx(ColorShout, FALSE);
+
return TRUE;
}
if (looking_at(buf, i, "* kibitzes: *")) {
- if (appData.zippyTalk && (random() % 10) < 9) {
+ if (appData.zippyTalk && ((unsigned) random() % 10) < 9) {
char *player = StripHighlightAndTitle(star_match[0]);
if (strcmp(player, ics_handle) != 0) {
Speak("kibitz", NULL);
}
}
+
+ ColorizeEx(ColorKibitz, FALSE);
+
return TRUE;
}
if (looking_at(buf, i, "* whispers: *")) {
- if (appData.zippyTalk && (random() % 10) < 9) {
+ if (appData.zippyTalk && ((unsigned) random() % 10) < 9) {
char *player = StripHighlightAndTitle(star_match[0]);
if (strcmp(player, ics_handle) != 0) {
Speak("whisper", NULL);
}
}
+
+ ColorizeEx(ColorKibitz, FALSE);
+
return TRUE;
}
char *player = StripHighlightAndTitle(star_match[0]);
if (strcmp(player, ics_handle) != 0) {
- if ((random() % 10) < 9)
+ if (((unsigned) random() % 10) < 9)
Speak("message", player);
f = fopen("zippy.messagelog", "a");
fprintf(f, "%s (%s:%s): %s\n", player,
channel[strlen(channel)-1] = NULLCHAR;
#if 0
/* Always tell to the channel (probability 90%) */
- if (strcmp(player, ics_handle) != 0 && (random() % 10) < 9) {
+ if (strcmp(player, ics_handle) != 0 &&
+ ((unsigned) random() % 10) < 9) {
Speak("tell", channel);
}
#else
Speak("tell", channel);
}
#endif
+
+ ColorizeEx( atoi(channel) == 1 ? ColorChannel1 : ColorChannel, FALSE );
}
return TRUE;
}
}
if (looking_at(buf, i, "Notification: * has arrived")) {
- if ((random() % 3) == 0) {
+ if (((unsigned) random() % 3) == 0) {
char *player = StripHighlightAndTitle(star_match[0]);
strcpy(lastgreet, player);
sprintf(reply, "greet %s\n", player);
}
if (looking_at(buf, i, "Notification: * has departed")) {
- if ((random() % 3) == 0) {
+ if (((unsigned) random() % 3) == 0) {
char *player = StripHighlightAndTitle(star_match[0]);
sprintf(reply, "farewell %s\n", player);
SendToICS(reply);