1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-21 00:19:29 +02:00

Refactoing of pathfinder <-> client/AI interaction to remove dependency on selected hero

- finished removal of server-side setSelection
- disabled some broken code (AI & cheats). TODO: fix
This commit is contained in:
Ivan Savenko
2014-09-21 16:42:08 +03:00
parent 78709e223b
commit 6c0c03d74b
19 changed files with 206 additions and 234 deletions

View File

@ -948,7 +948,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
CGPath &path = LOCPLINT->paths[h];
terrain.currentPath = &path;
if(!LOCPLINT->cb->getPath2(h->getPosition(false) + dir, path))
if(!LOCPLINT->cb->getPathsInfo(h)->getPath(h->getPosition(false) + dir, path))
{
terrain.currentPath = nullptr;
return;
@ -997,7 +997,7 @@ int3 CAdvMapInt::verifyPos(int3 ver)
void CAdvMapInt::select(const CArmedInstance *sel, bool centerView /*= true*/)
{
assert(sel);
LOCPLINT->cb->setSelection(sel);
LOCPLINT->setSelection(sel);
selection = sel;
if (LOCPLINT->battleInt == nullptr && LOCPLINT->makingTurn)
{
@ -1184,7 +1184,7 @@ void CAdvMapInt::tileLClicked(const int3 &mapPos)
}
else if(const CGHeroInstance * currentHero = curHero()) //hero is selected
{
const CGPathNode *pn = LOCPLINT->cb->getPathInfo(mapPos);
const CGPathNode *pn = LOCPLINT->cb->getPathsInfo(currentHero)->getPathInfo(mapPos);
if(currentHero == topBlocking) //clicked selected hero
{
LOCPLINT->openHeroWindow(currentHero);
@ -1206,7 +1206,7 @@ void CAdvMapInt::tileLClicked(const int3 &mapPos)
{
CGPath &path = LOCPLINT->paths[currentHero];
terrain.currentPath = &path;
bool gotPath = LOCPLINT->cb->getPath2(mapPos, path); //try getting path, erase if failed
bool gotPath = LOCPLINT->cb->getPathsInfo(currentHero)->getPath(mapPos, path); //try getting path, erase if failed
updateMoveHero(currentHero);
if (!gotPath)
LOCPLINT->eraseCurrentPathOf(currentHero);
@ -1249,11 +1249,6 @@ void CAdvMapInt::tileHovered(const int3 &mapPos)
statusbar.setText(hlp);
}
const CGPathNode *pnode = LOCPLINT->cb->getPathInfo(mapPos);
int turns = pnode->turns;
vstd::amin(turns, 3);
if(!selection) //may occur just at the start of game (fake move before full intiialization)
return;
@ -1298,6 +1293,10 @@ void CAdvMapInt::tileHovered(const int3 &mapPos)
}
else if(const CGHeroInstance *h = curHero())
{
const CGPathNode *pnode = LOCPLINT->cb->getPathsInfo(h)->getPathInfo(mapPos);
int turns = pnode->turns;
vstd::amin(turns, 3);
bool accessible = pnode->turns < 255;
if(objAtTile)