Forráskód Böngészése

* fixed #1199
* fixed advancing between misisons in campaigns

Michał W. Urbańczyk 12 éve
szülő
commit
17755caa10

+ 1 - 2
client/CMT.cpp

@@ -828,8 +828,7 @@ static void listenForEvents()
 // 					else
 // 					else
 					{
 					{
 						endGame();
 						endGame();
-						CGPreGame::create();
-						GH.curInt = CGP;
+						GH.curInt = CGPreGame::create();;
 						GH.defActionsDef = 63;
 						GH.defActionsDef = 63;
 					}
 					}
 				}
 				}

+ 2 - 1
client/CPlayerInterface.cpp

@@ -74,6 +74,7 @@ void processCommand(const std::string &message, CClient *&client);
 extern std::queue<SDL_Event> events;
 extern std::queue<SDL_Event> events;
 extern boost::mutex eventsM;
 extern boost::mutex eventsM;
 boost::recursive_mutex * CPlayerInterface::pim = new boost::recursive_mutex;
 boost::recursive_mutex * CPlayerInterface::pim = new boost::recursive_mutex;
+CondSh<bool> CPlayerInterface::terminate_cond;
 
 
 CPlayerInterface * LOCPLINT;
 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
 	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::this_thread::sleep(boost::posix_time::milliseconds(15));
 
 
+	boost::unique_lock<boost::recursive_mutex> un(*pim, boost::adopt_lock); //create lock from already owned mutex
 	if(terminate_cond.get())
 	if(terminate_cond.get())
 		return;
 		return;
 
 
-	boost::unique_lock<boost::recursive_mutex> 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
 	//make sure that gamestate won't change when GUI objects may obtain its parts on event processing or drawing request
 	boost::shared_lock<boost::shared_mutex> gsLock(cb->getGsMutex());
 	boost::shared_lock<boost::shared_mutex> gsLock(cb->getGsMutex());
 
 

+ 1 - 1
client/CPlayerInterface.h

@@ -245,7 +245,7 @@ public:
 	CPlayerInterface(int Player);//c-tor
 	CPlayerInterface(int Player);//c-tor
 	~CPlayerInterface();//d-tor
 	~CPlayerInterface();//d-tor
 
 
-	CondSh<bool> terminate_cond; // confirm termination
+	static CondSh<bool> terminate_cond; // confirm termination
 
 
 	//////////////////////////////////////////////////////////////////////////
 	//////////////////////////////////////////////////////////////////////////
 
 

+ 2 - 0
client/CPreGame.cpp

@@ -472,6 +472,8 @@ CGPreGame::CGPreGame():
 CGPreGame::~CGPreGame()
 CGPreGame::~CGPreGame()
 {
 {
 	disposeGraphics();
 	disposeGraphics();
+	if(CGP == this)
+		CGP = nullptr;
 }
 }
 
 
 void CGPreGame::openSel(CMenuScreen::EState screenType, CMenuScreen::EMultiMode multi /*= CMenuScreen::SINGLE_PLAYER*/)
 void CGPreGame::openSel(CMenuScreen::EState screenType, CMenuScreen::EMultiMode multi /*= CMenuScreen::SINGLE_PLAYER*/)

+ 8 - 6
client/CVideoHandler.cpp

@@ -406,11 +406,6 @@ CVideoPlayer::~CVideoPlayer()
 
 
 bool CVideoPlayer::open(std::string name)
 bool CVideoPlayer::open(std::string name)
 {
 {
-	if(boost::algorithm::ends_with(name, ".BIK"))
-		current = &bikPlayer;
-	else
-		current = &smkPlayer;
-
 	fname = name;
 	fname = name;
 	first = true;
 	first = true;
 
 
@@ -419,8 +414,15 @@ bool CVideoPlayer::open(std::string name)
 		// Extract video from video.vid so we can play it.
 		// Extract video from video.vid so we can play it.
 		// We can handle only videos in form of single file, no archive support yet.
 		// 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<char[]> data = unique_ptr<char[]>(new char[myVideo->getSize()]);
 			unique_ptr<char[]> data = unique_ptr<char[]>(new char[myVideo->getSize()]);
 			myVideo->read((ui8*)data.get(), myVideo->getSize());
 			myVideo->read((ui8*)data.get(), myVideo->getSize());
 
 

+ 1 - 1
client/Client.cpp

@@ -531,7 +531,7 @@ void CClient::proposeNextMission(shared_ptr<CCampaignState> camp)
 	endGame(false);
 	endGame(false);
 	LOCPLINT = nullptr; //TODO free res
 	LOCPLINT = nullptr; //TODO free res
 	GH.pushInt(new CBonusSelection(camp));
 	GH.pushInt(new CBonusSelection(camp));
-	GH.curInt = CGP;
+	GH.curInt = CGPreGame::create();
 }
 }
 
 
 void CClient::stopConnection()
 void CClient::stopConnection()