From c3d8f1f4253f72484100394940e62f2912cbc4ff Mon Sep 17 00:00:00 2001
From: Sean Dague
Date: Fri, 5 Oct 2007 15:45:45 +0000
Subject: getting all our line endings consistant again

---
 OpenSim/Framework/Communications/LoginService.cs   |    2 +-
 OpenSim/Framework/General/Culture.cs               |   52 +-
 OpenSim/Grid/ScriptServer/Application.cs           |   64 +-
 .../Grid/ScriptServer/Properties/AssemblyInfo.cs   |   66 +-
 .../ScriptServer/Region/RegionConnectionManager.cs |   32 +-
 .../ScriptServer/ScriptServer/RegionCommManager.cs |  146 +--
 .../ScriptEngineManager/ScriptEngineLoader.cs      |   10 +-
 .../ScriptServer/ScriptEnginesManager.cs           |   82 +-
 OpenSim/Grid/ScriptServer/ScriptServerMain.cs      |   96 +-
 OpenSim/Grid/UserServer/UserLoginService.cs        |  192 ++--
 .../Communications/Local/LocalInventoryService.cs  |  134 +--
 .../Communications/Local/LocalLoginService.cs      |  346 +++---
 .../Communications/OGS1/OGS1InventoryService.cs    |  104 +-
 .../Interfaces/IDynamicTextureManager.cs           |   18 +-
 .../Region/Environment/Interfaces/IHttpRequests.cs |    4 +-
 .../Region/Environment/Interfaces/IRegionModule.cs |    4 +-
 OpenSim/Region/Environment/Interfaces/ISimChat.cs  |    4 +-
 OpenSim/Region/Environment/Interfaces/ITerrain.cs  |   14 +-
 OpenSim/Region/Environment/ModuleLoader.cs         |  310 +++---
 .../Environment/Modules/AssetDownloadModule.cs     |   12 +-
 .../Environment/Modules/AvatarProfilesModule.cs    |   20 +-
 OpenSim/Region/Environment/Modules/ChatModule.cs   |  426 ++++----
 .../Environment/Modules/DynamicTextureModule.cs    |  312 +++---
 .../Region/Environment/Modules/FriendsModule.cs    |    8 +-
 OpenSim/Region/Environment/Modules/GroupsModule.cs |    8 +-
 .../Environment/Modules/InstantMessageModule.cs    |    8 +-
 .../Region/Environment/Modules/InventoryModule.cs  |    8 +-
 .../Environment/Modules/TextureDownloadModule.cs   |   16 +-
 OpenSim/Region/Environment/Modules/XferModule.cs   |   22 +-
 OpenSim/Region/Environment/PermissionManager.cs    |   16 +-
 .../Region/Environment/Scenes/Scene.Inventory.cs   |  890 ++++++++--------
 OpenSim/Region/Environment/Scenes/SceneManager.cs  |  500 ++++-----
 .../Environment/Scenes/Scripting/IScriptHost.cs    |    6 +-
 .../Environment/Scenes/Scripting/NullScriptHost.cs |   24 +-
 .../Region/Environment/Types/BasicQuadTreeNode.cs  |   24 +-
 OpenSim/Region/Environment/Types/UpdateQueue.cs    |   10 +-
 .../Region/ExtensionsScriptModule/ScriptManager.cs |  296 +++---
 .../Physics/OdePlugin/Meshing/Meshmerizer.cs       | 1120 ++++++++++----------
 .../Compiler/Server_API/LSL_BuiltIn_Commands.cs    |  264 ++---
 .../ScriptEngine/DotNetEngine/ScriptManager.cs     |    2 +-
 40 files changed, 2836 insertions(+), 2836 deletions(-)

diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index 06abb69..fddfb17 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -8,7 +8,7 @@ using Nwc.XmlRpc;
 using OpenSim.Framework.Console;
 using OpenSim.Framework.Interfaces;
 using OpenSim.Framework.Inventory;
-using OpenSim.Framework.Types;
+using OpenSim.Framework.Types;
 using OpenSim.Framework.Utilities;
 
 using OpenSim.Framework.Configuration;
