public PermissionWho EffectivePermissionWho(SimObject exportPrim)
        {
            if (WorldSystem.AssumeOwner)
            {
                return(PermissionWho.Owner);
            }
            Primitive.ObjectProperties permProps = exportPrim.Properties;
            Primitive prim          = exportPrim.Prim;
            UUID      objectGroupID = UUID.Zero;
            UUID      ownerID       = UUID.Zero;
            PrimFlags flag          = PrimFlags.None;

            if (prim != null)
            {
                objectGroupID = prim.GroupID;
                ownerID       = prim.OwnerID;
                flag          = prim.Flags;
            }
            else if (permProps != null)
            {
                objectGroupID = permProps.GroupID;
                ownerID       = permProps.OwnerID;
            }
            bool groupOwned = (flag & PrimFlags.ObjectGroupOwned) != 0;

            //  bool groupOwned = (flag & PrimFlags.) != 0;
            return(EffectivePermissionWho(ownerID, objectGroupID, groupOwned));
        }
        public uint GenerateClientFlags(SceneObjectPart part, ScenePresence sp)
        {
            // libomv will moan about PrimFlags.ObjectYouOfficer being
            // obsolete...
#pragma warning disable 0612
            const PrimFlags DEFAULT_FLAGS =
                PrimFlags.ObjectModify |
                PrimFlags.ObjectCopy |
                PrimFlags.ObjectMove |
                PrimFlags.ObjectTransfer |
                PrimFlags.ObjectYouOwner |
                PrimFlags.ObjectAnyOwner |
                PrimFlags.ObjectOwnerModify;
#pragma warning restore 0612

            if (part == null)
            {
                return(0);
            }

            uint perms = part.GetEffectiveObjectFlags() | (uint)DEFAULT_FLAGS;

            GenerateClientFlagsHandler handlerGenerateClientFlags = OnGenerateClientFlags;
            if (handlerGenerateClientFlags != null)
            {
                Delegate[] list = handlerGenerateClientFlags.GetInvocationList();
                foreach (GenerateClientFlagsHandler check in list)
                {
                    perms &= check(part, sp, perms);
                }
            }
            return(perms);
        }
        public uint GenerateClientFlags(UUID userID, ISceneChildEntity part)
        {
            // libomv will moan about PrimFlags.ObjectYouOfficer being
            // obsolete...
#pragma warning disable 0612
            const PrimFlags DEFAULT_FLAGS =
                PrimFlags.ObjectModify |
                PrimFlags.ObjectCopy |
                PrimFlags.ObjectMove |
                PrimFlags.ObjectTransfer |
                PrimFlags.ObjectYouOwner |
                PrimFlags.ObjectAnyOwner |
                PrimFlags.ObjectOwnerModify |
                PrimFlags.ObjectYouOfficer;
#pragma warning restore 0612

            if (part == null)
            {
                return(0);
            }

            uint perms = part.GetEffectiveObjectFlags() | (uint)DEFAULT_FLAGS;

            GenerateClientFlagsHandler handlerGenerateClientFlags = OnGenerateClientFlags;
            if (handlerGenerateClientFlags != null)
            {
                Delegate[] list = handlerGenerateClientFlags.GetInvocationList();
                perms = list.Cast <GenerateClientFlagsHandler>()
                        .Aggregate(perms, (current, check) => current & check(userID, part));
            }
            return(perms);
        }
Beispiel #4
0
        private static PrimFlags LSLEventFlagsToPrimFlags(LSLEventFlags eventFlags, out bool hasCollisionEvents)
        {
            PrimFlags flags = PrimFlags.None;

            if (eventFlags.HasFlag(LSLEventFlags.touch) || eventFlags.HasFlag(LSLEventFlags.touch_start) || eventFlags.HasFlag(LSLEventFlags.touch_end))
            {
                flags |= PrimFlags.Touch;
            }

            if (eventFlags.HasFlag(LSLEventFlags.money))
            {
                flags |= PrimFlags.Money;
            }

            if (eventFlags.HasFlag(LSLEventFlags.collision) || eventFlags.HasFlag(LSLEventFlags.collision_start) || eventFlags.HasFlag(LSLEventFlags.collision_end) ||
                eventFlags.HasFlag(LSLEventFlags.land_collision) || eventFlags.HasFlag(LSLEventFlags.land_collision_start) || eventFlags.HasFlag(LSLEventFlags.land_collision_end))
            {
                hasCollisionEvents = true;
            }
            else
            {
                hasCollisionEvents = false;
            }

            return(flags);
        }
        void ObjectDuplicateHandler(Packet packet, Agent agent)
        {
            ObjectDuplicatePacket duplicate = (ObjectDuplicatePacket)packet;

            PrimFlags flags  = (PrimFlags)duplicate.SharedData.DuplicateFlags;
            Vector3   offset = duplicate.SharedData.Offset;

            for (int i = 0; i < duplicate.ObjectData.Length; i++)
            {
                uint dupeID = duplicate.ObjectData[i].ObjectLocalID;

                SimulationObject obj;
                if (server.Scene.TryGetObject(dupeID, out obj))
                {
                    SimulationObject newObj = new SimulationObject(obj);
                    newObj.Prim.Position += offset;
                    newObj.Prim.ID        = UUID.Random();

                    server.Scene.ObjectAdd(this, agent, newObj, flags);
                }
                else
                {
                    Logger.Log("ObjectDuplicate sent for missing object " + dupeID,
                               Helpers.LogLevel.Warning);

                    KillObjectPacket kill = new KillObjectPacket();
                    kill.ObjectData       = new KillObjectPacket.ObjectDataBlock[1];
                    kill.ObjectData[0]    = new KillObjectPacket.ObjectDataBlock();
                    kill.ObjectData[0].ID = dupeID;
                    server.UDP.SendPacket(agent.AgentID, kill, PacketCategory.State);
                }
            }
        }
        public static ObjectUpdatePacket BuildFullUpdate(Primitive obj, ulong regionHandle, PrimFlags flags)
        {
            ObjectUpdatePacket update = new ObjectUpdatePacket();
            update.RegionData.RegionHandle = regionHandle;
            update.RegionData.TimeDilation = UInt16.MaxValue;
            update.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
            update.ObjectData[0] = BuildUpdateBlock(obj, regionHandle, flags);

            return update;
        }
        public static ObjectUpdatePacket.ObjectDataBlock BuildUpdateBlock(Primitive obj, ulong regionHandle, PrimFlags flags)
        {
            byte[] objectData = BuildObjectData(obj.Position, obj.Rotation, obj.Velocity,
                obj.Acceleration, obj.AngularVelocity);

            ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
            update.ClickAction = (byte)obj.ClickAction;
            update.CRC = 0;
            update.ExtraParams = obj.GetExtraParamsBytes();
            update.Flags = (byte)flags;
            update.FullID = obj.ID;
            update.Gain = obj.SoundGain;
            update.ID = obj.LocalID;
            update.JointAxisOrAnchor = obj.JointAxisOrAnchor;
            update.JointPivot = obj.JointPivot;
            update.JointType = (byte)obj.Joint;
            update.Material = (byte)obj.PrimData.Material;
            update.MediaURL = Utils.StringToBytes(obj.MediaURL);
            update.NameValue = Utils.StringToBytes(NameValue.NameValuesToString(obj.NameValues));
            update.ObjectData = objectData;
            update.OwnerID = (obj.Properties != null ? obj.Properties.OwnerID : UUID.Zero);
            update.ParentID = obj.ParentID;
            update.PathBegin = Primitive.PackBeginCut(obj.PrimData.PathBegin);
            update.PathCurve = (byte)obj.PrimData.PathCurve;
            update.PathEnd = Primitive.PackEndCut(obj.PrimData.PathEnd);
            update.PathRadiusOffset = Primitive.PackPathTwist(obj.PrimData.PathRadiusOffset);
            update.PathRevolutions = Primitive.PackPathRevolutions(obj.PrimData.PathRevolutions);
            update.PathScaleX = Primitive.PackPathScale(obj.PrimData.PathScaleX);
            update.PathScaleY = Primitive.PackPathScale(obj.PrimData.PathScaleY);
            update.PathShearX = (byte)Primitive.PackPathShear(obj.PrimData.PathShearX);
            update.PathShearY = (byte)Primitive.PackPathShear(obj.PrimData.PathShearY);
            update.PathSkew = Primitive.PackPathTwist(obj.PrimData.PathSkew);
            update.PathTaperX = Primitive.PackPathTaper(obj.PrimData.PathTaperX);
            update.PathTaperY = Primitive.PackPathTaper(obj.PrimData.PathTaperY);
            update.PathTwist = Primitive.PackPathTwist(obj.PrimData.PathTwist);
            update.PathTwistBegin = Primitive.PackPathTwist(obj.PrimData.PathTwistBegin);
            update.PCode = (byte)obj.PrimData.PCode;
            update.ProfileBegin = Primitive.PackBeginCut(obj.PrimData.ProfileBegin);
            update.ProfileCurve = (byte)obj.PrimData.ProfileCurve;
            update.ProfileEnd = Primitive.PackEndCut(obj.PrimData.ProfileEnd);
            update.ProfileHollow = Primitive.PackProfileHollow(obj.PrimData.ProfileHollow);
            update.PSBlock = obj.ParticleSys.GetBytes();
            update.TextColor = obj.TextColor.GetBytes(true);
            update.TextureAnim = obj.TextureAnim.GetBytes();
            update.TextureEntry = obj.Textures == null ? new byte[0] : obj.Textures.ToBytes();
            update.Radius = obj.SoundRadius;
            update.Scale = obj.Scale;
            update.Sound = obj.Sound;
            update.State = obj.PrimData.State;
            update.Text = Utils.StringToBytes(obj.Text);
            update.UpdateFlags = (uint)flags;
            update.Data = obj.GenericData == null ? new byte[0] : obj.GenericData;

            return update;
        }
        void ObjectFlagUpdateHandler(Packet packet, Agent agent)
        {
            ObjectFlagUpdatePacket update = (ObjectFlagUpdatePacket)packet;

            SimulationObject obj;

            if (server.Scene.TryGetObject(update.AgentData.ObjectLocalID, out obj))
            {
                PrimFlags flags = obj.Prim.Flags;

                if (update.AgentData.CastsShadows)
                {
                    flags |= PrimFlags.CastShadows;
                }
                else
                {
                    flags &= ~PrimFlags.CastShadows;
                }

                if (update.AgentData.IsPhantom)
                {
                    flags |= PrimFlags.Phantom;
                }
                else
                {
                    flags &= ~PrimFlags.Phantom;
                }

                if (update.AgentData.IsTemporary)
                {
                    flags |= PrimFlags.Temporary;
                }
                else
                {
                    flags &= ~PrimFlags.Temporary;
                }

                if (update.AgentData.UsePhysics)
                {
                    flags |= PrimFlags.Physics;
                }
                else
                {
                    flags &= ~PrimFlags.Physics;
                }

                server.Scene.ObjectFlags(this, obj, flags);
            }
            else
            {
                Logger.Log("Got an ObjectFlagUpdate packet for unknown object " + update.AgentData.ObjectLocalID,
                           Helpers.LogLevel.Warning);
            }
        }
Beispiel #9
0
        public static ObjectUpdatePacket BuildFullUpdate(Primitive obj, ulong regionHandle,
                                                         byte state, PrimFlags flags)
        {
            ObjectUpdatePacket update = new ObjectUpdatePacket();

            update.RegionData.RegionHandle = regionHandle;
            update.RegionData.TimeDilation = UInt16.MaxValue;
            update.ObjectData    = new ObjectUpdatePacket.ObjectDataBlock[1];
            update.ObjectData[0] = BuildUpdateBlock(obj, regionHandle, state, flags);

            return(update);
        }
Beispiel #10
0
        public void ObjectFlags(object sender, SimulationObject obj, PrimFlags flags)
        {
            if (OnObjectFlags != null)
            {
                OnObjectFlags(sender, obj, flags);
            }

            // Update the object
            obj.Prim.Flags = flags;

            // Inform clients
            BroadcastObjectUpdate(obj);
        }
