Merge branch 'master' into bulletsim

Conflicts:
	OpenSim/Region/Framework/Scenes/SceneManager.cs
bulletsim
Mic Bowman 2011-08-19 14:49:16 -07:00
commit 384cb79a1a
111 changed files with 2656 additions and 1160 deletions

View File

@ -14,6 +14,7 @@ people that make the day to day of OpenSim happen.
* Marck
* Mic Bowman (Intel)
* BlueWall (James Hughes)
* Snoopy Pfeffer
= Core Developers Following the White Rabbit =
Core developers who have temporarily (we hope) gone chasing the white rabbit.
@ -128,7 +129,6 @@ what it is today.
* Salahzar Stenvaag
* sempuki
* SignpostMarv
* Snoopy
* Strawberry Fride
* tglion
* tlaukkan/Tommil (Tommi S. E. Laukkanen, Bubble Cloud)

View File

@ -169,7 +169,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
float y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]);
float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]);
Vector3 vector = new Vector3(x, y, z);
presence.MoveToTarget(vector);
presence.MoveToTarget(vector, false);
}
catch (Exception e)
{

View File

@ -57,7 +57,6 @@ namespace OpenSim.Capabilities.Handlers
public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap)
{
Hashtable responsedata = new Hashtable();
responsedata["int_response_code"] = 400; //501; //410; //404;
responsedata["content_type"] = "text/plain";
@ -69,7 +68,6 @@ namespace OpenSim.Capabilities.Handlers
if (request.ContainsKey("mesh_id"))
meshStr = request["mesh_id"].ToString();
UUID meshID = UUID.Zero;
if (!String.IsNullOrEmpty(meshStr) && UUID.TryParse(meshStr, out meshID))
{
@ -82,9 +80,8 @@ namespace OpenSim.Capabilities.Handlers
return responsedata;
}
AssetBase mesh;
// Only try to fetch locally cached textures. Misses are redirected
mesh = m_assetService.GetCached(meshID.ToString());
AssetBase mesh = m_assetService.Get(meshID.ToString());
if (mesh != null)
{
if (mesh.Type == (SByte)AssetType.Mesh)
@ -105,36 +102,12 @@ namespace OpenSim.Capabilities.Handlers
}
else
{
mesh = m_assetService.Get(meshID.ToString());
if (mesh != null)
{
if (mesh.Type == (SByte)AssetType.Mesh)
{
responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data);
responsedata["content_type"] = "application/vnd.ll.mesh";
responsedata["int_response_code"] = 200;
}
// Optionally add additional mesh types here
else
{
responsedata["int_response_code"] = 404; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh.";
return responsedata;
}
}
else
{
responsedata["int_response_code"] = 404; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!";
return responsedata;
}
responsedata["int_response_code"] = 404; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!";
return responsedata;
}
}
return responsedata;

View File

@ -88,7 +88,7 @@ namespace OpenSim.Data.MSSQL
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
catch (Exception)
{
throw new Exception(sql);

View File

@ -191,7 +191,7 @@ namespace OpenSim.Data.MSSQL
{
cmd.ExecuteNonQuery();
}
catch (Exception e)
catch (Exception)
{
return false;
}

View File

@ -251,12 +251,14 @@ namespace OpenSim.Data.MySQL
}
/// <summary>
/// check if the asset UUID exist in database
/// Check if the asset exists in the database
/// </summary>
/// <param name="uuid">The asset UUID</param>
/// <returns>true if exist.</returns>
/// <returns>true if it exists, false otherwise.</returns>
override public bool ExistsAsset(UUID uuid)
{
// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid);
bool assetExists = false;
lock (m_dbLock)
@ -273,7 +275,10 @@ namespace OpenSim.Data.MySQL
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
{
if (dbReader.Read())
{
// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
assetExists = true;
}
}
}
catch (Exception e)

View File

@ -97,7 +97,7 @@ namespace OpenSim.Data.Null
foreach (RegionData r in m_regionData.Values)
{
m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower());
// m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower());
if (queryMatch(r.RegionName.ToLower()))
ret.Add(r);
}

View File

@ -41,8 +41,6 @@ COMMIT;
:VERSION 2
ATTACH 'inventoryStore.db' AS old;
BEGIN TRANSACTION;
INSERT INTO inventoryfolders (folderName, type, version, folderID, agentID, parentFolderID) SELECT `name` AS folderName, `type` AS type, `version` AS version, `UUID` AS folderID, `agentID` AS agentID, `parentID` AS parentFolderID from old.inventoryfolders;

View File

@ -106,7 +106,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T001_LoadEmpty()
{
TestHelper.InMethod();
TestHelpers.InMethod();
Assert.That(m_db.ExistsAsset(uuid1), Is.False);
Assert.That(m_db.ExistsAsset(uuid2), Is.False);
@ -116,7 +116,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T010_StoreReadVerifyAssets()
{
TestHelper.InMethod();
TestHelpers.InMethod();
AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1.ToString());
AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, critter2.ToString());
@ -183,7 +183,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T020_CheckForWeirdCreatorID()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// It is expected that eventually the CreatorID might be an arbitrary string (an URI)
// rather than a valid UUID (?). This test is to make sure that the database layer does not

View File

