1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Explicitly close sockets when plugin is stopped

This commit is contained in:
Ted John
2020-08-31 20:23:11 +01:00
parent 33ba51b763
commit 858bb4045f

View File

@@ -1165,10 +1165,20 @@ void ScriptEngine::UpdateSockets()
void ScriptEngine::RemoveSockets(const std::shared_ptr<Plugin>& plugin)
{
# ifndef DISABLE_NETWORK
_sockets.erase(
std::remove_if(
_sockets.begin(), _sockets.end(), [&plugin](const auto& socket) { return socket->GetPlugin() == plugin; }),
_sockets.end());
auto it = _sockets.begin();
while (it != _sockets.end())
{
auto socket = it->get();
if (socket->GetPlugin() == plugin)
{
socket->Dispose();
it = _sockets.erase(it);
}
else
{
it++;
}
}
# endif
}