Beispiel #11
0
        private void UpdatePrimFlags(LLPrimitive obj)
        {
            IList <LLInventoryTaskItem> scripts = obj.Inventory.GetScripts();
            LSLEventFlags eventFlags            = 0;
            bool          hasCollisionEvents;
            bool          scripted = false;

            if (scripts.Count > 0)
            {
                scripted = true;

                // Aggregate LSLEventFlags for all of the running scripts in this prim
                lock (m_syncRoot)
                {
                    for (int i = 0; i < scripts.Count; i++)
                    {
                        LLInventoryTaskItem scriptItem = scripts[i];
                        LSLScriptInstance   script;

                        if (m_scripts.TryGetValue(scriptItem.ID, out script))
                        {
                            eventFlags |= script.GetEventsForState(script.State);
                        }
                    }
                }
            }

            PrimFlags oldFlags = obj.Prim.Flags;

            PrimFlags newFlags = oldFlags;

            newFlags &= ~(PrimFlags.Scripted | PrimFlags.Touch | PrimFlags.Money);
            if (scripted)
            {
                newFlags |= PrimFlags.Scripted;
            }
            newFlags |= LSLEventFlagsToPrimFlags(eventFlags, out hasCollisionEvents);

            // FIXME: Do something with hasCollisionEvents

            if (newFlags != oldFlags)
            {
                obj.Prim.Flags = newFlags;
                m_scene.EntityAddOrUpdate(this, obj, 0, (uint)LLUpdateFlags.PrimFlags);
            }
        }
Beispiel #12
0
        public bool ObjectAdd(object sender, Agent creator, SimulationObject obj, PrimFlags creatorFlags)
        {
            // Check if the object already exists in the scene
            if (sceneObjects.ContainsKey(obj.Prim.ID))
            {
                Logger.Log(String.Format("Attempting to add duplicate object {0} to the scene",
                                         obj.Prim.ID), Helpers.LogLevel.Warning);
                return(false);
            }

            // Assign a unique LocalID to this object
            obj.Prim.LocalID = (uint)Interlocked.Increment(ref currentLocalID);

            if (OnObjectAdd != null)
            {
                OnObjectAdd(sender, creator, obj, creatorFlags);
            }

            // Add the object to the scene dictionary
            sceneObjects.Add(obj.Prim.LocalID, obj.Prim.ID, obj);

            // Send an update out to the creator
            ObjectUpdatePacket updateToOwner = SimulationObject.BuildFullUpdate(obj.Prim, server.RegionHandle, 0,
                                                                                obj.Prim.Flags | creatorFlags);

            server.UDP.SendPacket(creator.AgentID, updateToOwner, PacketCategory.State);

            // Send an update out to everyone else
            ObjectUpdatePacket updateToOthers = SimulationObject.BuildFullUpdate(obj.Prim, server.RegionHandle, 0,
                                                                                 obj.Prim.Flags);

            lock (server.Agents)
            {
                foreach (Agent recipient in server.Agents.Values)
                {
                    if (recipient != creator)
                    {
                        server.UDP.SendPacket(recipient.AgentID, updateToOthers, PacketCategory.State);
                    }
                }
            }

            return(true);
        }
