mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-09 13:14:02 +02:00
CAdvMapInt: keep old path if non-accessible tile clicked. Fix issue 2380
This commit is contained in:
parent
18b2f866c9
commit
cacc811ed8
@ -1421,12 +1421,12 @@ void CAdvMapInt::tileLClicked(const int3 &mapPos)
|
|||||||
bool canSelect = topBlocking && topBlocking->ID == Obj::HERO && topBlocking->tempOwner == LOCPLINT->playerID;
|
bool canSelect = topBlocking && topBlocking->ID == Obj::HERO && topBlocking->tempOwner == LOCPLINT->playerID;
|
||||||
canSelect |= topBlocking && topBlocking->ID == Obj::TOWN && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, topBlocking->tempOwner);
|
canSelect |= topBlocking && topBlocking->ID == Obj::TOWN && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, topBlocking->tempOwner);
|
||||||
|
|
||||||
if (selection->ID != Obj::HERO) //hero is not selected (presumably town)
|
if(selection->ID != Obj::HERO) //hero is not selected (presumably town)
|
||||||
{
|
{
|
||||||
assert(!terrain.currentPath); //path can be active only when hero is selected
|
assert(!terrain.currentPath); //path can be active only when hero is selected
|
||||||
if(selection == topBlocking) //selected town clicked
|
if(selection == topBlocking) //selected town clicked
|
||||||
LOCPLINT->openTownWindow(static_cast<const CGTownInstance*>(topBlocking));
|
LOCPLINT->openTownWindow(static_cast<const CGTownInstance*>(topBlocking));
|
||||||
else if ( canSelect )
|
else if(canSelect)
|
||||||
select(static_cast<const CArmedInstance*>(topBlocking), false);
|
select(static_cast<const CArmedInstance*>(topBlocking), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1445,22 +1445,26 @@ void CAdvMapInt::tileLClicked(const int3 &mapPos)
|
|||||||
}
|
}
|
||||||
else //still here? we need to move hero if we clicked end of already selected path or calculate a new path otherwise
|
else //still here? we need to move hero if we clicked end of already selected path or calculate a new path otherwise
|
||||||
{
|
{
|
||||||
if (terrain.currentPath && terrain.currentPath->endPos() == mapPos)//we'll be moving
|
if(terrain.currentPath && terrain.currentPath->endPos() == mapPos)//we'll be moving
|
||||||
{
|
{
|
||||||
if (CGI->mh->canStartHeroMovement())
|
if(CGI->mh->canStartHeroMovement())
|
||||||
LOCPLINT->moveHero(currentHero,*terrain.currentPath);
|
LOCPLINT->moveHero(currentHero, *terrain.currentPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else/* if(mp.z == currentHero->pos.z)*/ //remove old path and find a new one if we clicked on the map level on which hero is present
|
else //remove old path and find a new one if we clicked on accessible tile
|
||||||
{
|
{
|
||||||
CGPath &path = LOCPLINT->paths[currentHero];
|
CGPath &path = LOCPLINT->paths[currentHero];
|
||||||
|
CGPath newpath;
|
||||||
|
bool gotPath = LOCPLINT->cb->getPathsInfo(currentHero)->getPath(newpath, mapPos); //try getting path, erase if failed
|
||||||
|
if(gotPath && newpath.nodes.size())
|
||||||
|
path = newpath;
|
||||||
|
|
||||||
|
if(path.nodes.size())
|
||||||
terrain.currentPath = &path;
|
terrain.currentPath = &path;
|
||||||
bool gotPath = LOCPLINT->cb->getPathsInfo(currentHero)->getPath(path, mapPos); //try getting path, erase if failed
|
|
||||||
updateMoveHero(currentHero);
|
|
||||||
if (!gotPath)
|
|
||||||
LOCPLINT->eraseCurrentPathOf(currentHero);
|
|
||||||
else
|
else
|
||||||
return;
|
LOCPLINT->eraseCurrentPathOf(currentHero);
|
||||||
|
|
||||||
|
updateMoveHero(currentHero);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //end of hero is selected "case"
|
} //end of hero is selected "case"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user