Browse Source

Quick fix for major spell configuration bug
* clean fix requires save format change

AlexVinS 10 years ago
parent
commit
41f1d3f21f
2 changed files with 14 additions and 3 deletions
  1. 12 3
      lib/spells/CSpellHandler.cpp
  2. 2 0
      lib/spells/CSpellHandler.h

+ 12 - 3
lib/spells/CSpellHandler.cpp

@@ -980,7 +980,7 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode & json)
 			if(usePowerAsValue)
 				b->val = levelPower;
 
-			levelObject.effects.push_back(*b);
+			levelObject.effectsTmp.push_back(b);
 		}
 
 	}
@@ -994,9 +994,18 @@ void CSpellHandler::afterLoadFinalization()
 	for(auto spell: objects)
 	{
 		for(auto & level: spell->levels)
+		{
+			for(Bonus * bonus : level.effectsTmp)
+			{
+				level.effects.push_back(*bonus);
+				delete bonus;
+			}
+			level.effectsTmp.clear();
+			
 			for(auto & bonus: level.effects)
-				bonus.sid = spell->id;
-		spell->setup();
+				bonus.sid = spell->id;	
+		}
+		spell->setup();		
 	}
 }
 

+ 2 - 0
lib/spells/CSpellHandler.h

@@ -153,6 +153,8 @@ public:
 		std::string range;
 
 		std::vector<Bonus> effects;
+		
+		std::vector<Bonus *> effectsTmp; //TODO: this should replace effects 
 
 		LevelInfo();
 		~LevelInfo();