From 4c1c03cf37b6be8cf9c9d32b65b113d5f98b2aec Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Thu, 17 Sep 2009 14:27:28 +0000 Subject: [PATCH] Proper handling of bank names. --- hch/CObjectHandler.cpp | 21 +++++++++++++++------ hch/CObjectHandler.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index 79b239ffd..1a21e23bd 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -3876,6 +3876,15 @@ void CBank::initObj() daycounter = 0; multiplier = 1; } +const std::string & CBank::getHoverText() const +{ + hoverName = VLC->objh->creBanksNames[index]; + if (bc == NULL) + hoverName += " " + VLC->generaltexth->allTexts[352]; + else + hoverName += " " + VLC->generaltexth->allTexts[353]; + return hoverName; +} void CBank::reset(ui16 var1, ui16 var2) //prevents desync { ui8 chance = 0; @@ -4011,9 +4020,9 @@ void CBank::onHeroVisit (const CGHeroInstance * h) const BlockingDialog bd (true, false); bd.player = h->getOwner(); bd.soundID = soundBase::DANGER; - std::string desc = VLC->generaltexth->advobtxt[banktext]; - boost::algorithm::replace_first (desc, "%s", VLC->generaltexth->names[ID]); - bd.text << desc; + bd.text << VLC->generaltexth->advobtxt[banktext]; + if (ID == 16) + bd.text.addReplacement (VLC->objh->creBanksNames[index]); cb->showBlockingDialog (&bd, boost::bind (&CBank::fightGuards, this, h, _1)); } else @@ -4034,9 +4043,9 @@ void CBank::onHeroVisit (const CGHeroInstance * h) const } iw.soundID = soundBase::GRAVEYARD; iw.player = h->getOwner(); - std::string desc = VLC->generaltexth->advobtxt[33]; - boost::algorithm::replace_first (desc, "%s", VLC->generaltexth->names[ID]); - iw.text << desc; + iw.text << VLC->generaltexth->advobtxt[33]; + if (ID == 16 || ID == 24 || ID == 85) + iw.text.addReplacement (VLC->objh->creBanksNames[index]); cb->showInfoDialog(&iw); } } diff --git a/hch/CObjectHandler.h b/hch/CObjectHandler.h index ec29395ce..0c2f11988 100644 --- a/hch/CObjectHandler.h +++ b/hch/CObjectHandler.h @@ -874,6 +874,7 @@ class DLL_EXPORT CBank : public CArmedInstance ui32 daycounter; void initObj(); + const std::string & getHoverText() const; void setPropertyDer (ui8 what, ui32 val); void reset(ui16 var1, ui16 var2); void newTurn() const;