From b1a569910ba9a05786519d58bdd4a3c27265ea42 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Tue, 23 Jul 2013 05:41:42 +0000 Subject: [PATCH] Fixed #1378. --- lib/CObjectHandler.cpp | 34 ++++++++++++++-------------------- lib/CObjectHandler.h | 7 ++++--- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/lib/CObjectHandler.cpp b/lib/CObjectHandler.cpp index 0c8a380c4..538fc7ad6 100644 --- a/lib/CObjectHandler.cpp +++ b/lib/CObjectHandler.cpp @@ -4400,10 +4400,10 @@ void CQuest::getVisitText (MetaString &iwText, std::vector &component switch (missionType) { case MISSION_LEVEL: - components.push_back(Component (Component::EXPERIENCE, 1, m13489val, 0)); - if (!isCustom) - iwText.addReplacement(m13489val); - break; + components.push_back(Component (Component::EXPERIENCE, 1, m13489val, 0)); + if (!isCustom) + iwText.addReplacement(m13489val); + break; case MISSION_PRIMARY_STAT: { MetaString loot; @@ -4666,10 +4666,16 @@ void CGSeerHut::setObjToKill() } } -void CGSeerHut::initObj() +void CGSeerHut::init() { seerName = VLC->generaltexth->seerNames[ran()%VLC->generaltexth->seerNames.size()]; - quest->textOption = ran()%3; + quest->textOption = ran() % 3; +} + +void CGSeerHut::initObj() +{ + init(); + quest->progress = CQuest::NOT_ACTIVE; if (quest->missionType) { @@ -4986,22 +4992,10 @@ void CGSeerHut::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) finishQuest(hero, answer); } -void CGQuestGuard::initObj() +void CGQuestGuard::init() { blockVisit = true; - quest->progress = CQuest::NOT_ACTIVE; - quest->textOption = ran()%3 + 3; //3-5 - if (quest->missionType) - { - if (!quest->isCustomFirst) - quest->firstVisitText = VLC->generaltexth->quests[quest->missionType-1][0][quest->textOption]; - if (!quest->isCustomNext) - quest->nextVisitText = VLC->generaltexth->quests[quest->missionType-1][1][quest->textOption]; - if (!quest->isCustomComplete) - quest->completedText = VLC->generaltexth->quests[quest->missionType-1][2][quest->textOption]; - } - else - quest->firstVisitText = VLC->generaltexth->seerEmpty[quest->textOption]; + quest->textOption = (ran() % 3) + 3; //3-5 } void CGQuestGuard::completeQuest(const CGHeroInstance *h) const { diff --git a/lib/CObjectHandler.h b/lib/CObjectHandler.h index fc7937942..6589c1fb9 100644 --- a/lib/CObjectHandler.h +++ b/lib/CObjectHandler.h @@ -837,6 +837,7 @@ public: void onHeroVisit(const CGHeroInstance * h) const override; void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override; + virtual void init(); int checkDirection() const; //calculates the region of map where monster is placed void setObjToKill(); //remember creatures / heroes to kill after they are initialized const CGHeroInstance *getHeroToKill(bool allowNull = false) const; @@ -844,7 +845,7 @@ public: void getRolloverText (MetaString &text, bool onHover) const; void getCompletionText(MetaString &text, std::vector &components, bool isCustom, const CGHeroInstance * h = nullptr) const; void finishQuest (const CGHeroInstance * h, ui32 accept) const; //common for both objects - void completeQuest (const CGHeroInstance * h) const; + virtual void completeQuest (const CGHeroInstance * h) const; template void serialize(Handler &h, const int version) { @@ -859,8 +860,8 @@ class DLL_LINKAGE CGQuestGuard : public CGSeerHut { public: CGQuestGuard() : CGSeerHut(){}; - void initObj() override; - void completeQuest (const CGHeroInstance * h) const; + void init() override; + void completeQuest (const CGHeroInstance * h) const override; template void serialize(Handler &h, const int version) {