fix hang and crash caused by client kick

This commit is contained in:
Anonymous-275
2023-04-24 11:41:09 +01:00
parent 2cf27ad837
commit 57a58b1a38
2 changed files with 2 additions and 2 deletions

View File

@@ -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();
}

View File

@@ -192,9 +192,9 @@ void TServer::RemoveClient(const std::weak_ptr<TClient>& WeakClientPtr) {
void TServer::RemoveClientById(int Id) {
auto Client = GetClient(*this, Id);
WriteLock Lock(mClientsMutex);
if (Client) {
Client->ClearCars();
WriteLock Lock(mClientsMutex);
mClients.erase(Client);
}
}