[Dev Rev II] Bug FriendList not cleaned

Put your bugs you find in osRose here

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

[Dev Rev II] Bug FriendList not cleaned

Postby WiseGuy on Tue Jan 03, 2012 6:23 pm

This bug occurs when you return to character select.
previous friendlist container (whatever that called ) not emptied first before new character you select.

FIND:
  1. bool CCharServer::pakRequestWorld( CCharClient* thisclient, CPacket* P )
  2.  

AFTER:
  1.     result = DB->QStore("SELECT idfriend,namefriend FROM list_friend WHERE id=%i", thisclient->charid);
  2.     if(result==NULL) return false;
  3.  

ADD:
  1.     thisclient->FriendList.clear();
  2.  
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta

Re: [Dev Rev II] Bug FriendList not cleaned

Postby rl2171 on Tue Jan 03, 2012 10:00 pm

Thanks will update SVN soon
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Re: [Dev Rev II] Bug FriendList not cleaned

Postby WiseGuy on Wed Jan 04, 2012 2:38 am

no problem.

The same problem occurs also in the delete friend:

with this fix, you can remove friend in your friend friendlist window immediately. :D

FIND:
  1.        case 0x05://delete user.
  2.  

REPLACE:
  1.        case 0x05://delete user.
  2.         {
  3.             //WORD id = GETWORD ((*P),1);
  4.             DWORD id = GETDWORD ((*P),1);
  5.             if(!DB->QExecute("DELETE FROM list_friend WHERE id=%i and idfriend=%i",thisclient->charid,id))
  6.             {
  7.                 Log(MSG_INFO,"user failed to delete friend slot %i",thisclient->charname,id);
  8.                 return false;
  9.             }
  10.  
  11.             Log(MSG_INFO,"user %s deletes friend slot %i",thisclient->charname,id);
  12.  
  13.             CCharClient* otherclient = (CCharClient*) GetClientByID(id);
  14.             if(otherclient!=NULL)
  15.             {
  16.                     ChangeMessengerStatus ( thisclient, otherclient, 0x08);
  17.             }
  18.         }
  19.         break;
  20.  

BY:
  1.        case 0x05://delete user.
  2.         {
  3.             //WORD id = GETWORD ((*P),1);
  4.             DWORD id = GETDWORD ((*P),1);
  5.             if(!DB->QExecute("DELETE FROM list_friend WHERE (id=%i and idfriend=%i) OR (id=%i and idfriend=%i)",thisclient->charid,id, id,thisclient->charid))
  6.             {
  7.                 Log(MSG_INFO,"user %s failed to delete friend slot %i",thisclient->charname,id);
  8.                 return false;
  9.             }
  10.  
  11.             //Log(MSG_INFO,"user %s deletes friend slot %i",thisclient->charname,id);
  12.  
  13.             //WG: delete friend from my friendlist
  14.             for(UINT i=0;i<thisclient->FriendList.size();i++)
  15.             {
  16.                 CFriendList* thisfriend = thisclient->FriendList.at(i);
  17.                 if(thisfriend->id==id){
  18.                     thisclient->FriendList.erase(thisclient->FriendList.begin()+i);
  19.                     break;
  20.                 }   
  21.             }
  22.             //Log(MSG_INFO, "%s's  friends: %u", thisclient->charname, thisclient->FriendList.size());
  23.             //WG: delete friend from my friendlist
  24.  
  25.             CCharClient* otherclient = (CCharClient*) GetClientByID(id);
  26.             if(otherclient!=NULL)
  27.             {
  28.                     //ChangeMessengerStatus ( thisclient, otherclient, 0x08);
  29.                 //WG: delete me from my friendlist
  30.                 for(UINT i=0;i<otherclient->FriendList.size();i++)
  31.                 {
  32.                     CFriendList* thisfriend = otherclient->FriendList.at(i);
  33.                     if(thisfriend->id==thisclient->charid){
  34.                         otherclient->FriendList.erase(otherclient->FriendList.begin()+i);
  35.                         break;
  36.                     }   
  37.                 }
  38.                 //WG: update friend window
  39.                 BYTE nfriends = otherclient->FriendList.size();
  40.                 BEGINPACKET( pak, 0x7e1 );
  41.                 ADDBYTE    ( pak, 0x06 );
  42.                 ADDBYTE    ( pak, nfriends );
  43.                 if(nfriends>0){
  44.                     for(UINT i=0;i<nfriends;i++)
  45.                     {
  46.                         CFriendList* thisfriend = otherclient->FriendList.at(i);
  47.                         ADDDWORD     (pak, thisfriend->id);
  48.                         CCharClient* friendclient = (CCharClient*) GetClientByID( thisfriend->id );
  49.                         if(friendclient!=NULL){
  50.                             ADDBYTE    (pak, 0x07 );
  51.                         }else{
  52.                             ADDBYTE    (pak, 0x08 );
  53.                         }
  54.                         ADDSTRING  (pak, thisfriend->name);
  55.                         ADDBYTE    (pak, 0x00 );
  56.                     }   
  57.                 }
  58.                 otherclient->SendPacket(&pak);
  59.                 //Log(MSG_INFO, "%s's have friends: %u", otherclient->charname, otherclient->FriendList.size());
  60.                 //WG: delete me from my friendlist
  61.             }
  62.         }
  63.         break;
  64.  



the line:
ChangeMessengerStatus ( thisclient, otherclient, 0x08);
unnecessary, if you commenting, the log out message will not appear, so you can silent delete your friend :lol:
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta

Re: [Dev Rev II] Bug FriendList not cleaned

Postby hoegarden31 on Wed Jan 04, 2012 4:00 am

I changed the database too. I've put the id and friendid both primary key. Not that it change much.
I'm the one and only. In heaven and on earth.
Image
hoegarden31
Rackie
Rackie
 
Posts: 150
Joined: Sun Nov 13, 2011 7:13 pm

Re: [Dev Rev II] Bug FriendList not cleaned

Postby WiseGuy on Wed Jan 04, 2012 4:33 am

hoegarden31 wrote:Only one thing that now happens, is when a player deletes you as friend, he become instantly offline. But he's still in the list.


So, here is the solution, you disappear from his/her friendlist, no need to relog :D

Without deleted the friendlist container, the container wil be bigger everytime you return to char select.
See this situation: in your account id, you have 2 char, one with 5 frineds, and the other with 31 friends.
1. you login and choose char with 5 friends
2. return to character select
3. select char with bigger friends
from here your friendlist container will be 36
4. return to char select then choose ur char with 5 friends
if u limit friend inviation to 30, here is your problem, your char with 5 friends cannot invite anymore :lol:

Sorry for my bad English, but I hope u understand what I meant :lol:
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest