Bladeren bron

bug #1774

tags/v0.10.0^2
Shaun 2 jaren geleden
bovenliggende
commit
fe28c3ca6c
4 gewijzigde bestanden met toevoegingen van 21 en 17 verwijderingen
  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 Bestand weergeven

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


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




+ 3
- 1
src/server/components/portal/sendObjToZone.js Bestand weergeven

@@ -1,5 +1,7 @@
const sendObjToZone = async ({ obj, invokingObj, zoneName, toPos, toRelativePos }) => { 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) { if (obj.zoneName === zoneName) {
physics.removeObject(obj, obj.x, obj.y); physics.removeObject(obj, obj.x, obj.y);


+ 6
- 14
src/server/components/social/rezone.js Bestand weergeven

@@ -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 Bestand weergeven

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


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


if (pLen === 0) 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 () { send: function () {
if (!this.dirty) if (!this.dirty)
return; return;


Laden…
Annuleren
Opslaan