* Cruft removal step #1. Cleaning Modules directory.

0.6.0-stable
Adam Frisby 2008-04-30 21:43:47 +00:00
parent 3da6a05eaa
commit be20f41637
35 changed files with 2216 additions and 2127 deletions

View File

@ -37,24 +37,27 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
{ {
public class AssetDownloadModule : IRegionModule public class AssetDownloadModule : IRegionModule
{ {
private Scene m_scene;
private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
///
/// Assets requests (for each user) which are waiting for asset server data. This includes texture requests
/// </summary>
private Dictionary<LLUUID, Dictionary<LLUUID,AssetRequest>> RequestedAssets;
/// <summary> /// <summary>
/// Asset requests with data which are ready to be sent back to requesters. This includes textures. /// Asset requests with data which are ready to be sent back to requesters. This includes textures.
/// </summary> /// </summary>
private List<AssetRequest> AssetRequests; private List<AssetRequest> AssetRequests;
private Scene m_scene;
private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
///
/// Assets requests (for each user) which are waiting for asset server data. This includes texture requests
/// </summary>
private Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> RequestedAssets;
public AssetDownloadModule() public AssetDownloadModule()
{ {
RequestedAssets = new Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>>(); RequestedAssets = new Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>>();
AssetRequests = new List<AssetRequest>(); AssetRequests = new List<AssetRequest>();
} }
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
@ -92,6 +95,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
get { return true; } get { return true; }
} }
#endregion
public void NewClient(IClientAPI client) public void NewClient(IClientAPI client)
{ {
// client.OnRequestAsset += AddAssetRequest; // client.OnRequestAsset += AddAssetRequest;
@ -301,33 +306,37 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
{ {
// over max number of bytes so split up file // over max number of bytes so split up file
long restData = data.LongLength - m_maxPacketSize; long restData = data.LongLength - m_maxPacketSize;
int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize); int restPackets = (int) ((restData + m_maxPacketSize - 1) / m_maxPacketSize);
numPackets += restPackets; numPackets += restPackets;
} }
return numPackets; return numPackets;
} }
#region Nested type: AssetRequest
public class AssetRequest public class AssetRequest
{ {
public IClientAPI RequestUser;
public LLUUID RequestAssetID;
public AssetBase AssetInf; public AssetBase AssetInf;
public AssetBase ImageInfo; public byte AssetRequestSource = 2;
public LLUUID TransferRequestID;
public long DataPointer = 0; public long DataPointer = 0;
public int DiscardLevel = -1;
public AssetBase ImageInfo;
public bool IsTextureRequest;
public int NumPackets = 0; public int NumPackets = 0;
public int PacketCounter = 0; public int PacketCounter = 0;
public bool IsTextureRequest;
public byte AssetRequestSource = 2;
public byte[] Params = null; public byte[] Params = null;
public LLUUID RequestAssetID;
public IClientAPI RequestUser;
public LLUUID TransferRequestID;
//public bool AssetInCache; //public bool AssetInCache;
//public int TimeRequested; //public int TimeRequested;
public int DiscardLevel = -1;
public AssetRequest() public AssetRequest()
{ {
} }
} }
#endregion
} }
} }

View File

@ -44,10 +44,10 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Fields // Fields
private bool m_dumpAssetsToFile;
public AgentAssetTransactionsManager Manager;
public LLUUID UserID; public LLUUID UserID;
public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>();
public AgentAssetTransactionsManager Manager;
private bool m_dumpAssetsToFile;
// Methods // Methods
public AgentAssetTransactions(LLUUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile) public AgentAssetTransactions(LLUUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile)
@ -135,27 +135,30 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
} }
// Nested Types // Nested Types
#region Nested type: AssetXferUploader
public class AssetXferUploader public class AssetXferUploader
{ {
// Fields // Fields
public bool AddToInventory; public bool AddToInventory;
public AssetBase Asset; public AssetBase Asset;
public LLUUID InventFolder = LLUUID.Zero; public LLUUID InventFolder = LLUUID.Zero;
private sbyte invType = 0;
private bool m_createItem = false;
private string m_description = String.Empty;
private bool m_dumpAssetToFile;
private bool m_finished = false;
private string m_name = String.Empty;
private bool m_storeLocal;
private AgentAssetTransactions m_userTransactions;
private uint nextPerm = 0;
private IClientAPI ourClient; private IClientAPI ourClient;
public LLUUID TransactionID = LLUUID.Zero; public LLUUID TransactionID = LLUUID.Zero;
public bool UploadComplete;
public ulong XferID;
private string m_name = String.Empty;
private string m_description = String.Empty;
private sbyte type = 0; private sbyte type = 0;
private sbyte invType = 0; public bool UploadComplete;
private byte wearableType = 0; private byte wearableType = 0;
private uint nextPerm = 0; public ulong XferID;
private bool m_finished = false;
private bool m_createItem = false;
private AgentAssetTransactions m_userTransactions;
private bool m_storeLocal;
private bool m_dumpAssetToFile;
public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
{ {
@ -387,7 +390,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
item.BasePermissions = 2147483647; item.BasePermissions = 2147483647;
item.CurrentPermissions = 2147483647; item.CurrentPermissions = 2147483647;
item.NextPermissions = nextPerm; item.NextPermissions = nextPerm;
item.Flags = (uint)wearableType; item.Flags = (uint) wearableType;
userInfo.AddItem(ourClient.AgentId, item); userInfo.AddItem(ourClient.AgentId, item);
ourClient.SendInventoryItemCreateUpdate(item); ourClient.SendInventoryItemCreateUpdate(item);
@ -403,5 +406,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
return null; return null;
} }
} }
#endregion
} }
} }

View File

@ -33,7 +33,6 @@ using log4net;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.Agent.AssetTransaction;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
@ -41,8 +40,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions
{ {
private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
private Scene m_scene = null;
private bool m_dumpAssetsToFile = false; private bool m_dumpAssetsToFile = false;
private Scene m_scene = null;
private AgentAssetTransactionsManager m_transactionManager; private AgentAssetTransactionsManager m_transactionManager;
@ -51,6 +50,31 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
// System.Console.WriteLine("creating AgentAssetTransactionModule"); // System.Console.WriteLine("creating AgentAssetTransactionModule");
} }
#region IAgentAssetTransactions Members
public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
uint callbackID, string description, string name, sbyte invType,
sbyte type, byte wearableType, uint nextOwnerMask)
{
m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type,
wearableType, nextOwnerMask);
}
public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID,
InventoryItemBase item)
{
m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
}
public void RemoveAgentAssetTransactions(LLUUID userID)
{
m_transactionManager.RemoveAgentAssetTransactions(userID);
}
#endregion
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
@ -81,13 +105,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
{ {
m_transactionManager = new AgentAssetTransactionsManager(m_scene, false); m_transactionManager = new AgentAssetTransactionsManager(m_scene, false);
} }
} }
} }
public void PostInitialise() public void PostInitialise()
{ {
} }
public void Close() public void Close()
@ -104,29 +126,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
get { return true; } get { return true; }
} }
#endregion
public void NewClient(IClientAPI client) public void NewClient(IClientAPI client)
{ {
client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest; client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest;
client.OnXferReceive += m_transactionManager.HandleXfer; client.OnXferReceive += m_transactionManager.HandleXfer;
} }
public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
uint callbackID, string description, string name, sbyte invType,
sbyte type, byte wearableType, uint nextOwnerMask)
{
m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
}
public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID,
InventoryItemBase item)
{
m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
}
public void RemoveAgentAssetTransactions(LLUUID userID)
{
m_transactionManager.RemoveAgentAssetTransactions(userID);
}
} }
public class AgentAssetTransactionsManager public class AgentAssetTransactionsManager
@ -135,7 +141,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// Fields // Fields
public Scene MyScene;
/// <summary> /// <summary>
/// Each agent has its own singleton collection of transactions /// Each agent has its own singleton collection of transactions
@ -148,6 +153,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
/// </summary> /// </summary>
private bool m_dumpAssetsToFile; private bool m_dumpAssetsToFile;
public Scene MyScene;
public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile) public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile)
{ {
MyScene = scene; MyScene = scene;
@ -260,10 +267,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
if (uploader != null) if (uploader != null)
{ {
if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile)) if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile))
{ {
} }
} }
} }

View File

@ -41,9 +41,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
//private static readonly log4net.ILog m_log //private static readonly log4net.ILog m_log
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private List<Scene> m_scenes = new List<Scene>();
/// <summary> /// <summary>
/// There is one queue for all textures waiting to be sent, regardless of the requesting user. /// There is one queue for all textures waiting to be sent, regardless of the requesting user.
/// </summary> /// </summary>
@ -56,12 +53,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
private readonly Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices = private readonly Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices =
new Dictionary<LLUUID, UserTextureDownloadService>(); new Dictionary<LLUUID, UserTextureDownloadService>();
private Scene m_scene;
private List<Scene> m_scenes = new List<Scene>();
private Thread m_thread; private Thread m_thread;
public TextureDownloadModule() public TextureDownloadModule()
{ {
} }
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
if (m_scene == null) if (m_scene == null)
@ -83,6 +85,26 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
} }
} }
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "TextureDownloadModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
#endregion
/// <summary> /// <summary>
/// Cleanup the texture service related objects for the removed presence. /// Cleanup the texture service related objects for the removed presence.
/// </summary> /// </summary>
@ -102,24 +124,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
} }
} }
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "TextureDownloadModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
public void NewClient(IClientAPI client) public void NewClient(IClientAPI client)
{ {
client.OnRequestTexture += TextureRequest; client.OnRequestTexture += TextureRequest;

View File

@ -40,33 +40,36 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
//private static readonly log4net.ILog m_log //private static readonly log4net.ILog m_log
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private LLUUID m_textureId; private bool m_cancel = false;
private IClientAPI m_client; private IClientAPI m_client;
// See ITextureSender // See ITextureSender
private bool m_sending = false;
private LLUUID m_textureId;
// See ITextureSender
public TextureNotFoundSender(IClientAPI client, LLUUID textureID)
{
m_client = client;
m_textureId = textureID;
}
#region ITextureSender Members
public bool Sending public bool Sending
{ {
get { return false; } get { return false; }
set { m_sending = value; } set { m_sending = value; }
} }
private bool m_sending = false;
// See ITextureSender
public bool Cancel public bool Cancel
{ {
get { return false; } get { return false; }
set { m_cancel = value; } set { m_cancel = value; }
} }
private bool m_cancel = false;
public TextureNotFoundSender(IClientAPI client, LLUUID textureID)
{
m_client = client;
m_textureId = textureID;
}
// See ITextureSender // See ITextureSender
public void UpdateRequest(int discardLevel, uint packetNumber) public void UpdateRequest(int discardLevel, uint packetNumber)
{ {
@ -89,5 +92,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
return true; return true;
} }
#endregion
} }
} }

View File

@ -32,8 +32,6 @@ using log4net;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Limit; using OpenSim.Framework.Communications.Limit;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.Agent.TextureDownload;
using OpenSim.Region.Environment.Modules.Agent.TextureSender;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
@ -57,24 +55,14 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
/// </summary> /// </summary>
private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5; private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5;
/// <summary>
/// We're going to limit requests for the same missing texture.
/// XXX This is really a temporary solution to deal with the situation where a client continually requests
/// the same missing textures
/// </summary>
private readonly IRequestLimitStrategy<LLUUID> missingTextureLimitStrategy
= new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS);
/// <summary> /// <summary>
/// XXX Also going to limit requests for found textures. /// XXX Also going to limit requests for found textures.
/// </summary> /// </summary>
private readonly IRequestLimitStrategy<LLUUID> foundTextureLimitStrategy private readonly IRequestLimitStrategy<LLUUID> foundTextureLimitStrategy
= new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS);
/// <summary> private readonly IClientAPI m_client;
/// Holds texture senders before they have received the appropriate texture from the asset cache. private readonly Scene m_scene;
/// </summary>
private readonly Dictionary<LLUUID, TextureSender.TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender.TextureSender>();
/// <summary> /// <summary>
/// Texture Senders are placed in this queue once they have received their texture from the asset /// Texture Senders are placed in this queue once they have received their texture from the asset
@ -82,9 +70,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
/// </summary> /// </summary>
private readonly BlockingQueue<ITextureSender> m_sharedSendersQueue; private readonly BlockingQueue<ITextureSender> m_sharedSendersQueue;
private readonly Scene m_scene; /// <summary>
/// Holds texture senders before they have received the appropriate texture from the asset cache.
/// </summary>
private readonly Dictionary<LLUUID, TextureSender.TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender.TextureSender>();
private readonly IClientAPI m_client; /// <summary>
/// We're going to limit requests for the same missing texture.
/// XXX This is really a temporary solution to deal with the situation where a client continually requests
/// the same missing textures
/// </summary>
private readonly IRequestLimitStrategy<LLUUID> missingTextureLimitStrategy
= new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS);
public UserTextureDownloadService( public UserTextureDownloadService(
IClientAPI client, Scene scene, BlockingQueue<ITextureSender> sharedQueue) IClientAPI client, Scene scene, BlockingQueue<ITextureSender> sharedQueue)
@ -240,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
{ {
lock (m_textureSenders) lock (m_textureSenders)
{ {
foreach( TextureSender.TextureSender textureSender in m_textureSenders.Values ) foreach (TextureSender.TextureSender textureSender in m_textureSenders.Values)
{ {
textureSender.Cancel = true; textureSender.Cancel = true;
} }

View File

@ -48,6 +48,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
/// </summary> /// </summary>
public int counter = 0; public int counter = 0;
public bool ImageLoaded = false;
/// <summary> /// <summary>
/// Holds the texture asset to send. /// Holds the texture asset to send.
/// </summary> /// </summary>
@ -55,6 +57,12 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
//public LLUUID assetID { get { return m_asset.FullID; } } //public LLUUID assetID { get { return m_asset.FullID; } }
private bool m_cancel = false;
// See ITextureSender
private bool m_sending = false;
/// <summary> /// <summary>
/// This is actually the number of extra packets required to send the texture data! We always assume /// This is actually the number of extra packets required to send the texture data! We always assume
/// at least one is required. /// at least one is required.
@ -67,29 +75,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
/// </summary> /// </summary>
private int PacketCounter = 0; private int PacketCounter = 0;
// See ITextureSender
public bool Cancel
{
get { return false; }
set { m_cancel = value; }
}
private bool m_cancel = false;
// See ITextureSender
public bool Sending
{
get { return false; }
set { m_sending = value; }
}
private bool m_sending = false;
public bool ImageLoaded = false;
private IClientAPI RequestUser;
private int RequestedDiscardLevel = -1; private int RequestedDiscardLevel = -1;
private IClientAPI RequestUser;
private uint StartPacketNumber = 0; private uint StartPacketNumber = 0;
public TextureSender(IClientAPI client, int discardLevel, uint packetNumber) public TextureSender(IClientAPI client, int discardLevel, uint packetNumber)
@ -99,18 +86,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
StartPacketNumber = packetNumber; StartPacketNumber = packetNumber;
} }
/// <summary> #region ITextureSender Members
/// Load up the texture data to send.
/// </summary> public bool Cancel
/// <param name="asset">
/// A <see cref="AssetBase"/>
/// </param>
public void TextureReceived(AssetBase asset)
{ {
m_asset = asset; get { return false; }
NumPackets = CalculateNumPackets(asset.Data.Length); set { m_cancel = value; }
PacketCounter = (int) StartPacketNumber; }
ImageLoaded = true;
public bool Sending
{
get { return false; }
set { m_sending = value; }
} }
// See ITextureSender // See ITextureSender
@ -129,13 +116,29 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
SendPacket(); SendPacket();
counter++; counter++;
if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) ||
((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets/(RequestedDiscardLevel + 1))))) ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets / (RequestedDiscardLevel + 1)))))
{ {
return true; return true;
} }
return false; return false;
} }
#endregion
/// <summary>
/// Load up the texture data to send.
/// </summary>
/// <param name="asset">
/// A <see cref="AssetBase"/>
/// </param>
public void TextureReceived(AssetBase asset)
{
m_asset = asset;
NumPackets = CalculateNumPackets(asset.Data.Length);
PacketCounter = (int) StartPacketNumber;
ImageLoaded = true;
}
/// <summary> /// <summary>
/// Sends a texture packet to the client. /// Sends a texture packet to the client.
/// </summary> /// </summary>
@ -177,17 +180,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
im.Header.Reliable = false; im.Header.Reliable = false;
im.ImageID.Packet = (ushort) (PacketCounter); im.ImageID.Packet = (ushort) (PacketCounter);
im.ImageID.ID = m_asset.FullID; im.ImageID.ID = m_asset.FullID;
int size = m_asset.Data.Length - 600 - (1000*(PacketCounter - 1)); int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1));
if (size > 1000) size = 1000; if (size > 1000) size = 1000;
im.ImageData.Data = new byte[size]; im.ImageData.Data = new byte[size];
try try
{ {
Array.Copy(m_asset.Data, 600 + (1000*(PacketCounter - 1)), im.ImageData.Data, 0, size); Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size);
} }
catch (ArgumentOutOfRangeException) catch (ArgumentOutOfRangeException)
{ {
m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" + m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" +
m_asset.FullID.ToString() ); m_asset.FullID.ToString());
return; return;
} }
RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); RequestUser.OutPacket(im, ThrottleOutPacketType.Texture);
@ -210,7 +213,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
{ {
//over 600 bytes so split up file //over 600 bytes so split up file
int restData = (length - 600); int restData = (length - 600);
int restPackets = ((restData + 999)/1000); int restPackets = ((restData + 999) / 1000);
numPackets = restPackets; numPackets = restPackets;
} }

