aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs')
-rw-r--r--OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs148
1 files changed, 42 insertions, 106 deletions
diff --git a/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs b/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs
index 250f3fd..f3ad2cb 100644
--- a/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs
+++ b/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs
@@ -26,70 +26,58 @@
26*/ 26*/
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using OpenSim; 29using OpenSim.Framework.Console;
30using OpenSim.Framework.Utilities;
31using OpenSim.Framework.Interfaces; 30using OpenSim.Framework.Interfaces;
32using OpenSim.Framework.Terrain;
33//using OpenSim.world;
34using Db4objects.Db4o; 31using Db4objects.Db4o;
35 32
36namespace OpenSim.Config.SimConfigDb4o 33namespace OpenGrid.Config.GridConfigDb4o
37{ 34{
38 public class Db40ConfigPlugin: ISimConfig 35 public class Db40ConfigPlugin: IGridConfig
39 { 36 {
40 public SimConfig GetConfigObject() 37 public GridConfig GetConfigObject()
41 { 38 {
42 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Loading Db40Config dll"); 39 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Loading Db40Config dll");
43 return ( new DbSimConfig()); 40 return ( new DbGridConfig());
44 } 41 }
45 } 42 }
46 43
47 public class DbSimConfig : SimConfig 44 public class DbGridConfig : GridConfig
48 { 45 {
49 private bool isSandbox;
50 private IObjectContainer db; 46 private IObjectContainer db;
51 47
52 public void LoadDefaults() { 48 public void LoadDefaults() {
53 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); 49 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
54 50
55 this.RegionName=OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Name [OpenSim test]: ","OpenSim test"); 51 this.GridOwner = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid owner [OGS development team]: ", "OGS development team");
56 this.RegionLocX=(uint)Convert.ToInt32(OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location X [997]: ","997")); 52
57 this.RegionLocY=(uint)Convert.ToInt32(OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location Y [996]: ","996")); 53 this.DefaultAssetServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default asset server [no default]: ");
58 this.IPListenPort=Convert.ToInt32(OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("UDP port for client connections [9000]: ","9000")); 54 this.AssetSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to asset server: ");
59 this.IPListenAddr=OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ","127.0.0.1"); 55 this.AssetRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from asset server: ");
60 56
61 if(!isSandbox) 57 this.DefaultUserServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default user server [no default]: ");
62 { 58 this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server: ");
63 this.AssetURL=OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server URL: "); 59 this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server: ");
64 this.AssetSendKey=OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server key: "); 60
65 this.GridURL=OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid server URL: "); 61 this.SimSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to sims: ");
66 this.GridSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to grid server: "); 62 this.SimRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from sims: ");
67 this.GridRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from grid server: ");
68 this.UserURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("User server URL: ");
69 this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server: ");
70 this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server: ");
71 }
72 this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256));
73 } 63 }
74 64
75 public override void InitConfig(bool sandboxMode) { 65 public override void InitConfig() {
76 this.isSandbox = sandboxMode;
77 try { 66 try {
78 db = Db4oFactory.OpenFile("opensim.yap"); 67 db = Db4oFactory.OpenFile("opengrid.yap");
79 IObjectSet result = db.Get(typeof(DbSimConfig)); 68 IObjectSet result = db.Get(typeof(DbGridConfig));
80 if(result.Count==1) { 69 if(result.Count==1) {
81 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Found a SimConfig object in the local database, loading"); 70 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Found a GridConfig object in the local database, loading");
82 foreach (DbSimConfig cfg in result) { 71 foreach (DbGridConfig cfg in result) {
83 this.RegionName = cfg.RegionName; 72 this.GridOwner=cfg.GridOwner;
84 this.RegionLocX = cfg.RegionLocX; 73 this.DefaultAssetServer=cfg.DefaultAssetServer;
85 this.RegionLocY = cfg.RegionLocY; 74 this.AssetSendKey=cfg.AssetSendKey;
86 this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); 75 this.AssetRecvKey=cfg.AssetRecvKey;
87 this.IPListenPort = cfg.IPListenPort; 76 this.DefaultUserServer=cfg.DefaultUserServer;
88 this.IPListenAddr = cfg.IPListenAddr; 77 this.UserSendKey=cfg.UserSendKey;
89 this.AssetURL = cfg.AssetURL; 78 this.UserRecvKey=cfg.UserRecvKey;
90 this.AssetSendKey = cfg.AssetSendKey; 79 this.SimSendKey=cfg.SimSendKey;
91 this.GridURL = cfg.GridURL; 80 this.SimRecvKey=cfg.SimRecvKey;
92 this.GridSendKey = cfg.GridSendKey;
93 } 81 }
94 } else { 82 } else {
95 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); 83 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults");
@@ -103,70 +91,18 @@ namespace OpenSim.Config.SimConfigDb4o
103 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); 91 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString());
104 } 92 }
105 93
106 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sim settings loaded:"); 94 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid settings loaded:");
107 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Name: " + this.RegionName); 95 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid owner: " + this.GridOwner);
108 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); 96 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Default asset server: " + this.DefaultAssetServer);
109 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString()); 97 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to asset server: " + this.AssetSendKey);
110 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); 98 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from asset server: " + this.AssetRecvKey);
111 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sandbox Mode? " + isSandbox.ToString()); 99 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Default user server: " + this.DefaultUserServer);
112 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset URL: " + this.AssetURL); 100 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to user server: " + this.UserSendKey);
113 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset key: " + this.AssetSendKey); 101 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from user server: " + this.UserRecvKey);
114 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid URL: " + this.GridURL); 102 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to sims: " + this.SimSendKey);
115 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid key: " + this.GridSendKey); 103 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from sims: " + this.SimRecvKey);
116 } 104 }
117 105
118 public override float[] LoadWorld()
119 {
120 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Loading world....");
121 //World blank = new World();
122 float[] heightmap = null;
123 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB");
124 IObjectSet world_result = db.Get(typeof(MapStorage));
125 if(world_result.Count>0) {
126 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading");
127 MapStorage map=(MapStorage)world_result.Next();
128 //blank.LandMap = map.Map;
129 heightmap = map.Map;
130 } else {
131 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one");
132 HeightmapGenHills hills = new HeightmapGenHills();
133 // blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
134 heightmap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
135 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database");
136 MapStorage map= new MapStorage();
137 map.Map = heightmap; //blank.LandMap;
138 db.Set(map);
139 db.Commit();
140 }
141 return heightmap;
142 }
143
144 public override void SaveMap(float[] heightmap)
145 {
146 IObjectSet world_result = db.Get(typeof(MapStorage));
147 if(world_result.Count>0) {
148 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - updating saved copy of heightmap in local database");
149 MapStorage map=(MapStorage)world_result.Next();
150 db.Delete(map);
151 }
152 MapStorage map1= new MapStorage();
153 map1.Map = heightmap; //OpenSim_Main.local_world.LandMap;
154 db.Set(map1);
155 db.Commit();
156 }
157
158 public override void LoadFromGrid() {
159 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!");
160 // TODO: Make this crap work
161 /* WebRequest GridLogin = WebRequest.Create(this.GridURL + "regions/" + this.RegionHandle.ToString() + "/login");
162 WebResponse GridResponse = GridLogin.GetResponse();
163 byte[] idata = new byte[(int)GridResponse.ContentLength];
164 BinaryReader br = new BinaryReader(GridResponse.GetResponseStream());
165
166 br.Close();
167 GridResponse.Close();
168 */
169 }
170 106
171 public void Shutdown() { 107 public void Shutdown() {
172 db.Close(); 108 db.Close();