- fixed null pointer discovered by titi

This commit is contained in:
Mark Vejvoda
2013-01-24 23:10:25 +00:00
parent 8399ed2c6a
commit 743efc0822

View File

@@ -1089,7 +1089,10 @@ bool Gui::computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&t
else if(obj != NULL){
targetUnit= NULL;
highlightedResourceObjectPos=Map::toSurfCoords(obj->getMapPos());
getHighlightedResourceObject()->resetHighlight();
Object *selObj = getHighlightedResourceObject();
if(selObj != NULL) {
selObj->resetHighlight();
// get real click pos
renderer.computePosition(screenPos, targetPos);
@@ -1176,7 +1179,10 @@ bool Gui::computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&t
targetPos= obj->getMapPos();
posObjWorld= targetPos;
return true;
}
else {
return false;
}
}
else{
targetUnit= NULL;
@@ -1184,10 +1190,13 @@ bool Gui::computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&t
validPosObjWorld= true;
posObjWorld= targetPos;
if(world->getMap()->getSurfaceCell(Map::toSurfCoords(targetPos))->getResource()!=NULL)
{
if(world->getMap()->getSurfaceCell(Map::toSurfCoords(targetPos))->getResource() != NULL) {
highlightedResourceObjectPos=Map::toSurfCoords(targetPos);
getHighlightedResourceObject()->resetHighlight();
Object *selObj = getHighlightedResourceObject();
if(selObj != NULL) {
selObj->resetHighlight();
}
}
return true;