mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
- Removed pointer usage for CQuest. may look rough, but works and fixes #1051.
- Better autoSkip mode, now info windows are not displayed.
This commit is contained in:
parent
786bd73e67
commit
0435d5a4f1
@ -2170,26 +2170,26 @@ void VCAI::striveToGoal(const CGoal &ultimateGoal)
|
||||
|
||||
void VCAI::striveToQuest (const QuestInfo &q)
|
||||
{
|
||||
if (q.quest && q.quest->progress < CQuest::COMPLETE)
|
||||
if (q.quest.progress < CQuest::COMPLETE)
|
||||
{
|
||||
MetaString ms;
|
||||
q.quest->getRolloverText(ms, false);
|
||||
q.quest.getRolloverText(ms, false);
|
||||
BNLOG ("Trying to realize quest: %s", ms.toString());
|
||||
auto heroes = cb->getHeroesInfo();
|
||||
|
||||
switch (q.quest->missionType)
|
||||
switch (q.quest.missionType)
|
||||
{
|
||||
case CQuest::MISSION_ART:
|
||||
{
|
||||
BOOST_FOREACH (auto hero, heroes) //TODO: remove duplicated code?
|
||||
{
|
||||
if (q.quest->checkQuest(hero))
|
||||
if (q.quest.checkQuest(hero))
|
||||
{
|
||||
striveToGoal (CGoal(GET_OBJ).setobjid(q.obj->id).sethero(hero));
|
||||
return;
|
||||
}
|
||||
}
|
||||
BOOST_FOREACH (auto art, q.quest->m5arts)
|
||||
BOOST_FOREACH (auto art, q.quest.m5arts)
|
||||
{
|
||||
striveToGoal (CGoal(GET_ART_TYPE).setaid(art)); //TODO: transport?
|
||||
}
|
||||
@ -2200,7 +2200,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
||||
//striveToGoal (CGoal(RECRUIT_HERO));
|
||||
BOOST_FOREACH (auto hero, heroes)
|
||||
{
|
||||
if (q.quest->checkQuest(hero))
|
||||
if (q.quest.checkQuest(hero))
|
||||
{
|
||||
striveToGoal (CGoal(GET_OBJ).setobjid(q.obj->id).sethero(hero));
|
||||
return;
|
||||
@ -2214,13 +2214,13 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
||||
{
|
||||
BOOST_FOREACH (auto hero, heroes)
|
||||
{
|
||||
if (q.quest->checkQuest(hero)) //veyr bad info - stacks can be split between multiple heroes :(
|
||||
if (q.quest.checkQuest(hero)) //veyr bad info - stacks can be split between multiple heroes :(
|
||||
{
|
||||
striveToGoal (CGoal(GET_OBJ).setobjid(q.obj->id).sethero(hero));
|
||||
return;
|
||||
}
|
||||
}
|
||||
BOOST_FOREACH (auto creature, q.quest->m6creatures)
|
||||
BOOST_FOREACH (auto creature, q.quest.m6creatures)
|
||||
{
|
||||
striveToGoal (CGoal(GATHER_TROOPS).setobjid(creature.type->idNumber).setvalue(creature.count));
|
||||
}
|
||||
@ -2232,16 +2232,16 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
||||
{
|
||||
if (heroes.size())
|
||||
{
|
||||
if (q.quest->checkQuest(heroes.front())) //it doesn't matter which hero it is
|
||||
if (q.quest.checkQuest(heroes.front())) //it doesn't matter which hero it is
|
||||
{
|
||||
striveToGoal (CGoal(VISIT_TILE).settile(q.tile));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < q.quest->m7resources.size(); ++i)
|
||||
for (int i = 0; i < q.quest.m7resources.size(); ++i)
|
||||
{
|
||||
if (q.quest->m7resources[i])
|
||||
striveToGoal (CGoal(COLLECT_RES).setresID(i).setvalue(q.quest->m7resources[i]));
|
||||
if (q.quest.m7resources[i])
|
||||
striveToGoal (CGoal(COLLECT_RES).setresID(i).setvalue(q.quest.m7resources[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2252,7 +2252,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
||||
case CQuest::MISSION_KILL_HERO:
|
||||
case CQuest::MISSION_KILL_CREATURE:
|
||||
{
|
||||
auto obj = cb->getObjByQuestIdentifier(q.quest->m13489val);
|
||||
auto obj = cb->getObjByQuestIdentifier(q.quest.m13489val);
|
||||
if (obj)
|
||||
striveToGoal (CGoal(GET_OBJ).setobjid(obj->id));
|
||||
else
|
||||
@ -2264,13 +2264,13 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
||||
auto heroes = cb->getHeroesInfo();
|
||||
BOOST_FOREACH (auto hero, heroes)
|
||||
{
|
||||
if (q.quest->checkQuest(hero))
|
||||
if (q.quest.checkQuest(hero))
|
||||
{
|
||||
striveToGoal (CGoal(GET_OBJ).setobjid(q.obj->id).sethero(hero));
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < q.quest->m2stats.size(); ++i)
|
||||
for (int i = 0; i < q.quest.m2stats.size(); ++i)
|
||||
{
|
||||
BNLOG ("Don't know how to increase primary stat %d\n", i);
|
||||
}
|
||||
@ -2281,19 +2281,19 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
||||
auto heroes = cb->getHeroesInfo();
|
||||
BOOST_FOREACH (auto hero, heroes)
|
||||
{
|
||||
if (q.quest->checkQuest(hero))
|
||||
if (q.quest.checkQuest(hero))
|
||||
{
|
||||
striveToGoal (CGoal(VISIT_TILE).settile(q.tile).sethero(hero)); //TODO: causes infinite loop :/
|
||||
return;
|
||||
}
|
||||
}
|
||||
BNLOG ("Don't know how to reach hero level %d\n", q.quest->m13489val);
|
||||
BNLOG ("Don't know how to reach hero level %d\n", q.quest.m13489val);
|
||||
break;
|
||||
}
|
||||
case CQuest::MISSION_PLAYER:
|
||||
{
|
||||
if (playerID != q.quest->m13489val)
|
||||
BNLOG ("Can't be player of color %d\n", q.quest->m13489val);
|
||||
if (playerID != q.quest.m13489val)
|
||||
BNLOG ("Can't be player of color %d\n", q.quest.m13489val);
|
||||
break;
|
||||
}
|
||||
case CQuest::MISSION_KEYMASTER:
|
||||
@ -3467,7 +3467,7 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
|
||||
{
|
||||
if (q.obj == obj)
|
||||
{
|
||||
if (q.quest->checkQuest(*h))
|
||||
if (q.quest.checkQuest(*h))
|
||||
return true; //we completed the quest
|
||||
else
|
||||
return false; //we can't complete this quest
|
||||
|
@ -942,10 +942,15 @@ void CPlayerInterface::showComp(const Component &comp, std::string message)
|
||||
void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector<Component*> &components, int soundID)
|
||||
{
|
||||
EVENT_HANDLER_CALLED_BY_CLIENT;
|
||||
if (settings["session"]["autoSkip"].Bool() && !LOCPLINT->shiftPressed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
std::vector<CComponent*> intComps;
|
||||
for(int i=0;i<components.size();i++)
|
||||
intComps.push_back(new CComponent(*components[i]));
|
||||
showInfoDialog(text,intComps,soundID);
|
||||
|
||||
}
|
||||
|
||||
void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector<CComponent*> & components, int soundID, bool delComps)
|
||||
@ -953,6 +958,10 @@ void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector
|
||||
waitWhileDialog();
|
||||
|
||||
stopMovement();
|
||||
if (settings["session"]["autoSkip"].Bool() && !LOCPLINT->shiftPressed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CInfoWindow *temp = CInfoWindow::create(text, playerID, &components);
|
||||
temp->setDelComps(delComps);
|
||||
if(makingTurn && GH.listInt.size() && LOCPLINT == this)
|
||||
|
@ -139,7 +139,7 @@ void CQuestLog::init()
|
||||
for (int i = 0; i < quests.size(); ++i)
|
||||
{
|
||||
MetaString text;
|
||||
quests[i].quest->getRolloverText (text, false);
|
||||
quests[i].quest.getRolloverText (text, false);
|
||||
if (quests[i].obj)
|
||||
text.addReplacement (quests[i].obj->getHoverText()); //get name of the object
|
||||
CQuestLabel * label = new CQuestLabel (28, 199 + i * 24, FONT_SMALL, TOPLEFT, Colors::Cornsilk, text.toString());
|
||||
@ -191,7 +191,7 @@ void CQuestLog::selectQuest (int which)
|
||||
|
||||
MetaString text;
|
||||
std::vector<Component> components; //TODO: display them
|
||||
currentQuest->quest->getVisitText (text, components , currentQuest->quest->isCustomFirst, true);
|
||||
currentQuest->quest.getVisitText (text, components , currentQuest->quest.isCustomFirst, true);
|
||||
description->setTxt (text.toString()); //TODO: use special log entry text
|
||||
redraw();
|
||||
}
|
||||
|
@ -469,13 +469,21 @@ public:
|
||||
|
||||
struct DLL_LINKAGE QuestInfo //universal interface for human and AI
|
||||
{
|
||||
const CQuest * quest;
|
||||
CQuest quest;
|
||||
const CGObjectInstance * obj; //related object, most likely Seer Hut
|
||||
int3 tile;
|
||||
|
||||
QuestInfo(){};
|
||||
QuestInfo (const CQuest * Quest, const CGObjectInstance * Obj, int3 Tile) :
|
||||
quest (Quest), obj (Obj), tile (Tile){};
|
||||
quest (*Quest), obj (Obj), tile (Tile){};
|
||||
|
||||
bool operator= (const QuestInfo &qi)
|
||||
{
|
||||
quest = qi.quest;
|
||||
obj = qi.obj;
|
||||
tile = qi.tile;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator== (const QuestInfo & qi) const
|
||||
{
|
||||
|
@ -76,6 +76,8 @@ public:
|
||||
std::string firstVisitText, nextVisitText, completedText;
|
||||
bool isCustomFirst, isCustomNext, isCustomComplete;
|
||||
|
||||
CQuest(){missionType = 0;}; //default constructor
|
||||
|
||||
virtual bool checkQuest (const CGHeroInstance * h) const; //determines whether the quest is complete or not
|
||||
virtual void getVisitText (MetaString &text, std::vector<Component> &components, bool isCustom, bool FirstVisit, const CGHeroInstance * h = NULL) const;
|
||||
virtual void getCompletionText (MetaString &text, std::vector<Component> &components, bool isCustom, const CGHeroInstance * h = NULL) const;
|
||||
@ -83,6 +85,11 @@ public:
|
||||
virtual void completeQuest (const CGHeroInstance * h) const {};
|
||||
virtual void addReplacements(MetaString &out, const std::string &base) const;
|
||||
|
||||
bool operator== (const CQuest & quest) const
|
||||
{
|
||||
return (quest.qid == qid);
|
||||
}
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & qid & missionType & progress & lastDay & m13489val & m2stats & m5arts & m6creatures & m7resources
|
||||
|
@ -320,7 +320,6 @@ DLL_LINKAGE void RemoveObject::applyGs( CGameState *gs )
|
||||
{
|
||||
if (q.obj == obj)
|
||||
{
|
||||
q.quest = NULL; //remove entries related to quest guards?
|
||||
q.obj = NULL;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user