summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-10-27 09:35:04 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-10-27 09:35:04 +0800
commit2c29e7366096ec12e27bc0f844391ae0507af6be (patch)
tree96fa73131f0ffd56ac593b012d0643578f39f959
parent988347c73adf128cc97571569aee18bbc4008377 (diff)
downloadpttbbs-2c29e7366096ec12e27bc0f844391ae0507af6be.tar
pttbbs-2c29e7366096ec12e27bc0f844391ae0507af6be.tar.gz
pttbbs-2c29e7366096ec12e27bc0f844391ae0507af6be.tar.bz2
pttbbs-2c29e7366096ec12e27bc0f844391ae0507af6be.tar.lz
pttbbs-2c29e7366096ec12e27bc0f844391ae0507af6be.tar.xz
pttbbs-2c29e7366096ec12e27bc0f844391ae0507af6be.tar.zst
pttbbs-2c29e7366096ec12e27bc0f844391ae0507af6be.zip
complete assess
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@1264 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/mbbsd/assess.c25
-rw-r--r--pttbbs/mbbsd/bbs.c10
-rw-r--r--pttbbs/mbbsd/talk.c11
-rw-r--r--pttbbs/util/cleanpasswd.c36
4 files changed, 54 insertions, 28 deletions
diff --git a/pttbbs/mbbsd/assess.c b/pttbbs/mbbsd/assess.c
index 02498263..059fc078 100644
--- a/pttbbs/mbbsd/assess.c
+++ b/pttbbs/mbbsd/assess.c
@@ -1,20 +1,21 @@
#include "bbs.h"
+/* do (*num) + n, n is integer. */
inline static void inc(unsigned char *num, int n)
{
- if (SALE_MAXVALUE - *num >= n)
- (*num) += n;
- else
- (*num) = SALE_MAXVALUE;
-}
-
-inline static void dec(unsigned char *num, int n)
-{
- if (*num < n)
- (*num) -= n;
- else
- (*num) = 0;
+ if (n > 0){
+ if (SALE_MAXVALUE - *num < n)
+ (*num) = SALE_MAXVALUE;
+ else
+ (*num) += n;
+ }
+ else {
+ if (*num < n)
+ (*num) = 0;
+ else
+ (*num) -= n;
+ }
}
void inc_goodpost(int uid, int num)
diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c
index eb4c627d..478c7a37 100644
--- a/pttbbs/mbbsd/bbs.c
+++ b/pttbbs/mbbsd/bbs.c
@@ -1602,10 +1602,12 @@ mark_post(int ent, fileheader_t * fhdr, char *direct)
fhdr->filemode ^= FILE_MARKED;
- if (fhdr->filemode)
- inc_goodpost(searchuser(fhdr->owner), fhdr->recommend);
- else
- inc_badpost(searchuser(fhdr->owner), fhdr->recommend);
+ if (!(fhdr->filemode & FILE_BID)){
+ if (fhdr->filemode & FILE_MARKED)
+ inc_goodpost(searchuser(fhdr->owner), fhdr->recommend / 10);
+ else
+ inc_goodpost(searchuser(fhdr->owner), -1 * (fhdr->recommend / 10));
+ }
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
substitute_check(fhdr);
diff --git a/pttbbs/mbbsd/talk.c b/pttbbs/mbbsd/talk.c
index b1a3d712..07c94c45 100644
--- a/pttbbs/mbbsd/talk.c
+++ b/pttbbs/mbbsd/talk.c
@@ -358,11 +358,12 @@ my_query(char *uident)
26 - strlen(muser.userid) - strlen(muser.username), "",
money[i]);
if ((uentp && ((fri_stat & HFM) || strcmp(muser.userid,cuser.userid) == 0) && !uentp->invisible))
- prints(" (%d)", muser.money);
+ prints(" ($%d)", muser.money);
prints("\n");
+
prints("《上站次數》%d次", muser.numlogins);
move(2, 40);
- prints("《文章篇數》%d篇\n", muser.numposts);
+ prints("《文章篇數》%d篇 (佳作%d/劣文%d)\n", muser.numposts, muser.goodpost, muser.badpost);
prints("\033[1;33m《目前動態》%-28.28s\033[m",
(uentp && isvisible_stat(currutmp, uentp, fri_stat)) ?
@@ -374,15 +375,15 @@ my_query(char *uident)
prints("《上次上站》%-28.28s《上次故鄉》%s\n",
Cdate(&muser.lastlogin),
(muser.lasthost[0] ? muser.lasthost : "(不詳)"));
- prints("《文章評比》 優 %-3d 劣 %-3d 《競標評比》 優 %-3d 劣 %-3d\n",
- muser.goodpost, muser.badpost,
- muser.goodsale, muser.badsale);
prints("《五子棋戰績》%3d 勝 %3d 敗 %3d 和 "
"《象棋戰績》%3d 勝 %3d 敗 %3d 和\n",
muser.five_win, muser.five_lose, muser.five_tie,
muser.chc_win, muser.chc_lose, muser.chc_tie);
+ prints("《競標評比》 優 %d / 劣 %d", muser.goodsale, muser.badsale);
+ move(6, 40);
if ((uentp && ((fri_stat & HFM) || strcmp(muser.userid,cuser.userid) == 0) && !uentp->invisible))
prints("《 性 別 》%-28.28s\n", sex[muser.sex % 8]);
+
showplans(uident);
pressanykey();
return FULLUPDATE;
diff --git a/pttbbs/util/cleanpasswd.c b/pttbbs/util/cleanpasswd.c
index 3632ad5e..c5f8a251 100644
--- a/pttbbs/util/cleanpasswd.c
+++ b/pttbbs/util/cleanpasswd.c
@@ -2,8 +2,6 @@
#define _UTIL_C_
#include "bbs.h"
-extern userec_t xuser;
-
/* 當資料欄位有異動 例如用了舊的欄位 可用這個程式清除舊值 */
int clean_unused_var(userec_t *rec)
{
@@ -17,10 +15,34 @@ int clean_unused_var(userec_t *rec)
int main(int argc, char *argv[])
{
- attach_SHM();
- if(passwd_init())
- exit(1);
- if (passwd_apply(clean_unused_var) == 0)
- printf("ERROR\n");
+ int i, fd, fdw;
+ userec_t user;
+
+ if ((fd = open(BBSHOME"/.PASSWDS", O_RDONLY)) < 0){
+ perror("open .PASSWDS error");
+ exit(-1);
+ }
+
+ if ((fdw = open(BBSHOME"/.PASSWDS.new", O_WRONLY | O_TRUNC | O_CREAT, 0600)) < 0){
+ perror("open .PASSWDS.new error");
+ exit(-1);
+ }
+
+ for(i = 0; i < MAX_USERS; i++){
+ if (read(fd, &user, sizeof(user)) != sizeof(user))
+ break;
+ clean_unused_var(&user);
+ write(fdw, &user, sizeof(user));
+ }
+ close(fd);
+ close(fdw);
+
+ if (i != MAX_USERS)
+ fprintf(stderr, "ERROR\n");
+ else{
+ fprintf(stderr, "DONE\n");
+ system("/bin/mv " BBSHOME "/.PASSWDS " BBSHOME "/.PASSWDS.bak");
+ system("/bin/mv " BBSHOME "/.PASSWDS.new " BBSHOME "/.PASSWDS");
+ }
return 0;
}