Revert progressive texture patch from r8001 until issues can be addressed

0.6.2-post-fixes
Dahlia Trimble 2009-01-10 09:15:23 +00:00
parent a9988fa6cf
commit 630ce5b264
13 changed files with 314 additions and 431 deletions

View File

@ -204,14 +204,14 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
/// <param name="e"></param>
public void TextureRequest(Object sender, TextureRequestArgs e)
{
IClientAPI client = (IClientAPI) sender;
IClientAPI client = (IClientAPI)sender;
if (e.Priority == 1016001f) // Preview
{
if (client.Scene is Scene)
{
Scene scene = (Scene)client.Scene;
CachedUserInfo profile = scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId);
if (profile == null) // Deny unknown user
return;
@ -241,52 +241,44 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
{
ITextureSender sender = null;
// try
// {
try
{
while (true)
{
try
{
sender = m_queueSenders.Dequeue();
sender = m_queueSenders.Dequeue();
if (sender.Cancel)
if (sender.Cancel)
{
TextureSent(sender);
sender.Cancel = false;
}
else
{
bool finished = sender.SendTexturePacket();
if (finished)
{
TextureSent(sender);
sender.Cancel = false;
}
else
{
bool finished = sender.SendTexturePacket();
if (finished)
{
TextureSent(sender);
}
else
{
m_queueSenders.Enqueue(sender);
}
m_queueSenders.Enqueue(sender);
}
// Make sure that any sender we currently have can get garbage collected
sender = null;
//m_log.InfoFormat("[TEXTURE] Texture sender queue size: {0}", m_queueSenders.Count());
}
catch(Exception e)
{
m_log.ErrorFormat(
"[TEXTURE]: Texture send thread caught exception. The texture send was aborted. Exception is {0}", e);
}
// Make sure that any sender we currently have can get garbage collected
sender = null;
//m_log.InfoFormat("[TEXTURE] Texture sender queue size: {0}", m_queueSenders.Count());
}
// }
// catch (Exception e)
// {
// // TODO: Let users in the sim and those entering it and possibly an external watchdog know what has happened
// m_log.ErrorFormat(
// "[TEXTURE]: Texture send thread terminating with exception. PLEASE REBOOT YOUR SIM - TEXTURES WILL NOT BE AVAILABLE UNTIL YOU DO. Exception is {0}",
// e);
// }
}
catch (Exception e)
{
// TODO: Let users in the sim and those entering it and possibly an external watchdog know what has happened
m_log.ErrorFormat(
"[TEXTURE]: Texture send thread terminating with exception. PLEASE REBOOT YOUR SIM - TEXTURES WILL NOT BE AVAILABLE UNTIL YOU DO. Exception is {0}",
e);
}
}
/// <summary>

View File

@ -28,6 +28,7 @@
using System.Reflection;
using log4net;
using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
@ -38,11 +39,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
/// </summary>
public class TextureNotFoundSender : ITextureSender
{
// private static readonly log4net.ILog m_log
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// private static readonly log4net.ILog m_log
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// private IClientAPI m_client;
// private UUID m_textureId;
// private IClientAPI m_client;
// private UUID m_textureId;
public TextureNotFoundSender(IClientAPI client, UUID textureID)
{
@ -55,13 +56,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
public bool Sending
{
get { return false; }
set {}
set { }
}
public bool Cancel
{
get { return false; }
set {}
set { }
}
// See ITextureSender
@ -73,13 +74,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
// See ITextureSender
public bool SendTexturePacket()
{
// m_log.DebugFormat(
// "[TEXTURE NOT FOUND SENDER]: Informing the client that texture {0} cannot be found",
// m_textureId);
// m_log.DebugFormat(
// "[TEXTURE NOT FOUND SENDER]: Informing the client that texture {0} cannot be found",
// m_textureId);
// XXX Temporarily disabling as this appears to be causing client crashes on at least
// 1.19.0(5) of the Linden Second Life client.
// m_client.SendImageNotFound(m_textureId);
// m_client.SendImageNotFound(m_textureId);
return true;
}

View File

@ -56,10 +56,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
/// <summary>
/// We will allow the client to request the same texture n times before dropping further requests
///
/// This number contains repeated requests for the same texture at different resolutions (which
/// are handled since r7368). However, this situation should be handled in a more sophisticated way.
/// This number includes repeated requests for the same texture at different resolutions (which we don't
/// currently handle properly as far as I know). However, this situation should be handled in a more
/// sophisticated way.
/// </summary>
private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 15;
private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5;
/// <summary>
/// XXX Also going to limit requests for found textures.
@ -119,13 +120,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
}
else
{
// m_log.DebugFormat("[TEXTURE]: Received a request for texture {0}", e.RequestedAssetID);
// m_log.DebugFormat("[TEXTURE]: Received a request for texture {0}", e.RequestedAssetID);
if (!foundTextureLimitStrategy.AllowRequest(e.RequestedAssetID))
{
// m_log.DebugFormat(
// "[TEXTURE]: Refusing request for {0} from client {1}",
// e.RequestedAssetID, m_client.AgentId);
// m_log.DebugFormat(
// "[TEXTURE]: Refusing request for {0} from client {1}",
// e.RequestedAssetID, m_client.AgentId);
return;
}
@ -138,9 +139,9 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
// Commenting out this message for now as it causes too much noise with other
// debug messages.
// m_log.DebugFormat(
// "[TEXTURE]: Dropping requests for notified missing texture {0} for client {1} since we have received more than {2} requests",
// e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS);
// m_log.DebugFormat(
// "[TEXTURE]: Dropping requests for notified missing texture {0} for client {1} since we have received more than {2} requests",
// e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS);
}
return;
@ -148,7 +149,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
m_scene.AddPendingDownloads(1);
TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber, e.Priority);
TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber);
m_textureSenders.Add(e.RequestedAssetID, requestHandler);
m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true);
@ -195,9 +196,9 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
{
missingTextureLimitStrategy.MonitorRequests(textureID);
// m_log.DebugFormat(
// "[TEXTURE]: Queueing first TextureNotFoundSender for {0}, client {1}",
// textureID, m_client.AgentId);
// m_log.DebugFormat(
// "[TEXTURE]: Queueing first TextureNotFoundSender for {0}, client {1}",
// textureID, m_client.AgentId);
}
ITextureSender textureNotFoundSender = new TextureNotFoundSender(m_client, textureID);

View File

@ -53,7 +53,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
agent.startpos = Vector3.Zero;
agent.CapsPath = "http://wibble.com";
new TextureSender(new TestClient(agent), 0, 0, 1.0f);
new TextureSender(new TestClient(agent), 0, 0);
}
}
}

