From 012809dffdf4a65526451eae59831319cd5274f3 Mon Sep 17 00:00:00 2001 From: Shaun Date: Fri, 15 Apr 2022 11:45:55 +0200 Subject: [PATCH] work --- src/server/world/atlas.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/server/world/atlas.js b/src/server/world/atlas.js index 0b03f128..8120c3bf 100644 --- a/src/server/world/atlas.js +++ b/src/server/world/atlas.js @@ -58,6 +58,27 @@ module.exports = { } }); }, + + removeObjectFromInstancedZone: async function (thread, obj, callback) { + await new Promise(res => { + const cb = this.registerCallback(res); + + thread.worker.send({ + method: 'forceSavePlayer', + args: { + playerName: obj.name, + callbackId: cb + } + }); + }); + + thread.worker.kill(); + this.threads.spliceWhere(t => t === thread); + + if (callback) + callback(); + }, + removeObject: function (obj, skipLocal, callback) { if (!skipLocal) objects.removeObject(obj); @@ -67,11 +88,7 @@ module.exports = { return; if (thread.instanced) { - thread.worker.kill(); - this.threads.spliceWhere(t => t === thread); - - if (callback) - callback(); + this.removeObjectFromInstancedZone(thread, obj, callback); return; }