1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00

Fixes randomization of Witch Hut preconfigured in map editor

This commit is contained in:
Ivan Savenko 2024-10-03 12:35:15 +00:00
parent f5c2772f8d
commit 5d64da9b6c
3 changed files with 5 additions and 4 deletions

View File

@ -43,9 +43,10 @@ CGObjectInstance * CRewardableConstructor::create(IGameCallback * cb, std::share
return ret;
}
Rewardable::Configuration CRewardableConstructor::generateConfiguration(IGameCallback * cb, vstd::RNG & rand, MapObjectID objectID) const
Rewardable::Configuration CRewardableConstructor::generateConfiguration(IGameCallback * cb, vstd::RNG & rand, MapObjectID objectID, const std::map<std::string, JsonNode> & presetVariables) const
{
Rewardable::Configuration result;
result.variables.preset = presetVariables;
objectInfo.configureObject(result, rand, cb);
for(auto & rewardInfo : result.info)
@ -67,7 +68,7 @@ void CRewardableConstructor::configureObject(CGObjectInstance * object, vstd::RN
if (!rewardableObject)
throw std::runtime_error("Object " + std::to_string(object->getObjGroupIndex()) + ", " + std::to_string(object->getObjTypeIndex()) + " is not a rewardable object!" );
rewardableObject->configuration = generateConfiguration(object->cb, rng, object->ID);
rewardableObject->configuration = generateConfiguration(object->cb, rng, object->ID, rewardableObject->configuration.variables.preset);
rewardableObject->initializeGuards();
if (rewardableObject->configuration.info.empty())

View File

@ -31,7 +31,7 @@ public:
std::unique_ptr<IObjectInfo> getObjectInfo(std::shared_ptr<const ObjectTemplate> tmpl) const override;
Rewardable::Configuration generateConfiguration(IGameCallback * cb, vstd::RNG & rand, MapObjectID objectID) const;
Rewardable::Configuration generateConfiguration(IGameCallback * cb, vstd::RNG & rand, MapObjectID objectID, const std::map<std::string, JsonNode> & presetVariables) const;
};
VCMI_LIB_NAMESPACE_END

View File

@ -329,7 +329,7 @@ void CRewardableObject::newTurn(vstd::RNG & rand) const
if (configuration.resetParameters.rewards)
{
auto handler = std::dynamic_pointer_cast<const CRewardableConstructor>(getObjectHandler());
auto newConfiguration = handler->generateConfiguration(cb, rand, ID);
auto newConfiguration = handler->generateConfiguration(cb, rand, ID, configuration.variables.preset);
cb->setRewardableObjectConfiguration(id, newConfiguration);
}
if (configuration.resetParameters.visitors)