From e3ebe46bf4c4fd4d5cf97ca21c2f3c34bf3deb23 Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 2 Jul 2024 18:01:50 -0500 Subject: [PATCH] fix: defer actions until connection entity exists --- app/engine.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/engine.js b/app/engine.js index b875aab..3bf4058 100644 --- a/app/engine.js +++ b/app/engine.js @@ -51,15 +51,19 @@ export default class Engine { } } this.server.addPacketListener('Action', (connection, payload) => { - this.incomingActions.push([this.connectedPlayers.get(connection).entity, payload]); + this.incomingActions.push([connection, payload]); }); } acceptActions() { for (const [ - entity, + connection, payload, ] of this.incomingActions) { + if (!this.connectedPlayers.get(connection)) { + continue; + } + const {entity} = this.connectedPlayers.get(connection); const {Controlled, Ecs, Interacts, Inventory, Wielder} = entity; switch (payload.type) { case 'changeSlot': {