View File

@ -27,104 +27,13 @@
using System;
using System.Reflection;
using OpenMetaverse.Packets;
using log4net;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
{
public class ImageDownload
{
public const int FIRST_IMAGE_PACKET_SIZE = 600;
public const int IMAGE_PACKET_SIZE = 1000;
public OpenMetaverse.AssetTexture Texture;
public int DiscardLevel;
public float Priority;
public int CurrentPacket;
public int StopPacket;
public ImageDownload(OpenMetaverse.AssetTexture texture, int discardLevel, float priority, int packet)
{
Texture = texture;
Update(discardLevel, priority, packet);
}
/// <summary>
/// Updates an image transfer with new information and recalculates
/// offsets
/// </summary>
/// <param name="discardLevel">New requested discard level</param>
/// <param name="priority">New requested priority</param>
/// <param name="packet">New requested packet offset</param>
public void Update(int discardLevel, float priority, int packet)
{
Priority = priority;
DiscardLevel = Clamp(discardLevel, 0, Texture.LayerInfo.Length - 1);
StopPacket = GetPacketForBytePosition(Texture.LayerInfo[(Texture.LayerInfo.Length - 1) - DiscardLevel].End);
CurrentPacket = Clamp(packet, 1, TexturePacketCount());
}
/// <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()
{
return ((Texture.AssetData.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()
{
return FIRST_IMAGE_PACKET_SIZE + (CurrentPacket - 1) * IMAGE_PACKET_SIZE;
}
/// <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()
{
return Texture.AssetData.Length - (FIRST_IMAGE_PACKET_SIZE + ((TexturePacketCount() - 2) * 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);
}
/// <summary>
/// Clamp a given value between a range
/// </summary>
/// <param name="value">Value to clamp</param>
/// <param name="min">Minimum allowable value</param>
/// <param name="max">Maximum allowable value</param>
/// <returns>A value inclusively between lower and upper</returns>
static int Clamp(int value, int min, int max)
{
// First we check to see if we're greater than the max
value = (value > max) ? max : value;
// Then we check to see if we're less than the min.
value = (value < min) ? min : value;
// There's no check to see if min > max.
return value;
}
}
/// <summary>
/// A TextureSender handles the process of receiving a texture requested by the client from the
/// AssetCache, and then sending that texture back to the client.
@ -134,81 +43,90 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Records the number of times texture send has been called.
/// </summary>
public int counter = 0;
public bool ImageLoaded = false;
/// <summary>
/// Holds the texture asset to send.
/// </summary>
private AssetBase m_asset;
private bool m_cancel = false;
private bool m_sending = false;
private bool sendFirstPacket = false;
private int initialDiscardLevel = 0;
private int initialPacketNum = 0;
private float initialPriority = 0.0f;
private ImageDownload download;
//public UUID assetID { get { return m_asset.FullID; } }
// private bool m_cancel = false;
// See ITextureSender
// private bool m_sending = false;
/// <summary>
/// This is actually the number of extra packets required to send the texture data! We always assume
/// at least one is required.
/// </summary>
private int NumPackets = 0;
/// <summary>
/// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts
/// at the 600th byte (0th indexed).
/// </summary>
private int PacketCounter = 0;
private int RequestedDiscardLevel = -1;
private IClientAPI RequestUser;
private uint StartPacketNumber = 0;
public TextureSender(IClientAPI client, int discardLevel, uint packetNumber, float priority)
public TextureSender(IClientAPI client, int discardLevel, uint packetNumber)
{
RequestUser = client;
initialDiscardLevel = discardLevel;
initialPacketNum = (int)packetNumber;
initialPriority = priority;
RequestedDiscardLevel = discardLevel;
StartPacketNumber = packetNumber;
}
#region ITextureSender Members
public bool Cancel
{
get { return m_cancel; }
set { m_cancel = value; }
get { return false; }
set
{
// m_cancel = value;
}
}
public bool Sending
{
get { return m_sending; }
set { m_sending = value; }
get { return false; }
set
{
// m_sending = value;
}
}
// See ITextureSender
public void UpdateRequest(int discardLevel, uint packetNumber)
{
if (download == null)
return;
lock (download)
{
if (discardLevel < download.DiscardLevel)
m_log.DebugFormat("Image download {0} is changing from DiscardLevel {1} to {2}",
m_asset.FullID, download.DiscardLevel, discardLevel);
if (packetNumber != download.CurrentPacket)
m_log.DebugFormat("Image download {0} is changing from Packet {1} to {2}",
m_asset.FullID, download.CurrentPacket, packetNumber);
download.Update(discardLevel, download.Priority, (int)packetNumber);
sendFirstPacket = true;
}
RequestedDiscardLevel = discardLevel;
StartPacketNumber = packetNumber;
PacketCounter = (int)StartPacketNumber;
}
// See ITextureSender
public bool SendTexturePacket()
{
if (download != null && !m_cancel && (sendFirstPacket || download.CurrentPacket <= download.StopPacket))
//m_log.DebugFormat("[TEXTURE SENDER]: Sending packet for {0}", m_asset.FullID);
SendPacket();
counter++;
if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) ||
((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets / (RequestedDiscardLevel + 1)))))
{
SendPacket();
return false;
}
else
{
m_sending = false;
m_cancel = true;
sendFirstPacket = false;
return true;
}
return false;
}
#endregion
@ -220,52 +138,9 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
public void TextureReceived(AssetBase asset)
{
m_asset = asset;
try
{
OpenMetaverse.AssetTexture texture = new OpenMetaverse.AssetTexture(m_asset.FullID, m_asset.Data);
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)
{
download = new ImageDownload(texture, initialDiscardLevel, initialPriority, initialPacketNum);
ImageLoaded = true;
m_sending = true;
m_cancel = false;
sendFirstPacket = true;
return;
}
else
{
m_log.Error("JPEG2000 texture decoding succeeded, but sanity check failed for " +
m_asset.FullID.ToString());
}
}
else
{
m_log.Error("JPEG2000 texture decoding failed for " + m_asset.FullID.ToString());
}
}
catch (Exception ex)
{
m_log.Error("JPEG2000 texture decoding threw an exception for " + m_asset.FullID.ToString(), ex);
}
ImageLoaded = false;
m_sending = false;
m_cancel = true;
NumPackets = CalculateNumPackets(asset.Data.Length);
PacketCounter = (int)StartPacketNumber;
ImageLoaded = true;
}
/// <summary>
@ -273,48 +148,66 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
/// </summary>
private void SendPacket()
{
lock (download)
if (PacketCounter <= NumPackets)
{
if (sendFirstPacket)
if (PacketCounter == 0)
{
sendFirstPacket = false;
if (m_asset.Data.Length <= ImageDownload.FIRST_IMAGE_PACKET_SIZE)
if (NumPackets == 0)
{
RequestUser.SendImageFirstPart(1, m_asset.FullID, (uint)m_asset.Data.Length, m_asset.Data, 2);
return;
PacketCounter++;
}
else
{
byte[] firstImageData = new byte[ImageDownload.FIRST_IMAGE_PACKET_SIZE];
try { Buffer.BlockCopy(m_asset.Data, 0, firstImageData, 0, ImageDownload.FIRST_IMAGE_PACKET_SIZE); }
catch (Exception)
{
m_log.Error("Texture data copy failed on first packet for " + m_asset.FullID.ToString());
m_cancel = true;
m_sending = false;
return;
}
RequestUser.SendImageFirstPart((ushort)download.TexturePacketCount(), m_asset.FullID, (uint)m_asset.Data.Length, firstImageData, 2);
byte[] ImageData1 = new byte[600];
Array.Copy(m_asset.Data, 0, ImageData1, 0, 600);
RequestUser.SendImageFirstPart(
(ushort)(NumPackets), m_asset.FullID, (uint)m_asset.Data.Length, ImageData1, 2);
PacketCounter++;
}
}
int imagePacketSize = (download.CurrentPacket == download.TexturePacketCount() - 1) ?
download.LastPacketSize() : ImageDownload.IMAGE_PACKET_SIZE;
byte[] imageData = new byte[imagePacketSize];
try { Buffer.BlockCopy(m_asset.Data, download.CurrentBytePosition(), imageData, 0, imagePacketSize); }
catch (Exception)
else
{
m_log.Error("Texture data copy failed for " + m_asset.FullID.ToString());
m_cancel = true;
m_sending = false;
return;
}
int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1));
if (size > 1000) size = 1000;
byte[] imageData = new byte[size];
try
{
Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), imageData, 0, size);
}
catch (ArgumentOutOfRangeException)
{
m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" +
m_asset.FullID.ToString());
return;
}
RequestUser.SendImageNextPart((ushort)download.CurrentPacket, m_asset.FullID, imageData);
++download.CurrentPacket;
RequestUser.SendImageNextPart((ushort)PacketCounter, m_asset.FullID, imageData);
PacketCounter++;
}
}
}
/// <summary>
/// Calculate the number of packets that will be required to send the texture loaded into this sender
/// This is actually the number of 1000 byte packets not including an initial 600 byte packet...
/// </summary>
/// <param name="length"></param>
/// <returns></returns>
private int CalculateNumPackets(int length)
{
int numPackets = 0;
if (length > 600)
{
//over 600 bytes so split up file
int restData = (length - 600);
int restPackets = ((restData + 999) / 1000);
numPackets = restPackets;
}
return numPackets;
}
}
}

