Loading...   

  • Created By Uleat On: 03:25 PM February 24, 2018
  • Link

 common/emu_versions.h |  4 ++--
 common/servertalk.h   |  6 ++++++
 ucs/clientlist.cpp    | 40 ++++++++++++++++++++++++++++++++++++++++
 ucs/clientlist.h      |  8 ++++++++
 ucs/worldserver.cpp   |  8 ++++++++
 5 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/common/emu_versions.h b/common/emu_versions.h
index 9d9e1f58..9ab5becd 100644
--- a/common/emu_versions.h
+++ b/common/emu_versions.h
@@ -28,7 +28,7 @@
 namespace EQEmu
 {
 	namespace versions {
-		enum class ClientVersion {
+		enum class ClientVersion : uint32 {
 			Unknown = 0,
 			Client62,	// Build: 'Aug  4 2005 15:40:59'
 			Titanium,	// Build: 'Oct 31 2005 10:33:37'
@@ -72,7 +72,7 @@ namespace EQEmu
 		uint32 ConvertClientVersionToExpansion(ClientVersion client_version);
 
 
-		enum class MobVersion {
+		enum class MobVersion : uint32 {
 			Unknown = 0,
 			Client62,
 			Titanium,
diff --git a/common/servertalk.h b/common/servertalk.h
index f5965cd7..7640fbed 100644
--- a/common/servertalk.h
+++ b/common/servertalk.h
@@ -190,6 +190,7 @@
 #define ServerOP_ReloadLogs 0x4010
 #define ServerOP_ReloadPerlExportSettings	0x4011
 #define ServerOP_CZSetEntityVariableByClientName 0x4012
+#define ServerOP_UCSRegisterClientVersion	0x4013
 /* Query Server OP Codes */
 #define ServerOP_QSPlayerLogTrades					0x5010
 #define ServerOP_QSPlayerLogHandins					0x5011
@@ -1278,6 +1279,11 @@ struct ServerRequestTellQueue_Struct {
 	char	name[64];
 };
 
+struct UCSRegisterClientVersion_Struct {
+	uint32 character_id;
+	EQEmu::versions::ClientVersion client_version;
+};
+
 #pragma pack()
 
 #endif
diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp
index 998410ec..4b54ed13 100644
--- a/ucs/clientlist.cpp
+++ b/ucs/clientlist.cpp
@@ -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;
 }
@@ -681,8 +683,21 @@ void Clientlist::Process()
 			it = ClientChatConnections.erase(it);
 			continue;
 		}
+
+		if ((*it)->GetClientVersion() == EQEmu::versions::ClientVersion::Unknown)
+			RetryClientVersion((*it));
+
 		++it;
 	}
+
+	auto iter = ClientVersionQueue.begin();
+	while (iter != ClientVersionQueue.end) {
+		if ((*iter).second.second <= Timer::GetCurrentTime()) {
+			iter = ClientVersionQueue.erase(iter);
+			continue;
+		}
+		++iter;
+	}
 }
 
 void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
@@ -840,6 +855,28 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
 	}
 }
 
+void Clientlist::RegisterClientVersion(uint32 character_id, EQEmu::versions::ClientVersion client_version) {
+	for (auto it : ClientChatConnections) {
+		if (it->GetCharID() != character_id)
+			continue;
+
+		it->SetClientVersion(client_version);
+		ClientVersionQueue.erase(character_id);
+
+		return;
+	}
+
+	ClientVersionQueue[character_id] = std::pair<EQEmu::versions::ClientVersion, uint32>(client_version, (Timer::GetCurrentTime() + 90000));
+}
+
+void Clientlist::RetryClientVersion(Client* c) {
+	if (!c || ClientVersionQueue.find(c->GetCharID()) == ClientVersionQueue.end())
+		return;
+
+	c->SetClientVersion(ClientVersionQueue[c->GetCharID()].first);
+	ClientVersionQueue.erase(c->GetCharID());
+}
+
 void Clientlist::CloseAllConnections() {
 
 
@@ -2132,6 +2169,8 @@ void Client::AccountUpdate()
 
 void Client::SetConnectionType(char c) {
 
+	RawConnectionType = c;
+
 	switch (c)
 	{
 	case 'S':
@@ -2161,6 +2200,7 @@ void Client::SetConnectionType(char c) {
 	}
 	default:
 	{
+		RawConnectionType = '\0';
 		TypeOfConnection = ConnectionTypeUnknown;
 		Log(Logs::Detail, Logs::UCS_Server, "Connection type is unknown.");
 	}
diff --git a/ucs/clientlist.h b/ucs/clientlist.h
index 9b72df51..c03a6bfe 100644
--- a/ucs/clientlist.h
+++ b/ucs/clientlist.h
@@ -140,7 +140,10 @@ public:
 	int GetMailBoxNumber() { return CurrentMailBox; }
 	int GetMailBoxNumber(std::string CharacterName);
 	void SetConnectionType(char c);
+	void SetClientVersion(EQEmu::versions::ClientVersion client_version) { ClientVersion_ = client_version; }
+	char GetRawConnectionType() { return RawConnectionType; }
 	ConnectionType GetConnectionType() { return TypeOfConnection; }
+	EQEmu::versions::ClientVersion GetClientVersion() { return ClientVersion_; }
 	inline bool IsMailConnection() { return (TypeOfConnection == ConnectionTypeMail) || (TypeOfConnection == ConnectionTypeCombined); }
 	void SendNotification(int MailBoxNumber, std::string From, std::string Subject, int MessageID);
 	void ChangeMailBox(int NewMailBox);
@@ -167,7 +170,9 @@ private:
 	Timer *GlobalChatLimiterTimer; //60 seconds
 	int AttemptedMessages;
 	bool ForceDisconnect;
+	char RawConnectionType;
 	ConnectionType TypeOfConnection;
+	EQEmu::versions::ClientVersion ClientVersion_;
 	bool UnderfootOrLater;
 };
 
@@ -181,12 +186,15 @@ public:
 	void	CheckForStaleConnections(Client *c);
 	Client *IsCharacterOnline(std::string CharacterName);
 	void ProcessOPMailCommand(Client *c, std::string CommandString);
+	void RegisterClientVersion(uint32 character_id, EQEmu::versions::ClientVersion client_version);
+	void RetryClientVersion(Client* c);
 
 private:
 
 	EQ::Net::EQStreamManager *chatsf;
 
 	std::list<Client*> ClientChatConnections;
+	std::map<uint32, std::pair<EQEmu::versions::ClientVersion, uint32>> ClientVersionQueue;
 
 	OpcodeManager *ChatOpMgr;
 };
diff --git a/ucs/worldserver.cpp b/ucs/worldserver.cpp
index 14121103..79792493 100644
--- a/ucs/worldserver.cpp
+++ b/ucs/worldserver.cpp
@@ -114,5 +114,13 @@ void WorldServer::ProcessMessage(uint16 opcode, EQ::Net::Packet &p)
 			std::string());
 		break;
 	}
+
+	case ServerOP_UCSRegisterClientVersion:
+	{
+		UCSRegisterClientVersion_Struct* rcv = (UCSRegisterClientVersion_Struct*)pack->pBuffer;
+		g_Clientlist->RegisterClientVersion(rcv->character_id, rcv->client_version);
+		
+		break;
+	}
 	}
 }

Raw Paste Data