Make the reconnect code only trigger when there's actually a client IN ZONE and try to clean up otherwise

This commit is contained in:
KimLS
2019-07-23 21:59:22 -07:00
parent 780f8f8515
commit cd32a5a47a
13 changed files with 70 additions and 6 deletions
+1 -1
View File
@@ -446,7 +446,7 @@ Client::~Client() {
numclients--;
UpdateWindowTitle();
if(zone)
zone->RemoveAuth(GetName());
zone->RemoveAuth(GetName());
//let the stream factory know were done with this stream
eqs->Close();
+12
View File
@@ -1713,6 +1713,18 @@ Client *EntityList::GetClientByWID(uint32 iWID)
return nullptr;
}
Client *EntityList::GetClientByLSID(uint32 iLSID)
{
auto it = client_list.begin();
while (it != client_list.end()) {
if (it->second->LSAccountID() == iLSID) {
return it->second;
}
++it;
}
return nullptr;
}
Client *EntityList::GetRandomClient(const glm::vec3& location, float Distance, Client *ExcludeClient)
{
std::vector<Client *> ClientsInRange;
+1
View File
@@ -176,6 +176,7 @@ public:
}
Client *GetClientByCharID(uint32 iCharID);
Client *GetClientByWID(uint32 iWID);
Client *GetClientByLSID(uint32 iLSID);
Client *GetClient(uint32 ip, uint16 port);
Client *GetRandomClient(const glm::vec3& location, float Distance, Client *ExcludeClient = nullptr);
Group *GetGroupByMob(Mob* mob);
+17
View File
@@ -547,6 +547,23 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
break;
}
case ServerOP_DropClient: {
if (pack->size != sizeof(ServerZoneDropClient_Struct)) {
break;
}
ServerZoneDropClient_Struct* drop = (ServerZoneDropClient_Struct*)pack->pBuffer;
if (zone) {
zone->RemoveAuth(drop->lsid);
auto client = entity_list.GetClientByLSID(drop->lsid);
if (client) {
client->Kick();
client->Save();
}
}
break;
}
case ServerOP_ZonePlayer: {
ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*)pack->pBuffer;
Client* client = entity_list.GetClientByName(szp->name);
+16
View File
@@ -1106,6 +1106,7 @@ void Zone::AddAuth(ServerZoneIncomingClient_Struct* szic) {
zca->accid = szic->accid;
zca->admin = szic->admin;
zca->charid = szic->charid;
zca->lsid = szic->lsid;
zca->tellsoff = szic->tellsoff;
strn0cpy(zca->charname, szic->charname, sizeof(zca->charname));
strn0cpy(zca->lskey, szic->lskey, sizeof(zca->lskey));
@@ -1128,6 +1129,21 @@ void Zone::RemoveAuth(const char* iCharName)
}
}
void Zone::RemoveAuth(uint32 lsid)
{
LinkedListIterator<ZoneClientAuth_Struct*> iterator(client_auth_list);
iterator.Reset();
while (iterator.MoreElements()) {
ZoneClientAuth_Struct* zca = iterator.GetData();
if (zca->lsid == lsid) {
iterator.RemoveCurrent();
return;
}
iterator.Advance();
}
}
void Zone::ResetAuth()
{
LinkedListIterator<ZoneClientAuth_Struct*> iterator(client_auth_list);
+2
View File
@@ -52,6 +52,7 @@ struct ZoneClientAuth_Struct {
uint32 accid;
int16 admin;
uint32 charid;
uint32 lsid;
bool tellsoff;
char charname[64];
char lskey[30];
@@ -244,6 +245,7 @@ public:
void ReloadStaticData();
void ReloadWorld(uint32 Option);
void RemoveAuth(const char *iCharName);
void RemoveAuth(uint32 lsid);
void Repop(uint32 delay = 0);
void RepopClose(const glm::vec4 &client_position, uint32 repop_distance);
void RequestUCSServerStatus();