Merge branch 'avination' into ubitwork

Conflicts:
	OpenSim/Region/Framework/Scenes/CollisionSounds.cs
avinationmerge
UbitUmarov 2012-05-28 13:13:01 +01:00
commit 5141f4075f
2 changed files with 103 additions and 180 deletions

View File

@ -1673,16 +1673,25 @@ namespace OpenSim.ApplicationPlugins.RemoteController
Hashtable responseData = (Hashtable)response.Value; Hashtable responseData = (Hashtable)response.Value;
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable requestData = (Hashtable)request.Params[0];
int flags = 0;
string text = String.Empty;
int health = 0;
responseData["success"] = true; responseData["success"] = true;
CheckRegionParams(requestData, responseData); CheckRegionParams(requestData, responseData);
Scene scene = null; Scene scene = null;
try
{
GetSceneFromRegionParams(requestData, responseData, out scene); GetSceneFromRegionParams(requestData, responseData, out scene);
health = scene.GetHealth(out flags, out text);
}
catch (Exception e)
{
responseData["error"] = null;
}
int flags; responseData["success"] = true;
string text;
int health = scene.GetHealth(out flags, out text);
responseData["health"] = health; responseData["health"] = health;
responseData["flags"] = flags; responseData["flags"] = flags;
responseData["message"] = text; responseData["message"] = text;

View File

