Converted the LSL scripting engine into a IRegionModule, so now all "modules" share a common base interface and are loaded from the single loader. (It seems to work fine, but I have left the old scriptengine loader, incase we have to change back).

Removed the reference to OpenJpeg in the DynamicTextureModule, to see if that was causing the build problem someone is having. 
Added a Temporary fix for the "existing connection was forcibly closed by the remote host" exception on windows when a user logs out of a multiregion instance. 
Some early work to prepare for improving the way clients are updated (about prims etc).
afrisby
MW 2007-09-08 07:50:31 +00:00
parent 294572d7bb
commit c29df824c2
14 changed files with 295 additions and 25 deletions

View File

@ -152,15 +152,15 @@ namespace OpenSim.Framework.Utilities
return capsPath; return capsPath;
} }
//public static int fast_distance2d(int x, int y) public static int fast_distance2d(int x, int y)
//{ {
// x = System.Math.Abs(x); x = System.Math.Abs(x);
// y = System.Math.Abs(y); 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) public static string FieldToString(byte[] bytes)
{ {

View File

@ -191,8 +191,8 @@ namespace OpenSim
MainLog.Instance.Verbose("Loading Shared Modules"); MainLog.Instance.Verbose("Loading Shared Modules");
m_moduleLoader.LoadDefaultSharedModules(m_exceptSharedModules); m_moduleLoader.LoadDefaultSharedModules(m_exceptSharedModules);
// Load all script engines found // 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); // OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader ScriptEngineLoader = new OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader(m_log);
for (int i = 0; i < configFiles.Length; i++) for (int i = 0; i < configFiles.Length; i++)
{ {
@ -209,11 +209,11 @@ namespace OpenSim
scene.SetModuleInterfaces(); scene.SetModuleInterfaces();
// Check if we have a script engine to load // Check if we have a script engine to load
if (m_scriptEngine != null && m_scriptEngine != "") //if (m_scriptEngine != null && m_scriptEngine != "")
{ //{
OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface ScriptEngine = ScriptEngineLoader.LoadScriptEngine(m_scriptEngine); // OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface ScriptEngine = ScriptEngineLoader.LoadScriptEngine(m_scriptEngine);
scene.AddScriptEngine(ScriptEngine, m_log); // scene.AddScriptEngine(ScriptEngine, m_log);
} //}
//Server side object editing permissions checking //Server side object editing permissions checking
if (m_permissions) if (m_permissions)
@ -603,7 +603,7 @@ namespace OpenSim
string result = ""; string result = "";
for (int i = pos; i < commandParams.Length; i++) for (int i = pos; i < commandParams.Length; i++)
{ {
result += commandParams[i] +" "; result += commandParams[i] + " ";
} }
result = result.TrimEnd(' '); result = result.TrimEnd(' ');
return result; return result;

View File

@ -128,6 +128,14 @@ namespace OpenSim.Region.ClientStack
m_networkServer.RemoveClientCircuit(this.CircuitCode); m_networkServer.RemoveClientCircuit(this.CircuitCode);
this.ClientThread.Abort(); this.ClientThread.Abort();
} }
public override void ConnectionClosed()
{
clientPingTimer.Stop();
m_clientThreads.Remove(this.CircuitCode);
m_networkServer.RemoveClientCircuit(this.CircuitCode);
this.ClientThread.Abort();
}
#endregion #endregion
# region Packet Handling # region Packet Handling

View File

@ -315,6 +315,10 @@ namespace OpenSim.Region.ClientStack
} }
public virtual void ConnectionClosed()
{
}
#region Nested Classes #region Nested Classes
public class QueItem public class QueItem

View File

@ -74,6 +74,14 @@ namespace OpenSim.Region.ClientStack
} }
} }
public virtual void ConnectionClosed(uint circuitCode)
{
if (this.ClientThreads.ContainsKey(circuitCode))
{
ClientThreads[circuitCode].ConnectionClosed();
}
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@ -101,7 +101,23 @@ namespace OpenSim.Region.ClientStack
ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
epSender = (EndPoint)ipeSender; epSender = (EndPoint)ipeSender;
Packet packet = null; 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; int packetEnd = numBytes - 1;
packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);

View File

@ -44,6 +44,9 @@ namespace OpenSim.Region.Environment
LoadedModules.Add(avatarProfiles); LoadedModules.Add(avatarProfiles);
this.LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); 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) public void LoadDefaultSharedModules(string exceptModules)

View File

@ -5,7 +5,6 @@ using System.Threading;
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using OpenJPEGNet;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Framework.Interfaces; using OpenSim.Framework.Interfaces;

View File

@ -44,6 +44,7 @@ using OpenSim.Framework.Communications.Caches;
using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.LandManagement;
using OpenSim.Region.Environment; using OpenSim.Region.Environment;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Types;
using OpenSim.Region.Terrain; using OpenSim.Region.Terrain;
using OpenSim.Framework.Data; using OpenSim.Framework.Data;
using Caps = OpenSim.Region.Capabilities.Caps; using Caps = OpenSim.Region.Capabilities.Caps;
@ -72,6 +73,8 @@ namespace OpenSim.Region.Environment.Scenes
private int m_timePhase = 24; private int m_timePhase = 24;
private int m_timeUpdateCount; private int m_timeUpdateCount;
public BasicQuadTreeNode QuadTree;
private Mutex updateLock; private Mutex updateLock;
protected ModuleLoader m_moduleLoader; protected ModuleLoader m_moduleLoader;
@ -178,6 +181,10 @@ namespace OpenSim.Region.Environment.Scenes
m_eventManager.OnPermissionError += SendPermissionAlert; m_eventManager.OnPermissionError += SendPermissionAlert;
QuadTree = new BasicQuadTreeNode(null, 0, 0, 256, 256);
QuadTree.Subdivide();
QuadTree.Subdivide();
MainLog.Instance.Verbose("Creating new entitities instance"); MainLog.Instance.Verbose("Creating new entitities instance");
Entities = new Dictionary<LLUUID, EntityBase>(); Entities = new Dictionary<LLUUID, EntityBase>();
Avatars = new Dictionary<LLUUID, ScenePresence>(); Avatars = new Dictionary<LLUUID, ScenePresence>();
@ -596,6 +603,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (!Entities.ContainsKey(sceneObject.UUID)) if (!Entities.ContainsKey(sceneObject.UUID))
{ {
QuadTree.AddObject(sceneObject);
Entities.Add(sceneObject.UUID, sceneObject); Entities.Add(sceneObject.UUID, sceneObject);
} }
} }