View File

@ -30,6 +30,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using OpenMetaverse;
using OpenMetaverse.Packets;
using log4net;
using Nini.Config;
using Nwc.XmlRpc;
@ -101,10 +102,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
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 Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>();
private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong, Scene>();
private IMessageTransferModule m_TransferModule = null;
#region IRegionModule Members
@ -124,9 +125,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
if (!m_scenes.ContainsKey(scene.RegionInfo.RegionHandle))
m_scenes[scene.RegionInfo.RegionHandle] = scene;
}
scene.RegisterModuleInterface<IFriendsModule>(this);
scene.EventManager.OnNewClient += OnNewClient;
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
@ -179,7 +180,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
lock (m_rootAgents)
{
List<ScenePresence> friendsHere = new List<ScenePresence>();
try
{
UUID agentID = new UUID((string)requestData["agentID"]);
@ -212,7 +213,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);
}
@ -374,24 +375,24 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
}
return returnAgent;
}
public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage)
{
CachedUserInfo userInfo = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(fromUserId);
if (userInfo != null)
{
GridInstantMessage msg = new GridInstantMessage(
toUserClient.Scene, fromUserId, userInfo.UserProfile.Name, toUserClient.AgentId,
(byte)InstantMessageDialog.FriendshipOffered, offerMessage, false, Vector3.Zero);
(byte)InstantMessageDialog.FriendshipOffered, offerMessage, false, Vector3.Zero);
FriendshipOffered(msg);
}
else
{
m_log.ErrorFormat("[FRIENDS]: No user found for id {0} in OfferFriendship()", fromUserId);
}
}
}
#region FriendRequestHandling
@ -413,7 +414,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
FriendshipDeclined(client, im);
}
}
/// <summary>
/// Invoked when a user offers a friendship.
/// </summary>
@ -448,14 +449,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 remote, it will cause a OnGridInstantMessage on the remote server
m_TransferModule.SendInstantMessage(im,
delegate(bool success)
delegate(bool success)
{
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
}
);
}
}
}
/// <summary>
/// Invoked when a user accepts a friendship offer.
/// </summary>
@ -464,9 +465,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
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})",
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>
/// Invoked when a user declines a friendship offer.
/// </summary>
@ -477,7 +478,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
{
UUID fromAgentID = new UUID(im.fromAgentID);
UUID toAgentID = new UUID(im.toAgentID);
// declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator
// toAgentID is initiator, fromAgentID declined friendship
m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})",
@ -487,14 +488,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
// Send the decline to whoever is the destination.
GridInstantMessage msg = new GridInstantMessage(client.Scene, fromAgentID, client.Name, toAgentID,
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 remote, it will cause a OnGridInstantMessage on the remote server
m_TransferModule.SendInstantMessage(msg,
delegate(bool success) {
delegate(bool success)
{
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
}
);
);
}
private void OnGridInstantMessage(GridInstantMessage msg)
@ -510,7 +512,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
{
// this should succeed as we *know* the root agent is here.
m_TransferModule.SendInstantMessage(msg,
delegate(bool success) {
delegate(bool success)
{
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
}
);
@ -566,7 +569,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
client.Name, client.AgentId, agentID, friendID);
// 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.
lock (m_friendLists)
@ -609,7 +612,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
if (m_TransferModule != null)
{
m_TransferModule.SendInstantMessage(msg,
delegate(bool success) {
delegate(bool success)
{
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
}
);
@ -633,7 +637,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
if (m_TransferModule != null)
{
m_TransferModule.SendInstantMessage(msg,
delegate(bool success) {
delegate(bool success)
{
m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
}
);
@ -809,16 +814,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...
List<UUID> friendIDsToSendTo = new List<UUID>();
List<UUID> candidateFriendIDsToReceive = new List<UUID>();
foreach (FriendListItem item in friendList)
{
if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0)
{
// 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);
if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0)
if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0)
candidateFriendIDsToReceive.Add(item.Friend);
}
}
@ -857,7 +862,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
if (iAmOnline)
{
List<UUID> friendIDsToReceive = new List<UUID>();
for (int i = candidateFriendIDsToReceive.Count - 1; i >= 0; --i)
{
UUID uuid = candidateFriendIDsToReceive[i];
@ -867,11 +872,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
friendIDsToReceive.Add(uuid);
}
}
m_log.DebugFormat(
"[FRIEND]: Sending {0} online friends to {1}", friendIDsToReceive.Count, client.Name);
if (friendIDsToReceive.Count > 0)
if (friendIDsToReceive.Count > 0)
client.SendAgentOnline(friendIDsToReceive.ToArray());
// clear them for a possible second iteration; we don't have to repeat this
@ -914,7 +919,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
if (friendIDsToSendTo.Count > 0)
{
// 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)
{
ulong handle = friendRegions[uuid].regionHandle; // this can't fail as we filtered above already
@ -993,5 +998,5 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
}
}
#endregion
#endregion
}

View File

@ -31,6 +31,7 @@ using System.Reflection;
using System.Text;
using System.Timers;
using OpenMetaverse;
using OpenMetaverse.Packets;
using log4net;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
@ -42,12 +43,12 @@ namespace OpenSim.Region.Environment.Scenes
public partial class Scene
{
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Allows asynchronous derezzing of objects from the scene into a client's inventory.
/// </summary>
protected AsyncSceneObjectGroupDeleter m_asyncSceneObjectDeleter;
protected AsyncSceneObjectGroupDeleter m_asyncSceneObjectDeleter;
/// <summary>
/// Start all the scripts in the scene which should be started.
@ -60,14 +61,14 @@ namespace OpenSim.Region.Environment.Scenes
{
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)
{
IMoneyModule money=RequestModuleInterface<IMoneyModule>();
IMoneyModule money = RequestModuleInterface<IMoneyModule>();
if (money != null)
{
money.ApplyUploadCharge(agentID);
@ -145,9 +146,9 @@ namespace OpenSim.Region.Environment.Scenes
else
{
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);
}
}
}
/// <summary>
@ -175,7 +176,7 @@ namespace OpenSim.Region.Environment.Scenes
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
return UUID.Zero;
}
remoteClient.SendAgentAlertMessage("Notecard saved", false);
}
else if ((InventoryType)item.InvType == InventoryType.LSL)
@ -185,7 +186,7 @@ namespace OpenSim.Region.Environment.Scenes
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
return UUID.Zero;
}
remoteClient.SendAgentAlertMessage("Script saved", false);
}
@ -204,10 +205,10 @@ namespace OpenSim.Region.Environment.Scenes
else
{
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);
}
}
return UUID.Zero;
}
@ -283,7 +284,7 @@ namespace OpenSim.Region.Environment.Scenes
{
part.Inventory.RemoveScriptInstance(item.ItemID);
}
// Update item with new asset
item.AssetID = asset.FullID;
group.UpdateInventoryItem(item);
@ -335,9 +336,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="name">The name 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>
/* public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
UUID itemID, string name, string description,
uint nextOwnerMask)*/
/* public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
UUID itemID, string name, string description,
uint nextOwnerMask)*/
public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
UUID itemID, InventoryItemBase itemUpd)
{
@ -426,7 +427,7 @@ namespace OpenSim.Region.Environment.Scenes
{
return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero);
}
/// <summary>
/// Give an inventory item from one user to another
/// </summary>
@ -485,7 +486,7 @@ namespace OpenSim.Region.Environment.Scenes
itemCopy.AssetType = item.AssetType;
itemCopy.InvType = item.InvType;
itemCopy.Folder = recipientFolderId;
if (Permissions.PropagatePermissions())
{
if (item.InvType == 6)
@ -502,7 +503,7 @@ namespace OpenSim.Region.Environment.Scenes
if ((item.CurrentPermissions & 8) != 0) // Propagate slam bit
{
itemCopy.CurrentPermissions = item.NextPermissions;
itemCopy.BasePermissions=itemCopy.CurrentPermissions;
itemCopy.BasePermissions = itemCopy.CurrentPermissions;
itemCopy.CurrentPermissions |= 8;
}
@ -557,10 +558,10 @@ namespace OpenSim.Region.Environment.Scenes
m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemId.ToString() + ", no root folder");
return null;
}
return null;
}
/// <summary>
/// Give an entire inventory folder from one user to another. The entire contents (including all descendent
/// folders) is given.
@ -588,24 +589,24 @@ namespace OpenSim.Region.Environment.Scenes
return null;
}
if (!senderUserInfo.HasReceivedInventory)
{
m_log.DebugFormat(
"[AGENT INVENTORY]: Could not give inventory folder - have not yet received inventory for {0}",
senderId);
return null;
}
InventoryFolderImpl folder = senderUserInfo.RootFolder.FindFolder(folderId);
if (null == folder)
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Could not find inventory folder {0} to give", folderId);
return null;
return null;
}
CachedUserInfo recipientUserInfo
@ -618,30 +619,30 @@ namespace OpenSim.Region.Environment.Scenes
return null;
}
if (recipientParentFolderId == UUID.Zero)
recipientParentFolderId = recipientUserInfo.RootFolder.ID;
UUID newFolderId = UUID.Random();
recipientUserInfo.CreateFolder(folder.Name, newFolderId, (ushort)folder.Type, recipientParentFolderId);
// XXX: Messy - we should really get this back in the CreateFolder call
InventoryFolderImpl copiedFolder = recipientUserInfo.RootFolder.FindFolder(newFolderId);
// Give all the subfolders
List<InventoryFolderImpl> subFolders = folder.RequestListOfFolderImpls();
foreach (InventoryFolderImpl childFolder in subFolders)
{
GiveInventoryFolder(recipientId, senderId, childFolder.ID, copiedFolder.ID);
}
}
// Give all the items
List<InventoryItemBase> items = folder.RequestListOfItems();
foreach (InventoryItemBase item in items)
{
GiveInventoryItem(recipientId, senderId, item.ID, copiedFolder.ID);
}
return copiedFolder;
}
@ -879,7 +880,7 @@ namespace OpenSim.Region.Environment.Scenes
if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
return;
if (transactionID == UUID.Zero)
{
CachedUserInfo userInfo
@ -890,7 +891,7 @@ namespace OpenSim.Region.Environment.Scenes
ScenePresence presence;
TryGetAvatar(remoteClient.AgentId, out presence);
byte[] data = null;
if (invType == 3 && presence != null) // OpenMetaverse.asset.assettype.landmark = 3 - needs to be turned into an enum
{
Vector3 pos = presence.AbsolutePosition;
@ -989,8 +990,8 @@ namespace OpenSim.Region.Environment.Scenes
{
if (ent is SceneObjectGroup)
{
if (((SceneObjectGroup) ent).HasChildPrim(localID))
return (SceneObjectGroup) ent;
if (((SceneObjectGroup)ent).HasChildPrim(localID))
return (SceneObjectGroup)ent;
}
}
return null;
@ -1425,7 +1426,7 @@ namespace OpenSim.Region.Environment.Scenes
}
}
else // Updating existing item with new perms etc
{
{
IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
if (agentTransactions != null)
{
@ -1507,7 +1508,7 @@ namespace OpenSim.Region.Environment.Scenes
}
}
else // script has been rezzed directly into a prim's inventory
{
{
SceneObjectPart part = GetSceneObjectPart(itemBase.Folder);
if (part == null)
return;
@ -1517,10 +1518,10 @@ namespace OpenSim.Region.Environment.Scenes
if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
return;
if (!Permissions.CanCreateObjectInventory(
itemBase.InvType, part.UUID, remoteClient.AgentId))
return;
itemBase.InvType, part.UUID, remoteClient.AgentId))
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}"));
AssetCache.AddAsset(asset);
@ -1733,7 +1734,7 @@ namespace OpenSim.Region.Environment.Scenes
grp.UUID,
remoteClient.AgentId);
permissionToDelete = permissionToTake;
if (permissionToDelete)
{
AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
@ -1803,7 +1804,7 @@ namespace OpenSim.Region.Environment.Scenes
//
CachedUserInfo userInfo;
if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
action == DeRezAction.SaveToExistingUserInventoryItem)
{
// Take or take copy require a taker
@ -1846,18 +1847,18 @@ namespace OpenSim.Region.Environment.Scenes
//
InventoryFolderBase folder = null;
InventoryItemBase item = null;
InventoryItemBase item = null;
if (DeRezAction.SaveToExistingUserInventoryItem == action)
{
item = userInfo.RootFolder.FindItem(
objectGroup.RootPart.FromUserInventoryItemID);
if (null == item)
{
m_log.DebugFormat(
"[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
objectGroup.Name, objectGroup.UUID);
"[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
objectGroup.Name, objectGroup.UUID);
return UUID.Zero;
}
}
@ -1936,7 +1937,7 @@ namespace OpenSim.Region.Environment.Scenes
item.InvType = (int)InventoryType.Object;
item.Folder = folder.ID;
item.Owner = userInfo.UserProfile.ID;
}
AssetBase asset = CreateAsset(
@ -1946,10 +1947,10 @@ namespace OpenSim.Region.Environment.Scenes
Utils.StringToBytes(sceneObjectXml));
AssetCache.AddAsset(asset);
assetID = asset.FullID;
if (DeRezAction.SaveToExistingUserInventoryItem == action)
{
item.AssetID = asset.FullID;
{
item.AssetID = asset.FullID;
userInfo.UpdateItem(item);
}
else
@ -1958,8 +1959,8 @@ namespace OpenSim.Region.Environment.Scenes
if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions())
{
uint perms=objectGroup.GetEffectivePermissions();
uint nextPerms=(perms & 7) << 13;
uint perms = objectGroup.GetEffectivePermissions();
uint nextPerms = (perms & 7) << 13;
if ((nextPerms & (uint)PermissionMask.Copy) == 0)
perms &= ~(uint)PermissionMask.Copy;
if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
@ -1990,7 +1991,7 @@ namespace OpenSim.Region.Environment.Scenes
item.AssetType = asset.Type;
userInfo.AddItem(item);
if (remoteClient != null && item.Owner == remoteClient.AgentId)
{
remoteClient.SendInventoryItemCreateUpdate(item);
@ -2002,10 +2003,10 @@ namespace OpenSim.Region.Environment.Scenes
{
notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item);
}
}
}
}
}
return assetID;
}
@ -2019,11 +2020,11 @@ namespace OpenSim.Region.Environment.Scenes
m_log.InfoFormat("[ATTACHMENT]: Save request for {0} which is unchanged", grp.UUID);
return;
}
m_log.InfoFormat(
"[ATTACHMENT]: Updating asset for attachment {0}, attachpoint {1}",
"[ATTACHMENT]: Updating asset for attachment {0}, attachpoint {1}",
grp.UUID, grp.GetAttachmentPoint());
string sceneObjectXml = objectGroup.ToXmlString();
CachedUserInfo userInfo =
@ -2213,7 +2214,7 @@ namespace OpenSim.Region.Environment.Scenes
Vector3 pos = GetNewRezLocation(
RayStart, RayEnd, RayTargetID, Quaternion.Identity,
BypassRayCast, bRayEndIsIntersection,true,scale, false);
BypassRayCast, bRayEndIsIntersection, true, scale, false);
// Rez object
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
@ -2235,20 +2236,20 @@ namespace OpenSim.Region.Environment.Scenes
if (rezAsset != null)
{
UUID itemId = UUID.Zero;
// 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'
if (!Permissions.BypassPermissions())
{
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
{
{
itemId = item.ID;
}
}
string xmlData = Utils.BytesToString(rezAsset.Data);
SceneObjectGroup group = new SceneObjectGroup(itemId, xmlData, true);
if (!Permissions.CanRezObject(
group.Children.Count, remoteClient.AgentId, pos)
&& !attachment)
@ -2345,12 +2346,12 @@ namespace OpenSim.Region.Environment.Scenes
group.ClearPartAttachmentData();
}
}
if (!attachment)
{
// Fire on_rez
group.CreateScriptInstances(0, true, DefaultScriptEngine, 0);
rootPart.ScheduleFullUpdate();
}
@ -2489,7 +2490,7 @@ namespace OpenSim.Region.Environment.Scenes
DeRezObject(null, grp.RootPart.LocalId,
grp.RootPart.GroupID, DeRezAction.Return, UUID.Zero);
}
return true;
}
@ -2621,7 +2622,7 @@ namespace OpenSim.Region.Environment.Scenes
}
}
m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient);
}