diff --git a/OpenSim/Framework/General/Culture.cs b/OpenSim/Framework/General/Culture.cs
index 8f8561b..9e1c846 100644
--- a/OpenSim/Framework/General/Culture.cs
+++ b/OpenSim/Framework/General/Culture.cs
@@ -1,26 +1,26 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Text;
-using System.Threading;
-
-namespace OpenSim.Framework
-{
-    public class Culture
-    {
-        private static readonly CultureInfo m_cultureInfo = new System.Globalization.CultureInfo("en-US", true);
-
-        public static NumberFormatInfo NumberFormatInfo
-        {
-            get
-            {
-                return m_cultureInfo.NumberFormat;
-            }
-        }
-
-        public static void SetCurrentCulture()
-        {
-            Thread.CurrentThread.CurrentCulture = m_cultureInfo;
-        }
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Text;
+using System.Threading;
+
+namespace OpenSim.Framework
+{
+    public class Culture
+    {
+        private static readonly CultureInfo m_cultureInfo = new System.Globalization.CultureInfo("en-US", true);
+
+        public static NumberFormatInfo NumberFormatInfo
+        {
+            get
+            {
+                return m_cultureInfo.NumberFormat;
+            }
+        }
+
+        public static void SetCurrentCulture()
+        {
+            Thread.CurrentThread.CurrentCulture = m_cultureInfo;
+        }
+    }
+}
diff --git a/OpenSim/Grid/ScriptServer/Application.cs b/OpenSim/Grid/ScriptServer/Application.cs
index 780f037..7fc9a53 100644
--- a/OpenSim/Grid/ScriptServer/Application.cs
+++ b/OpenSim/Grid/ScriptServer/Application.cs
@@ -24,35 +24,35 @@
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
-*/
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace OpenSim.Grid.ScriptServer
-{
-    class OpenScript_Main
-    {
-     
-        public static ScriptServerMain SE;
-   
-        static void Main(string[] args)
-        {
-            // Application is starting
-            SE = new ScriptServerMain();
-
-            System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
-        }
-
-        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
-        {
-            Console.WriteLine("");
-            Console.WriteLine("APPLICATION EXCEPTION DETECTED");
-            Console.WriteLine("");
-            Console.WriteLine("Application is terminating: " + e.IsTerminating.ToString());
-            Console.WriteLine("Exception:");
-            Console.WriteLine(e.ExceptionObject.ToString());
-        }
-
-    }
-}
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Grid.ScriptServer
+{
+    class OpenScript_Main
+    {
+     
+        public static ScriptServerMain SE;
+   
+        static void Main(string[] args)
+        {
+            // Application is starting
+            SE = new ScriptServerMain();
+
+            System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
+        }
+
+        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
+        {
+            Console.WriteLine("");
+            Console.WriteLine("APPLICATION EXCEPTION DETECTED");
+            Console.WriteLine("");
+            Console.WriteLine("Application is terminating: " + e.IsTerminating.ToString());
+            Console.WriteLine("Exception:");
+            Console.WriteLine(e.ExceptionObject.ToString());
+        }
+
+    }
+}
diff --git a/OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs
index d60dbb4..63f40d4 100644
--- a/OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs
+++ b/OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs
@@ -1,33 +1,33 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("OpenSim.Grid.ScriptServer")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("OpenSim.Grid.ScriptServer")]
-[assembly: AssemblyCopyright("Copyright ©  2007")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("b6861b87-5203-4040-b756-fd4774932f82")]
-
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version 
-//      Build Number
-//      Revision
-//
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("OpenSim.Grid.ScriptServer")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("OpenSim.Grid.ScriptServer")]
+[assembly: AssemblyCopyright("Copyright ©  2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("b6861b87-5203-4040-b756-fd4774932f82")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs
index 7171b82..e808f82 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs
@@ -1,16 +1,16 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace OpenSim.Grid.ScriptServer
-{
-    // Maintains connection and communication to a region
-    internal class RegionConnectionManager
-    {
-
-        public RegionConnectionManager()
-        {
-        }
-
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Grid.ScriptServer
+{
+    // Maintains connection and communication to a region
+    internal class RegionConnectionManager
+    {
+
+        public RegionConnectionManager()
+        {
+        }
+
+    }
+}
diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs
index d609d63..c6564ad 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs
@@ -24,76 +24,76 @@
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
-*/
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading;
-using OpenSim.Framework.Console;
-
-namespace OpenSim.Grid.ScriptServer
-{
-    // Waiting for incoming script requests from region
-    internal class RegionCommManager
-    {
-        private Thread listenThread;
-
-        private List<RegionConnectionManager> Regions = new List<RegionConnectionManager>();
-
-        private LogBase m_log;
-        private ScriptServerMain m_ScriptServerMain;
-        public RegionCommManager(ScriptServerMain scm, LogBase logger)
-        {
-            m_ScriptServerMain = scm;
-            m_log = logger;
-        }
-        ~RegionCommManager()
-        {
-            Stop();
-        }
-
-        /// <summary>
-        /// Starts listening for region requests
-        /// </summary>
-        public void Start()
-        {
-            // Start listener
-            Stop();
-            listenThread = new Thread(ListenThreadLoop);
-            listenThread.Name = "listenThread";
-            listenThread.IsBackground = true;
-            listenThread.Start();
-        }
-        /// <summary>
-        /// Stops listening for region requests
-        /// </summary>
-        public void Stop()
-        {
-            // Stop listener, clean up
-            if (listenThread != null)
-            {
-                try
-                {
-                    if (listenThread.IsAlive)
-                        listenThread.Abort();
-                    listenThread.Join(1000); // Wait 1 second for thread to shut down
-                }
-                catch { }
-                listenThread = null;
-            }
-        }
-
-        private void ListenThreadLoop()
-        {
-            // * Listen for requests from regions
-            // * When a request is received:
-            //  - Authenticate region
-            //  - Authenticate user
-            //  - Have correct scriptengine load script
-            //   ~ ask scriptengines if they will accept script?
-            //  - Add script to shared communication channel towards that region
-
-        }
-
-    }
-}
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using OpenSim.Framework.Console;
+
+namespace OpenSim.Grid.ScriptServer
+{
+    // Waiting for incoming script requests from region
+    internal class RegionCommManager
+    {
+        private Thread listenThread;
+
+        private List<RegionConnectionManager> Regions = new List<RegionConnectionManager>();
+
+        private LogBase m_log;
+        private ScriptServerMain m_ScriptServerMain;
+        public RegionCommManager(ScriptServerMain scm, LogBase logger)
+        {
+            m_ScriptServerMain = scm;
+            m_log = logger;
+        }
+        ~RegionCommManager()
+        {
+            Stop();
+        }
+
+        /// <summary>
+        /// Starts listening for region requests
+        /// </summary>
+        public void Start()
+        {
+            // Start listener
+            Stop();
+            listenThread = new Thread(ListenThreadLoop);
+            listenThread.Name = "listenThread";
+            listenThread.IsBackground = true;
+            listenThread.Start();
+        }
+        /// <summary>
+        /// Stops listening for region requests
+        /// </summary>
+        public void Stop()
+        {
+            // Stop listener, clean up
+            if (listenThread != null)
+            {
+                try
+                {
+                    if (listenThread.IsAlive)
+                        listenThread.Abort();
+                    listenThread.Join(1000); // Wait 1 second for thread to shut down
+                }
+                catch { }
+                listenThread = null;
+            }
+        }
+
+        private void ListenThreadLoop()
+        {
+            // * Listen for requests from regions
+            // * When a request is received:
+            //  - Authenticate region
+            //  - Authenticate user
+            //  - Have correct scriptengine load script
+            //   ~ ask scriptengines if they will accept script?
+            //  - Add script to shared communication channel towards that region
+
+        }
+
+    }
+}
diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineLoader.cs b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineLoader.cs
index 8b07ab0..a259b1b 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineLoader.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineLoader.cs
@@ -28,8 +28,8 @@
 using System;
 using System.IO;
 using System.Reflection;
-using OpenSim.Framework.Console;
-
+using OpenSim.Framework.Console;
+
 namespace OpenSim.Grid.ScriptServer
 {
     internal class ScriptEngineLoader
@@ -39,7 +39,7 @@ namespace OpenSim.Grid.ScriptServer
 
         public ScriptEngineLoader(LogBase logger)
         {
-            m_log = logger;
+            m_log = logger;
         }
 
         public ScriptEngineInterface LoadScriptEngine(string EngineName)
@@ -121,5 +121,5 @@ namespace OpenSim.Grid.ScriptServer
             return ret;
         }
     }
-}
-
+}
+
diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs
index faa859d..bfcee79 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs
@@ -1,41 +1,41 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using OpenSim.Framework.Console;
-
-namespace OpenSim.Grid.ScriptServer
-{
-    internal class ScriptEngineManager
-    {
-        private LogBase m_log;
-        private ScriptEngineLoader ScriptEngineLoader;
-        private List<ScriptEngineInterface> scriptEngines = new List<ScriptEngineInterface>();
-        private ScriptServerMain m_ScriptServerMain;
-
-        // Initialize
-        public ScriptEngineManager(ScriptServerMain scm, LogBase logger)
-        {
-            m_ScriptServerMain = scm;
-            m_log = logger;
-            ScriptEngineLoader = new ScriptEngineLoader(m_log);
-            
-            // Temp - we should not load during initialize... Loading should be done later.
-            LoadEngine("DotNetScriptEngine");
-        }
-        ~ScriptEngineManager()
-        {
-        }
-
-        public void LoadEngine(string engineName)
-        {
-            // Load and add to list of ScriptEngines
-            ScriptEngineInterface sei = ScriptEngineLoader.LoadScriptEngine(engineName);
-            if (sei != null)
-            {
-                scriptEngines.Add(sei);
-            }
-        }
-
-        
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.Framework.Console;
+
+namespace OpenSim.Grid.ScriptServer
+{
+    internal class ScriptEngineManager
+    {
+        private LogBase m_log;
+        private ScriptEngineLoader ScriptEngineLoader;
+        private List<ScriptEngineInterface> scriptEngines = new List<ScriptEngineInterface>();
+        private ScriptServerMain m_ScriptServerMain;
+
+        // Initialize
+        public ScriptEngineManager(ScriptServerMain scm, LogBase logger)
+        {
+            m_ScriptServerMain = scm;
+            m_log = logger;
+            ScriptEngineLoader = new ScriptEngineLoader(m_log);
+            
+            // Temp - we should not load during initialize... Loading should be done later.
+            LoadEngine("DotNetScriptEngine");
+        }
+        ~ScriptEngineManager()
+        {
+        }
+
+        public void LoadEngine(string engineName)
+        {
+            // Load and add to list of ScriptEngines
+            ScriptEngineInterface sei = ScriptEngineLoader.LoadScriptEngine(engineName);
+            if (sei != null)
+            {
+                scriptEngines.Add(sei);
+            }
+        }
+
+        
+    }
+}
diff --git a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
index 8352859..37541c9 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
@@ -1,48 +1,48 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using OpenSim.Framework.Console;
-using OpenSim.Framework.Utilities;
-
-namespace OpenSim.Grid.ScriptServer
-{
-    public class ScriptServerMain : conscmd_callback
-    {
-        private readonly string m_logFilename = ("region-console.log");
-        internal RegionCommManager RegionScriptDaemon;           // Listen for incoming from region
-        internal ScriptEngineManager ScriptEngines;           // Loads scriptengines
-        private LogBase m_log;
-
-        public ScriptServerMain()
-        {
-            m_log = CreateLog();
-
-            RegionScriptDaemon = new RegionCommManager(this, m_log);
-            ScriptEngines = new ScriptEngineManager(this, m_log);
-            
-        }
-
-        ~ScriptServerMain()
-        {
-        }
-
-        protected LogBase CreateLog()
-        {
-            if (!Directory.Exists(Util.logDir()))
-            {
-                Directory.CreateDirectory(Util.logDir());
-            }
-
-            return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "Region", this, false);
-        }
-
-        public void RunCmd(string command, string[] cmdparams)
-        {
-        }
-        public void Show(string ShowWhat)
-        {
-        }
-
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+using OpenSim.Framework.Console;
+using OpenSim.Framework.Utilities;
+
+namespace OpenSim.Grid.ScriptServer
+{
+    public class ScriptServerMain : conscmd_callback
+    {
+        private readonly string m_logFilename = ("region-console.log");
+        internal RegionCommManager RegionScriptDaemon;           // Listen for incoming from region
+        internal ScriptEngineManager ScriptEngines;           // Loads scriptengines
+        private LogBase m_log;
+
+        public ScriptServerMain()
+        {
+            m_log = CreateLog();
+
+            RegionScriptDaemon = new RegionCommManager(this, m_log);
+            ScriptEngines = new ScriptEngineManager(this, m_log);
+            
+        }
+
+        ~ScriptServerMain()
+        {
+        }
+
+        protected LogBase CreateLog()
+        {
+            if (!Directory.Exists(Util.logDir()))
+            {
+                Directory.CreateDirectory(Util.logDir());
+            }
+
+            return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "Region", this, false);
+        }
+
+        public void RunCmd(string command, string[] cmdparams)
+        {
+        }
+        public void Show(string ShowWhat)
+        {
+        }
+
+    }
+}
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index b42427b..e18191f 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -1,96 +1,96 @@
-using System;
-using System.Collections;
-using System.Net;
-using Nwc.XmlRpc;
-using OpenSim.Framework.Data;
-using OpenSim.Framework.UserManagement;
-using OpenSim.Framework.Utilities;
-using OpenSim.Framework.Configuration;
-using OpenSim.Framework.Types;
-
-namespace OpenSim.Grid.UserServer
-{
-    public class UserLoginService : LoginService
-    {
-        public UserConfig m_config;
-
-        public UserLoginService(UserManagerBase userManager, UserConfig config, string welcomeMess)
-            : base(userManager, welcomeMess)
-        {
-            m_config = config;
-        }
-
-        /// <summary>
-        /// Customises the login response and fills in missing values.
-        /// </summary>
-        /// <param name="response">The existing response</param>
-        /// <param name="theUser">The user profile</param>
-        public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
-        {
-            // Load information from the gridserver
-            SimProfileData SimInfo = new SimProfileData();
-            SimInfo = SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
-
-            // Customise the response
-            // Home Location
-            response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + (SimInfo.regionLocY * 256).ToString() + "], " +
-                "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
-                "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
-
-            // Destination
-            Console.WriteLine("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY);
-            response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
-            response.SimPort = (Int32)SimInfo.serverPort;
-            response.RegionX = SimInfo.regionLocX;
-            response.RegionY = SimInfo.regionLocY;
-
-            //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
-            string capsPath = Util.GetRandomCapsPath();
-            response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
-
-            // Notify the target of an incoming user
-            Console.WriteLine("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
-
-            // Prepare notification
-            Hashtable SimParams = new Hashtable();
-            SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
-            SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
-            SimParams["firstname"] = theUser.username;
-            SimParams["lastname"] = theUser.surname;
-            SimParams["agent_id"] = theUser.UUID.ToString();
-            SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode);
-            SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
-            SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
-            SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
-            SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
-            SimParams["caps_path"] = capsPath;
-            ArrayList SendParams = new ArrayList();
-            SendParams.Add(SimParams);
-
-            // Update agent with target sim
-            theUser.currentAgent.currentRegion = SimInfo.UUID;
-            theUser.currentAgent.currentHandle = SimInfo.regionHandle;
-
-            System.Console.WriteLine("Informing region --> " + SimInfo.httpServerURI);
-            // Send
-            try
-            {
-                XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
-                XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
-            }
-            catch( WebException e )
-            {
-                switch( e.Status )
-                {
-                    case WebExceptionStatus.Timeout:
-                        //TODO: Send him to nearby or default region instead
-                        break;
-                       
-                    default:
-                        throw;
-                }
-            }
-        }
-    }
-}
-
+using System;
+using System.Collections;
+using System.Net;
+using Nwc.XmlRpc;
+using OpenSim.Framework.Data;
+using OpenSim.Framework.UserManagement;
+using OpenSim.Framework.Utilities;
+using OpenSim.Framework.Configuration;
+using OpenSim.Framework.Types;
+
+namespace OpenSim.Grid.UserServer
+{
+    public class UserLoginService : LoginService
+    {
+        public UserConfig m_config;
+
+        public UserLoginService(UserManagerBase userManager, UserConfig config, string welcomeMess)
+            : base(userManager, welcomeMess)
+        {
+            m_config = config;
+        }
+
+        /// <summary>
+        /// Customises the login response and fills in missing values.
+        /// </summary>
+        /// <param name="response">The existing response</param>
+        /// <param name="theUser">The user profile</param>
+        public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
+        {
+            // Load information from the gridserver
+            SimProfileData SimInfo = new SimProfileData();
+            SimInfo = SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
+
+            // Customise the response
+            // Home Location
+            response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + (SimInfo.regionLocY * 256).ToString() + "], " +
+                "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
+                "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
+
+            // Destination
+            Console.WriteLine("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY);
+            response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
+            response.SimPort = (Int32)SimInfo.serverPort;
+            response.RegionX = SimInfo.regionLocX;
+            response.RegionY = SimInfo.regionLocY;
+
+            //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
+            string capsPath = Util.GetRandomCapsPath();
+            response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
+
+            // Notify the target of an incoming user
+            Console.WriteLine("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
+
+            // Prepare notification
+            Hashtable SimParams = new Hashtable();
+            SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
+            SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
+            SimParams["firstname"] = theUser.username;
+            SimParams["lastname"] = theUser.surname;
+            SimParams["agent_id"] = theUser.UUID.ToString();
+            SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode);
+            SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
+            SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
+            SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
+            SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
+            SimParams["caps_path"] = capsPath;
+            ArrayList SendParams = new ArrayList();
+            SendParams.Add(SimParams);
+
+            // Update agent with target sim
+            theUser.currentAgent.currentRegion = SimInfo.UUID;
+            theUser.currentAgent.currentHandle = SimInfo.regionHandle;
+
+            System.Console.WriteLine("Informing region --> " + SimInfo.httpServerURI);
+            // Send
+            try
+            {
+                XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
+                XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
+            }
+            catch( WebException e )
+            {
+                switch( e.Status )
+                {
+                    case WebExceptionStatus.Timeout:
+                        //TODO: Send him to nearby or default region instead
+                        break;
+                       
+                    default:
+                        throw;
+                }
+            }
+        }
+    }
+}
+
diff --git a/OpenSim/Region/Communications/Local/LocalInventoryService.cs b/OpenSim/Region/Communications/Local/LocalInventoryService.cs
index dc91663..1f5b298 100644
--- a/OpenSim/Region/Communications/Local/LocalInventoryService.cs
+++ b/OpenSim/Region/Communications/Local/LocalInventoryService.cs
@@ -1,67 +1,67 @@
-using System.Collections.Generic;
-using libsecondlife;
-using OpenSim.Framework.Communications;
-using OpenSim.Framework.Types;
-using InventoryFolder=OpenSim.Framework.Communications.Caches.InventoryFolder;
-
-namespace OpenSim.Region.Communications.Local
-{
-    public class LocalInventoryService : InventoryServiceBase
-    {
-
-        public LocalInventoryService()
-        {
-
-        }
-
-        public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack)
-        {
-            List<InventoryFolderBase> folders = this.RequestFirstLevelFolders(userID);
-            InventoryFolder rootFolder = null;
-
-            //need to make sure we send root folder first
-            foreach (InventoryFolderBase folder in folders)
-            {
-                if (folder.parentID == libsecondlife.LLUUID.Zero)
-                {
-                    InventoryFolder newfolder = new InventoryFolder(folder);
-                    rootFolder = newfolder;
-                    folderCallBack(userID, newfolder);
-                }
-            }
-
-            if (rootFolder != null)
-            {
-                foreach (InventoryFolderBase folder in folders)
-                {
-                    if (folder.folderID != rootFolder.folderID)
-                    {
-                        InventoryFolder newfolder = new InventoryFolder(folder);
-                        folderCallBack(userID, newfolder);
-
-                        List<InventoryItemBase> items = this.RequestFolderItems(newfolder.folderID);
-                        foreach (InventoryItemBase item in items)
-                        {
-                            itemCallBack(userID, item);
-                        }
-                    }
-                }
-            }
-        }
-
-        public override void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder)
-        {
-            this.AddFolder(folder);
-        }
-
-        public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
-        {
-            this.AddItem(item);
-        }
-
-        public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
-        {
-            this.deleteItem(item);
-        }
-    }
-}
+using System.Collections.Generic;
+using libsecondlife;
+using OpenSim.Framework.Communications;
+using OpenSim.Framework.Types;
+using InventoryFolder=OpenSim.Framework.Communications.Caches.InventoryFolder;
+
+namespace OpenSim.Region.Communications.Local
+{
+    public class LocalInventoryService : InventoryServiceBase
+    {
+
+        public LocalInventoryService()
+        {
+
+        }
+
+        public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack)
+        {
+            List<InventoryFolderBase> folders = this.RequestFirstLevelFolders(userID);
+            InventoryFolder rootFolder = null;
+
+            //need to make sure we send root folder first
+            foreach (InventoryFolderBase folder in folders)
+            {
+                if (folder.parentID == libsecondlife.LLUUID.Zero)
+                {
+                    InventoryFolder newfolder = new InventoryFolder(folder);
+                    rootFolder = newfolder;
+                    folderCallBack(userID, newfolder);
+                }
+            }
+
+            if (rootFolder != null)
+            {
+                foreach (InventoryFolderBase folder in folders)
+                {
+                    if (folder.folderID != rootFolder.folderID)
+                    {
+                        InventoryFolder newfolder = new InventoryFolder(folder);
+                        folderCallBack(userID, newfolder);
+
+                        List<InventoryItemBase> items = this.RequestFolderItems(newfolder.folderID);
+                        foreach (InventoryItemBase item in items)
+                        {
+                            itemCallBack(userID, item);
+                        }
+                    }
+                }
+            }
+        }
+
+        public override void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder)
+        {
+            this.AddFolder(folder);
+        }
+
+        public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
+        {
+            this.AddItem(item);
+        }
+
+        public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
+        {
+            this.deleteItem(item);
+        }
+    }
+}
diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs
index 6829598..6ad39b0 100644
--- a/OpenSim/Region/Communications/Local/LocalLoginService.cs
+++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs
@@ -1,173 +1,173 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using libsecondlife;
-using OpenSim.Framework.Communications;
-using OpenSim.Framework.Types;
-using OpenSim.Framework.UserManagement;
-using OpenSim.Framework.Utilities;
-using OpenSim.Framework.Inventory;
-
-namespace OpenSim.Region.Communications.Local
-{
-    public delegate void LoginToRegionEvent(ulong regionHandle, Login login);
-
-    public class LocalLoginService : LoginService
-    {
-        private CommunicationsLocal m_Parent;
-
-        private NetworkServersInfo serversInfo;
-        private uint defaultHomeX;
-        private uint defaultHomeY;
-        private bool authUsers = false;
-
-        public event LoginToRegionEvent OnLoginToRegion;
-
-        public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate)
-            : base(userManager, welcomeMess)
-        {
-            m_Parent = parent;
-            this.serversInfo = serversInfo;
-            defaultHomeX = this.serversInfo.DefaultHomeLocX;
-            defaultHomeY = this.serversInfo.DefaultHomeLocY;
-            this.authUsers = authenticate;
-        }
-
-
-        public override UserProfileData GetTheUser(string firstname, string lastname)
-        {
-            UserProfileData profile = this.m_userManager.GetUserProfile(firstname, lastname);
-            if (profile != null)
-            {
-
-                return profile;
-            }
-
-            if (!authUsers)
-            {
-                //no current user account so make one
-                Console.WriteLine("No User account found so creating a new one ");
-                this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
-
-                profile = this.m_userManager.GetUserProfile(firstname, lastname);
-                if (profile != null)
-                {
-                    m_Parent.InventoryService.CreateNewUserInventory(profile.UUID);
-                }
-
-                return profile;
-            }
-            return null;
-        }
-
-        public override bool AuthenticateUser(UserProfileData profile, string password)
-        {
-            if (!authUsers)
-            {
-                //for now we will accept any password in sandbox mode
-                Console.WriteLine("authorising user");
-                return true;
-            }
-            else
-            {
-                Console.WriteLine("Authenticating " + profile.username + " " + profile.surname);
-
-                password = password.Remove(0, 3); //remove $1$
-
-                string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
-
-                return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
-            }
-        }
-
-        public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
-        {
-            ulong currentRegion = theUser.currentAgent.currentHandle;
-            RegionInfo reg = m_Parent.GridService.RequestNeighbourInfo(currentRegion);
-
-            if (reg != null)
-            {
-                response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
-                 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
-                 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
-                string capsPath = Util.GetRandomCapsPath();
-                response.SimAddress = reg.ExternalEndPoint.Address.ToString();
-                response.SimPort = (Int32)reg.ExternalEndPoint.Port;
-                response.RegionX = reg.RegionLocX;
-                response.RegionY = reg.RegionLocY;
-                
-
-                response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/";
-               // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/";
-                theUser.currentAgent.currentRegion = reg.SimUUID;
-                theUser.currentAgent.currentHandle = reg.RegionHandle;
-
-                Login _login = new Login();
-                //copy data to login object
-                _login.First = response.Firstname;
-                _login.Last = response.Lastname;
-                _login.Agent = response.AgentID;
-                _login.Session = response.SessionID;
-                _login.SecureSession = response.SecureSessionID;
-                _login.CircuitCode = (uint)response.CircuitCode;
-                _login.CapsPath = capsPath;
-
-                if( OnLoginToRegion != null )
-                {
-                    OnLoginToRegion(currentRegion, _login);
-                }
-            }
-            else
-            {
-                Console.WriteLine("not found region " + currentRegion);
-            }
-
-        }
-
-        protected override InventoryData CreateInventoryData(LLUUID userID)
-        {
-            List<InventoryFolderBase> folders = m_Parent.InventoryService.RequestFirstLevelFolders(userID);
-            if (folders.Count > 0)
-            {
-                LLUUID rootID = LLUUID.Zero;
-                ArrayList AgentInventoryArray = new ArrayList();
-                Hashtable TempHash;
-                foreach (InventoryFolderBase InvFolder in folders)
-                {
-                    if (InvFolder.parentID == LLUUID.Zero)
-                    {
-                        rootID = InvFolder.folderID;
-                    }
-                    TempHash = new Hashtable();
-                    TempHash["name"] = InvFolder.name;
-                    TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated();
-                    TempHash["version"] = (Int32)InvFolder.version;
-                    TempHash["type_default"] = (Int32)InvFolder.type;
-                    TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated();
-                    AgentInventoryArray.Add(TempHash);
-                }
-                return new InventoryData(AgentInventoryArray, rootID);
-            }
-            else
-            {
-                AgentInventory userInventory = new AgentInventory();
-                userInventory.CreateRootFolder(userID, false);
-
-                ArrayList AgentInventoryArray = new ArrayList();
-                Hashtable TempHash;
-                foreach (OpenSim.Framework.Inventory.InventoryFolder InvFolder in userInventory.InventoryFolders.Values)
-                {
-                    TempHash = new Hashtable();
-                    TempHash["name"] = InvFolder.FolderName;
-                    TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
-                    TempHash["version"] = (Int32)InvFolder.Version;
-                    TempHash["type_default"] = (Int32)InvFolder.DefaultType;
-                    TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
-                    AgentInventoryArray.Add(TempHash);
-                }
-
-                return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID);
-            }
-        }
-    }
-}
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using libsecondlife;
+using OpenSim.Framework.Communications;
+using OpenSim.Framework.Types;
+using OpenSim.Framework.UserManagement;
+using OpenSim.Framework.Utilities;
+using OpenSim.Framework.Inventory;
+
+namespace OpenSim.Region.Communications.Local
+{
+    public delegate void LoginToRegionEvent(ulong regionHandle, Login login);
+
+    public class LocalLoginService : LoginService
+    {
+        private CommunicationsLocal m_Parent;
+
+        private NetworkServersInfo serversInfo;
+        private uint defaultHomeX;
+        private uint defaultHomeY;
+        private bool authUsers = false;
+
+        public event LoginToRegionEvent OnLoginToRegion;
+
+        public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate)
+            : base(userManager, welcomeMess)
+        {
+            m_Parent = parent;
+            this.serversInfo = serversInfo;
+            defaultHomeX = this.serversInfo.DefaultHomeLocX;
+            defaultHomeY = this.serversInfo.DefaultHomeLocY;
+            this.authUsers = authenticate;
+        }
+
+
+        public override UserProfileData GetTheUser(string firstname, string lastname)
+        {
+            UserProfileData profile = this.m_userManager.GetUserProfile(firstname, lastname);
+            if (profile != null)
+            {
+
+                return profile;
+            }
+
+            if (!authUsers)
+            {
+                //no current user account so make one
+                Console.WriteLine("No User account found so creating a new one ");
+                this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
+
+                profile = this.m_userManager.GetUserProfile(firstname, lastname);
+                if (profile != null)
+                {
+                    m_Parent.InventoryService.CreateNewUserInventory(profile.UUID);
+                }
+
+                return profile;
+            }
+            return null;
+        }
+
+        public override bool AuthenticateUser(UserProfileData profile, string password)
+        {
+            if (!authUsers)
+            {
+                //for now we will accept any password in sandbox mode
+                Console.WriteLine("authorising user");
+                return true;
+            }
+            else
+            {
+                Console.WriteLine("Authenticating " + profile.username + " " + profile.surname);
+
+                password = password.Remove(0, 3); //remove $1$
+
+                string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
+
+                return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
+            }
+        }
+
+        public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
+        {
+            ulong currentRegion = theUser.currentAgent.currentHandle;
+            RegionInfo reg = m_Parent.GridService.RequestNeighbourInfo(currentRegion);
+
+            if (reg != null)
+            {
+                response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
+                 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
+                 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
+                string capsPath = Util.GetRandomCapsPath();
+                response.SimAddress = reg.ExternalEndPoint.Address.ToString();
+                response.SimPort = (Int32)reg.ExternalEndPoint.Port;
+                response.RegionX = reg.RegionLocX;
+                response.RegionY = reg.RegionLocY;
+                
+
+                response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/";
+               // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/";
+                theUser.currentAgent.currentRegion = reg.SimUUID;
+                theUser.currentAgent.currentHandle = reg.RegionHandle;
+
+                Login _login = new Login();
+                //copy data to login object
+                _login.First = response.Firstname;
+                _login.Last = response.Lastname;
+                _login.Agent = response.AgentID;
+                _login.Session = response.SessionID;
+                _login.SecureSession = response.SecureSessionID;
+                _login.CircuitCode = (uint)response.CircuitCode;
+                _login.CapsPath = capsPath;
+
+                if( OnLoginToRegion != null )
+                {
+                    OnLoginToRegion(currentRegion, _login);
+                }
+            }
+            else
+            {
+                Console.WriteLine("not found region " + currentRegion);
+            }
+
+        }
+
+        protected override InventoryData CreateInventoryData(LLUUID userID)
+        {
+            List<InventoryFolderBase> folders = m_Parent.InventoryService.RequestFirstLevelFolders(userID);
+            if (folders.Count > 0)
+            {
+                LLUUID rootID = LLUUID.Zero;
+                ArrayList AgentInventoryArray = new ArrayList();
+                Hashtable TempHash;
+                foreach (InventoryFolderBase InvFolder in folders)
+                {
+                    if (InvFolder.parentID == LLUUID.Zero)
+                    {
+                        rootID = InvFolder.folderID;
+                    }
+                    TempHash = new Hashtable();
+                    TempHash["name"] = InvFolder.name;
+                    TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated();
+                    TempHash["version"] = (Int32)InvFolder.version;
+                    TempHash["type_default"] = (Int32)InvFolder.type;
+                    TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated();
+                    AgentInventoryArray.Add(TempHash);
+                }
+                return new InventoryData(AgentInventoryArray, rootID);
+            }
+            else
+            {
+                AgentInventory userInventory = new AgentInventory();
+                userInventory.CreateRootFolder(userID, false);
+
+                ArrayList AgentInventoryArray = new ArrayList();
+                Hashtable TempHash;
+                foreach (OpenSim.Framework.Inventory.InventoryFolder InvFolder in userInventory.InventoryFolders.Values)
+                {
+                    TempHash = new Hashtable();
+                    TempHash["name"] = InvFolder.FolderName;
+                    TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
+                    TempHash["version"] = (Int32)InvFolder.Version;
+                    TempHash["type_default"] = (Int32)InvFolder.DefaultType;
+                    TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
+                    AgentInventoryArray.Add(TempHash);
+                }
+
+                return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID);
+            }
+        }
+    }
+}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
index f364771..56e1740 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
@@ -1,52 +1,52 @@
-using System.Collections.Generic;
-using libsecondlife;
-using OpenSim.Framework.Communications;
-using OpenSim.Framework.Types;
-using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder;
-
-
-namespace OpenSim.Region.Communications.OGS1
-{
-    public class OGS1InventoryService : IInventoryServices
-    {
-
-        public OGS1InventoryService()
-        {
-
-        }
-
-        #region IInventoryServices Members
-       
-        public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack)
-        {
-            
-        }
-
-        public void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder)
-        {
-            
-        }
-
-        public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
-        {
-            
-        }
-
-        public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
-        {
-            
-        }
-
-        public void CreateNewUserInventory(LLUUID user)
-        {
-            
-        }
-
-        public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID)
-        {
-            return new List<InventoryFolderBase>();
-        }
-
-        #endregion
-    }
-}
+using System.Collections.Generic;
+using libsecondlife;
+using OpenSim.Framework.Communications;
+using OpenSim.Framework.Types;
+using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder;
+
+
+namespace OpenSim.Region.Communications.OGS1
+{
+    public class OGS1InventoryService : IInventoryServices
+    {
+
+        public OGS1InventoryService()
+        {
+
+        }
+
+        #region IInventoryServices Members
+       
+        public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack)
+        {
+            
+        }
+
+        public void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder)
+        {
+            
+        }
+
+        public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
+        {
+            
+        }
+
+        public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
+        {
+            
+        }
+
+        public void CreateNewUserInventory(LLUUID user)
+        {
+            
+        }
+
+        public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID)
+        {
+            return new List<InventoryFolderBase>();
+        }
+
+        #endregion
+    }
+}
diff --git a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs
index 05cecf8..e91240a 100644
--- a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs
+++ b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs
@@ -1,17 +1,17 @@
-using System.IO;
-using libsecondlife;
-
+using System.IO;
+using libsecondlife;
+
 namespace OpenSim.Region.Environment.Interfaces
 {
     public interface IDynamicTextureManager
     {
         void RegisterRender(string handleType, IDynamicTextureRender render);
-        void ReturnData(LLUUID id, byte[] data);
-
-        LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams,
-                                    int updateTimer);
-
-        LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams,
+        void ReturnData(LLUUID id, byte[] data);
+
+        LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams,
+                                    int updateTimer);
+
+        LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams,
                                      int updateTimer);
     }
 
