소스 검색

Moved MetaString to a new file

Ivan Savenko 2 년 전
부모
커밋
2636a0dcc3

+ 1 - 1
client/windows/CQuestLog.cpp

@@ -28,7 +28,7 @@
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/CGameState.h"
 #include "../../lib/CGeneralTextHandler.h"
-#include "../../lib/NetPacksBase.h"
+#include "../../lib/MetaString.h"
 #include "../../lib/mapObjects/CQuest.h"
 
 VCMI_LIB_NAMESPACE_BEGIN

+ 2 - 0
cmake_modules/VCMI_lib.cmake

@@ -238,6 +238,7 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
 		${MAIN_LIB_DIR}/LoadProgress.cpp
 		${MAIN_LIB_DIR}/LogicalExpression.cpp
 		${MAIN_LIB_DIR}/NetPacksLib.cpp
+		${MAIN_LIB_DIR}/MetaString.cpp
 		${MAIN_LIB_DIR}/ObstacleHandler.cpp
 		${MAIN_LIB_DIR}/StartInfo.cpp
 		${MAIN_LIB_DIR}/ResourceSet.cpp
@@ -560,6 +561,7 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
 		${MAIN_LIB_DIR}/Languages.h
 		${MAIN_LIB_DIR}/LoadProgress.h
 		${MAIN_LIB_DIR}/LogicalExpression.h
+		${MAIN_LIB_DIR}/MetaString.h
 		${MAIN_LIB_DIR}/NetPacksBase.h
 		${MAIN_LIB_DIR}/NetPacks.h
 		${MAIN_LIB_DIR}/NetPacksLobby.h

+ 1 - 1
include/vcmi/spells/Caster.h

@@ -13,7 +13,7 @@
 VCMI_LIB_NAMESPACE_BEGIN
 
 class PlayerColor;
-struct MetaString;
+class MetaString;
 class ServerCallback;
 class CGHeroInstance;
 

+ 1 - 1
include/vcmi/spells/Magic.h

@@ -12,7 +12,7 @@
 
 VCMI_LIB_NAMESPACE_BEGIN
 
-struct MetaString;
+class MetaString;
 
 namespace battle
 {

+ 0 - 228
lib/CGameState.cpp

@@ -68,234 +68,6 @@ public:
 	}
 };
 
