Possible ghost connection ellimination

This commit is contained in:
Anonymous-275 2021-03-31 20:15:42 +03:00
parent 029cf94e68
commit 534b457f48
2 changed files with 3 additions and 8 deletions

View File

@ -93,7 +93,6 @@ void TNetwork::UDPServerMain() {
} }
if (Client->GetID() == ID) { if (Client->GetID() == ID) {
Client->UpdatePingTime();
Client->SetUDPAddr(client); Client->SetUDPAddr(client);
Client->SetIsConnected(true); Client->SetIsConnected(true);
TServer::GlobalParser(ClientPtr, Data.substr(2), mPPSMonitor, *this); TServer::GlobalParser(ClientPtr, Data.substr(2), mPPSMonitor, *this);
@ -356,7 +355,6 @@ std::shared_ptr<TClient> TNetwork::CreateClient(SOCKET TCPSock) {
bool TNetwork::TCPSend(TClient& c, const std::string& Data, bool IsSync) { bool TNetwork::TCPSend(TClient& c, const std::string& Data, bool IsSync) {
if (!IsSync) { if (!IsSync) {
if (c.IsSyncing()) { if (c.IsSyncing()) {
//std::unique_lock Lock(c.MissedPacketQueueMutex());
if (!Data.empty()) { if (!Data.empty()) {
if (Data.at(0) == 'O' || Data.at(0) == 'A' || Data.at(0) == 'C' || Data.at(0) == 'E') { if (Data.at(0) == 'O' || Data.at(0) == 'A' || Data.at(0) == 'C' || Data.at(0) == 'E') {
c.EnqueuePacket(Data); c.EnqueuePacket(Data);
@ -393,6 +391,7 @@ bool TNetwork::TCPSend(TClient& c, const std::string& Data, bool IsSync) {
} }
Sent += Temp; Sent += Temp;
} while (Sent < Size); } while (Sent < Size);
c.UpdatePingTime();
return true; return true;
} }

View File

@ -108,7 +108,6 @@ void TServer::GlobalParser(const std::weak_ptr<TClient>& Client, std::string Pac
} else { } else {
Network.UpdatePlayer(*LockedClient); Network.UpdatePlayer(*LockedClient);
} }
LockedClient->UpdatePingTime();
return; return;
case 'O': case 'O':
if (Packet.length() > 1000) { if (Packet.length() > 1000) {
@ -314,11 +313,8 @@ void TServer::ParseVehicle(TClient& c, const std::string& Pckt, TNetwork& Networ
void TServer::Apply(TClient& c, int VID, const std::string& pckt) { void TServer::Apply(TClient& c, int VID, const std::string& pckt) {
std::string Packet = pckt.substr(pckt.find('{')), VD = c.GetCarData(VID); std::string Packet = pckt.substr(pckt.find('{')), VD = c.GetCarData(VID);
std::string Header = VD.substr(0, VD.find('{')); std::string Header = VD.substr(0, VD.find('{'));
if(VD.empty()){
error("Applying config for a non existing car?"); VD = VD.substr(VD.find('{'));
abort();
}
VD = VD.substr(VD.find('{')); //TODO somehow this got hit while VD is empty
rapidjson::Document Veh, Pack; rapidjson::Document Veh, Pack;
Veh.Parse(VD.c_str()); Veh.Parse(VD.c_str());
if (Veh.HasParseError()) { if (Veh.HasParseError()) {