diff --git a/config/schemas/hero.json b/config/schemas/hero.json index 00715bc34..de587ed06 100644 --- a/config/schemas/hero.json +++ b/config/schemas/hero.json @@ -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", diff --git a/lib/CHeroHandler.cpp b/lib/CHeroHandler.cpp index 3aee1ee62..963745804 100644 --- a/lib/CHeroHandler.cpp +++ b/lib/CHeroHandler.cpp @@ -677,58 +677,6 @@ std::vector> SpecialtyInfoToBonuses(const SSpecialtyInfo return result; } -// convert deprecated format -std::vector> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec, int sid) -{ - std::vector> result; - for(std::shared_ptr 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 newBonus = std::make_shared(*oldBonus); - newBonus->updater = std::make_shared(); - result.push_back(newBonus); - } - else if(spec.growsWithLevel) - { - std::shared_ptr newBonus = std::make_shared(*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(); - result.push_back(newBonus); - break; - case Bonus::PRIMARY_SKILL: - if((newBonus->subtype == PrimarySkill::ATTACK || newBonus->subtype == PrimarySkill::DEFENSE) && newBonus->limiter) - { - std::shared_ptr creatureLimiter = std::dynamic_pointer_cast(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(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> convertedBonuses; @@ -963,13 +901,7 @@ void CHeroHandler::afterLoadFinalization() for(std::shared_ptr b : SpecialtyInfoToBonuses(spec, hero->ID.getNum())) convertedBonuses.push_back(b); } - for(const SSpecialtyBonus & spec : hero->specialtyDeprecated) - { - for(std::shared_ptr b : SpecialtyBonusToBonuses(spec, hero->ID.getNum())) - convertedBonuses.push_back(b); - } hero->specDeprecated.clear(); - hero->specialtyDeprecated.clear(); // store and create json for logging std::vector specVec; std::vector specNames; diff --git a/lib/CHeroHandler.h b/lib/CHeroHandler.h index 7adc27c25..8d97a003a 100644 --- a/lib/CHeroHandler.h +++ b/lib/CHeroHandler.h @@ -44,18 +44,6 @@ struct SSpecialtyInfo } }; -struct SSpecialtyBonus -/// temporary hold -{ - ui8 growsWithLevel; - BonusList bonuses; - template 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 > secSkillsInit; //initial secondary skills; first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert) std::vector specDeprecated; - std::vector specialtyDeprecated; BonusList specialty; std::set spells; bool haveSpellBook; @@ -147,7 +134,6 @@ public: // convert deprecated format std::vector> SpecialtyInfoToBonuses(const SSpecialtyInfo & spec, int sid = 0); -std::vector> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec, int sid = 0); class DLL_LINKAGE CHeroClass : public HeroClass { diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 74972d5a7..5b024e1bb 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -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 & b : type->specialty) addNewBonus(b); - //dito for old-style bonuses -> compatibility for old savegames - for(SSpecialtyBonus & sb : type->specialtyDeprecated) - for(const std::shared_ptr & b : sb.bonuses) - addNewBonus(b); for(SSpecialtyInfo & spec : type->specDeprecated) for(const std::shared_ptr & b : SpecialtyInfoToBonuses(spec, type->getIndex())) addNewBonus(b);