Bug fix: Keep generated resource tile state valid across recompute redraws#44
Open
instafluff0 wants to merge 2 commits into
Open
Bug fix: Keep generated resource tile state valid across recompute redraws#44instafluff0 wants to merge 2 commits into
instafluff0 wants to merge 2 commits into
Conversation
Owner
|
Thanks for the fix. This all looks fine except for the deletion of line 24930, why'd you do that? Also seeing this reminds me I wanted to combine all those |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a fix for som_rybov's bug report, here, save attached.
In a nutshell, I traced the crash back to
Tile_has_colonygetting a NULL tile. However patching that (bailing if NULL) fixed the symptom but not the underlying problem.As best I can tell, the crash is from
Trade_Net::recompute_resourcesreceiving a bad tile pointer while we have the temporarily expanded Map.TileCount to include generated resource tiles.patch_Trade_Net_recompute_resources buildsis->resource_tiles.Trade_Net::recompute_resourcesloops over 0 .. Map.TileCount - 1.Map_get_tile_when_recomputing_resources_*functions are supposed to return:Tile::has_colony(NULL)means (I think) the first tile lookup returned NULL.So if a resource recompute happens while saved_tile_count is already active, then saved_tile_count can be overwritten with an already-inflated tile count. Then an artificial tile index is misclassified as a real map index, so the wrapper calls real Map_get_tile with an out-of-range index. That returns NULL.
The saved game moves to the next turn after these changes, and calculated resources appear correct afterward.
Also: I noticed in the course of debugging this we had duplicate
define Tile_has_colonyentries in civ_prog_objects.csv and removed the 2nd one.PS - holy moly, the repo is really heating up with PRs. I hope all is well and this isn't all too much too quickly.
bug.zip