Beispiel #13
0
        static void SOPToXml(XmlTextWriter writer, PrimObject prim, PrimObject parent)
        {
            writer.WriteStartElement("SceneObjectPart");
            writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
            writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");

            WriteUUID(writer, "CreatorID", prim.CreatorID);
            WriteUUID(writer, "FolderID", prim.FolderID);
            writer.WriteElementString("InventorySerial", (prim.Inventory != null) ? prim.Inventory.Serial.ToString() : "0");

            // FIXME: Task inventory
            writer.WriteStartElement("TaskInventory");
            if (prim.Inventory != null)
            {
                foreach (PrimObject.InventoryBlock.ItemBlock item in prim.Inventory.Items)
                {
                    writer.WriteStartElement("", "TaskInventoryItem", "");

                    WriteUUID(writer, "AssetID", item.AssetID);
                    writer.WriteElementString("BasePermissions", item.PermsBase.ToString());
                    writer.WriteElementString("CreationDate", (item.CreationDate.ToUniversalTime() - Utils.Epoch).TotalSeconds.ToString());
                    WriteUUID(writer, "CreatorID", item.CreatorID);
                    writer.WriteElementString("Description", item.Description);
                    writer.WriteElementString("EveryonePermissions", item.PermsEveryone.ToString());
                    writer.WriteElementString("Flags", item.Flags.ToString());
                    WriteUUID(writer, "GroupID", item.GroupID);
                    writer.WriteElementString("GroupPermissions", item.PermsGroup.ToString());
                    writer.WriteElementString("InvType", ((int)item.InvType).ToString());
                    WriteUUID(writer, "ItemID", item.ID);
                    WriteUUID(writer, "OldItemID", UUID.Zero);
                    WriteUUID(writer, "LastOwnerID", item.LastOwnerID);
                    writer.WriteElementString("Name", item.Name);
                    writer.WriteElementString("NextPermissions", item.PermsNextOwner.ToString());
                    WriteUUID(writer, "OwnerID", item.OwnerID);
                    writer.WriteElementString("CurrentPermissions", item.PermsOwner.ToString());
                    WriteUUID(writer, "ParentID", prim.ID);
                    WriteUUID(writer, "ParentPartID", prim.ID);
                    WriteUUID(writer, "PermsGranter", item.PermsGranterID);
                    writer.WriteElementString("PermsMask", "0");
                    writer.WriteElementString("Type", ((int)item.Type).ToString());
                    writer.WriteElementString("OwnerChanged", "false");

                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();

            PrimFlags flags = PrimFlags.None;

            if (prim.UsePhysics)
            {
                flags |= PrimFlags.Physics;
            }
            if (prim.Phantom)
            {
                flags |= PrimFlags.Phantom;
            }
            if (prim.DieAtEdge)
            {
                flags |= PrimFlags.DieAtEdge;
            }
            if (prim.ReturnAtEdge)
            {
                flags |= PrimFlags.ReturnAtEdge;
            }
            if (prim.Temporary)
            {
                flags |= PrimFlags.Temporary;
            }
            if (prim.Sandbox)
            {
                flags |= PrimFlags.Sandbox;
            }
            writer.WriteElementString("ObjectFlags", ((int)flags).ToString());

            WriteUUID(writer, "UUID", prim.ID);
            writer.WriteElementString("LocalId", prim.LocalID.ToString());
            writer.WriteElementString("Name", prim.Name);
            writer.WriteElementString("Material", ((int)prim.Material).ToString());
            writer.WriteElementString("RegionHandle", prim.RegionHandle.ToString());
            writer.WriteElementString("ScriptAccessPin", prim.RemoteScriptAccessPIN.ToString());

            Vector3 groupPosition;

            if (parent == null)
            {
                groupPosition = prim.Position;
            }
            else
            {
                groupPosition = parent.Position;
            }

            WriteVector(writer, "GroupPosition", groupPosition);
            if (prim.ParentID == 0)
            {
                WriteVector(writer, "OffsetPosition", Vector3.Zero);
            }
            else
            {
                WriteVector(writer, "OffsetPosition", prim.Position);
            }
            WriteQuaternion(writer, "RotationOffset", prim.Rotation);
            WriteVector(writer, "Velocity", prim.Velocity);
            WriteVector(writer, "RotationalVelocity", Vector3.Zero);
            WriteVector(writer, "AngularVelocity", prim.AngularVelocity);
            WriteVector(writer, "Acceleration", prim.Acceleration);
            writer.WriteElementString("Description", prim.Description);
            writer.WriteStartElement("Color");
            writer.WriteElementString("R", prim.TextColor.R.ToString(Utils.EnUsCulture));
            writer.WriteElementString("G", prim.TextColor.G.ToString(Utils.EnUsCulture));
            writer.WriteElementString("B", prim.TextColor.B.ToString(Utils.EnUsCulture));
            writer.WriteElementString("A", prim.TextColor.G.ToString(Utils.EnUsCulture));
            writer.WriteEndElement();
            writer.WriteElementString("Text", prim.Text);
            writer.WriteElementString("SitName", prim.SitName);
            writer.WriteElementString("TouchName", prim.TouchName);

            writer.WriteElementString("LinkNum", prim.LinkNumber.ToString());
            writer.WriteElementString("ClickAction", prim.ClickAction.ToString());
            writer.WriteStartElement("Shape");

            writer.WriteElementString("PathBegin", Primitive.PackBeginCut(prim.Shape.PathBegin).ToString());
            writer.WriteElementString("PathCurve", prim.Shape.PathCurve.ToString());
            writer.WriteElementString("PathEnd", Primitive.PackEndCut(prim.Shape.PathEnd).ToString());
            writer.WriteElementString("PathRadiusOffset", Primitive.PackPathTwist(prim.Shape.PathRadiusOffset).ToString());
            writer.WriteElementString("PathRevolutions", Primitive.PackPathRevolutions(prim.Shape.PathRevolutions).ToString());
            writer.WriteElementString("PathScaleX", Primitive.PackPathScale(prim.Shape.PathScaleX).ToString());
            writer.WriteElementString("PathScaleY", Primitive.PackPathScale(prim.Shape.PathScaleY).ToString());
            writer.WriteElementString("PathShearX", ((byte)Primitive.PackPathShear(prim.Shape.PathShearX)).ToString());
            writer.WriteElementString("PathShearY", ((byte)Primitive.PackPathShear(prim.Shape.PathShearY)).ToString());
            writer.WriteElementString("PathSkew", Primitive.PackPathTwist(prim.Shape.PathSkew).ToString());
            writer.WriteElementString("PathTaperX", Primitive.PackPathTaper(prim.Shape.PathTaperX).ToString());
            writer.WriteElementString("PathTaperY", Primitive.PackPathTaper(prim.Shape.PathTaperY).ToString());
            writer.WriteElementString("PathTwist", Primitive.PackPathTwist(prim.Shape.PathTwist).ToString());
            writer.WriteElementString("PathTwistBegin", Primitive.PackPathTwist(prim.Shape.PathTwistBegin).ToString());
            writer.WriteElementString("PCode", prim.PCode.ToString());
            writer.WriteElementString("ProfileBegin", Primitive.PackBeginCut(prim.Shape.ProfileBegin).ToString());
            writer.WriteElementString("ProfileEnd", Primitive.PackEndCut(prim.Shape.ProfileEnd).ToString());
            writer.WriteElementString("ProfileHollow", Primitive.PackProfileHollow(prim.Shape.ProfileHollow).ToString());
            WriteVector(writer, "Scale", prim.Scale);
            writer.WriteElementString("State", prim.State.ToString());

            AssetPrim.ProfileShape shape = (AssetPrim.ProfileShape)(prim.Shape.ProfileCurve & 0x0F);
            HoleType hole = (HoleType)(prim.Shape.ProfileCurve & 0xF0);

            writer.WriteElementString("ProfileShape", shape.ToString());
            writer.WriteElementString("HollowShape", hole.ToString());
            writer.WriteElementString("ProfileCurve", prim.Shape.ProfileCurve.ToString());

            writer.WriteStartElement("TextureEntry");

            byte[] te;
            if (prim.Textures != null)
            {
                te = prim.Textures.GetBytes();
            }
            else
            {
                te = Utils.EmptyBytes;
            }

            writer.WriteBase64(te, 0, te.Length);
            writer.WriteEndElement();

            // FIXME: ExtraParams
            writer.WriteStartElement("ExtraParams"); writer.WriteEndElement();

            writer.WriteEndElement();

            WriteVector(writer, "Scale", prim.Scale);
            writer.WriteElementString("UpdateFlag", "0");
            WriteVector(writer, "SitTargetOrientation", Vector3.UnitZ); // TODO: Is this really a vector and not a quaternion?
            WriteVector(writer, "SitTargetPosition", prim.SitOffset);
            WriteVector(writer, "SitTargetPositionLL", prim.SitOffset);
            WriteQuaternion(writer, "SitTargetOrientationLL", prim.SitRotation);
            writer.WriteElementString("ParentID", prim.ParentID.ToString());
            writer.WriteElementString("CreationDate", ((int)Utils.DateTimeToUnixTime(prim.CreationDate)).ToString());
            writer.WriteElementString("Category", "0");
            writer.WriteElementString("SalePrice", prim.SalePrice.ToString());
            writer.WriteElementString("ObjectSaleType", ((int)prim.SaleType).ToString());
            writer.WriteElementString("OwnershipCost", "0");
            WriteUUID(writer, "GroupID", prim.GroupID);
            WriteUUID(writer, "OwnerID", prim.OwnerID);
            WriteUUID(writer, "LastOwnerID", prim.LastOwnerID);
            writer.WriteElementString("BaseMask", ((uint)PermissionMask.All).ToString());
            writer.WriteElementString("OwnerMask", ((uint)PermissionMask.All).ToString());
            writer.WriteElementString("GroupMask", ((uint)PermissionMask.All).ToString());
            writer.WriteElementString("EveryoneMask", ((uint)PermissionMask.All).ToString());
            writer.WriteElementString("NextOwnerMask", ((uint)PermissionMask.All).ToString());
            writer.WriteElementString("Flags", "None");
            WriteUUID(writer, "SitTargetAvatar", UUID.Zero);

            writer.WriteEndElement();
        }
Beispiel #14
0
 public static bool HasFlag(this PrimFlags primFlags, PrimFlags flag)
 {
     return (primFlags & flag) == flag;
 }
Beispiel #15
0
 public Primitive(Primitive prim)
 {
     ID           = prim.ID;
     GroupID      = prim.GroupID;
     LocalID      = prim.LocalID;
     ParentID     = prim.ParentID;
     RegionHandle = prim.RegionHandle;
     Flags        = prim.Flags;
     TreeSpecies  = prim.TreeSpecies;
     if (prim.ScratchPad != null)
     {
         ScratchPad = new byte[prim.ScratchPad.Length];
         Buffer.BlockCopy(prim.ScratchPad, 0, ScratchPad, 0, ScratchPad.Length);
     }
     else
     {
         ScratchPad = Utils.EmptyBytes;
     }
     Position          = prim.Position;
     Scale             = prim.Scale;
     Rotation          = prim.Rotation;
     Velocity          = prim.Velocity;
     AngularVelocity   = prim.AngularVelocity;
     Acceleration      = prim.Acceleration;
     CollisionPlane    = prim.CollisionPlane;
     Flexible          = prim.Flexible;
     Light             = prim.Light;
     Sculpt            = prim.Sculpt;
     ClickAction       = prim.ClickAction;
     Sound             = prim.Sound;
     OwnerID           = prim.OwnerID;
     SoundFlags        = prim.SoundFlags;
     SoundGain         = prim.SoundGain;
     SoundRadius       = prim.SoundRadius;
     Text              = prim.Text;
     TextColor         = prim.TextColor;
     MediaURL          = prim.MediaURL;
     Joint             = prim.Joint;
     JointPivot        = prim.JointPivot;
     JointAxisOrAnchor = prim.JointAxisOrAnchor;
     if (prim.NameValues != null)
     {
         if (NameValues == null || NameValues.Length != prim.NameValues.Length)
         {
             NameValues = new NameValue[prim.NameValues.Length];
         }
         Array.Copy(prim.NameValues, NameValues, prim.NameValues.Length);
     }
     else
     {
         NameValues = null;
     }
     PrimData   = prim.PrimData;
     Properties = prim.Properties;
     // FIXME: Get a real copy constructor for TextureEntry instead of serializing to bytes and back
     if (prim.Textures != null)
     {
         byte[] textureBytes = prim.Textures.GetBytes();
         Textures = new TextureEntry(textureBytes, 0, textureBytes.Length);
     }
     else
     {
         Textures = null;
     }
     TextureAnim = prim.TextureAnim;
     ParticleSys = prim.ParticleSys;
 }
Beispiel #16
0
        public static ObjectUpdatePacket.ObjectDataBlock BuildUpdateBlock(Primitive prim, PrimFlags flags, uint crc)
        {
            byte[] objectData = new byte[60];
            prim.Position.ToBytes(objectData, 0);
            prim.Velocity.ToBytes(objectData, 12);
            prim.Acceleration.ToBytes(objectData, 24);
            prim.Rotation.ToBytes(objectData, 36);
            prim.AngularVelocity.ToBytes(objectData, 48);

            ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
            update.ClickAction = (byte)prim.ClickAction;
            update.CRC = crc;
            update.ExtraParams = prim.GetExtraParamsBytes();
            update.Flags = (byte)flags;
            update.FullID = prim.ID;
            update.Gain = prim.SoundGain;
            update.ID = prim.LocalID;
            update.JointAxisOrAnchor = prim.JointAxisOrAnchor;
            update.JointPivot = prim.JointPivot;
            update.JointType = (byte)prim.Joint;
            update.Material = (byte)prim.PrimData.Material;
            update.MediaURL = Utils.StringToBytes(prim.MediaURL);
            update.NameValue = Utils.StringToBytes(NameValue.NameValuesToString(prim.NameValues));
            update.ObjectData = objectData;
            update.OwnerID = (prim.Properties != null ? prim.Properties.OwnerID : UUID.Zero);
            update.ParentID = prim.ParentID;
            update.PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin);
            update.PathCurve = (byte)prim.PrimData.PathCurve;
            update.PathEnd = Primitive.PackEndCut(prim.PrimData.PathEnd);
            update.PathRadiusOffset = Primitive.PackPathTwist(prim.PrimData.PathRadiusOffset);
            update.PathRevolutions = Primitive.PackPathRevolutions(prim.PrimData.PathRevolutions);
            update.PathScaleX = Primitive.PackPathScale(prim.PrimData.PathScaleX);
            update.PathScaleY = Primitive.PackPathScale(prim.PrimData.PathScaleY);
            update.PathShearX = (byte)Primitive.PackPathShear(prim.PrimData.PathShearX);
            update.PathShearY = (byte)Primitive.PackPathShear(prim.PrimData.PathShearY);
            update.PathSkew = Primitive.PackPathTwist(prim.PrimData.PathSkew);
            update.PathTaperX = Primitive.PackPathTaper(prim.PrimData.PathTaperX);
            update.PathTaperY = Primitive.PackPathTaper(prim.PrimData.PathTaperY);
            update.PathTwist = Primitive.PackPathTwist(prim.PrimData.PathTwist);
            update.PathTwistBegin = Primitive.PackPathTwist(prim.PrimData.PathTwistBegin);
            update.PCode = (byte)prim.PrimData.PCode;
            update.ProfileBegin = Primitive.PackBeginCut(prim.PrimData.ProfileBegin);
            update.ProfileCurve = (byte)prim.PrimData.ProfileCurve;
            update.ProfileEnd = Primitive.PackEndCut(prim.PrimData.ProfileEnd);
            update.ProfileHollow = Primitive.PackProfileHollow(prim.PrimData.ProfileHollow);
            update.PSBlock = prim.ParticleSys.GetBytes();
            update.TextColor = prim.TextColor.GetBytes(true);
            update.TextureAnim = prim.TextureAnim.GetBytes();
            update.TextureEntry = prim.Textures == null ? Utils.EmptyBytes : prim.Textures.GetBytes();
            update.Radius = prim.SoundRadius;
            update.Scale = prim.Scale;
            update.Sound = prim.Sound;
            update.State = prim.PrimData.State;
            update.Text = Utils.StringToBytes(prim.Text);
            update.UpdateFlags = (uint)flags;
            switch (prim.PrimData.PCode)
            {
                case PCode.Grass:
                case PCode.Tree:
                case PCode.NewTree:
                    update.Data = new byte[1];
                    update.Data[0] = (byte)prim.TreeSpecies;
                    break;
                default:
                    if (prim.ScratchPad != null)
                    {
                        update.Data = new byte[prim.ScratchPad.Length];
                        Buffer.BlockCopy(prim.ScratchPad, 0, update.Data, 0, update.Data.Length);
                    }
                    else
                    {
                        update.Data = new byte[0];
                    }
                    break;
            }

            return update;
        }
Beispiel #17
0
        public void aggregateScriptEvents()
        {
            AggregateScriptEvents = 0;

            // Aggregate script events
            lock (m_scriptEvents)
            {
                foreach (scriptEvents s in m_scriptEvents.Values)
                {
                    AggregateScriptEvents |= s;
                }
            }

            uint objectflagupdate = 0;

            if (
                ((AggregateScriptEvents & scriptEvents.touch) != 0) ||
                ((AggregateScriptEvents & scriptEvents.touch_end) != 0) ||
                ((AggregateScriptEvents & scriptEvents.touch_start) != 0)
                )
            {
                objectflagupdate |= (uint) PrimFlags.Touch;
            }

            if ((AggregateScriptEvents & scriptEvents.money) != 0)
            {
                objectflagupdate |= (uint) PrimFlags.Money;
            }

            if (AllowedDrop)
            {
                objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
            }

            // subscribe to physics updates.
            //We subscribe by default now... so 'shouldn't' need this
            if ((((AggregateScriptEvents & scriptEvents.collision) != 0) ||
                 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
                 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
                 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
                 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
                 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0)
                ) && PhysActor != null)
            {
                if (!m_hasSubscribedToCollisionEvent)
                {
                    m_hasSubscribedToCollisionEvent = true;
                    PhysActor.OnCollisionUpdate += PhysicsCollision;
                    PhysActor.SubscribeEvents(1000);
                }
            }
            else if (PhysActor != null)
            {
                if (m_hasSubscribedToCollisionEvent)
                {
                    m_hasSubscribedToCollisionEvent = false;
                    PhysActor.OnCollisionUpdate -= PhysicsCollision;
                }
            }

            if (m_parentGroup == null)
            {
//                MainConsole.Instance.DebugFormat(
//                    "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents() since m_parentGroup == null", Name, LocalId);
                ScheduleUpdate(PrimUpdateFlags.FullUpdate);
                return;
            }

            LocalFlags = (PrimFlags) objectflagupdate;

            if (m_parentGroup != null && m_parentGroup.RootPart == this)
            {
                m_parentGroup.aggregateScriptEvents();
            }
            else
            {
//                MainConsole.Instance.DebugFormat(
//                    "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId);
                ScheduleUpdate(PrimUpdateFlags.PrimFlags);
            }
        }
Beispiel #18
0
        public bool AddFlag(PrimFlags flag)
        {
            // PrimFlags prevflag = Flags;
            if ((Flags & flag) == 0)
            {
                //MainConsole.Instance.Debug("Adding flag: " + ((PrimFlags) flag).ToString());
                Flags |= flag;

                if (flag == PrimFlags.TemporaryOnRez)
                    ResetExpire();

                object[] o = new object[2];
                o[0] = this;
                o[1] = flag;
                m_parentGroup.Scene.AuroraEventManager.FireGenericEventHandler("ObjectAddedFlag", o);
                return true;
            }
            return false;
            // MainConsole.Instance.Debug("Aprev: " + prevflag.ToString() + " curr: " + Flags.ToString());
        }
Beispiel #19
0
        /// <summary>
        ///     Create a completely new SceneObjectPart (prim).  This will need to be added separately to a SceneObjectGroup
        /// </summary>
        /// <param name="ownerID"></param>
        /// <param name="shape"></param>
        /// <param name="groupPosition"></param>
        /// <param name="rotationOffset"></param>
        /// <param name="offsetPosition"></param>
        /// <param name="name"></param>
        public SceneObjectPart(
            UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
            Quaternion rotationOffset, Vector3 offsetPosition, string name)
        {
            m_name = name;

            CreationDate = (int) Utils.DateTimeToUnixTime(DateTime.Now);
            _ownerID = ownerID;
            _creatorID = _ownerID;
            LastOwnerID = UUID.Zero;
            UUID = UUID.Random();
            Shape = shape;
            CRC = 1;
            _ownershipCost = 0;
            _flags = 0;
            _groupID = UUID.Zero;
            _objectSaleType = 0;
            _salePrice = 0;
            _category = 0;
            LastOwnerID = _creatorID;
            m_groupPosition = groupPosition;
            m_offsetPosition = offsetPosition;
            RotationOffset = rotationOffset;
            Velocity = Vector3.Zero;
            AngularVelocity = Vector3.Zero;
            Acceleration = Vector3.Zero;
            SitTargetAvatar = new List<UUID>();
            StateSaves = new Dictionary<UUID, StateSave>();

            ValidpartOOB = false;

            // Prims currently only contain a single folder (Contents).  From looking at the Second Life protocol,
            // this appears to have the same UUID (!) as the prim.  If this isn't the case, one can't drag items from
            // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log

            Flags = 0;
            CreateSelected = true;

            TrimPermissions();
            //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo());

            m_inventory = new SceneObjectPartInventory(this);
            Material = (int) OpenMetaverse.Material.Wood;
        }
