diff --git a/lib/mapObjectConstructors/CRewardableConstructor.cpp b/lib/mapObjectConstructors/CRewardableConstructor.cpp index 8d3bec191..ad87c06fe 100644 --- a/lib/mapObjectConstructors/CRewardableConstructor.cpp +++ b/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()); diff --git a/lib/mapObjects/CGTownBuilding.cpp b/lib/mapObjects/CGTownBuilding.cpp index 098b519d5..0a8f952a6 100644 --- a/lib/mapObjects/CGTownBuilding.cpp +++ b/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); } } } diff --git a/lib/mapping/MapFormatH3M.cpp b/lib/mapping/MapFormatH3M.cpp index 58c181178..5c95fffae 100644 --- a/lib/mapping/MapFormatH3M.cpp +++ b/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) diff --git a/lib/rewardable/Reward.cpp b/lib/rewardable/Reward.cpp index 186f4ba16..07da516cd 100644 --- a/lib/rewardable/Reward.cpp +++ b/lib/rewardable/Reward.cpp @@ -61,7 +61,15 @@ void Rewardable::Reward::loadComponents(std::vector & 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(h->calculateXp(heroExperience)), 0);