Thank you to Kiryu for a patch to fix an out of Sync

error in Scene. Affects 6 files and is Mantis#201
afrisby
Charles Krinke 2007-12-17 16:41:28 +00:00
parent e7170496be
commit a990c64698
6 changed files with 112 additions and 30 deletions

View File

@ -129,7 +129,7 @@ namespace OpenSim.Region.Environment.Scenes
internal void UpdateEntities()
{
List<EntityBase> updateEntities = new List<EntityBase>(Entities.Values);
List<EntityBase> updateEntities = GetEntities();
foreach (EntityBase entity in updateEntities)
{
@ -147,7 +147,7 @@ namespace OpenSim.Region.Environment.Scenes
internal void UpdateEntityMovement()
{
List<EntityBase> moveEntities = new List<EntityBase>(Entities.Values);
List<EntityBase> moveEntities = GetEntities();
foreach (EntityBase entity in moveEntities)
{
@ -174,7 +174,10 @@ namespace OpenSim.Region.Environment.Scenes
if (!Entities.ContainsKey(sceneObject.UUID))
{
// QuadTree.AddObject(sceneObject);
Entities.Add(sceneObject.UUID, sceneObject);
lock (Entities)
{
Entities.Add(sceneObject.UUID, sceneObject);
}
m_numPrim++;
}
}
@ -188,7 +191,9 @@ namespace OpenSim.Region.Environment.Scenes
}
public void RemovePrim(uint localID, LLUUID avatar_deleter)
{
foreach (EntityBase obj in Entities.Values)
List<EntityBase> EntityList = GetEntities();
foreach (EntityBase obj in EntityList)
{
if (obj is SceneObjectGroup)
{
@ -310,7 +315,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns>
public List<ScenePresence> GetScenePresences()
{
List<ScenePresence> result = new List<ScenePresence>(ScenePresences.Values);
List<ScenePresence> result;
lock (ScenePresences)
{
result = new List<ScenePresence>(ScenePresences.Values);
}
return result;
}
@ -330,8 +340,9 @@ namespace OpenSim.Region.Environment.Scenes
public List<ScenePresence> GetScenePresences(FilterAvatarList filter)
{
List<ScenePresence> result = new List<ScenePresence>();
List<ScenePresence> ScenePresencesList = GetScenePresences();
foreach (ScenePresence avatar in ScenePresences.Values)
foreach (ScenePresence avatar in ScenePresencesList)
{
if (filter(avatar))
{
@ -358,7 +369,9 @@ namespace OpenSim.Region.Environment.Scenes
private SceneObjectGroup GetGroupByPrim(uint localID)
{
foreach (EntityBase ent in Entities.Values)
List<EntityBase> EntityList = GetEntities();
foreach (EntityBase ent in EntityList)
{
if (ent is SceneObjectGroup)
{
@ -371,7 +384,9 @@ namespace OpenSim.Region.Environment.Scenes
private SceneObjectGroup GetGroupByPrim(LLUUID fullID)
{
foreach (EntityBase ent in Entities.Values)
List<EntityBase> EntityList = GetEntities();
foreach (EntityBase ent in EntityList)
{
if (ent is SceneObjectGroup)
{
@ -461,6 +476,18 @@ namespace OpenSim.Region.Environment.Scenes
return false;
}
public List<EntityBase> GetEntities()
{
List<EntityBase> result;
lock (Entities)
{
result = new List<EntityBase>(Entities.Values);
}
return result;
}
#endregion
#region Other Methods
@ -484,7 +511,9 @@ namespace OpenSim.Region.Environment.Scenes
public void SendAllSceneObjectsToClient(ScenePresence presence)
{
foreach (EntityBase ent in Entities.Values)
List<EntityBase> EntityList = GetEntities();
foreach (EntityBase ent in EntityList)
{
if (ent is SceneObjectGroup)
{
@ -770,8 +799,10 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="childPrims"></param>
public void LinkObjects(uint parentPrim, List<uint> childPrims)
{
List<EntityBase> EntityList = GetEntities();
SceneObjectGroup parenPrim = null;
foreach (EntityBase ent in Entities.Values)
foreach (EntityBase ent in EntityList)
{
if (ent is SceneObjectGroup)
{
@ -788,7 +819,7 @@ namespace OpenSim.Region.Environment.Scenes
{
for (int i = 0; i < childPrims.Count; i++)
{
foreach (EntityBase ent in Entities.Values)
foreach (EntityBase ent in EntityList)
{
if (ent is SceneObjectGroup)
{
@ -819,8 +850,10 @@ namespace OpenSim.Region.Environment.Scenes
// XXX I'm anticipating that building this dictionary once is more efficient than
// repeated scanning of the Entity.Values for a large number of primIds. However, it might
// be more efficient yet to keep this dictionary permanently on hand.
Dictionary<uint, SceneObjectGroup> sceneObjects = new Dictionary<uint, SceneObjectGroup>();
foreach (EntityBase ent in Entities.Values)
List<EntityBase> EntitieList = GetEntities();
foreach (EntityBase ent in EntitieList)
{
if (ent is SceneObjectGroup)
{
@ -863,8 +896,10 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="flags"></param>
public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags, LLUUID AgentID, LLUUID GroupID)
{
List<EntityBase> EntityList = GetEntities();
SceneObjectGroup originPrim = null;
foreach (EntityBase ent in Entities.Values)
foreach (EntityBase ent in EntityList)
{
if (ent is SceneObjectGroup)
{
@ -882,7 +917,10 @@ namespace OpenSim.Region.Environment.Scenes
{
SceneObjectGroup copy = originPrim.Copy(AgentID, GroupID);
copy.AbsolutePosition = copy.AbsolutePosition + offset;
Entities.Add(copy.UUID, copy);
lock (Entities)
{
Entities.Add(copy.UUID, copy);
}
m_numPrim++;
copy.ScheduleGroupForFullUpdate();
}

View File

@ -33,6 +33,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Region.Physics.Manager;
using System.Collections.Generic;
namespace OpenSim.Region.Environment.Scenes
{
@ -342,7 +343,9 @@ namespace OpenSim.Region.Environment.Scenes
private SceneObjectGroup GetGroupByPrim(uint localID)
{
foreach (EntityBase ent in Entities.Values)
List<EntityBase> EntitieList = GetEntities();
foreach (EntityBase ent in EntitieList)
{
if (ent is SceneObjectGroup)
{
@ -455,7 +458,10 @@ namespace OpenSim.Region.Environment.Scenes
{
EntityBase selectedEnt = null;
//MainLog.Instance.Verbose("CLIENT", "LocalID:" + Data.ObjectLocalID.ToString());
foreach (EntityBase ent in Entities.Values)
List<EntityBase> EntitieList = GetEntities();
foreach (EntityBase ent in EntitieList)
{
if (ent.LocalId == Data.ObjectLocalID)
{

View File

@ -97,7 +97,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="remoteClient"></param>
public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
{
foreach (EntityBase ent in Entities.Values)
List<EntityBase> EntitieList = GetEntities();
foreach (EntityBase ent in EntitieList)
{
if (ent is SceneObjectGroup)
{
@ -119,7 +121,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="remoteClient"></param>
public void DeselectPrim(uint primLocalID, IClientAPI remoteClient)
{
foreach (EntityBase ent in Entities.Values)
List<EntityBase> EntitieList = GetEntities();
foreach (EntityBase ent in EntitieList)
{
if (ent is SceneObjectGroup)
{
@ -137,7 +141,9 @@ namespace OpenSim.Region.Environment.Scenes
{
EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient);
foreach (EntityBase ent in Entities.Values)
List<EntityBase> EntitieList = GetEntities();
foreach (EntityBase ent in EntitieList)
{
if (ent is SceneObjectGroup)
{

View File

@ -1615,7 +1615,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="message"></param>
public void SendGeneralAlert(string message)
{
foreach (ScenePresence presence in m_scenePresences.Values)
List<ScenePresence> presenceList = GetScenePresences();
foreach (ScenePresence presence in presenceList)
{
presence.ControllingClient.SendAlertMessage(message);
}
@ -1776,7 +1778,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="modal"></param>
public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
{
foreach (ScenePresence presence in m_scenePresences.Values)
List<ScenePresence> presenceList = GetScenePresences();
foreach (ScenePresence presence in presenceList)
{
if ((presence.Firstname == firstName) && (presence.Lastname == lastName))
{
@ -1821,7 +1825,9 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public void ForceClientUpdate()
{
foreach (EntityBase ent in Entities.Values)
List<EntityBase> EntitieList = GetEntities();
foreach (EntityBase ent in EntitieList)
{
if (ent is SceneObjectGroup)
{
@ -1838,7 +1844,10 @@ namespace OpenSim.Region.Environment.Scenes
public void HandleEditCommand(string[] cmdparams)
{
Console.WriteLine("Searching for Primitive: '" + cmdparams[0] + "'");
foreach (EntityBase ent in Entities.Values)
List<EntityBase> EntitieList = GetEntities();
foreach (EntityBase ent in EntitieList)
{
if (ent is SceneObjectGroup)
{
@ -2017,7 +2026,8 @@ namespace OpenSim.Region.Environment.Scenes
if (!(m_scenePresences.Equals(null)))
{
try {
foreach (ScenePresence presence in m_scenePresences.Values)
List<ScenePresence> presenceList = GetScenePresences();
foreach (ScenePresence presence in presenceList)
{
action(presence);
}
@ -2033,7 +2043,14 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="action"></param>
public void ForEachObject(Action<SceneObjectGroup> action)
{
foreach (SceneObjectGroup presence in m_sceneObjects.Values)
List<SceneObjectGroup> presenceList;
lock (m_sceneObjects)
{
presenceList = new List<SceneObjectGroup>(m_sceneObjects.Values);
}
foreach (SceneObjectGroup presence in presenceList)
{
action(presence);
}
@ -2074,6 +2091,11 @@ namespace OpenSim.Region.Environment.Scenes
m_innerScene.ForEachClient(action);
}
public List<EntityBase> GetEntities()
{
return m_innerScene.GetEntities();
}
#endregion
}
}

View File

@ -290,7 +290,9 @@ namespace OpenSim.Region.Environment.Scenes
{
ForEachCurrentScene(delegate(Scene scene)
{
foreach (EntityBase entity in scene.Entities.Values)
List<EntityBase> EntitieList = scene.GetEntities();
foreach (EntityBase entity in EntitieList)
{
if (entity is ScenePresence)
{
@ -315,7 +317,9 @@ namespace OpenSim.Region.Environment.Scenes
ForEachCurrentScene(delegate(Scene scene)
{
foreach (EntityBase entity in scene.Entities.Values)
List<EntityBase> EntitieList = scene.GetEntities();
foreach (EntityBase entity in EntitieList)
{
if (entity is ScenePresence)
{
@ -419,4 +423,4 @@ namespace OpenSim.Region.Environment.Scenes
m_localScenes.ForEach(action);
}
}
}
}

View File

@ -108,7 +108,10 @@ namespace OpenSim.Region.Environment.Scenes
StreamWriter stream = new StreamWriter(file);
int primCount = 0;
stream.WriteLine("<scene>\n");
foreach (EntityBase ent in m_innerScene.Entities.Values)
List<EntityBase> EntityList = m_innerScene.GetEntities();
foreach (EntityBase ent in EntityList)
{
if (ent is SceneObjectGroup)
{
@ -170,7 +173,10 @@ namespace OpenSim.Region.Environment.Scenes
StreamWriter stream = new StreamWriter(file);
int primCount = 0;
stream.WriteLine("<scene>\n");
foreach (EntityBase ent in m_innerScene.Entities.Values)
List<EntityBase> EntityList = m_innerScene.GetEntities();
foreach (EntityBase ent in EntityList)
{
if (ent is SceneObjectGroup)
{