City center yield not added

Five years later and here we still are. Stupid buggy mess. :badcomp:
 
Aww man, my 5 food city center is useless.
I'm surprised there's no fix for this.

Oh well, I'll remember not to accept peace treaties from the AI.
In one instance, asking for peace on my turn and taking the city that was offered gave me a useless city center. Loading and trying again with me setting the deal parameters gave me an ok city.

Same with luxury deals on AI turn "oh hey, you used to trade that incense to me, you have two, let's trade!"
I DON'T HAVE TWO.
 
I think I might have accidentally stumbled upon the source of the bug, though I haven't tested it myself. The bad code is in CvCity:: DoCreatePuppet(). TL;DR: the bug is caused by code that is not only not working as intended, but would (almost) never work as intended.

When a city is puppeted, all tiles within a 2-tile radius are supposed to have Working City Overrides set to the newly puppet city. Working City Overrides happen when a tile can be worked by multiple cities: the city to which the tile is currently allocated is its Working City Override, whereas the city that acquired the tile first is the Working City.

The problem is that the code doesn't do this at all. Instead, it follows the following strange set of instructions: for every tile within a 3-tile radius around the city, it checks whether that looped tile is within 2 range of the tile that is (City's X coordinate, City's Y coordinate) away from the looped tile. If it is, then that second tile's Working City Override is set to the newly puppeted city. This condition rarely ever fires off, and when it does, I think it will usually get cleaned up by one of the many updateWorkingCity() calls that exist in the game. When it doesn't get cleaned up though, you should experience an issue identical to the one people have been posting in screenshots here: the city to which the tile belongs cannot work it because its Working City Override is set to another city, the player cannot unset the Working City Override because the UI doesn't let them do it to city tiles, and the Working City Override city cannot work the tile either because it's outside of the city's work range (since cities have to be at least 3 tiles apart). If updateWorkingCity() is called in an incorrect order or not at all when a city flips from a peace deal, that might explain why people have only seen the bug as a result of getting a city through a peace deal.
 
Sorry if this should be posted in the Tech Support forum... mods, feel free to move this thread if it's inappropriate to post it here, but most of the threads there about in-game bugs don't seem to get addressed.

I am playing a game where I cannot work the base tile of my annexed city. This is the tile that the city is actually sitting on. That's 4 food and 2 hammers that I'm being deprived every turn. I think this happened after I annexed the city, because I didn't notice it when the city was a puppet. The screenshot (and the game save) are attached below. If I try to click on the center tile to work it, it acts as the "Reset Tiles" button and moves all my other citizens around but still does not work the base tile. Has anyone ever seen this bug? Is there a fix?

For what it's worth, I am using the EUI but no other mods.
 

Attachments

  • Isabella_0483 AD-0915.Civ5Save
    1.5 MB · Views: 259
  • Screen Shot 2016-04-28 at 12.10.50 AM.jpg
    Screen Shot 2016-04-28 at 12.10.50 AM.jpg
    382.5 KB · Views: 347
I used to have that bug sometimes, I think it got patched a while while back. Last time I had it was vanilla.
 
This is a known bug. If you accept an AI city from peace deal during AI's turn, it will happen. However if you only accept peacedeal during YOUR turn, you won't see this bug.
 
This is a known bug. If you accept an AI city from peace deal during AI's turn, it will happen. However if you only accept peacedeal during YOUR turn, you won't see this bug.

Well that's annoying, especially given that it's been a known bug for years, given how long this thread has been here. But at least I know how to avoid it (assuming I can remember your advice).
 
Still got this bug in 1.0.3.279

I made the deal for the city during my turn, not during the AI turn.

Constantinople is 4 tiles away as the closet city.
 

Attachments

  • 20160613175648_1.jpg
    20160613175648_1.jpg
    332.5 KB · Views: 274
same bug i think. city tile not providing any output, from city annexed in AI players offer of peace. Oct 2016. this is a very old bug.
 
I've found a fix for the bug.

TL;DR: In CvCityCitizens::IsCanWork(), change the line
if(pPlot->plotCheck(PUF_canSiege, GetOwner()) != NULL)
to
if(pPlot != m_pCity->plot() && pPlot->plotCheck(PUF_canSiege, GetOwner()) != NULL)

Here is how the bug breaks down:
  • A peace deal is accepted where a city is transferred;
  • CvPlayer::acquireCity() is called before CvTeam::makePeace();
  • This creates a new CvCity object owned by the new owner and deletes the old CvCity;
  • The new CvCity - like any new CvCity in Civ V - tries working its center tile;
  • Unlike with a peaceful city transfer, the Civs are still at war. Unlike with a conquest (where the garrison is destroyed), there's an enemy unit on the city's tile;
  • Enemy units on a tile prevent cities from working that tile;
  • Therefore, the city cannot work its center tile;
  • Since it's expected that a city will work its center tile from its creation to its destruction, the city is never told to start working the tile, since such a command is supposed to be redundant;
  • The result is that the city never works its center tile till (perhaps) it changes hands.
A bug like this can be fixed in a number of different ways, with different pros and cons. An obvious solution would be to call CvTeam::makePeace() before CvPlayer::acquireCity(); however, the comments in CvDealClasses::FinalizeDeal() warn strongly against processing peace treaties before other items in trades. I don't know why.

I have written a UI mod, and have added this incidental bug fix to it, so if anyone wants a version of Civ V without this bug, that's one option. The attachment is the version that works with multiplayer and (I believe) with achievements, created using MPMPM: unzip the file in the location they specify under Premade DLC packs.
 

Attachments

  • MP_MODSPACK.7z
    3.1 MB · Views: 115
Top Bottom