View Full Version : Allow Only 1 Session Per Account
trevius
08-01-2008, 05:04 AM
Since there are connection issues and some other issues with having more than 1 character logged in at the same time from a single account, I thought it would be nice if we had a way to only allow 1 session at a time per account. This won't limit how many connections they can have to the server, it will only block the same account from logging in more than one session at a time. They can still use as many accounts as they like to play more than 1 character at a time.
I think it would be good to have this implemented as a Rule, in case some admins don't want to use it, or don't want the headache of getting complaints from their players about it. This should be fairly simple code to write, but I think it surpasses my coding skills.
There is probably an easier way to do it, but I am thinking something similar to TheLieka's code for IP limiting should work just fine.
Here is an example of his code with a few changes I have made so far to start getting the code changed for this. Most of it is still his IP limiting code, though:
\common\ruletypes.h
RULE_BOOL ( World, AccountSessionLimit, false ) //Trevius Edit: Limit Accounts to only login 1 Character Per Session Default value: false (feature disabled)
RULE_INT ( World, ExemptAccountLimitStatus, -1 ) //Trevius Edit: Exempt accounts from the AccountSessionLimit rule if their status is >= this value. Default value: -1 (feature disabled)
\world\clientlist.h
void GetCLEIP(int32 iIP);
\world\clientlist.cpp
//Lieka Edit Begin: Check current CLE Entry IPs against incoming connection
void ClientList::GetCLEIP(int32 iIP) {
ClientListEntry* countCLEIPs = 0;
LinkedListIterator<ClientListEntry*> iterator(clientlist);
int IPInstances = 0;
iterator.Reset();
while(iterator.MoreElements()) {
countCLEIPs = iterator.GetData();
if ((countCLEIPs->GetIP() == iIP) && ((countCLEIPs->Admin() <= (RuleI(World, ExemptMaxClientsStatus))) || (RuleI(World, ExemptMaxClientsStatus) < 0))) {
IPInstances++;
if (IPInstances > (RuleI(World, MaxClientsPerIP))){
countCLEIPs->SetOnline(CLE_Status_Offline);
iterator.RemoveCurrent();
}
}
iterator.Advance();
}
}
//Lieka Edit End
\world\client.cpp
if (RuleI(World, AccountSessionLimit) = true) {
client_list.GetCLEIP(this->GetAccountID()); //Lieka Edit Begin: Check current CLE Entry IPs against incoming connection
}
Required SQL:
Insert into rule_values values (0, 'World:AccountSessionLimit', false);
Insert into rule_values values (0, 'World:ExemptAccountLimitStatus', -1);
If someone can get the rest figured out, I would love to get it put in on my server. I think with this set, it will keep new players from making the mistake of using multiple characters on the same account to box together, only to find out later on that they should have used separate accounts.
Here is a link to TheLieka's original posting for the IP Limiting, if anyone cares to compare and do some work on this:
http://www.eqemulator.net/forums/showthread.php?t=24730
Make sure to read the post he made later on there with a couple of corrections to his original submission.
rojadruid
08-01-2008, 07:51 AM
Thank you very much for this. This will be great once it gets to the main code.
Theeper
08-01-2008, 09:00 AM
I think booting the currently logged in character is a better way to limit this than to not allow the account to login when there's already a toon on. The reason is, I see ghosts and characters seemingly stuck online long after I log out sometimes. I think in some cases you might go LD and then not be able to get back in.
In the account table, the active character name is stored when you login .. what about simply checking the Client List and booting the character listed each time you login? This way, if there is already a toon logged in on the account, it will get WorldKicked when you login a second toon.
Granted this is not the way Live works, but I think it would cause less problems and be easier to implement.
So_1337
08-01-2008, 09:20 AM
I think booting the currently logged in character is a better way to limit this than to not allow the account to login when there's already a toon on. The reason is, I see ghosts and characters seemingly stuck online long after I log out sometimes. I think in some cases you might go LD and then not be able to get back in.
I'm going to have to agree. One of the main problems I've had with the IP Limiting code thus far has been where people disconnect/crash on one or more characters (limit is currently set for two) and then can't come back on. However, if I log in, I'll find their two characters standing right where they left them, and they'll stand there until the server reboots unless I do a #kick.
To see the above quoted modification to this code and/or the IP Limiting code would help immensely with the problem I just described, and maybe have an effect on the character ghosting issues that Windows servers experience.
rojadruid
08-01-2008, 01:03 PM
I think booting the currently logged in character is a better way to limit this than to not allow the account to login when there's already a toon on.
Correct me if I am wrong but live works this way does it not. Thats the way I remember it but it may have changed.
Live's way sucks. Definitely boot the char already in the game imo, it's simpler to implement and less annoying for the legit player.
trevius
08-01-2008, 05:27 PM
Ya, I do think that live does boot the character in game when you log in the same account again. I wasn't really thinking of the details I guess lol. The ghosting issue that causes problems with IP limiting is really only a problem on Windows. I wish they would fix that problem for Windows servers though, as Linux doesn't have player ghosting.
But anyway, the stuff I have posted so far isn't anywhere near done. That is why I posted it in the feature request section. It is mostly all still the IP Limiting code, and hasn't been modified accept for a few minor places like the rules. But, I do think it is something the emu has been missing and will help out with a couple of major issues. I will see if I can help figure out the code to do it, but I really do suck at it lol. I can only really work by example. For someone with good coding experience, I doubt this would be too hard though.
AndMetal
08-02-2008, 05:50 AM
To start, you would need the following from what you posted above to create the rule entries:
\common\ruletypes.h (http://eqemulator.cvs.sourceforge.net/eqemulator/EQEmuCVS/Source/common/ruletypes.h?revision=1.30&view=markup#l_67)
RULE_BOOL ( World, AccountSessionLimit, false ) //Trevius Edit: Limit Accounts to only login 1 Character Per Session Default value: false (feature disabled)
RULE_INT ( World, ExemptAccountLimitStatus, -1 ) //Trevius Edit: Exempt accounts from the AccountSessionLimit rule if their status is >= this value. Default value: -1 (feature disabled)
Required SQL:
Insert into rule_values values (0, 'World:AccountSessionLimit', false);
Insert into rule_values values (0, 'World:ExemptAccountLimitStatus', -1);
However, I think something similar to TheLieka's IP limiting code would be good, where you can specify how many characters on the same account can be logged on at once. For example, -1 means the rule is disabled, 1 would allow just 1 character on, etc.
The actual code to both check, and then as a result kick the online character, I believe would go in world/client.cpp (http://eqemulator.cvs.sourceforge.net/eqemulator/EQEmuCVS/Source/world/client.cpp?revision=1.26&view=markup#l_446) around line 463:
446 case OP_EnterWorld: // Enter world
447 {
448 if (GetAccountID() == 0) {
449 clog(WORLD__CLIENT_ERR,"Enter world with no logged in account");
450 eqs->Close();
451 break;
452 }
453 if(GetAdmin() < 0)
454 {
455 clog(WORLD__CLIENT,"Account banned or suspended.");
456 eqs->Close();
457 break;
458 }
459
460 if (RuleI(World, MaxClientsPerIP) >= 0) {
461 client_list.GetCLEIP(this->GetIP()); //Lieka Edit Begin: Check current CLE Entry IPs against incoming connection
462 }
463
We would first need to find out if any characters associated with the account are logged on, and if so proceed to kick the online one(s). I haven't found the Kick function in the source yet, but once we find that, then we can find out if we need the character name or if we can just use the account ID. From what I was able (http://eqemulator.cvs.sourceforge.net/eqemulator/EQEmuCVS/Source/zone/client.h?revision=1.67&view=markup#l_247) to (http://eqemulator.cvs.sourceforge.net/eqemulator/EQEmuCVS/Source/zone/client.cpp?revision=1.71&view=markup#l_1789) find (http://eqemulator.cvs.sourceforge.net/eqemulator/EQEmuCVS/Source/world/console.cpp?revision=1.9&view=markup#l_575), it looks like it may be manually defined in several different places, several different ways, so we may need to make one.
If I can, I'll look a little deeper into this, but hopefully this gives us a place to start.
trevius
09-24-2008, 05:42 AM
I am still wanting to get this feature added at some point. I am noting some code that might be usable to help write the account limiting code. Note that this is all code that already exists in the source, but I think some of it may be useful for making this feature.
clientlist.h
Client* FindByAccountID(int32 account_id);
Client* FindByName(char* charname);
ClientListEntry* FindCharacter(const char* name);
ClientListEntry* FindCLEByAccountID(int32 iAccID);
ClientListEntry* FindCLEByCharacterID(int32 iAccID);
ClientListEntry* GetCLE(int32 iID);
clientlist.cpp
ClientListEntry* ClientList::FindCLEByAccountID(int32 iAccID) {
LinkedListIterator<ClientListEntry*> iterator(clientlist);
iterator.Reset();
while(iterator.MoreElements()) {
if (iterator.GetData()->AccountID() == iAccID) {
return iterator.GetData();
}
iterator.Advance();
}
return 0;
}
cliententry.h
#define CLE_Status_Never -1
#define CLE_Status_Offline 0
#define CLE_Status_Online 1 // Will not overwrite more specific online status
#define CLE_Status_CharSelect 2
#define CLE_Status_Zoning 3
#define CLE_Status_InZone 4
// Account stuff
inline int32 AccountID() const { return paccountid; }
inline const char* AccountName() const { return paccountname; }
inline sint16 Admin() const { return padmin; }
inline void SetAdmin(int16 iAdmin) { padmin = iAdmin; }
// Character info
inline ZoneServer* Server() const { return pzoneserver; }
inline void ClearServer() { pzoneserver = 0; }
inline int32 CharID() const { return pcharid; }
inline const char* name() const { return pname; }
cliententry.cpp
void ClientListEntry::SetOnline(sint8 iOnline) {
if (iOnline >= CLE_Status_Online && pOnline < CLE_Status_Online)
numplayers++;
else if (iOnline < CLE_Status_Online && pOnline >= CLE_Status_Online) {
numplayers--;
}
if (iOnline != CLE_Status_Online || pOnline < CLE_Status_Online)
pOnline = iOnline;
if (iOnline < CLE_Status_Zoning)
Camp();
if (pOnline >= CLE_Status_Online)
stale = 0;
}
void ClientListEntry::Camp(ZoneServer* iZS) {
if (iZS != 0 && iZS != pzoneserver)
return;
if (pzoneserver){
pzoneserver->RemovePlayer();
LSUpdate(pzoneserver);
}
ClearVars();
stale = 0;
}
ClientListEntry* ClientList::GetCLE(int32 iID) {
LinkedListIterator<ClientListEntry*> iterator(clientlist);
iterator.Reset();
while(iterator.MoreElements()) {
if (iterator.GetData()->GetID() == iID) {
return iterator.GetData();
}
iterator.Advance();
}
return 0;
}
When I get more time, I am going to look into this further and see if I can get some code working to create this feature. All it should be doing is checking when a player logs in a character if they already have any other characters logged in on that same account. And, if they do, then it should boot the other character on the account that is already logged in and allow the new character to log in in it's place.
trevius
11-10-2008, 02:08 AM
Ok, looking at this further, I think we are doing almost the exact same thing that Lieka is doing with the IP limiting. The only difference is that we want to boot the Online characters instead of the incoming characters. I have rewritten this code a bit so that it should actually work, but that it should still be kicking off the incoming character. I think if we can figure out how to kick a character that is logged in and let the new incoming one replace them, that it should finalize this code.
\common\ruletypes.h
RULE_INT ( World, AccountSessionLimit, -1 ) //Max number of characters allowed on at once from a single account (-1 is disabled)
RULE_INT ( World, ExemptAccountLimitStatus, -1 ) //Min status required to be exempt from multi-session per account limiting (-1 is disabled)
\world\clientlist.h
void GetCLEAccount(int32 iAccID);
\world\client.cpp
if (RuleI(World, AccountSessionLimit) >= 0) {
client_list.GetCLEAccount(this->GetAccountID()); //Check current CLE Accounts against incoming connection
}
\world\clientlist.cpp
void ClientList::GetCLEAccount(int32 iAccID) {
ClientListEntry* count_Chars_On = 0;
LinkedListIterator<ClientListEntry*> iterator(clientlist);
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))) {
Chars_On++;
if (Chars_On > (RuleI(World, AccountSessionLimit))){
count_Chars_On->SetOnline(CLE_Status_Offline);
iterator.RemoveCurrent();
}
}
iterator.Advance();
}
}
Required SQL:
Insert into rule_values values (0, 'World:AccountSessionLimit', -1);
Insert into rule_values values (0, 'World:ExemptAccountLimitStatus', -1);
The only other thing I am unsure of is that by switching this from a Bool that only allows 1 max character on at a time per account into an Int that lets you set the max number allowed per account, I am not sure how it would decide which online character to kick off. I imagine it would just go through the while and kick the first one online that it got to once it exceeded the limit. But, I figured it was worth mentioning. Personally, I think this would have been fine as a Bool instead of an Int, so you just enable or disable it. I do think the exempt status check could possibly be useful though. No reason to limit admins from logging in more than 1 per account.
On another note, I think by enabling this rule and setting it to 1 character max per account, it should also stop the possible exploit with shared bank platinum. That is just one more reason to get this working :)
cavedude
11-10-2008, 02:16 AM
On another note, I think by enabling this rule and setting it to 1 character max per account, it should also stop the possible exploit with shared bank platinum. That is just one more reason to get this working :)
It would also help with client/server stability. Both login and world hate it when the same account logs on multiple times.
trevius
11-10-2008, 08:35 AM
I tested the code submitted above and it actually works perfectly as intended as far as I can tell. I was able to log on a single character from any account with any status, but if I tried to log on a second character from an account below the set exempt status, it would get disconnected after hitting "enter world". I also verified that the exempt status still works and you can log in as many as you want still if your account status is higher than the exempt setting.
So, all that is left is to figure out how to make it kick the character in game instead of disconnecting the new one trying to log in. I am thinking maybe the way to do it could be found in the code that keeps people from logging in the same character more than once. Since if you try to log in a character that is already online, it will boot the online character and let you log him/her in again with the new connection. This is mostly important for cases where a character may be bugged and stuck logged on. It would be extremely important on Windows servers using this feature, due to player ghosting.
cavedude
11-11-2008, 04:12 PM
I'm going to get this one PEQ tonight, and see how it goes. Since we're Linux we don't suffer from player ghosting, and LDs usually disconnect in under a minute so it's no problem for us as written.
trevius
11-11-2008, 07:10 PM
Been running it on my server a couple of days and haven't heard any issues with it yet. Seems to work exactly as intended. I am still trying to figure out where in the code it is checked if you are logging in the same character, because that is the only time it will boot the character that is online. If I can find that, I think we can add that to this code and have it kick the character in game.
Another nice bonus to this code is that on Windows servers running IP Limiting, character ghosting can cause players to be locked out of the server. But, with this rule in place, once we get it set to kick the in game character, it will resolve that issue and let them log in again.
Derision
11-19-2008, 04:57 AM
If you change the iterator from:
LinkedListIterator<ClientListEntry*> iterator(clientlist);
to
LinkedListIterator<ClientListEntry*> iterator(clientlist, BACKWARD);
it might allow the new login and kick off the older ones. I've not tested this with the code above, but I have tested a backward iterator, and Reset() starts it at the end, and Advance() moves it towards the start.
trevius
11-19-2008, 06:48 AM
Thanks, Derision :) I will give that a try along with a few other things I have been wanting to test as soon as I get my new test server up and running. Going to run VMWare on my Windows PC to have another Linux installation without having to dual boot or build a 3rd PC. It should be MUCH easier (on me and my players) to do code testing once I get Linux running on VMWare.
KingMort
11-21-2008, 07:09 AM
This exploit is majorly serious... Players can in fact duplicate tradeable items with this.. I hope that it gets fixed soon because until then Raid Addicts will not be Unlocked... Our economy has suffered greatly due to this..
Azamorra was a great coder who donated to our server an excellent fix for this , but it seems we have lost the code for it.. Aza if your out there please come back and help the community with this fix..
King
trevius
11-21-2008, 09:12 AM
What are you talking about KingMort? Are you sure the issue you are referring to is related to this topic? More details would be helpful. If you are having issues with the account limiting, you can disable it in your rules.
Secrets
11-21-2008, 10:52 AM
What are you talking about KingMort? Are you sure the issue you are referring to is related to this topic? More details would be helpful. If you are having issues with the account limiting, you can disable it in your rules.
He's just being KingMort atm. Ignore him. :)
He wants to put in the code on his server, however, I looked over the topics and can't make sense of where i'm supposed to put all the code right now. What do I remove, add, etc, because at the moment i'm sort of confused on where the code goes due to it being in three seperate posts.
I think what KingMort was trying to explain, from what I heard on IRC, that he wishes to disable the multi-account logon for his server, and that he's keeping it down until then.
So to prevent him from having a heart attack, could one of you please post the final code in a diff or something against latest SVN? I would appriciate it greatly. :P
cavedude
11-21-2008, 12:39 PM
http://www.eqemulator.net/forums/showpost.php?p=159757&postcount=10
That is all you need. It's currently running on TGC and works fine. Just find the void ClientList::GetCLEIP references and tack that code after them. Of course, players are going to complain because if they get kicked midfight, they have to wait 5 min to get back in, but oh well. It fixes several dupping/trading exploits and allows us to enable shared plat.
Mort is right of course, multiple toons on the same account opens the door for many exploits, which make obtaining items or gearing a guild let's say trivial.
KingMort
11-21-2008, 03:27 PM
Thanks Cavedude! I'll put that in myself
He's just being KingMort atm. Ignore him.
FU Secrets :)
Secrets
11-21-2008, 04:17 PM
From my testing with this code, it indeed kicks off players when they log in, but if you log in two characters to character select, and then log in them both at the same time, you are able to bypass it. Still messing with it to see if it was a fluke, though.
-S
Secrets
11-21-2008, 09:38 PM
Nevermind... KingMort was having issues with his SVN, doh.
I ended up putting in aza77's fix for this issue, which gets it from the loginserver->world, and denies a second account from logging in altogether. If I had aza77's contact info, i'd ask for permission to post it as I don't know if he wants that specific piece posted. But I don't have his contact info, so i'm tempted to share it.
KingMort
11-23-2008, 12:36 PM
Well it's not yours to be sharing so yeah...
Probably not a good idea
trevius
11-23-2008, 06:27 PM
I tried the suggestion that Derision made, but that didn't work. In fact, it stopped the limiting from happening at all as far as I could tell.
I am sure we can still come up with something. If I could only find the code that keeps you from logging in the same character more than once, I think it could be applied to this code to make a good solution.
I don't know if anything changed with the situation with aza77 (didn't know them), but here are a few excerpts from the changelog that seem to show that aza77 doesn't mind sharing code:
==10/28/2006
aza77: Fixed SendAppearancePacket
aza77: Fixed a PvP bug that caused the zone to crash on death
==07/16/2006
aza77: Fixed the lift issue + keyitems at doors
aza77: Fixed + modified traps and added a new type of trap
==07/13/2006
aza77: Added in game guild creation variables.GuildCreation + commands #guildcreate #guildapprove #guildlist
==07/12/2006
aza77: Added triggered only doors.
==07/05/2006
aza77: Added variables.Rules + commands #rules #acceptrules
==06/28/2006
aza77: Changed hp_regen + mana_regen such that negative values indicate no regen
==06/27/2006
aza77: Added quest::setnextinchpevent + $inchpevent
aza77: Added quest::sethp
==06/25/2006
aza77: Fixed PVP appearance issues
==06/15/2006
aza: Added MySQL5 support (FOR CUSTOM COMPILE ONLY)
==05/31/2006
FatherNitwit: (aza) Added quest::unscribespells
==05/06/2006
FatherNitwit: (aza) Enabled newer froglok classes.
FatherNitwit: (aza) Enabled several berserker combat skills.
==04/13/2006
FatherNitwit: Adding the incstats canges from aza on the forums.
And, here is the last post I see from aza77, and it just happens to show more sharing:
http://eqemulator.net/forums/showthread.php?t=21609
So, I would be pretty surprised if they were upset about their code being posted. From what I can tell, they would have wanted it shared. I do believe that the author reserves all rights to decide to share or not. Since you are unable to reach them, it is up to you whether to share or not. My guess is that the code wasn't meant to be secret, but was just something that they never got around to sharing. If they were a secretive person, then I would definitely say not to share.
Either way, we will get the account limiting issue resolved in the best way possible. It isn't a big deal. If the code that aza77 wrote just blocks them from logging in another character on the same account, then that is what the current code here already does, so it wouldn't be needed anyway. The only thing we need is a way to make it boot the in game character on the same account instead of blocking the one logging in. If it doesn't do that, there is no use for the code anyway.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.