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 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
  #2  
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
  #3  
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
  #4  
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
  #5  
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
  #6  
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
  #7  
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

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 03:32 PM.


 

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 - 2026, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3