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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion megamek/src/megamek/common/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,10 @@ public boolean hasEntity(int entityId) {
* (probably due to double-blind) ignore it.
*/
public synchronized void removeEntity(int id, int condition) {
// always attempt to remove the entity with this ID from the entities collection
// as it may have gotten stuck there.
entities.removeIf(ent -> (ent.getId() == id));

Entity toRemove = getEntity(id);
if (toRemove == null) {
// This next statement has been cluttering up double-blind
Expand All @@ -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.

removeEntityPositionLookup(toRemove);

Expand Down