View File

@ -37,15 +37,16 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
{ {
public class XferModule : IRegionModule, IXfer public class XferModule : IRegionModule, IXfer
{ {
private Scene m_scene;
public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>();
public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
private Scene m_scene;
public XferModule() public XferModule()
{ {
} }
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
m_scene = scene; m_scene = scene;
@ -72,6 +73,28 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
get { return false; } get { return false; }
} }
#endregion
#region IXfer Members
public bool AddNewFile(string fileName, byte[] data)
{
lock (NewFiles)
{
if (NewFiles.ContainsKey(fileName))
{
NewFiles[fileName] = data;
}
else
{
NewFiles.Add(fileName, data);
}
}
return true;
}
#endregion
public void NewClient(IClientAPI client) public void NewClient(IClientAPI client)
{ {
client.OnRequestXfer += RequestXfer; client.OnRequestXfer += RequestXfer;
@ -119,33 +142,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
} }
} }
public bool AddNewFile(string fileName, byte[] data) #region Nested type: XferDownLoad
{
lock (NewFiles)
{
if (NewFiles.ContainsKey(fileName))
{
NewFiles[fileName] = data;
}
else
{
NewFiles.Add(fileName, data);
}
}
return true;
}
public class XferDownLoad public class XferDownLoad
{ {
public byte[] Data = new byte[0];
public string FileName = String.Empty;
public ulong XferID = 0;
public int DataPointer = 0;
public uint Packet = 0;
public IClientAPI Client; public IClientAPI Client;
public uint Serial = 1;
private bool complete; private bool complete;
public byte[] Data = new byte[0];
public int DataPointer = 0;
public string FileName = String.Empty;
public uint Packet = 0;
public uint Serial = 1;
public ulong XferID = 0;
public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client)
{ {
@ -221,5 +229,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
return complete; return complete;
} }
} }
#endregion
} }
} }

View File

