From 17755caa108c5e697cefafa02d4a91dcd3f2a25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Tue, 5 Feb 2013 20:06:13 +0000 Subject: [PATCH] * fixed #1199 * fixed advancing between misisons in campaigns --- client/CMT.cpp | 3 +-- client/CPlayerInterface.cpp | 3 ++- client/CPlayerInterface.h | 2 +- client/CPreGame.cpp | 2 ++ client/CVideoHandler.cpp | 14 ++++++++------ client/Client.cpp | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/client/CMT.cpp b/client/CMT.cpp index 341f15058..3f26851cc 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -828,8 +828,7 @@ static void listenForEvents() // else { endGame(); - CGPreGame::create(); - GH.curInt = CGP; + GH.curInt = CGPreGame::create();; GH.defActionsDef = 63; } } diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 6122cc46e..cab21736e 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -74,6 +74,7 @@ void processCommand(const std::string &message, CClient *&client); extern std::queue events; extern boost::mutex eventsM; boost::recursive_mutex * CPlayerInterface::pim = new boost::recursive_mutex; +CondSh CPlayerInterface::terminate_cond; CPlayerInterface * LOCPLINT; @@ -1539,10 +1540,10 @@ void CPlayerInterface::update() while(!terminate_cond.get() && !pim->try_lock()) //try acquiring long until it succeeds or we are told to terminate boost::this_thread::sleep(boost::posix_time::milliseconds(15)); + boost::unique_lock un(*pim, boost::adopt_lock); //create lock from already owned mutex if(terminate_cond.get()) return; - boost::unique_lock un(*pim, boost::adopt_lock); //create lock from already owned mutex //make sure that gamestate won't change when GUI objects may obtain its parts on event processing or drawing request boost::shared_lock gsLock(cb->getGsMutex()); diff --git a/client/CPlayerInterface.h b/client/CPlayerInterface.h index 423bc89b7..5d9f4ff87 100644 --- a/client/CPlayerInterface.h +++ b/client/CPlayerInterface.h @@ -245,7 +245,7 @@ public: CPlayerInterface(int Player);//c-tor ~CPlayerInterface();//d-tor - CondSh terminate_cond; // confirm termination + static CondSh terminate_cond; // confirm termination ////////////////////////////////////////////////////////////////////////// diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index 6ff8bc0f9..66ca19084 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -472,6 +472,8 @@ CGPreGame::CGPreGame(): CGPreGame::~CGPreGame() { disposeGraphics(); + if(CGP == this) + CGP = nullptr; } void CGPreGame::openSel(CMenuScreen::EState screenType, CMenuScreen::EMultiMode multi /*= CMenuScreen::SINGLE_PLAYER*/) diff --git a/client/CVideoHandler.cpp b/client/CVideoHandler.cpp index 1809bacaa..17766eaa2 100644 --- a/client/CVideoHandler.cpp +++ b/client/CVideoHandler.cpp @@ -406,11 +406,6 @@ CVideoPlayer::~CVideoPlayer() bool CVideoPlayer::open(std::string name) { - if(boost::algorithm::ends_with(name, ".BIK")) - current = &bikPlayer; - else - current = &smkPlayer; - fname = name; first = true; @@ -419,8 +414,15 @@ bool CVideoPlayer::open(std::string name) // Extract video from video.vid so we can play it. // We can handle only videos in form of single file, no archive support yet. { - auto myVideo = CResourceHandler::get()->load(ResourceID("VIDEO/" + name, EResType::VIDEO)); + ResourceID videoID = ResourceID("VIDEO/" + name, EResType::VIDEO); + std::string realVideoFilename = CResourceHandler::get()->getResourceName(videoID); + if(boost::algorithm::iends_with(realVideoFilename, ".BIK")) + current = &bikPlayer; + else + current = &smkPlayer; + + auto myVideo = CResourceHandler::get()->load(videoID); unique_ptr data = unique_ptr(new char[myVideo->getSize()]); myVideo->read((ui8*)data.get(), myVideo->getSize()); diff --git a/client/Client.cpp b/client/Client.cpp index 786eed715..54b931245 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -531,7 +531,7 @@ void CClient::proposeNextMission(shared_ptr camp) endGame(false); LOCPLINT = nullptr; //TODO free res GH.pushInt(new CBonusSelection(camp)); - GH.curInt = CGP; + GH.curInt = CGPreGame::create(); } void CClient::stopConnection()