Unpack() public method

Unpack and OSDMap and initialize the appearance from it
public Unpack ( OSDMap data ) : void
data OSDMap
return void
示例#1
0
        public void osNpcLoadAppearance(LSL_Key npc, string notecard)
        {
            CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance");
            m_host.AddScriptLPS(1);

            INPCModule npcModule = World.RequestModuleInterface<INPCModule>();

            if (npcModule != null)
            {
                UUID npcId;
                if (!UUID.TryParse(npc.m_string, out npcId))
                    return;

                if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
                    return;

                string appearanceSerialized = LoadNotecard(notecard);

                if (appearanceSerialized == null)
                    OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));

                OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
//                OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
//                Console.WriteLine("appearanceSerialized {0}", appearanceSerialized);
//                Console.WriteLine("a.Type {0}, a.ToString() {1}", a.Type, a);
                AvatarAppearance appearance = new AvatarAppearance();
                appearance.Unpack(appearanceOsd);

                npcModule.SetNPCAppearance(npcId, appearance, m_host.ParentGroup.Scene);
            }
        }
示例#2
0
        /// <summary>
        /// Unpack agent circuit data map into an AgentCiruitData object
        /// </summary>
        /// <param name="args"></param>
        public virtual void UnpackAgentCircuitData (OSDMap args)
        {
            if (args["agent_id"] != null)
                AgentID = args["agent_id"].AsUUID();
            if (args["caps_path"] != null)
                CapsPath = args["caps_path"].AsString();
            if (args["reallyischild"] != null)
                reallyischild = args["reallyischild"].AsBoolean ();
            if (args["child"] != null)
                child = args["child"].AsBoolean();
            if (args["circuit_code"] != null)
                UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
            if (args["secure_session_id"] != null)
                SecureSessionID = args["secure_session_id"].AsUUID();
            if (args["session_id"] != null)
                SessionID = args["session_id"].AsUUID();
            if (args["service_session_id"] != null)
                ServiceSessionID = args["service_session_id"].AsString ();
            if (args["client_ip"] != null)
                IPAddress = args["client_ip"].AsString ();
            if (args["first_name"] != null)
                firstname = args["first_name"].AsString ();
            if (args["last_name"] != null)
                lastname = args["last_name"].AsString ();

            if (args["start_pos"] != null)
                Vector3.TryParse(args["start_pos"].AsString(), out startpos);

            if (args["teleport_flags"] != null)
                teleportFlags = args["teleport_flags"].AsUInteger();

            // DEBUG ON
            //m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}", AgentID, child, startpos.ToString());
            // DEBUG OFF

            try
            {
                // Unpack various appearance elements
                Appearance = new AvatarAppearance(AgentID);

                // Eventually this code should be deprecated, use full appearance
                // packing in packed_appearance
                if (args["appearance_serial"] != null)
                    Appearance.Serial = args["appearance_serial"].AsInteger();

                if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
                {
                    Appearance.Unpack((OSDMap)args["packed_appearance"]);
                    // DEBUG ON
                    //m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
                    // DEBUG OFF
                }
                // DEBUG ON
                else
                    m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
                // DEBUG OFF
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}", e.ToString());
            }

            if (args.ContainsKey("otherInfo"))
                OtherInformation = (OSDMap)OSDParser.DeserializeLLSDXml(args["otherInfo"].AsString());

            ServiceURLs = new Dictionary<string, object> ();
            // Try parse the new way, OSDMap
            if (args.ContainsKey ("serviceurls") && args["serviceurls"] != null && (args["serviceurls"]).Type == OSDType.Map)
            {
                OSDMap urls = (OSDMap)(args["serviceurls"]);
                foreach (KeyValuePair<String, OSD> kvp in urls)
                {
                    ServiceURLs[kvp.Key] = kvp.Value.AsString ();
                    //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]);

                }
            }
        }
