Exemple #1
0
        public void llSay(int channelID, object m_text)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }

            string text = m_text.ToString();

            if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel))
            {
                MainConsole.Instance.Debug(text);
            }
            else
            {
                if (text.Length > 1023)
                {
                    text = text.Substring(0, 1023);
                }

                IChatModule chatModule = World.RequestModuleInterface <IChatModule>();
                if (chatModule != null)
                {
                    chatModule.SimChat(text, ChatTypeEnum.Say, channelID,
                                       m_host.ParentEntity.RootChild.AbsolutePosition, m_host.Name, m_host.UUID, false,
                                       World);
                }

                if (m_comms != null)
                {
                    m_comms.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, text);
                }
            }
        }
Exemple #2
0
        public void aaSayDistance(int channelID, LSL_Float Distance, string text)
        {
            ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "AASayDistance", m_host, "AA");

            if (text.Length > 1023)
            {
                text = text.Substring(0, 1023);
            }

            IChatModule chatModule = World.RequestModuleInterface <IChatModule>();

            if (chatModule != null)
            {
                chatModule.SimChat(text, ChatTypeEnum.Custom, channelID,
                                   m_host.ParentEntity.RootChild.AbsolutePosition, m_host.Name,
                                   m_host.UUID, false, false, (float)Distance.value, UUID.Zero, World);
            }

            IWorldComm wComm = World.RequestModuleInterface <IWorldComm>();

            if (wComm != null)
            {
                wComm.DeliverMessage(ChatTypeEnum.Custom, channelID, m_host.Name, m_host.UUID, text, (float)Distance.value);
            }
        }
Exemple #3
0
        public void llShout(int channelID, string text)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }

            if (text.Length > 1023)
            {
                text = text.Substring(0, 1023);
            }

            IChatModule chatModule = World.RequestModuleInterface <IChatModule>();

            if (chatModule != null)
            {
                chatModule.SimChat(text, ChatTypeEnum.Shout, channelID,
                                   m_host.ParentEntity.RootChild.AbsolutePosition, m_host.Name, m_host.UUID, true, World);
            }

            if (m_comms != null)
            {
                m_comms.DeliverMessage(ChatTypeEnum.Shout, channelID, m_host.Name, m_host.UUID, text);
            }
        }
Exemple #4
0
        public void llRegionSay(int channelID, string text)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }

            if (text.Length > 1023)
            {
                text = text.Substring(0, 1023);
            }

            if (channelID == 0) //0 isn't normally allowed, so check against a higher threat level
            {
                if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "LSL", m_host, "LSL", m_itemID))
                {
                    return;
                }
            }

            IChatModule chatModule = World.RequestModuleInterface <IChatModule>();

            if (chatModule != null)
            {
                chatModule.SimChat(text, ChatTypeEnum.Region, channelID,
                                   m_host.ParentEntity.RootChild.AbsolutePosition, m_host.Name, m_host.UUID, false,
                                   World);
            }

            if (m_comms != null)
            {
                m_comms.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text);
            }
        }
        public void llStartAnimation(string anim)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }


            UUID invItemID = InventorySelf();

            if (invItemID == UUID.Zero)
            {
                return;
            }

            TaskInventoryItem item;

            lock (m_host.TaskInventory) {
                if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
                {
                    return;
                }
                item = m_host.TaskInventory[InventorySelf()];
            }

            if (item.PermsGranter == UUID.Zero)
            {
                return;
            }

            if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
            {
                IScenePresence presence = World.GetScenePresence(item.PermsGranter);

                if (presence != null)
                {
                    // Do NOT try to parse UUID, animations cannot be triggered by ID
                    UUID animID = KeyOrName(anim, AssetType.Animation, false);
                    if (animID == UUID.Zero)
                    {
                        bool RetVal = presence.Animator.AddAnimation(anim, m_host.UUID);
                        if (!RetVal)
                        {
                            IChatModule chatModule = World.RequestModuleInterface <IChatModule>();
                            if (chatModule != null)
                            {
                                chatModule.SimChat("Could not find animation '" + anim + "'.",
                                                   ChatTypeEnum.DebugChannel, 2147483647, m_host.AbsolutePosition,
                                                   m_host.Name, m_host.UUID, false, World);
                            }
                        }
                    }
                    else
                    {
                        presence.Animator.AddAnimation(animID, m_host.UUID);
                    }
                }
            }
        }