Beispiel #20
0
        public void aggregateScriptEvents()
        {
            if (ParentGroup == null || ParentGroup.RootPart == null)
                return;

            AggregateScriptEvents = 0;

            // Aggregate script events
            lock (m_scriptEvents)
            {
                foreach (scriptEvents s in m_scriptEvents.Values)
                {
                    AggregateScriptEvents |= s;
                }
            }

            uint objectflagupdate = 0;

            if (
                ((AggregateScriptEvents & scriptEvents.touch) != 0) ||
                ((AggregateScriptEvents & scriptEvents.touch_end) != 0) ||
                ((AggregateScriptEvents & scriptEvents.touch_start) != 0)
                )
            {
                objectflagupdate |= (uint) PrimFlags.Touch;
            }

            if ((AggregateScriptEvents & scriptEvents.money) != 0)
            {
                objectflagupdate |= (uint) PrimFlags.Money;
            }

            if (AllowedDrop)
            {
                objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
            }

            SubscribeForCollisionEvents();

            //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
            //{
            //    ParentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting;
            //}
            //else
            //{
            //    ParentGroup.Scene.EventManager.OnScriptTimerEvent -= handleTimerAccounting;
            //}

            LocalFlags = (PrimFlags)objectflagupdate;

            if (ParentGroup != null && ParentGroup.RootPart == this)
            {
                ParentGroup.aggregateScriptEvents();
            }
            else
            {
//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId);
                ScheduleFullUpdate();
            }
        }
        public void AddFlag(PrimFlags flag)
        {
            // PrimFlags prevflag = Flags;
            if ((ObjectFlags & (uint) flag) == 0)
            {
                _flags |= flag;

                if (flag == PrimFlags.TemporaryOnRez)
                    ResetExpire();
                if((flag & PrimFlags.Scripted) != 0 && !ParentGroup.IsScripted)
                    ParentGroup.CheckIfScriptedStatusChanged();
            }
        }
Beispiel #22
0
        public void AddFlag(PrimFlags flag)
        {
            // PrimFlags prevflag = Flags;
            if ((ObjectFlags & (uint) flag) == 0)
            {
		        _flags |= flag;

                if (flag == PrimFlags.TemporaryOnRez)
                    ResetExpire();
            }
        }
Beispiel #23
0
        public PrimFlags GetFlagsFor(IScenePresence presence, LLPrimitive entity)
        {
            PrimFlags   flags = entity.Prim.Flags;
            Permissions perms = entity.Prim.Properties.Permissions;

            // Remove flags that shouldn't be sent to clients
            flags &= ~(PrimFlags.DieAtEdge | PrimFlags.Flying | PrimFlags.ReturnAtEdge | PrimFlags.Sandbox);

            if (entity.OwnerID != UUID.Zero)
            {
                flags |= PrimFlags.ObjectAnyOwner; // Someone owns the object
            }
            if (entity.GroupID != UUID.Zero)
            {
                flags |= (PrimFlags.ObjectAnyOwner | PrimFlags.ObjectGroupOwned); // A group owns this object
            }
            if (entity.OwnerID == presence.ID || IsGridAdmin(presence) || IsEstateManager(presence))
            {
                // User owner permissions

                // Mark that we own this object
                flags |= PrimFlags.ObjectYouOwner;
                flags |= PrimFlags.ObjectOwnerModify;

                if (perms.OwnerMask.HasPermission(PermissionMask.Copy))
                {
                    flags |= PrimFlags.ObjectCopy;
                }
                if (perms.OwnerMask.HasPermission(PermissionMask.Modify))
                {
                    flags |= PrimFlags.ObjectModify;
                }
                if (perms.OwnerMask.HasPermission(PermissionMask.Move))
                {
                    flags |= PrimFlags.ObjectMove;
                }
                if (perms.OwnerMask.HasPermission(PermissionMask.Transfer))
                {
                    flags |= PrimFlags.ObjectTransfer;
                }
            }
            else if (IsInGroup(presence, entity.GroupID))
            {
                // Use group permissions

                // Mark that we own this object
                flags |= PrimFlags.ObjectYouOwner;
                flags |= PrimFlags.ObjectOwnerModify;
                flags |= PrimFlags.ObjectYouOfficer;

                if (perms.GroupMask.HasPermission(PermissionMask.Copy))
                {
                    flags |= PrimFlags.ObjectCopy;
                }
                if (perms.GroupMask.HasPermission(PermissionMask.Modify))
                {
                    flags |= PrimFlags.ObjectModify;
                }
                if (perms.GroupMask.HasPermission(PermissionMask.Move))
                {
                    flags |= PrimFlags.ObjectMove;
                }
                if (perms.GroupMask.HasPermission(PermissionMask.Transfer))
                {
                    flags |= PrimFlags.ObjectTransfer;
                }
            }
            else
            {
                // Use everyone permissions

                if (perms.EveryoneMask.HasPermission(PermissionMask.Copy))
                {
                    flags |= PrimFlags.ObjectCopy;
                }
                if (perms.EveryoneMask.HasPermission(PermissionMask.Modify))
                {
                    flags |= PrimFlags.ObjectModify;
                }
                if (perms.EveryoneMask.HasPermission(PermissionMask.Move))
                {
                    flags |= PrimFlags.ObjectMove;
                }
                if (perms.EveryoneMask.HasPermission(PermissionMask.Transfer))
                {
                    flags |= PrimFlags.ObjectTransfer;
                }
            }

            return(flags);
        }
Beispiel #24
0
        public static ObjectUpdatePacket.ObjectDataBlock BuildUpdateBlock(Primitive obj, ulong regionHandle,
                                                                          byte state, PrimFlags flags)
        {
            byte[] objectData = BuildObjectData(obj.Position, obj.Rotation, obj.Velocity,
                                                obj.Acceleration, obj.AngularVelocity);

            ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
            update.ClickAction       = (byte)obj.ClickAction;
            update.CRC               = 0;
            update.ExtraParams       = new byte[0]; //FIXME: Need a serializer for ExtraParams
            update.Flags             = (byte)flags;
            update.FullID            = obj.ID;
            update.Gain              = obj.SoundGain;
            update.ID                = obj.LocalID;
            update.JointAxisOrAnchor = obj.JointAxisOrAnchor;
            update.JointPivot        = obj.JointPivot;
            update.JointType         = (byte)obj.Joint;
            update.Material          = (byte)obj.PrimData.Material;
            update.MediaURL          = Utils.StringToBytes(obj.MediaURL);
            update.NameValue         = Utils.StringToBytes(NameValue.NameValuesToString(obj.NameValues));
            update.ObjectData        = objectData;
            update.OwnerID           = obj.Properties.OwnerID;
            update.ParentID          = obj.ParentID;
            update.PathBegin         = Primitive.PackBeginCut(obj.PrimData.PathBegin);
            update.PathCurve         = (byte)obj.PrimData.PathCurve;
            update.PathEnd           = Primitive.PackEndCut(obj.PrimData.PathEnd);
            update.PathRadiusOffset  = Primitive.PackPathTwist(obj.PrimData.PathRadiusOffset);
            update.PathRevolutions   = Primitive.PackPathRevolutions(obj.PrimData.PathRevolutions);
            update.PathScaleX        = Primitive.PackPathScale(obj.PrimData.PathScaleX);
            update.PathScaleY        = Primitive.PackPathScale(obj.PrimData.PathScaleY);
            update.PathShearX        = (byte)Primitive.PackPathShear(obj.PrimData.PathShearX);
            update.PathShearY        = (byte)Primitive.PackPathShear(obj.PrimData.PathShearY);
            update.PathSkew          = Primitive.PackPathTwist(obj.PrimData.PathSkew);
            update.PathTaperX        = Primitive.PackPathTaper(obj.PrimData.PathTaperX);
            update.PathTaperY        = Primitive.PackPathTaper(obj.PrimData.PathTaperY);
            update.PathTwist         = Primitive.PackPathTwist(obj.PrimData.PathTwist);
            update.PathTwistBegin    = Primitive.PackPathTwist(obj.PrimData.PathTwistBegin);
            update.PCode             = (byte)obj.PrimData.PCode;
            update.ProfileBegin      = Primitive.PackBeginCut(obj.PrimData.ProfileBegin);
            update.ProfileCurve      = (byte)obj.PrimData.ProfileCurve;
            update.ProfileEnd        = Primitive.PackEndCut(obj.PrimData.ProfileEnd);
            update.ProfileHollow     = Primitive.PackProfileHollow(obj.PrimData.ProfileHollow);
            update.PSBlock           = new byte[0]; // FIXME:
            update.TextColor         = obj.TextColor.GetBytes(true);
            update.TextureAnim       = obj.TextureAnim.GetBytes();
            update.TextureEntry      = obj.Textures == null ? new byte[0] : obj.Textures.ToBytes();
            update.Radius            = obj.SoundRadius;
            update.Scale             = obj.Scale;
            update.Sound             = obj.Sound;
            update.State             = state;
            update.Text              = Utils.StringToBytes(obj.Text);
            update.UpdateFlags       = (uint)flags;
            update.Data              = new byte[0]; // FIXME:

            return(update);
        }
Beispiel #25
0
        public void ObjectAddOrUpdate(object sender, SimulationObject obj, UUID ownerID, int scriptStartParam, PrimFlags creatorFlags, UpdateFlags updateFlags)
        {
            if (OnObjectAddOrUpdate != null)
            {
                OnObjectAddOrUpdate(sender, obj, ownerID, scriptStartParam, creatorFlags, updateFlags);
            }

            #region Initialize new objects

            // Check if the object already exists in the scene
            if (!sceneObjects.ContainsKey(obj.Prim.ID))
            {
                // Enable some default flags that all objects will have
                obj.Prim.Flags |= server.Permissions.GetDefaultObjectFlags();

                // Object did not exist before, so there's no way it could contain inventory
                obj.Prim.Flags |= PrimFlags.InventoryEmpty;

                // Fun Fact: Prim.OwnerID is only used by the LL viewer to mute sounds
                obj.Prim.OwnerID = ownerID;

                // Other than storing tree species, I have no idea what this does
                obj.Prim.ScratchPad = Utils.EmptyBytes;

                // Assign a unique LocalID to this object if no LocalID is set
                if (obj.Prim.LocalID == 0)
                    obj.Prim.LocalID = (uint)Interlocked.Increment(ref currentLocalID);

                // Assign a random ID to this object if no ID is set
                if (obj.Prim.ID == UUID.Zero)
                    obj.Prim.ID = UUID.Random();

                // Set the RegionHandle if no RegionHandle is set
                if (obj.Prim.RegionHandle == 0)
                    obj.Prim.RegionHandle = regionHandle;

                // Make sure this object has properties
                if (obj.Prim.Properties == null)
                {
                    obj.Prim.Properties = new Primitive.ObjectProperties();
                    obj.Prim.Properties.CreationDate = DateTime.Now;
                    obj.Prim.Properties.CreatorID = ownerID;
                    obj.Prim.Properties.Name = "New Object";
                    obj.Prim.Properties.ObjectID = obj.Prim.ID;
                    obj.Prim.Properties.OwnerID = ownerID;
                    obj.Prim.Properties.Permissions = server.Permissions.GetDefaultPermissions();
                    obj.Prim.Properties.SalePrice = 10;
                }

                // Set the default scale
                if (obj.Prim.Scale == Vector3.Zero)
                    obj.Prim.Scale = new Vector3(0.5f, 0.5f, 0.5f);

                // Set the collision plane
                if (obj.Prim.CollisionPlane == Vector4.Zero)
                    obj.Prim.CollisionPlane = Vector4.UnitW;

                // Set default textures if none are set
                if (obj.Prim.Textures == null)
                    obj.Prim.Textures = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f")); // Plywood

                // Add the object to the scene dictionary
                sceneObjects.Add(obj.Prim.LocalID, obj.Prim.ID, obj);
            }

            #endregion Initialize new objects

            // Reset the prim CRC
            obj.CRC = 0;

            #region UpdateFlags to packet type conversion

            bool canUseCompressed = true;
            bool canUseImproved = true;

            if ((updateFlags & UpdateFlags.FullUpdate) == UpdateFlags.FullUpdate || creatorFlags != PrimFlags.None)
            {
                canUseCompressed = false;
                canUseImproved = false;
            }
            else
            {
                if ((updateFlags & UpdateFlags.Velocity) != 0 ||
                    (updateFlags & UpdateFlags.Acceleration) != 0 ||
                    (updateFlags & UpdateFlags.CollisionPlane) != 0 ||
                    (updateFlags & UpdateFlags.Joint) != 0)
                {
                    canUseCompressed = false;
                }
                
                if ((updateFlags & UpdateFlags.PrimFlags) != 0 ||
                    (updateFlags & UpdateFlags.ParentID) != 0 ||
                    (updateFlags & UpdateFlags.Scale) != 0 ||
                    (updateFlags & UpdateFlags.PrimData) != 0 ||
                    (updateFlags & UpdateFlags.Text) != 0 ||
                    (updateFlags & UpdateFlags.NameValue) != 0 ||
                    (updateFlags & UpdateFlags.ExtraData) != 0 ||
                    (updateFlags & UpdateFlags.TextureAnim) != 0 ||
                    (updateFlags & UpdateFlags.Sound) != 0 ||
                    (updateFlags & UpdateFlags.Particles) != 0 ||
                    (updateFlags & UpdateFlags.Material) != 0 ||
                    (updateFlags & UpdateFlags.ClickAction) != 0 ||
                    (updateFlags & UpdateFlags.MediaURL) != 0 ||
                    (updateFlags & UpdateFlags.Joint) != 0)
                {
                    canUseImproved = false;
                }
            }

            #endregion UpdateFlags to packet type conversion

            SendObjectPacket(obj, canUseCompressed, canUseImproved, creatorFlags, updateFlags);
        }