示例#3
0
        /// <summary>
        /// Unpack agent circuit data map into an AgentCiruitData object
        /// </summary>
        /// <param name="args"></param>
        public void UnpackAgentCircuitData(OSDMap args)
        {
            if (args["agent_id"] != null)
            {
                AgentID = args["agent_id"].AsUUID();
            }
            if (args["base_folder"] != null)
            {
                BaseFolder = args["base_folder"].AsUUID();
            }
            if (args["caps_path"] != null)
            {
                CapsPath = args["caps_path"].AsString();
            }

            if ((args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array))
            {
                OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
                ChildrenCapSeeds = new Dictionary <ulong, string>();
                foreach (OSD o in childrenSeeds)
                {
                    if (o.Type == OSDType.Map)
                    {
                        ulong  handle = 0;
                        string seed   = "";
                        OSDMap pair   = (OSDMap)o;
                        if (pair["handle"] != null)
                        {
                            if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
                            {
                                continue;
                            }
                        }
                        if (pair["seed"] != null)
                        {
                            seed = pair["seed"].AsString();
                        }
                        if (!ChildrenCapSeeds.ContainsKey(handle))
                        {
                            ChildrenCapSeeds.Add(handle, seed);
                        }
                    }
                }
            }
            else
            {
                ChildrenCapSeeds = new Dictionary <ulong, string>();
            }

            if (args["child"] != null)
            {
                child = args["child"].AsBoolean();
            }
            if (args["circuit_code"] != null)
            {
                UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
            }
            if (args["first_name"] != null)
            {
                firstname = args["first_name"].AsString();
            }
            if (args["last_name"] != null)
            {
                lastname = args["last_name"].AsString();
            }
            if (args["inventory_folder"] != null)
            {
                InventoryFolder = args["inventory_folder"].AsUUID();
            }
            if (args["secure_session_id"] != null)
            {
                SecureSessionID = args["secure_session_id"].AsUUID();
            }
            if (args["session_id"] != null)
            {
                SessionID = args["session_id"].AsUUID();
            }
            if (args["service_session_id"] != null)
            {
                ServiceSessionID = args["service_session_id"].AsString();
            }
            if (args["client_ip"] != null)
            {
                IPAddress = args["client_ip"].AsString();
            }
            if (args["viewer"] != null)
            {
                Viewer = args["viewer"].AsString();
            }
            if (args["channel"] != null)
            {
                Channel = args["channel"].AsString();
            }
            if (args["mac"] != null)
            {
                Mac = args["mac"].AsString();
            }
            if (args["id0"] != null)
            {
                Id0 = args["id0"].AsString();
            }

            if (args["start_pos"] != null)
            {
                Vector3.TryParse(args["start_pos"].AsString(), out startpos);
            }

            //m_log.InfoFormat("[AGENTCIRCUITDATA]: agentid={0}, child={1}, startpos={2}", AgentID, child, startpos);

            try
            {
                // Unpack various appearance elements
                Appearance = new AvatarAppearance();

                // Eventually this code should be deprecated, use full appearance
                // packing in packed_appearance
                if (args["appearance_serial"] != null)
                {
                    Appearance.Serial = args["appearance_serial"].AsInteger();
                }

                if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
                {
                    Appearance.Unpack((OSDMap)args["packed_appearance"]);
                    //                    m_log.InfoFormat("[AGENTCIRCUITDATA] unpacked appearance");
                }
                else
                {
                    m_log.Warn("[AGENTCIRCUITDATA]: failed to find a valid packed_appearance");
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}", e.Message);
            }

            ServiceURLs = new Dictionary <string, object>();
            // Try parse the new way, OSDMap
            if (args.ContainsKey("serviceurls") && args["serviceurls"] != null && (args["serviceurls"]).Type == OSDType.Map)
            {
                OSDMap urls = (OSDMap)(args["serviceurls"]);
                foreach (KeyValuePair <String, OSD> kvp in urls)
                {
                    ServiceURLs[kvp.Key] = kvp.Value.AsString();
                    //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]);
                }
            }
            // else try the old way, OSDArray
            // OBSOLETE -- soon to be deleted
            else if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array)
            {
                OSDArray urls = (OSDArray)(args["service_urls"]);
                for (int i = 0; i < urls.Count / 2; i++)
                {
                    ServiceURLs[urls[i * 2].AsString()] = urls[(i * 2) + 1].AsString();
                    //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString());
                }
            }
        }