-void MetaString::getLocalString(const std::pair<ui8, ui32> & txt, std::string & dst) const
-{
-	int type = txt.first;
-	int ser = txt.second;
-
-	if(type == ART_NAMES)
-	{
-		const auto * art = ArtifactID(ser).toArtifact(VLC->artifacts());
-		if(art)
-			dst = art->getNameTranslated();
-		else
-			dst = "#!#";
-	}
-	else if(type == ART_DESCR)
-	{
-		const auto * art = ArtifactID(ser).toArtifact(VLC->artifacts());
-		if(art)
-			dst = art->getDescriptionTranslated();
-		else
-			dst = "#!#";
-	}
-	else if (type == ART_EVNTS)
-	{
-		const auto * art = ArtifactID(ser).toArtifact(VLC->artifacts());
-		if(art)
-			dst = art->getEventTranslated();
-		else
-			dst = "#!#";
-	}
-	else if(type == CRE_PL_NAMES)
-	{
-		const auto * cre = CreatureID(ser).toCreature(VLC->creatures());
-		if(cre)
-			dst = cre->getNamePluralTranslated();
-		else
-			dst = "#!#";
-	}
-	else if(type == CRE_SING_NAMES)
-	{
-		const auto * cre = CreatureID(ser).toCreature(VLC->creatures());
-		if(cre)
-			dst = cre->getNameSingularTranslated();
-		else
-			dst = "#!#";
-	}
-	else if(type == MINE_NAMES)
-	{
-		dst = VLC->generaltexth->translate("core.minename", ser);
-	}
-	else if(type == MINE_EVNTS)
-	{
-		dst = VLC->generaltexth->translate("core.mineevnt", ser);
-	}
-	else if(type == SPELL_NAME)
-	{
-		const auto * spell = SpellID(ser).toSpell(VLC->spells());
-		if(spell)
-			dst = spell->getNameTranslated();
-		else
-			dst = "#!#";
-	}
-	else if(type == OBJ_NAMES)
-	{
-		dst = VLC->objtypeh->getObjectName(ser, 0);
-	}
-	else if(type == SEC_SKILL_NAME)
-	{
-		dst = VLC->skillh->getByIndex(ser)->getNameTranslated();
-	}
-	else
-	{
-		switch(type)
-		{
-		case GENERAL_TXT:
-			dst = VLC->generaltexth->translate("core.genrltxt", ser);
-			break;
-		case RES_NAMES:
-			dst = VLC->generaltexth->translate("core.restypes", ser);
-			break;
-		case ARRAY_TXT:
-			dst = VLC->generaltexth->translate("core.arraytxt", ser);
-			break;
-		case CREGENS:
-			dst = VLC->objtypeh->getObjectName(Obj::CREATURE_GENERATOR1, ser);
-			break;
-		case CREGENS4:
-			dst = VLC->objtypeh->getObjectName(Obj::CREATURE_GENERATOR4, ser);
-			break;
-		case ADVOB_TXT:
-			dst = VLC->generaltexth->translate("core.advevent", ser);
-			break;
-		case COLOR:
-			dst = VLC->generaltexth->translate("vcmi.capitalColors", ser);
-			break;
-		case JK_TXT:
-			dst = VLC->generaltexth->translate("core.jktext", ser);
-			break;
-		default:
-			logGlobal->error("Failed string substitution because type is %d", type);
-			dst = "#@#";
-			return;
-		}
-	}
-}
-
-DLL_LINKAGE void MetaString::toString(std::string &dst) const
-{
-	size_t exSt = 0;
-	size_t loSt = 0;
-	size_t nums = 0;
-	dst.clear();
-
-	for(const auto & elem : message)
-	{//TEXACT_STRING, TLOCAL_STRING, TNUMBER, TREPLACE_ESTRING, TREPLACE_LSTRING, TREPLACE_NUMBER
-		switch(elem)
-		{
-		case TEXACT_STRING:
-			dst += exactStrings[exSt++];
-			break;
-		case TLOCAL_STRING:
-			{
-				std::string hlp;
-				getLocalString(localStrings[loSt++], hlp);
-				dst += hlp;
-			}
-			break;
-		case TNUMBER:
-			dst += std::to_string(numbers[nums++]);
-			break;
-		case TREPLACE_ESTRING:
-			boost::replace_first(dst, "%s", exactStrings[exSt++]);
-			break;
-		case TREPLACE_LSTRING:
-			{
-				std::string hlp;
-				getLocalString(localStrings[loSt++], hlp);
-				boost::replace_first(dst, "%s", hlp);
-			}
-			break;
-		case TREPLACE_NUMBER:
-			boost::replace_first(dst, "%d", std::to_string(numbers[nums++]));
-			break;
-		case TREPLACE_PLUSNUMBER:
-			boost::replace_first(dst, "%+d", '+' + std::to_string(numbers[nums++]));
-			break;
-		default:
-			logGlobal->error("MetaString processing error! Received message of type %d", int(elem));
-			break;
-		}
-	}
-}
-
-DLL_LINKAGE std::string MetaString::toString() const
-{
-	std::string ret;
-	toString(ret);
-	return ret;
-}
-
-DLL_LINKAGE std::string MetaString::buildList () const
-///used to handle loot from creature bank
-{
-
-	size_t exSt = 0;
-	size_t loSt = 0;
-	size_t nums = 0;
-	std::string lista;
-	for (int i = 0; i < message.size(); ++i)
-	{
-		if (i > 0 && (message[i] == TEXACT_STRING || message[i] == TLOCAL_STRING))
-		{
-			if (exSt == exactStrings.size() - 1)
-				lista += VLC->generaltexth->allTexts[141]; //" and "
-			else
-				lista += ", ";
-		}
-		switch (message[i])
-		{
-			case TEXACT_STRING:
-				lista += exactStrings[exSt++];
-				break;
-			case TLOCAL_STRING:
-			{
-				std::string hlp;
-				getLocalString (localStrings[loSt++], hlp);
-				lista += hlp;
-			}
-				break;
-			case TNUMBER:
-				lista += std::to_string(numbers[nums++]);
-				break;
-			case TREPLACE_ESTRING:
-				lista.replace (lista.find("%s"), 2, exactStrings[exSt++]);
-				break;
-			case TREPLACE_LSTRING:
-			{
-				std::string hlp;
-				getLocalString (localStrings[loSt++], hlp);
-				lista.replace (lista.find("%s"), 2, hlp);
-			}
-				break;
-			case TREPLACE_NUMBER:
-				lista.replace (lista.find("%d"), 2, std::to_string(numbers[nums++]));
-				break;
-			default:
-				logGlobal->error("MetaString processing error! Received message of type %d",int(message[i]));
-		}
-
-	}
-	return lista;
-}
-
-void MetaString::addCreReplacement(const CreatureID & id, TQuantity count) //adds sing or plural name;
-{
-	if (!count)
-		addReplacement (CRE_PL_NAMES, id); //no creatures - just empty name (eg. defeat Angels)
-	else if (count == 1)
-		addReplacement (CRE_SING_NAMES, id);
-	else
-		addReplacement (CRE_PL_NAMES, id);
-}
-
-void MetaString::addReplacement(const CStackBasicDescriptor & stack)
-{
-	assert(stack.type); //valid type
-	addCreReplacement(stack.type->getId(), stack.count);
-}
-
 static CGObjectInstance * createObject(const Obj & id, int subid, const int3 & pos, const PlayerColor & owner)
 {
 	CGObjectInstance * nobj;

+ 1 - 1
lib/CGameState.h

@@ -43,7 +43,7 @@ class CCreature;
 class CMap;
 struct StartInfo;
 struct SetObjectProperty;
-struct MetaString;
+class MetaString;
 struct CPack;
 class CSpell;
 struct TerrainTile;

+ 1 - 1
lib/IGameCallback.h

@@ -20,7 +20,7 @@ struct SetMovePoints;
 struct GiveBonus;
 struct BlockingDialog;
 struct TeleportDialog;
-struct MetaString;
+class MetaString;
 struct StackLocation;
 struct ArtifactLocation;
 class CCreatureSet;

+ 1 - 1
lib/IGameEventsReceiver.h

@@ -49,7 +49,7 @@ struct BattleTriggerEffect;
 struct CObstacleInstance;
 struct CPackForServer;
 class EVictoryLossCheckResult;
-struct MetaString;
+class MetaString;
 class ObstacleChanges;
 class UnitChanges;
 

+ 253 - 0
lib/MetaString.cpp

@@ -0,0 +1,253 @@
+/*
+ * CGameState.cpp, part of VCMI engine
+ *
+ * Authors: listed in file AUTHORS in main folder
+ *
+ * License: GNU General Public License v2.0 or later
+ * Full text of license available in license.txt file, in main folder
+ *
+ */
+#include "StdInc.h"
+#include "MetaString.h"
+
+#include "CArtHandler.h"
+#include "CCreatureHandler.h"
+#include "CCreatureSet.h"
+#include "CGeneralTextHandler.h"
+#include "CSkillHandler.h"
+#include "GameConstants.h"
+#include "VCMI_Lib.h"
+#include "mapObjectConstructors/CObjectClassesHandler.h"
+#include "spells/CSpellHandler.h"
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+void MetaString::getLocalString(const std::pair<ui8, ui32> & txt, std::string & dst) const
+{
+	int type = txt.first;
+	int ser = txt.second;
+
+	if(type == ART_NAMES)
+	{
+		const auto * art = ArtifactID(ser).toArtifact(VLC->artifacts());
+		if(art)
+			dst = art->getNameTranslated();
+		else
+			dst = "#!#";
+	}
+	else if(type == ART_DESCR)
+	{
+		const auto * art = ArtifactID(ser).toArtifact(VLC->artifacts());
+		if(art)
+			dst = art->getDescriptionTranslated();
+		else
+			dst = "#!#";
+	}
+	else if (type == ART_EVNTS)
+	{
+		const auto * art = ArtifactID(ser).toArtifact(VLC->artifacts());
+		if(art)
+			dst = art->getEventTranslated();
+		else
+			dst = "#!#";
+	}
+	else if(type == CRE_PL_NAMES)
+	{
+		const auto * cre = CreatureID(ser).toCreature(VLC->creatures());
+		if(cre)
+			dst = cre->getNamePluralTranslated();
+		else
+			dst = "#!#";
+	}
+	else if(type == CRE_SING_NAMES)
+	{
+		const auto * cre = CreatureID(ser).toCreature(VLC->creatures());
+		if(cre)
+			dst = cre->getNameSingularTranslated();
+		else
+			dst = "#!#";
+	}
+	else if(type == MINE_NAMES)
+	{
+		dst = VLC->generaltexth->translate("core.minename", ser);
+	}
+	else if(type == MINE_EVNTS)
+	{
+		dst = VLC->generaltexth->translate("core.mineevnt", ser);
+	}
+	else if(type == SPELL_NAME)
+	{
+		const auto * spell = SpellID(ser).toSpell(VLC->spells());
+		if(spell)
+			dst = spell->getNameTranslated();
+		else
+			dst = "#!#";
+	}
+	else if(type == OBJ_NAMES)
+	{
+		dst = VLC->objtypeh->getObjectName(ser, 0);
+	}
+	else if(type == SEC_SKILL_NAME)
+	{
+		dst = VLC->skillh->getByIndex(ser)->getNameTranslated();
+	}
+	else
+	{
+		switch(type)
+		{
+		case GENERAL_TXT:
+			dst = VLC->generaltexth->translate("core.genrltxt", ser);
+			break;
+		case RES_NAMES:
+			dst = VLC->generaltexth->translate("core.restypes", ser);
+			break;
+		case ARRAY_TXT:
+			dst = VLC->generaltexth->translate("core.arraytxt", ser);
+			break;
+		case CREGENS:
+			dst = VLC->objtypeh->getObjectName(Obj::CREATURE_GENERATOR1, ser);
+			break;
+		case CREGENS4:
+			dst = VLC->objtypeh->getObjectName(Obj::CREATURE_GENERATOR4, ser);
+			break;
+		case ADVOB_TXT:
+			dst = VLC->generaltexth->translate("core.advevent", ser);
+			break;
+		case COLOR:
+			dst = VLC->generaltexth->translate("vcmi.capitalColors", ser);
+			break;
+		case JK_TXT:
+			dst = VLC->generaltexth->translate("core.jktext", ser);
+			break;
+		default:
+			logGlobal->error("Failed string substitution because type is %d", type);
+			dst = "#@#";
+			return;
+		}
+	}
+}
+
+DLL_LINKAGE void MetaString::toString(std::string &dst) const
+{
+	size_t exSt = 0;
+	size_t loSt = 0;
+	size_t nums = 0;
+	dst.clear();
+
+	for(const auto & elem : message)
+	{//TEXACT_STRING, TLOCAL_STRING, TNUMBER, TREPLACE_ESTRING, TREPLACE_LSTRING, TREPLACE_NUMBER
+		switch(elem)
+		{
+		case TEXACT_STRING:
+			dst += exactStrings[exSt++];
+			break;
+		case TLOCAL_STRING:
+			{
+				std::string hlp;
+				getLocalString(localStrings[loSt++], hlp);
+				dst += hlp;
+			}
+			break;
+		case TNUMBER:
+			dst += std::to_string(numbers[nums++]);
+			break;
+		case TREPLACE_ESTRING:
+			boost::replace_first(dst, "%s", exactStrings[exSt++]);
+			break;
+		case TREPLACE_LSTRING:
+			{
+				std::string hlp;
+				getLocalString(localStrings[loSt++], hlp);
+				boost::replace_first(dst, "%s", hlp);
+			}
+			break;
+		case TREPLACE_NUMBER:
+			boost::replace_first(dst, "%d", std::to_string(numbers[nums++]));
+			break;
+		case TREPLACE_PLUSNUMBER:
+			boost::replace_first(dst, "%+d", '+' + std::to_string(numbers[nums++]));
+			break;
+		default:
+			logGlobal->error("MetaString processing error! Received message of type %d", int(elem));
+			break;
+		}
+	}
+}
+
+DLL_LINKAGE std::string MetaString::toString() const
+{
+	std::string ret;
+	toString(ret);
+	return ret;
+}
+
+DLL_LINKAGE std::string MetaString::buildList () const
+///used to handle loot from creature bank
+{
+
+	size_t exSt = 0;
+	size_t loSt = 0;
+	size_t nums = 0;
+	std::string lista;
+	for (int i = 0; i < message.size(); ++i)
+	{
+		if (i > 0 && (message[i] == TEXACT_STRING || message[i] == TLOCAL_STRING))
+		{
+			if (exSt == exactStrings.size() - 1)
+				lista += VLC->generaltexth->allTexts[141]; //" and "
+			else
+				lista += ", ";
+		}
+		switch (message[i])
+		{
+			case TEXACT_STRING:
+				lista += exactStrings[exSt++];
+				break;
+			case TLOCAL_STRING:
+			{
+				std::string hlp;
+				getLocalString (localStrings[loSt++], hlp);
+				lista += hlp;
+			}
+				break;
+			case TNUMBER:
+				lista += std::to_string(numbers[nums++]);
+				break;
+			case TREPLACE_ESTRING:
+				lista.replace (lista.find("%s"), 2, exactStrings[exSt++]);
+				break;
+			case TREPLACE_LSTRING:
+			{
+				std::string hlp;
+				getLocalString (localStrings[loSt++], hlp);
+				lista.replace (lista.find("%s"), 2, hlp);
+			}
+				break;
+			case TREPLACE_NUMBER:
+				lista.replace (lista.find("%d"), 2, std::to_string(numbers[nums++]));
+				break;
+			default:
+				logGlobal->error("MetaString processing error! Received message of type %d",int(message[i]));
+		}
+
+	}
+	return lista;
+}
+
+void MetaString::addCreReplacement(const CreatureID & id, TQuantity count) //adds sing or plural name;
+{
+	if (!count)
+		addReplacement (CRE_PL_NAMES, id); //no creatures - just empty name (eg. defeat Angels)
+	else if (count == 1)
+		addReplacement (CRE_SING_NAMES, id);
+	else
+		addReplacement (CRE_PL_NAMES, id);
+}
+
+void MetaString::addReplacement(const CStackBasicDescriptor & stack)
+{
+	assert(stack.type); //valid type
+	addCreReplacement(stack.type->getId(), stack.count);
+}
+
+VCMI_LIB_NAMESPACE_END

+ 90 - 0
lib/MetaString.h

@@ -0,0 +1,90 @@
+/*
+ * MetaString.h, part of VCMI engine
+ *
+ * Authors: listed in file AUTHORS in main folder
+ *
+ * License: GNU General Public License v2.0 or later
+ * Full text of license available in license.txt file, in main folder
+ *
+ */
+#pragma once
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+class CreatureID;
+class CStackBasicDescriptor;
+using TQuantity = si32;
+
+class DLL_LINKAGE MetaString
+{
+private:
+	enum EMessage {TEXACT_STRING, TLOCAL_STRING, TNUMBER, TREPLACE_ESTRING, TREPLACE_LSTRING, TREPLACE_NUMBER, TREPLACE_PLUSNUMBER};
+public:
+	enum {GENERAL_TXT=1, OBJ_NAMES, RES_NAMES, ART_NAMES, ARRAY_TXT, CRE_PL_NAMES, CREGENS, MINE_NAMES,
+		MINE_EVNTS, ADVOB_TXT, ART_EVNTS, SPELL_NAME, SEC_SKILL_NAME, CRE_SING_NAMES, CREGENS4, COLOR, ART_DESCR, JK_TXT};
+
+	std::vector<ui8> message; //vector of EMessage
+
+	std::vector<std::pair<ui8,ui32> > localStrings;
+	std::vector<std::string> exactStrings;
+	std::vector<int64_t> numbers;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & exactStrings;
+		h & localStrings;
+		h & message;
+		h & numbers;
+	}
+	void addTxt(ui8 type, ui32 serial)
+	{
+		message.push_back(TLOCAL_STRING);
+		localStrings.emplace_back(type, serial);
+	}
+	void addRawString(std::string value)
+	{
+		message.push_back(TEXACT_STRING);
+		exactStrings.push_back(value);
+	}
+	void appendNumber(int64_t value)
+	{
+		message.push_back(TNUMBER);
+		numbers.push_back(value);
+	}
+	void addReplacement(ui8 type, ui32 serial)
+	{
+		message.push_back(TREPLACE_LSTRING);
+		localStrings.emplace_back(type, serial);
+	}
+	void addReplacement(const std::string &txt)
+	{
+		message.push_back(TREPLACE_ESTRING);
+		exactStrings.push_back(txt);
+	}
+	void addReplacement(int64_t txt)
+	{
+		message.push_back(TREPLACE_NUMBER);
+		numbers.push_back(txt);
+	}
+	void addReplacement2(int64_t txt)
+	{
+		message.push_back(TREPLACE_PLUSNUMBER);
+		numbers.push_back(txt);
+	}
+	void addCreReplacement(const CreatureID & id, TQuantity count); //adds sing or plural name;
+	void addReplacement(const CStackBasicDescriptor &stack); //adds sing or plural name;
+	std::string buildList () const;
+	void clear()
+	{
+		exactStrings.clear();
+		localStrings.clear();
+		message.clear();
+		numbers.clear();
+	}
+	void toString(std::string &dst) const;
+	std::string toString() const;
+	void getLocalString(const std::pair<ui8, ui32> & txt, std::string & dst) const;
+
+};
+
+VCMI_LIB_NAMESPACE_END

