diff options
author | MW | 2007-03-08 13:21:24 +0000 |
---|---|---|
committer | MW | 2007-03-08 13:21:24 +0000 |
commit | f60bc970eb925cd245cc77b1ae700b28d4589163 (patch) | |
tree | d279883582f00232bad87bf17e5727ff263027a4 | |
parent | Brought OGS.sql back into trunk (diff) | |
download | opensim-SC-f60bc970eb925cd245cc77b1ae700b28d4589163.zip opensim-SC-f60bc970eb925cd245cc77b1ae700b28d4589163.tar.gz opensim-SC-f60bc970eb925cd245cc77b1ae700b28d4589163.tar.bz2 opensim-SC-f60bc970eb925cd245cc77b1ae700b28d4589163.tar.xz |
Another attemp to fix the Session Logout bug
World map data is now saved in database and recovered on startup.
Primitives are now backed up to a local database and reloaded on startup.
-rw-r--r-- | src/Config/SimConfig/Db4SimConfig.cs | 19 | ||||
-rw-r--r-- | src/Config/SimConfig/SimConfig.csproj | 4 | ||||
-rw-r--r-- | src/GridInterfaces/GridInterfaces.csproj | 1 | ||||
-rw-r--r-- | src/GridInterfaces/ILocalStorage.cs | 87 | ||||
-rw-r--r-- | src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs | 31 | ||||
-rw-r--r-- | src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs | 119 | ||||
-rw-r--r-- | src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj | 53 | ||||
-rw-r--r-- | src/LocalStorage/Db4LocalStorage/Db4LocalStorage.sln | 7 | ||||
-rw-r--r-- | src/Main.cs | 5 | ||||
-rw-r--r-- | src/OpenSimClient.cs | 1 | ||||
-rw-r--r-- | src/OpenSimConsole.cs | 7 | ||||
-rw-r--r-- | src/RemoteServers/RemoteGridServers/RemoteGrid.cs | 2 | ||||
-rw-r--r-- | src/Second-server.sln | 10 | ||||
-rw-r--r-- | src/world/Entity.cs | 5 | ||||
-rw-r--r-- | src/world/Primitive.cs | 110 | ||||
-rw-r--r-- | src/world/World.cs | 115 |
16 files changed, 524 insertions, 52 deletions
diff --git a/src/Config/SimConfig/Db4SimConfig.cs b/src/Config/SimConfig/Db4SimConfig.cs index cc31328..4a06187 100644 --- a/src/Config/SimConfig/Db4SimConfig.cs +++ b/src/Config/SimConfig/Db4SimConfig.cs | |||
@@ -111,16 +111,19 @@ namespace Db40SimConfig | |||
111 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Loading world...."); | 111 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Loading world...."); |
112 | World blank = new World(); | 112 | World blank = new World(); |
113 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB"); | 113 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB"); |
114 | IObjectSet world_result = db.Get(new float[65536]); | 114 | IObjectSet world_result = db.Get(typeof(MapStorage)); |
115 | if(world_result.Count>0) { | 115 | if(world_result.Count>0) { |
116 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading"); | 116 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading"); |
117 | blank.LandMap=(float[])world_result.Next(); | 117 | MapStorage map=(MapStorage)world_result.Next(); |
118 | blank.LandMap = map.Map; | ||
118 | } else { | 119 | } else { |
119 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one"); | 120 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one"); |
120 | HeightmapGenHills hills = new HeightmapGenHills(); | 121 | HeightmapGenHills hills = new HeightmapGenHills(); |
121 | blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); | 122 | blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); |
122 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database"); | 123 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database"); |
123 | db.Set(blank.LandMap); | 124 | MapStorage map= new MapStorage(); |
125 | map.Map = blank.LandMap; | ||
126 | db.Set(map); | ||
124 | db.Commit(); | 127 | db.Commit(); |
125 | } | 128 | } |
126 | return blank; | 129 | return blank; |
@@ -143,4 +146,14 @@ namespace Db40SimConfig | |||
143 | db.Close(); | 146 | db.Close(); |
144 | } | 147 | } |
145 | } | 148 | } |
149 | |||
150 | public class MapStorage | ||
151 | { | ||
152 | public float[] Map; | ||
153 | |||
154 | public MapStorage() | ||
155 | { | ||
156 | |||
157 | } | ||
158 | } | ||
146 | } | 159 | } |
diff --git a/src/Config/SimConfig/SimConfig.csproj b/src/Config/SimConfig/SimConfig.csproj index 08f0f24..3131405 100644 --- a/src/Config/SimConfig/SimConfig.csproj +++ b/src/Config/SimConfig/SimConfig.csproj | |||
@@ -44,6 +44,10 @@ | |||
44 | <Project>{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}</Project> | 44 | <Project>{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}</Project> |
45 | <Name>Second-server</Name> | 45 | <Name>Second-server</Name> |
46 | </ProjectReference> | 46 | </ProjectReference> |
47 | <ProjectReference Include="..\..\GridInterfaces\GridInterfaces.csproj"> | ||
48 | <Project>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</Project> | ||
49 | <Name>GridInterfaces</Name> | ||
50 | </ProjectReference> | ||
47 | </ItemGroup> | 51 | </ItemGroup> |
48 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | 52 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
49 | </Project> \ No newline at end of file | 53 | </Project> \ No newline at end of file |
diff --git a/src/GridInterfaces/GridInterfaces.csproj b/src/GridInterfaces/GridInterfaces.csproj index 3284e7f..bbdc9e9 100644 --- a/src/GridInterfaces/GridInterfaces.csproj +++ b/src/GridInterfaces/GridInterfaces.csproj | |||
@@ -35,6 +35,7 @@ | |||
35 | <Compile Include="IAssetServer.cs" /> | 35 | <Compile Include="IAssetServer.cs" /> |
36 | <Compile Include="AssemblyInfo.cs" /> | 36 | <Compile Include="AssemblyInfo.cs" /> |
37 | <Compile Include="IGridServer.cs" /> | 37 | <Compile Include="IGridServer.cs" /> |
38 | <Compile Include="ILocalStorage.cs" /> | ||
38 | </ItemGroup> | 39 | </ItemGroup> |
39 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | 40 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
40 | </Project> \ No newline at end of file | 41 | </Project> \ No newline at end of file |
diff --git a/src/GridInterfaces/ILocalStorage.cs b/src/GridInterfaces/ILocalStorage.cs new file mode 100644 index 0000000..5d6b9b1 --- /dev/null +++ b/src/GridInterfaces/ILocalStorage.cs | |||
@@ -0,0 +1,87 @@ | |||
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 | |||
28 | using System; | ||
29 | using libsecondlife; | ||
30 | |||
31 | namespace GridInterfaces | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// ILocalStorage. Really hacked together right now needs cleaning up | ||
35 | /// </summary> | ||
36 | public interface ILocalStorage | ||
37 | { | ||
38 | void StorePrim(PrimStorage prim); | ||
39 | void RemovePrim(LLUUID primID); | ||
40 | void LoadPrimitives(ILocalStorageReceiver receiver); | ||
41 | void ShutDown(); | ||
42 | } | ||
43 | |||
44 | public interface ILocalStorageReceiver | ||
45 | { | ||
46 | void PrimFromStorage(PrimStorage prim); | ||
47 | } | ||
48 | |||
49 | public class PrimStorage | ||
50 | { | ||
51 | public PrimData Data; | ||
52 | public LLVector3 Position; | ||
53 | public LLQuaternion Rotation; | ||
54 | public uint LocalID; | ||
55 | public LLUUID FullID; | ||
56 | |||
57 | public PrimStorage() | ||
58 | { | ||
59 | |||
60 | } | ||
61 | |||
62 | } | ||
63 | public class PrimData | ||
64 | { | ||
65 | public LLUUID OwnerID; | ||
66 | public byte PCode; | ||
67 | public byte PathBegin; | ||
68 | public byte PathEnd; | ||
69 | public byte PathScaleX; | ||
70 | public byte PathScaleY; | ||
71 | public byte PathShearX; | ||
72 | public byte PathShearY; | ||
73 | public sbyte PathSkew; | ||
74 | public byte ProfileBegin; | ||
75 | public byte ProfileEnd; | ||
76 | public LLVector3 Scale; | ||
77 | public byte PathCurve; | ||
78 | public byte ProfileCurve; | ||
79 | public uint ParentID=0; | ||
80 | public byte ProfileHollow; | ||
81 | |||
82 | public PrimData() | ||
83 | { | ||
84 | |||
85 | } | ||
86 | } | ||
87 | } | ||
diff --git a/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs b/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs new file mode 100644 index 0000000..6610606 --- /dev/null +++ b/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // Information about this assembly is defined by the following | ||
6 | // attributes. | ||
7 | // | ||
8 | // change them to the information which is associated with the assembly | ||
9 | // you compile. | ||
10 | |||
11 | [assembly: AssemblyTitle("Db4LocalStorage")] | ||
12 | [assembly: AssemblyDescription("")] | ||
13 | [assembly: AssemblyConfiguration("")] | ||
14 | [assembly: AssemblyCompany("")] | ||
15 | [assembly: AssemblyProduct("Db4LocalStorage")] | ||
16 | [assembly: AssemblyCopyright("")] | ||
17 | [assembly: AssemblyTrademark("")] | ||
18 | [assembly: AssemblyCulture("")] | ||
19 | |||
20 | // This sets the default COM visibility of types in the assembly to invisible. | ||
21 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. | ||
22 | [assembly: ComVisible(false)] | ||
23 | |||
24 | // The assembly version has following format : | ||
25 | // | ||
26 | // Major.Minor.Build.Revision | ||
27 | // | ||
28 | // You can specify all values by your own or you can build default build and revision | ||
29 | // numbers with the '*' character (the default): | ||
30 | |||
31 | [assembly: AssemblyVersion("1.0.*")] | ||
diff --git a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs new file mode 100644 index 0000000..9dc81a1 --- /dev/null +++ b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs | |||
@@ -0,0 +1,119 @@ | |||
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 Db4objects.Db4o; | ||
30 | using Db4objects.Db4o.Query; | ||
31 | using libsecondlife; | ||
32 | using GridInterfaces; | ||
33 | |||
34 | namespace Db4LocalStorage | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// | ||
38 | /// </summary> | ||
39 | public class Db4LocalStorage : ILocalStorage | ||
40 | { | ||
41 | private IObjectContainer db; | ||
42 | |||
43 | public Db4LocalStorage() | ||
44 | { | ||
45 | try | ||
46 | { | ||
47 | db = Db4oFactory.OpenFile("localworld.yap"); | ||
48 | ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage creation"); | ||
49 | } | ||
50 | catch(Exception e) | ||
51 | { | ||
52 | db.Close(); | ||
53 | ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage :Constructor - Exception occured"); | ||
54 | ServerConsole.MainConsole.Instance.WriteLine(e.ToString()); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | public void StorePrim(PrimStorage prim) | ||
59 | { | ||
60 | IObjectSet result = db.Query(new UUIDQuery(prim.FullID)); | ||
61 | if(result.Count>0) | ||
62 | { | ||
63 | //prim already in storage | ||
64 | //so update it | ||
65 | PrimStorage found = (PrimStorage) result.Next(); | ||
66 | found.Data = prim.Data; | ||
67 | found.Position = prim.Position; | ||
68 | found.Rotation = prim.Rotation; | ||
69 | db.Set(found); | ||
70 | } | ||
71 | else | ||
72 | { | ||
73 | //not in storage | ||
74 | db.Set(prim); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | public void RemovePrim(LLUUID primID) | ||
79 | { | ||
80 | IObjectSet result = db.Query(new UUIDQuery(primID)); | ||
81 | if(result.Count>0) | ||
82 | { | ||
83 | PrimStorage found = (PrimStorage) result.Next(); | ||
84 | db.Delete(found); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | |||
89 | public void LoadPrimitives(ILocalStorageReceiver receiver) | ||
90 | { | ||
91 | IObjectSet result = db.Get(typeof(PrimStorage)); | ||
92 | ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is "+result.Count); | ||
93 | foreach (PrimStorage prim in result) { | ||
94 | receiver.PrimFromStorage(prim); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public void ShutDown() | ||
99 | { | ||
100 | db.Commit(); | ||
101 | db.Close(); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | public class UUIDQuery : Predicate | ||
106 | { | ||
107 | private LLUUID _findID; | ||
108 | |||
109 | public UUIDQuery(LLUUID find) | ||
110 | { | ||
111 | _findID = find; | ||
112 | } | ||
113 | public bool Match(PrimStorage prim) | ||
114 | { | ||
115 | return (prim.FullID == _findID); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | } | ||
diff --git a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj new file mode 100644 index 0000000..9b5c487 --- /dev/null +++ b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj | |||
@@ -0,0 +1,53 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <OutputType>Library</OutputType> | ||
4 | <RootNamespace>Db4LocalStorage</RootNamespace> | ||
5 | <AssemblyName>Db4LocalStorage</AssemblyName> | ||
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
8 | <ProjectGuid>{74784F23-B0FD-484C-82C1-96C0215733DC}</ProjectGuid> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
11 | <OutputPath>bin\Debug\</OutputPath> | ||
12 | <Optimize>False</Optimize> | ||
13 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
14 | <DebugSymbols>True</DebugSymbols> | ||
15 | <DebugType>Full</DebugType> | ||
16 | <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | ||
17 | </PropertyGroup> | ||
18 | <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
19 | <OutputPath>bin\Release\</OutputPath> | ||
20 | <Optimize>True</Optimize> | ||
21 | <DefineConstants>TRACE</DefineConstants> | ||
22 | <DebugSymbols>False</DebugSymbols> | ||
23 | <DebugType>None</DebugType> | ||
24 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
25 | </PropertyGroup> | ||
26 | <ItemGroup> | ||
27 | <Reference Include="System" /> | ||
28 | <Reference Include="System.Xml" /> | ||
29 | <Reference Include="Db4objects.Db4o"> | ||
30 | <HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath> | ||
31 | <SpecificVersion>False</SpecificVersion> | ||
32 | </Reference> | ||
33 | <Reference Include="libsecondlife"> | ||
34 | <HintPath>..\..\..\..\..\..\..\Libsecond-dailys\libsl07-03\trunk\libsecondlife-cs\obj\Debug\libsecondlife.dll</HintPath> | ||
35 | <SpecificVersion>False</SpecificVersion> | ||
36 | </Reference> | ||
37 | </ItemGroup> | ||
38 | <ItemGroup> | ||
39 | <Compile Include="Db4LocalStorage.cs" /> | ||
40 | <Compile Include="AssemblyInfo.cs" /> | ||
41 | </ItemGroup> | ||
42 | <ItemGroup> | ||
43 | <ProjectReference Include="..\..\GridInterfaces\GridInterfaces.csproj"> | ||
44 | <Project>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</Project> | ||
45 | <Name>GridInterfaces</Name> | ||
46 | </ProjectReference> | ||
47 | <ProjectReference Include="..\..\ServerConsole\ServerConsole\ServerConsole.csproj"> | ||
48 | <Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project> | ||
49 | <Name>ServerConsole</Name> | ||
50 | </ProjectReference> | ||
51 | </ItemGroup> | ||
52 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
53 | </Project> \ 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 0000000..89e4710 --- /dev/null +++ b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.sln | |||
@@ -0,0 +1,7 @@ | |||
1 |  | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # SharpDevelop 2.1.0.2017 | ||
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4LocalStorage", "Db4LocalStorage.csproj", "{74784F23-B0FD-484C-82C1-96C0215733DC}" | ||
5 | EndProject | ||
6 | Global | ||
7 | EndGlobal | ||
diff --git a/src/Main.cs b/src/Main.cs index 4fc7d54..600ce38 100644 --- a/src/Main.cs +++ b/src/Main.cs | |||
@@ -150,9 +150,13 @@ namespace OpenSim | |||
150 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting up messaging system"); | 150 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting up messaging system"); |
151 | local_world.PhysScene = this.physManager.GetPhysicsScene("PhysX"); //should be reading from the config file what physics engine to use | 151 | local_world.PhysScene = this.physManager.GetPhysicsScene("PhysX"); //should be reading from the config file what physics engine to use |
152 | local_world.PhysScene.SetTerrain(local_world.LandMap); | 152 | local_world.PhysScene.SetTerrain(local_world.LandMap); |
153 | |||
153 | OpenSim_Main.gridServers.AssetServer.SetServerInfo(OpenSim_Main.cfg.AssetURL, OpenSim_Main.cfg.AssetSendKey); | 154 | OpenSim_Main.gridServers.AssetServer.SetServerInfo(OpenSim_Main.cfg.AssetURL, OpenSim_Main.cfg.AssetSendKey); |
154 | OpenSim_Main.gridServers.GridServer.SetServerInfo(OpenSim_Main.cfg.GridURL, OpenSim_Main.cfg.GridSendKey); | 155 | OpenSim_Main.gridServers.GridServer.SetServerInfo(OpenSim_Main.cfg.GridURL, OpenSim_Main.cfg.GridSendKey); |
155 | 156 | ||
157 | local_world.LoadStorageDLL("Db4LocalStorage.dll"); //all these dll names shouldn't be hard coded. | ||
158 | local_world.LoadPrimsFromStorage(); | ||
159 | |||
156 | MainServerListener(); | 160 | MainServerListener(); |
157 | 161 | ||
158 | } | 162 | } |
@@ -230,6 +234,7 @@ namespace OpenSim | |||
230 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing clients"); | 234 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing clients"); |
231 | // IMPLEMENT THIS | 235 | // IMPLEMENT THIS |
232 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing console and terminating"); | 236 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing console and terminating"); |
237 | OpenSim_Main.local_world.Close(); | ||
233 | ServerConsole.MainConsole.Instance.Close(); | 238 | ServerConsole.MainConsole.Instance.Close(); |
234 | Environment.Exit(0); | 239 | Environment.Exit(0); |
235 | } | 240 | } |
diff --git a/src/OpenSimClient.cs b/src/OpenSimClient.cs index 9544e7b..1f9c70c 100644 --- a/src/OpenSimClient.cs +++ b/src/OpenSimClient.cs | |||
@@ -99,6 +99,7 @@ namespace OpenSim | |||
99 | client.ClientAvatar.SendAppearanceToOtherAgent(this); | 99 | client.ClientAvatar.SendAppearanceToOtherAgent(this); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | OpenSim_Main.local_world.GetInitialPrims(this); | ||
102 | break; | 103 | break; |
103 | case PacketType.ObjectAdd: | 104 | case PacketType.ObjectAdd: |
104 | OpenSim_Main.local_world.AddNewPrim((ObjectAddPacket)Pack, this); | 105 | OpenSim_Main.local_world.AddNewPrim((ObjectAddPacket)Pack, this); |
diff --git a/src/OpenSimConsole.cs b/src/OpenSimConsole.cs index 7d8563f..80f36af 100644 --- a/src/OpenSimConsole.cs +++ b/src/OpenSimConsole.cs | |||
@@ -169,8 +169,11 @@ namespace OpenSim | |||
169 | OpenSim.world.Avatar TempAv; | 169 | OpenSim.world.Avatar TempAv; |
170 | this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP")); | 170 | this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP")); |
171 | foreach (libsecondlife.LLUUID UUID in OpenSim_Main.local_world.Entities.Keys) { | 171 | foreach (libsecondlife.LLUUID UUID in OpenSim_Main.local_world.Entities.Keys) { |
172 | TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID]; | 172 | if(OpenSim_Main.local_world.Entities[UUID].ToString()== "OpenSim.world.Avatar") |
173 | 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())); | 173 | { |
174 | TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID]; | ||
175 | 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())); | ||
176 | } | ||
174 | } | 177 | } |
175 | break; | 178 | break; |
176 | } | 179 | } |
diff --git a/src/RemoteServers/RemoteGridServers/RemoteGrid.cs b/src/RemoteServers/RemoteGridServers/RemoteGrid.cs index f7c33e8..428d5f5 100644 --- a/src/RemoteServers/RemoteGridServers/RemoteGrid.cs +++ b/src/RemoteServers/RemoteGridServers/RemoteGrid.cs | |||
@@ -111,7 +111,7 @@ namespace RemoteGridServers | |||
111 | 111 | ||
112 | public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) | 112 | public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) |
113 | { | 113 | { |
114 | WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + circuitCode.ToString() + "/delete"); | 114 | WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + "/" + circuitCode.ToString() + "/delete"); |
115 | WebResponse GridResponse = DeleteSession.GetResponse(); | 115 | WebResponse GridResponse = DeleteSession.GetResponse(); |
116 | StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); | 116 | StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); |
117 | String grTest = sr.ReadLine(); | 117 | String grTest = sr.ReadLine(); |
diff --git a/src/Second-server.sln b/src/Second-server.sln index 96755ee..a460b2a 100644 --- a/src/Second-server.sln +++ b/src/Second-server.sln | |||
@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysXplugin", "physics\plug | |||
17 | EndProject | 17 | EndProject |
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerConsole", "ServerConsole\ServerConsole\ServerConsole.csproj", "{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}" | 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerConsole", "ServerConsole\ServerConsole\ServerConsole.csproj", "{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}" |
19 | EndProject | 19 | EndProject |
20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4LocalStorage", "LocalStorage\Db4LocalStorage\Db4LocalStorage.csproj", "{74784F23-B0FD-484C-82C1-96C0215733DC}" | ||
21 | EndProject | ||
20 | Global | 22 | Global |
21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution | 23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution |
22 | Debug|.NET 1.1 = Debug|.NET 1.1 | 24 | Debug|.NET 1.1 = Debug|.NET 1.1 |
@@ -89,6 +91,14 @@ Global | |||
89 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1 | 91 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1 |
90 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.Build.0 = Release|Any CPU | 92 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.Build.0 = Release|Any CPU |
91 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.ActiveCfg = Release|Any CPU | 93 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.ActiveCfg = Release|Any CPU |
94 | {74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1 | ||
95 | {74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1 | ||
96 | {74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
97 | {74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
98 | {74784F23-B0FD-484C-82C1-96C0215733DC}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
99 | {74784F23-B0FD-484C-82C1-96C0215733DC}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1 | ||
100 | {74784F23-B0FD-484C-82C1-96C0215733DC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
101 | {74784F23-B0FD-484C-82C1-96C0215733DC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
92 | EndGlobalSection | 102 | EndGlobalSection |
93 | GlobalSection(SolutionProperties) = preSolution | 103 | GlobalSection(SolutionProperties) = preSolution |
94 | HideSolutionNode = FALSE | 104 | HideSolutionNode = FALSE |
diff --git a/src/world/Entity.cs b/src/world/Entity.cs index 147478b..ee4b2e4 100644 --- a/src/world/Entity.cs +++ b/src/world/Entity.cs | |||
@@ -58,5 +58,10 @@ namespace OpenSim.world | |||
58 | 58 | ||
59 | return mesh; | 59 | return mesh; |
60 | } | 60 | } |
61 | |||
62 | public virtual void BackUp() | ||
63 | { | ||
64 | |||
65 | } | ||
61 | } | 66 | } |
62 | } | 67 | } |
diff --git a/src/world/Primitive.cs b/src/world/Primitive.cs index 1fb7142..6029f76 100644 --- a/src/world/Primitive.cs +++ b/src/world/Primitive.cs | |||
@@ -4,6 +4,7 @@ using System.Text; | |||
4 | using OpenSim.types; | 4 | using OpenSim.types; |
5 | using libsecondlife; | 5 | using libsecondlife; |
6 | using libsecondlife.Packets; | 6 | using libsecondlife.Packets; |
7 | using GridInterfaces; | ||
7 | 8 | ||
8 | namespace OpenSim.world | 9 | namespace OpenSim.world |
9 | { | 10 | { |
@@ -15,7 +16,7 @@ namespace OpenSim.world | |||
15 | protected bool newPrimFlag; | 16 | protected bool newPrimFlag; |
16 | protected bool updateFlag; | 17 | protected bool updateFlag; |
17 | protected ObjectUpdatePacket OurPacket; | 18 | protected ObjectUpdatePacket OurPacket; |
18 | 19 | ||
19 | public bool UpdateFlag | 20 | public bool UpdateFlag |
20 | { | 21 | { |
21 | get | 22 | get |
@@ -69,6 +70,14 @@ namespace OpenSim.world | |||
69 | } | 70 | } |
70 | this.updateFlag = false; | 71 | this.updateFlag = false; |
71 | } | 72 | } |
73 | |||
74 | } | ||
75 | |||
76 | public void UpdateClient(OpenSimClient RemoteClient) | ||
77 | { | ||
78 | byte[] pb = this.position.GetBytes(); | ||
79 | Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length); | ||
80 | RemoteClient.OutPacket(OurPacket); | ||
72 | } | 81 | } |
73 | 82 | ||
74 | public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID) | 83 | public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID) |
@@ -118,8 +127,7 @@ namespace OpenSim.world | |||
118 | //finish off copying rest of shape data | 127 | //finish off copying rest of shape data |
119 | 128 | ||
120 | objupdate.ObjectData[0].ID = (uint)(localID); | 129 | objupdate.ObjectData[0].ID = (uint)(localID); |
121 | objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efefda" + (localID- 702000).ToString("000")); | 130 | objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID- 702000).ToString("00000")); |
122 | |||
123 | objupdate.ObjectData[0].ObjectData = new byte[60]; | 131 | objupdate.ObjectData[0].ObjectData = new byte[60]; |
124 | objupdate.ObjectData[0].ObjectData[46] = 128; | 132 | objupdate.ObjectData[0].ObjectData[46] = 128; |
125 | objupdate.ObjectData[0].ObjectData[47] = 63; | 133 | objupdate.ObjectData[0].ObjectData[47] = 63; |
@@ -135,6 +143,67 @@ namespace OpenSim.world | |||
135 | this.OurPacket = objupdate; | 143 | this.OurPacket = objupdate; |
136 | } | 144 | } |
137 | 145 | ||
146 | public void CreateFromStorage(PrimStorage store) | ||
147 | { | ||
148 | //need to clean this up as it shares a lot of code with CreateFromPacket() | ||
149 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
150 | objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; | ||
151 | objupdate.RegionData.TimeDilation = 64096; | ||
152 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
153 | |||
154 | this.primData = store.Data; | ||
155 | objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); | ||
156 | objupdate.ObjectData[0].PSBlock = new byte[0]; | ||
157 | objupdate.ObjectData[0].ExtraParams = new byte[1]; | ||
158 | objupdate.ObjectData[0].MediaURL = new byte[0]; | ||
159 | objupdate.ObjectData[0].NameValue = new byte[0]; | ||
160 | objupdate.ObjectData[0].PSBlock = new byte[0]; | ||
161 | objupdate.ObjectData[0].Text = new byte[0]; | ||
162 | objupdate.ObjectData[0].TextColor = new byte[4]; | ||
163 | objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0); | ||
164 | objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0); | ||
165 | objupdate.ObjectData[0].Material = 3; | ||
166 | objupdate.ObjectData[0].UpdateFlags=32+65536+131072+256+4+8+2048+524288+268435456; | ||
167 | objupdate.ObjectData[0].TextureAnim = new byte[0]; | ||
168 | objupdate.ObjectData[0].Sound = LLUUID.Zero; | ||
169 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); | ||
170 | objupdate.ObjectData[0].TextureEntry = ntex.ToBytes(); | ||
171 | objupdate.ObjectData[0].State = 0; | ||
172 | objupdate.ObjectData[0].Data = new byte[0]; | ||
173 | objupdate.ObjectData[0].OwnerID = this.primData.OwnerID; | ||
174 | objupdate.ObjectData[0].PCode = this.primData.PCode; | ||
175 | objupdate.ObjectData[0].PathBegin = this.primData.PathBegin; | ||
176 | objupdate.ObjectData[0].PathEnd = this.primData.PathEnd; | ||
177 | objupdate.ObjectData[0].PathScaleX = this.primData.PathScaleX; | ||
178 | objupdate.ObjectData[0].PathScaleY = this.primData.PathScaleY; | ||
179 | objupdate.ObjectData[0].PathShearX = this.primData.PathShearX; | ||
180 | objupdate.ObjectData[0].PathShearY = this.primData.PathShearY; | ||
181 | objupdate.ObjectData[0].PathSkew = this.primData.PathSkew; | ||
182 | objupdate.ObjectData[0].ProfileBegin = this.primData.ProfileBegin; | ||
183 | objupdate.ObjectData[0].ProfileEnd = this.primData.ProfileEnd; | ||
184 | objupdate.ObjectData[0].Scale = this.primData.Scale; | ||
185 | objupdate.ObjectData[0].PathCurve = this.primData.PathCurve; | ||
186 | objupdate.ObjectData[0].ProfileCurve = this.primData.ProfileCurve; | ||
187 | objupdate.ObjectData[0].ParentID = 0; | ||
188 | objupdate.ObjectData[0].ProfileHollow = this.primData.ProfileHollow; | ||
189 | //finish off copying rest of shape data | ||
190 | |||
191 | objupdate.ObjectData[0].ID = (uint)store.LocalID; | ||
192 | objupdate.ObjectData[0].FullID = store.FullID; | ||
193 | |||
194 | objupdate.ObjectData[0].ObjectData = new byte[60]; | ||
195 | objupdate.ObjectData[0].ObjectData[46] = 128; | ||
196 | objupdate.ObjectData[0].ObjectData[47] = 63; | ||
197 | LLVector3 pos1= store.Position; | ||
198 | //update position | ||
199 | byte[] pb = pos1.GetBytes(); | ||
200 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); | ||
201 | |||
202 | this.uuid = objupdate.ObjectData[0].FullID; | ||
203 | this.localid = objupdate.ObjectData[0].ID; | ||
204 | this.position = pos1; | ||
205 | this.OurPacket = objupdate; | ||
206 | } | ||
138 | public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() | 207 | public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() |
139 | { | 208 | { |
140 | uint ID = this.localid; | 209 | uint ID = this.localid; |
@@ -200,30 +269,17 @@ namespace OpenSim.world | |||
200 | dat.Data=bytes; | 269 | dat.Data=bytes; |
201 | return dat; | 270 | return dat; |
202 | } | 271 | } |
272 | |||
273 | public override void BackUp() | ||
274 | { | ||
275 | PrimStorage pStore = new PrimStorage(); | ||
276 | pStore.Data = this.primData; | ||
277 | pStore.FullID = this.uuid; | ||
278 | pStore.LocalID = this.localid; | ||
279 | pStore.Position = this.position; | ||
280 | pStore.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z , this.rotation.w); | ||
281 | OpenSim_Main.local_world.localStorage.StorePrim(pStore); | ||
282 | } | ||
203 | } | 283 | } |
204 | 284 | ||
205 | public class PrimData | ||
206 | { | ||
207 | public LLUUID OwnerID; | ||
208 | public byte PCode; | ||
209 | public byte PathBegin; | ||
210 | public byte PathEnd; | ||
211 | public byte PathScaleX; | ||
212 | public byte PathScaleY; | ||
213 | public byte PathShearX; | ||
214 | public byte PathShearY; | ||
215 | public sbyte PathSkew; | ||
216 | public byte ProfileBegin; | ||
217 | public byte ProfileEnd; | ||
218 | public LLVector3 Scale; | ||
219 | public byte PathCurve; | ||
220 | public byte ProfileCurve; | ||
221 | public uint ParentID=0; | ||
222 | public byte ProfileHollow; | ||
223 | |||
224 | public PrimData() | ||
225 | { | ||
226 | |||
227 | } | ||
228 | } | ||
229 | } | 285 | } |
diff --git a/src/world/World.cs b/src/world/World.cs index f6f58c7..6be9dd2 100644 --- a/src/world/World.cs +++ b/src/world/World.cs | |||
@@ -3,12 +3,14 @@ using libsecondlife; | |||
3 | using libsecondlife.Packets; | 3 | using libsecondlife.Packets; |
4 | using System.Collections.Generic; | 4 | using System.Collections.Generic; |
5 | using System.Text; | 5 | using System.Text; |
6 | using System.Reflection; | ||
6 | using System.IO; | 7 | using System.IO; |
7 | using PhysicsSystem; | 8 | using PhysicsSystem; |
9 | using GridInterfaces; | ||
8 | 10 | ||
9 | namespace OpenSim.world | 11 | namespace OpenSim.world |
10 | { | 12 | { |
11 | public class World | 13 | public class World : ILocalStorageReceiver |
12 | { | 14 | { |
13 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; | 15 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; |
14 | public float[] LandMap; | 16 | public float[] LandMap; |
@@ -17,9 +19,10 @@ namespace OpenSim.world | |||
17 | private PhysicsScene phyScene; | 19 | private PhysicsScene phyScene; |
18 | private float timeStep= 0.1f; | 20 | private float timeStep= 0.1f; |
19 | private libsecondlife.TerrainManager TerrainManager; | 21 | private libsecondlife.TerrainManager TerrainManager; |
20 | 22 | public ILocalStorage localStorage; | |
21 | private Random Rand = new Random(); | 23 | private Random Rand = new Random(); |
22 | private uint _primCount = 702000; | 24 | private uint _primCount = 702000; |
25 | private int storageCount; | ||
23 | 26 | ||
24 | public World() | 27 | public World() |
25 | { | 28 | { |
@@ -48,8 +51,7 @@ namespace OpenSim.world | |||
48 | 51 | ||
49 | public void Update() | 52 | public void Update() |
50 | { | 53 | { |
51 | 54 | if(this.phyScene.IsThreaded) | |
52 | if(this.phyScene.IsThreaded) | ||
53 | { | 55 | { |
54 | this.phyScene.GetResults(); | 56 | this.phyScene.GetResults(); |
55 | 57 | ||
@@ -66,24 +68,95 @@ namespace OpenSim.world | |||
66 | { | 68 | { |
67 | Entities[UUID].update(); | 69 | Entities[UUID].update(); |
68 | } | 70 | } |
71 | |||
72 | //backup world data | ||
73 | this.storageCount++; | ||
74 | if(storageCount> 1200) //set to how often you want to backup (currently set for about every 2 minutes) | ||
75 | { | ||
76 | this.Backup(); | ||
77 | storageCount =0; | ||
78 | } | ||
69 | } | 79 | } |
70 | 80 | ||
81 | public bool LoadStorageDLL(string dllName) | ||
82 | { | ||
83 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
84 | ILocalStorage store = null; | ||
85 | |||
86 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
87 | { | ||
88 | if (pluginType.IsPublic) | ||
89 | { | ||
90 | if (!pluginType.IsAbstract) | ||
91 | { | ||
92 | Type typeInterface = pluginType.GetInterface("ILocalStorage", true); | ||
93 | |||
94 | if (typeInterface != null) | ||
95 | { | ||
96 | ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
97 | store = plug; | ||
98 | break; | ||
99 | } | ||
100 | |||
101 | typeInterface = null; | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | pluginAssembly = null; | ||
106 | this.localStorage = store; | ||
107 | return(store == null); | ||
108 | } | ||
109 | |||
110 | public void LoadPrimsFromStorage() | ||
111 | { | ||
112 | ServerConsole.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives"); | ||
113 | this.localStorage.LoadPrimitives(this); | ||
114 | } | ||
115 | |||
116 | public void PrimFromStorage(PrimStorage prim) | ||
117 | { | ||
118 | if(prim.LocalID >= this._primCount) | ||
119 | { | ||
120 | _primCount = prim.LocalID + 1; | ||
121 | } | ||
122 | ServerConsole.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId "+ prim.LocalID+ " ) from storage"); | ||
123 | Primitive nPrim = new Primitive(); | ||
124 | nPrim.CreateFromStorage(prim); | ||
125 | this.Entities.Add(nPrim.uuid, nPrim); | ||
126 | } | ||
127 | |||
128 | public void Close() | ||
129 | { | ||
130 | this.localStorage.ShutDown(); | ||
131 | } | ||
132 | |||
71 | public void SendLayerData(OpenSimClient RemoteClient) { | 133 | public void SendLayerData(OpenSimClient RemoteClient) { |
72 | int[] patches = new int[4]; | 134 | int[] patches = new int[4]; |
73 | 135 | ||
74 | for (int y = 0; y < 16; y++) | 136 | for (int y = 0; y < 16; y++) |
75 | { | 137 | { |
76 | for (int x = 0; x < 16; x = x + 4) | 138 | for (int x = 0; x < 16; x = x + 4) |
77 | { | 139 | { |
78 | patches[0] = x + 0 + y * 16; | 140 | patches[0] = x + 0 + y * 16; |
79 | patches[1] = x + 1 + y * 16; | 141 | patches[1] = x + 1 + y * 16; |
80 | patches[2] = x + 2 + y * 16; | 142 | patches[2] = x + 2 + y * 16; |
81 | patches[3] = x + 3 + y * 16; | 143 | patches[3] = x + 3 + y * 16; |
82 | 144 | ||
83 | Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); | 145 | Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); |
84 | RemoteClient.OutPacket(layerpack); | 146 | RemoteClient.OutPacket(layerpack); |
85 | } | 147 | } |
86 | } | 148 | } |
149 | } | ||
150 | |||
151 | public void GetInitialPrims(OpenSimClient RemoteClient) | ||
152 | { | ||
153 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
154 | { | ||
155 | if(Entities[UUID].ToString()== "OpenSim.world.Primitive") | ||
156 | { | ||
157 | ((OpenSim.world.Primitive)Entities[UUID]).UpdateClient(RemoteClient); | ||
158 | } | ||
159 | } | ||
87 | } | 160 | } |
88 | 161 | ||
89 | public void AddViewerAgent(OpenSimClient AgentClient) { | 162 | public void AddViewerAgent(OpenSimClient AgentClient) { |
@@ -96,7 +169,7 @@ namespace OpenSim.world | |||
96 | NewAvatar.PhysActor = this.phyScene.AddAvatar(new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z)); | 169 | NewAvatar.PhysActor = this.phyScene.AddAvatar(new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z)); |
97 | //this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user | 170 | //this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user |
98 | this.Entities.Add(AgentClient.AgentID, NewAvatar); | 171 | this.Entities.Add(AgentClient.AgentID, NewAvatar); |
99 | } | 172 | } |
100 | 173 | ||
101 | public void AddNewPrim(ObjectAddPacket addPacket, OpenSimClient AgentClient) | 174 | public void AddNewPrim(ObjectAddPacket addPacket, OpenSimClient AgentClient) |
102 | { | 175 | { |
@@ -109,8 +182,12 @@ namespace OpenSim.world | |||
109 | 182 | ||
110 | public bool Backup() { | 183 | public bool Backup() { |
111 | /* TODO: Save the current world entities state. */ | 184 | /* TODO: Save the current world entities state. */ |
112 | 185 | ServerConsole.MainConsole.Instance.WriteLine("World.cs: Backup() - Backing up Primitives"); | |
113 | return false; | 186 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) |
187 | { | ||
188 | Entities[UUID].BackUp(); | ||
189 | } | ||
190 | return true; | ||
114 | } | 191 | } |
115 | 192 | ||
116 | } | 193 | } |