From d6d1fe2addacbeba208bd4fd219268d68b182e6f Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 1 Sep 2010 04:19:20 +0000 Subject: [PATCH] - bugfixes for multi-build. Now the other units are checked that they can not only build but repair too. Also those who repair now try to approach from the best angle as well as the builder. --- source/glest_game/game/commander.cpp | 16 +++++++++------- source/glest_game/world/unit_updater.cpp | 12 ++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index 0f230b0b..1abe099f 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -90,14 +90,16 @@ CommandResult Commander::tryGiveCommand(const Selection *selection, const Comman } } - NetworkCommand networkCommand(this->world,nctGiveCommand, unitId, - useCommandtype->getId(), usePos, unitType->getId(), - (targetUnit != NULL ? targetUnit->getId() : -1), - facing, tryQueue, commandStateType,commandStateValue); + if(useCommandtype != NULL) { + NetworkCommand networkCommand(this->world,nctGiveCommand, unitId, + useCommandtype->getId(), usePos, unitType->getId(), + (targetUnit != NULL ? targetUnit->getId() : -1), + facing, tryQueue, commandStateType,commandStateValue); - //every unit is ordered to a the position - CommandResult result= pushNetworkCommand(&networkCommand); - results.push_back(result); + //every unit is ordered to a the position + CommandResult result= pushNetworkCommand(&networkCommand); + results.push_back(result); + } } return computeResult(results); diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 362b80d1..72a919bf 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -810,19 +810,19 @@ void UnitUpdater::updateRepair(Unit *unit) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] rct = %p\n",__FILE__,__FUNCTION__,__LINE__,rct); - Unit *repaired= map->getCell(command->getPos())->getUnit(fLand); - bool nextToRepaired= repaired!=NULL && map->isNextTo(unit->getPos(), repaired); + Unit *repaired = map->getCell(command->getPos())->getUnit(fLand); + bool nextToRepaired = repaired != NULL && map->isNextTo(unit->getPos(), repaired); Unit *peerUnitBuilder = NULL; if(repaired == NULL) { peerUnitBuilder = findPeerUnitBuilder(unit); - if(peerUnitBuilder != NULL) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] peerUnitBuilder = %p\n",__FILE__,__FUNCTION__,__LINE__,peerUnitBuilder); - // command->getPos()-Vec2i(1) - //nextToRepaired= map->isNextTo(unit->getPos(), command->getPos()-Vec2i(1)); - nextToRepaired= (unit->getPos() == (command->getPos()-Vec2i(1))); + Vec2i buildPos = map->findBestBuildApproach(unit->getPos(), command->getPos(), peerUnitBuilder->getCurrCommand()->getUnitType()); + + //nextToRepaired= (unit->getPos() == (command->getPos()-Vec2i(1))); + nextToRepaired = (unit->getPos() == buildPos); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] peerUnitBuilder = %p, nextToRepaired = %d\n",__FILE__,__FUNCTION__,__LINE__,peerUnitBuilder,nextToRepaired);