From 41f1d3f21fcc56a369654d4ec4550dd9caa6db15 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Sat, 11 Apr 2015 13:14:26 +0300 Subject: [PATCH] Quick fix for major spell configuration bug * clean fix requires save format change --- lib/spells/CSpellHandler.cpp | 15 ++++++++++++--- lib/spells/CSpellHandler.h | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/spells/CSpellHandler.cpp b/lib/spells/CSpellHandler.cpp index 5e4445811..bf7fd27ec 100644 --- a/lib/spells/CSpellHandler.cpp +++ b/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(); } } diff --git a/lib/spells/CSpellHandler.h b/lib/spells/CSpellHandler.h index 428ebbc64..1c61f04e8 100644 --- a/lib/spells/CSpellHandler.h +++ b/lib/spells/CSpellHandler.h @@ -153,6 +153,8 @@ public: std::string range; std::vector effects; + + std::vector effectsTmp; //TODO: this should replace effects LevelInfo(); ~LevelInfo();