1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

small helpful function

This commit is contained in:
mateuszb
2008-02-17 19:04:27 +00:00
parent a997c41f5c
commit 3844c45441
2 changed files with 40 additions and 0 deletions

View File

@ -1644,3 +1644,42 @@ void CMapHandler::validateRectTerr(SDL_Rect * val, const SDL_Rect * ext)
}
}
}
unsigned char CMapHandler::getDir(const int3 &a, const int3 &b)
{
if(a.z!=b.z)
return -1; //error!
if(a.x==b.x+1 && a.y==b.y+1) //lt
{
return 0;
}
else if(a.x==b.x && a.y==b.y+1) //t
{
return 1;
}
else if(a.x==b.x-1 && a.y==b.y+1) //rt
{
return 2;
}
else if(a.x==b.x-1 && a.y==b.y) //r
{
return 3;
}
else if(a.x==b.x-1 && a.y==b.y-1) //rb
{
return 4;
}
else if(a.x==b.x && a.y==b.y-1) //b
{
return 5;
}
else if(a.x==b.x+1 && a.y==b.y-1) //lb
{
return 6;
}
else if(a.x==b.x+1 && a.y==b.y) //l
{
return 7;
}
}