2
0
Эх сурвалжийг харах

Change spell school serialization

AlexVinS 11 жил өмнө
parent
commit
5d1077161c

+ 9 - 9
lib/CSpellHandler.cpp

@@ -430,10 +430,10 @@ void CSpell::setup()
 {
 	setupMechanics();
 	
-	school[ESpellSchool::AIR] = air;
-	school[ESpellSchool::FIRE] = fire;
-	school[ESpellSchool::WATER] = water;
-	school[ESpellSchool::EARTH] = earth;	
+	air = school[ESpellSchool::AIR];
+	fire = school[ESpellSchool::FIRE];
+	water = school[ESpellSchool::WATER];
+	earth = school[ESpellSchool::EARTH];	
 }
 
 
@@ -657,11 +657,11 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode& json)
 	logGlobal->traceStream() << __FUNCTION__ << ": loading spell " << spell->name;
 
 	const auto schoolNames = json["school"];
-
-	spell->air   = schoolNames["air"].Bool();
-	spell->earth = schoolNames["earth"].Bool();
-	spell->fire  = schoolNames["fire"].Bool();
-	spell->water = schoolNames["water"].Bool();
+	
+	for(SpellSchoolInfo & info : spellSchoolConfig)
+	{
+		spell->school[info.id] = schoolNames[info.jsonName].Bool();
+	}
 
 	spell->level = json["level"].Float();
 	spell->power = json["power"].Float();

+ 3 - 1
lib/CSpellHandler.h

@@ -241,7 +241,7 @@ public:
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
-		h & identifier & id & name & level & earth & water & fire & air & power
+		h & identifier & id & name & level & power
 		  & probabilities  & attributes & combatSpell & creatureAbility & positiveness & counteredSpells & mainEffectAnim;
 		h & isRising & isDamage & isOffensive;
 		h & targetType;
@@ -255,6 +255,8 @@ public:
 
 		h & levels;
 		
+		h & school;
+		
 		if(!h.saving)
 			setup();
 	}