|
@@ -1421,13 +1421,13 @@ void CAdvMapInt::tileLClicked(const int3 &mapPos)
|
|
|
bool canSelect = topBlocking && topBlocking->ID == Obj::HERO && topBlocking->tempOwner == LOCPLINT->playerID;
|
|
|
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
|
|
|
if(selection == topBlocking) //selected town clicked
|
|
|
LOCPLINT->openTownWindow(static_cast<const CGTownInstance*>(topBlocking));
|
|
|
- else if ( canSelect )
|
|
|
- select(static_cast<const CArmedInstance*>(topBlocking), false);
|
|
|
+ else if(canSelect)
|
|
|
+ select(static_cast<const CArmedInstance*>(topBlocking), false);
|
|
|
return;
|
|
|
}
|
|
|
else if(const CGHeroInstance * currentHero = curHero()) //hero is selected
|
|
@@ -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
|
|
|
{
|
|
|
- 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())
|
|
|
- LOCPLINT->moveHero(currentHero,*terrain.currentPath);
|
|
|
+ if(CGI->mh->canStartHeroMovement())
|
|
|
+ LOCPLINT->moveHero(currentHero, *terrain.currentPath);
|
|
|
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];
|
|
|
- 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);
|
|
|
+ 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;
|
|
|
else
|
|
|
- return;
|
|
|
+ LOCPLINT->eraseCurrentPathOf(currentHero);
|
|
|
+
|
|
|
+ updateMoveHero(currentHero);
|
|
|
}
|
|
|
}
|
|
|
} //end of hero is selected "case"
|