From 3d93d390485075345442b9b5ea35eed88a9cab49 Mon Sep 17 00:00:00 2001
From: MW
Date: Wed, 16 May 2007 12:44:58 +0000
Subject: started to refactor startup code and to move udp server code out to
its own class (currently not being used though) so that a single instance can
handle multiple regions (each will need to be listening on a separate udp
port)
---
OpenSim.RegionServer/OpenSim.RegionServer.csproj | 80 +++--
.../OpenSim.RegionServer.dll.build | 16 +-
OpenSim.RegionServer/OpenSimMain.cs | 340 ++++++++++-----------
OpenSim.RegionServer/OpenSimNetworkHandler.cs | 2 -
OpenSim.RegionServer/QueItem.cs | 19 --
OpenSim.RegionServer/RegionInfo.cs | 13 +-
OpenSim.RegionServer/RegionInfoBase.cs | 32 ++
OpenSim.RegionServer/SimClient(Grid).cs | 146 ---------
OpenSim.RegionServer/SimClient.Grid.cs | 146 +++++++++
OpenSim.RegionServer/SimClient.PacketHandlers.cs | 156 ++++++++++
OpenSim.RegionServer/SimClientBase.cs | 32 ++
OpenSim.RegionServer/SimClientPacketHandlers.cs | 156 ----------
OpenSim.RegionServer/UDPServer.cs | 164 ++++++++++
OpenSim.RegionServer/world/Avatar.Client.cs | 33 ++
OpenSim.RegionServer/world/Avatar.Update.cs | 331 ++++++++++++++++++++
OpenSim.RegionServer/world/AvatarClient.cs | 33 --
OpenSim.RegionServer/world/AvatarUpdate.cs | 331 --------------------
OpenSim.RegionServer/world/World.PacketHandlers.cs | 229 ++++++++++++++
OpenSim.RegionServer/world/World.Scripting.cs | 124 ++++++++
OpenSim.RegionServer/world/WorldPacketHandlers.cs | 229 --------------
OpenSim.RegionServer/world/WorldScripting.cs | 124 --------
21 files changed, 1468 insertions(+), 1268 deletions(-)
delete mode 100644 OpenSim.RegionServer/QueItem.cs
create mode 100644 OpenSim.RegionServer/RegionInfoBase.cs
delete mode 100644 OpenSim.RegionServer/SimClient(Grid).cs
create mode 100644 OpenSim.RegionServer/SimClient.Grid.cs
create mode 100644 OpenSim.RegionServer/SimClient.PacketHandlers.cs
create mode 100644 OpenSim.RegionServer/SimClientBase.cs
delete mode 100644 OpenSim.RegionServer/SimClientPacketHandlers.cs
create mode 100644 OpenSim.RegionServer/UDPServer.cs
create mode 100644 OpenSim.RegionServer/world/Avatar.Client.cs
create mode 100644 OpenSim.RegionServer/world/Avatar.Update.cs
delete mode 100644 OpenSim.RegionServer/world/AvatarClient.cs
delete mode 100644 OpenSim.RegionServer/world/AvatarUpdate.cs
create mode 100644 OpenSim.RegionServer/world/World.PacketHandlers.cs
create mode 100644 OpenSim.RegionServer/world/World.Scripting.cs
delete mode 100644 OpenSim.RegionServer/world/WorldPacketHandlers.cs
delete mode 100644 OpenSim.RegionServer/world/WorldScripting.cs
(limited to 'OpenSim.RegionServer')
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
index 9bffb2a..366bd7a 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
@@ -1,4 +1,4 @@
-
+
Local
8.0.50727
@@ -6,7 +6,8 @@
{632E1BFD-0000-0000-0000-000000000000}
Debug
AnyCPU
-
+
+
OpenSim.RegionServer
@@ -15,9 +16,11 @@
IE50
false
Library
-
+
+
OpenSim.RegionServer
-
+
+
@@ -28,7 +31,8 @@
TRACE;DEBUG
-
+
+
True
4096
False
@@ -37,7 +41,8 @@
False
False
4
-
+
+
False
@@ -46,7 +51,8 @@
TRACE
-
+
+
False
4096
True
@@ -55,26 +61,28 @@
False
False
4
-
+
+
-
+
System.dll
False
-
+
+
System.Xml.dll
False
-
+
..\bin\libsecondlife.dll
False
-
+
..\bin\Axiom.MathLib.dll
False
-
+
..\bin\Db4objects.Db4o.dll
False
@@ -84,43 +92,43 @@
OpenSim.Terrain.BasicTerrain
{2270B8FE-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Framework
{8ACA2445-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Framework.Console
{A7CD0630-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.GenericConfig.Xml
{E88EF749-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Physics.Manager
{8BE16150-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Servers
{8BB20F0A-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
XMLRPC
{8E81D43C-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
@@ -139,21 +147,23 @@
Code
-
- Code
-
Code
-
+
+
Code
-
+
Code
+ SimClient.cs
-
+
Code
+ SimClient.cs
+
+
Code
@@ -172,16 +182,18 @@
Code
-
+
Code
+ Avatar.cs
-
+
Code
-
+
Code
+ Avatar.cs
-
+
Code
@@ -199,11 +211,13 @@
Code
-
+
Code
+ World.cs
-
+
Code
+ World.cs
Code
@@ -231,4 +245,4 @@
-
+
\ No newline at end of file
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
index bb7f9ab..ab21d7e 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
@@ -16,28 +16,30 @@
-
-
+
-
+
+
+
+
+
+
-
-
-
-
+
+
diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs
index fc604b7..9995d96 100644
--- a/OpenSim.RegionServer/OpenSimMain.cs
+++ b/OpenSim.RegionServer/OpenSimMain.cs
@@ -56,7 +56,6 @@ namespace OpenSim
public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback
{
- //private SimConfig Cfg;
private IGenericConfig localConfig;
//private IGenericConfig remoteConfig;
private PhysicsManager physManager;
@@ -65,7 +64,6 @@ namespace OpenSim
private World LocalWorld;
private AssetCache AssetCache;
private InventoryCache InventoryCache;
- //private Dictionary ClientThreads = new Dictionary();
private Dictionary clientCircuits = new Dictionary();
private DateTime startuptime;
private RegionInfo regionData;
@@ -79,16 +77,16 @@ namespace OpenSim
private AsyncCallback ReceivedData;
private System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer();
- //private string ConfigDll = "OpenSim.Config.SimConfigDb4o.dll";
public string m_physicsEngine;
public bool m_sandbox = false;
public bool m_loginserver;
- public OpenGridProtocolServer OGSServer;
public bool user_accounts = false;
public bool gridLocalAsset = false;
private bool configFileSetup = false;
public string m_config;
+ protected BaseHttpServer httpServer;
+
protected ConsoleBase m_console;
public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool verbose, string configFile)
@@ -122,42 +120,18 @@ namespace OpenSim
{
this.SetupFromConfigFile(this.localConfig);
}
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Loading configuration");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration");
this.regionData.InitConfig(this.m_sandbox, this.localConfig);
this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
-
GridServers = new Grid();
if (m_sandbox)
{
- GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
- GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
-
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Starting in Sandbox mode");
+ this.SetupLocalGridServers();
}
else
{
- if (this.gridLocalAsset)
- {
- GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
- }
- else
- {
- GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
- }
- GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";
-
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Starting in Grid mode");
- }
-
- try
- {
- GridServers.Initialise();
- }
- catch (Exception e)
- {
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,e.Message + "\nSorry, could not setup the grid interface");
- Environment.Exit(1);
+ this.SetupRemoteGridServers();
}
startuptime = DateTime.Now;
@@ -169,63 +143,120 @@ namespace OpenSim
}
catch (Exception e)
{
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,e.Message + "\nSorry, could not setup local cache");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup local cache");
Environment.Exit(1);
}
PacketServer packetServer = new PacketServer(this);
-
//should be passing a IGenericConfig object to these so they can read the config data they want from it
- GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);
+ GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);
IGridServer gridServer = GridServers.GridServer;
gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey);
if (!m_sandbox)
{
- if (GridServers.GridServer.RequestConnection(regionData.SimUUID, regionData.IPListenAddr, (uint)regionData.IPListenPort))
+ this.ConnectToRemoteGridServer();
+ }
+
+ this.SetupLocalWorld();
+
+ if (m_sandbox)
+ {
+ AssetCache.LoadDefaultTextureSet();
+ }
+
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Initialising HTTP server");
+
+ this.SetupHttpListener();
+
+ LoginServer loginServer = null;
+ LoginServer adminLoginServer = null;
+
+ bool sandBoxWithLoginServer = m_loginserver && m_sandbox;
+ if (sandBoxWithLoginServer)
+ {
+ loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
+ loginServer.Startup();
+
+ if (user_accounts)
{
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Success: Got a grid connection OK!");
+ //sandbox mode with loginserver using accounts
+ this.GridServers.UserServer = loginServer;
+ adminLoginServer = loginServer;
+
+ httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
}
else
{
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL,"Main.cs:Startup() - FAILED: Unable to get connection to grid. Shutting down.");
- Shutdown();
+ //sandbox mode with loginserver not using accounts
+ httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
}
+ }
- GridServers.AssetServer.SetServerInfo((string)((RemoteGridBase)GridServers.GridServer).GridData["asset_url"], (string)((RemoteGridBase)GridServers.GridServer).GridData["asset_sendkey"]);
+ AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);
+ adminWebFront.LoadMethods(httpServer);
- // If we are being told to load a file, load it.
- string dataUri = (string)((RemoteGridBase)GridServers.GridServer).GridData["data_uri"];
-
- if ( !String.IsNullOrEmpty( dataUri ) )
- {
- this.LocalWorld.m_datastore = dataUri;
- }
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting HTTP server");
+ httpServer.Start();
- if (((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString() != "")
- {
- // The grid server has told us who we are
- // We must obey the grid server.
- try
- {
- regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString());
- regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString());
- regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString();
- }
- catch (Exception e)
- {
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL,e.Message + "\nBAD ERROR! THIS SHOULD NOT HAPPEN! Bad GridData from the grid interface!!!! ZOMG!!!");
- Environment.Exit(1);
- }
- }
+ MainServerListener();
+ m_heartbeatTimer.Enabled = true;
+ m_heartbeatTimer.Interval = 100;
+ m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
+ }
+
+ # region Setup methods
+ protected virtual void SetupLocalGridServers()
+ {
+ GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
+ GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
+
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Sandbox mode");
+
+ try
+ {
+ GridServers.Initialise();
+ }
+ catch (Exception e)
+ {
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
+ Environment.Exit(1);
+ }
+ }
+
+ protected virtual void SetupRemoteGridServers()
+ {
+ if (this.gridLocalAsset)
+ {
+ GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
+ }
+ else
+ {
+ GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
}
+ GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Grid mode");
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL,"Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString());
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Initialising world");
+ try
+ {
+ GridServers.Initialise();
+ }
+ catch (Exception e)
+ {
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
+ Environment.Exit(1);
+ }
+ }
+
+ protected virtual void SetupLocalWorld()
+ {
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString());
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Initialising world");
m_console.componentname = "Region " + regionData.RegionName;
+
LocalWorld = new World(this._packetServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName);
LocalWorld.InventoryCache = InventoryCache;
LocalWorld.AssetCache = AssetCache;
@@ -241,28 +272,18 @@ namespace OpenSim
LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
LocalWorld.LoadWorldMap();
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting up messaging system");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting up messaging system");
LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use
LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D());
-
-
LocalWorld.LoadPrimsFromStorage();
+ }
- if (m_sandbox)
- {
- AssetCache.LoadDefaultTextureSet();
- }
-
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Initialising HTTP server");
- // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort);
-
- BaseHttpServer httpServer = new BaseHttpServer(regionData.IPListenPort);
+ protected virtual void SetupHttpListener()
+ {
+ httpServer = new BaseHttpServer(regionData.IPListenPort);
- if (gridServer.GetName() == "Remote")
+ if (this.GridServers.GridServer.GetName() == "Remote")
{
- // should startup the OGS protocol server here
- // Are we actually using this?
- OGSServer = new OpenGridProtocolServer(this.regionData.IPListenPort - 500); // Changed so we can have more than one OGSServer per machine.
// we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
httpServer.AddXmlRPCHandler("expect_user",
@@ -286,13 +307,13 @@ namespace OpenSim
agent_data.child = false;
}
- if (((RemoteGridBase)gridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode))
+ if (((RemoteGridBase)this.GridServers.GridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode))
{
- ((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode] = agent_data;
+ ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode] = agent_data;
}
else
{
- ((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data);
+ ((RemoteGridBase)this.GridServers.GridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data);
}
return new XmlRpcResponse();
@@ -308,11 +329,11 @@ namespace OpenSim
agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
agent_data.startpos = new LLVector3(Single.Parse((string)requestData["pos_x"]), Single.Parse((string)requestData["pos_y"]), Single.Parse((string)requestData["pos_z"]));
- if (((RemoteGridBase)gridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode))
+ if (((RemoteGridBase)this.GridServers.GridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode))
{
- ((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode].firstname = agent_data.firstname;
- ((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode].lastname = agent_data.lastname;
- ((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode].startpos = agent_data.startpos;
+ ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].firstname = agent_data.firstname;
+ ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].lastname = agent_data.lastname;
+ ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].startpos = agent_data.startpos;
}
return new XmlRpcResponse();
@@ -324,50 +345,50 @@ namespace OpenSim
return "OK";
});
}
+ }
- LoginServer loginServer = null;
- LoginServer adminLoginServer = null;
-
- bool sandBoxWithLoginServer = m_loginserver && m_sandbox;
- if (sandBoxWithLoginServer)
+ protected virtual void ConnectToRemoteGridServer()
+ {
+ if (GridServers.GridServer.RequestConnection(regionData.SimUUID, regionData.IPListenAddr, (uint)regionData.IPListenPort))
{
- loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort,regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
- loginServer.Startup();
-
- if (user_accounts)
- {
- //sandbox mode with loginserver using accounts
- this.GridServers.UserServer = loginServer;
- adminLoginServer = loginServer;
-
- httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
- }
- else
- {
- //sandbox mode with loginserver not using accounts
- httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
- }
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Success: Got a grid connection OK!");
+ }
+ else
+ {
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "Main.cs:Startup() - FAILED: Unable to get connection to grid. Shutting down.");
+ Shutdown();
}
- AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);
- adminWebFront.LoadMethods(httpServer);
+ GridServers.AssetServer.SetServerInfo((string)((RemoteGridBase)GridServers.GridServer).GridData["asset_url"], (string)((RemoteGridBase)GridServers.GridServer).GridData["asset_sendkey"]);
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting HTTP server");
- httpServer.Start();
+ // If we are being told to load a file, load it.
+ string dataUri = (string)((RemoteGridBase)GridServers.GridServer).GridData["data_uri"];
- if (gridServer.GetName() == "Remote")
+ if (!String.IsNullOrEmpty(dataUri))
{
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting up OGS protocol server");
- OGSServer.Start();
+ this.LocalWorld.m_datastore = dataUri;
}
- MainServerListener();
-
- m_heartbeatTimer.Enabled = true;
- m_heartbeatTimer.Interval = 100;
- m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
+ if (((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString() != "")
+ {
+ // The grid server has told us who we are
+ // We must obey the grid server.
+ try
+ {
+ regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString());
+ regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString());
+ regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString();
+ }
+ catch (Exception e)
+ {
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, e.Message + "\nBAD ERROR! THIS SHOULD NOT HAPPEN! Bad GridData from the grid interface!!!! ZOMG!!!");
+ Environment.Exit(1);
+ }
+ }
}
+ #endregion
+
private void SetupFromConfigFile(IGenericConfig configData)
{
try
@@ -430,7 +451,7 @@ namespace OpenSim
switch (attri)
{
default:
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating");
Environment.Exit(1);
break;
@@ -468,44 +489,7 @@ namespace OpenSim
}
}
- private SimConfig LoadConfigDll(string dllName)
- {
- try
- {
- Assembly pluginAssembly = Assembly.LoadFrom(dllName);
- SimConfig config = null;
-
- foreach (Type pluginType in pluginAssembly.GetTypes())
- {
- if (pluginType.IsPublic)
- {
- if (!pluginType.IsAbstract)
- {
- Type typeInterface = pluginType.GetInterface("ISimConfig", true);
-
- if (typeInterface != null)
- {
- ISimConfig plug = (ISimConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
- config = plug.GetConfigObject();
- break;
- }
-
- typeInterface = null;
- }
- }
- }
- pluginAssembly = null;
- return config;
- }
- catch (Exception e)
- {
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL,e.Message + "\nSorry, a fatal error occurred while trying to load the config DLL");
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL,"Can not continue starting up");
- Environment.Exit(1);
- return null;
- }
- }
-
+ # region UDP
private void OnReceivedData(IAsyncResult result)
{
ipeSender = new IPEndPoint(IPAddress.Any, 0);
@@ -544,7 +528,7 @@ namespace OpenSim
this._packetServer.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
//if (!((RemoteGridBase)GridServers.GridServer).agentcircuits[useCircuit.CircuitCode.Code].child)
-
+
}
else
@@ -557,21 +541,21 @@ namespace OpenSim
private void MainServerListener()
{
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:MainServerListener() - New thread started");
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:MainServerListener() - Opening UDP socket on " + regionData.IPListenAddr + ":" + regionData.IPListenPort);
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:MainServerListener() - New thread started");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:MainServerListener() - Opening UDP socket on " + regionData.IPListenAddr + ":" + regionData.IPListenPort);
ServerIncoming = new IPEndPoint(IPAddress.Any, regionData.IPListenPort);
Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
Server.Bind(ServerIncoming);
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:MainServerListener() - UDP socket bound, getting ready to listen");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:MainServerListener() - UDP socket bound, getting ready to listen");
ipeSender = new IPEndPoint(IPAddress.Any, 0);
epSender = (EndPoint)ipeSender;
ReceivedData = new AsyncCallback(this.OnReceivedData);
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:MainServerListener() - Listening...");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:MainServerListener() - Listening...");
}
@@ -611,16 +595,18 @@ namespace OpenSim
}
}
+ #endregion
+
///
/// Performs any last-minute sanity checking and shuts down the region server
///
public virtual void Shutdown()
{
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Shutdown() - Closing all threads");
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Shutdown() - Killing listener thread");
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Shutdown() - Killing clients");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing all threads");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing listener thread");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing clients");
// IMPLEMENT THIS
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Shutdown() - Closing console and terminating");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing console and terminating");
LocalWorld.Close();
GridServers.Close();
m_console.Close();
@@ -637,6 +623,7 @@ namespace OpenSim
LocalWorld.Update();
}
+ #region Console Commands
///
/// Runs commands issued by the server console from the operator
///
@@ -647,8 +634,8 @@ namespace OpenSim
switch (command)
{
case "help":
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"show users - show info about connected users");
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"shutdown - disconnect all clients and shutdown");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "show users - show info about connected users");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "shutdown - disconnect all clients and shutdown");
break;
case "show":
@@ -659,7 +646,7 @@ namespace OpenSim
string result = "";
if (!LocalWorld.Terrain.RunTerrainCmd(cmdparams, ref result))
{
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,result);
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, result);
}
break;
@@ -668,7 +655,7 @@ namespace OpenSim
break;
default:
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"Unknown command");
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "Unknown command");
break;
}
}
@@ -682,23 +669,24 @@ namespace OpenSim
switch (ShowWhat)
{
case "uptime":
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"OpenSim has been running since " + startuptime.ToString());
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"That is " + (DateTime.Now - startuptime).ToString());
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "OpenSim has been running since " + startuptime.ToString());
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "That is " + (DateTime.Now - startuptime).ToString());
break;
case "users":
OpenSim.world.Avatar TempAv;
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP"));
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP"));
foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys)
{
if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar")
{
TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID];
- m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()));
+ m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()));
}
}
break;
}
}
+ #endregion
}
diff --git a/OpenSim.RegionServer/OpenSimNetworkHandler.cs b/OpenSim.RegionServer/OpenSimNetworkHandler.cs
index 6649120..e3a7375 100644
--- a/OpenSim.RegionServer/OpenSimNetworkHandler.cs
+++ b/OpenSim.RegionServer/OpenSimNetworkHandler.cs
@@ -8,8 +8,6 @@ namespace OpenSim
{
public interface OpenSimNetworkHandler
{
- //public abstract void StartUp();
- // public abstract void Shutdown();
void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender);
void RemoveClientCircuit(uint circuitcode);
void RegisterPacketServer(PacketServer server);
diff --git a/OpenSim.RegionServer/QueItem.cs b/OpenSim.RegionServer/QueItem.cs
deleted file mode 100644
index d9b77ba..0000000
--- a/OpenSim.RegionServer/QueItem.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using libsecondlife.Packets;
-
-namespace OpenSim
-{
- /*
- public class QueItem
- {
- public QueItem()
- {
- }
-
- public Packet Packet;
- public bool Incoming;
- }*/
-
-}
diff --git a/OpenSim.RegionServer/RegionInfo.cs b/OpenSim.RegionServer/RegionInfo.cs
index 2707257..f82495a 100644
--- a/OpenSim.RegionServer/RegionInfo.cs
+++ b/OpenSim.RegionServer/RegionInfo.cs
@@ -10,19 +10,8 @@ using libsecondlife;
namespace OpenSim
{
- public class RegionInfo // could inherit from SimProfileBase
+ public class RegionInfo : RegionInfoBase
{
- public LLUUID SimUUID;
- public string RegionName;
- public uint RegionLocX;
- public uint RegionLocY;
- public ulong RegionHandle;
- public ushort RegionWaterHeight = 20;
- public bool RegionTerraform = true;
-
- public int IPListenPort;
- public string IPListenAddr;
-
//following should be removed and the GenericConfig object passed around,
//so each class (AssetServer, GridServer etc) can access what config data they want
public string AssetURL = "http://127.0.0.1:8003/";
diff --git a/OpenSim.RegionServer/RegionInfoBase.cs b/OpenSim.RegionServer/RegionInfoBase.cs
new file mode 100644
index 0000000..42d3030
--- /dev/null
+++ b/OpenSim.RegionServer/RegionInfoBase.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Net;
+using System.Web;
+using System.IO;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Framework.Utilities;
+using libsecondlife;
+
+namespace OpenSim
+{
+ public class RegionInfoBase
+ {
+ public LLUUID SimUUID;
+ public string RegionName;
+ public uint RegionLocX;
+ public uint RegionLocY;
+ public ulong RegionHandle;
+ public ushort RegionWaterHeight = 20;
+ public bool RegionTerraform = true;
+
+ public int IPListenPort;
+ public string IPListenAddr;
+
+ public RegionInfoBase()
+ {
+
+ }
+ }
+
+}
diff --git a/OpenSim.RegionServer/SimClient(Grid).cs b/OpenSim.RegionServer/SimClient(Grid).cs
deleted file mode 100644
index b0d59cc..0000000
--- a/OpenSim.RegionServer/SimClient(Grid).cs
+++ /dev/null
@@ -1,146 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using libsecondlife;
-using libsecondlife.Packets;
-using Nwc.XmlRpc;
-using System.Net;
-using System.Net.Sockets;
-using System.IO;
-using System.Threading;
-using System.Timers;
-using OpenSim.Framework.Interfaces;
-using OpenSim.Framework.Types;
-using OpenSim.Framework.Inventory;
-using OpenSim.Framework.Utilities;
-using OpenSim.world;
-using OpenSim.Assets;
-
-namespace OpenSim
-{
- public partial class SimClient
- {
-
- public void EnableNeighbours()
- {
- if ((this.m_gridServer.GetName() == "Remote") && (!this.m_child))
- {
- Hashtable SimParams;
- ArrayList SendParams;
- XmlRpcRequest GridReq;
- XmlRpcResponse GridResp;
- List enablePackets = new List();
- foreach (Hashtable neighbour in ((RemoteGridBase)this.m_gridServer).neighbours)
- {
- Console.WriteLine("http://" + neighbour["sim_ip"] + ":" + neighbour["sim_port"]);
- SimParams = new Hashtable();
- SimParams["session_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].SessionID.ToString();
- SimParams["secure_session_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].SecureSessionID.ToString();
- SimParams["firstname"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].firstname;
- SimParams["lastname"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].lastname;
- SimParams["agent_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].AgentID.ToString();
- SimParams["circuit_code"] = (Int32)this.CircuitCode;
- SimParams["child_agent"] = "1";
- SendParams = new ArrayList();
- SendParams.Add(SimParams);
-
- GridReq = new XmlRpcRequest("expect_user", SendParams);
- GridResp = GridReq.Send("http://" + neighbour["sim_ip"] + ":" + neighbour["sim_port"], 3000);
- EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
- enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
- enablesimpacket.SimulatorInfo.Handle = Helpers.UIntsToLong((uint)(Convert.ToInt32(neighbour["region_locx"]) * 256), (uint)(Convert.ToInt32(neighbour["region_locy"]) * 256));
- System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)neighbour["sim_ip"]);
- byte[] byteIP = neighbourIP.GetAddressBytes();
- enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
- enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
- enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
- enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
- enablesimpacket.SimulatorInfo.Port = (ushort)Convert.ToInt32(neighbour["sim_port"]);
- enablePackets.Add(enablesimpacket);
- }
- Thread.Sleep(3000);
- foreach (Packet enable in enablePackets)
- {
- this.OutPacket(enable);
- }
- enablePackets.Clear();
- }
- }
-
- public void CrossSimBorder(LLVector3 avatarpos)
- { // VERY VERY BASIC
-
- LLVector3 newpos = avatarpos;
- uint neighbourx = this.m_regionData.RegionLocX;
- uint neighboury = this.m_regionData.RegionLocY;
-
- if (avatarpos.X < 0)
- {
- neighbourx -= 1;
- newpos.X = 254;
- }
- if (avatarpos.X > 255)
- {
- neighbourx += 1;
- newpos.X = 1;
- }
- if (avatarpos.Y < 0)
- {
- neighboury -= 1;
- newpos.Y = 254;
- }
- if (avatarpos.Y > 255)
- {
- neighbourx += 1;
- newpos.Y = 1;
- }
- OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]");
-
- Hashtable SimParams;
- ArrayList SendParams;
- XmlRpcRequest GridReq;
- XmlRpcResponse GridResp;
- foreach (Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours)
- {
- if (((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString()))
- {
- SimParams = new Hashtable();
- SimParams["firstname"] = this.ClientAvatar.firstname;
- SimParams["lastname"] = this.ClientAvatar.lastname;
- SimParams["circuit_code"] = this.CircuitCode.ToString();
- SimParams["pos_x"] = newpos.X.ToString();
- SimParams["pos_y"] = newpos.Y.ToString();
- SimParams["pos_z"] = newpos.Z.ToString();
- SendParams = new ArrayList();
- SendParams.Add(SimParams);
-
- GridReq = new XmlRpcRequest("agent_crossing", SendParams);
- GridResp = GridReq.Send("http://" + borderingSim["sim_ip"] + ":" + borderingSim["sim_port"], 3000);
-
- CrossedRegionPacket NewSimPack = new CrossedRegionPacket();
- NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
- NewSimPack.AgentData.AgentID = this.AgentID;
- NewSimPack.AgentData.SessionID = this.SessionID;
- NewSimPack.Info = new CrossedRegionPacket.InfoBlock();
- NewSimPack.Info.Position = newpos;
- NewSimPack.Info.LookAt = new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
- NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock();
- NewSimPack.RegionData.RegionHandle = Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256));
- System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]);
- byte[] byteIP = neighbourIP.GetAddressBytes();
- NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
- NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
- NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
- NewSimPack.RegionData.SimIP += (uint)byteIP[0];
- NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]);
- NewSimPack.RegionData.SeedCapability = new byte[0];
- lock (PacketQueue)
- {
- ProcessOutPacket(NewSimPack);
- DowngradeClient();
- }
- }
- }
- }
- }
-}
diff --git a/OpenSim.RegionServer/SimClient.Grid.cs b/OpenSim.RegionServer/SimClient.Grid.cs
new file mode 100644
index 0000000..b0d59cc
--- /dev/null
+++ b/OpenSim.RegionServer/SimClient.Grid.cs
@@ -0,0 +1,146 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using libsecondlife;
+using libsecondlife.Packets;
+using Nwc.XmlRpc;
+using System.Net;
+using System.Net.Sockets;
+using System.IO;
+using System.Threading;
+using System.Timers;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Framework.Types;
+using OpenSim.Framework.Inventory;
+using OpenSim.Framework.Utilities;
+using OpenSim.world;
+using OpenSim.Assets;
+
+namespace OpenSim
+{
+ public partial class SimClient
+ {
+
+ public void EnableNeighbours()
+ {
+ if ((this.m_gridServer.GetName() == "Remote") && (!this.m_child))
+ {
+ Hashtable SimParams;
+ ArrayList SendParams;
+ XmlRpcRequest GridReq;
+ XmlRpcResponse GridResp;
+ List enablePackets = new List();
+ foreach (Hashtable neighbour in ((RemoteGridBase)this.m_gridServer).neighbours)
+ {
+ Console.WriteLine("http://" + neighbour["sim_ip"] + ":" + neighbour["sim_port"]);
+ SimParams = new Hashtable();
+ SimParams["session_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].SessionID.ToString();
+ SimParams["secure_session_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].SecureSessionID.ToString();
+ SimParams["firstname"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].firstname;
+ SimParams["lastname"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].lastname;
+ SimParams["agent_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].AgentID.ToString();
+ SimParams["circuit_code"] = (Int32)this.CircuitCode;
+ SimParams["child_agent"] = "1";
+ SendParams = new ArrayList();
+ SendParams.Add(SimParams);
+
+ GridReq = new XmlRpcRequest("expect_user", SendParams);
+ GridResp = GridReq.Send("http://" + neighbour["sim_ip"] + ":" + neighbour["sim_port"], 3000);
+ EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
+ enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
+ enablesimpacket.SimulatorInfo.Handle = Helpers.UIntsToLong((uint)(Convert.ToInt32(neighbour["region_locx"]) * 256), (uint)(Convert.ToInt32(neighbour["region_locy"]) * 256));
+ System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)neighbour["sim_ip"]);
+ byte[] byteIP = neighbourIP.GetAddressBytes();
+ enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
+ enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
+ enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
+ enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
+ enablesimpacket.SimulatorInfo.Port = (ushort)Convert.ToInt32(neighbour["sim_port"]);
+ enablePackets.Add(enablesimpacket);
+ }
+ Thread.Sleep(3000);
+ foreach (Packet enable in enablePackets)
+ {
+ this.OutPacket(enable);
+ }
+ enablePackets.Clear();
+ }
+ }
+
+ public void CrossSimBorder(LLVector3 avatarpos)
+ { // VERY VERY BASIC
+
+ LLVector3 newpos = avatarpos;
+ uint neighbourx = this.m_regionData.RegionLocX;
+ uint neighboury = this.m_regionData.RegionLocY;
+
+ if (avatarpos.X < 0)
+ {
+ neighbourx -= 1;
+ newpos.X = 254;
+ }
+ if (avatarpos.X > 255)
+ {
+ neighbourx += 1;
+ newpos.X = 1;
+ }
+ if (avatarpos.Y < 0)
+ {
+ neighboury -= 1;
+ newpos.Y = 254;
+ }
+ if (avatarpos.Y > 255)
+ {
+ neighbourx += 1;
+ newpos.Y = 1;
+ }
+ OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]");
+
+ Hashtable SimParams;
+ ArrayList SendParams;
+ XmlRpcRequest GridReq;
+ XmlRpcResponse GridResp;
+ foreach (Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours)
+ {
+ if (((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString()))
+ {
+ SimParams = new Hashtable();
+ SimParams["firstname"] = this.ClientAvatar.firstname;
+ SimParams["lastname"] = this.ClientAvatar.lastname;
+ SimParams["circuit_code"] = this.CircuitCode.ToString();
+ SimParams["pos_x"] = newpos.X.ToString();
+ SimParams["pos_y"] = newpos.Y.ToString();
+ SimParams["pos_z"] = newpos.Z.ToString();
+ SendParams = new ArrayList();
+ SendParams.Add(SimParams);
+
+ GridReq = new XmlRpcRequest("agent_crossing", SendParams);
+ GridResp = GridReq.Send("http://" + borderingSim["sim_ip"] + ":" + borderingSim["sim_port"], 3000);
+
+ CrossedRegionPacket NewSimPack = new CrossedRegionPacket();
+ NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
+ NewSimPack.AgentData.AgentID = this.AgentID;
+ NewSimPack.AgentData.SessionID = this.SessionID;
+ NewSimPack.Info = new CrossedRegionPacket.InfoBlock();
+ NewSimPack.Info.Position = newpos;
+ NewSimPack.Info.LookAt = new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
+ NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock();
+ NewSimPack.RegionData.RegionHandle = Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256));
+ System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]);
+ byte[] byteIP = neighbourIP.GetAddressBytes();
+ NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
+ NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
+ NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
+ NewSimPack.RegionData.SimIP += (uint)byteIP[0];
+ NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]);
+ NewSimPack.RegionData.SeedCapability = new byte[0];
+ lock (PacketQueue)
+ {
+ ProcessOutPacket(NewSimPack);
+ DowngradeClient();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/OpenSim.RegionServer/SimClient.PacketHandlers.cs b/OpenSim.RegionServer/SimClient.PacketHandlers.cs
new file mode 100644
index 0000000..5007a60
--- /dev/null
+++ b/OpenSim.RegionServer/SimClient.PacketHandlers.cs
@@ -0,0 +1,156 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using libsecondlife;
+using libsecondlife.Packets;
+using Nwc.XmlRpc;
+using System.Net;
+using System.Net.Sockets;
+using System.IO;
+using System.Threading;
+using System.Timers;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Framework.Types;
+using OpenSim.Framework.Inventory;
+using OpenSim.Framework.Utilities;
+using OpenSim.world;
+using OpenSim.Assets;
+
+namespace OpenSim
+{
+ public partial class SimClient
+ {
+ protected virtual bool Logout(SimClient simClient, Packet packet)
+ {
+ OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ProcessInPacket() - Got a logout request");
+ //send reply to let the client logout
+ LogoutReplyPacket logReply = new LogoutReplyPacket();
+ logReply.AgentData.AgentID = this.AgentID;
+ logReply.AgentData.SessionID = this.SessionID;
+ logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
+ logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
+ logReply.InventoryData[0].ItemID = LLUUID.Zero;
+ OutPacket(logReply);
+ //tell all clients to kill our object
+ KillObjectPacket kill = new KillObjectPacket();
+ kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
+ kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
+ kill.ObjectData[0].ID = this.ClientAvatar.localid;
+ foreach (SimClient client in m_clientThreads.Values)
+ {
+ client.OutPacket(kill);
+ }
+ if (this.m_userServer != null)
+ {
+ this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer);
+ }
+ else
+ {
+ this.m_inventoryCache.ClientLeaving(this.AgentID, null);
+ }
+
+ m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode);
+ /*lock (m_world.Entities)
+ {
+ m_world.Entities.Remove(this.AgentID);
+ }*/
+ m_world.RemoveViewerAgent(this);
+ //need to do other cleaning up here too
+ m_clientThreads.Remove(this.CircuitCode);
+ m_application.RemoveClientCircuit(this.CircuitCode);
+ this.ClientThread.Abort();
+ return true;
+ }
+
+ protected bool AgentTextureCached(SimClient simclient, Packet packet)
+ {
+ // Console.WriteLine(packet.ToString());
+ AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
+ AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
+ cachedresp.AgentData.AgentID = this.AgentID;
+ cachedresp.AgentData.SessionID = this.SessionID;
+ cachedresp.AgentData.SerialNum = this.cachedtextureserial;
+ this.cachedtextureserial++;
+ cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
+ for (int i = 0; i < chechedtex.WearableData.Length; i++)
+ {
+ cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
+ cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
+ cachedresp.WearableData[i].TextureID = LLUUID.Zero;
+ cachedresp.WearableData[i].HostName = new byte[0];
+ }
+ this.OutPacket(cachedresp);
+ return true;
+ }
+
+ protected bool MultipleObjUpdate(SimClient simClient, Packet packet)
+ {
+ MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
+ for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
+ {
+ if (multipleupdate.ObjectData[i].Type == 9) //change position
+ {
+ libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
+ foreach (Entity ent in m_world.Entities.Values)
+ {
+ if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
+ {
+ ((OpenSim.world.Primitive)ent).UpdatePosition(pos);
+
+ }
+ }
+ //should update stored position of the prim
+ }
+ else if (multipleupdate.ObjectData[i].Type == 10)//rotation
+ {
+ libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
+ foreach (Entity ent in m_world.Entities.Values)
+ {
+ if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
+ {
+ ent.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
+ ((OpenSim.world.Primitive)ent).UpdateFlag = true;
+ }
+ }
+ }
+ else if (multipleupdate.ObjectData[i].Type == 13)//scale
+ {
+
+ libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
+ foreach (Entity ent in m_world.Entities.Values)
+ {
+ if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
+ {
+ ((OpenSim.world.Primitive)ent).Scale = scale;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public void RequestMapLayer() //should be getting the map layer from the grid server
+ {
+ //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
+ MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
+ mapReply.AgentData.AgentID = this.AgentID;
+ mapReply.AgentData.Flags = 0;
+ mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
+ mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
+ mapReply.LayerData[0].Bottom = 800;
+ mapReply.LayerData[0].Left = 800;
+ mapReply.LayerData[0].Top = 1200;
+ mapReply.LayerData[0].Right = 1200;
+ mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
+ this.OutPacket(mapReply);
+ }
+
+ public void RequestMapBlock(int minX, int minY, int maxX, int maxY)
+ {
+ //check if our own map was requested
+ this.m_world.RequestMapBlock(this, minX, minY, maxX, maxY);
+
+ //now should get other regions maps from gridserver
+ }
+ }
+}
diff --git a/OpenSim.RegionServer/SimClientBase.cs b/OpenSim.RegionServer/SimClientBase.cs
new file mode 100644
index 0000000..d0dd381
--- /dev/null
+++ b/OpenSim.RegionServer/SimClientBase.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using libsecondlife;
+using libsecondlife.Packets;
+
+namespace OpenSim
+{
+ public class SimClientBase
+ {
+
+ protected virtual void ProcessInPacket(Packet Pack)
+ {
+
+ }
+
+ protected virtual void ProcessOutPacket(Packet Pack)
+ {
+
+ }
+
+ public virtual void InPacket(Packet NewPack)
+ {
+
+ }
+
+ public virtual void OutPacket(Packet NewPack)
+ {
+
+ }
+ }
+}
diff --git a/OpenSim.RegionServer/SimClientPacketHandlers.cs b/OpenSim.RegionServer/SimClientPacketHandlers.cs
deleted file mode 100644
index 5007a60..0000000
--- a/OpenSim.RegionServer/SimClientPacketHandlers.cs
+++ /dev/null
@@ -1,156 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using libsecondlife;
-using libsecondlife.Packets;
-using Nwc.XmlRpc;
-using System.Net;
-using System.Net.Sockets;
-using System.IO;
-using System.Threading;
-using System.Timers;
-using OpenSim.Framework.Interfaces;
-using OpenSim.Framework.Types;
-using OpenSim.Framework.Inventory;
-using OpenSim.Framework.Utilities;
-using OpenSim.world;
-using OpenSim.Assets;
-
-namespace OpenSim
-{
- public partial class SimClient
- {
- protected virtual bool Logout(SimClient simClient, Packet packet)
- {
- OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ProcessInPacket() - Got a logout request");
- //send reply to let the client logout
- LogoutReplyPacket logReply = new LogoutReplyPacket();
- logReply.AgentData.AgentID = this.AgentID;
- logReply.AgentData.SessionID = this.SessionID;
- logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
- logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
- logReply.InventoryData[0].ItemID = LLUUID.Zero;
- OutPacket(logReply);
- //tell all clients to kill our object
- KillObjectPacket kill = new KillObjectPacket();
- kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
- kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
- kill.ObjectData[0].ID = this.ClientAvatar.localid;
- foreach (SimClient client in m_clientThreads.Values)
- {
- client.OutPacket(kill);
- }
- if (this.m_userServer != null)
- {
- this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer);
- }
- else
- {
- this.m_inventoryCache.ClientLeaving(this.AgentID, null);
- }
-
- m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode);
- /*lock (m_world.Entities)
- {
- m_world.Entities.Remove(this.AgentID);
- }*/
- m_world.RemoveViewerAgent(this);
- //need to do other cleaning up here too
- m_clientThreads.Remove(this.CircuitCode);
- m_application.RemoveClientCircuit(this.CircuitCode);
- this.ClientThread.Abort();
- return true;
- }
-
- protected bool AgentTextureCached(SimClient simclient, Packet packet)
- {
- // Console.WriteLine(packet.ToString());
- AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
- AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
- cachedresp.AgentData.AgentID = this.AgentID;
- cachedresp.AgentData.SessionID = this.SessionID;
- cachedresp.AgentData.SerialNum = this.cachedtextureserial;
- this.cachedtextureserial++;
- cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
- for (int i = 0; i < chechedtex.WearableData.Length; i++)
- {
- cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
- cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
- cachedresp.WearableData[i].TextureID = LLUUID.Zero;
- cachedresp.WearableData[i].HostName = new byte[0];
- }
- this.OutPacket(cachedresp);
- return true;
- }
-
- protected bool MultipleObjUpdate(SimClient simClient, Packet packet)
- {
- MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
- for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
- {
- if (multipleupdate.ObjectData[i].Type == 9) //change position
- {
- libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
- foreach (Entity ent in m_world.Entities.Values)
- {
- if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
- {
- ((OpenSim.world.Primitive)ent).UpdatePosition(pos);
-
- }
- }
- //should update stored position of the prim
- }
- else if (multipleupdate.ObjectData[i].Type == 10)//rotation
- {
- libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
- foreach (Entity ent in m_world.Entities.Values)
- {
- if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
- {
- ent.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
- ((OpenSim.world.Primitive)ent).UpdateFlag = true;
- }
- }
- }
- else if (multipleupdate.ObjectData[i].Type == 13)//scale
- {
-
- libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
- foreach (Entity ent in m_world.Entities.Values)
- {
- if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
- {
- ((OpenSim.world.Primitive)ent).Scale = scale;
- }
- }
- }
- }
- return true;
- }
-
- public void RequestMapLayer() //should be getting the map layer from the grid server
- {
- //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
- MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
- mapReply.AgentData.AgentID = this.AgentID;
- mapReply.AgentData.Flags = 0;
- mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
- mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
- mapReply.LayerData[0].Bottom = 800;
- mapReply.LayerData[0].Left = 800;
- mapReply.LayerData[0].Top = 1200;
- mapReply.LayerData[0].Right = 1200;
- mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
- this.OutPacket(mapReply);
- }
-
- public void RequestMapBlock(int minX, int minY, int maxX, int maxY)
- {
- //check if our own map was requested
- this.m_world.RequestMapBlock(this, minX, minY, maxX, maxY);
-
- //now should get other regions maps from gridserver
- }
- }
-}
diff --git a/OpenSim.RegionServer/UDPServer.cs b/OpenSim.RegionServer/UDPServer.cs
new file mode 100644
index 0000000..e70ae78
--- /dev/null
+++ b/OpenSim.RegionServer/UDPServer.cs
@@ -0,0 +1,164 @@
+using System;
+using System.Text;
+using System.IO;
+using System.Threading;
+using System.Net;
+using System.Net.Sockets;
+using System.Timers;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using libsecondlife;
+using libsecondlife.Packets;
+using OpenSim.world;
+using OpenSim.Terrain;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Framework.Types;
+using OpenSim.UserServer;
+using OpenSim.Assets;
+using OpenSim.CAPS;
+using OpenSim.Framework.Console;
+using Nwc.XmlRpc;
+using OpenSim.Servers;
+using OpenSim.GenericConfig;
+
+namespace OpenSim
+{
+ public class UDPServer : OpenSimNetworkHandler
+ {
+ private Dictionary clientCircuits = new Dictionary();
+ public Socket Server;
+ private IPEndPoint ServerIncoming;
+ private byte[] RecvBuffer = new byte[4096];
+ private byte[] ZeroBuffer = new byte[8192];
+ private IPEndPoint ipeSender;
+ private EndPoint epSender;
+ private AsyncCallback ReceivedData;
+ private PacketServer _packetServer;
+
+ private int listenPort;
+ private Grid m_gridServers;
+ private World m_localWorld;
+ private AssetCache m_assetCache;
+ private InventoryCache m_inventoryCache;
+ private RegionInfo m_regionData;
+ private bool m_sandbox = false;
+ private bool user_accounts = false;
+ private ConsoleBase m_console;
+
+ public UDPServer(int port, Grid gridServers, World localWorld, AssetCache assetCache, InventoryCache inventoryCache, RegionInfo _regionData, bool sandbox, bool accounts, ConsoleBase console)
+ {
+ listenPort = port;
+ this.m_gridServers = gridServers;
+ this.m_localWorld = localWorld;
+ this.m_assetCache = assetCache;
+ this.m_inventoryCache = inventoryCache;
+ this.m_regionData = _regionData;
+ this.m_sandbox = sandbox;
+ this.user_accounts = accounts;
+ this.m_console = console;
+ PacketServer packetServer = new PacketServer(this);
+ this._packetServer.LocalWorld = m_localWorld;
+ this._packetServer.RegisterClientPacketHandlers();
+ }
+
+ protected virtual void OnReceivedData(IAsyncResult result)
+ {
+ ipeSender = new IPEndPoint(IPAddress.Any, 0);
+ epSender = (EndPoint)ipeSender;
+ Packet packet = null;
+ int numBytes = Server.EndReceiveFrom(result, ref epSender);
+ int packetEnd = numBytes - 1;
+
+ packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
+
+ // do we already have a circuit for this endpoint
+ if (this.clientCircuits.ContainsKey(epSender))
+ {
+ //if so then send packet to the packetserver
+ this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet);
+ }
+ else if (packet.Type == PacketType.UseCircuitCode)
+ {
+ // new client
+ this.AddNewClient(packet);
+ }
+ else
+ { // invalid client
+ Console.Error.WriteLine("Main.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString());
+ }
+
+ Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
+ }
+
+ protected virtual void AddNewClient(Packet packet)
+ {
+ UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet;
+ this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
+ bool isChildAgent = false;
+
+ SimClient newuser = new SimClient(epSender, useCircuit, m_localWorld, _packetServer.ClientThreads, m_assetCache, m_gridServers.GridServer, this, m_inventoryCache, m_sandbox, isChildAgent, this.m_regionData);
+ if ((this.m_gridServers.UserServer != null) && (user_accounts))
+ {
+ newuser.UserServer = this.m_gridServers.UserServer;
+ }
+ //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser);
+ this._packetServer.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
+ }
+
+ private void ServerListener()
+ {
+ m_console.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + listenPort);
+
+ ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
+ Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
+ Server.Bind(ServerIncoming);
+
+ m_console.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen");
+
+ ipeSender = new IPEndPoint(IPAddress.Any, 0);
+ epSender = (EndPoint)ipeSender;
+ ReceivedData = new AsyncCallback(this.OnReceivedData);
+ Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
+
+ m_console.WriteLine("Main.cs:MainServerListener() - Listening...");
+
+ }
+
+ public void RegisterPacketServer(PacketServer server)
+ {
+ this._packetServer = server;
+ }
+
+ public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender)
+ {
+ // find the endpoint for this circuit
+ EndPoint sendto = null;
+ foreach (KeyValuePair p in this.clientCircuits)
+ {
+ if (p.Value == circuitcode)
+ {
+ sendto = p.Key;
+ break;
+ }
+ }
+ if (sendto != null)
+ {
+ //we found the endpoint so send the packet to it
+ this.Server.SendTo(buffer, size, flags, sendto);
+ }
+ }
+
+ public virtual void RemoveClientCircuit(uint circuitcode)
+ {
+ foreach (KeyValuePair p in this.clientCircuits)
+ {
+ if (p.Value == circuitcode)
+ {
+ this.clientCircuits.Remove(p.Key);
+ break;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim.RegionServer/world/Avatar.Client.cs b/OpenSim.RegionServer/world/Avatar.Client.cs
new file mode 100644
index 0000000..7656a89
--- /dev/null
+++ b/OpenSim.RegionServer/world/Avatar.Client.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using libsecondlife.Packets;
+
+namespace OpenSim.world
+{
+ partial class Avatar
+ {
+ private List updateList = new List();
+ private List interestList = new List();
+
+ public void SendPacketToViewer(Packet packet)
+ {
+ this.ControllingClient.OutPacket(packet);
+ }
+
+ public void AddTerseUpdateToViewersList(ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock)
+ {
+
+ }
+
+ public void SendUpdateListToViewer()
+ {
+
+ }
+
+ private void UpdateInterestList()
+ {
+
+ }
+ }
+}
diff --git a/OpenSim.RegionServer/world/Avatar.Update.cs b/OpenSim.RegionServer/world/Avatar.Update.cs
new file mode 100644
index 0000000..ba2965d
--- /dev/null
+++ b/OpenSim.RegionServer/world/Avatar.Update.cs
@@ -0,0 +1,331 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using libsecondlife;
+using libsecondlife.Packets;
+
+namespace OpenSim.world
+{
+ partial class Avatar
+ {
+ public override void update()
+ {
+ if (this._physActor == null)
+ {
+ //HACKHACK: Note to work out why this entity does not have a physics actor
+ // and prehaps create one.
+ return;
+ }
+ libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
+ if (this.updateflag)
+ {
+ //need to send movement info
+ //so create the improvedterseobjectupdate packet
+ //use CreateTerseBlock()
+ ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
+ ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
+ terse.RegionData.RegionHandle = m_regionHandle; // FIXME
+ terse.RegionData.TimeDilation = 64096;
+ terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
+ terse.ObjectData[0] = terseBlock;
+ foreach (SimClient client in m_clientThreads.Values)
+ {
+ client.OutPacket(terse);
+ }
+
+ updateflag = false;
+ //this._updateCount = 0;
+ }
+ else
+ {
+
+ if ((pos2 != this.positionLastFrame) || (this.movementflag == 16))
+ {
+ _updateCount++;
+ if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0))
+ {
+ //It has been a while since last update was sent so lets send one.
+ ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
+ ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
+ terse.RegionData.RegionHandle = m_regionHandle; // FIXME
+ terse.RegionData.TimeDilation = 64096;
+ terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
+ terse.ObjectData[0] = terseBlock;
+ foreach (SimClient client in m_clientThreads.Values)
+ {
+ client.OutPacket(terse);
+ }
+ _updateCount = 0;
+ }
+
+ if (this.movementflag == 16)
+ {
+ movementflag = 0;
+ }
+ }
+
+ }
+ this.positionLastFrame = pos2;
+
+ if (!this.ControllingClient.m_sandboxMode)
+ {
+ if (pos2.X < 0)
+ {
+ ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
+ }
+
+ if (pos2.Y < 0)
+ {
+ ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
+ }
+
+ if (pos2.X > 255)
+ {
+ ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
+ }
+
+ if (pos2.Y > 255)
+ {
+ ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
+ }
+ }
+
+ }
+
+ public ObjectUpdatePacket CreateUpdatePacket()
+ {
+ System.Text.Encoding _enc = System.Text.Encoding.ASCII;
+ //send a objectupdate packet with information about the clients avatar
+ ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
+ objupdate.RegionData.RegionHandle = m_regionHandle;
+ objupdate.RegionData.TimeDilation = 64096;
+ objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
+
+ objupdate.ObjectData[0] = AvatarTemplate;
+ //give this avatar object a local id and assign the user a name
+ objupdate.ObjectData[0].ID = this.localid;
+ objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
+ objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
+
+ libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z);
+
+ byte[] pb = pos2.GetBytes();
+
+ Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
+ return objupdate;
+ }
+
+ public void SendInitialPosition()
+ {
+ System.Text.Encoding _enc = System.Text.Encoding.ASCII;
+ //send a objectupdate packet with information about the clients avatar
+
+ ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
+ objupdate.RegionData.RegionHandle = m_regionHandle;
+ objupdate.RegionData.TimeDilation = 64096;
+ objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
+ objupdate.ObjectData[0] = AvatarTemplate;
+ //give this avatar object a local id and assign the user a name
+
+ objupdate.ObjectData[0].ID = this.localid;
+ this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
+ objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
+ libsecondlife.LLVector3 pos2 = new LLVector3((float)this.Pos.X, (float)this.Pos.Y, (float)this.Pos.Z);
+ byte[] pb = pos2.GetBytes();
+ Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
+ m_world._localNumber++;
+ foreach (SimClient client in m_clientThreads.Values)
+ {
+ client.OutPacket(objupdate);
+ if (client.AgentID != ControllingClient.AgentID)
+ {
+ //the below line is already in Simclient.cs at line number 245 , directly below the call to this method
+ //if there is a problem/bug with that , then lets fix it there rather than duplicating it here
+ //client.ClientAvatar.SendAppearanceToOtherAgent(this.ControllingClient);
+
+ SendAppearanceToOtherAgent(client);
+ }
+ }
+ }
+
+ public void SendInitialAppearance()
+ {
+ AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
+ aw.AgentData.AgentID = this.ControllingClient.AgentID;
+ aw.AgentData.SerialNum = 0;
+ aw.AgentData.SessionID = ControllingClient.SessionID;
+
+ aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
+ AgentWearablesUpdatePacket.WearableDataBlock awb;
+ for (int i = 0; i < 13; i++)
+ {
+ awb = new AgentWearablesUpdatePacket.WearableDataBlock();
+ awb.WearableType = (byte)i;
+ awb.AssetID = this.Wearables[i].AssetID;
+ awb.ItemID = this.Wearables[i].ItemID;
+ aw.WearableData[i] = awb;
+ }
+
+ ControllingClient.OutPacket(aw);
+ }
+
+ public void SendAppearanceToOtherAgent(SimClient userInfo)
+ {
+ AvatarAppearancePacket avp = new AvatarAppearancePacket();
+ avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
+ avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes();
+
+ //a wearable update packets should only be sent about the viewers/agents own avatar not for other avatars
+ //but it seems that the following code only created the packets and never actually sent them anyway
+ /*AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
+ aw.AgentData.AgentID = this.ControllingClient.AgentID;
+ aw.AgentData.SessionID = userInfo.SessionID;
+ aw.AgentData.SerialNum = 0; //removed the use of a random number as a random number could be less than the last number, should have a counter variable for this
+
+ aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
+ AgentWearablesUpdatePacket.WearableDataBlock awb;
+ for (int i = 0; i < 13; i++)
+ {
+ awb = new AgentWearablesUpdatePacket.WearableDataBlock();
+ awb.WearableType = (byte)i;
+ awb.AssetID = this.Wearables[i].AssetID;
+ awb.ItemID = this.Wearables[i].ItemID;
+ aw.WearableData[i] = awb;
+ }*/
+
+ AvatarAppearancePacket.VisualParamBlock avblock = null;
+ for (int i = 0; i < 218; i++)
+ {
+ avblock = new AvatarAppearancePacket.VisualParamBlock();
+ avblock.ParamValue = visualParams[i];
+ avp.VisualParam[i] = avblock;
+ }
+
+ avp.Sender.IsTrial = false;
+ avp.Sender.ID = ControllingClient.AgentID;
+ userInfo.OutPacket(avp);
+ }
+
+ public void SetAppearance(AgentSetAppearancePacket appear)
+ {
+ LLObject.TextureEntry tex = new LLObject.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
+ this.avatarAppearanceTexture = tex;
+ for (int i = 0; i < appear.VisualParam.Length; i++)
+ {
+ this.visualParams[i] = appear.VisualParam[i].ParamValue;
+ }
+ foreach (SimClient client in m_clientThreads.Values)
+ {
+ if (client.AgentID != ControllingClient.AgentID)
+ {
+ SendAppearanceToOtherAgent(client);
+ }
+ }
+ }
+
+ public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
+ {
+ byte[] bytes = new byte[60];
+ int i = 0;
+ ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
+
+ dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
+ libsecondlife.LLVector3 pos2 = new LLVector3(0, 0, 0);
+ lock (m_world.LockPhysicsEngine)
+ {
+ pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
+ }
+
+ uint ID = this.localid;
+
+ bytes[i++] = (byte)(ID % 256);
+ bytes[i++] = (byte)((ID >> 8) % 256);
+ bytes[i++] = (byte)((ID >> 16) % 256);
+ bytes[i++] = (byte)((ID >> 24) % 256);
+ bytes[i++] = 0;
+ bytes[i++] = 1;
+ i += 14;
+ bytes[i++] = 128;
+ bytes[i++] = 63;
+
+ byte[] pb = pos2.GetBytes();
+ Array.Copy(pb, 0, bytes, i, pb.Length);
+ i += 12;
+ ushort InternVelocityX;
+ ushort InternVelocityY;
+ ushort InternVelocityZ;
+ Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(0, 0, 0);
+ lock (m_world.LockPhysicsEngine)
+ {
+ internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z);
+ }
+ internDirec = internDirec / 128.0f;
+ internDirec.x += 1;
+ internDirec.y += 1;
+ internDirec.z += 1;
+
+ InternVelocityX = (ushort)(32768 * internDirec.x);
+ InternVelocityY = (ushort)(32768 * internDirec.y);
+ InternVelocityZ = (ushort)(32768 * internDirec.z);
+
+ ushort ac = 32767;
+ bytes[i++] = (byte)(InternVelocityX % 256);
+ bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
+ bytes[i++] = (byte)(InternVelocityY % 256);
+ bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
+ bytes[i++] = (byte)(InternVelocityZ % 256);
+ bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
+
+ //accel
+ bytes[i++] = (byte)(ac % 256);
+ bytes[i++] = (byte)((ac >> 8) % 256);
+ bytes[i++] = (byte)(ac % 256);
+ bytes[i++] = (byte)((ac >> 8) % 256);
+ bytes[i++] = (byte)(ac % 256);
+ bytes[i++] = (byte)((ac >> 8) % 256);
+
+ //rot
+ bytes[i++] = (byte)(ac % 256);
+ bytes[i++] = (byte)((ac >> 8) % 256);
+ bytes[i++] = (byte)(ac % 256);
+ bytes[i++] = (byte)((ac >> 8) % 256);
+ bytes[i++] = (byte)(ac % 256);
+ bytes[i++] = (byte)((ac >> 8) % 256);
+ bytes[i++] = (byte)(ac % 256);
+ bytes[i++] = (byte)((ac >> 8) % 256);
+
+ //rotation vel
+ bytes[i++] = (byte)(ac % 256);
+ bytes[i++] = (byte)((ac >> 8) % 256);
+ bytes[i++] = (byte)(ac % 256);
+ bytes[i++] = (byte)((ac >> 8) % 256);
+ bytes[i++] = (byte)(ac % 256);
+ bytes[i++] = (byte)((ac >> 8) % 256);
+
+ dat.Data = bytes;
+ return (dat);
+ }
+
+ // Sends animation update
+ public void SendAnimPack()
+ {
+ AvatarAnimationPacket ani = new AvatarAnimationPacket();
+ ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
+ ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
+ ani.AnimationSourceList[0].ObjectID = ControllingClient.AgentID;
+ ani.Sender = new AvatarAnimationPacket.SenderBlock();
+ ani.Sender.ID = ControllingClient.AgentID;
+ ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1];
+ ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock();
+ ani.AnimationList[0].AnimID = this.current_anim;
+ ani.AnimationList[0].AnimSequenceID = this.anim_seq;
+
+ //ControllingClient.OutPacket(ani);
+ foreach (SimClient client in m_clientThreads.Values)
+ {
+ client.OutPacket(ani);
+ }
+ }
+
+ }
+}
diff --git a/OpenSim.RegionServer/world/AvatarClient.cs b/OpenSim.RegionServer/world/AvatarClient.cs
deleted file mode 100644
index 7656a89..0000000
--- a/OpenSim.RegionServer/world/AvatarClient.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using libsecondlife.Packets;
-
-namespace OpenSim.world
-{
- partial class Avatar
- {
- private List updateList = new List();
- private List interestList = new List();
-
- public void SendPacketToViewer(Packet packet)
- {
- this.ControllingClient.OutPacket(packet);
- }
-
- public void AddTerseUpdateToViewersList(ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock)
- {
-
- }
-
- public void SendUpdateListToViewer()
- {
-
- }
-
- private void UpdateInterestList()
- {
-
- }
- }
-}
diff --git a/OpenSim.RegionServer/world/AvatarUpdate.cs b/OpenSim.RegionServer/world/AvatarUpdate.cs
deleted file mode 100644
index ba2965d..0000000
--- a/OpenSim.RegionServer/world/AvatarUpdate.cs
+++ /dev/null
@@ -1,331 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using libsecondlife;
-using libsecondlife.Packets;
-
-namespace OpenSim.world
-{
- partial class Avatar
- {
- public override void update()
- {
- if (this._physActor == null)
- {
- //HACKHACK: Note to work out why this entity does not have a physics actor
- // and prehaps create one.
- return;
- }
- libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
- if (this.updateflag)
- {
- //need to send movement info
- //so create the improvedterseobjectupdate packet
- //use CreateTerseBlock()
- ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
- ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
- terse.RegionData.RegionHandle = m_regionHandle; // FIXME
- terse.RegionData.TimeDilation = 64096;
- terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
- terse.ObjectData[0] = terseBlock;
- foreach (SimClient client in m_clientThreads.Values)
- {
- client.OutPacket(terse);
- }
-
- updateflag = false;
- //this._updateCount = 0;
- }
- else
- {
-
- if ((pos2 != this.positionLastFrame) || (this.movementflag == 16))
- {
- _updateCount++;
- if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0))
- {
- //It has been a while since last update was sent so lets send one.
- ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
- ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
- terse.RegionData.RegionHandle = m_regionHandle; // FIXME
- terse.RegionData.TimeDilation = 64096;
- terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
- terse.ObjectData[0] = terseBlock;
- foreach (SimClient client in m_clientThreads.Values)
- {
- client.OutPacket(terse);
- }
- _updateCount = 0;
- }
-
- if (this.movementflag == 16)
- {
- movementflag = 0;
- }
- }
-
- }
- this.positionLastFrame = pos2;
-
- if (!this.ControllingClient.m_sandboxMode)
- {
- if (pos2.X < 0)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
- }
-
- if (pos2.Y < 0)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
- }
-
- if (pos2.X > 255)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
- }
-
- if (pos2.Y > 255)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
- }
- }
-
- }
-
- public ObjectUpdatePacket CreateUpdatePacket()
- {
- System.Text.Encoding _enc = System.Text.Encoding.ASCII;
- //send a objectupdate packet with information about the clients avatar
- ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
- objupdate.RegionData.RegionHandle = m_regionHandle;
- objupdate.RegionData.TimeDilation = 64096;
- objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
-
- objupdate.ObjectData[0] = AvatarTemplate;
- //give this avatar object a local id and assign the user a name
- objupdate.ObjectData[0].ID = this.localid;
- objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
- objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
-
- libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z);
-
- byte[] pb = pos2.GetBytes();
-
- Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
- return objupdate;
- }
-
- public void SendInitialPosition()
- {
- System.Text.Encoding _enc = System.Text.Encoding.ASCII;
- //send a objectupdate packet with information about the clients avatar
-
- ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
- objupdate.RegionData.RegionHandle = m_regionHandle;
- objupdate.RegionData.TimeDilation = 64096;
- objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
- objupdate.ObjectData[0] = AvatarTemplate;
- //give this avatar object a local id and assign the user a name
-
- objupdate.ObjectData[0].ID = this.localid;
- this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
- objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
- libsecondlife.LLVector3 pos2 = new LLVector3((float)this.Pos.X, (float)this.Pos.Y, (float)this.Pos.Z);
- byte[] pb = pos2.GetBytes();
- Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
- m_world._localNumber++;
- foreach (SimClient client in m_clientThreads.Values)
- {
- client.OutPacket(objupdate);
- if (client.AgentID != ControllingClient.AgentID)
- {
- //the below line is already in Simclient.cs at line number 245 , directly below the call to this method
- //if there is a problem/bug with that , then lets fix it there rather than duplicating it here
- //client.ClientAvatar.SendAppearanceToOtherAgent(this.ControllingClient);
-
- SendAppearanceToOtherAgent(client);
- }
- }
- }
-
- public void SendInitialAppearance()
- {
- AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
- aw.AgentData.AgentID = this.ControllingClient.AgentID;
- aw.AgentData.SerialNum = 0;
- aw.AgentData.SessionID = ControllingClient.SessionID;
-
- aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
- AgentWearablesUpdatePacket.WearableDataBlock awb;
- for (int i = 0; i < 13; i++)
- {
- awb = new AgentWearablesUpdatePacket.WearableDataBlock();
- awb.WearableType = (byte)i;
- awb.AssetID = this.Wearables[i].AssetID;
- awb.ItemID = this.Wearables[i].ItemID;
- aw.WearableData[i] = awb;
- }
-
- ControllingClient.OutPacket(aw);
- }
-
- public void SendAppearanceToOtherAgent(SimClient userInfo)
- {
- AvatarAppearancePacket avp = new AvatarAppearancePacket();
- avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
- avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes();
-
- //a wearable update packets should only be sent about the viewers/agents own avatar not for other avatars
- //but it seems that the following code only created the packets and never actually sent them anyway
- /*AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
- aw.AgentData.AgentID = this.ControllingClient.AgentID;
- aw.AgentData.SessionID = userInfo.SessionID;
- aw.AgentData.SerialNum = 0; //removed the use of a random number as a random number could be less than the last number, should have a counter variable for this
-
- aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
- AgentWearablesUpdatePacket.WearableDataBlock awb;
- for (int i = 0; i < 13; i++)
- {
- awb = new AgentWearablesUpdatePacket.WearableDataBlock();
- awb.WearableType = (byte)i;
- awb.AssetID = this.Wearables[i].AssetID;
- awb.ItemID = this.Wearables[i].ItemID;
- aw.WearableData[i] = awb;
- }*/
-
- AvatarAppearancePacket.VisualParamBlock avblock = null;
- for (int i = 0; i < 218; i++)
- {
- avblock = new AvatarAppearancePacket.VisualParamBlock();
- avblock.ParamValue = visualParams[i];
- avp.VisualParam[i] = avblock;
- }
-
- avp.Sender.IsTrial = false;
- avp.Sender.ID = ControllingClient.AgentID;
- userInfo.OutPacket(avp);
- }
-
- public void SetAppearance(AgentSetAppearancePacket appear)
- {
- LLObject.TextureEntry tex = new LLObject.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
- this.avatarAppearanceTexture = tex;
- for (int i = 0; i < appear.VisualParam.Length; i++)
- {
- this.visualParams[i] = appear.VisualParam[i].ParamValue;
- }
- foreach (SimClient client in m_clientThreads.Values)
- {
- if (client.AgentID != ControllingClient.AgentID)
- {
- SendAppearanceToOtherAgent(client);
- }
- }
- }
-
- public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
- {
- byte[] bytes = new byte[60];
- int i = 0;
- ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
-
- dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
- libsecondlife.LLVector3 pos2 = new LLVector3(0, 0, 0);
- lock (m_world.LockPhysicsEngine)
- {
- pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
- }
-
- uint ID = this.localid;
-
- bytes[i++] = (byte)(ID % 256);
- bytes[i++] = (byte)((ID >> 8) % 256);
- bytes[i++] = (byte)((ID >> 16) % 256);
- bytes[i++] = (byte)((ID >> 24) % 256);
- bytes[i++] = 0;
- bytes[i++] = 1;
- i += 14;
- bytes[i++] = 128;
- bytes[i++] = 63;
-
- byte[] pb = pos2.GetBytes();
- Array.Copy(pb, 0, bytes, i, pb.Length);
- i += 12;
- ushort InternVelocityX;
- ushort InternVelocityY;
- ushort InternVelocityZ;
- Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(0, 0, 0);
- lock (m_world.LockPhysicsEngine)
- {
- internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z);
- }
- internDirec = internDirec / 128.0f;
- internDirec.x += 1;
- internDirec.y += 1;
- internDirec.z += 1;
-
- InternVelocityX = (ushort)(32768 * internDirec.x);
- InternVelocityY = (ushort)(32768 * internDirec.y);
- InternVelocityZ = (ushort)(32768 * internDirec.z);
-
- ushort ac = 32767;
- bytes[i++] = (byte)(InternVelocityX % 256);
- bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
- bytes[i++] = (byte)(InternVelocityY % 256);
- bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
- bytes[i++] = (byte)(InternVelocityZ % 256);
- bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
-
- //accel
- bytes[i++] = (byte)(ac % 256);
- bytes[i++] = (byte)((ac >> 8) % 256);
- bytes[i++] = (byte)(ac % 256);
- bytes[i++] = (byte)((ac >> 8) % 256);
- bytes[i++] = (byte)(ac % 256);
- bytes[i++] = (byte)((ac >> 8) % 256);
-
- //rot
- bytes[i++] = (byte)(ac % 256);
- bytes[i++] = (byte)((ac >> 8) % 256);
- bytes[i++] = (byte)(ac % 256);
- bytes[i++] = (byte)((ac >> 8) % 256);
- bytes[i++] = (byte)(ac % 256);
- bytes[i++] = (byte)((ac >> 8) % 256);
- bytes[i++] = (byte)(ac % 256);
- bytes[i++] = (byte)((ac >> 8) % 256);
-
- //rotation vel
- bytes[i++] = (byte)(ac % 256);
- bytes[i++] = (byte)((ac >> 8) % 256);
- bytes[i++] = (byte)(ac % 256);
- bytes[i++] = (byte)((ac >> 8) % 256);
- bytes[i++] = (byte)(ac % 256);
- bytes[i++] = (byte)((ac >> 8) % 256);
-
- dat.Data = bytes;
- return (dat);
- }
-
- // Sends animation update
- public void SendAnimPack()
- {
- AvatarAnimationPacket ani = new AvatarAnimationPacket();
- ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
- ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
- ani.AnimationSourceList[0].ObjectID = ControllingClient.AgentID;
- ani.Sender = new AvatarAnimationPacket.SenderBlock();
- ani.Sender.ID = ControllingClient.AgentID;
- ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1];
- ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock();
- ani.AnimationList[0].AnimID = this.current_anim;
- ani.AnimationList[0].AnimSequenceID = this.anim_seq;
-
- //ControllingClient.OutPacket(ani);
- foreach (SimClient client in m_clientThreads.Values)
- {
- client.OutPacket(ani);
- }
- }
-
- }
-}
diff --git a/OpenSim.RegionServer/world/World.PacketHandlers.cs b/OpenSim.RegionServer/world/World.PacketHandlers.cs
new file mode 100644
index 0000000..2036bc6
--- /dev/null
+++ b/OpenSim.RegionServer/world/World.PacketHandlers.cs
@@ -0,0 +1,229 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using libsecondlife;
+using libsecondlife.Packets;
+using OpenSim.Physics.Manager;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Framework.Types;
+using OpenSim.Framework.Terrain;
+using OpenSim.Framework.Inventory;
+using OpenSim.Framework.Utilities;
+using OpenSim.Assets;
+
+namespace OpenSim.world
+{
+ partial class World
+ {
+ public bool ModifyTerrain(SimClient simClient, Packet packet)
+ {
+ ModifyLandPacket modify = (ModifyLandPacket)packet;
+
+ switch (modify.ModifyBlock.Action)
+ {
+ case 1:
+ // raise terrain
+ if (modify.ParcelData.Length > 0)
+ {
+ Terrain.raise(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
+ RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
+ }
+ break;
+ case 2:
+ //lower terrain
+ if (modify.ParcelData.Length > 0)
+ {
+ Terrain.lower(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
+ RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
+ }
+ break;
+ }
+ return true;
+ }
+
+ public bool SimChat(SimClient simClient, Packet packet)
+ {
+ System.Text.Encoding enc = System.Text.Encoding.ASCII;
+ ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)packet;
+ if (Util.FieldToString(inchatpack.ChatData.Message) == "")
+ {
+ //empty message so don't bother with it
+ return true;
+ }
+
+ libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
+ reply.ChatData.Audible = 1;
+ reply.ChatData.Message = inchatpack.ChatData.Message;
+ reply.ChatData.ChatType = inchatpack.ChatData.Type;
+ reply.ChatData.SourceType = 1;
+ reply.ChatData.Position = simClient.ClientAvatar.Pos;
+ reply.ChatData.FromName = enc.GetBytes(simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname + "\0");
+ reply.ChatData.OwnerID = simClient.AgentID;
+ reply.ChatData.SourceID = simClient.AgentID;
+ foreach (SimClient client in m_clientThreads.Values)
+ {
+ switch (inchatpack.ChatData.Type)
+ {
+ case 0:
+ int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
+ if ((dis < 10) && (dis > -10))
+ {
+ client.OutPacket(reply);
+ }
+ break;
+ case 1:
+ dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
+ if ((dis < 30) && (dis > -30))
+ {
+ client.OutPacket(reply);
+ }
+ break;
+ case 2:
+ dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
+ if ((dis < 100) && (dis > -100))
+ {
+ client.OutPacket(reply);
+ }
+ break;
+ }
+
+ }
+ return true;
+ }
+
+ public bool RezObject(SimClient simClient, Packet packet)
+ {
+ RezObjectPacket rezPacket = (RezObjectPacket)packet;
+ AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID);
+ if (inven != null)
+ {
+ if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
+ {
+ AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
+ if (asset != null)
+ {
+ PrimData primd = new PrimData(asset.Data);
+ Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
+ nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true);
+ this.Entities.Add(nPrim.uuid, nPrim);
+ this._primCount++;
+ this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID);
+ }
+ }
+ }
+ return true;
+ }
+
+ public bool DeRezObject(SimClient simClient, Packet packet)
+ {
+ DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
+
+ //Needs to delete object from physics at a later date
+ if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
+ {
+ //currently following code not used (or don't know of any case of destination being zero
+ libsecondlife.LLUUID[] DeRezEnts;
+ DeRezEnts = new libsecondlife.LLUUID[DeRezPacket.ObjectData.Length];
+ int i = 0;
+ foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
+ {
+
+ //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
+ foreach (Entity ent in this.Entities.Values)
+ {
+ if (ent.localid == Data.ObjectLocalID)
+ {
+ DeRezEnts[i++] = ent.uuid;
+ this.localStorage.RemovePrim(ent.uuid);
+ KillObjectPacket kill = new KillObjectPacket();
+ kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
+ kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
+ kill.ObjectData[0].ID = ent.localid;
+ foreach (SimClient client in m_clientThreads.Values)
+ {
+ client.OutPacket(kill);
+ }
+ //Uncommenting this means an old UUID will be re-used, thus crashing the asset server
+ //Uncomment when prim/object UUIDs are random or such
+ //2007-03-22 - Randomskk
+ //this._primCount--;
+ OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Deleted UUID " + ent.uuid);
+ }
+ }
+ }
+ foreach (libsecondlife.LLUUID uuid in DeRezEnts)
+ {
+ lock (Entities)
+ {
+ Entities.Remove(uuid);
+ }
+ }
+ }
+ else
+ {
+ foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
+ {
+ Entity selectedEnt = null;
+ //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
+ foreach (Entity ent in this.Entities.Values)
+ {
+ if (ent.localid == Data.ObjectLocalID)
+ {
+ AssetBase primAsset = new AssetBase();
+ primAsset.FullID = LLUUID.Random();//DeRezPacket.AgentBlock.TransactionID.Combine(LLUUID.Zero); //should be combining with securesessionid
+ primAsset.InvType = 6;
+ primAsset.Type = 6;
+ primAsset.Name = "Prim";
+ primAsset.Description = "";
+ primAsset.Data = ((Primitive)ent).GetByteArray();
+ this._assetCache.AddAsset(primAsset);
+ this._inventoryCache.AddNewInventoryItem(simClient, DeRezPacket.AgentBlock.DestinationID, primAsset);
+ selectedEnt = ent;
+ break;
+ }
+ }
+ if (selectedEnt != null)
+ {
+ this.localStorage.RemovePrim(selectedEnt.uuid);
+ KillObjectPacket kill = new KillObjectPacket();
+ kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
+ kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
+ kill.ObjectData[0].ID = selectedEnt.localid;
+ foreach (SimClient client in m_clientThreads.Values)
+ {
+ client.OutPacket(kill);
+ }
+ lock (Entities)
+ {
+ Entities.Remove(selectedEnt.uuid);
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public void RequestMapBlock(SimClient simClient, int minX, int minY, int maxX, int maxY)
+ {
+ System.Text.Encoding _enc = System.Text.Encoding.ASCII;
+ if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY)))
+ {
+ MapBlockReplyPacket mapReply = new MapBlockReplyPacket();
+ mapReply.AgentData.AgentID = simClient.AgentID;
+ mapReply.AgentData.Flags = 0;
+ mapReply.Data = new MapBlockReplyPacket.DataBlock[1];
+ mapReply.Data[0] = new MapBlockReplyPacket.DataBlock();
+ mapReply.Data[0].MapImageID = new LLUUID("00000000-0000-0000-9999-000000000007");
+ mapReply.Data[0].X = (ushort)m_regInfo.RegionLocX;
+ mapReply.Data[0].Y = (ushort)m_regInfo.RegionLocY;
+ mapReply.Data[0].WaterHeight =(byte) m_regInfo.RegionWaterHeight;
+ mapReply.Data[0].Name = _enc.GetBytes(this.m_regionName);
+ mapReply.Data[0].RegionFlags = 72458694;
+ mapReply.Data[0].Access = 13;
+ mapReply.Data[0].Agents = 1; //should send number of clients connected
+ simClient.OutPacket(mapReply);
+ }
+ }
+
+ }
+}
diff --git a/OpenSim.RegionServer/world/World.Scripting.cs b/OpenSim.RegionServer/world/World.Scripting.cs
new file mode 100644
index 0000000..44ef05a
--- /dev/null
+++ b/OpenSim.RegionServer/world/World.Scripting.cs
@@ -0,0 +1,124 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+using System.Reflection;
+using OpenSim.Framework;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Framework.Types;
+using libsecondlife;
+
+namespace OpenSim.world
+{
+ public partial class World
+ {
+ private Dictionary scriptEngines = new Dictionary();
+
+ private void LoadScriptEngines()
+ {
+ this.LoadScriptPlugins();
+ }
+
+ public void LoadScriptPlugins()
+ {
+ string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ScriptEngines");
+ string[] pluginFiles = Directory.GetFiles(path, "*.dll");
+
+
+ for (int i = 0; i < pluginFiles.Length; i++)
+ {
+ this.AddPlugin(pluginFiles[i]);
+ }
+ }
+
+ private void AddPlugin(string FileName)
+ {
+ Assembly pluginAssembly = Assembly.LoadFrom(FileName);
+
+ foreach (Type pluginType in pluginAssembly.GetTypes())
+ {
+ if (pluginType.IsPublic)
+ {
+ if (!pluginType.IsAbstract)
+ {
+ Type typeInterface = pluginType.GetInterface("IScriptEngine", true);
+
+ if (typeInterface != null)
+ {
+ IScriptEngine plug = (IScriptEngine)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
+ plug.Init(this);
+ this.scriptEngines.Add(plug.GetName(), plug);
+
+ }
+
+ typeInterface = null;
+ }
+ }
+ }
+
+ pluginAssembly = null;
+ }
+
+ public void LoadScript(string scriptType, string scriptName, string script, Entity ent)
+ {
+ if(this.scriptEngines.ContainsKey(scriptType))
+ {
+ this.scriptEngines[scriptType].LoadScript(script, scriptName, ent.localid);
+ }
+ }
+
+ #region IScriptAPI Methods
+
+ public OSVector3 GetEntityPosition(uint localID)
+ {
+ OSVector3 res = new OSVector3();
+ // Console.WriteLine("script- getting entity " + localID + " position");
+ foreach (Entity entity in this.Entities.Values)
+ {
+ if (entity.localid == localID)
+ {
+ res.X = entity.Pos.X;
+ res.Y = entity.Pos.Y;
+ res.Z = entity.Pos.Z;
+ }
+ }
+ return res;
+ }
+
+ public void SetEntityPosition(uint localID, float x , float y, float z)
+ {
+ foreach (Entity entity in this.Entities.Values)
+ {
+ if (entity.localid == localID && entity is Primitive)
+ {
+ LLVector3 pos = entity.Pos;
+ pos.X = x;
+ pos.Y = y;
+ Primitive prim = entity as Primitive;
+ // Of course, we really should have asked the physEngine if this is possible, and if not, returned false.
+ prim.UpdatePosition(pos);
+ // Console.WriteLine("script- setting entity " + localID + " positon");
+ }
+ }
+
+ }
+
+ public uint GetRandomAvatarID()
+ {
+ //Console.WriteLine("script- getting random avatar id");
+ uint res = 0;
+ foreach (Entity entity in this.Entities.Values)
+ {
+ if (entity is Avatar)
+ {
+ res = entity.localid;
+ }
+ }
+ return res;
+ }
+
+ #endregion
+
+
+ }
+}
diff --git a/OpenSim.RegionServer/world/WorldPacketHandlers.cs b/OpenSim.RegionServer/world/WorldPacketHandlers.cs
deleted file mode 100644
index 2036bc6..0000000
--- a/OpenSim.RegionServer/world/WorldPacketHandlers.cs
+++ /dev/null
@@ -1,229 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using libsecondlife;
-using libsecondlife.Packets;
-using OpenSim.Physics.Manager;
-using OpenSim.Framework.Interfaces;
-using OpenSim.Framework.Types;
-using OpenSim.Framework.Terrain;
-using OpenSim.Framework.Inventory;
-using OpenSim.Framework.Utilities;
-using OpenSim.Assets;
-
-namespace OpenSim.world
-{
- partial class World
- {
- public bool ModifyTerrain(SimClient simClient, Packet packet)
- {
- ModifyLandPacket modify = (ModifyLandPacket)packet;
-
- switch (modify.ModifyBlock.Action)
- {
- case 1:
- // raise terrain
- if (modify.ParcelData.Length > 0)
- {
- Terrain.raise(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
- RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
- }
- break;
- case 2:
- //lower terrain
- if (modify.ParcelData.Length > 0)
- {
- Terrain.lower(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
- RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
- }
- break;
- }
- return true;
- }
-
- public bool SimChat(SimClient simClient, Packet packet)
- {
- System.Text.Encoding enc = System.Text.Encoding.ASCII;
- ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)packet;
- if (Util.FieldToString(inchatpack.ChatData.Message) == "")
- {
- //empty message so don't bother with it
- return true;
- }
-
- libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
- reply.ChatData.Audible = 1;
- reply.ChatData.Message = inchatpack.ChatData.Message;
- reply.ChatData.ChatType = inchatpack.ChatData.Type;
- reply.ChatData.SourceType = 1;
- reply.ChatData.Position = simClient.ClientAvatar.Pos;
- reply.ChatData.FromName = enc.GetBytes(simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname + "\0");
- reply.ChatData.OwnerID = simClient.AgentID;
- reply.ChatData.SourceID = simClient.AgentID;
- foreach (SimClient client in m_clientThreads.Values)
- {
- switch (inchatpack.ChatData.Type)
- {
- case 0:
- int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
- if ((dis < 10) && (dis > -10))
- {
- client.OutPacket(reply);
- }
- break;
- case 1:
- dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
- if ((dis < 30) && (dis > -30))
- {
- client.OutPacket(reply);
- }
- break;
- case 2:
- dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
- if ((dis < 100) && (dis > -100))
- {
- client.OutPacket(reply);
- }
- break;
- }
-
- }
- return true;
- }
-
- public bool RezObject(SimClient simClient, Packet packet)
- {
- RezObjectPacket rezPacket = (RezObjectPacket)packet;
- AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID);
- if (inven != null)
- {
- if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
- {
- AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
- if (asset != null)
- {
- PrimData primd = new PrimData(asset.Data);
- Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
- nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true);
- this.Entities.Add(nPrim.uuid, nPrim);
- this._primCount++;
- this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID);
- }
- }
- }
- return true;
- }
-
- public bool DeRezObject(SimClient simClient, Packet packet)
- {
- DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
-
- //Needs to delete object from physics at a later date
- if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
- {
- //currently following code not used (or don't know of any case of destination being zero
- libsecondlife.LLUUID[] DeRezEnts;
- DeRezEnts = new libsecondlife.LLUUID[DeRezPacket.ObjectData.Length];
- int i = 0;
- foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
- {
-
- //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
- foreach (Entity ent in this.Entities.Values)
- {
- if (ent.localid == Data.ObjectLocalID)
- {
- DeRezEnts[i++] = ent.uuid;
- this.localStorage.RemovePrim(ent.uuid);
- KillObjectPacket kill = new KillObjectPacket();
- kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
- kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
- kill.ObjectData[0].ID = ent.localid;
- foreach (SimClient client in m_clientThreads.Values)
- {
- client.OutPacket(kill);
- }
- //Uncommenting this means an old UUID will be re-used, thus crashing the asset server
- //Uncomment when prim/object UUIDs are random or such
- //2007-03-22 - Randomskk
- //this._primCount--;
- OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Deleted UUID " + ent.uuid);
- }
- }
- }
- foreach (libsecondlife.LLUUID uuid in DeRezEnts)
- {
- lock (Entities)
- {
- Entities.Remove(uuid);
- }
- }
- }
- else
- {
- foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
- {
- Entity selectedEnt = null;
- //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
- foreach (Entity ent in this.Entities.Values)
- {
- if (ent.localid == Data.ObjectLocalID)
- {
- AssetBase primAsset = new AssetBase();
- primAsset.FullID = LLUUID.Random();//DeRezPacket.AgentBlock.TransactionID.Combine(LLUUID.Zero); //should be combining with securesessionid
- primAsset.InvType = 6;
- primAsset.Type = 6;
- primAsset.Name = "Prim";
- primAsset.Description = "";
- primAsset.Data = ((Primitive)ent).GetByteArray();
- this._assetCache.AddAsset(primAsset);
- this._inventoryCache.AddNewInventoryItem(simClient, DeRezPacket.AgentBlock.DestinationID, primAsset);
- selectedEnt = ent;
- break;
- }
- }
- if (selectedEnt != null)
- {
- this.localStorage.RemovePrim(selectedEnt.uuid);
- KillObjectPacket kill = new KillObjectPacket();
- kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
- kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
- kill.ObjectData[0].ID = selectedEnt.localid;
- foreach (SimClient client in m_clientThreads.Values)
- {
- client.OutPacket(kill);
- }
- lock (Entities)
- {
- Entities.Remove(selectedEnt.uuid);
- }
- }
- }
- }
- return true;
- }
-
- public void RequestMapBlock(SimClient simClient, int minX, int minY, int maxX, int maxY)
- {
- System.Text.Encoding _enc = System.Text.Encoding.ASCII;
- if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY)))
- {
- MapBlockReplyPacket mapReply = new MapBlockReplyPacket();
- mapReply.AgentData.AgentID = simClient.AgentID;
- mapReply.AgentData.Flags = 0;
- mapReply.Data = new MapBlockReplyPacket.DataBlock[1];
- mapReply.Data[0] = new MapBlockReplyPacket.DataBlock();
- mapReply.Data[0].MapImageID = new LLUUID("00000000-0000-0000-9999-000000000007");
- mapReply.Data[0].X = (ushort)m_regInfo.RegionLocX;
- mapReply.Data[0].Y = (ushort)m_regInfo.RegionLocY;
- mapReply.Data[0].WaterHeight =(byte) m_regInfo.RegionWaterHeight;
- mapReply.Data[0].Name = _enc.GetBytes(this.m_regionName);
- mapReply.Data[0].RegionFlags = 72458694;
- mapReply.Data[0].Access = 13;
- mapReply.Data[0].Agents = 1; //should send number of clients connected
- simClient.OutPacket(mapReply);
- }
- }
-
- }
-}
diff --git a/OpenSim.RegionServer/world/WorldScripting.cs b/OpenSim.RegionServer/world/WorldScripting.cs
deleted file mode 100644
index 44ef05a..0000000
--- a/OpenSim.RegionServer/world/WorldScripting.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using System.Reflection;
-using OpenSim.Framework;
-using OpenSim.Framework.Interfaces;
-using OpenSim.Framework.Types;
-using libsecondlife;
-
-namespace OpenSim.world
-{
- public partial class World
- {
- private Dictionary scriptEngines = new Dictionary();
-
- private void LoadScriptEngines()
- {
- this.LoadScriptPlugins();
- }
-
- public void LoadScriptPlugins()
- {
- string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ScriptEngines");
- string[] pluginFiles = Directory.GetFiles(path, "*.dll");
-
-
- for (int i = 0; i < pluginFiles.Length; i++)
- {
- this.AddPlugin(pluginFiles[i]);
- }
- }
-
- private void AddPlugin(string FileName)
- {
- Assembly pluginAssembly = Assembly.LoadFrom(FileName);
-
- foreach (Type pluginType in pluginAssembly.GetTypes())
- {
- if (pluginType.IsPublic)
- {
- if (!pluginType.IsAbstract)
- {
- Type typeInterface = pluginType.GetInterface("IScriptEngine", true);
-
- if (typeInterface != null)
- {
- IScriptEngine plug = (IScriptEngine)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
- plug.Init(this);
- this.scriptEngines.Add(plug.GetName(), plug);
-
- }
-
- typeInterface = null;
- }
- }
- }
-
- pluginAssembly = null;
- }
-
- public void LoadScript(string scriptType, string scriptName, string script, Entity ent)
- {
- if(this.scriptEngines.ContainsKey(scriptType))
- {
- this.scriptEngines[scriptType].LoadScript(script, scriptName, ent.localid);
- }
- }
-
- #region IScriptAPI Methods
-
- public OSVector3 GetEntityPosition(uint localID)
- {
- OSVector3 res = new OSVector3();
- // Console.WriteLine("script- getting entity " + localID + " position");
- foreach (Entity entity in this.Entities.Values)
- {
- if (entity.localid == localID)
- {
- res.X = entity.Pos.X;
- res.Y = entity.Pos.Y;
- res.Z = entity.Pos.Z;
- }
- }
- return res;
- }
-
- public void SetEntityPosition(uint localID, float x , float y, float z)
- {
- foreach (Entity entity in this.Entities.Values)
- {
- if (entity.localid == localID && entity is Primitive)
- {
- LLVector3 pos = entity.Pos;
- pos.X = x;
- pos.Y = y;
- Primitive prim = entity as Primitive;
- // Of course, we really should have asked the physEngine if this is possible, and if not, returned false.
- prim.UpdatePosition(pos);
- // Console.WriteLine("script- setting entity " + localID + " positon");
- }
- }
-
- }
-
- public uint GetRandomAvatarID()
- {
- //Console.WriteLine("script- getting random avatar id");
- uint res = 0;
- foreach (Entity entity in this.Entities.Values)
- {
- if (entity is Avatar)
- {
- res = entity.localid;
- }
- }
- return res;
- }
-
- #endregion
-
-
- }
-}
--
cgit v1.1