Bazaar developer reference

CvPlot::updateVisibility()

Defined in
CvPlot.cpp, line 598
Class
CvPlot
Hook name
CivHooks::CvPlot_updateVisibility

Hooks

static bool BeforeCvPlot_updateVisibility(CvPlot* self);static void AfterCvPlot_updateVisibility(CvPlot* self);static void ReplaceCvPlot_updateVisibility(void (*original)(CvPlot*), CvPlot* self);CivRegisterBefore<CivHooks::CvPlot_updateVisibility>(host, &BeforeCvPlot_updateVisibility);CivRegisterAfter<CivHooks::CvPlot_updateVisibility>(host, &AfterCvPlot_updateVisibility);CivRegisterReplace<CivHooks::CvPlot_updateVisibility>(host, &ReplaceCvPlot_updateVisibility);

Code

598void CvPlot::updateVisibility()599{600	if(!GC.IsGraphicsInitialized())601	{602		return;603	}604605	setLayoutDirty(true);606607	// Any unit that has visibility rules (it can become invisible to another player) needs to update itself.608	const TeamTypes eActiveTeam = GC.getGame().getActiveTeam();609	CvAssert(eActiveTeam != NO_TEAM);610	if (eActiveTeam != NO_TEAM)611	{612		IDInfo* pUnitNode = headUnitNode();613		while (pUnitNode != NULL)614		{615			CvUnit* pLoopUnit = GetPlayerUnit(*pUnitNode);616			pUnitNode = nextUnitNode(pUnitNode);617618			if (pLoopUnit)619			{620				InvisibleTypes eInvisibleType = pLoopUnit->getInvisibleType();621				if (eInvisibleType != NO_INVISIBLE)622				{623					// This unit has visibility rules, send a message that it needs to update itself.624					auto_ptr<ICvUnit1> pDllUnit(new CvDllUnit(pLoopUnit));625					gDLL->GameplayUnitVisibility(pDllUnit.get(), (pLoopUnit->getTeam() == eActiveTeam)?true:isInvisibleVisible(eActiveTeam, eInvisibleType), true, 0.01f);626				}627			}628		}629630		// Must update the other layers as well631		CvPlotManager& kPlotManager = GC.getMap().plotManager();632		int iNumLayers = kPlotManager.GetNumLayers();633		for (int iLayer = 0; iLayer < iNumLayers; ++iLayer)634		{	635			const CvIDInfoFixedVector &kUnits = kPlotManager.GetUnitsByIndex(m_iX, m_iY, iLayer);636			for (CvIDInfoFixedVector::const_iterator itrUnit = kUnits.begin(); itrUnit != kUnits.end(); ++itrUnit)637			{638				CvUnit* pLoopUnit = ::getUnit(*itrUnit);639				if (pLoopUnit)640				{641					InvisibleTypes eInvisibleType = pLoopUnit->getInvisibleType();642					if (eInvisibleType != NO_INVISIBLE)643					{644						// This unit has visibility rules, send a message that it needs to update itself.645						auto_ptr<ICvUnit1> pDllUnit(new CvDllUnit(pLoopUnit));646						gDLL->GameplayUnitVisibility(pDllUnit.get(), (pLoopUnit->getTeam() == eActiveTeam)?true:isInvisibleVisible(eActiveTeam, eInvisibleType), true, 0.01f);647					}648				}649			}650		}651	}652}

Calls

Called by