fix #135 by making onPlayerDisconnect blocking, and calling it before removing the player

before, the handlers were not waited for, so the client was usually
destructed before lua got to the actual event handler call. Now, the
handler is called and waited on, and once all handlers are done, the
client is properly removed from the players internally, thus making
calls to GetPlayerName, GetPlayerIdentifiers, etc. return nil etc.
This commit is contained in:
Lion Kortlepel
2022-10-28 17:42:10 +02:00
parent bbd27c9cba
commit 99f41c28cb
3 changed files with 24 additions and 9 deletions

View File

@@ -6,6 +6,7 @@
#include <optional>
void TClient::DeleteCar(int Ident) {
// TODO: Send delete packets
std::unique_lock lock(mVehicleDataMutex);
auto iter = std::find_if(mVehicleData.begin(), mVehicleData.end(), [&](auto& elem) {
return Ident == elem.ID();