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.