@ -107,7 +107,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T010_EstateSettingsSimpleStorage_MinimumParameterSet()
{
TestHelper.InMethod();
TestHelpers.InMethod();
EstateSettingsSimpleStorage(
REGION_ID,
@ -140,7 +140,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T011_EstateSettingsSimpleStorage_MaximumParameterSet()
{
TestHelper.InMethod();
TestHelpers.InMethod();
EstateSettingsSimpleStorage(
REGION_ID,
@ -173,7 +173,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T012_EstateSettingsSimpleStorage_AccurateParameterSet()
{
TestHelper.InMethod();
TestHelpers.InMethod();
EstateSettingsSimpleStorage(
REGION_ID,
@ -206,7 +206,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T012_EstateSettingsRandomStorage()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
@ -227,7 +227,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T020_EstateSettingsManagerList()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
@ -248,7 +248,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T021_EstateSettingsUserList()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
@ -269,7 +269,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T022_EstateSettingsGroupList()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
@ -290,7 +290,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T022_EstateSettingsBanList()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);

View File

@ -114,7 +114,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T001_LoadEmpty()
{
TestHelper.InMethod();
TestHelpers.InMethod();
Assert.That(db.getInventoryFolder(zero), Is.Null);
Assert.That(db.getInventoryFolder(folder1), Is.Null);
@ -134,7 +134,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T010_FolderNonParent()
{
TestHelper.InMethod();
TestHelpers.InMethod();
InventoryFolderBase f1 = NewFolder(folder2, folder1, owner1, name2);
// the folder will go in
@ -146,7 +146,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T011_FolderCreate()
{
TestHelper.InMethod();
TestHelpers.InMethod();
InventoryFolderBase f1 = NewFolder(folder1, zero, owner1, name1);
// TODO: this is probably wrong behavior, but is what we have
@ -171,7 +171,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T012_FolderList()
{
TestHelper.InMethod();
TestHelpers.InMethod();
InventoryFolderBase f2 = NewFolder(folder3, folder1, owner1, name3);
db.addInventoryFolder(f2);
@ -187,7 +187,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T013_FolderHierarchy()
{
TestHelper.InMethod();
TestHelpers.InMethod();
int n = db.getFolderHierarchy(zero).Count; // (for dbg - easier to see what's returned)
Assert.That(n, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
@ -202,7 +202,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T014_MoveFolder()
{
TestHelper.InMethod();
TestHelpers.InMethod();
InventoryFolderBase f2 = db.getInventoryFolder(folder2);
f2.ParentID = folder3;
@ -218,7 +218,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T015_FolderHierarchy()
{
TestHelper.InMethod();
TestHelpers.InMethod();
Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))");
@ -231,7 +231,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T100_NoItems()
{
TestHelper.InMethod();
TestHelpers.InMethod();
Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0))");
@ -245,7 +245,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T101_CreatItems()
{
TestHelper.InMethod();
TestHelpers.InMethod();
db.addInventoryItem(NewItem(item1, folder3, owner1, iname1, asset1));
db.addInventoryItem(NewItem(item2, folder3, owner1, iname2, asset2));
@ -256,7 +256,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T102_CompareItems()
{
TestHelper.InMethod();
TestHelpers.InMethod();
InventoryItemBase i1 = db.getInventoryItem(item1);
InventoryItemBase i2 = db.getInventoryItem(item2);
@ -275,7 +275,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T103_UpdateItem()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// TODO: probably shouldn't have the ability to have an
// owner of an item in a folder not owned by the user
@ -295,7 +295,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T104_RandomUpdateItem()
{
TestHelper.InMethod();
TestHelpers.InMethod();
PropertyScrambler<InventoryFolderBase> folderScrambler =
new PropertyScrambler<InventoryFolderBase>()
@ -354,7 +354,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T999_StillNull()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// After all tests are run, these should still return no results
Assert.That(db.getInventoryFolder(zero), Is.Null);

View File

@ -151,7 +151,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T001_LoadEmpty()
{
TestHelper.InMethod();
TestHelpers.InMethod();
List<SceneObjectGroup> objs = db.LoadObjects(region1);
List<SceneObjectGroup> objs3 = db.LoadObjects(region3);
@ -169,7 +169,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T010_StoreSimpleObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
SceneObjectGroup sog = NewSOG("object1", prim1, region1);
SceneObjectGroup sog2 = NewSOG("object2", prim2, region1);
@ -204,7 +204,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T011_ObjectNames()
{
TestHelper.InMethod();
TestHelpers.InMethod();
List<SceneObjectGroup> objs = db.LoadObjects(region1);
foreach (SceneObjectGroup sog in objs)
@ -218,7 +218,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T012_SceneParts()
{
TestHelper.InMethod();
TestHelpers.InMethod();
UUID tmp0 = UUID.Random();
UUID tmp1 = UUID.Random();
@ -253,7 +253,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T013_DatabasePersistency()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data
// The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored
@ -430,7 +430,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T014_UpdateObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
string text1 = "object1 text";
SceneObjectGroup sog = FindSOG("object1", region1);
@ -540,7 +540,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T015_LargeSceneObjects()
{
TestHelper.InMethod();
TestHelpers.InMethod();
UUID id = UUID.Random();
Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>();
@ -587,7 +587,7 @@ namespace OpenSim.Data.Tests
//[Test]
public void T016_RandomSogWithSceneParts()
{
TestHelper.InMethod();
TestHelpers.InMethod();
PropertyScrambler<SceneObjectPart> scrambler =
new PropertyScrambler<SceneObjectPart>()
@ -663,7 +663,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T020_PrimInventoryEmpty()
{
TestHelper.InMethod();
TestHelpers.InMethod();
SceneObjectGroup sog = GetMySOG("object1");
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
@ -687,7 +687,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T021_PrimInventoryBasic()
{
TestHelper.InMethod();
TestHelpers.InMethod();
SceneObjectGroup sog = GetMySOG("object1");
InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero);
@ -727,7 +727,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T025_PrimInventoryPersistency()
{
TestHelper.InMethod();
TestHelpers.InMethod();
InventoryItemBase i = new InventoryItemBase();
UUID id = UUID.Random();
@ -800,7 +800,7 @@ namespace OpenSim.Data.Tests
[ExpectedException(typeof(ArgumentException))]
public void T026_PrimInventoryMany()
{
TestHelper.InMethod();
TestHelpers.InMethod();
UUID i1,i2,i3,i4;
i1 = UUID.Random();
@ -832,7 +832,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T052_RemoveObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
db.RemoveObject(prim1, region1);
SceneObjectGroup sog = FindSOG("object1", region1);
@ -842,7 +842,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T100_DefaultRegionInfo()
{
TestHelper.InMethod();
TestHelpers.InMethod();
RegionSettings r1 = db.LoadRegionSettings(region1);
Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))");
@ -854,7 +854,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T101_UpdateRegionInfo()
{
TestHelper.InMethod();
TestHelpers.InMethod();
int agentlimit = random.Next();
double objectbonus = random.Next();
@ -960,7 +960,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T300_NoTerrain()
{
TestHelper.InMethod();
TestHelpers.InMethod();
Assert.That(db.LoadTerrain(zero), Is.Null);
Assert.That(db.LoadTerrain(region1), Is.Null);
@ -971,7 +971,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T301_CreateTerrain()
{
TestHelper.InMethod();
TestHelpers.InMethod();
double[,] t1 = GenTerrain(height1);
db.StoreTerrain(t1, region1);
@ -985,7 +985,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T302_FetchTerrain()
{
TestHelper.InMethod();
TestHelpers.InMethod();
double[,] baseterrain1 = GenTerrain(height1);
double[,] baseterrain2 = GenTerrain(height2);
@ -997,7 +997,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T303_UpdateTerrain()
{
TestHelper.InMethod();
TestHelpers.InMethod();
double[,] baseterrain1 = GenTerrain(height1);
double[,] baseterrain2 = GenTerrain(height2);
@ -1011,7 +1011,7 @@ namespace OpenSim.Data.Tests
[Test]
public void T400_EmptyLand()
{
TestHelper.InMethod();
TestHelpers.InMethod();
Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))");
Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))");

View File

@ -412,12 +412,20 @@ namespace OpenSim.Framework
}
/// <summary>
/// Add an attachment, if the attachpoint has the
/// Add an attachment
/// </summary>
/// <remarks>
/// If the attachpoint has the
/// 0x80 bit set then we assume this is an append
/// operation otherwise we replace whatever is
/// currently attached at the attachpoint
/// </remarks>
/// <param name="attachpoint"></param>
/// <param name="item">If UUID.Zero, then an any attachment at the attachpoint is removed.</param>
/// <param name="asset"></param>
/// <returns>
/// return true if something actually changed
/// </summary>
/// </returns>
public bool SetAttachment(int attachpoint, UUID item, UUID asset)
{
if (attachpoint == 0)
@ -539,7 +547,7 @@ namespace OpenSim.Framework
/// </summary>
public void Unpack(OSDMap data)
{
if ((data != null) && (data["serial"] != null))
if ((data != null) && (data["serial"] != null))
m_serial = data["serial"].AsInteger();
if ((data != null) && (data["height"] != null))
m_avatarHeight = (float)data["height"].AsReal();

View File

@ -786,7 +786,7 @@ namespace OpenSim.Framework
event DeRezObject OnDeRezObject;
event Action<IClientAPI> OnRegionHandShakeReply;
event GenericCall1 OnRequestWearables;
event GenericCall1 OnCompleteMovementToRegion;
event Action<IClientAPI, bool> OnCompleteMovementToRegion;
event UpdateAgent OnPreAgentUpdate;
event UpdateAgent OnAgentUpdate;
event AgentRequestSit OnAgentRequestSit;
@ -935,7 +935,7 @@ namespace OpenSim.Framework
event ScriptReset OnScriptReset;
event GetScriptRunning OnGetScriptRunning;
event SetScriptRunning OnSetScriptRunning;
event Action<Vector3> OnAutoPilotGo;
event Action<Vector3, bool> OnAutoPilotGo;
event TerrainUnacked OnUnackedTerrain;
event ActivateGesture OnActivateGesture;

View File

@ -70,8 +70,20 @@ namespace OpenSim.Framework
event restart OnRestart;
void AddNewClient(IClientAPI client);
void RemoveClient(UUID agentID);
/// <summary>
/// Register the new client with the scene. The client starts off as a child agent - the later agent crossing
/// will promote it to a root agent.
/// </summary>
/// <param name="client"></param>
/// <param name="type">The type of agent to add.</param>
void AddNewClient(IClientAPI client, PresenceType type);
/// <summary>
/// Remove the given client from the scene.
/// </summary>
/// <param name="agentID"></param>
/// <param name="closeChildAgents">Close the neighbour child agents associated with this client.</param>
void RemoveClient(UUID agentID, bool closeChildAgents);
void Restart();
//RegionInfo OtherRegionUp(RegionInfo thisRegion);

View File

@ -0,0 +1,39 @@
/*
* 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.Framework
{
/// <summary>
/// Indicate the type of ScenePresence.
/// </summary>
public enum PresenceType
{
User,
Npc
}
}

View File

@ -61,7 +61,7 @@ namespace OpenSim.Framework.Tests
"Magnitude of vector was incorrect.");
TestDelegate d = delegate() { Util.GetNormalizedVector(v1); };
bool causesArgumentException = TestHelper.AssertThisDelegateCausesArgumentException(d);
bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d);
Assert.That(causesArgumentException, Is.True,
"Getting magnitude of null vector did not cause argument exception.");
@ -94,12 +94,12 @@ namespace OpenSim.Framework.Tests
"Magnitude of vector was incorrect.");
TestDelegate d = delegate() { Util.GetNormalizedVector(v1); };
bool causesArgumentException = TestHelper.AssertThisDelegateCausesArgumentException(d);
bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d);
Assert.That(causesArgumentException, Is.True,
"Getting magnitude of null vector did not cause argument exception.");
d = delegate() { Util.GetNormalizedVector(v2); };
causesArgumentException = TestHelper.AssertThisDelegateCausesArgumentException(d);
causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d);
Assert.That(causesArgumentException, Is.True,
"Getting magnitude of null vector did not cause argument exception.");
}
@ -122,7 +122,7 @@ namespace OpenSim.Framework.Tests
"Magnitude of vector was incorrect.");
TestDelegate d = delegate() { Util.GetNormalizedVector(v1); };
bool causesArgumentException = TestHelper.AssertThisDelegateCausesArgumentException(d);
bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d);
Assert.That(causesArgumentException, Is.True,
"Getting magnitude of null vector did not cause argument exception.");

View File

@ -56,8 +56,13 @@ namespace OpenSim.Framework
/// <summary>
/// The method used by Util.FireAndForget for asynchronously firing events
/// </summary>
/// <remarks>
/// None is used to execute the method in the same thread that made the call. It should only be used by regression
/// test code that relies on predictable event ordering.
/// </remarks>
public enum FireAndForgetMethod
{
None,
UnsafeQueueUserWorkItem,
QueueUserWorkItem,
BeginInvoke,
@ -89,7 +94,8 @@ namespace OpenSim.Framework
public static readonly Regex UUIDPattern
= new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
public static FireAndForgetMethod FireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod;
/// <summary>
/// Gets the name of the directory where the current running executable
@ -1506,6 +1512,9 @@ namespace OpenSim.Framework
switch (FireAndForgetMethod)
{
case FireAndForgetMethod.None:
realCallback.Invoke(obj);
break;
case FireAndForgetMethod.UnsafeQueueUserWorkItem:
ThreadPool.UnsafeQueueUserWorkItem(realCallback, obj);
break;

View File

@ -549,6 +549,7 @@ namespace OpenSim
{
string regionName = string.Empty;
string regionFile = string.Empty;
if (cmd.Length == 3)
{
regionFile = cmd[2];
@ -558,14 +559,17 @@ namespace OpenSim
regionName = cmd[2];
regionFile = cmd[3];
}
string extension = Path.GetExtension(regionFile).ToLower();
bool isXml = extension.Equals(".xml");
bool isIni = extension.Equals(".ini");
if (!isXml && !isIni)
{
MainConsole.Instance.Output("Usage: create region [\"region name\"] <region_file.ini>");
return;
}
if (!Path.IsPathRooted(regionFile))
{
string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
@ -582,8 +586,18 @@ namespace OpenSim
regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source, regionName);
}
IScene scene;
Scene existingScene;
if (SceneManager.TryGetScene(regInfo.RegionID, out existingScene))
{
MainConsole.Instance.OutputFormat(
"ERROR: Cannot create region {0} with ID {1}, this ID is already assigned to region {2}",
regInfo.RegionName, regInfo.RegionID, existingScene.RegionInfo.RegionName);
return;
}
PopulateRegionEstateInfo(regInfo);
IScene scene;
CreateRegion(regInfo, true, out scene);
regInfo.EstateSettings.Save();
}

View File

@ -232,7 +232,7 @@ namespace OpenSim.Region.ClientStack.Linden
public string SeedCapRequest(string request, string path, string param,
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName);
// m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName);
if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint))
{

View File

@ -50,8 +50,8 @@ namespace OpenSim.Region.ClientStack.Linden
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class GetMeshModule : INonSharedRegionModule
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private IAssetService m_AssetService;
@ -113,12 +113,12 @@ namespace OpenSim.Region.ClientStack.Linden
public void RegisterCaps(UUID agentID, Caps caps)
{
UUID capID = UUID.Random();
// UUID capID = UUID.Random();
//caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture));
if (m_URL == "localhost")
{
m_log.InfoFormat("[GETMESH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName);
// m_log.DebugFormat("[GETMESH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName);
GetMeshHandler gmeshHandler = new GetMeshHandler(m_AssetService);
IRequestHandler reqHandler = new RestHTTPHandler("GET", "/CAPS/" + UUID.Random(),
delegate(Hashtable m_dhttpMethod)
@ -130,7 +130,7 @@ namespace OpenSim.Region.ClientStack.Linden
}
else
{
m_log.InfoFormat("[GETMESH]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName);
// m_log.DebugFormat("[GETMESH]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName);
caps.RegisterHandler("GetMesh", m_URL);
}
}

View File

@ -54,8 +54,9 @@ namespace OpenSim.Region.ClientStack.Linden
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class GetTextureModule : INonSharedRegionModule
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private IAssetService m_assetService;
@ -128,12 +129,12 @@ namespace OpenSim.Region.ClientStack.Linden
//caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture));
if (m_URL == "localhost")
{
m_log.InfoFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName);
// m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName);
caps.RegisterHandler("GetTexture", new GetTextureHandler("/CAPS/" + capID + "/", m_assetService));
}
else
{
m_log.InfoFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName);
// m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName);
caps.RegisterHandler("GetTexture", m_URL);
}
}

View File

@ -90,7 +90,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event ObjectAttach OnObjectAttach;
public event ObjectDeselect OnObjectDetach;
public event ObjectDrop OnObjectDrop;
public event GenericCall1 OnCompleteMovementToRegion;
public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit;
@ -231,7 +231,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event ScriptReset OnScriptReset;
public event GetScriptRunning OnGetScriptRunning;
public event SetScriptRunning OnSetScriptRunning;
public event Action<Vector3> OnAutoPilotGo;
public event Action<Vector3, bool> OnAutoPilotGo;
public event TerrainUnacked OnUnackedTerrain;
public event ActivateGesture OnActivateGesture;
public event DeactivateGesture OnDeactivateGesture;
@ -512,7 +512,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_udpServer.Flush(m_udpClient);
// Remove ourselves from the scene
m_scene.RemoveClient(AgentId);
m_scene.RemoveClient(AgentId, true);
// We can't reach into other scenes and close the connection
// We need to do this over grid communications
@ -692,7 +692,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public virtual void Start()
{
m_scene.AddNewClient(this);
m_scene.AddNewClient(this, PresenceType.User);
RefreshGroupMembership();
}
@ -6195,10 +6195,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
{
GenericCall1 handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
if (handlerCompleteMovementToRegion != null)
{
handlerCompleteMovementToRegion(sender);
handlerCompleteMovementToRegion(sender, true);
}
handlerCompleteMovementToRegion = null;
@ -11628,9 +11628,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
locy = Convert.ToSingle(args[1]) - (float)regionY;
locz = Convert.ToSingle(args[2]);
Action<Vector3> handlerAutoPilotGo = OnAutoPilotGo;
Action<Vector3, bool> handlerAutoPilotGo = OnAutoPilotGo;
if (handlerAutoPilotGo != null)
handlerAutoPilotGo(new Vector3(locx, locy, locz));
handlerAutoPilotGo(new Vector3(locx, locy, locz), false);
}
/// <summary>

View File

@ -357,8 +357,6 @@ namespace Flotsam.RegionModules.AssetCache
asset = (AssetBase)bformatter.Deserialize(stream);
UpdateMemoryCache(id, asset);
m_DiskHits++;
}
catch (System.Runtime.Serialization.SerializationException e)
@ -419,9 +417,15 @@ namespace Flotsam.RegionModules.AssetCache
if (m_MemoryCacheEnabled)
asset = GetFromMemoryCache(id);
if (asset == null && m_FileCacheEnabled)
{
asset = GetFromFileCache(id);
if (m_MemoryCacheEnabled && asset != null)
UpdateMemoryCache(id, asset);
}
if (((m_LogLevel >= 1)) && (m_HitRateDisplay != 0) && (m_Requests % m_HitRateDisplay == 0))
{
m_HitRateFile = (double)m_DiskHits / m_Requests * 100.0;
@ -589,33 +593,59 @@ namespace Flotsam.RegionModules.AssetCache
try
{
if (!Directory.Exists(directory))
try
{
Directory.CreateDirectory(directory);
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
stream = File.Open(tempname, FileMode.Create);
BinaryFormatter bformatter = new BinaryFormatter();
bformatter.Serialize(stream, asset);
}
catch (IOException e)
{
m_log.ErrorFormat(
"[FLOTSAM ASSET CACHE]: Failed to write asset {0} to temporary location {1} (final {2}) on cache in {3}. Exception {4} {5}.",
asset.ID, tempname, filename, directory, e.Message, e.StackTrace);
return;
}
finally
{
if (stream != null)
stream.Close();
}
stream = File.Open(tempname, FileMode.Create);
BinaryFormatter bformatter = new BinaryFormatter();
bformatter.Serialize(stream, asset);
stream.Close();
try
{
// Now that it's written, rename it so that it can be found.
//
// File.Copy(tempname, filename, true);
// File.Delete(tempname);
//
// For a brief period, this was done as a separate copy and then temporary file delete operation to
// avoid an IOException caused by move if some competing thread had already written the file.
// However, this causes exceptions on Windows when other threads attempt to read a file
// which is still being copied. So instead, go back to moving the file and swallow any IOException.
//
// This situation occurs fairly rarely anyway. We assume in this that moves are atomic on the
// filesystem.
File.Move(tempname, filename);
// Now that it's written, rename it so that it can be found.
File.Move(tempname, filename);
if (m_LogLevel >= 2)
m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Cache Stored :: {0}", asset.ID);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[FLOTSAM ASSET CACHE]: Failed to write asset {0} to cache. Directory {1}, tempname {2}, filename {3}. Exception {4} {5}.",
asset.ID, directory, tempname, filename, e.Message, e.StackTrace);
if (m_LogLevel >= 2)
m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Cache Stored :: {0}", asset.ID);
}
catch (IOException)
{
// If we see an IOException here it's likely that some other competing thread has written the
// cache file first, so ignore. Other IOException errors (e.g. filesystem full) should be
// signally by the earlier temporary file writing code.
}
}
finally
{
if (stream != null)
stream.Close();
// Even if the write fails with an exception, we need to make sure
// that we release the lock on that file, otherwise it'll never get
// cached
@ -629,13 +659,9 @@ namespace Flotsam.RegionModules.AssetCache
waitEvent.Set();
}
#else
if (m_CurrentlyWriting.Contains(filename))
{
m_CurrentlyWriting.Remove(filename);
}
m_CurrentlyWriting.Remove(filename);
#endif
}
}
}

View File

@ -65,18 +65,18 @@ namespace OpenSim.Region.CoreModules.Asset.Tests
config.Configs["AssetCache"].Set("MemoryCacheEnabled", "true");
m_cache = new FlotsamAssetCache();
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, config, m_cache);
m_scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(m_scene, config, m_cache);
}
[Test]
public void TestCacheAsset()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
AssetBase asset = AssetHelpers.CreateAsset();
asset.ID = TestHelper.ParseTail(0x1).ToString();
asset.ID = TestHelpers.ParseTail(0x1).ToString();
// Check we don't get anything before the asset is put in the cache
AssetBase retrievedAsset = m_cache.Get(asset.ID.ToString());
@ -93,11 +93,11 @@ namespace OpenSim.Region.CoreModules.Asset.Tests
[Test]
public void TestExpireAsset()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
AssetBase asset = AssetHelpers.CreateAsset();
asset.ID = TestHelper.ParseTail(0x2).ToString();
asset.ID = TestHelpers.ParseTail(0x2).ToString();
m_cache.Store(asset);
@ -110,11 +110,11 @@ namespace OpenSim.Region.CoreModules.Asset.Tests
[Test]
public void TestClearCache()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
AssetBase asset = AssetHelpers.CreateAsset();
asset.ID = TestHelper.ParseTail(0x2).ToString();
asset.ID = TestHelpers.ParseTail(0x2).ToString();
m_cache.Store(asset);

View File

@ -101,7 +101,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// <param name="silent"></param>
public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent)
{
m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject");
// m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject");
try
{
@ -226,9 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public UUID RezSingleAttachmentFromInventory(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus)
{
m_log.DebugFormat(
"[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
(AttachmentPoint)AttachmentPt, itemID, remoteClient.Name);
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
// (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name);
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
// be removed when that functionality is implemented in opensim
@ -466,7 +466,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
group.DetachToInventoryPrep();
m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
// m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
// If an item contains scripts, it's always changed.
// This ensures script state is saved on detach
@ -501,10 +501,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// <summary>
/// Update the attachment asset for the new sog details if they have changed.
/// </summary>
///
/// <remarks>
/// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects,
/// these details are not stored on the region.
///
/// </remarks>
/// <param name="remoteClient"></param>
/// <param name="grp"></param>
/// <param name="itemID"></param>
@ -566,8 +566,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// <param name="silent"></param>
protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
{
m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name,
attachmentpoint, attachOffset, so.RootPart.AttachedPos);
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}",
// so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos);
so.DetachFromBackup();

View File

@ -37,104 +37,132 @@ using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.CoreModules.Avatar.Attachments;
using OpenSim.Region.CoreModules.Framework.InventoryAccess;
using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.Framework.Scenes.Tests
namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
{
/// <summary>
/// Attachment tests
/// </summary>
[TestFixture]
public class AttachmentTests
public class AttachmentsModuleTests
{
public Scene scene, scene2;
public Scene scene;
public UUID agent1;
public static Random random;
public ulong region1, region2;
public AgentCircuitData acd1;
public SceneObjectGroup sog1, sog2, sog3;
public SceneObjectGroup sog1, sog2;
[TestFixtureSetUp]
[SetUp]
public void Init()
{
TestHelper.InMethod();
// Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
Util.FireAndForgetMethod = FireAndForgetMethod.None;
scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
interregionComms.Initialise(new IniConfigSource());
interregionComms.PostInitialise();
SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule());
agent1 = UUID.Random();
random = new Random();
sog1 = NewSOG(UUID.Random(), scene, agent1);
sog2 = NewSOG(UUID.Random(), scene, agent1);
sog3 = NewSOG(UUID.Random(), scene, agent1);
}
//ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
region1 = scene.RegionInfo.RegionHandle;
region2 = scene2.RegionInfo.RegionHandle;
SceneSetupHelpers.AddClient(scene, agent1);
[TearDown]
public void TearDown()
{
// We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
// threads. Possibly, later tests should be rewritten not to worry about such things.
Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
}
[Test]
public void T030_TestAddAttachments()
public void TestAddAttachments()
{
TestHelper.InMethod();
ScenePresence presence = scene.GetScenePresence(agent1);
TestHelpers.InMethod();
ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1);
presence.AddAttachment(sog1);
presence.AddAttachment(sog2);
presence.AddAttachment(sog3);
Assert.That(presence.HasAttachments(), Is.True);
Assert.That(presence.ValidateAttachments(), Is.True);
}
[Test]
public void T031_RemoveAttachments()
public void TestRemoveAttachments()
{
TestHelper.InMethod();
TestHelpers.InMethod();
ScenePresence presence = scene.GetScenePresence(agent1);
ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1);
presence.AddAttachment(sog1);
presence.AddAttachment(sog2);
presence.RemoveAttachment(sog1);
presence.RemoveAttachment(sog2);
presence.RemoveAttachment(sog3);
Assert.That(presence.HasAttachments(), Is.False);
}
[Test]
public void TestRezAttachmentsOnAvatarEntrance()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UUID userId = TestHelpers.ParseTail(0x1);
UUID attItemId = TestHelpers.ParseTail(0x2);
UUID attAssetId = TestHelpers.ParseTail(0x3);
string attName = "att";
UserAccountHelpers.CreateUserWithInventory(scene, userId);
InventoryItemBase attItem
= UserInventoryHelpers.CreateInventoryItem(
scene, attName, attItemId, attAssetId, userId, InventoryType.Object);
AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
acd.Appearance = new AvatarAppearance();
acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
Assert.That(presence.HasAttachments(), Is.True);
List<SceneObjectGroup> attachments = presence.Attachments;
Assert.That(attachments.Count, Is.EqualTo(1));
Assert.That(attachments[0].Name, Is.EqualTo(attName));
}
// I'm commenting this test because scene setup NEEDS InventoryService to
// be non-null
//[Test]
public void T032_CrossAttachments()
{
TestHelper.InMethod();
ScenePresence presence = scene.GetScenePresence(agent1);
ScenePresence presence2 = scene2.GetScenePresence(agent1);
presence2.AddAttachment(sog1);
presence2.AddAttachment(sog2);
ISharedRegionModule serialiser = new SerialiserModule();
SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
//Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
}
// public void T032_CrossAttachments()
// {
// TestHelpers.InMethod();
//
// ScenePresence presence = scene.GetScenePresence(agent1);
// ScenePresence presence2 = scene2.GetScenePresence(agent1);
// presence2.AddAttachment(sog1);
// presence2.AddAttachment(sog2);
//
// ISharedRegionModule serialiser = new SerialiserModule();
// SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
// SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
//
// Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
//
// //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
// Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
// Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
// }
private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent)
{

View File

@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
public void NewClient(IClientAPI client)
{
client.OnRequestWearables += SendWearables;
client.OnSetAppearance += SetAppearance;
client.OnSetAppearance += SetAppearanceFromClient;
client.OnAvatarNowWearing += AvatarIsWearing;
}
@ -189,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
/// <param name="client"></param>
/// <param name="texture"></param>
/// <param name="visualParam"></param>
public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
public void SetAppearanceFromClient(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
{
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null)
@ -257,6 +257,85 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
return true;
}
public bool SaveBakedTextures(UUID agentId)
{
ScenePresence sp = m_scene.GetScenePresence(agentId);
if (sp == null || sp.IsChildAgent)
return false;
AvatarAppearance appearance = sp.Appearance;
Primitive.TextureEntryFace[] faceTextures = appearance.Texture.FaceTextures;
m_log.DebugFormat(
"[AV FACTORY]: Permanently saving baked textures for {0} in {1}",
sp.Name, m_scene.RegionInfo.RegionName);
foreach (int i in Enum.GetValues(typeof(BakeType)))
{
BakeType bakeType = (BakeType)i;
if (bakeType == BakeType.Unknown)
continue;
// m_log.DebugFormat(
// "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}",
// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType);
Primitive.TextureEntryFace bakedTextureFace = faceTextures[ftIndex];
if (bakedTextureFace == null)
{
m_log.WarnFormat(
"[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently",
bakeType, sp.Name, m_scene.RegionInfo.RegionName);
continue;
}
AssetBase asset = m_scene.AssetService.Get(bakedTextureFace.TextureID.ToString());
if (asset != null)
{
asset.Temporary = false;
m_scene.AssetService.Store(asset);
}
else
{
m_log.WarnFormat(
"[AV FACTORY]: Baked texture id {0} not found for bake {1} for avatar {2} in {3} when trying to save permanently",
bakedTextureFace.TextureID, bakeType, sp.Name, m_scene.RegionInfo.RegionName);
}
}
// for (int i = 0; i < faceTextures.Length; i++)
// {
//// m_log.DebugFormat(
//// "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}",
//// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
//
// if (faceTextures[i] == null)
// continue;
//
// AssetBase asset = m_scene.AssetService.Get(faceTextures[i].TextureID.ToString());
//
// if (asset != null)
// {
// asset.Temporary = false;
// m_scene.AssetService.Store(asset);
// }
// else
// {
// m_log.WarnFormat(
// "[AV FACTORY]: Baked texture {0} for {1} in {2} not found when trying to save permanently",
// faceTextures[i].TextureID, sp.Name, m_scene.RegionInfo.RegionName);
// }
// }
return true;
}
#region UpdateAppearanceTimer
/// <summary>
@ -289,25 +368,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
}
}
private void HandleAppearanceSend(UUID agentid)
{
ScenePresence sp = m_scene.GetScenePresence(agentid);
if (sp == null)
{
m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid);
return;
}
// m_log.WarnFormat("[AVFACTORY]: Handle appearance send for {0}", agentid);
// Send the appearance to everyone in the scene
sp.SendAppearanceToAllOtherAgents();
// Send animations back to the avatar as well
sp.Animator.SendAnimPack();
}
private void HandleAppearanceSave(UUID agentid)
private void SaveAppearance(UUID agentid)
{
// We must set appearance parameters in the en_US culture in order to avoid issues where values are saved
// in a culture where decimal points are commas and then reloaded in a culture which just treats them as
@ -337,7 +398,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{
if (kvp.Value < now)
{
Util.FireAndForget(delegate(object o) { HandleAppearanceSend(kvp.Key); });
Util.FireAndForget(delegate(object o) { SendAppearance(kvp.Key); });
m_sendqueue.Remove(kvp.Key);
}
}
@ -350,7 +411,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{
if (kvp.Value < now)
{
Util.FireAndForget(delegate(object o) { HandleAppearanceSave(kvp.Key); });
Util.FireAndForget(delegate(object o) { SaveAppearance(kvp.Key); });
m_savequeue.Remove(kvp.Key);
}
}
@ -427,6 +488,24 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
}
}
public bool SendAppearance(UUID agentId)
{
ScenePresence sp = m_scene.GetScenePresence(agentId);
if (sp == null)
{
m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId);
return false;
}
// Send the appearance to everyone in the scene
sp.SendAppearanceToAllOtherAgents();
// Send animations back to the avatar as well
sp.Animator.SendAnimPack();
return true;
}
private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
{
IInventoryService invService = m_scene.InventoryService;

View File

@ -44,21 +44,21 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
[Test]
public void TestSetAppearance()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UUID userId = TestHelper.ParseTail(0x1);
UUID userId = TestHelpers.ParseTail(0x1);
AvatarFactoryModule afm = new AvatarFactoryModule();
TestScene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, afm);
TestClient tc = SceneSetupHelpers.AddClient(scene, userId);
TestScene scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, afm);
IClientAPI tc = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT];
for (byte i = 0; i < visualParams.Length; i++)
visualParams[i] = i;
afm.SetAppearance(tc, new Primitive.TextureEntry(TestHelper.ParseTail(0x10)), visualParams);
afm.SetAppearanceFromClient(tc, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams);
ScenePresence sp = scene.GetScenePresence(userId);

View File

@ -100,8 +100,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
// log4net.Config.XmlConfigurator.Configure();
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
Scene scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, archiverModule);
UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
@ -109,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
// Create scene object asset
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50);
SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50);
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
@ -127,10 +127,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
scene.AddInventoryItem(item1);
// Create coalesced objects asset
SceneObjectGroup cobj1 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120);
SceneObjectGroup cobj1 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120);
cobj1.AbsolutePosition = new Vector3(15, 30, 45);
SceneObjectGroup cobj2 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140);
SceneObjectGroup cobj2 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140);
cobj2.AbsolutePosition = new Vector3(25, 50, 75);
CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2);

View File

@ -61,14 +61,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
SerialiserModule serialiserModule = new SerialiserModule();
m_archiverModule = new InventoryArchiverModule();
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule);
m_scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule);
}
[Test]
public void TestLoadCoalesecedItem()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password");
@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestOrder()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveReadStream = new MemoryStream(m_iarStreamBytes);
@ -129,7 +129,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestSaveItemToIar()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
// Create user
@ -141,7 +141,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
// Create asset
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50);
SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50);
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
@ -224,7 +224,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestSaveItemToIarNoAssets()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
// Create user
@ -236,7 +236,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
// Create asset
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50);
SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50);
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
@ -325,7 +325,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestLoadIarCreatorAccountPresent()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood");
@ -357,7 +357,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestLoadIarV0_1SameNameCreator()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood");
@ -390,7 +390,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestLoadIarV0_1AbsentCreator()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "password");

View File

@ -57,13 +57,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestSavePathToIarV0_1()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
Scene scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, archiverModule);
// Create user
string userFirstName = "Jock";
@ -172,16 +172,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestLoadIarToInventoryPaths()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
SerialiserModule serialiserModule = new SerialiserModule();
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
// Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "meowfood");
UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
@ -217,13 +217,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestLoadIarPathStartsWithSlash()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
SerialiserModule serialiserModule = new SerialiserModule();
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
Scene scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password");
archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream);
@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestLoadIarPathWithEscapedChars()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
string itemName = "You & you are a mean/man/";
@ -247,8 +247,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
Scene scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, archiverModule);
// Create user
string userFirstName = "Jock";
@ -323,10 +323,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestNewIarPath()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene);
Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
@ -390,10 +390,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestPartExistingIarPath()
{
TestHelper.InMethod();
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene);
string folder1ExistingName = "a";
@ -441,10 +441,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[Test]
public void TestMergeIarPath()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene);
string folder1ExistingName = "a";

View File

@ -1065,10 +1065,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
#endregion
#region Enable Child Agent
/// <summary>
/// This informs a single neighbouring region about agent "avatar".
/// Calls an asynchronous method to do so.. so it doesn't lag the sim.
/// </summary>
/// <param name="sp"></param>
/// <param name="region"></param>
public void EnableChildAgent(ScenePresence sp, GridRegion region)
{
m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName);
@ -1126,6 +1129,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
/// This informs all neighbouring regions about agent "avatar".
/// Calls an asynchronous method to do so.. so it doesn't lag the sim.
/// </summary>
/// <param name="sp"></param>
public void EnableChildAgents(ScenePresence sp)
{
List<GridRegion> neighbours = new List<GridRegion>();
@ -1312,7 +1316,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
Utils.LongToUInts(reg.RegionHandle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
m_log.Debug("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
m_log.Debug("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint + ")");
string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath);

View File

@ -964,8 +964,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
}
}
}
else
{
m_log.WarnFormat(
"[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", item.AssetID, item.Name, item.ID, remoteClient.Name);
}
return group;
}
else
{
m_log.WarnFormat(
"[InventoryAccessModule]: Could not find item {0} for {1} in RezObject()",
itemID, remoteClient.Name);
}
return null;
}

View File

@ -65,8 +65,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
config.AddConfig("Modules");
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, config, m_iam);
m_scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(m_scene, config, m_iam);
// Create user
string userFirstName = "Jock";
@ -82,14 +82,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
[Test]
public void TestRezCoalescedObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
// Create asset
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20);
SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20);
object1.AbsolutePosition = new Vector3(15, 30, 45);
SceneObjectGroup object2 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40);
SceneObjectGroup object2 = SceneHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40);
object2.AbsolutePosition = new Vector3(25, 50, 75);
CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2);
@ -138,11 +138,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
[Test]
public void TestRezObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
// Create asset
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40);
SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40);
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);

View File

@ -186,7 +186,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
}
}
private string[] GetUserNames(UUID uuid)
{
string[] returnstring = new string[2];
@ -292,6 +291,25 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
return userID.ToString();
}
public void AddUser(UUID uuid, string first, string last)
{
if (m_UserCache.ContainsKey(uuid))
return;
UserData user = new UserData();
user.Id = uuid;
user.FirstName = first;
user.LastName = last;
// user.ProfileURL = we should initialize this to the default
AddUserInternal(user);
}
public void AddUser(UUID uuid, string first, string last, string profileURL)
{
AddUser(uuid, profileURL + ";" + first + " " + last);
}
public void AddUser(UUID id, string creatorData)
{
if (m_UserCache.ContainsKey(id))
@ -299,18 +317,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData);
UserData user = new UserData();
user.Id = id;
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id);
if (account != null)
{
user.FirstName = account.FirstName;
user.LastName = account.LastName;
// user.ProfileURL = we should initialize this to the default
AddUser(id, account.FirstName, account.LastName);
}
else
{
UserData user = new UserData();
user.Id = id;
if (creatorData != null && creatorData != string.Empty)
{
//creatorData = <endpoint>;<name>
@ -338,17 +355,19 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
user.FirstName = "Unknown";
user.LastName = "User";
}
AddUserInternal(user);
}
lock (m_UserCache)
m_UserCache[id] = user;
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.HomeURL);
}
public void AddUser(UUID uuid, string first, string last, string profileURL)
void AddUserInternal(UserData user)
{
AddUser(uuid, profileURL + ";" + first + " " + last);
lock (m_UserCache)
m_UserCache[user.Id] = user;
m_log.DebugFormat(
"[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}",
user.Id, user.FirstName, user.LastName, user.HomeURL);
}
//public void AddUser(UUID uuid, string userData)

View File

@ -93,7 +93,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
lookat = ((ScenePresence)sp).Lookat;
}
}
m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
// m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
m_GridUserService.LoggedOut(client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID, position, lookat);
}

View File

@ -211,11 +211,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return;
}
}
else
{
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: User {0} does not have InventoryServerURI. OH NOES!", userID);
return;
}
// else
// {
// m_log.DebugFormat("[HG INVENTORY CONNECTOR]: User {0} does not have InventoryServerURI. OH NOES!", userID);
// return;
// }
}
}
if (sp == null)

View File

@ -94,7 +94,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
}
}
m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
// m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
m_PresenceService.LogoutAgent(client.SessionId);
}

View File

@ -129,14 +129,12 @@ namespace OpenSim.Region.CoreModules.World
switch (cmd[1])
{
case "enable":
if (scene.LoginsDisabled)
MainConsole.Instance.Output(String.Format("Enabling logins for region {0}", scene.RegionInfo.RegionName));
scene.LoginsDisabled = false;
MainConsole.Instance.Output(String.Format("Logins are enabled for region {0}", scene.RegionInfo.RegionName));
break;
case "disable":
if (!scene.LoginsDisabled)
MainConsole.Instance.Output(String.Format("Disabling logins for region {0}", scene.RegionInfo.RegionName));
scene.LoginsDisabled = true;
MainConsole.Instance.Output(String.Format("Logins are disabled for region {0}", scene.RegionInfo.RegionName));
break;
case "status":
if (scene.LoginsDisabled)

View File

@ -68,8 +68,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
SerialiserModule serialiserModule = new SerialiserModule();
TerrainModule terrainModule = new TerrainModule();
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule);
m_scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule);
}
private void LoadCompleted(Guid requestId, string errorMessage)
@ -125,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
[Test]
public void TestSaveOar()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
SceneObjectPart part1 = CreateSceneObjectPart1();
@ -217,7 +217,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
[Test]
public void TestSaveOarNoAssets()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
SceneObjectPart part1 = CreateSceneObjectPart1();
@ -300,7 +300,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
[Test]
public void TestLoadOar()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
@ -409,7 +409,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
[Test]
public void TestLoadOarRegionSettings()
{
TestHelper.InMethod();
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
@ -505,7 +505,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
//[Test]
public void TestMergeOar()
{
TestHelper.InMethod();
TestHelpers.InMethod();
//XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
@ -524,8 +524,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
SerialiserModule serialiserModule = new SerialiserModule();
TerrainModule terrainModule = new TerrainModule();
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule);
Scene scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule);
m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false);

View File

@ -64,8 +64,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
{
m_pcm = new PrimCountModule();
LandManagementModule lmm = new LandManagementModule();
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm);
m_scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(m_scene, lmm, m_pcm);
int xParcelDivider = (int)Constants.RegionSize - 1;
@ -106,12 +106,12 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
[Test]
public void TestAddOwnerObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false);
Assert.That(pc.Owner, Is.EqualTo(3));
@ -124,7 +124,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
Assert.That(pc.Simulator, Is.EqualTo(3));
// Add a second object and retest
SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
SceneObjectGroup sog2 = SceneHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
m_scene.AddNewSceneObject(sog2, false);
Assert.That(pc.Owner, Is.EqualTo(5));
@ -143,12 +143,12 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
[Test]
public void TestCopyOwnerObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false);
m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity);
@ -169,12 +169,12 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
[Test]
public void TestMoveOwnerObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false);
SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
SceneObjectGroup sog2 = SceneHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
m_scene.AddNewSceneObject(sog2, false);
// Move the first scene object to the eastern strip parcel
@ -230,13 +230,13 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
[Test]
public void TestRemoveOwnerObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
IPrimCounts pc = m_lo.PrimCounts;
m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false);
SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
m_scene.AddNewSceneObject(SceneHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false);
SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
m_scene.AddNewSceneObject(sogToDelete, false);
m_scene.DeleteSceneObject(sogToDelete, false);
@ -253,14 +253,14 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
[Test]
public void TestAddGroupObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
m_lo.DeedToGroup(m_groupId);
IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
sog.GroupID = m_groupId;
m_scene.AddNewSceneObject(sog, false);
@ -284,18 +284,18 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
[Test]
public void TestRemoveGroupObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
m_lo.DeedToGroup(m_groupId);
IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1);
SceneObjectGroup sogToKeep = SceneHelpers.CreateSceneObject(1, m_userId, "a", 0x1);
sogToKeep.GroupID = m_groupId;
m_scene.AddNewSceneObject(sogToKeep, false);
SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
m_scene.AddNewSceneObject(sogToDelete, false);
m_scene.DeleteSceneObject(sogToDelete, false);
@ -313,12 +313,12 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
[Test]
public void TestAddOthersObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false);
Assert.That(pc.Owner, Is.EqualTo(0));
@ -334,13 +334,13 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
[Test]
public void TestRemoveOthersObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
IPrimCounts pc = m_lo.PrimCounts;
m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false);
SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10);
m_scene.AddNewSceneObject(SceneHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false);
SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10);
m_scene.AddNewSceneObject(sogToDelete, false);
m_scene.DeleteSceneObject(sogToDelete, false);
@ -360,10 +360,10 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
[Test]
public void TestTaint()
{
TestHelper.InMethod();
TestHelpers.InMethod();
IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false);
m_pcm.TaintPrimCount();

View File

@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
private Bitmap fetchTexture(UUID id)
{
AssetBase asset = m_scene.AssetService.Get(id.ToString());
m_log.DebugFormat("Fetched texture {0}, found: {1}", id, asset != null);
m_log.DebugFormat("[TexturedMapTileRenderer]: Fetched texture {0}, found: {1}", id, asset != null);
if (asset == null) return null;
ManagedImage managedImage;

View File

@ -53,17 +53,17 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
public void SetUp()
{
m_module = new MoapModule();
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, m_module);
m_scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(m_scene, m_module);
}
[Test]
public void TestClearMediaUrl()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
MediaEntry me = new MediaEntry();
m_module.SetMediaEntry(part, 1, me);
@ -84,11 +84,11 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
[Test]
public void TestSetMediaUrl()
{
TestHelper.InMethod();
TestHelpers.InMethod();
string homeUrl = "opensimulator.org";
SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
MediaEntry me = new MediaEntry() { HomeURL = homeUrl };
m_module.SetMediaEntry(part, 1, me);

View File

@ -236,14 +236,14 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
public void Init()
{
m_serialiserModule = new SerialiserModule();
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule);
m_scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(m_scene, m_serialiserModule);
}
[Test]
public void TestDeserializeXml()
{
TestHelper.InMethod();
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
SceneObjectGroup so = SceneObjectSerializer.FromOriginalXmlFormat(xml);
@ -259,7 +259,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
[Test]
public void TestSerializeXml()
{
TestHelper.InMethod();
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
string rpName = "My Little Donkey";
@ -334,7 +334,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
[Test]
public void TestDeserializeXml2()
{
TestHelper.InMethod();
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
SceneObjectGroup so = m_serialiserModule.DeserializeGroupFromXml2(xml2);
@ -350,7 +350,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
[Test]
public void TestSerializeXml2()
{
TestHelper.InMethod();
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
string rpName = "My Little Pony";

View File

@ -100,15 +100,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Vegetation
{
case Tree.Cypress1:
case Tree.Cypress2:
tree.Scale = new Vector3(4, 4, 10);
tree.Scale *= new Vector3(8, 8, 20);
break;
// case... other tree types
// tree.Scale = new Vector3(?, ?, ?);
// tree.Scale *= new Vector3(?, ?, ?);
// break;
default:
tree.Scale = new Vector3(4, 4, 4);
tree.Scale *= new Vector3(8, 8, 8);
break;
}
}

View File

@ -46,6 +46,7 @@ using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.CoreModules.World.Land;
using Caps=OpenSim.Framework.Capabilities.Caps;
using OSDArray=OpenMetaverse.StructuredData.OSDArray;
using OSDMap=OpenMetaverse.StructuredData.OSDMap;
@ -68,6 +69,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
protected Scene m_scene;
private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>();
private int cachedTime = 0;
private int blacklistTimeout = 10*60*1000; // 10 minutes
private byte[] myMapImageJPEG;
protected volatile bool m_Enabled = false;
private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>();
@ -85,6 +87,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
IConfig startupConfig = config.Configs["Startup"];
if (startupConfig.GetString("WorldMapModule", "WorldMap") == "WorldMap")
m_Enabled = true;
blacklistTimeout = startupConfig.GetInt("BlacklistTimeout", 10*60) * 1000;
}
public virtual void AddRegion (Scene scene)
@ -159,11 +163,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
m_scene.EventManager.OnClientClosed += ClientLoggedOut;
m_scene.EventManager.OnMakeChildAgent += MakeChildAgent;
m_scene.EventManager.OnMakeRootAgent += MakeRootAgent;
m_scene.EventManager.OnRegionUp += OnRegionUp;
StartThread(new object());
}
// this has to be called with a lock on m_scene
protected virtual void RemoveHandlers()
{
StopThread();
m_scene.EventManager.OnRegionUp -= OnRegionUp;
m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent;
m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
m_scene.EventManager.OnClientClosed -= ClientLoggedOut;
@ -279,7 +289,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
/// <returns></returns>
public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
{
m_log.Debug("[WORLD MAP]: MapLayer Request in region: " + m_scene.RegionInfo.RegionName);
m_log.DebugFormat("[WORLD MAP]: MapLayer Request in region: {0}", m_scene.RegionInfo.RegionName);
LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse());
return mapResponse;
@ -321,8 +331,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
lock (m_rootAgents)
{
m_rootAgents.Remove(AgentId);
if (m_rootAgents.Count == 0)
StopThread();
}
}
#endregion
@ -362,6 +370,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags,
uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
{
// m_log.DebugFormat("[WORLD MAP]: Handle MapItem request {0} {1}", regionhandle, itemtype);
lock (m_rootAgents)
{
if (!m_rootAgents.Contains(remoteClient.AgentId))
@ -370,7 +380,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
uint xstart = 0;
uint ystart = 0;
Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out xstart, out ystart);
if (itemtype == 6) // we only sevice 6 right now (avatar green dots)
if (itemtype == 6) // Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots)
{
if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
{
@ -414,14 +424,58 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
// Remote Map Item Request
// ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes.
// Note that we only start up a remote mapItem Request thread if there's users who could
// be making requests
if (!threadrunning)
{
m_log.Warn("[WORLD MAP]: Starting new remote request thread manually. This means that AvatarEnteringParcel never fired! This needs to be fixed! Don't Mantis this, as the developers can see it in this message");
StartThread(new object());
}
RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle);
}
} else if (itemtype == 7) // Service 7 (MAP_ITEM_LAND_FOR_SALE)
{
if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
{
// Parcels
ILandChannel landChannel = m_scene.LandChannel;
List<ILandObject> parcels = landChannel.AllParcels();
// Local Map Item Request
int tc = Environment.TickCount;
List<mapItemReply> mapitems = new List<mapItemReply>();
mapItemReply mapitem = new mapItemReply();
if ((parcels != null) && (parcels.Count >= 1))
{
foreach (ILandObject parcel_interface in parcels)
{
// Play it safe
if (!(parcel_interface is LandObject))
continue;
LandObject land = (LandObject)parcel_interface;
LandData parcel = land.LandData;
// Show land for sale
if ((parcel.Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale)
{
Vector3 min = parcel.AABBMin;
Vector3 max = parcel.AABBMax;
float x = (min.X+max.X)/2;
float y = (min.Y+max.Y)/2;
mapitem = new mapItemReply();
mapitem.x = (uint)(xstart + x);
mapitem.y = (uint)(ystart + y);
// mapitem.z = (uint)m_scene.GetGroundHeight(x,y);
mapitem.id = UUID.Zero;
mapitem.name = parcel.Name;
mapitem.Extra = parcel.Area;
mapitem.Extra2 = parcel.SalePrice;
mapitems.Add(mapitem);
}
}
}
remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
}
else
{
// Remote Map Item Request
// ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes.
RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle);
}
}
@ -542,6 +596,28 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
}
av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags);
}
// Service 7 (MAP_ITEM_LAND_FOR_SALE)
uint itemtype = 7;
if (response.ContainsKey(itemtype.ToString()))
{
List<mapItemReply> returnitems = new List<mapItemReply>();
OSDArray itemarray = (OSDArray)response[itemtype.ToString()];
for (int i = 0; i < itemarray.Count; i++)
{
OSDMap mapitem = (OSDMap)itemarray[i];
mapItemReply mi = new mapItemReply();
mi.x = (uint)mapitem["X"].AsInteger();
mi.y = (uint)mapitem["Y"].AsInteger();
mi.id = mapitem["ID"].AsUUID();
mi.Extra = mapitem["Extra"].AsInteger();
mi.Extra2 = mapitem["Extra2"].AsInteger();
mi.name = mapitem["Name"].AsString();
returnitems.Add(mi);
}
av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags);
}
}
}
}
@ -589,12 +665,23 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
private OSDMap RequestMapItemsAsync(UUID id, uint flags,
uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
{
// m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype);
string httpserver = "";
bool blacklisted = false;
lock (m_blacklistedregions)
{
if (m_blacklistedregions.ContainsKey(regionhandle))
blacklisted = true;
{
if (Environment.TickCount > (m_blacklistedregions[regionhandle] + blacklistTimeout))
{
m_log.DebugFormat("[WORLDMAP]: Unblock blacklisted region {0}", regionhandle);
m_blacklistedregions.Remove(regionhandle);
}
else
blacklisted = true;
}
}
if (blacklisted)
@ -636,7 +723,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
lock (m_blacklistedurls)
{
if (m_blacklistedurls.ContainsKey(httpserver))
blacklisted = true;
{
if (Environment.TickCount > (m_blacklistedurls[httpserver] + blacklistTimeout))
{
m_log.DebugFormat("[WORLDMAP]: Unblock blacklisted URL {0}", httpserver);
m_blacklistedurls.Remove(httpserver);
}
else
blacklisted = true;
}
}
// Can't find the http server
@ -682,7 +778,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
mapitemsrequest.ContentLength = buffer.Length; //Count bytes to send
os = mapitemsrequest.GetRequestStream();
os.Write(buffer, 0, buffer.Length); //Send it
os.Close();
//m_log.DebugFormat("[WORLD MAP]: Getting MapItems from {0}", httpserver);
}
catch (WebException ex)
@ -705,6 +800,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
responseMap["connect"] = OSD.FromBoolean(false);
return responseMap;
}
finally
{
if (os != null)
os.Close();
}
string response_mapItems_reply = null;
{ // get the response
@ -1060,6 +1160,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart);
// Service 6 (MAP_ITEM_AGENTS_LOCATION; green dots)
OSDMap responsemap = new OSDMap();
int tc = Environment.TickCount;
if (m_scene.GetRootAgentCount() == 0)
@ -1092,6 +1194,60 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
});
responsemap["6"] = responsearr;
}
// Service 7 (MAP_ITEM_LAND_FOR_SALE)
ILandChannel landChannel = m_scene.LandChannel;
List<ILandObject> parcels = landChannel.AllParcels();
if ((parcels == null) || (parcels.Count == 0))
{
OSDMap responsemapdata = new OSDMap();
responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1));
responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1));
responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
responsemapdata["Name"] = OSD.FromString("");
responsemapdata["Extra"] = OSD.FromInteger(0);
responsemapdata["Extra2"] = OSD.FromInteger(0);
OSDArray responsearr = new OSDArray();
responsearr.Add(responsemapdata);
responsemap["7"] = responsearr;
}
else
{
OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount());
foreach (ILandObject parcel_interface in parcels)
{
// Play it safe
if (!(parcel_interface is LandObject))
continue;
LandObject land = (LandObject)parcel_interface;
LandData parcel = land.LandData;
// Show land for sale
if ((parcel.Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale)
{
Vector3 min = parcel.AABBMin;
Vector3 max = parcel.AABBMax;
float x = (min.X+max.X)/2;
float y = (min.Y+max.Y)/2;
OSDMap responsemapdata = new OSDMap();
responsemapdata["X"] = OSD.FromInteger((int)(xstart + x));
responsemapdata["Y"] = OSD.FromInteger((int)(ystart + y));
// responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y));
responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
responsemapdata["Name"] = OSD.FromString(parcel.Name);
responsemapdata["Extra"] = OSD.FromInteger(parcel.Area);
responsemapdata["Extra2"] = OSD.FromInteger(parcel.SalePrice);
responsearr.Add(responsemapdata);
}
}
responsemap["7"] = responsearr;
}
return responsemap;
}
@ -1140,12 +1296,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
private void MakeRootAgent(ScenePresence avatar)
{
// You may ask, why this is in a threadpool to start with..
// The reason is so we don't cause the thread to freeze waiting
// for the 1 second it costs to start a thread manually.
if (!threadrunning)
Util.FireAndForget(this.StartThread);
lock (m_rootAgents)
{
if (!m_rootAgents.Contains(avatar.UUID))
@ -1160,8 +1310,30 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
lock (m_rootAgents)
{
m_rootAgents.Remove(avatar.UUID);
if (m_rootAgents.Count == 0)
StopThread();
}
}
public void OnRegionUp(GridRegion otherRegion)
{
ulong regionhandle = otherRegion.RegionHandle;
string httpserver = otherRegion.ServerURI + "MAP/MapItems/" + regionhandle.ToString();
lock (m_blacklistedregions)
{
if (!m_blacklistedregions.ContainsKey(regionhandle))
m_blacklistedregions.Remove(regionhandle);
}
lock (m_blacklistedurls)
{
if (m_blacklistedurls.ContainsKey(httpserver))
m_blacklistedurls.Remove(httpserver);
}
lock (m_cachedRegionMapItemsAddress)
{
if (!m_cachedRegionMapItemsAddress.ContainsKey(regionhandle))
m_cachedRegionMapItemsAddress.Remove(regionhandle);
}
}

View File

@ -83,7 +83,7 @@ namespace OpenSim.Region.Examples.SimpleModule
public event DeRezObject OnDeRezObject;
public event Action<IClientAPI> OnRegionHandShakeReply;
public event GenericCall1 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit;
@ -222,7 +222,7 @@ namespace OpenSim.Region.Examples.SimpleModule
public event ScriptReset OnScriptReset;
public event GetScriptRunning OnGetScriptRunning;
public event SetScriptRunning OnSetScriptRunning;
public event Action<Vector3> OnAutoPilotGo;
public event Action<Vector3, bool> OnAutoPilotGo;
public event TerrainUnacked OnUnackedTerrain;
@ -663,7 +663,7 @@ namespace OpenSim.Region.Examples.SimpleModule
if (OnCompleteMovementToRegion != null)
{
OnCompleteMovementToRegion(this);
OnCompleteMovementToRegion(this, true);
}
}
public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)

View File

@ -95,7 +95,7 @@ namespace OpenSim.Region.Examples.SimpleModule
for (int i = 0; i < 1; i++)
{
MyNpcCharacter m_character = new MyNpcCharacter(m_scene);
m_scene.AddNewClient(m_character);
m_scene.AddNewClient(m_character, PresenceType.Npc);
m_scene.AgentCrossing(m_character.AgentId, Vector3.Zero, false);
}

View File

@ -96,9 +96,10 @@ namespace OpenSim.Region.Framework.Interfaces
/// <summary>
/// Detach an object from the avatar.
/// </summary>
///
/// <remarks>
/// This method is called in response to a client's detach request, so we only update the information in
/// inventory
/// </remarks>
/// <param name="objectLocalID"></param>
/// <param name="remoteClient"></param>
void DetachObject(uint objectLocalID, IClientAPI remoteClient);

View File

@ -32,6 +32,14 @@ namespace OpenSim.Region.Framework.Interfaces
{
public interface IAvatarFactory
{
/// <summary>
/// Send the appearance of an avatar to others in the scene.
/// </summary>
/// <param name="agentId"></param>
/// <returns></returns>
bool SendAppearance(UUID agentId);
bool SaveBakedTextures(UUID agentId);
bool ValidateBakedTextureCache(IClientAPI client);
void QueueAppearanceSend(UUID agentid);
void QueueAppearanceSave(UUID agentid);

View File

@ -26,6 +26,7 @@
*/
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Framework.Interfaces
@ -39,9 +40,26 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="lastname"></param>
/// <param name="position"></param>
/// <param name="scene"></param>
/// <param name="cloneAppearanceFrom">The UUID of the avatar from which to clone the NPC's appearance from.</param>
/// <param name="appearance">The avatar appearance to use for the new NPC.</param>
/// <returns>The UUID of the ScenePresence created.</returns>
UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom);
UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance);
/// <summary>
/// Check if the agent is an NPC.
/// </summary>
/// <param name="agentID"></param>
/// <param name="scene"></param>
/// <returns>True if the agent is an NPC in the given scene. False otherwise.</returns>
bool IsNPC(UUID agentID, Scene scene);
/// <summary>
/// Set the appearance for an NPC.
/// </summary>
/// <param name="agentID"></param>
/// <param name="appearance"></param>
/// <param name="scene"></param>
/// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool SetNPCAppearance(UUID agentID, AvatarAppearance appearance, Scene scene);
/// <summary>
/// Move an NPC to a target over time.
@ -49,7 +67,23 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="agentID">The UUID of the NPC</param>
/// <param name="scene"></param>
/// <param name="pos"></param>
void MoveToTarget(UUID agentID, Scene scene, Vector3 pos);
/// <param name="noFly">
/// If true, then the avatar will attempt to walk to the location even if it's up in the air.
/// This is to allow walking on prims.
/// </param>
/// <param name="landAtTarget">
/// If true and the avatar is flying when it reaches the target, land.
/// </param>
/// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget);
/// <summary>
/// Stop the NPC's current movement.
/// </summary>
/// <param name="agentID">The UUID of the NPC</param>
/// <param name="scene"></param>
/// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool StopMoveToTarget(UUID agentID, Scene scene);
/// <summary>
/// Get the NPC to say something.
@ -57,14 +91,15 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="agentID">The UUID of the NPC</param>
/// <param name="scene"></param>
/// <param name="text"></param>
void Say(UUID agentID, Scene scene, string text);
/// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool Say(UUID agentID, Scene scene, string text);
/// <summary>
/// Delete an NPC.
/// </summary>
/// <param name="agentID">The UUID of the NPC</param>
/// <param name="scene"></param>
void DeleteNPC(UUID agentID, Scene scene);
/// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool DeleteNPC(UUID agentID, Scene scene);
}
}

View File

@ -5,13 +5,48 @@ using OpenMetaverse;
namespace OpenSim.Region.Framework.Interfaces
{
/// <summary>
/// This maintains the relationship between a UUID and a user name.
/// </summary>
public interface IUserManagement
{
string GetUserName(UUID uuid);
string GetUserHomeURL(UUID uuid);
string GetUserUUI(UUID uuid);
string GetUserServerURL(UUID uuid, string serverType);
void AddUser(UUID uuid, string userData);
/// <summary>
/// Add a user.
/// </summary>
/// <remarks>
/// If an account is found for the UUID, then the names in this will be used rather than any information
/// extracted from creatorData.
/// </remarks>
/// <param name="uuid"></param>
/// <param name="creatorData">The creator data for this user.</param>
void AddUser(UUID uuid, string creatorData);
/// <summary>
/// Add a user.
/// </summary>
/// <remarks>
/// The UUID is related to the name without any other checks being performed, such as user account presence.
/// </remarks>
/// <param name="uuid"></param>
/// <param name="firstName"></param>
/// <param name="lastName"></param>
void AddUser(UUID uuid, string firstName, string lastName);
/// <summary>
/// Add a user.
/// </summary>
/// <remarks>
/// The arguments apart from uuid are formed into a creatorData string and processing proceeds as for the
/// AddUser(UUID uuid, string creatorData) method.
/// </remarks>
/// <param name="uuid"></param>
/// <param name="firstName"></param>
/// <param name="profileURL"></param>
void AddUser(UUID uuid, string firstName, string lastName, string profileURL);
}
}

View File

@ -77,6 +77,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
if (m_scenePresence.IsChildAgent)
return;
// m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name);
if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID))
SendAnimPack();
}
@ -91,6 +93,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
if (animID == UUID.Zero)
return;
// m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", animID, name, m_scenePresence.Name);
AddAnimation(animID, objectID);
}
@ -127,13 +131,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation
/// </summary>
public void TrySetMovementAnimation(string anim)
{
//m_log.DebugFormat("Updating movement animation to {0}", anim);
if (!m_scenePresence.IsChildAgent)
{
if (m_animations.TrySetDefaultAnimation(
anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID))
{
// m_log.DebugFormat(
// "[SCENE PRESENCE ANIMATOR]: Updating movement animation to {0} for {1}",
// anim, m_scenePresence.Name);
// 16384 is CHANGED_ANIMATION
m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION});
SendAnimPack();

View File

@ -611,6 +611,10 @@ namespace OpenSim.Region.Framework.Scenes
"delete object name <name>",
"Delete object by name", HandleDeleteObject);
MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside",
"delete object outside",
"Delete all objects outside boundaries", HandleDeleteObject);
//Bind Storage Manager functions to some land manager functions for this scene
EventManager.OnLandObjectAdded +=
new EventManager.LandObjectAdded(simDataService.StoreLandObject);
@ -2539,10 +2543,11 @@ namespace OpenSim.Region.Framework.Scenes
#region Add/Remove Avatar Methods
/// <summary>
/// Adding a New Client and Create a Presence for it.
/// Add a new client and create a child agent for it.
/// </summary>
/// <param name="client"></param>
public override void AddNewClient(IClientAPI client)
/// <param name="type">The type of agent to add.</param>
public override void AddNewClient(IClientAPI client, PresenceType type)
{
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
bool vialogin = false;
@ -2562,7 +2567,7 @@ namespace OpenSim.Region.Framework.Scenes
m_clientManager.Add(client);
SubscribeToClientEvents(client);
ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance);
ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
m_eventManager.TriggerOnNewPresence(sp);
sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags;
@ -2577,12 +2582,13 @@ namespace OpenSim.Region.Framework.Scenes
}
}
if (GetScenePresence(client.AgentId) != null)
ScenePresence createdSp = GetScenePresence(client.AgentId);
if (createdSp != null)
{
m_LastLogin = Util.EnvironmentTickCount();
// Cache the user's name
CacheUserName(aCircuit);
CacheUserName(createdSp, aCircuit);
EventManager.TriggerOnNewClient(client);
if (vialogin)
@ -2590,28 +2596,41 @@ namespace OpenSim.Region.Framework.Scenes
}
}
private void CacheUserName(AgentCircuitData aCircuit)
/// <summary>
/// Cache the user name for later use.
/// </summary>
/// <param name="sp"></param>
/// <param name="aCircuit"></param>
private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit)
{
IUserManagement uMan = RequestModuleInterface<IUserManagement>();
if (uMan != null)
{
string homeURL = string.Empty;
string first = aCircuit.firstname, last = aCircuit.lastname;
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
homeURL = aCircuit.ServiceURLs["HomeURI"].ToString();
if (aCircuit.lastname.StartsWith("@"))
if (sp.PresenceType == PresenceType.Npc)
{
string[] parts = aCircuit.firstname.Split('.');
if (parts.Length >= 2)
{
first = parts[0];
last = parts[1];
}
uMan.AddUser(aCircuit.AgentID, first, last);
}
else
{
string homeURL = string.Empty;
uMan.AddUser(aCircuit.AgentID, first, last, homeURL);
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
homeURL = aCircuit.ServiceURLs["HomeURI"].ToString();
if (aCircuit.lastname.StartsWith("@"))
{
string[] parts = aCircuit.firstname.Split('.');
if (parts.Length >= 2)
{
first = parts[0];
last = parts[1];
}
}
uMan.AddUser(aCircuit.AgentID, first, last, homeURL);
}
}
}
@ -3091,11 +3110,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// Remove the given client from the scene.
/// </summary>
/// <param name="agentID"></param>
public override void RemoveClient(UUID agentID)
public override void RemoveClient(UUID agentID, bool closeChildAgents)
{
CheckHeartbeat();
bool childagentYN = false;
@ -3117,14 +3132,16 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.removeUserCount(!childagentYN);
if (CapsModule != null)
// TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
// unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
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);
if (!avatar.IsChildAgent)
if (closeChildAgents && !avatar.IsChildAgent)
{
//List<ulong> childknownRegions = new List<ulong>();
//List<ulong> ckn = avatar.KnownChildRegionHandles;
@ -3136,6 +3153,7 @@ namespace OpenSim.Region.Framework.Scenes
regions.Remove(RegionInfo.RegionHandle);
m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
}
m_eventManager.TriggerClientClosed(agentID, this);
}
catch (NullReferenceException)
@ -3146,7 +3164,7 @@ namespace OpenSim.Region.Framework.Scenes
m_eventManager.TriggerOnRemovePresence(agentID);
if (avatar != null && (!avatar.IsChildAgent))
if (avatar != null && (!avatar.IsChildAgent) && avatar.PresenceType != PresenceType.Npc)
avatar.SaveChangedAttachments();
ForEachClient(
@ -4942,11 +4960,19 @@ namespace OpenSim.Region.Framework.Scenes
private void HandleDeleteObject(string module, string[] cmd)
{
if (cmd.Length < 4)
if (cmd.Length < 3)
return;
string mode = cmd[2];
string o = cmd[3];
string o = "";
if (mode != "outside")
{
if (cmd.Length < 4)
return;
o = cmd[3];
}
List<SceneObjectGroup> deletes = new List<SceneObjectGroup>();
@ -4988,10 +5014,33 @@ namespace OpenSim.Region.Framework.Scenes
deletes.Add(g);
});
break;
case "outside":
ForEachSOG(delegate (SceneObjectGroup g)
{
SceneObjectPart rootPart = g.RootPart;
bool delete = false;
if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0)
{
delete = true;
} else {
ILandObject parcel = LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y);
if (parcel == null || parcel.LandData.Name == "NO LAND")
delete = true;
}
if (delete && !rootPart.IsAttachment && !deletes.Contains(g))
deletes.Add(g);
});
break;
}
foreach (SceneObjectGroup g in deletes)
{
m_log.InfoFormat("[SCENE]: Deleting object {0}", g.UUID);
DeleteSceneObject(g, false);
}
}
private void HandleReloadEstate(string module, string[] cmd)

View File

@ -175,18 +175,8 @@ namespace OpenSim.Region.Framework.Scenes
#region Add/Remove Agent/Avatar
/// <summary>
/// Register the new client with the scene. The client starts off as a child agent - the later agent crossing
/// will promote it to a root agent during login.
/// </summary>
/// <param name="client"></param
public abstract void AddNewClient(IClientAPI client);
/// <summary>
/// Remove a client from the scene
/// </summary>
/// <param name="agentID"></param>
public abstract void RemoveClient(UUID agentID);
public abstract void AddNewClient(IClientAPI client, PresenceType type);
public abstract void RemoveClient(UUID agentID, bool closeChildAgents);
public bool TryGetScenePresence(UUID agentID, out object scenePresence)
{

View File

@ -590,12 +590,13 @@ namespace OpenSim.Region.Framework.Scenes
}
}
protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance)
protected internal ScenePresence CreateAndAddChildScenePresence(
IClientAPI client, AvatarAppearance appearance, PresenceType type)
{
ScenePresence newAvatar = null;
// ScenePresence always defaults to child agent
newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance);
newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance, type);
AddScenePresence(newAvatar);

View File

@ -53,12 +53,12 @@ namespace OpenSim.Region.Framework.Scenes
get { return m_instance; }
}
private readonly List<Scene> m_localScenes;
private readonly List<Scene> m_localScenes = new List<Scene>();
private Scene m_currentScene = null;
public List<Scene> Scenes
{
get { return m_localScenes; }
get { return new List<Scene>(m_localScenes); }
}
public Scene CurrentScene
@ -72,13 +72,12 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_currentScene == null)
{
if (m_localScenes.Count > 0)
lock (m_localScenes)
{
return m_localScenes[0];
}
else
{
return null;
if (m_localScenes.Count > 0)
return m_localScenes[0];
else
return null;
}
}
else
@ -98,17 +97,21 @@ namespace OpenSim.Region.Framework.Scenes
{
// collect known shared modules in sharedModules
Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>();
for (int i = 0; i < m_localScenes.Count; i++)
lock (m_localScenes)
{
// extract known shared modules from scene
foreach (string k in m_localScenes[i].Modules.Keys)
for (int i = 0; i < m_localScenes.Count; i++)
{
if (m_localScenes[i].Modules[k].IsSharedModule &&
!sharedModules.ContainsKey(k))
sharedModules[k] = m_localScenes[i].Modules[k];
// extract known shared modules from scene
foreach (string k in m_localScenes[i].Modules.Keys)
{
if (m_localScenes[i].Modules[k].IsSharedModule &&
!sharedModules.ContainsKey(k))
sharedModules[k] = m_localScenes[i].Modules[k];
}
// close scene/region
m_localScenes[i].Close();
}
// close scene/region
m_localScenes[i].Close();
}
// all regions/scenes are now closed, we can now safely
@ -121,13 +124,16 @@ namespace OpenSim.Region.Framework.Scenes
public void Close(Scene cscene)
{
if (m_localScenes.Contains(cscene))
lock (m_localScenes)
{
for (int i = 0; i < m_localScenes.Count; i++)
if (m_localScenes.Contains(cscene))
{
if (m_localScenes[i].Equals(cscene))
for (int i = 0; i < m_localScenes.Count; i++)
{
m_localScenes[i].Close();
if (m_localScenes[i].Equals(cscene))
{
m_localScenes[i].Close();
}
}
}
}
@ -136,27 +142,33 @@ namespace OpenSim.Region.Framework.Scenes
public void Add(Scene scene)
{
scene.OnRestart += HandleRestart;
m_localScenes.Add(scene);
lock (m_localScenes)
m_localScenes.Add(scene);
}
public void HandleRestart(RegionInfo rdata)
{
m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main");
int RegionSceneElement = -1;
for (int i = 0; i < m_localScenes.Count; i++)
lock (m_localScenes)
{
if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName)
for (int i = 0; i < m_localScenes.Count; i++)
{
RegionSceneElement = i;
if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName)
{
RegionSceneElement = i;
}
}
}
// Now we make sure the region is no longer known about by the SceneManager
// Prevents duplicates.
// Now we make sure the region is no longer known about by the SceneManager
// Prevents duplicates.
if (RegionSceneElement >= 0)
{
m_localScenes.RemoveAt(RegionSceneElement);
if (RegionSceneElement >= 0)
{
m_localScenes.RemoveAt(RegionSceneElement);
}
}
// Send signal to main that we're restarting this sim.
@ -167,28 +179,32 @@ namespace OpenSim.Region.Framework.Scenes
{
RegionInfo Result = null;
for (int i = 0; i < m_localScenes.Count; i++)
{
if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle)
{
// Inform other regions to tell their avatar about me
Result = m_localScenes[i].RegionInfo;
}
}
if (Result != null)
lock (m_localScenes)
{
for (int i = 0; i < m_localScenes.Count; i++)
{
if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle)
if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle)
{
// Inform other regions to tell their avatar about me
//m_localScenes[i].OtherRegionUp(Result);
Result = m_localScenes[i].RegionInfo;
}
}
}
else
{
m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up");
if (Result != null)
{
for (int i = 0; i < m_localScenes.Count; i++)
{
if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle)
{
// Inform other regions to tell their avatar about me
//m_localScenes[i].OtherRegionUp(Result);
}
}
}
else
{
m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up");
}
}
}
@ -292,7 +308,8 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_currentScene == null)
{
m_localScenes.ForEach(func);
lock (m_localScenes)
m_localScenes.ForEach(func);
}
else
{
@ -321,12 +338,15 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
foreach (Scene scene in m_localScenes)
lock (m_localScenes)
{
if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
foreach (Scene scene in m_localScenes)
{
m_currentScene = scene;
return true;
if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
{
m_currentScene = scene;
return true;
}
}
}
@ -338,12 +358,15 @@ namespace OpenSim.Region.Framework.Scenes
{
m_log.Debug("Searching for Region: '" + regionID + "'");
foreach (Scene scene in m_localScenes)
lock (m_localScenes)
{
if (scene.RegionInfo.RegionID == regionID)
foreach (Scene scene in m_localScenes)
{
m_currentScene = scene;
return true;
if (scene.RegionInfo.RegionID == regionID)
{
m_currentScene = scene;
return true;
}
}
}
@ -352,26 +375,33 @@ namespace OpenSim.Region.Framework.Scenes
public bool TryGetScene(string regionName, out Scene scene)
{
foreach (Scene mscene in m_localScenes)
lock (m_localScenes)
{
if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0)
foreach (Scene mscene in m_localScenes)
{
scene = mscene;
return true;
if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0)
{
scene = mscene;
return true;
}
}
}
scene = null;
return false;
}
public bool TryGetScene(UUID regionID, out Scene scene)
{
foreach (Scene mscene in m_localScenes)
lock (m_localScenes)
{
if (mscene.RegionInfo.RegionID == regionID)
foreach (Scene mscene in m_localScenes)
{
scene = mscene;
return true;
if (mscene.RegionInfo.RegionID == regionID)
{
scene = mscene;
return true;
}
}
}
@ -381,13 +411,16 @@ namespace OpenSim.Region.Framework.Scenes
public bool TryGetScene(uint locX, uint locY, out Scene scene)
{
foreach (Scene mscene in m_localScenes)
lock (m_localScenes)
{
if (mscene.RegionInfo.RegionLocX == locX &&
mscene.RegionInfo.RegionLocY == locY)
foreach (Scene mscene in m_localScenes)
{
scene = mscene;
return true;
if (mscene.RegionInfo.RegionLocX == locX &&
mscene.RegionInfo.RegionLocY == locY)
{
scene = mscene;
return true;
}
}
}
@ -397,13 +430,16 @@ namespace OpenSim.Region.Framework.Scenes
public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene)
{
foreach (Scene mscene in m_localScenes)
lock (m_localScenes)
{
if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) &&
(mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port))
foreach (Scene mscene in m_localScenes)
{
scene = mscene;
return true;
if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) &&
(mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port))
{
scene = mscene;
return true;
}
}
}
@ -472,11 +508,14 @@ namespace OpenSim.Region.Framework.Scenes
public RegionInfo GetRegionInfo(UUID regionID)
{
foreach (Scene scene in m_localScenes)
lock (m_localScenes)
{
if (scene.RegionInfo.RegionID == regionID)
foreach (Scene scene in m_localScenes)
{
return scene.RegionInfo;
if (scene.RegionInfo.RegionID == regionID)
{
return scene.RegionInfo;
}
}
}
@ -495,11 +534,14 @@ namespace OpenSim.Region.Framework.Scenes
public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
{
foreach (Scene scene in m_localScenes)
lock (m_localScenes)
{
if (scene.TryGetScenePresence(avatarId, out avatar))
foreach (Scene scene in m_localScenes)
{
return true;
if (scene.TryGetScenePresence(avatarId, out avatar))
{
return true;
}
}
}
@ -510,12 +552,16 @@ namespace OpenSim.Region.Framework.Scenes
public bool TryGetAvatarsScene(UUID avatarId, out Scene scene)
{
ScenePresence avatar = null;
foreach (Scene mScene in m_localScenes)
lock (m_localScenes)
{
if (mScene.TryGetScenePresence(avatarId, out avatar))
foreach (Scene mScene in m_localScenes)
{
scene = mScene;
return true;
if (mScene.TryGetScenePresence(avatarId, out avatar))
{
scene = mScene;
return true;
}
}
}
@ -525,17 +571,22 @@ namespace OpenSim.Region.Framework.Scenes
public void CloseScene(Scene scene)
{
m_localScenes.Remove(scene);
lock (m_localScenes)
m_localScenes.Remove(scene);
scene.Close();
}
public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
{
foreach (Scene scene in m_localScenes)
lock (m_localScenes)
{
if (scene.TryGetAvatarByName(avatarName, out avatar))
foreach (Scene scene in m_localScenes)
{
return true;
if (scene.TryGetAvatarByName(avatarName, out avatar))
{
return true;
}
}
}
@ -545,7 +596,8 @@ namespace OpenSim.Region.Framework.Scenes
public void ForEachScene(Action<Scene> action)
{
m_localScenes.ForEach(action);
lock (m_localScenes)
m_localScenes.ForEach(action);
}
}
}

View File

@ -1650,7 +1650,7 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
if (avatar != null)
{
avatar.MoveToTarget(target);
avatar.MoveToTarget(target, false);
}
}
else
@ -2253,7 +2253,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="objectGroup"></param>
public virtual void DetachFromBackup()
{
if (m_isBackedUp)
if (m_isBackedUp && Scene != null)
m_scene.EventManager.OnBackup -= ProcessBackup;
m_isBackedUp = false;
@ -2520,7 +2520,7 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectPart selectionPart = GetChildPart(localID);
if (SetTemporary)
if (SetTemporary && Scene != null)
{
DetachFromBackup();
// Remove from database and parcel prim count
@ -2532,15 +2532,19 @@ namespace OpenSim.Region.Framework.Scenes
if (selectionPart != null)
{
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
if (Scene != null)
{
SceneObjectPart part = parts[i];
if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax ||
part.Scale.Y > m_scene.RegionInfo.PhysPrimMax ||
part.Scale.Z > m_scene.RegionInfo.PhysPrimMax)
for (int i = 0; i < parts.Length; i++)
{
UsePhysics = false; // Reset physics
break;
SceneObjectPart part = parts[i];
if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax ||
part.Scale.Y > m_scene.RegionInfo.PhysPrimMax ||
part.Scale.Z > m_scene.RegionInfo.PhysPrimMax)
{
UsePhysics = false; // Reset physics
break;
}
}
}

View File

@ -261,13 +261,10 @@ namespace OpenSim.Region.Framework.Scenes
}
protected SceneObjectPartInventory m_inventory;
public bool Undoing;
public bool IgnoreUndoUpdate = false;
private PrimFlags LocalFlags;
private float m_damage = -1.0f;
@ -1606,7 +1603,6 @@ namespace OpenSim.Region.Framework.Scenes
RotationOffset,
RigidBody,
m_localId);
PhysActor.SetMaterial(Material);
}
catch
{
@ -1618,6 +1614,7 @@ namespace OpenSim.Region.Framework.Scenes
{
PhysActor.SOPName = this.Name; // save object name and desc into the PhysActor so ODE internals know the joint/body info
PhysActor.SOPDescription = this.Description;
PhysActor.SetMaterial(Material);
DoPhysicsPropertyUpdate(RigidBody, true);
PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
}
@ -2970,22 +2967,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
public void ScriptSetPhantomStatus(bool Phantom)
{
if (m_parentGroup != null)
{
m_parentGroup.ScriptSetPhantomStatus(Phantom);
}
}
public void ScriptSetTemporaryStatus(bool Temporary)
{
if (m_parentGroup != null)
{
m_parentGroup.ScriptSetTemporaryStatus(Temporary);
}
}
public void ScriptSetPhysicsStatus(bool UsePhysics)
{
if (m_parentGroup == null)
@ -2994,15 +2975,6 @@ namespace OpenSim.Region.Framework.Scenes
m_parentGroup.ScriptSetPhysicsStatus(UsePhysics);
}
public void ScriptSetVolumeDetect(bool SetVD)
{
if (m_parentGroup != null)
{
m_parentGroup.ScriptSetVolumeDetect(SetVD);
}
}
/// <summary>
/// Set sculpt and mesh data, and tell the physics engine to process the change.
/// </summary>
@ -4542,6 +4514,9 @@ namespace OpenSim.Region.Framework.Scenes
{
RemFlag(PrimFlags.Phantom);
if (ParentGroup.Scene == null)
return;
PhysicsActor pa = PhysActor;
if (pa == null)
@ -4555,11 +4530,11 @@ namespace OpenSim.Region.Framework.Scenes
RotationOffset,
UsePhysics,
m_localId);
PhysActor.SetMaterial(Material);
pa = PhysActor;
if (pa != null)
{
PhysActor.SetMaterial(Material);
DoPhysicsPropertyUpdate(UsePhysics, true);
if (m_parentGroup != null)
@ -4645,6 +4620,8 @@ namespace OpenSim.Region.Framework.Scenes
ParentGroup.HasGroupChanged = true;
ScheduleFullUpdate();
// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags);
}
public void UpdateRotation(Quaternion rot)
@ -4864,7 +4841,7 @@ namespace OpenSim.Region.Framework.Scenes
// m_parentGroup.Scene.EventManager.OnScriptTimerEvent -= handleTimerAccounting;
//}
LocalFlags=(PrimFlags)objectflagupdate;
LocalFlags = (PrimFlags)objectflagupdate;
if (m_parentGroup != null && m_parentGroup.RootPart == this)
{

View File

@ -75,6 +75,11 @@ namespace OpenSim.Region.Framework.Scenes
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// What type of presence is this? User, NPC, etc.
/// </summary>
public PresenceType PresenceType { get; private set; }
// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
@ -173,7 +178,7 @@ namespace OpenSim.Region.Framework.Scenes
private float m_speedModifier = 1.0f;
private Quaternion m_bodyRot= Quaternion.Identity;
private Quaternion m_bodyRot = Quaternion.Identity;
private Quaternion m_bodyRotPrevious = Quaternion.Identity;
@ -708,15 +713,13 @@ namespace OpenSim.Region.Framework.Scenes
#region Constructor(s)
public ScenePresence()
public ScenePresence(
IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance, PresenceType type)
{
m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
CreateSceneViewer();
m_sceneViewer = new SceneViewer(this);
m_animator = new ScenePresenceAnimator(this);
}
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this()
{
PresenceType = type;
m_DrawDistance = world.DefaultDrawDistance;
m_rootRegionHandle = reginfo.RegionHandle;
m_controllingClient = client;
@ -762,19 +765,10 @@ namespace OpenSim.Region.Framework.Scenes
RegisterToEvents();
SetDirectionVectors();
}
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
: this(client, world, reginfo)
{
m_appearance = appearance;
}
private void CreateSceneViewer()
{
m_sceneViewer = new SceneViewer(this);
}
public void RegisterToEvents()
{
m_controllingClient.OnCompleteMovementToRegion += CompleteMovement;
@ -1144,10 +1138,14 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary>
/// Complete Avatar's movement into the region.
/// This is called upon a very important packet sent from the client,
/// so it's client-controlled. Never call this method directly.
/// </summary>
public void CompleteMovement(IClientAPI client)
/// <param name="client"></param>
/// <param name="openChildAgents">
/// If true, send notification to neighbour regions to expect
/// a child agent from the client. These neighbours can be some distance away, depending right now on the
/// configuration of DefaultDrawDistance in the [Startup] section of config
/// </param>
public void CompleteMovement(IClientAPI client, bool openChildAgents)
{
// DateTime startTime = DateTime.Now;
@ -1188,15 +1186,11 @@ namespace OpenSim.Region.Framework.Scenes
SendInitialData();
// Create child agents in neighbouring regions
if (!m_isChildAgent)
if (openChildAgents && !m_isChildAgent)
{
IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
if (m_agentTransfer != null)
m_agentTransfer.EnableChildAgents(this);
else
m_log.DebugFormat(
"[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active for region {0}",
m_scene.RegionInfo.RegionName);
IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
if (friendsModule != null)
@ -1294,7 +1288,6 @@ namespace OpenSim.Region.Framework.Scenes
#region Inputs
AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags;
Quaternion bodyRotation = agentData.BodyRotation;
// Camera location in world. We'll need to raytrace
// from this location from time to time.
@ -1380,6 +1373,15 @@ namespace OpenSim.Region.Framework.Scenes
if (m_allowMovement && !SitGround)
{
Quaternion bodyRotation = agentData.BodyRotation;
bool update_rotation = false;
if (bodyRotation != m_bodyRot)
{
Rotation = bodyRotation;
update_rotation = true;
}
bool update_movementflag = false;
if (agentData.UseClientAgentPosition)
@ -1389,11 +1391,8 @@ namespace OpenSim.Region.Framework.Scenes
}
int i = 0;
bool update_rotation = false;
bool DCFlagKeyPressed = false;
Vector3 agent_control_v3 = Vector3.Zero;
Quaternion q = bodyRotation;
bool oldflying = PhysicsActor.Flying;
@ -1407,12 +1406,6 @@ namespace OpenSim.Region.Framework.Scenes
if (actor.Flying != oldflying)
update_movementflag = true;
if (q != m_bodyRot)
{
m_bodyRot = q;
update_rotation = true;
}
if (m_parentID == 0)
{
bool bAllowUpdateMoveToPosition = false;
@ -1464,8 +1457,8 @@ namespace OpenSim.Region.Framework.Scenes
) // This or is for Nudge forward
{
m_movementflag -= ((byte)(uint)DCF);
update_movementflag = true;
/*
if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE)
&& ((m_movementflag & (byte)nudgehack) == nudgehack))
@ -1493,7 +1486,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else if (bAllowUpdateMoveToPosition)
{
if (HandleMoveToTargetUpdate(ref agent_control_v3, bodyRotation))
if (HandleMoveToTargetUpdate(ref agent_control_v3))
update_movementflag = true;
}
}
@ -1531,13 +1524,10 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat(
// "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3);
AddNewMovement(agent_control_v3, q);
AddNewMovement(agent_control_v3);
}
if (update_movementflag
&& ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0)
&& (m_parentID == 0)
&& !SitGround)
if (update_movementflag && m_parentID == 0)
Animator.UpdateMovementAnimations();
}
@ -1553,9 +1543,8 @@ namespace OpenSim.Region.Framework.Scenes
/// This doesn't actually perform the movement. Instead, it adds its vector to agent_control_v3.
/// </remarks>
/// <param value="agent_control_v3">Cumulative agent movement that this method will update.</param>
/// <param value="bodyRotation">New body rotation of the avatar.</param>
/// <returns>True if movement has been updated in some way. False otherwise.</returns>
public bool HandleMoveToTargetUpdate(ref Vector3 agent_control_v3, Quaternion bodyRotation)
public bool HandleMoveToTargetUpdate(ref Vector3 agent_control_v3)
{
// m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name);
@ -1591,7 +1580,7 @@ namespace OpenSim.Region.Framework.Scenes
// to such forces, but the following simple approach seems to works fine.
Vector3 LocalVectorToTarget3D =
(MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords
* Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords
* Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords
// Ignore z component of vector
// Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f);
LocalVectorToTarget3D.Normalize();
@ -1680,7 +1669,12 @@ namespace OpenSim.Region.Framework.Scenes
/// Move to the given target over time.
/// </summary>
/// <param name="pos"></param>
public void MoveToTarget(Vector3 pos)
/// <param name="noFly">
/// If true, then don't allow the avatar to fly to the target, even if it's up in the air.
/// This is to allow movement to targets that are known to be on an elevated platform with a continuous path
/// from start to finish.
/// </param>
public void MoveToTarget(Vector3 pos, bool noFly)
{
// m_log.DebugFormat(
// "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}",
@ -1714,15 +1708,17 @@ namespace OpenSim.Region.Framework.Scenes
"[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}",
Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
if (pos.Z > terrainHeight)
if (noFly)
PhysicsActor.Flying = false;
else if (pos.Z > terrainHeight)
PhysicsActor.Flying = true;
MovingToTarget = true;
MoveToPositionTarget = pos;
Vector3 agent_control_v3 = new Vector3();
HandleMoveToTargetUpdate(ref agent_control_v3, Rotation);
AddNewMovement(agent_control_v3, Rotation);
HandleMoveToTargetUpdate(ref agent_control_v3);
AddNewMovement(agent_control_v3);
}
/// <summary>
@ -1734,6 +1730,12 @@ namespace OpenSim.Region.Framework.Scenes
MovingToTarget = false;
MoveToPositionTarget = Vector3.Zero;
// We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct
// resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag.
// However, the line is here rather than in the NPC module since it also appears necessary to stop a
// viewer that uses "go here" from juddering on all subsequent avatar movements.
AgentControlFlags = (uint)AgentManager.ControlFlags.NONE;
}
private void CheckAtSitTarget()
@ -2295,20 +2297,11 @@ namespace OpenSim.Region.Framework.Scenes
/// Rotate the avatar to the given rotation and apply a movement in the given relative vector
/// </summary>
/// <param name="vec">The vector in which to move. This is relative to the rotation argument</param>
/// <param name="rotation">The direction in which this avatar should now face.
public void AddNewMovement(Vector3 vec, Quaternion rotation)
public void AddNewMovement(Vector3 vec)
{
if (m_isChildAgent)
{
// WHAT???
m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!");
return;
}
m_perfMonMS = Util.EnvironmentTickCount();
Rotation = rotation;
Vector3 direc = vec * rotation;
Vector3 direc = vec * Rotation;
direc.Normalize();
direc *= 0.03f * 128f * m_speedModifier;
@ -2513,13 +2506,7 @@ namespace OpenSim.Region.Framework.Scenes
// We have an appearance but we may not have the baked textures. Check the asset cache
// to see if all the baked textures are already here.
if (m_scene.AvatarFactory != null)
{
cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient);
}
else
{
m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name);
}
// If we aren't using a cached appearance, then clear out the baked textures
if (!cachedappearance)

View File

@ -41,7 +41,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestCross()
{
TestHelper.InMethod();
TestHelpers.InMethod();
List<Border> testborders = new List<Border>();
@ -99,7 +99,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestCrossSquare512()
{
TestHelper.InMethod();
TestHelpers.InMethod();
List<Border> testborders = new List<Border>();
@ -179,7 +179,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestCrossRectangle512x256()
{
TestHelper.InMethod();
TestHelpers.InMethod();
List<Border> testborders = new List<Border>();
@ -259,7 +259,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestCrossOdd512x512w256hole()
{
TestHelper.InMethod();
TestHelpers.InMethod();
List<Border> testborders = new List<Border>();
// 512____

View File

@ -45,12 +45,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
{
static public Random random;
SceneObjectGroup found;
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
[Test]
public void T010_AddObjects()
{
TestHelper.InMethod();
TestHelpers.InMethod();
random = new Random();
SceneObjectGroup found;
@ -85,7 +85,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void T011_ThreadAddRemoveTest()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// This test adds and removes with mutiple threads, attempting to break the
// uuid and localid dictionary coherence.

View File

@ -43,8 +43,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestDuplicateObject()
{
TestHelper.InMethod();
Scene scene = SceneSetupHelpers.SetupScene();
TestHelpers.InMethod();
Scene scene = SceneHelpers.SetupScene();
UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010");
string part1Name = "part1";

View File

@ -49,9 +49,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestAddSceneObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
string objName = "obj1";
UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001");
@ -76,9 +76,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
/// </summary>
public void TestAddExistingSceneObjectUuid()
{
TestHelper.InMethod();
TestHelpers.InMethod();
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
string obj1Name = "Alfred";
string obj2Name = "Betty";
@ -110,10 +110,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestDeleteSceneObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
TestScene scene = SceneSetupHelpers.SetupScene();
SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
TestScene scene = SceneHelpers.SetupScene();
SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
scene.DeleteSceneObject(part.ParentGroup, false);
SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
@ -126,20 +126,20 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestDeleteSceneObjectAsync()
{
TestHelper.InMethod();
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
TestScene scene = SceneSetupHelpers.SetupScene();
TestScene scene = SceneHelpers.SetupScene();
// Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
sogd.Enabled = false;
SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
IClientAPI client = SceneSetupHelpers.AddClient(scene, agentId);
IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
scene.DeRezObjects(client, new System.Collections.Generic.List<uint>() { part.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero);
SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);

View File

@ -56,17 +56,17 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestDeRezSceneObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
TestScene scene = SceneSetupHelpers.SetupScene();
TestScene scene = SceneHelpers.SetupScene();
IConfigSource configSource = new IniConfigSource();
IConfig config = configSource.AddConfig("Startup");
config.Set("serverside_object_permissions", true);
SceneSetupHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
TestClient client = SceneSetupHelpers.AddClient(scene, userId);
SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
// Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
@ -94,18 +94,18 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestDeRezSceneObjectNotOwner()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001");
TestScene scene = SceneSetupHelpers.SetupScene();
TestScene scene = SceneHelpers.SetupScene();
IConfigSource configSource = new IniConfigSource();
IConfig config = configSource.AddConfig("Startup");
config.Set("serverside_object_permissions", true);
SceneSetupHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
TestClient client = SceneSetupHelpers.AddClient(scene, userId);
SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
// Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;

View File

@ -50,14 +50,14 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestLinkDelink2SceneObjects()
{
TestHelper.InMethod();
TestHelpers.InMethod();
bool debugtest = false;
Scene scene = SceneSetupHelpers.SetupScene();
SceneObjectPart part1 = SceneSetupHelpers.AddSceneObject(scene);
Scene scene = SceneHelpers.SetupScene();
SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene);
SceneObjectGroup grp1 = part1.ParentGroup;
SceneObjectPart part2 = SceneSetupHelpers.AddSceneObject(scene);
SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene);
SceneObjectGroup grp2 = part2.ParentGroup;
grp1.AbsolutePosition = new Vector3(10, 10, 10);
@ -132,18 +132,18 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestLinkDelink2groups4SceneObjects()
{
TestHelper.InMethod();
TestHelpers.InMethod();
bool debugtest = false;
Scene scene = SceneSetupHelpers.SetupScene();
SceneObjectPart part1 = SceneSetupHelpers.AddSceneObject(scene);
Scene scene = SceneHelpers.SetupScene();
SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene);
SceneObjectGroup grp1 = part1.ParentGroup;
SceneObjectPart part2 = SceneSetupHelpers.AddSceneObject(scene);
SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene);
SceneObjectGroup grp2 = part2.ParentGroup;
SceneObjectPart part3 = SceneSetupHelpers.AddSceneObject(scene);
SceneObjectPart part3 = SceneHelpers.AddSceneObject(scene);
SceneObjectGroup grp3 = part3.ParentGroup;
SceneObjectPart part4 = SceneSetupHelpers.AddSceneObject(scene);
SceneObjectPart part4 = SceneHelpers.AddSceneObject(scene);
SceneObjectGroup grp4 = part4.ParentGroup;
grp1.AbsolutePosition = new Vector3(10, 10, 10);
@ -266,10 +266,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestNewSceneObjectLinkPersistence()
{
TestHelper.InMethod();
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
TestScene scene = SceneSetupHelpers.SetupScene();
TestScene scene = SceneHelpers.SetupScene();
string rootPartName = "rootpart";
UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");
@ -305,10 +305,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestDelinkPersistence()
{
TestHelper.InMethod();
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
TestScene scene = SceneSetupHelpers.SetupScene();
TestScene scene = SceneHelpers.SetupScene();
string rootPartName = "rootpart";
UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");

View File

@ -49,11 +49,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestResizeSceneObject()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
SceneObjectGroup g1 = SceneSetupHelpers.AddSceneObject(scene).ParentGroup;
Scene scene = SceneHelpers.SetupScene();
SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene).ParentGroup;
g1.GroupResize(new Vector3(2, 3, 4));
@ -72,12 +72,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestResizeSceneObjectPart()
{
TestHelper.InMethod();
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
SceneObjectGroup g1 = SceneSetupHelpers.CreateSceneObject(2, UUID.Zero);
SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(2, UUID.Zero);
g1.RootPart.Scale = new Vector3(2, 3, 4);
g1.Parts[1].Scale = new Vector3(5, 6, 7);

View File

@ -0,0 +1,66 @@
/*
* 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;
using System.Reflection;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.Framework.Scenes.Tests
{
/// <summary>
/// Basic scene object status tests
/// </summary>
[TestFixture]
public class SceneObjectStatusTests
{
[Test]
public void TestSetPhantom()
{
TestHelpers.InMethod();
// Scene scene = SceneSetupHelpers.SetupScene();
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero);
SceneObjectPart rootPart = so.RootPart;
Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
so.ScriptSetPhantomStatus(true);
// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
so.ScriptSetPhantomStatus(false);
Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
}
}
}

View File

@ -53,12 +53,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestShareWithGroup()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
TestScene scene = SceneSetupHelpers.SetupScene();
TestScene scene = SceneHelpers.SetupScene();
IConfigSource configSource = new IniConfigSource();
IConfig startupConfig = configSource.AddConfig("Startup");
@ -69,13 +69,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
groupsConfig.Set("Module", "GroupsModule");
groupsConfig.Set("DebugEnabled", true);
SceneSetupHelpers.SetupSceneModules(
SceneHelpers.SetupSceneModules(
scene, configSource, new object[]
{ new PermissionsModule(),
new GroupsModule(),
new MockGroupsServicesConnector() });
TestClient client = SceneSetupHelpers.AddClient(scene, userId);
IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
IGroupsModule groupsModule = scene.RequestModuleInterface<IGroupsModule>();

View File

@ -51,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
/// Scene presence tests
/// </summary>
[TestFixture]
public class ScenePresenceTests
public class ScenePresenceAgentTests
{
public Scene scene, scene2, scene3;
public UUID agent1, agent2, agent3;
@ -64,90 +64,140 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[TestFixtureSetUp]
public void Init()
{
TestHelper.InMethod();
TestHelpers.InMethod();
scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000);
scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
scene2 = SceneHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
scene3 = SceneHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000);
ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
interregionComms.Initialise(new IniConfigSource());
interregionComms.PostInitialise();
SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
SceneSetupHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms);
SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
SceneHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms);
agent1 = UUID.Random();
agent2 = UUID.Random();
agent3 = UUID.Random();
random = new Random();
sog1 = NewSOG(UUID.Random(), scene, agent1);
sog2 = NewSOG(UUID.Random(), scene, agent1);
sog3 = NewSOG(UUID.Random(), scene, agent1);
sog1 = SceneHelpers.CreateSceneObject(1, agent1);
scene.AddSceneObject(sog1);
sog2 = SceneHelpers.CreateSceneObject(1, agent1);
scene.AddSceneObject(sog2);
sog3 = SceneHelpers.CreateSceneObject(1, agent1);
scene.AddSceneObject(sog3);
//ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
region1 = scene.RegionInfo.RegionHandle;
region2 = scene2.RegionInfo.RegionHandle;
region3 = scene3.RegionInfo.RegionHandle;
}
/// <summary>
/// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene.
/// </summary>
[Test]
public void T010_TestAddRootAgent()
public void TestCloseAgent()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
string firstName = "testfirstname";
TestScene scene = SceneHelpers.SetupScene();
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
AgentCircuitData agent = new AgentCircuitData();
agent.AgentID = agent1;
agent.firstname = firstName;
agent.lastname = "testlastname";
agent.SessionID = UUID.Random();
agent.SecureSessionID = UUID.Random();
agent.circuitcode = 123;
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
agent.startpos = Vector3.Zero;
agent.CapsPath = GetRandomCapsObjectPath();
agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
agent.child = true;
Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null);
scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
scene.IncomingCloseAgent(sp.UUID);
string reason;
scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
testclient = new TestClient(agent, scene);
scene.AddNewClient(testclient);
ScenePresence presence = scene.GetScenePresence(agent1);
Assert.That(presence, Is.Not.Null, "presence is null");
Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same");
acd1 = agent;
Assert.That(scene.GetScenePresence(sp.UUID), Is.Null);
Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null);
}
/// <summary>
/// Test removing an uncrossed root agent from a scene.
/// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region
/// </summary>
/// <remarks>
/// Please note that unlike the other tests here, this doesn't rely on structures
/// </remarks>
[Test]
public void T011_TestRemoveRootAgent()
public void TestChildAgentEstablished()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
scene.RemoveClient(agent1);
UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
ScenePresence presence = scene.GetScenePresence(agent1);
TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
// TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
Assert.That(presence, Is.Null, "presence is not null");
IConfigSource configSource = new IniConfigSource();
configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule");
EntityTransferModule etm = new EntityTransferModule();
SceneHelpers.SetupSceneModules(myScene1, configSource, etm);
SceneHelpers.AddScenePresence(myScene1, agent1Id);
// ScenePresence childPresence = myScene2.GetScenePresence(agent1);
// TODO: Need to do a fair amount of work to allow synchronous establishment of child agents
// Assert.That(childPresence, Is.Not.Null);
// Assert.That(childPresence.IsChildAgent, Is.True);
}
// /// <summary>
// /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene.
// /// </summary>
// [Test]
// public void T010_TestAddRootAgent()
// {
// TestHelpers.InMethod();
//
// string firstName = "testfirstname";
//
// AgentCircuitData agent = new AgentCircuitData();
// agent.AgentID = agent1;
// agent.firstname = firstName;
// agent.lastname = "testlastname";
// agent.SessionID = UUID.Random();
// agent.SecureSessionID = UUID.Random();
// agent.circuitcode = 123;
// agent.BaseFolder = UUID.Zero;
// agent.InventoryFolder = UUID.Zero;
// agent.startpos = Vector3.Zero;
// agent.CapsPath = GetRandomCapsObjectPath();
// agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
// agent.child = true;
//
// scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
//
// string reason;
// scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
// testclient = new TestClient(agent, scene);
// scene.AddNewClient(testclient);
//
// ScenePresence presence = scene.GetScenePresence(agent1);
//
// Assert.That(presence, Is.Not.Null, "presence is null");
// Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same");
// acd1 = agent;
// }
//
// /// <summary>
// /// Test removing an uncrossed root agent from a scene.
// /// </summary>
// [Test]
// public void T011_TestRemoveRootAgent()
// {
// TestHelpers.InMethod();
//
// scene.RemoveClient(agent1);
//
// ScenePresence presence = scene.GetScenePresence(agent1);
//
// Assert.That(presence, Is.Null, "presence is not null");
// }
[Test]
public void T012_TestAddNeighbourRegion()
{
TestHelper.InMethod();
TestHelpers.InMethod();
string reason;
@ -157,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
scene.NewUserConnection(acd1, 0, out reason);
if (testclient == null)
testclient = new TestClient(acd1, scene);
scene.AddNewClient(testclient);
scene.AddNewClient(testclient, PresenceType.User);
ScenePresence presence = scene.GetScenePresence(agent1);
presence.MakeRootAgent(new Vector3(90,90,90),false);
@ -175,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void T013_TestRemoveNeighbourRegion()
{
TestHelper.InMethod();
TestHelpers.InMethod();
ScenePresence presence = scene.GetScenePresence(agent1);
presence.RemoveNeighbourRegion(region3);
@ -189,37 +239,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
*/
}
/// <summary>
/// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region
/// </summary>
/// <remarks>
/// Please note that unlike the other tests here, this doesn't rely on structures
/// </remarks>
[Test]
public void TestChildAgentEstablished()
{
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
TestScene myScene1 = SceneSetupHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
TestScene myScene2 = SceneSetupHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
IConfigSource configSource = new IniConfigSource();
configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule");
EntityTransferModule etm = new EntityTransferModule();
SceneSetupHelpers.SetupSceneModules(myScene1, configSource, etm);
SceneSetupHelpers.AddClient(myScene1, agent1Id);
ScenePresence childPresence = myScene2.GetScenePresence(agent1);
// TODO: Need to do a fair amount of work to allow synchronous establishment of child agents
// Assert.That(childPresence, Is.Not.Null);
// Assert.That(childPresence.IsChildAgent, Is.True);
}
// I'm commenting this test because it does not represent
// crossings. The Thread.Sleep's in here are not meaningful mocks,
// and they sometimes fail in panda.
@ -230,7 +249,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
//[Test]
public void T021_TestCrossToNewRegion()
{
TestHelper.InMethod();
TestHelpers.InMethod();
scene.RegisterRegionWithGrid();
scene2.RegisterRegionWithGrid();
@ -238,7 +257,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
// Adding child agent to region 1001
string reason;
scene2.NewUserConnection(acd1,0, out reason);
scene2.AddNewClient(testclient);
scene2.AddNewClient(testclient, PresenceType.User);
ScenePresence presence = scene.GetScenePresence(agent1);
presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true);
@ -349,37 +368,5 @@ namespace OpenSim.Region.Framework.Scenes.Tests
capsPath = capsPath.Remove(capsPath.Length - 4, 4);
return capsPath;
}
private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent)
{
SceneObjectPart sop = new SceneObjectPart();
sop.Name = RandomName();
sop.Description = RandomName();
sop.Text = RandomName();
sop.SitName = RandomName();
sop.TouchName = RandomName();
sop.UUID = uuid;
sop.Shape = PrimitiveBaseShape.Default;
sop.Shape.State = 1;
sop.OwnerID = agent;
SceneObjectGroup sog = new SceneObjectGroup(sop);
sog.SetScene(scene);
return sog;
}
private static string RandomName()
{
StringBuilder name = new StringBuilder();
int size = random.Next(5,12);
char ch ;
for (int i=0; i<size; i++)
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
name.Append(ch);
}
return name.ToString();
}
}
}

