Start of trying to make Region/Scene more modular.
Added preliminary IRegionModule interface. Also have a work in progress way of Modules registering optional API methods (kind of like Apache optional functions). But there must be a cleaner/nicer way in c# of doing these than the current way. Added three work in progress modules: ChatModule (simple handles in world chat, but by moving this to a module, we could support other types of chat modules, ie like a irc - opensim bridge module. ) , AvatarProfilesModule and XferModule. Moved most of the code from Scene.ModifyTerrain() into the BasicTerrain library, as the start of trying to make that more modular. Stopped Child agents showing up as part of the "show users" command.afrisby
parent
c1a899b651
commit
8e3b2392d1
|
@ -61,6 +61,8 @@ namespace OpenSim
|
|||
public bool user_accounts;
|
||||
public bool m_gridLocalAsset;
|
||||
|
||||
protected ModuleLoader m_moduleLoader;
|
||||
|
||||
protected string m_storageDLL = "OpenSim.DataStore.NullStorage.dll";
|
||||
|
||||
protected string m_startupCommandsFile = "";
|
||||
|
@ -168,6 +170,8 @@ namespace OpenSim
|
|||
configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
|
||||
}
|
||||
|
||||
m_moduleLoader = new ModuleLoader();
|
||||
|
||||
// Load all script engines found
|
||||
OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader ScriptEngineLoader = new OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader(m_log);
|
||||
|
||||
|
@ -225,7 +229,7 @@ namespace OpenSim
|
|||
|
||||
protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager)
|
||||
{
|
||||
return new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer);
|
||||
return new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, m_moduleLoader);
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
|
@ -491,15 +495,18 @@ namespace OpenSim
|
|||
if (entity is ScenePresence)
|
||||
{
|
||||
ScenePresence scenePrescence = entity as ScenePresence;
|
||||
m_log.Error(
|
||||
String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}",
|
||||
scenePrescence.Firstname,
|
||||
scenePrescence.Lastname,
|
||||
scenePrescence.UUID,
|
||||
scenePrescence.ControllingClient.AgentId,
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
scene.RegionInfo.RegionName));
|
||||
if (!scenePrescence.childAgent)
|
||||
{
|
||||
m_log.Error(
|
||||
String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}",
|
||||
scenePrescence.Firstname,
|
||||
scenePrescence.Lastname,
|
||||
scenePrescence.UUID,
|
||||
scenePrescence.ControllingClient.AgentId,
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
scene.RegionInfo.RegionName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,8 +85,8 @@ namespace OpenSim.Region.Communications.Local
|
|||
uint regX = 1000;
|
||||
uint regY = 1000;
|
||||
|
||||
tempfirstname = MainLog.Instance.CmdPrompt("First name", "Hello");
|
||||
templastname = MainLog.Instance.CmdPrompt("Last name", "Everyone");
|
||||
tempfirstname = MainLog.Instance.CmdPrompt("First name", "Default");
|
||||
templastname = MainLog.Instance.CmdPrompt("Last name", "User");
|
||||
tempMD5Passwd = MainLog.Instance.PasswdPrompt("Password");
|
||||
regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X", "1000"));
|
||||
regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y" , "1000"));
|
||||
|
|
|
@ -36,7 +36,7 @@ using OpenSim.Region.Environment.LandManagement;
|
|||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenSim.Region.Interfaces
|
||||
namespace OpenSim.Region.Environment.Interfaces
|
||||
{
|
||||
public interface IRegionDataStore
|
||||
{
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.Environment.Interfaces
|
||||
{
|
||||
public interface IRegionModule
|
||||
{
|
||||
void Initialise(Scenes.Scene scene);
|
||||
void PostInitialise();
|
||||
void CloseDown();
|
||||
string GetName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Modules;
|
||||
|
||||
namespace OpenSim.Region.Environment
|
||||
{
|
||||
public class ModuleLoader
|
||||
{
|
||||
|
||||
public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
|
||||
|
||||
public ModuleLoader()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Really just a test method for loading a set of currently internal modules
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
public void LoadInternalModules(Scene scene)
|
||||
{
|
||||
//Testing IRegionModule ideas
|
||||
XferModule xferManager = new XferModule();
|
||||
xferManager.Initialise(scene);
|
||||
scene.AddModule(xferManager.GetName(), xferManager);
|
||||
|
||||
ChatModule chatModule = new ChatModule();
|
||||
chatModule.Initialise(scene);
|
||||
scene.AddModule(chatModule.GetName(), chatModule);
|
||||
|
||||
AvatarProfilesModule avatarProfiles = new AvatarProfilesModule();
|
||||
avatarProfiles.Initialise(scene);
|
||||
scene.AddModule(avatarProfiles.GetName(), avatarProfiles);
|
||||
|
||||
// Post Initialise Modules
|
||||
xferManager.PostInitialise();
|
||||
// chatModule.PostInitialise(); //for now leave this disabled as it would start up a partially working irc bot
|
||||
avatarProfiles.PostInitialise();
|
||||
}
|
||||
|
||||
public void LoadModule(string dllName, string moduleName, Scene scene)
|
||||
{
|
||||
Assembly pluginAssembly = null;
|
||||
if (LoadedAssemblys.ContainsKey(dllName))
|
||||
{
|
||||
pluginAssembly = LoadedAssemblys[dllName];
|
||||
}
|
||||
else
|
||||
{
|
||||
pluginAssembly = Assembly.LoadFrom(dllName);
|
||||
this.LoadedAssemblys.Add(dllName, pluginAssembly);
|
||||
}
|
||||
|
||||
IRegionModule module = null;
|
||||
foreach (Type pluginType in pluginAssembly.GetTypes())
|
||||
{
|
||||
if (pluginType.IsPublic)
|
||||
{
|
||||
if (!pluginType.IsAbstract)
|
||||
{
|
||||
Type typeInterface = pluginType.GetInterface("IRegionModule", true);
|
||||
|
||||
if (typeInterface != null)
|
||||
{
|
||||
module = (IRegionModule)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||
break;
|
||||
}
|
||||
typeInterface = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
pluginAssembly = null;
|
||||
|
||||
if (module.GetName() == moduleName)
|
||||
{
|
||||
module.Initialise(scene);
|
||||
scene.AddModule(moduleName, module);
|
||||
module.PostInitialise(); //shouldn't be done here
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ClearCache()
|
||||
{
|
||||
this.LoadedAssemblys.Clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
public class AvatarProfilesModule :IRegionModule
|
||||
{
|
||||
|
||||
private Scene m_scene;
|
||||
|
||||
public AvatarProfilesModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initialise(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_scene.EventManager.OnNewClient += NewClient;
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void CloseDown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "AvatarProfilesModule";
|
||||
}
|
||||
|
||||
public void NewClient(IClientAPI client)
|
||||
{
|
||||
client.OnRequestAvatarProperties += RequestAvatarProperty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="avatarID"></param>
|
||||
public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID)
|
||||
{
|
||||
string about = "OpenSim crash test dummy";
|
||||
string bornOn = "Before now";
|
||||
string flAbout = "First life? What is one of those? OpenSim is my life!";
|
||||
LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000");
|
||||
remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", partner);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
using libsecondlife;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Utilities;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
public class ChatModule :IRegionModule
|
||||
{
|
||||
private Scene m_scene;
|
||||
|
||||
private string m_server = "irc2.choopa.net";
|
||||
|
||||
private int m_port = 6668;
|
||||
private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
|
||||
private string m_nick = "OpenSimBoT";
|
||||
private string m_channel = "#opensim";
|
||||
|
||||
private NetworkStream m_stream;
|
||||
private TcpClient m_irc;
|
||||
private StreamWriter m_ircWriter;
|
||||
private StreamReader m_ircReader;
|
||||
|
||||
private Thread pingSender;
|
||||
|
||||
private bool connected = false;
|
||||
|
||||
public ChatModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initialise(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_scene.EventManager.OnNewClient += NewClient;
|
||||
|
||||
//should register a optional API Method, so other modules can send chat messages using this module
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_irc = new TcpClient(m_server, m_port);
|
||||
m_stream = m_irc.GetStream();
|
||||
m_ircReader = new StreamReader(m_stream);
|
||||
m_ircWriter = new StreamWriter(m_stream);
|
||||
|
||||
pingSender = new Thread(new ThreadStart(this.PingRun));
|
||||
pingSender.Start();
|
||||
|
||||
m_ircWriter.WriteLine(m_user);
|
||||
m_ircWriter.Flush();
|
||||
m_ircWriter.WriteLine("NICK " + m_nick);
|
||||
m_ircWriter.Flush();
|
||||
m_ircWriter.WriteLine("JOIN " + m_channel);
|
||||
m_ircWriter.Flush();
|
||||
connected = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseDown()
|
||||
{
|
||||
m_ircWriter.Close();
|
||||
m_ircReader.Close();
|
||||
m_irc.Close();
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "ChatModule";
|
||||
}
|
||||
|
||||
public void NewClient(IClientAPI client)
|
||||
{
|
||||
client.OnChatFromViewer += SimChat;
|
||||
}
|
||||
|
||||
public void PingRun()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
m_ircWriter.WriteLine("PING :" + m_server);
|
||||
m_ircWriter.Flush();
|
||||
Thread.Sleep(15000);
|
||||
}
|
||||
}
|
||||
|
||||
public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
|
||||
{
|
||||
ScenePresence avatar = null;
|
||||
avatar = m_scene.RequestAvatar(fromAgentID);
|
||||
if (avatar != null)
|
||||
{
|
||||
fromPos = avatar.AbsolutePosition;
|
||||
fromName = avatar.Firstname + " " + avatar.Lastname;
|
||||
avatar = null;
|
||||
}
|
||||
|
||||
if (connected)
|
||||
{
|
||||
m_ircWriter.WriteLine("MSG " + m_channel +" :" + fromName + ", " + Util.FieldToString(message));
|
||||
m_ircWriter.Flush();
|
||||
}
|
||||
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
|
||||
{
|
||||
int dis = -1000;
|
||||
|
||||
//err ??? the following code seems to be request a scenePresence when it already has a ref to it
|
||||
avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId);
|
||||
if (avatar != null)
|
||||
{
|
||||
dis = (int)avatar.AbsolutePosition.GetDistanceTo(fromPos);
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0: // Whisper
|
||||
if ((dis < 10) && (dis > -10))
|
||||
{
|
||||
//should change so the message is sent through the avatar rather than direct to the ClientView
|
||||
presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
case 1: // Say
|
||||
if ((dis < 30) && (dis > -30))
|
||||
{
|
||||
//Console.WriteLine("sending chat");
|
||||
presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
case 2: // Shout
|
||||
if ((dis < 100) && (dis > -100))
|
||||
{
|
||||
presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xff: // Broadcast
|
||||
presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
|
||||
fromAgentID);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -9,6 +9,8 @@ using OpenSim.Region.Environment.LandManagement;
|
|||
|
||||
namespace OpenSim.Region.Environment
|
||||
{
|
||||
public delegate TResult ModuleAPIMethod<TResult, TParam0, TParam1>(TParam0 param0, TParam1 param1);
|
||||
|
||||
public class RegionManager
|
||||
{
|
||||
protected AgentCircuitManager authenticateHandler;
|
||||
|
|
|
@ -201,7 +201,10 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID);
|
||||
if (fileChange)
|
||||
{
|
||||
((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, xferManager);
|
||||
if (this.AddXferFile != null)
|
||||
{
|
||||
((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, AddXferFile);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -57,60 +57,8 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
if (!PermissionsMngr.CanTerraform(remoteUser.AgentId, new LLVector3(north, west, 0)))
|
||||
return;
|
||||
|
||||
// Shiny.
|
||||
double size = (double)(1 << brushsize);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case 0:
|
||||
// flatten terrain
|
||||
Terrain.FlattenTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
case 1:
|
||||
// raise terrain
|
||||
Terrain.RaiseTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
case 2:
|
||||
//lower terrain
|
||||
Terrain.LowerTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
case 3:
|
||||
// smooth terrain
|
||||
Terrain.SmoothTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
case 4:
|
||||
// noise
|
||||
Terrain.NoiseTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
case 5:
|
||||
// revert
|
||||
Terrain.RevertTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
|
||||
// CLIENT EXTENSIONS GO HERE
|
||||
case 128:
|
||||
// erode-thermal
|
||||
break;
|
||||
case 129:
|
||||
// erode-aerobic
|
||||
break;
|
||||
case 130:
|
||||
// erode-hydraulic
|
||||
break;
|
||||
}
|
||||
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
if (Terrain.Tainted(x * 16, y * 16))
|
||||
{
|
||||
remoteUser.SendLayerData(x, y, Terrain.GetHeights1D());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
//if it wasn't for the permission checking we could have the terrain module directly subscribe to the OnModifyTerrain event
|
||||
Terrain.ModifyTerrain(height, seconds, brushsize, action, north, west, remoteUser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -146,7 +94,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Should be removed soon as the Chat modules should take over this function
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="type"></param>
|
||||
|
@ -616,40 +564,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="avatarID"></param>
|
||||
public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID)
|
||||
{
|
||||
string about = "OpenSim crash test dummy";
|
||||
string bornOn = "Before now";
|
||||
string flAbout = "First life? What is one of those? OpenSim is my life!";
|
||||
LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000");
|
||||
remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", partner);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="xferID"></param>
|
||||
/// <param name="fileName"></param>
|
||||
public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
|
||||
{
|
||||
/*
|
||||
foreach (EntityBase ent in Entities.Values)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
((SceneObjectGroup)ent).RequestInventoryFile(remoteClient, ((SceneObjectGroup)ent).LocalId, xferID);
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
|
||||
{
|
||||
this.EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient);
|
||||
|
|
|
@ -42,6 +42,8 @@ using OpenSim.Framework.Utilities;
|
|||
using OpenSim.Physics.Manager;
|
||||
using OpenSim.Framework.Communications.Caches;
|
||||
using OpenSim.Region.Environment.LandManagement;
|
||||
using OpenSim.Region.Environment;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Scripting;
|
||||
using OpenSim.Region.Terrain;
|
||||
using OpenSim.Framework.Data;
|
||||
|
@ -73,15 +75,24 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
private Mutex updateLock;
|
||||
|
||||
protected ModuleLoader m_moduleLoader;
|
||||
protected StorageManager storageManager;
|
||||
protected AgentCircuitManager authenticateHandler;
|
||||
protected RegionCommsListener regionCommsHost;
|
||||
protected CommunicationsManager commsManager;
|
||||
protected XferManager xferManager;
|
||||
// protected XferManager xferManager;
|
||||
|
||||
protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>();
|
||||
protected BaseHttpServer httpListener;
|
||||
|
||||
protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>();
|
||||
protected Dictionary<string, object> APIMethods = new Dictionary<string, object>();
|
||||
|
||||
//API method Delegates
|
||||
|
||||
// this most likely shouldn't be handled as a API method like this, but doing it for testing purposes
|
||||
public ModuleAPIMethod<bool, string, byte[]>AddXferFile = null;
|
||||
|
||||
#region Properties
|
||||
|
||||
public AgentCircuitManager AuthenticateHandler
|
||||
|
@ -146,9 +157,11 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
/// <param name="regionHandle">Region Handle for this region</param>
|
||||
/// <param name="regionName">Region Name for this region</param>
|
||||
public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan,
|
||||
AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer)
|
||||
AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader)
|
||||
{
|
||||
updateLock = new Mutex(false);
|
||||
|
||||
m_moduleLoader = moduleLoader;
|
||||
authenticateHandler = authen;
|
||||
commsManager = commsMan;
|
||||
storageManager = storeManager;
|
||||
|
@ -164,8 +177,10 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
m_scriptManager = new ScriptManager(this);
|
||||
m_eventManager = new EventManager();
|
||||
m_permissionManager = new PermissionManager(this);
|
||||
xferManager = new XferManager();
|
||||
|
||||
MainLog.Instance.Verbose("Loading Region Modules");
|
||||
m_moduleLoader.LoadInternalModules(this);
|
||||
|
||||
m_eventManager.OnParcelPrimCountAdd +=
|
||||
m_LandManager.addPrimToLandPrimCounts;
|
||||
|
||||
|
@ -182,10 +197,17 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
ScenePresence.LoadAnims();
|
||||
|
||||
httpListener = httpServer;
|
||||
|
||||
SetMethodDelegates();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void SetMethodDelegates()
|
||||
{
|
||||
AddXferFile = (ModuleAPIMethod<bool, string, byte[]>)this.RequestAPIMethod("API_AddXferFile");
|
||||
}
|
||||
|
||||
#region Script Handling Methods
|
||||
|
||||
public void SendCommandToScripts(string[] args)
|
||||
|
@ -682,7 +704,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
client.OnRegionHandShakeReply += SendLayerData;
|
||||
//remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims);
|
||||
client.OnModifyTerrain += ModifyTerrain;
|
||||
client.OnChatFromViewer += SimChat;
|
||||
//client.OnChatFromViewer += SimChat;
|
||||
client.OnInstantMessage += InstantMessage;
|
||||
client.OnRequestWearables += InformClientOfNeighbours;
|
||||
client.OnAddPrim += AddNewPrim;
|
||||
|
@ -725,15 +747,14 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset;
|
||||
client.OnAssetUploadRequest += commsManager.TransactionsManager.HandleUDPUploadRequest;
|
||||
client.OnXferReceive += commsManager.TransactionsManager.HandleXfer;
|
||||
// client.OnRequestXfer += RequestXfer;
|
||||
client.OnRequestXfer += xferManager.RequestXfer;
|
||||
client.OnConfirmXfer += xferManager.AckPacket;
|
||||
client.OnRezScript += RezScript;
|
||||
client.OnRemoveTaskItem += RemoveTaskInventory;
|
||||
|
||||
client.OnRequestAvatarProperties += RequestAvatarProperty;
|
||||
// client.OnRequestAvatarProperties += RequestAvatarProperty;
|
||||
|
||||
client.OnGrabObject += ProcessObjectGrab;
|
||||
|
||||
EventManager.TriggerOnNewClient(client);
|
||||
}
|
||||
|
||||
protected ScenePresence CreateAndAddScenePresence(IClientAPI client)
|
||||
|
@ -1093,6 +1114,31 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
#endregion
|
||||
|
||||
public void AddModule(string name, IRegionModule module)
|
||||
{
|
||||
if (!this.Modules.ContainsKey(name))
|
||||
{
|
||||
Modules.Add(name, module);
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterAPIMethod(string name, object method)
|
||||
{
|
||||
if (!this.APIMethods.ContainsKey(name))
|
||||
{
|
||||
this.APIMethods.Add(name, method);
|
||||
}
|
||||
}
|
||||
|
||||
public object RequestAPIMethod(string name)
|
||||
{
|
||||
if (this.APIMethods.ContainsKey(name))
|
||||
{
|
||||
return APIMethods[name];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetTimePhase(int phase)
|
||||
{
|
||||
m_timePhase = phase;
|
||||
|
|
|
@ -14,6 +14,9 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
public delegate void OnBackupDelegate(Interfaces.IRegionDataStore datastore);
|
||||
public event OnBackupDelegate OnBackup;
|
||||
|
||||
public delegate void OnNewClientDelegate(IClientAPI client);
|
||||
public event OnNewClientDelegate OnNewClient;
|
||||
|
||||
public delegate void OnNewPresenceDelegate(ScenePresence presence);
|
||||
public event OnNewPresenceDelegate OnNewPresence;
|
||||
|
||||
|
@ -63,6 +66,12 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void TriggerOnNewClient(IClientAPI client)
|
||||
{
|
||||
if (OnNewClient != null)
|
||||
OnNewClient(client);
|
||||
}
|
||||
|
||||
public void TriggerOnNewPresence(ScenePresence presence)
|
||||
{
|
||||
if (OnNewPresence != null)
|
||||
|
|
|
@ -642,12 +642,12 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
return false;
|
||||
}
|
||||
|
||||
public string RequestInventoryFile(uint localID, XferManager xferManager)
|
||||
public string RequestInventoryFile(uint localID, ModuleAPIMethod<bool, string, byte[]> addXferFile)
|
||||
{
|
||||
SceneObjectPart part = this.GetChildPart(localID);
|
||||
if (part != null)
|
||||
{
|
||||
return part.RequestInventoryFile(xferManager);
|
||||
part.RequestInventoryFile(addXferFile);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -967,7 +967,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
/// Processes backup
|
||||
/// </summary>
|
||||
/// <param name="datastore"></param>
|
||||
public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore)
|
||||
public void ProcessBackup(OpenSim.Region.Environment.Interfaces.IRegionDataStore datastore)
|
||||
{
|
||||
datastore.StoreObject(this, m_scene.RegionInfo.SimUUID);
|
||||
}
|
||||
|
|
|
@ -482,7 +482,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
return false;
|
||||
}
|
||||
|
||||
public string RequestInventoryFile(XferManager xferManager)
|
||||
public string RequestInventoryFile(ModuleAPIMethod<bool, string, byte[]> addXferFile)
|
||||
{
|
||||
byte[] fileData = new byte[0];
|
||||
InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, this.UUID);
|
||||
|
@ -516,7 +516,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
fileData = Helpers.StringToField(invString.BuildString);
|
||||
if (fileData.Length > 2)
|
||||
{
|
||||
xferManager.AddNewFile(m_inventoryFileName, fileData);
|
||||
addXferFile(m_inventoryFileName, fileData);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ using OpenSim.Framework.Communications;
|
|||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Region.Capabilities;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Interfaces;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
|
|
|
@ -5,19 +5,52 @@ using System.Text;
|
|||
using libsecondlife;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Utilities;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.Environment
|
||||
{
|
||||
public class XferManager
|
||||
public class XferModule : IRegionModule
|
||||
{
|
||||
public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>();
|
||||
public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
|
||||
|
||||
public XferManager()
|
||||
private Scene m_scene;
|
||||
|
||||
public XferModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initialise(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_scene.EventManager.OnNewClient += NewClient;
|
||||
|
||||
m_scene.RegisterAPIMethod("API_AddXferFile", new ModuleAPIMethod<bool, string, byte[]>(this.AddNewFile));
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void CloseDown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "XferModule";
|
||||
}
|
||||
|
||||
public void NewClient(IClientAPI client)
|
||||
{
|
||||
client.OnRequestXfer += RequestXfer;
|
||||
client.OnConfirmXfer += AckPacket;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -50,7 +83,7 @@ namespace OpenSim.Region.Environment
|
|||
}
|
||||
}
|
||||
|
||||
public void AddNewFile(string fileName, byte[] data)
|
||||
public bool AddNewFile(string fileName, byte[] data)
|
||||
{
|
||||
lock (NewFiles)
|
||||
{
|
||||
|
@ -63,8 +96,10 @@ namespace OpenSim.Region.Environment
|
|||
NewFiles.Add(fileName, data);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public class XferDownLoad
|
||||
{
|
||||
public byte[] Data = new byte[0];
|
|
@ -19,8 +19,8 @@ namespace SimpleApp
|
|||
{
|
||||
private List<ScenePresence> m_avatars;
|
||||
|
||||
public MyWorld( RegionInfo regionInfo, AgentCircuitManager authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer)
|
||||
: base( regionInfo, authen, commsMan, assetCach, storeMan, httpServer)
|
||||
public MyWorld( RegionInfo regionInfo, AgentCircuitManager authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer, ModuleLoader moduleLoader)
|
||||
: base( regionInfo, authen, commsMan, assetCach, storeMan, httpServer, moduleLoader)
|
||||
{
|
||||
m_avatars = new List<Avatar>();
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace SimpleApp
|
|||
|
||||
protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager)
|
||||
{
|
||||
return new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer);
|
||||
return new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, new ModuleLoader());
|
||||
}
|
||||
|
||||
protected override StorageManager CreateStorageManager(RegionInfo regionInfo)
|
||||
|
|
|
@ -8,7 +8,7 @@ using System.IO;
|
|||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Environment.LandManagement;
|
||||
using OpenSim.Region.Environment;
|
||||
using OpenSim.Region.Interfaces;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Types;
|
||||
using OpenSim.Framework.Utilities;
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Text;
|
|||
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Environment.LandManagement;
|
||||
using OpenSim.Region.Interfaces;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Framework.Console;
|
||||
using libsecondlife;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ using System.Drawing.Imaging;
|
|||
using System.IO;
|
||||
using libTerrain;
|
||||
using OpenJPEGNet;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.Terrain
|
||||
{
|
||||
|
@ -128,6 +129,76 @@ namespace OpenSim.Region.Terrain
|
|||
heightmap.diff = new int[w / 16, h / 16];
|
||||
}
|
||||
|
||||
//Testing to see if moving the TerraForming packet handling code into here works well
|
||||
/// <summary>
|
||||
/// Modifies terrain using the specified information
|
||||
/// </summary>
|
||||
/// <param name="height">The height at which the user started modifying the terrain</param>
|
||||
/// <param name="seconds">The number of seconds the modify button was pressed</param>
|
||||
/// <param name="brushsize">The size of the brush used</param>
|
||||
/// <param name="action">The action to be performed</param>
|
||||
/// <param name="north">Distance from the north border where the cursor is located</param>
|
||||
/// <param name="west">Distance from the west border where the cursor is located</param>
|
||||
public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser)
|
||||
{
|
||||
|
||||
// Shiny.
|
||||
double size = (double)(1 << brushsize);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case 0:
|
||||
// flatten terrain
|
||||
this.FlattenTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
case 1:
|
||||
// raise terrain
|
||||
this.RaiseTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
case 2:
|
||||
//lower terrain
|
||||
this.LowerTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
case 3:
|
||||
// smooth terrain
|
||||
this.SmoothTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
case 4:
|
||||
// noise
|
||||
this.NoiseTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
case 5:
|
||||
// revert
|
||||
this.RevertTerrain(west, north, size, (double)seconds / 5.0);
|
||||
break;
|
||||
|
||||
// CLIENT EXTENSIONS GO HERE
|
||||
case 128:
|
||||
// erode-thermal
|
||||
break;
|
||||
case 129:
|
||||
// erode-aerobic
|
||||
break;
|
||||
case 130:
|
||||
// erode-hydraulic
|
||||
break;
|
||||
}
|
||||
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
if (this.Tainted(x * 16, y * 16))
|
||||
{
|
||||
remoteUser.SendLayerData(x, y, this.GetHeights1D());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks to make sure the terrain is within baked values +/- maxRaise/minLower
|
||||
/// </summary>
|
||||
|
|
|
@ -297,6 +297,7 @@
|
|||
<Reference name="System.Xml"/>
|
||||
<Reference name="Microsoft.JScript"/>
|
||||
<Reference name="libsecondlife.dll" />
|
||||
<Reference name="OpenSim.Framework"/>
|
||||
|
||||
<Files>
|
||||
<Match pattern="*.cs" recurse="true"/>
|
||||
|
|
Loading…
Reference in New Issue