diff --git a/CAdvmapInterface.cpp b/CAdvmapInterface.cpp index ec48a642e..db865a8a2 100644 --- a/CAdvmapInterface.cpp +++ b/CAdvmapInterface.cpp @@ -598,7 +598,7 @@ void CTerrainRect::clickLeft(tribool down) { if ( (currentPath->endPos()) == mp) { //move - LOCPLINT->cb->moveHero(0,currentPath->endPos());//todo - move selected hero + LOCPLINT->cb->moveHero(0,currentPath->endPos(), 1);//todo - move selected hero return; } else @@ -608,7 +608,9 @@ void CTerrainRect::clickLeft(tribool down) } } const CHeroInstance * currentHero = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].first; - currentPath = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].second = CGI->pathf->getPath(currentHero->pos,mp,currentHero); + int3 bufpos = currentHero->pos; + //bufpos.x-=1; + currentPath = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].second = CGI->pathf->getPath(bufpos,mp,currentHero,1); } void CTerrainRect::clickRight(tribool down) { diff --git a/CCallback.cpp b/CCallback.cpp index b6b80176c..79224996c 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -40,7 +40,7 @@ void CCallback::newTurn() } } } -bool CCallback::moveHero(int ID, int3 destPoint, int idtype) +bool CCallback::moveHero(int ID, int3 destPoint, int idtype, unsigned char posType) { if(ID<0 || ID>CGI->heroh->heroInstances.size()) return false; @@ -50,7 +50,7 @@ bool CCallback::moveHero(int ID, int3 destPoint, int idtype) return false; if(destPoint.z<0 || destPoint.z>CGI->mh->ttiles[0][0].size()-1) return false; - CPath * ourPath = CGI->pathf->getPath(CGI->heroh->heroInstances[ID]->pos, destPoint, CGI->heroh->heroInstances[ID]); + CPath * ourPath = CGI->pathf->getPath(CGI->heroh->heroInstances[ID]->pos, destPoint, CGI->heroh->heroInstances[ID], posType); if(!ourPath) return false; for(int i=ourPath->nodes.size()-1; i>0; i--) diff --git a/CCallback.h b/CCallback.h index 878fedf5a..c8a825c6f 100644 --- a/CCallback.h +++ b/CCallback.h @@ -22,7 +22,7 @@ protected: int player; public: - bool moveHero(int ID, int3 destPoint, int idtype=0);//idtype: 0-position in vector; 1-ID of hero + bool moveHero(int ID, int3 destPoint, int idtype=0, unsigned char posType=0);//idtype: 0-position in vector; 1-ID of hero int howManyTowns(); const CTownInstance * getTownInfo(int val, bool mode); //mode = 0 -> val = serial; mode = 1 -> val = ID diff --git a/CGameInterface.cpp b/CGameInterface.cpp index 9a63ec116..2614d7822 100644 --- a/CGameInterface.cpp +++ b/CGameInterface.cpp @@ -673,6 +673,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) } LOCPLINT->adventureInt->update(); //updating screen CGI->screenh->updateScreen(); + LOCPLINT->adventureInt->anim++; SDL_framerateDelay(mainFPSmng); //for animation purposes } //for(int i=1; i<32; i+=4) //main moving done diff --git a/CPathfinder.cpp b/CPathfinder.cpp index 55ce893ab..c7541e35f 100644 --- a/CPathfinder.cpp +++ b/CPathfinder.cpp @@ -4,19 +4,23 @@ #include "CGameInfo.h" #include "hch\CAmbarCendamo.h" #include "mapHandler.h" -int3 CPath::endPos() -{ - return int3(nodes[0].coord.x,nodes[0].coord.y,nodes[0].coord.z); -} int3 CPath::startPos() { return int3(nodes[nodes.size()-1].coord.x,nodes[nodes.size()-1].coord.y,nodes[nodes.size()-1].coord.z); } +int3 CPath::endPos() +{ + return int3(nodes[0].coord.x,nodes[0].coord.y,nodes[0].coord.z); +} -CPath * CPathfinder::getPath(const int3 &src, const int3 &dest, const CHeroInstance * hero) //TODO: test it (seems to be finished, but relies on unwritten functions :() +CPath * CPathfinder::getPath(int3 src, int3 dest, const CHeroInstance * hero, unsigned char type) //TODO: test it (seems to be finished, but relies on unwritten functions :() { if(src.z!=dest.z) //first check return NULL; + if(type==1) //calibrating + { + src.x-=1; + } //graph initialization graph.resize(CGI->ac->map.width); diff --git a/CPathfinder.h b/CPathfinder.h index 15f9b7463..5b65dbf21 100644 --- a/CPathfinder.h +++ b/CPathfinder.h @@ -29,8 +29,8 @@ class CPathfinder private: std::vector< std::vector > graph; public: - CPath * getPath(const int3 & src, const int3 & dest, const CHeroInstance * hero); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists - CPath * getPath(const int3 & src, const int3 & dest, const CHeroInstance * hero, int (*getDist)(int3 & a, int3 & b)); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists; uses getDist to calculate distance + CPath * getPath(int3 src, int3 dest, const CHeroInstance * hero, unsigned char type=0); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists; type - type of calculation: 0 - positions are normal positions of hero; 1 - given places are tiles blocked by hero + CPath * getPath(const int3 & src, const int3 & dest, const CHeroInstance * hero, int (*getDist)(int3 & a, int3 & b), unsigned char type=0); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists; uses getDist to calculate distance; type - type of calculation: 0 - positions are normal positions of hero; 1 - given places are tiles blocked by hero }; #endif //CPATHFINDER_H \ No newline at end of file