From 286f969f940bc4b929c72ca93d6322b82992c32e Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Sat, 23 Mar 2024 10:58:46 +0000 Subject: [PATCH] Remove computers from both lookups when they timeout In 5d8c46c7e61117ede5d6315efc81a4ae498f34ba, we switched to using UUIDs for looking up computers (rather than an integer ID). However, for compatibility in some of the command code, we need to maintain the old integer lookup map. Most of the code was updated to handle this, *except* the code to remove a computer from the registry. This meant that we'd fail to remove a computer from the UUID lookup map, so computers ended up in a phantom state where they were destroyed, but still accessible. This is not an issue on 1.20.4, because the legacy int lookup map was removed. Fixes #1760 --- .../shared/computer/core/ServerComputerRegistry.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputerRegistry.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputerRegistry.java index 34f76b19d..326562c7a 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputerRegistry.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputerRegistry.java @@ -42,13 +42,14 @@ public ServerComputer get(int sessionId, @Nullable UUID instanceId) { } void update() { - var it = getComputers().iterator(); + var it = computersByInstanceId.values().iterator(); while (it.hasNext()) { var computer = it.next(); if (computer.hasTimedOut()) { computer.unload(); computer.onRemoved(); it.remove(); + computersByInstanceUuid.remove(computer.getInstanceUUID()); } else { computer.tickServer(); }