mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-10-25 13:30:43 +00:00
fix hang and crash caused by client kick
This commit is contained in:
1 parent
2cf27ad837
commit
57a58b1a38
2 files changed
+2
-2
No files matched your search
+1
-1
@@ -25,7 +25,7 @@ void TClient::ClearCars() {
|
|||||||
std::unique_lock lock(mVehicleDataMutex);
|
std::unique_lock lock(mVehicleDataMutex);
|
||||||
for (const auto& Car : mVehicleData) {
|
for (const auto& Car : mVehicleData) {
|
||||||
std::string Destroy = "Od:" + std::to_string(GetID()) + "-" + std::to_string(Car.ID());
|
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();
|
mVehicleData.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -192,9 +192,9 @@ void TServer::RemoveClient(const std::weak_ptr<TClient>& WeakClientPtr) {
|
|||||||
|
|
||||||
void TServer::RemoveClientById(int Id) {
|
void TServer::RemoveClientById(int Id) {
|
||||||
auto Client = GetClient(*this, Id);
|
auto Client = GetClient(*this, Id);
|
||||||
WriteLock Lock(mClientsMutex);
|
|
||||||
if (Client) {
|
if (Client) {
|
||||||
Client->ClearCars();
|
Client->ClearCars();
|
||||||
|
WriteLock Lock(mClientsMutex);
|
||||||
mClients.erase(Client);
|
mClients.erase(Client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user