From 0c94a4d8910dbf36c2a5e1c7e47ec308bd99d24b Mon Sep 17 00:00:00 2001 From: nordsoft Date: Wed, 27 Sep 2023 23:57:05 +0200 Subject: [PATCH] Town name switched to id --- lib/gameState/CGameState.cpp | 2 +- lib/mapObjects/CGTownInstance.cpp | 20 ++++++++++---------- lib/mapObjects/CGTownInstance.h | 8 ++++---- lib/mapping/MapFormatH3M.cpp | 2 +- mapeditor/inspector/inspector.cpp | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index f5657821c..dd3c72a5e 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -1020,7 +1020,7 @@ void CGameState::initTowns() if(vti->getNameTranslated().empty()) { size_t nameID = getRandomGenerator().nextInt(vti->getTown()->getRandomNamesCount() - 1); - vti->setNameTranslated(vti->getTown()->getRandomNameTranslated(nameID)); + vti->setNameTextId(vti->getTown()->getRandomNameTextID(nameID)); } static const BuildingID basicDwellings[] = { BuildingID::DWELL_FIRST, BuildingID::DWELL_LVL_2, BuildingID::DWELL_LVL_3, BuildingID::DWELL_LVL_4, BuildingID::DWELL_LVL_5, BuildingID::DWELL_LVL_6, BuildingID::DWELL_LVL_7 }; diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index b82fe8d68..bf8b25124 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -327,7 +327,7 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const } else { - logGlobal->error("%s visits allied town of %s from different pos?", h->getNameTranslated(), name); + logGlobal->error("%s visits allied town of %s from different pos?", h->getNameTranslated(), nameTextId); } } @@ -337,15 +337,15 @@ void CGTownInstance::onHeroLeave(const CGHeroInstance * h) const if(visitingHero == h) { cb->stopHeroVisitCastle(this, h); - logGlobal->trace("%s correctly left town %s", h->getNameTranslated(), name); + logGlobal->trace("%s correctly left town %s", h->getNameTranslated(), nameTextId); } else - logGlobal->warn("Warning, %s tries to leave the town %s but hero is not inside.", h->getNameTranslated(), name); + logGlobal->warn("Warning, %s tries to leave the town %s but hero is not inside.", h->getNameTranslated(), nameTextId); } std::string CGTownInstance::getObjectName() const { - return name + ", " + town->faction->getNameTranslated(); + return nameTextId + ", " + town->faction->getNameTranslated(); } bool CGTownInstance::townEnvisagesBuilding(BuildingSubID::EBuildingSubID subId) const @@ -767,7 +767,7 @@ void CGTownInstance::updateAppearance() std::string CGTownInstance::nodeName() const { - return "Town (" + (town ? town->faction->getNameTranslated() : "unknown") + ") of " + name; + return "Town (" + (town ? town->faction->getNameTranslated() : "unknown") + ") of " + nameTextId; } void CGTownInstance::deserializationFix() @@ -915,12 +915,12 @@ CBonusSystemNode & CGTownInstance::whatShouldBeAttached() std::string CGTownInstance::getNameTranslated() const { - return name; + return VLC->generaltexth->translate(nameTextId); } -void CGTownInstance::setNameTranslated( const std::string & newName ) +void CGTownInstance::setNameTextId( const std::string & newName ) { - name = newName; + nameTextId = newName; } const CArmedInstance * CGTownInstance::getUpperArmy() const @@ -980,7 +980,7 @@ TResources CGTownInstance::getBuildingCost(const BuildingID & buildingID) const return town->buildings.at(buildingID)->resources; else { - logGlobal->error("Town %s at %s has no possible building %d!", name, pos.toString(), buildingID.toEnum()); + logGlobal->error("Town %s at %s has no possible building %d!", nameTextId, pos.toString(), buildingID.toEnum()); return TResources(); } @@ -1097,7 +1097,7 @@ void CGTownInstance::serializeJsonOptions(JsonSerializeFormat & handler) if(!handler.saving) handler.serializeEnum("tightFormation", formation, NArmyFormation::names); //for old format CArmedInstance::serializeJsonOptions(handler); - handler.serializeString("name", name); + handler.serializeString("name", nameTextId); { auto decodeBuilding = [this](const std::string & identifier) -> si32 diff --git a/lib/mapObjects/CGTownInstance.h b/lib/mapObjects/CGTownInstance.h index 6f47cf525..07da57644 100644 --- a/lib/mapObjects/CGTownInstance.h +++ b/lib/mapObjects/CGTownInstance.h @@ -44,7 +44,7 @@ struct DLL_LINKAGE GrowthInfo class DLL_LINKAGE CGTownInstance : public CGDwelling, public IShipyard, public IMarket, public INativeTerrainProvider, public ICreatureUpgrader { - std::string name; // name of town + std::string nameTextId; // name of town public: using CGDwelling::getPosition; @@ -73,7 +73,7 @@ public: template void serialize(Handler &h, const int version) { h & static_cast(*this); - h & name; + h & nameTextId; h & builded; h & destroyed; h & identifier; @@ -102,7 +102,7 @@ public: { if(!town->buildings.count(building) || !town->buildings.at(building)) { - logGlobal->error("#1444-like issue in CGTownInstance::serialize. From town %s at %s removing the bogus builtBuildings item %s", name, pos.toString(), building); + logGlobal->error("#1444-like issue in CGTownInstance::serialize. From town %s at %s removing the bogus builtBuildings item %s", nameTextId, pos.toString(), building); return true; } return false; @@ -126,7 +126,7 @@ public: const CArmedInstance *getUpperArmy() const; //garrisoned hero if present or the town itself std::string getNameTranslated() const; - void setNameTranslated(const std::string & newName); + void setNameTextId(const std::string & newName); ////////////////////////////////////////////////////////////////////////// diff --git a/lib/mapping/MapFormatH3M.cpp b/lib/mapping/MapFormatH3M.cpp index ba6fcaba2..90aeba11e 100644 --- a/lib/mapping/MapFormatH3M.cpp +++ b/lib/mapping/MapFormatH3M.cpp @@ -2094,7 +2094,7 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt bool hasName = reader->readBool(); if(hasName) - object->setNameTranslated(readLocalizedString(TextIdentifier("town", position.x, position.y, position.z, "name"))); + object->setNameTextId(readLocalizedString(TextIdentifier("town", position.x, position.y, position.z, "name"))); bool hasGarrison = reader->readBool(); if(hasGarrison) diff --git a/mapeditor/inspector/inspector.cpp b/mapeditor/inspector/inspector.cpp index 9955d207b..b32b9092e 100644 --- a/mapeditor/inspector/inspector.cpp +++ b/mapeditor/inspector/inspector.cpp @@ -553,7 +553,7 @@ void Inspector::setProperty(CGTownInstance * o, const QString & key, const QVari if(!o) return; if(key == "Town name") - o->setNameTranslated(value.toString().toStdString()); + o->setNameTextId(value.toString().toStdString()); } void Inspector::setProperty(CGSignBottle * o, const QString & key, const QVariant & value)