From 3ae89828a2fab3c69c331a9c24e2a18fe63a00a5 Mon Sep 17 00:00:00 2001 From: piaip Date: Sat, 21 Nov 2009 12:50:56 +0000 Subject: * remove set_mind restrictions git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5029 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs/include/proto.h | 1 + pttbbs/mbbsd/talk.c | 13 ++----------- pttbbs/mbbsd/user.c | 28 +++++++++++++++++----------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h index d0777dda..b8d38728 100644 --- a/pttbbs/include/proto.h +++ b/pttbbs/include/proto.h @@ -638,6 +638,7 @@ int topsong(void); /* user */ int kill_user(int num, const char *userid); int u_editcalendar(void); +int u_set_mind(); void user_display(const userec_t *u, int real); int isvalidemail(char *email); void uinfo_query(const char *uid, int real, int unum); diff --git a/pttbbs/mbbsd/talk.c b/pttbbs/mbbsd/talk.c index a459f107..bf64f983 100644 --- a/pttbbs/mbbsd/talk.c +++ b/pttbbs/mbbsd/talk.c @@ -2526,17 +2526,8 @@ userlist(void) break; case 'i': - if (HasUserPerm(PERM_BASIC|PERM_LOGINOK)) { - char mindbuf[5]; - getdata(b_lines - 1, 0, "現在的心情? ", - mindbuf, sizeof(mindbuf), DOECHO); - if (strcmp(mindbuf, "通緝") == 0) - vmsg("不可以把自己設通緝啦!"); - else if (strcmp(mindbuf, "壽星") == 0) - vmsg("你不是今天生日欸!"); - else - memcpy(currutmp->mind, mindbuf, 4); - } + if (HasUserPerm(PERM_BASIC|PERM_LOGINOK)) + u_set_mind(); redrawall = redraw = 1; break; diff --git a/pttbbs/mbbsd/user.c b/pttbbs/mbbsd/user.c index fae69e0a..f6daefdd 100644 --- a/pttbbs/mbbsd/user.c +++ b/pttbbs/mbbsd/user.c @@ -38,6 +38,22 @@ kill_user(int num, const char *userid) passwd_sync_update(num, &u); return 0; } + +int +u_set_mind() +{ + char mindbuf[sizeof(currutmp->mind)+1] = ""; + + // XXX 以往有 check 通緝/壽星,但我實在看不出這有什麼意義 + memcpy(mindbuf, currutmp->mind, sizeof(mindbuf)); + getdata_buf(b_lines - 1, 0, "現在的心情? ", mindbuf, sizeof(mindbuf), DOECHO); + if (memcmp(mindbuf, currutmp->mind, sizeof(currutmp->mind)) == 0) + return 0; + + memcpy(currutmp->mind, mindbuf, sizeof(currutmp->mind)); + return 1; +} + int u_loginview(void) { @@ -527,18 +543,8 @@ void Customize(void) } continue; case 1: - { - char mindbuf[6] = ""; - getdata(b_lines - 1, 0, "現在的心情? ", - mindbuf, 5, DOECHO); - if (strcmp(mindbuf, "通緝") == 0) - vmsg("不可以把自己設通緝啦!"); - else if (strcmp(mindbuf, "壽星") == 0) - vmsg("你不是今天生日欸!"); - else - memcpy(currutmp->mind, mindbuf, 4); + if (HasUserPerm(PERM_BASIC|PERM_LOGINOK) && u_set_mind()) dirty = 1; - } continue; } #ifdef PLAY_ANGEL -- cgit v1.2.3