Hooks
static bool BeforeCvTwoLayerPathFinder_GenerateUnitPath(CvTwoLayerPathFinder* self, const CvUnit* pkUnit, int iXstart, int iYstart, int iXdest, int iYdest, int iInfo, bool bReuse, bool& result);static void AfterCvTwoLayerPathFinder_GenerateUnitPath(CvTwoLayerPathFinder* self, const CvUnit* pkUnit, int iXstart, int iYstart, int iXdest, int iYdest, int iInfo, bool bReuse, bool& result);static bool ReplaceCvTwoLayerPathFinder_GenerateUnitPath(bool (*original)(CvTwoLayerPathFinder*, const CvUnit*, int, int, int, int, int, bool), CvTwoLayerPathFinder* self, const CvUnit* pkUnit, int iXstart, int iYstart, int iXdest, int iYdest, int iInfo, bool bReuse);CivRegisterBefore<CivHooks::CvTwoLayerPathFinder_GenerateUnitPath>(host, &BeforeCvTwoLayerPathFinder_GenerateUnitPath);CivRegisterAfter<CivHooks::CvTwoLayerPathFinder_GenerateUnitPath>(host, &AfterCvTwoLayerPathFinder_GenerateUnitPath);CivRegisterReplace<CivHooks::CvTwoLayerPathFinder_GenerateUnitPath>(host, &ReplaceCvTwoLayerPathFinder_GenerateUnitPath);
Code
2896/// Generate a path, using the supplied unit as the data2897bool CvTwoLayerPathFinder::GenerateUnitPath(const CvUnit* pkUnit, int iXstart, int iYstart, int iXdest, int iYdest, int iInfo /*= 0*/, bool bReuse /*= false*/)2898{2899 if (pkUnit)2900 {2901 CvAssert(gDLL->IsGameCoreThread() || !gDLL->IsGameCoreExecuting());2902 SetData(pkUnit);2903 bool bResult = GeneratePath(iXstart, iYstart, iXdest, iYdest, iInfo, bReuse);2904 if(GC.getLogging() && GC.getAILogging())2905 {2906 CvString strLogString;2907 uint uiChecksum = CRC_INIT;2908 // Loop through the nodes and make a checksum2909 CvAStarNode* pNode = GetLastNode();29102911 // Starting at the end, loop until we find a plot from this owner2912 while(pNode != NULL)2913 {2914 // Just do the X/Y for now2915 uiChecksum = g_CRC32.Calc( &pNode->m_iX, sizeof( pNode->m_iX ), uiChecksum );2916 uiChecksum = g_CRC32.Calc( &pNode->m_iY, sizeof( pNode->m_iY ), uiChecksum );2917 2918 pNode = pNode->m_pParent;2919 }29202921 strLogString.Format("%d, %d, %d, %d, %d, %8x", iXstart, iYstart, iXdest, iYdest, iInfo, uiChecksum);2922 LogPathGeneration(pkUnit, strLogString);2923 }2924 return bResult;2925 }2926 return false;2927}