Another potential trade-denial-related bug has popped up in the topic
This is weird; anyone ever see this?
You can't ask an AI civ to run Emancipation because they will redline it with the message TXT_KEY_DENIAL_ANGER_CIVIC ("We don't want to deal with the unhappiness"). However, that kind of denial message seems like it should come from asking them to switch
out of Emancipation, not into it. Here's the very brief bit of CvPlayerAI::AI_civicTrade() that is causing it:
Code:
if (getCivicPercentAnger(eCivic) > 0)
{
return DENIAL_ANGER_CIVIC;
}
That would make sense if a positive return value from CvPlayer::getCivicPercentAnger() means that your people will become unhappy if you run the suggested civic. But a positive return value instead means that you will get unhappiness if you
aren't running it. Note that you can see the true meaning of this return value by looking at how the same function is used in CvCity::unhappyLevel().
Unfortunately, fixing this properly is a little tricky. The quick and dirty method would be to do something like this:
Code:
if (getCivicPercentAnger(getCivics((CivicOptionTypes)(GC.getCivicInfo(eCivic).getCivicOptionType())),true) > 0)
{
return DENIAL_ANGER_CIVIC;
}
That basically says "if switching out of our current civic of the same type as the suggested one can cause unhappiness, deny." So, for example, if the AI is in Emancipation and the human is suggesting Caste System, they'll deny. But if the AI is running Caste System and the human is suggesting Emancipation, they'll consider it. This did work for me in a brief test.
Note that this fix assumes there is a maximum of one civic of each type that can cause unhappiness in other nations. This should work fine in the original game where Emancipation is the only such civic, but wouldn't be so hot if multiple civics have been modified to cause that sort of unhappiness. That'd require a much more complex check where you'd have to try and determine how much civic-related unhappiness you currently have and compare it to how much civic-related unhappiness you'd have if you switched.