* Added TryGetAvatar to SceneManager

* Refactored some names for clarity
afrisby
lbsa71 2007-09-20 05:02:44 +00:00
parent 604b786d89
commit 4ce0c0794a
4 changed files with 489 additions and 458 deletions

View File

@ -377,19 +377,19 @@ namespace OpenSim
switch (command) switch (command)
{ {
case "set-time": case "set-time":
m_localScenes.SetTimePhase(Convert.ToInt32(cmdparams[0])); m_localScenes.SetCurrentSceneTimePhase(Convert.ToInt32(cmdparams[0]));
break; break;
case "force-update": case "force-update":
Console.WriteLine("Updating all clients"); Console.WriteLine("Updating all clients");
m_localScenes.ForceClientUpdate(); m_localScenes.ForceCurrentSceneClientUpdate();
break; break;
case "edit-scale": case "edit-scale":
if (cmdparams.Length == 4) if (cmdparams.Length == 4)
{ {
m_localScenes.HandleEditCommand(cmdparams); m_localScenes.HandleEditCommandOnCurrentScene(cmdparams);
} }
break; break;
@ -427,34 +427,34 @@ namespace OpenSim
case "save-xml": case "save-xml":
if (cmdparams.Length > 0) if (cmdparams.Length > 0)
{ {
m_localScenes.SavePrimsToXml(cmdparams[0]); m_localScenes.SaveCurrentSceneToXml(cmdparams[0]);
} }
else else
{ {
m_localScenes.SavePrimsToXml(DEFAULT_PRIM_BACKUP_FILENAME); m_localScenes.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME);
} }
break; break;
case "load-xml": case "load-xml":
if (cmdparams.Length > 0) if (cmdparams.Length > 0)
{ {
m_localScenes.LoadPrimsFromXml(cmdparams[0]); m_localScenes.LoadCurrentSceneFromXml(cmdparams[0]);
} }
else else
{ {
m_localScenes.LoadPrimsFromXml(DEFAULT_PRIM_BACKUP_FILENAME); m_localScenes.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME);
} }
break; break;
case "terrain": case "terrain":
if (!m_localScenes.RunTerrainCmd(cmdparams, ref result)) if (!m_localScenes.RunTerrainCmdOnCurrentScene(cmdparams, ref result))
{ {
m_log.Error(result); m_log.Error(result);
} }
break; break;
case "script": case "script":
m_localScenes.SendCommandToScripts(cmdparams); m_localScenes.SendCommandToCurrentSceneScripts(cmdparams);
break; break;
case "command-script": case "command-script":
@ -468,16 +468,16 @@ namespace OpenSim
// Treats each user as a super-admin when disabled // Treats each user as a super-admin when disabled
bool permissions = Convert.ToBoolean(cmdparams[0]); bool permissions = Convert.ToBoolean(cmdparams[0]);
m_localScenes.BypassPermissions(!permissions); m_localScenes.SetBypassPermissionsOnCurrentScene(!permissions);
break; break;
case "backup": case "backup":
m_localScenes.Backup(); m_localScenes.BackupCurrentScene();
break; break;
case "alert": case "alert":
m_localScenes.HandleAlertCommand(cmdparams); m_localScenes.HandleAlertCommandOnCurrentScene(cmdparams);
break; break;
case "create": case "create":
@ -497,7 +497,7 @@ namespace OpenSim
{ {
string regionName = this.CombineParams(cmdparams, 0); string regionName = this.CombineParams(cmdparams, 0);
if (m_localScenes.TrySetCurrentRegion(regionName)) if (m_localScenes.TrySetCurrentScene(regionName))
{ {
} }
@ -535,7 +535,7 @@ namespace OpenSim
int newDebug; int newDebug;
if (int.TryParse(args[1], out newDebug)) if (int.TryParse(args[1], out newDebug))
{ {
m_localScenes.DebugPacket(m_log, newDebug); m_localScenes.SetDebugPacketOnCurrentScene(m_log, newDebug);
} }
else else
{ {
@ -568,7 +568,7 @@ namespace OpenSim
case "users": case "users":
m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World")); m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World"));
List<ScenePresence> avatars = m_localScenes.GetAvatars(); List<ScenePresence> avatars = m_localScenes.GetCurrentSceneAvatars();
foreach (ScenePresence avatar in avatars) foreach (ScenePresence avatar in avatars)
{ {

View File

@ -1400,5 +1400,21 @@ namespace OpenSim.Region.Environment.Scenes
} }
return null; return null;
} }
internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar)
{
ScenePresence presence;
if (Avatars.TryGetValue(avatarId, out presence))
{
if (!presence.childAgent)
{
avatar = presence;
return true;
}
}
avatar = null;
return false;
}
} }
} }

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Types; using OpenSim.Framework.Types;
using libsecondlife;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
@ -15,7 +16,7 @@ namespace OpenSim.Region.Environment.Scenes
get { return m_currentScene; } get { return m_currentScene; }
} }
private Scene CurrentOrFirstScene public Scene CurrentOrFirstScene
{ {
get get
{ {
@ -48,17 +49,17 @@ namespace OpenSim.Region.Environment.Scenes
m_localScenes.Add(scene); m_localScenes.Add(scene);
} }
public void SavePrimsToXml(string filename) public void SaveCurrentSceneToXml(string filename)
{ {
CurrentOrFirstScene.SavePrimsToXml(filename); CurrentOrFirstScene.SavePrimsToXml(filename);
} }
public void LoadPrimsFromXml(string filename) public void LoadCurrentSceneFromXml(string filename)
{ {
CurrentOrFirstScene.LoadPrimsFromXml(filename); CurrentOrFirstScene.LoadPrimsFromXml(filename);
} }
public bool RunTerrainCmd(string[] cmdparams, ref string result) public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
{ {
if (m_currentScene == null) if (m_currentScene == null)
{ {
@ -79,17 +80,17 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void SendCommandToScripts(string[] cmdparams) public void SendCommandToCurrentSceneScripts(string[] cmdparams)
{ {
ForEach(delegate(Scene scene) { scene.SendCommandToScripts(cmdparams); }); ForEachCurrentScene(delegate(Scene scene) { scene.SendCommandToScripts(cmdparams); });
} }
public void BypassPermissions(bool bypassPermissions) public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions)
{ {
ForEach(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; }); ForEachCurrentScene(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; });
} }
private void ForEach(Action<Scene> func) private void ForEachCurrentScene(Action<Scene> func)
{ {
if (m_currentScene == null) if (m_currentScene == null)
{ {
@ -101,17 +102,17 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void Backup() public void BackupCurrentScene()
{ {
ForEach(delegate(Scene scene) { scene.Backup(); }); ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
} }
public void HandleAlertCommand(string[] cmdparams) public void HandleAlertCommandOnCurrentScene(string[] cmdparams)
{ {
ForEach(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); }); ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
} }
public bool TrySetCurrentRegion(string regionName) public bool TrySetCurrentScene(string regionName)
{ {
if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0)) if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
{ {
@ -135,9 +136,9 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void DebugPacket(LogBase log, int newDebug) public void SetDebugPacketOnCurrentScene(LogBase log, int newDebug)
{ {
ForEach(delegate(Scene scene) ForEachCurrentScene(delegate(Scene scene)
{ {
foreach (EntityBase entity in scene.Entities.Values) foreach (EntityBase entity in scene.Entities.Values)
{ {
@ -157,11 +158,11 @@ namespace OpenSim.Region.Environment.Scenes
}); });
} }
public List<ScenePresence> GetAvatars() public List<ScenePresence> GetCurrentSceneAvatars()
{ {
List<ScenePresence> avatars = new List<ScenePresence>(); List<ScenePresence> avatars = new List<ScenePresence>();
ForEach(delegate(Scene scene) ForEachCurrentScene(delegate(Scene scene)
{ {
foreach (EntityBase entity in scene.Entities.Values) foreach (EntityBase entity in scene.Entities.Values)
{ {
@ -192,9 +193,9 @@ namespace OpenSim.Region.Environment.Scenes
return null; return null;
} }
public void SetTimePhase(int timePhase) public void SetCurrentSceneTimePhase(int timePhase)
{ {
ForEach(delegate(Scene scene) ForEachCurrentScene(delegate(Scene scene)
{ {
scene.SetTimePhase( scene.SetTimePhase(
timePhase) timePhase)
@ -203,14 +204,28 @@ namespace OpenSim.Region.Environment.Scenes
} }
public void ForceClientUpdate() public void ForceCurrentSceneClientUpdate()
{ {
ForEach(delegate(Scene scene) { scene.ForceClientUpdate(); }); ForEachCurrentScene(delegate(Scene scene) { scene.ForceClientUpdate(); });
} }
public void HandleEditCommand(string[] cmdparams) public void HandleEditCommandOnCurrentScene(string[] cmdparams)
{ {
ForEach(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); }); ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
}
public bool TryGetAvatar( LLUUID avatarId, out ScenePresence avatar )
{
foreach (Scene scene in m_localScenes)
{
if( scene.TryGetAvatar( avatarId, out avatar ))
{
return true;
}
}
avatar = null;
return false;
} }
} }
} }