Closed ricanuck closed 7 years ago
Do you have crosschecked it with the new version? Has Firaxis changed something?
IIRC #439 was created before the new patch released. That being said, the file in question has changed in the latest patch. These changes seem to exclusively affect great work info
This bug may have been there since launch, but was only now uncovered by the relative elegance of IDS's code. IDS "re-shuffles" everything to give the list of cities order. When doing this, the code uncovers this game-breaking bug. It is well hidden behind that veil of a "pseudo-name" for a city that has been occupied in war. I never noticed it, because I never paid to much attention to the city tooltips, especially of those occupied cities that I demanded. As long as you do not demand more cities than the occupied ones, you will never notice the bug (vanilla diplo deal window), and even if you demand more, the "extra" demanded must coincidentally be one of the "fake" occupied ones to trigger the bug (in the form of an impossibility to add that hidden duplicate city to the demand). What are the odds for that? Exactly. My educated guess is that it has been there forever. IDS uncovered it.
It is a very hard to explain bug; you only understand it after you have seen it in action and try to solve it. Let's see if I can put it into words:
Each button for a city in the original code is an object that points to a city of that player. That referred object seems to be the correct one, since whenever you click the button that you know has to point to a given city in a peace deal, you get exactly that city (tested). Now, that button also holds values as city IDs, and also corresponding city data. This is where the mismatch occurs. In the case of the original owner of the occupied cities, the value ForTypeName (the "name" of the city object) is not consistent with the city data linked by the button. In the case of the occupier, everything works as intended, that's why you see in the saves that the side of the occupier has no problems. If you check the code I submitted here, that code basically catches the bug when it happens, and transforms the outcome into the expected one. It's the very definition of a patch, but it should not be the final solution. Problem is, that solution can only come from Firaxis. Why? Because I suspect that the DealManager function (DLL) is creating this mess; it is the function called to list the cities available for trade (possibly to exclude capitals), and somehow that function is not returning the true occupied cities for the original owner but something else, in the form of a cityID value that points to another, non-occupied city of that player. If you look at my little code above after reading this, you will probably get a good idea of what is going on and how I am "catch-and'release" ing the expected result (because the cityID value on the side of the occupier is the correct and consistent one).
My opinion after hours on this? The solution here works fine, and we may have uncovered and patched a really serious bug at least until Firaxis acknowledges it and then fixes it. In the meanwhile, as I see it right now, our Diplomacydealview.lua is the only one giving the expected result when it comes to peace deals that involve occupied cities.
Test it.
See:
Could be a good test for this code. I am pretty sure I know exactly what goes on in the case linked.
Alright, I think this PR has matured long enough. I'm going to merge it tonight so we can get some nightly user feedback before we let this go free in the workshop version
What has citysupport.lua have to do with the diplo deal view?
Edit: Oh, OK, I see. I think I know what is going on, I changed the file a little since I committed in my own setup, will check with your save.
Yeap, that was it... your save works fine in my setup.
Adds convoluted code to compensate for the huge vanilla bug that mismatches cities internal values in the deal window. For details see #439 conversations towards the end. Also contains code from another branch/PR that hides city details when not owned by local player.