mirror of
https://github.com/glest/glest-source.git
synced 2025-08-21 23:45:14 +02:00
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.
This commit is contained in:
@@ -1185,6 +1185,19 @@ bool Gui::computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&t
|
|||||||
if(uc.empty() == false){
|
if(uc.empty() == false){
|
||||||
targetUnit= getRelevantObjectFromSelection(&uc);
|
targetUnit= getRelevantObjectFromSelection(&uc);
|
||||||
targetPos= targetUnit->getPosNotThreadSafe();
|
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;x<size;++x){
|
||||||
|
for ( int y= 0;y<size;++y){
|
||||||
|
if(world->getMap()->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();
|
highlightedUnitId=targetUnit->getId();
|
||||||
getHighlightedUnit()->resetHighlight();
|
getHighlightedUnit()->resetHighlight();
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user