Browse Source

bug #1995

tags/v0.12.0.20^2
Shaun 11 months ago
parent
commit
83152909a2
3 changed files with 32 additions and 9 deletions
  1. +10
    -0
      src/server/components/portal/sendObjToZone.js
  2. +19
    -9
      src/server/security/connections.js
  3. +3
    -0
      src/server/world/atlas.js

+ 10
- 0
src/server/components/portal/sendObjToZone.js View File

@@ -46,6 +46,16 @@ const sendObjToZone = async ({ obj, invokingObj, zoneName, toPos, toRelativePos
globalSyncer.processDestroyedObject(obj);
await obj.auth.doSave();

//Inform the main thread that we are rezoning. We do this because if the player
// dc's before rezone is complete the player might become stuck in the main thread
process.send({
method: 'object',
serverId: obj.serverId,
obj: {
rezoning: true
}
});

//We have to do this again. This is because onCollisionEnter in portal is not blocking (even though it is async)
// So physics will carry on and allow the obj to move onto the next tile (changing the position while we save above)
fixPosition(obj, toPos, toRelativePos, invokingObj);


+ 19
- 9
src/server/security/connections.js View File

@@ -44,9 +44,13 @@ module.exports = {
}]
});

await new Promise(res => {
atlas.removeObject(player, false, res);
});
//Rezoning is set to true while rezoning so we don't try to remove objects
// from zones if they are currently rezoning
if (player.rezoning !== true) {
await new Promise(res => {
atlas.removeObject(player, false, res);
});
}
}

if (player.name) {
@@ -123,19 +127,25 @@ module.exports = {
},

logOut: async function (exclude) {
let players = this.players;
const { players } = this;

let pLen = players.length;
for (let i = 0; i < pLen; i++) {
let p = players[i];
const p = players[i];

if ((!p) || (p === exclude) || (!p.auth))
if (!p || p === exclude || !p.auth)
continue;

if (p.auth.username === exclude.auth.username) {
else if (p.auth.username === exclude.auth.username) {
if (p.name && p.zoneId)
await atlas.forceSavePlayer(p.id, p.zoneId);

p.socket.emit('dc', {});
if (p.socket?.connected)
p.socket.emit('dc', {});
else {
players.splice(i, 1);
i--;
pLen--;
}
}
}
},


+ 3
- 0
src/server/world/atlas.js View File

@@ -15,6 +15,9 @@ module.exports = {
if (!serverObj)
return;

//While rezoning, this is set to true. So we remove it
delete serverObj.rezoning;

events.emit('onBeforePlayerEnterWorld', obj);

let { zoneName, zoneId } = obj;


Loading…
Cancel
Save