summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-07-10 23:29:30 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-07-10 23:29:30 +0800
commit36736d45a8f624bc68831035e65fac5e0bfa54ed (patch)
tree0549097b74134403f1307136d2006881394d9a71
parent70ad127d32badd2cf5a011982789d930d6cb60c0 (diff)
parent9351e5d49572d05a6aa21309daa315434def299c (diff)
downloadpttbbs-36736d45a8f624bc68831035e65fac5e0bfa54ed.tar
pttbbs-36736d45a8f624bc68831035e65fac5e0bfa54ed.tar.gz
pttbbs-36736d45a8f624bc68831035e65fac5e0bfa54ed.tar.bz2
pttbbs-36736d45a8f624bc68831035e65fac5e0bfa54ed.tar.lz
pttbbs-36736d45a8f624bc68831035e65fac5e0bfa54ed.tar.xz
pttbbs-36736d45a8f624bc68831035e65fac5e0bfa54ed.tar.zst
pttbbs-36736d45a8f624bc68831035e65fac5e0bfa54ed.zip
add some function of fpg
git-svn-id: http://opensvn.csie.org/pttbbs/branches/ptt.fpg@2122 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/bbs.h1
-rw-r--r--include/modes.h4
-rw-r--r--include/proto.h4
-rw-r--r--include/pttstruct.h6
-rw-r--r--innbbsd/Makefile4
-rw-r--r--mbbsd/Makefile6
-rw-r--r--mbbsd/bbs.c8
-rw-r--r--mbbsd/cache.c9
-rw-r--r--mbbsd/dark.c3
-rw-r--r--mbbsd/go.c1413
-rw-r--r--mbbsd/gomo.c14
-rw-r--r--mbbsd/mbbsd.c3
-rw-r--r--mbbsd/menu.c9
-rw-r--r--mbbsd/merge.c6
-rw-r--r--mbbsd/register.c5
-rw-r--r--mbbsd/talk.c51
-rw-r--r--mbbsd/var.c16
-rw-r--r--util/Makefile5
-rw-r--r--util/account.c312
-rw-r--r--util/buildAnnounce.c1
20 files changed, 1634 insertions, 246 deletions
diff --git a/include/bbs.h b/include/bbs.h
index 075db9a7..45ca1292 100644
--- a/include/bbs.h
+++ b/include/bbs.h
@@ -65,7 +65,6 @@
#include "modes.h"
#include "chc.h"
#include "proto.h"
-#include "gomo.h"
#ifdef ASSESS
#include "assess.h"
diff --git a/include/modes.h b/include/modes.h
index 6d0cacf6..d4f8c926 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -99,7 +99,8 @@
#define REEDIT 79
#define BLOGGING 80
#define CHESSWATCHING 81
-#define MODE_MAX 81 /* ©Ò¦³¨ä¥L¿ï³æ°ÊºA¶·¦b¦¹¤§«e */
+#define GO 82
+#define MODE_MAX 82 /* ©Ò¦³¨ä¥L¿ï³æ°ÊºA¶·¦b¦¹¤§«e */
/* menu.c ¤¤ªº¼Ò¦¡ */
#define QUIT 0x666 /* Return value to abort recursive functions */
@@ -156,6 +157,7 @@ enum {STRIP_ALL = 0, ONLY_COLOR, NO_RELOAD};
#define SIG_GOMO 3
#define SIG_CHC 4
#define SIG_DARK 5
+#define SIG_GO 6
/* talk.c ¤¤ªº¼Ò¦¡ */
#define WATERBALL_GENERAL 0
diff --git a/include/proto.h b/include/proto.h
index b0307d54..53d606b0 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -254,6 +254,10 @@ int ticket_main(void);
int openticket(int bid);
int ticket(int bid);
+/* go */
+int gochess(int fd);
+int GoBot(void);
+
/* gomo */
int gomoku(int fd);
diff --git a/include/pttstruct.h b/include/pttstruct.h
index 6c4dbf1e..a6863a96 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -509,6 +509,12 @@ typedef struct
int recno;
} TagItem;
+/* type in gomo.c, structure passing through socket */
+typedef struct {
+ char x;
+ char y;
+} Horder_t;
+
#ifdef OUTTACACHE
typedef struct {
int index; // ¦b SHM->uinfo[index]
diff --git a/innbbsd/Makefile b/innbbsd/Makefile
index b5b077ec..9bb71f52 100644
--- a/innbbsd/Makefile
+++ b/innbbsd/Makefile
@@ -40,7 +40,7 @@ CFLAGS+= -c -I. -I$(BBS_SRC)/include -I$(BBS_SRC)/mbbsd -D$(BBS_DEP) \
$(EXTRAFLAGS) -DDBZDEBUG -DBBSHOME='"$(BBSHOME)"' \
-D_PATH_BBSHOME=\"$(BBSHOME)\" \
-DVERSION=\"$(VERSION)\" -DADMINUSER=\"$(ADMINUSER)\"
-LDFLAGS+= -liconv
+#LDFLAGS+= -L/usr/local/lib
#
####################################################
@@ -96,7 +96,7 @@ solaris:
@$(MAKE) EXTRAFLAGS="-DMMAP -DSOLARIS -DSYSV" LDFLAGS="-lsocket -lnsl" YACC="bison -y" target
FreeBSD:
- @$(MAKE) CC=cc EXTRAFLAGS="-DBSD44 -DMMAP -DGETRUSAGE" LIBCRYPT=-lcrypt target
+ @$(MAKE) CC=cc EXTRAFLAGS="-DBSD44 -DMMAP -DGETRUSAGE" LDFLAGS="-lcrypt -liconv" target
bsd:
@$(MAKE) CC=cc EXTRAFLAGS="-DMMAP -DGETRUSAGE" target
diff --git a/mbbsd/Makefile b/mbbsd/Makefile
index c60550f3..abfa1e0a 100644
--- a/mbbsd/Makefile
+++ b/mbbsd/Makefile
@@ -12,9 +12,9 @@ PROG= mbbsd
OBJS= admin.o announce.o args.o assess.o bbs.o board.o cache.o cal.o card.o\
chat.o chc.o chicken.o convert.o dark.o edit.o fav.o friend.o gamble.o\
gomo.o guess.o indict.o io.o kaede.o lovepaper.o mail.o mbbsd.o menu.o\
- more.o name.o osdep.o othello.o page.o read.o record.o\
- register.o screen.o stuff.o talk.o term.o topsong.o user.o brc.o\
- vice.o vote.o xyz.o voteboard.o syspost.o var.o passwd.o calendar.o
+ more.o name.o osdep.o othello.o page.o read.o record.o register.o\
+ screen.o stuff.o talk.o term.o topsong.o user.o brc.o vice.o vote.o\
+ xyz.o voteboard.o syspost.o var.o passwd.o calendar.o go.o
.if defined(MERGEBBS)
CFLAGS+= -DMERGEBBS
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 80c3add4..17a35bc1 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -790,16 +790,16 @@ do_generalboardreply(fileheader_t * fhdr)
int
invalid_brdname(char *brd)
{
- register char ch;
+ register char ch, rv=0;
ch = *brd++;
if (!isalpha(ch))
- return 1;
+ rv = 2;
while ((ch = *brd++)) {
if (not_alnum(ch) && ch != '_' && ch != '-' && ch != '.')
- return 1;
+ return (1|rv);
}
- return 0;
+ return rv;
}
static int
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index 842cedad..d7bba339 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -473,7 +473,7 @@ setutmpmode(unsigned int mode)
currutmp->mode = currstat = mode;
/* °lÂÜ¨Ï¥ÎªÌ */
if (HAS_PERM(PERM_LOGUSER)) {
- log_user("setutmpmode to %s(%d)", modestring(currutmp, 0), mode);
+ log_user("setutmpmode to %s(%d)\n", modestring(currutmp, 0), mode);
}
}
#endif
@@ -524,6 +524,7 @@ sort_bcache(void)
SHM->Bbusystate = 0;
}
+#ifdef _BBS_UTIL_C_
void
reload_bcache(void)
{
@@ -541,6 +542,7 @@ reload_bcache(void)
close(fd);
}
memset(SHM->lastposttime, 0, MAX_BOARD * sizeof(time_t));
+ memset(SHM->total, 0, MAX_BOARD * sizeof(int));
/* µ¥©Ò¦³ boards ¸ê®Æ§ó·s«á¦A³]©w uptime */
SHM->Buptime = SHM->Btouchtime;
log_usies("CACHE", "reload bcache");
@@ -556,13 +558,18 @@ void resolve_boards(void)
}
numboards = SHM->Bnumber;
}
+#endif /* defined(_BBS_UTIL_C_)*/
+#if 0
+/* Unused */
void touch_boards(void)
{
SHM->Btouchtime = COMMON_TIME;
numboards = -1;
resolve_boards();
}
+#endif
+
void addbrd_touchcache(void)
{
SHM->Bnumber++;
diff --git a/mbbsd/dark.c b/mbbsd/dark.c
index 03777a2e..caad835b 100644
--- a/mbbsd/dark.c
+++ b/mbbsd/dark.c
@@ -357,7 +357,8 @@ main_dark(int fd, userinfo_t * uin)
rcount = 16;
bcount = 16;
//initialize
- cur_eaty = 18, cur_eatx = 5;
+ cur_eaty = 18, cur_eatx = 5;
+ setutmpmode(DARK);
brd_prints();
if (currutmp->turn) {
brd_rand();
diff --git a/mbbsd/go.c b/mbbsd/go.c
new file mode 100644
index 00000000..18f04120
--- /dev/null
+++ b/mbbsd/go.c
@@ -0,0 +1,1413 @@
+/* $Id$ */
+/*-------------------------------------------------------*/
+/* go.c ( NTU FPG BBS Ver 1.00 ) */
+/*-------------------------------------------------------*/
+/* target : ³ò´Ñ */
+/* create : 01/09/00 */
+/*-------------------------------------------------------*/
+
+#include "bbs.h"
+#include <sys/socket.h>
+
+#define BBLANK (0) /* ªÅ¥Õ */
+#define BBLACK (1) /* ¶Â¤l */
+#define BWHITE (2) /* ¥Õ¤l */
+
+#define redoln() (void)0
+
+#define BRDSIZ (19) /* ´Ñ½L³æÃä¤j¤p */
+
+#define BGOTO(x, y) move(20 - y , x * 2 + 4)
+
+static unsigned char go[BRDSIZ][BRDSIZ];
+static unsigned char l[BRDSIZ][BRDSIZ];
+static unsigned char ml[BRDSIZ][BRDSIZ];
+static int lib, mik, mjk, hik, hjk, mk, hk;
+static float win;
+
+//extern char *bw_chess[]; /* ©M¤­¤l´Ñ¦@¥Î */
+
+static char *locE = "ABCDEFGHJKLMNOPQRST";
+
+static char AB[41];
+
+static unsigned char me, he, hand;
+
+static Horder_t *v, pool[500];
+
+static void
+GO_init(void)
+{
+ memset(pool, 0, sizeof(pool));
+ v = pool;
+
+ memset(go, 0, sizeof(go));
+ memset( l, 0, sizeof(go));
+ memset(ml, 0, sizeof(go));
+}
+
+static void
+GO_add(Horder_t *mv)
+{
+ if (v < pool + 500)
+ *v++ = *mv;
+}
+
+static int
+GO_sethand(int i)
+{
+ int j;
+ char tmp[5];
+
+ if (i > 0 && i < 10)
+ {
+ move(1, 71);
+ prints("Åý¤l¡G%d", i);
+
+ win = 0;
+ go[3][3] = BBLACK;
+ if (i > 1)
+ {
+ go[15][15] = BBLACK;
+ if (i > 2)
+ {
+ go[3][15] = BBLACK;
+ if (i > 3)
+ {
+ go[15][3] = BBLACK;
+ if (i == 5)
+ go[9][9] = BBLACK;
+ else
+ if (i > 5)
+ {
+ go[9][15] = BBLACK;
+ go[9][3] = BBLACK;
+ if (i == 7)
+ go[9][9] = BBLACK;
+ else
+ if (i > 7)
+ {
+ go[15][9] = BBLACK;
+ go[3][9] = BBLACK;
+ if (i > 8)
+ go[9][9] = BBLACK;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ return 0;
+
+ hand = i;
+ *AB = 0;
+ for (i = 0;i < 19;i++)
+ for (j = 0;j < 19;j++)
+ if (go[i][j])
+ {
+ BGOTO(i, j);
+ outs(bw_chess[go[i][j] - 1]);
+ redoln();
+ sprintf(tmp, "[%c%c]", 'a' + i, 's' - j);
+ strcat(AB, tmp);
+ }
+ return 1;
+}
+
+
+static void
+GO_count(int x, int y, int color)
+{
+ ml[x][y] = 0;
+
+ if (x != 0)
+ {
+ if ((go[x - 1][y] == BBLANK) && ml[x - 1][y])
+ {
+ ++lib;
+ ml[x - 1][y] = 0;
+ }
+ else
+ if ((go[x - 1][y] == color) && ml[x - 1][y])
+ GO_count(x - 1, y, color);
+ }
+ if (x != 18)
+ {
+ if ((go[x + 1][y] == BBLANK) && ml[x + 1][y])
+ {
+ ++lib;
+ ml[x + 1][y] = 0;
+ }
+ else
+ if ((go[x + 1][y] == color) && ml[x + 1][y])
+ GO_count(x + 1, y, color);
+ }
+ if (y != 0)
+ {
+ if ((go[x][y - 1] == BBLANK) && ml[x][y - 1])
+ {
+ ++lib;
+ ml[x][y - 1] = 0;
+ }
+ else
+ if ((go[x][y - 1] == color) && ml[x][y - 1])
+ GO_count(x, y - 1, color);
+ }
+ if (y != 18)
+ {
+ if ((go[x][y + 1] == BBLANK) && ml[x][y + 1])
+ {
+ ++lib;
+ ml[x][y + 1] = 0;
+ }
+ else
+ if ((go[x][y + 1] == color) && ml[x][y + 1])
+ GO_count(x, y + 1, color);
+ }
+}
+
+static void
+GO_countlib(int x, int y, char color)
+{
+ int i, j;
+
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ ml[i][j] = 1;
+
+ GO_count(x, y, color);
+}
+
+static void
+GO_eval(char color)
+{
+ int i, j;
+
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ if (go[i][j] == color)
+ {
+ lib = 0;
+ GO_countlib(i, j, color);
+ l[i][j] = lib;
+ }
+}
+
+static int
+GO_check(Horder_t *mv)
+{
+ int m, n, k;
+
+ lib = 0;
+ GO_countlib(mv->x, mv->y, me);
+
+ if (lib == 0)
+ {
+ go[(int)mv->x][(int)mv->y] = me;
+
+ GO_eval(he);
+ k = 0;
+
+ for (m = 0; m < 19; m++)
+ for (n = 0; n < 19; n++)
+ if ((go[m][n] == he) && !l[m][n]) ++k;
+
+ if ((k == 0) || (k == 1 && ((mv->x == mik) && (mv->y == mjk))))
+ {
+ go[(int)mv->x][(int)mv->y] = BBLANK; /* restore to open */
+ return 0;
+ }
+ else
+ return 1;
+ }
+ else
+ return 1;
+}
+
+static void
+GO_blank(char x, char y)
+{
+ char *str = "¢z¢s¢{¢u¢q¢t¢|¢r¢}";
+ int n1, n2, loc;
+
+ BGOTO(x, y);
+ n1 = (x == 0) ? 0 : (x == 18) ? 2 : 1;
+ n2 = (y == 18) ? 0 : (y == 0) ? 2 : 1;
+ loc= 2 * (n2 * 3 + n1);
+ prints("%.2s", str + loc);
+ redoln();
+}
+
+static void
+GO_examboard(char color)
+{
+ int i, j, n;
+
+ GO_eval(color);
+
+ if (color == he)
+ {
+ hik = -1;
+ hjk = -1;
+ }
+ else
+ {
+ mik = -1;
+ mjk = -1;
+ }
+ n = 0;
+
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ if ((go[i][j] == color) && (l[i][j] == 0))
+ {
+ go[i][j] = BBLANK;
+ GO_blank(i, j);
+ if (color == he)
+ {
+ hik = i;
+ hjk = j;
+ ++hk;
+ }
+ else
+ {
+ mik = i;
+ mjk = j;
+ ++mk;
+ }
+ ++n;
+ }
+
+ if (color == he && n > 1)
+ {
+ hik = -1;
+ hjk = -1;
+ }
+ else if ( n > 1 )
+ {
+ mik = -1;
+ mjk = -1;
+ }
+}
+
+static void
+GO_clean(int fd, int x, int y, int color)
+{
+ Horder_t tmp;
+
+ ml[x][y] = 0;
+
+ go[x][y] = BBLANK;
+ GO_blank(x, y);
+
+ tmp.x = x;
+ tmp.y = y;
+
+ if (send(fd, &tmp, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ return;
+
+ if (x != 0)
+ {
+ if ((go[x - 1][y] == color) && ml[x - 1][y])
+ GO_clean(fd, x - 1, y, color);
+ }
+ if (x != 18)
+ {
+ if ((go[x + 1][y] == color) && ml[x + 1][y])
+ GO_clean(fd, x + 1, y, color);
+ }
+ if (y != 0)
+ {
+ if ((go[x][y - 1] == color) && ml[x][y - 1])
+ GO_clean(fd, x, y - 1, color);
+ }
+ if (y != 18)
+ {
+ if ((go[x][y + 1] == color) && ml[x][y + 1])
+ GO_clean(fd, x, y + 1, color);
+ }
+}
+
+static void
+GO_cleandead(int fd, char x, char y, char color)
+{
+ int i, j;
+
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ ml[i][j] = 1;
+
+ GO_clean(fd, x, y, color);
+}
+
+static void
+GO_log(char *userid)
+{
+ fileheader_t mymail;
+ char title[128], buf[80];
+ int i = 0;
+ FILE *fp;
+ Horder_t *ptr = pool;
+ //extern screenline *big_picture;
+
+ sethomepath(buf, cuser.userid);
+ stampfile(buf, &mymail);
+
+ fp = fopen(buf, "w");
+ for(i = 1; i < 21; i++)
+ fprintf(fp, "%.*s\n", big_picture[i].len, big_picture[i].data + 1);
+
+ i = 0;
+
+ fprintf(fp, "\n");
+
+ do
+ {
+ if (ptr->x == -1 || ptr->y == -1)
+ fprintf(fp, "[%3d]%s => %c", i + 1, win ? bw_chess[i % 2] : bw_chess[(i + 1) % 2],
+ (i % 5) == 4 ? '\n' : '\t');
+ else
+ fprintf(fp, "[%3d]%s => %.1s%d%c", i + 1, win ? bw_chess[i % 2] : bw_chess[(i + 1) % 2],
+ locE + ptr->x, ptr->y + 1, (i % 5) == 4 ? '\n' : '\t');
+ i++;
+
+ } while (++ptr < v);
+
+ fprintf(fp, "\n\n¡m¥H¤U¬° sgf ®æ¦¡´ÑÃСn\n\n(;GM[1]");
+ if (userid == NULL)
+ fprintf(fp, "GN[Gobot-Gobot FPG]\n");
+ else
+ fprintf(fp, "GN[%s-%s(%c) FPG]\n", userid, cuser.userid, me == BBLACK ? 'B' : 'W');
+ fprintf(fp, "SZ[19]HA[%d]", hand);
+ if (userid == NULL)
+ {
+ fprintf(fp, "PB[Gobot]PW[Gobot]\n");
+ }
+ else
+ {
+ if (me == BBLACK)
+ fprintf(fp, "PB[%s]PW[%s]\n", cuser.userid, userid);
+ else
+ fprintf(fp, "PB[%s]PW[%s]\n", userid, cuser.userid);
+ }
+ fprintf(fp, "PC[FPG BBS/Ptt BBS: ptt.cc]\n");
+
+ if (win)
+ i = 0;
+ else
+ {
+ i = 1;
+ fprintf(fp, "AB%s\n", AB);
+ }
+ ptr = pool;
+ do
+ {
+ if (ptr->x == -1 || ptr->y == -1)
+ fprintf(fp, ";%c[]%c", i % 2 ? 'W' : 'B', (i % 10) == 9 ? '\n' : ' ');
+ else
+ fprintf(fp, ";%c[%c%c]%c", i % 2 ? 'W' : 'B', 'a' + ptr->x, 's' - ptr->y, (i % 10) == 9 ? '\n' : ' ');
+
+ i++;
+ } while (++ptr < v);
+
+ fprintf(fp, ";)\n\n");
+ fclose(fp);
+
+ mymail.filemode = FILE_READ;
+
+ strcpy(mymail.owner, "[³Æ.§Ñ.¿ý]");
+ if (userid == NULL)
+ {
+ strcpy(mymail.title, "³ò´Ñ¥´ÃÐ");
+ }
+ else
+ snprintf(mymail.title, sizeof(mymail.title),
+ "\033[37;41m´ÑÃÐ\033[m %s VS %s", cuser.userid, userid);
+
+ sethomedir(title, cuser.userid);
+ append_record(title, &mymail, sizeof(mymail));
+}
+
+static int
+go_key(int fd, int ch, Horder_t *mv)
+{
+ if (ch >= 'a' && ch <= 's' && ch != 'i')
+ {
+ char pbuf[4];
+ int vx, vy;
+
+ pbuf[0] = ch;
+ pbuf[1] = 0;
+
+ if (fd) add_io(0, 0);
+ getdata(21, 9, "ª½±µ«ü©w¦ì¸m(1 - 19)¡G", pbuf, 4, DOECHO);
+ if (fd) add_io(fd, 0);
+ move(21, 9);
+ clrtoeol();
+ outs(" ");
+
+ vx = ch - 'a';
+ if (ch > 'i')
+ vx--;
+ vy = atoi(pbuf) - 1;
+ if( vx >= 0 && vx < BRDSIZ && vy >= 0 && vy < BRDSIZ && go[vx][vy] == BBLANK)
+ {
+ mv->x = vx;
+ mv->y = vy;
+ return 1;
+ }
+ }
+ else
+ {
+ switch(ch)
+ {
+ case KEY_RIGHT:
+ mv->x = (mv->x == BRDSIZ - 1) ? mv->x : mv->x + 1;
+ break;
+ case KEY_LEFT:
+ mv->x = (mv->x == 0 ) ? 0 : mv->x - 1;
+ break;
+ case KEY_UP:
+ mv->y = (mv->y == BRDSIZ - 1) ? mv->y : mv->y + 1;
+ break;
+ case KEY_DOWN:
+ mv->y = (mv->y == 0 ) ? 0 : mv->y - 1;
+ break;
+ case ' ':
+ case '\r':
+ case '\n':
+ if (go[(int)mv->x][(int)mv->y] == BBLANK && GO_check(mv))
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static unsigned char
+GO_findcolor(int x, int y)
+{
+ int k, result = 0, color[4];
+
+ if (go[x][y] != BBLANK)
+ return 0;
+
+ if (x > 0)
+ {
+ k = x;
+ do --k;
+ while ((go[k][y] == BBLANK) && (k > 0));
+ color[0] = go[k][y];
+ }
+ else
+ color[0] = go[x][y];
+
+ if (x < 18)
+ {
+ k = x;
+ do ++k;
+ while ((go[k][y] == BBLANK) && (k < 18));
+ color[1] = go[k][y];
+ }
+ else
+ color[1] = go[x][y];
+
+ if (y > 0)
+ {
+ k = y;
+ do --k;
+ while ((go[x][k] == BBLANK) && (k > 0));
+ color[2] = go[x][k];
+ }
+ else color[2] = go[x][y];
+
+ if (y < 18)
+ {
+ k = y;
+ do ++k;
+ while ((go[x][k] == BBLANK) && (k < 18));
+ color[3] = go[x][k];
+ }
+ else
+ color[3] = go[x][y];
+
+ for (k = 0;k < 4;k++)
+ {
+ if (color[k] == BBLANK)
+ continue;
+ else
+ {
+ result = color[k];
+ break;
+ }
+ }
+
+ for (k = 0;k < 4;k++)
+ {
+ if ((color[k] != BBLANK) && (color[k] != result))
+ return 0;
+ }
+
+ return result;
+}
+
+static int
+GO_result(void)
+{
+ int i, j, result;
+ float count[2];
+ char *chessresult[] = { "¡E", "¡C" };
+
+ count[0] = count[1] = 0;
+
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ if (go[i][j] == BBLANK)
+ {
+ result = GO_findcolor(i, j);
+ BGOTO(i, j);
+ if (result)
+ {
+ outs(chessresult[result - 1]);
+ count[result - 1]++;
+ }
+ else
+ {
+ outs("¡Ñ");
+ win -= 0.5;
+ }
+ redoln();
+ }
+ else
+ count[go[i][j] - 1]++;
+
+ if (me == BBLACK)
+ {
+ move(5, 46);
+ prints("%s ¤è¥Ø¼Æ¡G%-3.1f ", bw_chess[me - 1], count[0]);
+ move(6, 46);
+ prints("%s ¤è¥Ø¼Æ¡G%-3.1f ", bw_chess[he - 1], count[1]);
+ move(21, 46);
+ clrtoeol();
+ move(8, 46);
+
+ if (count[0] > 181 + win)
+ return 1;
+ }
+ else
+ {
+ move(5, 46);
+ prints("%s ¤è¥Ø¼Æ¡G%-3.1f ", bw_chess[me - 1], count[1]);
+ move(6, 46);
+ prints("%s ¤è¥Ø¼Æ¡G%-3.1f ", bw_chess[he - 1], count[0]);
+ move(21, 46);
+ clrtoeol();
+ move(8, 46);
+
+ if (count[0] <= 181 + win)
+ return 1;
+ }
+ return 0;
+}
+
+void
+GO_cleantable()
+{
+ int i, j;
+
+ move(1, 5);
+ for (i = 0; i < BRDSIZ; ++i)
+ prints("%c ", locE[i]);
+ for (i = 0; i < BRDSIZ; ++i) {
+ move(2 + i, 0);
+ prints("%3d", BRDSIZ - i);
+ for (j = 0; j < BRDSIZ; ++j)
+ GO_blank(i, j);
+ }
+}
+
+int
+gochess(int fd)
+{
+ Horder_t mv;
+ userinfo_t *my = currutmp;
+ time_t mtime, htime, btime;
+ int i, j, ch = 0, passflag, endflag, totalgo, timeflag, is_view;
+ unsigned char mhand, hhand;
+
+ GO_init();
+
+ hk = mk = 0;
+ totalgo = 0;
+ hik = hjk = -1;
+ mik = mjk = -1;
+ mhand = hhand = 250; /* ¤£¤Ó¥i¯à¤@¤ÀÄÁ¤º¤U³o»ò¦h¤â :p */
+ mtime = htime = 60; /* ¤@¶}©lªº¤@¤ÀÄÁ¤º¤£­p¤â */
+ win = 3.5;
+
+ me = !(my->turn) + 1;
+ he = my->turn + 1;
+ if (me > 2) me = 2;
+ if (he > 2) he = 2;
+
+ endflag = passflag = timeflag = 0;
+ is_view = 1;
+
+ setutmpmode(GO);
+
+ clear();
+
+ /* Æ[¾Ô¥Îµ{¦¡½X, »P ptt ¤£¬Û®e
+ if (me == BWHITE)
+ {
+ VIEWCHESS vs;
+
+ memset(&vs, 0, sizeof(VIEWCHESS));
+ strcpy(vs.userid[0], cuser.userid);
+ strcpy(vs.userid[1], my->mateid);
+ if (cshm_new(&vs) == -1)
+ is_view = 0;
+ }
+ */
+
+ prints("\033[1;46m ³ò´Ñ¹ï¾Ô \033[45m%31s VS %-31s\033[m",
+ cuser.userid, my->mateid);
+ GO_cleantable();
+
+ /* film_out(FILM_GO, 1); */
+
+ add_io(fd, 0);
+
+ mv.x = mv.y = 9;
+ btime = now;
+
+ for(;;)
+ {
+ if (endflag || timeflag)
+ {
+ move(5, 46);
+ prints("%s ¤è®É¶¡¡G----- --", bw_chess[me - 1]);
+ move(6, 46);
+ prints("%s ¤è®É¶¡¡G----- --", bw_chess[he - 1]);
+ }
+ else
+ {
+ if (my->turn)
+ {
+ mtime -= now - btime;
+ if (mtime < 0)
+ {
+ if (mhand > 25) /* ²Ä¤@¤ÀÄÁ¹L«á¡A­n¦b 12 ¤ÀÄÁ¤º¤U 25 ¤â */
+ {
+ mtime = 12 * 60;
+ mhand = 25;
+ }
+ else
+ {
+ mv.x = mv.y = -8;
+ if (send(fd, &mv, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ break;
+ move(8, 46);
+ outs("¥¼¦b®É¶¡¤º§¹¦¨ 25 ¤â¡Aµô©w±Ñ");
+ break;
+ }
+ }
+ }
+ else
+ {
+ htime -= now - btime;
+ if (htime < 0)
+ {
+ if (hhand > 25) /* ²Ä¤@¤ÀÄÁ¹L«á¡A­n¦b 12 ¤ÀÄÁ¤º¤U 25 ¤â */
+ {
+ htime = 12 * 60;
+ hhand = 25;
+ }
+ else
+ htime = 0;
+ }
+ }
+ move(5, 46);
+ prints("%s ¤è®É¶¡¡G%02ld:%02ld ", bw_chess[me - 1], mtime / 60, mtime % 60);
+ if (mhand <= 25)
+ prints("%2d ¤â", 25 - mhand);
+ move(6, 46);
+ prints("%s ¤è®É¶¡¡G%02ld:%02ld ", bw_chess[he - 1], htime / 60, htime % 60);
+ if (hhand <= 25)
+ prints("%2d ¤â", 25 - hhand);
+ }
+ btime = now;
+ move(2, 46);
+ prints("%s ¤è´£¤l¼Æ¡G%3d", bw_chess[me - 1], hk);
+ move(3, 46);
+ prints("%s ¤è´£¤l¼Æ¡G%3d", bw_chess[he - 1], mk);
+
+ move(8, 46);
+ clrtoeol();
+ if (endflag)
+ outs("½Ð²M°£¦º¤l¡A¥H«K­pºâ³Ó­t");
+ else if (my->turn)
+ prints("½ü¨ì¦Û¤v¤U¤F.... §Ú¬O %s", bw_chess[me - 1]);
+ else
+ outs("µ¥«Ý¹ï¤è¤U¤l....");
+
+
+ move(10, 46);
+ clrtoeol();
+ if (totalgo > 0)
+ {
+ if (pool[totalgo - 1].x == -1 || pool[totalgo - 1].y == -1)
+ prints("%s #%-3d PASS ¤W¤@¤â ", win ? bw_chess[(totalgo - 1) % 2] : bw_chess[totalgo % 2], totalgo);
+ else
+ prints("%s #%-3d %.1s%-2d ¤W¤@¤â ", win ? bw_chess[(totalgo - 1) % 2] : bw_chess[totalgo % 2], totalgo, locE + pool[totalgo - 1].x, pool[totalgo - 1].y + 1);
+ }
+
+ for (i = totalgo - 1;i > 0 && totalgo - i <= 10;i--)
+ {
+ move(10 + totalgo - i, 46);
+ clrtoeol();
+ if (pool[i - 1].x == -1 || pool[i - 1].y == -1)
+ prints("%s #%-3d PASS", win ? bw_chess[(i - 1) & 1] : bw_chess[i & 1], i);
+ else
+ prints("%s #%-3d %.1s%-2d ", win ? bw_chess[(i - 1) & 1] : bw_chess[i & 1], i, locE + pool[i - 1].x, pool[i - 1].y + 1);
+ }
+
+ move(21, 46);
+
+ if (v == pool)
+ {
+ if (me == BWHITE && win != 0)
+ outs("\033[1;33m«ö x Åý¤l y ¤£­­®É Ctrl-C ¤¤¤î´Ñ§½\033[m");
+ else
+ outs("\033[1;33m«ö Ctrl-C ¤¤¤î´Ñ§½\033[m");
+ }
+ else if (passflag && my->turn)
+ {
+ if (endflag)
+ outs("\033[1;33m¹ï¤è DONE¡A¤v¤è DONE ´N­pºâµ²ªG\033[m");
+ else
+ outs("\033[1;33m¹ï¤è PASS¡A¤v¤è PASS ´Nµ²§ô´Ñ§½\033[m");
+ }
+ else if (v > pool)
+ clrtoeol();
+
+ if (endflag)
+ outmsg("\033[1;33;42m ¤U´Ñ \033[;31;47m (¡ö¡ô¡õ¡÷)\033[30m²¾°Ê \033[31m(ªÅ¥ÕÁä/ENTER)\033[30m¤U¤l " /*\033[31m(v)\033[30m¶Ç°T */ "\033[31m(z)\033[30m§ë­° \033[31m(w)\033[30mDONE \033[31m(u)\033[30m¦^´_ \033[m");
+ else
+ outmsg("\033[1;33;42m ¤U´Ñ \033[;31;47m (¡ö¡ô¡õ¡÷)\033[30m²¾°Ê \033[31m(ªÅ¥ÕÁä/ENTER)\033[30m¤U¤l " /*\033[31m(v)\033[30m¶Ç°T */ "\033[31m(z)\033[30m§ë­° \033[31m(w)\033[30mPASS \033[m");
+
+ BGOTO(mv.x, mv.y);
+
+ /*
+ if (ch == -1 && is_view)
+ cshm_update(mv.x, mv.y);
+ */
+
+ ch = igetch();
+
+ /* ¹ï¾Ô¤¤¥á¤ô²y, ¼È¤£¤ä´©
+ if (ch == 'v')
+ {
+ //extern screenline *big_picture;
+ screenline* screen0 = calloc(t_lines, sizeof(screenline));
+ int y, x;
+
+ memcpy(screen0, big_picture, t_lines * sizeof(screenline));
+ add_io(0, 0);
+ getyx(&y, &x);
+ if (ch == 'v')
+ {
+ extern char watermode;
+
+ watermode = 2;
+ my_write(my->destuip->pid, "¥á¤ô²y¹L¥h¡G");
+ watermode = 0;
+ }
+ else
+ {
+ show_last_call_in();
+ my_write(currutmp->msgs[0].last_pid, "¤ô²y¥á¦^¥h¡G");
+ }
+ move(y, x);
+ memcpy(big_picture, screen0, t_lines * sizeof(screenline));
+ free(screen0);
+ redoscr();
+ add_io(fd, 0);
+ continue;
+ } else */ if (ch == 'x') {
+ if (v == pool && me == BWHITE && win != 0)
+ {
+ char buf[4];
+
+ add_io(0, 0);
+ getdata(21, 46, "­nÅý¦h¤Ö¤l©O(1 - 9)¡H ", buf, 4, DOECHO);
+ add_io(fd, 0);
+
+ if (GO_sethand(atoi(buf)))
+ {
+ mv.x = -9;
+ mv.y = atoi(buf);
+ if (send(fd, &mv, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ break;
+ mv.x = mv.y = 9;
+ my->turn = 1;
+ ch = -1;
+ }
+ continue;
+ }
+ }
+ else if (ch == 'y')
+ {
+ if (v == pool && me == BWHITE)
+ {
+ timeflag = 1;
+ mv.x = mv.y = -10;
+ if (send(fd, &mv, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ break;
+ mv.x = mv.y = 9;
+ ch = -1;
+ }
+ }
+ else if (ch == 'w')
+ {
+ if (endflag)
+ {
+ Horder_t tmp;
+
+ if (passflag && my->turn)
+ {
+ tmp.x = tmp.y = -3;
+ if (send(fd, &tmp, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ break;
+
+ if (GO_result())
+ outs("®¥ÁH¡A±zÀò±o³Ó§Q.... ");
+ else
+ outs("¿é¤F¡A¦A±µ¦AÀyËç.... ");
+
+ if (me == BWHITE)
+ ch = -1;
+
+ break;
+ }
+ else
+ {
+ Horder_t tmp;
+
+ passflag = 1;
+ tmp.x = tmp.y = -6;
+ if (send(fd, &tmp, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ break;
+ my->turn = 0;
+
+ if (me == BWHITE)
+ ch = -1;
+
+ continue;
+ }
+ }
+ else
+ {
+ if (my->turn)
+ {
+ if (passflag)
+ {
+ endflag = 1;
+ passflag = 0;
+ mv.x = mv.y = -2;
+ if (send(fd, &mv, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ break;
+ mv.x = mv.y = 9;
+ memcpy(l, go, sizeof(l)); /* ³Æ¥÷ */
+
+ if (me == BWHITE)
+ ch = -1;
+ continue;
+ }
+ else
+ {
+ passflag = 1;
+ mv.x = mv.y = -1;
+ if (send(fd, &mv, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ break;
+ GO_add(&mv);
+ totalgo++;
+ mv.x = mv.y = 9;
+ my->turn = 0;
+
+ if (me == BWHITE)
+ ch = -1;
+ continue;
+ }
+ }
+ }
+ }
+ else if (ch == Ctrl('C')/* && v == pool */)
+ {
+ mv.x = mv.y = -5;
+ if (send(fd, &mv, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ break;
+ break;
+ }
+ else if (ch == 'u')
+ {
+ if (endflag)
+ {
+ memcpy(go, l, sizeof(go));
+
+ for(i = 0;i < 19;i++)
+ for(j = 0;j < 19;j++)
+ {
+ BGOTO(i, j);
+ if (go[i][j])
+ {
+ outs(bw_chess[go[i][j] - 1]);
+ redoln();
+ }
+ else
+ GO_blank(i, j);
+ }
+ mv.x = mv.y = -7;
+ if (send(fd, &mv, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ break;
+ mv = *(v - 1);
+
+ if (me == BWHITE)
+ ch = -1;
+ }
+ }
+ else if (ch == 'z')
+ {
+ mv.x = mv.y = -4;
+ if (send(fd, &mv, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ break;
+ move(8, 46);
+ outs("±z»{¿é¤F.... ");
+ break;
+ }
+
+ if (ch == I_OTHERDATA)
+ {
+ ch = recv(fd, &mv, sizeof(Horder_t), 0);
+
+ if (ch <= 0)
+ {
+ move(8, 46);
+ outs("¹ï¤èÂ_½u.... ");
+ break;
+ }
+
+ if (ch != sizeof(Horder_t))
+ {
+ continue;
+ }
+
+ if (mv.x == -9 && mv.y > 0)
+ {
+ GO_sethand(mv.y);
+ mv.x = mv.y = 9;
+ my->turn = 0;
+ continue;
+ }
+
+ if (mv.x == -10 && mv.y == -10)
+ {
+ timeflag = 1;
+ mv.x = mv.y = 9;
+ continue;
+ }
+
+ if (mv.x == -5 && mv.y == -5)
+ break;
+
+ if (mv.x == -4 && mv.y == -4)
+ {
+ move(8, 46);
+ outs("¹ï¤è»{¿é.... ");
+ break;
+ }
+
+ if (mv.x == -8 && mv.y == -8)
+ {
+ move(8, 46);
+ outs("¹ï¤è¥¼¦b®É¶¡¤º§¹¦¨ 25 ¤â¡Aµô©w³Ó");
+ break;
+ }
+
+ if (mv.x == -3 && mv.y == -3)
+ {
+ if (GO_result())
+ outs("®¥ÁH¡A±zÀò±o³Ó§Q.... ");
+ else
+ outs("¿é¤F¡A¦A±µ¦AÀyËç.... ");
+ break;
+
+ if (me == BWHITE)
+ ch = -1;
+ }
+
+ if (mv.x == -2 && mv.y == -2)
+ {
+ endflag = 1;
+ passflag = 0;
+ mv.x = mv.y = 9;
+ my->turn = 1;
+ memcpy(l, go, sizeof(l)); /* ³Æ¥÷ */
+
+ if (me == BWHITE)
+ ch = -1;
+ continue;
+ }
+
+ if (mv.x == -7 && mv.y == -7)
+ {
+ memcpy(go, l, sizeof(go));
+
+ for(i = 0;i < 19;i++)
+ for(j = 0;j < 19;j++)
+ {
+ BGOTO(i, j);
+ if (go[i][j])
+ {
+ outs(bw_chess[go[i][j] - 1]);
+ redoln();
+ }
+ else
+ GO_blank(i, j);
+ }
+ mv = *(v - 1);
+
+ if (me == BWHITE)
+ ch = -1;
+
+ continue;
+ }
+
+ if (mv.x == -6 && mv.y == -6)
+ {
+ passflag = 1;
+ mv = *(v - 1);
+ my->turn = 1;
+
+ if (me == BWHITE)
+ ch = -1;
+
+ continue;
+ }
+
+ if (mv.x == -1 && mv.y == -1)
+ {
+ GO_add(&mv);
+ totalgo++;
+ mv.x = mv.y = 9;
+
+ passflag = 1;
+ my->turn = 1;
+
+ if (me == BWHITE)
+ ch = -1;
+
+ continue;
+ }
+
+ if (endflag)
+ {
+ int y, x;
+
+ getyx(&y, &x);
+
+ go[(int)mv.x][(int)mv.y] = BBLANK;
+ GO_blank(mv.x, mv.y);
+ /*
+ hk++;
+ */
+ mv.x = (x - 4) / 2;
+ mv.y = 20 - y;
+ BGOTO(mv.x, mv.y);
+
+ if (me == BWHITE)
+ ch = -1;
+ continue;
+ }
+
+ if (!my->turn)
+ {
+ GO_add(&mv);
+
+ totalgo++;
+ if (--hhand <= 0)
+ {
+ htime = 12 * 60;
+ hhand = 25;
+ }
+ go[(int)mv.x][(int)mv.y] = he;
+ BGOTO(mv.x, mv.y);
+ outs(bw_chess[he - 1]);
+ redoln();
+
+ GO_examboard(me);
+ my->turn = 1;
+ htime -= time(0) - btime;
+ btime = time(0);
+ passflag = 0;
+
+ if (me == BWHITE)
+ ch = -1;
+ }
+ continue;
+ }
+
+ if (endflag == 1 && (ch == ' ' || ch == '\r' || ch == '\n')) {
+ if (go[(int)mv.x][(int)mv.y] == me)
+ GO_cleandead(fd, mv.x, mv.y, me);
+
+ if (me == BWHITE)
+ ch = -1;
+ continue;
+ }
+
+ if (my->turn)
+ {
+ if (go_key(fd, ch, &mv))
+ my->turn = 0;
+ else
+ continue;
+
+ if (!my->turn)
+ {
+ GO_add(&mv);
+
+ totalgo++;
+ mtime -= time(0) - btime;
+ btime = time(0);
+ if (--mhand <= 0)
+ {
+ mtime = 12 * 60;
+ mhand = 25;
+ }
+ BGOTO(mv.x, mv.y);
+ outs(bw_chess[me - 1]);
+ redoln();
+ go[(int)mv.x][(int)mv.y] = me;
+ GO_examboard(he);
+ if (send(fd, &mv, sizeof(Horder_t), 0) != sizeof(Horder_t))
+ break;
+ passflag = 0;
+
+ if (me == BWHITE)
+ ch = -1;
+ }
+ }
+ }
+
+ add_io(0, 0);
+ close(fd);
+
+ igetch();
+
+ /*
+ if (me == BWHITE && is_view)
+ cshm_free();
+ */
+
+ if (endflag)
+ {
+ for(i = 0;i < 19;i++)
+ for(j = 0;j < 19;j++)
+ {
+ BGOTO(i, j);
+ if (l[i][j])
+ {
+ outs(bw_chess[l[i][j] - 1]);
+ redoln();
+ }
+ else
+ GO_blank(i, j);
+ }
+ }
+
+ if (v > pool + 10)
+ {
+ char ans[3];
+
+ getdata(b_lines - 1, 0, "­n¦s¦¨´ÑÃжÜ(Y/N)¡H[Y] ", ans, 3, LCECHO);
+
+ if (*ans != 'n')
+ GO_log(my->mateid);
+ }
+
+ return 0;
+}
+
+int
+GoBot(void)
+{
+ Horder_t mv;
+ int i, ch, totalgo;
+ unsigned char tmp_go[2][BRDSIZ][BRDSIZ];
+ unsigned char tmp_l[2][BRDSIZ][BRDSIZ];
+ unsigned char tmp_ml[2][BRDSIZ][BRDSIZ];
+ int tmp_lib[2], tmp_mik[2], tmp_mjk[2], tmp_hik[2], tmp_hjk[2];
+
+ GO_init();
+
+ memset(&tmp_go, 0, sizeof(tmp_go));
+ memset(&tmp_l, 0, sizeof(tmp_l));
+ memset(&tmp_ml, 0, sizeof(tmp_ml));
+ for (i = 0;i < 2;i++)
+ {
+ tmp_lib[i] = 0;
+ tmp_mik[i] = tmp_mjk[i] = tmp_hik[i] = tmp_hjk[i] = -1;
+ }
+
+
+ me = BBLACK;
+ he = BWHITE;
+ hand = 0;
+ totalgo = 0;
+ hik = hjk = -1;
+ mik = mjk = -1;
+
+ setutmpmode(GO);
+
+ clear();
+
+ prints("\033[1;46m ³ò´Ñ¥´ÃÐ \033[45m%66s\033[m", " ");
+ GO_cleantable();
+
+ /* film_out(FILM_GO, 1); */
+
+ mv.x = mv.y = 9;
+
+ for(;;)
+ {
+ move(8, 46);
+ clrtoeol();
+ prints("½ü¨ì %s ¤è¤U¤F....", bw_chess[me - 1]);
+
+ move(10, 46);
+ clrtoeol();
+ if (totalgo > 0)
+ {
+ if (pool[totalgo - 1].x == -1 || pool[totalgo - 1].y == -1)
+ prints("%s #%-3d PASS ¤W¤@¤â ", bw_chess[(totalgo - 1) & 1], totalgo);
+ else
+ prints("%s #%-3d %.1s%-2d ¤W¤@¤â ", bw_chess[(totalgo - 1) & 1], totalgo, locE + pool[totalgo - 1].x, pool[totalgo - 1].y + 1);
+ }
+
+ for (i = totalgo - 1;i > 0 && totalgo - i <= 10;i--)
+ {
+ move(10 + totalgo - i, 46);
+ clrtoeol();
+ if (pool[i - 1].x == -1 || pool[i - 1].y == -1)
+ prints("%s #%-3d PASS", bw_chess[(i - 1) % 2], i);
+ else
+ prints("%s #%-3d %.1s%-2d ", bw_chess[(i - 1) % 2], i, locE + pool[i - 1].x, pool[i - 1].y + 1);
+ }
+
+ outmsg(" ¥´ÃÐ  (¡ö¡ô¡õ¡÷)²¾°Ê (ªÅ¥ÕÁä/ENTER)¤U¤l (u)¦^¤W¤@¨B \033[31m(z)\033[30mÂ÷¶} ");
+
+ BGOTO(mv.x, mv.y);
+
+ ch = igetch();
+
+ if (ch == 'z')
+ break;
+ else if (ch == 'u')
+ {
+ memset(go, 0, sizeof(go));
+ memset( l, 0, sizeof(go));
+ memset(ml, 0, sizeof(go));
+ memset(&tmp_go, 0, sizeof(tmp_go));
+ memset(&tmp_l, 0, sizeof(tmp_l));
+ memset(&tmp_ml, 0, sizeof(tmp_ml));
+ for (i = 0;i < 2;i++)
+ {
+ tmp_lib[i] = 0;
+ tmp_mik[i] = tmp_mjk[i] = tmp_hik[i] = tmp_hjk[i] = -1;
+ }
+ me = BBLACK;
+ he = BWHITE;
+ hik = hjk = -1;
+ mik = mjk = -1;
+
+ /* film_out(FILM_GO, 1); */
+ totalgo--;
+ GO_cleantable();
+ for (i = 0;i < totalgo;i++)
+ {
+ BGOTO(pool[i].x, pool[i].y);
+ outs(bw_chess[me - 1]);
+ redoln();
+ go[(int)pool[i].x][(int)pool[i].y] = me;
+ GO_examboard(he);
+ memcpy(&tmp_go[me - 1], &go, sizeof(l));
+ memcpy(&tmp_l[me - 1], &l, sizeof(l));
+ memcpy(&tmp_ml[me - 1], &ml, sizeof(ml));
+ tmp_lib[me - 1] = lib;
+ tmp_mik[me - 1] = mik;
+ tmp_mjk[me - 1] = mjk;
+ tmp_hik[me - 1] = hik;
+ tmp_hjk[me - 1] = hjk;
+ me = he;
+ he = 3 - me;
+ memcpy(&go, &tmp_go[me - 1], sizeof(l));
+ memcpy(&l, &tmp_l[me - 1], sizeof(l));
+ memcpy(&ml, &tmp_ml[me - 1], sizeof(ml));
+ lib = tmp_lib[me - 1];
+ mik = tmp_mik[me - 1];
+ mjk = tmp_mjk[me - 1];
+ hik = tmp_hik[me - 1];
+ hjk = tmp_hjk[me - 1];
+ go[(int)pool[i].x][(int)pool[i].y] = he;
+ GO_examboard(me);
+ }
+ mv = *(--v);
+ }
+ else
+ {
+ if (go_key(0, ch, &mv))
+ {
+ GO_add(&mv);
+ totalgo++;
+ BGOTO(mv.x, mv.y);
+ outs(bw_chess[me - 1]);
+ redoln();
+ go[(int)mv.x][(int)mv.y] = me;
+ GO_examboard(he);
+ memcpy(&tmp_go[me - 1], &go, sizeof(l));
+ memcpy(&tmp_l[me - 1], &l, sizeof(l));
+ memcpy(&tmp_ml[me - 1], &ml, sizeof(ml));
+ tmp_lib[me - 1] = lib;
+ tmp_mik[me - 1] = mik;
+ tmp_mjk[me - 1] = mjk;
+ tmp_hik[me - 1] = hik;
+ tmp_hjk[me - 1] = hjk;
+ me = he;
+ he = 3 - me;
+ memcpy(&go, &tmp_go[me - 1], sizeof(l));
+ memcpy(&l, &tmp_l[me - 1], sizeof(l));
+ memcpy(&ml, &tmp_ml[me - 1], sizeof(ml));
+ lib = tmp_lib[me - 1];
+ mik = tmp_mik[me - 1];
+ mjk = tmp_mjk[me - 1];
+ hik = tmp_hik[me - 1];
+ hjk = tmp_hjk[me - 1];
+ go[(int)mv.x][(int)mv.y] = he;
+ GO_examboard(me);
+ }
+ }
+ }
+
+ if (v > pool)
+ {
+ char ans[3];
+
+ getdata(b_lines - 1, 0, "­n¦s¦¨´ÑÃжÜ(Y/N)¡H[Y] ", ans, 3, LCECHO);
+
+ if (*ans != 'n')
+ GO_log(NULL);
+ }
+
+ return 0;
+}
diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c
index 78d6cab5..fcfdf4fb 100644
--- a/mbbsd/gomo.c
+++ b/mbbsd/gomo.c
@@ -1,15 +1,11 @@
/* $Id$ */
#include "bbs.h"
+#include "gomo.h"
#define QCAST int (*)(const void *, const void *)
-static char * const chess[] = {"¡´", "¡³"};
static int tick, lastcount, mylasttick, hislasttick;
-
-typedef struct {
- char x;
- char y;
-} Horder_t;
+static char ku[BRDSIZ][BRDSIZ];
static Horder_t *v;
@@ -200,7 +196,7 @@ HO_log(Horder_t *pool, char *user)
i = 0;
do {
- fprintf(log, "[%2d]%s ==> %c%d%c", i + 1, chess[i % 2],
+ fprintf(log, "[%2d]%s ==> %c%d%c", i + 1, bw_chess[i % 2],
'A' + ptr->x, ptr->y + 1, (i % 2) ? '\n' : '\t');
i++;
} while (++ptr < v);
@@ -461,7 +457,7 @@ gomoku(int fd)
ku[(int)mv.x][(int)mv.y] = he;
bell();
BGOTO(mv.x, mv.y);
- outs(chess[he - 1]);
+ outs(bw_chess[he - 1]);
if (win) {
outmsg(win == 1 ? "¹ï¤èŤF!" : "¹ï¤è¸T¤â");
@@ -488,7 +484,7 @@ gomoku(int fd)
int win;
HO_add(&mv);
BGOTO(mv.x, mv.y);
- outs(chess[me - 1]);
+ outs(bw_chess[me - 1]);
win = chkmv(&mv, me, me == BBLACK);
ku[(int)mv.x][(int)mv.y] = me;
mylasttick = tick;
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 402a71c6..c202e786 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -914,7 +914,8 @@ user_login()
log_usies("ENTER", fromhost);
setproctitle("%s: %s", margs, cuser.userid);
resolve_fcache();
- resolve_boards();
+ /* resolve_boards(); */
+ numboards = SHM->Bnumber;
memset(&water[0], 0, sizeof(water_t) * 6);
strlcpy(water[0].userid, " ¥þ³¡ ", sizeof(water[0].userid));
diff --git a/mbbsd/menu.c b/mbbsd/menu.c
index fc75a145..3363e2e2 100644
--- a/mbbsd/menu.c
+++ b/mbbsd/menu.c
@@ -478,14 +478,15 @@ const static commands_t playlist[] = {
{chicken_main,PERM_LOGINOK, "CChicken "
"¡i\033[1;34m ¢Þtt¾iÂû³õ \033[m¡j"},
{playground,PERM_LOGINOK, "AAmusement ¡i\033[1;33m ¢Þtt¹C¼Ö³õ \033[m¡j"},
- {chessroom, PERM_LOGINOK, "BBhineseChess ¡i\033[1;34m ¢Þtt´Ñ°|\033[m¡j"},
+ {chessroom, PERM_LOGINOK, "BBhineseChess¡i\033[1;34m ¢Þtt´Ñ°| \033[m¡j"},
{NULL, 0, NULL}
};
const static commands_t chesslist[] = {
- {chc_main, PERM_LOGINOK, "11ChessFight ¡i\033[1;33m ÁÜ §½ \033[m¡j"},
- {chc_personal, PERM_LOGINOK, "22SelfPlay ¡i\033[1;34m ¥´ ÃÐ \033[m¡j"},
- {chc_watch, PERM_LOGINOK, "33ChessWatch ¡i\033[1;35m Æ[ ´Ñ \033[m¡j"},
+ {chc_main, PERM_LOGINOK, "11ChessFight ¡i\033[1;33m ¶H´ÑÁܧ½ \033[m¡j"},
+ {chc_personal, PERM_LOGINOK, "22SelfPlay ¡i\033[1;34m ¶H´Ñ¥´ÃÐ \033[m¡j"},
+ {chc_watch, PERM_LOGINOK, "33ChessWatch ¡i\033[1;35m ¶H´ÑÆ[´Ñ \033[m¡j"},
+ {GoBot, PERM_LOGINOK, "44GoBot ¡i\033[1;36m ³ò´Ñ¥´ÃÐ \033[m¡j"},
{NULL, 0, NULL}
};
diff --git a/mbbsd/merge.c b/mbbsd/merge.c
index 93aafaf4..9601bf1e 100644
--- a/mbbsd/merge.c
+++ b/mbbsd/merge.c
@@ -102,7 +102,7 @@ m_fpg()
#endif
i = cuser.exmailbox + man.mailk + man.keepmail;
- if (i > 1000) i = 1000;
+ if (i > MAX_EXKEEPMAIL) i = MAX_EXKEEPMAIL;
sprintf(buf, "±zªºªá¶é«H½c¦³ %d (%dk), ­ì¦³ %d ¶×¤J«á¦@¦³ %d\n",
man.keepmail, man.mailk, cuser.exmailbox, i);
strcat(msg, buf);
@@ -177,7 +177,7 @@ m_fpg()
Copy(buf, genbuf);
strcat(buf, genbuf);
friend_load(FRIEND_OVERRIDE);
- strcat(msg, "¶×¤J¦n¦³¤Íͳææ\n");
+ strcat(msg, "¶×¤J¦n¤Í¦W³æ\n");
}
sprintf(buf, "±b¸¹¶×¤J³ø§i %s -> %s ", userid, cuser.userid);
post_msg("Security", buf, msg, "[¨t²Î¦w¥þ§½]");
@@ -205,7 +205,7 @@ m_fpg_brd(char *bname, char *fromdir)
if(!getdata(20,0, "¤p³½ªºªO¦W [­^¤å¤j¤p¼g­n§¹¥þ¥¿½T]:", fbname, 20,
DOECHO)) return;
}
- while(invalid_brdname(fbname));
+ while((invalid_brdname(fbname)&1));
sprintf(buf, "fpg/boards/%s.inf", fbname);
if(!dashf(buf))
diff --git a/mbbsd/register.c b/mbbsd/register.c
index 64b0afe5..a578f16a 100644
--- a/mbbsd/register.c
+++ b/mbbsd/register.c
@@ -217,10 +217,11 @@ new_register()
}
getdata(17, 0, msg_uid, newuser.userid,
sizeof(newuser.userid), DOECHO);
+ strcpy(passbuf, newuser.userid); //PTT: getuser·|­×­×­××¥¿
- if (bad_user_id(newuser.userid))
+ if (bad_user_id(passbuf))
outs("µLªk±µ¨ü³o­Ó¥N¸¹¡A½Ð¨Ï¥Î­^¤å¦r¥À¡A¨Ã¥B¤£­n¥]§tªÅ®æ\n");
- else if ((id = getuser(newuser.userid)) &&
+ else if ((id = getuser(passbuf)) &&
(id = check_and_expire_account(id, &xuser)) >= 0) {
if (id == 999999)
outs("¦¹¥N¸¹¤w¸g¦³¤H¨Ï¥Î ¬O¤£¦º¤§¨­");
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index 9c5d4ce7..78c3c251 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -7,7 +7,7 @@ static char * const IdleTypeTable[] = {
"°¸¦bªá§b°Õ", "±¡¤H¨Ó¹q", "³V­¹¤¤", "«ô¨£©P¤½", "°²¦ºª¬ºA", "§Ú¦b«ä¦Ò"
};
static char * const sig_des[] = {
- "°«Âû", "²á¤Ñ", "", "¤U´Ñ", "¶H´Ñ", "·t´Ñ"
+ "°«Âû", "²á¤Ñ", "", "¤U´Ñ", "¶H´Ñ", "·t´Ñ", "¤U³ò´Ñ",
};
#define MAX_SHOW_MODE 4
@@ -78,7 +78,7 @@ char *
modestring(userinfo_t * uentp, int simple)
{
static char modestr[40];
- char *notonline = "¤£¦b¯¸¤W";
+ static char *const notonline = "¤£¦b¯¸¤W";
register int mode = uentp->mode;
register char *word;
int fri_stat;
@@ -89,6 +89,7 @@ modestring(userinfo_t * uentp, int simple)
word = ModeTypeTable[mode % MAX_MODES];
} else
word = ModeTypeTable[mode];
+
fri_stat = friend_stat(currutmp, uentp);
if (!(HAS_PERM(PERM_SYSOP) || HAS_PERM(PERM_SEECLOAK)) &&
((uentp->invisible || (fri_stat & HRM)) &&
@@ -101,8 +102,9 @@ modestring(userinfo_t * uentp, int simple)
word = modestr;
} else if (!mode && *uentp->chatid == 1) {
if (!simple)
- snprintf(modestr, sizeof(modestr),
- "¦^À³ %s", getuserid(uentp->destuid));
+ snprintf(modestr, sizeof(modestr), "¦^À³ %s",
+ isvisible_uid(uentp->destuid) ?
+ getuserid(uentp->destuid) : "ªÅ®ð");
else
snprintf(modestr, sizeof(modestr), "¦^À³©I¥s");
}
@@ -131,26 +133,16 @@ modestring(userinfo_t * uentp, int simple)
return word;
else if (uentp->in_chat && mode == CHATING)
snprintf(modestr, sizeof(modestr), "%s (%s)", word, uentp->chatid);
- else if (mode == TALK) {
+ else if (mode == TALK || mode == M_FIVE || mode == CHC || mode == GO
+ || mode == DARK) {
if (!isvisible_uid(uentp->destuid)) /* Leeym ¹ï¤è(µµ¦â)Áô§Î */
- snprintf(modestr, sizeof(modestr), "%s", "¥æ½Í ªÅ®ð");
+ snprintf(modestr, sizeof(modestr), "%s ªÅ®ð", word);
/* Leeym * ¤j®a¦Û¤vµo´§§a¡I */
else
snprintf(modestr, sizeof(modestr),
"%s %s", word, getuserid(uentp->destuid));
- } else if (mode == M_FIVE) {
- if (!isvisible_uid(uentp->destuid))
- snprintf(modestr, sizeof(modestr), "%s", "¤­¤l´Ñ ªÅ®ð");
- else
- snprintf(modestr, sizeof(modestr), "%s %s", word, getuserid(uentp->destuid));
} else if (mode == CHESSWATCHING) {
snprintf(modestr, sizeof(modestr), "Æ[´Ñ");
- } else if (mode == CHC) {
- if (isvisible_uid(uentp->destuid))
- snprintf(modestr, sizeof(modestr), "%s", "¤U¶H´Ñ");
- else
- snprintf(modestr, sizeof(modestr),
- "¤U¶H´Ñ %s", getuserid(uentp->destuid));
} else if (mode != PAGE && mode != TQUERY)
return word;
else
@@ -1357,6 +1349,7 @@ my_talk(userinfo_t * uin, int fri_stat, char defact)
if (ch == EDITING || ch == TALK || ch == CHATING || ch == PAGE ||
ch == MAILALL || ch == MONITOR || ch == M_FIVE || ch == CHC ||
+ ch == DARK || ch == GO ||
(!ch && (uin->chatid[0] == 1 || uin->chatid[0] == 3)) ||
uin->lockmode == M_FIVE || uin->lockmode == CHC) {
if (ch == CHC) {
@@ -1386,8 +1379,9 @@ my_talk(userinfo_t * uin, int fri_stat, char defact)
outs(msg_usr_left);
} else {
showplans(uin->userid);
- getdata(2, 0, "­n©M¥L(¦o) (T)½Í¤Ñ(F)¤U¤­¤l´Ñ(P)°«Ãdª«"
- "(C)¤U¶H´Ñ(D)¤U·t´Ñ(N)¨S¨Æ§ä¿ù¤H¤F?[N] ", genbuf, 4, LCECHO);
+ move(2, 0);
+ outs("­n©M¥L(¦o) (T)½Í¤Ñ(F)¤U¤­¤l´Ñ(P)°«Ãdª«(C)¤U¶H´Ñ(D)¤U·t´Ñ(G)¤U³ò´Ñ\n");
+ getdata(3, 0, " (N)¨S¨Æ§ä¿ù¤H¤F?[N] ", genbuf, 4, LCECHO);
switch (*genbuf) {
case 'y':
case 't':
@@ -1404,6 +1398,9 @@ my_talk(userinfo_t * uin, int fri_stat, char defact)
case 'd':
uin->sig = SIG_DARK;
break;
+ case 'g':
+ uin->sig = SIG_GO;
+ break;
case 'p':
reload_chicken();
getuser(uin->userid);
@@ -1457,6 +1454,9 @@ my_talk(userinfo_t * uin, int fri_stat, char defact)
case SIG_CHC:
chc(msgsock, CHC_VERSUS);
break;
+ case SIG_GO:
+ gochess(msgsock);
+ break;
case SIG_TALK:
default:
do_talk(msgsock);
@@ -2468,9 +2468,11 @@ userlist(void)
case 'm':
if (HAS_PERM(PERM_BASIC)) {
+ char userid[IDLEN + 1];
+ strlcpy(userid, uentp->userid, sizeof(userid));
stand_title("±H «H");
- prints("[±H«H] ¦¬«H¤H¡G%s", uentp->userid);
- my_send(uentp->userid);
+ prints("[±H«H] ¦¬«H¤H¡G%s", userid);
+ my_send(userid);
setutmpmode(LUSERS);
redrawall = redraw = 1;
}
@@ -2748,9 +2750,9 @@ talkreply(void)
" (B) ¹ï¤£°_¡A§Ú¦³¨Æ±¡¤£¯à¸ò§A %s\n",
sig_des[sig], sig_des[sig]);
prints(" (C) ½Ð¤£­n§n§Ú¦n¶Ü¡H"
- " (D) §Ú­nÂ÷¯¸Åo..¤U¦¸¦A²á§a.......\n");
+ " (D) §Ú­nÂ÷¯¸Åo..¤U¦¸¦A²á§a.......\n");
prints(" (E) ¦³¨Æ¶Ü¡H½Ð¥ý¨Ó«H"
- " (F) \033[1;33m§Ú¦Û¤v¿é¤J²z¥Ñ¦n¤F...\033[m\n");
+ " (F) \033[1;33m§Ú¦Û¤v¿é¤J²z¥Ñ¦n¤F...\033[m\n");
prints(" (1) %s¡H¥ý®³100»È¨â¨Ó"
" (2) %s¡H¥ý®³1000»È¨â¨Ó..\n\n", sig_des[sig], sig_des[sig]);
@@ -2799,6 +2801,9 @@ talkreply(void)
case SIG_CHC:
chc(a, CHC_VERSUS);
break;
+ case SIG_GO:
+ gochess(a);
+ break;
case SIG_TALK:
default:
do_talk(a);
diff --git a/mbbsd/var.c b/mbbsd/var.c
index 5198b45a..f7062848 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -259,11 +259,13 @@ char * const ModeTypeTable[MAX_MODES] = {
"¤õ¨®¬d¸ß", /* RAIL_WAY */
"·j´M¿ï³æ", /* SREG */
"¤U¶H´Ñ", /* CHC */
- "¤U·tµX", /* DARK */
- "NBA¤j²q´ú" /* TMPJACK */
+ "¤U·t´Ñ", /* DARK */
+ "NBA¤j²q´ú", /* TMPJACK */
"¢Þtt¬dº]¨t²Î", /* JCEE */
- "­«½s¤å³¹" /* REEDIT */
+ "­«½s¤å³¹", /* REEDIT */
"³¡¸¨®æ", /* BLOGGING */
+ "¬Ý¶H´Ñ", /* CHESSWATCHING */
+ "¤U³ò´Ñ", /* GO */
"", /* for future usage */
"",
"",
@@ -307,10 +309,6 @@ char * const ModeTypeTable[MAX_MODES] = {
"",
"",
"",
- "",
- "",
- "",
- "",
""
};
@@ -405,7 +403,7 @@ screenline_t *big_picture = NULL;
char roll;
/* gomo.c */
-char ku[BRDSIZ][BRDSIZ];
+const char * const bw_chess[] = {"¡´", "¡³"};
unsigned char *pat, *adv;
unsigned char * const pat_gomoku /* [1954] */ =
/* 0 */ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@@ -602,7 +600,7 @@ word_t *toplev;
#ifndef _BBS_UTIL_C_
/* menu.c */
const commands_t cmdlist[] = {
- {admin, PERM_SYSOP | PERM_VIEWSYSOP, "00Admin ¡i ¨t²ÎºûÅ@°Ï ¡j"},
+ {admin, PERM_SYSOP|PERM_ACCOUNTS|PERM_BOARD|PERM_VIEWSYSOP, "00Admin ¡i ¨t²ÎºûÅ@°Ï ¡j"},
{Announce, 0, "AAnnounce ¡i ºëµØ¤½§GÄæ ¡j"},
{Boards, 0, "FFavorite ¡i §Ú ªº ³Ì·R ¡j"},
{root_board, 0, "CClass ¡i ¤À²Õ°Q½×°Ï ¡j"},
diff --git a/util/Makefile b/util/Makefile
index 2fd805e3..4c5312b5 100644
--- a/util/Makefile
+++ b/util/Makefile
@@ -23,7 +23,7 @@ CPROG_WITH_UTIL= \
indexuser yearsold toplazyBM toplazyBBM \
reaper buildAnnounce inndBM shmctl \
outmail chkhbf checkmoney merge_dir \
- transman angel gamblegive
+ transman angel gamblegive checkdir
# ¤U­±³o¨Çµ{¦¡, ·|ª½±µ³Q compile
CPROG_WITHOUT_UTIL= \
@@ -38,8 +38,7 @@ PROGS= ${UTIL_OBJS} ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} \
openticket.sh stock.sh topsong.sh weather.sh \
stock.perl weather.perl toplazyBM.sh toplazyBBM.sh \
dailybackup.pl tarqueue.pl waterball.pl filtermail.pl \
- getbackup.pl udnnews.pl rebuildaloha.pl railway_wrapper.pl\
- checkdir
+ getbackup.pl udnnews.pl rebuildaloha.pl railway_wrapper.pl
all: ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} ${PROGS}
diff --git a/util/account.c b/util/account.c
index 6c05b569..ce7e5f94 100644
--- a/util/account.c
+++ b/util/account.c
@@ -1,45 +1,42 @@
/* $Id$ */
#include "bbs.h"
-//test
+// test
#define ACCOUNT_MAX_LINE 16
#define ADJUST_M 6 /* adjust back 5 minutes */
void
-reset_garbage()
+reset_garbage(void)
{
- if (SHM == NULL)
- {
+ if (SHM == NULL) {
attach_SHM();
if (SHM->Ptouchtime == 0)
SHM->Ptouchtime = 1;
}
-
-/* ¤£¾ã­Óreload?
- for(n=0;n<=SHM->max_film;n++)
- printf("\n**%d**\n %s \n",n,SHM->notes[n]);
- */
+ /*
+ * ¤£¾ã­Óreload? for(n=0;n<=SHM->max_film;n++) printf("\n**%d**\n %s
+ * \n",n,SHM->notes[n]);
+ */
SHM->Puptime = 0;
reload_pttcache();
printf("\n°ÊºA¬ÝªO¼Æ[%d]\n", SHM->max_film);
-/*
- for(n=0; n<MAX_MOVIE_SECTION; n++)
- printf("sec%d=> °_ÂI:%d ¤U¦¸­n´«ªº:%d\n ",n,SHM->n_notes[n],
- SHM->next_refresh[n]);
- printf("\n");
-*/
+ /*
+ * for(n=0; n<MAX_MOVIE_SECTION; n++) printf("sec%d=> °_ÂI:%d
+ * ¤U¦¸­n´«ªº:%d\n ",n,SHM->n_notes[n], SHM->next_refresh[n]);
+ * printf("\n");
+ */
}
void
keeplog(fpath, board, title)
- char *fpath;
- char *board;
- char *title;
+ char *fpath;
+ char *board;
+ char *title;
{
- fileheader_t fhdr;
- int bid;
- char genbuf[256], buf[256];
+ fileheader_t fhdr;
+ int bid;
+ char genbuf[256], buf[256];
if (!board)
board = "Record";
@@ -49,57 +46,58 @@ keeplog(fpath, board, title)
stampfile(genbuf, &fhdr);
sprintf(buf, "mv %s %s", fpath, genbuf);
system(buf);
-/*
- printf("keep record:[%s][%s][%s][%s]\n",fpath, board, title,genbuf);
-*/
+ /*
+ * printf("keep record:[%s][%s][%s][%s]\n",fpath, board, title,genbuf);
+ */
strcpy(fhdr.title, title);
strcpy(fhdr.owner, "[¾ú¥v¦Ñ®v]");
sprintf(genbuf, "boards/%c/%s/.DIR", board[0], board);
append_record(genbuf, &fhdr, sizeof(fhdr));
/* XXX: bid of cache.c's getbnum starts from 1 */
- if((bid = getbnum(board)) > 0)
+ if ((bid = getbnum(board)) > 0)
touchbtotal(bid);
}
static void
my_outs(fp, buf, mode)
- FILE *fp;
- char buf[], mode;
+ FILE *fp;
+ char buf[], mode;
{
- static char state = '0';
+ static char state = '0';
if (state != mode)
fprintf(fp, "[3%cm", state = mode);
- if (buf[0])
- {
+ if (buf[0]) {
fprintf(fp, buf);
buf[0] = 0;
}
}
-void gzip(source, target, stamp)
- char *source, *target, *stamp;
+void
+gzip(source, target, stamp)
+ char *source, *target, *stamp;
{
- char buf[128];
+ char buf[128];
sprintf(buf, "gzip -f9n adm/%s%s", target, stamp);
rename(source, &buf[14]);
system(buf);
}
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- int hour, max, item, total, i, j, mo, da, max_user = 0, max_login = 0,
- max_reg = 0, mahour = 0, k, wday;
- char *act_file = ".act";
- char *log_file = "usies";
- char *wday_str = "UMTWRFS";
- char buf[256], buf1[256], *p;
- FILE *fp, *fp1;
- int act[27]; /* ¦¸¼Æ/²Ö­p®É¶¡/pointer */
- time_t now;
- struct tm *ptime;
+ int hour, max, item, total, i, j, mo, da, max_user = 0,
+ max_login = 0, max_reg = 0, mahour = 0, k, wday;
+ char *act_file = ".act";
+ char *log_file = "usies";
+ char *wday_str = "UMTWRFS";
+ char buf[256], buf1[256], *p;
+ FILE *fp, *fp1;
+ int act[27]; /* ¦¸¼Æ/²Ö­p®É¶¡/pointer */
+ time_t now;
+ struct tm *ptime;
attach_SHM();
nice(10);
@@ -109,36 +107,30 @@ int main(int argc, char **argv)
memset(act, 0, sizeof(act));
printf("¦¸¼Æ/²Ö­p®É¶¡\n");
- if ((ptime->tm_hour != 0) && (fp = fopen(act_file, "r")))
- {
+ if ((ptime->tm_hour != 0) && (fp = fopen(act_file, "r"))) {
fread(act, sizeof(act), 1, fp);
fclose(fp);
}
- if ((fp = fopen(log_file, "r")) == NULL)
- {
+ if ((fp = fopen(log_file, "r")) == NULL) {
printf("cann't open usies\n");
return 1;
}
if (act[26])
fseek(fp, act[26], 0);
- while (fgets(buf, 256, fp))
- {
- buf[11+2]=0;
+ while (fgets(buf, 256, fp)) {
+ buf[11 + 2] = 0;
hour = atoi(buf + 11);
- if (hour < 0 || hour > 23)
- {
+ if (hour < 0 || hour > 23) {
continue;
}
-//"09/06/1999 17:44:58 Mon "
-// 012345678901234567890123
- if (strstr(buf + 20, "ENTER"))
- {
+ //"09/06/1999 17:44:58 Mon "
+ // 012345678901234567890123
+ if (strstr(buf + 20, "ENTER")) {
act[hour]++;
continue;
}
- if ((p = (char *) strstr(buf + 40, "Stay:")))
- {
- if((hour = atoi(p + 5))) {
+ if ((p = (char *)strstr(buf + 40, "Stay:"))) {
+ if ((hour = atoi(p + 5))) {
act[24] += hour;
act[25]++;
}
@@ -147,50 +139,39 @@ int main(int argc, char **argv)
}
act[26] = ftell(fp);
fclose(fp);
- for (i = max = total = 0; i < 24; i++)
- {
+ for (i = max = total = 0; i < 24; i++) {
total += act[i];
- if (act[i] > max)
- {
+ if (act[i] > max) {
max_user = max = act[i];
mahour = i;
}
}
item = max / ACCOUNT_MAX_LINE + 1;
- if (!ptime->tm_hour)
- {
+ if (!ptime->tm_hour) {
keeplog("etc/today", "Record", "¤W¯¸¤H¦¸²Î­p");
keeplog("etc/money", "Security", "¥»¤éª÷¿ú©¹¨Ó°O¿ý");
keeplog("etc/illegal_money", "Security", "¥»¤é¹HªkÁÈ¿ú°O¿ý");
keeplog("etc/chicken", "Record", "Âû³õ³ø§i");
}
-
printf("¤W¯¸¤H¦¸²Î­p\n");
- if ((fp = fopen("etc/today", "w")) == NULL)
- {
+ if ((fp = fopen("etc/today", "w")) == NULL) {
printf("cann't open etc/today\n");
return 1;
}
fprintf(fp, "\t\t\t ¨C¤p®É¤W¯¸¤H¦¸²Î­p [%02d/%02d/%02d] \n\n", ptime->tm_year % 100, ptime->tm_mon + 1, ptime->tm_mday);
- for (i = ACCOUNT_MAX_LINE + 1; i > 0; i--)
- {
+ for (i = ACCOUNT_MAX_LINE + 1; i > 0; i--) {
strcpy(buf, " ");
- for (j = 0; j < 24; j++)
- {
+ for (j = 0; j < 24; j++) {
max = item * i;
hour = act[j];
- if (hour && (max > hour) && (max - item <= hour))
- {
+ if (hour && (max > hour) && (max - item <= hour)) {
my_outs(fp, buf, '3');
fprintf(fp, "%-3d", hour / 10);
- }
- else if (max <= hour)
- {
+ } else if (max <= hour) {
my_outs(fp, buf, '4');
fprintf(fp, "¢i ");
- }
- else
+ } else
strcat(buf, " ");
}
fprintf(fp, "\n");
@@ -201,12 +182,11 @@ int main(int argc, char **argv)
fprintf(fp, " Á`¦@¤W¯¸¤H¦¸¡G%-7d¥­§¡¨Ï¥Î¤H¼Æ¡G%d\n", total, total / 24);
fclose(fp);
- if((fp = fopen(act_file, "w"))) {
+ if ((fp = fopen(act_file, "w"))) {
fwrite(act, sizeof(act), 1, fp);
fclose(fp);
}
-
-/* -------------------------------------------------------------- */
+ /* -------------------------------------------------------------- */
sprintf(buf, "-%02d%02d%02d",
ptime->tm_year % 100, ptime->tm_mon + 1, ptime->tm_mday);
@@ -215,104 +195,89 @@ int main(int argc, char **argv)
printf("¾ú¥v¨Æ¥ó³B²z\n");
-/* Ptt ¾ú¥v¨Æ¥ó³B²z */
- if((fp = fopen("etc/history.data", "r"))) { /*³Ì¦h¦P®É¤W½u */
- if (fscanf(fp, "%d %d %d %d", &max_login, &max, &max_reg, &k))
- {
- int a;
+ /* Ptt ¾ú¥v¨Æ¥ó³B²z */
+ if ((fp = fopen("etc/history.data", "r"))) { /* ³Ì¦h¦P®É¤W½u */
+ if (fscanf(fp, "%d %d %d %d", &max_login, &max, &max_reg, &k)) {
+ int a;
resolve_fcache();
printf("¦¹®É¬q³Ì¦h¦P®É¤W½u:%d ¹L¥h:%d\n", a = SHM->max_user, k);
fclose(fp);
- if (a > k)
- {
+ if (a > k) {
ptime = localtime(&SHM->max_time);
- if((fp1 = fopen("etc/history", "a")))
- {
+ if ((fp1 = fopen("etc/history", "a"))) {
fprintf(fp1,
"¡· ¡i%02d/%02d/%02d %02d:%02d¡j"
- "¦P®É¦b§{¤º¤H¼Æ­º¦¸¹F¨ì %d ¤H¦¸\n",
- ptime->tm_mon + 1, ptime->tm_mday, ptime->tm_year % 100,
+ "¦P®É¦b§{¤º¤H¼Æ­º¦¸¹F¨ì %d ¤H¦¸\n",
+ ptime->tm_mon + 1, ptime->tm_mday, ptime->tm_year % 100,
ptime->tm_hour, ptime->tm_min, a);
fclose(fp1);
}
- if((fp = fopen("etc/history.data", "w")))
- {
+ if ((fp = fopen("etc/history.data", "w"))) {
fprintf(fp, "%d %d %d %d", max_login, max, max_reg, a);
fclose(fp);
}
}
- }
- else
+ } else
fclose(fp);
}
ptime = localtime(&now);
- if (ptime->tm_hour)
- {
+ if (ptime->tm_hour) {
/* rotate one line in today_is */
puts("¦h­Ó¸`¤é³B²z");
- if((fp1 = fopen("etc/today_is", "r"))) {
- char tod[100][20];
-
+ if ((fp1 = fopen("etc/today_is", "r"))) {
+ char tod[100][20];
+
i = 0;
- while(i < 100 && fgets(tod[i], sizeof(tod[0]), fp1))
+ while (i < 100 && fgets(tod[i], sizeof(tod[0]), fp1))
i++;
fclose(fp1);
-
+
fp1 = fopen("etc/today_is", "w");
- for(j = 0; j < i; j++)
+ for (j = 0; j < i; j++)
fputs(tod[j + 1 < i ? j + 1 : 0], fp1);
fclose(fp1);
}
}
-
-
- if (!ptime->tm_hour)
- {
+ if (!ptime->tm_hour) {
keeplog(".note", "Record", "¤ß±¡¯d¨¥ª©");
system("/bin/cp etc/today etc/yesterday");
-/* system("rm -f note.dat"); */
-/* Ptt */
+ /* system("rm -f note.dat"); */
+ /* Ptt */
sprintf(buf1, "[¤½¦w³ø§i] ¨Ï¥ÎªÌ¤W½uºÊ±± [%02d/%02d:%02d]"
,ptime->tm_mon + 1, ptime->tm_mday, ptime->tm_hour);
keeplog("usies", "Security", buf1);
printf("[¤½¦w³ø§i] ¨Ï¥ÎªÌ¤W½uºÊ±±\n");
gzip(log_file, "usies", buf);
printf("À£ÁY¨Ï¥ÎªÌ¤W½uºÊ±±\n");
-/* Ptt ¾ú¥v¨Æ¥ó³B²z */
+ /* Ptt ¾ú¥v¨Æ¥ó³B²z */
now = time(NULL) - ADJUST_M * 60; /* back to ancent */
ptime = localtime(&now);
attach_SHM();
- if((fp = fopen("etc/history.data", "r")))
- { /* ³æ¤é³Ì¦h¦¸¤H¦¸,¦P®É¤W½u,µù¥U */
- if (fscanf(fp, "%d %d %d %d", &max_login, &max, &max_reg, &k))
- {
+ if ((fp = fopen("etc/history.data", "r"))) { /* ³æ¤é³Ì¦h¦¸¤H¦¸,¦P®É¤W½u
+ * ,µù¥U */
+ if (fscanf(fp, "%d %d %d %d", &max_login, &max, &max_reg, &k)) {
fp1 = fopen("etc/history", "r+");
fseek(fp1, 0, 2);
- if (max_user > max)
- {
+ if (max_user > max) {
fprintf(fp1, "¡º ¡i%02d/%02d/%02d %02d¡j "
- "³æ¤@¤p®É¤W½u¤H¦¸­º¦¸¹F¨ì %d ¤H¦¸ \n"
+ "³æ¤@¤p®É¤W½u¤H¦¸­º¦¸¹F¨ì %d ¤H¦¸ \n"
,ptime->tm_mon + 1, ptime->tm_mday, ptime->tm_year % 100, mahour, max_user);
max = max_user;
}
- if (total > max_login)
- {
+ if (total > max_login) {
fprintf(fp1, "¡» ¡i%02d/%02d/%02d¡j "
- "³æ¤é¤W½u¤H¦¸­º¦¸¹F¨ì %d ¤H¦¸ \n"
+ "³æ¤é¤W½u¤H¦¸­º¦¸¹F¨ì %d ¤H¦¸ \n"
,ptime->tm_mon + 1, ptime->tm_mday, ptime->tm_year % 100, total);
max_login = total;
}
-
- if (SHM->number > max_reg + max_reg / 10)
- {
+ if (SHM->number > max_reg + max_reg / 10) {
fprintf(fp1, "¡¹ ¡i%02d/%02d/%02d¡j "
"Á`µù¥U¤H¼Æ´£¤É¨ì %d ¤H \n"
,ptime->tm_mon + 1, ptime->tm_mday, ptime->tm_year % 100, SHM->number);
max_reg = SHM->number;
}
-
fclose(fp1);
}
fclose(fp);
@@ -325,43 +290,42 @@ int main(int argc, char **argv)
/* Ptt ¸`¤é³B²z */
printf("¸`¤é³B²z\n");
- if((fp1 = fopen("etc/today_is", "w"))) {
+ if ((fp1 = fopen("etc/today_is", "w"))) {
i = 0;
- if((fp = fopen("etc/feast", "r"))) {
- while(fgets(buf1, sizeof(buf1), fp)) {
- if(buf[0] != '#' &&
- sscanf(buf1, "%d %c%c", &mo, buf, buf+1) == 3) {
- if (isdigit(buf[0])) {
- if (isdigit(buf[1])) {
- da = 10 * (buf[0] - '0') + (buf[1] - '0');
- if(ptime->tm_mday == da && ptime->tm_mon + 1 == mo) {
- i = 1;
- fprintf(fp1, "%-14.14s", &buf1[6]);
- }
- }
- else {
- if (buf[0] - '0' <= 4) {
- wday = 0;
- buf[1] = toupper(buf[1]);
- while(wday < 7 && buf[1] != *(wday_str + wday))
- wday++;
- if (ptime->tm_mon + 1 == mo && ptime->tm_wday == wday &&
- (ptime->tm_mday - 1)/7 + 1 == (buf[0] - '0')) {
- i = 1;
- fprintf(fp1, "%-14.14s", &buf1[6]);
- }
- }
- }
- }
+ if ((fp = fopen("etc/feast", "r"))) {
+ while (fgets(buf1, sizeof(buf1), fp)) {
+ if (buf[0] != '#' &&
+ sscanf(buf1, "%d %c%c", &mo, buf, buf + 1) == 3) {
+ if (isdigit(buf[0])) {
+ if (isdigit(buf[1])) {
+ da = 10 * (buf[0] - '0') + (buf[1] - '0');
+ if (ptime->tm_mday == da && ptime->tm_mon + 1 == mo) {
+ i = 1;
+ fprintf(fp1, "%-14.14s", &buf1[6]);
+ }
+ } else {
+ if (buf[0] - '0' <= 4) {
+ wday = 0;
+ buf[1] = toupper(buf[1]);
+ while (wday < 7 && buf[1] != *(wday_str + wday))
+ wday++;
+ if (ptime->tm_mon + 1 == mo && ptime->tm_wday == wday &&
+ (ptime->tm_mday - 1) / 7 + 1 == (buf[0] - '0')) {
+ i = 1;
+ fprintf(fp1, "%-14.14s", &buf1[6]);
+ }
+ }
+ }
+ }
}
}
fclose(fp);
}
printf("¸`¤é³B²z1\n");
- if(i == 0) {
- if((fp = fopen("etc/today_boring", "r"))) {
- while(fgets(buf1, sizeof(buf1), fp))
- if(strlen(buf1) > 3)
+ if (i == 0) {
+ if ((fp = fopen("etc/today_boring", "r"))) {
+ while (fgets(buf1, sizeof(buf1), fp))
+ if (strlen(buf1) > 3)
fprintf(fp1, "%s", buf1);
fclose(fp);
} else
@@ -369,17 +333,13 @@ int main(int argc, char **argv)
}
fclose(fp1);
}
-
/* Ptt Åwªïµe­±³B²z */
printf("Åwªïµe­±³B²z\n");
- if((fp = fopen("etc/Welcome.date", "r")))
- {
- char temp[50];
- while (fscanf(fp, "%d %d %s\n", &mo, &da, buf1) != EOF)
- {
- if (ptime->tm_mday == da && ptime->tm_mon + 1 == mo)
- {
+ if ((fp = fopen("etc/Welcome.date", "r"))) {
+ char temp[50];
+ while (fscanf(fp, "%d %d %s\n", &mo, &da, buf1) != EOF) {
+ if (ptime->tm_mday == da && ptime->tm_mon + 1 == mo) {
strcpy(temp, buf1);
sprintf(buf1, "cp -f etc/Welcomes/%s etc/Welcome", temp);
system(buf1);
@@ -389,34 +349,30 @@ int main(int argc, char **argv)
fclose(fp);
}
printf("Åwªïµe­±³B²z\n");
- if (ptime->tm_wday == 0)
- {
+ if (ptime->tm_wday == 0) {
keeplog("etc/week", "Record", "¥»¶g¼öªù¸ÜÃD");
gzip("bbslog", "bntplink", buf);
gzip("innd/bbslog", "innbbsd", buf);
gzip("etc/mailog", "mailog", buf);
}
-
if (ptime->tm_mday == 1)
keeplog("etc/month", "Record", "¥»¤ë¼öªù¸ÜÃD");
if (ptime->tm_yday == 1)
keeplog("etc/year", "Record", "¦~«×¼öªù¸ÜÃD");
- }
- else if (ptime->tm_hour == 3 && ptime->tm_wday == 6)
- {
- char *fn1 = "tmp";
- char *fn2 = "suicide";
+ } else if (ptime->tm_hour == 3 && ptime->tm_wday == 6) {
+ char *fn1 = "tmp";
+ char *fn2 = "suicide";
rename(fn1, fn2);
mkdir(fn1, 0755);
sprintf(buf, "tar cfz adm/%s-%02d%02d%02d.tgz %s",
- fn2, ptime->tm_year % 100, ptime->tm_mon + 1, ptime->tm_mday, fn2);
+ fn2, ptime->tm_year % 100, ptime->tm_mon + 1, ptime->tm_mday, fn2);
system(buf);
sprintf(buf, "/bin/rm -fr %s", fn2);
system(buf);
}
-/* Ptt reset Ptt's share memory */
+ /* Ptt reset Ptt's share memory */
printf("­«³]Pttcache »Pfcache\n");
SHM->Puptime = 0;
@@ -424,9 +380,9 @@ int main(int argc, char **argv)
reset_garbage();
printf("­pºâ¶i¯¸µe­±¼Æ: ");
- for( i = 0 ; i < 5 ; ++i ){
+ for (i = 0; i < 5; ++i) {
sprintf(buf, "etc/Welcome_login.%d", i);
- if( access(buf, 0) < 0 )
+ if (access(buf, 0) < 0)
break;
}
printf("%d\n", SHM->GV2.e.nWelcomes = i);
diff --git a/util/buildAnnounce.c b/util/buildAnnounce.c
index 0bfbefbd..be1b4ad4 100644
--- a/util/buildAnnounce.c
+++ b/util/buildAnnounce.c
@@ -4,7 +4,6 @@
#define GROUPROOT BBSHOME"/man/group"
extern boardheader_t *bcache;
-extern void resolve_boards();
extern int numboards;
int cmpboardclass(const void *a, const void *b)