diff options
Diffstat (limited to 'src/Config/SimConfig/Db4SimConfig.cs')
-rw-r--r-- | src/Config/SimConfig/Db4SimConfig.cs | 177 |
1 files changed, 0 insertions, 177 deletions
diff --git a/src/Config/SimConfig/Db4SimConfig.cs b/src/Config/SimConfig/Db4SimConfig.cs deleted file mode 100644 index 1b696fe..0000000 --- a/src/Config/SimConfig/Db4SimConfig.cs +++ /dev/null | |||
@@ -1,177 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using OpenSim; | ||
30 | using OpenSim.world; | ||
31 | using Db4objects.Db4o; | ||
32 | |||
33 | namespace Db40SimConfig | ||
34 | { | ||
35 | public class Db40ConfigPlugin: ISimConfig | ||
36 | { | ||
37 | public SimConfig GetConfigObject() | ||
38 | { | ||
39 | ServerConsole.MainConsole.Instance.WriteLine("Loading Db40Config dll"); | ||
40 | return ( new DbSimConfig()); | ||
41 | } | ||
42 | } | ||
43 | |||
44 | public class DbSimConfig :SimConfig | ||
45 | { | ||
46 | private IObjectContainer db; | ||
47 | |||
48 | public void LoadDefaults() { | ||
49 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); | ||
50 | |||
51 | this.RegionName=ServerConsole.MainConsole.Instance.CmdPrompt("Name [OpenSim test]: ","OpenSim test"); | ||
52 | this.RegionLocX=(uint)Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("Grid Location X [997]: ","997")); | ||
53 | this.RegionLocY=(uint)Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("Grid Location Y [996]: ","996")); | ||
54 | this.IPListenPort=Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("UDP port for client connections [9000]: ","9000")); | ||
55 | this.IPListenAddr=ServerConsole.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ","127.0.0.1"); | ||
56 | |||
57 | if(!OpenSim_Main.sim.sandbox) | ||
58 | { | ||
59 | this.AssetURL=ServerConsole.MainConsole.Instance.CmdPrompt("Asset server URL: "); | ||
60 | this.AssetSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Asset server key: "); | ||
61 | this.GridURL=ServerConsole.MainConsole.Instance.CmdPrompt("Grid server URL: "); | ||
62 | this.GridSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to grid server: "); | ||
63 | this.GridRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from grid server: "); | ||
64 | this.UserURL=ServerConsole.MainConsole.Instance.CmdPrompt("User server URL: "); | ||
65 | this.UserSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to user server: "); | ||
66 | this.UserRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from user server: "); | ||
67 | } | ||
68 | this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); | ||
69 | } | ||
70 | |||
71 | public override void InitConfig() { | ||
72 | try { | ||
73 | db = Db4oFactory.OpenFile("opensim.yap"); | ||
74 | IObjectSet result = db.Get(typeof(DbSimConfig)); | ||
75 | if(result.Count==1) { | ||
76 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Found a SimConfig object in the local database, loading"); | ||
77 | foreach (DbSimConfig cfg in result) { | ||
78 | this.RegionName = cfg.RegionName; | ||
79 | this.RegionLocX = cfg.RegionLocX; | ||
80 | this.RegionLocY = cfg.RegionLocY; | ||
81 | this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); | ||
82 | this.IPListenPort = cfg.IPListenPort; | ||
83 | this.IPListenAddr = cfg.IPListenAddr; | ||
84 | this.AssetURL = cfg.AssetURL; | ||
85 | this.AssetSendKey = cfg.AssetSendKey; | ||
86 | this.GridURL = cfg.GridURL; | ||
87 | this.GridSendKey = cfg.GridSendKey; | ||
88 | } | ||
89 | } else { | ||
90 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); | ||
91 | LoadDefaults(); | ||
92 | ServerConsole.MainConsole.Instance.WriteLine("Writing out default settings to local database"); | ||
93 | db.Set(this); | ||
94 | } | ||
95 | } catch(Exception e) { | ||
96 | db.Close(); | ||
97 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured"); | ||
98 | ServerConsole.MainConsole.Instance.WriteLine(e.ToString()); | ||
99 | } | ||
100 | |||
101 | ServerConsole.MainConsole.Instance.WriteLine("Sim settings loaded:"); | ||
102 | ServerConsole.MainConsole.Instance.WriteLine("Name: " + this.RegionName); | ||
103 | ServerConsole.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); | ||
104 | ServerConsole.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString()); | ||
105 | ServerConsole.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); | ||
106 | ServerConsole.MainConsole.Instance.WriteLine("Sandbox Mode? " + OpenSim_Main.sim.sandbox.ToString()); | ||
107 | ServerConsole.MainConsole.Instance.WriteLine("Asset URL: " + this.AssetURL); | ||
108 | ServerConsole.MainConsole.Instance.WriteLine("Asset key: " + this.AssetSendKey); | ||
109 | ServerConsole.MainConsole.Instance.WriteLine("Grid URL: " + this.GridURL); | ||
110 | ServerConsole.MainConsole.Instance.WriteLine("Grid key: " + this.GridSendKey); | ||
111 | } | ||
112 | |||
113 | public override World LoadWorld() | ||
114 | { | ||
115 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Loading world...."); | ||
116 | World blank = new World(); | ||
117 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB"); | ||
118 | IObjectSet world_result = db.Get(typeof(MapStorage)); | ||
119 | if(world_result.Count>0) { | ||
120 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading"); | ||
121 | MapStorage map=(MapStorage)world_result.Next(); | ||
122 | blank.LandMap = map.Map; | ||
123 | } else { | ||
124 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one"); | ||
125 | HeightmapGenHills hills = new HeightmapGenHills(); | ||
126 | blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); | ||
127 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database"); | ||
128 | MapStorage map= new MapStorage(); | ||
129 | map.Map = blank.LandMap; | ||
130 | db.Set(map); | ||
131 | db.Commit(); | ||
132 | } | ||
133 | return blank; | ||
134 | } | ||
135 | |||
136 | public override void SaveMap() | ||
137 | { | ||
138 | IObjectSet world_result = db.Get(typeof(MapStorage)); | ||
139 | if(world_result.Count>0) { | ||
140 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - updating saved copy of heightmap in local database"); | ||
141 | MapStorage map=(MapStorage)world_result.Next(); | ||
142 | db.Delete(map); | ||
143 | } | ||
144 | MapStorage map1= new MapStorage(); | ||
145 | map1.Map = OpenSim_Main.local_world.LandMap; | ||
146 | db.Set(map1); | ||
147 | db.Commit(); | ||
148 | } | ||
149 | |||
150 | public override void LoadFromGrid() { | ||
151 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!"); | ||
152 | // TODO: Make this crap work | ||
153 | /* WebRequest GridLogin = WebRequest.Create(this.GridURL + "regions/" + this.RegionHandle.ToString() + "/login"); | ||
154 | WebResponse GridResponse = GridLogin.GetResponse(); | ||
155 | byte[] idata = new byte[(int)GridResponse.ContentLength]; | ||
156 | BinaryReader br = new BinaryReader(GridResponse.GetResponseStream()); | ||
157 | |||
158 | br.Close(); | ||
159 | GridResponse.Close(); | ||
160 | */ | ||
161 | } | ||
162 | |||
163 | public void Shutdown() { | ||
164 | db.Close(); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | public class MapStorage | ||
169 | { | ||
170 | public float[] Map; | ||
171 | |||
172 | public MapStorage() | ||
173 | { | ||
174 | |||
175 | } | ||
176 | } | ||
177 | } | ||