diff options
-rw-r--r-- | include/pttstruct.h | 22 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 2 | ||||
-rw-r--r-- | mbbsd/talk.c | 98 |
3 files changed, 103 insertions, 19 deletions
diff --git a/include/pttstruct.h b/include/pttstruct.h index 7fa188e3..c6bf8107 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -100,7 +100,8 @@ typedef struct userec_t { unsigned char badsale; /* 競標 壞的評價 */ char myangel[IDLEN+1]; /* 我的小天使 */ unsigned short chess_elo_rating; /* 象棋等級分 */ - char pad[52]; + unsigned int withme; + char pad[48]; } userec_t; /* these are flags in userec_t.uflag */ #define PAGER_FLAG 0x4 /* true if pager was OFF last session */ @@ -125,6 +126,21 @@ typedef struct userec_t { #define REJ_OUTTAMAIL 0x400 /* true if don't accept outside mails */ #define REJECT_OUTTAMAIL (cuser.uflag2 & REJ_OUTTAMAIL) +/* flags in userec_t.withme */ +#define WITHME_ALLFLAG 0x55555555 +#define WITHME_TALK 0x00000001 +#define WITHME_NOTALK 0x00000002 +#define WITHME_FIVE 0x00000004 +#define WITHME_NOFIVE 0x00000008 +#define WITHME_PAT 0x00000010 +#define WITHME_NOPAT 0x00000020 +#define WITHME_CHESS 0x00000040 +#define WITHME_NOCHESS 0x00000080 +#define WITHME_DARK 0x00000100 +#define WITHME_NODARK 0x00000200 +#define WITHME_GO 0x00000400 +#define WITHME_NOGO 0x00000800 + #ifdef PLAY_ANGEL #define REJ_QUESTION 0x800 /* true if don't want to be angel for a while */ #define REJECT_QUESTION (cuser.uflag2 & REJ_QUESTION) @@ -273,6 +289,7 @@ typedef struct msgque_t { int msgmode; } msgque_t; +/* user data in shm */ typedef struct userinfo_t { int uid; /* Used to find user name in passwd file */ pid_t pid; /* kill() to notify user of talk request */ @@ -307,8 +324,7 @@ typedef struct userinfo_t { int friendtotal; /* 好友比較的cache 大小 */ char msgcount; msgque_t msgs[MAX_MSGS]; - // uptime 好像沒用到 - time_t uptime; + unsigned int withme; time_t lastact; /* 上次使用者動的時間 */ unsigned int brc_id; unsigned char lockmode; /* 不准 multi_login 玩的東西 */ diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 5a928602..611d603b 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -144,6 +144,7 @@ u_exit(char *mode) brc_finalize(); cuser.invisible = currutmp->invisible; + cuser.withme = currutmp->withme; cuser.pager = currutmp->pager; memcpy(cuser.mind, currutmp->mind, 4); setutmpbid(0); @@ -743,6 +744,7 @@ setup_utmp(int mode) uinfo.chess_elo_rating = cuser.chess_elo_rating; uinfo.invisible = cuser.invisible % 2; uinfo.pager = cuser.pager % 5; + uinfo.withme = cuser.withme; memcpy(uinfo.mind, cuser.mind, 4); #ifdef WHERE uinfo.from_alias = where(fromhost); diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 70faf745..2b9d8f03 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -9,8 +9,11 @@ static char * const IdleTypeTable[] = { static char * const sig_des[] = { "鬥雞", "聊天", "", "下棋", "象棋", "暗棋", "下圍棋", }; +static char * const withme_str[] = { + "談天", "下五子棋", "鬥寵物", "下象棋", "下暗棋", "下圍棋", NULL +}; -#define MAX_SHOW_MODE 4 +#define MAX_SHOW_MODE 5 #define M_INT 15 /* monitor mode update interval */ #define P_INT 20 /* interval to check for page req. in * talk/chat */ @@ -1344,7 +1347,6 @@ my_talk(userinfo_t * uin, int fri_stat, char defact) pid_t pid; char c; char genbuf[4]; - unsigned char mode0 = currutmp->mode; genbuf[0] = defact; @@ -1382,10 +1384,26 @@ my_talk(userinfo_t * uin, int fri_stat, char defact) //resetutmpent(); outs(msg_usr_left); } else { + int i,j; showplans(uin->userid); move(2, 0); + for(i=0;i<2;i++) { + if(uin->withme & (WITHME_ALLFLAG<<i)) { + if(i==0) + outs("歡迎跟我:"); + else + outs("請別找我:"); + for(j=0; j<32 && withme_str[j/2]; j+=2) + if(uin->withme & (1<<(j+i))) + if(withme_str[j/2]) { + outs(withme_str[j/2]); + outc(' '); + } + outc('\n'); + } + } outs("要和他(她) (T)談天(F)下五子棋(P)鬥寵物(C)下象棋(D)下暗棋(G)下圍棋\n"); - getdata(3, 0, " (N)沒事找錯人了?[N] ", genbuf, 4, LCECHO); + getdata(5, 0, " (N)沒事找錯人了?[N] ", genbuf, 4, LCECHO); switch (*genbuf) { case 'y': case 't': @@ -1537,18 +1555,18 @@ t_showhelp() "(f) 全部/好友列表 (數字) 跳至該使用者\n" "(p) 切換呼叫器 (g/i) 給錢/切換心情\n" "(a/d/o) 好友 增加/刪除/修改 (/)(s) 網友ID/暱稱搜尋\n" - "(N) 修改暱稱"); + "(N) 修改暱稱 (y) 我想找人聊天、下棋…\n"); if (HAS_PERM(PERM_PAGE)) { - outs("\n\n\033[36m【 交談專用鍵 】\033[m\n" + outs("\n\033[36m【 交談專用鍵 】\033[m\n" "(→)(t)(Enter) 跟他/她聊天\n" "(w) 熱線 Call in\n" "(^W)切換水球方式 一般 / 進階 / 未來\n" "(b) 對好友廣播 (一定要在好友列表中)\n" - "(^R) 即時回應 (有人 Call in 你時)"); + "(^R) 即時回應 (有人 Call in 你時)\n"); } if (HAS_PERM(PERM_SYSOP)) { - outs("\n\n\033[36m【 站長專用鍵 】\033[m\n\n"); + outs("\n\033[36m【 站長專用鍵 】\033[m\n\n"); outs("(u)/(H) 設定使用者資料/切換隱形模式\n"); outs("(K) 把壞蛋踢出去\n"); #if defined(SHOWBOARD) && defined(DEBUG) @@ -1630,18 +1648,20 @@ descript(int show_mode, userinfo_t * uentp, time_t diff) : "*"); case 2: snprintf(description, sizeof(description), - "%4d/%4d/%4d", uentp->five_win, - uentp->five_lose, uentp->five_tie); + "%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: -#ifdef DEBUG snprintf(description, sizeof(description), - "%4d", uentp->chess_elo_rating); -#else + "%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, sizeof(description), - "%4d/%4d/%4d", uentp->chc_win, - uentp->chc_lose, uentp->chc_tie); -#endif + "%4d %s", uentp->chess_elo_rating, + (uentp->withme&WITHME_CHESS)?"找我下棋":(uentp->withme&WITHME_NOCHESS)?"別找我":""); return description; default: syslog(LOG_WARNING, "damn!!! what's wrong?? show_mode = %d", @@ -1854,7 +1874,7 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, "嗨! 朋友", "網友代號", "網友動態", "發呆時間", "來自何方", " 五子棋 ", " 象棋 " }; char *MODE_STRING[MAX_SHOW_MODE] = { - "故鄉", "好友描述", "五子棋戰績", "象棋戰績" + "故鄉", "好友描述", "五子棋戰績", "象棋戰績", "象棋等級分", }; char pagerchar[5] = "* -Wf"; @@ -1982,6 +2002,47 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, } } +void set_withme_flag(void) +{ + int i; + char genbuf[20]; + int line; + + move(1, 0); + clrtobot(); + + do { + move(1, 0); + line=1; + for(i=0; i<16 && withme_str[i]; i++) { + clrtoeol(); + if(currutmp->withme&(1<<(i*2))) + prints("[%c] 我很想跟人%s, 歡迎任何人找我\n",'a'+i, withme_str[i]); + else if(currutmp->withme&(1<<(i*2+1))) + prints("[%c] 我不太想%s\n",'a'+i, withme_str[i]); + else + prints("[%c] (%s)沒意見\n",'a'+i, withme_str[i]); + line++; + } + getdata(line,0,"用字母切換 [想/不想/沒意見]",genbuf, sizeof(genbuf), DOECHO); + for(i=0;genbuf[i];i++) { + int ch=genbuf[i]; + ch=tolower(ch); + if('a'<=ch && ch<'a'+16) { + ch-='a'; + if(currutmp->withme&(1<<ch*2)) { + currutmp->withme&=~(1<<ch*2); + currutmp->withme|=1<<(ch*2+1); + } else if(currutmp->withme&(1<<(ch*2+1))) { + currutmp->withme&=~(1<<(ch*2+1)); + } else { + currutmp->withme|=1<<(ch*2); + } + } + } + } while(genbuf[0]!='\0'); +} + int call_in(userinfo_t * uentp, int fri_stat) { @@ -2562,6 +2623,11 @@ userlist(void) redrawall = redraw = 1; break; + case 'y': + set_withme_flag(); + redrawall = redraw = 1; + break; + default: if (now >= lastupdate + 2) redraw = 1; |