@ -44,21 +44,21 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
public class ChatModule : IRegionModule, ISimChat public class ChatModule : IRegionModule, ISimChat
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string m_defaultzone = null;
private List<Scene> m_scenes = new List<Scene>();
private int m_whisperdistance = 10;
private int m_saydistance = 30;
private int m_shoutdistance = 100;
private IRCChatModule m_irc = null; private IRCChatModule m_irc = null;
private Thread m_irc_connector = null;
private string m_last_new_user = null;
private string m_last_leaving_user = null; private string m_last_leaving_user = null;
private string m_defaultzone = null; private string m_last_new_user = null;
private int m_saydistance = 30;
private List<Scene> m_scenes = new List<Scene>();
private int m_shoutdistance = 100;
internal object m_syncInit = new object(); internal object m_syncInit = new object();
internal object m_syncLogout = new object(); internal object m_syncLogout = new object();
private Thread m_irc_connector=null; private int m_whisperdistance = 10;
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
@ -85,14 +85,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
try try
{ {
m_defaultzone = config.Configs["IRC"].GetString("nick","Sim"); m_defaultzone = config.Configs["IRC"].GetString("nick", "Sim");
} }
catch (Exception) catch (Exception)
{ {
} }
// setup IRC Relay // setup IRC Relay
if (m_irc == null) { m_irc = new IRCChatModule(config); } if (m_irc == null)
{
m_irc = new IRCChatModule(config);
}
if (m_irc_connector == null) if (m_irc_connector == null)
{ {
m_irc_connector = new Thread(IRCConnectRun); m_irc_connector = new Thread(IRCConnectRun);
@ -142,83 +145,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
get { return true; } get { return true; }
} }
public void NewClient(IClientAPI client) #endregion
{
try
{
client.OnChatFromViewer += SimChat;
if ((m_irc.Enabled) && (m_irc.Connected)) #region ISimChat Members
{
string clientName = client.FirstName + " " + client.LastName;
// handles simple case. May not work for hundred connecting in per second.
// and the NewClients calles getting interleved
// but filters out multiple reports
if (clientName != m_last_new_user)
{
m_last_new_user = clientName;
string clientRegion = FindClientRegion(client.FirstName, client.LastName);
m_irc.PrivMsg(m_irc.Nick, "Sim", "notices " + clientName + " in "+clientRegion);
}
}
client.OnLogout += ClientLoggedOut;
client.OnConnectionClosed += ClientLoggedOut;
client.OnLogout += ClientLoggedOut;
}
catch (Exception ex)
{
m_log.Error("[IRC]: NewClient exception trap:" + ex.ToString());
}
}
public void ClientLoggedOut(IClientAPI client)
{
lock (m_syncLogout)
{
try
{
if ((m_irc.Enabled) && (m_irc.Connected))
{
string clientName = client.FirstName + " " + client.LastName;
string clientRegion = FindClientRegion(client.FirstName, client.LastName);
// handles simple case. May not work for hundred connecting in per second.
// and the NewClients calles getting interleved
// but filters out multiple reports
if (clientName != m_last_leaving_user)
{
m_last_leaving_user = clientName;
m_irc.PrivMsg(m_irc.Nick, "Sim", "notices " + clientName + " left " + clientRegion);
m_log.Info("[IRC]: IRC watcher notices " + clientName + " left " + clientRegion);
}
}
}
catch (Exception ex)
{
m_log.Error("[IRC]: ClientLoggedOut exception trap:" + ex.ToString());
}
}
}
private void TrySendChatMessage(ScenePresence presence, LLVector3 fromPos, LLVector3 regionPos,
LLUUID fromAgentID, string fromName, ChatTypeEnum type, string message)
{
if (!presence.IsChildAgent)
{
LLVector3 fromRegionPos = fromPos + regionPos;
LLVector3 toRegionPos = presence.AbsolutePosition + regionPos;
int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos));
if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
type == ChatTypeEnum.Say && dis > m_saydistance ||
type == ChatTypeEnum.Shout && dis > m_shoutdistance)
{
return;
}
// TODO: should change so the message is sent through the avatar rather than direct to the ClientView
presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
}
}
public void SimChat(Object sender, ChatFromViewerArgs e) public void SimChat(Object sender, ChatFromViewerArgs e)
{ {
@ -301,12 +230,92 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
} }
} }
#endregion
public void NewClient(IClientAPI client)
{
try
{
client.OnChatFromViewer += SimChat;
if ((m_irc.Enabled) && (m_irc.Connected))
{
string clientName = client.FirstName + " " + client.LastName;
// handles simple case. May not work for hundred connecting in per second.
// and the NewClients calles getting interleved
// but filters out multiple reports
if (clientName != m_last_new_user)
{
m_last_new_user = clientName;
string clientRegion = FindClientRegion(client.FirstName, client.LastName);
m_irc.PrivMsg(m_irc.Nick, "Sim", "notices " + clientName + " in " + clientRegion);
}
}
client.OnLogout += ClientLoggedOut;
client.OnConnectionClosed += ClientLoggedOut;
client.OnLogout += ClientLoggedOut;
}
catch (Exception ex)
{
m_log.Error("[IRC]: NewClient exception trap:" + ex.ToString());
}
}
public void ClientLoggedOut(IClientAPI client)
{
lock (m_syncLogout)
{
try
{
if ((m_irc.Enabled) && (m_irc.Connected))
{
string clientName = client.FirstName + " " + client.LastName;
string clientRegion = FindClientRegion(client.FirstName, client.LastName);
// handles simple case. May not work for hundred connecting in per second.
// and the NewClients calles getting interleved
// but filters out multiple reports
if (clientName != m_last_leaving_user)
{
m_last_leaving_user = clientName;
m_irc.PrivMsg(m_irc.Nick, "Sim", "notices " + clientName + " left " + clientRegion);
m_log.Info("[IRC]: IRC watcher notices " + clientName + " left " + clientRegion);
}
}
}
catch (Exception ex)
{
m_log.Error("[IRC]: ClientLoggedOut exception trap:" + ex.ToString());
}
}
}
private void TrySendChatMessage(ScenePresence presence, LLVector3 fromPos, LLVector3 regionPos,
LLUUID fromAgentID, string fromName, ChatTypeEnum type, string message)
{
if (!presence.IsChildAgent)
{
LLVector3 fromRegionPos = fromPos + regionPos;
LLVector3 toRegionPos = presence.AbsolutePosition + regionPos;
int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos));
if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
type == ChatTypeEnum.Say && dis > m_saydistance ||
type == ChatTypeEnum.Shout && dis > m_shoutdistance)
{
return;
}
// TODO: should change so the message is sent through the avatar rather than direct to the ClientView
presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
}
}
// if IRC is enabled then just keep trying using a monitor thread // if IRC is enabled then just keep trying using a monitor thread
public void IRCConnectRun() public void IRCConnectRun()
{ {
while(true) while (true)
{ {
if ((m_irc.Enabled)&&(!m_irc.Connected)) if ((m_irc.Enabled) && (!m_irc.Connected))
{ {
m_irc.Connect(m_scenes); m_irc.Connect(m_scenes);
} }
@ -314,16 +323,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
} }
} }
public string FindClientRegion(string client_FirstName,string client_LastName) public string FindClientRegion(string client_FirstName, string client_LastName)
{ {
string sourceRegion = null; string sourceRegion = null;
foreach (Scene s in m_scenes) foreach (Scene s in m_scenes)
{ {
s.ForEachScenePresence(delegate(ScenePresence presence) s.ForEachScenePresence(delegate(ScenePresence presence)
{ {
if ((presence.IsChildAgent==false) if ((presence.IsChildAgent == false)
&&(presence.Firstname==client_FirstName) && (presence.Firstname == client_FirstName)
&&(presence.Lastname==client_LastName)) && (presence.Lastname == client_LastName))
{ {
sourceRegion = presence.Scene.RegionInfo.RegionName; sourceRegion = presence.Scene.RegionInfo.RegionName;
//sourceRegion= s.RegionInfo.RegionName; //sourceRegion= s.RegionInfo.RegionName;
@ -331,37 +340,59 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
}); });
if (sourceRegion != null) return sourceRegion; if (sourceRegion != null) return sourceRegion;
} }
if (m_defaultzone == null) { m_defaultzone = "Sim"; } if (m_defaultzone == null)
{
m_defaultzone = "Sim";
}
return m_defaultzone; return m_defaultzone;
} }
} }
internal class IRCChatModule internal class IRCChatModule
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); #region ErrorReplies enum
public enum ErrorReplies
{
NotRegistered = 451, // ":You have not registered"
NicknameInUse = 433 // "<nick> :Nickname is already in use"
}
#endregion
#region Replies enum
public enum Replies
{
MotdStart = 375, // ":- <server> Message of the day - "
Motd = 372, // ":- <text>"
EndOfMotd = 376 // ":End of /MOTD command"
}
#endregion
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Thread listener;
private string m_server = null;
private uint m_port = 6668;
private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
private string m_nick = null;
private string m_basenick = null; private string m_basenick = null;
private string m_channel = null; private string m_channel = null;
private bool m_connected = false;
private bool m_enabled = false;
private List<Scene> m_last_scenes = null;
private string m_nick = null;
private uint m_port = 6668;
private string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}"; private string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}";
private StreamReader m_reader;
private List<Scene> m_scenes = null;
private string m_server = null;
private NetworkStream m_stream; private NetworkStream m_stream;
internal object m_syncConnect = new object();
private TcpClient m_tcp; private TcpClient m_tcp;
private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
private StreamWriter m_writer; private StreamWriter m_writer;
private StreamReader m_reader;
private Thread pingSender; private Thread pingSender;
private Thread listener;
internal object m_syncConnect = new object();
private bool m_enabled = false;
private bool m_connected = false;
private List<Scene> m_scenes = null;
private List<Scene> m_last_scenes = null;
public IRCChatModule(IConfigSource config) public IRCChatModule(IConfigSource config)
{ {
@ -412,6 +443,21 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
} }
} }
public bool Enabled
{
get { return m_enabled; }
}
public bool Connected
{
get { return m_connected; }
}
public string Nick
{
get { return m_nick; }
}
public bool Connect(List<Scene> scenes) public bool Connect(List<Scene> scenes)
{ {
lock (m_syncConnect) lock (m_syncConnect)
@ -420,9 +466,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
{ {
if (m_connected) return true; if (m_connected) return true;
m_scenes = scenes; m_scenes = scenes;
if (m_last_scenes == null) { m_last_scenes = scenes; } if (m_last_scenes == null)
{
m_last_scenes = scenes;
}
m_tcp = new TcpClient(m_server, (int)m_port); m_tcp = new TcpClient(m_server, (int) m_port);
m_log.Info("[IRC]: Connecting..."); m_log.Info("[IRC]: Connecting...");
m_stream = m_tcp.GetStream(); m_stream = m_tcp.GetStream();
m_log.Info("[IRC]: Connected to " + m_server); m_log.Info("[IRC]: Connected to " + m_server);
@ -458,21 +507,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
} }
} }
public bool Enabled
{
get { return m_enabled; }
}
public bool Connected
{
get { return m_connected; }
}
public string Nick
{
get { return m_nick; }
}
public void Reconnect() public void Reconnect()
{ {
m_connected = false; m_connected = false;
@ -481,7 +515,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
m_writer.Close(); m_writer.Close();
m_reader.Close(); m_reader.Close();
m_tcp.Close(); m_tcp.Close();
if (m_enabled) { Connect(m_last_scenes); } if (m_enabled)
{
Connect(m_last_scenes);
}
} }
public void PrivMsg(string from, string region, string msg) public void PrivMsg(string from, string region, string msg)
@ -627,7 +664,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
} }
} }
public void BroadcastSim(string message,string sender) public void BroadcastSim(string message, string sender)
{ {
LLVector3 pos = new LLVector3(128, 128, 20); LLVector3 pos = new LLVector3(128, 128, 20);
try try
@ -652,19 +689,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
} }
} }
public enum ErrorReplies
{
NotRegistered = 451, // ":You have not registered"
NicknameInUse = 433 // "<nick> :Nickname is already in use"
}
public enum Replies
{
MotdStart = 375, // ":- <server> Message of the day - "
Motd = 372, // ":- <text>"
EndOfMotd = 376 // ":End of /MOTD command"
}
public void ProcessIRCCommand(string command) public void ProcessIRCCommand(string command)
{ {
//m_log.Info("[IRC]: ProcessIRCCommand:" + command); //m_log.Info("[IRC]: ProcessIRCCommand:" + command);
@ -713,7 +737,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
Int32 commandCode = Int32.Parse(commArgs[1]); Int32 commandCode = Int32.Parse(commArgs[1]);
switch (commandCode) switch (commandCode)
{ {
case (int)ErrorReplies.NicknameInUse: case (int) ErrorReplies.NicknameInUse:
// Gen a new name // Gen a new name
m_nick = m_basenick + Util.RandomClass.Next(1, 99); m_nick = m_basenick + Util.RandomClass.Next(1, 99);
m_log.Error("[IRC]: IRC SERVER reports NicknameInUse, trying " + m_nick); m_log.Error("[IRC]: IRC SERVER reports NicknameInUse, trying " + m_nick);
@ -723,9 +747,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
m_writer.WriteLine("JOIN " + m_channel); m_writer.WriteLine("JOIN " + m_channel);
m_writer.Flush(); m_writer.Flush();
break; break;
case (int)ErrorReplies.NotRegistered: case (int) ErrorReplies.NotRegistered:
break; break;
case (int)Replies.EndOfMotd: case (int) Replies.EndOfMotd:
break; break;
} }
} }
@ -739,13 +763,26 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
string commAct = commArgs[1]; string commAct = commArgs[1];
switch (commAct) switch (commAct)
{ {
case "JOIN": eventIrcJoin(commArgs); break; case "JOIN":
case "PART": eventIrcPart(commArgs); break; eventIrcJoin(commArgs);
case "MODE": eventIrcMode(commArgs); break; break;
case "NICK": eventIrcNickChange(commArgs); break; case "PART":
case "KICK": eventIrcKick(commArgs); break; eventIrcPart(commArgs);
case "QUIT": eventIrcQuit(commArgs); break; break;
case "PONG": break; // that's nice case "MODE":
eventIrcMode(commArgs);
break;
case "NICK":
eventIrcNickChange(commArgs);
break;
case "KICK":
eventIrcKick(commArgs);
break;
case "QUIT":
eventIrcQuit(commArgs);
break;
case "PONG":
break; // that's nice
} }
} }
} }
@ -797,7 +834,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
{ {
KickMessage += commArgs[i] + " "; KickMessage += commArgs[i] + " ";
} }
BroadcastSim(UserKicker + " kicked " + UserKicked +" on "+IrcChannel+" saying "+KickMessage, m_nick); BroadcastSim(UserKicker + " kicked " + UserKicked + " on " + IrcChannel + " saying " + KickMessage, m_nick);
if (UserKicked == m_nick) if (UserKicked == m_nick)
{ {
BroadcastSim("Hey, that was me!!!", m_nick); BroadcastSim("Hey, that was me!!!", m_nick);

View File

@ -42,13 +42,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
private Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>();
private List<Scene> m_scene = new List<Scene>(); private List<Scene> m_scene = new List<Scene>();
Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>(); #region IRegionModule Members
Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
@ -68,11 +67,33 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
scene.EventManager.OnMakeChildAgent += MakeChildAgent; scene.EventManager.OnMakeChildAgent += MakeChildAgent;
scene.EventManager.OnClientClosed += ClientLoggedOut; scene.EventManager.OnClientClosed += ClientLoggedOut;
} }
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "FriendsModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
public XmlRpcResponse processPresenceUpdate(XmlRpcRequest req) public XmlRpcResponse processPresenceUpdate(XmlRpcRequest req)
{ {
m_log.Info("[FRIENDS]: Got Notification about a user! OMG"); m_log.Info("[FRIENDS]: Got Notification about a user! OMG");
return new XmlRpcResponse(); return new XmlRpcResponse();
} }
private void OnNewClient(IClientAPI client) private void OnNewClient(IClientAPI client)
{ {
// All friends establishment protocol goes over instant message // All friends establishment protocol goes over instant message
@ -169,10 +190,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
onp.AgentBlock = onpb; onp.AgentBlock = onpb;
client.OutPacket(onp, ThrottleOutPacketType.Task); client.OutPacket(onp, ThrottleOutPacketType.Task);
} }
} }
private void ClientLoggedOut(LLUUID AgentId) private void ClientLoggedOut(LLUUID AgentId)
@ -208,7 +225,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
List<FriendListItem> flfli = new List<FriendListItem>(); List<FriendListItem> flfli = new List<FriendListItem>();
try try
{ {
lock (FriendLists) lock (FriendLists)
{ {
if (FriendLists.ContainsKey(updateUsers[i])) if (FriendLists.ContainsKey(updateUsers[i]))
@ -231,7 +247,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
{ {
flfli[i].onlinestatus = false; flfli[i].onlinestatus = false;
} }
} }
catch (IndexOutOfRangeException) catch (IndexOutOfRangeException)
@ -242,7 +257,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
m_log.Info("[FRIEND]: Unable to enumerate last friendlist user. User logged off"); m_log.Info("[FRIEND]: Unable to enumerate last friendlist user. User logged off");
} }
} }
} }
for (int i = 0; i < updateUsers.Count; i++) for (int i = 0; i < updateUsers.Count; i++)
@ -250,7 +264,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
ScenePresence av = GetPresenceFromAgentID(updateUsers[i]); ScenePresence av = GetPresenceFromAgentID(updateUsers[i]);
if (av != null) if (av != null)
{ {
OfflineNotificationPacket onp = new OfflineNotificationPacket(); OfflineNotificationPacket onp = new OfflineNotificationPacket();
OfflineNotificationPacket.AgentBlockBlock[] onpb = new OfflineNotificationPacket.AgentBlockBlock[1]; OfflineNotificationPacket.AgentBlockBlock[] onpb = new OfflineNotificationPacket.AgentBlockBlock[1];
OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock(); OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
@ -265,7 +278,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
{ {
FriendLists.Remove(AgentId); FriendLists.Remove(AgentId);
} }
} }
private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID) private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID)
@ -282,7 +294,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
{ {
JId avatarID = new JId(avatar.JID); JId avatarID = new JId(avatar.JID);
// REST Post XMPP Stanzas! // REST Post XMPP Stanzas!
} }
// Claim User! my user! Mine mine mine! // Claim User! my user! Mine mine mine!
} }
@ -295,9 +306,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
} }
//m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
} }
private void MakeChildAgent(ScenePresence avatar) private void MakeChildAgent(ScenePresence avatar)
{ {
lock (m_rootAgents) lock (m_rootAgents)
{ {
if (m_rootAgents.ContainsKey(avatar.UUID)) if (m_rootAgents.ContainsKey(avatar.UUID))
@ -307,13 +318,35 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
m_rootAgents.Remove(avatar.UUID); m_rootAgents.Remove(avatar.UUID);
m_log.Info("[FRIEND]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent"); m_log.Info("[FRIEND]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent");
} }
}
} }
} }
private ScenePresence GetPresenceFromAgentID(LLUUID AgentID)
{
ScenePresence returnAgent = null;
lock (m_scene)
{
ScenePresence queryagent = null;
for (int i = 0; i < m_scene.Count; i++)
{
queryagent = m_scene[i].GetScenePresence(AgentID);
if (queryagent != null)
{
if (!queryagent.IsChildAgent)
{
returnAgent = queryagent;
break;
} }
}
}
}
return returnAgent;
}
#region FriendRequestHandling #region FriendRequestHandling
private void OnInstantMessage(IClientAPI client,LLUUID fromAgentID,
private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
LLUUID fromAgentSession, LLUUID toAgentID, LLUUID fromAgentSession, LLUUID toAgentID,
LLUUID imSessionID, uint timestamp, string fromAgentName, LLUUID imSessionID, uint timestamp, string fromAgentName,
string message, byte dialog, bool fromGroup, byte offline, string message, byte dialog, bool fromGroup, byte offline,
@ -324,13 +357,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
// https://wiki.secondlife.com/wiki/ImprovedInstantMessage // https://wiki.secondlife.com/wiki/ImprovedInstantMessage
// 38 == Offer friendship // 38 == Offer friendship
if (dialog == (byte)38) if (dialog == (byte) 38)
{ {
LLUUID friendTransactionID = LLUUID.Random(); LLUUID friendTransactionID = LLUUID.Random();
m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
m_log.Info("[FRIEND]: 38 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message); m_log.Info("[FRIEND]: 38 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" +
message);
GridInstantMessage msg = new GridInstantMessage(); GridInstantMessage msg = new GridInstantMessage();
msg.fromAgentID = fromAgentID.UUID; msg.fromAgentID = fromAgentID.UUID;
msg.fromAgentSession = fromAgentSession.UUID; msg.fromAgentSession = fromAgentSession.UUID;
@ -340,11 +374,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
msg.timestamp = timestamp; msg.timestamp = timestamp;
if (client != null) if (client != null)
{ {
msg.fromAgentName = client.FirstName + " " + client.LastName;// fromAgentName; msg.fromAgentName = client.FirstName + " " + client.LastName; // fromAgentName;
} }
else else
{ {
msg.fromAgentName = "(hippos)";// Added for posterity. This means that we can't figure out who sent it msg.fromAgentName = "(hippos)"; // Added for posterity. This means that we can't figure out who sent it
} }
msg.message = message; msg.message = message;
msg.dialog = dialog; msg.dialog = dialog;
@ -359,15 +393,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
} }
// 39 == Accept Friendship // 39 == Accept Friendship
if (dialog == (byte)39) if (dialog == (byte) 39)
{ {
m_log.Info("[FRIEND]: 39 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message); m_log.Info("[FRIEND]: 39 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" +
message);
} }
// 40 == Decline Friendship // 40 == Decline Friendship
if (dialog == (byte)40) if (dialog == (byte) 40)
{ {
m_log.Info("[FRIEND]: 40 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message); m_log.Info("[FRIEND]: 40 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" +
message);
} }
} }
@ -395,16 +431,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
msg.imSessionID = transactionID.UUID; msg.imSessionID = transactionID.UUID;
msg.message = agentID.UUID.ToString(); msg.message = agentID.UUID.ToString();
msg.ParentEstateID = 0; msg.ParentEstateID = 0;
msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); msg.timestamp = (uint) Util.UnixTimeSinceEpoch();
msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID; msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID;
msg.dialog = (byte)39;// Approved friend request msg.dialog = (byte) 39; // Approved friend request
msg.Position = new sLLVector3(); msg.Position = new sLLVector3();
msg.offline = (byte)0; msg.offline = (byte) 0;
msg.binaryBucket = new byte[0]; msg.binaryBucket = new byte[0];
// We don't really care which scene we pipe it through, it goes to the shared IM Module and/or the database // We don't really care which scene we pipe it through, it goes to the shared IM Module and/or the database
SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint)1); SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint) 1);
m_pendingFriendRequests.Remove(transactionID); m_pendingFriendRequests.Remove(transactionID);
// TODO: Inform agent that the friend is online // TODO: Inform agent that the friend is online
@ -433,11 +469,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
msg.imSessionID = transactionID.UUID; msg.imSessionID = transactionID.UUID;
msg.message = agentID.UUID.ToString(); msg.message = agentID.UUID.ToString();
msg.ParentEstateID = 0; msg.ParentEstateID = 0;
msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); msg.timestamp = (uint) Util.UnixTimeSinceEpoch();
msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID; msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID;
msg.dialog = (byte)40;// Deny friend request msg.dialog = (byte) 40; // Deny friend request
msg.Position = new sLLVector3(); msg.Position = new sLLVector3();
msg.offline = (byte)0; msg.offline = (byte) 0;
msg.binaryBucket = new byte[0]; msg.binaryBucket = new byte[0];
SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
m_pendingFriendRequests.Remove(transactionID); m_pendingFriendRequests.Remove(transactionID);
@ -453,52 +489,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
private void OnGridInstantMessage(GridInstantMessage msg) private void OnGridInstantMessage(GridInstantMessage msg)
{ {
// Trigger the above event handler // Trigger the above event handler
OnInstantMessage(null,new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession), OnInstantMessage(null, new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession),
new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName,
msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID,
new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID), new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID),
msg.binaryBucket); msg.binaryBucket);
} }
#endregion #endregion
private ScenePresence GetPresenceFromAgentID(LLUUID AgentID)
{
ScenePresence returnAgent = null;
lock (m_scene)
{
ScenePresence queryagent = null;
for (int i = 0; i < m_scene.Count; i++)
{
queryagent = m_scene[i].GetScenePresence(AgentID);
if (queryagent != null)
{
if (!queryagent.IsChildAgent)
{
returnAgent = queryagent;
break;
}
}
}
}
return returnAgent;
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "FriendsModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
} }
} }

View File

