Bazaar developer reference

CvCity::IsBlockaded() const

Defined in
CvCity.cpp, line 10076
Class
CvCity
Hook name
CivHooks::CvCity_IsBlockaded

Hooks

static bool BeforeCvCity_IsBlockaded(const CvCity* self, bool& result);static void AfterCvCity_IsBlockaded(const CvCity* self, bool& result);static bool ReplaceCvCity_IsBlockaded(bool (*original)(const CvCity*), const CvCity* self);CivRegisterBefore<CivHooks::CvCity_IsBlockaded>(host, &BeforeCvCity_IsBlockaded);CivRegisterAfter<CivHooks::CvCity_IsBlockaded>(host, &AfterCvCity_IsBlockaded);CivRegisterReplace<CivHooks::CvCity_IsBlockaded>(host, &ReplaceCvCity_IsBlockaded);

Code

10076bool CvCity::IsBlockaded() const10077{10078	VALIDATE_OBJECT10079	bool bHasWaterRouteBuilding = false;1008010081	CvBuildingXMLEntries* pkGameBuildings = GC.GetGameBuildings();1008210083	// Loop through adding the available buildings10084	for(int i = 0; i < GC.GetGameBuildings()->GetNumBuildings(); i++)10085	{10086		BuildingTypes eBuilding = (BuildingTypes)i;10087		CvBuildingEntry* pkBuildingInfo = pkGameBuildings->GetEntry(i);10088		if(pkBuildingInfo)10089		{10090			if(pkBuildingInfo->AllowsWaterRoutes())10091			{10092				if(GetCityBuildings()->GetNumActiveBuilding(eBuilding) > 0)10093				{10094					bHasWaterRouteBuilding = true;10095					break;10096				}10097			}10098		}10099	}1010010101	// there is no water route building, so it can't be blockaded10102	if(!bHasWaterRouteBuilding)10103	{10104		return false;10105	}10106	10107#if defined(MOD_GLOBAL_ADJACENT_BLOCKADES)10108	if (MOD_GLOBAL_ADJACENT_BLOCKADES) {10109		for (int iPortLoop = 0; iPortLoop < NUM_DIRECTION_TYPES; ++iPortLoop) {10110			CvPlot* pAdjacentPlot = plotDirection(getX(), getY(), ((DirectionTypes)iPortLoop));10111			if (pAdjacentPlot && pAdjacentPlot->isWater() && !pAdjacentPlot->isBlockaded(getOwner())) {10112				return false;10113			}10114		}10115	10116		return true;10117	} else {10118#endif10119		int iRange = 2;10120		CvPlot* pLoopPlot = NULL;1012110122		for(int iDX = -iRange; iDX <= iRange; iDX++)10123		{10124			for(int iDY = -iRange; iDY <= iRange; iDY++)10125			{10126				pLoopPlot = plotXYWithRangeCheck(getX(), getY(), iDX, iDY, iRange);10127				if(!pLoopPlot)10128				{10129					continue;10130				}1013110132				if(pLoopPlot->isWater() && pLoopPlot->getVisibleEnemyDefender(getOwner()))10133				{10134					return true;10135				}10136			}10137		}1013810139		return false;10140#if defined(MOD_GLOBAL_ADJACENT_BLOCKADES)10141	}10142#endif10143}

Calls

Called by