From c46fffb99342eee4d4eeec4e8a4707a294f0b3b7 Mon Sep 17 00:00:00 2001 From: in2 Date: Thu, 15 Jan 2004 17:37:12 +0000 Subject: add some comments for ofo water mode. set nkwbd default to 5, 5 git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1484 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/common.h | 4 ++++ mbbsd/mbbsd.c | 31 +++++++++++++++++++++++++++---- mbbsd/talk.c | 19 ++++++++++++++----- mbbsd/var.c | 6 +++--- util/shmctl.c | 12 ++++++------ 5 files changed, 54 insertions(+), 18 deletions(-) diff --git a/include/common.h b/include/common.h index 64064ed4..1b6826a7 100644 --- a/include/common.h +++ b/include/common.h @@ -185,4 +185,8 @@ #define STR_CURSOR "●" #define STR_UNCUR " " + +#define NOTREPLYING -1 +#define REPLYING 0 +#define RECVINREPLYING 1 #endif diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index d2f4aa87..2c2d6cbf 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -365,15 +365,38 @@ write_request(int sig) reentrant_write_request = 1; #endif if (WATERMODE(WATER_OFO)) { - if( (msgcount = currutmp->msgcount) > 0 ){ - for( i = 0 ; i < msgcount ; ++i ){ + /* 如果目前正在回水球模式的話, 就不能進行 add_history() , + 因為會改寫 water[], 而使回水球目的爛掉, 所以分成幾種情況考慮. + sig != 0表真的有水球進來, 故顯示. + sig == 0表示沒有水球進來, 不過之前尚有水球還沒寫到 water[]. + */ + static int alreadyshow = 0; + + if( sig ){ /* 真的有水球進來 */ + + /* 若原來正在 REPLYING , 則改成 RECVINREPLYING, + 這樣在回水球結束後, 會再呼叫一次 write_request(0) */ + if( wmofo == REPLYING ) + wmofo = RECVINREPLYING; + + /* 顯示 */ + for( ; alreadyshow < currutmp->msgcount && alreadyshow < MAX_MSGS + ; ++alreadyshow ){ bell(); - show_call_in(1, i); + show_call_in(1, alreadyshow); refresh(); - add_history(&currutmp->msgs[i]); } + } + + /* 看看是不是要把 currutmp->msg 拿回 water[] (by add_history()) + 須要是不在回水球中 (NOTREPLYING) */ + if( wmofo == NOTREPLYING && + (msgcount = currutmp->msgcount) > 0 ){ + for( i = 0 ; i < msgcount ; ++i ) + add_history(&currutmp->msgs[i]); if( (currutmp->msgcount -= msgcount) < 0 ) currutmp->msgcount = 0; + alreadyshow = 0; } } else { if (currutmp->mode != 0 && diff --git a/mbbsd/talk.c b/mbbsd/talk.c index f44b69b9..4af0fa92 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -105,7 +105,16 @@ modestring(userinfo_t * uentp, int simple) "回應 %s", getuserid(uentp->destuid)); else snprintf(modestr, sizeof(modestr), "回應呼叫"); - } else if (!mode && *uentp->chatid == 2) + } + else if (!mode && *uentp->chatid == 3) + snprintf(modestr, sizeof(modestr), "水球準備中"); + else if ( +#ifdef NOKILLWATERBALL + uentp->msgcount > 0 +#else + (!mode) && *uentp->chatid == 2 +#endif + ) if (uentp->msgcount < 10) { char *cnum[10] = {"", "一", "兩", "三", "四", "五", "六", "七", @@ -114,8 +123,6 @@ modestring(userinfo_t * uentp, int simple) "中%s顆水球", cnum[(int)(uentp->msgcount)]); } else snprintf(modestr, sizeof(modestr), "不行了 @_@"); - else if (!mode && *uentp->chatid == 3) - snprintf(modestr, sizeof(modestr), "水球準備中"); else if (!mode) return (uentp->destuid == 6) ? uentp->chatid : IdleTypeTable[(0 <= uentp->destuid && uentp->destuid < 6) ? @@ -540,9 +547,11 @@ my_write2(void) currstat = currstat0; currutmp->chatid[0] = c0; currutmp->mode = mode0; - if (wmofo == 1) + if (wmofo == RECVINREPLYING){ + wmofo = NOTREPLYING; write_request(0); - wmofo = -1; + } + wmofo = NOTREPLYING; } /* diff --git a/mbbsd/var.c b/mbbsd/var.c index e657aa68..89a88244 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -343,9 +343,9 @@ int wmofo = -1; * Ctrl-R) * * WATERMODE(WATER_OFO) by in2 - * wmofo = -1 沒在回水球 - * = 0 正在回水球 - * = 1 回水球間又接到水球 + * wmofo = NOTREPLYING 沒在回水球 + * = REPLYING 正在回水球 + * = RECVINREPLYING 回水球間又接到水球 * * wmofo >=0 時收到水球將只顯示, 不會到water[]裡, * 待回完水球的時候一次寫入. diff --git a/util/shmctl.c b/util/shmctl.c index fad17e36..001fd4eb 100644 --- a/util/shmctl.c +++ b/util/shmctl.c @@ -496,19 +496,19 @@ int bBMC(int argc, char **argv) #ifdef NOKILLWATERBALL int nkwbd(int argc, char **argv) { - int ch, sleeptime = 20, timeout = 20; + int ch, sleeptime = 5, timeout = 5; while( (ch = getopt(argc, argv, "s:t:h")) != -1 ) switch( ch ){ case 's': - if( (sleeptime = atoi(optarg)) < 10 ){ - fprintf(stderr, "sleeptime < 10? set to 20"); - sleeptime = 20; + if( (sleeptime = atoi(optarg)) <= 0 ){ + fprintf(stderr, "sleeptime <= 0? set to 5"); + sleeptime = 5; } break; case 't': - if( (timeout = atoi(optarg)) < 10 ){ - fprintf(stderr, "timeout < 10? set to 20"); + if( (timeout = atoi(optarg)) <= 0 ){ + fprintf(stderr, "timeout <= 0? set to 5"); timeout = 20; } break; -- cgit v1.2.3