Bazaar developer reference

CvCity::GetLocalResourceWonderProductionMod(BuildingTypes, CvString *) const

Defined in
CvCity.cpp, line 8886
Class
CvCity
Hook name
CivHooks::CvCity_GetLocalResourceWonderProductionMod

Hooks

static bool BeforeCvCity_GetLocalResourceWonderProductionMod(const CvCity* self, BuildingTypes eBuilding, CvString* toolTipSink, int& result);static void AfterCvCity_GetLocalResourceWonderProductionMod(const CvCity* self, BuildingTypes eBuilding, CvString* toolTipSink, int& result);static int ReplaceCvCity_GetLocalResourceWonderProductionMod(int (*original)(const CvCity*, BuildingTypes, CvString*), const CvCity* self, BuildingTypes eBuilding, CvString* toolTipSink);CivRegisterBefore<CivHooks::CvCity_GetLocalResourceWonderProductionMod>(host, &BeforeCvCity_GetLocalResourceWonderProductionMod);CivRegisterAfter<CivHooks::CvCity_GetLocalResourceWonderProductionMod>(host, &AfterCvCity_GetLocalResourceWonderProductionMod);CivRegisterReplace<CivHooks::CvCity_GetLocalResourceWonderProductionMod>(host, &ReplaceCvCity_GetLocalResourceWonderProductionMod);

Code

8886int CvCity::GetLocalResourceWonderProductionMod(BuildingTypes eBuilding, CvString* toolTipSink) const8887{8888	VALIDATE_OBJECT88898890	int iMultiplier = 0;88918892	CvAssertMsg(eBuilding > -1 && eBuilding < GC.getNumBuildingInfos(), "Invalid building index. Please show Jon.");8893	CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eBuilding);8894	if(pkBuildingInfo)8895	{8896		// Is this even a wonder?8897		const CvBuildingClassInfo& kBuildingClassInfo = pkBuildingInfo->GetBuildingClassInfo();8898		if(!::isWorldWonderClass(kBuildingClassInfo) &&8899		        !::isTeamWonderClass(kBuildingClassInfo) &&8900		        !::isNationalWonderClass(kBuildingClassInfo))8901		{8902			return 0;8903		}8904		8905#if defined(MOD_TRADE_WONDER_RESOURCE_ROUTES)8906		// Are we using a trade route to ship the wonder resource from/to this city?8907		bool bWonderResourceIn = false;8908		bool bWonderResourceOut = false;8909		if (MOD_TRADE_WONDER_RESOURCE_ROUTES) {8910			CvGameTrade* pGameTrade = GC.getGame().GetGameTrade();8911			for (uint ui = 0; ui < pGameTrade->m_aTradeConnections.size(); ui++)8912			{8913				if (pGameTrade->IsTradeRouteIndexEmpty(ui))8914				{8915					continue;8916				}89178918				if (pGameTrade->m_aTradeConnections[ui].m_eConnectionType == TRADE_CONNECTION_WONDER_RESOURCE)8919				{8920					CvCity* pOriginCity = CvGameTrade::GetOriginCity(pGameTrade->m_aTradeConnections[ui]);8921					CvCity* pDestCity = CvGameTrade::GetDestCity(pGameTrade->m_aTradeConnections[ui]);89228923					if (pDestCity->getX() == getX() && pDestCity->getY() == getY())8924					{8925						ResourceTypes eWonderResource = ::getWonderResource();8926						bWonderResourceIn = (eWonderResource != NO_RESOURCE && pOriginCity->GetNumResourceLocal(eWonderResource) > 0);8927					}8928					else8929					{8930						if (pOriginCity->getX() == getX() && pOriginCity->getY() == getY())8931						{8932							bWonderResourceOut = true;8933						}8934					}89358936					break;8937				}8938			}8939			// if (bWonderResourceIn) CUSTOMLOG("Shipping a wonder resource into %s", getName().c_str());8940			// if (bWonderResourceOut) CUSTOMLOG("Shipping a wonder resource out of %s", getName().c_str());8941		}8942#endif89438944		// Resource wonder bonus8945		for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++)8946		{8947			const ResourceTypes eResource = static_cast<ResourceTypes>(iResourceLoop);8948			CvResourceInfo* pkResource = GC.getResourceInfo(eResource);8949			if(pkResource)8950			{8951				int iBonus = pkResource->getWonderProductionMod();8952				if(iBonus != 0)8953				{8954#if defined(MOD_TRADE_WONDER_RESOURCE_ROUTES)8955					bool bHasLocalResource = IsHasResourceLocal(eResource, /*bTestVisible*/ false);8956					if (MOD_TRADE_WONDER_RESOURCE_ROUTES) {8957						// We're shipping one in, or we're not shipping our only one out, or we have more than one8958						bHasLocalResource = bWonderResourceIn || (m_paiNumResourcesLocal[eResource] == 1 && !bWonderResourceOut) || (m_paiNumResourcesLocal[eResource] > 1);8959					}8960					if(bHasLocalResource)8961#else8962					if(IsHasResourceLocal(eResource, /*bTestVisible*/ false))8963#endif8964					{8965						// Depends on era of wonder?8966						EraTypes eResourceObsoleteEra = pkResource->getWonderProductionModObsoleteEra();8967						if (eResourceObsoleteEra != NO_ERA)8968						{8969							EraTypes eWonderEra;8970							TechTypes eTech = (TechTypes)pkBuildingInfo->GetPrereqAndTech();8971							if(eTech != NO_TECH)8972							{8973								CvTechEntry* pEntry = GC.GetGameTechs()->GetEntry(eTech);8974								if(pEntry)8975								{8976									eWonderEra = (EraTypes)pEntry->GetEra();8977									if(eWonderEra != NO_ERA)8978									{8979										if (eWonderEra >= eResourceObsoleteEra)8980										{8981											continue;8982										}8983									}8984								}8985							}8986						}89878988						iMultiplier += iBonus;8989						GC.getGame().BuildProdModHelpText(toolTipSink, "TXT_KEY_PRODMOD_WONDER_LOCAL_RES", iBonus, pkBuildingInfo->GetDescription());8990					}8991				}8992			}8993		}89948995	}89968997	return iMultiplier;8998}

Calls

Called by