- attempt to improve harvesting a bit

This commit is contained in:
Mark Vejvoda
2011-03-29 04:57:36 +00:00
parent b6e9a7aca5
commit 614d0c25db
2 changed files with 49 additions and 7 deletions

View File

@@ -832,15 +832,21 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
switch(this->game->getGameSettings()->getPathFinderType()) {
case pfBasic:
{
const bool newHarvestPath = true;
bool isNearResource = false;
Vec2i clickPos = command->getOriginalPos();
bool isNearResource = map->isResourceNear(unit->getPos(), r->getType(), targetPos,unit->getType()->getSize(),unit, false,&clickPos);
//bool isNearResource = map->isResourceNear(unit->getPos(), r->getType(), targetPos,unit->getType()->getSize(),unit);
if(newHarvestPath == true) {
isNearResource = map->isResourceNear(unit->getPos(), r->getType(), targetPos,unit->getType()->getSize(),unit, false,&clickPos);
}
else {
isNearResource = map->isResourceNear(unit->getPos(), r->getType(), targetPos,unit->getType()->getSize(),unit);
}
if(isNearResource == true) {
if((unit->getPos().dist(command->getPos()) < harvestDistance || unit->getPos().dist(targetPos) < harvestDistance) && isNearResource == true) {
canHarvestDestPos = true;
}
}
else {
else if(newHarvestPath == true) {
if(clickPos != command->getOriginalPos()) {
//printf("%%----------- unit [%s - %d] CHANGING RESOURCE POS from [%s] to [%s]\n",unit->getFullName().c_str(),unit->getId(),command->getOriginalPos().getString().c_str(),clickPos.getString().c_str());