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

more robust orphan cleanup #2690

Merged
merged 1 commit into from
Mar 3, 2021
Merged

Conversation

NickAragua
Copy link
Member

For some reason, the game's entities collection got out of sync with the rest of its entity management collections, so an entity destroyed in the physical phase was showing up in the game (though with 0 CT structure) when loading a save game made in the end phase.

This change makes game more aggressive about keeping the entities collection clear of entities being removed.

@@ -1402,7 +1406,6 @@ public synchronized void removeEntity(int id, int condition) {
return;
}

entities.remove(toRemove);
entityIds.remove(Integer.valueOf(id));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also remove the id before the if statement?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably wouldn't hurt, but, unlike entities, we don't use that lookup table to drive "get me all the entities in the game" functionality.

Copy link
Contributor

@Windchild292 Windchild292 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant to approve with the recommendation.

@NickAragua NickAragua merged commit 58111d2 into MegaMek:master Mar 3, 2021
@NickAragua NickAragua deleted the fix_entity_orphan branch March 3, 2021 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants