Bazaar developer reference

CvPlot::canSeePlot(const CvPlot *, TeamTypes, int, DirectionTypes, DomainTypes) const

Defined in
CvPlot.cpp, line 1837
Class
CvPlot
Hook name
CivHooks::CvPlot_canSeePlot

Hooks

static bool BeforeCvPlot_canSeePlot(const CvPlot* self, const CvPlot* pPlot, TeamTypes eTeam, int iRange, DirectionTypes eFacingDirection, DomainTypes eUnitDomain, bool& result);static void AfterCvPlot_canSeePlot(const CvPlot* self, const CvPlot* pPlot, TeamTypes eTeam, int iRange, DirectionTypes eFacingDirection, DomainTypes eUnitDomain, bool& result);static bool ReplaceCvPlot_canSeePlot(bool (*original)(const CvPlot*, const CvPlot*, TeamTypes, int, DirectionTypes, DomainTypes), const CvPlot* self, const CvPlot* pPlot, TeamTypes eTeam, int iRange, DirectionTypes eFacingDirection, DomainTypes eUnitDomain);CivRegisterBefore<CivHooks::CvPlot_canSeePlot>(host, &BeforeCvPlot_canSeePlot);CivRegisterAfter<CivHooks::CvPlot_canSeePlot>(host, &AfterCvPlot_canSeePlot);CivRegisterReplace<CivHooks::CvPlot_canSeePlot>(host, &ReplaceCvPlot_canSeePlot);

Code

1836#if defined MOD_BUGFIX_NAVAL_TARGETING1837bool CvPlot::canSeePlot(const CvPlot* pPlot, TeamTypes eTeam, int iRange, DirectionTypes eFacingDirection, DomainTypes eUnitDomain) const1838#else1839bool CvPlot::canSeePlot(const CvPlot* pPlot, TeamTypes eTeam, int iRange, DirectionTypes eFacingDirection) const1840#endif1841{1842	iRange++;18431844	if(pPlot == NULL)1845	{1846		return false;1847	}18481849	if(pPlot == this)1850	{1851		return true;1852	}18531854	int startX = getX();1855	int startY = getY();1856	int destX = pPlot->getX();1857	int destY = pPlot->getY();18581859	int iDistance = plotDistance(startX, startY, destX,  destY);18601861	if(iDistance <= iRange)1862	{1863		//find displacement1864		int dy = destY - startY;18651866		int iX1 = xToHexspaceX(destX,  destY);1867		int iX2 = xToHexspaceX(startX, startY);1868		 1869		int dx = iX1 - iX2;18701871		dx = dxWrap(dx); //world wrap1872		dy = dyWrap(dy);18731874		//check if in facing direction1875		if(shouldProcessDisplacementPlot(dx, dy, iRange - 1, eFacingDirection))1876		{1877			if(iDistance == 1)1878			{1879				return true;1880			}18811882			//check if anything blocking the plot1883#if defined MOD_BUGFIX_NAVAL_TARGETING1884			int iLevel;18851886			if (eUnitDomain == DOMAIN_SEA && !isWater()) {1887				iLevel = GC.getTerrainInfo(TERRAIN_COAST)->getSeeFromLevel();1888				iLevel += GC.getSEAWATER_SEE_FROM_CHANGE();18891890				if (GET_TEAM(eTeam).isExtraWaterSeeFrom())1891				{1892					iLevel++;1893				}1894			}1895			else1896			{1897				iLevel = seeFromLevel(eTeam);1898			}18991900			if (CvTargeting::CanSeeDisplacementPlot(startX, startY, dx, dy, iLevel))1901#else1902			if (CvTargeting::CanSeeDisplacementPlot(startX, startY, dx, dy, seeFromLevel(eTeam)))1903#endif1904			{1905				return true;1906			}1907		}1908	}19091910	return false;1911}

Calls

Called by