|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
 |
|
 |

04-16-2009, 03:12 PM
|
Developer
|
|
Join Date: Feb 2004
Location: UK
Posts: 1,540
|
|
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.
|
 |
|
 |

04-16-2009, 07:01 PM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
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!
|

04-17-2009, 06:58 AM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
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 
Last edited by trevius; 04-17-2009 at 03:02 PM..
|

04-17-2009, 09:52 AM
|
 |
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
Quote:
Originally Posted by trevius
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!
|

04-17-2009, 06:02 AM
|
 |
Demi-God
|
|
Join Date: May 2007
Location: b
Posts: 1,449
|
|
Quote:
Originally Posted by Derision
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.
|
Thread Tools |
|
Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 01:07 PM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |