Esempio n. 1
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);
            }
        }
        public bool SendChatMessageToNeighbors(OSChatMessage message, ChatSourceType type, RegionInfo region)
        {
            bool RetVal = false;

            if (!m_KnownNeighbors.ContainsKey(region.RegionID))
            {
                return(RetVal);
            }

            foreach (GridRegion neighbor in m_KnownNeighbors[region.RegionID])
            {
                if (neighbor.RegionID == region.RegionID)
                {
                    continue;
                }
                Scene scene = FindSceneByUUID(region.RegionID);
                if (scene != null)
                {
                    IChatModule chatModule = scene.RequestModuleInterface <IChatModule>();
                    if (chatModule != null && !RetVal)
                    {
                        chatModule.DeliverChatToAvatars(type, message);
                        RetVal = true;
                    }
                }
            }
            return(RetVal);
        }
        private string ProcessAvatarChatCommand(ScenePresence presence, OSDMap map)
        {
            IChatModule chatModule = presence.Scene.RequestModuleInterface <IChatModule>();

            if (chatModule == null)
            {
                return(BuildCommandResponse(RemoteCommandResponse.ERROR, "No chat module found"));
            }

            OSDMap dataMap = (OSDMap)map["data"];

            int    channel = dataMap["channel"].AsInteger();
            string message = dataMap["text"].AsString();

            //Send the message
            chatModule.OnChatFromClient(presence.ControllingClient, new OSChatMessage
            {
                Channel         = channel,
                DestinationUUID = UUID.Zero,
                From            = string.Empty,
                Message         = message,
                Position        = presence.AbsolutePosition,
                Scene           = presence.Scene,
                Sender          = presence.ControllingClient,
                SenderUUID      = presence.UUID,
                Type            = ChatTypeEnum.Say
            });

            return(BuildCommandResponse(RemoteCommandResponse.OK, null));
        }
Esempio n. 4
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);
            }
        }
        public void Initialize(IChatModule module)
        {
            //Show gods in chat by adding the godPrefix to their name
            m_indicategod = module.Config.GetBoolean("indicate_god", true);
            m_godPrefix   = module.Config.GetString("godPrefix", "");

            //Send incoming users a message
            m_useWelcomeMessage = module.Config.GetBoolean("useWelcomeMessage", true);
            m_welcomeMessage    = module.Config.GetString("welcomeMessage", "");

            //Tell all users about an incoming or outgoing agent
            m_announceNewAgents    = module.Config.GetBoolean("announceNewAgents", true);
            m_announceClosedAgents = module.Config.GetBoolean("announceClosingAgents", true);
            m_useAuth  = module.Config.GetBoolean("use_Auth", true);
            chatModule = module;
            module.RegisterChatPlugin("Chat", this);
            module.RegisterChatPlugin("all", this);

            // load web settings overrides (if any)
            //IGenericsConnector generics = Framework.Utilities.DataManager.RequestPlugin<IGenericsConnector> ();
            //if (generics != null)
            //{
            //    var settings = generics.GetGeneric<Universe.Modules.Web.GridSettings> (UUID.Zero, "GridSettings", "Settings");
            //    if (settings != null)
            //        WelcomeMessage = settings.WelcomeMessage;
            //}
        }
Esempio n. 6
0
        private void chatting(Object sender, IrcMessageEventArgs <TextMessage> e, IScenePresence presence)
        {
            IChatModule chatModule = m_scene.RequestModuleInterface <IChatModule>();

            if (chatModule != null)
            {
                if (e.Message.Targets.Count > 0 && e.Message.Targets[0] == clients[presence.UUID].User.Nick)
                {
                    UUID fakeUUID;
                    if (!m_ircUsersToFakeUUIDs.TryGetValue(e.Message.Sender.UserName, out fakeUUID))
                    {
                        fakeUUID = UUID.Random();
                        m_ircUsersToFakeUUIDs[e.Message.Sender.UserName] = fakeUUID;
                    }
                    presence.ControllingClient.SendInstantMessage(new GridInstantMessage()
                    {
                        FromAgentID   = fakeUUID,
                        FromAgentName = e.Message.Sender.Nick,
                        ToAgentID     = presence.UUID,
                        Dialog        = (byte)InstantMessageDialog.MessageFromAgent,
                        Message       = e.Message.Text,
                        FromGroup     = false,
                        SessionID     = UUID.Zero,
                        Offline       = 0,
                        BinaryBucket  = new byte[0],
                        Timestamp     = (uint)Util.UnixTimeSinceEpoch()
                    });
                }
                else
                {
                    chatModule.TrySendChatMessage(presence, presence.AbsolutePosition, UUID.Zero,
                                                  e.Message.Targets[0] + " - " + e.Message.Sender.Nick, ChatTypeEnum.Say, e.Message.Text, ChatSourceType.Agent, 20);
                }
            }
        }
