Bazaar developer reference

CvFlavorManager::AdjustWeightsForMap()

Defined in
CvFlavorManager.cpp, line 381
Class
CvFlavorManager
Hook name
CivHooks::CvFlavorManager_AdjustWeightsForMap

Hooks

static bool BeforeCvFlavorManager_AdjustWeightsForMap(CvFlavorManager* self);static void AfterCvFlavorManager_AdjustWeightsForMap(CvFlavorManager* self);static void ReplaceCvFlavorManager_AdjustWeightsForMap(void (*original)(CvFlavorManager*), CvFlavorManager* self);CivRegisterBefore<CivHooks::CvFlavorManager_AdjustWeightsForMap>(host, &BeforeCvFlavorManager_AdjustWeightsForMap);CivRegisterAfter<CivHooks::CvFlavorManager_AdjustWeightsForMap>(host, &AfterCvFlavorManager_AdjustWeightsForMap);CivRegisterReplace<CivHooks::CvFlavorManager_AdjustWeightsForMap>(host, &ReplaceCvFlavorManager_AdjustWeightsForMap);

Code

380/// Make some adjustments to flavors based on the map we're on381void CvFlavorManager::AdjustWeightsForMap()382{383	int iTotalLandTiles;384	int iNumPlayers;385	double iTilesPerPlayer;386	double fAdjust;387	int iAdjust;388389	iTotalLandTiles = GC.getMap().getLandPlots();390	iNumPlayers = GC.getGame().countMajorCivsAlive();391392	if(iNumPlayers > 0)393	{394		int iNumFlavorTypes = GC.getNumFlavorTypes();395		// Find tiles per player396		iTilesPerPlayer = (double)iTotalLandTiles / (double)iNumPlayers;397398		// Compute +/- addition399		//400		// We want this to be logarithmic, since that is the curve between lots of players on a duel map401		// and a few player on a huge map.  "FLAVOR_STANDARD_LOG10_TILES_PER_PLAYER" is the typical log10 of402		// tiles per player.  We go up and down from this point (multiplying by a coefficient) from here403		fAdjust = log10(iTilesPerPlayer) - GC.getFLAVOR_STANDARD_LOG10_TILES_PER_PLAYER();404		fAdjust *= (double)GC.getFLAVOR_EXPANDGROW_COEFFICIENT();405		iAdjust = (int)fAdjust;406407		int iFlavorMaxValue = /*20*/ GC.getPERSONALITY_FLAVOR_MAX_VALUE();408		int iFlavorMinValue = /*0*/ GC.getPERSONALITY_FLAVOR_MIN_VALUE();409410		int iExpansionIndex = GC.getInfoTypeForString("FLAVOR_EXPANSION");411		int iGrowthIndex = GC.getInfoTypeForString("FLAVOR_GROWTH");412413		// Boost expansion414		CvAssert(iExpansionIndex >= 0 && iExpansionIndex < iNumFlavorTypes);415		if (iExpansionIndex >= 0 && iExpansionIndex < iNumFlavorTypes)416		{417			m_piPersonalityFlavor[iExpansionIndex] += iAdjust;418			if(m_piPersonalityFlavor[iExpansionIndex] > iFlavorMaxValue)419			{420				m_piPersonalityFlavor[iExpansionIndex] = iFlavorMaxValue;421			}422		}423424		// Reduce growth425		CvAssert(iGrowthIndex >= 0 && iGrowthIndex < iNumFlavorTypes);426		if (iGrowthIndex >= 0 && iGrowthIndex < iNumFlavorTypes)427		{428			m_piPersonalityFlavor[iGrowthIndex] -= iAdjust;429			if(m_piPersonalityFlavor[iGrowthIndex] < iFlavorMinValue)430			{431				m_piPersonalityFlavor[iGrowthIndex] = iFlavorMinValue;432			}433		}434435		// Save these off as our core personality and broadcast updates436		ResetToBasePersonality();437	}438}

Calls

Called by