diff options
author | UbitUmarov | 2018-12-30 22:31:32 +0000 |
---|---|---|
committer | UbitUmarov | 2018-12-30 22:31:32 +0000 |
commit | ffca7de65d2c19081899dae75303a3f98833c665 (patch) | |
tree | a5b91c89b9421f8ff68ef64eedaf4b139dc5ee56 /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |
parent | mantis 8436: fix lludp message (diff) | |
download | opensim-SC-ffca7de65d2c19081899dae75303a3f98833c665.zip opensim-SC-ffca7de65d2c19081899dae75303a3f98833c665.tar.gz opensim-SC-ffca7de65d2c19081899dae75303a3f98833c665.tar.bz2 opensim-SC-ffca7de65d2c19081899dae75303a3f98833c665.tar.xz |
add some persistence (mysql only)
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 106 |
1 files changed, 103 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index fd3a96b..479fb91 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -32,6 +32,8 @@ using System.IO; | |||
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Runtime.Serialization; | 33 | using System.Runtime.Serialization; |
34 | using System.Security.Permissions; | 34 | using System.Security.Permissions; |
35 | using System.Threading; | ||
36 | using System.Text; | ||
35 | using System.Xml; | 37 | using System.Xml; |
36 | using System.Xml.Serialization; | 38 | using System.Xml.Serialization; |
37 | using log4net; | 39 | using log4net; |
@@ -5657,13 +5659,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
5657 | UpdatePrimFlags(wasUsingPhysics,wasTemporary,wasPhantom,makeVolumeDetect,false); | 5659 | UpdatePrimFlags(wasUsingPhysics,wasTemporary,wasPhantom,makeVolumeDetect,false); |
5658 | } | 5660 | } |
5659 | 5661 | ||
5662 | protected static int m_animationSequenceNumber = (int)(Util.GetTimeStampTicks() & 0x5fffafL); | ||
5663 | public static int NextObjectAnimationSequenceNumber | ||
5664 | { | ||
5665 | get | ||
5666 | { | ||
5667 | int ret = Interlocked.Increment(ref m_animationSequenceNumber); | ||
5668 | if (ret <= 0) | ||
5669 | { | ||
5670 | m_animationSequenceNumber = (int)(Util.GetTimeStampTicks() & 0xafff5fL); | ||
5671 | ret = Interlocked.Increment(ref m_animationSequenceNumber); | ||
5672 | } | ||
5673 | return ret; | ||
5674 | } | ||
5675 | } | ||
5676 | |||
5660 | private object animsLock = new object(); | 5677 | private object animsLock = new object(); |
5661 | public Dictionary<UUID, int> Animations = null; | 5678 | public Dictionary<UUID, int> Animations = null; |
5662 | public Dictionary<UUID, string> AnimationsNames = null; | 5679 | public Dictionary<UUID, string> AnimationsNames = null; |
5663 | 5680 | ||
5664 | public bool AddAnimation(UUID animId, string animName) | 5681 | public bool AddAnimation(UUID animId, string animName) |
5665 | { | 5682 | { |
5666 | if (ParentGroup == null || ParentGroup.IsDeleted || ParentGroup.inTransit) | 5683 | if (animId == UUID.Zero || string.IsNullOrEmpty(animName) || |
5684 | ParentGroup == null || ParentGroup.IsDeleted || ParentGroup.inTransit) | ||
5667 | return false; | 5685 | return false; |
5668 | 5686 | ||
5669 | lock (animsLock) | 5687 | lock (animsLock) |
@@ -5676,7 +5694,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5676 | if (Animations.ContainsKey(animId)) | 5694 | if (Animations.ContainsKey(animId)) |
5677 | return false; | 5695 | return false; |
5678 | 5696 | ||
5679 | Animations[animId] = ParentGroup.Scene.NextObjectAnimationSequenceNumber; | 5697 | Animations[animId] = NextObjectAnimationSequenceNumber; |
5680 | AnimationsNames[animId] = animName; | 5698 | AnimationsNames[animId] = animName; |
5681 | ScheduleUpdate(PrimUpdateFlags.Animations); | 5699 | ScheduleUpdate(PrimUpdateFlags.Animations); |
5682 | } | 5700 | } |
@@ -5685,7 +5703,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5685 | 5703 | ||
5686 | public bool RemoveAnimation(UUID animId) | 5704 | public bool RemoveAnimation(UUID animId) |
5687 | { | 5705 | { |
5688 | if (ParentGroup == null || ParentGroup.IsDeleted || ParentGroup.inTransit) | 5706 | if (animId == UUID.Zero || ParentGroup == null || ParentGroup.IsDeleted || ParentGroup.inTransit) |
5689 | return false; | 5707 | return false; |
5690 | 5708 | ||
5691 | lock (animsLock) | 5709 | lock (animsLock) |
@@ -5726,5 +5744,87 @@ namespace OpenSim.Region.Framework.Scenes | |||
5726 | return Animations.Count; | 5744 | return Animations.Count; |
5727 | } | 5745 | } |
5728 | } | 5746 | } |
5747 | |||
5748 | public Byte[] SerializeAnimations() | ||
5749 | { | ||
5750 | if (AnimationsNames == null) | ||
5751 | return null; | ||
5752 | |||
5753 | |||
5754 | lock (animsLock) | ||
5755 | { | ||
5756 | if (AnimationsNames.Count == 0) | ||
5757 | return new byte[] { 0 }; | ||
5758 | |||
5759 | using (MemoryStream ms = new MemoryStream()) | ||
5760 | { | ||
5761 | byte[] tmp = Utils.UInt16ToBytes((ushort)Animations.Count); | ||
5762 | ms.Write(tmp, 0, 2); | ||
5763 | |||
5764 | foreach(KeyValuePair<UUID,string> kvp in AnimationsNames) | ||
5765 | { | ||
5766 | tmp = kvp.Key.GetBytes(); | ||
5767 | ms.Write(tmp, 0, 16); | ||
5768 | if(string.IsNullOrEmpty(kvp.Value)) | ||
5769 | ms.WriteByte(0); | ||
5770 | else | ||
5771 | { | ||
5772 | byte[] str = Util.StringToBytes(kvp.Value, 64); | ||
5773 | int len = str.Length - 1; | ||
5774 | ms.WriteByte((byte)len); | ||
5775 | ms.Write(str, 0 , len); | ||
5776 | } | ||
5777 | } | ||
5778 | return ms.ToArray(); | ||
5779 | } | ||
5780 | } | ||
5781 | } | ||
5782 | |||
5783 | public void DeSerializeAnimations(Byte[] data) | ||
5784 | { | ||
5785 | if(data == null) | ||
5786 | { | ||
5787 | Animations = null; | ||
5788 | AnimationsNames = null; | ||
5789 | return; | ||
5790 | } | ||
5791 | |||
5792 | if (data.Length < 2) | ||
5793 | { | ||
5794 | Animations = new Dictionary<UUID, int>(); | ||
5795 | AnimationsNames = new Dictionary<UUID, string>(); | ||
5796 | return; | ||
5797 | } | ||
5798 | |||
5799 | try | ||
5800 | { | ||
5801 | int count = (int)Utils.BytesToUInt16(data, 0); | ||
5802 | if(count == 0) | ||
5803 | return; | ||
5804 | |||
5805 | Animations = new Dictionary<UUID, int>(count); | ||
5806 | AnimationsNames = new Dictionary<UUID, string>(count); | ||
5807 | int pos = 2; | ||
5808 | while(--count >= 0) | ||
5809 | { | ||
5810 | UUID id = new UUID(data, pos); | ||
5811 | if(id == UUID.Zero) | ||
5812 | break; | ||
5813 | pos += 16; | ||
5814 | int strlen = data[pos++]; | ||
5815 | string name = UTF8Encoding.UTF8.GetString(data, pos, strlen); | ||
5816 | if(string.IsNullOrEmpty(name)) | ||
5817 | break; | ||
5818 | pos += strlen; | ||
5819 | Animations[id] = NextObjectAnimationSequenceNumber; | ||
5820 | AnimationsNames[id] = name; | ||
5821 | } | ||
5822 | return; | ||
5823 | } | ||
5824 | catch { } | ||
5825 | |||
5826 | Animations = null; | ||
5827 | AnimationsNames = null; | ||
5828 | } | ||
5729 | } | 5829 | } |
5730 | } | 5830 | } |