From b4f666e85c89490e8ffe929120bc50bcb40f87e1 Mon Sep 17 00:00:00 2001 From: in2 Date: Sun, 2 Jun 2002 07:13:34 +0000 Subject: board friend git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@275 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/talk.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 77b8edf5..32988a87 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -1,4 +1,4 @@ -/* $Id: talk.c,v 1.56 2002/06/02 01:55:21 in2 Exp $ */ +/* $Id: talk.c,v 1.57 2002/06/02 07:13:34 in2 Exp $ */ #include #include #include @@ -1555,6 +1555,20 @@ static void pickup_myfriend(pickup_t *friends, int *nGots, qsort(friends, *nGots, sizeof(pickup_t), sort_cmpfriend); } +static void pickup_bfriend(pickup_t *friends, int *nGots) +{ + userinfo_t *ptr; + for( ptr = bcache[currutmp->brc_id - 1].u, *nGots = 0 ; + ptr != NULL && *nGots < MAX_FRIEND ; + ptr = ptr->nextbfriend ){ + if( currutmp != ptr && isvisible(currutmp, ptr) ){ + friends[*nGots].ui = ptr; + friends[(*nGots)++].friend = IBH; + } + } + qsort(friends, *nGots, sizeof(pickup_t), sort_cmpfriend); +} + static void pickup(pickup_t *currpickup, int pickup_way, int *page, int *myfriend, int *friendme) { @@ -1564,6 +1578,7 @@ static void pickup(pickup_t *currpickup, int pickup_way, int *page, int friendtotal= currutmp->friendtotal; userinfo_t **utmp; + static int nFriends, nBoardFriends; int which, got, sorted_way; got = 0; @@ -1572,26 +1587,36 @@ static void pickup(pickup_t *currpickup, int pickup_way, int *page, *myfriend = *friendme = 1; if( cuser.uflag & FRIEND_FLAG || - (pickup_way == 0 && *page * MAXPICKUP < friendtotal) ){ + (pickup_way == 0 && *page * MAXPICKUP < (friendtotal + 1)) ){ /* [¶Ù! ªB¤Í] mode. we need to pickup ALL friends (from currutmp friend_online), sort, and get pickup from right starting position */ pickup_t friends[MAX_FRIEND + 1]; - int nGots; - pickup_myfriend(friends, &nGots, myfriend, friendme); + pickup_myfriend(friends, &nFriends, myfriend, friendme); for( which = *page * MAXPICKUP ; - got < MAXPICKUP && which < nGots ; + got < MAXPICKUP && which < nFriends ; ++got, ++which ) currpickup[got] = friends[which]; } if( !(cuser.uflag & FRIEND_FLAG) ){ + if( pickup_way == 0 ){ + /* now pickup board friends */ + pickup_t friends[MAX_FRIEND + 1]; + pickup_bfriend(friends, &nBoardFriends); + which = *page * MAXPICKUP - nFriends; + for( which = (which >= 0 ? which : 0) ; + got < MAXPICKUP && which < nBoardFriends ; + ++got, ++which ) + currpickup[got] = friends[which]; + } + sorted_way = ((pickup_way == 0) ? 0 : (pickup_way - 1)); utmp = utmpshm->sorted[currsorted][sorted_way]; - which = *page * MAXPICKUP - currutmp->friendtotal; + which = *page * MAXPICKUP - nFriends - nBoardFriends; for( which = (which >= 0 ? which : 0) ; got < MAXPICKUP && which < utmpnumber ; ++got, ++which ){ -- cgit v1.2.3