aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorlbsa712007-07-17 00:07:26 +0000
committerlbsa712007-07-17 00:07:26 +0000
commit47ea453b32fe8122ed2eb0d62607f65d3dbdddb8 (patch)
tree83877e94fdc053c3c0f5d2e431cbe8f49228840e /OpenSim
parent* RegionApplicationBase restructuring now complete (diff)
downloadopensim-SC-47ea453b32fe8122ed2eb0d62607f65d3dbdddb8.zip
opensim-SC-47ea453b32fe8122ed2eb0d62607f65d3dbdddb8.tar.gz
opensim-SC-47ea453b32fe8122ed2eb0d62607f65d3dbdddb8.tar.bz2
opensim-SC-47ea453b32fe8122ed2eb0d62607f65d3dbdddb8.tar.xz
* debugged quite a lot of db-related strangeness and various refactoring goofs
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs13
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs55
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Program.cs17
-rw-r--r--OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs249
4 files changed, 150 insertions, 184 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 671b222..5bba87a 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -89,7 +89,7 @@ namespace OpenSim.Region.Environment.Scenes
89 return (this.phyScene); 89 return (this.phyScene);
90 } 90 }
91 } 91 }
92 92
93 private LandManager m_LandManager; 93 private LandManager m_LandManager;
94 public LandManager LandManager 94 public LandManager LandManager
95 { 95 {
@@ -441,15 +441,8 @@ namespace OpenSim.Region.Environment.Scenes
441 /// </summary> 441 /// </summary>
442 public void LoadPrimsFromStorage() 442 public void LoadPrimsFromStorage()
443 { 443 {
444 try 444 MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives");
445 { 445 this.localStorage.LoadPrimitives(this);
446 MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives");
447 this.localStorage.LoadPrimitives(this);
448 }
449 catch (Exception e)
450 {
451 MainLog.Instance.Warn("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString());
452 }
453 } 446 }
454 447
455 /// <summary> 448 /// <summary>
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index cbf69ac..4326553 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -38,7 +38,7 @@ using OpenSim.Framework;
38 38
39namespace OpenSim.Region.Environment.Scenes 39namespace OpenSim.Region.Environment.Scenes
40{ 40{
41 public abstract class SceneBase : IWorld 41 public abstract class SceneBase : IWorld
42 { 42 {
43 public Dictionary<LLUUID, EntityBase> Entities; 43 public Dictionary<LLUUID, EntityBase> Entities;
44 protected ulong m_regionHandle; 44 protected ulong m_regionHandle;
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Environment.Scenes
47 47
48 public TerrainEngine Terrain; 48 public TerrainEngine Terrain;
49 49
50 public string m_datastore; 50 protected string m_datastore;
51 public ILocalStorage localStorage; 51 public ILocalStorage localStorage;
52 52
53 protected object m_syncRoot = new object(); 53 protected object m_syncRoot = new object();
@@ -76,44 +76,37 @@ namespace OpenSim.Region.Environment.Scenes
76 /// <returns>Successful or not</returns> 76 /// <returns>Successful or not</returns>
77 public bool LoadStorageDLL(string dllName) 77 public bool LoadStorageDLL(string dllName)
78 { 78 {
79 try 79 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
80 { 80 ILocalStorage store = null;
81 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
82 ILocalStorage store = null;
83 81
84 foreach (Type pluginType in pluginAssembly.GetTypes()) 82 foreach (Type pluginType in pluginAssembly.GetTypes())
83 {
84 if (pluginType.IsPublic)
85 { 85 {
86 if (pluginType.IsPublic) 86 if (!pluginType.IsAbstract)
87 { 87 {
88 if (!pluginType.IsAbstract) 88 Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
89 {
90 Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
91 89
92 if (typeInterface != null) 90 if (typeInterface != null)
93 { 91 {
94 ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 92 ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
95 store = plug; 93 store = plug;
96
97 store.Initialise(this.m_datastore);
98 break;
99 }
100 94
101 typeInterface = null; 95 store.Initialise(this.m_datastore);
96 break;
102 } 97 }
98
99 typeInterface = null;
103 } 100 }
104 } 101 }
105 pluginAssembly = null;
106 this.localStorage = store;
107 return (store == null);
108 }
109 catch (Exception e)
110 {
111 MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString());
112 return false;
113 } 102 }
103 pluginAssembly = null;
104 this.localStorage = store;
105 return (store == null);
106
114 } 107 }
115 108
116 109
117 /// <summary> 110 /// <summary>
118 /// Send the region heightmap to the client 111 /// Send the region heightmap to the client
119 /// </summary> 112 /// </summary>
@@ -150,7 +143,7 @@ namespace OpenSim.Region.Environment.Scenes
150 /// </summary> 143 /// </summary>
151 /// <param name="agentID"></param> 144 /// <param name="agentID"></param>
152 public abstract void RemoveClient(LLUUID agentID); 145 public abstract void RemoveClient(LLUUID agentID);
153 146
154 #endregion 147 #endregion
155 148
156 /// <summary> 149 /// <summary>
@@ -190,6 +183,6 @@ namespace OpenSim.Region.Environment.Scenes
190 183
191 #endregion 184 #endregion
192 185
193 186
194 } 187 }
195} 188}
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
index c945d39..322db2c 100644
--- a/OpenSim/Region/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -22,10 +22,6 @@ namespace SimpleApp
22{ 22{
23 class Program : RegionApplicationBase, conscmd_callback 23 class Program : RegionApplicationBase, conscmd_callback
24 { 24 {
25 public MyWorld m_scene;
26 private SceneObject m_sceneObject;
27 public MyNpcCharacter m_character;
28
29 protected override LogBase CreateLog() 25 protected override LogBase CreateLog()
30 { 26 {
31 return new LogBase(null, "SimpleApp", this, false); 27 return new LogBase(null, "SimpleApp", this, false);
@@ -40,20 +36,21 @@ namespace SimpleApp
40 LocalAssetServer assetServer = new LocalAssetServer(); 36 LocalAssetServer assetServer = new LocalAssetServer();
41 assetServer.SetServerInfo("http://localhost:8003/", ""); 37 assetServer.SetServerInfo("http://localhost:8003/", "");
42 38
43 AssetCache m_assetCache = new AssetCache(assetServer); 39 m_assetCache = new AssetCache(assetServer);
44 } 40 }
45 41
46 public void Run() 42 public void Run()
47 { 43 {
48 base.StartUp(); 44 base.StartUp();
49 45
50 CommunicationsLocal m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer); 46 m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer);
51 47
52 ScenePresence.PhysicsEngineFlying = true; 48 ScenePresence.PhysicsEngineFlying = true;
53 49
54 IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000); 50 IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000);
55 RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "localhost"); 51 RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "localhost");
56 52 regionInfo.DataStore = "simpleapp_datastore.yap";
53
57 UDPServer udpServer; 54 UDPServer udpServer;
58 55
59 Scene scene = SetupScene(regionInfo, out udpServer); 56 Scene scene = SetupScene(regionInfo, out udpServer);
@@ -64,10 +61,10 @@ namespace SimpleApp
64 shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); 61 shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
65 LLVector3 pos = new LLVector3(138, 129, 27); 62 LLVector3 pos = new LLVector3(138, 129, 27);
66 63
67 m_sceneObject = new MySceneObject(scene, scene.EventManager, LLUUID.Zero, scene.PrimIDAllocate(), pos, shape); 64 SceneObject m_sceneObject = new MySceneObject(scene, scene.EventManager, LLUUID.Zero, scene.PrimIDAllocate(), pos, shape);
68 scene.AddEntity(m_sceneObject); 65 scene.AddEntity(m_sceneObject);
69 66
70 m_character = new MyNpcCharacter(); 67 MyNpcCharacter m_character = new MyNpcCharacter();
71 scene.AddNewClient(m_character, false); 68 scene.AddNewClient(m_character, false);
72 69
73 m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit."); 70 m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit.");
@@ -107,7 +104,7 @@ namespace SimpleApp
107 { 104 {
108 Program app = new Program(); 105 Program app = new Program();
109 106
110 app.StartUp(); 107 app.Run();
111 } 108 }
112 } 109 }
113} 110}
diff --git a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
index f3d7a2c..2f827cf 100644
--- a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
+++ b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
@@ -64,22 +64,15 @@ namespace OpenSim.Region.GridInterfaces.Local
64 this._assetRequests = new BlockingQueue<ARequest>(); 64 this._assetRequests = new BlockingQueue<ARequest>();
65 yapfile = File.Exists("regionassets.yap"); 65 yapfile = File.Exists("regionassets.yap");
66 66
67 MainLog.Instance.Verbose( "Local Asset Server class created"); 67 MainLog.Instance.Verbose("Local Asset Server class created");
68 try 68 db = Db4oFactory.OpenFile("regionassets.yap");
69 { 69 MainLog.Instance.Verbose("Db4 Asset database creation");
70 db = Db4oFactory.OpenFile("regionassets.yap"); 70
71 MainLog.Instance.Verbose( "Db4 Asset database creation");
72 }
73 catch (Exception e)
74 {
75 db.Close();
76 MainLog.Instance.WriteLine(LogPriority.MEDIUM, "Db4 Asset server :Constructor - Exception occured");
77 MainLog.Instance.Warn(e.ToString());
78 }
79 if (!yapfile) 71 if (!yapfile)
80 { 72 {
81 this.SetUpAssetDatabase(); 73 this.SetUpAssetDatabase();
82 } 74 }
75
83 this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); 76 this._localAssetServerThread = new Thread(new ThreadStart(RunRequests));
84 this._localAssetServerThread.IsBackground = true; 77 this._localAssetServerThread.IsBackground = true;
85 this._localAssetServerThread.Start(); 78 this._localAssetServerThread.Start();
@@ -122,7 +115,7 @@ namespace OpenSim.Region.GridInterfaces.Local
122 { 115 {
123 if (db != null) 116 if (db != null)
124 { 117 {
125 MainLog.Instance.Verbose( "Closing local asset server database"); 118 MainLog.Instance.Verbose("Closing local asset server database");
126 db.Close(); 119 db.Close();
127 } 120 }
128 } 121 }
@@ -163,116 +156,106 @@ namespace OpenSim.Region.GridInterfaces.Local
163 156
164 private void SetUpAssetDatabase() 157 private void SetUpAssetDatabase()
165 { 158 {
166 try 159 MainLog.Instance.Verbose("Setting up asset database");
167 {
168 160
169 MainLog.Instance.Verbose( "Setting up asset database"); 161 AssetBase Image = new AssetBase();
170 162 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001");
171 AssetBase Image = new AssetBase(); 163 Image.Name = "Bricks";
172 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); 164 this.LoadAsset(Image, true, "bricks.jp2");
173 Image.Name = "Bricks"; 165 AssetStorage store = new AssetStorage();
174 this.LoadAsset(Image, true, "bricks.jp2"); 166 store.Data = Image.Data;
175 AssetStorage store = new AssetStorage(); 167 store.Name = Image.Name;
176 store.Data = Image.Data; 168 store.UUID = Image.FullID;
177 store.Name = Image.Name; 169 db.Set(store);
178 store.UUID = Image.FullID; 170 db.Commit();
179 db.Set(store); 171
180 db.Commit(); 172 Image = new AssetBase();
181 173 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002");
182 Image = new AssetBase(); 174 Image.Name = "Plywood";
183 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); 175 this.LoadAsset(Image, true, "plywood.jp2");
184 Image.Name = "Plywood"; 176 store = new AssetStorage();
185 this.LoadAsset(Image, true, "plywood.jp2"); 177 store.Data = Image.Data;
186 store = new AssetStorage(); 178 store.Name = Image.Name;
187 store.Data = Image.Data; 179 store.UUID = Image.FullID;
188 store.Name = Image.Name; 180 db.Set(store);
189 store.UUID = Image.FullID; 181 db.Commit();
190 db.Set(store); 182
191 db.Commit(); 183 Image = new AssetBase();
192 184 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003");
193 Image = new AssetBase(); 185 Image.Name = "Rocks";
194 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); 186 this.LoadAsset(Image, true, "rocks.jp2");
195 Image.Name = "Rocks"; 187 store = new AssetStorage();
196 this.LoadAsset(Image, true, "rocks.jp2"); 188 store.Data = Image.Data;
197 store = new AssetStorage(); 189 store.Name = Image.Name;
198 store.Data = Image.Data; 190 store.UUID = Image.FullID;
199 store.Name = Image.Name; 191 db.Set(store);
200 store.UUID = Image.FullID; 192 db.Commit();
201 db.Set(store); 193
202 db.Commit(); 194 Image = new AssetBase();
203 195 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004");
204 Image = new AssetBase(); 196 Image.Name = "Granite";
205 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); 197 this.LoadAsset(Image, true, "granite.jp2");
206 Image.Name = "Granite"; 198 store = new AssetStorage();
207 this.LoadAsset(Image, true, "granite.jp2"); 199 store.Data = Image.Data;
208 store = new AssetStorage(); 200 store.Name = Image.Name;
209 store.Data = Image.Data; 201 store.UUID = Image.FullID;
210 store.Name = Image.Name; 202 db.Set(store);
211 store.UUID = Image.FullID; 203 db.Commit();
212 db.Set(store);
213 db.Commit();
214
215 Image = new AssetBase();
216 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005");
217 Image.Name = "Hardwood";
218 this.LoadAsset(Image, true, "hardwood.jp2");
219 store = new AssetStorage();
220 store.Data = Image.Data;
221 store.Name = Image.Name;
222 store.UUID = Image.FullID;
223 db.Set(store);
224 db.Commit();
225
226 Image = new AssetBase();
227 Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005");
228 Image.Name = "Prim Base Texture";
229 this.LoadAsset(Image, true, "plywood.jp2");
230 store = new AssetStorage();
231 store.Data = Image.Data;
232 store.Name = Image.Name;
233 store.UUID = Image.FullID;
234 db.Set(store);
235 db.Commit();
236
237 Image = new AssetBase();
238 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006");
239 Image.Name = "Map Base Texture";
240 this.LoadAsset(Image, true, "map_base.jp2");
241 store = new AssetStorage();
242 store.Data = Image.Data;
243 store.Name = Image.Name;
244 store.UUID = Image.FullID;
245 db.Set(store);
246 db.Commit();
247
248 Image = new AssetBase();
249 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007");
250 Image.Name = "Map Texture";
251 this.LoadAsset(Image, true, "map1.jp2");
252 store = new AssetStorage();
253 store.Data = Image.Data;
254 store.Name = Image.Name;
255 store.UUID = Image.FullID;
256 db.Set(store);
257 db.Commit();
258
259 Image = new AssetBase();
260 Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
261 Image.Name = "Shape";
262 this.LoadAsset(Image, false, "base_shape.dat");
263 store = new AssetStorage();
264 store.Data = Image.Data;
265 store.Name = Image.Name;
266 store.UUID = Image.FullID;
267 db.Set(store);
268 db.Commit();
269 }
270 catch (Exception e)
271 {
272 Console.WriteLine("exception loading default assets into database");
273 Console.WriteLine(e.Message);
274 }
275 204
205 Image = new AssetBase();
206 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005");
207 Image.Name = "Hardwood";
208 this.LoadAsset(Image, true, "hardwood.jp2");
209 store = new AssetStorage();
210 store.Data = Image.Data;
211 store.Name = Image.Name;
212 store.UUID = Image.FullID;
213 db.Set(store);
214 db.Commit();
215
216 Image = new AssetBase();
217 Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005");
218 Image.Name = "Prim Base Texture";
219 this.LoadAsset(Image, true, "plywood.jp2");
220 store = new AssetStorage();
221 store.Data = Image.Data;
222 store.Name = Image.Name;
223 store.UUID = Image.FullID;
224 db.Set(store);
225 db.Commit();
226
227 Image = new AssetBase();
228 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006");
229 Image.Name = "Map Base Texture";
230 this.LoadAsset(Image, true, "map_base.jp2");
231 store = new AssetStorage();
232 store.Data = Image.Data;
233 store.Name = Image.Name;
234 store.UUID = Image.FullID;
235 db.Set(store);
236 db.Commit();
237
238 Image = new AssetBase();
239 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007");
240 Image.Name = "Map Texture";
241 this.LoadAsset(Image, true, "map1.jp2");
242 store = new AssetStorage();
243 store.Data = Image.Data;
244 store.Name = Image.Name;
245 store.UUID = Image.FullID;
246 db.Set(store);
247 db.Commit();
248
249 Image = new AssetBase();
250 Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
251 Image.Name = "Shape";
252 this.LoadAsset(Image, false, "base_shape.dat");
253 store = new AssetStorage();
254 store.Data = Image.Data;
255 store.Name = Image.Name;
256 store.UUID = Image.FullID;
257 db.Set(store);
258 db.Commit();
276 } 259 }
277 260
278 private void LoadAsset(AssetBase info, bool image, string filename) 261 private void LoadAsset(AssetBase info, bool image, string filename)
@@ -294,18 +277,18 @@ namespace OpenSim.Region.GridInterfaces.Local
294 //info.loaded=true; 277 //info.loaded=true;
295 } 278 }
296 } 279 }
297 public class AssetUUIDQuery : Predicate 280 public class AssetUUIDQuery : Predicate
298 { 281 {
299 private LLUUID _findID; 282 private LLUUID _findID;
300 283
301 public AssetUUIDQuery(LLUUID find) 284 public AssetUUIDQuery(LLUUID find)
302 { 285 {
303 _findID = find; 286 _findID = find;
304 } 287 }
305 public bool Match(AssetStorage asset) 288 public bool Match(AssetStorage asset)
306 { 289 {
307 return (asset.UUID == _findID); 290 return (asset.UUID == _findID);
308 }
309 } 291 }
310 292 }
293
311} 294}