Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 04-16-2009, 02:48 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Sounds like he was having issues with the session timeout limit from the character select screen and also maybe issues with logging in 2 characters on the same account (not sure I read that correctly).

Basically, if you wait at the character select for more than about 1 minute, you will get disconnected as soon as you try to enter world. This 1 minute also includes character creation, so you have to be quick about creating a new character.

I don't know why this limit is set so tightly, because it is pretty annoying. I don't even think it actually disconnects you from the server until you try to do something and get the disconnect message, so there isn't really a reason for it to time out like that. It isn't helping the server in any way at all as far as I can tell.

As for the account session limiting, I fully agree that it needs work. I think it is useful to stop certain hacks and other issues, but I don't even run it on my server because of some of the problems it causes with connections. Since I made it, I have been saying that it needs to be changed to kick the character in game and always let you log in, instead of blocking the new connection while it waits for the one that is logged in to time out. I just don't personally know how to make it do that atm. I basically just used TheLieka's code for IP Limiting and set it to do the same thing for accounts. It does what it is meant to do, but you are right that it needs to be looked at. I just don't personally know how to make it do what it needs to be doing.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #2  
Old 04-16-2009, 03:12 PM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

Try this:

Code:
Index: world/clientlist.cpp
===================================================================
--- world/clientlist.cpp        (revision 432)
+++ world/clientlist.cpp        (working copy)
@@ -100,17 +100,32 @@
 //Account Limiting Code to limit the number of characters allowed on from a single account at once.
 void ClientList::GetCLEAccount(int32 iAccID) {
        ClientListEntry* count_Chars_On = 0;
-       LinkedListIterator<ClientListEntry*> iterator(clientlist);
+       LinkedListIterator<ClientListEntry*> iterator(clientlist, BACKWARD);

        int Chars_On = 0;
        iterator.Reset();
        while(iterator.MoreElements()) {
                count_Chars_On = iterator.GetData();
-               if ((count_Chars_On->AccountID() == iAccID) && ((count_Chars_On->Admin() <= (RuleI(World, ExemptAccountLimitStatus))) || (RuleI(World, ExemptAccountLimitStatus) < 0))) {
+               if ((count_Chars_On->LSAccountID() == iAccID) && ((count_Chars_On->Admin() <= (RuleI(World, ExemptAccountLimitStatus))) || (RuleI(World, ExemptAccountLimitStatus) < 0))) {
                        Chars_On++;
-                       if (Chars_On > (RuleI(World, AccountSessionLimit))){
+                       _log(NET__ERROR, "LSAccount: %i has %i connections.", iAccID, Chars_On);
+                       if (Chars_On >= (RuleI(World, AccountSessionLimit))){
+                               // If we have a char name, they are in a zone, so send a kick to the zone server
+                               if(strlen(count_Chars_On->name())) {
+                                       _log(NET__ERROR, "Sending kick to %s", count_Chars_On->name());
+
+                                       ServerPacket* pack = new ServerPacket(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct));
+                                       ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*) pack->pBuffer;
+                                       strcpy(skp->adminname, "SessionLimit");
+                                       strcpy(skp->name, count_Chars_On->name());
+                                       skp->adminrank = 255;
+                                       zoneserver_list.SendPacket(pack);
+                                       safe_delete(pack);
+                               }
+                               _log(NET__ERROR, "Putting CLE offline");
                                count_Chars_On->SetOnline(CLE_Status_Offline);
                                iterator.RemoveCurrent();
+                               continue;
                        }
                }
                iterator.Advance();
Index: world/LoginServer.cpp
===================================================================
--- world/LoginServer.cpp       (revision 432)
+++ world/LoginServer.cpp       (working copy)
@@ -151,6 +151,11 @@
                }
                case ServerOP_LSClientAuth: {
                        ServerLSClientAuth* slsca = (ServerLSClientAuth*) pack->pBuffer;
+
+                       if (RuleI(World, AccountSessionLimit) >= 0) {
+                               client_list.GetCLEAccount(slsca->lsaccount_id);  //Check current CLE Accounts against incoming connection
+                       }
+
                        client_list.CLEAdd(slsca->lsaccount_id, slsca->name, slsca->key, slsca->worldadmin, slsca->ip, slsca->local);
                        break;
                }
Index: world/client.cpp
===================================================================
--- world/client.cpp    (revision 432)
+++ world/client.cpp    (working copy)
@@ -490,10 +490,6 @@
                                break;
                        }

-                       if (RuleI(World, AccountSessionLimit) >= 0) {
-                               client_list.GetCLEAccount(this->GetAccountID());  //Check current CLE Accounts against incoming connection
-                       }
-
                        if (RuleI(World, MaxClientsPerIP) >= 0) {
                    client_list.GetCLEIP(this->GetIP());  //Lieka Edit Begin:  Check current CLE Entry IPs against incoming connection
             }
In my limited testing on my private server, this seems to have the desired effect of kicking the existing connection and letting the new one in.

I moved the check, so it will kick the existing connection before the new one even gets to Character Select.

Edit: Code updated to remove memory leak.

Last edited by Derision; 04-17-2009 at 12:22 AM.. Reason: Code updated to remove memory leak.
Reply With Quote
  #3  
Old 04-16-2009, 07:01 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I will try to get that running on SH tonight for testing. If players aren't reporting any issues with it, I will let you know, so you can commit it if you like. I am sure that any server using account session limiting would much prefer to use that way over the existing one! Thanks again, Derision!
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 04-17-2009, 06:58 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I got Derision's code running on SH right now and it seems to work fine so far. I will leave it running and see if I get any reports of issues with it. I bet that PEQ and other servers using the old Session Limiting would love the new code for handling it. I didn't even run the old code because of the issues with it, but with this new code, I will definitely keep it enabled

Also, I moved this thread to Code Submissions, since it contains a nice bit of code
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 04-17-2009 at 03:02 PM..
Reply With Quote
  #5  
Old 04-17-2009, 09:52 AM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Quote:
Originally Posted by trevius View Post
I got Derision's code running on SH right now and it seems to work fine so far. I will leave it running and see if I get any reports of issues with it. I bet that PEQ and other servers using the old Session Limiting would love the new code for handling it. I didn't even run the old code because of the issues with it, but with this new code, I will definitely keep it enabled

Also, I moved this thread to Code Submissions, since it contains a nice bit of code
You got that right, I might even bring PEQ down to get this in today! Derision, once again (for the millionth time) you sir, rock!
Reply With Quote
  #6  
Old 04-17-2009, 06:02 AM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,449
Default

Quote:
Originally Posted by Derision View Post
Try this:

In my limited testing on my private server, this seems to have the desired effect of kicking the existing connection and letting the new one in.

I moved the check, so it will kick the existing connection before the new one even gets to Character Select.

Edit: Code updated to remove memory leak.
Thank you! This is exactly what some of us need. I'm sure it will take a lot of stress off of both server admins and players.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:05 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3