Esempio n. 7
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);
                }
            }
        }
Esempio n. 8
0
        public void llRegionSayTo(LSL_Key toID, int channelID, string text)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }

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

            if (text.Length > 1023)
            {
                text = text.Substring(0, 1023);
            }
            if (channelID == 0)
            {
                IScenePresence presence = World.GetScenePresence(UUID.Parse(toID.m_string));
                if (presence != null)
                {
                    if (chatModule != null)
                    {
                        chatModule.TrySendChatMessage(presence, m_host.AbsolutePosition,
                                                      m_host.UUID, m_host.Name, ChatTypeEnum.Say, text,
                                                      ChatSourceType.Object, 10000);
                    }
                }
            }

            if (m_comms != null)
            {
                m_comms.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID,
                                       UUID.Parse(toID.m_string), text);
            }
        }
Esempio n. 9
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);
                    }
                }
            }
        }
Esempio n. 11
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);
            }
        }
Esempio n. 12
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;
        }
Esempio n. 13
0
        private static void JoinChannel(Client client, string channel, IScenePresence presence)
        {
            client.SendJoin(channel);
            IChatModule chatModule = presence.Scene.RequestModuleInterface <IChatModule>();

            if (chatModule != null)
            {
                chatModule.TrySendChatMessage(presence, presence.AbsolutePosition, UUID.Zero,
                                              "System", ChatTypeEnum.Say, "You joined " + channel, ChatSourceType.Agent, 20);
            }
        }
Esempio n. 14
0
        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;
        }
Esempio n. 15
0
        public void RegionLoaded(IScene scene)
        {
            IChatModule chatmodule = scene.RequestModuleInterface <IChatModule>();

            if (chatmodule != null && m_settings != null)
            {
                //Set default chat ranges
                m_settings.WhisperDistance = chatmodule.WhisperDistance;
                m_settings.SayDistance     = chatmodule.SayDistance;
                m_settings.ShoutDistance   = chatmodule.ShoutDistance;
            }
        }
Esempio n. 16
0
        public void llOwnerSay(string msg)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }

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

            if (chatModule != null)
            {
                chatModule.SimChatBroadcast(msg, ChatTypeEnum.Owner, 0,
                                            m_host.AbsolutePosition, m_host.Name, m_host.UUID, false, UUID.Zero, World);
            }
        }
 public void Initialize(IChatModule module)
 {
     //Show gods in chat by adding the godPrefix to their name
     m_indicategod = module.Config.GetBoolean("indicate_god", true);
     m_godPrefix = module.Config.GetString("godPrefix", "");
     //Send incoming users a message
     m_useWelcomeMessage = module.Config.GetBoolean("useWelcomeMessage", true);
     m_welcomeMessage = module.Config.GetString("welcomeMessage", "");
     //Tell all users about an incoming or outgoing agent
     m_announceNewAgents = module.Config.GetBoolean("announceNewAgents", true);
     m_announceClosedAgents = module.Config.GetBoolean("announceClosingAgents", true);
     m_useAuth = module.Config.GetBoolean("use_Auth", true);
     chatModule = module;
     module.RegisterChatPlugin("Chat", this);
     module.RegisterChatPlugin("all", this);
 }
Esempio n. 18
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);
            }
        }
Esempio n. 19
0
 public void Initialize(IChatModule module)
 {
     //Show gods in chat by adding the godPrefix to their name
     m_indicategod = module.Config.GetBoolean("indicate_god", true);
     m_godPrefix   = module.Config.GetString("godPrefix", "");
     //Send incoming users a message
     m_useWelcomeMessage = module.Config.GetBoolean("useWelcomeMessage", true);
     m_welcomeMessage    = module.Config.GetString("welcomeMessage", "");
     //Tell all users about an incoming or outgoing agent
     m_announceNewAgents    = module.Config.GetBoolean("announceNewAgents", true);
     m_announceClosedAgents = module.Config.GetBoolean("announceClosingAgents", true);
     m_useAuth  = module.Config.GetBoolean("use_Auth", true);
     chatModule = module;
     module.RegisterChatPlugin("Chat", this);
     module.RegisterChatPlugin("all", this);
 }
