From 73a36680bd5dacd4f2630c50115ef4c1f10dc387 Mon Sep 17 00:00:00 2001 From: mingchen Date: Wed, 6 Jun 2007 18:15:12 +0000 Subject: *Added new commands ('backup','show parcels','reset parcels') *Added parcel join support *Made parcel saving and loading much more efficient *Fixed bug that would not allow joining of parcel locally in the viewer (gives an error before sending to server) *Known Issue: Restoring parcels from storage is not working correctly. For now, do a 'reset parcels' to regenerate a standard parcel --- .../LocalStorageDb4o/Db4LocalStorage.cs | 88 +++++++++++++++------- .../OpenSim.Storage.LocalStorageDb4o.csproj | 42 ++++++----- .../LocalStorageDb4o/UUIDPrimQuery.cs | 52 +++++++++++++ .../OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs | 52 ------------- 4 files changed, 138 insertions(+), 96 deletions(-) create mode 100644 OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDPrimQuery.cs delete mode 100644 OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs (limited to 'OpenSim/OpenSim.Storage/LocalStorageDb4o') diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs b/OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs index 2fb3c90..d7b9f38 100644 --- a/OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs +++ b/OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs @@ -71,7 +71,7 @@ namespace OpenSim.Storage.LocalStorageDb4o public void StorePrim(PrimData prim) { - IObjectSet result = db.Query(new UUIDQuery(prim.FullID)); + IObjectSet result = db.Query(new UUIDPrimQuery(prim.FullID)); if(result.Count>0) { //prim already in storage @@ -112,7 +112,7 @@ namespace OpenSim.Storage.LocalStorageDb4o public void RemovePrim(LLUUID primID) { - IObjectSet result = db.Query(new UUIDQuery(primID)); + IObjectSet result = db.Query(new UUIDPrimQuery(primID)); if(result.Count>0) { PrimData found = (PrimData) result.Next(); @@ -133,7 +133,6 @@ namespace OpenSim.Storage.LocalStorageDb4o public float[] LoadWorld() { OpenSim.Framework.Console.MainConsole.Instance.Verbose("LoadWorld() - Loading world...."); - //World blank = new World(); float[] heightmap = null; OpenSim.Framework.Console.MainConsole.Instance.Verbose("LoadWorld() - Looking for a heightmap in local DB"); IObjectSet world_result = db.Get(typeof(MapStorage)); @@ -144,21 +143,6 @@ namespace OpenSim.Storage.LocalStorageDb4o //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); - heightmap = new float[256, 256]; - 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; } @@ -177,27 +161,77 @@ namespace OpenSim.Storage.LocalStorageDb4o db.Commit(); } - public void SaveParcels(ParcelData[] parcel_data) + public void SaveParcel(ParcelData parcel) { - MainConsole.Instance.Notice("Parcel Backup: Saving Parcels..."); - IObjectSet result = db.Get(typeof(ParcelData)); - foreach (ParcelData parcel in result) + IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID)); + if (result.Count > 0) + { + //Old Parcel + ParcelData updateParcel = (ParcelData)result.Next(); + updateParcel.AABBMax = parcel.AABBMax; + updateParcel.AABBMin = parcel.AABBMin; + updateParcel.area = parcel.area; + updateParcel.auctionID = parcel.auctionID; + updateParcel.authBuyerID = parcel.authBuyerID; + updateParcel.category = parcel.category; + updateParcel.claimDate = parcel.claimDate; + updateParcel.claimPrice = parcel.claimPrice; + updateParcel.groupID = parcel.groupID; + updateParcel.groupPrims = parcel.groupPrims; + updateParcel.isGroupOwned = parcel.isGroupOwned; + updateParcel.localID = parcel.localID; + updateParcel.ownerID = parcel.ownerID; + updateParcel.parcelBitmapByteArray = (byte[])parcel.parcelBitmapByteArray.Clone(); + updateParcel.parcelDesc = parcel.parcelDesc; + updateParcel.parcelFlags = parcel.parcelFlags; + updateParcel.parcelName = parcel.parcelName; + updateParcel.parcelStatus = parcel.parcelStatus; + updateParcel.salePrice = parcel.salePrice; + + db.Set(updateParcel); + } + else { - db.Delete(parcel); + db.Set(parcel); } - MainConsole.Instance.Notice("Parcel Backup: Removing old entries complete. Adding new entries."); + db.Commit(); + } + + public void SaveParcels(ParcelData[] parcel_data) + { + MainConsole.Instance.Notice("Parcel Backup: Saving Parcels..."); int i; for (i = 0; i < parcel_data.GetLength(0); i++) { - MainConsole.Instance.Notice("Adding : " + i + " - SAMPLE: " + parcel_data[i].parcelBitmapByteArray[0]); - db.Set(parcel_data[i]); + SaveParcel(parcel_data[i]); } - db.Commit(); MainConsole.Instance.Notice("Parcel Backup: Parcel Save Complete"); } + public void RemoveParcel(ParcelData parcel) + { + IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID)); + if (result.Count > 0) + { + db.Delete(result[0]); + } + db.Commit(); + } + public void RemoveAllParcels() + { + MainConsole.Instance.Notice("Parcel Backup: Removing all parcels..."); + IObjectSet result = db.Get(typeof(ParcelData)); + if (result.Count > 0) + { + foreach (ParcelData parcelData in result) + { + RemoveParcel(parcelData); + } + } + } + public void LoadParcels(ILocalStorageParcelReceiver recv) { MainConsole.Instance.Notice("Parcel Backup: Loading Parcels..."); diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj b/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj index 9b4ff5d..231ba1d 100644 --- a/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj +++ b/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj @@ -1,4 +1,4 @@ - + Local 8.0.50727 @@ -6,7 +6,8 @@ {E1B79ECF-0000-0000-0000-000000000000} Debug AnyCPU - + + OpenSim.Storage.LocalStorageDb4o @@ -15,9 +16,11 @@ IE50 false Library - + + OpenSim.Storage.LocalStorageDb4o - + + @@ -28,7 +31,8 @@ TRACE;DEBUG - + + True 4096 False @@ -37,7 +41,8 @@ False False 4 - + + False @@ -46,7 +51,8 @@ TRACE - + + False 4096 True @@ -55,22 +61,23 @@ False False 4 - + + - + System.dll False - + System.Xml.dll False - + ..\..\..\bin\Db4objects.Db4o.dll False - + ..\..\..\bin\libsecondlife.dll False @@ -80,26 +87,27 @@ OpenSim.Framework {8ACA2445-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Framework.Console {A7CD0630-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False Code - + + Code Code - + Code @@ -110,4 +118,4 @@ - + \ No newline at end of file diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDPrimQuery.cs b/OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDPrimQuery.cs new file mode 100644 index 0000000..b2e8a91 --- /dev/null +++ b/OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDPrimQuery.cs @@ -0,0 +1,52 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* 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 OpenSim Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Text; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; + +namespace OpenSim.Storage.LocalStorageDb4o +{ + public class UUIDPrimQuery : Predicate + { + private LLUUID _findID; + + public UUIDPrimQuery(LLUUID find) + { + _findID = find; + } + public bool Match(PrimData prim) + { + return (prim.FullID == _findID); + } + } +} diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs b/OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs deleted file mode 100644 index 4c0be60..0000000 --- a/OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* 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 OpenSim Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Text; -using Db4objects.Db4o; -using Db4objects.Db4o.Query; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; - -namespace OpenSim.Storage.LocalStorageDb4o -{ - public class UUIDQuery : Predicate - { - private LLUUID _findID; - - public UUIDQuery(LLUUID find) - { - _findID = find; - } - public bool Match(PrimData prim) - { - return (prim.FullID == _findID); - } - } -} -- cgit v1.1