Exemple #1
0
 public LSL_Float llListStatistics(int operation, LSL_List src)
 {
     m_host.AddScriptLPS(1);
     LSL_List nums = LSL_List.ToDoubleList(src);
     switch (operation)
     {
         case ScriptBaseClass.LIST_STAT_RANGE:
             return nums.Range();
         case ScriptBaseClass.LIST_STAT_MIN:
             return nums.Min();
         case ScriptBaseClass.LIST_STAT_MAX:
             return nums.Max();
         case ScriptBaseClass.LIST_STAT_MEAN:
             return nums.Mean();
         case ScriptBaseClass.LIST_STAT_MEDIAN:
             return nums.Median();
         case ScriptBaseClass.LIST_STAT_NUM_COUNT:
             return nums.NumericLength();
         case ScriptBaseClass.LIST_STAT_STD_DEV:
             return nums.StdDev();
         case ScriptBaseClass.LIST_STAT_SUM:
             return nums.Sum();
         case ScriptBaseClass.LIST_STAT_SUM_SQUARES:
             return nums.SumSqrs();
         case ScriptBaseClass.LIST_STAT_GEOMETRIC_MEAN:
             return nums.GeometricMean();
         case ScriptBaseClass.LIST_STAT_HARMONIC_MEAN:
             return nums.HarmonicMean();
         default:
             return 0.0;
     }
 }
        public int tsuccirEvenlyDistributeChildPrimsInOtherObject(UUID host, UUID script, string otherObject, object[] argsObj)
        {
            SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host);
            hostPart.AddScriptLPS(1);

            LSL_List args = new LSL_List();
            args.Data = argsObj;
            LSL_Vector size;
            LSL_Vector point;
            LSL_Rotation rot;
            LSL_Vector distribution;
            LSL_Vector margin;
            try
            {
                size = args.GetVector3Item(0);
                point = args.GetVector3Item(1);
                rot = args.GetQuaternionItem(2);
                distribution = args.GetVector3Item(3);
                margin = args.GetVector3Item(4);
            }
            catch (Exception e)
            {
                ScriptError(hostPart, e.Message);
                return 0;
            }

            UUID otherObjectKey;
            if (!UUID.TryParse(otherObject, out otherObjectKey))
            {
                ScriptError(hostPart, "Other object key is not a valid UUID");
                return 0;
            }

            SceneObjectPart other = hostPart.ParentGroup.Scene.GetSceneObjectPart(otherObjectKey);
            if (other == null)
            {
                ScriptError(hostPart, "Other object could not be found");
                return 0;
            }

            return EvenlyDistributeChildPrims(other.ParentGroup, size, point, rot, distribution, margin) ? 1 : 0;
        }
Exemple #3
0
        public void llParcelMediaCommandList(LSL_List commandList)
        {
            // TODO: Not implemented yet (missing in libomv?):
            //  PARCEL_MEDIA_COMMAND_LOOP_SET    float loop      Use this to get or set the parcel's media loop duration. (1.19.1 RC0 or later)

            m_host.AddScriptLPS(1);

            // according to the docs, this command only works if script owner and land owner are the same
            // lets add estate owners and gods, too, and use the generic permission check.
            ILandObject landObject = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
            if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, landObject, GroupPowers.ChangeMedia)) return;

            bool update = false; // send a ParcelMediaUpdate (and possibly change the land's media URL)?
            byte loop = 0;

            LandData landData = landObject.LandData;
            string url = landData.MediaURL;
            string texture = landData.MediaID.ToString();
            bool autoAlign = landData.MediaAutoScale != 0;
            string mediaType = ""; // TODO these have to be added as soon as LandData supports it
            string description = "";
            int width = 0;
            int height = 0;

            ParcelMediaCommandEnum? commandToSend = null;
            float time = 0.0f; // default is from start

            ScenePresence presence = null;

            for (int i = 0; i < commandList.Data.Length; i++)
            {
                ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i];
                switch (command)
                {
                    case ParcelMediaCommandEnum.Agent:
                        // we send only to one agent
                        if ((i + 1) < commandList.Length)
                        {
                            if (commandList.Data[i + 1] is LSL_String)
                            {
                                UUID agentID;
                                if (UUID.TryParse((LSL_String)commandList.Data[i + 1], out agentID))
                                {
                                    presence = World.GetScenePresence(agentID);
                                }
                            }
                            else ShoutError("The argument of PARCEL_MEDIA_COMMAND_AGENT must be a key");
                            ++i;
                        }
                        break;

                    case ParcelMediaCommandEnum.Loop:
                        loop = 1;
                        commandToSend = command;
                        update = true; //need to send the media update packet to set looping
                        break;

                    case ParcelMediaCommandEnum.Play:
                        loop = 0;
                        commandToSend = command;
                        update = true; //need to send the media update packet to make sure it doesn't loop
                        break;

                    case ParcelMediaCommandEnum.Pause:
                    case ParcelMediaCommandEnum.Stop:
                    case ParcelMediaCommandEnum.Unload:
                        commandToSend = command;
                        break;

                    case ParcelMediaCommandEnum.Url:
                        if ((i + 1) < commandList.Length)
                        {
                            if (commandList.Data[i + 1] is LSL_String)
                            {
                                url = (LSL_String)commandList.Data[i + 1];
                                update = true;
                            }
                            else ShoutError("The argument of PARCEL_MEDIA_COMMAND_URL must be a string.");
                            ++i;
                        }
                        break;

                    case ParcelMediaCommandEnum.Texture:
                        if ((i + 1) < commandList.Length)
                        {
                            if (commandList.Data[i + 1] is LSL_String)
                            {
                                texture = (LSL_String)commandList.Data[i + 1];
                                update = true;
                            }
                            else ShoutError("The argument of PARCEL_MEDIA_COMMAND_TEXTURE must be a string or key.");
                            ++i;
                        }
                        break;

                    case ParcelMediaCommandEnum.Time:
                        if ((i + 1) < commandList.Length)
                        {
                            if (commandList.Data[i + 1] is LSL_Float)
                            {
                                time = (float)(LSL_Float)commandList.Data[i + 1];
                            }
                            else ShoutError("The argument of PARCEL_MEDIA_COMMAND_TIME must be a float.");
                            ++i;
                        }
                        break;

                    case ParcelMediaCommandEnum.AutoAlign:
                        if ((i + 1) < commandList.Length)
                        {
                            if (commandList.Data[i + 1] is LSL_Integer)
                            {
                                autoAlign = (LSL_Integer)commandList.Data[i + 1];
                                update = true;
                            }

                            else ShoutError("The argument of PARCEL_MEDIA_COMMAND_AUTO_ALIGN must be an integer.");
                            ++i;
                        }
                        break;

                    case ParcelMediaCommandEnum.Type:
                        if ((i + 1) < commandList.Length)
                        {
                            if (commandList.Data[i + 1] is LSL_String)
                            {
                                mediaType = (LSL_String)commandList.Data[i + 1];
                                update = true;
                            }
                            else ShoutError("The argument of PARCEL_MEDIA_COMMAND_TYPE must be a string.");
                            ++i;
                        }
                        break;

                    case ParcelMediaCommandEnum.Desc:
                        if ((i + 1) < commandList.Length)
                        {
                            if (commandList.Data[i + 1] is LSL_String)
                            {
                                description = (LSL_String)commandList.Data[i + 1];
                                update = true;
                            }
                            else ShoutError("The argument of PARCEL_MEDIA_COMMAND_DESC must be a string.");
                            ++i;
                        }
                        break;

                    case ParcelMediaCommandEnum.Size:
                        if ((i + 2) < commandList.Length)
                        {
                            if (commandList.Data[i + 1] is LSL_Integer)
                            {
                                if (commandList.Data[i + 2] is LSL_Integer)
                                {
                                    width = (LSL_Integer)commandList.Data[i + 1];
                                    height = (LSL_Integer)commandList.Data[i + 2];
                                    update = true;
                                }
                                else ShoutError("The second argument of PARCEL_MEDIA_COMMAND_SIZE must be an integer.");
                            }
                            else ShoutError("The first argument of PARCEL_MEDIA_COMMAND_SIZE must be an integer.");
                            i += 2;
                        }
                        break;

                    default:
                        NotImplemented("llParcelMediaCommandList parameter not supported yet: " + Enum.Parse(typeof(ParcelMediaCommandEnum), commandList.Data[i].ToString()).ToString());
                        break;
                }//end switch
            }//end for

            // if we didn't get a presence, we send to all and change the url
            // if we did get a presence, we only send to the agent specified, and *don't change the land settings*!

            // did something important change or do we only start/stop/pause?
            if (update)
            {
                if (presence == null)
                {
                    // we send to all
                    landData.MediaID = new UUID(texture);
                    landData.MediaAutoScale = autoAlign ? (byte)1 : (byte)0;
                    landData.MediaWidth = width;
                    landData.MediaHeight = height;
                    landData.MediaType = mediaType;

                    // do that one last, it will cause a ParcelPropertiesUpdate
                    landObject.SetMediaUrl(url);

                    // now send to all (non-child) agents in the parcel
                    World.ForEachRootScenePresence(delegate(ScenePresence sp)
                    {
                        if (sp.currentParcelUUID == landData.GlobalID)
                        {
                            sp.ControllingClient.SendParcelMediaUpdate(landData.MediaURL,
                                                                          landData.MediaID,
                                                                          landData.MediaAutoScale,
                                                                          mediaType,
                                                                          description,
                                                                          width, height,
                                                                          loop);
                        }
                    });
                }
                else if (!presence.IsChildAgent)
                {
                    // we only send to one (root) agent
                    presence.ControllingClient.SendParcelMediaUpdate(url,
                                                                     new UUID(texture),
                                                                     autoAlign ? (byte)1 : (byte)0,
                                                                     mediaType,
                                                                     description,
                                                                     width, height,
                                                                     loop);
                }
            }

            if (commandToSend != null)
            {
                // the commandList contained a start/stop/... command, too
                if (presence == null)
                {
                    // send to all (non-child) agents in the parcel
                    World.ForEachRootScenePresence(delegate(ScenePresence sp)
                    {
                        if (sp.currentParcelUUID == landData.GlobalID)
                        {
                            sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this?
                                                                           (ParcelMediaCommandEnum)commandToSend,
                                                                           time);
                        }
                    });
                }
                else if (!presence.IsChildAgent)
                {
                    presence.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this?
                                                                      (ParcelMediaCommandEnum)commandToSend,
                                                                      time);
                }
            }
            ScriptSleep(2000);
        }
Exemple #4
0
        public void llSetPayPrice(int price, LSL_List quick_pay_buttons)
        {
            m_host.AddScriptLPS(1);

            if (quick_pay_buttons.Data.Length < 4)
            {
                LSLError("List must have at least 4 elements");
                return;
            }
            m_host.ParentGroup.RootPart.PayPrice[0]=price;

            m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0];
            m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1];
            m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2];
            m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3];
            m_host.ParentGroup.HasGroupChanged = true;
        }
 public LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules)
 {
     CheckThreatLevel(ThreatLevel.High, "osGetPrimitiveParams");
     m_host.AddScriptLPS(1);
     InitLSL();
     
     return m_LSL_Api.GetPrimitiveParamsEx(prim, rules);
 }
        public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options)
        {
            CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments");
            m_host.AddScriptLPS(1);

            UUID targetUUID;
            if(!UUID.TryParse(avatar.ToString(), out targetUUID))
                return;
            
            if(targetUUID == UUID.Zero)
                return;
            
            ScenePresence target;
            if(!World.TryGetScenePresence(targetUUID, out target))
               return;

            if(target.IsDeleted || target.IsInTransit)
               return;

            List<int> aps = new List<int>();
            if(attachmentPoints.Length != 0)
            {
                foreach (object point in attachmentPoints.Data)
                {
                    int ipoint;
                    if (int.TryParse(point.ToString(), out ipoint))
                    {
                        aps.Add(ipoint);
                    }
                }
                // parsing failed
                if(aps.Count != attachmentPoints.Length)
                    return;
            }

            List<SceneObjectGroup> attachments = new List<SceneObjectGroup>();

            bool msgAll;
            bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0;

            if(aps.Count == 0)
            {
                if(!invertPoints)
                    return;
                msgAll = true;
                invertPoints = false;
            }
            else
                msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL);

            if (msgAll && invertPoints)
                return;

            if (msgAll || invertPoints)
            {
                attachments = target.GetAttachments();
            }
            else
            {
                foreach (int point in aps)
                {
                    if (point > 0)
                    {
                        attachments.AddRange(target.GetAttachments((uint)point));
                    }
                }
            }

            // if we have no attachments at this point, exit now
            if (attachments.Count == 0)
            {
                return;
            }

            bool optionObjCreator = (options & 
                        ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0;
            bool optionScriptCreator = (options &
                        ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0;

            UUID hostCreatorID = m_host.CreatorID;
            UUID itemCreatorID = m_item.CreatorID;

            foreach (SceneObjectGroup sog in attachments)
            {
                if(sog.IsDeleted || sog.inTransit)
                    continue;

                if (invertPoints && aps.Contains((int)sog.AttachmentPoint))
                    continue;

                UUID CreatorID = sog.RootPart.CreatorID;
                if (optionObjCreator && CreatorID != hostCreatorID)
                    continue;

                if (optionScriptCreator && CreatorID != itemCreatorID)
                    continue;

                SceneObjectPart[] parts = sog.Parts;
                foreach(SceneObjectPart p in parts)
                    MessageObject(p.UUID, message);
            }
        }
Exemple #7
0
 public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y)
 {
     return(m_OSSL_Functions.osDrawFilledPolygon(drawList, x, y));
 }
        public LSL_String osFormatString(string str, LSL_List strings)
        {
            CheckThreatLevel(ThreatLevel.VeryLow, "osFormatString");
            m_host.AddScriptLPS(1);

            return String.Format(str, strings.Data);
        }
Exemple #9
0
 public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints)
 {
     return(m_OSSL_Functions.osGetNumberOfAttachments(avatar, attachmentPoints));
 }
Exemple #10
0
 public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags)
 {
     m_OSSL_Functions.osMessageAttachments(avatar, message, attachmentPoints, flags);
 }
Exemple #11
0
 public LSL_String osRequestSecureURL(LSL_List options)
 {
     return(m_OSSL_Functions.osRequestSecureURL(options));
 }
Exemple #12
0
 public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules)
 {
     m_OSSL_Functions.osSetPrimitiveParams(prim, rules);
 }
Exemple #13
0
 public LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules)
 {
     return(m_OSSL_Functions.osGetPrimitiveParams(prim, rules));
 }
Exemple #14
0
        // Get a list of all the avatars/agents in the region
        public LSL_List osGetAgents()
        {
            // threat level is None as we could get this information with an
            // in-world script as well, just not as efficient
            CheckThreatLevel(ThreatLevel.None, "osGetAgents");
            m_host.AddScriptLPS(1);

            LSL_List result = new LSL_List();
            World.ForEachRootScenePresence(delegate(ScenePresence sp)
            {
                result.Add(new LSL_String(sp.Name));
            });
            return result;
        }
Exemple #15
0
 public LSL_String osFormatString(string str, LSL_List strings)
 {
     return(m_OSSL_Functions.osFormatString(str, strings));
 }
Exemple #16
0
 public void osSetParcelDetails(LSL_Vector pos, LSL_List rules)
 {
     const string functionName = "osSetParcelDetails";
     CheckThreatLevel(ThreatLevel.High, functionName);
     SetParcelDetails(pos, rules, functionName);
 }
Exemple #17
0
 public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules)
 {
     return(m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules));
 }
Exemple #18
0
        /// <summary>
        /// Get the primitive parameters of a linked prim.
        /// </summary>
        /// <remarks>
        /// Threat level is 'Low' because certain users could possibly be tricked into
        /// dropping an unverified script into one of their own objects, which could
        /// then gather the physical construction details of the object and transmit it
        /// to an unscrupulous third party, thus permitting unauthorized duplication of
        /// the object's form.
        /// </remarks>
        /// <param name="linknumber"></param>
        /// <param name="rules"></param>
        /// <returns></returns>
        public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules)
        {
            CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams");
            m_host.AddScriptLPS(1);
            InitLSL();
            // One needs to cast m_LSL_Api because we're using functions not
            // on the ILSL_Api interface.
            LSL_Api LSL_Api = (LSL_Api)m_LSL_Api;
            LSL_List retVal = new LSL_List();
            LSL_List remaining = new LSL_List();
            List<SceneObjectPart> parts = LSL_Api.GetLinkParts(linknumber);
            foreach (SceneObjectPart part in parts)
            {
                remaining = LSL_Api.GetPrimParams(part, rules, ref retVal);
            }

            while (remaining.Length > 2)
            {
                linknumber = remaining.GetLSLIntegerItem(0);
                rules = remaining.GetSublist(1, -1);
                parts = LSL_Api.GetLinkParts(linknumber);

                foreach (SceneObjectPart part in parts)
                    remaining = LSL_Api.GetPrimParams(part, rules, ref retVal);
            }
            return retVal;
        }
Exemple #19
0
        /// <summary>
        /// Get the current Windlight scene
        /// </summary>
        /// <returns>List of windlight parameters</returns>
        public LSL_List lsGetWindlightScene(LSL_List rules)
        {
            if (!m_LSFunctionsEnabled)
            {
                LSShoutError("LightShare functions are not enabled.");
                return(new LSL_List());
            }
            m_host.AddScriptLPS(1);
            RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;

            LSL_List values = new LSL_List();
            int      idx    = 0;

            while (idx < rules.Length)
            {
                LSL_Integer ruleInt = rules.GetLSLIntegerItem(idx);
                uint        rule    = (uint)ruleInt;
                LSL_List    toadd   = new LSL_List();

                switch (rule)
                {
                case (int)ScriptBaseClass.WL_AMBIENT:
                    toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
                    break;

                case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
                    toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
                    break;

                case (int)ScriptBaseClass.WL_BLUE_DENSITY:
                    toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
                    break;

                case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
                    toadd.Add(new LSL_Float(wl.blurMultiplier));
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_COLOR:
                    toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
                    toadd.Add(new LSL_Float(wl.cloudCoverage));
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
                    toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_SCALE:
                    toadd.Add(new LSL_Float(wl.cloudScale));
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
                    toadd.Add(new LSL_Float(wl.cloudScrollX));
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
                    toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
                    toadd.Add(new LSL_Float(wl.cloudScrollY));
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
                    toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
                    toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
                    break;

                case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
                    toadd.Add(new LSL_Float(wl.densityMultiplier));
                    break;

                case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
                    toadd.Add(new LSL_Float(wl.distanceMultiplier));
                    break;

                case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
                    toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
                    break;

                case (int)ScriptBaseClass.WL_EAST_ANGLE:
                    toadd.Add(new LSL_Float(wl.eastAngle));
                    break;

                case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
                    toadd.Add(new LSL_Float(wl.fresnelOffset));
                    break;

                case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
                    toadd.Add(new LSL_Float(wl.fresnelScale));
                    break;

                case (int)ScriptBaseClass.WL_HAZE_DENSITY:
                    toadd.Add(new LSL_Float(wl.hazeDensity));
                    break;

                case (int)ScriptBaseClass.WL_HAZE_HORIZON:
                    toadd.Add(new LSL_Float(wl.hazeHorizon));
                    break;

                case (int)ScriptBaseClass.WL_HORIZON:
                    toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
                    break;

                case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
                    toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
                    break;

                case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
                    toadd.Add(new LSL_Integer(wl.maxAltitude));
                    break;

                case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
                    toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
                    break;

                case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
                    toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
                    break;

                case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
                    toadd.Add(new LSL_Float(wl.refractScaleAbove));
                    break;

                case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
                    toadd.Add(new LSL_Float(wl.refractScaleBelow));
                    break;

                case (int)ScriptBaseClass.WL_SCENE_GAMMA:
                    toadd.Add(new LSL_Float(wl.sceneGamma));
                    break;

                case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
                    toadd.Add(new LSL_Float(wl.starBrightness));
                    break;

                case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
                    toadd.Add(new LSL_Float(wl.sunGlowFocus));
                    break;

                case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
                    toadd.Add(new LSL_Float(wl.sunGlowSize));
                    break;

                case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
                    toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
                    break;

                case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
                    toadd.Add(new LSL_Float(wl.sunMoonPosition));
                    break;

                case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
                    toadd.Add(new LSL_Float(wl.underwaterFogModifier));
                    break;

                case (int)ScriptBaseClass.WL_WATER_COLOR:
                    toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
                    break;

                case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
                    toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
                    break;
                }

                if (toadd.Length > 0)
                {
                    values.Add(ruleInt);
                    values.Add(toadd.Data[0]);
                }
                idx++;
            }

            return(values);
        }
Exemple #20
0
        /// <summary>
        /// Like osGetAgents but returns enough info for a radar
        /// </summary>
        /// <returns>Strided list of the UUID, position and name of each avatar in the region</returns>
        public LSL_List osGetAvatarList()
        {
            CheckThreatLevel(ThreatLevel.None, "osGetAvatarList");
            m_host.AddScriptLPS(1);

            LSL_List result = new LSL_List();
            World.ForEachRootScenePresence(delegate (ScenePresence avatar)
            {
                if (avatar != null && avatar.UUID != m_host.OwnerID)
                {
                    result.Add(new LSL_String(avatar.UUID.ToString()));
                    result.Add(new LSL_Vector(avatar.AbsolutePosition));
                    result.Add(new LSL_String(avatar.Name));
                }
            });

            return result;
        }
