diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 1b99c87d..3347062b 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -248,9 +248,9 @@ bool Map::isInsideSurface(const Vec2i &sPos) const{ } //returns if there is a resource next to a unit, in "resourcePos" is stored the relative position of the resource -bool Map::isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i &resourcePos) const{ - for(int i=-1; i<=1; ++i){ - for(int j=-1; j<=1; ++j){ +bool Map::isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i &resourcePos, int size) const{ + for(int i=-1; i<=size; ++i){ + for(int j=-1; j<=size; ++j){ if(isInside(pos.x+i, pos.y+j)){ Resource *r= getSurfaceCell(toSurfCoords(Vec2i(pos.x+i, pos.y+j)))->getResource(); if(r!=NULL){ diff --git a/source/glest_game/world/map.h b/source/glest_game/world/map.h index aa3dc509..7ee659b0 100755 --- a/source/glest_game/world/map.h +++ b/source/glest_game/world/map.h @@ -196,7 +196,7 @@ public: bool isInside(const Vec2i &pos) const; bool isInsideSurface(int sx, int sy) const; bool isInsideSurface(const Vec2i &sPos) const; - bool isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i &resourcePos) const; + bool isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i &resourcePos, int size) const; bool isResourceNear(const Vec2i &pos, int size, const ResourceType *rt, Vec2i &resourcePos) const; //free cells diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 216fc71d..31f0373c 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -492,7 +492,7 @@ void UnitUpdater::updateHarvest(Unit *unit){ switch(this->game->getGameSettings()->getPathFinderType()) { case pfBasic: canHarvestDestPos = (unit->getPos().dist(command->getPos())isResourceNear(unit->getPos(), r->getType(), targetPos)); + map->isResourceNear(unit->getPos(), r->getType(), targetPos,unit->getType()->getSize())); break; case pfRoutePlanner: canHarvestDestPos = map->isResourceNear(unit->getPos(), unit->getType()->getSize(), r->getType(), targetPos);