View File

@ -44,7 +44,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
/// Teleport tests in a standalone OpenSim
/// </summary>
[TestFixture]
public class StandaloneTeleportTests
public class ScenePresenceTeleportTests
{
/// <summary>
/// Test a teleport between two regions that are not neighbours and do not share any neighbours in common.
@ -54,7 +54,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
//[Test, LongRunning]
public void TestSimpleNotNeighboursTeleport()
{
TestHelper.InMethod();
TestHelpers.InMethod();
ThreadRunResults results = new ThreadRunResults();
results.Result = false;
results.Message = "Test did not run";
@ -116,16 +116,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests
ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010);
SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms);
Scene sceneB = SceneHelpers.SetupScene("sceneB", sceneBId, 1010, 1010);
SceneHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms);
sceneB.RegisterRegionWithGrid();
Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000);
SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
Scene sceneA = SceneHelpers.SetupScene("sceneA", sceneAId, 1000, 1000);
SceneHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
sceneA.RegisterRegionWithGrid();
UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041");
TestClient client = SceneSetupHelpers.AddClient(sceneA, agentId);
TestClient client = (TestClient)SceneHelpers.AddScenePresence(sceneA, agentId).ControllingClient;
ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface<ICapabilitiesModule>();

View File

@ -58,9 +58,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestUpdateScene()
{
TestHelper.InMethod();
TestHelpers.InMethod();
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
scene.Update();
Assert.That(scene.Frame, Is.EqualTo(1));

View File

@ -55,12 +55,12 @@ namespace OpenSim.Region.Framework.Tests
[Test]
public void TestRezObjectFromInventoryItem()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID);
SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
SceneObjectPart sop1 = sog1.RootPart;
// Create an object embedded inside the first
@ -98,12 +98,12 @@ namespace OpenSim.Region.Framework.Tests
[Test]
public void TestMoveTaskInventoryItem()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID);
SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
SceneObjectPart sop1 = sog1.RootPart;
TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1);
@ -125,12 +125,12 @@ namespace OpenSim.Region.Framework.Tests
[Test]
public void TestMoveTaskInventoryItemNoParent()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID);
SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
SceneObjectPart sop1 = sog1.RootPart;
TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1);

