mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Fix regressions from timers - client may be destroyed while receiving
timer update or pack reply
This commit is contained in:
@@ -50,6 +50,7 @@
|
|||||||
#include "../lib/registerTypes/RegisterTypesLobbyPacks.h"
|
#include "../lib/registerTypes/RegisterTypesLobbyPacks.h"
|
||||||
#include "../lib/serializer/Connection.h"
|
#include "../lib/serializer/Connection.h"
|
||||||
#include "../lib/serializer/CMemorySerializer.h"
|
#include "../lib/serializer/CMemorySerializer.h"
|
||||||
|
#include "../lib/UnlockGuard.h"
|
||||||
|
|
||||||
#include <boost/uuid/uuid.hpp>
|
#include <boost/uuid/uuid.hpp>
|
||||||
#include <boost/uuid/uuid_io.hpp>
|
#include <boost/uuid/uuid_io.hpp>
|
||||||
@@ -417,8 +418,12 @@ void CServerHandler::sendClientDisconnecting()
|
|||||||
}
|
}
|
||||||
sendLobbyPack(lcd);
|
sendLobbyPack(lcd);
|
||||||
|
|
||||||
|
{
|
||||||
|
// Network thread might be applying network pack at this moment
|
||||||
|
auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex);
|
||||||
c->close();
|
c->close();
|
||||||
c.reset();
|
c.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerHandler::setCampaignState(std::shared_ptr<CampaignState> newCampaign)
|
void CServerHandler::setCampaignState(std::shared_ptr<CampaignState> newCampaign)
|
||||||
@@ -665,9 +670,6 @@ void CServerHandler::startGameplay(VCMI_LIB_WRAP_NAMESPACE(CGameState) * gameSta
|
|||||||
|
|
||||||
void CServerHandler::endGameplay(bool closeConnection, bool restart)
|
void CServerHandler::endGameplay(bool closeConnection, bool restart)
|
||||||
{
|
{
|
||||||
client->endGame();
|
|
||||||
vstd::clear_pointer(client);
|
|
||||||
|
|
||||||
if(closeConnection)
|
if(closeConnection)
|
||||||
{
|
{
|
||||||
// Game is ending
|
// Game is ending
|
||||||
@@ -675,6 +677,10 @@ void CServerHandler::endGameplay(bool closeConnection, bool restart)
|
|||||||
CSH->sendClientDisconnecting();
|
CSH->sendClientDisconnecting();
|
||||||
logNetwork->info("Closed connection.");
|
logNetwork->info("Closed connection.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client->endGame();
|
||||||
|
vstd::clear_pointer(client);
|
||||||
|
|
||||||
if(!restart)
|
if(!restart)
|
||||||
{
|
{
|
||||||
if(CMM)
|
if(CMM)
|
||||||
|
Reference in New Issue
Block a user