瀏覽代碼

correct detection of blocked pos after disappearing objects and hero movement

mateuszb 18 年之前
父節點
當前提交
7c0f9afc9f
共有 5 個文件被更改,包括 25 次插入8 次删除
  1. 1 1
      CGameInterface.h
  2. 1 1
      CMT.cpp
  3. 1 0
      CPlayerInterface.cpp
  4. 21 5
      mapHandler.cpp
  5. 1 1
      mapHandler.h

+ 1 - 1
CGameInterface.h

@@ -20,7 +20,7 @@ public:
 	virtual void heroKilled(const CGHeroInstance*)=0{};
 	virtual void heroCreated(const CGHeroInstance*)=0{};
 	virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val)=0{};
-	virtual void heroMoved(const HeroMoveDetails & details)=0;
+	virtual void heroMoved(const HeroMoveDetails & details)=0{};
 	virtual void receivedResource(int type, int val){};
 };
 class CAIHandler

+ 1 - 1
CMT.cpp

@@ -728,7 +728,7 @@ int _tmain(int argc, _TCHAR* argv[])
 		{ 
 
 			if(cgi->scenarioOps.playerInfos[i].name=="Computer")
-				cgi->playerint.push_back(CAIHandler::getNewAI(new CCallback(cgi->state,cgi->scenarioOps.playerInfos[i].color),"EmptyAI.dll"));
+				cgi->playerint.push_back(static_cast<CGameInterface*>(CAIHandler::getNewAI(new CCallback(cgi->state,cgi->scenarioOps.playerInfos[i].color),"EmptyAI.dll")));
 			else 
 			{
 				cgi->state->currentPlayer=cgi->scenarioOps.playerInfos[i].color;

+ 1 - 0
CPlayerInterface.cpp

@@ -993,6 +993,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 	//ho->moveDir = 0; //move ended
 	ho->isStanding = true;
 	//move finished
+	CGI->mh->recalculateHideVisPosUnderObj(details.ho, true);
 	adventureInt->heroList.draw();
 }
 void CPlayerInterface::heroKilled(const CGHeroInstance*)

+ 21 - 5
mapHandler.cpp

@@ -1844,15 +1844,31 @@ bool CMapHandler::recalculateHideVisPos(int3 &pos)
 	return true;
 }
 
-bool CMapHandler::recalculateHideVisPosUnderObj(CGObjectInstance *obj)
+bool CMapHandler::recalculateHideVisPosUnderObj(CGObjectInstance *obj, bool withBorder)
 {
-	for(int fx=0; fx<obj->defInfo->handler->ourImages[0].bitmap->w/32; ++fx)
+	if(withBorder)
 	{
-		for(int fy=0; fy<obj->defInfo->handler->ourImages[0].bitmap->h/32; ++fy)
+		for(int fx=-1; fx<=obj->defInfo->handler->ourImages[0].bitmap->w/32; ++fx)
 		{
-			if((obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)>=0 && (obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)>=0 && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
+			for(int fy=-1; fy<=obj->defInfo->handler->ourImages[0].bitmap->h/32; ++fy)
 			{
-				recalculateHideVisPos(int3(obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32, obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32, obj->pos.z));
+				if((obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)>=0 && (obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)>=0 && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
+				{
+					recalculateHideVisPos(int3(obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32 +1, obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32 + 1, obj->pos.z));
+				}
+			}
+		}
+	}
+	else
+	{
+		for(int fx=0; fx<obj->defInfo->handler->ourImages[0].bitmap->w/32; ++fx)
+		{
+			for(int fy=0; fy<obj->defInfo->handler->ourImages[0].bitmap->h/32; ++fy)
+			{
+				if((obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)>=0 && (obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)>=0 && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
+				{
+					recalculateHideVisPos(int3(obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32 +1, obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32 + 1, obj->pos.z));
+				}
 			}
 		}
 	}

+ 1 - 1
mapHandler.h

@@ -88,7 +88,7 @@ public:
 	bool hideObject(CGObjectInstance * obj); //removes appropriate things from ttiles, so obj will be no longer visible on map (but still will exist)
 	bool removeObject(CGObjectInstance * obj); //removes object from each place in VCMI (I hope)
 	bool recalculateHideVisPos(int3& pos); //recalculates position for hidden / visitable positions
-	bool recalculateHideVisPosUnderObj(CGObjectInstance * obj); //recalculates position for hidden / visitable positions under given object
+	bool recalculateHideVisPosUnderObj(CGObjectInstance * obj, bool withBorder = false); //recalculates position for hidden / visitable positions under given object
 	void init();
 	SDL_Surface * terrainRect(int x, int y, int dx, int dy, int level=0, unsigned char anim=0, PseudoV< PseudoV< PseudoV<unsigned char> > > & visibilityMap = CGI->mh->visibility);
 	SDL_Surface * terrBitmap(int x, int y);