Bug #2441
openai/default: Clean up on every early return from cityresult_fill()
0%
Description
cityresult_fill() switches the player's government to the goal government and, for a virtual city, temporarily gives the center tile to the player.
The restore is only at the end of the function; three early returns missed it.
The missing-city-center assert path leaks the result and the virtual city, and leaves the government and tile owner changed.
Te "all tiles worked" return leaves the government changed.
The final sanity asserts leak the result.
In practice the first two paths are unreachable (the center is always iterated, and best_other takes the first non-center tile whatever its value), so this is just a bug on assert paths rather than a live one.
The patch makes every return do the right thing.
Found while reading the code for #2440.
Files
Updated by Marko Lindqvist about 3 hours ago
- Category set to AI
- Status changed from New to In Review
- Assignee set to Marko Lindqvist
- Target version set to 3.4.0