From 7b50e32b284c66bb5f72cea0d8fa33b3f54d880f Mon Sep 17 00:00:00 2001 From: phosit Date: Sat, 13 Sep 2025 17:50:53 +0200 Subject: [PATCH] Always delete metadata when destroying entities On newly deserialized clients there is no property for the destroied entities. Because of that the metadata of the entity wasn't remembered in the event and wasn't destroied. --- .../mods/public/simulation/ai/common-api/shared.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/binaries/data/mods/public/simulation/ai/common-api/shared.js b/binaries/data/mods/public/simulation/ai/common-api/shared.js index 2d0f735ef5..0467b3d3d5 100644 --- a/binaries/data/mods/public/simulation/ai/common-api/shared.js +++ b/binaries/data/mods/public/simulation/ai/common-api/shared.js @@ -237,9 +237,6 @@ SharedScript.prototype.ApplyEntitiesDelta = function(state) for (const evt of state.events.Destroy) { - if (!this._entities.has(evt.entity)) - continue;// probably should remove the event. - if (foundationFinished[evt.entity]) evt.SuccessfulFoundation = true; @@ -251,9 +248,12 @@ SharedScript.prototype.ApplyEntitiesDelta = function(state) evt.metadata[player] = this._entityMetadata[player][evt.entity]; const entity = this._entities.get(evt.entity); - for (const entCol of this._entityCollections.values()) - entCol.removeEnt(entity); - this.entities.removeEnt(entity); + if (entity) + { + for (const entCol of this._entityCollections.values()) + entCol.removeEnt(entity); + this.entities.removeEnt(entity); + } this._entities.delete(evt.entity); this._entitiesModifications.delete(evt.entity);