瀏覽代碼

Remove some usages of server-side translations

Ivan Savenko 1 年之前
父節點
當前提交
18ece6dcf6

+ 0 - 1
client/Client.h

@@ -217,7 +217,6 @@ public:
 	void setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, ObjPropertyID identifier) override {};
 	void setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, ObjPropertyID identifier) override {};
 
 
 	void showInfoDialog(InfoWindow * iw) override {};
 	void showInfoDialog(InfoWindow * iw) override {};
-	void showInfoDialog(const std::string & msg, PlayerColor player) override {};
 	void removeGUI() const;
 	void removeGUI() const;
 
 
 #if SCRIPTING_ENABLED
 #if SCRIPTING_ENABLED

+ 0 - 1
lib/IGameCallback.h

@@ -78,7 +78,6 @@ public:
 	virtual void setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, ObjPropertyID identifier) = 0;
 	virtual void setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, ObjPropertyID identifier) = 0;
 
 
 	virtual void showInfoDialog(InfoWindow * iw) = 0;
 	virtual void showInfoDialog(InfoWindow * iw) = 0;
-	virtual void showInfoDialog(const std::string & msg, PlayerColor player) = 0;
 
 
 	virtual void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells)=0;
 	virtual void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells)=0;
 	virtual bool removeObject(const CGObjectInstance * obj, const PlayerColor & initiator) = 0;
 	virtual bool removeObject(const CGObjectInstance * obj, const PlayerColor & initiator) = 0;

+ 0 - 3
lib/bonuses/Bonus.cpp

@@ -130,10 +130,7 @@ std::string Bonus::Description(std::optional<si32> customValue) const
 	auto valueToShow = customValue.value_or(val);
 	auto valueToShow = customValue.value_or(val);
 
 
 	if(valueToShow != 0)
 	if(valueToShow != 0)
-	{
-		descriptionHelper.replaceNumber(valueToShow);
 		descriptionHelper.replacePositiveNumber(valueToShow);
 		descriptionHelper.replacePositiveNumber(valueToShow);
-	}
 
 
 	return descriptionHelper.toString();
 	return descriptionHelper.toString();
 }
 }

+ 3 - 3
lib/mapObjects/CGHeroInstance.h

@@ -144,6 +144,9 @@ public:
 	//////////////////////////////////////////////////////////////////////////
 	//////////////////////////////////////////////////////////////////////////
 
 
 	std::string getBiographyTranslated() const;
 	std::string getBiographyTranslated() const;
+	std::string getBiographyTextID() const;
+
+	std::string getNameTextID() const;
 	std::string getNameTranslated() const;
 	std::string getNameTranslated() const;
 
 
 	HeroTypeID getPortraitSource() const;
 	HeroTypeID getPortraitSource() const;
@@ -152,9 +155,6 @@ public:
 	std::string getClassNameTranslated() const;
 	std::string getClassNameTranslated() const;
 	std::string getClassNameTextID() const;
 	std::string getClassNameTextID() const;
 
 
-private:
-	std::string getNameTextID() const;
-	std::string getBiographyTextID() const;
 public:
 public:
 
 
 	bool hasSpellbook() const;
 	bool hasSpellbook() const;

+ 4 - 12
server/CGameHandler.cpp

@@ -388,7 +388,7 @@ void CGameHandler::giveExperience(const CGHeroInstance * hero, TExpType amountTo
 		InfoWindow iw;
 		InfoWindow iw;
 		iw.player = hero->tempOwner;
 		iw.player = hero->tempOwner;
 		iw.text.appendLocalString(EMetaText::GENERAL_TXT, 1); //can gain no more XP
 		iw.text.appendLocalString(EMetaText::GENERAL_TXT, 1); //can gain no more XP
-		iw.text.replaceRawString(hero->getNameTranslated());
+		iw.text.replaceTextID(hero->getNameTextID());
 		sendAndApply(&iw);
 		sendAndApply(&iw);
 	}
 	}
 
 
@@ -1593,7 +1593,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
 		iw.components.emplace_back(ComponentType::SEC_SKILL, scholarSkill, scholarSkillLevel);
 		iw.components.emplace_back(ComponentType::SEC_SKILL, scholarSkill, scholarSkillLevel);
 
 
 		iw.text.appendLocalString(EMetaText::GENERAL_TXT, 139);//"%s, who has studied magic extensively,
 		iw.text.appendLocalString(EMetaText::GENERAL_TXT, 139);//"%s, who has studied magic extensively,
-		iw.text.replaceRawString(h1->getNameTranslated());
+		iw.text.replaceTextID(h1->getNameTextID());
 
 
 		if (!cs2.spells.empty())//if found new spell - apply
 		if (!cs2.spells.empty())//if found new spell - apply
 		{
 		{
@@ -1614,7 +1614,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
 				}
 				}
 			}
 			}
 			iw.text.appendLocalString(EMetaText::GENERAL_TXT, 142);//from %s
 			iw.text.appendLocalString(EMetaText::GENERAL_TXT, 142);//from %s
-			iw.text.replaceRawString(h2->getNameTranslated());
+			iw.text.replaceTextID(h2->getNameTextID());
 			sendAndApply(&cs2);
 			sendAndApply(&cs2);
 		}
 		}
 
 
