//------------------------------------------------------------------------------ void CvDllGameContext::TEMPOnHexUnitChangedAttack(ICvUnit1* pUnit) { CvUnit* pkUnit = GC.UnwrapUnitPointer(pUnit); SPathFinderUserData data(pkUnit,CvUnit::MOVEFLAG_DECLARE_WAR|CvUnit::MOVEFLAG_ATTACK,1); data.ePathType = PT_UNIT_REACHABLE_PLOTS; //potential deadlock - need to use special pathfinder instance ReachablePlots plots = GC.GetPathFinder().GetPlotsInReach(pkUnit->getX(),pkUnit->getY(),data); for (ReachablePlots::iterator it = plots.begin(); it != plots.end(); ++it) { CvPlot* pPlot = GC.getMap().plotByIndexUnchecked(it->iPlotIndex); if(pPlot && pPlot->isVisible(pkUnit->getTeam()) && (pPlot->isVisibleEnemyUnit(pkUnit) || pPlot->isEnemyCity(*pkUnit))) { auto_ptr<ICvPlot1> pDllPlot = GC.WrapPlotPointer(pPlot); GC.GetEngineUserInterface()->AddHexToUIRange(pDllPlot.get()); } } }
//------------------------------------------------------------------------------ void CvDllGameContext::TEMPOnHexUnitChangedAttack(ICvUnit1* pUnit) { CvUnit* pkUnit = GC.UnwrapUnitPointer(pUnit); CvTwoLayerPathFinder& thePathfinder = GC.GetInterfacePathFinder(); SPathFinderUserData data(pkUnit,CvUnit::MOVEFLAG_NO_INTERMEDIATE_STOPS|CvUnit::MOVEFLAG_DECLARE_WAR|CvUnit::MOVEFLAG_ATTACK,1); data.ePathType = PT_UNIT_REACHABLE_PLOTS; ReachablePlots plots = GC.GetInterfacePathFinder().GetPlotsInReach(pkUnit->getX(),pkUnit->getY(),data,0); for (ReachablePlots::iterator it = plots.begin(); it != plots.end(); ++it) { CvPlot* pPlot = GC.getMap().plotByIndexUnchecked(it->first); if(pPlot && pPlot->isVisible(pkUnit->getTeam()) && (pPlot->isVisibleEnemyUnit(pkUnit) || pPlot->isEnemyCity(*pkUnit))) { auto_ptr<ICvPlot1> pDllPlot = GC.WrapPlotPointer(pPlot); GC.GetEngineUserInterface()->AddHexToUIRange(pDllPlot.get()); } } }