1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

- fixed deadlock on visiting such objects like artifacts

- typos in vcmibuilder script
This commit is contained in:
Ivan Savenko
2012-12-05 10:46:53 +00:00
parent 85a23e298c
commit cfaa9fd00a
2 changed files with 14 additions and 11 deletions

View File

@@ -1698,6 +1698,13 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
getTilesInRange(tmh.fowRevealed, h->getSightCenter()+(tmh.end-tmh.start), h->getSightRadious(), h->tempOwner, 1);
};
auto applyWithResult = [&](TryMoveHero::EResult result) -> bool
{
tmh.result = result;
sendAndApply(&tmh);
return result != TryMoveHero::FAILED;
};
//interaction with blocking object (like resources)
auto blockingVisit = [&]() -> bool
{
@@ -1705,6 +1712,9 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
{
if(obj != h && obj->blockVisit && !(obj->getPassableness() & 1<<h->tempOwner))
{
applyWithResult(TryMoveHero::BLOCKING_VISIT);
//can't move to that tile but we visit object
objectVisited(t.visitableObjects.back(), h);
@@ -1715,13 +1725,6 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
return false;
};
auto applyWithResult = [&](TryMoveHero::EResult result) -> bool
{
tmh.result = result;
sendAndApply(&tmh);
return result != TryMoveHero::FAILED;
};
//hero enters the boat
if(!h->boat && !t.visitableObjects.empty() && t.visitableObjects.back()->ID == Obj::BOAT)
{
@@ -1752,7 +1755,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
tmh.movePoints = std::max(ui32(0), h->movement - cost);
if(blockingVisit())
return applyWithResult(TryMoveHero::BLOCKING_VISIT);
return true;
leaveTile();
@@ -1770,7 +1773,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
else //instant move - teleportation
{
if(blockingVisit()) // e.g. hero on the other side of teleporter
return applyWithResult(TryMoveHero::BLOCKING_VISIT);
return true;
leaveTile();
applyWithResult(TryMoveHero::TELEPORTATION);