From b49f8a377b9ac542096a0bc8ad30b11942c27413 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Tue, 23 Oct 2012 08:02:26 -0700
Subject: BulletSim: minor change to insure avatar body recreation when shape
changes.
---
OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index b1833c5..d9427e1 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -338,6 +338,7 @@ public class BSShapeCollection : IDisposable
ret = GetReferenceToNativeShape(prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_AVATAR,
ShapeData.FixedShapeKey.KEY_CAPSULE, shapeCallback);
DetailLog("{0},BSShapeCollection.CreateGeom,avatarCapsule,shape={1}", prim.LocalID, prim.BSShape);
+ ret = true;
haveShape = true;
}
// If the prim attributes are simple, this could be a simple Bullet native shape
@@ -411,15 +412,14 @@ public class BSShapeCollection : IDisposable
ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey,
ShapeDestructionCallback shapeCallback)
{
+ // release any previous shape
+ DereferenceShape(prim.BSShape, true, shapeCallback);
shapeData.Type = shapeType;
// Bullet native objects are scaled by the Bullet engine so pass the size in
prim.Scale = shapeData.Size;
shapeData.Scale = shapeData.Size;
- // release any previous shape
- DereferenceShape(prim.BSShape, true, shapeCallback);
-
BulletShape newShape = BuildPhysicalNativeShape(shapeType, shapeData, shapeKey);
// Don't need to do a 'ReferenceShape()' here because native shapes are not shared.
--
cgit v1.1
From b6fc5bad000e7e7af992e7f29eeb2de9f716fcc4 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Tue, 23 Oct 2012 17:30:43 -0700
Subject: BulletSim: fix problem with avatars sinking into the ground. Change
terrain activation state to DISABLE_SIMULATION for better performance.
---
.../Region/Physics/BulletSPlugin/BSCharacter.cs | 27 ++++++++++++++--------
OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 3 +--
.../Physics/BulletSPlugin/BSShapeCollection.cs | 4 ++--
.../Physics/BulletSPlugin/BSTerrainManager.cs | 4 ++--
4 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 07dd613..a041ba8 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -105,7 +105,7 @@ public class BSCharacter : BSPhysObject
shapeData.Position = _position;
shapeData.Rotation = _orientation;
shapeData.Velocity = _velocity;
- shapeData.Size = Scale;
+ shapeData.Size = Scale; // capsule is a native shape but scale is not just <1,1,1>
shapeData.Scale = Scale;
shapeData.Mass = _mass;
shapeData.Buoyancy = _buoyancy;
@@ -144,7 +144,9 @@ public class BSCharacter : BSPhysObject
ForcePosition = _position;
// Set the velocity and compute the proper friction
ForceVelocity = _velocity;
+
BulletSimAPI.SetRestitution2(BSBody.ptr, PhysicsScene.Params.avatarRestitution);
+ BulletSimAPI.SetMargin2(BSShape.ptr, PhysicsScene.Params.collisionMargin);
BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale);
BulletSimAPI.SetContactProcessingThreshold2(BSBody.ptr, PhysicsScene.Params.contactProcessingThreshold);
if (PhysicsScene.Params.ccdMotionThreshold > 0f)
@@ -156,11 +158,15 @@ public class BSCharacter : BSPhysObject
OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw);
BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia);
+ // Make so capsule does not fall over
+ BulletSimAPI.SetAngularFactorV2(BSBody.ptr, OMV.Vector3.Zero);
+
BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT);
BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, BSBody.ptr);
- BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG);
+ // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG);
+ BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.DISABLE_DEACTIVATION);
BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, BSBody.ptr);
// Do this after the object has been added to the world
@@ -175,11 +181,13 @@ public class BSCharacter : BSPhysObject
}
// No one calls this method so I don't know what it could possibly mean
public override bool Stopped { get { return false; } }
+
public override OMV.Vector3 Size {
get
{
// Avatar capsule size is kept in the scale parameter.
- return _size;
+ // return _size;
+ return new OMV.Vector3(Scale.X * 2f, Scale.Y * 2f, Scale.Z);
}
set {
@@ -199,7 +207,9 @@ public class BSCharacter : BSPhysObject
}
}
+
public override OMV.Vector3 Scale { get; set; }
+
public override PrimitiveBaseShape Shape
{
set { BaseShape = value; }
@@ -264,7 +274,7 @@ public class BSCharacter : BSPhysObject
// Check that the current position is sane and, if not, modify the position to make it so.
- // Check for being below terrain and being out of bounds.
+ // Check for being below terrain or on water.
// Returns 'true' of the position was made sane by some action.
private bool PositionSanityCheck()
{
@@ -335,7 +345,7 @@ public class BSCharacter : BSPhysObject
}
// Avatars don't do vehicles
- public override int VehicleType { get { return 0; } set { return; } }
+ public override int VehicleType { get { return (int)Vehicle.TYPE_NONE; } set { return; } }
public override void VehicleFloatParam(int param, float value) { }
public override void VehicleVectorParam(int param, OMV.Vector3 value) {}
public override void VehicleRotationParam(int param, OMV.Quaternion rotation) { }
@@ -588,9 +598,8 @@ public class BSCharacter : BSPhysObject
newScale.X = PhysicsScene.Params.avatarCapsuleRadius;
newScale.Y = PhysicsScene.Params.avatarCapsuleRadius;
- // From the total height, remote the capsule half spheres that are at each end
- newScale.Z = (size.Z * 2f) - Math.Min(newScale.X, newScale.Y);
- // newScale.Z = (size.Z * 2f);
+ // From the total height, remove the capsule half spheres that are at each end
+ newScale.Z = size.Z- (newScale.X + newScale.Y);
Scale = newScale;
}
@@ -636,7 +645,7 @@ public class BSCharacter : BSPhysObject
BulletSimAPI.SetLinearVelocity2(BSBody.ptr, avVel);
}
- // Tell the linkset about this
+ // Tell the linkset about value changes
Linkset.UpdateProperties(this);
// Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index e686f2f..db0c99e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -692,7 +692,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters
{
if (_taintedObjects.Count > 0) // save allocating new list if there is nothing to process
{
- // swizzle a new list into the list location so we can process what's there
int taintCount = m_taintsToProcessPerStep;
TaintCallbackEntry oneCallback = new TaintCallbackEntry();
while (_taintedObjects.Count > 0 && taintCount-- > 0)
@@ -711,7 +710,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
{
try
{
- DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", DetailLogZero, oneCallback.ident); // DEBUG DEBUG DEBUG
+ DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", DetailLogZero, oneCallback.ident);
oneCallback.callback();
}
catch (Exception e)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index d9427e1..30fa50a 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -443,7 +443,8 @@ public class BSShapeCollection : IDisposable
if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR)
{
newShape = new BulletShape(
- BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1.0f, 1.0f, nativeShapeData.Scale), shapeType);
+ BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, nativeShapeData.Scale)
+ , shapeType);
DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", nativeShapeData.ID, nativeShapeData.Scale);
}
else
@@ -790,7 +791,6 @@ public class BSShapeCollection : IDisposable
// If the collisionObject is not the correct type for solidness, rebuild what's there
mustRebuild = true;
}
-
}
if (mustRebuild || forceRebuild)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
index ae267e3..880859a 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
@@ -333,8 +333,8 @@ public class BSTerrainManager
// Make sure the new shape is processed.
// BulletSimAPI.Activate2(mapInfo.terrainBody.ptr, true);
- BulletSimAPI.ForceActivationState2(mapInfo.terrainBody.ptr, ActivationState.ISLAND_SLEEPING);
- // BulletSimAPI.ForceActivationState2(mapInfo.terrainBody.ptr, ActivationState.DISABLE_SIMULATION);
+ // BulletSimAPI.ForceActivationState2(mapInfo.terrainBody.ptr, ActivationState.ISLAND_SLEEPING);
+ BulletSimAPI.ForceActivationState2(mapInfo.terrainBody.ptr, ActivationState.DISABLE_SIMULATION);
m_terrainModified = true;
};
--
cgit v1.1
From 938fa96b9f5377ef330171232262b4d8aaca0918 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Oct 2012 01:33:21 +0100
Subject: minor: Move co-ordinate related help to object commands to common
ConsoleUtil.CoordHelp
---
OpenSim/Framework/Console/ConsoleUtil.cs | 17 ++++++++++
.../World/Objects/Commands/ObjectCommandsModule.cs | 36 ++--------------------
2 files changed, 20 insertions(+), 33 deletions(-)
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index a7cf0c0..027753d 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -36,6 +36,23 @@ public class ConsoleUtil
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ ///
+ /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section
+ /// rather than in each help summary.
+ ///
+ public const string CoordHelp
+= @"Each component of the coord is comma separated. There must be no spaces between the commas.
+If you don't care about the z component you can simply omit it.
+If you don't care about the x or y components then you can leave them blank (though a comma is still required)
+If you want to specify the maxmimum value of a component then you can use ~ instead of a number
+If you want to specify the minimum value of a component then you can use -~ instead of a number
+e.g.
+delete object pos 20,20,20 to 40,40,40
+delete object pos 20,20 to 40,40
+delete object pos ,20,20 to ,40,40
+delete object pos ,,30 to ,,~
+delete object pos ,,-~ to ,,30";
+
public const string MinRawConsoleVectorValue = "-~";
public const string MaxRawConsoleVectorValue = "~";
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index 87241e1..6435ae6 100644
--- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -122,17 +122,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
"delete object pos",
"delete object pos to ",
"Delete scene objects within the given area.",
- "Each component of the coord is comma separated. There must be no spaces between the commas.\n"
- + "If you don't care about the z component you can simply omit it.\n"
- + "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n"
- + "If you want to specify the maxmimum value of a component then you can use ~ instead of a number\n"
- + "If you want to specify the minimum value of a component then you can use -~ instead of a number\n"
- + "e.g.\n"
- + "delete object pos 20,20,20 to 40,40,40\n"
- + "delete object pos 20,20 to 40,40\n"
- + "delete object pos ,20,20 to ,40,40\n"
- + "delete object pos ,,30 to ,,~\n"
- + "delete object pos ,,-~ to ,,30",
+ ConsoleUtil.CoordHelp,
HandleDeleteObject);
m_console.Commands.AddCommand(
@@ -164,17 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
"Show details of scene objects within the given area.",
"The --full option will print out information on all the parts of the object.\n"
+ "For yet more detailed part information, use the \"show part\" commands.\n"
- + "Each component of the coord is comma separated. There must be no spaces between the commas.\n"
- + "If you don't care about the z component you can simply omit it.\n"
- + "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n"
- + "If you want to specify the maxmimum value of a component then you can use ~ instead of a number\n"
- + "If you want to specify the minimum value of a component then you can use -~ instead of a number\n"
- + "e.g.\n"
- + "show object pos 20,20,20 to 40,40,40\n"
- + "show object pos 20,20 to 40,40\n"
- + "show object pos ,20,20 to ,40,40\n"
- + "show object pos ,,30 to ,,~\n"
- + "show object pos ,,-~ to ,,30",
+ + ConsoleUtil.CoordHelp,
HandleShowObjectByPos);
m_console.Commands.AddCommand(
@@ -199,17 +179,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
"show part pos",
"show part pos to ",
"Show details of scene object parts within the given area.",
- "Each component of the coord is comma separated. There must be no spaces between the commas.\n"
- + "If you don't care about the z component you can simply omit it.\n"
- + "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n"
- + "If you want to specify the maxmimum value of a component then you can use ~ instead of a number\n"
- + "If you want to specify the minimum value of a component then you can use -~ instead of a number\n"
- + "e.g.\n"
- + "show object pos 20,20,20 to 40,40,40\n"
- + "show object pos 20,20 to 40,40\n"
- + "show object pos ,20,20 to ,40,40\n"
- + "show object pos ,,30 to ,,~\n"
- + "show object pos ,,-~ to ,,30",
+ ConsoleUtil.CoordHelp,
HandleShowPartByPos);
}
--
cgit v1.1
From de47646c3de1fd56df71b700c817e67663e8a751 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Tue, 23 Oct 2012 17:34:14 -0700
Subject: BulletSim: update binaries with small change that insures that manual
position/rotation setting results in an update event.
---
bin/lib32/BulletSim.dll | Bin 598016 -> 598016 bytes
bin/lib32/libBulletSim.so | Bin 2772750 -> 2772770 bytes
bin/lib64/BulletSim.dll | Bin 764416 -> 764416 bytes
bin/lib64/libBulletSim.so | Bin 3031835 -> 3031859 bytes
4 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll
index f976efe..fbc83e6 100755
Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ
diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so
index a00bc3a..65d3805 100755
Binary files a/bin/lib32/libBulletSim.so and b/bin/lib32/libBulletSim.so differ
diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll
index acaa9c8..936368a 100755
Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ
diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so
index 996ea21..82fbad6 100755
Binary files a/bin/lib64/libBulletSim.so and b/bin/lib64/libBulletSim.so differ
--
cgit v1.1
From 73db057fa1dbda7d6dff7de770cef8670b234f84 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Oct 2012 02:05:28 +0100
Subject: Add "dump object uuid" console command. This allows any object in
the scene to be serialized and dumped to XML for debug purposes.
---
OpenSim/Framework/Console/ConsoleUtil.cs | 206 ++++++++++++---------
.../World/Objects/Commands/ObjectCommandsModule.cs | 53 ++++++
2 files changed, 168 insertions(+), 91 deletions(-)
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index 027753d..5c25ccb 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -32,100 +32,124 @@ using System.Reflection;
using log4net;
using OpenMetaverse;
-public class ConsoleUtil
+namespace OpenSim.Framework.Console
{
-// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- ///
- /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section
- /// rather than in each help summary.
- ///
- public const string CoordHelp
-= @"Each component of the coord is comma separated. There must be no spaces between the commas.
-If you don't care about the z component you can simply omit it.
-If you don't care about the x or y components then you can leave them blank (though a comma is still required)
-If you want to specify the maxmimum value of a component then you can use ~ instead of a number
-If you want to specify the minimum value of a component then you can use -~ instead of a number
-e.g.
-delete object pos 20,20,20 to 40,40,40
-delete object pos 20,20 to 40,40
-delete object pos ,20,20 to ,40,40
-delete object pos ,,30 to ,,~
-delete object pos ,,-~ to ,,30";
-
- public const string MinRawConsoleVectorValue = "-~";
- public const string MaxRawConsoleVectorValue = "~";
-
- public const string VectorSeparator = ",";
- public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
-
- ///
- /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
- ///
- /// /param>
- ///
- ///
- public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector)
+ public class ConsoleUtil
{
- return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector);
- }
-
- ///
- /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3
- ///
- /// /param>
- ///
- ///
- public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector)
- {
- return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector);
- }
-
- ///
- /// Convert a vector input from the console to an OpenMetaverse.Vector3
- ///
- ///
- /// A string in the form ,, where there is no space between values.
- /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value
- /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40)
- /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue
- /// Other than that, component values must be numeric.
- ///
- ///
- ///
- ///
- public static bool TryParseConsoleVector(
- string rawConsoleVector, Func blankComponentFunc, out Vector3 vector)
- {
- List components = rawConsoleVector.Split(VectorSeparatorChars).ToList();
-
- if (components.Count < 1 || components.Count > 3)
+ // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ ///
+ /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section
+ /// rather than in each help summary.
+ ///
+ public const string CoordHelp
+ = @"Each component of the coord is comma separated. There must be no spaces between the commas.
+ If you don't care about the z component you can simply omit it.
+ If you don't care about the x or y components then you can leave them blank (though a comma is still required)
+ If you want to specify the maxmimum value of a component then you can use ~ instead of a number
+ If you want to specify the minimum value of a component then you can use -~ instead of a number
+ e.g.
+ delete object pos 20,20,20 to 40,40,40
+ delete object pos 20,20 to 40,40
+ delete object pos ,20,20 to ,40,40
+ delete object pos ,,30 to ,,~
+ delete object pos ,,-~ to ,,30";
+
+ public const string MinRawConsoleVectorValue = "-~";
+ public const string MaxRawConsoleVectorValue = "~";
+
+ public const string VectorSeparator = ",";
+ public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
+
+ ///
+ /// Try to parse a console UUID from the console.
+ ///
+ ///
+ /// Will complain to the console if parsing fails.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid)
{
- vector = Vector3.Zero;
- return false;
+ if (!UUID.TryParse(rawUuid, out uuid))
+ {
+ console.OutputFormat("{0} is not a valid uuid", rawUuid);
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
+ ///
+ /// /param>
+ ///
+ ///
+ public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector)
+ {
+ return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector);
+ }
+
+ ///
+ /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3
+ ///
+ /// /param>
+ ///
+ ///
+ public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector)
+ {
+ return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector);
+ }
+
+ ///
+ /// Convert a vector input from the console to an OpenMetaverse.Vector3
+ ///
+ ///
+ /// A string in the form ,, where there is no space between values.
+ /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value
+ /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40)
+ /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue
+ /// Other than that, component values must be numeric.
+ ///
+ ///
+ ///
+ ///
+ public static bool TryParseConsoleVector(
+ string rawConsoleVector, Func blankComponentFunc, out Vector3 vector)
+ {
+ List components = rawConsoleVector.Split(VectorSeparatorChars).ToList();
+
+ if (components.Count < 1 || components.Count > 3)
+ {
+ vector = Vector3.Zero;
+ return false;
+ }
+
+ for (int i = components.Count; i < 3; i++)
+ components.Add("");
+
+ List semiDigestedComponents
+ = components.ConvertAll(
+ c =>
+ {
+ if (c == "")
+ return blankComponentFunc.Invoke(c);
+ else if (c == MaxRawConsoleVectorValue)
+ return float.MaxValue.ToString();
+ else if (c == MinRawConsoleVectorValue)
+ return float.MinValue.ToString();
+ else
+ return c;
+ });
+
+ string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray());
+
+ // m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector);
+
+ return Vector3.TryParse(semiDigestedConsoleVector, out vector);
}
-
- for (int i = components.Count; i < 3; i++)
- components.Add("");
-
- List semiDigestedComponents
- = components.ConvertAll(
- c =>
- {
- if (c == "")
- return blankComponentFunc.Invoke(c);
- else if (c == MaxRawConsoleVectorValue)
- return float.MaxValue.ToString();
- else if (c == MinRawConsoleVectorValue)
- return float.MinValue.ToString();
- else
- return c;
- });
-
- string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray());
-
-// m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector);
-
- return Vector3.TryParse(semiDigestedConsoleVector, out vector);
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index 6435ae6..41a1afd 100644
--- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -27,10 +27,12 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
+using System.Xml;
using log4net;
using Mono.Addins;
using NDesk.Options;
@@ -41,6 +43,7 @@ using OpenSim.Framework.Console;
using OpenSim.Framework.Monitoring;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Scenes.Serialization;
namespace OpenSim.Region.CoreModules.World.Objects.Commands
{
@@ -181,6 +184,16 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
"Show details of scene object parts within the given area.",
ConsoleUtil.CoordHelp,
HandleShowPartByPos);
+
+ m_console.Commands.AddCommand(
+ "Objects",
+ false,
+ "dump object uuid",
+ "dump object uuid ",
+ "Dump the formatted serialization of the given object to the file .xml",
+ "e.g. dump object uuid c1ed6809-cc24-4061-a4c2-93082a2d1f1d will dump serialization to c1ed6809-cc24-4061-a4c2-93082a2d1f1d.xml\n"
+ + "To locate the UUID in the first place, you need to use the other show object commands",
+ HandleDumpObjectByUuid);
}
public void RemoveRegion(Scene scene)
@@ -447,6 +460,46 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
OutputSopsToConsole(searchPredicate, true);
}
+ private void HandleDumpObjectByUuid(string module, string[] cmdparams)
+ {
+ if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
+ return;
+
+ if (cmdparams.Length < 4)
+ {
+ m_console.OutputFormat("Usage: dump object uuid ");
+ return;
+ }
+
+ UUID objectUuid;
+ if (!ConsoleUtil.TryParseConsoleUuid(m_console, cmdparams[3], out objectUuid))
+ return;
+
+ SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid);
+
+ if (so == null)
+ {
+// m_console.OutputFormat("No part found with uuid {0}", objectUuid);
+ return;
+ }
+
+ string fileName = string.Format("{0}.xml", objectUuid);
+
+ if (File.Exists(fileName))
+ {
+ m_console.OutputFormat("File {0} already exists. Please move or remove it.", fileName);
+ return;
+ }
+
+ using (XmlTextWriter xtw = new XmlTextWriter(fileName, Encoding.UTF8))
+ {
+ xtw.Formatting = Formatting.Indented;
+ SceneObjectSerializer.ToOriginalXmlFormat(so, xtw, true);
+ }
+
+ m_console.OutputFormat("Object dumped to file {0}", fileName);
+ }
+
///
/// Append a scene object report to an input StringBuilder
///
--
cgit v1.1
From f76dceb90b5a76a7b6a5243c9032996c007c0cf5 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Oct 2012 03:08:58 +0100
Subject: Get "save oar" and "save iar" to tell you in a more friendly manner
if the filename to save already exists, rather than exception throwing.
Also changes ConsoleUtil.CheckFileExists to CheckFileDoesNotExist() since this is more meaningful in the context, even though it does result in double negatives.
---
OpenSim/Framework/Console/ConsoleUtil.cs | 19 +++++++++++++++++++
.../Inventory/Archiver/InventoryArchiverModule.cs | 4 ++++
.../CoreModules/World/Archiver/ArchiverModule.cs | 18 +++++++++++-------
.../World/Objects/Commands/ObjectCommandsModule.cs | 5 +----
.../Region/OptionalModules/Asset/AssetInfoModule.cs | 3 +++
OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | 3 +++
6 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index 5c25ccb..3ebfdf8 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Reflection;
using log4net;
@@ -60,6 +61,24 @@ namespace OpenSim.Framework.Console
public const string VectorSeparator = ",";
public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
+
+ ///
+ /// Check if the given file path exists.
+ ///
+ /// If not, warning is printed to the given console.
+ /// true if the file does not exist, false otherwise.
+ ///
+ ///
+ public static bool CheckFileDoesNotExist(ICommandConsole console, string path)
+ {
+ if (File.Exists(path))
+ {
+ console.OutputFormat("File {0} already exists. Please move or remove it.", path);
+ return false;
+ }
+
+ return true;
+ }
///
/// Try to parse a console UUID from the console.
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index cf87010..afe1200 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -35,6 +35,7 @@ using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
+using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
@@ -209,6 +210,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
Guid id, string firstName, string lastName, string invPath, string pass, string savePath,
Dictionary options)
{
+ if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, savePath))
+ return false;
+
if (m_scenes.Count > 0)
{
UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index 2a87dc2..970487a 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -32,6 +32,8 @@ using System.Reflection;
using log4net;
using NDesk.Options;
using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@@ -117,7 +119,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
//
// foreach (string param in mainParams)
// m_log.DebugFormat("GOT PARAM [{0}]", param);
-
+
if (mainParams.Count > 2)
{
DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty);
@@ -150,14 +152,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
List mainParams = ops.Parse(cmdparams);
+ string path;
if (mainParams.Count > 2)
- {
- ArchiveRegion(mainParams[2], options);
- }
+ path = mainParams[2];
else
- {
- ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, options);
- }
+ path = DEFAULT_OAR_BACKUP_FILENAME;
+
+ if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, path))
+ return;
+
+ ArchiveRegion(path, options);
}
public void ArchiveRegion(string savePath, Dictionary options)
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index 41a1afd..f0a35ad 100644
--- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -485,11 +485,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
string fileName = string.Format("{0}.xml", objectUuid);
- if (File.Exists(fileName))
- {
- m_console.OutputFormat("File {0} already exists. Please move or remove it.", fileName);
+ if (!ConsoleUtil.CheckFileDoesNotExist(m_console, fileName))
return;
- }
using (XmlTextWriter xtw = new XmlTextWriter(fileName, Encoding.UTF8))
{
diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
index 41ec14f..7639c6c 100644
--- a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
@@ -127,6 +127,9 @@ namespace OpenSim.Region.OptionalModules.Asset
}
string fileName = rawAssetId;
+
+ if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName))
+ return;
using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
{
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
index 46b0c67..4123f49 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
@@ -141,6 +141,9 @@ namespace OpenSim.Server.Handlers.Asset
}
string fileName = rawAssetId;
+
+ if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName))
+ return;
using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
{
--
cgit v1.1
From 81aeecc90723658187668baa49bd168b7b333afb Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Oct 2012 04:10:22 +0100
Subject: Allow "show object", "show part", "dump object" and "delete object"
to accept a local ID as well as a UUID.
This means that the sub-commands are now id rather than uuid, e.g. show object id
---
OpenSim/Framework/Console/ConsoleUtil.cs | 58 +++++++++++-
.../World/Objects/Commands/ObjectCommandsModule.cs | 103 ++++++++++++---------
OpenSim/Region/Framework/Scenes/Scene.cs | 13 ++-
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 24 +++++
4 files changed, 153 insertions(+), 45 deletions(-)
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index 3ebfdf8..16a63e0 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -38,6 +38,8 @@ namespace OpenSim.Framework.Console
public class ConsoleUtil
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ public const int LocalIdNotFound = 0;
///
/// Used by modules to display stock co-ordinate help, though possibly this should be under some general section
@@ -87,19 +89,71 @@ namespace OpenSim.Framework.Console
/// Will complain to the console if parsing fails.
///
///
- ///
+ /// If null then no complaint is printed.
///
///
public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid)
{
if (!UUID.TryParse(rawUuid, out uuid))
{
- console.OutputFormat("{0} is not a valid uuid", rawUuid);
+ if (console != null)
+ console.OutputFormat("{0} is not a valid uuid", rawUuid);
+
return false;
}
return true;
}
+
+ public static bool TryParseConsoleLocalId(ICommandConsole console, string rawLocalId, out uint localId)
+ {
+ if (!uint.TryParse(rawLocalId, out localId))
+ {
+ if (console != null)
+ console.OutputFormat("{0} is not a valid local id", localId);
+
+ return false;
+ }
+
+ if (localId == 0)
+ {
+ if (console != null)
+ console.OutputFormat("{0} is not a valid local id - it must be greater than 0", localId);
+
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Tries to parse the input as either a UUID or a local ID.
+ ///
+ /// true if parsing succeeded, false otherwise.
+ ///
+ ///
+ ///
+ ///
+ /// Will be set to ConsoleUtil.LocalIdNotFound if parsing result was a UUID or no parse succeeded.
+ ///
+ public static bool TryParseConsoleId(ICommandConsole console, string rawId, out UUID uuid, out uint localId)
+ {
+ if (TryParseConsoleUuid(null, rawId, out uuid))
+ {
+ localId = LocalIdNotFound;
+ return true;
+ }
+
+ if (TryParseConsoleLocalId(null, rawId, out localId))
+ {
+ return true;
+ }
+
+ if (console != null)
+ console.OutputFormat("{0} is not a valid UUID or local id", rawId);
+
+ return false;
+ }
///
/// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index f0a35ad..b2c9bce 100644
--- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -99,9 +99,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
HandleDeleteObject);
m_console.Commands.AddCommand(
- "Objects", false, "delete object uuid",
- "delete object uuid ",
- "Delete a scene object by uuid",
+ "Objects", false, "delete object id",
+ "delete object id ",
+ "Delete a scene object by uuid or localID",
HandleDeleteObject);
m_console.Commands.AddCommand(
@@ -131,12 +131,12 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
m_console.Commands.AddCommand(
"Objects",
false,
- "show object uuid",
- "show object uuid [--full] ",
- "Show details of a scene object with the given UUID",
+ "show object id",
+ "show object id [--full] ",
+ "Show details of a scene object with the given UUID or localID",
"The --full option will print out information on all the parts of the object.\n"
+ "For yet more detailed part information, use the \"show part\" commands.",
- HandleShowObjectByUuid);
+ HandleShowObjectById);
m_console.Commands.AddCommand(
"Objects",
@@ -163,9 +163,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
m_console.Commands.AddCommand(
"Objects",
false,
- "show part uuid",
- "show part uuid ",
- "Show details of a scene object parts with the given UUID", HandleShowPartByUuid);
+ "show part id",
+ "show part id ",
+ "Show details of a scene object part with the given UUID or localID", HandleShowPartById);
m_console.Commands.AddCommand(
"Objects",
@@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
"show part name",
"show part name [--regex] ",
"Show details of scene object parts with the given name.",
- "If --regex is specified then the name is treatead as a regular expression",
+ "If --regex is specified then the name is treated as a regular expression",
HandleShowPartByName);
m_console.Commands.AddCommand(
@@ -188,12 +188,13 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
m_console.Commands.AddCommand(
"Objects",
false,
- "dump object uuid",
- "dump object uuid ",
+ "dump object id",
+ "dump object id ",
"Dump the formatted serialization of the given object to the file .xml",
"e.g. dump object uuid c1ed6809-cc24-4061-a4c2-93082a2d1f1d will dump serialization to c1ed6809-cc24-4061-a4c2-93082a2d1f1d.xml\n"
- + "To locate the UUID in the first place, you need to use the other show object commands",
- HandleDumpObjectByUuid);
+ + "To locate the UUID or localID in the first place, you need to use the other show object commands.\n"
+ + "If a local ID is given then the filename used is still that for the UUID",
+ HandleDumpObjectById);
}
public void RemoveRegion(Scene scene)
@@ -248,7 +249,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
m_console.OutputFormat(sb.ToString());
}
- private void HandleShowObjectByUuid(string module, string[] cmdparams)
+ private void HandleShowObjectById(string module, string[] cmdparams)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
@@ -264,14 +265,17 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
return;
}
- UUID objectUuid;
- if (!UUID.TryParse(mainParams[3], out objectUuid))
- {
- m_console.OutputFormat("{0} is not a valid uuid", mainParams[3]);
+ UUID uuid;
+ uint localId;
+ if (!ConsoleUtil.TryParseConsoleId(m_console, mainParams[3], out uuid, out localId))
return;
- }
- SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid);
+ SceneObjectGroup so;
+
+ if (localId != ConsoleUtil.LocalIdNotFound)
+ so = m_scene.GetSceneObjectGroup(localId);
+ else
+ so = m_scene.GetSceneObjectGroup(uuid);
if (so == null)
{
@@ -348,7 +352,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
OutputSogsToConsole(searchPredicate, showFull);
}
- private void HandleShowPartByUuid(string module, string[] cmdparams)
+ private void HandleShowPartById(string module, string[] cmdparams)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
@@ -361,18 +365,20 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
if (mainParams.Count < 4)
{
- m_console.OutputFormat("Usage: show part uuid [--full] ");
+ m_console.OutputFormat("Usage: show part id [--full] ");
return;
}
UUID objectUuid;
- if (!UUID.TryParse(mainParams[3], out objectUuid))
- {
- m_console.OutputFormat("{0} is not a valid uuid", mainParams[3]);
+ uint localId;
+ if (!ConsoleUtil.TryParseConsoleId(m_console, mainParams[3], out objectUuid, out localId))
return;
- }
- SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid);
+ SceneObjectPart sop;
+ if (localId == ConsoleUtil.LocalIdNotFound)
+ sop = m_scene.GetSceneObjectPart(objectUuid);
+ else
+ sop = m_scene.GetSceneObjectPart(localId);
if (sop == null)
{
@@ -460,22 +466,27 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
OutputSopsToConsole(searchPredicate, true);
}
- private void HandleDumpObjectByUuid(string module, string[] cmdparams)
+ private void HandleDumpObjectById(string module, string[] cmdparams)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
if (cmdparams.Length < 4)
{
- m_console.OutputFormat("Usage: dump object uuid ");
+ m_console.OutputFormat("Usage: dump object id ");
return;
}
UUID objectUuid;
- if (!ConsoleUtil.TryParseConsoleUuid(m_console, cmdparams[3], out objectUuid))
+ uint localId;
+ if (!ConsoleUtil.TryParseConsoleId(m_console, cmdparams[3], out objectUuid, out localId))
return;
- SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid);
+ SceneObjectGroup so;
+ if (localId == ConsoleUtil.LocalIdNotFound)
+ so = m_scene.GetSceneObjectGroup(objectUuid);
+ else
+ so = m_scene.GetSceneObjectGroup(localId);
if (so == null)
{
@@ -483,6 +494,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
return;
}
+ // In case we found it via local ID.
+ objectUuid = so.UUID;
+
string fileName = string.Format("{0}.xml", objectUuid);
if (!ConsoleUtil.CheckFileDoesNotExist(m_console, fileName))
@@ -661,19 +675,24 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
break;
- case "uuid":
- if (!UUID.TryParse(o, out match))
+ case "id":
+ UUID uuid;
+ uint localId;
+ if (!ConsoleUtil.TryParseConsoleId(m_console, o, out uuid, out localId))
return;
requireConfirmation = false;
deletes = new List();
-
- m_scene.ForEachSOG(delegate (SceneObjectGroup g)
- {
- if (g.UUID == match && !g.IsAttachment)
- deletes.Add(g);
- });
-
+
+ SceneObjectGroup so;
+ if (localId == ConsoleUtil.LocalIdNotFound)
+ so = m_scene.GetSceneObjectGroup(uuid);
+ else
+ so = m_scene.GetSceneObjectGroup(localId);
+
+ if (!so.IsAttachment)
+ deletes.Add(so);
+
// if (deletes.Count == 0)
// m_console.OutputFormat("No objects were found with uuid {0}", match);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 5f45529..532598a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -4688,13 +4688,24 @@ namespace OpenSim.Region.Framework.Scenes
/// Get a group via its UUID
///
///
- /// null if no group with that name exists
+ /// null if no group with that id exists
public SceneObjectGroup GetSceneObjectGroup(UUID fullID)
{
return m_sceneGraph.GetSceneObjectGroup(fullID);
}
///
+ /// Get a group via its local ID
+ ///
+ /// This will only return a group if the local ID matches a root part
+ ///
+ /// null if no group with that id exists
+ public SceneObjectGroup GetSceneObjectGroup(uint localID)
+ {
+ return m_sceneGraph.GetSceneObjectGroup(localID);
+ }
+
+ ///
/// Get a group by name from the scene (will return the first
/// found, if there are more than one prim with the same name)
///
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 209a770..a4383fd 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -983,6 +983,30 @@ namespace OpenSim.Region.Framework.Scenes
}
///
+ /// Get a group in the scene
+ ///
+ ///
+ /// This will only return a group if the local ID matches the root part, not other parts.
+ ///
+ /// Local id of the root part of the group
+ /// null if no such group was found
+ protected internal SceneObjectGroup GetSceneObjectGroup(uint localID)
+ {
+ lock (SceneObjectGroupsByLocalPartID)
+ {
+ if (SceneObjectGroupsByLocalPartID.ContainsKey(localID))
+ {
+ SceneObjectGroup so = SceneObjectGroupsByLocalPartID[localID];
+
+ if (so.LocalId == localID)
+ return so;
+ }
+ }
+
+ return null;
+ }
+
+ ///
/// Get a group by name from the scene (will return the first
/// found, if there are more than one prim with the same name)
///
--
cgit v1.1
From 1743fe5d62422f959f1f865d1def2ad929375460 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 25 Oct 2012 00:29:50 +0100
Subject: Move npc creation tests involving appearance from
OSSL_ApiAppearanceTest to OSSL_ApiNpcTests
This is a more intuitive location.
---
.../Shared/Tests/OSSL_ApiAppearanceTest.cs | 70 ----------------------
.../ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | 69 +++++++++++++++++++++
2 files changed, 69 insertions(+), 70 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
index c8718d9..c401794 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
@@ -75,76 +75,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
m_engine.AddRegion(m_scene);
}
- ///
- /// Test creation of an NPC where the appearance data comes from a notecard
- ///
- [Test]
- public void TestOsNpcCreateUsingAppearanceFromNotecard()
- {
- TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
-
- // Store an avatar with a different height from default in a notecard.
- UUID userId = TestHelpers.ParseTail(0x1);
- float newHeight = 1.9f;
-
- ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
- sp.Appearance.AvatarHeight = newHeight;
- SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
- SceneObjectPart part = so.RootPart;
- m_scene.AddSceneObject(so);
-
- OSSL_Api osslApi = new OSSL_Api();
- osslApi.Initialize(m_engine, part, null);
-
- string notecardName = "appearanceNc";
- osslApi.osOwnerSaveAppearance(notecardName);
-
- // Try creating a bot using the appearance in the notecard.
- string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName);
- Assert.That(npcRaw, Is.Not.Null);
-
- UUID npcId = new UUID(npcRaw);
- ScenePresence npc = m_scene.GetScenePresence(npcId);
- Assert.That(npc, Is.Not.Null);
- Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
- }
-
- ///
- /// Test creation of an NPC where the appearance data comes from an avatar already in the region.
- ///
- [Test]
- public void TestOsNpcCreateUsingAppearanceFromAvatar()
- {
- TestHelpers.InMethod();
-// TestHelpers.EnableLogging();
-
- // Store an avatar with a different height from default in a notecard.
- UUID userId = TestHelpers.ParseTail(0x1);
- float newHeight = 1.9f;
-
- ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
- sp.Appearance.AvatarHeight = newHeight;
- SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
- SceneObjectPart part = so.RootPart;
- m_scene.AddSceneObject(so);
-
- OSSL_Api osslApi = new OSSL_Api();
- osslApi.Initialize(m_engine, part, null);
-
- string notecardName = "appearanceNc";
- osslApi.osOwnerSaveAppearance(notecardName);
-
- // Try creating a bot using the existing avatar's appearance
- string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString());
- Assert.That(npcRaw, Is.Not.Null);
-
- UUID npcId = new UUID(npcRaw);
- ScenePresence npc = m_scene.GetScenePresence(npcId);
- Assert.That(npc, Is.Not.Null);
- Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
- }
-
[Test]
public void TestOsOwnerSaveAppearance()
{
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
index 25679a6..b5a4d93 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
@@ -79,6 +79,75 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
}
///
+ /// Test creation of an NPC where the appearance data comes from a notecard
+ ///
+ [Test]
+ public void TestOsNpcCreateUsingAppearanceFromNotecard()
+ {
+ TestHelpers.InMethod();
+
+ // Store an avatar with a different height from default in a notecard.
+ UUID userId = TestHelpers.ParseTail(0x1);
+ float newHeight = 1.9f;
+
+ ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
+ sp.Appearance.AvatarHeight = newHeight;
+ SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
+ SceneObjectPart part = so.RootPart;
+ m_scene.AddSceneObject(so);
+
+ OSSL_Api osslApi = new OSSL_Api();
+ osslApi.Initialize(m_engine, part, null);
+
+ string notecardName = "appearanceNc";
+ osslApi.osOwnerSaveAppearance(notecardName);
+
+ // Try creating a bot using the appearance in the notecard.
+ string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName);
+ Assert.That(npcRaw, Is.Not.Null);
+
+ UUID npcId = new UUID(npcRaw);
+ ScenePresence npc = m_scene.GetScenePresence(npcId);
+ Assert.That(npc, Is.Not.Null);
+ Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
+ }
+
+ ///
+ /// Test creation of an NPC where the appearance data comes from an avatar already in the region.
+ ///
+ [Test]
+ public void TestOsNpcCreateUsingAppearanceFromAvatar()
+ {
+ TestHelpers.InMethod();
+// TestHelpers.EnableLogging();
+
+ // Store an avatar with a different height from default in a notecard.
+ UUID userId = TestHelpers.ParseTail(0x1);
+ float newHeight = 1.9f;
+
+ ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
+ sp.Appearance.AvatarHeight = newHeight;
+ SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
+ SceneObjectPart part = so.RootPart;
+ m_scene.AddSceneObject(so);
+
+ OSSL_Api osslApi = new OSSL_Api();
+ osslApi.Initialize(m_engine, part, null);
+
+ string notecardName = "appearanceNc";
+ osslApi.osOwnerSaveAppearance(notecardName);
+
+ // Try creating a bot using the existing avatar's appearance
+ string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString());
+ Assert.That(npcRaw, Is.Not.Null);
+
+ UUID npcId = new UUID(npcRaw);
+ ScenePresence npc = m_scene.GetScenePresence(npcId);
+ Assert.That(npc, Is.Not.Null);
+ Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
+ }
+
+ ///
/// Test removal of an owned NPC.
///
[Test]
--
cgit v1.1
From 5d4ac5a90fea758e18c8a9e97b06e799186b5a14 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 25 Oct 2012 00:59:27 +0100
Subject: Add TestOsNpcLoadAppearance()
---
OpenSim/Framework/AvatarAppearance.cs | 3 ++
.../Shared/Tests/OSSL_ApiAppearanceTest.cs | 6 ++-
.../ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | 43 +++++++++++++++++++++-
3 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 4f598b0..95e9667 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -330,6 +330,9 @@ namespace OpenSim.Framework
SetVisualParams(visualParams);
}
+ ///
+ /// Set avatar height by a calculation based on their visual parameters.
+ ///
public virtual void SetHeight()
{
// Start with shortest possible female avatar height
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
index c401794..eb51c4e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
@@ -36,11 +36,12 @@ using OpenMetaverse;
using OpenMetaverse.Assets;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
+using OpenSim.Region.CoreModules.Avatar.Attachments;
using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
-using OpenSim.Region.OptionalModules.World.NPC;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api;
+using OpenSim.Region.OptionalModules.World.NPC;
using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
@@ -68,7 +69,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
config.Set("Enabled", "true");
m_scene = new SceneHelpers().SetupScene();
- SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule());
+ SceneHelpers.SetupSceneModules(
+ m_scene, initConfigSource, new AvatarFactoryModule(), new AttachmentsModule(), new NPCModule());
m_engine = new XEngine.XEngine();
m_engine.Initialise(initConfigSource);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
index b5a4d93..0a3a75d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
@@ -36,6 +36,7 @@ using OpenMetaverse;
using OpenMetaverse.Assets;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
+using OpenSim.Region.CoreModules.Avatar.Attachments;
using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
using OpenSim.Region.OptionalModules.World.NPC;
using OpenSim.Region.Framework.Scenes;
@@ -71,7 +72,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
config.Set("Enabled", "true");
m_scene = new SceneHelpers().SetupScene();
- SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule());
+ SceneHelpers.SetupSceneModules(
+ m_scene, initConfigSource, new AvatarFactoryModule(), new AttachmentsModule(), new NPCModule());
m_engine = new XEngine.XEngine();
m_engine.Initialise(initConfigSource);
@@ -147,6 +149,44 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
}
+ [Test]
+ public void TestOsNpcLoadAppearance()
+ {
+ TestHelpers.InMethod();
+
+ // Store an avatar with a different height from default in a notecard.
+ UUID userId = TestHelpers.ParseTail(0x1);
+ float firstHeight = 1.9f;
+ float secondHeight = 2.1f;
+ string firstAppearanceNcName = "appearanceNc1";
+ string secondAppearanceNcName = "appearanceNc2";
+
+ ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
+ sp.Appearance.AvatarHeight = firstHeight;
+ SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
+ SceneObjectPart part = so.RootPart;
+ m_scene.AddSceneObject(so);
+
+ OSSL_Api osslApi = new OSSL_Api();
+ osslApi.Initialize(m_engine, part, null);
+
+ osslApi.osOwnerSaveAppearance(firstAppearanceNcName);
+
+ string npcRaw
+ = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
+
+ // Create a second appearance notecard with a different height
+ sp.Appearance.AvatarHeight = secondHeight;
+ osslApi.osOwnerSaveAppearance(secondAppearanceNcName);
+
+ osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
+
+ UUID npcId = new UUID(npcRaw);
+ ScenePresence npc = m_scene.GetScenePresence(npcId);
+ Assert.That(npc, Is.Not.Null);
+ Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(secondHeight));
+ }
+
///
/// Test removal of an owned NPC.
///
@@ -154,7 +194,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
public void TestOsNpcRemoveOwned()
{
TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
// Store an avatar with a different height from default in a notecard.
UUID userId = TestHelpers.ParseTail(0x1);
--
cgit v1.1
From ae662b54ea972e4da4f805fe38b5714d595e032a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 25 Oct 2012 01:07:06 +0100
Subject: Make osNpcCreate() return UUID.Zero instead of throwing an exception
if notecard name is invalid. Make osNpcLoadAppearance() fail silently in
same circumstance rather than throwing exception.
---
.../Shared/Api/Implementation/OSSL_Api.cs | 26 +++++++----
.../Shared/Tests/OSSL_ApiAppearanceTest.cs | 6 +--
.../ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | 54 ++++++++++++++++++++++
3 files changed, 74 insertions(+), 12 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 29bc163..804b0af 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1780,18 +1780,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected string LoadNotecard(string notecardNameOrUuid)
{
UUID assetID = CacheNotecard(notecardNameOrUuid);
- StringBuilder notecardData = new StringBuilder();
- for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
+ if (assetID != UUID.Zero)
{
- string line = NotecardCache.GetLine(assetID, count) + "\n";
-
-// m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line);
-
- notecardData.Append(line);
+ StringBuilder notecardData = new StringBuilder();
+
+ for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
+ {
+ string line = NotecardCache.GetLine(assetID, count) + "\n";
+
+ // m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line);
+
+ notecardData.Append(line);
+ }
+
+ return notecardData.ToString();
}
- return notecardData.ToString();
+ return null;
}
///
@@ -2407,6 +2413,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
string appearanceSerialized = LoadNotecard(notecard);
+
+ if (appearanceSerialized == null)
+ return;
+
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
index eb51c4e..c401794 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
@@ -36,12 +36,11 @@ using OpenMetaverse;
using OpenMetaverse.Assets;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
-using OpenSim.Region.CoreModules.Avatar.Attachments;
using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
+using OpenSim.Region.OptionalModules.World.NPC;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api;
-using OpenSim.Region.OptionalModules.World.NPC;
using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
@@ -69,8 +68,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
config.Set("Enabled", "true");
m_scene = new SceneHelpers().SetupScene();
- SceneHelpers.SetupSceneModules(
- m_scene, initConfigSource, new AvatarFactoryModule(), new AttachmentsModule(), new NPCModule());
+ SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule());
m_engine = new XEngine.XEngine();
m_engine.Initialise(initConfigSource);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
index 0a3a75d..4e58315 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
@@ -114,6 +114,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
}
+ [Test]
+ public void TestOsNpcCreateNotExistingNotecard()
+ {
+ TestHelpers.InMethod();
+
+ UUID userId = TestHelpers.ParseTail(0x1);
+
+ SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
+ m_scene.AddSceneObject(so);
+
+ OSSL_Api osslApi = new OSSL_Api();
+ osslApi.Initialize(m_engine, so.RootPart, null);
+
+ string npcRaw
+ = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name");
+
+ UUID npcId = new UUID(npcRaw);
+ Assert.That(npcId, Is.EqualTo(UUID.Zero));
+ }
+
///
/// Test creation of an NPC where the appearance data comes from an avatar already in the region.
///
@@ -187,6 +207,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(secondHeight));
}
+ [Test]
+ public void TestOsNpcLoadAppearanceNotExistingNotecard()
+ {
+ TestHelpers.InMethod();
+
+ // Store an avatar with a different height from default in a notecard.
+ UUID userId = TestHelpers.ParseTail(0x1);
+ float firstHeight = 1.9f;
+ float secondHeight = 2.1f;
+ string firstAppearanceNcName = "appearanceNc1";
+ string secondAppearanceNcName = "appearanceNc2";
+
+ ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
+ sp.Appearance.AvatarHeight = firstHeight;
+ SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
+ SceneObjectPart part = so.RootPart;
+ m_scene.AddSceneObject(so);
+
+ OSSL_Api osslApi = new OSSL_Api();
+ osslApi.Initialize(m_engine, part, null);
+
+ osslApi.osOwnerSaveAppearance(firstAppearanceNcName);
+
+ string npcRaw
+ = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
+
+ osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
+
+ UUID npcId = new UUID(npcRaw);
+ ScenePresence npc = m_scene.GetScenePresence(npcId);
+ Assert.That(npc, Is.Not.Null);
+ Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(firstHeight));
+ }
+
///
/// Test removal of an owned NPC.
///
--
cgit v1.1
From d9aaf51561ea7bb2ee030c648611a5281f21ec49 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 25 Oct 2012 02:52:20 +0100
Subject: When scripts generate expected exceptions (e.g. due to checked bad
parameter) throw ScriptException instead of just a plain old exception.
This is to make it easier to distinguish these exceptions from unexpected OpenSimulator problems internally and in regression tests.
No functional changes.
---
.../Framework/Scenes/Scene.PacketHandlers.cs | 5 ++-
.../Shared/Api/Implementation/LSL_Api.cs | 4 +--
.../Shared/Api/Implementation/MOD_Api.cs | 10 +++---
.../Shared/Api/Implementation/OSSL_Api.cs | 2 +-
.../Region/ScriptEngine/Shared/ScriptException.cs | 40 ++++++++++++++++++++++
5 files changed, 52 insertions(+), 9 deletions(-)
create mode 100644 OpenSim/Region/ScriptEngine/Shared/ScriptException.cs
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 6e53951..99bf72a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -38,7 +38,6 @@ namespace OpenSim.Region.Framework.Scenes
{
public partial class Scene
{
-
protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
{
@@ -66,6 +65,10 @@ namespace OpenSim.Region.Framework.Scenes
args.From = fromName;
args.TargetUUID = targetID;
+// m_log.DebugFormat(
+// "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}",
+// args.Message.Replace("\n", "\\n"), args.Channel, args.Type, fromName, broadcast);
+
if (broadcast)
EventManager.TriggerOnChatBroadcast(this, args);
else
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index cf801ba..dc791d3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -10685,12 +10685,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal void Deprecated(string command)
{
- throw new Exception("Command deprecated: " + command);
+ throw new ScriptException("Command deprecated: " + command);
}
internal void LSLError(string msg)
{
- throw new Exception("LSL Runtime Error: " + msg);
+ throw new ScriptException("LSL Runtime Error: " + msg);
}
public delegate void AssetRequestCallback(UUID assetID, AssetBase asset);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 6809c09..a830a15 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -95,13 +95,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal void MODError(string msg)
{
- throw new Exception("MOD Runtime Error: " + msg);
+ throw new ScriptException("MOD Runtime Error: " + msg);
}
- //
- //Dumps an error message on the debug console.
- //
-
+ ///
+ /// Dumps an error message on the debug console.
+ ///
+ ///
internal void MODShoutError(string message)
{
if (message.Length > 1023)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 804b0af..5301ccd 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -210,7 +210,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal void OSSLError(string msg)
{
- throw new Exception("OSSL Runtime Error: " + msg);
+ throw new ScriptException("OSSL Runtime Error: " + msg);
}
///
diff --git a/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs
new file mode 100644
index 0000000..ae67fc5
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+
+namespace OpenSim.Region.ScriptEngine.Shared
+{
+ public class ScriptException : Exception
+ {
+ public ScriptException() : base() {}
+
+ public ScriptException(string message) : base(message) {}
+
+ public ScriptException(string message, Exception innerException) : base(message, innerException) {}
+ }
+}
\ No newline at end of file
--
cgit v1.1
From 8af8319b95c14819d0305527f8f6876a334fa3c0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 25 Oct 2012 03:02:00 +0100
Subject: Get osNpcCreate() and osNpcLoadAppearance() to generate a script
error if appearance notecard does not exist, rather than returning UUID.Zero
or silently failing.
---
.../Shared/Api/Implementation/OSSL_Api.cs | 11 ++++----
.../ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | 30 +++++++++++++++++-----
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 5301ccd..0811519 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2346,11 +2346,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
appearance = new AvatarAppearance();
appearance.Unpack(appearanceOsd);
}
+ else
+ {
+ OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
+ }
}
- if (appearance == null)
- return new LSL_Key(UUID.Zero.ToString());
-
UUID ownerID = UUID.Zero;
if (owned)
ownerID = m_host.OwnerID;
@@ -2415,8 +2416,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string appearanceSerialized = LoadNotecard(notecard);
if (appearanceSerialized == null)
- return;
-
+ OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
+
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
index 4e58315..b49bcc2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
@@ -127,11 +127,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
OSSL_Api osslApi = new OSSL_Api();
osslApi.Initialize(m_engine, so.RootPart, null);
- string npcRaw
- = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name");
-
- UUID npcId = new UUID(npcRaw);
- Assert.That(npcId, Is.EqualTo(UUID.Zero));
+ string npcRaw;
+ bool gotExpectedException = false;
+ try
+ {
+ npcRaw
+ = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name");
+ }
+ catch (ScriptException)
+ {
+ gotExpectedException = true;
+ }
+
+ Assert.That(gotExpectedException, Is.True);
}
///
@@ -233,7 +241,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
string npcRaw
= osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
- osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
+ bool gotExpectedException = false;
+ try
+ {
+ osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
+ }
+ catch (ScriptException)
+ {
+ gotExpectedException = true;
+ }
+
+ Assert.That(gotExpectedException, Is.True);
UUID npcId = new UUID(npcRaw);
ScenePresence npc = m_scene.GetScenePresence(npcId);
--
cgit v1.1
From c13a99dc5cc82efac5497dab27dcb6b0d9865cea Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 25 Oct 2012 03:26:12 +0100
Subject: Fix script error messages not showing up in viewer 3 and associated
viewers.
Viewer 3 will discard such a message if the chat message owner does not match the avatar.
We were filling the ownerID with the primID, so this never matched, hence viewer 3 did not see any script error messages.
This commit fills the ownerID in with the prim ownerID so the script owner will receive script error messages.
This does not affect viewer 1 and associated viewers which continue to process script errors as normal.
---
OpenSim/Framework/Client/IClientChat.cs | 7 ++--
OpenSim/Framework/IClientAPI.cs | 16 +++++++--
.../Region/ClientStack/Linden/UDP/LLClientView.cs | 7 ++--
.../Region/CoreModules/Avatar/Chat/ChatModule.cs | 39 +++++++++++++++-------
.../Framework/Scenes/Scene.PacketHandlers.cs | 12 +++++++
.../Server/IRCClientView.cs | 3 +-
.../Avatar/Concierge/ConciergeModule.cs | 5 +--
.../Region/OptionalModules/World/NPC/NPCAvatar.cs | 10 +++---
OpenSim/Tests/Common/Mock/TestClient.cs | 10 ++----
9 files changed, 75 insertions(+), 34 deletions(-)
diff --git a/OpenSim/Framework/Client/IClientChat.cs b/OpenSim/Framework/Client/IClientChat.cs
index 078ea9b..86b1faa 100644
--- a/OpenSim/Framework/Client/IClientChat.cs
+++ b/OpenSim/Framework/Client/IClientChat.cs
@@ -33,7 +33,8 @@ namespace OpenSim.Framework.Client
{
event ChatMessage OnChatFromClient;
- void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source,
- byte audible);
+ void SendChatMessage(
+ string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source,
+ byte audible);
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 9856978..87433cc 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -1099,8 +1099,20 @@ namespace OpenSim.Framework
void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs);
void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args);
- void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source,
- byte audible);
+ ///
+ /// Send chat to the viewer.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ void SendChatMessage(
+ string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source,
+ byte audible);
void SendInstantMessage(GridInstantMessage im);
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 7427c59..8e5a6d2 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -817,8 +817,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OutPacket(mov, ThrottleOutPacketType.Unknown);
}
- public void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName,
- UUID fromAgentID, byte source, byte audible)
+ public void SendChatMessage(
+ string message, byte type, Vector3 fromPos, string fromName,
+ UUID fromAgentID, UUID ownerID, byte source, byte audible)
{
ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
reply.ChatData.Audible = audible;
@@ -827,7 +828,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
reply.ChatData.SourceType = source;
reply.ChatData.Position = fromPos;
reply.ChatData.FromName = Util.StringToBytes256(fromName);
- reply.ChatData.OwnerID = fromAgentID;
+ reply.ChatData.OwnerID = ownerID;
reply.ChatData.SourceID = fromAgentID;
OutPacket(reply, ThrottleOutPacketType.Task);
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index e4452fb..ddf92c3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -186,6 +186,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
{
string fromName = c.From;
UUID fromID = UUID.Zero;
+ UUID ownerID = UUID.Zero;
UUID targetID = c.TargetUUID;
string message = c.Message;
IScene scene = c.Scene;
@@ -208,12 +209,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
fromPos = avatar.AbsolutePosition;
fromName = avatar.Name;
fromID = c.Sender.AgentId;
+ ownerID = c.Sender.AgentId;
break;
case ChatSourceType.Object:
fromID = c.SenderUUID;
+ if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
+ ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
+
break;
}
@@ -236,7 +241,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
s.ForEachRootScenePresence(
delegate(ScenePresence presence)
{
- if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false))
+ if (TrySendChatMessage(
+ presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false))
receiverIDs.Add(presence.UUID);
}
);
@@ -248,8 +254,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
ScenePresence presence = s.GetScenePresence(targetID);
if (presence != null && !presence.IsChildAgent)
{
- if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, ChatTypeEnum.Say, message, sourceType, true))
- receiverIDs.Add(presence.UUID);
+ if (TrySendChatMessage(
+ presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true))
+ receiverIDs.Add(presence.UUID);
}
}
}
@@ -305,9 +312,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
(null != c.SenderObject) &&
(((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
return;
-
- client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
- (byte)sourceType, (byte)ChatAudibleLevel.Fully);
+
+ client.SendChatMessage(
+ c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID,
+ (byte)sourceType, (byte)ChatAudibleLevel.Fully);
+
receiverIDs.Add(client.AgentId);
});
@@ -322,15 +331,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
///
/// /param>
///
+ ///
+ /// Owner of the message. For at least some messages from objects, this has to be correctly filled with the owner's UUID.
+ /// This is the case for script error messages in viewer 3 since LLViewer change EXT-7762
+ ///
///
///
///
///
/// true if the message was sent to the receiver, false if it was not sent due to failing a
/// precondition
- protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
- UUID fromAgentID, string fromName, ChatTypeEnum type,
- string message, ChatSourceType src, bool ignoreDistance)
+ protected virtual bool TrySendChatMessage(
+ ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
+ UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type,
+ string message, ChatSourceType src, bool ignoreDistance)
{
// don't send stuff to child agents
if (presence.IsChildAgent) return false;
@@ -353,10 +367,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
}
// TODO: should change so the message is sent through the avatar rather than direct to the ClientView
- presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
- fromAgentID, (byte)src, (byte)ChatAudibleLevel.Fully);
+ presence.ControllingClient.SendChatMessage(
+ message, (byte) type, fromPos, fromName,
+ fromAgentID, ownerID, (byte)src, (byte)ChatAudibleLevel.Fully);
return true;
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 99bf72a..df43271 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -38,6 +38,18 @@ namespace OpenSim.Region.Framework.Scenes
{
public partial class Scene
{
+ ///
+ /// Send chat to listeners.
+ ///
+ ///
+ /// /param>
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
{
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index e93bd7c..781539a 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -954,7 +954,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
}
- public void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source, byte audible)
+ public void SendChatMessage(
+ string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, byte audible)
{
if (audible > 0 && message.Length > 0)
IRC_SendChannelPrivmsg(fromName, message);
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
index e22618d..5c3be29 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
@@ -546,8 +546,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
c.SenderUUID = UUID.Zero;
c.Scene = agent.Scene;
- agent.ControllingClient.SendChatMessage(msg, (byte) ChatTypeEnum.Say, PosOfGod, m_whoami, UUID.Zero,
- (byte)ChatSourceType.Object, (byte)ChatAudibleLevel.Fully);
+ agent.ControllingClient.SendChatMessage(
+ msg, (byte) ChatTypeEnum.Say, PosOfGod, m_whoami, UUID.Zero, UUID.Zero,
+ (byte)ChatSourceType.Object, (byte)ChatAudibleLevel.Fully);
}
private static void checkStringParameters(XmlRpcRequest request, string[] param)
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index ffd4222..5ea2bcd 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -603,13 +603,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{
}
- public virtual void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName,
- UUID fromAgentID, byte source, byte audible)
+ public virtual void SendChatMessage(
+ string message, byte type, Vector3 fromPos, string fromName,
+ UUID fromAgentID, UUID ownerID, byte source, byte audible)
{
}
- public virtual void SendChatMessage(byte[] message, byte type, Vector3 fromPos, string fromName,
- UUID fromAgentID, byte source, byte audible)
+ public virtual void SendChatMessage(
+ byte[] message, byte type, Vector3 fromPos, string fromName,
+ UUID fromAgentID, UUID ownerID, byte source, byte audible)
{
}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index bb8b935..dde37ab 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -528,13 +528,9 @@ namespace OpenSim.Tests.Common.Mock
{
}
- public virtual void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName,
- UUID fromAgentID, byte source, byte audible)
- {
- }
-
- public virtual void SendChatMessage(byte[] message, byte type, Vector3 fromPos, string fromName,
- UUID fromAgentID, byte source, byte audible)
+ public virtual void SendChatMessage(
+ string message, byte type, Vector3 fromPos, string fromName,
+ UUID fromAgentID, UUID ownerID, byte source, byte audible)
{
}
--
cgit v1.1
From fa484c3494a7190b4d7526094347be74d091e125 Mon Sep 17 00:00:00 2001
From: nebadon
Date: Thu, 25 Oct 2012 11:31:25 -0700
Subject: Fix for Mantis 0006376: Avatar no longer show Walking animation when
any AO hud is loaded. Thank you tglion
---
OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
index ad421ee..9ed4f47 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
@@ -87,7 +87,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
{
if (m_defaultAnimation.AnimID == animID)
{
- m_defaultAnimation = new OpenSim.Framework.Animation(UUID.Zero, 1, UUID.Zero);
+ m_defaultAnimation = new OpenSim.Framework.Animation(animID, 1, UUID.Zero);
}
else if (HasAnimation(animID))
{
--
cgit v1.1
From 22e216fd123744f6c87024fc18f3c9b306777fe2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 25 Oct 2012 22:55:29 +0100
Subject: In Scene.Close(), dispose of the physics scene after base.Close()
since script events can still access Physics scene until the script engine
shuts down (triggered off base.Close())
XEngine listeners to EventManager.OnShutdown which is triggered from base.Close().
Possibly it could listen for the earlier OnSceneShuttingDown instead, but the easier solution right now is to relocate disposal of the physics scene.
This bug has existed since c150320 (Thu Jul 26 15:27:18 2012) and was in 0.7.4
---
OpenSim/Region/Framework/Scenes/Scene.cs | 14 ++++++++------
OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | 17 +++++++++++++++++
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 532598a..d48dc11 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1310,6 +1310,14 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.Close();
+ if (!GridService.DeregisterRegion(RegionInfo.RegionID))
+ m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name);
+
+ base.Close();
+
+ // XEngine currently listens to the EventManager.OnShutdown event to trigger script stop and persistence.
+ // Therefore. we must dispose of the PhysicsScene after this to prevent a window where script code can
+ // attempt to reference a null or disposed physics scene.
if (PhysicsScene != null)
{
PhysicsScene phys = PhysicsScene;
@@ -1318,12 +1326,6 @@ namespace OpenSim.Region.Framework.Scenes
phys.Dispose();
phys = null;
}
-
- 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();
}
///
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index d722a09..ac3da1e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -65,5 +65,22 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(scene.Frame, Is.EqualTo(1));
}
+
+ [Test]
+ public void TestShutdownScene()
+ {
+ TestHelpers.InMethod();
+
+ Scene scene = new SceneHelpers().SetupScene();
+ scene.Close();
+
+ Assert.That(scene.ShuttingDown, Is.True);
+ Assert.That(scene.Active, Is.False);
+
+ // Trying to update a shutdown scene should result in no update
+ scene.Update(1);
+
+ Assert.That(scene.Frame, Is.EqualTo(0));
+ }
}
}
\ No newline at end of file
--
cgit v1.1
From 424f68b64b72ed8402a01c4d9090bfe6dc7d2b09 Mon Sep 17 00:00:00 2001
From: Oren Hurvitz
Date: Sun, 21 Oct 2012 13:17:39 +0200
Subject: Changed duplicate Asset ID's to unique ID's in
CollisionSoundsAssetSet.xml
---
.../CollisionSoundsAssetSet/CollisionSoundsAssetSet.xml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/bin/assets/CollisionSoundsAssetSet/CollisionSoundsAssetSet.xml b/bin/assets/CollisionSoundsAssetSet/CollisionSoundsAssetSet.xml
index 7498ae0..b570c55 100644
--- a/bin/assets/CollisionSoundsAssetSet/CollisionSoundsAssetSet.xml
+++ b/bin/assets/CollisionSoundsAssetSet/CollisionSoundsAssetSet.xml
@@ -303,37 +303,37 @@
-
+
--
cgit v1.1
From b4923da3348b05e4b85f842210bea4e6f08b4cef Mon Sep 17 00:00:00 2001
From: Oren Hurvitz
Date: Mon, 13 Aug 2012 16:02:50 +0300
Subject: Changed "course" to "coarse" in several places
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 14 +++++++-------
.../RegionCombinerModule/RegionCombinerModule.cs | 20 ++++++++++----------
.../RegionCombinerModule/RegionCourseLocation.cs | 2 +-
3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 1222ac6..b6d0a3b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Region.Framework.Scenes
public ScriptControlled eventControls;
}
- public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List coarseLocations, List avatarUUIDs);
+ public delegate void SendCoarseLocationsMethod(UUID scene, ScenePresence presence, List coarseLocations, List avatarUUIDs);
public class ScenePresence : EntityBase, IScenePresence
{
@@ -186,7 +186,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public bool SitGround { get; private set; }
- private SendCourseLocationsMethod m_sendCourseLocationsMethod;
+ private SendCoarseLocationsMethod m_sendCoarseLocationsMethod;
//private Vector3 m_requestedSitOffset = new Vector3();
@@ -695,7 +695,7 @@ namespace OpenSim.Region.Framework.Scenes
AttachmentsSyncLock = new Object();
AllowMovement = true;
IsChildAgent = true;
- m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
+ m_sendCoarseLocationsMethod = SendCoarseLocationsDefault;
Animator = new ScenePresenceAnimator(this);
PresenceType = type;
DrawDistance = world.DefaultDrawDistance;
@@ -2432,17 +2432,17 @@ namespace OpenSim.Region.Framework.Scenes
public void SendCoarseLocations(List coarseLocations, List avatarUUIDs)
{
- SendCourseLocationsMethod d = m_sendCourseLocationsMethod;
+ SendCoarseLocationsMethod d = m_sendCoarseLocationsMethod;
if (d != null)
{
d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs);
}
}
- public void SetSendCourseLocationMethod(SendCourseLocationsMethod d)
+ public void SetSendCoarseLocationMethod(SendCoarseLocationsMethod d)
{
if (d != null)
- m_sendCourseLocationsMethod = d;
+ m_sendCoarseLocationsMethod = d;
}
public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List coarseLocations, List avatarUUIDs)
@@ -2646,7 +2646,7 @@ namespace OpenSim.Region.Framework.Scenes
#region Significant Movement Method
///
- /// This checks for a significant movement and sends a courselocationchange update
+ /// This checks for a significant movement and sends a coarselocationchange update
///
protected void CheckForSignificantMovement()
{
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
index 190fca0..905540d 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
@@ -719,21 +719,21 @@ namespace OpenSim.Region.RegionCombinerModule
rootConn.ClientEventForwarder = new RegionCombinerClientEventForwarder(rootConn);
// Sets up the CoarseLocationUpdate forwarder for this root region
- scene.EventManager.OnNewPresence += SetCourseLocationDelegate;
+ scene.EventManager.OnNewPresence += SetCoarseLocationDelegate;
// Adds this root region to a dictionary of regions that are connectable
m_regions.Add(scene.RegionInfo.originRegionID, rootConn);
}
}
- private void SetCourseLocationDelegate(ScenePresence presence)
+ private void SetCoarseLocationDelegate(ScenePresence presence)
{
- presence.SetSendCourseLocationMethod(SendCourseLocationUpdates);
+ presence.SetSendCoarseLocationMethod(SendCoarseLocationUpdates);
}
// This delegate was refactored for non-combined regions.
// This combined region version will not use the pre-compiled lists of locations and ids
- private void SendCourseLocationUpdates(UUID sceneId, ScenePresence presence, List coarseLocations, List avatarUUIDs)
+ private void SendCoarseLocationUpdates(UUID sceneId, ScenePresence presence, List coarseLocations, List avatarUUIDs)
{
RegionConnections connectiondata = null;
lock (m_regions)
@@ -756,18 +756,18 @@ namespace OpenSim.Region.RegionCombinerModule
}
});
- DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence);
+ DistributeCoarseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence);
}
- private void DistributeCourseLocationUpdates(List locations, List uuids,
+ private void DistributeCoarseLocationUpdates(List locations, List uuids,
RegionConnections connectiondata, ScenePresence rootPresence)
{
RegionData[] rdata = connectiondata.ConnectedRegions.ToArray();
//List clients = new List();
- Dictionary updates = new Dictionary();
+ Dictionary updates = new Dictionary();
// Root Region entry
- RegionCourseLocationStruct rootupdatedata = new RegionCourseLocationStruct();
+ RegionCoarseLocationStruct rootupdatedata = new RegionCoarseLocationStruct();
rootupdatedata.Locations = new List();
rootupdatedata.Uuids = new List();
rootupdatedata.Offset = Vector2.Zero;
@@ -781,7 +781,7 @@ namespace OpenSim.Region.RegionCombinerModule
foreach (RegionData regiondata in rdata)
{
Vector2 offset = new Vector2(regiondata.Offset.X, regiondata.Offset.Y);
- RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct();
+ RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct();
updatedata.Locations = new List();
updatedata.Uuids = new List();
updatedata.Offset = offset;
@@ -807,7 +807,7 @@ namespace OpenSim.Region.RegionCombinerModule
if (!updates.ContainsKey(offset))
{
// This shouldn't happen
- RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct();
+ RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct();
updatedata.Locations = new List();
updatedata.Uuids = new List();
updatedata.Offset = offset;
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs b/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs
index 53a678f..224ac99 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs
@@ -33,7 +33,7 @@ using OpenSim.Framework;
namespace OpenSim.Region.RegionCombinerModule
{
- struct RegionCourseLocationStruct
+ struct RegionCoarseLocationStruct
{
public List Locations;
public List Uuids;
--
cgit v1.1
From dc17cee044e0d2d17e8152eb31829c3ad5a99359 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 25 Oct 2012 23:47:13 +0100
Subject: minor: if a scene is already shutting down on Scene.Close(), warn and
exit instead of attempting to run another shutdown concurrently.
Thanks to Oren Hurvitz for this change.
---
OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d48dc11..0f39671 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1267,6 +1267,12 @@ namespace OpenSim.Region.Framework.Scenes
// This is the method that shuts down the scene.
public override void Close()
{
+ if (m_shuttingDown)
+ {
+ m_log.WarnFormat("[SCENE]: Ignoring close request because already closing {0}", Name);
+ return;
+ }
+
m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName);
StatsReporter.Close();
--
cgit v1.1
From 85c909c0b551630d17c3f3bf4aff20e7bf8008e5 Mon Sep 17 00:00:00 2001
From: Oren Hurvitz
Date: Tue, 23 Oct 2012 10:46:45 +0200
Subject: Fixed saving non-square multi-region OARs
---
OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs
index a66ed88..d8dace2 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs
@@ -110,7 +110,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
lastX = (lastX == null) ? curLastX : (lastX > curLastX) ? lastX : curLastX;
}
- Rect = new Rectangle((int)firstX, (int)firstY, (int)(lastY - firstY + 1), (int)(lastX - firstX + 1));
+ Rect = new Rectangle((int)firstX, (int)firstY, (int)(lastX - firstX + 1), (int)(lastY - firstY + 1));
// Calculate the subdirectory in which each region will be stored in the archive
--
cgit v1.1
From 2fb89b5aac0369e126234a8189d676d904d0ae33 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Oct 2012 01:15:16 +0100
Subject: Comment out InventoryTransferModule.NeedSceneCacheClear() and
invocations since the call itself does nothing and the return value is
ignored by all callers.
This is a very old method (+4 years) so is probably confusing code cruft.
---
.../Inventory/Transfer/InventoryTransferModule.cs | 154 ++++++++++-----------
.../EntityTransfer/EntityTransferModule.cs | 31 +++--
OpenSim/Region/Framework/Scenes/Scene.cs | 24 ++--
3 files changed, 106 insertions(+), 103 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 33b4839..8ff20dd 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -38,15 +38,15 @@ using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{
- public class InventoryTransferModule : IInventoryTransferModule, ISharedRegionModule
+ public class InventoryTransferModule : ISharedRegionModule
{
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
///
private List m_Scenelist = new List();
- private Dictionary m_AgentRegions =
- new Dictionary();
+// private Dictionary m_AgentRegions =
+// new Dictionary();
private IMessageTransferModule m_TransferModule = null;
private bool m_Enabled = true;
@@ -76,12 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
m_Scenelist.Add(scene);
- scene.RegisterModuleInterface(this);
+// scene.RegisterModuleInterface(this);
scene.EventManager.OnNewClient += OnNewClient;
- scene.EventManager.OnClientClosed += ClientLoggedOut;
+// scene.EventManager.OnClientClosed += ClientLoggedOut;
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
- scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene;
+// scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene;
}
public void RegionLoaded(Scene scene)
@@ -96,9 +96,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
m_Scenelist.Clear();
scene.EventManager.OnNewClient -= OnNewClient;
- scene.EventManager.OnClientClosed -= ClientLoggedOut;
+// scene.EventManager.OnClientClosed -= ClientLoggedOut;
scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
- scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene;
+// scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene;
}
}
}
@@ -106,9 +106,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
public void RemoveRegion(Scene scene)
{
scene.EventManager.OnNewClient -= OnNewClient;
- scene.EventManager.OnClientClosed -= ClientLoggedOut;
+// scene.EventManager.OnClientClosed -= ClientLoggedOut;
scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
- scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene;
+// scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene;
m_Scenelist.Remove(scene);
}
@@ -138,10 +138,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
client.OnInstantMessage += OnInstantMessage;
}
- protected void OnSetRootAgentScene(UUID id, Scene scene)
- {
- m_AgentRegions[id] = scene;
- }
+// protected void OnSetRootAgentScene(UUID id, Scene scene)
+// {
+// m_AgentRegions[id] = scene;
+// }
private Scene FindClientScene(UUID agentId)
{
@@ -448,69 +448,69 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
}
}
- public bool NeedSceneCacheClear(UUID agentID, Scene scene)
- {
- if (!m_AgentRegions.ContainsKey(agentID))
- {
- // Since we can get here two ways, we need to scan
- // the scenes here. This is somewhat more expensive
- // but helps avoid a nasty bug
- //
-
- foreach (Scene s in m_Scenelist)
- {
- ScenePresence presence;
-
- if (s.TryGetScenePresence(agentID, out presence))
- {
- // If the agent is in this scene, then we
- // are being called twice in a single
- // teleport. This is wasteful of cycles
- // but harmless due to this 2nd level check
- //
- // If the agent is found in another scene
- // then the list wasn't current
- //
- // If the agent is totally unknown, then what
- // are we even doing here??
- //
- if (s == scene)
- {
- //m_log.Debug("[INVTRANSFERMOD]: s == scene. Returning true in " + scene.RegionInfo.RegionName);
- return true;
- }
- else
- {
- //m_log.Debug("[INVTRANSFERMOD]: s != scene. Returning false in " + scene.RegionInfo.RegionName);
- return false;
- }
- }
- }
- //m_log.Debug("[INVTRANSFERMOD]: agent not in scene. Returning true in " + scene.RegionInfo.RegionName);
- return true;
- }
-
- // The agent is left in current Scene, so we must be
- // going to another instance
- //
- if (m_AgentRegions[agentID] == scene)
- {
- //m_log.Debug("[INVTRANSFERMOD]: m_AgentRegions[agentID] == scene. Returning true in " + scene.RegionInfo.RegionName);
- m_AgentRegions.Remove(agentID);
- return true;
- }
-
- // Another region has claimed the agent
- //
- //m_log.Debug("[INVTRANSFERMOD]: last resort. Returning false in " + scene.RegionInfo.RegionName);
- return false;
- }
-
- public void ClientLoggedOut(UUID agentID, Scene scene)
- {
- if (m_AgentRegions.ContainsKey(agentID))
- m_AgentRegions.Remove(agentID);
- }
+// public bool NeedSceneCacheClear(UUID agentID, Scene scene)
+// {
+// if (!m_AgentRegions.ContainsKey(agentID))
+// {
+// // Since we can get here two ways, we need to scan
+// // the scenes here. This is somewhat more expensive
+// // but helps avoid a nasty bug
+// //
+//
+// foreach (Scene s in m_Scenelist)
+// {
+// ScenePresence presence;
+//
+// if (s.TryGetScenePresence(agentID, out presence))
+// {
+// // If the agent is in this scene, then we
+// // are being called twice in a single
+// // teleport. This is wasteful of cycles
+// // but harmless due to this 2nd level check
+// //
+// // If the agent is found in another scene
+// // then the list wasn't current
+// //
+// // If the agent is totally unknown, then what
+// // are we even doing here??
+// //
+// if (s == scene)
+// {
+// //m_log.Debug("[INVTRANSFERMOD]: s == scene. Returning true in " + scene.RegionInfo.RegionName);
+// return true;
+// }
+// else
+// {
+// //m_log.Debug("[INVTRANSFERMOD]: s != scene. Returning false in " + scene.RegionInfo.RegionName);
+// return false;
+// }
+// }
+// }
+// //m_log.Debug("[INVTRANSFERMOD]: agent not in scene. Returning true in " + scene.RegionInfo.RegionName);
+// return true;
+// }
+//
+// // The agent is left in current Scene, so we must be
+// // going to another instance
+// //
+// if (m_AgentRegions[agentID] == scene)
+// {
+// //m_log.Debug("[INVTRANSFERMOD]: m_AgentRegions[agentID] == scene. Returning true in " + scene.RegionInfo.RegionName);
+// m_AgentRegions.Remove(agentID);
+// return true;
+// }
+//
+// // Another region has claimed the agent
+// //
+// //m_log.Debug("[INVTRANSFERMOD]: last resort. Returning false in " + scene.RegionInfo.RegionName);
+// return false;
+// }
+//
+// public void ClientLoggedOut(UUID agentID, Scene scene)
+// {
+// if (m_AgentRegions.ContainsKey(agentID))
+// m_AgentRegions.Remove(agentID);
+// }
///
///
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 90fe430..7498cfe 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -672,13 +672,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
sp.Reset();
}
- // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
- if (sp.Scene.NeedSceneCacheClear(sp.UUID))
- {
- m_log.DebugFormat(
- "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed",
- sp.UUID);
- }
+ // Commented pending deletion since this method no longer appears to do anything at all
+// // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
+// if (sp.Scene.NeedSceneCacheClear(sp.UUID))
+// {
+// m_log.DebugFormat(
+// "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed",
+// sp.UUID);
+// }
m_entityTransferStateMachine.ResetFromTransit(sp.UUID);
}
@@ -1237,14 +1238,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
AgentHasMovedAway(agent, false);
- // the user may change their profile information in other region,
- // so the userinfo in UserProfileCache is not reliable any more, delete it
- // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
- if (agent.Scene.NeedSceneCacheClear(agent.UUID))
- {
- m_log.DebugFormat(
- "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID);
- }
+// // the user may change their profile information in other region,
+// // so the userinfo in UserProfileCache is not reliable any more, delete it
+// // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
+// if (agent.Scene.NeedSceneCacheClear(agent.UUID))
+// {
+// m_log.DebugFormat(
+// "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID);
+// }
//m_log.Debug("AFTER CROSS");
//Scene.DumpChildrenSeeds(UUID);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0f39671..9c61fe7 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3435,9 +3435,10 @@ namespace OpenSim.Region.Framework.Scenes
if (closeChildAgents && CapsModule != null)
CapsModule.RemoveCaps(agentID);
- // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
- // this method is doing is HORRIBLE!!!
- avatar.Scene.NeedSceneCacheClear(avatar.UUID);
+// // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
+// // this method is doing is HORRIBLE!!!
+ // Commented pending deletion since this method no longer appears to do anything at all
+// avatar.Scene.NeedSceneCacheClear(avatar.UUID);
if (closeChildAgents && !isChildAgent)
{
@@ -4873,14 +4874,15 @@ namespace OpenSim.Region.Framework.Scenes
client.SendRegionHandle(regionID, handle);
}
- public bool NeedSceneCacheClear(UUID agentID)
- {
- IInventoryTransferModule inv = RequestModuleInterface();
- if (inv == null)
- return true;
-
- return inv.NeedSceneCacheClear(agentID, this);
- }
+// Commented pending deletion since this method no longer appears to do anything at all
+// public bool NeedSceneCacheClear(UUID agentID)
+// {
+// IInventoryTransferModule inv = RequestModuleInterface();
+// if (inv == null)
+// return true;
+//
+// return inv.NeedSceneCacheClear(agentID, this);
+// }
public void CleanTempObjects()
{
--
cgit v1.1
From 01972cc9e8f3288330cdc7ba343b99be7f1491ec Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Tue, 23 Oct 2012 11:34:43 +0100
Subject: system ints can end up in LSL lists, which can cause
counter-intuitive unknown list element type errors in ConvertFromLSL (via
modInvoke)
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index a830a15..60bb107 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -359,6 +359,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
result[i] = (string)(LSL_String)plist[i];
else if (plist[i] is LSL_Integer)
result[i] = (int)(LSL_Integer)plist[i];
+ else if (plist[i] is int)
+ result[i] = plist[i];
else if (plist[i] is LSL_Float)
result[i] = (float)(LSL_Float)plist[i];
else if (plist[i] is LSL_Key)
--
cgit v1.1
From ecdb88679e6bb59da13da0f3994cc42d8e84a30d Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Tue, 23 Oct 2012 11:39:55 +0100
Subject: Removing the apparently superfluous explicit namespace reference so
that the if-else-if-else block in ConvertFromLSL can have a consistent
appearance
---
.../Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 60bb107..a181dbe 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -366,15 +366,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
else if (plist[i] is LSL_Key)
result[i] = new UUID((LSL_Key)plist[i]);
else if (plist[i] is LSL_Rotation)
- {
- result[i] = (OpenMetaverse.Quaternion)(
- (LSL_Rotation)plist[i]);
- }
+ result[i] = (Quaternion)((LSL_Rotation)plist[i]);
else if (plist[i] is LSL_Vector)
- {
- result[i] = (OpenMetaverse.Vector3)(
- (LSL_Vector)plist[i]);
- }
+ result[i] = (Vector3)((LSL_Vector)plist[i]);
else
MODError(String.Format("{0}: unknown LSL list element type", fname));
}
--
cgit v1.1
From 1b3b7a61acf8784af3167a35c0f06eaeb413af9c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Oct 2012 01:50:46 +0100
Subject: minor: Add comment as to why we are pulcking plain old ints out of
the LSL_List when converting values from LSL for modInvoke()
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index a181dbe..8f34833 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -359,6 +359,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
result[i] = (string)(LSL_String)plist[i];
else if (plist[i] is LSL_Integer)
result[i] = (int)(LSL_Integer)plist[i];
+ // The int check exists because of the many plain old int script constants in ScriptBase which
+ // are not LSL_Integers.
else if (plist[i] is int)
result[i] = plist[i];
else if (plist[i] is LSL_Float)
--
cgit v1.1
From 18b1ee6f379f4d34f72a9056bf6cdf185311fd05 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Tue, 23 Oct 2012 15:29:40 +0100
Subject: Formatting and casing correction in WorldCommModule, trailing new
line in OSSL to get git diff to not complain
---
OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | 6 +++---
OpenSim/Region/Framework/Interfaces/IWorldComm.cs | 2 +-
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
index 8358bc0..c68ed6b 100644
--- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
@@ -472,8 +472,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
if (coll.Count > 0)
{
- // special case, called with same filter settings, return same handle
- // (2008-05-02, tested on 1.21.1 server, still holds)
+ // special case, called with same filter settings, return same
+ // handle (2008-05-02, tested on 1.21.1 server, still holds)
return coll[0].GetHandle();
}
@@ -712,7 +712,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
}
}
- public class ListenerInfo: IWorldCommListenerInfo
+ public class ListenerInfo : IWorldCommListenerInfo
{
private bool m_active; // Listener is active or not
private int m_handle; // Assigned handle of this listener
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
index 4e74781..8d88065 100644
--- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// the script during 'peek' time. Parameter hostID is needed to
/// determine the position of the script.
///
- /// localID of the script engine
+ /// localID of the script engine
/// UUID of the script engine
/// UUID of the SceneObjectPart
/// channel to listen on
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 0811519..0650b90 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3648,4 +3648,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
DropAttachmentAt(false, pos, rot);
}
}
-}
\ No newline at end of file
+}
--
cgit v1.1
From e977761071a2d614a9a621437fbf86479b414759 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Tue, 23 Oct 2012 15:42:16 +0100
Subject: adding ability for listeners to be filtered by regular expressions
and a general-purpose function to see if a given string matches a given regex
---
.../Scripting/WorldComm/WorldCommModule.cs | 129 ++++++++++++++++++---
OpenSim/Region/Framework/Interfaces/IWorldComm.cs | 25 ++++
.../Shared/Api/Implementation/OSSL_Api.cs | 63 ++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 24 ++++
.../Shared/Api/Runtime/LSL_Constants.cs | 10 ++
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 ++
6 files changed, 242 insertions(+), 19 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
index c68ed6b..cf0eb2a 100644
--- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Text.RegularExpressions;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -170,12 +171,42 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
/// UUID of the SceneObjectPart
/// channel to listen on
/// name to filter on
- /// key to filter on (user given, could be totally faked)
+ ///
+ /// key to filter on (user given, could be totally faked)
+ ///
/// msg to filter on
/// number of the scripts handle
- public int Listen(uint localID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg)
+ public int Listen(uint localID, UUID itemID, UUID hostID, int channel,
+ string name, UUID id, string msg)
{
- return m_listenerManager.AddListener(localID, itemID, hostID, channel, name, id, msg);
+ return m_listenerManager.AddListener(localID, itemID, hostID,
+ channel, name, id, msg);
+ }
+
+ ///
+ /// Create a listen event callback with the specified filters.
+ /// The parameters localID,itemID are needed to uniquely identify
+ /// the script during 'peek' time. Parameter hostID is needed to
+ /// determine the position of the script.
+ ///
+ /// localID of the script engine
+ /// UUID of the script engine
+ /// UUID of the SceneObjectPart
+ /// channel to listen on
+ /// name to filter on
+ ///
+ /// key to filter on (user given, could be totally faked)
+ ///
+ /// msg to filter on
+ ///
+ /// Bitfield indicating which strings should be processed as regex.
+ ///
+ /// number of the scripts handle
+ public int Listen(uint localID, UUID itemID, UUID hostID, int channel,
+ string name, UUID id, string msg, int regexBitfield)
+ {
+ return m_listenerManager.AddListener(localID, itemID, hostID,
+ channel, name, id, msg, regexBitfield);
}
///
@@ -465,10 +496,20 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
m_curlisteners = 0;
}
- public int AddListener(uint localID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg)
+ public int AddListener(uint localID, UUID itemID, UUID hostID,
+ int channel, string name, UUID id, string msg)
+ {
+ return AddListener(localID, itemID, hostID, channel, name, id,
+ msg, 0);
+ }
+
+ public int AddListener(uint localID, UUID itemID, UUID hostID,
+ int channel, string name, UUID id, string msg,
+ int regexBitfield)
{
// do we already have a match on this particular filter event?
- List coll = GetListeners(itemID, channel, name, id, msg);
+ List coll = GetListeners(itemID, channel, name, id,
+ msg);
if (coll.Count > 0)
{
@@ -485,7 +526,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
if (newHandle > 0)
{
- ListenerInfo li = new ListenerInfo(newHandle, localID, itemID, hostID, channel, name, id, msg);
+ ListenerInfo li = new ListenerInfo(newHandle, localID,
+ itemID, hostID, channel, name, id, msg,
+ regexBitfield);
List listeners;
if (!m_listeners.TryGetValue(channel,out listeners))
@@ -626,6 +669,22 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
return -1;
}
+ /// These are duplicated from ScriptBaseClass
+ /// http://opensimulator.org/mantis/view.php?id=6106#c21945
+ #region Constants for the bitfield parameter of osListenRegex
+
+ ///
+ /// process name parameter as regex
+ ///
+ public const int OS_LISTEN_REGEX_NAME = 0x1;
+
+ ///
+ /// process message parameter as regex
+ ///
+ public const int OS_LISTEN_REGEX_MESSAGE = 0x2;
+
+ #endregion
+
// Theres probably a more clever and efficient way to
// do this, maybe with regex.
// PM2008: Ha, one could even be smart and define a specialized Enumerator.
@@ -651,7 +710,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
{
continue;
}
- if (li.GetName().Length > 0 && !li.GetName().Equals(name))
+ if (li.GetName().Length > 0 && (
+ ((li.GetRegexBitfield() & OS_LISTEN_REGEX_NAME) != OS_LISTEN_REGEX_NAME && !li.GetName().Equals(name)) ||
+ ((li.GetRegexBitfield() & OS_LISTEN_REGEX_NAME) == OS_LISTEN_REGEX_NAME && !Regex.IsMatch(name, li.GetName()))
+ ))
{
continue;
}
@@ -659,7 +721,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
{
continue;
}
- if (li.GetMessage().Length > 0 && !li.GetMessage().Equals(msg))
+ if (li.GetMessage().Length > 0 && (
+ ((li.GetRegexBitfield() & OS_LISTEN_REGEX_MESSAGE) != OS_LISTEN_REGEX_MESSAGE && !li.GetMessage().Equals(msg)) ||
+ ((li.GetRegexBitfield() & OS_LISTEN_REGEX_MESSAGE) == OS_LISTEN_REGEX_MESSAGE && !Regex.IsMatch(msg, li.GetMessage()))
+ ))
{
continue;
}
@@ -692,10 +757,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
{
int idx = 0;
Object[] item = new Object[6];
+ int dataItemLength = 6;
while (idx < data.Length)
{
- Array.Copy(data, idx, item, 0, 6);
+ dataItemLength = (idx + 7 == data.Length || (idx + 7 < data.Length && data[idx + 7] is bool)) ? 7 : 6;
+ item = new Object[dataItemLength];
+ Array.Copy(data, idx, item, 0, dataItemLength);
ListenerInfo info =
ListenerInfo.FromData(localID, itemID, hostID, item);
@@ -707,7 +775,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
m_listeners[(int)item[2]].Add(info);
}
- idx+=6;
+ idx+=dataItemLength;
}
}
}
@@ -723,19 +791,33 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
private UUID m_id; // ID to filter messages from
private string m_name; // Object name to filter messages from
private string m_message; // The message
+ private int m_regexBitfield; // The regex bitfield
public ListenerInfo(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, UUID id, string message)
{
- Initialise(handle, localID, ItemID, hostID, channel, name, id, message);
+ Initialise(handle, localID, ItemID, hostID, channel, name, id,
+ message, 0);
+ }
+
+ public ListenerInfo(int handle, uint localID, UUID ItemID,
+ UUID hostID, int channel, string name, UUID id,
+ string message, int regexBitfield)
+ {
+ Initialise(handle, localID, ItemID, hostID, channel, name, id,
+ message, regexBitfield);
}
public ListenerInfo(ListenerInfo li, string name, UUID id, string message)
{
- Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message);
+ Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message, 0);
+ }
+
+ public ListenerInfo(ListenerInfo li, string name, UUID id, string message, int regexBitfield)
+ {
+ Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message, regexBitfield);
}
- private void Initialise(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name,
- UUID id, string message)
+ private void Initialise(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, UUID id, string message, int regexBitfield)
{
m_active = true;
m_handle = handle;
@@ -746,11 +828,12 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
m_name = name;
m_id = id;
m_message = message;
+ m_regexBitfield = regexBitfield;
}
public Object[] GetSerializationData()
{
- Object[] data = new Object[6];
+ Object[] data = new Object[7];
data[0] = m_active;
data[1] = m_handle;
@@ -758,16 +841,19 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
data[3] = m_name;
data[4] = m_id;
data[5] = m_message;
+ data[6] = m_regexBitfield;
return data;
}
public static ListenerInfo FromData(uint localID, UUID ItemID, UUID hostID, Object[] data)
{
- ListenerInfo linfo = new ListenerInfo((int)data[1], localID,
- ItemID, hostID, (int)data[2], (string)data[3],
- (UUID)data[4], (string)data[5]);
- linfo.m_active=(bool)data[0];
+ ListenerInfo linfo = new ListenerInfo((int)data[1], localID, ItemID, hostID, (int)data[2], (string)data[3], (UUID)data[4], (string)data[5]);
+ linfo.m_active = (bool)data[0];
+ if (data.Length >= 7)
+ {
+ linfo.m_regexBitfield = (int)data[6];
+ }
return linfo;
}
@@ -826,5 +912,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
{
return m_id;
}
+
+ public int GetRegexBitfield()
+ {
+ return m_regexBitfield;
+ }
}
}
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
index 8d88065..66b3f3a 100644
--- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
@@ -45,6 +45,14 @@ namespace OpenSim.Region.Framework.Interfaces
void Deactivate();
void Activate();
UUID GetID();
+
+ ///
+ /// Bitfield indicating which strings should be processed as regex.
+ /// 1 corresponds to IWorldCommListenerInfo::GetName()
+ /// 2 corresponds to IWorldCommListenerInfo::GetMessage()
+ ///
+ ///
+ int GetRegexBitfield();
}
public interface IWorldComm
@@ -70,6 +78,23 @@ namespace OpenSim.Region.Framework.Interfaces
/// number of the scripts handle
int Listen(uint LocalID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg);
+ ///
+ /// Create a listen event callback with the specified filters.
+ /// The parameters localID,itemID are needed to uniquely identify
+ /// the script during 'peek' time. Parameter hostID is needed to
+ /// determine the position of the script.
+ ///
+ /// localID of the script engine
+ /// UUID of the script engine
+ /// UUID of the SceneObjectPart
+ /// channel to listen on
+ /// name to filter on
+ /// key to filter on (user given, could be totally faked)
+ /// msg to filter on
+ /// Bitfield indicating which strings should be processed as regex.
+ /// number of the scripts handle
+ int Listen(uint LocalID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg, int regexBitfield);
+
///
/// This method scans over the objects which registered an interest in listen callbacks.
/// For everyone it finds, it checks if it fits the given filter. If it does, then
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 0650b90..828288d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3647,5 +3647,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
DropAttachmentAt(false, pos, rot);
}
+
+ public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield)
+ {
+ CheckThreatLevel(ThreatLevel.Low, "osListenRegex");
+ m_host.AddScriptLPS(1);
+ UUID keyID;
+ UUID.TryParse(ID, out keyID);
+
+ // if we want the name to be used as a regular expression, ensure it is valid first.
+ if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_NAME) == ScriptBaseClass.OS_LISTEN_REGEX_NAME)
+ {
+ try
+ {
+ Regex.IsMatch("", name);
+ }
+ catch (Exception)
+ {
+ OSSLShoutError("Name regex is invalid.");
+ return -1;
+ }
+ }
+
+ // if we want the msg to be used as a regular expression, ensure it is valid first.
+ if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE) == ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE)
+ {
+ try
+ {
+ Regex.IsMatch("", msg);
+ }
+ catch (Exception)
+ {
+ OSSLShoutError("Message regex is invalid.");
+ return -1;
+ }
+ }
+
+ IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface();
+ return (wComm == null) ? -1 : wComm.Listen(
+ m_host.LocalId,
+ m_item.ItemID,
+ m_host.UUID,
+ channelID,
+ name,
+ keyID,
+ msg,
+ regexBitfield
+ );
+ }
+
+ public LSL_Integer osRegexIsMatch(string input, string pattern)
+ {
+ CheckThreatLevel(ThreatLevel.Low, "osRegexIsMatch");
+ m_host.AddScriptLPS(1);
+ try
+ {
+ return Regex.IsMatch(input, pattern) ? 1 : 0;
+ }
+ catch (Exception)
+ {
+ OSSLShoutError("Possible invalid regular expression detected.");
+ return 0;
+ }
+ }
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 93188c9..cdd9ea8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -418,5 +418,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
///
///
void osForceDropAttachmentAt(vector pos, rotation rot);
+
+ ///
+ /// Identical to llListen except for a bitfield which indicates which
+ /// string parameters should be parsed as regex patterns.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// OS_LISTEN_REGEX_NAME
+ /// OS_LISTEN_REGEX_MESSAGE
+ ///
+ ///
+ LSL_Integer osListenRegex(int channelID, string name, string ID,
+ string msg, int regexBitfield);
+
+ ///
+ /// Wraps to bool Regex.IsMatch(string input, string pattern)
+ ///
+ /// string to test for match
+ /// string to use as pattern
+ /// boolean
+ LSL_Integer osRegexIsMatch(string input, string pattern);
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 62bd6b8..880841b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -716,5 +716,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public static readonly LSLInteger RCERR_UNKNOWN = -1;
public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2;
public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3;
+
+ ///
+ /// process name parameter as regex
+ ///
+ public const int OS_LISTEN_REGEX_NAME = 0x1;
+
+ ///
+ /// process message parameter as regex
+ ///
+ public const int OS_LISTEN_REGEX_MESSAGE = 0x2;
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index dee1b28..afa9ae0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -992,5 +992,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
m_OSSL_Functions.osForceDropAttachmentAt(pos, rot);
}
+
+ public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield)
+ {
+ return m_OSSL_Functions.osListenRegex(channelID, name, ID, msg, regexBitfield);
+ }
+
+ public LSL_Integer osRegexIsMatch(string input, string pattern)
+ {
+ return m_OSSL_Functions.osRegexIsMatch(input, pattern);
+ }
}
}
--
cgit v1.1
From 80dcc13af2b33a5621bac49f15cbf6a97d2d8e16 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Tue, 23 Oct 2012 16:02:31 +0100
Subject: refactoring IWorldCommListenerInfo.GetRegexBitfield() method to be a
field with a private setter
---
.../Scripting/WorldComm/WorldCommModule.cs | 20 ++++++++------------
OpenSim/Region/Framework/Interfaces/IWorldComm.cs | 3 +--
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
index cf0eb2a..401ff6c 100644
--- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
@@ -711,8 +711,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
continue;
}
if (li.GetName().Length > 0 && (
- ((li.GetRegexBitfield() & OS_LISTEN_REGEX_NAME) != OS_LISTEN_REGEX_NAME && !li.GetName().Equals(name)) ||
- ((li.GetRegexBitfield() & OS_LISTEN_REGEX_NAME) == OS_LISTEN_REGEX_NAME && !Regex.IsMatch(name, li.GetName()))
+ ((li.RegexBitfield & OS_LISTEN_REGEX_NAME) != OS_LISTEN_REGEX_NAME && !li.GetName().Equals(name)) ||
+ ((li.RegexBitfield & OS_LISTEN_REGEX_NAME) == OS_LISTEN_REGEX_NAME && !Regex.IsMatch(name, li.GetName()))
))
{
continue;
@@ -722,8 +722,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
continue;
}
if (li.GetMessage().Length > 0 && (
- ((li.GetRegexBitfield() & OS_LISTEN_REGEX_MESSAGE) != OS_LISTEN_REGEX_MESSAGE && !li.GetMessage().Equals(msg)) ||
- ((li.GetRegexBitfield() & OS_LISTEN_REGEX_MESSAGE) == OS_LISTEN_REGEX_MESSAGE && !Regex.IsMatch(msg, li.GetMessage()))
+ ((li.RegexBitfield & OS_LISTEN_REGEX_MESSAGE) != OS_LISTEN_REGEX_MESSAGE && !li.GetMessage().Equals(msg)) ||
+ ((li.RegexBitfield & OS_LISTEN_REGEX_MESSAGE) == OS_LISTEN_REGEX_MESSAGE && !Regex.IsMatch(msg, li.GetMessage()))
))
{
continue;
@@ -791,7 +791,6 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
private UUID m_id; // ID to filter messages from
private string m_name; // Object name to filter messages from
private string m_message; // The message
- private int m_regexBitfield; // The regex bitfield
public ListenerInfo(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, UUID id, string message)
{
@@ -828,7 +827,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
m_name = name;
m_id = id;
m_message = message;
- m_regexBitfield = regexBitfield;
+ RegexBitfield = regexBitfield;
}
public Object[] GetSerializationData()
@@ -841,7 +840,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
data[3] = m_name;
data[4] = m_id;
data[5] = m_message;
- data[6] = m_regexBitfield;
+ data[6] = RegexBitfield;
return data;
}
@@ -852,7 +851,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
linfo.m_active = (bool)data[0];
if (data.Length >= 7)
{
- linfo.m_regexBitfield = (int)data[6];
+ linfo.RegexBitfield = (int)data[6];
}
return linfo;
@@ -913,9 +912,6 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
return m_id;
}
- public int GetRegexBitfield()
- {
- return m_regexBitfield;
- }
+ public int RegexBitfield { get; private set; }
}
}
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
index 66b3f3a..d76a0d7 100644
--- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
@@ -51,8 +51,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// 1 corresponds to IWorldCommListenerInfo::GetName()
/// 2 corresponds to IWorldCommListenerInfo::GetMessage()
///
- ///
- int GetRegexBitfield();
+ int RegexBitfield { get; }
}
public interface IWorldComm
--
cgit v1.1
From 16809bd0eada0e5bd0f4dbf823cbd27ae212e037 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Oct 2012 02:36:58 +0100
Subject: minor: Make the error thrown logged when a simulator in grid mode is
trying to set estate owner to a user that doesn't exist a little more
obvious.
---
OpenSim/Region/Application/OpenSimBase.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 4f1b439..7b591a8 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -543,7 +543,7 @@ namespace OpenSim
if (account == null)
{
m_log.ErrorFormat(
- "[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first.");
+ "[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first at the grid level.");
}
else
{
--
cgit v1.1