diff --git a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs
index cb00b48..49b96d0 100644
--- a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs
+++ b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs
@@ -1,5 +1,5 @@
-using libsecondlife;
-
+using libsecondlife;
+
 namespace OpenSim.Region.Environment.Interfaces
 {
     public interface IHttpRequests
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs
index 981b73f..2c7c742 100644
--- a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs
+++ b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs
@@ -1,5 +1,5 @@
-using OpenSim.Region.Environment.Scenes;
-
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment.Interfaces
 {
     public interface IRegionModule
diff --git a/OpenSim/Region/Environment/Interfaces/ISimChat.cs b/OpenSim/Region/Environment/Interfaces/ISimChat.cs
index 5aa78ab..36ff1ad 100644
--- a/OpenSim/Region/Environment/Interfaces/ISimChat.cs
+++ b/OpenSim/Region/Environment/Interfaces/ISimChat.cs
@@ -1,5 +1,5 @@
-using libsecondlife;
-
+using libsecondlife;
+
 namespace OpenSim.Region.Environment.Interfaces
 {
     public interface ISimChat
diff --git a/OpenSim/Region/Environment/Interfaces/ITerrain.cs b/OpenSim/Region/Environment/Interfaces/ITerrain.cs
index f9ff71a..3d0169a 100644
--- a/OpenSim/Region/Environment/Interfaces/ITerrain.cs
+++ b/OpenSim/Region/Environment/Interfaces/ITerrain.cs
@@ -1,16 +1,16 @@
-using OpenSim.Framework.Interfaces;
-
+using OpenSim.Framework.Interfaces;
+
 namespace OpenSim.Region.Environment.Interfaces
 {
     public interface ITerrain
     {
         bool Tainted();
         bool Tainted(int x, int y);
-        void ResetTaint();
-
-        void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west,
-                           IClientAPI remoteUser);
-
+        void ResetTaint();
+
+        void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west,
+                           IClientAPI remoteUser);
+
         void CheckHeightValues();
         float[] GetHeights1D();
         float[,] GetHeights2D();
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs
index 2b18949..ce2a843 100644
--- a/OpenSim/Region/Environment/ModuleLoader.cs
+++ b/OpenSim/Region/Environment/ModuleLoader.cs
@@ -1,156 +1,156 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Modules;
-using OpenSim.Region.Environment.Scenes;
-
-namespace OpenSim.Region.Environment
-{
-    public class ModuleLoader
-    {
-        public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
-
-        public List<IRegionModule> LoadedModules = new List<IRegionModule>();
-        public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>();
-
-        public ModuleLoader()
-        {
-        }
-
-        /// <summary>
-        /// Should have a module factory?
-        /// </summary>
-        /// <param name="scene"></param>
-        public void CreateDefaultModules(Scene scene, string exceptModules)
-        {
-            IRegionModule module = new XferModule();
-            InitialiseModule(module, scene);
-
-            module = new ChatModule();
-            InitialiseModule(module, scene);
-
-            module = new AvatarProfilesModule();
-            InitialiseModule(module, scene);
-
-            LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene);
-
-            string lslPath = Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
-            LoadRegionModule(lslPath, "LSLScriptingModule", scene);
-        }
-
-
-        public void LoadDefaultSharedModules(string exceptModules)
-        {
-            DynamicTextureModule dynamicModule = new DynamicTextureModule();
-            LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule);
-        }
-
-        public void InitialiseSharedModules(Scene scene)
-        {
-            foreach (IRegionModule module in LoadedSharedModules.Values)
-            {
-                module.Initialise(scene);
-                scene.AddModule(module.GetName(), module); //should be doing this?
-            }
-        }
-
-        private void InitialiseModule(IRegionModule module, Scene scene)
-        {
-            module.Initialise(scene);
-            scene.AddModule(module.GetName(), module);
-            LoadedModules.Add(module);
-        }
-
-        /// <summary>
-        ///  Loads/initialises a Module instance that can be used by mutliple Regions
-        /// </summary>
-        /// <param name="dllName"></param>
-        /// <param name="moduleName"></param>
-        /// <param name="scene"></param>
-        public void LoadSharedModule(string dllName, string moduleName)
-        {
-            IRegionModule module = LoadModule(dllName, moduleName);
-            if (module != null)
-            {
-                LoadedSharedModules.Add(module.GetName(), module);
-            }
-        }
-
-        public void LoadRegionModule(string dllName, string moduleName, Scene scene)
-        {
-            IRegionModule module = LoadModule(dllName, moduleName);
-            if (module != null)
-            {
-                InitialiseModule(module, scene);
-            }
-        }
-
-        /// <summary>
-        /// Loads a external Module (if not already loaded) and creates a new instance of it.
-        /// </summary>
-        /// <param name="dllName"></param>
-        /// <param name="moduleName"></param>
-        /// <param name="scene"></param>
-        public IRegionModule LoadModule(string dllName, string moduleName)
-        {
-            Assembly pluginAssembly = null;
-            if (LoadedAssemblys.ContainsKey(dllName))
-            {
-                pluginAssembly = LoadedAssemblys[dllName];
-            }
-            else
-            {
-                pluginAssembly = Assembly.LoadFrom(dllName);
-                LoadedAssemblys.Add(dllName, pluginAssembly);
-            }
-
-            IRegionModule module = null;
-            foreach (Type pluginType in pluginAssembly.GetTypes())
-            {
-                if (pluginType.IsPublic)
-                {
-                    if (!pluginType.IsAbstract)
-                    {
-                        Type typeInterface = pluginType.GetInterface("IRegionModule", true);
-
-                        if (typeInterface != null)
-                        {
-                            module =
-                                (IRegionModule) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
-                            break;
-                        }
-                        typeInterface = null;
-                    }
-                }
-            }
-            pluginAssembly = null;
-
-            if ((module != null) || (module.GetName() == moduleName))
-            {
-                return module;
-            }
-
-            return null;
-        }
-
-        public void PostInitialise()
-        {
-            foreach (IRegionModule module in LoadedSharedModules.Values)
-            {
-                module.PostInitialise();
-            }
-
-            foreach (IRegionModule module in LoadedModules)
-            {
-                module.PostInitialise();
-            }
-        }
-
-        public void ClearCache()
-        {
-            LoadedAssemblys.Clear();
-        }
-    }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Modules;
+using OpenSim.Region.Environment.Scenes;
+
+namespace OpenSim.Region.Environment
+{
+    public class ModuleLoader
+    {
+        public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
+
+        public List<IRegionModule> LoadedModules = new List<IRegionModule>();
+        public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>();
+
+        public ModuleLoader()
+        {
+        }
+
+        /// <summary>
+        /// Should have a module factory?
+        /// </summary>
+        /// <param name="scene"></param>
+        public void CreateDefaultModules(Scene scene, string exceptModules)
+        {
+            IRegionModule module = new XferModule();
+            InitialiseModule(module, scene);
+
+            module = new ChatModule();
+            InitialiseModule(module, scene);
+
+            module = new AvatarProfilesModule();
+            InitialiseModule(module, scene);
+
+            LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene);
+
+            string lslPath = Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
+            LoadRegionModule(lslPath, "LSLScriptingModule", scene);
+        }
+
+
+        public void LoadDefaultSharedModules(string exceptModules)
+        {
+            DynamicTextureModule dynamicModule = new DynamicTextureModule();
+            LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule);
+        }
+
+        public void InitialiseSharedModules(Scene scene)
+        {
+            foreach (IRegionModule module in LoadedSharedModules.Values)
+            {
+                module.Initialise(scene);
+                scene.AddModule(module.GetName(), module); //should be doing this?
+            }
+        }
+
+        private void InitialiseModule(IRegionModule module, Scene scene)
+        {
+            module.Initialise(scene);
+            scene.AddModule(module.GetName(), module);
+            LoadedModules.Add(module);
+        }
+
+        /// <summary>
+        ///  Loads/initialises a Module instance that can be used by mutliple Regions
+        /// </summary>
+        /// <param name="dllName"></param>
+        /// <param name="moduleName"></param>
+        /// <param name="scene"></param>
+        public void LoadSharedModule(string dllName, string moduleName)
+        {
+            IRegionModule module = LoadModule(dllName, moduleName);
+            if (module != null)
+            {
+                LoadedSharedModules.Add(module.GetName(), module);
+            }
+        }
+
+        public void LoadRegionModule(string dllName, string moduleName, Scene scene)
+        {
+            IRegionModule module = LoadModule(dllName, moduleName);
+            if (module != null)
+            {
+                InitialiseModule(module, scene);
+            }
+        }
+
+        /// <summary>
+        /// Loads a external Module (if not already loaded) and creates a new instance of it.
+        /// </summary>
+        /// <param name="dllName"></param>
+        /// <param name="moduleName"></param>
+        /// <param name="scene"></param>
+        public IRegionModule LoadModule(string dllName, string moduleName)
+        {
+            Assembly pluginAssembly = null;
+            if (LoadedAssemblys.ContainsKey(dllName))
+            {
+                pluginAssembly = LoadedAssemblys[dllName];
+            }
+            else
+            {
+                pluginAssembly = Assembly.LoadFrom(dllName);
+                LoadedAssemblys.Add(dllName, pluginAssembly);
+            }
+
+            IRegionModule module = null;
+            foreach (Type pluginType in pluginAssembly.GetTypes())
+            {
+                if (pluginType.IsPublic)
+                {
+                    if (!pluginType.IsAbstract)
+                    {
+                        Type typeInterface = pluginType.GetInterface("IRegionModule", true);
+
+                        if (typeInterface != null)
+                        {
+                            module =
+                                (IRegionModule) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
+                            break;
+                        }
+                        typeInterface = null;
+                    }
+                }
+            }
+            pluginAssembly = null;
+
+            if ((module != null) || (module.GetName() == moduleName))
+            {
+                return module;
+            }
+
+            return null;
+        }
+
+        public void PostInitialise()
+        {
+            foreach (IRegionModule module in LoadedSharedModules.Values)
+            {
+                module.PostInitialise();
+            }
+
+            foreach (IRegionModule module in LoadedModules)
+            {
+                module.PostInitialise();
+            }
+        }
+
+        public void ClearCache()
+        {
+            LoadedAssemblys.Clear();
+        }
+    }
 }
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs
index 511b5f6..7d789f9 100644
--- a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs
@@ -1,7 +1,7 @@
-using OpenSim.Framework.Interfaces;
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Scenes;
-
+using OpenSim.Framework.Interfaces;
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment.Modules
 {
     public class AssetDownloadModule : IRegionModule
@@ -9,7 +9,7 @@ namespace OpenSim.Region.Environment.Modules
         private Scene m_scene;
 
         public AssetDownloadModule()
-        {
+        {
         }
 
         public void Initialise(Scene scene)
@@ -19,7 +19,7 @@ namespace OpenSim.Region.Environment.Modules
         }
 
         public void PostInitialise()
-        {
+        {
         }
 
         public void CloseDown()
diff --git a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs
index ea5f787..aaa9261 100644
--- a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs
+++ b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs
@@ -1,16 +1,16 @@
-using libsecondlife;
-using OpenSim.Framework.Interfaces;
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Scenes;
-
+using libsecondlife;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment.Modules
 {
     public class AvatarProfilesModule : IRegionModule
-    {
+    {
         private Scene m_scene;
 
         public AvatarProfilesModule()
-        {
+        {
         }
 
         public void Initialise(Scene scene)
@@ -20,11 +20,11 @@ namespace OpenSim.Region.Environment.Modules
         }
 
         public void PostInitialise()
-        {
+        {
         }
 
         public void CloseDown()
-        {
+        {
         }
 
         public string GetName()
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Environment.Modules
             string bornOn = "Before now";
             string flAbout = "First life? What is one of those? OpenSim is my life!";
             LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000");
-            remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "",
+            remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "",
                                               partner);
         }
     }
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs
index 1c7b806..2eac7d6 100644
--- a/OpenSim/Region/Environment/Modules/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/ChatModule.cs
@@ -1,214 +1,214 @@
-using System;
-using System.IO;
-using System.Net.Sockets;
-using System.Threading;
-using libsecondlife;
-using OpenSim.Framework.Interfaces;
-using OpenSim.Framework.Utilities;
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Scenes;
-
-namespace OpenSim.Region.Environment.Modules
-{
-    public class ChatModule : IRegionModule, ISimChat
-    {
-        private Scene m_scene;
-
-        private string m_server = "irc2.choopa.net";
-
-        // private int m_port = 6668;
-        //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
-        private string m_nick = "OSimBot";
-        private string m_channel = "#opensim";
-
-        // private NetworkStream m_stream;
-        private TcpClient m_irc;
-        private StreamWriter m_ircWriter;
-        private StreamReader m_ircReader;
-
-        //  private Thread pingSender;
-        //  private Thread listener;
-
-        private bool connected = false;
-
-        public ChatModule()
-        {
-            m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
-            m_irc = null;
-            m_ircWriter = null;
-            m_ircReader = null;
-        }
-
-        public void Initialise(Scene scene)
-        {
-            m_scene = scene;
-            m_scene.EventManager.OnNewClient += NewClient;
-
-            m_scene.RegisterModuleInterface<ISimChat>(this);
-        }
-
-        public void PostInitialise()
-        {
-            /*
-            try
-            {
-                m_irc = new TcpClient(m_server, m_port);
-                m_stream = m_irc.GetStream();
-                m_ircReader = new StreamReader(m_stream);
-                m_ircWriter = new StreamWriter(m_stream);
-
-                pingSender = new Thread(new ThreadStart(this.PingRun));
-                pingSender.Start();
-
-                listener = new Thread(new ThreadStart(this.ListenerRun));
-                listener.Start();
-
-                m_ircWriter.WriteLine(m_user);
-                m_ircWriter.Flush();
-                m_ircWriter.WriteLine("NICK " + m_nick);
-                m_ircWriter.Flush();
-                m_ircWriter.WriteLine("JOIN " + m_channel);
-                m_ircWriter.Flush();
-                connected = true;
-            }
-            catch (Exception e)
-            {
-                Console.WriteLine(e.ToString());
-            }
-            */
-        }
-
-        public void CloseDown()
-        {
-            m_ircWriter.Close();
-            m_ircReader.Close();
-            m_irc.Close();
-        }
-
-        public string GetName()
-        {
-            return "ChatModule";
-        }
-
-        public bool IsSharedModule()
-        {
-            return false;
-        }
-
-        public void NewClient(IClientAPI client)
-        {
-            client.OnChatFromViewer += SimChat;
-        }
-
-        public void PingRun()
-        {
-            while (true)
-            {
-                m_ircWriter.WriteLine("PING :" + m_server);
-                m_ircWriter.Flush();
-                Thread.Sleep(15000);
-            }
-        }
-
-        public void ListenerRun()
-        {
-            string inputLine;
-            LLVector3 pos = new LLVector3(128, 128, 20);
-            while (true)
-            {
-                while ((inputLine = m_ircReader.ReadLine()) != null)
-                {
-                    Console.WriteLine(inputLine);
-                    if (inputLine.Contains(m_channel))
-                    {
-                        string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
-                        m_scene.Broadcast(delegate(IClientAPI client)
-                                                         {
-                                                             client.SendChatMessage(
-                                                                 Helpers.StringToField(mess), 255, pos, "IRC:",
-                                                                 LLUUID.Zero);
-                                                         });
-                    }
-                }
-            }
-        }
-
-        public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName,
-                            LLUUID fromAgentID)
-        {
-            ScenePresence avatar = null;
-            avatar = m_scene.GetScenePresence(fromAgentID);
-            if (avatar != null)
-            {
-                fromPos = avatar.AbsolutePosition;
-                fromName = avatar.Firstname + " " + avatar.Lastname;
-                avatar = null;
-            }
-
-            if (connected)
-            {
-                m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">:  " +
-                                      Util.FieldToString(message));
-                m_ircWriter.Flush();
-            }
-
-            if (channel == 0)
-            {
-                m_scene.ForEachScenePresence(delegate(ScenePresence presence)
-                                                 {
-                                                     int dis = -1000;
-
-                                                     //err ??? the following code seems to be request a scenePresence when it already has a ref to it
-                                                     avatar = m_scene.GetScenePresence(presence.ControllingClient.AgentId);
-                                                     if (avatar != null)
-                                                     {
-                                                         dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos);
-                                                     }
-
-                                                     switch (type)
-                                                     {
-                                                         case 0: // Whisper
-                                                             if ((dis < 10) && (dis > -10))
-                                                             {
-                                                                 //should change so the message is sent through the avatar rather than direct to the ClientView
-                                                                 presence.ControllingClient.SendChatMessage(message,
-                                                                                                            type,
-                                                                                                            fromPos,
-                                                                                                            fromName,
-                                                                                                            fromAgentID);
-                                                             }
-                                                             break;
-                                                         case 1: // Say
-                                                             if ((dis < 30) && (dis > -30))
-                                                             {
-                                                                 //Console.WriteLine("sending chat");
-                                                                 presence.ControllingClient.SendChatMessage(message,
-                                                                                                            type,
-                                                                                                            fromPos,
-                                                                                                            fromName,
-                                                                                                            fromAgentID);
-                                                             }
-                                                             break;
-                                                         case 2: // Shout
-                                                             if ((dis < 100) && (dis > -100))
-                                                             {
-                                                                 presence.ControllingClient.SendChatMessage(message,
-                                                                                                            type,
-                                                                                                            fromPos,
-                                                                                                            fromName,
-                                                                                                            fromAgentID);
-                                                             }
-                                                             break;
-
-                                                         case 0xff: // Broadcast
-                                                             presence.ControllingClient.SendChatMessage(message, type,
-                                                                                                        fromPos,
-                                                                                                        fromName,
-                                                                                                        fromAgentID);
-                                                             break;
-                                                     }
-                                                 });
-            }
-        }
-    }
+using System;
+using System.IO;
+using System.Net.Sockets;
+using System.Threading;
+using libsecondlife;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Framework.Utilities;
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+
+namespace OpenSim.Region.Environment.Modules
+{
+    public class ChatModule : IRegionModule, ISimChat
+    {
+        private Scene m_scene;
+
+        private string m_server = "irc2.choopa.net";
+
+        // private int m_port = 6668;
+        //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
+        private string m_nick = "OSimBot";
+        private string m_channel = "#opensim";
+
+        // private NetworkStream m_stream;
+        private TcpClient m_irc;
+        private StreamWriter m_ircWriter;
+        private StreamReader m_ircReader;
+
+        //  private Thread pingSender;
+        //  private Thread listener;
+
+        private bool connected = false;
+
+        public ChatModule()
+        {
+            m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
+            m_irc = null;
+            m_ircWriter = null;
+            m_ircReader = null;
+        }
+
+        public void Initialise(Scene scene)
+        {
+            m_scene = scene;
+            m_scene.EventManager.OnNewClient += NewClient;
+
+            m_scene.RegisterModuleInterface<ISimChat>(this);
+        }
+
+        public void PostInitialise()
+        {
+            /*
+            try
+            {
+                m_irc = new TcpClient(m_server, m_port);
+                m_stream = m_irc.GetStream();
+                m_ircReader = new StreamReader(m_stream);
+                m_ircWriter = new StreamWriter(m_stream);
+
+                pingSender = new Thread(new ThreadStart(this.PingRun));
+                pingSender.Start();
+
+                listener = new Thread(new ThreadStart(this.ListenerRun));
+                listener.Start();
+
+                m_ircWriter.WriteLine(m_user);
+                m_ircWriter.Flush();
+                m_ircWriter.WriteLine("NICK " + m_nick);
+                m_ircWriter.Flush();
+                m_ircWriter.WriteLine("JOIN " + m_channel);
+                m_ircWriter.Flush();
+                connected = true;
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e.ToString());
+            }
+            */
+        }
+
+        public void CloseDown()
+        {
+            m_ircWriter.Close();
+            m_ircReader.Close();
+            m_irc.Close();
+        }
+
+        public string GetName()
+        {
+            return "ChatModule";
+        }
+
+        public bool IsSharedModule()
+        {
+            return false;
+        }
+
+        public void NewClient(IClientAPI client)
+        {
+            client.OnChatFromViewer += SimChat;
+        }
+
+        public void PingRun()
+        {
+            while (true)
+            {
+                m_ircWriter.WriteLine("PING :" + m_server);
+                m_ircWriter.Flush();
+                Thread.Sleep(15000);
+            }
+        }
+
+        public void ListenerRun()
+        {
+            string inputLine;
+            LLVector3 pos = new LLVector3(128, 128, 20);
+            while (true)
+            {
+                while ((inputLine = m_ircReader.ReadLine()) != null)
+                {
+                    Console.WriteLine(inputLine);
+                    if (inputLine.Contains(m_channel))
+                    {
+                        string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
+                        m_scene.Broadcast(delegate(IClientAPI client)
+                                                         {
+                                                             client.SendChatMessage(
+                                                                 Helpers.StringToField(mess), 255, pos, "IRC:",
+                                                                 LLUUID.Zero);
+                                                         });
+                    }
+                }
+            }
+        }
+
+        public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName,
+                            LLUUID fromAgentID)
+        {
+            ScenePresence avatar = null;
+            avatar = m_scene.GetScenePresence(fromAgentID);
+            if (avatar != null)
+            {
+                fromPos = avatar.AbsolutePosition;
+                fromName = avatar.Firstname + " " + avatar.Lastname;
+                avatar = null;
+            }
+
+            if (connected)
+            {
+                m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">:  " +
+                                      Util.FieldToString(message));
+                m_ircWriter.Flush();
+            }
+
+            if (channel == 0)
+            {
+                m_scene.ForEachScenePresence(delegate(ScenePresence presence)
+                                                 {
+                                                     int dis = -1000;
+
+                                                     //err ??? the following code seems to be request a scenePresence when it already has a ref to it
+                                                     avatar = m_scene.GetScenePresence(presence.ControllingClient.AgentId);
+                                                     if (avatar != null)
+                                                     {
+                                                         dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos);
+                                                     }
+
+                                                     switch (type)
+                                                     {
+                                                         case 0: // Whisper
+                                                             if ((dis < 10) && (dis > -10))
+                                                             {
+                                                                 //should change so the message is sent through the avatar rather than direct to the ClientView
+                                                                 presence.ControllingClient.SendChatMessage(message,
+                                                                                                            type,
+                                                                                                            fromPos,
+                                                                                                            fromName,
+                                                                                                            fromAgentID);
+                                                             }
+                                                             break;
+                                                         case 1: // Say
+                                                             if ((dis < 30) && (dis > -30))
+                                                             {
+                                                                 //Console.WriteLine("sending chat");
+                                                                 presence.ControllingClient.SendChatMessage(message,
+                                                                                                            type,
+                                                                                                            fromPos,
+                                                                                                            fromName,
+                                                                                                            fromAgentID);
+                                                             }
+                                                             break;
+                                                         case 2: // Shout
+                                                             if ((dis < 100) && (dis > -100))
+                                                             {
+                                                                 presence.ControllingClient.SendChatMessage(message,
+                                                                                                            type,
+                                                                                                            fromPos,
+                                                                                                            fromName,
+                                                                                                            fromAgentID);
+                                                             }
+                                                             break;
+
+                                                         case 0xff: // Broadcast
+                                                             presence.ControllingClient.SendChatMessage(message, type,
+                                                                                                        fromPos,
+                                                                                                        fromName,
+                                                                                                        fromAgentID);
+                                                             break;
+                                                     }
+                                                 });
+            }
+        }
+    }
 }
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs
index 0fd03d3..5f8824c 100644
--- a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs
+++ b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs
@@ -1,157 +1,157 @@
-using System;
-using System.Collections.Generic;
-using libsecondlife;
-using OpenSim.Framework.Types;
-using OpenSim.Framework.Utilities;
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Scenes;
-
-namespace OpenSim.Region.Environment.Modules
-{
-    public class DynamicTextureModule : IRegionModule, IDynamicTextureManager
-    {
-        private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
-
-        private Dictionary<string, IDynamicTextureRender> RenderPlugins =
-            new Dictionary<string, IDynamicTextureRender>();
-
-        private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>();
-
-        public void Initialise(Scene scene)
-        {
-            if (!RegisteredScenes.ContainsKey(scene.RegionInfo.SimUUID))
-            {
-                RegisteredScenes.Add(scene.RegionInfo.SimUUID, scene);
-                scene.RegisterModuleInterface<IDynamicTextureManager>(this);
-            }
-        }
-
-        public void PostInitialise()
-        {
-        }
-
-        public void CloseDown()
-        {
-        }
-
-        public string GetName()
-        {
-            return "DynamicTextureModule";
-        }
-
-        public bool IsSharedModule()
-        {
-            return true;
-        }
-
-        public void RegisterRender(string handleType, IDynamicTextureRender render)
-        {
-            if (!RenderPlugins.ContainsKey(handleType))
-            {
-                RenderPlugins.Add(handleType, render);
-            }
-        }
-
-        public void ReturnData(LLUUID id, byte[] data)
-        {
-            if (Updaters.ContainsKey(id))
-            {
-                DynamicTextureUpdater updater = Updaters[id];
-                if (RegisteredScenes.ContainsKey(updater.SimUUID))
-                {
-                    Scene scene = RegisteredScenes[updater.SimUUID];
-                    updater.DataReceived(data, scene);
-                }
-            }
-        }
-
-        public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url,
-                                           string extraParams, int updateTimer)
-        {
-            Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType);
-            if (RenderPlugins.ContainsKey(contentType))
-            {
-                DynamicTextureUpdater updater = new DynamicTextureUpdater();
-                updater.SimUUID = simID;
-                updater.PrimID = primID;
-                updater.ContentType = contentType;
-                updater.Url = url;
-                updater.UpdateTimer = updateTimer;
-                updater.UpdaterID = LLUUID.Random();
-                updater.Params = extraParams;
-
-                if (!Updaters.ContainsKey(updater.UpdaterID))
-                {
-                    Updaters.Add(updater.UpdaterID, updater);
-                }
-
-                RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams);
-                return updater.UpdaterID;
-            }
-            return LLUUID.Zero;
-        }
-
-        public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data,
-                                            string extraParams, int updateTimer)
-        {
-            if (RenderPlugins.ContainsKey(contentType))
-            {
-                DynamicTextureUpdater updater = new DynamicTextureUpdater();
-                updater.SimUUID = simID;
-                updater.PrimID = primID;
-                updater.ContentType = contentType;
-                updater.BodyData = data;
-                updater.UpdateTimer = updateTimer;
-                updater.UpdaterID = LLUUID.Random();
-                updater.Params = extraParams;
-
-                if (!Updaters.ContainsKey(updater.UpdaterID))
-                {
-                    Updaters.Add(updater.UpdaterID, updater);
-                }
-
-                RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
-                return updater.UpdaterID;
-            }
-            return LLUUID.Zero;
-        }
-
-        public class DynamicTextureUpdater
-        {
-            public LLUUID SimUUID;
-            public LLUUID UpdaterID;
-            public string ContentType;
-            public string Url;
-            public string BodyData;
-            public LLUUID PrimID;
-            public int UpdateTimer;
-            public LLUUID LastAssetID;
-            public string Params;
-
-            public DynamicTextureUpdater()
-            {
-                LastAssetID = LLUUID.Zero;
-                UpdateTimer = 0;
-                BodyData = null;
-            }
-
-            public void DataReceived(byte[] data, Scene scene)
-            {
-                //TODO delete the last asset(data), if it was a dynamic texture
-
-                AssetBase asset = new AssetBase();
-                asset.FullID = LLUUID.Random();
-                asset.Data = data;
-                asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000);
-                asset.Type = 0;
-                scene.commsManager.AssetCache.AddAsset(asset);
-
-                LastAssetID = asset.FullID;
-
-                SceneObjectPart part = scene.GetSceneObjectPart(PrimID);
-                part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes();
-                part.ScheduleFullUpdate();
-            }
-        }
-    }
+using System;
+using System.Collections.Generic;
+using libsecondlife;
+using OpenSim.Framework.Types;
+using OpenSim.Framework.Utilities;
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+
+namespace OpenSim.Region.Environment.Modules
+{
+    public class DynamicTextureModule : IRegionModule, IDynamicTextureManager
+    {
+        private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
+
+        private Dictionary<string, IDynamicTextureRender> RenderPlugins =
+            new Dictionary<string, IDynamicTextureRender>();
+
+        private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>();
+
+        public void Initialise(Scene scene)
+        {
+            if (!RegisteredScenes.ContainsKey(scene.RegionInfo.SimUUID))
+            {
+                RegisteredScenes.Add(scene.RegionInfo.SimUUID, scene);
+                scene.RegisterModuleInterface<IDynamicTextureManager>(this);
+            }
+        }
+
+        public void PostInitialise()
+        {
+        }
+
+        public void CloseDown()
+        {
+        }
+
+        public string GetName()
+        {
+            return "DynamicTextureModule";
+        }
+
+        public bool IsSharedModule()
+        {
+            return true;
+        }
+
+        public void RegisterRender(string handleType, IDynamicTextureRender render)
+        {
+            if (!RenderPlugins.ContainsKey(handleType))
+            {
+                RenderPlugins.Add(handleType, render);
+            }
+        }
+
+        public void ReturnData(LLUUID id, byte[] data)
+        {
+            if (Updaters.ContainsKey(id))
+            {
+                DynamicTextureUpdater updater = Updaters[id];
+                if (RegisteredScenes.ContainsKey(updater.SimUUID))
+                {
+                    Scene scene = RegisteredScenes[updater.SimUUID];
+                    updater.DataReceived(data, scene);
+                }
+            }
+        }
+
+        public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url,
+                                           string extraParams, int updateTimer)
+        {
+            Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType);
+            if (RenderPlugins.ContainsKey(contentType))
+            {
+                DynamicTextureUpdater updater = new DynamicTextureUpdater();
+                updater.SimUUID = simID;
+                updater.PrimID = primID;
+                updater.ContentType = contentType;
+                updater.Url = url;
+                updater.UpdateTimer = updateTimer;
+                updater.UpdaterID = LLUUID.Random();
+                updater.Params = extraParams;
+
+                if (!Updaters.ContainsKey(updater.UpdaterID))
+                {
+                    Updaters.Add(updater.UpdaterID, updater);
+                }
+
+                RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams);
+                return updater.UpdaterID;
+            }
+            return LLUUID.Zero;
+        }
+
+        public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data,
+                                            string extraParams, int updateTimer)
+        {
+            if (RenderPlugins.ContainsKey(contentType))
+            {
+                DynamicTextureUpdater updater = new DynamicTextureUpdater();
+                updater.SimUUID = simID;
+                updater.PrimID = primID;
+                updater.ContentType = contentType;
+                updater.BodyData = data;
+                updater.UpdateTimer = updateTimer;
+                updater.UpdaterID = LLUUID.Random();
+                updater.Params = extraParams;
+
+                if (!Updaters.ContainsKey(updater.UpdaterID))
+                {
+                    Updaters.Add(updater.UpdaterID, updater);
+                }
+
+                RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
+                return updater.UpdaterID;
+            }
+            return LLUUID.Zero;
+        }
+
+        public class DynamicTextureUpdater
+        {
+            public LLUUID SimUUID;
+            public LLUUID UpdaterID;
+            public string ContentType;
+            public string Url;
+            public string BodyData;
+            public LLUUID PrimID;
+            public int UpdateTimer;
+            public LLUUID LastAssetID;
+            public string Params;
+
+            public DynamicTextureUpdater()
+            {
+                LastAssetID = LLUUID.Zero;
+                UpdateTimer = 0;
+                BodyData = null;
+            }
+
+            public void DataReceived(byte[] data, Scene scene)
+            {
+                //TODO delete the last asset(data), if it was a dynamic texture
+
+                AssetBase asset = new AssetBase();
+                asset.FullID = LLUUID.Random();
+                asset.Data = data;
+                asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000);
+                asset.Type = 0;
+                scene.commsManager.AssetCache.AddAsset(asset);
+
+                LastAssetID = asset.FullID;
+
+                SceneObjectPart part = scene.GetSceneObjectPart(PrimID);
+                part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes();
+                part.ScheduleFullUpdate();
+            }
+        }
+    }
 }
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs
index c2a7291..767b4b0 100644
--- a/OpenSim/Region/Environment/Modules/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs
@@ -1,6 +1,6 @@
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Scenes;
-
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment.Modules
 {
     public class FriendsModule : IRegionModule
@@ -13,7 +13,7 @@ namespace OpenSim.Region.Environment.Modules
         }
 
         public void PostInitialise()
