diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-10-28 00:24:30 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-10-28 00:24:30 +0800 |
commit | 2978116a7e4508f412eb49020ed2344dccbca52e (patch) | |
tree | 2dddde33bb374115adb8d1cf3c98bfebcb3243d3 /util/shmctl.c | |
parent | 773f263060586631b3c184cfbbe5cfd2c9467f4c (diff) | |
download | pttbbs-2978116a7e4508f412eb49020ed2344dccbca52e.tar pttbbs-2978116a7e4508f412eb49020ed2344dccbca52e.tar.gz pttbbs-2978116a7e4508f412eb49020ed2344dccbca52e.tar.bz2 pttbbs-2978116a7e4508f412eb49020ed2344dccbca52e.tar.lz pttbbs-2978116a7e4508f412eb49020ed2344dccbca52e.tar.xz pttbbs-2978116a7e4508f412eb49020ed2344dccbca52e.tar.zst pttbbs-2978116a7e4508f412eb49020ed2344dccbca52e.zip |
chess listing sorted by rating(conditional) and player attitute
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2283 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/shmctl.c')
-rw-r--r-- | util/shmctl.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/util/shmctl.c b/util/shmctl.c index 198d6e8f..493e7c35 100644 --- a/util/shmctl.c +++ b/util/shmctl.c @@ -270,14 +270,31 @@ static int cmputmpchc(const void *i, const void *j) { userinfo_t *a=(*((userinfo_t **) i)),*b=(*((userinfo_t **) j)); - int played_a=(a->chc_win+a->chc_lose+a->chc_lose)!=0; - int played_b=(b->chc_win+b->chc_lose+b->chc_lose)!=0; + int total_a=a->chc_win+a->chc_lose+a->chc_lose; + int total_b=b->chc_win+b->chc_lose+b->chc_lose; + int played_a=(total_a!=0); + int played_b=(total_b!=0); int type; + // NOTE: 目前 "別找我下棋" 不影響排序 + /* 1. "找我下棋" 排最前面 */ + if ((a->withme&WITHME_CHESS)!=(b->withme&WITHME_CHESS)) + return (a->withme&WITHME_CHESS)?-1:1; +#ifdef CHC_SORTBY_RATING + /* 2. 下超過十盤棋用等級分排序 */ + if ((total_a>=10)!=(total_b>=10)) + return (total_a>=10)?-1:1; + if (total_a>=10 && total_b>=10) { + if (a->chess_elo_rating!=b->chess_elo_rating) + return b->chess_elo_rating-a->chess_elo_rating; + } +#endif + /* 3. 有下過棋的在沒下過的前面 */ if ((type = played_b - played_a)) return type; if (played_a == 0) return 0; + /* 4. 剩下(下不超過十盤或等級分相同, 或不用等級分排序)的人以勝負和排 */ if ((type = b->chc_win - a->chc_win)) return type; if ((type = a->chc_lose - b->chc_lose)) |