Thunderbrd
C2C War Dog
Ok i had a bit of time and something is really off there. Even after a few turns i had the first wrong value this must have something to do with all the changes in CvUnit::defenderValue and the functions it calls. Alot changed since Koshling added that cache so it seems it's no longer working. I don't think it would be possible to cache it another way because CvUnit::defenderValue seems to return a different value starting at the second time it is called with the same arguments in the same turn.
Ok, so this was the main turn time slowdown issue I've been suspecting has been the big cause of five and 10 minute turn times. I had disabled a seriously important caching as a result of some problems I was having with it that led to this final comment from Alberts as we tried to work out what was wrong.
For the record, I've figured out the issue.
1) CvUnit:defenderValue is not coming up with different answers each time the function is called. If it were, the unit determined to be the target would change or the odds would differ and when the caching is disabled, that is not happening. (I also did some checking to ensure it wasn't happening anyhow and even if it was, with the caching on, it wouldn't be the cause of the original issue because CvUnit::defenderValue is only called when the checksum doesn't come up with a valid hit.
2) The caching is working fine... UNTIL any assassination calls.
3) The reason for this most likely comes down to the fact that we're simply adding numbers to get an appropriate 'hit'. Then we check that against the current hit points to make sure its the same unit and that the unit hasn't been engaged in battle or injured in any way that could change the results of the valuation. What's happening seems to be that this allows the checksum to reference the wrong result set when assassination calls are made.
So the fix is to reinstate the caching but to exclude assassination combat checks and always force those to fully evaluate. Unfortunately, this does suggest there is a fundamental potential flaw in the checksum method that can take place at times and should perhaps have an extra check circumstance to enforce correct referencing. But the speedup is worth it to turn it on without much heavier engineering because you'd rarely ever SEE the problem manifest. If you do, it would likely be a very odd case of the unit attacking an unexpected defender when you actually go to attack. This should not be common but it was quite common with the assassination checks because of the adjustment of the final checksum reference being in increments of 1(even 1*10 or * 100 or * 1000 and the problem would not be uncommon to replicate itself.)
So once this new dll effort has been recommitted to the SVN, I'm hoping that there will be few rule breaches and much faster end turns.
This has been one of the 'big ones' I've been hung up on for a while here.