-        {
+        {
         }
 
         public void CloseDown()
diff --git a/OpenSim/Region/Environment/Modules/GroupsModule.cs b/OpenSim/Region/Environment/Modules/GroupsModule.cs
index dcef2c5..fa5804e 100644
--- a/OpenSim/Region/Environment/Modules/GroupsModule.cs
+++ b/OpenSim/Region/Environment/Modules/GroupsModule.cs
@@ -1,6 +1,6 @@
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Scenes;
-
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment.Modules
 {
     public class GroupsModule : IRegionModule
@@ -13,7 +13,7 @@ namespace OpenSim.Region.Environment.Modules
         }
 
         public void PostInitialise()
-        {
+        {
         }
 
         public void CloseDown()
diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
index 14f2b65..44cb3d5 100644
--- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
+++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
@@ -1,6 +1,6 @@
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Scenes;
-
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment.Modules
 {
     public class InstantMessageModule : IRegionModule
@@ -13,7 +13,7 @@ namespace OpenSim.Region.Environment.Modules
         }
 
         public void PostInitialise()
-        {
+        {
         }
 
         public void CloseDown()
diff --git a/OpenSim/Region/Environment/Modules/InventoryModule.cs b/OpenSim/Region/Environment/Modules/InventoryModule.cs
index 40bd37e..527731d 100644
--- a/OpenSim/Region/Environment/Modules/InventoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/InventoryModule.cs
@@ -1,6 +1,6 @@
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Scenes;
-
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment.Modules
 {
     public class InventoryModule : IRegionModule
@@ -13,7 +13,7 @@ namespace OpenSim.Region.Environment.Modules
         }
 
         public void PostInitialise()
-        {
+        {
         }
 
         public void CloseDown()
diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
index f107d77..38c7d9b 100644
--- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
@@ -1,8 +1,8 @@
-using libsecondlife;
-using OpenSim.Framework.Interfaces;
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Scenes;
-
+using libsecondlife;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment.Modules
 {
     public class TextureDownloadModule : IRegionModule
@@ -10,7 +10,7 @@ namespace OpenSim.Region.Environment.Modules
         private Scene m_scene;
 
         public TextureDownloadModule()
-        {
+        {
         }
 
         public void Initialise(Scene scene)
@@ -20,7 +20,7 @@ namespace OpenSim.Region.Environment.Modules
         }
 
         public void PostInitialise()
-        {
+        {
         }
 
         public void CloseDown()
@@ -42,7 +42,7 @@ namespace OpenSim.Region.Environment.Modules
         }
 
         public void TextureAssetCallback(LLUUID texture, byte[] data)
-        {
+        {
         }
     }
 }
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/XferModule.cs b/OpenSim/Region/Environment/Modules/XferModule.cs
index 7f8c5c1..9f93c1e 100644
--- a/OpenSim/Region/Environment/Modules/XferModule.cs
+++ b/OpenSim/Region/Environment/Modules/XferModule.cs
@@ -1,10 +1,10 @@
-using System;
-using System.Collections.Generic;
-using libsecondlife;
-using OpenSim.Framework.Interfaces;
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Scenes;
-
+using System;
+using System.Collections.Generic;
+using libsecondlife;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment.Modules
 {
     public class XferModule : IRegionModule, IXfer
@@ -15,7 +15,7 @@ namespace OpenSim.Region.Environment.Modules
         private Scene m_scene;
 
         public XferModule()
-        {
+        {
         }
 
         public void Initialise(Scene scene)
@@ -27,11 +27,11 @@ namespace OpenSim.Region.Environment.Modules
         }
 
         public void PostInitialise()
-        {
+        {
         }
 
         public void CloseDown()
-        {
+        {
         }
 
         public string GetName()
@@ -119,7 +119,7 @@ namespace OpenSim.Region.Environment.Modules
             }
 
             public XferDownLoad()
-            {
+            {
             }
 
             public void StartSend()
diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs
index 0a33380..4c02a6c 100644
--- a/OpenSim/Region/Environment/PermissionManager.cs
+++ b/OpenSim/Region/Environment/PermissionManager.cs
@@ -1,7 +1,7 @@
-using libsecondlife;
-using OpenSim.Region.Environment.LandManagement;
-using OpenSim.Region.Environment.Scenes;
-
+using libsecondlife;
+using OpenSim.Region.Environment.LandManagement;
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment
 {
     public class PermissionManager
@@ -12,8 +12,8 @@ namespace OpenSim.Region.Environment
         // disable in any production environment
         // TODO: Change this to false when permissions are a desired default
         // TODO: Move to configuration option.
-        private bool m_bypassPermissions = true;
-
+        private bool m_bypassPermissions = true;
+
         public bool BypassPermissions
         {
             get { return m_bypassPermissions; }
@@ -117,7 +117,7 @@ namespace OpenSim.Region.Environment
                 permission = true;
 
             // Users should be able to edit what is over their land.
-            if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID ==
+            if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID ==
                 user)
                 permission = true;
 
@@ -294,6 +294,6 @@ namespace OpenSim.Region.Environment
             return GenericParcelPermission(user, parcel);
         }
 
-        #endregion
+        #endregion
     }
 }
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index b7f5bad..24f1a86 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -1,445 +1,445 @@
-using Axiom.Math;
-using libsecondlife;
-using libsecondlife.Packets;
-using OpenSim.Framework.Communications.Cache;
-using OpenSim.Framework.Communications.Caches;
-using OpenSim.Framework.Interfaces;
-using OpenSim.Framework.Types;
-using OpenSim.Framework.Utilities;
-using OpenSim.Region.Physics.Manager;
-
-namespace OpenSim.Region.Environment.Scenes
-{
-    public partial class Scene
-    {
-        //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete
-        // or at least some of they can be moved somewhere else
-
-        public void AddInventoryItem(LLUUID avatarId, InventoryItemBase item)
-        {
-            ScenePresence avatar;
-
-            if ( TryGetAvatar( avatarId, out avatar ))
-            {
-                AddInventoryItem(avatar.ControllingClient, item);
-            }
-        }
-
-        public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item)
-        {
-            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
-            if (userInfo != null)
-            {
-                userInfo.AddItem(remoteClient.AgentId, item);
-                remoteClient.SendInventoryItemUpdate(item);
-            }
-        }
-
-        public LLUUID CapsUpdateInventoryItemAsset(LLUUID avatarId, LLUUID itemID, byte[] data)
-        {
-            ScenePresence avatar;
-
-            if (TryGetAvatar(avatarId, out avatar))
-            {
-                return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
-            }
-
-            return LLUUID.Zero;
-        }
-
-        public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data)
-        {
-            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
-            if (userInfo != null)
-            {
-                if (userInfo.RootFolder != null)
-                {
-                    InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
-                    if (item != null)
-                    {
-                        AssetBase asset;
-                        asset = new AssetBase();
-                        asset.FullID = LLUUID.Random();
-                        asset.Type = (sbyte) item.assetType;
-                        asset.InvType = (sbyte) item.invType;
-                        asset.Name = item.inventoryName;
-                        asset.Data = data;
-                        commsManager.AssetCache.AddAsset(asset);
-
-                        item.assetID = asset.FullID;
-                        userInfo.UpdateItem(remoteClient.AgentId, item);
-
-                        // remoteClient.SendInventoryItemUpdate(item);
-                        if (item.invType == 7)
-                        {
-                            //do we want to know about updated note cards?
-                        }
-                        else if (item.invType == 10)
-                        {
-                            // do we want to know about updated scripts
-                        }
-
-                        return (asset.FullID);
-                    }
-                }
-            }
-            return LLUUID.Zero;
-        }
-
-        public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID,
-                                                LLUUID itemID)
-        {
-            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
-            if (userInfo != null)
-            {
-                if (userInfo.RootFolder != null)
-                {
-                    InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
-                    if (item != null)
-                    {
-                        AgentAssetTransactions transactions =
-                            commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
-                        if (transactions != null)
-                        {
-                            AssetBase asset = null;
-                            bool addToCache = false;
-
-                            asset = commsManager.AssetCache.GetAsset(assetID);
-                            if (asset == null)
-                            {
-                                asset = transactions.GetTransactionAsset(transactionID);
-                                addToCache = true;
-                            }
-
-                            if (asset != null)
-                            {
-                                if (asset.FullID == assetID)
-                                {
-                                    asset.Name = item.inventoryName;
-                                    asset.Description = item.inventoryDescription;
-                                    asset.InvType = (sbyte) item.invType;
-                                    asset.Type = (sbyte) item.assetType;
-                                    item.assetID = asset.FullID;
-
-                                    if (addToCache)
-                                    {
-                                        commsManager.AssetCache.AddAsset(asset);
-                                    }
-
-                                    userInfo.UpdateItem(remoteClient.AgentId, item);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// temporary method to test out creating new inventory items
-        /// </summary>
-        /// <param name="remoteClient"></param>
-        /// <param name="transActionID"></param>
-        /// <param name="folderID"></param>
-        /// <param name="callbackID"></param>
-        /// <param name="description"></param>
-        /// <param name="name"></param>
-        /// <param name="invType"></param>
-        /// <param name="type"></param>
-        /// <param name="wearableType"></param>
-        /// <param name="nextOwnerMask"></param>
-        public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID,
-                                           uint callbackID, string description, string name, sbyte invType, sbyte type,
-                                           byte wearableType, uint nextOwnerMask)
-        {
-            if (transActionID == LLUUID.Zero)
-            {
-                CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
-                if (userInfo != null)
-                {
-                    AssetBase asset = new AssetBase();
-                    asset.Name = name;
-                    asset.Description = description;
-                    asset.InvType = invType;
-                    asset.Type = type;
-                    asset.FullID = LLUUID.Random();
-                    asset.Data = new byte[1];
-                    commsManager.AssetCache.AddAsset(asset);
-
-                    InventoryItemBase item = new InventoryItemBase();
-                    item.avatarID = remoteClient.AgentId;
-                    item.creatorsID = remoteClient.AgentId;
-                    item.inventoryID = LLUUID.Random();
-                    item.assetID = asset.FullID;
-                    item.inventoryDescription = description;
-                    item.inventoryName = name;
-                    item.assetType = invType;
-                    item.invType = invType;
-                    item.parentFolderID = folderID;
-                    item.inventoryCurrentPermissions = 2147483647;
-                    item.inventoryNextPermissions = nextOwnerMask;
-
-                    userInfo.AddItem(remoteClient.AgentId, item);
-                    remoteClient.SendInventoryItemUpdate(item);
-                }
-            }
-            else
-            {
-                commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID,
-                                                                                callbackID, description, name, invType,
-                                                                                type, wearableType, nextOwnerMask);
-                //System.Console.WriteLine("request to create inventory item from transaction " + transActionID);
-            }
-        }
-
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="remoteClient"></param>
-        /// <param name="primLocalID"></param>
-        public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
-        {
-            bool hasPrim = false;
-            foreach (EntityBase ent in Entities.Values)
-            {
-                if (ent is SceneObjectGroup)
-                {
-                    hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID);
-                    if (hasPrim != false)
-                    {
-                        bool fileChange = ((SceneObjectGroup) ent).GetPartInventoryFileName(remoteClient, primLocalID);
-                        if (fileChange)
-                        {
-                            if (XferManager != null)
-                            {
-                                ((SceneObjectGroup) ent).RequestInventoryFile(primLocalID, XferManager);
-                            }
-                        }
-                        break;
-                    }
-                }
-            }
-        }
-
-        public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID)
-        {
-            bool hasPrim = false;
-            foreach (EntityBase ent in Entities.Values)
-            {
-                if (ent is SceneObjectGroup)
-                {
-                    hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID);
-                    if (hasPrim != false)
-                    {
-                        int type = ((SceneObjectGroup) ent).RemoveInventoryItem(remoteClient, localID, itemID);
-                        ((SceneObjectGroup) ent).GetProperites(remoteClient);
-                        if (type == 10)
-                        {
-                            EventManager.TriggerRemoveScript(localID, itemID);
-                        }
-                    }
-                }
-            }
-        }
-
-        public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID)
-        {
-            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
-            LLUUID copyID = LLUUID.Random();
-            if (userInfo != null)
-            {
-                if (userInfo.RootFolder != null)
-                {
-                    InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
-                    if (item != null)
-                    {
-                        bool isTexture = false;
-                        bool rezzed = false;
-                        if (item.invType == 0)
-                        {
-                            isTexture = true;
-                        }
-                        AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture);
-                        if (rezAsset != null)
-                        {
-                            string script = Util.FieldToString(rezAsset.Data);
-                            //Console.WriteLine("rez script "+script);
-                            EventManager.TriggerRezScript(localID, copyID, script);
-                            rezzed = true;
-                        }
-                        else
-                        {
-                            //lets try once more incase the asset cache is being slow getting the asset from server
-                            rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture);
-                            if (rezAsset != null)
-                            {
-                                string script = Util.FieldToString(rezAsset.Data);
-                                // Console.WriteLine("rez script " + script);
-                                EventManager.TriggerRezScript(localID, copyID, script);
-                                rezzed = true;
-                            }
-                        }
-
-                        if (rezzed)
-                        {
-                            bool hasPrim = false;
-                            foreach (EntityBase ent in Entities.Values)
-                            {
-                                if (ent is SceneObjectGroup)
-                                {
-                                    hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID);
-                                    if (hasPrim != false)
-                                    {
-                                        bool added =
-                                            ((SceneObjectGroup) ent).AddInventoryItem(remoteClient, localID, item,
-                                                                                      copyID);
-                                        ((SceneObjectGroup) ent).GetProperites(remoteClient);
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="packet"></param>
-        /// <param name="simClient"></param>
-        public void DeRezObject(Packet packet, IClientAPI remoteClient)
-        {
-            DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet;
-
-            if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
-            {
-                //currently following code not used (or don't know of any case of destination being zero
-            }
-            else
-            {
-                foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
-                {
-                    EntityBase selectedEnt = null;
-                    //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
-                    foreach (EntityBase ent in Entities.Values)
-                    {
-                        if (ent.LocalId == Data.ObjectLocalID)
-                        {
-                            selectedEnt = ent;
-                            break;
-                        }
-                    }
-                    if (selectedEnt != null)
-                    {
-                        if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID))
-                        {
-                            string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString();
-                            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
-                            if (userInfo != null)
-                            {
-                                AssetBase asset = new AssetBase();
-                                asset.Name = ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId);
-                                asset.Description =
-                                    ((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId);
-                                asset.InvType = 6;
-                                asset.Type = 6;
-                                asset.FullID = LLUUID.Random();
-                                asset.Data = Helpers.StringToField(sceneObjectXml);
-                                commsManager.AssetCache.AddAsset(asset);
-
-
-                                InventoryItemBase item = new InventoryItemBase();
-                                item.avatarID = remoteClient.AgentId;
-                                item.creatorsID = remoteClient.AgentId;
-                                item.inventoryID = LLUUID.Random();
-                                item.assetID = asset.FullID;
-                                item.inventoryDescription = asset.Description;
-                                item.inventoryName = asset.Name;
-                                item.assetType = asset.Type;
-                                item.invType = asset.InvType;
-                                item.parentFolderID = DeRezPacket.AgentBlock.DestinationID;
-                                item.inventoryCurrentPermissions = 2147483647;
-                                item.inventoryNextPermissions = 2147483647;
-
-                                userInfo.AddItem(remoteClient.AgentId, item);
-                                remoteClient.SendInventoryItemUpdate(item);
-                            }
-
-                            SceneObjectPart rootPart =
-                                ((SceneObjectGroup) selectedEnt).GetChildPart(((SceneObjectGroup) selectedEnt).UUID);
-                            if (rootPart.PhysActor != null)
-                            {
-                                phyScene.RemovePrim(rootPart.PhysActor);
-                                rootPart.PhysActor = null;
-                            }
-
-                            storageManager.DataStore.RemoveObject(((SceneObjectGroup) selectedEnt).UUID,
-                                                                  m_regInfo.SimUUID);
-                            ((SceneObjectGroup) selectedEnt).DeleteGroup();
-
-                            lock (Entities)
-                            {
-                                Entities.Remove(((SceneObjectGroup) selectedEnt).UUID);
-                            }
-                            ((SceneObjectGroup) selectedEnt).DeleteParts();
-                        }
-                    }
-                }
-            }
-        }
-
-        public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos)
-        {
-            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
-            if (userInfo != null)
-            {
-                if (userInfo.RootFolder != null)
-                {
-                    InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
-                    if (item != null)
-                    {
-                        AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
-                        if (rezAsset != null)
-                        {
-                            AddRezObject(Util.FieldToString(rezAsset.Data), pos);
-                            userInfo.DeleteItem(remoteClient.AgentId, item);
-                            remoteClient.SendRemoveInventoryItem(itemID);
-                        }
-                        else
-                        {
-                            //lets try once more incase the asset cache is being slow getting the asset from server
-                            rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
-                            if (rezAsset != null)
-                            {
-                                AddRezObject(Util.FieldToString(rezAsset.Data), pos);
-                                userInfo.DeleteItem(remoteClient.AgentId, item);
-                                remoteClient.SendRemoveInventoryItem(itemID);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        private void AddRezObject(string xmlData, LLVector3 pos)
-        {
-            SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
-            AddEntity(group);
-            group.AbsolutePosition = pos;
-            SceneObjectPart rootPart = group.GetChildPart(group.UUID);
-            if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
-            {
-                PrimitiveBaseShape pbs = rootPart.Shape;
-                rootPart.PhysActor = phyScene.AddPrimShape(
-                    rootPart.Name,
-                    pbs,
-                    new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
-                                      rootPart.AbsolutePosition.Z),
-                    new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
-                    new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
-                                   rootPart.RotationOffset.Y, rootPart.RotationOffset.Z));
-            }
-        }
-    }
-}
+using Axiom.Math;
+using libsecondlife;
+using libsecondlife.Packets;
+using OpenSim.Framework.Communications.Cache;
+using OpenSim.Framework.Communications.Caches;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Framework.Types;
+using OpenSim.Framework.Utilities;
+using OpenSim.Region.Physics.Manager;
+
+namespace OpenSim.Region.Environment.Scenes
+{
+    public partial class Scene
+    {
+        //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete
+        // or at least some of they can be moved somewhere else
+
+        public void AddInventoryItem(LLUUID avatarId, InventoryItemBase item)
+        {
+            ScenePresence avatar;
+
+            if ( TryGetAvatar( avatarId, out avatar ))
+            {
+                AddInventoryItem(avatar.ControllingClient, item);
+            }
+        }
+
+        public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item)
+        {
+            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
+            if (userInfo != null)
+            {
+                userInfo.AddItem(remoteClient.AgentId, item);
+                remoteClient.SendInventoryItemUpdate(item);
+            }
+        }
+
+        public LLUUID CapsUpdateInventoryItemAsset(LLUUID avatarId, LLUUID itemID, byte[] data)
+        {
+            ScenePresence avatar;
+
+            if (TryGetAvatar(avatarId, out avatar))
+            {
+                return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
+            }
+
+            return LLUUID.Zero;
+        }
+
+        public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data)
+        {
+            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
+            if (userInfo != null)
+            {
+                if (userInfo.RootFolder != null)
+                {
+                    InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
+                    if (item != null)
+                    {
+                        AssetBase asset;
+                        asset = new AssetBase();
+                        asset.FullID = LLUUID.Random();
+                        asset.Type = (sbyte) item.assetType;
+                        asset.InvType = (sbyte) item.invType;
+                        asset.Name = item.inventoryName;
+                        asset.Data = data;
+                        commsManager.AssetCache.AddAsset(asset);
+
+                        item.assetID = asset.FullID;
+                        userInfo.UpdateItem(remoteClient.AgentId, item);
+
+                        // remoteClient.SendInventoryItemUpdate(item);
+                        if (item.invType == 7)
+                        {
+                            //do we want to know about updated note cards?
+                        }
+                        else if (item.invType == 10)
+                        {
+                            // do we want to know about updated scripts
+                        }
+
+                        return (asset.FullID);
+                    }
+                }
+            }
+            return LLUUID.Zero;
+        }
+
+        public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID,
+                                                LLUUID itemID)
+        {
+            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
+            if (userInfo != null)
+            {
+                if (userInfo.RootFolder != null)
+                {
+                    InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
+                    if (item != null)
+                    {
+                        AgentAssetTransactions transactions =
+                            commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
+                        if (transactions != null)
+                        {
+                            AssetBase asset = null;
+                            bool addToCache = false;
+
+                            asset = commsManager.AssetCache.GetAsset(assetID);
+                            if (asset == null)
+                            {
+                                asset = transactions.GetTransactionAsset(transactionID);
+                                addToCache = true;
+                            }
+
+                            if (asset != null)
+                            {
+                                if (asset.FullID == assetID)
+                                {
+                                    asset.Name = item.inventoryName;
+                                    asset.Description = item.inventoryDescription;
+                                    asset.InvType = (sbyte) item.invType;
+                                    asset.Type = (sbyte) item.assetType;
+                                    item.assetID = asset.FullID;
+
+                                    if (addToCache)
+                                    {
+                                        commsManager.AssetCache.AddAsset(asset);
+                                    }
+
+                                    userInfo.UpdateItem(remoteClient.AgentId, item);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// temporary method to test out creating new inventory items
+        /// </summary>
+        /// <param name="remoteClient"></param>
+        /// <param name="transActionID"></param>
+        /// <param name="folderID"></param>
+        /// <param name="callbackID"></param>
+        /// <param name="description"></param>
+        /// <param name="name"></param>
+        /// <param name="invType"></param>
+        /// <param name="type"></param>
+        /// <param name="wearableType"></param>
+        /// <param name="nextOwnerMask"></param>
+        public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID,
+                                           uint callbackID, string description, string name, sbyte invType, sbyte type,
+                                           byte wearableType, uint nextOwnerMask)
+        {
+            if (transActionID == LLUUID.Zero)
+            {
+                CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
+                if (userInfo != null)
+                {
+                    AssetBase asset = new AssetBase();
+                    asset.Name = name;
+                    asset.Description = description;
+                    asset.InvType = invType;
+                    asset.Type = type;
+                    asset.FullID = LLUUID.Random();
+                    asset.Data = new byte[1];
+                    commsManager.AssetCache.AddAsset(asset);
+
+                    InventoryItemBase item = new InventoryItemBase();
+                    item.avatarID = remoteClient.AgentId;
+                    item.creatorsID = remoteClient.AgentId;
+                    item.inventoryID = LLUUID.Random();
+                    item.assetID = asset.FullID;
+                    item.inventoryDescription = description;
+                    item.inventoryName = name;
+                    item.assetType = invType;
+                    item.invType = invType;
+                    item.parentFolderID = folderID;
+                    item.inventoryCurrentPermissions = 2147483647;
+                    item.inventoryNextPermissions = nextOwnerMask;
+
+                    userInfo.AddItem(remoteClient.AgentId, item);
+                    remoteClient.SendInventoryItemUpdate(item);
+                }
+            }
+            else
+            {
+                commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID,
+                                                                                callbackID, description, name, invType,
+                                                                                type, wearableType, nextOwnerMask);
+                //System.Console.WriteLine("request to create inventory item from transaction " + transActionID);
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="remoteClient"></param>
+        /// <param name="primLocalID"></param>
+        public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
+        {
+            bool hasPrim = false;
+            foreach (EntityBase ent in Entities.Values)
+            {
+                if (ent is SceneObjectGroup)
+                {
+                    hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID);
+                    if (hasPrim != false)
+                    {
+                        bool fileChange = ((SceneObjectGroup) ent).GetPartInventoryFileName(remoteClient, primLocalID);
+                        if (fileChange)
+                        {
+                            if (XferManager != null)
+                            {
+                                ((SceneObjectGroup) ent).RequestInventoryFile(primLocalID, XferManager);
+                            }
+                        }
+                        break;
+                    }
+                }
+            }
+        }
+
+        public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID)
+        {
+            bool hasPrim = false;
+            foreach (EntityBase ent in Entities.Values)
+            {
+                if (ent is SceneObjectGroup)
+                {
+                    hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID);
+                    if (hasPrim != false)
+                    {
+                        int type = ((SceneObjectGroup) ent).RemoveInventoryItem(remoteClient, localID, itemID);
+                        ((SceneObjectGroup) ent).GetProperites(remoteClient);
+                        if (type == 10)
+                        {
+                            EventManager.TriggerRemoveScript(localID, itemID);
+                        }
+                    }
+                }
+            }
+        }
+
+        public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID)
+        {
+            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
+            LLUUID copyID = LLUUID.Random();
+            if (userInfo != null)
+            {
+                if (userInfo.RootFolder != null)
+                {
+                    InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
+                    if (item != null)
+                    {
+                        bool isTexture = false;
+                        bool rezzed = false;
+                        if (item.invType == 0)
+                        {
+                            isTexture = true;
+                        }
+                        AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture);
+                        if (rezAsset != null)
+                        {
+                            string script = Util.FieldToString(rezAsset.Data);
+                            //Console.WriteLine("rez script "+script);
+                            EventManager.TriggerRezScript(localID, copyID, script);
+                            rezzed = true;
+                        }
+                        else
+                        {
+                            //lets try once more incase the asset cache is being slow getting the asset from server
+                            rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture);
+                            if (rezAsset != null)
+                            {
+                                string script = Util.FieldToString(rezAsset.Data);
+                                // Console.WriteLine("rez script " + script);
+                                EventManager.TriggerRezScript(localID, copyID, script);
+                                rezzed = true;
+                            }
+                        }
+
+                        if (rezzed)
+                        {
+                            bool hasPrim = false;
+                            foreach (EntityBase ent in Entities.Values)
+                            {
+                                if (ent is SceneObjectGroup)
+                                {
+                                    hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID);
+                                    if (hasPrim != false)
+                                    {
+                                        bool added =
+                                            ((SceneObjectGroup) ent).AddInventoryItem(remoteClient, localID, item,
+                                                                                      copyID);
+                                        ((SceneObjectGroup) ent).GetProperites(remoteClient);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="packet"></param>
+        /// <param name="simClient"></param>
+        public void DeRezObject(Packet packet, IClientAPI remoteClient)
+        {
+            DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet;
+
+            if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
+            {
+                //currently following code not used (or don't know of any case of destination being zero
+            }
+            else
+            {
+                foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
+                {
+                    EntityBase selectedEnt = null;
+                    //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
+                    foreach (EntityBase ent in Entities.Values)
+                    {
+                        if (ent.LocalId == Data.ObjectLocalID)
+                        {
+                            selectedEnt = ent;
+                            break;
+                        }
+                    }
+                    if (selectedEnt != null)
+                    {
+                        if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID))
+                        {
+                            string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString();
+                            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
+                            if (userInfo != null)
+                            {
+                                AssetBase asset = new AssetBase();
+                                asset.Name = ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId);
+                                asset.Description =
+                                    ((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId);
+                                asset.InvType = 6;
+                                asset.Type = 6;
+                                asset.FullID = LLUUID.Random();
+                                asset.Data = Helpers.StringToField(sceneObjectXml);
+                                commsManager.AssetCache.AddAsset(asset);
+
+
+                                InventoryItemBase item = new InventoryItemBase();
+                                item.avatarID = remoteClient.AgentId;
+                                item.creatorsID = remoteClient.AgentId;
+                                item.inventoryID = LLUUID.Random();
+                                item.assetID = asset.FullID;
+                                item.inventoryDescription = asset.Description;
+                                item.inventoryName = asset.Name;
+                                item.assetType = asset.Type;
+                                item.invType = asset.InvType;
+                                item.parentFolderID = DeRezPacket.AgentBlock.DestinationID;
+                                item.inventoryCurrentPermissions = 2147483647;
+                                item.inventoryNextPermissions = 2147483647;
+
+                                userInfo.AddItem(remoteClient.AgentId, item);
+                                remoteClient.SendInventoryItemUpdate(item);
+                            }
+
+                            SceneObjectPart rootPart =
+                                ((SceneObjectGroup) selectedEnt).GetChildPart(((SceneObjectGroup) selectedEnt).UUID);
+                            if (rootPart.PhysActor != null)
+                            {
+                                phyScene.RemovePrim(rootPart.PhysActor);
+                                rootPart.PhysActor = null;
+                            }
+
+                            storageManager.DataStore.RemoveObject(((SceneObjectGroup) selectedEnt).UUID,
+                                                                  m_regInfo.SimUUID);
+                            ((SceneObjectGroup) selectedEnt).DeleteGroup();
+
+                            lock (Entities)
+                            {
+                                Entities.Remove(((SceneObjectGroup) selectedEnt).UUID);
+                            }
+                            ((SceneObjectGroup) selectedEnt).DeleteParts();
+                        }
+                    }
+                }
+            }
+        }
+
+        public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos)
+        {
+            CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
+            if (userInfo != null)
+            {
+                if (userInfo.RootFolder != null)
+                {
+                    InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
+                    if (item != null)
+                    {
+                        AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
+                        if (rezAsset != null)
+                        {
+                            AddRezObject(Util.FieldToString(rezAsset.Data), pos);
+                            userInfo.DeleteItem(remoteClient.AgentId, item);
+                            remoteClient.SendRemoveInventoryItem(itemID);
+                        }
+                        else
+                        {
+                            //lets try once more incase the asset cache is being slow getting the asset from server
+                            rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
+                            if (rezAsset != null)
+                            {
+                                AddRezObject(Util.FieldToString(rezAsset.Data), pos);
+                                userInfo.DeleteItem(remoteClient.AgentId, item);
+                                remoteClient.SendRemoveInventoryItem(itemID);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        private void AddRezObject(string xmlData, LLVector3 pos)
+        {
+            SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
+            AddEntity(group);
+            group.AbsolutePosition = pos;
+            SceneObjectPart rootPart = group.GetChildPart(group.UUID);
+            if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
+            {
+                PrimitiveBaseShape pbs = rootPart.Shape;
+                rootPart.PhysActor = phyScene.AddPrimShape(
+                    rootPart.Name,
+                    pbs,
+                    new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
+                                      rootPart.AbsolutePosition.Z),
+                    new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
+                    new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
+                                   rootPart.RotationOffset.Y, rootPart.RotationOffset.Z));
+            }
+        }
+    }
+}
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
index 0049282..89f60d1 100644
--- a/OpenSim/Region/Environment/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -1,251 +1,251 @@
-using System;
-using System.Collections.Generic;
-using OpenSim.Framework.Console;
-using OpenSim.Framework.Types;
-using libsecondlife;
-
-namespace OpenSim.Region.Environment.Scenes
-{
-    public class SceneManager
-    {
-        private readonly List<Scene> m_localScenes;
-        private Scene m_currentScene = null;
-
-        public Scene CurrentScene
-        {
-            get { return m_currentScene; }
-        }
-
-        public Scene CurrentOrFirstScene
-        {
-            get
-            {
-                if (m_currentScene == null)
-                {
-                    return m_localScenes[0];
-                }
-                else
-                {
-                    return m_currentScene;
-                }
-            }
-        }
-
-        public SceneManager()
-        {
-            m_localScenes = new List<Scene>();
-        }
-
-        public void Close()
-        {
-            for (int i = 0; i < m_localScenes.Count; i++)
-            {
-                m_localScenes[i].Close();
-            }
-        }
-
-        public void Add(Scene scene)
-        {
-            m_localScenes.Add(scene);
-        }
-
-        public void SaveCurrentSceneToXml(string filename)
-        {
-            CurrentOrFirstScene.SavePrimsToXml(filename);
-        }
-
-        public void LoadCurrentSceneFromXml(string filename)
-        {
-            CurrentOrFirstScene.LoadPrimsFromXml(filename);
-        }
-
-        public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
-        {
-            if (m_currentScene == null)
-            {
-                bool success = true;
-                foreach (Scene scene in m_localScenes)
-                {
-                    if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
-                    {
-                        success = false;
-                    }
-                }
-
-                return success;
-            }
-            else
-            {
-                return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
-            }
-        }
-
-        public void SendCommandToCurrentSceneScripts(string[] cmdparams)
-        {
-            ForEachCurrentScene(delegate(Scene scene) { scene.SendCommandToPlugins(cmdparams); });
-        }
-
-        public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions)
-        {
-            ForEachCurrentScene(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; });
-        }
-
-        private void ForEachCurrentScene(Action<Scene> func)
-        {
-            if (m_currentScene == null)
-            {
-                m_localScenes.ForEach(func);
-            }
-            else
-            {
-                func(m_currentScene);
-            }
-        }
-
-        public void BackupCurrentScene()
-        {
-            ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
-        }
-
-        public void HandleAlertCommandOnCurrentScene(string[] cmdparams)
-        {
-            ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
-        }
-
-        public bool TrySetCurrentScene(string regionName)
-        {
-            if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
-            {
-                m_currentScene = null;
-                return true;
-            }
-            else
-            {
-                Console.WriteLine("Searching for Region: '" + regionName + "'");
-
-                foreach (Scene scene in m_localScenes)
-                {
-                    if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
-                    {
-                        m_currentScene = scene;
-                        return true;
-                    }
-                }
-
-                return false;
-            }
-        }
-
-        public void SetDebugPacketOnCurrentScene(LogBase log, int newDebug)
-        {
-            ForEachCurrentScene(delegate(Scene scene)
-                        {
-                            foreach (EntityBase entity in scene.Entities.Values)
-                            {
-                                if (entity is ScenePresence)
-                                {
-                                    ScenePresence scenePrescence = entity as ScenePresence;
-                                    if (!scenePrescence.IsChildAgent)
-                                    {
-                                        log.Error(String.Format("Packet debug for {0} {1} set to {2}",
-                                                                scenePrescence.Firstname, scenePrescence.Lastname,
-                                                                newDebug));
-
-                                        scenePrescence.ControllingClient.SetDebug(newDebug);
-                                    }
-                                }
-                            }
-                        });
-        }
-
-        public List<ScenePresence> GetCurrentSceneAvatars()
-        {
-            List<ScenePresence> avatars = new List<ScenePresence>();
-
-            ForEachCurrentScene(delegate(Scene scene)
-                        {
-                            foreach (EntityBase entity in scene.Entities.Values)
-                            {
-                                if (entity is ScenePresence)
-                                {
-                                    ScenePresence scenePrescence = entity as ScenePresence;
-                                    if (!scenePrescence.IsChildAgent)
-                                    {
-                                        avatars.Add(scenePrescence);
-                                    }
-                                }
-                            }
-                        });
-
-            return avatars;
-        }
-
-        public RegionInfo GetRegionInfo(ulong regionHandle)
-        {
-            foreach (Scene scene in m_localScenes)
-            {
-                if (scene.RegionInfo.RegionHandle == regionHandle)
-                {
-                    return scene.RegionInfo;
-                }
-            }
-
-            return null;
-        }
-
-        public void SetCurrentSceneTimePhase(int timePhase)
-        {
-            ForEachCurrentScene(delegate(Scene scene)
-                        {
-                            scene.SetTimePhase(
-                                timePhase)
-                                ;
-                        });
-        }
-
-
-        public void ForceCurrentSceneClientUpdate()
-        {
-            ForEachCurrentScene(delegate(Scene scene) { scene.ForceClientUpdate(); });
-        }
-
-        public void HandleEditCommandOnCurrentScene(string[] cmdparams)
-        {
-            ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
-        }
-
-        public bool TryGetAvatar( LLUUID avatarId, out ScenePresence avatar )
-        {
-            foreach (Scene scene in m_localScenes)
-            {
-                if( scene.TryGetAvatar( avatarId, out avatar ))
-                {
-                    return true;
-                }
-            }
-
-            avatar = null;
-            return false;
-        }
-
-        public void CloseScene(Scene scene)
-        {
-            m_localScenes.Remove(scene);
-            scene.Close();
-        }
-
-        public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
-        {
-            foreach (Scene scene in m_localScenes)
-            {
-                if (scene.TryGetAvatarByName(avatarName, out avatar))
-                {
-                    return true;
-                }
-            }
-
-            avatar = null;
-            return false;
-        }
-    }
+using System;
+using System.Collections.Generic;
+using OpenSim.Framework.Console;
+using OpenSim.Framework.Types;
+using libsecondlife;
+
+namespace OpenSim.Region.Environment.Scenes
+{
+    public class SceneManager
+    {
+        private readonly List<Scene> m_localScenes;
+        private Scene m_currentScene = null;
+
+        public Scene CurrentScene
+        {
+            get { return m_currentScene; }
+        }
+
+        public Scene CurrentOrFirstScene
+        {
+            get
+            {
+                if (m_currentScene == null)
+                {
+                    return m_localScenes[0];
+                }
+                else
+                {
+                    return m_currentScene;
+                }
+            }
+        }
+
+        public SceneManager()
+        {
+            m_localScenes = new List<Scene>();
+        }
+
+        public void Close()
+        {
+            for (int i = 0; i < m_localScenes.Count; i++)
+            {
+                m_localScenes[i].Close();
+            }
+        }
+
+        public void Add(Scene scene)
+        {
+            m_localScenes.Add(scene);
+        }
+
+        public void SaveCurrentSceneToXml(string filename)
+        {
+            CurrentOrFirstScene.SavePrimsToXml(filename);
+        }
+
+        public void LoadCurrentSceneFromXml(string filename)
+        {
+            CurrentOrFirstScene.LoadPrimsFromXml(filename);
+        }
+
+        public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
+        {
+            if (m_currentScene == null)
+            {
+                bool success = true;
+                foreach (Scene scene in m_localScenes)
+                {
+                    if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
+                    {
+                        success = false;
+                    }
+                }
+
+                return success;
+            }
+            else
+            {
+                return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
+            }
+        }
+
+        public void SendCommandToCurrentSceneScripts(string[] cmdparams)
+        {
+            ForEachCurrentScene(delegate(Scene scene) { scene.SendCommandToPlugins(cmdparams); });
+        }
+
+        public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions)
+        {
+            ForEachCurrentScene(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; });
+        }
+
+        private void ForEachCurrentScene(Action<Scene> func)
+        {
+            if (m_currentScene == null)
+            {
+                m_localScenes.ForEach(func);
+            }
+            else
+            {
+                func(m_currentScene);
+            }
+        }
+
+        public void BackupCurrentScene()
+        {
+            ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
+        }
+
+        public void HandleAlertCommandOnCurrentScene(string[] cmdparams)
+        {
+            ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
+        }
+
+        public bool TrySetCurrentScene(string regionName)
+        {
+            if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
+            {
+                m_currentScene = null;
+                return true;
+            }
+            else
+            {
+                Console.WriteLine("Searching for Region: '" + regionName + "'");
+
+                foreach (Scene scene in m_localScenes)
+                {
+                    if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
+                    {
+                        m_currentScene = scene;
+                        return true;
+                    }
+                }
+
+                return false;
+            }
+        }
+
+        public void SetDebugPacketOnCurrentScene(LogBase log, int newDebug)
+        {
+            ForEachCurrentScene(delegate(Scene scene)
+                        {
+                            foreach (EntityBase entity in scene.Entities.Values)
+                            {
+                                if (entity is ScenePresence)
+                                {
+                                    ScenePresence scenePrescence = entity as ScenePresence;
+                                    if (!scenePrescence.IsChildAgent)
+                                    {
+                                        log.Error(String.Format("Packet debug for {0} {1} set to {2}",
+                                                                scenePrescence.Firstname, scenePrescence.Lastname,
+                                                                newDebug));
+
+                                        scenePrescence.ControllingClient.SetDebug(newDebug);
+                                    }
+                                }
+                            }
+                        });
+        }
+
+        public List<ScenePresence> GetCurrentSceneAvatars()
+        {
+            List<ScenePresence> avatars = new List<ScenePresence>();
+
+            ForEachCurrentScene(delegate(Scene scene)
+                        {
+                            foreach (EntityBase entity in scene.Entities.Values)
+                            {
+                                if (entity is ScenePresence)
+                                {
+                                    ScenePresence scenePrescence = entity as ScenePresence;
+                                    if (!scenePrescence.IsChildAgent)
+                                    {
+                                        avatars.Add(scenePrescence);
+                                    }
+                                }
+                            }
+                        });
+
+            return avatars;
+        }
+
+        public RegionInfo GetRegionInfo(ulong regionHandle)
+        {
+            foreach (Scene scene in m_localScenes)
+            {
+                if (scene.RegionInfo.RegionHandle == regionHandle)
+                {
+                    return scene.RegionInfo;
+                }
+            }
+
+            return null;
+        }
+
+        public void SetCurrentSceneTimePhase(int timePhase)
+        {
+            ForEachCurrentScene(delegate(Scene scene)
+                        {
+                            scene.SetTimePhase(
+                                timePhase)
+                                ;
+                        });
+        }
+
+
+        public void ForceCurrentSceneClientUpdate()
+        {
+            ForEachCurrentScene(delegate(Scene scene) { scene.ForceClientUpdate(); });
+        }
+
+        public void HandleEditCommandOnCurrentScene(string[] cmdparams)
+        {
+            ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
+        }
+
+        public bool TryGetAvatar( LLUUID avatarId, out ScenePresence avatar )
+        {
+            foreach (Scene scene in m_localScenes)
+            {
+                if( scene.TryGetAvatar( avatarId, out avatar ))
+                {
+                    return true;
+                }
+            }
+
+            avatar = null;
+            return false;
+        }
+
+        public void CloseScene(Scene scene)
+        {
+            m_localScenes.Remove(scene);
+            scene.Close();
+        }
+
+        public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
+        {
+            foreach (Scene scene in m_localScenes)
+            {
+                if (scene.TryGetAvatarByName(avatarName, out avatar))
+                {
+                    return true;
+                }
+            }
+
+            avatar = null;
+            return false;
+        }
+    }
 }
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs
index dbd43be..baaeb86 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs
@@ -1,6 +1,6 @@
-using Axiom.Math;
-using libsecondlife;
-
+using Axiom.Math;
+using libsecondlife;
+
 namespace OpenSim.Region.Environment.Scenes.Scripting
 {
     public interface IScriptHost
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
index 6876cfb..2337aba 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
@@ -1,13 +1,13 @@
-using System;
-using Axiom.Math;
-using libsecondlife;
-
+using System;
+using Axiom.Math;
+using libsecondlife;
+
 namespace OpenSim.Region.Environment.Scenes.Scripting
 {
     public class NullScriptHost : IScriptHost
-    {
-        private LLVector3 m_pos = new LLVector3(128, 128, 30);
-
+    {
+        private LLVector3 m_pos = new LLVector3(128, 128, 30);
+
         public string Name
         {
             get { return "Object"; }
@@ -38,13 +38,13 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
         }
 
         public LLUUID ObjectOwner
-        {
-            get { return LLUUID.Zero; }
+        {
+            get { return LLUUID.Zero; }
         }
 
-        public LLUUID ObjectCreator
-        {
-            get { return LLUUID.Zero; }
+        public LLUUID ObjectCreator
+        {
+            get { return LLUUID.Zero; }
         }
 
         public LLVector3 AbsolutePosition
diff --git a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs
index 0b815ba..2b8d92e 100644
--- a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs
+++ b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
-using OpenSim.Region.Environment.Scenes;
-
+using System.Collections.Generic;
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment.Types
 {
     public class BasicQuadTreeNode
@@ -64,16 +64,16 @@ namespace OpenSim.Region.Environment.Types
             if (m_childNodes == null)
             {
                 m_childNodes = new BasicQuadTreeNode[4];
-                m_childNodes[0] =
+                m_childNodes[0] =
                     new BasicQuadTreeNode(this, m_leftX, m_leftY, (short) (m_width/2), (short) (m_height/2));
-                m_childNodes[1] =
-                    new BasicQuadTreeNode(this, (short) (m_leftX + (m_width/2)), m_leftY, (short) (m_width/2),
+                m_childNodes[1] =
+                    new BasicQuadTreeNode(this, (short) (m_leftX + (m_width/2)), m_leftY, (short) (m_width/2),
                                           (short) (m_height/2));
-                m_childNodes[2] =
-                    new BasicQuadTreeNode(this, m_leftX, (short) (m_leftY + (m_height/2)), (short) (m_width/2),
+                m_childNodes[2] =
+                    new BasicQuadTreeNode(this, m_leftX, (short) (m_leftY + (m_height/2)), (short) (m_width/2),
                                           (short) (m_height/2));
-                m_childNodes[3] =
-                    new BasicQuadTreeNode(this, (short) (m_leftX + (m_width/2)), (short) (m_height + (m_height/2)),
+                m_childNodes[3] =
+                    new BasicQuadTreeNode(this, (short) (m_leftX + (m_width/2)), (short) (m_height + (m_height/2)),
                                           (short) (m_width/2), (short) (m_height/2));
             }
             else
@@ -132,7 +132,7 @@ namespace OpenSim.Region.Environment.Types
                 List<SceneObjectGroup> outBounds = new List<SceneObjectGroup>();
                 foreach (SceneObjectGroup group in m_objects)
                 {
-                    if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) &&
+                    if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) &&
                         ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height))))
                     {
                         //still in bounds
@@ -157,7 +157,7 @@ namespace OpenSim.Region.Environment.Types
 
         public void PassUp(SceneObjectGroup group)
         {
-            if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) &&
+            if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) &&
                 ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height))))
             {
                 AddObject(group);
diff --git a/OpenSim/Region/Environment/Types/UpdateQueue.cs b/OpenSim/Region/Environment/Types/UpdateQueue.cs
index 6e26aaf..c1fb161 100644
--- a/OpenSim/Region/Environment/Types/UpdateQueue.cs
+++ b/OpenSim/Region/Environment/Types/UpdateQueue.cs
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
-using libsecondlife;
-using OpenSim.Region.Environment.Scenes;
-
+using System.Collections.Generic;
+using libsecondlife;
+using OpenSim.Region.Environment.Scenes;
+
 namespace OpenSim.Region.Environment.Types
 {
     public class UpdateQueue
@@ -46,6 +46,6 @@ namespace OpenSim.Region.Environment.Types
             }
 
             return part;
-        }
+        }
     }
 }
\ No newline at end of file
diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs
index d2bf919..61e9114 100644
--- a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs
+++ b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs
@@ -1,148 +1,148 @@
-/*
-* Copyright (c) Contributors, http://opensimulator.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*     * Redistributions of source code must retain the above copyright
-*       notice, this list of conditions and the following disclaimer.
-*     * Redistributions in binary form must reproduce the above copyright
-*       notice, this list of conditions and the following disclaimer in the
-*       documentation and/or other materials provided with the distribution.
-*     * Neither the name of the OpenSim Project nor the
-*       names of its contributors may be used to endorse or promote products
-*       derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-* 
-*/
-using System.Collections.Generic;
-using OpenSim.Framework.Console;
-using OpenSim.Region.Environment.Interfaces;
-using OpenSim.Region.Environment.Scenes;
-using OpenSim.Region.ExtensionsScriptModule.CSharp;
-using OpenSim.Region.ExtensionsScriptModule.JScript;
-using OpenSim.Region.ExtensionsScriptModule.JVMEngine;
-
-namespace OpenSim.Region.ExtensionsScriptModule
-{
-    public class ScriptManager : IRegionModule, IExtensionScriptModule
-    {
-        readonly List<IScript> scripts = new List<IScript>();
-        Scene m_scene;
-        readonly Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>();
-
-        private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts)
-        {
-            foreach (KeyValuePair<string, IScript> script in compiledscripts)
-            {
-                ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
-                MainLog.Instance.Verbose("Loading " + script.Key);
-                script.Value.Initialise(scriptInfo);
-                scripts.Add(script.Value);
-            }
-
-            MainLog.Instance.Verbose(string.Format("Finished loading {0} script(s)", compiledscripts.Count));
-        }
-
-        public ScriptManager()
-        {
-            // Default Engines
-            CSharpScriptEngine csharpCompiler = new CSharpScriptEngine();
-            compilers.Add(csharpCompiler.FileExt(), csharpCompiler);
-
-            JScriptEngine jscriptCompiler = new JScriptEngine();
-            compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler);
-
-            JavaEngine javaCompiler = new JavaEngine();
-            compilers.Add(javaCompiler.FileExt(), javaCompiler);
-        }
-
-        public void Initialise(Scene scene)
-        {
-            System.Console.WriteLine("Initialising Extensions Scripting Module");
-            m_scene = scene;
-
-            m_scene.RegisterModuleInterface<IExtensionScriptModule>(this);
-        }
-
-        public void PostInitialise()
-        {
-
-        }
-
-        public void CloseDown()
-        {
-
-        }
-
-        public string GetName()
-        {
-            return "ExtensionsScriptingModule";
-        }
-
-        public bool IsSharedModule()
-        {
-            return false;
-        }
-
-        public bool Compile(string filename)
-        {
-            foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers)
-            {
-                if (filename.EndsWith(compiler.Key))
-                {
-                    LoadFromCompiler(compiler.Value.compile(filename));
-                    break;
-                }
-            }
-
-            return true;
-        }
-
-        public void RunScriptCmd(string[] args)
-        {
-            switch (args[0])
-            {
-                case "load":
-                    Compile(args[1]);
-                    break;
-
-                default:
-                    MainLog.Instance.Error("Unknown script command");
-                    break;
-            }
-        }
-
-        public bool AddPreCompiledScript(IScript script)
-        {
-            MainLog.Instance.Verbose("Loading script " + script.Name);
-            ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
-            script.Initialise(scriptInfo);
-            scripts.Add(script);
-
-            return true;
-        }
-    }
-
-    public interface IExtensionScriptModule
-    {
-        bool Compile(string filename);
-        bool AddPreCompiledScript(IScript script);
-    }
-
-    interface IScriptCompiler
-    {
-        Dictionary<string, IScript> compile(string filename);
-        string FileExt();
-    }
-}
+/*
+* Copyright (c) Contributors, http://opensimulator.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*     * Redistributions of source code must retain the above copyright
+*       notice, this list of conditions and the following disclaimer.
+*     * Redistributions in binary form must reproduce the above copyright
+*       notice, this list of conditions and the following disclaimer in the
+*       documentation and/or other materials provided with the distribution.
+*     * Neither the name of the OpenSim Project nor the
+*       names of its contributors may be used to endorse or promote products
+*       derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* 
+*/
+using System.Collections.Generic;
+using OpenSim.Framework.Console;
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+using OpenSim.Region.ExtensionsScriptModule.CSharp;
+using OpenSim.Region.ExtensionsScriptModule.JScript;
+using OpenSim.Region.ExtensionsScriptModule.JVMEngine;
+
+namespace OpenSim.Region.ExtensionsScriptModule
+{
+    public class ScriptManager : IRegionModule, IExtensionScriptModule
+    {
+        readonly List<IScript> scripts = new List<IScript>();
+        Scene m_scene;
+        readonly Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>();
+
+        private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts)
+        {
+            foreach (KeyValuePair<string, IScript> script in compiledscripts)
+            {
+                ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
+                MainLog.Instance.Verbose("Loading " + script.Key);
+                script.Value.Initialise(scriptInfo);
+                scripts.Add(script.Value);
+            }
+
+            MainLog.Instance.Verbose(string.Format("Finished loading {0} script(s)", compiledscripts.Count));
+        }
+
+        public ScriptManager()
+        {
+            // Default Engines
+            CSharpScriptEngine csharpCompiler = new CSharpScriptEngine();
+            compilers.Add(csharpCompiler.FileExt(), csharpCompiler);
+
+            JScriptEngine jscriptCompiler = new JScriptEngine();
+            compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler);
+
+            JavaEngine javaCompiler = new JavaEngine();
+            compilers.Add(javaCompiler.FileExt(), javaCompiler);
+        }
+
+        public void Initialise(Scene scene)
+        {
+            System.Console.WriteLine("Initialising Extensions Scripting Module");
+            m_scene = scene;
+
+            m_scene.RegisterModuleInterface<IExtensionScriptModule>(this);
+        }
+
+        public void PostInitialise()
+        {
+
+        }
+
+        public void CloseDown()
+        {
+
+        }
+
+        public string GetName()
+        {
+            return "ExtensionsScriptingModule";
+        }
+
+        public bool IsSharedModule()
+        {
+            return false;
+        }
+
+        public bool Compile(string filename)
+        {
+            foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers)
+            {
+                if (filename.EndsWith(compiler.Key))
+                {
+                    LoadFromCompiler(compiler.Value.compile(filename));
+                    break;
+                }
+            }
+
+            return true;
+        }
+
+        public void RunScriptCmd(string[] args)
+        {
+            switch (args[0])
+            {
+                case "load":
+                    Compile(args[1]);
+                    break;
+
+                default:
+                    MainLog.Instance.Error("Unknown script command");
+                    break;
+            }
+        }
+
+        public bool AddPreCompiledScript(IScript script)
+        {
+            MainLog.Instance.Verbose("Loading script " + script.Name);
+            ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
+            script.Initialise(scriptInfo);
+            scripts.Add(script);
+
+            return true;
+        }
+    }
+
+    public interface IExtensionScriptModule
+    {
+        bool Compile(string filename);
+        bool AddPreCompiledScript(IScript script);
+    }
+
+    interface IScriptCompiler
+    {
+        Dictionary<string, IScript> compile(string filename);
+        string FileExt();
+    }
+}
diff --git a/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs
index 28dca41..ce3ba5c 100644
--- a/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs
@@ -1,560 +1,560 @@
-using System;
-using System.Globalization;
-using System.Diagnostics;
-using System.Collections.Generic;
-using System.Text;
-using System.Runtime.InteropServices;
-
-using OpenSim.Framework.Types;
-using OpenSim.Region.Physics.Manager;
-
-namespace OpenSim.Region.Physics.OdePlugin
-{
-    public class Mesh
-    {
-        public List<Vertex> vertices;
-        public List<Triangle> triangles;
-
-        public float[] normals;
-
-        public Mesh()
-        {
-            vertices = new List<Vertex>();
-            triangles = new List<Triangle>();
-        }
-
-        public void Add(Triangle triangle)
-        {
-            int i;
-            i = vertices.IndexOf(triangle.v1);
-            if (i < 0)
-                throw new ArgumentException("Vertex v1 not known to mesh");
-            i = vertices.IndexOf(triangle.v2);
-            if (i < 0)
-                throw new ArgumentException("Vertex v2 not known to mesh");
-            i = vertices.IndexOf(triangle.v3);
-            if (i < 0)
-                throw new ArgumentException("Vertex v3 not known to mesh");
-
-            triangles.Add(triangle);
-        }
-
-        public void Add(Vertex v)
-        {
-            vertices.Add(v);
-        }
-
-
-        public float[] getVertexListAsFloat()
-        {
-            float[] result = new float[vertices.Count * 3];
-            for (int i = 0; i < vertices.Count; i++)
-            {
-                Vertex v = vertices[i];
-                PhysicsVector point = v.point;
-                result[3 * i + 0] = point.X;
-                result[3 * i + 1] = point.Y;
-                result[3 * i + 2] = point.Z;
-            }
-            GCHandle.Alloc(result, GCHandleType.Pinned);
-            return result;
-        }
-
-        public int[] getIndexListAsInt()
-        {
-            int[] result = new int[triangles.Count * 3];
-            for (int i = 0; i < triangles.Count; i++)
-            {
-                Triangle t = triangles[i];
-                result[3 * i + 0] = vertices.IndexOf(t.v1);
-                result[3 * i + 1] = vertices.IndexOf(t.v2);
-                result[3 * i + 2] = vertices.IndexOf(t.v3);
-            }
-            GCHandle.Alloc(result, GCHandleType.Pinned);
-            return result;
-        }
-
-
-        public void Append(Mesh newMesh)
-        {
-            foreach (Vertex v in newMesh.vertices)
-                vertices.Add(v);
-
-            foreach (Triangle t in newMesh.triangles)
-                Add(t);
-
-        }
-    }
-
-
-
-    public class Meshmerizer
-    {
-
-        static List<Triangle> FindInfluencedTriangles(List<Triangle> triangles, Vertex v) 
-        {
-            List<Triangle> influenced = new List<Triangle>();
-            foreach (Triangle t in triangles)
-            {
-                float dx, dy;
-
-                if (t.isInCircle(v.point.X, v.point.Y))
-                {
-                    influenced.Add(t);
-                }
-            }
-            return influenced;
-        }
-        
-        
-        static void InsertVertices(List<Vertex> vertices, int usedForSeed, List<Triangle> triangles, List<int> innerBorders) 
-        {
-            // This is a variant of the delaunay algorithm
-            // each time a new vertex is inserted, all triangles that are influenced by it are deleted
-            // and replaced by new ones including the new vertex
-            // It is not very time efficient but easy to implement.
-
-            int iCurrentVertex;
-            int iMaxVertex=vertices.Count;
-            for (iCurrentVertex = usedForSeed; iCurrentVertex < iMaxVertex; iCurrentVertex++)
-            {
-                // Background: A triangle mesh fulfills the delaunay condition if (iff!)
-                // each circumlocutory circle (i.e. the circle that touches all three corners) 
-                // of each triangle is empty of other vertices.
-                // Obviously a single (seeding) triangle fulfills this condition.
-                // If we now add one vertex, we need to reconstruct all triangles, that
-                // do not fulfill this condition with respect to the new triangle
-
-                // Find the triangles that are influenced by the new vertex
-                Vertex v=vertices[iCurrentVertex];
-                List<Triangle> influencedTriangles=FindInfluencedTriangles(triangles, v);
-
-                List<Simplex> simplices = new List<Simplex>();
-
-                // Reconstruction phase. First step, dissolve each triangle into it's simplices,
-                // i.e. it's "border lines"
-                // Goal is to find "inner" borders and delete them, while the hull gets conserved.
-                // Inner borders are special in the way that they always come twice, which is how we detect them 
-                foreach (Triangle t in influencedTriangles)
-                {
-                    List<Simplex> newSimplices = t.GetSimplices();
-                    simplices.AddRange(newSimplices);
-                    triangles.Remove(t);
-                }
-                // Now sort the simplices. That will make identical ones side by side in the list
-                simplices.Sort();
-
-                // Look for duplicate simplices here. 
-                // Remember, they are directly side by side in the list right now
-                int iSimplex;
-                List<Simplex> innerSimplices=new List<Simplex>();
-                for (iSimplex = 1; iSimplex < simplices.Count; iSimplex++) // Startindex=1, so we can refer backwards
-                {
-                    if (simplices[iSimplex - 1].CompareTo(simplices[iSimplex])==0)
-                    {
-                        innerSimplices.Add(simplices[iSimplex - 1]);
-                        innerSimplices.Add(simplices[iSimplex]);
-                    }
-                }
-
-                foreach (Simplex s in innerSimplices)
-                {
-                        simplices.Remove(s);
-                }
-
-                // each simplex still in the list belongs to the hull of the region in question
-                // The new vertex (yes, we still deal with verices here :-) ) forms a triangle 
-                // With each of these simplices. Build the new triangles and add them to the list
-                foreach (Simplex s in simplices)
-                {
-                    Triangle t = new Triangle(s.v1, s.v2, vertices[iCurrentVertex]);
-                    triangles.Add(t);
-                }
-            }
-
-            // At this point all vertices should be inserted into the mesh
-            // But the areas, that should be kept free still are filled with triangles
-            // We have to remove them. For this we have a list of indices to vertices.
-            // Each triangle that solemnly constists of vertices from the inner border
-            // are deleted
-
-            List<Triangle> innerTriangles = new List<Triangle>();
-            foreach (Triangle t in triangles)
-            {
-                if (
-                       innerBorders.Contains(vertices.IndexOf(t.v1))
-                    && innerBorders.Contains(vertices.IndexOf(t.v2))
-                    && innerBorders.Contains(vertices.IndexOf(t.v3))
-                    )
-                    innerTriangles.Add(t);
-            }
-            foreach (Triangle t in innerTriangles)
-            {
-                triangles.Remove(t);
-            }
-        }
-
-
-        static Mesh CreateBoxMeshX(PrimitiveBaseShape primShape, PhysicsVector size)
-        // Builds the x (+ and -) surfaces of a box shaped prim
-        {
-            UInt16 hollowFactor = primShape.ProfileHollow;
-            Mesh meshMX = new Mesh();
-
-
-            // Surface 0, -X
-            meshMX.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
-            meshMX.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
-            meshMX.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
-            meshMX.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
-
-            meshMX.Add(new Triangle(meshMX.vertices[0], meshMX.vertices[2], meshMX.vertices[1]));
-            meshMX.Add(new Triangle(meshMX.vertices[1], meshMX.vertices[2], meshMX.vertices[3]));
-
-
-            Mesh meshPX = new Mesh();
-            // Surface 1, +X
-            meshPX.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
-            meshPX.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
-            meshPX.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
-            meshPX.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
-
-
-            meshPX.Add(new Triangle(meshPX.vertices[0], meshPX.vertices[1], meshPX.vertices[2]));
-            meshPX.Add(new Triangle(meshPX.vertices[2], meshPX.vertices[1], meshPX.vertices[3]));
-
-
-            if (hollowFactor > 0)
-            {
-                float hollowFactorF = (float)hollowFactor / (float)50000;
-
-                Vertex IPP;
-                Vertex IPM;
-                Vertex IMP;
-                Vertex IMM;
-
-                IPP = new Vertex("Inner-X+Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
-                IPM = new Vertex("Inner-X+Y-Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
-                IMP = new Vertex("Inner-X-Y+Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
-                IMM = new Vertex("Inner-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
-
-                meshMX.Add(IPP);
-                meshMX.Add(IPM);
-                meshMX.Add(IMP);
-                meshMX.Add(IMM);
-
-                meshMX.Add(new Triangle(IPP, IMP, IPM));
-                meshMX.Add(new Triangle(IPM, IMP, IMM));
-
-                foreach (Triangle t in meshMX.triangles)
-                {
-                    PhysicsVector n = t.getNormal();
-                }
-
-
-
-                IPP = new Vertex("Inner+X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
-                IPM = new Vertex("Inner+X+Y-Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
-                IMP = new Vertex("Inner+X-Y+Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
-                IMM = new Vertex("Inner+X-Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
-
-                meshPX.Add(IPP);
-                meshPX.Add(IPM);
-                meshPX.Add(IMP);
-                meshPX.Add(IMM);
-
-                meshPX.Add(new Triangle(IPP, IPM, IMP));
-                meshPX.Add(new Triangle(IMP, IPM, IMM));
-
-                foreach (Triangle t in meshPX.triangles)
-                {
-                    PhysicsVector n = t.getNormal();
-                }
-            }
-
-            Mesh result = new Mesh();
-            result.Append(meshMX);
-            result.Append(meshPX);
-
-            return result;
-        }
-
-
-
-        static Mesh CreateBoxMeshY(PrimitiveBaseShape primShape, PhysicsVector size)
-        // Builds the y (+ and -) surfaces of a box shaped prim
-        {
-            UInt16 hollowFactor = primShape.ProfileHollow;
-
-            // (M)inus Y
-            Mesh MeshMY = new Mesh();
-            MeshMY.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
-            MeshMY.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
-            MeshMY.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
-            MeshMY.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
-
-            MeshMY.Add(new Triangle(MeshMY.vertices[0], MeshMY.vertices[1], MeshMY.vertices[2]));
-            MeshMY.Add(new Triangle(MeshMY.vertices[2], MeshMY.vertices[1], MeshMY.vertices[3]));
-
-            // (P)lus Y
-            Mesh MeshPY = new Mesh();
-
-            MeshPY.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
-            MeshPY.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
-            MeshPY.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
-            MeshPY.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
-
-            MeshPY.Add(new Triangle(MeshPY.vertices[1], MeshPY.vertices[0], MeshPY.vertices[2]));
-            MeshPY.Add(new Triangle(MeshPY.vertices[1], MeshPY.vertices[2], MeshPY.vertices[3]));
-
-            if (hollowFactor > 0)
-            {
-                float hollowFactorF = (float)hollowFactor / (float)50000;
-
-                Vertex IPP;
-                Vertex IPM;
-                Vertex IMP;
-                Vertex IMM;
-
-                IPP = new Vertex("Inner+X-Y+Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
-                IPM = new Vertex("Inner+X-Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
-                IMP = new Vertex("Inner-X-Y+Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
-                IMM = new Vertex("Inner-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
-
-                MeshMY.Add(IPP);
-                MeshMY.Add(IPM);
-                MeshMY.Add(IMP);
-                MeshMY.Add(IMM);
-
-                MeshMY.Add(new Triangle(IPP, IPM, IMP));
-                MeshMY.Add(new Triangle(IMP, IPM, IMM));
-
-                foreach (Triangle t in MeshMY.triangles)
-                {
-                    PhysicsVector n = t.getNormal();
-                }
-
-
-
-                IPP = new Vertex("Inner+X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
-                IPM=new Vertex("Inner+X+Y-Z", +size.X * hollowFactorF / 2.0f, +size.Y  * hollowFactorF / 2.0f, -size.Z / 2.0f);
-                IMP=new Vertex("Inner-X+Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y  * hollowFactorF / 2.0f, +size.Z / 2.0f);
-                IMM=new Vertex("Inner-X+Y-Z", -size.X * hollowFactorF / 2.0f, +size.Y  * hollowFactorF / 2.0f, -size.Z / 2.0f);
-
-                MeshPY.Add(IPP);
-                MeshPY.Add(IPM);
-                MeshPY.Add(IMP);
-                MeshPY.Add(IMM);
-
-                MeshPY.Add(new Triangle(IPM, IPP, IMP));
-                MeshPY.Add(new Triangle(IMP, IMM, IPM));
-
-                foreach (Triangle t in MeshPY.triangles)
-                {
-                    PhysicsVector n = t.getNormal();
-                }
-
-
-
-            }
-
-
-            Mesh result = new Mesh();
-            result.Append(MeshMY);
-            result.Append(MeshPY);
-
-            return result;
-        }
-            
-        static Mesh CreateBoxMeshZ(PrimitiveBaseShape primShape, PhysicsVector size)
-        // Builds the z (+ and -) surfaces of a box shaped prim
-        {
-            UInt16 hollowFactor = primShape.ProfileHollow;
-
-            // Base, i.e. outer shape
-            // (M)inus Z
-            Mesh MZ = new Mesh();
-
-            MZ.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
-            MZ.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
-            MZ.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
-            MZ.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
-
-
-            MZ.Add(new Triangle(MZ.vertices[1], MZ.vertices[0], MZ.vertices[2]));
-            MZ.Add(new Triangle(MZ.vertices[1], MZ.vertices[2], MZ.vertices[3]));
-
-            // (P)lus Z
-            Mesh PZ = new Mesh();
-
-            PZ.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, 0.0f));
-            PZ.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, 0.0f));
-            PZ.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, 0.0f));
-            PZ.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, 0.0f));
-
-            // Surface 5, +Z
-            PZ.Add(new Triangle(PZ.vertices[0], PZ.vertices[1], PZ.vertices[2]));
-            PZ.Add(new Triangle(PZ.vertices[2], PZ.vertices[1], PZ.vertices[3]));
-
-            if (hollowFactor > 0)
-            {
-                float hollowFactorF = (float)hollowFactor / (float)50000;
-
-                MZ.Add(new Vertex("-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
-                MZ.Add(new Vertex("-X+Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
-                MZ.Add(new Vertex("-X-Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
-                MZ.Add(new Vertex("-X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
-
-                List<int> innerBorders = new List<int>();
-                innerBorders.Add(4);
-                innerBorders.Add(5);
-                innerBorders.Add(6);
-                innerBorders.Add(7);
-
-                InsertVertices(MZ.vertices, 4, MZ.triangles, innerBorders);
-
-                PZ.Add(new Vertex("-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
-                PZ.Add(new Vertex("-X+Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
-                PZ.Add(new Vertex("-X-Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
-                PZ.Add(new Vertex("-X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
-
-                innerBorders = new List<int>();
-                innerBorders.Add(4);
-                innerBorders.Add(5);
-                innerBorders.Add(6);
-                innerBorders.Add(7);
-
-                InsertVertices(PZ.vertices, 4, PZ.triangles, innerBorders);
-
-            }
-
-            foreach (Vertex v in PZ.vertices)
-            {
-                v.point.Z = size.Z / 2.0f;
-            }
-            foreach (Vertex v in MZ.vertices)
-            {
-                v.point.Z = -size.Z / 2.0f;
-            }
-
-            foreach (Triangle t in MZ.triangles)
-            {
-                PhysicsVector n = t.getNormal();
-                if (n.Z > 0.0)
-                    t.invertNormal();
-            }
-
-            foreach (Triangle t in PZ.triangles)
-            {
-                PhysicsVector n = t.getNormal();
-                if (n.Z < 0.0)
-                    t.invertNormal();
-            }
-
-            Mesh result = new Mesh();
-            result.Append(MZ);
-            result.Append(PZ);
-
-            return result;
-        }
-
-        static Mesh CreateBoxMesh(PrimitiveBaseShape primShape, PhysicsVector size)
-        {
-            Mesh result = new Mesh();
-
-
-
-            Mesh MeshX = Meshmerizer.CreateBoxMeshX(primShape, size);
-            Mesh MeshY = Meshmerizer.CreateBoxMeshY(primShape, size);
-            Mesh MeshZ = Meshmerizer.CreateBoxMeshZ(primShape, size);
-
-            result.Append(MeshX);
-            result.Append(MeshY);
-            result.Append(MeshZ);
-
-            return result;
-        }
-
-
-        public static void CalcNormals(Mesh mesh) 
-        {
-            int iTriangles = mesh.triangles.Count;
-
-            mesh.normals = new float[iTriangles*3];
-
-            int i=0;
-            foreach (Triangle t in mesh.triangles)
-            {
-
-                float ux, uy, uz;
-                float vx, vy, vz;
-                float wx, wy, wz;
-
-                    ux = t.v1.point.X;
-                    uy = t.v1.point.Y;
-                    uz = t.v1.point.Z;
-
-                    vx = t.v2.point.X;
-                    vy = t.v2.point.Y;
-                    vz = t.v2.point.Z;
-
-                    wx = t.v3.point.X;
-                    wy = t.v3.point.Y;
-                    wz = t.v3.point.Z;
-
-                    // Vectors for edges
-                    float e1x, e1y, e1z;
-                    float e2x, e2y, e2z;
-
-                    e1x = ux - vx;
-                    e1y = uy - vy;
-                    e1z = uz - vz;
-
-                    e2x = ux - wx;
-                    e2y = uy - wy;
-                    e2z = uz - wz;
-
-
-                    // Cross product for normal
-                    float nx, ny, nz;
-                    nx = e1y * e2z - e1z * e2y;
-                    ny = e1z * e2x - e1x * e2z;
-                    nz = e1x * e2y - e1y * e2x;
-
-                    // Length
-                    float l = (float)Math.Sqrt(nx * nx + ny * ny + nz * nz);
-
-                    // Normalized "normal"
-                    nx /= l;
-                    ny /= l;
-                    nz /= l;
-
-                mesh.normals[i] = nx;
-                mesh.normals[i + 1] = ny;
-                mesh.normals[i + 2] = nz;
-
-                i+=3;
-            }
-        }
-
-        public static Mesh CreateMesh(PrimitiveBaseShape primShape, PhysicsVector size)
-        {
-            Mesh mesh = null;
-
-            switch (primShape.ProfileShape)
-            {
-                case ProfileShape.Square:
-                    mesh=CreateBoxMesh(primShape, size);
-                    CalcNormals(mesh);
-                    break;
-                default:
-                    mesh=null;
-                    break;
-            }
-
-            return mesh;
-
-        }
-    }
-}
-
+using System;
+using System.Globalization;
+using System.Diagnostics;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+
+using OpenSim.Framework.Types;
+using OpenSim.Region.Physics.Manager;
+
+namespace OpenSim.Region.Physics.OdePlugin
+{
+    public class Mesh
+    {
+        public List<Vertex> vertices;
+        public List<Triangle> triangles;
+
+        public float[] normals;
+
+        public Mesh()
+        {
+            vertices = new List<Vertex>();
+            triangles = new List<Triangle>();
+        }
+
+        public void Add(Triangle triangle)
+        {
+            int i;
+            i = vertices.IndexOf(triangle.v1);
+            if (i < 0)
+                throw new ArgumentException("Vertex v1 not known to mesh");
+            i = vertices.IndexOf(triangle.v2);
+            if (i < 0)
+                throw new ArgumentException("Vertex v2 not known to mesh");
+            i = vertices.IndexOf(triangle.v3);
+            if (i < 0)
+                throw new ArgumentException("Vertex v3 not known to mesh");
+
+            triangles.Add(triangle);
+        }
+
+        public void Add(Vertex v)
+        {
+            vertices.Add(v);
+        }
+
+
+        public float[] getVertexListAsFloat()
+        {
+            float[] result = new float[vertices.Count * 3];
+            for (int i = 0; i < vertices.Count; i++)
+            {
+                Vertex v = vertices[i];
+                PhysicsVector point = v.point;
+                result[3 * i + 0] = point.X;
+                result[3 * i + 1] = point.Y;
+                result[3 * i + 2] = point.Z;
+            }
+            GCHandle.Alloc(result, GCHandleType.Pinned);
+            return result;
+        }
+
+        public int[] getIndexListAsInt()
+        {
+            int[] result = new int[triangles.Count * 3];
+            for (int i = 0; i < triangles.Count; i++)
+            {
+                Triangle t = triangles[i];
+                result[3 * i + 0] = vertices.IndexOf(t.v1);
+                result[3 * i + 1] = vertices.IndexOf(t.v2);
+                result[3 * i + 2] = vertices.IndexOf(t.v3);
+            }
+            GCHandle.Alloc(result, GCHandleType.Pinned);
+            return result;
+        }
+
+
+        public void Append(Mesh newMesh)
+        {
+            foreach (Vertex v in newMesh.vertices)
+                vertices.Add(v);
+
+            foreach (Triangle t in newMesh.triangles)
+                Add(t);
+
+        }
+    }
+
+
+
+    public class Meshmerizer
+    {
+
+        static List<Triangle> FindInfluencedTriangles(List<Triangle> triangles, Vertex v) 
+        {
+            List<Triangle> influenced = new List<Triangle>();
+            foreach (Triangle t in triangles)
+            {
+                float dx, dy;
+
+                if (t.isInCircle(v.point.X, v.point.Y))
+                {
+                    influenced.Add(t);
+                }
+            }
+            return influenced;
+        }
+        
+        
+        static void InsertVertices(List<Vertex> vertices, int usedForSeed, List<Triangle> triangles, List<int> innerBorders) 
+        {
+            // This is a variant of the delaunay algorithm
+            // each time a new vertex is inserted, all triangles that are influenced by it are deleted
+            // and replaced by new ones including the new vertex
+            // It is not very time efficient but easy to implement.
+
+            int iCurrentVertex;
+            int iMaxVertex=vertices.Count;
+            for (iCurrentVertex = usedForSeed; iCurrentVertex < iMaxVertex; iCurrentVertex++)
+            {
+                // Background: A triangle mesh fulfills the delaunay condition if (iff!)
+                // each circumlocutory circle (i.e. the circle that touches all three corners) 
+                // of each triangle is empty of other vertices.
+                // Obviously a single (seeding) triangle fulfills this condition.
+                // If we now add one vertex, we need to reconstruct all triangles, that
+                // do not fulfill this condition with respect to the new triangle
+
+                // Find the triangles that are influenced by the new vertex
+                Vertex v=vertices[iCurrentVertex];
+                List<Triangle> influencedTriangles=FindInfluencedTriangles(triangles, v);
+
+                List<Simplex> simplices = new List<Simplex>();
+
+                // Reconstruction phase. First step, dissolve each triangle into it's simplices,
+                // i.e. it's "border lines"
+                // Goal is to find "inner" borders and delete them, while the hull gets conserved.
+                // Inner borders are special in the way that they always come twice, which is how we detect them 
+                foreach (Triangle t in influencedTriangles)
+                {
+                    List<Simplex> newSimplices = t.GetSimplices();
+                    simplices.AddRange(newSimplices);
+                    triangles.Remove(t);
+                }
+                // Now sort the simplices. That will make identical ones side by side in the list
+                simplices.Sort();
+
+                // Look for duplicate simplices here. 
+                // Remember, they are directly side by side in the list right now
+                int iSimplex;
+                List<Simplex> innerSimplices=new List<Simplex>();
+                for (iSimplex = 1; iSimplex < simplices.Count; iSimplex++) // Startindex=1, so we can refer backwards
+                {
+                    if (simplices[iSimplex - 1].CompareTo(simplices[iSimplex])==0)
+                    {
+                        innerSimplices.Add(simplices[iSimplex - 1]);
+                        innerSimplices.Add(simplices[iSimplex]);
+                    }
+                }
+
+                foreach (Simplex s in innerSimplices)
+                {
+                        simplices.Remove(s);
+                }
+
+                // each simplex still in the list belongs to the hull of the region in question
+                // The new vertex (yes, we still deal with verices here :-) ) forms a triangle 
+                // With each of these simplices. Build the new triangles and add them to the list
+                foreach (Simplex s in simplices)
+                {
+                    Triangle t = new Triangle(s.v1, s.v2, vertices[iCurrentVertex]);
+                    triangles.Add(t);
+                }
+            }
+
+            // At this point all vertices should be inserted into the mesh
+            // But the areas, that should be kept free still are filled with triangles
+            // We have to remove them. For this we have a list of indices to vertices.
+            // Each triangle that solemnly constists of vertices from the inner border
+            // are deleted
+
+            List<Triangle> innerTriangles = new List<Triangle>();
+            foreach (Triangle t in triangles)
+            {
+                if (
+                       innerBorders.Contains(vertices.IndexOf(t.v1))
+                    && innerBorders.Contains(vertices.IndexOf(t.v2))
+                    && innerBorders.Contains(vertices.IndexOf(t.v3))
+                    )
+                    innerTriangles.Add(t);
+            }
+            foreach (Triangle t in innerTriangles)
+            {
+                triangles.Remove(t);
+            }
+        }
+
+
+        static Mesh CreateBoxMeshX(PrimitiveBaseShape primShape, PhysicsVector size)
+        // Builds the x (+ and -) surfaces of a box shaped prim
+        {
+            UInt16 hollowFactor = primShape.ProfileHollow;
+            Mesh meshMX = new Mesh();
+
+
+            // Surface 0, -X
+            meshMX.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
+            meshMX.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
+            meshMX.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
+            meshMX.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
+
+            meshMX.Add(new Triangle(meshMX.vertices[0], meshMX.vertices[2], meshMX.vertices[1]));
+            meshMX.Add(new Triangle(meshMX.vertices[1], meshMX.vertices[2], meshMX.vertices[3]));
+
+
+            Mesh meshPX = new Mesh();
+            // Surface 1, +X
+            meshPX.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
+            meshPX.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
+            meshPX.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
+            meshPX.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
+
+
+            meshPX.Add(new Triangle(meshPX.vertices[0], meshPX.vertices[1], meshPX.vertices[2]));
+            meshPX.Add(new Triangle(meshPX.vertices[2], meshPX.vertices[1], meshPX.vertices[3]));
+
+
+            if (hollowFactor > 0)
+            {
+                float hollowFactorF = (float)hollowFactor / (float)50000;
+
+                Vertex IPP;
+                Vertex IPM;
+                Vertex IMP;
+                Vertex IMM;
+
+                IPP = new Vertex("Inner-X+Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
+                IPM = new Vertex("Inner-X+Y-Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
+                IMP = new Vertex("Inner-X-Y+Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
+                IMM = new Vertex("Inner-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
+
+                meshMX.Add(IPP);
+                meshMX.Add(IPM);
+                meshMX.Add(IMP);
+                meshMX.Add(IMM);
+
+                meshMX.Add(new Triangle(IPP, IMP, IPM));
+                meshMX.Add(new Triangle(IPM, IMP, IMM));
+
+                foreach (Triangle t in meshMX.triangles)
+                {
+                    PhysicsVector n = t.getNormal();
+                }
+
+
+
+                IPP = new Vertex("Inner+X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
+                IPM = new Vertex("Inner+X+Y-Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
+                IMP = new Vertex("Inner+X-Y+Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
+                IMM = new Vertex("Inner+X-Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
+
+                meshPX.Add(IPP);
+                meshPX.Add(IPM);
+                meshPX.Add(IMP);
+                meshPX.Add(IMM);
+
+                meshPX.Add(new Triangle(IPP, IPM, IMP));
+                meshPX.Add(new Triangle(IMP, IPM, IMM));
+
+                foreach (Triangle t in meshPX.triangles)
+                {
+                    PhysicsVector n = t.getNormal();
+                }
+            }
+
+            Mesh result = new Mesh();
+            result.Append(meshMX);
+            result.Append(meshPX);
+
+            return result;
+        }
+
+
+
+        static Mesh CreateBoxMeshY(PrimitiveBaseShape primShape, PhysicsVector size)
+        // Builds the y (+ and -) surfaces of a box shaped prim
+        {
+            UInt16 hollowFactor = primShape.ProfileHollow;
+
+            // (M)inus Y
+            Mesh MeshMY = new Mesh();
+            MeshMY.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
+            MeshMY.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
+            MeshMY.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
+            MeshMY.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
+
+            MeshMY.Add(new Triangle(MeshMY.vertices[0], MeshMY.vertices[1], MeshMY.vertices[2]));
+            MeshMY.Add(new Triangle(MeshMY.vertices[2], MeshMY.vertices[1], MeshMY.vertices[3]));
+
+            // (P)lus Y
+            Mesh MeshPY = new Mesh();
+
+            MeshPY.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
+            MeshPY.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
+            MeshPY.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
+            MeshPY.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
+
+            MeshPY.Add(new Triangle(MeshPY.vertices[1], MeshPY.vertices[0], MeshPY.vertices[2]));
+            MeshPY.Add(new Triangle(MeshPY.vertices[1], MeshPY.vertices[2], MeshPY.vertices[3]));
+
+            if (hollowFactor > 0)
+            {
+                float hollowFactorF = (float)hollowFactor / (float)50000;
+
+                Vertex IPP;
+                Vertex IPM;
+                Vertex IMP;
+                Vertex IMM;
+
+                IPP = new Vertex("Inner+X-Y+Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
+                IPM = new Vertex("Inner+X-Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
+                IMP = new Vertex("Inner-X-Y+Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
+                IMM = new Vertex("Inner-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
+
+                MeshMY.Add(IPP);
+                MeshMY.Add(IPM);
+                MeshMY.Add(IMP);
+                MeshMY.Add(IMM);
+
+                MeshMY.Add(new Triangle(IPP, IPM, IMP));
+                MeshMY.Add(new Triangle(IMP, IPM, IMM));
+
+                foreach (Triangle t in MeshMY.triangles)
+                {
+                    PhysicsVector n = t.getNormal();
+                }
+
+
+
+                IPP = new Vertex("Inner+X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
+                IPM=new Vertex("Inner+X+Y-Z", +size.X * hollowFactorF / 2.0f, +size.Y  * hollowFactorF / 2.0f, -size.Z / 2.0f);
+                IMP=new Vertex("Inner-X+Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y  * hollowFactorF / 2.0f, +size.Z / 2.0f);
+                IMM=new Vertex("Inner-X+Y-Z", -size.X * hollowFactorF / 2.0f, +size.Y  * hollowFactorF / 2.0f, -size.Z / 2.0f);
+
+                MeshPY.Add(IPP);
+                MeshPY.Add(IPM);
+                MeshPY.Add(IMP);
+                MeshPY.Add(IMM);
+
+                MeshPY.Add(new Triangle(IPM, IPP, IMP));
+                MeshPY.Add(new Triangle(IMP, IMM, IPM));
+
+                foreach (Triangle t in MeshPY.triangles)
+                {
+                    PhysicsVector n = t.getNormal();
+                }
+
+
+
+            }
+
+
+            Mesh result = new Mesh();
+            result.Append(MeshMY);
+            result.Append(MeshPY);
+
+            return result;
+        }
+            
+        static Mesh CreateBoxMeshZ(PrimitiveBaseShape primShape, PhysicsVector size)
+        // Builds the z (+ and -) surfaces of a box shaped prim
+        {
+            UInt16 hollowFactor = primShape.ProfileHollow;
+
+            // Base, i.e. outer shape
+            // (M)inus Z
+            Mesh MZ = new Mesh();
+
+            MZ.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
+            MZ.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
+            MZ.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
+            MZ.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
+
+
+            MZ.Add(new Triangle(MZ.vertices[1], MZ.vertices[0], MZ.vertices[2]));
+            MZ.Add(new Triangle(MZ.vertices[1], MZ.vertices[2], MZ.vertices[3]));
+
+            // (P)lus Z
+            Mesh PZ = new Mesh();
+
+            PZ.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, 0.0f));
+            PZ.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, 0.0f));
+            PZ.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, 0.0f));
+            PZ.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, 0.0f));
+
+            // Surface 5, +Z
+            PZ.Add(new Triangle(PZ.vertices[0], PZ.vertices[1], PZ.vertices[2]));
+            PZ.Add(new Triangle(PZ.vertices[2], PZ.vertices[1], PZ.vertices[3]));
+
+            if (hollowFactor > 0)
+            {
+                float hollowFactorF = (float)hollowFactor / (float)50000;
+
+                MZ.Add(new Vertex("-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
+                MZ.Add(new Vertex("-X+Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
+                MZ.Add(new Vertex("-X-Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
+                MZ.Add(new Vertex("-X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
+
+                List<int> innerBorders = new List<int>();
+                innerBorders.Add(4);
+                innerBorders.Add(5);
+                innerBorders.Add(6);
+                innerBorders.Add(7);
+
+                InsertVertices(MZ.vertices, 4, MZ.triangles, innerBorders);
+
+                PZ.Add(new Vertex("-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
+                PZ.Add(new Vertex("-X+Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
+                PZ.Add(new Vertex("-X-Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
+                PZ.Add(new Vertex("-X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
+
+                innerBorders = new List<int>();
+                innerBorders.Add(4);
+                innerBorders.Add(5);
+                innerBorders.Add(6);
+                innerBorders.Add(7);
+
+                InsertVertices(PZ.vertices, 4, PZ.triangles, innerBorders);
+
+            }
+
+            foreach (Vertex v in PZ.vertices)
+            {
+                v.point.Z = size.Z / 2.0f;
+            }
+            foreach (Vertex v in MZ.vertices)
+            {
+                v.point.Z = -size.Z / 2.0f;
+            }
+
+            foreach (Triangle t in MZ.triangles)
+            {
+                PhysicsVector n = t.getNormal();
+                if (n.Z > 0.0)
+                    t.invertNormal();
+            }
+
+            foreach (Triangle t in PZ.triangles)
+            {
+                PhysicsVector n = t.getNormal();
+                if (n.Z < 0.0)
+                    t.invertNormal();
+            }
+
+            Mesh result = new Mesh();
+            result.Append(MZ);
+            result.Append(PZ);
+
+            return result;
+        }
+
+        static Mesh CreateBoxMesh(PrimitiveBaseShape primShape, PhysicsVector size)
+        {
+            Mesh result = new Mesh();
+
+
+
+            Mesh MeshX = Meshmerizer.CreateBoxMeshX(primShape, size);
+            Mesh MeshY = Meshmerizer.CreateBoxMeshY(primShape, size);
+            Mesh MeshZ = Meshmerizer.CreateBoxMeshZ(primShape, size);
+
+            result.Append(MeshX);
+            result.Append(MeshY);
+            result.Append(MeshZ);
+
+            return result;
+        }
+
+
+        public static void CalcNormals(Mesh mesh) 
+        {
+            int iTriangles = mesh.triangles.Count;
+
+            mesh.normals = new float[iTriangles*3];
+
+            int i=0;
+            foreach (Triangle t in mesh.triangles)
+            {
+
+                float ux, uy, uz;
+                float vx, vy, vz;
+                float wx, wy, wz;
+
+                    ux = t.v1.point.X;
+                    uy = t.v1.point.Y;
+                    uz = t.v1.point.Z;
+
+                    vx = t.v2.point.X;
+                    vy = t.v2.point.Y;
+                    vz = t.v2.point.Z;
+
+                    wx = t.v3.point.X;
+                    wy = t.v3.point.Y;
+                    wz = t.v3.point.Z;
+
+                    // Vectors for edges
+                    float e1x, e1y, e1z;
+                    float e2x, e2y, e2z;
+
+                    e1x = ux - vx;
+                    e1y = uy - vy;
+                    e1z = uz - vz;
+
+                    e2x = ux - wx;
+                    e2y = uy - wy;
+                    e2z = uz - wz;
+
+
+                    // Cross product for normal
+                    float nx, ny, nz;
+                    nx = e1y * e2z - e1z * e2y;
+                    ny = e1z * e2x - e1x * e2z;
+                    nz = e1x * e2y - e1y * e2x;
+
+                    // Length
+                    float l = (float)Math.Sqrt(nx * nx + ny * ny + nz * nz);
+
+                    // Normalized "normal"
+                    nx /= l;
+                    ny /= l;
+                    nz /= l;
+
+                mesh.normals[i] = nx;
+                mesh.normals[i + 1] = ny;
+                mesh.normals[i + 2] = nz;
+
+                i+=3;
+            }
+        }
+
+        public static Mesh CreateMesh(PrimitiveBaseShape primShape, PhysicsVector size)
+        {
+            Mesh mesh = null;
+
+            switch (primShape.ProfileShape)
+            {
+                case ProfileShape.Square:
+                    mesh=CreateBoxMesh(primShape, size);
+                    CalcNormals(mesh);
+                    break;
+                default:
+                    mesh=null;
+                    break;
+            }
+
+            return mesh;
+
+        }
+    }
+}
+
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
index caa068d..6838f47 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
@@ -760,138 +760,138 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
         }
 
         public double llGetRegionTimeDilation() { return 1.0f; }
-        public double llGetRegionFPS() { return 10.0f; }
-
-        /* particle system rules should be coming into this routine as doubles, that is
-        rule[0] should be an integer from this list and rule[1] should be the arg
-        for the same integer. wiki.secondlife.com has most of this mapping, but some
-        came from http://www.caligari-designs.com/p4u2
-
-        We iterate through the list for 'Count' elements, incrementing by two for each
-        iteration and set the members of Primitive.ParticleSystem, one at a time.
-        */
-        public enum PrimitiveRule : int
-        {
-            PSYS_PART_FLAGS = 0,
-            PSYS_PART_START_COLOR = 1,
-            PSYS_PART_START_ALPHA = 2,
-            PSYS_PART_END_COLOR = 3,
-            PSYS_PART_END_ALPHA = 4,
-            PSYS_PART_START_SCALE = 5,
-            PSYS_PART_END_SCALE = 6,
-            PSYS_PART_MAX_AGE = 7,
-            PSYS_SRC_ACCEL = 8,
-            PSYS_SRC_PATTERN = 9,
-            PSYS_SRC_TEXTURE = 12,
-            PSYS_SRC_BURST_RATE = 13,
-            PSYS_SRC_BURST_PART_COUNT = 15,
-            PSYS_SRC_BURST_RADIUS = 16,
-            PSYS_SRC_BURST_SPEED_MIN = 17,
-            PSYS_SRC_BURST_SPEED_MAX = 18,
-            PSYS_SRC_MAX_AGE = 19,
-            PSYS_SRC_TARGET_KEY = 20,
-            PSYS_SRC_OMEGA = 21,
-            PSYS_SRC_ANGLE_BEGIN = 22,
-            PSYS_SRC_ANGLE_END = 23
-        }
-
-        public void llParticleSystem(List<Object> rules)
-        {
-            Primitive.ParticleSystem prules = new Primitive.ParticleSystem();
-            for (int i = 0; i < rules.Count; i += 2)
-            {
-                switch ((int)rules[i])
-                {
-                    case (int)PrimitiveRule.PSYS_PART_FLAGS:
-                        prules.PartFlags = (uint)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_PART_START_COLOR:
-                        prules.PartStartColor = (LLColor)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_PART_START_ALPHA:
-                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_PART_END_COLOR:
-                        prules.PartEndColor = (LLColor)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_PART_END_ALPHA:
-                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_PART_START_SCALE:
-                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_PART_END_SCALE:
-                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_PART_MAX_AGE:
-                        prules.MaxAge = (float)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_ACCEL:
-                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_PATTERN:
-                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_TEXTURE:
-                        prules.Texture = (LLUUID)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_BURST_RATE:
-                        prules.BurstRate = (float)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_BURST_PART_COUNT:
-                        prules.BurstPartCount = (byte)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_BURST_RADIUS:
-                        prules.BurstRadius = (float)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_BURST_SPEED_MIN:
-                        prules.BurstSpeedMin = (float)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_BURST_SPEED_MAX:
-                        prules.BurstSpeedMax = (float)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_MAX_AGE:
-                        prules.MaxAge = (float)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_TARGET_KEY:
-                        prules.Target = (LLUUID)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_OMEGA:
-                        //cast??                    prules.MaxAge = (float)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_ANGLE_BEGIN:
-                        prules.InnerAngle = (float)rules[i + 1];
-                        break;
-
-                    case (int)PrimitiveRule.PSYS_SRC_ANGLE_END:
-                        prules.OuterAngle = (float)rules[i + 1];
-                        break;
-
-                }
-            }
-
-            m_host.AddNewParticleSystem(prules);
-        }
-
+        public double llGetRegionFPS() { return 10.0f; }
+
+        /* particle system rules should be coming into this routine as doubles, that is
+        rule[0] should be an integer from this list and rule[1] should be the arg
+        for the same integer. wiki.secondlife.com has most of this mapping, but some
+        came from http://www.caligari-designs.com/p4u2
+
+        We iterate through the list for 'Count' elements, incrementing by two for each
+        iteration and set the members of Primitive.ParticleSystem, one at a time.
+        */
+        public enum PrimitiveRule : int
+        {
+            PSYS_PART_FLAGS = 0,
+            PSYS_PART_START_COLOR = 1,
+            PSYS_PART_START_ALPHA = 2,
+            PSYS_PART_END_COLOR = 3,
+            PSYS_PART_END_ALPHA = 4,
+            PSYS_PART_START_SCALE = 5,
+            PSYS_PART_END_SCALE = 6,
+            PSYS_PART_MAX_AGE = 7,
+            PSYS_SRC_ACCEL = 8,
+            PSYS_SRC_PATTERN = 9,
+            PSYS_SRC_TEXTURE = 12,
+            PSYS_SRC_BURST_RATE = 13,
+            PSYS_SRC_BURST_PART_COUNT = 15,
+            PSYS_SRC_BURST_RADIUS = 16,
+            PSYS_SRC_BURST_SPEED_MIN = 17,
+            PSYS_SRC_BURST_SPEED_MAX = 18,
+            PSYS_SRC_MAX_AGE = 19,
+            PSYS_SRC_TARGET_KEY = 20,
+            PSYS_SRC_OMEGA = 21,
+            PSYS_SRC_ANGLE_BEGIN = 22,
+            PSYS_SRC_ANGLE_END = 23
+        }
+
+        public void llParticleSystem(List<Object> rules)
+        {
+            Primitive.ParticleSystem prules = new Primitive.ParticleSystem();
+            for (int i = 0; i < rules.Count; i += 2)
+            {
+                switch ((int)rules[i])
+                {
+                    case (int)PrimitiveRule.PSYS_PART_FLAGS:
+                        prules.PartFlags = (uint)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_PART_START_COLOR:
+                        prules.PartStartColor = (LLColor)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_PART_START_ALPHA:
+                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_PART_END_COLOR:
+                        prules.PartEndColor = (LLColor)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_PART_END_ALPHA:
+                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_PART_START_SCALE:
+                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_PART_END_SCALE:
+                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_PART_MAX_AGE:
+                        prules.MaxAge = (float)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_ACCEL:
+                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_PATTERN:
+                        //what is the cast?                    prules.PartStartColor = (LLColor)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_TEXTURE:
+                        prules.Texture = (LLUUID)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_BURST_RATE:
+                        prules.BurstRate = (float)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_BURST_PART_COUNT:
+                        prules.BurstPartCount = (byte)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_BURST_RADIUS:
+                        prules.BurstRadius = (float)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_BURST_SPEED_MIN:
+                        prules.BurstSpeedMin = (float)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_BURST_SPEED_MAX:
+                        prules.BurstSpeedMax = (float)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_MAX_AGE:
+                        prules.MaxAge = (float)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_TARGET_KEY:
+                        prules.Target = (LLUUID)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_OMEGA:
+                        //cast??                    prules.MaxAge = (float)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_ANGLE_BEGIN:
+                        prules.InnerAngle = (float)rules[i + 1];
+                        break;
+
+                    case (int)PrimitiveRule.PSYS_SRC_ANGLE_END:
+                        prules.OuterAngle = (float)rules[i + 1];
+                        break;
+
+                }
+            }
+
+            m_host.AddNewParticleSystem(prules);
+        }
+
         public void llGroundRepel(double height, int water, double tau) { NotImplemented("llGroundRepel"); }
         public void llGiveInventoryList() { NotImplemented("llGiveInventoryList"); }
         public void llSetVehicleType(int type) { NotImplemented("llSetVehicleType"); }
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
index 197eb72..381fd8c 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
@@ -285,7 +285,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
                 before = GC.GetTotalMemory(true);
 #endif
 
-                LSL_BaseClass CompiledScript;
+                LSL_BaseClass CompiledScript;
                 CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource);
 
 #if DEBUG
-- 
cgit v1.1