Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
	OpenSim/Region/Framework/Scenes/Scene.cs
avinationmerge
Melanie 2012-06-29 22:24:53 +01:00
commit 6137f37028
13 changed files with 131 additions and 123 deletions

View File

@ -301,6 +301,7 @@ namespace OpenSim.Capabilities.Handlers
InventoryItemBase linkedItem
= m_InventoryService.GetItem(new InventoryItemBase(link.AssetID));
if (linkedItem != null)
itemsToReturn.Insert(0, linkedItem);
}
}

View File

@ -56,6 +56,11 @@ namespace OpenSim.Framework
public interface IScene
{
/// <summary>
/// The name of this scene.
/// </summary>
string Name { get; }
RegionInfo RegionInfo { get; }
RegionStatus RegionStatus { get; set; }

View File

@ -44,9 +44,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
}
protected int m_objectNameCallsReceived;
public MockScene()
public MockScene() : base(new RegionInfo(1000, 1000, null, null))
{
m_regInfo = new RegionInfo(1000, 1000, null, null);
m_regStatus = RegionStatus.Up;
}

View File

@ -366,10 +366,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// At the moment we can only deal with a single attachment
if (attachments.Count != 0)
{
UUID oldAttachmentItemID = attachments[0].FromItemID;
if (oldAttachmentItemID != UUID.Zero)
DetachSingleAttachmentToInvInternal(sp, oldAttachmentItemID);
if (attachments[0].FromItemID != UUID.Zero)
DetachSingleAttachmentToInvInternal(sp, attachments[0]);
else
m_log.WarnFormat(
"[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
@ -434,12 +432,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return null;
}
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc);
if (att == null)
DetachSingleAttachmentToInv(sp, itemID);
return att;
return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc);
}
public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist)
@ -516,18 +509,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero);
}
public void DetachSingleAttachmentToInv(IScenePresence sp, UUID itemID)
public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so)
{
lock (sp.AttachmentsSyncLock)
{
// Save avatar attachment information
// m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID);
bool changed = sp.Appearance.DetachAttachment(itemID);
if (so.AttachedAvatar != sp.UUID)
{
m_log.WarnFormat(
"[ATTACHMENTS MODULE]: Tried to detach object {0} from {1} {2} but attached avatar id was {3} in {4}",
so.Name, sp.Name, sp.UUID, so.AttachedAvatar, m_scene.RegionInfo.RegionName);
return;
}
bool changed = sp.Appearance.DetachAttachment(so.FromItemID);
if (changed && m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
DetachSingleAttachmentToInvInternal(sp, itemID);
DetachSingleAttachmentToInvInternal(sp, so);
}
}
@ -794,46 +796,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return item;
}
// What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
// To LocalId or UUID, *THAT* is the question. How now Brown UUID??
private void DetachSingleAttachmentToInvInternal(IScenePresence sp, UUID itemID)
private void DetachSingleAttachmentToInvInternal(IScenePresence sp, SceneObjectGroup so)
{
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Detaching item {0} to inventory for {1}", itemID, sp.Name);
if (itemID == UUID.Zero) // If this happened, someone made a mistake....
return;
// We can NOT use the dictionries here, as we are looking
// for an entity by the fromAssetID, which is NOT the prim UUID
EntityBase[] detachEntities = m_scene.GetEntities();
SceneObjectGroup group;
lock (sp.AttachmentsSyncLock)
{
foreach (EntityBase entity in detachEntities)
{
if (entity is SceneObjectGroup)
{
group = (SceneObjectGroup)entity;
if (group.FromItemID == itemID)
{
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
sp.RemoveAttachment(group);
m_scene.DeleteSceneObject(group, false);
m_scene.EventManager.TriggerOnAttach(so.LocalId, so.FromItemID, UUID.Zero);
sp.RemoveAttachment(so);
m_scene.DeleteSceneObject(so, false);
// Prepare sog for storage
group.AttachedAvatar = UUID.Zero;
group.RootPart.SetParentLocalId(0);
group.IsAttachment = false;
group.AbsolutePosition = group.RootPart.AttachedPos;
so.AttachedAvatar = UUID.Zero;
so.RootPart.SetParentLocalId(0);
so.IsAttachment = false;
so.AbsolutePosition = so.RootPart.AttachedPos;
UpdateKnownItem(sp, group, true);
return;
}
}
}
}
UpdateKnownItem(sp, so, true);
}
protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
@ -1047,8 +1024,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID);
if (sp != null && group != null)
DetachSingleAttachmentToInv(sp, group.FromItemID);
DetachSingleAttachmentToInv(sp, group);
}
private void Client_OnDetachAttachmentIntoInv(UUID itemID, IClientAPI remoteClient)
@ -1058,7 +1036,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
if (sp != null)
DetachSingleAttachmentToInv(sp, itemID);
{
lock (sp.AttachmentsSyncLock)
{
List<SceneObjectGroup> attachments = sp.GetAttachments();
foreach (SceneObjectGroup group in attachments)
{
if (group.FromItemID == itemID)
{
DetachSingleAttachmentToInv(sp, group);
return;
}
}
}
}
}
private void Client_OnObjectDrop(uint soLocalId, IClientAPI remoteClient)

