Browse Source

* MSVC compilation fixes
* campaign epilogues and minor fixes

mateuszb 12 years ago
parent
commit
602827d1ae

+ 2 - 2
client/CPreGame.cpp

@@ -4101,9 +4101,9 @@ CPrologEpilogVideo::CPrologEpilogVideo( CCampaignScenario::SScenarioPrologEpilog
 
 	auto lines = CMessage::breakText(spe.prologText, 500, EFonts::FONT_BIG);
 
-	txt = CSDL_Ext::newSurface(500, 20 * lines.size() + 5);
+	txt = CSDL_Ext::newSurface(500, 20 * lines.size() + 10);
 	curTxtH = screen->h;
-	graphics->fonts[FONT_BIG]->renderTextLinesCenter(txt, lines, Colors::METALLIC_GOLD, Point(txt->w/2, txt->h/2));
+	graphics->fonts[FONT_BIG]->renderTextLinesCenter(txt, lines, Colors::METALLIC_GOLD, Point(txt->w/2, txt->h/2 + 5));
 	//SDL_SaveBMP(txt, "txtsrfc.bmp");
 }
 

+ 24 - 3
client/Client.cpp

@@ -524,10 +524,7 @@ void CClient::finishCampaign( shared_ptr<CCampaignState> camp )
 
 void CClient::proposeNextMission(shared_ptr<CCampaignState> camp)
 {
-	endGame(false);
-	LOCPLINT = nullptr; //TODO free res
 	GH.pushInt(new CBonusSelection(camp));
-	GH.curInt = CGPreGame::create();
 }
 
 void CClient::stopConnection()
@@ -679,6 +676,30 @@ int CClient::sendRequest(const CPack *request, TPlayerColor player)
 	return requestID;
 }
 
+void CClient::campaignMapFinished( shared_ptr<CCampaignState> camp )
+{
+	endGame(false);
+	LOCPLINT = nullptr; //TODO free res
+
+	GH.curInt = CGPreGame::create();
+	auto & epilogue = camp->camp->scenarios[camp->mapsConquered.back()].epilog;
+	auto finisher = [&]()
+	{
+		if(camp->mapsRemaining.size())
+			proposeNextMission(camp);
+		else
+			finishCampaign(camp);
+	};
+	if(epilogue.hasPrologEpilog)
+	{
+		GH.pushInt(new CPrologEpilogVideo(epilogue, finisher));
+	}
+	else
+	{
+		finisher();
+	}
+}
+
 template void CClient::serialize( CISer<CLoadFile> &h, const int version );
 template void CClient::serialize( COSer<CSaveFile> &h, const int version );
 

+ 1 - 0
client/Client.h

@@ -148,6 +148,7 @@ public:
 	void save(const std::string & fname);
 	void loadGame(const std::string & fname);
 	void run();
+	void campaignMapFinished( shared_ptr<CCampaignState> camp );
 	void finishCampaign( shared_ptr<CCampaignState> camp );
 	void proposeNextMission(shared_ptr<CCampaignState> camp);
 	void invalidatePaths(const CGHeroInstance *h = NULL); //invalidates paths for hero h or for any hero if h is NULL => they'll got recalculated when the next query comes

+ 1 - 4
client/NetPacksClient.cpp

@@ -311,10 +311,7 @@ void RemoveBonus::applyCl( CClient *cl )
 void UpdateCampaignState::applyCl( CClient *cl )
 {
 	cl->stopConnection();
-	if(camp->mapsRemaining.size())
-		cl->proposeNextMission(camp);
-	else
-		cl->finishCampaign(camp);
+	cl->campaignMapFinished(camp);
 }
 
 void PrepareForAdvancingCampaign::applyCl(CClient *cl)

+ 2 - 1
lib/Mapping/CCampaignHandler.cpp

@@ -464,7 +464,8 @@ CCampaignState::CCampaignState( unique_ptr<CCampaign> _camp ) : camp(std::move(_
 {
 	for(int i = 0; i < camp->scenarios.size(); i++)
 	{
-		mapsRemaining.push_back(i);
+		if(vstd::contains(camp->mapPieces, i)) //not all maps must be present in a campaign
+			mapsRemaining.push_back(i);
 	}
 }
 

+ 1 - 0
lib/RegisterTypes.cpp

@@ -1,4 +1,5 @@
 #include "StdInc.h"
+#define DO_NOT_DISABLE_REGISTER_TYPES_INSTANTIATION
 #include "RegisterTypes.h"
 
 #include "Mapping/CMapInfo.h"

+ 4 - 1
lib/RegisterTypes.h

@@ -264,9 +264,12 @@ void registerTypes(Serializer &s)
 	registerTypes4(s);
 }
 
+#ifndef DO_NOT_DISABLE_REGISTER_TYPES_INSTANTIATION
 extern template DLL_LINKAGE void registerTypes<CISer<CConnection>>(CISer<CConnection>& s);
 extern template DLL_LINKAGE void registerTypes<COSer<CConnection>>(COSer<CConnection>& s);
 extern template DLL_LINKAGE void registerTypes<CSaveFile>(CSaveFile & s);
 extern template DLL_LINKAGE void registerTypes<CLoadFile>(CLoadFile & s);
 extern template DLL_LINKAGE void registerTypes<CTypeList>(CTypeList & s);
-extern template DLL_LINKAGE void registerTypes<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);
+extern template DLL_LINKAGE void registerTypes<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);
+#endif
+

+ 1 - 0
lib/VCMI_lib.vcxproj

@@ -200,6 +200,7 @@
     <ClCompile Include="Mapping\CMapService.cpp" />
     <ClCompile Include="Mapping\CMapEditManager.cpp" />
     <ClCompile Include="Mapping\MapFormatH3M.cpp" />
+    <ClCompile Include="RegisterTypes.cpp" />
     <ClCompile Include="RMG\CMapGenOptions.cpp" />
     <ClCompile Include="RMG\CMapGenerator.cpp" />
     <ClCompile Include="HeroBonus.cpp" />