Dresden
Emperor
- Joined
- Jul 10, 2008
- Messages
- 1,081
Breaking this off from the 0.19.1 topic....
This post is about addressing the AP "hibernation" problems. Occasionally, the AP votes will stop coming for long stretches of time. One such occurrence is when a non-AP-owner Pope switches to Free Religion after a recent Pope vote. DanF did a good job explaining this situation in a post I shall be quoting below with some spoilerized code and reference blocks.
And this leads us into problem #2. If the pope vote actually fails (e.g. if the only eligible candidate doesn't have enough votes on his own and everyone else abstains) we are pushed back into the same situation. In the second attached save, after our 8 turn waiting period, the pope vote has come up but Napolean doesn't have enough votes to win. (I WBed away Hinduism from all but one of his and Tokugawa's cities and abstained on our vote too.) However, the Pope timer gets reset back to 4 and so we're once again forced into a long waiting period; this one approximately 50 turns.
In this case, I think we need to look at CvGame::doVoteResults(), check for a secgen/pope vote that had no winner, and reset the secgen/pope timer if necessary which should give us the standard 9-turn delay. Testing on that will happen in the next couple days.
But wait, there's more! There are also other reports of AP weirdness such as the following quote from r_rolo1 in a BUG topic where this issue came up.
And finally there's the old issue of the disappearing hammer bonus that I am trying very hard to ignore until somebody forces a save upon me.
This post is about addressing the AP "hibernation" problems. Occasionally, the AP votes will stop coming for long stretches of time. One such occurrence is when a non-AP-owner Pope switches to Free Religion after a recent Pope vote. DanF did a good job explaining this situation in a post I shall be quoting below with some spoilerized code and reference blocks.
The original test saves for this posted by LegionSteve awhile ago weren't optimal; the first was a well-after-the-fact illustration and the second was pretty significantly WorldBuildered. I wanted something a little closer to true game conditions so I've attached a less-severly modified save based on the ungy-04 SG. In that game originally Wang Kon had built the AP and switched to Free Religion a few turns before teching Mass Media and obsoleting the thing. In this modification, the AP has been magically transported to Paris so when Wang goes FR he will become ineligible to be the Pope, causing CvGame::clearSecretaryGeneral() to be triggered. Additionally, the human player was given a tiny Hindu city so that we can get in on the voting and better see what's happening. With the original 3.17 logic, a pope vote is almost 40 turns away for the reasons Dan outlined above. With Dan's proposed change, the pope vote comes up after just 8 turns.Hmmm, after some tests with a modified CvVictoryScreen.py to show me the timer values for votes and Resident elections, I can't say I'm really much wiser.
There is just one odd thing:
When the VoteTimer reaches 0 it triggers a vote and the timer is then reset to iVoteInterval (9 turns for normal game speed). But if there are no valid resolutions the VoteTimer is set to 0 again immediately, hence the game tries for a new vote on the very next turn. The ResidentTimer starts with 4 (GlobalDefines DIPLO_VOTE_SECRETARY_GENERAL_INTERVAL) and decrements every time the VoteTimer reaches 0. If the ResidentTimer reaches 0 itself the next vote will be the election of a new Resident (this vote is always possible). But in case there are no valid resolutions the timers develop like this:
If there is no valid Resident (former Resident was not the builder of AP and changed Religion or switched to FR) the game skips the normal vote triggering procedure when the VoteTimer reaches 0. The VoteTimer is therefore reset to 9, the ResidentTimer decrements and the game goes on. Thus it takes much longer until a new Resident gets elected and until valid votes can be triggered again (up to almost 50 turns scaled for game speed). Maybe that was the reason why some thought the AP was in a state of hibernation. But it *will* come back to life eventually, so it's not really a bug that breaks the AP completely.Spoiler :Code:[SIZE="3"] VoteTimer | ResidentTimer 9 | 4 8 | 4 7 | 4 6 | 4 5 | 4 4 | 4 3 | 4 2 | 4 1 | 4 0 | 4 (no vote possible) 0 | 3 (no vote possible) 0 | 2 (no vote possible) 0 | 1 (no vote possible) 0 | 0 (Vote for new Resident)[/SIZE]
I would suggest to alter CvGame::clearSecretaryGeneral (the method that's called when the Resident loses his position due to FR or another Religion):
The blue code sets the ResidentTimer to 0 so that a new Resident can be elected at the earliest possible voting date (VoteTimer = 0).Spoiler :Code:[SIZE="3"]void CvGame::clearSecretaryGeneral(VoteSourceTypes eVoteSource) { for (int j = 0; j < GC.getNumVoteInfos(); ++j) { CvVoteInfo& kVote = GC.getVoteInfo((VoteTypes)j); if (kVote.isVoteSourceType(eVoteSource)) { if (kVote.isSecretaryGeneral()) { VoteTriggeredData kData; kData.eVoteSource = eVoteSource; kData.kVoteOption.eVote = (VoteTypes)j; kData.kVoteOption.iCityId = -1; kData.kVoteOption.szText.empty(); kData.kVoteOption.ePlayer = NO_PLAYER; setVoteOutcome(kData, NO_PLAYER_VOTE); [COLOR="RoyalBlue"][B]setSecretaryGeneralTimer(eVoteSource, 0);[/B][/COLOR] } } } }[/SIZE]
I don't have much time right now unfortunately to test this thoroughly (just tried with LegionSteve's save and it worked fine). I also hadn't encountered that problem personally so I don't have any other saves or testbeds to try it out...
And this leads us into problem #2. If the pope vote actually fails (e.g. if the only eligible candidate doesn't have enough votes on his own and everyone else abstains) we are pushed back into the same situation. In the second attached save, after our 8 turn waiting period, the pope vote has come up but Napolean doesn't have enough votes to win. (I WBed away Hinduism from all but one of his and Tokugawa's cities and abstained on our vote too.) However, the Pope timer gets reset back to 4 and so we're once again forced into a long waiting period; this one approximately 50 turns.
In this case, I think we need to look at CvGame::doVoteResults(), check for a secgen/pope vote that had no winner, and reset the secgen/pope timer if necessary which should give us the standard 9-turn delay. Testing on that will happen in the next couple days.
But wait, there's more! There are also other reports of AP weirdness such as the following quote from r_rolo1 in a BUG topic where this issue came up.
Hopefully he'll come up with some saves so we can see what's happening there as this sounds like a somewhat different issue.The problem is that if a certain vote is called ( like the inocuous OB agreement ) and it happens something that changes the AI mind about it before the AI vote on that ( like for a example, a war between 2 AP members ( this already happened to me )), the vote sometimes gets stuck and no vote result ( and by extension no other AP votes ) is posted ,sometimes during that whole session, sometimes during a smaller period ( reloading or simply save/load normally solves it ).
I'm pretty sure that I have a save in those conditions ( I discovered that it is highly reproducible anyway: get a AP vote, DOW on a AP member on the same turn, see the vote disapear ) buried in my saves folder.... gimme a day or two![]()
And finally there's the old issue of the disappearing hammer bonus that I am trying very hard to ignore until somebody forces a save upon me.
