Bazaar developer reference

CvPlayerEspionage::CreateSpy()

Defined in
CvEspionageClasses.cpp, line 242
Class
CvPlayerEspionage
Hook name
CivHooks::CvPlayerEspionage_CreateSpy

Hooks

static bool BeforeCvPlayerEspionage_CreateSpy(CvPlayerEspionage* self);static void AfterCvPlayerEspionage_CreateSpy(CvPlayerEspionage* self);static void ReplaceCvPlayerEspionage_CreateSpy(void (*original)(CvPlayerEspionage*), CvPlayerEspionage* self);CivRegisterBefore<CivHooks::CvPlayerEspionage_CreateSpy>(host, &BeforeCvPlayerEspionage_CreateSpy);CivRegisterAfter<CivHooks::CvPlayerEspionage_CreateSpy>(host, &AfterCvPlayerEspionage_CreateSpy);CivRegisterReplace<CivHooks::CvPlayerEspionage_CreateSpy>(host, &ReplaceCvPlayerEspionage_CreateSpy);

Code

241/// AddSpy - Grants the player a spy to use242void CvPlayerEspionage::CreateSpy()243{244	// don't create spies if espionage is disabled245	if(GC.getGame().isOption(GAMEOPTION_NO_ESPIONAGE))246	{247		return;248	}249250	if (m_pPlayer->GetEspionageAI()->m_iTurnEspionageStarted == -1)251	{252		m_pPlayer->GetEspionageAI()->m_iTurnEspionageStarted = GC.getGame().getGameTurn();253	}254255	CvEspionageSpy kNewSpy;256	kNewSpy.m_eRank = (CvSpyRank)m_pPlayer->GetStartingSpyRank();257	kNewSpy.m_eSpyState = SPY_STATE_UNASSIGNED;258#if defined(MOD_BUGFIX_SPY_NAMES)259	GetNextSpyName(&kNewSpy);260#else261	kNewSpy.m_iName = GetNextSpyName();262#endif263	kNewSpy.m_bEvaluateReassignment = true;264265#if defined(MOD_API_ESPIONAGE)266	kNewSpy.m_bPassive = false;267#endif268269	m_aSpyList.push_back(kNewSpy);270271	CvNotifications* pNotifications = m_pPlayer->GetNotifications();272	if(pNotifications)273	{274#if defined(MOD_BUGFIX_SPY_NAMES)275		const char* szSpyName = kNewSpy.GetSpyName(m_pPlayer);276#else277		const char* szSpyName = m_pPlayer->getCivilizationInfo().getSpyNames(kNewSpy.m_iName);278#endif279		CvString strBuffer = GetLocalizedText("TXT_KEY_NOTIFICATION_SPY_CREATED", szSpyName);280		CvString strSummary = GetLocalizedText("TXT_KEY_NOTIFICATION_SUMMARY_SPY_CREATED", szSpyName);281		pNotifications->Add(NOTIFICATION_SPY_CREATED_ACTIVE_PLAYER, strBuffer, strSummary, -1, -1, 0);282	}283284	if(GC.getLogging())285	{286		CvString strMsg;287		strMsg.Format("New Spy, %d,", m_aSpyList.size() - 1);288#if defined(MOD_BUGFIX_SPY_NAMES)289		strMsg += GetLocalizedText(kNewSpy.GetSpyName(m_pPlayer));290#else291		strMsg += GetLocalizedText(m_pPlayer->getCivilizationInfo().getSpyNames(kNewSpy.m_iName));292#endif293		LogEspionageMsg(strMsg);294	}295}

Calls

Called by