diff --git a/client/ClientNetPackVisitors.h b/client/ClientNetPackVisitors.h index fc7714b5f..1a2813a02 100644 --- a/client/ClientNetPackVisitors.h +++ b/client/ClientNetPackVisitors.h @@ -104,6 +104,7 @@ public: void visitSetAvailableArtifacts(SetAvailableArtifacts & pack) override; void visitEntitiesChanged(EntitiesChanged & pack) override; void visitPlayerCheated(PlayerCheated & pack) override; + void visitChangeTownName(ChangeTownName & pack) override; }; class ApplyFirstClientNetPackVisitor : public VCMI_LIB_WRAP_NAMESPACE(ICPackVisitor) diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index 29a8558f9..5e74691f0 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -1071,3 +1071,16 @@ void ApplyClientNetPackVisitor::visitPlayerCheated(PlayerCheated & pack) if(pack.colorScheme != ColorScheme::KEEP && vstd::contains(cl.playerint, pack.player)) cl.playerint[pack.player]->setColorScheme(pack.colorScheme); } + +void ApplyClientNetPackVisitor::visitChangeTownName(ChangeTownName & pack) +{ + if(!adventureInt) + return; + + const CGTownInstance *town = gs.getTown(pack.tid); + if(town) + { + adventureInt->onTownChanged(town); + ENGINE->windows().totalRedraw(); + } +} diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index 6308604ee..3832c3b0d 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -1438,6 +1438,9 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst heroes = std::make_shared(town, Point(241, 387), Point(241, 483), garr, true); title = std::make_shared(Rect(83, 386, 140, 20), FONT_MEDIUM, ETextAlignment::TOPLEFT, town->getNameTranslated(), true, [this](){ std::string name = title->getText(); + std::string originalName = LIBRARY->generaltexth->translate(town->getNameTextID()); + if(name == originalName) + name = ""; // use textID again GAME->interface()->cb->setTownName(town, name); }); income = std::make_shared(195, 443, FONT_SMALL, ETextAlignment::CENTER);