Bazaar developer reference

CvGame::canHandleAction(int, CvPlot *, bool)

Defined in
CvGame.cpp, line 2930
Class
CvGame
Hook name
CivHooks::CvGame_canHandleAction

Hooks

static bool BeforeCvGame_canHandleAction(CvGame* self, int iAction, CvPlot* pPlot, bool bTestVisible, bool& result);static void AfterCvGame_canHandleAction(CvGame* self, int iAction, CvPlot* pPlot, bool bTestVisible, bool& result);static bool ReplaceCvGame_canHandleAction(bool (*original)(CvGame*, int, CvPlot*, bool), CvGame* self, int iAction, CvPlot* pPlot, bool bTestVisible);CivRegisterBefore<CivHooks::CvGame_canHandleAction>(host, &BeforeCvGame_canHandleAction);CivRegisterAfter<CivHooks::CvGame_canHandleAction>(host, &AfterCvGame_canHandleAction);CivRegisterReplace<CivHooks::CvGame_canHandleAction>(host, &ReplaceCvGame_canHandleAction);

Code

2930bool CvGame::canHandleAction(int iAction, CvPlot* pPlot, bool bTestVisible)2931{2932	CvPlot* pMissionPlot;2933	bool bShift = gDLL->shiftKey();29342935	CvActionInfo* pActionInfo = GC.getActionInfo(iAction);2936	CvAssert(pActionInfo != NULL);2937	if(!pActionInfo) return false;29382939	if(pActionInfo->getControlType() != NO_CONTROL)2940	{2941		if(canDoControl((ControlTypes)(GC.getActionInfo(iAction)->getControlType())))2942		{2943			return true;2944		}2945	}29462947	if(GC.GetEngineUserInterface()->isCitySelection())2948	{2949		return false; // XXX hack!2950	}29512952	auto_ptr<ICvUnit1> pHeadSelectedUnit(GC.GetEngineUserInterface()->GetHeadSelectedUnit());2953	CvUnit* pkHeadSelectedUnit = GC.UnwrapUnitPointer(pHeadSelectedUnit.get());29542955	if(pkHeadSelectedUnit != NULL)2956	{2957		if(pkHeadSelectedUnit->getOwner() == getActivePlayer())2958		{2959			if(GET_PLAYER(pkHeadSelectedUnit->getOwner()).isSimultaneousTurns() || GET_PLAYER(pkHeadSelectedUnit->getOwner()).isTurnActive())2960			{2961				if(GC.getActionInfo(iAction)->getMissionType() != NO_MISSION)2962				{2963					if(pPlot != NULL)2964					{2965						pMissionPlot = pPlot;2966					}2967					else if(bShift)2968					{2969						pMissionPlot = pkHeadSelectedUnit->LastMissionPlot();2970					}2971					else2972					{2973						pMissionPlot = NULL;2974					}29752976					if((pMissionPlot == NULL) || !(pMissionPlot->isVisible(pkHeadSelectedUnit->getTeam())))2977					{2978						pMissionPlot = pkHeadSelectedUnit->plot();2979					}29802981					if(pkHeadSelectedUnit->CanStartMission(pActionInfo->getMissionType(), pActionInfo->getMissionData(), -1, pMissionPlot, bTestVisible))2982					{2983						return true;2984					}2985				}29862987				if(GC.getActionInfo(iAction)->getCommandType() != NO_COMMAND)2988				{2989					if(pkHeadSelectedUnit->canDoCommand(((CommandTypes)(pActionInfo->getCommandType())), pActionInfo->getCommandData(), -1, bTestVisible))2990					{2991						return true;2992					}2993				}29942995				if(GC.GetEngineUserInterface()->CanDoInterfaceMode((InterfaceModeTypes)pActionInfo->getInterfaceModeType(), bTestVisible))2996				{2997					return true;2998				}2999			}3000		}3001	}30023003	return false;3004}

Calls

Called by