Browse Source

bug #1774

tags/v0.10.0^2
Shaun 2 years ago
parent
commit
fe28c3ca6c
4 changed files with 21 additions and 17 deletions
  1. +1
    -1
      src/client/js/objects/objects.js
  2. +3
    -1
      src/server/components/portal/sendObjToZone.js
  3. +6
    -14
      src/server/components/social/rezone.js
  4. +11
    -1
      src/server/world/syncer.js

+ 1
- 1
src/client/js/objects/objects.js View File

@@ -95,7 +95,7 @@ define([

if (oldZone === null)
o.destroy();
else if ((o.zoneId === oldZone) && (!o.has('player')))
else if (o.zoneId === oldZone)
o.destroy();
}



+ 3
- 1
src/server/components/portal/sendObjToZone.js View File

@@ -1,5 +1,7 @@
const sendObjToZone = async ({ obj, invokingObj, zoneName, toPos, toRelativePos }) => {
const { instance: { physics, syncer: globalSyncer } } = obj;
const { serverId, instance: { physics, syncer: globalSyncer } } = obj;

globalSyncer.flushForTarget(serverId);

if (obj.zoneName === zoneName) {
physics.removeObject(obj, obj.x, obj.y);


+ 6
- 14
src/server/components/social/rezone.js View File

@@ -1,18 +1,10 @@
module.exports = async (cpnSocial, targetZone) => {
const { obj } = cpnSocial;

obj.fireEvent('beforeRezone');
const sendObjToZone = require('../portal/sendObjToZone');

obj.destroyed = true;

const simpleObj = obj.getSimple(true, false, true);
module.exports = (cpnSocial, targetZone) => {
const { obj } = cpnSocial;

process.send({
method: 'rezone',
id: obj.serverId,
args: {
obj: simpleObj,
newZone: targetZone
}
sendObjToZone({
obj,
zoneName: targetZone
});
};

+ 11
- 1
src/server/world/syncer.js View File

@@ -14,7 +14,7 @@ module.exports = {
let oList = objects.objects;
let oLen = oList.length;

let pList = oList.filter(f => f.player);
let pList = oList.filter(f => f.player && !f.destroyed);
let pLen = pList.length;

if (pLen === 0)
@@ -166,6 +166,16 @@ module.exports = {
});
},

flushForTarget: function (targetServerId) {
const buffer = this.buffer;

for (let p in buffer) {
const list = buffer[p];

list.spliceWhere(l => l.to === targetServerId);
}
},

send: function () {
if (!this.dirty)
return;


Loading…
Cancel
Save