mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
removed specialtyDeprecated from CGHeroInstance; improved savegame compatibility
This commit is contained in:
parent
81c44dac41
commit
6037c19b9a
@ -130,6 +130,7 @@ public:
|
||||
|
||||
// convert deprecated format
|
||||
std::vector<std::shared_ptr<Bonus>> SpecialtyInfoToBonuses(const SSpecialtyInfo & spec, int sid);
|
||||
std::vector<std::shared_ptr<Bonus>> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec);
|
||||
|
||||
class DLL_LINKAGE CHeroClass
|
||||
{
|
||||
|
@ -541,6 +541,23 @@ void CGHeroInstance::recreateSecondarySkillsBonuses()
|
||||
updateSkill(SecondarySkill(skill_info.first), level);
|
||||
}
|
||||
|
||||
void CGHeroInstance::recreateSpecialtyBonuses(std::vector<HeroSpecial*> & specialtyDeprecated)
|
||||
{
|
||||
auto HeroSpecialToSpecialtyBonus = [](HeroSpecial & hs) -> SSpecialtyBonus
|
||||
{
|
||||
SSpecialtyBonus sb;
|
||||
sb.growsWithLevel = hs.growsWithLevel;
|
||||
sb.bonuses = hs.getBonusList();
|
||||
return sb;
|
||||
};
|
||||
|
||||
for(HeroSpecial * hs : specialtyDeprecated)
|
||||
{
|
||||
for(std::shared_ptr<Bonus> b : SpecialtyBonusToBonuses(HeroSpecialToSpecialtyBonus(*hs)))
|
||||
addNewBonus(b);
|
||||
}
|
||||
}
|
||||
|
||||
void CGHeroInstance::updateSkill(SecondarySkill which, int val)
|
||||
{
|
||||
auto skillBonus = (*VLC->skillh)[which]->getBonus(val);
|
||||
|
@ -39,6 +39,21 @@ public:
|
||||
|
||||
class DLL_LINKAGE CGHeroInstance : public CArmedInstance, public IBoatGenerator, public CArtifactSet, public spells::Caster
|
||||
{
|
||||
private:
|
||||
// deprecated - used only for loading of old saves
|
||||
struct HeroSpecial : CBonusSystemNode
|
||||
{
|
||||
bool growsWithLevel;
|
||||
|
||||
HeroSpecial(){growsWithLevel = false;};
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<CBonusSystemNode&>(*this);
|
||||
h & growsWithLevel;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -95,21 +110,6 @@ public:
|
||||
}
|
||||
} patrol;
|
||||
|
||||
struct DLL_LINKAGE HeroSpecial : CBonusSystemNode
|
||||
{
|
||||
bool growsWithLevel;
|
||||
|
||||
HeroSpecial(){growsWithLevel = false;};
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<CBonusSystemNode&>(*this);
|
||||
h & growsWithLevel;
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<HeroSpecial*> specialtyDeprecated;
|
||||
|
||||
struct DLL_LINKAGE SecondarySkillsInfo
|
||||
{
|
||||
//skills are determined, initialized at map start
|
||||
@ -268,6 +268,7 @@ protected:
|
||||
|
||||
private:
|
||||
void levelUpAutomatically(CRandomGenerator & rand);
|
||||
void recreateSpecialtyBonuses(std::vector<HeroSpecial*> & specialtyDeprecated);
|
||||
|
||||
public:
|
||||
std::string getHeroTypeName() const;
|
||||
@ -297,7 +298,12 @@ public:
|
||||
h & boat;
|
||||
h & type;
|
||||
if(version < 778)
|
||||
{
|
||||
std::vector<HeroSpecial*> specialtyDeprecated;
|
||||
h & specialtyDeprecated;
|
||||
if(!h.saving)
|
||||
recreateSpecialtyBonuses(specialtyDeprecated);
|
||||
}
|
||||
h & commander;
|
||||
h & visitedObjects;
|
||||
BONUS_TREE_DESERIALIZATION_FIX
|
||||
|
Loading…
Reference in New Issue
Block a user