Exemple #6
0
        // This callback allows the PhysicsScene to call back to its caller (the SceneGraph) and
        // alert the user of errors by using the debug channel in the same way that scripts alert
        // the user of compile errors.

        // This routine is normally called from within a lock (OdeLock) from within the OdePhysicsScene
        // WARNING: be careful of deadlocks here if you manipulate the scene. Remember you are being called
        // from within the OdePhysicsScene.
        public void jointErrorMessage(PhysicsJoint joint, string message)
        {
            if (joint != null)
            {
                if (joint.ErrorMessageCount > PhysicsJoint.maxErrorMessages)
                {
                    return;
                }

                SceneObjectPart jointProxyObject = GetSceneObjectPart(joint.ObjectNameInScene);
                if (jointProxyObject != null)
                {
                    IChatModule chatModule = m_scene.RequestModuleInterface <IChatModule>();
                    if (chatModule != null)
                    {
                        chatModule.SimChat("[NINJA]: " + message,
                                           ChatTypeEnum.DebugChannel,
                                           2147483647,
                                           jointProxyObject.AbsolutePosition,
                                           jointProxyObject.Name,
                                           jointProxyObject.UUID,
                                           false, m_scene);
                    }

                    joint.ErrorMessageCount++;

                    if (joint.ErrorMessageCount > PhysicsJoint.maxErrorMessages)
                    {
                        if (chatModule != null)
                        {
                            chatModule.SimChat("[NINJA]: Too many messages for this joint, suppressing further messages.",
                                               ChatTypeEnum.DebugChannel,
                                               2147483647,
                                               jointProxyObject.AbsolutePosition,
                                               jointProxyObject.Name,
                                               jointProxyObject.UUID,
                                               false, m_scene);
                        }
                    }
                }
                else
                {
                    // couldn't find the joint proxy object; the error message is silently suppressed
                }
            }
        }
Exemple #7
0
        public void SendChatMessage(int sayType, string message, int channel)
        {
            IChatModule chatModule = m_object.Scene.RequestModuleInterface <IChatModule>();

            if (chatModule != null)
            {
                chatModule.SimChat(message, (ChatTypeEnum)sayType, channel,
                                   m_object.RootChild.AbsolutePosition, m_object.Name, m_object.UUID, false, m_object.Scene);
            }
        }
