@@ -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(); | ||||
} | } | ||||
@@ -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); | ||||
@@ -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 | |||||
}); | }); | ||||
}; | }; |
@@ -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; | ||||