* ModuleLoader: Privatized some too-public fields

* Scene: Changed name from MakeAvatarPhysical to MakeRootAgent and added ForEachClient
* SceneManager: Added ForEachScene
* Worked some on appearances.
afrisby
lbsa71 2007-10-29 11:54:31 +00:00
parent 27f003b683
commit 03d49b0217
6 changed files with 85 additions and 55 deletions

View File

@ -39,6 +39,12 @@ namespace OpenSim.Framework.Types
} }
public AvatarWearable( LLUUID itemId, LLUUID assetId )
{
AssetID = assetId;
ItemID = itemId;
}
public static AvatarWearable[] DefaultWearables public static AvatarWearable[] DefaultWearables
{ {
get get

View File

@ -750,7 +750,7 @@ namespace OpenSim
break; break;
case "modules": case "modules":
m_log.Error("The currently loaded shared modules are:"); 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); m_log.Error("Shared Module: " + module.Name);
} }

View File

@ -27,6 +27,7 @@
*/ */
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
@ -42,10 +43,10 @@ namespace OpenSim.Region.Environment
{ {
public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
public List<IRegionModule> LoadedModules = new List<IRegionModule>(); private readonly List<IRegionModule> m_loadedModules = new List<IRegionModule>();
public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>(); private Dictionary<string, IRegionModule> m_loadedSharedModules = new Dictionary<string, IRegionModule>();
private readonly LogBase m_log; private readonly LogBase m_log;
private IConfigSource m_config; private readonly IConfigSource m_config;
public ModuleLoader(LogBase log, IConfigSource config) public ModuleLoader(LogBase log, IConfigSource config)
{ {
@ -53,6 +54,16 @@ namespace OpenSim.Region.Environment
m_config = config; 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) public void PickupModules(Scene scene, string moduleDir)
{ {
DirectoryInfo dir = new DirectoryInfo(moduleDir); DirectoryInfo dir = new DirectoryInfo(moduleDir);
@ -66,19 +77,19 @@ namespace OpenSim.Region.Environment
public void LoadDefaultSharedModules() public void LoadDefaultSharedModules()
{ {
DynamicTextureModule dynamicModule = new DynamicTextureModule(); DynamicTextureModule dynamicModule = new DynamicTextureModule();
LoadedSharedModules.Add(dynamicModule.Name, dynamicModule); m_loadedSharedModules.Add(dynamicModule.Name, dynamicModule);
ChatModule chat = new ChatModule(); ChatModule chat = new ChatModule();
LoadedSharedModules.Add(chat.Name, chat); m_loadedSharedModules.Add(chat.Name, chat);
InstantMessageModule imMod = new InstantMessageModule(); InstantMessageModule imMod = new InstantMessageModule();
LoadedSharedModules.Add(imMod.Name, imMod); m_loadedSharedModules.Add(imMod.Name, imMod);
LoadImageURLModule loadMod = new LoadImageURLModule(); LoadImageURLModule loadMod = new LoadImageURLModule();
LoadedSharedModules.Add(loadMod.Name, loadMod); m_loadedSharedModules.Add(loadMod.Name, loadMod);
AvatarFactoryModule avatarFactory = new AvatarFactoryModule(); AvatarFactoryModule avatarFactory = new AvatarFactoryModule();
LoadedSharedModules.Add(avatarFactory.Name, avatarFactory); m_loadedSharedModules.Add(avatarFactory.Name, avatarFactory);
//TextureDownloadModule textureModule = new TextureDownloadModule(); //TextureDownloadModule textureModule = new TextureDownloadModule();
//LoadedSharedModules.Add(textureModule.Name, textureModule); //LoadedSharedModules.Add(textureModule.Name, textureModule);
@ -86,7 +97,7 @@ namespace OpenSim.Region.Environment
public void InitialiseSharedModules(Scene scene) public void InitialiseSharedModules(Scene scene)
{ {
foreach (IRegionModule module in LoadedSharedModules.Values) foreach (IRegionModule module in m_loadedSharedModules.Values)
{ {
module.Initialise(scene, m_config); module.Initialise(scene, m_config);
scene.AddModule(module.Name, module); //should be doing this? scene.AddModule(module.Name, module); //should be doing this?
@ -97,7 +108,7 @@ namespace OpenSim.Region.Environment
{ {
module.Initialise(scene, m_config); module.Initialise(scene, m_config);
scene.AddModule(module.Name, module); scene.AddModule(module.Name, module);
LoadedModules.Add(module); m_loadedModules.Add(module);
} }
/// <summary> /// <summary>
@ -111,7 +122,7 @@ namespace OpenSim.Region.Environment
IRegionModule module = LoadModule(dllName, moduleName); IRegionModule module = LoadModule(dllName, moduleName);
if (module != null) 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() public void PostInitialise()
{ {
foreach (IRegionModule module in LoadedSharedModules.Values) foreach (IRegionModule module in m_loadedSharedModules.Values)
{ {
module.PostInitialise(); module.PostInitialise();
} }
foreach (IRegionModule module in LoadedModules) foreach (IRegionModule module in m_loadedModules)
{ {
module.PostInitialise(); module.PostInitialise();
} }

View File

@ -1134,7 +1134,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (m_scenePresences.ContainsKey(agentID)) 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; avatar = null;
return false; return false;
} }
internal void ForEachClient( Action<IClientAPI> action )
{
foreach (ScenePresence presence in m_scenePresences.Values )
{
action(presence.ControllingClient);
}
}
} }
} }

View File

@ -310,5 +310,10 @@ namespace OpenSim.Region.Environment.Scenes
avatar = null; avatar = null;
return false; return false;
} }
public void ForEachScene(Action<Scene> action )
{
m_localScenes.ForEach( action );
}
} }
} }

View File

@ -248,8 +248,8 @@ namespace OpenSim.Region.Environment.Scenes
Animations.LoadAnims(); Animations.LoadAnims();
//register for events //register for events
m_controllingClient.OnRequestWearables += SendOurAppearance; m_controllingClient.OnRequestWearables += SendAppearance;
m_controllingClient.OnSetAppearance += new SetAppearance(SetAppearance); m_controllingClient.OnSetAppearance += SetAppearance;
m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; m_controllingClient.OnCompleteMovementToRegion += CompleteMovement;
m_controllingClient.OnCompleteMovementToRegion += SendInitialData; m_controllingClient.OnCompleteMovementToRegion += SendInitialData;
m_controllingClient.OnAgentUpdate += HandleAgentUpdate; m_controllingClient.OnAgentUpdate += HandleAgentUpdate;
@ -343,7 +343,7 @@ namespace OpenSim.Region.Environment.Scenes
#region Status Methods #region Status Methods
public void MakeAvatarPhysical(LLVector3 pos, bool isFlying) public void MakeRootAgent(LLVector3 pos, bool isFlying)
{ {
m_newAvatar = true; m_newAvatar = true;
m_isChildAgent = false; m_isChildAgent = false;
@ -412,7 +412,7 @@ namespace OpenSim.Region.Environment.Scenes
m_visualParams[i] = visualParam[i].ParamValue; m_visualParams[i] = visualParam[i].ParamValue;
} }
SendAppearanceToAllOtherAgents(); SendAppearanceToAllOtherClients();
} }
/// <summary> /// <summary>
@ -433,7 +433,7 @@ namespace OpenSim.Region.Environment.Scenes
m_isChildAgent = false; m_isChildAgent = false;
//this.m_scene.SendAllSceneObjectsToClient(this.ControllingClient); //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() public void SendFullUpdateToAllClients()
{ {
List<ScenePresence> avatars = m_scene.GetScenePresences(); List<ScenePresence> agents = m_scene.GetScenePresences();
foreach (ScenePresence avatar in avatars) foreach (ScenePresence agent in agents)
{ {
SendFullUpdateToOtherClient(avatar); IClientAPI client = agent.ControllingClient;
if (avatar.LocalId != LocalId) 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) if (!agent.m_isChildAgent)
{ {
avatar.SendFullUpdateToOtherClient(this); client.SendAppearance(m_controllingClient.AgentId, m_visualParams,
avatar.SendAppearanceToOtherAgent(this); m_textureEntry.ToBytes());
} }
} }
} }
@ -736,22 +739,28 @@ namespace OpenSim.Region.Environment.Scenes
} }
SendFullUpdateToAllClients(); SendFullUpdateToAllClients();
SendAppearanceToAllOtherAgents(); SendAppearanceToAllOtherClients();
} }
/// <summary> public void SetWearable( int wearableId, AvatarWearable wearable )
///
/// </summary>
/// <param name="OurClient"></param>
public void SendOurAppearance(IClientAPI OurClient)
{ {
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.SendFullUpdateToAllClients();
//this.SendAppearanceToAllOtherAgents(); //this.SendAppearanceToAllOtherClients();
m_scene.SendAllSceneObjectsToClient(this); 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 //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 //gives the user god powers, should help with debuging things in the future
@ -767,25 +776,16 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public void SendAppearanceToAllOtherAgents() public void SendAppearanceToAllOtherClients()
{ {
m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) m_scene.ForEachClient(delegate(IClientAPI client)
{ {
if (scenePresence != this) if( client != m_controllingClient )
{ {
SendAppearanceToOtherAgent(scenePresence); client.SendAppearance(m_controllingClient.AgentId, m_visualParams,
} m_textureEntry.ToBytes() );
}); }
} });
/// <summary>
///
/// </summary>
/// <param name="avatarInfo"></param>
public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
{
avatarInfo.m_controllingClient.SendAppearance(m_controllingClient.AgentId, m_visualParams,
m_textureEntry.ToBytes());
} }
/// <summary> /// <summary>