View File

@ -63,7 +63,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
private IConfig m_ScriptConfig;
private ICompiler m_Compiler;
private int m_MinThreads;
private int m_MaxThreads ;
private int m_MaxThreads;
private int m_IdleTimeout;
private int m_StackSize;
private int m_SleepTime;
@ -72,8 +72,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
private bool m_Enabled = false;
private bool m_InitialStartup = true;
// disable warning: need to keep a reference to XEngine.EventManager
// alive to avoid it being garbage collected
// disable warning: need to keep a reference to XEngine.EventManager
// alive to avoid it being garbage collected
#pragma warning disable 414
private EventManager m_EventManager;
#pragma warning restore 414
@ -85,8 +85,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// Maps the local id to the script inventory items in it
private Dictionary<uint, List<UUID> > m_PrimObjects =
new Dictionary<uint, List<UUID> >();
private Dictionary<uint, List<UUID>> m_PrimObjects =
new Dictionary<uint, List<UUID>>();
// Maps the UUID above to the script instance
@ -105,8 +105,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// List the scripts running in each appdomain
private Dictionary<UUID, List<UUID> > m_DomainScripts =
new Dictionary<UUID, List<UUID> >();
private Dictionary<UUID, List<UUID>> m_DomainScripts =
new Dictionary<UUID, List<UUID>>();
private Queue m_CompileQueue = new Queue(100);
IWorkItemResult m_CurrentCompile = null;
@ -152,7 +152,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
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;
}
@ -172,7 +172,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100);
m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60);
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_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000;
@ -239,7 +239,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (m_SleepTime > 0)
{
m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
new Object[]{ m_SleepTime });
new Object[] { m_SleepTime });
}
if (m_SaveTime > 0)
@ -268,7 +268,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (saveTime > 0)
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>();
@ -319,7 +319,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
System.Threading.Thread.Sleep(sleepTime);
m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
new Object[]{ sleepTime });
new Object[] { sleepTime });
return 0;
}
@ -351,12 +351,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
int colon = firstline.IndexOf(':');
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))
{
engine = engineName;
script = "//" + script.Substring(script.IndexOf(':')+1);
script = "//" + script.Substring(script.IndexOf(':') + 1);
}
else
{
@ -365,21 +365,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
SceneObjectPart part =
m_Scene.GetSceneObjectPart(
localID);
TaskInventoryItem item =
part.Inventory.GetInventoryItem(itemID);
ScenePresence presence =
ScenePresence presence =
m_Scene.GetScenePresence(
item.OwnerID);
if (presence != null)
{
presence.ControllingClient.SendAgentAlertMessage(
"Selected engine unavailable. "+
"Running script on "+
ScriptEngineName,
false);
presence.ControllingClient.SendAgentAlertMessage(
"Selected engine unavailable. " +
"Running script on " +
ScriptEngineName,
false);
}
}
}
@ -389,7 +389,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (engine != ScriptEngineName)
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)
{
@ -453,7 +453,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
Object[] p = (Object[])parm;
uint localID = (uint)p[0];
UUID itemID = (UUID)p[1];
string script =(string)p[2];
string script = (string)p[2];
int startParam = (int)p[3];
bool postOnRez = (bool)p[4];
StateSource stateSource = (StateSource)p[5];
@ -469,7 +469,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
Log.Error("[Script] SceneObjectPart unavailable. Script NOT started.");
return false;
}
}
TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID);
if (item == null)
@ -477,8 +477,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
UUID assetID = item.AssetID;
// m_log.DebugFormat("[XEngine] Compiling script {0} ({1})",
// item.Name, itemID.ToString());
// m_log.DebugFormat("[XEngine] Compiling script {0} ({1})",
// item.Name, itemID.ToString());
ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID);
@ -509,7 +509,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
catch (Exception e2) // LEGIT: User Scripting
{
m_log.Error("[XEngine]: "+
m_log.Error("[XEngine]: " +
"Error displaying error in-world: " +
e2.ToString());
m_log.Error("[XEngine]: " +
@ -537,27 +537,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
try
{
AppDomainSetup appSetup = new AppDomainSetup();
// appSetup.ApplicationBase = Path.Combine(
// "ScriptEngines",
// m_Scene.RegionInfo.RegionID.ToString());
// appSetup.ApplicationBase = Path.Combine(
// "ScriptEngines",
// m_Scene.RegionInfo.RegionID.ToString());
Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
Evidence evidence = new Evidence(baseEvidence);
AppDomain sandbox =
m_AppDomains[appDomain] =
AppDomain.CreateDomain(
m_Scene.RegionInfo.RegionID.ToString(),
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 +=
new ResolveEventHandler(
@ -613,7 +603,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (!m_Scripts.ContainsKey(itemID))
return;
IScriptInstance instance=m_Scripts[itemID];
IScriptInstance instance = m_Scripts[itemID];
m_Scripts.Remove(itemID);
instance.ClearQueue();
@ -685,17 +675,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
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
{
if (File.Exists(m_Assemblies[assetID]))
File.Delete(m_Assemblies[assetID]);
if (File.Exists(m_Assemblies[assetID]+".state"))
File.Delete(m_Assemblies[assetID]+".state");
if (File.Exists(m_Assemblies[assetID] + ".state"))
File.Delete(m_Assemblies[assetID] + ".state");
if (File.Exists(m_Assemblies[assetID]+".mdb"))
File.Delete(m_Assemblies[assetID]+".mdb");
if (File.Exists(m_Assemblies[assetID] + ".mdb"))
File.Delete(m_Assemblies[assetID] + ".mdb");
}
catch (Exception)
{
@ -713,7 +703,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
AppDomain.Unload(domain);
domain = null;
// m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString());
// m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString());
}
}
@ -745,8 +735,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return new XWorkItem(m_ThreadPool.QueueWorkItem(
new WorkItemCallback(this.ProcessEventHandler),
parms));
}
}
/// <summary>
/// Process a previously posted script event.
/// </summary>
@ -757,8 +747,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
CultureInfo USCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = USCulture;
IScriptInstance instance = (ScriptInstance) parms;
IScriptInstance instance = (ScriptInstance)parms;
//m_log.DebugFormat("[XENGINE]: Processing event for {0}", instance);
return instance.EventProcessor();
@ -773,13 +763,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public bool PostObjectEvent(uint localID, EventParams p)
{
bool result = false;
lock (m_PrimObjects)
{
if (!m_PrimObjects.ContainsKey(localID))
return false;
foreach (UUID itemID in m_PrimObjects[localID])
{
if (m_Scripts.ContainsKey(itemID))
@ -831,7 +821,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (string s in pathList)
{
string path = Path.Combine(Directory.GetCurrentDirectory(),
Path.Combine(s, assemblyName))+".dll";
Path.Combine(s, assemblyName)) + ".dll";
if (File.Exists(path))
return Assembly.LoadFrom(path);
@ -969,7 +959,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
i.Running = prevRunning;
}
DoBackup(new Object[] {0});
DoBackup(new Object[] { 0 });
}
public IScriptApi GetApi(UUID itemID, string name)

Binary file not shown.

Binary file not shown.