mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +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:
@ -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
|
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;
|
int3 ret;
|
||||||
ret.x = adventureInt->position.x + ((GH.current->motion.x-CGI->mh->offsetX-pos.x)/32);
|
ret.x = adventureInt->position.x + ((x-CGI->mh->offsetX-pos.x)/32);
|
||||||
ret.y = adventureInt->position.y + ((GH.current->motion.y-CGI->mh->offsetY-pos.y)/32);
|
ret.y = adventureInt->position.y + ((y-CGI->mh->offsetY-pos.y)/32);
|
||||||
ret.z = adventureInt->position.z;
|
ret.z = adventureInt->position.z;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int3 CTerrainRect::whichTileIsIt()
|
int3 CTerrainRect::whichTileIsIt()
|
||||||
{
|
{
|
||||||
|
if(GH.current)
|
||||||
return whichTileIsIt(GH.current->motion.x,GH.current->motion.y);
|
return whichTileIsIt(GH.current->motion.x,GH.current->motion.y);
|
||||||
|
else
|
||||||
|
return int3(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int3 CTerrainRect::tileCountOnScreen()
|
int3 CTerrainRect::tileCountOnScreen()
|
||||||
|
@ -74,7 +74,7 @@ public:
|
|||||||
void showAll(SDL_Surface * to) override;
|
void showAll(SDL_Surface * to) override;
|
||||||
void showAnim(SDL_Surface * to);
|
void showAnim(SDL_Surface * to);
|
||||||
void showPath(const SDL_Rect * extRect, 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
|
int3 whichTileIsIt(); //uses current cursor pos
|
||||||
/// @returns number of visible tiles on screen respecting current map scaling
|
/// @returns number of visible tiles on screen respecting current map scaling
|
||||||
int3 tileCountOnScreen();
|
int3 tileCountOnScreen();
|
||||||
|
Reference in New Issue
Block a user