diff options
Diffstat (limited to 'mbbsd/cal.c')
-rw-r--r-- | mbbsd/cal.c | 63 |
1 files changed, 29 insertions, 34 deletions
diff --git a/mbbsd/cal.c b/mbbsd/cal.c index d2cec676..29cacc98 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -59,21 +59,16 @@ unlockutmpmode() int vice(int money, char *item) { - char buf[128]; - unsigned int viceserial = (currutmp->lastact % 1000000) * 100 + rand() % 100; - FILE *fp; + char buf[128], vice[12]; + unsigned int viceserial = (currutmp->lastact % 1000000) * 100 + rand() % 100; + demoney(-money); - snprintf(buf, sizeof(buf), BBSHOME "/home/%c/%s/%s", - cuser.userid[0], cuser.userid, VICE_NEW); - fp = fopen(buf, "a"); - if (!fp) { - return 0; - } - fprintf(fp, "%08d\n", viceserial); - fclose(fp); + setuserfile(buf, VICE_NEW); + sprintf(vice,"%8.8d\n", viceserial); + log_file(buf, vice, 1); snprintf(buf, sizeof(buf), "%s 花了%d$ 編號[%08d]", item, money, viceserial); - mail_id(cuser.userid, buf, "etc/vice.txt", "Ptt經濟部"); + mail_id(cuser->userid, buf, "etc/vice.txt", "Ptt經濟部"); return 0; } @@ -99,7 +94,7 @@ osong(char *defaultid) lockreturn0(OSONG, LOCK_MULTI); /* Jaky 一人一天點一首 */ - if (!strcmp(buf, Cdatedate(&cuser.lastsong)) && !HAS_PERM(PERM_SYSOP)) { + if (!strcmp(buf, Cdatedate(&cuser->lastsong)) && !HAS_PERM(PERM_SYSOP)) { move(22, 0); outs("你今天已經點過囉,明天再點吧...."); refresh(); @@ -108,7 +103,7 @@ osong(char *defaultid) unlockutmpmode(); return 0; } - if (cuser.money < 200) { + if (cuser->money < 200) { move(22, 0); outs("點歌要200銀唷!...."); refresh(); @@ -118,7 +113,7 @@ osong(char *defaultid) } move(12, 0); clrtobot(); - prints("親愛的 %s 歡迎來到歐桑自動點歌系統\n", cuser.userid); + prints("親愛的 %s 歡迎來到歐桑自動點歌系統\n", cuser->userid); trans_buffer[0] = 0; if (!defaultid) { getdata(13, 0, "要點給誰呢:[可直接按 Enter 先選歌]", @@ -142,7 +137,7 @@ osong(char *defaultid) getdata_str(14, 0, "想要要對他(她)說..:", say, sizeof(say), DOECHO, "我愛妳.."); snprintf(save_title, sizeof(save_title), - "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser.userid, say); + "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser->userid, say); getdata_str(16, 0, "寄到誰的信箱(可用E-mail)?", receiver, sizeof(receiver), LCECHO, destid); @@ -170,7 +165,7 @@ osong(char *defaultid) strlcpy(mail.owner, "點歌機", sizeof(mail.owner)); snprintf(mail.title, sizeof(mail.title), "◇ %s 點給 %s ", - (ano[0] == 'y') ? "匿名者" : cuser.userid, destid); + (ano[0] == 'y') ? "匿名者" : cuser->userid, destid); while (fgets(buf, sizeof(buf), fp)) { char *po; @@ -188,7 +183,7 @@ osong(char *defaultid) po[0] = 0; snprintf(genbuf, sizeof(genbuf), "%s%s%s", buf, - (ano[0] == 'y') ? "匿名者" : cuser.userid, po + 7); + (ano[0] == 'y') ? "匿名者" : cuser->userid, po + 7); strlcpy(buf, genbuf, sizeof(buf)); } while ((po = strstr(buf, "<~Des~>"))) { @@ -208,7 +203,7 @@ osong(char *defaultid) if (append_record(OSONGPATH "/.DIR", &mail, sizeof(mail)) != -1) { - cuser.lastsong = now; + cuser->lastsong = now; /* Jaky 超過 500 首歌就開始砍 */ nsongs = get_num_records(OSONGPATH "/.DIR", sizeof(mail)); if (nsongs > 500) { @@ -218,7 +213,7 @@ osong(char *defaultid) vice(200, "點歌"); } snprintf(save_title, sizeof(save_title), - "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser.userid, say); + "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser->userid, say); hold_mail(filename, destid); if (receiver[0]) { @@ -256,9 +251,9 @@ static int inmailbox(int m) { passwd_query(usernum, &xuser); - cuser.exmailbox = xuser.exmailbox + m; - passwd_update(usernum, &cuser); - return cuser.exmailbox; + cuser->exmailbox = xuser.exmailbox + m; +// passwd_update(usernum, &cuser); + return cuser->exmailbox; } @@ -273,7 +268,7 @@ p_cloak() buf, sizeof(buf), LCECHO); if (buf[0] != 'y') return 0; - if (cuser.money >= 19) { + if (cuser->money >= 19) { vice(19, "cloak"); currutmp->invisible %= 2; outs((currutmp->invisible ^= 1) ? MSG_CLOAKED : MSG_UNCLOAK); @@ -293,7 +288,7 @@ p_from() if (ans[0] != 'y') return 0; reload_money(); - if (cuser.money < 49) + if (cuser->money < 49) return 0; if (getdata_buf(b_lines - 1, 0, "請輸入新故鄉:", currutmp->from, sizeof(currutmp->from), DOECHO)) { @@ -309,13 +304,13 @@ p_exmail() char ans[4], buf[200]; int n; - if (cuser.exmailbox >= MAX_EXKEEPMAIL) { + if (cuser->exmailbox >= MAX_EXKEEPMAIL) { prints("容量最多增加 %d 封,不能再買了。", MAX_EXKEEPMAIL); refresh(); return 0; } snprintf(buf, sizeof(buf), - "您曾增購 %d 封容量,還要再買多少?", cuser.exmailbox); + "您曾增購 %d 封容量,還要再買多少?", cuser->exmailbox); getdata_str(b_lines - 2, 0, buf, ans, sizeof(ans), LCECHO, "10"); @@ -324,10 +319,10 @@ p_exmail() return 0; if (n < 0) n = 100; - if (n + cuser.exmailbox > MAX_EXKEEPMAIL) - n = MAX_EXKEEPMAIL - cuser.exmailbox; + if (n + cuser->exmailbox > MAX_EXKEEPMAIL) + n = MAX_EXKEEPMAIL - cuser->exmailbox; reload_money(); - if (cuser.money < n * 1000) + if (cuser->money < n * 1000) return 0; vice(n * 1000, "mail"); inmailbox(n); @@ -384,23 +379,23 @@ p_give() move(1, 0); usercomplete("這位幸運兒的id:", id); - if (!id[0] || !strcmp(cuser.userid, id) || + if (!id[0] || !strcmp(cuser->userid, id) || !getdata(2, 0, "要給多少錢:", genbuf, 7, LCECHO)) return 0; money = atoi(genbuf); reload_money(); - if (money > 0 && cuser.money >= money) { + if (money > 0 && cuser->money >= money) { tax = give_tax(money); if (money - tax <= 0) return 0; /* 繳完稅就沒錢給了 */ deumoney(searchuser(id), money - tax); demoney(-money); snprintf(genbuf, sizeof(genbuf), "%s\t給%s\t%d\t%s\n", - cuser.userid, id, money - tax, ctime(&now)); + cuser->userid, id, money - tax, ctime(&now)); log_file(FN_MONEY, genbuf, 1); genbuf[0] = 'n'; getdata(3, 0, "要自行書寫紅包袋嗎?[y/N]", genbuf, 2, LCECHO); - mail_redenvelop(cuser.userid, id, money - tax, genbuf[0]); + mail_redenvelop(cuser->userid, id, money - tax, genbuf[0]); } return 0; } |