Beispiel #26
0
 public static bool HasFlag(this PrimFlags primFlags, PrimFlags flag)
 {
     return((primFlags & flag) == flag);
 }
        public void aggregateScriptEvents()
        {
            AggregateScriptEvents = 0;

            // Aggregate script events
            lock (m_scriptEvents)
            {
                foreach (scriptEvents s in m_scriptEvents.Values)
                {
                    AggregateScriptEvents |= s;
                }
            }

            uint objectflagupdate = 0;

            if (
                ((AggregateScriptEvents & scriptEvents.touch) != 0) ||
                ((AggregateScriptEvents & scriptEvents.touch_end) != 0) ||
                ((AggregateScriptEvents & scriptEvents.touch_start) != 0)
                )
            {
                objectflagupdate |= (uint) PrimFlags.Touch;
            }

            if ((AggregateScriptEvents & scriptEvents.money) != 0)
            {
                objectflagupdate |= (uint) PrimFlags.Money;
            }

            if (AllowedDrop)
            {
                objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
            }

            // subscribe to physics updates.
            if (PhysActor != null)
            {
                PhysActor.OnCollisionUpdate += PhysicsCollision;
                PhysActor.SubscribeEvents(1000);
            }

            if (m_parentGroup == null)
            {
//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents() since m_parentGroup == null", Name, LocalId);
                ScheduleUpdate(PrimUpdateFlags.FullUpdate);
                return;
            }

            LocalFlags=(PrimFlags)objectflagupdate;

            if (m_parentGroup != null && m_parentGroup.RootPart == this)
            {
                m_parentGroup.aggregateScriptEvents();
            }
            else
            {
//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId);
                ScheduleUpdate(PrimUpdateFlags.PrimFlags);
            }
        }
Beispiel #28
0
 public void RemGroupFlagValue(PrimFlags flag)
 {
     ForEachPart((SceneObjectPart part) =>
     {
         part.RemFlag(flag);
     }
     );
 }
Beispiel #29
0
        public void AddFlag(PrimFlags flag)
        {
            // PrimFlags prevflag = Flags;
            if ((ObjectFlags & (uint) flag) == 0)
            {
                _flags |= flag;

                if (flag == PrimFlags.TemporaryOnRez)
                    ResetExpire();
                if (ParentGroup != null)    // null when called from the persistence backup
                    if((flag & PrimFlags.Scripted) != 0 && !ParentGroup.IsScripted)
                        ParentGroup.RecalcScriptedStatus();
            }
        }
Beispiel #30
0
 public SendPrimitiveData(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape,
                            Vector3 pos, Vector3 vel, Vector3 acc, Quaternion rotation, Vector3 rvel,
                            uint flags,
                            UUID objectID, UUID ownerID, string text, byte[] color, uint parentID,
                            byte[] particleSystem,
                            byte clickAction, byte material, byte[] textureanim, bool attachment,
                            uint AttachPoint, UUID AssetId, UUID SoundId, double SoundVolume, byte SoundFlags,
                            double SoundRadius, double priority)
 {
     this.m_regionHandle = regionHandle;
     this.m_timeDilation = timeDilation;
     this.m_localID = localID;
     this.m_primShape = primShape;
     this.m_pos = pos;
     this.m_vel = vel;
     this.m_acc = acc;
     this.m_rotation = rotation;
     this.m_rvel = rvel;
     this.m_flags = (PrimFlags)flags;
     this.m_objectID = objectID;
     this.m_ownerID = ownerID;
     this.m_text = text;
     this.m_color = color;
     this.m_parentID = parentID;
     this.m_particleSystem = particleSystem;
     this.m_clickAction = clickAction;
     this.m_material = material;
     this.m_textureanim = textureanim;
     this.m_attachment = attachment;
     this.m_AttachPoint = AttachPoint;
     this.m_AssetId = AssetId;
     this.m_SoundId = SoundId;
     this.m_SoundVolume = SoundVolume;
     this.m_SoundFlags = SoundFlags;
     this.m_SoundRadius = SoundRadius;
     this.m_priority = priority;
 }
Beispiel #31
0
        public void SendFullUpdateToClientImmediate(IClientAPI remoteClient, Vector3 lPos, uint clientFlags)
        {
            clientFlags &= ~(uint)PrimFlags.CreateSelected;
            if ((uint)(_flags & PrimFlags.Scripted) != 0)
                clientFlags |= (uint)PrimFlags.Scripted;
            else
                clientFlags &= ~(uint)PrimFlags.Scripted;

            if (remoteClient.AgentId == _ownerID)
            {
                if ((uint)(_flags & PrimFlags.CreateSelected) != 0)
                {
                    clientFlags |= (uint)PrimFlags.CreateSelected;
                    _flags &= ~PrimFlags.CreateSelected;
                }
            }
            else
            {   // Someone else's object
                // If it's worn as a HUD, don't send this no matter what
                if (ParentGroup.IsAttachedHUD)
                    return;
            }

            remoteClient.SendPrimitiveToClientImmediate(this, clientFlags, lPos);
        }
Beispiel #32
0
 public bool RemFlag(PrimFlags flag)
 {
     // PrimFlags prevflag = Flags;
     if ((Flags & flag) != 0)
     {
         //MainConsole.Instance.Debug("Removing flag: " + ((PrimFlags)flag).ToString());
         Flags &= ~flag;
         object[] o = new object[2];
         o[0] = this;
         o[1] = flag;
         m_parentGroup.Scene.AuroraEventManager.FireGenericEventHandler("ObjectRemovedFlag", o);
         return true;
     }
     return false;
     //MainConsole.Instance.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString());
     //ScheduleFullUpdate();
 }