示例#4
0
        private LSL_Key NpcCreate(
            string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent, bool hostGroupID)
        {
            if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z)))
            {
                OSSLError("no permission to rez NPC at requested location");
                return new LSL_Key(UUID.Zero.ToString());
            }

            INPCModule module = World.RequestModuleInterface<INPCModule>();
            if(module == null)
            {
                OSSLError("NPC module not enabled");
                return new LSL_Key(UUID.Zero.ToString());
            }

            string groupTitle = String.Empty;
            UUID groupID = UUID.Zero;

            AvatarAppearance appearance = null;

            // check creation options
            NPCOptionsFlags createFlags = module.NPCOptionFlags;

            if((createFlags & NPCOptionsFlags.AllowNotOwned) == 0 && !owned)
            {
                OSSLError("Not owned NPCs disabled");
                owned = true; // we should get here...
            }

            if((createFlags & NPCOptionsFlags.AllowSenseAsAvatar) == 0 && senseAsAgent)
            {
                OSSLError("NPC allow sense as Avatar disabled");
                senseAsAgent = false;
            }

            if(hostGroupID && m_host.GroupID != UUID.Zero)
            {
                IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface<IGroupsModule>();
                if (groupsModule != null)
                {
                    GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID);
                    if (member == null)
                    {
                        OSSLError(string.Format("osNpcCreate: the object owner is not member of the object group"));
                        return new LSL_Key(UUID.Zero.ToString());
                    }

                    groupID = m_host.GroupID;

                    if((createFlags & NPCOptionsFlags.NoNPCGroup) != 0)
                    {
                        GroupRecord grprec = groupsModule.GetGroupRecord(m_host.GroupID);
                        if(grprec != null && grprec.GroupName != "")
                            groupTitle = grprec.GroupName;
                    }
                }
            }

            if((createFlags & NPCOptionsFlags.NoNPCGroup) == 0)
            {
                if (firstname != String.Empty || lastname != String.Empty)
                {
                    if (firstname != "Shown outfit:")
                        groupTitle = "- NPC -";
                }
            }
               
            if((createFlags & NPCOptionsFlags.AllowCloneOtherAvatars) != 0)
            {
                UUID id;
                if (UUID.TryParse(notecard, out id))
                {
                    ScenePresence clonePresence = World.GetScenePresence(id);
                    if (clonePresence != null)
                        appearance = clonePresence.Appearance;
                }
            }

            if (appearance == null)
            {
                string appearanceSerialized = LoadNotecard(notecard);

                if (appearanceSerialized != null)
                {
                    try
                    {
                        OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
                        appearance = new AvatarAppearance();
                        appearance.Unpack(appearanceOsd);
                    }
                    catch
                    {
                        OSSLError(string.Format("osNpcCreate: Error processing notcard '{0}'", notecard));
                        return new LSL_Key(UUID.Zero.ToString());
                    }
                }
            else
                {
                    OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
                }
            }

            UUID ownerID = UUID.Zero;
            if (owned)
                ownerID = m_host.OwnerID;
            UUID x = module.CreateNPC(firstname,
                                      lastname,
                                      position,
                                      UUID.Random(),
                                      ownerID,
                                      groupTitle,
                                      groupID,
                                      senseAsAgent,
                                      World,
                                      appearance);

            ScenePresence sp;
            if (World.TryGetScenePresence(x, out sp))
            {
                sp.SendAvatarDataToAllAgents();
            }
            return new LSL_Key(x.ToString());
        }
示例#5
0
        private LSL_Key NpcCreate(
            string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent)
        {
            INPCModule module = World.RequestModuleInterface<INPCModule>();
            if (module != null)
            {
                AvatarAppearance appearance = null;

                UUID id;
                if (UUID.TryParse(notecard, out id))
                {
                    ScenePresence clonePresence = World.GetScenePresence(id);
                    if (clonePresence != null)
                        appearance = clonePresence.Appearance;
                }

                if (appearance == null)
                {
                    string appearanceSerialized = LoadNotecard(notecard);

                    if (appearanceSerialized != null)
                    {
                        OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
                        appearance = new AvatarAppearance();
                        appearance.Unpack(appearanceOsd);
                    }
                }

                if (appearance == null)
                    return new LSL_Key(UUID.Zero.ToString());

                UUID ownerID = UUID.Zero;
                if (owned)
                    ownerID = m_host.OwnerID;
                UUID x = module.CreateNPC(firstname,
                                          lastname,
                                          position,
                                          ownerID,
                                          senseAsAgent,
                                          World,
                                          appearance);

                return new LSL_Key(x.ToString());
            }

            return new LSL_Key(UUID.Zero.ToString());
        }
