Hooks
static bool BeforeCvCity_ChangeNumResourceLocal(CvCity* self, ResourceTypes eResource, int iChange);static void AfterCvCity_ChangeNumResourceLocal(CvCity* self, ResourceTypes eResource, int iChange);static void ReplaceCvCity_ChangeNumResourceLocal(void (*original)(CvCity*, ResourceTypes, int), CvCity* self, ResourceTypes eResource, int iChange);CivRegisterBefore<CivHooks::CvCity_ChangeNumResourceLocal>(host, &BeforeCvCity_ChangeNumResourceLocal);CivRegisterAfter<CivHooks::CvCity_ChangeNumResourceLocal>(host, &AfterCvCity_ChangeNumResourceLocal);CivRegisterReplace<CivHooks::CvCity_ChangeNumResourceLocal>(host, &ReplaceCvCity_ChangeNumResourceLocal);
Code
3373void CvCity::ChangeNumResourceLocal(ResourceTypes eResource, int iChange)3374{3375 VALIDATE_OBJECT33763377 CvAssertMsg(eResource >= 0, "eIndex expected to be >= 0");3378 CvAssertMsg(eResource < GC.getNumResourceInfos(), "eIndex expected to be < GC.getNumResourceInfos()");33793380 if(iChange != 0)3381 {3382 bool bOldHasResource = IsHasResourceLocal(eResource, /*bTestVisible*/ false);33833384 m_paiNumResourcesLocal.setAt(eResource, m_paiNumResourcesLocal[eResource] + iChange);33853386 if(bOldHasResource != IsHasResourceLocal(eResource, /*bTestVisible*/ false))3387 {3388 if(IsHasResourceLocal(eResource, /*bTestVisible*/ false))3389 {3390 processResource(eResource, 1);33913392 // Notification letting player know his city gets a bonus for wonders3393 int iWonderMod = GC.getResourceInfo(eResource)->getWonderProductionMod();3394 if(iWonderMod != 0)3395 {3396 CvNotifications* pNotifications = GET_PLAYER(getOwner()).GetNotifications();3397 if(pNotifications)3398 {3399 Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_RESOURCE_WONDER_MOD");3400 strText << getNameKey() << GC.getResourceInfo(eResource)->GetTextKey() << iWonderMod;3401 Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_RESOURCE_WONDER_MOD_SUMMARY");3402 strSummary << getNameKey() << GC.getResourceInfo(eResource)->GetTextKey();3403 pNotifications->Add(NOTIFICATION_DISCOVERED_BONUS_RESOURCE, strText.toUTF8(), strSummary.toUTF8(), getX(), getY(), eResource);3404 }3405 }3406 }3407 else3408 {3409 processResource(eResource, -1);3410 }3411 }34123413 // Building Culture change for a local resource3414 for(int iBuildingLoop = 0; iBuildingLoop < GC.getNumBuildingInfos(); iBuildingLoop++)3415 {3416 const BuildingTypes eBuilding = static_cast<BuildingTypes>(iBuildingLoop);3417 CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eBuilding);3418 if(pkBuildingInfo)3419 {3420 // Do we have this building?3421 if(GetCityBuildings()->GetNumBuilding(eBuilding) > 0)3422 {3423 // Does eBuilding give culture with eResource?3424 int iCulture = pkBuildingInfo->GetResourceCultureChange(eResource);34253426 if(iCulture != 0)3427#if defined(MOD_BUGFIX_MINOR)3428 iCulture *= GetCityBuildings()->GetNumBuilding(eBuilding);3429#endif3430 ChangeJONSCulturePerTurnFromBuildings(iCulture * iChange);34313432 // Does eBuilding give faith with eResource?3433 int iFaith = pkBuildingInfo->GetResourceFaithChange(eResource);34343435 if(iFaith != 0)3436#if defined(MOD_BUGFIX_MINOR)3437 iFaith *= GetCityBuildings()->GetNumBuilding(eBuilding);3438#endif3439 ChangeFaithPerTurnFromBuildings(iFaith * iChange);3440 }3441 }3442 }3443 }3444}