View File

@ -55,12 +55,12 @@ namespace OpenSim.Region.Framework.Tests
[Test]
public void TestGiveInventoryItem()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, 1001);
UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, 1002);
Scene scene = SceneHelpers.SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID);
scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID);
@ -82,12 +82,12 @@ namespace OpenSim.Region.Framework.Tests
[Test]
public void TestGiveInventoryFolder()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, 1001);
UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, 1002);
Scene scene = SceneHelpers.SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
InventoryFolderBase folder1
= UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1");

View File

@ -47,7 +47,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
public void Init()
{
// FIXME: We don't need a full scene here - it would be enough to set up the asset service.
Scene scene = SceneSetupHelpers.SetupScene();
Scene scene = SceneHelpers.SetupScene();
m_assetService = scene.AssetService;
m_uuidGatherer = new UuidGatherer(m_assetService);
}
@ -55,7 +55,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestCorruptAsset()
{
TestHelper.InMethod();
TestHelpers.InMethod();
UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
AssetBase corruptAsset
@ -75,7 +75,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void TestMissingAsset()
{
TestHelper.InMethod();
TestHelpers.InMethod();
UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();

View File

@ -677,7 +677,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public event DeRezObject OnDeRezObject;
public event Action<IClientAPI> OnRegionHandShakeReply;
public event GenericCall1 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit;
@ -806,7 +806,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public event ScriptReset OnScriptReset;
public event GetScriptRunning OnGetScriptRunning;
public event SetScriptRunning OnSetScriptRunning;
public event Action<Vector3> OnAutoPilotGo;
public event Action<Vector3, bool> OnAutoPilotGo;
public event TerrainUnacked OnUnackedTerrain;
public event ActivateGesture OnActivateGesture;
public event DeactivateGesture OnDeactivateGesture;
@ -893,7 +893,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public void Start()
{
Scene.AddNewClient(this);
Scene.AddNewClient(this, PresenceType.User);
// Mimicking LLClientView which gets always set appearance from client.
Scene scene = (Scene)Scene;
@ -913,7 +913,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
if (OnCompleteMovementToRegion != null)
{
OnCompleteMovementToRegion(this);
OnCompleteMovementToRegion(this, true);
}
}

View File

@ -47,16 +47,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
[Test]
public void TestBasic()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
TestScene scene = SceneSetupHelpers.SetupScene();
TestScene scene = SceneHelpers.SetupScene();
IConfigSource configSource = new IniConfigSource();
IConfig config = configSource.AddConfig("Groups");
config.Set("Enabled", true);
config.Set("Module", "GroupsModule");
config.Set("DebugEnabled", true);
SceneSetupHelpers.SetupSceneModules(
SceneHelpers.SetupSceneModules(
scene, configSource, new object[] { new MockGroupsServicesConnector() });
}
}

View File

@ -126,6 +126,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded;
if(m_uri != string.Empty)
{
RRAlert("shutdown");
}
m_scene = null;
}

