Bazaar developer reference

CvUnit::load()

Defined in
CvUnit.cpp, line 4454
Class
CvUnit
Hook name
CivHooks::CvUnit_load

Hooks

static bool BeforeCvUnit_load(CvUnit* self);static void AfterCvUnit_load(CvUnit* self);static void ReplaceCvUnit_load(void (*original)(CvUnit*), CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_load>(host, &BeforeCvUnit_load);CivRegisterAfter<CivHooks::CvUnit_load>(host, &AfterCvUnit_load);CivRegisterReplace<CivHooks::CvUnit_load>(host, &ReplaceCvUnit_load);

Code

4454void CvUnit::load()4455{4456	VALIDATE_OBJECT4457	IDInfo* pUnitNode;4458	CvUnit* pLoopUnit;4459	CvPlot* pPlot;4460	int iPass;44614462	pPlot = plot();44634464	if(!pPlot || !canLoad(*pPlot))4465	{4466		return;4467	}446844694470	for(iPass = 0; iPass < 2; iPass++)4471	{4472		pUnitNode = pPlot->headUnitNode();44734474		while(pUnitNode != NULL)4475		{4476			pLoopUnit = ::getUnit(*pUnitNode);4477			pUnitNode = pPlot->nextUnitNode(pUnitNode);44784479			if(pLoopUnit && canLoadUnit(*pLoopUnit, *pPlot))4480			{4481				if((iPass == 0) ? (pLoopUnit->getOwner() == getOwner()) : (pLoopUnit->getTeam() == getTeam()))4482				{4483					setTransportUnit(pLoopUnit);4484					break;4485				}4486			}4487		}44884489		if(isCargo())4490		{4491			break;4492		}4493	}4494}

Calls

Called by