Explorar o código

Use arraytxt for object bonus description

gamestales-com hai 1 ano
pai
achega
faea00a7e1

+ 5 - 5
config/objects/rewardableOnceVisitable.json

@@ -154,7 +154,7 @@
 				"onVisited" : [
 				"onVisited" : [
 					{
 					{
 						"message" : 163,
 						"message" : 163,
-						"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE" } ]
+						"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE", "description" : 104 } ]
 					}
 					}
 				],
 				],
 				"rewards" : [
 				"rewards" : [
@@ -162,25 +162,25 @@
 						"appearChance" : { "max" : 30 },
 						"appearChance" : { "max" : 30 },
 						"message" : 162,
 						"message" : 162,
 						"artifacts" : [ { "class" : "TREASURE" } ],
 						"artifacts" : [ { "class" : "TREASURE" } ],
-						"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE" } ]
+						"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE", "description" : 104 } ]
 					},
 					},
 					{
 					{
 						"appearChance" : { "min" : 30, "max" : 80 },
 						"appearChance" : { "min" : 30, "max" : 80 },
 						"message" : 162,
 						"message" : 162,
 						"artifacts" : [ { "class" : "MINOR" } ],
 						"artifacts" : [ { "class" : "MINOR" } ],
-						"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE" } ]
+						"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE", "description" : 104 } ]
 					},
 					},
 					{
 					{
 						"appearChance" : { "min" : 80, "max" : 95 },
 						"appearChance" : { "min" : 80, "max" : 95 },
 						"message" : 162,
 						"message" : 162,
 						"artifacts" : [ { "class" : "MAJOR" } ],
 						"artifacts" : [ { "class" : "MAJOR" } ],
-						"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE" } ]
+						"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE", "description" : 104 } ]
 					},
 					},
 					{
 					{
 						"appearChance" : { "min" : 95 },
 						"appearChance" : { "min" : 95 },
 						"message" : 162,
 						"message" : 162,
 						"artifacts" : [ { "class" : "RELIC" } ],
 						"artifacts" : [ { "class" : "RELIC" } ],
-						"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE" } ]
+						"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE", "description" : 104 } ]
 					}
 					}
 				]
 				]
 			}
 			}

+ 2 - 2
lib/JsonNode.cpp

@@ -427,14 +427,14 @@ static void loadBonusSubtype(BonusSubtypeID & subtype, BonusType type, const Jso
 
 
 	if (node.isNumber()) // Compatibility code for 1.3 or older
 	if (node.isNumber()) // Compatibility code for 1.3 or older
 	{
 	{
-		logMod->warn("Bonus subtype must be string!");
+		logMod->warn("Bonus subtype must be string! (%s)", node.meta);
 		subtype = BonusCustomSubtype(node.Integer());
 		subtype = BonusCustomSubtype(node.Integer());
 		return;
 		return;
 	}
 	}
 
 
 	if (!node.isString())
 	if (!node.isString())
 	{
 	{
-		logMod->warn("Bonus subtype must be string!");
+		logMod->warn("Bonus subtype must be string! (%s)", node.meta);
 		subtype = BonusSubtypeID();
 		subtype = BonusSubtypeID();
 		return;
 		return;
 	}
 	}

+ 17 - 18
lib/networkPacks/NetPacksLib.cpp

@@ -993,29 +993,28 @@ void GiveBonus::applyGs(CGameState *gs)
 
 
 	std::string &descr = b->description;
 	std::string &descr = b->description;
 
 
-	if(bdescr.empty() && (bonus.type == BonusType::LUCK || bonus.type == BonusType::MORALE))
+	if(!bdescr.empty()) 
 	{
 	{
-		if (bonus.source == BonusSource::OBJECT_TYPE || bonus.source == BonusSource::OBJECT_INSTANCE)
-		{
-			descr = VLC->generaltexth->arraytxt[bonus.val > 0 ? 110 : 109]; //+/-%d Temporary until next battle"
-		}
-		else if(bonus.source == BonusSource::TOWN_STRUCTURE)
-		{
-			descr = bonus.description;
-			return;
-		}
-		else
-		{
-			descr = bdescr.toString();
-		}
+		descr = bdescr.toString();
+	}
+	else if(!descr.empty())
+	{
+		//use preseet description
+	}
+	else if((bonus.type == BonusType::LUCK || bonus.type == BonusType::MORALE)
+		  && (bonus.source == BonusSource::OBJECT_TYPE || bonus.source == BonusSource::OBJECT_INSTANCE))
+	{
+		//no description, use generic
+		//?could use allways when Type == BonusDuration::Type::ONE_BATTLE
+		descr = VLC->generaltexth->arraytxt[bonus.val > 0 ? 110 : 109]; //+/-%d Temporary until next battle"
 	}
 	}
 	else
 	else
 	{
 	{
-		descr = bdescr.toString();
+		logGlobal->debug("Empty bonus decription. Type=%d", (int) bonus.type);
 	}
 	}
-	// Some of(?) versions of H3 use %s here instead of %d. Try to replace both of them
-	boost::replace_first(descr, "%d", std::to_string(std::abs(bonus.val)));
-	boost::replace_first(descr, "%s", std::to_string(std::abs(bonus.val)));
+	// Some of(?) versions of H3 use " %s" here instead of %d. Try to replace both of them
+	boost::replace_first(descr, "%d", std::to_string(std::abs(bonus.val))); // " +/-%d Temporary until next battle
+	boost::replace_first(descr, " %s", boost::str(boost::format(" %+d") % bonus.val));  // " %s" in arraytxt.69, fountian of fortune
 }
 }
 
 
 void ChangeObjPos::applyGs(CGameState *gs)
 void ChangeObjPos::applyGs(CGameState *gs)