@ -41,10 +41,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private List<Scene> m_scene = new List<Scene>();
private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>();
private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>();
private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>(); private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>();
private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>();
private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>();
private List<Scene> m_scene = new List<Scene>();
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
@ -58,6 +60,42 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
//scene.EventManager. //scene.EventManager.
} }
public void PostInitialise()
{
}
public void Close()
{
m_log.Info("[GROUP]: Shutting down group module.");
lock (m_iclientmap)
{
m_iclientmap.Clear();
}
lock (m_groupmap)
{
m_groupmap.Clear();
}
lock (m_grouplistmap)
{
m_grouplistmap.Clear();
}
GC.Collect();
}
public string Name
{
get { return "GroupsModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
private void OnNewClient(IClientAPI client) private void OnNewClient(IClientAPI client)
{ {
// All friends establishment protocol goes over instant message // All friends establishment protocol goes over instant message
@ -139,11 +177,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
} }
//remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle); //remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle);
} }
} }
} }
} }
private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID, private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
@ -201,63 +237,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
} }
GC.Collect(); GC.Collect();
} }
public void PostInitialise()
{
}
public void Close()
{
m_log.Info("[GROUP]: Shutting down group module.");
lock (m_iclientmap)
{
m_iclientmap.Clear();
}
lock (m_groupmap)
{
m_groupmap.Clear();
}
lock (m_grouplistmap)
{
m_grouplistmap.Clear();
}
GC.Collect();
}
public string Name
{
get { return "GroupsModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
} }
public class GroupData public class GroupData
{ {
public LLUUID GroupID;
public string groupName;
public string ActiveGroupTitle; public string ActiveGroupTitle;
public List<string> GroupTitles; public LLUUID GroupID;
public List<LLUUID> GroupMembers; public List<LLUUID> GroupMembers;
public uint groupPowers = (uint)(GroupPowers.LandAllowLandmark | GroupPowers.LandAllowSetHome); public string groupName;
public uint groupPowers = (uint) (GroupPowers.LandAllowLandmark | GroupPowers.LandAllowSetHome);
public GroupPowers ActiveGroupPowers public List<string> GroupTitles;
{
set
{
groupPowers = (uint) value;
}
get
{
return (GroupPowers)groupPowers;
}
}
public GroupData() public GroupData()
{ {
@ -265,11 +254,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
GroupMembers = new List<LLUUID>(); GroupMembers = new List<LLUUID>();
} }
public GroupPowers ActiveGroupPowers
{
set { groupPowers = (uint) value; }
get { return (GroupPowers) groupPowers; }
}
} }
public class GroupList public class GroupList
{ {
public List<LLUUID> m_GroupList; public List<LLUUID> m_GroupList;
public GroupList() public GroupList()
{ {
m_GroupList = new List<LLUUID>(); m_GroupList = new List<LLUUID>();

View File

@ -38,6 +38,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
{ {
private readonly List<Scene> m_scenes = new List<Scene>(); private readonly List<Scene> m_scenes = new List<Scene>();
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
lock (m_scenes) lock (m_scenes)
@ -56,86 +58,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
} }
} }
private void OnNewClient(IClientAPI client)
{
client.OnInstantMessage += OnInstantMessage;
}
private void OnInstantMessage(IClientAPI client,LLUUID fromAgentID,
LLUUID fromAgentSession, LLUUID toAgentID,
LLUUID imSessionID, uint timestamp, string fromAgentName,
string message, byte dialog, bool fromGroup, byte offline,
uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
byte[] binaryBucket)
{
bool dialogHandledElsewhere
= ((dialog == 38) || (dialog == 39) || (dialog == 40)
|| dialog == (byte)InstantMessageDialog.InventoryOffered
|| dialog == (byte)InstantMessageDialog.InventoryAccepted
|| dialog == (byte)InstantMessageDialog.InventoryDeclined);
// IM dialogs need to be pre-processed and have their sessionID filled by the server
// so the sim can match the transaction on the return packet.
// Don't send a Friend Dialog IM with a LLUUID.Zero session.
if (!(dialogHandledElsewhere && imSessionID == LLUUID.Zero))
{
// Try root avatar only first
foreach (Scene scene in m_scenes)
{
if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
{
// Local message
ScenePresence user = (ScenePresence)scene.Entities[toAgentID];
if (!user.IsChildAgent)
{
user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
toAgentID, imSessionID, fromAgentName, dialog,
timestamp);
// Message sent
return;
}
}
}
// try child avatar second
foreach (Scene scene in m_scenes)
{
if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
{
// Local message
ScenePresence user = (ScenePresence)scene.Entities[toAgentID];
user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
toAgentID, imSessionID, fromAgentName, dialog,
timestamp);
// Message sent
return;
}
}
}
// Still here, try send via Grid
// TODO
}
// Trusty OSG1 called method. This method also gets called from the FriendsModule
// Turns out the sim has to send an instant message to the user to get it to show an accepted friend.
private void OnGridInstantMessage(GridInstantMessage msg)
{
// Trigger the above event handler
OnInstantMessage(null,new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession),
new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName,
msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID,
new LLVector3(msg.Position.x,msg.Position.y,msg.Position.z), new LLUUID(msg.RegionID),
msg.binaryBucket);
}
public void PostInitialise() public void PostInitialise()
{ {
} }
@ -153,5 +75,84 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
{ {
get { return true; } get { return true; }
} }
#endregion
private void OnNewClient(IClientAPI client)
{
client.OnInstantMessage += OnInstantMessage;
}
private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
LLUUID fromAgentSession, LLUUID toAgentID,
LLUUID imSessionID, uint timestamp, string fromAgentName,
string message, byte dialog, bool fromGroup, byte offline,
uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
byte[] binaryBucket)
{
bool dialogHandledElsewhere
= ((dialog == 38) || (dialog == 39) || (dialog == 40)
|| dialog == (byte) InstantMessageDialog.InventoryOffered
|| dialog == (byte) InstantMessageDialog.InventoryAccepted
|| dialog == (byte) InstantMessageDialog.InventoryDeclined);
// IM dialogs need to be pre-processed and have their sessionID filled by the server
// so the sim can match the transaction on the return packet.
// Don't send a Friend Dialog IM with a LLUUID.Zero session.
if (!(dialogHandledElsewhere && imSessionID == LLUUID.Zero))
{
// Try root avatar only first
foreach (Scene scene in m_scenes)
{
if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
{
// Local message
ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
if (!user.IsChildAgent)
{
user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
toAgentID, imSessionID, fromAgentName, dialog,
timestamp);
// Message sent
return;
}
}
}
// try child avatar second
foreach (Scene scene in m_scenes)
{
if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
{
// Local message
ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
toAgentID, imSessionID, fromAgentName, dialog,
timestamp);
// Message sent
return;
}
}
}
// Still here, try send via Grid
// TODO
}
// Trusty OSG1 called method. This method also gets called from the FriendsModule
// Turns out the sim has to send an instant message to the user to get it to show an accepted friend.
private void OnGridInstantMessage(GridInstantMessage msg)
{
// Trigger the above event handler
OnInstantMessage(null, new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession),
new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName,
msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID,
new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID),
msg.binaryBucket);
}
} }
} }

View File