View File

@ -43,6 +43,9 @@ namespace OpenSim.Region.Environment.Scenes
protected byte[] m_particleSystem = new byte[0]; protected byte[] m_particleSystem = new byte[0];
public uint TimeStampFull = 0;
public uint TimeStampTerse = 0;
protected SceneObjectGroup m_parentGroup; protected SceneObjectGroup m_parentGroup;
/// <summary> /// <summary>
@ -366,6 +369,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
m_parentGroup.HasChanged = true; m_parentGroup.HasChanged = true;
} }
this.TimeStampFull =(uint) Util.UnixTimeSinceEpoch();
m_updateFlag = 2; m_updateFlag = 2;
} }
@ -380,6 +384,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
m_parentGroup.HasChanged = true; m_parentGroup.HasChanged = true;
} }
this.TimeStampTerse = (uint)Util.UnixTimeSinceEpoch();
m_updateFlag = 1; m_updateFlag = 1;
} }
} }

View File

@ -88,11 +88,13 @@ namespace OpenSim.Region.Environment.Scenes
public delegate void SignificantClientMovement(IClientAPI remote_client); public delegate void SignificantClientMovement(IClientAPI remote_client);
public event SignificantClientMovement OnSignificantClientMovement; public event SignificantClientMovement OnSignificantClientMovement;
public List<SceneObjectGroup> InterestList = new List<SceneObjectGroup>();
// private Queue<SceneObjectGroup> m_fullGroupUpdates = new Queue<SceneObjectGroup>(); // private Queue<SceneObjectGroup> m_fullGroupUpdates = new Queue<SceneObjectGroup>();
// private Queue<SceneObjectGroup> m_terseGroupUpdates = new Queue<SceneObjectGroup>(); // private Queue<SceneObjectGroup> m_terseGroupUpdates = new Queue<SceneObjectGroup>();
private Queue<SceneObjectPart> m_fullPartUpdates = new Queue<SceneObjectPart>(); private Queue<SceneObjectPart> m_fullPartUpdates = new Queue<SceneObjectPart>();
private Queue<SceneObjectPart> m_teserPartUpdates = new Queue<SceneObjectPart>(); private Queue<SceneObjectPart> m_tersePartUpdates = new Queue<SceneObjectPart>();
#region Properties #region Properties
/// <summary> /// <summary>
@ -201,7 +203,7 @@ namespace OpenSim.Region.Environment.Scenes
public void AddTersePart(SceneObjectPart part) public void AddTersePart(SceneObjectPart part)
{ {
m_teserPartUpdates.Enqueue(part); m_tersePartUpdates.Enqueue(part);
} }
public void AddFullPart(SceneObjectPart part) public void AddFullPart(SceneObjectPart part)
@ -211,18 +213,18 @@ namespace OpenSim.Region.Environment.Scenes
public void SendPrimUpdates() public void SendPrimUpdates()
{ {
if (m_teserPartUpdates.Count > 0) if (m_tersePartUpdates.Count > 0)
{ {
bool terse = true; bool terse = true;
int terseCount = 0; int terseCount = 0;
while (terse) while (terse)
{ {
SceneObjectPart part = m_teserPartUpdates.Dequeue(); SceneObjectPart part = m_tersePartUpdates.Dequeue();
part.SendTerseUpdate(this.ControllingClient); part.SendTerseUpdate(this.ControllingClient);
terseCount++; terseCount++;
if ((m_teserPartUpdates.Count < 1) |(terseCount > 30)) if ((m_tersePartUpdates.Count < 1) |(terseCount > 30))
{ {
terse = false; terse = false;
} }

View File

@ -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<SceneObjectGroup> m_objects = new List<SceneObjectGroup>();
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<SceneObjectGroup> 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<SceneObjectGroup> outBounds = new List<SceneObjectGroup>();
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);
}
}
}
}
}

View File

@ -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<SceneObjectPart> m_queue;
private List<LLUUID> m_ids;
public UpdateQueue()
{
m_queue = new Queue<SceneObjectPart>();
m_ids = new List<LLUUID>();
}
}
}

View File

@ -30,8 +30,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
//using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Region.Environment.Interfaces;
using libsecondlife; using libsecondlife;
namespace OpenSim.Region.ScriptEngine.DotNetEngine namespace OpenSim.Region.ScriptEngine.DotNetEngine
@ -40,7 +41,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// This is the root object for ScriptEngine /// This is the root object for ScriptEngine
/// </summary> /// </summary>
[Serializable] [Serializable]
public class ScriptEngine : OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface public class ScriptEngine :IRegionModule
{ {
internal OpenSim.Region.Environment.Scenes.Scene World; internal OpenSim.Region.Environment.Scenes.Scene World;
@ -99,5 +100,33 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID); // Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID);
// myScriptManager.StartScript(ScriptID, ObjectID); // 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
} }
} }