Beispiel #33
0
        void SendObjectPacket(SimulationObject obj, bool canUseCompressed, bool canUseImproved, PrimFlags creatorFlags, UpdateFlags updateFlags)
        {
            if (!canUseImproved && !canUseCompressed)
            {
                #region ObjectUpdate

                Logger.DebugLog("Sending ObjectUpdate");

                if (sceneAgents.ContainsKey(obj.Prim.OwnerID))
                {
                    // Send an update out to the creator
                    ObjectUpdatePacket updateToOwner = new ObjectUpdatePacket();
                    updateToOwner.RegionData.RegionHandle = regionHandle;
                    updateToOwner.RegionData.TimeDilation = (ushort)(timeDilation * (float)UInt16.MaxValue);
                    updateToOwner.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
                    updateToOwner.ObjectData[0] = SimulationObject.BuildUpdateBlock(obj.Prim,
                        obj.Prim.Flags | creatorFlags | PrimFlags.ObjectYouOwner, obj.CRC);

                    udp.SendPacket(obj.Prim.OwnerID, updateToOwner, PacketCategory.State);
                }

                // Send an update out to everyone else
                ObjectUpdatePacket updateToOthers = new ObjectUpdatePacket();
                updateToOthers.RegionData.RegionHandle = regionHandle;
                updateToOthers.RegionData.TimeDilation = UInt16.MaxValue;
                updateToOthers.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
                updateToOthers.ObjectData[0] = SimulationObject.BuildUpdateBlock(obj.Prim,
                    obj.Prim.Flags, obj.CRC);

                ForEachAgent(
                    delegate(Agent recipient)
                    {
                        if (recipient.ID != obj.Prim.OwnerID)
                            udp.SendPacket(recipient.ID, updateToOthers, PacketCategory.State);
                    }
                );

                #endregion ObjectUpdate
            }
            else if (!canUseImproved)
            {
                #region ObjectUpdateCompressed

                #region Size calculation and field serialization

                CompressedFlags flags = 0;
                int size = 84;
                byte[] textBytes = null;
                byte[] mediaURLBytes = null;
                byte[] particleBytes = null;
                byte[] extraParamBytes = null;
                byte[] nameValueBytes = null;
                byte[] textureBytes = null;
                byte[] textureAnimBytes = null;

                if ((updateFlags & UpdateFlags.AngularVelocity) != 0)
                {
                    flags |= CompressedFlags.HasAngularVelocity;
                    size += 12;
                }
                if ((updateFlags & UpdateFlags.ParentID) != 0)
                {
                    flags |= CompressedFlags.HasParent;
                    size += 4;
                }
                if ((updateFlags & UpdateFlags.ScratchPad) != 0)
                {
                    switch (obj.Prim.PrimData.PCode)
                    {
                        case PCode.Grass:
                        case PCode.Tree:
                        case PCode.NewTree:
                            flags |= CompressedFlags.Tree;
                            size += 2; // Size byte plus one byte
                            break;
                        default:
                            flags |= CompressedFlags.ScratchPad;
                            size += 1 + obj.Prim.ScratchPad.Length; // Size byte plus bytes
                            break;
                    }
                }
                if ((updateFlags & UpdateFlags.Text) != 0)
                {
                    flags |= CompressedFlags.HasText;
                    textBytes = Utils.StringToBytes(obj.Prim.Text);
                    size += textBytes.Length; // Null-terminated, no size byte
                    size += 4; // Text color
                }
                if ((updateFlags & UpdateFlags.MediaURL) != 0)
                {
                    flags |= CompressedFlags.MediaURL;
                    mediaURLBytes = Utils.StringToBytes(obj.Prim.MediaURL);
                    size += mediaURLBytes.Length; // Null-terminated, no size byte
                }
                if ((updateFlags & UpdateFlags.Particles) != 0)
                {
                    flags |= CompressedFlags.HasParticles;
                    particleBytes = obj.Prim.ParticleSys.GetBytes();
                    size += particleBytes.Length; // Should be exactly 86 bytes
                }

                // Extra Params
                extraParamBytes = obj.Prim.GetExtraParamsBytes();
                size += extraParamBytes.Length;

                if ((updateFlags & UpdateFlags.Sound) != 0)
                {
                    flags |= CompressedFlags.HasSound;
                    size += 25; // SoundID, SoundGain, SoundFlags, SoundRadius
                }
                if ((updateFlags & UpdateFlags.NameValue) != 0)
                {
                    flags |= CompressedFlags.HasNameValues;
                    nameValueBytes = Utils.StringToBytes(NameValue.NameValuesToString(obj.Prim.NameValues));
                    size += nameValueBytes.Length; // Null-terminated, no size byte
                }

                size += 23; // PrimData
                size += 4; // Texture Length
                textureBytes = obj.Prim.Textures.GetBytes();
                size += textureBytes.Length; // Texture Entry

                if ((updateFlags & UpdateFlags.TextureAnim) != 0)
                {
                    flags |= CompressedFlags.TextureAnimation;
                    size += 4; // TextureAnim Length
                    textureAnimBytes = obj.Prim.TextureAnim.GetBytes();
                    size += textureAnimBytes.Length; // TextureAnim
                }

                #endregion Size calculation and field serialization

                #region Packet serialization

                int pos = 0;
                byte[] data = new byte[size];

                // UUID
                obj.Prim.ID.ToBytes(data, 0);
                pos += 16;
                // LocalID
                Utils.UIntToBytes(obj.Prim.LocalID, data, pos);
                pos += 4;
                // PCode
                data[pos++] = (byte)obj.Prim.PrimData.PCode;
                // State
                data[pos++] = obj.Prim.PrimData.State;
                // CRC
                Utils.UIntToBytes(obj.CRC, data, pos);
                pos += 4;
                // Material
                data[pos++] = (byte)obj.Prim.PrimData.Material;
                // ClickAction
                data[pos++] = (byte)obj.Prim.ClickAction;
                // Scale
                obj.Prim.Scale.ToBytes(data, pos);
                pos += 12;
                // Position
                obj.Prim.Position.ToBytes(data, pos);
                pos += 12;
                // Rotation
                obj.Prim.Rotation.ToBytes(data, pos);
                pos += 12;
                // Compressed Flags
                Utils.UIntToBytes((uint)flags, data, pos);
                pos += 4;
                // OwnerID
                obj.Prim.OwnerID.ToBytes(data, pos);
                pos += 16;

                if ((flags & CompressedFlags.HasAngularVelocity) != 0)
                {
                    obj.Prim.AngularVelocity.ToBytes(data, pos);
                    pos += 12;
                }
                if ((flags & CompressedFlags.HasParent) != 0)
                {
                    Utils.UIntToBytes(obj.Prim.ParentID, data, pos);
                    pos += 4;
                }
                if ((flags & CompressedFlags.ScratchPad) != 0)
                {
                    data[pos++] = (byte)obj.Prim.ScratchPad.Length;
                    Buffer.BlockCopy(obj.Prim.ScratchPad, 0, data, pos, obj.Prim.ScratchPad.Length);
                    pos += obj.Prim.ScratchPad.Length;
                }
                else if ((flags & CompressedFlags.Tree) != 0)
                {
                    data[pos++] = 1;
                    data[pos++] = (byte)obj.Prim.TreeSpecies;
                }
                if ((flags & CompressedFlags.HasText) != 0)
                {
                    Buffer.BlockCopy(textBytes, 0, data, pos, textBytes.Length);
                    pos += textBytes.Length;
                    obj.Prim.TextColor.ToBytes(data, pos, false);
                    pos += 4;
                }
                if ((flags & CompressedFlags.MediaURL) != 0)
                {
                    Buffer.BlockCopy(mediaURLBytes, 0, data, pos, mediaURLBytes.Length);
                    pos += mediaURLBytes.Length;
                }
                if ((flags & CompressedFlags.HasParticles) != 0)
                {
                    Buffer.BlockCopy(particleBytes, 0, data, pos, particleBytes.Length);
                    pos += particleBytes.Length;
                }

                // Extra Params
                Buffer.BlockCopy(extraParamBytes, 0, data, pos, extraParamBytes.Length);
                pos += extraParamBytes.Length;

                if ((flags & CompressedFlags.HasSound) != 0)
                {
                    obj.Prim.Sound.ToBytes(data, pos);
                    pos += 16;
                    Utils.FloatToBytes(obj.Prim.SoundGain, data, pos);
                    pos += 4;
                    data[pos++] = (byte)obj.Prim.SoundFlags;
                    Utils.FloatToBytes(obj.Prim.SoundRadius, data, pos);
                    pos += 4;
                }
                if ((flags & CompressedFlags.HasNameValues) != 0)
                {
                    Buffer.BlockCopy(nameValueBytes, 0, data, pos, nameValueBytes.Length);
                    pos += nameValueBytes.Length;
                }

                // Path PrimData
                data[pos++] = (byte)obj.Prim.PrimData.PathCurve;
                Utils.UInt16ToBytes(Primitive.PackBeginCut(obj.Prim.PrimData.PathBegin), data, pos); pos += 2;
                Utils.UInt16ToBytes(Primitive.PackEndCut(obj.Prim.PrimData.PathEnd), data, pos); pos += 2;
                data[pos++] = Primitive.PackPathScale(obj.Prim.PrimData.PathScaleX);
                data[pos++] = Primitive.PackPathScale(obj.Prim.PrimData.PathScaleY);
                data[pos++] = (byte)Primitive.PackPathShear(obj.Prim.PrimData.PathShearX);
                data[pos++] = (byte)Primitive.PackPathShear(obj.Prim.PrimData.PathShearY);
                data[pos++] = (byte)Primitive.PackPathTwist(obj.Prim.PrimData.PathTwist);
                data[pos++] = (byte)Primitive.PackPathTwist(obj.Prim.PrimData.PathTwistBegin);
                data[pos++] = (byte)Primitive.PackPathTwist(obj.Prim.PrimData.PathRadiusOffset);
                data[pos++] = (byte)Primitive.PackPathTaper(obj.Prim.PrimData.PathTaperX);
                data[pos++] = (byte)Primitive.PackPathTaper(obj.Prim.PrimData.PathTaperY);
                data[pos++] = Primitive.PackPathRevolutions(obj.Prim.PrimData.PathRevolutions);
                data[pos++] = (byte)Primitive.PackPathTwist(obj.Prim.PrimData.PathSkew);
                // Profile PrimData
                data[pos++] = obj.Prim.PrimData.profileCurve;
                Utils.UInt16ToBytes(Primitive.PackBeginCut(obj.Prim.PrimData.ProfileBegin), data, pos); pos += 2;
                Utils.UInt16ToBytes(Primitive.PackEndCut(obj.Prim.PrimData.ProfileEnd), data, pos); pos += 2;
                Utils.UInt16ToBytes(Primitive.PackProfileHollow(obj.Prim.PrimData.ProfileHollow), data, pos); pos += 2;

                // Texture Length
                Utils.UIntToBytes((uint)textureBytes.Length, data, pos);
                pos += 4;
                // Texture Entry
                Buffer.BlockCopy(textureBytes, 0, data, pos, textureBytes.Length);
                pos += textureBytes.Length;

                if ((flags & CompressedFlags.TextureAnimation) != 0)
                {
                    Utils.UIntToBytes((uint)textureAnimBytes.Length, data, pos);
                    pos += 4;
                    Buffer.BlockCopy(textureAnimBytes, 0, data, pos, textureAnimBytes.Length);
                    pos += textureAnimBytes.Length;
                }

                #endregion Packet serialization

                #region Packet sending

                //Logger.DebugLog("Sending ObjectUpdateCompressed with " + flags.ToString());

                if (sceneAgents.ContainsKey(obj.Prim.OwnerID))
                {
                    // Send an update out to the creator
                    ObjectUpdateCompressedPacket updateToOwner = new ObjectUpdateCompressedPacket();
                    updateToOwner.RegionData.RegionHandle = regionHandle;
                    updateToOwner.RegionData.TimeDilation = (ushort)(timeDilation * (float)UInt16.MaxValue);
                    updateToOwner.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[1];
                    updateToOwner.ObjectData[0] = new ObjectUpdateCompressedPacket.ObjectDataBlock();
                    updateToOwner.ObjectData[0].UpdateFlags = (uint)(obj.Prim.Flags | creatorFlags | PrimFlags.ObjectYouOwner);
                    updateToOwner.ObjectData[0].Data = data;

                    udp.SendPacket(obj.Prim.OwnerID, updateToOwner, PacketCategory.State);
                }

                // Send an update out to everyone else
                ObjectUpdateCompressedPacket updateToOthers = new ObjectUpdateCompressedPacket();
                updateToOthers.RegionData.RegionHandle = regionHandle;
                updateToOthers.RegionData.TimeDilation = UInt16.MaxValue;
                updateToOthers.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[1];
                updateToOthers.ObjectData[0] = new ObjectUpdateCompressedPacket.ObjectDataBlock();
                updateToOthers.ObjectData[0].UpdateFlags = (uint)obj.Prim.Flags;
                updateToOthers.ObjectData[0].Data = data;

                ForEachAgent(
                    delegate(Agent recipient)
                    {
                        if (recipient.ID != obj.Prim.OwnerID)
                            udp.SendPacket(recipient.ID, updateToOthers, PacketCategory.State);
                    }
                );

                #endregion Packet sending

                #endregion ObjectUpdateCompressed
            }
            else
            {
                #region ImprovedTerseObjectUpdate

                //Logger.DebugLog("Sending ImprovedTerseObjectUpdate");

                int pos = 0;
                byte[] data = new byte[(obj.Prim is Avatar ? 60 : 44)];

                // LocalID
                Utils.UIntToBytes(obj.Prim.LocalID, data, pos);
                pos += 4;
                // Avatar/CollisionPlane
                data[pos++] = obj.Prim.PrimData.State;
                if (obj.Prim is Avatar)
                {
                    data[pos++] = 1;
                    obj.Prim.CollisionPlane.ToBytes(data, pos);
                    pos += 16;
                }
                else
                {
                    ++pos;
                }
                // Position
                obj.Prim.Position.ToBytes(data, pos);
                pos += 12;

                // Velocity
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.Velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.Velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.Velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
                // Acceleration
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.Acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.Acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.Acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
                // Rotation
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.Rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.Rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.Rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.Rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
                // Angular Velocity
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.AngularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.AngularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
                Utils.UInt16ToBytes(Utils.FloatToUInt16(obj.Prim.AngularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;

                ImprovedTerseObjectUpdatePacket update = new ImprovedTerseObjectUpdatePacket();
                update.RegionData.RegionHandle = RegionHandle;
                update.RegionData.TimeDilation = (ushort)(timeDilation * (float)UInt16.MaxValue);
                update.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
                update.ObjectData[0] = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
                update.ObjectData[0].Data = data;

                if ((updateFlags & UpdateFlags.Textures) != 0)
                {
                    byte[] textureBytes = obj.Prim.Textures.GetBytes();
                    byte[] textureEntry = new byte[textureBytes.Length + 4];

                    // Texture Length
                    Utils.IntToBytes(textureBytes.Length, textureEntry, 0);
                    // Texture
                    Buffer.BlockCopy(textureBytes, 0, textureEntry, 4, textureBytes.Length);

                    update.ObjectData[0].TextureEntry = textureEntry;
                }
                else
                {
                    update.ObjectData[0].TextureEntry = Utils.EmptyBytes;
                }

                udp.BroadcastPacket(update, PacketCategory.State);

                #endregion ImprovedTerseObjectUpdate
            }
        }
Beispiel #34
0
        /// <summary>
        /// Sends a full update to the client
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="lPos"></param>
        /// <param name="clientFlags"></param>
        public void SendFullUpdateToClient(IClientAPI remoteClient, Vector3 lPos, uint clientFlags)
        {
            // Suppress full updates during attachment editing
            //
            if (ParentGroup.IsSelected && IsAttachment)
                return;
            
            if (ParentGroup.IsDeleted)
                return;

            clientFlags &= ~(uint) PrimFlags.CreateSelected;

            if (remoteClient.AgentId == _ownerID)
            {
                if ((uint) (_flags & PrimFlags.CreateSelected) != 0)
                {
                    clientFlags |= (uint) PrimFlags.CreateSelected;
                    _flags &= ~PrimFlags.CreateSelected;
                }
            }
            //bool isattachment = IsAttachment;
            //if (LocalId != ParentGroup.RootPart.LocalId)
                //isattachment = ParentGroup.RootPart.IsAttachment;

            byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
            remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, m_shape,
                                               lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID,
                                               m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment,
                                               AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient)));
        }
