mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-04 14:56:04 +00:00
fix hang and crash caused by client kick
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user