Exemple #21
0
        private RegionLightShareData getWindlightProfileFromRules(LSL_List rules)
        {
            RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();

//            LSL_List values = new LSL_List();
            int idx = 0;

            while (idx < rules.Length)
            {
                uint rule;

                try
                {
                    rule = (uint)rules.GetLSLIntegerItem(idx);
                }
                catch (InvalidCastException)
                {
                    throw new InvalidCastException(string.Format("Error running rule type: arg #{0} - parameter type must be integer", idx));
                }

                LSL_Types.Quaternion iQ;
                LSL_Types.Vector3    iV;
                switch (rule)
                {
                case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
                    idx++;
                    try
                    {
                        wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_SUN_MOON_POSITION: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_AMBIENT:
                    idx++;
                    try
                    {
                        iQ = rules.GetQuaternionItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_AMBIENT: arg #{0} - parameter 1 must be rotation", idx));
                    }
                    wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
                    break;

                case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
                    idx++;
                    try
                    {
                        iV = rules.GetVector3Item(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_BIG_WAVE_DIRECTION: arg #{0} - parameter 1 must be vector", idx));
                    }
                    wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
                    break;

                case (int)ScriptBaseClass.WL_BLUE_DENSITY:
                    idx++;
                    try
                    {
                        iQ = rules.GetQuaternionItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_BLUE_DENSITY: arg #{0} - parameter 1 must be rotation", idx));
                    }
                    wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
                    break;

                case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
                    idx++;
                    try
                    {
                        wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_BLUR_MULTIPLIER: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_COLOR:
                    idx++;
                    try
                    {
                        iQ = rules.GetQuaternionItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_COLOR: arg #{0} - parameter 1 must be rotation", idx));
                    }
                    wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
                    idx++;
                    try
                    {
                        wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_COVERAGE: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
                    idx++;
                    try
                    {
                        iV = rules.GetVector3Item(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_DETAIL_XY_DENSITY: arg #{0} - parameter 1 must be vector", idx));
                    }
                    wl.cloudDetailXYDensity = iV;
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_SCALE:
                    idx++;
                    try
                    {
                        wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCALE: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
                    idx++;
                    try
                    {
                        wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_X: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
                    idx++;
                    try
                    {
                        wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_Y_LOCK: arg #{0} - parameter 1 must be integer", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
                    idx++;
                    try
                    {
                        wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_Y: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
                    idx++;
                    try
                    {
                        wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_Y_LOCK: arg #{0} - parameter 1 must be integer", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
                    idx++;
                    try
                    {
                        iV = rules.GetVector3Item(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_XY_DENSITY: arg #{0} - parameter 1 must be vector", idx));
                    }
                    wl.cloudXYDensity = iV;
                    break;

                case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
                    idx++;
                    try
                    {
                        wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_DENSITY_MULTIPLIER: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
                    idx++;
                    try
                    {
                        wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_DISTANCE_MULTIPLIER: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
                    idx++;
                    try
                    {
                        wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_DRAW_CLASSIC_CLOUDS: arg #{0} - parameter 1 must be integer", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_EAST_ANGLE:
                    idx++;
                    try
                    {
                        wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_EAST_ANGLE: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
                    idx++;
                    try
                    {
                        wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_FRESNEL_OFFSET: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
                    idx++;
                    try
                    {
                        wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_FRESNEL_SCALE: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_HAZE_DENSITY:
                    idx++;
                    try
                    {
                        wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_HAZE_DENSITY: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_HAZE_HORIZON:
                    idx++;
                    try
                    {
                        wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_HAZE_HORIZON: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_HORIZON:
                    idx++;
                    try
                    {
                        iQ = rules.GetQuaternionItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_HORIZON: arg #{0} - parameter 1 must be rotation", idx));
                    }
                    wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
                    break;

                case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
                    idx++;
                    try
                    {
                        iV = rules.GetVector3Item(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_LITTLE_WAVE_DIRECTION: arg #{0} - parameter 1 must be vector", idx));
                    }
                    wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
                    break;

                case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
                    idx++;
                    try
                    {
                        wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_MAX_ALTITUDE: arg #{0} - parameter 1 must be integer", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
                    idx++;
                    try
                    {
                        wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
                    }
                    catch (ArgumentException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_NORMAL_MAP_TEXTURE: arg #{0} - parameter 1 must be key", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
                    idx++;
                    try
                    {
                        iV = rules.GetVector3Item(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_REFLECTION_WAVELET_SCALE: arg #{0} - parameter 1 must be vector", idx));
                    }
                    wl.reflectionWaveletScale = iV;
                    break;

                case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
                    idx++;
                    try
                    {
                        wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_REFRACT_SCALE_ABOVE: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
                    idx++;
                    try
                    {
                        wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_REFRACT_SCALE_BELOW: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_SCENE_GAMMA:
                    idx++;
                    try
                    {
                        wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_SCENE_GAMMA: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
                    idx++;
                    try
                    {
                        wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_STAR_BRIGHTNESS: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
                    idx++;
                    try
                    {
                        wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_SUN_GLOW_FOCUS: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
                    idx++;
                    try
                    {
                        wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_SUN_GLOW_SIZE: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
                    idx++;
                    iQ = rules.GetQuaternionItem(idx);
                    try
                    {
                        wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_SUN_MOON_COLOR: arg #{0} - parameter 1 must be rotation", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
                    idx++;
                    try
                    {
                        wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_UNDERWATER_FOG_MODIFIER: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;

                case (int)ScriptBaseClass.WL_WATER_COLOR:
                    idx++;
                    try
                    {
                        iV = rules.GetVector3Item(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_WATER_COLOR: arg #{0} - parameter 1 must be vector", idx));
                    }
                    wl.waterColor = iV;
                    break;

                case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
                    idx++;
                    try
                    {
                        wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
                    }
                    catch (InvalidCastException)
                    {
                        throw new InvalidCastException(string.Format("Error running rule WL_WATER_FOG_DENSITY_EXPONENT: arg #{0} - parameter 1 must be float", idx));
                    }
                    break;
                }
                idx++;
            }
            return(wl);
        }
 /**
  * @brief Load current detect params from a list
  * @param dpList = as returned by xmrEventSaveDets()
  */
 public override void xmrEventLoadDets(LSL_List dpList)
 {
     m_DetectParams = ObjArrToDetPrms(dpList.Data);
 }
        private void processXstate(XmlDocument doc)
        {
            XmlNodeList rootL = doc.GetElementsByTagName("ScriptState");

            if (rootL.Count != 1)
            {
                throw new Exception("Xstate <ScriptState> missing");
            }

            XmlNode rootNode = rootL[0];

            if (rootNode == null)
            {
                throw new Exception("Xstate root missing");
            }

            string stateName = "";
            bool   running   = false;

            UUID   permsGranter  = UUID.Zero;
            int    permsMask     = 0;
            double minEventDelay = 0.0;

            Object[] pluginData = new Object[0];

            LinkedList <EventParams> eventQueue = new LinkedList <EventParams>();

            Dictionary <string, int> intNames      = new Dictionary <string, int>();
            Dictionary <string, int> doubleNames   = new Dictionary <string, int>();
            Dictionary <string, int> stringNames   = new Dictionary <string, int>();
            Dictionary <string, int> vectorNames   = new Dictionary <string, int>();
            Dictionary <string, int> rotationNames = new Dictionary <string, int>();
            Dictionary <string, int> listNames     = new Dictionary <string, int>();

            int[]          ints      = null;
            double[]       doubles   = null;
            string[]       strings   = null;
            LSL_Vector[]   vectors   = null;
            LSL_Rotation[] rotations = null;
            LSL_List[]     lists     = null;

            int nn = m_ObjCode.globalVarNames.Count;

            if (nn > 0)
            {
                Dictionary <int, string> tmpVars;
                if (m_ObjCode.globalVarNames.TryGetValue("iarIntegers", out tmpVars))
                {
                    getvarNames(tmpVars, intNames);
                    ints = new int[tmpVars.Count];
                }
                if (m_ObjCode.globalVarNames.TryGetValue("iarFloats", out tmpVars))
                {
                    getvarNames(tmpVars, doubleNames);
                    doubles = new double[tmpVars.Count];
                }
                if (m_ObjCode.globalVarNames.TryGetValue("iarVectors", out tmpVars))
                {
                    getvarNames(tmpVars, vectorNames);
                    vectors = new LSL_Vector[tmpVars.Count];
                }
                if (m_ObjCode.globalVarNames.TryGetValue("iarRotations", out tmpVars))
                {
                    getvarNames(tmpVars, rotationNames);
                    rotations = new LSL_Rotation[tmpVars.Count];
                }
                if (m_ObjCode.globalVarNames.TryGetValue("iarStrings", out tmpVars))
                {
                    getvarNames(tmpVars, stringNames);
                    strings = new string[tmpVars.Count];
                }
                if (m_ObjCode.globalVarNames.TryGetValue("iarLists", out tmpVars))
                {
                    getvarNames(tmpVars, listNames);
                    lists = new LSL_List[tmpVars.Count];
                }
            }

            int heapsz = 0;

            try
            {
                XmlNodeList partL = rootNode.ChildNodes;
                foreach (XmlNode part in partL)
                {
                    switch (part.Name)
                    {
                    case "State":
                        stateName = part.InnerText;
                        break;

                    case "Running":
                        running = bool.Parse(part.InnerText);
                        break;

                    case "Variables":
                        int         indx;
                        XmlNodeList varL = part.ChildNodes;
                        foreach (XmlNode var in varL)
                        {
                            string varName;
                            object o     = ReadXTypedValue(var, out varName);
                            Type   otype = o.GetType();
                            if (otype == typeof(LSL_Integer))
                            {
                                if (intNames.TryGetValue(varName, out indx))
                                {
                                    ints[indx] = ((LSL_Integer)o);
                                }
                                continue;
                            }
                            if (otype == typeof(LSL_Float))
                            {
                                if (doubleNames.TryGetValue(varName, out indx))
                                {
                                    doubles[indx] = ((LSL_Float)o);
                                }
                                continue;
                            }
                            if (otype == typeof(LSL_String))
                            {
                                if (stringNames.TryGetValue(varName, out indx))
                                {
                                    strings[indx] = ((LSL_String)o);
                                    heapsz       += ((LSL_String)o).Length;
                                }
                                continue;
                            }
                            if (otype == typeof(LSL_Rotation))
                            {
                                if (rotationNames.TryGetValue(varName, out indx))
                                {
                                    rotations[indx] = ((LSL_Rotation)o);
                                }
                                continue;
                            }
                            if (otype == typeof(LSL_Vector))
                            {
                                if (vectorNames.TryGetValue(varName, out indx))
                                {
                                    vectors[indx] = ((LSL_Vector)o);
                                }
                                continue;
                            }
                            if (otype == typeof(LSL_Key))
                            {
                                if (stringNames.TryGetValue(varName, out indx))
                                {
                                    strings[indx] = ((LSL_Key)o);
                                    heapsz       += ((LSL_String)o).Length;
                                }
                                continue;
                            }
                            if (otype == typeof(UUID))
                            {
                                if (stringNames.TryGetValue(varName, out indx))
                                {
                                    LSL_String id = ((UUID)o).ToString();
                                    strings[indx] = (id);
                                    heapsz       += id.Length;
                                }
                                continue;
                            }
                            if (otype == typeof(LSL_List))
                            {
                                if (listNames.TryGetValue(varName, out indx))
                                {
                                    LSL_List lo = (LSL_List)o;
                                    lists[indx] = (lo);
                                    heapsz     += lo.Size;
                                }
                                continue;
                            }
                        }
                        break;

                    case "Queue":
                        XmlNodeList itemL = part.ChildNodes;
                        foreach (XmlNode item in itemL)
                        {
                            List <Object>       parms    = new List <Object>();
                            List <DetectParams> detected = new List <DetectParams>();

                            string      eventName = item.Attributes.GetNamedItem("event").Value;
                            XmlNodeList eventL    = item.ChildNodes;
                            foreach (XmlNode evt in eventL)
                            {
                                switch (evt.Name)
                                {
                                case "Params":
                                    XmlNodeList prms = evt.ChildNodes;
                                    foreach (XmlNode pm in prms)
                                    {
                                        parms.Add(ReadXTypedValue(pm));
                                    }

                                    break;

                                case "Detected":
                                    XmlNodeList detL = evt.ChildNodes;
                                    foreach (XmlNode det in detL)
                                    {
                                        string     vect = det.Attributes.GetNamedItem("pos").Value;
                                        LSL_Vector v    = new LSL_Vector(vect);

                                        int          d_linkNum  = 0;
                                        UUID         d_group    = UUID.Zero;
                                        string       d_name     = String.Empty;
                                        UUID         d_owner    = UUID.Zero;
                                        LSL_Vector   d_position = new LSL_Vector();
                                        LSL_Rotation d_rotation = new LSL_Rotation();
                                        int          d_type     = 0;
                                        LSL_Vector   d_velocity = new LSL_Vector();

                                        try
                                        {
                                            string tmp;

                                            tmp = det.Attributes.GetNamedItem("linkNum").Value;
                                            int.TryParse(tmp, out d_linkNum);

                                            tmp = det.Attributes.GetNamedItem("group").Value;
                                            UUID.TryParse(tmp, out d_group);

                                            d_name = det.Attributes.GetNamedItem("name").Value;

                                            tmp = det.Attributes.GetNamedItem("owner").Value;
                                            UUID.TryParse(tmp, out d_owner);

                                            tmp        = det.Attributes.GetNamedItem("position").Value;
                                            d_position = new LSL_Types.Vector3(tmp);

                                            tmp        = det.Attributes.GetNamedItem("rotation").Value;
                                            d_rotation = new LSL_Rotation(tmp);

                                            tmp = det.Attributes.GetNamedItem("type").Value;
                                            int.TryParse(tmp, out d_type);

                                            tmp        = det.Attributes.GetNamedItem("velocity").Value;
                                            d_velocity = new LSL_Vector(tmp);
                                        }
                                        catch (Exception)         // Old version XML
                                        {
                                        }

                                        UUID uuid = new UUID();
                                        UUID.TryParse(det.InnerText, out uuid);

                                        DetectParams d = new DetectParams();
                                        d.Key       = uuid;
                                        d.OffsetPos = v;
                                        d.LinkNum   = d_linkNum;
                                        d.Group     = d_group;
                                        d.Name      = d_name;
                                        d.Owner     = d_owner;
                                        d.Position  = d_position;
                                        d.Rotation  = d_rotation;
                                        d.Type      = d_type;
                                        d.Velocity  = d_velocity;

                                        detected.Add(d);
                                    }
                                    break;
                                }
                            }
                            EventParams ep = new EventParams(
                                eventName, parms.ToArray(),
                                detected.ToArray());
                            eventQueue.AddLast(ep);
                        }
                        break;

                    case "Plugins":
                        List <Object> olist  = new List <Object>();
                        XmlNodeList   itemLP = part.ChildNodes;
                        foreach (XmlNode item in itemLP)
                        {
                            olist.Add(ReadXTypedValue(item));
                        }
                        pluginData = olist.ToArray();
                        break;

                    case "Permissions":
                        string tmpPerm;
                        int    mask = 0;
                        tmpPerm = part.Attributes.GetNamedItem("mask").Value;
                        if (tmpPerm != null)
                        {
                            int.TryParse(tmpPerm, out mask);
                            if (mask != 0)
                            {
                                tmpPerm = part.Attributes.GetNamedItem("granter").Value;
                                if (tmpPerm != null)
                                {
                                    UUID granter = new UUID();
                                    UUID.TryParse(tmpPerm, out granter);
                                    if (granter != UUID.Zero)
                                    {
                                        permsMask    = mask;
                                        permsGranter = granter;
                                    }
                                }
                            }
                        }
                        break;

                    case "MinEventDelay":
                        double.TryParse(part.InnerText, out minEventDelay);
                        break;
                    }
                }
            }
            catch
            {
                throw new Exception("Xstate fail decode");
            }

            int k = 0;

            stateCode = 0;
            foreach (string sn in m_ObjCode.stateNames)
            {
                if (stateName == sn)
                {
                    stateCode = k;
                    break;
                }
                k++;
            }
            eventCode = ScriptEventCode.None;
            m_Running = running;
            doGblInit = false;

            m_Item.PermsGranter = permsGranter;
            m_Item.PermsMask    = permsMask;
            m_Part.Inventory.UpdateInventoryItem(m_Item, false, false);

            lock (m_RunLock)
            {
                glblVars.iarIntegers    = (ints != null) ? ints : XMRInstArrays.noIntegers;
                glblVars.iarFloats      = (doubles != null) ? doubles : XMRInstArrays.noFloats;
                glblVars.iarStrings     = (strings != null) ? strings : XMRInstArrays.noStrings;
                glblVars.iarVectors     = (vectors != null) ? vectors : XMRInstArrays.noVectors;
                glblVars.iarRotations   = (rotations != null) ? rotations : XMRInstArrays.noRotations;
                glblVars.iarLists       = (lists != null) ? lists : XMRInstArrays.noLists;
                glblVars.iarChars       = XMRInstArrays.noChars;
                glblVars.iarArrays      = XMRInstArrays.noArrays;
                glblVars.iarObjects     = XMRInstArrays.noObjects;
                glblVars.iarSDTClObjs   = XMRInstArrays.noSDTClObjs;
                glblVars.iarSDTIntfObjs = XMRInstArrays.noSDTIntfObjs;

                AddArraysHeapUse(heapsz);
                CheckRunLockInvariants(true);
            }

            lock (m_QueueLock)
            {
                m_DetectParams = null;
                foreach (EventParams evt in m_EventQueue)
                {
                    eventQueue.AddLast(evt);
                }

                m_EventQueue = eventQueue;
                for (int i = m_EventCounts.Length; --i >= 0;)
                {
                    m_EventCounts[i] = 0;
                }
                foreach (EventParams evt in m_EventQueue)
                {
                    if (m_eventCodeMap.TryGetValue(evt.EventName, out ScriptEventCode evtCode))
                    {
                        m_EventCounts[(int)evtCode]++;
                    }
                }
            }

            AsyncCommandManager.CreateFromData(m_Engine,
                                               m_LocalID, m_ItemID, m_Part.UUID, pluginData);

            MinEventDelay = minEventDelay;
        }
Exemple #24
0
        public LSL_List llParcelMediaQuery(LSL_List aList)
        {
            m_host.AddScriptLPS(1);
            LSL_List list = new LSL_List();
            //TO DO: make the implementation for the missing commands
            //PARCEL_MEDIA_COMMAND_LOOP_SET    float loop      Use this to get or set the parcel's media loop duration. (1.19.1 RC0 or later)
            for (int i = 0; i < aList.Data.Length; i++)
            {

                if (aList.Data[i] != null)
                {
                    switch ((ParcelMediaCommandEnum) aList.Data[i])
                    {
                        case ParcelMediaCommandEnum.Url:
                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL));
                            break;
                        case ParcelMediaCommandEnum.Desc:
                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).Description));
                            break;
                        case ParcelMediaCommandEnum.Texture:
                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaID.ToString()));
                            break;
                        case ParcelMediaCommandEnum.Type:
                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaType));
                            break;
                        case ParcelMediaCommandEnum.Size:
                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaWidth));
                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaHeight));
                            break;
                        default:
                            ParcelMediaCommandEnum mediaCommandEnum = ParcelMediaCommandEnum.Url;
                            NotImplemented("llParcelMediaQuery parameter do not supported yet: " + Enum.Parse(mediaCommandEnum.GetType() , aList.Data[i].ToString()).ToString());
                            break;
                    }

                }
            }
            ScriptSleep(2000);
            return list;
        }
        public void TestllListFindList()
        {
            TestHelpers.InMethod();

            LSL_List src = new LSL_List(new LSL_Integer(1), new LSL_Integer(2), new LSL_Integer(3));

            {
                // Test for a single item that should be found
                int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(4)));
                Assert.That(result, Is.EqualTo(-1));
            }

            {
                // Test for a single item that should be found
                int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(2)));
                Assert.That(result, Is.EqualTo(1));
            }

            {
                // Test for a constant that should be found
                int result = m_lslApi.llListFindList(src, new LSL_List(ScriptBaseClass.AGENT));
                Assert.That(result, Is.EqualTo(0));
            }

            {
                // Test for a list that should be found
                int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(2), new LSL_Integer(3)));
                Assert.That(result, Is.EqualTo(1));
            }

            {
                // Test for a single item not in the list
                int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(4)));
                Assert.That(result, Is.EqualTo(-1));
            }

            {
                // Test for something that should not be cast
                int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_String("4")));
                Assert.That(result, Is.EqualTo(-1));
            }

            {
                // Test for a list not in the list
                int result
                    = m_lslApi.llListFindList(
                          src, new LSL_List(new LSL_Integer(2), new LSL_Integer(3), new LSL_Integer(4)));
                Assert.That(result, Is.EqualTo(-1));
            }

            {
                LSL_List srcWithConstants
                    = new LSL_List(new LSL_Integer(3), ScriptBaseClass.AGENT, ScriptBaseClass.OS_NPC_LAND_AT_TARGET);

                // Test for constants that appears in the source list that should be found
                int result
                    = m_lslApi.llListFindList(srcWithConstants, new LSL_List(new LSL_Integer(1), new LSL_Integer(2)));

                Assert.That(result, Is.EqualTo(1));
            }
        }
Exemple #26
0
        public void llSetCameraParams(LSL_List rules)
        {
            m_host.AddScriptLPS(1);

            // the object we are in
            UUID objectID = m_host.ParentUUID;
            if (objectID == UUID.Zero)
                return;

            // we need the permission first, to know which avatar we want to set the camera for
            UUID agentID = m_item.PermsGranter;

            if (agentID == UUID.Zero)
                return;

            if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
                return;

            ScenePresence presence = World.GetScenePresence(agentID);

            // we are not interested in child-agents
            if (presence.IsChildAgent) return;

            SortedDictionary<int, float> parameters = new SortedDictionary<int, float>();
            object[] data = rules.Data;
            for (int i = 0; i < data.Length; ++i) {
                int type = Convert.ToInt32(data[i++].ToString());
                if (i >= data.Length) break; // odd number of entries => ignore the last

                // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3)
                switch (type) {
                case ScriptBaseClass.CAMERA_FOCUS:
                case ScriptBaseClass.CAMERA_FOCUS_OFFSET:
                case ScriptBaseClass.CAMERA_POSITION:
                    LSL_Vector v = (LSL_Vector)data[i];
                    parameters.Add(type + 1, (float)v.x);
                    parameters.Add(type + 2, (float)v.y);
                    parameters.Add(type + 3, (float)v.z);
                    break;
                default:
                    // TODO: clean that up as soon as the implicit casts are in
                    if (data[i] is LSL_Float)
                        parameters.Add(type, (float)((LSL_Float)data[i]).value);
                    else if (data[i] is LSL_Integer)
                        parameters.Add(type, (float)((LSL_Integer)data[i]).value);
                    else parameters.Add(type, Convert.ToSingle(data[i]));
                    break;
                }
            }
            if (parameters.Count > 0) presence.ControllingClient.SendSetFollowCamProperties(objectID, parameters);
        }
Exemple #27
0
 // Deprecated
 public void osParcelSetDetails(vector pos, LSL_List rules)
 {
     m_OSSL_Functions.osParcelSetDetails(pos, rules);
 }
        public int tsuccirEvenlyDistributeChildPrims(UUID host, UUID script, object[] argsObj)
        {
            SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host);
            hostPart.AddScriptLPS(1);
            LSL_List args = new LSL_List();
            args.Data = argsObj;

            LSL_Vector size = args.GetVector3Item(0);
            LSL_Vector point = args.GetVector3Item(1);
            LSL_Rotation rot = args.GetQuaternionItem(2);
            LSL_Vector distribution = args.GetVector3Item(3);
            LSL_Vector margin = args.GetVector3Item(4);

            return EvenlyDistributeChildPrims(hostPart.ParentGroup, size, point, rot, distribution, margin) ? 1 : 0;
        }
Exemple #29
0
        private LSL_List GetPrimMediaParams(SceneObjectPart part, int face, LSL_List rules)
        {
            // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid
            // TODO: Need to correctly handle case where a face has no media (which gives back an empty list).
            // Assuming silently fail means give back an empty list.  Ideally, need to check this.
            if (face < 0 || face > part.GetNumberOfSides() - 1)
                return new LSL_List();

            IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
            if (null == module)
                return new LSL_List();

            MediaEntry me = module.GetMediaEntry(part, face);

            // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams
            if (null == me)
                return new LSL_List();

            LSL_List res = new LSL_List();

            for (int i = 0; i < rules.Length; i++)
            {
                int code = (int)rules.GetLSLIntegerItem(i);

                switch (code)
                {
                    case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
                        // Not implemented
                        res.Add(new LSL_Integer(0));
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
                        if (me.Controls == MediaControls.Standard)
                            res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD));
                        else
                            res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_MINI));
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
                        res.Add(new LSL_String(me.CurrentURL));
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
                        res.Add(new LSL_String(me.HomeURL));
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
                        res.Add(me.AutoLoop ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
                        res.Add(me.AutoPlay ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
                        res.Add(me.AutoScale ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
                        res.Add(me.AutoZoom ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
                        res.Add(me.InteractOnFirstClick ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
                        res.Add(new LSL_Integer(me.Width));
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS:
                        res.Add(new LSL_Integer(me.Height));
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE:
                        res.Add(me.EnableWhiteList ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_WHITELIST:
                        string[] urls = (string[])me.WhiteList.Clone();

                        for (int j = 0; j < urls.Length; j++)
                            urls[j] = Uri.EscapeDataString(urls[j]);

                        res.Add(new LSL_String(string.Join(", ", urls)));
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT:
                        res.Add(new LSL_Integer((int)me.InteractPermissions));
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
                        res.Add(new LSL_Integer((int)me.ControlPermissions));
                        break;

                    default: return ScriptBaseClass.LSL_STATUS_MALFORMED_PARAMS;
                }
            }

            return res;
        }
Exemple #30
0
        public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options)
        {
            CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments");
            m_host.AddScriptLPS(1);

            UUID targetUUID;
            ScenePresence target;

            if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
            {
                List<int> aps = new List<int>();
                foreach (object point in attachmentPoints.Data)
                {
                    int ipoint;
                    if (int.TryParse(point.ToString(), out ipoint))
                    {
                        aps.Add(ipoint);
                    }
                }

                List<SceneObjectGroup> attachments = new List<SceneObjectGroup>();

                bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL);
                bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0;

                if (msgAll && invertPoints)
                {
                    return;
                }
                else if (msgAll || invertPoints)
                {
                    attachments = target.GetAttachments();
                }
                else
                {
                    foreach (int point in aps)
                    {
                        if (point > 0)
                        {
                            attachments.AddRange(target.GetAttachments((uint)point));
                        }
                    }
                }

                // if we have no attachments at this point, exit now
                if (attachments.Count == 0)
                {
                    return;
                }

                List<SceneObjectGroup> ignoreThese = new List<SceneObjectGroup>();

                if (invertPoints)
                {
                    foreach (SceneObjectGroup attachment in attachments)
                    {
                        if (aps.Contains((int)attachment.AttachmentPoint))
                        {
                            ignoreThese.Add(attachment);
                        }
                    }
                }

                foreach (SceneObjectGroup attachment in ignoreThese)
                {
                    attachments.Remove(attachment);
                }
                ignoreThese.Clear();

                // if inverting removed all attachments to check, exit now
                if (attachments.Count < 1)
                {
                    return;
                }

                if ((options & ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0)
                {
                    foreach (SceneObjectGroup attachment in attachments)
                    {
                        if (attachment.RootPart.CreatorID != m_host.CreatorID)
                        {
                            ignoreThese.Add(attachment);
                        }
                    }

                    foreach (SceneObjectGroup attachment in ignoreThese)
                    {
                        attachments.Remove(attachment);
                    }
                    ignoreThese.Clear();

                    // if filtering by same object creator removed all
                    //  attachments to check, exit now
                    if (attachments.Count == 0)
                    {
                        return;
                    }
                }

                if ((options & ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0)
                {
                    foreach (SceneObjectGroup attachment in attachments)
                    {
                        if (attachment.RootPart.CreatorID != m_item.CreatorID)
                        {
                            ignoreThese.Add(attachment);
                        }
                    }

                    foreach (SceneObjectGroup attachment in ignoreThese)
                    {
                        attachments.Remove(attachment);
                    }
                    ignoreThese.Clear();

                    // if filtering by object creator must match originating
                    //  script creator removed all attachments to check,
                    //  exit now
                    if (attachments.Count == 0)
                    {
                        return;
                    }
                }

                foreach (SceneObjectGroup attachment in attachments)
                {
                    MessageObject(attachment.RootPart.UUID, message);
                }
            }
        }
Exemple #31
0
 public LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules)
 {
     m_host.AddScriptLPS(1);
     ScriptSleep(1000);
     return SetPrimMediaParams(m_host, face, rules);
 }
Exemple #32
0
        public string osDrawPolygon(string drawList, LSL_List x, LSL_List y)
        {
            CheckThreatLevel(ThreatLevel.None, "osDrawPolygon");

            m_host.AddScriptLPS(1);

            if (x.Length != y.Length || x.Length < 3)
            {
                return "";
            }
            drawList += "Polygon " + x.GetLSLStringItem(0) + "," + y.GetLSLStringItem(0);
            for (int i = 1; i < x.Length; i++)
            {
                drawList += "," + x.GetLSLStringItem(i) + "," + y.GetLSLStringItem(i);
            }
            drawList += "; ";
            return drawList;
        }
Exemple #33
0
        public LSL_Integer llSetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules)
        {
            m_host.AddScriptLPS(1);
            ScriptSleep(1000);
            if (link == ScriptBaseClass.LINK_ROOT)
                return SetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules);
            else if (link == ScriptBaseClass.LINK_THIS)
                return SetPrimMediaParams(m_host, face, rules);
            else
            {
                SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link);
                if (null != part)
                    return SetPrimMediaParams(part, face, rules);
            }

            return ScriptBaseClass.LSL_STATUS_NOT_FOUND;
        }
Exemple #34
0
        private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName)
        {
            m_host.AddScriptLPS(1);

            // Get a reference to the land data and make sure the owner of the script
            // can modify it

            ILandObject startLandObject = World.LandChannel.GetLandObject((int)pos.x, (int)pos.y);
            if (startLandObject == null)
            {
                OSSLShoutError("There is no land at that location");
                return;
            }

            if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, startLandObject, GroupPowers.LandOptions, false))
            {
                OSSLShoutError("You do not have permission to modify the parcel");
                return;
            }

            // Create a new land data object we can modify
            LandData newLand = startLandObject.LandData.Copy();
            UUID uuid;

            // Process the rules, not sure what the impact would be of changing owner or group
            for (int idx = 0; idx < rules.Length;)
            {
                int code = rules.GetLSLIntegerItem(idx++);
                string arg = rules.GetLSLStringItem(idx++);
                switch (code)
                {
                    case ScriptBaseClass.PARCEL_DETAILS_NAME:
                        newLand.Name = arg;
                        break;

                    case ScriptBaseClass.PARCEL_DETAILS_DESC:
                        newLand.Description = arg;
                        break;

                    case ScriptBaseClass.PARCEL_DETAILS_OWNER:
                        CheckThreatLevel(ThreatLevel.VeryHigh, functionName);
                        if (UUID.TryParse(arg, out uuid))
                            newLand.OwnerID = uuid;
                        break;

                    case ScriptBaseClass.PARCEL_DETAILS_GROUP:
                        CheckThreatLevel(ThreatLevel.VeryHigh, functionName);
                        if (UUID.TryParse(arg, out uuid))
                            newLand.GroupID = uuid;
                        break;

                    case ScriptBaseClass.PARCEL_DETAILS_CLAIMDATE:
                        CheckThreatLevel(ThreatLevel.VeryHigh, functionName);
                        newLand.ClaimDate = Convert.ToInt32(arg);
                        if (newLand.ClaimDate == 0)
                            newLand.ClaimDate = Util.UnixTimeSinceEpoch();
                        break;
                 }
             }

            World.LandChannel.UpdateLandObject(newLand.LocalID,newLand);
        }
Exemple #35
0
        private LSL_Integer SetPrimMediaParams(SceneObjectPart part, LSL_Integer face, LSL_List rules)
        {
            // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid
            // Assuming silently fail means sending back LSL_STATUS_OK.  Ideally, need to check this.
            // Don't perform the media check directly
            if (face < 0 || face > part.GetNumberOfSides() - 1)
                return ScriptBaseClass.LSL_STATUS_NOT_FOUND;

            IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
            if (null == module)
                return ScriptBaseClass.LSL_STATUS_NOT_SUPPORTED;

            MediaEntry me = module.GetMediaEntry(part, face);
            if (null == me)
                me = new MediaEntry();

            int i = 0;

            while (i < rules.Length - 1)
            {
                int code = rules.GetLSLIntegerItem(i++);

                switch (code)
                {
                    case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
                        me.EnableAlterntiveImage = (rules.GetLSLIntegerItem(i++) != 0 ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
                        int v = rules.GetLSLIntegerItem(i++);
                        if (ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD == v)
                            me.Controls = MediaControls.Standard;
                        else
                            me.Controls = MediaControls.Mini;
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
                        me.CurrentURL = rules.GetLSLStringItem(i++);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
                        me.HomeURL = rules.GetLSLStringItem(i++);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
                        me.AutoLoop = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
                        me.AutoPlay = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
                        me.AutoScale = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
                        me.AutoZoom = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
                        me.InteractOnFirstClick = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
                        me.Width = (int)rules.GetLSLIntegerItem(i++);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS:
                        me.Height = (int)rules.GetLSLIntegerItem(i++);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE:
                        me.EnableWhiteList = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_WHITELIST:
                        string[] rawWhiteListUrls = rules.GetLSLStringItem(i++).ToString().Split(new char[] { ',' });
                        List<string> whiteListUrls = new List<string>();
                        Array.ForEach(
                            rawWhiteListUrls, delegate(string rawUrl) { whiteListUrls.Add(rawUrl.Trim()); });
                        me.WhiteList = whiteListUrls.ToArray();
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT:
                        me.InteractPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
                        break;

                    case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
                        me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
                        break;

                    default: return ScriptBaseClass.LSL_STATUS_MALFORMED_PARAMS;
                }
            }

            module.SetMediaEntry(part, face, me);

            return ScriptBaseClass.LSL_STATUS_OK;
        }
Exemple #36
0
        public LSL_List osMatchString(string src, string pattern, int start)
        {
            CheckThreatLevel(ThreatLevel.VeryLow, "osMatchString");
            m_host.AddScriptLPS(1);

            LSL_List result = new LSL_List();

            // Normalize indices (if negative).
            // After normlaization they may still be
            // negative, but that is now relative to
            // the start, rather than the end, of the
            // sequence.
            if (start < 0)
            {
                start = src.Length + start;
            }

            if (start < 0 || start >= src.Length)
            {
                return result;  // empty list
            }

            // Find matches beginning at start position
            Regex matcher = new Regex(pattern);
            Match match = matcher.Match(src, start);
            while (match.Success)
            {
                foreach (System.Text.RegularExpressions.Group g in match.Groups)
                {
                    if (g.Success)
                    {
                        result.Add(new LSL_String(g.Value));
                        result.Add(new LSL_Integer(g.Index));
                    }
                }

                match = match.NextMatch();
            }

            return result;
        }
Exemple #37
0
        //  <summary>
        //  Scan the string supplied in 'src' and
        //  tokenize it based upon two sets of
        //  tokenizers provided in two lists,
        //  separators and spacers.
        //  </summary>
        //
        //  <remarks>
        //  Separators demarcate tokens and are
        //  elided as they are encountered. Spacers
        //  also demarcate tokens, but are themselves
        //  retained as tokens.
        //
        //  Both separators and spacers may be arbitrarily
        //  long strings. i.e. ":::".
        //
        //  The function returns an ordered list
        //  representing the tokens found in the supplied
        //  sources string. If two successive tokenizers
        //  are encountered, then a NULL entry is added
        //  to the list.
        //
        //  It is a precondition that the source and
        //  toekizer lisst are non-null. If they are null,
        //  then a null pointer exception will be thrown
        //  while their lengths are being determined.
        //
        //  A small amount of working memoryis required
        //  of approximately 8*#tokenizers.
        //
        //  There are many ways in which this function
        //  can be implemented, this implementation is
        //  fairly naive and assumes that when the
        //  function is invooked with a short source
        //  string and/or short lists of tokenizers, then
        //  performance will not be an issue.
        //
        //  In order to minimize the perofrmance
        //  effects of long strings, or large numbers
        //  of tokeizers, the function skips as far as
        //  possible whenever a toekenizer is found,
        //  and eliminates redundant tokenizers as soon
        //  as is possible.
        //
        //  The implementation tries to avoid any copying
        //  of arrays or other objects.
        //  </remarks>

        private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls)
        {
            int         beginning = 0;
            int         srclen    = src.Length;
            int         seplen    = separators.Length;
            object[]    separray  = separators.Data;
            int         spclen    = spacers.Length;
            object[]    spcarray  = spacers.Data;
            int         mlen      = seplen+spclen;

            int[]       offset    = new int[mlen+1];
            bool[]      active    = new bool[mlen];

            int         best;
            int         j;

            //    Initial capacity reduces resize cost

            LSL_List tokens = new LSL_List();

            //    All entries are initially valid

            for (int i = 0; i < mlen; i++)
                active[i] = true;

            offset[mlen] = srclen;

            while (beginning < srclen)
            {

                best = mlen;    // as bad as it gets

                //    Scan for separators

                for (j = 0; j < seplen; j++)
                {
                    if (separray[j].ToString() == String.Empty)
                        active[j] = false;

                    if (active[j])
                    {
                        // scan all of the markers
                        if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1)
                        {
                            // not present at all
                            active[j] = false;
                        }
                        else
                        {
                            // present and correct
                            if (offset[j] < offset[best])
                            {
                                // closest so far
                                best = j;
                                if (offset[best] == beginning)
                                    break;
                            }
                        }
                    }
                }

                //    Scan for spacers

                if (offset[best] != beginning)
                {
                    for (j = seplen; (j < mlen) && (offset[best] > beginning); j++)
                    {
                        if (spcarray[j-seplen].ToString() == String.Empty)
                            active[j] = false;

                        if (active[j])
                        {
                            // scan all of the markers
                            if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1)
                            {
                                // not present at all
                                active[j] = false;
                            }
                            else
                            {
                                // present and correct
                                if (offset[j] < offset[best])
                                {
                                    // closest so far
                                    best = j;
                                }
                            }
                        }
                    }
                }

                //    This is the normal exit from the scanning loop

                if (best == mlen)
                {
                    // no markers were found on this pass
                    // so we're pretty much done
                    if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0))
                        tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning)));
                    break;
                }

                //    Otherwise we just add the newly delimited token
                //    and recalculate where the search should continue.
                if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0))
                    tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning)));

                if (best < seplen)
                {
                    beginning = offset[best] + (separray[best].ToString()).Length;
                }
                else
                {
                    beginning = offset[best] + (spcarray[best - seplen].ToString()).Length;
                    string str = spcarray[best - seplen].ToString();
                    if ((keepNulls) || ((!keepNulls) && (str.Length > 0)))
                        tokens.Add(new LSL_String(str));
                }
            }

            //    This an awkward an not very intuitive boundary case. If the
            //    last substring is a tokenizer, then there is an implied trailing
            //    null list entry. Hopefully the single comparison will not be too
            //    arduous. Alternatively the 'break' could be replced with a return
            //    but that's shabby programming.

            if ((beginning == srclen) && (keepNulls))
            {
                if (srclen != 0)
                    tokens.Add(new LSL_String(""));
            }

            return tokens;
        }