@ -41,8 +41,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
private static readonly ILog m_log private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
/// <summary> /// <summary>
/// We need to keep track of the pending item offers between clients since the itemId offered only /// We need to keep track of the pending item offers between clients since the itemId offered only
/// occurs in the initial offer message, not the accept message. So this dictionary links /// occurs in the initial offer message, not the accept message. So this dictionary links
@ -50,6 +48,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
/// </summary> /// </summary>
private IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>(); private IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>();
private Scene m_scene;
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
m_scene = scene; m_scene = scene;
@ -74,6 +76,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
get { return false; } get { return false; }
} }
#endregion
private void OnNewClient(IClientAPI client) private void OnNewClient(IClientAPI client)
{ {
// Inventory giving is conducted via instant message // Inventory giving is conducted via instant message
@ -87,7 +91,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
uint ParentEstateID, LLVector3 Position, LLUUID RegionID, uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
byte[] binaryBucket) byte[] binaryBucket)
{ {
if (dialog == (byte)InstantMessageDialog.InventoryOffered) if (dialog == (byte) InstantMessageDialog.InventoryOffered)
{ {
m_log.DebugFormat( m_log.DebugFormat(
"[AGENT INVENTORY]: Routing inventory offering message from {0}, {1} to {2}", "[AGENT INVENTORY]: Routing inventory offering message from {0}, {1} to {2}",
@ -95,7 +99,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
{ {
ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
if (!user.IsChildAgent) if (!user.IsChildAgent)
{ {
@ -133,7 +137,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
toAgentID, client.AgentId, client.Name, message); toAgentID, client.AgentId, client.Name, message);
} }
} }
else if (dialog == (byte)InstantMessageDialog.InventoryAccepted) else if (dialog == (byte) InstantMessageDialog.InventoryAccepted)
{ {
m_log.DebugFormat( m_log.DebugFormat(
"[AGENT INVENTORY]: Routing inventory accepted message from {0}, {1} to {2}", "[AGENT INVENTORY]: Routing inventory accepted message from {0}, {1} to {2}",
@ -141,7 +145,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
{ {
ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
if (!user.IsChildAgent) if (!user.IsChildAgent)
{ {
@ -183,11 +187,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
toAgentID, client.AgentId, client.Name, message); toAgentID, client.AgentId, client.Name, message);
} }
} }
else if (dialog == (byte)InstantMessageDialog.InventoryDeclined) else if (dialog == (byte) InstantMessageDialog.InventoryDeclined)
{ {
if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
{ {
ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
if (!user.IsChildAgent) if (!user.IsChildAgent)
{ {

View File

@ -45,6 +45,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles
{ {
} }
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
m_scene = scene; m_scene = scene;
@ -69,6 +71,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles
get { return false; } get { return false; }
} }
#endregion
public void NewClient(IClientAPI client) public void NewClient(IClientAPI client)
{ {
client.OnRequestAvatarProperties += RequestAvatarProperty; client.OnRequestAvatarProperties += RequestAvatarProperty;

View File

@ -47,17 +47,19 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene; private static readonly string m_parcelVoiceInfoRequestPath = "0007/";
private IConfig m_config; private static readonly string m_provisionVoiceAccountRequestPath = "0008/";
private string m_asterisk; private string m_asterisk;
private string m_asterisk_password; private string m_asterisk_password;
private string m_asterisk_salt; private string m_asterisk_salt;
private int m_asterisk_timeout; private int m_asterisk_timeout;
private string m_sipDomain;
private string m_confDomain; private string m_confDomain;
private IConfig m_config;
private Scene m_scene;
private string m_sipDomain;
private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; #region IRegionModule Members
private static readonly string m_provisionVoiceAccountRequestPath = "0008/";
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
@ -77,7 +79,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
} }
m_log.Info("[ASTERISKVOICE] plugin enabled"); m_log.Info("[ASTERISKVOICE] plugin enabled");
try { try
{
m_sipDomain = m_config.GetString("sip_domain", String.Empty); m_sipDomain = m_config.GetString("sip_domain", String.Empty);
m_log.InfoFormat("[ASTERISKVOICE] using SIP domain {0}", m_sipDomain); m_log.InfoFormat("[ASTERISKVOICE] using SIP domain {0}", m_sipDomain);
@ -120,6 +123,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
get { return false; } get { return false; }
} }
#endregion
public void OnRegisterCaps(LLUUID agentID, Caps caps) public void OnRegisterCaps(LLUUID agentID, Caps caps)
{ {
m_log.DebugFormat("[ASTERISKVOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); m_log.DebugFormat("[ASTERISKVOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
@ -189,11 +194,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
SendParams.Add(requestData); SendParams.Add(requestData);
XmlRpcRequest updateAccountRequest = new XmlRpcRequest("region_update", SendParams); XmlRpcRequest updateAccountRequest = new XmlRpcRequest("region_update", SendParams);
XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout); XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout);
Hashtable responseData = (Hashtable)updateAccountResponse.Value; Hashtable responseData = (Hashtable) updateAccountResponse.Value;
if (!responseData.ContainsKey("success")) throw new Exception("region_update call failed"); if (!responseData.ContainsKey("success")) throw new Exception("region_update call failed");
bool success = Convert.ToBoolean((string)responseData["success"]); bool success = Convert.ToBoolean((string) responseData["success"]);
if (!success) throw new Exception("region_update failed"); if (!success) throw new Exception("region_update failed");
@ -264,11 +269,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
SendParams.Add(requestData); SendParams.Add(requestData);
XmlRpcRequest updateAccountRequest = new XmlRpcRequest("account_update", SendParams); XmlRpcRequest updateAccountRequest = new XmlRpcRequest("account_update", SendParams);
XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout); XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout);
Hashtable responseData = (Hashtable)updateAccountResponse.Value; Hashtable responseData = (Hashtable) updateAccountResponse.Value;
if (!responseData.ContainsKey("success")) throw new Exception("account_update call failed"); if (!responseData.ContainsKey("success")) throw new Exception("account_update call failed");
bool success = Convert.ToBoolean((string)responseData["success"]); bool success = Convert.ToBoolean((string) responseData["success"]);
if (!success) throw new Exception("account_update failed"); if (!success) throw new Exception("account_update failed");
return r; return r;

View File

@ -46,12 +46,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private IConfig m_config;
private string m_sipDomain;
private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; private static readonly string m_parcelVoiceInfoRequestPath = "0007/";
private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; private static readonly string m_provisionVoiceAccountRequestPath = "0008/";
private IConfig m_config;
private Scene m_scene;
private string m_sipDomain;
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
@ -95,6 +96,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice
get { return false; } get { return false; }
} }
#endregion
public void OnRegisterCaps(LLUUID agentID, Caps caps) public void OnRegisterCaps(LLUUID agentID, Caps caps)
{ {
m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps);

View File

@ -28,15 +28,23 @@
using System; using System;
using Nini.Config; using Nini.Config;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.Framework;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules.Framework namespace OpenSim.Region.Environment.Modules.Framework
{ {
public class CommanderTestModule : IRegionModule, ICommandableModule public class CommanderTestModule : IRegionModule, ICommandableModule
{ {
Commander m_commander = new Commander("CommanderTest"); private Commander m_commander = new Commander("CommanderTest");
Scene m_scene; private Scene m_scene;
#region ICommandableModule Members
public ICommander CommandInterface
{
get { throw new NotImplementedException(); }
}
#endregion
#region IRegionModule Members #region IRegionModule Members
@ -45,11 +53,6 @@ namespace OpenSim.Region.Environment.Modules.Framework
m_scene = scene; m_scene = scene;
} }
private void InterfaceHelloWorld(Object[] args)
{
Console.WriteLine("Hello World");
}
public void PostInitialise() public void PostInitialise()
{ {
Command testCommand = new Command("hello", InterfaceHelloWorld, "Says a simple debugging test string"); Command testCommand = new Command("hello", InterfaceHelloWorld, "Says a simple debugging test string");
@ -77,13 +80,9 @@ namespace OpenSim.Region.Environment.Modules.Framework
#endregion #endregion
#region ICommandableModule Members private void InterfaceHelloWorld(Object[] args)
public ICommander CommandInterface
{ {
get { throw new NotImplementedException(); } Console.WriteLine("Hello World");
} }
#endregion
} }
} }

View File

@ -35,61 +35,14 @@ namespace OpenSim.Region.Environment.Modules.Communications.Interregion
private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>(); private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>();
private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>(); private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>();
private IConfigSource m_config; private IConfigSource m_config;
private RemotingObject m_myRemote;
private Object m_lockObject = new object();
private TcpChannel m_tcpChannel;
private int m_tcpPort = 10101;
private bool m_enabled = false; private bool m_enabled = false;
#region IRegionModule Members private Object m_lockObject = new object();
private RemotingObject m_myRemote;
private TcpChannel m_tcpChannel;
private int m_tcpPort = 10101;
//TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated. #region IInterregionModule Members
public void Initialise(Scene scene, IConfigSource source)
{
if (m_enabled)
{
m_myLocations.Add(new Location((int) scene.RegionInfo.RegionLocX,
(int) scene.RegionInfo.RegionLocY));
m_config = source;
scene.RegisterModuleInterface<IInterregionModule>(this);
}
}
//TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated.
public void PostInitialise()
{
if (m_enabled)
{
try
{
m_tcpPort = m_config.Configs["Comms"].GetInt("remoting_port", m_tcpPort);
}
catch
{
}
internal_CreateRemotingObjects();
}
}
public void Close()
{
ChannelServices.UnregisterChannel(m_tcpChannel);
}
public string Name
{
get { return "InterregionModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
public void internal_CreateRemotingObjects() public void internal_CreateRemotingObjects()
{ {
@ -106,22 +59,6 @@ namespace OpenSim.Region.Environment.Modules.Communications.Interregion
} }
} }
public void RegisterRemoteRegion(string uri)
{
RegisterRemotingInterface((RemotingObject) Activator.GetObject(typeof (RemotingObject), uri));
}
private void RegisterRemotingInterface(RemotingObject remote)
{
Location[] locs = remote.GetLocations();
string[] interfaces = remote.GetInterfaces();
foreach (Location loc in locs)
{
m_neighbourInterfaces[loc] = interfaces;
m_neighbourRemote[loc] = remote;
}
}
public void RegisterMethod<T>(T e) public void RegisterMethod<T>(T e)
{ {
m_interfaces[typeof (T)] = e; m_interfaces[typeof (T)] = e;
@ -171,5 +108,73 @@ namespace OpenSim.Region.Environment.Modules.Communications.Interregion
{ {
return new Location(0, 0); return new Location(0, 0);
} }
#endregion
//TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated.
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource source)
{
if (m_enabled)
{
m_myLocations.Add(new Location((int) scene.RegionInfo.RegionLocX,
(int) scene.RegionInfo.RegionLocY));
m_config = source;
scene.RegisterModuleInterface<IInterregionModule>(this);
}
}
//TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated.
public void PostInitialise()
{
if (m_enabled)
{
try
{
m_tcpPort = m_config.Configs["Comms"].GetInt("remoting_port", m_tcpPort);
}
catch
{
}
internal_CreateRemotingObjects();
}
}
public void Close()
{
ChannelServices.UnregisterChannel(m_tcpChannel);
}
public string Name
{
get { return "InterregionModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
public void RegisterRemoteRegion(string uri)
{
RegisterRemotingInterface((RemotingObject) Activator.GetObject(typeof (RemotingObject), uri));
}
private void RegisterRemotingInterface(RemotingObject remote)
{
Location[] locs = remote.GetLocations();
string[] interfaces = remote.GetInterfaces();
foreach (Location loc in locs)
{
m_neighbourInterfaces[loc] = interfaces;
m_neighbourRemote[loc] = remote;
}
}
} }
} }

View File

@ -47,32 +47,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>(); private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>();
public void Initialise(Scene scene, IConfigSource config) #region IDynamicTextureManager Members
{
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
{
RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
scene.RegisterModuleInterface<IDynamicTextureManager>(this);
}
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "DynamicTextureModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
public void RegisterRender(string handleType, IDynamicTextureRender render) public void RegisterRender(string handleType, IDynamicTextureRender render)
{ {
@ -164,20 +139,55 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
return LLUUID.Zero; return LLUUID.Zero;
} }
#endregion
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
{
RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
scene.RegisterModuleInterface<IDynamicTextureManager>(this);
}
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "DynamicTextureModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
#region Nested type: DynamicTextureUpdater
public class DynamicTextureUpdater public class DynamicTextureUpdater
{ {
public LLUUID SimUUID; public bool BlendWithOldTexture = false;
public LLUUID UpdaterID;
public string ContentType;
public string Url;
public string BodyData; public string BodyData;
public LLUUID PrimID; public string ContentType;
public int UpdateTimer; public byte FrontAlpha = 255;
public LLUUID LastAssetID; public LLUUID LastAssetID;
public string Params; public string Params;
public bool BlendWithOldTexture = false; public LLUUID PrimID;
public bool SetNewFrontAlpha = false; public bool SetNewFrontAlpha = false;
public byte FrontAlpha = 255; public LLUUID SimUUID;
public LLUUID UpdaterID;
public int UpdateTimer;
public string Url;
public DynamicTextureUpdater() public DynamicTextureUpdater()
{ {
@ -273,5 +283,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
} }
} }
} }
#endregion
} }
} }

View File

@ -84,45 +84,20 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
{ {
public class HttpRequestModule : IRegionModule, IHttpRequests public class HttpRequestModule : IRegionModule, IHttpRequests
{ {
private Scene m_scene;
private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>();
private object HttpListLock = new object(); private object HttpListLock = new object();
private string m_name = "HttpScriptRequests";
private int httpTimeout = 30000; private int httpTimeout = 30000;
private string m_name = "HttpScriptRequests";
// <request id, HttpRequestClass> // <request id, HttpRequestClass>
private Dictionary<LLUUID, HttpRequestClass> m_pendingRequests; private Dictionary<LLUUID, HttpRequestClass> m_pendingRequests;
private Scene m_scene;
private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>();
public HttpRequestModule() public HttpRequestModule()
{ {
} }
public void Initialise(Scene scene, IConfigSource config) #region IHttpRequests Members
{
m_scene = scene;
m_scene.RegisterModuleInterface<IHttpRequests>(this);
m_pendingRequests = new Dictionary<LLUUID, HttpRequestClass>();
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return m_name; }
}
public bool IsSharedModule
{
get { return true; }
}
public LLUUID MakeHttpRequest(string url, string parameters, string body) public LLUUID MakeHttpRequest(string url, string parameters, string body)
{ {
@ -141,7 +116,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
if (parameters != null) if (parameters != null)
{ {
string[] parms = parameters.ToArray(); string[] parms = parameters.ToArray();
for (int i = 0; i < parms.Length/2; i += 2) for (int i = 0; i < parms.Length / 2; i += 2)
{ {
switch (Int32.Parse(parms[i])) switch (Int32.Parse(parms[i]))
{ {
@ -187,7 +162,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
public void StopHttpRequest(uint m_localID, LLUUID m_itemID) public void StopHttpRequest(uint m_localID, LLUUID m_itemID)
{ {
if(m_pendingRequests != null) { if (m_pendingRequests != null)
{
lock (HttpListLock) lock (HttpListLock)
{ {
HttpRequestClass tmpReq; HttpRequestClass tmpReq;
@ -243,36 +219,68 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
} }
} }
#endregion
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
m_scene.RegisterModuleInterface<IHttpRequests>(this);
m_pendingRequests = new Dictionary<LLUUID, HttpRequestClass>();
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return m_name; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
} }
public class HttpRequestClass public class HttpRequestClass
{ {
// Constants for parameters // Constants for parameters
public const int HTTP_BODY_MAXLENGTH = 2;
public const int HTTP_METHOD = 0; public const int HTTP_METHOD = 0;
public const int HTTP_MIMETYPE = 1; public const int HTTP_MIMETYPE = 1;
public const int HTTP_BODY_MAXLENGTH = 2;
public const int HTTP_VERIFY_CERT = 3; public const int HTTP_VERIFY_CERT = 3;
public bool finished;
public int httpBodyMaxLen = 2048; // not implemented
// Parameter members and default values // Parameter members and default values
public string httpMethod = "GET"; public string httpMethod = "GET";
public string httpMIMEType = "text/plain;charset=utf-8"; public string httpMIMEType = "text/plain;charset=utf-8";
public int httpBodyMaxLen = 2048; // not implemented private Thread httpThread;
public int httpTimeout;
public bool httpVerifyCert = true; // not implemented public bool httpVerifyCert = true; // not implemented
// Request info // Request info
public uint localID;
public LLUUID itemID; public LLUUID itemID;
public LLUUID reqID; public uint localID;
public int httpTimeout;
public string url;
public string outbound_body;
public DateTime next; public DateTime next;
public int status; public string outbound_body;
public bool finished; public LLUUID reqID;
public List<string> response_metadata;
public string response_body;
public HttpWebRequest request; public HttpWebRequest request;
private Thread httpThread; public string response_body;
public List<string> response_metadata;
public int status;
public string url;
public void process() public void process()
{ {

View File

@ -40,39 +40,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
public class LoadImageURLModule : IRegionModule, IDynamicTextureRender public class LoadImageURLModule : IRegionModule, IDynamicTextureRender
{ {
private string m_name = "LoadImageURL"; private string m_name = "LoadImageURL";
private IDynamicTextureManager m_textureManager;
private Scene m_scene; private Scene m_scene;
private IDynamicTextureManager m_textureManager;
public void Initialise(Scene scene, IConfigSource config) #region IDynamicTextureRender Members
{
if (m_scene == null)
{
m_scene = scene;
}
}
public void PostInitialise()
{
m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
if (m_textureManager != null)
{
m_textureManager.RegisterRender(GetContentType(), this);
}
}
public void Close()
{
}
public string Name
{
get { return m_name; }
}
public bool IsSharedModule
{
get { return true; }
}
public string GetName() public string GetName()
{ {
@ -110,6 +81,43 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
return false; return false;
} }
#endregion
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
if (m_scene == null)
{
m_scene = scene;
}
}
public void PostInitialise()
{
m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
if (m_textureManager != null)
{
m_textureManager.RegisterRender(GetContentType(), this);
}
}
public void Close()
{
}
public string Name
{
get { return m_name; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
private void MakeHttpRequest(string url, LLUUID requestID) private void MakeHttpRequest(string url, LLUUID requestID)
{ {
WebRequest request = HttpWebRequest.Create(url); WebRequest request = HttpWebRequest.Create(url);
@ -139,7 +147,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
{ {
newsize = new Size(64, 64); newsize = new Size(64, 64);
} }
else if ((image.Height <256) && (image.Width < 256)) else if ((image.Height < 256) && (image.Width < 256))
{ {
newsize = new Size(128, 128); newsize = new Size(128, 128);
} }
@ -153,7 +161,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
} }
else else
{ {
newsize = new Size(1024,1024); newsize = new Size(1024, 1024);
} }
Bitmap resize = new Bitmap(image, newsize); Bitmap resize = new Bitmap(image, newsize);
@ -163,6 +171,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
} }
} }
#region Nested type: RequestState
public class RequestState public class RequestState
{ {
public HttpWebRequest Request = null; public HttpWebRequest Request = null;
@ -175,5 +185,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
RequestID = requestID; RequestID = requestID;
} }
} }
#endregion
} }
} }

View File

@ -44,14 +44,56 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
{ {
public class VectorRenderModule : IRegionModule, IDynamicTextureRender public class VectorRenderModule : IRegionModule, IDynamicTextureRender
{ {
private Scene m_scene;
private string m_name = "VectorRenderModule"; private string m_name = "VectorRenderModule";
private Scene m_scene;
private IDynamicTextureManager m_textureManager; private IDynamicTextureManager m_textureManager;
public VectorRenderModule() public VectorRenderModule()
{ {
} }
#region IDynamicTextureRender Members
public string GetContentType()
{
return ("vector");
}
public string GetName()
{
return m_name;
}
public bool SupportsAsynchronous()
{
return true;
}
public byte[] ConvertUrl(string url, string extraParams)
{
return null;
}
public byte[] ConvertStream(Stream data, string extraParams)
{
return null;
}
public bool AsyncConvertUrl(LLUUID id, string url, string extraParams)
{
return false;
}
public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams)
{
Draw(bodyData, id, extraParams);
return true;
}
#endregion
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
if (m_scene == null) if (m_scene == null)
@ -83,14 +125,18 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
get { return true; } get { return true; }
} }
#endregion
private void Draw(string data, LLUUID id, string extraParams) private void Draw(string data, LLUUID id, string extraParams)
{ {
// TODO: this is a brutal hack. extraParams should actually be parsed reasonably. // TODO: this is a brutal hack. extraParams should actually be parsed reasonably.
int size = 256; int size = 256;
try { try
{
size = Convert.ToInt32(extraParams); size = Convert.ToInt32(extraParams);
} catch (Exception e) { }
catch (Exception e)
{
//Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used //Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used
Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString()); Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString());
} }
@ -122,12 +168,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
} }
GDIDraw(data, graph); GDIDraw(data, graph);
byte[] imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true); byte[] imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true);
m_textureManager.ReturnData(id, imageJ2000); m_textureManager.ReturnData(id, imageJ2000);
} }
/* /*
@ -175,8 +219,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
Pen drawPen = new Pen(Color.Black, 7); Pen drawPen = new Pen(Color.Black, 7);
Font myFont = new Font("Times New Roman", 14); Font myFont = new Font("Times New Roman", 14);
SolidBrush myBrush = new SolidBrush(Color.Black); SolidBrush myBrush = new SolidBrush(Color.Black);
char[] lineDelimiter = { ';' }; char[] lineDelimiter = {';'};
char[] partsDelimiter = { ',' }; char[] partsDelimiter = {','};
string[] lines = data.Split(lineDelimiter); string[] lines = data.Split(lineDelimiter);
foreach (string line in lines) foreach (string line in lines)
@ -188,16 +232,16 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
float x = 0; float x = 0;
float y = 0; float y = 0;
GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y); GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y);
startPoint.X = (int)x; startPoint.X = (int) x;
startPoint.Y = (int)y; startPoint.Y = (int) y;
} }
else if (nextLine.StartsWith("LineTo")) else if (nextLine.StartsWith("LineTo"))
{ {
float x = 0; float x = 0;
float y = 0; float y = 0;
GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y); GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y);
endPoint.X = (int)x; endPoint.X = (int) x;
endPoint.Y = (int)y; endPoint.Y = (int) y;
graph.DrawLine(drawPen, startPoint, endPoint); graph.DrawLine(drawPen, startPoint, endPoint);
startPoint.X = endPoint.X; startPoint.X = endPoint.X;
startPoint.Y = endPoint.Y; startPoint.Y = endPoint.Y;
@ -213,10 +257,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
float x = 0; float x = 0;
float y = 0; float y = 0;
GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y); GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y);
endPoint.X = (int)x; endPoint.X = (int) x;
endPoint.Y = (int)y; endPoint.Y = (int) y;
Image image = ImageHttpRequest(nextLine); Image image = ImageHttpRequest(nextLine);
graph.DrawImage(image, (float)startPoint.X, (float)startPoint.Y, x, y); graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y);
startPoint.X += endPoint.X; startPoint.X += endPoint.X;
startPoint.Y += endPoint.Y; startPoint.Y += endPoint.Y;
} }
@ -225,8 +269,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
float x = 0; float x = 0;
float y = 0; float y = 0;
GetParams(partsDelimiter, ref nextLine, 9, ref x, ref y); GetParams(partsDelimiter, ref nextLine, 9, ref x, ref y);
endPoint.X = (int)x; endPoint.X = (int) x;
endPoint.Y = (int)y; endPoint.Y = (int) y;
graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
startPoint.X += endPoint.X; startPoint.X += endPoint.X;
startPoint.Y += endPoint.Y; startPoint.Y += endPoint.Y;
@ -236,8 +280,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
float x = 0; float x = 0;
float y = 0; float y = 0;
GetParams(partsDelimiter, ref nextLine, 13, ref x, ref y); GetParams(partsDelimiter, ref nextLine, 13, ref x, ref y);
endPoint.X = (int)x; endPoint.X = (int) x;
endPoint.Y = (int)y; endPoint.Y = (int) y;
graph.FillRectangle(myBrush, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); graph.FillRectangle(myBrush, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
startPoint.X += endPoint.X; startPoint.X += endPoint.X;
startPoint.Y += endPoint.Y; startPoint.Y += endPoint.Y;
@ -247,8 +291,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
float x = 0; float x = 0;
float y = 0; float y = 0;
GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y); GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y);
endPoint.X = (int)x; endPoint.X = (int) x;
endPoint.Y = (int)y; endPoint.Y = (int) y;
graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
startPoint.X += endPoint.X; startPoint.X += endPoint.X;
startPoint.Y += endPoint.Y; startPoint.Y += endPoint.Y;
@ -312,7 +356,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
WebRequest request = HttpWebRequest.Create(url); WebRequest request = HttpWebRequest.Create(url);
//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. //Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used.
//Ckrinke Stream str = null; //Ckrinke Stream str = null;
HttpWebResponse response = (HttpWebResponse)(request).GetResponse(); HttpWebResponse response = (HttpWebResponse) (request).GetResponse();
if (response.StatusCode == HttpStatusCode.OK) if (response.StatusCode == HttpStatusCode.OK)
{ {
Bitmap image = new Bitmap(response.GetResponseStream()); Bitmap image = new Bitmap(response.GetResponseStream());
@ -321,41 +365,5 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
return null; return null;
} }
public string GetContentType()
{
return ("vector");
}
public string GetName()
{
return m_name;
}
public bool SupportsAsynchronous()
{
return true;
}
public byte[] ConvertUrl(string url, string extraParams)
{
return null;
}
public byte[] ConvertStream(Stream data, string extraParams)
{
return null;
}
public bool AsyncConvertUrl(LLUUID id, string url, string extraParams)
{
return false;
}
public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams)
{
Draw(bodyData, id, extraParams);
return true;
}
} }
} }

View File

@ -67,18 +67,20 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
{ {
public class WorldCommModule : IRegionModule, IWorldComm public class WorldCommModule : IRegionModule, IWorldComm
{ {
private Scene m_scene;
private object CommListLock = new object(); private object CommListLock = new object();
private object ListLock = new object(); private object ListLock = new object();
private string m_name = "WorldCommModule";
private ListenerManager m_listenerManager; private ListenerManager m_listenerManager;
private Queue m_pendingQ; private string m_name = "WorldCommModule";
private Queue m_pending; private Queue m_pending;
private Queue m_pendingQ;
private Scene m_scene;
public WorldCommModule() public WorldCommModule()
{ {
} }
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
m_scene = scene; m_scene = scene;
@ -107,23 +109,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
get { return false; } get { return false; }
} }
public void NewClient(IClientAPI client) #endregion
{
client.OnChatFromViewer += DeliverClientMessage;
}
/******************************************************************** #region IWorldComm Members
*
* Listener Stuff
*
* *****************************************************************/
private void DeliverClientMessage(Object sender, ChatFromViewerArgs e)
{
DeliverMessage(e.Sender.AgentId.ToString(),
e.Type, e.Channel,
e.Sender.FirstName + " " + e.Sender.LastName,
e.Message);
}
public int Listen(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg) public int Listen(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg)
{ {
@ -295,7 +283,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
lock (m_pending.SyncRoot) lock (m_pending.SyncRoot)
{ {
li = (ListenerInfo)m_pending.Dequeue(); li = (ListenerInfo) m_pending.Dequeue();
} }
return li; return li;
@ -303,20 +291,41 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
public uint PeekNextMessageLocalID() public uint PeekNextMessageLocalID()
{ {
return ((ListenerInfo)m_pending.Peek()).GetLocalID(); return ((ListenerInfo) m_pending.Peek()).GetLocalID();
} }
public LLUUID PeekNextMessageItemID() public LLUUID PeekNextMessageItemID()
{ {
return ((ListenerInfo)m_pending.Peek()).GetItemID(); return ((ListenerInfo) m_pending.Peek()).GetItemID();
}
#endregion
public void NewClient(IClientAPI client)
{
client.OnChatFromViewer += DeliverClientMessage;
}
/********************************************************************
*
* Listener Stuff
*
* *****************************************************************/
private void DeliverClientMessage(Object sender, ChatFromViewerArgs e)
{
DeliverMessage(e.Sender.AgentId.ToString(),
e.Type, e.Channel,
e.Sender.FirstName + " " + e.Sender.LastName,
e.Message);
} }
} }
public class ListenerManager public class ListenerManager
{ {
//private Dictionary<int, ListenerInfo> m_listeners; //private Dictionary<int, ListenerInfo> m_listeners;
private Hashtable m_listeners = Hashtable.Synchronized(new Hashtable());
private object ListenersLock = new object(); private object ListenersLock = new object();
private Hashtable m_listeners = Hashtable.Synchronized(new Hashtable());
private int m_MaxListeners = 100; private int m_MaxListeners = 100;
public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg) public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg)
@ -363,7 +372,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
IDictionaryEnumerator en = m_listeners.GetEnumerator(); IDictionaryEnumerator en = m_listeners.GetEnumerator();
while (en.MoveNext()) while (en.MoveNext())
{ {
ListenerInfo li = (ListenerInfo)en.Value; ListenerInfo li = (ListenerInfo) en.Value;
if (li.GetItemID().Equals(itemID)) if (li.GetItemID().Equals(itemID))
{ {
removedListeners.Add(li.GetHandle()); removedListeners.Add(li.GetHandle());
@ -400,12 +409,11 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
public void Activate(int handle) public void Activate(int handle)
{ {
if (m_listeners.ContainsKey(handle)) if (m_listeners.ContainsKey(handle))
{ {
lock (m_listeners.SyncRoot) lock (m_listeners.SyncRoot)
{ {
ListenerInfo li = (ListenerInfo)m_listeners[handle]; ListenerInfo li = (ListenerInfo) m_listeners[handle];
li.Activate(); li.Activate();
} }
} }
@ -413,10 +421,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
public void Dectivate(int handle) public void Dectivate(int handle)
{ {
if (m_listeners.ContainsKey(handle)) if (m_listeners.ContainsKey(handle))
{ {
ListenerInfo li = (ListenerInfo)m_listeners[handle]; ListenerInfo li = (ListenerInfo) m_listeners[handle];
li.Deactivate(); li.Deactivate();
} }
} }
@ -432,7 +439,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
IDictionaryEnumerator en = m_listeners.GetEnumerator(); IDictionaryEnumerator en = m_listeners.GetEnumerator();
while (en.MoveNext()) while (en.MoveNext())
{ {
ListenerInfo li = (ListenerInfo)en.Value; ListenerInfo li = (ListenerInfo) en.Value;
if (li.IsActive()) if (li.IsActive())
{ {
@ -478,16 +485,16 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
public class ListenerInfo public class ListenerInfo
{ {
private LLUUID m_itemID; // ID of the host script engine private bool m_active; // Listener is active or not
private LLUUID m_hostID; // ID of the host/scene part
private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message
private int m_channel; // Channel private int m_channel; // Channel
private int m_handle; // Assigned handle of this listener private int m_handle; // Assigned handle of this listener
private uint m_localID; // Local ID from script engine private LLUUID m_hostID; // ID of the host/scene part
private string m_name; // Object name to filter messages from
private LLUUID m_id; // ID to filter messages from private LLUUID m_id; // ID to filter messages from
private LLUUID m_itemID; // ID of the host script engine
private uint m_localID; // Local ID from script engine
private string m_message; // The message private string m_message; // The message
private bool m_active; // Listener is active or not private string m_name; // Object name to filter messages from
private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message
public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message) public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message)
{ {

View File

@ -79,20 +79,21 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private object XMLRPCListLock = new object();
private string m_name = "XMLRPCModule"; private string m_name = "XMLRPCModule";
private int RemoteReplyScriptWait = 300;
private int RemoteReplyScriptTimeout = 9000;
private int m_remoteDataPort = 0;
private List<Scene> m_scenes = new List<Scene>();
// <channel id, RPCChannelInfo> // <channel id, RPCChannelInfo>
private Dictionary<LLUUID, RPCChannelInfo> m_openChannels; private Dictionary<LLUUID, RPCChannelInfo> m_openChannels;
private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses;
private int m_remoteDataPort = 0;
private Dictionary<LLUUID, RPCRequestInfo> m_rpcPending; private Dictionary<LLUUID, RPCRequestInfo> m_rpcPending;
private Dictionary<LLUUID, RPCRequestInfo> m_rpcPendingResponses; private Dictionary<LLUUID, RPCRequestInfo> m_rpcPendingResponses;
private List<Scene> m_scenes = new List<Scene>();
private int RemoteReplyScriptTimeout = 9000;
private int RemoteReplyScriptWait = 300;
private object XMLRPCListLock = new object();
private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses; #region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
@ -125,7 +126,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
// Attach xmlrpc handlers // Attach xmlrpc handlers
m_log.Info("[REMOTE_DATA]: " + m_log.Info("[REMOTE_DATA]: " +
"Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands.");
BaseHttpServer httpServer = new BaseHttpServer((uint)m_remoteDataPort); BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort);
httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
httpServer.Start(); httpServer.Start();
} }
@ -145,6 +146,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
get { return true; } get { return true; }
} }
#endregion
#region IXMLRPC Members
public bool IsEnabled() public bool IsEnabled()
{ {
return (m_remoteDataPort > 0); return (m_remoteDataPort > 0);
@ -196,7 +201,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
// for when a script is deleted // for when a script is deleted
public void DeleteChannels(LLUUID itemID) public void DeleteChannels(LLUUID itemID)
{ {
if (m_openChannels != null) if (m_openChannels != null)
{ {
ArrayList tmp = new ArrayList(); ArrayList tmp = new ArrayList();
@ -212,12 +216,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
} }
IEnumerator tmpEnumerator = tmp.GetEnumerator(); IEnumerator tmpEnumerator = tmp.GetEnumerator();
while ( tmpEnumerator.MoveNext() ) while (tmpEnumerator.MoveNext())
m_openChannels.Remove((LLUUID)tmpEnumerator.Current); m_openChannels.Remove((LLUUID) tmpEnumerator.Current);
} }
} }
} }
/********************************************** /**********************************************
@ -255,67 +257,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
} }
public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0];
bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
requestData.Contains("StringValue"));
if (GoodXML)
{
LLUUID channel = new LLUUID((string)requestData["Channel"]);
RPCChannelInfo rpcChanInfo;
if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
{
string intVal = (string)requestData["IntValue"];
string strVal = (string)requestData["StringValue"];
RPCRequestInfo rpcInfo;
lock (XMLRPCListLock)
{
rpcInfo =
new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
intVal);
m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo);
}
int timeoutCtr = 0;
while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
{
Thread.Sleep(RemoteReplyScriptWait);
timeoutCtr += RemoteReplyScriptWait;
}
if (rpcInfo.IsProcessed())
{
Hashtable param = new Hashtable();
param["StringValue"] = rpcInfo.GetStrRetval();
param["IntValue"] = Convert.ToString(rpcInfo.GetIntRetval());
ArrayList parameters = new ArrayList();
parameters.Add(param);
response.Value = parameters;
rpcInfo = null;
}
else
{
response.SetFault(-1, "Script timeout");
rpcInfo = null;
}
}
else
{
response.SetFault(-1, "Invalid channel");
}
}
return response;
}
public bool hasRequests() public bool hasRequests()
{ {
lock (XMLRPCListLock) lock (XMLRPCListLock)
@ -339,7 +280,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
if (m_rpcPending.TryGetValue(luid, out tmpReq)) if (m_rpcPending.TryGetValue(luid, out tmpReq))
{ {
if (!tmpReq.IsProcessed()) return tmpReq; if (!tmpReq.IsProcessed()) return tmpReq;
} }
} }
@ -367,13 +307,11 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
public LLUUID SendRemoteData(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata) public LLUUID SendRemoteData(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata)
{ {
SendRemoteDataRequest req = new SendRemoteDataRequest( SendRemoteDataRequest req = new SendRemoteDataRequest(
localID, itemID, channel, dest, idata, sdata localID, itemID, channel, dest, idata, sdata
); );
m_pendingSRDResponses.Add(req.GetReqID(), req); m_pendingSRDResponses.Add(req.GetReqID(), req);
return req.process(); return req.process();
} }
public SendRemoteDataRequest GetNextCompletedSRDRequest() public SendRemoteDataRequest GetNextCompletedSRDRequest()
@ -423,19 +361,82 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
} }
} }
} }
#endregion
public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable) request.Params[0];
bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
requestData.Contains("StringValue"));
if (GoodXML)
{
LLUUID channel = new LLUUID((string) requestData["Channel"]);
RPCChannelInfo rpcChanInfo;
if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
{
string intVal = (string) requestData["IntValue"];
string strVal = (string) requestData["StringValue"];
RPCRequestInfo rpcInfo;
lock (XMLRPCListLock)
{
rpcInfo =
new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
intVal);
m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo);
}
int timeoutCtr = 0;
while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
{
Thread.Sleep(RemoteReplyScriptWait);
timeoutCtr += RemoteReplyScriptWait;
}
if (rpcInfo.IsProcessed())
{
Hashtable param = new Hashtable();
param["StringValue"] = rpcInfo.GetStrRetval();
param["IntValue"] = Convert.ToString(rpcInfo.GetIntRetval());
ArrayList parameters = new ArrayList();
parameters.Add(param);
response.Value = parameters;
rpcInfo = null;
}
else
{
response.SetFault(-1, "Script timeout");
rpcInfo = null;
}
}
else
{
response.SetFault(-1, "Invalid channel");
}
}
return response;
}
} }
public class RPCRequestInfo public class RPCRequestInfo
{ {
private string m_StrVal;
private string m_IntVal;
private bool m_processed;
private string m_respStr;
private int m_respInt;
private uint m_localID;
private LLUUID m_ItemID;
private LLUUID m_MessageID;
private LLUUID m_ChannelKey; private LLUUID m_ChannelKey;
private string m_IntVal;
private LLUUID m_ItemID;
private uint m_localID;
private LLUUID m_MessageID;
private bool m_processed;
private int m_respInt;
private string m_respStr;
private string m_StrVal;
public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal) public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal)
{ {
@ -474,6 +475,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
{ {
return m_respStr; return m_respStr;
} }
public void SetIntRetval(int resp) public void SetIntRetval(int resp)
{ {
m_respInt = resp; m_respInt = resp;
@ -483,6 +485,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
{ {
return m_respInt; return m_respInt;
} }
public uint GetLocalID() public uint GetLocalID()
{ {
return m_localID; return m_localID;
@ -511,9 +514,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
public class RPCChannelInfo public class RPCChannelInfo
{ {
private LLUUID m_ChannelKey;
private LLUUID m_itemID; private LLUUID m_itemID;
private uint m_localID; private uint m_localID;
private LLUUID m_ChannelKey;
public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID) public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID)
{ {
@ -536,38 +539,34 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
{ {
return m_localID; return m_localID;
} }
} }
public class SendRemoteDataRequest public class SendRemoteDataRequest
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public LLUUID reqID;
public string destURL;
public string channel; public string channel;
public string sdata; public string destURL;
public int idata;
public bool finished; public bool finished;
public string response_sdata;
public int response_idata;
public XmlRpcRequest request;
private Thread httpThread; private Thread httpThread;
public int idata;
public LLUUID m_itemID; public LLUUID m_itemID;
public uint m_localID; public uint m_localID;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public LLUUID reqID;
public XmlRpcRequest request;
public int response_idata;
public string response_sdata;
public string sdata;
public SendRemoteDataRequest(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata) public SendRemoteDataRequest(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata)
{ {
this.channel = channel; this.channel = channel;
this.destURL = dest; destURL = dest;
this.idata = idata; this.idata = idata;
this.sdata = sdata; this.sdata = sdata;
m_itemID = itemID; m_itemID = itemID;
m_localID = localID; m_localID = localID;
reqID = LLUUID.Random(); reqID = LLUUID.Random();
} }
public LLUUID process() public LLUUID process()
@ -581,7 +580,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
ThreadTracker.Add(httpThread); ThreadTracker.Add(httpThread);
return reqID; return reqID;
} }
/* /*
@ -597,8 +595,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
// if not, use as method name // if not, use as method name
LLUUID parseUID; LLUUID parseUID;
string mName = "llRemoteData"; string mName = "llRemoteData";
if( (channel != null) && (channel != "") ) if ((channel != null) && (channel != ""))
if( !LLUUID.TryParse(channel, out parseUID) ) if (!LLUUID.TryParse(channel, out parseUID))
mName = channel; mName = channel;
else else
param["Channel"] = channel; param["Channel"] = channel;
@ -615,26 +613,28 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
if (resp != null) if (resp != null)
{ {
Hashtable respParms; Hashtable respParms;
if(resp.Value.GetType().Equals(Type.GetType("System.Collections.Hashtable"))) { if (resp.Value.GetType().Equals(Type.GetType("System.Collections.Hashtable")))
respParms = (Hashtable)resp.Value; {
respParms = (Hashtable) resp.Value;
} }
else { else
ArrayList respData = (ArrayList)resp.Value; {
respParms = (Hashtable)respData[0]; ArrayList respData = (ArrayList) resp.Value;
respParms = (Hashtable) respData[0];
} }
if (respParms != null) if (respParms != null)
{ {
if (respParms.Contains("StringValue")) if (respParms.Contains("StringValue"))
{ {
sdata = (string)respParms["StringValue"]; sdata = (string) respParms["StringValue"];
} }
if (respParms.Contains("IntValue")) if (respParms.Contains("IntValue"))
{ {
idata = Convert.ToInt32((string)respParms["IntValue"]); idata = Convert.ToInt32((string) respParms["IntValue"]);
} }
if (respParms.Contains("faultString")) if (respParms.Contains("faultString"))
{ {
sdata = (string)respParms["faultString"]; sdata = (string) respParms["faultString"];
} }
if (respParms.Contains("faultCode")) if (respParms.Contains("faultCode"))
{ {

View File

@ -43,61 +43,45 @@ namespace OpenSim.Region.Environment.Modules.World.Land
//Land types set with flags in ParcelOverlay. //Land types set with flags in ParcelOverlay.
//Only one of these can be used. //Only one of these can be used.
public const byte LAND_TYPE_PUBLIC = (byte)0; //Equals 00000000 public const float BAN_LINE_SAFETY_HIEGHT = 100;
public const byte LAND_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000
public const byte LAND_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 64; //Equals 01000000
public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011
public const byte LAND_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100
public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101
//Flags that when set, a border on the given side will be placed
//NOTE: North and East is assumable by the west and south sides (if land to east has a west border, then I have an east border; etc)
//This took forever to figure out -- jeesh. /blame LL for even having to send these
public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000
public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000
//RequestResults (I think these are right, they seem to work): //RequestResults (I think these are right, they seem to work):
public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land
public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land
public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land
//ParcelSelectObjects //ParcelSelectObjects
public const int LAND_SELECT_OBJECTS_OWNER = 2;
public const int LAND_SELECT_OBJECTS_GROUP = 4; public const int LAND_SELECT_OBJECTS_GROUP = 4;
public const int LAND_SELECT_OBJECTS_OTHER = 8; public const int LAND_SELECT_OBJECTS_OTHER = 8;
public const int LAND_SELECT_OBJECTS_OWNER = 2;
public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101
public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100
public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010
public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001
public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011
public const byte LAND_TYPE_PUBLIC = (byte) 0; //Equals 00000000
//These are other constants. Yay! //These are other constants. Yay!
public const int START_LAND_LOCAL_ID = 1; public const int START_LAND_LOCAL_ID = 1;
public const float BAN_LINE_SAFETY_HIEGHT = 100;
#endregion #endregion
private Scene m_scene; private int[,] landIDList = new int[64,64];
private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>(); private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>();
private int lastLandLocalID = START_LAND_LOCAL_ID - 1;
private int[,] landIDList = new int[64, 64];
private bool landPrimCountTainted = false; private bool landPrimCountTainted = false;
private int lastLandLocalID = START_LAND_LOCAL_ID - 1;
private bool m_allowedForcefulBans = true; private bool m_allowedForcefulBans = true;
public bool allowedForcefulBans private Scene m_scene;
{
get
{
return m_allowedForcefulBans;
}
set
{
m_allowedForcefulBans = value;
}
}
public LandChannel(Scene scene) public LandChannel(Scene scene)
{ {
m_scene = scene; m_scene = scene;
landIDList.Initialize(); landIDList.Initialize();
} }
#region Land Object From Storage Functions #region Land Object From Storage Functions
public void IncomingLandObjectsFromStorage(List<LandData> data) public void IncomingLandObjectsFromStorage(List<LandData> data)
@ -137,6 +121,60 @@ namespace OpenSim.Region.Environment.Modules.World.Land
#region Parcel Add/Remove/Get/Create #region Parcel Add/Remove/Get/Create
public void updateLandObject(int local_id, LandData newData)
{
if (landList.ContainsKey(local_id))
{
landList[local_id].landData = newData.Copy();
m_scene.EventManager.TriggerLandObjectUpdated((uint) local_id, landList[local_id]);
}
}
/// <summary>
/// Get the land object at the specified point
/// </summary>
/// <param name="x">Value between 0 - 256 on the x axis of the point</param>
/// <param name="y">Value between 0 - 256 on the y axis of the point</param>
/// <returns>Land object at the point supplied</returns>
public ILandObject getLandObject(float x_float, float y_float)
{
int x;
int y;
try
{
x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0)));
y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0)));
}
catch (OverflowException)
{
return null;
}
if (x >= 64 || y >= 64 || x < 0 || y < 0)
{
return null;
}
else
{
return landList[landIDList[x, y]];
}
}
public ILandObject getLandObject(int x, int y)
{
if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0)
{
// These exceptions here will cause a lot of complaints from the users specifically because
// they happen every time at border crossings
throw new Exception("Error: Parcel not found at point " + x + ", " + y);
}
else
{
return landList[landIDList[x / 4, y / 4]];
}
}
/// <summary> /// <summary>
/// Creates a basic Parcel object without an owner (a zeroed key) /// Creates a basic Parcel object without an owner (a zeroed key)
/// </summary> /// </summary>
@ -154,7 +192,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{ {
lastLandLocalID++; lastLandLocalID++;
new_land.landData.localID = lastLandLocalID; new_land.landData.localID = lastLandLocalID;
landList.Add(lastLandLocalID, (LandObject)new_land.Copy()); landList.Add(lastLandLocalID, (LandObject) new_land.Copy());
bool[,] landBitmap = new_land.getLandBitmap(); bool[,] landBitmap = new_land.getLandBitmap();
@ -197,15 +235,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
landList.Remove(local_id); landList.Remove(local_id);
} }
public void updateLandObject(int local_id, LandData newData)
{
if (landList.ContainsKey(local_id))
{
landList[local_id].landData = newData.Copy();
m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]);
}
}
private void performFinalLandJoin(ILandObject master, ILandObject slave) private void performFinalLandJoin(ILandObject master, ILandObject slave)
{ {
int x, y; int x, y;
@ -225,37 +254,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
updateLandObject(master.landData.localID, master.landData); updateLandObject(master.landData.localID, master.landData);
} }
/// <summary>
/// Get the land object at the specified point
/// </summary>
/// <param name="x">Value between 0 - 256 on the x axis of the point</param>
/// <param name="y">Value between 0 - 256 on the y axis of the point</param>
/// <returns>Land object at the point supplied</returns>
public ILandObject getLandObject(float x_float, float y_float)
{
int x;
int y;
try
{
x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0)));
y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0)));
}
catch (OverflowException)
{
return null;
}
if (x >= 64 || y >= 64 || x < 0 || y < 0)
{
return null;
}
else
{
return landList[landIDList[x, y]];
}
}
public ILandObject getLandObject(int parcelLocalID) public ILandObject getLandObject(int parcelLocalID)
{ {
lock (landList) lock (landList)
@ -268,24 +266,102 @@ namespace OpenSim.Region.Environment.Modules.World.Land
return null; return null;
} }
public ILandObject getLandObject(int x, int y)
{
if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0)
{
// These exceptions here will cause a lot of complaints from the users specifically because
// they happen every time at border crossings
throw new Exception("Error: Parcel not found at point " + x + ", " + y);
}
else
{
return landList[landIDList[x / 4, y / 4]];
}
}
#endregion #endregion
#region Parcel Modification #region Parcel Modification
public void resetAllLandPrimCounts()
{
foreach (LandObject p in landList.Values)
{
p.resetLandPrimCounts();
}
}
public void setPrimsTainted()
{
landPrimCountTainted = true;
}
public bool isLandPrimCountTainted()
{
return landPrimCountTainted;
}
public void addPrimToLandPrimCounts(SceneObjectGroup obj)
{
LLVector3 position = obj.AbsolutePosition;
ILandObject landUnderPrim = getLandObject(position.X, position.Y);
if (landUnderPrim != null)
{
landUnderPrim.addPrimToCount(obj);
}
}
public void removePrimFromLandPrimCounts(SceneObjectGroup obj)
{
foreach (LandObject p in landList.Values)
{
p.removePrimFromCount(obj);
}
}
public void finalizeLandPrimCountUpdate()
{
//Get Simwide prim count for owner
Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>();
foreach (LandObject p in landList.Values)
{
if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID))
{
List<LandObject> tempList = new List<LandObject>();
tempList.Add(p);
landOwnersAndParcels.Add(p.landData.ownerID, tempList);
}
else
{
landOwnersAndParcels[p.landData.ownerID].Add(p);
}
}
foreach (LLUUID owner in landOwnersAndParcels.Keys)
{
int simArea = 0;
int simPrims = 0;
foreach (LandObject p in landOwnersAndParcels[owner])
{
simArea += p.landData.area;
simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims +
p.landData.selectedPrims;
}
foreach (LandObject p in landOwnersAndParcels[owner])
{
p.landData.simwideArea = simArea;
p.landData.simwidePrims = simPrims;
}
}
}
public void updateLandPrimCounts()
{
foreach (EntityBase obj in m_scene.Entities.Values)
{
if (obj is SceneObjectGroup)
{
m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj);
}
}
}
public void performParcelPrimCountUpdate()
{
resetAllLandPrimCounts();
m_scene.EventManager.TriggerParcelPrimCountUpdate();
finalizeLandPrimCountUpdate();
landPrimCountTainted = false;
}
/// <summary> /// <summary>
/// Subdivides a piece of land /// Subdivides a piece of land
/// </summary> /// </summary>
@ -435,97 +511,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
return true; return true;
} }
public void resetAllLandPrimCounts()
{
foreach (LandObject p in landList.Values)
{
p.resetLandPrimCounts();
}
}
public void setPrimsTainted()
{
landPrimCountTainted = true;
}
public bool isLandPrimCountTainted()
{
return landPrimCountTainted;
}
public void addPrimToLandPrimCounts(SceneObjectGroup obj)
{
LLVector3 position = obj.AbsolutePosition;
ILandObject landUnderPrim = getLandObject(position.X, position.Y);
if (landUnderPrim != null)
{
landUnderPrim.addPrimToCount(obj);
}
}
public void removePrimFromLandPrimCounts(SceneObjectGroup obj)
{
foreach (LandObject p in landList.Values)
{
p.removePrimFromCount(obj);
}
}
public void finalizeLandPrimCountUpdate()
{
//Get Simwide prim count for owner
Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>();
foreach (LandObject p in landList.Values)
{
if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID))
{
List<LandObject> tempList = new List<LandObject>();
tempList.Add(p);
landOwnersAndParcels.Add(p.landData.ownerID, tempList);
}
else
{
landOwnersAndParcels[p.landData.ownerID].Add(p);
}
}
foreach (LLUUID owner in landOwnersAndParcels.Keys)
{
int simArea = 0;
int simPrims = 0;
foreach (LandObject p in landOwnersAndParcels[owner])
{
simArea += p.landData.area;
simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims +
p.landData.selectedPrims;
}
foreach (LandObject p in landOwnersAndParcels[owner])
{
p.landData.simwideArea = simArea;
p.landData.simwidePrims = simPrims;
}
}
}
public void updateLandPrimCounts()
{
foreach (EntityBase obj in m_scene.Entities.Values)
{
if (obj is SceneObjectGroup)
{
m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj);
}
}
}
public void performParcelPrimCountUpdate()
{
resetAllLandPrimCounts();
m_scene.EventManager.TriggerParcelPrimCountUpdate();
finalizeLandPrimCountUpdate();
landPrimCountTainted = false;
}
#endregion #endregion
#region Parcel Updating #region Parcel Updating
@ -547,7 +532,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{ {
for (x = 0; x < 64; x++) for (x = 0; x < 64; x++)
{ {
byte tempByte = (byte)0; //This represents the byte for the current 4x4 byte tempByte = (byte) 0; //This represents the byte for the current 4x4
ILandObject currentParcelBlock = null; ILandObject currentParcelBlock = null;
try try
@ -623,10 +608,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land
if (byteArrayCount >= LAND_BLOCKS_PER_PACKET) if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
{ {
byteArrayCount = 0; byteArrayCount = 0;
packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay); packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
packet.ParcelData.Data = byteArray; packet.ParcelData.Data = byteArray;
packet.ParcelData.SequenceID = sequenceID; packet.ParcelData.SequenceID = sequenceID;
remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task); remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task);
sequenceID++; sequenceID++;
byteArray = new byte[LAND_BLOCKS_PER_PACKET]; byteArray = new byte[LAND_BLOCKS_PER_PACKET];
} }
@ -652,7 +637,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{ {
for (y = 0; y < inc_y; y++) for (y = 0; y < inc_y; y++)
{ {
ILandObject currentParcel = null; ILandObject currentParcel = null;
try try
{ {
@ -693,7 +677,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
if (landList.ContainsKey(packet.ParcelData.LocalID)) if (landList.ContainsKey(packet.ParcelData.LocalID))
{ {
landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client); landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client);
} }
} }
@ -719,6 +702,14 @@ namespace OpenSim.Region.Environment.Modules.World.Land
#endregion #endregion
#region ILandChannel Members
public bool allowedForcefulBans
{
get { return m_allowedForcefulBans; }
set { m_allowedForcefulBans = value; }
}
/// <summary> /// <summary>
/// Resets the sim to the default land object (full sim piece of land owned by the default user) /// Resets the sim to the default land object (full sim piece of land owned by the default user)
/// </summary> /// </summary>
@ -731,7 +722,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene); ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene);
fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize));
fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
addLandObject(fullSimParcel); addLandObject(fullSimParcel);
@ -816,18 +807,17 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{ {
if (presence.UUID == avatar.AgentId) if (presence.UUID == avatar.AgentId)
{ {
List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition); List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition);
foreach (ILandObject checkBan in checkLandParcels) foreach (ILandObject checkBan in checkLandParcels)
{ {
if (checkBan.isBannedFromLand(avatar.AgentId)) if (checkBan.isBannedFromLand(avatar.AgentId))
{ {
checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar);
return; //Only send one return; //Only send one
} }
else if (checkBan.isRestrictedFromLand(avatar.AgentId)) else if (checkBan.isRestrictedFromLand(avatar.AgentId))
{ {
checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar); checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar);
return; //Only send one return; //Only send one
} }
} }
@ -841,8 +831,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
ILandObject over = null; ILandObject over = null;
try try
{ {
over = getLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
(int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
} }
catch (Exception) catch (Exception)
{ {
@ -873,11 +863,12 @@ namespace OpenSim.Region.Environment.Modules.World.Land
} }
} }
} }
public void sendLandUpdate(ScenePresence avatar) public void sendLandUpdate(ScenePresence avatar)
{ {
sendLandUpdate(avatar, false); sendLandUpdate(avatar, false);
} }
public void handleSignificantClientMovement(IClientAPI remote_client) public void handleSignificantClientMovement(IClientAPI remote_client)
{ {
ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId); ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId);
@ -949,6 +940,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
} }
} }
#endregion
// If the economy has been validated by the economy module, // If the economy has been validated by the economy module,
// and land has been validated as well, this method transfers // and land has been validated as well, this method transfers
// the land ownership // the land ownership
@ -961,7 +954,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{ {
if (landList.ContainsKey(e.parcelLocalID)) if (landList.ContainsKey(e.parcelLocalID))
{ {
landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint)e.transactionID, e.parcelPrice, e.parcelArea); landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint) e.transactionID, e.parcelPrice, e.parcelArea);
return; return;
} }
} }
@ -990,16 +983,15 @@ namespace OpenSim.Region.Environment.Modules.World.Land
int saleprice = lob.landData.salePrice; int saleprice = lob.landData.salePrice;
LLUUID pOwnerID = lob.landData.ownerID; LLUUID pOwnerID = lob.landData.ownerID;
bool landforsale = ((lob.landData.landFlags & (uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0); bool landforsale = ((lob.landData.landFlags &
(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0);
if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale) if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale)
{ {
lock (e) lock (e)
{ {
e.parcelOwnerID = pOwnerID; e.parcelOwnerID = pOwnerID;
e.landValidated = true; e.landValidated = true;
} }
} }
} }
} }

View File

@ -27,7 +27,6 @@
using Nini.Config; using Nini.Config;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.World.Land;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules.World.Land namespace OpenSim.Region.Environment.Modules.World.Land
@ -53,18 +52,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
lock (m_scene) lock (m_scene)
{ {
m_scene.LandChannel = (ILandChannel)landChannel; m_scene.LandChannel = (ILandChannel) landChannel;
} }
} }
public void PostInitialise() public void PostInitialise()
{ {
} }
public void Close() public void Close()
{ {
} }
public string Name public string Name
@ -77,10 +74,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
get { return false; } get { return false; }
} }
#endregion #endregion
} }
} }

View File

@ -33,7 +33,6 @@ using libsecondlife.Packets;
using log4net; using log4net;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.World.Land;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules.World.Land namespace OpenSim.Region.Environment.Modules.World.Land
@ -46,23 +45,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
#region Member Variables #region Member Variables
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private bool[,] m_landBitmap = new bool[64,64];
protected LandData m_landData = new LandData(); protected LandData m_landData = new LandData();
protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
protected Scene m_scene; protected Scene m_scene;
protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
private bool[,] m_landBitmap = new bool[64,64];
public bool[,] landBitmap public bool[,] landBitmap
{ {
get get { return m_landBitmap; }
{ set { m_landBitmap = value; }
return m_landBitmap;
}
set
{
m_landBitmap = value;
}
} }
#endregion #endregion
@ -71,15 +63,9 @@ namespace OpenSim.Region.Environment.Modules.World.Land
public LandData landData public LandData landData
{ {
get get { return m_landData; }
{
return m_landData;
}
set set { m_landData = value; }
{
m_landData = value;
}
} }
public LLUUID regionUUID public LLUUID regionUUID
@ -87,9 +73,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
get { return m_scene.RegionInfo.RegionID; } get { return m_scene.RegionInfo.RegionID; }
} }
#endregion
#region Constructors #region Constructors
public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene) public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene)
@ -115,7 +98,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{ {
if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize)
{ {
return (landBitmap[x/4, y/4] == true); return (landBitmap[x / 4, y / 4] == true);
} }
else else
{ {
@ -171,7 +154,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{ {
updatePacket.ParcelData.MaxPrims = updatePacket.ParcelData.MaxPrims =
Convert.ToInt32( Convert.ToInt32(
Math.Round((Convert.ToDecimal(landData.area)/Convert.ToDecimal(65536))*m_scene.objectCapacity* Math.Round((Convert.ToDecimal(landData.area) / Convert.ToDecimal(65536)) * m_scene.objectCapacity *
Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor)));
} }
else else
@ -261,6 +244,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
sendLandUpdateToAvatarsOverMe(); sendLandUpdateToAvatarsOverMe();
} }
} }
public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area)
{ {
LandData newData = landData.Copy(); LandData newData = landData.Copy();
@ -272,7 +256,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
newData.claimPrice = claimprice; newData.claimPrice = claimprice;
newData.salePrice = 0; newData.salePrice = 0;
newData.authBuyerID = LLUUID.Zero; newData.authBuyerID = LLUUID.Zero;
newData.landFlags &= ~(uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects); newData.landFlags &= ~(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects);
m_scene.LandChannel.updateLandObject(landData.localID, newData); m_scene.LandChannel.updateLandObject(landData.localID, newData);
sendLandUpdateToAvatarsOverMe(); sendLandUpdateToAvatarsOverMe();
@ -339,12 +323,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land
try try
{ {
over = over =
m_scene.LandChannel.getLandObject((int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.X))), m_scene.LandChannel.getLandObject((int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.X))),
(int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.Y)))); (int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.Y))));
} }
catch (Exception) catch (Exception)
{ {
m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + Math.Round(avatars[i].AbsolutePosition.Y)); m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " +
Math.Round(avatars[i].AbsolutePosition.Y));
} }
if (over != null) if (over != null)
@ -463,6 +448,25 @@ namespace OpenSim.Region.Environment.Modules.World.Land
#region Update Functions #region Update Functions
public void updateLandBitmapByteArray()
{
landData.landBitmapByteArray = convertLandBitmapToBytes();
}
/// <summary>
/// Update all settings in land such as area, bitmap byte array, etc
/// </summary>
public void forceUpdateLandInfo()
{
updateAABBAndAreaValues();
updateLandBitmapByteArray();
}
public void setLandBitmapFromByteArray()
{
landBitmap = convertBytesToLandBitmap();
}
/// <summary> /// <summary>
/// Updates the AABBMin and AABBMax values after area/shape modification of the land object /// Updates the AABBMin and AABBMax values after area/shape modification of the land object
/// </summary> /// </summary>
@ -495,8 +499,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
if (ty > 255) if (ty > 255)
ty = 255; ty = 255;
landData.AABBMin = landData.AABBMin =
new LLVector3((float)(min_x * 4), (float)(min_y * 4), new LLVector3((float) (min_x * 4), (float) (min_y * 4),
(float)m_scene.Heightmap[tx, ty]); (float) m_scene.Heightmap[tx, ty]);
tx = max_x * 4; tx = max_x * 4;
if (tx > 255) if (tx > 255)
@ -505,30 +509,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land
if (ty > 255) if (ty > 255)
ty = 255; ty = 255;
landData.AABBMax = landData.AABBMax =
new LLVector3((float)(max_x * 4), (float)(max_y * 4), new LLVector3((float) (max_x * 4), (float) (max_y * 4),
(float)m_scene.Heightmap[tx, ty]); (float) m_scene.Heightmap[tx, ty]);
landData.area = tempArea; landData.area = tempArea;
} }
public void updateLandBitmapByteArray()
{
landData.landBitmapByteArray = convertLandBitmapToBytes();
}
/// <summary>
/// Update all settings in land such as area, bitmap byte array, etc
/// </summary>
public void forceUpdateLandInfo()
{
updateAABBAndAreaValues();
updateLandBitmapByteArray();
}
public void setLandBitmapFromByteArray()
{
landBitmap = convertBytesToLandBitmap();
}
#endregion #endregion
#region Land Bitmap Functions #region Land Bitmap Functions
@ -561,64 +546,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land
return landBitmap; return landBitmap;
} }
/// <summary>
/// Converts the land bitmap to a packet friendly byte array
/// </summary>
/// <returns></returns>
private byte[] convertLandBitmapToBytes()
{
byte[] tempConvertArr = new byte[512];
byte tempByte = 0;
int x, y, i, byteNum = 0;
i = 0;
for (y = 0; y < 64; y++)
{
for (x = 0; x < 64; x++)
{
tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++%8));
if (i%8 == 0)
{
tempConvertArr[byteNum] = tempByte;
tempByte = (byte) 0;
i = 0;
byteNum++;
}
}
}
return tempConvertArr;
}
private bool[,] convertBytesToLandBitmap()
{
bool[,] tempConvertMap = new bool[64,64];
tempConvertMap.Initialize();
byte tempByte = 0;
int x = 0, y = 0, i = 0, bitNum = 0;
for (i = 0; i < 512; i++)
{
tempByte = landData.landBitmapByteArray[i];
for (bitNum = 0; bitNum < 8; bitNum++)
{
bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
tempConvertMap[x, y] = bit;
x++;
if (x > 63)
{
x = 0;
y++;
}
}
}
return tempConvertMap;
}
/// <summary> /// <summary>
/// Full sim land object creation /// Full sim land object creation
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public bool[,] basicFullRegionLandBitmap() public bool[,] basicFullRegionLandBitmap()
{ {
return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize); return getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize);
} }
/// <summary> /// <summary>
@ -662,8 +596,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{ {
for (x = 0; x < 64; x++) for (x = 0; x < 64; x++)
{ {
if (x >= start_x/4 && x < end_x/4 if (x >= start_x / 4 && x < end_x / 4
&& y >= start_y/4 && y < end_y/4) && y >= start_y / 4 && y < end_y / 4)
{ {
land_bitmap[x, y] = set_value; land_bitmap[x, y] = set_value;
} }
@ -705,6 +639,57 @@ namespace OpenSim.Region.Environment.Modules.World.Land
return bitmap_base; return bitmap_base;
} }
/// <summary>
/// Converts the land bitmap to a packet friendly byte array
/// </summary>
/// <returns></returns>
private byte[] convertLandBitmapToBytes()
{
byte[] tempConvertArr = new byte[512];
byte tempByte = 0;
int x, y, i, byteNum = 0;
i = 0;
for (y = 0; y < 64; y++)
{
for (x = 0; x < 64; x++)
{
tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8));
if (i % 8 == 0)
{
tempConvertArr[byteNum] = tempByte;
tempByte = (byte) 0;
i = 0;
byteNum++;
}
}
}
return tempConvertArr;
}
private bool[,] convertBytesToLandBitmap()
{
bool[,] tempConvertMap = new bool[64,64];
tempConvertMap.Initialize();
byte tempByte = 0;
int x = 0, y = 0, i = 0, bitNum = 0;
for (i = 0; i < 512; i++)
{
tempByte = landData.landBitmapByteArray[i];
for (bitNum = 0; bitNum < 8; bitNum++)
{
bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
tempConvertMap[x, y] = bit;
x++;
if (x > 63)
{
x = 0;
y++;
}
}
}
return tempConvertMap;
}
#endregion #endregion
#region Object Select and Object Owner Listing #region Object Select and Object Owner Listing
@ -938,6 +923,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
#endregion #endregion
#endregion
} }
} }

View File

@ -110,6 +110,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName) private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName)
{ {
#region GZip Compressed Version #region GZip Compressed Version
FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create); FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create);
MemoryStream gzipMSStream = new MemoryStream(); MemoryStream gzipMSStream = new MemoryStream();
GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress); GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress);
@ -117,6 +118,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
gzipMSStream.WriteTo(objectsFileCompressed); gzipMSStream.WriteTo(objectsFileCompressed);
objectsFileCompressed.Flush(); objectsFileCompressed.Flush();
objectsFileCompressed.Close(); objectsFileCompressed.Close();
#endregion #endregion
} }
} }

View File

@ -39,15 +39,17 @@ namespace OpenSim.Region.Environment.Modules
{ {
//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 const double m_real_day = 24.0;
private const int m_default_frame = 100; private const int m_default_frame = 100;
private int m_frame_mod; private const double m_real_day = 24.0;
private double m_day_length; private double m_day_length;
private int m_dilation; private int m_dilation;
private int m_frame; private int m_frame;
private long m_start; private int m_frame_mod;
private Scene m_scene; private Scene m_scene;
private long m_start;
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
@ -66,7 +68,7 @@ namespace OpenSim.Region.Environment.Modules
m_frame_mod = m_default_frame; m_frame_mod = m_default_frame;
} }
m_dilation = (int) (m_real_day/m_day_length); m_dilation = (int) (m_real_day / m_day_length);
m_scene = scene; m_scene = scene;
scene.EventManager.OnFrame += SunUpdate; scene.EventManager.OnFrame += SunUpdate;
scene.EventManager.OnNewClient += SunToClient; scene.EventManager.OnNewClient += SunToClient;
@ -90,6 +92,8 @@ namespace OpenSim.Region.Environment.Modules
get { return false; } get { return false; }
} }
#endregion
public void SunToClient(IClientAPI client) public void SunToClient(IClientAPI client)
{ {
client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f));
@ -121,15 +125,15 @@ namespace OpenSim.Region.Environment.Modules
// ticks don't get out of hand // ticks don't get out of hand
private double HourOfTheDay() private double HourOfTheDay()
{ {
long m_addticks = (DateTime.Now.Ticks - m_start)*m_dilation; long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation;
DateTime dt = new DateTime(m_start + m_addticks); DateTime dt = new DateTime(m_start + m_addticks);
return (double) dt.Hour + ((double) dt.Minute/60.0); return (double) dt.Hour + ((double) dt.Minute / 60.0);
} }
private LLVector3 SunPos(double hour) private LLVector3 SunPos(double hour)
{ {
// now we have our radian position // now we have our radian position
double rad = (hour/m_real_day)*2*Math.PI - (Math.PI/2.0); double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0);
double z = Math.Sin(rad); double z = Math.Sin(rad);
double x = Math.Cos(rad); double x = Math.Cos(rad);
return new LLVector3((float) x, 0f, (float) z); return new LLVector3((float) x, 0f, (float) z);

View File

@ -27,7 +27,6 @@
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
{ {

View File

@ -27,7 +27,6 @@
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
{ {

View File

@ -27,7 +27,6 @@
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
{ {

View File

@ -35,7 +35,6 @@ using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.Framework; using OpenSim.Region.Environment.Modules.Framework;
using OpenSim.Region.Environment.Modules.World.Terrain;
using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes;
using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes;
@ -79,9 +78,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects =
new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>();
private Dictionary<Location, ITerrainChannel> m_channels;
private ITerrainChannel m_channel; private ITerrainChannel m_channel;
private Dictionary<Location, ITerrainChannel> m_channels;
private Dictionary<string, ITerrainEffect> m_plugineffects; private Dictionary<string, ITerrainEffect> m_plugineffects;
private ITerrainChannel m_revert; private ITerrainChannel m_revert;
private Scene m_scene; private Scene m_scene;
@ -252,7 +250,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
{ {
m_plugineffects.Add(pluginType.Name, terEffect); m_plugineffects.Add(pluginType.Name, terEffect);
m_log.Info("E ... " + pluginType.Name); m_log.Info("E ... " + pluginType.Name);
} else }
else
{ {
m_log.Warn("E ... " + pluginType.Name + " (Already added)"); m_log.Warn("E ... " + pluginType.Name + " (Already added)");
} }

View File

@ -44,13 +44,14 @@ namespace OpenSim.Region.Environment.Modules
/// </summary> /// </summary>
public class TreePopulatorModule : IRegionModule public class TreePopulatorModule : IRegionModule
{ {
private Scene m_scene;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private List<LLUUID> m_trees;
public double m_tree_density = 50.0; // Aim for this many per region public double m_tree_density = 50.0; // Aim for this many per region
public double m_tree_updates = 1000.0; // MS between updates public double m_tree_updates = 1000.0; // MS between updates
private List<LLUUID> m_trees;
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
@ -59,7 +60,8 @@ namespace OpenSim.Region.Environment.Modules
m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density); m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density);
} }
catch (Exception) catch (Exception)
{ } {
}
m_trees = new List<LLUUID>(); m_trees = new List<LLUUID>();
m_scene = scene; m_scene = scene;
@ -72,7 +74,27 @@ namespace OpenSim.Region.Environment.Modules
m_log.Debug("[TREES]: Initialised tree module"); m_log.Debug("[TREES]: Initialised tree module");
} }
void EventManager_OnPluginConsole(string[] args) public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "TreePopulatorModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
#endregion
private void EventManager_OnPluginConsole(string[] args)
{ {
if (args[0] == "tree") if (args[0] == "tree")
{ {
@ -81,13 +103,13 @@ namespace OpenSim.Region.Environment.Modules
} }
} }
void growTrees() private void growTrees()
{ {
foreach (LLUUID tree in m_trees) foreach (LLUUID tree in m_trees)
{ {
if (m_scene.Entities.ContainsKey(tree)) if (m_scene.Entities.ContainsKey(tree))
{ {
SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
// 100 seconds to grow 1m // 100 seconds to grow 1m
s_tree.Scale += new LLVector3(0.1f, 0.1f, 0.1f); s_tree.Scale += new LLVector3(0.1f, 0.1f, 0.1f);
@ -101,13 +123,13 @@ namespace OpenSim.Region.Environment.Modules
} }
} }
void seedTrees() private void seedTrees()
{ {
foreach (LLUUID tree in m_trees) foreach (LLUUID tree in m_trees)
{ {
if (m_scene.Entities.ContainsKey(tree)) if (m_scene.Entities.ContainsKey(tree))
{ {
SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
if (s_tree.Scale.X > 0.5) if (s_tree.Scale.X > 0.5)
{ {
@ -116,7 +138,6 @@ namespace OpenSim.Region.Environment.Modules
SpawnChild(s_tree); SpawnChild(s_tree);
} }
} }
} }
else else
{ {
@ -125,7 +146,7 @@ namespace OpenSim.Region.Environment.Modules
} }
} }
void killTrees() private void killTrees()
{ {
foreach (LLUUID tree in m_trees) foreach (LLUUID tree in m_trees)
{ {
@ -133,7 +154,7 @@ namespace OpenSim.Region.Environment.Modules
if (m_scene.Entities.ContainsKey(tree)) if (m_scene.Entities.ContainsKey(tree))
{ {
SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; SceneObjectPart selectedTree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) + double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) +
Math.Pow(selectedTree.Scale.Y, 2) + Math.Pow(selectedTree.Scale.Y, 2) +
Math.Pow(selectedTree.Scale.Z, 2)); Math.Pow(selectedTree.Scale.Z, 2));
@ -142,7 +163,7 @@ namespace OpenSim.Region.Environment.Modules
{ {
if (picktree != tree) if (picktree != tree)
{ {
SceneObjectPart pickedTree = ((SceneObjectGroup)m_scene.Entities[picktree]).RootPart; SceneObjectPart pickedTree = ((SceneObjectGroup) m_scene.Entities[picktree]).RootPart;
double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) + double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) +
Math.Pow(pickedTree.Scale.Y, 2) + Math.Pow(pickedTree.Scale.Y, 2) +
@ -199,15 +220,15 @@ namespace OpenSim.Region.Environment.Modules
double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
position.X += (float)randX; position.X += (float) randX;
position.Y += (float)randY; position.Y += (float) randY;
CreateTree(position); CreateTree(position);
} }
private void CreateTree(LLVector3 position) private void CreateTree(LLVector3 position)
{ {
position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y]; position.Z = (float) m_scene.Heightmap[(int) position.X, (int) position.Y];
SceneObjectGroup tree = SceneObjectGroup tree =
m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f), m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f),
@ -220,29 +241,11 @@ namespace OpenSim.Region.Environment.Modules
tree.SendGroupFullUpdate(); tree.SendGroupFullUpdate();
} }
void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e) private void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e)
{ {
growTrees(); growTrees();
seedTrees(); seedTrees();
killTrees(); killTrees();
} }
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "TreePopulatorModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
} }
} }