(sdk) int iFundedPercent or calculateTotalCommerce()

Ri-Hatz

Chieftain
Joined
Jun 23, 2008
Messages
93
I want to determine how much gold a player "could" get per turn if research is at 0%.
Below is what im working with right now. the function CvPlayer::calculateTotalCommerce() is not working really well, cause it also returns high values even if the player has very high maintenance or unit costs.
About the iFundedPercent. What does it return? Does it get as high as 100 but not above?


Code:
		int iNetCommerce = 1 + getCommerceRate(COMMERCE_GOLD) + getCommerceRate(COMMERCE_RESEARCH) + std::max(0, getGoldPerTurn());
		int iNetExpenses = calculateInflatedCosts() + std::min(0, getGoldPerTurn());

		int iFundedPercent = (100 * (iNetCommerce - iNetExpenses)) / std::max(1, iNetCommerce);

Code:
int CvPlayer::calculateTotalCommerce() const
{
	int iTotalCommerce = calculateBaseNetGold() + calculateBaseNetResearch();

	for (int i = 0; i < NUM_COMMERCE_TYPES; ++i)
	{
		if (COMMERCE_GOLD != i && COMMERCE_RESEARCH != i)
		{
			iTotalCommerce += getCommerceRate((CommerceTypes)i);
		}
	}

	return iTotalCommerce;
}
 
I don't think you can do the calculation this way. For one thing, each city's commerce is converted into Research/Gold using the percentage rates and then the building multipliers affect the values. So you need to perform the calculation for each city individually and sum them up.

You basically need to copy the functions that calculate the actual Gold and change your copies to use a 100% tax rate.
 
Top Bottom