diff options
author | ge49jic <jonas.gunz@tum.de> | 2018-12-29 10:53:53 +0100 |
---|---|---|
committer | ge49jic <jonas.gunz@tum.de> | 2018-12-29 10:53:53 +0100 |
commit | 32adea5719fbfd07390c7a459ee4a60c48f84835 (patch) | |
tree | 151df91e0a9b29442f14396fca5ce739cf2854df /cObjectHandler.cpp | |
parent | 167abfe3746df80dd48dd65751583d97449e55f3 (diff) | |
download | termgl-32adea5719fbfd07390c7a459ee4a60c48f84835.tar.gz |
cObjectHandler:clickEvent now checks coordinates and sets activeObject
Diffstat (limited to 'cObjectHandler.cpp')
-rw-r--r-- | cObjectHandler.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cObjectHandler.cpp b/cObjectHandler.cpp index edd021c..68abace 100644 --- a/cObjectHandler.cpp +++ b/cObjectHandler.cpp @@ -73,6 +73,13 @@ int cObjectHandler::write() int cObjectHandler::clickEvent(sPos _pos, unsigned int _button) { + if(_pos.x >= iHitMap.size()) + return 1; + if(_pos.y >= iHitMap[_pos.x].size()) + return 1; + + iActiveObject = iHitMap[_pos.x][_pos.y]; //Set active object + if(objects[ iHitMap[_pos.x][_pos.y] ]) objects[ iHitMap[_pos.x][_pos.y] ]->onClick(_pos, _button); else |