Hooks
static bool BeforeCvPlot_updateSight(CvPlot* self, bool bIncrement);static void AfterCvPlot_updateSight(CvPlot* self, bool bIncrement);static void ReplaceCvPlot_updateSight(void (*original)(CvPlot*, bool), CvPlot* self, bool bIncrement);CivRegisterBefore<CivHooks::CvPlot_updateSight>(host, &BeforeCvPlot_updateSight);CivRegisterAfter<CivHooks::CvPlot_updateSight>(host, &AfterCvPlot_updateSight);CivRegisterReplace<CivHooks::CvPlot_updateSight>(host, &ReplaceCvPlot_updateSight);
Code
1955void CvPlot::updateSight(bool bIncrement)1956{1957 IDInfo* pUnitNode;1958 CvCity* pCity;1959 CvUnit* pLoopUnit;1960 int iLoop;1961 int iI;19621963 pCity = getPlotCity();19641965 // Owned1966 if(isOwned())1967 {1968#if defined(MOD_API_EXTENSIONS)1969 changeAdjacentSight(getTeam(), GC.getPLOT_VISIBILITY_RANGE(), bIncrement, NO_INVISIBLE, NO_DIRECTION);1970#else1971 changeAdjacentSight(getTeam(), GC.getPLOT_VISIBILITY_RANGE(), bIncrement, NO_INVISIBLE, NO_DIRECTION, false);1972#endif19731974 // if this tile is owned by a minor share the visibility with my ally1975 if(pCity)1976 {1977 for(uint ui = 0; ui < MAX_MAJOR_CIVS; ui++)1978 {1979 PlayerTypes ePlayer = (PlayerTypes)ui;1980 if(GET_PLAYER(ePlayer).GetEspionage()->HasEstablishedSurveillanceInCity(pCity))1981 {1982#if defined(MOD_API_EXTENSIONS)1983 changeAdjacentSight(GET_PLAYER(ePlayer).getTeam(), GC.getESPIONAGE_SURVEILLANCE_SIGHT_RANGE(), bIncrement, NO_INVISIBLE, NO_DIRECTION);1984#else1985 changeAdjacentSight(GET_PLAYER(ePlayer).getTeam(), GC.getESPIONAGE_SURVEILLANCE_SIGHT_RANGE(), bIncrement, NO_INVISIBLE, NO_DIRECTION, false);1986#endif1987 }1988 }1989 }19901991 PlayerTypes ownerID = getOwner();1992 if(ownerID >= MAX_MAJOR_CIVS && ownerID != BARBARIAN_PLAYER)1993 {1994 CvPlayer& thisPlayer = GET_PLAYER(ownerID);1995 CvMinorCivAI* pMinorCivAI = thisPlayer.GetMinorCivAI();1996 if(pMinorCivAI && pMinorCivAI->GetAlly() != NO_PLAYER)1997 {1998#if defined(MOD_API_EXTENSIONS)1999 changeAdjacentSight(GET_PLAYER(pMinorCivAI->GetAlly()).getTeam(), GC.getPLOT_VISIBILITY_RANGE(), bIncrement, NO_INVISIBLE, NO_DIRECTION);2000#else2001 changeAdjacentSight(GET_PLAYER(pMinorCivAI->GetAlly()).getTeam(), GC.getPLOT_VISIBILITY_RANGE(), bIncrement, NO_INVISIBLE, NO_DIRECTION, false);2002#endif2003 }2004 }2005 }20062007 pUnitNode = headUnitNode();20082009 // Unit2010 while(pUnitNode != NULL)2011 {2012 pLoopUnit = GetPlayerUnit(*pUnitNode);2013 pUnitNode = nextUnitNode(pUnitNode);20142015 if(pLoopUnit)2016 {2017 if (pLoopUnit->canChangeVisibility())2018#if defined(MOD_API_EXTENSIONS)2019 changeAdjacentSight(pLoopUnit->getTeam(), pLoopUnit->visibilityRange(), bIncrement, pLoopUnit->getSeeInvisibleType(), pLoopUnit->getFacingDirection(true), pLoopUnit);2020#else2021 changeAdjacentSight(pLoopUnit->getTeam(), pLoopUnit->visibilityRange(), bIncrement, pLoopUnit->getSeeInvisibleType(), pLoopUnit->getFacingDirection(true));2022#endif2023 }2024 }20252026 if(getReconCount() > 0)2027 {2028#if !defined(MOD_PROMOTIONS_VARIABLE_RECON)2029 int iRange = GC.getRECON_VISIBILITY_RANGE();2030#endif2031 for(iI = 0; iI < MAX_PLAYERS; ++iI)2032 {2033 for(pLoopUnit = GET_PLAYER((PlayerTypes)iI).firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = GET_PLAYER((PlayerTypes)iI).nextUnit(&iLoop))2034 {2035 if(pLoopUnit->getReconPlot() == this && pLoopUnit->canChangeVisibility())2036 {2037#if defined(MOD_PROMOTIONS_VARIABLE_RECON)2038#if defined(MOD_API_EXTENSIONS)2039 changeAdjacentSight(pLoopUnit->getTeam(), pLoopUnit->reconRange(), bIncrement, pLoopUnit->getSeeInvisibleType(), pLoopUnit->getFacingDirection(true), pLoopUnit);2040#else2041 changeAdjacentSight(pLoopUnit->getTeam(), pLoopUnit->reconRange(), bIncrement, pLoopUnit->getSeeInvisibleType(), pLoopUnit->getFacingDirection(true));2042#endif2043#else2044#if defined(MOD_API_EXTENSIONS)2045 changeAdjacentSight(pLoopUnit->getTeam(), iRange, bIncrement, pLoopUnit->getSeeInvisibleType(), pLoopUnit->getFacingDirection(true), pLoopUnit);2046#else2047 changeAdjacentSight(pLoopUnit->getTeam(), iRange, bIncrement, pLoopUnit->getSeeInvisibleType(), pLoopUnit->getFacingDirection(true));2048#endif2049#endif2050 }2051 }2052 }2053 }2054}