Hooks
static bool BeforeCvDiplomacyAI_SetPlayerNoSettleRequestAccepted(CvDiplomacyAI* self, PlayerTypes ePlayer, bool bValue);static void AfterCvDiplomacyAI_SetPlayerNoSettleRequestAccepted(CvDiplomacyAI* self, PlayerTypes ePlayer, bool bValue);static void ReplaceCvDiplomacyAI_SetPlayerNoSettleRequestAccepted(void (*original)(CvDiplomacyAI*, PlayerTypes, bool), CvDiplomacyAI* self, PlayerTypes ePlayer, bool bValue);CivRegisterBefore<CivHooks::CvDiplomacyAI_SetPlayerNoSettleRequestAccepted>(host, &BeforeCvDiplomacyAI_SetPlayerNoSettleRequestAccepted);CivRegisterAfter<CivHooks::CvDiplomacyAI_SetPlayerNoSettleRequestAccepted>(host, &AfterCvDiplomacyAI_SetPlayerNoSettleRequestAccepted);CivRegisterReplace<CivHooks::CvDiplomacyAI_SetPlayerNoSettleRequestAccepted>(host, &ReplaceCvDiplomacyAI_SetPlayerNoSettleRequestAccepted);
Code
20923void CvDiplomacyAI::SetPlayerNoSettleRequestAccepted(PlayerTypes ePlayer, bool bValue)20924{20925 CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");20926 CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "DIPLOMACY_AI: Invalid Player Index. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");2092720928 if(bValue != IsPlayerNoSettleRequestAccepted(ePlayer))20929 {20930 m_pabPlayerNoSettleRequestAccepted[ePlayer] = bValue;2093120932 PlayerTypes eID = GetPlayer()->GetID();2093320934 int iPlotLoop;2093520936 // Add blocker to plots nearby ePlayer20937 if(bValue)20938 {20939 int iLoopX, iLoopY;20940 CvPlot* pNearbyPlot;20941 int iRange = 6;2094220943 // Loop through all of this player's Cities and create a barrier around them20944 CvCity* pLoopCity;20945 int iCityLoop;20946 for(pLoopCity = GET_PLAYER(ePlayer).firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(ePlayer).nextCity(&iCityLoop))20947 {20948 for(iLoopX = -(iRange); iLoopX <= iRange; iLoopX++)20949 {20950 for(iLoopY = -(iRange); iLoopY <= iRange; iLoopY++)20951 {20952 pNearbyPlot = plotXY(pLoopCity->getX(), pLoopCity->getY(), iLoopX, iLoopY);2095320954 if(pNearbyPlot != NULL)20955 {20956 if(plotDistance(pNearbyPlot->getX(), pNearbyPlot->getY(), pLoopCity->getX(), pLoopCity->getY()) <= iRange)20957 {20958 pNearbyPlot->SetNoSettling(eID, true);20959 }20960 }20961 }20962 }20963 }20964 }20965 // Remove blocker from all plots20966 else20967 {20968 int iNumPlots = GC.getMap().numPlots();20969 for(iPlotLoop = 0; iPlotLoop < iNumPlots; iPlotLoop++)20970 {20971 GC.getMap().plotByIndexUnchecked(iPlotLoop)->SetNoSettling(eID, false);20972 }20973 }20974 }20975}