From b729272d521985d2656660d2f83a3a29c8f6ec8f Mon Sep 17 00:00:00 2001 From: scw Date: Sun, 12 Mar 2006 11:25:53 +0000 Subject: GO scoring and displaying on userlist. !!!NOTE: shared memory changed!!! git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3276 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/shmctl.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'util') diff --git a/util/shmctl.c b/util/shmctl.c index 0699d601..a1dabe31 100644 --- a/util/shmctl.c +++ b/util/shmctl.c @@ -337,6 +337,25 @@ cmputmpchc(const void * i, const void * j) return a->chc_tie - b->chc_tie; } +static int +cmputmpgo(const void * i, const void * j) +{ + userinfo_t *a=&SHM->uinfo[*(int*)i],*b=&SHM->uinfo[*(int*)j]; + int played_a=(a->go_win+a->go_lose+a->go_tie)!=0; + int played_b=(b->go_win+b->go_lose+b->go_tie)!=0; + int type; + + if ((type = played_b - played_a)) + return type; + if (played_a == 0) + return 0; + if ((type = b->go_win - a->go_win)) + return type; + if ((type = a->go_lose - b->go_lose)) + return type; + return a->go_tie - b->go_tie; +} + static int cmputmppid(const void * i, const void * j) { @@ -376,12 +395,12 @@ inline void utmpsort(int sortall) } SHM->UTMPnumber = count; qsort(SHM->sorted[ns][0], count, sizeof(int), cmputmpuserid); - memcpy(SHM->sorted[ns][6], - SHM->sorted[ns][0], sizeof(int) * count); memcpy(SHM->sorted[ns][7], SHM->sorted[ns][0], sizeof(int) * count); - qsort(SHM->sorted[ns][6], count, sizeof(int), cmputmpuid); - qsort(SHM->sorted[ns][7], count, sizeof(int), cmputmppid); + memcpy(SHM->sorted[ns][8], + SHM->sorted[ns][0], sizeof(int) * count); + qsort(SHM->sorted[ns][7], count, sizeof(int), cmputmpuid); + qsort(SHM->sorted[ns][8], count, sizeof(int), cmputmppid); if( sortall ){ memcpy(SHM->sorted[ns][1], SHM->sorted[ns][0], sizeof(int) * count); @@ -393,11 +412,14 @@ inline void utmpsort(int sortall) SHM->sorted[ns][0], sizeof(int) * count); memcpy(SHM->sorted[ns][5], SHM->sorted[ns][0], sizeof(int) * count); + memcpy(SHM->sorted[ns][6], + SHM->sorted[ns][0], sizeof(int) * count); qsort(SHM->sorted[ns][1], count, sizeof(int), cmputmpmode); qsort(SHM->sorted[ns][2], count, sizeof(int), cmputmpidle); qsort(SHM->sorted[ns][3], count, sizeof(int), cmputmpfrom); qsort(SHM->sorted[ns][4], count, sizeof(int), cmputmpfive); qsort(SHM->sorted[ns][5], count, sizeof(int), cmputmpchc); + qsort(SHM->sorted[ns][6], count, sizeof(int), cmputmpgo); memset(nusers, 0, sizeof(nusers)); for (i = 0; i < count; ++i) { uentp = &SHM->uinfo[SHM->sorted[ns][0][i]]; -- cgit v1.2.3