Exemple #38
0
 /// <summary>
  /// Return information regarding various simulator statistics (sim fps, physics fps, time
  /// dilation, total number of prims, total number of active scripts, script lps, various
  /// timing data, packets in/out, etc. Basically much the information that's shown in the
  /// client's Statistics Bar (Ctrl-Shift-1)
  /// </summary>
  /// <returns>List of floats</returns>
  public LSL_List osGetRegionStats()
  {
      CheckThreatLevel(ThreatLevel.Moderate, "osGetRegionStats");
      m_host.AddScriptLPS(1);
      LSL_List ret = new LSL_List();
      float[] stats = World.StatsReporter.LastReportedSimStats;
      
      for (int i = 0; i < 21; i++)
      {
          ret.Add(new LSL_Float(stats[i]));
      }
      return ret;
  }
Exemple #39
0
 public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers)
 {
     m_host.AddScriptLPS(1);
     return this.ParseString(src, separators, spacers, false);
 }
Exemple #40
0
 public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules)
 {
     CheckThreatLevel(ThreatLevel.High, "osSetPrimitiveParams");
     m_host.AddScriptLPS(1);
     InitLSL();
     
     m_LSL_Api.SetPrimitiveParamsEx(prim, rules, "osSetPrimitiveParams");
 }
