internal void SendWeaponReload(Weapon w) { if (IsServer) { if (!PrunedPacketsToClient.ContainsKey(w.Comp.Data.Repo.Base)) { const PacketType type = PacketType.WeaponReload; w.Comp.Data.Repo.Base.UpdateCompBasePacketInfo(w.Comp); PacketInfo oldInfo; WeaponReloadPacket iPacket; if (PrunedPacketsToClient.TryGetValue(w.Reload, out oldInfo)) { iPacket = (WeaponReloadPacket)oldInfo.Packet; iPacket.EntityId = w.Comp.MyCube.EntityId; iPacket.Data = w.Reload; } else { iPacket = PacketReloadPool.Get(); iPacket.MId = ++w.MIds[(int)type]; iPacket.EntityId = w.Comp.MyCube.EntityId; iPacket.SenderId = MultiplayerId; iPacket.PType = type; iPacket.Data = w.Reload; iPacket.WeaponId = w.WeaponId; } PrunedPacketsToClient[w.Reload] = new PacketInfo { Entity = w.Comp.MyCube, Packet = iPacket, }; } else { SendCompBaseData(w.Comp); } } else { Log.Line($"SendWeaponReload should never be called on Client"); } }
private void ServerPacketsForClientsClean() { PacketsToClient.Clear(); foreach (var pInfo in PrunedPacketsToClient.Values) { switch (pInfo.Packet.PType) { case PacketType.AiData: { var iPacket = (AiDataPacket)pInfo.Packet; PacketAiPool.Return(iPacket); break; } case PacketType.CompBase: { var iPacket = (CompBasePacket)pInfo.Packet; PacketCompBasePool.Return(iPacket); break; } case PacketType.CompState: { var iPacket = (CompStatePacket)pInfo.Packet; PacketStatePool.Return(iPacket); break; } case PacketType.TargetChange: { var iPacket = (TargetPacket)pInfo.Packet; PacketTargetPool.Return(iPacket); break; } case PacketType.WeaponReload: { var iPacket = (WeaponReloadPacket)pInfo.Packet; PacketReloadPool.Return(iPacket); break; } case PacketType.Construct: { var iPacket = (ConstructPacket)pInfo.Packet; PacketConstructPool.Return(iPacket); break; } case PacketType.ConstructFoci: { var iPacket = (ConstructFociPacket)pInfo.Packet; PacketConstructFociPool.Return(iPacket); break; } case PacketType.WeaponAmmo: { var iPacket = (WeaponAmmoPacket)pInfo.Packet; PacketAmmoPool.Return(iPacket); break; } } } PrunedPacketsToClient.Clear(); }