Merge branch 'master' into bigmerge

Conflicts:
	OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
	OpenSim/Region/Framework/Scenes/ScenePresence.cs
avinationmerge
Melanie 2011-12-05 17:10:51 +00:00
commit 5ab536a1e9
27 changed files with 828 additions and 455 deletions

View File

@ -350,7 +350,5 @@ namespace OpenSim.Capabilities.Handlers
} }
return null; return null;
} }
} }
} }

View File

@ -0,0 +1,183 @@
/*
* 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;
using System.Collections.Specialized;
using System.Drawing;
using System.Drawing.Imaging;
using System.Reflection;
using System.IO;
using System.Web;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenMetaverse.Imaging;
using OpenSim.Framework;
using OpenSim.Framework.Capabilities;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps;
namespace OpenSim.Capabilities.Handlers
{
public class UploadBakedTextureHandler
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Caps m_HostCapsObj;
private IAssetService m_assetService;
private bool m_persistBakedTextures;
public UploadBakedTextureHandler(Caps caps, IAssetService assetService, bool persistBakedTextures)
{
m_HostCapsObj = caps;
m_assetService = assetService;
m_persistBakedTextures = persistBakedTextures;
}
/// <summary>
/// Handle a request from the client for a Uri to upload a baked texture.
/// </summary>
/// <param name="request"></param>
/// <param name="path"></param>
/// <param name="param"></param>
/// <param name="httpRequest"></param>
/// <param name="httpResponse"></param>
/// <returns>The upload response if the request is successful, null otherwise.</returns>
public string UploadBakedTexture(
string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
try
{
// m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " + m_regionName);
string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
BakedTextureUploader uploader =
new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener);
uploader.OnUpLoad += BakedTextureUploaded;
m_HostCapsObj.HttpListener.AddStreamHandler(
new BinaryStreamHandler("POST", capsBase + uploaderPath,
uploader.uploaderCaps));
string protocol = "http://";
if (m_HostCapsObj.SSLCaps)
protocol = "https://";
string uploaderURL = protocol + m_HostCapsObj.HostName + ":" +
m_HostCapsObj.Port.ToString() + capsBase + uploaderPath;
LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
uploadResponse.uploader = uploaderURL;
uploadResponse.state = "upload";
return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
}
catch (Exception e)
{
m_log.Error("[UPLOAD BAKED TEXTURE HANDLER]: " + e.ToString());
}
return null;
}
/// <summary>
/// Called when a baked texture has been successfully uploaded by a client.
/// </summary>
/// <param name="assetID"></param>
/// <param name="data"></param>
private void BakedTextureUploaded(UUID assetID, byte[] data)
{
// m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
AssetBase asset;
asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString());
asset.Data = data;
asset.Temporary = true;
asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are
m_assetService.Store(asset);
}
}
class BakedTextureUploader
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public event Action<UUID, byte[]> OnUpLoad;
private string uploaderPath = String.Empty;
private UUID newAssetID;
private IHttpServer httpListener;
public BakedTextureUploader(string path, IHttpServer httpServer)
{
newAssetID = UUID.Random();
uploaderPath = path;
httpListener = httpServer;
// m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID);
}
/// <summary>
/// Handle raw uploaded baked texture data.
/// </summary>
/// <param name="data"></param>
/// <param name="path"></param>
/// <param name="param"></param>
/// <returns></returns>
public string uploaderCaps(byte[] data, string path, string param)
{
Action<UUID, byte[]> handlerUpLoad = OnUpLoad;
// Don't do this asynchronously, otherwise it's possible for the client to send set appearance information
// on another thread which might send out avatar updates before the asset has been put into the asset
// service.
if (handlerUpLoad != null)
handlerUpLoad(newAssetID, data);
string res = String.Empty;
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
uploadComplete.new_asset = newAssetID.ToString();
uploadComplete.new_inventory_item = UUID.Zero;
uploadComplete.state = "complete";
res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
httpListener.RemoveStreamHandler("POST", uploaderPath);
// m_log.DebugFormat("[BAKED TEXTURE UPLOADER]: baked texture upload completed for {0}", newAssetID);
return res;
}
}
}

View File

@ -40,24 +40,40 @@ namespace OpenSim.Data.Null
{ {
private static NullRegionData Instance = null; private static NullRegionData Instance = null;
/// <summary>
/// Should we use the static instance for all invocations?
/// </summary>
private bool m_useStaticInstance = true;
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
Dictionary<UUID, RegionData> m_regionData = new Dictionary<UUID, RegionData>(); Dictionary<UUID, RegionData> m_regionData = new Dictionary<UUID, RegionData>();
public NullRegionData(string connectionString, string realm) public NullRegionData(string connectionString, string realm)
{ {
if (Instance == null) // m_log.DebugFormat(
// "[NULL REGION DATA]: Constructor got connectionString {0}, realm {1}", connectionString, realm);
// The !static connection string is a hack so that regression tests can use this module without a high degree of fragility
// in having to deal with the static reference in the once-loaded NullRegionData class.
//
// In standalone operation, we have to use only one instance of this class since the login service and
// simulator have no other way of using a common data store.
if (connectionString == "!static")
m_useStaticInstance = false;
else if (Instance == null)
Instance = this; Instance = this;
//Console.WriteLine("[XXX] NullRegionData constructor");
} }
private delegate bool Matcher(string value); private delegate bool Matcher(string value);
public List<RegionData> Get(string regionName, UUID scopeID) public List<RegionData> Get(string regionName, UUID scopeID)
{ {
if (Instance != this) if (m_useStaticInstance && Instance != this)
return Instance.Get(regionName, scopeID); return Instance.Get(regionName, scopeID);
// m_log.DebugFormat("[NULL REGION DATA]: Getting region {0}, scope {1}", regionName, scopeID);
string cleanName = regionName.ToLower(); string cleanName = regionName.ToLower();
// Handle SQL wildcards // Handle SQL wildcards
@ -82,6 +98,7 @@ namespace OpenSim.Data.Null
cleanName = cleanName.Remove(cleanName.Length - 1); cleanName = cleanName.Remove(cleanName.Length - 1);
} }
} }
Matcher queryMatch; Matcher queryMatch;
if (wildcardPrefix && wildcardSuffix) if (wildcardPrefix && wildcardSuffix)
queryMatch = delegate(string s) { return s.Contains(cleanName); }; queryMatch = delegate(string s) { return s.Contains(cleanName); };
@ -110,7 +127,7 @@ namespace OpenSim.Data.Null
public RegionData Get(int posX, int posY, UUID scopeID) public RegionData Get(int posX, int posY, UUID scopeID)
{ {
if (Instance != this) if (m_useStaticInstance && Instance != this)
return Instance.Get(posX, posY, scopeID); return Instance.Get(posX, posY, scopeID);
List<RegionData> ret = new List<RegionData>(); List<RegionData> ret = new List<RegionData>();
@ -129,7 +146,7 @@ namespace OpenSim.Data.Null
public RegionData Get(UUID regionID, UUID scopeID) public RegionData Get(UUID regionID, UUID scopeID)
{ {
if (Instance != this) if (m_useStaticInstance && Instance != this)
return Instance.Get(regionID, scopeID); return Instance.Get(regionID, scopeID);
if (m_regionData.ContainsKey(regionID)) if (m_regionData.ContainsKey(regionID))
@ -140,7 +157,7 @@ namespace OpenSim.Data.Null
public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID)
{ {
if (Instance != this) if (m_useStaticInstance && Instance != this)
return Instance.Get(startX, startY, endX, endY, scopeID); return Instance.Get(startX, startY, endX, endY, scopeID);
List<RegionData> ret = new List<RegionData>(); List<RegionData> ret = new List<RegionData>();
@ -156,9 +173,12 @@ namespace OpenSim.Data.Null
public bool Store(RegionData data) public bool Store(RegionData data)
{ {
if (Instance != this) if (m_useStaticInstance && Instance != this)
return Instance.Store(data); return Instance.Store(data);
// m_log.DebugFormat(
// "[NULL REGION DATA]: Storing region {0} {1}, scope {2}", data.RegionName, data.RegionID, data.ScopeID);
m_regionData[data.RegionID] = data; m_regionData[data.RegionID] = data;
return true; return true;
@ -166,7 +186,7 @@ namespace OpenSim.Data.Null
public bool SetDataItem(UUID regionID, string item, string value) public bool SetDataItem(UUID regionID, string item, string value)
{ {
if (Instance != this) if (m_useStaticInstance && Instance != this)
return Instance.SetDataItem(regionID, item, value); return Instance.SetDataItem(regionID, item, value);
if (!m_regionData.ContainsKey(regionID)) if (!m_regionData.ContainsKey(regionID))
@ -179,9 +199,11 @@ namespace OpenSim.Data.Null
public bool Delete(UUID regionID) public bool Delete(UUID regionID)
{ {
if (Instance != this) if (m_useStaticInstance && Instance != this)
return Instance.Delete(regionID); return Instance.Delete(regionID);
// m_log.DebugFormat("[NULL REGION DATA]: Deleting region {0}", regionID);
if (!m_regionData.ContainsKey(regionID)) if (!m_regionData.ContainsKey(regionID))
return false; return false;

View File

@ -35,22 +35,36 @@ namespace OpenSim.Framework
/// </summary> /// </summary>
public class AgentCircuitManager public class AgentCircuitManager
{ {
public Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>(); /// <summary>
public Dictionary<UUID, AgentCircuitData> AgentCircuitsByUUID = new Dictionary<UUID, AgentCircuitData>(); /// Agent circuits indexed by circuit code.
/// </summary>
/// <remarks>
/// We lock this for operations both on this dictionary and on m_agentCircuitsByUUID
/// </remarks>
private Dictionary<uint, AgentCircuitData> m_agentCircuits = new Dictionary<uint, AgentCircuitData>();
/// <summary>
/// Agent circuits indexed by agent UUID.
/// </summary>
private Dictionary<UUID, AgentCircuitData> m_agentCircuitsByUUID = new Dictionary<UUID, AgentCircuitData>();
public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode) public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode)
{ {
AgentCircuitData validcircuit = null; AgentCircuitData validcircuit = null;
if (AgentCircuits.ContainsKey(circuitcode))
lock (m_agentCircuits)
{ {
validcircuit = AgentCircuits[circuitcode]; if (m_agentCircuits.ContainsKey(circuitcode))
validcircuit = m_agentCircuits[circuitcode];
} }
AuthenticateResponse user = new AuthenticateResponse(); AuthenticateResponse user = new AuthenticateResponse();
if (validcircuit == null) if (validcircuit == null)
{ {
//don't have this circuit code in our list //don't have this circuit code in our list
user.Authorised = false; user.Authorised = false;
return (user); return user;
} }
if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID)) if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
@ -72,7 +86,7 @@ namespace OpenSim.Framework
user.Authorised = false; user.Authorised = false;
} }
return (user); return user;
} }
/// <summary> /// <summary>
@ -82,73 +96,93 @@ namespace OpenSim.Framework
/// <param name="agentData"></param> /// <param name="agentData"></param>
public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData) public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
{ {
lock (AgentCircuits) lock (m_agentCircuits)
{ {
if (AgentCircuits.ContainsKey(circuitCode)) if (m_agentCircuits.ContainsKey(circuitCode))
{ {
AgentCircuits[circuitCode] = agentData; m_agentCircuits[circuitCode] = agentData;
AgentCircuitsByUUID[agentData.AgentID] = agentData; m_agentCircuitsByUUID[agentData.AgentID] = agentData;
} }
else else
{ {
AgentCircuits.Add(circuitCode, agentData); m_agentCircuits.Add(circuitCode, agentData);
AgentCircuitsByUUID[agentData.AgentID] = agentData; m_agentCircuitsByUUID[agentData.AgentID] = agentData;
} }
} }
} }
public virtual void RemoveCircuit(uint circuitCode) public virtual void RemoveCircuit(uint circuitCode)
{ {
lock (AgentCircuits) lock (m_agentCircuits)
{ {
if (AgentCircuits.ContainsKey(circuitCode)) if (m_agentCircuits.ContainsKey(circuitCode))
{ {
UUID agentID = AgentCircuits[circuitCode].AgentID; UUID agentID = m_agentCircuits[circuitCode].AgentID;
AgentCircuits.Remove(circuitCode); m_agentCircuits.Remove(circuitCode);
AgentCircuitsByUUID.Remove(agentID); m_agentCircuitsByUUID.Remove(agentID);
} }
} }
} }
public virtual void RemoveCircuit(UUID agentID) public virtual void RemoveCircuit(UUID agentID)
{ {
lock (AgentCircuits) lock (m_agentCircuits)
{ {
if (AgentCircuitsByUUID.ContainsKey(agentID)) if (m_agentCircuitsByUUID.ContainsKey(agentID))
{ {
uint circuitCode = AgentCircuitsByUUID[agentID].circuitcode; uint circuitCode = m_agentCircuitsByUUID[agentID].circuitcode;
AgentCircuits.Remove(circuitCode); m_agentCircuits.Remove(circuitCode);
AgentCircuitsByUUID.Remove(agentID); m_agentCircuitsByUUID.Remove(agentID);
} }
} }
} }
public AgentCircuitData GetAgentCircuitData(uint circuitCode) public AgentCircuitData GetAgentCircuitData(uint circuitCode)
{ {
AgentCircuitData agentCircuit = null; AgentCircuitData agentCircuit = null;
AgentCircuits.TryGetValue(circuitCode, out agentCircuit);
lock (m_agentCircuits)
m_agentCircuits.TryGetValue(circuitCode, out agentCircuit);
return agentCircuit; return agentCircuit;
} }
public AgentCircuitData GetAgentCircuitData(UUID agentID) public AgentCircuitData GetAgentCircuitData(UUID agentID)
{ {
AgentCircuitData agentCircuit = null; AgentCircuitData agentCircuit = null;
AgentCircuitsByUUID.TryGetValue(agentID, out agentCircuit);
lock (m_agentCircuits)
m_agentCircuitsByUUID.TryGetValue(agentID, out agentCircuit);
return agentCircuit; return agentCircuit;
} }
/// <summary>
/// Get all current agent circuits indexed by agent UUID.
/// </summary>
/// <returns></returns>
public Dictionary<UUID, AgentCircuitData> GetAgentCircuits()
{
lock (m_agentCircuits)
return new Dictionary<UUID, AgentCircuitData>(m_agentCircuitsByUUID);
}
public void UpdateAgentData(AgentCircuitData agentData) public void UpdateAgentData(AgentCircuitData agentData)
{ {
if (AgentCircuits.ContainsKey((uint) agentData.circuitcode)) lock (m_agentCircuits)
{ {
AgentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname; if (m_agentCircuits.ContainsKey((uint) agentData.circuitcode))
AgentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname; {
AgentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos; m_agentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname;
m_agentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname;
m_agentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos;
// Updated for when we don't know them before calling Scene.NewUserConnection // Updated for when we don't know them before calling Scene.NewUserConnection
AgentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID; m_agentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID;
AgentCircuits[(uint) agentData.circuitcode].SessionID = agentData.SessionID; m_agentCircuits[(uint) agentData.circuitcode].SessionID = agentData.SessionID;
// m_log.Debug("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z); // m_log.Debug("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
}
} }
} }
@ -159,37 +193,36 @@ namespace OpenSim.Framework
/// <param name="newcircuitcode"></param> /// <param name="newcircuitcode"></param>
public bool TryChangeCiruitCode(uint circuitcode, uint newcircuitcode) public bool TryChangeCiruitCode(uint circuitcode, uint newcircuitcode)
{ {
lock (AgentCircuits) lock (m_agentCircuits)
{ {
if (AgentCircuits.ContainsKey((uint)circuitcode) && !AgentCircuits.ContainsKey((uint)newcircuitcode)) if (m_agentCircuits.ContainsKey((uint)circuitcode) && !m_agentCircuits.ContainsKey((uint)newcircuitcode))
{ {
AgentCircuitData agentData = AgentCircuits[(uint)circuitcode]; AgentCircuitData agentData = m_agentCircuits[(uint)circuitcode];
agentData.circuitcode = newcircuitcode; agentData.circuitcode = newcircuitcode;
AgentCircuits.Remove((uint)circuitcode); m_agentCircuits.Remove((uint)circuitcode);
AgentCircuits.Add(newcircuitcode, agentData); m_agentCircuits.Add(newcircuitcode, agentData);
return true; return true;
} }
} }
return false;
return false;
} }
public void UpdateAgentChildStatus(uint circuitcode, bool childstatus) public void UpdateAgentChildStatus(uint circuitcode, bool childstatus)
{ {
if (AgentCircuits.ContainsKey(circuitcode)) lock (m_agentCircuits)
{ if (m_agentCircuits.ContainsKey(circuitcode))
AgentCircuits[circuitcode].child = childstatus; m_agentCircuits[circuitcode].child = childstatus;
}
} }
public bool GetAgentChildStatus(uint circuitcode) public bool GetAgentChildStatus(uint circuitcode)
{ {
if (AgentCircuits.ContainsKey(circuitcode)) lock (m_agentCircuits)
{ if (m_agentCircuits.ContainsKey(circuitcode))
return AgentCircuits[circuitcode].child; return m_agentCircuits[circuitcode].child;
}
return false; return false;
} }
} }

View File

@ -194,8 +194,6 @@ namespace OpenSim.Framework.Tests
resp = agentCircuitManager.AuthenticateSession(SessionId2, AgentId2, circuitcode2); resp = agentCircuitManager.AuthenticateSession(SessionId2, AgentId2, circuitcode2);
Assert.That(!resp.Authorised); Assert.That(!resp.Authorised);
} }
} }
} }

View File

@ -87,8 +87,6 @@ namespace OpenSim.Framework.Tests
anim4.SequenceNum = anim2.SequenceNum; anim4.SequenceNum = anim2.SequenceNum;
Assert.That(anim4.ObjectID == objUUID2 && anim4.AnimID == animUUID2 && anim4.SequenceNum == 1, "void constructor and manual field population failed to set the properties correctly."); Assert.That(anim4.ObjectID == objUUID2 && anim4.AnimID == animUUID2 && anim4.SequenceNum == 1, "void constructor and manual field population failed to set the properties correctly.");
} }
} }
} }

View File

@ -1039,7 +1039,7 @@ namespace OpenSim
{ {
//this.HttpServer. //this.HttpServer.
acd.AppendFormat("{0}:\n", scene.RegionInfo.RegionName); acd.AppendFormat("{0}:\n", scene.RegionInfo.RegionName);
foreach (AgentCircuitData aCircuit in scene.AuthenticateHandler.AgentCircuits.Values) foreach (AgentCircuitData aCircuit in scene.AuthenticateHandler.GetAgentCircuits().Values)
acd.AppendFormat("\t{0} {1} ({2})\n", aCircuit.firstname, aCircuit.lastname, (aCircuit.child ? "Child" : "Root")); acd.AppendFormat("\t{0} {1} ({2})\n", aCircuit.firstname, aCircuit.lastname, (aCircuit.child ? "Child" : "Root"));
} }
); );

View File

@ -56,8 +56,6 @@ namespace OpenSim.Region.ClientStack.Linden
string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder,
byte[] data, string inventoryType, string assetType); byte[] data, string inventoryType, string assetType);
public delegate void UploadedBakedTexture(UUID assetID, byte[] data);
public delegate UUID UpdateItem(UUID itemID, byte[] data); public delegate UUID UpdateItem(UUID itemID, byte[] data);
public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors); public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors);
@ -97,7 +95,6 @@ namespace OpenSim.Region.ClientStack.Linden
private static readonly string m_notecardTaskUpdatePath = "0005/"; private static readonly string m_notecardTaskUpdatePath = "0005/";
// private static readonly string m_fetchInventoryPath = "0006/"; // private static readonly string m_fetchInventoryPath = "0006/";
// private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule.
private static readonly string m_uploadBakedTexturePath = "0010/";// This is in the LandManagementModule.
// These are callbacks which will be setup by the scene so that we can update scene data when we // These are callbacks which will be setup by the scene so that we can update scene data when we
@ -164,8 +161,6 @@ namespace OpenSim.Region.ClientStack.Linden
IRequestHandler req = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); IRequestHandler req = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory);
m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req);
m_HostCapsObj.RegisterHandler("UpdateScriptTask", req); m_HostCapsObj.RegisterHandler("UpdateScriptTask", req);
m_HostCapsObj.RegisterHandler("UploadBakedTexture", new RestStreamHandler("POST", capsBase + m_uploadBakedTexturePath, UploadBakedTexture));
} }
catch (Exception e) catch (Exception e)
{ {
@ -330,74 +325,6 @@ namespace OpenSim.Region.ClientStack.Linden
} }
} }
/// <summary>
/// Handle a request from the client for a Uri to upload a baked texture.
/// </summary>
/// <param name="request"></param>
/// <param name="path"></param>
/// <param name="param"></param>
/// <param name="httpRequest"></param>
/// <param name="httpResponse"></param>
/// <returns>The upload response if the request is successful, null otherwise.</returns>
public string UploadBakedTexture(string request, string path,
string param, OSHttpRequest httpRequest,
OSHttpResponse httpResponse)
{
try
{
// m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " + m_regionName);
string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
BakedTextureUploader uploader =
new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener);
uploader.OnUpLoad += BakedTextureUploaded;
m_HostCapsObj.HttpListener.AddStreamHandler(
new BinaryStreamHandler("POST", capsBase + uploaderPath,
uploader.uploaderCaps));
string protocol = "http://";
if (m_HostCapsObj.SSLCaps)
protocol = "https://";
string uploaderURL = protocol + m_HostCapsObj.HostName + ":" +
m_HostCapsObj.Port.ToString() + capsBase + uploaderPath;
LLSDAssetUploadResponse uploadResponse =
new LLSDAssetUploadResponse();
uploadResponse.uploader = uploaderURL;
uploadResponse.state = "upload";
return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
}
catch (Exception e)
{
m_log.Error("[CAPS]: " + e.ToString());
}
return null;
}
/// <summary>
/// Called when a baked texture has been successfully uploaded by a client.
/// </summary>
/// <param name="assetID"></param>
/// <param name="data"></param>
public void BakedTextureUploaded(UUID assetID, byte[] data)
{
// m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
AssetBase asset;
asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString());
asset.Data = data;
asset.Temporary = true;
asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are
m_assetService.Store(asset);
}
/// <summary> /// <summary>
/// Called when new asset data for an agent inventory item update has been uploaded. /// Called when new asset data for an agent inventory item update has been uploaded.
/// </summary> /// </summary>
@ -1067,6 +994,7 @@ namespace OpenSim.Region.ClientStack.Linden
// XXX Maybe this should be some meaningful error packet // XXX Maybe this should be some meaningful error packet
return null; return null;
} }
///Left this in and commented in case there are unforseen issues ///Left this in and commented in case there are unforseen issues
//private void SaveAssetToFile(string filename, byte[] data) //private void SaveAssetToFile(string filename, byte[] data)
//{ //{
@ -1090,53 +1018,4 @@ namespace OpenSim.Region.ClientStack.Linden
fs.Close(); fs.Close();
} }
} }
public class BakedTextureUploader
{
public event UploadedBakedTexture OnUpLoad;
private UploadedBakedTexture handlerUpLoad = null;
private string uploaderPath = String.Empty;
private UUID newAssetID;
private IHttpServer httpListener;
public BakedTextureUploader(string path, IHttpServer httpServer)
{
newAssetID = UUID.Random();
uploaderPath = path;
httpListener = httpServer;
// m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID);
}
/// <summary>
/// Handle raw uploaded baked texture data.
/// </summary>
/// <param name="data"></param>
/// <param name="path"></param>
/// <param name="param"></param>
/// <returns></returns>
public string uploaderCaps(byte[] data, string path, string param)
{
handlerUpLoad = OnUpLoad;
if (handlerUpLoad != null)
{
Util.FireAndForget(delegate(object o) { handlerUpLoad(newAssetID, data); });
}
string res = String.Empty;
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
uploadComplete.new_asset = newAssetID.ToString();
uploadComplete.new_inventory_item = UUID.Zero;
uploadComplete.state = "complete";
res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
httpListener.RemoveStreamHandler("POST", uploaderPath);
// m_log.InfoFormat("[CAPS] baked texture upload completed for {0}",newAssetID);
return res;
}
}
} }

View File

@ -0,0 +1,112 @@
/*
* 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;
using System.Collections.Specialized;
using System.Drawing;
using System.Drawing.Imaging;
using System.Reflection;
using System.IO;
using System.Web;
using log4net;
using Nini.Config;
using Mono.Addins;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenMetaverse.Imaging;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps;
using OpenSim.Capabilities.Handlers;
namespace OpenSim.Region.ClientStack.Linden
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class UploadBakedTextureModule : INonSharedRegionModule
{
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// For historical reasons this is fixed, but there
/// </summary>
private static readonly string m_uploadBakedTexturePath = "0010/";// This is in the LandManagementModule.
private Scene m_scene;
private bool m_persistBakedTextures;
public void Initialise(IConfigSource source)
{
IConfig sconfig = source.Configs["Startup"];
if (sconfig != null)
m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
}
public void AddRegion(Scene s)
{
m_scene = s;
}
public void RemoveRegion(Scene s)
{
}
public void RegionLoaded(Scene s)
{
m_scene.EventManager.OnRegisterCaps += RegisterCaps;
}
public void PostInitialise()
{
}
public void Close() { }
public string Name { get { return "UploadBakedTextureModule"; } }
public Type ReplaceableInterface
{
get { return null; }
}
public void RegisterCaps(UUID agentID, Caps caps)
{
caps.RegisterHandler(
"UploadBakedTexture",
new RestStreamHandler(
"POST",
"/CAPS/" + m_uploadBakedTexturePath,
new UploadBakedTextureHandler(
caps, m_scene.AssetService, m_persistBakedTextures).UploadBakedTexture));
}
}
}

View File

@ -496,7 +496,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Well, this is it. The agent is over there. // Well, this is it. The agent is over there.
KillEntity(sp.Scene, sp.LocalId); KillEntity(sp.Scene, sp.LocalId);
// Now let's make it officially a child agent // Now let's make it officially a child agent
sp.MakeChildAgent(); sp.MakeChildAgent();
@ -511,9 +510,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
sp.Scene.IncomingCloseAgent(sp.UUID); sp.Scene.IncomingCloseAgent(sp.UUID);
} }
else else
{
// now we have a child agent in this region. // now we have a child agent in this region.
sp.Reset(); sp.Reset();
}
// REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
if (sp.Scene.NeedSceneCacheClear(sp.UUID)) if (sp.Scene.NeedSceneCacheClear(sp.UUID))
@ -965,115 +965,121 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion,
bool isFlying, string version) bool isFlying, string version)
{ {
ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); try
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3} running version {4}", agent.Firstname, agent.Lastname, neighbourx, neighboury, version);
Scene m_scene = agent.Scene;
if (neighbourRegion != null)
{ {
if (!agent.ValidateAttachments()) ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Failed validation of all attachments for region crossing of {0} from {1} to {2}. Continuing.",
agent.Name, agent.Scene.RegionInfo.RegionName, neighbourRegion.RegionName);
pos = pos + (agent.Velocity); m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3} running version {4}", agent.Firstname, agent.Lastname, neighbourx, neighboury, version);
SetInTransit(agent.UUID); Scene m_scene = agent.Scene;
AgentData cAgent = new AgentData();
agent.CopyTo(cAgent);
cAgent.Position = pos;
if (isFlying)
cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
cAgent.CallbackURI = m_scene.RegionInfo.ServerURI +
"agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/";
if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) if (neighbourRegion != null)
{ {
// region doesn't take it if (!agent.ValidateAttachments())
ReInstantiateScripts(agent); m_log.DebugFormat(
ResetFromTransit(agent.UUID); "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for region crossing of {0} from {1} to {2}. Continuing.",
return agent; agent.Name, agent.Scene.RegionInfo.RegionName, neighbourRegion.RegionName);
}
// Next, let's close the child agent connections that are too far away. pos = pos + (agent.Velocity);
agent.CloseChildAgents(neighbourx, neighboury);
//AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); SetInTransit(agent.UUID);
agent.ControllingClient.RequestClientInfo(); AgentData cAgent = new AgentData();
agent.CopyTo(cAgent);
cAgent.Position = pos;
if (isFlying)
cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
cAgent.CallbackURI = m_scene.RegionInfo.ServerURI +
"agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/";
//m_log.Debug("BEFORE CROSS"); if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent))
//Scene.DumpChildrenSeeds(UUID); {
//DumpKnownRegions(); // region doesn't take it
string agentcaps; ReInstantiateScripts(agent);
if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) ResetFromTransit(agent.UUID);
{ return agent;
m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", }
neighbourRegion.RegionHandle);
return agent;
}
string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps);
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); // Next, let's close the child agent connections that are too far away.
agent.CloseChildAgents(neighbourx, neighboury);
IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>(); //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
IPEndPoint neighbourExternal = neighbourRegion.ExternalEndPoint; agent.ControllingClient.RequestClientInfo();
if (neighbourExternal != null)
{ //m_log.Debug("BEFORE CROSS");
//Scene.DumpChildrenSeeds(UUID);
//DumpKnownRegions();
string agentcaps;
if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
{
m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.",
neighbourRegion.RegionHandle);
return agent;
}
string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps);
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
if (eq != null) if (eq != null)
{ {
eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal, eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
capsPath, agent.UUID, agent.ControllingClient.SessionId); capsPath, agent.UUID, agent.ControllingClient.SessionId);
} }
else else
{ {
agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal, agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
capsPath); capsPath);
} }
if (!WaitForCallback(agent.UUID))
{
m_log.Debug("[ENTITY TRANSFER MODULE]: Callback never came in crossing agent");
ReInstantiateScripts(agent);
ResetFromTransit(agent.UUID);
// Yikes! We should just have a ref to scene here.
//agent.Scene.InformClientOfNeighbours(agent);
EnableChildAgents(agent);
return agent;
}
agent.MakeChildAgent();
// now we have a child agent in this region. Request all interesting data about other (root) agents
agent.SendOtherAgentsAvatarDataToMe();
agent.SendOtherAgentsAppearanceToMe();
// Backwards compatibility
if (version == "Unknown" || version == string.Empty)
{
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Old neighbor, passing attachments one by one...");
CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
}
AgentHasMovedAway(agent, false);
// the user may change their profile information in other region,
// so the userinfo in UserProfileCache is not reliable any more, delete it
// REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
if (agent.Scene.NeedSceneCacheClear(agent.UUID))
{
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID);
}
} }
if (!WaitForCallback(agent.UUID)) //m_log.Debug("AFTER CROSS");
{ //Scene.DumpChildrenSeeds(UUID);
m_log.Debug("[ENTITY TRANSFER MODULE]: Callback never came in crossing agent"); //DumpKnownRegions();
ReInstantiateScripts(agent); }
ResetFromTransit(agent.UUID); catch (Exception e)
{
// Yikes! We should just have a ref to scene here. m_log.ErrorFormat(
//agent.Scene.InformClientOfNeighbours(agent); "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2}. Exception {3}{4}",
EnableChildAgents(agent); agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName, e.Message, e.StackTrace);
return agent;
}
agent.MakeChildAgent();
// now we have a child agent in this region. Request all interesting data about other (root) agents
agent.SendOtherAgentsAvatarDataToMe();
agent.SendOtherAgentsAppearanceToMe();
// Backwards compatibility
if (version == "Unknown" || version == string.Empty)
{
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Old neighbor, passing attachments one by one...");
CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
}
AgentHasMovedAway(agent, false);
// the user may change their profile information in other region,
// so the userinfo in UserProfileCache is not reliable any more, delete it
// REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
if (agent.Scene.NeedSceneCacheClear(agent.UUID))
{
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID);
}
} }
//m_log.Debug("AFTER CROSS");
//Scene.DumpChildrenSeeds(UUID);
//DumpKnownRegions();
return agent; return agent;
} }
@ -1359,7 +1365,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
string reason = String.Empty; string reason = String.Empty;
bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason); bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason);
if (regionAccepted && newAgent) if (regionAccepted && newAgent)

View File

@ -31,11 +31,10 @@ using System.IO;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using log4net.Config; using log4net.Config;
using Nini.Config;
using NUnit.Framework; using NUnit.Framework;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using Nini.Config;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion; using GridRegion = OpenSim.Services.Interfaces.GridRegion;
@ -69,6 +68,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
[Test] [Test]
public void TestRegisterRegion() public void TestRegisterRegion()
{ {
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
SetUp(); SetUp();
// Create 4 regions // Create 4 regions
@ -191,7 +193,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
results = m_LocalConnector.GetHyperlinks(UUID.Zero); results = m_LocalConnector.GetHyperlinks(UUID.Zero);
Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null"); Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null");
Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected"); Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected");
} }
} }
} }

View File

@ -54,11 +54,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
/// <value> /// <value>
/// The current movement animation /// The current movement animation
/// </value> /// </value>
public string CurrentMovementAnimation public string CurrentMovementAnimation { get; private set; }
{
get { return m_movementAnimation; }
}
protected string m_movementAnimation = "CROUCH";
private int m_animTickFall; private int m_animTickFall;
public int m_animTickJump; // ScenePresence has to see this to control +Z force public int m_animTickJump; // ScenePresence has to see this to control +Z force
public bool m_jumping = false; public bool m_jumping = false;
@ -79,6 +76,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
public ScenePresenceAnimator(ScenePresence sp) public ScenePresenceAnimator(ScenePresence sp)
{ {
m_scenePresence = sp; m_scenePresence = sp;
CurrentMovementAnimation = "CROUCH";
} }
public void AddAnimation(UUID animID, UUID objectID) public void AddAnimation(UUID animID, UUID objectID)
@ -131,8 +129,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation
public void ResetAnimations() public void ResetAnimations()
{ {
// m_log.DebugFormat(
// "[SCENE PRESENCE ANIMATOR]: Resetting animations for {0} in {1}",
// m_scenePresence.Name, m_scenePresence.Scene.RegionInfo.RegionName);
m_animations.Clear(); m_animations.Clear();
TrySetMovementAnimation("STAND");
} }
/// <summary> /// <summary>
@ -143,6 +144,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
{ {
if (!m_scenePresence.IsChildAgent) if (!m_scenePresence.IsChildAgent)
{ {
// m_log.DebugFormat(
// "[SCENE PRESENCE ANIMATOR]: Setting movement animation {0} for {1}",
// anim, m_scenePresence.Name);
if (m_animations.TrySetDefaultAnimation( if (m_animations.TrySetDefaultAnimation(
anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID))
{ {
@ -155,12 +160,18 @@ namespace OpenSim.Region.Framework.Scenes.Animation
SendAnimPack(); SendAnimPack();
} }
} }
else
{
m_log.WarnFormat(
"[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {0} on child presence {1}",
anim, m_scenePresence.Name);
}
} }
/// <summary> /// <summary>
/// This method determines the proper movement related animation /// This method determines the proper movement related animation
/// </summary> /// </summary>
public string GetMovementAnimation() private string DetermineMovementAnimation()
{ {
const float FALL_DELAY = 800f; const float FALL_DELAY = 800f;
const float PREJUMP_DELAY = 200f; const float PREJUMP_DELAY = 200f;
@ -263,7 +274,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
return "FALLDOWN"; return "FALLDOWN";
} }
return m_movementAnimation; return CurrentMovementAnimation;
} }
#endregion Falling/Floating/Landing #endregion Falling/Floating/Landing
@ -274,7 +285,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation
int jumptime; int jumptime;
jumptime = Environment.TickCount - m_animTickJump; jumptime = Environment.TickCount - m_animTickJump;
if ((move.Z > 0f) && (!m_jumping)) if ((move.Z > 0f) && (!m_jumping))
{ {
// Start jumping, prejump // Start jumping, prejump
@ -318,7 +328,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
#region Ground Movement #region Ground Movement
if (m_movementAnimation == "FALLDOWN") if (CurrentMovementAnimation == "FALLDOWN")
{ {
m_falling = false; m_falling = false;
m_animTickFall = Environment.TickCount; m_animTickFall = Environment.TickCount;
@ -331,16 +341,17 @@ namespace OpenSim.Region.Framework.Scenes.Animation
else else
return "LAND"; return "LAND";
} }
else if ((m_movementAnimation == "LAND") || (m_movementAnimation == "SOFT_LAND") || (m_movementAnimation == "STANDUP")) else if ((CurrentMovementAnimation == "LAND") || (CurrentMovementAnimation == "SOFT_LAND") || (CurrentMovementAnimation == "STANDUP"))
{ {
int landElapsed = Environment.TickCount - m_animTickFall; int landElapsed = Environment.TickCount - m_animTickFall;
int limit = 1000; int limit = 1000;
if(m_movementAnimation == "LAND") limit = 350; if (CurrentMovementAnimation == "LAND")
limit = 350;
// NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client
if ((m_animTickFall != 0) && (landElapsed <= limit)) if ((m_animTickFall != 0) && (landElapsed <= limit))
{ {
return m_movementAnimation; return CurrentMovementAnimation;
} }
else else
{ {
@ -378,7 +389,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
#endregion Ground Movement #endregion Ground Movement
m_falling = false; m_falling = false;
return m_movementAnimation;
return CurrentMovementAnimation;
} }
/// <summary> /// <summary>
@ -386,8 +398,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation
/// </summary> /// </summary>
public void UpdateMovementAnimations() public void UpdateMovementAnimations()
{ {
m_movementAnimation = GetMovementAnimation(); CurrentMovementAnimation = DetermineMovementAnimation();
TrySetMovementAnimation(m_movementAnimation);
// m_log.DebugFormat(
// "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()",
// CurrentMovementAnimation, m_scenePresence.Name);
TrySetMovementAnimation(CurrentMovementAnimation);
} }
public UUID[] GetAnimationArray() public UUID[] GetAnimationArray()

View File

@ -3325,9 +3325,14 @@ namespace OpenSim.Region.Framework.Scenes
if (hasHollow) ret += 1; if (hasHollow) ret += 1;
break; break;
case PrimType.SCULPT: case PrimType.SCULPT:
ret = 1; // Special mesh handling
if (Shape.SculptType == (byte)SculptType.Mesh)
ret = 8; // if it's a mesh then max 8 faces
else
ret = 1; // if it's a sculpt then max 1 face
break; break;
} }
return ret; return ret;
} }
@ -3340,6 +3345,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (Shape.SculptEntry) if (Shape.SculptEntry)
return PrimType.SCULPT; return PrimType.SCULPT;
if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
{ {
if (Shape.PathCurve == (byte)Extrusion.Straight) if (Shape.PathCurve == (byte)Extrusion.Straight)

View File

@ -149,9 +149,9 @@ namespace OpenSim.Region.Framework.Scenes
} }
private bool m_wasFlying; // add for fly velocity control private bool m_wasFlying; // add for fly velocity control
private int m_lastColCount = -1; //KF: Look for Collision chnages // private int m_lastColCount = -1; //KF: Look for Collision chnages
private int m_updateCount = 0; //KF: Update Anims for a while // private int m_updateCount = 0; //KF: Update Anims for a while
private static readonly int UPDATE_COUNT = 10; // how many frames to update for // private static readonly int UPDATE_COUNT = 10; // how many frames to update for
private List<uint> m_lastColliders = new List<uint>(); private List<uint> m_lastColliders = new List<uint>();
private TeleportFlags m_teleportFlags; private TeleportFlags m_teleportFlags;
@ -794,9 +794,6 @@ namespace OpenSim.Region.Framework.Scenes
AdjustKnownSeeds(); AdjustKnownSeeds();
// TODO: I think, this won't send anything, as we are still a child here...
Animator.TrySetMovementAnimation("STAND");
// we created a new ScenePresence (a new child agent) in a fresh region. // we created a new ScenePresence (a new child agent) in a fresh region.
// Request info about all the (root) agents in this region // Request info about all the (root) agents in this region
// Note: This won't send data *to* other clients in that region (children don't send) // Note: This won't send data *to* other clients in that region (children don't send)
@ -1012,13 +1009,17 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// This turns a root agent into a child agent /// This turns a root agent into a child agent
/// </summary>
/// <remarks>
/// when an agent departs this region for a neighbor, this gets called. /// when an agent departs this region for a neighbor, this gets called.
/// ///
/// It doesn't get called for a teleport. Reason being, an agent that /// It doesn't get called for a teleport. Reason being, an agent that
/// teleports out may not end up anywhere near this region /// teleports out may not end up anywhere near this region
/// </summary> /// </remarks>
public void MakeChildAgent() public void MakeChildAgent()
{ {
m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName);
// Reset these so that teleporting in and walking out isn't seen // Reset these so that teleporting in and walking out isn't seen
// as teleporting back // as teleporting back
TeleportFlags = TeleportFlags.Default; TeleportFlags = TeleportFlags.Default;
@ -1308,11 +1309,11 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE PRESENCE]: In {0} received agent update from {1}", // "[SCENE PRESENCE]: In {0} received agent update from {1}",
// Scene.RegionInfo.RegionName, remoteClient.Name); // Scene.RegionInfo.RegionName, remoteClient.Name);
//if (IsChildAgent) if (IsChildAgent)
//{ {
// // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
// return; return;
//} }
++m_movementUpdateCount; ++m_movementUpdateCount;
if (m_movementUpdateCount < 1) if (m_movementUpdateCount < 1)
@ -1381,14 +1382,14 @@ namespace OpenSim.Region.Framework.Scenes
#endregion Inputs #endregion Inputs
// Make anims work for client side autopilot // // Make anims work for client side autopilot
if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0) // if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
m_updateCount = UPDATE_COUNT; // m_updateCount = UPDATE_COUNT;
//
// Make turning in place work // // Make turning in place work
if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0 || // if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0 ||
(flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) // (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
m_updateCount = UPDATE_COUNT; // m_updateCount = UPDATE_COUNT;
if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
{ {
@ -1597,8 +1598,8 @@ namespace OpenSim.Region.Framework.Scenes
// } // }
// } // }
if (update_movementflag && ParentID == 0) // if (update_movementflag && ParentID == 0)
Animator.UpdateMovementAnimations(); // Animator.UpdateMovementAnimations();
} }
m_scene.EventManager.TriggerOnClientMovement(this); m_scene.EventManager.TriggerOnClientMovement(this);
@ -2315,13 +2316,8 @@ namespace OpenSim.Region.Framework.Scenes
public void HandleAgentSitOnGround() public void HandleAgentSitOnGround()
{ {
m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. // m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.
Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
// TODO: This doesn't prevent the user from walking yet.
// Setting parent ID would fix this, if we knew what value
// to use. Or we could add a m_isSitting variable.
//Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
SitGround = true; SitGround = true;
RemoveFromPhysicalScene(); RemoveFromPhysicalScene();
} }
@ -2933,9 +2929,12 @@ namespace OpenSim.Region.Framework.Scenes
public void Reset() public void Reset()
{ {
// m_log.DebugFormat("[SCENE PRESENCE]: Resetting {0} in {1}", Name, Scene.RegionInfo.RegionName);
// Put the child agent back at the center // Put the child agent back at the center
AbsolutePosition AbsolutePosition
= new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70);
Animator.ResetAnimations(); Animator.ResetAnimations();
} }
@ -3158,7 +3157,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void CopyFrom(AgentData cAgent) private void CopyFrom(AgentData cAgent)
{ {
m_originRegionID = cAgent.RegionID; m_originRegionID = cAgent.RegionID;
@ -3217,13 +3216,10 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
catch { } catch { }
// Animations
try // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object?
{ if (cAgent.Anims != null)
Animator.ResetAnimations();
Animator.Animations.FromArray(cAgent.Anims); Animator.Animations.FromArray(cAgent.Anims);
}
catch { }
if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0) if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0)
{ {
@ -3305,19 +3301,32 @@ namespace OpenSim.Region.Framework.Scenes
ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true);
} }
// Event called by the physics plugin to tell the avatar about a collision. /// <summary>
private void PhysicsCollisionUpdate(EventArgs e) /// Event called by the physics plugin to tell the avatar about a collision.
/// </summary>
/// <remarks>
/// This function is called continuously, even when there are no collisions. If the avatar is walking on the
/// ground or a prim then there will be collision information between the avatar and the surface.
///
/// FIXME: However, we can't safely avoid calling this yet where there are no collisions without analyzing whether
/// any part of this method is relying on an every-frame call.
/// </remarks>
/// <param name="e"></param>
public void PhysicsCollisionUpdate(EventArgs e)
{ {
if (IsChildAgent)
return;
//if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
// The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents(
// as of this comment the interval is set in AddToPhysicalScene // as of this comment the interval is set in AddToPhysicalScene
if (Animator != null) if (Animator != null)
{ {
if (m_updateCount > 0) // if (m_updateCount > 0)
{ // {
Animator.UpdateMovementAnimations(); Animator.UpdateMovementAnimations();
m_updateCount--; // m_updateCount--;
} // }
} }
CollisionEventUpdate collisionData = (CollisionEventUpdate)e; CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
@ -3325,13 +3334,13 @@ namespace OpenSim.Region.Framework.Scenes
CollisionPlane = Vector4.UnitW; CollisionPlane = Vector4.UnitW;
// No collisions at all means we may be flying. Update always // // No collisions at all means we may be flying. Update always
// to make falling work // // to make falling work
if (m_lastColCount != coldata.Count || coldata.Count == 0) // if (m_lastColCount != coldata.Count || coldata.Count == 0)
{ // {
m_updateCount = UPDATE_COUNT; // m_updateCount = UPDATE_COUNT;
m_lastColCount = coldata.Count; // m_lastColCount = coldata.Count;
} // }
if (coldata.Count != 0 && Animator != null) if (coldata.Count != 0 && Animator != null)
{ {

View File

@ -31,7 +31,7 @@ using System.Reflection;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Timers; using System.Timers;
using Timer=System.Timers.Timer; using Timer = System.Timers.Timer;
using Nini.Config; using Nini.Config;
using NUnit.Framework; using NUnit.Framework;
using OpenMetaverse; using OpenMetaverse;
@ -39,11 +39,13 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.ClientStack.Linden;
using OpenSim.Region.CoreModules.Framework.EntityTransfer; using OpenSim.Region.CoreModules.Framework.EntityTransfer;
using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
using OpenSim.Tests.Common; using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Mock;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Tests namespace OpenSim.Region.Framework.Scenes.Tests
{ {
@ -103,21 +105,71 @@ namespace OpenSim.Region.Framework.Scenes.Tests
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null);
Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
scene.IncomingCloseAgent(sp.UUID); scene.IncomingCloseAgent(sp.UUID);
Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); Assert.That(scene.GetScenePresence(sp.UUID), Is.Null);
Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null);
Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0));
}
[Test]
public void TestCreateChildScenePresence()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
LocalSimulationConnectorModule lsc = new LocalSimulationConnectorModule();
IConfigSource configSource = new IniConfigSource();
IConfig config = configSource.AddConfig("Modules");
config.Set("SimulationServices", "LocalSimulationConnectorModule");
TestScene scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, configSource, lsc);
UUID agentId = TestHelpers.ParseTail(0x01);
AgentCircuitData acd = SceneHelpers.GenerateAgentData(agentId);
acd.child = true;
GridRegion region = scene.GridService.GetRegionByName(UUID.Zero, scene.RegionInfo.RegionName);
string reason;
// *** This is the first stage, when a neighbouring region is told that a viewer is about to try and
// establish a child scene presence. We pass in the circuit code that the client has to connect with ***
// XXX: ViaLogin may not be correct here.
scene.SimulationService.CreateAgent(region, acd, (uint)TeleportFlags.ViaLogin, out reason);
Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null);
Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
// There's no scene presence yet since only an agent circuit has been established.
Assert.That(scene.GetScenePresence(agentId), Is.Null);
// *** This is the second stage, where the client established a child agent/scene presence using the
// circuit code given to the scene in stage 1 ***
TestClient client = new TestClient(acd, scene);
scene.AddNewClient(client, PresenceType.User);
Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null);
Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
ScenePresence sp = scene.GetScenePresence(agentId);
Assert.That(sp, Is.Not.Null);
Assert.That(sp.UUID, Is.EqualTo(agentId));
Assert.That(sp.IsChildAgent, Is.True);
} }
/// <summary> /// <summary>
/// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Please note that unlike the other tests here, this doesn't rely on structures /// Please note that unlike the other tests here, this doesn't rely on anything set up in the instance fields.
/// INCOMPLETE
/// </remarks> /// </remarks>
[Test] [Test]
public void TestChildAgentEstablished() public void TestChildAgentEstablishedInNeighbour()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure(); // log4net.Config.XmlConfigurator.Configure();
@ -125,18 +177,25 @@ namespace OpenSim.Region.Framework.Scenes.Tests
UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
// TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
IConfigSource configSource = new IniConfigSource(); IConfigSource configSource = new IniConfigSource();
configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule"); IConfig config = configSource.AddConfig("Startup");
config.Set("serverside_object_permissions", true);
config.Set("EventQueue", true);
EntityTransferModule etm = new EntityTransferModule(); EntityTransferModule etm = new EntityTransferModule();
SceneHelpers.SetupSceneModules(myScene1, configSource, etm); EventQueueGetModule eqgm1 = new EventQueueGetModule();
SceneHelpers.SetupSceneModules(myScene1, configSource, etm, eqgm1);
SceneHelpers.AddScenePresence(myScene1, agent1Id); EventQueueGetModule eqgm2 = new EventQueueGetModule();
SceneHelpers.SetupSceneModules(myScene2, configSource, etm, eqgm2);
// SceneHelpers.AddScenePresence(myScene1, agent1Id);
// ScenePresence childPresence = myScene2.GetScenePresence(agent1); // ScenePresence childPresence = myScene2.GetScenePresence(agent1);
//
// TODO: Need to do a fair amount of work to allow synchronous establishment of child agents // // 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, Is.Not.Null);
// Assert.That(childPresence.IsChildAgent, Is.True); // Assert.That(childPresence.IsChildAgent, Is.True);
} }
@ -194,48 +253,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
// Assert.That(presence, Is.Null, "presence is not null"); // Assert.That(presence, Is.Null, "presence is not null");
// } // }
[Test]
public void T012_TestAddNeighbourRegion()
{
TestHelpers.InMethod();
string reason;
if (acd1 == null)
fixNullPresence();
scene.NewUserConnection(acd1, 0, out reason);
if (testclient == null)
testclient = new TestClient(acd1, scene);
scene.AddNewClient(testclient, PresenceType.User);
ScenePresence presence = scene.GetScenePresence(agent1);
presence.MakeRootAgent(new Vector3(90,90,90),false);
string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
presence.AddNeighbourRegion(region2, cap);
presence.AddNeighbourRegion(region3, cap);
Assert.That(presence.KnownRegionCount, Is.EqualTo(2));
}
[Test]
public void T013_TestRemoveNeighbourRegion()
{
TestHelpers.InMethod();
ScenePresence presence = scene.GetScenePresence(agent1);
presence.RemoveNeighbourRegion(region3);
Assert.That(presence.KnownRegionCount,Is.EqualTo(1));
/*
presence.MakeChildAgent;
presence.MakeRootAgent;
CompleteAvatarMovement
*/
}
// I'm commenting this test because it does not represent // I'm commenting this test because it does not represent
// crossings. The Thread.Sleep's in here are not meaningful mocks, // crossings. The Thread.Sleep's in here are not meaningful mocks,
// and they sometimes fail in panda. // and they sometimes fail in panda.
@ -338,33 +355,5 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
} }
public void fixNullPresence()
{
string firstName = "testfirstname";
AgentCircuitData agent = new AgentCircuitData();
agent.AgentID = agent1;
agent.firstname = firstName;
agent.lastname = "testlastname";
agent.SessionID = UUID.Zero;
agent.SecureSessionID = UUID.Zero;
agent.circuitcode = 123;
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
agent.startpos = Vector3.Zero;
agent.CapsPath = GetRandomCapsObjectPath();
agent.Appearance = new AvatarAppearance();
acd1 = agent;
}
public static string GetRandomCapsObjectPath()
{
UUID caps = UUID.Random();
string capsPath = caps.ToString();
capsPath = capsPath.Remove(capsPath.Length - 4, 4);
return capsPath;
}
} }
} }

