Pārlūkot izejas kodu

Fix results of merge conflict with Warmonger. + more fixes to barseBonus.
Bonus duration now can be array and parsed to bitmask as designed.

alexvins 12 gadi atpakaļ
vecāks
revīzija
36469f406c
2 mainītis faili ar 31 papildinājumiem un 10 dzēšanām
  1. 4 4
      config/spell_info.json
  2. 27 6
      lib/JsonNode.cpp

+ 4 - 4
config/spell_info.json

@@ -760,12 +760,12 @@
 				{
 				{
 					"type": 	"NOT_ACTIVE",
 					"type": 	"NOT_ACTIVE",
 					"subtype": 	62,
 					"subtype": 	62,
-					"duration":	"UNITL_BEING_ATTACKED N_TURNS",
+					"duration":	["UNITL_BEING_ATTACKED","N_TURNS"],
 					"values":[0,0,0,0]
 					"values":[0,0,0,0]
 				},
 				},
 				{
 				{
 					"type": 	"GENERAL_ATTACK_REDUCTION",
 					"type": 	"GENERAL_ATTACK_REDUCTION",
-					"duration":	"UNITL_BEING_ATTACKED N_TURNS"
+					"duration":	["UNITL_BEING_ATTACKED","N_TURNS"]
 				},
 				},
 				{
 				{
 					"type": 	"NO_RETALIATION",
 					"type": 	"NO_RETALIATION",
@@ -836,7 +836,7 @@
 				{
 				{
 					"type": 	"NOT_ACTIVE",
 					"type": 	"NOT_ACTIVE",
 					"subtype": 	62,
 					"subtype": 	62,
-					"duration":	"UNITL_BEING_ATTACKED N_TURNS",
+					"duration":	["UNITL_BEING_ATTACKED","N_TURNS"],
 					"values":[0,0,0,0]
 					"values":[0,0,0,0]
 				},
 				},
 				{
 				{
@@ -918,7 +918,7 @@
 				{
 				{
 					"type": 	"NOT_ACTIVE",
 					"type": 	"NOT_ACTIVE",
 					"subtype": 	74,
 					"subtype": 	74,
-					"duration":	"UNITL_BEING_ATTACKED N_TURNS",
+					"duration":	["UNITL_BEING_ATTACKED","N_TURNS"],
 					"values":[0,0,0,0]
 					"values":[0,0,0,0]
 				},
 				},
 				{
 				{

+ 27 - 6
lib/JsonNode.cpp

@@ -943,7 +943,7 @@ void JsonUtils::resolveIdentifier (si32 &var, const JsonNode &node, std::string
 				});
 				});
 				break;
 				break;
 			default:
 			default:
-				tlog2 << "Error! Wrong indentifier used for value of " << name; 
+				tlog2 << "Error! Wrong indentifier used for value of " << name;
 		}
 		}
 	}
 	}
 }
 }
@@ -962,7 +962,7 @@ void JsonUtils::resolveIdentifier (const JsonNode &node, si32 &var)
 			});
 			});
 			break;
 			break;
 		default:
 		default:
-			tlog2 << "Error! Wrong indentifier used for identifier!"; 
+			tlog2 << "Error! Wrong indentifier used for identifier!";
 	}
 	}
 }
 }
 
 
@@ -1009,20 +1009,41 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
 
 
 	value = &ability["effectRange"];
 	value = &ability["effectRange"];
 	if (!value->isNull())
 	if (!value->isNull())
-		b->valType = parseByMap(bonusLimitEffect, value, "effect range ");
+		b->effectRange = parseByMap(bonusLimitEffect, value, "effect range ");
+
 	value = &ability["duration"];
 	value = &ability["duration"];
 	if (!value->isNull())
 	if (!value->isNull())
-		b->valType = parseByMap(bonusDurationMap, value, "duration type ");
+	{
+		switch (value->getType())
+		{
+		case JsonNode::DATA_STRING:
+			b->duration = parseByMap(bonusDurationMap, value, "duration type ");
+			break;
+		case JsonNode::DATA_VECTOR:
+			{
+				ui16 dur = 0;
+				BOOST_FOREACH (const JsonNode & d, value->Vector())
+				{
+					dur |= parseByMap(bonusDurationMap, &d, "duration type ");
+				}
+				b->duration = dur;
+			}
+			break;
+		default:
+			tlog2 << "Error! Wrong bonus duration format.";
+		}
+	}
+
 	value = &ability["source"];
 	value = &ability["source"];
 	if (!value->isNull())
 	if (!value->isNull())
-		b->valType = parseByMap(bonusSourceMap, value, "source type ");
+		b->source = parseByMap(bonusSourceMap, value, "source type ");
 
 
 	value = &ability["limiters"];
 	value = &ability["limiters"];
 	if (!value->isNull())
 	if (!value->isNull())
 	{
 	{
 		BOOST_FOREACH (const JsonNode & limiter, value->Vector())
 		BOOST_FOREACH (const JsonNode & limiter, value->Vector())
 		{
 		{
-			switch (limiter.getType()) 
+			switch (limiter.getType())
 			{
 			{
 				case JsonNode::DATA_STRING: //pre-defined limiters
 				case JsonNode::DATA_STRING: //pre-defined limiters
 					b->limiter = parseByMap(bonusLimiterMap, &limiter, "limiter type ");
 					b->limiter = parseByMap(bonusLimiterMap, &limiter, "limiter type ");