1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Town name switched to id

This commit is contained in:
nordsoft
2023-09-27 23:57:05 +02:00
parent 41da252e67
commit 0c94a4d891
5 changed files with 17 additions and 17 deletions

View File

@@ -1020,7 +1020,7 @@ void CGameState::initTowns()
if(vti->getNameTranslated().empty()) if(vti->getNameTranslated().empty())
{ {
size_t nameID = getRandomGenerator().nextInt(vti->getTown()->getRandomNamesCount() - 1); 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 }; 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 };

View File

@@ -327,7 +327,7 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const
} }
else 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) if(visitingHero == h)
{ {
cb->stopHeroVisitCastle(this, 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 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 std::string CGTownInstance::getObjectName() const
{ {
return name + ", " + town->faction->getNameTranslated(); return nameTextId + ", " + town->faction->getNameTranslated();
} }
bool CGTownInstance::townEnvisagesBuilding(BuildingSubID::EBuildingSubID subId) const bool CGTownInstance::townEnvisagesBuilding(BuildingSubID::EBuildingSubID subId) const
@@ -767,7 +767,7 @@ void CGTownInstance::updateAppearance()
std::string CGTownInstance::nodeName() const 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() void CGTownInstance::deserializationFix()
@@ -915,12 +915,12 @@ CBonusSystemNode & CGTownInstance::whatShouldBeAttached()
std::string CGTownInstance::getNameTranslated() const 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 const CArmedInstance * CGTownInstance::getUpperArmy() const
@@ -980,7 +980,7 @@ TResources CGTownInstance::getBuildingCost(const BuildingID & buildingID) const
return town->buildings.at(buildingID)->resources; return town->buildings.at(buildingID)->resources;
else 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(); return TResources();
} }
@@ -1097,7 +1097,7 @@ void CGTownInstance::serializeJsonOptions(JsonSerializeFormat & handler)
if(!handler.saving) if(!handler.saving)
handler.serializeEnum("tightFormation", formation, NArmyFormation::names); //for old format handler.serializeEnum("tightFormation", formation, NArmyFormation::names); //for old format
CArmedInstance::serializeJsonOptions(handler); CArmedInstance::serializeJsonOptions(handler);
handler.serializeString("name", name); handler.serializeString("name", nameTextId);
{ {
auto decodeBuilding = [this](const std::string & identifier) -> si32 auto decodeBuilding = [this](const std::string & identifier) -> si32

View File

@@ -44,7 +44,7 @@ struct DLL_LINKAGE GrowthInfo
class DLL_LINKAGE CGTownInstance : public CGDwelling, public IShipyard, public IMarket, public INativeTerrainProvider, public ICreatureUpgrader 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: public:
using CGDwelling::getPosition; using CGDwelling::getPosition;
@@ -73,7 +73,7 @@ public:
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & static_cast<CGDwelling&>(*this); h & static_cast<CGDwelling&>(*this);
h & name; h & nameTextId;
h & builded; h & builded;
h & destroyed; h & destroyed;
h & identifier; h & identifier;
@@ -102,7 +102,7 @@ public:
{ {
if(!town->buildings.count(building) || !town->buildings.at(building)) 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 true;
} }
return false; return false;
@@ -126,7 +126,7 @@ public:
const CArmedInstance *getUpperArmy() const; //garrisoned hero if present or the town itself const CArmedInstance *getUpperArmy() const; //garrisoned hero if present or the town itself
std::string getNameTranslated() const; std::string getNameTranslated() const;
void setNameTranslated(const std::string & newName); void setNameTextId(const std::string & newName);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@@ -2094,7 +2094,7 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
bool hasName = reader->readBool(); bool hasName = reader->readBool();
if(hasName) 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(); bool hasGarrison = reader->readBool();
if(hasGarrison) if(hasGarrison)

View File

@@ -553,7 +553,7 @@ void Inspector::setProperty(CGTownInstance * o, const QString & key, const QVari
if(!o) return; if(!o) return;
if(key == "Town name") 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) void Inspector::setProperty(CGSignBottle * o, const QString & key, const QVariant & value)