diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2013-04-18 20:58:15 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2013-04-18 20:58:15 +0800 |
commit | c461d64ee59402d7f6c02d83f743879702ff2fb4 (patch) | |
tree | 71f1d057f5760e508c1e276cdedb590a67b90a5b | |
parent | 86f157eaf253a54253669b5783942f83fd8f6355 (diff) | |
download | pttbbs-c461d64ee59402d7f6c02d83f743879702ff2fb4.tar pttbbs-c461d64ee59402d7f6c02d83f743879702ff2fb4.tar.gz pttbbs-c461d64ee59402d7f6c02d83f743879702ff2fb4.tar.bz2 pttbbs-c461d64ee59402d7f6c02d83f743879702ff2fb4.tar.lz pttbbs-c461d64ee59402d7f6c02d83f743879702ff2fb4.tar.xz pttbbs-c461d64ee59402d7f6c02d83f743879702ff2fb4.tar.zst pttbbs-c461d64ee59402d7f6c02d83f743879702ff2fb4.zip |
Support DARK userec (ch_dark module does not use chess framework, so dark chess
results are still not recorded yet).
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5839 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/mbbsd/mbbsd.c | 3 | ||||
-rw-r--r-- | pttbbs/mbbsd/passwd.c | 13 | ||||
-rw-r--r-- | pttbbs/mbbsd/talk.c | 49 | ||||
-rw-r--r-- | pttbbs/mbbsd/user.c | 94 |
4 files changed, 76 insertions, 83 deletions
diff --git a/pttbbs/mbbsd/mbbsd.c b/pttbbs/mbbsd/mbbsd.c index a9dec00b..7eed6d41 100644 --- a/pttbbs/mbbsd/mbbsd.c +++ b/pttbbs/mbbsd/mbbsd.c @@ -935,6 +935,9 @@ setup_utmp(int mode) uinfo.go_win = cuser.go_win; uinfo.go_lose = cuser.go_lose; uinfo.go_tie = cuser.go_tie; + uinfo.dark_win = cuser.dark_win; + uinfo.dark_lose = cuser.dark_lose; + uinfo.dark_tie = cuser.dark_tie; uinfo.invisible = cuser.invisible % 2; uinfo.pager = cuser.pager % PAGER_MODES; uinfo.withme = cuser.withme & ~WITHME_ALLFLAG; diff --git a/pttbbs/mbbsd/passwd.c b/pttbbs/mbbsd/passwd.c index 3b33a529..91b02887 100644 --- a/pttbbs/mbbsd/passwd.c +++ b/pttbbs/mbbsd/passwd.c @@ -312,6 +312,7 @@ pwcuChessResult(int sigType, ChessGameResult r) assert(sizeof(* utmp_win) == sizeof(currutmp->chc_win)); assert(sizeof(*cuser_lose)== sizeof( cuser.five_lose)); assert(sizeof(* u_tie) == sizeof( u.go_tie)); + assert(sizeof(* u_tie) == sizeof( u.dark_tie)); // determine variables switch(sigType) @@ -352,6 +353,18 @@ pwcuChessResult(int sigType, ChessGameResult r) u_tie = &( u.five_tie); break; + case SIG_DARK: + utmp_win = &(currutmp->dark_win); + utmp_lose = &(currutmp->dark_lose); + utmp_tie = &(currutmp->dark_tie); + cuser_win = &( cuser.dark_win); + cuser_lose= &( cuser.dark_lose); + cuser_tie = &( cuser.dark_tie); + u_win = &( u.dark_win); + u_lose = &( u.dark_lose); + u_tie = &( u.dark_tie); + break; + default: assert(!"unknown sigtype"); break; diff --git a/pttbbs/mbbsd/talk.c b/pttbbs/mbbsd/talk.c index db7b290a..35b9a406 100644 --- a/pttbbs/mbbsd/talk.c +++ b/pttbbs/mbbsd/talk.c @@ -11,7 +11,7 @@ static char * const withme_str[] = { "談天", "下五子棋", "鬥寵物", "下象棋", "下暗棋", "下圍棋", "下黑白棋", NULL }; -#define MAX_SHOW_MODE 6 +#define MAX_SHOW_MODE 7 /* M_INT: monitor mode update interval */ #define M_INT 15 /* P_INT: interval to check for page req. in talk/chat */ @@ -23,8 +23,7 @@ typedef struct pickup_t { int friend, uoffset; } pickup_t; -/* 記錄 friend 的 user number */ -// +// If you want to change this, you have to change shm structure and shmctl.c #define PICKUP_WAYS 8 static char * const fcolor[11] = { @@ -1639,28 +1638,36 @@ descript(int show_mode, const userinfo_t * uentp, int diff, char *description, i return (((uentp->pager != PAGER_DISABLE && uentp->pager != PAGER_ANTIWB && diff) || HasUserPerm(PERM_SYSOP)) ? uentp->from : "*"); case 2: - snprintf(description, len, - "%4d/%4d/%2d %c", uentp->five_win, - uentp->five_lose, uentp->five_tie, - (uentp->withme&WITHME_FIVE)?'o':(uentp->withme&WITHME_NOFIVE)?'x':' '); + snprintf(description, len, "%4d/%4d/%2d %c", + uentp->five_win, uentp->five_lose, uentp->five_tie, + (uentp->withme&WITHME_FIVE)?'o': + (uentp->withme&WITHME_NOFIVE)?'x':' '); return description; case 3: - snprintf(description, len, - "%4d/%4d/%2d %c", uentp->chc_win, - uentp->chc_lose, uentp->chc_tie, - (uentp->withme&WITHME_CHESS)?'o':(uentp->withme&WITHME_NOCHESS)?'x':' '); + snprintf(description, len, "%4d/%4d/%2d %c", + uentp->chc_win, uentp->chc_lose, uentp->chc_tie, + (uentp->withme&WITHME_CHESS)?'o': + (uentp->withme&WITHME_NOCHESS)?'x':' '); return description; case 4: snprintf(description, len, "%4d %s", uentp->chess_elo_rating, - (uentp->withme&WITHME_CHESS)?"找我下棋":(uentp->withme&WITHME_NOCHESS)?"別找我":""); + (uentp->withme&WITHME_CHESS)?"找我下棋": + (uentp->withme&WITHME_NOCHESS)?"別找我":""); return description; case 5: - snprintf(description, len, - "%4d/%4d/%2d %c", uentp->go_win, - uentp->go_lose, uentp->go_tie, - (uentp->withme&WITHME_GO)?'o':(uentp->withme&WITHME_NOGO)?'x':' '); + snprintf(description, len, "%4d/%4d/%2d %c", + uentp->go_win, uentp->go_lose, uentp->go_tie, + (uentp->withme&WITHME_GO)?'o': + (uentp->withme&WITHME_NOGO)?'x':' '); + return description; + case 6: + snprintf(description, len, "%4d/%4d/%2d %c", + uentp->dark_win, uentp->dark_lose, uentp->dark_tie, + (uentp->withme&WITHME_DARK)?'o': + (uentp->withme&WITHME_NODARK)?'x':' '); return description; + default: syslog(LOG_WARNING, "damn!!! what's wrong?? show_mode = %d", show_mode); @@ -1903,10 +1910,12 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, int show_pid, int myfriend, int friendme, int bfriend, int badfriend) { char *msg_pickup_way[PICKUP_WAYS] = { - "嗨! 朋友", "網友代號", "網友動態", "發呆時間", "來自何方", " 五子棋 ", " 象棋 ", " 圍棋 ", + "嗨! 朋友", "網友代號", "網友動態", "發呆時間", "來自何方", + " 五子棋 ", " 象棋 ", " 圍棋 ", }; char *MODE_STRING[MAX_SHOW_MODE] = { "故鄉", "好友描述", "五子棋戰績", "象棋戰績", "象棋等級分", "圍棋戰績", + "暗棋戰績", }; char pagerchar[6] = "* -Wf"; @@ -2464,7 +2473,11 @@ userlist(void) break; case 'S': /* 顯示好友描述 */ +#ifdef HAVE_DARK_CHESS_LOG show_mode = (show_mode+1) % MAX_SHOW_MODE; +#else + show_mode = (show_mode+1) % (MAX_SHOW_MODE - 1); +#endif #ifdef CHESSCOUNTRY if (show_mode == 2) user_query_mode = 1; @@ -2472,6 +2485,8 @@ userlist(void) user_query_mode = 2; else if (show_mode == 5) user_query_mode = 3; + else if (show_mode == 6) + user_query_mode = 4; else user_query_mode = 0; #endif /* defined(CHESSCOUNTRY) */ diff --git a/pttbbs/mbbsd/user.c b/pttbbs/mbbsd/user.c index c3fd006c..6563c126 100644 --- a/pttbbs/mbbsd/user.c +++ b/pttbbs/mbbsd/user.c @@ -619,6 +619,26 @@ void Customize(void) vmsg("設定完成"); } +static void set_chess(const char *name, int y, + uint16_t *p_win, uint16_t *p_lose, uint16_t *p_tie) { + char buf[STRLEN]; + char prompt[STRLEN]; + char *p; + char *strtok_pos; + snprintf(buf, sizeof(buf), "%d/%d/%d", *p_win, *p_lose, *p_tie); + snprintf(prompt, sizeof(prompt), "%s 戰績 勝/敗/和:", name); + if (!getdata_str(y, 0, prompt, buf, 5 * 3 + 3, DOECHO, buf)) + return; + p = strtok_r(buf, "/\r\n", &strtok_pos); + if (!p) return; + *p_win = atoi(p); + p = strtok_r(NULL, "/\r\n", &strtok_pos); + if (!p) return; + *p_lose = atoi(p); + p = strtok_r(NULL, "/\r\n", &strtok_pos); + if (!p) return; + *p_tie = atoi(p); +} void uinfo_query(const char *orig_uid, int adminmode, int unum) @@ -951,75 +971,17 @@ uinfo_query(const char *orig_uid, int adminmode, int unum) if ((tmp = atoi(buf)) >= 0) x.vl_count = tmp; - snprintf(genbuf, sizeof(genbuf), - "%d/%d/%d", x.five_win, x.five_lose, x.five_tie); - if (getdata_str(y++, 0, "五子棋戰績 勝/敗/和:", buf, 16, DOECHO, - genbuf)) - while (1) { - char *p; - char *strtok_pos; - p = strtok_r(buf, "/\r\n", &strtok_pos); - if (!p) - break; - x.five_win = atoi(p); - p = strtok_r(NULL, "/\r\n", &strtok_pos); - if (!p) - break; - x.five_lose = atoi(p); - p = strtok_r(NULL, "/\r\n", &strtok_pos); - if (!p) - break; - x.five_tie = atoi(p); - break; - } - snprintf(genbuf, sizeof(genbuf), - "%d/%d/%d", x.chc_win, x.chc_lose, x.chc_tie); - if (getdata_str(y++, 0, " 象棋 戰績 勝/敗/和:", buf, 16, DOECHO, - genbuf)) - while (1) { - char *p; - char *strtok_pos; - p = strtok_r(buf, "/\r\n", &strtok_pos); - if (!p) - break; - x.chc_win = atoi(p); - p = strtok_r(NULL, "/\r\n", &strtok_pos); - if (!p) - break; - x.chc_lose = atoi(p); - p = strtok_r(NULL, "/\r\n", &strtok_pos); - if (!p) - break; - x.chc_tie = atoi(p); - break; - } - snprintf(genbuf, sizeof(genbuf), - "%d/%d/%d", x.go_win, x.go_lose, x.go_tie); - if (getdata_str(y++, 0, " 圍棋 戰績 勝/敗/和:", buf, 16, DOECHO, - genbuf)) - while (1) { - char *p; - char *strtok_pos; - p = strtok_r(buf, "/\r\n", &strtok_pos); - if (!p) - break; - x.go_win = atoi(p); - p = strtok_r(NULL, "/\r\n", &strtok_pos); - if (!p) - break; - x.go_lose = atoi(p); - p = strtok_r(NULL, "/\r\n", &strtok_pos); - if (!p) - break; - x.go_tie = atoi(p); - break; - } - y -= 3; // rollback games set to get more space + set_chess("五子棋", y++, &x.five_win, &x.five_lose, &x.five_tie); + set_chess("象棋", y++, &x.chc_win, &x.chc_lose, &x.chc_tie); + set_chess("圍棋", y++, &x.go_win, &x.go_lose, &x.go_tie); + set_chess("暗棋", y++, &x.dark_win, &x.dark_lose, &x.dark_tie); + y -= 4; // rollback games set to get more space move(y++, 0); clrtobot(); - prints("棋類: (五子棋)%d/%d/%d (象棋)%d/%d/%d (圍棋)%d/%d/%d\n", + prints("棋類: 五子:%d/%d/%d 象:%d/%d/%d 圍:%d/%d/%d 暗:%d/%d/%d\n", x.five_win, x.five_lose, x.five_tie, x.chc_win, x.chc_lose, x.chc_tie, - x.go_win, x.go_lose, x.go_tie); + x.go_win, x.go_lose, x.go_tie, + x.dark_win, x.dark_lose, x.dark_tie); #ifdef FOREIGN_REG if (getdata_str(y++, 0, "住在 1)台灣 2)其他:", buf, 2, DOECHO, x.uflag & UF_FOREIGN ? "2" : "1")) if ((tmp = atoi(buf)) > 0){ |