Hooks
static bool BeforeCvAINavalOperation_SelectInitialMusterPoint(CvAINavalOperation* self, CvArmyAI* pThisArmy, CvPlot*& result);static void AfterCvAINavalOperation_SelectInitialMusterPoint(CvAINavalOperation* self, CvArmyAI* pThisArmy, CvPlot*& result);static CvPlot* ReplaceCvAINavalOperation_SelectInitialMusterPoint(CvPlot* (*original)(CvAINavalOperation*, CvArmyAI*), CvAINavalOperation* self, CvArmyAI* pThisArmy);CivRegisterBefore<CivHooks::CvAINavalOperation_SelectInitialMusterPoint>(host, &BeforeCvAINavalOperation_SelectInitialMusterPoint);CivRegisterAfter<CivHooks::CvAINavalOperation_SelectInitialMusterPoint>(host, &AfterCvAINavalOperation_SelectInitialMusterPoint);CivRegisterReplace<CivHooks::CvAINavalOperation_SelectInitialMusterPoint>(host, &ReplaceCvAINavalOperation_SelectInitialMusterPoint);
Code
3813/// Figure out the initial rally point3814CvPlot* CvAINavalOperation::SelectInitialMusterPoint(CvArmyAI* pThisArmy)3815{3816 CvPlot* pMusterPt = NULL;3817 CvPlot* pStartCityPlot;3818 CvCity* pStartCity;3819 CvPlot* pCurrentPlot;3820 CvPlot* pAdjacentPlot;3821 int iSpacesFromTarget = 0;3822 int iDirectionLoop;3823 CvAStarNode* pNode;3824 bool bMusterPointFound = false;38253826 pStartCity = GetOperationStartCity();3827 if(pStartCity)3828 {3829 pStartCityPlot = pStartCity->plot();38303831 if(pStartCityPlot != NULL)3832 {3833 // Find an adjacent water tile3834 for(iDirectionLoop = 0; iDirectionLoop < NUM_DIRECTION_TYPES && !bMusterPointFound; ++iDirectionLoop)3835 {3836 pAdjacentPlot = plotDirection(pStartCityPlot->getX(), pStartCityPlot->getY(), ((DirectionTypes)iDirectionLoop));3837 if(pAdjacentPlot != NULL && pAdjacentPlot->isWater())3838 {3839 // Generate path3840 GC.getStepFinder().SetData(&m_eEnemy);3841 if(GC.getStepFinder().GeneratePath(pAdjacentPlot->getX(), pAdjacentPlot->getY(), pThisArmy->GetGoalPlot()->getX(), pThisArmy->GetGoalPlot()->getY(), m_eOwner, false))3842 {3843 pNode = GC.getStepFinder().GetLastNode();38443845 // Starting at the end, loop until we find a plot from this owner3846 while(pNode != NULL)3847 {3848 pCurrentPlot = GC.getMap().plotCheckInvalid(pNode->m_iX, pNode->m_iY);38493850 // Is this the deploy point?3851 if(iSpacesFromTarget == GetDeployRange())3852 {3853 pMusterPt = pCurrentPlot;3854 bMusterPointFound = true;3855 break;3856 }38573858 // Move to the previous plot on the path3859 iSpacesFromTarget++;3860 pNode = pNode->m_pParent;3861 }3862 }3863 }3864 }3865 }3866 }38673868 if(pMusterPt != NULL)3869 {3870 SetMusterPlot(pMusterPt);3871 }3872 else3873 {3874 if(GC.getLogging() && GC.getAILogging())3875 {3876 CvString szMsg;3877 szMsg.Format("No muster point found, Naval operation aborting, Target was, X: %d, Y: %d", pThisArmy->GetGoalPlot()->getX(), pThisArmy->GetGoalPlot()->getY());3878 LogOperationSpecialMessage(szMsg);3879 }3880 }38813882 return pMusterPt;3883}