From d363a96e8de078ccd6ae1d450833a2f684a9e61b Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 18 Mar 2007 16:18:53 +0000 Subject: [PATCH] More refactoring, Removed the static variables from OpenSim_Main, and now just have that a singleton of that class. Moved the abstract SimConfig class to the framework as well as HeightmapGenHills.cs. Added IUserServer.cs for the interface through which the sim will contact the user server for things like inventory details. --- .../HeightMapGenHills.cs | 2 +- OpenSim.FrameWork/IAssetServer.cs | 15 - src/Config.cs => OpenSim.FrameWork/IConfig.cs | 12 +- OpenSim.FrameWork/IUserServer.cs | 13 + OpenSim.FrameWork/OpenSim.Framework.csproj | 3 + OpenSim.FrameWork/UserProfileManagerBase.cs | 12 + OpenSim.FrameWork/Util.cs | 10 + bin/PhysicsManager.dll | Bin 20480 -> 20480 bytes bin/RemoteGridServers.dll | Bin 20480 -> 20480 bytes bin/ServerConsole.dll | Bin 16384 -> 16384 bytes bin/SimConfig.dll | Bin 20480 -> 20480 bytes src/CAPS/SimHttp.cs | 6 +- src/Config/SimConfig/Db4SimConfig.cs | 31 +- src/Config/SimConfig/SimConfig.csproj | 4 - src/Grid.cs | 88 ++++++ src/GridServers/LocalUserProfileManager.cs | 11 +- src/GridServers/LoginServer.cs | 292 ++++++++++-------- src/Main.cs | 180 ++++------- src/OpenSimClient.cs | 64 ++-- src/OpenSimConsole.cs | 14 +- src/Second-server.csproj | 15 +- src/Util.cs | 88 ------ src/world/Avatar.cs | 24 +- src/world/Primitive.cs | 21 +- src/world/World.cs | 5 +- 25 files changed, 446 insertions(+), 464 deletions(-) rename {src => OpenSim.FrameWork}/HeightMapGenHills.cs (96%) rename src/Config.cs => OpenSim.FrameWork/IConfig.cs (88%) create mode 100644 OpenSim.FrameWork/IUserServer.cs create mode 100644 src/Grid.cs delete mode 100644 src/Util.cs diff --git a/src/HeightMapGenHills.cs b/OpenSim.FrameWork/HeightMapGenHills.cs similarity index 96% rename from src/HeightMapGenHills.cs rename to OpenSim.FrameWork/HeightMapGenHills.cs index e7589aff00..6a729da553 100644 --- a/src/HeightMapGenHills.cs +++ b/OpenSim.FrameWork/HeightMapGenHills.cs @@ -27,7 +27,7 @@ using System; -namespace OpenSim +namespace OpenSim.Framework.Terrain { public class HeightmapGenHills { diff --git a/OpenSim.FrameWork/IAssetServer.cs b/OpenSim.FrameWork/IAssetServer.cs index f6e6d7d934..76c63fc193 100644 --- a/OpenSim.FrameWork/IAssetServer.cs +++ b/OpenSim.FrameWork/IAssetServer.cs @@ -61,21 +61,6 @@ namespace OpenSim.Framework.Interfaces public bool IsTexture; } - /*public class AssetBase - { - public byte[] Data; - public LLUUID FullID; - public sbyte Type; - public sbyte InvType; - public string Name; - public string Description; - - public AssetBase() - { - - } - }*/ - public interface IAssetPlugin { IAssetServer GetAssetServer(); diff --git a/src/Config.cs b/OpenSim.FrameWork/IConfig.cs similarity index 88% rename from src/Config.cs rename to OpenSim.FrameWork/IConfig.cs index d36388b412..355bd6cea4 100644 --- a/src/Config.cs +++ b/OpenSim.FrameWork/IConfig.cs @@ -31,9 +31,9 @@ using System; using System.Collections.Generic; using System.IO; using libsecondlife; -using OpenSim.world; +//using OpenSim.world; -namespace OpenSim +namespace OpenSim.Framework.Interfaces { /// /// This class handles connection to the underlying database used for configuration of the region. @@ -60,10 +60,10 @@ namespace OpenSim public string GridURL; public string GridSendKey; - public abstract void InitConfig(); - public abstract void LoadFromGrid(); - public abstract World LoadWorld(); - public abstract void SaveMap(); + public abstract void InitConfig(bool sandboxMode); + public abstract void LoadFromGrid(); + public abstract float[] LoadWorld(); + public abstract void SaveMap(float[] heightmap); } diff --git a/OpenSim.FrameWork/IUserServer.cs b/OpenSim.FrameWork/IUserServer.cs new file mode 100644 index 0000000000..5e9d96e20d --- /dev/null +++ b/OpenSim.FrameWork/IUserServer.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Inventory; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public interface IUserServer + { + AgentInventory RequestAgentsInventory(LLUUID agentID); + } +} diff --git a/OpenSim.FrameWork/OpenSim.Framework.csproj b/OpenSim.FrameWork/OpenSim.Framework.csproj index 3b5c8ee628..61665f8309 100644 --- a/OpenSim.FrameWork/OpenSim.Framework.csproj +++ b/OpenSim.FrameWork/OpenSim.Framework.csproj @@ -41,10 +41,13 @@ + + + diff --git a/OpenSim.FrameWork/UserProfileManagerBase.cs b/OpenSim.FrameWork/UserProfileManagerBase.cs index 9a79b09119..ad03bc23d2 100644 --- a/OpenSim.FrameWork/UserProfileManagerBase.cs +++ b/OpenSim.FrameWork/UserProfileManagerBase.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using libsecondlife; using OpenSim.Framework.Utilities; +using OpenSim.Framework.Inventory; namespace OpenSim.Framework.User { @@ -75,5 +76,16 @@ namespace OpenSim.Framework.User return newprofile; } + public virtual AgentInventory GetUsersInventory(LLUUID agentID) + { + UserProfile user = this.GetProfileByLLUUID(agentID); + if (user != null) + { + return user.Inventory; + } + + return null; + } + } } diff --git a/OpenSim.FrameWork/Util.cs b/OpenSim.FrameWork/Util.cs index d864d3f88a..620a6a549e 100644 --- a/OpenSim.FrameWork/Util.cs +++ b/OpenSim.FrameWork/Util.cs @@ -8,11 +8,21 @@ namespace OpenSim.Framework.Utilities { public class Util { + private static Random randomClass = new Random(); + public static ulong UIntsToLong(uint X, uint Y) { return Helpers.UIntsToLong(X, Y); } + public static Random RandomClass + { + get + { + return randomClass; + } + } + public Util() { diff --git a/bin/PhysicsManager.dll b/bin/PhysicsManager.dll index 311d9d1ac4d6caeb471fee708d8cba9e991b5403..12faf24feaf78a1c7b5fe524053f83eab43a629c 100644 GIT binary patch delta 2530 zcmaJ@ZERCj7=F*`z1?khZ`XDmUAvZb8-uPRV~o$Kgb$4}5CI`D77326!eFDU-69~P z8zK=jgn1(1jHOx)!pf(R`jK89q1Ma9U1Y5!fPr_kdaJRAo)9>j>BbXbG zga+$WSYdJ`oFI-w6|6qpqxzeRRgdaXj&wAf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RKFyiTBAvkWan9y6={!z>RVDXdJoxw3dH0P4Q8(5G zM{RzhvVxoI(;Rm$1_nlkPjfa;Gmv5AG+{7cFk~=iu-LrY&>e|8ncLVNN%AA(I-bpp H4*&T9JDDlM delta 118 zcmZozz}T>WaY6@k!sA~XyUV4RHZ)CUkxpP**R(lJI*(HzdF9sf-b-O_d%ZLDz8rXF zzWIsD3U00qP3~L_42%pLnl?`}kYVIBW-w+jVK8Md+q~P*9f>=c+t?mS@+0Fqp3RI7 G|M>wtgC>Lk diff --git a/bin/ServerConsole.dll b/bin/ServerConsole.dll index 9afcf97f4e92edb11d10c2eda16868818a67438e..cad41635443a5e914fdf039f83855cc86b7be355 100644 GIT binary patch delta 126 zcmZo@U~Fh$oY27>obq>LceXH#C)dit&A){0m<7)L)!wo;dzagO=iQS{gMz+n_7HdB z`}o(!?rdQecdm6!n|}%0F$-+tQ;6bwbHa0VoT9W=c4*{g4{;Yx z?sZM>Tnr413_yDGbOnA!UPA^w24f&JVK8Md*}Pd%8%=2PYb9$mMIRZ@@oZ)^_|Fdj DvY8^H diff --git a/bin/SimConfig.dll b/bin/SimConfig.dll index 9af49b5853a0217cd2bee9fbaeeb572916a176ba..1b14d11ef2bf27f418692e4510c8f0e8ad8361c0 100644 GIT binary patch delta 2492 zcmZvddu&rx9LIm>-rFZ#*WSWt={j1=qbpnK0C^3}cnC~EAcGNLLJAaE*mk#W1hI@3 z9|Qsj;}8W=n5c2XK*S{?CI$&=Fvg&Xe}FuM7$2yBBqS<{;P;#^gAs0WKlk^#zx#Wf zb=h{7ZD+f-sPk9+*S0Od4zzVHa84~JT0poeh`efB$iqWyDSM}D6U#V#SvbWt1GhpZ z`fLc%OMQtLzs1JzIj#sB!q>ZwEL75rNGqMEMDmF2sSOG>8vP-)dVy}^p&p~}zVS?t zaln1!pFKuDAFBsu6pBm%AWGzqYZO;e0g+o#Tg7LUluMR=Jq9Ij?0z(4Gs4`dPdDe%^Tm46Q=;5l&6c#NvQ?I9NsHoIWr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~av?*Ln9 z3s^!qdWX-Z9rO{u5K*ON2Ytb_3#o#>y&o%Agw z^(|RUefqt0lE(BBINh!1!24kF(l-4e`ki*_j}T-3$m8Tya)n~Os^c&n*0-QXAL?~f z&tzrw>?i#t#NjR()9cD1^?>UGq$O7qWYaOQ7F?8|2Boy%ola1@k{2jms@SdU*CN3L z-AJcs7wS1eC_?={I(+-aNImPstCeNBDW*74X*JsTk;q5>%sPC}O}OmDC#hhQbKzO9 z34hg)*j?2qKCPN#clD>%bf^0gw`T@=S5c2-zC6;!%O@6Ab|%wnXfWMJgUL0kZpf?? ztE=aTyQ^&RWOXe6QFV~HFT+A-vR^Q#(OQ`5O%0`}H*;gMccqG%zsUL2oBfmBS20#| zH2g8|%O~jS=Sj!%c2h+>E"; break; diff --git a/src/Config/SimConfig/Db4SimConfig.cs b/src/Config/SimConfig/Db4SimConfig.cs index 7037c444f9..1fafc10153 100644 --- a/src/Config/SimConfig/Db4SimConfig.cs +++ b/src/Config/SimConfig/Db4SimConfig.cs @@ -28,7 +28,9 @@ using System; using System.Collections.Generic; using OpenSim; using OpenSim.Framework.Utilities; -using OpenSim.world; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Terrain; +//using OpenSim.world; using Db4objects.Db4o; namespace Db40SimConfig @@ -44,6 +46,7 @@ namespace Db40SimConfig public class DbSimConfig :SimConfig { + private bool isSandbox; private IObjectContainer db; public void LoadDefaults() { @@ -55,7 +58,7 @@ namespace Db40SimConfig this.IPListenPort=Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("UDP port for client connections [9000]: ","9000")); this.IPListenAddr=ServerConsole.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ","127.0.0.1"); - if(!OpenSim_Main.sim.sandbox) + if(!isSandbox) { this.AssetURL=ServerConsole.MainConsole.Instance.CmdPrompt("Asset server URL: "); this.AssetSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Asset server key: "); @@ -65,7 +68,8 @@ namespace Db40SimConfig this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); } - public override void InitConfig() { + public override void InitConfig(bool sandboxMode) { + this.isSandbox = sandboxMode; try { db = Db4oFactory.OpenFile("opensim.yap"); IObjectSet result = db.Get(typeof(DbSimConfig)); @@ -100,37 +104,40 @@ namespace Db40SimConfig ServerConsole.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); ServerConsole.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString()); ServerConsole.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); - ServerConsole.MainConsole.Instance.WriteLine("Sandbox Mode? " + OpenSim_Main.sim.sandbox.ToString()); + ServerConsole.MainConsole.Instance.WriteLine("Sandbox Mode? " + isSandbox.ToString()); ServerConsole.MainConsole.Instance.WriteLine("Asset URL: " + this.AssetURL); ServerConsole.MainConsole.Instance.WriteLine("Asset key: " + this.AssetSendKey); ServerConsole.MainConsole.Instance.WriteLine("Grid URL: " + this.GridURL); ServerConsole.MainConsole.Instance.WriteLine("Grid key: " + this.GridSendKey); } - public override World LoadWorld() + public override float[] LoadWorld() { ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Loading world...."); - World blank = new World(); + //World blank = new World(); + float[] heightmap = null; ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB"); IObjectSet world_result = db.Get(typeof(MapStorage)); if(world_result.Count>0) { ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading"); MapStorage map=(MapStorage)world_result.Next(); - blank.LandMap = map.Map; + //blank.LandMap = map.Map; + heightmap = map.Map; } else { ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one"); HeightmapGenHills hills = new HeightmapGenHills(); - blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); + // blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); + heightmap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database"); MapStorage map= new MapStorage(); - map.Map = blank.LandMap; + map.Map = heightmap; //blank.LandMap; db.Set(map); db.Commit(); } - return blank; + return heightmap; } - public override void SaveMap() + public override void SaveMap(float[] heightmap) { IObjectSet world_result = db.Get(typeof(MapStorage)); if(world_result.Count>0) { @@ -139,7 +146,7 @@ namespace Db40SimConfig db.Delete(map); } MapStorage map1= new MapStorage(); - map1.Map = OpenSim_Main.local_world.LandMap; + map1.Map = heightmap; //OpenSim_Main.local_world.LandMap; db.Set(map1); db.Commit(); } diff --git a/src/Config/SimConfig/SimConfig.csproj b/src/Config/SimConfig/SimConfig.csproj index 9a689ef6b0..9993b61983 100644 --- a/src/Config/SimConfig/SimConfig.csproj +++ b/src/Config/SimConfig/SimConfig.csproj @@ -44,10 +44,6 @@ {C9A6026D-8E0C-4FE4-8691-FB2A566AA245} ServerConsole - - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E} - Second-server - \ No newline at end of file diff --git a/src/Grid.cs b/src/Grid.cs new file mode 100644 index 0000000000..d310bdb59d --- /dev/null +++ b/src/Grid.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Reflection; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.LocalServers; + +namespace OpenSim +{ + public class Grid + { + public IAssetServer AssetServer; + public IGridServer GridServer; + public string AssetDll = ""; + public string GridDll = ""; + + public Grid() + { + } + + public void LoadPlugins() + { + this.AssetServer = this.LoadAssetDll(this.AssetDll); + this.GridServer = this.LoadGridDll(this.GridDll); + } + public void Close() + { + this.AssetServer.Close(); + this.GridServer.Close(); + } + + private IAssetServer LoadAssetDll(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + IAssetServer server = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IAssetPlugin", true); + + if (typeInterface != null) + { + IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + server = plug.GetAssetServer(); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + return server; + } + + private IGridServer LoadGridDll(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + IGridServer server = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IGridPlugin", true); + + if (typeInterface != null) + { + IGridPlugin plug = (IGridPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + server = plug.GetGridServer(); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + return server; + } + } +} diff --git a/src/GridServers/LocalUserProfileManager.cs b/src/GridServers/LocalUserProfileManager.cs index 4952f04ff7..cb4c545d16 100644 --- a/src/GridServers/LocalUserProfileManager.cs +++ b/src/GridServers/LocalUserProfileManager.cs @@ -19,13 +19,18 @@ namespace OpenSim.Framework.LocalServers _gridServer = gridServer; } + public override void InitUserProfiles() + { + // TODO: need to load from database + } + public override void CustomiseResponse(ref System.Collections.Hashtable response, UserProfile theUser) { uint circode = (uint)response["circuit_code"]; theUser.AddSimCircuit(circode, LLUUID.Random()); response["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}"; - response["sim_port"] = OpenSim_Main.cfg.IPListenPort; - response["sim_ip"] = OpenSim_Main.cfg.IPListenAddr; + response["sim_port"] = OpenSim_Main.Instance.Cfg.IPListenPort; + response["sim_ip"] = OpenSim_Main.Instance.Cfg.IPListenAddr; response["region_y"] = (Int32)996 * 256; response["region_x"] = (Int32)997* 256; @@ -62,7 +67,7 @@ namespace OpenSim.Framework.LocalServers _login.InventoryFolder = new LLUUID((string)Inventory1["folder_id"]); //working on local computer if so lets add to the gridserver's list of sessions? - if (OpenSim_Main.gridServers.GridServer.GetName() == "Local") + if (OpenSim_Main.Instance.GridServers.GridServer.GetName() == "Local") { ((LocalGridBase)this._gridServer).AddNewSession(_login); } diff --git a/src/GridServers/LoginServer.cs b/src/GridServers/LoginServer.cs index cc14263dca..57b08bb4d8 100644 --- a/src/GridServers/LoginServer.cs +++ b/src/GridServers/LoginServer.cs @@ -42,6 +42,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Grid; using OpenSim.Framework.Inventory; using OpenSim.Framework.User; +using OpenSim.Framework.Utilities; namespace OpenSim.Framework.LocalServers { @@ -49,20 +50,13 @@ namespace OpenSim.Framework.LocalServers /// /// When running in local (default) mode , handles client logins. /// - public class LoginServer : LoginService + public class LoginServer : LoginService , IUserServer { - public LoginServer(IGridServer gridServer) - { - _gridServer = gridServer; - } - - private Login _login; private IGridServer _gridServer; private ushort _loginPort = 8080; public IPAddress clientAddress = IPAddress.Loopback; public IPAddress remoteAddress = IPAddress.Any; private Socket loginServer; - private Random RandomClass = new Random(); private int NumClients; private string _defaultResponse; private bool userAccounts = false; @@ -70,6 +64,11 @@ namespace OpenSim.Framework.LocalServers private bool _needPasswd = false; private LocalUserProfileManager userManager; + public LoginServer(IGridServer gridServer) + { + _gridServer = gridServer; + } + // InitializeLogin: initialize the login private void InitializeLogin() { @@ -89,7 +88,10 @@ namespace OpenSim.Framework.LocalServers } SR.Close(); this._mpasswd = EncodePassword("testpass"); + userManager = new LocalUserProfileManager(this._gridServer); + userManager.InitUserProfiles(); + userManager.SetKeys("", "", "", "Welcome to OpenSim"); loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); loginServer.Bind(new IPEndPoint(remoteAddress, _loginPort)); @@ -174,6 +176,7 @@ namespace OpenSim.Framework.LocalServers if (this.userAccounts) { + //ask the UserProfile Manager to process the request string reply = this.userManager.ParseXMLRPC(new String(content)); // forward the XML-RPC response to the client writer.WriteLine("HTTP/1.0 200 OK"); @@ -183,138 +186,158 @@ namespace OpenSim.Framework.LocalServers } else { + //handle ourselves XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content)); - this.ProcessXmlRequest(request, writer); + if (request.MethodName == "login_to_simulator") + { + this.ProcessXmlRequest(request, writer); + } + else + { + XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); + Hashtable PresenceErrorRespData = new Hashtable(); + PresenceErrorRespData["reason"] = "XmlRequest"; ; + PresenceErrorRespData["message"] = "Unknown Rpc request"; + PresenceErrorRespData["login"] = "false"; + PresenceErrorResp.Value = PresenceErrorRespData; + string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""); + writer.WriteLine("HTTP/1.0 200 OK"); + writer.WriteLine("Content-type: text/xml"); + writer.WriteLine(); + writer.WriteLine(reply); + } } } } public bool ProcessXmlRequest(XmlRpcRequest request, StreamWriter writer) { - if (request.MethodName == "login_to_simulator") + Hashtable requestData = (Hashtable)request.Params[0]; + string first; + string last; + string passwd; + LLUUID Agent; + LLUUID Session; + + //get login name + if (requestData.Contains("first")) { - Hashtable requestData = (Hashtable)request.Params[0]; - string first; - string last; - string passwd; - LLUUID Agent; - LLUUID Session; - - //get login name - if (requestData.Contains("first")) - { - first = (string)requestData["first"]; - } - else - { - first = "test"; - } - - if (requestData.Contains("last")) - { - last = (string)requestData["last"]; - } - else - { - last = "User" + NumClients.ToString(); - } - - if (requestData.Contains("passwd")) - { - passwd = (string)requestData["passwd"]; - } - else - { - passwd = "notfound"; - } - - if (!Authenticate(first, last, passwd)) - { - // Fail miserably - writer.WriteLine("HTTP/1.0 403 Authentication Forbidden"); - writer.WriteLine(); - return false; - } - NumClients++; - - //create a agent and session LLUUID - Agent = GetAgentId(first, last); - int SessionRand = this.RandomClass.Next(1, 999); - Session = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797"); - - //create some login info - Hashtable LoginFlagsHash = new Hashtable(); - LoginFlagsHash["daylight_savings"] = "N"; - LoginFlagsHash["stipend_since_login"] = "N"; - LoginFlagsHash["gendered"] = "Y"; - LoginFlagsHash["ever_logged_in"] = "Y"; - ArrayList LoginFlags = new ArrayList(); - LoginFlags.Add(LoginFlagsHash); - - Hashtable GlobalT = new Hashtable(); - GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; - GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - ArrayList GlobalTextures = new ArrayList(); - GlobalTextures.Add(GlobalT); - - XmlRpcResponse response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse); - Hashtable responseData = (Hashtable)response.Value; - - responseData["sim_port"] = OpenSim_Main.cfg.IPListenPort; - responseData["sim_ip"] = OpenSim_Main.cfg.IPListenAddr; - responseData["agent_id"] = Agent.ToStringHyphenated(); - responseData["session_id"] = Session.ToStringHyphenated(); - responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - responseData["login-flags"] = LoginFlags; - responseData["global-textures"] = GlobalTextures; - - //inventory - ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"]; - Hashtable Inventory1 = (Hashtable)InventoryList[0]; - Hashtable Inventory2 = (Hashtable)InventoryList[1]; - LLUUID BaseFolderID = LLUUID.Random(); - LLUUID InventoryFolderID = LLUUID.Random(); - Inventory2["name"] = "Base"; - Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated(); - Inventory2["type_default"] = 6; - Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated(); - - ArrayList InventoryRoot = (ArrayList)responseData["inventory-root"]; - Hashtable Inventoryroot = (Hashtable)InventoryRoot[0]; - Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated(); - - CustomiseLoginResponse(responseData, first, last); - - this._login = new Login(); - //copy data to login object - _login.First = first; - _login.Last = last; - _login.Agent = Agent; - _login.Session = Session; - _login.BaseFolder = BaseFolderID; - _login.InventoryFolder = InventoryFolderID; - - //working on local computer if so lets add to the gridserver's list of sessions? - if (OpenSim_Main.gridServers.GridServer.GetName() == "Local") - { - ((LocalGridBase)this._gridServer).AddNewSession(_login); - } - - // forward the XML-RPC response to the client - writer.WriteLine("HTTP/1.0 200 OK"); - writer.WriteLine("Content-type: text/xml"); - writer.WriteLine(); - - XmlTextWriter responseWriter = new XmlTextWriter(writer); - XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response); - responseWriter.Close(); + first = (string)requestData["first"]; } else { - writer.WriteLine("HTTP/1.0 403 Authentication Forbidden"); - writer.WriteLine(); + first = "test"; } + + if (requestData.Contains("last")) + { + last = (string)requestData["last"]; + } + else + { + last = "User" + NumClients.ToString(); + } + + if (requestData.Contains("passwd")) + { + passwd = (string)requestData["passwd"]; + } + else + { + passwd = "notfound"; + } + + if (!Authenticate(first, last, passwd)) + { + XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); + Hashtable PresenceErrorRespData = new Hashtable(); + PresenceErrorRespData["reason"] = "key"; ; + PresenceErrorRespData["message"] = "You have entered an invalid name/password combination. Check Caps/lock."; + PresenceErrorRespData["login"] = "false"; + PresenceErrorResp.Value = PresenceErrorRespData; + string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""); + writer.WriteLine("HTTP/1.0 200 OK"); + writer.WriteLine("Content-type: text/xml"); + writer.WriteLine(); + writer.WriteLine(reply); + return false; + } + + NumClients++; + + //create a agent and session LLUUID + Agent = GetAgentId(first, last); + int SessionRand = Util.RandomClass.Next(1, 999); + Session = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797"); + + //create some login info + Hashtable LoginFlagsHash = new Hashtable(); + LoginFlagsHash["daylight_savings"] = "N"; + LoginFlagsHash["stipend_since_login"] = "N"; + LoginFlagsHash["gendered"] = "Y"; + LoginFlagsHash["ever_logged_in"] = "Y"; + ArrayList LoginFlags = new ArrayList(); + LoginFlags.Add(LoginFlagsHash); + + Hashtable GlobalT = new Hashtable(); + GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; + GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + ArrayList GlobalTextures = new ArrayList(); + GlobalTextures.Add(GlobalT); + + XmlRpcResponse response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse); + Hashtable responseData = (Hashtable)response.Value; + + responseData["sim_port"] = OpenSim_Main.Instance.Cfg.IPListenPort; + responseData["sim_ip"] = OpenSim_Main.Instance.Cfg.IPListenAddr; + responseData["agent_id"] = Agent.ToStringHyphenated(); + responseData["session_id"] = Session.ToStringHyphenated(); + responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + responseData["login-flags"] = LoginFlags; + responseData["global-textures"] = GlobalTextures; + + //inventory + ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"]; + Hashtable Inventory1 = (Hashtable)InventoryList[0]; + Hashtable Inventory2 = (Hashtable)InventoryList[1]; + LLUUID BaseFolderID = LLUUID.Random(); + LLUUID InventoryFolderID = LLUUID.Random(); + Inventory2["name"] = "Base"; + Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated(); + Inventory2["type_default"] = 6; + Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated(); + + ArrayList InventoryRoot = (ArrayList)responseData["inventory-root"]; + Hashtable Inventoryroot = (Hashtable)InventoryRoot[0]; + Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated(); + + CustomiseLoginResponse(responseData, first, last); + + Login _login = new Login(); + //copy data to login object + _login.First = first; + _login.Last = last; + _login.Agent = Agent; + _login.Session = Session; + _login.BaseFolder = BaseFolderID; + _login.InventoryFolder = InventoryFolderID; + + //working on local computer if so lets add to the gridserver's list of sessions? + if (OpenSim_Main.Instance.GridServers.GridServer.GetName() == "Local") + { + ((LocalGridBase)this._gridServer).AddNewSession(_login); + } + + // forward the XML-RPC response to the client + writer.WriteLine("HTTP/1.0 200 OK"); + writer.WriteLine("Content-type: text/xml"); + writer.WriteLine(); + + XmlTextWriter responseWriter = new XmlTextWriter(writer); + XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response); + responseWriter.Close(); + return true; } @@ -325,7 +348,7 @@ namespace OpenSim.Framework.LocalServers protected virtual LLUUID GetAgentId(string firstName, string lastName) { LLUUID Agent; - int AgentRand = this.RandomClass.Next(1, 9999); + int AgentRand = Util.RandomClass.Next(1, 9999); Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead"); return Agent; } @@ -365,6 +388,17 @@ namespace OpenSim.Framework.LocalServers return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower(); } + public AgentInventory RequestAgentsInventory(LLUUID agentID) + { + AgentInventory aInventory = null; + if (this.userAccounts) + { + aInventory = this.userManager.GetUsersInventory(agentID); + } + + return aInventory; + } + } diff --git a/src/Main.cs b/src/Main.cs index 6a3b6fb8b2..3c48d179e7 100644 --- a/src/Main.cs +++ b/src/Main.cs @@ -52,12 +52,23 @@ namespace OpenSim /// public class OpenSim_Main { - public static OpenSim_Main sim; - public static SimConfig cfg; - public static World local_world; - public static Grid gridServers; + private static OpenSim_Main instance = null; + + public static OpenSim_Main Instance + { + get + { + return instance; + } + } + + public World LocalWorld; + public Grid GridServers; + public SimConfig Cfg; + public SimCAPSHTTPServer HttpServer; + public AssetCache AssetCache; + public InventoryManager InventoryCache; - public SimCAPSHTTPServer http_server; public Socket Server; private IPEndPoint ServerIncoming; private byte[] RecvBuffer = new byte[4096]; @@ -66,8 +77,6 @@ namespace OpenSim private EndPoint epSender; private AsyncCallback ReceivedData; - public AssetCache assetCache; - public InventoryManager inventoryManager; public DateTime startuptime; public Dictionary ClientThreads = new Dictionary(); private PhysicsManager physManager; @@ -84,55 +93,55 @@ namespace OpenSim Console.WriteLine("Starting...\n"); ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local, "", 0); - sim = new OpenSim_Main(); + instance = new OpenSim_Main(); - sim.sandbox = false; - sim.loginserver = false; - sim._physicsEngine = "PhysX"; + Instance.sandbox = false; + Instance.loginserver = false; + Instance._physicsEngine = "PhysX"; for (int i = 0; i < args.Length; i++) { if (args[i] == "-sandbox") { - sim.sandbox = true; + Instance.sandbox = true; } if (args[i] == "-loginserver") { - sim.loginserver = true; + Instance.loginserver = true; } if (args[i] == "-realphysx") { - sim._physicsEngine = "RealPhysX"; + Instance._physicsEngine = "RealPhysX"; OpenSim.world.Avatar.PhysicsEngineFlying = true; } } - OpenSim_Main.gridServers = new Grid(); - if (sim.sandbox) + OpenSim_Main.Instance.GridServers = new Grid(); + if (Instance.sandbox) { - OpenSim_Main.gridServers.AssetDll = "LocalGridServers.dll"; - OpenSim_Main.gridServers.GridDll = "LocalGridServers.dll"; - OpenSim_Main.gridServers.LoadPlugins(); + OpenSim_Main.Instance.GridServers.AssetDll = "LocalGridServers.dll"; + OpenSim_Main.Instance.GridServers.GridDll = "LocalGridServers.dll"; + OpenSim_Main.Instance.GridServers.LoadPlugins(); ServerConsole.MainConsole.Instance.WriteLine("Starting in Sandbox mode"); } else { - OpenSim_Main.gridServers.AssetDll = "RemoteGridServers.dll"; - OpenSim_Main.gridServers.GridDll = "RemoteGridServers.dll"; - OpenSim_Main.gridServers.LoadPlugins(); + OpenSim_Main.Instance.GridServers.AssetDll = "RemoteGridServers.dll"; + OpenSim_Main.Instance.GridServers.GridDll = "RemoteGridServers.dll"; + OpenSim_Main.Instance.GridServers.LoadPlugins(); ServerConsole.MainConsole.Instance.WriteLine("Starting in Grid mode"); } - if (sim.loginserver && sim.sandbox) + if (Instance.loginserver && Instance.sandbox) { - LoginServer loginServer = new LoginServer(OpenSim_Main.gridServers.GridServer); + LoginServer loginServer = new LoginServer(OpenSim_Main.Instance.GridServers.GridServer); loginServer.Startup(); } - sim.assetCache = new AssetCache(OpenSim_Main.gridServers.AssetServer); - sim.inventoryManager = new InventoryManager(); + Instance.AssetCache = new AssetCache(OpenSim_Main.Instance.GridServers.AssetServer); + Instance.InventoryCache = new InventoryManager(); - sim.Startup(); + Instance.Startup(); while (true) { @@ -150,41 +159,41 @@ namespace OpenSim // We check our local database first, then the grid for config options ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Loading configuration"); - cfg = this.LoadConfigDll(this.ConfigDll); - cfg.InitConfig(); + Cfg = this.LoadConfigDll(this.ConfigDll); + Cfg.InitConfig(this.sandbox); ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Contacting gridserver"); - cfg.LoadFromGrid(); + Cfg.LoadFromGrid(); - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - We are " + cfg.RegionName + " at " + cfg.RegionLocX.ToString() + "," + cfg.RegionLocY.ToString()); + ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - We are " + Cfg.RegionName + " at " + Cfg.RegionLocX.ToString() + "," + Cfg.RegionLocY.ToString()); ServerConsole.MainConsole.Instance.WriteLine("Initialising world"); - local_world = cfg.LoadWorld(); + Instance.LocalWorld = new World(); + Instance.LocalWorld.LandMap = Cfg.LoadWorld(); this.physManager = new PhysicsSystem.PhysicsManager(); this.physManager.LoadPlugins(); ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting up messaging system"); - local_world.PhysScene = this.physManager.GetPhysicsScene(this._physicsEngine); //should be reading from the config file what physics engine to use - local_world.PhysScene.SetTerrain(local_world.LandMap); + Instance.LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this._physicsEngine); //should be reading from the config file what physics engine to use + Instance.LocalWorld.PhysScene.SetTerrain(Instance.LocalWorld.LandMap); - OpenSim_Main.gridServers.AssetServer.SetServerInfo(OpenSim_Main.cfg.AssetURL, OpenSim_Main.cfg.AssetSendKey); - OpenSim_Main.gridServers.GridServer.SetServerInfo(OpenSim_Main.cfg.GridURL, OpenSim_Main.cfg.GridSendKey); + OpenSim_Main.Instance.GridServers.AssetServer.SetServerInfo(OpenSim_Main.Instance.Cfg.AssetURL, OpenSim_Main.Instance.Cfg.AssetSendKey); + OpenSim_Main.Instance.GridServers.GridServer.SetServerInfo(OpenSim_Main.Instance.Cfg.GridURL, OpenSim_Main.Instance.Cfg.GridSendKey); - local_world.LoadStorageDLL("Db4LocalStorage.dll"); //all these dll names shouldn't be hard coded. - local_world.LoadPrimsFromStorage(); + Instance.LocalWorld.LoadStorageDLL("Db4LocalStorage.dll"); //all these dll names shouldn't be hard coded. + Instance.LocalWorld.LoadPrimsFromStorage(); if (this.sandbox) { - this.assetCache.LoadDefaultTextureSet(); + this.AssetCache.LoadDefaultTextureSet(); } ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server"); - http_server = new SimCAPSHTTPServer(); + HttpServer = new SimCAPSHTTPServer(); timer1.Enabled = true; timer1.Interval = 100; timer1.Elapsed += new ElapsedEventHandler(this.Timer1Tick); MainServerListener(); - } private SimConfig LoadConfigDll(string dllName) @@ -244,9 +253,9 @@ namespace OpenSim private void MainServerListener() { ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - New thread started"); - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + cfg.IPListenAddr + ":" + cfg.IPListenPort); + ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + Cfg.IPListenAddr + ":" + Cfg.IPListenPort); - ServerIncoming = new IPEndPoint(IPAddress.Any, cfg.IPListenPort); + ServerIncoming = new IPEndPoint(IPAddress.Any, Cfg.IPListenPort); Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); Server.Bind(ServerIncoming); @@ -268,8 +277,8 @@ namespace OpenSim ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing clients"); // IMPLEMENT THIS ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing console and terminating"); - OpenSim_Main.local_world.Close(); - OpenSim_Main.gridServers.Close(); + OpenSim_Main.Instance.LocalWorld.Close(); + OpenSim_Main.Instance.GridServers.Close(); ServerConsole.MainConsole.Instance.Close(); Environment.Exit(0); } @@ -277,86 +286,9 @@ namespace OpenSim void Timer1Tick(object sender, System.EventArgs e) { - local_world.Update(); + Instance.LocalWorld.Update(); } } - public class Grid - { - public IAssetServer AssetServer; - public IGridServer GridServer; - public string AssetDll = ""; - public string GridDll = ""; - - public Grid() - { - } - - public void LoadPlugins() - { - this.AssetServer = this.LoadAssetDll(this.AssetDll); - this.GridServer = this.LoadGridDll(this.GridDll); - } - public void Close() - { - this.AssetServer.Close(); - this.GridServer.Close(); - } - - private IAssetServer LoadAssetDll(string dllName) - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - IAssetServer server = null; - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IAssetPlugin", true); - - if (typeInterface != null) - { - IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - server = plug.GetAssetServer(); - break; - } - - typeInterface = null; - } - } - } - pluginAssembly = null; - return server; - } - - private IGridServer LoadGridDll(string dllName) - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - IGridServer server = null; - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IGridPlugin", true); - - if (typeInterface != null) - { - IGridPlugin plug = (IGridPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - server = plug.GetGridServer(); - break; - } - - typeInterface = null; - } - } - } - pluginAssembly = null; - return server; - } - } + } diff --git a/src/OpenSimClient.cs b/src/OpenSimClient.cs index 062d04e8a6..3aa3480f7e 100644 --- a/src/OpenSimClient.cs +++ b/src/OpenSimClient.cs @@ -103,15 +103,15 @@ namespace OpenSim switch (Pack.Type) { case PacketType.CompleteAgentMovement: - ClientAvatar.CompleteMovement(OpenSim_Main.local_world); + ClientAvatar.CompleteMovement(OpenSim_Main.Instance.LocalWorld); ClientAvatar.SendInitialPosition(); break; case PacketType.RegionHandshakeReply: - OpenSim_Main.local_world.SendLayerData(this); + OpenSim_Main.Instance.LocalWorld.SendLayerData(this); break; case PacketType.AgentWearablesRequest: ClientAvatar.SendInitialAppearance(); - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) + foreach (OpenSimClient client in OpenSim_Main.Instance.ClientThreads.Values) { if (client.AgentID != this.AgentID) { @@ -120,10 +120,10 @@ namespace OpenSim client.ClientAvatar.SendAppearanceToOtherAgent(this); } } - OpenSim_Main.local_world.GetInitialPrims(this); + OpenSim_Main.Instance.LocalWorld.GetInitialPrims(this); break; case PacketType.ObjectAdd: - OpenSim_Main.local_world.AddNewPrim((ObjectAddPacket)Pack, this); + OpenSim_Main.Instance.LocalWorld.AddNewPrim((ObjectAddPacket)Pack, this); break; case PacketType.ObjectLink: ServerConsole.MainConsole.Instance.WriteLine(Pack.ToString()); @@ -135,7 +135,7 @@ namespace OpenSim ObjectShapePacket shape = (ObjectShapePacket)Pack; for (int i = 0; i < shape.ObjectData.Length; i++) { - foreach (Entity ent in OpenSim_Main.local_world.Entities.Values) + foreach (Entity ent in OpenSim_Main.Instance.LocalWorld.Entities.Values) { if (ent.localid == shape.ObjectData[i].ObjectLocalID) { @@ -152,7 +152,7 @@ namespace OpenSim if (multipleupdate.ObjectData[i].Type == 9) //change position { libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); - foreach (Entity ent in OpenSim_Main.local_world.Entities.Values) + foreach (Entity ent in OpenSim_Main.Instance.LocalWorld.Entities.Values) { if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID) { @@ -166,7 +166,7 @@ namespace OpenSim else if (multipleupdate.ObjectData[i].Type == 10)//rotation { libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); - foreach (Entity ent in OpenSim_Main.local_world.Entities.Values) + foreach (Entity ent in OpenSim_Main.Instance.LocalWorld.Entities.Values) { if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID) { @@ -179,7 +179,7 @@ namespace OpenSim { libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); - foreach (Entity ent in OpenSim_Main.local_world.Entities.Values) + foreach (Entity ent in OpenSim_Main.Instance.LocalWorld.Entities.Values) { if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID) { @@ -193,13 +193,13 @@ namespace OpenSim RequestImagePacket imageRequest = (RequestImagePacket)Pack; for (int i = 0; i < imageRequest.RequestImage.Length; i++) { - OpenSim_Main.sim.assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); + OpenSim_Main.Instance.AssetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); } break; case PacketType.TransferRequest: //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); TransferRequestPacket transfer = (TransferRequestPacket)Pack; - OpenSim_Main.sim.assetCache.AddAssetRequest(this, transfer); + OpenSim_Main.Instance.AssetCache.AddAssetRequest(this, transfer); break; case PacketType.AgentUpdate: ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); @@ -219,17 +219,17 @@ namespace OpenSim kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); kill.ObjectData[0].ID = this.ClientAvatar.localid; - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) + foreach (OpenSimClient client in OpenSim_Main.Instance.ClientThreads.Values) { client.OutPacket(kill); } - OpenSim_Main.gridServers.GridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode); - lock (OpenSim_Main.local_world.Entities) + OpenSim_Main.Instance.GridServers.GridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode); + lock (OpenSim_Main.Instance.LocalWorld.Entities) { - OpenSim_Main.local_world.Entities.Remove(this.AgentID); + OpenSim_Main.Instance.LocalWorld.Entities.Remove(this.AgentID); } //need to do other cleaning up here too - OpenSim_Main.sim.ClientThreads.Remove(this.userEP); + OpenSim_Main.Instance.ClientThreads.Remove(this.userEP); this.ClientThread.Abort(); break; case PacketType.ChatFromViewer: @@ -246,7 +246,7 @@ namespace OpenSim reply.ChatData.FromName = _enc.GetBytes(this.ClientAvatar.firstname + " " + this.ClientAvatar.lastname + "\0"); reply.ChatData.OwnerID = this.AgentID; reply.ChatData.SourceID = this.AgentID; - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) + foreach (OpenSimClient client in OpenSim_Main.Instance.ClientThreads.Values) { client.OutPacket(reply); } @@ -255,7 +255,7 @@ namespace OpenSim ObjectImagePacket imagePack = (ObjectImagePacket)Pack; for (int i = 0; i < imagePack.ObjectData.Length; i++) { - foreach (Entity ent in OpenSim_Main.local_world.Entities.Values) + foreach (Entity ent in OpenSim_Main.Instance.LocalWorld.Entities.Values) { if (ent.localid == imagePack.ObjectData[i].ObjectLocalID) { @@ -266,7 +266,7 @@ namespace OpenSim break; case PacketType.ObjectFlagUpdate: ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; - foreach (Entity ent in OpenSim_Main.local_world.Entities.Values) + foreach (Entity ent in OpenSim_Main.Instance.LocalWorld.Entities.Values) { if (ent.localid == flags.AgentData.ObjectLocalID) { @@ -321,11 +321,11 @@ namespace OpenSim case PacketType.FetchInventory: Console.WriteLine("fetch item packet"); FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; - OpenSim_Main.sim.inventoryManager.FetchInventory(this, FetchInventory); + OpenSim_Main.Instance.InventoryCache.FetchInventory(this, FetchInventory); break; case PacketType.FetchInventoryDescendents: FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; - OpenSim_Main.sim.inventoryManager.FetchInventoryDescendents(this, Fetch); + OpenSim_Main.Instance.InventoryCache.FetchInventoryDescendents(this, Fetch); break; } } @@ -464,11 +464,11 @@ namespace OpenSim if (Pack.Header.Zerocoded) { int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); - OpenSim_Main.sim.Server.SendTo(ZeroOutBuffer, packetsize, SocketFlags.None, userEP); + OpenSim_Main.Instance.Server.SendTo(ZeroOutBuffer, packetsize, SocketFlags.None, userEP); } else { - OpenSim_Main.sim.Server.SendTo(sendbuffer, sendbuffer.Length, SocketFlags.None, userEP); + OpenSim_Main.Instance.Server.SendTo(sendbuffer, sendbuffer.Length, SocketFlags.None, userEP); } } catch (Exception) @@ -569,14 +569,14 @@ namespace OpenSim private void InitNewClient() { ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); - OpenSim_Main.local_world.AddViewerAgent(this); - world.Entity tempent = OpenSim_Main.local_world.Entities[this.AgentID]; + OpenSim_Main.Instance.LocalWorld.AddViewerAgent(this); + world.Entity tempent = OpenSim_Main.Instance.LocalWorld.Entities[this.AgentID]; this.ClientAvatar = (world.Avatar)tempent; } private void AuthUser() { - AuthenticateResponse sessionInfo = OpenSim_Main.gridServers.GridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); + AuthenticateResponse sessionInfo = OpenSim_Main.Instance.GridServers.GridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); if (!sessionInfo.Authorised) { //session/circuit not authorised @@ -595,16 +595,16 @@ namespace OpenSim this.ClientAvatar.lastname = sessionInfo.LoginInfo.Last; // Create Inventory, currently only works for sandbox mode - if (OpenSim_Main.sim.sandbox) + if (OpenSim_Main.Instance.sandbox) { if (sessionInfo.LoginInfo.InventoryFolder != null) { this.CreateInventory(sessionInfo.LoginInfo.InventoryFolder); if (sessionInfo.LoginInfo.BaseFolder != null) { - OpenSim_Main.sim.inventoryManager.CreateNewInventoryFolder(this, sessionInfo.LoginInfo.BaseFolder); + OpenSim_Main.Instance.InventoryCache.CreateNewInventoryFolder(this, sessionInfo.LoginInfo.BaseFolder); this.newAssetFolder = sessionInfo.LoginInfo.BaseFolder; - AssetBase[] inventorySet = OpenSim_Main.sim.assetCache.CreateNewInventorySet(this.AgentID); + AssetBase[] inventorySet = OpenSim_Main.Instance.AssetCache.CreateNewInventorySet(this.AgentID); if (inventorySet != null) { for (int i = 0; i < inventorySet.Length; i++) @@ -612,7 +612,7 @@ namespace OpenSim if (inventorySet[i] != null) { Console.WriteLine(Helpers.FieldToString(inventorySet[i].Data)); - OpenSim_Main.sim.inventoryManager.AddNewInventoryItem(this, sessionInfo.LoginInfo.BaseFolder, inventorySet[i]); + OpenSim_Main.Instance.InventoryCache.AddNewInventoryItem(this, sessionInfo.LoginInfo.BaseFolder, inventorySet[i]); } } } @@ -628,8 +628,8 @@ namespace OpenSim { AgentInventory inventory = new AgentInventory(); inventory.AgentID = this.AgentID; - OpenSim_Main.sim.inventoryManager.AddNewAgentsInventory(inventory); - OpenSim_Main.sim.inventoryManager.CreateNewInventoryFolder(this, baseFolder); + OpenSim_Main.Instance.InventoryCache.AddNewAgentsInventory(inventory); + OpenSim_Main.Instance.InventoryCache.CreateNewInventoryFolder(this, baseFolder); } } diff --git a/src/OpenSimConsole.cs b/src/OpenSimConsole.cs index cf8b648330..6a94288599 100644 --- a/src/OpenSimConsole.cs +++ b/src/OpenSimConsole.cs @@ -156,7 +156,7 @@ namespace OpenSim break; case "regenerate": - OpenSim_Main.local_world.RegenerateTerrain(); + OpenSim_Main.Instance.LocalWorld.RegenerateTerrain(); break; case "shutdown": @@ -170,16 +170,16 @@ namespace OpenSim public override void ShowCommands(string ShowWhat) { switch(ShowWhat) { case "uptime": - this.WriteLine("OpenSim has been running since " + OpenSim_Main.sim.startuptime.ToString()); - this.WriteLine("That is " + (DateTime.Now-OpenSim_Main.sim.startuptime).ToString()); + this.WriteLine("OpenSim has been running since " + OpenSim_Main.Instance.startuptime.ToString()); + this.WriteLine("That is " + (DateTime.Now-OpenSim_Main.Instance.startuptime).ToString()); break; case "users": OpenSim.world.Avatar TempAv; this.WriteLine(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 OpenSim_Main.local_world.Entities.Keys) { - if(OpenSim_Main.local_world.Entities[UUID].ToString()== "OpenSim.world.Avatar") + foreach (libsecondlife.LLUUID UUID in OpenSim_Main.Instance.LocalWorld.Entities.Keys) { + if(OpenSim_Main.Instance.LocalWorld.Entities[UUID].ToString()== "OpenSim.world.Avatar") { - TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID]; + TempAv=(OpenSim.world.Avatar)OpenSim_Main.Instance.LocalWorld.Entities[UUID]; this.WriteLine(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())); } } @@ -190,7 +190,7 @@ namespace OpenSim // Displays a prompt to the user and then runs the command they entered public override void MainConsolePrompt() { string[] tempstrarray; - string tempstr = this.CmdPrompt("OpenSim-" + OpenSim_Main.cfg.RegionHandle.ToString() + " # "); + string tempstr = this.CmdPrompt("OpenSim-" + OpenSim_Main.Instance.Cfg.RegionHandle.ToString() + " # "); tempstrarray = tempstr.Split(' '); string cmd=tempstrarray[0]; Array.Reverse(tempstrarray); diff --git a/src/Second-server.csproj b/src/Second-server.csproj index fa5bdbef99..f4dcae8fa8 100644 --- a/src/Second-server.csproj +++ b/src/Second-server.csproj @@ -57,7 +57,7 @@ - + @@ -73,20 +73,11 @@ - - - {D7F0395B-FADC-4936-80A0-D95AACE92F62} - LocalGridServers - - - {74784F23-B0FD-484C-82C1-96C0215733DC} - Db4LocalStorage - {2E46A825-3168-492F-93BC-637126B5B72B} OpenSim.Framework @@ -95,10 +86,6 @@ {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B} PhysicsManager - - {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5} - RemoteGridServers - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245} ServerConsole diff --git a/src/Util.cs b/src/Util.cs deleted file mode 100644 index 4323b6f58a..0000000000 --- a/src/Util.cs +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ - -* Copyright (c) , -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections.Generic; -using System.Threading; -using libsecondlife; -using libsecondlife.Packets; - -namespace OpenSim -{ - /// - /// - /// - public class Util - { - public static ulong UIntsToLong(uint X, uint Y) - { - return Helpers.UIntsToLong(X, Y); - } - public Util() - { - - } - } - - public class QueItem - { - public QueItem() - { - } - - public Packet Packet; - public bool Incoming; - } - - public class BlockingQueue - { - private Queue _queue = new Queue(); - private object _queueSync = new object(); - - public void Enqueue(T value) - { - lock (_queueSync) - { - _queue.Enqueue(value); - Monitor.Pulse(_queueSync); - } - } - - public T Dequeue() - { - lock (_queueSync) - { - if (_queue.Count < 1) - Monitor.Wait(_queueSync); - - return _queue.Dequeue(); - } - } - } -} diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs index 477dd62465..0717c56f44 100644 --- a/src/world/Avatar.cs +++ b/src/world/Avatar.cs @@ -27,9 +27,9 @@ namespace OpenSim.world { ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); ControllingClient = TheClient; - localid = 8880000 + (OpenSim_Main.local_world._localNumber++); + localid = 8880000 + (OpenSim_Main.Instance.LocalWorld._localNumber++); position = new LLVector3(100.0f, 100.0f, 30.0f); - position.Z = OpenSim_Main.local_world.LandMap[(int)position.Y * 256 + (int)position.X] + 1; + position.Z = OpenSim_Main.Instance.LocalWorld.LandMap[(int)position.Y * 256 + (int)position.X] + 1; } public PhysicsActor PhysActor @@ -73,11 +73,11 @@ namespace OpenSim.world //use CreateTerseBlock() ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME + terse.RegionData.RegionHandle = OpenSim_Main.Instance.Cfg.RegionHandle; // FIXME terse.RegionData.TimeDilation = 64096; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; terse.ObjectData[0] = terseBlock; - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) + foreach (OpenSimClient client in OpenSim_Main.Instance.ClientThreads.Values) { client.OutPacket(terse); } @@ -95,11 +95,11 @@ namespace OpenSim.world //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 = OpenSim_Main.cfg.RegionHandle; // FIXME + terse.RegionData.RegionHandle = OpenSim_Main.Instance.Cfg.RegionHandle; // FIXME terse.RegionData.TimeDilation = 64096; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; terse.ObjectData[0] = terseBlock; - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) + foreach (OpenSimClient client in OpenSim_Main.Instance.ClientThreads.Values) { client.OutPacket(terse); } @@ -141,7 +141,7 @@ namespace OpenSim.world AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); mov.AgentData.SessionID = this.ControllingClient.SessionID; mov.AgentData.AgentID = this.ControllingClient.AgentID; - mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle; + mov.Data.RegionHandle = OpenSim_Main.Instance.Cfg.RegionHandle; // TODO - dynamicalise this stuff mov.Data.Timestamp = 1172750370; mov.Data.Position = new LLVector3(100f, 100f, 23f); @@ -156,7 +156,7 @@ namespace OpenSim.world 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 = OpenSim_Main.cfg.RegionHandle; + objupdate.RegionData.RegionHandle = OpenSim_Main.Instance.Cfg.RegionHandle; objupdate.RegionData.TimeDilation = 64096; objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; @@ -171,9 +171,9 @@ namespace OpenSim.world byte[] pb = pos2.GetBytes(); Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); - OpenSim_Main.local_world._localNumber++; + OpenSim_Main.Instance.LocalWorld._localNumber++; - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) + foreach (OpenSimClient client in OpenSim_Main.Instance.ClientThreads.Values) { client.OutPacket(objupdate); if (client.AgentID != ControllingClient.AgentID) @@ -215,7 +215,7 @@ namespace OpenSim.world 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 = OpenSim_Main.cfg.RegionHandle; + objupdate.RegionData.RegionHandle = OpenSim_Main.Instance.Cfg.RegionHandle; objupdate.RegionData.TimeDilation = 64096; objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; @@ -394,7 +394,7 @@ namespace OpenSim.world handshake.RegionInfo.SimAccess = 13; handshake.RegionInfo.WaterHeight = 20; handshake.RegionInfo.RegionFlags = 72458694; - handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0"); + handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.Instance.Cfg.RegionName + "\0"); handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); diff --git a/src/world/Primitive.cs b/src/world/Primitive.cs index 3195b1e448..149dd8665b 100644 --- a/src/world/Primitive.cs +++ b/src/world/Primitive.cs @@ -99,7 +99,7 @@ namespace OpenSim.world { if (this.newPrimFlag) { - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) + foreach (OpenSimClient client in OpenSim_Main.Instance.ClientThreads.Values) { client.OutPacket(OurPacket); } @@ -108,11 +108,11 @@ namespace OpenSim.world else if (this.updateFlag) { ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME + terse.RegionData.RegionHandle = OpenSim_Main.Instance.Cfg.RegionHandle; // FIXME terse.RegionData.TimeDilation = 64096; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; terse.ObjectData[0] = this.CreateImprovedBlock(); - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) + foreach (OpenSimClient client in OpenSim_Main.Instance.ClientThreads.Values) { client.OutPacket(terse); } @@ -120,7 +120,7 @@ namespace OpenSim.world } else if (this.dirtyFlag) { - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) + foreach (OpenSimClient client in OpenSim_Main.Instance.ClientThreads.Values) { UpdateClient(client); } @@ -131,11 +131,11 @@ namespace OpenSim.world if (this._physActor != null && this.physicsEnabled) { ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME + terse.RegionData.RegionHandle = OpenSim_Main.Instance.Cfg.RegionHandle; // FIXME terse.RegionData.TimeDilation = 64096; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; terse.ObjectData[0] = this.CreateImprovedBlock(); - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) + foreach (OpenSimClient client in OpenSim_Main.Instance.ClientThreads.Values) { client.OutPacket(terse); } @@ -254,7 +254,7 @@ namespace OpenSim.world public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) { ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; + objupdate.RegionData.RegionHandle = OpenSim_Main.Instance.Cfg.RegionHandle; objupdate.RegionData.TimeDilation = 64096; objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; @@ -301,8 +301,6 @@ namespace OpenSim.world PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist; PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin; - //finish off copying rest of shape data - objupdate.ObjectData[0].ID = (uint)(localID); objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID - 702000).ToString("00000")); objupdate.ObjectData[0].ObjectData = new byte[60]; @@ -324,7 +322,7 @@ namespace OpenSim.world { //need to clean this up as it shares a lot of code with CreateFromPacket() ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; + objupdate.RegionData.RegionHandle = OpenSim_Main.Instance.Cfg.RegionHandle; objupdate.RegionData.TimeDilation = 64096; objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; @@ -476,12 +474,11 @@ namespace OpenSim.world public override void BackUp() { - this.primData.FullID = this.uuid; this.primData.LocalID = this.localid; this.primData.Position = this.position; this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w); - OpenSim_Main.local_world.localStorage.StorePrim(this.primData); + OpenSim_Main.Instance.LocalWorld.localStorage.StorePrim(this.primData); } } diff --git a/src/world/World.cs b/src/world/World.cs index d55830c1b0..fbab044e15 100644 --- a/src/world/World.cs +++ b/src/world/World.cs @@ -8,6 +8,7 @@ using System.IO; using PhysicsSystem; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Assets; +using OpenSim.Framework.Terrain; namespace OpenSim.world { @@ -113,9 +114,9 @@ namespace OpenSim.world HeightmapGenHills hills = new HeightmapGenHills(); this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); this.phyScene.SetTerrain(this.LandMap); - OpenSim_Main.cfg.SaveMap(); + OpenSim_Main.Instance.Cfg.SaveMap(this.LandMap); - foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { + foreach(OpenSimClient client in OpenSim_Main.Instance.ClientThreads.Values) { this.SendLayerData(client); } }