diff options
Diffstat (limited to 'mbbsd/assess.c')
-rw-r--r-- | mbbsd/assess.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/mbbsd/assess.c b/mbbsd/assess.c index cc5e84b1..02498263 100644 --- a/mbbsd/assess.c +++ b/mbbsd/assess.c @@ -1,36 +1,47 @@ #include "bbs.h" -inline static void inc(unsigned char *num) + +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 < SALE_MAXVALUE) - (*num)++; + if (*num < n) + (*num) -= n; + else + (*num) = 0; } -void inc_goodpost(int uid) +void inc_goodpost(int uid, int num) { passwd_query(uid, &xuser); - inc(&xuser.goodpost); + inc(&xuser.goodpost, num); passwd_update(uid, &xuser); } -void inc_badpost(int uid) +void inc_badpost(int uid, int num) { passwd_query(uid, &xuser); - inc(&xuser.badpost); + inc(&xuser.badpost, num); passwd_update(uid, &xuser); } -void inc_goodsale(int uid) +void inc_goodsale(int uid, int num) { passwd_query(uid, &xuser); - inc(&xuser.goodsale); + inc(&xuser.goodsale, num); passwd_update(uid, &xuser); } -void inc_badsale(int uid) +void inc_badsale(int uid, int num) { passwd_query(uid, &xuser); - inc(&xuser.badsale); + inc(&xuser.badsale, num); passwd_update(uid, &xuser); } |