1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Avoid crashes caused by mouse events. Fix issue 1955

Mouse handling code need refactoring, but for now we at least shouldn't crash.
This commit is contained in:
Arseniy Shestakov 2016-01-09 15:32:42 +03:00
parent 676f078b2e
commit 46e3d849af
2 changed files with 8 additions and 5 deletions

View File

@ -322,18 +322,21 @@ void CTerrainRect::showAnim(SDL_Surface * to)
show(to); // currently the same; maybe we should pass some flag to map handler so it redraws ONLY tiles that need redraw instead of full
}
int3 CTerrainRect::whichTileIsIt(const int & x, const int & y)
int3 CTerrainRect::whichTileIsIt(const int x, const int y)
{
int3 ret;
ret.x = adventureInt->position.x + ((GH.current->motion.x-CGI->mh->offsetX-pos.x)/32);
ret.y = adventureInt->position.y + ((GH.current->motion.y-CGI->mh->offsetY-pos.y)/32);
ret.x = adventureInt->position.x + ((x-CGI->mh->offsetX-pos.x)/32);
ret.y = adventureInt->position.y + ((y-CGI->mh->offsetY-pos.y)/32);
ret.z = adventureInt->position.z;
return ret;
}
int3 CTerrainRect::whichTileIsIt()
{
if(GH.current)
return whichTileIsIt(GH.current->motion.x,GH.current->motion.y);
else
return int3(-1);
}
int3 CTerrainRect::tileCountOnScreen()

View File

@ -74,7 +74,7 @@ public:
void showAll(SDL_Surface * to) override;
void showAnim(SDL_Surface * to);
void showPath(const SDL_Rect * extRect, SDL_Surface * to);
int3 whichTileIsIt(const int & x, const int & y); //x,y are cursor position
int3 whichTileIsIt(const int x, const int y); //x,y are cursor position
int3 whichTileIsIt(); //uses current cursor pos
/// @returns number of visible tiles on screen respecting current map scaling
int3 tileCountOnScreen();