UCS / Raid / Zone Fixes (#1033)

* Cache EntityList::GetRaidByClient

* Adjustments [skip ci]

* Update entity [skip ci]

* More cleanup [skip ci]

* More tweaks [skip ci]

* Cleanup [skip ci]

* Fix bugs with UCS reconnection on crash / exit, not adding soft deleted characters, put main loop on UV lib

* Reduce log spam that should be debugging; send keepalives to clients so that they properly prune from the connection list

* Shutdown the eventloop to properly shutdown the zone versus calling a hard exit
This commit is contained in:
Chris Miles
2020-04-14 23:28:43 -05:00
committed by GitHub
parent bffeee8d1a
commit 16cfad1966
14 changed files with 146 additions and 69 deletions
+30 -11
View File
@@ -6,29 +6,38 @@
#include "../common/misc_functions.h"
#include "../common/md5.h"
#include "../common/packet_dump.h"
#include "../common/event/timer.h"
UCSConnection::UCSConnection()
{
Stream = 0;
connection = 0;
}
void UCSConnection::SetConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> inStream)
{
if (Stream && Stream->Handle())
{
if (inStream && connection && connection->Handle()) {
LogInfo("Incoming UCS Connection while we were already connected to a UCS");
Stream->Handle()->Disconnect();
connection->Handle()->Disconnect();
}
connection = inStream;
if (connection) {
connection->OnMessage(
std::bind(
&UCSConnection::ProcessPacket,
this,
std::placeholders::_1,
std::placeholders::_2
)
);
}
Stream = inStream;
if (Stream) {
Stream->OnMessage(std::bind(&UCSConnection::ProcessPacket, this, std::placeholders::_1, std::placeholders::_2));
}
m_keepalive.reset(new EQ::Timer(5000, true, std::bind(&UCSConnection::OnKeepAlive, this, std::placeholders::_1)));
}
void UCSConnection::ProcessPacket(uint16 opcode, EQ::Net::Packet &p)
{
if (!Stream)
if (!connection)
return;
ServerPacket tpack(opcode, p);
@@ -60,10 +69,10 @@ void UCSConnection::ProcessPacket(uint16 opcode, EQ::Net::Packet &p)
void UCSConnection::SendPacket(ServerPacket* pack)
{
if (!Stream)
if (!connection)
return;
Stream->SendPacket(pack);
connection->SendPacket(pack);
}
void UCSConnection::SendMessage(const char *From, const char *Message)
@@ -78,3 +87,13 @@ void UCSConnection::SendMessage(const char *From, const char *Message)
SendPacket(pack);
safe_delete(pack);
}
void UCSConnection::OnKeepAlive(EQ::Timer *t)
{
if (!connection) {
return;
}
ServerPacket pack(ServerOP_KeepAlive, 0);
connection->SendPacket(&pack);
}