cosmetics

0.9.1.0-post-fixes
UbitUmarov 2019-01-31 11:46:18 +00:00
parent 1e1d296ef4
commit e0b06d4b6b
1 changed files with 18 additions and 49 deletions

View File

@ -639,6 +639,9 @@ namespace OpenSim.Region.Framework.Scenes
// Get the current list of updates and clear the list before iterating // Get the current list of updates and clear the list before iterating
lock (m_updateLock) lock (m_updateLock)
{ {
if(m_updateList.Count == 0)
return;
updates = m_updateList; updates = m_updateList;
m_updateList = new Dictionary<UUID, SceneObjectGroup>(); m_updateList = new Dictionary<UUID, SceneObjectGroup>();
} }
@ -728,19 +731,12 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence oldref; ScenePresence oldref;
if (m_scenePresenceMap.TryGetValue(id, out oldref)) if (m_scenePresenceMap.TryGetValue(id, out oldref))
{ {
// Remember the old presence reference from the dictionary
uint oldLocalID = oldref.LocalId; uint oldLocalID = oldref.LocalId;
// Replace the presence reference in the dictionary with the new value
m_scenePresenceMap[id] = presence;
if (localid != oldLocalID) if (localid != oldLocalID)
m_scenePresenceLocalIDMap.Remove(oldLocalID); m_scenePresenceLocalIDMap.Remove(oldLocalID);
m_scenePresenceLocalIDMap[localid] = presence;
}
else
{
m_scenePresenceMap[id] = presence;
m_scenePresenceLocalIDMap[localid] = presence;
} }
m_scenePresenceMap[id] = presence;
m_scenePresenceLocalIDMap[localid] = presence;
m_scenePresenceList = null; m_scenePresenceList = null;
} }
finally finally
@ -748,7 +744,6 @@ namespace OpenSim.Region.Framework.Scenes
if(entered) if(entered)
m_scenePresencesLock.ExitWriteLock(); m_scenePresencesLock.ExitWriteLock();
} }
return presence; return presence;
} }
@ -1163,8 +1158,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
EntityBase[] entities = Entities.GetEntities(); EntityBase[] entities = Entities.GetEntities();
List<SceneObjectGroup> ret = new List<SceneObjectGroup>(256); List<SceneObjectGroup> ret = new List<SceneObjectGroup>(256);
int len = entities.Length;
for (int i = 0; i < len; ++i) for (int i = 0; i < entities.Length; ++i)
{ {
if(entities[i] is SceneObjectGroup) if(entities[i] is SceneObjectGroup)
ret.Add((SceneObjectGroup)entities[i]); ret.Add((SceneObjectGroup)entities[i]);
@ -1207,8 +1202,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
EntityBase entity = null; EntityBase entity = null;
EntityBase[] entities = Entities.GetEntities(); EntityBase[] entities = Entities.GetEntities();
int len = entities.Length; for (int i = 0; i < entities.Length; ++i)
for (int i = 0; i < len; ++i)
{ {
entity = entities[i]; entity = entities[i];
if (entity is SceneObjectGroup && entity.Name == name) if (entity is SceneObjectGroup && entity.Name == name)
@ -1289,9 +1283,8 @@ namespace OpenSim.Region.Framework.Scenes
protected internal SceneObjectPart GetSceneObjectPart(string name) protected internal SceneObjectPart GetSceneObjectPart(string name)
{ {
SceneObjectPart[] parts = GetPartsArray(); SceneObjectPart[] parts = GetPartsArray();
int len = parts.Length;
SceneObjectPart sop; SceneObjectPart sop;
for (int i = 0; i < len; ++i) for (int i = 0; i < parts.Length; ++i)
{ {
sop = parts[i]; sop = parts[i];
if (sop.ParentGroup == null || sop.ParentGroup.IsDeleted) if (sop.ParentGroup == null || sop.ParentGroup.IsDeleted)
@ -1356,9 +1349,8 @@ namespace OpenSim.Region.Framework.Scenes
protected internal void ForEachSOG(Action<SceneObjectGroup> action) protected internal void ForEachSOG(Action<SceneObjectGroup> action)
{ {
EntityBase[] entities = Entities.GetEntities(); EntityBase[] entities = Entities.GetEntities();
int len = entities.Length;
EntityBase entity; EntityBase entity;
for (int i = 0; i < len; ++i) for (int i = 0; i < entities.Length; ++i)
{ {
entity = entities[i]; entity = entities[i];
if (entity is SceneObjectGroup) if (entity is SceneObjectGroup)
@ -1790,7 +1782,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
{ {
SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); SceneObjectPart part = group.GetPart(primLocalID);
if (part != null) if (part != null)
{ {
part.ClickAction = Convert.ToByte(clickAction); part.ClickAction = Convert.ToByte(clickAction);
@ -1807,7 +1799,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
{ {
SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); SceneObjectPart part = group.GetPart(primLocalID);
if (part != null) if (part != null)
{ {
part.Material = Convert.ToByte(material); part.Material = Convert.ToByte(material);
@ -1963,23 +1955,20 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="prims"></param> /// <param name="prims"></param>
protected internal void DelinkObjects(List<SceneObjectPart> prims) protected internal void DelinkObjects(List<SceneObjectPart> prims)
{ {
List<SceneObjectPart> childParts = new List<SceneObjectPart>();
List<SceneObjectPart> rootParts = new List<SceneObjectPart>();
List<SceneObjectGroup> affectedGroups = new List<SceneObjectGroup>();
// Look them all up in one go, since that is comparatively expensive
//
Monitor.Enter(m_linkLock); Monitor.Enter(m_linkLock);
try try
{ {
List<SceneObjectPart> childParts = new List<SceneObjectPart>();
List<SceneObjectPart> rootParts = new List<SceneObjectPart>();
List<SceneObjectGroup> affectedGroups = new List<SceneObjectGroup>();
// Look them all up in one go, since that is comparatively expensive
//
foreach (SceneObjectPart part in prims) foreach (SceneObjectPart part in prims)
{ {
if(part == null) if(part == null)
continue; continue;
SceneObjectGroup parentSOG = part.ParentGroup; SceneObjectGroup parentSOG = part.ParentGroup;
if(parentSOG == null || if(parentSOG == null || parentSOG.IsDeleted || parentSOG.inTransit || parentSOG.PrimCount == 1)
parentSOG.IsDeleted ||
parentSOG.inTransit ||
parentSOG.PrimCount == 1)
continue; continue;
if (!affectedGroups.Contains(parentSOG)) if (!affectedGroups.Contains(parentSOG))
@ -2164,7 +2153,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
// FIXME: This section needs to be refactored so that it just calls AddSceneObject()
bool entered = false; bool entered = false;
try try
{ {
@ -2194,9 +2182,6 @@ namespace OpenSim.Region.Framework.Scenes
m_scenePartsLock.ExitWriteLock(); m_scenePartsLock.ExitWriteLock();
} }
// PROBABLE END OF FIXME
copy.IsSelected = createSelected; copy.IsSelected = createSelected;
if (rot != Quaternion.Identity) if (rot != Quaternion.Identity)
@ -2221,23 +2206,7 @@ namespace OpenSim.Region.Framework.Scenes
return null; return null;
} }
/// Calculates the distance between two Vector3s
/// </summary>
/// <param name="v1"></param>
/// <param name="v2"></param>
/// <returns></returns>
protected internal float Vector3Distance(Vector3 v1, Vector3 v2)
{
// We don't really need the double floating point precision...
// so casting it to a single
return
(float)
Math.Sqrt((v1.X - v2.X) * (v1.X - v2.X) + (v1.Y - v2.Y) * (v1.Y - v2.Y) + (v1.Z - v2.Z) * (v1.Z - v2.Z));
}
#endregion #endregion
} }
} }