diff options
author | MW | 2007-08-28 14:21:17 +0000 |
---|---|---|
committer | MW | 2007-08-28 14:21:17 +0000 |
commit | 8e3b2392d129d727bfd00a2d9faa08d9e5be92de (patch) | |
tree | 7e6b89ee495af1d5ea76c58fc0796a3bb38ecc5d /OpenSim/Region/Environment/Scenes | |
parent | Ensure that UserProfileData doesn't pass down null values. (diff) | |
download | opensim-SC-8e3b2392d129d727bfd00a2d9faa08d9e5be92de.zip opensim-SC-8e3b2392d129d727bfd00a2d9faa08d9e5be92de.tar.gz opensim-SC-8e3b2392d129d727bfd00a2d9faa08d9e5be92de.tar.bz2 opensim-SC-8e3b2392d129d727bfd00a2d9faa08d9e5be92de.tar.xz |
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.
Diffstat (limited to '')
6 files changed, 75 insertions, 103 deletions
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 | |||
201 | bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID); | 201 | bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID); |
202 | if (fileChange) | 202 | if (fileChange) |
203 | { | 203 | { |
204 | ((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, xferManager); | 204 | if (this.AddXferFile != null) |
205 | { | ||
206 | ((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, AddXferFile); | ||
207 | } | ||
205 | } | 208 | } |
206 | break; | 209 | break; |
207 | } | 210 | } |
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 | |||
57 | if (!PermissionsMngr.CanTerraform(remoteUser.AgentId, new LLVector3(north, west, 0))) | 57 | if (!PermissionsMngr.CanTerraform(remoteUser.AgentId, new LLVector3(north, west, 0))) |
58 | return; | 58 | return; |
59 | 59 | ||
60 | // Shiny. | 60 | //if it wasn't for the permission checking we could have the terrain module directly subscribe to the OnModifyTerrain event |
61 | double size = (double)(1 << brushsize); | 61 | Terrain.ModifyTerrain(height, seconds, brushsize, action, north, west, remoteUser); |
62 | |||
63 | switch (action) | ||
64 | { | ||
65 | case 0: | ||
66 | // flatten terrain | ||
67 | Terrain.FlattenTerrain(west, north, size, (double)seconds / 5.0); | ||
68 | break; | ||
69 | case 1: | ||
70 | // raise terrain | ||
71 | Terrain.RaiseTerrain(west, north, size, (double)seconds / 5.0); | ||
72 | break; | ||
73 | case 2: | ||
74 | //lower terrain | ||
75 | Terrain.LowerTerrain(west, north, size, (double)seconds / 5.0); | ||
76 | break; | ||
77 | case 3: | ||
78 | // smooth terrain | ||
79 | Terrain.SmoothTerrain(west, north, size, (double)seconds / 5.0); | ||
80 | break; | ||
81 | case 4: | ||
82 | // noise | ||
83 | Terrain.NoiseTerrain(west, north, size, (double)seconds / 5.0); | ||
84 | break; | ||
85 | case 5: | ||
86 | // revert | ||
87 | Terrain.RevertTerrain(west, north, size, (double)seconds / 5.0); | ||
88 | break; | ||
89 | |||
90 | // CLIENT EXTENSIONS GO HERE | ||
91 | case 128: | ||
92 | // erode-thermal | ||
93 | break; | ||
94 | case 129: | ||
95 | // erode-aerobic | ||
96 | break; | ||
97 | case 130: | ||
98 | // erode-hydraulic | ||
99 | break; | ||
100 | } | ||
101 | |||
102 | for (int x = 0; x < 16; x++) | ||
103 | { | ||
104 | for (int y = 0; y < 16; y++) | ||
105 | { | ||
106 | if (Terrain.Tainted(x * 16, y * 16)) | ||
107 | { | ||
108 | remoteUser.SendLayerData(x, y, Terrain.GetHeights1D()); | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | return; | ||
114 | } | 62 | } |
115 | 63 | ||
116 | /// <summary> | 64 | /// <summary> |
@@ -146,7 +94,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
146 | } | 94 | } |
147 | 95 | ||
148 | /// <summary> | 96 | /// <summary> |
149 | /// | 97 | /// Should be removed soon as the Chat modules should take over this function |
150 | /// </summary> | 98 | /// </summary> |
151 | /// <param name="message"></param> | 99 | /// <param name="message"></param> |
152 | /// <param name="type"></param> | 100 | /// <param name="type"></param> |
@@ -616,40 +564,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
616 | } | 564 | } |
617 | } | 565 | } |
618 | 566 | ||
619 | /// <summary> | ||
620 | /// | ||
621 | /// </summary> | ||
622 | /// <param name="remoteClient"></param> | ||
623 | /// <param name="avatarID"></param> | ||
624 | public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) | ||
625 | { | ||
626 | string about = "OpenSim crash test dummy"; | ||
627 | string bornOn = "Before now"; | ||
628 | string flAbout = "First life? What is one of those? OpenSim is my life!"; | ||
629 | LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); | ||
630 | remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", partner); | ||
631 | } | ||
632 | |||
633 | /// <summary> | ||
634 | /// | ||
635 | /// </summary> | ||
636 | /// <param name="remoteClient"></param> | ||
637 | /// <param name="xferID"></param> | ||
638 | /// <param name="fileName"></param> | ||
639 | public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) | ||
640 | { | ||
641 | /* | ||
642 | foreach (EntityBase ent in Entities.Values) | ||
643 | { | ||
644 | if (ent is SceneObjectGroup) | ||
645 | { | ||
646 | ((SceneObjectGroup)ent).RequestInventoryFile(remoteClient, ((SceneObjectGroup)ent).LocalId, xferID); | ||
647 | break; | ||
648 | } | ||
649 | }*/ | ||
650 | } | ||
651 | |||
652 | |||
653 | public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) | 567 | public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) |
654 | { | 568 | { |
655 | this.EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient); | 569 | 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; | |||
42 | using OpenSim.Physics.Manager; | 42 | using OpenSim.Physics.Manager; |
43 | using OpenSim.Framework.Communications.Caches; | 43 | using OpenSim.Framework.Communications.Caches; |
44 | using OpenSim.Region.Environment.LandManagement; | 44 | using OpenSim.Region.Environment.LandManagement; |
45 | using OpenSim.Region.Environment; | ||
46 | using OpenSim.Region.Environment.Interfaces; | ||
45 | using OpenSim.Region.Scripting; | 47 | using OpenSim.Region.Scripting; |
46 | using OpenSim.Region.Terrain; | 48 | using OpenSim.Region.Terrain; |
47 | using OpenSim.Framework.Data; | 49 | using OpenSim.Framework.Data; |
@@ -73,15 +75,24 @@ namespace OpenSim.Region.Environment.Scenes | |||
73 | 75 | ||
74 | private Mutex updateLock; | 76 | private Mutex updateLock; |
75 | 77 | ||
78 | protected ModuleLoader m_moduleLoader; | ||
76 | protected StorageManager storageManager; | 79 | protected StorageManager storageManager; |
77 | protected AgentCircuitManager authenticateHandler; | 80 | protected AgentCircuitManager authenticateHandler; |
78 | protected RegionCommsListener regionCommsHost; | 81 | protected RegionCommsListener regionCommsHost; |
79 | protected CommunicationsManager commsManager; | 82 | protected CommunicationsManager commsManager; |
80 | protected XferManager xferManager; | 83 | // protected XferManager xferManager; |
81 | 84 | ||
82 | protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); | 85 | protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); |
83 | protected BaseHttpServer httpListener; | 86 | protected BaseHttpServer httpListener; |
84 | 87 | ||
88 | protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>(); | ||
89 | protected Dictionary<string, object> APIMethods = new Dictionary<string, object>(); | ||
90 | |||
91 | //API method Delegates | ||
92 | |||
93 | // this most likely shouldn't be handled as a API method like this, but doing it for testing purposes | ||
94 | public ModuleAPIMethod<bool, string, byte[]>AddXferFile = null; | ||
95 | |||
85 | #region Properties | 96 | #region Properties |
86 | 97 | ||
87 | public AgentCircuitManager AuthenticateHandler | 98 | public AgentCircuitManager AuthenticateHandler |
@@ -146,9 +157,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
146 | /// <param name="regionHandle">Region Handle for this region</param> | 157 | /// <param name="regionHandle">Region Handle for this region</param> |
147 | /// <param name="regionName">Region Name for this region</param> | 158 | /// <param name="regionName">Region Name for this region</param> |
148 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, | 159 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, |
149 | AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer) | 160 | AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader) |
150 | { | 161 | { |
151 | updateLock = new Mutex(false); | 162 | updateLock = new Mutex(false); |
163 | |||
164 | m_moduleLoader = moduleLoader; | ||
152 | authenticateHandler = authen; | 165 | authenticateHandler = authen; |
153 | commsManager = commsMan; | 166 | commsManager = commsMan; |
154 | storageManager = storeManager; | 167 | storageManager = storeManager; |
@@ -164,8 +177,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
164 | m_scriptManager = new ScriptManager(this); | 177 | m_scriptManager = new ScriptManager(this); |
165 | m_eventManager = new EventManager(); | 178 | m_eventManager = new EventManager(); |
166 | m_permissionManager = new PermissionManager(this); | 179 | m_permissionManager = new PermissionManager(this); |
167 | xferManager = new XferManager(); | ||
168 | 180 | ||
181 | MainLog.Instance.Verbose("Loading Region Modules"); | ||
182 | m_moduleLoader.LoadInternalModules(this); | ||
183 | |||
169 | m_eventManager.OnParcelPrimCountAdd += | 184 | m_eventManager.OnParcelPrimCountAdd += |
170 | m_LandManager.addPrimToLandPrimCounts; | 185 | m_LandManager.addPrimToLandPrimCounts; |
171 | 186 | ||
@@ -182,10 +197,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
182 | ScenePresence.LoadAnims(); | 197 | ScenePresence.LoadAnims(); |
183 | 198 | ||
184 | httpListener = httpServer; | 199 | httpListener = httpServer; |
200 | |||
201 | SetMethodDelegates(); | ||
185 | } | 202 | } |
186 | 203 | ||
187 | #endregion | 204 | #endregion |
188 | 205 | ||
206 | private void SetMethodDelegates() | ||
207 | { | ||
208 | AddXferFile = (ModuleAPIMethod<bool, string, byte[]>)this.RequestAPIMethod("API_AddXferFile"); | ||
209 | } | ||
210 | |||
189 | #region Script Handling Methods | 211 | #region Script Handling Methods |
190 | 212 | ||
191 | public void SendCommandToScripts(string[] args) | 213 | public void SendCommandToScripts(string[] args) |
@@ -682,7 +704,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
682 | client.OnRegionHandShakeReply += SendLayerData; | 704 | client.OnRegionHandShakeReply += SendLayerData; |
683 | //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); | 705 | //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); |
684 | client.OnModifyTerrain += ModifyTerrain; | 706 | client.OnModifyTerrain += ModifyTerrain; |
685 | client.OnChatFromViewer += SimChat; | 707 | //client.OnChatFromViewer += SimChat; |
686 | client.OnInstantMessage += InstantMessage; | 708 | client.OnInstantMessage += InstantMessage; |
687 | client.OnRequestWearables += InformClientOfNeighbours; | 709 | client.OnRequestWearables += InformClientOfNeighbours; |
688 | client.OnAddPrim += AddNewPrim; | 710 | client.OnAddPrim += AddNewPrim; |
@@ -725,15 +747,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
725 | client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset; | 747 | client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset; |
726 | client.OnAssetUploadRequest += commsManager.TransactionsManager.HandleUDPUploadRequest; | 748 | client.OnAssetUploadRequest += commsManager.TransactionsManager.HandleUDPUploadRequest; |
727 | client.OnXferReceive += commsManager.TransactionsManager.HandleXfer; | 749 | client.OnXferReceive += commsManager.TransactionsManager.HandleXfer; |
728 | // client.OnRequestXfer += RequestXfer; | ||
729 | client.OnRequestXfer += xferManager.RequestXfer; | ||
730 | client.OnConfirmXfer += xferManager.AckPacket; | ||
731 | client.OnRezScript += RezScript; | 750 | client.OnRezScript += RezScript; |
732 | client.OnRemoveTaskItem += RemoveTaskInventory; | 751 | client.OnRemoveTaskItem += RemoveTaskInventory; |
733 | 752 | ||
734 | client.OnRequestAvatarProperties += RequestAvatarProperty; | 753 | // client.OnRequestAvatarProperties += RequestAvatarProperty; |
735 | 754 | ||
736 | client.OnGrabObject += ProcessObjectGrab; | 755 | client.OnGrabObject += ProcessObjectGrab; |
756 | |||
757 | EventManager.TriggerOnNewClient(client); | ||
737 | } | 758 | } |
738 | 759 | ||
739 | protected ScenePresence CreateAndAddScenePresence(IClientAPI client) | 760 | protected ScenePresence CreateAndAddScenePresence(IClientAPI client) |
@@ -1093,6 +1114,31 @@ namespace OpenSim.Region.Environment.Scenes | |||
1093 | 1114 | ||
1094 | #endregion | 1115 | #endregion |
1095 | 1116 | ||
1117 | public void AddModule(string name, IRegionModule module) | ||
1118 | { | ||
1119 | if (!this.Modules.ContainsKey(name)) | ||
1120 | { | ||
1121 | Modules.Add(name, module); | ||
1122 | } | ||
1123 | } | ||
1124 | |||
1125 | public void RegisterAPIMethod(string name, object method) | ||
1126 | { | ||
1127 | if (!this.APIMethods.ContainsKey(name)) | ||
1128 | { | ||
1129 | this.APIMethods.Add(name, method); | ||
1130 | } | ||
1131 | } | ||
1132 | |||
1133 | public object RequestAPIMethod(string name) | ||
1134 | { | ||
1135 | if (this.APIMethods.ContainsKey(name)) | ||
1136 | { | ||
1137 | return APIMethods[name]; | ||
1138 | } | ||
1139 | return false; | ||
1140 | } | ||
1141 | |||
1096 | public void SetTimePhase(int phase) | 1142 | public void SetTimePhase(int phase) |
1097 | { | 1143 | { |
1098 | m_timePhase = phase; | 1144 | 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 | |||
14 | public delegate void OnBackupDelegate(Interfaces.IRegionDataStore datastore); | 14 | public delegate void OnBackupDelegate(Interfaces.IRegionDataStore datastore); |
15 | public event OnBackupDelegate OnBackup; | 15 | public event OnBackupDelegate OnBackup; |
16 | 16 | ||
17 | public delegate void OnNewClientDelegate(IClientAPI client); | ||
18 | public event OnNewClientDelegate OnNewClient; | ||
19 | |||
17 | public delegate void OnNewPresenceDelegate(ScenePresence presence); | 20 | public delegate void OnNewPresenceDelegate(ScenePresence presence); |
18 | public event OnNewPresenceDelegate OnNewPresence; | 21 | public event OnNewPresenceDelegate OnNewPresence; |
19 | 22 | ||
@@ -63,6 +66,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
63 | } | 66 | } |
64 | } | 67 | } |
65 | 68 | ||
69 | public void TriggerOnNewClient(IClientAPI client) | ||
70 | { | ||
71 | if (OnNewClient != null) | ||
72 | OnNewClient(client); | ||
73 | } | ||
74 | |||
66 | public void TriggerOnNewPresence(ScenePresence presence) | 75 | public void TriggerOnNewPresence(ScenePresence presence) |
67 | { | 76 | { |
68 | if (OnNewPresence != null) | 77 | 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 | |||
642 | return false; | 642 | return false; |
643 | } | 643 | } |
644 | 644 | ||
645 | public string RequestInventoryFile(uint localID, XferManager xferManager) | 645 | public string RequestInventoryFile(uint localID, ModuleAPIMethod<bool, string, byte[]> addXferFile) |
646 | { | 646 | { |
647 | SceneObjectPart part = this.GetChildPart(localID); | 647 | SceneObjectPart part = this.GetChildPart(localID); |
648 | if (part != null) | 648 | if (part != null) |
649 | { | 649 | { |
650 | return part.RequestInventoryFile(xferManager); | 650 | part.RequestInventoryFile(addXferFile); |
651 | } | 651 | } |
652 | return ""; | 652 | return ""; |
653 | } | 653 | } |
@@ -967,7 +967,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
967 | /// Processes backup | 967 | /// Processes backup |
968 | /// </summary> | 968 | /// </summary> |
969 | /// <param name="datastore"></param> | 969 | /// <param name="datastore"></param> |
970 | public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) | 970 | public void ProcessBackup(OpenSim.Region.Environment.Interfaces.IRegionDataStore datastore) |
971 | { | 971 | { |
972 | datastore.StoreObject(this, m_scene.RegionInfo.SimUUID); | 972 | datastore.StoreObject(this, m_scene.RegionInfo.SimUUID); |
973 | } | 973 | } |
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 | |||
482 | return false; | 482 | return false; |
483 | } | 483 | } |
484 | 484 | ||
485 | public string RequestInventoryFile(XferManager xferManager) | 485 | public string RequestInventoryFile(ModuleAPIMethod<bool, string, byte[]> addXferFile) |
486 | { | 486 | { |
487 | byte[] fileData = new byte[0]; | 487 | byte[] fileData = new byte[0]; |
488 | InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, this.UUID); | 488 | InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, this.UUID); |
@@ -516,7 +516,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
516 | fileData = Helpers.StringToField(invString.BuildString); | 516 | fileData = Helpers.StringToField(invString.BuildString); |
517 | if (fileData.Length > 2) | 517 | if (fileData.Length > 2) |
518 | { | 518 | { |
519 | xferManager.AddNewFile(m_inventoryFileName, fileData); | 519 | addXferFile(m_inventoryFileName, fileData); |
520 | } | 520 | } |
521 | return ""; | 521 | return ""; |
522 | } | 522 | } |