Hooks
static bool BeforeCvPlayer_found(CvPlayer* self, int iX, int iY, ReligionTypes eReligion);static void AfterCvPlayer_found(CvPlayer* self, int iX, int iY, ReligionTypes eReligion);static void ReplaceCvPlayer_found(void (*original)(CvPlayer*, int, int, ReligionTypes), CvPlayer* self, int iX, int iY, ReligionTypes eReligion);CivRegisterBefore<CivHooks::CvPlayer_found>(host, &BeforeCvPlayer_found);CivRegisterAfter<CivHooks::CvPlayer_found>(host, &AfterCvPlayer_found);CivRegisterReplace<CivHooks::CvPlayer_found>(host, &ReplaceCvPlayer_found);
Code
7530#if defined(MOD_GLOBAL_RELIGIOUS_SETTLERS)7531void CvPlayer::found(int iX, int iY, ReligionTypes eReligion)7532#else7533void CvPlayer::found(int iX, int iY)7534#endif7535{7536 if(!canFound(iX, iY))7537 {7538 return;7539 }75407541 SetTurnsSinceSettledLastCity(0);75427543#if defined(MOD_GLOBAL_RELIGIOUS_SETTLERS) && defined(MOD_API_EXTENSIONS)7544 CvCity* pCity = initCity(iX, iY, true, true, eReligion);7545#else7546 CvCity* pCity = initCity(iX, iY);7547#endif7548 CvAssertMsg(pCity != NULL, "City is not assigned a valid value");7549 if(pCity == NULL)7550 return;75517552 int iExtraTerritoryClaim = GetPlayerTraits()->GetExtraFoundedCityTerritoryClaimRange();7553 for (int i = 0; i < iExtraTerritoryClaim; i++)7554 {7555 CvPlot* pPlotToAcquire = pCity->GetNextBuyablePlot();75567557 // maybe the player owns ALL of the plots or there are none available?7558 if(pPlotToAcquire)7559 {7560 pCity->DoAcquirePlot(pPlotToAcquire->getX(), pPlotToAcquire->getY());7561 }7562 }75637564 for(int iI = 0; iI < GC.getNumBuildingClassInfos(); iI++)7565 {7566 const BuildingClassTypes eBuildingClass = static_cast<BuildingClassTypes>(iI);7567 CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo(eBuildingClass);7568 if(pkBuildingClassInfo)7569 {7570 const BuildingTypes eLoopBuilding = ((BuildingTypes)(getCivilizationInfo().getCivilizationBuildings(iI)));7571 if(eLoopBuilding != NO_BUILDING)7572 {7573 CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eLoopBuilding);7574 if(pkBuildingInfo)7575 {7576 if(pkBuildingInfo->GetFreeStartEra() != NO_ERA)7577 {7578 if(GC.getGame().getStartEra() >= pkBuildingInfo->GetFreeStartEra())7579 {7580 if(pCity->canConstruct(eLoopBuilding))7581 {7582 pCity->GetCityBuildings()->SetNumRealBuilding(eLoopBuilding, 1);75837584#if defined(MOD_EVENTS_CITY)7585 if (MOD_EVENTS_CITY) {7586 GAMEEVENTINVOKE_HOOK(GAMEEVENT_CityConstructed, pCity->getOwner(), pCity->GetID(), eLoopBuilding, false, false);7587 }7588#endif7589 }7590 }7591 }7592 }7593 }7594 }7595 }75967597 AwardFreeBuildings(pCity);75987599 DoUpdateNextPolicyCost();76007601 if(isHuman() && getAdvancedStartPoints() < 0)7602 {7603 // Human player is prompted to choose production BEFORE the AI runs for the turn.7604 // So we'll force the AI strategies on the city now, just after it is founded.7605 // And if the very first turn, we haven't even run player strategies once yet, so do that too.7606 if(GC.getGame().getGameTurn() == 0)7607 {7608 this->GetEconomicAI()->DoTurn();7609 this->GetMilitaryAI()->DoTurn();7610 this->GetReligionAI()->DoTurn();7611 this->GetEspionageAI()->DoTurn();7612 this->GetTradeAI()->DoTurn();7613 }7614 pCity->GetCityStrategyAI()->DoTurn();7615 pCity->chooseProduction();7616 pCity->doFoundMessage();76177618 // If this is the first city (or we still aren't getting tech for some other reason notify the player)7619 if(GetPlayerTechs()->GetCurrentResearch() == NO_TECH && GetScienceTimes100() > 0)7620 {7621 if(GetID() == GC.getGame().getActivePlayer())7622 {7623 chooseTech();7624 }7625 }7626 }7627 else7628 {7629 pCity->doFoundMessage();76307631 // AI civ, may need to redo city specializations7632 GetCitySpecializationAI()->SetSpecializationsDirty(SPECIALIZATION_UPDATE_CITY_FOUNDED);7633 }76347635 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();7636 if(pkScriptSystem)7637 {7638 CvLuaArgsHandle args;7639 args->Push(GetID());7640 args->Push(pCity->getX());7641 args->Push(pCity->getY());7642 7643 bool bResult;7644 LuaSupport::CallHook(pkScriptSystem, "PlayerCityFounded", args.get(), bResult);7645 }7646}