View File

@ -227,9 +227,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
scene.AttachmentsModule.RezSingleAttachmentFromInventory(
SceneObjectGroup so
= (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory(
sp, attItem.ID, (uint)AttachmentPoint.Chest);
scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, attItem.ID);
scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, so);
// Check status on scene presence
Assert.That(sp.HasAttachments(), Is.False);

View File

@ -114,11 +114,11 @@ namespace OpenSim.Region.Framework.Interfaces
void DetachSingleAttachmentToGround(IScenePresence sp, uint objectLocalID);
/// <summary>
/// Detach the given item so that it remains in the user's inventory.
/// Detach the given attachment so that it remains in the user's inventory.
/// </summary>
/// <param name="sp">/param>
/// <param name="itemID"></param>
void DetachSingleAttachmentToInv(IScenePresence sp, UUID itemID);
/// <param name="grp">The attachment to detach.</param>
void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup grp);
/// Update the position of an attachment.
/// </summary>

View File

@ -72,6 +72,10 @@ namespace OpenSim.Region.Framework.Interfaces
/// <returns></returns>
List<SceneObjectGroup> GetAttachments(uint attachmentPoint);
/// <summary>
/// Does this avatar have any attachments?
/// </summary>
/// <returns></returns>
bool HasAttachments();
// Don't use these methods directly. Instead, use the AttachmentsModule

View File

