Browse Source

Rename hero strings to text id

nordsoft 2 years ago
parent
commit
5b97c323d3

+ 4 - 4
client/lobby/OptionsTab.cpp

@@ -405,8 +405,8 @@ std::string OptionsTab::CPlayerSettingsHelper::getName()
 			return CGI->generaltexth->allTexts[522];
 		default:
 		{
-			if(!playerSettings.heroName.empty())
-				return playerSettings.heroName;
+			if(!playerSettings.heroNameTextId.empty())
+				return playerSettings.heroNameTextId;
 			auto index = playerSettings.hero.getNum() >= CGI->heroh->size() ? 0 : playerSettings.hero.getNum();
 			return (*CGI->heroh)[index]->getNameTranslated();
 		}
@@ -927,7 +927,7 @@ void OptionsTab::SelectionWindow::setElement(int elem, bool doApply)
 			if(!doApply)
 			{
 				CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::HERO);
-				if(settings["general"]["enableUiEnhancements"].Bool() && helper.playerSettings.hero.getNum() > PlayerSettings::RANDOM && helper.playerSettings.heroName.empty())
+				if(settings["general"]["enableUiEnhancements"].Bool() && helper.playerSettings.hero.getNum() > PlayerSettings::RANDOM && helper.playerSettings.heroNameTextId.empty())
 					GH.windows().createAndPushWindow<CHeroOverview>(helper.playerSettings.hero);
 				else
 					GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
@@ -1013,7 +1013,7 @@ void OptionsTab::SelectedBox::showPopupWindow(const Point & cursorPosition)
 	if(playerSettings.hero.getNum() == PlayerSettings::NONE && !SEL->getPlayerInfo(playerSettings.color.getNum()).hasCustomMainHero() && CPlayerSettingsHelper::type == HERO)
 		return;
 
-	if(settings["general"]["enableUiEnhancements"].Bool() && CPlayerSettingsHelper::type == HERO && playerSettings.hero.getNum() > PlayerSettings::RANDOM && playerSettings.heroName.empty())
+	if(settings["general"]["enableUiEnhancements"].Bool() && CPlayerSettingsHelper::type == HERO && playerSettings.hero.getNum() > PlayerSettings::RANDOM && playerSettings.heroNameTextId.empty())
 		GH.windows().createAndPushWindow<CHeroOverview>(playerSettings.hero);
 	else
 		GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(*this);

+ 2 - 2
lib/StartInfo.h

@@ -59,7 +59,7 @@ struct DLL_LINKAGE PlayerSettings
 	HeroTypeID hero;
 	HeroTypeID heroPortrait; //-1 if default, else ID
 
-	std::string heroName;
+	std::string heroNameTextId;
 	PlayerColor color; //from 0 -
 	enum EHandicap {NO_HANDICAP, MILD, SEVERE};
 	EHandicap handicap;//0-no, 1-mild, 2-severe
@@ -73,7 +73,7 @@ struct DLL_LINKAGE PlayerSettings
 		h & castle;
 		h & hero;
 		h & heroPortrait;
-		h & heroName;
+		h & heroNameTextId;
 		h & bonus;
 		h & color;
 		h & handicap;

+ 1 - 1
lib/mapping/CMapHeader.cpp

@@ -62,7 +62,7 @@ bool PlayerInfo::canAnyonePlay() const
 
 bool PlayerInfo::hasCustomMainHero() const
 {
-	return !mainCustomHeroName.empty() && mainCustomHeroPortrait != -1;
+	return !mainCustomHeroNameTextId.empty() && mainCustomHeroPortrait != -1;
 }
 
 EventCondition::EventCondition(EWinLoseType condition):

+ 2 - 2
lib/mapping/CMapHeader.h

@@ -63,7 +63,7 @@ struct DLL_LINKAGE PlayerInfo
 	bool hasRandomHero;
 	/// The default value is -1.
 	si32 mainCustomHeroPortrait;
-	std::string mainCustomHeroName;
+	std::string mainCustomHeroNameTextId;
 	/// ID of custom hero (only if portrait and hero name are set, otherwise unpredicted value), -1 if none (not always -1)
 	si32 mainCustomHeroId;
 
@@ -84,7 +84,7 @@ struct DLL_LINKAGE PlayerInfo
 		h & allowedFactions;
 		h & isFactionRandom;
 		h & mainCustomHeroPortrait;
-		h & mainCustomHeroName;
+		h & mainCustomHeroNameTextId;
 		h & heroesNames;
 		h & hasMainTown;
 		h & generateHeroAtMainTown;

+ 1 - 1
lib/mapping/MapFormatH3M.cpp

@@ -253,7 +253,7 @@ void CMapLoaderH3M::readPlayerInfo()
 		if(playerInfo.mainCustomHeroId != -1)
 		{
 			playerInfo.mainCustomHeroPortrait = reader->readHeroPortrait();
-			playerInfo.mainCustomHeroName = readLocalizedString(TextIdentifier("header", "player", i, "mainHeroName"));
+			playerInfo.mainCustomHeroNameTextId = readLocalizedString(TextIdentifier("header", "player", i, "mainHeroName"));
 		}
 
 		if(features.levelAB)

+ 1 - 1
lib/mapping/MapFormatJson.cpp

@@ -571,7 +571,7 @@ void CMapFormatJson::serializePlayerInfo(JsonSerializeFormat & handler)
 				if(instanceName == info.mainHeroInstance)
 				{
 					//this is main hero
-					info.mainCustomHeroName = hname.heroName;
+					info.mainCustomHeroNameTextId = hname.heroName;
 					info.hasRandomHero = (hname.heroId == -1);
 					info.mainCustomHeroId = hname.heroId;
 					info.mainCustomHeroPortrait = -1;

+ 1 - 1
server/CVCMIServer.cpp

@@ -730,7 +730,7 @@ void CVCMIServer::updateStartInfoOnMapChange(std::shared_ptr<CMapInfo> mapInfo,
 			if(pset.hero.getNum() != PlayerSettings::RANDOM && pinfo.hasCustomMainHero())
 			{
 				pset.hero = pinfo.mainCustomHeroId;
-				pset.heroName = pinfo.mainCustomHeroName;
+				pset.heroNameTextId = pinfo.mainCustomHeroNameTextId;
 				pset.heroPortrait = pinfo.mainCustomHeroPortrait;
 			}
 

+ 1 - 1
test/game/CGameStateTest.cpp

@@ -170,7 +170,7 @@ public:
 			if(pset.hero.getNum() != PlayerSettings::RANDOM && pinfo.hasCustomMainHero())
 			{
 				pset.hero = pinfo.mainCustomHeroId;
-				pset.heroName = pinfo.mainCustomHeroName;
+				pset.heroNameTextId = pinfo.mainCustomHeroNameTextId;
 				pset.heroPortrait = pinfo.mainCustomHeroPortrait;
 			}
 

+ 1 - 1
test/map/MapComparer.cpp

@@ -76,7 +76,7 @@ void checkEqual(const PlayerInfo & actual, const PlayerInfo & expected)
 
 	VCMI_CHECK_FIELD_EQUAL(isFactionRandom);
 	VCMI_CHECK_FIELD_EQUAL(mainCustomHeroPortrait);
-	VCMI_CHECK_FIELD_EQUAL(mainCustomHeroName);
+	VCMI_CHECK_FIELD_EQUAL(mainCustomHeroNameTextId);
 
 	VCMI_CHECK_FIELD_EQUAL(mainCustomHeroId);