@@ -1642,7 +1642,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
 				}
 				}
 			}
 			}
 			iw.text.appendLocalString(EMetaText::GENERAL_TXT, 148);//from %s
 			iw.text.appendLocalString(EMetaText::GENERAL_TXT, 148);//from %s
-			iw.text.replaceRawString(h2->getNameTranslated());
+			iw.text.replaceTextID(h2->getNameTextID());
 			sendAndApply(&cs1);
 			sendAndApply(&cs1);
 		}
 		}
 		sendAndApply(&iw);
 		sendAndApply(&iw);
@@ -4265,14 +4265,6 @@ void CGameHandler::showInfoDialog(InfoWindow * iw)
 	sendAndApply(iw);
 	sendAndApply(iw);
 }
 }
 
 
-void CGameHandler::showInfoDialog(const std::string & msg, PlayerColor player)
-{
-	InfoWindow iw;
-	iw.player = player;
-	iw.text.appendRawString(msg);
-	showInfoDialog(&iw);
-}
-
 CRandomGenerator & CGameHandler::getRandomGenerator()
 CRandomGenerator & CGameHandler::getRandomGenerator()
 {
 {
 	return CRandomGenerator::getDefault();
 	return CRandomGenerator::getDefault();

+ 0 - 1
server/CGameHandler.h

@@ -160,7 +160,6 @@ public:
 	void setObjPropertyValue(ObjectInstanceID objid, ObjProperty prop, int32_t value) override;
 	void setObjPropertyValue(ObjectInstanceID objid, ObjProperty prop, int32_t value) override;
 	void setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, ObjPropertyID identifier) override;
 	void setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, ObjPropertyID identifier) override;
 	void showInfoDialog(InfoWindow * iw) override;
 	void showInfoDialog(InfoWindow * iw) override;
-	void showInfoDialog(const std::string & msg, PlayerColor player) override;
 
 
 	//////////////////////////////////////////////////////////////////////////
 	//////////////////////////////////////////////////////////////////////////
 	void useScholarSkill(ObjectInstanceID hero1, ObjectInstanceID hero2);
 	void useScholarSkill(ObjectInstanceID hero1, ObjectInstanceID hero2);

+ 16 - 15
server/battles/BattleActionProcessor.cpp

@@ -1523,26 +1523,27 @@ void BattleActionProcessor::addGenericKilledLog(BattleLogMessage & blm, const CS
 {
 {
 	if(killed > 0)
 	if(killed > 0)
 	{
 	{
-		const int32_t txtIndex = (killed > 1) ? 379 : 378;
-		std::string formatString = VLC->generaltexth->allTexts[txtIndex];
-
-		// these default h3 texts have unnecessary new lines, so get rid of them before displaying (and trim just in case, trimming newlines does not works for some reason)
-		formatString.erase(std::remove(formatString.begin(), formatString.end(), '\n'), formatString.end());
-		formatString.erase(std::remove(formatString.begin(), formatString.end(), '\r'), formatString.end());
-		boost::algorithm::trim(formatString);
+		MetaString line;
 
 
-		boost::format txt(formatString);
-		if(killed > 1)
+		if (killed > 1)
 		{
 		{
-			txt % killed % (multiple ? VLC->generaltexth->allTexts[43] : defender->unitType()->getNamePluralTranslated()); // creatures perish
+			line.appendTextID("core.genrltxt.379"); // %d %s perished
+			line.replaceNumber(killed);
 		}
 		}
-		else //killed == 1
+		else
+			line.appendTextID("core.genrltxt.378"); // One %s perishes
+
+		if (multiple)
 		{
 		{
-			txt % (multiple ? VLC->generaltexth->allTexts[42] : defender->unitType()->getNameSingularTranslated()); // creature perishes
+			if (killed > 1)
+				line.replaceTextID("core.genrltxt.43"); // creatures
+			else
+				line.replaceTextID("core.genrltxt.42"); // creature
 		}
 		}
-		MetaString line;
-		line.appendRawString(txt.str());
-		blm.lines.push_back(std::move(line));
+		else
+			line.replaceName(CreatureID(defender->unitId()), killed);
+
+		blm.lines.push_back(line);
 	}
 	}
 }
 }
 
 

+ 0 - 1
test/mock/mock_IGameCallback.h

@@ -38,7 +38,6 @@ public:
 	void setObjPropertyValue(ObjectInstanceID objid, ObjProperty prop, int32_t value = 0) override {}
 	void setObjPropertyValue(ObjectInstanceID objid, ObjProperty prop, int32_t value = 0) override {}
 	void setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, ObjPropertyID identifier) override {}
 	void setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, ObjPropertyID identifier) override {}
 	void showInfoDialog(InfoWindow * iw) override {}
 	void showInfoDialog(InfoWindow * iw) override {}
-	void showInfoDialog(const std::string & msg, PlayerColor player) override {}
 
 
 	void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells) override {}
 	void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells) override {}
 	bool removeObject(const CGObjectInstance * obj, const PlayerColor & initiator) override {return false;}
 	bool removeObject(const CGObjectInstance * obj, const PlayerColor & initiator) override {return false;}