1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Queries refactoring

* Moved SUMMON_BOAT special case to mechanics
* Partially moved Town portal logic to mechanics class
* Added generic query reply to CCallback
* Redesigned Queries so that base API do not depends on CGameHandler
* Got rid of CGameHandler::castSpellRequest
* Removed CGameHandler::castSpell
* Added new Query type for town portal dialog (not used yet)
This commit is contained in:
AlexVinS
2017-06-06 07:53:51 +03:00
parent f463dc2fa3
commit 3d1a84875e
32 changed files with 729 additions and 295 deletions

View File

@ -235,7 +235,7 @@ bool QueryReply::applyGh( CGameHandler *gh )
COMPLAIN_AND_RETURN("Cannot answer the query with id -1!");
assert(vstd::contains(gh->states.players, player));
return gh->queryReply(qid, answer, player);
return gh->queryReply(qid, reply, player);
}
bool MakeAction::applyGh( CGameHandler *gh )
@ -275,10 +275,22 @@ bool DigWithHero::applyGh( CGameHandler *gh )
return gh->dig(gh->getHero(id));
}
bool CastAdvSpell::applyGh( CGameHandler *gh )
bool CastAdvSpell::applyGh(CGameHandler * gh)
{
ERROR_IF_NOT_OWNS(hid);
return gh->castSpell(gh->getHero(hid), sid, pos);
const CSpell * s = sid.toSpell();
if(!s)
ERROR_AND_RETURN;
const CGHeroInstance * h = gh->getHero(hid);
if(!h)
ERROR_AND_RETURN;
auto query = std::make_shared<AdventureSpellCastQuery>(&gh->queries, gh->spellEnv, s, h, pos);
gh->queries.addQuery(query);
gh->queries.popIfTop(query);//if we already can perform cast do it now
return true;
}
bool PlayerMessage::applyGh( CGameHandler *gh )