While trying to fix an issue with Multiple Production in ExtraModMod, I noticed a few issues related to unhappy production that are also present in More Naval AI. I'm attaching a savegame that allows to reproduce all of them. The first (and less important) one is that unhappy production will be shown in the information text that appears in the city GUI for commerce and science (these can be seen by placing the mouse on top of the research or commerce in the upper left corner of the city GUI).
The second is that unhappy production is calculated only in the getProductionDifference and getYieldRate methods of CvCity, but not in getBaseYieldRate. The result of this problem can be seen in the information text that appears for the forge. The total production of the city is 13, and then it gets 9 additional production from the unhappy population thanks to the Pillar of Chains. But the forge information text, instead of showing 5 additional hammers, shows only 3, because it is not taking into account the production that comes from unhappy population. All other GUI improvements introduced by BUG will also have the same error.
Although in the mentioned case the error only relates to the GUI, the issue gets more serious when we take into account that the AI is using getBaseYieldRate to value buildings (in CvCityAI) or civics (in CvPlayerAI). Therefore, I reckon that all of the AI's production related calculations are wrong as soon as a city gets unhappy production.
The attached source code (created against r1647) fixes both issues.
Fixed in [r1652]
Related
Commit: [r1652]