Bazaar developer reference

CvGame::selectGroup(CvUnit *, bool, bool, bool)

Defined in
CvGame.cpp, line 2787
Class
CvGame
Hook name
CivHooks::CvGame_selectGroup

Hooks

static bool BeforeCvGame_selectGroup(CvGame* self, CvUnit* pUnit, bool bShift, bool bCtrl, bool bAlt);static void AfterCvGame_selectGroup(CvGame* self, CvUnit* pUnit, bool bShift, bool bCtrl, bool bAlt);static void ReplaceCvGame_selectGroup(void (*original)(CvGame*, CvUnit*, bool, bool, bool), CvGame* self, CvUnit* pUnit, bool bShift, bool bCtrl, bool bAlt);CivRegisterBefore<CivHooks::CvGame_selectGroup>(host, &BeforeCvGame_selectGroup);CivRegisterAfter<CivHooks::CvGame_selectGroup>(host, &AfterCvGame_selectGroup);CivRegisterReplace<CivHooks::CvGame_selectGroup>(host, &ReplaceCvGame_selectGroup);

Code

2787void CvGame::selectGroup(CvUnit* pUnit, bool bShift, bool bCtrl, bool bAlt)2788{2789	IDInfo* pUnitNode;2790	CvPlot* pUnitPlot;2791	bool bGroup;27922793	CvAssertMsg(pUnit != NULL, "pUnit == NULL unexpectedly");27942795	if(bAlt || bCtrl)2796	{2797		GC.GetEngineUserInterface()->clearSelectedCities();27982799		if(!bShift)2800		{2801			GC.GetEngineUserInterface()->ClearSelectionList();2802			bGroup = true;2803		}2804		else2805		{2806			bGroup = true;2807		}28082809		if(!pUnit) return;28102811		pUnitPlot = pUnit->plot();28122813		pUnitNode = pUnitPlot->headUnitNode();28142815		while(pUnitNode != NULL)2816		{2817			CvUnit* pLoopUnit = ::getUnit(*pUnitNode);2818			pUnitNode = pUnitPlot->nextUnitNode(pUnitNode);28192820			if(NULL != pLoopUnit && pLoopUnit->getOwner() == getActivePlayer())2821			{2822				if(pLoopUnit->canMove())2823				{2824					CvPlayerAI* pOwnerPlayer = &(GET_PLAYER(pLoopUnit->getOwner()));2825					if( !pOwnerPlayer->isSimultaneousTurns() || getTurnSlice() - pLoopUnit->getLastMoveTurn() > GC.getMIN_TIMER_UNIT_DOUBLE_MOVES())2826					{2827						if(bAlt || (pLoopUnit->getUnitType() == pUnit->getUnitType()))2828						{2829							auto_ptr<ICvUnit1> pDllLoopUnit = GC.WrapUnitPointer(pLoopUnit);2830							GC.GetEngineUserInterface()->InsertIntoSelectionList(pDllLoopUnit.get(), true, false, bGroup, false, true);2831						}2832					}2833				}2834			}2835		}2836	}2837	else2838	{2839		auto_ptr<ICvUnit1> pDllUnit = GC.WrapUnitPointer(pUnit);2840		GC.GetEngineUserInterface()->selectUnit(pDllUnit.get(), !bShift, bShift, true);2841	}2842}

Calls

Called by