View File

@ -37,6 +37,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{
public class NPCAvatar : IClientAPI
{
/// <summary>
/// Signal whether the avatar should land when it reaches a move target
/// </summary>
public bool LandAtTarget { get; set; }
private readonly string m_firstname;
private readonly string m_lastname;
private readonly Vector3 m_startPos;
@ -190,7 +195,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public event DeRezObject OnDeRezObject;
public event Action<IClientAPI> OnRegionHandShakeReply;
public event GenericCall1 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit;
@ -328,7 +333,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public event ScriptReset OnScriptReset;
public event GetScriptRunning OnGetScriptRunning;
public event SetScriptRunning OnSetScriptRunning;
public event Action<Vector3> OnAutoPilotGo;
public event Action<Vector3, bool> OnAutoPilotGo;
public event TerrainUnacked OnUnackedTerrain;
@ -745,12 +750,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{
OnRegionHandShakeReply(this);
}
if (OnCompleteMovementToRegion != null)
{
OnCompleteMovementToRegion(this);
}
}
public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
{
}
@ -841,6 +842,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public void Close()
{
// Remove ourselves from the scene
m_scene.RemoveClient(AgentId, false);
}
public void Start()

View File

@ -45,7 +45,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
private Dictionary<UUID, AvatarAppearance> m_appearanceCache = new Dictionary<UUID, AvatarAppearance>();
public void Initialise(Scene scene, IConfigSource source)
{
@ -75,35 +74,44 @@ namespace OpenSim.Region.OptionalModules.World.NPC
// We are close enough to the target
m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name);
if (presence.PhysicsActor.Flying)
{
Vector3 targetPos = presence.MoveToPositionTarget;
float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
if (targetPos.Z - terrainHeight < 0.2)
{
presence.PhysicsActor.Flying = false;
}
}
presence.Velocity = Vector3.Zero;
presence.AbsolutePosition = presence.MoveToPositionTarget;
presence.ResetMoveToTarget();
// FIXME: This doesn't work
if (presence.PhysicsActor.Flying)
presence.Animator.TrySetMovementAnimation("HOVER");
else
presence.Animator.TrySetMovementAnimation("STAND");
{
// A horrible hack to stop the NPC dead in its tracks rather than having them overshoot
// the target if flying.
// We really need to be more subtle (slow the avatar as it approaches the target) or at
// least be able to set collision status once, rather than 5 times to give it enough
// weighting so that that PhysicsActor thinks it really is colliding.
for (int i = 0; i < 5; i++)
presence.PhysicsActor.IsColliding = true;
// Vector3 targetPos = presence.MoveToPositionTarget;
if (m_avatars[presence.UUID].LandAtTarget)
presence.PhysicsActor.Flying = false;
// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
// if (targetPos.Z - terrainHeight < 0.2)
// {
// presence.PhysicsActor.Flying = false;
// }
}
// m_log.DebugFormat(
// "[NPC MODULE]: AgentControlFlags {0}, MovementFlag {1} for {2}",
// presence.AgentControlFlags, presence.MovementFlag, presence.Name);
}
else
{
m_log.DebugFormat(
"[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}",
presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget);
// m_log.DebugFormat(
// "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}",
// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget);
Vector3 agent_control_v3 = new Vector3();
presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation);
presence.AddNewMovement(agent_control_v3, presence.Rotation);
presence.HandleMoveToTargetUpdate(ref agent_control_v3);
presence.AddNewMovement(agent_control_v3);
}
//
//// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null);
@ -115,29 +123,48 @@ namespace OpenSim.Region.OptionalModules.World.NPC
}
}
private AvatarAppearance GetAppearance(UUID target, Scene scene)
public bool IsNPC(UUID agentId, Scene scene)
{
if (m_appearanceCache.ContainsKey(target))
return m_appearanceCache[target];
ScenePresence sp = scene.GetScenePresence(agentId);
if (sp == null || sp.IsChildAgent)
return false;
ScenePresence originalPresence = scene.GetScenePresence(target);
if (originalPresence != null)
{
AvatarAppearance originalAppearance = originalPresence.Appearance;
m_appearanceCache.Add(target, originalAppearance);
return originalAppearance;
}
else
{
m_log.DebugFormat(
"[NPC MODULE]: Avatar {0} is not in the scene for us to grab baked textures from them. Using defaults.", target);
return new AvatarAppearance();
}
lock (m_avatars)
return m_avatars.ContainsKey(agentId);
}
public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom)
public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene)
{
ScenePresence sp = scene.GetScenePresence(agentId);
if (sp == null || sp.IsChildAgent)
return false;
lock (m_avatars)
if (!m_avatars.ContainsKey(agentId))
return false;
// FIXME: An extremely bad bit of code that reaches directly into the attachments list and manipulates it
List<SceneObjectGroup> attachments = sp.Attachments;
lock (attachments)
{
foreach (SceneObjectGroup att in attachments)
scene.DeleteSceneObject(att, false);
attachments.Clear();
}
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
sp.Appearance = npcAppearance;
sp.RezAttachments();
IAvatarFactory module = scene.RequestModuleInterface<IAvatarFactory>();
module.SendAppearance(sp.UUID);
return true;
}
public UUID CreateNPC(
string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance)
{
NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene);
npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
@ -152,8 +179,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
acd.lastname = lastname;
acd.ServiceURLs = new Dictionary<string, object>();
AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene);
AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true);
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
acd.Appearance = npcAppearance;
// for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++)
@ -164,7 +190,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
// }
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
scene.AddNewClient(npcAvatar);
scene.AddNewClient(npcAvatar, PresenceType.Npc);
ScenePresence sp;
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
@ -172,13 +198,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
m_log.DebugFormat(
"[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
// Shouldn't call this - temporary.
sp.CompleteMovement(npcAvatar);
// sp.SendAppearanceToAllOtherAgents();
//
// // Send animations back to the avatar as well
// sp.Animator.SendAnimPack();
sp.CompleteMovement(npcAvatar, false);
}
else
{
@ -193,7 +213,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return npcAvatar.AgentId;
}
public void MoveToTarget(UUID agentID, Scene scene, Vector3 pos)
public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget)
{
lock (m_avatars)
{
@ -203,34 +223,70 @@ namespace OpenSim.Region.OptionalModules.World.NPC
scene.TryGetScenePresence(agentID, out sp);
m_log.DebugFormat(
"[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName);
"[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget);
sp.MoveToTarget(pos);
m_avatars[agentID].LandAtTarget = landAtTarget;
sp.MoveToTarget(pos, noFly);
return true;
}
}
return false;
}
public void Say(UUID agentID, Scene scene, string text)
public bool StopMoveToTarget(UUID agentID, Scene scene)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
scene.TryGetScenePresence(agentID, out sp);
sp.Velocity = Vector3.Zero;
sp.ResetMoveToTarget();
return true;
}
}
return false;
}
public bool Say(UUID agentID, Scene scene, string text)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
scene.TryGetScenePresence(agentID, out sp);
m_avatars[agentID].Say(text);
return true;
}
}
return false;
}
public void DeleteNPC(UUID agentID, Scene scene)
public bool DeleteNPC(UUID agentID, Scene scene)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
scene.RemoveClient(agentID);
scene.RemoveClient(agentID, false);
m_avatars.Remove(agentID);
return true;
}
}
return false;
}
public void PostInitialise()

