Bazaar developer reference

CvHomelandAI::ExecuteSSPartAdds()

Defined in
CvHomelandAI.cpp, line 4618
Class
CvHomelandAI
Hook name
CivHooks::CvHomelandAI_ExecuteSSPartAdds

Hooks

static bool BeforeCvHomelandAI_ExecuteSSPartAdds(CvHomelandAI* self);static void AfterCvHomelandAI_ExecuteSSPartAdds(CvHomelandAI* self);static void ReplaceCvHomelandAI_ExecuteSSPartAdds(void (*original)(CvHomelandAI*), CvHomelandAI* self);CivRegisterBefore<CivHooks::CvHomelandAI_ExecuteSSPartAdds>(host, &BeforeCvHomelandAI_ExecuteSSPartAdds);CivRegisterAfter<CivHooks::CvHomelandAI_ExecuteSSPartAdds>(host, &AfterCvHomelandAI_ExecuteSSPartAdds);CivRegisterReplace<CivHooks::CvHomelandAI_ExecuteSSPartAdds>(host, &ReplaceCvHomelandAI_ExecuteSSPartAdds);

Code

4617/// Moves a spaceship part into the spaceship if already there4618void CvHomelandAI::ExecuteSSPartAdds()4619{4620	CvCity* pLoopCity;4621	CvCity* pCapitalCity = NULL;4622	int iLoopCity = 0;4623	for(pLoopCity = m_pPlayer->firstCity(&iLoopCity); pLoopCity != NULL; pLoopCity = m_pPlayer->nextCity(&iLoopCity))4624	{4625		if(pLoopCity->isCapital())4626		{4627			pCapitalCity = pLoopCity;4628			break;4629		}4630	}46314632	if(pCapitalCity != NULL)4633	{4634		FStaticVector< CvHomelandUnit, 64, true, c_eCiv5GameplayDLL >::iterator it;4635		for(it = m_CurrentMoveUnits.begin(); it != m_CurrentMoveUnits.end(); ++it)4636		{4637			UnitHandle pUnit = m_pPlayer->getUnit(it->GetID());4638			if(!pUnit)4639			{4640				continue;4641			}46424643			if(pUnit->plot() == pCapitalCity->plot())4644			{4645				if(GC.getLogging() && GC.getAILogging())4646				{4647					CvString strLogString;4648					CvString strTemp;4649					strTemp = pUnit->getUnitInfo().GetDescription();4650					strLogString.Format("Adding %s to spaceship, X: %d, Y: %d", strTemp.GetCString(), pUnit->getX(), pUnit->getY());4651					LogHomelandMessage(strLogString);4652				}46534654				pUnit->PushMission(CvTypes::getMISSION_SPACESHIP());4655				UnitProcessed(pUnit->GetID());4656			}46574658			else if (TurnsToReachTarget(pUnit, pCapitalCity->plot()) == 0)4659			{4660				pUnit->PushMission(CvTypes::getMISSION_MOVE_TO(), pCapitalCity->getX(), pCapitalCity->getY());4661				pUnit->PushMission(CvTypes::getMISSION_SPACESHIP());4662				pUnit->finishMoves();4663				UnitProcessed(pUnit->GetID());46644665				if(GC.getLogging() && GC.getAILogging())4666				{4667					CvString strLogString;4668					CvString strTemp;4669					strTemp = pUnit->getUnitInfo().GetDescription();4670					strLogString.Format("Moving %s to spaceship and adding it directly in", strTemp.GetCString(), pUnit->getX(), pUnit->getY());4671					LogHomelandMessage(strLogString);4672				}4673			}4674		}4675	}4676}

Calls

Called by