@ -637,7 +637,6 @@ namespace OpenSim.Region.Framework.Scenes
m_SimulationDataService = simDataService;
m_EstateDataService = estateDataService;
m_regionHandle = m_regInfo.RegionHandle;
m_regionName = m_regInfo.RegionName;
m_lastIncoming = 0;
m_lastOutgoing = 0;
@ -654,7 +653,7 @@ namespace OpenSim.Region.Framework.Scenes
// resave.
// FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new
// region is set up and avoid these gyrations.
RegionSettings rs = simDataService.LoadRegionSettings(m_regInfo.RegionID);
RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID);
bool updatedTerrainTextures = false;
if (rs.TerrainTexture1 == UUID.Zero)
{
@ -683,10 +682,10 @@ namespace OpenSim.Region.Framework.Scenes
if (updatedTerrainTextures)
rs.Save();
m_regInfo.RegionSettings = rs;
RegionInfo.RegionSettings = rs;
if (estateDataService != null)
m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);
#endregion Region Settings
@ -861,7 +860,7 @@ namespace OpenSim.Region.Framework.Scenes
StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
}
public Scene(RegionInfo regInfo)
public Scene(RegionInfo regInfo) : base(regInfo)
{
PhysicalPrims = true;
CollidablePrims = true;
@ -888,7 +887,6 @@ namespace OpenSim.Region.Framework.Scenes
WestBorders.Add(westBorder);
BordersLocked = false;
m_regInfo = regInfo;
m_eventManager = new EventManager();
m_permissions = new ScenePermissions(this);
@ -1232,8 +1230,8 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.Close();
if (!GridService.DeregisterRegion(m_regInfo.RegionID))
m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName);
if (!GridService.DeregisterRegion(RegionInfo.RegionID))
m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name);
// call the base class Close method.
base.Close();
@ -1770,14 +1768,14 @@ namespace OpenSim.Region.Framework.Scenes
public void StoreWindlightProfile(RegionLightShareData wl)
{
m_regInfo.WindlightSettings = wl;
RegionInfo.WindlightSettings = wl;
SimulationDataService.StoreRegionWindlightSettings(wl);
m_eventManager.TriggerOnSaveNewWindlightProfile();
}
public void LoadWindlightProfile()
{
m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(RegionInfo.RegionID);
RegionInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(RegionInfo.RegionID);
m_eventManager.TriggerOnSaveNewWindlightProfile();
}
@ -2318,7 +2316,7 @@ namespace OpenSim.Region.Framework.Scenes
ForceSceneObjectBackup(so);
so.DetachFromBackup();
SimulationDataService.RemoveObject(so.UUID, m_regInfo.RegionID);
SimulationDataService.RemoveObject(so.UUID, RegionInfo.RegionID);
}
// We need to keep track of this state in case this group is still queued for further backup.
@ -2662,7 +2660,7 @@ namespace OpenSim.Region.Framework.Scenes
// enter. Period.
//
int flags = GetUserFlags(sceneObject.OwnerID);
if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
{
m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
@ -3908,9 +3906,9 @@ namespace OpenSim.Region.Framework.Scenes
}
}
if (m_regInfo.EstateSettings != null)
if (RegionInfo.EstateSettings != null)
{
if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0))
{
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@ -3942,7 +3940,7 @@ namespace OpenSim.Region.Framework.Scenes
}
bool groupAccess = false;
UUID[] estateGroups = m_regInfo.EstateSettings.EstateGroups;
UUID[] estateGroups = RegionInfo.EstateSettings.EstateGroups;
if (estateGroups != null)
{
@ -3960,8 +3958,8 @@ namespace OpenSim.Region.Framework.Scenes
m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!");
}
if (!m_regInfo.EstateSettings.PublicAccess &&
!m_regInfo.EstateSettings.HasAccess(agent.AgentID) &&
if (!RegionInfo.EstateSettings.PublicAccess &&
!RegionInfo.EstateSettings.HasAccess(agent.AgentID) &&
!groupAccess)
{
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate",
@ -4034,7 +4032,7 @@ namespace OpenSim.Region.Framework.Scenes
// if (loggingOffUser != null)
// {
// UUID localRegionSecret = UUID.Zero;
// bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret);
// bool parsedsecret = UUID.TryParse(RegionInfo.regionSecret, out localRegionSecret);
//
// // Region Secret is used here in case a new sessionid overwrites an old one on the user server.
// // Will update the user server in a few revisions to use it.
@ -4272,13 +4270,13 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence sp = GetScenePresence(remoteClient.AgentId);
if (sp != null)
{
uint regionX = m_regInfo.RegionLocX;
uint regionY = m_regInfo.RegionLocY;
uint regionX = RegionInfo.RegionLocX;
uint regionY = RegionInfo.RegionLocY;
Utils.LongToUInts(regionHandle, out regionX, out regionY);
int shiftx = (int) regionX - (int) m_regInfo.RegionLocX * (int)Constants.RegionSize;
int shifty = (int) regionY - (int) m_regInfo.RegionLocY * (int)Constants.RegionSize;
int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize;
int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize;
position.X += shiftx;
position.Y += shifty;
@ -4301,7 +4299,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!result)
{
regionHandle = m_regInfo.RegionHandle;
regionHandle = RegionInfo.RegionHandle;
}
else
{
@ -4807,7 +4805,7 @@ namespace OpenSim.Region.Framework.Scenes
public void DeleteFromStorage(UUID uuid)
{
SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
}
public int GetHealth(out int flags, out string message)
@ -5288,7 +5286,7 @@ Environment.Exit(1);
IEstateDataService estateDataService = EstateDataService;
if (estateDataService != null)
{
m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);
TriggerEstateSunUpdate();
}
}

View File

@ -52,6 +52,8 @@ namespace OpenSim.Region.Framework.Scenes
#region Fields
public string Name { get { return RegionInfo.RegionName; } }
public IConfigSource Config
{
get { return GetConfig(); }
@ -148,6 +150,11 @@ namespace OpenSim.Region.Framework.Scenes
#endregion
public SceneBase(RegionInfo regInfo)
{
RegionInfo = regInfo;
}
#region Update Methods
/// <summary>
@ -211,10 +218,7 @@ namespace OpenSim.Region.Framework.Scenes
///
/// </summary>
/// <returns></returns>
public virtual RegionInfo RegionInfo
{
get { return m_regInfo; }
}
public virtual RegionInfo RegionInfo { get; private set; }
#region admin stuff

View File

@ -1270,7 +1270,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void UnSubscribeEvents()
{
CollisionEventsThisFrame.Clear();
_parent_scene.RemoveCollisionEventReporting(this);
// Don't clear collision event reporting here. This is called directly from scene code and so can lead
// to a race condition with the simulate loop

View File

@ -387,12 +387,12 @@ namespace OpenSim.Region.Physics.OdePlugin
/// <summary>
/// A dictionary of actors that should receive collision events.
/// </summary>
private readonly Dictionary<uint, PhysicsActor> _collisionEventPrim = new Dictionary<uint, PhysicsActor>();
private readonly Dictionary<uint, PhysicsActor> m_collisionEventActors = new Dictionary<uint, PhysicsActor>();
/// <summary>
/// A dictionary of collision event changes that are waiting to be processed.
/// </summary>
private readonly Dictionary<uint, PhysicsActor> _collisionEventPrimChanges = new Dictionary<uint, PhysicsActor>();
private readonly Dictionary<uint, PhysicsActor> m_collisionEventActorsChanges = new Dictionary<uint, PhysicsActor>();
/// <summary>
/// Maps a unique geometry id (a memory location) to a physics actor name.
@ -1908,8 +1908,8 @@ namespace OpenSim.Region.Physics.OdePlugin
{
// m_log.DebugFormat("[PHYSICS]: Adding {0} {1} to collision event reporting", obj.SOPName, obj.LocalID);
lock (_collisionEventPrimChanges)
_collisionEventPrimChanges[obj.LocalID] = obj;
lock (m_collisionEventActorsChanges)
m_collisionEventActorsChanges[obj.LocalID] = obj;
}
/// <summary>
@ -1920,8 +1920,8 @@ namespace OpenSim.Region.Physics.OdePlugin
{
// m_log.DebugFormat("[PHYSICS]: Removing {0} {1} from collision event reporting", obj.SOPName, obj.LocalID);
lock (_collisionEventPrimChanges)
_collisionEventPrimChanges[obj.LocalID] = null;
lock (m_collisionEventActorsChanges)
m_collisionEventActorsChanges[obj.LocalID] = null;
}
#region Add/Remove Entities
@ -2930,17 +2930,17 @@ namespace OpenSim.Region.Physics.OdePlugin
// We change _collisionEventPrimChanges to avoid locking _collisionEventPrim itself and causing potential
// deadlock if the collision event tries to lock something else later on which is already locked by a
// caller that is adding or removing the collision event.
lock (_collisionEventPrimChanges)
lock (m_collisionEventActorsChanges)
{
foreach (KeyValuePair<uint, PhysicsActor> kvp in _collisionEventPrimChanges)
foreach (KeyValuePair<uint, PhysicsActor> kvp in m_collisionEventActorsChanges)
{
if (kvp.Value == null)
_collisionEventPrim.Remove(kvp.Key);
m_collisionEventActors.Remove(kvp.Key);
else
_collisionEventPrim[kvp.Key] = kvp.Value;
m_collisionEventActors[kvp.Key] = kvp.Value;
}
_collisionEventPrimChanges.Clear();
m_collisionEventActorsChanges.Clear();
}
if (SupportsNINJAJoints)
@ -3092,7 +3092,7 @@ namespace OpenSim.Region.Physics.OdePlugin
tempTick = tempTick2;
}
foreach (PhysicsActor obj in _collisionEventPrim.Values)
foreach (PhysicsActor obj in m_collisionEventActors.Values)
{
// m_log.DebugFormat("[PHYSICS]: Assessing {0} {1} for collision events", obj.SOPName, obj.LocalID);
@ -3227,10 +3227,10 @@ namespace OpenSim.Region.Physics.OdePlugin
}
tickCountFrameRun = Util.EnvironmentTickCount();
}
if (CollectStats)
m_stats[ODETotalFrameMsStatName] += Util.EnvironmentTickCountSubtract(startFrameTick);
}
return fps;
}

