summaryrefslogtreecommitdiffstats
path: root/cacheserver/friend.cpp
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-03-29 01:32:33 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-03-29 01:32:33 +0800
commit99cefa7694fc89c2830341b2f4d41c0e9ee571a1 (patch)
tree3aab2bcc7fdf4a4258431d6c1ff061617d99120c /cacheserver/friend.cpp
parent4efbbdd8076dcadf0df8ff46a89434d79a3314be (diff)
downloadpttbbs-99cefa7694fc89c2830341b2f4d41c0e9ee571a1.tar
pttbbs-99cefa7694fc89c2830341b2f4d41c0e9ee571a1.tar.gz
pttbbs-99cefa7694fc89c2830341b2f4d41c0e9ee571a1.tar.bz2
pttbbs-99cefa7694fc89c2830341b2f4d41c0e9ee571a1.tar.lz
pttbbs-99cefa7694fc89c2830341b2f4d41c0e9ee571a1.tar.xz
pttbbs-99cefa7694fc89c2830341b2f4d41c0e9ee571a1.tar.zst
pttbbs-99cefa7694fc89c2830341b2f4d41c0e9ee571a1.zip
bug fix, clear friend data only when all account logout.
allow like/hate oneself. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3311 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'cacheserver/friend.cpp')
-rw-r--r--cacheserver/friend.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/cacheserver/friend.cpp b/cacheserver/friend.cpp
index a3110ea7..e62a7198 100644
--- a/cacheserver/friend.cpp
+++ b/cacheserver/friend.cpp
@@ -131,7 +131,6 @@ template<class R,class B>
struct RelationList: public myvector<Relation, 8, short> {
RelationList() :myvector<Relation, 8, short>() {}
void add(Uid me, Uid him) {
- assert(me!=him);
RelationList<B,R>& bl=R::backlist(him);
short me_offset=append(Relation(him));
short him_offset=bl.append(Relation(me,me_offset));
@@ -201,7 +200,7 @@ struct Utmp {
public:
Uid utmp[USHM_SIZE];
};
-Utmp utmp;
+static Utmp utmp;
struct BBSUser {
Uid me;
@@ -228,11 +227,9 @@ struct BBSUser {
online++;
assert(online==utmplist.n);
for(int i=0; i<MAX_FRIEND && likehim[i]; i++)
- if(likehim[i]!=me)
- like.add(me, likehim[i]);
+ like.add(me, likehim[i]);
for(int i=0; i<MAX_REJECT && hatehim[i]; i++)
- if(hatehim[i]!=me)
- hate.add(me, hatehim[i]);
+ hate.add(me, hatehim[i]);
}
void logout(int utmpidx) {
@@ -247,8 +244,10 @@ struct BBSUser {
utmp.utmp[utmpidx]=-1;
online--;
assert(online==utmplist.n);
- like.deleteall(me);
- hate.deleteall(me);
+ if(online==0) {
+ like.deleteall(me);
+ hate.deleteall(me);
+ }
}
bool isfree() const {
return online==0 && like.n==0 && hate.n==0 && likeby.n==0 && hateby.n==0;
@@ -331,6 +330,7 @@ extern "C" int genfriendlist(int uid, int index, ocfs_t *fs, int maxfs)
BBSUser& h=userlist.users[work.base[i].who];
for(int j=0; j<h.utmplist.n && nfs<maxfs; j++) {
int rstat=reverse_friend_stat(work.base[i].bits);
+ if(h.utmplist.base[j]==index) continue;
fs[nfs].index=h.utmplist.base[j];
fs[nfs].uid=h.me;
fs[nfs].friendstat=(work.base[i].bits<<24)|h.utmplist.base[j];