View File

@ -34,6 +34,7 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
using OpenSim.Region.CoreModules.Framework.UserManagement;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@ -49,7 +50,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
[Test]
public void TestCreate()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
IConfigSource config = new IniConfigSource();
@ -57,13 +58,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
config.Configs["NPC"].Set("Enabled", "true");
AvatarFactoryModule afm = new AvatarFactoryModule();
TestScene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule());
TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1));
UserManagementModule umm = new UserManagementModule();
TestScene scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, config, afm, umm, new NPCModule());
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
// 8 is the index of the first baked texture in AvatarAppearance
UUID originalFace8TextureId = TestHelper.ParseTail(0x10);
UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
originalTef.TextureID = originalFace8TextureId;
@ -72,21 +75,22 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
// ScenePresence.SendInitialData() to reset our entire appearance.
scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId));
afm.SetAppearance(originalClient, originalTe, null);
afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId);
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);
ScenePresence npc = scene.GetScenePresence(npcId);
Assert.That(npc, Is.Not.Null);
Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
}
[Test]
public void TestMove()
{
TestHelper.InMethod();
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
IConfigSource config = new IniConfigSource();
@ -94,14 +98,14 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
config.AddConfig("NPC");
config.Configs["NPC"].Set("Enabled", "true");
TestScene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, config, new NPCModule());
TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1));
TestScene scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, config, new NPCModule());
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
Vector3 startPos = new Vector3(128, 128, 30);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, originalClient.AgentId);
UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance);
ScenePresence npc = scene.GetScenePresence(npcId);
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
@ -113,7 +117,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
Vector3 targetPos = startPos + new Vector3(0, 0, 10);
npcModule.MoveToTarget(npc.UUID, scene, targetPos);
npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false);
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
@ -131,11 +135,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move");
Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE));
// Try a second movement
startPos = npc.AbsolutePosition;
targetPos = startPos + new Vector3(10, 0, 0);
npcModule.MoveToTarget(npc.UUID, scene, targetPos);
npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false);
scene.Update();

View File

@ -258,7 +258,11 @@ namespace OpenSim.Region.Physics.OdePlugin
public override bool Flying
{
get { return flying; }
set { flying = value; }
set
{
flying = value;
// m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying);
}
}
/// <summary>
@ -305,10 +309,12 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_iscolliding = true;
}
if (m_wascolliding != m_iscolliding)
{
//base.SendCollisionUpdate(new CollisionEventUpdate());
}
m_wascolliding = m_iscolliding;
}
}

View File

