فهرست منبع

Fix components problem

nordsoft 2 سال پیش
والد
کامیت
e3538f24ab

+ 0 - 5
lib/mapObjectConstructors/CRewardableConstructor.cpp

@@ -51,11 +51,6 @@ void CRewardableConstructor::configureObject(CGObjectInstance * object, CRandomG
 			{
 				bonus.source = BonusSource::OBJECT;
 				bonus.sid = rewardableObject->ID;
-				//TODO: bonus.description = object->getObjectName();
-				if (bonus.type == BonusType::MORALE)
-					rewardInfo.reward.extraComponents.emplace_back(Component::EComponentType::MORALE, 0, bonus.val, 0);
-				if (bonus.type == BonusType::LUCK)
-					rewardInfo.reward.extraComponents.emplace_back(Component::EComponentType::LUCK, 0, bonus.val, 0);
 			}
 		}
 		assert(!rewardableObject->configuration.info.empty());

+ 0 - 4
lib/mapObjects/CGTownBuilding.cpp

@@ -307,10 +307,6 @@ void CTownRewardableBuilding::initObj(CRandomGenerator & rand)
 		{
 			bonus.source = BonusSource::TOWN_STRUCTURE;
 			bonus.sid = bID;
-			if (bonus.type == BonusType::MORALE)
-				rewardInfo.reward.extraComponents.emplace_back(Component::EComponentType::MORALE, 0, bonus.val, 0);
-			if (bonus.type == BonusType::LUCK)
-				rewardInfo.reward.extraComponents.emplace_back(Component::EComponentType::LUCK, 0, bonus.val, 0);
 		}
 	}
 }

+ 4 - 2
lib/mapping/MapFormatH3M.cpp

@@ -1024,8 +1024,10 @@ void CMapLoaderH3M::readBoxContent(CGPandoraBox * object, const int3 & mapPositi
 	
 	reward.heroExperience = reader->readUInt32();
 	reward.manaDiff = reader->readInt32();
-	reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, reader->readUInt8(), idToBeGiven);
-	reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, reader->readUInt8(), idToBeGiven);
+	if(auto val = reader->readUInt8())
+		reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, val, idToBeGiven);
+	if(auto val = reader->readUInt8())
+		reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, val, idToBeGiven);
 
 	reader->readResourses(reward.resources);
 	for(int x = 0; x < GameConstants::PRIMARY_SKILLS; ++x)

+ 9 - 1
lib/rewardable/Reward.cpp

@@ -61,7 +61,15 @@ void Rewardable::Reward::loadComponents(std::vector<Component> & comps,
 {
 	for (auto comp : extraComponents)
 		comps.push_back(comp);
-
+	
+	for (auto & bonus : bonuses)
+	{
+		if (bonus.type == BonusType::MORALE)
+			comps.emplace_back(Component::EComponentType::MORALE, 0, bonus.val, 0);
+		if (bonus.type == BonusType::LUCK)
+			comps.emplace_back(Component::EComponentType::LUCK, 0, bonus.val, 0);
+	}
+	
 	if (heroExperience)
 	{
 		comps.emplace_back(Component::EComponentType::EXPERIENCE, 0, static_cast<si32>(h->calculateXp(heroExperience)), 0);