mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Merge pull request #571 from dydzio0614/VictoryCrashFix
Victory crash/freeze fix
This commit is contained in:
commit
fd2a33bc36
@ -1265,6 +1265,7 @@ static void handleEvent(SDL_Event & ev)
|
|||||||
break;
|
break;
|
||||||
case EUserEvent::CAMPAIGN_START_SCENARIO:
|
case EUserEvent::CAMPAIGN_START_SCENARIO:
|
||||||
{
|
{
|
||||||
|
CSH->campaignServerRestartLock.set(true);
|
||||||
CSH->endGameplay();
|
CSH->endGameplay();
|
||||||
auto ourCampaign = std::shared_ptr<CCampaignState>(reinterpret_cast<CCampaignState *>(ev.user.data1));
|
auto ourCampaign = std::shared_ptr<CCampaignState>(reinterpret_cast<CCampaignState *>(ev.user.data1));
|
||||||
auto & epilogue = ourCampaign->camp->scenarios[ourCampaign->mapsConquered.back()].epilog;
|
auto & epilogue = ourCampaign->camp->scenarios[ourCampaign->mapsConquered.back()].epilog;
|
||||||
@ -1281,6 +1282,7 @@ static void handleEvent(SDL_Event & ev)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
CSH->campaignServerRestartLock.waitUntil(false);
|
||||||
finisher();
|
finisher();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2467,7 +2467,6 @@ void CPlayerInterface::showShipyardDialogOrProblemPopup(const IShipyard *obj)
|
|||||||
|
|
||||||
void CPlayerInterface::requestReturningToMainMenu(bool won)
|
void CPlayerInterface::requestReturningToMainMenu(bool won)
|
||||||
{
|
{
|
||||||
CSH->state = EClientState::DISCONNECTING;
|
|
||||||
CCS->soundh->ambientStopAllChannels();
|
CCS->soundh->ambientStopAllChannels();
|
||||||
if(won && cb->getStartInfo()->campState)
|
if(won && cb->getStartInfo()->campState)
|
||||||
CSH->startCampaignScenario(cb->getStartInfo()->campState);
|
CSH->startCampaignScenario(cb->getStartInfo()->campState);
|
||||||
|
@ -101,7 +101,7 @@ public:
|
|||||||
extern std::string NAME;
|
extern std::string NAME;
|
||||||
|
|
||||||
CServerHandler::CServerHandler()
|
CServerHandler::CServerHandler()
|
||||||
: state(EClientState::NONE), mx(std::make_shared<boost::recursive_mutex>()), client(nullptr), loadMode(0), campaignStateToSend(nullptr)
|
: state(EClientState::NONE), mx(std::make_shared<boost::recursive_mutex>()), client(nullptr), loadMode(0), campaignStateToSend(nullptr), campaignServerRestartLock(false)
|
||||||
{
|
{
|
||||||
uuid = boost::uuids::to_string(boost::uuids::random_generator()());
|
uuid = boost::uuids::to_string(boost::uuids::random_generator()());
|
||||||
applier = std::make_shared<CApplier<CBaseForLobbyApply>>();
|
applier = std::make_shared<CApplier<CBaseForLobbyApply>>();
|
||||||
@ -495,6 +495,7 @@ void CServerHandler::endGameplay(bool closeConnection, bool restart)
|
|||||||
{
|
{
|
||||||
if(CMM)
|
if(CMM)
|
||||||
{
|
{
|
||||||
|
GH.terminate_cond->setn(false);
|
||||||
GH.curInt = CMM.get();
|
GH.curInt = CMM.get();
|
||||||
CMM->enable();
|
CMM->enable();
|
||||||
}
|
}
|
||||||
@ -644,6 +645,7 @@ void CServerHandler::threadHandleConnection()
|
|||||||
logNetwork->error(e.what());
|
logNetwork->error(e.what());
|
||||||
if(client)
|
if(client)
|
||||||
{
|
{
|
||||||
|
state = EClientState::DISCONNECTING;
|
||||||
CGuiHandler::pushSDLEvent(SDL_USEREVENT, EUserEvent::RETURN_TO_MAIN_MENU);
|
CGuiHandler::pushSDLEvent(SDL_USEREVENT, EUserEvent::RETURN_TO_MAIN_MENU);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -690,6 +692,7 @@ void CServerHandler::threadRunServer()
|
|||||||
logNetwork->error("Check %s for more info", logName);
|
logNetwork->error("Check %s for more info", logName);
|
||||||
}
|
}
|
||||||
threadRunLocalServer.reset();
|
threadRunLocalServer.reset();
|
||||||
|
CSH->campaignServerRestartLock.setn(false);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../lib/CStopWatch.h"
|
#include "../lib/CStopWatch.h"
|
||||||
|
|
||||||
#include "../lib/StartInfo.h"
|
#include "../lib/StartInfo.h"
|
||||||
|
#include "../lib/CondSh.h"
|
||||||
|
|
||||||
struct SharedMemory;
|
struct SharedMemory;
|
||||||
class CConnection;
|
class CConnection;
|
||||||
@ -95,6 +96,8 @@ public:
|
|||||||
std::shared_ptr<CConnection> c;
|
std::shared_ptr<CConnection> c;
|
||||||
CClient * client;
|
CClient * client;
|
||||||
|
|
||||||
|
CondSh<bool> campaignServerRestartLock;
|
||||||
|
|
||||||
CServerHandler();
|
CServerHandler();
|
||||||
|
|
||||||
void resetStateForLobby(const StartInfo::EMode mode, const std::vector<std::string> * names = nullptr);
|
void resetStateForLobby(const StartInfo::EMode mode, const std::vector<std::string> * names = nullptr);
|
||||||
|
@ -352,7 +352,7 @@ std::shared_ptr<CMainMenu> CMainMenu::create()
|
|||||||
if(!CMM)
|
if(!CMM)
|
||||||
CMM = std::shared_ptr<CMainMenu>(new CMainMenu());
|
CMM = std::shared_ptr<CMainMenu>(new CMainMenu());
|
||||||
|
|
||||||
GH.terminate_cond->set(false);
|
GH.terminate_cond->setn(false);
|
||||||
return CMM;
|
return CMM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +191,8 @@ void CVCMIServer::run()
|
|||||||
{
|
{
|
||||||
gh->run(si->mode == StartInfo::LOAD_GAME);
|
gh->run(si->mode == StartInfo::LOAD_GAME);
|
||||||
}
|
}
|
||||||
|
while(state == EServerState::GAMEPLAY_ENDED)
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVCMIServer::threadAnnounceLobby()
|
void CVCMIServer::threadAnnounceLobby()
|
||||||
|
Loading…
Reference in New Issue
Block a user