From 7b47f5edb12a5860be51f1f4f409703d5cf048d3 Mon Sep 17 00:00:00 2001 From: titiger Date: Fri, 11 Nov 2016 01:34:28 +0100 Subject: [PATCH] When giving default orders we must respect cellmap of target unit We need to respect cellmaps by searching for a cell which is really occupied. This fixes an issue that new workers do not start with autorepair. It happens typically with round building were top left cell map is empty. Now order is given to a place which is really occupied by the unit(building) to repair. --- source/glest_game/gui/gui.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/glest_game/gui/gui.cpp b/source/glest_game/gui/gui.cpp index d784b29ad..87aa2cad4 100644 --- a/source/glest_game/gui/gui.cpp +++ b/source/glest_game/gui/gui.cpp @@ -1185,6 +1185,19 @@ bool Gui::computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&t if(uc.empty() == false){ targetUnit= getRelevantObjectFromSelection(&uc); targetPos= targetUnit->getPosNotThreadSafe(); + // we need to respect cellmaps. Searching for a cell which is really occupied + int size=targetUnit->getType()->getSize(); + bool foundUnit=false; + for ( int x= 0;xgetMap()->getCell(Vec2i(targetPos.x+x,targetPos.y+y))->getUnit(targetUnit->getType()->getField())==targetUnit){ + targetPos=Vec2i(targetPos.x+x,targetPos.y+y); + foundUnit=true; + break; + } + } + if(foundUnit) break; + } highlightedUnitId=targetUnit->getId(); getHighlightedUnit()->resetHighlight(); return true;