Merge branch 'master' of /home/opensim/var/repo/opensim

integration
BlueWall 2012-06-25 20:15:07 -04:00
commit 4c28972294
9 changed files with 214 additions and 54 deletions

View File

@ -79,6 +79,16 @@ namespace OpenSim.Framework.Console
return sb.ToString(); return sb.ToString();
} }
public void AddColumn(string name, int width)
{
Columns.Add(new ConsoleDisplayTableColumn(name, width));
}
public void AddRow(params string[] cells)
{
Rows.Add(new ConsoleDisplayTableRow(cells));
}
public void AddToStringBuilder(StringBuilder sb) public void AddToStringBuilder(StringBuilder sb)
{ {
string formatString = GetFormatString(); string formatString = GetFormatString();
@ -135,5 +145,10 @@ namespace OpenSim.Framework.Console
{ {
Cells = cells; Cells = cells;
} }
public ConsoleDisplayTableRow(params string[] cells) : this()
{
Cells = new List<string>(cells);
}
} }
} }

View File

@ -3808,6 +3808,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
&& part.ParentGroup.HasPrivateAttachmentPoint && part.ParentGroup.HasPrivateAttachmentPoint
&& part.ParentGroup.AttachedAvatar != AgentId) && part.ParentGroup.AttachedAvatar != AgentId)
continue; continue;
// If the part has since been deleted, then drop the update. In the case of attachments,
// this is to avoid spurious updates to other viewers since post-processing of attachments
// has to change the IsAttachment flag for various reasons (which will end up in a pass
// of the test above).
//
// Actual deletions (kills) happen in another method.
if (part.ParentGroup.IsDeleted)
continue;
} }
objectUpdateBlocks.Value.Add(updateBlock); objectUpdateBlocks.Value.Add(updateBlock);
@ -3815,7 +3824,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
else if (!canUseImproved) else if (!canUseImproved)
{ {
compressedUpdateBlocks.Value.Add(CreateCompressedUpdateBlock((SceneObjectPart)update.Entity, updateFlags)); SceneObjectPart part = (SceneObjectPart)update.Entity;
ObjectUpdateCompressedPacket.ObjectDataBlock compressedBlock
= CreateCompressedUpdateBlock(part, updateFlags);
// If the part has since been deleted, then drop the update. In the case of attachments,
// this is to avoid spurious updates to other viewers since post-processing of attachments
// has to change the IsAttachment flag for various reasons (which will end up in a pass
// of the test above).
//
// Actual deletions (kills) happen in another method.
if (part.ParentGroup.IsDeleted)
continue;
compressedUpdateBlocks.Value.Add(compressedBlock);
compressedUpdates.Value.Add(update); compressedUpdates.Value.Add(update);
} }
else else
@ -3842,6 +3864,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
&& part.ParentGroup.HasPrivateAttachmentPoint && part.ParentGroup.HasPrivateAttachmentPoint
&& part.ParentGroup.AttachedAvatar != AgentId) && part.ParentGroup.AttachedAvatar != AgentId)
continue; continue;
// If the part has since been deleted, then drop the update. In the case of attachments,
// this is to avoid spurious updates to other viewers since post-processing of attachments
// has to change the IsAttachment flag for various reasons (which will end up in a pass
// of the test above).
//
// Actual deletions (kills) happen in another method.
if (part.ParentGroup.IsDeleted)
continue;
} }
terseUpdateBlocks.Value.Add(terseUpdateBlock); terseUpdateBlocks.Value.Add(terseUpdateBlock);

View File

