aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorAdam Frisby2007-10-22 15:23:48 +0000
committerAdam Frisby2007-10-22 15:23:48 +0000
commitc4707a284ffecf81e8ca60a1019e234339222631 (patch)
treebff5da1d8ecf39b0b4578ebec0b8b3dc86c03d85 /OpenSim
parentattempt to fix the muliple repeat problem (that sdague is getting) in the IRC... (diff)
downloadopensim-SC_OLD-c4707a284ffecf81e8ca60a1019e234339222631.zip
opensim-SC_OLD-c4707a284ffecf81e8ca60a1019e234339222631.tar.gz
opensim-SC_OLD-c4707a284ffecf81e8ca60a1019e234339222631.tar.bz2
opensim-SC_OLD-c4707a284ffecf81e8ca60a1019e234339222631.tar.xz
* Major ass commit.
* Sqlite Storage Engine now supports terrain -- however be aware that every terrain revision stored will at 512KB to your database file. At the moment it is storing every revision from the first. * Fixed an issue where by noverbose mode would display lots of useless junk. Noverbose mode is now quite usable. * Fixed a whole bunch of console message issues such as naming and categorisation
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs4
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServer.cs4
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs4
-rw-r--r--OpenSim/Framework/Communications/Cache/SQLAssetServer.cs4
-rw-r--r--OpenSim/Framework/Communications/InventoryServiceBase.cs2
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs2
-rw-r--r--OpenSim/Framework/Console/LogBase.cs63
-rw-r--r--OpenSim/Framework/General/Types/EstateSettings.cs8
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs2
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs18
-rw-r--r--OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs4
-rw-r--r--OpenSim/Region/Environment/ModuleLoader.cs428
-rw-r--r--OpenSim/Region/Environment/Modules/ChatModule.cs381
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs8
-rw-r--r--OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs4
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs2
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs121
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs4
18 files changed, 568 insertions, 495 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 17829b2..9dbd50e 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications.Cache
72 /// </summary> 72 /// </summary>
73 public AssetCache(IAssetServer assetServer) 73 public AssetCache(IAssetServer assetServer)
74 { 74 {
75 System.Console.WriteLine("Creating Asset cache"); 75 OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE","Creating Asset cache");
76 _assetServer = assetServer; 76 _assetServer = assetServer;
77 _assetServer.SetReceiver(this); 77 _assetServer.SetReceiver(this);
78 Assets = new Dictionary<LLUUID, AssetInfo>(); 78 Assets = new Dictionary<LLUUID, AssetInfo>();
@@ -89,7 +89,7 @@ namespace OpenSim.Framework.Communications.Cache
89 89
90 public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) 90 public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey)
91 { 91 {
92 System.Console.WriteLine("Creating Asset cache"); 92 OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE", "Creating Asset cache");
93 _assetServer = this.LoadAssetDll(assetServerDLLName); 93 _assetServer = this.LoadAssetDll(assetServerDLLName);
94 94
95 95
diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs
index 22bdc5c..aebda00 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServer.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Framework.Communications.Cache
51 yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); 51 yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap"));
52 52
53 db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); 53 db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap"));
54 MainLog.Instance.Verbose("Db4 Asset database creation"); 54 MainLog.Instance.Verbose("ASSETS","Db4 Asset database creation");
55 55
56 if (!yapfile) 56 if (!yapfile)
57 { 57 {
@@ -75,7 +75,7 @@ namespace OpenSim.Framework.Communications.Cache
75 75
76 if (db != null) 76 if (db != null)
77 { 77 {
78 MainLog.Instance.Verbose("Closing local asset server database"); 78 MainLog.Instance.Verbose("ASSETSERVER","Closing local asset server database");
79 db.Close(); 79 db.Close();
80 } 80 }
81 } 81 }
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index 08d5b87..685c0b9 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -36,8 +36,8 @@ namespace OpenSim.Framework.Communications.Cache
36 36
37 37
38 public AssetServerBase() 38 public AssetServerBase()
39 { 39 {
40 System.Console.WriteLine("Starting Db4o asset storage system"); 40 OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSERVER","Starting Db4o asset storage system");
41 this._assetRequests = new BlockingQueue<ARequest>(); 41 this._assetRequests = new BlockingQueue<ARequest>();
42 42
43 this._localAssetServerThread = new Thread( RunRequests ); 43 this._localAssetServerThread = new Thread( RunRequests );
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
index 69f83d2..580e5c4 100644
--- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
+++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Framework.Communications.Cache
68 m_assetProviderPlugin = plug; 68 m_assetProviderPlugin = plug;
69 m_assetProviderPlugin.Initialise(); 69 m_assetProviderPlugin.Initialise();
70 70
71 MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); 71 MainLog.Instance.Verbose("AssetStorage","Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version);
72 } 72 }
73 73
74 typeInterface = null; 74 typeInterface = null;
@@ -92,7 +92,7 @@ namespace OpenSim.Framework.Communications.Cache
92 { 92 {
93 ARequest req = this._assetRequests.Dequeue(); 93 ARequest req = this._assetRequests.Dequeue();
94 94
95 MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); 95 MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID);
96 96
97 AssetBase asset = null; 97 AssetBase asset = null;
98 lock (syncLock) 98 lock (syncLock)
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs
index 65eb509..06a1ca8 100644
--- a/OpenSim/Framework/Communications/InventoryServiceBase.cs
+++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Framework.Communications
70 (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 70 (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
71 plug.Initialise(); 71 plug.Initialise();
72 this.m_plugins.Add(plug.getName(), plug); 72 this.m_plugins.Add(plug.getName(), plug);
73 MainLog.Instance.Verbose("Inventorystorage: Added IInventoryData Interface"); 73 MainLog.Instance.Verbose("INVENTORY","Added IInventoryData Interface");
74 } 74 }
75 } 75 }
76 } 76 }
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index 674c746..f4648df 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Framework.UserManagement
66 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) 66 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
67 { 67 {
68 68
69 MainLog.Instance.Verbose("Attempting login now..."); 69 MainLog.Instance.Verbose("LOGIN","Attempting login now...");
70 XmlRpcResponse response = new XmlRpcResponse(); 70 XmlRpcResponse response = new XmlRpcResponse();
71 Hashtable requestData = (Hashtable)request.Params[0]; 71 Hashtable requestData = (Hashtable)request.Params[0];
72 72
diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs
index 5a7ce4d..246afa1 100644
--- a/OpenSim/Framework/Console/LogBase.cs
+++ b/OpenSim/Framework/Console/LogBase.cs
@@ -170,8 +170,11 @@ namespace OpenSim.Framework.Console
170 /// <param name="args">WriteLine-style message arguments</param> 170 /// <param name="args">WriteLine-style message arguments</param>
171 public void Verbose(string format, params object[] args) 171 public void Verbose(string format, params object[] args)
172 { 172 {
173 WriteNewLine(ConsoleColor.Gray, format, args); 173 if (!m_silent)
174 return; 174 {
175 WriteNewLine(ConsoleColor.Gray, format, args);
176 return;
177 }
175 } 178 }
176 179
177 /// <summary> 180 /// <summary>
@@ -182,9 +185,12 @@ namespace OpenSim.Framework.Console
182 /// <param name="args">WriteLine-style message arguments</param> 185 /// <param name="args">WriteLine-style message arguments</param>
183 public void Verbose(string sender, string format, params object[] args) 186 public void Verbose(string sender, string format, params object[] args)
184 { 187 {
185 WritePrefixLine(DeriveColor(sender), sender); 188 if (!m_silent)
186 WriteNewLine(ConsoleColor.Gray, format, args); 189 {
187 return; 190 WritePrefixLine(DeriveColor(sender), sender);
191 WriteNewLine(ConsoleColor.Gray, format, args);
192 return;
193 }
188 } 194 }
189 195
190 /// <summary> 196 /// <summary>
@@ -234,22 +240,20 @@ namespace OpenSim.Framework.Console
234 Log.Write(now); 240 Log.Write(now);
235 Log.WriteLine(format, args); 241 Log.WriteLine(format, args);
236 Log.Flush(); 242 Log.Flush();
237 if (!m_silent) 243
244 System.Console.Write(now);
245 try
238 { 246 {
239 System.Console.Write(now); 247 if (color != ConsoleColor.White)
240 try 248 System.Console.ForegroundColor = color;
241 {
242 if (color != ConsoleColor.White)
243 System.Console.ForegroundColor = color;
244 249
245 System.Console.WriteLine(format, args); 250 System.Console.WriteLine(format, args);
246 System.Console.ResetColor(); 251 System.Console.ResetColor();
247 } 252 }
248 catch (ArgumentNullException) 253 catch (ArgumentNullException)
249 { 254 {
250 // Some older systems dont support coloured text. 255 // Some older systems dont support coloured text.
251 System.Console.WriteLine(format, args); 256 System.Console.WriteLine(format, args);
252 }
253 } 257 }
254 return; 258 return;
255 } 259 }
@@ -265,19 +269,16 @@ namespace OpenSim.Framework.Console
265 269
266 System.Console.Write("["); 270 System.Console.Write("[");
267 271
268 if (!m_silent) 272 try
269 { 273 {
270 try 274 System.Console.ForegroundColor = color;
271 { 275 System.Console.Write(sender);
272 System.Console.ForegroundColor = color; 276 System.Console.ResetColor();
273 System.Console.Write(sender); 277 }
274 System.Console.ResetColor(); 278 catch (ArgumentNullException)
275 } 279 {
276 catch (ArgumentNullException) 280 // Some older systems dont support coloured text.
277 { 281 System.Console.WriteLine(sender);
278 // Some older systems dont support coloured text.
279 System.Console.WriteLine(sender);
280 }
281 } 282 }
282 283
283 System.Console.Write("] \t"); 284 System.Console.Write("] \t");
diff --git a/OpenSim/Framework/General/Types/EstateSettings.cs b/OpenSim/Framework/General/Types/EstateSettings.cs
index abdcf6f..2675e52 100644
--- a/OpenSim/Framework/General/Types/EstateSettings.cs
+++ b/OpenSim/Framework/General/Types/EstateSettings.cs
@@ -557,8 +557,12 @@ namespace OpenSim.Framework.Types
557 private ConfigurationMember configMember; 557 private ConfigurationMember configMember;
558 public EstateSettings() 558 public EstateSettings()
559 { 559 {
560 configMember = new ConfigurationMember(Path.Combine(Util.configDir(),"estate_settings.xml"), "ESTATE SETTINGS", this.loadConfigurationOptions, this.handleIncomingConfiguration); 560 // Temporary hack to prevent multiple loadings.
561 configMember.performConfigurationRetrieve(); 561 if (configMember == null)
562 {
563 configMember = new ConfigurationMember(Path.Combine(Util.configDir(), "estate_settings.xml"), "ESTATE SETTINGS", this.loadConfigurationOptions, this.handleIncomingConfiguration);
564 configMember.performConfigurationRetrieve();
565 }
562 } 566 }
563 567
564 public void loadConfigurationOptions() 568 public void loadConfigurationOptions()
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index 6d432fd..179a651 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -224,7 +224,7 @@ namespace OpenSim.Framework.Servers
224 { 224 {
225 try 225 try
226 { 226 {
227 MainLog.Instance.Status("HTTPD", "Spawned main thread OK"); 227 MainLog.Instance.Verbose("HTTPD", "Spawned main thread OK");
228 m_httpListener = new HttpListener(); 228 m_httpListener = new HttpListener();
229 229
230 m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); 230 m_httpListener.Prefixes.Add("http://+:" + m_port + "/");
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index d2f5648..9de3831 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -262,8 +262,10 @@ namespace OpenSim
262 } 262 }
263 else 263 else
264 { 264 {
265 MainLog.Instance.Verbose("No startup command script specified. Moving on..."); 265 MainLog.Instance.Verbose("STARTUP","No startup command script specified. Moving on...");
266 } 266 }
267
268 MainLog.Instance.Status("STARTUP","Startup complete, serving " + m_udpServers.Count.ToString() + " region(s)");
267 } 269 }
268 270
269 private static void CreateDefaultRegionInfoXml(string fileName) 271 private static void CreateDefaultRegionInfoXml(string fileName)
@@ -361,11 +363,11 @@ namespace OpenSim
361 RunCommandScript(m_shutdownCommandsFile); 363 RunCommandScript(m_shutdownCommandsFile);
362 } 364 }
363 365
364 m_log.Verbose("Closing all threads"); 366 m_log.Verbose("SHUTDOWN", "Closing all threads");
365 m_log.Verbose("Killing listener thread"); 367 m_log.Verbose("SHUTDOWN", "Killing listener thread");
366 m_log.Verbose("Killing clients"); 368 m_log.Verbose("SHUTDOWN", "Killing clients");
367 // IMPLEMENT THIS 369 // IMPLEMENT THIS
368 m_log.Verbose("Closing console and terminating"); 370 m_log.Verbose("SHUTDOWN", "Closing console and terminating");
369 371
370 m_sceneManager.Close(); 372 m_sceneManager.Close();
371 373
@@ -380,7 +382,7 @@ namespace OpenSim
380 /// <param name="fileName"></param> 382 /// <param name="fileName"></param>
381 private void RunCommandScript(string fileName) 383 private void RunCommandScript(string fileName)
382 { 384 {
383 MainLog.Instance.Verbose("Running command script (" + fileName + ")"); 385 MainLog.Instance.Verbose("COMMANDFILE", "Running " + fileName);
384 if (File.Exists(fileName)) 386 if (File.Exists(fileName))
385 { 387 {
386 StreamReader readFile = File.OpenText(fileName); 388 StreamReader readFile = File.OpenText(fileName);
@@ -389,14 +391,14 @@ namespace OpenSim
389 { 391 {
390 if (currentCommand != "") 392 if (currentCommand != "")
391 { 393 {
392 MainLog.Instance.Verbose("Running '" + currentCommand + "'"); 394 MainLog.Instance.Verbose("COMMANDFILE", "Running '" + currentCommand + "'");
393 MainLog.Instance.MainLogRunCommand(currentCommand); 395 MainLog.Instance.MainLogRunCommand(currentCommand);
394 } 396 }
395 } 397 }
396 } 398 }
397 else 399 else
398 { 400 {
399 MainLog.Instance.Error("Command script missing. Can not run commands"); 401 MainLog.Instance.Error("COMMANDFILE","Command script missing. Can not run commands");
400 } 402 }
401 } 403 }
402 404
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
index 1a00f2c..e375343 100644
--- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
+++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
@@ -47,8 +47,8 @@ namespace OpenSim.Region.Environment.Interfaces
47 47
48 List<SceneObjectGroup> LoadObjects(LLUUID regionUUID); 48 List<SceneObjectGroup> LoadObjects(LLUUID regionUUID);
49 49
50 void StoreTerrain(double[,] terrain); 50 void StoreTerrain(double[,] terrain, LLUUID regionID);
51 double[,] LoadTerrain(); 51 double[,] LoadTerrain(LLUUID regionID);
52 52
53 void StoreParcel(Land Parcel); 53 void StoreParcel(Land Parcel);
54 void RemoveLandObject(uint ID); 54 void RemoveLandObject(uint ID);
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs
index 4c66d2e..4fc45a0 100644
--- a/OpenSim/Region/Environment/ModuleLoader.cs
+++ b/OpenSim/Region/Environment/ModuleLoader.cs
@@ -1,214 +1,214 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Framework.Console; 33using OpenSim.Framework.Console;
34using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Modules; 35using OpenSim.Region.Environment.Modules;
36using OpenSim.Region.Environment.Scenes; 36using OpenSim.Region.Environment.Scenes;
37using Nini.Config; 37using Nini.Config;
38 38
39namespace OpenSim.Region.Environment 39namespace OpenSim.Region.Environment
40{ 40{
41 public class ModuleLoader 41 public class ModuleLoader
42 { 42 {
43 public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); 43 public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
44 44
45 public List<IRegionModule> LoadedModules = new List<IRegionModule>(); 45 public List<IRegionModule> LoadedModules = new List<IRegionModule>();
46 public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>(); 46 public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>();
47 private readonly LogBase m_log; 47 private readonly LogBase m_log;
48 private IConfigSource m_config; 48 private IConfigSource m_config;
49 49
50 public ModuleLoader(LogBase log, IConfigSource config) 50 public ModuleLoader(LogBase log, IConfigSource config)
51 { 51 {
52 m_log = log; 52 m_log = log;
53 m_config = config; 53 m_config = config;
54 } 54 }
55 55
56 public void PickupModules(Scene scene, string moduleDir) 56 public void PickupModules(Scene scene, string moduleDir)
57 { 57 {
58 DirectoryInfo dir = new DirectoryInfo(moduleDir); 58 DirectoryInfo dir = new DirectoryInfo(moduleDir);
59 59
60 foreach (FileInfo fileInfo in dir.GetFiles("*.dll")) 60 foreach (FileInfo fileInfo in dir.GetFiles("*.dll"))
61 { 61 {
62 LoadRegionModules(fileInfo.FullName, scene); 62 LoadRegionModules(fileInfo.FullName, scene);
63 } 63 }
64 } 64 }
65 65
66 public void LoadDefaultSharedModules() 66 public void LoadDefaultSharedModules()
67 { 67 {
68 DynamicTextureModule dynamicModule = new DynamicTextureModule(); 68 DynamicTextureModule dynamicModule = new DynamicTextureModule();
69 LoadedSharedModules.Add(dynamicModule.Name, dynamicModule); 69 LoadedSharedModules.Add(dynamicModule.Name, dynamicModule);
70 ChatModule chat = new ChatModule(); 70 ChatModule chat = new ChatModule();
71 LoadedSharedModules.Add(chat.Name, chat); 71 LoadedSharedModules.Add(chat.Name, chat);
72 InstantMessageModule imMod = new InstantMessageModule(); 72 InstantMessageModule imMod = new InstantMessageModule();
73 LoadedSharedModules.Add(imMod.Name, imMod); 73 LoadedSharedModules.Add(imMod.Name, imMod);
74 LoadImageURLModule loadMod = new LoadImageURLModule(); 74 LoadImageURLModule loadMod = new LoadImageURLModule();
75 LoadedSharedModules.Add(loadMod.Name, loadMod); 75 LoadedSharedModules.Add(loadMod.Name, loadMod);
76 } 76 }
77 77
78 public void InitialiseSharedModules(Scene scene) 78 public void InitialiseSharedModules(Scene scene)
79 { 79 {
80 foreach (IRegionModule module in LoadedSharedModules.Values) 80 foreach (IRegionModule module in LoadedSharedModules.Values)
81 { 81 {
82 module.Initialise(scene, m_config); 82 module.Initialise(scene, m_config);
83 scene.AddModule(module.Name, module); //should be doing this? 83 scene.AddModule(module.Name, module); //should be doing this?
84 } 84 }
85 } 85 }
86 86
87 public void InitializeModule(IRegionModule module, Scene scene) 87 public void InitializeModule(IRegionModule module, Scene scene)
88 { 88 {
89 module.Initialise(scene, m_config); 89 module.Initialise(scene, m_config);
90 scene.AddModule(module.Name, module); 90 scene.AddModule(module.Name, module);
91 LoadedModules.Add(module); 91 LoadedModules.Add(module);
92 } 92 }
93 93
94 /// <summary> 94 /// <summary>
95 /// Loads/initialises a Module instance that can be used by mutliple Regions 95 /// Loads/initialises a Module instance that can be used by mutliple Regions
96 /// </summary> 96 /// </summary>
97 /// <param name="dllName"></param> 97 /// <param name="dllName"></param>
98 /// <param name="moduleName"></param> 98 /// <param name="moduleName"></param>
99 /// <param name="scene"></param> 99 /// <param name="scene"></param>
100 public void LoadSharedModule(string dllName, string moduleName) 100 public void LoadSharedModule(string dllName, string moduleName)
101 { 101 {
102 IRegionModule module = LoadModule(dllName, moduleName); 102 IRegionModule module = LoadModule(dllName, moduleName);
103 if (module != null) 103 if (module != null)
104 { 104 {
105 LoadedSharedModules.Add(module.Name, module); 105 LoadedSharedModules.Add(module.Name, module);
106 } 106 }
107 } 107 }
108 108
109 public void LoadRegionModules(string dllName, Scene scene) 109 public void LoadRegionModules(string dllName, Scene scene)
110 { 110 {
111 IRegionModule[] modules = LoadModules(dllName); 111 IRegionModule[] modules = LoadModules(dllName);
112 112
113 if (modules.Length > 0) 113 if (modules.Length > 0)
114 { 114 {
115 m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName ); 115 m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName );
116 foreach (IRegionModule module in modules) 116 foreach (IRegionModule module in modules)
117 { 117 {
118 if (!module.IsSharedModule) 118 if (!module.IsSharedModule)
119 { 119 {
120 m_log.Verbose("MODULES", " [{0}]: Initializing.", module.Name); 120 m_log.Verbose("MODULES", " [{0}]: Initializing.", module.Name);
121 InitializeModule(module, scene); 121 InitializeModule(module, scene);
122 } 122 }
123 } 123 }
124 } 124 }
125 } 125 }
126 126
127 public void LoadRegionModule(string dllName, string moduleName, Scene scene) 127 public void LoadRegionModule(string dllName, string moduleName, Scene scene)
128 { 128 {
129 IRegionModule module = LoadModule(dllName, moduleName); 129 IRegionModule module = LoadModule(dllName, moduleName);
130 if (module != null) 130 if (module != null)
131 { 131 {
132 InitializeModule(module, scene); 132 InitializeModule(module, scene);
133 } 133 }
134 } 134 }
135 135
136 /// <summary> 136 /// <summary>
137 /// Loads a external Module (if not already loaded) and creates a new instance of it. 137 /// Loads a external Module (if not already loaded) and creates a new instance of it.
138 /// </summary> 138 /// </summary>
139 /// <param name="dllName"></param> 139 /// <param name="dllName"></param>
140 /// <param name="moduleName"></param> 140 /// <param name="moduleName"></param>
141 /// <param name="scene"></param> 141 /// <param name="scene"></param>
142 public IRegionModule LoadModule(string dllName, string moduleName) 142 public IRegionModule LoadModule(string dllName, string moduleName)
143 { 143 {
144 IRegionModule[] modules = LoadModules(dllName); 144 IRegionModule[] modules = LoadModules(dllName);
145 145
146 foreach (IRegionModule module in modules) 146 foreach (IRegionModule module in modules)
147 { 147 {
148 if ((module != null) && (module.Name == moduleName)) 148 if ((module != null) && (module.Name == moduleName))
149 { 149 {
150 return module; 150 return module;
151 } 151 }
152 } 152 }
153 153
154 return null; 154 return null;
155 } 155 }
156 156
157 public IRegionModule[] LoadModules(string dllName) 157 public IRegionModule[] LoadModules(string dllName)
158 { 158 {
159 List<IRegionModule> modules = new List<IRegionModule>(); 159 List<IRegionModule> modules = new List<IRegionModule>();
160 160
161 Assembly pluginAssembly; 161 Assembly pluginAssembly;
162 if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly )) 162 if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly ))
163 { 163 {
164 try 164 try
165 { 165 {
166 pluginAssembly = Assembly.LoadFrom(dllName); 166 pluginAssembly = Assembly.LoadFrom(dllName);
167 LoadedAssemblys.Add(dllName, pluginAssembly); 167 LoadedAssemblys.Add(dllName, pluginAssembly);
168 } 168 }
169 catch( BadImageFormatException e ) 169 catch( BadImageFormatException e )
170 { 170 {
171 m_log.Warn( "MODULES", "The file [{0}] is not a module assembly.", e.FileName ); 171 m_log.Verbose( "MODULES", "The file [{0}] is not a module assembly.", e.FileName );
172 } 172 }
173 } 173 }
174 174
175 175
176 if (pluginAssembly != null) 176 if (pluginAssembly != null)
177 { 177 {
178 foreach (Type pluginType in pluginAssembly.GetTypes()) 178 foreach (Type pluginType in pluginAssembly.GetTypes())
179 { 179 {
180 if (pluginType.IsPublic) 180 if (pluginType.IsPublic)
181 { 181 {
182 if (!pluginType.IsAbstract) 182 if (!pluginType.IsAbstract)
183 { 183 {
184 if( pluginType.GetInterface("IRegionModule") != null ) 184 if( pluginType.GetInterface("IRegionModule") != null )
185 { 185 {
186 modules.Add((IRegionModule) Activator.CreateInstance(pluginType)); 186 modules.Add((IRegionModule) Activator.CreateInstance(pluginType));
187 } 187 }
188 } 188 }
189 } 189 }
190 } 190 }
191 } 191 }
192 192
193 return modules.ToArray(); 193 return modules.ToArray();
194 } 194 }
195 195
196 public void PostInitialise() 196 public void PostInitialise()
197 { 197 {
198 foreach (IRegionModule module in LoadedSharedModules.Values) 198 foreach (IRegionModule module in LoadedSharedModules.Values)
199 { 199 {
200 module.PostInitialise(); 200 module.PostInitialise();
201 } 201 }
202 202
203 foreach (IRegionModule module in LoadedModules) 203 foreach (IRegionModule module in LoadedModules)
204 { 204 {
205 module.PostInitialise(); 205 module.PostInitialise();
206 } 206 }
207 } 207 }
208 208
209 public void ClearCache() 209 public void ClearCache()
210 { 210 {
211 LoadedAssemblys.Clear(); 211 LoadedAssemblys.Clear();
212 } 212 }
213 } 213 }
214} 214}
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs
index 58b9d7b..1f488b0 100644
--- a/OpenSim/Region/Environment/Modules/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/ChatModule.cs
@@ -45,26 +45,55 @@ namespace OpenSim.Region.Environment.Modules
45 private List<Scene> m_scenes = new List<Scene>(); 45 private List<Scene> m_scenes = new List<Scene>();
46 private LogBase m_log; 46 private LogBase m_log;
47 47
48 private string m_server = null;
49 private int m_port = 6668;
50 private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
51 private string m_nick = null;
52 private string m_channel = null;
53
48 private int m_whisperdistance = 10; 54 private int m_whisperdistance = 10;
49 private int m_saydistance = 30; 55 private int m_saydistance = 30;
50 private int m_shoutdistance = 100; 56 private int m_shoutdistance = 100;
51 57
52 private IRCChatModule m_irc = null; 58 private NetworkStream m_stream;
59 private TcpClient m_irc;
60 private StreamWriter m_ircWriter;
61 private StreamReader m_ircReader;
62
63 private Thread pingSender;
64 private Thread listener;
65
66 private bool m_enable_irc = false;
67 private bool connected = false;
53 68
54 public ChatModule() 69 public ChatModule()
55 { 70 {
71 m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
72 m_irc = null;
73 m_ircWriter = null;
74 m_ircReader = null;
75
56 m_log = OpenSim.Framework.Console.MainLog.Instance; 76 m_log = OpenSim.Framework.Console.MainLog.Instance;
57 } 77 }
58 78
59 public void Initialise(Scene scene, Nini.Config.IConfigSource config) 79 public void Initialise(Scene scene, Nini.Config.IConfigSource config)
60 { 80 {
61 // wrap this in a try block so that defaults will work if
62 // the config file doesn't specify otherwise.
63 try { 81 try {
64 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 82 m_server = config.Configs["IRC"].GetString("server");
65 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 83 m_nick = config.Configs["IRC"].GetString("nick");
66 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 84 m_channel = config.Configs["IRC"].GetString("channel");
67 } catch (Exception e) {} 85 m_port = config.Configs["IRC"].GetInt("port", m_port);
86 m_user = config.Configs["IRC"].GetString("username", m_user);
87 if (m_server != null && m_nick != null && m_channel != null) {
88 m_enable_irc = true;
89 }
90 } catch (Exception e) {
91 OpenSim.Framework.Console.MainLog.Instance.Verbose("No IRC config information, skipping IRC bridge configuration");
92 }
93
94 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance");
95 m_saydistance = config.Configs["Chat"].GetInt("say_distance");
96 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance");
68 97
69 if (!m_scenes.Contains(scene)) 98 if (!m_scenes.Contains(scene))
70 { 99 {
@@ -72,21 +101,43 @@ namespace OpenSim.Region.Environment.Modules
72 scene.EventManager.OnNewClient += NewClient; 101 scene.EventManager.OnNewClient += NewClient;
73 scene.RegisterModuleInterface<ISimChat>(this); 102 scene.RegisterModuleInterface<ISimChat>(this);
74 } 103 }
75
76 // setup IRC Relay
77 m_irc = new IRCChatModule(config);
78 } 104 }
79 105
80 public void PostInitialise() 106 public void PostInitialise()
81 { 107 {
82 108 if( m_enable_irc ) {
83 if (m_irc.Enabled) { 109 try
84 m_irc.Connect(m_scenes); 110 {
111 m_irc = new TcpClient(m_server, m_port);
112 m_stream = m_irc.GetStream();
113 m_ircReader = new StreamReader(m_stream);
114 m_ircWriter = new StreamWriter(m_stream);
115
116 pingSender = new Thread(new ThreadStart(this.PingRun));
117 pingSender.Start();
118
119 listener = new Thread(new ThreadStart(this.ListenerRun));
120 listener.Start();
121
122 m_ircWriter.WriteLine(m_user);
123 m_ircWriter.Flush();
124 m_ircWriter.WriteLine("NICK " + m_nick);
125 m_ircWriter.Flush();
126 m_ircWriter.WriteLine("JOIN " + m_channel);
127 m_ircWriter.Flush();
128 connected = true;
129 }
130 catch (Exception e)
131 {
132 Console.WriteLine(e.ToString());
133 }
85 } 134 }
86 } 135 }
87 136
88 public void Close() 137 public void Close()
89 { 138 {
139 m_ircWriter.Close();
140 m_ircReader.Close();
90 m_irc.Close(); 141 m_irc.Close();
91 } 142 }
92 143
@@ -105,6 +156,43 @@ namespace OpenSim.Region.Environment.Modules
105 client.OnChatFromViewer += SimChat; 156 client.OnChatFromViewer += SimChat;
106 } 157 }
107 158
159 public void PingRun()
160 {
161 while (true)
162 {
163 m_ircWriter.WriteLine("PING :" + m_server);
164 m_ircWriter.Flush();
165 Thread.Sleep(15000);
166 }
167 }
168
169 public void ListenerRun()
170 {
171 string inputLine;
172 LLVector3 pos = new LLVector3(128, 128, 20);
173 while (true)
174 {
175 while ((inputLine = m_ircReader.ReadLine()) != null)
176 {
177 Console.WriteLine(inputLine);
178 if (inputLine.Contains(m_channel))
179 {
180 string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
181 foreach (Scene m_scene in m_scenes)
182 {
183 m_scene.Broadcast(delegate(IClientAPI client)
184 {
185 client.SendChatMessage(
186 Helpers.StringToField(mess), 255, pos, "IRC:",
187 LLUUID.Zero);
188 });
189 }
190 }
191 }
192 Thread.Sleep(50);
193 }
194 }
195
108 public void SimChat(Object sender, ChatFromViewerArgs e) 196 public void SimChat(Object sender, ChatFromViewerArgs e)
109 { 197 {
110 ScenePresence avatar = null; 198 ScenePresence avatar = null;
@@ -158,215 +246,80 @@ namespace OpenSim.Region.Environment.Modules
158 246
159 m_log.Verbose("CHAT", fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + e.Message); 247 m_log.Verbose("CHAT", fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + e.Message);
160 248
161 if (m_irc.Connected) 249 if (connected)
162 { 250 {
163 m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, e.Message); 251 try
164 } 252 {
165 253 m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + " in " + scene.RegionInfo.RegionName + ">: " +
166 if (e.Channel == 0) 254 e.Message);
167 { 255 m_ircWriter.Flush();
168 foreach (Scene m_scene in m_scenes)
169 {
170 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
171 {
172 int dis = -100000;
173
174 LLVector3 avatarRegionPos = presence.AbsolutePosition + new LLVector3(scene.RegionInfo.RegionLocX * 256, scene.RegionInfo.RegionLocY * 256, 0);
175 dis = Math.Abs((int)avatarRegionPos.GetDistanceTo(fromRegionPos));
176
177 switch (e.Type)
178 {
179 case ChatTypeEnum.Whisper:
180 if (dis < m_whisperdistance)
181 {
182 //should change so the message is sent through the avatar rather than direct to the ClientView
183 presence.ControllingClient.SendChatMessage(message,
184 type,
185 fromPos,
186 fromName,
187 fromAgentID);
188 }
189 break;
190 case ChatTypeEnum.Say:
191 if (dis < m_saydistance)
192 {
193 //Console.WriteLine("sending chat");
194 presence.ControllingClient.SendChatMessage(message,
195 type,
196 fromPos,
197 fromName,
198 fromAgentID);
199 }
200 break;
201 case ChatTypeEnum.Shout:
202 if (dis < m_shoutdistance)
203 {
204 presence.ControllingClient.SendChatMessage(message,
205 type,
206 fromPos,
207 fromName,
208 fromAgentID);
209 }
210 break;
211
212 case ChatTypeEnum.Broadcast:
213 presence.ControllingClient.SendChatMessage(message, type,
214 fromPos,
215 fromName,
216 fromAgentID);
217 break;
218 default:
219 break;
220 }
221 });
222 } 256 }
223 } 257 catch (IOException)
224 } 258 {
225 } 259 m_log.Error("IRC","Disconnected from IRC server.");
226 260 listener.Abort();
227 class IRCChatModule { 261 pingSender.Abort();
228 private string m_server = null; 262 connected = false;
229 private int m_port = 6668;
230 private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
231 private string m_nick = null;
232 private string m_channel = null;
233
234 private NetworkStream m_stream;
235 private TcpClient m_tcp;
236 private StreamWriter m_writer;
237 private StreamReader m_reader;
238
239 private Thread pingSender;
240 private Thread listener;
241
242 private bool m_enabled = false;
243 private bool m_connected = false;
244
245 private List<Scene> m_scenes = null;
246 private LogBase m_log;
247
248 public IRCChatModule(Nini.Config.IConfigSource config) {
249 m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
250 m_tcp = null;
251 m_writer = null;
252 m_reader = null;
253
254 try {
255 m_server = config.Configs["IRC"].GetString("server");
256 m_nick = config.Configs["IRC"].GetString("nick");
257 m_channel = config.Configs["IRC"].GetString("channel");
258 m_port = config.Configs["IRC"].GetInt("port", m_port);
259 m_user = config.Configs["IRC"].GetString("username", m_user);
260 if (m_server != null && m_nick != null && m_channel != null) {
261 m_enabled = true;
262 } 263 }
263 } catch (Exception e) {
264 Console.WriteLine("No IRC config information, skipping IRC bridge configuration");
265 } 264 }
266 m_log = OpenSim.Framework.Console.MainLog.Instance;
267 }
268 265
269 public bool Connect(List<Scene> scenes) { 266 if (e.Channel == 0)
270 try {
271 m_scenes = scenes;
272
273 m_tcp = new TcpClient(m_server, m_port);
274 m_log.Verbose("IRC", "Connecting...");
275 m_stream = m_tcp.GetStream();
276 m_log.Verbose("IRC", "Connected to " + m_server);
277 m_reader = new StreamReader(m_stream);
278 m_writer = new StreamWriter(m_stream);
279
280 pingSender = new Thread(new ThreadStart(this.PingRun));
281 pingSender.Start();
282
283 listener = new Thread(new ThreadStart(this.ListenerRun));
284 listener.Start();
285
286 m_writer.WriteLine(m_user);
287 m_writer.Flush();
288 m_writer.WriteLine("NICK " + m_nick);
289 m_writer.Flush();
290 m_writer.WriteLine("JOIN " + m_channel);
291 m_writer.Flush();
292 m_log.Verbose("IRC", "Connection fully established");
293 m_connected = true;
294 } catch (Exception e) {
295 Console.WriteLine(e.ToString());
296 }
297 return m_connected;
298 }
299
300 public bool Enabled
301 {
302 get { return m_enabled; }
303 }
304
305 public bool Connected
306 {
307 get { return m_connected; }
308 }
309
310 public void PrivMsg(string from, string region, string msg) {
311 try {
312 m_writer.WriteLine("PRIVMSG {0} :<{1} in {2}>: {3}", m_channel, from, region, msg);
313 m_writer.Flush();
314 } catch (IOException) {
315 m_log.Error("IRC","Disconnected from IRC server.");
316 listener.Abort();
317 pingSender.Abort();
318 m_connected = false;
319 }
320 }
321
322
323 public void PingRun()
324 {
325 while (true)
326 {
327 m_writer.WriteLine("PING :" + m_server);
328 m_writer.Flush();
329 Thread.Sleep(15000);
330 }
331 }
332
333 public void ListenerRun()
334 {
335 string inputLine;
336 LLVector3 pos = new LLVector3(128, 128, 20);
337 while (true)
338 { 267 {
339 while ((inputLine = m_reader.ReadLine()) != null) 268 foreach (Scene m_scene in m_scenes)
340 { 269 {
341 Console.WriteLine(inputLine); 270 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
342 if (inputLine.Contains(m_channel)) 271 {
343 { 272 int dis = -100000;
344 string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); 273
345 foreach (Scene m_scene in m_scenes) 274 LLVector3 avatarRegionPos = presence.AbsolutePosition + new LLVector3(scene.RegionInfo.RegionLocX * 256, scene.RegionInfo.RegionLocY * 256, 0);
346 { 275 dis = Math.Abs((int)avatarRegionPos.GetDistanceTo(fromRegionPos));
347 m_scene.ForEachScenePresence(delegate(ScenePresence avatar) 276
348 { 277 switch (e.Type)
349 if (!avatar.IsChildAgent) 278 {
350 { 279 case ChatTypeEnum.Whisper:
351 avatar.ControllingClient.SendChatMessage( 280 if (dis < m_whisperdistance)
352 Helpers.StringToField(mess), 255, pos, "IRC:", 281 {
353 LLUUID.Zero); 282 //should change so the message is sent through the avatar rather than direct to the ClientView
283 presence.ControllingClient.SendChatMessage(message,
284 type,
285 fromPos,
286 fromName,
287 fromAgentID);
354 } 288 }
355 }); 289 break;
356 } 290 default:
357 } 291 case ChatTypeEnum.Say:
292 if (dis < m_saydistance)
293 {
294 //Console.WriteLine("sending chat");
295 presence.ControllingClient.SendChatMessage(message,
296 type,
297 fromPos,
298 fromName,
299 fromAgentID);
300 }
301 break;
302 case ChatTypeEnum.Shout:
303 if (dis < m_shoutdistance)
304 {
305 presence.ControllingClient.SendChatMessage(message,
306 type,
307 fromPos,
308 fromName,
309 fromAgentID);
310 }
311 break;
312
313 case ChatTypeEnum.Broadcast:
314 presence.ControllingClient.SendChatMessage(message, type,
315 fromPos,
316 fromName,
317 fromAgentID);
318 break;
319 }
320 });
358 } 321 }
359 Thread.Sleep(50);
360 } 322 }
361 } 323 }
362
363
364 public void Close() {
365 listener.Abort();
366 pingSender.Abort();
367 m_writer.Close();
368 m_reader.Close();
369 m_tcp.Close();
370 }
371 } 324 }
372} 325}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 553e55f..fe2e470 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -370,7 +370,7 @@ namespace OpenSim.Region.Environment.Scenes
370 phyScene.SetTerrain(Terrain.GetHeights1D()); 370 phyScene.SetTerrain(Terrain.GetHeights1D());
371 } 371 }
372 372
373 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); 373 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(),RegionInfo.RegionID);
374 374
375 float[] terData = Terrain.GetHeights1D(); 375 float[] terData = Terrain.GetHeights1D();
376 376
@@ -466,7 +466,7 @@ namespace OpenSim.Region.Environment.Scenes
466 { 466 {
467 try 467 try
468 { 468 {
469 double[,] map = storageManager.DataStore.LoadTerrain(); 469 double[,] map = storageManager.DataStore.LoadTerrain(RegionInfo.RegionID);
470 if (map == null) 470 if (map == null)
471 { 471 {
472 if (string.IsNullOrEmpty(m_regInfo.estateSettings.terrainFile)) 472 if (string.IsNullOrEmpty(m_regInfo.estateSettings.terrainFile))
@@ -474,7 +474,7 @@ namespace OpenSim.Region.Environment.Scenes
474 MainLog.Instance.Verbose("TERRAIN", "No default terrain. Generating a new terrain."); 474 MainLog.Instance.Verbose("TERRAIN", "No default terrain. Generating a new terrain.");
475 Terrain.HillsGenerator(); 475 Terrain.HillsGenerator();
476 476
477 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); 477 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(),RegionInfo.RegionID);
478 } 478 }
479 else 479 else
480 { 480 {
@@ -488,7 +488,7 @@ namespace OpenSim.Region.Environment.Scenes
488 MainLog.Instance.Verbose("TERRAIN", "No terrain found in database or default. Generating a new terrain."); 488 MainLog.Instance.Verbose("TERRAIN", "No terrain found in database or default. Generating a new terrain.");
489 Terrain.HillsGenerator(); 489 Terrain.HillsGenerator();
490 } 490 }
491 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); 491 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID);
492 } 492 }
493 } 493 }
494 else 494 else
diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs
index be27a0b..74bd856 100644
--- a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs
+++ b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs
@@ -69,8 +69,8 @@ namespace OpenSim.Region.ExtensionsScriptModule
69 } 69 }
70 70
71 public void Initialise(Scene scene, IConfigSource config) 71 public void Initialise(Scene scene, IConfigSource config)
72 { 72 {
73 System.Console.WriteLine("Initialising Extensions Scripting Module"); 73 OpenSim.Framework.Console.MainLog.Instance.Verbose("SCRIPTMODULE", "Initialising Extensions Scripting Module");
74 m_scene = scene; 74 m_scene = scene;
75 75
76 m_scene.RegisterModuleInterface<IExtensionScriptModule>(this); 76 m_scene.RegisterModuleInterface<IExtensionScriptModule>(this);
diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
index 87b6d34..81bc938 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
@@ -93,7 +93,7 @@ namespace OpenSim.Region.Physics.Manager
93 IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 93 IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
94 plug.Init(); 94 plug.Init();
95 this._plugins.Add(plug.GetName(),plug); 95 this._plugins.Add(plug.GetName(),plug);
96 Console.WriteLine("added physics engine: " + plug.GetName()); 96 OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS","Added physics engine: " + plug.GetName());
97 97
98 } 98 }
99 99
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
index 733e4c4..cc0ff7a 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
@@ -43,10 +43,12 @@ namespace OpenSim.DataStore.MonoSqlite
43 { 43 {
44 private const string primSelect = "select * from prims"; 44 private const string primSelect = "select * from prims";
45 private const string shapeSelect = "select * from primshapes"; 45 private const string shapeSelect = "select * from primshapes";
46 private const string terrainSelect = "select * from terrain";
46 47
47 private DataSet ds; 48 private DataSet ds;
48 private SqliteDataAdapter primDa; 49 private SqliteDataAdapter primDa;
49 private SqliteDataAdapter shapeDa; 50 private SqliteDataAdapter shapeDa;
51 private SqliteDataAdapter terrainDa;
50 52
51 /*********************************************************************** 53 /***********************************************************************
52 * 54 *
@@ -70,6 +72,8 @@ namespace OpenSim.DataStore.MonoSqlite
70 shapeDa = new SqliteDataAdapter(shapeSelectCmd); 72 shapeDa = new SqliteDataAdapter(shapeSelectCmd);
71 // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); 73 // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa);
72 74
75 SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, conn);
76 terrainDa = new SqliteDataAdapter(terrainSelectCmd);
73 77
74 // We fill the data set, now we've got copies in memory for the information 78 // We fill the data set, now we've got copies in memory for the information
75 // TODO: see if the linkage actually holds. 79 // TODO: see if the linkage actually holds.
@@ -83,6 +87,10 @@ namespace OpenSim.DataStore.MonoSqlite
83 87
84 ds.Tables.Add(createShapeTable()); 88 ds.Tables.Add(createShapeTable());
85 setupShapeCommands(shapeDa, conn); 89 setupShapeCommands(shapeDa, conn);
90
91 ds.Tables.Add(createTerrainTable());
92 setupTerrainCommands(terrainDa, conn);
93 terrainDa.Fill(ds.Tables["terrain"]);
86 94
87 // WORKAROUND: This is a work around for sqlite on 95 // WORKAROUND: This is a work around for sqlite on
88 // windows, which gets really unhappy with blob columns 96 // windows, which gets really unhappy with blob columns
@@ -210,14 +218,57 @@ namespace OpenSim.DataStore.MonoSqlite
210 } 218 }
211 219
212 220
213 public void StoreTerrain(double[,] ter) 221 public void StoreTerrain(double[,] ter, LLUUID regionID)
214 { 222 {
223 int revision = OpenSim.Framework.Utilities.Util.UnixTimeSinceEpoch();
224
225 MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString());
226
227 DataTable terrain = ds.Tables["terrain"];
228
229 DataRow newrow = terrain.NewRow();
230 fillTerrainRow(newrow, regionID, revision, ter);
231 terrain.Rows.Add(newrow);
215 232
233 Commit();
216 } 234 }
217 235
218 public double[,] LoadTerrain() 236 public double[,] LoadTerrain(LLUUID regionID)
219 { 237 {
220 return null; 238 double[,] terret = new double[256, 256];
239 terret.Initialize();
240
241 DataTable terrain = ds.Tables["terrain"];
242
243 DataRow[] rows = terrain.Select("RegionUUID = '" + regionID.ToString() + "'","Revision DESC");
244
245 int rev = 0;
246
247 if (rows.Length > 0)
248 {
249 DataRow row = rows[0];
250
251 byte[] heightmap = (byte[])row["Heightfield"];
252 for (int x = 0; x < 256; x++)
253 {
254 for (int y = 0; y < 256; y++)
255 {
256 terret[x, y] = BitConverter.ToDouble(heightmap, ((x * 256) + y) * 8);
257 }
258 }
259
260 rev = (int)row["Revision"];
261 }
262 else
263 {
264 MainLog.Instance.Verbose("DATASTORE", "No terrain found for region");
265 return null;
266 }
267
268
269 MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString());
270
271 return terret;
221 } 272 }
222 273
223 public void RemoveLandObject(uint id) 274 public void RemoveLandObject(uint id)
@@ -240,6 +291,7 @@ namespace OpenSim.DataStore.MonoSqlite
240 lock (ds) { 291 lock (ds) {
241 primDa.Update(ds, "prims"); 292 primDa.Update(ds, "prims");
242 shapeDa.Update(ds, "primshapes"); 293 shapeDa.Update(ds, "primshapes");
294 terrainDa.Update(ds, "terrain");
243 ds.AcceptChanges(); 295 ds.AcceptChanges();
244 } 296 }
245 } 297 }
@@ -263,6 +315,22 @@ namespace OpenSim.DataStore.MonoSqlite
263 dt.Columns.Add(col); 315 dt.Columns.Add(col);
264 } 316 }
265 317
318 private DataTable createTerrainTable()
319 {
320 DataTable terrain = new DataTable("terrain");
321
322 createCol(terrain, "RegionUUID", typeof(System.String));
323 createCol(terrain, "Revision", typeof(System.Int32));
324 createCol(terrain, "Heightfield", typeof(System.Byte[]));
325
326 /* // Attempting to work out requirements to get SQLite to actually *save* the data.
327 createCol(terrain, "PrIndex", typeof(System.String));
328 terrain.PrimaryKey = new DataColumn[] { terrain.Columns["PrIndex"] };
329 */
330
331 return terrain;
332 }
333
266 private DataTable createPrimTable() 334 private DataTable createPrimTable()
267 { 335 {
268 DataTable prims = new DataTable("prims"); 336 DataTable prims = new DataTable("prims");
@@ -431,6 +499,22 @@ namespace OpenSim.DataStore.MonoSqlite
431 return prim; 499 return prim;
432 } 500 }
433 501
502 private void fillTerrainRow(DataRow row, LLUUID regionUUID, int rev, double[,] val)
503 {
504 row["RegionUUID"] = regionUUID;
505 row["Revision"] = rev;
506
507 System.IO.MemoryStream str = new System.IO.MemoryStream(65536 * sizeof(double));
508 System.IO.BinaryWriter bw = new System.IO.BinaryWriter(str);
509
510 // TODO: COMPATIBILITY - Add byte-order conversions
511 for (int x = 0; x < 256; x++)
512 for (int y = 0; y < 256; y++)
513 bw.Write(val[x, y]);
514
515 row["Heightfield"] = str.ToArray();
516 }
517
434 private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) 518 private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID)
435 { 519 {
436 row["UUID"] = prim.UUID; 520 row["UUID"] = prim.UUID;
@@ -692,7 +776,7 @@ namespace OpenSim.DataStore.MonoSqlite
692 subsql += ",\n"; 776 subsql += ",\n";
693 } 777 }
694 subsql += col.ColumnName + " " + sqliteType(col.DataType); 778 subsql += col.ColumnName + " " + sqliteType(col.DataType);
695 if (col == dt.PrimaryKey[0]) 779 if (dt.PrimaryKey.Length > 0 && col == dt.PrimaryKey[0])
696 { 780 {
697 subsql += " primary key"; 781 subsql += " primary key";
698 } 782 }
@@ -746,6 +830,12 @@ namespace OpenSim.DataStore.MonoSqlite
746 da.DeleteCommand = delete; 830 da.DeleteCommand = delete;
747 } 831 }
748 832
833 private void setupTerrainCommands(SqliteDataAdapter da, SqliteConnection conn)
834 {
835 da.InsertCommand = createInsertCommand("terrain", ds.Tables["terrain"]);
836 da.InsertCommand.Connection = conn;
837 }
838
749 private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn) 839 private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn)
750 { 840 {
751 da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]); 841 da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]);
@@ -764,12 +854,15 @@ namespace OpenSim.DataStore.MonoSqlite
764 { 854 {
765 string createPrims = defineTable(createPrimTable()); 855 string createPrims = defineTable(createPrimTable());
766 string createShapes = defineTable(createShapeTable()); 856 string createShapes = defineTable(createShapeTable());
857 string createTerrain = defineTable(createTerrainTable());
767 858
768 SqliteCommand pcmd = new SqliteCommand(createPrims, conn); 859 SqliteCommand pcmd = new SqliteCommand(createPrims, conn);
769 SqliteCommand scmd = new SqliteCommand(createShapes, conn); 860 SqliteCommand scmd = new SqliteCommand(createShapes, conn);
861 SqliteCommand tcmd = new SqliteCommand(createTerrain, conn);
770 conn.Open(); 862 conn.Open();
771 pcmd.ExecuteNonQuery(); 863 pcmd.ExecuteNonQuery();
772 scmd.ExecuteNonQuery(); 864 scmd.ExecuteNonQuery();
865 tcmd.ExecuteNonQuery();
773 conn.Close(); 866 conn.Close();
774 } 867 }
775 868
@@ -779,12 +872,15 @@ namespace OpenSim.DataStore.MonoSqlite
779 SqliteDataAdapter pDa = new SqliteDataAdapter(primSelectCmd); 872 SqliteDataAdapter pDa = new SqliteDataAdapter(primSelectCmd);
780 SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn); 873 SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn);
781 SqliteDataAdapter sDa = new SqliteDataAdapter(shapeSelectCmd); 874 SqliteDataAdapter sDa = new SqliteDataAdapter(shapeSelectCmd);
875 SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, conn);
876 SqliteDataAdapter tDa = new SqliteDataAdapter(terrainSelectCmd);
782 877
783 DataSet tmpDS = new DataSet(); 878 DataSet tmpDS = new DataSet();
784 try 879 try
785 { 880 {
786 pDa.Fill(tmpDS, "prims"); 881 pDa.Fill(tmpDS, "prims");
787 sDa.Fill(tmpDS, "primshapes"); 882 sDa.Fill(tmpDS, "primshapes");
883 tDa.Fill(tmpDS, "terrain");
788 } 884 }
789 catch (Mono.Data.SqliteClient.SqliteSyntaxException) 885 catch (Mono.Data.SqliteClient.SqliteSyntaxException)
790 { 886 {
@@ -794,6 +890,7 @@ namespace OpenSim.DataStore.MonoSqlite
794 890
795 pDa.Fill(tmpDS, "prims"); 891 pDa.Fill(tmpDS, "prims");
796 sDa.Fill(tmpDS, "primshapes"); 892 sDa.Fill(tmpDS, "primshapes");
893 tDa.Fill(tmpDS, "terrain");
797 894
798 foreach (DataColumn col in createPrimTable().Columns) 895 foreach (DataColumn col in createPrimTable().Columns)
799 { 896 {
@@ -811,6 +908,14 @@ namespace OpenSim.DataStore.MonoSqlite
811 return false; 908 return false;
812 } 909 }
813 } 910 }
911 foreach (DataColumn col in createTerrainTable().Columns)
912 {
913 if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName))
914 {
915 MainLog.Instance.Verbose("DATASTORE", "Missing require column:" + col.ColumnName);
916 return false;
917 }
918 }
814 return true; 919 return true;
815 } 920 }
816 921
@@ -834,6 +939,14 @@ namespace OpenSim.DataStore.MonoSqlite
834 { 939 {
835 return DbType.Double; 940 return DbType.Double;
836 } 941 }
942 else if (type == typeof(System.Byte))
943 {
944 return DbType.Byte;
945 }
946 else if (type == typeof(System.Double))
947 {
948 return DbType.Double;
949 }
837 else if (type == typeof(System.Byte[])) 950 else if (type == typeof(System.Byte[]))
838 { 951 {
839 return DbType.Binary; 952 return DbType.Binary;
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
index 91b1914..f726ea2 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
@@ -61,12 +61,12 @@ namespace OpenSim.DataStore.NullStorage
61 return new List<SceneObjectGroup>(); 61 return new List<SceneObjectGroup>();
62 } 62 }
63 63
64 public void StoreTerrain(double[,] ter) 64 public void StoreTerrain(double[,] ter, LLUUID regionID)
65 { 65 {
66 66
67 } 67 }
68 68
69 public double[,] LoadTerrain() 69 public double[,] LoadTerrain(LLUUID regionID)
70 { 70 {
71 return null; 71 return null;
72 } 72 }