#include "bbs.h"
/* do (*num) + n, n is integer. */
inline static void inc(unsigned char *num, int n)
{
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)
{
passwd_query(uid, &xuser);
inc(&xuser.goodpost, num);
passwd_update(uid, &xuser);
}
void inc_badpost(int uid, int num)
{
passwd_query(uid, &xuser);
inc(&xuser.badpost, num);
passwd_update(uid, &xuser);
}
void inc_goodsale(int uid, int num)
{
passwd_query(uid, &xuser);
inc(&xuser.goodsale, num);
passwd_update(uid, &xuser);
}
void inc_badsale(int uid, int num)
{
passwd_query(uid, &xuser);
inc(&xuser.badsale, num);
passwd_update(uid, &xuser);
}
void set_assess(int uid, unsigned char num, int type)
{
passwd_query(uid, &xuser);
switch (type){
case GOODPOST:
xuser.goodpost = num;
break;
case BADPOST:
xuser.badpost = num;
break;
case GOODSALE:
xuser.goodsale = num;
break;
case BADSALE:
xuser.badsale = num;
break;
}
passwd_update(uid, &xuser);
}