@ -369,7 +369,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// convert a LSL_Rotation to a Quaternion
protected Quaternion Rot2Quaternion(LSL_Rotation r)
public static Quaternion Rot2Quaternion(LSL_Rotation r)
{
Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
q.Normalize();
@ -1204,10 +1204,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((status & ScriptBaseClass.STATUS_PHANTOM) == ScriptBaseClass.STATUS_PHANTOM)
{
if (value != 0)
m_host.ScriptSetPhantomStatus(true);
else
m_host.ScriptSetPhantomStatus(false);
if (m_host.ParentGroup != null)
m_host.ParentGroup.ScriptSetPhantomStatus(value != 0);
}
if ((status & ScriptBaseClass.STATUS_CAST_SHADOWS) == ScriptBaseClass.STATUS_CAST_SHADOWS)
@ -2063,6 +2061,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
return llGetRootRotation();
}
m_host.AddScriptLPS(1);
Quaternion q = m_host.GetWorldRotation();
return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
@ -6446,9 +6445,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (m_host.ParentGroup != null)
{
if (!m_host.ParentGroup.IsDeleted)
{
m_host.ParentGroup.RootPart.ScriptSetVolumeDetect(detect!=0);
}
m_host.ParentGroup.ScriptSetVolumeDetect(detect != 0);
}
}
@ -6456,7 +6453,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// This is a depecated function so this just replicates the result of
/// invoking it in SL
/// </summary>
public void llRemoteLoadScript(string target, string name, int running, int start_param)
{
m_host.AddScriptLPS(1);
@ -7254,14 +7250,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
string ph = rules.Data[idx++].ToString();
bool phantom;
if (ph.Equals("1"))
phantom = true;
else
phantom = false;
if (m_host.ParentGroup != null)
m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1"));
part.ScriptSetPhantomStatus(phantom);
break;
case (int)ScriptBaseClass.PRIM_PHYSICS:
@ -7282,14 +7274,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (remain < 1)
return;
string temp = rules.Data[idx++].ToString();
bool tempOnRez;
if (temp.Equals("1"))
tempOnRez = true;
else
tempOnRez = false;
if (m_host.ParentGroup != null)
m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1"));
part.ScriptSetTemporaryStatus(tempOnRez);
break;
case (int)ScriptBaseClass.PRIM_TEXGEN:
@ -7662,7 +7650,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case ScriptBaseClass.PRIM_TYPE_BOX:
case ScriptBaseClass.PRIM_TYPE_CYLINDER:
case ScriptBaseClass.PRIM_TYPE_PRISM:
res.Add(new LSL_Integer(Shape.ProfileCurve));
res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
@ -7671,7 +7659,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
case ScriptBaseClass.PRIM_TYPE_SPHERE:
res.Add(new LSL_Integer(Shape.ProfileCurve));
res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
@ -7687,7 +7675,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case ScriptBaseClass.PRIM_TYPE_TUBE:
case ScriptBaseClass.PRIM_TYPE_TORUS:
// holeshape
res.Add(new LSL_Integer(Shape.ProfileCurve));
res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
// cut
res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
@ -10578,9 +10566,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
public static string GetLine(UUID assetID, int line, int maxLength)
/// <summary>
/// Get a notecard line.
/// </summary>
/// <param name="assetID"></param>
/// <param name="line">Lines start at index 0</param>
/// <returns></returns>
public static string GetLine(UUID assetID, int lineNumber)
{
if (line < 0)
if (lineNumber < 0)
return "";
string data;
@ -10592,17 +10586,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_Notecards[assetID].lastRef = DateTime.Now;
if (line >= m_Notecards[assetID].text.Length)
if (lineNumber >= m_Notecards[assetID].text.Length)
return "\n\n\n";
data = m_Notecards[assetID].text[line];
if (data.Length > maxLength)
data = data.Substring(0, maxLength);
data = m_Notecards[assetID].text[lineNumber];
return data;
}
}
/// <summary>
/// Get a notecard line.
/// </summary>
/// <param name="assetID"></param>
/// <param name="line">Lines start at index 0</param>
/// <param name="maxLength">Maximum length of the returned line. Longer lines will be truncated</para>
/// <returns></returns>
public static string GetLine(UUID assetID, int lineNumber, int maxLength)
{
string line = GetLine(assetID, lineNumber);
if (line.Length > maxLength)
line = line.Substring(0, maxLength);
return line;
}
public static void CacheCheck()
{
foreach (UUID key in new List<UUID>(m_Notecards.Keys))

View File

@ -28,11 +28,16 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.Remoting.Lifetime;
using System.Text;
using System.Net;
using System.Threading;
using System.Xml;
using log4net;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using Nini.Config;
using OpenSim;
using OpenSim.Framework;
@ -119,6 +124,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
[Serializable]
public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
internal IScriptEngine m_ScriptEngine;
internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there
internal SceneObjectPart m_host;
@ -348,20 +355,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
System.Threading.Thread.Sleep(delay);
}
//
// OpenSim functions
//
public LSL_Integer osSetTerrainHeight(int x, int y, double val)
{
CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight");
return SetTerrainHeight(x, y, val);
}
public LSL_Integer osTerrainSetHeight(int x, int y, double val)
{
CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight");
OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight");
return SetTerrainHeight(x, y, val);
}
private LSL_Integer SetTerrainHeight(int x, int y, double val)
{
m_host.AddScriptLPS(1);
@ -384,12 +390,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight");
return GetTerrainHeight(x, y);
}
public LSL_Float osTerrainGetHeight(int x, int y)
{
CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight");
OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight");
return GetTerrainHeight(x, y);
}
private LSL_Float GetTerrainHeight(int x, int y)
{
m_host.AddScriptLPS(1);
@ -862,7 +870,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence target = (ScenePresence)World.Entities[avatarID];
if (target != null)
{
UUID animID=UUID.Zero;
UUID animID = UUID.Zero;
lock (m_host.TaskInventory)
{
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
@ -1021,6 +1029,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
drawList += "PenColor " + color + "; ";
return drawList;
}
// Deprecated
public string osSetPenColour(string drawList, string colour)
{
@ -1182,11 +1191,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
OSSLDeprecated("osSunGetParam", "osGetSunParam");
return GetSunParam(param);
}
public double osGetSunParam(string param)
{
CheckThreatLevel(ThreatLevel.None, "osGetSunParam");
return GetSunParam(param);
}
private double GetSunParam(string param)
{
m_host.AddScriptLPS(1);
@ -1208,11 +1219,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
OSSLDeprecated("osSunSetParam", "osSetSunParam");
SetSunParam(param, value);
}
public void osSetSunParam(string param, double value)
{
CheckThreatLevel(ThreatLevel.None, "osSetSunParam");
SetSunParam(param, value);
}
private void SetSunParam(string param, double value)
{
m_host.AddScriptLPS(1);
@ -1222,10 +1235,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
module.SetSunParameter(param, value);
}
}
public string osWindActiveModelPluginName()
{
CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName");
@ -1304,12 +1315,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
OSSLDeprecated(functionName, "osSetParcelDetails");
SetParcelDetails(pos, rules, functionName);
}
public void osSetParcelDetails(LSL_Vector pos, LSL_List rules)
{
const string functionName = "osSetParcelDetails";
CheckThreatLevel(ThreatLevel.High, functionName);
SetParcelDetails(pos, rules, functionName);
}
private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName)
{
m_host.AddScriptLPS(1);
@ -1429,8 +1442,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID);
else
OSSLError("osSetParcelSIPAddress: No voice module enabled for this land");
}
public string osGetScriptEngineName()
@ -1683,8 +1694,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return jsondata;
}
// send a message to to object identified by the given UUID, a script in the object must implement the dataserver function
// the dataserver function is passed the ID of the calling function and a string message
/// <summary>
/// Send a message to to object identified by the given UUID
/// </summary>
/// <remarks>
/// A script in the object must implement the dataserver function
/// the dataserver function is passed the ID of the calling function and a string message
/// </remarks>
/// <param name="objectUUID"></param>
/// <param name="message"></param>
public void osMessageObject(LSL_Key objectUUID, string message)
{
CheckThreatLevel(ThreatLevel.Low, "osMessageObject");
@ -1699,34 +1717,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
"dataserver", resobj, new DetectParams[0]));
}
// This needs ThreatLevel high. It is an excellent griefer tool,
// In a loop, it can cause asset bloat and DOS levels of asset
// writes.
//
/// <summary>
/// Write a notecard directly to the prim's inventory.
/// </summary>
/// <remarks>
/// This needs ThreatLevel high. It is an excellent griefer tool,
/// In a loop, it can cause asset bloat and DOS levels of asset
/// writes.
/// </remarks>
/// <param name="notecardName">The name of the notecard to write.</param>
/// <param name="contents">The contents of the notecard.</param>
public void osMakeNotecard(string notecardName, LSL_Types.list contents)
{
CheckThreatLevel(ThreatLevel.High, "osMakeNotecard");
m_host.AddScriptLPS(1);
StringBuilder notecardData = new StringBuilder();
for (int i = 0; i < contents.Length; i++)
notecardData.Append((string)(contents.GetLSLStringItem(i) + "\n"));
SaveNotecard(notecardName, "Script generated notecard", notecardData.ToString(), false);
}
/// <summary>
/// Save a notecard to prim inventory.
/// </summary>
/// <param name="name"></param>
/// <param name="description">Description of notecard</param>
/// <param name="notecardData"></param>
/// <param name="forceSameName">
/// If true, then if an item exists with the same name, it is replaced.
/// If false, then a new item is created witha slightly different name (e.g. name 1)
/// </param>
/// <returns>Prim inventory item created.</returns>
protected TaskInventoryItem SaveNotecard(string name, string description, string data, bool forceSameName)
{
// Create new asset
AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
asset.Description = "Script Generated Notecard";
string notecardData = String.Empty;
AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
asset.Description = description;
for (int i = 0; i < contents.Length; i++) {
notecardData += contents.GetLSLStringItem(i) + "\n";
}
int textLength = data.Length;
data
= "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
+ textLength.ToString() + "\n" + data + "}\n";
int textLength = notecardData.Length;
notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
+ textLength.ToString() + "\n" + notecardData + "}\n";
asset.Data = Util.UTF8.GetBytes(notecardData);
asset.Data = Util.UTF8.GetBytes(data);
World.AssetService.Store(asset);
// Create Task Entry
TaskInventoryItem taskItem=new TaskInventoryItem();
TaskInventoryItem taskItem = new TaskInventoryItem();
taskItem.ResetIDs(m_host.UUID);
taskItem.ParentID = m_host.UUID;
@ -1748,33 +1788,96 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
taskItem.PermsMask = 0;
taskItem.AssetID = asset.FullID;
m_host.Inventory.AddInventoryItem(taskItem, false);
if (forceSameName)
m_host.Inventory.AddInventoryItemExclusive(taskItem, false);
else
m_host.Inventory.AddInventoryItem(taskItem, false);
return taskItem;
}
/// <summary>
/// Load the notecard data found at the given prim inventory item name or asset uuid.
/// </summary>
/// <param name="notecardNameOrUuid"></param>
/// <returns>The text loaded. Null if no notecard was found.</returns>
protected string LoadNotecard(string notecardNameOrUuid)
{
UUID assetID = CacheNotecard(notecardNameOrUuid);
StringBuilder notecardData = new StringBuilder();
/*Instead of using the LSL Dataserver event to pull notecard data,
this will simply read the requested line and return its data as a string.
for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
{
string line = NotecardCache.GetLine(assetID, count) + "\n";
Warning - due to the synchronous method this function uses to fetch assets, its use
may be dangerous and unreliable while running in grid mode.
*/
// m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line);
notecardData.Append(line);
}
return notecardData.ToString();
}
/// <summary>
/// Cache a notecard's contents.
/// </summary>
/// <param name="notecardNameOrUuid"></param>
/// <returns>
/// The asset id of the notecard, which is used for retrieving the cached data.
/// UUID.Zero if no asset could be found.
/// </returns>
protected UUID CacheNotecard(string notecardNameOrUuid)
{
UUID assetID = UUID.Zero;
if (!UUID.TryParse(notecardNameOrUuid, out assetID))
{
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == notecardNameOrUuid)
{
assetID = item.AssetID;
}
}
}
if (assetID == UUID.Zero)
return UUID.Zero;
if (!NotecardCache.IsCached(assetID))
{
AssetBase a = World.AssetService.Get(assetID.ToString());
if (a == null)
return UUID.Zero;
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
string data = enc.GetString(a.Data);
NotecardCache.Cache(assetID, data);
};
return assetID;
}
/// <summary>
/// Directly get an entire notecard at once.
/// </summary>
/// <remarks>
/// Instead of using the LSL Dataserver event to pull notecard data
/// this will simply read the entire notecard and return its data as a string.
///
/// Warning - due to the synchronous method this function uses to fetch assets, its use
/// may be dangerous and unreliable while running in grid mode.
/// </remarks>
/// <param name="name">Name of the notecard or its asset id</param>
/// <param name="line">The line number to read. The first line is line 0</param>
/// <returns>Notecard line</returns>
public string osGetNotecardLine(string name, int line)
{
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine");
m_host.AddScriptLPS(1);
UUID assetID = UUID.Zero;
if (!UUID.TryParse(name, out assetID))
{
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
{
assetID = item.AssetID;
}
}
}
UUID assetID = CacheNotecard(name);
if (assetID == UUID.Zero)
{
@ -1782,109 +1885,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return "ERROR!";
}
if (!NotecardCache.IsCached(assetID))
{
AssetBase a = World.AssetService.Get(assetID.ToString());
if (a != null)
{
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
string data = enc.GetString(a.Data);
NotecardCache.Cache(assetID, data);
}
else
{
OSSLShoutError("Notecard '" + name + "' could not be found.");
return "ERROR!";
}
};
return NotecardCache.GetLine(assetID, line, 255);
return NotecardCache.GetLine(assetID, line);
}
/*Instead of using the LSL Dataserver event to pull notecard data line by line,
this will simply read the entire notecard and return its data as a string.
Warning - due to the synchronous method this function uses to fetch assets, its use
may be dangerous and unreliable while running in grid mode.
*/
/// <summary>
/// Get an entire notecard at once.
/// </summary>
/// <remarks>
/// Instead of using the LSL Dataserver event to pull notecard data line by line,
/// this will simply read the entire notecard and return its data as a string.
///
/// Warning - due to the synchronous method this function uses to fetch assets, its use
/// may be dangerous and unreliable while running in grid mode.
/// </remarks>
/// <param name="name">Name of the notecard or its asset id</param>
/// <returns>Notecard text</returns>
public string osGetNotecard(string name)
{
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard");
m_host.AddScriptLPS(1);
UUID assetID = UUID.Zero;
string NotecardData = "";
string text = LoadNotecard(name);
if (!UUID.TryParse(name, out assetID))
{
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
{
assetID = item.AssetID;
}
}
}
if (assetID == UUID.Zero)
if (text == null)
{
OSSLShoutError("Notecard '" + name + "' could not be found.");
return "ERROR!";
}
if (!NotecardCache.IsCached(assetID))
else
{
AssetBase a = World.AssetService.Get(assetID.ToString());
if (a != null)
{
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
string data = enc.GetString(a.Data);
NotecardCache.Cache(assetID, data);
}
else
{
OSSLShoutError("Notecard '" + name + "' could not be found.");
return "ERROR!";
}
};
for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
{
NotecardData += NotecardCache.GetLine(assetID, count, 255) + "\n";
return text;
}
return NotecardData;
}
/*Instead of using the LSL Dataserver event to pull notecard data,
this will simply read the number of note card lines and return this data as an integer.
Warning - due to the synchronous method this function uses to fetch assets, its use
may be dangerous and unreliable while running in grid mode.
*/
/// <summary>
/// Get the number of lines in the given notecard.
/// </summary>
/// <remarks>
/// Instead of using the LSL Dataserver event to pull notecard data,
/// this will simply read the number of note card lines and return this data as an integer.
///
/// Warning - due to the synchronous method this function uses to fetch assets, its use
/// may be dangerous and unreliable while running in grid mode.
/// </remarks>
/// <param name="name">Name of the notecard or its asset id</param>
/// <returns></returns>
public int osGetNumberOfNotecardLines(string name)
{
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines");
m_host.AddScriptLPS(1);
UUID assetID = UUID.Zero;
if (!UUID.TryParse(name, out assetID))
{
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
{
assetID = item.AssetID;
}
}
}
UUID assetID = CacheNotecard(name);
if (assetID == UUID.Zero)
{
@ -1892,22 +1943,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return -1;
}
if (!NotecardCache.IsCached(assetID))
{
AssetBase a = World.AssetService.Get(assetID.ToString());
if (a != null)
{
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
string data = enc.GetString(a.Data);
NotecardCache.Cache(assetID, data);
}
else
{
OSSLShoutError("Notecard '" + name + "' could not be found.");
return -1;
}
};
return NotecardCache.GetLines(assetID);
}
@ -1947,15 +1982,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
return "";
}
}
/// <summary>
/// Get the nickname of this grid, as set in the [GridInfo] config section.
/// </summary>
/// <remarks>
/// Threat level is Moderate because intentional abuse, for instance
/// scripts that are written to be malicious only on one grid,
/// for instance in a HG scenario, are a distinct possibility.
///
/// Use value from the config file and return it.
///
/// </remarks>
/// <returns></returns>
public string osGetGridNick()
{
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick");
@ -2063,12 +2100,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return World.RegionInfo.RegionSettings.LoadedCreationID;
}
// Threat level is 'Low' because certain users could possibly be tricked into
// dropping an unverified script into one of their own objects, which could
// then gather the physical construction details of the object and transmit it
// to an unscrupulous third party, thus permitting unauthorized duplication of
// the object's form.
//
/// <summary>
/// Get the primitive parameters of a linked prim.
/// </summary>
/// <remarks>
/// Threat level is 'Low' because certain users could possibly be tricked into
/// dropping an unverified script into one of their own objects, which could
/// then gather the physical construction details of the object and transmit it
/// to an unscrupulous third party, thus permitting unauthorized duplication of
/// the object's form.
/// </remarks>
/// <param name="linknumber"></param>
/// <param name="rules"></param>
/// <returns></returns>
public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules)
{
CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams");
@ -2083,25 +2127,122 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return retVal;
}
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom)
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard)
{
CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
//QueueUserWorkItem
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
AvatarAppearance appearance = null;
UUID id;
if (UUID.TryParse(notecard, out id))
{
ScenePresence clonePresence = World.GetScenePresence(id);
if (clonePresence != null)
appearance = clonePresence.Appearance;
}
if (appearance == null)
{
string appearanceSerialized = LoadNotecard(notecard);
if (appearanceSerialized != null)
{
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
appearance = new AvatarAppearance();
appearance.Unpack(appearanceOsd);
}
}
if (appearance == null)
return new LSL_Key(UUID.Zero.ToString());
UUID x = module.CreateNPC(firstname,
lastname,
new Vector3((float) position.x, (float) position.y, (float) position.z),
World,
new UUID(cloneFrom));
appearance);
return new LSL_Key(x.ToString());
}
return new LSL_Key(UUID.Zero.ToString());
}
/// <summary>
/// Save the current appearance of the NPC permanently to the named notecard.
/// </summary>
/// <param name="avatar"></param>
/// <param name="notecard">The name of the notecard to which to save the appearance.</param>
/// <returns>The asset ID of the notecard saved.</returns>
public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard)
{
CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance");
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
if (npcModule != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return new LSL_Key(UUID.Zero.ToString());
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
return new LSL_Key(UUID.Zero.ToString());
return SaveAppearanceToNotecard(npcId, notecard);
}
return new LSL_Key(UUID.Zero.ToString());
}
public void osNpcLoadAppearance(LSL_Key npc, string notecard)
{
CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance");
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
if (npcModule != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return;
string appearanceSerialized = LoadNotecard(notecard);
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized);
// Console.WriteLine("a.Type {0}, a.ToString() {1}", a.Type, a);
AvatarAppearance appearance = new AvatarAppearance();
appearance.Unpack(appearanceOsd);
npcModule.SetNPCAppearance(npcId, appearance, m_host.ParentGroup.Scene);
}
}
public LSL_Vector osNpcGetPos(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.High, "osNpcGetPos");
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
if (npcModule != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return new LSL_Vector(0, 0, 0);
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
return new LSL_Vector(0, 0, 0);
Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition;
return new LSL_Vector(pos.X, pos.Y, pos.Z);
}
return new LSL_Vector(0, 0, 0);
}
public void osNpcMoveTo(LSL_Key npc, LSL_Vector position)
{
CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
@ -2109,11 +2250,87 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return;
Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
module.MoveToTarget(new UUID(npc.m_string), World, pos);
module.MoveToTarget(npcId, World, pos, false, true);
}
}
public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options)
{
CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget");
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return;
Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z);
module.MoveToTarget(
new UUID(npc.m_string),
World,
pos,
(options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
(options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0);
}
}
public LSL_Rotation osNpcGetRot(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.High, "osNpcGetRot");
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
if (npcModule != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
ScenePresence sp = World.GetScenePresence(npcId);
Quaternion rot = sp.Rotation;
return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W);
}
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
}
public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation)
{
CheckThreatLevel(ThreatLevel.High, "osNpcSetRot");
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
if (npcModule != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return;
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
return;
ScenePresence sp = World.GetScenePresence(npcId);
sp.Rotation = LSL_Api.Rot2Quaternion(rotation);
}
}
public void osNpcStopMoveToTarget(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo");
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
module.StopMoveToTarget(new UUID(npc.m_string), World);
}
public void osNpcSay(LSL_Key npc, string message)
{
CheckThreatLevel(ThreatLevel.High, "osNpcSay");
@ -2136,6 +2353,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
/// <summary>
/// Save the current appearance of the script owner permanently to the named notecard.
/// </summary>
/// <param name="notecard">The name of the notecard to which to save the appearance.</param>
/// <returns>The asset ID of the notecard saved.</returns>
public LSL_Key osOwnerSaveAppearance(string notecard)
{
CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance");
return SaveAppearanceToNotecard(m_host.OwnerID, notecard);
}
public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard)
{
CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance");
return SaveAppearanceToNotecard(avatarId, notecard);
}
protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecard)
{
IAvatarFactory appearanceModule = World.RequestModuleInterface<IAvatarFactory>();
if (appearanceModule != null)
{
appearanceModule.SaveBakedTextures(sp.UUID);
OSDMap appearancePacked = sp.Appearance.Pack();
TaskInventoryItem item
= SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
return new LSL_Key(item.AssetID.ToString());
}
else
{
return new LSL_Key(UUID.Zero.ToString());
}
}
protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecard)
{
ScenePresence sp = World.GetScenePresence(avatarId);
if (sp == null || sp.IsChildAgent)
return new LSL_Key(UUID.Zero.ToString());
return SaveAppearanceToNotecard(sp, notecard);
}
protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecard)
{
UUID avatarId;
if (!UUID.TryParse(rawAvatarId, out avatarId))
return new LSL_Key(UUID.Zero.ToString());
return SaveAppearanceToNotecard(avatarId, notecard);
}
/// <summary>
/// Get current region's map texture UUID
/// </summary>
@ -2344,10 +2619,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
obj.Shape.ProjectionFocus = (float)focus;
obj.Shape.ProjectionAmbiance = (float)amb;
obj.ParentGroup.HasGroupChanged = true;
obj.ScheduleFullUpdate();
}
/// <summary>
@ -2372,6 +2645,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
});
return result;
}