Beispiel #35
0
        public bool AgentAdd(object sender, Agent agent, PrimFlags creatorFlags)
        {
            // Sanity check, since this should have already been done
            agent.Avatar.Prim.ID = agent.Info.ID;

            // Check if the agent already exists in the scene
            lock (sceneAgents)
            {
                if (sceneAgents.ContainsKey(agent.ID))
                    sceneAgents.Remove(agent.ID);
            }

            // Update the current region handle
            agent.Avatar.Prim.RegionHandle = regionHandle;

            // Avatars always have physics
            agent.Avatar.Prim.Flags |= PrimFlags.Physics;

            // Default avatar values
            agent.Avatar.Prim.Position = new Vector3(128f, 128f, 25f);
            agent.Avatar.Prim.Rotation = Quaternion.Identity;
            agent.Avatar.Prim.Scale = new Vector3(0.45f, 0.6f, 1.9f);
            agent.Avatar.Prim.PrimData.Material = Material.Flesh;
            agent.Avatar.Prim.PrimData.PCode = PCode.Avatar;
            agent.Avatar.Prim.Textures = new Primitive.TextureEntry(new UUID("c228d1cf-4b5d-4ba8-84f4-899a0796aa97"));

            // Set the avatar name
            NameValue[] name = new NameValue[2];
            name[0] = new NameValue("FirstName", NameValue.ValueType.String, NameValue.ClassType.ReadWrite,
                NameValue.SendtoType.SimViewer, agent.Info.FirstName);
            name[1] = new NameValue("LastName", NameValue.ValueType.String, NameValue.ClassType.ReadWrite,
                NameValue.SendtoType.SimViewer, agent.Info.LastName);
            agent.Avatar.Prim.NameValues = name;

            // Give testers a provisionary balance of 1000L
            agent.Info.Balance = 1000;

            // Some default avatar prim properties
            agent.Avatar.Prim.Properties = new Primitive.ObjectProperties();
            agent.Avatar.Prim.Properties.CreationDate = Utils.UnixTimeToDateTime(agent.Info.CreationTime);
            agent.Avatar.Prim.Properties.Name = agent.FullName;
            agent.Avatar.Prim.Properties.ObjectID = agent.ID;

            if (agent.Avatar.Prim.LocalID == 0)
            {
                // Assign a unique LocalID to this agent
                agent.Avatar.Prim.LocalID = (uint)Interlocked.Increment(ref currentLocalID);
            }

            if (OnAgentAdd != null)
                OnAgentAdd(sender, agent, creatorFlags);

            // Add the agent to the scene dictionary
            lock (sceneAgents) sceneAgents[agent.ID] = agent;

            Logger.Log("Added agent " + agent.FullName + " to the scene", Helpers.LogLevel.Info);

            return true;
        }
Beispiel #36
0
 public void RemFlag(PrimFlags flag)
 {
     // PrimFlags prevflag = Flags;
     if ((ObjectFlags & (uint) flag) != 0)
     {
         //m_log.Debug("Removing flag: " + ((PrimFlags)flag).ToString());
         _flags &= ~flag;
         if ((flag & PrimFlags.Scripted) != 0)
             if(ParentGroup != null)
                 ParentGroup.RecalcScriptedStatus();
     }
     //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString());
     //ScheduleFullUpdate();
 }
Beispiel #37
0
 public void RemFlag(PrimFlags flag)
 {
     // PrimFlags prevflag = Flags;
     if ((Flags & flag) != 0)
     {
         //m_log.Debug("Removing flag: " + ((PrimFlags)flag).ToString());
         Flags &= ~flag;
     }
     //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString());
     //ScheduleFullUpdate();
 }
Beispiel #38
0
        public void DoAggregateScriptEvents()
        {
            AggregateScriptEvents = 0;

            // Aggregate script events
            lock (m_scriptEvents)
            {
                foreach (ScriptEvents s in m_scriptEvents.Values)
                {
                    AggregateScriptEvents |= s;
                }
            }

            uint objectflagupdate = 0;

            if (
                ((AggregateScriptEvents & ScriptEvents.touch) != 0) ||
                ((AggregateScriptEvents & ScriptEvents.touch_end) != 0) ||
                ((AggregateScriptEvents & ScriptEvents.touch_start) != 0)
                )
            {
                objectflagupdate |= (uint) PrimFlags.Touch;
            }

            if ((AggregateScriptEvents & ScriptEvents.money) != 0)
            {
                objectflagupdate |= (uint) PrimFlags.Money;
            }

            if (AllowedDrop)
            {
                objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
            }

            if (! CheckForScriptCollisionEventsAndSubscribe())
            {
                PhysicsActor physActor = PhysActor;
                if (physActor != null)
                {
                    physActor.UnSubscribeEvents();
                    physActor.OnCollisionUpdate -= PhysicsCollision;
                }
            }

            if (m_parentGroup == null)
            {
                ScheduleFullUpdate(PrimUpdateFlags.FindBest);
                return;
            }

            LocalFlags=(PrimFlags)objectflagupdate;

            if (m_parentGroup != null && m_parentGroup.RootPart == this)
                m_parentGroup.aggregateScriptEvents();
            else
                ScheduleFullUpdate(PrimUpdateFlags.FindBest);
        }
Beispiel #39
0
        public void aggregateScriptEvents()
        {
            AggregateScriptEvents = 0;

            // Aggregate script events
            lock (m_scriptEvents)
            {
                foreach (scriptEvents s in m_scriptEvents.Values)
                {
                    AggregateScriptEvents |= s;
                }
            }

            uint objectflagupdate = 0;

            if (
                ((AggregateScriptEvents & scriptEvents.touch) != 0) ||
                ((AggregateScriptEvents & scriptEvents.touch_end) != 0) ||
                ((AggregateScriptEvents & scriptEvents.touch_start) != 0)
                )
            {
                objectflagupdate |= (uint) PrimFlags.Touch;
            }

            if ((AggregateScriptEvents & scriptEvents.money) != 0)
            {
                objectflagupdate |= (uint) PrimFlags.Money;
            }

            if (AllowedDrop)
            {
                objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
            }

            if (
                ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
                ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
                ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
                (CollisionSound != UUID.Zero)
                )
            {
                // subscribe to physics updates.
                if (PhysActor != null)
                {
                    PhysActor.OnCollisionUpdate += PhysicsCollision;
                    PhysActor.SubscribeEvents(1000);

                }
            }
            else
            {
                if (PhysActor != null)
                {
                    PhysActor.UnSubscribeEvents();
                    PhysActor.OnCollisionUpdate -= PhysicsCollision;
                }
            }

            if (m_parentGroup == null)
            {
                ScheduleFullUpdate();
                return;
            }

            if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
            {
                m_parentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting;
            }
            else
            {
                m_parentGroup.Scene.EventManager.OnScriptTimerEvent -= handleTimerAccounting;
            }

            LocalFlags=(PrimFlags)objectflagupdate;

            if (m_parentGroup != null && m_parentGroup.RootPart == this)
                m_parentGroup.aggregateScriptEvents();
            else
                ScheduleFullUpdate();
        }
 public bool RemFlag(PrimFlags flag)
 {
     // PrimFlags prevflag = Flags;
     if ((Flags & flag) != 0)
     {
         //m_log.Debug("Removing flag: " + ((PrimFlags)flag).ToString());
         Flags &= ~flag;
         return true;
     }
     return false;
     //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString());
     //ScheduleFullUpdate();
 }
        void ObjectAddHandler(Packet packet, Agent agent)
        {
            ObjectAddPacket add = (ObjectAddPacket)packet;

            Vector3   position             = Vector3.Zero;
            Vector3   scale                = add.ObjectData.Scale;
            PCode     pcode                = (PCode)add.ObjectData.PCode;
            PrimFlags flags                = (PrimFlags)add.ObjectData.AddFlags;
            bool      bypassRaycast        = (add.ObjectData.BypassRaycast == 1);
            bool      rayEndIsIntersection = (add.ObjectData.RayEndIsIntersection == 1);

            #region Position Calculation

            if (rayEndIsIntersection)
            {
                // HACK: Blindly trust where the client tells us to place
                position = add.ObjectData.RayEnd;
            }
            else
            {
                if (add.ObjectData.RayTargetID != UUID.Zero)
                {
                    SimulationObject obj;
                    if (server.Scene.TryGetObject(add.ObjectData.RayTargetID, out obj))
                    {
                        // Test for a collision with the specified object
                        position = ObjectCollisionTest(add.ObjectData.RayStart, add.ObjectData.RayEnd, obj);
                    }
                }

                if (position == Vector3.Zero)
                {
                    // Test for a collision with the entire scene
                    position = FullSceneCollisionTest(add.ObjectData.RayStart, add.ObjectData.RayEnd);
                }
            }

            // Position lies on the face of another surface, either terrain of an object.
            // Back up along the ray so we are not colliding with the mesh.
            // HACK: This is really cheesy and should be done by a collision system
            Vector3 rayDir = Vector3.Normalize(add.ObjectData.RayEnd - add.ObjectData.RayStart);
            position -= rayDir * scale;

            #endregion Position Calculation

            #region Foliage Handling

            // Set all foliage to phantom
            if (pcode == PCode.Grass || pcode == PCode.Tree || pcode == PCode.NewTree)
            {
                flags |= PrimFlags.Phantom;

                if (pcode != PCode.Grass)
                {
                    // Resize based on the foliage type
                    Tree tree = (Tree)add.ObjectData.State;

                    switch (tree)
                    {
                    case Tree.Cypress1:
                    case Tree.Cypress2:
                        scale = new Vector3(4f, 4f, 10f);
                        break;

                    default:
                        scale = new Vector3(4f, 4f, 4f);
                        break;
                    }
                }
            }

            #endregion Foliage Handling

            // Create an object
            Primitive prim = new Primitive();
            prim.Flags =
                PrimFlags.ObjectModify |
                PrimFlags.ObjectCopy |
                PrimFlags.ObjectAnyOwner |
                PrimFlags.ObjectMove |
                PrimFlags.ObjectTransfer |
                PrimFlags.ObjectOwnerModify;
            // TODO: Security check
            prim.GroupID  = add.AgentData.GroupID;
            prim.ID       = UUID.Random();
            prim.MediaURL = String.Empty;
            prim.OwnerID  = agent.AgentID;
            prim.Position = position;

            prim.PrimData.Material         = (Material)add.ObjectData.Material;
            prim.PrimData.PathCurve        = (PathCurve)add.ObjectData.PathCurve;
            prim.PrimData.ProfileCurve     = (ProfileCurve)add.ObjectData.ProfileCurve;
            prim.PrimData.PathBegin        = Primitive.UnpackBeginCut(add.ObjectData.PathBegin);
            prim.PrimData.PathEnd          = Primitive.UnpackEndCut(add.ObjectData.PathEnd);
            prim.PrimData.PathScaleX       = Primitive.UnpackPathScale(add.ObjectData.PathScaleX);
            prim.PrimData.PathScaleY       = Primitive.UnpackPathScale(add.ObjectData.PathScaleY);
            prim.PrimData.PathShearX       = Primitive.UnpackPathShear((sbyte)add.ObjectData.PathShearX);
            prim.PrimData.PathShearY       = Primitive.UnpackPathShear((sbyte)add.ObjectData.PathShearY);
            prim.PrimData.PathTwist        = Primitive.UnpackPathTwist(add.ObjectData.PathTwist);
            prim.PrimData.PathTwistBegin   = Primitive.UnpackPathTwist(add.ObjectData.PathTwistBegin);
            prim.PrimData.PathRadiusOffset = Primitive.UnpackPathTwist(add.ObjectData.PathRadiusOffset);
            prim.PrimData.PathTaperX       = Primitive.UnpackPathTaper(add.ObjectData.PathTaperX);
            prim.PrimData.PathTaperY       = Primitive.UnpackPathTaper(add.ObjectData.PathTaperY);
            prim.PrimData.PathRevolutions  = Primitive.UnpackPathRevolutions(add.ObjectData.PathRevolutions);
            prim.PrimData.PathSkew         = Primitive.UnpackPathTwist(add.ObjectData.PathSkew);
            prim.PrimData.ProfileBegin     = Primitive.UnpackBeginCut(add.ObjectData.ProfileBegin);
            prim.PrimData.ProfileEnd       = Primitive.UnpackEndCut(add.ObjectData.ProfileEnd);
            prim.PrimData.ProfileHollow    = Primitive.UnpackProfileHollow(add.ObjectData.ProfileHollow);
            prim.PrimData.PCode            = pcode;

            prim.Properties.CreationDate = DateTime.Now;
            prim.Properties.CreatorID    = agent.AgentID;
            prim.Properties.Description  = String.Empty;
            prim.Properties.GroupID      = add.AgentData.GroupID;
            prim.Properties.LastOwnerID  = agent.AgentID;
            prim.Properties.Name         = "New Object";
            prim.Properties.ObjectID     = prim.ID;
            prim.Properties.OwnerID      = prim.OwnerID;
            prim.Properties.Permissions  = Permissions.FullPermissions;
            prim.Properties.SalePrice    = 10;

            prim.RegionHandle = server.RegionHandle;
            prim.Rotation     = add.ObjectData.Rotation;
            prim.Scale        = scale;
            prim.Textures     = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
            prim.TextColor    = Color4.Black;

            // Add this prim to the object database
            SimulationObject simObj = new SimulationObject(prim, server);
            server.Scene.ObjectAdd(this, agent, simObj, flags);
        }