+ 1 - 0
lib/NetPacks.h

@@ -19,6 +19,7 @@
 #include "CGameStateFwd.h"
 #include "mapping/CMapDefines.h"
 #include "battle/CObstacleInstance.h"
+#include "MetaString.h"
 
 #include "spells/ViewSpellInt.h"
 

+ 0 - 85
lib/NetPacksBase.h

@@ -115,91 +115,6 @@ protected:
 	virtual void visitBasic(ICPackVisitor & cpackVisitor) override;
 };
 
-struct DLL_LINKAGE MetaString
-{
-private:
-	enum EMessage {TEXACT_STRING, TLOCAL_STRING, TNUMBER, TREPLACE_ESTRING, TREPLACE_LSTRING, TREPLACE_NUMBER, TREPLACE_PLUSNUMBER};
-public:
-	enum {GENERAL_TXT=1, OBJ_NAMES, RES_NAMES, ART_NAMES, ARRAY_TXT, CRE_PL_NAMES, CREGENS, MINE_NAMES,
-		MINE_EVNTS, ADVOB_TXT, ART_EVNTS, SPELL_NAME, SEC_SKILL_NAME, CRE_SING_NAMES, CREGENS4, COLOR, ART_DESCR, JK_TXT};
-
-	std::vector<ui8> message; //vector of EMessage
-
-	std::vector<std::pair<ui8,ui32> > localStrings;
-	std::vector<std::string> exactStrings;
-	std::vector<int64_t> numbers;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & exactStrings;
-		h & localStrings;
-		h & message;
-		h & numbers;
-	}
-	void addTxt(ui8 type, ui32 serial)
-	{
-		message.push_back(TLOCAL_STRING);
-		localStrings.emplace_back(type, serial);
-	}
-	MetaString& operator<<(const std::pair<ui8,ui32> &txt)
-	{
-		message.push_back(TLOCAL_STRING);
-		localStrings.push_back(txt);
-		return *this;
-	}
-	MetaString& operator<<(int64_t txt)
-	{
-		message.push_back(TNUMBER);
-		numbers.push_back(txt);
-		return *this;
-	}
-
-	void addRawString(std::string value)
-	{
-		message.push_back(TEXACT_STRING);
-		exactStrings.push_back(value);
-	}
-	void addNumber(int64_t value)
-	{
-		message.push_back(TNUMBER);
-		numbers.push_back(value);
-	}
-	void addReplacement(ui8 type, ui32 serial)
-	{
-		message.push_back(TREPLACE_LSTRING);
-		localStrings.emplace_back(type, serial);
-	}
-	void addReplacement(const std::string &txt)
-	{
-		message.push_back(TREPLACE_ESTRING);
-		exactStrings.push_back(txt);
-	}
-	void addReplacement(int64_t txt)
-	{
-		message.push_back(TREPLACE_NUMBER);
-		numbers.push_back(txt);
-	}
-	void addReplacement2(int64_t txt)
-	{
-		message.push_back(TREPLACE_PLUSNUMBER);
-		numbers.push_back(txt);
-	}
-	void addCreReplacement(const CreatureID & id, TQuantity count); //adds sing or plural name;
-	void addReplacement(const CStackBasicDescriptor &stack); //adds sing or plural name;
-	std::string buildList () const;
-	void clear()
-	{
-		exactStrings.clear();
-		localStrings.clear();
-		message.clear();
-		numbers.clear();
-	}
-	void toString(std::string &dst) const;
-	std::string toString() const;
-	void getLocalString(const std::pair<ui8, ui32> & txt, std::string & dst) const;
-
-};
-
 struct Component
 {
 	enum class EComponentType : uint8_t 

+ 1 - 0
lib/battle/Unit.cpp

@@ -13,6 +13,7 @@
 
 #include "../VCMI_Lib.h"
 #include "../CGeneralTextHandler.h"
+#include "../MetaString.h"
 #include "../NetPacksBase.h"
 
 #include "../serializer/JsonDeserializer.h"

+ 1 - 1
lib/battle/Unit.h

@@ -21,7 +21,7 @@
 
 VCMI_LIB_NAMESPACE_BEGIN
 
-struct MetaString;
+class MetaString;
 class JsonNode;
 class JsonSerializeFormat;
 

+ 2 - 2
lib/mapObjects/CGCreature.cpp

@@ -49,7 +49,7 @@ std::string CGCreature::getHoverText(const CGHeroInstance * hero) const
 	if(hero->hasVisions(this, 0))
 	{
 		MetaString ms;
-		ms << stacks.begin()->second->count;
+		ms.appendNumber(stacks.begin()->second->count);
 		ms.addRawString(" ");
 		ms.addTxt(MetaString::CRE_PL_NAMES,subID);
 
@@ -324,7 +324,7 @@ void CGCreature::joinDecision(const CGHeroInstance *h, int cost, ui32 accept) co
 		{
 			InfoWindow iw;
 			iw.player = h->tempOwner;
-			iw.text << std::pair<ui8,ui32>(1,29);  //You don't have enough gold
+			iw.text.addTxt(1,29);  //You don't have enough gold
 			cb->showInfoDialog(&iw);
 
 			//act as if player refused

+ 1 - 1
lib/mapObjects/CQuest.cpp

@@ -1157,7 +1157,7 @@ void CGBorderGuard::initObj(CRandomGenerator & rand)
 
 void CGBorderGuard::getVisitText (MetaString &text, std::vector<Component> &components, bool isCustom, bool FirstVisit, const CGHeroInstance * h) const
 {
-	text << std::pair<ui8,ui32>(11,18);
+	text.addTxt(11,18);
 }
 
 void CGBorderGuard::getRolloverText (MetaString &text, bool onHover) const

+ 1 - 0
lib/mapObjects/IObjectInterface.h

@@ -20,6 +20,7 @@ class CRandomGenerator;
 class IGameCallback;
 class ResourceSet;
 class int3;
+class MetaString;
 
 class DLL_LINKAGE IObjectInterface
 {

+ 1 - 0
lib/mapObjects/MiscObjects.h

@@ -10,6 +10,7 @@
 #pragma once
 
 #include "CArmedInstance.h"
+#include "../MetaString.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 2 - 1
lib/rewardable/Configuration.h

@@ -11,8 +11,9 @@
 #pragma once
 
 #include "Limiter.h"
-#include "Reward.h"
+#include "MetaString.h"
 #include "NetPacksBase.h"
+#include "Reward.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 1 - 1
lib/spells/BonusCaster.cpp

@@ -13,7 +13,7 @@
 
 #include <vcmi/spells/Spell.h>
 
-#include "../NetPacksBase.h"
+#include "../MetaString.h"
 #include "../battle/Unit.h"
 #include "../bonuses/Bonus.h"
 

+ 0 - 1
lib/spells/Problem.cpp

@@ -8,7 +8,6 @@
  *
  */
 #include "StdInc.h"
-
 #include "Problem.h"
 
 VCMI_LIB_NAMESPACE_BEGIN

+ 1 - 1
lib/spells/Problem.h

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

+ 1 - 1
lib/spells/effects/Timed.h

@@ -16,7 +16,7 @@ VCMI_LIB_NAMESPACE_BEGIN
 
 struct Bonus;
 struct SetStackEffect;
-struct MetaString;
+class MetaString;
 
 namespace spells
 {