Page 1 of 1

ACCEPTED_CONNECTION (102) / Friends bug

Posted: Sun Aug 09, 2009 9:32 am
by John Adams
Scat, this bug is a problem that everytime a player zones, they are disconnected and reconnected, and we're counting that new connection as a brand new one, thus throwing this stat counter way off.

The same thing happens when I have Scatman on my Friend list, and Scatman zones. I see him logging in over and over everytime he zones.

Maybe both these checks are just in the wrong place?

Re: ACCEPTED_CONNECTION (102) / Friends bug

Posted: Sun Aug 09, 2009 3:43 pm
by Secrets
Think it might be related to putting it in a place (SetReadyForSpawns) instead of a place they first login. (SendLoginInfo)

If you put it under their firstlogin in Client::SendLoginInfo and send a login message, and when they leave the world server have them log out send a logout message to all clients. Probably would work better, instead of having it iterated to all clients per client logging in. (at least, I think that's what is happening!)

I'll try and fix it tonight if no one else gets around to it.

PS: Hi John!

Re: ACCEPTED_CONNECTION (102) / Friends bug

Posted: Sun Aug 09, 2009 4:10 pm
by Secrets
Think I fixed this, i'll post a diff shortly.

Was definately related to iterating through a list of clients. You get a logged in message every time a match is found when it iterates through CheckFriendList(this) in function Client::SetReadyForSpawns. I moved that to when a player logged in, and replaced it to only update your friends list when you zone with an entirely new function. Diff inc shortly.

Re: ACCEPTED_CONNECTION (102) / Friends bug

Posted: Sun Aug 09, 2009 4:24 pm
by John Adams
Right on, thanks Secrets. Post your diff and Scatman or LE will check it out.

Re: ACCEPTED_CONNECTION (102) / Friends bug

Posted: Sun Aug 09, 2009 4:29 pm
by Secrets

Code: Select all

Index: client.cpp
===================================================================
--- client.cpp	(revision 297)
+++ client.cpp	(working copy)
@@ -232,6 +232,7 @@
 	if(firstlogin){
 		ClientPacketFunctions::SendMOTD ( this );
 		ClientPacketFunctions::SendCharacterMacros(this);
+		zone_list.CheckFriendList(this);
 	}
 	database.LoadPlayerFactions(this);
 	database.LoadCharacterQuests(this);
@@ -3736,7 +3737,7 @@
 			world.GroupMessage(GetPlayer()->GetGroup(), "%s has returned from Linkdead.", GetPlayer()->GetName());
 		}
 	}
-	zone_list.CheckFriendList(this);
+	zone_list.CheckFriendZoned(this);
 }
 
 void Client::SendChatRelationship(int8 type, const char* name){
Index: World.cpp
===================================================================
--- World.cpp	(revision 297)
+++ World.cpp	(working copy)
@@ -328,6 +328,19 @@
 	MClientList.unlock();
 }
 
+void ZoneList::CheckFriendZoned(Client* client){
+	MClientList.lock();
+	map<string,Client*>::iterator itr;
+	for(itr = client_map.begin(); itr != client_map.end(); itr++){
+		if(itr->second != client && itr->second){
+			if(itr->second->GetPlayer()->IsFriend(client->GetPlayer()->GetName())){
+				itr->second->SendFriendList();
+			}
+		}
+	}
+	MClientList.unlock();
+}
+
 bool ZoneList::HandleGlobalChatMessage(Client* from, char* to, int16 channel, char* message, char* channel_name){
 	if(channel == CHANNEL_TELL){
 		Client* find_client = zone_list.GetClientByCharName(to);
Index: World.h
===================================================================
--- World.h	(revision 297)
+++ World.h	(working copy)
@@ -236,6 +236,7 @@
 		MClientList.unlock();
 	}
 	void CheckFriendList(Client* client);
+	void CheckFriendZoned(Client* client);
 	bool HandleGlobalChatMessage(Client* from, char* to, int16 channel, char* message, char* channel_name = 0);
 	void HandleGlobalBroadcast(const char* message);
 	void HandleGlobalAnnouncement(const char* message);

Re: ACCEPTED_CONNECTION (102) / Friends bug

Posted: Mon Aug 10, 2009 12:15 am
by Scatman
That's the exact same code I had. Go ahead and commit it, and I'll merge it with some other changes.

Re: ACCEPTED_CONNECTION (102) / Friends bug

Posted: Mon Aug 10, 2009 8:13 am
by John Adams
I don't think Secrets has commit ability (only a few do). That's why the diff, ya silly hobbit. :D

Re: ACCEPTED_CONNECTION (102) / Friends bug

Posted: Sun Aug 16, 2009 10:35 am
by John Adams
Ok since Scatman has the memory span of the average housefly (J/K!!!), I went ahead and added, tested, and committed this code from Secrets. :)