mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
vcmi: remove vector speciality format
It is deprecated and will not be used anymore.
This commit is contained in:
parent
96c40eb36e
commit
d9496dd9f7
@ -120,48 +120,24 @@
|
||||
"additionalItems" : true
|
||||
},
|
||||
"specialty": {
|
||||
"anyOf" : [
|
||||
{
|
||||
"type":"array",
|
||||
"description": "Description of hero specialty using bonus system (deprecated)",
|
||||
"items": {
|
||||
"type" : "object",
|
||||
"additionalProperties" : false,
|
||||
"required" : [ "bonuses" ],
|
||||
"properties" : {
|
||||
"growsWithLevel" : {
|
||||
"type" : "boolean",
|
||||
"description" : "Specialty growth with level. Deprecated, use bonuses with updaters instead."
|
||||
},
|
||||
"bonuses" : {
|
||||
"type" : "array",
|
||||
"description" : "List of bonuses",
|
||||
"items" : { "$ref" : "bonus.json" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "object",
|
||||
"description": "Description of hero specialty using bonus system",
|
||||
"additionalProperties" : false,
|
||||
"properties" : {
|
||||
"base" : {
|
||||
"type" : "object",
|
||||
"description": "Description of hero specialty using bonus system",
|
||||
"additionalProperties" : false,
|
||||
"properties" : {
|
||||
"base" : {
|
||||
"type" : "object",
|
||||
"description" : "Will be merged with all bonuses."
|
||||
},
|
||||
"bonuses" : {
|
||||
"type" : "object",
|
||||
"description" : "Set of bonuses",
|
||||
"additionalProperties" : { "$ref" : "bonus.json" }
|
||||
},
|
||||
"creature" : {
|
||||
"type" : "string",
|
||||
"description" : "Name of base creature to grant standard specialty to."
|
||||
}
|
||||
}
|
||||
"description" : "Will be merged with all bonuses."
|
||||
},
|
||||
"bonuses" : {
|
||||
"type" : "object",
|
||||
"description" : "Set of bonuses",
|
||||
"additionalProperties" : { "$ref" : "bonus.json" }
|
||||
},
|
||||
"creature" : {
|
||||
"type" : "string",
|
||||
"description" : "Name of base creature to grant standard specialty to."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"spellbook": {
|
||||
"type":"array",
|
||||
|
@ -677,58 +677,6 @@ std::vector<std::shared_ptr<Bonus>> SpecialtyInfoToBonuses(const SSpecialtyInfo
|
||||
return result;
|
||||
}
|
||||
|
||||
// convert deprecated format
|
||||
std::vector<std::shared_ptr<Bonus>> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec, int sid)
|
||||
{
|
||||
std::vector<std::shared_ptr<Bonus>> result;
|
||||
for(std::shared_ptr<Bonus> oldBonus : spec.bonuses)
|
||||
{
|
||||
oldBonus->sid = sid;
|
||||
if(oldBonus->type == Bonus::SPECIAL_SPELL_LEV || oldBonus->type == Bonus::SPECIAL_BLESS_DAMAGE)
|
||||
{
|
||||
// these bonuses used to auto-scale with hero level
|
||||
std::shared_ptr<Bonus> newBonus = std::make_shared<Bonus>(*oldBonus);
|
||||
newBonus->updater = std::make_shared<TimesHeroLevelUpdater>();
|
||||
result.push_back(newBonus);
|
||||
}
|
||||
else if(spec.growsWithLevel)
|
||||
{
|
||||
std::shared_ptr<Bonus> newBonus = std::make_shared<Bonus>(*oldBonus);
|
||||
switch(newBonus->type)
|
||||
{
|
||||
case Bonus::SECONDARY_SKILL_PREMY:
|
||||
break; // ignore - used to be overwritten based on SPECIAL_SECONDARY_SKILL
|
||||
case Bonus::SPECIAL_SECONDARY_SKILL:
|
||||
newBonus->type = Bonus::SECONDARY_SKILL_PREMY;
|
||||
newBonus->updater = std::make_shared<TimesHeroLevelUpdater>();
|
||||
result.push_back(newBonus);
|
||||
break;
|
||||
case Bonus::PRIMARY_SKILL:
|
||||
if((newBonus->subtype == PrimarySkill::ATTACK || newBonus->subtype == PrimarySkill::DEFENSE) && newBonus->limiter)
|
||||
{
|
||||
std::shared_ptr<CCreatureTypeLimiter> creatureLimiter = std::dynamic_pointer_cast<CCreatureTypeLimiter>(newBonus->limiter);
|
||||
if(creatureLimiter)
|
||||
{
|
||||
const CCreature * cre = creatureLimiter->creature;
|
||||
int creStat = newBonus->subtype == PrimarySkill::ATTACK ? cre->getAttack(false) : cre->getDefense(false);
|
||||
int creLevel = cre->level ? cre->level : 5;
|
||||
newBonus->updater = std::make_shared<GrowsWithLevelUpdater>(creStat, creLevel);
|
||||
}
|
||||
result.push_back(newBonus);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result.push_back(newBonus);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.push_back(oldBonus);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CHeroHandler::beforeValidate(JsonNode & object)
|
||||
{
|
||||
//handle "base" specialty info
|
||||
@ -781,19 +729,7 @@ void CHeroHandler::loadHeroSpecialty(CHero * hero, const JsonNode & node)
|
||||
}
|
||||
//new(er) format, using bonus system
|
||||
const JsonNode & specialtyNode = node["specialty"];
|
||||
if(specialtyNode.getType() == JsonNode::JsonType::DATA_VECTOR)
|
||||
{
|
||||
//deprecated middle-aged format
|
||||
for(const JsonNode & specialty : node["specialty"].Vector())
|
||||
{
|
||||
SSpecialtyBonus hs;
|
||||
hs.growsWithLevel = specialty["growsWithLevel"].Bool();
|
||||
for (const JsonNode & bonus : specialty["bonuses"].Vector())
|
||||
hs.bonuses.push_back(prepSpec(JsonUtils::parseBonus(bonus)));
|
||||
hero->specialtyDeprecated.push_back(hs);
|
||||
}
|
||||
}
|
||||
else if(specialtyNode.getType() == JsonNode::JsonType::DATA_STRUCT)
|
||||
if(specialtyNode.getType() == JsonNode::JsonType::DATA_STRUCT)
|
||||
{
|
||||
//creature specialty - alias for simplicity
|
||||
if(!specialtyNode["creature"].isNull())
|
||||
@ -813,6 +749,8 @@ void CHeroHandler::loadHeroSpecialty(CHero * hero, const JsonNode & node)
|
||||
hero->specialty.push_back(prepSpec(JsonUtils::parseBonus(keyValue.second)));
|
||||
}
|
||||
}
|
||||
else
|
||||
logMod->error("Unsupported speciality format for hero %s!", hero->getNameTranslated());
|
||||
}
|
||||
|
||||
void CHeroHandler::loadExperience()
|
||||
@ -954,7 +892,7 @@ void CHeroHandler::afterLoadFinalization()
|
||||
bonus->sid = hero->getIndex();
|
||||
}
|
||||
|
||||
if(hero->specDeprecated.size() > 0 || hero->specialtyDeprecated.size() > 0)
|
||||
if(hero->specDeprecated.size() > 0)
|
||||
{
|
||||
logMod->debug("Converting specialty format for hero %s(%s)", hero->getNameTranslated(), FactionID::encode(hero->heroClass->faction));
|
||||
std::vector<std::shared_ptr<Bonus>> convertedBonuses;
|
||||
@ -963,13 +901,7 @@ void CHeroHandler::afterLoadFinalization()
|
||||
for(std::shared_ptr<Bonus> b : SpecialtyInfoToBonuses(spec, hero->ID.getNum()))
|
||||
convertedBonuses.push_back(b);
|
||||
}
|
||||
for(const SSpecialtyBonus & spec : hero->specialtyDeprecated)
|
||||
{
|
||||
for(std::shared_ptr<Bonus> b : SpecialtyBonusToBonuses(spec, hero->ID.getNum()))
|
||||
convertedBonuses.push_back(b);
|
||||
}
|
||||
hero->specDeprecated.clear();
|
||||
hero->specialtyDeprecated.clear();
|
||||
// store and create json for logging
|
||||
std::vector<JsonNode> specVec;
|
||||
std::vector<std::string> specNames;
|
||||
|
@ -44,18 +44,6 @@ struct SSpecialtyInfo
|
||||
}
|
||||
};
|
||||
|
||||
struct SSpecialtyBonus
|
||||
/// temporary hold
|
||||
{
|
||||
ui8 growsWithLevel;
|
||||
BonusList bonuses;
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & growsWithLevel;
|
||||
h & bonuses;
|
||||
}
|
||||
};
|
||||
|
||||
class DLL_LINKAGE CHero : public HeroType
|
||||
{
|
||||
friend class CHeroHandler;
|
||||
@ -85,7 +73,6 @@ public:
|
||||
CHeroClass * heroClass;
|
||||
std::vector<std::pair<SecondarySkill, ui8> > secSkillsInit; //initial secondary skills; first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert)
|
||||
std::vector<SSpecialtyInfo> specDeprecated;
|
||||
std::vector<SSpecialtyBonus> specialtyDeprecated;
|
||||
BonusList specialty;
|
||||
std::set<SpellID> spells;
|
||||
bool haveSpellBook;
|
||||
@ -147,7 +134,6 @@ public:
|
||||
|
||||
// convert deprecated format
|
||||
std::vector<std::shared_ptr<Bonus>> SpecialtyInfoToBonuses(const SSpecialtyInfo & spec, int sid = 0);
|
||||
std::vector<std::shared_ptr<Bonus>> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec, int sid = 0);
|
||||
|
||||
class DLL_LINKAGE CHeroClass : public HeroClass
|
||||
{
|
||||
|
@ -509,10 +509,6 @@ void CGHeroInstance::initObj(CRandomGenerator & rand)
|
||||
//copy active (probably growing) bonuses from hero prototype to hero object
|
||||
for(const std::shared_ptr<Bonus> & b : type->specialty)
|
||||
addNewBonus(b);
|
||||
//dito for old-style bonuses -> compatibility for old savegames
|
||||
for(SSpecialtyBonus & sb : type->specialtyDeprecated)
|
||||
for(const std::shared_ptr<Bonus> & b : sb.bonuses)
|
||||
addNewBonus(b);
|
||||
for(SSpecialtyInfo & spec : type->specDeprecated)
|
||||
for(const std::shared_ptr<Bonus> & b : SpecialtyInfoToBonuses(spec, type->getIndex()))
|
||||
addNewBonus(b);
|
||||
|
Loading…
x
Reference in New Issue
Block a user