示例#6
0
        /// <summary>
        /// Unpack agent circuit data map into an AgentCiruitData object
        /// </summary>
        /// <param name="args"></param>
        public void UnpackAgentCircuitData(OSDMap args)
        {
            if (args["agent_id"] != null)
                AgentID = args["agent_id"].AsUUID();
            if (args["base_folder"] != null)
                BaseFolder = args["base_folder"].AsUUID();
            if (args["caps_path"] != null)
                CapsPath = args["caps_path"].AsString();

            if ((args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array))
            {
                OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
                ChildrenCapSeeds = new Dictionary<ulong, string>();
                foreach (OSD o in childrenSeeds)
                {
                    if (o.Type == OSDType.Map)
                    {
                        ulong handle = 0;
                        string seed = "";
                        OSDMap pair = (OSDMap)o;
                        if (pair["handle"] != null)
                            if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
                                continue;
                        if (pair["seed"] != null)
                            seed = pair["seed"].AsString();
                        if (!ChildrenCapSeeds.ContainsKey(handle))
                            ChildrenCapSeeds.Add(handle, seed);
                    }
                }
            }
            else
                ChildrenCapSeeds = new Dictionary<ulong, string>();

            if (args["child"] != null)
                child = args["child"].AsBoolean();
            if (args["circuit_code"] != null)
                UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
            if (args["first_name"] != null)
                firstname = args["first_name"].AsString();
            if (args["last_name"] != null)
                lastname = args["last_name"].AsString();
            if (args["inventory_folder"] != null)
                InventoryFolder = args["inventory_folder"].AsUUID();
            if (args["secure_session_id"] != null)
                SecureSessionID = args["secure_session_id"].AsUUID();
            if (args["session_id"] != null)
                SessionID = args["session_id"].AsUUID();
            if (args["service_session_id"] != null)
                ServiceSessionID = args["service_session_id"].AsString();
            if (args["client_ip"] != null)
                IPAddress = args["client_ip"].AsString();
            if (args["viewer"] != null)
                Viewer = args["viewer"].AsString();
            if (args["channel"] != null)
                Channel = args["channel"].AsString();
            if (args["mac"] != null)
                Mac = args["mac"].AsString();
            if (args["id0"] != null)
                Id0 = args["id0"].AsString();

            if (args["start_pos"] != null)
                Vector3.TryParse(args["start_pos"].AsString(), out startpos);

            // DEBUG ON
            //m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}", AgentID, child, startpos.ToString());
            // DEBUG OFF

            try
            {
                // Unpack various appearance elements
                Appearance = new AvatarAppearance(AgentID);

                // Eventually this code should be deprecated, use full appearance
                // packing in packed_appearance
                if (args["appearance_serial"] != null)
                    Appearance.Serial = args["appearance_serial"].AsInteger();

                if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
                {
                    Appearance.Unpack((OSDMap)args["packed_appearance"]);
                    // DEBUG ON
                    //m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
                    // DEBUG OFF
                }
                // DEBUG ON
                else
                    m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
                // DEBUG OFF
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}", e.Message);
            }

            ServiceURLs = new Dictionary<string, object>();
            if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array)
            {
                OSDArray urls = (OSDArray)(args["service_urls"]);
                for (int i = 0; i < urls.Count / 2; i++)
                {
                    ServiceURLs[urls[i * 2].AsString()] = urls[(i * 2) + 1].AsString();
                    //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString());

                }
            }
        }