Exemple #41
0
 public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers)
 {
     m_host.AddScriptLPS(1);
     return this.ParseString(src, separators, spacers, true);
 }
Exemple #42
0
        public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints)
        {
            CheckThreatLevel(ThreatLevel.Moderate, "osGetNumberOfAttachments");

            m_host.AddScriptLPS(1);

            UUID targetUUID;
            ScenePresence target;
            LSL_List resp = new LSL_List();

            if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
            {
                foreach (object point in attachmentPoints.Data)
                {
                    LSL_Integer ipoint = new LSL_Integer(
                        (point is LSL_Integer || point is int || point is uint) ?
                            (int)point :
                            0
                    );
                    resp.Add(ipoint);
                    if (ipoint == 0)
                    {
                        // indicates zero attachments
                        resp.Add(new LSL_Integer(0));
                    }
                    else
                    {
                        // gets the number of attachments on the attachment point
                        resp.Add(new LSL_Integer(target.GetAttachments((uint)ipoint).Count));
                    }
                }
            }

            return resp;
        }
Exemple #43
0
        /// <summary>
        /// illListReplaceList removes the sub-list defined by the inclusive indices
        /// start and end and inserts the src list in its place. The inclusive
        /// nature of the indices means that at least one element must be deleted
        /// if the indices are within the bounds of the existing list. I.e. 2,2
        /// will remove the element at index 2 and replace it with the source
        /// list. Both indices may be negative, with the usual interpretation. An
        /// interesting case is where end is lower than start. As these indices
        /// bound the list to be removed, then 0->end, and start->lim are removed
        /// and the source list is added as a suffix.
        /// </summary>

        public LSL_List llListReplaceList(LSL_List dest, LSL_List src, int start, int end)
        {
            LSL_List pref = null;

            m_host.AddScriptLPS(1);

            // Note that although we have normalized, both
            // indices could still be negative.
            if (start < 0)
            {
                start = start+dest.Length;
            }

            if (end < 0)
            {
                end = end+dest.Length;
            }
            // The comventional case, remove a sequence starting with
            // start and ending with end. And then insert the source
            // list.
            if (start <= end)
            {
                // If greater than zero, then there is going to be a
                // surviving prefix. Otherwise the inclusive nature
                // of the indices mean that we're going to add the
                // source list as a prefix.
                if (start > 0)
                {
                    pref = dest.GetSublist(0,start-1);
                    // Only add a suffix if there is something
                    // beyond the end index (it's inclusive too).
                    if (end + 1 < dest.Length)
                    {
                        return pref + src + dest.GetSublist(end + 1, -1);
                    }
                    else
                    {
                        return pref + src;
                    }
                }
                // If start is less than or equal to zero, then
                // the new list is simply a prefix. We still need to
                // figure out any necessary surgery to the destination
                // based upon end. Note that if end exceeds the upper
                // bound in this case, the entire destination list
                // is removed.
                else
                {
                    if (end + 1 < dest.Length)
                    {
                        return src + dest.GetSublist(end + 1, -1);
                    }
                    else
                    {
                        return src;
                    }
                }
            }
            // Finally, if start > end, we strip away a prefix and
            // a suffix, to leave the list that sits <between> ens
            // and start, and then tag on the src list. AT least
            // that's my interpretation. We can get sublist to do
            // this for us. Note that one, or both of the indices
            // might have been negative.
            else
            {
                return dest.GetSublist(end + 1, start - 1) + src;
            }
        }
