diff --git a/OpenSim/Framework/General/Util.cs b/OpenSim/Framework/General/Util.cs
index 5eae206930..1ec7d78f9b 100644
--- a/OpenSim/Framework/General/Util.cs
+++ b/OpenSim/Framework/General/Util.cs
@@ -152,15 +152,15 @@ namespace OpenSim.Framework.Utilities
return capsPath;
}
- //public static int fast_distance2d(int x, int y)
- //{
- // x = System.Math.Abs(x);
- // y = System.Math.Abs(y);
+ public static int fast_distance2d(int x, int y)
+ {
+ x = System.Math.Abs(x);
+ y = System.Math.Abs(y);
- // int min = System.Math.Min(x, y);
+ int min = System.Math.Min(x, y);
- // return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
- //}
+ return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
+ }
public static string FieldToString(byte[] bytes)
{
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index 1170f801fb..9e0bc09f47 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -191,8 +191,8 @@ namespace OpenSim
MainLog.Instance.Verbose("Loading Shared Modules");
m_moduleLoader.LoadDefaultSharedModules(m_exceptSharedModules);
- // Load all script engines found
- OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader ScriptEngineLoader = new OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader(m_log);
+ // Load all script engines found (scripting engine is now a IRegionModule so loaded in the module loader
+ // OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader ScriptEngineLoader = new OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader(m_log);
for (int i = 0; i < configFiles.Length; i++)
{
@@ -209,11 +209,11 @@ namespace OpenSim
scene.SetModuleInterfaces();
// Check if we have a script engine to load
- if (m_scriptEngine != null && m_scriptEngine != "")
- {
- OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface ScriptEngine = ScriptEngineLoader.LoadScriptEngine(m_scriptEngine);
- scene.AddScriptEngine(ScriptEngine, m_log);
- }
+ //if (m_scriptEngine != null && m_scriptEngine != "")
+ //{
+ // OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface ScriptEngine = ScriptEngineLoader.LoadScriptEngine(m_scriptEngine);
+ // scene.AddScriptEngine(ScriptEngine, m_log);
+ //}
//Server side object editing permissions checking
if (m_permissions)
@@ -371,7 +371,7 @@ namespace OpenSim
/// Additional arguments passed to the command
public void RunCmd(string command, string[] cmdparams)
{
- if ((m_consoleRegion == null) || (command == "change-region") || (command == "shutdown"))
+ if ((m_consoleRegion == null) || (command == "change-region") || (command == "shutdown"))
{
switch (command)
{
@@ -603,7 +603,7 @@ namespace OpenSim
string result = "";
for (int i = pos; i < commandParams.Length; i++)
{
- result += commandParams[i] +" ";
+ result += commandParams[i] + " ";
}
result = result.TrimEnd(' ');
return result;
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index ff527fbf28..52fc568233 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -128,6 +128,14 @@ namespace OpenSim.Region.ClientStack
m_networkServer.RemoveClientCircuit(this.CircuitCode);
this.ClientThread.Abort();
}
+
+ public override void ConnectionClosed()
+ {
+ clientPingTimer.Stop();
+ m_clientThreads.Remove(this.CircuitCode);
+ m_networkServer.RemoveClientCircuit(this.CircuitCode);
+ this.ClientThread.Abort();
+ }
#endregion
# region Packet Handling
diff --git a/OpenSim/Region/ClientStack/ClientViewBase.cs b/OpenSim/Region/ClientStack/ClientViewBase.cs
index 0b2c875b71..8a7c764955 100644
--- a/OpenSim/Region/ClientStack/ClientViewBase.cs
+++ b/OpenSim/Region/ClientStack/ClientViewBase.cs
@@ -315,6 +315,10 @@ namespace OpenSim.Region.ClientStack
}
+ public virtual void ConnectionClosed()
+ {
+ }
+
#region Nested Classes
public class QueItem
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs
index 66a7ffd9ea..59f11d5fba 100644
--- a/OpenSim/Region/ClientStack/PacketServer.cs
+++ b/OpenSim/Region/ClientStack/PacketServer.cs
@@ -74,6 +74,14 @@ namespace OpenSim.Region.ClientStack
}
}
+ public virtual void ConnectionClosed(uint circuitCode)
+ {
+ if (this.ClientThreads.ContainsKey(circuitCode))
+ {
+ ClientThreads[circuitCode].ConnectionClosed();
+ }
+ }
+
///
///
///
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index 45eb0cddfa..8b4a3cbdd8 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -101,7 +101,23 @@ namespace OpenSim.Region.ClientStack
ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
epSender = (EndPoint)ipeSender;
Packet packet = null;
- int numBytes = Server.EndReceiveFrom(result, ref epSender);
+
+ int numBytes;
+
+ try
+ {
+ numBytes = Server.EndReceiveFrom(result, ref epSender);
+ }
+ catch (System.Net.Sockets.SocketException)
+ {
+ Console.WriteLine("Remote host Closed connection");
+ this._packetServer.ConnectionClosed(this.clientCircuits[epSender]);
+ ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
+ epSender = (EndPoint)ipeSender;
+ Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
+ return;
+ }
+
int packetEnd = numBytes - 1;
packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs
index e8e7bc2000..be3384b5eb 100644
--- a/OpenSim/Region/Environment/ModuleLoader.cs
+++ b/OpenSim/Region/Environment/ModuleLoader.cs
@@ -44,6 +44,9 @@ namespace OpenSim.Region.Environment
LoadedModules.Add(avatarProfiles);
this.LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene);
+
+ string lslPath = System.IO.Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
+ this.LoadRegionModule(lslPath, "LSLScriptingModule", scene);
}
public void LoadDefaultSharedModules(string exceptModules)
diff --git a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs
index 9fbd68eaf5..8223919f53 100644
--- a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs
+++ b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs
@@ -5,7 +5,6 @@ using System.Threading;
using System.IO;
using System.Collections.Generic;
using libsecondlife;
-using OpenJPEGNet;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Framework.Interfaces;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 4151074189..1ce75e0e2b 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -44,6 +44,7 @@ using OpenSim.Framework.Communications.Caches;
using OpenSim.Region.Environment.LandManagement;
using OpenSim.Region.Environment;
using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Types;
using OpenSim.Region.Terrain;
using OpenSim.Framework.Data;
using Caps = OpenSim.Region.Capabilities.Caps;
@@ -72,6 +73,8 @@ namespace OpenSim.Region.Environment.Scenes
private int m_timePhase = 24;
private int m_timeUpdateCount;
+ public BasicQuadTreeNode QuadTree;
+
private Mutex updateLock;
protected ModuleLoader m_moduleLoader;
@@ -178,6 +181,10 @@ namespace OpenSim.Region.Environment.Scenes
m_eventManager.OnPermissionError += SendPermissionAlert;
+ QuadTree = new BasicQuadTreeNode(null, 0, 0, 256, 256);
+ QuadTree.Subdivide();
+ QuadTree.Subdivide();
+
MainLog.Instance.Verbose("Creating new entitities instance");
Entities = new Dictionary();
Avatars = new Dictionary();
@@ -596,6 +603,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (!Entities.ContainsKey(sceneObject.UUID))
{
+ QuadTree.AddObject(sceneObject);
Entities.Add(sceneObject.UUID, sceneObject);
}
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index dec017e4e4..9e207c8758 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -43,6 +43,9 @@ namespace OpenSim.Region.Environment.Scenes
protected byte[] m_particleSystem = new byte[0];
+ public uint TimeStampFull = 0;
+ public uint TimeStampTerse = 0;
+
protected SceneObjectGroup m_parentGroup;
///
@@ -366,6 +369,7 @@ namespace OpenSim.Region.Environment.Scenes
{
m_parentGroup.HasChanged = true;
}
+ this.TimeStampFull =(uint) Util.UnixTimeSinceEpoch();
m_updateFlag = 2;
}
@@ -380,6 +384,7 @@ namespace OpenSim.Region.Environment.Scenes
{
m_parentGroup.HasChanged = true;
}
+ this.TimeStampTerse = (uint)Util.UnixTimeSinceEpoch();
m_updateFlag = 1;
}
}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 285c691dfe..7b7c595eeb 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -88,11 +88,13 @@ namespace OpenSim.Region.Environment.Scenes
public delegate void SignificantClientMovement(IClientAPI remote_client);
public event SignificantClientMovement OnSignificantClientMovement;
+ public List InterestList = new List();
+
// private Queue m_fullGroupUpdates = new Queue();
// private Queue m_terseGroupUpdates = new Queue();
private Queue m_fullPartUpdates = new Queue();
- private Queue m_teserPartUpdates = new Queue();
+ private Queue m_tersePartUpdates = new Queue();
#region Properties
///
@@ -201,7 +203,7 @@ namespace OpenSim.Region.Environment.Scenes
public void AddTersePart(SceneObjectPart part)
{
- m_teserPartUpdates.Enqueue(part);
+ m_tersePartUpdates.Enqueue(part);
}
public void AddFullPart(SceneObjectPart part)
@@ -211,18 +213,18 @@ namespace OpenSim.Region.Environment.Scenes
public void SendPrimUpdates()
{
- if (m_teserPartUpdates.Count > 0)
+ if (m_tersePartUpdates.Count > 0)
{
bool terse = true;
int terseCount = 0;
while (terse)
{
- SceneObjectPart part = m_teserPartUpdates.Dequeue();
+ SceneObjectPart part = m_tersePartUpdates.Dequeue();
part.SendTerseUpdate(this.ControllingClient);
terseCount++;
- if ((m_teserPartUpdates.Count < 1) |(terseCount > 30))
+ if ((m_tersePartUpdates.Count < 1) |(terseCount > 30))
{
terse = false;
}
diff --git a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs
new file mode 100644
index 0000000000..c7b0524f52
--- /dev/null
+++ b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs
@@ -0,0 +1,167 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.Region.Environment.Scenes;
+
+namespace OpenSim.Region.Environment.Types
+{
+ public class BasicQuadTreeNode
+ {
+ private List m_objects = new List();
+ private BasicQuadTreeNode[] m_childNodes = null;
+ private BasicQuadTreeNode m_parent = null;
+
+ private short m_leftX;
+ private short m_leftY;
+ private short m_width;
+ private short m_height;
+
+ public BasicQuadTreeNode(BasicQuadTreeNode parent, short leftX, short leftY, short width, short height)
+ {
+ m_parent = parent;
+ m_leftX = leftX;
+ m_leftY = leftY;
+ m_width = width;
+ m_height = height;
+ }
+
+ public void AddObject(SceneObjectGroup obj)
+ {
+ if (m_childNodes == null)
+ {
+ if (!m_objects.Contains(obj))
+ {
+ m_objects.Add(obj);
+ }
+ }
+ else
+ {
+ if (obj.AbsolutePosition.X < (m_leftX + (m_width / 2)))
+ {
+ if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2)))
+ {
+ m_childNodes[0].AddObject(obj);
+ }
+ else
+ {
+ m_childNodes[2].AddObject(obj);
+ }
+ }
+ else
+ {
+ if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2)))
+ {
+ m_childNodes[1].AddObject(obj);
+ }
+ else
+ {
+ m_childNodes[3].AddObject(obj);
+ }
+ }
+ }
+ }
+
+ public void Subdivide()
+ {
+ if (m_childNodes == null)
+ {
+ m_childNodes = new BasicQuadTreeNode[4];
+ 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),(short) (m_height / 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)),(short)( m_width / 2), (short)(m_height / 2));
+ }
+ else
+ {
+ for (int i = 0; i < m_childNodes.Length; i++)
+ {
+ m_childNodes[i].Subdivide();
+ }
+ }
+ }
+
+ public List GetObjectsFrom(int x, int y)
+ {
+ if (m_childNodes == null)
+ {
+ return m_objects;
+ }
+ else
+ {
+ if (x < (m_leftX + (m_width / 2)))
+ {
+ if (y < (m_leftY + (m_height / 2)))
+ {
+ return m_childNodes[0].GetObjectsFrom(x, y);
+ }
+ else
+ {
+ return m_childNodes[2].GetObjectsFrom(x, y);
+ }
+ }
+ else
+ {
+ if (y < (m_leftY + (m_height / 2)))
+ {
+ return m_childNodes[1].GetObjectsFrom(x, y);
+ }
+ else
+ {
+ return m_childNodes[3].GetObjectsFrom(x, y);
+ }
+ }
+ }
+ }
+
+ public void Update()
+ {
+ if (m_childNodes != null)
+ {
+ for (int i = 0; i < 4; i++)
+ {
+ m_childNodes[i].Update();
+ }
+ }
+ else
+ {
+ List outBounds = new List();
+ foreach (SceneObjectGroup group in m_objects)
+ {
+ 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
+ }
+ else
+ {
+ outBounds.Add(group);
+ }
+ }
+
+ foreach (SceneObjectGroup removee in outBounds)
+ {
+ m_objects.Remove(removee);
+ if (m_parent != null)
+ {
+ m_parent.PassUp(removee);
+ }
+ }
+ outBounds.Clear();
+ }
+ }
+
+ public void PassUp(SceneObjectGroup group)
+ {
+ 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))))
+ {
+ this.AddObject(group);
+ }
+ else
+ {
+ if (m_parent != null)
+ {
+ m_parent.PassUp(group);
+ }
+ }
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Types/UpdateQueue.cs b/OpenSim/Region/Environment/Types/UpdateQueue.cs
new file mode 100644
index 0000000000..d7eb6ee62b
--- /dev/null
+++ b/OpenSim/Region/Environment/Types/UpdateQueue.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.Region.Environment.Scenes;
+using libsecondlife;
+
+namespace OpenSim.Region.Environment.Types
+{
+ public class UpdateQueue
+ {
+ private Queue m_queue;
+
+ private List m_ids;
+
+ public UpdateQueue()
+ {
+ m_queue = new Queue();
+ m_ids = new List();
+ }
+ }
+}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
index d0823d059b..694059cfcd 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
@@ -30,8 +30,9 @@ using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework.Console;
-//using OpenSim.Region.Environment.Scenes;
+using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Scenes.Scripting;
+using OpenSim.Region.Environment.Interfaces;
using libsecondlife;
namespace OpenSim.Region.ScriptEngine.DotNetEngine
@@ -40,7 +41,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// This is the root object for ScriptEngine
///
[Serializable]
- public class ScriptEngine : OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface
+ public class ScriptEngine :IRegionModule
{
internal OpenSim.Region.Environment.Scenes.Scene World;
@@ -99,5 +100,33 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID);
// myScriptManager.StartScript(ScriptID, ObjectID);
//}
+
+ #region IRegionModule
+
+ public void Initialise(Scene scene)
+ {
+ this.InitializeEngine(scene, MainLog.Instance);
+ }
+
+ public void PostInitialise()
+ {
+
+ }
+
+ public void CloseDown()
+ {
+ }
+
+ public string GetName()
+ {
+ return "LSLScriptingModule";
+ }
+
+ public bool IsSharedModule()
+ {
+ return false;
+ }
+
+ #endregion
}
}