diff --git a/src/Network 2.0/VehicleData.cpp b/src/Network 2.0/VehicleData.cpp index c472488..724b4c5 100644 --- a/src/Network 2.0/VehicleData.cpp +++ b/src/Network 2.0/VehicleData.cpp @@ -182,7 +182,6 @@ void HandleChunk(Client*c,const std::string&Data){ void UDPParser(Client*c, const std::string&Packet){ if(Packet.substr(0,4) == "ACK:"){ AckID(stoi(Packet.substr(4))); - std::cout << "Got Ack from " << c->GetName() << std::endl; return; }else if(Packet.substr(0,3) == "BD:"){ int pos = Packet.find(':',4); diff --git a/src/Network 2.0/VehicleEvent.cpp b/src/Network 2.0/VehicleEvent.cpp index 8b9201b..e7c2403 100644 --- a/src/Network 2.0/VehicleEvent.cpp +++ b/src/Network 2.0/VehicleEvent.cpp @@ -15,10 +15,11 @@ struct Sequence{ bool Done = false; }; void CreateNewThread(Client*client); -void CreateClient(SOCKET TCPSock,const std::string &Name, const std::string &DID) { +void CreateClient(SOCKET TCPSock,const std::string &Name, const std::string &DID,const std::string &Role) { auto *client = new Client; client->SetTCPSock(TCPSock); client->SetName(Name); + client->SetRole(Role); client->SetDID(DID); Clients.insert(client); CreateNewThread(client); @@ -57,12 +58,22 @@ void Check(Sequence* S){ } } void Identification(SOCKET TCPSock){ - Sequence* S = new Sequence; + auto* S = new Sequence; S->TCPSock = TCPSock; std::thread Timeout(Check,S); Timeout.detach(); - std::string Name,DID,Role,Res = TCPRcv(TCPSock); + std::string Name,DID,Role,Res = TCPRcv(TCPSock),Ver = TCPRcv(TCPSock); S->Done = true; + if(Ver.size() > 3 && Ver.substr(0,2) == "VC"){ + Ver = Ver.substr(2); + if(Ver.length() > 4 || Ver < ClientVersion){ + closesocket(TCPSock); + return; + } + }else{ + closesocket(TCPSock); + return; + } if(Res.size() > 3 && Res.substr(0,2) == "NR"){ if(Res.find(':') == std::string::npos){ closesocket(TCPSock); @@ -77,14 +88,14 @@ void Identification(SOCKET TCPSock){ } if(Debug)debug("Name -> " + Name + ", Role -> " + Role + ", ID -> " + DID); if(Role == "MDEV"){ - CreateClient(TCPSock,Name,DID); + CreateClient(TCPSock,Name,DID,Role); return; } }else{ closesocket(TCPSock); return; } - if(Clients.size() < MaxPlayers)CreateClient(TCPSock,Name,DID); + if(Clients.size() < MaxPlayers)CreateClient(TCPSock,Name,DID,Role); } void TCPServerMain(){ diff --git a/src/main.cpp b/src/main.cpp index d8121e0..951e694 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,7 @@ void addToLog(const std::string& Data); //void ServerMain(int Port, int MaxClients); void HeartbeatInit(); std::string ServerVersion = "0.4"; -std::string ClientVersion = "1.4+"; +std::string ClientVersion = "1.4"; std::string CustomIP; void HandleResources(std::string path); void StatInit();