View File

@ -0,0 +1,70 @@
/*
* 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 System.Threading;
using System.Timers;
using Nini.Config;
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.Framework.EntityTransfer;
using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
using OpenSim.Region.Physics.Manager;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.Framework.Scenes.Tests
{
/// <summary>
/// Scene presence animation tests
/// </summary>
[TestFixture]
public class ScenePresenceAnimationTests
{
[Test]
public void TestFlyingAnimation()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
TestScene scene = SceneHelpers.SetupScene();
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
sp.PhysicsActor.Flying = true;
sp.PhysicsCollisionUpdate(new CollisionEventUpdate());
Assert.That(sp.Animator.CurrentMovementAnimation, Is.EqualTo("HOVER"));
}
}
}

View File

@ -5975,7 +5975,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
flags |= ScriptBaseClass.AGENT_TYPING; flags |= ScriptBaseClass.AGENT_TYPING;
} }
string agentMovementAnimation = agent.Animator.GetMovementAnimation(); string agentMovementAnimation = agent.Animator.CurrentMovementAnimation;
if (agentMovementAnimation == "CROUCH") if (agentMovementAnimation == "CROUCH")
{ {

View File

@ -45,9 +45,11 @@ namespace OpenSim.Server.Handlers.Hypergrid
base(config, server, configName) base(config, server, configName)
{ {
server.AddStreamHandler(new HeloServerGetHandler("opensim-robust")); server.AddStreamHandler(new HeloServerGetHandler("opensim-robust"));
server.AddStreamHandler(new HeloServerHeadHandler("opensim-robust"));
} }
} }
[Obsolete]
public class HeloServerGetHandler : BaseStreamHandler public class HeloServerGetHandler : BaseStreamHandler
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -68,7 +70,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
private byte[] OKResponse(OSHttpResponse httpResponse) private byte[] OKResponse(OSHttpResponse httpResponse)
{ {
m_log.Debug("[HELO]: hi, I was called"); m_log.Debug("[HELO]: hi, GET was called");
httpResponse.AddHeader("X-Handlers-Provided", m_HandlersType); httpResponse.AddHeader("X-Handlers-Provided", m_HandlersType);
httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.StatusCode = (int)HttpStatusCode.OK;
httpResponse.StatusDescription = "OK"; httpResponse.StatusDescription = "OK";
@ -76,4 +78,34 @@ namespace OpenSim.Server.Handlers.Hypergrid
} }
} }
public class HeloServerHeadHandler : BaseStreamHandler
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string m_HandlersType;
public HeloServerHeadHandler(string handlersType) :
base("HEAD", "/helo")
{
m_HandlersType = handlersType;
}
public override byte[] Handle(string path, Stream requestData,
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
return OKResponse(httpResponse);
}
private byte[] OKResponse(OSHttpResponse httpResponse)
{
m_log.Debug("[HELO]: hi, HEAD was called");
httpResponse.AddHeader("X-Handlers-Provided", m_HandlersType);
httpResponse.StatusCode = (int)HttpStatusCode.OK;
httpResponse.StatusDescription = "OK";
return new byte[0];
}
}
} }

View File

@ -143,7 +143,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
UUID.TryParse(sessionID_str, out sessionID); UUID.TryParse(sessionID_str, out sessionID);
string gridName = (string)requestData["externalName"]; string gridName = (string)requestData["externalName"];
bool success = m_HomeUsersService.AgentIsComingHome(sessionID, gridName); bool success = m_HomeUsersService.IsAgentComingHome(sessionID, gridName);
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
hash["result"] = success.ToString(); hash["result"] = success.ToString();

View File

@ -54,6 +54,8 @@ namespace OpenSim.Services.Connectors
public virtual string Helo() public virtual string Helo()
{ {
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI + "/helo"); HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI + "/helo");
// Eventually we need to switch to HEAD
/* req.Method = "HEAD"; */
try try
{ {

View File

@ -356,7 +356,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
return null; return null;
} }
public bool AgentIsComingHome(UUID sessionID, string thisGridExternalName) public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
{ {
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
hash["sessionID"] = sessionID.ToString(); hash["sessionID"] = sessionID.ToString();

View File

@ -243,7 +243,7 @@ namespace OpenSim.Services.HypergridService
// Make sure this is the user coming home, and not a foreign user with same UUID as a local user // Make sure this is the user coming home, and not a foreign user with same UUID as a local user
if (m_UserAgentService != null) if (m_UserAgentService != null)
{ {
if (!m_UserAgentService.AgentIsComingHome(aCircuit.SessionID, m_ExternalName)) if (!m_UserAgentService.IsAgentComingHome(aCircuit.SessionID, m_ExternalName))
{ {
// Can't do, sorry // Can't do, sorry
reason = "Unauthorized"; reason = "Unauthorized";

View File

@ -281,7 +281,7 @@ namespace OpenSim.Services.HypergridService
} }
// We need to prevent foreign users with the same UUID as a local user // We need to prevent foreign users with the same UUID as a local user
public bool AgentIsComingHome(UUID sessionID, string thisGridExternalName) public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
{ {
if (!m_TravelingAgents.ContainsKey(sessionID)) if (!m_TravelingAgents.ContainsKey(sessionID))
return false; return false;

View File

@ -65,7 +65,7 @@ namespace OpenSim.Services.Interfaces
List<UUID> StatusNotification(List<string> friends, UUID userID, bool online); List<UUID> StatusNotification(List<string> friends, UUID userID, bool online);
//List<UUID> GetOnlineFriends(UUID userID, List<string> friends); //List<UUID> GetOnlineFriends(UUID userID, List<string> friends);
bool AgentIsComingHome(UUID sessionID, string thisGridExternalName); bool IsAgentComingHome(UUID sessionID, string thisGridExternalName);
bool VerifyAgent(UUID sessionID, string token); bool VerifyAgent(UUID sessionID, string token);
bool VerifyClient(UUID sessionID, string reportedIP); bool VerifyClient(UUID sessionID, string reportedIP);
} }

View File

@ -49,6 +49,7 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Mock;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Tests.Common namespace OpenSim.Tests.Common
{ {
@ -139,6 +140,7 @@ namespace OpenSim.Tests.Common
testScene.RegionInfo.EstateSettings = new EstateSettings(); testScene.RegionInfo.EstateSettings = new EstateSettings();
testScene.LoginsDisabled = false; testScene.LoginsDisabled = false;
testScene.RegisterRegionWithGrid();
return testScene; return testScene;
} }
@ -222,6 +224,7 @@ namespace OpenSim.Tests.Common
config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
config.Configs["GridService"].Set("ConnectionString", "!static");
LocalGridServicesConnector gridService = new LocalGridServicesConnector(); LocalGridServicesConnector gridService = new LocalGridServicesConnector();
gridService.Initialise(config); gridService.Initialise(config);
@ -393,27 +396,42 @@ namespace OpenSim.Tests.Common
/// <returns></returns> /// <returns></returns>
public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData)
{ {
string reason;
// We emulate the proper login sequence here by doing things in four stages // We emulate the proper login sequence here by doing things in four stages
// Stage 0: log the presence // Stage 0: login
scene.PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); scene.PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
// Stage 1: simulate login by telling the scene to expect a new user connection // Stages 1 & 2
if (!scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason)) ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin);
// Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
sp.CompleteMovement(sp.ControllingClient, true);
return sp;
}
private static ScenePresence IntroduceClientToScene(Scene scene, AgentCircuitData agentData, TeleportFlags tf)
{
string reason;
// Stage 1: tell the scene to expect a new user connection
if (!scene.NewUserConnection(agentData, (uint)tf, out reason))
Console.WriteLine("NewUserConnection failed: " + reason); Console.WriteLine("NewUserConnection failed: " + reason);
// Stage 2: add the new client as a child agent to the scene // Stage 2: add the new client as a child agent to the scene
TestClient client = new TestClient(agentData, scene); TestClient client = new TestClient(agentData, scene);
scene.AddNewClient(client, PresenceType.User); scene.AddNewClient(client, PresenceType.User);
// Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. return scene.GetScenePresence(agentData.AgentID);
ScenePresence scp = scene.GetScenePresence(agentData.AgentID); }
scp.CompleteMovement(client, true);
//scp.MakeRootAgent(new Vector3(90, 90, 90), true);
return scp; public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId)
{
AgentCircuitData acd = GenerateAgentData(agentId);
acd.child = true;
// XXX: ViaLogin may not be correct for child agents
return IntroduceClientToScene(scene, acd, TeleportFlags.ViaLogin);
} }
/// <summary> /// <summary>

View File

@ -260,7 +260,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
; See http://opensimulator.org/wiki/GridInfo ; See http://opensimulator.org/wiki/GridInfo
; login uri: for grid this is the login server URI ; login uri: for grid this is the login server URI
login = http://127.0.0.1:9000/ login = http://127.0.0.1:8002/
; long grid name: the long name of your grid ; long grid name: the long name of your grid
gridname = "the lost continent of hippo" gridname = "the lost continent of hippo"

View File

@ -3048,6 +3048,7 @@
<Reference name="OpenSim.Framework.Servers"/> <Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Statistics"/> <Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/> <Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Region.ClientStack.LindenCaps"/>
<Reference name="OpenSim.Region.Framework"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.CoreModules"/> <Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.OptionalModules"/> <Reference name="OpenSim.Region.OptionalModules"/>