Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 08-01-2008, 05:04 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default Allow Only 1 Session Per Account

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
Code:
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
Code:
void	GetCLEIP(int32 iIP);

\world\clientlist.cpp
Code:
 //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
Code:
if (RuleI(World, AccountSessionLimit) = true) {
client_list.GetCLEIP(this->GetAccountID());  //Lieka Edit Begin:  Check current CLE Entry IPs against incoming connection
}

Required SQL:
Code:
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.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 08-01-2008 at 01:06 PM..
Reply With Quote
  #2  
Old 08-01-2008, 07:51 AM
rojadruid
Discordant
 
Join Date: May 2005
Location: Smith Falls, Ontario, Canada
Posts: 283
Default

Thank you very much for this. This will be great once it gets to the main code.
__________________
Rojadruid

Innoruuk Server [legit]
Server Admin.
Server Status: UP
Reply With Quote
  #3  
Old 08-01-2008, 09:00 AM
Theeper
Discordant
 
Join Date: May 2004
Posts: 290
Default

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.
Reply With Quote
  #4  
Old 08-01-2008, 09:20 AM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

Quote:
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.
Reply With Quote
  #5  
Old 08-01-2008, 01:03 PM
rojadruid
Discordant
 
Join Date: May 2005
Location: Smith Falls, Ontario, Canada
Posts: 283
Default

Quote:
Originally Posted by Theeper View Post
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.
__________________
Rojadruid

Innoruuk Server [legit]
Server Admin.
Server Status: UP
Reply With Quote
  #6  
Old 08-01-2008, 03:00 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

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.
Reply With Quote
  #7  
Old 08-01-2008, 05:27 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

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.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #8  
Old 08-02-2008, 05:50 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

To start, you would need the following from what you posted above to create the rule entries:
Quote:
Originally Posted by trevius View Post
\common\ruletypes.h
Code:
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:
Code:
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 around line 463:
Code:
  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 to find, 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.
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote
  #9  
Old 09-24-2008, 05:42 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

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
Code:
	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
Code:
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
Code:
#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
Code:
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.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #10  
Old 11-10-2008, 02:08 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

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
Code:
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
Code:
void	GetCLEAccount(int32 iAccID);
\world\client.cpp
Code:
if (RuleI(World, AccountSessionLimit) >= 0) {
client_list.GetCLEAccount(this->GetAccountID());  //Check current CLE Accounts against incoming connection
}
\world\clientlist.cpp
Code:
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:
Code:
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
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #11  
Old 11-10-2008, 02:16 AM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Quote:
Originally Posted by trevius View Post
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.
Reply With Quote
  #12  
Old 11-10-2008, 08:35 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

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.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #13  
Old 11-11-2008, 04:12 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

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.
Reply With Quote
  #14  
Old 11-11-2008, 07:10 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

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.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #15  
Old 11-19-2008, 04:57 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

If you change the iterator from:

Code:
LinkedListIterator<ClientListEntry*> iterator(clientlist);
to

Code:
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.
Reply With Quote
Reply


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 09:02 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