diff --git a/OpenSim/Framework/General/Types/AgentWearable.cs b/OpenSim/Framework/General/Types/AgentWearable.cs index b503ea21ab..ecd45d51b7 100644 --- a/OpenSim/Framework/General/Types/AgentWearable.cs +++ b/OpenSim/Framework/General/Types/AgentWearable.cs @@ -39,6 +39,12 @@ namespace OpenSim.Framework.Types } + public AvatarWearable( LLUUID itemId, LLUUID assetId ) + { + AssetID = assetId; + ItemID = itemId; + } + public static AvatarWearable[] DefaultWearables { get diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 8ea9347bad..4e844703c1 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -750,7 +750,7 @@ namespace OpenSim break; case "modules": m_log.Error("The currently loaded shared modules are:"); - foreach (OpenSim.Region.Environment.Interfaces.IRegionModule module in m_moduleLoader.LoadedSharedModules.Values) + foreach (OpenSim.Region.Environment.Interfaces.IRegionModule module in m_moduleLoader.GetLoadedSharedModules ) { m_log.Error("Shared Module: " + module.Name); } diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index 442ee77f87..c0dd52a731 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -27,6 +27,7 @@ */ using System; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Reflection; @@ -42,10 +43,10 @@ namespace OpenSim.Region.Environment { public Dictionary LoadedAssemblys = new Dictionary(); - public List LoadedModules = new List(); - public Dictionary LoadedSharedModules = new Dictionary(); + private readonly List m_loadedModules = new List(); + private Dictionary m_loadedSharedModules = new Dictionary(); private readonly LogBase m_log; - private IConfigSource m_config; + private readonly IConfigSource m_config; public ModuleLoader(LogBase log, IConfigSource config) { @@ -53,6 +54,16 @@ namespace OpenSim.Region.Environment m_config = config; } + public IRegionModule[] GetLoadedSharedModules + { + get + { + IRegionModule[] regionModules = new IRegionModule[ m_loadedSharedModules.Count ]; + m_loadedSharedModules.Values.CopyTo( regionModules, 0 ); + return regionModules; + } + } + public void PickupModules(Scene scene, string moduleDir) { DirectoryInfo dir = new DirectoryInfo(moduleDir); @@ -66,19 +77,19 @@ namespace OpenSim.Region.Environment public void LoadDefaultSharedModules() { DynamicTextureModule dynamicModule = new DynamicTextureModule(); - LoadedSharedModules.Add(dynamicModule.Name, dynamicModule); + m_loadedSharedModules.Add(dynamicModule.Name, dynamicModule); ChatModule chat = new ChatModule(); - LoadedSharedModules.Add(chat.Name, chat); + m_loadedSharedModules.Add(chat.Name, chat); InstantMessageModule imMod = new InstantMessageModule(); - LoadedSharedModules.Add(imMod.Name, imMod); + m_loadedSharedModules.Add(imMod.Name, imMod); LoadImageURLModule loadMod = new LoadImageURLModule(); - LoadedSharedModules.Add(loadMod.Name, loadMod); + m_loadedSharedModules.Add(loadMod.Name, loadMod); AvatarFactoryModule avatarFactory = new AvatarFactoryModule(); - LoadedSharedModules.Add(avatarFactory.Name, avatarFactory); + m_loadedSharedModules.Add(avatarFactory.Name, avatarFactory); //TextureDownloadModule textureModule = new TextureDownloadModule(); //LoadedSharedModules.Add(textureModule.Name, textureModule); @@ -86,7 +97,7 @@ namespace OpenSim.Region.Environment public void InitialiseSharedModules(Scene scene) { - foreach (IRegionModule module in LoadedSharedModules.Values) + foreach (IRegionModule module in m_loadedSharedModules.Values) { module.Initialise(scene, m_config); scene.AddModule(module.Name, module); //should be doing this? @@ -97,7 +108,7 @@ namespace OpenSim.Region.Environment { module.Initialise(scene, m_config); scene.AddModule(module.Name, module); - LoadedModules.Add(module); + m_loadedModules.Add(module); } /// @@ -111,7 +122,7 @@ namespace OpenSim.Region.Environment IRegionModule module = LoadModule(dllName, moduleName); if (module != null) { - LoadedSharedModules.Add(module.Name, module); + m_loadedSharedModules.Add(module.Name, module); } } @@ -204,12 +215,12 @@ namespace OpenSim.Region.Environment public void PostInitialise() { - foreach (IRegionModule module in LoadedSharedModules.Values) + foreach (IRegionModule module in m_loadedSharedModules.Values) { module.PostInitialise(); } - foreach (IRegionModule module in LoadedModules) + foreach (IRegionModule module in m_loadedModules) { module.PostInitialise(); } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index e86562db6d..1f50e1b4de 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1134,7 +1134,7 @@ namespace OpenSim.Region.Environment.Scenes { if (m_scenePresences.ContainsKey(agentID)) { - m_scenePresences[agentID].MakeAvatarPhysical(position, isFlying); + m_scenePresences[agentID].MakeRootAgent(position, isFlying); } } } @@ -1570,5 +1570,13 @@ namespace OpenSim.Region.Environment.Scenes avatar = null; return false; } + + internal void ForEachClient( Action action ) + { + foreach (ScenePresence presence in m_scenePresences.Values ) + { + action(presence.ControllingClient); + } + } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 76ff6cf97a..e8444622e9 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -310,5 +310,10 @@ namespace OpenSim.Region.Environment.Scenes avatar = null; return false; } + + public void ForEachScene(Action action ) + { + m_localScenes.ForEach( action ); + } } } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 716aaa68fe..9b6e58dfdc 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -248,8 +248,8 @@ namespace OpenSim.Region.Environment.Scenes Animations.LoadAnims(); //register for events - m_controllingClient.OnRequestWearables += SendOurAppearance; - m_controllingClient.OnSetAppearance += new SetAppearance(SetAppearance); + m_controllingClient.OnRequestWearables += SendAppearance; + m_controllingClient.OnSetAppearance += SetAppearance; m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; m_controllingClient.OnCompleteMovementToRegion += SendInitialData; m_controllingClient.OnAgentUpdate += HandleAgentUpdate; @@ -343,7 +343,7 @@ namespace OpenSim.Region.Environment.Scenes #region Status Methods - public void MakeAvatarPhysical(LLVector3 pos, bool isFlying) + public void MakeRootAgent(LLVector3 pos, bool isFlying) { m_newAvatar = true; m_isChildAgent = false; @@ -412,7 +412,7 @@ namespace OpenSim.Region.Environment.Scenes m_visualParams[i] = visualParam[i].ParamValue; } - SendAppearanceToAllOtherAgents(); + SendAppearanceToAllOtherClients(); } /// @@ -433,7 +433,7 @@ namespace OpenSim.Region.Environment.Scenes m_isChildAgent = false; //this.m_scene.SendAllSceneObjectsToClient(this.ControllingClient); - this.MakeAvatarPhysical(this.AbsolutePosition, false); + this.MakeRootAgent(this.AbsolutePosition, false); } } @@ -707,16 +707,19 @@ namespace OpenSim.Region.Environment.Scenes public void SendFullUpdateToAllClients() { - List avatars = m_scene.GetScenePresences(); - foreach (ScenePresence avatar in avatars) + List agents = m_scene.GetScenePresences(); + foreach (ScenePresence agent in agents) { - SendFullUpdateToOtherClient(avatar); - if (avatar.LocalId != LocalId) + IClientAPI client = agent.ControllingClient; + client.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, + LocalId, AbsolutePosition, m_textureEntry.ToBytes(), m_parentID ); + + if (agent.LocalId != LocalId) { - if (!avatar.m_isChildAgent) - { - avatar.SendFullUpdateToOtherClient(this); - avatar.SendAppearanceToOtherAgent(this); + if (!agent.m_isChildAgent) + { + client.SendAppearance(m_controllingClient.AgentId, m_visualParams, + m_textureEntry.ToBytes()); } } } @@ -736,22 +739,28 @@ namespace OpenSim.Region.Environment.Scenes } SendFullUpdateToAllClients(); - SendAppearanceToAllOtherAgents(); + SendAppearanceToAllOtherClients(); } - /// - /// - /// - /// - public void SendOurAppearance(IClientAPI OurClient) + public void SetWearable( int wearableId, AvatarWearable wearable ) { - m_controllingClient.SendWearables(m_wearables); + m_wearables[wearableId] = wearable; + + m_scene.ForEachClient( delegate( IClientAPI client ) + { + SendAppearance( client ); + }); + } + + public void SendAppearance(IClientAPI client) + { + client.SendWearables(m_wearables); //this.SendFullUpdateToAllClients(); - //this.SendAppearanceToAllOtherAgents(); + //this.SendAppearanceToAllOtherClients(); m_scene.SendAllSceneObjectsToClient(this); - m_controllingClient.SendViewerTime(m_scene.TimePhase); + client.SendViewerTime(m_scene.TimePhase); //Please don't remove the following code (at least not yet), just leave it commented out //gives the user god powers, should help with debuging things in the future @@ -767,25 +776,16 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void SendAppearanceToAllOtherAgents() + public void SendAppearanceToAllOtherClients() { - m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) - { - if (scenePresence != this) - { - SendAppearanceToOtherAgent(scenePresence); - } - }); - } - - /// - /// - /// - /// - public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) - { - avatarInfo.m_controllingClient.SendAppearance(m_controllingClient.AgentId, m_visualParams, - m_textureEntry.ToBytes()); + m_scene.ForEachClient(delegate(IClientAPI client) + { + if( client != m_controllingClient ) + { + client.SendAppearance(m_controllingClient.AgentId, m_visualParams, + m_textureEntry.ToBytes() ); + } + }); } ///