@ -152,31 +152,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
} }
} }
public void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted) public void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted)
{ {
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);
if (!Enabled) if (!Enabled)
return; return;
foreach (SceneObjectGroup grp in sp.GetAttachments()) // m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);
lock (sp.AttachmentsSyncLock)
{ {
grp.IsAttachment = false; foreach (SceneObjectGroup grp in sp.GetAttachments())
grp.AbsolutePosition = grp.RootPart.AttachedPos; {
UpdateKnownItem(sp, grp, saveAllScripted); grp.Scene.DeleteSceneObject(grp, false);
grp.IsAttachment = true;
if (saveChanged || saveAllScripted)
{
grp.IsAttachment = false;
grp.AbsolutePosition = grp.RootPart.AttachedPos;
UpdateKnownItem(sp, grp, saveAllScripted);
}
}
sp.ClearAttachments();
} }
} }
public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent) public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent)
{ {
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}",
// m_scene.RegionInfo.RegionName, sp.Name, silent);
if (!Enabled) if (!Enabled)
return; return;
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}",
// m_scene.RegionInfo.RegionName, sp.Name, silent);
foreach (SceneObjectGroup sop in sp.GetAttachments()) foreach (SceneObjectGroup sop in sp.GetAttachments())
{ {
sop.Scene.DeleteSceneObject(sop, silent); sop.Scene.DeleteSceneObject(sop, silent);
@ -628,6 +637,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{ {
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
sp.RemoveAttachment(group); sp.RemoveAttachment(group);
m_scene.DeleteSceneObject(group, false);
// Prepare sog for storage // Prepare sog for storage
group.AttachedAvatar = UUID.Zero; group.AttachedAvatar = UUID.Zero;
@ -636,7 +646,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
group.AbsolutePosition = group.RootPart.AttachedPos; group.AbsolutePosition = group.RootPart.AttachedPos;
UpdateKnownItem(sp, group, true); UpdateKnownItem(sp, group, true);
m_scene.DeleteSceneObject(group, false);
return; return;
} }

View File

@ -128,7 +128,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
/// <param name="visualParam"></param> /// <param name="visualParam"></param>
public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams) public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams)
{ {
// m_log.InfoFormat("[AVFACTORY]: start SetAppearance for {0}", client.AgentId); // m_log.DebugFormat(
// "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}",
// sp.Name, textureEntry, visualParams);
// TODO: This is probably not necessary any longer, just assume the // TODO: This is probably not necessary any longer, just assume the
// textureEntry set implies that the appearance transaction is complete // textureEntry set implies that the appearance transaction is complete

View File

@ -43,10 +43,15 @@ namespace OpenSim.Region.Framework.Interfaces
void RezAttachments(IScenePresence sp); void RezAttachments(IScenePresence sp);
/// <summary> /// <summary>
/// Save the attachments that have change on this presence. /// Derez the attachements for a scene presence that is closing.
/// </summary> /// </summary>
/// <param name="sp"></param> /// <remarks>
void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted); /// Attachment changes are saved.
/// </remarks>
/// <param name="sp">The presence closing</param>
/// <param name="saveChanged">Save changed attachments.</param>
/// <param name="saveAllScripted">Save attachments with scripts even if they haven't changed.</para>
void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted);
/// <summary> /// <summary>
/// Delete all the presence's attachments from the scene /// Delete all the presence's attachments from the scene

View File

