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;
}
//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)
{

View File

@ -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)
@ -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;

View File

@ -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

View File

@ -315,6 +315,10 @@ namespace OpenSim.Region.ClientStack
}
public virtual void ConnectionClosed()
{
}
#region Nested Classes
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>

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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<LLUUID, EntityBase>();
Avatars = new Dictionary<LLUUID, ScenePresence>();
@ -596,6 +603,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (!Entities.ContainsKey(sceneObject.UUID))
{
QuadTree.AddObject(sceneObject);
Entities.Add(sceneObject.UUID, sceneObject);
}
}

View File

@ -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;
/// <summary>
@ -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;
}
}

View File

@ -88,11 +88,13 @@ namespace OpenSim.Region.Environment.Scenes
public delegate void SignificantClientMovement(IClientAPI remote_client);
public event SignificantClientMovement OnSignificantClientMovement;
public List<SceneObjectGroup> InterestList = new List<SceneObjectGroup>();
// private Queue<SceneObjectGroup> m_fullGroupUpdates = new Queue<SceneObjectGroup>();
// private Queue<SceneObjectGroup> m_terseGroupUpdates = new Queue<SceneObjectGroup>();
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
/// <summary>
@ -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;
}

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.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
/// </summary>
[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
}
}