Browse Source

bug: Fixed character select hanging

tags/v0.12.0.8^2
Shaun 1 year ago
parent
commit
c8412bbbc8
4 changed files with 13 additions and 10 deletions
  1. +1
    -1
      src/server/config/consts.js
  2. +1
    -1
      src/server/security/connections.js
  3. +8
    -5
      src/server/world/atlas.js
  4. +3
    -3
      src/server/world/instancer.js

+ 1
- 1
src/server/config/consts.js View File

@@ -1,6 +1,6 @@
module.exports = {
//At which interval does each zone tick in ms
tickTime: 350,
tickTime: 5,

//The maximum level a player can reach
maxLevel: 20,


+ 1
- 1
src/server/security/connections.js View File

@@ -130,7 +130,7 @@ module.exports = {

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

p.socket.emit('dc', {});
}


+ 8
- 5
src/server/world/atlas.js View File

@@ -60,14 +60,14 @@ module.exports = {
});
},

removeObjectFromInstancedZone: async function (thread, obj, callback) {
removeObjectFromInstancedZone: async function (thread, objId, callback) {
await new Promise(res => {
const cb = this.registerCallback(res);

thread.worker.send({
method: 'forceSavePlayer',
args: {
playerName: obj.name,
playerId: objId,
callbackId: cb
}
});
@@ -80,6 +80,9 @@ module.exports = {
},

removeObject: async function (obj, skipLocal, callback) {
//We need to store the player id because the calling thread might delete it (connections.unzone)
const playerId = obj.id;

if (!skipLocal)
objects.removeObject(obj);

@@ -88,7 +91,7 @@ module.exports = {
return;

if (thread.instanced && (await gePlayerCountInThread(thread)) === 1) {
this.removeObjectFromInstancedZone(thread, obj, callback);
this.removeObjectFromInstancedZone(thread, playerId, callback);

return;
}
@@ -161,7 +164,7 @@ module.exports = {
await returnWhenThreadsIdle();
},

forceSavePlayer: async function (playerName, zoneId) {
forceSavePlayer: async function (playerId, zoneId) {
const thread = getThreadFromId(zoneId);

if (!thread)
@@ -173,7 +176,7 @@ module.exports = {
thread.worker.send({
method: 'forceSavePlayer',
args: {
playerName,
playerId,
callbackId
}
});


+ 3
- 3
src/server/world/instancer.js View File

@@ -363,14 +363,14 @@ module.exports = {
});
},

forceSavePlayer: async function ({ playerName, callbackId }) {
const player = objects.objects.find(o => o.player && o.name === playerName);
forceSavePlayer: async function ({ playerId, callbackId }) {
const player = objects.objects.find(o => o.serverId === playerId);

if (!player?.auth) {
await io.setAsync({
key: new Date(),
table: 'error',
value: 'no auth found for forcesave ' + playerName
value: 'no auth found for forcesave ' + player?.name
});

return;


Loading…
Cancel
Save