Bazaar developer reference

CvPlot::isBlockaded(PlayerTypes)

Defined in
CvPlot.cpp, line 5799
Class
CvPlot
Hook name
CivHooks::CvPlot_isBlockaded

Hooks

static bool BeforeCvPlot_isBlockaded(CvPlot* self, PlayerTypes ePlayer, bool& result);static void AfterCvPlot_isBlockaded(CvPlot* self, PlayerTypes ePlayer, bool& result);static bool ReplaceCvPlot_isBlockaded(bool (*original)(CvPlot*, PlayerTypes), CvPlot* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvPlot_isBlockaded>(host, &BeforeCvPlot_isBlockaded);CivRegisterAfter<CivHooks::CvPlot_isBlockaded>(host, &AfterCvPlot_isBlockaded);CivRegisterReplace<CivHooks::CvPlot_isBlockaded>(host, &ReplaceCvPlot_isBlockaded);

Code

5799bool CvPlot::isBlockaded(PlayerTypes ePlayer)5800{5801	if (!isWater()) {5802		return false;5803	}58045805	// An enemy ship on the plot trumps all5806	if (getVisibleEnemyDefender(ePlayer)) {5807		return true;5808	}58095810#if defined(MOD_GLOBAL_ALLIES_BLOCK_BLOCKADES)5811	if (MOD_GLOBAL_ALLIES_BLOCK_BLOCKADES) {5812		// An allied ship on the plot secures the plot5813		if (IsActualAlliedUnit(ePlayer)) {5814			return false;5815		}5816	}5817#endif58185819	// An enemy ship adjacent to the plot blockades it5820	for (int iEnemyLoop = 0; iEnemyLoop < NUM_DIRECTION_TYPES; ++iEnemyLoop) {5821		CvPlot* pEnemyPlot = plotDirection(getX(), getY(), ((DirectionTypes)iEnemyLoop));58225823#if defined(MOD_GLOBAL_SHORT_EMBARKED_BLOCKADES)5824		if (pEnemyPlot && (pEnemyPlot->isWater() || pEnemyPlot->isCity()) && pEnemyPlot->IsActualEnemyUnit(ePlayer, true, true)) {5825#else5826		if (pEnemyPlot && (pEnemyPlot->isWater() || pEnemyPlot->isCity()) && pEnemyPlot->IsActualEnemyUnit(ePlayer)) {5827#endif5828			return true;5829		}5830	}58315832#if defined(MOD_GLOBAL_ALLIES_BLOCK_BLOCKADES)5833	if (MOD_GLOBAL_ALLIES_BLOCK_BLOCKADES) {5834		// An allied ship adjacent to the plot secures it5835		for (int iAlliedLoop = 0; iAlliedLoop < NUM_DIRECTION_TYPES; ++iAlliedLoop) {5836			CvPlot* pAlliedPlot = plotDirection(getX(), getY(), ((DirectionTypes)iAlliedLoop));58375838			if (pAlliedPlot && (pAlliedPlot->isWater() || pAlliedPlot->isCity()) && pAlliedPlot->IsActualAlliedUnit(ePlayer)) {5839				return false;5840			}5841		}5842	}5843#endif58445845	// An enemy ship 2 tiles away blockades it5846	int iRange = 2;5847	CvPlot* pLoopPlot = NULL;58485849	for (int iDX = -iRange; iDX <= iRange; iDX++) {5850		for (int iDY = -iRange; iDY <= iRange; iDY++) {5851			pLoopPlot = plotXY(getX(), getY(), iDX, iDY);5852			if (!pLoopPlot || plotDistance(getX(), getY(), pLoopPlot->getX(), pLoopPlot->getY()) != iRange) {5853				continue;5854			}58555856#if defined(MOD_GLOBAL_SHORT_EMBARKED_BLOCKADES)5857			if (pLoopPlot->isWater() && pLoopPlot->IsActualEnemyUnit(ePlayer, true, true)) {5858#else5859			if (pLoopPlot->isWater() && pLoopPlot->IsActualEnemyUnit(ePlayer)) {5860#endif5861				return true;5862			}5863		}5864	}58655866	return false;5867}

Calls

Called by