示例#7
0
        /// <summary>
        /// Unpack agent circuit data map into an AgentCiruitData object
        /// </summary>
        /// <param name="args"></param>
        public virtual void UnpackAgentCircuitData (OSDMap args)
        {
            if (args["agent_id"] != null)
                AgentID = args["agent_id"].AsUUID();
            if (args["caps_path"] != null)
                CapsPath = args["caps_path"].AsString();

            if (args["child"] != null)
                child = args["child"].AsBoolean();
            if (args["circuit_code"] != null)
                UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
            if (args["secure_session_id"] != null)
                SecureSessionID = args["secure_session_id"].AsUUID();
            if (args["session_id"] != null)
                SessionID = args["session_id"].AsUUID();
            if (args["service_session_id"] != null)
                ServiceSessionID = args["service_session_id"].AsString();
            if (args["client_ip"] != null)
                IPAddress = args["client_ip"].AsString();

            if (args["start_pos"] != null)
                Vector3.TryParse(args["start_pos"].AsString(), out startpos);

            if (args["teleport_flags"] != null)
                teleportFlags = args["teleport_flags"].AsUInteger();

            // DEBUG ON
            //m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}", AgentID, child, startpos.ToString());
            // DEBUG OFF

            try
            {
                // Unpack various appearance elements
                Appearance = new AvatarAppearance(AgentID);

                // Eventually this code should be deprecated, use full appearance
                // packing in packed_appearance
                if (args["appearance_serial"] != null)
                    Appearance.Serial = args["appearance_serial"].AsInteger();

                if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
                {
                    Appearance.Unpack((OSDMap)args["packed_appearance"]);
                    // DEBUG ON
                    //m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
                    // DEBUG OFF
                }
                // DEBUG ON
                else
                    m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
                // DEBUG OFF
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}", e.ToString());
            }

            if (args.ContainsKey("otherInfo"))
                OtherInformation = (OSDMap)OSDParser.DeserializeLLSDXml(args["otherInfo"].AsString());
        }
        public void TestOsOwnerSaveAppearance()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            UUID userId = TestHelpers.ParseTail(0x1);
            float newHeight = 1.9f;

            ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
            sp.Appearance.AvatarHeight = newHeight;
            SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
            SceneObjectPart part = so.RootPart;
            m_scene.AddSceneObject(so);

            OSSL_Api osslApi = new OSSL_Api();
            osslApi.Initialize(m_engine, part, null, null);

            string notecardName = "appearanceNc";

            osslApi.osOwnerSaveAppearance(notecardName);

            IList<TaskInventoryItem> items = part.Inventory.GetInventoryItems(notecardName);
            Assert.That(items.Count, Is.EqualTo(1));

            TaskInventoryItem ncItem = items[0];
            Assert.That(ncItem.Name, Is.EqualTo(notecardName));

            AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString());
            Assert.That(ncAsset, Is.Not.Null);

            AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data);
            anc.Decode();
            OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText);
            AvatarAppearance savedAppearance = new AvatarAppearance();
            savedAppearance.Unpack(appearanceOsd);

            Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight));
        }
 private AvatarAppearance ConvertXMLToAvatarAppearance(OSDMap map, out string FolderNameToPlaceAppearanceIn)
 {
     AvatarAppearance appearance = new AvatarAppearance();
     appearance.Unpack(map);
     FolderNameToPlaceAppearanceIn = map["FolderName"].AsString();
     return appearance;
 }
