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

View File

@ -80,6 +80,7 @@
#define ServerOP_GroupJoin 0x003e //for joining ooz folks #define ServerOP_GroupJoin 0x003e //for joining ooz folks
#define ServerOP_UpdateSpawn 0x003f #define ServerOP_UpdateSpawn 0x003f
#define ServerOP_SpawnStatusChange 0x0040 #define ServerOP_SpawnStatusChange 0x0040
#define ServerOP_DropClient 0x0041 // DropClient
#define ServerOP_ReloadTasks 0x0060 #define ServerOP_ReloadTasks 0x0060
#define ServerOP_DepopAllPlayersCorpses 0x0061 #define ServerOP_DepopAllPlayersCorpses 0x0061
#define ServerOP_ReloadTitles 0x0062 #define ServerOP_ReloadTitles 0x0062
@ -317,11 +318,17 @@ struct ServerZoneIncomingClient_Struct {
uint32 accid; uint32 accid;
int16 admin; int16 admin;
uint32 charid; uint32 charid;
uint32 lsid;
bool tellsoff; bool tellsoff;
char charname[64]; char charname[64];
char lskey[30]; char lskey[30];
}; };
struct ServerZoneDropClient_Struct
{
uint32 lsid;
};
struct ServerChangeWID_Struct { struct ServerChangeWID_Struct {
uint32 charid; uint32 charid;
uint32 newwid; uint32 newwid;

View File

@ -121,6 +121,8 @@ void ClientListEntry::SetOnline(ZoneServer* iZS, int8 iOnline) {
} }
void ClientListEntry::SetOnline(int8 iOnline) { void ClientListEntry::SetOnline(int8 iOnline) {
Log(Logs::Detail, Logs::World_Server, "ClientListEntry::SetOnline for %s(%i) = %i", AccountName(), AccountID(), iOnline);
if (iOnline >= CLE_Status_Online && pOnline < CLE_Status_Online) if (iOnline >= CLE_Status_Online && pOnline < CLE_Status_Online)
numplayers++; numplayers++;
else if (iOnline < CLE_Status_Online && pOnline >= CLE_Status_Online) { else if (iOnline < CLE_Status_Online && pOnline >= CLE_Status_Online) {

View File

@ -64,8 +64,6 @@ void ClientList::Process() {
struct in_addr in; struct in_addr in;
in.s_addr = iterator.GetData()->GetIP(); in.s_addr = iterator.GetData()->GetIP();
Log(Logs::Detail, Logs::World_Server,"Removing client from %s:%d", inet_ntoa(in), iterator.GetData()->GetPort()); Log(Logs::Detail, Logs::World_Server,"Removing client from %s:%d", inet_ntoa(in), iterator.GetData()->GetPort());
//the client destructor should take care of this.
// iterator.GetData()->Free();
iterator.RemoveCurrent(); iterator.RemoveCurrent();
} }
else else

View File

@ -109,14 +109,14 @@ void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p) {
auto cle = client_list.FindCLEByLSID(utwr->lsaccountid); auto cle = client_list.FindCLEByLSID(utwr->lsaccountid);
if (cle != nullptr) { if (cle != nullptr) {
auto status = cle->GetOnline(); auto status = cle->GetOnline();
if (CLE_Status_Zoning == status || CLE_Status_InZone == status) { if (CLE_Status_InZone == status) {
utwrs->response = UserToWorldStatusAlreadyOnline; utwrs->response = UserToWorldStatusAlreadyOnline;
SendPacket(&outpack); SendPacket(&outpack);
return; return;
} }
else { else {
//our existing cle is in a state we can login to, mark the old as stale and remove it. zoneserver_list.DropClient(utwrs->lsaccountid);
client_list.RemoveCLEByLSID(utwr->lsaccountid); client_list.RemoveCLEByLSID(utwrs->lsaccountid);
} }
} }
} }

View File

@ -708,6 +708,13 @@ void ZSList::WorldShutDown(uint32 time, uint32 interval)
} }
} }
void ZSList::DropClient(uint32 lsid) {
ServerPacket packet(ServerOP_DropClient, sizeof(ServerZoneDropClient_Struct));
auto drop = (ServerZoneDropClient_Struct*)packet.pBuffer;
drop->lsid = lsid;
SendPacket(&packet);
}
void ZSList::OnTick(EQ::Timer *t) void ZSList::OnTick(EQ::Timer *t)
{ {
if (!EventSubscriptionWatcher::Get()->IsSubscribed("EQW::ZoneUpdate")) { if (!EventSubscriptionWatcher::Get()->IsSubscribed("EQW::ZoneUpdate")) {

View File

@ -57,6 +57,7 @@ public:
void SOPZoneBootup(const char *adminname, uint32 ZoneServerID, const char *zonename, bool iMakeStatic = false); void SOPZoneBootup(const char *adminname, uint32 ZoneServerID, const char *zonename, bool iMakeStatic = false);
void UpdateUCSServerAvailable(bool ucss_available = true); void UpdateUCSServerAvailable(bool ucss_available = true);
void WorldShutDown(uint32 time, uint32 interval); void WorldShutDown(uint32 time, uint32 interval);
void DropClient(uint32 lsid);
ZoneServer* FindByPort(uint16 port); ZoneServer* FindByPort(uint16 port);
ZoneServer* FindByID(uint32 ZoneID); ZoneServer* FindByID(uint32 ZoneID);

View File

@ -1457,6 +1457,7 @@ void ZoneServer::IncomingClient(Client* client) {
s->accid = client->GetAccountID(); s->accid = client->GetAccountID();
s->admin = client->GetAdmin(); s->admin = client->GetAdmin();
s->charid = client->GetCharID(); s->charid = client->GetCharID();
s->lsid = client->GetLSID();
if (client->GetCLE()) if (client->GetCLE())
s->tellsoff = client->GetCLE()->TellsOff(); s->tellsoff = client->GetCLE()->TellsOff();
strn0cpy(s->charname, client->GetCharName(), sizeof(s->charname)); strn0cpy(s->charname, client->GetCharName(), sizeof(s->charname));

View File

@ -446,7 +446,7 @@ Client::~Client() {
numclients--; numclients--;
UpdateWindowTitle(); UpdateWindowTitle();
if(zone) if(zone)
zone->RemoveAuth(GetName()); zone->RemoveAuth(GetName());
//let the stream factory know were done with this stream //let the stream factory know were done with this stream
eqs->Close(); eqs->Close();

View File

@ -1713,6 +1713,18 @@ Client *EntityList::GetClientByWID(uint32 iWID)
return nullptr; 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) Client *EntityList::GetRandomClient(const glm::vec3& location, float Distance, Client *ExcludeClient)
{ {
std::vector<Client *> ClientsInRange; std::vector<Client *> ClientsInRange;

View File

@ -176,6 +176,7 @@ public:
} }
Client *GetClientByCharID(uint32 iCharID); Client *GetClientByCharID(uint32 iCharID);
Client *GetClientByWID(uint32 iWID); Client *GetClientByWID(uint32 iWID);
Client *GetClientByLSID(uint32 iLSID);
Client *GetClient(uint32 ip, uint16 port); Client *GetClient(uint32 ip, uint16 port);
Client *GetRandomClient(const glm::vec3& location, float Distance, Client *ExcludeClient = nullptr); Client *GetRandomClient(const glm::vec3& location, float Distance, Client *ExcludeClient = nullptr);
Group *GetGroupByMob(Mob* mob); Group *GetGroupByMob(Mob* mob);

View File

@ -547,6 +547,23 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
} }
break; 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: { case ServerOP_ZonePlayer: {
ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*)pack->pBuffer; ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*)pack->pBuffer;
Client* client = entity_list.GetClientByName(szp->name); Client* client = entity_list.GetClientByName(szp->name);

View File

@ -1106,6 +1106,7 @@ void Zone::AddAuth(ServerZoneIncomingClient_Struct* szic) {
zca->accid = szic->accid; zca->accid = szic->accid;
zca->admin = szic->admin; zca->admin = szic->admin;
zca->charid = szic->charid; zca->charid = szic->charid;
zca->lsid = szic->lsid;
zca->tellsoff = szic->tellsoff; zca->tellsoff = szic->tellsoff;
strn0cpy(zca->charname, szic->charname, sizeof(zca->charname)); strn0cpy(zca->charname, szic->charname, sizeof(zca->charname));
strn0cpy(zca->lskey, szic->lskey, sizeof(zca->lskey)); 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() void Zone::ResetAuth()
{ {
LinkedListIterator<ZoneClientAuth_Struct*> iterator(client_auth_list); LinkedListIterator<ZoneClientAuth_Struct*> iterator(client_auth_list);

View File

@ -52,6 +52,7 @@ struct ZoneClientAuth_Struct {
uint32 accid; uint32 accid;
int16 admin; int16 admin;
uint32 charid; uint32 charid;
uint32 lsid;
bool tellsoff; bool tellsoff;
char charname[64]; char charname[64];
char lskey[30]; char lskey[30];
@ -244,6 +245,7 @@ public:
void ReloadStaticData(); void ReloadStaticData();
void ReloadWorld(uint32 Option); void ReloadWorld(uint32 Option);
void RemoveAuth(const char *iCharName); void RemoveAuth(const char *iCharName);
void RemoveAuth(uint32 lsid);
void Repop(uint32 delay = 0); void Repop(uint32 delay = 0);
void RepopClose(const glm::vec4 &client_position, uint32 repop_distance); void RepopClose(const glm::vec4 &client_position, uint32 repop_distance);
void RequestUCSServerStatus(); void RequestUCSServerStatus();