aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/Application.cs122
-rw-r--r--OpenSim/Region/Application/OpenSim.csproj190
-rw-r--r--OpenSim/Region/Application/OpenSim.exe.build60
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs485
-rw-r--r--OpenSim/Region/Application/VersionInfo.cs38
-rw-r--r--OpenSim/Region/Caches/AssetCache.cs670
-rw-r--r--OpenSim/Region/Caches/OpenSim.Region.Caches.csproj97
-rw-r--r--OpenSim/Region/Caches/OpenSim.Region.Caches.dll.build43
-rw-r--r--OpenSim/Region/Caches/Properties/AssemblyInfo.cs35
-rw-r--r--OpenSim/Region/Capabilities/Caps.cs279
-rw-r--r--OpenSim/Region/Capabilities/LLSDArray.cs45
-rw-r--r--OpenSim/Region/Capabilities/LLSDCapEvent.cs45
-rw-r--r--OpenSim/Region/Capabilities/LLSDCapsDetails.cs19
-rw-r--r--OpenSim/Region/Capabilities/LLSDEmpty.cs42
-rw-r--r--OpenSim/Region/Capabilities/LLSDHelpers.cs165
-rw-r--r--OpenSim/Region/Capabilities/LLSDMapLayer.cs50
-rw-r--r--OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs45
-rw-r--r--OpenSim/Region/Capabilities/LLSDMapRequest.cs17
-rw-r--r--OpenSim/Region/Capabilities/LLSDTest.cs45
-rw-r--r--OpenSim/Region/Capabilities/LLSDType.cs53
-rw-r--r--OpenSim/Region/Capabilities/LLSDUploadReply.cs47
-rw-r--r--OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj143
-rw-r--r--OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build56
-rw-r--r--OpenSim/Region/ClientStack/Assets/InventoryCache.cs338
-rw-r--r--OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs46
-rw-r--r--OpenSim/Region/ClientStack/ClientView.API.cs976
-rw-r--r--OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs358
-rw-r--r--OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs196
-rw-r--r--OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs556
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs273
-rw-r--r--OpenSim/Region/ClientStack/ClientViewBase.cs327
-rw-r--r--OpenSim/Region/ClientStack/OpenSim.Region.ClientStack.csproj166
-rw-r--r--OpenSim/Region/ClientStack/OpenSim.Region.ClientStack.dll.build60
-rw-r--r--OpenSim/Region/ClientStack/PacketServer.cs183
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs128
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs207
-rw-r--r--OpenSim/Region/Communications/Local/CommunicationsLocal.cs60
-rw-r--r--OpenSim/Region/Communications/Local/LocalBackEndServices.cs208
-rw-r--r--OpenSim/Region/Communications/Local/LocalUserServices.cs145
-rw-r--r--OpenSim/Region/Communications/Local/OpenSim.Region.Communications.Local.csproj121
-rw-r--r--OpenSim/Region/Communications/Local/OpenSim.Region.Communications.Local.dll.build48
-rw-r--r--OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs35
-rw-r--r--OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs18
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1GridServices.cs248
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs70
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserServices.cs109
-rw-r--r--OpenSim/Region/Communications/OGS1/OpenSim.Region.Communications.OGS1.csproj142
-rw-r--r--OpenSim/Region/Communications/OGS1/OpenSim.Region.Communications.OGS1.dll.build53
-rw-r--r--OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs35
-rw-r--r--OpenSim/Region/Environment/EstateManager.cs301
-rw-r--r--OpenSim/Region/Environment/OpenSim.Region.Environment.csproj212
-rw-r--r--OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build72
-rw-r--r--OpenSim/Region/Environment/ParcelManager.cs892
-rw-r--r--OpenSim/Region/Environment/RegionManager.cs31
-rw-r--r--OpenSim/Region/Environment/Scenes/Entity.cs193
-rw-r--r--OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs19
-rw-r--r--OpenSim/Region/Environment/Scenes/Primitive.cs582
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs305
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs784
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs200
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneEvents.cs52
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObject.cs128
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs76
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs90
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs549
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpScriptEngine.cs104
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine.cs104
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Script.cs71
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs58
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs96
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyWorld.cs113
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Program.cs129
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj156
-rw-r--r--OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build54
-rw-r--r--OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs58
-rw-r--r--OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs312
-rw-r--r--OpenSim/Region/GridInterfaces/Local/OpenSim.Region.GridInterfaces.Local.csproj107
-rw-r--r--OpenSim/Region/GridInterfaces/Local/OpenSim.Region.GridInterfaces.Local.dll.build45
-rw-r--r--OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs58
-rw-r--r--OpenSim/Region/GridInterfaces/Remote/OpenSim.Region.GridInterfaces.Remote.csproj107
-rw-r--r--OpenSim/Region/GridInterfaces/Remote/OpenSim.Region.GridInterfaces.Remote.dll.build45
-rw-r--r--OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs135
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs58
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs294
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.csproj93
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.dll.build42
-rw-r--r--OpenSim/Region/Physics/Manager/AssemblyInfo.cs58
-rw-r--r--OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.csproj112
-rw-r--r--OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.dll.build47
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs161
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsManager.cs117
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs113
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsVector.cs54
-rw-r--r--OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs58
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs456
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.csproj97
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.dll.build43
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs58
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.csproj97
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.dll.build43
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs424
-rw-r--r--OpenSim/Region/Scripting/Properties/AssemblyInfo.cs35
-rw-r--r--OpenSim/Region/Scripting/Script.cs32
-rw-r--r--OpenSim/Region/Scripting/ScriptAccess.cs31
-rw-r--r--OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs117
-rw-r--r--OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Region.Storage.LocalStorageBerkeleyDB.csproj112
-rw-r--r--OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Region.Storage.LocalStorageBerkeleyDB.dll.build46
-rw-r--r--OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build46
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs58
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs271
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs43
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/OpenSim.Region.Storage.LocalStorageDb4o.csproj116
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/OpenSim.Region.Storage.LocalStorageDb4o.dll.build48
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs52
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs52
-rw-r--r--OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Region.Storage.LocalStorageSQLite.csproj111
-rw-r--r--OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Region.Storage.LocalStorageSQLite.dll.build46
-rw-r--r--OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build46
-rw-r--r--OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs62
-rw-r--r--OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs198
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/OpenSim.Region.Terrain.BasicTerrain.csproj110
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/OpenSim.Region.Terrain.BasicTerrain.dll.build47
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs62
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs786
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs130
126 files changed, 19250 insertions, 0 deletions
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
new file mode 100644
index 0000000..1dcd99b
--- /dev/null
+++ b/OpenSim/Region/Application/Application.cs
@@ -0,0 +1,122 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Framework.Console;
32using OpenSim.Region.ClientStack;
33
34namespace OpenSim
35{
36 public class Application
37 {
38 //could move our main function into OpenSimMain and kill this class
39 [STAThread]
40 public static void Main(string[] args)
41 {
42 Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
43 Console.WriteLine("Starting...\n");
44
45 bool sandBoxMode = false;
46 bool startLoginServer = false;
47 string physicsEngine = "basicphysics";
48 bool allowFlying = false;
49 bool userAccounts = false;
50 bool gridLocalAsset = false;
51 bool useConfigFile = false;
52 bool silent = false;
53 string configFile = "simconfig.xml";
54
55 for (int i = 0; i < args.Length; i++)
56 {
57 if (args[i] == "-sandbox")
58 {
59 sandBoxMode = true;
60 startLoginServer = true;
61 }
62 /*
63 if (args[i] == "-loginserver")
64 {
65 startLoginServer = true;
66 }*/
67 if (args[i] == "-accounts")
68 {
69 userAccounts = true;
70 }
71 if (args[i] == "-realphysx")
72 {
73 physicsEngine = "RealPhysX";
74 allowFlying = true;
75 }
76 if (args[i] == "-ode")
77 {
78 physicsEngine = "OpenDynamicsEngine";
79 allowFlying = true;
80 }
81 if (args[i] == "-localasset")
82 {
83 gridLocalAsset = true;
84 }
85 if (args[i] == "-configfile")
86 {
87 useConfigFile = true;
88 }
89 if (args[i] == "-noverbose")
90 {
91 silent = true;
92 }
93 if (args[i] == "-config")
94 {
95 try
96 {
97 i++;
98 configFile = args[i];
99 }
100 catch (Exception e)
101 {
102 Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")");
103 }
104 }
105 }
106
107 OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
108 // OpenSimRoot.Instance.Application = sim;
109 sim.m_sandbox = sandBoxMode;
110 sim.user_accounts = userAccounts;
111 sim.gridLocalAsset = gridLocalAsset;
112 OpenSim.Region.Environment.Scenes.ScenePresence.PhysicsEngineFlying = allowFlying;
113
114 sim.StartUp();
115
116 while (true)
117 {
118 OpenSim.Framework.Console.MainLog.Instance.MainLogPrompt();
119 }
120 }
121 }
122}
diff --git a/OpenSim/Region/Application/OpenSim.csproj b/OpenSim/Region/Application/OpenSim.csproj
new file mode 100644
index 0000000..bec85cc
--- /dev/null
+++ b/OpenSim/Region/Application/OpenSim.csproj
@@ -0,0 +1,190 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{438A9556-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Exe</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Axiom.MathLib.dll" >
62 <HintPath>..\..\..\bin\Axiom.MathLib.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="Db4objects.Db4o.dll" >
66 <HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="libsecondlife.dll" >
70 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System" >
74 <HintPath>System.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="System.Xml" >
78 <HintPath>System.Xml.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="XMLRPC.dll" >
82 <HintPath>..\..\..\bin\XMLRPC.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 </ItemGroup>
86 <ItemGroup>
87 <ProjectReference Include="..\..\Framework\General\OpenSim.Framework.csproj">
88 <Name>OpenSim.Framework</Name>
89 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
90 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
91 <Private>False</Private>
92 </ProjectReference>
93 <ProjectReference Include="..\..\Framework\Communications\OpenSim.Framework.Communications.csproj">
94 <Name>OpenSim.Framework.Communications</Name>
95 <Project>{CB52B7E7-0000-0000-0000-000000000000}</Project>
96 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
97 <Private>False</Private>
98 </ProjectReference>
99 <ProjectReference Include="..\..\Framework\Console\OpenSim.Framework.Console.csproj">
100 <Name>OpenSim.Framework.Console</Name>
101 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
102 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
103 <Private>False</Private>
104 </ProjectReference>
105 <ProjectReference Include="..\..\Framework\Data\OpenSim.Framework.Data.csproj">
106 <Name>OpenSim.Framework.Data</Name>
107 <Project>{36B72A9B-0000-0000-0000-000000000000}</Project>
108 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
109 <Private>False</Private>
110 </ProjectReference>
111 <ProjectReference Include="..\..\Framework\GenericConfig\Xml\OpenSim.Framework.GenericConfig.Xml.csproj">
112 <Name>OpenSim.Framework.GenericConfig.Xml</Name>
113 <Project>{C74E4A30-0000-0000-0000-000000000000}</Project>
114 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
115 <Private>False</Private>
116 </ProjectReference>
117 <ProjectReference Include="..\..\Framework\Servers\OpenSim.Framework.Servers.csproj">
118 <Name>OpenSim.Framework.Servers</Name>
119 <Project>{2CC71860-0000-0000-0000-000000000000}</Project>
120 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
121 <Private>False</Private>
122 </ProjectReference>
123 <ProjectReference Include="..\..\Framework\UserManager\OpenSim.Framework.UserManagement.csproj">
124 <Name>OpenSim.Framework.UserManagement</Name>
125 <Project>{586E2916-0000-0000-0000-000000000000}</Project>
126 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
127 <Private>False</Private>
128 </ProjectReference>
129 <ProjectReference Include="..\Caches\OpenSim.Region.Caches.csproj">
130 <Name>OpenSim.Region.Caches</Name>
131 <Project>{61FCCDB3-0000-0000-0000-000000000000}</Project>
132 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
133 <Private>False</Private>
134 </ProjectReference>
135 <ProjectReference Include="..\ClientStack\OpenSim.Region.ClientStack.csproj">
136 <Name>OpenSim.Region.ClientStack</Name>
137 <Project>{DC3698B2-0000-0000-0000-000000000000}</Project>
138 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
139 <Private>False</Private>
140 </ProjectReference>
141 <ProjectReference Include="..\Communications\Local\OpenSim.Region.Communications.Local.csproj">
142 <Name>OpenSim.Region.Communications.Local</Name>
143 <Project>{BFB5D807-0000-0000-0000-000000000000}</Project>
144 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
145 <Private>False</Private>
146 </ProjectReference>
147 <ProjectReference Include="..\Communications\OGS1\OpenSim.Region.Communications.OGS1.csproj">
148 <Name>OpenSim.Region.Communications.OGS1</Name>
149 <Project>{4806E378-0000-0000-0000-000000000000}</Project>
150 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
151 <Private>False</Private>
152 </ProjectReference>
153 <ProjectReference Include="..\Environment\OpenSim.Region.Environment.csproj">
154 <Name>OpenSim.Region.Environment</Name>
155 <Project>{DCBA491C-0000-0000-0000-000000000000}</Project>
156 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
157 <Private>False</Private>
158 </ProjectReference>
159 <ProjectReference Include="..\Physics\Manager\OpenSim.Region.Physics.Manager.csproj">
160 <Name>OpenSim.Region.Physics.Manager</Name>
161 <Project>{F4FF31EB-0000-0000-0000-000000000000}</Project>
162 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
163 <Private>False</Private>
164 </ProjectReference>
165 <ProjectReference Include="..\Terrain.BasicTerrain\OpenSim.Region.Terrain.BasicTerrain.csproj">
166 <Name>OpenSim.Region.Terrain.BasicTerrain</Name>
167 <Project>{C9E0F891-0000-0000-0000-000000000000}</Project>
168 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
169 <Private>False</Private>
170 </ProjectReference>
171 </ItemGroup>
172 <ItemGroup>
173 <Compile Include="Application.cs">
174 <SubType>Code</SubType>
175 </Compile>
176 <Compile Include="OpenSimMain.cs">
177 <SubType>Code</SubType>
178 </Compile>
179 <Compile Include="VersionInfo.cs">
180 <SubType>Code</SubType>
181 </Compile>
182 </ItemGroup>
183 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
184 <PropertyGroup>
185 <PreBuildEvent>
186 </PreBuildEvent>
187 <PostBuildEvent>
188 </PostBuildEvent>
189 </PropertyGroup>
190</Project>
diff --git a/OpenSim/Region/Application/OpenSim.exe.build b/OpenSim/Region/Application/OpenSim.exe.build
new file mode 100644
index 0000000..6c7d7ac
--- /dev/null
+++ b/OpenSim/Region/Application/OpenSim.exe.build
@@ -0,0 +1,60 @@
1<?xml version="1.0" ?>
2<project name="OpenSim" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="exe" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.exe">
11 <resources prefix="OpenSim" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="Application.cs" />
15 <include name="OpenSimMain.cs" />
16 <include name="VersionInfo.cs" />
17 </sources>
18 <references basedir="${project::get-base-directory()}">
19 <lib>
20 <include name="${project::get-base-directory()}" />
21 <include name="${project::get-base-directory()}/${build.dir}" />
22 </lib>
23 <include name="../../../bin/Axiom.MathLib.dll" />
24 <include name="../../../bin/Db4objects.Db4o.dll" />
25 <include name="../../../bin/libsecondlife.dll" />
26 <include name="../../../bin/OpenSim.Framework.dll" />
27 <include name="../../../bin/OpenSim.Framework.Communications.dll" />
28 <include name="../../../bin/OpenSim.Framework.Console.dll" />
29 <include name="../../../bin/OpenSim.Framework.Data.dll" />
30 <include name="../../../bin/OpenSim.Framework.GenericConfig.Xml.dll" />
31 <include name="../../../bin/OpenSim.Framework.Servers.dll" />
32 <include name="../../../bin/OpenSim.Framework.UserManagement.dll" />
33 <include name="../../../bin/OpenSim.Region.Caches.dll" />
34 <include name="../../../bin/OpenSim.Region.ClientStack.dll" />
35 <include name="../../../bin/OpenSim.Region.Communications.Local.dll" />
36 <include name="../../../bin/OpenSim.Region.Communications.OGS1.dll" />
37 <include name="../../../bin/OpenSim.Region.Environment.dll" />
38 <include name="../../../bin/OpenSim.Region.Physics.Manager.dll" />
39 <include name="../../../bin/OpenSim.Region.Terrain.BasicTerrain.dll" />
40 <include name="System.dll" />
41 <include name="System.Xml.dll" />
42 <include name="../../../bin/XMLRPC.dll" />
43 </references>
44 </csc>
45 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
46 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
47 <copy todir="${project::get-base-directory()}/../../../bin/">
48 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
49 <include name="*.dll"/>
50 <include name="*.exe"/>
51 </fileset>
52 </copy>
53 </target>
54 <target name="clean">
55 <delete dir="${bin.dir}" failonerror="false" />
56 <delete dir="${obj.dir}" failonerror="false" />
57 </target>
58 <target name="doc" description="Creates documentation.">
59 </target>
60</project>
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
new file mode 100644
index 0000000..fcb2493
--- /dev/null
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -0,0 +1,485 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using System.Text;
31using System.IO;
32using System.Threading;
33using System.Net;
34using System.Net.Sockets;
35using System.Timers;
36using System.Reflection;
37using System.Collections;
38using System.Collections.Generic;
39using libsecondlife;
40using libsecondlife.Packets;
41using OpenSim.Region.Environment;
42using OpenSim.Region.Environment.Scenes;
43using OpenSim.Region.Terrain;
44using OpenSim.Framework.Interfaces;
45using OpenSim.Framework.Data;
46
47using OpenSim.Framework.Types;
48using OpenSim.Framework;
49using OpenSim.Assets;
50using OpenSim.Region.Caches;
51using OpenSim.Framework.Console;
52using OpenSim.Physics.Manager;
53using Nwc.XmlRpc;
54using OpenSim.Framework.Servers;
55using OpenSim.GenericConfig;
56using OpenSim.Framework.Communications;
57using OpenSim.Region.Communications.OGS1;
58using OpenSim.Region.Communications.Local;
59
60using OpenSim.Region.ClientStack;
61
62namespace OpenSim
63{
64
65 public class OpenSimMain : RegionApplicationBase, conscmd_callback
66 {
67 protected CommunicationsManager commsManager;
68 // private CheckSumServer checkServer;
69
70 private bool m_silent;
71 private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log";
72
73 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
74 {
75 this.configFileSetup = useConfigFile;
76 m_sandbox = sandBoxMode;
77 m_loginserver = startLoginServer;
78 m_physicsEngine = physicsEngine;
79 m_config = configFile;
80 m_silent = silent;
81 }
82
83 /// <summary>
84 /// Performs initialisation of the world, such as loading configuration from disk.
85 /// </summary>
86 public override void StartUp()
87 {
88 this.serversData = new NetworkServersInfo();
89
90 this.localConfig = new XmlConfig(m_config);
91 this.localConfig.LoadData();
92
93 if (this.configFileSetup)
94 {
95 this.SetupFromConfigFile(this.localConfig);
96 }
97
98 m_log = new LogBase(m_logFilename, "Region", this, m_silent);
99 OpenSim.Framework.Console.MainLog.Instance = m_log;
100
101 m_log.Verbose( "Main.cs:Startup() - Loading configuration");
102 this.serversData.InitConfig(this.m_sandbox, this.localConfig);
103 this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
104
105 ScenePresence.LoadTextureFile("avatar-texture.dat");
106
107 ClientView.TerrainManager = new TerrainManager(new SecondLife());
108
109 if (m_sandbox)
110 {
111 this.SetupLocalGridServers();
112 // this.checkServer = new CheckSumServer(12036);
113 // this.checkServer.ServerListener();
114 this.commsManager = new CommunicationsLocal(this.serversData);
115 }
116 else
117 {
118 this.SetupRemoteGridServers();
119 this.commsManager = new CommunicationsOGS1(this.serversData);
120 }
121
122 startuptime = DateTime.Now;
123
124 this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
125 this.physManager.LoadPlugins();
126
127 this.SetupHttpListener();
128
129 this.SetupWorld();
130
131 m_log.Verbose( "Main.cs:Startup() - Initialising HTTP server");
132
133
134
135 if (m_sandbox)
136 {
137 httpServer.AddXmlRPCHandler("login_to_simulator", ((CommunicationsLocal)this.commsManager).UserServices.XmlRpcLoginMethod);
138 }
139
140 //Start http server
141 m_log.Verbose( "Main.cs:Startup() - Starting HTTP server");
142 httpServer.Start();
143
144 // Start UDP servers
145 for (int i = 0; i < m_udpServer.Count; i++)
146 {
147 this.m_udpServer[i].ServerListener();
148 }
149
150 }
151
152 # region Setup methods
153 protected override void SetupLocalGridServers()
154 {
155 try
156 {
157 AssetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", this.serversData.AssetURL, this.serversData.AssetSendKey);
158 InventoryCache = new InventoryCache();
159 }
160 catch (Exception e)
161 {
162 m_log.Error( e.Message + "\nSorry, could not setup local cache");
163 Environment.Exit(1);
164 }
165
166 }
167
168 protected override void SetupRemoteGridServers()
169 {
170 try
171 {
172 AssetCache = new AssetCache("OpenSim.Region.GridInterfaces.Remote.dll", this.serversData.AssetURL, this.serversData.AssetSendKey);
173 InventoryCache = new InventoryCache();
174 }
175 catch (Exception e)
176 {
177 m_log.Error( e.Message + "\nSorry, could not setup remote cache");
178 Environment.Exit(1);
179 }
180 }
181
182 protected override void SetupWorld()
183 {
184 IGenericConfig regionConfig;
185 Scene LocalWorld;
186 UDPServer udpServer;
187 RegionInfo regionDat = new RegionInfo();
188 AuthenticateSessionsBase authenBase;
189
190 string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Regions");
191 string[] configFiles = Directory.GetFiles(path, "*.xml");
192
193 if (configFiles.Length == 0)
194 {
195 string path2 = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Regions");
196 string path3 = Path.Combine(path2, "default.xml");
197 Console.WriteLine("Creating default region config file");
198 //TODO create default region
199 IGenericConfig defaultConfig = new XmlConfig(path3);
200 defaultConfig.LoadData();
201 defaultConfig.Commit();
202 defaultConfig.Close();
203 defaultConfig = null;
204 configFiles = Directory.GetFiles(path, "*.xml");
205 }
206
207 for (int i = 0; i < configFiles.Length; i++)
208 {
209 regionDat = new RegionInfo();
210 if (m_sandbox)
211 {
212 AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal();
213 this.AuthenticateSessionsHandler.Add(authen);
214 authenBase = authen;
215 }
216 else
217 {
218 AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); //new AuthenticateSessionsRemote();
219 this.AuthenticateSessionsHandler.Add(authen);
220 authenBase = authen;
221 }
222 Console.WriteLine("Loading region config file");
223 regionConfig = new XmlConfig(configFiles[i]);
224 regionConfig.LoadData();
225 regionDat.InitConfig(this.m_sandbox, regionConfig);
226 regionConfig.Close();
227
228 udpServer = new UDPServer(regionDat.CommsIPListenPort, this.AssetCache, this.InventoryCache, this.m_log, authenBase);
229
230 m_udpServer.Add(udpServer);
231 this.regionData.Add(regionDat);
232
233 /*
234 m_log.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString());
235 m_log.Verbose( "Initialising world");
236 m_log.componentname = "Region " + regionData.RegionName;
237 */
238
239 LocalWorld = new Scene(udpServer.PacketServer.ClientAPIs, regionDat, authenBase, commsManager, this.AssetCache, httpServer);
240 this.m_localWorld.Add(LocalWorld);
241 //LocalWorld.InventoryCache = InventoryCache;
242 //LocalWorld.AssetCache = AssetCache;
243
244 udpServer.LocalWorld = LocalWorld;
245
246 LocalWorld.LoadStorageDLL("OpenSim.Region.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
247 LocalWorld.LoadWorldMap();
248
249 m_log.Verbose( "Main.cs:Startup() - Starting up messaging system");
250 LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine);
251 LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D());
252 LocalWorld.LoadPrimsFromStorage();
253
254 //Master Avatar Setup
255 UserProfileData masterAvatar = commsManager.UserServer.SetupMasterUser(LocalWorld.RegionInfo.MasterAvatarFirstName, LocalWorld.RegionInfo.MasterAvatarLastName, LocalWorld.RegionInfo.MasterAvatarSandboxPassword);
256 if (masterAvatar != null)
257 {
258 LocalWorld.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID;
259 LocalWorld.localStorage.LoadParcels((ILocalStorageParcelReceiver)LocalWorld.parcelManager);
260 }
261
262
263 LocalWorld.StartTimer();
264 }
265 }
266
267 protected override void SetupHttpListener()
268 {
269 httpServer = new BaseHttpServer(this.serversData.HttpListenerPort); //regionData[0].IPListenPort);
270
271 if (!this.m_sandbox)
272 {
273
274 // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
275
276
277 httpServer.AddRestHandler("GET", "/simstatus/",
278 delegate(string request, string path, string param)
279 {
280 return "OK";
281 });
282 }
283 }
284
285 protected override void ConnectToRemoteGridServer()
286 {
287
288 }
289
290 #endregion
291
292 private void SetupFromConfigFile(IGenericConfig configData)
293 {
294 // Log filename
295 string attri = "";
296 attri = configData.GetAttribute("LogFilename");
297 if (String.IsNullOrEmpty(attri))
298 {
299 }
300 else
301 {
302 m_logFilename = attri;
303 }
304
305 // SandBoxMode
306 attri = "";
307 attri = configData.GetAttribute("SandBox");
308 if ((attri == "") || ((attri != "false") && (attri != "true")))
309 {
310 this.m_sandbox = false;
311 configData.SetAttribute("SandBox", "false");
312 }
313 else
314 {
315 this.m_sandbox = Convert.ToBoolean(attri);
316 }
317
318 // LoginServer
319 attri = "";
320 attri = configData.GetAttribute("LoginServer");
321 if ((attri == "") || ((attri != "false") && (attri != "true")))
322 {
323 this.m_loginserver = false;
324 configData.SetAttribute("LoginServer", "false");
325 }
326 else
327 {
328 this.m_loginserver = Convert.ToBoolean(attri);
329 }
330
331 // Sandbox User accounts
332 attri = "";
333 attri = configData.GetAttribute("UserAccount");
334 if ((attri == "") || ((attri != "false") && (attri != "true")))
335 {
336 this.user_accounts = false;
337 configData.SetAttribute("UserAccounts", "false");
338 }
339 else if (attri == "true")
340 {
341 this.user_accounts = Convert.ToBoolean(attri);
342 }
343
344 // Grid mode hack to use local asset server
345 attri = "";
346 attri = configData.GetAttribute("LocalAssets");
347 if ((attri == "") || ((attri != "false") && (attri != "true")))
348 {
349 this.gridLocalAsset = false;
350 configData.SetAttribute("LocalAssets", "false");
351 }
352 else if (attri == "true")
353 {
354 this.gridLocalAsset = Convert.ToBoolean(attri);
355 }
356
357
358 attri = "";
359 attri = configData.GetAttribute("PhysicsEngine");
360 switch (attri)
361 {
362 default:
363 m_log.Warn( "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating");
364 Environment.Exit(1);
365 break;
366
367 case "":
368 this.m_physicsEngine = "basicphysics";
369 configData.SetAttribute("PhysicsEngine", "basicphysics");
370 OpenSim.Region.Environment.Scenes.ScenePresence.PhysicsEngineFlying = false;
371 break;
372
373 case "basicphysics":
374 this.m_physicsEngine = "basicphysics";
375 configData.SetAttribute("PhysicsEngine", "basicphysics");
376 OpenSim.Region.Environment.Scenes.ScenePresence.PhysicsEngineFlying = false;
377 break;
378
379 case "RealPhysX":
380 this.m_physicsEngine = "RealPhysX";
381 OpenSim.Region.Environment.Scenes.ScenePresence.PhysicsEngineFlying = true;
382 break;
383
384 case "OpenDynamicsEngine":
385 this.m_physicsEngine = "OpenDynamicsEngine";
386 OpenSim.Region.Environment.Scenes.ScenePresence.PhysicsEngineFlying = true;
387 break;
388 }
389
390 configData.Commit();
391
392 }
393
394 /// <summary>
395 /// Performs any last-minute sanity checking and shuts down the region server
396 /// </summary>
397 public virtual void Shutdown()
398 {
399 m_log.Verbose( "Main.cs:Shutdown() - Closing all threads");
400 m_log.Verbose( "Main.cs:Shutdown() - Killing listener thread");
401 m_log.Verbose( "Main.cs:Shutdown() - Killing clients");
402 // IMPLEMENT THIS
403 m_log.Verbose( "Main.cs:Shutdown() - Closing console and terminating");
404 for (int i = 0; i < m_localWorld.Count; i++)
405 {
406 ((Scene)m_localWorld[i]).Close();
407 }
408 m_log.Close();
409 Environment.Exit(0);
410 }
411
412 #region Console Commands
413 /// <summary>
414 /// Runs commands issued by the server console from the operator
415 /// </summary>
416 /// <param name="command">The first argument of the parameter (the command)</param>
417 /// <param name="cmdparams">Additional arguments passed to the command</param>
418 public void RunCmd(string command, string[] cmdparams)
419 {
420 switch (command)
421 {
422 case "help":
423 m_log.Error( "show users - show info about connected users");
424 m_log.Error( "shutdown - disconnect all clients and shutdown");
425 break;
426
427 case "show":
428 if (cmdparams.Length > 0)
429 {
430 Show(cmdparams[0]);
431 }
432 break;
433
434 case "terrain":
435 string result = "";
436 for (int i = 0; i < m_localWorld.Count; i++)
437 {
438 if (!((Scene)m_localWorld[i]).Terrain.RunTerrainCmd(cmdparams, ref result))
439 {
440 m_log.Error(result);
441 }
442 }
443 break;
444
445 case "shutdown":
446 Shutdown();
447 break;
448
449 default:
450 m_log.Error( "Unknown command");
451 break;
452 }
453 }
454
455 /// <summary>
456 /// Outputs to the console information about the region
457 /// </summary>
458 /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param>
459 public void Show(string ShowWhat)
460 {
461 switch (ShowWhat)
462 {
463 case "uptime":
464 m_log.Error( "OpenSim has been running since " + startuptime.ToString());
465 m_log.Error( "That is " + (DateTime.Now - startuptime).ToString());
466 break;
467 case "users":
468 OpenSim.Region.Environment.Scenes.ScenePresence TempAv;
469 m_log.Error( String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP"));
470 /* foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys)
471 {
472 if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar")
473 {
474 TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID];
475 m_log.Error( 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()));
476 }
477 }*/
478 break;
479 }
480 }
481 #endregion
482 }
483
484
485} \ No newline at end of file
diff --git a/OpenSim/Region/Application/VersionInfo.cs b/OpenSim/Region/Application/VersionInfo.cs
new file mode 100644
index 0000000..5d1354e
--- /dev/null
+++ b/OpenSim/Region/Application/VersionInfo.cs
@@ -0,0 +1,38 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29
30namespace OpenSim
31{
32 /// <summary>
33 /// </summary>
34 public class VersionInfo
35 {
36 public static string Version = "0.3, SVN build ";
37 }
38}
diff --git a/OpenSim/Region/Caches/AssetCache.cs b/OpenSim/Region/Caches/AssetCache.cs
new file mode 100644
index 0000000..6cf921b
--- /dev/null
+++ b/OpenSim/Region/Caches/AssetCache.cs
@@ -0,0 +1,670 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using System.Collections.Generic;
31using System.Threading;
32using System.Reflection;
33using libsecondlife;
34using libsecondlife.Packets;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types;
37using OpenSim.Framework.Utilities;
38
39namespace OpenSim.Region.Caches
40{
41 public delegate void DownloadComplete(AssetCache.TextureSender sender);
42
43 /// <summary>
44 /// Manages local cache of assets and their sending to viewers.
45 /// </summary>
46 public class AssetCache : IAssetReceiver
47 {
48 public Dictionary<libsecondlife.LLUUID, AssetInfo> Assets;
49 public Dictionary<libsecondlife.LLUUID, TextureImage> Textures;
50
51 public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers
52 public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent
53
54 public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); //Assets requested from the asset server
55 public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); //Textures requested from the asset server
56
57 public Dictionary<LLUUID, TextureSender> SendingTextures = new Dictionary<LLUUID, TextureSender>();
58 private IAssetServer _assetServer;
59 private Thread _assetCacheThread;
60 private LLUUID[] textureList = new LLUUID[5];
61
62 /// <summary>
63 ///
64 /// </summary>
65 public AssetCache(IAssetServer assetServer)
66 {
67 Console.WriteLine("Creating Asset cache");
68 _assetServer = assetServer;
69 _assetServer.SetReceiver(this);
70 Assets = new Dictionary<libsecondlife.LLUUID, AssetInfo>();
71 Textures = new Dictionary<libsecondlife.LLUUID, TextureImage>();
72 this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
73 this._assetCacheThread.IsBackground = true;
74 this._assetCacheThread.Start();
75
76 }
77
78 public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey)
79 {
80 Console.WriteLine("Creating Asset cache");
81 _assetServer = this.LoadAssetDll(assetServerDLLName);
82 _assetServer.SetServerInfo(assetServerURL, assetServerKey);
83 _assetServer.SetReceiver(this);
84 Assets = new Dictionary<libsecondlife.LLUUID, AssetInfo>();
85 Textures = new Dictionary<libsecondlife.LLUUID, TextureImage>();
86 this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
87 this._assetCacheThread.IsBackground = true;
88 this._assetCacheThread.Start();
89
90 }
91
92 /// <summary>
93 ///
94 /// </summary>
95 public void RunAssetManager()
96 {
97 while (true)
98 {
99 try
100 {
101 //Console.WriteLine("Asset cache loop");
102 this.ProcessAssetQueue();
103 this.ProcessTextureQueue();
104 Thread.Sleep(500);
105 }
106 catch (Exception e)
107 {
108 Console.WriteLine(e.Message);
109 }
110 }
111 }
112
113 public void LoadDefaultTextureSet()
114 {
115 //hack: so we can give each user a set of textures
116 textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001");
117 textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002");
118 textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003");
119 textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004");
120 textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005");
121
122 for (int i = 0; i < textureList.Length; i++)
123 {
124 this._assetServer.RequestAsset(textureList[i], true);
125 }
126
127 }
128
129 public AssetBase[] CreateNewInventorySet(LLUUID agentID)
130 {
131 AssetBase[] inventorySet = new AssetBase[this.textureList.Length];
132 for (int i = 0; i < textureList.Length; i++)
133 {
134 if (this.Textures.ContainsKey(textureList[i]))
135 {
136 inventorySet[i] = this.CloneImage(agentID, this.Textures[textureList[i]]);
137 TextureImage image = new TextureImage(inventorySet[i]);
138 this.Textures.Add(image.FullID, image);
139 this._assetServer.UploadNewAsset(image); //save the asset to the asset server
140 }
141 }
142 return inventorySet;
143 }
144
145 public AssetBase GetAsset(LLUUID assetID)
146 {
147 AssetBase asset = null;
148 if (this.Textures.ContainsKey(assetID))
149 {
150 asset = this.Textures[assetID];
151 }
152 else if (this.Assets.ContainsKey(assetID))
153 {
154 asset = this.Assets[assetID];
155 }
156 return asset;
157 }
158
159 public void AddAsset(AssetBase asset)
160 {
161 // Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated());
162 if (asset.Type == 0)
163 {
164 //Console.WriteLine("which is a texture");
165 if (!this.Textures.ContainsKey(asset.FullID))
166 { //texture
167 TextureImage textur = new TextureImage(asset);
168 this.Textures.Add(textur.FullID, textur);
169 this._assetServer.UploadNewAsset(asset);
170 }
171 }
172 else
173 {
174 if (!this.Assets.ContainsKey(asset.FullID))
175 {
176 AssetInfo assetInf = new AssetInfo(asset);
177 this.Assets.Add(assetInf.FullID, assetInf);
178 this._assetServer.UploadNewAsset(asset);
179 }
180 }
181 }
182
183 /// <summary>
184 ///
185 /// </summary>
186 private void ProcessTextureQueue()
187 {
188 if (this.TextureRequests.Count == 0)
189 {
190 //no requests waiting
191 return;
192 }
193 int num;
194 num = this.TextureRequests.Count;
195
196 AssetRequest req;
197 for (int i = 0; i < num; i++)
198 {
199 req = (AssetRequest)this.TextureRequests[i];
200 if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID))
201 {
202 TextureSender sender = new TextureSender(req);
203 sender.OnComplete += this.TextureSent;
204 lock (this.SendingTextures)
205 {
206 this.SendingTextures.Add(req.ImageInfo.FullID, sender);
207 }
208 }
209
210 }
211
212 this.TextureRequests.Clear();
213 }
214
215 /// <summary>
216 /// Event handler, called by a TextureSender object to say that texture has been sent
217 /// </summary>
218 /// <param name="sender"></param>
219 public void TextureSent(AssetCache.TextureSender sender)
220 {
221 if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID))
222 {
223 lock (this.SendingTextures)
224 {
225 this.SendingTextures.Remove(sender.request.ImageInfo.FullID);
226 }
227 }
228 }
229
230 public void AssetReceived(AssetBase asset, bool IsTexture)
231 {
232 if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server
233 {
234 //check if it is a texture or not
235 //then add to the correct cache list
236 //then check for waiting requests for this asset/texture (in the Requested lists)
237 //and move those requests into the Requests list.
238 if (IsTexture)
239 {
240 TextureImage image = new TextureImage(asset);
241 this.Textures.Add(image.FullID, image);
242 if (this.RequestedTextures.ContainsKey(image.FullID))
243 {
244 AssetRequest req = this.RequestedTextures[image.FullID];
245 req.ImageInfo = image;
246 if (image.Data.LongLength > 600)
247 {
248 //over 600 bytes so split up file
249 req.NumPackets = 1 + (int)(image.Data.Length - 600 + 999) / 1000;
250 }
251 else
252 {
253 req.NumPackets = 1;
254 }
255 this.RequestedTextures.Remove(image.FullID);
256 this.TextureRequests.Add(req);
257 }
258 }
259 else
260 {
261 AssetInfo assetInf = new AssetInfo(asset);
262 this.Assets.Add(assetInf.FullID, assetInf);
263 if (this.RequestedAssets.ContainsKey(assetInf.FullID))
264 {
265 AssetRequest req = this.RequestedAssets[assetInf.FullID];
266 req.AssetInf = assetInf;
267 if (assetInf.Data.LongLength > 600)
268 {
269 //over 600 bytes so split up file
270 req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000;
271 }
272 else
273 {
274 req.NumPackets = 1;
275 }
276 this.RequestedAssets.Remove(assetInf.FullID);
277 this.AssetRequests.Add(req);
278 }
279 }
280 }
281 }
282
283 public void AssetNotFound(AssetBase asset)
284 {
285 //the asset server had no knowledge of requested asset
286
287 }
288
289 #region Assets
290 /// <summary>
291 ///
292 /// </summary>
293 /// <param name="userInfo"></param>
294 /// <param name="transferRequest"></param>
295 public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest)
296 {
297 LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0);
298 //check to see if asset is in local cache, if not we need to request it from asset server.
299
300 if (!this.Assets.ContainsKey(requestID))
301 {
302 //not found asset
303 // so request from asset server
304 if (!this.RequestedAssets.ContainsKey(requestID))
305 {
306 AssetRequest request = new AssetRequest();
307 request.RequestUser = userInfo;
308 request.RequestAssetID = requestID;
309 request.TransferRequestID = transferRequest.TransferInfo.TransferID;
310 this.RequestedAssets.Add(requestID, request);
311 this._assetServer.RequestAsset(requestID, false);
312 }
313 return;
314 }
315 //it is in our cache
316 AssetInfo asset = this.Assets[requestID];
317
318 //work out how many packets it should be sent in
319 // and add to the AssetRequests list
320 AssetRequest req = new AssetRequest();
321 req.RequestUser = userInfo;
322 req.RequestAssetID = requestID;
323 req.TransferRequestID = transferRequest.TransferInfo.TransferID;
324 req.AssetInf = asset;
325
326 if (asset.Data.LongLength > 600)
327 {
328 //over 600 bytes so split up file
329 req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000;
330 }
331 else
332 {
333 req.NumPackets = 1;
334 }
335
336 this.AssetRequests.Add(req);
337 }
338
339 /// <summary>
340 ///
341 /// </summary>
342 private void ProcessAssetQueue()
343 {
344 if (this.AssetRequests.Count == 0)
345 {
346 //no requests waiting
347 return;
348 }
349 int num;
350
351 if (this.AssetRequests.Count < 5)
352 {
353 //lower than 5 so do all of them
354 num = this.AssetRequests.Count;
355 }
356 else
357 {
358 num = 5;
359 }
360 AssetRequest req;
361 for (int i = 0; i < num; i++)
362 {
363 req = (AssetRequest)this.AssetRequests[i];
364
365 TransferInfoPacket Transfer = new TransferInfoPacket();
366 Transfer.TransferInfo.ChannelType = 2;
367 Transfer.TransferInfo.Status = 0;
368 Transfer.TransferInfo.TargetType = 0;
369 Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes();
370 Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length;
371 Transfer.TransferInfo.TransferID = req.TransferRequestID;
372 req.RequestUser.OutPacket(Transfer);
373
374 if (req.NumPackets == 1)
375 {
376 TransferPacketPacket TransferPacket = new TransferPacketPacket();
377 TransferPacket.TransferData.Packet = 0;
378 TransferPacket.TransferData.ChannelType = 2;
379 TransferPacket.TransferData.TransferID = req.TransferRequestID;
380 TransferPacket.TransferData.Data = req.AssetInf.Data;
381 TransferPacket.TransferData.Status = 1;
382 req.RequestUser.OutPacket(TransferPacket);
383 }
384 else
385 {
386 //more than one packet so split file up , for now it can't be bigger than 2000 bytes
387 TransferPacketPacket TransferPacket = new TransferPacketPacket();
388 TransferPacket.TransferData.Packet = 0;
389 TransferPacket.TransferData.ChannelType = 2;
390 TransferPacket.TransferData.TransferID = req.TransferRequestID;
391 byte[] chunk = new byte[1000];
392 Array.Copy(req.AssetInf.Data, chunk, 1000);
393 TransferPacket.TransferData.Data = chunk;
394 TransferPacket.TransferData.Status = 0;
395 req.RequestUser.OutPacket(TransferPacket);
396
397 TransferPacket = new TransferPacketPacket();
398 TransferPacket.TransferData.Packet = 1;
399 TransferPacket.TransferData.ChannelType = 2;
400 TransferPacket.TransferData.TransferID = req.TransferRequestID;
401 byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)];
402 Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length);
403 TransferPacket.TransferData.Data = chunk1;
404 TransferPacket.TransferData.Status = 1;
405 req.RequestUser.OutPacket(TransferPacket);
406 }
407
408 }
409
410 //remove requests that have been completed
411 for (int i = 0; i < num; i++)
412 {
413 this.AssetRequests.RemoveAt(0);
414 }
415
416 }
417
418 public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset)
419 {
420 AssetInfo newAsset = new AssetInfo();
421 newAsset.Data = new byte[sourceAsset.Data.Length];
422 Array.Copy(sourceAsset.Data, newAsset.Data, sourceAsset.Data.Length);
423 newAsset.FullID = LLUUID.Random();
424 newAsset.Type = sourceAsset.Type;
425 newAsset.InvType = sourceAsset.InvType;
426 return (newAsset);
427 }
428 #endregion
429
430 #region Textures
431 /// <summary>
432 ///
433 /// </summary>
434 /// <param name="userInfo"></param>
435 /// <param name="imageID"></param>
436 public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID)
437 {
438 //Console.WriteLine("texture request for " + imageID.ToStringHyphenated());
439 //check to see if texture is in local cache, if not request from asset server
440 if (!this.Textures.ContainsKey(imageID))
441 {
442 if (!this.RequestedTextures.ContainsKey(imageID))
443 {
444 //not is cache so request from asset server
445 AssetRequest request = new AssetRequest();
446 request.RequestUser = userInfo;
447 request.RequestAssetID = imageID;
448 request.IsTextureRequest = true;
449 this.RequestedTextures.Add(imageID, request);
450 this._assetServer.RequestAsset(imageID, true);
451 }
452 return;
453 }
454
455 //Console.WriteLine("texture already in cache");
456 TextureImage imag = this.Textures[imageID];
457 AssetRequest req = new AssetRequest();
458 req.RequestUser = userInfo;
459 req.RequestAssetID = imageID;
460 req.IsTextureRequest = true;
461 req.ImageInfo = imag;
462
463 if (imag.Data.LongLength > 600)
464 {
465 //over 600 bytes so split up file
466 req.NumPackets = 1 + (int)(imag.Data.Length - 600 + 999) / 1000;
467 }
468 else
469 {
470 req.NumPackets = 1;
471 }
472 this.TextureRequests.Add(req);
473 }
474
475 public TextureImage CloneImage(LLUUID newOwner, TextureImage source)
476 {
477 TextureImage newImage = new TextureImage();
478 newImage.Data = new byte[source.Data.Length];
479 Array.Copy(source.Data, newImage.Data, source.Data.Length);
480 //newImage.filename = source.filename;
481 newImage.FullID = LLUUID.Random();
482 newImage.Name = source.Name;
483 return (newImage);
484 }
485 #endregion
486
487 private IAssetServer LoadAssetDll(string dllName)
488 {
489 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
490 IAssetServer server = null;
491
492 foreach (Type pluginType in pluginAssembly.GetTypes())
493 {
494 if (pluginType.IsPublic)
495 {
496 if (!pluginType.IsAbstract)
497 {
498 Type typeInterface = pluginType.GetInterface("IAssetPlugin", true);
499
500 if (typeInterface != null)
501 {
502 IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
503 server = plug.GetAssetServer();
504 break;
505 }
506
507 typeInterface = null;
508 }
509 }
510 }
511 pluginAssembly = null;
512 return server;
513 }
514
515 public class AssetRequest
516 {
517 public IClientAPI RequestUser;
518 public LLUUID RequestAssetID;
519 public AssetInfo AssetInf;
520 public TextureImage ImageInfo;
521 public LLUUID TransferRequestID;
522 public long DataPointer = 0;
523 public int NumPackets = 0;
524 public int PacketCounter = 0;
525 public bool IsTextureRequest;
526 //public bool AssetInCache;
527 //public int TimeRequested;
528
529 public AssetRequest()
530 {
531
532 }
533 }
534
535 public class AssetInfo : AssetBase
536 {
537 public AssetInfo()
538 {
539
540 }
541
542 public AssetInfo(AssetBase aBase)
543 {
544 Data = aBase.Data;
545 FullID = aBase.FullID;
546 Type = aBase.Type;
547 InvType = aBase.InvType;
548 Name = aBase.Name;
549 Description = aBase.Description;
550 }
551 }
552
553 public class TextureImage : AssetBase
554 {
555 public TextureImage()
556 {
557
558 }
559
560 public TextureImage(AssetBase aBase)
561 {
562 Data = aBase.Data;
563 FullID = aBase.FullID;
564 Type = aBase.Type;
565 InvType = aBase.InvType;
566 Name = aBase.Name;
567 Description = aBase.Description;
568 }
569 }
570
571 public class TextureSender
572 {
573 public AssetRequest request;
574 public event DownloadComplete OnComplete;
575 Thread m_thread;
576 public TextureSender(AssetRequest req)
577 {
578 request = req;
579 //Console.WriteLine("creating worker thread for texture " + req.ImageInfo.FullID.ToStringHyphenated());
580 //Console.WriteLine("texture data length is " + req.ImageInfo.Data.Length);
581 // Console.WriteLine("in " + req.NumPackets + " packets");
582 //ThreadPool.QueueUserWorkItem(new WaitCallback(SendTexture), new object());
583
584 //need some sort of custom threadpool here, as using the .net one, overloads it and stops the handling of incoming packets etc
585 //but don't really want to create a thread for every texture download
586 m_thread = new Thread(new ThreadStart(SendTexture));
587 m_thread.IsBackground = true;
588 m_thread.Start();
589 }
590
591 public void SendTexture()
592 {
593 //Console.WriteLine("starting to send sending texture " + request.ImageInfo.FullID.ToStringHyphenated());
594 while (request.PacketCounter != request.NumPackets)
595 {
596 SendPacket();
597 Thread.Sleep(500);
598 }
599
600 //Console.WriteLine("finished sending texture " + request.ImageInfo.FullID.ToStringHyphenated());
601 if (OnComplete != null)
602 {
603 OnComplete(this);
604 }
605 }
606
607 public void SendPacket()
608 {
609 AssetRequest req = request;
610 // Console.WriteLine("sending " + req.ImageInfo.FullID);
611
612 // if (req.ImageInfo.FullID == new LLUUID("00000000-0000-0000-5005-000000000005"))
613 if (req.PacketCounter == 0)
614 {
615 //first time for this request so send imagedata packet
616 if (req.NumPackets == 1)
617 {
618 //only one packet so send whole file
619 ImageDataPacket im = new ImageDataPacket();
620 im.ImageID.Packets = 1;
621 im.ImageID.ID = req.ImageInfo.FullID;
622 im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
623 im.ImageData.Data = req.ImageInfo.Data;
624 im.ImageID.Codec = 2;
625 req.RequestUser.OutPacket(im);
626 req.PacketCounter++;
627 //req.ImageInfo.l= time;
628 //System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID);
629 // Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated());
630 }
631 else
632 {
633 //more than one packet so split file up
634 ImageDataPacket im = new ImageDataPacket();
635 im.ImageID.Packets = (ushort)req.NumPackets;
636 im.ImageID.ID = req.ImageInfo.FullID;
637 im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
638 im.ImageData.Data = new byte[600];
639 Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600);
640 im.ImageID.Codec = 2;
641 req.RequestUser.OutPacket(im);
642 req.PacketCounter++;
643 //req.ImageInfo.last_used = time;
644 //System.Console.WriteLine("sent first packet of texture:
645 // Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated());
646 }
647 }
648 else
649 {
650 //Console.WriteLine("sending packet" + req.PacketCounter + "for " + req.ImageInfo.FullID.ToStringHyphenated());
651 //send imagepacket
652 //more than one packet so split file up
653 ImagePacketPacket im = new ImagePacketPacket();
654 im.ImageID.Packet = (ushort)req.PacketCounter;
655 im.ImageID.ID = req.ImageInfo.FullID;
656 int size = req.ImageInfo.Data.Length - 600 - 1000 * (req.PacketCounter - 1);
657 if (size > 1000) size = 1000;
658 im.ImageData.Data = new byte[size];
659 Array.Copy(req.ImageInfo.Data, 600 + 1000 * (req.PacketCounter - 1), im.ImageData.Data, 0, size);
660 req.RequestUser.OutPacket(im);
661 req.PacketCounter++;
662 //req.ImageInfo.last_used = time;
663 //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID);
664 }
665
666 }
667 }
668 }
669}
670
diff --git a/OpenSim/Region/Caches/OpenSim.Region.Caches.csproj b/OpenSim/Region/Caches/OpenSim.Region.Caches.csproj
new file mode 100644
index 0000000..4a73d08
--- /dev/null
+++ b/OpenSim/Region/Caches/OpenSim.Region.Caches.csproj
@@ -0,0 +1,97 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{61FCCDB3-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Caches</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Caches</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="libsecondlife.dll" >
62 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System" >
66 <HintPath>System.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Xml" >
70 <HintPath>System.Xml.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 </ItemGroup>
74 <ItemGroup>
75 <ProjectReference Include="..\..\Framework\General\OpenSim.Framework.csproj">
76 <Name>OpenSim.Framework</Name>
77 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
78 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
79 <Private>False</Private>
80 </ProjectReference>
81 </ItemGroup>
82 <ItemGroup>
83 <Compile Include="AssetCache.cs">
84 <SubType>Code</SubType>
85 </Compile>
86 <Compile Include="Properties\AssemblyInfo.cs">
87 <SubType>Code</SubType>
88 </Compile>
89 </ItemGroup>
90 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
91 <PropertyGroup>
92 <PreBuildEvent>
93 </PreBuildEvent>
94 <PostBuildEvent>
95 </PostBuildEvent>
96 </PropertyGroup>
97</Project>
diff --git a/OpenSim/Region/Caches/OpenSim.Region.Caches.dll.build b/OpenSim/Region/Caches/OpenSim.Region.Caches.dll.build
new file mode 100644
index 0000000..3ca89e8
--- /dev/null
+++ b/OpenSim/Region/Caches/OpenSim.Region.Caches.dll.build
@@ -0,0 +1,43 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Caches" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Caches" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssetCache.cs" />
15 <include name="Properties/AssemblyInfo.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="../../../bin/libsecondlife.dll" />
23 <include name="../../../bin/OpenSim.Framework.dll" />
24 <include name="System.dll" />
25 <include name="System.Xml.dll" />
26 </references>
27 </csc>
28 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
29 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
30 <copy todir="${project::get-base-directory()}/../../../bin/">
31 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
32 <include name="*.dll"/>
33 <include name="*.exe"/>
34 </fileset>
35 </copy>
36 </target>
37 <target name="clean">
38 <delete dir="${bin.dir}" failonerror="false" />
39 <delete dir="${obj.dir}" failonerror="false" />
40 </target>
41 <target name="doc" description="Creates documentation.">
42 </target>
43</project>
diff --git a/OpenSim/Region/Caches/Properties/AssemblyInfo.cs b/OpenSim/Region/Caches/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..5e6ecbb
--- /dev/null
+++ b/OpenSim/Region/Caches/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Region.Caches")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenSim.Region.Caches")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("2b15ddbf-0341-49a6-85c0-cece268a4518")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.0")]
35[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs
new file mode 100644
index 0000000..416a6bc
--- /dev/null
+++ b/OpenSim/Region/Capabilities/Caps.cs
@@ -0,0 +1,279 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using System.IO;
33using System.Xml;
34using OpenSim.Framework.Servers;
35using OpenSim.Framework;
36using OpenSim.Framework.Utilities;
37using OpenSim.Framework.Types;
38using OpenSim.Region.Caches;
39using libsecondlife;
40
41namespace OpenSim.Region.Capabilities
42{
43 public delegate void UpLoadedTexture(LLUUID assetID, LLUUID inventoryItem, byte[] data);
44
45 public class Caps
46 {
47 private string httpListenerAddress;
48 private uint httpListenPort;
49 private string capsObjectPath = "00001-";
50 private string requestPath = "0000/";
51 private string mapLayerPath = "0001/";
52 private string newInventory = "0002/";
53 private string requestTexture = "0003/";
54 private string eventQueue = "0100/";
55 private BaseHttpServer httpListener;
56 private LLUUID agentID;
57 private AssetCache assetCache;
58 private int eventQueueCount = 1;
59 private Queue<string> CapsEventQueue = new Queue<string>();
60
61 public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent)
62 {
63 assetCache = assetCach;
64 capsObjectPath = capsPath;
65 httpListener = httpServer;
66 httpListenerAddress = httpListen;
67 httpListenPort = httpPort;
68 agentID = agent;
69 }
70
71 /// <summary>
72 ///
73 /// </summary>
74 public void RegisterHandlers()
75 {
76 Console.WriteLine("registering CAPS handlers");
77 httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + requestPath, CapsRequest);
78 httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + mapLayerPath, MapLayer);
79 httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + newInventory, NewAgentInventory);
80 httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + eventQueue, ProcessEventQueue);
81 }
82
83 /// <summary>
84 ///
85 /// </summary>
86 /// <param name="request"></param>
87 /// <param name="path"></param>
88 /// <param name="param"></param>
89 /// <returns></returns>
90 public string CapsRequest(string request, string path, string param)
91 {
92 // Console.WriteLine("Caps Request " + request);
93 string result = "";
94 result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities());
95 return result;
96 }
97
98 /// <summary>
99 ///
100 /// </summary>
101 /// <returns></returns>
102 protected LLSDCapsDetails GetCapabilities()
103 {
104 /* string capURLS = "";
105 capURLS += "<key>MapLayer</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath + "</string>";
106 capURLS += "<key>NewFileAgentInventory</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory + "</string>";
107 //capURLS += "<key>RequestTextureDownload</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + requestTexture + "</string>";
108 //capURLS += "<key>EventQueueGet</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + eventQueue + "</string>";
109 return capURLS;*/
110
111 LLSDCapsDetails caps = new LLSDCapsDetails();
112 caps.MapLayer = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath;
113 caps.NewFileAgentInventory = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory;
114 return caps;
115 }
116
117 /// <summary>
118 ///
119 /// </summary>
120 /// <param name="request"></param>
121 /// <param name="path"></param>
122 /// <param name="param"></param>
123 /// <returns></returns>
124 public string MapLayer(string request, string path, string param)
125 {
126 Encoding _enc = System.Text.Encoding.UTF8;
127 Hashtable hash =(Hashtable) LLSD.LLSDDeserialize(_enc.GetBytes(request));
128 LLSDMapRequest mapReq = new LLSDMapRequest();
129 LLSDHelpers.DeserialiseLLSDMap(hash, mapReq );
130
131 LLSDMapLayerResponse mapResponse= new LLSDMapLayerResponse();
132 mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse());
133 string res = LLSDHelpers.SerialiseLLSDReply(mapResponse);
134
135 //Console.WriteLine(" Maplayer response is " + res);
136
137 return res;
138 }
139
140 /// <summary>
141 ///
142 /// </summary>
143 /// <returns></returns>
144 protected LLSDMapLayer BuildLLSDMapLayerResponse()
145 {
146 LLSDMapLayer mapLayer = new LLSDMapLayer();
147 mapLayer.Right = 5000;
148 mapLayer.Top = 5000;
149 mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
150
151 return mapLayer;
152 }
153
154 public string ProcessEventQueue(string request, string path, string param)
155 {
156 string res = "";
157
158 if (this.CapsEventQueue.Count > 0)
159 {
160 lock (this.CapsEventQueue)
161 {
162 string item = CapsEventQueue.Dequeue();
163 res = item;
164 }
165 }
166 else
167 {
168 res = this.CreateEmptyEventResponse();
169 }
170 return res;
171 }
172
173 public string CreateEstablishAgentComms(string caps, string ipAddressPort)
174 {
175 string res = "<llsd><map><key>id</key><integer>" + eventQueueCount + "</integer>";
176 res += "<key>events</key><array><map>";
177 res += "<key>message</key><string>EstablishAgentCommunication</string>";
178 res += "<key>body</key><map>";
179 res += "<key>sim-ip-and-port</key><string>" + ipAddressPort + "</string>";
180 res += "<key>seed-capability</key><string>" + caps + "</string>";
181 res += "<key>agent-id</key><uuid>" + this.agentID.ToStringHyphenated() + "</uuid>";
182 res += "</map>";
183 res += "</map></array>";
184 res += "</map></llsd>";
185 eventQueueCount++;
186 this.CapsEventQueue.Enqueue(res);
187 return res;
188 }
189
190 public string CreateEmptyEventResponse()
191 {
192 string res = "<llsd><map><key>id</key><integer>" + eventQueueCount + "</integer>";
193 res += "<key>events</key><array><map>";
194 res += "</map></array>";
195 res += "</map></llsd>";
196 eventQueueCount++;
197 return res;
198 }
199
200 public string NewAgentInventory(string request, string path, string param)
201 {
202 //Console.WriteLine("received upload request:"+ request);
203 string res = "";
204 LLUUID newAsset = LLUUID.Random();
205 LLUUID newInvItem = LLUUID.Random();
206 string uploaderPath = capsObjectPath + Util.RandomClass.Next(5000, 8000).ToString("0000");
207 AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener);
208 httpListener.AddRestHandler("POST", "/CAPS/" + uploaderPath, uploader.uploaderCaps);
209 string uploaderURL = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + uploaderPath;
210 //Console.WriteLine("uploader url is " + uploaderURL);
211 res += "<llsd><map>";
212 res += "<key>uploader</key><string>" + uploaderURL + "</string>";
213 //res += "<key>success</key><boolean>true</boolean>";
214 res += "<key>state</key><string>upload</string>";
215 res += "</map></llsd>";
216 uploader.OnUpLoad += this.UploadHandler;
217 return res;
218 }
219
220 public void UploadHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data)
221 {
222 // Console.WriteLine("upload handler called");
223 AssetBase asset;
224 asset = new AssetBase();
225 asset.FullID = assetID;
226 asset.Type = 0;
227 asset.InvType = 0;
228 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000");
229 asset.Data = data;
230 this.assetCache.AddAsset(asset);
231 }
232
233 public class AssetUploader
234 {
235 public event UpLoadedTexture OnUpLoad;
236
237 private string uploaderPath = "";
238 private LLUUID newAssetID;
239 private LLUUID inventoryItemID;
240 private BaseHttpServer httpListener;
241 public AssetUploader(LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer)
242 {
243 newAssetID = assetID;
244 inventoryItemID = inventoryItem;
245 uploaderPath = path;
246 httpListener = httpServer;
247
248 }
249
250 public string uploaderCaps(string request, string path, string param)
251 {
252 Encoding _enc = System.Text.Encoding.UTF8;
253 byte[] data = _enc.GetBytes(request);
254 //Console.WriteLine("recieved upload " + Util.FieldToString(data));
255 LLUUID inv = this.inventoryItemID;
256 string res = "";
257 res += "<llsd><map>";
258 res += "<key>new_asset</key><string>" + newAssetID.ToStringHyphenated() + "</string>";
259 res += "<key>new_inventory_item</key><uuid>" + inv.ToStringHyphenated() + "</uuid>";
260 res += "<key>state</key><string>complete</string>";
261 res += "</map></llsd>";
262
263 // Console.WriteLine("asset " + newAssetID.ToStringHyphenated() + " , inventory item " + inv.ToStringHyphenated());
264 httpListener.RemoveRestHandler("POST", "/CAPS/" + uploaderPath);
265 if (OnUpLoad != null)
266 {
267 OnUpLoad(newAssetID, inv, data);
268 }
269
270 /*FileStream fs = File.Create("upload.jp2");
271 BinaryWriter bw = new BinaryWriter(fs);
272 bw.Write(data);
273 bw.Close();
274 fs.Close();*/
275 return res;
276 }
277 }
278 }
279}
diff --git a/OpenSim/Region/Capabilities/LLSDArray.cs b/OpenSim/Region/Capabilities/LLSDArray.cs
new file mode 100644
index 0000000..76d5a2c
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDArray.cs
@@ -0,0 +1,45 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32
33namespace OpenSim.Region.Capabilities
34{
35 [LLSDType("ARRAY")]
36 public class LLSDArray
37 {
38 public ArrayList Array = new ArrayList();
39
40 public LLSDArray()
41 {
42
43 }
44 }
45}
diff --git a/OpenSim/Region/Capabilities/LLSDCapEvent.cs b/OpenSim/Region/Capabilities/LLSDCapEvent.cs
new file mode 100644
index 0000000..d47d25c
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDCapEvent.cs
@@ -0,0 +1,45 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Region.Capabilities
33{
34 [LLSDType("MAP")]
35 public class LLSDCapEvent
36 {
37 public int id = 0;
38 public LLSDArray events = new LLSDArray();
39
40 public LLSDCapEvent()
41 {
42
43 }
44 }
45}
diff --git a/OpenSim/Region/Capabilities/LLSDCapsDetails.cs b/OpenSim/Region/Capabilities/LLSDCapsDetails.cs
new file mode 100644
index 0000000..d6db606
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDCapsDetails.cs
@@ -0,0 +1,19 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Region.Capabilities
6{
7 [LLSDType("MAP")]
8 public class LLSDCapsDetails
9 {
10 public string MapLayer = "";
11 public string NewFileAgentInventory = "";
12 //public string EventQueueGet = "";
13
14 public LLSDCapsDetails()
15 {
16
17 }
18 }
19}
diff --git a/OpenSim/Region/Capabilities/LLSDEmpty.cs b/OpenSim/Region/Capabilities/LLSDEmpty.cs
new file mode 100644
index 0000000..68f1ce9
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDEmpty.cs
@@ -0,0 +1,42 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Region.Capabilities
33{
34 [LLSDType("MAP")]
35 public class LLSDEmpty
36 {
37 public LLSDEmpty()
38 {
39
40 }
41 }
42}
diff --git a/OpenSim/Region/Capabilities/LLSDHelpers.cs b/OpenSim/Region/Capabilities/LLSDHelpers.cs
new file mode 100644
index 0000000..76d9345
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDHelpers.cs
@@ -0,0 +1,165 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using System.IO;
33using System.Xml;
34using libsecondlife;
35
36namespace OpenSim.Region.Capabilities
37{
38 public class LLSDHelpers
39 {
40 public static string SerialiseLLSDReply(object obj)
41 {
42 StringWriter sw = new StringWriter();
43 XmlTextWriter writer = new XmlTextWriter(sw);
44 writer.Formatting = Formatting.None;
45 writer.WriteStartElement(String.Empty, "llsd", String.Empty);
46 LLSDHelpers.SerializeLLSDType(writer, obj);
47 writer.WriteEndElement();
48 writer.Close();
49 return sw.ToString();
50 }
51
52 public static void SerializeLLSDType(XmlTextWriter writer, object obj)
53 {
54 Type myType = obj.GetType();
55 LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
56 if (llsdattributes.Length > 0)
57 {
58 switch (llsdattributes[0].ObjectType)
59 {
60 case "MAP":
61 writer.WriteStartElement(String.Empty, "map", String.Empty);
62 System.Reflection.FieldInfo[] fields = myType.GetFields();
63 for (int i = 0; i < fields.Length; i++)
64 {
65 object fieldValue = fields[i].GetValue(obj);
66 LLSDType[] fieldAttributes = (LLSDType[])fieldValue.GetType().GetCustomAttributes(typeof(LLSDType), false);
67 if (fieldAttributes.Length > 0)
68 {
69 writer.WriteStartElement(String.Empty, "key", String.Empty);
70 writer.WriteString(fields[i].Name);
71 writer.WriteEndElement();
72 SerializeLLSDType(writer, fieldValue);
73 }
74 else
75 {
76 writer.WriteStartElement(String.Empty, "key", String.Empty);
77 writer.WriteString(fields[i].Name);
78 writer.WriteEndElement();
79 LLSD.LLSDWriteOne(writer, fieldValue);
80 }
81 }
82 writer.WriteEndElement();
83 break;
84 case "ARRAY":
85 // LLSDArray arrayObject = obj as LLSDArray;
86 // ArrayList a = arrayObject.Array;
87 ArrayList a = (ArrayList)obj.GetType().GetField("Array").GetValue(obj);
88 if (a != null)
89 {
90 writer.WriteStartElement(String.Empty, "array", String.Empty);
91 foreach (object item in a)
92 {
93 SerializeLLSDType(writer, item);
94 }
95 writer.WriteEndElement();
96 }
97 break;
98 }
99 }
100 else
101 {
102 LLSD.LLSDWriteOne(writer, obj);
103 }
104 }
105
106 public static object DeserialiseLLSDMap(Hashtable llsd, object obj)
107 {
108 Type myType = obj.GetType();
109 LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
110 if (llsdattributes.Length > 0)
111 {
112 switch (llsdattributes[0].ObjectType)
113 {
114 case "MAP":
115 IDictionaryEnumerator enumerator = llsd.GetEnumerator();
116 while (enumerator.MoveNext())
117 {
118 System.Reflection.FieldInfo field = myType.GetField((string)enumerator.Key);
119 if (field != null)
120 {
121 if (enumerator.Value is Hashtable)
122 {
123 object fieldValue = field.GetValue(obj);
124 DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue);
125 }
126 else if (enumerator.Value is ArrayList)
127 {
128 object fieldValue = field.GetValue(obj);
129 fieldValue.GetType().GetField("Array").SetValue(fieldValue, enumerator.Value);
130 //TODO
131 // the LLSD map/array types in the array need to be deserialised
132 // but first we need to know the right class to deserialise them into.
133 }
134 else
135 {
136 field.SetValue(obj, enumerator.Value);
137 }
138 }
139 }
140 break;
141 }
142 }
143 return obj;
144 }
145 }
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165}
diff --git a/OpenSim/Region/Capabilities/LLSDMapLayer.cs b/OpenSim/Region/Capabilities/LLSDMapLayer.cs
new file mode 100644
index 0000000..b097ec3
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDMapLayer.cs
@@ -0,0 +1,50 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32using libsecondlife;
33
34namespace OpenSim.Region.Capabilities
35{
36 [LLSDType("MAP")]
37 public class LLSDMapLayer
38 {
39 public int Left = 0;
40 public int Right = 0;
41 public int Top = 0;
42 public int Bottom = 0;
43 public LLUUID ImageID = LLUUID.Zero;
44
45 public LLSDMapLayer()
46 {
47
48 }
49 }
50}
diff --git a/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs
new file mode 100644
index 0000000..ee37a5b
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs
@@ -0,0 +1,45 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Region.Capabilities
33{
34 [LLSDType("MAP")]
35 public class LLSDMapLayerResponse
36 {
37 public LLSDMapRequest AgentData = new LLSDMapRequest();
38 public LLSDArray LayerData = new LLSDArray();
39
40 public LLSDMapLayerResponse()
41 {
42
43 }
44 }
45}
diff --git a/OpenSim/Region/Capabilities/LLSDMapRequest.cs b/OpenSim/Region/Capabilities/LLSDMapRequest.cs
new file mode 100644
index 0000000..b15f1be
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDMapRequest.cs
@@ -0,0 +1,17 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Region.Capabilities
6{
7 [LLSDType("MAP")]
8 public class LLSDMapRequest
9 {
10 public int Flags = 0;
11
12 public LLSDMapRequest()
13 {
14
15 }
16 }
17}
diff --git a/OpenSim/Region/Capabilities/LLSDTest.cs b/OpenSim/Region/Capabilities/LLSDTest.cs
new file mode 100644
index 0000000..3948f2c
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDTest.cs
@@ -0,0 +1,45 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Region.Capabilities
33{
34 [LLSDType("MAP")]
35 public class LLSDTest
36 {
37 public int Test1 = 20;
38 public int Test2 = 10;
39
40 public LLSDTest()
41 {
42
43 }
44 }
45}
diff --git a/OpenSim/Region/Capabilities/LLSDType.cs b/OpenSim/Region/Capabilities/LLSDType.cs
new file mode 100644
index 0000000..7da5861
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDType.cs
@@ -0,0 +1,53 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Region.Capabilities
33{
34 [AttributeUsage(AttributeTargets.Class)]
35 public class LLSDType : Attribute
36 {
37 private string myType;
38
39 public LLSDType(string type)
40 {
41 myType = type;
42
43 }
44
45 public string ObjectType
46 {
47 get
48 {
49 return myType;
50 }
51 }
52 }
53}
diff --git a/OpenSim/Region/Capabilities/LLSDUploadReply.cs b/OpenSim/Region/Capabilities/LLSDUploadReply.cs
new file mode 100644
index 0000000..83cf166
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDUploadReply.cs
@@ -0,0 +1,47 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32using libsecondlife;
33namespace OpenSim.Region.Capabilities
34{
35 [LLSDType("MAP")]
36 public class LLSDUploadReply
37 {
38 public string new_asset = "";
39 public LLUUID new_inventory_item = LLUUID.Zero;
40 public string state = "";
41
42 public LLSDUploadReply()
43 {
44
45 }
46 }
47}
diff --git a/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj
new file mode 100644
index 0000000..4667d52
--- /dev/null
+++ b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj
@@ -0,0 +1,143 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{39038E85-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Capabilities</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Capabilities</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="libsecondlife.dll" >
62 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System" >
66 <HintPath>System.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Xml" >
70 <HintPath>System.Xml.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="XMLRPC.dll" >
74 <HintPath>..\..\..\bin\XMLRPC.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 </ItemGroup>
78 <ItemGroup>
79 <ProjectReference Include="..\..\Framework\General\OpenSim.Framework.csproj">
80 <Name>OpenSim.Framework</Name>
81 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
82 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
83 <Private>False</Private>
84 </ProjectReference>
85 <ProjectReference Include="..\..\Framework\Servers\OpenSim.Framework.Servers.csproj">
86 <Name>OpenSim.Framework.Servers</Name>
87 <Project>{2CC71860-0000-0000-0000-000000000000}</Project>
88 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
89 <Private>False</Private>
90 </ProjectReference>
91 <ProjectReference Include="..\Caches\OpenSim.Region.Caches.csproj">
92 <Name>OpenSim.Region.Caches</Name>
93 <Project>{61FCCDB3-0000-0000-0000-000000000000}</Project>
94 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
95 <Private>False</Private>
96 </ProjectReference>
97 </ItemGroup>
98 <ItemGroup>
99 <Compile Include="Caps.cs">
100 <SubType>Code</SubType>
101 </Compile>
102 <Compile Include="LLSDArray.cs">
103 <SubType>Code</SubType>
104 </Compile>
105 <Compile Include="LLSDCapEvent.cs">
106 <SubType>Code</SubType>
107 </Compile>
108 <Compile Include="LLSDCapsDetails.cs">
109 <SubType>Code</SubType>
110 </Compile>
111 <Compile Include="LLSDEmpty.cs">
112 <SubType>Code</SubType>
113 </Compile>
114 <Compile Include="LLSDHelpers.cs">
115 <SubType>Code</SubType>
116 </Compile>
117 <Compile Include="LLSDMapLayer.cs">
118 <SubType>Code</SubType>
119 </Compile>
120 <Compile Include="LLSDMapLayerResponse.cs">
121 <SubType>Code</SubType>
122 </Compile>
123 <Compile Include="LLSDMapRequest.cs">
124 <SubType>Code</SubType>
125 </Compile>
126 <Compile Include="LLSDTest.cs">
127 <SubType>Code</SubType>
128 </Compile>
129 <Compile Include="LLSDType.cs">
130 <SubType>Code</SubType>
131 </Compile>
132 <Compile Include="LLSDUploadReply.cs">
133 <SubType>Code</SubType>
134 </Compile>
135 </ItemGroup>
136 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
137 <PropertyGroup>
138 <PreBuildEvent>
139 </PreBuildEvent>
140 <PostBuildEvent>
141 </PostBuildEvent>
142 </PropertyGroup>
143</Project>
diff --git a/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build
new file mode 100644
index 0000000..a091b5c
--- /dev/null
+++ b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build
@@ -0,0 +1,56 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Capabilities" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Capabilities" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="Caps.cs" />
15 <include name="LLSDArray.cs" />
16 <include name="LLSDCapEvent.cs" />
17 <include name="LLSDCapsDetails.cs" />
18 <include name="LLSDEmpty.cs" />
19 <include name="LLSDHelpers.cs" />
20 <include name="LLSDMapLayer.cs" />
21 <include name="LLSDMapLayerResponse.cs" />
22 <include name="LLSDMapRequest.cs" />
23 <include name="LLSDTest.cs" />
24 <include name="LLSDType.cs" />
25 <include name="LLSDUploadReply.cs" />
26 </sources>
27 <references basedir="${project::get-base-directory()}">
28 <lib>
29 <include name="${project::get-base-directory()}" />
30 <include name="${project::get-base-directory()}/${build.dir}" />
31 </lib>
32 <include name="../../../bin/libsecondlife.dll" />
33 <include name="../../../bin/OpenSim.Framework.dll" />
34 <include name="../../../bin/OpenSim.Framework.Servers.dll" />
35 <include name="../../../bin/OpenSim.Region.Caches.dll" />
36 <include name="System.dll" />
37 <include name="System.Xml.dll" />
38 <include name="../../../bin/XMLRPC.dll" />
39 </references>
40 </csc>
41 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
42 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
43 <copy todir="${project::get-base-directory()}/../../../bin/">
44 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
45 <include name="*.dll"/>
46 <include name="*.exe"/>
47 </fileset>
48 </copy>
49 </target>
50 <target name="clean">
51 <delete dir="${bin.dir}" failonerror="false" />
52 <delete dir="${obj.dir}" failonerror="false" />
53 </target>
54 <target name="doc" description="Creates documentation.">
55 </target>
56</project>
diff --git a/OpenSim/Region/ClientStack/Assets/InventoryCache.cs b/OpenSim/Region/ClientStack/Assets/InventoryCache.cs
new file mode 100644
index 0000000..da74f85
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Assets/InventoryCache.cs
@@ -0,0 +1,338 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using System.Collections.Generic;
31using libsecondlife;
32using OpenSim;
33using libsecondlife.Packets;
34//using OpenSim.GridServers;
35using OpenSim.Framework.Inventory;
36using OpenSim.Framework.Types;
37using OpenSim.Framework.Interfaces;
38using OpenSim.Region.ClientStack;
39
40namespace OpenSim.Assets
41{
42 /// <summary>
43 /// Description of InventoryManager.
44 /// </summary>
45 public class InventoryCache
46 {
47 private Dictionary<LLUUID, AgentInventory> _agentsInventory;
48 private List<UserServerRequest> _serverRequests; //list of requests made to user server.
49 private System.Text.Encoding _enc = System.Text.Encoding.ASCII;
50 private const uint FULL_MASK_PERMISSIONS = 2147483647;
51
52 public InventoryCache()
53 {
54 _agentsInventory = new Dictionary<LLUUID, AgentInventory>();
55 _serverRequests = new List<UserServerRequest>();
56 }
57
58 public void AddNewAgentsInventory(AgentInventory agentInventory)
59 {
60 if (!this._agentsInventory.ContainsKey(agentInventory.AgentID))
61 {
62 this._agentsInventory.Add(agentInventory.AgentID, agentInventory);
63 }
64 }
65
66 public AgentInventory FetchAgentsInventory(LLUUID agentID, IUserServer userserver)
67 {
68 AgentInventory res = null;
69 if (!this._agentsInventory.ContainsKey(agentID))
70 {
71 res = userserver.RequestAgentsInventory(agentID);
72 this._agentsInventory.Add(agentID,res);
73 }
74 return res;
75 }
76
77 public AgentInventory GetAgentsInventory(LLUUID agentID)
78 {
79 if (this._agentsInventory.ContainsKey(agentID))
80 {
81 return this._agentsInventory[agentID];
82 }
83
84 return null;
85 }
86
87 public void ClientLeaving(LLUUID clientID, IUserServer userserver)
88 {
89 if (this._agentsInventory.ContainsKey(clientID))
90 {
91 if (userserver != null)
92 {
93 userserver.UpdateAgentsInventory(clientID, this._agentsInventory[clientID]);
94 }
95 this._agentsInventory.Remove(clientID);
96 }
97 }
98
99 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID)
100 {
101 return this.CreateNewInventoryFolder(remoteClient, folderID, 0);
102 }
103
104 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type)
105 {
106 bool res = false;
107 if (folderID != LLUUID.Zero) //don't create a folder with a zero id
108 {
109 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
110 {
111 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type);
112 }
113 }
114 return res;
115 }
116
117 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent)
118 {
119 bool res = false;
120 if (folderID != LLUUID.Zero) //don't create a folder with a zero id
121 {
122 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
123 {
124 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type, folderName, parent);
125 }
126 }
127 return res;
128 }
129
130 public LLUUID AddNewInventoryItem(ClientView remoteClient, LLUUID folderID, OpenSim.Framework.Types.AssetBase asset)
131 {
132 LLUUID newItem = null;
133 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
134 {
135 newItem = this._agentsInventory[remoteClient.AgentID].AddToInventory(folderID, asset);
136 if (newItem != null)
137 {
138 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[newItem];
139 this.SendItemUpdateCreate(remoteClient, Item);
140 }
141 }
142
143 return newItem;
144 }
145 public bool DeleteInventoryItem(ClientView remoteClient, LLUUID itemID)
146 {
147 bool res = false;
148 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
149 {
150 res = this._agentsInventory[remoteClient.AgentID].DeleteFromInventory(itemID);
151 if (res)
152 {
153 RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket();
154 remove.AgentData.AgentID = remoteClient.AgentID;
155 remove.AgentData.SessionID = remoteClient.SessionID;
156 remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
157 remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
158 remove.InventoryData[0].ItemID = itemID;
159 remoteClient.OutPacket(remove);
160 }
161 }
162
163 return res;
164 }
165
166 public bool UpdateInventoryItemAsset(ClientView remoteClient, LLUUID itemID, OpenSim.Framework.Types.AssetBase asset)
167 {
168 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
169 {
170 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemAsset(itemID, asset);
171 if (res)
172 {
173 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
174 this.SendItemUpdateCreate(remoteClient, Item);
175 }
176 return res;
177 }
178
179 return false;
180 }
181
182 public bool UpdateInventoryItemDetails(ClientView remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
183 {
184 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
185 {
186 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemDetails(itemID, packet);
187 if (res)
188 {
189 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
190 this.SendItemUpdateCreate(remoteClient, Item);
191 }
192 return res;
193 }
194
195 return false;
196 }
197
198 public void FetchInventoryDescendents(ClientView userInfo, FetchInventoryDescendentsPacket FetchDescend)
199 {
200 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
201 {
202 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
203 if (FetchDescend.InventoryData.FetchItems)
204 {
205 if (agentInventory.InventoryFolders.ContainsKey(FetchDescend.InventoryData.FolderID))
206 {
207 InventoryFolder Folder = agentInventory.InventoryFolders[FetchDescend.InventoryData.FolderID];
208 InventoryDescendentsPacket Descend = new InventoryDescendentsPacket();
209 Descend.AgentData.AgentID = userInfo.AgentID;
210 Descend.AgentData.OwnerID = Folder.OwnerID;
211 Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID;
212 Descend.AgentData.Descendents = Folder.Items.Count;
213 Descend.AgentData.Version = Folder.Items.Count;
214
215
216 Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count];
217 for (int i = 0; i < Folder.Items.Count; i++)
218 {
219
220 InventoryItem Item = Folder.Items[i];
221 Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
222 Descend.ItemData[i].ItemID = Item.ItemID;
223 Descend.ItemData[i].AssetID = Item.AssetID;
224 Descend.ItemData[i].CreatorID = Item.CreatorID;
225 Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS;
226 Descend.ItemData[i].CreationDate = 1000;
227 Descend.ItemData[i].Description = _enc.GetBytes(Item.Description + "\0");
228 Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS;
229 Descend.ItemData[i].Flags = 1;
230 Descend.ItemData[i].FolderID = Item.FolderID;
231 Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
232 Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS;
233 Descend.ItemData[i].InvType = Item.InvType;
234 Descend.ItemData[i].Name = _enc.GetBytes(Item.Name + "\0");
235 Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS;
236 Descend.ItemData[i].OwnerID = Item.OwnerID;
237 Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS;
238 Descend.ItemData[i].SalePrice = 100;
239 Descend.ItemData[i].SaleType = 0;
240 Descend.ItemData[i].Type = Item.Type;
241 Descend.ItemData[i].CRC = libsecondlife.Helpers.InventoryCRC(1000, 0, Descend.ItemData[i].InvType, Descend.ItemData[i].Type, Descend.ItemData[i].AssetID, Descend.ItemData[i].GroupID, 100, Descend.ItemData[i].OwnerID, Descend.ItemData[i].CreatorID, Descend.ItemData[i].ItemID, Descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
242 }
243
244 userInfo.OutPacket(Descend);
245
246 }
247 }
248 else
249 {
250 Console.WriteLine("fetch subfolders");
251 }
252 }
253 }
254
255 public void FetchInventory(ClientView userInfo, FetchInventoryPacket FetchItems)
256 {
257 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
258 {
259 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
260
261 for (int i = 0; i < FetchItems.InventoryData.Length; i++)
262 {
263 if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID))
264 {
265 InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID];
266 FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket();
267 InventoryReply.AgentData.AgentID = userInfo.AgentID;
268 InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
269 InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
270 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
271 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
272 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
273 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
274 InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
275 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0");
276 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
277 InventoryReply.InventoryData[0].Flags = 0;
278 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
279 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
280 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
281 InventoryReply.InventoryData[0].InvType = Item.InvType;
282 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0");
283 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
284 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
285 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
286 InventoryReply.InventoryData[0].SalePrice = 100;
287 InventoryReply.InventoryData[0].SaleType = 0;
288 InventoryReply.InventoryData[0].Type = Item.Type;
289 InventoryReply.InventoryData[0].CRC = libsecondlife.Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
290 userInfo.OutPacket(InventoryReply);
291 }
292 }
293 }
294 }
295
296 private void SendItemUpdateCreate(ClientView remoteClient, InventoryItem Item)
297 {
298
299 UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket();
300 InventoryReply.AgentData.AgentID = remoteClient.AgentID;
301 InventoryReply.AgentData.SimApproved = true;
302 InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
303 InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
304 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
305 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
306 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
307 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
308 InventoryReply.InventoryData[0].CreationDate = 1000;
309 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0");
310 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
311 InventoryReply.InventoryData[0].Flags = 0;
312 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
313 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
314 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
315 InventoryReply.InventoryData[0].InvType = Item.InvType;
316 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0");
317 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
318 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
319 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
320 InventoryReply.InventoryData[0].SalePrice = 100;
321 InventoryReply.InventoryData[0].SaleType = 0;
322 InventoryReply.InventoryData[0].Type = Item.Type;
323 InventoryReply.InventoryData[0].CRC = libsecondlife.Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
324
325 remoteClient.OutPacket(InventoryReply);
326 }
327 }
328
329
330
331 public class UserServerRequest
332 {
333 public UserServerRequest()
334 {
335
336 }
337 }
338}
diff --git a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs
new file mode 100644
index 0000000..f99cf79
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs
@@ -0,0 +1,46 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using System.Net;
32using System.Net.Sockets;
33using libsecondlife;
34
35
36namespace OpenSim.Region.ClientStack
37{
38
39 public interface ClientStackNetworkHandler
40 {
41 void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender);
42 void RemoveClientCircuit(uint circuitcode);
43 void RegisterPacketServer(PacketServer server);
44 }
45
46}
diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs
new file mode 100644
index 0000000..9650b42
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientView.API.cs
@@ -0,0 +1,976 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Framework.Interfaces;
32using OpenSim.Framework.Inventory;
33using OpenSim.Framework.Types;
34
35using libsecondlife;
36using libsecondlife.Packets;
37
38namespace OpenSim.Region.ClientStack
39{
40 partial class ClientView
41 {
42 public event ChatFromViewer OnChatFromViewer;
43 public event RezObject OnRezObject;
44 public event GenericCall4 OnDeRezObject;
45 public event ModifyTerrain OnModifyTerrain;
46 public event GenericCall OnRegionHandShakeReply;
47 public event GenericCall OnRequestWearables;
48 public event SetAppearance OnSetAppearance;
49 public event GenericCall2 OnCompleteMovementToRegion;
50 public event UpdateAgent OnAgentUpdate;
51 public event StartAnim OnStartAnim;
52 public event GenericCall OnRequestAvatarsData;
53 public event LinkObjects OnLinkObjects;
54 public event UpdateVector OnGrapObject;
55 public event ObjectSelect OnDeGrapObject;
56 public event MoveObject OnGrapUpdate;
57 public event GenericCall4 OnAddPrim;
58 public event UpdateShape OnUpdatePrimShape;
59 public event ObjectSelect OnObjectSelect;
60 public event UpdatePrimFlags OnUpdatePrimFlags;
61 public event UpdatePrimTexture OnUpdatePrimTexture;
62 public event UpdateVector OnUpdatePrimPosition;
63 public event UpdatePrimRotation OnUpdatePrimRotation;
64 public event UpdateVector OnUpdatePrimScale;
65 public event StatusChange OnChildAgentStatus;
66 public event GenericCall2 OnStopMovement;
67 public event NewAvatar OnNewAvatar;
68 public event GenericCall6 OnRemoveAvatar;
69 public event RequestMapBlocks OnRequestMapBlocks;
70 public event TeleportLocationRequest OnTeleportLocationRequest;
71
72 public event UUIDNameRequest OnNameFromUUIDRequest;
73
74 public event ParcelPropertiesRequest OnParcelPropertiesRequest;
75 public event ParcelDivideRequest OnParcelDivideRequest;
76 public event ParcelJoinRequest OnParcelJoinRequest;
77 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
78
79 public event EstateOwnerMessageRequest OnEstateOwnerMessage;
80 /// <summary>
81 ///
82 /// </summary>
83 public LLVector3 StartPos
84 {
85 get
86 {
87 return startpos;
88 }
89 set
90 {
91 startpos = value;
92 }
93 }
94
95 /// <summary>
96 ///
97 /// </summary>
98 public LLUUID AgentId
99 {
100 get
101 {
102 return this.AgentID;
103 }
104 }
105
106 /// <summary>
107 ///
108 /// </summary>
109 public string FirstName
110 {
111 get
112 {
113 return this.firstName;
114 }
115
116 }
117
118 /// <summary>
119 ///
120 /// </summary>
121 public string LastName
122 {
123 get
124 {
125 return this.lastName;
126 }
127 }
128
129 #region World/Avatar to Client
130
131 /// <summary>
132 ///
133 /// </summary>
134 /// <param name="regionInfo"></param>
135 public void SendRegionHandshake(RegionInfo regionInfo)
136 {
137 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
138 RegionHandshakePacket handshake = new RegionHandshakePacket();
139
140 handshake.RegionInfo.BillableFactor = regionInfo.estateSettings.billableFactor;
141 handshake.RegionInfo.IsEstateManager = false;
142 handshake.RegionInfo.TerrainHeightRange00 = regionInfo.estateSettings.terrainHeightRange0;
143 handshake.RegionInfo.TerrainHeightRange01 = regionInfo.estateSettings.terrainHeightRange1;
144 handshake.RegionInfo.TerrainHeightRange10 = regionInfo.estateSettings.terrainHeightRange2;
145 handshake.RegionInfo.TerrainHeightRange11 = regionInfo.estateSettings.terrainHeightRange3;
146 handshake.RegionInfo.TerrainStartHeight00 = regionInfo.estateSettings.terrainStartHeight0;
147 handshake.RegionInfo.TerrainStartHeight01 = regionInfo.estateSettings.terrainStartHeight1;
148 handshake.RegionInfo.TerrainStartHeight10 = regionInfo.estateSettings.terrainStartHeight2;
149 handshake.RegionInfo.TerrainStartHeight11 = regionInfo.estateSettings.terrainStartHeight3;
150 handshake.RegionInfo.SimAccess = (byte)regionInfo.estateSettings.simAccess;
151 handshake.RegionInfo.WaterHeight = regionInfo.estateSettings.waterHeight;
152
153
154 handshake.RegionInfo.RegionFlags = (uint)regionInfo.estateSettings.regionFlags;
155
156 handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0");
157 handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID;
158 handshake.RegionInfo.TerrainBase0 = regionInfo.estateSettings.terrainBase0;
159 handshake.RegionInfo.TerrainBase1 = regionInfo.estateSettings.terrainBase1;
160 handshake.RegionInfo.TerrainBase2 = regionInfo.estateSettings.terrainBase2;
161 handshake.RegionInfo.TerrainBase3 = regionInfo.estateSettings.terrainBase3;
162 handshake.RegionInfo.TerrainDetail0 = regionInfo.estateSettings.terrainDetail0;
163 handshake.RegionInfo.TerrainDetail1 = regionInfo.estateSettings.terrainDetail1;
164 handshake.RegionInfo.TerrainDetail2 = regionInfo.estateSettings.terrainDetail2;
165 handshake.RegionInfo.TerrainDetail3 = regionInfo.estateSettings.terrainDetail3;
166 handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting?
167
168 this.OutPacket(handshake);
169 }
170
171 /// <summary>
172 ///
173 /// </summary>
174 /// <param name="regInfo"></param>
175 public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look)
176 {
177 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
178 mov.AgentData.SessionID = this.SessionID;
179 mov.AgentData.AgentID = this.AgentID;
180 mov.Data.RegionHandle = regInfo.RegionHandle;
181 mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this
182
183 if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
184 {
185 mov.Data.Position = this.startpos;
186 }
187 else
188 {
189 mov.Data.Position = pos;
190 }
191 mov.Data.LookAt = look;
192
193 OutPacket(mov);
194 }
195
196 /// <summary>
197 ///
198 /// </summary>
199 /// <param name="message"></param>
200 /// <param name="type"></param>
201 /// <param name="fromPos"></param>
202 /// <param name="fromName"></param>
203 /// <param name="fromAgentID"></param>
204 public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
205 {
206 SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID);
207 }
208
209 /// <summary>
210 ///
211 /// </summary>
212 /// <param name="message"></param>
213 /// <param name="type"></param>
214 /// <param name="fromPos"></param>
215 /// <param name="fromName"></param>
216 /// <param name="fromAgentID"></param>
217 public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
218 {
219 System.Text.Encoding enc = System.Text.Encoding.ASCII;
220 libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
221 reply.ChatData.Audible = 1;
222 reply.ChatData.Message = message;
223 reply.ChatData.ChatType = type;
224 reply.ChatData.SourceType = 1;
225 reply.ChatData.Position = fromPos;
226 reply.ChatData.FromName = enc.GetBytes(fromName + "\0");
227 reply.ChatData.OwnerID = fromAgentID;
228 reply.ChatData.SourceID = fromAgentID;
229
230 this.OutPacket(reply);
231 }
232
233
234 /// <summary>
235 /// Send the region heightmap to the client
236 /// </summary>
237 /// <param name="map">heightmap</param>
238 public virtual void SendLayerData(float[] map)
239 {
240 try
241 {
242 int[] patches = new int[4];
243
244 for (int y = 0; y < 16; y++)
245 {
246 for (int x = 0; x < 16; x = x + 4)
247 {
248 patches[0] = x + 0 + y * 16;
249 patches[1] = x + 1 + y * 16;
250 patches[2] = x + 2 + y * 16;
251 patches[3] = x + 3 + y * 16;
252
253 Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
254 OutPacket(layerpack);
255 }
256 }
257 }
258 catch (Exception e)
259 {
260 OpenSim.Framework.Console.MainLog.Instance.Warn("ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString());
261 }
262 }
263
264 /// <summary>
265 /// Sends a specified patch to a client
266 /// </summary>
267 /// <param name="px">Patch coordinate (x) 0..16</param>
268 /// <param name="py">Patch coordinate (y) 0..16</param>
269 /// <param name="map">heightmap</param>
270 public void SendLayerData(int px, int py, float[] map)
271 {
272 try
273 {
274 int[] patches = new int[1];
275 int patchx, patchy;
276 patchx = px / 16;
277 patchy = py / 16;
278
279 patches[0] = patchx + 0 + patchy * 16;
280
281 Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
282 OutPacket(layerpack);
283 }
284 catch (Exception e)
285 {
286 OpenSim.Framework.Console.MainLog.Instance.Warn("ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString());
287 }
288 }
289
290 /// <summary>
291 ///
292 /// </summary>
293 /// <param name="neighbourHandle"></param>
294 /// <param name="neighbourIP"></param>
295 /// <param name="neighbourPort"></param>
296 public void InformClientOfNeighbour(ulong neighbourHandle, System.Net.IPAddress neighbourIP, ushort neighbourPort)
297 {
298 EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
299 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
300 enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
301
302 byte[] byteIP = neighbourIP.GetAddressBytes();
303 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
304 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
305 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
306 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
307 enablesimpacket.SimulatorInfo.Port = neighbourPort;
308 OutPacket(enablesimpacket);
309 }
310
311 /// <summary>
312 ///
313 /// </summary>
314 /// <returns></returns>
315 public AgentCircuitData RequestClientInfo()
316 {
317 AgentCircuitData agentData = new AgentCircuitData();
318 agentData.AgentID = this.AgentId;
319 agentData.SessionID = this.SessionID;
320 agentData.SecureSessionID = this.SecureSessionID;
321 agentData.circuitcode = this.CircuitCode;
322 agentData.child = false;
323 agentData.firstname = this.firstName;
324 agentData.lastname = this.lastName;
325
326 return agentData;
327 }
328
329 public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, System.Net.IPAddress newRegionIP, ushort newRegionPort)
330 {
331 LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
332
333 CrossedRegionPacket newSimPack = new CrossedRegionPacket();
334 newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
335 newSimPack.AgentData.AgentID = this.AgentID;
336 newSimPack.AgentData.SessionID = this.SessionID;
337 newSimPack.Info = new CrossedRegionPacket.InfoBlock();
338 newSimPack.Info.Position = pos;
339 newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
340 newSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock();
341 newSimPack.RegionData.RegionHandle = newRegionHandle;
342 byte[] byteIP = newRegionIP.GetAddressBytes();
343 newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
344 newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
345 newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
346 newSimPack.RegionData.SimIP += (uint)byteIP[0];
347 newSimPack.RegionData.SimPort = newRegionPort;
348 newSimPack.RegionData.SeedCapability = new byte[0];
349
350 this.OutPacket(newSimPack);
351 //this.DowngradeClient();
352 }
353
354 public void SendMapBlock(List<MapBlockData> mapBlocks)
355 {
356 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
357
358 MapBlockReplyPacket mapReply = new MapBlockReplyPacket();
359 mapReply.AgentData.AgentID = this.AgentID;
360 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count];
361 mapReply.AgentData.Flags = 0;
362
363 for (int i = 0; i < mapBlocks.Count; i++)
364 {
365 mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
366 mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId;
367 mapReply.Data[i].X = mapBlocks[i].X;
368 mapReply.Data[i].Y = mapBlocks[i].Y;
369 mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight;
370 mapReply.Data[i].Name = _enc.GetBytes(mapBlocks[i].Name);
371 mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags;
372 mapReply.Data[i].Access = mapBlocks[i].Access;
373 mapReply.Data[i].Agents = mapBlocks[i].Agents;
374 }
375 this.OutPacket(mapReply);
376 }
377
378 public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags)
379 {
380 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
381 tpLocal.Info.AgentID = this.AgentID;
382 tpLocal.Info.TeleportFlags = flags;
383 tpLocal.Info.LocationID = 2;
384 tpLocal.Info.LookAt = lookAt;
385 tpLocal.Info.Position = position;
386 OutPacket(tpLocal);
387 }
388
389 public void SendRegionTeleport(ulong regionHandle, byte simAccess, string ipAddress, ushort ipPort, uint locationID, uint flags)
390 {
391 TeleportFinishPacket teleport = new TeleportFinishPacket();
392 teleport.Info.AgentID = this.AgentID;
393 teleport.Info.RegionHandle = regionHandle;
394 teleport.Info.SimAccess = simAccess;
395 teleport.Info.SeedCapability = new byte[0];
396
397 System.Net.IPAddress oIP = System.Net.IPAddress.Parse(ipAddress);
398 byte[] byteIP = oIP.GetAddressBytes();
399 uint ip = (uint)byteIP[3] << 24;
400 ip += (uint)byteIP[2] << 16;
401 ip += (uint)byteIP[1] << 8;
402 ip += (uint)byteIP[0];
403
404 teleport.Info.SimIP = ip;
405 teleport.Info.SimPort = ipPort;
406 teleport.Info.LocationID = 4;
407 teleport.Info.TeleportFlags = 1 << 4;
408 OutPacket(teleport);
409 }
410
411 /// <summary>
412 ///
413 /// </summary>
414 public void SendTeleportCancel()
415 {
416 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
417 tpCancel.Info.SessionID = this.SessionID;
418 tpCancel.Info.AgentID = this.AgentID;
419
420 OutPacket(tpCancel);
421 }
422
423 /// <summary>
424 ///
425 /// </summary>
426 public void SendTeleportLocationStart()
427 {
428 TeleportStartPacket tpStart = new TeleportStartPacket();
429 tpStart.Info.TeleportFlags = 16; // Teleport via location
430 OutPacket(tpStart);
431 }
432
433 public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance)
434 {
435 MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket();
436 money.MoneyData.AgentID = this.AgentID;
437 money.MoneyData.TransactionID = transaction;
438 money.MoneyData.TransactionSuccess = success;
439 money.MoneyData.Description = description;
440 money.MoneyData.MoneyBalance = balance;
441 OutPacket(money);
442 }
443
444 #region Appearance/ Wearables Methods
445
446 /// <summary>
447 ///
448 /// </summary>
449 /// <param name="wearables"></param>
450 public void SendWearables(AvatarWearable[] wearables)
451 {
452 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
453 aw.AgentData.AgentID = this.AgentID;
454 aw.AgentData.SerialNum = 0;
455 aw.AgentData.SessionID = this.SessionID;
456
457 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
458 AgentWearablesUpdatePacket.WearableDataBlock awb;
459 for (int i = 0; i < wearables.Length; i++)
460 {
461 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
462 awb.WearableType = (byte)i;
463 awb.AssetID = wearables[i].AssetID;
464 awb.ItemID = wearables[i].ItemID;
465 aw.WearableData[i] = awb;
466 }
467
468 this.OutPacket(aw);
469 }
470
471 /// <summary>
472 ///
473 /// </summary>
474 /// <param name="agentID"></param>
475 /// <param name="visualParams"></param>
476 /// <param name="textureEntry"></param>
477 public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry)
478 {
479 AvatarAppearancePacket avp = new AvatarAppearancePacket();
480 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
481 avp.ObjectData.TextureEntry = textureEntry;
482
483 AvatarAppearancePacket.VisualParamBlock avblock = null;
484 for (int i = 0; i < visualParams.Length; i++)
485 {
486 avblock = new AvatarAppearancePacket.VisualParamBlock();
487 avblock.ParamValue = visualParams[i];
488 avp.VisualParam[i] = avblock;
489 }
490
491 avp.Sender.IsTrial = false;
492 avp.Sender.ID = agentID;
493 OutPacket(avp);
494 }
495
496 #endregion
497
498 #region Avatar Packet/data sending Methods
499
500 /// <summary>
501 ///
502 /// </summary>
503 /// <param name="regionInfo"></param>
504 /// <param name="firstName"></param>
505 /// <param name="lastName"></param>
506 /// <param name="avatarID"></param>
507 /// <param name="avatarLocalID"></param>
508 /// <param name="Pos"></param>
509 public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry)
510 {
511 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
512 //send a objectupdate packet with information about the clients avatar
513
514 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
515 objupdate.RegionData.RegionHandle = regionHandle;
516 objupdate.RegionData.TimeDilation = 64096;
517 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
518 objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket(textureEntry);
519 //give this avatar object a local id and assign the user a name
520
521 objupdate.ObjectData[0].ID = avatarLocalID;
522 objupdate.ObjectData[0].FullID = avatarID;
523 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName + " \0");
524 libsecondlife.LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z);
525 byte[] pb = pos2.GetBytes();
526 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
527
528 OutPacket(objupdate);
529
530 }
531
532 /// <summary>
533 ///
534 /// </summary>
535 /// <param name="regionHandle"></param>
536 /// <param name="timeDilation"></param>
537 /// <param name="localID"></param>
538 /// <param name="position"></param>
539 /// <param name="velocity"></param>
540 public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity)
541 {
542 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity);
543 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
544 terse.RegionData.RegionHandle = regionHandle;
545 terse.RegionData.TimeDilation = timeDilation;
546 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
547 terse.ObjectData[0] = terseBlock;
548
549 this.OutPacket(terse);
550 }
551
552 #endregion
553
554 #region Primitive Packet/data Sending Methods
555
556 /// <summary>
557 ///
558 /// </summary>
559 /// <param name="localID"></param>
560 /// <param name="rotation"></param>
561 /// <param name="attachPoint"></param>
562 public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint)
563 {
564 ObjectAttachPacket attach = new ObjectAttachPacket();
565 attach.AgentData.AgentID = this.AgentID;
566 attach.AgentData.SessionID = this.SessionID;
567 attach.AgentData.AttachmentPoint = attachPoint;
568 attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1];
569 attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock();
570 attach.ObjectData[0].ObjectLocalID = localID;
571 attach.ObjectData[0].Rotation = rotation;
572
573 this.OutPacket(attach);
574 }
575
576 /// <summary>
577 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive
578 /// or big changes to a existing primitive.
579 /// </summary>
580 /// <param name="regionHandle"></param>
581 /// <param name="timeDilation"></param>
582 /// <param name="localID"></param>
583 /// <param name="primData"></param>
584 /// <param name="pos"></param>
585 /// <param name="rotation"></param>
586 /// <param name="textureID"></param>
587 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags)
588 {
589 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
590 outPacket.RegionData.RegionHandle = regionHandle;
591 outPacket.RegionData.TimeDilation = timeDilation;
592 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
593 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags);
594 outPacket.ObjectData[0].ID = localID;
595 outPacket.ObjectData[0].FullID = primData.FullID;
596 byte[] pb = pos.GetBytes();
597 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
598 byte[] rot = rotation.GetBytes();
599 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 48, rot.Length);
600 OutPacket(outPacket);
601 }
602
603 /// <summary>
604 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive
605 /// or big changes to a existing primitive.
606 /// Uses default rotation
607 /// </summary>
608 /// <param name="primData"></param>
609 /// <param name="pos"></param>
610 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID , uint flags)
611 {
612 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
613 outPacket.RegionData.RegionHandle = regionHandle;
614 outPacket.RegionData.TimeDilation = timeDilation;
615 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
616 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags);
617 outPacket.ObjectData[0].ID = localID;
618 outPacket.ObjectData[0].FullID = primData.FullID;
619 byte[] pb = pos.GetBytes();
620 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
621
622 OutPacket(outPacket);
623 }
624
625 /// <summary>
626 ///
627 /// </summary>
628 /// <param name="regionHandle"></param>
629 /// <param name="timeDilation"></param>
630 /// <param name="localID"></param>
631 /// <param name="position"></param>
632 /// <param name="rotation"></param>
633 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation)
634 {
635 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
636 terse.RegionData.RegionHandle = regionHandle;
637 terse.RegionData.TimeDilation = timeDilation;
638 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
639 terse.ObjectData[0] = this.CreatePrimImprovedBlock(localID, position, rotation);
640
641 this.OutPacket(terse);
642 }
643
644 #endregion
645
646 #endregion
647
648 #region Helper Methods
649
650 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity)
651 {
652 byte[] bytes = new byte[60];
653 int i = 0;
654 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
655
656 dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
657
658 uint ID = localID;
659
660 bytes[i++] = (byte)(ID % 256);
661 bytes[i++] = (byte)((ID >> 8) % 256);
662 bytes[i++] = (byte)((ID >> 16) % 256);
663 bytes[i++] = (byte)((ID >> 24) % 256);
664 bytes[i++] = 0;
665 bytes[i++] = 1;
666 i += 14;
667 bytes[i++] = 128;
668 bytes[i++] = 63;
669
670 byte[] pb = pos.GetBytes();
671 Array.Copy(pb, 0, bytes, i, pb.Length);
672 i += 12;
673 ushort InternVelocityX;
674 ushort InternVelocityY;
675 ushort InternVelocityZ;
676 Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(0, 0, 0);
677
678 internDirec = new Axiom.MathLib.Vector3(velocity.X, velocity.Y, velocity.Z);
679
680 internDirec = internDirec / 128.0f;
681 internDirec.x += 1;
682 internDirec.y += 1;
683 internDirec.z += 1;
684
685 InternVelocityX = (ushort)(32768 * internDirec.x);
686 InternVelocityY = (ushort)(32768 * internDirec.y);
687 InternVelocityZ = (ushort)(32768 * internDirec.z);
688
689 ushort ac = 32767;
690 bytes[i++] = (byte)(InternVelocityX % 256);
691 bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
692 bytes[i++] = (byte)(InternVelocityY % 256);
693 bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
694 bytes[i++] = (byte)(InternVelocityZ % 256);
695 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
696
697 //accel
698 bytes[i++] = (byte)(ac % 256);
699 bytes[i++] = (byte)((ac >> 8) % 256);
700 bytes[i++] = (byte)(ac % 256);
701 bytes[i++] = (byte)((ac >> 8) % 256);
702 bytes[i++] = (byte)(ac % 256);
703 bytes[i++] = (byte)((ac >> 8) % 256);
704
705 //rot
706 bytes[i++] = (byte)(ac % 256);
707 bytes[i++] = (byte)((ac >> 8) % 256);
708 bytes[i++] = (byte)(ac % 256);
709 bytes[i++] = (byte)((ac >> 8) % 256);
710 bytes[i++] = (byte)(ac % 256);
711 bytes[i++] = (byte)((ac >> 8) % 256);
712 bytes[i++] = (byte)(ac % 256);
713 bytes[i++] = (byte)((ac >> 8) % 256);
714
715 //rotation vel
716 bytes[i++] = (byte)(ac % 256);
717 bytes[i++] = (byte)((ac >> 8) % 256);
718 bytes[i++] = (byte)(ac % 256);
719 bytes[i++] = (byte)((ac >> 8) % 256);
720 bytes[i++] = (byte)(ac % 256);
721 bytes[i++] = (byte)((ac >> 8) % 256);
722
723 dat.Data = bytes;
724 return (dat);
725 }
726
727 /// <summary>
728 ///
729 /// </summary>
730 /// <param name="localID"></param>
731 /// <param name="position"></param>
732 /// <param name="rotation"></param>
733 /// <returns></returns>
734 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, LLQuaternion rotation)
735 {
736 uint ID = localID;
737 byte[] bytes = new byte[60];
738
739 int i = 0;
740 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
741 dat.TextureEntry = new byte[0];
742 bytes[i++] = (byte)(ID % 256);
743 bytes[i++] = (byte)((ID >> 8) % 256);
744 bytes[i++] = (byte)((ID >> 16) % 256);
745 bytes[i++] = (byte)((ID >> 24) % 256);
746 bytes[i++] = 0;
747 bytes[i++] = 0;
748
749 byte[] pb = position.GetBytes();
750 Array.Copy(pb, 0, bytes, i, pb.Length);
751 i += 12;
752 ushort ac = 32767;
753
754 //vel
755 bytes[i++] = (byte)(ac % 256);
756 bytes[i++] = (byte)((ac >> 8) % 256);
757 bytes[i++] = (byte)(ac % 256);
758 bytes[i++] = (byte)((ac >> 8) % 256);
759 bytes[i++] = (byte)(ac % 256);
760 bytes[i++] = (byte)((ac >> 8) % 256);
761
762 //accel
763 bytes[i++] = (byte)(ac % 256);
764 bytes[i++] = (byte)((ac >> 8) % 256);
765 bytes[i++] = (byte)(ac % 256);
766 bytes[i++] = (byte)((ac >> 8) % 256);
767 bytes[i++] = (byte)(ac % 256);
768 bytes[i++] = (byte)((ac >> 8) % 256);
769
770 ushort rw, rx, ry, rz;
771 rw = (ushort)(32768 * (rotation.W + 1));
772 rx = (ushort)(32768 * (rotation.X + 1));
773 ry = (ushort)(32768 * (rotation.Y + 1));
774 rz = (ushort)(32768 * (rotation.Z + 1));
775
776 //rot
777 bytes[i++] = (byte)(rx % 256);
778 bytes[i++] = (byte)((rx >> 8) % 256);
779 bytes[i++] = (byte)(ry % 256);
780 bytes[i++] = (byte)((ry >> 8) % 256);
781 bytes[i++] = (byte)(rz % 256);
782 bytes[i++] = (byte)((rz >> 8) % 256);
783 bytes[i++] = (byte)(rw % 256);
784 bytes[i++] = (byte)((rw >> 8) % 256);
785
786 //rotation vel
787 bytes[i++] = (byte)(ac % 256);
788 bytes[i++] = (byte)((ac >> 8) % 256);
789 bytes[i++] = (byte)(ac % 256);
790 bytes[i++] = (byte)((ac >> 8) % 256);
791 bytes[i++] = (byte)(ac % 256);
792 bytes[i++] = (byte)((ac >> 8) % 256);
793
794 dat.Data = bytes;
795 return dat;
796 }
797
798
799 /// <summary>
800 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive)
801 /// </summary>
802 /// <param name="primData"></param>
803 /// <returns></returns>
804 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimData primData, LLUUID textureID, uint flags)
805 {
806 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
807 this.SetDefaultPrimPacketValues(objupdate);
808 objupdate.UpdateFlags = flags;
809 this.SetPrimPacketShapeData(objupdate, primData, textureID);
810
811 return objupdate;
812 }
813
814 /// <summary>
815 /// Copy the data from a PrimData object to a ObjectUpdatePacket
816 /// </summary>
817 /// <param name="objectData"></param>
818 /// <param name="primData"></param>
819 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimData primData, LLUUID textureID)
820 {
821 LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID);
822 objectData.TextureEntry = ntex.ToBytes();
823 objectData.OwnerID = primData.OwnerID;
824 objectData.PCode = primData.PCode;
825 objectData.PathBegin = primData.PathBegin;
826 objectData.PathEnd = primData.PathEnd;
827 objectData.PathScaleX = primData.PathScaleX;
828 objectData.PathScaleY = primData.PathScaleY;
829 objectData.PathShearX = primData.PathShearX;
830 objectData.PathShearY = primData.PathShearY;
831 objectData.PathSkew = primData.PathSkew;
832 objectData.ProfileBegin = primData.ProfileBegin;
833 objectData.ProfileEnd = primData.ProfileEnd;
834 objectData.Scale = primData.Scale;
835 objectData.PathCurve = primData.PathCurve;
836 objectData.ProfileCurve = primData.ProfileCurve;
837 objectData.ParentID = primData.ParentID;
838 objectData.ProfileHollow = primData.ProfileHollow;
839 objectData.PathRadiusOffset = primData.PathRadiusOffset;
840 objectData.PathRevolutions = primData.PathRevolutions;
841 objectData.PathTaperX = primData.PathTaperX;
842 objectData.PathTaperY = primData.PathTaperY;
843 objectData.PathTwist = primData.PathTwist;
844 objectData.PathTwistBegin = primData.PathTwistBegin;
845 }
846
847 /// <summary>
848 /// Set some default values in a ObjectUpdatePacket
849 /// </summary>
850 /// <param name="objdata"></param>
851 protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
852 {
853 objdata.PSBlock = new byte[0];
854 objdata.ExtraParams = new byte[1];
855 objdata.MediaURL = new byte[0];
856 objdata.NameValue = new byte[0];
857 objdata.Text = new byte[0];
858 objdata.TextColor = new byte[4];
859 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
860 objdata.JointPivot = new LLVector3(0, 0, 0);
861 objdata.Material = 3;
862 objdata.TextureAnim = new byte[0];
863 objdata.Sound = LLUUID.Zero;
864 objdata.State = 0;
865 objdata.Data = new byte[0];
866
867 objdata.ObjectData = new byte[60];
868 objdata.ObjectData[46] = 128;
869 objdata.ObjectData[47] = 63;
870 }
871
872
873 /// <summary>
874 ///
875 /// </summary>
876 /// <returns></returns>
877 protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry)
878 {
879 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
880
881 SetDefaultAvatarPacketValues(ref objdata);
882 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24);
883 objdata.PathCurve = 16;
884 objdata.ProfileCurve = 1;
885 objdata.PathScaleX = 100;
886 objdata.PathScaleY = 100;
887 objdata.ParentID = 0;
888 objdata.OwnerID = LLUUID.Zero;
889 objdata.Scale = new LLVector3(1, 1, 1);
890 objdata.PCode = 47;
891 if (textureEntry != null)
892 {
893 objdata.TextureEntry = textureEntry;
894 }
895 System.Text.Encoding enc = System.Text.Encoding.ASCII;
896 libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
897 pos.X = 100f;
898 objdata.ID = 8880000;
899 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
900 libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100f, 23f);
901 //objdata.FullID=user.AgentID;
902 byte[] pb = pos.GetBytes();
903 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
904
905 return objdata;
906 }
907
908 /// <summary>
909 ///
910 /// </summary>
911 /// <param name="objdata"></param>
912 protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata)
913 {
914 objdata.PSBlock = new byte[0];
915 objdata.ExtraParams = new byte[1];
916 objdata.MediaURL = new byte[0];
917 objdata.NameValue = new byte[0];
918 objdata.Text = new byte[0];
919 objdata.TextColor = new byte[4];
920 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
921 objdata.JointPivot = new LLVector3(0, 0, 0);
922 objdata.Material = 4;
923 objdata.TextureAnim = new byte[0];
924 objdata.Sound = LLUUID.Zero;
925 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
926 objdata.TextureEntry = ntex.ToBytes();
927 objdata.State = 0;
928 objdata.Data = new byte[0];
929
930 objdata.ObjectData = new byte[76];
931 objdata.ObjectData[15] = 128;
932 objdata.ObjectData[16] = 63;
933 objdata.ObjectData[56] = 128;
934 objdata.ObjectData[61] = 102;
935 objdata.ObjectData[62] = 40;
936 objdata.ObjectData[63] = 61;
937 objdata.ObjectData[64] = 189;
938 }
939
940 /// <summary>
941 ///
942 /// </summary>
943 /// <param name="addPacket"></param>
944 /// <returns></returns>
945 protected PrimData CreatePrimFromObjectAdd(ObjectAddPacket addPacket)
946 {
947 PrimData PData = new PrimData();
948 PData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
949 PData.PCode = addPacket.ObjectData.PCode;
950 PData.PathBegin = addPacket.ObjectData.PathBegin;
951 PData.PathEnd = addPacket.ObjectData.PathEnd;
952 PData.PathScaleX = addPacket.ObjectData.PathScaleX;
953 PData.PathScaleY = addPacket.ObjectData.PathScaleY;
954 PData.PathShearX = addPacket.ObjectData.PathShearX;
955 PData.PathShearY = addPacket.ObjectData.PathShearY;
956 PData.PathSkew = addPacket.ObjectData.PathSkew;
957 PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
958 PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
959 PData.Scale = addPacket.ObjectData.Scale;
960 PData.PathCurve = addPacket.ObjectData.PathCurve;
961 PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
962 PData.ParentID = 0;
963 PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
964 PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
965 PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
966 PData.PathTaperX = addPacket.ObjectData.PathTaperX;
967 PData.PathTaperY = addPacket.ObjectData.PathTaperY;
968 PData.PathTwist = addPacket.ObjectData.PathTwist;
969 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
970
971 return PData;
972 }
973 #endregion
974
975 }
976}
diff --git a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
new file mode 100644
index 0000000..bc6cc21
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
@@ -0,0 +1,358 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Assets;
32using OpenSim.Framework.Types;
33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework.Utilities;
35using OpenSim.Region.Caches;
36using libsecondlife;
37using libsecondlife.Packets;
38
39namespace OpenSim.Region.ClientStack
40{
41 partial class ClientView
42 {
43 public class AgentAssetUpload
44 {
45 private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>();
46 private ClientView ourClient;
47 private AssetCache m_assetCache;
48 private InventoryCache m_inventoryCache;
49
50 public AgentAssetUpload(ClientView client, AssetCache assetCache, InventoryCache inventoryCache)
51 {
52 this.ourClient = client;
53 m_assetCache = assetCache;
54 m_inventoryCache = inventoryCache;
55 }
56
57 public void AddUpload(LLUUID transactionID, AssetBase asset)
58 {
59 AssetTransaction upload = new AssetTransaction();
60 lock (this.transactions)
61 {
62 upload.Asset = asset;
63 upload.TransactionID = transactionID;
64 this.transactions.Add(transactionID, upload);
65 }
66 if (upload.Asset.Data.Length > 2)
67 {
68 //is complete
69 upload.UploadComplete = true;
70 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
71 response.AssetBlock.Type = asset.Type;
72 response.AssetBlock.Success = true;
73 response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID);
74 this.ourClient.OutPacket(response);
75 m_assetCache.AddAsset(asset);
76 }
77 else
78 {
79 upload.UploadComplete = false;
80 upload.XferID = Util.GetNextXferID();
81 RequestXferPacket xfer = new RequestXferPacket();
82 xfer.XferID.ID = upload.XferID;
83 xfer.XferID.VFileType = upload.Asset.Type;
84 xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID);
85 xfer.XferID.FilePath = 0;
86 xfer.XferID.Filename = new byte[0];
87 this.ourClient.OutPacket(xfer);
88 }
89
90 }
91
92 public AssetBase GetUpload(LLUUID transactionID)
93 {
94 if (this.transactions.ContainsKey(transactionID))
95 {
96 return this.transactions[transactionID].Asset;
97 }
98
99 return null;
100 }
101
102 public void HandleUploadPacket(AssetUploadRequestPacket pack, LLUUID assetID)
103 {
104 // Console.Write("asset upload request , type = " + pack.AssetBlock.Type.ToString());
105 AssetBase asset = null;
106 if (pack.AssetBlock.Type == 0)
107 {
108
109 //first packet for transaction
110 asset = new AssetBase();
111 asset.FullID = assetID;
112 asset.Type = pack.AssetBlock.Type;
113 asset.InvType = asset.Type;
114 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000");
115 asset.Data = pack.AssetBlock.AssetData;
116
117
118 }
119 else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5 | pack.AssetBlock.Type == 7)
120 {
121
122 asset = new AssetBase();
123 asset.FullID = assetID;
124 // Console.WriteLine("skin asset id is " + assetID.ToStringHyphenated());
125 asset.Type = pack.AssetBlock.Type;
126 asset.InvType = asset.Type;
127 asset.Name = "NewClothing" + Util.RandomClass.Next(1, 1000).ToString("000");
128 asset.Data = pack.AssetBlock.AssetData;
129
130
131 }
132
133 if (asset != null)
134 {
135 this.AddUpload(pack.AssetBlock.TransactionID, asset);
136 }
137 else
138 {
139
140 //currently we don't support this asset type
141 //so lets just tell the client that the upload is complete
142 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
143 response.AssetBlock.Type = pack.AssetBlock.Type;
144 response.AssetBlock.Success = true;
145 response.AssetBlock.UUID = pack.AssetBlock.TransactionID.Combine(this.ourClient.SecureSessionID);
146 this.ourClient.OutPacket(response);
147 }
148
149 }
150
151 #region Xfer packet system for larger uploads
152
153 public void HandleXferPacket(SendXferPacketPacket xferPacket)
154 {
155 lock (this.transactions)
156 {
157 foreach (AssetTransaction trans in this.transactions.Values)
158 {
159 if (trans.XferID == xferPacket.XferID.ID)
160 {
161 if (trans.Asset.Data.Length > 1)
162 {
163 byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length];
164 Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length);
165 Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length);
166 trans.Asset.Data = newArray;
167 }
168 else
169 {
170 byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4];
171 Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4);
172 trans.Asset.Data = newArray;
173 }
174
175 if ((xferPacket.XferID.Packet & 2147483648) != 0)
176 {
177 //end of transfer
178 trans.UploadComplete = true;
179 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
180 response.AssetBlock.Type = trans.Asset.Type;
181 response.AssetBlock.Success = true;
182 response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID);
183 this.ourClient.OutPacket(response);
184
185 m_assetCache.AddAsset(trans.Asset);
186 //check if we should add it to inventory
187 if (trans.AddToInventory)
188 {
189 // m_assetCache.AddAsset(trans.Asset);
190 m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset);
191 }
192
193
194 }
195 break;
196 }
197
198 }
199 }
200
201 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket();
202 confirmXfer.XferID.ID = xferPacket.XferID.ID;
203 confirmXfer.XferID.Packet = xferPacket.XferID.Packet;
204 this.ourClient.OutPacket(confirmXfer);
205 }
206
207 #endregion
208
209 public AssetBase AddUploadToAssetCache(LLUUID transactionID)
210 {
211 AssetBase asset = null;
212 if (this.transactions.ContainsKey(transactionID))
213 {
214 AssetTransaction trans = this.transactions[transactionID];
215 if (trans.UploadComplete)
216 {
217 m_assetCache.AddAsset(trans.Asset);
218 asset = trans.Asset;
219 }
220 }
221
222 return asset;
223 }
224
225 public void CreateInventoryItem(CreateInventoryItemPacket packet)
226 {
227 if (this.transactions.ContainsKey(packet.InventoryBlock.TransactionID))
228 {
229 AssetTransaction trans = this.transactions[packet.InventoryBlock.TransactionID];
230 trans.Asset.Description = Util.FieldToString(packet.InventoryBlock.Description);
231 trans.Asset.Name = Util.FieldToString(packet.InventoryBlock.Name);
232 trans.Asset.Type = packet.InventoryBlock.Type;
233 trans.Asset.InvType = packet.InventoryBlock.InvType;
234 if (trans.UploadComplete)
235 {
236 //already complete so we can add it to the inventory
237 //m_assetCache.AddAsset(trans.Asset);
238 m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset);
239 }
240 else
241 {
242 trans.AddToInventory = true;
243 trans.InventFolder = packet.InventoryBlock.FolderID;
244 }
245 }
246 }
247
248 private class AssetTransaction
249 {
250 public uint XferID;
251 public AssetBase Asset;
252 public bool AddToInventory;
253 public LLUUID InventFolder = LLUUID.Zero;
254 public bool UploadComplete = false;
255 public LLUUID TransactionID = LLUUID.Zero;
256
257 public AssetTransaction()
258 {
259
260 }
261 }
262
263 //new class , not currently used.
264 public class AssetXferUploader
265 {
266 private IClientAPI ourClient;
267
268 public bool UploadComplete = false;
269
270 public bool AddToInventory;
271 public LLUUID InventFolder = LLUUID.Zero;
272
273 public uint XferID;
274 public AssetBase Asset;
275 public LLUUID TransactionID = LLUUID.Zero;
276
277
278 public AssetXferUploader(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data)
279 {
280 ourClient = remoteClient;
281 Asset = new AssetBase();
282 Asset.FullID = assetID;
283 Asset.InvType = type;
284 Asset.Type = type;
285 Asset.Data = data;
286 Asset.Name = "blank";
287 Asset.Description = "empty";
288 TransactionID = transaction;
289
290 if (Asset.Data.Length > 2)
291 {
292 //data block should only have data in it, if there is no more data to be uploaded
293 this.SendCompleteMessage();
294 }
295 else
296 {
297 this.ReqestStartXfer();
298 }
299 }
300
301 protected void SendCompleteMessage()
302 {
303 UploadComplete = true;
304 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
305 response.AssetBlock.Type = Asset.Type;
306 response.AssetBlock.Success = true;
307 response.AssetBlock.UUID = Asset.FullID;
308 this.ourClient.OutPacket(response);
309
310 //TODO trigger event
311 }
312
313 protected void ReqestStartXfer()
314 {
315 UploadComplete = false;
316 XferID = Util.GetNextXferID();
317 RequestXferPacket xfer = new RequestXferPacket();
318 xfer.XferID.ID = XferID;
319 xfer.XferID.VFileType = Asset.Type;
320 xfer.XferID.VFileID = Asset.FullID;
321 xfer.XferID.FilePath = 0;
322 xfer.XferID.Filename = new byte[0];
323 this.ourClient.OutPacket(xfer);
324 }
325
326 public void HandleXferPacket(uint xferID, uint packetID, byte[] data)
327 {
328 if (XferID == xferID)
329 {
330 if (Asset.Data.Length > 1)
331 {
332 byte[] newArray = new byte[Asset.Data.Length + data.Length];
333 Array.Copy(Asset.Data, 0, newArray, 0, Asset.Data.Length);
334 Array.Copy(data, 0, newArray, Asset.Data.Length, data.Length);
335 Asset.Data = newArray;
336 }
337 else
338 {
339 byte[] newArray = new byte[data.Length - 4];
340 Array.Copy(data, 4, newArray, 0, data.Length - 4);
341 Asset.Data = newArray;
342 }
343
344 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket();
345 confirmXfer.XferID.ID = xferID;
346 confirmXfer.XferID.Packet = packetID;
347 this.ourClient.OutPacket(confirmXfer);
348
349 if ((packetID & 2147483648) != 0)
350 {
351 this.SendCompleteMessage();
352 }
353 }
354 }
355 }
356 }
357 }
358}
diff --git a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
new file mode 100644
index 0000000..0456e3c
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
@@ -0,0 +1,196 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using libsecondlife;
32using libsecondlife.Packets;
33using Nwc.XmlRpc;
34using System.Net;
35using System.Net.Sockets;
36using System.IO;
37using System.Threading;
38using System.Timers;
39using OpenSim.Framework.Interfaces;
40using OpenSim.Framework.Types;
41using OpenSim.Framework.Inventory;
42using OpenSim.Framework.Utilities;
43using OpenSim.Assets;
44
45namespace OpenSim.Region.ClientStack
46{
47 public partial class ClientView
48 {
49 protected virtual void RegisterLocalPacketHandlers()
50 {
51 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
52 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
53 this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
54 }
55
56 protected virtual bool Logout(ClientView simClient, Packet packet)
57 {
58 OpenSim.Framework.Console.MainLog.Instance.Verbose( "OpenSimClient.cs:ProcessInPacket() - Got a logout request");
59 //send reply to let the client logout
60 LogoutReplyPacket logReply = new LogoutReplyPacket();
61 logReply.AgentData.AgentID = this.AgentID;
62 logReply.AgentData.SessionID = this.SessionID;
63 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
64 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
65 logReply.InventoryData[0].ItemID = LLUUID.Zero;
66 OutPacket(logReply);
67 //tell all clients to kill our object
68 KillObjectPacket kill = new KillObjectPacket();
69 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
70 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
71 // kill.ObjectData[0].ID = this.ClientAvatar.localid;
72 foreach (ClientView client in m_clientThreads.Values)
73 {
74 client.OutPacket(kill);
75 }
76
77 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
78
79
80 // m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode);
81 /*lock (m_world.Entities)
82 {
83 m_world.Entities.Remove(this.AgentID);
84 }*/
85 // m_world.RemoveViewerAgent(this);
86 //need to do other cleaning up here too
87 m_clientThreads.Remove(this.CircuitCode);
88 m_networkServer.RemoveClientCircuit(this.CircuitCode);
89 this.ClientThread.Abort();
90 return true;
91 }
92
93 protected bool AgentTextureCached(ClientView simclient, Packet packet)
94 {
95 // Console.WriteLine(packet.ToString());
96 AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
97 AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
98 cachedresp.AgentData.AgentID = this.AgentID;
99 cachedresp.AgentData.SessionID = this.SessionID;
100 cachedresp.AgentData.SerialNum = this.cachedtextureserial;
101 this.cachedtextureserial++;
102 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
103 for (int i = 0; i < chechedtex.WearableData.Length; i++)
104 {
105 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
106 cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
107 cachedresp.WearableData[i].TextureID = LLUUID.Zero;
108 cachedresp.WearableData[i].HostName = new byte[0];
109 }
110 this.OutPacket(cachedresp);
111 return true;
112 }
113
114 protected bool MultipleObjUpdate(ClientView simClient, Packet packet)
115 {
116 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
117 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
118 {
119 if (multipleupdate.ObjectData[i].Type == 9) //change position
120 {
121 if (OnUpdatePrimPosition != null)
122 {
123 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
124 OnUpdatePrimPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
125 }
126 //should update stored position of the prim
127 }
128 else if (multipleupdate.ObjectData[i].Type == 10)//rotation
129 {
130 if (OnUpdatePrimRotation != null)
131 {
132 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
133 OnUpdatePrimRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
134 }
135 }
136 else if (multipleupdate.ObjectData[i].Type == 13)//scale
137 {
138 if (OnUpdatePrimScale != null)
139 {
140 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
141 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
142 }
143 }
144 }
145 return true;
146 }
147
148 public void RequestMapLayer()
149 {
150 //should be getting the map layer from the grid server
151 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
152 MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
153 mapReply.AgentData.AgentID = this.AgentID;
154 mapReply.AgentData.Flags = 0;
155 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
156 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
157 mapReply.LayerData[0].Bottom = 0;
158 mapReply.LayerData[0].Left = 0;
159 mapReply.LayerData[0].Top = 30000;
160 mapReply.LayerData[0].Right = 30000;
161 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
162 this.OutPacket(mapReply);
163 }
164
165 public void RequestMapBlocks(int minX, int minY, int maxX, int maxY)
166 {
167 /*
168 IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
169 MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
170 mbReply.AgentData.AgentID = this.AgentID;
171 int len;
172 if (simMapProfiles == null)
173 len = 0;
174 else
175 len = simMapProfiles.Count;
176
177 mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
178 int iii;
179 for (iii = 0; iii < len; iii++)
180 {
181 Hashtable mp = (Hashtable)simMapProfiles[iii];
182 mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
183 mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]);
184 mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
185 mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
186 mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]);
187 mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
188 mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
189 mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
190 mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
191 }
192 this.OutPacket(mbReply);
193 */
194 }
195 }
196}
diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
new file mode 100644
index 0000000..794ce79
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
@@ -0,0 +1,556 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using libsecondlife;
32using libsecondlife.Packets;
33using Nwc.XmlRpc;
34using System.Net;
35using System.Net.Sockets;
36using System.IO;
37using System.Threading;
38using System.Timers;
39using OpenSim.Framework.Interfaces;
40using OpenSim.Framework.Types;
41using OpenSim.Framework.Inventory;
42using OpenSim.Framework.Utilities;
43using OpenSim.Assets;
44
45namespace OpenSim.Region.ClientStack
46{
47 public partial class ClientView
48 {
49 protected override void ProcessInPacket(Packet Pack)
50 {
51 ack_pack(Pack);
52 if (debug)
53 {
54 if (Pack.Type != PacketType.AgentUpdate)
55 {
56 Console.WriteLine(Pack.Type.ToString());
57 }
58 }
59
60 if (this.ProcessPacketMethod(Pack))
61 {
62 //there is a handler registered that handled this packet type
63 return;
64 }
65 else
66 {
67 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
68
69 switch (Pack.Type)
70 {
71 case PacketType.ViewerEffect:
72 ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
73 foreach (ClientView client in m_clientThreads.Values)
74 {
75 if (client.AgentID != this.AgentID)
76 {
77 viewer.AgentData.AgentID = client.AgentID;
78 viewer.AgentData.SessionID = client.SessionID;
79 client.OutPacket(viewer);
80 }
81 }
82 break;
83
84 #region World/Avatar
85 case PacketType.ChatFromViewer:
86 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
87 if (Util.FieldToString(inchatpack.ChatData.Message) == "")
88 {
89 //empty message so don't bother with it
90 break;
91 }
92 string fromName = ""; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
93 byte[] message = inchatpack.ChatData.Message;
94 byte type = inchatpack.ChatData.Type;
95 LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos;
96 LLUUID fromAgentID = AgentID;
97 if (OnChatFromViewer != null)
98 {
99 this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID);
100 }
101 break;
102 case PacketType.RezObject:
103 RezObjectPacket rezPacket = (RezObjectPacket)Pack;
104 AgentInventory inven = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
105 if (inven != null)
106 {
107 if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
108 {
109 AssetBase asset = this.m_assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
110 if (asset != null)
111 {
112 if (OnRezObject != null)
113 {
114 this.OnRezObject(asset, rezPacket.RezData.RayEnd);
115 this.m_inventoryCache.DeleteInventoryItem(this, rezPacket.InventoryData.ItemID);
116 }
117 }
118 }
119 }
120 break;
121 case PacketType.DeRezObject:
122 if (OnDeRezObject != null)
123 {
124 OnDeRezObject(Pack, this);
125 }
126 break;
127 case PacketType.ModifyLand:
128 ModifyLandPacket modify = (ModifyLandPacket)Pack;
129 if (modify.ParcelData.Length > 0)
130 {
131 if (OnModifyTerrain != null)
132 {
133 OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize,
134 modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West);
135 }
136 }
137 break;
138 case PacketType.RegionHandshakeReply:
139 if (OnRegionHandShakeReply != null)
140 {
141 OnRegionHandShakeReply(this);
142 }
143 break;
144 case PacketType.AgentWearablesRequest:
145 if (OnRequestWearables != null)
146 {
147 OnRequestWearables(this);
148 }
149 if (OnRequestAvatarsData != null)
150 {
151 OnRequestAvatarsData(this);
152 }
153 break;
154 case PacketType.AgentSetAppearance:
155 AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
156 if (OnSetAppearance != null)
157 {
158 OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam);
159 }
160 break;
161 case PacketType.CompleteAgentMovement:
162 if (OnCompleteMovementToRegion != null)
163 {
164 OnCompleteMovementToRegion();
165 }
166 break;
167 case PacketType.AgentUpdate:
168 if (OnAgentUpdate != null)
169 {
170 AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack;
171 OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation );
172 }
173 break;
174 case PacketType.AgentAnimation:
175 if (!m_child)
176 {
177 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
178 for (int i = 0; i < AgentAni.AnimationList.Length; i++)
179 {
180 if (AgentAni.AnimationList[i].StartAnim)
181 {
182 if (OnStartAnim != null)
183 {
184 OnStartAnim(AgentAni.AnimationList[i].AnimID, 1);
185 }
186 }
187 }
188 }
189 break;
190
191 #endregion
192
193 #region Objects/Prims
194 case PacketType.ObjectLink:
195 // OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString());
196 ObjectLinkPacket link = (ObjectLinkPacket)Pack;
197 uint parentprimid = 0;
198 List<uint> childrenprims = new List<uint>();
199 if (link.ObjectData.Length > 1)
200 {
201 parentprimid = link.ObjectData[0].ObjectLocalID;
202
203 for (int i = 1; i < link.ObjectData.Length; i++)
204 {
205 childrenprims.Add(link.ObjectData[i].ObjectLocalID);
206 }
207 }
208 if (OnLinkObjects != null)
209 {
210 OnLinkObjects(parentprimid, childrenprims);
211 }
212 break;
213 case PacketType.ObjectAdd:
214 // m_world.AddNewPrim((ObjectAddPacket)Pack, this);
215 if (OnAddPrim != null)
216 {
217 OnAddPrim(Pack, this);
218 }
219 break;
220 case PacketType.ObjectShape:
221 ObjectShapePacket shape = (ObjectShapePacket)Pack;
222 for (int i = 0; i < shape.ObjectData.Length; i++)
223 {
224 if (OnUpdatePrimShape != null)
225 {
226 OnUpdatePrimShape(shape.ObjectData[i].ObjectLocalID, shape.ObjectData[i]);
227 }
228 }
229 break;
230 case PacketType.ObjectSelect:
231 ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
232 for (int i = 0; i < incomingselect.ObjectData.Length; i++)
233 {
234 if (OnObjectSelect != null)
235 {
236 OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
237 }
238 }
239 break;
240 case PacketType.ObjectFlagUpdate:
241 ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
242 if (OnUpdatePrimFlags != null)
243 {
244 OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this);
245 }
246 break;
247 case PacketType.ObjectImage:
248 ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
249 for (int i = 0; i < imagePack.ObjectData.Length; i++)
250 {
251 if (OnUpdatePrimTexture != null)
252 {
253 OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this);
254 }
255 }
256 break;
257 case PacketType.ObjectGrab:
258 ObjectGrabPacket grap = (ObjectGrabPacket)Pack;
259 if (OnGrapObject != null)
260 {
261 OnGrapObject(grap.ObjectData.LocalID, grap.ObjectData.GrabOffset, this);
262 }
263 break;
264 case PacketType.ObjectGrabUpdate:
265 ObjectGrabUpdatePacket grapUpdate = (ObjectGrabUpdatePacket)Pack;
266 if (OnGrapUpdate != null)
267 {
268 OnGrapUpdate(grapUpdate.ObjectData.ObjectID, grapUpdate.ObjectData.GrabOffsetInitial, grapUpdate.ObjectData.GrabPosition, this);
269 }
270 break;
271 case PacketType.ObjectDeGrab:
272 ObjectDeGrabPacket deGrap = (ObjectDeGrabPacket)Pack;
273 if (OnDeGrapObject != null)
274 {
275 OnDeGrapObject(deGrap.ObjectData.LocalID, this);
276 }
277 break;
278 #endregion
279
280 #region Inventory/Asset/Other related packets
281 case PacketType.RequestImage:
282 RequestImagePacket imageRequest = (RequestImagePacket)Pack;
283 for (int i = 0; i < imageRequest.RequestImage.Length; i++)
284 {
285 m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image);
286 }
287 break;
288 case PacketType.TransferRequest:
289 //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
290 TransferRequestPacket transfer = (TransferRequestPacket)Pack;
291 m_assetCache.AddAssetRequest(this, transfer);
292 break;
293 case PacketType.AssetUploadRequest:
294 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
295 this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID));
296 break;
297 case PacketType.RequestXfer:
298 //Console.WriteLine(Pack.ToString());
299 break;
300 case PacketType.SendXferPacket:
301 this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack);
302 break;
303 case PacketType.CreateInventoryFolder:
304 CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
305 m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID);
306 //Console.WriteLine(Pack.ToString());
307 break;
308 case PacketType.CreateInventoryItem:
309 //Console.WriteLine(Pack.ToString());
310 CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
311 if (createItem.InventoryBlock.TransactionID != LLUUID.Zero)
312 {
313 this.UploadAssets.CreateInventoryItem(createItem);
314 }
315 else
316 {
317 // Console.Write(Pack.ToString());
318 this.CreateInventoryItem(createItem);
319 }
320 break;
321 case PacketType.FetchInventory:
322 //Console.WriteLine("fetch item packet");
323 FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack;
324 m_inventoryCache.FetchInventory(this, FetchInventory);
325 break;
326 case PacketType.FetchInventoryDescendents:
327 FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
328 m_inventoryCache.FetchInventoryDescendents(this, Fetch);
329 break;
330 case PacketType.UpdateInventoryItem:
331 UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
332 //Console.WriteLine(Pack.ToString());
333 for (int i = 0; i < update.InventoryData.Length; i++)
334 {
335 if (update.InventoryData[i].TransactionID != LLUUID.Zero)
336 {
337 AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID));
338 if (asset != null)
339 {
340 // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
341 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
342 }
343 else
344 {
345 asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID);
346 if (asset != null)
347 {
348 //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache");
349 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
350 }
351 else
352 {
353 //Console.WriteLine("trying to update inventory item, but asset is null");
354 }
355 }
356 }
357 else
358 {
359 m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ;
360 }
361 }
362 break;
363 case PacketType.RequestTaskInventory:
364 // Console.WriteLine(Pack.ToString());
365 RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
366 ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket();
367 bool foundent = false;
368 /* foreach (Entity ent in m_world.Entities.Values)
369 {
370 if (ent.localid == requesttask.InventoryData.LocalID)
371 {
372 replytask.InventoryData.TaskID = ent.uuid;
373 replytask.InventoryData.Serial = 0;
374 replytask.InventoryData.Filename = new byte[0];
375 foundent = true;
376 }
377 }
378 if (foundent)
379 {
380 this.OutPacket(replytask);
381 }*/
382 break;
383 case PacketType.UpdateTaskInventory:
384 // Console.WriteLine(Pack.ToString());
385 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
386 AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
387 /*if (myinventory != null)
388 {
389 if (updatetask.UpdateData.Key == 0)
390 {
391 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null)
392 {
393 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7)
394 {
395 LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID;
396 AssetBase assBase = this.m_assetCache.GetAsset(noteaid);
397 if (assBase != null)
398 {
399 foreach (Entity ent in m_world.Entities.Values)
400 {
401 if (ent.localid == updatetask.UpdateData.LocalID)
402 {
403 if (ent is OpenSim.world.Primitive)
404 {
405 this.m_world.AddScript(ent, Util.FieldToString(assBase.Data));
406 }
407 }
408 }
409 }
410 }
411 }
412 }
413 }*/
414 break;
415 case PacketType.MapLayerRequest:
416 this.RequestMapLayer();
417 break;
418 case PacketType.MapBlockRequest:
419 MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
420 if (OnRequestMapBlocks != null)
421 {
422 OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY);
423 }
424 break;
425 case PacketType.TeleportLandmarkRequest:
426 TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
427
428 TeleportStartPacket tpStart = new TeleportStartPacket();
429 tpStart.Info.TeleportFlags = 8; // tp via lm
430 this.OutPacket(tpStart);
431
432 TeleportProgressPacket tpProgress = new TeleportProgressPacket();
433 tpProgress.Info.Message = (new System.Text.ASCIIEncoding()).GetBytes("sending_landmark");
434 tpProgress.Info.TeleportFlags = 8;
435 tpProgress.AgentData.AgentID = tpReq.Info.AgentID;
436 this.OutPacket(tpProgress);
437
438 // Fetch landmark
439 LLUUID lmid = tpReq.Info.LandmarkID;
440 AssetBase lma = this.m_assetCache.GetAsset(lmid);
441 if (lma != null)
442 {
443 AssetLandmark lm = new AssetLandmark(lma);
444
445 if (lm.RegionID == m_regionData.SimUUID)
446 {
447 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
448
449 tpLocal.Info.AgentID = tpReq.Info.AgentID;
450 tpLocal.Info.TeleportFlags = 8; // Teleport via landmark
451 tpLocal.Info.LocationID = 2;
452 tpLocal.Info.Position = lm.Position;
453 OutPacket(tpLocal);
454 }
455 else
456 {
457 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
458 tpCancel.Info.AgentID = tpReq.Info.AgentID;
459 tpCancel.Info.SessionID = tpReq.Info.SessionID;
460 OutPacket(tpCancel);
461 }
462 }
463 else
464 {
465 Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented");
466
467 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
468 tpCancel.Info.AgentID = tpReq.Info.AgentID;
469 tpCancel.Info.SessionID = tpReq.Info.SessionID;
470 OutPacket(tpCancel);
471 }
472 break;
473 case PacketType.TeleportLocationRequest:
474 TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
475 // Console.WriteLine(tpLocReq.ToString());
476
477 if (OnTeleportLocationRequest != null)
478 {
479 OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, tpLocReq.Info.LookAt, 16);
480 }
481 else
482 {
483 //no event handler so cancel request
484 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
485 tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
486 tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
487 OutPacket(tpCancel);
488 }
489 break;
490 #endregion
491
492 case PacketType.MoneyBalanceRequest:
493 this.SendMoneyBalance(LLUUID.Zero, true, new byte[0], 1000);
494 break;
495 case PacketType.UUIDNameRequest:
496 UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
497 foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
498 {
499 OnNameFromUUIDRequest(UUIDBlock.ID, this);
500 }
501 break;
502 #region Parcel related packets
503 case PacketType.ParcelPropertiesRequest:
504 ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
505 if (OnParcelPropertiesRequest != null)
506 {
507 OnParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), (int)Math.Round(propertiesRequest.ParcelData.South), (int)Math.Round(propertiesRequest.ParcelData.East), (int)Math.Round(propertiesRequest.ParcelData.North), propertiesRequest.ParcelData.SequenceID, propertiesRequest.ParcelData.SnapSelection, this);
508 }
509 break;
510 case PacketType.ParcelDivide:
511 ParcelDividePacket parcelDivide = (ParcelDividePacket)Pack;
512 if (OnParcelDivideRequest != null)
513 {
514 OnParcelDivideRequest((int)Math.Round(parcelDivide.ParcelData.West), (int)Math.Round(parcelDivide.ParcelData.South), (int)Math.Round(parcelDivide.ParcelData.East), (int)Math.Round(parcelDivide.ParcelData.North), this);
515 }
516 break;
517 case PacketType.ParcelJoin:
518 ParcelJoinPacket parcelJoin = (ParcelJoinPacket)Pack;
519 if (OnParcelJoinRequest != null)
520 {
521 OnParcelJoinRequest((int)Math.Round(parcelJoin.ParcelData.West), (int)Math.Round(parcelJoin.ParcelData.South), (int)Math.Round(parcelJoin.ParcelData.East), (int)Math.Round(parcelJoin.ParcelData.North), this);
522 }
523 break;
524 case PacketType.ParcelPropertiesUpdate:
525 ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket)Pack;
526 if (OnParcelPropertiesUpdateRequest != null)
527 {
528 OnParcelPropertiesUpdateRequest(updatePacket, this);
529 }
530 break;
531 #endregion
532
533 #region Estate Packets
534 case PacketType.EstateOwnerMessage:
535 EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
536 if (OnEstateOwnerMessage != null)
537 {
538 OnEstateOwnerMessage(messagePacket, this);
539 }
540 break;
541 #endregion
542
543 #region unimplemented handlers
544 case PacketType.AgentIsNowWearing:
545 // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack;
546 //Console.WriteLine(Pack.ToString());
547 break;
548 case PacketType.ObjectScale:
549 //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString());
550 break;
551 #endregion
552 }
553 }
554 }
555 }
556}
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
new file mode 100644
index 0000000..9c4462d
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -0,0 +1,273 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using libsecondlife;
32using libsecondlife.Packets;
33using Nwc.XmlRpc;
34using System.Net;
35using System.Net.Sockets;
36using System.IO;
37using System.Threading;
38using System.Timers;
39using OpenSim.Framework;
40using OpenSim.Framework.Interfaces;
41using OpenSim.Framework.Types;
42using OpenSim.Framework.Inventory;
43using OpenSim.Framework.Utilities;
44using OpenSim.Assets;
45using OpenSim.Region.Caches;
46
47namespace OpenSim.Region.ClientStack
48{
49 public delegate bool PacketMethod(ClientView simClient, Packet packet);
50
51 /// <summary>
52 /// Handles new client connections
53 /// Constructor takes a single Packet and authenticates everything
54 /// </summary>
55 public partial class ClientView : ClientViewBase, IClientAPI
56 {
57 public static TerrainManager TerrainManager;
58
59 protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
60 protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); //local handlers for this instance
61
62 public LLUUID AgentID;
63 public LLUUID SessionID;
64 public LLUUID SecureSessionID = LLUUID.Zero;
65 public string firstName;
66 public string lastName;
67 public bool m_child = false;
68 private UseCircuitCodePacket cirpack;
69 public Thread ClientThread;
70 public LLVector3 startpos;
71
72 private AgentAssetUpload UploadAssets;
73 private LLUUID newAssetFolder = LLUUID.Zero;
74 private bool debug = false;
75 protected IWorld m_world;
76 private Dictionary<uint, ClientView> m_clientThreads;
77 private AssetCache m_assetCache;
78 private InventoryCache m_inventoryCache;
79 private int cachedtextureserial = 0;
80 private RegionInfo m_regionData;
81 protected AuthenticateSessionsBase m_authenticateSessionsHandler;
82
83 public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions )
84 {
85 m_world = world;
86 m_clientThreads = clientThreads;
87 m_assetCache = assetCache;
88
89 m_networkServer = packServer;
90 m_inventoryCache = inventoryCache;
91 m_authenticateSessionsHandler = authenSessions;
92
93 OpenSim.Framework.Console.MainLog.Instance.Verbose( "OpenSimClient.cs - Started up new client thread to handle incoming request");
94 cirpack = initialcirpack;
95 userEP = remoteEP;
96
97 this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code);
98
99 PacketQueue = new BlockingQueue<QueItem>();
100
101 this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
102 AckTimer = new System.Timers.Timer(500);
103 AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
104 AckTimer.Start();
105
106 this.RegisterLocalPacketHandlers();
107
108 ClientThread = new Thread(new ThreadStart(AuthUser));
109 ClientThread.IsBackground = true;
110 ClientThread.Start();
111 }
112
113 # region Client Methods
114
115 public void KillClient()
116 {
117 KillObjectPacket kill = new KillObjectPacket();
118 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
119 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
120 //kill.ObjectData[0].ID = this.ClientAvatar.localid;
121 foreach (ClientView client in m_clientThreads.Values)
122 {
123 client.OutPacket(kill);
124 }
125
126 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
127 m_world.RemoveClient(this.AgentId);
128
129 m_clientThreads.Remove(this.CircuitCode);
130 m_networkServer.RemoveClientCircuit(this.CircuitCode);
131 this.ClientThread.Abort();
132 }
133 #endregion
134
135 # region Packet Handling
136 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
137 {
138 bool result = false;
139 lock (PacketHandlers)
140 {
141 if (!PacketHandlers.ContainsKey(packetType))
142 {
143 PacketHandlers.Add(packetType, handler);
144 result = true;
145 }
146 }
147 return result;
148 }
149
150 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
151 {
152 bool result = false;
153 lock (m_packetHandlers)
154 {
155 if (!m_packetHandlers.ContainsKey(packetType))
156 {
157 m_packetHandlers.Add(packetType, handler);
158 result = true;
159 }
160 }
161 return result;
162 }
163
164 protected virtual bool ProcessPacketMethod(Packet packet)
165 {
166 bool result = false;
167 bool found = false;
168 PacketMethod method;
169 if (m_packetHandlers.TryGetValue(packet.Type, out method))
170 {
171 //there is a local handler for this packet type
172 result = method(this, packet);
173 }
174 else
175 {
176 //there is not a local handler so see if there is a Global handler
177 lock (PacketHandlers)
178 {
179 found = PacketHandlers.TryGetValue(packet.Type, out method);
180 }
181 if (found)
182 {
183 result = method(this, packet);
184 }
185 }
186 return result;
187 }
188
189 protected virtual void ClientLoop()
190 {
191 OpenSim.Framework.Console.MainLog.Instance.Verbose( "OpenSimClient.cs:ClientLoop() - Entered loop");
192 while (true)
193 {
194 QueItem nextPacket = PacketQueue.Dequeue();
195 if (nextPacket.Incoming)
196 {
197 //is a incoming packet
198 ProcessInPacket(nextPacket.Packet);
199 }
200 else
201 {
202 //is a out going packet
203 ProcessOutPacket(nextPacket.Packet);
204 }
205 }
206 }
207 # endregion
208
209 # region Setup
210
211 protected virtual void InitNewClient()
212 {
213 OpenSim.Framework.Console.MainLog.Instance.Verbose( "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world");
214 this.m_world.AddNewClient(this, this.AgentID, false);
215 }
216
217 protected virtual void AuthUser()
218 {
219 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
220 AuthenticateResponse sessionInfo = this.m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
221 if (!sessionInfo.Authorised)
222 {
223 //session/circuit not authorised
224 OpenSim.Framework.Console.MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
225 ClientThread.Abort();
226 }
227 else
228 {
229 OpenSim.Framework.Console.MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
230 //session is authorised
231 this.AgentID = cirpack.CircuitCode.ID;
232 this.SessionID = cirpack.CircuitCode.SessionID;
233 this.CircuitCode = cirpack.CircuitCode.Code;
234 this.firstName = sessionInfo.LoginInfo.First;
235 this.lastName = sessionInfo.LoginInfo.Last;
236
237 if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero)
238 {
239 this.SecureSessionID = sessionInfo.LoginInfo.SecureSession;
240 }
241 InitNewClient();
242
243 ClientLoop();
244 }
245 }
246 # endregion
247
248
249 protected override void KillThread()
250 {
251 this.ClientThread.Abort();
252 }
253
254 #region Inventory Creation
255 private void SetupInventory(AuthenticateResponse sessionInfo)
256 {
257
258 }
259 private AgentInventory CreateInventory(LLUUID baseFolder)
260 {
261 AgentInventory inventory = null;
262
263 return inventory;
264 }
265
266 private void CreateInventoryItem(CreateInventoryItemPacket packet)
267 {
268
269 }
270 #endregion
271
272 }
273}
diff --git a/OpenSim/Region/ClientStack/ClientViewBase.cs b/OpenSim/Region/ClientStack/ClientViewBase.cs
new file mode 100644
index 0000000..7d39405
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientViewBase.cs
@@ -0,0 +1,327 @@
1
2/*
3* Copyright (c) Contributors, http://www.openmetaverse.org/
4* See CONTRIBUTORS.TXT for a full list of copyright holders.
5*
6* Redistribution and use in source and binary forms, with or without
7* modification, are permitted provided that the following conditions are met:
8* * Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10* * Redistributions in binary form must reproduce the above copyright
11* notice, this list of conditions and the following disclaimer in the
12* documentation and/or other materials provided with the distribution.
13* * Neither the name of the OpenSim Project nor the
14* names of its contributors may be used to endorse or promote products
15* derived from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
18* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
21* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*
28*/
29using System;
30using System.Collections;
31using System.Collections.Generic;
32using libsecondlife;
33using libsecondlife.Packets;
34using System.Net;
35using System.Net.Sockets;
36using System.IO;
37using System.Threading;
38using System.Timers;
39using OpenSim.Framework.Utilities;
40using OpenSim.Framework.Interfaces;
41
42namespace OpenSim.Region.ClientStack
43{
44 public class ClientViewBase
45 {
46 protected BlockingQueue<QueItem> PacketQueue;
47 protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
48 protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
49
50 protected System.Timers.Timer AckTimer;
51 protected uint Sequence = 0;
52 protected object SequenceLock = new object();
53 protected const int MAX_APPENDED_ACKS = 10;
54 protected const int RESEND_TIMEOUT = 4000;
55 protected const int MAX_SEQUENCE = 0xFFFFFF;
56
57 public uint CircuitCode;
58 public EndPoint userEP;
59
60 protected PacketServer m_networkServer;
61
62 public ClientViewBase()
63 {
64
65 }
66
67 protected virtual void ProcessInPacket(Packet Pack)
68 {
69
70 }
71
72 protected virtual void ProcessOutPacket(Packet Pack)
73 {
74 // Keep track of when this packet was sent out
75 Pack.TickCount = Environment.TickCount;
76
77 if (!Pack.Header.Resent)
78 {
79 // Set the sequence number
80 lock (SequenceLock)
81 {
82 if (Sequence >= MAX_SEQUENCE)
83 Sequence = 1;
84 else
85 Sequence++;
86 Pack.Header.Sequence = Sequence;
87 }
88
89 if (Pack.Header.Reliable) //DIRTY HACK
90 {
91 lock (NeedAck)
92 {
93 if (!NeedAck.ContainsKey(Pack.Header.Sequence))
94 {
95 try
96 {
97 NeedAck.Add(Pack.Header.Sequence, Pack);
98 }
99 catch (Exception e) // HACKY
100 {
101 e.ToString();
102 // Ignore
103 // Seems to throw a exception here occasionally
104 // of 'duplicate key' despite being locked.
105 // !?!?!?
106 }
107 }
108 else
109 {
110 // Client.Log("Attempted to add a duplicate sequence number (" +
111 // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " +
112 // packet.Type.ToString(), Helpers.LogLevel.Warning);
113 }
114 }
115
116 // Don't append ACKs to resent packets, in case that's what was causing the
117 // delivery to fail
118 if (!Pack.Header.Resent)
119 {
120 // Append any ACKs that need to be sent out to this packet
121 lock (PendingAcks)
122 {
123 if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS &&
124 Pack.Type != PacketType.PacketAck &&
125 Pack.Type != PacketType.LogoutRequest)
126 {
127 Pack.Header.AckList = new uint[PendingAcks.Count];
128 int i = 0;
129
130 foreach (uint ack in PendingAcks.Values)
131 {
132 Pack.Header.AckList[i] = ack;
133 i++;
134 }
135
136 PendingAcks.Clear();
137 Pack.Header.AppendedAcks = true;
138 }
139 }
140 }
141 }
142 }
143
144 byte[] ZeroOutBuffer = new byte[4096];
145 byte[] sendbuffer;
146 sendbuffer = Pack.ToBytes();
147
148 try
149 {
150 if (Pack.Header.Zerocoded)
151 {
152 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
153 m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP);
154 }
155 else
156 {
157 m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP);
158 }
159 }
160 catch (Exception)
161 {
162 OpenSim.Framework.Console.MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread");
163 this.KillThread();
164 }
165
166 }
167
168 public virtual void InPacket(Packet NewPack)
169 {
170 // Handle appended ACKs
171 if (NewPack.Header.AppendedAcks)
172 {
173 lock (NeedAck)
174 {
175 foreach (uint ack in NewPack.Header.AckList)
176 {
177 NeedAck.Remove(ack);
178 }
179 }
180 }
181
182 // Handle PacketAck packets
183 if (NewPack.Type == PacketType.PacketAck)
184 {
185 PacketAckPacket ackPacket = (PacketAckPacket)NewPack;
186
187 lock (NeedAck)
188 {
189 foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets)
190 {
191 NeedAck.Remove(block.ID);
192 }
193 }
194 }
195 else if ((NewPack.Type == PacketType.StartPingCheck))
196 {
197 //reply to pingcheck
198 libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack;
199 libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket();
200 endPing.PingID.PingID = startPing.PingID.PingID;
201 OutPacket(endPing);
202 }
203 else
204 {
205 QueItem item = new QueItem();
206 item.Packet = NewPack;
207 item.Incoming = true;
208 this.PacketQueue.Enqueue(item);
209 }
210
211 }
212
213 public virtual void OutPacket(Packet NewPack)
214 {
215 QueItem item = new QueItem();
216 item.Packet = NewPack;
217 item.Incoming = false;
218 this.PacketQueue.Enqueue(item);
219 }
220
221 # region Low Level Packet Methods
222
223 protected void ack_pack(Packet Pack)
224 {
225 if (Pack.Header.Reliable)
226 {
227 libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket();
228 ack_it.Packets = new PacketAckPacket.PacketsBlock[1];
229 ack_it.Packets[0] = new PacketAckPacket.PacketsBlock();
230 ack_it.Packets[0].ID = Pack.Header.Sequence;
231 ack_it.Header.Reliable = false;
232
233 OutPacket(ack_it);
234
235 }
236 /*
237 if (Pack.Header.Reliable)
238 {
239 lock (PendingAcks)
240 {
241 uint sequence = (uint)Pack.Header.Sequence;
242 if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; }
243 }
244 }*/
245 }
246
247 protected void ResendUnacked()
248 {
249 int now = Environment.TickCount;
250
251 lock (NeedAck)
252 {
253 foreach (Packet packet in NeedAck.Values)
254 {
255 if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent))
256 {
257 OpenSim.Framework.Console.MainLog.Instance.Verbose( "Resending " + packet.Type.ToString() + " packet, " +
258 (now - packet.TickCount) + "ms have passed");
259
260 packet.Header.Resent = true;
261 OutPacket(packet);
262 }
263 }
264 }
265 }
266
267 protected void SendAcks()
268 {
269 lock (PendingAcks)
270 {
271 if (PendingAcks.Count > 0)
272 {
273 if (PendingAcks.Count > 250)
274 {
275 // FIXME: Handle the odd case where we have too many pending ACKs queued up
276 OpenSim.Framework.Console.MainLog.Instance.Verbose( "Too many ACKs queued up!");
277 return;
278 }
279
280 //OpenSim.Framework.Console.MainLog.Instance.WriteLine("Sending PacketAck");
281
282
283 int i = 0;
284 PacketAckPacket acks = new PacketAckPacket();
285 acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count];
286
287 foreach (uint ack in PendingAcks.Values)
288 {
289 acks.Packets[i] = new PacketAckPacket.PacketsBlock();
290 acks.Packets[i].ID = ack;
291 i++;
292 }
293
294 acks.Header.Reliable = false;
295 OutPacket(acks);
296
297 PendingAcks.Clear();
298 }
299 }
300 }
301
302 protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea)
303 {
304 SendAcks();
305 ResendUnacked();
306 }
307 #endregion
308
309 protected virtual void KillThread()
310 {
311
312 }
313
314 #region Nested Classes
315
316 public class QueItem
317 {
318 public QueItem()
319 {
320 }
321
322 public Packet Packet;
323 public bool Incoming;
324 }
325 #endregion
326 }
327}
diff --git a/OpenSim/Region/ClientStack/OpenSim.Region.ClientStack.csproj b/OpenSim/Region/ClientStack/OpenSim.Region.ClientStack.csproj
new file mode 100644
index 0000000..3093eb0
--- /dev/null
+++ b/OpenSim/Region/ClientStack/OpenSim.Region.ClientStack.csproj
@@ -0,0 +1,166 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{DC3698B2-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.ClientStack</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.ClientStack</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Axiom.MathLib.dll" >
62 <HintPath>..\..\..\bin\Axiom.MathLib.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="Db4objects.Db4o.dll" >
66 <HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="libsecondlife.dll" >
70 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System" >
74 <HintPath>System.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="System.Xml" >
78 <HintPath>System.Xml.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="XMLRPC.dll" >
82 <HintPath>..\..\..\bin\XMLRPC.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 </ItemGroup>
86 <ItemGroup>
87 <ProjectReference Include="..\..\Framework\General\OpenSim.Framework.csproj">
88 <Name>OpenSim.Framework</Name>
89 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
90 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
91 <Private>False</Private>
92 </ProjectReference>
93 <ProjectReference Include="..\..\Framework\Console\OpenSim.Framework.Console.csproj">
94 <Name>OpenSim.Framework.Console</Name>
95 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
96 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
97 <Private>False</Private>
98 </ProjectReference>
99 <ProjectReference Include="..\..\Framework\Servers\OpenSim.Framework.Servers.csproj">
100 <Name>OpenSim.Framework.Servers</Name>
101 <Project>{2CC71860-0000-0000-0000-000000000000}</Project>
102 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
103 <Private>False</Private>
104 </ProjectReference>
105 <ProjectReference Include="..\Caches\OpenSim.Region.Caches.csproj">
106 <Name>OpenSim.Region.Caches</Name>
107 <Project>{61FCCDB3-0000-0000-0000-000000000000}</Project>
108 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
109 <Private>False</Private>
110 </ProjectReference>
111 <ProjectReference Include="..\Physics\Manager\OpenSim.Region.Physics.Manager.csproj">
112 <Name>OpenSim.Region.Physics.Manager</Name>
113 <Project>{F4FF31EB-0000-0000-0000-000000000000}</Project>
114 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
115 <Private>False</Private>
116 </ProjectReference>
117 <ProjectReference Include="..\Terrain.BasicTerrain\OpenSim.Region.Terrain.BasicTerrain.csproj">
118 <Name>OpenSim.Region.Terrain.BasicTerrain</Name>
119 <Project>{C9E0F891-0000-0000-0000-000000000000}</Project>
120 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
121 <Private>False</Private>
122 </ProjectReference>
123 </ItemGroup>
124 <ItemGroup>
125 <Compile Include="ClientStackNetworkHandler.cs">
126 <SubType>Code</SubType>
127 </Compile>
128 <Compile Include="ClientView.AgentAssetUpload.cs">
129 <SubType>Code</SubType>
130 </Compile>
131 <Compile Include="ClientView.API.cs">
132 <SubType>Code</SubType>
133 </Compile>
134 <Compile Include="ClientView.cs">
135 <SubType>Code</SubType>
136 </Compile>
137 <Compile Include="ClientView.PacketHandlers.cs">
138 <SubType>Code</SubType>
139 </Compile>
140 <Compile Include="ClientView.ProcessPackets.cs">
141 <SubType>Code</SubType>
142 </Compile>
143 <Compile Include="ClientViewBase.cs">
144 <SubType>Code</SubType>
145 </Compile>
146 <Compile Include="PacketServer.cs">
147 <SubType>Code</SubType>
148 </Compile>
149 <Compile Include="RegionApplicationBase.cs">
150 <SubType>Code</SubType>
151 </Compile>
152 <Compile Include="UDPServer.cs">
153 <SubType>Code</SubType>
154 </Compile>
155 <Compile Include="Assets\InventoryCache.cs">
156 <SubType>Code</SubType>
157 </Compile>
158 </ItemGroup>
159 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
160 <PropertyGroup>
161 <PreBuildEvent>
162 </PreBuildEvent>
163 <PostBuildEvent>
164 </PostBuildEvent>
165 </PropertyGroup>
166</Project>
diff --git a/OpenSim/Region/ClientStack/OpenSim.Region.ClientStack.dll.build b/OpenSim/Region/ClientStack/OpenSim.Region.ClientStack.dll.build
new file mode 100644
index 0000000..f76a4c8
--- /dev/null
+++ b/OpenSim/Region/ClientStack/OpenSim.Region.ClientStack.dll.build
@@ -0,0 +1,60 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.ClientStack" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.ClientStack" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="ClientStackNetworkHandler.cs" />
15 <include name="ClientView.AgentAssetUpload.cs" />
16 <include name="ClientView.API.cs" />
17 <include name="ClientView.cs" />
18 <include name="ClientView.PacketHandlers.cs" />
19 <include name="ClientView.ProcessPackets.cs" />
20 <include name="ClientViewBase.cs" />
21 <include name="PacketServer.cs" />
22 <include name="RegionApplicationBase.cs" />
23 <include name="UDPServer.cs" />
24 <include name="Assets/InventoryCache.cs" />
25 </sources>
26 <references basedir="${project::get-base-directory()}">
27 <lib>
28 <include name="${project::get-base-directory()}" />
29 <include name="${project::get-base-directory()}/${build.dir}" />
30 </lib>
31 <include name="../../../bin/Axiom.MathLib.dll" />
32 <include name="../../../bin/Db4objects.Db4o.dll" />
33 <include name="../../../bin/libsecondlife.dll" />
34 <include name="../../../bin/OpenSim.Framework.dll" />
35 <include name="../../../bin/OpenSim.Framework.Console.dll" />
36 <include name="../../../bin/OpenSim.Framework.Servers.dll" />
37 <include name="../../../bin/OpenSim.Region.Caches.dll" />
38 <include name="../../../bin/OpenSim.Region.Physics.Manager.dll" />
39 <include name="../../../bin/OpenSim.Region.Terrain.BasicTerrain.dll" />
40 <include name="System.dll" />
41 <include name="System.Xml.dll" />
42 <include name="../../../bin/XMLRPC.dll" />
43 </references>
44 </csc>
45 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
46 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
47 <copy todir="${project::get-base-directory()}/../../../bin/">
48 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
49 <include name="*.dll"/>
50 <include name="*.exe"/>
51 </fileset>
52 </copy>
53 </target>
54 <target name="clean">
55 <delete dir="${bin.dir}" failonerror="false" />
56 <delete dir="${obj.dir}" failonerror="false" />
57 </target>
58 <target name="doc" description="Creates documentation.">
59 </target>
60</project>
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs
new file mode 100644
index 0000000..ffd254e
--- /dev/null
+++ b/OpenSim/Region/ClientStack/PacketServer.cs
@@ -0,0 +1,183 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife.Packets;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework;
34using System.Net;
35using System.Net.Sockets;
36using OpenSim.Assets;
37using OpenSim.Region.Caches;
38
39namespace OpenSim.Region.ClientStack
40{
41 public class PacketServer
42 {
43 private ClientStackNetworkHandler _networkHandler;
44 private IWorld _localWorld;
45 public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>();
46 public Dictionary<uint, IClientAPI> ClientAPIs = new Dictionary<uint, IClientAPI>();
47 protected uint serverPort;
48
49 public PacketServer(ClientStackNetworkHandler networkHandler, uint port)
50 {
51 _networkHandler = networkHandler;
52 this.serverPort = port;
53 _networkHandler.RegisterPacketServer(this);
54 }
55
56 public IWorld LocalWorld
57 {
58 set
59 {
60 this._localWorld = value;
61 }
62 }
63
64 /// <summary>
65 ///
66 /// </summary>
67 /// <param name="circuitCode"></param>
68 /// <param name="packet"></param>
69 public virtual void ClientInPacket(uint circuitCode, Packet packet)
70 {
71 if (this.ClientThreads.ContainsKey(circuitCode))
72 {
73 ClientThreads[circuitCode].InPacket(packet);
74 }
75 }
76
77 /// <summary>
78 ///
79 /// </summary>
80 /// <param name="circuitCode"></param>
81 /// <returns></returns>
82 public virtual bool AddNewCircuitCodeClient(uint circuitCode)
83 {
84 return false;
85 }
86
87 /// <summary>
88 ///
89 /// </summary>
90 /// <param name="packet"></param>
91 public virtual void SendPacketToAllClients(Packet packet)
92 {
93
94 }
95
96 /// <summary>
97 ///
98 /// </summary>
99 /// <param name="packet"></param>
100 /// <param name="simClient"></param>
101 public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient)
102 {
103
104 }
105
106 /// <summary>
107 ///
108 /// </summary>
109 /// <param name="packetType"></param>
110 /// <param name="handler"></param>
111 public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler)
112 {
113
114 }
115
116 /// <summary>
117 ///
118 /// </summary>
119 public virtual void RegisterClientPacketHandlers()
120 {
121
122 }
123
124 /// <summary>
125 ///
126 /// </summary>
127 /// <param name="remoteEP"></param>
128 /// <param name="initialcirpack"></param>
129 /// <param name="clientThreads"></param>
130 /// <param name="world"></param>
131 /// <param name="assetCache"></param>
132 /// <param name="packServer"></param>
133 /// <param name="inventoryCache"></param>
134 /// <param name="authenSessions"></param>
135 /// <returns></returns>
136 protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions)
137 {
138 return new ClientView(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions );
139 }
140
141 /// <summary>
142 ///
143 /// </summary>
144 /// <param name="epSender"></param>
145 /// <param name="useCircuit"></param>
146 /// <param name="assetCache"></param>
147 /// <param name="inventoryCache"></param>
148 /// <param name="authenticateSessionsClass"></param>
149 /// <returns></returns>
150 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass)
151 {
152 ClientView newuser =
153 CreateNewClient(epSender, useCircuit, ClientThreads, _localWorld, assetCache, this, inventoryCache,
154 authenticateSessionsClass);
155
156 this.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
157 this.ClientAPIs.Add(useCircuit.CircuitCode.Code, (IClientAPI)newuser);
158
159 return true;
160 }
161
162 /// <summary>
163 ///
164 /// </summary>
165 /// <param name="buffer"></param>
166 /// <param name="size"></param>
167 /// <param name="flags"></param>
168 /// <param name="circuitcode"></param>
169 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
170 {
171 this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode);
172 }
173
174 /// <summary>
175 ///
176 /// </summary>
177 /// <param name="circuitcode"></param>
178 public virtual void RemoveClientCircuit(uint circuitcode)
179 {
180 this._networkHandler.RemoveClientCircuit(circuitcode);
181 }
182 }
183}
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
new file mode 100644
index 0000000..94db8ee
--- /dev/null
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -0,0 +1,128 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Text;
30using System.IO;
31using System.Threading;
32using System.Net;
33using System.Net.Sockets;
34using System.Timers;
35using System.Reflection;
36using System.Collections;
37using System.Collections.Generic;
38using libsecondlife;
39using libsecondlife.Packets;
40using OpenSim.Region.Terrain;
41using OpenSim.Framework.Interfaces;
42using OpenSim.Framework.Types;
43using OpenSim.Framework;
44using OpenSim.Assets;
45using OpenSim.Region.Caches;
46using OpenSim.Framework.Console;
47using OpenSim.Physics.Manager;
48using Nwc.XmlRpc;
49using OpenSim.Framework.Servers;
50
51namespace OpenSim.Region.ClientStack
52{
53 public class RegionApplicationBase
54 {
55 protected IGenericConfig localConfig;
56 protected PhysicsManager physManager;
57 protected AssetCache AssetCache;
58 protected InventoryCache InventoryCache;
59 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
60 protected DateTime startuptime;
61 protected NetworkServersInfo serversData;
62
63 public string m_physicsEngine;
64 public bool m_sandbox = false;
65 public bool m_loginserver;
66 public bool user_accounts = false;
67 public bool gridLocalAsset = false;
68 protected bool configFileSetup = false;
69 public string m_config;
70
71 protected List<UDPServer> m_udpServer = new List<UDPServer>();
72 protected List<RegionInfo> regionData = new List<RegionInfo>();
73 protected List<IWorld> m_localWorld = new List<IWorld>();
74 protected BaseHttpServer httpServer;
75 protected List<AuthenticateSessionsBase> AuthenticateSessionsHandler = new List<AuthenticateSessionsBase>();
76
77 protected LogBase m_log;
78
79 public RegionApplicationBase()
80 {
81
82 }
83
84 public RegionApplicationBase(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
85 {
86 this.configFileSetup = useConfigFile;
87 m_sandbox = sandBoxMode;
88 m_loginserver = startLoginServer;
89 m_physicsEngine = physicsEngine;
90 m_config = configFile;
91 }
92
93 /*protected World m_localWorld;
94 public World LocalWorld
95 {
96 get { return m_localWorld; }
97 }*/
98
99 /// <summary>
100 /// Performs initialisation of the world, such as loading configuration from disk.
101 /// </summary>
102 public virtual void StartUp()
103 {
104 }
105
106 protected virtual void SetupLocalGridServers()
107 {
108 }
109
110 protected virtual void SetupRemoteGridServers()
111 {
112
113 }
114
115 protected virtual void SetupWorld()
116 {
117 }
118
119 protected virtual void SetupHttpListener()
120 {
121 }
122
123 protected virtual void ConnectToRemoteGridServer()
124 {
125
126 }
127 }
128}
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
new file mode 100644
index 0000000..259352c
--- /dev/null
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -0,0 +1,207 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Text;
30using System.IO;
31using System.Threading;
32using System.Net;
33using System.Net.Sockets;
34using System.Timers;
35using System.Reflection;
36using System.Collections;
37using System.Collections.Generic;
38using libsecondlife;
39using libsecondlife.Packets;
40using OpenSim.Region.Terrain;
41using OpenSim.Framework.Interfaces;
42using OpenSim.Framework.Types;
43using OpenSim.Assets;
44using OpenSim.Region.Caches;
45using OpenSim.Framework.Console;
46using OpenSim.Framework;
47using Nwc.XmlRpc;
48using OpenSim.Framework.Servers;
49
50namespace OpenSim.Region.ClientStack
51{
52
53 public class UDPServer : ClientStackNetworkHandler
54 {
55 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
56 public Socket Server;
57 protected IPEndPoint ServerIncoming;
58 protected byte[] RecvBuffer = new byte[4096];
59 protected byte[] ZeroBuffer = new byte[8192];
60 protected IPEndPoint ipeSender;
61 protected EndPoint epSender;
62 protected AsyncCallback ReceivedData;
63 protected PacketServer _packetServer;
64
65 protected int listenPort;
66 protected IWorld m_localWorld;
67 protected AssetCache m_assetCache;
68 protected InventoryCache m_inventoryCache;
69 protected LogBase m_log;
70 protected AuthenticateSessionsBase m_authenticateSessionsClass;
71
72 public PacketServer PacketServer
73 {
74 get
75 {
76 return _packetServer;
77 }
78 set
79 {
80 _packetServer = value;
81 }
82 }
83
84 public IWorld LocalWorld
85 {
86 set
87 {
88 this.m_localWorld = value;
89 this._packetServer.LocalWorld = this.m_localWorld;
90 }
91 }
92
93 public UDPServer()
94 {
95 }
96
97 public UDPServer(int port, AssetCache assetCache, InventoryCache inventoryCache, LogBase console, AuthenticateSessionsBase authenticateClass)
98 {
99 listenPort = port;
100 this.m_assetCache = assetCache;
101 this.m_inventoryCache = inventoryCache;
102 this.m_log = console;
103 this.m_authenticateSessionsClass = authenticateClass;
104 this.CreatePacketServer();
105
106 }
107
108 protected virtual void CreatePacketServer()
109 {
110 PacketServer packetServer = new PacketServer(this, (uint) listenPort);
111 }
112
113 protected virtual void OnReceivedData(IAsyncResult result)
114 {
115 ipeSender = new IPEndPoint(IPAddress.Any, 0);
116 epSender = (EndPoint)ipeSender;
117 Packet packet = null;
118 int numBytes = Server.EndReceiveFrom(result, ref epSender);
119 int packetEnd = numBytes - 1;
120
121 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
122
123 // do we already have a circuit for this endpoint
124 if (this.clientCircuits.ContainsKey(epSender))
125 {
126 //if so then send packet to the packetserver
127 this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet);
128 }
129 else if (packet.Type == PacketType.UseCircuitCode)
130 {
131 // new client
132 this.AddNewClient(packet);
133 }
134 else
135 { // invalid client
136 m_log.Warn("UDPServer.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString());
137 }
138
139 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
140 }
141
142 protected virtual void AddNewClient(Packet packet)
143 {
144 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet;
145 this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
146
147 this.PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_inventoryCache, m_authenticateSessionsClass);
148 }
149
150 public void ServerListener()
151 {
152 m_log.Status("UDPServer.cs:ServerListener() - Opening UDP socket on " + listenPort);
153
154 ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
155 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
156 Server.Bind(ServerIncoming);
157
158 m_log.Verbose("UDPServer.cs:ServerListener() - UDP socket bound, getting ready to listen");
159
160 ipeSender = new IPEndPoint(IPAddress.Any, 0);
161 epSender = (EndPoint)ipeSender;
162 ReceivedData = new AsyncCallback(this.OnReceivedData);
163 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
164
165 m_log.Verbose("UDPServer.cs:ServerListener() - Listening...");
166
167 }
168
169 public virtual void RegisterPacketServer(PacketServer server)
170 {
171 this._packetServer = server;
172 }
173
174 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender)
175 {
176 // find the endpoint for this circuit
177 EndPoint sendto = null;
178 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
179 {
180 if (p.Value == circuitcode)
181 {
182 sendto = p.Key;
183 break;
184 }
185 }
186 if (sendto != null)
187 {
188 //we found the endpoint so send the packet to it
189 this.Server.SendTo(buffer, size, flags, sendto);
190 }
191 }
192
193 public virtual void RemoveClientCircuit(uint circuitcode)
194 {
195 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
196 {
197 if (p.Value == circuitcode)
198 {
199 this.clientCircuits.Remove(p.Key);
200 break;
201 }
202 }
203 }
204
205
206 }
207} \ No newline at end of file
diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
new file mode 100644
index 0000000..bacaa3e
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
@@ -0,0 +1,60 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using libsecondlife;
33using OpenSim.Framework;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Communications;
37
38namespace OpenSim.Region.Communications.Local
39{
40 public class CommunicationsLocal : CommunicationsManager
41 {
42 public LocalBackEndServices SandBoxServices = new LocalBackEndServices();
43 public LocalUserServices UserServices;
44
45 public CommunicationsLocal(NetworkServersInfo serversInfo)
46 : base(serversInfo)
47 {
48 UserServices = new LocalUserServices(this,this.ServersInfo.DefaultHomeLocX,this.ServersInfo.DefaultHomeLocY);
49 UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll");
50 UserServer = UserServices;
51 GridServer = SandBoxServices;
52 InterRegion = SandBoxServices;
53 }
54
55 internal void InformRegionOfLogin(ulong regionHandle, Login login)
56 {
57 this.SandBoxServices.AddNewSession(regionHandle, login);
58 }
59 }
60}
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
new file mode 100644
index 0000000..26834be
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
@@ -0,0 +1,208 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32using OpenSim.Framework.Types;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35
36namespace OpenSim.Region.Communications.Local
37{
38
39 public class LocalBackEndServices : IGridServices, IInterRegionCommunications
40 {
41 protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>();
42 protected Dictionary<ulong, RegionCommsListener> regionHosts = new Dictionary<ulong, RegionCommsListener>();
43
44 public LocalBackEndServices()
45 {
46
47 }
48
49 /// <summary>
50 /// Register a region method with the BackEnd Services.
51 /// </summary>
52 /// <param name="regionInfo"></param>
53 /// <returns></returns>
54 public RegionCommsListener RegisterRegion(RegionInfo regionInfo, GridInfo gridInfo)
55 {
56 //Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering");
57 if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle))
58 {
59 //Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle );
60 this.regions.Add(regionInfo.RegionHandle, regionInfo);
61 RegionCommsListener regionHost = new RegionCommsListener();
62 this.regionHosts.Add(regionInfo.RegionHandle, regionHost);
63
64 return regionHost;
65 }
66
67 //already in our list of regions so for now lets return null
68 return null;
69 }
70
71 /// <summary>
72 /// </summary>
73 /// <param name="regionInfo"></param>
74 /// <returns></returns>
75 public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo)
76 {
77 // Console.WriteLine("Finding Neighbours to " + regionInfo.RegionHandle);
78 List<RegionInfo> neighbours = new List<RegionInfo>();
79
80 foreach (RegionInfo reg in this.regions.Values)
81 {
82 // Console.WriteLine("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY);
83 if (reg.RegionHandle != regionInfo.RegionHandle)
84 {
85 //Console.WriteLine("CommsManager- RequestNeighbours() - found a different region in list, checking location");
86 if ((reg.RegionLocX > (regionInfo.RegionLocX - 2)) && (reg.RegionLocX < (regionInfo.RegionLocX + 2)))
87 {
88 if ((reg.RegionLocY > (regionInfo.RegionLocY - 2)) && (reg.RegionLocY < (regionInfo.RegionLocY + 2)))
89 {
90 neighbours.Add(reg);
91 }
92 }
93 }
94 }
95 return neighbours;
96 }
97
98 /// <summary>
99 ///
100 /// </summary>
101 /// <param name="regionHandle"></param>
102 /// <returns></returns>
103 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
104 {
105 if (this.regions.ContainsKey(regionHandle))
106 {
107 return this.regions[regionHandle];
108 }
109 return null;
110 }
111
112 /// <summary>
113 ///
114 /// </summary>
115 /// <param name="minX"></param>
116 /// <param name="minY"></param>
117 /// <param name="maxX"></param>
118 /// <param name="maxY"></param>
119 /// <returns></returns>
120 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
121 {
122 List<MapBlockData> mapBlocks = new List<MapBlockData>();
123 foreach(RegionInfo regInfo in this.regions.Values)
124 {
125 if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY)))
126 {
127 MapBlockData map = new MapBlockData();
128 map.Name = regInfo.RegionName;
129 map.X = (ushort)regInfo.RegionLocX;
130 map.Y = (ushort)regInfo.RegionLocY;
131 map.WaterHeight =(byte) regInfo.estateSettings.waterHeight;
132 map.MapImageId = regInfo.estateSettings.terrainImageID; //new LLUUID("00000000-0000-0000-9999-000000000007");
133 map.Agents = 1;
134 map.RegionFlags = 72458694;
135 map.Access = 13;
136 mapBlocks.Add(map);
137 }
138 }
139 return mapBlocks;
140 }
141
142 /// <summary>
143 /// </summary>
144 /// <param name="regionHandle"></param>
145 /// <param name="agentData"></param>
146 /// <returns></returns>
147 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData
148 {
149 //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent");
150 if (this.regionHosts.ContainsKey(regionHandle))
151 {
152 // Console.WriteLine("CommsManager- Informing a region to expect child agent");
153 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agentData);
154 return true;
155 }
156 return false;
157 }
158
159 /// <summary>
160 ///
161 /// </summary>
162 /// <param name="regionHandle"></param>
163 /// <param name="agentID"></param>
164 /// <param name="position"></param>
165 /// <returns></returns>
166 public bool ExpectAvatarCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position)
167 {
168 if (this.regionHosts.ContainsKey(regionHandle))
169 {
170 // Console.WriteLine("CommsManager- Informing a region to expect avatar crossing");
171 this.regionHosts[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position);
172 return true;
173 }
174 return false;
175 }
176
177 /// <summary>
178 /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
179 /// </summary>
180 /// <param name="regionHandle"></param>
181 /// <param name="loginData"></param>
182 /// <returns></returns>
183 public bool AddNewSession(ulong regionHandle, Login loginData)
184 {
185 AgentCircuitData agent = new AgentCircuitData();
186 agent.AgentID = loginData.Agent;
187 agent.firstname = loginData.First;
188 agent.lastname = loginData.Last;
189 agent.SessionID = loginData.Session;
190 agent.SecureSessionID = loginData.SecureSession;
191 agent.circuitcode = loginData.CircuitCode;
192 agent.BaseFolder = loginData.BaseFolder;
193 agent.InventoryFolder = loginData.InventoryFolder;
194 agent.startpos = new LLVector3(128, 128, 70);
195 agent.CapsPath = loginData.CapsPath;
196
197 if (this.regionHosts.ContainsKey(regionHandle))
198 {
199 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent);
200 return true;
201 }
202
203 // region not found
204 return false;
205 }
206 }
207}
208
diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs
new file mode 100644
index 0000000..6cf254b
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs
@@ -0,0 +1,145 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5
6using OpenSim.Framework.Communications;
7//using OpenSim.Framework.User;
8using OpenSim.Framework.UserManagement;
9using OpenSim.Framework.Data;
10using OpenSim.Framework.Types;
11using OpenSim.Framework.Utilities;
12
13using libsecondlife;
14
15namespace OpenSim.Region.Communications.Local
16{
17 public class LocalUserServices : UserManagerBase, IUserServices
18 {
19 private CommunicationsLocal m_Parent;
20
21 private uint defaultHomeX ;
22 private uint defaultHomeY;
23 public LocalUserServices(CommunicationsLocal parent, uint defHomeX, uint defHomeY)
24 {
25 m_Parent = parent;
26 defaultHomeX = defHomeX;
27 defaultHomeY = defHomeY;
28 }
29
30 public UserProfileData GetUserProfile(string firstName, string lastName)
31 {
32 return GetUserProfile(firstName + " " + lastName);
33 }
34
35 public UserProfileData GetUserProfile(string name)
36 {
37 return this.getUserProfile(name);
38 }
39
40 public UserProfileData GetUserProfile(LLUUID avatarID)
41 {
42 return this.getUserProfile(avatarID);
43 }
44
45 /// <summary>
46 ///
47 /// </summary>
48 /// <returns></returns>
49 public override string GetMessage()
50 {
51 return "Welcome to OpenSim";
52 }
53
54 public override UserProfileData GetTheUser(string firstname, string lastname)
55 {
56 UserProfileData profile = getUserProfile(firstname, lastname);
57 if (profile != null)
58 {
59
60 return profile;
61 }
62
63 //no current user account so make one
64 Console.WriteLine("No User account found so creating a new one ");
65 this.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
66
67 profile = getUserProfile(firstname, lastname);
68
69 return profile;
70 }
71
72 public override bool AuthenticateUser(ref UserProfileData profile, string password)
73 {
74 //for now we will accept any password in sandbox mode
75 Console.WriteLine("authorising user");
76 return true;
77 }
78
79 public override void CustomiseResponse(ref LoginResponse response, ref UserProfileData theUser)
80 {
81 ulong currentRegion = theUser.currentAgent.currentHandle;
82 RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion);
83
84
85 if (reg != null)
86 {
87 response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
88 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
89 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
90 string capsPath = Util.GetRandomCapsPath();
91 response.SimAddress = reg.CommsExternalAddress;
92 response.SimPort = (Int32)reg.CommsIPListenPort;
93 response.RegionX = reg.RegionLocX ;
94 response.RegionY = reg.RegionLocY ;
95 response.SeedCapability = "http://" + reg.CommsIPListenAddr + ":" + "9000" + "/CAPS/" + capsPath + "0000/";
96 theUser.currentAgent.currentRegion = reg.SimUUID;
97 theUser.currentAgent.currentHandle = reg.RegionHandle;
98
99 Login _login = new Login();
100 //copy data to login object
101 _login.First = response.Firstname;
102 _login.Last = response.Lastname;
103 _login.Agent = response.AgentID;
104 _login.Session = response.SessionID;
105 _login.SecureSession = response.SecureSessionID;
106 _login.CircuitCode = (uint)response.CircuitCode;
107 _login.CapsPath = capsPath;
108
109 m_Parent.InformRegionOfLogin(currentRegion, _login);
110 }
111 else
112 {
113 Console.WriteLine("not found region " + currentRegion);
114 }
115
116 }
117
118 public UserProfileData SetupMasterUser(string firstName, string lastName)
119 {
120 return SetupMasterUser(firstName, lastName, "");
121 }
122
123 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
124 {
125 UserProfileData profile = getUserProfile(firstName, lastName);
126 if (profile != null)
127 {
128
129 return profile;
130 }
131
132 Console.WriteLine("Unknown Master User. Sandbox Mode: Creating Account");
133 this.AddUserProfile(firstName, lastName, password, defaultHomeX, defaultHomeY);
134
135 profile = getUserProfile(firstName, lastName);
136
137 if (profile == null)
138 {
139 Console.WriteLine("Unknown Master User after creation attempt. No clue what to do here.");
140 }
141
142 return profile;
143 }
144 }
145}
diff --git a/OpenSim/Region/Communications/Local/OpenSim.Region.Communications.Local.csproj b/OpenSim/Region/Communications/Local/OpenSim.Region.Communications.Local.csproj
new file mode 100644
index 0000000..0a15a49
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/OpenSim.Region.Communications.Local.csproj
@@ -0,0 +1,121 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{BFB5D807-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Communications.Local</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Communications.Local</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="libsecondlife.dll" >
62 <HintPath>..\..\..\..\bin\libsecondlife.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System" >
66 <HintPath>System.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Xml" >
70 <HintPath>System.Xml.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 </ItemGroup>
74 <ItemGroup>
75 <ProjectReference Include="..\..\..\Framework\General\OpenSim.Framework.csproj">
76 <Name>OpenSim.Framework</Name>
77 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
78 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
79 <Private>False</Private>
80 </ProjectReference>
81 <ProjectReference Include="..\..\..\Framework\Communications\OpenSim.Framework.Communications.csproj">
82 <Name>OpenSim.Framework.Communications</Name>
83 <Project>{CB52B7E7-0000-0000-0000-000000000000}</Project>
84 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
85 <Private>False</Private>
86 </ProjectReference>
87 <ProjectReference Include="..\..\..\Framework\Data\OpenSim.Framework.Data.csproj">
88 <Name>OpenSim.Framework.Data</Name>
89 <Project>{36B72A9B-0000-0000-0000-000000000000}</Project>
90 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
91 <Private>False</Private>
92 </ProjectReference>
93 <ProjectReference Include="..\..\..\Framework\UserManager\OpenSim.Framework.UserManagement.csproj">
94 <Name>OpenSim.Framework.UserManagement</Name>
95 <Project>{586E2916-0000-0000-0000-000000000000}</Project>
96 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
97 <Private>False</Private>
98 </ProjectReference>
99 </ItemGroup>
100 <ItemGroup>
101 <Compile Include="CommunicationsLocal.cs">
102 <SubType>Code</SubType>
103 </Compile>
104 <Compile Include="LocalBackEndServices.cs">
105 <SubType>Code</SubType>
106 </Compile>
107 <Compile Include="LocalUserServices.cs">
108 <SubType>Code</SubType>
109 </Compile>
110 <Compile Include="Properties\AssemblyInfo.cs">
111 <SubType>Code</SubType>
112 </Compile>
113 </ItemGroup>
114 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
115 <PropertyGroup>
116 <PreBuildEvent>
117 </PreBuildEvent>
118 <PostBuildEvent>
119 </PostBuildEvent>
120 </PropertyGroup>
121</Project>
diff --git a/OpenSim/Region/Communications/Local/OpenSim.Region.Communications.Local.dll.build b/OpenSim/Region/Communications/Local/OpenSim.Region.Communications.Local.dll.build
new file mode 100644
index 0000000..3cac9d3
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/OpenSim.Region.Communications.Local.dll.build
@@ -0,0 +1,48 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Communications.Local" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Communications.Local" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="CommunicationsLocal.cs" />
15 <include name="LocalBackEndServices.cs" />
16 <include name="LocalUserServices.cs" />
17 <include name="Properties/AssemblyInfo.cs" />
18 </sources>
19 <references basedir="${project::get-base-directory()}">
20 <lib>
21 <include name="${project::get-base-directory()}" />
22 <include name="${project::get-base-directory()}/${build.dir}" />
23 </lib>
24 <include name="../../../../bin/libsecondlife.dll" />
25 <include name="../../../../bin/OpenSim.Framework.dll" />
26 <include name="../../../../bin/OpenSim.Framework.Communications.dll" />
27 <include name="../../../../bin/OpenSim.Framework.Data.dll" />
28 <include name="../../../../bin/OpenSim.Framework.UserManagement.dll" />
29 <include name="System.dll" />
30 <include name="System.Xml.dll" />
31 </references>
32 </csc>
33 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/" />
34 <mkdir dir="${project::get-base-directory()}/../../../../bin/"/>
35 <copy todir="${project::get-base-directory()}/../../../../bin/">
36 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
37 <include name="*.dll"/>
38 <include name="*.exe"/>
39 </fileset>
40 </copy>
41 </target>
42 <target name="clean">
43 <delete dir="${bin.dir}" failonerror="false" />
44 <delete dir="${obj.dir}" failonerror="false" />
45 </target>
46 <target name="doc" description="Creates documentation.">
47 </target>
48</project>
diff --git a/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..1eb7107
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Region.Communications.Local")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenSim.Region.Communications.Local")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("fb173926-bd0a-4cd0-bb45-185b2f72ddfb")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.0")]
35[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
new file mode 100644
index 0000000..870f577
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
@@ -0,0 +1,18 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Types;
5using OpenSim.Framework.Communications;
6namespace OpenSim.Region.Communications.OGS1
7{
8 public class CommunicationsOGS1 : CommunicationsManager
9 {
10 private OGS1GridServices gridInterComms = new OGS1GridServices();
11 public CommunicationsOGS1(NetworkServersInfo serversInfo) :base(serversInfo)
12 {
13 GridServer = gridInterComms;
14 InterRegion = gridInterComms;
15 UserServer = new OGS1UserServices(this);
16 }
17 }
18}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
new file mode 100644
index 0000000..5f0c80c
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -0,0 +1,248 @@
1using System;
2using System.Collections.Generic;
3using System.Collections;
4using System.Text;
5using System.Runtime.Remoting;
6using System.Runtime.Remoting.Channels;
7using System.Runtime.Remoting.Channels.Tcp;
8
9using OpenSim.Framework.Servers;
10using OpenSim.Framework;
11using OpenSim.Framework.Types;
12using OpenSim.Framework.Communications;
13
14using Nwc.XmlRpc;
15using libsecondlife;
16
17namespace OpenSim.Region.Communications.OGS1
18{
19 public class OGS1GridServices : IGridServices, IInterRegionCommunications
20 {
21 public Dictionary<ulong, RegionCommsListener> listeners = new Dictionary<ulong, RegionCommsListener>();
22 public GridInfo grid;
23 public BaseHttpServer httpListener;
24 private bool initialised = false;
25
26 public RegionCommsListener RegisterRegion(RegionInfo regionInfo, GridInfo gridInfo)
27 {
28 Hashtable GridParams = new Hashtable();
29
30 grid = gridInfo;
31
32 // Login / Authentication
33 GridParams["authkey"] = gridInfo.GridServerSendKey;
34 GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated();
35 GridParams["sim_ip"] = regionInfo.CommsExternalAddress;
36 GridParams["sim_port"] = regionInfo.CommsIPListenPort.ToString();
37
38 // Package into an XMLRPC Request
39 ArrayList SendParams = new ArrayList();
40 SendParams.Add(GridParams);
41
42 // Send Request
43 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
44 XmlRpcResponse GridResp = GridReq.Send(gridInfo.GridServerURI, 3000);
45 Hashtable GridRespData = (Hashtable)GridResp.Value;
46 Hashtable griddatahash = GridRespData;
47
48 // Process Response
49 if (GridRespData.ContainsKey("error"))
50 {
51 string errorstring = (string)GridRespData["error"];
52 OpenSim.Framework.Console.MainLog.Instance.Error("Unable to connect to grid: " + errorstring);
53 return null;
54 }
55
56 if (!this.listeners.ContainsKey(regionInfo.RegionHandle))
57 {
58 // initialised = true;
59 httpListener = new BaseHttpServer(regionInfo.CommsIPListenPort);
60 httpListener.AddXmlRPCHandler("expect_user", this.ExpectUser);
61 httpListener.Start();
62 }
63
64 // Initialise the background listeners
65 listeners[regionInfo.RegionHandle] = new RegionCommsListener();
66
67 return listeners[regionInfo.RegionHandle];
68 }
69
70 public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo)
71 {
72 Hashtable respData = MapBlockQuery((int)regionInfo.RegionLocX - 1, (int)regionInfo.RegionLocY - 1, (int)regionInfo.RegionLocX + 1, (int)regionInfo.RegionLocY + 1);
73
74 List<RegionInfo> neighbours = new List<RegionInfo>();
75
76 foreach (Hashtable n in (Hashtable)respData.Values)
77 {
78 RegionInfo neighbour = new RegionInfo();
79
80 //OGS1
81 neighbour.RegionHandle = (ulong)n["regionhandle"];
82 neighbour.RegionLocX = (uint)n["x"];
83 neighbour.RegionLocY = (uint)n["y"];
84 neighbour.RegionName = (string)n["name"];
85
86 //OGS1+
87 neighbour.CommsIPListenAddr = (string)n["sim_ip"];
88 neighbour.CommsIPListenPort = (int)n["sim_port"];
89 neighbour.CommsExternalAddress = (string)n["sim_uri"];
90 neighbour.SimUUID = (string)n["uuid"];
91
92 neighbours.Add(neighbour);
93 }
94
95 return neighbours;
96 }
97
98 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
99 {
100 OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented - RequestNeighbourInfo()");
101 return null;
102 }
103
104 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
105 {
106 Hashtable respData = MapBlockQuery(minX, minY, maxX, maxY);
107
108 List<MapBlockData> neighbours = new List<MapBlockData>();
109
110 foreach (Hashtable n in (Hashtable)respData.Values)
111 {
112 MapBlockData neighbour = new MapBlockData();
113
114 neighbour.X = (ushort)n["x"];
115 neighbour.Y = (ushort)n["y"];
116
117 neighbour.Name = (string)n["name"];
118 neighbour.Access = (byte)n["access"];
119 neighbour.RegionFlags = (uint)n["region-flags"];
120 neighbour.WaterHeight = (byte)n["water-height"];
121 neighbour.MapImageId = (string)n["map-image-id"];
122
123 neighbours.Add(neighbour);
124 }
125
126 return neighbours;
127 }
128
129 /// <summary>
130 /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates
131 /// </summary>
132 /// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks>
133 /// <param name="minX">Minimum X value</param>
134 /// <param name="minY">Minimum Y value</param>
135 /// <param name="maxX">Maximum X value</param>
136 /// <param name="maxY">Maximum Y value</param>
137 /// <returns>Hashtable of hashtables containing map data elements</returns>
138 private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY)
139 {
140 Hashtable param = new Hashtable();
141 param["xmin"] = minX;
142 param["ymin"] = minY;
143 param["xmax"] = maxX;
144 param["ymax"] = maxY;
145 IList parameters = new ArrayList();
146 parameters.Add(param);
147 XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
148 XmlRpcResponse resp = req.Send(grid.GridServerURI, 3000);
149 Hashtable respData = (Hashtable)resp.Value;
150 return respData;
151 }
152
153 // Grid Request Processing
154 public XmlRpcResponse ExpectUser(XmlRpcRequest request)
155 {
156 Hashtable requestData = (Hashtable)request.Params[0];
157 AgentCircuitData agentData = new AgentCircuitData();
158 agentData.SessionID = new LLUUID((string)requestData["session_id"]);
159 agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
160 agentData.firstname = (string)requestData["firstname"];
161 agentData.lastname = (string)requestData["lastname"];
162 agentData.AgentID = new LLUUID((string)requestData["agent_id"]);
163 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
164 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
165 {
166 agentData.child = true;
167 }
168 else
169 {
170 agentData.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"]));
171 agentData.child = false;
172
173 }
174
175 if (listeners.ContainsKey((ulong)requestData["regionhandle"]))
176 {
177 this.listeners[(ulong)requestData["regionhandle"]].TriggerExpectUser((ulong)requestData["regionhandle"], agentData);
178 }
179 else
180 {
181 OpenSim.Framework.Console.MainLog.Instance.Error("ExpectUser() - Unknown region " + ((ulong)requestData["regionhandle"]).ToString());
182 }
183
184 return new XmlRpcResponse();
185 }
186
187 #region InterRegion Comms
188 private void StartRemoting()
189 {
190 TcpChannel ch = new TcpChannel(8895);
191 ChannelServices.RegisterChannel(ch);
192
193 WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry( Type.GetType("OGS1InterRegionRemoting"), "InterRegions", WellKnownObjectMode.Singleton);
194 RemotingConfiguration.RegisterWellKnownServiceType(wellType);
195 InterRegionSingleton.Instance.OnArrival += this.IncomingArrival;
196 InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent;
197 }
198
199 #region Methods called by regions in this instance
200 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
201 {
202 if (this.listeners.ContainsKey(regionHandle))
203 {
204 this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData);
205 return true;
206 }
207 //TODO need to see if we know about where this region is and use .net remoting
208 // to inform it.
209 return false;
210 }
211
212 public bool ExpectAvatarCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position)
213 {
214 if (this.listeners.ContainsKey(regionHandle))
215 {
216 this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position);
217 return true;
218 }
219 //TODO need to see if we know about where this region is and use .net remoting
220 // to inform it.
221 return false;
222 }
223 #endregion
224
225 #region Methods triggered by calls from external instances
226 public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData)
227 {
228 if (this.listeners.ContainsKey(regionHandle))
229 {
230 this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData);
231 return true;
232 }
233 return false;
234 }
235
236 public bool IncomingArrival(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position)
237 {
238 if (this.listeners.ContainsKey(regionHandle))
239 {
240 this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position);
241 return true;
242 }
243 return false;
244 }
245 #endregion
246 #endregion
247 }
248}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs
new file mode 100644
index 0000000..51b33e9
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs
@@ -0,0 +1,70 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Types;
5using OpenSim.Framework.Communications;
6namespace OpenSim.Region.Communications.OGS1
7{
8 public delegate bool InformRegionChild(ulong regionHandle, AgentCircuitData agentData);
9 public delegate bool ExpectArrival(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position);
10
11 public sealed class InterRegionSingleton
12 {
13 static readonly InterRegionSingleton instance = new InterRegionSingleton();
14
15 public event InformRegionChild OnChildAgent;
16 public event ExpectArrival OnArrival;
17
18 static InterRegionSingleton()
19 {
20 }
21
22 InterRegionSingleton()
23 {
24 }
25
26 public static InterRegionSingleton Instance
27 {
28 get
29 {
30 return instance;
31 }
32 }
33
34 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
35 {
36 if (OnChildAgent != null)
37 {
38 return OnChildAgent(regionHandle, agentData);
39 }
40 return false;
41 }
42
43 public bool ExpectAvatarCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position)
44 {
45 if (OnArrival != null)
46 {
47 return OnArrival(regionHandle, agentID, position);
48 }
49 return false;
50 }
51 }
52
53 public class OGS1InterRegionRemoting : MarshalByRefObject
54 {
55
56 public OGS1InterRegionRemoting()
57 {
58 }
59
60 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
61 {
62 return InterRegionSingleton.Instance.InformRegionOfChildAgent(regionHandle, agentData);
63 }
64
65 public bool ExpectAvatarCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position)
66 {
67 return InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, agentID, position);
68 }
69 }
70}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
new file mode 100644
index 0000000..856c447
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -0,0 +1,109 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5using OpenSim.Framework.Types;
6using OpenSim.Framework.Communications;
7using OpenSim.Framework.Data;
8using libsecondlife;
9
10using Nwc.XmlRpc;
11
12namespace OpenSim.Region.Communications.OGS1
13{
14 public class OGS1UserServices :IUserServices
15 {
16 CommunicationsOGS1 m_parent;
17 public OGS1UserServices(CommunicationsOGS1 parent)
18 {
19 m_parent = parent;
20 }
21
22 public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data)
23 {
24 if (data.Contains("error_type"))
25 {
26 Console.WriteLine("Error sent by user server when trying to get user profile: (" + data["error_type"] + "): " + data["error_desc"]);
27 return null;
28 }
29
30 UserProfileData userData = new UserProfileData();
31 userData.username = (string)data["firstname"];
32 userData.surname = (string)data["lastname"];
33 userData.UUID = new LLUUID((string)data["uuid"]);
34 userData.userInventoryURI = (string)data["server_inventory"];
35 userData.userAssetURI = (string)data["server_asset"];
36 userData.profileFirstText = (string)data["profile_firstlife_about"];
37 userData.profileFirstImage = new LLUUID((string)data["profile_firstlife_image"]);
38 userData.profileCanDoMask = (uint)data["profile_can_do"];
39 userData.profileWantDoMask = (uint)data["profile_want_do"];
40 userData.profileImage = new LLUUID((string)data["profile_image"]);
41 userData.lastLogin = (int)data["profile_lastlogin"];
42 userData.homeLocation = new LLVector3();
43 userData.homeLookAt = new LLVector3();
44
45 return userData;
46 }
47 public UserProfileData GetUserProfile(string firstName, string lastName)
48 {
49 return GetUserProfile(firstName + " " + lastName);
50 }
51 public UserProfileData GetUserProfile(string name)
52 {
53
54 try
55 {
56 Hashtable param = new Hashtable();
57 param["avatar_name"] = name;
58 IList parameters = new ArrayList();
59 parameters.Add(param);
60 XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters);
61 XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000);
62 Hashtable respData = (Hashtable)resp.Value;
63
64 return ConvertXMLRPCDataToUserProfile(respData);
65 }
66 catch (Exception e)
67 {
68 Console.WriteLine("Error when trying to fetch profile data by name from remote user server: " + e.Message);
69 }
70 return null;
71 }
72 public UserProfileData GetUserProfile(LLUUID avatarID)
73 {
74 try
75 {
76
77 Hashtable param = new Hashtable();
78 param["avatar_uuid"] = avatarID.ToString();
79 IList parameters = new ArrayList();
80 parameters.Add(param);
81 XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters);
82 XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000);
83 Hashtable respData = (Hashtable)resp.Value;
84
85 return ConvertXMLRPCDataToUserProfile(respData);
86 }
87 catch (Exception e)
88 {
89 Console.WriteLine("Error when trying to fetch profile data by uuid from remote user server: " + e.Message);
90 }
91 return null;
92 }
93
94 public UserProfileData SetupMasterUser(string firstName, string lastName)
95 {
96 return SetupMasterUser(firstName, lastName, "");
97 }
98
99 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
100 {
101 UserProfileData profile = GetUserProfile(firstName, lastName);
102 if (profile == null)
103 {
104 Console.WriteLine("Unknown Master User. Grid Mode: No clue what I should do. Probably would choose the grid owner UUID when that is implemented");
105 }
106 return null;
107 }
108 }
109}
diff --git a/OpenSim/Region/Communications/OGS1/OpenSim.Region.Communications.OGS1.csproj b/OpenSim/Region/Communications/OGS1/OpenSim.Region.Communications.OGS1.csproj
new file mode 100644
index 0000000..d6abd13
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/OpenSim.Region.Communications.OGS1.csproj
@@ -0,0 +1,142 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{4806E378-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Communications.OGS1</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Communications.OGS1</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="libsecondlife.dll" >
62 <HintPath>..\..\..\..\bin\libsecondlife.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System" >
66 <HintPath>System.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Data" >
70 <HintPath>System.Data.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System.Runtime.Remoting" >
74 <HintPath>System.Runtime.Remoting.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="System.Xml" >
78 <HintPath>System.Xml.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="XMLRPC.dll" >
82 <HintPath>..\..\..\..\bin\XMLRPC.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 </ItemGroup>
86 <ItemGroup>
87 <ProjectReference Include="..\..\..\Framework\General\OpenSim.Framework.csproj">
88 <Name>OpenSim.Framework</Name>
89 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
90 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
91 <Private>False</Private>
92 </ProjectReference>
93 <ProjectReference Include="..\..\..\Framework\Communications\OpenSim.Framework.Communications.csproj">
94 <Name>OpenSim.Framework.Communications</Name>
95 <Project>{CB52B7E7-0000-0000-0000-000000000000}</Project>
96 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
97 <Private>False</Private>
98 </ProjectReference>
99 <ProjectReference Include="..\..\..\Framework\Console\OpenSim.Framework.Console.csproj">
100 <Name>OpenSim.Framework.Console</Name>
101 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
102 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
103 <Private>False</Private>
104 </ProjectReference>
105 <ProjectReference Include="..\..\..\Framework\Data\OpenSim.Framework.Data.csproj">
106 <Name>OpenSim.Framework.Data</Name>
107 <Project>{36B72A9B-0000-0000-0000-000000000000}</Project>
108 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
109 <Private>False</Private>
110 </ProjectReference>
111 <ProjectReference Include="..\..\..\Framework\Servers\OpenSim.Framework.Servers.csproj">
112 <Name>OpenSim.Framework.Servers</Name>
113 <Project>{2CC71860-0000-0000-0000-000000000000}</Project>
114 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
115 <Private>False</Private>
116 </ProjectReference>
117 </ItemGroup>
118 <ItemGroup>
119 <Compile Include="CommunicationsOGS1.cs">
120 <SubType>Code</SubType>
121 </Compile>
122 <Compile Include="OGS1GridServices.cs">
123 <SubType>Code</SubType>
124 </Compile>
125 <Compile Include="OGS1InterSimComms.cs">
126 <SubType>Code</SubType>
127 </Compile>
128 <Compile Include="OGS1UserServices.cs">
129 <SubType>Code</SubType>
130 </Compile>
131 <Compile Include="Properties\AssemblyInfo.cs">
132 <SubType>Code</SubType>
133 </Compile>
134 </ItemGroup>
135 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
136 <PropertyGroup>
137 <PreBuildEvent>
138 </PreBuildEvent>
139 <PostBuildEvent>
140 </PostBuildEvent>
141 </PropertyGroup>
142</Project>
diff --git a/OpenSim/Region/Communications/OGS1/OpenSim.Region.Communications.OGS1.dll.build b/OpenSim/Region/Communications/OGS1/OpenSim.Region.Communications.OGS1.dll.build
new file mode 100644
index 0000000..04d61b9
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/OpenSim.Region.Communications.OGS1.dll.build
@@ -0,0 +1,53 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Communications.OGS1" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Communications.OGS1" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="CommunicationsOGS1.cs" />
15 <include name="OGS1GridServices.cs" />
16 <include name="OGS1InterSimComms.cs" />
17 <include name="OGS1UserServices.cs" />
18 <include name="Properties/AssemblyInfo.cs" />
19 </sources>
20 <references basedir="${project::get-base-directory()}">
21 <lib>
22 <include name="${project::get-base-directory()}" />
23 <include name="${project::get-base-directory()}/${build.dir}" />
24 </lib>
25 <include name="../../../../bin/libsecondlife.dll" />
26 <include name="../../../../bin/OpenSim.Framework.dll" />
27 <include name="../../../../bin/OpenSim.Framework.Communications.dll" />
28 <include name="../../../../bin/OpenSim.Framework.Console.dll" />
29 <include name="../../../../bin/OpenSim.Framework.Data.dll" />
30 <include name="../../../../bin/OpenSim.Framework.Servers.dll" />
31 <include name="System.dll" />
32 <include name="System.Data.dll" />
33 <include name="System.Runtime.Remoting.dll" />
34 <include name="System.Xml.dll" />
35 <include name="../../../../bin/XMLRPC.dll" />
36 </references>
37 </csc>
38 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/" />
39 <mkdir dir="${project::get-base-directory()}/../../../../bin/"/>
40 <copy todir="${project::get-base-directory()}/../../../../bin/">
41 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
42 <include name="*.dll"/>
43 <include name="*.exe"/>
44 </fileset>
45 </copy>
46 </target>
47 <target name="clean">
48 <delete dir="${bin.dir}" failonerror="false" />
49 <delete dir="${obj.dir}" failonerror="false" />
50 </target>
51 <target name="doc" description="Creates documentation.">
52 </target>
53</project>
diff --git a/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..0c6f965
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenGrid.Framework.Communications.OGS1")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenGrid.Framework.Communications.OGS1")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("a8b2b39b-c83b-41e2-b0b5-7ccfc1fddae7")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.0")]
35[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs
new file mode 100644
index 0000000..c2c1ecf
--- /dev/null
+++ b/OpenSim/Region/Environment/EstateManager.cs
@@ -0,0 +1,301 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Framework.Types;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Region.Environment;
34using OpenSim.Region.Environment.Scenes;
35using OpenSim;
36using libsecondlife;
37using libsecondlife.Packets;
38using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence;
39
40
41namespace OpenSim.Region.Environment
42{
43
44 /// <summary>
45 /// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings
46 /// </summary>
47 public class EstateManager
48 {
49 private Scene m_world;
50 private RegionInfo m_regInfo;
51
52 public EstateManager(Scene world,RegionInfo reginfo)
53 {
54 m_world = world; //Estate settings found at world.m_regInfo.estateSettings
55 m_regInfo = reginfo;
56 }
57
58 private bool convertParamStringToBool(byte[] field)
59 {
60 string s = Helpers.FieldToUTF8String(field);
61 if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
62 {
63 return true;
64 }
65 return false;
66 }
67
68 public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client)
69 {
70 if (remote_client.AgentId == m_regInfo.MasterAvatarAssignedUUID)
71 {
72 switch (Helpers.FieldToUTF8String(packet.MethodData.Method))
73 {
74 case "getinfo":
75 Console.WriteLine("GETINFO Requested");
76 this.sendRegionInfoPacketToAll();
77
78 break;
79 case "setregioninfo":
80 if (packet.ParamList.Length != 9)
81 {
82 OpenSim.Framework.Console.MainLog.Instance.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length");
83 }
84 else
85 {
86 m_regInfo.estateSettings.regionFlags = libsecondlife.Simulator.RegionFlags.None;
87
88 if (convertParamStringToBool(packet.ParamList[0].Parameter))
89 {
90 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.BlockTerraform;
91 }
92
93 if (convertParamStringToBool(packet.ParamList[1].Parameter))
94 {
95 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.NoFly;
96 }
97
98 if (convertParamStringToBool(packet.ParamList[2].Parameter))
99 {
100 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.AllowDamage;
101 }
102
103 if (convertParamStringToBool(packet.ParamList[3].Parameter) == false)
104 {
105 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.BlockLandResell;
106 }
107
108
109 int tempMaxAgents = Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter)));
110 m_regInfo.estateSettings.maxAgents = (byte)tempMaxAgents;
111
112 float tempObjectBonusFactor = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
113 m_regInfo.estateSettings.objectBonusFactor = tempObjectBonusFactor;
114
115 int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter));
116 m_regInfo.estateSettings.simAccess = (libsecondlife.Simulator.SimAccess)tempMatureLevel;
117
118
119 if (convertParamStringToBool(packet.ParamList[7].Parameter))
120 {
121 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.RestrictPushObject;
122 }
123
124 if (convertParamStringToBool(packet.ParamList[8].Parameter))
125 {
126 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.AllowParcelChanges;
127 }
128
129 sendRegionInfoPacketToAll();
130
131 }
132 break;
133 case "texturebase":
134 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
135 {
136 string s = Helpers.FieldToUTF8String(block.Parameter);
137 string[] splitField = s.Split(' ');
138 if (splitField.Length == 2)
139 {
140 LLUUID tempUUID = new LLUUID(splitField[1]);
141 switch (Convert.ToInt16(splitField[0]))
142 {
143 case 0:
144 m_regInfo.estateSettings.terrainBase0 = tempUUID;
145 break;
146 case 1:
147 m_regInfo.estateSettings.terrainBase1 = tempUUID;
148 break;
149 case 2:
150 m_regInfo.estateSettings.terrainBase2 = tempUUID;
151 break;
152 case 3:
153 m_regInfo.estateSettings.terrainBase3 = tempUUID;
154 break;
155 }
156 }
157 }
158 break;
159 case "texturedetail":
160 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
161 {
162
163 string s = Helpers.FieldToUTF8String(block.Parameter);
164 string[] splitField = s.Split(' ');
165 if (splitField.Length == 2)
166 {
167 LLUUID tempUUID = new LLUUID(splitField[1]);
168 switch (Convert.ToInt16(splitField[0]))
169 {
170 case 0:
171 m_regInfo.estateSettings.terrainDetail0 = tempUUID;
172 break;
173 case 1:
174 m_regInfo.estateSettings.terrainDetail1 = tempUUID;
175 break;
176 case 2:
177 m_regInfo.estateSettings.terrainDetail2 = tempUUID;
178 break;
179 case 3:
180 m_regInfo.estateSettings.terrainDetail3 = tempUUID;
181 break;
182 }
183 }
184 }
185 break;
186 case "textureheights":
187 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
188 {
189
190 string s = Helpers.FieldToUTF8String(block.Parameter);
191 string[] splitField = s.Split(' ');
192 if (splitField.Length == 3)
193 {
194
195 float tempHeightLow = (float)Convert.ToDecimal(splitField[1]);
196 float tempHeightHigh = (float)Convert.ToDecimal(splitField[2]);
197
198 switch (Convert.ToInt16(splitField[0]))
199 {
200 case 0:
201 m_regInfo.estateSettings.terrainStartHeight0 = tempHeightLow;
202 m_regInfo.estateSettings.terrainHeightRange0 = tempHeightHigh;
203 break;
204 case 1:
205 m_regInfo.estateSettings.terrainStartHeight1 = tempHeightLow;
206 m_regInfo.estateSettings.terrainHeightRange1 = tempHeightHigh;
207 break;
208 case 2:
209 m_regInfo.estateSettings.terrainStartHeight2 = tempHeightLow;
210 m_regInfo.estateSettings.terrainHeightRange2 = tempHeightHigh;
211 break;
212 case 3:
213 m_regInfo.estateSettings.terrainStartHeight3 = tempHeightLow;
214 m_regInfo.estateSettings.terrainHeightRange3 = tempHeightHigh;
215 break;
216 }
217 }
218 }
219 break;
220 case "texturecommit":
221 sendRegionHandshakeToAll();
222 break;
223 case "setregionterrain":
224 if (packet.ParamList.Length != 9)
225 {
226 OpenSim.Framework.Console.MainLog.Instance.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
227 }
228 else
229 {
230 m_regInfo.estateSettings.waterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter));
231 m_regInfo.estateSettings.terrainRaiseLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter));
232 m_regInfo.estateSettings.terrainLowerLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter));
233 m_regInfo.estateSettings.useFixedSun = this.convertParamStringToBool(packet.ParamList[4].Parameter);
234 m_regInfo.estateSettings.sunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
235
236 sendRegionInfoPacketToAll();
237 }
238 break;
239 default:
240 OpenSim.Framework.Console.MainLog.Instance.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString());
241 break;
242 }
243 }
244 }
245
246 public void sendRegionInfoPacketToAll()
247 {
248 List<Avatar> avatars = m_world.RequestAvatarList();
249
250 for (int i = 0; i < avatars.Count; i++)
251 {
252 this.sendRegionInfoPacket(avatars[i].ControllingClient);
253 }
254 }
255
256 public void sendRegionHandshakeToAll()
257 {
258 List<Avatar> avatars = m_world.RequestAvatarList();
259
260 for (int i = 0; i < avatars.Count; i++)
261 {
262 this.sendRegionHandshake(avatars[i].ControllingClient);
263 }
264 }
265
266 public void sendRegionInfoPacket(IClientAPI remote_client)
267 {
268 Encoding _enc = System.Text.Encoding.ASCII;
269
270 AgentCircuitData circuitData = remote_client.RequestClientInfo();
271
272 RegionInfoPacket regionInfoPacket = new RegionInfoPacket();
273 regionInfoPacket.AgentData.AgentID = circuitData.AgentID;
274 regionInfoPacket.AgentData.SessionID = circuitData.SessionID;
275 regionInfoPacket.RegionInfo.BillableFactor = m_regInfo.estateSettings.billableFactor;
276 regionInfoPacket.RegionInfo.EstateID = m_regInfo.estateSettings.estateID;
277 regionInfoPacket.RegionInfo.MaxAgents = m_regInfo.estateSettings.maxAgents;
278 regionInfoPacket.RegionInfo.ObjectBonusFactor = m_regInfo.estateSettings.objectBonusFactor;
279 regionInfoPacket.RegionInfo.ParentEstateID = m_regInfo.estateSettings.parentEstateID;
280 regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.estateSettings.pricePerMeter;
281 regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.estateSettings.redirectGridX;
282 regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.estateSettings.redirectGridY;
283 regionInfoPacket.RegionInfo.RegionFlags = (uint)m_regInfo.estateSettings.regionFlags;
284 regionInfoPacket.RegionInfo.SimAccess = (byte)m_regInfo.estateSettings.simAccess;
285 regionInfoPacket.RegionInfo.SimName = _enc.GetBytes( m_regInfo.RegionName);
286 regionInfoPacket.RegionInfo.SunHour = m_regInfo.estateSettings.sunHour;
287 regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.estateSettings.terrainLowerLimit;
288 regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.estateSettings.terrainRaiseLimit;
289 regionInfoPacket.RegionInfo.UseEstateSun = !m_regInfo.estateSettings.useFixedSun;
290 regionInfoPacket.RegionInfo.WaterHeight = m_regInfo.estateSettings.waterHeight;
291
292 remote_client.OutPacket(regionInfoPacket);
293 }
294
295 public void sendRegionHandshake(IClientAPI remoteClient)
296 {
297 remoteClient.SendRegionHandshake(m_regInfo);
298 }
299
300 }
301}
diff --git a/OpenSim/Region/Environment/OpenSim.Region.Environment.csproj b/OpenSim/Region/Environment/OpenSim.Region.Environment.csproj
new file mode 100644
index 0000000..428f381
--- /dev/null
+++ b/OpenSim/Region/Environment/OpenSim.Region.Environment.csproj
@@ -0,0 +1,212 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{DCBA491C-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Environment</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Environment</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Axiom.MathLib.dll" >
62 <HintPath>..\..\..\bin\Axiom.MathLib.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="Db4objects.Db4o.dll" >
66 <HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="libsecondlife.dll" >
70 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="Microsoft.JScript" >
74 <HintPath>Microsoft.JScript.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="System" >
78 <HintPath>System.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="System.Xml" >
82 <HintPath>System.Xml.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 <Reference Include="XMLRPC.dll" >
86 <HintPath>..\..\..\bin\XMLRPC.dll</HintPath>
87 <Private>False</Private>
88 </Reference>
89 </ItemGroup>
90 <ItemGroup>
91 <ProjectReference Include="..\..\Framework\General\OpenSim.Framework.csproj">
92 <Name>OpenSim.Framework</Name>
93 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
94 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
95 <Private>False</Private>
96 </ProjectReference>
97 <ProjectReference Include="..\..\Framework\Communications\OpenSim.Framework.Communications.csproj">
98 <Name>OpenSim.Framework.Communications</Name>
99 <Project>{CB52B7E7-0000-0000-0000-000000000000}</Project>
100 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
101 <Private>False</Private>
102 </ProjectReference>
103 <ProjectReference Include="..\..\Framework\Console\OpenSim.Framework.Console.csproj">
104 <Name>OpenSim.Framework.Console</Name>
105 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
106 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
107 <Private>False</Private>
108 </ProjectReference>
109 <ProjectReference Include="..\..\Framework\GenericConfig\Xml\OpenSim.Framework.GenericConfig.Xml.csproj">
110 <Name>OpenSim.Framework.GenericConfig.Xml</Name>
111 <Project>{C74E4A30-0000-0000-0000-000000000000}</Project>
112 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
113 <Private>False</Private>
114 </ProjectReference>
115 <ProjectReference Include="..\..\Framework\Servers\OpenSim.Framework.Servers.csproj">
116 <Name>OpenSim.Framework.Servers</Name>
117 <Project>{2CC71860-0000-0000-0000-000000000000}</Project>
118 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
119 <Private>False</Private>
120 </ProjectReference>
121 <ProjectReference Include="..\Caches\OpenSim.Region.Caches.csproj">
122 <Name>OpenSim.Region.Caches</Name>
123 <Project>{61FCCDB3-0000-0000-0000-000000000000}</Project>
124 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
125 <Private>False</Private>
126 </ProjectReference>
127 <ProjectReference Include="..\Capabilities\OpenSim.Region.Capabilities.csproj">
128 <Name>OpenSim.Region.Capabilities</Name>
129 <Project>{39038E85-0000-0000-0000-000000000000}</Project>
130 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
131 <Private>False</Private>
132 </ProjectReference>
133 <ProjectReference Include="..\Physics\Manager\OpenSim.Region.Physics.Manager.csproj">
134 <Name>OpenSim.Region.Physics.Manager</Name>
135 <Project>{F4FF31EB-0000-0000-0000-000000000000}</Project>
136 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
137 <Private>False</Private>
138 </ProjectReference>
139 <ProjectReference Include="..\Terrain.BasicTerrain\OpenSim.Region.Terrain.BasicTerrain.csproj">
140 <Name>OpenSim.Region.Terrain.BasicTerrain</Name>
141 <Project>{C9E0F891-0000-0000-0000-000000000000}</Project>
142 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
143 <Private>False</Private>
144 </ProjectReference>
145 </ItemGroup>
146 <ItemGroup>
147 <Compile Include="EstateManager.cs">
148 <SubType>Code</SubType>
149 </Compile>
150 <Compile Include="ParcelManager.cs">
151 <SubType>Code</SubType>
152 </Compile>
153 <Compile Include="RegionManager.cs">
154 <SubType>Code</SubType>
155 </Compile>
156 <Compile Include="Scenes\Entity.cs">
157 <SubType>Code</SubType>
158 </Compile>
159 <Compile Include="Scenes\IScenePresenceBody.cs">
160 <SubType>Code</SubType>
161 </Compile>
162 <Compile Include="Scenes\Primitive.cs">
163 <SubType>Code</SubType>
164 </Compile>
165 <Compile Include="Scenes\Scene.cs">
166 <SubType>Code</SubType>
167 </Compile>
168 <Compile Include="Scenes\Scene.PacketHandlers.cs">
169 <SubType>Code</SubType>
170 </Compile>
171 <Compile Include="Scenes\SceneBase.cs">
172 <SubType>Code</SubType>
173 </Compile>
174 <Compile Include="Scenes\SceneEvents.cs">
175 <SubType>Code</SubType>
176 </Compile>
177 <Compile Include="Scenes\SceneObject.cs">
178 <SubType>Code</SubType>
179 </Compile>
180 <Compile Include="Scenes\ScenePresence.Animations.cs">
181 <SubType>Code</SubType>
182 </Compile>
183 <Compile Include="Scenes\ScenePresence.Body.cs">
184 <SubType>Code</SubType>
185 </Compile>
186 <Compile Include="Scenes\ScenePresence.cs">
187 <SubType>Code</SubType>
188 </Compile>
189 <Compile Include="Scenes\scripting\Script.cs">
190 <SubType>Code</SubType>
191 </Compile>
192 <Compile Include="Scenes\scripting\ScriptInfo.cs">
193 <SubType>Code</SubType>
194 </Compile>
195 <Compile Include="Scenes\scripting\ScriptManager.cs">
196 <SubType>Code</SubType>
197 </Compile>
198 <Compile Include="Scenes\scripting\Engines\CSharpScriptEngine.cs">
199 <SubType>Code</SubType>
200 </Compile>
201 <Compile Include="Scenes\scripting\Engines\JScriptEngine.cs">
202 <SubType>Code</SubType>
203 </Compile>
204 </ItemGroup>
205 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
206 <PropertyGroup>
207 <PreBuildEvent>
208 </PreBuildEvent>
209 <PostBuildEvent>
210 </PostBuildEvent>
211 </PropertyGroup>
212</Project>
diff --git a/OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build b/OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build
new file mode 100644
index 0000000..2fa5e76
--- /dev/null
+++ b/OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build
@@ -0,0 +1,72 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Environment" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Environment" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="EstateManager.cs" />
15 <include name="ParcelManager.cs" />
16 <include name="RegionManager.cs" />
17 <include name="Scenes/Entity.cs" />
18 <include name="Scenes/IScenePresenceBody.cs" />
19 <include name="Scenes/Primitive.cs" />
20 <include name="Scenes/Scene.cs" />
21 <include name="Scenes/Scene.PacketHandlers.cs" />
22 <include name="Scenes/SceneBase.cs" />
23 <include name="Scenes/SceneEvents.cs" />
24 <include name="Scenes/SceneObject.cs" />
25 <include name="Scenes/ScenePresence.Animations.cs" />
26 <include name="Scenes/ScenePresence.Body.cs" />
27 <include name="Scenes/ScenePresence.cs" />
28 <include name="Scenes/scripting/Script.cs" />
29 <include name="Scenes/scripting/ScriptInfo.cs" />
30 <include name="Scenes/scripting/ScriptManager.cs" />
31 <include name="Scenes/scripting/Engines/CSharpScriptEngine.cs" />
32 <include name="Scenes/scripting/Engines/JScriptEngine.cs" />
33 </sources>
34 <references basedir="${project::get-base-directory()}">
35 <lib>
36 <include name="${project::get-base-directory()}" />
37 <include name="${project::get-base-directory()}/${build.dir}" />
38 </lib>
39 <include name="../../../bin/Axiom.MathLib.dll" />
40 <include name="../../../bin/Db4objects.Db4o.dll" />
41 <include name="../../../bin/libsecondlife.dll" />
42 <include name="Microsoft.JScript.dll" />
43 <include name="../../../bin/OpenSim.Framework.dll" />
44 <include name="../../../bin/OpenSim.Framework.Communications.dll" />
45 <include name="../../../bin/OpenSim.Framework.Console.dll" />
46 <include name="../../../bin/OpenSim.Framework.GenericConfig.Xml.dll" />
47 <include name="../../../bin/OpenSim.Framework.Servers.dll" />
48 <include name="../../../bin/OpenSim.Region.Caches.dll" />
49 <include name="../../../bin/OpenSim.Region.Capabilities.dll" />
50 <include name="../../../bin/OpenSim.Region.Physics.Manager.dll" />
51 <include name="../../../bin/OpenSim.Region.Terrain.BasicTerrain.dll" />
52 <include name="System.dll" />
53 <include name="System.Xml.dll" />
54 <include name="../../../bin/XMLRPC.dll" />
55 </references>
56 </csc>
57 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
58 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
59 <copy todir="${project::get-base-directory()}/../../../bin/">
60 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
61 <include name="*.dll"/>
62 <include name="*.exe"/>
63 </fileset>
64 </copy>
65 </target>
66 <target name="clean">
67 <delete dir="${bin.dir}" failonerror="false" />
68 <delete dir="${obj.dir}" failonerror="false" />
69 </target>
70 <target name="doc" description="Creates documentation.">
71 </target>
72</project>
diff --git a/OpenSim/Region/Environment/ParcelManager.cs b/OpenSim/Region/Environment/ParcelManager.cs
new file mode 100644
index 0000000..1cab4ab
--- /dev/null
+++ b/OpenSim/Region/Environment/ParcelManager.cs
@@ -0,0 +1,892 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32using libsecondlife.Packets;
33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework.Types;
35using OpenSim.Region.Environment.Scenes;
36using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence;
37
38namespace OpenSim.Region.Environment
39{
40
41
42 #region ParcelManager Class
43 /// <summary>
44 /// Handles Parcel objects and operations requiring information from other Parcel objects (divide, join, etc)
45 /// </summary>
46 public class ParcelManager : OpenSim.Framework.Interfaces.ILocalStorageParcelReceiver
47 {
48
49 #region Constants
50 //Parcel types set with flags in ParcelOverlay.
51 //Only one of these can be used.
52 public const byte PARCEL_TYPE_PUBLIC = (byte)0; //Equals 00000000
53 public const byte PARCEL_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001
54 public const byte PARCEL_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010
55 public const byte PARCEL_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011
56 public const byte PARCEL_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100
57 public const byte PARCEL_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101
58
59
60 //Flags that when set, a border on the given side will be placed
61 //NOTE: North and East is assumable by the west and south sides (if parcel to east has a west border, then I have an east border; etc)
62 //This took forever to figure out -- jeesh. /blame LL for even having to send these
63 public const byte PARCEL_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000
64 public const byte PARCEL_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000
65
66 //RequestResults (I think these are right, they seem to work):
67 public const int PARCEL_RESULT_ONE_PARCEL = 0; // The request they made contained only one parcel
68 public const int PARCEL_RESULT_MULTIPLE_PARCELS = 1; // The request they made contained more than one parcel
69
70 //These are other constants. Yay!
71 public const int START_PARCEL_LOCAL_ID = 1;
72 #endregion
73
74 #region Member Variables
75 public Dictionary<int, Parcel> parcelList = new Dictionary<int, Parcel>();
76 private int lastParcelLocalID = START_PARCEL_LOCAL_ID - 1;
77 private int[,] parcelIDList = new int[64, 64];
78
79 private Scene m_world;
80 private RegionInfo m_regInfo;
81
82 #endregion
83
84 #region Constructors
85 public ParcelManager(Scene world, RegionInfo reginfo)
86 {
87
88 m_world = world;
89 m_regInfo = reginfo;
90 parcelIDList.Initialize();
91
92 }
93 #endregion
94
95 #region Member Functions
96
97 #region Parcel From Storage Functions
98 public void ParcelFromStorage(ParcelData data)
99 {
100 Parcel new_parcel = new Parcel(data.ownerID, data.isGroupOwned, m_world);
101 new_parcel.parcelData = data.Copy();
102 new_parcel.setParcelBitmapFromByteArray();
103 addParcel(new_parcel);
104
105 }
106
107 public void NoParcelDataFromStorage()
108 {
109 resetSimParcels();
110 }
111 #endregion
112
113 #region Parcel Add/Remove/Get/Create
114 /// <summary>
115 /// Creates a basic Parcel object without an owner (a zeroed key)
116 /// </summary>
117 /// <returns></returns>
118 public Parcel createBaseParcel()
119 {
120 return new Parcel(new LLUUID(), false, m_world);
121 }
122
123 /// <summary>
124 /// Adds a parcel to the stored list and adds them to the parcelIDList to what they own
125 /// </summary>
126 /// <param name="new_parcel">The parcel being added</param>
127 public void addParcel(Parcel new_parcel)
128 {
129 lastParcelLocalID++;
130 new_parcel.parcelData.localID = lastParcelLocalID;
131 parcelList.Add(lastParcelLocalID, new_parcel.Copy());
132
133
134 bool[,] parcelBitmap = new_parcel.getParcelBitmap();
135 int x, y;
136 for (x = 0; x < 64; x++)
137 {
138 for (y = 0; y < 64; y++)
139 {
140 if (parcelBitmap[x, y])
141 {
142 parcelIDList[x, y] = lastParcelLocalID;
143 }
144 }
145 }
146 parcelList[lastParcelLocalID].forceUpdateParcelInfo();
147
148
149 }
150 /// <summary>
151 /// Removes a parcel from the list. Will not remove if local_id is still owning an area in parcelIDList
152 /// </summary>
153 /// <param name="local_id">Parcel.localID of the parcel to remove.</param>
154 public void removeParcel(int local_id)
155 {
156 int x, y;
157 for (x = 0; x < 64; x++)
158 {
159 for (y = 0; y < 64; y++)
160 {
161 if (parcelIDList[x, y] == local_id)
162 {
163 throw new Exception("Could not remove parcel. Still being used at " + x + ", " + y);
164 }
165 }
166 }
167 m_world.localStorage.RemoveParcel(parcelList[local_id].parcelData);
168 parcelList.Remove(local_id);
169 }
170
171 private void performFinalParcelJoin(Parcel master, Parcel slave)
172 {
173 int x, y;
174 bool[,] parcelBitmapSlave = slave.getParcelBitmap();
175 for (x = 0; x < 64; x++)
176 {
177 for (y = 0; y < 64; y++)
178 {
179 if (parcelBitmapSlave[x, y])
180 {
181 parcelIDList[x, y] = master.parcelData.localID;
182 }
183 }
184 }
185 removeParcel(slave.parcelData.localID);
186 }
187 /// <summary>
188 /// Get the parcel at the specified point
189 /// </summary>
190 /// <param name="x">Value between 0 - 256 on the x axis of the point</param>
191 /// <param name="y">Value between 0 - 256 on the y axis of the point</param>
192 /// <returns>Parcel at the point supplied</returns>
193 public Parcel getParcel(int x, int y)
194 {
195 if (x > 256 || y > 256 || x < 0 || y < 0)
196 {
197 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
198 }
199 else
200 {
201 return parcelList[parcelIDList[x / 4, y / 4]];
202 }
203
204 }
205 #endregion
206
207 #region Parcel Modification
208 /// <summary>
209 /// Subdivides a parcel
210 /// </summary>
211 /// <param name="start_x">West Point</param>
212 /// <param name="start_y">South Point</param>
213 /// <param name="end_x">East Point</param>
214 /// <param name="end_y">North Point</param>
215 /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param>
216 /// <returns>Returns true if successful</returns>
217 private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id)
218 {
219 //First, lets loop through the points and make sure they are all in the same parcel
220 //Get the parcel at start
221 Parcel startParcel = getParcel(start_x, start_y);
222 if (startParcel == null) return false; //No such parcel at the beginning
223
224 //Loop through the points
225 try
226 {
227 int totalX = end_x - start_x;
228 int totalY = end_y - start_y;
229 int x, y;
230 for (y = 0; y < totalY; y++)
231 {
232 for (x = 0; x < totalX; x++)
233 {
234 Parcel tempParcel = getParcel(start_x + x, start_y + y);
235 if (tempParcel == null) return false; //No such parcel at that point
236 if (tempParcel != startParcel) return false; //Subdividing over 2 parcels; no-no
237 }
238 }
239 }
240 catch (Exception)
241 {
242 return false; //Exception. For now, lets skip subdivision
243 }
244
245 //If we are still here, then they are subdividing within one parcel
246 //Check owner
247 if (startParcel.parcelData.ownerID != attempting_user_id)
248 {
249 return false; //They cant do this!
250 }
251
252 //Lets create a new parcel with bitmap activated at that point (keeping the old parcels info)
253 Parcel newParcel = startParcel.Copy();
254 newParcel.parcelData.parcelName = "Subdivision of " + newParcel.parcelData.parcelName;
255 newParcel.parcelData.globalID = LLUUID.Random();
256
257 newParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(start_x, start_y, end_x, end_y));
258
259 //Now, lets set the subdivision area of the original to false
260 int startParcelIndex = startParcel.parcelData.localID;
261 parcelList[startParcelIndex].setParcelBitmap(Parcel.modifyParcelBitmapSquare(startParcel.getParcelBitmap(), start_x, start_y, end_x, end_y, false));
262 parcelList[startParcelIndex].forceUpdateParcelInfo();
263
264
265 //Now add the new parcel
266 addParcel(newParcel);
267
268
269
270
271
272 return true;
273 }
274 /// <summary>
275 /// Join 2 parcels together
276 /// </summary>
277 /// <param name="start_x">x value in first parcel</param>
278 /// <param name="start_y">y value in first parcel</param>
279 /// <param name="end_x">x value in second parcel</param>
280 /// <param name="end_y">y value in second parcel</param>
281 /// <param name="attempting_user_id">LLUUID of the avatar trying to join the parcels</param>
282 /// <returns>Returns true if successful</returns>
283 private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id)
284 {
285 end_x -= 4;
286 end_y -= 4;
287
288 //NOTE: The following only connects the parcels in each corner and not all the parcels that are within the selection box!
289 //This should be fixed later -- somewhat "incomplete code" --Ming
290 Parcel startParcel, endParcel;
291
292 try
293 {
294 startParcel = getParcel(start_x, start_y);
295 endParcel = getParcel(end_x, end_y);
296 }
297 catch (Exception)
298 {
299 return false; //Error occured when trying to get the start and end parcels
300 }
301 if (startParcel == endParcel)
302 {
303 return false; //Subdivision of the same parcel is not allowed
304 }
305
306 //Check the parcel owners:
307 if (startParcel.parcelData.ownerID != endParcel.parcelData.ownerID)
308 {
309 return false;
310 }
311 if (startParcel.parcelData.ownerID != attempting_user_id)
312 {
313 //TODO: Group editing stuff. Avatar owner support for now
314 return false;
315 }
316
317 //Same owners! Lets join them
318 //Merge them to startParcel
319 parcelList[startParcel.parcelData.localID].setParcelBitmap(Parcel.mergeParcelBitmaps(startParcel.getParcelBitmap(), endParcel.getParcelBitmap()));
320 performFinalParcelJoin(startParcel, endParcel);
321
322 return true;
323
324
325
326 }
327 #endregion
328
329 #region Parcel Updating
330 /// <summary>
331 /// Where we send the ParcelOverlay packet to the client
332 /// </summary>
333 /// <param name="remote_client">The object representing the client</param>
334 public void sendParcelOverlay(IClientAPI remote_client)
335 {
336 const int PARCEL_BLOCKS_PER_PACKET = 1024;
337 int x, y = 0;
338 byte[] byteArray = new byte[PARCEL_BLOCKS_PER_PACKET];
339 int byteArrayCount = 0;
340 int sequenceID = 0;
341 ParcelOverlayPacket packet;
342
343 for (y = 0; y < 64; y++)
344 {
345 for (x = 0; x < 64; x++)
346 {
347 byte tempByte = (byte)0; //This represents the byte for the current 4x4
348 Parcel currentParcelBlock = getParcel(x * 4, y * 4);
349
350 if (currentParcelBlock.parcelData.ownerID == remote_client.AgentId)
351 {
352 //Owner Flag
353 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_REQUESTER);
354 }
355 else if (currentParcelBlock.parcelData.salePrice > 0 && (currentParcelBlock.parcelData.authBuyerID == LLUUID.Zero || currentParcelBlock.parcelData.authBuyerID == remote_client.AgentId))
356 {
357 //Sale Flag
358 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_IS_FOR_SALE);
359 }
360 else if (currentParcelBlock.parcelData.ownerID == LLUUID.Zero)
361 {
362 //Public Flag
363 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_PUBLIC);
364 }
365 else
366 {
367 //Other Flag
368 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_OTHER);
369 }
370
371
372 //Now for border control
373 if (x == 0)
374 {
375 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST);
376 }
377 else if (getParcel((x - 1) * 4, y * 4) != currentParcelBlock)
378 {
379 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST);
380 }
381
382 if (y == 0)
383 {
384 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH);
385 }
386 else if (getParcel(x * 4, (y - 1) * 4) != currentParcelBlock)
387 {
388 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH);
389 }
390
391 byteArray[byteArrayCount] = tempByte;
392 byteArrayCount++;
393 if (byteArrayCount >= PARCEL_BLOCKS_PER_PACKET)
394 {
395 byteArrayCount = 0;
396 packet = new ParcelOverlayPacket();
397 packet.ParcelData.Data = byteArray;
398 packet.ParcelData.SequenceID = sequenceID;
399 remote_client.OutPacket((Packet)packet);
400 sequenceID++;
401 byteArray = new byte[PARCEL_BLOCKS_PER_PACKET];
402 }
403 }
404 }
405
406 packet = new ParcelOverlayPacket();
407 packet.ParcelData.Data = byteArray;
408 packet.ParcelData.SequenceID = sequenceID; //Eh?
409 remote_client.OutPacket((Packet)packet);
410 }
411
412 public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client)
413 {
414 //Get the parcels within the bounds
415 List<Parcel> temp = new List<Parcel>();
416 int x, y, i;
417 int inc_x = end_x - start_x;
418 int inc_y = end_y - start_y;
419 for (x = 0; x < inc_x; x++)
420 {
421 for (y = 0; y < inc_y; y++)
422 {
423 OpenSim.Region.Environment.Parcel currentParcel = getParcel(start_x + x, start_y + y);
424 if (!temp.Contains(currentParcel))
425 {
426 currentParcel.forceUpdateParcelInfo();
427 temp.Add(currentParcel);
428 }
429 }
430 }
431
432 int requestResult = ParcelManager.PARCEL_RESULT_ONE_PARCEL;
433 if (temp.Count > 1)
434 {
435 requestResult = ParcelManager.PARCEL_RESULT_MULTIPLE_PARCELS;
436 }
437
438 for (i = 0; i < temp.Count; i++)
439 {
440 temp[i].sendParcelProperties(sequence_id, snap_selection, requestResult, remote_client);
441 }
442
443
444 sendParcelOverlay(remote_client);
445 }
446
447 public void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
448 {
449 if (parcelList.ContainsKey(packet.ParcelData.LocalID))
450 {
451 parcelList[packet.ParcelData.LocalID].updateParcelProperties(packet, remote_client);
452 }
453 }
454 public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client)
455 {
456 subdivide(west, south, east, north, remote_client.AgentId);
457 }
458 public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client)
459 {
460 join(west, south, east, north, remote_client.AgentId);
461
462 }
463 #endregion
464
465 /// <summary>
466 /// Resets the sim to the default parcel (full sim parcel owned by the default user)
467 /// </summary>
468 public void resetSimParcels()
469 {
470 //Remove all the parcels in the sim and add a blank, full sim parcel set to public
471 parcelList.Clear();
472 lastParcelLocalID = START_PARCEL_LOCAL_ID - 1;
473 parcelIDList.Initialize();
474
475 Parcel fullSimParcel = new Parcel(LLUUID.Zero, false, m_world);
476
477 fullSimParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(0, 0, 256, 256));
478 fullSimParcel.parcelData.parcelName = "Your Sim Parcel";
479 fullSimParcel.parcelData.parcelDesc = "";
480
481 fullSimParcel.parcelData.ownerID = m_regInfo.MasterAvatarAssignedUUID;
482 fullSimParcel.parcelData.salePrice = 1;
483 fullSimParcel.parcelData.parcelFlags = libsecondlife.Parcel.ParcelFlags.ForSale;
484 fullSimParcel.parcelData.parcelStatus = libsecondlife.Parcel.ParcelStatus.Leased;
485
486 addParcel(fullSimParcel);
487
488 }
489 #endregion
490 }
491 #endregion
492
493
494 #region Parcel Class
495 /// <summary>
496 /// Keeps track of a specific parcel's information
497 /// </summary>
498 public class Parcel
499 {
500 #region Member Variables
501 public ParcelData parcelData = new ParcelData();
502 public Scene m_world;
503
504 private bool[,] parcelBitmap = new bool[64, 64];
505
506 #endregion
507
508
509 #region Constructors
510 public Parcel(LLUUID owner_id, bool is_group_owned, Scene world)
511 {
512 m_world = world;
513 parcelData.ownerID = owner_id;
514 parcelData.isGroupOwned = is_group_owned;
515
516 }
517 #endregion
518
519
520 #region Member Functions
521
522 #region General Functions
523 /// <summary>
524 /// Checks to see if this parcel contains a point
525 /// </summary>
526 /// <param name="x"></param>
527 /// <param name="y"></param>
528 /// <returns>Returns true if the parcel contains the specified point</returns>
529 public bool containsPoint(int x, int y)
530 {
531 if (x >= 0 && y >= 0 && x <= 256 && x <= 256)
532 {
533 return (parcelBitmap[x / 4, y / 4] == true);
534 }
535 else
536 {
537 return false;
538 }
539 }
540
541 public Parcel Copy()
542 {
543 Parcel newParcel = new Parcel(this.parcelData.ownerID, this.parcelData.isGroupOwned, m_world);
544
545 //Place all new variables here!
546 newParcel.parcelBitmap = (bool[,])(this.parcelBitmap.Clone());
547 newParcel.parcelData = parcelData.Copy();
548
549 return newParcel;
550 }
551
552 #endregion
553
554
555 #region Packet Request Handling
556 /// <summary>
557 /// Sends parcel properties as requested
558 /// </summary>
559 /// <param name="sequence_id">ID sent by client for them to keep track of</param>
560 /// <param name="snap_selection">Bool sent by client for them to use</param>
561 /// <param name="remote_client">Object representing the client</param>
562 public void sendParcelProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client)
563 {
564
565 ParcelPropertiesPacket updatePacket = new ParcelPropertiesPacket();
566 updatePacket.ParcelData.AABBMax = parcelData.AABBMax;
567 updatePacket.ParcelData.AABBMin = parcelData.AABBMin;
568 updatePacket.ParcelData.Area = parcelData.area;
569 updatePacket.ParcelData.AuctionID = parcelData.auctionID;
570 updatePacket.ParcelData.AuthBuyerID = parcelData.authBuyerID; //unemplemented
571
572 updatePacket.ParcelData.Bitmap = parcelData.parcelBitmapByteArray;
573
574 updatePacket.ParcelData.Desc = libsecondlife.Helpers.StringToField(parcelData.parcelDesc);
575 updatePacket.ParcelData.Category = (byte)parcelData.category;
576 updatePacket.ParcelData.ClaimDate = parcelData.claimDate;
577 updatePacket.ParcelData.ClaimPrice = parcelData.claimPrice;
578 updatePacket.ParcelData.GroupID = parcelData.groupID;
579 updatePacket.ParcelData.GroupPrims = parcelData.groupPrims;
580 updatePacket.ParcelData.IsGroupOwned = parcelData.isGroupOwned;
581 updatePacket.ParcelData.LandingType = (byte)parcelData.landingType;
582 updatePacket.ParcelData.LocalID = parcelData.localID;
583 updatePacket.ParcelData.MaxPrims = 1000; //unemplemented
584 updatePacket.ParcelData.MediaAutoScale = parcelData.mediaAutoScale;
585 updatePacket.ParcelData.MediaID = parcelData.mediaID;
586 updatePacket.ParcelData.MediaURL = Helpers.StringToField(parcelData.mediaURL);
587 updatePacket.ParcelData.MusicURL = Helpers.StringToField(parcelData.musicURL);
588 updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName);
589 updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented
590 updatePacket.ParcelData.OtherCount = 0; //unemplemented
591 updatePacket.ParcelData.OtherPrims = 0; //unemplented
592 updatePacket.ParcelData.OwnerID = parcelData.ownerID;
593 updatePacket.ParcelData.OwnerPrims = 0; //unemplemented
594 updatePacket.ParcelData.ParcelFlags = (uint)parcelData.parcelFlags; //unemplemented
595 updatePacket.ParcelData.ParcelPrimBonus = (float)1.0; //unemplemented
596 updatePacket.ParcelData.PassHours = parcelData.passHours;
597 updatePacket.ParcelData.PassPrice = parcelData.passPrice;
598 updatePacket.ParcelData.PublicCount = 0; //unemplemented
599 updatePacket.ParcelData.RegionDenyAnonymous = false; //unemplemented
600 updatePacket.ParcelData.RegionDenyIdentified = false; //unemplemented
601 updatePacket.ParcelData.RegionDenyTransacted = false; //unemplemented
602 updatePacket.ParcelData.RegionPushOverride = true; //unemplemented
603 updatePacket.ParcelData.RentPrice = 0; //??
604 updatePacket.ParcelData.RequestResult = request_result;
605 updatePacket.ParcelData.SalePrice = parcelData.salePrice; //unemplemented
606 updatePacket.ParcelData.SelectedPrims = 0; //unemeplemented
607 updatePacket.ParcelData.SelfCount = 0;//unemplemented
608 updatePacket.ParcelData.SequenceID = sequence_id;
609 updatePacket.ParcelData.SimWideMaxPrims = 15000; //unemplemented
610 updatePacket.ParcelData.SimWideTotalPrims = 0; //unemplemented
611 updatePacket.ParcelData.SnapSelection = snap_selection;
612 updatePacket.ParcelData.SnapshotID = parcelData.snapshotID;
613 updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus;
614 updatePacket.ParcelData.TotalPrims = 0; //unemplemented
615 updatePacket.ParcelData.UserLocation = parcelData.userLocation;
616 updatePacket.ParcelData.UserLookAt = parcelData.userLookAt;
617 remote_client.OutPacket((Packet)updatePacket);
618 }
619
620 public void updateParcelProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
621 {
622 if (remote_client.AgentId == parcelData.ownerID)
623 {
624 //Needs later group support
625 parcelData.authBuyerID = packet.ParcelData.AuthBuyerID;
626 parcelData.category = (libsecondlife.Parcel.ParcelCategory)packet.ParcelData.Category;
627 parcelData.parcelDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc);
628 parcelData.groupID = packet.ParcelData.GroupID;
629 parcelData.landingType = packet.ParcelData.LandingType;
630 parcelData.mediaAutoScale = packet.ParcelData.MediaAutoScale;
631 parcelData.mediaID = packet.ParcelData.MediaID;
632 parcelData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL);
633 parcelData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL);
634 parcelData.parcelName = libsecondlife.Helpers.FieldToUTF8String(packet.ParcelData.Name);
635 parcelData.parcelFlags = (libsecondlife.Parcel.ParcelFlags)packet.ParcelData.ParcelFlags;
636 parcelData.passHours = packet.ParcelData.PassHours;
637 parcelData.passPrice = packet.ParcelData.PassPrice;
638 parcelData.salePrice = packet.ParcelData.SalePrice;
639 parcelData.snapshotID = packet.ParcelData.SnapshotID;
640 parcelData.userLocation = packet.ParcelData.UserLocation;
641 parcelData.userLookAt = packet.ParcelData.UserLookAt;
642
643 List<Avatar> avatars = m_world.RequestAvatarList();
644
645 for (int i = 0; i < avatars.Count; i++)
646 {
647 Parcel over = m_world.parcelManager.getParcel((int)Math.Round(avatars[i].Pos.X), (int)Math.Round(avatars[i].Pos.Y));
648 if (over == this)
649 {
650 sendParcelProperties(0, false, 0, avatars[i].ControllingClient);
651 }
652 }
653
654 }
655 }
656 #endregion
657
658
659 #region Update Functions
660 /// <summary>
661 /// Updates the AABBMin and AABBMax values after area/shape modification of parcel
662 /// </summary>
663 private void updateAABBAndAreaValues()
664 {
665 int min_x = 64;
666 int min_y = 64;
667 int max_x = 0;
668 int max_y = 0;
669 int tempArea = 0;
670 int x, y;
671 for (x = 0; x < 64; x++)
672 {
673 for (y = 0; y < 64; y++)
674 {
675 if (parcelBitmap[x, y] == true)
676 {
677 if (min_x > x) min_x = x;
678 if (min_y > y) min_y = y;
679 if (max_x < x) max_x = x;
680 if (max_y < y) max_y = y;
681 tempArea += 16; //16sqm parcel
682 }
683 }
684 }
685 parcelData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), m_world.Terrain[(min_x * 4), (min_y * 4)]);
686 parcelData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), m_world.Terrain[(max_x * 4), (max_y * 4)]);
687 parcelData.area = tempArea;
688 }
689
690 public void updateParcelBitmapByteArray()
691 {
692 parcelData.parcelBitmapByteArray = convertParcelBitmapToBytes();
693 }
694
695 /// <summary>
696 /// Update all settings in parcel such as area, bitmap byte array, etc
697 /// </summary>
698 public void forceUpdateParcelInfo()
699 {
700 this.updateAABBAndAreaValues();
701 this.updateParcelBitmapByteArray();
702 }
703
704 public void setParcelBitmapFromByteArray()
705 {
706 parcelBitmap = convertBytesToParcelBitmap();
707 }
708 #endregion
709
710
711 #region Parcel Bitmap Functions
712 /// <summary>
713 /// Sets the parcel's bitmap manually
714 /// </summary>
715 /// <param name="bitmap">64x64 block representing where this parcel is on a map</param>
716 public void setParcelBitmap(bool[,] bitmap)
717 {
718 if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2)
719 {
720 //Throw an exception - The bitmap is not 64x64
721 throw new Exception("Error: Invalid Parcel Bitmap");
722 }
723 else
724 {
725 //Valid: Lets set it
726 parcelBitmap = bitmap;
727 forceUpdateParcelInfo();
728
729 }
730 }
731 /// <summary>
732 /// Gets the parcels bitmap manually
733 /// </summary>
734 /// <returns></returns>
735 public bool[,] getParcelBitmap()
736 {
737 return parcelBitmap;
738 }
739 /// <summary>
740 /// Converts the parcel bitmap to a packet friendly byte array
741 /// </summary>
742 /// <returns></returns>
743 private byte[] convertParcelBitmapToBytes()
744 {
745 byte[] tempConvertArr = new byte[512];
746 byte tempByte = 0;
747 int x, y, i, byteNum = 0;
748 i = 0;
749 for (y = 0; y < 64; y++)
750 {
751 for (x = 0; x < 64; x++)
752 {
753 tempByte = Convert.ToByte(tempByte | Convert.ToByte(parcelBitmap[x, y]) << (i++ % 8));
754 if (i % 8 == 0)
755 {
756 tempConvertArr[byteNum] = tempByte;
757 tempByte = (byte)0;
758 i = 0;
759 byteNum++;
760 }
761 }
762 }
763 return tempConvertArr;
764 }
765
766 private bool[,] convertBytesToParcelBitmap()
767 {
768 bool[,] tempConvertMap = new bool[64, 64];
769 tempConvertMap.Initialize();
770 byte tempByte = 0;
771 int x = 0, y = 0, i = 0, bitNum = 0;
772 for (i = 0; i < 512; i++)
773 {
774 tempByte = parcelData.parcelBitmapByteArray[i];
775 for (bitNum = 0; bitNum < 8; bitNum++)
776 {
777 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte)1);
778 tempConvertMap[x, y] = bit;
779 x++;
780 if (x > 63)
781 {
782 x = 0;
783 y++;
784 }
785
786 }
787
788 }
789 return tempConvertMap;
790 }
791 /// <summary>
792 /// Full sim parcel creation
793 /// </summary>
794 /// <returns></returns>
795 public static bool[,] basicFullRegionParcelBitmap()
796 {
797 return getSquareParcelBitmap(0, 0, 256, 256);
798 }
799
800 /// <summary>
801 /// Used to modify the bitmap between the x and y points. Points use 64 scale
802 /// </summary>
803 /// <param name="start_x"></param>
804 /// <param name="start_y"></param>
805 /// <param name="end_x"></param>
806 /// <param name="end_y"></param>
807 /// <returns></returns>
808 public static bool[,] getSquareParcelBitmap(int start_x, int start_y, int end_x, int end_y)
809 {
810
811 bool[,] tempBitmap = new bool[64, 64];
812 tempBitmap.Initialize();
813
814 tempBitmap = modifyParcelBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true);
815 return tempBitmap;
816 }
817
818 /// <summary>
819 /// Change a parcel's bitmap at within a square and set those points to a specific value
820 /// </summary>
821 /// <param name="parcel_bitmap"></param>
822 /// <param name="start_x"></param>
823 /// <param name="start_y"></param>
824 /// <param name="end_x"></param>
825 /// <param name="end_y"></param>
826 /// <param name="set_value"></param>
827 /// <returns></returns>
828 public static bool[,] modifyParcelBitmapSquare(bool[,] parcel_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value)
829 {
830 if (parcel_bitmap.GetLength(0) != 64 || parcel_bitmap.GetLength(1) != 64 || parcel_bitmap.Rank != 2)
831 {
832 //Throw an exception - The bitmap is not 64x64
833 throw new Exception("Error: Invalid Parcel Bitmap in modifyParcelBitmapSquare()");
834 }
835
836 int x, y;
837 for (y = 0; y < 64; y++)
838 {
839 for (x = 0; x < 64; x++)
840 {
841 if (x >= start_x / 4 && x < end_x / 4
842 && y >= start_y / 4 && y < end_y / 4)
843 {
844 parcel_bitmap[x, y] = set_value;
845 }
846 }
847 }
848 return parcel_bitmap;
849 }
850 /// <summary>
851 /// Join the true values of 2 bitmaps together
852 /// </summary>
853 /// <param name="bitmap_base"></param>
854 /// <param name="bitmap_add"></param>
855 /// <returns></returns>
856 public static bool[,] mergeParcelBitmaps(bool[,] bitmap_base, bool[,] bitmap_add)
857 {
858 if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2)
859 {
860 //Throw an exception - The bitmap is not 64x64
861 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeParcelBitmaps");
862 }
863 if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2)
864 {
865 //Throw an exception - The bitmap is not 64x64
866 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeParcelBitmaps");
867
868 }
869
870 int x, y;
871 for (y = 0; y < 64; y++)
872 {
873 for (x = 0; x < 64; x++)
874 {
875 if (bitmap_add[x, y])
876 {
877 bitmap_base[x, y] = true;
878 }
879 }
880 }
881 return bitmap_base;
882 }
883 #endregion
884
885 #endregion
886
887
888 }
889 #endregion
890
891
892}
diff --git a/OpenSim/Region/Environment/RegionManager.cs b/OpenSim/Region/Environment/RegionManager.cs
new file mode 100644
index 0000000..4ff55a8
--- /dev/null
+++ b/OpenSim/Region/Environment/RegionManager.cs
@@ -0,0 +1,31 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Communications;
5using OpenSim.Framework;
6using OpenSim.Framework.Types;
7using OpenSim.Framework.Servers;
8using OpenSim.Region.Capabilities;
9
10namespace OpenSim.Region.Environment
11{
12 public class RegionManager //needs renaming , but first we need to rename the namespace
13 {
14 protected AuthenticateSessionsBase authenticateHandler;
15 protected RegionCommsListener regionCommsHost;
16 protected CommunicationsManager commsManager;
17 protected List<Caps> capsHandlers = new List<Caps>();
18 protected BaseHttpServer httpListener;
19
20 protected Scenes.Scene m_Scene;
21
22 public ParcelManager parcelManager;
23 public EstateManager estateManager;
24
25 public RegionManager()
26 {
27
28 }
29
30 }
31}
diff --git a/OpenSim/Region/Environment/Scenes/Entity.cs b/OpenSim/Region/Environment/Scenes/Entity.cs
new file mode 100644
index 0000000..db5070d
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Entity.cs
@@ -0,0 +1,193 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using Axiom.MathLib;
32using OpenSim.Physics.Manager;
33using libsecondlife;
34
35namespace OpenSim.Region.Environment.Scenes
36{
37 public abstract class Entity
38 {
39 public libsecondlife.LLUUID uuid;
40 public Quaternion rotation;
41 protected List<Entity> children;
42
43 protected PhysicsActor _physActor;
44 protected Scene m_world;
45 protected string m_name;
46
47 /// <summary>
48 ///
49 /// </summary>
50 public virtual string Name
51 {
52 get { return m_name; }
53 }
54
55 protected LLVector3 m_pos;
56 /// <summary>
57 ///
58 /// </summary>
59 public virtual LLVector3 Pos
60 {
61 get
62 {
63 if (this._physActor != null)
64 {
65 m_pos.X = _physActor.Position.X;
66 m_pos.Y = _physActor.Position.Y;
67 m_pos.Z = _physActor.Position.Z;
68 }
69
70 return m_pos;
71 }
72 set
73 {
74 if (this._physActor != null)
75 {
76 try
77 {
78 lock (this.m_world.SyncRoot)
79 {
80
81 this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
82 }
83 }
84 catch (Exception e)
85 {
86 Console.WriteLine(e.Message);
87 }
88 }
89
90 m_pos = value;
91 }
92 }
93
94 public LLVector3 velocity;
95
96 /// <summary>
97 ///
98 /// </summary>
99 public virtual LLVector3 Velocity
100 {
101 get
102 {
103 if (this._physActor != null)
104 {
105 velocity.X = _physActor.Velocity.X;
106 velocity.Y = _physActor.Velocity.Y;
107 velocity.Z = _physActor.Velocity.Z;
108 }
109
110 return velocity;
111 }
112 set
113 {
114 if (this._physActor != null)
115 {
116 try
117 {
118 lock (this.m_world.SyncRoot)
119 {
120
121 this._physActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z);
122 }
123 }
124 catch (Exception e)
125 {
126 Console.WriteLine(e.Message);
127 }
128 }
129
130 velocity = value;
131 }
132 }
133
134 protected uint m_localId;
135
136 public uint LocalId
137 {
138 get { return m_localId; }
139 }
140
141 /// <summary>
142 /// Creates a new Entity (should not occur on it's own)
143 /// </summary>
144 public Entity()
145 {
146 uuid = new libsecondlife.LLUUID();
147
148 m_pos = new LLVector3();
149 velocity = new LLVector3();
150 rotation = new Quaternion();
151 m_name = "(basic entity)";
152 children = new List<Entity>();
153 }
154
155 /// <summary>
156 ///
157 /// </summary>
158 public virtual void updateMovement()
159 {
160 foreach (Entity child in children)
161 {
162 child.updateMovement();
163 }
164 }
165
166 /// <summary>
167 /// Performs any updates that need to be done at each frame. This function is overridable from it's children.
168 /// </summary>
169 public virtual void update() {
170 // Do any per-frame updates needed that are applicable to every type of entity
171 foreach (Entity child in children)
172 {
173 child.update();
174 }
175 }
176
177 /// <summary>
178 /// Called at a set interval to inform entities that they should back themsleves up to the DB
179 /// </summary>
180 public virtual void BackUp()
181 {
182
183 }
184
185 /// <summary>
186 /// Infoms the entity that the land (heightmap) has changed
187 /// </summary>
188 public virtual void LandRenegerated()
189 {
190
191 }
192 }
193}
diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
new file mode 100644
index 0000000..36023d0
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
@@ -0,0 +1,19 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6using OpenSim.Physics.Manager;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Types;
9
10namespace OpenSim.Region.Environment.Scenes
11{
12 public interface IScenePresenceBody
13 {
14 void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation);
15 void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam);
16 void SendOurAppearance(IClientAPI OurClient);
17 void SendAppearanceToOtherAgent(ScenePresence avatarInfo);
18 }
19}
diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs
new file mode 100644
index 0000000..0f649b2
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Primitive.cs
@@ -0,0 +1,582 @@
1
2/*
3* Copyright (c) Contributors, http://www.openmetaverse.org/
4* See CONTRIBUTORS.TXT for a full list of copyright holders.
5*
6* Redistribution and use in source and binary forms, with or without
7* modification, are permitted provided that the following conditions are met:
8* * Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10* * Redistributions in binary form must reproduce the above copyright
11* notice, this list of conditions and the following disclaimer in the
12* documentation and/or other materials provided with the distribution.
13* * Neither the name of the OpenSim Project nor the
14* names of its contributors may be used to endorse or promote products
15* derived from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
18* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
21* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*
28*/
29using System;
30using System.Collections.Generic;
31using System.Text;
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Physics.Manager;
36using OpenSim.Framework.Types;
37using OpenSim.Framework.Inventory;
38
39namespace OpenSim.Region.Environment.Scenes
40{
41 public class Primitive : Entity
42 {
43 internal PrimData primData;
44 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
45 // private Dictionary<uint, IClientAPI> m_clientThreads;
46 private ulong m_regionHandle;
47 private const uint FULL_MASK_PERMISSIONS = 2147483647;
48 private bool physicsEnabled = false;
49 private byte updateFlag = 0;
50 private uint flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
51
52 private Dictionary<LLUUID, InventoryItem> inventoryItems;
53
54 #region Properties
55
56 public LLVector3 Scale
57 {
58 set
59 {
60 this.primData.Scale = value;
61 //this.dirtyFlag = true;
62 }
63 get
64 {
65 return this.primData.Scale;
66 }
67 }
68
69 public PhysicsActor PhysActor
70 {
71 set
72 {
73 this._physActor = value;
74 }
75 }
76
77 public override LLVector3 Pos
78 {
79 get
80 {
81 return base.Pos;
82 }
83 set
84 {
85 base.Pos = value;
86 }
87 }
88 #endregion
89
90 /// <summary>
91 ///
92 /// </summary>
93 /// <param name="clientThreads"></param>
94 /// <param name="regionHandle"></param>
95 /// <param name="world"></param>
96 public Primitive( ulong regionHandle, Scene world)
97 {
98 // m_clientThreads = clientThreads;
99 m_regionHandle = regionHandle;
100 m_world = world;
101 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
102 }
103
104 /// <summary>
105 ///
106 /// </summary>
107 /// <param name="regionHandle"></param>
108 /// <param name="world"></param>
109 /// <param name="addPacket"></param>
110 /// <param name="ownerID"></param>
111 /// <param name="localID"></param>
112 public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
113 {
114 // m_clientThreads = clientThreads;
115 m_regionHandle = regionHandle;
116 m_world = world;
117 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
118 this.CreateFromPacket(addPacket, ownerID, localID);
119 }
120
121 /// <summary>
122 ///
123 /// </summary>
124 /// <param name="clientThreads"></param>
125 /// <param name="regionHandle"></param>
126 /// <param name="world"></param>
127 /// <param name="owner"></param>
128 /// <param name="fullID"></param>
129 /// <param name="localID"></param>
130 public Primitive( ulong regionHandle, Scene world, LLUUID owner, LLUUID fullID, uint localID)
131 {
132 // m_clientThreads = clientThreads;
133 m_regionHandle = regionHandle;
134 m_world = world;
135 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
136 this.primData = new PrimData();
137 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
138 this.primData.OwnerID = owner;
139 this.primData.FullID = this.uuid = fullID;
140 this.primData.LocalID = m_localId = localID;
141 }
142
143 /// <summary>
144 /// Constructor to create a default cube
145 /// </summary>
146 /// <param name="clientThreads"></param>
147 /// <param name="regionHandle"></param>
148 /// <param name="world"></param>
149 /// <param name="owner"></param>
150 /// <param name="localID"></param>
151 /// <param name="position"></param>
152 public Primitive( ulong regionHandle, Scene world, LLUUID owner, uint localID, LLVector3 position)
153 {
154 //m_clientThreads = clientThreads;
155 m_regionHandle = regionHandle;
156 m_world = world;
157 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
158 this.primData = PrimData.DefaultCube();
159 this.primData.OwnerID = owner;
160 this.primData.LocalID = m_localId = localID;
161 this.Pos = this.primData.Position = position;
162
163 this.updateFlag = 1;
164 }
165
166 /// <summary>
167 ///
168 /// </summary>
169 /// <returns></returns>
170 public byte[] GetByteArray()
171 {
172 byte[] result = null;
173 List<byte[]> dataArrays = new List<byte[]>();
174 dataArrays.Add(primData.ToBytes());
175 foreach (Entity child in children)
176 {
177 if (child is OpenSim.Region.Environment.Scenes.Primitive)
178 {
179 dataArrays.Add(((OpenSim.Region.Environment.Scenes.Primitive)child).GetByteArray());
180 }
181 }
182 byte[] primstart = Helpers.StringToField("<Prim>");
183 byte[] primend = Helpers.StringToField("</Prim>");
184 int totalLength = primstart.Length + primend.Length;
185 for (int i = 0; i < dataArrays.Count; i++)
186 {
187 totalLength += dataArrays[i].Length;
188 }
189
190 result = new byte[totalLength];
191 int arraypos = 0;
192 Array.Copy(primstart, 0, result, 0, primstart.Length);
193 arraypos += primstart.Length;
194 for (int i = 0; i < dataArrays.Count; i++)
195 {
196 Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length);
197 arraypos += dataArrays[i].Length;
198 }
199 Array.Copy(primend, 0, result, arraypos, primend.Length);
200
201 return result;
202 }
203
204 #region Overridden Methods
205
206 /// <summary>
207 ///
208 /// </summary>
209 public override void update()
210 {
211 if (this.updateFlag == 1) // is a new prim just been created/reloaded
212 {
213 this.SendFullUpdateToAllClients();
214 this.updateFlag = 0;
215 }
216 if (this.updateFlag == 2) //some change has been made so update the clients
217 {
218 this.SendTerseUpdateToALLClients();
219 this.updateFlag = 0;
220 }
221 }
222
223 /// <summary>
224 ///
225 /// </summary>
226 public override void BackUp()
227 {
228
229 }
230
231 #endregion
232
233 #region Packet handlers
234
235 /// <summary>
236 ///
237 /// </summary>
238 /// <param name="pos"></param>
239 public void UpdatePosition(LLVector3 pos)
240 {
241 this.Pos = new LLVector3(pos.X, pos.Y, pos.Z);
242 this.updateFlag = 2;
243 }
244
245 /// <summary>
246 ///
247 /// </summary>
248 /// <param name="addPacket"></param>
249 public void UpdateShape(ObjectShapePacket.ObjectDataBlock updatePacket)
250 {
251 this.primData.PathBegin = updatePacket.PathBegin;
252 this.primData.PathEnd = updatePacket.PathEnd;
253 this.primData.PathScaleX = updatePacket.PathScaleX;
254 this.primData.PathScaleY = updatePacket.PathScaleY;
255 this.primData.PathShearX = updatePacket.PathShearX;
256 this.primData.PathShearY = updatePacket.PathShearY;
257 this.primData.PathSkew = updatePacket.PathSkew;
258 this.primData.ProfileBegin = updatePacket.ProfileBegin;
259 this.primData.ProfileEnd = updatePacket.ProfileEnd;
260 this.primData.PathCurve = updatePacket.PathCurve;
261 this.primData.ProfileCurve = updatePacket.ProfileCurve;
262 this.primData.ProfileHollow = updatePacket.ProfileHollow;
263 this.primData.PathRadiusOffset = updatePacket.PathRadiusOffset;
264 this.primData.PathRevolutions = updatePacket.PathRevolutions;
265 this.primData.PathTaperX = updatePacket.PathTaperX;
266 this.primData.PathTaperY = updatePacket.PathTaperY;
267 this.primData.PathTwist = updatePacket.PathTwist;
268 this.primData.PathTwistBegin = updatePacket.PathTwistBegin;
269 }
270
271 /// <summary>
272 ///
273 /// </summary>
274 /// <param name="tex"></param>
275 public void UpdateTexture(byte[] tex)
276 {
277 this.primData.TextureEntry = tex;
278 }
279
280 /// <summary>
281 ///
282 /// </summary>
283 /// <param name="pack"></param>
284 public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
285 {
286
287 }
288
289 /// <summary>
290 ///
291 /// </summary>
292 /// <param name="prim"></param>
293 public void AssignToParent(Primitive prim)
294 {
295
296 }
297
298 #endregion
299
300 # region Inventory Methods
301 /// <summary>
302 ///
303 /// </summary>
304 /// <param name="item"></param>
305 /// <returns></returns>
306 public bool AddToInventory(InventoryItem item)
307 {
308 return false;
309 }
310
311 /// <summary>
312 ///
313 /// </summary>
314 /// <param name="itemID"></param>
315 /// <returns></returns>
316 public InventoryItem RemoveFromInventory(LLUUID itemID)
317 {
318 return null;
319 }
320
321 /// <summary>
322 ///
323 /// </summary>
324 /// <param name="simClient"></param>
325 /// <param name="packet"></param>
326 public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet)
327 {
328
329 }
330
331 /// <summary>
332 ///
333 /// </summary>
334 /// <param name="simClient"></param>
335 /// <param name="xferID"></param>
336 public void RequestXferInventory(IClientAPI simClient, ulong xferID)
337 {
338 //will only currently work if the total size of the inventory data array is under about 1000 bytes
339 SendXferPacketPacket send = new SendXferPacketPacket();
340
341 send.XferID.ID = xferID;
342 send.XferID.Packet = 1 + 2147483648;
343 send.DataPacket.Data = this.ConvertInventoryToBytes();
344
345 simClient.OutPacket(send);
346 }
347
348 /// <summary>
349 ///
350 /// </summary>
351 /// <returns></returns>
352 public byte[] ConvertInventoryToBytes()
353 {
354 System.Text.Encoding enc = System.Text.Encoding.ASCII;
355 byte[] result = new byte[0];
356 List<byte[]> inventoryData = new List<byte[]>();
357 int totallength = 0;
358 foreach (InventoryItem invItem in inventoryItems.Values)
359 {
360 byte[] data = enc.GetBytes(invItem.ExportString());
361 inventoryData.Add(data);
362 totallength += data.Length;
363 }
364 //TODO: copy arrays into the single result array
365
366 return result;
367 }
368
369 /// <summary>
370 ///
371 /// </summary>
372 /// <param name="data"></param>
373 public void CreateInventoryFromBytes(byte[] data)
374 {
375
376 }
377
378 #endregion
379
380 #region Update viewers Methods
381
382 /// <summary>
383 ///
384 /// </summary>
385 /// <param name="remoteClient"></param>
386 public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
387 {
388 this.SendFullUpdateToClient(remoteClient);
389 for (int i = 0; i < this.children.Count; i++)
390 {
391 if (this.children[i] is Primitive)
392 {
393 ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
394 }
395 }
396 }
397
398 /// <summary>
399 ///
400 /// </summary>
401 /// <param name="remoteClient"></param>
402 public void SendFullUpdateToClient(IClientAPI remoteClient)
403 {
404 LLVector3 lPos;
405 if (this._physActor != null && this.physicsEnabled)
406 {
407 PhysicsVector pPos = this._physActor.Position;
408 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
409 }
410 else
411 {
412 lPos = this.Pos;
413 }
414
415 remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.primData, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags);
416 }
417
418 /// <summary>
419 ///
420 /// </summary>
421 public void SendFullUpdateToAllClients()
422 {
423 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
424 for (int i = 0; i < avatars.Count; i++)
425 {
426 this.SendFullUpdateToClient(avatars[i].ControllingClient);
427 }
428 }
429
430 /// <summary>
431 ///
432 /// </summary>
433 /// <param name="RemoteClient"></param>
434 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
435 {
436 LLVector3 lPos;
437 Axiom.MathLib.Quaternion lRot;
438 if (this._physActor != null && this.physicsEnabled) //is this needed ? doesn't the property fields do this for us?
439 {
440 PhysicsVector pPos = this._physActor.Position;
441 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
442 lRot = this._physActor.Orientation;
443 }
444 else
445 {
446 lPos = this.Pos;
447 lRot = this.rotation;
448 }
449 LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w);
450 RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot);
451 }
452
453 /// <summary>
454 ///
455 /// </summary>
456 public void SendTerseUpdateToALLClients()
457 {
458 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
459 for (int i = 0; i < avatars.Count; i++)
460 {
461 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
462 }
463 }
464
465 #endregion
466
467 #region Create Methods
468
469 /// <summary>
470 ///
471 /// </summary>
472 /// <param name="addPacket"></param>
473 /// <param name="ownerID"></param>
474 /// <param name="localID"></param>
475 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
476 {
477 PrimData PData = new PrimData();
478 this.primData = PData;
479 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
480
481 PData.OwnerID = ownerID;
482 PData.PCode = addPacket.ObjectData.PCode;
483 PData.PathBegin = addPacket.ObjectData.PathBegin;
484 PData.PathEnd = addPacket.ObjectData.PathEnd;
485 PData.PathScaleX = addPacket.ObjectData.PathScaleX;
486 PData.PathScaleY = addPacket.ObjectData.PathScaleY;
487 PData.PathShearX = addPacket.ObjectData.PathShearX;
488 PData.PathShearY = addPacket.ObjectData.PathShearY;
489 PData.PathSkew = addPacket.ObjectData.PathSkew;
490 PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
491 PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
492 PData.Scale = addPacket.ObjectData.Scale;
493 PData.PathCurve = addPacket.ObjectData.PathCurve;
494 PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
495 PData.ParentID = 0;
496 PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
497 PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
498 PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
499 PData.PathTaperX = addPacket.ObjectData.PathTaperX;
500 PData.PathTaperY = addPacket.ObjectData.PathTaperY;
501 PData.PathTwist = addPacket.ObjectData.PathTwist;
502 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
503 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
504 this.primData.FullID = this.uuid = LLUUID.Random();
505 this.primData.LocalID = m_localId = (uint)(localID);
506 this.primData.Position = this.Pos = pos1;
507
508 this.updateFlag = 1;
509 }
510
511 /// <summary>
512 ///
513 /// </summary>
514 /// <param name="data"></param>
515 public void CreateFromBytes(byte[] data)
516 {
517
518 }
519
520 /// <summary>
521 ///
522 /// </summary>
523 /// <param name="primData"></param>
524 public void CreateFromPrimData(PrimData primData)
525 {
526 this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false);
527 }
528
529 /// <summary>
530 ///
531 /// </summary>
532 /// <param name="primData"></param>
533 /// <param name="posi"></param>
534 /// <param name="localID"></param>
535 /// <param name="newprim"></param>
536 public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim)
537 {
538
539 }
540
541 public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
542 {
543 // Console.WriteLine("moving prim to new location " + pos.X + " , " + pos.Y + " , " + pos.Z);
544 this.Pos = pos;
545 this.SendTerseUpdateToALLClients();
546 }
547
548 public void GetProperites(IClientAPI client)
549 {
550 //needs changing
551 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
552 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
553 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
554 proper.ObjectData[0].ItemID = LLUUID.Zero;
555 proper.ObjectData[0].CreationDate = (ulong)primData.CreationDate;
556 proper.ObjectData[0].CreatorID = primData.OwnerID;
557 proper.ObjectData[0].FolderID = LLUUID.Zero;
558 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
559 proper.ObjectData[0].GroupID = LLUUID.Zero;
560 proper.ObjectData[0].InventorySerial = 0;
561 proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
562 proper.ObjectData[0].ObjectID = this.uuid;
563 proper.ObjectData[0].OwnerID = primData.OwnerID;
564 proper.ObjectData[0].TouchName = new byte[0];
565 proper.ObjectData[0].TextureID = new byte[0];
566 proper.ObjectData[0].SitName = new byte[0];
567 proper.ObjectData[0].Name = new byte[0];
568 proper.ObjectData[0].Description = new byte[0];
569 proper.ObjectData[0].OwnerMask = primData.OwnerMask;
570 proper.ObjectData[0].NextOwnerMask = primData.NextOwnerMask;
571 proper.ObjectData[0].GroupMask = primData.GroupMask;
572 proper.ObjectData[0].EveryoneMask = primData.EveryoneMask;
573 proper.ObjectData[0].BaseMask = primData.BaseMask;
574
575 client.OutPacket(proper);
576
577 }
578
579 #endregion
580
581 }
582}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
new file mode 100644
index 0000000..1d55c4d
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -0,0 +1,305 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32using libsecondlife.Packets;
33using OpenSim.Physics.Manager;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Inventory;
37using OpenSim.Framework.Utilities;
38
39namespace OpenSim.Region.Environment.Scenes
40{
41 public partial class Scene
42 {
43 /// <summary>
44 /// Modifies terrain using the specified information
45 /// </summary>
46 /// <param name="height">The height at which the user started modifying the terrain</param>
47 /// <param name="seconds">The number of seconds the modify button was pressed</param>
48 /// <param name="brushsize">The size of the brush used</param>
49 /// <param name="action">The action to be performed</param>
50 /// <param name="north">Distance from the north border where the cursor is located</param>
51 /// <param name="west">Distance from the west border where the cursor is located</param>
52 public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west)
53 {
54 // Shiny.
55 double size = (double)(1 << brushsize);
56
57 switch (action)
58 {
59 case 0:
60 // flatten terrain
61 Terrain.flatten(north, west, size, (double)seconds / 100.0);
62 RegenerateTerrain(true, (int)north, (int)west);
63 break;
64 case 1:
65 // raise terrain
66 Terrain.raise(north, west, size, (double)seconds / 100.0);
67 RegenerateTerrain(true, (int)north, (int)west);
68 break;
69 case 2:
70 //lower terrain
71 Terrain.lower(north, west, size, (double)seconds / 100.0);
72 RegenerateTerrain(true, (int)north, (int)west);
73 break;
74 case 3:
75 // smooth terrain
76 Terrain.smooth(north, west, size, (double)seconds / 100.0);
77 RegenerateTerrain(true, (int)north, (int)west);
78 break;
79 case 4:
80 // noise
81 Terrain.noise(north, west, size, (double)seconds / 100.0);
82 RegenerateTerrain(true, (int)north, (int)west);
83 break;
84 case 5:
85 // revert
86 Terrain.revert(north, west, size, (double)seconds / 100.0);
87 RegenerateTerrain(true, (int)north, (int)west);
88 break;
89
90 // CLIENT EXTENSIONS GO HERE
91 case 128:
92 // erode-thermal
93 break;
94 case 129:
95 // erode-aerobic
96 break;
97 case 130:
98 // erode-hydraulic
99 break;
100 }
101 return;
102 }
103
104 /// <summary>
105 ///
106 /// </summary>
107 /// <param name="message"></param>
108 /// <param name="type"></param>
109 /// <param name="fromPos"></param>
110 /// <param name="fromName"></param>
111 /// <param name="fromAgentID"></param>
112 public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
113 {
114 Console.WriteLine("Chat message");
115 ScenePresence avatar = null;
116 foreach (IClientAPI client in m_clientThreads.Values)
117 {
118 int dis = -1000;
119 if (this.Avatars.ContainsKey(client.AgentId))
120 {
121
122 avatar = this.Avatars[client.AgentId];
123 // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
124 dis= (int)avatar.Pos.GetDistanceTo(fromPos);
125 Console.WriteLine("found avatar at " +dis);
126
127 }
128
129 switch (type)
130 {
131 case 0: // Whisper
132 if ((dis < 10) && (dis > -10))
133 {
134 //should change so the message is sent through the avatar rather than direct to the ClientView
135 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
136 }
137 break;
138 case 1: // Say
139 if ((dis < 30) && (dis > -30))
140 {
141 Console.WriteLine("sending chat");
142 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
143 }
144 break;
145 case 2: // Shout
146 if ((dis < 100) && (dis > -100))
147 {
148 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
149 }
150 break;
151
152 case 0xff: // Broadcast
153 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
154 break;
155 }
156
157 }
158 }
159
160 /// <summary>
161 ///
162 /// </summary>
163 /// <param name="primAsset"></param>
164 /// <param name="pos"></param>
165 public void RezObject(AssetBase primAsset, LLVector3 pos)
166 {
167
168 }
169
170 /// <summary>
171 ///
172 /// </summary>
173 /// <param name="packet"></param>
174 /// <param name="simClient"></param>
175 public void DeRezObject(Packet packet, IClientAPI simClient)
176 {
177
178 }
179
180 /// <summary>
181 ///
182 /// </summary>
183 /// <param name="remoteClient"></param>
184 public void SendAvatarsToClient(IClientAPI remoteClient)
185 {
186
187 }
188
189 /// <summary>
190 ///
191 /// </summary>
192 /// <param name="parentPrim"></param>
193 /// <param name="childPrims"></param>
194 public void LinkObjects(uint parentPrim, List<uint> childPrims)
195 {
196
197
198 }
199
200 /// <summary>
201 ///
202 /// </summary>
203 /// <param name="primLocalID"></param>
204 /// <param name="shapeBlock"></param>
205 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock)
206 {
207
208 }
209
210 /// <summary>
211 ///
212 /// </summary>
213 /// <param name="primLocalID"></param>
214 /// <param name="remoteClient"></param>
215 public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
216 {
217 foreach (Entity ent in Entities.Values)
218 {
219 if (ent.LocalId == primLocalID)
220 {
221 ((OpenSim.Region.Environment.Scenes.Primitive)ent).GetProperites(remoteClient);
222 break;
223 }
224 }
225 }
226
227 public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
228 {
229 if (this.Entities.ContainsKey(objectID))
230 {
231 ((Primitive)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient);
232 }
233 }
234
235 /// <summary>
236 ///
237 /// </summary>
238 /// <param name="localID"></param>
239 /// <param name="packet"></param>
240 /// <param name="remoteClient"></param>
241 public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient)
242 {
243
244 }
245
246 /// <summary>
247 ///
248 /// </summary>
249 /// <param name="localID"></param>
250 /// <param name="texture"></param>
251 /// <param name="remoteClient"></param>
252 public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient)
253 {
254
255 }
256
257 /// <summary>
258 ///
259 /// </summary>
260 /// <param name="localID"></param>
261 /// <param name="pos"></param>
262 /// <param name="remoteClient"></param>
263 public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
264 {
265 foreach (Entity ent in Entities.Values)
266 {
267 if (ent.LocalId == localID)
268 {
269 ((OpenSim.Region.Environment.Scenes.Primitive)ent).UpdatePosition(pos);
270 break;
271 }
272 }
273 }
274
275 /// <summary>
276 ///
277 /// </summary>
278 /// <param name="localID"></param>
279 /// <param name="rot"></param>
280 /// <param name="remoteClient"></param>
281 public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
282 {
283
284 }
285
286 /// <summary>
287 ///
288 /// </summary>
289 /// <param name="localID"></param>
290 /// <param name="scale"></param>
291 /// <param name="remoteClient"></param>
292 public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient)
293 {
294 }
295
296 /// <summary>
297 /// Sends prims to a client
298 /// </summary>
299 /// <param name="RemoteClient">Client to send to</param>
300 public void GetInitialPrims(IClientAPI RemoteClient)
301 {
302
303 }
304 }
305}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
new file mode 100644
index 0000000..8c912d0
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -0,0 +1,784 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using libsecondlife;
30using libsecondlife.Packets;
31using System.Collections.Generic;
32using System.Text;
33using System.Reflection;
34using System.IO;
35using System.Threading;
36using System.Timers;
37using OpenSim.Physics.Manager;
38using OpenSim.Framework.Interfaces;
39using OpenSim.Framework.Types;
40using OpenSim.Framework.Inventory;
41using OpenSim.Framework;
42using OpenSim.Region.Terrain;
43using OpenSim.Framework.Communications;
44using OpenSim.Region.Caches;
45using OpenSim.Region.Environment;
46using OpenSim.Framework.Servers;
47using OpenSim.Region.Enviorment.Scripting;
48using OpenSim.Region.Capabilities;
49using Caps = OpenSim.Region.Capabilities.Caps;
50
51namespace OpenSim.Region.Environment.Scenes
52{
53 public delegate bool FilterAvatarList(ScenePresence avatar);
54
55 public partial class Scene : SceneBase, ILocalStorageReceiver
56 {
57 protected System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer();
58 protected Dictionary<libsecondlife.LLUUID, ScenePresence> Avatars;
59 protected Dictionary<libsecondlife.LLUUID, Primitive> Prims;
60 private PhysicsScene phyScene;
61 private float timeStep = 0.1f;
62 private Random Rand = new Random();
63 private uint _primCount = 702000;
64 private int storageCount;
65 private Mutex updateLock;
66
67 protected AuthenticateSessionsBase authenticateHandler;
68 protected RegionCommsListener regionCommsHost;
69 protected CommunicationsManager commsManager;
70
71 protected Dictionary<LLUUID,Caps> capsHandlers = new Dictionary<LLUUID, Caps>();
72 protected BaseHttpServer httpListener;
73
74 public ParcelManager parcelManager;
75 public EstateManager estateManager;
76 public EventManager eventManager;
77 public ScriptManager scriptManager;
78
79 #region Properties
80 /// <summary>
81 ///
82 /// </summary>
83 public PhysicsScene PhysScene
84 {
85 set
86 {
87 this.phyScene = value;
88 }
89 get
90 {
91 return (this.phyScene);
92 }
93 }
94
95 #endregion
96
97 #region Constructors
98 /// <summary>
99 /// Creates a new World class, and a region to go with it.
100 /// </summary>
101 /// <param name="clientThreads">Dictionary to contain client threads</param>
102 /// <param name="regionHandle">Region Handle for this region</param>
103 /// <param name="regionName">Region Name for this region</param>
104 public Scene(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
105 {
106 try
107 {
108 updateLock = new Mutex(false);
109 this.authenticateHandler = authen;
110 this.commsManager = commsMan;
111 this.assetCache = assetCach;
112 m_clientThreads = clientThreads;
113 m_regInfo = regInfo;
114 m_regionHandle = m_regInfo.RegionHandle;
115 m_regionName = m_regInfo.RegionName;
116 this.m_datastore = m_regInfo.DataStore;
117 this.RegisterRegionWithComms();
118
119 parcelManager = new ParcelManager(this, this.m_regInfo);
120 estateManager = new EstateManager(this, this.m_regInfo);
121 scriptManager = new ScriptManager(this);
122 eventManager = new EventManager();
123
124 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs - creating new entitities instance");
125 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
126 Avatars = new Dictionary<LLUUID, ScenePresence>();
127 Prims = new Dictionary<LLUUID, Primitive>();
128
129 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs - creating LandMap");
130 Terrain = new TerrainEngine();
131
132 ScenePresence.LoadAnims();
133 this.httpListener = httpServer;
134
135 }
136 catch (Exception e)
137 {
138 OpenSim.Framework.Console.MainLog.Instance.Error( "World.cs: Constructor failed with exception " + e.ToString());
139 }
140 }
141 #endregion
142
143 /// <summary>
144 ///
145 /// </summary>
146 public void StartTimer()
147 {
148 m_heartbeatTimer.Enabled = true;
149 m_heartbeatTimer.Interval = 100;
150 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
151 }
152
153
154 #region Update Methods
155
156
157 /// <summary>
158 /// Performs per-frame updates regularly
159 /// </summary>
160 /// <param name="sender"></param>
161 /// <param name="e"></param>
162 void Heartbeat(object sender, System.EventArgs e)
163 {
164 this.Update();
165 }
166
167 /// <summary>
168 /// Performs per-frame updates on the world, this should be the central world loop
169 /// </summary>
170 public override void Update()
171 {
172 updateLock.WaitOne();
173 try
174 {
175 if (this.phyScene.IsThreaded)
176 {
177 this.phyScene.GetResults();
178
179 }
180
181 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
182 {
183 Entities[UUID].updateMovement();
184 }
185
186 lock (this.m_syncRoot)
187 {
188 this.phyScene.Simulate(timeStep);
189 }
190
191 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
192 {
193 Entities[UUID].update();
194 }
195
196 // General purpose event manager
197 eventManager.TriggerOnFrame();
198
199 //backup world data
200 this.storageCount++;
201 if (storageCount > 1200) //set to how often you want to backup
202 {
203 this.Backup();
204 storageCount = 0;
205 }
206 }
207 catch (Exception e)
208 {
209 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString());
210 }
211 updateLock.ReleaseMutex();
212
213 }
214
215 /// <summary>
216 ///
217 /// </summary>
218 /// <returns></returns>
219 public bool Backup()
220 {
221 /*
222 try
223 {
224 // Terrain backup routines
225 if (Terrain.tainted > 0)
226 {
227 Terrain.tainted = 0;
228 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Terrain tainted, saving.");
229 localStorage.SaveMap(Terrain.getHeights1D());
230 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Terrain saved, informing Physics.");
231 lock (this.m_syncRoot)
232 {
233 phyScene.SetTerrain(Terrain.getHeights1D());
234 }
235 }
236
237 // Primitive backup routines
238 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Backing up Primitives");
239 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
240 {
241 Entities[UUID].BackUp();
242 }
243
244 //Parcel backup routines
245 ParcelData[] parcels = new ParcelData[parcelManager.parcelList.Count];
246 int i = 0;
247 foreach (OpenSim.Region.Parcel parcel in parcelManager.parcelList.Values)
248 {
249 parcels[i] = parcel.parcelData;
250 i++;
251 }
252 localStorage.SaveParcels(parcels);
253
254 // Backup successful
255 return true;
256 }
257 catch (Exception e)
258 {
259 // Backup failed
260 OpenSim.Framework.Console.MainLog.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Backup() - Backup Failed with exception " + e.ToString());
261 return false;
262 }
263 */
264 return true;
265 }
266 #endregion
267
268 #region Regenerate Terrain
269
270 /// <summary>
271 /// Rebuilds the terrain using a procedural algorithm
272 /// </summary>
273 public void RegenerateTerrain()
274 {
275 try
276 {
277 Terrain.hills();
278
279 lock (this.m_syncRoot)
280 {
281 this.phyScene.SetTerrain(Terrain.getHeights1D());
282 }
283 this.localStorage.SaveMap(this.Terrain.getHeights1D());
284
285 foreach (IClientAPI client in m_clientThreads.Values)
286 {
287 this.SendLayerData(client);
288 }
289
290 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
291 {
292 Entities[UUID].LandRenegerated();
293 }
294 }
295 catch (Exception e)
296 {
297 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
298 }
299 }
300
301 /// <summary>
302 /// Rebuilds the terrain using a 2D float array
303 /// </summary>
304 /// <param name="newMap">256,256 float array containing heights</param>
305 public void RegenerateTerrain(float[,] newMap)
306 {
307 try
308 {
309 this.Terrain.setHeights2D(newMap);
310 lock (this.m_syncRoot)
311 {
312 this.phyScene.SetTerrain(this.Terrain.getHeights1D());
313 }
314 this.localStorage.SaveMap(this.Terrain.getHeights1D());
315
316 foreach (IClientAPI client in m_clientThreads.Values)
317 {
318 this.SendLayerData(client);
319 }
320
321 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
322 {
323 Entities[UUID].LandRenegerated();
324 }
325 }
326 catch (Exception e)
327 {
328 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
329 }
330 }
331
332 /// <summary>
333 /// Rebuilds the terrain assuming changes occured at a specified point[?]
334 /// </summary>
335 /// <param name="changes">???</param>
336 /// <param name="pointx">???</param>
337 /// <param name="pointy">???</param>
338 public void RegenerateTerrain(bool changes, int pointx, int pointy)
339 {
340 try
341 {
342 if (changes)
343 {
344 /* Dont save here, rely on tainting system instead */
345
346 foreach (IClientAPI client in m_clientThreads.Values)
347 {
348 this.SendLayerData(pointx, pointy, client);
349 }
350 }
351 }
352 catch (Exception e)
353 {
354 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
355 }
356 }
357
358 #endregion
359
360 #region Load Terrain
361 /// <summary>
362 /// Loads the World heightmap
363 /// </summary>
364 ///
365 public override void LoadWorldMap()
366 {
367 try
368 {
369 float[] map = this.localStorage.LoadWorld();
370 if (map == null)
371 {
372 if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile))
373 {
374 Console.WriteLine("No default terrain, procedurally generating...");
375 this.Terrain.hills();
376
377 this.localStorage.SaveMap(this.Terrain.getHeights1D());
378 }
379 else
380 {
381 try
382 {
383 this.Terrain.loadFromFileF32(this.m_regInfo.estateSettings.terrainFile);
384 this.Terrain *= this.m_regInfo.estateSettings.terrainMultiplier;
385 }
386 catch
387 {
388 Console.WriteLine("Unable to load default terrain, procedurally generating instead...");
389 Terrain.hills();
390 }
391 this.localStorage.SaveMap(this.Terrain.getHeights1D());
392 }
393 }
394 else
395 {
396 this.Terrain.setHeights1D(map);
397 }
398
399 CreateTerrainTexture();
400
401 }
402 catch (Exception e)
403 {
404 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: LoadWorldMap() - Failed with exception " + e.ToString());
405 }
406 }
407
408 /// <summary>
409 ///
410 /// </summary>
411 private void CreateTerrainTexture()
412 {
413 //create a texture asset of the terrain
414 byte[] data = this.Terrain.exportJpegImage("defaultstripe.png");
415 this.m_regInfo.estateSettings.terrainImageID = LLUUID.Random();
416 AssetBase asset = new AssetBase();
417 asset.FullID = this.m_regInfo.estateSettings.terrainImageID;
418 asset.Data = data;
419 asset.Name = "terrainImage";
420 asset.Type = 0;
421 this.assetCache.AddAsset(asset);
422 }
423 #endregion
424
425 #region Primitives Methods
426
427
428 /// <summary>
429 /// Loads the World's objects
430 /// </summary>
431 public void LoadPrimsFromStorage()
432 {
433 try
434 {
435 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: LoadPrimsFromStorage() - Loading primitives");
436 this.localStorage.LoadPrimitives(this);
437 }
438 catch (Exception e)
439 {
440 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString());
441 }
442 }
443
444 /// <summary>
445 /// Loads a specific object from storage
446 /// </summary>
447 /// <param name="prim">The object to load</param>
448 public void PrimFromStorage(PrimData prim)
449 {
450
451 }
452
453 /// <summary>
454 ///
455 /// </summary>
456 /// <param name="addPacket"></param>
457 /// <param name="agentClient"></param>
458 public void AddNewPrim(Packet addPacket, IClientAPI agentClient)
459 {
460 AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentId);
461 }
462
463 /// <summary>
464 ///
465 /// </summary>
466 /// <param name="addPacket"></param>
467 /// <param name="ownerID"></param>
468 public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID)
469 {
470 try
471 {
472 Primitive prim = new Primitive(m_regionHandle, this, addPacket, ownerID, this._primCount);
473
474 this.Entities.Add(prim.uuid, prim);
475 this._primCount++;
476
477 // Trigger event for listeners
478 eventManager.TriggerOnNewPrimitive(prim);
479 }
480 catch (Exception e)
481 {
482 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: AddNewPrim() - Failed with exception " + e.ToString());
483 }
484 }
485
486 #endregion
487
488 #region Add/Remove Avatar Methods
489
490 /// <summary>
491 ///
492 /// </summary>
493 /// <param name="remoteClient"></param
494 /// <param name="agentID"></param>
495 /// <param name="child"></param>
496 public override void AddNewClient(IClientAPI remoteClient, LLUUID agentID, bool child)
497 {
498 remoteClient.OnRegionHandShakeReply += this.SendLayerData;
499 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims);
500 remoteClient.OnChatFromViewer += this.SimChat;
501 remoteClient.OnRequestWearables += this.InformClientOfNeighbours;
502 remoteClient.OnAddPrim += this.AddNewPrim;
503 remoteClient.OnUpdatePrimPosition += this.UpdatePrimPosition;
504 remoteClient.OnRequestMapBlocks += this.RequestMapBlocks;
505 remoteClient.OnTeleportLocationRequest += this.RequestTeleportLocation;
506 //remoteClient.OnObjectSelect += this.SelectPrim;
507 remoteClient.OnGrapUpdate += this.MoveObject;
508 remoteClient.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest;
509
510 /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest);
511 remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest);
512 remoteClient.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest);
513 remoteClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest);
514 remoteClient.OnEstateOwnerMessage += new EstateOwnerMessageRequest(estateManager.handleEstateOwnerMessage);
515 */
516
517 ScenePresence newAvatar = null;
518 try
519 {
520
521 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
522 newAvatar = new ScenePresence(remoteClient, this, this.m_regInfo);
523 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Adding new avatar to world");
524 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Starting RegionHandshake ");
525
526 //newAvatar.SendRegionHandshake();
527 this.estateManager.sendRegionHandshake(remoteClient);
528
529 PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z);
530 lock (this.m_syncRoot)
531 {
532 newAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
533 }
534
535 lock (Entities)
536 {
537 if (!Entities.ContainsKey(agentID))
538 {
539 this.Entities.Add(agentID, newAvatar);
540 }
541 else
542 {
543 Entities[agentID] = newAvatar;
544 }
545 }
546 lock (Avatars)
547 {
548 if (Avatars.ContainsKey(agentID))
549 {
550 Avatars[agentID] = newAvatar;
551 }
552 else
553 {
554 this.Avatars.Add(agentID, newAvatar);
555 }
556 }
557 }
558 catch (Exception e)
559 {
560 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: AddViewerAgent() - Failed with exception " + e.ToString());
561 }
562 return;
563 }
564
565
566
567 /// <summary>
568 ///
569 /// </summary>
570 /// <param name="agentID"></param>
571 public override void RemoveClient(LLUUID agentID)
572 {
573 eventManager.TriggerOnRemovePresence(agentID);
574
575 return;
576 }
577 #endregion
578
579 #region Request Avatars List Methods
580 //The idea is to have a group of method that return a list of avatars meeting some requirement
581 // ie it could be all Avatars within a certain range of the calling prim/avatar.
582
583 /// <summary>
584 /// Request a List of all Avatars in this World
585 /// </summary>
586 /// <returns></returns>
587 public List<ScenePresence> RequestAvatarList()
588 {
589 List<ScenePresence> result = new List<ScenePresence>();
590
591 foreach (ScenePresence avatar in Avatars.Values)
592 {
593 result.Add(avatar);
594 }
595
596 return result;
597 }
598
599 /// <summary>
600 /// Request a filtered list of Avatars in this World
601 /// </summary>
602 /// <returns></returns>
603 public List<ScenePresence> RequestAvatarList(FilterAvatarList filter)
604 {
605 List<ScenePresence> result = new List<ScenePresence>();
606
607 foreach (ScenePresence avatar in Avatars.Values)
608 {
609 if (filter(avatar))
610 {
611 result.Add(avatar);
612 }
613 }
614
615 return result;
616 }
617
618 /// <summary>
619 /// Request a Avatar by UUID
620 /// </summary>
621 /// <param name="avatarID"></param>
622 /// <returns></returns>
623 public ScenePresence RequestAvatar(LLUUID avatarID)
624 {
625 if (this.Avatars.ContainsKey(avatarID))
626 {
627 return Avatars[avatarID];
628 }
629 return null;
630 }
631 #endregion
632
633
634 #region RegionCommsHost
635
636 /// <summary>
637 ///
638 /// </summary>
639 public void RegisterRegionWithComms()
640 {
641 GridInfo gridSettings = new GridInfo();
642 this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo,gridSettings);
643 if (this.regionCommsHost != null)
644 {
645 this.regionCommsHost.OnExpectUser += new ExpectUserDelegate(this.NewUserConnection);
646 this.regionCommsHost.OnAvatarCrossingIntoRegion += new AgentCrossing(this.AgentCrossing);
647 }
648 }
649
650 /// <summary>
651 ///
652 /// </summary>
653 /// <param name="regionHandle"></param>
654 /// <param name="agent"></param>
655 public void NewUserConnection(ulong regionHandle, AgentCircuitData agent)
656 {
657 // Console.WriteLine("World.cs - add new user connection");
658 //should just check that its meant for this region
659 if (regionHandle == this.m_regInfo.RegionHandle)
660 {
661 if (agent.CapsPath != "")
662 {
663 //Console.WriteLine("new user, so creating caps handler for it");
664 Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.CommsIPListenAddr, 9000, agent.CapsPath, agent.AgentID);
665 cap.RegisterHandlers();
666 this.capsHandlers.Add(agent.AgentID, cap);
667 }
668 this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
669 }
670 }
671
672 public void AgentCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position)
673 {
674 if (regionHandle == this.m_regInfo.RegionHandle)
675 {
676 if (this.Avatars.ContainsKey(agentID))
677 {
678 this.Avatars[agentID].MakeAvatar(position);
679 }
680 }
681 }
682
683 /// <summary>
684 ///
685 /// </summary>
686 public void InformClientOfNeighbours(IClientAPI remoteClient)
687 {
688 // Console.WriteLine("informing client of neighbouring regions");
689 List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo);
690
691 //Console.WriteLine("we have " + neighbours.Count + " neighbouring regions");
692 if (neighbours != null)
693 {
694 for (int i = 0; i < neighbours.Count; i++)
695 {
696 // Console.WriteLine("sending neighbours data");
697 AgentCircuitData agent = remoteClient.RequestClientInfo();
698 agent.BaseFolder = LLUUID.Zero;
699 agent.InventoryFolder = LLUUID.Zero;
700 agent.startpos = new LLVector3(128, 128, 70);
701 agent.child = true;
702 this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent);
703 remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr), (ushort)neighbours[i].CommsIPListenPort);
704 //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort);
705 }
706 }
707 }
708
709 /// <summary>
710 ///
711 /// </summary>
712 /// <param name="regionHandle"></param>
713 /// <returns></returns>
714 public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
715 {
716 return this.commsManager.GridServer.RequestNeighbourInfo(regionHandle);
717 }
718
719 /// <summary>
720 ///
721 /// </summary>
722 /// <param name="minX"></param>
723 /// <param name="minY"></param>
724 /// <param name="maxX"></param>
725 /// <param name="maxY"></param>
726 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
727 {
728 List<MapBlockData> mapBlocks;
729 mapBlocks = this.commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
730 remoteClient.SendMapBlock(mapBlocks);
731 }
732
733 /// <summary>
734 ///
735 /// </summary>
736 /// <param name="remoteClient"></param>
737 /// <param name="RegionHandle"></param>
738 /// <param name="position"></param>
739 /// <param name="lookAt"></param>
740 /// <param name="flags"></param>
741 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags)
742 {
743 if (regionHandle == this.m_regionHandle)
744 {
745 if (this.Avatars.ContainsKey(remoteClient.AgentId))
746 {
747 remoteClient.SendTeleportLocationStart();
748 remoteClient.SendLocalTeleport(position, lookAt, flags);
749 this.Avatars[remoteClient.AgentId].Teleport(position);
750 }
751 }
752 else
753 {
754 RegionInfo reg = this.RequestNeighbouringRegionInfo(regionHandle);
755 if (reg != null)
756 {
757 remoteClient.SendTeleportLocationStart();
758 AgentCircuitData agent = remoteClient.RequestClientInfo();
759 agent.BaseFolder = LLUUID.Zero;
760 agent.InventoryFolder = LLUUID.Zero;
761 agent.startpos = new LLVector3(128, 128, 70);
762 agent.child = true;
763 this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
764 this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position);
765 remoteClient.SendRegionTeleport(regionHandle, 13, reg.CommsIPListenAddr, (ushort)reg.CommsIPListenPort, 4, (1 << 4));
766 }
767 //remoteClient.SendTeleportCancel();
768 }
769 }
770
771 /// <summary>
772 ///
773 /// </summary>
774 /// <param name="regionhandle"></param>
775 /// <param name="agentID"></param>
776 /// <param name="position"></param>
777 public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position)
778 {
779 return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position);
780 }
781
782 #endregion
783 }
784}
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
new file mode 100644
index 0000000..50d3b82
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -0,0 +1,200 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using libsecondlife;
30using libsecondlife.Packets;
31using System.Collections.Generic;
32using System.Text;
33using System.Reflection;
34using System.IO;
35using System.Threading;
36using OpenSim.Physics.Manager;
37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Types;
39using OpenSim.Framework.Inventory;
40using OpenSim.Region.Terrain;
41using OpenSim.Region.Caches;
42
43namespace OpenSim.Region.Environment.Scenes
44{
45 public abstract class SceneBase : IWorld
46 {
47 public Dictionary<libsecondlife.LLUUID, Entity> Entities;
48 protected Dictionary<uint, IClientAPI> m_clientThreads;
49 protected ulong m_regionHandle;
50 protected string m_regionName;
51 protected RegionInfo m_regInfo;
52
53 public TerrainEngine Terrain;
54
55 public string m_datastore;
56 public ILocalStorage localStorage;
57
58 protected object m_syncRoot = new object();
59 private uint m_nextLocalId = 8880000;
60 protected AssetCache assetCache;
61
62 #region Update Methods
63 /// <summary>
64 /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation)
65 /// </summary>
66 public abstract void Update();
67
68 #endregion
69
70 #region Terrain Methods
71
72 /// <summary>
73 /// Loads the World heightmap
74 /// </summary>
75 public abstract void LoadWorldMap();
76
77 /// <summary>
78 /// Loads a new storage subsystem from a named library
79 /// </summary>
80 /// <param name="dllName">Storage Library</param>
81 /// <returns>Successful or not</returns>
82 public bool LoadStorageDLL(string dllName)
83 {
84 try
85 {
86 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
87 ILocalStorage store = null;
88
89 foreach (Type pluginType in pluginAssembly.GetTypes())
90 {
91 if (pluginType.IsPublic)
92 {
93 if (!pluginType.IsAbstract)
94 {
95 Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
96
97 if (typeInterface != null)
98 {
99 ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
100 store = plug;
101
102 store.Initialise(this.m_datastore);
103 break;
104 }
105
106 typeInterface = null;
107 }
108 }
109 }
110 pluginAssembly = null;
111 this.localStorage = store;
112 return (store == null);
113 }
114 catch (Exception e)
115 {
116 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString());
117 return false;
118 }
119 }
120
121
122 /// <summary>
123 /// Send the region heightmap to the client
124 /// </summary>
125 /// <param name="RemoteClient">Client to send to</param>
126 public virtual void SendLayerData(IClientAPI RemoteClient)
127 {
128 RemoteClient.SendLayerData(Terrain.getHeights1D());
129 }
130
131 /// <summary>
132 /// Sends a specified patch to a client
133 /// </summary>
134 /// <param name="px">Patch coordinate (x) 0..16</param>
135 /// <param name="py">Patch coordinate (y) 0..16</param>
136 /// <param name="RemoteClient">The client to send to</param>
137 public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient)
138 {
139 RemoteClient.SendLayerData(px, py, Terrain.getHeights1D());
140 }
141
142 #endregion
143
144 #region Add/Remove Agent/Avatar
145 /// <summary>
146 ///
147 /// </summary>
148 /// <param name="remoteClient"></param>
149 /// <param name="agentID"></param>
150 /// <param name="child"></param>
151 public abstract void AddNewClient(IClientAPI remoteClient, LLUUID agentID, bool child);
152
153 /// <summary>
154 ///
155 /// </summary>
156 /// <param name="agentID"></param>
157 public abstract void RemoveClient(LLUUID agentID);
158
159 #endregion
160
161 /// <summary>
162 ///
163 /// </summary>
164 /// <returns></returns>
165 public virtual RegionInfo RegionInfo
166 {
167 get { return this.m_regInfo; }
168 }
169
170 public object SyncRoot
171 {
172 get { return m_syncRoot; }
173 }
174
175 public uint NextLocalId
176 {
177 get { return m_nextLocalId++; }
178 }
179
180 #region Shutdown
181 /// <summary>
182 /// Tidy before shutdown
183 /// </summary>
184 public virtual void Close()
185 {
186 try
187 {
188 this.localStorage.ShutDown();
189 }
190 catch (Exception e)
191 {
192 OpenSim.Framework.Console.MainLog.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString());
193 }
194 }
195
196 #endregion
197
198
199 }
200}
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
new file mode 100644
index 0000000..fa1bacb
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -0,0 +1,52 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Region.Environment.Scenes
6{
7 /// <summary>
8 /// A class for triggering remote scene events.
9 /// </summary>
10 public class EventManager
11 {
12 public delegate void OnFrameDelegate();
13 public event OnFrameDelegate OnFrame;
14
15 public delegate void OnNewPresenceDelegate(ScenePresence presence);
16 public event OnNewPresenceDelegate OnNewPresence;
17
18 public delegate void OnNewPrimitiveDelegate(Primitive prim);
19 public event OnNewPrimitiveDelegate OnNewPrimitive;
20
21 public delegate void OnRemovePresenceDelegate(libsecondlife.LLUUID uuid);
22 public event OnRemovePresenceDelegate OnRemovePresence;
23
24 public void TriggerOnFrame()
25 {
26 if (OnFrame != null)
27 {
28 OnFrame();
29 }
30 }
31
32 public void TriggerOnNewPrimitive(Primitive prim)
33 {
34 if (OnNewPrimitive != null)
35 OnNewPrimitive(prim);
36 }
37
38 public void TriggerOnNewPresence(ScenePresence presence)
39 {
40 if (OnNewPresence != null)
41 OnNewPresence(presence);
42 }
43
44 public void TriggerOnRemovePresence(libsecondlife.LLUUID uuid)
45 {
46 if (OnRemovePresence != null)
47 {
48 OnRemovePresence(uuid);
49 }
50 }
51 }
52}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs
new file mode 100644
index 0000000..88fb160
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs
@@ -0,0 +1,128 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32using libsecondlife.Packets;
33using OpenSim.Framework.Interfaces;
34using OpenSim.Physics.Manager;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Inventory;
37
38namespace OpenSim.Region.Environment.Scenes
39{
40 public class SceneObject : Entity
41 {
42 private LLUUID rootUUID;
43 //private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>();
44 protected Primitive rootPrimitive;
45 private Scene m_world;
46 protected ulong regionHandle;
47
48 /// <summary>
49 ///
50 /// </summary>
51 public SceneObject()
52 {
53
54 }
55
56 /// <summary>
57 ///
58 /// </summary>
59 /// <param name="addPacket"></param>
60 /// <param name="agentID"></param>
61 /// <param name="localID"></param>
62 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID)
63 {
64 this.rootPrimitive = new Primitive( this.regionHandle, this.m_world, addPacket, agentID, localID);
65 }
66
67 /// <summary>
68 ///
69 /// </summary>
70 /// <param name="data"></param>
71 public void CreateFromBytes(byte[] data)
72 {
73
74 }
75
76 /// <summary>
77 ///
78 /// </summary>
79 public override void update()
80 {
81
82 }
83
84 /// <summary>
85 ///
86 /// </summary>
87 public override void BackUp()
88 {
89
90 }
91
92 /// <summary>
93 ///
94 /// </summary>
95 /// <param name="client"></param>
96 public void GetProperites(IClientAPI client)
97 {
98 //needs changing
99 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
100 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
101 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
102 proper.ObjectData[0].ItemID = LLUUID.Zero;
103 proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.primData.CreationDate;
104 proper.ObjectData[0].CreatorID = this.rootPrimitive.primData.OwnerID;
105 proper.ObjectData[0].FolderID = LLUUID.Zero;
106 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
107 proper.ObjectData[0].GroupID = LLUUID.Zero;
108 proper.ObjectData[0].InventorySerial = 0;
109 proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
110 proper.ObjectData[0].ObjectID = this.uuid;
111 proper.ObjectData[0].OwnerID = this.rootPrimitive.primData.OwnerID;
112 proper.ObjectData[0].TouchName = new byte[0];
113 proper.ObjectData[0].TextureID = new byte[0];
114 proper.ObjectData[0].SitName = new byte[0];
115 proper.ObjectData[0].Name = new byte[0];
116 proper.ObjectData[0].Description = new byte[0];
117 proper.ObjectData[0].OwnerMask = this.rootPrimitive.primData.OwnerMask;
118 proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.primData.NextOwnerMask;
119 proper.ObjectData[0].GroupMask = this.rootPrimitive.primData.GroupMask;
120 proper.ObjectData[0].EveryoneMask = this.rootPrimitive.primData.EveryoneMask;
121 proper.ObjectData[0].BaseMask = this.rootPrimitive.primData.BaseMask;
122
123 client.OutPacket(proper);
124
125 }
126
127 }
128}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs
new file mode 100644
index 0000000..2caabc2
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs
@@ -0,0 +1,76 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32using System.Xml;
33
34namespace OpenSim.Region.Environment.Scenes
35{
36 partial class ScenePresence
37 {
38 public class AvatarAnimations
39 {
40
41 public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
42 public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
43
44 public AvatarAnimations()
45 {
46 }
47
48 public void LoadAnims()
49 {
50 //OpenSim.Framework.Console.MainLog.Instance.Verbose("Avatar.cs:LoadAnims() - Loading avatar animations");
51 XmlTextReader reader = new XmlTextReader("data/avataranimations.xml");
52
53 XmlDocument doc = new XmlDocument();
54 doc.Load(reader);
55 foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
56 {
57
58 if (nod.Attributes["name"] != null)
59 {
60 AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText);
61 }
62
63 }
64
65 reader.Close();
66
67 // OpenSim.Framework.Console.MainLog.Instance.Verbose("Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)");
68
69 foreach (KeyValuePair<string, LLUUID> kp in OpenSim.Region.Environment.Scenes.ScenePresence.Animations.AnimsLLUUID)
70 {
71 AnimsNames.Add(kp.Value, kp.Key);
72 }
73 }
74 }
75 }
76}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs
new file mode 100644
index 0000000..2c81d2a
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs
@@ -0,0 +1,90 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32using libsecondlife.Packets;
33using OpenSim.Physics.Manager;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36
37namespace OpenSim.Region.Environment.Scenes
38{
39 partial class ScenePresence
40 {
41 public class Avatar : IScenePresenceBody
42 {
43 public Avatar()
44 {
45
46 }
47
48 public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
49 {
50 }
51
52 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
53 {
54 }
55
56 public void SendOurAppearance(IClientAPI OurClient)
57 {
58 }
59
60 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
61 {
62 }
63 }
64
65 public class ChildAgent : IScenePresenceBody //is a ghost
66 {
67 public ChildAgent()
68 {
69
70 }
71
72 public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
73 {
74 }
75
76 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
77 {
78 }
79
80 public void SendOurAppearance(IClientAPI OurClient)
81 {
82 }
83
84 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
85 {
86 }
87 }
88 }
89
90}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
new file mode 100644
index 0000000..b90004e
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -0,0 +1,549 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Text;
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Physics.Manager;
35using OpenSim.Framework.Inventory;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types;
38using Axiom.MathLib;
39
40namespace OpenSim.Region.Environment.Scenes
41{
42 public partial class ScenePresence : Entity
43 {
44 public static bool PhysicsEngineFlying = false;
45 public static AvatarAnimations Animations;
46 public static byte[] DefaultTexture;
47 public string firstname;
48 public string lastname;
49 public IClientAPI ControllingClient;
50 public LLUUID current_anim;
51 public int anim_seq;
52 private bool updateflag = false;
53 private byte movementflag = 0;
54 private List<NewForce> forcesList = new List<NewForce>();
55 private short _updateCount = 0;
56 private Axiom.MathLib.Quaternion bodyRot;
57 private LLObject.TextureEntry avatarAppearanceTexture = null;
58 private byte[] visualParams;
59 private AvatarWearable[] Wearables;
60 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
61 private ulong m_regionHandle;
62 private bool childAgent = false;
63 private bool newForce = false;
64 private bool newAvatar = false;
65 private IScenePresenceBody m_body;
66
67 protected RegionInfo m_regionInfo;
68
69 private Vector3[] Dir_Vectors = new Vector3[6];
70 private enum Dir_ControlFlags
71 {
72 DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS,
73 DIR_CONTROL_FLAG_BACK = MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG,
74 DIR_CONTROL_FLAG_LEFT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_POS,
75 DIR_CONTROL_FLAG_RIGHT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_NEG,
76 DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS,
77 DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG
78 }
79
80 #region Properties
81 /// <summary>
82 ///
83 /// </summary>
84 public PhysicsActor PhysActor
85 {
86 set
87 {
88 this._physActor = value;
89 }
90 get
91 {
92 return _physActor;
93 }
94 }
95 #endregion
96
97 #region Constructor(s)
98 /// <summary>
99 ///
100 /// </summary>
101 /// <param name="theClient"></param>
102 /// <param name="world"></param>
103 /// <param name="clientThreads"></param>
104 /// <param name="regionDat"></param>
105 public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo)
106 {
107
108 m_world = world;
109 this.uuid = theClient.AgentId;
110
111 m_regionInfo = reginfo;
112 m_regionHandle = reginfo.RegionHandle;
113 OpenSim.Framework.Console.MainLog.Instance.Verbose("Avatar.cs ");
114 ControllingClient = theClient;
115 this.firstname = ControllingClient.FirstName;
116 this.lastname = ControllingClient.LastName;
117 m_localId = m_world.NextLocalId;
118 Pos = ControllingClient.StartPos;
119 visualParams = new byte[218];
120 for (int i = 0; i < 218; i++)
121 {
122 visualParams[i] = 100;
123 }
124
125 Wearables = AvatarWearable.DefaultWearables;
126
127 this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
128
129 //register for events
130 ControllingClient.OnRequestWearables += this.SendOurAppearance;
131 //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance);
132 ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement;
133 ControllingClient.OnCompleteMovementToRegion += this.SendInitialData;
134 ControllingClient.OnAgentUpdate += this.HandleAgentUpdate;
135 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
136 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
137 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
138
139 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD
140 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK
141 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT
142 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT
143 Dir_Vectors[4] = new Vector3(0, 0, 1); //UP
144 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN
145
146 }
147 #endregion
148
149 #region Status Methods
150 /// <summary>
151 /// Not Used, most likely can be deleted
152 /// </summary>
153 /// <param name="status"></param>
154 public void ChildStatusChange(bool status)
155 {
156 this.childAgent = status;
157
158 if (this.childAgent == true)
159 {
160 this.Velocity = new LLVector3(0, 0, 0);
161 this.Pos = new LLVector3(128, 128, 70);
162
163 }
164 }
165
166 /// <summary>
167 ///
168 /// </summary>
169 /// <param name="pos"></param>
170 public void MakeAvatar(LLVector3 pos)
171 {
172 //this.childAvatar = false;
173 this.Pos = pos;
174 this.newAvatar = true;
175 this.childAgent = false;
176 }
177
178 protected void MakeChildAgent()
179 {
180 this.Velocity = new LLVector3(0, 0, 0);
181 this.Pos = new LLVector3(128, 128, 70);
182 this.childAgent = true;
183 }
184
185 /// <summary>
186 ///
187 /// </summary>
188 /// <param name="pos"></param>
189 public void Teleport(LLVector3 pos)
190 {
191 this.Pos = pos;
192 this.SendTerseUpdateToALLClients();
193 }
194
195 /// <summary>
196 ///
197 /// </summary>
198 public void StopMovement()
199 {
200
201 }
202 #endregion
203
204 #region Event Handlers
205 /// <summary>
206 ///
207 /// </summary>
208 /// <param name="texture"></param>
209 /// <param name="visualParam"></param>
210 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
211 {
212
213 }
214
215 /// <summary>
216 /// Complete Avatar's movement into the region
217 /// </summary>
218 public void CompleteMovement()
219 {
220 LLVector3 look = this.Velocity;
221 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
222 {
223 look = new LLVector3(0.99f, 0.042f, 0);
224 }
225 this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos, look);
226 if (this.childAgent)
227 {
228 this.childAgent = false;
229 }
230 }
231
232 /// <summary>
233 ///
234 /// </summary>
235 /// <param name="pack"></param>
236 public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
237 {
238 int i = 0;
239 bool update_movementflag = false;
240 bool update_rotation = false;
241 bool DCFlagKeyPressed = false;
242 Vector3 agent_control_v3 = new Vector3(0, 0, 0);
243 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z);
244
245 this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0);
246
247 if (q != this.bodyRot)
248 {
249 this.bodyRot = q;
250 update_rotation = true;
251 }
252 foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags)))
253 {
254 if ((flags & (uint)DCF) != 0)
255 {
256 DCFlagKeyPressed = true;
257 agent_control_v3 += Dir_Vectors[i];
258 if ((movementflag & (uint)DCF) == 0)
259 {
260 movementflag += (byte)(uint)DCF;
261 update_movementflag = true;
262 }
263 }
264 else
265 {
266 if ((movementflag & (uint)DCF) != 0)
267 {
268 movementflag -= (byte)(uint)DCF;
269 update_movementflag = true;
270 }
271 }
272 i++;
273 }
274 if ((update_movementflag) || (update_rotation && DCFlagKeyPressed))
275 {
276 this.AddNewMovement(agent_control_v3, q);
277 }
278
279 }
280
281 protected void AddNewMovement(Axiom.MathLib.Vector3 vec, Axiom.MathLib.Quaternion rotation)
282 {
283 NewForce newVelocity = new NewForce();
284 Axiom.MathLib.Vector3 direc = rotation * vec;
285 direc.Normalize();
286
287 direc = direc * ((0.03f) * 128f);
288 if (this._physActor.Flying)
289 direc *= 4;
290
291 newVelocity.X = direc.x;
292 newVelocity.Y = direc.y;
293 newVelocity.Z = direc.z;
294 this.forcesList.Add(newVelocity);
295 }
296
297 #endregion
298
299 #region Overridden Methods
300 /// <summary>
301 ///
302 /// </summary>
303 public override void LandRenegerated()
304 {
305
306 }
307
308 /// <summary>
309 ///
310 /// </summary>
311 public override void update()
312 {
313 if (this.childAgent == false)
314 {
315 if (this.newForce)
316 {
317 this.SendTerseUpdateToALLClients();
318 _updateCount = 0;
319 }
320 else if (movementflag != 0)
321 {
322 _updateCount++;
323 if (_updateCount > 3)
324 {
325 this.SendTerseUpdateToALLClients();
326 _updateCount = 0;
327 }
328 }
329
330 this.CheckForBorderCrossing();
331 }
332 }
333 #endregion
334
335 #region Update Client(s)
336 /// <summary>
337 ///
338 /// </summary>
339 /// <param name="RemoteClient"></param>
340 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
341 {
342 LLVector3 pos = this.Pos;
343 LLVector3 vel = this.Velocity;
344 RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z));
345 }
346
347 /// <summary>
348 ///
349 /// </summary>
350 public void SendTerseUpdateToALLClients()
351 {
352 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
353 for (int i = 0; i < avatars.Count; i++)
354 {
355 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
356 }
357 }
358
359 /// <summary>
360 ///
361 /// </summary>
362 /// <param name="remoteAvatar"></param>
363 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
364 {
365 remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture);
366 }
367
368 /// <summary>
369 ///
370 /// </summary>
371 public void SendInitialData()
372 {
373 this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture);
374 if (this.newAvatar)
375 {
376 this.m_world.InformClientOfNeighbours(this.ControllingClient);
377 this.newAvatar = false;
378 }
379 }
380
381 /// <summary>
382 ///
383 /// </summary>
384 /// <param name="OurClient"></param>
385 public void SendOurAppearance(IClientAPI OurClient)
386 {
387 this.ControllingClient.SendWearables(this.Wearables);
388 }
389
390 /// <summary>
391 ///
392 /// </summary>
393 /// <param name="avatarInfo"></param>
394 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
395 {
396
397 }
398
399 /// <summary>
400 ///
401 /// </summary>
402 /// <param name="animID"></param>
403 /// <param name="seq"></param>
404 public void SendAnimPack(LLUUID animID, int seq)
405 {
406
407
408 }
409
410 /// <summary>
411 ///
412 /// </summary>
413 public void SendAnimPack()
414 {
415
416 }
417 #endregion
418
419 #region Border Crossing Methods
420 /// <summary>
421 ///
422 /// </summary>
423 protected void CheckForBorderCrossing()
424 {
425 LLVector3 pos2 = this.Pos;
426 LLVector3 vel = this.Velocity;
427
428 float timeStep = 0.2f;
429 pos2.X = pos2.X + (vel.X * timeStep);
430 pos2.Y = pos2.Y + (vel.Y * timeStep);
431 pos2.Z = pos2.Z + (vel.Z * timeStep);
432
433 if ((pos2.X < 0) || (pos2.X > 256))
434 {
435 this.CrossToNewRegion();
436 }
437
438 if ((pos2.Y < 0) || (pos2.Y > 256))
439 {
440 this.CrossToNewRegion();
441 }
442 }
443
444 /// <summary>
445 ///
446 /// </summary>
447 protected void CrossToNewRegion()
448 {
449 LLVector3 pos = this.Pos;
450 LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z);
451 uint neighbourx = this.m_regionInfo.RegionLocX;
452 uint neighboury = this.m_regionInfo.RegionLocY;
453
454 if (pos.X < 2)
455 {
456 neighbourx -= 1;
457 newpos.X = 254;
458 }
459 if (pos.X > 253)
460 {
461 neighbourx += 1;
462 newpos.X = 1;
463 }
464 if (pos.Y < 2)
465 {
466 neighboury -= 1;
467 newpos.Y = 254;
468 }
469 if (pos.Y > 253)
470 {
471 neighboury += 1;
472 newpos.Y = 1;
473 }
474
475 LLVector3 vel = this.velocity;
476 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256));
477 RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle);
478 if (neighbourRegion != null)
479 {
480 bool res = this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos);
481 if (res)
482 {
483 this.MakeChildAgent();
484 this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, System.Net.IPAddress.Parse(neighbourRegion.CommsIPListenAddr), (ushort)neighbourRegion.CommsIPListenPort);
485 }
486 }
487 }
488 #endregion
489
490 /// <summary>
491 ///
492 /// </summary>
493 public static void LoadAnims()
494 {
495
496 }
497
498 /// <summary>
499 ///
500 /// </summary>
501 public override void updateMovement()
502 {
503 newForce = false;
504 lock (this.forcesList)
505 {
506 if (this.forcesList.Count > 0)
507 {
508 for (int i = 0; i < this.forcesList.Count; i++)
509 {
510 NewForce force = this.forcesList[i];
511
512 this.updateflag = true;
513 this.Velocity = new LLVector3(force.X, force.Y, force.Z);
514 this.newForce = true;
515 }
516 for (int i = 0; i < this.forcesList.Count; i++)
517 {
518 this.forcesList.RemoveAt(0);
519 }
520 }
521 }
522 }
523
524 public static void LoadTextureFile(string name)
525 {
526 FileInfo fInfo = new FileInfo(name);
527 long numBytes = fInfo.Length;
528 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
529 BinaryReader br = new BinaryReader(fStream);
530 byte[] data1 = br.ReadBytes((int)numBytes);
531 br.Close();
532 fStream.Close();
533 DefaultTexture = data1;
534 }
535
536 public class NewForce
537 {
538 public float X;
539 public float Y;
540 public float Z;
541
542 public NewForce()
543 {
544
545 }
546 }
547 }
548
549}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpScriptEngine.cs
new file mode 100644
index 0000000..a232b65
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpScriptEngine.cs
@@ -0,0 +1,104 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32// Compilation stuff
33using System.CodeDom;
34using System.CodeDom.Compiler;
35using Microsoft.CSharp;
36
37namespace OpenSim.Region.Enviorment.Scripting
38{
39 public class CSharpScriptEngine : IScriptCompiler
40 {
41 public string FileExt()
42 {
43 return ".cs";
44 }
45
46 private Dictionary<string,IScript> LoadDotNetScript(ICodeCompiler compiler, string filename)
47 {
48 CompilerParameters compilerParams = new CompilerParameters();
49 CompilerResults compilerResults;
50 compilerParams.GenerateExecutable = false;
51 compilerParams.GenerateInMemory = true;
52 compilerParams.IncludeDebugInformation = false;
53 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
54 compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
55 compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
56 compilerParams.ReferencedAssemblies.Add("System.dll");
57
58 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
59
60 if (compilerResults.Errors.Count > 0)
61 {
62 OpenSim.Framework.Console.MainLog.Instance.Error("Compile errors");
63 foreach (CompilerError error in compilerResults.Errors)
64 {
65 OpenSim.Framework.Console.MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
66 }
67 }
68 else
69 {
70 Dictionary<string,IScript> scripts = new Dictionary<string,IScript>();
71
72 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
73 {
74 Type testInterface = pluginType.GetInterface("IScript", true);
75
76 if (testInterface != null)
77 {
78 IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
79
80 string scriptName = "C#/" + script.getName();
81 Console.WriteLine("Script: " + scriptName + " loaded.");
82
83 if (!scripts.ContainsKey(scriptName))
84 {
85 scripts.Add(scriptName, script);
86 }
87 else
88 {
89 scripts[scriptName] = script;
90 }
91 }
92 }
93 return scripts;
94 }
95 return null;
96 }
97
98 public Dictionary<string,IScript> compile(string filename)
99 {
100 CSharpCodeProvider csharpProvider = new CSharpCodeProvider();
101 return LoadDotNetScript(csharpProvider.CreateCompiler(), filename);
102 }
103 }
104}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine.cs
new file mode 100644
index 0000000..2d44223
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine.cs
@@ -0,0 +1,104 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32// Compilation stuff
33using System.CodeDom;
34using System.CodeDom.Compiler;
35using Microsoft.JScript;
36
37namespace OpenSim.Region.Enviorment.Scripting
38{
39 public class JScriptEngine : IScriptCompiler
40 {
41 public string FileExt()
42 {
43 return ".js";
44 }
45
46 private Dictionary<string, IScript> LoadDotNetScript(ICodeCompiler compiler, string filename)
47 {
48 CompilerParameters compilerParams = new CompilerParameters();
49 CompilerResults compilerResults;
50 compilerParams.GenerateExecutable = false;
51 compilerParams.GenerateInMemory = true;
52 compilerParams.IncludeDebugInformation = false;
53 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
54 compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
55 compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
56 compilerParams.ReferencedAssemblies.Add("System.dll");
57
58 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
59
60 if (compilerResults.Errors.Count > 0)
61 {
62 OpenSim.Framework.Console.MainLog.Instance.Error("Compile errors");
63 foreach (CompilerError error in compilerResults.Errors)
64 {
65 OpenSim.Framework.Console.MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
66 }
67 }
68 else
69 {
70 Dictionary<string, IScript> scripts = new Dictionary<string, IScript>();
71
72 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
73 {
74 Type testInterface = pluginType.GetInterface("IScript", true);
75
76 if (testInterface != null)
77 {
78 IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
79
80 string scriptName = "JS.NET/" + script.getName();
81 Console.WriteLine("Script: " + scriptName + " loaded.");
82
83 if (!scripts.ContainsKey(scriptName))
84 {
85 scripts.Add(scriptName, script);
86 }
87 else
88 {
89 scripts[scriptName] = script;
90 }
91 }
92 }
93 return scripts;
94 }
95 return null;
96 }
97
98 public Dictionary<string, IScript> compile(string filename)
99 {
100 JScriptCodeProvider jscriptProvider = new JScriptCodeProvider();
101 return LoadDotNetScript(jscriptProvider.CreateCompiler(), filename);
102 }
103 }
104}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Script.cs b/OpenSim/Region/Environment/Scenes/scripting/Script.cs
new file mode 100644
index 0000000..1e64675
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Script.cs
@@ -0,0 +1,71 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32using OpenSim.Framework.Console;
33using OpenSim.Framework;
34using OpenSim.Region.Environment;
35using OpenSim.Region.Environment.Scenes;
36
37namespace OpenSim.Region.Enviorment.Scripting
38{
39 public interface IScript
40 {
41 void Initialise(ScriptInfo scriptInfo);
42 string getName();
43 }
44
45 public class TestScript : IScript
46 {
47 ScriptInfo script;
48
49 public string getName()
50 {
51 return "TestScript 0.1";
52 }
53
54 public void Initialise(ScriptInfo scriptInfo)
55 {
56 script = scriptInfo;
57 script.events.OnFrame += new OpenSim.Region.Environment.Scenes.EventManager.OnFrameDelegate(events_OnFrame);
58 script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
59 }
60
61 void events_OnNewPresence(ScenePresence presence)
62 {
63 script.logger.Verbose("Hello " + presence.firstname.ToString() + "!");
64 }
65
66 void events_OnFrame()
67 {
68 //script.logger.Verbose("Hello World!");
69 }
70 }
71}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs
new file mode 100644
index 0000000..522a572
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32using OpenSim.Region.Environment.Scenes;
33using OpenSim.Framework.Console;
34
35namespace OpenSim.Region.Enviorment.Scripting
36{
37 /// <summary>
38 /// Class which provides access to the world
39 /// </summary>
40 public class ScriptInfo
41 {
42 // Reference to world.eventsManager provided for convenience
43 public EventManager events;
44
45 // The main world
46 public Scene world;
47
48 // The console
49 public LogBase logger;
50
51 public ScriptInfo(Scene scene)
52 {
53 world = scene;
54 events = world.eventManager;
55 logger = OpenSim.Framework.Console.MainLog.Instance;
56 }
57 }
58}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs
new file mode 100644
index 0000000..eb1c1d9
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs
@@ -0,0 +1,96 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Region.Enviorment.Scripting
33{
34 public class ScriptManager
35 {
36 List<IScript> scripts = new List<IScript>();
37 OpenSim.Region.Environment.Scenes.Scene scene;
38 Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>();
39
40 private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts)
41 {
42 foreach (KeyValuePair<string, IScript> script in compiledscripts)
43 {
44 ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
45 OpenSim.Framework.Console.MainLog.Instance.Verbose("Loading " + script.Key);
46 script.Value.Initialise(scriptInfo);
47 scripts.Add(script.Value);
48 }
49 OpenSim.Framework.Console.MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)");
50 }
51
52 public ScriptManager(OpenSim.Region.Environment.Scenes.Scene world)
53 {
54 scene = world;
55
56 // Default Engines
57 CSharpScriptEngine csharpCompiler = new CSharpScriptEngine();
58 compilers.Add(csharpCompiler.FileExt(),csharpCompiler);
59
60 JScriptEngine jscriptCompiler = new JScriptEngine();
61 compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler);
62 }
63
64 public void Compile(string filename)
65 {
66 foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers)
67 {
68 if (filename.EndsWith(compiler.Key))
69 {
70 LoadFromCompiler(compiler.Value.compile(filename));
71 break;
72 }
73 }
74 }
75
76 public void RunScriptCmd(string[] args)
77 {
78 switch (args[0])
79 {
80 case "load":
81 Compile(args[1]);
82 break;
83
84 default:
85 OpenSim.Framework.Console.MainLog.Instance.Error("Unknown script command");
86 break;
87 }
88 }
89 }
90
91 interface IScriptCompiler
92 {
93 Dictionary<string,IScript> compile(string filename);
94 string FileExt();
95 }
96}
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
new file mode 100644
index 0000000..89f39d3
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
@@ -0,0 +1,113 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Interfaces;
5using OpenSim.Framework.Types;
6using OpenSim.Framework.Console;
7using libsecondlife;
8using OpenSim.Region.Environment;
9using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence;
10using OpenSim.Region.Environment.Scenes;
11using OpenSim.Framework;
12using OpenSim.Region.Caches;
13using OpenSim.Framework.Communications;
14using OpenSim.Framework.Servers;
15
16namespace SimpleApp
17{
18 public class MyWorld : Scene
19 {
20 private RegionInfo m_regionInfo;
21 private List<OpenSim.Region.Environment.Scenes.ScenePresence> m_avatars;
22
23 public MyWorld(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
24 : base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer)
25 {
26 m_regionInfo = regionInfo;
27 m_avatars = new List<Avatar>();
28 }
29
30 public override void SendLayerData(IClientAPI remoteClient)
31 {
32 float[] map = new float[65536];
33
34 for (int i = 0; i < 65536; i++)
35 {
36 int x = i % 256;
37 int y = i / 256;
38
39 map[i] = (float)(x + y / 2);
40 }
41
42 remoteClient.SendLayerData(map);
43 }
44
45 #region IWorld Members
46
47 override public void AddNewClient(IClientAPI client, LLUUID agentID, bool child)
48
49 {
50 LLVector3 pos = new LLVector3(128, 128, 128);
51
52 client.OnRegionHandShakeReply += SendLayerData;
53 client.OnChatFromViewer +=
54 delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
55 {
56 // Echo it (so you know what you typed)
57 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
58 client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero );
59 };
60
61 client.OnRequestWearables += SendWearables;
62
63 client.OnCompleteMovementToRegion += delegate()
64 {
65 client.MoveAgentIntoRegion(m_regionInfo, pos, LLVector3.Zero );
66 };
67
68 client.OnCompleteMovementToRegion += delegate()
69 {
70 client.SendAvatarData(m_regionInfo.RegionHandle, client.FirstName,
71 client.LastName, client.AgentId, 0,
72 pos, null);
73
74 client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero );
75 };
76
77 client.SendRegionHandshake(m_regionInfo);
78
79 OpenSim.Region.Environment.Scenes.ScenePresence avatar = new Avatar( client, this, m_regionInfo );
80
81 }
82
83 private void SendWearables( IClientAPI client )
84 {
85 client.SendWearables( AvatarWearable.DefaultWearables );
86 }
87
88
89 override public void RemoveClient(LLUUID agentID)
90 {
91
92 }
93
94 public RegionInfo RegionInfo
95 {
96 get { return m_regionInfo; }
97 }
98
99 public object SyncRoot
100 {
101 get { return this; }
102 }
103
104 private uint m_nextLocalId = 1;
105
106 public uint NextLocalId
107 {
108 get { return m_nextLocalId++; }
109 }
110
111 #endregion
112 }
113}
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
new file mode 100644
index 0000000..4060d68
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -0,0 +1,129 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim;
5using OpenSim.Region.GridInterfaces.Local;
6using OpenSim.Framework.Interfaces;
7using OpenSim.Framework.Types;
8using OpenSim.Framework.Console;
9using OpenSim.Framework.Servers;
10using OpenSim.Assets;
11using libsecondlife;
12using OpenSim.Framework;
13using OpenSim.Region.Caches;
14using OpenSim.Framework.Communications;
15using OpenSim.Region.Communications.Local;
16using OpenSim.Region.ClientStack;
17
18namespace SimpleApp
19{
20 class Program : IAssetReceiver, conscmd_callback
21 {
22 private LogBase m_log;
23 AuthenticateSessionsBase m_circuitManager;
24
25 private void Run()
26 {
27 m_log = new LogBase(null, "SimpleApp", this, false);
28 MainLog.Instance = m_log;
29
30 // CheckSumServer checksumServer = new CheckSumServer(12036);
31 // checksumServer.ServerListener();
32
33 string simAddr = "127.0.0.1";
34 int simPort = 9000;
35 /*
36 LoginServer loginServer = new LoginServer( simAddr, simPort, 0, 0, false );
37 loginServer.Startup();
38 loginServer.SetSessionHandler( AddNewSessionHandler );*/
39
40 m_circuitManager = new AuthenticateSessionsBase();
41
42 InventoryCache inventoryCache = new InventoryCache();
43
44 LocalAssetServer assetServer = new LocalAssetServer();
45 assetServer.SetServerInfo("http://127.0.0.1:8003/", "");
46 assetServer.SetReceiver(this);
47
48 AssetCache assetCache = new AssetCache(assetServer);
49
50 UDPServer udpServer = new UDPServer(simPort, assetCache, inventoryCache, m_log, m_circuitManager );
51 PacketServer packetServer = new PacketServer( udpServer, (uint) simPort );
52 udpServer.ServerListener();
53
54 ClientView.TerrainManager = new TerrainManager(new SecondLife());
55
56 CommunicationsManager communicationsManager = new CommunicationsLocal(null);
57
58 RegionInfo regionInfo = new RegionInfo( );
59 BaseHttpServer httpServer = new BaseHttpServer(simPort);
60 udpServer.LocalWorld = new MyWorld( packetServer.ClientAPIs, regionInfo, m_circuitManager, communicationsManager, assetCache, httpServer );
61
62 // World world = new World(udpServer.PacketServer.ClientAPIs, regionInfo);
63 // PhysicsScene physicsScene = new NullPhysicsScene();
64 // world.PhysicsScene = physicsScene;
65 // udpServer.LocalWorld = world;
66
67 // httpServer.AddXmlRPCHandler( "login_to_simulator", loginServer.XmlRpcLoginMethod );
68 httpServer.Start();
69
70 m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit.");
71 m_log.ReadLine();
72 }
73
74 private bool AddNewSessionHandler(ulong regionHandle, Login loginData)
75 {
76 m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last);
77
78 AgentCircuitData agent = new AgentCircuitData();
79 agent.AgentID = loginData.Agent;
80 agent.firstname = loginData.First;
81 agent.lastname = loginData.Last;
82 agent.SessionID = loginData.Session;
83 agent.SecureSessionID = loginData.SecureSession;
84 agent.circuitcode = loginData.CircuitCode;
85 agent.BaseFolder = loginData.BaseFolder;
86 agent.InventoryFolder = loginData.InventoryFolder;
87 agent.startpos = new LLVector3(128, 128, 70);
88
89 m_circuitManager.AddNewCircuit(agent.circuitcode, agent);
90
91 return true;
92 }
93
94 #region IAssetReceiver Members
95
96 public void AssetReceived( AssetBase asset, bool IsTexture)
97 {
98 throw new Exception("The method or operation is not implemented.");
99 }
100
101 public void AssetNotFound( AssetBase asset)
102 {
103 throw new Exception("The method or operation is not implemented.");
104 }
105
106 #endregion
107
108 #region conscmd_callback Members
109
110 public void RunCmd(string cmd, string[] cmdparams)
111 {
112 throw new Exception("The method or operation is not implemented.");
113 }
114
115 public void Show(string ShowWhat)
116 {
117 throw new Exception("The method or operation is not implemented.");
118 }
119
120 #endregion
121
122 static void Main(string[] args)
123 {
124 Program app = new Program();
125
126 app.Run();
127 }
128 }
129}
diff --git a/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs b/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..0f9bf0f
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("SimpleApp")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("Playahead AB")]
12[assembly: AssemblyProduct("SimpleApp")]
13[assembly: AssemblyCopyright("Copyright © Playahead AB 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("a5cfa45f-5acf-4b2e-9c50-1dd1fd7608ee")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj b/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj
new file mode 100644
index 0000000..0a82172
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj
@@ -0,0 +1,156 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{24B12448-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>SimpleApp</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Exe</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>SimpleApp</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="libsecondlife.dll" >
62 <HintPath>..\..\..\..\bin\libsecondlife.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System" >
66 <HintPath>System.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Data.dll" >
70 <HintPath>..\..\..\..\bin\System.Data.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System.Xml" >
74 <HintPath>System.Xml.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="XMLRPC.dll" >
78 <HintPath>..\..\..\..\bin\XMLRPC.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 </ItemGroup>
82 <ItemGroup>
83 <ProjectReference Include="..\..\..\Framework\General\OpenSim.Framework.csproj">
84 <Name>OpenSim.Framework</Name>
85 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
86 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
87 <Private>False</Private>
88 </ProjectReference>
89 <ProjectReference Include="..\..\..\Framework\Communications\OpenSim.Framework.Communications.csproj">
90 <Name>OpenSim.Framework.Communications</Name>
91 <Project>{CB52B7E7-0000-0000-0000-000000000000}</Project>
92 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
93 <Private>False</Private>
94 </ProjectReference>
95 <ProjectReference Include="..\..\..\Framework\Console\OpenSim.Framework.Console.csproj">
96 <Name>OpenSim.Framework.Console</Name>
97 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
98 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
99 <Private>False</Private>
100 </ProjectReference>
101 <ProjectReference Include="..\..\..\Framework\Servers\OpenSim.Framework.Servers.csproj">
102 <Name>OpenSim.Framework.Servers</Name>
103 <Project>{2CC71860-0000-0000-0000-000000000000}</Project>
104 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
105 <Private>False</Private>
106 </ProjectReference>
107 <ProjectReference Include="..\..\Caches\OpenSim.Region.Caches.csproj">
108 <Name>OpenSim.Region.Caches</Name>
109 <Project>{61FCCDB3-0000-0000-0000-000000000000}</Project>
110 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
111 <Private>False</Private>
112 </ProjectReference>
113 <ProjectReference Include="..\..\ClientStack\OpenSim.Region.ClientStack.csproj">
114 <Name>OpenSim.Region.ClientStack</Name>
115 <Project>{DC3698B2-0000-0000-0000-000000000000}</Project>
116 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
117 <Private>False</Private>
118 </ProjectReference>
119 <ProjectReference Include="..\..\Communications\Local\OpenSim.Region.Communications.Local.csproj">
120 <Name>OpenSim.Region.Communications.Local</Name>
121 <Project>{BFB5D807-0000-0000-0000-000000000000}</Project>
122 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
123 <Private>False</Private>
124 </ProjectReference>
125 <ProjectReference Include="..\..\Environment\OpenSim.Region.Environment.csproj">
126 <Name>OpenSim.Region.Environment</Name>
127 <Project>{DCBA491C-0000-0000-0000-000000000000}</Project>
128 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
129 <Private>False</Private>
130 </ProjectReference>
131 <ProjectReference Include="..\..\GridInterfaces\Local\OpenSim.Region.GridInterfaces.Local.csproj">
132 <Name>OpenSim.Region.GridInterfaces.Local</Name>
133 <Project>{241A8CDD-0000-0000-0000-000000000000}</Project>
134 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
135 <Private>False</Private>
136 </ProjectReference>
137 </ItemGroup>
138 <ItemGroup>
139 <Compile Include="MyWorld.cs">
140 <SubType>Code</SubType>
141 </Compile>
142 <Compile Include="Program.cs">
143 <SubType>Code</SubType>
144 </Compile>
145 <Compile Include="Properties\AssemblyInfo.cs">
146 <SubType>Code</SubType>
147 </Compile>
148 </ItemGroup>
149 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
150 <PropertyGroup>
151 <PreBuildEvent>
152 </PreBuildEvent>
153 <PostBuildEvent>
154 </PostBuildEvent>
155 </PropertyGroup>
156</Project>
diff --git a/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build b/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build
new file mode 100644
index 0000000..f8896fa
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build
@@ -0,0 +1,54 @@
1<?xml version="1.0" ?>
2<project name="SimpleApp" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="exe" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.exe">
11 <resources prefix="SimpleApp" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="MyWorld.cs" />
15 <include name="Program.cs" />
16 <include name="Properties/AssemblyInfo.cs" />
17 </sources>
18 <references basedir="${project::get-base-directory()}">
19 <lib>
20 <include name="${project::get-base-directory()}" />
21 <include name="${project::get-base-directory()}/${build.dir}" />
22 </lib>
23 <include name="../../../../bin/libsecondlife.dll" />
24 <include name="../../../../bin/OpenSim.Framework.dll" />
25 <include name="../../../../bin/OpenSim.Framework.Communications.dll" />
26 <include name="../../../../bin/OpenSim.Framework.Console.dll" />
27 <include name="../../../../bin/OpenSim.Framework.Servers.dll" />
28 <include name="../../../../bin/OpenSim.Region.Caches.dll" />
29 <include name="../../../../bin/OpenSim.Region.ClientStack.dll" />
30 <include name="../../../../bin/OpenSim.Region.Communications.Local.dll" />
31 <include name="../../../../bin/OpenSim.Region.Environment.dll" />
32 <include name="../../../../bin/OpenSim.Region.GridInterfaces.Local.dll" />
33 <include name="System.dll" />
34 <include name="System.Data.dll.dll" />
35 <include name="System.Xml.dll" />
36 <include name="../../../../bin/XMLRPC.dll" />
37 </references>
38 </csc>
39 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/" />
40 <mkdir dir="${project::get-base-directory()}/../../../../bin/"/>
41 <copy todir="${project::get-base-directory()}/../../../../bin/">
42 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
43 <include name="*.dll"/>
44 <include name="*.exe"/>
45 </fileset>
46 </copy>
47 </target>
48 <target name="clean">
49 <delete dir="${bin.dir}" failonerror="false" />
50 <delete dir="${obj.dir}" failonerror="false" />
51 </target>
52 <target name="doc" description="Creates documentation.">
53 </target>
54</project>
diff --git a/OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs b/OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs
new file mode 100644
index 0000000..52ecd6b
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// Information about this assembly is defined by the following
33// attributes.
34//
35// change them to the information which is associated with the assembly
36// you compile.
37
38[assembly: AssemblyTitle("LocalGridServers")]
39[assembly: AssemblyDescription("")]
40[assembly: AssemblyConfiguration("")]
41[assembly: AssemblyCompany("")]
42[assembly: AssemblyProduct("LocalGridServers")]
43[assembly: AssemblyCopyright("")]
44[assembly: AssemblyTrademark("")]
45[assembly: AssemblyCulture("")]
46
47// This sets the default COM visibility of types in the assembly to invisible.
48// If you need to expose a type to COM, use [ComVisible(true)] on that type.
49[assembly: ComVisible(false)]
50
51// The assembly version has following format :
52//
53// Major.Minor.Build.Revision
54//
55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default):
57
58[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
new file mode 100644
index 0000000..95d03f1
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
@@ -0,0 +1,312 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using System.Threading;
32using System.IO;
33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework.Types;
35using OpenSim.Framework.Utilities;
36using OpenSim.Framework.Console;
37using libsecondlife;
38using Db4objects.Db4o;
39using Db4objects.Db4o.Query;
40
41namespace OpenSim.Region.GridInterfaces.Local
42{
43 public class LocalAssetPlugin : IAssetPlugin
44 {
45 public LocalAssetPlugin()
46 {
47
48 }
49
50 public IAssetServer GetAssetServer()
51 {
52 return (new LocalAssetServer());
53 }
54 }
55
56 public class LocalAssetServer : IAssetServer
57 {
58 private IAssetReceiver _receiver;
59 private BlockingQueue<ARequest> _assetRequests;
60 private IObjectContainer db;
61 private Thread _localAssetServerThread;
62
63 public LocalAssetServer()
64 {
65 bool yapfile;
66 this._assetRequests = new BlockingQueue<ARequest>();
67 yapfile = System.IO.File.Exists("assets.yap");
68
69 OpenSim.Framework.Console.MainLog.Instance.Verbose( "Local Asset Server class created");
70 try
71 {
72 db = Db4oFactory.OpenFile("assets.yap");
73 OpenSim.Framework.Console.MainLog.Instance.Verbose( "Db4 Asset database creation");
74 }
75 catch (Exception e)
76 {
77 db.Close();
78 OpenSim.Framework.Console.MainLog.Instance.WriteLine(LogPriority.MEDIUM, "Db4 Asset server :Constructor - Exception occured");
79 OpenSim.Framework.Console.MainLog.Instance.Warn(e.ToString());
80 }
81 if (!yapfile)
82 {
83 this.SetUpAssetDatabase();
84 }
85 this._localAssetServerThread = new Thread(new ThreadStart(RunRequests));
86 this._localAssetServerThread.IsBackground = true;
87 this._localAssetServerThread.Start();
88
89 }
90
91 public void SetReceiver(IAssetReceiver receiver)
92 {
93 this._receiver = receiver;
94 }
95
96 public void RequestAsset(LLUUID assetID, bool isTexture)
97 {
98 ARequest req = new ARequest();
99 req.AssetID = assetID;
100 req.IsTexture = isTexture;
101 this._assetRequests.Enqueue(req);
102 }
103
104 public void UpdateAsset(AssetBase asset)
105 {
106
107 }
108
109 public void UploadNewAsset(AssetBase asset)
110 {
111 AssetStorage store = new AssetStorage();
112 store.Data = asset.Data;
113 store.Name = asset.Name;
114 store.UUID = asset.FullID;
115 db.Set(store);
116 db.Commit();
117 }
118
119 public void SetServerInfo(string ServerUrl, string ServerKey)
120 {
121
122 }
123 public void Close()
124 {
125 if (db != null)
126 {
127 OpenSim.Framework.Console.MainLog.Instance.Verbose( "Closing local asset server database");
128 db.Close();
129 }
130 }
131
132 private void RunRequests()
133 {
134 while (true)
135 {
136 byte[] idata = null;
137 bool found = false;
138 AssetStorage foundAsset = null;
139 ARequest req = this._assetRequests.Dequeue();
140 IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
141 if (result.Count > 0)
142 {
143 foundAsset = (AssetStorage)result.Next();
144 found = true;
145 }
146
147 AssetBase asset = new AssetBase();
148 if (found)
149 {
150 asset.FullID = foundAsset.UUID;
151 asset.Type = foundAsset.Type;
152 asset.InvType = foundAsset.Type;
153 asset.Name = foundAsset.Name;
154 idata = foundAsset.Data;
155 }
156 else
157 {
158 asset.FullID = LLUUID.Zero;
159 }
160 asset.Data = idata;
161 _receiver.AssetReceived(asset, req.IsTexture);
162 }
163
164 }
165
166 private void SetUpAssetDatabase()
167 {
168 try
169 {
170
171 OpenSim.Framework.Console.MainLog.Instance.Verbose( "Setting up asset database");
172
173 AssetBase Image = new AssetBase();
174 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001");
175 Image.Name = "Bricks";
176 this.LoadAsset(Image, true, "bricks.jp2");
177 AssetStorage store = new AssetStorage();
178 store.Data = Image.Data;
179 store.Name = Image.Name;
180 store.UUID = Image.FullID;
181 db.Set(store);
182 db.Commit();
183
184 Image = new AssetBase();
185 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002");
186 Image.Name = "Plywood";
187 this.LoadAsset(Image, true, "plywood.jp2");
188 store = new AssetStorage();
189 store.Data = Image.Data;
190 store.Name = Image.Name;
191 store.UUID = Image.FullID;
192 db.Set(store);
193 db.Commit();
194
195 Image = new AssetBase();
196 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003");
197 Image.Name = "Rocks";
198 this.LoadAsset(Image, true, "rocks.jp2");
199 store = new AssetStorage();
200 store.Data = Image.Data;
201 store.Name = Image.Name;
202 store.UUID = Image.FullID;
203 db.Set(store);
204 db.Commit();
205
206 Image = new AssetBase();
207 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004");
208 Image.Name = "Granite";
209 this.LoadAsset(Image, true, "granite.jp2");
210 store = new AssetStorage();
211 store.Data = Image.Data;
212 store.Name = Image.Name;
213 store.UUID = Image.FullID;
214 db.Set(store);
215 db.Commit();
216
217 Image = new AssetBase();
218 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005");
219 Image.Name = "Hardwood";
220 this.LoadAsset(Image, true, "hardwood.jp2");
221 store = new AssetStorage();
222 store.Data = Image.Data;
223 store.Name = Image.Name;
224 store.UUID = Image.FullID;
225 db.Set(store);
226 db.Commit();
227
228 Image = new AssetBase();
229 Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005");
230 Image.Name = "Prim Base Texture";
231 this.LoadAsset(Image, true, "plywood.jp2");
232 store = new AssetStorage();
233 store.Data = Image.Data;
234 store.Name = Image.Name;
235 store.UUID = Image.FullID;
236 db.Set(store);
237 db.Commit();
238
239 Image = new AssetBase();
240 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006");
241 Image.Name = "Map Base Texture";
242 this.LoadAsset(Image, true, "map_base.jp2");
243 store = new AssetStorage();
244 store.Data = Image.Data;
245 store.Name = Image.Name;
246 store.UUID = Image.FullID;
247 db.Set(store);
248 db.Commit();
249
250 Image = new AssetBase();
251 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007");
252 Image.Name = "Map Texture";
253 this.LoadAsset(Image, true, "map1.jp2");
254 store = new AssetStorage();
255 store.Data = Image.Data;
256 store.Name = Image.Name;
257 store.UUID = Image.FullID;
258 db.Set(store);
259 db.Commit();
260
261 Image = new AssetBase();
262 Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
263 Image.Name = "Shape";
264 this.LoadAsset(Image, false, "base_shape.dat");
265 store = new AssetStorage();
266 store.Data = Image.Data;
267 store.Name = Image.Name;
268 store.UUID = Image.FullID;
269 db.Set(store);
270 db.Commit();
271 }
272 catch (Exception e)
273 {
274 Console.WriteLine(e.Message);
275 }
276
277 }
278
279 private void LoadAsset(AssetBase info, bool image, string filename)
280 {
281 //should request Asset from storage manager
282 //but for now read from file
283
284 string dataPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder;
285 string fileName = Path.Combine(dataPath, filename);
286 FileInfo fInfo = new FileInfo(fileName);
287 long numBytes = fInfo.Length;
288 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
289 byte[] idata = new byte[numBytes];
290 BinaryReader br = new BinaryReader(fStream);
291 idata = br.ReadBytes((int)numBytes);
292 br.Close();
293 fStream.Close();
294 info.Data = idata;
295 //info.loaded=true;
296 }
297 }
298 public class AssetUUIDQuery : Predicate
299 {
300 private LLUUID _findID;
301
302 public AssetUUIDQuery(LLUUID find)
303 {
304 _findID = find;
305 }
306 public bool Match(AssetStorage asset)
307 {
308 return (asset.UUID == _findID);
309 }
310 }
311
312}
diff --git a/OpenSim/Region/GridInterfaces/Local/OpenSim.Region.GridInterfaces.Local.csproj b/OpenSim/Region/GridInterfaces/Local/OpenSim.Region.GridInterfaces.Local.csproj
new file mode 100644
index 0000000..484a205
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Local/OpenSim.Region.GridInterfaces.Local.csproj
@@ -0,0 +1,107 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{241A8CDD-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.GridInterfaces.Local</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.GridInterfaces.Local</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Db4objects.Db4o.dll" >
62 <HintPath>..\..\..\..\bin\Db4objects.Db4o.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="libsecondlife.dll" >
66 <HintPath>..\..\..\..\bin\libsecondlife.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System" >
70 <HintPath>System.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System.Xml" >
74 <HintPath>System.Xml.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 </ItemGroup>
78 <ItemGroup>
79 <ProjectReference Include="..\..\..\Framework\General\OpenSim.Framework.csproj">
80 <Name>OpenSim.Framework</Name>
81 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
82 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
83 <Private>False</Private>
84 </ProjectReference>
85 <ProjectReference Include="..\..\..\Framework\Console\OpenSim.Framework.Console.csproj">
86 <Name>OpenSim.Framework.Console</Name>
87 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
88 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
89 <Private>False</Private>
90 </ProjectReference>
91 </ItemGroup>
92 <ItemGroup>
93 <Compile Include="AssemblyInfo.cs">
94 <SubType>Code</SubType>
95 </Compile>
96 <Compile Include="LocalAssetServer.cs">
97 <SubType>Code</SubType>
98 </Compile>
99 </ItemGroup>
100 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
101 <PropertyGroup>
102 <PreBuildEvent>
103 </PreBuildEvent>
104 <PostBuildEvent>
105 </PostBuildEvent>
106 </PropertyGroup>
107</Project>
diff --git a/OpenSim/Region/GridInterfaces/Local/OpenSim.Region.GridInterfaces.Local.dll.build b/OpenSim/Region/GridInterfaces/Local/OpenSim.Region.GridInterfaces.Local.dll.build
new file mode 100644
index 0000000..4770e6d
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Local/OpenSim.Region.GridInterfaces.Local.dll.build
@@ -0,0 +1,45 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.GridInterfaces.Local" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.GridInterfaces.Local" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="LocalAssetServer.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="../../../../bin/Db4objects.Db4o.dll" />
23 <include name="../../../../bin/libsecondlife.dll" />
24 <include name="../../../../bin/OpenSim.Framework.dll" />
25 <include name="../../../../bin/OpenSim.Framework.Console.dll" />
26 <include name="System.dll" />
27 <include name="System.Xml.dll" />
28 </references>
29 </csc>
30 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/" />
31 <mkdir dir="${project::get-base-directory()}/../../../../bin/"/>
32 <copy todir="${project::get-base-directory()}/../../../../bin/">
33 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
34 <include name="*.dll"/>
35 <include name="*.exe"/>
36 </fileset>
37 </copy>
38 </target>
39 <target name="clean">
40 <delete dir="${bin.dir}" failonerror="false" />
41 <delete dir="${obj.dir}" failonerror="false" />
42 </target>
43 <target name="doc" description="Creates documentation.">
44 </target>
45</project>
diff --git a/OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs b/OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs
new file mode 100644
index 0000000..51596d0
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// Information about this assembly is defined by the following
33// attributes.
34//
35// change them to the information which is associated with the assembly
36// you compile.
37
38[assembly: AssemblyTitle("RemoteGridServers")]
39[assembly: AssemblyDescription("")]
40[assembly: AssemblyConfiguration("")]
41[assembly: AssemblyCompany("")]
42[assembly: AssemblyProduct("RemoteGridServers")]
43[assembly: AssemblyCopyright("")]
44[assembly: AssemblyTrademark("")]
45[assembly: AssemblyCulture("")]
46
47// This sets the default COM visibility of types in the assembly to invisible.
48// If you need to expose a type to COM, use [ComVisible(true)] on that type.
49[assembly: ComVisible(false)]
50
51// The assembly version has following format :
52//
53// Major.Minor.Build.Revision
54//
55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default):
57
58[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/GridInterfaces/Remote/OpenSim.Region.GridInterfaces.Remote.csproj b/OpenSim/Region/GridInterfaces/Remote/OpenSim.Region.GridInterfaces.Remote.csproj
new file mode 100644
index 0000000..793fde2
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Remote/OpenSim.Region.GridInterfaces.Remote.csproj
@@ -0,0 +1,107 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{98C7B681-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.GridInterfaces.Remote</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.GridInterfaces.Remote</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="libsecondlife.dll" >
62 <HintPath>..\..\..\..\bin\libsecondlife.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System" >
66 <HintPath>System.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Xml" >
70 <HintPath>System.Xml.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="XMLRPC.dll" >
74 <HintPath>..\..\..\..\bin\XMLRPC.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 </ItemGroup>
78 <ItemGroup>
79 <ProjectReference Include="..\..\..\Framework\General\OpenSim.Framework.csproj">
80 <Name>OpenSim.Framework</Name>
81 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
82 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
83 <Private>False</Private>
84 </ProjectReference>
85 <ProjectReference Include="..\..\..\Framework\Console\OpenSim.Framework.Console.csproj">
86 <Name>OpenSim.Framework.Console</Name>
87 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
88 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
89 <Private>False</Private>
90 </ProjectReference>
91 </ItemGroup>
92 <ItemGroup>
93 <Compile Include="AssemblyInfo.cs">
94 <SubType>Code</SubType>
95 </Compile>
96 <Compile Include="RemoteAssetServer.cs">
97 <SubType>Code</SubType>
98 </Compile>
99 </ItemGroup>
100 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
101 <PropertyGroup>
102 <PreBuildEvent>
103 </PreBuildEvent>
104 <PostBuildEvent>
105 </PostBuildEvent>
106 </PropertyGroup>
107</Project>
diff --git a/OpenSim/Region/GridInterfaces/Remote/OpenSim.Region.GridInterfaces.Remote.dll.build b/OpenSim/Region/GridInterfaces/Remote/OpenSim.Region.GridInterfaces.Remote.dll.build
new file mode 100644
index 0000000..0bf1b86
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Remote/OpenSim.Region.GridInterfaces.Remote.dll.build
@@ -0,0 +1,45 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.GridInterfaces.Remote" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.GridInterfaces.Remote" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="RemoteAssetServer.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="../../../../bin/libsecondlife.dll" />
23 <include name="../../../../bin/OpenSim.Framework.dll" />
24 <include name="../../../../bin/OpenSim.Framework.Console.dll" />
25 <include name="System.dll" />
26 <include name="System.Xml.dll" />
27 <include name="../../../../bin/XMLRPC.dll" />
28 </references>
29 </csc>
30 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/" />
31 <mkdir dir="${project::get-base-directory()}/../../../../bin/"/>
32 <copy todir="${project::get-base-directory()}/../../../../bin/">
33 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
34 <include name="*.dll"/>
35 <include name="*.exe"/>
36 </fileset>
37 </copy>
38 </target>
39 <target name="clean">
40 <delete dir="${bin.dir}" failonerror="false" />
41 <delete dir="${obj.dir}" failonerror="false" />
42 </target>
43 <target name="doc" description="Creates documentation.">
44 </target>
45</project>
diff --git a/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs b/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs
new file mode 100644
index 0000000..4652f70
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs
@@ -0,0 +1,135 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using System.Threading;
32using System.Net;
33using System.Net.Sockets;
34using System.IO;
35using libsecondlife;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types;
38using OpenSim.Framework.Utilities;
39
40namespace OpenSim.Region.GridInterfaces.Remote
41{
42 public class RemoteAssetServer : IAssetServer
43 {
44 private IAssetReceiver _receiver;
45 private BlockingQueue<ARequest> _assetRequests;
46 private Thread _remoteAssetServerThread;
47 private string AssetServerUrl;
48 private string AssetSendKey;
49
50 public RemoteAssetServer()
51 {
52 this._assetRequests = new BlockingQueue<ARequest>();
53 this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests));
54 this._remoteAssetServerThread.IsBackground = true;
55 this._remoteAssetServerThread.Start();
56 OpenSim.Framework.Console.MainLog.Instance.Verbose("Remote Asset Server class created");
57 }
58
59 public void SetReceiver(IAssetReceiver receiver)
60 {
61 this._receiver = receiver;
62 }
63
64 public void RequestAsset(LLUUID assetID, bool isTexture)
65 {
66 ARequest req = new ARequest();
67 req.AssetID = assetID;
68 req.IsTexture = isTexture;
69 this._assetRequests.Enqueue(req);
70 }
71
72 public void UpdateAsset(AssetBase asset)
73 {
74
75 }
76
77 public void UploadNewAsset(AssetBase asset)
78 {
79 Encoding Windows1252Encoding = Encoding.GetEncoding(1252);
80 string ret = Windows1252Encoding.GetString(asset.Data);
81 byte[] buffer = Windows1252Encoding.GetBytes(ret);
82 WebClient client = new WebClient();
83 client.UploadData(this.AssetServerUrl + "assets/" + asset.FullID, buffer);
84
85 }
86
87 public void SetServerInfo(string ServerUrl, string ServerKey)
88 {
89 this.AssetServerUrl = ServerUrl;
90 this.AssetSendKey = ServerKey;
91 }
92
93 private void RunRequests()
94 {
95 while (true)
96 {
97 //we need to add support for the asset server not knowing about a requested asset
98 // 404... THE MAGIC FILE NOT FOUND ERROR, very useful for telling you things such as a file (or asset ;) ) not being found!!!!!!!!!!! it's 2:22AM
99 ARequest req = this._assetRequests.Dequeue();
100 LLUUID assetID = req.AssetID;
101 // OpenSim.Framework.Console.MainLog.Instance.Verbose(" RemoteAssetServer- Got a AssetServer request, processing it - " + this.AssetServerUrl + "assets/" + assetID);
102 WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "assets/" + assetID);
103 WebResponse AssetResponse = AssetLoad.GetResponse();
104 byte[] idata = new byte[(int)AssetResponse.ContentLength];
105 BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream());
106 idata = br.ReadBytes((int)AssetResponse.ContentLength);
107 br.Close();
108
109 AssetBase asset = new AssetBase();
110 asset.FullID = assetID;
111 asset.Data = idata;
112 _receiver.AssetReceived(asset, req.IsTexture);
113 }
114 }
115
116 public void Close()
117 {
118
119 }
120 }
121
122 public class RemoteAssetPlugin : IAssetPlugin
123 {
124 public RemoteAssetPlugin()
125 {
126
127 }
128
129 public IAssetServer GetAssetServer()
130 {
131 return (new RemoteAssetServer());
132 }
133 }
134
135}
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
new file mode 100644
index 0000000..177c49d
--- /dev/null
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// Information about this assembly is defined by the following
33// attributes.
34//
35// change them to the information which is associated with the assembly
36// you compile.
37
38[assembly: AssemblyTitle("PhysXplugin")]
39[assembly: AssemblyDescription("")]
40[assembly: AssemblyConfiguration("")]
41[assembly: AssemblyCompany("")]
42[assembly: AssemblyProduct("PhysXplugin")]
43[assembly: AssemblyCopyright("")]
44[assembly: AssemblyTrademark("")]
45[assembly: AssemblyCulture("")]
46
47// This sets the default COM visibility of types in the assembly to invisible.
48// If you need to expose a type to COM, use [ComVisible(true)] on that type.
49[assembly: ComVisible(false)]
50
51// The assembly version has following format :
52//
53// Major.Minor.Build.Revision
54//
55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default):
57
58[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
new file mode 100644
index 0000000..dcb8f3b
--- /dev/null
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -0,0 +1,294 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using OpenSim.Physics.Manager;
31
32namespace OpenSim.Region.Physics.BasicPhysicsPlugin
33{
34 /// <summary>
35 /// Will be the PhysX plugin but for now will be a very basic physics engine
36 /// </summary>
37 public class BasicPhysicsPlugin : IPhysicsPlugin
38 {
39 private BasicScene _mScene;
40
41 public BasicPhysicsPlugin()
42 {
43
44 }
45
46 public bool Init()
47 {
48 return true;
49 }
50
51 public PhysicsScene GetScene()
52 {
53 return new BasicScene();
54 }
55
56 public string GetName()
57 {
58 return("basicphysics");
59 }
60
61 public void Dispose()
62 {
63
64 }
65 }
66
67 public class BasicScene :PhysicsScene
68 {
69 private List<BasicActor> _actors = new List<BasicActor>();
70 private float[] _heightMap;
71
72 public BasicScene()
73 {
74
75 }
76
77 public override PhysicsActor AddAvatar(PhysicsVector position)
78 {
79 BasicActor act = new BasicActor();
80 act.Position = position;
81 _actors.Add(act);
82 return act;
83 }
84
85 public override void RemoveAvatar(PhysicsActor actor)
86 {
87 BasicActor act = (BasicActor)actor;
88 if(_actors.Contains(act))
89 {
90 _actors.Remove(act);
91 }
92
93 }
94
95 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
96 {
97 return null;
98 }
99
100 public override void Simulate(float timeStep)
101 {
102 foreach (BasicActor actor in _actors)
103 {
104 actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep);
105 actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep);
106 actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
107 /*if(actor.Flying)
108 {
109 actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
110 }
111 else
112 {
113 actor.Position.Z = actor.Position.Z + ((-9.8f + actor.Velocity.Z) * timeStep);
114 }
115 if(actor.Position.Z < (_heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1))
116 {*/
117 if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256))
118 {
119 actor.Position.Z = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1;
120 }
121 else
122 {
123 if (actor.Position.Y < 0)
124 {
125 actor.Position.Y = 0;
126 }
127 else if (actor.Position.Y > 256)
128 {
129 actor.Position.Y = 256;
130 }
131
132 if (actor.Position.X < 0)
133 {
134 actor.Position.X = 0;
135 }
136 if (actor.Position.X > 256)
137 {
138 actor.Position.X = 256;
139 }
140 }
141 //}
142
143
144
145 // This code needs sorting out - border crossings etc
146/* if(actor.Position.X<0)
147 {
148 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
149 actor.Position.X = 0;
150 actor.Velocity.X = 0;
151 }
152 if(actor.Position.Y < 0)
153 {
154 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
155 actor.Position.Y = 0;
156 actor.Velocity.Y = 0;
157 }
158 if(actor.Position.X > 255)
159 {
160 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
161 actor.Position.X = 255;
162 actor.Velocity.X = 0;
163 }
164 if(actor.Position.Y > 255)
165 {
166 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
167 actor.Position.Y = 255;
168 actor.Velocity.X = 0;
169 }*/
170 }
171 }
172
173 public override void GetResults()
174 {
175
176 }
177
178 public override bool IsThreaded
179 {
180 get
181 {
182 return(false); // for now we won't be multithreaded
183 }
184 }
185
186 public override void SetTerrain(float[] heightMap)
187 {
188 this._heightMap = heightMap;
189 }
190
191 public override void DeleteTerrain()
192 {
193
194 }
195 }
196
197 public class BasicActor : PhysicsActor
198 {
199 private PhysicsVector _position;
200 private PhysicsVector _velocity;
201 private PhysicsVector _acceleration;
202 private bool flying;
203 public BasicActor()
204 {
205 _velocity = new PhysicsVector();
206 _position = new PhysicsVector();
207 _acceleration = new PhysicsVector();
208 }
209
210 public override bool Flying
211 {
212 get
213 {
214 return false;
215 }
216 set
217 {
218 flying= value;
219 }
220 }
221
222 public override PhysicsVector Position
223 {
224 get
225 {
226 return _position;
227 }
228 set
229 {
230 _position = value;
231 }
232 }
233
234 public override PhysicsVector Velocity
235 {
236 get
237 {
238 return _velocity;
239 }
240 set
241 {
242 _velocity = value;
243 }
244 }
245
246 public override Axiom.MathLib.Quaternion Orientation
247 {
248 get
249 {
250 return Axiom.MathLib.Quaternion.Identity;
251 }
252 set
253 {
254
255 }
256 }
257
258 public override PhysicsVector Acceleration
259 {
260 get
261 {
262 return _acceleration;
263 }
264
265 }
266
267 public override bool Kinematic
268 {
269 get
270 {
271 return true;
272 }
273 set
274 {
275
276 }
277 }
278 public void SetAcceleration (PhysicsVector accel)
279 {
280 this._acceleration = accel;
281 }
282
283 public override void AddForce(PhysicsVector force)
284 {
285
286 }
287
288 public override void SetMomentum(PhysicsVector momentum)
289 {
290
291 }
292 }
293
294}
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.csproj b/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.csproj
new file mode 100644
index 0000000..7dad533
--- /dev/null
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.csproj
@@ -0,0 +1,93 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{15B4FEF3-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Physics.BasicPhysicsPlugin</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Physics.BasicPhysicsPlugin</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\Physics\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\Physics\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Axiom.MathLib.dll" >
62 <HintPath>..\..\..\..\bin\Axiom.MathLib.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System" >
66 <HintPath>System.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 </ItemGroup>
70 <ItemGroup>
71 <ProjectReference Include="..\Manager\OpenSim.Region.Physics.Manager.csproj">
72 <Name>OpenSim.Region.Physics.Manager</Name>
73 <Project>{F4FF31EB-0000-0000-0000-000000000000}</Project>
74 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
75 <Private>False</Private>
76 </ProjectReference>
77 </ItemGroup>
78 <ItemGroup>
79 <Compile Include="AssemblyInfo.cs">
80 <SubType>Code</SubType>
81 </Compile>
82 <Compile Include="BasicPhysicsPlugin.cs">
83 <SubType>Code</SubType>
84 </Compile>
85 </ItemGroup>
86 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
87 <PropertyGroup>
88 <PreBuildEvent>
89 </PreBuildEvent>
90 <PostBuildEvent>
91 </PostBuildEvent>
92 </PropertyGroup>
93</Project>
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.dll.build b/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.dll.build
new file mode 100644
index 0000000..6cf26ca
--- /dev/null
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/OpenSim.Region.Physics.BasicPhysicsPlugin.dll.build
@@ -0,0 +1,42 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Physics.BasicPhysicsPlugin" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Physics.BasicPhysicsPlugin" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="BasicPhysicsPlugin.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="../../../../bin/Axiom.MathLib.dll" />
23 <include name="../../../../bin/OpenSim.Region.Physics.Manager.dll" />
24 <include name="System.dll" />
25 </references>
26 </csc>
27 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/Physics/" />
28 <mkdir dir="${project::get-base-directory()}/../../../../bin/Physics/"/>
29 <copy todir="${project::get-base-directory()}/../../../../bin/Physics/">
30 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
31 <include name="*.dll"/>
32 <include name="*.exe"/>
33 </fileset>
34 </copy>
35 </target>
36 <target name="clean">
37 <delete dir="${bin.dir}" failonerror="false" />
38 <delete dir="${obj.dir}" failonerror="false" />
39 </target>
40 <target name="doc" description="Creates documentation.">
41 </target>
42</project>
diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
new file mode 100644
index 0000000..132f64a
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// Information about this assembly is defined by the following
33// attributes.
34//
35// change them to the information which is associated with the assembly
36// you compile.
37
38[assembly: AssemblyTitle("PhysicsManager")]
39[assembly: AssemblyDescription("")]
40[assembly: AssemblyConfiguration("")]
41[assembly: AssemblyCompany("")]
42[assembly: AssemblyProduct("PhysicsManager")]
43[assembly: AssemblyCopyright("")]
44[assembly: AssemblyTrademark("")]
45[assembly: AssemblyCulture("")]
46
47// This sets the default COM visibility of types in the assembly to invisible.
48// If you need to expose a type to COM, use [ComVisible(true)] on that type.
49[assembly: ComVisible(false)]
50
51// The assembly version has following format :
52//
53// Major.Minor.Build.Revision
54//
55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default):
57
58[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.csproj b/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.csproj
new file mode 100644
index 0000000..f340400
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.csproj
@@ -0,0 +1,112 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{F4FF31EB-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Physics.Manager</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Physics.Manager</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Axiom.MathLib.dll" >
62 <HintPath>..\..\..\..\bin\Axiom.MathLib.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System" >
66 <HintPath>System.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Xml" >
70 <HintPath>System.Xml.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 </ItemGroup>
74 <ItemGroup>
75 <ProjectReference Include="..\..\..\Framework\General\OpenSim.Framework.csproj">
76 <Name>OpenSim.Framework</Name>
77 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
78 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
79 <Private>False</Private>
80 </ProjectReference>
81 <ProjectReference Include="..\..\..\Framework\Console\OpenSim.Framework.Console.csproj">
82 <Name>OpenSim.Framework.Console</Name>
83 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
84 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
85 <Private>False</Private>
86 </ProjectReference>
87 </ItemGroup>
88 <ItemGroup>
89 <Compile Include="AssemblyInfo.cs">
90 <SubType>Code</SubType>
91 </Compile>
92 <Compile Include="PhysicsActor.cs">
93 <SubType>Code</SubType>
94 </Compile>
95 <Compile Include="PhysicsManager.cs">
96 <SubType>Code</SubType>
97 </Compile>
98 <Compile Include="PhysicsScene.cs">
99 <SubType>Code</SubType>
100 </Compile>
101 <Compile Include="PhysicsVector.cs">
102 <SubType>Code</SubType>
103 </Compile>
104 </ItemGroup>
105 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
106 <PropertyGroup>
107 <PreBuildEvent>
108 </PreBuildEvent>
109 <PostBuildEvent>
110 </PostBuildEvent>
111 </PropertyGroup>
112</Project>
diff --git a/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.dll.build b/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.dll.build
new file mode 100644
index 0000000..4b7ce81
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/OpenSim.Region.Physics.Manager.dll.build
@@ -0,0 +1,47 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Physics.Manager" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Physics.Manager" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="PhysicsActor.cs" />
16 <include name="PhysicsManager.cs" />
17 <include name="PhysicsScene.cs" />
18 <include name="PhysicsVector.cs" />
19 </sources>
20 <references basedir="${project::get-base-directory()}">
21 <lib>
22 <include name="${project::get-base-directory()}" />
23 <include name="${project::get-base-directory()}/${build.dir}" />
24 </lib>
25 <include name="../../../../bin/Axiom.MathLib.dll" />
26 <include name="../../../../bin/OpenSim.Framework.dll" />
27 <include name="../../../../bin/OpenSim.Framework.Console.dll" />
28 <include name="System.dll" />
29 <include name="System.Xml.dll" />
30 </references>
31 </csc>
32 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/" />
33 <mkdir dir="${project::get-base-directory()}/../../../../bin/"/>
34 <copy todir="${project::get-base-directory()}/../../../../bin/">
35 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
36 <include name="*.dll"/>
37 <include name="*.exe"/>
38 </fileset>
39 </copy>
40 </target>
41 <target name="clean">
42 <delete dir="${bin.dir}" failonerror="false" />
43 <delete dir="${obj.dir}" failonerror="false" />
44 </target>
45 <target name="doc" description="Creates documentation.">
46 </target>
47</project>
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
new file mode 100644
index 0000000..6366fb8
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -0,0 +1,161 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Physics.Manager
33{
34 public abstract class PhysicsActor
35 {
36 public static PhysicsActor Null
37 {
38 get
39 {
40 return new NullPhysicsActor();
41 }
42 }
43
44 public abstract PhysicsVector Position
45 {
46 get;
47 set;
48 }
49
50 public abstract PhysicsVector Velocity
51 {
52 get;
53 set;
54 }
55
56 public abstract PhysicsVector Acceleration
57 {
58 get;
59 }
60
61 public abstract Axiom.MathLib.Quaternion Orientation
62 {
63 get;
64 set;
65 }
66
67 public abstract bool Flying
68 {
69 get;
70 set;
71 }
72
73 public abstract bool Kinematic
74 {
75 get;
76 set;
77 }
78
79 public abstract void AddForce(PhysicsVector force);
80
81 public abstract void SetMomentum(PhysicsVector momentum);
82 }
83
84 public class NullPhysicsActor : PhysicsActor
85 {
86 public override PhysicsVector Position
87 {
88 get
89 {
90 return PhysicsVector.Zero;
91 }
92 set
93 {
94 return;
95 }
96 }
97
98 public override PhysicsVector Velocity
99 {
100 get
101 {
102 return PhysicsVector.Zero;
103 }
104 set
105 {
106 return;
107 }
108 }
109
110 public override Axiom.MathLib.Quaternion Orientation
111 {
112 get
113 {
114 return Axiom.MathLib.Quaternion.Identity;
115 }
116 set
117 {
118
119 }
120 }
121
122 public override PhysicsVector Acceleration
123 {
124 get { return PhysicsVector.Zero; }
125 }
126
127 public override bool Flying
128 {
129 get
130 {
131 return false;
132 }
133 set
134 {
135 return;
136 }
137 }
138
139 public override bool Kinematic
140 {
141 get
142 {
143 return true;
144 }
145 set
146 {
147 return;
148 }
149 }
150
151 public override void AddForce(PhysicsVector force)
152 {
153 return;
154 }
155
156 public override void SetMomentum(PhysicsVector momentum)
157 {
158 return;
159 }
160 }
161}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsManager.cs b/OpenSim/Region/Physics/Manager/PhysicsManager.cs
new file mode 100644
index 0000000..efccb36
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/PhysicsManager.cs
@@ -0,0 +1,117 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Collections;
31using System.IO;
32using System.Reflection;
33using Axiom.MathLib;
34using OpenSim.Framework.Console;
35
36namespace OpenSim.Physics.Manager
37{
38 /// <summary>
39 /// Description of MyClass.
40 /// </summary>
41 public class PhysicsManager
42 {
43 private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>();
44
45 public PhysicsManager()
46 {
47
48 }
49
50 public PhysicsScene GetPhysicsScene(string engineName)
51 {
52 if (String.IsNullOrEmpty(engineName))
53 {
54 return new NullPhysicsScene();
55 }
56
57 if(_plugins.ContainsKey(engineName))
58 {
59 OpenSim.Framework.Console.MainLog.Instance.WriteLine(LogPriority.LOW,"creating "+engineName);
60 return _plugins[engineName].GetScene();
61 }
62 else
63 {
64 OpenSim.Framework.Console.MainLog.Instance.WriteLine(LogPriority.MEDIUM,"couldn't find physicsEngine: {0}",engineName);
65 throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName));
66 }
67 }
68
69 public void LoadPlugins()
70 {
71 string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics");
72 string[] pluginFiles = Directory.GetFiles(path, "*.dll");
73
74
75 for(int i= 0; i<pluginFiles.Length; i++)
76 {
77 this.AddPlugin(pluginFiles[i]);
78 }
79 }
80
81 private void AddPlugin(string FileName)
82 {
83 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
84
85 foreach (Type pluginType in pluginAssembly.GetTypes())
86 {
87 if (pluginType.IsPublic)
88 {
89 if (!pluginType.IsAbstract)
90 {
91 Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true);
92
93 if (typeInterface != null)
94 {
95 IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
96 plug.Init();
97 this._plugins.Add(plug.GetName(),plug);
98
99 }
100
101 typeInterface = null;
102 }
103 }
104 }
105
106 pluginAssembly = null;
107 }
108 }
109
110 public interface IPhysicsPlugin
111 {
112 bool Init();
113 PhysicsScene GetScene();
114 string GetName();
115 void Dispose();
116 }
117}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
new file mode 100644
index 0000000..0901c2f
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -0,0 +1,113 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Framework.Console;
32
33namespace OpenSim.Physics.Manager
34{
35 public abstract class PhysicsScene
36 {
37 public static PhysicsScene Null
38 {
39 get
40 {
41 return new NullPhysicsScene();
42 }
43 }
44
45 public abstract PhysicsActor AddAvatar(PhysicsVector position);
46
47 public abstract void RemoveAvatar(PhysicsActor actor);
48
49 public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size);
50
51 public abstract void Simulate(float timeStep);
52
53 public abstract void GetResults();
54
55 public abstract void SetTerrain(float[] heightMap);
56
57 public abstract void DeleteTerrain();
58
59 public abstract bool IsThreaded
60 {
61 get;
62 }
63 }
64
65 public class NullPhysicsScene : PhysicsScene
66 {
67 private static int m_workIndicator;
68
69 public override PhysicsActor AddAvatar(PhysicsVector position)
70 {
71 OpenSim.Framework.Console.MainLog.Instance.Verbose("NullPhysicsScene : AddAvatar({0})", position);
72 return PhysicsActor.Null;
73 }
74
75 public override void RemoveAvatar(PhysicsActor actor)
76 {
77
78 }
79
80 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
81 {
82 OpenSim.Framework.Console.MainLog.Instance.Verbose( "NullPhysicsScene : AddPrim({0},{1})", position, size);
83 return PhysicsActor.Null;
84 }
85
86 public override void Simulate(float timeStep)
87 {
88 m_workIndicator = (m_workIndicator + 1) % 10;
89
90 //OpenSim.Framework.Console.MainLog.Instance.SetStatus(m_workIndicator.ToString());
91 }
92
93 public override void GetResults()
94 {
95 OpenSim.Framework.Console.MainLog.Instance.Verbose( "NullPhysicsScene : GetResults()");
96 }
97
98 public override void SetTerrain(float[] heightMap)
99 {
100 OpenSim.Framework.Console.MainLog.Instance.Verbose( "NullPhysicsScene : SetTerrain({0} items)", heightMap.Length);
101 }
102
103 public override void DeleteTerrain()
104 {
105
106 }
107
108 public override bool IsThreaded
109 {
110 get { return false; }
111 }
112 }
113}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
new file mode 100644
index 0000000..888dbb5
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
@@ -0,0 +1,54 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Physics.Manager
33{
34 public class PhysicsVector
35 {
36 public float X;
37 public float Y;
38 public float Z;
39
40 public PhysicsVector()
41 {
42
43 }
44
45 public PhysicsVector(float x, float y, float z)
46 {
47 X = x;
48 Y = y;
49 Z = z;
50 }
51
52 public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
53 }
54}
diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
new file mode 100644
index 0000000..b49c8da
--- /dev/null
+++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// Information about this assembly is defined by the following
33// attributes.
34//
35// change them to the information which is associated with the assembly
36// you compile.
37
38[assembly: AssemblyTitle("RealPhysXplugin")]
39[assembly: AssemblyDescription("")]
40[assembly: AssemblyConfiguration("")]
41[assembly: AssemblyCompany("")]
42[assembly: AssemblyProduct("RealPhysXplugin")]
43[assembly: AssemblyCopyright("")]
44[assembly: AssemblyTrademark("")]
45[assembly: AssemblyCulture("")]
46
47// This sets the default COM visibility of types in the assembly to invisible.
48// If you need to expose a type to COM, use [ComVisible(true)] on that type.
49[assembly: ComVisible(false)]
50
51// The assembly version has following format :
52//
53// Major.Minor.Build.Revision
54//
55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default):
57
58[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
new file mode 100644
index 0000000..8aca851
--- /dev/null
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -0,0 +1,456 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using OpenSim.Physics.Manager;
31using Ode.NET;
32
33namespace OpenSim.Region.Physics.OdePlugin
34{
35 /// <summary>
36 /// ODE plugin
37 /// </summary>
38 public class OdePlugin : IPhysicsPlugin
39 {
40 private OdeScene _mScene;
41
42 public OdePlugin()
43 {
44
45 }
46
47 public bool Init()
48 {
49 return true;
50 }
51
52 public PhysicsScene GetScene()
53 {
54 if (_mScene == null)
55 {
56 _mScene = new OdeScene();
57 }
58 return (_mScene);
59 }
60
61 public string GetName()
62 {
63 return ("OpenDynamicsEngine");
64 }
65
66 public void Dispose()
67 {
68
69 }
70 }
71
72 public class OdeScene : PhysicsScene
73 {
74 static public IntPtr world;
75 static public IntPtr space;
76 static private IntPtr contactgroup;
77 static private IntPtr LandGeom;
78 //static private IntPtr Land;
79 private double[] _heightmap;
80 static private d.NearCallback nearCallback = near;
81 private List<OdeCharacter> _characters = new List<OdeCharacter>();
82 private static d.ContactGeom[] contacts = new d.ContactGeom[30];
83 private static d.Contact contact;
84
85 public OdeScene()
86 {
87 contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM;
88 contact.surface.mu = d.Infinity;
89 contact.surface.mu2 = 0.0f;
90 contact.surface.bounce = 0.1f;
91 contact.surface.bounce_vel = 0.1f;
92 contact.surface.soft_cfm = 0.01f;
93
94 world = d.WorldCreate();
95 space = d.HashSpaceCreate(IntPtr.Zero);
96 contactgroup = d.JointGroupCreate(0);
97 d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f);
98 //d.WorldSetCFM(world, 1e-5f);
99 d.WorldSetAutoDisableFlag(world, false);
100 d.WorldSetContactSurfaceLayer(world, 0.001f);
101 // d.CreatePlane(space, 0, 0, 1, 0);
102 this._heightmap = new double[65536];
103 }
104
105 // This function blatantly ripped off from BoxStack.cs
106 static private void near(IntPtr space, IntPtr g1, IntPtr g2)
107 {
108 IntPtr b1 = d.GeomGetBody(g1);
109 IntPtr b2 = d.GeomGetBody(g2);
110 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
111 return;
112
113 int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf);
114 for (int i = 0; i < count; ++i)
115 {
116 contact.geom = contacts[i];
117 IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact);
118 d.JointAttach(joint, b1, b2);
119 }
120
121 }
122
123 public override PhysicsActor AddAvatar(PhysicsVector position)
124 {
125 PhysicsVector pos = new PhysicsVector();
126 pos.X = position.X;
127 pos.Y = position.Y;
128 pos.Z = position.Z + 20;
129 OdeCharacter newAv = new OdeCharacter(this, pos);
130 this._characters.Add(newAv);
131 return newAv;
132 }
133
134 public override void RemoveAvatar(PhysicsActor actor)
135 {
136
137 }
138
139 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
140 {
141 PhysicsVector pos = new PhysicsVector();
142 pos.X = position.X;
143 pos.Y = position.Y;
144 pos.Z = position.Z;
145 PhysicsVector siz = new PhysicsVector();
146 siz.X = size.X;
147 siz.Y = size.Y;
148 siz.Z = size.Z;
149 return new OdePrim();
150 }
151
152 public override void Simulate(float timeStep)
153 {
154 foreach (OdeCharacter actor in _characters)
155 {
156 actor.Move(timeStep * 5f);
157 }
158 d.SpaceCollide(space, IntPtr.Zero, nearCallback);
159 d.WorldQuickStep(world, timeStep * 5f);
160 d.JointGroupEmpty(contactgroup);
161 foreach (OdeCharacter actor in _characters)
162 {
163 actor.UpdatePosition();
164 }
165
166 }
167
168 public override void GetResults()
169 {
170
171 }
172
173 public override bool IsThreaded
174 {
175 get
176 {
177 return (false); // for now we won't be multithreaded
178 }
179 }
180
181 public override void SetTerrain(float[] heightMap)
182 {
183 for (int i = 0; i < 65536; i++)
184 {
185 // this._heightmap[i] = (double)heightMap[i];
186 // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...)
187 int x = i & 0xff;
188 int y = i >> 8;
189 this._heightmap[i] = (double)heightMap[x * 256 + y];
190 }
191 IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
192 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
193 d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
194 LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
195 d.Matrix3 R = new d.Matrix3();
196
197 Axiom.MathLib.Quaternion q1 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(1,0,0));
198 Axiom.MathLib.Quaternion q2 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(0,1,0));
199 //Axiom.MathLib.Quaternion q3 = Axiom.MathLib.Quaternion.FromAngleAxis(3.14f, new Axiom.MathLib.Vector3(0, 0, 1));
200
201 q1 = q1 * q2;
202 //q1 = q1 * q3;
203 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3();
204 float angle = 0;
205 q1.ToAngleAxis(ref angle, ref v3);
206
207 d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle);
208 d.GeomSetRotation(LandGeom, ref R);
209 d.GeomSetPosition(LandGeom, 128, 128, 0);
210 }
211
212 public override void DeleteTerrain()
213 {
214
215 }
216 }
217
218 public class OdeCharacter : PhysicsActor
219 {
220 private PhysicsVector _position;
221 private PhysicsVector _velocity;
222 private PhysicsVector _acceleration;
223 private bool flying;
224 //private float gravityAccel;
225 private IntPtr BoundingCapsule;
226 IntPtr capsule_geom;
227 d.Mass capsule_mass;
228
229 public OdeCharacter(OdeScene parent_scene, PhysicsVector pos)
230 {
231 _velocity = new PhysicsVector();
232 _position = pos;
233 _acceleration = new PhysicsVector();
234 d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f);
235 capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f);
236 this.BoundingCapsule = d.BodyCreate(OdeScene.world);
237 d.BodySetMass(BoundingCapsule, ref capsule_mass);
238 d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z);
239 d.GeomSetBody(capsule_geom, BoundingCapsule);
240 }
241
242 public override bool Flying
243 {
244 get
245 {
246 return flying;
247 }
248 set
249 {
250 flying = value;
251 }
252 }
253
254 public override PhysicsVector Position
255 {
256 get
257 {
258 return _position;
259 }
260 set
261 {
262 _position = value;
263 }
264 }
265
266 public override PhysicsVector Velocity
267 {
268 get
269 {
270 return _velocity;
271 }
272 set
273 {
274 _velocity = value;
275 }
276 }
277
278 public override bool Kinematic
279 {
280 get
281 {
282 return false;
283 }
284 set
285 {
286
287 }
288 }
289
290 public override Axiom.MathLib.Quaternion Orientation
291 {
292 get
293 {
294 return Axiom.MathLib.Quaternion.Identity;
295 }
296 set
297 {
298
299 }
300 }
301
302 public override PhysicsVector Acceleration
303 {
304 get
305 {
306 return _acceleration;
307 }
308
309 }
310 public void SetAcceleration(PhysicsVector accel)
311 {
312 this._acceleration = accel;
313 }
314
315 public override void AddForce(PhysicsVector force)
316 {
317
318 }
319
320 public override void SetMomentum(PhysicsVector momentum)
321 {
322
323 }
324
325 public void Move(float timeStep)
326 {
327 PhysicsVector vec = new PhysicsVector();
328 vec.X = this._velocity.X * timeStep;
329 vec.Y = this._velocity.Y * timeStep;
330 if (flying)
331 {
332 vec.Z = (this._velocity.Z + 0.5f) * timeStep;
333 }
334 d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z);
335 }
336
337 public void UpdatePosition()
338 {
339 d.Vector3 vec = d.BodyGetPosition(BoundingCapsule);
340 this._position.X = vec.X;
341 this._position.Y = vec.Y;
342 this._position.Z = vec.Z+1.0f;
343 }
344 }
345
346 public class OdePrim : PhysicsActor
347 {
348 private PhysicsVector _position;
349 private PhysicsVector _velocity;
350 private PhysicsVector _acceleration;
351
352 public OdePrim()
353 {
354 _velocity = new PhysicsVector();
355 _position = new PhysicsVector();
356 _acceleration = new PhysicsVector();
357 }
358 public override bool Flying
359 {
360 get
361 {
362 return false; //no flying prims for you
363 }
364 set
365 {
366
367 }
368 }
369 public override PhysicsVector Position
370 {
371 get
372 {
373 PhysicsVector pos = new PhysicsVector();
374 // PhysicsVector vec = this._prim.Position;
375 //pos.X = vec.X;
376 //pos.Y = vec.Y;
377 //pos.Z = vec.Z;
378 return pos;
379
380 }
381 set
382 {
383 /*PhysicsVector vec = value;
384 PhysicsVector pos = new PhysicsVector();
385 pos.X = vec.X;
386 pos.Y = vec.Y;
387 pos.Z = vec.Z;
388 this._prim.Position = pos;*/
389 }
390 }
391
392 public override PhysicsVector Velocity
393 {
394 get
395 {
396 return _velocity;
397 }
398 set
399 {
400 _velocity = value;
401 }
402 }
403
404 public override bool Kinematic
405 {
406 get
407 {
408 return false;
409 //return this._prim.Kinematic;
410 }
411 set
412 {
413 //this._prim.Kinematic = value;
414 }
415 }
416
417 public override Axiom.MathLib.Quaternion Orientation
418 {
419 get
420 {
421 Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion();
422 return res;
423 }
424 set
425 {
426
427 }
428 }
429
430 public override PhysicsVector Acceleration
431 {
432 get
433 {
434 return _acceleration;
435 }
436
437 }
438 public void SetAcceleration(PhysicsVector accel)
439 {
440 this._acceleration = accel;
441 }
442
443 public override void AddForce(PhysicsVector force)
444 {
445
446 }
447
448 public override void SetMomentum(PhysicsVector momentum)
449 {
450
451 }
452
453
454 }
455
456}
diff --git a/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.csproj b/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.csproj
new file mode 100644
index 0000000..490c681
--- /dev/null
+++ b/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.csproj
@@ -0,0 +1,97 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{90620634-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Physics.OdePlugin</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Physics.OdePlugin</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\Physics\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\Physics\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Axiom.MathLib.dll" >
62 <HintPath>..\..\..\..\bin\Axiom.MathLib.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="Ode.NET.dll" >
66 <HintPath>..\..\..\..\bin\Ode.NET.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System" >
70 <HintPath>System.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 </ItemGroup>
74 <ItemGroup>
75 <ProjectReference Include="..\Manager\OpenSim.Region.Physics.Manager.csproj">
76 <Name>OpenSim.Region.Physics.Manager</Name>
77 <Project>{F4FF31EB-0000-0000-0000-000000000000}</Project>
78 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
79 <Private>False</Private>
80 </ProjectReference>
81 </ItemGroup>
82 <ItemGroup>
83 <Compile Include="AssemblyInfo.cs">
84 <SubType>Code</SubType>
85 </Compile>
86 <Compile Include="OdePlugin.cs">
87 <SubType>Code</SubType>
88 </Compile>
89 </ItemGroup>
90 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
91 <PropertyGroup>
92 <PreBuildEvent>
93 </PreBuildEvent>
94 <PostBuildEvent>
95 </PostBuildEvent>
96 </PropertyGroup>
97</Project>
diff --git a/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.dll.build b/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.dll.build
new file mode 100644
index 0000000..07b9386
--- /dev/null
+++ b/OpenSim/Region/Physics/OdePlugin/OpenSim.Region.Physics.OdePlugin.dll.build
@@ -0,0 +1,43 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Physics.OdePlugin" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Physics.OdePlugin" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="OdePlugin.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="../../../../bin/Axiom.MathLib.dll" />
23 <include name="../../../../bin/Ode.NET.dll" />
24 <include name="../../../../bin/OpenSim.Region.Physics.Manager.dll" />
25 <include name="System.dll" />
26 </references>
27 </csc>
28 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/Physics/" />
29 <mkdir dir="${project::get-base-directory()}/../../../../bin/Physics/"/>
30 <copy todir="${project::get-base-directory()}/../../../../bin/Physics/">
31 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
32 <include name="*.dll"/>
33 <include name="*.exe"/>
34 </fileset>
35 </copy>
36 </target>
37 <target name="clean">
38 <delete dir="${bin.dir}" failonerror="false" />
39 <delete dir="${obj.dir}" failonerror="false" />
40 </target>
41 <target name="doc" description="Creates documentation.">
42 </target>
43</project>
diff --git a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
new file mode 100644
index 0000000..b49c8da
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// Information about this assembly is defined by the following
33// attributes.
34//
35// change them to the information which is associated with the assembly
36// you compile.
37
38[assembly: AssemblyTitle("RealPhysXplugin")]
39[assembly: AssemblyDescription("")]
40[assembly: AssemblyConfiguration("")]
41[assembly: AssemblyCompany("")]
42[assembly: AssemblyProduct("RealPhysXplugin")]
43[assembly: AssemblyCopyright("")]
44[assembly: AssemblyTrademark("")]
45[assembly: AssemblyCulture("")]
46
47// This sets the default COM visibility of types in the assembly to invisible.
48// If you need to expose a type to COM, use [ComVisible(true)] on that type.
49[assembly: ComVisible(false)]
50
51// The assembly version has following format :
52//
53// Major.Minor.Build.Revision
54//
55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default):
57
58[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.csproj b/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.csproj
new file mode 100644
index 0000000..77da908
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.csproj
@@ -0,0 +1,97 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{A6D191D8-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Physics.PhysXPlugin</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Physics.PhysXPlugin</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\Physics\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\Physics\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Axiom.MathLib.dll" >
62 <HintPath>..\..\..\..\bin\Axiom.MathLib.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="PhysX_Wrapper_Dotnet.dll" >
66 <HintPath>..\..\..\..\bin\PhysX_Wrapper_Dotnet.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System" >
70 <HintPath>System.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 </ItemGroup>
74 <ItemGroup>
75 <ProjectReference Include="..\Manager\OpenSim.Region.Physics.Manager.csproj">
76 <Name>OpenSim.Region.Physics.Manager</Name>
77 <Project>{F4FF31EB-0000-0000-0000-000000000000}</Project>
78 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
79 <Private>False</Private>
80 </ProjectReference>
81 </ItemGroup>
82 <ItemGroup>
83 <Compile Include="AssemblyInfo.cs">
84 <SubType>Code</SubType>
85 </Compile>
86 <Compile Include="PhysXPlugin.cs">
87 <SubType>Code</SubType>
88 </Compile>
89 </ItemGroup>
90 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
91 <PropertyGroup>
92 <PreBuildEvent>
93 </PreBuildEvent>
94 <PostBuildEvent>
95 </PostBuildEvent>
96 </PropertyGroup>
97</Project>
diff --git a/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.dll.build b/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.dll.build
new file mode 100644
index 0000000..c1a9608
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/OpenSim.Region.Physics.PhysXPlugin.dll.build
@@ -0,0 +1,43 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Physics.PhysXPlugin" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Physics.PhysXPlugin" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="PhysXPlugin.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="../../../../bin/Axiom.MathLib.dll" />
23 <include name="../../../../bin/OpenSim.Region.Physics.Manager.dll" />
24 <include name="../../../../bin/PhysX_Wrapper_Dotnet.dll" />
25 <include name="System.dll" />
26 </references>
27 </csc>
28 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/Physics/" />
29 <mkdir dir="${project::get-base-directory()}/../../../../bin/Physics/"/>
30 <copy todir="${project::get-base-directory()}/../../../../bin/Physics/">
31 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
32 <include name="*.dll"/>
33 <include name="*.exe"/>
34 </fileset>
35 </copy>
36 </target>
37 <target name="clean">
38 <delete dir="${bin.dir}" failonerror="false" />
39 <delete dir="${obj.dir}" failonerror="false" />
40 </target>
41 <target name="doc" description="Creates documentation.">
42 </target>
43</project>
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
new file mode 100644
index 0000000..8bf794b
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -0,0 +1,424 @@
1/*/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using OpenSim.Physics.Manager;
31using PhysXWrapper;
32
33namespace OpenSim.Region.Physics.PhysXPlugin
34{
35 /// <summary>
36 /// Will be the PhysX plugin but for now will be a very basic physics engine
37 /// </summary>
38 public class PhysXPlugin : IPhysicsPlugin
39 {
40 private PhysXScene _mScene;
41
42 public PhysXPlugin()
43 {
44
45 }
46
47 public bool Init()
48 {
49 return true;
50 }
51
52 public PhysicsScene GetScene()
53 {
54 if(_mScene == null)
55 {
56 _mScene = new PhysXScene();
57 }
58 return(_mScene);
59 }
60
61 public string GetName()
62 {
63 return("RealPhysX");
64 }
65
66 public void Dispose()
67 {
68
69 }
70 }
71
72 public class PhysXScene :PhysicsScene
73 {
74 private List<PhysXCharacter> _characters = new List<PhysXCharacter>();
75 private List<PhysXPrim> _prims = new List<PhysXPrim>();
76 private float[] _heightMap = null;
77 private NxPhysicsSDK mySdk;
78 private NxScene scene;
79
80 public PhysXScene()
81 {
82 mySdk = NxPhysicsSDK.CreateSDK();
83 Console.WriteLine("Sdk created - now creating scene");
84 scene = mySdk.CreateScene();
85
86 }
87
88 public override PhysicsActor AddAvatar(PhysicsVector position)
89 {
90 Vec3 pos = new Vec3();
91 pos.X = position.X;
92 pos.Y = position.Y;
93 pos.Z = position.Z;
94 PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos));
95 act.Position = position;
96 _characters.Add(act);
97 return act;
98 }
99
100 public override void RemoveAvatar(PhysicsActor actor)
101 {
102
103 }
104
105 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
106 {
107 Vec3 pos = new Vec3();
108 pos.X = position.X;
109 pos.Y = position.Y;
110 pos.Z = position.Z;
111 Vec3 siz = new Vec3();
112 siz.X = size.X;
113 siz.Y = size.Y;
114 siz.Z = size.Z;
115 PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz));
116 _prims.Add(act);
117 return act;
118 }
119 public override void Simulate(float timeStep)
120 {
121 try
122 {
123 foreach (PhysXCharacter actor in _characters)
124 {
125 actor.Move(timeStep);
126 }
127 scene.Simulate(timeStep);
128 scene.FetchResults();
129 scene.UpdateControllers();
130
131 foreach (PhysXCharacter actor in _characters)
132 {
133 actor.UpdatePosition();
134 }
135 }
136 catch (Exception e)
137 {
138 Console.WriteLine(e.Message);
139 }
140
141 }
142
143 public override void GetResults()
144 {
145
146 }
147
148 public override bool IsThreaded
149 {
150 get
151 {
152 return(false); // for now we won't be multithreaded
153 }
154 }
155
156 public override void SetTerrain(float[] heightMap)
157 {
158 if (this._heightMap != null)
159 {
160 Console.WriteLine("PhysX - deleting old terrain");
161 this.scene.DeleteTerrain();
162 }
163 this._heightMap = heightMap;
164 this.scene.AddTerrain(heightMap);
165 }
166
167 public override void DeleteTerrain()
168 {
169 this.scene.DeleteTerrain();
170 }
171 }
172
173 public class PhysXCharacter : PhysicsActor
174 {
175 private PhysicsVector _position;
176 private PhysicsVector _velocity;
177 private PhysicsVector _acceleration;
178 private NxCharacter _character;
179 private bool flying;
180 private float gravityAccel;
181
182 public PhysXCharacter(NxCharacter character)
183 {
184 _velocity = new PhysicsVector();
185 _position = new PhysicsVector();
186 _acceleration = new PhysicsVector();
187 _character = character;
188 }
189
190 public override bool Flying
191 {
192 get
193 {
194 return flying;
195 }
196 set
197 {
198 flying = value;
199 }
200 }
201
202 public override PhysicsVector Position
203 {
204 get
205 {
206 return _position;
207 }
208 set
209 {
210 _position = value;
211 Vec3 ps = new Vec3();
212 ps.X = value.X;
213 ps.Y = value.Y;
214 ps.Z = value.Z;
215 this._character.Position = ps;
216 }
217 }
218
219 public override PhysicsVector Velocity
220 {
221 get
222 {
223 return _velocity;
224 }
225 set
226 {
227 _velocity = value;
228 }
229 }
230
231 public override bool Kinematic
232 {
233 get
234 {
235 return false;
236 }
237 set
238 {
239
240 }
241 }
242
243 public override Axiom.MathLib.Quaternion Orientation
244 {
245 get
246 {
247 return Axiom.MathLib.Quaternion.Identity;
248 }
249 set
250 {
251
252 }
253 }
254
255 public override PhysicsVector Acceleration
256 {
257 get
258 {
259 return _acceleration;
260 }
261
262 }
263 public void SetAcceleration (PhysicsVector accel)
264 {
265 this._acceleration = accel;
266 }
267
268 public override void AddForce(PhysicsVector force)
269 {
270
271 }
272
273 public override void SetMomentum(PhysicsVector momentum)
274 {
275
276 }
277
278 public void Move(float timeStep)
279 {
280 Vec3 vec = new Vec3();
281 vec.X = this._velocity.X * timeStep;
282 vec.Y = this._velocity.Y * timeStep;
283 if(flying)
284 {
285 vec.Z = ( this._velocity.Z) * timeStep;
286 }
287 else
288 {
289 gravityAccel+= -9.8f;
290 vec.Z = (gravityAccel + this._velocity.Z) * timeStep;
291 }
292 int res = this._character.Move(vec);
293 if(res == 1)
294 {
295 gravityAccel = 0;
296 }
297 }
298
299 public void UpdatePosition()
300 {
301 Vec3 vec = this._character.Position;
302 this._position.X = vec.X;
303 this._position.Y = vec.Y;
304 this._position.Z = vec.Z;
305 }
306 }
307
308 public class PhysXPrim : PhysicsActor
309 {
310 private PhysicsVector _position;
311 private PhysicsVector _velocity;
312 private PhysicsVector _acceleration;
313 private NxActor _prim;
314
315 public PhysXPrim(NxActor prim)
316 {
317 _velocity = new PhysicsVector();
318 _position = new PhysicsVector();
319 _acceleration = new PhysicsVector();
320 _prim = prim;
321 }
322 public override bool Flying
323 {
324 get
325 {
326 return false; //no flying prims for you
327 }
328 set
329 {
330
331 }
332 }
333 public override PhysicsVector Position
334 {
335 get
336 {
337 PhysicsVector pos = new PhysicsVector();
338 Vec3 vec = this._prim.Position;
339 pos.X = vec.X;
340 pos.Y = vec.Y;
341 pos.Z = vec.Z;
342 return pos;
343
344 }
345 set
346 {
347 PhysicsVector vec = value;
348 Vec3 pos = new Vec3();
349 pos.X = vec.X;
350 pos.Y = vec.Y;
351 pos.Z = vec.Z;
352 this._prim.Position = pos;
353 }
354 }
355
356 public override PhysicsVector Velocity
357 {
358 get
359 {
360 return _velocity;
361 }
362 set
363 {
364 _velocity = value;
365 }
366 }
367
368 public override bool Kinematic
369 {
370 get
371 {
372 return this._prim.Kinematic;
373 }
374 set
375 {
376 this._prim.Kinematic = value;
377 }
378 }
379
380 public override Axiom.MathLib.Quaternion Orientation
381 {
382 get
383 {
384 Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion();
385 PhysXWrapper.Quaternion quat = this._prim.GetOrientation();
386 res.w = quat.W;
387 res.x = quat.X;
388 res.y = quat.Y;
389 res.z = quat.Z;
390 return res;
391 }
392 set
393 {
394
395 }
396 }
397
398 public override PhysicsVector Acceleration
399 {
400 get
401 {
402 return _acceleration;
403 }
404
405 }
406 public void SetAcceleration (PhysicsVector accel)
407 {
408 this._acceleration = accel;
409 }
410
411 public override void AddForce(PhysicsVector force)
412 {
413
414 }
415
416 public override void SetMomentum(PhysicsVector momentum)
417 {
418
419 }
420
421
422 }
423
424}
diff --git a/OpenSim/Region/Scripting/Properties/AssemblyInfo.cs b/OpenSim/Region/Scripting/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f5da4c0
--- /dev/null
+++ b/OpenSim/Region/Scripting/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Scripting")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenSim.Scripting")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("61eae1ad-82aa-4c77-8bc5-b5a8c9522b18")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.0")]
35[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Scripting/Script.cs b/OpenSim/Region/Scripting/Script.cs
new file mode 100644
index 0000000..0f4af00
--- /dev/null
+++ b/OpenSim/Region/Scripting/Script.cs
@@ -0,0 +1,32 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using OpenSim.Framework.Console;
6using OpenSim.Framework;
7using OpenSim.Region;
8using OpenSim.Region.Scenes;
9
10namespace OpenSim.Scripting
11{
12 public interface IScript
13 {
14 void Initialise(ScriptInfo scriptInfo);
15 }
16
17 public class TestScript : IScript
18 {
19 ScriptInfo script;
20
21 public void Initialise(ScriptInfo scriptInfo)
22 {
23 script = scriptInfo;
24 script.events.OnFrame += new OpenSim.Region.Scenes.EventManager.OnFrameDelegate(events_OnFrame);
25 }
26
27 void events_OnFrame()
28 {
29 script.logger.Verbose("Hello World!");
30 }
31 }
32}
diff --git a/OpenSim/Region/Scripting/ScriptAccess.cs b/OpenSim/Region/Scripting/ScriptAccess.cs
new file mode 100644
index 0000000..a9fede5
--- /dev/null
+++ b/OpenSim/Region/Scripting/ScriptAccess.cs
@@ -0,0 +1,31 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using OpenSim.Region.Scenes;
6using OpenSim.Framework.Console;
7
8namespace OpenSim.Scripting
9{
10 /// <summary>
11 /// Class which provides access to the world
12 /// </summary>
13 public class ScriptInfo
14 {
15 // Reference to world.eventsManager provided for convenience
16 public EventManager events;
17
18 // The main world
19 public Scene world;
20
21 // The console
22 public LogBase logger;
23
24 public ScriptInfo(Scene scene)
25 {
26 world = scene;
27 events = world.eventManager;
28 logger = OpenSim.Framework.Console.MainLog.Instance;
29 }
30 }
31}
diff --git a/OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs
new file mode 100644
index 0000000..3bc6f25
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs
@@ -0,0 +1,117 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29// BDB Support
30// Apparently broken on Mono
31
32using System;
33using System.Collections.Generic;
34using System.Data;
35using libsecondlife;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types;
38using BerkeleyDb;
39using Kds.Serialization;
40using Kds.Serialization.Buffer;
41
42namespace OpenSim.Region.Storage.LocalStorageBDB
43{
44 public class BDBLocalStorage : ILocalStorage
45 {
46 const string simDbName = "localsim.db";
47
48 DbHash sim;
49 Db DB;
50 //BEFormatter formatter;
51
52 public BDBLocalStorage()
53 {
54 DB = new Db(DbCreateFlags.None);
55 sim = (DbHash)DB.Open(null, simDbName, null, BerkeleyDb.DbType.Hash, Db.OpenFlags.Create, 0);
56 //vendorDb = (DbBTree)db.Open(null, VendorDbName, null, DbType.BTree, Db.OpenFlags.Create, 0);
57 }
58
59 public void Initialise(string file)
60 {
61 // Blank
62 }
63
64 public void StorePrim(PrimData prim)
65 {
66 DbEntry key = new DbEntry();
67 DbEntry data = new DbEntry();
68 lock (sim)
69 {
70 sim.PutUnique(null, ref key, ref data, DbFile.WriteFlags.AutoCommit);
71 }
72 }
73 public void RemovePrim(LLUUID primID)
74 {
75
76 }
77 public void LoadPrimitives(ILocalStorageReceiver receiver)
78 {
79
80 }
81 public float[] LoadWorld()
82 {
83 return new float[65536];
84 }
85 public void SaveMap(float[] heightmap)
86 {
87
88 }
89
90 public void SaveParcels(ParcelData[] parcel_data)
91 {
92 }
93
94 public void SaveParcel(ParcelData parcel)
95 {
96 }
97
98 public void RemoveParcel(ParcelData parcel)
99 {
100 }
101
102 public void RemoveAllParcels()
103 {
104 }
105
106 public void LoadParcels(ILocalStorageParcelReceiver recv)
107 {
108 recv.NoParcelDataFromStorage();
109 }
110
111 public void ShutDown()
112 {
113 sim.GetDb().Close();
114 DB.Close();
115 }
116 }
117} \ No newline at end of file
diff --git a/OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Region.Storage.LocalStorageBerkeleyDB.csproj b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Region.Storage.LocalStorageBerkeleyDB.csproj
new file mode 100644
index 0000000..b956c9b
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Region.Storage.LocalStorageBerkeleyDB.csproj
@@ -0,0 +1,112 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{A4691E59-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Storage.LocalStorageBerkeleyDB</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Storage.LocalStorageBerkeleyDB</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Kds.Serialization.dll" >
62 <HintPath>..\..\..\..\bin\Kds.Serialization.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="libdb_dotNET43.dll" >
66 <HintPath>..\..\..\..\bin\libdb_dotNET43.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="libsecondlife.dll" >
70 <HintPath>..\..\..\..\bin\libsecondlife.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System" >
74 <HintPath>System.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="System.Data" >
78 <HintPath>System.Data.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="System.Xml" >
82 <HintPath>System.Xml.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 </ItemGroup>
86 <ItemGroup>
87 <ProjectReference Include="..\..\..\Framework\General\OpenSim.Framework.csproj">
88 <Name>OpenSim.Framework</Name>
89 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
90 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
91 <Private>False</Private>
92 </ProjectReference>
93 <ProjectReference Include="..\..\..\Framework\Console\OpenSim.Framework.Console.csproj">
94 <Name>OpenSim.Framework.Console</Name>
95 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
96 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
97 <Private>False</Private>
98 </ProjectReference>
99 </ItemGroup>
100 <ItemGroup>
101 <Compile Include="BDBLocalStorage.cs">
102 <SubType>Code</SubType>
103 </Compile>
104 </ItemGroup>
105 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
106 <PropertyGroup>
107 <PreBuildEvent>
108 </PreBuildEvent>
109 <PostBuildEvent>
110 </PostBuildEvent>
111 </PropertyGroup>
112</Project>
diff --git a/OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Region.Storage.LocalStorageBerkeleyDB.dll.build b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Region.Storage.LocalStorageBerkeleyDB.dll.build
new file mode 100644
index 0000000..20f5171
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Region.Storage.LocalStorageBerkeleyDB.dll.build
@@ -0,0 +1,46 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Storage.LocalStorageBerkeleyDB" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Storage.LocalStorageBerkeleyDB" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="BDBLocalStorage.cs" />
15 </sources>
16 <references basedir="${project::get-base-directory()}">
17 <lib>
18 <include name="${project::get-base-directory()}" />
19 <include name="${project::get-base-directory()}/${build.dir}" />
20 </lib>
21 <include name="../../../../bin/Kds.Serialization.dll" />
22 <include name="../../../../bin/libdb_dotNET43.dll" />
23 <include name="../../../../bin/libsecondlife.dll" />
24 <include name="../../../../bin/OpenSim.Framework.dll" />
25 <include name="../../../../bin/OpenSim.Framework.Console.dll" />
26 <include name="System.dll" />
27 <include name="System.Data.dll" />
28 <include name="System.Xml.dll" />
29 </references>
30 </csc>
31 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/" />
32 <mkdir dir="${project::get-base-directory()}/../../../../bin/"/>
33 <copy todir="${project::get-base-directory()}/../../../../bin/">
34 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
35 <include name="*.dll"/>
36 <include name="*.exe"/>
37 </fileset>
38 </copy>
39 </target>
40 <target name="clean">
41 <delete dir="${bin.dir}" failonerror="false" />
42 <delete dir="${obj.dir}" failonerror="false" />
43 </target>
44 <target name="doc" description="Creates documentation.">
45 </target>
46</project>
diff --git a/OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build
new file mode 100644
index 0000000..bc2d8ec
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build
@@ -0,0 +1,46 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Storage.LocalStorageBerkeleyDB" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Storage.LocalStorageBerkeleyDB" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="BDBLocalStorage.cs" />
15 </sources>
16 <references basedir="${project::get-base-directory()}">
17 <lib>
18 <include name="${project::get-base-directory()}" />
19 <include name="${project::get-base-directory()}/${build.dir}" />
20 </lib>
21 <include name="../../../bin/Kds.Serialization.dll" />
22 <include name="../../../bin/libdb_dotNET43.dll" />
23 <include name="../../../bin/libsecondlife.dll" />
24 <include name="../../../bin/OpenSim.Framework.dll" />
25 <include name="../../../bin/OpenSim.Framework.Console.dll" />
26 <include name="System.dll" />
27 <include name="System.Data.dll" />
28 <include name="System.Xml.dll" />
29 </references>
30 </csc>
31 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
32 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
33 <copy todir="${project::get-base-directory()}/../../../bin/">
34 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
35 <include name="*.dll"/>
36 <include name="*.exe"/>
37 </fileset>
38 </copy>
39 </target>
40 <target name="clean">
41 <delete dir="${bin.dir}" failonerror="false" />
42 <delete dir="${obj.dir}" failonerror="false" />
43 </target>
44 <target name="doc" description="Creates documentation.">
45 </target>
46</project>
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs b/OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs
new file mode 100644
index 0000000..ea2b62e
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// Information about this assembly is defined by the following
33// attributes.
34//
35// change them to the information which is associated with the assembly
36// you compile.
37
38[assembly: AssemblyTitle("Db4LocalStorage")]
39[assembly: AssemblyDescription("")]
40[assembly: AssemblyConfiguration("")]
41[assembly: AssemblyCompany("")]
42[assembly: AssemblyProduct("Db4LocalStorage")]
43[assembly: AssemblyCopyright("")]
44[assembly: AssemblyTrademark("")]
45[assembly: AssemblyCulture("")]
46
47// This sets the default COM visibility of types in the assembly to invisible.
48// If you need to expose a type to COM, use [ComVisible(true)] on that type.
49[assembly: ComVisible(false)]
50
51// The assembly version has following format :
52//
53// Major.Minor.Build.Revision
54//
55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default):
57
58[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs b/OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs
new file mode 100644
index 0000000..5cb4861
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs
@@ -0,0 +1,271 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using Db4objects.Db4o;
31using Db4objects.Db4o.Query;
32
33using libsecondlife;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Console;
37
38
39namespace OpenSim.Region.Storage.LocalStorageDb4o
40{
41 /// <summary>
42 ///
43 /// </summary>
44 public class Db4LocalStorage : ILocalStorage
45 {
46 private IObjectContainer db;
47 private string datastore;
48
49 public Db4LocalStorage()
50 {
51
52 }
53
54 public void Initialise(string dfile)
55 {
56 OpenSim.Framework.Console.MainLog.Instance.Warn("Db4LocalStorage Opening " + dfile);
57 datastore = dfile;
58 try
59 {
60 db = Db4oFactory.OpenFile(datastore);
61 OpenSim.Framework.Console.MainLog.Instance.Verbose("Db4LocalStorage creation");
62 }
63 catch (Exception e)
64 {
65 db.Close();
66 OpenSim.Framework.Console.MainLog.Instance.Warn("Db4LocalStorage :Constructor - Exception occured");
67 OpenSim.Framework.Console.MainLog.Instance.Warn(e.ToString());
68 }
69 }
70
71 public void StorePrim(PrimData prim)
72 {
73 IObjectSet result = db.Query(new UUIDPrimQuery(prim.FullID));
74 if (result.Count > 0)
75 {
76 //prim already in storage
77 //so update it
78 PrimData found = (PrimData)result.Next();
79 found.PathBegin = prim.PathBegin;
80 found.PathCurve = prim.PathCurve;
81 found.PathEnd = prim.PathEnd;
82 found.PathRadiusOffset = prim.PathRadiusOffset;
83 found.PathRevolutions = prim.PathRevolutions;
84 found.PathScaleX = prim.PathScaleX;
85 found.PathScaleY = prim.PathScaleY;
86 found.PathShearX = prim.PathShearX;
87 found.PathShearY = prim.PathShearY;
88 found.PathSkew = prim.PathSkew;
89 found.PathTaperX = prim.PathTaperX;
90 found.PathTaperY = prim.PathTaperY;
91 found.PathTwist = prim.PathTwist;
92 found.PathTwistBegin = prim.PathTwistBegin;
93 found.PCode = prim.PCode;
94 found.ProfileBegin = prim.ProfileBegin;
95 found.ProfileCurve = prim.ProfileCurve;
96 found.ProfileEnd = prim.ProfileEnd;
97 found.ProfileHollow = prim.ProfileHollow;
98 found.Position = prim.Position;
99 found.Rotation = prim.Rotation;
100 found.TextureEntry = prim.TextureEntry;
101 db.Set(found);
102 db.Commit();
103 }
104 else
105 {
106 //not in storage
107 db.Set(prim);
108 db.Commit();
109 }
110 }
111
112 public void RemovePrim(LLUUID primID)
113 {
114 IObjectSet result = db.Query(new UUIDPrimQuery(primID));
115 if (result.Count > 0)
116 {
117 PrimData found = (PrimData)result.Next();
118 db.Delete(found);
119 }
120 }
121
122
123 public void LoadPrimitives(ILocalStorageReceiver receiver)
124 {
125 IObjectSet result = db.Get(typeof(PrimData));
126 OpenSim.Framework.Console.MainLog.Instance.Verbose("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is " + result.Count);
127 foreach (PrimData prim in result)
128 {
129 receiver.PrimFromStorage(prim);
130 }
131 }
132
133 public float[] LoadWorld()
134 {
135 OpenSim.Framework.Console.MainLog.Instance.Verbose("LoadWorld() - Loading world....");
136 float[] heightmap = null;
137 OpenSim.Framework.Console.MainLog.Instance.Verbose("LoadWorld() - Looking for a heightmap in local DB");
138 IObjectSet world_result = db.Get(typeof(MapStorage));
139 if (world_result.Count > 0)
140 {
141 OpenSim.Framework.Console.MainLog.Instance.Verbose("LoadWorld() - Found a heightmap in local database, loading");
142 MapStorage map = (MapStorage)world_result.Next();
143 //blank.LandMap = map.Map;
144 heightmap = map.Map;
145 }
146 return heightmap;
147 }
148
149 public void SaveMap(float[] heightmap)
150 {
151 IObjectSet world_result = db.Get(typeof(MapStorage));
152 if (world_result.Count > 0)
153 {
154 OpenSim.Framework.Console.MainLog.Instance.Verbose("SaveWorld() - updating saved copy of heightmap in local database");
155 MapStorage map = (MapStorage)world_result.Next();
156 db.Delete(map);
157 }
158 MapStorage map1 = new MapStorage();
159 map1.Map = heightmap; //OpenSim_Main.local_world.LandMap;
160 db.Set(map1);
161 db.Commit();
162 }
163
164 public void SaveParcel(ParcelData parcel)
165 {
166 IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID));
167 if (result.Count > 0)
168 {
169 //Old Parcel
170 ParcelData updateParcel = (ParcelData)result.Next();
171 updateParcel.AABBMax = parcel.AABBMax;
172 updateParcel.AABBMin = parcel.AABBMin;
173 updateParcel.area = parcel.area;
174 updateParcel.auctionID = parcel.auctionID;
175 updateParcel.authBuyerID = parcel.authBuyerID;
176 updateParcel.category = parcel.category;
177 updateParcel.claimDate = parcel.claimDate;
178 updateParcel.claimPrice = parcel.claimPrice;
179 updateParcel.groupID = parcel.groupID;
180 updateParcel.groupPrims = parcel.groupPrims;
181 updateParcel.isGroupOwned = parcel.isGroupOwned;
182 updateParcel.landingType = parcel.landingType;
183 updateParcel.mediaAutoScale = parcel.mediaAutoScale;
184 updateParcel.mediaID = parcel.mediaID;
185 updateParcel.mediaURL = parcel.mediaURL;
186 updateParcel.musicURL = parcel.musicURL;
187 updateParcel.localID = parcel.localID;
188 updateParcel.ownerID = parcel.ownerID;
189 updateParcel.passHours = parcel.passHours;
190 updateParcel.passPrice = parcel.passPrice;
191 updateParcel.parcelBitmapByteArray = (byte[])parcel.parcelBitmapByteArray.Clone();
192 updateParcel.parcelDesc = parcel.parcelDesc;
193 updateParcel.parcelFlags = parcel.parcelFlags;
194 updateParcel.parcelName = parcel.parcelName;
195 updateParcel.parcelStatus = parcel.parcelStatus;
196 updateParcel.salePrice = parcel.salePrice;
197 updateParcel.snapshotID = parcel.snapshotID;
198 updateParcel.userLocation = parcel.userLocation;
199 updateParcel.userLookAt = parcel.userLookAt;
200
201 db.Set(updateParcel);
202 }
203 else
204 {
205 db.Set(parcel);
206 }
207 db.Commit();
208 }
209
210 public void SaveParcels(ParcelData[] parcel_data)
211 {
212 MainLog.Instance.Notice("Parcel Backup: Saving Parcels...");
213 int i;
214 for (i = 0; i < parcel_data.GetLength(0); i++)
215 {
216
217 SaveParcel(parcel_data[i]);
218
219 }
220 MainLog.Instance.Notice("Parcel Backup: Parcel Save Complete");
221 }
222
223 public void RemoveParcel(ParcelData parcel)
224 {
225 IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID));
226 if (result.Count > 0)
227 {
228 db.Delete(result[0]);
229 }
230 db.Commit();
231 }
232 public void RemoveAllParcels()
233 {
234 MainLog.Instance.Notice("Parcel Backup: Removing all parcels...");
235 IObjectSet result = db.Get(typeof(ParcelData));
236 if (result.Count > 0)
237 {
238 foreach (ParcelData parcelData in result)
239 {
240 RemoveParcel(parcelData);
241 }
242 }
243 }
244
245 public void LoadParcels(ILocalStorageParcelReceiver recv)
246 {
247 MainLog.Instance.Notice("Parcel Backup: Loading Parcels...");
248 IObjectSet result = db.Get(typeof(ParcelData));
249 if (result.Count > 0)
250 {
251 MainLog.Instance.Notice("Parcel Backup: Parcels exist in database.");
252 foreach (ParcelData parcelData in result)
253 {
254
255 recv.ParcelFromStorage(parcelData);
256 }
257 }
258 else
259 {
260 MainLog.Instance.Notice("Parcel Backup: No parcels exist. Creating basic parcel.");
261 recv.NoParcelDataFromStorage();
262 }
263 MainLog.Instance.Notice("Parcel Backup: Parcels Restored");
264 }
265 public void ShutDown()
266 {
267 db.Commit();
268 db.Close();
269 }
270 }
271} \ No newline at end of file
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs b/OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs
new file mode 100644
index 0000000..22f3392
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs
@@ -0,0 +1,43 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Region.Storage.LocalStorageDb4o
33{
34 public class MapStorage
35 {
36 public float[] Map;
37
38 public MapStorage()
39 {
40
41 }
42 }
43} \ No newline at end of file
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/OpenSim.Region.Storage.LocalStorageDb4o.csproj b/OpenSim/Region/Storage/LocalStorageDb4o/OpenSim.Region.Storage.LocalStorageDb4o.csproj
new file mode 100644
index 0000000..147158c
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/OpenSim.Region.Storage.LocalStorageDb4o.csproj
@@ -0,0 +1,116 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{43DB702D-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Storage.LocalStorageDb4o</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Storage.LocalStorageDb4o</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Db4objects.Db4o.dll" >
62 <HintPath>..\..\..\..\bin\Db4objects.Db4o.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="libsecondlife.dll" >
66 <HintPath>..\..\..\..\bin\libsecondlife.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System" >
70 <HintPath>System.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System.Xml" >
74 <HintPath>System.Xml.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 </ItemGroup>
78 <ItemGroup>
79 <ProjectReference Include="..\..\..\Framework\General\OpenSim.Framework.csproj">
80 <Name>OpenSim.Framework</Name>
81 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
82 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
83 <Private>False</Private>
84 </ProjectReference>
85 <ProjectReference Include="..\..\..\Framework\Console\OpenSim.Framework.Console.csproj">
86 <Name>OpenSim.Framework.Console</Name>
87 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
88 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
89 <Private>False</Private>
90 </ProjectReference>
91 </ItemGroup>
92 <ItemGroup>
93 <Compile Include="AssemblyInfo.cs">
94 <SubType>Code</SubType>
95 </Compile>
96 <Compile Include="Db4LocalStorage.cs">
97 <SubType>Code</SubType>
98 </Compile>
99 <Compile Include="MapStorage.cs">
100 <SubType>Code</SubType>
101 </Compile>
102 <Compile Include="UUIDParcelQuery.cs">
103 <SubType>Code</SubType>
104 </Compile>
105 <Compile Include="UUIDPrimQuery.cs">
106 <SubType>Code</SubType>
107 </Compile>
108 </ItemGroup>
109 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
110 <PropertyGroup>
111 <PreBuildEvent>
112 </PreBuildEvent>
113 <PostBuildEvent>
114 </PostBuildEvent>
115 </PropertyGroup>
116</Project>
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/OpenSim.Region.Storage.LocalStorageDb4o.dll.build b/OpenSim/Region/Storage/LocalStorageDb4o/OpenSim.Region.Storage.LocalStorageDb4o.dll.build
new file mode 100644
index 0000000..fc9f055
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/OpenSim.Region.Storage.LocalStorageDb4o.dll.build
@@ -0,0 +1,48 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Storage.LocalStorageDb4o" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Storage.LocalStorageDb4o" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="Db4LocalStorage.cs" />
16 <include name="MapStorage.cs" />
17 <include name="UUIDParcelQuery.cs" />
18 <include name="UUIDPrimQuery.cs" />
19 </sources>
20 <references basedir="${project::get-base-directory()}">
21 <lib>
22 <include name="${project::get-base-directory()}" />
23 <include name="${project::get-base-directory()}/${build.dir}" />
24 </lib>
25 <include name="../../../../bin/Db4objects.Db4o.dll" />
26 <include name="../../../../bin/libsecondlife.dll" />
27 <include name="../../../../bin/OpenSim.Framework.dll" />
28 <include name="../../../../bin/OpenSim.Framework.Console.dll" />
29 <include name="System.dll" />
30 <include name="System.Xml.dll" />
31 </references>
32 </csc>
33 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/" />
34 <mkdir dir="${project::get-base-directory()}/../../../../bin/"/>
35 <copy todir="${project::get-base-directory()}/../../../../bin/">
36 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
37 <include name="*.dll"/>
38 <include name="*.exe"/>
39 </fileset>
40 </copy>
41 </target>
42 <target name="clean">
43 <delete dir="${bin.dir}" failonerror="false" />
44 <delete dir="${obj.dir}" failonerror="false" />
45 </target>
46 <target name="doc" description="Creates documentation.">
47 </target>
48</project>
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs
new file mode 100644
index 0000000..dcbe639
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs
@@ -0,0 +1,52 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using Db4objects.Db4o;
32using Db4objects.Db4o.Query;
33using libsecondlife;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36
37namespace OpenSim.Region.Storage.LocalStorageDb4o
38{
39 public class UUIDParcelQuery : Predicate
40 {
41 private LLUUID globalIDSearch;
42
43 public UUIDParcelQuery(LLUUID find)
44 {
45 globalIDSearch = find;
46 }
47 public bool Match(ParcelData parcel)
48 {
49 return (parcel.globalID == globalIDSearch);
50 }
51 }
52}
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs
new file mode 100644
index 0000000..23de6dd
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs
@@ -0,0 +1,52 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using Db4objects.Db4o;
32using Db4objects.Db4o.Query;
33using libsecondlife;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36
37namespace OpenSim.Region.Storage.LocalStorageDb4o
38{
39 public class UUIDPrimQuery : Predicate
40 {
41 private LLUUID _findID;
42
43 public UUIDPrimQuery(LLUUID find)
44 {
45 _findID = find;
46 }
47 public bool Match(PrimData prim)
48 {
49 return (prim.FullID == _findID);
50 }
51 }
52}
diff --git a/OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Region.Storage.LocalStorageSQLite.csproj b/OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Region.Storage.LocalStorageSQLite.csproj
new file mode 100644
index 0000000..d1353a5
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Region.Storage.LocalStorageSQLite.csproj
@@ -0,0 +1,111 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{477B9270-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Storage.LocalStorageSQLite</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Storage.LocalStorageSQLite</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="libsecondlife.dll" >
62 <HintPath>..\..\..\..\bin\libsecondlife.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System" >
66 <HintPath>System.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Data" >
70 <HintPath>System.Data.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System.Data.SQLite.dll" >
74 <HintPath>..\..\..\..\bin\System.Data.SQLite.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="System.Xml" >
78 <HintPath>System.Xml.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 </ItemGroup>
82 <ItemGroup>
83 <ProjectReference Include="..\..\..\Framework\General\OpenSim.Framework.csproj">
84 <Name>OpenSim.Framework</Name>
85 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
86 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
87 <Private>False</Private>
88 </ProjectReference>
89 <ProjectReference Include="..\..\..\Framework\Console\OpenSim.Framework.Console.csproj">
90 <Name>OpenSim.Framework.Console</Name>
91 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
92 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
93 <Private>False</Private>
94 </ProjectReference>
95 </ItemGroup>
96 <ItemGroup>
97 <Compile Include="SQLiteLocalStorage.cs">
98 <SubType>Code</SubType>
99 </Compile>
100 <Compile Include="Properties\AssemblyInfo.cs">
101 <SubType>Code</SubType>
102 </Compile>
103 </ItemGroup>
104 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
105 <PropertyGroup>
106 <PreBuildEvent>
107 </PreBuildEvent>
108 <PostBuildEvent>
109 </PostBuildEvent>
110 </PropertyGroup>
111</Project>
diff --git a/OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Region.Storage.LocalStorageSQLite.dll.build b/OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Region.Storage.LocalStorageSQLite.dll.build
new file mode 100644
index 0000000..9d12c33
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Region.Storage.LocalStorageSQLite.dll.build
@@ -0,0 +1,46 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Storage.LocalStorageSQLite" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Storage.LocalStorageSQLite" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="SQLiteLocalStorage.cs" />
15 <include name="Properties/AssemblyInfo.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="../../../../bin/libsecondlife.dll" />
23 <include name="../../../../bin/OpenSim.Framework.dll" />
24 <include name="../../../../bin/OpenSim.Framework.Console.dll" />
25 <include name="System.dll" />
26 <include name="System.Data.dll" />
27 <include name="../../../../bin/System.Data.SQLite.dll" />
28 <include name="System.Xml.dll" />
29 </references>
30 </csc>
31 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../bin/" />
32 <mkdir dir="${project::get-base-directory()}/../../../../bin/"/>
33 <copy todir="${project::get-base-directory()}/../../../../bin/">
34 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
35 <include name="*.dll"/>
36 <include name="*.exe"/>
37 </fileset>
38 </copy>
39 </target>
40 <target name="clean">
41 <delete dir="${bin.dir}" failonerror="false" />
42 <delete dir="${obj.dir}" failonerror="false" />
43 </target>
44 <target name="doc" description="Creates documentation.">
45 </target>
46</project>
diff --git a/OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build b/OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build
new file mode 100644
index 0000000..bd4c731
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build
@@ -0,0 +1,46 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Storage.LocalStorageSQLite" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Storage.LocalStorageSQLite" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="SQLiteLocalStorage.cs" />
15 <include name="Properties/AssemblyInfo.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="../../../bin/libsecondlife.dll" />
23 <include name="../../../bin/OpenSim.Framework.dll" />
24 <include name="../../../bin/OpenSim.Framework.Console.dll" />
25 <include name="System.dll" />
26 <include name="System.Data.dll" />
27 <include name="../../../bin/System.Data.SQLite.dll" />
28 <include name="System.Xml.dll" />
29 </references>
30 </csc>
31 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
32 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
33 <copy todir="${project::get-base-directory()}/../../../bin/">
34 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
35 <include name="*.dll"/>
36 <include name="*.exe"/>
37 </fileset>
38 </copy>
39 </target>
40 <target name="clean">
41 <delete dir="${bin.dir}" failonerror="false" />
42 <delete dir="${obj.dir}" failonerror="false" />
43 </target>
44 <target name="doc" description="Creates documentation.">
45 </target>
46</project>
diff --git a/OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs b/OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..80158d5
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs
@@ -0,0 +1,62 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// General Information about an assembly is controlled through the following
33// set of attributes. Change these attribute values to modify the information
34// associated with an assembly.
35[assembly: AssemblyTitle("OpenSim.Region.Storage.LocalStorageSQLite")]
36[assembly: AssemblyDescription("")]
37[assembly: AssemblyConfiguration("")]
38[assembly: AssemblyCompany("")]
39[assembly: AssemblyProduct("OpenSim.Region.Storage.LocalStorageSQLite")]
40[assembly: AssemblyCopyright("Copyright © 2007")]
41[assembly: AssemblyTrademark("")]
42[assembly: AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47[assembly: ComVisible(false)]
48
49// The following GUID is for the ID of the typelib if this project is exposed to COM
50[assembly: Guid("ecd6e0c1-7909-413e-9e3f-659678ac3bc3")]
51
52// Version information for an assembly consists of the following four values:
53//
54// Major Version
55// Minor Version
56// Build Number
57// Revision
58//
59// You can specify all the values or you can default the Revision and Build Numbers
60// by using the '*' as shown below:
61[assembly: AssemblyVersion("1.0.0.*")]
62[assembly: AssemblyFileVersion("1.0.0.*")]
diff --git a/OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs b/OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs
new file mode 100644
index 0000000..b407be4
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs
@@ -0,0 +1,198 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29// SQLite Support
30// A bad idea, but the IRC people told me to!
31
32using System;
33using System.Collections.Generic;
34using System.Data;
35using System.Data.SQLite;
36using libsecondlife;
37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Types;
39
40namespace OpenSim.Region.Storage.LocalStorageSQLite
41{
42 public class SQLiteLocalStorage : ILocalStorage
43 {
44 IDbConnection db;
45
46 public SQLiteLocalStorage()
47 {
48 try
49 {
50 string connectionstring = "URI=file:localsim.sdb";
51 db = (IDbConnection)new SQLiteConnection(connectionstring);
52 db.Open();
53 }
54 catch (Exception e)
55 {
56 db.Close();
57 OpenSim.Framework.Console.MainLog.Instance.Warn("SQLiteLocalStorage :Constructor - Exception occured");
58 OpenSim.Framework.Console.MainLog.Instance.Warn(e.ToString());
59 }
60 }
61
62 public void Initialise(string file)
63 {
64 // Blank
65 }
66
67 public void StorePrim(PrimData prim)
68 {
69 IDbCommand cmd = db.CreateCommand();
70
71 //SECURITY WARNING:
72 // These parameters wont produce SQL injections since they are all integer based, however.
73 // if inserting strings such as name or description, you will need to use appropriate
74 // measures to prevent SQL injection (although the value of SQL injection in this is limited).
75
76 string sql = "REPLACE INTO prim (OwnerID,PCode,PathBegin,PathEnd,PathScaleX,PathScaleY,PathShearX,PathShearY,PathSkew,ProfileBegin,ProfileEnd,Scale,PathCurve,ProfileCurve,ParentID,ProfileHollow,PathRadiusOffset,PathRevolutions,PathTaperX,PathTaperY,PathTwist,PathTwistBegin,Texture,CreationDate,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,Position,Rotation,LocalID,FullID) ";
77 sql += "VALUES (";
78 sql += "\"" + prim.OwnerID.ToStringHyphenated() + "\","; // KILL ME NOW!
79 sql += "\"" + prim.PCode.ToString() + "\",";
80 sql += "\"" + prim.PathBegin.ToString() + "\",";
81 sql += "\"" + prim.PathEnd.ToString() + "\",";
82 sql += "\"" + prim.PathScaleX.ToString() + "\",";
83 sql += "\"" + prim.PathScaleY.ToString() + "\",";
84 sql += "\"" + prim.PathShearX.ToString() + "\",";
85 sql += "\"" + prim.PathShearY.ToString() + "\",";
86 sql += "\"" + prim.PathSkew.ToString() + "\",";
87 sql += "\"" + prim.ProfileBegin.ToString() + "\",";
88 sql += "\"" + prim.ProfileEnd.ToString() + "\",";
89 sql += "\"" + prim.Scale.ToString() + "\",";
90 sql += "\"" + prim.PathCurve.ToString() + "\",";
91 sql += "\"" + prim.ProfileCurve.ToString() + "\",";
92 sql += "\"" + prim.ParentID.ToString() + "\",";
93 sql += "\"" + prim.ProfileHollow.ToString() + "\",";
94 sql += "\"" + prim.PathRadiusOffset.ToString() + "\",";
95 sql += "\"" + prim.PathRevolutions.ToString() + "\",";
96 sql += "\"" + prim.PathTaperX.ToString() + "\",";
97 sql += "\"" + prim.PathTaperY.ToString() + "\",";
98 sql += "\"" + prim.PathTwist.ToString() + "\",";
99 sql += "\"" + prim.PathTwistBegin.ToString() + "\",";
100 sql += "\"" + prim.TextureEntry.ToString() + "\",";
101 sql += "\"" + prim.CreationDate.ToString() + "\",";
102 sql += "\"" + prim.OwnerMask.ToString() + "\",";
103 sql += "\"" + prim.NextOwnerMask.ToString() + "\",";
104 sql += "\"" + prim.GroupMask.ToString() + "\",";
105 sql += "\"" + prim.EveryoneMask.ToString() + "\",";
106 sql += "\"" + prim.BaseMask.ToString() + "\",";
107 sql += "\"" + prim.Position.ToString() + "\",";
108 sql += "\"" + prim.Rotation.ToString() + "\",";
109 sql += "\"" + prim.LocalID.ToString() + "\",";
110 sql += "\"" + prim.FullID.ToString() + "\")";
111
112 cmd.CommandText = sql;
113
114 try
115 {
116 cmd.ExecuteNonQuery();
117 }
118 catch (Exception e)
119 {
120 OpenSim.Framework.Console.MainLog.Instance.Warn("SQLiteLocalStorage :StorePrim - Exception occured");
121 OpenSim.Framework.Console.MainLog.Instance.Warn(e.ToString());
122 }
123
124 cmd.Dispose();
125 cmd = null;
126 }
127
128 public void RemovePrim(LLUUID primID)
129 {
130 IDbCommand cmd = db.CreateCommand();
131
132 //SECURITY WARNING:
133 // These parameters wont produce SQL injections since they are all integer based, however.
134 // if inserting strings such as name or description, you will need to use appropriate
135 // measures to prevent SQL injection (although the value of SQL injection in this is limited).
136
137 string sql = "DELETE FROM prim WHERE FullID = \"" + primID.ToStringHyphenated() + "\"";
138
139 cmd.CommandText = sql;
140
141 try
142 {
143 cmd.ExecuteNonQuery();
144 }
145 catch (Exception e)
146 {
147 OpenSim.Framework.Console.MainLog.Instance.Warn("SQLiteLocalStorage :RemovePrim - Exception occured");
148 OpenSim.Framework.Console.MainLog.Instance.Warn(e.ToString());
149 }
150
151 cmd.Dispose();
152 cmd = null;
153 }
154
155 public void LoadPrimitives(ILocalStorageReceiver receiver)
156 {
157
158 }
159
160 public float[] LoadWorld()
161 {
162 return new float[65536];
163 }
164
165 public void SaveMap(float[] heightmap)
166 {
167
168 }
169
170 public void SaveParcels(ParcelData[] parcel_manager)
171 {
172
173 }
174
175 public void SaveParcel(ParcelData parcel)
176 {
177 }
178
179 public void RemoveParcel(ParcelData parcel)
180 {
181 }
182
183 public void RemoveAllParcels()
184 {
185 }
186
187 public void LoadParcels(ILocalStorageParcelReceiver recv)
188 {
189 recv.NoParcelDataFromStorage();
190 }
191
192 public void ShutDown()
193 {
194 db.Close();
195 db = null;
196 }
197 }
198} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/OpenSim.Region.Terrain.BasicTerrain.csproj b/OpenSim/Region/Terrain.BasicTerrain/OpenSim.Region.Terrain.BasicTerrain.csproj
new file mode 100644
index 0000000..24667e5
--- /dev/null
+++ b/OpenSim/Region/Terrain.BasicTerrain/OpenSim.Region.Terrain.BasicTerrain.csproj
@@ -0,0 +1,110 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{C9E0F891-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.Terrain.BasicTerrain</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.Terrain.BasicTerrain</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="libTerrain-BSD.dll" >
62 <HintPath>..\..\..\bin\libTerrain-BSD.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="Microsoft.JScript" >
66 <HintPath>Microsoft.JScript.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="openjpegnet.dll" >
70 <HintPath>..\..\..\bin\openjpegnet.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System" >
74 <HintPath>System.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="System.Data" >
78 <HintPath>System.Data.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="System.Drawing" >
82 <HintPath>System.Drawing.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 <Reference Include="System.Xml" >
86 <HintPath>System.Xml.dll</HintPath>
87 <Private>False</Private>
88 </Reference>
89 </ItemGroup>
90 <ItemGroup>
91 </ItemGroup>
92 <ItemGroup>
93 <Compile Include="TerrainEngine.cs">
94 <SubType>Code</SubType>
95 </Compile>
96 <Compile Include="TerrainFilter.cs">
97 <SubType>Code</SubType>
98 </Compile>
99 <Compile Include="Properties\AssemblyInfo.cs">
100 <SubType>Code</SubType>
101 </Compile>
102 </ItemGroup>
103 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
104 <PropertyGroup>
105 <PreBuildEvent>
106 </PreBuildEvent>
107 <PostBuildEvent>
108 </PostBuildEvent>
109 </PropertyGroup>
110</Project>
diff --git a/OpenSim/Region/Terrain.BasicTerrain/OpenSim.Region.Terrain.BasicTerrain.dll.build b/OpenSim/Region/Terrain.BasicTerrain/OpenSim.Region.Terrain.BasicTerrain.dll.build
new file mode 100644
index 0000000..dc7203a
--- /dev/null
+++ b/OpenSim/Region/Terrain.BasicTerrain/OpenSim.Region.Terrain.BasicTerrain.dll.build
@@ -0,0 +1,47 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.Terrain.BasicTerrain" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Region.Terrain.BasicTerrain" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="TerrainEngine.cs" />
15 <include name="TerrainFilter.cs" />
16 <include name="Properties/AssemblyInfo.cs" />
17 </sources>
18 <references basedir="${project::get-base-directory()}">
19 <lib>
20 <include name="${project::get-base-directory()}" />
21 <include name="${project::get-base-directory()}/${build.dir}" />
22 </lib>
23 <include name="../../../bin/libTerrain-BSD.dll" />
24 <include name="Microsoft.JScript.dll" />
25 <include name="../../../bin/openjpegnet.dll" />
26 <include name="System.dll" />
27 <include name="System.Data.dll" />
28 <include name="System.Drawing.dll" />
29 <include name="System.Xml.dll" />
30 </references>
31 </csc>
32 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
33 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
34 <copy todir="${project::get-base-directory()}/../../../bin/">
35 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
36 <include name="*.dll"/>
37 <include name="*.exe"/>
38 </fileset>
39 </copy>
40 </target>
41 <target name="clean">
42 <delete dir="${bin.dir}" failonerror="false" />
43 <delete dir="${obj.dir}" failonerror="false" />
44 </target>
45 <target name="doc" description="Creates documentation.">
46 </target>
47</project>
diff --git a/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..7d10ae3
--- /dev/null
+++ b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs
@@ -0,0 +1,62 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// General Information about an assembly is controlled through the following
33// set of attributes. Change these attribute values to modify the information
34// associated with an assembly.
35[assembly: AssemblyTitle("OpenSim.Region.Terrain.BasicTerrain")]
36[assembly: AssemblyDescription("")]
37[assembly: AssemblyConfiguration("")]
38[assembly: AssemblyCompany("")]
39[assembly: AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")]
40[assembly: AssemblyCopyright("Copyright © 2007")]
41[assembly: AssemblyTrademark("")]
42[assembly: AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47[assembly: ComVisible(false)]
48
49// The following GUID is for the ID of the typelib if this project is exposed to COM
50[assembly: Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")]
51
52// Version information for an assembly consists of the following four values:
53//
54// Major Version
55// Minor Version
56// Build Number
57// Revision
58//
59// You can specify all the values or you can default the Revision and Build Numbers
60// by using the '*' as shown below:
61[assembly: AssemblyVersion("1.0.0.0")]
62[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
new file mode 100644
index 0000000..c2d7e86
--- /dev/null
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -0,0 +1,786 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using System.Drawing;
32using libTerrain;
33using OpenJPEGNet;
34
35namespace OpenSim.Region.Terrain
36{
37 public class TerrainCommand
38 {
39 public virtual bool run(string[] cmdargs, ref string output)
40 {
41 return false;
42 }
43
44 public string args;
45 public string help;
46 }
47
48 public class TerrainEngine
49 {
50 /// <summary>
51 /// Plugin library for scripts
52 /// </summary>
53 public FilterHost customFilters = new FilterHost();
54
55 /// <summary>
56 /// A [normally] 256x256 heightmap
57 /// </summary>
58 public Channel heightmap;
59
60 /// <summary>
61 /// A copy of heightmap at the last save point (for reverting)
62 /// </summary>
63 public Channel revertmap;
64
65 /// <summary>
66 /// Water heightmap (needs clientside mods to work)
67 /// </summary>
68 public Channel watermap;
69
70 /// <summary>
71 /// Whether or not the terrain has been modified since it was last saved and sent to the Physics engine.
72 /// Counts the number of modifications since the last save. (0 = Untainted)
73 /// </summary>
74 public int tainted;
75
76 int w, h;
77
78 /// <summary>
79 /// Generate a new TerrainEngine instance and creates a new heightmap
80 /// </summary>
81 public TerrainEngine()
82 {
83 w = 256;
84 h = 256;
85 heightmap = new Channel(w, h);
86
87 tainted++;
88 }
89
90 /// <summary>
91 /// Converts the heightmap to a 65536 value 1D floating point array
92 /// </summary>
93 /// <returns>A float[65536] array containing the heightmap</returns>
94 public float[] getHeights1D()
95 {
96 float[] heights = new float[w * h];
97 int i;
98
99 for (i = 0; i < w * h; i++)
100 {
101 heights[i] = (float)heightmap.map[i / w, i % w];
102 }
103
104 return heights;
105 }
106
107 /// <summary>
108 /// Converts the heightmap to a 256x256 value 2D floating point array.
109 /// </summary>
110 /// <returns>An array of 256,256 values containing the heightmap</returns>
111 public float[,] getHeights2D()
112 {
113 float[,] heights = new float[w, h];
114 int x, y;
115 for (x = 0; x < w; x++)
116 {
117 for (y = 0; y < h; y++)
118 {
119 heights[x, y] = (float)heightmap.map[x, y];
120 }
121 }
122 return heights;
123 }
124
125 /// <summary>
126 /// Imports a 1D floating point array into the 2D heightmap array
127 /// </summary>
128 /// <param name="heights">The array to import (must have 65536 members)</param>
129 public void setHeights1D(float[] heights)
130 {
131 int i;
132 for (i = 0; i < w * h; i++)
133 {
134 heightmap.map[i / w, i % w] = heights[i];
135 }
136
137 tainted++;
138 }
139
140 /// <summary>
141 /// Loads a 2D array of values into the heightmap
142 /// </summary>
143 /// <param name="heights">An array of 256,256 float values</param>
144 public void setHeights2D(float[,] heights)
145 {
146 int x, y;
147 for (x = 0; x < w; x++)
148 {
149 for (y = 0; y < h; y++)
150 {
151 heightmap.set(x, y, (double)heights[x, y]);
152 }
153 }
154 tainted++;
155 }
156
157 /// <summary>
158 /// Swaps the two heightmap buffers (the 'revert map' and the heightmap)
159 /// </summary>
160 public void swapRevertMaps()
161 {
162 Channel backup = heightmap.copy();
163 heightmap = revertmap;
164 revertmap = backup;
165 }
166
167 /// <summary>
168 /// Saves the current heightmap into the revertmap
169 /// </summary>
170 public void saveRevertMap()
171 {
172 revertmap = heightmap.copy();
173 }
174
175 /// <summary>
176 /// Processes a terrain-specific command
177 /// </summary>
178 /// <param name="args">Commandline arguments (space seperated)</param>
179 /// <param name="resultText">Reference that returns error or help text if returning false</param>
180 /// <returns>If the operation was successful (if not, the error is placed into resultText)</returns>
181 public bool RunTerrainCmd(string[] args, ref string resultText)
182 {
183 string command = args[0];
184
185 try
186 {
187
188 switch (command)
189 {
190 case "help":
191 resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n";
192 resultText += "terrain voronoi <points> <blocksize> - generates a worley fractal with X points per block";
193 resultText += "terrain seed <seed> - sets the random seed value to <seed>\n";
194 resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n";
195 resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32', 'F64' or 'PNG'\n";
196 resultText += "terrain save grdmap <filename> <gradient map> - creates a PNG snapshot of the region using a named gradient map\n";
197 resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n";
198 resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest>\n";
199 resultText += "terrain erode thermal <talus> <rounds> <carry>\n";
200 resultText += "terrain multiply <val> - multiplies a terrain by <val>\n";
201 resultText += "terrain revert - reverts the terrain to the stored original\n";
202 resultText += "terrain bake - saves the current terrain into the revert map\n";
203 resultText += "terrain csfilter <filename.cs> - loads a new filter from the specified .cs file\n";
204 resultText += "terrain jsfilter <filename.js> - loads a new filter from the specified .js file\n";
205 foreach (KeyValuePair<string, ITerrainFilter> filter in customFilters.filters)
206 {
207 resultText += filter.Value.Help();
208 }
209
210 return false;
211
212 case "revert":
213 swapRevertMaps();
214 saveRevertMap();
215 break;
216
217 case "bake":
218 saveRevertMap();
219 break;
220
221 case "seed":
222 setSeed(Convert.ToInt32(args[1]));
223 break;
224
225 case "erode":
226 return consoleErosion(args, ref resultText);
227
228 case "voronoi":
229 double[] c = new double[2];
230 c[0] = -1;
231 c[1] = 1;
232 heightmap.voronoiDiagram(Convert.ToInt32(args[1]), Convert.ToInt32(args[2]), c);
233 break;
234
235 case "hills":
236 return consoleHills(args, ref resultText);
237
238 case "regenerate":
239 hills();
240 break;
241
242 case "rescale":
243 setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2]));
244 break;
245
246 case "multiply":
247 heightmap *= Convert.ToDouble(args[1]);
248 break;
249
250 case "load":
251 switch (args[1].ToLower())
252 {
253 case "f32":
254 loadFromFileF32(args[2]);
255 break;
256
257 case "f64":
258 loadFromFileF64(args[2]);
259 break;
260
261 case "raw":
262 loadFromFileSLRAW(args[2]);
263 break;
264
265 case "img":
266 heightmap.loadImage(args[2]);
267 return false;
268
269 default:
270 resultText = "Unknown image or data format";
271 return false;
272 }
273 break;
274
275 case "save":
276 switch (args[1].ToLower())
277 {
278 case "f32":
279 writeToFileF32(args[2]);
280 break;
281
282 case "f64":
283 writeToFileF64(args[2]);
284 break;
285
286 case "grdmap":
287 exportImage(args[2], args[3]);
288 break;
289
290 case "png":
291 heightmap.saveImage(args[2]);
292 break;
293
294 default:
295 resultText = "Unknown image or data format";
296 return false;
297 }
298 break;
299
300 case "csfilter":
301 customFilters.LoadFilterCSharp(args[1]);
302 break;
303 case "jsfilter":
304 customFilters.LoadFilterJScript(args[1]);
305 break;
306
307 default:
308 // Run any custom registered filters
309 if (customFilters.filters.ContainsKey(command))
310 {
311 customFilters.filters[command].Filter(heightmap, args);
312 break;
313 }
314 else
315 {
316 resultText = "Unknown terrain command";
317 return false;
318 }
319 }
320 return true;
321 }
322 catch (Exception e)
323 {
324 resultText = "Error running terrain command: " + e.ToString();
325 return false;
326 }
327 }
328
329 private bool consoleErosion(string[] args, ref string resultText)
330 {
331 switch (args[1].ToLower())
332 {
333 case "aerobic":
334 // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest
335 heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), Convert.ToInt32(args[6]), Convert.ToBoolean(args[7]));
336 break;
337 case "thermal":
338 heightmap.thermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4]));
339 break;
340 default:
341 resultText = "Unknown erosion type";
342 return false;
343 }
344 return true;
345 }
346
347 private bool consoleHills(string[] args, ref string resultText)
348 {
349 int count;
350 double sizeMin;
351 double sizeRange;
352 bool island;
353 bool additive;
354 bool noisy;
355
356 if (args.GetLength(0) > 2)
357 {
358 count = Convert.ToInt32(args[2]);
359 sizeMin = Convert.ToDouble(args[3]);
360 sizeRange = Convert.ToDouble(args[4]);
361 island = Convert.ToBoolean(args[5]);
362 additive = Convert.ToBoolean(args[6]);
363 noisy = Convert.ToBoolean(args[7]);
364 }
365 else
366 {
367 count = 200;
368 sizeMin = 20;
369 sizeRange = 40;
370 island = true;
371 additive = true;
372 noisy = false;
373 }
374
375 switch (args[1].ToLower())
376 {
377 case "blocks":
378 heightmap.hillsBlocks(count, sizeMin, sizeRange, island, additive, noisy);
379 break;
380 case "cones":
381 heightmap.hillsCones(count, sizeMin, sizeRange, island, additive, noisy);
382 break;
383 case "spheres":
384 heightmap.hillsSpheres(count, sizeMin, sizeRange, island, additive, noisy);
385 break;
386 case "squared":
387 heightmap.hillsSquared(count, sizeMin, sizeRange, island, additive, noisy);
388 break;
389 default:
390 resultText = "Unknown hills type";
391 return false;
392 }
393 return true;
394 }
395
396 /// <summary>
397 /// Renormalises the array between min and max
398 /// </summary>
399 /// <param name="min">Minimum value of the new array</param>
400 /// <param name="max">Maximum value of the new array</param>
401 public void setRange(float min, float max)
402 {
403 heightmap.normalise((double)min, (double)max);
404 tainted++;
405 }
406
407 /// <summary>
408 /// Loads a file consisting of 256x256 doubles and imports it as an array into the map.
409 /// </summary>
410 /// <remarks>TODO: Move this to libTerrain itself</remarks>
411 /// <param name="filename">The filename of the double array to import</param>
412 public void loadFromFileF64(string filename)
413 {
414 System.IO.FileInfo file = new System.IO.FileInfo(filename);
415 System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read);
416 System.IO.BinaryReader bs = new System.IO.BinaryReader(s);
417 int x, y;
418 for (x = 0; x < w; x++)
419 {
420 for (y = 0; y < h; y++)
421 {
422 heightmap.map[x, y] = bs.ReadDouble();
423 }
424 }
425
426 bs.Close();
427 s.Close();
428
429 tainted++;
430 }
431
432 /// <summary>
433 /// Loads a file consisting of 256x256 floats and imports it as an array into the map.
434 /// </summary>
435 /// <remarks>TODO: Move this to libTerrain itself</remarks>
436 /// <param name="filename">The filename of the float array to import</param>
437 public void loadFromFileF32(string filename)
438 {
439 System.IO.FileInfo file = new System.IO.FileInfo(filename);
440 System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read);
441 System.IO.BinaryReader bs = new System.IO.BinaryReader(s);
442 int x, y;
443 for (x = 0; x < w; x++)
444 {
445 for (y = 0; y < h; y++)
446 {
447 heightmap.map[x, y] = (double)bs.ReadSingle();
448 }
449 }
450
451 bs.Close();
452 s.Close();
453
454 tainted++;
455 }
456
457 /// <summary>
458 /// Loads a file formatted in the SL .RAW Format used on the main grid
459 /// </summary>
460 /// <remarks>This file format stinks and is best avoided.</remarks>
461 /// <param name="filename">A path to the .RAW format</param>
462 public void loadFromFileSLRAW(string filename)
463 {
464 System.IO.FileInfo file = new System.IO.FileInfo(filename);
465 System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read);
466 System.IO.BinaryReader bs = new System.IO.BinaryReader(s);
467 int x, y;
468 for (x = 0; x < w; x++)
469 {
470 for (y = 0; y < h; y++)
471 {
472 heightmap.map[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0);
473 bs.ReadBytes(11); // Advance the stream to next bytes.
474 }
475 }
476
477 bs.Close();
478 s.Close();
479
480 tainted++;
481 }
482
483 /// <summary>
484 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array.
485 /// </summary>
486 /// <param name="filename">The desired output filename</param>
487 public void writeToFileF64(string filename)
488 {
489 System.IO.FileInfo file = new System.IO.FileInfo(filename);
490 System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
491 System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s);
492
493 int x, y;
494 for (x = 0; x < w; x++)
495 {
496 for (y = 0; y < h; y++)
497 {
498 bs.Write(heightmap.get(x, y));
499 }
500 }
501
502 bs.Close();
503 s.Close();
504 }
505
506 /// <summary>
507 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry float[] array
508 /// </summary>
509 /// <param name="filename">The desired output filename</param>
510 public void writeToFileF32(string filename)
511 {
512 System.IO.FileInfo file = new System.IO.FileInfo(filename);
513 System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
514 System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s);
515
516 int x, y;
517 for (x = 0; x < w; x++)
518 {
519 for (y = 0; y < h; y++)
520 {
521 bs.Write((float)heightmap.get(x, y));
522 }
523 }
524
525 bs.Close();
526 s.Close();
527 }
528
529 /// <summary>
530 /// Sets the random seed to be used by procedural functions which involve random numbers.
531 /// </summary>
532 /// <param name="val">The desired seed</param>
533 public void setSeed(int val)
534 {
535 heightmap.seed = val;
536 }
537
538 /// <summary>
539 /// Raises land in a sphere around the specified coordinates
540 /// </summary>
541 /// <param name="rx">Center of the sphere on the X axis</param>
542 /// <param name="ry">Center of the sphere on the Y axis</param>
543 /// <param name="size">The radius of the sphere</param>
544 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
545 public void raise(double rx, double ry, double size, double amount)
546 {
547 lock (heightmap)
548 {
549 heightmap.raise(rx, ry, size, amount);
550 }
551
552 tainted++;
553 }
554
555 /// <summary>
556 /// Lowers the land in a sphere around the specified coordinates
557 /// </summary>
558 /// <param name="rx">The center of the sphere at the X axis</param>
559 /// <param name="ry">The center of the sphere at the Y axis</param>
560 /// <param name="size">The radius of the sphere in meters</param>
561 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
562 public void lower(double rx, double ry, double size, double amount)
563 {
564 lock (heightmap)
565 {
566 heightmap.lower(rx, ry, size, amount);
567 }
568
569 tainted++;
570 }
571
572 /// <summary>
573 /// Flattens the land under the brush of specified coordinates (spherical mask)
574 /// </summary>
575 /// <param name="rx">Center of sphere</param>
576 /// <param name="ry">Center of sphere</param>
577 /// <param name="size">Radius of the sphere</param>
578 /// <param name="amount">Thickness of the mask (0..2 recommended)</param>
579 public void flatten(double rx, double ry, double size, double amount)
580 {
581 lock (heightmap)
582 {
583 heightmap.flatten(rx, ry, size, amount);
584 }
585
586 tainted++;
587 }
588
589 /// <summary>
590 /// Creates noise within the specified bounds
591 /// </summary>
592 /// <param name="rx">Center of the bounding sphere</param>
593 /// <param name="ry">Center of the bounding sphere</param>
594 /// <param name="size">The radius of the sphere</param>
595 /// <param name="amount">Strength of the mask (0..2) recommended</param>
596 public void noise(double rx, double ry, double size, double amount)
597 {
598 lock (heightmap)
599 {
600 Channel smoothed = new Channel();
601 smoothed.noise();
602
603 Channel mask = new Channel();
604 mask.raise(rx, ry, size, amount);
605
606 heightmap.blend(smoothed, mask);
607 }
608
609 tainted++;
610 }
611
612 /// <summary>
613 /// Reverts land within the specified bounds
614 /// </summary>
615 /// <param name="rx">Center of the bounding sphere</param>
616 /// <param name="ry">Center of the bounding sphere</param>
617 /// <param name="size">The radius of the sphere</param>
618 /// <param name="amount">Strength of the mask (0..2) recommended</param>
619 public void revert(double rx, double ry, double size, double amount)
620 {
621 lock (heightmap)
622 {
623 Channel mask = new Channel();
624 mask.raise(rx, ry, size, amount);
625
626 heightmap.blend(revertmap, mask);
627 }
628
629 tainted++;
630 }
631
632 /// <summary>
633 /// Smooths land under the brush of specified coordinates (spherical mask)
634 /// </summary>
635 /// <param name="rx">Center of the sphere</param>
636 /// <param name="ry">Center of the sphere</param>
637 /// <param name="size">Radius of the sphere</param>
638 /// <param name="amount">Thickness of the mask (0..2 recommended)</param>
639 public void smooth(double rx, double ry, double size, double amount)
640 {
641 lock (heightmap)
642 {
643 Channel smoothed = heightmap.copy();
644 smoothed.smooth(amount);
645
646 Channel mask = new Channel();
647 mask.raise(rx,ry,size,amount);
648
649 heightmap.blend(smoothed, mask);
650 }
651
652 tainted++;
653 }
654
655 /// <summary>
656 /// Generates a simple set of hills in the shape of an island
657 /// </summary>
658 public void hills()
659 {
660 lock (heightmap)
661 {
662 heightmap.hillsSpheres(200, 20, 40, true, true, false);
663 heightmap.normalise();
664 heightmap *= 60.0; // Raise to 60m
665 }
666
667 tainted++;
668 }
669
670 /// <summary>
671 /// Multiplies the heightfield by val
672 /// </summary>
673 /// <param name="meep">The heightfield</param>
674 /// <param name="val">The multiplier</param>
675 /// <returns></returns>
676 public static TerrainEngine operator *(TerrainEngine meep, Double val)
677 {
678 meep.heightmap *= val;
679 meep.tainted++;
680 return meep;
681 }
682
683 /// <summary>
684 /// Returns the height at the coordinates x,y
685 /// </summary>
686 /// <param name="x">X Coordinate</param>
687 /// <param name="y">Y Coordinate</param>
688 /// <returns></returns>
689 public float this[int x, int y]
690 {
691 get
692 {
693 return (float)heightmap.get(x, y);
694 }
695 set
696 {
697 tainted++;
698 heightmap.set(x, y, (double)value);
699 }
700 }
701
702 /// <summary>
703 /// Exports the current heightmap to a PNG file
704 /// </summary>
705 /// <param name="filename">The destination filename for the image</param>
706 /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param>
707 public void exportImage(string filename, string gradientmap)
708 {
709 try
710 {
711 Bitmap gradientmapLd = new Bitmap(gradientmap);
712
713 int pallete = gradientmapLd.Height;
714
715 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
716 Color[] colours = new Color[pallete];
717
718 for (int i = 0; i < pallete; i++)
719 {
720 colours[i] = gradientmapLd.GetPixel(0, i);
721 }
722
723 Channel copy = heightmap.copy();
724 for (int x = 0; x < copy.w; x++)
725 {
726 for (int y = 0; y < copy.h; y++)
727 {
728 // 512 is the largest possible height before colours clamp
729 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(x, y) / 512.0), 0.0) * pallete);
730 bmp.SetPixel(x, y, colours[colorindex]);
731 }
732 }
733
734 bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
735 }
736 catch (Exception e)
737 {
738 Console.WriteLine("Failed generating terrain map: " + e.ToString());
739 }
740 }
741
742 /// <summary>
743 /// Exports the current heightmap in Jpeg2000 format to a byte[]
744 /// </summary>
745 /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param>
746 public byte[] exportJpegImage(string gradientmap)
747 {
748 byte[] imageData = null;
749 try
750 {
751 Bitmap gradientmapLd = new Bitmap(gradientmap);
752
753 int pallete = gradientmapLd.Height;
754
755 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
756 Color[] colours = new Color[pallete];
757
758 for (int i = 0; i < pallete; i++)
759 {
760 colours[i] = gradientmapLd.GetPixel(0, i);
761 }
762
763 Channel copy = heightmap.copy();
764 for (int x = 0; x < copy.w; x++)
765 {
766 for (int y = 0; y < copy.h; y++)
767 {
768 // 512 is the largest possible height before colours clamp
769 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(copy.h - y, x) / 512.0), 0.0) * pallete);
770 bmp.SetPixel(x, y, colours[colorindex]);
771 }
772 }
773
774 //bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
775 imageData = OpenJPEGNet.OpenJPEG.EncodeFromImage(bmp, "map");
776
777 }
778 catch (Exception e)
779 {
780 Console.WriteLine("Failed generating terrain map: " + e.ToString());
781 }
782
783 return imageData;
784 }
785 }
786} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs
new file mode 100644
index 0000000..e0ae586
--- /dev/null
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs
@@ -0,0 +1,130 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32using System.CodeDom.Compiler;
33using System.CodeDom;
34using Microsoft.CSharp;
35using Microsoft.JScript;
36
37using libTerrain;
38
39namespace OpenSim.Region.Terrain
40{
41 public interface ITerrainFilter
42 {
43 void Filter(Channel heightmap, string[] args);
44 string Register();
45 string Help();
46 }
47
48 public class TestFilter : ITerrainFilter
49 {
50 public void Filter(Channel heightmap, string[] args)
51 {
52 Console.WriteLine("Hello world");
53 }
54
55 public string Register()
56 {
57 return "demofilter";
58 }
59
60 public string Help()
61 {
62 return "demofilter - Does nothing";
63 }
64 }
65
66 public class FilterHost
67 {
68 public Dictionary<string, ITerrainFilter> filters = new Dictionary<string, ITerrainFilter>();
69
70 private void LoadFilter(ICodeCompiler compiler, string filename)
71 {
72 CompilerParameters compilerParams = new CompilerParameters();
73 CompilerResults compilerResults;
74 compilerParams.GenerateExecutable = false;
75 compilerParams.GenerateInMemory = true;
76 compilerParams.IncludeDebugInformation = false;
77 compilerParams.ReferencedAssemblies.Add("libTerrain-BSD.dll");
78 compilerParams.ReferencedAssemblies.Add("OpenSim.Terrain.BasicTerrain.dll");
79 compilerParams.ReferencedAssemblies.Add("System.dll");
80
81 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
82
83 if (compilerResults.Errors.Count > 0)
84 {
85 Console.WriteLine("Compile errors:");
86 foreach (CompilerError error in compilerResults.Errors)
87 {
88 Console.WriteLine(error.Line.ToString() + ": " + error.ErrorText.ToString());
89 }
90 }
91 else
92 {
93 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
94 {
95 Type testInterface = pluginType.GetInterface("ITerrainFilter",true);
96
97 if (testInterface != null)
98 {
99 ITerrainFilter filter = (ITerrainFilter)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
100
101 string filterName = filter.Register();
102 Console.WriteLine("Plugin: " + filterName + " loaded.");
103
104 if (!filters.ContainsKey(filterName))
105 {
106 filters.Add(filterName, filter);
107 }
108 else
109 {
110 filters[filterName] = filter;
111 }
112 }
113 }
114 }
115
116 }
117
118 public void LoadFilterCSharp(string filename)
119 {
120 CSharpCodeProvider compiler = new CSharpCodeProvider();
121 LoadFilter(compiler.CreateCompiler(), filename);
122 }
123
124 public void LoadFilterJScript(string filename)
125 {
126 JScriptCodeProvider compiler = new JScriptCodeProvider();
127 LoadFilter(compiler.CreateCompiler(), filename);
128 }
129 }
130}