@ -53,12 +53,12 @@ namespace OpenSim.Region.Framework.Scenes
get { return m_instance; } get { return m_instance; }
} }
private readonly List<Scene> m_localScenes = new List<Scene>(); private readonly DoubleDictionary<UUID, string, Scene> m_localScenes = new DoubleDictionary<UUID, string, Scene>();
private Scene m_currentScene = null; private Scene m_currentScene = null;
public List<Scene> Scenes public List<Scene> Scenes
{ {
get { return new List<Scene>(m_localScenes); } get { return new List<Scene>(m_localScenes.FindAll(delegate(Scene s) { return true; })); }
} }
public Scene CurrentScene public Scene CurrentScene
@ -72,13 +72,10 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (m_currentScene == null) if (m_currentScene == null)
{ {
lock (m_localScenes) List<Scene> sceneList = Scenes;
{ if (sceneList.Count == 0)
if (m_localScenes.Count > 0)
return m_localScenes[0];
else
return null; return null;
} return sceneList[0];
} }
else else
{ {
@ -90,7 +87,7 @@ namespace OpenSim.Region.Framework.Scenes
public SceneManager() public SceneManager()
{ {
m_instance = this; m_instance = this;
m_localScenes = new List<Scene>(); m_localScenes = new DoubleDictionary<UUID, string, Scene>();
} }
public void Close() public void Close()
@ -98,20 +95,18 @@ namespace OpenSim.Region.Framework.Scenes
// collect known shared modules in sharedModules // collect known shared modules in sharedModules
Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>(); Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>();
lock (m_localScenes) List<Scene> sceneList = Scenes;
{ for (int i = 0; i < sceneList.Count; i++)
for (int i = 0; i < m_localScenes.Count; i++)
{ {
// extract known shared modules from scene // extract known shared modules from scene
foreach (string k in m_localScenes[i].Modules.Keys) foreach (string k in sceneList[i].Modules.Keys)
{ {
if (m_localScenes[i].Modules[k].IsSharedModule && if (sceneList[i].Modules[k].IsSharedModule &&
!sharedModules.ContainsKey(k)) !sharedModules.ContainsKey(k))
sharedModules[k] = m_localScenes[i].Modules[k]; sharedModules[k] = sceneList[i].Modules[k];
} }
// close scene/region // close scene/region
m_localScenes[i].Close(); sceneList[i].Close();
}
} }
// all regions/scenes are now closed, we can now safely // all regions/scenes are now closed, we can now safely
@ -120,31 +115,22 @@ namespace OpenSim.Region.Framework.Scenes
{ {
mod.Close(); mod.Close();
} }
m_localScenes.Clear();
} }
public void Close(Scene cscene) public void Close(Scene cscene)
{ {
lock (m_localScenes) if (!m_localScenes.ContainsKey(cscene.RegionInfo.RegionID))
{ return;
if (m_localScenes.Contains(cscene)) cscene.Close();
{
for (int i = 0; i < m_localScenes.Count; i++)
{
if (m_localScenes[i].Equals(cscene))
{
m_localScenes[i].Close();
}
}
}
}
} }
public void Add(Scene scene) public void Add(Scene scene)
{ {
scene.OnRestart += HandleRestart; scene.OnRestart += HandleRestart;
lock (m_localScenes) m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene);
m_localScenes.Add(scene);
} }
public void HandleRestart(RegionInfo rdata) public void HandleRestart(RegionInfo rdata)
@ -152,24 +138,7 @@ namespace OpenSim.Region.Framework.Scenes
m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main");
int RegionSceneElement = -1; int RegionSceneElement = -1;
lock (m_localScenes) m_localScenes.Remove(rdata.RegionID);
{
for (int i = 0; i < m_localScenes.Count; i++)
{
if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName)
{
RegionSceneElement = i;
}
}
// Now we make sure the region is no longer known about by the SceneManager
// Prevents duplicates.
if (RegionSceneElement >= 0)
{
m_localScenes.RemoveAt(RegionSceneElement);
}
}
// Send signal to main that we're restarting this sim. // Send signal to main that we're restarting this sim.
OnRestartSim(rdata); OnRestartSim(rdata);
@ -179,25 +148,23 @@ namespace OpenSim.Region.Framework.Scenes
{ {
RegionInfo Result = null; RegionInfo Result = null;
lock (m_localScenes) Scene s = m_localScenes.FindValue(delegate(Scene x)
{ {
for (int i = 0; i < m_localScenes.Count; i++) if (x.RegionInfo.RegionHandle == regionHandle)
{ return true;
if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) return false;
{ });
// Inform other regions to tell their avatar about me
Result = m_localScenes[i].RegionInfo;
}
}
if (Result != null) if (s != null)
{ {
for (int i = 0; i < m_localScenes.Count; i++) List<Scene> sceneList = Scenes;
for (int i = 0; i < sceneList.Count; i++)
{ {
if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) if (sceneList[i]!= s)
{ {
// Inform other regions to tell their avatar about me // Inform other regions to tell their avatar about me
//m_localScenes[i].OtherRegionUp(Result); //sceneList[i].OtherRegionUp(Result);
} }
} }
} }
@ -206,7 +173,6 @@ namespace OpenSim.Region.Framework.Scenes
m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up");
} }
} }
}
/// <summary> /// <summary>
/// Save the prims in the current scene to an xml file in OpenSimulator's original 'xml' format /// Save the prims in the current scene to an xml file in OpenSimulator's original 'xml' format
@ -308,8 +274,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (m_currentScene == null) if (m_currentScene == null)
{ {
lock (m_localScenes) List<Scene> sceneList = Scenes;
m_localScenes.ForEach(func); sceneList.ForEach(func);
} }
else else
{ {
@ -338,17 +304,13 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
lock (m_localScenes) Scene s;
if (m_localScenes.TryGetValue(regionName, out s))
{ {
foreach (Scene scene in m_localScenes) m_currentScene = s;
{
if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
{
m_currentScene = scene;
return true; return true;
} }
}
}
return false; return false;
} }
@ -358,62 +320,31 @@ namespace OpenSim.Region.Framework.Scenes
{ {
// m_log.Debug("Searching for Region: '" + regionID + "'"); // m_log.Debug("Searching for Region: '" + regionID + "'");
lock (m_localScenes) Scene s;
if (m_localScenes.TryGetValue(regionID, out s))
{ {
foreach (Scene scene in m_localScenes) m_currentScene = s;
{
if (scene.RegionInfo.RegionID == regionID)
{
m_currentScene = scene;
return true; return true;
} }
}
}
return false; return false;
} }
public bool TryGetScene(string regionName, out Scene scene) public bool TryGetScene(string regionName, out Scene scene)
{ {
lock (m_localScenes) return m_localScenes.TryGetValue(regionName, out scene);
{
foreach (Scene mscene in m_localScenes)
{
if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0)
{
scene = mscene;
return true;
}
}
}
scene = null;
return false;
} }
public bool TryGetScene(UUID regionID, out Scene scene) public bool TryGetScene(UUID regionID, out Scene scene)
{ {
lock (m_localScenes) return m_localScenes.TryGetValue(regionID, out scene);
{
foreach (Scene mscene in m_localScenes)
{
if (mscene.RegionInfo.RegionID == regionID)
{
scene = mscene;
return true;
}
}
}
scene = null;
return false;
} }
public bool TryGetScene(uint locX, uint locY, out Scene scene) public bool TryGetScene(uint locX, uint locY, out Scene scene)
{ {
lock (m_localScenes) List<Scene> sceneList = Scenes;
{ foreach (Scene mscene in sceneList)
foreach (Scene mscene in m_localScenes)
{ {
if (mscene.RegionInfo.RegionLocX == locX && if (mscene.RegionInfo.RegionLocX == locX &&
mscene.RegionInfo.RegionLocY == locY) mscene.RegionInfo.RegionLocY == locY)
@ -422,7 +353,6 @@ namespace OpenSim.Region.Framework.Scenes
return true; return true;
} }
} }
}
scene = null; scene = null;
return false; return false;
@ -430,9 +360,8 @@ namespace OpenSim.Region.Framework.Scenes
public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene)
{ {
lock (m_localScenes) List<Scene> sceneList = Scenes;
{ foreach (Scene mscene in sceneList)
foreach (Scene mscene in m_localScenes)
{ {
if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) &&
(mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port))
@ -441,7 +370,6 @@ namespace OpenSim.Region.Framework.Scenes
return true; return true;
} }
} }
}
scene = null; scene = null;
return false; return false;
@ -504,15 +432,10 @@ namespace OpenSim.Region.Framework.Scenes
public RegionInfo GetRegionInfo(UUID regionID) public RegionInfo GetRegionInfo(UUID regionID)
{ {
lock (m_localScenes) Scene s;
if (m_localScenes.TryGetValue(regionID, out s))
{ {
foreach (Scene scene in m_localScenes) return s.RegionInfo;
{
if (scene.RegionInfo.RegionID == regionID)
{
return scene.RegionInfo;
}
}
} }
return null; return null;
@ -530,16 +453,14 @@ namespace OpenSim.Region.Framework.Scenes
public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
{ {
lock (m_localScenes) List<Scene> sceneList = Scenes;
{ foreach (Scene scene in sceneList)
foreach (Scene scene in m_localScenes)
{ {
if (scene.TryGetScenePresence(avatarId, out avatar)) if (scene.TryGetScenePresence(avatarId, out avatar))
{ {
return true; return true;
} }
} }
}
avatar = null; avatar = null;
return false; return false;
@ -547,16 +468,14 @@ namespace OpenSim.Region.Framework.Scenes
public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar)
{ {
lock (m_localScenes) List<Scene> sceneList = Scenes;
{ foreach (Scene scene in sceneList)
foreach (Scene scene in m_localScenes)
{ {
avatar = scene.GetScenePresence(avatarId); avatar = scene.GetScenePresence(avatarId);
if (avatar != null && !avatar.IsChildAgent) if (avatar != null && !avatar.IsChildAgent)
return true; return true;
} }
}
avatar = null; avatar = null;
return false; return false;
@ -564,24 +483,21 @@ namespace OpenSim.Region.Framework.Scenes
public void CloseScene(Scene scene) public void CloseScene(Scene scene)
{ {
lock (m_localScenes) m_localScenes.Remove(scene.RegionInfo.RegionID);
m_localScenes.Remove(scene);
scene.Close(); scene.Close();
} }
public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
{ {
lock (m_localScenes) List<Scene> sceneList = Scenes;
{ foreach (Scene scene in sceneList)
foreach (Scene scene in m_localScenes)
{ {
if (scene.TryGetAvatarByName(avatarName, out avatar)) if (scene.TryGetAvatarByName(avatarName, out avatar))
{ {
return true; return true;
} }
} }
}
avatar = null; avatar = null;
return false; return false;
@ -589,15 +505,13 @@ namespace OpenSim.Region.Framework.Scenes
public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp)
{ {
lock (m_localScenes) List<Scene> sceneList = Scenes;
{ foreach (Scene scene in sceneList)
foreach (Scene scene in m_localScenes)
{ {
sp = scene.GetScenePresence(firstName, lastName); sp = scene.GetScenePresence(firstName, lastName);
if (sp != null && !sp.IsChildAgent) if (sp != null && !sp.IsChildAgent)
return true; return true;
} }
}
sp = null; sp = null;
return false; return false;
@ -605,8 +519,8 @@ namespace OpenSim.Region.Framework.Scenes
public void ForEachScene(Action<Scene> action) public void ForEachScene(Action<Scene> action)
{ {
lock (m_localScenes) List<Scene> sceneList = Scenes;
m_localScenes.ForEach(action); sceneList.ForEach(action);
} }
} }
} }