diff --git a/CPathfinder.cpp b/CPathfinder.cpp index d3b36d04a..b28f7cc6d 100644 --- a/CPathfinder.cpp +++ b/CPathfinder.cpp @@ -6,6 +6,7 @@ #include "mapHandler.h" #include "CGameState.h" #include "hch/CObjectHandler.h" +#include "hch/CDefObjInfoHandler.h" using namespace std; @@ -168,9 +169,85 @@ void CPathfinder::AddNeighbors(vector* branch) if(c.g != -1 && c.h != -1) { - vector toAdd = *branch; - toAdd.push_back(c); - Open.push(toAdd); + bool pass = true; //checking for allowed visiting direction + for(int b=0; bmh->ttiles[i][j][node.z].tileInfo->visitableObjects.size(); ++b) //checking destination tile + { + CGDefInfo * di = CGI->mh->ttiles[i][j][node.z].tileInfo->visitableObjects[b]->defInfo; + if( (i == node.x-1 && j == node.y-1) && !(di->visitDir & (1<<4)) ) + { + pass = false; break; + } + if( (i == node.x && j == node.y-1) && !(di->visitDir & (1<<5)) ) + { + pass = false; break; + } + if( (i == node.x+1 && j == node.y-1) && !(di->visitDir & (1<<6)) ) + { + pass = false; break; + } + if( (i == node.x+1 && j == node.y) && !(di->visitDir & (1<<7)) ) + { + pass = false; break; + } + if( (i == node.x+1 && j == node.y+1) && !(di->visitDir & (1<<0)) ) + { + pass = false; break; + } + if( (i == node.x && j == node.y+1) && !(di->visitDir & (1<<1)) ) + { + pass = false; break; + } + if( (i == node.x-1 && j == node.y+1) && !(di->visitDir & (1<<2)) ) + { + pass = false; break; + } + if( (i == node.x-1 && j == node.y) && !(di->visitDir & (1<<3)) ) + { + pass = false; break; + } + } + for(int b=0; bmh->ttiles[node.x][node.y][node.z].tileInfo->visitableObjects.size(); ++b) //checking source tile + { + CGDefInfo * di = CGI->mh->ttiles[node.x][node.y][node.z].tileInfo->visitableObjects[b]->defInfo; + if( (i == node.x-1 && j == node.y-1) && !(di->visitDir & (1<<0)) ) + { + pass = false; break; + } + if( (i == node.x && j == node.y-1) && !(di->visitDir & (1<<1)) ) + { + pass = false; break; + } + if( (i == node.x+1 && j == node.y-1) && !(di->visitDir & (1<<2)) ) + { + pass = false; break; + } + if( (i == node.x+1 && j == node.y) && !(di->visitDir & (1<<3)) ) + { + pass = false; break; + } + if( (i == node.x+1 && j == node.y+1) && !(di->visitDir & (1<<4)) ) + { + pass = false; break; + } + if( (i == node.x && j == node.y+1) && !(di->visitDir & (1<<5)) ) + { + pass = false; break; + } + if( (i == node.x-1 && j == node.y+1) && !(di->visitDir & (1<<6)) ) + { + pass = false; break; + } + if( (i == node.x-1 && j == node.y) && !(di->visitDir & (1<<7)) ) + { + pass = false; break; + } + } + if(pass) + { + vector toAdd = *branch; + toAdd.push_back(c); + Open.push(toAdd); + } } //delete c; } diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index 54a625564..beea0d801 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -1519,6 +1519,16 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) delObjRect(hp.x, hp.y-1, hp.z, ho->id); delObjRect(hp.x, hp.y, hp.z, ho->id); } + + //restoring good order of objects + std::stable_sort(CGI->mh->ttiles[details.dst.x-2][details.dst.y-1][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-2][details.dst.y-1][details.dst.z].objects.end(), ocmptwo_cgin); + std::stable_sort(CGI->mh->ttiles[details.dst.x-1][details.dst.y-1][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-1][details.dst.y-1][details.dst.z].objects.end(), ocmptwo_cgin); + std::stable_sort(CGI->mh->ttiles[details.dst.x][details.dst.y-1][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x][details.dst.y-1][details.dst.z].objects.end(), ocmptwo_cgin); + + std::stable_sort(CGI->mh->ttiles[details.dst.x-2][details.dst.y][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-2][details.dst.y][details.dst.z].objects.end(), ocmptwo_cgin); + std::stable_sort(CGI->mh->ttiles[details.dst.x-1][details.dst.y][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-1][details.dst.y][details.dst.z].objects.end(), ocmptwo_cgin); + std::stable_sort(CGI->mh->ttiles[details.dst.x][details.dst.y][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x][details.dst.y][details.dst.z].objects.end(), ocmptwo_cgin); + ho->isStanding = true; //move finished adventureInt->minimap.draw(); diff --git a/config/battleStartpos.txt b/config/battleStartpos.txt index 708e47637..0d101a090 100644 --- a/config/battleStartpos.txt +++ b/config/battleStartpos.txt @@ -12,9 +12,9 @@ 49 151 49 100 151 15 83 117 185 -17 49 100 151 185 -17 49 83 117 151 185 -17 49 83 100 117 151 185 +15 49 100 151 185 +15 49 83 117 151 185 +15 49 83 100 117 151 185 //tight_formation //atacker 86 diff --git a/hch/CDefObjInfoHandler.cpp b/hch/CDefObjInfoHandler.cpp index fb51a6987..172168750 100644 --- a/hch/CDefObjInfoHandler.cpp +++ b/hch/CDefObjInfoHandler.cpp @@ -5,6 +5,7 @@ #include "CLodHandler.h" #include #include "../lib/VCMI_Lib.h" +#include extern CLodHandler * bitmaph; bool CGDefInfo::isVisitable() { @@ -26,6 +27,7 @@ void CDefObjInfoHandler::load() std::istringstream inp(bitmaph->getTextFile("ZOBJCTS.TXT")); int objNumber; inp>>objNumber; + std::set ids; for(int hh=0; hh>nobj->id; inp>>nobj->subid; inp>>nobj->type; + if(nobj->type == 2 || nobj->type == 3 || nobj->type == 4 || nobj->type == 5 || nobj->id == 111) //creature, hero, artifact, resource or whripool + { + nobj->visitDir = 0xff; + ids.insert(nobj->id); + } + else + nobj->visitDir = (8|16|32|64|128); //disabled visiting from the top inp>>nobj->printPriority; gobjs[nobj->id][nobj->subid] = nobj; if(nobj->id==98) diff --git a/hch/CObjectHandler.h b/hch/CObjectHandler.h index 99ba97e68..69455600d 100644 --- a/hch/CObjectHandler.h +++ b/hch/CObjectHandler.h @@ -91,7 +91,7 @@ public: int portrait; //may be custom int mana; // remaining spell points std::vector primSkills; //0-attack, 1-defence, 2-spell power, 3-knowledge - std::vector > secSkills; //first - ID of skill, second - level of skill (0 - basic, 1 - adv., 2 - expert) + std::vector > secSkills; //first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert) int movement; //remaining movement points int identifier; //from the map file bool sex; diff --git a/map.cpp b/map.cpp index 0281ccdfe..f7898e728 100644 --- a/map.cpp +++ b/map.cpp @@ -1725,6 +1725,10 @@ void Mapa::readDefInfo( unsigned char * bufor, int &i) vinya->visitMap[zi] = reverse(bytes[6+zi]); } i+=16; + if(vinya->id!=34) + vinya->visitDir = VLC->dobjinfo->gobjs[vinya->id][vinya->subid]->visitDir; + else + vinya->visitDir = 0xff; defy.push_back(vinya); // add this def to the vector } } diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 0adaa8211..d0ad21507 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -211,7 +211,7 @@ void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs) for(int i=0;isecSkills.size();i++) { - if(hero->secSkills[i].second < 2) + if(hero->secSkills[i].second < 3) basicAndAdv.insert(hero->secSkills[i].first); else expert.insert(hero->secSkills[i].first);