Browse Source

bug #1691: Fixed a crash caused by atlas not waiting long enough for instanced maps to spawn

tags/v0.12.0
Shaun 1 year ago
parent
commit
f5fc0a49ac
2 changed files with 28 additions and 21 deletions
  1. +24
    -21
      src/server/world/atlas.js
  2. +4
    -0
      src/server/world/instancer.js

+ 24
- 21
src/server/world/atlas.js View File

@@ -36,9 +36,8 @@ module.exports = {
if (map.instanced) {
delete obj.x;
delete obj.y;
thread = this.spawnMap(map);

await new Promise(res => setTimeout(res, 2000));
thread = await this.spawnMap(map);
} else
thread = this.getThreadFromName(map.name);
}
@@ -171,27 +170,27 @@ module.exports = {
.filter(m => !m.disabled && !m.instanced)
.forEach(m => this.spawnMap(m));
},
spawnMap: function ({ name, path, instanced }) {
const worker = childProcess.fork('./world/worker', [name]);

const id = instanced ? _.getGuid() : name;

const thread = {
id,
name,
instanced,
path,
worker
};

const onMessage = this.onMessage.bind(this, thread);
worker.on('message', function (m) {
onMessage(m);
});
spawnMap: async function ({ name, path, instanced }) {
return new Promise(resolveOnReady => {
const worker = childProcess.fork('./world/worker', [name]);

const id = instanced ? _.getGuid() : name;

const thread = {
id,
name,
instanced,
path,
worker,
cbOnInitialized: resolveOnReady
};

this.threads.push(thread);
const onMessage = this.onMessage.bind(this, thread);
worker.on('message', function (m) {
onMessage(m);
});

return thread;
this.threads.push(thread);
},
onMessage: function (thread, message) {
if (message.module) {
@@ -229,6 +228,10 @@ module.exports = {
});
},

onInitialized: function (thread) {
thread.cbOnInitialized(thread);
},

event: function (thread, message) {
objects.sendEvent(message, thread);
},


+ 4
- 0
src/server/world/instancer.js View File

@@ -75,6 +75,10 @@ module.exports = {

this.clientAck = clientAck;
eventEmitter.on('removeObject', unstageZoneIn);

process.send({
method: 'onInitialized'
});
},

startRegen: function (respawnMap, respawnPos) {


Loading…
Cancel
Save