From 57a58b1a380ccf2f69805be2365367c1bc8ad99f Mon Sep 17 00:00:00 2001 From: Anonymous-275 <36374260+Anonymous-275@users.noreply.github.com> Date: Mon, 24 Apr 2023 11:41:09 +0100 Subject: [PATCH] fix hang and crash caused by client kick --- src/Client.cpp | 2 +- src/TServer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Client.cpp b/src/Client.cpp index 6532d55..cc6285e 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -25,7 +25,7 @@ void TClient::ClearCars() { std::unique_lock lock(mVehicleDataMutex); for (const auto& Car : mVehicleData) { std::string Destroy = "Od:" + std::to_string(GetID()) + "-" + std::to_string(Car.ID()); - LuaAPI::MP::Engine->Network().SendToAll(nullptr, StringToVector(Destroy), true, true); + LuaAPI::MP::Engine->Network().SendToAll(this, StringToVector(Destroy), false, true); } mVehicleData.clear(); } diff --git a/src/TServer.cpp b/src/TServer.cpp index 9ee382d..47a69cc 100644 --- a/src/TServer.cpp +++ b/src/TServer.cpp @@ -192,9 +192,9 @@ void TServer::RemoveClient(const std::weak_ptr& WeakClientPtr) { void TServer::RemoveClientById(int Id) { auto Client = GetClient(*this, Id); - WriteLock Lock(mClientsMutex); if (Client) { Client->ClearCars(); + WriteLock Lock(mClientsMutex); mClients.erase(Client); } }