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