Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aa7ca7fe6: Linkgraph node index order must be maintained due to other references. #7431

Merged
merged 1 commit into from Mar 30, 2019

Conversation

PeterN
Copy link
Member

@PeterN PeterN commented Mar 28, 2019

Linkgraph nodes require a specific order that was maintained by swapping just the last
element for the node to be removed. std::vector::erase() changed this to removing the
node is then shuffling the remain items down, which upsets other references to this
indices. This causes deleted nodes to still be referenced and vice-versa.

This is fixed by switching back to the original swap & pop method.

…er references.

Linkgraph nodes require a specific order that was maintained by swapping just the last
element for the node to be removed. std::vector::erase() changed this to removing the
node is then shuffling the remain items down, which upsets other references to this
indices.

This is fixed by switching back to the original swap & pop method.
@PeterN
Copy link
Member Author

PeterN commented Mar 28, 2019

Attached a savegame that will crash within a few game days without this fix:
pr7431.zip

@PeterN PeterN added the regression It used to work, and now it's broken. label Mar 28, 2019
@PeterN PeterN merged commit 32fda83 into OpenTTD:master Mar 30, 2019
@PeterN PeterN deleted the fix-aa7ca7fe6 branch March 30, 2019 22:19
@planetmaker planetmaker added the backport requested This PR should be backport to current release (RC / stable) label Apr 6, 2019
@PeterN PeterN removed the backport requested This PR should be backport to current release (RC / stable) label Apr 8, 2019
@PeterN
Copy link
Member Author

PeterN commented Apr 8, 2019

Backport is not necessary as the change that caused the regression came after the 1.9 branch.

douiwby pushed a commit to douiwby/OpenTTD that referenced this pull request Apr 16, 2020
…er references. (OpenTTD#7431)

Linkgraph nodes require a specific order that was maintained by swapping just the last
element for the node to be removed. std::vector::erase() changed this to removing the
node is then shuffling the remain items down, which upsets other references to this
indices.

This is fixed by switching back to the original swap & pop method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression It used to work, and now it's broken.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants