瀏覽代碼

fixes #1325

tags/v0.4.1.5
Big Bad Waffle 4 年之前
父節點
當前提交
3f03ffc4c4
共有 2 個檔案被更改,包括 15 行新增1 行删除
  1. +1
    -1
      src/server/world/instancer.js
  2. +14
    -0
      src/server/world/map.js

+ 1
- 1
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)) {


+ 14
- 0
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;
}
};

Loading…
取消
儲存