Hooks
static bool BeforeCvPlayerEspionage_ExtractSpyFromCity(CvPlayerEspionage* self, uint uiSpyIndex, bool& result);static void AfterCvPlayerEspionage_ExtractSpyFromCity(CvPlayerEspionage* self, uint uiSpyIndex, bool& result);static bool ReplaceCvPlayerEspionage_ExtractSpyFromCity(bool (*original)(CvPlayerEspionage*, uint), CvPlayerEspionage* self, uint uiSpyIndex);CivRegisterBefore<CivHooks::CvPlayerEspionage_ExtractSpyFromCity>(host, &BeforeCvPlayerEspionage_ExtractSpyFromCity);CivRegisterAfter<CivHooks::CvPlayerEspionage_ExtractSpyFromCity>(host, &AfterCvPlayerEspionage_ExtractSpyFromCity);CivRegisterReplace<CivHooks::CvPlayerEspionage_ExtractSpyFromCity>(host, &ReplaceCvPlayerEspionage_ExtractSpyFromCity);
Code
1543/// RemoveSpyFromCity - Remove a spy from this city1544bool CvPlayerEspionage::ExtractSpyFromCity(uint uiSpyIndex)1545{1546 CvAssertMsg(uiSpyIndex < m_aSpyList.size(), "iSpyIndex is out of bounds");1547 if(uiSpyIndex >= m_aSpyList.size())1548 {1549 return false;1550 }15511552 if(!IsSpyInCity(uiSpyIndex))1553 {1554 return true;1555 }15561557 bool bHadSurveillance = HasEstablishedSurveillance(uiSpyIndex);15581559 int iCityX = m_aSpyList[uiSpyIndex].m_iCityX;1560 int iCityY = m_aSpyList[uiSpyIndex].m_iCityY;15611562 m_aSpyList[uiSpyIndex].m_iCityX = -1;1563 m_aSpyList[uiSpyIndex].m_iCityY = -1;1564#if defined(MOD_API_ESPIONAGE)1565 m_aSpyList[uiSpyIndex].SetSpyState(m_pPlayer->GetID(), uiSpyIndex, SPY_STATE_UNASSIGNED);1566#else1567 m_aSpyList[uiSpyIndex].m_eSpyState = SPY_STATE_UNASSIGNED;1568#endif15691570 CvPlot* pPlot = GC.getMap().plot(iCityX, iCityY);1571 CvAssertMsg(pPlot, "Spy coordinates did not point to plot");1572 if(!pPlot)1573 {1574 return false;1575 }15761577 CvCity* pCity = pPlot->getPlotCity();1578 CvAssertMsg(pCity, "No city in plot pointed to by spy");1579 if(!pCity)1580 {1581 return false;1582 }15831584 // turn off visibility of city1585 if(bHadSurveillance)1586 {1587#if defined(MOD_API_EXTENSIONS)1588 pCity->plot()->changeAdjacentSight(m_pPlayer->getTeam(), GC.getESPIONAGE_SURVEILLANCE_SIGHT_RANGE(), false, NO_INVISIBLE, NO_DIRECTION);1589#else1590 pCity->plot()->changeAdjacentSight(m_pPlayer->getTeam(), GC.getESPIONAGE_SURVEILLANCE_SIGHT_RANGE(), false, NO_INVISIBLE, NO_DIRECTION, false);1591#endif1592 }15931594 pCity->GetCityEspionage()->m_aiSpyAssignment[m_pPlayer->GetID()] = -1;1595 pCity->GetCityEspionage()->ResetProgress(m_pPlayer->GetID());15961597 return true;1598}