1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Fixed at least two #1428 freezes, likely more.

They were occurring when AI hero visited bank that was also guarded by neutral creature nearby,
This commit is contained in:
Michał W. Urbańczyk
2013-09-27 23:46:58 +00:00
parent 0a0048fdf4
commit d1807585ad
8 changed files with 71 additions and 12 deletions

View File

@@ -86,6 +86,11 @@ void CQuery::onExposure(CGameHandler *gh, QueryPtr topQuery)
gh->queries.popQuery(*this);
}
void CQuery::onAdding(CGameHandler *gh, PlayerColor color)
{
}
CObjectVisitQuery::CObjectVisitQuery(const CGObjectInstance *Obj, const CGHeroInstance *Hero, int3 Tile)
: visitedObject(Obj), visitingHero(Hero), tile(Tile), removeObjectAfterVisit(false)
{
@@ -169,6 +174,7 @@ void Queries::addQuery(QueryPtr query)
void Queries::addQuery(PlayerColor player, QueryPtr query)
{
LOG_TRACE_PARAMS(logGlobal, "player='%s', query='%s'", player % query);
query->onAdding(gh, player);
queries[player].push_back(query);
}
@@ -372,3 +378,21 @@ void CHeroMovementQuery::onExposure(CGameHandler *gh, QueryPtr topQuery)
gh->queries.popIfTop(*this);
}
void CHeroMovementQuery::onRemoval(CGameHandler *gh, PlayerColor color)
{
PlayerBlocked pb;
pb.player = color;
pb.reason = PlayerBlocked::ONGOING_MOVEMENT;
pb.startOrEnd = PlayerBlocked::BLOCKADE_ENDED;
gh->sendAndApply(&pb);
}
void CHeroMovementQuery::onAdding(CGameHandler *gh, PlayerColor color)
{
PlayerBlocked pb;
pb.player = color;
pb.reason = PlayerBlocked::ONGOING_MOVEMENT;
pb.startOrEnd = PlayerBlocked::BLOCKADE_STARTED;
gh->sendAndApply(&pb);
}