Ivan Savenko 2 lat temu
rodzic
commit
9b5e81929f

+ 5 - 0
lib/MetaString.cpp

@@ -300,6 +300,11 @@ void MetaString::replaceCreatureName(const CStackBasicDescriptor & stack)
 	replaceCreatureName(stack.type->getId(), stack.count);
 }
 
+bool MetaString::operator == (const MetaString & other) const
+{
+	return message == other.message && localStrings == other.localStrings && exactStrings == other.exactStrings && stringsTextID == other.stringsTextID && numbers == other.numbers;
+}
+
 void MetaString::jsonSerialize(JsonNode & dest) const
 {
 	JsonNode jsonMessage;

+ 2 - 0
lib/MetaString.h

@@ -109,6 +109,8 @@ public:
 	/// Returns true if current string is empty
 	bool empty() const;
 
+	bool operator == (const MetaString & other) const;
+
 	void jsonSerialize(JsonNode & dest) const;
 	void jsonDeserialize(const JsonNode & dest);
 

+ 1 - 1
scripting/lua/api/netpacks/BattleLogMessage.cpp

@@ -47,7 +47,7 @@ int BattleLogMessageProxy::addText(lua_State * L)
 		{
 			if(object->lines.empty())
 				object->lines.emplace_back();
-			object->lines.back() << text;
+			object->lines.back().appendRawString(text);
 		}
 	}
 

+ 6 - 6
scripting/lua/api/netpacks/InfoWindow.cpp

@@ -56,17 +56,17 @@ int InfoWindowProxy::addReplacement(lua_State * L)
 			const auto *raw = lua_tolstring(L, 2, &len);
 			std::string text(raw, len);
 
-			object->text.addReplacement(text);
+			object->text.replaceRawString(text);
 		}
 		else if(lua_isnumber(L, 2))
 		{
-			object->text.addReplacement(lua_tointeger(L, 2));
+			object->text.replaceNumber(lua_tointeger(L, 2));
 		}
 	}
 	else if(top >= 3)
 	{
 		if(lua_isnumber(L, 2) && lua_isnumber(L, 3))
-			object->text.addReplacement(lua_tointeger(L, 2), lua_tointeger(L, 3));
+			object->text.replaceLocalString(static_cast<EMetaText>(lua_tointeger(L, 2)), lua_tointeger(L, 3));
 	}
 
 	return S.retVoid();
@@ -90,18 +90,18 @@ int InfoWindowProxy::addText(lua_State * L)
 			const auto *raw = lua_tolstring(L, 2, &len);
 			std::string text(raw, len);
 
-			object->text << text;
+			object->text.appendRawString(text);
 		}
 		else if(lua_isnumber(L, 2))
 		{
-			object->text << (lua_tointeger(L, 2));
+			object->text.appendNumber(lua_tointeger(L, 2));
 		}
 	}
 
 	if(top >= 3)
 	{
 		if(lua_isnumber(L, 2) && lua_isnumber(L, 3))
-			object->text.addTxt(lua_tointeger(L, 2), lua_tointeger(L, 3));
+			object->text.appendLocalString(static_cast<EMetaText>(lua_tointeger(L, 2)), lua_tointeger(L, 3));
 	}
 
 	return S.retVoid();

+ 1 - 1
test/mock/mock_spells_Problem.h

@@ -12,7 +12,7 @@
 
 #include <vcmi/spells/Magic.h>
 
-#include "../../lib/NetPacksBase.h"
+#include "../../lib/MetaString.h"
 
 namespace spells
 {