Hooks
static bool BeforeCvGameTrade_DisplayTemporaryPopupTradeRoute(CvGameTrade* self, int iDestX, int iDestY, TradeConnectionType type, DomainTypes eDomain);static void AfterCvGameTrade_DisplayTemporaryPopupTradeRoute(CvGameTrade* self, int iDestX, int iDestY, TradeConnectionType type, DomainTypes eDomain);static void ReplaceCvGameTrade_DisplayTemporaryPopupTradeRoute(void (*original)(CvGameTrade*, int, int, TradeConnectionType, DomainTypes), CvGameTrade* self, int iDestX, int iDestY, TradeConnectionType type, DomainTypes eDomain);CivRegisterBefore<CivHooks::CvGameTrade_DisplayTemporaryPopupTradeRoute>(host, &BeforeCvGameTrade_DisplayTemporaryPopupTradeRoute);CivRegisterAfter<CivHooks::CvGameTrade_DisplayTemporaryPopupTradeRoute>(host, &AfterCvGameTrade_DisplayTemporaryPopupTradeRoute);CivRegisterReplace<CivHooks::CvGameTrade_DisplayTemporaryPopupTradeRoute>(host, &ReplaceCvGameTrade_DisplayTemporaryPopupTradeRoute);
Code
1602void CvGameTrade::DisplayTemporaryPopupTradeRoute(int iDestX, int iDestY, TradeConnectionType type, DomainTypes eDomain)1603{1604 int i,n;1605 int plotsX[MAX_PLOTS_TO_DISPLAY], plotsY[MAX_PLOTS_TO_DISPLAY];16061607 int iOriginX,iOriginY;1608 PlayerTypes eOriginPlayer;1609 bool bSuccess = false;1610 CvAStarNode* pPathfinderNode = NULL;1611 TradeConnection tempTradeConnection;16121613 {1614 auto_ptr<ICvUnit1> pSelectedUnit(GC.GetEngineUserInterface()->GetHeadSelectedUnit());1615 CvUnit* pkSelectedUnit = GC.UnwrapUnitPointer(pSelectedUnit.get());1616 CvAssert(pkSelectedUnit != NULL);1617 if (pkSelectedUnit)1618 {1619 iOriginX = pkSelectedUnit->getX();1620 iOriginY = pkSelectedUnit->getY();1621 eOriginPlayer = pkSelectedUnit->getOwner();1622 }1623 else1624 {1625 return;1626 }1627 }16281629 switch (eDomain)1630 {1631 case DOMAIN_LAND:1632 bSuccess = GC.GetInternationalTradeRouteLandFinder().GeneratePath(iOriginX, iOriginY, iDestX, iDestY, eOriginPlayer, false);1633 pPathfinderNode = GC.GetInternationalTradeRouteLandFinder().GetLastNode();1634 break;1635 case DOMAIN_SEA:1636 bSuccess = GC.GetInternationalTradeRouteWaterFinder().GeneratePath(iOriginX, iOriginY, iDestX, iDestY, eOriginPlayer, false);1637 pPathfinderNode = GC.GetInternationalTradeRouteWaterFinder().GetLastNode();1638 break;1639 }16401641 gDLL->TradeVisuals_DestroyRoute(TEMPORARY_POPUPROUTE_ID,GC.getGame().getActivePlayer());1642 if (bSuccess && pPathfinderNode != NULL) {1643 CopyPathIntoTradeConnection(pPathfinderNode, &tempTradeConnection);1644 n = tempTradeConnection.m_aPlotList.size();1645 if (n>0 && n <=MAX_PLOTS_TO_DISPLAY) {1646 for (i=0;i<n;++i) {1647 plotsX[i] = tempTradeConnection.m_aPlotList[i].m_iX;1648 plotsY[i] = tempTradeConnection.m_aPlotList[i].m_iY;1649 }1650 gDLL->TradeVisuals_NewRoute(TEMPORARY_POPUPROUTE_ID,eOriginPlayer,type,n,plotsX,plotsY);1651 gDLL->TradeVisuals_ActivatePopupRoute(TEMPORARY_POPUPROUTE_ID);1652 }1653 }1654 m_CurrentTemporaryPopupRoute.iPlotX = iDestX;1655 m_CurrentTemporaryPopupRoute.iPlotY = iDestY;1656 m_CurrentTemporaryPopupRoute.type = type;1657}