示例#10
0
        /// <summary>
        /// Unpack agent circuit data map into an AgentCiruitData object
        /// </summary>
        /// <param name="args"></param>
        public void UnpackAgentCircuitData(OSDMap args)
        {
            OSD tmpOSD;

            if (args.TryGetValue("agent_id", out tmpOSD))
            {
                AgentID = tmpOSD.AsUUID();
            }
            if (args.TryGetValue("base_folder", out tmpOSD))
            {
                BaseFolder = tmpOSD.AsUUID();
            }
            if (args.TryGetValue("caps_path", out tmpOSD))
            {
                CapsPath = tmpOSD.AsString();
            }

            if ((args.TryGetValue("children_seeds", out tmpOSD) && tmpOSD is OSDArray))
            {
                OSDArray childrenSeeds = (OSDArray)tmpOSD;
                ChildrenCapSeeds = new Dictionary <ulong, string>();
                foreach (OSD o in childrenSeeds)
                {
                    if (o.Type == OSDType.Map)
                    {
                        ulong  handle = 0;
                        string seed   = "";
                        OSDMap pair   = (OSDMap)o;
                        if (pair.TryGetValue("handle", out tmpOSD))
                        {
                            if (!UInt64.TryParse(tmpOSD.AsString(), out handle))
                            {
                                continue;
                            }
                        }
                        if (!ChildrenCapSeeds.ContainsKey(handle))
                        {
                            if (pair.TryGetValue("seed", out tmpOSD))
                            {
                                seed = tmpOSD.AsString();
                                ChildrenCapSeeds.Add(handle, seed);
                            }
                        }
                    }
                }
            }
            else
            {
                ChildrenCapSeeds = new Dictionary <ulong, string>();
            }

            if (args.TryGetValue("child", out tmpOSD))
            {
                child = tmpOSD.AsBoolean();
            }
            if (args.TryGetValue("circuit_code", out tmpOSD))
            {
                UInt32.TryParse(tmpOSD.AsString(), out circuitcode);
            }
            if (args.TryGetValue("first_name", out tmpOSD))
            {
                firstname = tmpOSD.AsString();
            }
            if (args.TryGetValue("last_name", out tmpOSD))
            {
                lastname = tmpOSD.AsString();
            }
            if (args.TryGetValue("display_name", out tmpOSD))
            {
                hasDisplayName = true;
                displayname    = tmpOSD.AsString();
            }
            if (args.TryGetValue("inventory_folder", out tmpOSD))
            {
                InventoryFolder = tmpOSD.AsUUID();
            }
            if (args.TryGetValue("secure_session_id", out tmpOSD))
            {
                SecureSessionID = tmpOSD.AsUUID();
            }
            if (args.TryGetValue("session_id", out tmpOSD))
            {
                SessionID = tmpOSD.AsUUID();
            }
            if (args.TryGetValue("service_session_id", out tmpOSD))
            {
                ServiceSessionID = tmpOSD.AsString();
            }
            if (args.TryGetValue("client_ip", out tmpOSD))
            {
                IPAddress = tmpOSD.AsString();
            }
            if (args.TryGetValue("viewer", out tmpOSD))
            {
                Viewer = tmpOSD.AsString();
            }
            if (args.TryGetValue("channel", out tmpOSD))
            {
                Channel = tmpOSD.AsString();
            }
            if (args.TryGetValue("mac", out tmpOSD))
            {
                Mac = tmpOSD.AsString();
            }
            if (args.TryGetValue("id0", out tmpOSD))
            {
                Id0 = tmpOSD.AsString();
            }
            if (args.TryGetValue("teleport_flags", out tmpOSD))
            {
                teleportFlags = tmpOSD.AsUInteger();
            }

            if (args.TryGetValue("start_pos", out tmpOSD))
            {
                Vector3.TryParse(tmpOSD.AsString(), out startpos);
            }

            if (args.TryGetValue("far", out tmpOSD))
            {
                startfar = (float)tmpOSD.AsReal();
            }

            //m_log.InfoFormat("[AGENTCIRCUITDATA]: agentid={0}, child={1}, startpos={2}", AgentID, child, startpos);

            try
            {
                // Unpack various appearance elements
                Appearance = new AvatarAppearance();

                // Eventually this code should be deprecated, use full appearance
                // packing in packed_appearance
                if (args.TryGetValue("appearance_serial", out tmpOSD))
                {
                    Appearance.Serial = tmpOSD.AsInteger();
                }

                if (args.TryGetValue("packed_appearance", out tmpOSD) && (tmpOSD is OSDMap))
                {
                    Appearance.Unpack((OSDMap)tmpOSD);
                    //                    m_log.InfoFormat("[AGENTCIRCUITDATA] unpacked appearance");
                }
                else
                {
                    m_log.Warn("[AGENTCIRCUITDATA]: failed to find a valid packed_appearance");
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}", e.Message);
            }

            ServiceURLs = new Dictionary <string, object>();
            // Try parse the new way, OSDMap
            if (args.TryGetValue("serviceurls", out tmpOSD) && (tmpOSD is OSDMap))
            {
                OSDMap urls = (OSDMap)tmpOSD;
                foreach (KeyValuePair <String, OSD> kvp in urls)
                {
                    ServiceURLs[kvp.Key] = kvp.Value;
                    //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]);
                }
            }
            // else try the old way, OSDArray
            // OBSOLETE -- soon to be deleted
            else if (args.TryGetValue("service_urls", out tmpOSD) && (tmpOSD is OSDArray))
            {
                OSDArray urls = (OSDArray)tmpOSD;
                OSD      tmpOSDb;
                for (int i = 0; i < urls.Count - 1; i += 2)
                {
                    tmpOSD  = urls[i];
                    tmpOSDb = urls[i + 1];
                    ServiceURLs[tmpOSD.AsString()] = tmpOSDb.AsString();
                    //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString());
                }
            }
        }