Exemple #44
0
        public LSL_String osRequestSecureURL(LSL_List options)
        {
            CheckThreatLevel(ThreatLevel.Moderate, "osRequestSecureURL");
            m_host.AddScriptLPS(1);
            
            Hashtable opts = new Hashtable();
            for (int i = 0 ; i < options.Length ; i++)
            {
                object opt = options.Data[i];
                if (opt.ToString() == "allowXss")
                    opts["allowXss"] = true;
            }

            if (m_UrlModule != null)
                return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID, opts).ToString();
            return UUID.Zero.ToString();
        }
        public void TestllGetLinkPrimitiveParams()
        {
            TestHelpers.InMethod();
            TestHelpers.EnableLogging();

            UUID ownerId = TestHelpers.ParseTail(0x1);

            SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10);

            grp1.AbsolutePosition = new Vector3(10, 11, 12);
            m_scene.AddSceneObject(grp1);

            LSL_Api apiGrp1 = new LSL_Api();

            apiGrp1.Initialize(m_engine, grp1.RootPart, null, null);

            // Check simple 1 prim case
            {
                LSL_List resList
                    = apiGrp1.llGetLinkPrimitiveParams(1, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));

                Assert.That(resList.Length, Is.EqualTo(1));
            }

            // Check 2 prim case
            {
                LSL_List resList
                    = apiGrp1.llGetLinkPrimitiveParams(
                          1,
                          new LSL_List(
                              new LSL_Integer(ScriptBaseClass.PRIM_ROTATION),
                              new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET),
                              new LSL_Integer(2),
                              new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));

                Assert.That(resList.Length, Is.EqualTo(2));
            }

            // Check invalid parameters are ignored
            {
                LSL_List resList
                    = apiGrp1.llGetLinkPrimitiveParams(3, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));

                Assert.That(resList.Length, Is.EqualTo(0));
            }

            // Check all parameters are ignored if an initial bad link is given
            {
                LSL_List resList
                    = apiGrp1.llGetLinkPrimitiveParams(
                          3,
                          new LSL_List(
                              new LSL_Integer(ScriptBaseClass.PRIM_ROTATION),
                              new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET),
                              new LSL_Integer(1),
                              new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));

                Assert.That(resList.Length, Is.EqualTo(0));
            }

            // Check only subsequent parameters are ignored when we hit the first bad link number
            {
                LSL_List resList
                    = apiGrp1.llGetLinkPrimitiveParams(
                          1,
                          new LSL_List(
                              new LSL_Integer(ScriptBaseClass.PRIM_ROTATION),
                              new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET),
                              new LSL_Integer(3),
                              new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));

                Assert.That(resList.Length, Is.EqualTo(1));
            }
        }