Bläddra i källkod

fix regressions from modernization

Ivan Savenko 2 år sedan
förälder
incheckning
f65c6ad275

+ 2 - 2
lib/CArtHandler.cpp

@@ -419,8 +419,8 @@ ArtifactPosition::ArtifactPosition(std::string slotName):
 	auto it = artifactPositionMap.find (slotName);
 	if (it != artifactPositionMap.end())
 		num = it->second;
-
-	logMod->warn("Warning! Artifact slot %s not recognized!", slotName);
+	else
+		logMod->warn("Warning! Artifact slot %s not recognized!", slotName);
 }
 
 void CArtHandler::addSlot(CArtifact * art, const std::string & slotID)

+ 3 - 3
lib/mapObjects/CGHeroInstance.cpp

@@ -243,7 +243,7 @@ CGHeroInstance::CGHeroInstance():
 	movement(UNINITIALIZED_MOVEMENT),
 	portrait(UNINITIALIZED_PORTRAIT),
 	level(1),
-	exp(std::numeric_limits<TExpType>::max()),
+	exp(UNINITIALIZED_EXPERIENCE),
 	sex(std::numeric_limits<ui8>::max())
 {
 	setNodeType(HERO);
@@ -320,7 +320,7 @@ void CGHeroInstance::initHero(CRandomGenerator & rand)
 	if (patrol.patrolling)
 		patrol.initialPos = visitablePos();
 
-	if(exp == 0xffffffff)
+	if(exp == UNINITIALIZED_EXPERIENCE)
 	{
 		initExp(rand);
 	}
@@ -1445,7 +1445,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
 	handler.serializeString("biography", biographyCustom);
 	handler.serializeInt("experience", exp, 0);
 
-	if(!handler.saving && exp != 0xffffffff) //do not gain levels if experience is not initialized
+	if(!handler.saving && exp != UNINITIALIZED_EXPERIENCE) //do not gain levels if experience is not initialized
 	{
 		while (gainsLevel())
 		{

+ 1 - 0
lib/mapObjects/CGHeroInstance.h

@@ -82,6 +82,7 @@ public:
 	static constexpr si32 UNINITIALIZED_PORTRAIT = -1;
 	static constexpr si32 UNINITIALIZED_MANA = -1;
 	static constexpr ui32 UNINITIALIZED_MOVEMENT = -1;
+	static constexpr TExpType UNINITIALIZED_EXPERIENCE = std::numeric_limits<TExpType>::max();
 
 	//std::vector<const CArtifact*> artifacts; //hero's artifacts from bag
 	//std::map<ui16, const CArtifact*> artifWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5

+ 5 - 0
lib/mapObjects/CGTownInstance.cpp

@@ -82,6 +82,11 @@ void CCreGenLeveledCastleInfo::serializeJson(JsonSerializeFormat & handler)
 	CCreGenLeveledInfo::serializeJson(handler);
 }
 
+CGDwelling::CGDwelling()
+	: info(nullptr)
+{
+}
+
 CGDwelling::~CGDwelling()
 {
 	vstd::clear_pointer(info);

+ 1 - 0
lib/mapObjects/CGTownInstance.h

@@ -68,6 +68,7 @@ public:
 	CSpecObjInfo * info; //random dwelling options; not serialized
 	TCreaturesSet creatures; //creatures[level] -> <vector of alternative ids (base creature and upgrades, creatures amount>
 
+	CGDwelling();
 	~CGDwelling() override;
 
 	void initRandomObjectInfo();

+ 2 - 2
lib/mapping/MapFormatH3M.cpp

@@ -1609,7 +1609,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(const ObjectInstanceID & idToBeGiven,
 		}
 		else
 		{
-			nhi->exp = 0xffffffff;
+			nhi->exp = CGHeroInstance::UNINITIALIZED_EXPERIENCE;
 		}
 	}
 	else
@@ -1619,7 +1619,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(const ObjectInstanceID & idToBeGiven,
 		//0 means "not set" in <=AB maps
 		if(!nhi->exp)
 		{
-			nhi->exp = 0xffffffff;
+			nhi->exp = CGHeroInstance::UNINITIALIZED_EXPERIENCE;
 		}
 	}