From 401a39c3e1af7bb78a0783f6d1fb63b59704b0a8 Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Sun, 22 Aug 2010 22:30:17 +0000 Subject: [PATCH] harvesting units of size>1 should work better ( testing is still needed for this! ) --- source/glest_game/world/map.cpp | 6 +++--- source/glest_game/world/map.h | 2 +- source/glest_game/world/unit_updater.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 1b99c87d6..3347062b1 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 aa3dc5093..7ee659b02 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 216fc71dc..31f0373c6 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);