Several cities have or are close to a prepped item on the limit (given mostly 135h per pop due to org rel and forge
Examples:
Antioch - Barracks 15h (150-135) 2 pop
State Religion = Christianity
Antioch's Religions = Judaism only
Antioch has a Forge
Expected multiplier = 1.25
Hypothesis: Whipping 1 population point might give: floor( 1 * 90 * 1.25 ) = 112 H
Barracks Hammers remaining = 150 H - 15 H = 135 H
135 H > 112 H, so it's a 2-pop-whipping action
2-pop-whipping brings us to 240 H / 150 H, as expected: floor( 2 * 90 * 1.25) = 225; 15 H + 225 H = 240 H
So, that example doesn't help, because the City didn't have Christianity in it.
Houston - Theatre 15h (150-135) 2 pop
Houston's Religions = Christianity + Judaism
Houston has a Forge
Expected multiplier = 1.5
Hypothesis: Whipping 1 population point might give: floor( 1 * 90 * 1.5 ) = 135 H
Theatre Hammers remaining = 150 H - 15 H = 135 H
135 H = 135 H, so you'd expect it to be a 1-pop-whipping action, but it's a 2-pop-whipping action. Hence, our hypothesis must be incorrect and the math must be slightly different than guessed.
2-pop-whipping bring us to 285 H / 150 H; floor( 2 * 90 * 1.5 ) = 270; 15 H + 270 H = 285 H. So, at least you don't get free Hammers or anything game-breaking.
If you have 16 H in the Theatre, it becomes a 1-pop-whipping action and you end up with 151 / 150 H in the Theatre.
Thus, the math seems pretty close to what we had hypothesized, but isn't quite there. Probably the best approach at this point would be to code-dive.
Buffalo - Forge 135h (360 - 2*112,5) 3 pop
Yes, I agree, according to our hypothesis, you'd have expected a 2-pop-whipping action for Buffalo's Forge.
Tiwanaku - Aquaduct 30h (300 - 2*135) 2 pop not 3
...
Not working:
Tiwanaku - Aquaduct 30h (300-2*135) 2 pop instead of 3
Well, by "not working," it fits with our hypothesis, in that we'd expect it to be a 2-pop-whipping action.
But, since it is a 2-pop-whipping action and you only get 300 H / 300 H, the game isn't giving any extra Hammers, so there's nothing game-breaking here, again.
I think that the relevant code is likely to be in CvCity.cpp, with the word "hurry" being used instead of "whipping." For example, the following "round up" comments look to be a bit suspicious:
Code:
int CvCity::getHurryCost(bool bExtra, int iProductionLeft, int iHurryModifier, int iModifier) const
{
int iProduction = (iProductionLeft * iHurryModifier + 99) / 100; // round up
if (bExtra)
{
int iExtraProduction = getExtraProductionDifference(iProduction, iModifier);
if (iExtraProduction > 0)
{
int iAdjustedProd = iProduction * iProduction;
// round up
iProduction = (iAdjustedProd + (iExtraProduction - 1)) / iExtraProduction;
}
}
return std::max(0, iProduction);
}
The following functions are probably also be related, but I'm not sufficiently experienced with code-diving to offer any real insights:
Code:
int CvCity::getHurryPopulation(HurryTypes eHurry, int iHurryCost) const
{
if (GC.getHurryInfo(eHurry).getProductionPerPopulation() == 0)
{
return 0;
}
int iPopulation = (iHurryCost - 1) / GC.getGameINLINE().getProductionPerPopulation(eHurry);
return std::max(1, (iPopulation + 1));
}
int CvCity::hurryProduction(HurryTypes eHurry) const
{
int iProduction;
if (GC.getHurryInfo(eHurry).getProductionPerPopulation() > 0)
{
iProduction = (100 * getExtraProductionDifference(hurryPopulation(eHurry) * GC.getGameINLINE().getProductionPerPopulation(eHurry))) / std::max(1, getHurryCostModifier());
FAssert(iProduction >= productionLeft());
}
else
{
iProduction = productionLeft();
}
return iProduction;
}
.....However when a rounding is involved:
It gets more crazy when I look at 90*1,25=112,5 limit and examine how to prep worker (120h)
-8 h/f prep leads to a 2pop whip
-3f/4h prep with forge (=8 h/f) leads to 1pop whip
-4f/3h prep with forge (=7,75 h/f) leads to a 2pop whip
Is that a typo, where you meant to say "-8 h/f prep leads to a 1pop whip"?
Fractional Hammers are not carried-forward into the following turn, so -4f/3h really only gives you 4 H for the 4 F and 3 H for the 3 H, and thus it's not unexpected to only have 7 H at the start of the next turn--you won't have 7.75 H behind the scenes and the "extra" 0.75 H just get lost.