Browse Source

Fix campaigns progression

Ivan Savenko 6 months ago
parent
commit
a89cf280e3

+ 3 - 0
lib/gameState/CGameStateCampaign.cpp

@@ -394,6 +394,9 @@ void CGameStateCampaign::transferMissingArtifacts(const CampaignTravel & travelO
 
 	for(auto hero : gameState->map->getObjects<CGHeroInstance>())
 	{
+		if (!hero->getOwner().isValidPlayer())
+			continue; // prisons
+
 		if (gameState->getPlayerState(hero->getOwner())->isHuman())
 		{
 			receiver = hero;

+ 14 - 1
lib/gameState/CGameStateCampaign.h

@@ -68,7 +68,20 @@ public:
 
 	template <typename Handler> void serialize(Handler &h)
 	{
-		// no-op, but needed to auto-create this class if gamestate had it during serialization
+		if (h.saving || h.hasFeature(Handler::Version::NO_RAW_POINTERS_IN_SERIALIZER))
+		{
+			// no-op, but needed to auto-create this class if gamestate had it during serialization
+		}
+		else
+		{
+			bool dummyA = false;
+			uint32_t dummyB = 0;
+			uint16_t dummyC = 0;
+
+			h & dummyA;
+			h & dummyB;
+			h & dummyC;
+		}
 	}
 };
 

+ 5 - 1
lib/mapping/MapFormatH3M.cpp

@@ -2040,7 +2040,11 @@ std::shared_ptr<CGObjectInstance> CMapLoaderH3M::readHero(const int3 & mapPositi
 
 	//If hero of this type has been predefined, use that as a base.
 	//Instance data will overwrite the predefined values where appropriate.
-	auto object = map->tryTakeFromHeroPool(heroType);
+	std::shared_ptr<CGHeroInstance> object;
+
+	if (heroType.hasValue())
+		object = map->tryTakeFromHeroPool(heroType);
+
 	if (!object)
 	{
 		object = std::make_shared<CGHeroInstance>(map->cb);