Exemple #8
0
        public void DisplayUserNotification(string message, string stage, bool postScriptCAPSError, bool IsError)
        {
            if (message == "")
            {
                return; //No blank messages
            }
            IScenePresence presence = World.GetScenePresence(Part.OwnerID);

            if (presence != null && (!PostOnRez) && postScriptCAPSError)
            {
                presence.ControllingClient.SendAgentAlertMessage(
                    m_ScriptEngine.ChatCompileErrorsToDebugChannel
                        ? "Script saved with errors, check debug window!"
                        : "Script saved with errors!",
                    false);
            }

            if (postScriptCAPSError)
            {
                m_ScriptEngine.ScriptErrorReporter.AddError(ItemID, new ArrayList(message.Split('\n')));
            }

            // DISPLAY ERROR ON CONSOLE
            if (m_ScriptEngine.DisplayErrorsOnConsole)
            {
                string consoletext = IsError ? "Error " : "Warning ";
                consoletext += stage + " script:\n" + message + " prim name: " + Part.Name + "@ " +
                               Part.AbsolutePosition +
                               (InventoryItem != null ? ("item name: " + InventoryItem.Name) : (" itemID: " + ItemID)) +
                               ", CompiledFile: " + AssemblyName;
                MainConsole.Instance.Error(consoletext);
            }

            // DISPLAY ERROR INWORLD
            string inworldtext = IsError ? "Error " : "Warning ";

            inworldtext += stage + " script: " + message;
            if (inworldtext.Length > 1100)
            {
                inworldtext = inworldtext.Substring(0, 1099);
            }

            if (m_ScriptEngine.ChatCompileErrorsToDebugChannel)
            {
                IChatModule chatModule = World.RequestModuleInterface <IChatModule>();
                if (chatModule != null)
                {
                    chatModule.SimChat(inworldtext, ChatTypeEnum.DebugChannel,
                                       2147483647, Part.AbsolutePosition, Part.Name, Part.UUID, false, World);
                }
            }
            m_ScriptEngine.ScriptFailCount++;
            m_ScriptEngine.ScriptErrorMessages += inworldtext;
        }
        public bool Check()
        {
            bool needToContinue = false;
            foreach (IHttpRequestModule iHttpReq in m_modules)
            {
                IServiceRequest httpInfo = null;

                if (iHttpReq != null)
                {
                    httpInfo = iHttpReq.GetNextCompletedRequest();
                    if (!needToContinue)
                        needToContinue = iHttpReq.GetRequestCount() > 0;
                }

                if (httpInfo == null)
                    continue;

                while (httpInfo != null)
                {
                    IHttpRequestClass info = (IHttpRequestClass) httpInfo;
                    //MainConsole.Instance.Debug("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status);

                    // Deliver data to prim's remote_data handler

                    iHttpReq.RemoveCompletedRequest(info);

                    object[] resobj = new object[]
                                          {
                                              new LSL_Types.LSLString(info.ReqID.ToString()),
                                              new LSL_Types.LSLInteger(info.Status),
                                              new LSL_Types.list(info.Metadata),
                                              new LSL_Types.LSLString(info.ResponseBody)
                                          };

                    m_ScriptEngine.AddToObjectQueue(info.PrimID, "http_response", new DetectParams[0], resobj);
                    if (info.Status == (int)499 && //Too many for this prim
                        info.VerbroseThrottle)
                    {
                        ISceneChildEntity part = m_ScriptEngine.Scene.GetSceneObjectPart(info.PrimID);
                        if (part != null)
                        {
                            IChatModule chatModule = m_ScriptEngine.Scene.RequestModuleInterface<IChatModule>();
                            if (chatModule != null)
                                chatModule.SimChat(
                                    part.Name + "(" + part.AbsolutePosition +
                                    ") http_response error: Too many outgoing requests.", ChatTypeEnum.DebugChannel,
                                    2147483647, part.AbsolutePosition, part.Name, part.UUID, false, m_ScriptEngine.Scene);
                        }
                    }
                    httpInfo = iHttpReq.GetNextCompletedRequest();
                }
            }
            return needToContinue;
        }
Exemple #10
0
        public void Say(string msg, int channel)
        {
            if (!CanEdit())
            {
                return;
            }

            ISceneChildEntity sop        = GetSOP();
            IChatModule       chatModule = m_rootScene.RequestModuleInterface <IChatModule>();

            if (chatModule != null)
            {
                chatModule.SimChat(msg, ChatTypeEnum.Say, channel, sop.AbsolutePosition,
                                   sop.Name, sop.UUID, false, m_rootScene);
            }
        }
