From 1ea4ba3a18cf0ccdc512a1cc800e44bc5cf16210 Mon Sep 17 00:00:00 2001
From: MW
Date: Mon, 2 Apr 2007 10:46:59 +0000
Subject: Moved database storage of the world map to the Db4LocalStorage so its
in the same database as in world prims are stored.
---
.../LocalStorageDb4o/Db4LocalStorage.cs | 47 ++++-
OpenSim.Storage/LocalStorageDb4o/MapStorage.cs | 16 ++
.../OpenSim.Storage.LocalStorageDb4o.csproj | 223 +++++++++++----------
3 files changed, 175 insertions(+), 111 deletions(-)
create mode 100644 OpenSim.Storage/LocalStorageDb4o/MapStorage.cs
(limited to 'OpenSim.Storage')
diff --git a/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs b/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs
index 93ed9cc..cdab9ba 100644
--- a/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs
+++ b/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs
@@ -31,6 +31,7 @@ using Db4objects.Db4o.Query;
using libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Assets;
+using OpenSim.Framework.Terrain;
namespace OpenSim.Storage.LocalStorageDb4o
{
@@ -116,7 +117,51 @@ namespace OpenSim.Storage.LocalStorageDb4o
receiver.PrimFromStorage(prim);
}
}
-
+
+ public float[] LoadWorld()
+ {
+ OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Loading world....");
+ //World blank = new World();
+ float[] heightmap = null;
+ OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Looking for a heightmap in local DB");
+ IObjectSet world_result = db.Get(typeof(MapStorage));
+ if (world_result.Count > 0)
+ {
+ OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Found a heightmap in local database, loading");
+ MapStorage map = (MapStorage)world_result.Next();
+ //blank.LandMap = map.Map;
+ heightmap = map.Map;
+ }
+ else
+ {
+ OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - No heightmap found, generating new one");
+ HeightmapGenHills hills = new HeightmapGenHills();
+ // blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
+ heightmap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
+ OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Saving heightmap to local database");
+ MapStorage map = new MapStorage();
+ map.Map = heightmap; //blank.LandMap;
+ db.Set(map);
+ db.Commit();
+ }
+ return heightmap;
+ }
+
+ public void SaveMap(float[] heightmap)
+ {
+ IObjectSet world_result = db.Get(typeof(MapStorage));
+ if (world_result.Count > 0)
+ {
+ OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SaveWorld() - updating saved copy of heightmap in local database");
+ MapStorage map = (MapStorage)world_result.Next();
+ db.Delete(map);
+ }
+ MapStorage map1 = new MapStorage();
+ map1.Map = heightmap; //OpenSim_Main.local_world.LandMap;
+ db.Set(map1);
+ db.Commit();
+ }
+
public void ShutDown()
{
db.Commit();
diff --git a/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs b/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs
new file mode 100644
index 0000000..db590ff
--- /dev/null
+++ b/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Storage.LocalStorageDb4o
+{
+ public class MapStorage
+ {
+ public float[] Map;
+
+ public MapStorage()
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj
index b366e35..6504b77 100644
--- a/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj
+++ b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj
@@ -1,110 +1,113 @@
-
-
- Local
- 8.0.50727
- 2.0
- {4D4E187D-0000-0000-0000-000000000000}
- Debug
- AnyCPU
-
-
-
- OpenSim.Storage.LocalStorageDb4o
- JScript
- Grid
- IE50
- false
- Library
-
- OpenSim.Storage.LocalStorageDb4o
-
-
-
-
-
- False
- 285212672
- False
-
-
- TRACE
-
- False
- 4096
- True
- ../../bin/
- False
- False
- False
- 4
-
-
-
- False
- 285212672
- False
-
-
- TRACE;DEBUG
-
- True
- 4096
- False
- ../../bin/
- False
- False
- False
- 4
-
-
-
-
- System.dll
- False
-
-
- System.Xml.dll
- False
-
-
- ..\..\bin\Db4objects.Db4o.dll
- False
-
-
- ..\..\bin\libsecondlife.dll
- False
-
-
-
-
- OpenSim.Framework
- {7404933D-0000-0000-0000-000000000000}
- {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
-
-
- OpenSim.Framework.Console
- {16759386-0000-0000-0000-000000000000}
- {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
-
-
-
-
- Code
-
-
- Code
-
-
- Code
-
-
-
-
-
-
-
-
-
-
+
+
+ Local
+ 8.0.50727
+ 2.0
+ {E1B79ECF-0000-0000-0000-000000000000}
+ Debug
+ AnyCPU
+
+
+
+ OpenSim.Storage.LocalStorageDb4o
+ JScript
+ Grid
+ IE50
+ false
+ Library
+
+ OpenSim.Storage.LocalStorageDb4o
+
+
+
+
+
+ False
+ 285212672
+ False
+
+
+ TRACE;DEBUG
+
+ True
+ 4096
+ False
+ ..\..\bin\
+ False
+ False
+ False
+ 4
+
+
+
+ False
+ 285212672
+ False
+
+
+ TRACE
+
+ False
+ 4096
+ True
+ ..\..\bin\
+ False
+ False
+ False
+ 4
+
+
+
+
+ System.dll
+ False
+
+
+ System.Xml.dll
+ False
+
+
+ ..\..\bin\Db4objects.Db4o.dll
+ False
+
+
+ ..\..\bin\libsecondlife.dll
+ False
+
+
+
+
+ OpenSim.Framework
+ {8ACA2445-0000-0000-0000-000000000000}
+ {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ False
+
+
+ OpenSim.Framework.Console
+ {A7CD0630-0000-0000-0000-000000000000}
+ {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ False
+
+
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+
+
+
+
+
+
+
+
--
cgit v1.1