Explorar el Código

another fix for #1325 to cater for portals

(cherry picked from commit 4a587582d0)
tags/v0.4.2^2
Big Bad Waffle hace 4 años
padre
commit
e1b4f9c344
Se han modificado 1 ficheros con 24 adiciones y 10 borrados
  1. +24
    -10
      src/server/world/map.js

+ 24
- 10
src/server/world/map.js Ver fichero

@@ -442,17 +442,31 @@ module.exports = {
//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);
if (!path.length)
return true;
const { x, y } = path[path.length - 1];
const isFullPath = (s.x === x && s.y === y);
const fnCanPath = positions => {
return positions.some(p => {
const path = physics.getPath(pos, p);
//Are we on the position?
if (!path.length)
return true;

const { x, y } = path[path.length - 1];
//Can we reach the position?
const isFullPath = (p.x === x && p.y === y);
if (isFullPath)
return true;

return false;
});
};

const canPathToSpawn = fnCanPath(this.spawn);

if (canPathToSpawn)
return true;

return isFullPath;
});
const portals = objects.objects.filter(o => o.portal);
const canPathToPortal = fnCanPath(portals);

return canPath;
return canPathToPortal;
}
};

Cargando…
Cancelar
Guardar