View File

@ -3266,16 +3266,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
private void DetachWrapper(object o)
{
if (World.AttachmentsModule != null)
{
SceneObjectPart host = (SceneObjectPart)o;
SceneObjectGroup grp = host.ParentGroup;
UUID itemID = grp.FromItemID;
ScenePresence presence = World.GetScenePresence(host.OwnerID);
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
if (attachmentsModule != null)
attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
World.AttachmentsModule.DetachSingleAttachmentToInv(presence, host.ParentGroup);
}
}
public void llAttachToAvatar(int attachmentPoint)

View File

@ -847,27 +847,34 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (engine == ScriptEngineName)
{
// If we are falling back on XEngine as the default engine, then only complain to the user
// if a script language has been explicitly set and it's one that we recognize. If it's
// if a script language has been explicitly set and it's one that we recognize or there are
// no non-whitespace characters after the colon.
//
// If the script is
// explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message.
//
// If the colon ends the line then we'll risk the false positive as this is more likely
// to signal a real scriptengine line where the user wants to use the default compile language.
//
// This avoids the overwhelming number of false positives where we're in this code because
// there's a colon in a comment in the first line of a script for entirely
// unrelated reasons (e.g. vim settings).
//
// TODO: A better fix would be to deprecate simple : detection and look for some less likely
// string to begin the comment (like #! in unix shell scripts).
bool scriptExplicitlyInXEngineLanguage = false;
string restOfScript = script.Substring(colon + 1);
bool warnRunningInXEngine = false;
string restOfFirstLine = firstline.Substring(colon + 1);
// FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs
if (restOfScript.StartsWith("c#")
|| restOfScript.StartsWith("vb")
|| restOfScript.StartsWith("lsl")
|| restOfScript.StartsWith("js")
|| restOfScript.StartsWith("yp"))
scriptExplicitlyInXEngineLanguage = true;
if (restOfFirstLine.StartsWith("c#")
|| restOfFirstLine.StartsWith("vb")
|| restOfFirstLine.StartsWith("lsl")
|| restOfFirstLine.StartsWith("js")
|| restOfFirstLine.StartsWith("yp")
|| restOfFirstLine.Length == 0)
warnRunningInXEngine = true;
if (scriptExplicitlyInXEngineLanguage)
if (warnRunningInXEngine)
{
SceneObjectPart part =
m_Scene.GetSceneObjectPart(