Bazaar developer reference

CvUnit::doCommand(CommandTypes, int, int)

Defined in
CvUnit.cpp, line 2472
Class
CvUnit
Hook name
CivHooks::CvUnit_doCommand

Hooks

static bool BeforeCvUnit_doCommand(CvUnit* self, CommandTypes eCommand, int iData1, int iData2);static void AfterCvUnit_doCommand(CvUnit* self, CommandTypes eCommand, int iData1, int iData2);static void ReplaceCvUnit_doCommand(void (*original)(CvUnit*, CommandTypes, int, int), CvUnit* self, CommandTypes eCommand, int iData1, int iData2);CivRegisterBefore<CivHooks::CvUnit_doCommand>(host, &BeforeCvUnit_doCommand);CivRegisterAfter<CivHooks::CvUnit_doCommand>(host, &AfterCvUnit_doCommand);CivRegisterReplace<CivHooks::CvUnit_doCommand>(host, &ReplaceCvUnit_doCommand);

Code

2472void CvUnit::doCommand(CommandTypes eCommand, int iData1, int iData2)2473{2474	VALIDATE_OBJECT2475	bool bCycle;24762477	bCycle = false;24782479	CvAssert(getOwner() != NO_PLAYER);24802481	if(canDoCommand(eCommand, iData1, iData2))2482	{2483		switch(eCommand)2484		{2485		case COMMAND_PROMOTION:2486			promote((PromotionTypes)iData1, iData2);2487			break;24882489		case COMMAND_UPGRADE:2490			DoUpgrade();2491			bCycle = true;2492			break;24932494		case COMMAND_AUTOMATE:2495			Automate((AutomateTypes)iData1);2496			bCycle = true;2497			break;24982499		case COMMAND_WAKE:2500			SetActivityType(ACTIVITY_AWAKE);2501			if((getOwner() == GC.getGame().getActivePlayer()) && IsSelected())2502			{2503				// Force the UI to update so they see any new commands2504				DLLUI->setDirty(UnitInfo_DIRTY_BIT, true);2505			}2506			break;25072508		case COMMAND_CANCEL:2509			PopMission();2510			break;25112512		case COMMAND_CANCEL_ALL:2513			ClearMissionQueue();2514			break;25152516		case COMMAND_STOP_AUTOMATION:2517			SetAutomateType(NO_AUTOMATE);2518			break;25192520		case COMMAND_DELETE:2521			scrap();2522			bCycle = true;2523			break;25242525		case COMMAND_GIFT:2526			gift();2527			bCycle = true;2528			break;25292530		case COMMAND_HOTKEY:2531			setHotKeyNumber(iData1);2532			break;25332534		default:2535			CvAssert(false);2536			break;2537		}2538	}25392540	if(bCycle)2541	{2542		if(IsSelected())2543		{2544			DLLUI->setCycleSelectionCounter(1);2545		}2546	}2547}

Calls

Called by