From fdc9ed89b4adaa7f23ca06613b2ee36c30895021 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 2 Apr 2007 15:48:01 +0000 Subject: OpenSim no longer uses OpenSim.Config.SimConfigDb4o, it now uses OpenSim.GenericConfig.Xml (or a class implementing IGenericConfig). --- OpenSim.RegionServer/OpenSim.RegionServer.csproj | 9 + .../OpenSim.RegionServer.dll.build | 2 + OpenSim.RegionServer/OpenSimMain.cs | 59 ++++-- OpenSim.RegionServer/RegionInfo.cs | 229 +++++++++++++++++++++ OpenSim.RegionServer/world/World.cs | 4 +- 5 files changed, 283 insertions(+), 20 deletions(-) create mode 100644 OpenSim.RegionServer/RegionInfo.cs (limited to 'OpenSim.RegionServer') diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj index e293a8c..b9b440f 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj +++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj @@ -92,6 +92,12 @@ {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} False + + OpenSim.GenericConfig.Xml + {E88EF749-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + OpenSim.Physics.Manager {8BE16150-0000-0000-0000-000000000000} @@ -127,6 +133,9 @@ Code + + Code + Code diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build index 6f86970..926a310 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build +++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build @@ -18,6 +18,7 @@ + @@ -47,6 +48,7 @@ + diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index c0fe95b..8bbdcd5 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs @@ -45,6 +45,7 @@ using OpenSim.Assets; using OpenSim.CAPS; using OpenSim.Framework.Console; using OpenSim.Physics.Manager; +using OpenSim.GenericConfig; using Nwc.XmlRpc; using OpenSim.Servers; @@ -53,7 +54,9 @@ namespace OpenSim public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback { - private SimConfig Cfg; + //private SimConfig Cfg; + private IGenericConfig localConfig; + //private IGenericConfig remoteConfig; private PhysicsManager physManager; private Grid GridServers; private BaseHttpServer _httpServer; @@ -64,6 +67,7 @@ namespace OpenSim //private Dictionary ClientThreads = new Dictionary(); private Dictionary clientCircuits = new Dictionary(); private DateTime startuptime; + private RegionInfo regionData; public Socket Server; private IPEndPoint ServerIncoming; @@ -74,7 +78,7 @@ namespace OpenSim private AsyncCallback ReceivedData; private System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer(); - private string ConfigDll = "OpenSim.Config.SimConfigDb4o.dll"; + //private string ConfigDll = "OpenSim.Config.SimConfigDb4o.dll"; public string m_physicsEngine; public bool m_sandbox = false; public bool m_loginserver; @@ -94,6 +98,30 @@ namespace OpenSim public virtual void StartUp() { + this.regionData = new RegionInfo(); + try + { + this.localConfig = new XmlConfig("simconfig.xml"); + this.localConfig.LoadData(); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + + string configfromgrid = localConfig.GetAttribute("ConfigFromGrid"); + if (configfromgrid == "true") + { + //config from remote server is not implemented yet + //this.remoteConfig = new RemoteConfig(localConfig.GetAttribute("RemoteConfigURL"), localConfig.GetAttribute("SimUUID")); + //this.remoteConfig.LoadData(); + //this.regionData.InitConfig(this.m_sandbox, this.remoteConfig); + //this.remoteConfig.Close(); + } + else + { + this.regionData.InitConfig(this.m_sandbox, this.localConfig); + } GridServers = new Grid(); if (m_sandbox) @@ -120,17 +148,14 @@ namespace OpenSim // We check our local database first, then the grid for config options m_console.WriteLine("Main.cs:Startup() - Loading configuration"); - Cfg = this.LoadConfigDll(this.ConfigDll); - Cfg.InitConfig(this.m_sandbox); - m_console.WriteLine("Main.cs:Startup() - Contacting gridserver"); - Cfg.LoadFromGrid(); + //Cfg = this.LoadConfigDll(this.ConfigDll); + //Cfg.InitConfig(this.m_sandbox); - PacketServer packetServer = new PacketServer(this); + PacketServer packetServer = new PacketServer(this); - m_console.WriteLine("Main.cs:Startup() - We are " + Cfg.RegionName + " at " + Cfg.RegionLocX.ToString() + "," + Cfg.RegionLocY.ToString()); + m_console.WriteLine("Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString()); m_console.WriteLine("Initialising world"); - LocalWorld = new World(this._packetServer.ClientThreads, Cfg.RegionHandle, Cfg.RegionName, Cfg); - //LocalWorld.LandMap = Cfg.LoadWorld(); + LocalWorld = new World(this._packetServer.ClientThreads, regionData.RegionHandle, regionData.RegionName); LocalWorld.InventoryCache = InventoryCache; LocalWorld.AssetCache = AssetCache; @@ -147,10 +172,10 @@ namespace OpenSim LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use LocalWorld.PhysScene.SetTerrain(LocalWorld.LandMap); - GridServers.AssetServer.SetServerInfo(Cfg.AssetURL, Cfg.AssetSendKey); - //GridServers.GridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey); + //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); IGridServer gridServer = GridServers.GridServer; - gridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey); + gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey); LocalWorld.LoadPrimsFromStorage(); @@ -161,7 +186,7 @@ namespace OpenSim m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server"); // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort); - _httpServer = new BaseHttpServer(Cfg.IPListenPort); + _httpServer = new BaseHttpServer(regionData.IPListenPort); if (gridServer.GetName() == "Remote") { @@ -195,7 +220,7 @@ namespace OpenSim bool sandBoxWithLoginServer = m_loginserver && m_sandbox; if (sandBoxWithLoginServer) { - loginServer = new LoginServer(gridServer, Cfg.IPListenAddr, Cfg.IPListenPort, this.user_accounts); + loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort, this.user_accounts); loginServer.Startup(); if( user_accounts ) @@ -294,9 +319,9 @@ namespace OpenSim private void MainServerListener() { m_console.WriteLine("Main.cs:MainServerListener() - New thread started"); - m_console.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + Cfg.IPListenAddr + ":" + Cfg.IPListenPort); + m_console.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + regionData.IPListenAddr + ":" + regionData.IPListenPort); - ServerIncoming = new IPEndPoint(IPAddress.Any, Cfg.IPListenPort); + ServerIncoming = new IPEndPoint(IPAddress.Any, regionData.IPListenPort); Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); Server.Bind(ServerIncoming); diff --git a/OpenSim.RegionServer/RegionInfo.cs b/OpenSim.RegionServer/RegionInfo.cs new file mode 100644 index 0000000..15cc105 --- /dev/null +++ b/OpenSim.RegionServer/RegionInfo.cs @@ -0,0 +1,229 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; + +namespace OpenSim +{ + public class RegionInfo // could inherit from SimProfileBase + { + public string RegionName; + + public uint RegionLocX; + public uint RegionLocY; + public ulong RegionHandle; + + 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 = ""; + public string AssetSendKey = ""; + + public string GridURL = ""; + public string GridSendKey = ""; + public string GridRecvKey = ""; + public string UserURL = ""; + public string UserSendKey = ""; + public string UserRecvKey = ""; + private bool isSandbox; + + public RegionInfo() + { + + } + + public void InitConfig(bool sandboxMode, IGenericConfig configData) + { + this.isSandbox = sandboxMode; + try + { + // Sim name + string attri =""; + attri = configData.GetAttribute("SimName"); + if (attri == "") + { + this.RegionName = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Name [OpenSim test]: ", "OpenSim test"); + configData.SetAttribute("SimName", this.RegionName); + } + else + { + this.RegionName = attri; + } + // Sim/Grid location X + attri = ""; + attri = configData.GetAttribute("SimLocationX"); + if (attri == "") + { + string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location X [997]: ", "997"); + configData.SetAttribute("SimLocationX", location); + this.RegionLocX = (uint)Convert.ToInt32(location); + } + else + { + this.RegionLocX = (uint)Convert.ToInt32(attri); + } + // Sim/Grid location Y + attri = ""; + attri = configData.GetAttribute("SimLocationY"); + if (attri == "") + { + string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location Y [996]: ", "996"); + configData.SetAttribute("SimLocationY", location); + this.RegionLocY = (uint)Convert.ToInt32(location); + } + else + { + this.RegionLocY = (uint)Convert.ToInt32(attri); + } + //Sim Listen Port + attri = ""; + attri = configData.GetAttribute("SimListenPort"); + if (attri == "") + { + string port = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("UDP port for client connections [9000]: ", "9000"); + configData.SetAttribute("SimListenPort", port); + this.IPListenPort = Convert.ToInt32(port); + } + else + { + this.IPListenPort = Convert.ToInt32(attri); + } + //Sim Listen Address + attri = ""; + attri = configData.GetAttribute("SimListenAddress"); + if (attri == "") + { + this.IPListenAddr = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ", "127.0.0.1"); + configData.SetAttribute("SimListenAddress", this.IPListenAddr); + } + else + { + this.IPListenAddr = attri; + } + + if (!isSandbox) + { + //shouldn't be reading this data in here, it should be up to the classes implementing the server interfaces to read what they need from the config object + + // Asset Server URL + attri = ""; + attri = configData.GetAttribute("AssetServerURL"); + if (attri == "") + { + this.AssetURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server URL: "); + configData.SetAttribute("AssetServerURL", this.AssetURL); + } + else + { + this.AssetURL = attri; + } + //Asset Server key + attri = ""; + attri = configData.GetAttribute("AssetServerKey"); + if (attri == "") + { + this.AssetSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server key: "); + configData.SetAttribute("AssetServerKey", this.AssetSendKey); + } + else + { + this.AssetSendKey = attri; + } + //Grid Sever URL + attri = ""; + attri = configData.GetAttribute("GridServerURL"); + if (attri == "") + { + this.GridURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid server URL: "); + configData.SetAttribute("GridServerURL", this.GridURL); + } + else + { + this.GridURL = attri; + } + //Grid Send Key + attri = ""; + attri = configData.GetAttribute("GridSendKey"); + if (attri == "") + { + this.GridSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to grid server: "); + configData.SetAttribute("GridSendKey", this.GridSendKey); + } + else + { + this.GridSendKey = attri; + } + //Grid Receive Key + attri = ""; + attri = configData.GetAttribute("GridRecvKey"); + if (attri == "") + { + this.GridRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from grid server: "); + configData.SetAttribute("GridRecvKey", this.GridRecvKey); + } + else + { + this.GridRecvKey = attri; + } + //User Server URL + attri = ""; + attri = configData.GetAttribute("UserServerURL"); + if (attri == "") + { + this.UserURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("User server URL: "); + configData.SetAttribute("UserServerURL", this.UserURL); + } + else + { + this.UserURL = attri; + } + //User Send Key + attri = ""; + attri = configData.GetAttribute("UserSendKey"); + if (attri == "") + { + this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server: "); + configData.SetAttribute("UserSendKey", this.UserSendKey); + } + else + { + this.UserSendKey = attri; + } + //User Receive Key + attri = ""; + attri = configData.GetAttribute("UserRecvKey"); + if (attri == "") + { + this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server: "); + configData.SetAttribute("UserRecvKey", this.UserRecvKey); + } + else + { + this.UserRecvKey = attri; + } + } + this.RegionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); + configData.Commit(); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); + } + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sim settings loaded:"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Name: " + this.RegionName); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString()); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sandbox Mode? " + isSandbox.ToString()); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset URL: " + this.AssetURL); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset key: " + this.AssetSendKey); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid URL: " + this.GridURL); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid key: " + this.GridSendKey); + } + } +} diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs index 4f8e53d..e848cad 100644 --- a/OpenSim.RegionServer/world/World.cs +++ b/OpenSim.RegionServer/world/World.cs @@ -31,16 +31,14 @@ namespace OpenSim.world private Dictionary m_clientThreads; private ulong m_regionHandle; private string m_regionName; - private SimConfig m_cfg; private InventoryCache _inventoryCache; private AssetCache _assetCache; - public World(Dictionary clientThreads, ulong regionHandle, string regionName, SimConfig cfg) + public World(Dictionary clientThreads, ulong regionHandle, string regionName) { m_clientThreads = clientThreads; m_regionHandle = regionHandle; m_regionName = regionName; - m_cfg = cfg; OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); Entities = new Dictionary(); -- cgit v1.1