Bazaar developer reference

CvUnit::repairFleet()

Defined in
CvUnit.cpp, line 9596
Class
CvUnit
Hook name
CivHooks::CvUnit_repairFleet

Hooks

static bool BeforeCvUnit_repairFleet(CvUnit* self, bool& result);static void AfterCvUnit_repairFleet(CvUnit* self, bool& result);static bool ReplaceCvUnit_repairFleet(bool (*original)(CvUnit*), CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_repairFleet>(host, &BeforeCvUnit_repairFleet);CivRegisterAfter<CivHooks::CvUnit_repairFleet>(host, &AfterCvUnit_repairFleet);CivRegisterReplace<CivHooks::CvUnit_repairFleet>(host, &ReplaceCvUnit_repairFleet);

Code

9596bool CvUnit::repairFleet()9597{9598	VALIDATE_OBJECT95999600	CvPlot* pPlot = plot();96019602	if(!canRepairFleet(pPlot))9603		return false;96049605	// Do the repairing - first this hex9606	int iUnitLoop;9607	for (iUnitLoop = 0; iUnitLoop < pPlot->getNumUnits(); iUnitLoop++)9608	{9609		CvUnit *pUnit = pPlot->getUnitByIndex(iUnitLoop);9610		if (pUnit->getOwner() == getOwner() && (pUnit->isEmbarked() || pUnit->getDomainType() == DOMAIN_SEA))9611		{9612			pUnit->changeDamage(-pUnit->getDamage());9613		}9614	}96159616	// And then all adjacent9617	for (int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)9618	{9619		CvPlot *pAdjacentPlot = plotDirection(getX(), getY(), ((DirectionTypes)iI));96209621		if(pAdjacentPlot != NULL)9622		{9623			for (iUnitLoop = 0; iUnitLoop < pAdjacentPlot->getNumUnits(); iUnitLoop++)9624			{	9625				CvUnit *pUnit = pAdjacentPlot->getUnitByIndex(iUnitLoop);9626				if (pUnit->getOwner() == getOwner() && (pUnit->isEmbarked() || pUnit->getDomainType() == DOMAIN_SEA))9627				{9628					pUnit->changeDamage(-pUnit->getDamage());9629				}9630			}9631		}9632	}96339634	if(pPlot->isActiveVisible(false))9635	{9636		auto_ptr<ICvUnit1> pDllUnit(new CvDllUnit(this));9637		gDLL->GameplayUnitActivate(pDllUnit.get());9638	}96399640	if(IsGreatPerson())9641	{9642		CvPlayer& kPlayer = GET_PLAYER(getOwner());9643#if defined(MOD_EVENTS_GREAT_PEOPLE)9644		kPlayer.DoGreatPersonExpended(getUnitType(), this);9645#else9646		kPlayer.DoGreatPersonExpended(getUnitType());9647#endif9648	}96499650	kill(true);96519652	return true;9653}

Calls

Called by