Beispiel #42
0
        /// <summary>
        /// Create (rez) a new prim object in a simulator
        /// </summary>
        /// <param name="simulator">A reference to the <seealso cref="Simulator"/> object to place the object in</param>
        /// <param name="prim">Data describing the prim object to rez</param>
        /// <param name="groupID">Group ID that this prim will be set to, or UUID.Zero if you
        /// do not want the object to be associated with a specific group</param>
        /// <param name="position">An approximation of the position at which to rez the prim</param>
        /// <param name="scale">Scale vector to size this prim</param>
        /// <param name="rotation">Rotation quaternion to rotate this prim</param>
        /// <param name="createFlags">Specify the <seealso cref="PrimFlags"/></param>
        /// <remarks>Due to the way client prim rezzing is done on the server,
        /// the requested position for an object is only close to where the prim
        /// actually ends up. If you desire exact placement you'll need to 
        /// follow up by moving the object after it has been created. This
        /// function will not set textures, light and flexible data, or other 
        /// extended primitive properties</remarks>
        public void AddPrim(Simulator simulator, Primitive.ConstructionData prim, UUID groupID, Vector3 position,
            Vector3 scale, Quaternion rotation, PrimFlags createFlags)
        {
            ObjectAddPacket packet = new ObjectAddPacket();

            packet.AgentData.AgentID = Client.Self.AgentID;
            packet.AgentData.SessionID = Client.Self.SessionID;
            packet.AgentData.GroupID = groupID;

            packet.ObjectData.State = prim.State;
            packet.ObjectData.AddFlags = (uint)createFlags;
            packet.ObjectData.PCode = (byte)PCode.Prim;

            packet.ObjectData.Material = (byte)prim.Material;
            packet.ObjectData.Scale = scale;
            packet.ObjectData.Rotation = rotation;

            packet.ObjectData.PathCurve = (byte)prim.PathCurve;
            packet.ObjectData.PathBegin = Primitive.PackBeginCut(prim.PathBegin);
            packet.ObjectData.PathEnd = Primitive.PackEndCut(prim.PathEnd);
            packet.ObjectData.PathRadiusOffset = Primitive.PackPathTwist(prim.PathRadiusOffset);
            packet.ObjectData.PathRevolutions = Primitive.PackPathRevolutions(prim.PathRevolutions);
            packet.ObjectData.PathScaleX = Primitive.PackPathScale(prim.PathScaleX);
            packet.ObjectData.PathScaleY = Primitive.PackPathScale(prim.PathScaleY);
            packet.ObjectData.PathShearX = (byte)Primitive.PackPathShear(prim.PathShearX);
            packet.ObjectData.PathShearY = (byte)Primitive.PackPathShear(prim.PathShearY);
            packet.ObjectData.PathSkew = Primitive.PackPathTwist(prim.PathSkew);
            packet.ObjectData.PathTaperX = Primitive.PackPathTaper(prim.PathTaperX);
            packet.ObjectData.PathTaperY = Primitive.PackPathTaper(prim.PathTaperY);
            packet.ObjectData.PathTwist = Primitive.PackPathTwist(prim.PathTwist);
            packet.ObjectData.PathTwistBegin = Primitive.PackPathTwist(prim.PathTwistBegin);

            packet.ObjectData.ProfileCurve = prim.profileCurve;
            packet.ObjectData.ProfileBegin = Primitive.PackBeginCut(prim.ProfileBegin);
            packet.ObjectData.ProfileEnd = Primitive.PackEndCut(prim.ProfileEnd);
            packet.ObjectData.ProfileHollow = Primitive.PackProfileHollow(prim.ProfileHollow);

            packet.ObjectData.RayStart = position;
            packet.ObjectData.RayEnd = position;
            packet.ObjectData.RayEndIsIntersection = 0;
            packet.ObjectData.RayTargetID = UUID.Zero;
            packet.ObjectData.BypassRaycast = 1;

            Client.Network.SendPacket(packet, simulator);
        }
Beispiel #43
0
        private void SetSOPFlags(SceneObjectPart part, PrimFlags flags)
        {
            //Do not set part.Flags yet,
            //part.Flags = flags;
            // DebugLog.WarnFormat("[SYNC INFO PRIM] SetSOPFlags");

            bool UsePhysics = (flags & PrimFlags.Physics) != 0;
            bool IsTemporary = (flags & PrimFlags.TemporaryOnRez) != 0;
            //bool IsVolumeDetect = part.VolumeDetectActive;
            bool IsPhantom = (flags & PrimFlags.Phantom) != 0;

            if (part.ParentGroup != null)
            {
                //part.ParentGroup.UpdatePrimFlagsBySync(part.LocalId, UsePhysics, IsTemporary, IsPhantom, part.VolumeDetectActive);
                part.ParentGroup.UpdatePrimFlags(part.LocalId, UsePhysics, IsTemporary, IsPhantom, part.VolumeDetectActive);
                //part.UpdatePrimFlagsBySync(UsePhysics, IsTemporary, IsPhantom, part.VolumeDetectActive);
            }
            part.Flags = flags;
            //DSL part.aggregateScriptEventSubscriptions();
            part.ScheduleFullUpdate();
        }
Beispiel #44
0
        public void AddFlag(PrimFlags flag)
        {
            // PrimFlags prevflag = Flags;
            if ((Flags & flag) == 0)
            {
                //m_log.Debug("Adding flag: " + ((PrimFlags) flag).ToString());
                Flags |= flag;

                if (flag == PrimFlags.TemporaryOnRez)
                    ResetExpire();
            }
            // m_log.Debug("Aprev: " + prevflag.ToString() + " curr: " + Flags.ToString());
        }
Beispiel #45
0
 public void SetPrimFlags(Primitive UnPhantom, PrimFlags fs)
 {
     client.Objects.SetFlags(GetSimulator(UnPhantom),UnPhantom.LocalID, ((fs & PrimFlags.Physics) != 0), //
                             ((fs & PrimFlags.Temporary) != 0),
                             ((fs & PrimFlags.Phantom) != 0),
                             ((fs & PrimFlags.CastShadows) != 0));
 }
Beispiel #46
0
        public void aggregateScriptEvents()
        {
            AggregateScriptEvents = 0;

            // Aggregate script events
            lock (m_scriptEvents)
            {
                foreach (scriptEvents s in m_scriptEvents.Values)
                {
                    AggregateScriptEvents |= s;
                }
            }

            uint objectflagupdate = 0;

            if (
                ((AggregateScriptEvents & scriptEvents.touch) != 0) ||
                ((AggregateScriptEvents & scriptEvents.touch_end) != 0) ||
                ((AggregateScriptEvents & scriptEvents.touch_start) != 0)
                )
            {
                objectflagupdate |= (uint) PrimFlags.Touch;
            }

            if ((AggregateScriptEvents & scriptEvents.money) != 0)
            {
                objectflagupdate |= (uint) PrimFlags.Money;
            }

            if (AllowedDrop)
            {
                objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
            }

            if (
                ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
                ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
                ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
                ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
                ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
                ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
                (CollisionSound != UUID.Zero)
                )
            {
                // subscribe to physics updates.
                if (PhysActor != null)
                {
                    PhysActor.OnCollisionUpdate += PhysicsCollision;
                    PhysActor.SubscribeEvents(1000);
                }
            }
            else
            {
                if (PhysActor != null)
                {
                    PhysActor.UnSubscribeEvents();
                    PhysActor.OnCollisionUpdate -= PhysicsCollision;
                }
            }

            //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
            //{
            //    ParentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting;
            //}
            //else
            //{
            //    ParentGroup.Scene.EventManager.OnScriptTimerEvent -= handleTimerAccounting;
            //}

            LocalFlags = (PrimFlags)objectflagupdate;

            if (ParentGroup != null && ParentGroup.RootPart == this)
            {
                ParentGroup.aggregateScriptEvents();
            }
            else
            {
//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId);
                ScheduleFullUpdate();
            }
        }
Beispiel #47
0
        private void StartScript(UUID sourceItemID, UUID sourceAssetID, ISceneEntity hostObject, byte[] scriptBinary)
        {
            // Create a new AppDomain for this script
            AppDomainSetup domainSetup = new AppDomainSetup();

            domainSetup.LoaderOptimization = LoaderOptimization.SingleDomain;
            AppDomain scriptDomain = AppDomain.CreateDomain(sourceItemID + ".lsl", null, domainSetup);

            // Create an instance (that lives in this AppDomain) and a wrapper
            // (that lives in the script AppDomain) for this script
            LSLScriptInstance instance = new LSLScriptInstance(sourceItemID, sourceAssetID, hostObject, scriptDomain);
            LSLScriptWrapper  wrapper  = (LSLScriptWrapper)scriptDomain.CreateInstanceAndUnwrap(
                Assembly.GetExecutingAssembly().FullName, "Simian.Scripting.Linden.LSLScriptWrapper");

            wrapper.Init(scriptBinary, instance);
            instance.Init(wrapper);

            lock (m_syncRoot)
            {
                // If this script is already running, shut it down
                StopScript(sourceItemID, false);

                // Keep track of this script
                m_scripts[sourceItemID] = instance;

                // Keep track of the entity containing this script
                Dictionary <UUID, LSLScriptInstance> entityScripts;
                if (!m_scriptedEntities.TryGetValue(hostObject.ID, out entityScripts))
                {
                    entityScripts = new Dictionary <UUID, LSLScriptInstance>();
                    m_scriptedEntities[hostObject.ID] = entityScripts;
                }
                entityScripts[instance.ID] = instance;
            }

            if (hostObject is LLPrimitive)
            {
                // Update the PrimFlags for the containing LLPrimitive
                LLPrimitive obj = (LLPrimitive)hostObject;
                bool        hasCollisionEvents;

                PrimFlags     oldFlags   = obj.Prim.Flags;
                LSLEventFlags eventFlags = wrapper.GetEventsForState("default");

                PrimFlags newFlags = oldFlags;
                newFlags &= ~(PrimFlags.Touch | PrimFlags.Money);
                newFlags |= PrimFlags.Scripted | LSLEventFlagsToPrimFlags(eventFlags, out hasCollisionEvents);

                // FIXME: Do something with hasCollisionEvents

                // Either update the PrimFlags for this prim or just schedule
                // it for serialization (since it has a new script)
                if (newFlags != oldFlags)
                {
                    obj.Prim.Flags = newFlags;
                    m_scene.EntityAddOrUpdate(this, obj, 0, (uint)LLUpdateFlags.PrimFlags);
                }
                else
                {
                    m_scene.EntityAddOrUpdate(this, obj, UpdateFlags.Serialize, 0);
                }
            }

            // Fire the state_entry event to get this script started
            PostScriptEvent(new EventParams(sourceItemID, "state_entry", new object[0], new DetectParams[0]));
        }