summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/assess.c46
1 files changed, 14 insertions, 32 deletions
diff --git a/mbbsd/assess.c b/mbbsd/assess.c
index 95426e26..a9bbe10f 100644
--- a/mbbsd/assess.c
+++ b/mbbsd/assess.c
@@ -13,41 +13,23 @@ inline static void inc(unsigned char *num, int n)
(*num) += n;
}
-int inc_goodpost(int uid, int num)
-{
- passwd_query(uid, &xuser);
- inc(&xuser.goodpost, num);
- SHM->uinfo[uid - 1].goodpost = xuser.goodpost;
- passwd_update(uid, &xuser);
- return xuser.goodpost;
-}
-
-int inc_badpost(int uid, int num)
-{
- passwd_query(uid, &xuser);
- inc(&xuser.badpost, num);
- SHM->uinfo[uid - 1].badpost = xuser.badpost;
- passwd_update(uid, &xuser);
- return xuser.badpost;
+#define modify_column(name) \
+int inc_##name(int uid, int num) \
+{ \
+ passwd_query(uid, &xuser); \
+ inc(&xuser.name, num); \
+ userinfo_t *user = search_ulist(uid); \
+ if (user != NULL) \
+ user->name = xuser.name; \
+ passwd_update(uid, &xuser); \
+ return xuser.name; \
}
-int inc_goodsale(int uid, int num)
-{
- passwd_query(uid, &xuser);
- inc(&xuser.goodsale, num);
- SHM->uinfo[uid - 1].goodsale = xuser.goodsale;
- passwd_update(uid, &xuser);
- return xuser.goodsale;
-}
+modify_column(goodpost);
+modify_column(badpost);
+modify_column(goodsale);
+modify_column(badsale);
-int inc_badsale(int uid, int num)
-{
- passwd_query(uid, &xuser);
- inc(&xuser.badsale, num);
- SHM->uinfo[uid - 1].badsale = xuser.badsale;
- passwd_update(uid, &xuser);
- return xuser.badsale;
-}
void set_assess(int uid, unsigned char num, int type)
{