Esempio n. 20
0
        public void aaSayTo(string userID, string text)
        {
            ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "AASayTo", m_host, "AA");


            UUID AgentID;

            if (UUID.TryParse(userID, out AgentID))
            {
                IChatModule chatModule = World.RequestModuleInterface <IChatModule>();
                if (chatModule != null)
                {
                    chatModule.SimChatBroadcast(text, ChatTypeEnum.SayTo, 0,
                                                m_host.AbsolutePosition, m_host.Name, m_host.UUID, false, AgentID, World);
                }
            }
        }
Esempio n. 21
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);
         }
     }
 }
Esempio n. 22
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
                }
            }
        }
        //
        //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);
        }
 public void RegionLoaded(IScene scene)
 {
     IChatModule chatmodule = scene.RequestModuleInterface<IChatModule>();
     if (chatmodule != null && m_settings != null)
     {
         //Set default chat ranges
         m_settings.WhisperDistance = chatmodule.WhisperDistance;
         m_settings.SayDistance = chatmodule.SayDistance;
         m_settings.ShoutDistance = chatmodule.ShoutDistance;
     }
     /*IScriptModule scriptmodule = scene.RequestModuleInterface<IScriptModule>();
     if (scriptmodule != null)
     {
         List<string> FunctionNames = scriptmodule.GetAllFunctionNames();
         foreach (string FunctionName in FunctionNames)
         {
             m_settings.LSLCommands.Add(OSD.FromString(FunctionName));
         }
     }*/
 }
Esempio n. 25
0
 public override bool Start()
 {
     _module = new ChatModule(this);
     return true;
 }
 public void Initialize(IChatModule module)
 {
     module.RegisterChatPlugin("calc", this);
 }
 public void Initialize(IChatModule module)
 {
     m_indicategod = module.Config.GetBoolean("indicate_god", true);
     m_godPrefix = module.Config.GetString("godPrefix", "");
     m_useWelcomeMessage = module.Config.GetBoolean("useWelcomeMessage", true);
     m_welcomeMessage = module.Config.GetString("welcomeMessage", "");
     m_announceNewAgents = module.Config.GetBoolean("announceNewAgents", true);
     m_announceClosedAgents = module.Config.GetBoolean("announceClosingAgents", true);
     m_useAuth = module.Config.GetBoolean("use_Auth", true);
     chatModule = module;
     module.RegisterChatPlugin("Chat", this);
     module.RegisterChatPlugin("all", this);
 }
            /// <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();
            }
 public void Initialize(IChatModule module)
 {
     module.RegisterChatPlugin("calc", this);
 }
 public void Initialize(IChatModule module)
 {
     //We register all so that we can hook up to all chat when they enable us
     module.RegisterChatPlugin("all", this);
 }
        public void Initialize (IChatModule module)
        {
            //Show gods in chat by adding the godPrefix to their name
            m_indicategod = module.Config.GetBoolean ("indicate_god", true);
            m_godPrefix = module.Config.GetString ("godPrefix", "");

            //Send incoming users a message
            m_useWelcomeMessage = module.Config.GetBoolean ("useWelcomeMessage", true);
            m_welcomeMessage = module.Config.GetString ("welcomeMessage", "");

            //Tell all users about an incoming or outgoing agent
            m_announceNewAgents = module.Config.GetBoolean ("announceNewAgents", true);
            m_announceClosedAgents = module.Config.GetBoolean ("announceClosingAgents", true);
            m_useAuth = module.Config.GetBoolean ("use_Auth", true);
            chatModule = module;
            module.RegisterChatPlugin ("Chat", this);
            module.RegisterChatPlugin ("all", this);

            // load web settings overrides (if any)
            //IGenericsConnector generics = Framework.Utilities.DataManager.RequestPlugin<IGenericsConnector> ();
            //if (generics != null)
            //{
            //    var settings = generics.GetGeneric<Universe.Modules.Web.GridSettings> (UUID.Zero, "GridSettings", "Settings");
            //    if (settings != null)
            //        WelcomeMessage = settings.WelcomeMessage;
            //}
        }
Esempio n. 32
0
 public void Initialize(IChatModule module)
 {
     //We register all so that we can hook up to all chat when they enable us
     module.RegisterChatPlugin("all", this);
 }