@ -500,6 +500,7 @@ namespace OpenSim.Region.Framework.Scenes
public IAttachmentsModule AttachmentsModule { get; set; } public IAttachmentsModule AttachmentsModule { get; set; }
public IEntityTransferModule EntityTransferModule { get; private set; } public IEntityTransferModule EntityTransferModule { get; private set; }
public IAgentAssetTransactions AgentTransactionsModule { get; private set; } public IAgentAssetTransactions AgentTransactionsModule { get; private set; }
public IUserManagement UserManagementModule { get; private set; }
public IAvatarFactoryModule AvatarFactory public IAvatarFactoryModule AvatarFactory
{ {
@ -1243,6 +1244,7 @@ namespace OpenSim.Region.Framework.Scenes
EntityTransferModule = RequestModuleInterface<IEntityTransferModule>(); EntityTransferModule = RequestModuleInterface<IEntityTransferModule>();
m_groupsModule = RequestModuleInterface<IGroupsModule>(); m_groupsModule = RequestModuleInterface<IGroupsModule>();
AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>(); AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>();
UserManagementModule = RequestModuleInterface<IUserManagement>();
} }
#endregion #endregion
@ -2021,9 +2023,8 @@ namespace OpenSim.Region.Framework.Scenes
sceneObject.SetGroup(groupID, null); sceneObject.SetGroup(groupID, null);
} }
IUserManagement uman = RequestModuleInterface<IUserManagement>(); if (UserManagementModule != null)
if (uman != null) sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID);
sceneObject.RootPart.CreatorIdentification = uman.GetUserUUI(ownerID);
sceneObject.ScheduleGroupForFullUpdate(); sceneObject.ScheduleGroupForFullUpdate();
@ -2711,14 +2712,13 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="aCircuit"></param> /// <param name="aCircuit"></param>
private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit)
{ {
IUserManagement uMan = RequestModuleInterface<IUserManagement>(); if (UserManagementModule != null)
if (uMan != null)
{ {
string first = aCircuit.firstname, last = aCircuit.lastname; string first = aCircuit.firstname, last = aCircuit.lastname;
if (sp.PresenceType == PresenceType.Npc) if (sp.PresenceType == PresenceType.Npc)
{ {
uMan.AddUser(aCircuit.AgentID, first, last); UserManagementModule.AddUser(aCircuit.AgentID, first, last);
} }
else else
{ {
@ -2737,7 +2737,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
uMan.AddUser(aCircuit.AgentID, first, last, homeURL); UserManagementModule.AddUser(aCircuit.AgentID, first, last, homeURL);
} }
} }
} }
@ -3292,17 +3292,19 @@ namespace OpenSim.Region.Framework.Scenes
if (!isChildAgent) if (!isChildAgent)
{ {
if (AttachmentsModule != null && avatar.PresenceType != PresenceType.Npc) if (AttachmentsModule != null)
{ {
IUserManagement uMan = RequestModuleInterface<IUserManagement>();
// Don't save attachments for HG visitors, it // Don't save attachments for HG visitors, it
// messes up their inventory. When a HG visitor logs // messes up their inventory. When a HG visitor logs
// out on a foreign grid, their attachments will be // out on a foreign grid, their attachments will be
// reloaded in the state they were in when they left // reloaded in the state they were in when they left
// the home grid. This is best anyway as the visited // the home grid. This is best anyway as the visited
// grid may use an incompatible script engine. // grid may use an incompatible script engine.
if (uMan == null || uMan.IsLocalGridUser(avatar.UUID)) bool saveChanged
AttachmentsModule.SaveChangedAttachments(avatar, false); = avatar.PresenceType != PresenceType.Npc
&& (UserManagementModule == null || UserManagementModule.IsLocalGridUser(avatar.UUID));
AttachmentsModule.DeRezAttachments(avatar, saveChanged, false);
} }
ForEachClient( ForEachClient(

View File

@ -3416,9 +3416,6 @@ namespace OpenSim.Region.Framework.Scenes
public void Close() public void Close()
{ {
if (!IsChildAgent && m_scene.AttachmentsModule != null)
m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false);
// Clear known regions // Clear known regions
KnownRegions = new Dictionary<ulong, string>(); KnownRegions = new Dictionary<ulong, string>();

View File

@ -187,8 +187,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
TestScene scene = new SceneHelpers().SetupScene(); TestScene scene = new SceneHelpers().SetupScene();
SceneObjectPart part = SceneHelpers.AddSceneObject(scene); SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
Assert.That(part.ParentGroup.IsDeleted, Is.False);
scene.DeleteSceneObject(part.ParentGroup, false); scene.DeleteSceneObject(part.ParentGroup, false);
Assert.That(part.ParentGroup.IsDeleted, Is.True);
SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
Assert.That(retrievedPart, Is.Null); Assert.That(retrievedPart, Is.Null);
} }
@ -219,8 +224,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(retrievedPart, Is.Not.Null); Assert.That(retrievedPart, Is.Not.Null);
Assert.That(part.ParentGroup.IsDeleted, Is.False);
sogd.InventoryDeQueueAndDelete(); sogd.InventoryDeQueueAndDelete();
Assert.That(part.ParentGroup.IsDeleted, Is.True);
SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
Assert.That(retrievedPart2, Is.Null); Assert.That(retrievedPart2, Is.Null);
} }

View File

@ -85,19 +85,38 @@ namespace OpenSim.Services.GridService
if (MainConsole.Instance != null) if (MainConsole.Instance != null)
{ {
MainConsole.Instance.Commands.AddCommand("Regions", true, MainConsole.Instance.Commands.AddCommand("Regions", true,
"deregister region", "deregister region id",
"deregister region <Region UUID>", "deregister region id <Region UUID>",
"Deregister a region manually.", "Deregister a region manually.",
String.Empty, String.Empty,
HandleDeregisterRegion); HandleDeregisterRegion);
// A messy way of stopping this command being added if we are in standalone (since the simulator
// has an identically named command
//
// XXX: We're relying on the OpenSimulator version being registered first, which is not well defined.
if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0)
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show regions",
"show all regions",
"Show details on all regions",
String.Empty,
HandleShowRegions);
MainConsole.Instance.Commands.AddCommand("Regions", true, MainConsole.Instance.Commands.AddCommand("Regions", true,
"show region", "show region name",
"show region <Region name>", "show region name <Region name>",
"Show details on a region", "Show details on a region",
String.Empty, String.Empty,
HandleShowRegion); HandleShowRegion);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show region at",
"show region at <x-coord> <y-coord>",
"Show details on a region at the given co-ordinate.",
"For example, show region at 1000 1000",
HandleShowRegionAt);
MainConsole.Instance.Commands.AddCommand("Regions", true, MainConsole.Instance.Commands.AddCommand("Regions", true,
"set region flags", "set region flags",
"set region flags <Region name> <flags>", "set region flags <Region name> <flags>",
@ -504,13 +523,13 @@ namespace OpenSim.Services.GridService
private void HandleDeregisterRegion(string module, string[] cmd) private void HandleDeregisterRegion(string module, string[] cmd)
{ {
if (cmd.Length != 3) if (cmd.Length != 4)
{ {
MainConsole.Instance.Output("Syntax: degregister region <Region UUID>"); MainConsole.Instance.Output("Syntax: degregister region id <Region UUID>");
return; return;
} }
string rawRegionUuid = cmd[2]; string rawRegionUuid = cmd[3];
UUID regionUuid; UUID regionUuid;
if (!UUID.TryParse(rawRegionUuid, out regionUuid)) if (!UUID.TryParse(rawRegionUuid, out regionUuid))
@ -540,36 +559,107 @@ namespace OpenSim.Services.GridService
return; return;
} }
private void HandleShowRegions(string module, string[] cmd)
{
if (cmd.Length != 2)
{
MainConsole.Instance.Output("Syntax: show regions");
return;
}
List<RegionData> regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero);
OutputRegionsToConsoleSummary(regions);
}
private void HandleShowRegion(string module, string[] cmd) private void HandleShowRegion(string module, string[] cmd)
{ {
if (cmd.Length != 3) if (cmd.Length != 4)
{ {
MainConsole.Instance.Output("Syntax: show region <region name>"); MainConsole.Instance.Output("Syntax: show region name <region name>");
return; return;
} }
List<RegionData> regions = m_Database.Get(cmd[2], UUID.Zero);
string regionName = cmd[3];
List<RegionData> regions = m_Database.Get(regionName, UUID.Zero);
if (regions == null || regions.Count < 1) if (regions == null || regions.Count < 1)
{ {
MainConsole.Instance.Output("Region not found"); MainConsole.Instance.Output("No region with name {0} found", regionName);
return; return;
} }
OutputRegionsToConsole(regions);
}
private void HandleShowRegionAt(string module, string[] cmd)
{
if (cmd.Length != 5)
{
MainConsole.Instance.Output("Syntax: show region at <x-coord> <y-coord>");
return;
}
int x, y;
if (!int.TryParse(cmd[3], out x))
{
MainConsole.Instance.Output("x-coord must be an integer");
return;
}
if (!int.TryParse(cmd[4], out y))
{
MainConsole.Instance.Output("y-coord must be an integer");
return;
}
RegionData region = m_Database.Get(x * (int)Constants.RegionSize, y * (int)Constants.RegionSize, UUID.Zero);
if (region == null)
{
MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y);
return;
}
OutputRegionToConsole(region);
}
private void OutputRegionToConsole(RegionData r)
{
OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
ConsoleDisplayList dispList = new ConsoleDisplayList();
dispList.AddRow("Region Name", r.RegionName);
dispList.AddRow("Region ID", r.RegionID);
dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
dispList.AddRow("URI", r.Data["serverURI"]);
dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
dispList.AddRow("Flags", flags);
MainConsole.Instance.Output(dispList.ToString());
}
private void OutputRegionsToConsole(List<RegionData> regions)
{
foreach (RegionData r in regions)
OutputRegionToConsole(r);
}
private void OutputRegionsToConsoleSummary(List<RegionData> regions)
{
ConsoleDisplayTable dispTable = new ConsoleDisplayTable();
dispTable.AddColumn("Name", 16);
dispTable.AddColumn("ID", 36);
dispTable.AddColumn("Owner ID", 36);
dispTable.AddColumn("Flags", 60);
foreach (RegionData r in regions) foreach (RegionData r in regions)
{ {
OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
dispTable.AddRow(r.RegionName, r.RegionID.ToString(), r.Data["owner_uuid"].ToString(), flags.ToString());
ConsoleDisplayList dispList = new ConsoleDisplayList();
dispList.AddRow("Region Name", r.RegionName);
dispList.AddRow("Region ID", r.RegionID);
dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
dispList.AddRow("URI", r.Data["serverURI"]);
dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
dispList.AddRow("Flags", flags);
MainConsole.Instance.Output(dispList.ToString());
} }
return; MainConsole.Instance.Output(dispTable.ToString());
} }
private int ParseFlags(int prev, string flags) private int ParseFlags(int prev, string flags)