示例#11
0
        /// <summary>
        /// Unpack agent circuit data map into an AgentCiruitData object
        /// </summary>
        /// <param name="args"></param>
        public void UnpackAgentCircuitData(OSDMap args)
        {
            if (args["agent_id"] != null)
            {
                AgentID = args["agent_id"].AsUUID();
            }
            if (args["caps_path"] != null)
            {
                CapsPath = args["caps_path"].AsString();
            }

            if (args["child"] != null)
            {
                child = args["child"].AsBoolean();
            }
            if (args["circuit_code"] != null)
            {
                UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
            }
            if (args["secure_session_id"] != null)
            {
                SecureSessionID = args["secure_session_id"].AsUUID();
            }
            if (args["session_id"] != null)
            {
                SessionID = args["session_id"].AsUUID();
            }
            if (args["service_session_id"] != null)
            {
                ServiceSessionID = args["service_session_id"].AsString();
            }
            if (args["client_ip"] != null)
            {
                IPAddress = args["client_ip"].AsString();
            }

            if (args["start_pos"] != null)
            {
                Vector3.TryParse(args["start_pos"].AsString(), out startpos);
            }

            if (args["teleport_flags"] != null)
            {
                teleportFlags = args["teleport_flags"].AsUInteger();
            }

            // DEBUG ON
            //m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}", AgentID, child, startpos.ToString());
            // DEBUG OFF

            try
            {
                // Unpack various appearance elements
                Appearance = new AvatarAppearance(AgentID);

                // Eventually this code should be deprecated, use full appearance
                // packing in packed_appearance
                if (args["appearance_serial"] != null)
                {
                    Appearance.Serial = args["appearance_serial"].AsInteger();
                }

                if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
                {
                    Appearance.Unpack((OSDMap)args["packed_appearance"]);
                    // DEBUG ON
                    //m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
                    // DEBUG OFF
                }
                // DEBUG ON
                else
                {
                    m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
                }
                // DEBUG OFF
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}", e.ToString());
            }

            if (args.ContainsKey("otherInfo"))
            {
                OtherInformation = (OSDMap)OSDParser.DeserializeLLSDXml(args["otherInfo"].AsString());
            }
        }
示例#12
0
        /// <summary>
        /// Unpack agent circuit data map into an AgentCiruitData object
        /// </summary>
        /// <param name="args"></param>
        public void UnpackAgentCircuitData(OSDMap args)
        {
            if (args["agent_id"] != null)
                AgentID = args["agent_id"].AsUUID();
            if (args["caps_path"] != null)
                CapsPath = args["caps_path"].AsString();

            if (args["child"] != null)
                child = args["child"].AsBoolean();
            if (args["circuit_code"] != null)
                UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
            if (args["secure_session_id"] != null)
                SecureSessionID = args["secure_session_id"].AsUUID();
            if (args["session_id"] != null)
                SessionID = args["session_id"].AsUUID();
            if (args["service_session_id"] != null)
                ServiceSessionID = args["service_session_id"].AsString();
            if (args["client_ip"] != null)
                IPAddress = args["client_ip"].AsString();

            if (args["start_pos"] != null)
                Vector3.TryParse(args["start_pos"].AsString(), out startpos);

            // DEBUG ON
            //m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}", AgentID, child, startpos.ToString());
            // DEBUG OFF

            try
            {
                // Unpack various appearance elements
                Appearance = new AvatarAppearance(AgentID);

                // Eventually this code should be deprecated, use full appearance
                // packing in packed_appearance
                if (args["appearance_serial"] != null)
                    Appearance.Serial = args["appearance_serial"].AsInteger();

                if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
                {
                    Appearance.Unpack((OSDMap)args["packed_appearance"]);
                    // DEBUG ON
                    //m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
                    // DEBUG OFF
                }
                // DEBUG ON
                else
                    m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
                // DEBUG OFF
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}", e.ToString());
            }

            if (args.ContainsKey("otherInfo"))
                OtherInformation = (OSDMap)OSDParser.DeserializeLLSDXml(args["otherInfo"].AsString());

            ServiceURLs = new Dictionary<string, object>();
            if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array)
            {
                OSDArray urls = (OSDArray)(args["service_urls"]);
                for (int i = 0; i < urls.Count / 2; i++)
                {
                    ServiceURLs[urls[i * 2].AsString()] = urls[(i * 2) + 1].AsString();
                    //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString());

                }
            }
        }
