public void CreateClientData(MyClientStateBase forClient) { if (m_clientInventoryUpdate == null) { m_clientInventoryUpdate = new Dictionary <ulong, InventoryClientData>(); } InventoryClientData data; if (m_clientInventoryUpdate.TryGetValue(forClient.EndpointId.Value, out data) == false) { m_clientInventoryUpdate[forClient.EndpointId.Value] = new InventoryClientData(); data = m_clientInventoryUpdate[forClient.EndpointId.Value]; } data.Dirty = false; List <MyPhysicalInventoryItem> items = Inventory.GetItems(); foreach (var serverItem in items) { MyFixedPoint amount = serverItem.Amount; var gasItem = serverItem.Content as MyObjectBuilder_GasContainerObject; if (gasItem != null) { amount = (MyFixedPoint)gasItem.GasLevel; } data.ClientItems[serverItem.ItemId] = new ClientInvetoryData() { Item = serverItem, Amount = amount }; } }
public void DestroyClientData(MyClientStateBase forClient) { if (m_clientInventoryUpdate != null) { m_clientInventoryUpdate.Remove(forClient.EndpointId.Value); } }
public void OnAck(MyClientStateBase forClient, byte packetId, bool delivered) { Console.WriteLine(String.Format("delivery: {0}, {1}", packetId, delivered)); InventoryClientData clientData = m_clientInventoryUpdate[forClient.EndpointId.Value]; InventoryPartInfo packetInfo; if (clientData.SendPackets.TryGetValue(packetId, out packetInfo)) { if (delivered == false) { if (packetInfo.AllItemsSend) { clientData.Dirty = true; clientData.MainSendingInfo.StartItemIndex = 0; clientData.MainSendingInfo.NumItems = 0; clientData.SendPackets.Clear(); clientData.FailedIncompletePackets.Clear(); } else { clientData.FailedIncompletePackets.Add(packetInfo); } } clientData.SendPackets.Remove(packetId); } }
public void Serialize(BitStream stream, MyClientStateBase forClient, byte packetId, int maxBitPosition) { SmallBitField dirtyFlags; if (stream.Writing) { var data = m_clientData[forClient]; dirtyFlags = data.DirtyProperties; stream.WriteUInt64(dirtyFlags.Bits, m_properties.Count); } else { dirtyFlags.Bits = stream.ReadUInt64(m_properties.Count); } for (int i = 0; i < m_properties.Count; i++) { if (dirtyFlags[i]) { m_properties[i].Serialize(stream, false); // Received from server, don't validate if (stream.Reading) // Received from server, it's no longer dirty { m_dirtyProperties[i] = false; } } } if (stream.Writing && stream.BitPosition <= maxBitPosition) { var data = m_clientData[forClient]; data.PacketId = packetId; data.SentProperties.Bits = data.DirtyProperties.Bits; data.DirtyProperties.Bits = 0; } }
public void DestroyClientData(MyClientStateBase forClient) { if (m_clientStreamData != null) { m_clientStreamData.Remove(forClient.EndpointId.Value); } }
public void ForceSend(MyClientStateBase clientData) { StreamClientData streamData = m_clientStreamData[clientData.EndpointId.Value]; streamData.ForceSend = true; SaveReplicable(streamData); }
public void Serialize(BitStream stream, MyClientStateBase forClient, byte packetId, int maxBitPosition) { if (stream.Writing) { InventoryClientData clientData = m_clientInventoryUpdate[forClient.EndpointId.Value]; if (clientData.FailedIncompletePackets.Count > 0) { InventoryPartInfo failedPacket = clientData.FailedIncompletePackets[0]; clientData.FailedIncompletePackets.RemoveAtFast(0); InventoryPartInfo reSendPacket = WriteInventory(ref failedPacket, stream, packetId, maxBitPosition, true); clientData.SendPackets[packetId] = reSendPacket; } else { clientData.MainSendingInfo = WriteInventory(ref clientData.MainSendingInfo, stream, packetId, maxBitPosition); clientData.SendPackets[packetId] = clientData.MainSendingInfo; List <MyPhysicalInventoryItem> items = Inventory.GetItems(); if (clientData.MainSendingInfo.StartItemIndex + clientData.MainSendingInfo.NumItems >= items.Count) { clientData.MainSendingInfo.StartItemIndex = 0; clientData.MainSendingInfo.NumItems = 0; clientData.Dirty = false; } } } else { ReadInventory(stream); } }
public override float GetPriority(MyClientStateBase client) { if (m_clientList == null) { m_clientList = new HashSet <ulong>(); } if (m_clientList.Contains(client.EndpointId.Value)) { return(1.0f); } if (Inventory.Owner is MyCharacter) { MyPlayer player = MyPlayer.GetPlayerFromCharacter(Inventory.Owner as MyCharacter); if (player != null && player.Id.SteamId == client.EndpointId.Value) { m_clientList.Add(client.EndpointId.Value); return(1.0f); } } float priority = Inventory.GetPriority(client); if (priority > 0.0f) { m_clientList.Add(client.EndpointId.Value); } return(priority); }
public float GetGroupPriority(int frameCountWithoutSync, MyClientStateBase client) { Debug.Assert(m_properties.Count > 0, "When no properties are defined, it should not get there"); // Temporarily disabled //return 0; // Called only on server float priority = m_gridReplicable.GetPriority(client); if (priority <= 0) { return(0); } // TODO: Raise priority only when client is looking into terminal if (m_clientData[client].DirtyProperties.Bits > 0 && m_clientData[client].PacketId == null) { return(priority); } else { return(0); } }
public override float GetPriority(MyClientStateBase state) { float priority = base.GetPriority(state); if (priority == 0.0f) { MyPlayerCollection playerCollection = MySession.Static.Players; var connectedPlayers = playerCollection.GetOnlinePlayers(); foreach (var player in connectedPlayers) { if (player.Client.SteamUserId == state.EndpointId.Value && player.Character != null) { var broadcasters = player.Character.RadioReceiver.GetRelayedBroadcastersForPlayer(player.Identity.IdentityId); foreach (var broadcaster in broadcasters) { var cubeblock = broadcaster.Parent as MyCubeBlock; if (cubeblock != null && cubeblock.CubeGrid == Grid) { return(0.1f); // Minimal priority, update, but not that often } } } } } return(priority); }
public void OnAck(MyClientStateBase forClient, byte packetId, bool delivered) { //streaming is reliable don't care return; StreamClientData clientData = m_clientStreamData[forClient.EndpointId.Value]; StreamPartInfo packetInfo; if (clientData.SendPackets.TryGetValue(packetId, out packetInfo)) { if (delivered) { clientData.SendPackets.Remove(packetId); if (clientData.SendPackets.Count == 0 && clientData.RemainingBits == 0) { clientData.Dirty = false; clientData.ForceSend = false; } } else { if (clientData.ObjectData != null) { clientData.FailedIncompletePackets.Add(packetInfo); clientData.Dirty = true; clientData.SendPackets.Remove(packetId); } } } }
public override float GetPriority(MyClientStateBase client) { if (Voxel.Save == false && Voxel.ContentChanged == false && Voxel.BeforeContentChanged == false) { return(0.0f); } return(GetBasePriority(Voxel.PositionComp.GetPosition(), Voxel.Storage.Size * MyVoxelConstants.VOXEL_SIZE_IN_METRES, client)); }
protected override float GetGroupPriority(int frameCountWithoutSync, MyClientStateBase client, PrioritySettings settings) { if (IsSlaveGrid()) { return(0); } return(base.GetGroupPriority(frameCountWithoutSync, client, settings)); }
public override float GetPriority(MyClientStateBase client) { if (m_properties.Count == 0) { return(0); } // Same priority as grid return(m_gridReplicable.GetPriority(client)); }
public static MyNetworkClient GetClient(this MyClientStateBase state) { MyNetworkClient client; if (state == null) { return(null); } Sync.Clients.TryGetClient(state.EndpointId.Id.Value, out client); return(client); }
public override void Serialize(BitStream stream, MyClientStateBase forClient, byte packetId, int maxBitPosition) { if (MyFakes.ENABLE_MULTIPLAYER_ENTITY_SUPPORT) { SerializePhysicsWithSupport(stream, forClient, packetId, maxBitPosition); } else { base.Serialize(stream, forClient, packetId, maxBitPosition); } }
public void Serialize(VRage.Library.Collections.BitStream stream, MyClientStateBase forClient, byte packetId, int maxBitPosition) { if (stream.Reading) { ProcessRead(ref stream); } else { ProcessWrite(maxBitPosition, ref stream, forClient, packetId); } }
public void Serialize(BitStream stream, MyClientStateBase forClient, byte packetId, int maxBitPosition) { if (stream.Writing) { InventoryClientData clientData = m_clientInventoryUpdate[forClient.EndpointId.Value]; bool needsSplit = false; if (clientData.FailedIncompletePackets.Count > 0) { InventoryDeltaInformation failedPacket = clientData.FailedIncompletePackets[0]; clientData.FailedIncompletePackets.RemoveAtFast(0); InventoryDeltaInformation reSendPacket = WriteInventory(ref failedPacket, stream, packetId, maxBitPosition, out needsSplit); if (needsSplit) { //resend split doesnt generate new id becaose it was part of allreadt sent message clientData.FailedIncompletePackets.Add(CreateSplit(ref failedPacket, ref reSendPacket)); } if (reSendPacket.HasChanges) { clientData.SendPackets[packetId] = reSendPacket; } } else { InventoryDeltaInformation difference = CalculateInventoryDiff(ref clientData); difference.MessageId = clientData.CurrentMessageId; clientData.MainSendingInfo = WriteInventory(ref difference, stream, packetId, maxBitPosition, out needsSplit); if (needsSplit) { //split generate new id becaose its different message clientData.CurrentMessageId++; InventoryDeltaInformation split = CreateSplit(ref difference, ref clientData.MainSendingInfo); split.MessageId = clientData.CurrentMessageId; clientData.FailedIncompletePackets.Add(split); } if (clientData.MainSendingInfo.HasChanges) { clientData.SendPackets[packetId] = clientData.MainSendingInfo; clientData.CurrentMessageId++; } clientData.Dirty = false; } } else { ReadInventory(stream); } }
public void DestroyClientData(MyClientStateBase forClient) { if (m_serverClientData != null) { m_serverClientData.Remove(forClient.EndpointId.Value); } if (m_clientUpdateFlag != null) { m_clientUpdateFlag.Remove(forClient.EndpointId.Value); } }
protected override float GetGroupPriority(int frameCountWithoutSync, MyClientStateBase client, PrioritySettings settings) { const float HighQualityDistance = 8; // under 8m, character physics sync gets high priority to have smooth movement var clientPos = ((MyClientState)client).Position; var characterPos = Entity.PositionComp.GetPosition(); bool isHighQuality = Vector3D.DistanceSquared(clientPos, characterPos) < HighQualityDistance * HighQualityDistance; isHighQuality = isHighQuality && !Entity.IsDead; return(base.GetGroupPriority(frameCountWithoutSync, client, isHighQuality ? m_highQuality : settings)); }
public override float GetPriority(MyClientStateBase state) { var info = Instance.ControllerInfo; if (info != null && info.Controller != null && info.Controller.Player != null && info.Controller.Player.Id.SteamId == state.EndpointId.Value) { return(1.0f); } return(base.GetPriority(state)); }
public void OnAck(MyClientStateBase forClient, byte packetId, bool delivered) { if (delivered) { return; } var dataPerClient = _serverData[forClient.EndpointId]; var dataPerClient2 = dataPerClient; dataPerClient2.DirtyProperties.Bits = dataPerClient2.DirtyProperties.Bits | dataPerClient.SentProperties[packetId].Bits; _server.AddToDirtyGroups(this); }
public virtual void Serialize(BitStream stream, MyClientStateBase forClient, byte packetId, int maxBitPosition) { MyNetworkClient client = null; if (forClient != null) { Sync.Clients.TryGetClient(forClient.EndpointId.Value, out client); } // TODO: Rewrite and move 'SerializePhysics' to this class (when on trunk) ((MySyncEntity)Entity.SyncObject).SerializePhysics(stream, client, false); }
public void CreateClientData(MyClientStateBase forClient) { if (m_serverClientData == null) { m_serverClientData = new Dictionary <ulong, ClientData>(); } if (m_clientUpdateFlag == null) { m_clientUpdateFlag = new Dictionary <ulong, bool>(); } m_clientUpdateFlag[forClient.EndpointId.Value] = false; }
public void CreateClientData(MyClientStateBase forClient) { var dataPerClient = new DataPerClient(); _serverData.Add(forClient.EndpointId, dataPerClient); if (m_properties.Count > 0) { dataPerClient.DirtyProperties.Reset(true); } dataPerClient.HasRights = !Plugin.StaticConfig.InventoryPreventSharing || (Owner as InventoryReplicable).HasRights(forClient.EndpointId.Id, ValidationType.Access | ValidationType.Ownership) == ValidationResult.Passed; }
public void OnAck(MyClientStateBase forClient, byte packetId, bool delivered) { if (_serverData == null || !_serverData.TryGetValue(forClient.EndpointId, out var data) || !data.SendPackets.TryGetValue(packetId, out var item)) { return; } if (!delivered) { data.FailedIncompletePackets.Add(item); _server.AddToDirtyGroups(this); } data.SendPackets.Remove(packetId); }
public void CreateClientData(MyClientStateBase forClient) { if (m_clientInventoryUpdate == null) { m_clientInventoryUpdate = new Dictionary <ulong, InventoryClientData>(); } InventoryClientData data; if (m_clientInventoryUpdate.TryGetValue(forClient.EndpointId.Value, out data) == false) { m_clientInventoryUpdate[forClient.EndpointId.Value] = new InventoryClientData(); } m_clientInventoryUpdate[forClient.EndpointId.Value].Dirty = true; }
protected virtual float GetGroupPriority(int frameCountWithoutSync, MyClientStateBase client, PrioritySettings settings) { float priority = GetBasicPhysicsPriority(client); if (priority <= 0) { return(0); } float updateFrameCount; priority *= GetMovementScale(settings, out updateFrameCount); return(RampPriority(priority, frameCountWithoutSync, updateFrameCount)); }
public void CreateClientData(MyClientStateBase forClient) { if (m_clientStreamData == null) { m_clientStreamData = new Dictionary <ulong, StreamClientData>(); } StreamClientData data; if (m_clientStreamData.TryGetValue(forClient.EndpointId.Value, out data) == false) { m_clientStreamData[forClient.EndpointId.Value] = new StreamClientData(); } m_clientStreamData[forClient.EndpointId.Value].Dirty = true; }
public void OnAck(MyClientStateBase forClient, byte packetId, bool delivered) { Console.WriteLine(String.Format("delivery: {0}, {1}", packetId, delivered)); InventoryClientData clientData = m_clientInventoryUpdate[forClient.EndpointId.Value]; InventoryDeltaInformation packetInfo; if (clientData.SendPackets.TryGetValue(packetId, out packetInfo)) { if (delivered == false) { clientData.FailedIncompletePackets.Add(packetInfo); } clientData.SendPackets.Remove(packetId); } }