소스 검색

Add description for bonuses from hero specialty

godric3 7 년 전
부모
커밋
f9ac46576b
4개의 변경된 파일13개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 2
      lib/CHeroHandler.cpp
  2. 1 1
      lib/CHeroHandler.h
  3. 3 0
      lib/HeroBonus.cpp
  4. 1 1
      lib/mapObjects/CGHeroInstance.cpp

+ 8 - 2
lib/CHeroHandler.cpp

@@ -564,11 +564,12 @@ std::vector<std::shared_ptr<Bonus>> SpecialtyInfoToBonuses(const SSpecialtyInfo
 }
 
 // convert deprecated format
-std::vector<std::shared_ptr<Bonus>> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec)
+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
@@ -860,6 +861,11 @@ void CHeroHandler::afterLoadFinalization()
 {
 	for(ConstTransitivePtr<CHero> hero : heroes)
 	{
+		for(auto bonus : hero->specialty)
+		{
+			bonus->sid = hero->ID.getNum();
+		}
+
 		if(hero->specDeprecated.size() > 0 || hero->specialtyDeprecated.size() > 0)
 		{
 			logMod->debug("Converting specialty format for hero %s(%s)", hero->identifier, VLC->townh->encodeFaction(hero->heroClass->faction));
@@ -871,7 +877,7 @@ void CHeroHandler::afterLoadFinalization()
 			}
 			for(const SSpecialtyBonus & spec : hero->specialtyDeprecated)
 			{
-				for(std::shared_ptr<Bonus> b : SpecialtyBonusToBonuses(spec))
+				for(std::shared_ptr<Bonus> b : SpecialtyBonusToBonuses(spec, hero->ID.getNum()))
 					convertedBonuses.push_back(b);
 			}
 			hero->specDeprecated.clear();

+ 1 - 1
lib/CHeroHandler.h

@@ -135,7 +135,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);
+std::vector<std::shared_ptr<Bonus>> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec, int sid);
 
 class DLL_LINKAGE CHeroClass
 {

+ 3 - 0
lib/HeroBonus.cpp

@@ -1250,6 +1250,9 @@ std::string Bonus::Description() const
 			case SECONDARY_SKILL:
 				str << VLC->skillh->skillName(sid);
 				break;
+			case HERO_SPECIAL:
+				str << VLC->heroh->heroes[sid]->name;
+				break;
 			default:
 				//todo: handle all possible sources
 				str << "Unknown";

+ 1 - 1
lib/mapObjects/CGHeroInstance.cpp

@@ -552,7 +552,7 @@ void CGHeroInstance::recreateSpecialtyBonuses(std::vector<HeroSpecial *> & speci
 
 	for(HeroSpecial * hs : specialtyDeprecated)
 	{
-		for(std::shared_ptr<Bonus> b : SpecialtyBonusToBonuses(HeroSpecialToSpecialtyBonus(*hs)))
+		for(std::shared_ptr<Bonus> b : SpecialtyBonusToBonuses(HeroSpecialToSpecialtyBonus(*hs), type->ID.getNum()))
 			addNewBonus(b);
 	}
 }