summaryrefslogblamecommitdiffstats
path: root/mbbsd/assess.c
blob: 957d3042b9d95a3a47db562e7ed35b6d8f8e613e (plain) (tree)
1
2
3
4
5
6
7
8

                
             
 
                                  

                                                 
                                            




                                

 
                                  

                              
                              
                               
                          

 
                                 

                              
                             
                               
                         

 
                                  

                              
                              
                               
                          

 
                                 

                              
                             
                               
                         




















                                                     
      
#include "bbs.h"

#ifdef ASSESS

/* do (*num) + n, n is integer. */
inline static void inc(unsigned char *num, int n)
{
    if (n >= 0 && SALE_MAXVALUE - *num <= n)
    (*num) = SALE_MAXVALUE;
    else if (n < 0 && *num < -n)
    (*num) = 0;
    else
    (*num) += n;
}

int inc_goodpost(int uid, int num)
{
    passwd_query(uid, &xuser);
    inc(&xuser.goodpost, num);
    passwd_update(uid, &xuser);
    return xuser.goodpost;
}

int inc_badpost(int uid, int num)
{
    passwd_query(uid, &xuser);
    inc(&xuser.badpost, num);
    passwd_update(uid, &xuser);
    return xuser.badpost;
}

int inc_goodsale(int uid, int num)
{
    passwd_query(uid, &xuser);
    inc(&xuser.goodsale, num);
    passwd_update(uid, &xuser);
    return xuser.goodsale;
}

int inc_badsale(int uid, int num)
{
    passwd_query(uid, &xuser);
    inc(&xuser.badsale, num);
    passwd_update(uid, &xuser);
    return xuser.badsale;
}

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);
}
#endif