aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMW2007-08-28 14:21:17 +0000
committerMW2007-08-28 14:21:17 +0000
commit8e3b2392d129d727bfd00a2d9faa08d9e5be92de (patch)
tree7e6b89ee495af1d5ea76c58fc0796a3bb38ecc5d /OpenSim
parentEnsure that UserProfileData doesn't pass down null values. (diff)
downloadopensim-SC_OLD-8e3b2392d129d727bfd00a2d9faa08d9e5be92de.zip
opensim-SC_OLD-8e3b2392d129d727bfd00a2d9faa08d9e5be92de.tar.gz
opensim-SC_OLD-8e3b2392d129d727bfd00a2d9faa08d9e5be92de.tar.bz2
opensim-SC_OLD-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 'OpenSim')
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs27
-rw-r--r--OpenSim/Region/Communications/Local/CommunicationsLocal.cs4
-rw-r--r--OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs2
-rw-r--r--OpenSim/Region/Environment/Interfaces/IRegionModule.cs14
-rw-r--r--OpenSim/Region/Environment/ModuleLoader.cs93
-rw-r--r--OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs61
-rw-r--r--OpenSim/Region/Environment/Modules/ChatModule.cs165
-rw-r--r--OpenSim/Region/Environment/RegionManager.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs5
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs92
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs62
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneEvents.cs9
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs6
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs4
-rw-r--r--OpenSim/Region/Environment/StorageManager.cs2
-rw-r--r--OpenSim/Region/Environment/XferModule.cs (renamed from OpenSim/Region/Environment/XferManager.cs)41
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyWorld.cs4
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Program.cs2
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs2
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs2
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs71
21 files changed, 545 insertions, 125 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index 0b51759..8377d84 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -61,6 +61,8 @@ namespace OpenSim
61 public bool user_accounts; 61 public bool user_accounts;
62 public bool m_gridLocalAsset; 62 public bool m_gridLocalAsset;
63 63
64 protected ModuleLoader m_moduleLoader;
65
64 protected string m_storageDLL = "OpenSim.DataStore.NullStorage.dll"; 66 protected string m_storageDLL = "OpenSim.DataStore.NullStorage.dll";
65 67
66 protected string m_startupCommandsFile = ""; 68 protected string m_startupCommandsFile = "";
@@ -168,6 +170,8 @@ namespace OpenSim
168 configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); 170 configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
169 } 171 }
170 172
173 m_moduleLoader = new ModuleLoader();
174
171 // Load all script engines found 175 // Load all script engines found
172 OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader ScriptEngineLoader = new OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader(m_log); 176 OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader ScriptEngineLoader = new OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader(m_log);
173 177
@@ -225,7 +229,7 @@ namespace OpenSim
225 229
226 protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager) 230 protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager)
227 { 231 {
228 return new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer); 232 return new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, m_moduleLoader);
229 } 233 }
230 234
231 protected override void Initialize() 235 protected override void Initialize()
@@ -491,15 +495,18 @@ namespace OpenSim
491 if (entity is ScenePresence) 495 if (entity is ScenePresence)
492 { 496 {
493 ScenePresence scenePrescence = entity as ScenePresence; 497 ScenePresence scenePrescence = entity as ScenePresence;
494 m_log.Error( 498 if (!scenePrescence.childAgent)
495 String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", 499 {
496 scenePrescence.Firstname, 500 m_log.Error(
497 scenePrescence.Lastname, 501 String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}",
498 scenePrescence.UUID, 502 scenePrescence.Firstname,
499 scenePrescence.ControllingClient.AgentId, 503 scenePrescence.Lastname,
500 "Unknown", 504 scenePrescence.UUID,
501 "Unknown", 505 scenePrescence.ControllingClient.AgentId,
502 scene.RegionInfo.RegionName)); 506 "Unknown",
507 "Unknown",
508 scene.RegionInfo.RegionName));
509 }
503 } 510 }
504 } 511 }
505 } 512 }
diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
index c1e9efb..19c8860 100644
--- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
+++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
@@ -85,8 +85,8 @@ namespace OpenSim.Region.Communications.Local
85 uint regX = 1000; 85 uint regX = 1000;
86 uint regY = 1000; 86 uint regY = 1000;
87 87
88 tempfirstname = MainLog.Instance.CmdPrompt("First name", "Hello"); 88 tempfirstname = MainLog.Instance.CmdPrompt("First name", "Default");
89 templastname = MainLog.Instance.CmdPrompt("Last name", "Everyone"); 89 templastname = MainLog.Instance.CmdPrompt("Last name", "User");
90 tempMD5Passwd = MainLog.Instance.PasswdPrompt("Password"); 90 tempMD5Passwd = MainLog.Instance.PasswdPrompt("Password");
91 regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X", "1000")); 91 regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X", "1000"));
92 regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y" , "1000")); 92 regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y" , "1000"));
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
index 9b97fc6..24da06c 100644
--- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
+++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
@@ -36,7 +36,7 @@ using OpenSim.Region.Environment.LandManagement;
36 36
37using System.Collections.Generic; 37using System.Collections.Generic;
38 38
39namespace OpenSim.Region.Interfaces 39namespace OpenSim.Region.Environment.Interfaces
40{ 40{
41 public interface IRegionDataStore 41 public interface IRegionDataStore
42 { 42 {
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs
new file mode 100644
index 0000000..84e156f
--- /dev/null
+++ b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs
@@ -0,0 +1,14 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Region.Environment.Interfaces
6{
7 public interface IRegionModule
8 {
9 void Initialise(Scenes.Scene scene);
10 void PostInitialise();
11 void CloseDown();
12 string GetName();
13 }
14}
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs
new file mode 100644
index 0000000..8e42d90
--- /dev/null
+++ b/OpenSim/Region/Environment/ModuleLoader.cs
@@ -0,0 +1,93 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4using System.Text;
5using OpenSim.Region.Environment.Scenes;
6using OpenSim.Region.Environment.Interfaces;
7using OpenSim.Region.Environment.Modules;
8
9namespace OpenSim.Region.Environment
10{
11 public class ModuleLoader
12 {
13
14 public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
15
16 public ModuleLoader()
17 {
18
19 }
20
21 /// <summary>
22 /// Really just a test method for loading a set of currently internal modules
23 /// </summary>
24 /// <param name="scene"></param>
25 public void LoadInternalModules(Scene scene)
26 {
27 //Testing IRegionModule ideas
28 XferModule xferManager = new XferModule();
29 xferManager.Initialise(scene);
30 scene.AddModule(xferManager.GetName(), xferManager);
31
32 ChatModule chatModule = new ChatModule();
33 chatModule.Initialise(scene);
34 scene.AddModule(chatModule.GetName(), chatModule);
35
36 AvatarProfilesModule avatarProfiles = new AvatarProfilesModule();
37 avatarProfiles.Initialise(scene);
38 scene.AddModule(avatarProfiles.GetName(), avatarProfiles);
39
40 // Post Initialise Modules
41 xferManager.PostInitialise();
42 // chatModule.PostInitialise(); //for now leave this disabled as it would start up a partially working irc bot
43 avatarProfiles.PostInitialise();
44 }
45
46 public void LoadModule(string dllName, string moduleName, Scene scene)
47 {
48 Assembly pluginAssembly = null;
49 if (LoadedAssemblys.ContainsKey(dllName))
50 {
51 pluginAssembly = LoadedAssemblys[dllName];
52 }
53 else
54 {
55 pluginAssembly = Assembly.LoadFrom(dllName);
56 this.LoadedAssemblys.Add(dllName, pluginAssembly);
57 }
58
59 IRegionModule module = null;
60 foreach (Type pluginType in pluginAssembly.GetTypes())
61 {
62 if (pluginType.IsPublic)
63 {
64 if (!pluginType.IsAbstract)
65 {
66 Type typeInterface = pluginType.GetInterface("IRegionModule", true);
67
68 if (typeInterface != null)
69 {
70 module = (IRegionModule)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
71 break;
72 }
73 typeInterface = null;
74 }
75 }
76 }
77 pluginAssembly = null;
78
79 if (module.GetName() == moduleName)
80 {
81 module.Initialise(scene);
82 scene.AddModule(moduleName, module);
83 module.PostInitialise(); //shouldn't be done here
84 }
85
86 }
87
88 public void ClearCache()
89 {
90 this.LoadedAssemblys.Clear();
91 }
92 }
93}
diff --git a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs
new file mode 100644
index 0000000..1427c58
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs
@@ -0,0 +1,61 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using OpenSim.Framework.Interfaces;
6using OpenSim.Region.Environment.Scenes;
7using OpenSim.Region.Environment.Interfaces;
8
9namespace OpenSim.Region.Environment.Modules
10{
11 public class AvatarProfilesModule :IRegionModule
12 {
13
14 private Scene m_scene;
15
16 public AvatarProfilesModule()
17 {
18
19 }
20
21 public void Initialise(Scene scene)
22 {
23 m_scene = scene;
24 m_scene.EventManager.OnNewClient += NewClient;
25 }
26
27 public void PostInitialise()
28 {
29
30 }
31
32 public void CloseDown()
33 {
34
35 }
36
37 public string GetName()
38 {
39 return "AvatarProfilesModule";
40 }
41
42 public void NewClient(IClientAPI client)
43 {
44 client.OnRequestAvatarProperties += RequestAvatarProperty;
45 }
46
47 /// <summary>
48 ///
49 /// </summary>
50 /// <param name="remoteClient"></param>
51 /// <param name="avatarID"></param>
52 public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID)
53 {
54 string about = "OpenSim crash test dummy";
55 string bornOn = "Before now";
56 string flAbout = "First life? What is one of those? OpenSim is my life!";
57 LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000");
58 remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", partner);
59 }
60 }
61}
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs
new file mode 100644
index 0000000..703fe65
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/ChatModule.cs
@@ -0,0 +1,165 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Net;
5using System.Net.Sockets;
6using System.Threading;
7using System.IO;
8using libsecondlife;
9using OpenSim.Region.Environment.Scenes;
10using OpenSim.Region.Environment.Interfaces;
11using OpenSim.Framework.Interfaces;
12using OpenSim.Framework.Utilities;
13
14namespace OpenSim.Region.Environment.Modules
15{
16 public class ChatModule :IRegionModule
17 {
18 private Scene m_scene;
19
20 private string m_server = "irc2.choopa.net";
21
22 private int m_port = 6668;
23 private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
24 private string m_nick = "OpenSimBoT";
25 private string m_channel = "#opensim";
26
27 private NetworkStream m_stream;
28 private TcpClient m_irc;
29 private StreamWriter m_ircWriter;
30 private StreamReader m_ircReader;
31
32 private Thread pingSender;
33
34 private bool connected = false;
35
36 public ChatModule()
37 {
38
39 }
40
41 public void Initialise(Scene scene)
42 {
43 m_scene = scene;
44 m_scene.EventManager.OnNewClient += NewClient;
45
46 //should register a optional API Method, so other modules can send chat messages using this module
47 }
48
49 public void PostInitialise()
50 {
51 try
52 {
53 m_irc = new TcpClient(m_server, m_port);
54 m_stream = m_irc.GetStream();
55 m_ircReader = new StreamReader(m_stream);
56 m_ircWriter = new StreamWriter(m_stream);
57
58 pingSender = new Thread(new ThreadStart(this.PingRun));
59 pingSender.Start();
60
61 m_ircWriter.WriteLine(m_user);
62 m_ircWriter.Flush();
63 m_ircWriter.WriteLine("NICK " + m_nick);
64 m_ircWriter.Flush();
65 m_ircWriter.WriteLine("JOIN " + m_channel);
66 m_ircWriter.Flush();
67 connected = true;
68 }
69 catch (Exception e)
70 {
71 Console.WriteLine(e.ToString());
72 }
73 }
74
75 public void CloseDown()
76 {
77 m_ircWriter.Close();
78 m_ircReader.Close();
79 m_irc.Close();
80 }
81
82 public string GetName()
83 {
84 return "ChatModule";
85 }
86
87 public void NewClient(IClientAPI client)
88 {
89 client.OnChatFromViewer += SimChat;
90 }
91
92 public void PingRun()
93 {
94 while (true)
95 {
96 m_ircWriter.WriteLine("PING :" + m_server);
97 m_ircWriter.Flush();
98 Thread.Sleep(15000);
99 }
100 }
101
102 public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
103 {
104 ScenePresence avatar = null;
105 avatar = m_scene.RequestAvatar(fromAgentID);
106 if (avatar != null)
107 {
108 fromPos = avatar.AbsolutePosition;
109 fromName = avatar.Firstname + " " + avatar.Lastname;
110 avatar = null;
111 }
112
113 if (connected)
114 {
115 m_ircWriter.WriteLine("MSG " + m_channel +" :" + fromName + ", " + Util.FieldToString(message));
116 m_ircWriter.Flush();
117 }
118
119 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
120 {
121 int dis = -1000;
122
123 //err ??? the following code seems to be request a scenePresence when it already has a ref to it
124 avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId);
125 if (avatar != null)
126 {
127 dis = (int)avatar.AbsolutePosition.GetDistanceTo(fromPos);
128 }
129
130 switch (type)
131 {
132 case 0: // Whisper
133 if ((dis < 10) && (dis > -10))
134 {
135 //should change so the message is sent through the avatar rather than direct to the ClientView
136 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
137 fromAgentID);
138 }
139 break;
140 case 1: // Say
141 if ((dis < 30) && (dis > -30))
142 {
143 //Console.WriteLine("sending chat");
144 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
145 fromAgentID);
146 }
147 break;
148 case 2: // Shout
149 if ((dis < 100) && (dis > -100))
150 {
151 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
152 fromAgentID);
153 }
154 break;
155
156 case 0xff: // Broadcast
157 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
158 fromAgentID);
159 break;
160 }
161 });
162 }
163
164 }
165}
diff --git a/OpenSim/Region/Environment/RegionManager.cs b/OpenSim/Region/Environment/RegionManager.cs
index 255aa45..0146b52 100644
--- a/OpenSim/Region/Environment/RegionManager.cs
+++ b/OpenSim/Region/Environment/RegionManager.cs
@@ -9,6 +9,8 @@ using OpenSim.Region.Environment.LandManagement;
9 9
10namespace OpenSim.Region.Environment 10namespace OpenSim.Region.Environment
11{ 11{
12 public delegate TResult ModuleAPIMethod<TResult, TParam0, TParam1>(TParam0 param0, TParam1 param1);
13
12 public class RegionManager 14 public class RegionManager
13 { 15 {
14 protected AgentCircuitManager authenticateHandler; 16 protected AgentCircuitManager authenticateHandler;
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;
42using OpenSim.Physics.Manager; 42using OpenSim.Physics.Manager;
43using OpenSim.Framework.Communications.Caches; 43using OpenSim.Framework.Communications.Caches;
44using OpenSim.Region.Environment.LandManagement; 44using OpenSim.Region.Environment.LandManagement;
45using OpenSim.Region.Environment;
46using OpenSim.Region.Environment.Interfaces;
45using OpenSim.Region.Scripting; 47using OpenSim.Region.Scripting;
46using OpenSim.Region.Terrain; 48using OpenSim.Region.Terrain;
47using OpenSim.Framework.Data; 49using 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 }
diff --git a/OpenSim/Region/Environment/StorageManager.cs b/OpenSim/Region/Environment/StorageManager.cs
index a7d67d3..a478827 100644
--- a/OpenSim/Region/Environment/StorageManager.cs
+++ b/OpenSim/Region/Environment/StorageManager.cs
@@ -7,7 +7,7 @@ using OpenSim.Framework.Communications;
7using OpenSim.Framework.Servers; 7using OpenSim.Framework.Servers;
8using OpenSim.Region.Capabilities; 8using OpenSim.Region.Capabilities;
9using OpenSim.Region.Environment.Scenes; 9using OpenSim.Region.Environment.Scenes;
10using OpenSim.Region.Interfaces; 10using OpenSim.Region.Environment.Interfaces;
11 11
12using System.Reflection; 12using System.Reflection;
13 13
diff --git a/OpenSim/Region/Environment/XferManager.cs b/OpenSim/Region/Environment/XferModule.cs
index c49601c..beb72120 100644
--- a/OpenSim/Region/Environment/XferManager.cs
+++ b/OpenSim/Region/Environment/XferModule.cs
@@ -5,17 +5,50 @@ using System.Text;
5using libsecondlife; 5using libsecondlife;
6using OpenSim.Framework.Interfaces; 6using OpenSim.Framework.Interfaces;
7using OpenSim.Framework.Utilities; 7using OpenSim.Framework.Utilities;
8using OpenSim.Region.Environment.Scenes;
9using OpenSim.Region.Environment.Interfaces;
8 10
9namespace OpenSim.Region.Environment 11namespace OpenSim.Region.Environment
10{ 12{
11 public class XferManager 13 public class XferModule : IRegionModule
12 { 14 {
13 public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); 15 public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>();
14 public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); 16 public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
15 17
16 public XferManager() 18 private Scene m_scene;
19
20 public XferModule()
21 {
22
23 }
24
25 public void Initialise(Scene scene)
26 {
27 m_scene = scene;
28 m_scene.EventManager.OnNewClient += NewClient;
29
30 m_scene.RegisterAPIMethod("API_AddXferFile", new ModuleAPIMethod<bool, string, byte[]>(this.AddNewFile));
31 }
32
33 public void PostInitialise()
34 {
35
36 }
37
38 public void CloseDown()
39 {
40
41 }
42
43 public string GetName()
17 { 44 {
45 return "XferModule";
46 }
18 47
48 public void NewClient(IClientAPI client)
49 {
50 client.OnRequestXfer += RequestXfer;
51 client.OnConfirmXfer += AckPacket;
19 } 52 }
20 53
21 /// <summary> 54 /// <summary>
@@ -50,7 +83,7 @@ namespace OpenSim.Region.Environment
50 } 83 }
51 } 84 }
52 85
53 public void AddNewFile(string fileName, byte[] data) 86 public bool AddNewFile(string fileName, byte[] data)
54 { 87 {
55 lock (NewFiles) 88 lock (NewFiles)
56 { 89 {
@@ -63,8 +96,10 @@ namespace OpenSim.Region.Environment
63 NewFiles.Add(fileName, data); 96 NewFiles.Add(fileName, data);
64 } 97 }
65 } 98 }
99 return true;
66 } 100 }
67 101
102
68 public class XferDownLoad 103 public class XferDownLoad
69 { 104 {
70 public byte[] Data = new byte[0]; 105 public byte[] Data = new byte[0];
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
index a84af49..cf71389 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
@@ -19,8 +19,8 @@ namespace SimpleApp
19 { 19 {
20 private List<ScenePresence> m_avatars; 20 private List<ScenePresence> m_avatars;
21 21
22 public MyWorld( RegionInfo regionInfo, AgentCircuitManager authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer) 22 public MyWorld( RegionInfo regionInfo, AgentCircuitManager authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer, ModuleLoader moduleLoader)
23 : base( regionInfo, authen, commsMan, assetCach, storeMan, httpServer) 23 : base( regionInfo, authen, commsMan, assetCach, storeMan, httpServer, moduleLoader)
24 { 24 {
25 m_avatars = new List<Avatar>(); 25 m_avatars = new List<Avatar>();
26 } 26 }
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
index 2346109..3ba1b82 100644
--- a/OpenSim/Region/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -104,7 +104,7 @@ namespace SimpleApp
104 104
105 protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager) 105 protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager)
106 { 106 {
107 return new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer); 107 return new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, new ModuleLoader());
108 } 108 }
109 109
110 protected override StorageManager CreateStorageManager(RegionInfo regionInfo) 110 protected override StorageManager CreateStorageManager(RegionInfo regionInfo)
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
index 86a575a..c4fafde 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
@@ -8,7 +8,7 @@ using System.IO;
8using OpenSim.Region.Environment.Scenes; 8using OpenSim.Region.Environment.Scenes;
9using OpenSim.Region.Environment.LandManagement; 9using OpenSim.Region.Environment.LandManagement;
10using OpenSim.Region.Environment; 10using OpenSim.Region.Environment;
11using OpenSim.Region.Interfaces; 11using OpenSim.Region.Environment.Interfaces;
12using OpenSim.Framework.Console; 12using OpenSim.Framework.Console;
13using OpenSim.Framework.Types; 13using OpenSim.Framework.Types;
14using OpenSim.Framework.Utilities; 14using OpenSim.Framework.Utilities;
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
index 176a534..645bc96 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
@@ -4,7 +4,7 @@ using System.Text;
4 4
5using OpenSim.Region.Environment.Scenes; 5using OpenSim.Region.Environment.Scenes;
6using OpenSim.Region.Environment.LandManagement; 6using OpenSim.Region.Environment.LandManagement;
7using OpenSim.Region.Interfaces; 7using OpenSim.Region.Environment.Interfaces;
8using OpenSim.Framework.Console; 8using OpenSim.Framework.Console;
9using libsecondlife; 9using libsecondlife;
10 10
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
index af92fe7..d5cfb69 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -32,6 +32,7 @@ using System.Drawing.Imaging;
32using System.IO; 32using System.IO;
33using libTerrain; 33using libTerrain;
34using OpenJPEGNet; 34using OpenJPEGNet;
35using OpenSim.Framework.Interfaces;
35 36
36namespace OpenSim.Region.Terrain 37namespace OpenSim.Region.Terrain
37{ 38{
@@ -128,6 +129,76 @@ namespace OpenSim.Region.Terrain
128 heightmap.diff = new int[w / 16, h / 16]; 129 heightmap.diff = new int[w / 16, h / 16];
129 } 130 }
130 131
132 //Testing to see if moving the TerraForming packet handling code into here works well
133 /// <summary>
134 /// Modifies terrain using the specified information
135 /// </summary>
136 /// <param name="height">The height at which the user started modifying the terrain</param>
137 /// <param name="seconds">The number of seconds the modify button was pressed</param>
138 /// <param name="brushsize">The size of the brush used</param>
139 /// <param name="action">The action to be performed</param>
140 /// <param name="north">Distance from the north border where the cursor is located</param>
141 /// <param name="west">Distance from the west border where the cursor is located</param>
142 public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser)
143 {
144
145 // Shiny.
146 double size = (double)(1 << brushsize);
147
148 switch (action)
149 {
150 case 0:
151 // flatten terrain
152 this.FlattenTerrain(west, north, size, (double)seconds / 5.0);
153 break;
154 case 1:
155 // raise terrain
156 this.RaiseTerrain(west, north, size, (double)seconds / 5.0);
157 break;
158 case 2:
159 //lower terrain
160 this.LowerTerrain(west, north, size, (double)seconds / 5.0);
161 break;
162 case 3:
163 // smooth terrain
164 this.SmoothTerrain(west, north, size, (double)seconds / 5.0);
165 break;
166 case 4:
167 // noise
168 this.NoiseTerrain(west, north, size, (double)seconds / 5.0);
169 break;
170 case 5:
171 // revert
172 this.RevertTerrain(west, north, size, (double)seconds / 5.0);
173 break;
174
175 // CLIENT EXTENSIONS GO HERE
176 case 128:
177 // erode-thermal
178 break;
179 case 129:
180 // erode-aerobic
181 break;
182 case 130:
183 // erode-hydraulic
184 break;
185 }
186
187 for (int x = 0; x < 16; x++)
188 {
189 for (int y = 0; y < 16; y++)
190 {
191 if (this.Tainted(x * 16, y * 16))
192 {
193 remoteUser.SendLayerData(x, y, this.GetHeights1D());
194 }
195 }
196 }
197
198 return;
199 }
200
201
131 /// <summary> 202 /// <summary>
132 /// Checks to make sure the terrain is within baked values +/- maxRaise/minLower 203 /// Checks to make sure the terrain is within baked values +/- maxRaise/minLower
133 /// </summary> 204 /// </summary>