浏览代码

* added visitDir bitfield in CGDefInfo specifying from which directions object can be visited
* fixed crashbug in heroList (showing after dismissing hero)

Michał W. Urbańczyk 18 年之前
父节点
当前提交
77fadf561d
共有 4 个文件被更改,包括 19 次插入3 次删除
  1. 10 1
      CPlayerInterface.cpp
  2. 4 0
      hch/CDefObjInfoHandler.cpp
  3. 2 0
      hch/CDefObjInfoHandler.h
  4. 3 2
      hch/CObjectHandler.h

+ 10 - 1
CPlayerInterface.cpp

@@ -1380,7 +1380,7 @@ SDL_Surface * CPlayerInterface::drawPrimarySkill(const CGHeroInstance *curh, SDL
 SDL_Surface * CPlayerInterface::drawHeroInfoWin(const CGHeroInstance * curh)
 {
 	char * buf = new char[10];
-	SDL_Surface * ret = copySurface(hInfo);
+	SDL_Surface * ret = SDL_DisplayFormat(hInfo);
 	SDL_SetColorKey(ret,SDL_SRCCOLORKEY,SDL_MapRGB(ret->format,0,255,255));
 	blueToPlayersAdv(ret,playerID,1);
 	printAt(curh->name,75,15,GEOR13,zwykly,ret);
@@ -1875,6 +1875,13 @@ void CHeroList::genList()
 }
 void CHeroList::select(int which)
 {
+	if (which<0)
+	{
+		selected = which;
+		LOCPLINT->adventureInt->selection.selected = LOCPLINT->adventureInt->terrain.currentPath = NULL;
+		draw();
+		LOCPLINT->adventureInt->infoBar.draw(NULL);
+	}
 	if (which>=items.size()) 
 		return;
 	selected = which;
@@ -2012,6 +2019,8 @@ void CHeroList::updateHList()
 {
 	items.clear();
 	genList();
+	if(selected>=items.size())
+		select(items.size()-1);
 }
 void CHeroList::updateMove(const CGHeroInstance* which) //draws move points bar
 {

+ 4 - 0
hch/CDefObjInfoHandler.cpp

@@ -13,6 +13,10 @@ bool CGDefInfo::isVisitable()
 	}
 	return false;
 }
+CGDefInfo::CGDefInfo()
+{
+	visitDir = (8|16|32|64|128); //4,5,6,7,8 - any not-from-up direction
+}
 bool DefObjInfo::operator==(const std::string & por) const
 {
 	return this->defName == por;

+ 2 - 0
hch/CDefObjInfoHandler.h

@@ -10,6 +10,7 @@ public:
 
 	unsigned char visitMap[6];
 	unsigned char blockMap[6];
+	unsigned char visitDir; //directions from which object can be entered, format same as for moveDir in CGHeroInstance(but 0 - 7)
 	int id, subid; //of object described by this defInfo
 	int terrainAllowed, //on which terrain it is possible to place object
 		 terrainMenu; //in which menus in map editor object will be showed
@@ -24,6 +25,7 @@ public:
 		else
 			return subid<por.subid;
 	}
+	CGDefInfo();
 };
 struct DefObjInfo
 {

+ 3 - 2
hch/CObjectHandler.h

@@ -329,8 +329,9 @@ public:
 class CGHeroInstance : public CGObjectInstance
 {
 public:
-	int moveDir;
-
+	int moveDir; //format:	123
+					//		8 4
+					//		765
 	bool isStanding;
 	bool flagPrinted;
 	CHero * type;