From 3f03ffc4c477a994b933918bad3c9666960c990f Mon Sep 17 00:00:00 2001 From: Big Bad Waffle Date: Fri, 20 Dec 2019 20:00:05 +0200 Subject: [PATCH] fixes #1325 --- src/server/world/instancer.js | 2 +- src/server/world/map.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/server/world/instancer.js b/src/server/world/instancer.js index 3d860a29..8249e5b9 100644 --- a/src/server/world/instancer.js +++ b/src/server/world/instancer.js @@ -93,7 +93,7 @@ module.exports = { if (spawnEvent.changed) msg.keepPos = false; - if ((msg.keepPos) && (!physics.isValid(obj.x, obj.y))) + if (msg.keepPos && (!physics.isValid(obj.x, obj.y) || !map.canPathFromPos(obj))) msg.keepPos = false; if (!msg.keepPos || !obj.has('x') || (map.mapFile.properties.isRandom && obj.instanceId !== map.seed)) { diff --git a/src/server/world/map.js b/src/server/world/map.js index a478c72c..3ca7c5ca 100644 --- a/src/server/world/map.js +++ b/src/server/world/map.js @@ -437,5 +437,19 @@ module.exports = { let spawns = this.spawn.filter(s => (((s.maxLevel) && (s.maxLevel >= level)) || (!s.maxLevel))); return spawns[0]; + }, + + //Find if any spawns can path to a position. This is important for when maps change and players + // log in on tiles that aren't blocking but not able to reach anywhere useful + canPathFromPos: function (pos) { + const canPath = this.spawn.some(s => { + const path = physics.getPath(pos, s); + const { x, y } = path[path.length - 1]; + const isFullPath = (s.x === x && s.y === y); + + return isFullPath; + }); + + return canPath; } };