示例#13
0
        private LSL_Key NpcCreate(
            string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent)
        {

            if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z)))
                return new LSL_Key(UUID.Zero.ToString());

            INPCModule module = World.RequestModuleInterface<INPCModule>();
            if (module != null)
            {
                string groupTitle = String.Empty;
                AvatarAppearance appearance = null;

                // check creation options
                NPCOptionsFlags createFlags = module.NPCOptionFlags;

                if((createFlags & NPCOptionsFlags.AllowNotOwned) == 0 && !owned)
                {
                    OSSLError("Not owned NPCs disabled");
                    owned = true; // we should get here...
                }

                if((createFlags & NPCOptionsFlags.AllowSenseAsAvatar) == 0 && senseAsAgent)
                {
                    OSSLError("NPC allow sense as Avatar disabled");
                    senseAsAgent = false;
                }

                if((createFlags & NPCOptionsFlags.NoNPCGroup) == 0)
                {
                    if (firstname != String.Empty || lastname != String.Empty)
                        {
                            if (firstname != "Shown outfit:")
                                groupTitle = "- NPC -";
                        }
                }
               
                if((createFlags & NPCOptionsFlags.AllowCloneOtherAvatars) != 0)
                {
                    UUID id;
                    if (UUID.TryParse(notecard, out id))
                    {
                        ScenePresence clonePresence = World.GetScenePresence(id);
                        if (clonePresence != null)
                            appearance = clonePresence.Appearance;
                    }
                }

                if (appearance == null)
                {
                    string appearanceSerialized = LoadNotecard(notecard);

                    if (appearanceSerialized != null)
                    {
                        try
                        {
                            OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
                            appearance = new AvatarAppearance();
                            appearance.Unpack(appearanceOsd);
                        }
                        catch
                        {
                            return UUID.Zero.ToString();
                        }
                    }
                    else
                    {
                        OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
                    }
                }

                UUID ownerID = UUID.Zero;
                if (owned)
                    ownerID = m_host.OwnerID;
                UUID x = module.CreateNPC(firstname,
                                          lastname,
                                          position,
                                          ownerID,
                                          senseAsAgent,
                                          World,
                                          appearance);

                ScenePresence sp;
                if (World.TryGetScenePresence(x, out sp))
                {
                    sp.Grouptitle = groupTitle;
                    sp.SendAvatarDataToAllAgents();
                }
                return new LSL_Key(x.ToString());
            }

            return new LSL_Key(UUID.Zero.ToString());
        }
示例#14
0
        public void osNpcLoadAppearance(LSL_Key npc, string notecard)
        {
            CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance");

            INPCModule npcModule = World.RequestModuleInterface<INPCModule>();

            if (npcModule != null)
            {
                UUID npcId;
                if (!UUID.TryParse(npc.m_string, out npcId))
                    return;

                string appearanceSerialized = LoadNotecard(notecard);
                OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
//                OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
//                Console.WriteLine("appearanceSerialized {0}", appearanceSerialized);
//                Console.WriteLine("a.Type {0}, a.ToString() {1}", a.Type, a);
                AvatarAppearance appearance = new AvatarAppearance();
                appearance.Unpack(appearanceOsd);

                npcModule.SetNPCAppearance(npcId, appearance, m_host.ParentGroup.Scene);
            }
        }
示例#15
0
        public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard)
        {
            CheckThreatLevel(ThreatLevel.High, "osNpcCreate");

            INPCModule module = World.RequestModuleInterface<INPCModule>();
            if (module != null)
            {
                AvatarAppearance appearance = null;

                UUID id;
                if (UUID.TryParse(notecard, out id))
                {
                    ScenePresence clonePresence = World.GetScenePresence(id);
                    if (clonePresence != null)
                        appearance = clonePresence.Appearance;
                }

                if (appearance == null)
                {
                    string appearanceSerialized = LoadNotecard(notecard);

                    if (appearanceSerialized != null)
                    {
                        OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
                        appearance = new AvatarAppearance();
                        appearance.Unpack(appearanceOsd);
                    }
                }

                if (appearance == null)
                    return new LSL_Key(UUID.Zero.ToString());

                UUID x = module.CreateNPC(firstname,
                                          lastname,
                                          new Vector3((float) position.x, (float) position.y, (float) position.z),
                                          World,
                                          appearance);

                return new LSL_Key(x.ToString());
            }

            return new LSL_Key(UUID.Zero.ToString());
        }