Added ClientVersion request system to UCS server (needed to fix saylinks)

This commit is contained in:
Uleat
2018-02-25 21:40:45 -05:00
parent 361937d443
commit 6c2a8edea6
13 changed files with 175 additions and 2 deletions
+85
View File
@@ -512,7 +512,9 @@ Client::Client(std::shared_ptr<EQStreamInterface> eqs) {
AccountGrabUpdateTimer = new Timer(60000); //check every minute
GlobalChatLimiterTimer = new Timer(RuleI(Chat, IntervalDurationMS));
RawConnectionType = '\0';
TypeOfConnection = ConnectionTypeUnknown;
ClientVersion_ = EQEmu::versions::ClientVersion::Unknown;
UnderfootOrLater = false;
}
@@ -643,6 +645,10 @@ void Clientlist::Process()
database.GetAccountStatus((*it));
// give world packet a chance to arrive and be processed
if ((*it)->GetCharID())
ClientVersionRequestQueue[(*it)->GetCharID()] = (Timer::GetCurrentTime() + (RuleI(Chat, ExpireClientVersionRequests) * 1000));
if ((*it)->GetConnectionType() == ConnectionTypeCombined)
(*it)->SendFriends();
@@ -681,8 +687,35 @@ void Clientlist::Process()
it = ClientChatConnections.erase(it);
continue;
}
// initiate request if we don't already have a reply from 'world enter' (ucs crash recovery protocol)
if ((*it)->GetClientVersion() == EQEmu::versions::ClientVersion::Unknown) {
if (!CheckForClientVersionReply((*it)))
RequestClientVersion((*it)->GetCharID());
}
++it;
}
// delete expired replies
auto repiter = ClientVersionReplyQueue.begin();
while (repiter != ClientVersionReplyQueue.end()) {
if ((*repiter).second.second <= Timer::GetCurrentTime()) {
repiter = ClientVersionReplyQueue.erase(repiter);
continue;
}
++repiter;
}
// delete expired requests
auto reqiter = ClientVersionRequestQueue.begin();
while (reqiter != ClientVersionRequestQueue.end()) {
if ((*reqiter).second <= Timer::GetCurrentTime()) {
reqiter = ClientVersionRequestQueue.erase(reqiter);
continue;
}
++reqiter;
}
}
void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
@@ -840,6 +873,55 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
}
}
void Clientlist::RequestClientVersion(uint32 character_id) {
if (!character_id)
return;
if (ClientVersionRequestQueue.find(character_id) != ClientVersionRequestQueue.end()) {
if (ClientVersionRequestQueue[character_id] > Timer::GetCurrentTime())
return;
}
if (LogSys.log_settings[Logs::UCS_Server].is_category_enabled) {
Log(Logs::Detail, Logs::UCS_Server, "Requesting ClientVersion reply for character id: %u",
character_id);
}
ClientVersionRequestIDs.push_back(character_id);
ClientVersionRequestQueue[character_id] = (Timer::GetCurrentTime() + (RuleI(Chat, ExpireClientVersionRequests) * 1000));
}
bool Clientlist::QueueClientVersionReply(uint32 character_id, EQEmu::versions::ClientVersion client_version) {
if (!character_id)
return true;
if (client_version == EQEmu::versions::ClientVersion::Unknown)
return false;
if (LogSys.log_settings[Logs::UCS_Server].is_category_enabled) {
Log(Logs::Detail, Logs::UCS_Server, "Queueing ClientVersion %u reply for character id: %u",
static_cast<uint32>(client_version), character_id);
}
ClientVersionReplyQueue[character_id] = cvt_pair(client_version, (Timer::GetCurrentTime() + (RuleI(Chat, ExpireClientVersionReplies) * 1000)));
ClientVersionRequestQueue.erase(character_id);
return true;
}
bool Clientlist::CheckForClientVersionReply(Client* c) {
if (!c)
return true;
if (ClientVersionReplyQueue.find(c->GetCharID()) == ClientVersionReplyQueue.end())
return false;
if (LogSys.log_settings[Logs::UCS_Server].is_category_enabled) {
Log(Logs::General, Logs::UCS_Server, "Registering ClientVersion %s for stream %s:%u",
EQEmu::versions::ClientVersionName(ClientVersionReplyQueue[c->GetCharID()].first), c->ClientStream->GetRemoteAddr().c_str(), c->ClientStream->GetRemotePort());
}
c->SetClientVersion(ClientVersionReplyQueue[c->GetCharID()].first);
ClientVersionReplyQueue.erase(c->GetCharID());
return true;
}
void Clientlist::CloseAllConnections() {
@@ -2132,6 +2214,8 @@ void Client::AccountUpdate()
void Client::SetConnectionType(char c) {
RawConnectionType = c;
switch (c)
{
case 'S':
@@ -2161,6 +2245,7 @@ void Client::SetConnectionType(char c) {
}
default:
{
RawConnectionType = '\0';
TypeOfConnection = ConnectionTypeUnknown;
Log(Logs::Detail, Logs::UCS_Server, "Connection type is unknown.");
}