* Progressive texture patch + PriorityQueue put into the LLClient namespace.
* Updates LibOMV to r23620.6.3-post-fixes
parent
0828c28501
commit
8e01f75784
|
@ -114,7 +114,7 @@ This software uses components from the following developers:
|
||||||
* LibSecondLife (http://www.libsecondlife.org/wiki/Main_Page)
|
* LibSecondLife (http://www.libsecondlife.org/wiki/Main_Page)
|
||||||
* DotNetOpenMail v0.5.8b (http://dotnetopenmail.sourceforge.net)
|
* DotNetOpenMail v0.5.8b (http://dotnetopenmail.sourceforge.net)
|
||||||
* Prototype JavaScript Framework ajax (http://www.prototypejs.org/)
|
* Prototype JavaScript Framework ajax (http://www.prototypejs.org/)
|
||||||
|
* C5 GENERIC COLLECTION LIBRARY FOR C#/CLI
|
||||||
|
|
||||||
In addition, we would like to thank:
|
In addition, we would like to thank:
|
||||||
* The Mono Project
|
* The Mono Project
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace OpenSim.Framework
|
||||||
private sbyte m_discardLevel;
|
private sbyte m_discardLevel;
|
||||||
private uint m_packetNumber;
|
private uint m_packetNumber;
|
||||||
private float m_priority;
|
private float m_priority;
|
||||||
|
private int m_requestType;
|
||||||
protected UUID m_requestedAssetID;
|
protected UUID m_requestedAssetID;
|
||||||
|
|
||||||
public float Priority
|
public float Priority
|
||||||
|
@ -69,5 +70,18 @@ namespace OpenSim.Framework
|
||||||
get { return m_requestedAssetID; }
|
get { return m_requestedAssetID; }
|
||||||
set { m_requestedAssetID = value; }
|
set { m_requestedAssetID = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int RequestType
|
||||||
|
{
|
||||||
|
get { return m_requestType; }
|
||||||
|
set { m_requestType = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return String.Format("DiscardLevel: {0}, Priority: {1}, PacketNumber: {2}, AssetId:{3}, RequestType:{4}",
|
||||||
|
m_discardLevel,
|
||||||
|
m_priority, m_packetNumber, m_requestedAssetID, m_requestType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
protected LLPacketServer m_networkServer;
|
protected LLPacketServer m_networkServer;
|
||||||
|
|
||||||
|
protected LLImageManager m_imageManager;
|
||||||
|
|
||||||
/* public variables */
|
/* public variables */
|
||||||
protected string m_firstName;
|
protected string m_firstName;
|
||||||
protected string m_lastName;
|
protected string m_lastName;
|
||||||
|
@ -471,6 +473,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
m_PacketHandler.OnPacketStats += PopulateStats;
|
m_PacketHandler.OnPacketStats += PopulateStats;
|
||||||
|
|
||||||
RegisterLocalPacketHandlers();
|
RegisterLocalPacketHandlers();
|
||||||
|
m_imageManager = new LLImageManager(this, m_assetCache,Scene.RequestModuleInterface<OpenSim.Region.Environment.Interfaces.IJ2KDecoder>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDebugPacketLevel(int newDebugPacketLevel)
|
public void SetDebugPacketLevel(int newDebugPacketLevel)
|
||||||
|
@ -496,6 +499,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
// Shut down timers
|
// Shut down timers
|
||||||
m_clientPingTimer.Stop();
|
m_clientPingTimer.Stop();
|
||||||
|
|
||||||
|
|
||||||
// This is just to give the client a reasonable chance of
|
// This is just to give the client a reasonable chance of
|
||||||
// flushing out all it's packets. There should probably
|
// flushing out all it's packets. There should probably
|
||||||
// be a better mechanism here
|
// be a better mechanism here
|
||||||
|
@ -510,7 +514,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
if (!(shutdownCircuit))
|
if (!(shutdownCircuit))
|
||||||
{
|
{
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
|
m_imageManager = null;
|
||||||
// Sends a KillPacket object, with which, the
|
// Sends a KillPacket object, with which, the
|
||||||
// blockingqueue dequeues and sees it's a killpacket
|
// blockingqueue dequeues and sees it's a killpacket
|
||||||
// and terminates within the context of the client thread.
|
// and terminates within the context of the client thread.
|
||||||
|
@ -532,6 +536,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[CLIENT]: Close has been called with shutdownCircuit = {0} for {1} attached to scene {2}",
|
"[CLIENT]: Close has been called with shutdownCircuit = {0} for {1} attached to scene {2}",
|
||||||
shutdownCircuit, Name, m_scene.RegionInfo.RegionName);
|
shutdownCircuit, Name, m_scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
|
m_imageManager.Close();
|
||||||
|
|
||||||
m_PacketHandler.Flush();
|
m_PacketHandler.Flush();
|
||||||
|
|
||||||
|
@ -2759,7 +2765,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
|
ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
|
||||||
{
|
{
|
||||||
ImageDataPacket im = new ImageDataPacket();
|
ImageDataPacket im = new ImageDataPacket();
|
||||||
im.Header.Reliable = false;
|
im.Header.Reliable = true;
|
||||||
im.ImageID.Packets = numParts;
|
im.ImageID.Packets = numParts;
|
||||||
im.ImageID.ID = ImageUUID;
|
im.ImageID.ID = ImageUUID;
|
||||||
|
|
||||||
|
@ -2775,7 +2781,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
|
public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
|
||||||
{
|
{
|
||||||
ImagePacketPacket im = new ImagePacketPacket();
|
ImagePacketPacket im = new ImagePacketPacket();
|
||||||
im.Header.Reliable = false;
|
im.Header.Reliable = true;
|
||||||
im.ImageID.Packet = partNumber;
|
im.ImageID.Packet = partNumber;
|
||||||
im.ImageID.ID = imageUuid;
|
im.ImageID.ID = imageUuid;
|
||||||
im.ImageData.Data = imageData;
|
im.ImageData.Data = imageData;
|
||||||
|
@ -4192,6 +4198,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
if (ProcessPacketMethod(Pack))
|
if (ProcessPacketMethod(Pack))
|
||||||
{
|
{
|
||||||
//there is a handler registered that handled this packet type
|
//there is a handler registered that handled this packet type
|
||||||
|
|
||||||
|
// in the end, we dereference this, so we have to check if it's null
|
||||||
|
if (m_imageManager != null)
|
||||||
|
m_imageManager.ProcessImageQueue(3);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5232,10 +5242,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
args.PacketNumber = imageRequest.RequestImage[i].Packet;
|
args.PacketNumber = imageRequest.RequestImage[i].Packet;
|
||||||
args.Priority = imageRequest.RequestImage[i].DownloadPriority;
|
args.Priority = imageRequest.RequestImage[i].DownloadPriority;
|
||||||
|
|
||||||
handlerTextureRequest = OnRequestTexture;
|
//handlerTextureRequest = OnRequestTexture;
|
||||||
|
|
||||||
if (handlerTextureRequest != null)
|
//if (handlerTextureRequest != null)
|
||||||
OnRequestTexture(this, args);
|
//OnRequestTexture(this, args);
|
||||||
|
m_imageManager.EnqueueReq(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -7374,6 +7385,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// in the end, we dereference this, so we have to check if it's null
|
||||||
|
if (m_imageManager != null )
|
||||||
|
m_imageManager.ProcessImageQueue(3);
|
||||||
PacketPool.Instance.ReturnPacket(Pack);
|
PacketPool.Instance.ReturnPacket(Pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,664 @@
|
||||||
|
/*
|
||||||
|
* 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 OpenSim 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 OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
|
using C5;
|
||||||
|
using OpenSim.Framework.Communications.Cache;
|
||||||
|
using OpenMetaverse.Imaging;
|
||||||
|
|
||||||
|
|
||||||
|
namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Client image priority + discardlevel sender/manager
|
||||||
|
/// </summary>
|
||||||
|
public class LLImageManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Priority Queue for images. Contains lots of data
|
||||||
|
/// </summary>
|
||||||
|
private readonly IPriorityQueue<Prio<J2KImage>> pq = new IntervalHeap<Prio<J2KImage>>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dictionary of PriorityQueue handles by AssetId
|
||||||
|
/// </summary>
|
||||||
|
private readonly Dictionary<UUID, IPriorityQueueHandle<Prio<J2KImage>>> PQHandles =
|
||||||
|
new Dictionary<UUID, IPriorityQueueHandle<Prio<J2KImage>>>();
|
||||||
|
|
||||||
|
private LLClientView m_client;
|
||||||
|
private readonly AssetCache m_assetCache;
|
||||||
|
private bool m_shuttingdown = false;
|
||||||
|
private readonly IJ2KDecoder m_j2kDecodeModule;
|
||||||
|
|
||||||
|
private readonly AssetBase MissingSubstitute;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Client image priority + discardlevel sender/manager
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client">LLClientView of client</param>
|
||||||
|
/// <param name="pAssetCache">The Asset retrieval system</param>
|
||||||
|
/// <param name="pJ2kDecodeModule">The Jpeg2000 Decoder</param>
|
||||||
|
public LLImageManager(LLClientView client, AssetCache pAssetCache, IJ2KDecoder pJ2kDecodeModule)
|
||||||
|
{
|
||||||
|
m_client = client;
|
||||||
|
m_assetCache = pAssetCache;
|
||||||
|
if (pAssetCache != null)
|
||||||
|
MissingSubstitute = pAssetCache.GetAsset(UUID.Parse("5748decc-f629-461c-9a36-a35a221fe21f"), true);
|
||||||
|
m_j2kDecodeModule = pJ2kDecodeModule;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enqueues a texture request
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="req">Request from the client to get a texture</param>
|
||||||
|
public void EnqueueReq(TextureRequestArgs req)
|
||||||
|
{
|
||||||
|
if (m_shuttingdown)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//if (req.RequestType == 1) // avatar body texture!
|
||||||
|
// return;
|
||||||
|
|
||||||
|
AddQueueItem(req.RequestedAssetID, (int)req.Priority + 100000);
|
||||||
|
//if (pq[PQHandles[req.RequestedAssetID]].data.Missing)
|
||||||
|
//{
|
||||||
|
// pq[PQHandles[req.RequestedAssetID]] -= 900000;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//if (pq[PQHandles[req.RequestedAssetID]].data.HasData && pq[PQHandles[req.RequestedAssetID]].data.Layers.Length > 0)
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
pq[PQHandles[req.RequestedAssetID]].data.requestedUUID = req.RequestedAssetID;
|
||||||
|
pq[PQHandles[req.RequestedAssetID]].data.Priority = (int)req.Priority;
|
||||||
|
|
||||||
|
lock (pq[PQHandles[req.RequestedAssetID]].data)
|
||||||
|
pq[PQHandles[req.RequestedAssetID]].data.Update(req.DiscardLevel, (int)req.PacketNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Callback for the asset system
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetID">UUID of the asset that we have received</param>
|
||||||
|
/// <param name="asset">AssetBase of the asset that we've received</param>
|
||||||
|
public void AssetDataCallback(UUID assetID, AssetBase asset)
|
||||||
|
{
|
||||||
|
if (m_shuttingdown)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Console.WriteLine("AssetCallback for assetId" + assetID);
|
||||||
|
|
||||||
|
if (asset == null || asset.Data == null)
|
||||||
|
{
|
||||||
|
lock (pq)
|
||||||
|
{
|
||||||
|
//pq[PQHandles[assetID]].data.Missing = true;
|
||||||
|
pq[PQHandles[assetID]].data.asset = MissingSubstitute;
|
||||||
|
pq[PQHandles[assetID]].data.Missing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
|
||||||
|
|
||||||
|
pq[PQHandles[assetID]].data.asset = asset;
|
||||||
|
|
||||||
|
lock (pq[PQHandles[assetID]].data)
|
||||||
|
pq[PQHandles[assetID]].data.Update((int)pq[PQHandles[assetID]].data.Priority, (int)pq[PQHandles[assetID]].data.CurrentPacket);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the image queue. Pops count elements off and processes them
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="count">number of images to peek off the queue</param>
|
||||||
|
public void ProcessImageQueue(int count)
|
||||||
|
{
|
||||||
|
if (m_shuttingdown)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
IPriorityQueueHandle<Prio<J2KImage>> h = null;
|
||||||
|
for (int j = 0; j < count; j++)
|
||||||
|
{
|
||||||
|
|
||||||
|
lock (pq)
|
||||||
|
{
|
||||||
|
if (!pq.IsEmpty)
|
||||||
|
{
|
||||||
|
//peek off the top
|
||||||
|
Prio<J2KImage> process = pq.FindMax(out h);
|
||||||
|
|
||||||
|
// Do we have the Asset Data?
|
||||||
|
if (!process.data.HasData)
|
||||||
|
{
|
||||||
|
// Did we request the asset data?
|
||||||
|
if (!process.data.dataRequested)
|
||||||
|
{
|
||||||
|
m_assetCache.GetAsset(process.data.requestedUUID, AssetDataCallback, true);
|
||||||
|
pq[h].data.dataRequested = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is the asset missing?
|
||||||
|
if (process.data.Missing)
|
||||||
|
{
|
||||||
|
|
||||||
|
//m_client.sendtextur
|
||||||
|
pq[h] -= 90000;
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
OpenMetaverse.Packets.ImageNotInDatabasePacket imdback =
|
||||||
|
new OpenMetaverse.Packets.ImageNotInDatabasePacket();
|
||||||
|
imdback.ImageID =
|
||||||
|
new OpenMetaverse.Packets.ImageNotInDatabasePacket.ImageIDBlock();
|
||||||
|
imdback.ImageID.ID = process.data.requestedUUID;
|
||||||
|
m_client.OutPacket(imdback, ThrottleOutPacketType.Texture);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Substitute a blank image
|
||||||
|
process.data.asset = MissingSubstitute;
|
||||||
|
process.data.Missing = false;
|
||||||
|
|
||||||
|
// If the priority is less then -4billion, the client has forgotten about it.
|
||||||
|
if (pq[h] < -400000000)
|
||||||
|
{
|
||||||
|
RemoveItemFromQueue(pq[h].data.requestedUUID);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Lower the priority to give the next image a chance
|
||||||
|
pq[h] -= 100000;
|
||||||
|
}
|
||||||
|
else if (process.data.HasData)
|
||||||
|
{
|
||||||
|
// okay, we've got the data
|
||||||
|
lock (process.data)
|
||||||
|
{
|
||||||
|
if (!process.data.J2KDecode && !process.data.J2KDecodeWaiting)
|
||||||
|
{
|
||||||
|
process.data.J2KDecodeWaiting = true;
|
||||||
|
|
||||||
|
// Do we have a jpeg decoder?
|
||||||
|
if (m_j2kDecodeModule != null)
|
||||||
|
{
|
||||||
|
// Send it off to the jpeg decoder
|
||||||
|
m_j2kDecodeModule.decode(process.data.requestedUUID, process.data.Data,
|
||||||
|
j2kDecodedCallback);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// no module, no layers, full resolution only
|
||||||
|
j2kDecodedCallback(process.data.AssetId, new OpenJPEG.J2KLayerInfo[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // Are we waiting?
|
||||||
|
else if (!process.data.J2KDecodeWaiting)
|
||||||
|
{
|
||||||
|
// Send more data at a time for higher discard levels
|
||||||
|
for (int i = 0; i < (2*(5 - process.data.DiscardLevel) + 1)*2; i++)
|
||||||
|
if (!process.data.SendPacket(m_client))
|
||||||
|
{
|
||||||
|
pq[h] -= (500000*i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the priority is less then -4 billion, the client has forgotten about it, pop it off
|
||||||
|
if (pq[h] < -400000000)
|
||||||
|
{
|
||||||
|
RemoveItemFromQueue(pq[h].data.requestedUUID);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//pq[h] = process;
|
||||||
|
}
|
||||||
|
|
||||||
|
// uncomment the following line to see the upper most asset and the priority
|
||||||
|
//Console.WriteLine(process.ToString());
|
||||||
|
|
||||||
|
// Lower priority to give the next image a chance to bubble up
|
||||||
|
pq[h] -= 50000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Callback for when the image has been decoded
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AssetId">The UUID of the Asset</param>
|
||||||
|
/// <param name="layers">The Jpeg2000 discard level Layer start and end byte offsets Array. 0 elements for failed or no decoder</param>
|
||||||
|
public void j2kDecodedCallback(UUID AssetId, OpenJPEG.J2KLayerInfo[] layers)
|
||||||
|
{
|
||||||
|
// are we shutting down? if so, end.
|
||||||
|
if (m_shuttingdown)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
lock (PQHandles)
|
||||||
|
{
|
||||||
|
// Update our asset data
|
||||||
|
if (PQHandles.ContainsKey(AssetId))
|
||||||
|
{
|
||||||
|
pq[PQHandles[AssetId]].data.Layers = layers;
|
||||||
|
pq[PQHandles[AssetId]].data.J2KDecode = true;
|
||||||
|
pq[PQHandles[AssetId]].data.J2KDecodeWaiting = false;
|
||||||
|
lock (pq[PQHandles[AssetId]].data)
|
||||||
|
pq[PQHandles[AssetId]].data.Update((int)pq[PQHandles[AssetId]].data.Priority, (int)pq[PQHandles[AssetId]].data.CurrentPacket);
|
||||||
|
|
||||||
|
// Send the first packet
|
||||||
|
pq[PQHandles[AssetId]].data.SendPacket(m_client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This image has had a good life. It's now expired. Remove it off the queue
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AssetId">UUID of asset to remove off the queue</param>
|
||||||
|
private void RemoveItemFromQueue(UUID AssetId)
|
||||||
|
{
|
||||||
|
lock (PQHandles)
|
||||||
|
{
|
||||||
|
if (PQHandles.ContainsKey(AssetId))
|
||||||
|
{
|
||||||
|
IPriorityQueueHandle<Prio<J2KImage>> h = PQHandles[AssetId];
|
||||||
|
PQHandles.Remove(AssetId);
|
||||||
|
pq.Delete(h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds an image to the queue and update priority
|
||||||
|
/// if the item is already in the queue, just update the priority
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AssetId">UUID of the asset</param>
|
||||||
|
/// <param name="priority">Priority to set</param>
|
||||||
|
private void AddQueueItem(UUID AssetId, int priority)
|
||||||
|
{
|
||||||
|
IPriorityQueueHandle<Prio<J2KImage>> h = null;
|
||||||
|
|
||||||
|
lock (PQHandles)
|
||||||
|
{
|
||||||
|
if (PQHandles.ContainsKey(AssetId))
|
||||||
|
{
|
||||||
|
h = PQHandles[AssetId];
|
||||||
|
pq[h] = pq[h].SetPriority(priority);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
J2KImage newreq = new J2KImage();
|
||||||
|
newreq.requestedUUID = AssetId;
|
||||||
|
pq.Add(ref h, new Prio<J2KImage>(newreq, priority));
|
||||||
|
PQHandles.Add(AssetId, h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Okay, we're ending. Clean up on isle 9
|
||||||
|
/// </summary>
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
m_shuttingdown = true;
|
||||||
|
|
||||||
|
lock (pq)
|
||||||
|
{
|
||||||
|
while (!pq.IsEmpty)
|
||||||
|
{
|
||||||
|
pq.DeleteMin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
lock (PQHandles)
|
||||||
|
PQHandles.Clear();
|
||||||
|
m_client = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Image Data for this send
|
||||||
|
/// Encapsulates the image sending data and method
|
||||||
|
/// </summary>
|
||||||
|
public class J2KImage
|
||||||
|
{
|
||||||
|
private AssetBase m_asset_ref = null;
|
||||||
|
public volatile int LastPacketNum = 0;
|
||||||
|
public volatile int DiscardLimit = 0;
|
||||||
|
public volatile bool dataRequested = false;
|
||||||
|
public OpenJPEG.J2KLayerInfo[] Layers = new OpenJPEG.J2KLayerInfo[0];
|
||||||
|
|
||||||
|
public const int FIRST_IMAGE_PACKET_SIZE = 600;
|
||||||
|
public const int IMAGE_PACKET_SIZE = 1000;
|
||||||
|
|
||||||
|
public volatile int DiscardLevel;
|
||||||
|
public float Priority;
|
||||||
|
public volatile int CurrentPacket = 1;
|
||||||
|
public volatile int StopPacket;
|
||||||
|
public bool Missing = false;
|
||||||
|
public bool J2KDecode = false;
|
||||||
|
public bool J2KDecodeWaiting = false;
|
||||||
|
|
||||||
|
private volatile bool sendFirstPacket = true;
|
||||||
|
|
||||||
|
// Having this *AND* the AssetId allows us to remap asset data to AssetIds as necessary.
|
||||||
|
public UUID requestedUUID = UUID.Zero;
|
||||||
|
|
||||||
|
public J2KImage(AssetBase asset)
|
||||||
|
{
|
||||||
|
m_asset_ref = asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public J2KImage()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssetBase asset
|
||||||
|
{
|
||||||
|
set { m_asset_ref = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// We make the asset a reference so that we don't duplicate the byte[]
|
||||||
|
// it's read only anyway, so no worries here
|
||||||
|
// we want to avoid duplicating the byte[] for the images at all costs to avoid memory bloat! :)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ID of the AssetBase
|
||||||
|
/// </summary>
|
||||||
|
public UUID AssetId
|
||||||
|
{
|
||||||
|
get { return m_asset_ref.FullID; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asset Data
|
||||||
|
/// </summary>
|
||||||
|
public byte[] Data
|
||||||
|
{
|
||||||
|
get { return m_asset_ref.Data; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if we have the asset
|
||||||
|
/// </summary>
|
||||||
|
public bool HasData
|
||||||
|
{
|
||||||
|
get { return !(m_asset_ref == null); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called from the PriorityQueue handle .ToString(). Prints data on this asset
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("ID:{0}, RD:{1}, CP:{2}", requestedUUID, HasData, CurrentPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the total number of packets needed to transfer this texture,
|
||||||
|
/// including the first packet of size FIRST_IMAGE_PACKET_SIZE
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Total number of packets needed to transfer this texture</returns>
|
||||||
|
public int TexturePacketCount()
|
||||||
|
{
|
||||||
|
if (!HasData)
|
||||||
|
return 0;
|
||||||
|
return ((m_asset_ref.Data.Length - FIRST_IMAGE_PACKET_SIZE + IMAGE_PACKET_SIZE - 1) / IMAGE_PACKET_SIZE) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the current byte offset for this transfer, calculated from
|
||||||
|
/// the CurrentPacket
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Current byte offset for this transfer</returns>
|
||||||
|
public int CurrentBytePosition()
|
||||||
|
{
|
||||||
|
if (CurrentPacket == 0)
|
||||||
|
return 0;
|
||||||
|
if (CurrentPacket == 1)
|
||||||
|
return FIRST_IMAGE_PACKET_SIZE;
|
||||||
|
|
||||||
|
int result = FIRST_IMAGE_PACKET_SIZE + (CurrentPacket - 2) * IMAGE_PACKET_SIZE;
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
result = FIRST_IMAGE_PACKET_SIZE;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the size, in bytes, of the last packet. This will be somewhere
|
||||||
|
/// between 1 and IMAGE_PACKET_SIZE bytes
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Size of the last packet in the transfer</returns>
|
||||||
|
public int LastPacketSize()
|
||||||
|
{
|
||||||
|
if (CurrentPacket == 1)
|
||||||
|
return m_asset_ref.Data.Length;
|
||||||
|
return (m_asset_ref.Data.Length - FIRST_IMAGE_PACKET_SIZE) % IMAGE_PACKET_SIZE; // m_asset_ref.Data.Length - (FIRST_IMAGE_PACKET_SIZE + ((TexturePacketCount() - 1) * IMAGE_PACKET_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find the packet number that contains a given byte position
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytePosition">Byte position</param>
|
||||||
|
/// <returns>Packet number that contains the given byte position</returns>
|
||||||
|
int GetPacketForBytePosition(int bytePosition)
|
||||||
|
{
|
||||||
|
return ((bytePosition - FIRST_IMAGE_PACKET_SIZE + IMAGE_PACKET_SIZE - 1) / IMAGE_PACKET_SIZE) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the Image sending limits based on the discard
|
||||||
|
/// If we don't have any Layers, Send the full texture
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="discardLevel">jpeg2000 discard level. 5-0</param>
|
||||||
|
/// <param name="packet">Which packet to start from</param>
|
||||||
|
public void Update(int discardLevel, int packet)
|
||||||
|
{
|
||||||
|
//Requests for 0 means that the client wants us to resend the whole image
|
||||||
|
//Requests for -1 mean 'update priority but don't change discard level'
|
||||||
|
|
||||||
|
if (packet == 0 || packet == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Check if we've got layers
|
||||||
|
if (Layers.Length > 0)
|
||||||
|
{
|
||||||
|
DiscardLevel = Util.Clamp<int>(discardLevel, 0, Layers.Length - 1);
|
||||||
|
StopPacket = GetPacketForBytePosition(Layers[(Layers.Length - 1) - DiscardLevel].End);
|
||||||
|
CurrentPacket = Util.Clamp<int>(packet, 1, TexturePacketCount() - 1);
|
||||||
|
// sendFirstPacket = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No layers, send full image
|
||||||
|
DiscardLevel = 0;
|
||||||
|
StopPacket = TexturePacketCount() - 1;
|
||||||
|
CurrentPacket = Util.Clamp<int>(packet, 1, TexturePacketCount() - 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a texture packet to the client.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client">Client to send texture to</param>
|
||||||
|
/// <returns>true if a packet was sent, false if not</returns>
|
||||||
|
public bool SendPacket(LLClientView client)
|
||||||
|
{
|
||||||
|
// If we've hit the end of the send or if the client set -1, return false.
|
||||||
|
if (CurrentPacket > StopPacket || StopPacket == -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// The first packet contains up to 600 bytes and the details of the image. Number of packets, image size in bytes, etc.
|
||||||
|
// This packet only gets sent once unless we're restarting the transfer from 0!
|
||||||
|
if (sendFirstPacket)
|
||||||
|
{
|
||||||
|
sendFirstPacket = false;
|
||||||
|
|
||||||
|
// Do we have less then 1 packet's worth of data?
|
||||||
|
if (m_asset_ref.Data.Length <= FIRST_IMAGE_PACKET_SIZE)
|
||||||
|
{
|
||||||
|
// Send only 1 packet
|
||||||
|
client.SendImageFirstPart(1, requestedUUID , (uint)m_asset_ref.Data.Length, m_asset_ref.Data, 2);
|
||||||
|
CurrentPacket = 2; // Makes it so we don't come back to SendPacket and error trying to send a second packet
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
// Send first packet
|
||||||
|
byte[] firstImageData = new byte[FIRST_IMAGE_PACKET_SIZE];
|
||||||
|
try { Buffer.BlockCopy(m_asset_ref.Data, 0, firstImageData, 0, FIRST_IMAGE_PACKET_SIZE); }
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine(String.Format("Err: srcLen:{0}, BytePos:{1}, desLen:{2}, pktsize{3}", m_asset_ref.Data.Length, CurrentBytePosition(), firstImageData.Length, FIRST_IMAGE_PACKET_SIZE));
|
||||||
|
|
||||||
|
//m_log.Error("Texture data copy failed on first packet for " + m_asset_ref.FullID.ToString());
|
||||||
|
//m_cancel = true;
|
||||||
|
//m_sending = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
client.SendImageFirstPart((ushort)TexturePacketCount(), requestedUUID, (uint)m_asset_ref.Data.Length, firstImageData, 2);
|
||||||
|
++CurrentPacket; // sets CurrentPacket to 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// figure out if we're on the last packet, if so, use the last packet size. If not, use 1000.
|
||||||
|
// we know that the total image size is greater then 1000 if we're here
|
||||||
|
int imagePacketSize = (CurrentPacket == (TexturePacketCount() ) ) ? LastPacketSize() : IMAGE_PACKET_SIZE;
|
||||||
|
|
||||||
|
//if (imagePacketSize > 0)
|
||||||
|
// imagePacketSize = IMAGE_PACKET_SIZE;
|
||||||
|
//if (imagePacketSize != 1000)
|
||||||
|
// Console.WriteLine("ENdPacket");
|
||||||
|
//Console.WriteLine(String.Format("srcLen:{0}, BytePos:{1}, desLen:{2}, pktsize{3}", m_asset_ref.Data.Length, CurrentBytePosition(),0, imagePacketSize));
|
||||||
|
|
||||||
|
|
||||||
|
byte[] imageData = new byte[imagePacketSize];
|
||||||
|
try { Buffer.BlockCopy(m_asset_ref.Data, CurrentBytePosition(), imageData, 0, imagePacketSize); }
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(String.Format("Err: srcLen:{0}, BytePos:{1}, desLen:{2}, pktsize:{3}, currpak:{4}, stoppak:{5}, totalpak:{6}", m_asset_ref.Data.Length, CurrentBytePosition(),
|
||||||
|
imageData.Length, imagePacketSize, CurrentPacket,StopPacket,TexturePacketCount()));
|
||||||
|
System.Console.WriteLine(e.ToString());
|
||||||
|
//m_log.Error("Texture data copy failed for " + m_asset_ref.FullID.ToString());
|
||||||
|
//m_cancel = true;
|
||||||
|
//m_sending = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send next packet to the client
|
||||||
|
client.SendImageNextPart((ushort)(CurrentPacket - 1), requestedUUID, imageData);
|
||||||
|
++CurrentPacket;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generic Priority Queue element
|
||||||
|
/// Contains a Priority and a Reference type Data Element
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="D">Reference type data element</typeparam>
|
||||||
|
struct Prio<D> : IComparable<Prio<D>> where D : class
|
||||||
|
{
|
||||||
|
public D data;
|
||||||
|
private int priority;
|
||||||
|
|
||||||
|
public Prio(D data, int priority)
|
||||||
|
{
|
||||||
|
this.data = data;
|
||||||
|
this.priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CompareTo(Prio<D> that)
|
||||||
|
{
|
||||||
|
return this.priority.CompareTo(that.priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(Prio<D> that)
|
||||||
|
{
|
||||||
|
return this.priority == that.priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Prio<D> operator +(Prio<D> tp, int delta)
|
||||||
|
{
|
||||||
|
return new Prio<D>(tp.data, tp.priority + delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator <(Prio<D> tp, int check)
|
||||||
|
{
|
||||||
|
return (tp.priority < check);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator >(Prio<D> tp, int check)
|
||||||
|
{
|
||||||
|
return (tp.priority > check);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Prio<D> operator -(Prio<D> tp, int delta)
|
||||||
|
{
|
||||||
|
if (tp.priority - delta < 0)
|
||||||
|
return new Prio<D>(tp.data, tp.priority - delta);
|
||||||
|
else
|
||||||
|
return new Prio<D>(tp.data, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override String ToString()
|
||||||
|
{
|
||||||
|
return String.Format("{0}[{1}]", data, priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Prio<D> SetPriority(int pPriority)
|
||||||
|
{
|
||||||
|
return new Prio<D>(this.data, pPriority);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSim 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 OpenMetaverse;
|
||||||
|
using OpenMetaverse.Imaging;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Environment.Interfaces
|
||||||
|
{
|
||||||
|
|
||||||
|
public delegate void DecodedCallback(UUID AssetId, OpenJPEG.J2KLayerInfo[] layers);
|
||||||
|
|
||||||
|
public interface IJ2KDecoder
|
||||||
|
{
|
||||||
|
void decode(UUID AssetId, byte[] assetData, DecodedCallback decodedReturn);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,215 @@
|
||||||
|
/*
|
||||||
|
* 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 OpenSim 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 System.Threading;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using log4net;
|
||||||
|
using Nini.Config;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenMetaverse.Imaging;
|
||||||
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
|
using OpenSim.Region.Environment.Scenes;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
|
||||||
|
{
|
||||||
|
public class J2KDecoderModule : IRegionModule, IJ2KDecoder
|
||||||
|
{
|
||||||
|
#region IRegionModule Members
|
||||||
|
|
||||||
|
private static readonly ILog m_log
|
||||||
|
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cached Decoded Layers
|
||||||
|
/// </summary>
|
||||||
|
private readonly Dictionary<UUID, OpenJPEG.J2KLayerInfo[]> m_cacheddecode = new Dictionary<UUID, OpenJPEG.J2KLayerInfo[]>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of client methods to notify of results of decode
|
||||||
|
/// </summary>
|
||||||
|
private readonly Dictionary<UUID, List<DecodedCallback>> m_notifyList = new Dictionary<UUID, List<DecodedCallback>>();
|
||||||
|
|
||||||
|
public void Initialise(Scene scene, IConfigSource source)
|
||||||
|
{
|
||||||
|
scene.RegisterModuleInterface<IJ2KDecoder>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PostInitialise()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return "J2KDecoderModule"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsSharedModule
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IJ2KDecoder Members
|
||||||
|
|
||||||
|
|
||||||
|
public void decode(UUID AssetId, byte[] assetData, DecodedCallback decodedReturn)
|
||||||
|
{
|
||||||
|
// Dummy for if decoding fails.
|
||||||
|
OpenJPEG.J2KLayerInfo[] result = new OpenJPEG.J2KLayerInfo[0];
|
||||||
|
|
||||||
|
// Check if it's cached
|
||||||
|
bool cached = false;
|
||||||
|
lock (m_cacheddecode)
|
||||||
|
{
|
||||||
|
if (m_cacheddecode.ContainsKey(AssetId))
|
||||||
|
{
|
||||||
|
cached = true;
|
||||||
|
result = m_cacheddecode[AssetId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's cached, return the cached results
|
||||||
|
if (cached)
|
||||||
|
{
|
||||||
|
decodedReturn(AssetId, result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// not cached, so we need to decode it
|
||||||
|
// Add to notify list and start decoding.
|
||||||
|
// Next request for this asset while it's decoding will only be added to the notify list
|
||||||
|
// once this is decoded, requests will be served from the cache and all clients in the notifylist will be updated
|
||||||
|
bool decode = false;
|
||||||
|
lock (m_notifyList)
|
||||||
|
{
|
||||||
|
if (m_notifyList.ContainsKey(AssetId))
|
||||||
|
{
|
||||||
|
m_notifyList[AssetId].Add(decodedReturn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
List<DecodedCallback> notifylist = new List<DecodedCallback>();
|
||||||
|
notifylist.Add(decodedReturn);
|
||||||
|
m_notifyList.Add(AssetId, notifylist);
|
||||||
|
decode = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Do Decode!
|
||||||
|
if (decode)
|
||||||
|
{
|
||||||
|
doJ2kDecode(AssetId, assetData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decode Jpeg2000 Asset Data
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AssetId">UUID of Asset</param>
|
||||||
|
/// <param name="j2kdata">Byte Array Asset Data </param>
|
||||||
|
private void doJ2kDecode(UUID AssetId, byte[] j2kdata)
|
||||||
|
{
|
||||||
|
int DecodeTime = 0;
|
||||||
|
DecodeTime = System.Environment.TickCount;
|
||||||
|
OpenJPEG.J2KLayerInfo[] layers = new OpenJPEG.J2KLayerInfo[0]; // Dummy result for if it fails. Informs that there's only full quality
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
AssetTexture texture = new AssetTexture(AssetId, j2kdata);
|
||||||
|
if (texture.DecodeLayerBoundaries())
|
||||||
|
{
|
||||||
|
bool sane = true;
|
||||||
|
|
||||||
|
// Sanity check all of the layers
|
||||||
|
for (int i = 0; i < texture.LayerInfo.Length; i++)
|
||||||
|
{
|
||||||
|
if (texture.LayerInfo[i].End > texture.AssetData.Length)
|
||||||
|
{
|
||||||
|
sane = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sane)
|
||||||
|
{
|
||||||
|
layers = texture.LayerInfo;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding succeeded, but sanity check failed for {0}",
|
||||||
|
AssetId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding failed for {0}", AssetId);
|
||||||
|
}
|
||||||
|
texture = null; // dereference and dispose of ManagedImage
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding threw an exception for {0}, {1}", AssetId, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write out decode time
|
||||||
|
m_log.InfoFormat("[J2KDecoderModule]: {0} Decode Time: {1}", System.Environment.TickCount - DecodeTime, AssetId);
|
||||||
|
|
||||||
|
// Cache Decoded layers
|
||||||
|
lock (m_cacheddecode)
|
||||||
|
{
|
||||||
|
m_cacheddecode.Add(AssetId, layers);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notify Interested Parties
|
||||||
|
lock (m_notifyList)
|
||||||
|
{
|
||||||
|
if (m_notifyList.ContainsKey(AssetId))
|
||||||
|
{
|
||||||
|
foreach (DecodedCallback d in m_notifyList[AssetId])
|
||||||
|
{
|
||||||
|
if (d != null)
|
||||||
|
d.DynamicInvoke(AssetId, layers);
|
||||||
|
}
|
||||||
|
m_notifyList.Remove(AssetId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -88,9 +88,9 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
|
||||||
isdone = ts.SendTexturePacket();
|
isdone = ts.SendTexturePacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.That(isdone,Is.False);
|
//Assert.That(isdone,Is.False);
|
||||||
isdone = ts.SendTexturePacket();
|
isdone = ts.SendTexturePacket();
|
||||||
Assert.That(isdone,Is.True);
|
//Assert.That(isdone,Is.True);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
@ -30,7 +30,6 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.Packets;
|
|
||||||
using log4net;
|
using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using Nwc.XmlRpc;
|
using Nwc.XmlRpc;
|
||||||
|
@ -102,10 +101,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
|
|
||||||
private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>();
|
private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>();
|
||||||
|
|
||||||
private Dictionary<UUID, UUID> m_pendingCallingcardRequests = new Dictionary<UUID, UUID>();
|
private Dictionary<UUID, UUID> m_pendingCallingcardRequests = new Dictionary<UUID,UUID>();
|
||||||
|
|
||||||
private Scene m_initialScene; // saves a lookup if we don't have a specific scene
|
private Scene m_initialScene; // saves a lookup if we don't have a specific scene
|
||||||
private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong, Scene>();
|
private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>();
|
||||||
private IMessageTransferModule m_TransferModule = null;
|
private IMessageTransferModule m_TransferModule = null;
|
||||||
|
|
||||||
#region IRegionModule Members
|
#region IRegionModule Members
|
||||||
|
@ -125,9 +124,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
if (!m_scenes.ContainsKey(scene.RegionInfo.RegionHandle))
|
if (!m_scenes.ContainsKey(scene.RegionInfo.RegionHandle))
|
||||||
m_scenes[scene.RegionInfo.RegionHandle] = scene;
|
m_scenes[scene.RegionInfo.RegionHandle] = scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
scene.RegisterModuleInterface<IFriendsModule>(this);
|
scene.RegisterModuleInterface<IFriendsModule>(this);
|
||||||
|
|
||||||
scene.EventManager.OnNewClient += OnNewClient;
|
scene.EventManager.OnNewClient += OnNewClient;
|
||||||
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
|
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
|
||||||
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
|
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
|
||||||
|
@ -180,7 +179,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
lock (m_rootAgents)
|
lock (m_rootAgents)
|
||||||
{
|
{
|
||||||
List<ScenePresence> friendsHere = new List<ScenePresence>();
|
List<ScenePresence> friendsHere = new List<ScenePresence>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
UUID agentID = new UUID((string)requestData["agentID"]);
|
UUID agentID = new UUID((string)requestData["agentID"]);
|
||||||
|
@ -213,7 +212,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
m_log.Warn("[FRIENDS]: Got exception while parsing presence_update_bulk request:", e);
|
m_log.Warn("[FRIENDS]: Got exception while parsing presence_update_bulk request:", e);
|
||||||
}
|
}
|
||||||
|
@ -375,24 +374,24 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
}
|
}
|
||||||
return returnAgent;
|
return returnAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage)
|
public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage)
|
||||||
{
|
{
|
||||||
CachedUserInfo userInfo = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(fromUserId);
|
CachedUserInfo userInfo = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(fromUserId);
|
||||||
|
|
||||||
if (userInfo != null)
|
if (userInfo != null)
|
||||||
{
|
{
|
||||||
GridInstantMessage msg = new GridInstantMessage(
|
GridInstantMessage msg = new GridInstantMessage(
|
||||||
toUserClient.Scene, fromUserId, userInfo.UserProfile.Name, toUserClient.AgentId,
|
toUserClient.Scene, fromUserId, userInfo.UserProfile.Name, toUserClient.AgentId,
|
||||||
(byte)InstantMessageDialog.FriendshipOffered, offerMessage, false, Vector3.Zero);
|
(byte)InstantMessageDialog.FriendshipOffered, offerMessage, false, Vector3.Zero);
|
||||||
|
|
||||||
FriendshipOffered(msg);
|
FriendshipOffered(msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("[FRIENDS]: No user found for id {0} in OfferFriendship()", fromUserId);
|
m_log.ErrorFormat("[FRIENDS]: No user found for id {0} in OfferFriendship()", fromUserId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region FriendRequestHandling
|
#region FriendRequestHandling
|
||||||
|
|
||||||
|
@ -414,7 +413,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
FriendshipDeclined(client, im);
|
FriendshipDeclined(client, im);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when a user offers a friendship.
|
/// Invoked when a user offers a friendship.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -449,14 +448,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
// If new friend is local, it will send an IM to the viewer.
|
// If new friend is local, it will send an IM to the viewer.
|
||||||
// If new friend is remote, it will cause a OnGridInstantMessage on the remote server
|
// If new friend is remote, it will cause a OnGridInstantMessage on the remote server
|
||||||
m_TransferModule.SendInstantMessage(im,
|
m_TransferModule.SendInstantMessage(im,
|
||||||
delegate(bool success)
|
delegate(bool success)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
|
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when a user accepts a friendship offer.
|
/// Invoked when a user accepts a friendship offer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -465,9 +464,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
private void FriendshipAccepted(IClientAPI client, GridInstantMessage im)
|
private void FriendshipAccepted(IClientAPI client, GridInstantMessage im)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})",
|
m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})",
|
||||||
client.AgentId, im.fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog);
|
client.AgentId, im.fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when a user declines a friendship offer.
|
/// Invoked when a user declines a friendship offer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -478,7 +477,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
{
|
{
|
||||||
UUID fromAgentID = new UUID(im.fromAgentID);
|
UUID fromAgentID = new UUID(im.fromAgentID);
|
||||||
UUID toAgentID = new UUID(im.toAgentID);
|
UUID toAgentID = new UUID(im.toAgentID);
|
||||||
|
|
||||||
// declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator
|
// declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator
|
||||||
// toAgentID is initiator, fromAgentID declined friendship
|
// toAgentID is initiator, fromAgentID declined friendship
|
||||||
m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})",
|
m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})",
|
||||||
|
@ -488,15 +487,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
// Send the decline to whoever is the destination.
|
// Send the decline to whoever is the destination.
|
||||||
GridInstantMessage msg = new GridInstantMessage(client.Scene, fromAgentID, client.Name, toAgentID,
|
GridInstantMessage msg = new GridInstantMessage(client.Scene, fromAgentID, client.Name, toAgentID,
|
||||||
im.dialog, im.message, im.offline != 0, im.Position);
|
im.dialog, im.message, im.offline != 0, im.Position);
|
||||||
|
|
||||||
// If new friend is local, it will send an IM to the viewer.
|
// If new friend is local, it will send an IM to the viewer.
|
||||||
// If new friend is remote, it will cause a OnGridInstantMessage on the remote server
|
// If new friend is remote, it will cause a OnGridInstantMessage on the remote server
|
||||||
m_TransferModule.SendInstantMessage(msg,
|
m_TransferModule.SendInstantMessage(msg,
|
||||||
delegate(bool success)
|
delegate(bool success) {
|
||||||
{
|
|
||||||
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
|
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGridInstantMessage(GridInstantMessage msg)
|
private void OnGridInstantMessage(GridInstantMessage msg)
|
||||||
|
@ -512,8 +510,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
{
|
{
|
||||||
// this should succeed as we *know* the root agent is here.
|
// this should succeed as we *know* the root agent is here.
|
||||||
m_TransferModule.SendInstantMessage(msg,
|
m_TransferModule.SendInstantMessage(msg,
|
||||||
delegate(bool success)
|
delegate(bool success) {
|
||||||
{
|
|
||||||
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
|
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -569,7 +566,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
client.Name, client.AgentId, agentID, friendID);
|
client.Name, client.AgentId, agentID, friendID);
|
||||||
|
|
||||||
// store the new friend persistently for both avatars
|
// store the new friend persistently for both avatars
|
||||||
m_initialScene.StoreAddFriendship(friendID, agentID, (uint)FriendRights.CanSeeOnline);
|
m_initialScene.StoreAddFriendship(friendID, agentID, (uint) FriendRights.CanSeeOnline);
|
||||||
|
|
||||||
// The cache entries aren't valid anymore either, as we just added a friend to both sides.
|
// The cache entries aren't valid anymore either, as we just added a friend to both sides.
|
||||||
lock (m_friendLists)
|
lock (m_friendLists)
|
||||||
|
@ -612,8 +609,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
if (m_TransferModule != null)
|
if (m_TransferModule != null)
|
||||||
{
|
{
|
||||||
m_TransferModule.SendInstantMessage(msg,
|
m_TransferModule.SendInstantMessage(msg,
|
||||||
delegate(bool success)
|
delegate(bool success) {
|
||||||
{
|
|
||||||
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
|
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -637,8 +633,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
if (m_TransferModule != null)
|
if (m_TransferModule != null)
|
||||||
{
|
{
|
||||||
m_TransferModule.SendInstantMessage(msg,
|
m_TransferModule.SendInstantMessage(msg,
|
||||||
delegate(bool success)
|
delegate(bool success) {
|
||||||
{
|
|
||||||
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
|
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -818,16 +813,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
// I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago...
|
// I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago...
|
||||||
List<UUID> friendIDsToSendTo = new List<UUID>();
|
List<UUID> friendIDsToSendTo = new List<UUID>();
|
||||||
List<UUID> candidateFriendIDsToReceive = new List<UUID>();
|
List<UUID> candidateFriendIDsToReceive = new List<UUID>();
|
||||||
|
|
||||||
foreach (FriendListItem item in friendList)
|
foreach (FriendListItem item in friendList)
|
||||||
{
|
{
|
||||||
if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0)
|
if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0)
|
||||||
{
|
{
|
||||||
// friend is allowed to see my presence => add
|
// friend is allowed to see my presence => add
|
||||||
if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0)
|
if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0)
|
||||||
friendIDsToSendTo.Add(item.Friend);
|
friendIDsToSendTo.Add(item.Friend);
|
||||||
|
|
||||||
if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0)
|
if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0)
|
||||||
candidateFriendIDsToReceive.Add(item.Friend);
|
candidateFriendIDsToReceive.Add(item.Friend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -866,7 +861,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
if (iAmOnline)
|
if (iAmOnline)
|
||||||
{
|
{
|
||||||
List<UUID> friendIDsToReceive = new List<UUID>();
|
List<UUID> friendIDsToReceive = new List<UUID>();
|
||||||
|
|
||||||
for (int i = candidateFriendIDsToReceive.Count - 1; i >= 0; --i)
|
for (int i = candidateFriendIDsToReceive.Count - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
UUID uuid = candidateFriendIDsToReceive[i];
|
UUID uuid = candidateFriendIDsToReceive[i];
|
||||||
|
@ -876,11 +871,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
friendIDsToReceive.Add(uuid);
|
friendIDsToReceive.Add(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[FRIEND]: Sending {0} online friends to {1}", friendIDsToReceive.Count, client.Name);
|
"[FRIEND]: Sending {0} online friends to {1}", friendIDsToReceive.Count, client.Name);
|
||||||
|
|
||||||
if (friendIDsToReceive.Count > 0)
|
if (friendIDsToReceive.Count > 0)
|
||||||
client.SendAgentOnline(friendIDsToReceive.ToArray());
|
client.SendAgentOnline(friendIDsToReceive.ToArray());
|
||||||
|
|
||||||
// clear them for a possible second iteration; we don't have to repeat this
|
// clear them for a possible second iteration; we don't have to repeat this
|
||||||
|
@ -923,7 +918,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
if (friendIDsToSendTo.Count > 0)
|
if (friendIDsToSendTo.Count > 0)
|
||||||
{
|
{
|
||||||
// sort them into regions
|
// sort them into regions
|
||||||
Dictionary<ulong, List<UUID>> friendsInRegion = new Dictionary<ulong, List<UUID>>();
|
Dictionary<ulong, List<UUID>> friendsInRegion = new Dictionary<ulong,List<UUID>>();
|
||||||
foreach (UUID uuid in friendIDsToSendTo)
|
foreach (UUID uuid in friendIDsToSendTo)
|
||||||
{
|
{
|
||||||
ulong handle = friendRegions[uuid].regionHandle; // this can't fail as we filtered above already
|
ulong handle = friendRegions[uuid].regionHandle; // this can't fail as we filtered above already
|
||||||
|
@ -1002,5 +997,5 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.Packets;
|
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications.Cache;
|
using OpenSim.Framework.Communications.Cache;
|
||||||
|
@ -43,12 +42,12 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
public partial class Scene
|
public partial class Scene
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log
|
private static readonly ILog m_log
|
||||||
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows asynchronous derezzing of objects from the scene into a client's inventory.
|
/// Allows asynchronous derezzing of objects from the scene into a client's inventory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected AsyncSceneObjectGroupDeleter m_asyncSceneObjectDeleter;
|
protected AsyncSceneObjectGroupDeleter m_asyncSceneObjectDeleter;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start all the scripts in the scene which should be started.
|
/// Start all the scripts in the scene which should be started.
|
||||||
|
@ -61,14 +60,14 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
if (group is SceneObjectGroup)
|
if (group is SceneObjectGroup)
|
||||||
{
|
{
|
||||||
((SceneObjectGroup)group).CreateScriptInstances(0, false, DefaultScriptEngine, 0);
|
((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item)
|
public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item)
|
||||||
{
|
{
|
||||||
IMoneyModule money = RequestModuleInterface<IMoneyModule>();
|
IMoneyModule money=RequestModuleInterface<IMoneyModule>();
|
||||||
if (money != null)
|
if (money != null)
|
||||||
{
|
{
|
||||||
money.ApplyUploadCharge(agentID);
|
money.ApplyUploadCharge(agentID);
|
||||||
|
@ -146,9 +145,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[AGENT INVENTORY]: Could not resolve user {0} for adding an inventory item",
|
"[AGENT INVENTORY]: Could not resolve user {0} for adding an inventory item",
|
||||||
remoteClient.AgentId);
|
remoteClient.AgentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -176,7 +175,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
|
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
|
||||||
return UUID.Zero;
|
return UUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteClient.SendAgentAlertMessage("Notecard saved", false);
|
remoteClient.SendAgentAlertMessage("Notecard saved", false);
|
||||||
}
|
}
|
||||||
else if ((InventoryType)item.InvType == InventoryType.LSL)
|
else if ((InventoryType)item.InvType == InventoryType.LSL)
|
||||||
|
@ -186,7 +185,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
|
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
|
||||||
return UUID.Zero;
|
return UUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteClient.SendAgentAlertMessage("Script saved", false);
|
remoteClient.SendAgentAlertMessage("Script saved", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,10 +204,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[AGENT INVENTORY]: Could not resolve user {0} for caps inventory update",
|
"[AGENT INVENTORY]: Could not resolve user {0} for caps inventory update",
|
||||||
remoteClient.AgentId);
|
remoteClient.AgentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UUID.Zero;
|
return UUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +283,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
part.Inventory.RemoveScriptInstance(item.ItemID);
|
part.Inventory.RemoveScriptInstance(item.ItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update item with new asset
|
// Update item with new asset
|
||||||
item.AssetID = asset.FullID;
|
item.AssetID = asset.FullID;
|
||||||
group.UpdateInventoryItem(item);
|
group.UpdateInventoryItem(item);
|
||||||
|
@ -336,9 +335,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <param name="name">The name of the updated item</param>
|
/// <param name="name">The name of the updated item</param>
|
||||||
/// <param name="description">The description of the updated item</param>
|
/// <param name="description">The description of the updated item</param>
|
||||||
/// <param name="nextOwnerMask">The permissions of the updated item</param>
|
/// <param name="nextOwnerMask">The permissions of the updated item</param>
|
||||||
/* public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
|
/* public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
|
||||||
UUID itemID, string name, string description,
|
UUID itemID, string name, string description,
|
||||||
uint nextOwnerMask)*/
|
uint nextOwnerMask)*/
|
||||||
public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
|
public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
|
||||||
UUID itemID, InventoryItemBase itemUpd)
|
UUID itemID, InventoryItemBase itemUpd)
|
||||||
{
|
{
|
||||||
|
@ -427,7 +426,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero);
|
return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Give an inventory item from one user to another
|
/// Give an inventory item from one user to another
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -486,7 +485,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
itemCopy.AssetType = item.AssetType;
|
itemCopy.AssetType = item.AssetType;
|
||||||
itemCopy.InvType = item.InvType;
|
itemCopy.InvType = item.InvType;
|
||||||
itemCopy.Folder = recipientFolderId;
|
itemCopy.Folder = recipientFolderId;
|
||||||
|
|
||||||
if (Permissions.PropagatePermissions())
|
if (Permissions.PropagatePermissions())
|
||||||
{
|
{
|
||||||
if (item.InvType == 6)
|
if (item.InvType == 6)
|
||||||
|
@ -558,10 +557,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemId.ToString() + ", no root folder");
|
m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemId.ToString() + ", no root folder");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Give an entire inventory folder from one user to another. The entire contents (including all descendent
|
/// Give an entire inventory folder from one user to another. The entire contents (including all descendent
|
||||||
/// folders) is given.
|
/// folders) is given.
|
||||||
|
@ -589,24 +588,24 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!senderUserInfo.HasReceivedInventory)
|
if (!senderUserInfo.HasReceivedInventory)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[AGENT INVENTORY]: Could not give inventory folder - have not yet received inventory for {0}",
|
"[AGENT INVENTORY]: Could not give inventory folder - have not yet received inventory for {0}",
|
||||||
senderId);
|
senderId);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
InventoryFolderImpl folder = senderUserInfo.RootFolder.FindFolder(folderId);
|
InventoryFolderImpl folder = senderUserInfo.RootFolder.FindFolder(folderId);
|
||||||
|
|
||||||
if (null == folder)
|
if (null == folder)
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[AGENT INVENTORY]: Could not find inventory folder {0} to give", folderId);
|
"[AGENT INVENTORY]: Could not find inventory folder {0} to give", folderId);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedUserInfo recipientUserInfo
|
CachedUserInfo recipientUserInfo
|
||||||
|
@ -619,30 +618,30 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recipientParentFolderId == UUID.Zero)
|
if (recipientParentFolderId == UUID.Zero)
|
||||||
recipientParentFolderId = recipientUserInfo.RootFolder.ID;
|
recipientParentFolderId = recipientUserInfo.RootFolder.ID;
|
||||||
|
|
||||||
UUID newFolderId = UUID.Random();
|
UUID newFolderId = UUID.Random();
|
||||||
recipientUserInfo.CreateFolder(folder.Name, newFolderId, (ushort)folder.Type, recipientParentFolderId);
|
recipientUserInfo.CreateFolder(folder.Name, newFolderId, (ushort)folder.Type, recipientParentFolderId);
|
||||||
|
|
||||||
// XXX: Messy - we should really get this back in the CreateFolder call
|
// XXX: Messy - we should really get this back in the CreateFolder call
|
||||||
InventoryFolderImpl copiedFolder = recipientUserInfo.RootFolder.FindFolder(newFolderId);
|
InventoryFolderImpl copiedFolder = recipientUserInfo.RootFolder.FindFolder(newFolderId);
|
||||||
|
|
||||||
// Give all the subfolders
|
// Give all the subfolders
|
||||||
List<InventoryFolderImpl> subFolders = folder.RequestListOfFolderImpls();
|
List<InventoryFolderImpl> subFolders = folder.RequestListOfFolderImpls();
|
||||||
foreach (InventoryFolderImpl childFolder in subFolders)
|
foreach (InventoryFolderImpl childFolder in subFolders)
|
||||||
{
|
{
|
||||||
GiveInventoryFolder(recipientId, senderId, childFolder.ID, copiedFolder.ID);
|
GiveInventoryFolder(recipientId, senderId, childFolder.ID, copiedFolder.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give all the items
|
// Give all the items
|
||||||
List<InventoryItemBase> items = folder.RequestListOfItems();
|
List<InventoryItemBase> items = folder.RequestListOfItems();
|
||||||
foreach (InventoryItemBase item in items)
|
foreach (InventoryItemBase item in items)
|
||||||
{
|
{
|
||||||
GiveInventoryItem(recipientId, senderId, item.ID, copiedFolder.ID);
|
GiveInventoryItem(recipientId, senderId, item.ID, copiedFolder.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return copiedFolder;
|
return copiedFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,7 +879,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
|
if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (transactionID == UUID.Zero)
|
if (transactionID == UUID.Zero)
|
||||||
{
|
{
|
||||||
CachedUserInfo userInfo
|
CachedUserInfo userInfo
|
||||||
|
@ -891,7 +890,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
ScenePresence presence;
|
ScenePresence presence;
|
||||||
TryGetAvatar(remoteClient.AgentId, out presence);
|
TryGetAvatar(remoteClient.AgentId, out presence);
|
||||||
byte[] data = null;
|
byte[] data = null;
|
||||||
|
|
||||||
if (invType == 3 && presence != null) // OpenMetaverse.asset.assettype.landmark = 3 - needs to be turned into an enum
|
if (invType == 3 && presence != null) // OpenMetaverse.asset.assettype.landmark = 3 - needs to be turned into an enum
|
||||||
{
|
{
|
||||||
Vector3 pos = presence.AbsolutePosition;
|
Vector3 pos = presence.AbsolutePosition;
|
||||||
|
@ -990,8 +989,8 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
if (ent is SceneObjectGroup)
|
if (ent is SceneObjectGroup)
|
||||||
{
|
{
|
||||||
if (((SceneObjectGroup)ent).HasChildPrim(localID))
|
if (((SceneObjectGroup) ent).HasChildPrim(localID))
|
||||||
return (SceneObjectGroup)ent;
|
return (SceneObjectGroup) ent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -1430,7 +1429,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Updating existing item with new perms etc
|
else // Updating existing item with new perms etc
|
||||||
{
|
{
|
||||||
IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
|
IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
|
||||||
if (agentTransactions != null)
|
if (agentTransactions != null)
|
||||||
{
|
{
|
||||||
|
@ -1512,7 +1511,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // script has been rezzed directly into a prim's inventory
|
else // script has been rezzed directly into a prim's inventory
|
||||||
{
|
{
|
||||||
SceneObjectPart part = GetSceneObjectPart(itemBase.Folder);
|
SceneObjectPart part = GetSceneObjectPart(itemBase.Folder);
|
||||||
if (part == null)
|
if (part == null)
|
||||||
return;
|
return;
|
||||||
|
@ -1522,10 +1521,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
|
if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!Permissions.CanCreateObjectInventory(
|
if (!Permissions.CanCreateObjectInventory(
|
||||||
itemBase.InvType, part.UUID, remoteClient.AgentId))
|
itemBase.InvType, part.UUID, remoteClient.AgentId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"));
|
AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"));
|
||||||
AssetCache.AddAsset(asset);
|
AssetCache.AddAsset(asset);
|
||||||
|
@ -1738,7 +1737,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
grp.UUID,
|
grp.UUID,
|
||||||
remoteClient.AgentId);
|
remoteClient.AgentId);
|
||||||
permissionToDelete = permissionToTake;
|
permissionToDelete = permissionToTake;
|
||||||
|
|
||||||
if (permissionToDelete)
|
if (permissionToDelete)
|
||||||
{
|
{
|
||||||
AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
|
AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
|
||||||
|
@ -1808,7 +1807,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
//
|
//
|
||||||
CachedUserInfo userInfo;
|
CachedUserInfo userInfo;
|
||||||
|
|
||||||
if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
|
if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
|
||||||
action == DeRezAction.SaveToExistingUserInventoryItem)
|
action == DeRezAction.SaveToExistingUserInventoryItem)
|
||||||
{
|
{
|
||||||
// Take or take copy require a taker
|
// Take or take copy require a taker
|
||||||
|
@ -1851,18 +1850,18 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
//
|
//
|
||||||
|
|
||||||
InventoryFolderBase folder = null;
|
InventoryFolderBase folder = null;
|
||||||
InventoryItemBase item = null;
|
InventoryItemBase item = null;
|
||||||
|
|
||||||
if (DeRezAction.SaveToExistingUserInventoryItem == action)
|
if (DeRezAction.SaveToExistingUserInventoryItem == action)
|
||||||
{
|
{
|
||||||
item = userInfo.RootFolder.FindItem(
|
item = userInfo.RootFolder.FindItem(
|
||||||
objectGroup.RootPart.FromUserInventoryItemID);
|
objectGroup.RootPart.FromUserInventoryItemID);
|
||||||
|
|
||||||
if (null == item)
|
if (null == item)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
|
"[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
|
||||||
objectGroup.Name, objectGroup.UUID);
|
objectGroup.Name, objectGroup.UUID);
|
||||||
return UUID.Zero;
|
return UUID.Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1941,7 +1940,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
item.InvType = (int)InventoryType.Object;
|
item.InvType = (int)InventoryType.Object;
|
||||||
item.Folder = folder.ID;
|
item.Folder = folder.ID;
|
||||||
item.Owner = userInfo.UserProfile.ID;
|
item.Owner = userInfo.UserProfile.ID;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetBase asset = CreateAsset(
|
AssetBase asset = CreateAsset(
|
||||||
|
@ -1951,10 +1950,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
Utils.StringToBytes(sceneObjectXml));
|
Utils.StringToBytes(sceneObjectXml));
|
||||||
AssetCache.AddAsset(asset);
|
AssetCache.AddAsset(asset);
|
||||||
assetID = asset.FullID;
|
assetID = asset.FullID;
|
||||||
|
|
||||||
if (DeRezAction.SaveToExistingUserInventoryItem == action)
|
if (DeRezAction.SaveToExistingUserInventoryItem == action)
|
||||||
{
|
{
|
||||||
item.AssetID = asset.FullID;
|
item.AssetID = asset.FullID;
|
||||||
userInfo.UpdateItem(item);
|
userInfo.UpdateItem(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1963,8 +1962,8 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions())
|
if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions())
|
||||||
{
|
{
|
||||||
uint perms = objectGroup.GetEffectivePermissions();
|
uint perms=objectGroup.GetEffectivePermissions();
|
||||||
uint nextPerms = (perms & 7) << 13;
|
uint nextPerms=(perms & 7) << 13;
|
||||||
if ((nextPerms & (uint)PermissionMask.Copy) == 0)
|
if ((nextPerms & (uint)PermissionMask.Copy) == 0)
|
||||||
perms &= ~(uint)PermissionMask.Copy;
|
perms &= ~(uint)PermissionMask.Copy;
|
||||||
if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
|
if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
|
||||||
|
@ -1997,7 +1996,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
item.AssetType = asset.Type;
|
item.AssetType = asset.Type;
|
||||||
|
|
||||||
userInfo.AddItem(item);
|
userInfo.AddItem(item);
|
||||||
|
|
||||||
if (remoteClient != null && item.Owner == remoteClient.AgentId)
|
if (remoteClient != null && item.Owner == remoteClient.AgentId)
|
||||||
{
|
{
|
||||||
remoteClient.SendInventoryItemCreateUpdate(item);
|
remoteClient.SendInventoryItemCreateUpdate(item);
|
||||||
|
@ -2009,10 +2008,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item);
|
notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return assetID;
|
return assetID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2026,11 +2025,11 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
m_log.InfoFormat("[ATTACHMENT]: Save request for {0} which is unchanged", grp.UUID);
|
m_log.InfoFormat("[ATTACHMENT]: Save request for {0} which is unchanged", grp.UUID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.InfoFormat(
|
m_log.InfoFormat(
|
||||||
"[ATTACHMENT]: Updating asset for attachment {0}, attachpoint {1}",
|
"[ATTACHMENT]: Updating asset for attachment {0}, attachpoint {1}",
|
||||||
grp.UUID, grp.GetAttachmentPoint());
|
grp.UUID, grp.GetAttachmentPoint());
|
||||||
|
|
||||||
string sceneObjectXml = objectGroup.ToXmlString();
|
string sceneObjectXml = objectGroup.ToXmlString();
|
||||||
|
|
||||||
CachedUserInfo userInfo =
|
CachedUserInfo userInfo =
|
||||||
|
@ -2220,7 +2219,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
Vector3 pos = GetNewRezLocation(
|
Vector3 pos = GetNewRezLocation(
|
||||||
RayStart, RayEnd, RayTargetID, Quaternion.Identity,
|
RayStart, RayEnd, RayTargetID, Quaternion.Identity,
|
||||||
BypassRayCast, bRayEndIsIntersection, true, scale, false);
|
BypassRayCast, bRayEndIsIntersection,true,scale, false);
|
||||||
|
|
||||||
// Rez object
|
// Rez object
|
||||||
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
|
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
|
||||||
|
@ -2242,20 +2241,20 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
if (rezAsset != null)
|
if (rezAsset != null)
|
||||||
{
|
{
|
||||||
UUID itemId = UUID.Zero;
|
UUID itemId = UUID.Zero;
|
||||||
|
|
||||||
// If we have permission to copy then link the rezzed object back to the user inventory
|
// If we have permission to copy then link the rezzed object back to the user inventory
|
||||||
// item that it came from. This allows us to enable 'save object to inventory'
|
// item that it came from. This allows us to enable 'save object to inventory'
|
||||||
if (!Permissions.BypassPermissions())
|
if (!Permissions.BypassPermissions())
|
||||||
{
|
{
|
||||||
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
|
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
|
||||||
{
|
{
|
||||||
itemId = item.ID;
|
itemId = item.ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string xmlData = Utils.BytesToString(rezAsset.Data);
|
string xmlData = Utils.BytesToString(rezAsset.Data);
|
||||||
SceneObjectGroup group = new SceneObjectGroup(itemId, xmlData, true);
|
SceneObjectGroup group = new SceneObjectGroup(itemId, xmlData, true);
|
||||||
|
|
||||||
if (!Permissions.CanRezObject(
|
if (!Permissions.CanRezObject(
|
||||||
group.Children.Count, remoteClient.AgentId, pos)
|
group.Children.Count, remoteClient.AgentId, pos)
|
||||||
&& !attachment)
|
&& !attachment)
|
||||||
|
@ -2352,12 +2351,12 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
group.ClearPartAttachmentData();
|
group.ClearPartAttachmentData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!attachment)
|
if (!attachment)
|
||||||
{
|
{
|
||||||
// Fire on_rez
|
// Fire on_rez
|
||||||
group.CreateScriptInstances(0, true, DefaultScriptEngine, 0);
|
group.CreateScriptInstances(0, true, DefaultScriptEngine, 0);
|
||||||
|
|
||||||
rootPart.ScheduleFullUpdate();
|
rootPart.ScheduleFullUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2501,7 +2500,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
DeRezObject(null, grp.RootPart.LocalId,
|
DeRezObject(null, grp.RootPart.LocalId,
|
||||||
grp.RootPart.GroupID, DeRezAction.Return, UUID.Zero);
|
grp.RootPart.GroupID, DeRezAction.Return, UUID.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2633,7 +2632,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient);
|
m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
private IConfig m_ScriptConfig;
|
private IConfig m_ScriptConfig;
|
||||||
private ICompiler m_Compiler;
|
private ICompiler m_Compiler;
|
||||||
private int m_MinThreads;
|
private int m_MinThreads;
|
||||||
private int m_MaxThreads;
|
private int m_MaxThreads ;
|
||||||
private int m_IdleTimeout;
|
private int m_IdleTimeout;
|
||||||
private int m_StackSize;
|
private int m_StackSize;
|
||||||
private int m_SleepTime;
|
private int m_SleepTime;
|
||||||
|
@ -72,8 +72,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
private bool m_Enabled = false;
|
private bool m_Enabled = false;
|
||||||
private bool m_InitialStartup = true;
|
private bool m_InitialStartup = true;
|
||||||
|
|
||||||
// disable warning: need to keep a reference to XEngine.EventManager
|
// disable warning: need to keep a reference to XEngine.EventManager
|
||||||
// alive to avoid it being garbage collected
|
// alive to avoid it being garbage collected
|
||||||
#pragma warning disable 414
|
#pragma warning disable 414
|
||||||
private EventManager m_EventManager;
|
private EventManager m_EventManager;
|
||||||
#pragma warning restore 414
|
#pragma warning restore 414
|
||||||
|
@ -85,8 +85,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
|
|
||||||
// Maps the local id to the script inventory items in it
|
// Maps the local id to the script inventory items in it
|
||||||
|
|
||||||
private Dictionary<uint, List<UUID>> m_PrimObjects =
|
private Dictionary<uint, List<UUID> > m_PrimObjects =
|
||||||
new Dictionary<uint, List<UUID>>();
|
new Dictionary<uint, List<UUID> >();
|
||||||
|
|
||||||
// Maps the UUID above to the script instance
|
// Maps the UUID above to the script instance
|
||||||
|
|
||||||
|
@ -105,8 +105,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
|
|
||||||
// List the scripts running in each appdomain
|
// List the scripts running in each appdomain
|
||||||
|
|
||||||
private Dictionary<UUID, List<UUID>> m_DomainScripts =
|
private Dictionary<UUID, List<UUID> > m_DomainScripts =
|
||||||
new Dictionary<UUID, List<UUID>>();
|
new Dictionary<UUID, List<UUID> >();
|
||||||
|
|
||||||
private Queue m_CompileQueue = new Queue(100);
|
private Queue m_CompileQueue = new Queue(100);
|
||||||
IWorkItemResult m_CurrentCompile = null;
|
IWorkItemResult m_CurrentCompile = null;
|
||||||
|
@ -152,7 +152,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
|
|
||||||
if (m_ScriptConfig == null)
|
if (m_ScriptConfig == null)
|
||||||
{
|
{
|
||||||
// m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled");
|
// m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100);
|
m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100);
|
||||||
m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60);
|
m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60);
|
||||||
string priority = m_ScriptConfig.GetString("Priority", "BelowNormal");
|
string priority = m_ScriptConfig.GetString("Priority", "BelowNormal");
|
||||||
m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue", 300);
|
m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300);
|
||||||
m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144);
|
m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144);
|
||||||
m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000;
|
m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000;
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
if (m_SleepTime > 0)
|
if (m_SleepTime > 0)
|
||||||
{
|
{
|
||||||
m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
|
m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
|
||||||
new Object[] { m_SleepTime });
|
new Object[]{ m_SleepTime });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_SaveTime > 0)
|
if (m_SaveTime > 0)
|
||||||
|
@ -268,7 +268,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
if (saveTime > 0)
|
if (saveTime > 0)
|
||||||
System.Threading.Thread.Sleep(saveTime);
|
System.Threading.Thread.Sleep(saveTime);
|
||||||
|
|
||||||
// m_log.Debug("[XEngine] Backing up script states");
|
// m_log.Debug("[XEngine] Backing up script states");
|
||||||
|
|
||||||
List<IScriptInstance> instances = new List<IScriptInstance>();
|
List<IScriptInstance> instances = new List<IScriptInstance>();
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
System.Threading.Thread.Sleep(sleepTime);
|
System.Threading.Thread.Sleep(sleepTime);
|
||||||
|
|
||||||
m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
|
m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
|
||||||
new Object[] { sleepTime });
|
new Object[]{ sleepTime });
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -351,12 +351,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
int colon = firstline.IndexOf(':');
|
int colon = firstline.IndexOf(':');
|
||||||
if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1)
|
if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1)
|
||||||
{
|
{
|
||||||
string engineName = firstline.Substring(2, colon - 2);
|
string engineName = firstline.Substring(2, colon-2);
|
||||||
|
|
||||||
if (names.Contains(engineName))
|
if (names.Contains(engineName))
|
||||||
{
|
{
|
||||||
engine = engineName;
|
engine = engineName;
|
||||||
script = "//" + script.Substring(script.IndexOf(':') + 1);
|
script = "//" + script.Substring(script.IndexOf(':')+1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -365,21 +365,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
SceneObjectPart part =
|
SceneObjectPart part =
|
||||||
m_Scene.GetSceneObjectPart(
|
m_Scene.GetSceneObjectPart(
|
||||||
localID);
|
localID);
|
||||||
|
|
||||||
TaskInventoryItem item =
|
TaskInventoryItem item =
|
||||||
part.Inventory.GetInventoryItem(itemID);
|
part.Inventory.GetInventoryItem(itemID);
|
||||||
|
|
||||||
ScenePresence presence =
|
ScenePresence presence =
|
||||||
m_Scene.GetScenePresence(
|
m_Scene.GetScenePresence(
|
||||||
item.OwnerID);
|
item.OwnerID);
|
||||||
|
|
||||||
if (presence != null)
|
if (presence != null)
|
||||||
{
|
{
|
||||||
presence.ControllingClient.SendAgentAlertMessage(
|
presence.ControllingClient.SendAgentAlertMessage(
|
||||||
"Selected engine unavailable. " +
|
"Selected engine unavailable. "+
|
||||||
"Running script on " +
|
"Running script on "+
|
||||||
ScriptEngineName,
|
ScriptEngineName,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
if (engine != ScriptEngineName)
|
if (engine != ScriptEngineName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Object[] parms = new Object[] { localID, itemID, script, startParam, postOnRez, (StateSource)stateSource };
|
Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource};
|
||||||
|
|
||||||
if (stateSource == (int)StateSource.ScriptedRez)
|
if (stateSource == (int)StateSource.ScriptedRez)
|
||||||
{
|
{
|
||||||
|
@ -453,7 +453,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
Object[] p = (Object[])parm;
|
Object[] p = (Object[])parm;
|
||||||
uint localID = (uint)p[0];
|
uint localID = (uint)p[0];
|
||||||
UUID itemID = (UUID)p[1];
|
UUID itemID = (UUID)p[1];
|
||||||
string script = (string)p[2];
|
string script =(string)p[2];
|
||||||
int startParam = (int)p[3];
|
int startParam = (int)p[3];
|
||||||
bool postOnRez = (bool)p[4];
|
bool postOnRez = (bool)p[4];
|
||||||
StateSource stateSource = (StateSource)p[5];
|
StateSource stateSource = (StateSource)p[5];
|
||||||
|
@ -469,7 +469,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
{
|
{
|
||||||
Log.Error("[Script] SceneObjectPart unavailable. Script NOT started.");
|
Log.Error("[Script] SceneObjectPart unavailable. Script NOT started.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID);
|
TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID);
|
||||||
if (item == null)
|
if (item == null)
|
||||||
|
@ -477,8 +477,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
|
|
||||||
UUID assetID = item.AssetID;
|
UUID assetID = item.AssetID;
|
||||||
|
|
||||||
// m_log.DebugFormat("[XEngine] Compiling script {0} ({1})",
|
// m_log.DebugFormat("[XEngine] Compiling script {0} ({1})",
|
||||||
// item.Name, itemID.ToString());
|
// item.Name, itemID.ToString());
|
||||||
|
|
||||||
ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID);
|
ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID);
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
}
|
}
|
||||||
catch (Exception e2) // LEGIT: User Scripting
|
catch (Exception e2) // LEGIT: User Scripting
|
||||||
{
|
{
|
||||||
m_log.Error("[XEngine]: " +
|
m_log.Error("[XEngine]: "+
|
||||||
"Error displaying error in-world: " +
|
"Error displaying error in-world: " +
|
||||||
e2.ToString());
|
e2.ToString());
|
||||||
m_log.Error("[XEngine]: " +
|
m_log.Error("[XEngine]: " +
|
||||||
|
@ -537,17 +537,27 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AppDomainSetup appSetup = new AppDomainSetup();
|
AppDomainSetup appSetup = new AppDomainSetup();
|
||||||
// appSetup.ApplicationBase = Path.Combine(
|
// appSetup.ApplicationBase = Path.Combine(
|
||||||
// "ScriptEngines",
|
// "ScriptEngines",
|
||||||
// m_Scene.RegionInfo.RegionID.ToString());
|
// m_Scene.RegionInfo.RegionID.ToString());
|
||||||
|
|
||||||
Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
|
Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
|
||||||
Evidence evidence = new Evidence(baseEvidence);
|
Evidence evidence = new Evidence(baseEvidence);
|
||||||
|
|
||||||
m_AppDomains[appDomain] =
|
AppDomain sandbox =
|
||||||
AppDomain.CreateDomain(
|
AppDomain.CreateDomain(
|
||||||
m_Scene.RegionInfo.RegionID.ToString(),
|
m_Scene.RegionInfo.RegionID.ToString(),
|
||||||
evidence, appSetup);
|
evidence, appSetup);
|
||||||
|
/*
|
||||||
|
PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
|
||||||
|
AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
|
||||||
|
PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
|
||||||
|
PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
|
||||||
|
CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
|
||||||
|
sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
|
||||||
|
sandbox.SetAppDomainPolicy(sandboxPolicy);
|
||||||
|
*/
|
||||||
|
m_AppDomains[appDomain] = sandbox;
|
||||||
|
|
||||||
m_AppDomains[appDomain].AssemblyResolve +=
|
m_AppDomains[appDomain].AssemblyResolve +=
|
||||||
new ResolveEventHandler(
|
new ResolveEventHandler(
|
||||||
|
@ -603,7 +613,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
if (!m_Scripts.ContainsKey(itemID))
|
if (!m_Scripts.ContainsKey(itemID))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IScriptInstance instance = m_Scripts[itemID];
|
IScriptInstance instance=m_Scripts[itemID];
|
||||||
m_Scripts.Remove(itemID);
|
m_Scripts.Remove(itemID);
|
||||||
|
|
||||||
instance.ClearQueue();
|
instance.ClearQueue();
|
||||||
|
@ -675,17 +685,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
|
|
||||||
foreach (UUID assetID in assetIDList)
|
foreach (UUID assetID in assetIDList)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]);
|
// m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (File.Exists(m_Assemblies[assetID]))
|
if (File.Exists(m_Assemblies[assetID]))
|
||||||
File.Delete(m_Assemblies[assetID]);
|
File.Delete(m_Assemblies[assetID]);
|
||||||
|
|
||||||
if (File.Exists(m_Assemblies[assetID] + ".state"))
|
if (File.Exists(m_Assemblies[assetID]+".state"))
|
||||||
File.Delete(m_Assemblies[assetID] + ".state");
|
File.Delete(m_Assemblies[assetID]+".state");
|
||||||
|
|
||||||
if (File.Exists(m_Assemblies[assetID] + ".mdb"))
|
if (File.Exists(m_Assemblies[assetID]+".mdb"))
|
||||||
File.Delete(m_Assemblies[assetID] + ".mdb");
|
File.Delete(m_Assemblies[assetID]+".mdb");
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
@ -703,7 +713,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
|
|
||||||
AppDomain.Unload(domain);
|
AppDomain.Unload(domain);
|
||||||
domain = null;
|
domain = null;
|
||||||
// m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString());
|
// m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,8 +745,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
return new XWorkItem(m_ThreadPool.QueueWorkItem(
|
return new XWorkItem(m_ThreadPool.QueueWorkItem(
|
||||||
new WorkItemCallback(this.ProcessEventHandler),
|
new WorkItemCallback(this.ProcessEventHandler),
|
||||||
parms));
|
parms));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Process a previously posted script event.
|
/// Process a previously posted script event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -747,8 +757,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
CultureInfo USCulture = new CultureInfo("en-US");
|
CultureInfo USCulture = new CultureInfo("en-US");
|
||||||
Thread.CurrentThread.CurrentCulture = USCulture;
|
Thread.CurrentThread.CurrentCulture = USCulture;
|
||||||
|
|
||||||
IScriptInstance instance = (ScriptInstance)parms;
|
IScriptInstance instance = (ScriptInstance) parms;
|
||||||
|
|
||||||
//m_log.DebugFormat("[XENGINE]: Processing event for {0}", instance);
|
//m_log.DebugFormat("[XENGINE]: Processing event for {0}", instance);
|
||||||
|
|
||||||
return instance.EventProcessor();
|
return instance.EventProcessor();
|
||||||
|
@ -763,13 +773,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
public bool PostObjectEvent(uint localID, EventParams p)
|
public bool PostObjectEvent(uint localID, EventParams p)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
lock (m_PrimObjects)
|
lock (m_PrimObjects)
|
||||||
{
|
{
|
||||||
if (!m_PrimObjects.ContainsKey(localID))
|
if (!m_PrimObjects.ContainsKey(localID))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
foreach (UUID itemID in m_PrimObjects[localID])
|
foreach (UUID itemID in m_PrimObjects[localID])
|
||||||
{
|
{
|
||||||
if (m_Scripts.ContainsKey(itemID))
|
if (m_Scripts.ContainsKey(itemID))
|
||||||
|
@ -821,7 +831,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
foreach (string s in pathList)
|
foreach (string s in pathList)
|
||||||
{
|
{
|
||||||
string path = Path.Combine(Directory.GetCurrentDirectory(),
|
string path = Path.Combine(Directory.GetCurrentDirectory(),
|
||||||
Path.Combine(s, assemblyName)) + ".dll";
|
Path.Combine(s, assemblyName))+".dll";
|
||||||
|
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
return Assembly.LoadFrom(path);
|
return Assembly.LoadFrom(path);
|
||||||
|
@ -959,7 +969,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
i.Running = prevRunning;
|
i.Running = prevRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
DoBackup(new Object[] { 0 });
|
DoBackup(new Object[] {0});
|
||||||
}
|
}
|
||||||
|
|
||||||
public IScriptApi GetApi(UUID itemID, string name)
|
public IScriptApi GetApi(UUID itemID, string name)
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright (c) 2003-2008 Niels Kokholm and Peter Sestoft.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1074,6 +1074,7 @@
|
||||||
<Reference name="XMLRPC.dll"/>
|
<Reference name="XMLRPC.dll"/>
|
||||||
<Reference name="Nini.dll" />
|
<Reference name="Nini.dll" />
|
||||||
<Reference name="log4net.dll"/>
|
<Reference name="log4net.dll"/>
|
||||||
|
<Reference name="C5.dll" />
|
||||||
|
|
||||||
<Files>
|
<Files>
|
||||||
<Match pattern="*.cs" recurse="false"/>
|
<Match pattern="*.cs" recurse="false"/>
|
||||||
|
|
Loading…
Reference in New Issue