// Token: 0x060007D9 RID: 2009 RVA: 0x0003E01C File Offset: 0x0003C21C private void ServerSortSendZDOS(List <ZDO> objects, Vector3 refPos, ZDOMan.ZDOPeer peer) { float time = Time.time; for (int i = 0; i < objects.Count; i++) { ZDO zdo = objects[i]; Vector3 position = zdo.GetPosition(); zdo.m_tempSortValue = Vector3.Distance(position, refPos); float num = 100f; ZDOMan.ZDOPeer.PeerZDOInfo peerZDOInfo; if (peer.m_zdos.TryGetValue(zdo.m_uid, out peerZDOInfo)) { num = Mathf.Clamp(time - peerZDOInfo.m_syncTime, 0f, 100f); zdo.m_tempHaveRevision = true; } else { zdo.m_tempHaveRevision = false; } zdo.m_tempSortValue -= num * 1.5f; } ZDOMan.compareReceiver = peer.m_peer.m_uid; objects.Sort(new Comparison <ZDO>(ZDOMan.ServerSendCompare)); }
// Token: 0x060007D6 RID: 2006 RVA: 0x0003DD08 File Offset: 0x0003BF08 private void CreateSyncList(ZDOMan.ZDOPeer peer, List <ZDO> toSync) { if (ZNet.instance.IsServer()) { Vector3 refPos = peer.m_peer.GetRefPos(); Vector2i zone = ZoneSystem.instance.GetZone(refPos); this.m_tempToSyncDistant.Clear(); this.FindSectorObjects(zone, ZoneSystem.instance.m_activeArea, ZoneSystem.instance.m_activeDistantArea, toSync, this.m_tempToSyncDistant); this.ServerSortSendZDOS(toSync, refPos, peer); toSync.AddRange(this.m_tempToSyncDistant); this.AddForceSendZdos(peer, toSync); return; } this.m_tempRemoveList.Clear(); foreach (ZDOID zdoid in this.m_clientChangeQueue) { ZDO zdo = this.GetZDO(zdoid); if (zdo != null) { toSync.Add(zdo); } else { this.m_tempRemoveList.Add(zdoid); } } foreach (ZDOID item in this.m_tempRemoveList) { this.m_clientChangeQueue.Remove(item); } this.ClientSortSendZDOS(toSync, peer); this.AddForceSendZdos(peer, toSync); }
// Token: 0x060007C2 RID: 1986 RVA: 0x0003D0E4 File Offset: 0x0003B2E4 public void AddPeer(ZNetPeer netPeer) { ZDOMan.ZDOPeer zdopeer = new ZDOMan.ZDOPeer(); zdopeer.m_peer = netPeer; this.m_peers.Add(zdopeer); zdopeer.m_peer.m_rpc.Register <ZPackage>("ZDOData", new Action <ZRpc, ZPackage>(this.RPC_ZDOData)); }
// Token: 0x060007EE RID: 2030 RVA: 0x0003E8D0 File Offset: 0x0003CAD0 private void RPC_RequestZDO(long sender, ZDOID id) { ZDOMan.ZDOPeer peer = this.GetPeer(sender); if (peer != null) { peer.ForceSendZDO(id); } }
// Token: 0x060007C3 RID: 1987 RVA: 0x0003D12C File Offset: 0x0003B32C public void RemovePeer(ZNetPeer netPeer) { ZDOMan.ZDOPeer zdopeer = this.FindPeer(netPeer); if (zdopeer != null) { this.m_peers.Remove(zdopeer); if (ZNet.instance.IsServer()) { this.RemoveOrphanNonPersistentZDOS(); } } }
// Token: 0x060007DD RID: 2013 RVA: 0x0003E2AC File Offset: 0x0003C4AC private void AddDistantObjects(ZDOMan.ZDOPeer peer, int maxItems, List <ZDO> toSync) { if (peer.m_sendIndex >= this.m_objectsByID.Count) { peer.m_sendIndex = 0; } IEnumerable <KeyValuePair <ZDOID, ZDO> > enumerable = this.m_objectsByID.Skip(peer.m_sendIndex).Take(maxItems); peer.m_sendIndex += maxItems; foreach (KeyValuePair <ZDOID, ZDO> keyValuePair in enumerable) { toSync.Add(keyValuePair.Value); } }
// Token: 0x060007DB RID: 2011 RVA: 0x0003E134 File Offset: 0x0003C334 private void ClientSortSendZDOS(List <ZDO> objects, ZDOMan.ZDOPeer peer) { float time = Time.time; for (int i = 0; i < objects.Count; i++) { ZDO zdo = objects[i]; zdo.m_tempSortValue = 0f; float num = 100f; ZDOMan.ZDOPeer.PeerZDOInfo peerZDOInfo; if (peer.m_zdos.TryGetValue(zdo.m_uid, out peerZDOInfo)) { num = Mathf.Clamp(time - peerZDOInfo.m_syncTime, 0f, 100f); } zdo.m_tempSortValue -= num * 1.5f; } objects.Sort(new Comparison <ZDO>(ZDOMan.ClientSendCompare)); }
// Token: 0x060007F1 RID: 2033 RVA: 0x0003E9A8 File Offset: 0x0003CBA8 public void ForceSendZDO(long peerID, ZDOID id) { if (ZNet.instance.IsServer()) { ZDOMan.ZDOPeer peer = this.GetPeer(peerID); if (peer != null) { peer.ForceSendZDO(id); return; } } else { foreach (ZDOMan.ZDOPeer zdopeer in this.m_peers) { zdopeer.ForceSendZDO(id); } } }
// Token: 0x060007D7 RID: 2007 RVA: 0x0003DE4C File Offset: 0x0003C04C private void AddForceSendZdos(ZDOMan.ZDOPeer peer, List <ZDO> syncList) { if (peer.m_forceSend.Count > 0) { this.m_tempRemoveList.Clear(); foreach (ZDOID zdoid in peer.m_forceSend) { ZDO zdo = this.GetZDO(zdoid); if (zdo != null) { syncList.Insert(0, zdo); } else { this.m_tempRemoveList.Add(zdoid); } } foreach (ZDOID item in this.m_tempRemoveList) { peer.m_forceSend.Remove(item); } } }
// Token: 0x060007D3 RID: 2003 RVA: 0x0003D98C File Offset: 0x0003BB8C private void RPC_ZDOData(ZRpc rpc, ZPackage pkg) { ZDOMan.ZDOPeer zdopeer = this.FindPeer(rpc); if (zdopeer == null) { ZLog.Log("ZDO data from unkown host, ignoring"); return; } float time = Time.time; int num = 0; ZPackage pkg2 = new ZPackage(); int num2 = pkg.ReadInt(); for (int i = 0; i < num2; i++) { ZDOID id = pkg.ReadZDOID(); ZDO zdo = this.GetZDO(id); if (zdo != null) { zdo.InvalidateSector(); } } for (;;) { ZDOID zdoid = pkg.ReadZDOID(); if (zdoid.IsNone()) { break; } num++; uint num3 = pkg.ReadUInt(); uint num4 = pkg.ReadUInt(); long owner = pkg.ReadLong(); Vector3 vector = pkg.ReadVector3(); pkg.ReadPackage(ref pkg2); ZDO zdo2 = this.GetZDO(zdoid); bool flag = false; if (zdo2 != null) { if (num4 <= zdo2.m_dataRevision) { if (num3 > zdo2.m_ownerRevision) { zdo2.m_owner = owner; zdo2.m_ownerRevision = num3; zdopeer.m_zdos[zdoid] = new ZDOMan.ZDOPeer.PeerZDOInfo(num4, num3, time); continue; } continue; } } else { zdo2 = this.CreateNewZDO(zdoid, vector); flag = true; } zdo2.m_ownerRevision = num3; zdo2.m_dataRevision = num4; zdo2.m_owner = owner; zdo2.InternalSetPosition(vector); zdopeer.m_zdos[zdoid] = new ZDOMan.ZDOPeer.PeerZDOInfo(zdo2.m_dataRevision, zdo2.m_ownerRevision, time); zdo2.Deserialize(pkg2); if (ZNet.instance.IsServer() && flag && this.m_deadZDOs.ContainsKey(zdoid)) { zdo2.SetOwner(this.m_myid); this.DestroyZDO(zdo2); } } this.m_zdosRecv += num; }
// Token: 0x060007D2 RID: 2002 RVA: 0x0003D744 File Offset: 0x0003B944 private bool SendZDOs(ZDOMan.ZDOPeer peer, bool flush) { int sendQueueSize = peer.m_peer.m_socket.GetSendQueueSize(); if (!flush && sendQueueSize > 10240) { return(false); } int num = 10240 - sendQueueSize; if (num < 2048) { return(false); } this.m_tempToSync.Clear(); this.CreateSyncList(peer, this.m_tempToSync); if (this.m_tempToSync.Count == 0 && peer.m_invalidSector.Count == 0) { return(false); } ZPackage zpackage = new ZPackage(); bool flag = false; if (peer.m_invalidSector.Count > 0) { flag = true; zpackage.Write(peer.m_invalidSector.Count); foreach (ZDOID id in peer.m_invalidSector) { zpackage.Write(id); } peer.m_invalidSector.Clear(); } else { zpackage.Write(0); } float time = Time.time; ZPackage zpackage2 = new ZPackage(); bool flag2 = false; int num2 = 0; while (num2 < this.m_tempToSync.Count && zpackage.Size() <= num) { ZDO zdo = this.m_tempToSync[num2]; peer.m_forceSend.Remove(zdo.m_uid); if (!ZNet.instance.IsServer()) { this.m_clientChangeQueue.Remove(zdo.m_uid); } if (peer.ShouldSend(zdo)) { zpackage.Write(zdo.m_uid); zpackage.Write(zdo.m_ownerRevision); zpackage.Write(zdo.m_dataRevision); zpackage.Write(zdo.m_owner); zpackage.Write(zdo.GetPosition()); zpackage2.Clear(); zdo.Serialize(zpackage2); zpackage.Write(zpackage2); peer.m_zdos[zdo.m_uid] = new ZDOMan.ZDOPeer.PeerZDOInfo(zdo.m_dataRevision, zdo.m_ownerRevision, time); flag2 = true; this.m_zdosSent++; } num2++; } zpackage.Write(ZDOID.None); if (flag2 || flag) { peer.m_peer.m_rpc.Invoke("ZDOData", new object[] { zpackage }); } return(flag2 || flag); }
// Token: 0x060007D1 RID: 2001 RVA: 0x0003D738 File Offset: 0x0003B938 private void SendAllZDOs(ZDOMan.ZDOPeer peer) { while (this.SendZDOs(peer, true)) { } }