From 8e3b2392d129d727bfd00a2d9faa08d9e5be92de Mon Sep 17 00:00:00 2001
From: MW
Date: Tue, 28 Aug 2007 14:21:17 +0000
Subject: 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.
---
.../Region/Environment/Scenes/Scene.Inventory.cs | 5 +-
.../Environment/Scenes/Scene.PacketHandlers.cs | 92 +---------------------
OpenSim/Region/Environment/Scenes/Scene.cs | 62 +++++++++++++--
OpenSim/Region/Environment/Scenes/SceneEvents.cs | 9 +++
.../Region/Environment/Scenes/SceneObjectGroup.cs | 6 +-
.../Region/Environment/Scenes/SceneObjectPart.cs | 4 +-
6 files changed, 75 insertions(+), 103 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes')
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 16cd484..d31b5b0 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -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;
}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
index d94a748..dcec289 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -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);
}
///
@@ -146,7 +94,7 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- ///
+ /// Should be removed soon as the Chat modules should take over this function
///
///
///
@@ -616,40 +564,6 @@ namespace OpenSim.Region.Environment.Scenes
}
}
- ///
- ///
- ///
- ///
- ///
- 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);
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- 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);
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 2259a3e..b2ddb7d 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -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 capsHandlers = new Dictionary();
protected BaseHttpServer httpListener;
+ protected Dictionary Modules = new Dictionary();
+ protected Dictionary APIMethods = new Dictionary();
+
+ //API method Delegates
+
+ // this most likely shouldn't be handled as a API method like this, but doing it for testing purposes
+ public ModuleAPIMethodAddXferFile = null;
+
#region Properties
public AgentCircuitManager AuthenticateHandler
@@ -146,9 +157,11 @@ namespace OpenSim.Region.Environment.Scenes
/// Region Handle for this region
/// Region Name for this region
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)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;
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 3c6b277..a86a1bc 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -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)
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 2fd7b57..0fc1656 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -642,12 +642,12 @@ namespace OpenSim.Region.Environment.Scenes
return false;
}
- public string RequestInventoryFile(uint localID, XferManager xferManager)
+ public string RequestInventoryFile(uint localID, ModuleAPIMethod 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
///
///
- public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore)
+ public void ProcessBackup(OpenSim.Region.Environment.Interfaces.IRegionDataStore datastore)
{
datastore.StoreObject(this, m_scene.RegionInfo.SimUUID);
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index a621632..cc8e717 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -482,7 +482,7 @@ namespace OpenSim.Region.Environment.Scenes
return false;
}
- public string RequestInventoryFile(XferManager xferManager)
+ public string RequestInventoryFile(ModuleAPIMethod 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 "";
}
--
cgit v1.1