1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-14 02:33:51 +02:00

Merge branch 'develop' of https://github.com/vcmi/vcmi into develop

This commit is contained in:
DjWarmonger 2016-01-29 18:21:56 +01:00
commit ca4e13b2dc
16 changed files with 114 additions and 72 deletions

View File

@ -1069,7 +1069,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
LOCPLINT->proposeLoadingGame(); LOCPLINT->proposeLoadingGame();
return; return;
case SDLK_s: case SDLK_s:
if(isActive()) if(isActive() && key.type == SDL_KEYUP)
GH.pushInt(new CSavingScreen(CPlayerInterface::howManyPeople > 1)); GH.pushInt(new CSavingScreen(CPlayerInterface::howManyPeople > 1));
return; return;
case SDLK_d: case SDLK_d:

View File

@ -146,6 +146,8 @@
"mageGuild" : 4, "mageGuild" : 4,
"warMachine" : "ballista", "warMachine" : "ballista",
"moatDamage" : 70, "moatDamage" : 70,
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
"primaryResource": "ore", "primaryResource": "ore",
"buildings" : "buildings" :
{ {

View File

@ -151,6 +151,7 @@
"primaryResource" : "mercury", "primaryResource" : "mercury",
"warMachine" : "ballista", "warMachine" : "ballista",
"moatDamage" : 70, "moatDamage" : 70,
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
"buildings" : "buildings" :
{ {

View File

@ -146,6 +146,7 @@
"primaryResource" : "sulfur", "primaryResource" : "sulfur",
"warMachine" : "ballista", "warMachine" : "ballista",
"moatDamage" : 90, "moatDamage" : 90,
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
"buildings" : "buildings" :
{ {

View File

@ -144,9 +144,11 @@
], ],
"horde" : [ 0, -1 ], "horde" : [ 0, -1 ],
"mageGuild" : 3, "mageGuild" : 3,
"primaryResource":"ore",
"warMachine" : "firstAidTent", "warMachine" : "firstAidTent",
"moatDamage" : 90, "moatDamage" : 90,
"primaryResource":"ore", "moatHexes" : [ 10, 11, 27, 28, 43, 44, 60, 61, 76, 77, 94, 110, 111, 128, 129, 145, 146, 163, 164, 180, 181 ],
"buildings" : "buildings" :
{ {
"mageGuild1": { "id" : 0 }, "mageGuild1": { "id" : 0 },

View File

@ -147,6 +147,7 @@
"primaryResource" : "mercury", "primaryResource" : "mercury",
"warMachine" : "ammoCart", "warMachine" : "ammoCart",
"moatDamage" : 90, "moatDamage" : 90,
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
"buildings" : "buildings" :
{ {

View File

@ -148,9 +148,10 @@
], ],
"horde" : [ 0, -1 ], "horde" : [ 0, -1 ],
"mageGuild" : 5, "mageGuild" : 5,
"primaryResource": "ore",
"warMachine" : "firstAidTent", "warMachine" : "firstAidTent",
"moatDamage" : 70, "moatDamage" : 70,
"primaryResource": "ore", "moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
"buildings" : "buildings" :
{ {

View File

@ -151,6 +151,7 @@
"primaryResource" : "crystal", "primaryResource" : "crystal",
"warMachine" : "firstAidTent", "warMachine" : "firstAidTent",
"moatDamage" : 70, "moatDamage" : 70,
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
"buildings" : "buildings" :
{ {

View File

@ -145,6 +145,7 @@
"mageGuild" : 3, "mageGuild" : 3,
"warMachine" : "ammoCart", "warMachine" : "ammoCart",
"moatDamage" : 70, "moatDamage" : 70,
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
"buildings" : "buildings" :
{ {

View File

@ -146,6 +146,7 @@
"mageGuild" : 5, "mageGuild" : 5,
"warMachine" : "ammoCart", "warMachine" : "ammoCart",
"moatDamage" : 0, //TODO: minefield "moatDamage" : 0, //TODO: minefield
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
"buildings" : "buildings" :
{ {

View File

@ -230,6 +230,11 @@
"type":"number", "type":"number",
"description": "Damage dealt to creature that entered town moat during siege" "description": "Damage dealt to creature that entered town moat during siege"
}, },
"moatHexes": {
"type" : "array",
"description" : "Numbers of battlefield hexes affected by moat during siege",
"items" : { "type" : "number" }
},
"musicTheme": { "musicTheme": {
"type":"string", "type":"string",
"description": "Path to town music theme", "description": "Path to town music theme",

View File

@ -1,6 +1,7 @@
#include "StdInc.h" #include "StdInc.h"
#include "CObstacleInstance.h" #include "CObstacleInstance.h"
#include "CHeroHandler.h" #include "CHeroHandler.h"
#include "CTownHandler.h"
#include "VCMI_Lib.h" #include "VCMI_Lib.h"
#include "spells/CSpellHandler.h" #include "spells/CSpellHandler.h"
@ -145,7 +146,5 @@ void SpellCreatedObstacle::battleTurnPassed()
std::vector<BattleHex> MoatObstacle::getAffectedTiles() const std::vector<BattleHex> MoatObstacle::getAffectedTiles() const
{ {
//rrr... need initializer lists return VLC->townh->factions[ID]->town->moatHexes;
static const BattleHex moatHexes[] = {11, 28, 44, 61, 77, 111, 129, 146, 164, 181};
return std::vector<BattleHex>(moatHexes, moatHexes + ARRAY_COUNT(moatHexes));
} }

View File

@ -13,6 +13,7 @@
#include "filesystem/Filesystem.h" #include "filesystem/Filesystem.h"
#include "mapObjects/CObjectClassesHandler.h" #include "mapObjects/CObjectClassesHandler.h"
#include "mapObjects/CObjectHandler.h" #include "mapObjects/CObjectHandler.h"
#include "BattleHex.h"
/* /*
* CTownHandler.cpp, part of VCMI engine * CTownHandler.cpp, part of VCMI engine
@ -85,6 +86,12 @@ CTown::~CTown()
str.dellNull(); str.dellNull();
} }
std::vector<BattleHex> CTown::defaultMoatHexes()
{
static const std::vector<BattleHex> moatHexes = {11, 28, 44, 61, 77, 111, 129, 146, 164, 181};
return moatHexes;
}
CTownHandler::CTownHandler() CTownHandler::CTownHandler()
{ {
VLC->townh = this; VLC->townh = this;
@ -542,7 +549,13 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source)
town.moatDamage = source["moatDamage"].Float(); town.moatDamage = source["moatDamage"].Float();
// Compatability for <= 0.98f mods
if(source["moatHexes"].isNull())
{
town.moatHexes = CTown::defaultMoatHexes();
}
else
town.moatHexes = source["moatHexes"].convertTo<std::vector<BattleHex> >();
town.mageLevel = source["mageGuild"].Float(); town.mageLevel = source["mageGuild"].Float();
town.names = source["names"].convertTo<std::vector<std::string> >(); town.names = source["names"].convertTo<std::vector<std::string> >();

View File

@ -21,6 +21,7 @@ class CLegacyConfigParser;
class JsonNode; class JsonNode;
class CTown; class CTown;
class CFaction; class CFaction;
struct BattleHex;
/// a typical building encountered in every castle ;] /// a typical building encountered in every castle ;]
/// this is structure available to both client and server /// this is structure available to both client and server
@ -136,6 +137,8 @@ class DLL_LINKAGE CTown
public: public:
CTown(); CTown();
~CTown(); ~CTown();
// TODO: remove once save and mod compatability not needed
static std::vector<BattleHex> defaultMoatHexes();
CFaction * faction; CFaction * faction;
@ -156,6 +159,7 @@ public:
ui16 primaryRes; ui16 primaryRes;
ArtifactID warMachine; ArtifactID warMachine;
si32 moatDamage; si32 moatDamage;
std::vector<BattleHex> moatHexes;
// default chance for hero of specific class to appear in tavern, if field "tavern" was not set // default chance for hero of specific class to appear in tavern, if field "tavern" was not set
// resulting chance = sqrt(town.chance * heroClass.chance) // resulting chance = sqrt(town.chance * heroClass.chance)
ui32 defaultTavernChance; ui32 defaultTavernChance;
@ -205,7 +209,16 @@ public:
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & names & faction & creatures & dwellings & dwellingNames & buildings & hordeLvl & mageLevel h & names & faction & creatures & dwellings & dwellingNames & buildings & hordeLvl & mageLevel
& primaryRes & warMachine & clientInfo & moatDamage & defaultTavernChance; & primaryRes & warMachine & clientInfo & moatDamage;
if(version >= 758)
{
h & moatHexes;
}
else if(!h.saving)
{
moatHexes = defaultMoatHexes();
}
h & defaultTavernChance;
auto findNull = [](const std::pair<BuildingID, ConstTransitivePtr<CBuilding>> &building) auto findNull = [](const std::pair<BuildingID, ConstTransitivePtr<CBuilding>> &building)
{ return building.second == nullptr; }; { return building.second == nullptr; };

View File

@ -27,7 +27,7 @@
#include "mapping/CCampaignHandler.h" //for CCampaignState #include "mapping/CCampaignHandler.h" //for CCampaignState
#include "rmg/CMapGenerator.h" // for CMapGenOptions #include "rmg/CMapGenerator.h" // for CMapGenOptions
const ui32 version = 757; const ui32 version = 758;
const ui32 minSupportedVersion = 753; const ui32 minSupportedVersion = 753;
class CISer; class CISer;

View File

@ -45,20 +45,20 @@ static std::string & visitedTxt(const bool visited)
return VLC->generaltexth->allTexts[id]; return VLC->generaltexth->allTexts[id];
} }
bool CQuest::checkQuest (const CGHeroInstance * h) const bool CQuest::checkQuest(const CGHeroInstance * h) const
{ {
switch (missionType) switch (missionType)
{ {
case MISSION_NONE: case MISSION_NONE:
return true; return true;
case MISSION_LEVEL: case MISSION_LEVEL:
if (m13489val <= h->level) if(m13489val <= h->level)
return true; return true;
return false; return false;
case MISSION_PRIMARY_STAT: case MISSION_PRIMARY_STAT:
for (int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i) for(int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i)
{ {
if (h->getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(i)) < m2stats[i]) if(h->getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(i)) < m2stats[i])
return false; return false;
} }
return true; return true;
@ -68,9 +68,9 @@ bool CQuest::checkQuest (const CGHeroInstance * h) const
return true; return true;
return false; return false;
case MISSION_ART: case MISSION_ART:
for (auto & elem : m5arts) for(auto & elem : m5arts)
{ {
if (h->hasArt(elem, false, true)) if(h->hasArt(elem, false, true))
continue; continue;
return false; //if the artifact was not found return false; //if the artifact was not found
} }
@ -80,31 +80,31 @@ bool CQuest::checkQuest (const CGHeroInstance * h) const
std::vector<CStackBasicDescriptor>::const_iterator cre; std::vector<CStackBasicDescriptor>::const_iterator cre;
TSlots::const_iterator it; TSlots::const_iterator it;
ui32 count; ui32 count;
for (cre = m6creatures.begin(); cre != m6creatures.end(); ++cre) for(cre = m6creatures.begin(); cre != m6creatures.end(); ++cre)
{ {
for (count = 0, it = h->Slots().begin(); it != h->Slots().end(); ++it) for(count = 0, it = h->Slots().begin(); it != h->Slots().end(); ++it)
{ {
if (it->second->type == cre->type) if(it->second->type == cre->type)
count += it->second->count; count += it->second->count;
} }
if (count < cre->count) //not enough creatures of this kind if(count < cre->count) //not enough creatures of this kind
return false; return false;
} }
} }
return true; return true;
case MISSION_RESOURCES: case MISSION_RESOURCES:
for (Res::ERes i = Res::WOOD; i <= Res::GOLD; vstd::advance(i, +1)) //including Mithril ? for(Res::ERes i = Res::WOOD; i <= Res::GOLD; vstd::advance(i, +1)) //including Mithril ?
{ //Quest has no direct access to callback { //Quest has no direct access to callback
if (h->cb->getResource (h->tempOwner, i) < m7resources[i]) if(h->cb->getResource (h->tempOwner, i) < m7resources[i])
return false; return false;
} }
return true; return true;
case MISSION_HERO: case MISSION_HERO:
if (m13489val == h->type->ID.getNum()) if(m13489val == h->type->ID.getNum())
return true; return true;
return false; return false;
case MISSION_PLAYER: case MISSION_PLAYER:
if (m13489val == h->getOwner().getNum()) if(m13489val == h->getOwner().getNum())
return true; return true;
return false; return false;
default: default:
@ -112,17 +112,17 @@ bool CQuest::checkQuest (const CGHeroInstance * h) const
} }
} }
void CQuest::getVisitText (MetaString &iwText, std::vector<Component> &components, bool isCustom, bool firstVisit, const CGHeroInstance * h) const void CQuest::getVisitText(MetaString &iwText, std::vector<Component> &components, bool isCustom, bool firstVisit, const CGHeroInstance * h) const
{ {
std::string text; std::string text;
bool failRequirements = (h ? !checkQuest(h) : true); bool failRequirements = (h ? !checkQuest(h) : true);
if (firstVisit) if(firstVisit)
{ {
isCustom = isCustomFirst; isCustom = isCustomFirst;
iwText << (text = firstVisitText); iwText << (text = firstVisitText);
} }
else if (failRequirements) else if(failRequirements)
{ {
isCustom = isCustomNext; isCustom = isCustomNext;
iwText << (text = nextVisitText); iwText << (text = nextVisitText);
@ -131,15 +131,15 @@ void CQuest::getVisitText (MetaString &iwText, std::vector<Component> &component
{ {
case MISSION_LEVEL: case MISSION_LEVEL:
components.push_back(Component (Component::EXPERIENCE, 0, m13489val, 0)); components.push_back(Component (Component::EXPERIENCE, 0, m13489val, 0));
if (!isCustom) if(!isCustom)
iwText.addReplacement(m13489val); iwText.addReplacement(m13489val);
break; break;
case MISSION_PRIMARY_STAT: case MISSION_PRIMARY_STAT:
{ {
MetaString loot; MetaString loot;
for (int i = 0; i < 4; ++i) for(int i = 0; i < 4; ++i)
{ {
if (m2stats[i]) if(m2stats[i])
{ {
components.push_back(Component (Component::PRIM_SKILL, i, m2stats[i], 0)); components.push_back(Component (Component::PRIM_SKILL, i, m2stats[i], 0));
loot << "%d %s"; loot << "%d %s";
@ -153,19 +153,19 @@ void CQuest::getVisitText (MetaString &iwText, std::vector<Component> &component
break; break;
case MISSION_KILL_HERO: case MISSION_KILL_HERO:
components.push_back(Component(Component::HERO_PORTRAIT, heroPortrait, 0, 0)); components.push_back(Component(Component::HERO_PORTRAIT, heroPortrait, 0, 0));
if (!isCustom) if(!isCustom)
addReplacements(iwText, text); addReplacements(iwText, text);
break; break;
case MISSION_HERO: case MISSION_HERO:
//FIXME: portrait may not match hero, if custom portrait was set in map editor //FIXME: portrait may not match hero, if custom portrait was set in map editor
components.push_back(Component (Component::HERO_PORTRAIT, VLC->heroh->heroes[m13489val]->imageIndex, 0, 0)); components.push_back(Component (Component::HERO_PORTRAIT, VLC->heroh->heroes[m13489val]->imageIndex, 0, 0));
if (!isCustom) if(!isCustom)
iwText.addReplacement(VLC->heroh->heroes[m13489val]->name); iwText.addReplacement(VLC->heroh->heroes[m13489val]->name);
break; break;
case MISSION_KILL_CREATURE: case MISSION_KILL_CREATURE:
{ {
components.push_back(Component(stackToKill)); components.push_back(Component(stackToKill));
if (!isCustom) if(!isCustom)
{ {
addReplacements(iwText, text); addReplacements(iwText, text);
} }
@ -174,35 +174,35 @@ void CQuest::getVisitText (MetaString &iwText, std::vector<Component> &component
case MISSION_ART: case MISSION_ART:
{ {
MetaString loot; MetaString loot;
for (auto & elem : m5arts) for(auto & elem : m5arts)
{ {
components.push_back(Component (Component::ARTIFACT, elem, 0, 0)); components.push_back(Component (Component::ARTIFACT, elem, 0, 0));
loot << "%s"; loot << "%s";
loot.addReplacement(MetaString::ART_NAMES, elem); loot.addReplacement(MetaString::ART_NAMES, elem);
} }
if (!isCustom) if(!isCustom)
iwText.addReplacement(loot.buildList()); iwText.addReplacement(loot.buildList());
} }
break; break;
case MISSION_ARMY: case MISSION_ARMY:
{ {
MetaString loot; MetaString loot;
for (auto & elem : m6creatures) for(auto & elem : m6creatures)
{ {
components.push_back(Component(elem)); components.push_back(Component(elem));
loot << "%s"; loot << "%s";
loot.addReplacement(elem); loot.addReplacement(elem);
} }
if (!isCustom) if(!isCustom)
iwText.addReplacement(loot.buildList()); iwText.addReplacement(loot.buildList());
} }
break; break;
case MISSION_RESOURCES: case MISSION_RESOURCES:
{ {
MetaString loot; MetaString loot;
for (int i = 0; i < 7; ++i) for(int i = 0; i < 7; ++i)
{ {
if (m7resources[i]) if(m7resources[i])
{ {
components.push_back(Component (Component::RESOURCE, i, m7resources[i], 0)); components.push_back(Component (Component::RESOURCE, i, m7resources[i], 0));
loot << "%d %s"; loot << "%d %s";
@ -210,29 +210,29 @@ void CQuest::getVisitText (MetaString &iwText, std::vector<Component> &component
loot.addReplacement(MetaString::RES_NAMES, i); loot.addReplacement(MetaString::RES_NAMES, i);
} }
} }
if (!isCustom) if(!isCustom)
iwText.addReplacement(loot.buildList()); iwText.addReplacement(loot.buildList());
} }
break; break;
case MISSION_PLAYER: case MISSION_PLAYER:
components.push_back(Component (Component::FLAG, m13489val, 0, 0)); components.push_back(Component (Component::FLAG, m13489val, 0, 0));
if (!isCustom) if(!isCustom)
iwText.addReplacement(VLC->generaltexth->colors[m13489val]); iwText.addReplacement(VLC->generaltexth->colors[m13489val]);
break; break;
} }
} }
void CQuest::getRolloverText (MetaString &ms, bool onHover) const void CQuest::getRolloverText(MetaString &ms, bool onHover) const
{ {
// Quests with MISSION_NONE type don't have a text for them // Quests with MISSION_NONE type don't have a text for them
assert(missionType != MISSION_NONE); assert(missionType != MISSION_NONE);
if (onHover) if(onHover)
ms << "\n\n"; ms << "\n\n";
ms << VLC->generaltexth->quests[missionType-1][onHover ? 3 : 4][textOption]; ms << VLC->generaltexth->quests[missionType-1][onHover ? 3 : 4][textOption];
switch (missionType) switch(missionType)
{ {
case MISSION_LEVEL: case MISSION_LEVEL:
ms.addReplacement(boost::lexical_cast<std::string>(m13489val)); ms.addReplacement(boost::lexical_cast<std::string>(m13489val));
@ -306,10 +306,10 @@ void CQuest::getRolloverText (MetaString &ms, bool onHover) const
} }
} }
void CQuest::getCompletionText (MetaString &iwText, std::vector<Component> &components, bool isCustom, const CGHeroInstance * h) const void CQuest::getCompletionText(MetaString &iwText, std::vector<Component> &components, bool isCustom, const CGHeroInstance * h) const
{ {
iwText << completedText; iwText << completedText;
switch (missionType) switch(missionType)
{ {
case CQuest::MISSION_LEVEL: case CQuest::MISSION_LEVEL:
if (!isCustomComplete) if (!isCustomComplete)
@ -398,14 +398,14 @@ CGSeerHut::CGSeerHut() : IQuestObject()
void CGSeerHut::setObjToKill() void CGSeerHut::setObjToKill()
{ {
if (quest->missionType == CQuest::MISSION_KILL_CREATURE) if(quest->missionType == CQuest::MISSION_KILL_CREATURE)
{ {
quest->stackToKill = getCreatureToKill(false)->getStack(SlotID(0)); //FIXME: stacks tend to disappear (desync?) on server :? quest->stackToKill = getCreatureToKill(false)->getStack(SlotID(0)); //FIXME: stacks tend to disappear (desync?) on server :?
assert(quest->stackToKill.type); assert(quest->stackToKill.type);
quest->stackToKill.count = 0; //no count in info window quest->stackToKill.count = 0; //no count in info window
quest->stackDirection = checkDirection(); quest->stackDirection = checkDirection();
} }
else if (quest->missionType == CQuest::MISSION_KILL_HERO) else if(quest->missionType == CQuest::MISSION_KILL_HERO)
{ {
quest->heroName = getHeroToKill(false)->name; quest->heroName = getHeroToKill(false)->name;
quest->heroPortrait = getHeroToKill(false)->portrait; quest->heroPortrait = getHeroToKill(false)->portrait;
@ -416,7 +416,7 @@ void CGSeerHut::init()
{ {
seerName = *RandomGeneratorUtil::nextItem(VLC->generaltexth->seerNames, cb->gameState()->getRandomGenerator()); seerName = *RandomGeneratorUtil::nextItem(VLC->generaltexth->seerNames, cb->gameState()->getRandomGenerator());
quest->textOption = cb->gameState()->getRandomGenerator().nextInt(2); quest->textOption = cb->gameState()->getRandomGenerator().nextInt(2);
quest->completedOption = cb->gameState()->getRandomGenerator().nextInt(1, 5); quest->completedOption = cb->gameState()->getRandomGenerator().nextInt(1, 3);
} }
void CGSeerHut::initObj() void CGSeerHut::initObj()
@ -424,13 +424,13 @@ void CGSeerHut::initObj()
init(); init();
quest->progress = CQuest::NOT_ACTIVE; quest->progress = CQuest::NOT_ACTIVE;
if (quest->missionType) if(quest->missionType)
{ {
if (!quest->isCustomFirst) if(!quest->isCustomFirst)
quest->firstVisitText = VLC->generaltexth->quests[quest->missionType-1][0][quest->textOption]; quest->firstVisitText = VLC->generaltexth->quests[quest->missionType-1][0][quest->textOption];
if (!quest->isCustomNext) if(!quest->isCustomNext)
quest->nextVisitText = VLC->generaltexth->quests[quest->missionType-1][1][quest->textOption]; quest->nextVisitText = VLC->generaltexth->quests[quest->missionType-1][1][quest->textOption];
if (!quest->isCustomComplete) if(!quest->isCustomComplete)
quest->completedText = VLC->generaltexth->quests[quest->missionType-1][2][quest->textOption]; quest->completedText = VLC->generaltexth->quests[quest->missionType-1][2][quest->textOption];
} }
else else
@ -440,23 +440,23 @@ void CGSeerHut::initObj()
} }
} }
void CGSeerHut::getRolloverText (MetaString &text, bool onHover) const void CGSeerHut::getRolloverText(MetaString &text, bool onHover) const
{ {
quest->getRolloverText (text, onHover);//TODO: simplify? quest->getRolloverText (text, onHover);//TODO: simplify?
if (!onHover) if(!onHover)
text.addReplacement(seerName); text.addReplacement(seerName);
} }
std::string CGSeerHut::getHoverText(PlayerColor player) const std::string CGSeerHut::getHoverText(PlayerColor player) const
{ {
std::string hoverName = getObjectName(); std::string hoverName = getObjectName();
if (ID == Obj::SEER_HUT && quest->progress != CQuest::NOT_ACTIVE) if(ID == Obj::SEER_HUT && quest->progress != CQuest::NOT_ACTIVE)
{ {
hoverName = VLC->generaltexth->allTexts[347]; hoverName = VLC->generaltexth->allTexts[347];
boost::algorithm::replace_first(hoverName,"%s", seerName); boost::algorithm::replace_first(hoverName, "%s", seerName);
} }
if (quest->progress & quest->missionType) //rollover when the quest is active if(quest->progress & quest->missionType) //rollover when the quest is active
{ {
MetaString ms; MetaString ms;
getRolloverText (ms, true); getRolloverText (ms, true);
@ -495,7 +495,7 @@ void IQuestObject::getVisitText (MetaString &text, std::vector<Component> &compo
void CGSeerHut::getCompletionText(MetaString &text, std::vector<Component> &components, bool isCustom, const CGHeroInstance * h) const void CGSeerHut::getCompletionText(MetaString &text, std::vector<Component> &components, bool isCustom, const CGHeroInstance * h) const
{ {
quest->getCompletionText (text, components, isCustom, h); quest->getCompletionText (text, components, isCustom, h);
switch (rewardType) switch(rewardType)
{ {
case EXPERIENCE: components.push_back(Component (Component::EXPERIENCE, 0, h->calculateXp(rVal), 0)); case EXPERIENCE: components.push_back(Component (Component::EXPERIENCE, 0, h->calculateXp(rVal), 0));
break; break;
@ -522,7 +522,7 @@ void CGSeerHut::getCompletionText(MetaString &text, std::vector<Component> &comp
void CGSeerHut::setPropertyDer (ui8 what, ui32 val) void CGSeerHut::setPropertyDer (ui8 what, ui32 val)
{ {
switch (what) switch(what)
{ {
case 10: case 10:
quest->progress = static_cast<CQuest::Eprogress>(val); quest->progress = static_cast<CQuest::Eprogress>(val);
@ -532,44 +532,44 @@ void CGSeerHut::setPropertyDer (ui8 what, ui32 val)
void CGSeerHut::newTurn() const void CGSeerHut::newTurn() const
{ {
if (quest->lastDay >= 0 && quest->lastDay < cb->getDate()-1) //time is up if(quest->lastDay >= 0 && quest->lastDay <= cb->getDate() - 1) //time is up
{ {
cb->setObjProperty (id, CGSeerHut::OBJPROP_VISITED, CQuest::COMPLETE); cb->setObjProperty (id, CGSeerHut::OBJPROP_VISITED, CQuest::COMPLETE);
} }
} }
void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const void CGSeerHut::onHeroVisit(const CGHeroInstance * h) const
{ {
InfoWindow iw; InfoWindow iw;
iw.player = h->getOwner(); iw.player = h->getOwner();
if (quest->progress < CQuest::COMPLETE) if(quest->progress < CQuest::COMPLETE)
{ {
bool firstVisit = !quest->progress; bool firstVisit = !quest->progress;
bool failRequirements = !checkQuest(h); bool failRequirements = !checkQuest(h);
bool isCustom=false; bool isCustom = false;
if (firstVisit) if(firstVisit)
{ {
isCustom = quest->isCustomFirst; isCustom = quest->isCustomFirst;
cb->setObjProperty (id, CGSeerHut::OBJPROP_VISITED, CQuest::IN_PROGRESS); cb->setObjProperty(id, CGSeerHut::OBJPROP_VISITED, CQuest::IN_PROGRESS);
AddQuest aq; AddQuest aq;
aq.quest = QuestInfo (quest, this, visitablePos()); aq.quest = QuestInfo (quest, this, visitablePos());
aq.player = h->tempOwner; aq.player = h->tempOwner;
cb->sendAndApply (&aq); //TODO: merge with setObjProperty? cb->sendAndApply(&aq); //TODO: merge with setObjProperty?
} }
else if (failRequirements) else if(failRequirements)
{ {
isCustom = quest->isCustomNext; isCustom = quest->isCustomNext;
} }
if (firstVisit || failRequirements) if(firstVisit || failRequirements)
{ {
getVisitText (iw.text, iw.components, isCustom, firstVisit, h); getVisitText (iw.text, iw.components, isCustom, firstVisit, h);
cb->showInfoDialog(&iw); cb->showInfoDialog(&iw);
} }
if (!failRequirements) // propose completion, also on first visit if(!failRequirements) // propose completion, also on first visit
{ {
BlockingDialog bd (true, false); BlockingDialog bd (true, false);
bd.player = h->getOwner(); bd.player = h->getOwner();
@ -746,6 +746,7 @@ void CGQuestGuard::init()
{ {
blockVisit = true; blockVisit = true;
quest->textOption = cb->gameState()->getRandomGenerator().nextInt(3, 5); quest->textOption = cb->gameState()->getRandomGenerator().nextInt(3, 5);
quest->completedOption = cb->gameState()->getRandomGenerator().nextInt(4, 5);
} }
void CGQuestGuard::completeQuest(const CGHeroInstance *h) const void CGQuestGuard::completeQuest(const CGHeroInstance *h) const
@ -817,12 +818,12 @@ void CGBorderGuard::getRolloverText (MetaString &text, bool onHover) const
text << VLC->generaltexth->tentColors[subID] << " " << VLC->objtypeh->getObjectName(Obj::KEYMASTER); text << VLC->generaltexth->tentColors[subID] << " " << VLC->objtypeh->getObjectName(Obj::KEYMASTER);
} }
bool CGBorderGuard::checkQuest (const CGHeroInstance * h) const bool CGBorderGuard::checkQuest(const CGHeroInstance * h) const
{ {
return wasMyColorVisited (h->tempOwner); return wasMyColorVisited (h->tempOwner);
} }
void CGBorderGuard::onHeroVisit( const CGHeroInstance * h ) const void CGBorderGuard::onHeroVisit(const CGHeroInstance * h) const
{ {
if (wasMyColorVisited (h->getOwner()) ) if (wasMyColorVisited (h->getOwner()) )
{ {
@ -850,7 +851,7 @@ void CGBorderGuard::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answ
cb->removeObject(this); cb->removeObject(this);
} }
void CGBorderGate::onHeroVisit( const CGHeroInstance * h ) const //TODO: passability void CGBorderGate::onHeroVisit(const CGHeroInstance * h) const //TODO: passability
{ {
if (!wasMyColorVisited (h->getOwner()) ) if (!wasMyColorVisited (h->getOwner()) )
{ {