diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-10-16 14:39:09 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-10-16 14:39:09 +0800 |
commit | f1dc70216212a7bf817c0debbca2f6296542b043 (patch) | |
tree | 63270c5aefd854a1cbfa4830f5b9d33cea8df53f | |
parent | 9ef3d37fad2ba89a358d47dc7f3d6720940c8a47 (diff) | |
download | pttbbs-f1dc70216212a7bf817c0debbca2f6296542b043.tar pttbbs-f1dc70216212a7bf817c0debbca2f6296542b043.tar.gz pttbbs-f1dc70216212a7bf817c0debbca2f6296542b043.tar.bz2 pttbbs-f1dc70216212a7bf817c0debbca2f6296542b043.tar.lz pttbbs-f1dc70216212a7bf817c0debbca2f6296542b043.tar.xz pttbbs-f1dc70216212a7bf817c0debbca2f6296542b043.tar.zst pttbbs-f1dc70216212a7bf817c0debbca2f6296542b043.zip |
show chess rating not only in debug mode
let user set his attitude about talk/play with others
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2252 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-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; /* �v�� �a������ */ char myangel[IDLEN+1]; /* �ڪ��p�Ѩ� */ unsigned short chess_elo_rating; /* �H�ѵ��Ť� */ - 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; /* �n�ͤ����cache �j�p */ char msgcount; msgque_t msgs[MAX_MSGS]; - // uptime �n���S�Ψ� - time_t uptime; + unsigned int withme; time_t lastact; /* �W���ϥΪ̰ʪ��ɶ� */ unsigned int brc_id; unsigned char lockmode; /* ���� multi_login �����F�� */ 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[] = { "����", "���", "", "�U��", "�H��", "�t��", "�U���", }; +static char * const withme_str[] = { + "�ͤ�", "�U���l��", "���d��", "�U�H��", "�U�t��", "�U���", 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("�w���ڡG"); + else + outs("�ЧO��ڡG"); + 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("�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); + getdata(5, 0, " (N)�S�Ƨ���H�F?[N] ", genbuf, 4, LCECHO); switch (*genbuf) { case 'y': case 't': @@ -1537,18 +1555,18 @@ t_showhelp() "(f) ����/�n�ͦC�� (�Ʀr) ���ܸӨϥΪ�\n" "(p) �����I�s�� (g/i) ����/�����߱�\n" "(a/d/o) �n�� �W�[/�R��/�ק� (/)(s) ����ID/�ʺٷj�M\n" - "(N) �ק�ʺ�"); + "(N) �ק�ʺ� (y) �ڷQ��H��ѡB�U�ѡK\n"); if (HAS_PERM(PERM_PAGE)) { - outs("\n\n\033[36m�i ��ͱM���� �j\033[m\n" + outs("\n\033[36m�i ��ͱM���� �j\033[m\n" "(��)(t)(Enter) ��L���o���\n" "(w) ���u Call in\n" "(^W)�������y�覡 �@�� / �i�� / ����\n" "(b) ��n�ͼs�� (�@�w�n�b�n�ͦC����)\n" - "(^R) �Y�ɦ^�� (���H Call in �A��)"); + "(^R) �Y�ɦ^�� (���H Call in �A��)\n"); } if (HAS_PERM(PERM_SYSOP)) { - outs("\n\n\033[36m�i �����M���� �j\033[m\n\n"); + outs("\n\033[36m�i �����M���� �j\033[m\n\n"); outs("(u)/(H) �]�w�ϥΪ̸��/�������μҦ�\n"); outs("(K) ���a�J��X�h\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)?"��ڤU��":(uentp->withme&WITHME_NOCHESS)?"�O���":""); 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, "��! �B��", "���ͥN��", "���ͰʺA", "�o�b�ɶ�", "�Ӧۦ��", " ���l�� ", " �H�� " }; char *MODE_STRING[MAX_SHOW_MODE] = { - "�G�m", "�n�ʹy�z", "���l�Ѿ��Z", "�H�Ѿ��Z" + "�G�m", "�n�ʹy�z", "���l�Ѿ��Z", "�H�Ѿ��Z", "�H�ѵ��Ť�", }; 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] �ګܷQ��H%s, �w�����H���\n",'a'+i, withme_str[i]); + else if(currutmp->withme&(1<<(i*2+1))) + prints("[%c] �ڤ��ӷQ%s\n",'a'+i, withme_str[i]); + else + prints("[%c] (%s)�S�N��\n",'a'+i, withme_str[i]); + line++; + } + getdata(line,0,"�Φr������ [�Q/���Q/�S�N��]",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; |