Bazaar developer reference

CvPlot::Validate(CvMap &)

Defined in
CvPlot.cpp, line 11696
Class
CvPlot
Hook name
CivHooks::CvPlot_Validate

Hooks

static bool BeforeCvPlot_Validate(CvPlot* self, CvMap& kParentMap, int& result);static void AfterCvPlot_Validate(CvPlot* self, CvMap& kParentMap, int& result);static int ReplaceCvPlot_Validate(int (*original)(CvPlot*, CvMap&), CvPlot* self, CvMap& kParentMap);CivRegisterBefore<CivHooks::CvPlot_Validate>(host, &BeforeCvPlot_Validate);CivRegisterAfter<CivHooks::CvPlot_Validate>(host, &AfterCvPlot_Validate);CivRegisterReplace<CivHooks::CvPlot_Validate>(host, &ReplaceCvPlot_Validate);

Code

11692//	Validate the contents of the plot.  This will attempt to clean up inconsistencies.11693//	Returns 0 if no errors or:11694//		bit 0 = true, an error was found in the plot's data11695//		bit 1 = true, the error was un-recoverable11696int CvPlot::Validate(CvMap& kParentMap)11697{11698	int iError = 0;11699	IDInfo* pUnitNode = headUnitNode();1170011701	while(pUnitNode != NULL)11702	{11703		CvUnit* pkUnit = GetPlayerUnit(*pUnitNode);11704		if(pkUnit == NULL)11705		{11706			m_units.deleteNode(pUnitNode);11707			pUnitNode = headUnitNode();11708			iError |= 1;11709		}11710		else11711		{11712			if(pkUnit->getX() != m_iX || pkUnit->getY() != m_iY)11713			{11714				iError |= 1;11715				// Unit thinks it is in another plot.  Unit wins.11716				m_units.deleteNode(pUnitNode);1171711718				CvPlot* pkCorrectPlot = kParentMap.plot(pkUnit->getX(), pkUnit->getY());11719				if(pkCorrectPlot)11720				{11721					if(pkCorrectPlot->getUnitIndex(pkUnit) < 0)	// Already in there?11722						pkCorrectPlot->addUnit(pkUnit, false);		// Nope, add it.11723				}11724				else11725				{11726					// Drat, that plot does not exist.11727					iError |= 2;11728				}1172911730				pUnitNode = headUnitNode();11731			}11732			else11733				pUnitNode = nextUnitNode(pUnitNode);11734		}11735	}1173611737	return iError;11738}

Calls

Called by