diff options
author | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-05-18 17:14:32 +0800 |
---|---|---|
committer | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-05-18 17:14:32 +0800 |
commit | d00edbdbd10efdd918837b5958dba4577be59e84 (patch) | |
tree | 8fc451c3f5443deda2d4167056dc9cf3e8546e00 /mbbsd | |
parent | 36a55220bb41463b63308ea5b2c781bdfa453e9f (diff) | |
download | pttbbs-d00edbdbd10efdd918837b5958dba4577be59e84.tar pttbbs-d00edbdbd10efdd918837b5958dba4577be59e84.tar.gz pttbbs-d00edbdbd10efdd918837b5958dba4577be59e84.tar.bz2 pttbbs-d00edbdbd10efdd918837b5958dba4577be59e84.tar.lz pttbbs-d00edbdbd10efdd918837b5958dba4577be59e84.tar.xz pttbbs-d00edbdbd10efdd918837b5958dba4577be59e84.tar.zst pttbbs-d00edbdbd10efdd918837b5958dba4577be59e84.zip |
Many changes in structure.
Add sex restriction.
git-svn-id: http://opensvn.csie.org/pttbbs/branches/scw.angel@1999 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/mbbsd.c | 7 | ||||
-rw-r--r-- | mbbsd/talk.c | 49 | ||||
-rw-r--r-- | mbbsd/user.c | 35 | ||||
-rw-r--r-- | mbbsd/var.c | 4 |
4 files changed, 77 insertions, 18 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 8fef76de..345b9ad6 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -771,8 +771,11 @@ setup_utmp(int mode) #endif if (enter_uflag & CLOAK_FLAG) uinfo.invisible = YEA; - if (cuser.uflag2 & BEING_ANGEL) - uinfo.being_angel = 1; + + if (REJECT_QUESTION) + uinfo.angel = 1; + uinfo.angel |= ANGEL_STATUS() << 1; + getnewutmpent(&uinfo); SHM->UTMPneedsort = 1; if (!(cuser.numlogins % 20) && cuser.userlevel & PERM_BM) diff --git a/mbbsd/talk.c b/mbbsd/talk.c index af14b57f..4495ce7c 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -603,6 +603,8 @@ my_write2(void) * 6. my_write2 flag = WATERBALL_CONFIRM, 4 (pre-edit but confirm) * 7. (when defined PLAY_ANGEL) * 呼叫小天使 flag = WATERBALL_ANGEL, 5 (隱藏 id) + * 8. (when defined PLAY_ANGEL) + * 回答小主人 flag = WATERBALL_ANSWER, 6 */ int my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin) @@ -709,7 +711,8 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin) kill(uin->pid, SIGUSR1); } else if (flag != WATERBALL_ALOHA && #ifdef PLAY_ANGEL - flag != WATERBALL_ANGEL && flag != WATERBALL_ANSWER && + (flag != WATERBALL_ANGEL || (uin->angel & 1)) && + flag != WATERBALL_ANSWER && /* Angel accept or not is checked outside. * Avoiding new users don't know what pager is. */ #endif @@ -1926,11 +1929,13 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, int call_in(userinfo_t * uentp, int fri_stat) { +#ifdef PLAY_ANGLE static int CallInAngelWarning = 1; if( CallInAngelWarning && ! strcasecmp(uentp->userid, cuser.myangel) ){ outmsg("直接丟水球給小天使是會被知道 ID 的喔!"); CallInAngelWarning = 0; } +#endif if (iswritable_stat(uentp, fri_stat)) { char genbuf[60]; @@ -2803,16 +2808,23 @@ t_changeangel(){ static int FindAngel(void){ - /* TODO: randomized choose an online angel, shouldn't be themself */ int nAngel; int i, j; int choose; int trial = 0; + int mask; + + if (cuser.sex < 6) /* 正常性別 */ + mask = 1 | (2 << (cuser.sex & 1)); + else + mask = 7; + do{ nAngel = 0; j = SHM->currsorted; for (i = 0; i < SHM->UTMPnumber; ++i) - if (SHM->sorted[j][0][i]->userlevel & PERM_ANGEL) + if ((SHM->sorted[j][0][i]->userlevel & PERM_ANGEL) + && (SHM->sorted[j][0][j]->angel & mask) == 0) ++nAngel; if (nAngel == 0) @@ -2821,10 +2833,11 @@ FindAngel(void){ choose = rand() % nAngel + 1; j = SHM->currsorted; for (i = 0; i < SHM->UTMPnumber && choose; ++i) - if (SHM->sorted[j][0][i]->userlevel & PERM_ANGEL) + if ((SHM->sorted[j][0][i]->userlevel & PERM_ANGEL) + && (SHM->sorted[j][0][j]->angel & mask) == 0) --choose; - if (choose == 0 && SHM->sorted[j][0][i - 1] != currutmp){ + if (choose == 0 && SHM->sorted[j][0][i - 1]->uid != currutmp->uid){ strlcpy(cuser.myangel, SHM->sorted[j][0][i - 1]->userid, IDLEN + 1); return 1; } @@ -2864,12 +2877,15 @@ TalkToAngel(){ } uent = search_ulist_userid(cuser.myangel); - if (uent == 0 || !uent->being_angel){ + if (uent == 0 || (uent->angel & 1)){ NoAngelFound("您的小天使現在不在線上"); return; } - /* TODO: complete first name-hiden waterball */ + move(b_lines - 1, 0); + outs("現在你的id受到保密,回答你問題的小天使並不知道你是誰 \n" + "你可以選擇不向對方透露自己身份來保護自己 "); + snprintf(buf, 128, "問小天使 %s: ", cuser.myangel); my_write(uent->pid, buf, cuser.myangel, WATERBALL_ANGEL, uent); return; @@ -2890,15 +2906,22 @@ CallAngel(){ redoscr(); } -void SwitchBeingAngel(){ - cuser.uflag2 ^= BEING_ANGEL; - currutmp->being_angel ^= 1; +void +SwitchBeingAngel(){ + cuser.uflag2 ^= REJ_QUESTION; + currutmp->angel ^= 1; } -int t_switchangel(){ +void +SwitchAngelSex(int newmode){ + ANGEL_SET(newmode); + currutmp->angel = (currutmp->angel & ~0x6) | ((newmode & 3) << 1); +} + +int +t_switchangel(){ SwitchBeingAngel(); - outs(cuser.uflag2 & BEING_ANGEL ? - "開放小主人問問題" : "休息一會兒"); + outs(REJECT_QUESTION ? "休息一會兒" : "開放小主人問問題"); return XEASY; } #endif diff --git a/mbbsd/user.c b/mbbsd/user.c index cbb85d1d..e01f00c6 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -89,8 +89,10 @@ user_display(userec_t * u, int real) get_num_records(genbuf, sizeof(fileheader_t)), u->exmailbox, u->mobile, u->month, u->day, u->year % 100, u->mychicken.name); +#ifdef PLAY_ANGEL prints(" 小 天 使: %s\n", u->myangel[0] ? u->myangel : "無"); +#endif prints(" 註冊日期: %s", ctime(&u->firstlogin)); prints(" 前次光臨: %s", ctime(&u->lastlogin)); prints(" 前次點歌: %s", ctime(&u->lastsong)); @@ -221,6 +223,9 @@ static void Customize(void) char done = 0, mindbuf[5]; char *wm[3] = {"一般", "進階", "未來"}; int key; +#ifdef PLAY_ANGEL + char *am[4] = {"男女皆可", "限女生", "限男生", "暫不接受新的小主人"}; +#endif showtitle("個人化設定", "個人化設定"); memcpy(mindbuf, &currutmp->mind, 4); @@ -240,8 +245,9 @@ static void Customize(void) #ifdef PLAY_ANGEL if( HAS_PERM(PERM_ANGEL) ){ prints("%-30s%10s\n", "F. 接受小主人詢問", - ((cuser.uflag2 & BEING_ANGEL) ? "是" : "否")); - key = getkey("請按 [A-F] 切換設定,按 [Return] 結束:"); + (REJECT_QUESTION ? "否" : "是")); + prints("%-30s%10s\n", "G. 接受的小主人性別", am[ANGEL_STATUS()]); + key = getkey("請按 [A-G] 切換設定,按 [Return] 結束:"); }else #endif key = getkey("請按 [A-E] 切換設定,按 [Return] 結束:"); @@ -281,7 +287,15 @@ static void Customize(void) #ifdef PLAY_ANGEL case 'f': if( HAS_PERM(PERM_ANGEL) ){ - t_switchangel(); + SwitchBeingAngel(); + break; + } + done = 1; + break; + + case 'g': + if( HAS_PERM(PERM_ANGEL) ){ + SwitchAngelSex(ANGEL_STATUS() + 1); break; } #endif @@ -394,6 +408,21 @@ uinfo_query(userec_t * u, int real, int unum) i++; break; } + +#ifdef PLAY_ANGEL + if (real) + while (1) { + getdata_str(i, 0, "小天使:", buf, IDLEN + 1, DOECHO, + x.myangel); + if(buf[0] == 0 || (getuser(buf) && + (xuser.userlevel & PERM_ANGEL))){ + strlcpy(x.myangel, buf, IDLEN + 1); + ++i; + break; + } + } +#endif + if (real) { int l; if (HAS_PERM(PERM_BBSADM)) { diff --git a/mbbsd/var.c b/mbbsd/var.c index b3afba22..c499663b 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -21,7 +21,11 @@ char *str_permid[] = { "BBSADM", /* PERM_POSTMARK */ "不列入排行榜", /* PERM_NOTOP */ "違法通緝中", /* PERM_VIOLATELAW */ +#ifdef PLAY_ANGEL "可擔任小天使", /* PERM_ANGEL */ +#else + "未使用", +#endif "不允許\認證碼註冊", /* PERM_NOREGCODE */ "視覺站長", /* PERM_VIEWSYSOP */ "觀察使用者行蹤", /* PERM_LOGUSER */ |