diff --git a/src/Config/SimConfig/Db4SimConfig.cs b/src/Config/SimConfig/Db4SimConfig.cs
index cc31328218..4a0618704d 100644
--- a/src/Config/SimConfig/Db4SimConfig.cs
+++ b/src/Config/SimConfig/Db4SimConfig.cs
@@ -111,16 +111,19 @@ namespace Db40SimConfig
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Loading world....");
World blank = new World();
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB");
- IObjectSet world_result = db.Get(new float[65536]);
+ IObjectSet world_result = db.Get(typeof(MapStorage));
if(world_result.Count>0) {
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading");
- blank.LandMap=(float[])world_result.Next();
+ MapStorage map=(MapStorage)world_result.Next();
+ blank.LandMap = map.Map;
} else {
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one");
HeightmapGenHills hills = new HeightmapGenHills();
blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database");
- db.Set(blank.LandMap);
+ MapStorage map= new MapStorage();
+ map.Map = blank.LandMap;
+ db.Set(map);
db.Commit();
}
return blank;
@@ -143,4 +146,14 @@ namespace Db40SimConfig
db.Close();
}
}
+
+ public class MapStorage
+ {
+ public float[] Map;
+
+ public MapStorage()
+ {
+
+ }
+ }
}
diff --git a/src/Config/SimConfig/SimConfig.csproj b/src/Config/SimConfig/SimConfig.csproj
index 08f0f24bc7..3131405970 100644
--- a/src/Config/SimConfig/SimConfig.csproj
+++ b/src/Config/SimConfig/SimConfig.csproj
@@ -44,6 +44,10 @@
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}
Second-server
+
+ {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}
+ GridInterfaces
+
\ No newline at end of file
diff --git a/src/GridInterfaces/GridInterfaces.csproj b/src/GridInterfaces/GridInterfaces.csproj
index 3284e7f29b..bbdc9e9692 100644
--- a/src/GridInterfaces/GridInterfaces.csproj
+++ b/src/GridInterfaces/GridInterfaces.csproj
@@ -35,6 +35,7 @@
+
\ No newline at end of file
diff --git a/src/GridInterfaces/ILocalStorage.cs b/src/GridInterfaces/ILocalStorage.cs
new file mode 100644
index 0000000000..5d6b9b1c99
--- /dev/null
+++ b/src/GridInterfaces/ILocalStorage.cs
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
+*
+* 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 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 ``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 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 libsecondlife;
+
+namespace GridInterfaces
+{
+ ///
+ /// ILocalStorage. Really hacked together right now needs cleaning up
+ ///
+ public interface ILocalStorage
+ {
+ void StorePrim(PrimStorage prim);
+ void RemovePrim(LLUUID primID);
+ void LoadPrimitives(ILocalStorageReceiver receiver);
+ void ShutDown();
+ }
+
+ public interface ILocalStorageReceiver
+ {
+ void PrimFromStorage(PrimStorage prim);
+ }
+
+ public class PrimStorage
+ {
+ public PrimData Data;
+ public LLVector3 Position;
+ public LLQuaternion Rotation;
+ public uint LocalID;
+ public LLUUID FullID;
+
+ public PrimStorage()
+ {
+
+ }
+
+ }
+ public class PrimData
+ {
+ public LLUUID OwnerID;
+ public byte PCode;
+ public byte PathBegin;
+ public byte PathEnd;
+ public byte PathScaleX;
+ public byte PathScaleY;
+ public byte PathShearX;
+ public byte PathShearY;
+ public sbyte PathSkew;
+ public byte ProfileBegin;
+ public byte ProfileEnd;
+ public LLVector3 Scale;
+ public byte PathCurve;
+ public byte ProfileCurve;
+ public uint ParentID=0;
+ public byte ProfileHollow;
+
+ public PrimData()
+ {
+
+ }
+ }
+}
diff --git a/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs b/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs
new file mode 100644
index 0000000000..66106068df
--- /dev/null
+++ b/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs
@@ -0,0 +1,31 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("Db4LocalStorage")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Db4LocalStorage")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.*")]
diff --git a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs
new file mode 100644
index 0000000000..9dc81a1504
--- /dev/null
+++ b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
+*
+* 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 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 ``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 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 Db4objects.Db4o;
+using Db4objects.Db4o.Query;
+using libsecondlife;
+using GridInterfaces;
+
+namespace Db4LocalStorage
+{
+ ///
+ ///
+ ///
+ public class Db4LocalStorage : ILocalStorage
+ {
+ private IObjectContainer db;
+
+ public Db4LocalStorage()
+ {
+ try
+ {
+ db = Db4oFactory.OpenFile("localworld.yap");
+ ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage creation");
+ }
+ catch(Exception e)
+ {
+ db.Close();
+ ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage :Constructor - Exception occured");
+ ServerConsole.MainConsole.Instance.WriteLine(e.ToString());
+ }
+ }
+
+ public void StorePrim(PrimStorage prim)
+ {
+ IObjectSet result = db.Query(new UUIDQuery(prim.FullID));
+ if(result.Count>0)
+ {
+ //prim already in storage
+ //so update it
+ PrimStorage found = (PrimStorage) result.Next();
+ found.Data = prim.Data;
+ found.Position = prim.Position;
+ found.Rotation = prim.Rotation;
+ db.Set(found);
+ }
+ else
+ {
+ //not in storage
+ db.Set(prim);
+ }
+ }
+
+ public void RemovePrim(LLUUID primID)
+ {
+ IObjectSet result = db.Query(new UUIDQuery(primID));
+ if(result.Count>0)
+ {
+ PrimStorage found = (PrimStorage) result.Next();
+ db.Delete(found);
+ }
+ }
+
+
+ public void LoadPrimitives(ILocalStorageReceiver receiver)
+ {
+ IObjectSet result = db.Get(typeof(PrimStorage));
+ ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is "+result.Count);
+ foreach (PrimStorage prim in result) {
+ receiver.PrimFromStorage(prim);
+ }
+ }
+
+ public void ShutDown()
+ {
+ db.Commit();
+ db.Close();
+ }
+ }
+
+ public class UUIDQuery : Predicate
+ {
+ private LLUUID _findID;
+
+ public UUIDQuery(LLUUID find)
+ {
+ _findID = find;
+ }
+ public bool Match(PrimStorage prim)
+ {
+ return (prim.FullID == _findID);
+ }
+ }
+
+}
diff --git a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj
new file mode 100644
index 0000000000..9b5c48789d
--- /dev/null
+++ b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj
@@ -0,0 +1,53 @@
+
+
+ Library
+ Db4LocalStorage
+ Db4LocalStorage
+ Debug
+ AnyCPU
+ {74784F23-B0FD-484C-82C1-96C0215733DC}
+
+
+ bin\Debug\
+ False
+ DEBUG;TRACE
+ True
+ Full
+ True
+
+
+ bin\Release\
+ True
+ TRACE
+ False
+ None
+ False
+
+
+
+
+
+ ..\..\..\bin\Db4objects.Db4o.dll
+ False
+
+
+ ..\..\..\..\..\..\..\Libsecond-dailys\libsl07-03\trunk\libsecondlife-cs\obj\Debug\libsecondlife.dll
+ False
+
+
+
+
+
+
+
+
+ {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}
+ GridInterfaces
+
+
+ {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}
+ ServerConsole
+
+
+
+
\ No newline at end of file
diff --git a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.sln b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.sln
new file mode 100644
index 0000000000..89e471054a
--- /dev/null
+++ b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.sln
@@ -0,0 +1,7 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# SharpDevelop 2.1.0.2017
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4LocalStorage", "Db4LocalStorage.csproj", "{74784F23-B0FD-484C-82C1-96C0215733DC}"
+EndProject
+Global
+EndGlobal
diff --git a/src/Main.cs b/src/Main.cs
index 4fc7d54d32..600ce3815e 100644
--- a/src/Main.cs
+++ b/src/Main.cs
@@ -150,9 +150,13 @@ namespace OpenSim
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting up messaging system");
local_world.PhysScene = this.physManager.GetPhysicsScene("PhysX"); //should be reading from the config file what physics engine to use
local_world.PhysScene.SetTerrain(local_world.LandMap);
+
OpenSim_Main.gridServers.AssetServer.SetServerInfo(OpenSim_Main.cfg.AssetURL, OpenSim_Main.cfg.AssetSendKey);
OpenSim_Main.gridServers.GridServer.SetServerInfo(OpenSim_Main.cfg.GridURL, OpenSim_Main.cfg.GridSendKey);
+ local_world.LoadStorageDLL("Db4LocalStorage.dll"); //all these dll names shouldn't be hard coded.
+ local_world.LoadPrimsFromStorage();
+
MainServerListener();
}
@@ -230,6 +234,7 @@ namespace OpenSim
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing clients");
// IMPLEMENT THIS
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing console and terminating");
+ OpenSim_Main.local_world.Close();
ServerConsole.MainConsole.Instance.Close();
Environment.Exit(0);
}
diff --git a/src/OpenSimClient.cs b/src/OpenSimClient.cs
index 9544e7b359..1f9c70cd03 100644
--- a/src/OpenSimClient.cs
+++ b/src/OpenSimClient.cs
@@ -99,6 +99,7 @@ namespace OpenSim
client.ClientAvatar.SendAppearanceToOtherAgent(this);
}
}
+ OpenSim_Main.local_world.GetInitialPrims(this);
break;
case PacketType.ObjectAdd:
OpenSim_Main.local_world.AddNewPrim((ObjectAddPacket)Pack, this);
diff --git a/src/OpenSimConsole.cs b/src/OpenSimConsole.cs
index 7d8563f597..80f36afbc9 100644
--- a/src/OpenSimConsole.cs
+++ b/src/OpenSimConsole.cs
@@ -169,8 +169,11 @@ namespace OpenSim
OpenSim.world.Avatar TempAv;
this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP"));
foreach (libsecondlife.LLUUID UUID in OpenSim_Main.local_world.Entities.Keys) {
- TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID];
- this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}",TempAv.firstname, TempAv.lastname,UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()));
+ if(OpenSim_Main.local_world.Entities[UUID].ToString()== "OpenSim.world.Avatar")
+ {
+ TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID];
+ this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}",TempAv.firstname, TempAv.lastname,UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()));
+ }
}
break;
}
diff --git a/src/RemoteServers/RemoteGridServers/RemoteGrid.cs b/src/RemoteServers/RemoteGridServers/RemoteGrid.cs
index f7c33e82d4..428d5f551b 100644
--- a/src/RemoteServers/RemoteGridServers/RemoteGrid.cs
+++ b/src/RemoteServers/RemoteGridServers/RemoteGrid.cs
@@ -111,7 +111,7 @@ namespace RemoteGridServers
public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
- WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + circuitCode.ToString() + "/delete");
+ WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + "/" + circuitCode.ToString() + "/delete");
WebResponse GridResponse = DeleteSession.GetResponse();
StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
String grTest = sr.ReadLine();
diff --git a/src/Second-server.sln b/src/Second-server.sln
index 96755ee15c..a460b2a8c6 100644
--- a/src/Second-server.sln
+++ b/src/Second-server.sln
@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysXplugin", "physics\plug
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerConsole", "ServerConsole\ServerConsole\ServerConsole.csproj", "{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4LocalStorage", "LocalStorage\Db4LocalStorage\Db4LocalStorage.csproj", "{74784F23-B0FD-484C-82C1-96C0215733DC}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET 1.1 = Debug|.NET 1.1
@@ -89,6 +91,14 @@ Global
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.Build.0 = Release|Any CPU
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1
+ {74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1
+ {74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {74784F23-B0FD-484C-82C1-96C0215733DC}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
+ {74784F23-B0FD-484C-82C1-96C0215733DC}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1
+ {74784F23-B0FD-484C-82C1-96C0215733DC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {74784F23-B0FD-484C-82C1-96C0215733DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/world/Entity.cs b/src/world/Entity.cs
index 147478b2b7..ee4b2e4826 100644
--- a/src/world/Entity.cs
+++ b/src/world/Entity.cs
@@ -58,5 +58,10 @@ namespace OpenSim.world
return mesh;
}
+
+ public virtual void BackUp()
+ {
+
+ }
}
}
diff --git a/src/world/Primitive.cs b/src/world/Primitive.cs
index 1fb7142194..6029f765bb 100644
--- a/src/world/Primitive.cs
+++ b/src/world/Primitive.cs
@@ -4,6 +4,7 @@ using System.Text;
using OpenSim.types;
using libsecondlife;
using libsecondlife.Packets;
+using GridInterfaces;
namespace OpenSim.world
{
@@ -15,7 +16,7 @@ namespace OpenSim.world
protected bool newPrimFlag;
protected bool updateFlag;
protected ObjectUpdatePacket OurPacket;
-
+
public bool UpdateFlag
{
get
@@ -69,6 +70,14 @@ namespace OpenSim.world
}
this.updateFlag = false;
}
+
+ }
+
+ public void UpdateClient(OpenSimClient RemoteClient)
+ {
+ byte[] pb = this.position.GetBytes();
+ Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length);
+ RemoteClient.OutPacket(OurPacket);
}
public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID)
@@ -118,8 +127,7 @@ namespace OpenSim.world
//finish off copying rest of shape data
objupdate.ObjectData[0].ID = (uint)(localID);
- objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efefda" + (localID- 702000).ToString("000"));
-
+ objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID- 702000).ToString("00000"));
objupdate.ObjectData[0].ObjectData = new byte[60];
objupdate.ObjectData[0].ObjectData[46] = 128;
objupdate.ObjectData[0].ObjectData[47] = 63;
@@ -135,6 +143,67 @@ namespace OpenSim.world
this.OurPacket = objupdate;
}
+ public void CreateFromStorage(PrimStorage store)
+ {
+ //need to clean this up as it shares a lot of code with CreateFromPacket()
+ ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
+ objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
+ objupdate.RegionData.TimeDilation = 64096;
+ objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
+
+ this.primData = store.Data;
+ objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
+ objupdate.ObjectData[0].PSBlock = new byte[0];
+ objupdate.ObjectData[0].ExtraParams = new byte[1];
+ objupdate.ObjectData[0].MediaURL = new byte[0];
+ objupdate.ObjectData[0].NameValue = new byte[0];
+ objupdate.ObjectData[0].PSBlock = new byte[0];
+ objupdate.ObjectData[0].Text = new byte[0];
+ objupdate.ObjectData[0].TextColor = new byte[4];
+ objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0);
+ objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0);
+ objupdate.ObjectData[0].Material = 3;
+ objupdate.ObjectData[0].UpdateFlags=32+65536+131072+256+4+8+2048+524288+268435456;
+ objupdate.ObjectData[0].TextureAnim = new byte[0];
+ objupdate.ObjectData[0].Sound = LLUUID.Zero;
+ LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
+ objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
+ objupdate.ObjectData[0].State = 0;
+ objupdate.ObjectData[0].Data = new byte[0];
+ objupdate.ObjectData[0].OwnerID = this.primData.OwnerID;
+ objupdate.ObjectData[0].PCode = this.primData.PCode;
+ objupdate.ObjectData[0].PathBegin = this.primData.PathBegin;
+ objupdate.ObjectData[0].PathEnd = this.primData.PathEnd;
+ objupdate.ObjectData[0].PathScaleX = this.primData.PathScaleX;
+ objupdate.ObjectData[0].PathScaleY = this.primData.PathScaleY;
+ objupdate.ObjectData[0].PathShearX = this.primData.PathShearX;
+ objupdate.ObjectData[0].PathShearY = this.primData.PathShearY;
+ objupdate.ObjectData[0].PathSkew = this.primData.PathSkew;
+ objupdate.ObjectData[0].ProfileBegin = this.primData.ProfileBegin;
+ objupdate.ObjectData[0].ProfileEnd = this.primData.ProfileEnd;
+ objupdate.ObjectData[0].Scale = this.primData.Scale;
+ objupdate.ObjectData[0].PathCurve = this.primData.PathCurve;
+ objupdate.ObjectData[0].ProfileCurve = this.primData.ProfileCurve;
+ objupdate.ObjectData[0].ParentID = 0;
+ objupdate.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
+ //finish off copying rest of shape data
+
+ objupdate.ObjectData[0].ID = (uint)store.LocalID;
+ objupdate.ObjectData[0].FullID = store.FullID;
+
+ objupdate.ObjectData[0].ObjectData = new byte[60];
+ objupdate.ObjectData[0].ObjectData[46] = 128;
+ objupdate.ObjectData[0].ObjectData[47] = 63;
+ LLVector3 pos1= store.Position;
+ //update position
+ byte[] pb = pos1.GetBytes();
+ Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
+
+ this.uuid = objupdate.ObjectData[0].FullID;
+ this.localid = objupdate.ObjectData[0].ID;
+ this.position = pos1;
+ this.OurPacket = objupdate;
+ }
public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock()
{
uint ID = this.localid;
@@ -200,30 +269,17 @@ namespace OpenSim.world
dat.Data=bytes;
return dat;
}
+
+ public override void BackUp()
+ {
+ PrimStorage pStore = new PrimStorage();
+ pStore.Data = this.primData;
+ pStore.FullID = this.uuid;
+ pStore.LocalID = this.localid;
+ pStore.Position = this.position;
+ pStore.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z , this.rotation.w);
+ OpenSim_Main.local_world.localStorage.StorePrim(pStore);
+ }
}
- public class PrimData
- {
- public LLUUID OwnerID;
- public byte PCode;
- public byte PathBegin;
- public byte PathEnd;
- public byte PathScaleX;
- public byte PathScaleY;
- public byte PathShearX;
- public byte PathShearY;
- public sbyte PathSkew;
- public byte ProfileBegin;
- public byte ProfileEnd;
- public LLVector3 Scale;
- public byte PathCurve;
- public byte ProfileCurve;
- public uint ParentID=0;
- public byte ProfileHollow;
-
- public PrimData()
- {
-
- }
- }
}
diff --git a/src/world/World.cs b/src/world/World.cs
index f6f58c7130..6be9dd2bb6 100644
--- a/src/world/World.cs
+++ b/src/world/World.cs
@@ -3,12 +3,14 @@ using libsecondlife;
using libsecondlife.Packets;
using System.Collections.Generic;
using System.Text;
+using System.Reflection;
using System.IO;
using PhysicsSystem;
+using GridInterfaces;
namespace OpenSim.world
{
- public class World
+ public class World : ILocalStorageReceiver
{
public Dictionary Entities;
public float[] LandMap;
@@ -17,9 +19,10 @@ namespace OpenSim.world
private PhysicsScene phyScene;
private float timeStep= 0.1f;
private libsecondlife.TerrainManager TerrainManager;
-
+ public ILocalStorage localStorage;
private Random Rand = new Random();
private uint _primCount = 702000;
+ private int storageCount;
public World()
{
@@ -48,8 +51,7 @@ namespace OpenSim.world
public void Update()
{
-
- if(this.phyScene.IsThreaded)
+ if(this.phyScene.IsThreaded)
{
this.phyScene.GetResults();
@@ -66,24 +68,95 @@ namespace OpenSim.world
{
Entities[UUID].update();
}
+
+ //backup world data
+ this.storageCount++;
+ if(storageCount> 1200) //set to how often you want to backup (currently set for about every 2 minutes)
+ {
+ this.Backup();
+ storageCount =0;
+ }
}
+ public bool LoadStorageDLL(string dllName)
+ {
+ Assembly pluginAssembly = Assembly.LoadFrom(dllName);
+ ILocalStorage store = null;
+
+ foreach (Type pluginType in pluginAssembly.GetTypes())
+ {
+ if (pluginType.IsPublic)
+ {
+ if (!pluginType.IsAbstract)
+ {
+ Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
+
+ if (typeInterface != null)
+ {
+ ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
+ store = plug;
+ break;
+ }
+
+ typeInterface = null;
+ }
+ }
+ }
+ pluginAssembly = null;
+ this.localStorage = store;
+ return(store == null);
+ }
+
+ public void LoadPrimsFromStorage()
+ {
+ ServerConsole.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives");
+ this.localStorage.LoadPrimitives(this);
+ }
+
+ public void PrimFromStorage(PrimStorage prim)
+ {
+ if(prim.LocalID >= this._primCount)
+ {
+ _primCount = prim.LocalID + 1;
+ }
+ ServerConsole.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId "+ prim.LocalID+ " ) from storage");
+ Primitive nPrim = new Primitive();
+ nPrim.CreateFromStorage(prim);
+ this.Entities.Add(nPrim.uuid, nPrim);
+ }
+
+ public void Close()
+ {
+ this.localStorage.ShutDown();
+ }
+
public void SendLayerData(OpenSimClient RemoteClient) {
int[] patches = new int[4];
- for (int y = 0; y < 16; y++)
- {
- for (int x = 0; x < 16; x = x + 4)
- {
- patches[0] = x + 0 + y * 16;
- patches[1] = x + 1 + y * 16;
- patches[2] = x + 2 + y * 16;
- patches[3] = x + 3 + y * 16;
+ for (int y = 0; y < 16; y++)
+ {
+ for (int x = 0; x < 16; x = x + 4)
+ {
+ patches[0] = x + 0 + y * 16;
+ patches[1] = x + 1 + y * 16;
+ patches[2] = x + 2 + y * 16;
+ patches[3] = x + 3 + y * 16;
- Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches);
- RemoteClient.OutPacket(layerpack);
- }
- }
+ Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches);
+ RemoteClient.OutPacket(layerpack);
+ }
+ }
+ }
+
+ public void GetInitialPrims(OpenSimClient RemoteClient)
+ {
+ foreach (libsecondlife.LLUUID UUID in Entities.Keys)
+ {
+ if(Entities[UUID].ToString()== "OpenSim.world.Primitive")
+ {
+ ((OpenSim.world.Primitive)Entities[UUID]).UpdateClient(RemoteClient);
+ }
+ }
}
public void AddViewerAgent(OpenSimClient AgentClient) {
@@ -96,7 +169,7 @@ namespace OpenSim.world
NewAvatar.PhysActor = this.phyScene.AddAvatar(new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z));
//this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user
this.Entities.Add(AgentClient.AgentID, NewAvatar);
- }
+ }
public void AddNewPrim(ObjectAddPacket addPacket, OpenSimClient AgentClient)
{
@@ -109,8 +182,12 @@ namespace OpenSim.world
public bool Backup() {
/* TODO: Save the current world entities state. */
-
- return false;
+ ServerConsole.MainConsole.Instance.WriteLine("World.cs: Backup() - Backing up Primitives");
+ foreach (libsecondlife.LLUUID UUID in Entities.Keys)
+ {
+ Entities[UUID].BackUp();
+ }
+ return true;
}
}