View File

@ -168,12 +168,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules);
key osNpcCreate(string user, string name, vector position, key cloneFrom);
key osNpcCreate(string user, string name, vector position, string notecard);
LSL_Key osNpcSaveAppearance(key npc, string notecard);
void osNpcLoadAppearance(key npc, string notecard);
vector osNpcGetPos(key npc);
void osNpcMoveTo(key npc, vector position);
void osNpcMoveToTarget(key npc, vector target, int options);
rotation osNpcGetRot(key npc);
void osNpcSetRot(LSL_Key npc, rotation rot);
void osNpcStopMoveToTarget(LSL_Key npc);
void osNpcSay(key npc, string message);
void osNpcRemove(key npc);
LSL_Key osOwnerSaveAppearance(string notecard);
LSL_Key osAgentSaveAppearance(key agentId, string notecard);
key osGetMapTexture();
key osGetRegionMapTexture(string regionName);
LSL_List osGetRegionStats();

View File

@ -591,6 +591,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int STATS_ACTIVE_SCRIPTS = 19;
public const int STATS_SCRIPT_LPS = 20;
// Constants for osNpc* functions
public const int OS_NPC_FLY = 0;
public const int OS_NPC_NO_FLY = 1;
public const int OS_NPC_LAND_AT_TARGET = 2;
public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED";
public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED";

View File

@ -483,11 +483,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom);
}
public key osNpcSaveAppearance(key npc, string notecard)
{
return m_OSSL_Functions.osNpcSaveAppearance(npc, notecard);
}
public void osNpcLoadAppearance(key npc, string notecard)
{
m_OSSL_Functions.osNpcLoadAppearance(npc, notecard);
}
public vector osNpcGetPos(LSL_Key npc)
{
return m_OSSL_Functions.osNpcGetPos(npc);
}
public void osNpcMoveTo(key npc, vector position)
{
m_OSSL_Functions.osNpcMoveTo(npc, position);
}
public void osNpcMoveToTarget(key npc, vector target, int options)
{
m_OSSL_Functions.osNpcMoveToTarget(npc, target, options);
}
public rotation osNpcGetRot(key npc)
{
return m_OSSL_Functions.osNpcGetRot(npc);
}
public void osNpcSetRot(key npc, rotation rot)
{
m_OSSL_Functions.osNpcSetRot(npc, rot);
}
public void osNpcStopMoveToTarget(LSL_Key npc)
{
m_OSSL_Functions.osNpcStopMoveToTarget(npc);
}
public void osNpcSay(key npc, string message)
{
m_OSSL_Functions.osNpcSay(npc, message);
@ -498,6 +533,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osNpcRemove(npc);
}
public LSL_Key osOwnerSaveAppearance(string notecard)
{
return m_OSSL_Functions.osOwnerSaveAppearance(notecard);
}
public LSL_Key osAgentSaveAppearance(LSL_Key agentId, string notecard)
{
return m_OSSL_Functions.osAgentSaveAppearance(agentId, notecard);
}
public OSSLPrim Prim;
[Serializable]

View File

@ -27,11 +27,13 @@
using System.Collections.Generic;
using NUnit.Framework;
using OpenSim.Framework;
using OpenSim.Tests.Common;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.Framework.Scenes;
using Nini.Config;
using OpenSim.Region.ScriptEngine.Shared.Api;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using OpenMetaverse;
using System;
using OpenSim.Tests.Common.Mock;
@ -47,6 +49,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6;
private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d;
private const double FLOAT_ACCURACY = 0.00005d;
private LSL_Api m_lslApi;
[SetUp]
@ -57,8 +60,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
IConfig config = initConfigSource.AddConfig("XEngine");
config.Set("Enabled", "true");
Scene scene = SceneSetupHelpers.SetupScene();
SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
Scene scene = SceneHelpers.SetupScene();
SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
XEngine.XEngine engine = new XEngine.XEngine();
engine.Initialise(initConfigSource);
@ -165,6 +168,178 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
Assert.Less(eulerCalc.z, eulerCheck.z + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z upper bounds check fail");
}
[Test]
// llSetPrimitiveParams and llGetPrimitiveParams test.
public void TestllSetPrimitiveParams()
{
// Create Prim1.
Scene scene = SceneHelpers.SetupScene();
string obj1Name = "Prim1";
UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001");
SceneObjectPart part1 =
new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default,
Vector3.Zero, Quaternion.Identity,
Vector3.Zero) { Name = obj1Name, UUID = objUuid };
Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True);
// Test a sphere.
CheckllSetPrimitiveParams(
"test 1", // Prim test identification string
new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size
ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type
ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type
new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut
0.80d, // Prim hollow
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
new LSL_Types.Vector3(0.32d, 0.76d, 0.0d)); // Prim dimple
// Test a prism.
CheckllSetPrimitiveParams(
"test 2", // Prim test identification string
new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
0.90d, // Prim hollow
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); // Prim shear
// Test a box.
CheckllSetPrimitiveParams(
"test 3", // Prim test identification string
new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
ScriptBaseClass.PRIM_TYPE_BOX, // Prim type
ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
0.90d, // Prim hollow
new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist
new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); // Prim shear
// Test a tube.
CheckllSetPrimitiveParams(
"test 4", // Prim test identification string
new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size
ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type
ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
0.00d, // Prim hollow
new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist
new LSL_Types.Vector3(1.0d, 0.5d, 0.0d), // Prim hole size
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut
new LSL_Types.Vector3(-1.0d, 1.0d, 0.0d), // Prim taper
1.0d, // Prim revolutions
1.0d, // Prim radius
0.0d); // Prim skew
}
// Set prim params for a box, cylinder or prism and check results.
public void CheckllSetPrimitiveParams(string primTest,
LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear)
{
// Set the prim params.
m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
primCut, primHollow, primTwist, primTaper, primShear));
// Get params for prim to validate settings.
LSL_Types.list primParams =
m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
// Validate settings.
CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
"TestllSetPrimitiveParams " + primTest + " prim type check fail");
Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
"TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
"TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper");
CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear");
}
// Set prim params for a sphere and check results.
public void CheckllSetPrimitiveParams(string primTest,
LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple)
{
// Set the prim params.
m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
primCut, primHollow, primTwist, primDimple));
// Get params for prim to validate settings.
LSL_Types.list primParams =
m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
// Validate settings.
CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
"TestllSetPrimitiveParams " + primTest + " prim type check fail");
Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
"TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
"TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple");
}
// Set prim params for a torus, tube or ring and check results.
public void CheckllSetPrimitiveParams(string primTest,
LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize,
LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper,
double primRev, double primRadius, double primSkew)
{
// Set the prim params.
m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut,
primTaper, primRev, primRadius, primSkew));
// Get params for prim to validate settings.
LSL_Types.list primParams =
m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
// Valdate settings.
CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
"TestllSetPrimitiveParams " + primTest + " prim type check fail");
Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
"TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
"TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size");
CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear");
CheckllSetPrimitiveParamsVector(primProfCut, m_lslApi.llList2Vector(primParams, 8), primTest + " prim profile cut");
CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 9), primTest + " prim taper");
Assert.AreEqual(primRev, m_lslApi.llList2Float(primParams, 10), FLOAT_ACCURACY,
"TestllSetPrimitiveParams " + primTest + " prim revolution fail");
Assert.AreEqual(primRadius, m_lslApi.llList2Float(primParams, 11), FLOAT_ACCURACY,
"TestllSetPrimitiveParams " + primTest + " prim radius fail");
Assert.AreEqual(primSkew, m_lslApi.llList2Float(primParams, 12), FLOAT_ACCURACY,
"TestllSetPrimitiveParams " + primTest + " prim skew fail");
}
public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg)
{
// Check each vector component against expected result.
Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY,
"TestllSetPrimitiveParams " + msg + " vector check fail on x component");
Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY,
"TestllSetPrimitiveParams " + msg + " vector check fail on y component");
Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY,
"TestllSetPrimitiveParams " + msg + " vector check fail on z component");
}
[Test]
// llVecNorm test.
public void TestllVecNorm()

View File

@ -0,0 +1,229 @@
/*
* 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;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using log4net;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenMetaverse.Assets;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
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.Services.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.ScriptEngine.Shared.Tests
{
/// <summary>
/// Tests for OSSL_Api
/// </summary>
[TestFixture]
public class OSSL_ApiAppearanceTest
{
protected Scene m_scene;
protected XEngine.XEngine m_engine;
[SetUp]
public void SetUp()
{
IConfigSource initConfigSource = new IniConfigSource();
IConfig config = initConfigSource.AddConfig("XEngine");
config.Set("Enabled", "true");
config.Set("AllowOSFunctions", "true");
config.Set("OSFunctionThreatLevel", "Severe");
config = initConfigSource.AddConfig("NPC");
config.Set("Enabled", "true");
m_scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule());
m_engine = new XEngine.XEngine();
m_engine.Initialise(initConfigSource);
m_engine.AddRegion(m_scene);
}
/// <summary>
/// Test creation of an NPC where the appearance data comes from a notecard
/// </summary>
[Test]
public void TestOsNpcCreateFromNotecard()
{
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);
SceneObjectPart part = so.RootPart;
m_scene.AddSceneObject(so);
OSSL_Api osslApi = new OSSL_Api();
osslApi.Initialize(m_engine, part, part.LocalId, part.UUID);
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));
}
/// <summary>
/// Test creation of an NPC where the appearance data comes from an avatar already in the region.
/// </summary>
[Test]
public void TestOsNpcCreateFromAvatar()
{
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);
SceneObjectPart part = so.RootPart;
m_scene.AddSceneObject(so);
OSSL_Api osslApi = new OSSL_Api();
osslApi.Initialize(m_engine, part, part.LocalId, part.UUID);
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()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
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);
SceneObjectPart part = so.RootPart;
m_scene.AddSceneObject(so);
OSSL_Api osslApi = new OSSL_Api();
osslApi.Initialize(m_engine, part, part.LocalId, part.UUID);
string notecardName = "appearanceNc";
osslApi.osOwnerSaveAppearance(notecardName);
IList<TaskInventoryItem> items = part.Inventory.GetInventoryItems(notecardName);
Assert.That(items.Count, Is.EqualTo(1));
TaskInventoryItem ncItem = items[0];
Assert.That(ncItem.Name, Is.EqualTo(notecardName));
AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString());
Assert.That(ncAsset, Is.Not.Null);
AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data);
anc.Decode();
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText);
AvatarAppearance savedAppearance = new AvatarAppearance();
savedAppearance.Unpack(appearanceOsd);
Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight));
}
[Test]
public void TestOsAgentSaveAppearance()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UUID ownerId = TestHelpers.ParseTail(0x1);
UUID nonOwnerId = TestHelpers.ParseTail(0x2);
float newHeight = 1.9f;
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, nonOwnerId);
sp.Appearance.AvatarHeight = newHeight;
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId);
SceneObjectPart part = so.RootPart;
m_scene.AddSceneObject(so);
OSSL_Api osslApi = new OSSL_Api();
osslApi.Initialize(m_engine, part, part.LocalId, part.UUID);
string notecardName = "appearanceNc";
osslApi.osAgentSaveAppearance(new LSL_Types.LSLString(nonOwnerId.ToString()), notecardName);
IList<TaskInventoryItem> items = part.Inventory.GetInventoryItems(notecardName);
Assert.That(items.Count, Is.EqualTo(1));
TaskInventoryItem ncItem = items[0];
Assert.That(ncItem.Name, Is.EqualTo(notecardName));
AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString());
Assert.That(ncAsset, Is.Not.Null);
AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data);
anc.Decode();
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText);
AvatarAppearance savedAppearance = new AvatarAppearance();
savedAppearance.Unpack(appearanceOsd);
Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight));
}
}
}

View File

@ -174,10 +174,12 @@ namespace OpenSim.Services.AssetService
public virtual string Store(AssetBase asset)
{
// m_log.DebugFormat(
// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.ID, asset.Data.Length);
m_Database.StoreAsset(asset);
if (!m_Database.ExistsAsset(asset.FullID))
{
// m_log.DebugFormat(
// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length);
m_Database.StoreAsset(asset);
}
return asset.ID;
}

View File

@ -97,7 +97,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
}
}
m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
// m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
m_GridUserService.LoggedOut(client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID, position, lookat);
}
}

View File

@ -510,8 +510,9 @@ namespace OpenSim.Services.GridService
OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} {5}\n\n",
r.RegionName, r.RegionID,
String.Format("{0},{1}", r.posX, r.posY), r.Data["serverURI"],
r.Data["owner_uuid"].ToString(), flags.ToString()));
String.Format("{0},{1}", r.posX / Constants.RegionSize, r.posY / Constants.RegionSize),
r.Data["serverURI"],
r.Data["owner_uuid"], flags));
}
return;
}

View File

@ -95,7 +95,6 @@ namespace OpenSim.Services.HypergridService
m_InGatekeeper = serverConfig.GetBoolean("InGatekeeper", false);
m_log.DebugFormat("[HG IM SERVICE]: Starting... InRobust? {0}", m_InGatekeeper);
if (gridService == string.Empty || presenceService == string.Empty)
throw new Exception(String.Format("Incomplete specifications, InstantMessage Service cannot function."));
@ -120,8 +119,8 @@ namespace OpenSim.Services.HypergridService
public bool IncomingInstantMessage(GridInstantMessage im)
{
m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID);
UUID toAgentID = new UUID(im.toAgentID);
// m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID);
// UUID toAgentID = new UUID(im.toAgentID);
bool success = false;
if (m_IMSimConnector != null)
@ -142,7 +141,7 @@ namespace OpenSim.Services.HypergridService
public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner)
{
m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url);
// m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url);
if (url != string.Empty)
return TrySendInstantMessage(im, url, true, foreigner);
else
@ -333,7 +332,7 @@ namespace OpenSim.Services.HypergridService
if (m_RestURL != string.Empty && (im.offline != 0)
&& (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages)))
{
m_log.DebugFormat("[HG IM SERVICE]: Message saved");
// m_log.DebugFormat("[HG IM SERVICE]: Message saved");
return SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
"POST", m_RestURL + "/SaveMessage/", im);

View File

@ -56,7 +56,7 @@ namespace OpenSim.Services.Interfaces
byte[] GetData(string id);
/// <summary>
/// Synchronously fetches an asset from the local cache only
/// Synchronously fetches an asset from the local cache only.
/// </summary>
/// <param name="id">Asset ID</param>
/// <returns>The fetched asset, or null if it did not exist in the local cache</returns>
@ -75,7 +75,9 @@ namespace OpenSim.Services.Interfaces
/// <summary>
/// Creates a new asset
/// </summary>
/// Returns a random ID if none is passed into it
/// <remarks>
/// Returns a random ID if none is passed via the asset argument.
/// </remarks>
/// <param name="asset"></param>
/// <returns></returns>
string Store(AssetBase asset);
@ -83,7 +85,9 @@ namespace OpenSim.Services.Interfaces
/// <summary>
/// Update an asset's content
/// </summary>
/// <remarks>
/// Attachments and bare scripts need this!!
/// </remarks>
/// <param name="id"> </param>
/// <param name="data"></param>
/// <returns></returns>

View File

@ -183,6 +183,8 @@ namespace OpenSim.Services.LLLoginService
private BuddyList m_buddyList = null;
private string currency;
static LLLoginResponse()
{
// This is being set, but it's not used
@ -218,7 +220,7 @@ namespace OpenSim.Services.LLLoginService
public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo,
GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService,
string where, string startlocation, Vector3 position, Vector3 lookAt, List<InventoryItemBase> gestures, string message,
GridRegion home, IPEndPoint clientIP, string mapTileURL, string searchURL)
GridRegion home, IPEndPoint clientIP, string mapTileURL, string searchURL, string currency)
: this()
{
FillOutInventoryData(invSkel, libService);
@ -236,6 +238,7 @@ namespace OpenSim.Services.LLLoginService
StartLocation = where;
MapTileURL = mapTileURL;
SearchURL = searchURL;
Currency = currency;
FillOutHomeData(pinfo, home);
LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z);
@ -382,6 +385,8 @@ namespace OpenSim.Services.LLLoginService
initialOutfit.Add(InitialOutfitHash);
mapTileURL = String.Empty;
searchURL = String.Empty;
currency = String.Empty;
}
@ -456,6 +461,12 @@ namespace OpenSim.Services.LLLoginService
responseData["buddy-list"] = m_buddyList.ToArray();
}
if (currency != String.Empty)
{
// responseData["real_currency"] = currency;
responseData["currency"] = currency;
}
responseData["login"] = "true";
return responseData;
@ -940,6 +951,12 @@ namespace OpenSim.Services.LLLoginService
set { m_buddyList = value; }
}
public string Currency
{
get { return currency; }
set { currency = value; }
}
#endregion
public class UserInfo

View File

@ -75,6 +75,7 @@ namespace OpenSim.Services.LLLoginService
protected bool m_AllowRemoteSetLoginLevel;
protected string m_MapTileURL;
protected string m_SearchURL;
protected string m_Currency;
protected string m_AllowedClients;
protected string m_DeniedClients;
@ -108,6 +109,7 @@ namespace OpenSim.Services.LLLoginService
m_GatekeeperURL = m_LoginServerConfig.GetString("GatekeeperURI", string.Empty);
m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty);
m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty);
m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty);
m_AllowedClients = m_LoginServerConfig.GetString("AllowedClients", string.Empty);
m_DeniedClients = m_LoginServerConfig.GetString("DeniedClients", string.Empty);
@ -408,7 +410,7 @@ namespace OpenSim.Services.LLLoginService
// Finally, fill out the response and return it
//
LLLoginResponse response = new LLLoginResponse(account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService,
where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP, m_MapTileURL, m_SearchURL);
where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP, m_MapTileURL, m_SearchURL, m_Currency);
m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to client.");
return response;

View File

@ -54,7 +54,7 @@ namespace OpenSim.Tests.Common
/// <summary>
/// Helpers for setting up scenes.
/// </summary>
public class SceneSetupHelpers
public class SceneHelpers
{
/// <summary>
/// Set up a test scene
@ -331,6 +331,7 @@ namespace OpenSim.Tests.Common
agentData.InventoryFolder = UUID.Zero;
agentData.startpos = Vector3.Zero;
agentData.CapsPath = "http://wibble.com";
agentData.ServiceURLs = new Dictionary<string, object>();
return agentData;
}
@ -341,9 +342,9 @@ namespace OpenSim.Tests.Common
/// <param name="scene"></param>
/// <param name="agentId"></param>
/// <returns></returns>
public static TestClient AddClient(Scene scene, UUID agentId)
public static ScenePresence AddScenePresence(Scene scene, UUID agentId)
{
return AddClient(scene, GenerateAgentData(agentId));
return AddScenePresence(scene, GenerateAgentData(agentId));
}
/// <summary>
@ -364,7 +365,7 @@ namespace OpenSim.Tests.Common
/// <param name="scene"></param>
/// <param name="agentData"></param>
/// <returns></returns>
public static TestClient AddClient(Scene scene, AgentCircuitData agentData)
public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData)
{
string reason;
@ -379,14 +380,14 @@ namespace OpenSim.Tests.Common
// Stage 2: add the new client as a child agent to the scene
TestClient client = new TestClient(agentData, scene);
scene.AddNewClient(client);
scene.AddNewClient(client, PresenceType.User);
// Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
ScenePresence scp = scene.GetScenePresence(agentData.AgentID);
scp.CompleteMovement(client);
scp.CompleteMovement(client, true);
//scp.MakeRootAgent(new Vector3(90, 90, 90), true);
return client;
return scp;
}
/// <summary>

View File

@ -74,7 +74,7 @@ namespace OpenSim.Tests.Common
/// <param name="id"></param>
public static TaskInventoryItem AddSceneObject(Scene scene, SceneObjectPart sop, string itemName, UUID id)
{
SceneObjectGroup taskSceneObject = SceneSetupHelpers.CreateSceneObject(1, UUID.Zero);
SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, UUID.Zero);
AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject);
scene.AssetService.Store(taskSceneObjectAsset);
TaskInventoryItem taskSceneObjectItem

View File

@ -118,13 +118,12 @@ namespace OpenSim.Tests.Common
public static UserAccount CreateUserWithInventory(Scene scene)
{
return CreateUserWithInventory(scene, 99);
return CreateUserWithInventory(scene, TestHelpers.ParseTail(99));
}
public static UserAccount CreateUserWithInventory(Scene scene, int uuidTail)
public static UserAccount CreateUserWithInventory(Scene scene, UUID userId)
{
return CreateUserWithInventory(
scene, "Bill", "Bailey", new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail)), "troll");
return CreateUserWithInventory(scene, "Bill", "Bailey", userId, "troll");
}
public static UserAccount CreateUserWithInventory(
@ -139,7 +138,6 @@ namespace OpenSim.Tests.Common
{
// FIXME: This should really be set up by UserAccount itself
ua.ServiceURLs = new Dictionary<string, object>();
scene.UserAccountService.StoreUserAccount(ua);
scene.InventoryService.CreateUserInventory(ua.PrincipalID);
scene.AuthenticationService.SetPassword(ua.PrincipalID, pw);

Some files were not shown because too many files have changed in this diff Show More