Exemple #11
0
 void TriggerAlert(string function, LimitDef d, string message, ISceneChildEntity host)
 {
     if (d.Alert == LimitAlert.Console || d.Alert == LimitAlert.ConsoleAndInworld)
     {
         MainConsole.Instance.Warn("[Limitor]: " + message);
     }
     if (d.Alert == LimitAlert.Inworld || d.Alert == LimitAlert.ConsoleAndInworld)
     {
         IChatModule chatModule = host.ParentEntity.Scene.RequestModuleInterface <IChatModule>();
         if (chatModule != null)
         {
             chatModule.SimChat("[Limitor]: " + message, ChatTypeEnum.DebugChannel,
                                2147483647, host.AbsolutePosition, host.Name, host.UUID, false,
                                host.ParentEntity.Scene);
         }
     }
 }
        //
        //Dumps an error message on the debug console.
        //

        internal void modShoutError(string message)
        {
            if (message.Length > 1023)
            {
                message = message.Substring(0, 1023);
            }

            IChatModule chatModule = World.RequestModuleInterface <IChatModule>();

            if (chatModule != null)
            {
                chatModule.SimChat(message, ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL,
                                   m_host.ParentEntity.RootChild.AbsolutePosition, m_host.Name, m_host.UUID, true, World);
            }

            IWorldComm wComm = World.RequestModuleInterface <IWorldComm>();

            wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
        }
            /// <summary>
            ///     Called once new texture data has been received for this updater.
            /// </summary>
            public void DataReceived(byte [] data, IScene scene)
            {
                ISceneChildEntity part = scene.GetSceneObjectPart(PrimID);

                if (part == null || data == null || data.Length <= 1)
                {
                    IChatModule chatModule = scene.RequestModuleInterface <IChatModule> ();
                    if (chatModule != null)
                    {
                        string msg =
                            string.Format("DynamicTextureModule: Error preparing image using URL {0}", Url);
                        if (part != null)
                        {
                            chatModule.SimChat(msg, ChatTypeEnum.Say, 0,
                                               part.ParentEntity.AbsolutePosition, part.Name, part.UUID, false, scene);
                        }
                        else
                        {
                            chatModule.SimChat(msg, ChatTypeEnum.Say, 0,
                                               new Vector3(), "Unknown", UUID.Zero, false, scene);
                        }
                    }
                    return;
                }

                byte []   assetData = null;
                AssetBase oldAsset  = null;

                if (BlendWithOldTexture)
                {
                    Primitive.TextureEntryFace defaultFace = part.Shape.Textures.DefaultTexture;
                    if (defaultFace != null)
                    {
                        oldAsset = scene.AssetService.Get(defaultFace.TextureID.ToString());

                        if (oldAsset != null)
                        {
                            assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha, scene);
                        }
                    }
                }

                if (assetData == null)
                {
                    assetData = new byte [data.Length];
                    Array.Copy(data, assetData, data.Length);
                }

                AssetBase asset = null;

                if (LastAssetID != UUID.Zero)
                {
                    asset = scene.AssetService.Get(LastAssetID.ToString());
                    if (asset != null)
                    {
                        asset.Description = string.Format("URL image : {0}", Url);
                        asset.Data        = assetData;
                        if ((asset.Flags & AssetFlags.Local) == AssetFlags.Local)
                        {
                            asset.Flags = asset.Flags & ~AssetFlags.Local;
                        }
                        if (((asset.Flags & AssetFlags.Temporary) == AssetFlags.Temporary) != ((Disp & DISP_TEMP) != 0))
                        {
                            if ((Disp & DISP_TEMP) != 0)
                            {
                                asset.Flags |= AssetFlags.Temporary;
                            }
                            else
                            {
                                asset.Flags = asset.Flags & ~AssetFlags.Temporary;
                            }
                        }
                        asset.ID = scene.AssetService.Store(asset);
                    }
                }

                // either we have no LastAssetID or the above failed to retrieve the asset...so...
                if (asset == null)
                {
                    // Create a new asset for user
                    asset = new AssetBase(UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000),
                                          AssetType.Texture,
                                          scene.RegionInfo.RegionID)
                    {
                        Data = assetData, Description = string.Format("URL image : {0}", Url)
                    };
                    if ((Disp & DISP_TEMP) != 0)
                    {
                        asset.Flags = AssetFlags.Temporary;
                    }
                    asset.ID = scene.AssetService.Store(asset);
                }

                IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface <IJ2KDecoder> ();

                if (cacheLayerDecode != null)
                {
                    cacheLayerDecode.Decode(asset.ID, asset.Data);
                    cacheLayerDecode = null;
                    LastAssetID      = asset.ID;
                }

                UUID oldID = UUID.Zero;

                lock (part) {
                    // mostly keep the values from before
                    Primitive.TextureEntry tmptex = part.Shape.Textures;

                    // remove the old asset from the cache
                    oldID = tmptex.DefaultTexture.TextureID;

                    if (Face == ALL_SIDES)
                    {
                        tmptex.DefaultTexture.TextureID = asset.ID;
                    }
                    else
                    {
                        try {
                            Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face);
                            texface.TextureID          = asset.ID;
                            tmptex.FaceTextures [Face] = texface;
                        } catch (Exception) {
                            tmptex.DefaultTexture.TextureID = asset.ID;
                        }
                    }

                    // I'm pretty sure we always want to force this to true
                    // I'm pretty sure no one wants to set fullbright true if it wasn't true before.
                    // tmptex.DefaultTexture.Fullbright = true;

                    part.UpdateTexture(tmptex, true);
                }

                if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
                {
                    if (oldAsset == null)
                    {
                        oldAsset = scene.AssetService.Get(oldID.ToString());
                    }
                    if (oldAsset != null)
                    {
                        if ((oldAsset.Flags & AssetFlags.Temporary) == AssetFlags.Temporary)
                        {
                            scene.AssetService.Delete(oldID);
                        }
                    }
                }

                if (oldAsset != null)
                {
                    oldAsset.Dispose();
                }
                asset.Dispose();
            }