1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

correct detection of blocked pos after disappearing objects and hero movement

This commit is contained in:
mateuszb
2007-11-29 18:45:47 +00:00
parent ea8ab56cea
commit 7c0f9afc9f
5 changed files with 25 additions and 8 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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*)

View File

@@ -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));
}
}
}
}

View File

@@ -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);