From d67b5fa474b6269506d47d12f660309d4faa9b7a Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 10 Apr 2007 15:44:54 +0000 Subject: [PATCH] Work in progress of adding a embedded java vm for scripting testing /prototyping. Currently the vm is at a early stage and very limited: currently only supports static methods (instance methods support is nearly finished though) currently a class can't have member variables, so currently only local variables in the methods. Also in this branch, connecting the vm to opensim is not completely finished: it is being uploaded just for viewing purposes. --- .../GridConfigDb4o/AssemblyInfo.cs | 31 + .../GridConfigDb4o/DbGridConfig.cs | 112 + .../OpenGrid.Config.GridConfigDb4o.csproj | 111 + ...OpenGrid.Config.GridConfigDb4o.csproj.user | 12 + .../OpenGrid.Config.GridConfigDb4o.dll.build | 46 + OpenGridServices.GridServer/GridHttp.cs | 229 + OpenGridServices.GridServer/Main.cs | 189 + .../OpenGridServices.GridServer.csproj | 117 + .../OpenGridServices.GridServer.csproj.user | 12 + .../OpenGridServices.GridServer.exe.build | 48 + .../Properties/AssemblyInfo.cs | 33 + OpenGridServices.GridServer/SimProfiles.cs | 142 + OpenGridServices.UserServer/Main.cs | 176 + .../OGS-UserServer.csproj | 63 + .../OGS-UserServer.csproj.user | 8 + .../OpenGridServices.UserServer.csproj | 114 + .../OpenGridServices.UserServer.csproj.user | 12 + .../OpenGridServices.UserServer.exe.build | 47 + .../Properties/AssemblyInfo.cs | 33 + OpenGridServices.UserServer/UserHttp.cs | 157 + OpenSim.Framework.Console/AssemblyInfo.cs | 31 + OpenSim.Framework.Console/ConsoleBase.cs | 151 + .../ConsoleCallbacksBase.cs | 12 + OpenSim.Framework.Console/MainConsole.cs | 48 + .../OpenSim.Framework.Console.csproj | 89 + .../OpenSim.Framework.Console.csproj.user | 12 + .../OpenSim.Framework.Console.dll.build | 42 + OpenSim.Framework/AgentCiruitData.cs | 19 + OpenSim.Framework/AgentInventory.cs | 242 + OpenSim.Framework/AssetBase.cs | 22 + OpenSim.Framework/BlockingQueue.cs | 33 + OpenSim.Framework/HeightMapGenHills.cs | 149 + OpenSim.Framework/IAssetServer.cs | 68 + OpenSim.Framework/IConfig.cs | 76 + OpenSim.Framework/IGenericConfig.cs | 15 + OpenSim.Framework/IGridConfig.cs | 64 + OpenSim.Framework/IGridServer.cs | 78 + OpenSim.Framework/ILocalStorage.cs | 53 + OpenSim.Framework/IScriptAPI.cs | 13 + OpenSim.Framework/IScriptEngine.cs | 14 + OpenSim.Framework/IUserConfig.cs | 58 + OpenSim.Framework/IUserServer.cs | 15 + OpenSim.Framework/LocalGridBase.cs | 21 + OpenSim.Framework/Login.cs | 22 + OpenSim.Framework/LoginService.cs | 14 + OpenSim.Framework/NeighbourInfo.cs | 19 + OpenSim.Framework/OSVector3.cs | 18 + OpenSim.Framework/OpenSim.Framework.csproj | 178 + .../OpenSim.Framework.csproj.user | 12 + OpenSim.Framework/OpenSim.Framework.dll.build | 67 + OpenSim.Framework/PrimData.cs | 168 + OpenSim.Framework/Properties/AssemblyInfo.cs | 33 + OpenSim.Framework/RemoteGridBase.cs | 25 + OpenSim.Framework/SimProfile.cs | 51 + OpenSim.Framework/SimProfileBase.cs | 26 + OpenSim.Framework/UserProfile.cs | 51 + OpenSim.Framework/UserProfileManager.cs | 250 + OpenSim.Framework/UserProfileManagerBase.cs | 124 + OpenSim.Framework/Util.cs | 45 + OpenSim.FxCop | 7241 +++++++++++++++++ .../Xml/OpenSim.GenericConfig.Xml.csproj | 93 + .../Xml/OpenSim.GenericConfig.Xml.csproj.user | 12 + .../Xml/OpenSim.GenericConfig.Xml.dll.build | 42 + .../Xml/Properties/AssemblyInfo.cs | 35 + OpenSim.GenericConfig/Xml/XmlConfig.cs | 109 + OpenSim.GridInterfaces/Local/AssemblyInfo.cs | 31 + .../Local/LocalAssetServer.cs | 248 + .../Local/LocalGridServer.cs | 156 + .../Local/OpenSim.GridInterfaces.Local.csproj | 110 + .../OpenSim.GridInterfaces.Local.csproj.user | 12 + .../OpenSim.GridInterfaces.Local.dll.build | 46 + OpenSim.GridInterfaces/Remote/AssemblyInfo.cs | 31 + .../OpenSim.GridInterfaces.Remote.csproj | 106 + .../OpenSim.GridInterfaces.Remote.csproj.user | 12 + .../OpenSim.GridInterfaces.Remote.dll.build | 45 + .../Remote/RemoteAssetServer.cs | 102 + .../Remote/RemoteGridServer.cs | 176 + .../BasicPhysicsPlugin/AssemblyInfo.cs | 31 + .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 256 + .../OpenSim.Physics.BasicPhysicsPlugin.csproj | 93 + ...Sim.Physics.BasicPhysicsPlugin.csproj.user | 12 + ...enSim.Physics.BasicPhysicsPlugin.dll.build | 42 + OpenSim.Physics/Manager/AssemblyInfo.cs | 31 + .../Manager/OpenSim.Physics.Manager.csproj | 112 + .../OpenSim.Physics.Manager.csproj.user | 12 + .../Manager/OpenSim.Physics.Manager.dll.build | 47 + OpenSim.Physics/Manager/PhysicsActor.cs | 161 + OpenSim.Physics/Manager/PhysicsManager.cs | 116 + OpenSim.Physics/Manager/PhysicsScene.cs | 105 + OpenSim.Physics/Manager/PhysicsVector.cs | 54 + OpenSim.Physics/OdePlugin/AssemblyInfo.cs | 31 + OpenSim.Physics/OdePlugin/OdePlugin.cs | 447 + .../OpenSim.Physics.OdePlugin.csproj | 97 + .../OpenSim.Physics.OdePlugin.csproj.user | 12 + .../OpenSim.Physics.OdePlugin.dll.build | 43 + OpenSim.Physics/PhysXPlugin/AssemblyInfo.cs | 31 + .../OpenSim.Physics.PhysXPlugin.csproj | 97 + .../OpenSim.Physics.PhysXPlugin.csproj.user | 12 + .../OpenSim.Physics.PhysXPlugin.dll.build | 43 + OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs | 444 + OpenSim.RegionServer/AgentAssetUpload.cs | 232 + OpenSim.RegionServer/Assets/AssetCache.cs | 574 ++ OpenSim.RegionServer/Assets/InventoryCache.cs | 336 + OpenSim.RegionServer/CAPS/AdminWebFront.cs | 257 + OpenSim.RegionServer/ConsoleCmds.cs | 0 OpenSim.RegionServer/Grid.cs | 90 + .../OpenSim.RegionServer.csproj | 238 + .../OpenSim.RegionServer.csproj.user | 12 + .../OpenSim.RegionServer.dll.build | 82 + OpenSim.RegionServer/OpenSim.csproj | 186 + OpenSim.RegionServer/OpenSim.exe.build | 69 + OpenSim.RegionServer/OpenSimMain.cs | 449 + OpenSim.RegionServer/OpenSimNetworkHandler.cs | 17 + OpenSim.RegionServer/PacketServer.cs | 87 + OpenSim.RegionServer/QueItem.cs | 18 + OpenSim.RegionServer/RegionInfo.cs | 244 + OpenSim.RegionServer/SimClient.cs | 944 +++ OpenSim.RegionServer/SimConsole.cs | 0 OpenSim.RegionServer/VersionInfo.cs | 37 + OpenSim.RegionServer/types/Mesh.cs | 28 + OpenSim.RegionServer/types/Triangle.cs | 28 + OpenSim.RegionServer/world/Avatar.cs | 351 + .../world/AvatarAnimations.cs | 163 + OpenSim.RegionServer/world/AvatarClient.cs | 33 + OpenSim.RegionServer/world/AvatarUpdate.cs | 301 + OpenSim.RegionServer/world/Entity.cs | 124 + OpenSim.RegionServer/world/Primitive.cs | 563 ++ OpenSim.RegionServer/world/Primitive2.cs | 429 + OpenSim.RegionServer/world/ScriptEngine.cs | 18 + OpenSim.RegionServer/world/SurfacePatch.cs | 22 + OpenSim.RegionServer/world/World.cs | 417 + .../world/WorldPacketHandlers.cs | 182 + OpenSim.RegionServer/world/WorldScripting.cs | 99 + .../world/scripting/IScript.cs | 16 + .../world/scripting/IScriptContext.cs | 13 + .../world/scripting/IScriptEntity.cs | 19 + .../world/scripting/IScriptHandler.cs | 98 + .../world/scripting/Script.cs | 26 + .../world/scripting/ScriptFactory.cs | 8 + .../scripting/Scripts/FollowRandomAvatar.cs | 37 + .../ClassInstance.cs | 18 + OpenSim.Scripting.EmbeddedJVM/ClassRecord.cs | 475 ++ OpenSim.Scripting.EmbeddedJVM/Heap.cs | 16 + OpenSim.Scripting.EmbeddedJVM/Interpreter.cs | 105 + .../InterpreterLogic.cs | 283 + .../InterpreterMethods.cs | 137 + .../InterpreterReturn.cs | 13 + OpenSim.Scripting.EmbeddedJVM/MainMemory.cs | 18 + OpenSim.Scripting.EmbeddedJVM/MethodMemory.cs | 19 + OpenSim.Scripting.EmbeddedJVM/Object.cs | 10 + .../OpenSim.Scripting.EmbeddedJVM.csproj | 75 + OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs | 126 + .../Properties/AssemblyInfo.cs | 33 + OpenSim.Scripting.EmbeddedJVM/Stack.cs | 15 + OpenSim.Scripting.EmbeddedJVM/StackFrame.cs | 22 + OpenSim.Scripting.EmbeddedJVM/Thread.cs | 88 + .../Types/ArrayReference.cs | 10 + .../Types/BaseType.cs | 10 + .../Types/ObjectReference.cs | 16 + .../Types/PrimitiveTypes/Byte.cs | 10 + .../Types/PrimitiveTypes/Char.cs | 10 + .../Types/PrimitiveTypes/Float.cs | 16 + .../Types/PrimitiveTypes/Int.cs | 16 + .../LocalStorageDb4o/AssemblyInfo.cs | 31 + .../LocalStorageDb4o/Db4LocalStorage.cs | 174 + .../LocalStorageDb4o/MapStorage.cs | 16 + .../OpenSim.Storage.LocalStorageDb4o.csproj | 113 + ...enSim.Storage.LocalStorageDb4o.csproj.user | 12 + ...OpenSim.Storage.LocalStorageDb4o.dll.build | 47 + OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs | 25 + OpenSim.Terrain.BasicTerrain/Hills.cs | 72 + OpenSim.Terrain.BasicTerrain/Normalise.cs | 102 + .../OpenSim.Terrain.BasicTerrain.csproj | 50 + .../Properties/AssemblyInfo.cs | 35 + OpenSim.Terrain.BasicTerrain/RaiseLower.cs | 91 + OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 134 + OpenSim.build | 118 + OpenSim.sln | 127 + OpenSim.suo | Bin 0 -> 224256 bytes OpenSim/Application.cs | 64 + OpenSim/OpenSim.csproj | 126 + OpenSim/OpenSim.csproj.user | 13 + OpenSim/OpenSim.exe.build | 48 + .../UserConfigDb4o/AssemblyInfo.cs | 31 + .../UserConfigDb4o/DbUserConfig.cs | 95 + .../OpenUser.Config.UserConfigDb4o.csproj | 111 + ...OpenUser.Config.UserConfigDb4o.csproj.user | 12 + .../OpenUser.Config.UserConfigDb4o.dll.build | 46 + Prebuild/Prebuild.build | 67 + Prebuild/Prebuild.sln | 19 + Prebuild/README | 230 + Prebuild/TODO | 21 + Prebuild/doc/prebuild-example1.xml | 300 + Prebuild/doc/prebuild-example2.xml | 72 + Prebuild/doc/prebuild-example3.xml | 113 + Prebuild/doc/prebuild-example4.xml | 715 ++ Prebuild/doc/prebuild-example5.xml | 187 + Prebuild/prebuild | 2 + Prebuild/scripts/Clean.bat | 2 + Prebuild/scripts/Help.bat | 2 + Prebuild/scripts/MonoDevelop.sh | 2 + Prebuild/scripts/Prebuild.nsi | 231 + Prebuild/scripts/SharpDevelop.bat | 4 + Prebuild/scripts/SharpDevelop2.bat | 4 + Prebuild/scripts/VS2002.bat | 4 + Prebuild/scripts/VS2003.bat | 4 + Prebuild/scripts/VS2005.bat | 4 + Prebuild/scripts/autotools.bat | 4 + Prebuild/scripts/autotools.sh | 2 + Prebuild/scripts/nant.bat | 4 + Prebuild/scripts/nant.sh | 2 + Prebuild/src/App.ico | Bin 0 -> 4286 bytes .../src/Core/Attributes/DataNodeAttribute.cs | 81 + .../Core/Attributes/OptionNodeAttribute.cs | 80 + .../src/Core/Attributes/TargetAttribute.cs | 80 + Prebuild/src/Core/FatalException.cs | 94 + Prebuild/src/Core/Interfaces/IDataNode.cs | 56 + Prebuild/src/Core/Interfaces/ITarget.cs | 60 + Prebuild/src/Core/Kernel.cs | 758 ++ Prebuild/src/Core/Nodes/ConfigurationNode.cs | 177 + Prebuild/src/Core/Nodes/DataNode.cs | 82 + Prebuild/src/Core/Nodes/ExcludeNode.cs | 85 + Prebuild/src/Core/Nodes/FileNode.cs | 238 + Prebuild/src/Core/Nodes/FilesNode.cs | 222 + Prebuild/src/Core/Nodes/MatchNode.cs | 299 + Prebuild/src/Core/Nodes/OptionsNode.cs | 655 ++ Prebuild/src/Core/Nodes/ProcessNode.cs | 119 + Prebuild/src/Core/Nodes/ProjectNode.cs | 494 ++ Prebuild/src/Core/Nodes/ReferenceNode.cs | 143 + Prebuild/src/Core/Nodes/ReferencePathNode.cs | 98 + Prebuild/src/Core/Nodes/SolutionNode.cs | 284 + Prebuild/src/Core/Parse/IfContext.cs | 163 + Prebuild/src/Core/Parse/Preprocessor.cs | 519 ++ Prebuild/src/Core/Targets/AutotoolsTarget.cs | 926 +++ Prebuild/src/Core/Targets/DebugTarget.cs | 102 + .../src/Core/Targets/MonoDevelopTarget.cs | 458 ++ Prebuild/src/Core/Targets/NAntTarget.cs | 621 ++ .../src/Core/Targets/SharpDevelop2Target.cs | 90 + .../src/Core/Targets/SharpDevelopTarget.cs | 437 + Prebuild/src/Core/Targets/VS2002Target.cs | 96 + Prebuild/src/Core/Targets/VS2003Target.cs | 633 ++ Prebuild/src/Core/Targets/VS2005Target.cs | 883 ++ Prebuild/src/Core/UnknownLanguageException.cs | 63 + .../Core/Utilities/CommandLineCollection.cs | 162 + .../src/Core/Utilities/CurrentDirectory.cs | 89 + Prebuild/src/Core/Utilities/Helper.cs | 661 ++ Prebuild/src/Core/Utilities/Log.cs | 279 + Prebuild/src/Core/WarningException.cs | 93 + Prebuild/src/Prebuild.cs | 165 + Prebuild/src/Prebuild.csproj | 205 + Prebuild/src/Prebuild.csproj.user | 12 + Prebuild/src/Prebuild.exe.build | 80 + Prebuild/src/Prebuild.snk | Bin 0 -> 596 bytes Prebuild/src/Properties/AssemblyInfo.cs | 101 + Prebuild/src/data/dnpb-1.0.xsd | 183 + Prebuild/src/data/dnpb-1.1.xsd | 184 + Prebuild/src/data/dnpb-1.2.xsd | 198 + Prebuild/src/data/dnpb-1.3.xsd | 206 + Prebuild/src/data/dnpb-1.4.xsd | 212 + Prebuild/src/data/dnpb-1.5.xsd | 215 + Prebuild/src/data/prebuild-1.6.xsd | 231 + Prebuild/src/data/prebuild-1.7.xsd | 261 + README.txt | 116 + Servers/BaseHttpServer.cs | 224 + Servers/IRestHandler.cs | 8 + Servers/LocalUserProfileManager.cs | 109 + Servers/LoginResponse.cs | 398 + Servers/LoginServer.cs | 283 + Servers/OpenSim.Servers.csproj | 115 + Servers/OpenSim.Servers.csproj.user | 12 + Servers/OpenSim.Servers.dll.build | 48 + Servers/XmlRpcMethod.cs | 7 + bin/Axiom.MathLib.dll | Bin 0 -> 69632 bytes bin/Db4objects.Db4o.dll | Bin 0 -> 593408 bytes bin/Ode.NET.dll | Bin 0 -> 57344 bytes bin/OpenGrid.Config.GridConfigDb4o.dll | Bin 0 -> 20480 bytes bin/OpenUser.Config.UserConfigDb4o.dll | Bin 0 -> 20480 bytes bin/PhysX-wrapper.dll | Bin 0 -> 57344 bytes bin/PhysX_Wrapper_Dotnet.dll | Bin 0 -> 8704 bytes bin/Prebuild.exe | Bin 0 -> 176128 bytes bin/assets.yap | Bin 0 -> 2520896 bytes bin/assets/base_shape.dat | 105 + bin/assets/bricks.jp2 | Bin 0 -> 32865 bytes bin/assets/granite.jp2 | Bin 0 -> 32897 bytes bin/assets/hardwood.jp2 | Bin 0 -> 32876 bytes bin/assets/map_base.jp2 | Bin 0 -> 153 bytes bin/assets/plywood.jp2 | Bin 0 -> 32794 bytes bin/assets/rocks.jp2 | Bin 0 -> 32731 bytes bin/assets/testpic2.jp2 | Bin 0 -> 291 bytes bin/avatar-template.dat | Bin 0 -> 552 bytes bin/libode.a | Bin 0 -> 8041800 bytes bin/libode.so | Bin 0 -> 4474949 bytes bin/libsecondlife.dll | Bin 0 -> 2338816 bytes bin/localworld.yap | Bin 0 -> 8853 bytes bin/log4net.dll | Bin 0 -> 270336 bytes bin/login.htm | 5 + bin/new-login.dat | 1 + bin/newaccountform.htm | 9 + bin/ode.dll | Bin 0 -> 409600 bytes bin/testadmin.htm | 125 + prebuild.xml | 540 ++ 301 files changed, 41870 insertions(+) create mode 100644 OpenGrid.Config/GridConfigDb4o/AssemblyInfo.cs create mode 100644 OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs create mode 100644 OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.csproj create mode 100644 OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.csproj.user create mode 100644 OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.dll.build create mode 100644 OpenGridServices.GridServer/GridHttp.cs create mode 100644 OpenGridServices.GridServer/Main.cs create mode 100644 OpenGridServices.GridServer/OpenGridServices.GridServer.csproj create mode 100644 OpenGridServices.GridServer/OpenGridServices.GridServer.csproj.user create mode 100644 OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build create mode 100644 OpenGridServices.GridServer/Properties/AssemblyInfo.cs create mode 100644 OpenGridServices.GridServer/SimProfiles.cs create mode 100644 OpenGridServices.UserServer/Main.cs create mode 100644 OpenGridServices.UserServer/OGS-UserServer.csproj create mode 100644 OpenGridServices.UserServer/OGS-UserServer.csproj.user create mode 100644 OpenGridServices.UserServer/OpenGridServices.UserServer.csproj create mode 100644 OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user create mode 100644 OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build create mode 100644 OpenGridServices.UserServer/Properties/AssemblyInfo.cs create mode 100644 OpenGridServices.UserServer/UserHttp.cs create mode 100644 OpenSim.Framework.Console/AssemblyInfo.cs create mode 100644 OpenSim.Framework.Console/ConsoleBase.cs create mode 100644 OpenSim.Framework.Console/ConsoleCallbacksBase.cs create mode 100644 OpenSim.Framework.Console/MainConsole.cs create mode 100644 OpenSim.Framework.Console/OpenSim.Framework.Console.csproj create mode 100644 OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user create mode 100644 OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build create mode 100644 OpenSim.Framework/AgentCiruitData.cs create mode 100644 OpenSim.Framework/AgentInventory.cs create mode 100644 OpenSim.Framework/AssetBase.cs create mode 100644 OpenSim.Framework/BlockingQueue.cs create mode 100644 OpenSim.Framework/HeightMapGenHills.cs create mode 100644 OpenSim.Framework/IAssetServer.cs create mode 100644 OpenSim.Framework/IConfig.cs create mode 100644 OpenSim.Framework/IGenericConfig.cs create mode 100644 OpenSim.Framework/IGridConfig.cs create mode 100644 OpenSim.Framework/IGridServer.cs create mode 100644 OpenSim.Framework/ILocalStorage.cs create mode 100644 OpenSim.Framework/IScriptAPI.cs create mode 100644 OpenSim.Framework/IScriptEngine.cs create mode 100644 OpenSim.Framework/IUserConfig.cs create mode 100644 OpenSim.Framework/IUserServer.cs create mode 100644 OpenSim.Framework/LocalGridBase.cs create mode 100644 OpenSim.Framework/Login.cs create mode 100644 OpenSim.Framework/LoginService.cs create mode 100644 OpenSim.Framework/NeighbourInfo.cs create mode 100644 OpenSim.Framework/OSVector3.cs create mode 100644 OpenSim.Framework/OpenSim.Framework.csproj create mode 100644 OpenSim.Framework/OpenSim.Framework.csproj.user create mode 100644 OpenSim.Framework/OpenSim.Framework.dll.build create mode 100644 OpenSim.Framework/PrimData.cs create mode 100644 OpenSim.Framework/Properties/AssemblyInfo.cs create mode 100644 OpenSim.Framework/RemoteGridBase.cs create mode 100644 OpenSim.Framework/SimProfile.cs create mode 100644 OpenSim.Framework/SimProfileBase.cs create mode 100644 OpenSim.Framework/UserProfile.cs create mode 100644 OpenSim.Framework/UserProfileManager.cs create mode 100644 OpenSim.Framework/UserProfileManagerBase.cs create mode 100644 OpenSim.Framework/Util.cs create mode 100644 OpenSim.FxCop create mode 100644 OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj create mode 100644 OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user create mode 100644 OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build create mode 100644 OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs create mode 100644 OpenSim.GenericConfig/Xml/XmlConfig.cs create mode 100644 OpenSim.GridInterfaces/Local/AssemblyInfo.cs create mode 100644 OpenSim.GridInterfaces/Local/LocalAssetServer.cs create mode 100644 OpenSim.GridInterfaces/Local/LocalGridServer.cs create mode 100644 OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj create mode 100644 OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj.user create mode 100644 OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build create mode 100644 OpenSim.GridInterfaces/Remote/AssemblyInfo.cs create mode 100644 OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj create mode 100644 OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj.user create mode 100644 OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build create mode 100644 OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs create mode 100644 OpenSim.GridInterfaces/Remote/RemoteGridServer.cs create mode 100644 OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs create mode 100644 OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs create mode 100644 OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj create mode 100644 OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user create mode 100644 OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build create mode 100644 OpenSim.Physics/Manager/AssemblyInfo.cs create mode 100644 OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj create mode 100644 OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj.user create mode 100644 OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build create mode 100644 OpenSim.Physics/Manager/PhysicsActor.cs create mode 100644 OpenSim.Physics/Manager/PhysicsManager.cs create mode 100644 OpenSim.Physics/Manager/PhysicsScene.cs create mode 100644 OpenSim.Physics/Manager/PhysicsVector.cs create mode 100644 OpenSim.Physics/OdePlugin/AssemblyInfo.cs create mode 100644 OpenSim.Physics/OdePlugin/OdePlugin.cs create mode 100644 OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj create mode 100644 OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj.user create mode 100644 OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.dll.build create mode 100644 OpenSim.Physics/PhysXPlugin/AssemblyInfo.cs create mode 100644 OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj create mode 100644 OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj.user create mode 100644 OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build create mode 100644 OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs create mode 100644 OpenSim.RegionServer/AgentAssetUpload.cs create mode 100644 OpenSim.RegionServer/Assets/AssetCache.cs create mode 100644 OpenSim.RegionServer/Assets/InventoryCache.cs create mode 100644 OpenSim.RegionServer/CAPS/AdminWebFront.cs create mode 100644 OpenSim.RegionServer/ConsoleCmds.cs create mode 100644 OpenSim.RegionServer/Grid.cs create mode 100644 OpenSim.RegionServer/OpenSim.RegionServer.csproj create mode 100644 OpenSim.RegionServer/OpenSim.RegionServer.csproj.user create mode 100644 OpenSim.RegionServer/OpenSim.RegionServer.dll.build create mode 100644 OpenSim.RegionServer/OpenSim.csproj create mode 100644 OpenSim.RegionServer/OpenSim.exe.build create mode 100644 OpenSim.RegionServer/OpenSimMain.cs create mode 100644 OpenSim.RegionServer/OpenSimNetworkHandler.cs create mode 100644 OpenSim.RegionServer/PacketServer.cs create mode 100644 OpenSim.RegionServer/QueItem.cs create mode 100644 OpenSim.RegionServer/RegionInfo.cs create mode 100644 OpenSim.RegionServer/SimClient.cs create mode 100644 OpenSim.RegionServer/SimConsole.cs create mode 100644 OpenSim.RegionServer/VersionInfo.cs create mode 100644 OpenSim.RegionServer/types/Mesh.cs create mode 100644 OpenSim.RegionServer/types/Triangle.cs create mode 100644 OpenSim.RegionServer/world/Avatar.cs create mode 100644 OpenSim.RegionServer/world/AvatarAnimations.cs create mode 100644 OpenSim.RegionServer/world/AvatarClient.cs create mode 100644 OpenSim.RegionServer/world/AvatarUpdate.cs create mode 100644 OpenSim.RegionServer/world/Entity.cs create mode 100644 OpenSim.RegionServer/world/Primitive.cs create mode 100644 OpenSim.RegionServer/world/Primitive2.cs create mode 100644 OpenSim.RegionServer/world/ScriptEngine.cs create mode 100644 OpenSim.RegionServer/world/SurfacePatch.cs create mode 100644 OpenSim.RegionServer/world/World.cs create mode 100644 OpenSim.RegionServer/world/WorldPacketHandlers.cs create mode 100644 OpenSim.RegionServer/world/WorldScripting.cs create mode 100644 OpenSim.RegionServer/world/scripting/IScript.cs create mode 100644 OpenSim.RegionServer/world/scripting/IScriptContext.cs create mode 100644 OpenSim.RegionServer/world/scripting/IScriptEntity.cs create mode 100644 OpenSim.RegionServer/world/scripting/IScriptHandler.cs create mode 100644 OpenSim.RegionServer/world/scripting/Script.cs create mode 100644 OpenSim.RegionServer/world/scripting/ScriptFactory.cs create mode 100644 OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/ClassInstance.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/ClassRecord.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Heap.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Interpreter.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/InterpreterLogic.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/InterpreterMethods.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/InterpreterReturn.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/MainMemory.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/MethodMemory.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Object.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj create mode 100644 OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Properties/AssemblyInfo.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Stack.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/StackFrame.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Thread.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/ArrayReference.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/BaseType.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/ObjectReference.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Byte.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Char.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Float.cs create mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Int.cs create mode 100644 OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs create mode 100644 OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs create mode 100644 OpenSim.Storage/LocalStorageDb4o/MapStorage.cs create mode 100644 OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj create mode 100644 OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj.user create mode 100644 OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build create mode 100644 OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs create mode 100644 OpenSim.Terrain.BasicTerrain/Hills.cs create mode 100644 OpenSim.Terrain.BasicTerrain/Normalise.cs create mode 100644 OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj create mode 100644 OpenSim.Terrain.BasicTerrain/Properties/AssemblyInfo.cs create mode 100644 OpenSim.Terrain.BasicTerrain/RaiseLower.cs create mode 100644 OpenSim.Terrain.BasicTerrain/TerrainEngine.cs create mode 100644 OpenSim.build create mode 100644 OpenSim.sln create mode 100644 OpenSim.suo create mode 100644 OpenSim/Application.cs create mode 100644 OpenSim/OpenSim.csproj create mode 100644 OpenSim/OpenSim.csproj.user create mode 100644 OpenSim/OpenSim.exe.build create mode 100644 OpenUser.Config/UserConfigDb4o/AssemblyInfo.cs create mode 100644 OpenUser.Config/UserConfigDb4o/DbUserConfig.cs create mode 100644 OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.csproj create mode 100644 OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.csproj.user create mode 100644 OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.dll.build create mode 100644 Prebuild/Prebuild.build create mode 100644 Prebuild/Prebuild.sln create mode 100644 Prebuild/README create mode 100644 Prebuild/TODO create mode 100644 Prebuild/doc/prebuild-example1.xml create mode 100644 Prebuild/doc/prebuild-example2.xml create mode 100644 Prebuild/doc/prebuild-example3.xml create mode 100644 Prebuild/doc/prebuild-example4.xml create mode 100644 Prebuild/doc/prebuild-example5.xml create mode 100644 Prebuild/prebuild create mode 100644 Prebuild/scripts/Clean.bat create mode 100644 Prebuild/scripts/Help.bat create mode 100644 Prebuild/scripts/MonoDevelop.sh create mode 100644 Prebuild/scripts/Prebuild.nsi create mode 100644 Prebuild/scripts/SharpDevelop.bat create mode 100644 Prebuild/scripts/SharpDevelop2.bat create mode 100644 Prebuild/scripts/VS2002.bat create mode 100644 Prebuild/scripts/VS2003.bat create mode 100644 Prebuild/scripts/VS2005.bat create mode 100644 Prebuild/scripts/autotools.bat create mode 100644 Prebuild/scripts/autotools.sh create mode 100644 Prebuild/scripts/nant.bat create mode 100644 Prebuild/scripts/nant.sh create mode 100644 Prebuild/src/App.ico create mode 100644 Prebuild/src/Core/Attributes/DataNodeAttribute.cs create mode 100644 Prebuild/src/Core/Attributes/OptionNodeAttribute.cs create mode 100644 Prebuild/src/Core/Attributes/TargetAttribute.cs create mode 100644 Prebuild/src/Core/FatalException.cs create mode 100644 Prebuild/src/Core/Interfaces/IDataNode.cs create mode 100644 Prebuild/src/Core/Interfaces/ITarget.cs create mode 100644 Prebuild/src/Core/Kernel.cs create mode 100644 Prebuild/src/Core/Nodes/ConfigurationNode.cs create mode 100644 Prebuild/src/Core/Nodes/DataNode.cs create mode 100644 Prebuild/src/Core/Nodes/ExcludeNode.cs create mode 100644 Prebuild/src/Core/Nodes/FileNode.cs create mode 100644 Prebuild/src/Core/Nodes/FilesNode.cs create mode 100644 Prebuild/src/Core/Nodes/MatchNode.cs create mode 100644 Prebuild/src/Core/Nodes/OptionsNode.cs create mode 100644 Prebuild/src/Core/Nodes/ProcessNode.cs create mode 100644 Prebuild/src/Core/Nodes/ProjectNode.cs create mode 100644 Prebuild/src/Core/Nodes/ReferenceNode.cs create mode 100644 Prebuild/src/Core/Nodes/ReferencePathNode.cs create mode 100644 Prebuild/src/Core/Nodes/SolutionNode.cs create mode 100644 Prebuild/src/Core/Parse/IfContext.cs create mode 100644 Prebuild/src/Core/Parse/Preprocessor.cs create mode 100644 Prebuild/src/Core/Targets/AutotoolsTarget.cs create mode 100644 Prebuild/src/Core/Targets/DebugTarget.cs create mode 100644 Prebuild/src/Core/Targets/MonoDevelopTarget.cs create mode 100644 Prebuild/src/Core/Targets/NAntTarget.cs create mode 100644 Prebuild/src/Core/Targets/SharpDevelop2Target.cs create mode 100644 Prebuild/src/Core/Targets/SharpDevelopTarget.cs create mode 100644 Prebuild/src/Core/Targets/VS2002Target.cs create mode 100644 Prebuild/src/Core/Targets/VS2003Target.cs create mode 100644 Prebuild/src/Core/Targets/VS2005Target.cs create mode 100644 Prebuild/src/Core/UnknownLanguageException.cs create mode 100644 Prebuild/src/Core/Utilities/CommandLineCollection.cs create mode 100644 Prebuild/src/Core/Utilities/CurrentDirectory.cs create mode 100644 Prebuild/src/Core/Utilities/Helper.cs create mode 100644 Prebuild/src/Core/Utilities/Log.cs create mode 100644 Prebuild/src/Core/WarningException.cs create mode 100644 Prebuild/src/Prebuild.cs create mode 100644 Prebuild/src/Prebuild.csproj create mode 100644 Prebuild/src/Prebuild.csproj.user create mode 100644 Prebuild/src/Prebuild.exe.build create mode 100644 Prebuild/src/Prebuild.snk create mode 100644 Prebuild/src/Properties/AssemblyInfo.cs create mode 100644 Prebuild/src/data/dnpb-1.0.xsd create mode 100644 Prebuild/src/data/dnpb-1.1.xsd create mode 100644 Prebuild/src/data/dnpb-1.2.xsd create mode 100644 Prebuild/src/data/dnpb-1.3.xsd create mode 100644 Prebuild/src/data/dnpb-1.4.xsd create mode 100644 Prebuild/src/data/dnpb-1.5.xsd create mode 100644 Prebuild/src/data/prebuild-1.6.xsd create mode 100644 Prebuild/src/data/prebuild-1.7.xsd create mode 100644 README.txt create mode 100644 Servers/BaseHttpServer.cs create mode 100644 Servers/IRestHandler.cs create mode 100644 Servers/LocalUserProfileManager.cs create mode 100644 Servers/LoginResponse.cs create mode 100644 Servers/LoginServer.cs create mode 100644 Servers/OpenSim.Servers.csproj create mode 100644 Servers/OpenSim.Servers.csproj.user create mode 100644 Servers/OpenSim.Servers.dll.build create mode 100644 Servers/XmlRpcMethod.cs create mode 100644 bin/Axiom.MathLib.dll create mode 100644 bin/Db4objects.Db4o.dll create mode 100644 bin/Ode.NET.dll create mode 100644 bin/OpenGrid.Config.GridConfigDb4o.dll create mode 100644 bin/OpenUser.Config.UserConfigDb4o.dll create mode 100644 bin/PhysX-wrapper.dll create mode 100644 bin/PhysX_Wrapper_Dotnet.dll create mode 100644 bin/Prebuild.exe create mode 100644 bin/assets.yap create mode 100644 bin/assets/base_shape.dat create mode 100644 bin/assets/bricks.jp2 create mode 100644 bin/assets/granite.jp2 create mode 100644 bin/assets/hardwood.jp2 create mode 100644 bin/assets/map_base.jp2 create mode 100644 bin/assets/plywood.jp2 create mode 100644 bin/assets/rocks.jp2 create mode 100644 bin/assets/testpic2.jp2 create mode 100644 bin/avatar-template.dat create mode 100644 bin/libode.a create mode 100644 bin/libode.so create mode 100644 bin/libsecondlife.dll create mode 100644 bin/localworld.yap create mode 100644 bin/log4net.dll create mode 100644 bin/login.htm create mode 100644 bin/new-login.dat create mode 100644 bin/newaccountform.htm create mode 100644 bin/ode.dll create mode 100644 bin/testadmin.htm create mode 100644 prebuild.xml diff --git a/OpenGrid.Config/GridConfigDb4o/AssemblyInfo.cs b/OpenGrid.Config/GridConfigDb4o/AssemblyInfo.cs new file mode 100644 index 0000000000..b5065bc11e --- /dev/null +++ b/OpenGrid.Config/GridConfigDb4o/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("GridConfig")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("GridConfig")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs b/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs new file mode 100644 index 0000000000..10844675f0 --- /dev/null +++ b/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs @@ -0,0 +1,112 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using Db4objects.Db4o; + +namespace OpenGrid.Config.GridConfigDb4o +{ + public class Db40ConfigPlugin: IGridConfig + { + public GridConfig GetConfigObject() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Loading Db40Config dll"); + return ( new DbGridConfig()); + } + } + + public class DbGridConfig : GridConfig + { + private IObjectContainer db; + + public void LoadDefaults() { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); + + this.GridOwner = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid owner [OGS development team]: ", "OGS development team"); + + this.DefaultAssetServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default asset server [no default]: "); + this.AssetSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to asset server: "); + this.AssetRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from asset server: "); + + this.DefaultUserServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default user server [no default]: "); + this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server: "); + this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server: "); + + this.SimSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to sims: "); + this.SimRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from sims: "); + } + + public override void InitConfig() { + try { + db = Db4oFactory.OpenFile("opengrid.yap"); + IObjectSet result = db.Get(typeof(DbGridConfig)); + if(result.Count==1) { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Found a GridConfig object in the local database, loading"); + foreach (DbGridConfig cfg in result) { + this.GridOwner=cfg.GridOwner; + this.DefaultAssetServer=cfg.DefaultAssetServer; + this.AssetSendKey=cfg.AssetSendKey; + this.AssetRecvKey=cfg.AssetRecvKey; + this.DefaultUserServer=cfg.DefaultUserServer; + this.UserSendKey=cfg.UserSendKey; + this.UserRecvKey=cfg.UserRecvKey; + this.SimSendKey=cfg.SimSendKey; + this.SimRecvKey=cfg.SimRecvKey; + } + } else { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); + LoadDefaults(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Writing out default settings to local database"); + db.Set(this); + db.Close(); + } + } catch(Exception e) { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); + } + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid settings loaded:"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid owner: " + this.GridOwner); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Default asset server: " + this.DefaultAssetServer); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to asset server: " + this.AssetSendKey); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from asset server: " + this.AssetRecvKey); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Default user server: " + this.DefaultUserServer); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to user server: " + this.UserSendKey); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from user server: " + this.UserRecvKey); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to sims: " + this.SimSendKey); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from sims: " + this.SimRecvKey); + } + + + public void Shutdown() { + db.Close(); + } + } + +} diff --git a/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.csproj b/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.csproj new file mode 100644 index 0000000000..00d987b49e --- /dev/null +++ b/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.csproj @@ -0,0 +1,111 @@ + + + Local + 8.0.50727 + 2.0 + {B0027747-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenGrid.Config.GridConfigDb4o + JScript + Grid + IE50 + false + Library + + OpenGrid.Config.GridConfigDb4o + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + ..\..\bin\System.Data.dll + False + + + System.Xml.dll + False + + + ..\..\bin\libsecondlife.dll + False + + + ..\..\bin\Db4objects.Db4o.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + + + + + + + + diff --git a/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.csproj.user b/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.dll.build b/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.dll.build new file mode 100644 index 0000000000..73e09cee24 --- /dev/null +++ b/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.dll.build @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenGridServices.GridServer/GridHttp.cs b/OpenGridServices.GridServer/GridHttp.cs new file mode 100644 index 0000000000..4bc9ef0e96 --- /dev/null +++ b/OpenGridServices.GridServer/GridHttp.cs @@ -0,0 +1,229 @@ +/* +Copyright (c) OpenGrid project, http://osgrid.org/ + + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Text; +using Nwc.XmlRpc; +using System.Threading; +using System.Text.RegularExpressions; +using System.Net; +using System.Xml; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Console; + +namespace OpenGridServices.GridServer +{ + public class GridHTTPServer { + public Thread HTTPD; + public HttpListener Listener; + + public GridHTTPServer() { + MainConsole.Instance.WriteLine("Starting up HTTP Server"); + HTTPD = new Thread(new ThreadStart(StartHTTP)); + HTTPD.Start(); + } + + public void StartHTTP() { + MainConsole.Instance.WriteLine("GridHttp.cs:StartHTTP() - Spawned main thread OK"); + Listener = new HttpListener(); + + Listener.Prefixes.Add("http://+:8001/sims/"); + Listener.Prefixes.Add("http://+:8001/gods/"); + Listener.Prefixes.Add("http://+:8001/highestuuid/"); + Listener.Prefixes.Add("http://+:8001/uuidblocks/"); + Listener.Start(); + + MainConsole.Instance.WriteLine("GridHttp.cs:StartHTTP() - Successfully bound to port 8001"); + + HttpListenerContext context; + while(true) { + context = Listener.GetContext(); + ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); + } + } + + static string ParseXMLRPC(string requestBody, string referrer) { + try{ + XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); + + Hashtable requestData = (Hashtable)request.Params[0]; + switch(request.MethodName) { + case "simulator_login": + if(!(referrer=="simulator")) { + XmlRpcResponse ErrorResp = new XmlRpcResponse(); + Hashtable ErrorRespData = new Hashtable(); + ErrorRespData["error"]="Only simulators can login with this method"; + ErrorResp.Value=ErrorRespData; + return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(ErrorResp),"utf-16","utf-8")); + } + + if(!((string)requestData["authkey"]==OpenGrid_Main.thegrid.SimRecvKey)) { + XmlRpcResponse ErrorResp = new XmlRpcResponse(); + Hashtable ErrorRespData = new Hashtable(); + ErrorRespData["error"]="invalid key"; + ErrorResp.Value=ErrorRespData; + return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(ErrorResp),"utf-16","utf-8")); + } + + SimProfileBase TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByLLUUID(new LLUUID((string)requestData["UUID"])); + XmlRpcResponse SimLoginResp = new XmlRpcResponse(); + Hashtable SimLoginRespData = new Hashtable(); + + ArrayList SimNeighboursData = new ArrayList(); + + SimProfileBase neighbour; + Hashtable NeighbourBlock; + for(int x=-1; x<2; x++) for(int y=-1; y<2; y++) { + if(OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle(Helpers.UIntsToLong((uint)((TheSim.RegionLocX+x)*256), (uint)(TheSim.RegionLocY+y)*256))!=null) { + neighbour=OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle(Helpers.UIntsToLong((uint)((TheSim.RegionLocX+x)*256), (uint)(TheSim.RegionLocY+y)*256)); + NeighbourBlock = new Hashtable(); + NeighbourBlock["sim_ip"] = neighbour.sim_ip; + NeighbourBlock["sim_port"] = neighbour.sim_port.ToString(); + NeighbourBlock["region_locx"] = neighbour.RegionLocX.ToString(); + NeighbourBlock["region_locy"] = neighbour.RegionLocY.ToString(); + NeighbourBlock["UUID"] = neighbour.UUID.ToString(); + SimNeighboursData.Add(NeighbourBlock); + } + } + + SimLoginRespData["region_locx"]=TheSim.RegionLocX.ToString(); + SimLoginRespData["region_locy"]=TheSim.RegionLocY.ToString(); + SimLoginRespData["regionname"]=TheSim.regionname; + SimLoginRespData["estate_id"]="1"; + SimLoginRespData["neighbours"]=SimNeighboursData; + SimLoginRespData["asset_url"]=OpenGrid_Main.thegrid.DefaultAssetServer; + SimLoginRespData["asset_sendkey"]=OpenGrid_Main.thegrid.AssetSendKey; + SimLoginRespData["asset_recvkey"]=OpenGrid_Main.thegrid.AssetRecvKey; + SimLoginRespData["user_url"]=OpenGrid_Main.thegrid.DefaultUserServer; + SimLoginRespData["user_sendkey"]=OpenGrid_Main.thegrid.UserSendKey; + SimLoginRespData["user_recvkey"]=OpenGrid_Main.thegrid.UserRecvKey; + SimLoginRespData["authkey"]=OpenGrid_Main.thegrid.SimSendKey; + SimLoginResp.Value=SimLoginRespData; + return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(SimLoginResp),"utf-16","utf-8")); + break; + } + } catch(Exception e) { + Console.WriteLine(e.ToString()); + } + return ""; + } + + static string ParseREST(string requestBody, string requestURL, string HTTPmethod) { + char[] splitter = {'/'}; + string[] rest_params = requestURL.Split(splitter); + string req_type = rest_params[0]; // First part of the URL is the type of request - + string respstring; + switch(req_type) { + case "sims": + LLUUID UUID = new LLUUID((string)rest_params[1]); + SimProfileBase TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByLLUUID(UUID); + if(!(TheSim==null)) { + switch(HTTPmethod) { + case "GET": + respstring="" + OpenGrid_Main.thegrid.SimSendKey + ""; + respstring+=""; + respstring+="" + TheSim.UUID.ToString() + ""; + respstring+="" + TheSim.regionname + ""; + respstring+="" + TheSim.sim_ip + ""; + respstring+="" + TheSim.sim_port.ToString() + ""; + respstring+="" + TheSim.RegionLocX.ToString() + ""; + respstring+="" + TheSim.RegionLocY.ToString() + ""; + respstring+="1"; + respstring+=""; + break; + case "POST": + XmlDocument doc = new XmlDocument(); + doc.LoadXml(requestBody); + XmlNode authkeynode = doc.FirstChild; + if (authkeynode.Name != "authkey") + respstring = "bad XML - expected authkey tag"; + XmlNode simnode = doc.ChildNodes[1]; + if (simnode.Name != "sim") + respstring = "bad XML - expected sim tag"; + + break; + } + } + break; + } + return ""; + + } + + + static void HandleRequest(Object stateinfo) { + HttpListenerContext context=(HttpListenerContext)stateinfo; + + HttpListenerRequest request = context.Request; + HttpListenerResponse response = context.Response; + + response.KeepAlive=false; + response.SendChunked=false; + + System.IO.Stream body = request.InputStream; + System.Text.Encoding encoding = System.Text.Encoding.UTF8; + System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); + + string requestBody = reader.ReadToEnd(); + body.Close(); + reader.Close(); + + // TODO: AUTHENTICATION!!!!!!!!! MUST ADD!!!!!!!!!! SCRIPT KIDDIES LOVE LACK OF IT!!!!!!!!!! + + string responseString=""; + switch(request.ContentType) { + case "text/xml": + // must be XML-RPC, so pass to the XML-RPC parser + + responseString=ParseXMLRPC(requestBody,request.Headers["Referer"]); + response.AddHeader("Content-type","text/xml"); + break; + + case null: + // must be REST or invalid crap, so pass to the REST parser + responseString=ParseREST(request.Url.OriginalString,requestBody,request.HttpMethod); + break; + } + + + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); + System.IO.Stream output = response.OutputStream; + response.SendChunked=false; + response.ContentLength64=buffer.Length; + output.Write(buffer,0,buffer.Length); + output.Close(); + } + } + + +} diff --git a/OpenGridServices.GridServer/Main.cs b/OpenGridServices.GridServer/Main.cs new file mode 100644 index 0000000000..192b10c0b8 --- /dev/null +++ b/OpenGridServices.GridServer/Main.cs @@ -0,0 +1,189 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.IO; +using System.Text; +using System.Timers; +using System.Net; +using System.Reflection; +using libsecondlife; +using OpenSim.Framework; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; + +namespace OpenGridServices.GridServer +{ + /// + /// + public class OpenGrid_Main : conscmd_callback + { + private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll"; + private GridConfig Cfg; + public static OpenGrid_Main thegrid; + public string GridOwner; + public string DefaultStartupMsg; + public string DefaultAssetServer; + public string AssetSendKey; + public string AssetRecvKey; + public string DefaultUserServer; + public string UserSendKey; + public string UserRecvKey; + public string SimSendKey; + public string SimRecvKey; + public LLUUID highestUUID; + + public GridHTTPServer _httpd; + public SimProfileManager _regionmanager; + + private ConsoleBase m_console; + private Timer SimCheckTimer; + + [STAThread] + public static void Main(string[] args) + { + Console.WriteLine("Starting...\n"); + + thegrid = new OpenGrid_Main(); + thegrid.Startup(); + + thegrid.Work(); + } + + private void Work() + { + m_console.WriteLine("\nEnter help for a list of commands\n"); + + while (true) + { + m_console.MainConsolePrompt(); + } + } + + private OpenGrid_Main() + { + m_console = new ConsoleBase("opengrid-gridserver-console.log", "OpenGrid", this); + MainConsole.Instance = m_console; + } + + public void Startup() + { + m_console.WriteLine("Main.cs:Startup() - Loading configuration"); + Cfg = this.LoadConfigDll(this.ConfigDll); + Cfg.InitConfig(); + + m_console.WriteLine("Main.cs:Startup() - Loading sim profiles from database"); + this._regionmanager = new SimProfileManager(); + _regionmanager.LoadProfiles(); + + m_console.WriteLine("Main.cs:Startup() - Starting HTTP process"); + _httpd = new GridHTTPServer(); + + m_console.WriteLine("Main.cs:Startup() - Starting sim status checker"); + SimCheckTimer = new Timer(); + SimCheckTimer.Interval = 300000; // 5 minutes + SimCheckTimer.Elapsed+=new ElapsedEventHandler(CheckSims); + SimCheckTimer.Enabled=true; + } + + private GridConfig LoadConfigDll(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + GridConfig config = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IGridConfig", true); + + if (typeInterface != null) + { + IGridConfig plug = (IGridConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + config = plug.GetConfigObject(); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + return config; + } + + public void CheckSims(object sender, ElapsedEventArgs e) { + foreach(SimProfileBase sim in _regionmanager.SimProfiles.Values) { + string SimResponse=""; + try { + WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/"); + CheckSim.Method = "GET"; + CheckSim.ContentType = "text/plaintext"; + CheckSim.ContentLength = 0; + + StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII); + stOut.Write(""); + stOut.Close(); + + StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream()); + SimResponse = stIn.ReadToEnd(); + stIn.Close(); + } catch(Exception exception) { + } + if(SimResponse=="OK") { + _regionmanager.SimProfiles[sim.UUID].online=true; + } else { + _regionmanager.SimProfiles[sim.UUID].online=false; + } + } + } + + public void RunCmd(string cmd, string[] cmdparams) + { + switch (cmd) + { + case "help": + m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)"); + break; + + case "shutdown": + m_console.Close(); + Environment.Exit(0); + break; + } + } + + public void Show(string ShowWhat) + { + } + } +} diff --git a/OpenGridServices.GridServer/OpenGridServices.GridServer.csproj b/OpenGridServices.GridServer/OpenGridServices.GridServer.csproj new file mode 100644 index 0000000000..836a98b8f0 --- /dev/null +++ b/OpenGridServices.GridServer/OpenGridServices.GridServer.csproj @@ -0,0 +1,117 @@ + + + Local + 8.0.50727 + 2.0 + {21BFC8E2-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenGridServices.GridServer + JScript + Grid + IE50 + false + Exe + + OpenGridServices.GridServer + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Data.dll + False + + + System.Xml.dll + False + + + ..\bin\libsecondlife.dll + False + + + ..\bin\Db4objects.Db4o.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenGridServices.GridServer/OpenGridServices.GridServer.csproj.user b/OpenGridServices.GridServer/OpenGridServices.GridServer.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenGridServices.GridServer/OpenGridServices.GridServer.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build b/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build new file mode 100644 index 0000000000..111e2f7213 --- /dev/null +++ b/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenGridServices.GridServer/Properties/AssemblyInfo.cs b/OpenGridServices.GridServer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..8471e6b067 --- /dev/null +++ b/OpenGridServices.GridServer/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OGS-GridServer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OGS-GridServer")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenGridServices.GridServer/SimProfiles.cs b/OpenGridServices.GridServer/SimProfiles.cs new file mode 100644 index 0000000000..7aff4342e4 --- /dev/null +++ b/OpenGridServices.GridServer/SimProfiles.cs @@ -0,0 +1,142 @@ +/* +Copyright (c) OpenGrid project, http://osgrid.org/ + + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Console; +using OpenSim.Framework.Sims; +using Db4objects.Db4o; + +namespace OpenGridServices.GridServer +{ + /// + /// + public class SimProfileManager { + + public Dictionary SimProfiles = new Dictionary(); + + public SimProfileManager() { + } + + public void LoadProfiles() { // should abstract this out + IObjectContainer db; + db = Db4oFactory.OpenFile("simprofiles.yap"); + IObjectSet result = db.Get(typeof(SimProfileBase)); + foreach (SimProfileBase simprof in result) { + SimProfiles.Add(simprof.UUID, simprof); + } + MainConsole.Instance.WriteLine("SimProfiles.Cs:LoadProfiles() - Successfully loaded " + result.Count.ToString() + " from database"); + db.Close(); + } + + public SimProfileBase GetProfileByHandle(ulong reqhandle) { + foreach (libsecondlife.LLUUID UUID in SimProfiles.Keys) { + if(SimProfiles[UUID].regionhandle==reqhandle) return SimProfiles[UUID]; + } + return null; + } + + public SimProfileBase GetProfileByLLUUID(LLUUID ProfileLLUUID) { + return SimProfiles[ProfileLLUUID]; + } + + public bool AuthenticateSim(LLUUID RegionUUID, uint regionhandle, string simrecvkey) { + SimProfileBase TheSim=GetProfileByHandle(regionhandle); + if(TheSim != null) + if(TheSim.recvkey==simrecvkey) { + return true; + } else { + return false; + } else return false; + + } + + public string GetXMLNeighbours(ulong reqhandle) { + string response=""; + SimProfileBase central_region = GetProfileByHandle(reqhandle); + SimProfileBase neighbour; + for(int x=-1; x<2; x++) for(int y=-1; y<2; y++) { + if(GetProfileByHandle(Util.UIntsToLong((uint)((central_region.RegionLocX+x)*256), (uint)(central_region.RegionLocY+y)*256))!=null) { + neighbour=GetProfileByHandle(Util.UIntsToLong((uint)((central_region.RegionLocX+x)*256), (uint)(central_region.RegionLocY+y)*256)); + response+=""; + response+="" + neighbour.sim_ip + ""; + response+="" + neighbour.sim_port.ToString() + ""; + response+="" + neighbour.RegionLocX.ToString() + ""; + response+="" + neighbour.RegionLocY.ToString() + ""; + response+="" + neighbour.regionhandle.ToString() + ""; + response+=""; + + } + } + return response; + } + + public SimProfileBase CreateNewProfile(string regionname, string caps_url, string sim_ip, uint sim_port, uint RegionLocX, uint RegionLocY, string sendkey, string recvkey) { + SimProfileBase newprofile = new SimProfileBase(); + newprofile.regionname=regionname; + newprofile.sim_ip=sim_ip; + newprofile.sim_port=sim_port; + newprofile.RegionLocX=RegionLocX; + newprofile.RegionLocY=RegionLocY; + newprofile.caps_url="http://" + sim_ip + ":9000/"; + newprofile.sendkey=sendkey; + newprofile.recvkey=recvkey; + newprofile.regionhandle=Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); + newprofile.UUID=LLUUID.Random(); + this.SimProfiles.Add(newprofile.UUID,newprofile); + return newprofile; + } + + } + + /* is in OpenSim.Framework + public class SimProfileBase { + public LLUUID UUID; + public ulong regionhandle; + public string regionname; + public string sim_ip; + public uint sim_port; + public string caps_url; + public uint RegionLocX; + public uint RegionLocY; + public string sendkey; + public string recvkey; + + + public SimProfileBase() { + } + + + }*/ + +} diff --git a/OpenGridServices.UserServer/Main.cs b/OpenGridServices.UserServer/Main.cs new file mode 100644 index 0000000000..999d446dd1 --- /dev/null +++ b/OpenGridServices.UserServer/Main.cs @@ -0,0 +1,176 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.IO; +using System.Text; +using libsecondlife; +using OpenSim.Framework.User; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Console; + +namespace OpenGridServices.UserServer +{ + /// + /// + public class OpenUser_Main : conscmd_callback + { + private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll"; + private UserConfig Cfg; + + public static OpenUser_Main userserver; + + public UserHTTPServer _httpd; + public UserProfileManager _profilemanager; + + public Dictionary UserSessions = new Dictionary(); + + ConsoleBase m_console; + + [STAThread] + public static void Main( string[] args ) + { + Console.WriteLine("Starting...\n"); + + userserver = new OpenUser_Main(); + userserver.Startup(); + + userserver.Work(); + } + + private OpenUser_Main() + { + m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this); + MainConsole.Instance = m_console; + } + + private void Work() + { + m_console.WriteLine("\nEnter help for a list of commands\n"); + + while (true) + { + m_console.MainConsolePrompt(); + } + } + + public void Startup() { + MainConsole.Instance.WriteLine("Main.cs:Startup() - Loading configuration"); + Cfg = this.LoadConfigDll(this.ConfigDll); + Cfg.InitConfig(); + + MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager"); + _profilemanager = new UserProfileManager(); + _profilemanager.InitUserProfiles(); + _profilemanager.SetKeys(Cfg.GridSendKey, Cfg.GridRecvKey, Cfg.GridServerURL, Cfg.DefaultStartupMsg); + + MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process"); + _httpd = new UserHTTPServer(); + } + + public void RunCmd(string cmd, string[] cmdparams) + { + switch (cmd) + { + case "help": + m_console.WriteLine("create user - create a new user"); + m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)"); + break; + + case "create user": + m_console.WriteLine("Creating new user profile"); + string tempfirstname; + string templastname; + string tempMD5Passwd; + + tempfirstname=m_console.CmdPrompt("First name: "); + templastname=m_console.CmdPrompt("Last name: "); + tempMD5Passwd=m_console.PasswdPrompt("Password: "); + + System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider(); + byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd); + bs = x.ComputeHash(bs); + System.Text.StringBuilder s = new System.Text.StringBuilder(); + foreach (byte b in bs) + { + s.Append(b.ToString("x2").ToLower()); + } + tempMD5Passwd = "$1$" + s.ToString(); + + UserProfile newuser=_profilemanager.CreateNewProfile(tempfirstname,templastname,tempMD5Passwd); + newuser.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f); + newuser.homepos = new LLVector3(128f,128f,23f); + _profilemanager.SaveUserProfiles(); + break; + + case "shutdown": + m_console.Close(); + Environment.Exit(0); + break; + } + } + + private UserConfig LoadConfigDll(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + UserConfig config = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IUserConfig", true); + + if (typeInterface != null) + { + IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + config = plug.GetConfigObject(); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + return config; + } + + public void Show(string ShowWhat) + { + } + } +} diff --git a/OpenGridServices.UserServer/OGS-UserServer.csproj b/OpenGridServices.UserServer/OGS-UserServer.csproj new file mode 100644 index 0000000000..f4fa8b6403 --- /dev/null +++ b/OpenGridServices.UserServer/OGS-UserServer.csproj @@ -0,0 +1,63 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {D45B6E48-5668-478D-B9CB-6D46E665FACF} + Exe + Properties + OGS_UserServer + OGS-UserServer + OpenGridServices.OpenUser_Main + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\common\bin\libsecondlife.dll + + + + + + + + OGS-Console.cs + + + VersionInfo.cs + + + + + + + + + {2E46A825-3168-492F-93BC-637126B5B72B} + OpenSim.Framework + + + {7667E6E2-F227-41A2-B1B2-315613E1BAFC} + ServerConsole + + + + \ No newline at end of file diff --git a/OpenGridServices.UserServer/OGS-UserServer.csproj.user b/OpenGridServices.UserServer/OGS-UserServer.csproj.user new file mode 100644 index 0000000000..aa75a3df42 --- /dev/null +++ b/OpenGridServices.UserServer/OGS-UserServer.csproj.user @@ -0,0 +1,8 @@ + + + publish\ + 0 + en-US + false + + \ No newline at end of file diff --git a/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj b/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj new file mode 100644 index 0000000000..95f548cb5f --- /dev/null +++ b/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj @@ -0,0 +1,114 @@ + + + Local + 8.0.50727 + 2.0 + {66591469-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenGridServices.UserServer + JScript + Grid + IE50 + false + Exe + + OpenGridServices.UserServer + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Data.dll + False + + + System.Xml.dll + False + + + ..\bin\libsecondlife.dll + False + + + ..\bin\Db4objects.Db4o.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user b/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build b/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build new file mode 100644 index 0000000000..fd1be1543a --- /dev/null +++ b/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenGridServices.UserServer/Properties/AssemblyInfo.cs b/OpenGridServices.UserServer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..5d5ce8d1cf --- /dev/null +++ b/OpenGridServices.UserServer/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OGS-UserServer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OGS-UserServer")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e266513a-090b-4d38-80f6-8599eef68c8c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenGridServices.UserServer/UserHttp.cs b/OpenGridServices.UserServer/UserHttp.cs new file mode 100644 index 0000000000..6fe7fc105b --- /dev/null +++ b/OpenGridServices.UserServer/UserHttp.cs @@ -0,0 +1,157 @@ +/* +Copyright (c) OpenGrid project, http://osgrid.org/ + + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Text; +using Nwc.XmlRpc; +using System.Threading; +using System.Text.RegularExpressions; +using System.Net; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.User; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Console; + +namespace OpenGridServices.UserServer +{ + public class UserHTTPServer + { + public Thread HTTPD; + public HttpListener Listener; + + public UserHTTPServer() + { + MainConsole.Instance.WriteLine("Starting up HTTP Server"); + HTTPD = new Thread(new ThreadStart(StartHTTP)); + HTTPD.Start(); + } + + public void StartHTTP() + { + MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK"); + Listener = new HttpListener(); + + Listener.Prefixes.Add("http://+:8002/userserver/"); + Listener.Prefixes.Add("http://+:8002/usersessions/"); + Listener.Start(); + + HttpListenerContext context; + while (true) + { + context = Listener.GetContext(); + ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); + } + } + + static string ParseXMLRPC(string requestBody) + { + return OpenUser_Main.userserver._profilemanager.ParseXMLRPC(requestBody); + } + + static string ParseREST(HttpListenerRequest www_req) + { + Console.WriteLine("INCOMING REST - " + www_req.RawUrl); + + char[] splitter = { '/' }; + string[] rest_params = www_req.RawUrl.Split(splitter); + string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla + switch (req_type) + { + case "usersessions": + LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid + if (www_req.HttpMethod == "DELETE") + { + foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys) + { + if (OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID == sessionid) + { + OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID = null; + OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID = null; + OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear(); + } + } + + } + return "OK"; + } + + return ""; + } + + + static void HandleRequest(Object stateinfo) + { + HttpListenerContext context = (HttpListenerContext)stateinfo; + + HttpListenerRequest request = context.Request; + HttpListenerResponse response = context.Response; + + response.KeepAlive = false; + response.SendChunked = false; + + System.IO.Stream body = request.InputStream; + System.Text.Encoding encoding = System.Text.Encoding.UTF8; + System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); + + string requestBody = reader.ReadToEnd(); + body.Close(); + reader.Close(); + + string responseString = ""; + switch (request.ContentType) + { + case "text/xml": + // must be XML-RPC, so pass to the XML-RPC parser + + responseString = ParseXMLRPC(requestBody); + response.AddHeader("Content-type", "text/xml"); + break; + + case "text/plaintext": + responseString = ParseREST(request); + response.AddHeader("Content-type", "text/plaintext"); + break; + } + + + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); + System.IO.Stream output = response.OutputStream; + response.SendChunked = false; + response.ContentLength64 = buffer.Length; + output.Write(buffer, 0, buffer.Length); + output.Close(); + } + } + + +} diff --git a/OpenSim.Framework.Console/AssemblyInfo.cs b/OpenSim.Framework.Console/AssemblyInfo.cs new file mode 100644 index 0000000000..00a9b7d748 --- /dev/null +++ b/OpenSim.Framework.Console/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("ServerConsole")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ServerConsole")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.Framework.Console/ConsoleBase.cs b/OpenSim.Framework.Console/ConsoleBase.cs new file mode 100644 index 0000000000..e2e4457deb --- /dev/null +++ b/OpenSim.Framework.Console/ConsoleBase.cs @@ -0,0 +1,151 @@ +using System; +using System.IO; + +namespace OpenSim.Framework.Console +{ + public class ConsoleBase + { + StreamWriter Log; + public conscmd_callback cmdparser; + public string componentname; + + // STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!! + // constype - the type of console to use (see enum ConsoleType) + // sparam - depending on the console type: + // TCP - the IP to bind to (127.0.0.1 if blank) + // Local - param ignored + // and for the iparam: + // TCP - the port to bind to + // Local - param ignored + // LogFile - duh + // componentname - which component of the OGS system? (user, asset etc) + // cmdparser - a reference to a conscmd_callback object + + public ConsoleBase(string LogFile, string componentname, conscmd_callback cmdparser) + { + this.componentname = componentname; + this.cmdparser = cmdparser; + + System.Console.WriteLine("ServerConsole.cs - creating new local console"); + System.Console.WriteLine("Logs will be saved to current directory in " + LogFile); + Log = File.AppendText(LogFile); + Log.WriteLine("========================================================================"); + Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString()); + } + + public void Close() + { + Log.WriteLine("Shutdown at " + DateTime.Now.ToString()); + Log.Close(); + } + + public void Write(string format, params object[] args) + { + Log.Write(format, args); + System.Console.Write(format, args); + return; + } + + public void WriteLine(string format, params object[] args) + { + Log.WriteLine(format, args); + System.Console.WriteLine(format, args); + return; + } + + public string ReadLine() + { + string TempStr = System.Console.ReadLine(); + Log.WriteLine(TempStr); + return TempStr; + } + + public int Read() + { + int TempInt = System.Console.Read(); + Log.Write((char)TempInt); + return TempInt; + } + + // Displays a prompt and waits for the user to enter a string, then returns that string + // Done with no echo and suitable for passwords + public string PasswdPrompt(string prompt) + { + // FIXME: Needs to be better abstracted + Log.WriteLine(prompt); + this.Write(prompt); + ConsoleColor oldfg = System.Console.ForegroundColor; + System.Console.ForegroundColor = System.Console.BackgroundColor; + string temp = System.Console.ReadLine(); + System.Console.ForegroundColor = oldfg; + return temp; + } + + // Displays a command prompt and waits for the user to enter a string, then returns that string + public string CmdPrompt(string prompt) + { + this.Write(prompt); + return this.ReadLine(); + } + + // Displays a command prompt and returns a default value if the user simply presses enter + public string CmdPrompt(string prompt, string defaultresponse) + { + string temp = CmdPrompt(prompt); + if (temp == "") + { + return defaultresponse; + } + else + { + return temp; + } + } + + // Displays a command prompt and returns a default value, user may only enter 1 of 2 options + public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) + { + bool itisdone = false; + string temp = CmdPrompt(prompt, defaultresponse); + while (itisdone == false) + { + if ((temp == OptionA) || (temp == OptionB)) + { + itisdone = true; + } + else + { + this.WriteLine("Valid options are " + OptionA + " or " + OptionB); + temp = CmdPrompt(prompt, defaultresponse); + } + } + return temp; + } + + // Runs a command with a number of parameters + public Object RunCmd(string Cmd, string[] cmdparams) + { + cmdparser.RunCmd(Cmd, cmdparams); + return null; + } + + // Shows data about something + public void ShowCommands(string ShowWhat) + { + cmdparser.Show(ShowWhat); + } + + public void MainConsolePrompt() + { + string[] tempstrarray; + string tempstr = this.CmdPrompt(this.componentname + "# "); + tempstrarray = tempstr.Split(' '); + string cmd = tempstrarray[0]; + Array.Reverse(tempstrarray); + Array.Resize(ref tempstrarray, tempstrarray.Length - 1); + Array.Reverse(tempstrarray); + string[] cmdparams = (string[])tempstrarray; + RunCmd(cmd, cmdparams); + } + } +} diff --git a/OpenSim.Framework.Console/ConsoleCallbacksBase.cs b/OpenSim.Framework.Console/ConsoleCallbacksBase.cs new file mode 100644 index 0000000000..bb589d2b92 --- /dev/null +++ b/OpenSim.Framework.Console/ConsoleCallbacksBase.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Console +{ + public interface conscmd_callback + { + void RunCmd(string cmd, string[] cmdparams); + void Show(string ShowWhat); + } +} diff --git a/OpenSim.Framework.Console/MainConsole.cs b/OpenSim.Framework.Console/MainConsole.cs new file mode 100644 index 0000000000..02c4ae89f0 --- /dev/null +++ b/OpenSim.Framework.Console/MainConsole.cs @@ -0,0 +1,48 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; + +namespace OpenSim.Framework.Console +{ + public class MainConsole { + + private static ConsoleBase instance; + + public static ConsoleBase Instance + { + get + { + return instance; + } + set + { + instance = value; + } + } + } + +} diff --git a/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj b/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj new file mode 100644 index 0000000000..096149217b --- /dev/null +++ b/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj @@ -0,0 +1,89 @@ + + + Local + 8.0.50727 + 2.0 + {A7CD0630-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Framework.Console + JScript + Grid + IE50 + false + Library + + OpenSim.Framework.Console + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + + + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user b/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build b/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build new file mode 100644 index 0000000000..a3019ee83e --- /dev/null +++ b/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Framework/AgentCiruitData.cs b/OpenSim.Framework/AgentCiruitData.cs new file mode 100644 index 0000000000..461d962da7 --- /dev/null +++ b/OpenSim.Framework/AgentCiruitData.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public class AgentCircuitData + { + public AgentCircuitData() { } + public LLUUID AgentID; + public LLUUID SessionID; + public LLUUID SecureSessionID; + public string firstname; + public string lastname; + public uint circuitcode; + public bool child; + } +} diff --git a/OpenSim.Framework/AgentInventory.cs b/OpenSim.Framework/AgentInventory.cs new file mode 100644 index 0000000000..9919ec3d90 --- /dev/null +++ b/OpenSim.Framework/AgentInventory.cs @@ -0,0 +1,242 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Assets; + +namespace OpenSim.Framework.Inventory +{ + public class AgentInventory + { + //Holds the local copy of Inventory info for a agent + public Dictionary InventoryFolders; + public Dictionary InventoryItems; + public InventoryFolder InventoryRoot = new InventoryFolder(); + public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server + public LLUUID AgentID; + public AvatarWearable[] Wearables; + + public AgentInventory() + { + InventoryFolders = new Dictionary(); + InventoryItems = new Dictionary(); + this.Initialise(); + } + + public virtual void Initialise() + { + Wearables = new AvatarWearable[13]; //should be 12 of these + for (int i = 0; i < 13; i++) + { + Wearables[i] = new AvatarWearable(); + } + + InventoryRoot = new InventoryFolder(); + InventoryRoot.FolderID = LLUUID.Random(); + InventoryRoot.ParentID = LLUUID.Zero; + InventoryRoot.Version = 1; + InventoryRoot.DefaultType = 8; + InventoryRoot.OwnerID = this.AgentID; + InventoryRoot.FolderName = "My Inventory"; + InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot); + } + + public bool CreateNewFolder(LLUUID folderID, ushort type) + { + InventoryFolder Folder = new InventoryFolder(); + Folder.FolderID = folderID; + Folder.OwnerID = this.AgentID; + Folder.DefaultType = type; + this.InventoryFolders.Add(Folder.FolderID, Folder); + return (true); + } + + public void CreateRootFolder(LLUUID newAgentID, bool createTextures) + { + this.AgentID = newAgentID; + /* InventoryRoot = new InventoryFolder(); + InventoryRoot.FolderID = LLUUID.Random(); + InventoryRoot.ParentID = new LLUUID(); + InventoryRoot.Version = 1; + InventoryRoot.DefaultType = 8; + InventoryRoot.OwnerID = this.AgentID; + InventoryRoot.FolderName = "My Inventory-"; + InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);*/ + InventoryRoot.OwnerID = this.AgentID; + if (createTextures) + { + this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID); + } + } + + public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName) + { + InventoryFolder Folder = new InventoryFolder(); + Folder.FolderID = folderID; + Folder.OwnerID = this.AgentID; + Folder.DefaultType = type; + Folder.FolderName = folderName; + this.InventoryFolders.Add(Folder.FolderID, Folder); + + return (true); + } + + public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parent) + { + Console.WriteLine("creating new folder called " + folderName + " in agents inventory"); + InventoryFolder Folder = new InventoryFolder(); + Folder.FolderID = folderID; + Folder.OwnerID = this.AgentID; + Folder.DefaultType = type; + Folder.FolderName = folderName; + Folder.ParentID = parent; + this.InventoryFolders.Add(Folder.FolderID, Folder); + + return (true); + } + + public bool HasFolder(LLUUID folderID) + { + if (this.InventoryFolders.ContainsKey(folderID)) + { + return true; + } + return false; + } + + public bool UpdateItemAsset(LLUUID itemID, AssetBase asset) + { + if(this.InventoryItems.ContainsKey(itemID)) + { + InventoryItem Item = this.InventoryItems[itemID]; + Item.AssetID = asset.FullID; + Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated()); + //TODO need to update the rest of the info + } + return true; + } + + public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet) + { + Console.WriteLine("updating inventory item details"); + if (this.InventoryItems.ContainsKey(itemID)) + { + Console.WriteLine("changing name to "+ Helpers.FieldToString(packet.Name)); + InventoryItem Item = this.InventoryItems[itemID]; + Item.Name = Helpers.FieldToString(packet.Name); + Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated()); + //TODO need to update the rest of the info + } + return true; + } + + public LLUUID AddToInventory(LLUUID folderID, AssetBase asset) + { + if (this.InventoryFolders.ContainsKey(folderID)) + { + LLUUID NewItemID = LLUUID.Random(); + + InventoryItem Item = new InventoryItem(); + Item.FolderID = folderID; + Item.OwnerID = AgentID; + Item.AssetID = asset.FullID; + Item.ItemID = NewItemID; + Item.Type = asset.Type; + Item.Name = asset.Name; + Item.Description = asset.Description; + Item.InvType = asset.InvType; + this.InventoryItems.Add(Item.ItemID, Item); + InventoryFolder Folder = InventoryFolders[Item.FolderID]; + Folder.Items.Add(Item); + return (Item.ItemID); + } + else + { + return (null); + } + } + + public bool DeleteFromInventory(LLUUID itemID) + { + bool res = false; + if (this.InventoryItems.ContainsKey(itemID)) + { + InventoryItem item = this.InventoryItems[itemID]; + this.InventoryItems.Remove(itemID); + foreach (InventoryFolder fold in InventoryFolders.Values) + { + if (fold.Items.Contains(item)) + { + fold.Items.Remove(item); + break; + } + } + res = true; + + } + return res; + } + } + + public class InventoryFolder + { + public List Items; + //public List Subfolders; + public LLUUID FolderID; + public LLUUID OwnerID; + public LLUUID ParentID = LLUUID.Zero; + public string FolderName; + public ushort DefaultType; + public ushort Version; + + public InventoryFolder() + { + Items = new List(); + //Subfolders = new List(); + } + + } + + public class InventoryItem + { + public LLUUID FolderID; + public LLUUID OwnerID; + public LLUUID ItemID; + public LLUUID AssetID; + public LLUUID CreatorID; + public sbyte InvType; + public sbyte Type; + public string Name =""; + public string Description; + + public InventoryItem() + { + this.CreatorID = LLUUID.Zero; + } + + public string ExportString() + { + string typ = "notecard"; + string result = ""; + result += "\tinv_object\t0\n\t{\n"; + result += "\t\tobj_id\t%s\n"; + result += "\t\tparent_id\t"+ ItemID.ToString() +"\n"; + result += "\t\ttype\t"+ typ +"\n"; + result += "\t\tname\t" + Name+"|\n"; + result += "\t}\n"; + return result; + } + } + + public class AvatarWearable + { + public LLUUID AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); + public LLUUID ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); + + public AvatarWearable() + { + + } + } +} diff --git a/OpenSim.Framework/AssetBase.cs b/OpenSim.Framework/AssetBase.cs new file mode 100644 index 0000000000..8206b307e0 --- /dev/null +++ b/OpenSim.Framework/AssetBase.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Assets +{ + public class AssetBase + { + public byte[] Data; + public LLUUID FullID; + public sbyte Type; + public sbyte InvType; + public string Name; + public string Description; + + public AssetBase() + { + + } + } +} diff --git a/OpenSim.Framework/BlockingQueue.cs b/OpenSim.Framework/BlockingQueue.cs new file mode 100644 index 0000000000..f840354295 --- /dev/null +++ b/OpenSim.Framework/BlockingQueue.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Utilities +{ + public class BlockingQueue + { + private Queue _queue = new Queue(); + private object _queueSync = new object(); + + public void Enqueue(T value) + { + lock (_queueSync) + { + _queue.Enqueue(value); + Monitor.Pulse(_queueSync); + } + } + + public T Dequeue() + { + lock (_queueSync) + { + if (_queue.Count < 1) + Monitor.Wait(_queueSync); + + return _queue.Dequeue(); + } + } + } +} diff --git a/OpenSim.Framework/HeightMapGenHills.cs b/OpenSim.Framework/HeightMapGenHills.cs new file mode 100644 index 0000000000..6a729da553 --- /dev/null +++ b/OpenSim.Framework/HeightMapGenHills.cs @@ -0,0 +1,149 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; + +namespace OpenSim.Framework.Terrain +{ + public class HeightmapGenHills + { + private Random Rand = new Random(); + private int NumHills; + private float HillMin; + private float HillMax; + private bool Island; + private float[] heightmap; + + public float[] GenerateHeightmap(int numHills, float hillMin, float hillMax, bool island) + { + NumHills = numHills; + HillMin = hillMin; + HillMax = hillMax; + Island = island; + + heightmap = new float[256 * 256]; + + for (int i = 0; i < numHills; i++) + { + AddHill(); + } + + Normalize(); + + return heightmap; + } + + private void AddHill() + { + float x, y; + float radius = RandomRange(HillMin, HillMax); + + if (Island) + { + // Which direction from the center of the map the hill is placed + float theta = RandomRange(0, 6.28f); + + // How far from the center of the map to place the hill. The radius + // is subtracted from the range to prevent any part of the hill from + // reaching the edge of the map + float distance = RandomRange(radius / 2.0f, 128.0f - radius); + + x = 128.0f + (float)Math.Cos(theta) * distance; + y = 128.0f + (float)Math.Sin(theta) * distance; + } + else + { + x = RandomRange(-radius, 256.0f + radius); + y = RandomRange(-radius, 256.0f + radius); + } + + float radiusSq = radius * radius; + float distSq; + float height; + + int xMin = (int)(x - radius) - 1; + int xMax = (int)(x + radius) + 1; + if (xMin < 0) xMin = 0; + if (xMax > 255) xMax = 255; + + int yMin = (int)(y - radius) - 1; + int yMax = (int)(y + radius) + 1; + if (yMin < 0) yMin = 0; + if (yMax > 255) yMax = 255; + + // Loop through each affected cell and determine the height at that point + for (int v = yMin; v <= yMax; ++v) + { + float fv = (float)v; + + for (int h = xMin; h <= xMax; ++h) + { + float fh = (float)h; + + // Determine how far from the center of this hill this point is + distSq = (x - fh) * (x - fh) + (y - fv) * (y - fv); + height = radiusSq - distSq; + + // Don't add negative hill values + if (height > 0.0f) heightmap[h + v * 256] += height; + } + } + } + + private void Normalize() + { + float min = heightmap[0]; + float max = heightmap[0]; + + for (int x = 0; x < 256; x++) + { + for (int y = 0; y < 256; y++) + { + if (heightmap[x + y * 256] < min) min = heightmap[x + y * 256]; + if (heightmap[x + y * 256] > max) max = heightmap[x + y * 256]; + } + } + + // Avoid a rare divide by zero + if (min != max) + { + for (int x = 0; x < 256; x++) + { + for (int y = 0; y < 256; y++) + { + heightmap[x + y * 256] = ((heightmap[x + y * 256] - min) / (max - min)) * (HillMax - HillMin); + } + } + } + } + + private float RandomRange(float min, float max) + { + return (float)Rand.NextDouble() * (max - min) + min; + } + } +} diff --git a/OpenSim.Framework/IAssetServer.cs b/OpenSim.Framework/IAssetServer.cs new file mode 100644 index 0000000000..a0de548a0e --- /dev/null +++ b/OpenSim.Framework/IAssetServer.cs @@ -0,0 +1,68 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Net; +using System.Net.Sockets; +using System.IO; +using System.Threading; +using libsecondlife; +using OpenSim.Framework.Assets; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// Description of IAssetServer. + /// + + public interface IAssetServer + { + void SetReceiver(IAssetReceiver receiver); + void RequestAsset(LLUUID assetID, bool isTexture); + void UpdateAsset(AssetBase asset); + void UploadNewAsset(AssetBase asset); + void SetServerInfo(string ServerUrl, string ServerKey); + void Close(); + } + + // could change to delegate? + public interface IAssetReceiver + { + void AssetReceived(AssetBase asset, bool IsTexture); + void AssetNotFound(AssetBase asset); + } + + public interface IAssetPlugin + { + IAssetServer GetAssetServer(); + } + + public struct ARequest + { + public LLUUID AssetID; + public bool IsTexture; + } +} diff --git a/OpenSim.Framework/IConfig.cs b/OpenSim.Framework/IConfig.cs new file mode 100644 index 0000000000..7b4c0404b7 --- /dev/null +++ b/OpenSim.Framework/IConfig.cs @@ -0,0 +1,76 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + +* Copyright (c) , +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Collections.Generic; +using System.IO; +using libsecondlife; +//using OpenSim.world; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// This class handles connection to the underlying database used for configuration of the region. + /// Region content is also stored by this class. The main entry point is InitConfig() which attempts to locate + /// opensim.yap in the current working directory. If opensim.yap can not be found, default settings are loaded from + /// what is hardcoded here and then saved into opensim.yap for future startups. + /// + + + public abstract class SimConfig + { + public string RegionName; + + public uint RegionLocX; + public uint RegionLocY; + public ulong RegionHandle; + + public int IPListenPort; + public string IPListenAddr; + + public string AssetURL; + public string AssetSendKey; + + public string GridURL; + public string GridSendKey; + public string GridRecvKey; + public string UserURL; + public string UserSendKey; + public string UserRecvKey; + + public abstract void InitConfig(bool sandboxMode); + public abstract void LoadFromGrid(); + + } + + public interface ISimConfig + { + SimConfig GetConfigObject(); + } +} diff --git a/OpenSim.Framework/IGenericConfig.cs b/OpenSim.Framework/IGenericConfig.cs new file mode 100644 index 0000000000..a853fe41f2 --- /dev/null +++ b/OpenSim.Framework/IGenericConfig.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Interfaces +{ + public interface IGenericConfig + { + void LoadData(); + string GetAttribute(string attributeName); + bool SetAttribute(string attributeName, string attributeValue); + void Commit(); + void Close(); + } +} diff --git a/OpenSim.Framework/IGridConfig.cs b/OpenSim.Framework/IGridConfig.cs new file mode 100644 index 0000000000..b2f26dac99 --- /dev/null +++ b/OpenSim.Framework/IGridConfig.cs @@ -0,0 +1,64 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + +* Copyright (c) , +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Collections.Generic; +using System.IO; +using libsecondlife; +//using OpenSim.world; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// + + + public abstract class GridConfig + { + public string GridOwner; + public string DefaultStartupMsg; + public string DefaultAssetServer; + public string AssetSendKey; + public string AssetRecvKey; + public string DefaultUserServer; + public string UserSendKey; + public string UserRecvKey; + public string SimSendKey; + public string SimRecvKey; + + + public abstract void InitConfig(); + + } + + public interface IGridConfig + { + GridConfig GetConfigObject(); + } +} diff --git a/OpenSim.Framework/IGridServer.cs b/OpenSim.Framework/IGridServer.cs new file mode 100644 index 0000000000..001ce3b3be --- /dev/null +++ b/OpenSim.Framework/IGridServer.cs @@ -0,0 +1,78 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + + +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Sockets; +using System.IO; +using libsecondlife; +using OpenSim; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// Handles connection to Grid Servers. + /// also Sim to Sim connections? + /// + + public interface IGridServer + { + UUIDBlock RequestUUIDBlock(); + NeighbourInfo[] RequestNeighbours(); //should return a array of neighbouring regions + AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + string GetName(); + bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port); + void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + void Close(); + } + + public struct UUIDBlock + { + public LLUUID BlockStart; + public LLUUID BlockEnd; + } + + public class AuthenticateResponse + { + public bool Authorised; + public Login LoginInfo; + + public AuthenticateResponse() + { + + } + + } + + public interface IGridPlugin + { + IGridServer GetGridServer(); + } +} diff --git a/OpenSim.Framework/ILocalStorage.cs b/OpenSim.Framework/ILocalStorage.cs new file mode 100644 index 0000000000..bc11d8ffad --- /dev/null +++ b/OpenSim.Framework/ILocalStorage.cs @@ -0,0 +1,53 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using libsecondlife; +using OpenSim.Framework.Assets; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// ILocalStorage. Really hacked together right now needs cleaning up + /// + public interface ILocalStorage + { + void StorePrim(PrimData prim); + void RemovePrim(LLUUID primID); + void LoadPrimitives(ILocalStorageReceiver receiver); + float[,] LoadWorld(); + void SaveMap(float[,] heightmap); + void ShutDown(); + } + + public interface ILocalStorageReceiver + { + void PrimFromStorage(PrimData prim); + } + +} + diff --git a/OpenSim.Framework/IScriptAPI.cs b/OpenSim.Framework/IScriptAPI.cs new file mode 100644 index 0000000000..2f58198551 --- /dev/null +++ b/OpenSim.Framework/IScriptAPI.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Interfaces +{ + public interface IScriptAPI + { + OSVector3 GetEntityPosition(uint localID); + void SetEntityPosition(uint localID, float x, float y, float z); + uint GetRandomAvatarID(); + } +} diff --git a/OpenSim.Framework/IScriptEngine.cs b/OpenSim.Framework/IScriptEngine.cs new file mode 100644 index 0000000000..ed8974c1c3 --- /dev/null +++ b/OpenSim.Framework/IScriptEngine.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Interfaces +{ + public interface IScriptEngine + { + bool Init(IScriptAPI api); + string GetName(); + void LoadScript(string script, string scriptName, uint entityID); + void OnFrame(); + } +} diff --git a/OpenSim.Framework/IUserConfig.cs b/OpenSim.Framework/IUserConfig.cs new file mode 100644 index 0000000000..e15867dc2f --- /dev/null +++ b/OpenSim.Framework/IUserConfig.cs @@ -0,0 +1,58 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + +* Copyright (c) , +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Collections.Generic; +using System.IO; +using libsecondlife; +//using OpenSim.world; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// + + + public abstract class UserConfig + { + public string DefaultStartupMsg; + public string GridServerURL; + public string GridSendKey; + public string GridRecvKey; + + + public abstract void InitConfig(); + + } + + public interface IUserConfig + { + UserConfig GetConfigObject(); + } +} diff --git a/OpenSim.Framework/IUserServer.cs b/OpenSim.Framework/IUserServer.cs new file mode 100644 index 0000000000..21f27216f1 --- /dev/null +++ b/OpenSim.Framework/IUserServer.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Inventory; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public interface IUserServer + { + AgentInventory RequestAgentsInventory(LLUUID agentID); + void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory); + } +} diff --git a/OpenSim.Framework/LocalGridBase.cs b/OpenSim.Framework/LocalGridBase.cs new file mode 100644 index 0000000000..6857d6ddc9 --- /dev/null +++ b/OpenSim.Framework/LocalGridBase.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public abstract class LocalGridBase : IGridServer + { + public abstract UUIDBlock RequestUUIDBlock(); + public abstract NeighbourInfo[] RequestNeighbours(); + public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract string GetName(); + public abstract bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port); + public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + public abstract void AddNewSession(Login session); + public abstract void Close(); + } + +} diff --git a/OpenSim.Framework/Login.cs b/OpenSim.Framework/Login.cs new file mode 100644 index 0000000000..8a67853c44 --- /dev/null +++ b/OpenSim.Framework/Login.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public class Login + { + public string First = "Test"; + public string Last = "User"; + public LLUUID Agent; + public LLUUID Session; + public LLUUID SecureSession = LLUUID.Zero; + public LLUUID InventoryFolder; + public LLUUID BaseFolder; + public Login() + { + + } + } +} diff --git a/OpenSim.Framework/LoginService.cs b/OpenSim.Framework/LoginService.cs new file mode 100644 index 0000000000..eba0281729 --- /dev/null +++ b/OpenSim.Framework/LoginService.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using Nwc.XmlRpc; +using libsecondlife; + +namespace OpenSim.Framework.Grid +{ + public abstract class LoginService + { + + } +} \ No newline at end of file diff --git a/OpenSim.Framework/NeighbourInfo.cs b/OpenSim.Framework/NeighbourInfo.cs new file mode 100644 index 0000000000..8b4fa64e1f --- /dev/null +++ b/OpenSim.Framework/NeighbourInfo.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Interfaces +{ + public class NeighbourInfo + { + public NeighbourInfo() + { + } + + public ulong regionhandle; + public uint RegionLocX; + public uint RegionLocY; + public string sim_ip; + public uint sim_port; + } +} diff --git a/OpenSim.Framework/OSVector3.cs b/OpenSim.Framework/OSVector3.cs new file mode 100644 index 0000000000..b5d12233c1 --- /dev/null +++ b/OpenSim.Framework/OSVector3.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework +{ + public class OSVector3 + { + public float X; + public float Y; + public float Z; + + public OSVector3() + { + + } + } +} diff --git a/OpenSim.Framework/OpenSim.Framework.csproj b/OpenSim.Framework/OpenSim.Framework.csproj new file mode 100644 index 0000000000..7de30e4e24 --- /dev/null +++ b/OpenSim.Framework/OpenSim.Framework.csproj @@ -0,0 +1,178 @@ + + + Local + 8.0.50727 + 2.0 + {8ACA2445-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + + OpenSim.Framework + JScript + Grid + IE50 + false + Library + + + OpenSim.Framework + + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + + False + 285212672 + False + + + TRACE + + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + + System.dll + False + + + + System.Xml.dll + False + + + ..\bin\libsecondlife.dll + False + + + ..\bin\Db4objects.Db4o.dll + False + + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + \ No newline at end of file diff --git a/OpenSim.Framework/OpenSim.Framework.csproj.user b/OpenSim.Framework/OpenSim.Framework.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenSim.Framework/OpenSim.Framework.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.Framework/OpenSim.Framework.dll.build b/OpenSim.Framework/OpenSim.Framework.dll.build new file mode 100644 index 0000000000..b351625070 --- /dev/null +++ b/OpenSim.Framework/OpenSim.Framework.dll.build @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Framework/PrimData.cs b/OpenSim.Framework/PrimData.cs new file mode 100644 index 0000000000..ee4188d39c --- /dev/null +++ b/OpenSim.Framework/PrimData.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Assets +{ + public class PrimData + { + private const uint FULL_MASK_PERMISSIONS = 2147483647; + + public LLUUID OwnerID; + public byte PCode; + public byte PathBegin; + public byte PathEnd; + public byte PathScaleX; + public byte PathScaleY; + public byte PathShearX; + public byte PathShearY; + public sbyte PathSkew; + public byte ProfileBegin; + public byte ProfileEnd; + public LLVector3 Scale; + public byte PathCurve; + public byte ProfileCurve; + public uint ParentID = 0; + public byte ProfileHollow; + public sbyte PathRadiusOffset; + public byte PathRevolutions; + public sbyte PathTaperX; + public sbyte PathTaperY; + public sbyte PathTwist; + public sbyte PathTwistBegin; + public byte[] Texture; + + + public Int32 CreationDate; + public uint OwnerMask = FULL_MASK_PERMISSIONS; + public uint NextOwnerMask = FULL_MASK_PERMISSIONS; + public uint GroupMask = FULL_MASK_PERMISSIONS; + public uint EveryoneMask = FULL_MASK_PERMISSIONS; + public uint BaseMask = FULL_MASK_PERMISSIONS; + + //following only used during prim storage + public LLVector3 Position; + public LLQuaternion Rotation = new LLQuaternion(0,1,0,0); + public uint LocalID; + public LLUUID FullID; + + public PrimData() + { + + } + + public PrimData(byte[] data) + { + int i =0; + + this.OwnerID = new LLUUID(data, i); i += 16; + this.PCode = data[i++]; + this.PathBegin = data[i++]; + this.PathEnd = data[i++]; + this.PathScaleX = data[i++]; + this.PathScaleY = data[i++]; + this.PathShearX = data[i++]; + this.PathShearY = data[i++]; + this.PathSkew = (sbyte)data[i++]; + this.ProfileBegin = data[i++]; + this.ProfileEnd = data[i++]; + this.Scale = new LLVector3(data, i); i += 12; + this.PathCurve = data[i++]; + this.ProfileCurve = data[i++]; + this.ParentID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); + this.ProfileHollow = data[i++]; + this.PathRadiusOffset = (sbyte)data[i++]; + this.PathRevolutions = data[i++]; + this.PathTaperX = (sbyte)data[i++]; + this.PathTaperY =(sbyte) data[i++]; + this.PathTwist = (sbyte) data[i++]; + this.PathTwistBegin = (sbyte) data[i++]; + ushort length = (ushort)(data[i++] + (data[i++] << 8)); + this.Texture = new byte[length]; + Array.Copy(data, i, Texture, 0, length); i += length; + this.CreationDate = (Int32)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); + this.OwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); + this.NextOwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); + this.GroupMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); + this.EveryoneMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); + this.BaseMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); + this.Position = new LLVector3(data, i); i += 12; + this.Rotation = new LLQuaternion(data,i, true); i += 12; + this.LocalID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24)); + this.FullID = new LLUUID(data, i); i += 16; + + } + + public byte[] ToBytes() + { + int i = 0; + byte[] bytes = new byte[121 + Texture.Length]; + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = this.PCode; + bytes[i++] = this.PathBegin; + bytes[i++] = this.PathEnd; + bytes[i++] = this.PathScaleX; + bytes[i++] = this.PathScaleY; + bytes[i++] = this.PathShearX; + bytes[i++] = this.PathShearY; + bytes[i++] = (byte)this.PathSkew; + bytes[i++] = this.ProfileBegin; + bytes[i++] = this.ProfileEnd; + Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = this.PathCurve; + bytes[i++] = this.ProfileCurve; + bytes[i++] = (byte)(ParentID % 256); + bytes[i++] = (byte)((ParentID >> 8) % 256); + bytes[i++] = (byte)((ParentID >> 16) % 256); + bytes[i++] = (byte)((ParentID >> 24) % 256); + bytes[i++] = this.ProfileHollow; + bytes[i++] = ((byte)this.PathRadiusOffset); + bytes[i++] = this.PathRevolutions; + bytes[i++] = ((byte) this.PathTaperX); + bytes[i++] = ((byte) this.PathTaperY); + bytes[i++] = ((byte) this.PathTwist); + bytes[i++] = ((byte) this.PathTwistBegin); + bytes[i++] = (byte)(Texture.Length % 256); + bytes[i++] = (byte)((Texture.Length >> 8) % 256); + Array.Copy(Texture, 0, bytes, i, Texture.Length); i += Texture.Length; + bytes[i++] = (byte)(this.CreationDate % 256); + bytes[i++] = (byte)((this.CreationDate >> 8) % 256); + bytes[i++] = (byte)((this.CreationDate >> 16) % 256); + bytes[i++] = (byte)((this.CreationDate >> 24) % 256); + bytes[i++] = (byte)(this.OwnerMask % 256); + bytes[i++] = (byte)((this.OwnerMask >> 8) % 256); + bytes[i++] = (byte)((this.OwnerMask >> 16) % 256); + bytes[i++] = (byte)((this.OwnerMask >> 24) % 256); + bytes[i++] = (byte)(this.NextOwnerMask % 256); + bytes[i++] = (byte)((this.NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((this.NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((this.NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(this.GroupMask % 256); + bytes[i++] = (byte)((this.GroupMask >> 8) % 256); + bytes[i++] = (byte)((this.GroupMask >> 16) % 256); + bytes[i++] = (byte)((this.GroupMask >> 24) % 256); + bytes[i++] = (byte)(this.EveryoneMask % 256); + bytes[i++] = (byte)((this.EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((this.EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((this.EveryoneMask >> 24) % 256); + bytes[i++] = (byte)(this.BaseMask % 256); + bytes[i++] = (byte)((this.BaseMask >> 8) % 256); + bytes[i++] = (byte)((this.BaseMask >> 16) % 256); + bytes[i++] = (byte)((this.BaseMask >> 24) % 256); + Array.Copy(this.Position.GetBytes(), 0, bytes, i, 12); i += 12; + if (this.Rotation == new LLQuaternion(0,0,0,0)) + { + this.Rotation = new LLQuaternion(0, 1, 0, 0); + } + Array.Copy(this.Rotation.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(this.LocalID % 256); + bytes[i++] = (byte)((this.LocalID >> 8) % 256); + bytes[i++] = (byte)((this.LocalID >> 16) % 256); + bytes[i++] = (byte)((this.LocalID >> 24) % 256); + Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16; + + return bytes; + } + } +} diff --git a/OpenSim.Framework/Properties/AssemblyInfo.cs b/OpenSim.Framework/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..86f5cdbd10 --- /dev/null +++ b/OpenSim.Framework/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.FrameWork")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenSim.FrameWork")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a08e20c7-f191-4137-b1f0-9291408fa521")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim.Framework/RemoteGridBase.cs b/OpenSim.Framework/RemoteGridBase.cs new file mode 100644 index 0000000000..e1f0b9be61 --- /dev/null +++ b/OpenSim.Framework/RemoteGridBase.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public abstract class RemoteGridBase : IGridServer + { + public abstract Dictionary agentcircuits + { + get; + set; + } + + public abstract UUIDBlock RequestUUIDBlock(); + public abstract NeighbourInfo[] RequestNeighbours(); + public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract string GetName(); + public abstract bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port); + public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + public abstract void Close(); + } +} diff --git a/OpenSim.Framework/SimProfile.cs b/OpenSim.Framework/SimProfile.cs new file mode 100644 index 0000000000..ac4cf9e327 --- /dev/null +++ b/OpenSim.Framework/SimProfile.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Xml; +using System.Text; +using libsecondlife; +using Nwc.XmlRpc; + +namespace OpenSim.Framework.Sims +{ + public class SimProfile : SimProfileBase + { + public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey) + { + try + { + Hashtable GridReqParams = new Hashtable(); + GridReqParams["region_handle"] = region_handle.ToString(); + GridReqParams["caller"] = "userserver"; + GridReqParams["authkey"] = SendKey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(GridReqParams); + XmlRpcRequest GridReq = new XmlRpcRequest("get_sim_info", SendParams); + + XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000); + + Hashtable RespData = (Hashtable)GridResp.Value; + this.UUID = new LLUUID((string)RespData["UUID"]); + this.regionhandle = (ulong)Convert.ToUInt64(RespData["regionhandle"]); + this.regionname = (string)RespData["regionname"]; + this.sim_ip = (string)RespData["sim_ip"]; + this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]); + this.caps_url = (string)RespData["caps_url"]; + this.RegionLocX = (uint)Convert.ToUInt32(RespData["RegionLocX"]); + this.RegionLocY = (uint)Convert.ToUInt32(RespData["RegionLocY"]); + this.sendkey = (string)RespData["sendkey"]; + this.recvkey = (string)RespData["recvkey"]; + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + return this; + } + + public SimProfile() + { + } + } + +} diff --git a/OpenSim.Framework/SimProfileBase.cs b/OpenSim.Framework/SimProfileBase.cs new file mode 100644 index 0000000000..ffc66ec531 --- /dev/null +++ b/OpenSim.Framework/SimProfileBase.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Sims +{ + public class SimProfileBase + { + public LLUUID UUID; + public ulong regionhandle; + public string regionname; + public string sim_ip; + public uint sim_port; + public string caps_url; + public uint RegionLocX; + public uint RegionLocY; + public string sendkey; + public string recvkey; + public bool online; + + public SimProfileBase() + { + } + } +} diff --git a/OpenSim.Framework/UserProfile.cs b/OpenSim.Framework/UserProfile.cs new file mode 100644 index 0000000000..215f7da1ef --- /dev/null +++ b/OpenSim.Framework/UserProfile.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Inventory; + +namespace OpenSim.Framework.User +{ + public class UserProfile + { + + public string firstname; + public string lastname; + public ulong homeregionhandle; + public LLVector3 homepos; + public LLVector3 homelookat; + + public bool IsGridGod = false; + public bool IsLocal = true; // will be used in future for visitors from foreign grids + public string AssetURL; + public string MD5passwd; + + public LLUUID CurrentSessionID; + public LLUUID CurrentSecureSessionID; + public LLUUID UUID; + public Dictionary Circuits = new Dictionary(); // tracks circuit codes + + public AgentInventory Inventory; + + public UserProfile() + { + Circuits = new Dictionary(); + Inventory = new AgentInventory(); + homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256)); ; + + } + + public void InitSessionData() + { + CurrentSessionID = LLUUID.Random(); + CurrentSecureSessionID = LLUUID.Random(); + } + + public void AddSimCircuit(uint circuitCode, LLUUID regionUUID) + { + if (this.Circuits.ContainsKey(regionUUID) == false) + this.Circuits.Add(regionUUID, circuitCode); + } + + } +} diff --git a/OpenSim.Framework/UserProfileManager.cs b/OpenSim.Framework/UserProfileManager.cs new file mode 100644 index 0000000000..d4748345cd --- /dev/null +++ b/OpenSim.Framework/UserProfileManager.cs @@ -0,0 +1,250 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.User +{ + public class UserProfileManager : UserProfileManagerBase + { + public string GridURL; + public string GridSendKey; + public string GridRecvKey; + public string DefaultStartupMsg; + + public UserProfileManager() + { + + } + + public void SetKeys(string sendKey, string recvKey, string url, string message) + { + GridRecvKey = recvKey; + GridSendKey = sendKey; + GridURL = url; + DefaultStartupMsg = message; + } + + public virtual string ParseXMLRPC(string requestBody) + { + + XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); + + switch (request.MethodName) + { + case "login_to_simulator": + XmlRpcResponse response = XmlRpcLoginMethod(request); + + return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(response), "utf-16", "utf-8")); + } + + return ""; + } + + public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); + bool GoodLogin = false; + string firstname = ""; + string lastname = ""; + string passwd = ""; + + if (GoodXML) + { + firstname = (string)requestData["first"]; + lastname = (string)requestData["last"]; + passwd = (string)requestData["passwd"]; + GoodLogin = AuthenticateUser(firstname, lastname, passwd); + } + + + if (!(GoodXML && GoodLogin)) + { + response = CreateErrorConnectingToGridResponse(); + } + else + { + UserProfile TheUser = GetProfileByName(firstname, lastname); + //we need to sort out how sessions are logged out , currently the sim tells the gridserver + //but if as this suggests the userserver handles it then please have the sim telling the userserver instead + //as it really makes things messy for sandbox mode + //if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null))) + // { + // response = CreateAlreadyLoggedInResponse(); + // } + //else + //{ + try + { + Hashtable responseData = new Hashtable(); + + LLUUID AgentID = TheUser.UUID; + TheUser.InitSessionData(); + // SimProfile SimInfo = new SimProfile(); + // SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); + + + Hashtable GlobalT = new Hashtable(); + GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; + GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + ArrayList GlobalTextures = new ArrayList(); + GlobalTextures.Add(GlobalT); + + Hashtable LoginFlagsHash = new Hashtable(); + LoginFlagsHash["daylight_savings"] = "N"; + LoginFlagsHash["stipend_since_login"] = "N"; + LoginFlagsHash["gendered"] = "Y"; + LoginFlagsHash["ever_logged_in"] = "Y"; + ArrayList LoginFlags = new ArrayList(); + LoginFlags.Add(LoginFlagsHash); + + Hashtable uiconfig = new Hashtable(); + uiconfig["allow_first_life"] = "Y"; + ArrayList ui_config = new ArrayList(); + ui_config.Add(uiconfig); + + Hashtable ClassifiedCategoriesHash = new Hashtable(); + ClassifiedCategoriesHash["category_name"] = "bla bla"; + ClassifiedCategoriesHash["category_id"] = (Int32)1; + ArrayList ClassifiedCategories = new ArrayList(); + ClassifiedCategories.Add(ClassifiedCategoriesHash); + + ArrayList AgentInventory = new ArrayList(); + Console.WriteLine("adding inventory to response"); + foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values) + { + Hashtable TempHash = new Hashtable(); + Console.WriteLine("adding folder " + InvFolder.FolderName + ", ID: " + InvFolder.FolderID.ToStringHyphenated() + " with parent: " + InvFolder.ParentID.ToStringHyphenated()); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventory.Add(TempHash); + } + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = TheUser.Inventory.InventoryRoot.FolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + + Hashtable InitialOutfitHash = new Hashtable(); + InitialOutfitHash["folder_name"] = "Nightclub Female"; + InitialOutfitHash["gender"] = "female"; + ArrayList InitialOutfit = new ArrayList(); + InitialOutfit.Add(InitialOutfitHash); + + uint circode = (uint)(Util.RandomClass.Next()); + //TheUser.AddSimCircuit(circode, SimInfo.UUID); + + responseData["last_name"] = TheUser.lastname; + responseData["ui-config"] = ui_config; + responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString(); + responseData["login-flags"] = LoginFlags; + responseData["global-textures"] = GlobalTextures; + responseData["classified_categories"] = ClassifiedCategories; + responseData["event_categories"] = new ArrayList(); + responseData["inventory-skeleton"] = AgentInventory; + responseData["inventory-skel-lib"] = new ArrayList(); + responseData["inventory-root"] = InventoryRoot; + responseData["event_notifications"] = new ArrayList(); + responseData["gestures"] = new ArrayList(); + responseData["inventory-lib-owner"] = new ArrayList(); + responseData["initial-outfit"] = InitialOutfit; + responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + responseData["start_location"] = "last"; + responseData["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + TheUser.homepos.X.ToString() + ",r" + TheUser.homepos.Y.ToString() + ",r" + TheUser.homepos.Z.ToString() + "], 'look_at':[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]}"; + responseData["message"] = DefaultStartupMsg; + responseData["first_name"] = TheUser.firstname; + responseData["circuit_code"] = (Int32)circode; + responseData["sim_port"] = 9000; //(Int32)SimInfo.sim_port; + responseData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated(); + responseData["look_at"] = "\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n"; + responseData["agent_id"] = AgentID.ToStringHyphenated(); + responseData["region_y"] = (Int32)996 * 256; // (Int32)SimInfo.RegionLocY * 256; + responseData["region_x"] = (Int32)997 * 256; //SimInfo.RegionLocX * 256; + responseData["seed_capability"] = null; + responseData["agent_access"] = "M"; + responseData["session_id"] = TheUser.CurrentSessionID.ToStringHyphenated(); + responseData["login"] = "true"; + + this.CustomiseResponse(ref responseData, TheUser); + response.Value = responseData; + //TheUser.SendDataToSim(SimInfo); + + + + } + catch (Exception E) + { + Console.WriteLine(E.ToString()); + } + //} + } + return response; + } + + private static XmlRpcResponse CreateErrorConnectingToGridResponse() + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable ErrorRespData = new Hashtable(); + ErrorRespData["reason"] = "key"; + ErrorRespData["message"] = "Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct"; + ErrorRespData["login"] = "false"; + response.Value = ErrorRespData; + return response; + } + + private static XmlRpcResponse CreateAlreadyLoggedInResponse() + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable PresenceErrorRespData = new Hashtable(); + PresenceErrorRespData["reason"] = "presence"; + PresenceErrorRespData["message"] = "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner"; + PresenceErrorRespData["login"] = "false"; + response.Value = PresenceErrorRespData; + return response; + } + + public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser) + { + //default method set up to act as ogs user server + SimProfile SimInfo = new SimProfile(); + //get siminfo from grid server + SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); + Int32 circode = (Int32)response["circuit_code"]; + theUser.AddSimCircuit((uint)circode, SimInfo.UUID); + response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}"; + response["sim_ip"] = SimInfo.sim_ip.ToString(); + response["sim_port"] = (Int32)SimInfo.sim_port; + response["region_y"] = (Int32)SimInfo.RegionLocY * 256; + response["region_x"] = (Int32)SimInfo.RegionLocX * 256; + + //default is ogs user server, so let the sim know about the user via a XmlRpcRequest + Console.WriteLine(SimInfo.caps_url); + Hashtable SimParams = new Hashtable(); + SimParams["session_id"] = theUser.CurrentSessionID.ToString(); + SimParams["secure_session_id"] = theUser.CurrentSecureSessionID.ToString(); + SimParams["firstname"] = theUser.firstname; + SimParams["lastname"] = theUser.lastname; + SimParams["agent_id"] = theUser.UUID.ToString(); + SimParams["circuit_code"] = (Int32)theUser.Circuits[SimInfo.UUID]; + ArrayList SendParams = new ArrayList(); + SendParams.Add(SimParams); + + XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); + XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000); + } + } +} diff --git a/OpenSim.Framework/UserProfileManagerBase.cs b/OpenSim.Framework/UserProfileManagerBase.cs new file mode 100644 index 0000000000..44288315a1 --- /dev/null +++ b/OpenSim.Framework/UserProfileManagerBase.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Inventory; +using Db4objects.Db4o; + +namespace OpenSim.Framework.User +{ + public class UserProfileManagerBase + { + + public Dictionary UserProfiles = new Dictionary(); + + public UserProfileManagerBase() + { + } + + public virtual void InitUserProfiles() + { + IObjectContainer db; + db = Db4oFactory.OpenFile("userprofiles.yap"); + IObjectSet result = db.Get(typeof(UserProfile)); + foreach (UserProfile userprof in result) + { + UserProfiles.Add(userprof.UUID, userprof); + } + Console.WriteLine("UserProfiles.Cs:InitUserProfiles() - Successfully loaded " + result.Count.ToString() + " from database"); + db.Close(); + } + + public virtual void SaveUserProfiles() // ZOMG! INEFFICIENT! + { + IObjectContainer db; + db = Db4oFactory.OpenFile("userprofiles.yap"); + IObjectSet result = db.Get(typeof(UserProfile)); + foreach (UserProfile userprof in result) + { + db.Delete(userprof); + db.Commit(); + } + foreach (UserProfile userprof in UserProfiles.Values) + { + db.Set(userprof); + db.Commit(); + } + db.Close(); + } + + public UserProfile GetProfileByName(string firstname, string lastname) + { + foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys) + { + if ((UserProfiles[UUID].firstname == firstname) && (UserProfiles[UUID].lastname == lastname)) + { + return UserProfiles[UUID]; + } + } + return null; + } + + public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) + { + return UserProfiles[ProfileLLUUID]; + } + + public virtual bool AuthenticateUser(string firstname, string lastname, string passwd) + { + UserProfile TheUser = GetProfileByName(firstname, lastname); + passwd = passwd.Remove(0, 3); //remove $1$ + if (TheUser != null) + { + if (TheUser.MD5passwd == passwd) + { + Console.WriteLine("UserProfile - authorised "); + return true; + } + else + { + Console.WriteLine("UserProfile - not authorised, password not match " + TheUser.MD5passwd + " and " + passwd); + return false; + } + } + else + { + Console.WriteLine("UserProfile - not authorised , unkown: " + firstname + " , " + lastname); + return false; + } + + } + + public void SetGod(LLUUID GodID) + { + this.UserProfiles[GodID].IsGridGod = true; + } + + public virtual UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd) + { + Console.WriteLine("creating new profile for : " + firstname + " , " + lastname); + UserProfile newprofile = new UserProfile(); + newprofile.homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256)); + newprofile.firstname = firstname; + newprofile.lastname = lastname; + newprofile.MD5passwd = MD5passwd; + newprofile.UUID = LLUUID.Random(); + newprofile.Inventory.CreateRootFolder(newprofile.UUID, true); + this.UserProfiles.Add(newprofile.UUID, newprofile); + return newprofile; + } + + public virtual AgentInventory GetUsersInventory(LLUUID agentID) + { + UserProfile user = this.GetProfileByLLUUID(agentID); + if (user != null) + { + return user.Inventory; + } + + return null; + } + + } +} diff --git a/OpenSim.Framework/Util.cs b/OpenSim.Framework/Util.cs new file mode 100644 index 0000000000..695cac9d3b --- /dev/null +++ b/OpenSim.Framework/Util.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace OpenSim.Framework.Utilities +{ + public class Util + { + private static Random randomClass = new Random(); + private static uint nextXferID = 5000; + private static object XferLock = new object(); + + public static ulong UIntsToLong(uint X, uint Y) + { + return Helpers.UIntsToLong(X, Y); + } + + public static Random RandomClass + { + get + { + return randomClass; + } + } + + public static uint GetNextXferID() + { + uint id = 0; + lock(XferLock) + { + id = nextXferID; + nextXferID++; + } + return id; + } + + public Util() + { + + } + } + +} diff --git a/OpenSim.FxCop b/OpenSim.FxCop new file mode 100644 index 0000000000..1e2ea2d798 --- /dev/null +++ b/OpenSim.FxCop @@ -0,0 +1,7241 @@ + + + + True + http://www.gotdotnet.com/team/fxcop//xsl/1.35/FxCopReport.xsl + + + + + + True + True + True + 10 + 1 + + False + False + + False + 120 + + + + $(ProjectDir)/lib/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sim + OpenSim + + + + + + + + + Sim + OpenSim.Assets + + + + + + + + + OpenSim.CAPS + + + + + Sim + OpenSim.CAPS + + + + + OpenSim.CAPS + + + + + + + + + Sim + OpenSim.Config.SimConfigDb4o + + + Sim + OpenSim.Config.SimConfigDb4o + + + + + + + + + OpenSim.Framework.Assets + + + + + Sim + OpenSim.Framework.Assets + + + + + + + + + Sim + OpenSim.Framework.Console + + + + + + + + + OpenSim.Framework.Grid + + + + + Sim + OpenSim.Framework.Grid + + + + + + + + + Sim + OpenSim.Framework.Interfaces + + + + + + + + + OpenSim.Framework.Inventory + + + + + Sim + OpenSim.Framework.Inventory + + + + + + + + + OpenSim.Framework.Sims + + + + + Sim + OpenSim.Framework.Sims + + + + + + + + + OpenSim.Framework.Terrain + + + + + Sim + OpenSim.Framework.Terrain + + + + + + + + + OpenSim.Framework.User + + + + + Sim + OpenSim.Framework.User + + + + + + + + + OpenSim.Framework.Utilities + + + + + Sim + OpenSim.Framework.Utilities + + + + + + + + + Sim + OpenSim.GridInterfaces.Local + + + + + + + + + OpenSim.GridInterfaces.Remote + + + + + Sim + OpenSim.GridInterfaces.Remote + + + + + + + + + Plugin + OpenSim.Physics.BasicPhysicsPlugin + + + + + Sim + OpenSim.Physics.BasicPhysicsPlugin + + + + + + + + + Sim + OpenSim.Physics.Manager + + + + + + + + + OpenSim.Physics.OdePlugin + + + + + Plugin + OpenSim.Physics.OdePlugin + + + + + Sim + OpenSim.Physics.OdePlugin + + + + + + + + + OpenSim.Physics.PhysXPlugin + + + + + Plugin + OpenSim.Physics.PhysXPlugin + + + + + Sim + OpenSim.Physics.PhysXPlugin + + + + + + + + + Sim + OpenSim.Storage.LocalStorageDb4o + + + + + + + + + OpenSim.types + + + + + OpenSim.types + + + + + Sim + OpenSim.types + + + + + + + + + OpenSim.UserServer + + + + + Sim + OpenSim.UserServer + + + + + + + + + OpenSim.world + + + + + Sim + OpenSim.world + + + + + + + + + OpenSim.world.scripting + + + + + OpenSim.world.scripting + + + OpenSim.world.scripting + + + + + Sim + OpenSim.world.scripting + + + + + + + + + + + + + OpenGridServices.ServerConsole + + + + + OpenGridServices.ServerConsole + + + + + OpenGridServices.ServerConsole + + + + + + + + + + + conscmd_callback + + + + + conscmd + ServerConsole.conscmd_callback + + + + + conscmd_callback + + + + + + + + + conscmd_callback.RunCmd(String, String[]):Void + cmdparams + cmdparams + + + + + + + + + ShowWhat + + + + + + + + + + + + + ConsoleBase.CmdPrompt(String, String):String + defaultresponse + defaultresponse + + + + + + + + + OptionA + + + + + OptionB + + + + + ConsoleBase.CmdPrompt(String, String, String, String):String + defaultresponse + defaultresponse + + + + + + + + + Passwd + ConsoleBase.PasswdPrompt(String):String + + + + + + + + + Cmd + + + + + ConsoleBase.RunCmd(String, String[]):Object + cmdparams + cmdparams + + + + + + + + + ShowWhat + + + + + + + + + Line + + + + + + + + + Line + + + + + + + + + + + + + Sim + ConsoleType.SimChat + + + + + + + + + ConsoleType.TCP + + + + + + + + + + + MainConsole + + + + + + + + + + + + + + + + + OpenSim.Config.SimConfigDb4o + + + + + OpenSim.Config.SimConfigDb4o + + + + + OpenSim.Config.SimConfigDb4o + + + + + + + + + + + Plugin + OpenSim.Config.SimConfigDb4o.Db40ConfigPlugin + + + + + + + + + Sim + OpenSim.Config.SimConfigDb4o.DbSimConfig + + + + + Db + OpenSim.Config.SimConfigDb4o.DbSimConfig + + + + + + + + + DbSimConfig.InitConfig(Boolean):Void + System.Exception + + + + + DbSimConfig.InitConfig(Boolean):Void + System.UInt32.ToString + System.UInt32.ToString(System.IFormatProvider) + + + + + DbSimConfig.InitConfig(Boolean):Void + System.UInt64.ToString + System.UInt64.ToString(System.IFormatProvider) + + + + + + + + + DbSimConfig.LoadDefaults():Void + System.Convert.ToInt32(System.String) + System.Convert.ToInt32(System.String,System.IFormatProvider) + + + DbSimConfig.LoadDefaults():Void + System.Convert.ToInt32(System.String) + System.Convert.ToInt32(System.String,System.IFormatProvider) + + + DbSimConfig.LoadDefaults():Void + System.Convert.ToInt32(System.String) + System.Convert.ToInt32(System.String,System.IFormatProvider) + + + + + + + + + + + + + Map + + + + + + + + + + + + + + + + + + + OpenSim + + + + + OpenSim + + + + + OpenSim + + + + + OpenSim + + + + + OpenSim + + + + + + + + + + + + + 'args' + RegionServer.Main(String[]):Void + + + 'args' + RegionServer.Main(String[]):Void + + + + + + + + + + + + + + + + + + + OpenSim.Framework.Console + + + + + OpenSim.Framework.Console + + + + + OpenSim.Framework.Console + + + + + + + + + + + + + ConsoleBase.CmdPrompt(String, String):String + defaultresponse + defaultresponse + + + + + + + + + OptionA + + + + + OptionB + + + + + ConsoleBase.CmdPrompt(String, String, String, String):String + defaultresponse + defaultresponse + + + + + + + + + Cmd + + + + + ConsoleBase.RunCmd(String, String[]):Object + cmdparams + cmdparams + + + + + + + + + ShowWhat + + + + + + + + + + + + + Sim + ConsoleType.SimChat + + + + + + + + + ConsoleType.TCP + + + + + + + + + + + MainConsole + + + + + + + + + + + + + + + + + OpenSim.Framework + + + + + OpenSim.Framework + + + + + OpenSim.Framework + + + + + + + + + + + + + Data + + + + + + + + + Description + + + + + + + + + FullID + + + + + + + + + InvType + + + + + + + + + Name + + + + + + + + + Type + + + + + + + + + + + + + PrimData.PrimData() + ParentID + System.UInt32 + 0 + + + + + + + + + FullID + + + + + + + + + LocalID + + + + + + + + + OwnerID + + + + + + + + + ParentID + + + + + + + + + PathBegin + + + + + + + + + PathCurve + + + + + + + + + PathEnd + + + + + + + + + PathRadiusOffset + + + + + + + + + PathRevolutions + + + + + + + + + PathScaleX + + + + + + + + + PathScaleY + + + + + + + + + PathShearX + + + + + + + + + PathShearY + + + + + + + + + PathSkew + + + + + + + + + PathTaperX + + + + + + + + + PathTaperY + + + + + + + + + PathTwist + + + + + + + + + PathTwistBegin + + + + + + + + + PCode + + + + + + + + + Position + + + + + + + + + ProfileBegin + + + + + + + + + ProfileCurve + + + + + + + + + ProfileEnd + + + + + + + + + ProfileHollow + + + + + + + + + Rotation + + + + + + + + + Scale + + + + + + + + + Texture + + + + + + + + + + + + + + + Login + LoginService + LogOn + + + + + + + + + + + + + + + AgentID + + + + + + + + + circuitcode + + + + + circuitcode + AgentCircuitData.circuitcode + + + + + + + + + firstname + + + + + firstname + AgentCircuitData.firstname + + + + + + + + + lastname + + + + + lastname + AgentCircuitData.lastname + + + + + + + + + SecureSessionID + + + + + + + + + SessionID + + + + + + + + + + + OpenSim.Framework.Interfaces.ARequest + + + OpenSim.Framework.Interfaces.ARequest + + + + + + + + + AssetID + + + + + + + + + IsTexture + + + + + + + + + + + + + Authorised + + + + + Authorised + AuthenticateResponse.Authorised + + + + + + + + + LoginInfo + + + + + Login + LoginInfo + LogOn + + + + + + + + + + + Plugin + OpenSim.Framework.Interfaces.IAssetPlugin + + + + + + + + + GetAssetServer + + + + + + + + + + + + + IsTexture + + + + + + + + + + + + + ID + assetID + Id + + + + + + + + + ServerUrl + + + + + ServerKey + + + + + ServerUrl + IAssetServer.SetServerInfo(String, String):Void + + + + + + + + + + + Plugin + OpenSim.Framework.Interfaces.IGridPlugin + + + + + + + + + GetGridServer + + + + + + + + + + + + + ID + sessionID + Id + + + + + ID + agentID + Id + + + + + + + + + GetName + + + + + + + + + ID + sessionID + Id + + + + + ID + agentID + Id + + + + + Logout + LogoutSession + LogOff + + + + + + + + + Neighbours + IGridServer.RequestNeighbours():NeighbourInfo[] + + + + + + + + + IGridServer.RequestUUIDBlock():UUIDBlock + + + + + + + + + ServerUrl + + + + + SendKey + + + + + RecvKey + + + + + IGridServer.SetServerInfo(String, String, String):Void + Recv + RecvKey + + + + + ServerUrl + IGridServer.SetServerInfo(String, String, String):Void + + + + + + + + + + + + + ID + primID + Id + + + + + + + + + ShutDown + method + ShutDown + Shutdown + + + + + + + + + + + Sim + OpenSim.Framework.Interfaces.ISimConfig + + + + + + + + + GetConfigObject + + + + + + + + + + + + + ID + agentID + Id + + + + + + + + + ServerUrl + + + + + SendKey + + + + + RecvKey + + + + + IUserServer.SetServerInfo(String, String, String):Void + Recv + RecvKey + + + + + ServerUrl + IUserServer.SetServerInfo(String, String, String):Void + + + + + + + + + + + + + Logout + LogoutSession + LogOff + + + + + + + + + + + Login + Login + LogOn + + + + + + + + + Agent + + + + + + + + + BaseFolder + + + + + + + + + First + + + + + + + + + InventoryFolder + + + + + + + + + Last + + + + + + + + + SecureSession + + + + + + + + + Session + + + + + + + + + + + Neighbour + OpenSim.Framework.Interfaces.NeighbourInfo + + + + + + + + + regionhandle + + + + + regionhandle + NeighbourInfo.regionhandle + + + + + + + + + RegionLocX + + + + + + + + + RegionLocY + + + + + + + + + sim_ip + + + + + sim + NeighbourInfo.sim_ip + + + + + sim_ip + + + + + + + + + sim_port + + + + + sim + NeighbourInfo.sim_port + + + + + sim_port + + + + + + + + + + + + + agentcircuits + + + + + agentcircuits + + + + + agentcircuits + RemoteGridBase.agentcircuits:Dictionary`2<System.UInt32,OpenSim.Framework.Interfaces.AgentCircuitData> + + + + + + + + + Logout + LogoutSession + LogOff + + + + + + + + + + + Sim + OpenSim.Framework.Interfaces.SimConfig + + + + + + + + + AssetSendKey + + + + + + + + + AssetURL + + + + + + + + + GridRecvKey + + + + + Recv + SimConfig.GridRecvKey + + + + + + + + + GridSendKey + + + + + + + + + GridURL + + + + + + + + + IPListenAddr + + + + + Addr + SimConfig.IPListenAddr + + + + + + + + + IPListenPort + + + + + + + + + RegionHandle + + + + + + + + + RegionLocX + + + + + + + + + RegionLocY + + + + + + + + + RegionName + + + + + + + + + SimConfig.SaveMap(Single[]):Void + heightmap + heightmap + + + + + + + + + UserRecvKey + + + + + Recv + SimConfig.UserRecvKey + + + + + + + + + UserSendKey + + + + + + + + + UserURL + + + + + + + + + + + UUIDBlock + + + + + OpenSim.Framework.Interfaces.UUIDBlock + + + OpenSim.Framework.Interfaces.UUIDBlock + + + + + + + + + BlockEnd + + + + + + + + + BlockStart + + + + + + + + + + + + + + + + + AgentInventory.AgentInventory() + AgentInventory.AgentInventory() AgentInventory.Initialise():Void + + + + + + + + + ID + folderID + Id + + + + + + + + + AgentID + + + + + + + + + ID + folderID + Id + + + + + + + + + Initialise + AgentInventory.Initialise():Void + + + + + + + + + InventoryFolders + + + + + + + + + InventoryItems + + + + + + + + + InventoryRoot + + + + + + + + + LastCached + + + + + + + + + ID + itemID + Id + + + + + + + + + Wearables + + + + + Wearables + AgentInventory.Wearables + + + + + + + + + + + + + AssetID + + + + + + + + + ItemID + + + + + + + + + + + + + DefaultType + + + + + + + + + FolderID + + + + + + + + + FolderName + + + + + + + + + Items + + + + + System.Collections.Generic.List`1<OpenSim.Framework.Inventory.InventoryItem> + InventoryFolder.Items + + + + + + + + + OwnerID + + + + + + + + + ParentID + + + + + + + + + Version + + + + + + + + + + + + + AssetID + + + + + + + + + CreatorID + + + + + + + + + Description + + + + + + + + + FolderID + + + + + + + + + InvType + + + + + + + + + ItemID + + + + + + + + + Name + + + + + + + + + OwnerID + + + + + + + + + Type + + + + + + + + + + + + + + + Sim + OpenSim.Framework.Sims.SimProfile + + + + + + + + + SimProfile.LoadFromGrid(UInt64, String, String, String):SimProfile + System.Exception + + + + + GridURL + + + + + SendKey + + + + + RecvKey + + + + + SimProfile.LoadFromGrid(UInt64, String, String, String):SimProfile + Recv + RecvKey + + + + + region_handle + + + + + GridURL + + + + + RecvKey + SimProfile.LoadFromGrid(UInt64, String, String, String):SimProfile + + + + + SimProfile.LoadFromGrid(UInt64, String, String, String):SimProfile + System.Convert.ToUInt16(System.Object) + System.Convert.ToUInt16(System.Object,System.IFormatProvider) + + + + + SimProfile.LoadFromGrid(UInt64, String, String, String):SimProfile + System.Convert.ToUInt32(System.Object) + System.Convert.ToUInt32(System.Object,System.IFormatProvider) + + + SimProfile.LoadFromGrid(UInt64, String, String, String):SimProfile + System.Convert.ToUInt32(System.Object) + System.Convert.ToUInt32(System.Object,System.IFormatProvider) + + + + + SimProfile.LoadFromGrid(UInt64, String, String, String):SimProfile + System.Convert.ToUInt64(System.Object) + System.Convert.ToUInt64(System.Object,System.IFormatProvider) + + + + + SimProfile.LoadFromGrid(UInt64, String, String, String):SimProfile + System.UInt64.ToString + System.UInt64.ToString(System.IFormatProvider) + + + + + + + + + + + Sim + OpenSim.Framework.Sims.SimProfileBase + + + + + + + + + caps_url + + + + + caps_url + + + + + + + + + recvkey + + + + + recvkey + SimProfileBase.recvkey + + + + + + + + + regionhandle + + + + + regionhandle + SimProfileBase.regionhandle + + + + + + + + + RegionLocX + + + + + + + + + RegionLocY + + + + + + + + + regionname + + + + + regionname + SimProfileBase.regionname + + + + + + + + + sendkey + + + + + sendkey + SimProfileBase.sendkey + + + + + + + + + sim_ip + + + + + sim + SimProfileBase.sim_ip + + + + + sim_ip + + + + + + + + + sim_port + + + + + sim + SimProfileBase.sim_port + + + + + sim_port + + + + + + + + + UUID + + + + + + + + + + + + + + + Heightmap + OpenSim.Framework.Terrain.HeightmapGenHills + + + + + + + + + HeightmapGenHills.GenerateHeightmap(Int32, Single, Single, Boolean):Single[] + num + numHills + + + + + Heightmap + HeightmapGenHills.GenerateHeightmap(Int32, Single, Single, Boolean):Single[] + + + + + + + + + HeightmapGenHills.NumHills + + + + + + + + + + + + + + + + + UserProfile.UserProfile() + IsGridGod + System.Boolean + false + + + + + + + + + Sim + UserProfile.AddSimCircuit(UInt32, LLUUID):Void + + + + + regionUUID + + + + + + + + + AssetURL + + + + + + + + + Circuits + + + + + + + + + CurrentSecureSessionID + + + + + + + + + CurrentSessionID + + + + + + + + + firstname + + + + + firstname + UserProfile.firstname + + + + + + + + + homelookat + + + + + homelookat + UserProfile.homelookat + + + + + + + + + homepos + + + + + homepos + UserProfile.homepos + + + + + + + + + homeregionhandle + + + + + homeregionhandle + UserProfile.homeregionhandle + + + + + + + + + Inventory + + + + + + + + + IsGridGod + + + + + + + + + IsLocal + + + + + + + + + lastname + + + + + lastname + UserProfile.lastname + + + + + + + + + MD5passwd + + + + + + + + + UUID + + + + + + + + + + + + + response + + + + + Customise + UserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + + + + + UserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + GridResp + Nwc.XmlRpc.XmlRpcResponse + + + + + UserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + + + UserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.UInt32.ToString + System.UInt32.ToString(System.IFormatProvider) + + + UserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.UInt32.ToString + System.UInt32.ToString(System.IFormatProvider) + + + + + + + + + DefaultStartupMsg + + + + + + + + + GridRecvKey + + + + + Recv + UserProfileManager.GridRecvKey + + + + + + + + + GridSendKey + + + + + + + + + GridURL + + + + + + + + + UserProfileManager.ParseXMLRPC(String):String + System.Exception + + + + + UserProfileManager.ParseXMLRPC(String):String + + + + + UserProfileManager.ParseXMLRPC(String):String + System.Int32.ToString + System.Int32.ToString(System.IFormatProvider) + + + UserProfileManager.ParseXMLRPC(String):String + System.Int32.ToString + System.Int32.ToString(System.IFormatProvider) + + + + + UserProfileManager.ParseXMLRPC(String):String + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.ParseXMLRPC(String):String + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.ParseXMLRPC(String):String + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.ParseXMLRPC(String):String + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.ParseXMLRPC(String):String + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.ParseXMLRPC(String):String + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.ParseXMLRPC(String):String + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.ParseXMLRPC(String):String + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + UserProfileManager.ParseXMLRPC(String):String + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + + + + + + + UserProfileManager.SetKeys(String, String, String, String):Void + recv + recvKey + + + + + url + UserProfileManager.SetKeys(String, String, String, String):Void + + + + + + + + + + + + + UserProfileManagerBase.AuthenticateUser(String, String, String):Boolean + firstname + firstname + + + + + UserProfileManagerBase.AuthenticateUser(String, String, String):Boolean + lastname + lastname + + + + + UserProfileManagerBase.AuthenticateUser(String, String, String):Boolean + passwd + passwd + + + + + + + + + MD5passwd + + + + + UserProfileManagerBase.CreateNewProfile(String, String, String):UserProfile + firstname + firstname + + + + + UserProfileManagerBase.CreateNewProfile(String, String, String):UserProfile + lastname + lastname + + + + + UserProfileManagerBase.CreateNewProfile(String, String, String):UserProfile + M + MD5passwd + + + + + + + + + ProfileLLUUID + + + + + ProfileLLUUID + + + + + UserProfileManagerBase.GetProfileByLLUUID(LLUUID):UserProfile + + + + + + + + + UserProfileManagerBase.GetProfileByName(String, String):UserProfile + firstname + firstname + + + + + UserProfileManagerBase.GetProfileByName(String, String):UserProfile + lastname + lastname + + + + + + + + + ID + agentID + Id + + + + + + + + + GodID + + + + + ID + GodID + Id + + + + + + + + + UserProfiles + + + + + + + + + + + + + + + OpenSim.Framework.Utilities.BlockingQueue`1 + Queue + + + + + + + + + Util + OpenSim.Framework.Utilities.Util + + + + + Util + + + + + Util + System.Web.Util + + + + + + + + + Xfer + Util.GetNextXferID():UInt32 + + + + + Util.GetNextXferID():UInt32 + + + + + GetNextXferID + + + + + + + + + X + + + + + Y + + + + + Util.UIntsToLong(UInt32, UInt32):UInt64 + X + + + + + Util.UIntsToLong(UInt32, UInt32):UInt64 + Y + + + + + Ints + Util.UIntsToLong(UInt32, UInt32):UInt64 + + + + + + + + + + + + + + + + + + + OpenSim.GridInterfaces.Local + + + + + OpenSim.GridInterfaces.Local + + + + + OpenSim.GridInterfaces.Local + + + + + + + + + + + + + Data + + + + + + + + + Name + + + + + + + + + Type + + + + + + + + + UUID + + + + + + + + + + + AssetUUIDQuery + + + + + + + + + 'asset' + AssetUUIDQuery.Match(AssetStorage):Boolean + + + + + + + + + + + Plugin + OpenSim.GridInterfaces.Local.LocalAssetPlugin + + + + + + + + + + + LocalAssetServer.LocalAssetServer() + System.Exception + + + + + + + + + LocalAssetServer.LoadAsset(AssetBase, Boolean, String):Void + + + + + image + LocalAssetServer.LoadAsset(AssetBase, Boolean, String):Void + + + + + + + + + 'asset' + LocalAssetServer.UploadNewAsset(AssetBase):Void + + + + + + + + + + + Plugin + OpenSim.GridInterfaces.Local.LocalGridPlugin + + + + + + + + + + + Logout + LogoutSession + LogOff + + + + + + + + + Sessions + + + + + System.Collections.Generic.List`1<OpenSim.Framework.Interfaces.Login> + LocalGridServer.Sessions + + + + + + + + + + + + + + + + + + + OpenSim.GridInterfaces.Remote + + + + + OpenSim.GridInterfaces.Remote + + + + + OpenSim.GridInterfaces.Remote + + + + + + + + + + + Plugin + OpenSim.GridInterfaces.Remote.RemoteAssetPlugin + + + + + + + + + Plugin + OpenSim.GridInterfaces.Remote.RemoteGridPlugin + + + + + + + + + + + agentcircuits + + + + + + + + + circuitcode + RemoteGridServer.AuthenticateSession(LLUUID, LLUUID, UInt32):AuthenticateResponse + circuitCode + IGridServer.AuthenticateSession(LLUUID, LLUUID, UInt32):AuthenticateResponse + + + + + + + + + RemoteGridServer.GridRecvKey + + + + + + + + + RemoteGridServer.GridSendKey + + + + + + + + + RemoteGridServer.LogoutSession(LLUUID, LLUUID, UInt32):Boolean + WebRequest.Create(Uri):WebRequest + WebRequest.Create(String):WebRequest + + + + + RemoteGridServer.LogoutSession(LLUUID, LLUUID, UInt32):Boolean + GridResponse + System.String + + + + + Logout + LogoutSession + LogOff + + + + + 'sessionID' + RemoteGridServer.LogoutSession(LLUUID, LLUUID, UInt32):Boolean + + + + + + + + + + + + + + + + + + + OpenSim.Physics.Manager + + + + + OpenSim.Physics.Manager + + + + + OpenSim.Physics.Manager + + + + + + + + + + + Plugin + OpenSim.Physics.Manager.IPhysicsPlugin + + + + + + + + + GetName + + + + + + + + + GetScene + + + + + + + + + + + + + 'heightMap' + NullPhysicsScene.SetTerrain(Single[]):Void + + + + + + + + + NullPhysicsScene.Simulate(Single):Void + System.Int32.ToString + System.Int32.ToString(System.IFormatProvider) + + + + + + + + + + + + + Kinematic + PhysicsActor.Kinematic:Boolean + + + + + + + + + + + + + PhysicsManager.GetPhysicsScene(String):PhysicsScene + System.String.Format(System.String,System.Object) + System.String.Format(System.IFormatProvider,System.String,System.Object[]) + + + + + + + + + Plugins + PhysicsManager.LoadPlugins():Void + + + + + + + + + + + + + PhysicsVector.PhysicsVector(Single, Single, Single) + x + + + + + PhysicsVector.PhysicsVector(Single, Single, Single) + y + + + + + PhysicsVector.PhysicsVector(Single, Single, Single) + z + + + + + + + + + X + + + + + X + PhysicsVector.X + + + + + + + + + Y + + + + + Y + PhysicsVector.Y + + + + + + + + + Z + + + + + Z + PhysicsVector.Z + + + + + + + + + PhysicsVector.Zero + OpenSim.Physics.Manager.PhysicsVector + + + + + + + + + + + + + + + + + + + OpenSim.RegionServer + + + + + OpenSim.RegionServer + + + + + OpenSim.RegionServer + + + + + OpenSim.RegionServer + + + + + OpenSim.RegionServer + + + + + + + + + + + + + ID + transactionID + Id + + + + + + + + + ID + transactionID + Id + + + + + + + + + ID + transactionID + Id + + + + + + + + + ID + assetID + Id + + + + + AgentAssetUpload.HandleUploadPacket(AssetUploadRequestPacket, LLUUID):Void + System.Int32.ToString(System.String) + System.Int32.ToString(System.String,System.IFormatProvider) + + + AgentAssetUpload.HandleUploadPacket(AssetUploadRequestPacket, LLUUID):Void + System.Int32.ToString(System.String) + System.Int32.ToString(System.String,System.IFormatProvider) + + + + + 'assetID' + AgentAssetUpload.HandleUploadPacket(AssetUploadRequestPacket, LLUUID):Void + + + 'pack' + AgentAssetUpload.HandleUploadPacket(AssetUploadRequestPacket, LLUUID):Void + + + + + + + + + AgentAssetUpload.HandleXferPacket(SendXferPacketPacket):Void + xfer + xferPacket + + + + + Xfer + AgentAssetUpload.HandleXferPacket(SendXferPacketPacket):Void + + + + + + + + + + + + + AssetTransaction.AssetTransaction() + UploadComplete + System.Boolean + false + + + + + + + + + AddToInventory + + + + + + + + + Asset + + + + + + + + + InventFolder + + + + + + + + + TransactionID + + + + + + + + + UploadComplete + + + + + + + + + XferID + + + + + Xfer + AssetTransaction.XferID + + + + + + + + + + + Grid + OpenSim.Framework.Grid + + + + + + + + + AssetDll + + + + + + + + + AssetServer + + + + + + + + + GridDll + + + + + + + + + GridServer + + + + + + + + + Initialise + Grid.Initialise():Void + + + + + + + + + Grid.LoadAssetDll(String):IAssetServer + + + + + + + + + Grid.LoadGridDll(String):IGridServer + + + + + + + + + + + Sim + OpenSim.OpenSimApplication + + + + + + + + + OpenSimApplication.RemoveClientCircuit(UInt32):Void + circuitcode + circuitcode + + + + + + + + + OpenSimApplication.SendPacketTo(Byte[], Int32, SocketFlags, UInt32):Void + circuitcode + circuitcode + + + + + + + + + StartUp + method + StartUp + Startup + + + + + + + + + + + Sim + OpenSim.OpenSimMain + + + + + OpenSim.OpenSimMain + System.Timers.Timer, System.Net.Sockets.Socket + + + + + + + + + OpenSimMain.OpenSimMain() + loginserver + System.Boolean + false + + + OpenSimMain.OpenSimMain() + sandbox + System.Boolean + false + + + + + + + + + _physicsEngine + + + + + _physicsEngine + + + + + + + + + OpenSimMain.LoadConfigDll(String):SimConfig + + + + + + + + + loginserver + + + + + loginserver + OpenSimMain.loginserver + + + + + + + + + sandbox + + + + + + + + + Server + + + + + + + + + Timer.set_Interval(Double):Void + OpenSimMain.StartUp():Void + + + + + OpenSimMain.StartUp():Void + System.UInt32.ToString + System.UInt32.ToString(System.IFormatProvider) + + + OpenSimMain.StartUp():Void + System.UInt32.ToString + System.UInt32.ToString(System.IFormatProvider) + + + + + + + + + + + Sim + OpenSim.OpenSimRoot + + + + + + + + + OpenSimRoot.OpenSimRoot() + Sandbox + System.Boolean + false + + + + + + + + + Application + + + + + + + + + AssetCache + + + + + + + + + Cfg + + + + + Cfg + OpenSimRoot.Cfg + + + + + + + + + ClientThreads + + + + + + + + + GridServers + + + + + + + + + HttpServer + + + + + + + + + InventoryCache + + + + + + + + + LocalWorld + + + + + + + + + Sandbox + + + + + + + + + StartUp + method + StartUp + Startup + + + + + + + + + startuptime + + + + + startuptime + OpenSimRoot.startuptime + + + + + + + + + + + Que + OpenSim.QueItem + + + + + + + + + Incoming + + + + + + + + + Packet + + + + + + + + + + + Sim + OpenSim.SimClient + + + + + OpenSim.SimClient + System.Timers.Timer + + + + + + + + + SimClient.SimClient(EndPoint, UseCircuitCodePacket) + Sequence + System.UInt32 + 0 + + + SimClient.SimClient(EndPoint, UseCircuitCodePacket) + debug + System.Boolean + false + + + + + Timer.Timer(Double) + SimClient.SimClient(EndPoint, UseCircuitCodePacket) + + + + + SimClient.SimClient(EndPoint, UseCircuitCodePacket) + initialcirpack + initialcirpack + + + + + + + + + AgentID + + + + + + + + + CircuitCode + + + + + + + + + ClientAvatar + + + + + + + + + NewPack + + + + + + + + + SimClient.newAssetFolder + + + + + + + + + NewPack + + + + + + + + + Pack + + + + + SimClient.ProcessInPacket(Packet):Void + wear + libsecondlife.Packets.AgentIsNowWearingPacket + + + + + op_Equality + "" + SimClient.ProcessInPacket(Packet):Void + + + + + + + + + SimClient.ProcessOutPacket(Packet):Void + System.Exception + + + + + Pack + + + + + + + + + SecureSessionID + + + + + + + + + SessionID + + + + + + + + + userEP + + + + + + + + + + + OpenSim.SimConsole + OpenSim.Framework.Console.ConsoleBase + + + + + Sim + OpenSim.SimConsole + + + + + + + + + SimConsole.SimConsole(ConsoleType, String, Int32) + constype + constype + + + + + SimConsole.SimConsole(ConsoleType, String, Int32) + sparam + sparam + + + + + SimConsole.SimConsole(ConsoleType, String, Int32) + iparam + iparam + + + + + iparam + SimConsole.SimConsole(ConsoleType, String, Int32) + + + + + sparam + SimConsole.SimConsole(ConsoleType, String, Int32) + + + + + + + + + op_Equality + "" + SimConsole.CmdPrompt(String, String):String + + + + + + + + + SimConsole.ConsType + + + + + + + + + SimConsole.MainConsolePrompt():Void + System.UInt64.ToString + System.UInt64.ToString(System.IFormatProvider) + + + + + + + + + 'cmdparams' + SimConsole.RunCmd(String, String[]):Object + + + + + + + + + SimConsole.ShowCommands(String):Void + System.String.Format(System.String,System.Object[]) + System.String.Format(System.IFormatProvider,System.String,System.Object[]) + + + SimConsole.ShowCommands(String):Void + System.String.Format(System.String,System.Object[]) + System.String.Format(System.IFormatProvider,System.String,System.Object[]) + + + + + + + + + + + + + Version + + + + + + + + + + + + + + + + + ID + imageID + Id + + + + + + + + + AssetRequests + + + + + System.Collections.Generic.List`1<OpenSim.Assets.AssetRequest> + AssetCache.AssetRequests + + + + + + + + + Assets + + + + + + + + + sourceAsset + AssetCache.CloneAsset(LLUUID, AssetInfo):AssetInfo + OpenSim.Assets.AssetInfo + OpenSim.Framework.Assets.AssetBase + + + + + AssetCache.CloneAsset(LLUUID, AssetInfo):AssetInfo + + + + + newOwner + AssetCache.CloneAsset(LLUUID, AssetInfo):AssetInfo + + + + + 'sourceAsset' + AssetCache.CloneAsset(LLUUID, AssetInfo):AssetInfo + + + + + + + + + source + AssetCache.CloneImage(LLUUID, TextureImage):TextureImage + OpenSim.Assets.TextureImage + OpenSim.Framework.Assets.AssetBase + + + + + AssetCache.CloneImage(LLUUID, TextureImage):TextureImage + + + + + newOwner + AssetCache.CloneImage(LLUUID, TextureImage):TextureImage + + + + + 'source' + AssetCache.CloneImage(LLUUID, TextureImage):TextureImage + + + + + + + + + ID + agentID + Id + + + + + + + + + ID + assetID + Id + + + + + + + + + RequestedAssets + + + + + + + + + RequestedTextures + + + + + + + + + AssetCache.RunAssetManager():Void + System.Exception + + + + + + + + + TextureRequests + + + + + System.Collections.Generic.List`1<OpenSim.Assets.AssetRequest> + AssetCache.TextureRequests + + + + + + + + + Textures + + + + + + + + + + + OpenSim.Assets.AssetInfo + OpenSim.Framework.Assets.AssetBase + + + + + + + + + AssetInfo.AssetInfo(AssetBase) + a + aBase + + + + + 'aBase' + AssetInfo.AssetInfo(AssetBase) + + + + + + + + + + + + + AssetRequest.AssetRequest() + DataPointer + System.Int64 + 0 + + + AssetRequest.AssetRequest() + NumPackets + System.Int32 + 0 + + + AssetRequest.AssetRequest() + PacketCounter + System.Int32 + 0 + + + + + + + + + AssetInf + + + + + + + + + DataPointer + + + + + + + + + ImageInfo + + + + + + + + + IsTextureRequest + + + + + + + + + NumPackets + + + + + Num + AssetRequest.NumPackets + + + + + + + + + PacketCounter + + + + + + + + + RequestAssetID + + + + + + + + + RequestUser + + + + + + + + + TransferRequestID + + + + + + + + + + + + + ID + folderID + Id + + + + + + + + + ID + clientID + Id + + + + + + + + + ID + folderID + Id + + + + + + + + + ID + folderID + Id + + + + + + + + + FetchItems + + + + + + + + + FetchDescend + + + + + + + + + ID + agentID + Id + + + + + + + + + ID + itemID + Id + + + + + + + + + + + OpenSim.Assets.TextureImage + OpenSim.Framework.Assets.AssetBase + + + + + + + + + TextureImage.TextureImage(AssetBase) + a + aBase + + + + + 'aBase' + TextureImage.TextureImage(AssetBase) + + + + + + + + + + + + + + + Sim + OpenSim.CAPS.SimCAPSHTTPServer + + + + + SimCAPSHTTPServer + + + + + OpenSim.CAPS.SimCAPSHTTPServer + System.Net.HttpListener + + + + + + + + + SimCAPSHTTPServer.HandleRequest(Object):Void + stateinfo + stateinfo + + + + + + + + + HTTPD + + + + + + + + + Listener + + + + + + + + + SimCAPSHTTPServer.LoadAdminPage():Void + System.Exception + + + + + + + + + SimCAPSHTTPServer.ParseLLSDXML(String):String + + + + + requestBody + SimCAPSHTTPServer.ParseLLSDXML(String):String + + + + + + + + + SimCAPSHTTPServer.ParseREST(String, String, String):String + System.Exception + + + + + SimCAPSHTTPServer.ParseREST(String, String, String):String + System.String.Format(System.String,System.Object[]) + System.String.Format(System.IFormatProvider,System.String,System.Object[]) + + + + + + + + + SimCAPSHTTPServer.ParseXMLRPC(String):String + System.Exception + + + + + SimCAPSHTTPServer.ParseXMLRPC(String):String + + + + + SimCAPSHTTPServer.ParseXMLRPC(String):String + System.Convert.ToUInt32(System.Object) + System.Convert.ToUInt32(System.Object,System.IFormatProvider) + + + + + + + + + SimCAPSHTTPServer.StartHTTP():Void + System.Exception + + + + + SimCAPSHTTPServer.StartHTTP():Void + + + + + + + + + + + + + + + + + mesh + + + + + System.Collections.Generic.List`1<OpenSim.types.Triangle> + Mesh.mesh + + + + + + + + + Mesh.op_Addition(Mesh, Mesh):Mesh + a + + + + + Mesh.op_Addition(Mesh, Mesh):Mesh + b + + + + + Add + Mesh.op_Addition(Mesh, Mesh):Mesh + + + + + Mesh + Mesh.op_Addition(Mesh, Mesh):Mesh + + + + + + + + + + + + + A + + + + + B + + + + + C + + + + + Triangle.Triangle(Vector3, Vector3, Vector3) + A + + + + + Triangle.Triangle(Vector3, Vector3, Vector3) + B + + + + + Triangle.Triangle(Vector3, Vector3, Vector3) + C + + + + + + + + + + + + + + + + + LocalUserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Int32.ToString + System.Int32.ToString(System.IFormatProvider) + + + LocalUserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Int32.ToString + System.Int32.ToString(System.IFormatProvider) + + + + + LocalUserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + LocalUserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + LocalUserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + LocalUserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + LocalUserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + LocalUserProfileManager.CustomiseResponse(Hashtable&, UserProfile):Void + System.Single.ToString + System.Single.ToString(System.IFormatProvider) + + + + + + + + + + + OpenSim.UserServer.LoginServer + OpenSim.Framework.Grid.LoginService + + + + + OpenSim.UserServer.LoginServer + System.Net.Sockets.Socket + + + + + Login + LoginServer + LogOn + + + + + + + + + LoginServer.LoginServer(IGridServer) + _needPasswd + System.Boolean + false + + + LoginServer.LoginServer(IGridServer) + userAccounts + System.Boolean + false + + + + + + + + + LoginServer.Authenticate(String, String, String):Boolean + passwd + passwd + + + + + + + + + clientAddress + + + + + + + + + Customise + LoginServer.CustomiseLoginResponse(Hashtable, String, String):Void + + + + + Login + CustomiseLoginResponse + LogOn + + + + + + + + + LoginServer.EncodePassword(String):String + System.String.ToLower + System.String.ToLower(System.Globalization.CultureInfo) + + + + + + + + + LoginServer.GetAgentId(String, String):LLUUID + System.Int32.ToString(System.String) + System.Int32.ToString(System.String,System.IFormatProvider) + + + + + + + + + LoginServer.InitializeLogin():Void + 4 + UserProfileManager.SetKeys(String, String, String, String):Void + Welcome to OpenSim + + + + + Sim + OpenSim + + + + + + + + + LoginServer.LoginRequest(StreamReader, StreamWriter):Void + System.Exception + + + + + LoginServer.LoginRequest(StreamReader, StreamWriter):Void + System.Convert.ToInt32(System.String) + System.Convert.ToInt32(System.String,System.IFormatProvider) + + + + + op_Inequality + "" + LoginServer.LoginRequest(StreamReader, StreamWriter):Void + + + + + + + + + writer + LoginServer.ProcessXmlRequest(XmlRpcRequest, StreamWriter):Boolean + System.IO.StreamWriter + System.IO.TextWriter + + + + + LoginServer.ProcessXmlRequest(XmlRpcRequest, StreamWriter):Boolean + System.Int32.ToString + System.Int32.ToString(System.IFormatProvider) + + + + + LoginServer.ProcessXmlRequest(XmlRpcRequest, StreamWriter):Boolean + System.Int32.ToString(System.String) + System.Int32.ToString(System.String,System.IFormatProvider) + + + + + 'request' + LoginServer.ProcessXmlRequest(XmlRpcRequest, StreamWriter):Boolean + + + 'writer' + LoginServer.ProcessXmlRequest(XmlRpcRequest, StreamWriter):Boolean + + + 'writer' + LoginServer.ProcessXmlRequest(XmlRpcRequest, StreamWriter):Boolean + + + + + + + + + remoteAddress + + + + + + + + + LoginServer.RunLogin():Void + System.Exception + + + LoginServer.RunLogin():Void + System.Exception + + + + + LoginServer.RunLogin():Void + clientEndPoint + System.Net.IPEndPoint + + + + + + + + + + + + + + + + + Avatar.Avatar() + PhysicsEngineFlying + System.Boolean + false + + + + + + + + + Avatar.Avatar(SimClient) + _updateCount + System.Int16 + 0 + + + Avatar.Avatar(SimClient) + avatarAppearanceTexture + libsecondlife.LLObject+TextureEntry + null + + + Avatar.Avatar(SimClient) + movementflag + System.Byte + 0 + + + Avatar.Avatar(SimClient) + updateflag + System.Boolean + false + + + + + TheClient + + + + + + + + + anim_seq + + + + + anim + Avatar.anim_seq + + + + + anim_seq + + + + + + + + + Animations + + + + + + + + + RegionInfo + + + + + RegionInfo + Avatar.CompleteMovement(World):Void + + + + + + + + + ControllingClient + + + + + + + + + current_anim + + + + + anim + Avatar.current_anim + + + + + current_anim + + + + + + + + + firstname + + + + + firstname + Avatar.firstname + + + + + + + + + lastname + + + + + lastname + Avatar.lastname + + + + + + + + + Anims + Avatar.LoadAnims():Void + + + + + + + + + PhysActor + + + + + + + + + PhysicsEngineFlying + + + + + + + + + Anim + Avatar.SendAnimPack():Void + + + + + + + + + 'userInfo' + Avatar.SendAppearanceToOtherAgent(SimClient):Void + + + + + + + + + RegionInfo + + + + + RegionInfo + Avatar.SendRegionHandshake(World):Void + + + + + + + + + + + + + AnimsLLUUID + + + + + Anims + AvatarAnimations.AnimsLLUUID + + + + + + + + + AnimsNames + + + + + Anims + AvatarAnimations.AnimsNames + + + + + + + + + Anims + AvatarAnimations.LoadAnims():Void + + + + + + + + + + + + + Entity.Entity() + localid + System.UInt32 + 0 + + + + + + + + + addForces + + + + + + + + + BackUp + method + BackUp + Backup + + + + + + + + + children + + + + + System.Collections.Generic.List`1<OpenSim.world.Entity> + Entity.children + + + + + + + + + getMesh + + + + + + + + + getName + + + + + + + + + localid + + + + + localid + Entity.localid + + + + + + + + + name + + + + + + + + + position + + + + + + + + + rotation + + + + + + + + + update + + + + + + + + + uuid + + + + + uuid + Entity.uuid + + + + + + + + + velocity + + + + + + + + + + + + + X + + + + + X + NewForce.X + + + + + + + + + Y + + + + + Y + NewForce.Y + + + + + + + + + Z + + + + + Z + NewForce.Z + + + + + + + + + + + 'UpdateFlag' + updateFlag + + + + + + + + + Primitive.Primitive() + dirtyFlag + System.Boolean + false + + + Primitive.Primitive() + mesh_cutbegin + System.Single + 0.0 + + + Primitive.Primitive() + newPrimFlag + System.Boolean + false + + + Primitive.Primitive() + physicsEnabled + System.Boolean + false + + + Primitive.Primitive() + physicstest + System.Boolean + false + + + Primitive.Primitive() + updateFlag + System.Boolean + false + + + + + + + + + localID-702000 + Primitive.CreateFromPacket(ObjectAddPacket, LLUUID, UInt32):Void + + + + + ID + agentID + Id + + + + + ID + localID + Id + + + + + Primitive.CreateFromPacket(ObjectAddPacket, LLUUID, UInt32):Void + System.UInt32.ToString(System.String) + System.UInt32.ToString(System.String,System.IFormatProvider) + + + + + 'addPacket' + Primitive.CreateFromPacket(ObjectAddPacket, LLUUID, UInt32):Void + + + + + + + + + 'store' + Primitive.CreateFromStorage(PrimData):Void + + + + + + + + + dirtyFlag + + + + + + + + + mesh_cutbegin + + + + + cutbegin + Primitive.mesh_cutbegin + + + + + mesh_cutbegin + + + + + + + + + mesh_cutend + + + + + cutend + Primitive.mesh_cutend + + + + + mesh_cutend + + + + + + + + + newPrimFlag + + + + + + + + + PhysActor + + + + + + + + + primData + + + + + + + + + RemoteClient + + + + + 'RemoteClient' + Primitive.UpdateClient(SimClient):Void + + + + + + + + + updateFlag + + + + + + + + + 'pack' + Primitive.UpdateObjectFlags(ObjectFlagUpdatePacket):Void + + + + + + + + + 'addPacket' + Primitive.UpdateShape(ObjectDataBlock):Void + + + + + + + + + + + + + ScriptEngine.ScriptEngine(World) + env + env + + + + + env + ScriptEngine.ScriptEngine(World) + + + + + + + + + ScriptEngine.LoadScript():Void + + + + + + + + + + + + + HeightMap + + + + + + + + + + + World + OpenSim.world + + + + + + + + + World.World() + _localNumber + System.UInt32 + 0 + + + + + + + + + _localNumber + + + + + _localNumber + + + + + + + + + AgentClient + + + + + + + + + AgentClient + + + + + + + + + DeRezPacket + + + + + AgentClient + + + + + World.DeRezObject(DeRezObjectPacket, SimClient):Void + Rez + DeRezPacket + + + + + Rez + World.DeRezObject(DeRezObjectPacket, SimClient):Void + + + + + AgentClient + World.DeRezObject(DeRezObjectPacket, SimClient):Void + + + + + De + World.DeRezObject(DeRezObjectPacket, SimClient):Void + + + + + + + + + Entities + + + + + + + + + RemoteClient + + + + + Prims + World.GetInitialPrims(SimClient):Void + + + + + + + + + LandMap + + + + + + + + + Prims + World.LoadPrimsFromStorage():Void + + + + + + + + + World.LoadStorageDLL(String):Boolean + + + + + + + + + localStorage + + + + + + + + + World.Rand + + + + + + + + + Scripts + + + + + + + + + RemoteClient + + + + + 'RemoteClient' + World.SendLayerData(SimClient):Void + + + 'RemoteClient' + World.SendLayerData(SimClient):Void + + + 'RemoteClient' + World.SendLayerData(SimClient):Void + + + + + + + + + + + + + + + + + IScriptHost.Register(IScript):Boolean + iscript + iscript + + + + + + + + + + + + + + + + + + + OpenSim.Storage.LocalStorageDb4o + + + + + OpenSim.Storage.LocalStorageDb4o + + + + + OpenSim.Storage.LocalStorageDb4o + + + + + + + + + + + + + Db4LocalStorage.Db4LocalStorage() + System.Exception + + + + + + + + + 'receiver' + Db4LocalStorage.LoadPrimitives(ILocalStorageReceiver):Void + + + + + + + + + 'prim' + Db4LocalStorage.StorePrim(PrimData):Void + + + + + + + + + + + UUIDQuery + + + + + + + + + 'prim' + UUIDQuery.Match(PrimData):Boolean + + + + + + + + + + + + + + + + + + + OpenSim.Physics.BasicPhysicsPlugin + + + + + + + + + + OpenSim.Physics.BasicPhysicsPlugin + + + + + + + + + + OpenSim.Physics.BasicPhysicsPlugin + + + + + + + + + + + + + + + + + + BasicActor.flying + + + + + + + + + BasicActor.SetAcceleration(PhysicsVector):Void + accel + accel + + + + + + + + + + + Plugin + OpenSim.Physics.BasicPhysicsPlugin.BasicPhysicsPlugin + + + + + BasicPhysicsPlugin + OpenSim.Physics.BasicPhysicsPlugin + + + + + + + + + + + + + + + + + OpenSim.Physics.OdePlugin + + + + + OpenSim.Physics.OdePlugin + + + + + OpenSim.Physics.OdePlugin + + + + + + + + + + + OdeCharacter + + + + + + + + + parent_scene + OdeCharacter.OdeCharacter(OdeScene, PhysicsVector) + + + + + 'pos' + OdeCharacter.OdeCharacter(OdeScene, PhysicsVector) + + + + + + + + + OdeCharacter.capsule_geom + + + + + + + + + OdeCharacter.gravityAccel + + + + + + + + + OdeCharacter.SetAcceleration(PhysicsVector):Void + accel + accel + + + + + + + + + + + Plugin + OpenSim.Physics.OdePlugin.OdePlugin + + + + + OdePlugin + OpenSim.Physics.OdePlugin + + + + + + + + + + + OdePrim._position + + + + + + + + + OdePrim.SetAcceleration(PhysicsVector):Void + accel + accel + + + + + + + + + + + + + 'position' + OdeScene.AddPrim(PhysicsVector, PhysicsVector):PhysicsActor + + + 'size' + OdeScene.AddPrim(PhysicsVector, PhysicsVector):PhysicsActor + + + + + + + + + OdeScene.Land + + + + + + + + + OdeScene.LandGeom + + + + + + + + + 'heightMap' + OdeScene.SetTerrain(Single[]):Void + + + 'heightMap' + OdeScene.SetTerrain(Single[]):Void + + + + + + + + + space + + + + + space + + + + + + + + + world + + + + + world + + + + + + + + + + + + + + + + + + + OpenSim.Physics.PhysXPlugin + + + + + OpenSim.Physics.PhysXPlugin + + + + + OpenSim.Physics.PhysXPlugin + + + + + + + + + + + + + PhysXCharacter.SetAcceleration(PhysicsVector):Void + accel + accel + + + + + + + + + + + Plugin + OpenSim.Physics.PhysXPlugin.PhysXPlugin + + + + + PhysXPlugin + OpenSim.Physics.PhysXPlugin + + + + + + + + + + + PhysXPrim._position + + + + + + + + + PhysXPrim.SetAcceleration(PhysicsVector):Void + accel + accel + + + + + + + + + + + + + + + + Save it for a rainy day. + Save it for a rainy day. + Save it for a rainy day. + + + + + No valid permission requests were found for assembly '{0}'. You should always specify the minimum security permissions using SecurityAction.RequestMinimum. + + + Sign '{0}' with a strong name key. + + + Consider merging the types defined in '{0}' with another namespace. + + + It appears that field '{0}' is never used or is only ever assigned to. Use this field or remove it. + + + Change '{0}' to be read-only by removing the property setter. + + + The compound word '{0}' in {1} '{2}' exists as a discrete term. If your usage is intended to be single word, case it as '{3}'. + + + '{0}' is marked ComVisible(true) but has the following ComVisible(false) types in its object hierarchy: {1} + + + Consider changing the type of parameter '{0}' in {1} from {2} to its base type {3}. This method appears to only require base class members in its implementation. Suppress this violation if there is a compelling reason to require the more derived type in the method signature. + + + '{0}' contains a call chain that results in a call to a virtual method defined by the class. Review the following call stack for unintended consequences: {1} + + + Modify '{0}' to catch a more specific exception than '{1}' or rethrow the exception. + + + Remove the readonly declaration from '{0}' or change the field to one that is an immutable reference type. If the reference type '{1}' is, in fact, immutable, exclude this message. + + + Make '{0}' private or internal (Friend in VB, public private in C++) and provide a public or protected property to access it. + + + Change '{0}' in {1} to use Collection<T>, ReadOnlyCollection<T> or KeyedCollection<K,V> + + + {0} initializes field {1} of type {2} to {3}. Remove this initialization as it will be done automatically by the runtime. + + + {0} passes a literal as parameter {1} of a call to {2}. Retrieve the following string argument from a resource table instead: '{3}' + + + Consider a design that does not require that '{0}' be a reference parameter. + + + {0} creates an exception of type '{1}', an exception type that is not sufficiently specific and should never be raised by user code. If this exception instance might be thrown, use a different exception type. + + + Modify the call to {0} in method {1} to set the timer interval to a value that's greater than or equal to one second. + + + Correct the casing of member name '{0}'. + Correct the casing of namespace name '{0}'. + Correct the casing of parameter name '{0}'. + Correct the casing of type name '{0}'. + + + Correct the spelling of the unrecognized token '{0}' in member name '{1}'. + Consider providing a more meaningful name than the one-letter token '{0}' in member name '{1}'. + Correct the spelling of the unrecognized token '{0}' in namespace '{1}'. + In method {0}, correct the spelling of the unrecognized token '{1}' in parameter name '{2}' or strip it entirely if it represents any sort of hungarian notation. + In method {0}, consider providing a more meaningful name than the one-letter parameter name '{1}'. + Correct the spelling of the unrecognized token '{0}' in type name '{1}'. + + + Change member names {0} and '{1}' so that they differ by more than case. + + + Remove all underscores from member '{0}'. + Remove all underscores from parameter '{0}'. + Remove all underscores from type '{0}'. + + + Rename '{0}' so that it does not end in '{1}'. + + + Correct the spelling of the unrecognized token '{0}' in the literal '{1}'. + + + Correct the capitalization of member name '{0}'. + Correct the capitalization of namespace name '{0}'. + Correct the capitalization of parameter name '{0}'. + Correct the capitalization of type name '{0}'. + + + Add an AssemblyVersion attribute to '{0}'. + + + '{0}' should be marked with CLSCompliantAttribute and its value should be true. + + + Mark '{0}' as ComVisible(false) at the assembly level, then mark all types within the assembly that should be exposed to Com clients as ComVisible(true). + + + The 'this' parameter (or 'Me' in VB) of {0} is never used. Mark the member as static (or Shared in VB) or use 'this'/'Me' in the method body or at least one property accessor, if appropriate. + + + Consider making '{0}' non-public or a constant. + + + Correct the potential overflow in the operation '{0}' in '{1}'. + + + Provide a method named '{0}' as a friendly alternate for operator {1}. + + + Consider adding an overload of the equality operator for '{0}' that takes the same parameters as {1}. + + + '{0}' should override Equals. + '{0}' should override the equality (==) and inequality (!=) operators. + + + Change parameter name '{0}' of method {1} to '{2}' in order to match the identifier as it has been declared in {3}. + + + Modify {0} to call {1} instead of {2}. + + + Make '{0}' private. + + + Add a property getter to '{0}'. + + + {0} declares a local, '{1}', of type {2}, which is never used or is only assigned to. Use this local or remove it. + + + Parameter '{0}' of {1} is never used. Remove the parameter or use it in the method body. + + + Correct the capitalization of '{0}' in member name '{1}'. + 'Id' is an abbreviation and therefore is not subject to acronym casing guidelines. Correct the capitalization of 'ID' in member name '{0}' by changing it to 'Id'. + 'Id' is an abbreviation and therefore is not subject to acronym casing guidelines. Correct the capitalization of '{0}' in parameter name '{1}' by changing it to '{2}'. + Correct the capitalization of '{0}' in type name '{1}'. + + + {0} makes a call to {1} that does not explicitly provide a CultureInfo. This should be replaced with a call to {2}. + + + {0} makes a call to {1} that does not explicitly provide an IFormatProvider. This should be replaced with a call to {2}. + + + Remove the public constructors from '{0}'. + + + Replace the call to String.{0}({1}) in '{2}' with a call to String.IsNullOrEmpty. + + + The type name '{0}' conflicts in whole or in part with the namespace name '{1}'. Change either name to eliminate the conflict. + + + Implement IDisposable on '{0}' as it instantiates members of the following IDisposable types: {1} + + + Implement IDisposable on '{0}'. + + + Change the type of parameter '{0}' of method {1} from string to System.Uri, or provide an overload of {1}, that allows '{0}' to be passed as a System.Uri object. + + + Replace the term '{0}' in member name '{1}' with the preferred alternate '{2}'. + Replace the term '{0}' in type name '{1}' with the preferred alternate '{2}'. + + + Change '{0}' to a property if appropriate. + + + Validate parameter {0} passed to externally visible method {1}. + + + + diff --git a/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj b/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj new file mode 100644 index 0000000000..98e813e9c6 --- /dev/null +++ b/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj @@ -0,0 +1,93 @@ + + + Local + 8.0.50727 + 2.0 + {E88EF749-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.GenericConfig.Xml + JScript + Grid + IE50 + false + Library + + OpenSim.GenericConfig.Xml + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user b/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build b/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build new file mode 100644 index 0000000000..9b63b42dc1 --- /dev/null +++ b/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs b/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..de5f48df02 --- /dev/null +++ b/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.GenericConfig")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenSim.GenericConfig")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("285a3047-f165-46c8-8767-b51428738a09")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim.GenericConfig/Xml/XmlConfig.cs b/OpenSim.GenericConfig/Xml/XmlConfig.cs new file mode 100644 index 0000000000..62e3cbfce7 --- /dev/null +++ b/OpenSim.GenericConfig/Xml/XmlConfig.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using OpenSim.Framework.Interfaces; + +namespace OpenSim.GenericConfig +{ + public class XmlConfig : IGenericConfig + { + private XmlDocument doc; + private XmlNode rootNode; + private XmlNode configNode; + private string fileName; + private bool createdFile = false; + + public XmlConfig(string filename) + { + fileName = filename; + } + + public void LoadData() + { + doc = new XmlDocument(); + try + { + if (System.IO.File.Exists(fileName)) + { + XmlTextReader reader = new XmlTextReader(fileName); + reader.WhitespaceHandling = WhitespaceHandling.None; + doc.Load(reader); + reader.Close(); + } + else + { + createdFile = true; + rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); + doc.AppendChild(rootNode); + configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); + rootNode.AppendChild(configNode); + } + + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return; + } + try + { + rootNode = doc.FirstChild; + if (rootNode.Name != "Root") + throw new Exception("Error: Invalid .xml File. Missing "); + + configNode = rootNode.FirstChild; + if (configNode.Name != "Config") + throw new Exception("Error: Invalid .xml File. first child should be "); + + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + if (createdFile) + { + this.Commit(); + } + } + + public string GetAttribute(string attributeName) + { + string result = ""; + if (configNode.Attributes[attributeName] != null) + { + result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value; + } + return result; + } + + public bool SetAttribute(string attributeName, string attributeValue) + { + if (configNode.Attributes[attributeName] != null) + { + ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; + } + else + { + XmlAttribute attri; + attri = doc.CreateAttribute(attributeName); + attri.Value = attributeValue; + configNode.Attributes.Append(attri); + } + return true; + } + + public void Commit() + { + doc.Save(fileName); + } + + public void Close() + { + configNode = null; + rootNode = null; + doc = null; + } + + } +} diff --git a/OpenSim.GridInterfaces/Local/AssemblyInfo.cs b/OpenSim.GridInterfaces/Local/AssemblyInfo.cs new file mode 100644 index 0000000000..103b49a207 --- /dev/null +++ b/OpenSim.GridInterfaces/Local/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("LocalGridServers")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("LocalGridServers")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.GridInterfaces/Local/LocalAssetServer.cs b/OpenSim.GridInterfaces/Local/LocalAssetServer.cs new file mode 100644 index 0000000000..fc0ba4a04a --- /dev/null +++ b/OpenSim.GridInterfaces/Local/LocalAssetServer.cs @@ -0,0 +1,248 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.IO; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Utilities; +using libsecondlife; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; + +namespace OpenSim.GridInterfaces.Local +{ + public class LocalAssetPlugin : IAssetPlugin + { + public LocalAssetPlugin() + { + + } + + public IAssetServer GetAssetServer() + { + return (new LocalAssetServer()); + } + } + + public class LocalAssetServer : IAssetServer + { + private IAssetReceiver _receiver; + private BlockingQueue _assetRequests; + private IObjectContainer db; + private Thread _localAssetServerThread; + + public LocalAssetServer() + { + bool yapfile; + this._assetRequests = new BlockingQueue(); + yapfile = System.IO.File.Exists("assets.yap"); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Local Asset Server class created"); + try + { + db = Db4oFactory.OpenFile("assets.yap"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4 Asset database creation"); + } + catch (Exception e) + { + db.Close(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4 Asset server :Constructor - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); + } + if (!yapfile) + { + this.SetUpAssetDatabase(); + } + this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); + this._localAssetServerThread.IsBackground = true; + this._localAssetServerThread.Start(); + + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void RequestAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + + } + + public void UploadNewAsset(AssetBase asset) + { + AssetStorage store = new AssetStorage(); + store.Data = asset.Data; + store.Name = asset.Name; + store.UUID = asset.FullID; + db.Set(store); + db.Commit(); + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + + } + public void Close() + { + if (db != null) + { + Console.WriteLine("Closing local Asset server database"); + db.Close(); + } + } + + private void RunRequests() + { + while (true) + { + byte[] idata = null; + bool found = false; + AssetStorage foundAsset = null; + ARequest req = this._assetRequests.Dequeue(); + IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); + if (result.Count > 0) + { + foundAsset = (AssetStorage)result.Next(); + found = true; + } + + AssetBase asset = new AssetBase(); + if (found) + { + asset.FullID = foundAsset.UUID; + asset.Type = foundAsset.Type; + asset.InvType = foundAsset.Type; + asset.Name = foundAsset.Name; + idata = foundAsset.Data; + } + else + { + asset.FullID = LLUUID.Zero; + } + asset.Data = idata; + _receiver.AssetReceived(asset, req.IsTexture); + } + + } + + private void SetUpAssetDatabase() + { + try + { + + Console.WriteLine("setting up Asset database"); + + AssetBase Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); + Image.Name = "Bricks"; + this.LoadAsset(Image, true, "bricks.jp2"); + AssetStorage store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); + Image.Name = "Plywood"; + this.LoadAsset(Image, true, "plywood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); + Image.Name = "Rocks"; + this.LoadAsset(Image, true, "rocks.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); + Image.Name = "Granite"; + this.LoadAsset(Image, true, "granite.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); + Image.Name = "Hardwood"; + this.LoadAsset(Image, true, "hardwood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); + Image.Name = "Prim Base Texture"; + this.LoadAsset(Image, true, "plywood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + Image.Name = "Shape"; + this.LoadAsset(Image, false, "base_shape.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + + } + + private void LoadAsset(AssetBase info, bool image, string filename) + { + //should request Asset from storage manager + //but for now read from file + + string dataPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; + string fileName = Path.Combine(dataPath, filename); + FileInfo fInfo = new FileInfo(fileName); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + byte[] idata = new byte[numBytes]; + BinaryReader br = new BinaryReader(fStream); + idata = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + info.Data = idata; + //info.loaded=true; + } + } +} diff --git a/OpenSim.GridInterfaces/Local/LocalGridServer.cs b/OpenSim.GridInterfaces/Local/LocalGridServer.cs new file mode 100644 index 0000000000..311179ba37 --- /dev/null +++ b/OpenSim.GridInterfaces/Local/LocalGridServer.cs @@ -0,0 +1,156 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Threading; +using System.IO; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using libsecondlife; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; + +namespace OpenSim.GridInterfaces.Local +{ + /// + /// + /// + /// + public class LocalGridPlugin : IGridPlugin + { + public LocalGridPlugin() + { + + } + + public IGridServer GetGridServer() + { + return(new LocalGridServer()); + } + } + + public class LocalGridServer : LocalGridBase + { + public List Sessions = new List(); + + public LocalGridServer() + { + Sessions = new List(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Local Grid Server class created"); + } + + public override bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port) + { + return true; + } + + public override string GetName() + { + return "Local"; + } + + public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) + { + //we are running local + AuthenticateResponse user = new AuthenticateResponse(); + + lock(this.Sessions) + { + + for(int i = 0; i < Sessions.Count; i++) + { + if((Sessions[i].Agent == agentID) && (Sessions[i].Session == sessionID)) + { + user.Authorised = true; + user.LoginInfo = Sessions[i]; + } + } + } + return(user); + } + + public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) + { + return(true); + } + + public override UUIDBlock RequestUUIDBlock() + { + UUIDBlock uuidBlock = new UUIDBlock(); + return(uuidBlock); + } + + public override NeighbourInfo[] RequestNeighbours() + { + return null; + } + + public override void SetServerInfo(string ServerUrl, string SendKey, string RecvKey) + { + + } + + public override void Close() + { + + } + + /// + /// used by the local login server to inform us of new sessions + /// + /// + public override void AddNewSession(Login session) + { + lock(this.Sessions) + { + this.Sessions.Add(session); + } + } + } + + public class AssetUUIDQuery : Predicate + { + private LLUUID _findID; + + public AssetUUIDQuery(LLUUID find) + { + _findID = find; + } + public bool Match(AssetStorage asset) + { + return (asset.UUID == _findID); + } + } + + public class AssetStorage + { + public byte[] Data; + public sbyte Type; + public string Name; + public LLUUID UUID; + } +} diff --git a/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj b/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj new file mode 100644 index 0000000000..1aec5aa1e2 --- /dev/null +++ b/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj @@ -0,0 +1,110 @@ + + + Local + 8.0.50727 + 2.0 + {546099CD-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.GridInterfaces.Local + JScript + Grid + IE50 + false + Library + + OpenSim.GridInterfaces.Local + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + ..\..\bin\Db4objects.Db4o.dll + False + + + ..\..\bin\libsecondlife.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj.user b/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build b/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build new file mode 100644 index 0000000000..c7a19667e2 --- /dev/null +++ b/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.GridInterfaces/Remote/AssemblyInfo.cs b/OpenSim.GridInterfaces/Remote/AssemblyInfo.cs new file mode 100644 index 0000000000..0fa7d6ea66 --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("RemoteGridServers")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RemoteGridServers")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj b/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj new file mode 100644 index 0000000000..2b804565a6 --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj @@ -0,0 +1,106 @@ + + + Local + 8.0.50727 + 2.0 + {B55C0B5D-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.GridInterfaces.Remote + JScript + Grid + IE50 + false + Library + + OpenSim.GridInterfaces.Remote + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + ..\..\bin\libsecondlife.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj.user b/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build b/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build new file mode 100644 index 0000000000..4788f32198 --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs b/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs new file mode 100644 index 0000000000..528e9fa680 --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Net; +using System.Net.Sockets; +using System.IO; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Utilities; + +namespace OpenSim.GridInterfaces.Remote +{ + public class RemoteAssetServer : IAssetServer + { + private IAssetReceiver _receiver; + private BlockingQueue _assetRequests; + private Thread _remoteAssetServerThread; + private string AssetServerUrl; + private string AssetSendKey; + + public RemoteAssetServer() + { + this._assetRequests = new BlockingQueue(); + this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests)); + this._remoteAssetServerThread.IsBackground = true; + this._remoteAssetServerThread.Start(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Remote Asset Server class created"); + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void RequestAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + + } + + public void UploadNewAsset(AssetBase asset) + { + + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + this.AssetServerUrl = ServerUrl; + this.AssetSendKey = ServerKey; + } + + private void RunRequests() + { + while (true) + { + //we need to add support for the asset server not knowing about a requested asset + ARequest req = this._assetRequests.Dequeue(); + LLUUID assetID = req.AssetID; + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(" RemoteAssetServer- Got a AssetServer request, processing it"); + WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "getasset/" + AssetSendKey + "/" + assetID + "/data"); + WebResponse AssetResponse = AssetLoad.GetResponse(); + byte[] idata = new byte[(int)AssetResponse.ContentLength]; + BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream()); + idata = br.ReadBytes((int)AssetResponse.ContentLength); + br.Close(); + + AssetBase asset = new AssetBase(); + asset.FullID = assetID; + asset.Data = idata; + _receiver.AssetReceived(asset, req.IsTexture); + } + } + + public void Close() + { + + } + } + + public class RemoteAssetPlugin : IAssetPlugin + { + public RemoteAssetPlugin() + { + + } + + public IAssetServer GetAssetServer() + { + return (new RemoteAssetServer()); + } + } + +} diff --git a/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs b/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs new file mode 100644 index 0000000000..d51d212dc6 --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs @@ -0,0 +1,176 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Net; +using System.Net.Sockets; +using System.IO; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; + +namespace OpenSim.GridInterfaces.Remote +{ + public class RemoteGridServer : RemoteGridBase + { + private string GridServerUrl; + private string GridSendKey; + private string GridRecvKey; + private Dictionary AgentCircuits = new Dictionary(); + + public override Dictionary agentcircuits + { + get { return AgentCircuits; } + set { AgentCircuits = value; } + } + + public RemoteGridServer() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Remote Grid Server class created"); + } + + public override bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port) + { + Hashtable GridParams = new Hashtable(); + GridParams["authkey"]=GridSendKey; + GridParams["UUID"]=SimUUID.ToString(); + GridParams["sim_ip"]=sim_ip; + GridParams["sim_port"]=sim_port.ToString(); + ArrayList SendParams = new ArrayList(); + SendParams.Add(GridParams); + + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); + XmlRpcResponse GridResp = GridReq.Send(this.GridServerUrl, 3000); + Hashtable GridRespData = (Hashtable)GridResp.Value; + + if(GridRespData.ContainsKey("error")) { + string errorstring = (string)GridRespData["error"]; + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Error connecting to grid:"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(errorstring); + return false; + } + return true; + } + + public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode) + { + AgentCircuitData validcircuit = null; + if (this.AgentCircuits.ContainsKey(circuitcode)) + { + validcircuit = this.AgentCircuits[circuitcode]; + } + AuthenticateResponse user = new AuthenticateResponse(); + if (validcircuit == null) + { + //don't have this circuit code in our list + user.Authorised = false; + return (user); + } + + if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID)) + { + // YAY! Valid login + user.Authorised = true; + user.LoginInfo = new Login(); + user.LoginInfo.Agent = agentID; + user.LoginInfo.Session = sessionID; + user.LoginInfo.SecureSession = validcircuit.SecureSessionID; + user.LoginInfo.First = validcircuit.firstname; + user.LoginInfo.Last = validcircuit.lastname; + } + else + { + // Invalid + user.Authorised = false; + } + + return (user); + } + + public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) + { + WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + sessionID.ToString()); + DeleteSession.Method = "DELETE"; + DeleteSession.ContentType = "text/plaintext"; + DeleteSession.ContentLength = 0; + + StreamWriter stOut = new StreamWriter(DeleteSession.GetRequestStream(), System.Text.Encoding.ASCII); + stOut.Write(""); + stOut.Close(); + + StreamReader stIn = new StreamReader(DeleteSession.GetResponse().GetResponseStream()); + string GridResponse = stIn.ReadToEnd(); + stIn.Close(); + return (true); + } + + public override UUIDBlock RequestUUIDBlock() + { + UUIDBlock uuidBlock = new UUIDBlock(); + return (uuidBlock); + } + + public override NeighbourInfo[] RequestNeighbours() + { + return null; + } + + public override void SetServerInfo(string ServerUrl, string SendKey, string RecvKey) + { + this.GridServerUrl = ServerUrl; + this.GridSendKey = SendKey; + this.GridRecvKey = RecvKey; + } + + public override string GetName() + { + return "Remote"; + } + + public override void Close() + { + + } + } + + public class RemoteGridPlugin : IGridPlugin + { + public RemoteGridPlugin() + { + + } + + public IGridServer GetGridServer() + { + return (new RemoteGridServer()); + } + } + +} diff --git a/OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs new file mode 100644 index 0000000000..0c9c06c43d --- /dev/null +++ b/OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("PhysXplugin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PhysXplugin")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs new file mode 100644 index 0000000000..62b6ffc605 --- /dev/null +++ b/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -0,0 +1,256 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using OpenSim.Physics.Manager; + +namespace OpenSim.Physics.BasicPhysicsPlugin +{ + /// + /// Will be the PhysX plugin but for now will be a very basic physics engine + /// + public class BasicPhysicsPlugin : IPhysicsPlugin + { + private BasicScene _mScene; + + public BasicPhysicsPlugin() + { + + } + + public bool Init() + { + return true; + } + + public PhysicsScene GetScene() + { + if(_mScene == null) + { + _mScene = new BasicScene(); + } + return(_mScene); + } + + public string GetName() + { + return("basicphysics"); + } + + public void Dispose() + { + + } + } + + public class BasicScene :PhysicsScene + { + private List _actors = new List(); + private float[] _heightMap; + + public BasicScene() + { + + } + + public override PhysicsActor AddAvatar(PhysicsVector position) + { + BasicActor act = new BasicActor(); + act.Position = position; + _actors.Add(act); + return act; + } + + public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) + { + return null; + } + + public override void Simulate(float timeStep) + { + foreach (BasicActor actor in _actors) + { + actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep); + actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep); + actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep); + /*if(actor.Flying) + { + actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep); + } + else + { + actor.Position.Z = actor.Position.Z + ((-9.8f + actor.Velocity.Z) * timeStep); + } + if(actor.Position.Z < (_heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1)) + {*/ + actor.Position.Z = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1; + //} + if(actor.Position.X<0) + { + actor.Position.X = 0; + actor.Velocity.X = 0; + } + if(actor.Position.Y < 0) + { + actor.Position.Y = 0; + actor.Velocity.Y = 0; + } + if(actor.Position.X > 255) + { + actor.Position.X = 255; + actor.Velocity.X = 0; + } + if(actor.Position.Y > 255) + { + actor.Position.Y = 255; + actor.Velocity.X = 0; + } + } + } + + public override void GetResults() + { + + } + + public override bool IsThreaded + { + get + { + return(false); // for now we won't be multithreaded + } + } + + public override void SetTerrain(float[] heightMap) + { + this._heightMap = heightMap; + } + + public override void DeleteTerrain() + { + + } + } + + public class BasicActor : PhysicsActor + { + private PhysicsVector _position; + private PhysicsVector _velocity; + private PhysicsVector _acceleration; + private bool flying; + public BasicActor() + { + _velocity = new PhysicsVector(); + _position = new PhysicsVector(); + _acceleration = new PhysicsVector(); + } + + public override bool Flying + { + get + { + return false; + } + set + { + flying= value; + } + } + + public override PhysicsVector Position + { + get + { + return _position; + } + set + { + _position = value; + } + } + + public override PhysicsVector Velocity + { + get + { + return _velocity; + } + set + { + _velocity = value; + } + } + + public override Axiom.MathLib.Quaternion Orientation + { + get + { + return Axiom.MathLib.Quaternion.Identity; + } + set + { + + } + } + + public override PhysicsVector Acceleration + { + get + { + return _acceleration; + } + + } + + public override bool Kinematic + { + get + { + return true; + } + set + { + + } + } + public void SetAcceleration (PhysicsVector accel) + { + this._acceleration = accel; + } + + public override void AddForce(PhysicsVector force) + { + + } + + public override void SetMomentum(PhysicsVector momentum) + { + + } + } + +} diff --git a/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj new file mode 100644 index 0000000000..6d5b4d03d6 --- /dev/null +++ b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj @@ -0,0 +1,93 @@ + + + Local + 8.0.50727 + 2.0 + {4F874463-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Physics.BasicPhysicsPlugin + JScript + Grid + IE50 + false + Library + + OpenSim.Physics.BasicPhysicsPlugin + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\Physics\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\Physics\ + False + False + False + 4 + + + + + System.dll + False + + + ..\..\bin\Axiom.MathLib.dll + False + + + + + OpenSim.Physics.Manager + {8BE16150-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build new file mode 100644 index 0000000000..7b063a3634 --- /dev/null +++ b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Physics/Manager/AssemblyInfo.cs b/OpenSim.Physics/Manager/AssemblyInfo.cs new file mode 100644 index 0000000000..57a8913d33 --- /dev/null +++ b/OpenSim.Physics/Manager/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("PhysicsManager")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PhysicsManager")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj b/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj new file mode 100644 index 0000000000..294e005304 --- /dev/null +++ b/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj @@ -0,0 +1,112 @@ + + + Local + 8.0.50727 + 2.0 + {8BE16150-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Physics.Manager + JScript + Grid + IE50 + false + Library + + OpenSim.Physics.Manager + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + ..\..\bin\Axiom.MathLib.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj.user b/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build b/OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build new file mode 100644 index 0000000000..15544852b9 --- /dev/null +++ b/OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Physics/Manager/PhysicsActor.cs b/OpenSim.Physics/Manager/PhysicsActor.cs new file mode 100644 index 0000000000..a0b6c21b56 --- /dev/null +++ b/OpenSim.Physics/Manager/PhysicsActor.cs @@ -0,0 +1,161 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Physics.Manager +{ + public abstract class PhysicsActor + { + public static PhysicsActor Null + { + get + { + return new NullPhysicsActor(); + } + } + + public abstract PhysicsVector Position + { + get; + set; + } + + public abstract PhysicsVector Velocity + { + get; + set; + } + + public abstract PhysicsVector Acceleration + { + get; + } + + public abstract Axiom.MathLib.Quaternion Orientation + { + get; + set; + } + + public abstract bool Flying + { + get; + set; + } + + public abstract bool Kinematic + { + get; + set; + } + + public abstract void AddForce(PhysicsVector force); + + public abstract void SetMomentum(PhysicsVector momentum); + } + + public class NullPhysicsActor : PhysicsActor + { + public override PhysicsVector Position + { + get + { + return PhysicsVector.Zero; + } + set + { + return; + } + } + + public override PhysicsVector Velocity + { + get + { + return PhysicsVector.Zero; + } + set + { + return; + } + } + + public override Axiom.MathLib.Quaternion Orientation + { + get + { + return Axiom.MathLib.Quaternion.Identity; + } + set + { + + } + } + + public override PhysicsVector Acceleration + { + get { return PhysicsVector.Zero; } + } + + public override bool Flying + { + get + { + return false; + } + set + { + return; + } + } + + public override bool Kinematic + { + get + { + return true; + } + set + { + return; + } + } + + public override void AddForce(PhysicsVector force) + { + return; + } + + public override void SetMomentum(PhysicsVector momentum) + { + return; + } + } +} diff --git a/OpenSim.Physics/Manager/PhysicsManager.cs b/OpenSim.Physics/Manager/PhysicsManager.cs new file mode 100644 index 0000000000..616682b0da --- /dev/null +++ b/OpenSim.Physics/Manager/PhysicsManager.cs @@ -0,0 +1,116 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Collections; +using System.IO; +using System.Reflection; +using Axiom.MathLib; + +namespace OpenSim.Physics.Manager +{ + /// + /// Description of MyClass. + /// + public class PhysicsManager + { + private Dictionary _plugins=new Dictionary(); + + public PhysicsManager() + { + + } + + public PhysicsScene GetPhysicsScene(string engineName) + { + if (String.IsNullOrEmpty(engineName)) + { + return new NullPhysicsScene(); + } + + if(_plugins.ContainsKey(engineName)) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("creating "+engineName); + return _plugins[engineName].GetScene(); + } + else + { + string error = String.Format("couldn't find physicsEngine: {0}", engineName); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(error); + throw new ArgumentException(error); + } + } + + public void LoadPlugins() + { + string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics"); + string[] pluginFiles = Directory.GetFiles(path, "*.dll"); + + + for(int i= 0; i nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Physics.Manager +{ + public abstract class PhysicsScene + { + public static PhysicsScene Null + { + get + { + return new NullPhysicsScene(); + } + } + + public abstract PhysicsActor AddAvatar(PhysicsVector position); + + public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size); + + public abstract void Simulate(float timeStep); + + public abstract void GetResults(); + + public abstract void SetTerrain(float[] heightMap); + + public abstract void DeleteTerrain(); + + public abstract bool IsThreaded + { + get; + } + } + + public class NullPhysicsScene : PhysicsScene + { + private static int m_workIndicator; + + public override PhysicsActor AddAvatar(PhysicsVector position) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : AddAvatar({0})", position); + return PhysicsActor.Null; + } + + public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : AddPrim({0},{1})", position, size); + return PhysicsActor.Null; + } + + public override void Simulate(float timeStep) + { + m_workIndicator = (m_workIndicator + 1) % 10; + + //OpenSim.Framework.Console.MainConsole.Instance.SetStatus(m_workIndicator.ToString()); + } + + public override void GetResults() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : GetResults()"); + } + + public override void SetTerrain(float[] heightMap) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : SetTerrain({0} items)", heightMap.Length); + } + + public override void DeleteTerrain() + { + + } + + public override bool IsThreaded + { + get { return false; } + } + } +} diff --git a/OpenSim.Physics/Manager/PhysicsVector.cs b/OpenSim.Physics/Manager/PhysicsVector.cs new file mode 100644 index 0000000000..3c824d010d --- /dev/null +++ b/OpenSim.Physics/Manager/PhysicsVector.cs @@ -0,0 +1,54 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Physics.Manager +{ + public class PhysicsVector + { + public float X; + public float Y; + public float Z; + + public PhysicsVector() + { + + } + + public PhysicsVector(float x, float y, float z) + { + X = x; + Y = y; + Z = z; + } + + public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f); + } +} diff --git a/OpenSim.Physics/OdePlugin/AssemblyInfo.cs b/OpenSim.Physics/OdePlugin/AssemblyInfo.cs new file mode 100644 index 0000000000..913aae73c0 --- /dev/null +++ b/OpenSim.Physics/OdePlugin/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("RealPhysXplugin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RealPhysXplugin")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.Physics/OdePlugin/OdePlugin.cs b/OpenSim.Physics/OdePlugin/OdePlugin.cs new file mode 100644 index 0000000000..325e2fde85 --- /dev/null +++ b/OpenSim.Physics/OdePlugin/OdePlugin.cs @@ -0,0 +1,447 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using OpenSim.Physics.Manager; +using Ode.NET; + +namespace OpenSim.Physics.OdePlugin +{ + /// + /// ODE plugin + /// + public class OdePlugin : IPhysicsPlugin + { + private OdeScene _mScene; + + public OdePlugin() + { + + } + + public bool Init() + { + return true; + } + + public PhysicsScene GetScene() + { + if (_mScene == null) + { + _mScene = new OdeScene(); + } + return (_mScene); + } + + public string GetName() + { + return ("OpenDynamicsEngine"); + } + + public void Dispose() + { + + } + } + + public class OdeScene : PhysicsScene + { + static public IntPtr world; + static public IntPtr space; + static private IntPtr contactgroup; + static private IntPtr LandGeom; + static private IntPtr Land; + private double[] _heightmap; + static private d.NearCallback nearCallback = near; + private List _characters = new List(); + private static d.ContactGeom[] contacts = new d.ContactGeom[30]; + private static d.Contact contact; + + public OdeScene() + { + contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM; + contact.surface.mu = d.Infinity; + contact.surface.mu2 = 0.0f; + contact.surface.bounce = 0.1f; + contact.surface.bounce_vel = 0.1f; + contact.surface.soft_cfm = 0.01f; + + world = d.WorldCreate(); + space = d.HashSpaceCreate(IntPtr.Zero); + contactgroup = d.JointGroupCreate(0); + d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f); + //d.WorldSetCFM(world, 1e-5f); + d.WorldSetAutoDisableFlag(world, false); + d.WorldSetContactSurfaceLayer(world, 0.001f); + // d.CreatePlane(space, 0, 0, 1, 0); + this._heightmap = new double[65536]; + } + + // This function blatantly ripped off from BoxStack.cs + static private void near(IntPtr space, IntPtr g1, IntPtr g2) + { + //Console.WriteLine("collision callback"); + IntPtr b1 = d.GeomGetBody(g1); + IntPtr b2 = d.GeomGetBody(g2); + if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) + return; + + int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf); + for (int i = 0; i < count; ++i) + { + contact.geom = contacts[i]; + IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact); + d.JointAttach(joint, b1, b2); + } + + } + + public override PhysicsActor AddAvatar(PhysicsVector position) + { + PhysicsVector pos = new PhysicsVector(); + pos.X = position.X; + pos.Y = position.Y; + pos.Z = position.Z + 20; + OdeCharacter newAv = new OdeCharacter(this, pos); + this._characters.Add(newAv); + return newAv; + } + + public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) + { + PhysicsVector pos = new PhysicsVector(); + pos.X = position.X; + pos.Y = position.Y; + pos.Z = position.Z; + PhysicsVector siz = new PhysicsVector(); + siz.X = size.X; + siz.Y = size.Y; + siz.Z = size.Z; + return new OdePrim(); + } + + public override void Simulate(float timeStep) + { + foreach (OdeCharacter actor in _characters) + { + actor.Move(timeStep * 5f); + } + d.SpaceCollide(space, IntPtr.Zero, nearCallback); + d.WorldQuickStep(world, timeStep * 5f); + d.JointGroupEmpty(contactgroup); + foreach (OdeCharacter actor in _characters) + { + actor.UpdatePosition(); + } + + } + + public override void GetResults() + { + + } + + public override bool IsThreaded + { + get + { + return (false); // for now we won't be multithreaded + } + } + + public override void SetTerrain(float[] heightMap) + { + for (int i = 0; i < 65536; i++) + { + this._heightmap[i] = (double)heightMap[i]; + } + IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); + d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0); + d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256); + LandGeom = d.CreateHeightfield(space, HeightmapData, 1); + d.Matrix3 R = new d.Matrix3(); + + Axiom.MathLib.Quaternion q1 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(1,0,0)); + Axiom.MathLib.Quaternion q2 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(0,1,0)); + //Axiom.MathLib.Quaternion q3 = Axiom.MathLib.Quaternion.FromAngleAxis(3.14f, new Axiom.MathLib.Vector3(0, 0, 1)); + + q1 = q1 * q2; + //q1 = q1 * q3; + Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(); + float angle = 0; + q1.ToAngleAxis(ref angle, ref v3); + + d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle); + d.GeomSetRotation(LandGeom, ref R); + d.GeomSetPosition(LandGeom, 128, 128, 0); + } + + public override void DeleteTerrain() + { + + } + } + + public class OdeCharacter : PhysicsActor + { + private PhysicsVector _position; + private PhysicsVector _velocity; + private PhysicsVector _acceleration; + private bool flying; + private float gravityAccel; + private IntPtr BoundingCapsule; + IntPtr capsule_geom; + d.Mass capsule_mass; + + public OdeCharacter(OdeScene parent_scene, PhysicsVector pos) + { + _velocity = new PhysicsVector(); + _position = pos; + _acceleration = new PhysicsVector(); + d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f); + capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f); + this.BoundingCapsule = d.BodyCreate(OdeScene.world); + d.BodySetMass(BoundingCapsule, ref capsule_mass); + d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); + d.GeomSetBody(capsule_geom, BoundingCapsule); + } + + public override bool Flying + { + get + { + return flying; + } + set + { + flying = value; + } + } + + public override PhysicsVector Position + { + get + { + return _position; + } + set + { + _position = value; + } + } + + public override PhysicsVector Velocity + { + get + { + return _velocity; + } + set + { + _velocity = value; + } + } + + public override bool Kinematic + { + get + { + return false; + } + set + { + + } + } + + public override Axiom.MathLib.Quaternion Orientation + { + get + { + return Axiom.MathLib.Quaternion.Identity; + } + set + { + + } + } + + public override PhysicsVector Acceleration + { + get + { + return _acceleration; + } + + } + public void SetAcceleration(PhysicsVector accel) + { + this._acceleration = accel; + } + + public override void AddForce(PhysicsVector force) + { + + } + + public override void SetMomentum(PhysicsVector momentum) + { + + } + + public void Move(float timeStep) + { + PhysicsVector vec = new PhysicsVector(); + vec.X = this._velocity.X * timeStep; + vec.Y = this._velocity.Y * timeStep; + if (flying) + { + vec.Z = (this._velocity.Z + 0.5f) * timeStep; + } + d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z); + } + + public void UpdatePosition() + { + d.Vector3 vec = d.BodyGetPosition(BoundingCapsule); + this._position.X = vec.X; + this._position.Y = vec.Y; + this._position.Z = vec.Z; + } + } + + public class OdePrim : PhysicsActor + { + private PhysicsVector _position; + private PhysicsVector _velocity; + private PhysicsVector _acceleration; + + public OdePrim() + { + _velocity = new PhysicsVector(); + _position = new PhysicsVector(); + _acceleration = new PhysicsVector(); + } + public override bool Flying + { + get + { + return false; //no flying prims for you + } + set + { + + } + } + public override PhysicsVector Position + { + get + { + PhysicsVector pos = new PhysicsVector(); + // PhysicsVector vec = this._prim.Position; + //pos.X = vec.X; + //pos.Y = vec.Y; + //pos.Z = vec.Z; + return pos; + + } + set + { + /*PhysicsVector vec = value; + PhysicsVector pos = new PhysicsVector(); + pos.X = vec.X; + pos.Y = vec.Y; + pos.Z = vec.Z; + this._prim.Position = pos;*/ + } + } + + public override PhysicsVector Velocity + { + get + { + return _velocity; + } + set + { + _velocity = value; + } + } + + public override bool Kinematic + { + get + { + return false; + //return this._prim.Kinematic; + } + set + { + //this._prim.Kinematic = value; + } + } + + public override Axiom.MathLib.Quaternion Orientation + { + get + { + Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion(); + return res; + } + set + { + + } + } + + public override PhysicsVector Acceleration + { + get + { + return _acceleration; + } + + } + public void SetAcceleration(PhysicsVector accel) + { + this._acceleration = accel; + } + + public override void AddForce(PhysicsVector force) + { + + } + + public override void SetMomentum(PhysicsVector momentum) + { + + } + + + } + +} diff --git a/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj b/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj new file mode 100644 index 0000000000..68f1aa1c4f --- /dev/null +++ b/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj @@ -0,0 +1,97 @@ + + + Local + 8.0.50727 + 2.0 + {63A05FE9-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Physics.OdePlugin + JScript + Grid + IE50 + false + Library + + OpenSim.Physics.OdePlugin + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\Physics\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\Physics\ + False + False + False + 4 + + + + + System.dll + False + + + ..\..\bin\Axiom.MathLib.dll + False + + + ..\..\bin\Ode.NET.dll + False + + + + + OpenSim.Physics.Manager + {8BE16150-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj.user b/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.dll.build b/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.dll.build new file mode 100644 index 0000000000..098472aac4 --- /dev/null +++ b/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.dll.build @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim.Physics/PhysXPlugin/AssemblyInfo.cs new file mode 100644 index 0000000000..913aae73c0 --- /dev/null +++ b/OpenSim.Physics/PhysXPlugin/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("RealPhysXplugin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RealPhysXplugin")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj b/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj new file mode 100644 index 0000000000..efe9c79c3b --- /dev/null +++ b/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj @@ -0,0 +1,97 @@ + + + Local + 8.0.50727 + 2.0 + {988F0AC4-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Physics.PhysXPlugin + JScript + Grid + IE50 + false + Library + + OpenSim.Physics.PhysXPlugin + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\Physics\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\Physics\ + False + False + False + 4 + + + + + System.dll + False + + + ..\..\bin\Axiom.MathLib.dll + False + + + ..\..\bin\PhysX_Wrapper_Dotnet.dll + False + + + + + OpenSim.Physics.Manager + {8BE16150-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj.user b/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build b/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build new file mode 100644 index 0000000000..3ae7013826 --- /dev/null +++ b/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs new file mode 100644 index 0000000000..10e92fe6ed --- /dev/null +++ b/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs @@ -0,0 +1,444 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using OpenSim.Physics.Manager; +using PhysXWrapper; + +namespace OpenSim.Physics.PhysXPlugin +{ + /// + /// Will be the PhysX plugin but for now will be a very basic physics engine + /// + public class PhysXPlugin : IPhysicsPlugin + { + private PhysXScene _mScene; + + public PhysXPlugin() + { + + } + + public bool Init() + { + return true; + } + + public PhysicsScene GetScene() + { + if(_mScene == null) + { + _mScene = new PhysXScene(); + } + return(_mScene); + } + + public string GetName() + { + return("RealPhysX"); + } + + public void Dispose() + { + + } + } + + public class PhysXScene :PhysicsScene + { + private List _characters = new List(); + private List _prims = new List(); + private float[] _heightMap = null; + private NxPhysicsSDK mySdk; + private NxScene scene; + + public PhysXScene() + { + mySdk = NxPhysicsSDK.CreateSDK(); + Console.WriteLine("Sdk created - now creating scene"); + scene = mySdk.CreateScene(); + + } + + public override PhysicsActor AddAvatar(PhysicsVector position) + { + Vec3 pos = new Vec3(); + pos.X = position.X; + pos.Y = position.Y; + pos.Z = position.Z; + PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos)); + act.Position = position; + _characters.Add(act); + return act; + } + + public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) + { + Vec3 pos = new Vec3(); + pos.X = position.X; + pos.Y = position.Y; + pos.Z = position.Z; + Vec3 siz = new Vec3(); + siz.X = size.X; + siz.Y = size.Y; + siz.Z = size.Z; + PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz)); + _prims.Add(act); + return act; + } + public override void Simulate(float timeStep) + { + try + { + foreach (PhysXCharacter actor in _characters) + { + actor.Move(timeStep); + } + scene.Simulate(timeStep); + scene.FetchResults(); + scene.UpdateControllers(); + + foreach (PhysXCharacter actor in _characters) + { + actor.UpdatePosition(); + } + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + + } + + public override void GetResults() + { + + } + + public override bool IsThreaded + { + get + { + return(false); // for now we won't be multithreaded + } + } + + public override void SetTerrain(float[] heightMap) + { + if (this._heightMap != null) + { + Console.WriteLine("PhysX - deleting old terrain"); + this.scene.DeleteTerrain(); + } + this._heightMap = heightMap; + this.scene.AddTerrain(heightMap); + } + + public override void DeleteTerrain() + { + this.scene.DeleteTerrain(); + } + } + + public class PhysXCharacter : PhysicsActor + { + private PhysicsVector _position; + private PhysicsVector _velocity; + private PhysicsVector _acceleration; + private NxCharacter _character; + private bool flying; + private float gravityAccel; + + public PhysXCharacter(NxCharacter character) + { + _velocity = new PhysicsVector(); + _position = new PhysicsVector(); + _acceleration = new PhysicsVector(); + _character = character; + } + + public override bool Flying + { + get + { + return flying; + } + set + { + flying = value; + } + } + + public override PhysicsVector Position + { + get + { + return _position; + } + set + { + _position = value; + Vec3 ps = new Vec3(); + ps.X = value.X; + ps.Y = value.Y; + ps.Z = value.Z; + this._character.Position = ps; + } + } + + public override PhysicsVector Velocity + { + get + { + return _velocity; + } + set + { + _velocity = value; + } + } + + public override bool Kinematic + { + get + { + return false; + } + set + { + + } + } + + public override Axiom.MathLib.Quaternion Orientation + { + get + { + return Axiom.MathLib.Quaternion.Identity; + } + set + { + + } + } + + public override PhysicsVector Acceleration + { + get + { + return _acceleration; + } + + } + public void SetAcceleration (PhysicsVector accel) + { + this._acceleration = accel; + } + + public override void AddForce(PhysicsVector force) + { + + } + + public override void SetMomentum(PhysicsVector momentum) + { + + } + + public void Move(float timeStep) + { + Vec3 vec = new Vec3(); + vec.X = this._velocity.X * timeStep; + vec.Y = this._velocity.Y * timeStep; + if(flying) + { + vec.Z = ( this._velocity.Z) * timeStep; + } + else + { + gravityAccel+= -9.8f; + vec.Z = (gravityAccel + this._velocity.Z) * timeStep; + } + int res = this._character.Move(vec); + if(res == 1) + { + gravityAccel = 0; + } + } + + public void UpdatePosition() + { + Vec3 vec = this._character.Position; + this._position.X = vec.X; + this._position.Y = vec.Y; + this._position.Z = vec.Z; + } + } + + public class PhysXPrim : PhysicsActor + { + private PhysicsVector _position; + private PhysicsVector _velocity; + private PhysicsVector _acceleration; + private NxActor _prim; + + public PhysXPrim(NxActor prim) + { + _velocity = new PhysicsVector(); + _position = new PhysicsVector(); + _acceleration = new PhysicsVector(); + _prim = prim; + } + public override bool Flying + { + get + { + return false; //no flying prims for you + } + set + { + + } + } + public override PhysicsVector Position + { + get + { + PhysicsVector pos = new PhysicsVector(); + Vec3 vec = this._prim.Position; + pos.X = vec.X; + pos.Y = vec.Y; + pos.Z = vec.Z; + return pos; + + } + set + { + PhysicsVector vec = value; + Vec3 pos = new Vec3(); + pos.X = vec.X; + pos.Y = vec.Y; + pos.Z = vec.Z; + this._prim.Position = pos; + } + } + + public override PhysicsVector Velocity + { + get + { + return _velocity; + } + set + { + _velocity = value; + } + } + + public override bool Kinematic + { + get + { + return this._prim.Kinematic; + } + set + { + this._prim.Kinematic = value; + } + } + + public override Axiom.MathLib.Quaternion Orientation + { + get + { + Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion(); + PhysXWrapper.Quaternion quat = this._prim.GetOrientation(); + res.w = quat.W; + res.x = quat.X; + res.y = quat.Y; + res.z = quat.Z; + return res; + } + set + { + + } + } + + public override PhysicsVector Acceleration + { + get + { + return _acceleration; + } + + } + public void SetAcceleration (PhysicsVector accel) + { + this._acceleration = accel; + } + + public override void AddForce(PhysicsVector force) + { + + } + + public override void SetMomentum(PhysicsVector momentum) + { + + } + + + } + +} diff --git a/OpenSim.RegionServer/AgentAssetUpload.cs b/OpenSim.RegionServer/AgentAssetUpload.cs new file mode 100644 index 0000000000..998a9db7d9 --- /dev/null +++ b/OpenSim.RegionServer/AgentAssetUpload.cs @@ -0,0 +1,232 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Assets; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Utilities; +using libsecondlife; +using libsecondlife.Packets; + +namespace OpenSim +{ + public class AgentAssetUpload + { + private Dictionary transactions = new Dictionary(); + private SimClient ourClient; + private AssetCache m_assetCache; + private InventoryCache m_inventoryCache; + + public AgentAssetUpload(SimClient client, AssetCache assetCache, InventoryCache inventoryCache) + { + this.ourClient = client; + m_assetCache = assetCache; + m_inventoryCache = inventoryCache; + } + + public void AddUpload(LLUUID transactionID, AssetBase asset) + { + AssetTransaction upload = new AssetTransaction(); + lock (this.transactions) + { + upload.Asset = asset; + upload.TransactionID = transactionID; + this.transactions.Add(transactionID, upload); + } + if (upload.Asset.Data.Length > 2) + { + //is complete + upload.UploadComplete = true; + AssetUploadCompletePacket response = new AssetUploadCompletePacket(); + response.AssetBlock.Type = asset.Type; + response.AssetBlock.Success = true; + response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID); + this.ourClient.OutPacket(response); + m_assetCache.AddAsset(asset); + } + else + { + upload.UploadComplete = false; + upload.XferID = Util.GetNextXferID(); + RequestXferPacket xfer = new RequestXferPacket(); + xfer.XferID.ID = upload.XferID; + xfer.XferID.VFileType = upload.Asset.Type; + xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID); + xfer.XferID.FilePath = 0; + xfer.XferID.Filename = new byte[0]; + this.ourClient.OutPacket(xfer); + } + + } + + public AssetBase GetUpload(LLUUID transactionID) + { + if (this.transactions.ContainsKey(transactionID)) + { + return this.transactions[transactionID].Asset; + } + + return null; + } + + public void HandleUploadPacket(AssetUploadRequestPacket pack, LLUUID assetID) + { + Console.Write("asset upload request , type = " + pack.AssetBlock.Type.ToString()); + AssetBase asset = null; + if (pack.AssetBlock.Type == 0) + { + + //first packet for transaction + asset = new AssetBase(); + asset.FullID = assetID; + asset.Type = pack.AssetBlock.Type; + asset.InvType = asset.Type; + asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); + asset.Data = pack.AssetBlock.AssetData; + + + } + else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5 | pack.AssetBlock.Type == 7) + { + + asset = new AssetBase(); + asset.FullID = assetID; + // Console.WriteLine("skin asset id is " + assetID.ToStringHyphenated()); + asset.Type = pack.AssetBlock.Type; + asset.InvType = asset.Type; + asset.Name = "NewClothing" + Util.RandomClass.Next(1, 1000).ToString("000"); + asset.Data = pack.AssetBlock.AssetData; + + + } + + if (asset != null) + { + this.AddUpload(pack.AssetBlock.TransactionID, asset); + } + else + { + + //currently we don't support this asset type + //so lets just tell the client that the upload is complete + AssetUploadCompletePacket response = new AssetUploadCompletePacket(); + response.AssetBlock.Type = pack.AssetBlock.Type; + response.AssetBlock.Success = true; + response.AssetBlock.UUID = pack.AssetBlock.TransactionID.Combine(this.ourClient.SecureSessionID); + this.ourClient.OutPacket(response); + } + + } + + #region Xfer packet system for larger uploads + + public void HandleXferPacket(SendXferPacketPacket xferPacket) + { + lock (this.transactions) + { + foreach (AssetTransaction trans in this.transactions.Values) + { + if (trans.XferID == xferPacket.XferID.ID) + { + if (trans.Asset.Data.Length > 1) + { + byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length]; + Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length); + Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length); + trans.Asset.Data = newArray; + } + else + { + byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4]; + Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4); + trans.Asset.Data = newArray; + } + + if ((xferPacket.XferID.Packet & 2147483648) != 0) + { + //end of transfer + trans.UploadComplete = true; + AssetUploadCompletePacket response = new AssetUploadCompletePacket(); + response.AssetBlock.Type = trans.Asset.Type; + response.AssetBlock.Success = true; + response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID); + this.ourClient.OutPacket(response); + + m_assetCache.AddAsset(trans.Asset); + //check if we should add it to inventory + if (trans.AddToInventory) + { + // m_assetCache.AddAsset(trans.Asset); + m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset); + } + + + } + break; + } + + } + } + + ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); + confirmXfer.XferID.ID = xferPacket.XferID.ID; + confirmXfer.XferID.Packet = xferPacket.XferID.Packet; + this.ourClient.OutPacket(confirmXfer); + } + + #endregion + + public AssetBase AddUploadToAssetCache(LLUUID transactionID) + { + AssetBase asset = null; + if (this.transactions.ContainsKey(transactionID)) + { + AssetTransaction trans = this.transactions[transactionID]; + if (trans.UploadComplete) + { + m_assetCache.AddAsset(trans.Asset); + asset = trans.Asset; + } + } + + return asset; + } + + public void CreateInventoryItem(CreateInventoryItemPacket packet) + { + if (this.transactions.ContainsKey(packet.InventoryBlock.TransactionID)) + { + AssetTransaction trans = this.transactions[packet.InventoryBlock.TransactionID]; + trans.Asset.Description = Helpers.FieldToString(packet.InventoryBlock.Description); + trans.Asset.Name = Helpers.FieldToString(packet.InventoryBlock.Name); + trans.Asset.Type = packet.InventoryBlock.Type; + trans.Asset.InvType = packet.InventoryBlock.InvType; + if (trans.UploadComplete) + { + //already complete so we can add it to the inventory + //m_assetCache.AddAsset(trans.Asset); + m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset); + } + else + { + trans.AddToInventory = true; + trans.InventFolder = packet.InventoryBlock.FolderID; + } + } + } + + private class AssetTransaction + { + public uint XferID; + public AssetBase Asset; + public bool AddToInventory; + public LLUUID InventFolder = LLUUID.Zero; + public bool UploadComplete = false; + public LLUUID TransactionID = LLUUID.Zero; + + public AssetTransaction() + { + + } + } + } +} diff --git a/OpenSim.RegionServer/Assets/AssetCache.cs b/OpenSim.RegionServer/Assets/AssetCache.cs new file mode 100644 index 0000000000..573e5fdbc0 --- /dev/null +++ b/OpenSim.RegionServer/Assets/AssetCache.cs @@ -0,0 +1,574 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using System.Threading; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Assets +{ + /// + /// Manages local cache of assets and their sending to viewers. + /// + public class AssetCache : IAssetReceiver + { + public Dictionary Assets; + public Dictionary Textures; + + public List AssetRequests = new List(); //assets ready to be sent to viewers + public List TextureRequests = new List(); //textures ready to be sent + + public Dictionary RequestedAssets = new Dictionary(); //Assets requested from the asset server + public Dictionary RequestedTextures = new Dictionary(); //Textures requested from the asset server + + private IAssetServer _assetServer; + private Thread _assetCacheThread; + private LLUUID[] textureList = new LLUUID[5]; + + /// + /// + /// + public AssetCache(IAssetServer assetServer) + { + Console.WriteLine("Creating Asset cache"); + _assetServer = assetServer; + _assetServer.SetReceiver(this); + Assets = new Dictionary(); + Textures = new Dictionary(); + this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); + this._assetCacheThread.IsBackground = true; + this._assetCacheThread.Start(); + + } + + /// + /// + /// + public void RunAssetManager() + { + while (true) + { + try + { + //Console.WriteLine("Asset cache loop"); + this.ProcessAssetQueue(); + this.ProcessTextureQueue(); + Thread.Sleep(500); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + } + + public void LoadDefaultTextureSet() + { + //hack: so we can give each user a set of textures + textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001"); + textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002"); + textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003"); + textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004"); + textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005"); + + for (int i = 0; i < textureList.Length; i++) + { + this._assetServer.RequestAsset(textureList[i], true); + } + + } + + public AssetBase[] CreateNewInventorySet(LLUUID agentID) + { + AssetBase[] inventorySet = new AssetBase[this.textureList.Length]; + for (int i = 0; i < textureList.Length; i++) + { + if (this.Textures.ContainsKey(textureList[i])) + { + inventorySet[i] = this.CloneImage(agentID, this.Textures[textureList[i]]); + TextureImage image = new TextureImage(inventorySet[i]); + this.Textures.Add(image.FullID, image); + this._assetServer.UploadNewAsset(image); //save the asset to the asset server + } + } + return inventorySet; + } + + public AssetBase GetAsset(LLUUID assetID) + { + AssetBase asset = null; + if(this.Textures.ContainsKey(assetID)) + { + asset = this.Textures[assetID]; + } + else if (this.Assets.ContainsKey(assetID)) + { + asset = this.Assets[assetID]; + } + return asset; + } + + public void AddAsset(AssetBase asset) + { + if (asset.Type == 0) + { + if (!this.Textures.ContainsKey(asset.FullID)) + { //texture + TextureImage textur = new TextureImage(asset); + this.Textures.Add(textur.FullID, textur); + this._assetServer.UploadNewAsset(asset); + } + } + else + { + if (!this.Assets.ContainsKey(asset.FullID)) + { + AssetInfo assetInf = new AssetInfo(asset); + this.Assets.Add(assetInf.FullID, assetInf); + this._assetServer.UploadNewAsset(asset); + } + } + } + + /// + /// + /// + private void ProcessTextureQueue() + { + if (this.TextureRequests.Count == 0) + { + //no requests waiting + return; + } + int num; + + if (this.TextureRequests.Count < 5) + { + //lower than 5 so do all of them + num = this.TextureRequests.Count; + } + else + { + num = 5; + } + AssetRequest req; + for (int i = 0; i < num; i++) + { + req = (AssetRequest)this.TextureRequests[i]; + if (req.PacketCounter != req.NumPackets) + { + // if (req.ImageInfo.FullID == new LLUUID("00000000-0000-0000-5005-000000000005")) + if (req.PacketCounter == 0) + { + //first time for this request so send imagedata packet + if (req.NumPackets == 1) + { + //only one packet so send whole file + ImageDataPacket im = new ImageDataPacket(); + im.ImageID.Packets = 1; + im.ImageID.ID = req.ImageInfo.FullID; + im.ImageID.Size = (uint)req.ImageInfo.Data.Length; + im.ImageData.Data = req.ImageInfo.Data; + im.ImageID.Codec = 2; + req.RequestUser.OutPacket(im); + req.PacketCounter++; + //req.ImageInfo.l= time; + //System.Console.WriteLine("sent texture: "+req.image_info.FullID); + } + else + { + //more than one packet so split file up + ImageDataPacket im = new ImageDataPacket(); + im.ImageID.Packets = (ushort)req.NumPackets; + im.ImageID.ID = req.ImageInfo.FullID; + im.ImageID.Size = (uint)req.ImageInfo.Data.Length; + im.ImageData.Data = new byte[600]; + Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600); + im.ImageID.Codec = 2; + req.RequestUser.OutPacket(im); + req.PacketCounter++; + //req.ImageInfo.last_used = time; + //System.Console.WriteLine("sent first packet of texture: + } + } + else + { + //send imagepacket + //more than one packet so split file up + ImagePacketPacket im = new ImagePacketPacket(); + im.ImageID.Packet = (ushort)req.PacketCounter; + im.ImageID.ID = req.ImageInfo.FullID; + int size = req.ImageInfo.Data.Length - 600 - 1000 * (req.PacketCounter - 1); + if (size > 1000) size = 1000; + im.ImageData.Data = new byte[size]; + Array.Copy(req.ImageInfo.Data, 600 + 1000 * (req.PacketCounter - 1), im.ImageData.Data, 0, size); + req.RequestUser.OutPacket(im); + req.PacketCounter++; + //req.ImageInfo.last_used = time; + //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); + } + } + } + + //remove requests that have been completed + int count = 0; + for (int i = 0; i < num; i++) + { + if (this.TextureRequests.Count > count) + { + req = (AssetRequest)this.TextureRequests[count]; + if (req.PacketCounter == req.NumPackets) + { + this.TextureRequests.Remove(req); + } + else + { + count++; + } + } + } + + } + public void AssetReceived(AssetBase asset, bool IsTexture) + { + if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server + { + //check if it is a texture or not + //then add to the correct cache list + //then check for waiting requests for this asset/texture (in the Requested lists) + //and move those requests into the Requests list. + if (IsTexture) + { + TextureImage image = new TextureImage(asset); + this.Textures.Add(image.FullID, image); + if (this.RequestedTextures.ContainsKey(image.FullID)) + { + AssetRequest req = this.RequestedTextures[image.FullID]; + req.ImageInfo = image; + if (image.Data.LongLength > 600) + { + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(image.Data.Length - 600 + 999) / 1000; + } + else + { + req.NumPackets = 1; + } + this.RequestedTextures.Remove(image.FullID); + this.TextureRequests.Add(req); + } + } + else + { + AssetInfo assetInf = new AssetInfo(asset); + this.Assets.Add(assetInf.FullID, assetInf); + if (this.RequestedAssets.ContainsKey(assetInf.FullID)) + { + AssetRequest req = this.RequestedAssets[assetInf.FullID]; + req.AssetInf = assetInf; + if (assetInf.Data.LongLength > 600) + { + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000; + } + else + { + req.NumPackets = 1; + } + this.RequestedAssets.Remove(assetInf.FullID); + this.AssetRequests.Add(req); + } + } + } + } + + public void AssetNotFound(AssetBase asset) + { + //the asset server had no knowledge of requested asset + + } + + #region Assets + /// + /// + /// + /// + /// + public void AddAssetRequest(SimClient userInfo, TransferRequestPacket transferRequest) + { + LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); + //check to see if asset is in local cache, if not we need to request it from asset server. + if (!this.Assets.ContainsKey(requestID)) + { + //not found asset + // so request from asset server + if (!this.RequestedAssets.ContainsKey(requestID)) + { + AssetRequest request = new AssetRequest(); + request.RequestUser = userInfo; + request.RequestAssetID = requestID; + request.TransferRequestID = transferRequest.TransferInfo.TransferID; + this.RequestedAssets.Add(requestID, request); + this._assetServer.RequestAsset(requestID, false); + } + return; + } + //it is in our cache + AssetInfo asset = this.Assets[requestID]; + + //work out how many packets it should be sent in + // and add to the AssetRequests list + AssetRequest req = new AssetRequest(); + req.RequestUser = userInfo; + req.RequestAssetID = requestID; + req.TransferRequestID = transferRequest.TransferInfo.TransferID; + req.AssetInf = asset; + + if (asset.Data.LongLength > 600) + { + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000; + } + else + { + req.NumPackets = 1; + } + + this.AssetRequests.Add(req); + } + + /// + /// + /// + private void ProcessAssetQueue() + { + if (this.AssetRequests.Count == 0) + { + //no requests waiting + return; + } + int num; + + if (this.AssetRequests.Count < 5) + { + //lower than 5 so do all of them + num = this.AssetRequests.Count; + } + else + { + num = 5; + } + AssetRequest req; + for (int i = 0; i < num; i++) + { + req = (AssetRequest)this.AssetRequests[i]; + + TransferInfoPacket Transfer = new TransferInfoPacket(); + Transfer.TransferInfo.ChannelType = 2; + Transfer.TransferInfo.Status = 0; + Transfer.TransferInfo.TargetType = 0; + Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes(); + Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; + Transfer.TransferInfo.TransferID = req.TransferRequestID; + req.RequestUser.OutPacket(Transfer); + + if (req.NumPackets == 1) + { + TransferPacketPacket TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = 0; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = req.TransferRequestID; + TransferPacket.TransferData.Data = req.AssetInf.Data; + TransferPacket.TransferData.Status = 1; + req.RequestUser.OutPacket(TransferPacket); + } + else + { + //more than one packet so split file up , for now it can't be bigger than 2000 bytes + TransferPacketPacket TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = 0; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = req.TransferRequestID; + byte[] chunk = new byte[1000]; + Array.Copy(req.AssetInf.Data, chunk, 1000); + TransferPacket.TransferData.Data = chunk; + TransferPacket.TransferData.Status = 0; + req.RequestUser.OutPacket(TransferPacket); + + TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = 1; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = req.TransferRequestID; + byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)]; + Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length); + TransferPacket.TransferData.Data = chunk1; + TransferPacket.TransferData.Status = 1; + req.RequestUser.OutPacket(TransferPacket); + } + + } + + //remove requests that have been completed + for (int i = 0; i < num; i++) + { + this.AssetRequests.RemoveAt(0); + } + + } + + public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset) + { + AssetInfo newAsset = new AssetInfo(); + newAsset.Data = new byte[sourceAsset.Data.Length]; + Array.Copy(sourceAsset.Data, newAsset.Data, sourceAsset.Data.Length); + newAsset.FullID = LLUUID.Random(); + newAsset.Type = sourceAsset.Type; + newAsset.InvType = sourceAsset.InvType; + return (newAsset); + } + #endregion + + #region Textures + /// + /// + /// + /// + /// + public void AddTextureRequest(SimClient userInfo, LLUUID imageID) + { + //check to see if texture is in local cache, if not request from asset server + if (!this.Textures.ContainsKey(imageID)) + { + if (!this.RequestedTextures.ContainsKey(imageID)) + { + //not is cache so request from asset server + AssetRequest request = new AssetRequest(); + request.RequestUser = userInfo; + request.RequestAssetID = imageID; + request.IsTextureRequest = true; + this.RequestedTextures.Add(imageID, request); + this._assetServer.RequestAsset(imageID, true); + } + return; + } + + TextureImage imag = this.Textures[imageID]; + AssetRequest req = new AssetRequest(); + req.RequestUser = userInfo; + req.RequestAssetID = imageID; + req.IsTextureRequest = true; + req.ImageInfo = imag; + + if (imag.Data.LongLength > 600) + { + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(imag.Data.Length - 600 + 999) / 1000; + } + else + { + req.NumPackets = 1; + } + this.TextureRequests.Add(req); + } + + public TextureImage CloneImage(LLUUID newOwner, TextureImage source) + { + TextureImage newImage = new TextureImage(); + newImage.Data = new byte[source.Data.Length]; + Array.Copy(source.Data, newImage.Data, source.Data.Length); + //newImage.filename = source.filename; + newImage.FullID = LLUUID.Random(); + newImage.Name = source.Name; + return (newImage); + } + #endregion + + } + + public class AssetRequest + { + public SimClient RequestUser; + public LLUUID RequestAssetID; + public AssetInfo AssetInf; + public TextureImage ImageInfo; + public LLUUID TransferRequestID; + public long DataPointer = 0; + public int NumPackets = 0; + public int PacketCounter = 0; + public bool IsTextureRequest; + //public bool AssetInCache; + //public int TimeRequested; + + public AssetRequest() + { + + } + } + + public class AssetInfo : AssetBase + { + public AssetInfo() + { + + } + + public AssetInfo(AssetBase aBase) + { + Data = aBase.Data; + FullID = aBase.FullID; + Type = aBase.Type; + InvType = aBase.InvType; + Name = aBase.Name; + Description = aBase.Description; + } + } + + public class TextureImage : AssetBase + { + public TextureImage() + { + + } + + public TextureImage(AssetBase aBase) + { + Data = aBase.Data; + FullID = aBase.FullID; + Type = aBase.Type; + InvType = aBase.InvType; + Name = aBase.Name; + Description = aBase.Description; + } + } + +} diff --git a/OpenSim.RegionServer/Assets/InventoryCache.cs b/OpenSim.RegionServer/Assets/InventoryCache.cs new file mode 100644 index 0000000000..a50bb2b1f9 --- /dev/null +++ b/OpenSim.RegionServer/Assets/InventoryCache.cs @@ -0,0 +1,336 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using libsecondlife; +using OpenSim; +using libsecondlife.Packets; +//using OpenSim.GridServers; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Interfaces; + +namespace OpenSim.Assets +{ + /// + /// Description of InventoryManager. + /// + public class InventoryCache + { + private Dictionary _agentsInventory; + private List _serverRequests; //list of requests made to user server. + private System.Text.Encoding _enc = System.Text.Encoding.ASCII; + private const uint FULL_MASK_PERMISSIONS = 2147483647; + + public InventoryCache() + { + _agentsInventory = new Dictionary(); + _serverRequests = new List(); + } + + public void AddNewAgentsInventory(AgentInventory agentInventory) + { + if (!this._agentsInventory.ContainsKey(agentInventory.AgentID)) + { + this._agentsInventory.Add(agentInventory.AgentID, agentInventory); + } + } + + public AgentInventory FetchAgentsInventory(LLUUID agentID, IUserServer userserver) + { + AgentInventory res = null; + if (!this._agentsInventory.ContainsKey(agentID)) + { + res = userserver.RequestAgentsInventory(agentID); + this._agentsInventory.Add(agentID,res); + } + return res; + } + + public AgentInventory GetAgentsInventory(LLUUID agentID) + { + if (this._agentsInventory.ContainsKey(agentID)) + { + return this._agentsInventory[agentID]; + } + + return null; + } + + public void ClientLeaving(LLUUID clientID, IUserServer userserver) + { + if (this._agentsInventory.ContainsKey(clientID)) + { + if (userserver != null) + { + userserver.UpdateAgentsInventory(clientID, this._agentsInventory[clientID]); + } + this._agentsInventory.Remove(clientID); + } + } + + public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID) + { + return this.CreateNewInventoryFolder(remoteClient, folderID, 0); + } + + public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID, ushort type) + { + bool res = false; + if (folderID != LLUUID.Zero) //don't create a folder with a zero id + { + if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) + { + res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type); + } + } + return res; + } + + public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent) + { + bool res = false; + if (folderID != LLUUID.Zero) //don't create a folder with a zero id + { + if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) + { + res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type, folderName, parent); + } + } + return res; + } + + public LLUUID AddNewInventoryItem(SimClient remoteClient, LLUUID folderID, OpenSim.Framework.Assets.AssetBase asset) + { + LLUUID newItem = null; + if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) + { + newItem = this._agentsInventory[remoteClient.AgentID].AddToInventory(folderID, asset); + if (newItem != null) + { + InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[newItem]; + this.SendItemUpdateCreate(remoteClient, Item); + } + } + + return newItem; + } + public bool DeleteInventoryItem(SimClient remoteClient, LLUUID itemID) + { + bool res = false; + if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) + { + res = this._agentsInventory[remoteClient.AgentID].DeleteFromInventory(itemID); + if (res) + { + RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket(); + remove.AgentData.AgentID = remoteClient.AgentID; + remove.AgentData.SessionID = remoteClient.SessionID; + remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1]; + remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock(); + remove.InventoryData[0].ItemID = itemID; + remoteClient.OutPacket(remove); + } + } + + return res; + } + + public bool UpdateInventoryItemAsset(SimClient remoteClient, LLUUID itemID, OpenSim.Framework.Assets.AssetBase asset) + { + if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) + { + bool res = _agentsInventory[remoteClient.AgentID].UpdateItemAsset(itemID, asset); + if (res) + { + InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID]; + this.SendItemUpdateCreate(remoteClient, Item); + } + return res; + } + + return false; + } + + public bool UpdateInventoryItemDetails(SimClient remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet) + { + if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) + { + bool res = _agentsInventory[remoteClient.AgentID].UpdateItemDetails(itemID, packet); + if (res) + { + InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID]; + this.SendItemUpdateCreate(remoteClient, Item); + } + return res; + } + + return false; + } + + public void FetchInventoryDescendents(SimClient userInfo, FetchInventoryDescendentsPacket FetchDescend) + { + if (this._agentsInventory.ContainsKey(userInfo.AgentID)) + { + AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; + if (FetchDescend.InventoryData.FetchItems) + { + if (agentInventory.InventoryFolders.ContainsKey(FetchDescend.InventoryData.FolderID)) + { + InventoryFolder Folder = agentInventory.InventoryFolders[FetchDescend.InventoryData.FolderID]; + InventoryDescendentsPacket Descend = new InventoryDescendentsPacket(); + Descend.AgentData.AgentID = userInfo.AgentID; + Descend.AgentData.OwnerID = Folder.OwnerID; + Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID; + Descend.AgentData.Descendents = Folder.Items.Count; + Descend.AgentData.Version = Folder.Items.Count; + + + Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count]; + for (int i = 0; i < Folder.Items.Count; i++) + { + + InventoryItem Item = Folder.Items[i]; + Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); + Descend.ItemData[i].ItemID = Item.ItemID; + Descend.ItemData[i].AssetID = Item.AssetID; + Descend.ItemData[i].CreatorID = Item.CreatorID; + Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS; + Descend.ItemData[i].CreationDate = 1000; + Descend.ItemData[i].Description = _enc.GetBytes(Item.Description + "\0"); + Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS; + Descend.ItemData[i].Flags = 1; + Descend.ItemData[i].FolderID = Item.FolderID; + Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); + Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS; + Descend.ItemData[i].InvType = Item.InvType; + Descend.ItemData[i].Name = _enc.GetBytes(Item.Name + "\0"); + Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS; + Descend.ItemData[i].OwnerID = Item.OwnerID; + Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS; + Descend.ItemData[i].SalePrice = 100; + Descend.ItemData[i].SaleType = 0; + Descend.ItemData[i].Type = Item.Type; + 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); + } + + userInfo.OutPacket(Descend); + + } + } + else + { + Console.WriteLine("fetch subfolders"); + } + } + } + + public void FetchInventory(SimClient userInfo, FetchInventoryPacket FetchItems) + { + if (this._agentsInventory.ContainsKey(userInfo.AgentID)) + { + AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; + + for (int i = 0; i < FetchItems.InventoryData.Length; i++) + { + if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID)) + { + InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID]; + FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket(); + InventoryReply.AgentData.AgentID = userInfo.AgentID; + InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; + InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); + InventoryReply.InventoryData[0].ItemID = Item.ItemID; + InventoryReply.InventoryData[0].AssetID = Item.AssetID; + InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; + InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); + InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].Flags = 0; + InventoryReply.InventoryData[0].FolderID = Item.FolderID; + InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); + InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].InvType = Item.InvType; + InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); + InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; + InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].SalePrice = 100; + InventoryReply.InventoryData[0].SaleType = 0; + InventoryReply.InventoryData[0].Type = Item.Type; + 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); + userInfo.OutPacket(InventoryReply); + } + } + } + } + + private void SendItemUpdateCreate(SimClient remoteClient, InventoryItem Item) + { + + UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket(); + InventoryReply.AgentData.AgentID = remoteClient.AgentID; + InventoryReply.AgentData.SimApproved = true; + InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1]; + InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock(); + InventoryReply.InventoryData[0].ItemID = Item.ItemID; + InventoryReply.InventoryData[0].AssetID = Item.AssetID; + InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; + InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].CreationDate = 1000; + InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); + InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].Flags = 0; + InventoryReply.InventoryData[0].FolderID = Item.FolderID; + InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); + InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].InvType = Item.InvType; + InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); + InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; + InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].SalePrice = 100; + InventoryReply.InventoryData[0].SaleType = 0; + InventoryReply.InventoryData[0].Type = Item.Type; + 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); + + remoteClient.OutPacket(InventoryReply); + } + } + + + + public class UserServerRequest + { + public UserServerRequest() + { + + } + } +} diff --git a/OpenSim.RegionServer/CAPS/AdminWebFront.cs b/OpenSim.RegionServer/CAPS/AdminWebFront.cs new file mode 100644 index 0000000000..d4519e82e2 --- /dev/null +++ b/OpenSim.RegionServer/CAPS/AdminWebFront.cs @@ -0,0 +1,257 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using OpenSim.world; +using OpenSim.UserServer; +using OpenSim.Servers; +using OpenSim.Assets; +using OpenSim.Framework.Inventory; +using libsecondlife; +using OpenSim.RegionServer.world.scripting; +using Avatar=libsecondlife.Avatar; +using OpenSim.RegionServer.world.scripting.Scripts; + +namespace OpenSim.CAPS +{ + public class AdminWebFront + { + private string AdminPage; + private string NewAccountForm; + private string LoginForm; + private string passWord = "Admin"; + private World m_world; + private LoginServer _userServer; + private InventoryCache _inventoryCache; + + public AdminWebFront(string password, World world, InventoryCache inventoryCache, LoginServer userserver) + { + _inventoryCache = inventoryCache; + _userServer = userserver; + m_world = world; + passWord = password; + LoadAdminPage(); + } + + public void LoadMethods( BaseHttpServer server ) + { + server.AddRestHandler("GET", "/Admin", GetAdminPage); + server.AddRestHandler("GET", "/Admin/Welcome", GetWelcomePage); + server.AddRestHandler("GET", "/Admin/Accounts", GetAccountsPage ); + server.AddRestHandler("GET", "/Admin/Clients", GetConnectedClientsPage); + server.AddRestHandler("GET", "/Admin/Entities", GetEntitiesPage); + server.AddRestHandler("GET", "/Admin/Scripts", GetScriptsPage); + server.AddRestHandler("GET", "/Admin/AddTestScript", AddTestScript ); + server.AddRestHandler("GET", "/ClientInventory", GetClientsInventory); + + server.AddRestHandler("POST", "/Admin/NewAccount", PostNewAccount ); + server.AddRestHandler("POST", "/Admin/Login", PostLogin ); + } + + private string GetWelcomePage(string request, string path) + { + string responseString; + responseString = "Welcome to the OpenSim Admin Page"; + responseString += "


" + LoginForm; + return responseString; + } + + private string PostLogin(string requestBody, string path) + { + string responseString; +// Console.WriteLine(requestBody); + if (requestBody == passWord) + { + responseString = "

Login Successful

"; + } + else + { + responseString = "

Password Error

"; + responseString += "

Please Login with the correct password

"; + responseString += "

" + LoginForm; + } + return responseString; + } + + private string PostNewAccount(string requestBody, string path) + { + string responseString; + string firstName = ""; + string secondName = ""; + string userPasswd = ""; + string[] comp; + string[] passw; + string[] line; + string delimStr = "&"; + char[] delimiter = delimStr.ToCharArray(); + string delimStr2 = "="; + char[] delimiter2 = delimStr2.ToCharArray(); + + //Console.WriteLine(requestBody); + comp = requestBody.Split(delimiter); + passw = comp[3].Split(delimiter2); + if (passw[1] == passWord) // check admin password is correct + { + + line = comp[0].Split(delimiter2); //split firstname + if (line.Length > 1) + { + firstName = line[1]; + } + line = comp[1].Split(delimiter2); //split secondname + if (line.Length > 1) + { + secondName = line[1]; + } + line = comp[2].Split(delimiter2); //split user password + if (line.Length > 1) + { + userPasswd = line[1]; + } + if (this._userServer != null) + { + this._userServer.CreateUserAccount(firstName, secondName, userPasswd); + } + responseString = "

New Account created

"; + } + else + { + responseString = "

Admin password is incorrect, please login with the correct password

"; + responseString += "

" + LoginForm; + } + return responseString; + } + + private string GetConnectedClientsPage(string request, string path) + { + string responseString; + responseString = "

Listing connected Clients

"; + OpenSim.world.Avatar TempAv; + foreach (libsecondlife.LLUUID UUID in m_world.Entities.Keys) + { + if (m_world.Entities[UUID].ToString() == "OpenSim.world.Avatar") + { + TempAv = (OpenSim.world.Avatar)m_world.Entities[UUID]; + responseString += "

Client: "; + responseString += TempAv.firstname + " , " + TempAv.lastname + " , " + UUID + " , " + TempAv.ControllingClient.SessionID + " , " + TempAv.ControllingClient.CircuitCode + " , " + TempAv.ControllingClient.userEP.ToString(); + responseString += "

"; + } + } + return responseString; + } + + private string AddTestScript(string request, string path) + { + int index = path.LastIndexOf('/'); + + string lluidStr = path.Substring(index+1); + + LLUUID id; + + if( LLUUID.TryParse( lluidStr, out id ) ) + { + // This is just here for concept purposes... Remove! + m_world.AddScript( m_world.Entities[id], new FollowRandomAvatar()); + return String.Format("Added new script to object [{0}]", id); + } + else + { + return String.Format("Couldn't parse [{0}]", lluidStr ); + } + } + + private string GetScriptsPage(string request, string path) + { + return String.Empty; + } + + private string GetEntitiesPage(string request, string path) + { + string responseString; + responseString = "

Listing current entities

    "; + + foreach (Entity entity in m_world.Entities.Values) + { + string testScriptLink = "javascript:loadXMLDoc('Admin/AddTestScript/" + entity.uuid.ToString() + "');"; + responseString += String.Format( "
  • [{0}] \"{1}\" @ {2} add test script
  • ", entity.uuid, entity.Name, entity.Pos, testScriptLink ); + } + responseString += "
"; + return responseString; + } + + private string GetClientsInventory(string request, string path) + { + string[] line; + string delimStr = "/"; + char[] delimiter = delimStr.ToCharArray(); + string responseString; + responseString = "

Listing Inventory

"; + + line = path.Split(delimiter); + if (line.Length > 2) + { + if (line[1] == "ClientInventory") + { + AgentInventory inven = this._inventoryCache.GetAgentsInventory(new libsecondlife.LLUUID(line[2])); + responseString += "

Client: " + inven.AgentID.ToStringHyphenated() +"

"; + if (inven != null) + { + foreach (InventoryItem item in inven.InventoryItems.Values) + { + responseString += "

InventoryItem: "; + responseString += item.Name +" , "+ item.ItemID +" , "+ item.Type +" , "+ item.FolderID +" , "+ item.AssetID +" , "+ item.Description ; + responseString += "

"; + } + } + } + } + return responseString; + } + + private string GetCachedAssets(string request, string path) + { + return ""; + } + + private string GetAccountsPage(string request, string path) + { + string responseString; + responseString = "

Account management

"; + responseString += "
"; + responseString += "

Create New Account

"; + responseString += NewAccountForm; + return responseString; + } + + private string GetAdminPage(string request, string path) + { + return AdminPage; + } + + private void LoadAdminPage() + { + try + { + StreamReader SR; + + SR = File.OpenText("testadmin.htm"); + AdminPage = SR.ReadToEnd(); + SR.Close(); + + SR = File.OpenText("newaccountform.htm"); + NewAccountForm = SR.ReadToEnd(); + SR.Close(); + + SR = File.OpenText("login.htm"); + LoginForm = SR.ReadToEnd(); + SR.Close(); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + + } + + } +} diff --git a/OpenSim.RegionServer/ConsoleCmds.cs b/OpenSim.RegionServer/ConsoleCmds.cs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/OpenSim.RegionServer/Grid.cs b/OpenSim.RegionServer/Grid.cs new file mode 100644 index 0000000000..db5b8febc8 --- /dev/null +++ b/OpenSim.RegionServer/Grid.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Reflection; +using OpenSim.Framework.Interfaces; +using OpenSim.UserServer; + +namespace OpenSim +{ + public class Grid + { + public IAssetServer AssetServer; + public IGridServer GridServer; + public IUserServer UserServer; + public string AssetDll = ""; + public string GridDll = ""; + + public Grid() + { + } + + public virtual void Initialise() + { + //load the dlls + this.AssetServer = this.LoadAssetDll(this.AssetDll); + this.GridServer = this.LoadGridDll(this.GridDll); + } + public virtual void Close() + { + this.AssetServer.Close(); + this.GridServer.Close(); + } + + private IAssetServer LoadAssetDll(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + IAssetServer server = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IAssetPlugin", true); + + if (typeInterface != null) + { + IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + server = plug.GetAssetServer(); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + return server; + } + + private IGridServer LoadGridDll(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + IGridServer server = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IGridPlugin", true); + + if (typeInterface != null) + { + IGridPlugin plug = (IGridPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + server = plug.GetGridServer(); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + return server; + } + } +} diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj new file mode 100644 index 0000000000..5fd5d650e5 --- /dev/null +++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj @@ -0,0 +1,238 @@ + + + Local + 8.0.50727 + 2.0 + {632E1BFD-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + + OpenSim.RegionServer + JScript + Grid + IE50 + false + Library + + + OpenSim.RegionServer + + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + + False + 285212672 + False + + + TRACE + + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + + System.dll + False + + + + System.Xml.dll + False + + + ..\bin\libsecondlife.dll + False + + + ..\bin\Axiom.MathLib.dll + False + + + ..\bin\Db4objects.Db4o.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.GenericConfig.Xml + {E88EF749-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Physics.Manager + {8BE16150-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + {FFD5951C-4002-4ACA-9ADF-68852357B94A} + OpenSim.Terrain.BasicTerrain + + + OpenSim.Servers + {8BB20F0A-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + + \ No newline at end of file diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj.user b/OpenSim.RegionServer/OpenSim.RegionServer.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build new file mode 100644 index 0000000000..cd900f56ce --- /dev/null +++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.RegionServer/OpenSim.csproj b/OpenSim.RegionServer/OpenSim.csproj new file mode 100644 index 0000000000..035f3e02ef --- /dev/null +++ b/OpenSim.RegionServer/OpenSim.csproj @@ -0,0 +1,186 @@ + + + Local + 8.0.50727 + 2.0 + {6E597AD4-1F7D-4389-B04C-403EF1046AAB} + Debug + AnyCPU + + + + + OpenSim + JScript + Grid + IE50 + false + Exe + + + OpenSim + + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + + False + 285212672 + False + + + TRACE + + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + + System.dll + False + + + + System.Xml.dll + False + + + ..\bin\libsecondlife.dll + False + + + ..\bin\Axiom.MathLib.dll + False + + + ..\bin\Db4objects.Db4o.dll + False + + + + + OpenSim.Framework.Console + {1492353A-6133-4557-9AD8-6E24386D70F8} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Physics.Manager + {0FD686EA-1917-469E-A885-1D9DEEA1D340} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework + {E267CE4E-F355-4A27-8D0D-CA48FEE7F978} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + \ No newline at end of file diff --git a/OpenSim.RegionServer/OpenSim.exe.build b/OpenSim.RegionServer/OpenSim.exe.build new file mode 100644 index 0000000000..529f5fb55b --- /dev/null +++ b/OpenSim.RegionServer/OpenSim.exe.build @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs new file mode 100644 index 0000000000..3ec46873c4 --- /dev/null +++ b/OpenSim.RegionServer/OpenSimMain.cs @@ -0,0 +1,449 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Text; +using System.IO; +using System.Threading; +using System.Net; +using System.Net.Sockets; +using System.Timers; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.world; +using OpenSim.Terrain; +using OpenSim.Framework.Interfaces; +using OpenSim.UserServer; +using OpenSim.Assets; +using OpenSim.CAPS; +using OpenSim.Framework.Console; +using OpenSim.Physics.Manager; +using OpenSim.GenericConfig; +using Nwc.XmlRpc; +using OpenSim.Servers; + +namespace OpenSim +{ + + public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback + { + //private SimConfig Cfg; + private IGenericConfig localConfig; + //private IGenericConfig remoteConfig; + private PhysicsManager physManager; + private Grid GridServers; + private BaseHttpServer _httpServer; + private PacketServer _packetServer; + private World LocalWorld; + private AssetCache AssetCache; + private InventoryCache InventoryCache; + //private Dictionary ClientThreads = new Dictionary(); + private Dictionary clientCircuits = new Dictionary(); + private DateTime startuptime; + private RegionInfo regionData; + + public Socket Server; + private IPEndPoint ServerIncoming; + private byte[] RecvBuffer = new byte[4096]; + private byte[] ZeroBuffer = new byte[8192]; + private IPEndPoint ipeSender; + private EndPoint epSender; + private AsyncCallback ReceivedData; + + private System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer(); + //private string ConfigDll = "OpenSim.Config.SimConfigDb4o.dll"; + public string m_physicsEngine; + public bool m_sandbox = false; + public bool m_loginserver; + public bool user_accounts = false; + + protected ConsoleBase m_console; + + public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine) + { + m_sandbox = sandBoxMode; + m_loginserver = startLoginServer; + m_physicsEngine = physicsEngine; + + m_console = new ConsoleBase("region-console.log", "Region", this); + OpenSim.Framework.Console.MainConsole.Instance = m_console; + } + + /// + /// Performs initialisation of the world, such as loading configuration from disk. + /// + public virtual void StartUp() + { + this.regionData = new RegionInfo(); + try + { + this.localConfig = new XmlConfig("simconfig.xml"); + this.localConfig.LoadData(); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + m_console.WriteLine("Main.cs:Startup() - Loading configuration"); + this.regionData.InitConfig(this.m_sandbox, this.localConfig); + //regionData.SimUUID = new LLUUID(localConfig.GetAttribute("SimUUID")); //don't need as regionData.SimUUID is already set through the above line + this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change + + + GridServers = new Grid(); + if (m_sandbox) + { + GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; + GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; + + m_console.WriteLine("Starting in Sandbox mode"); + } + else + { + GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll"; + GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll"; + + m_console.WriteLine("Starting in Grid mode"); + } + + GridServers.Initialise(); + + startuptime = DateTime.Now; + + AssetCache = new AssetCache(GridServers.AssetServer); + InventoryCache = new InventoryCache(); + + PacketServer packetServer = new PacketServer(this); + + m_console.WriteLine("Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString()); + m_console.WriteLine("Initialising world"); + LocalWorld = new World(this._packetServer.ClientThreads, regionData.RegionHandle, regionData.RegionName); + LocalWorld.InventoryCache = InventoryCache; + LocalWorld.AssetCache = AssetCache; + + this._packetServer.LocalWorld = LocalWorld; + this._packetServer.RegisterClientPacketHandlers(); + + this.physManager = new OpenSim.Physics.Manager.PhysicsManager(); + this.physManager.LoadPlugins(); + + LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. + LocalWorld.LoadWorldMap(); + + m_console.WriteLine("Main.cs:Startup() - Starting up messaging system"); + LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use + LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D()); + + //should be passing a IGenericConfig object to these so they can read the config data they want from it + GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey); + IGridServer gridServer = GridServers.GridServer; + gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey); + + LocalWorld.LoadPrimsFromStorage(); + + if (m_sandbox) + { + AssetCache.LoadDefaultTextureSet(); + } + + m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server"); + // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort); + _httpServer = new BaseHttpServer(regionData.IPListenPort); + + if (gridServer.GetName() == "Remote") + { + //we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server + _httpServer.AddXmlRPCHandler("expect_user", + delegate(XmlRpcRequest request) + { + Hashtable requestData = (Hashtable)request.Params[0]; + AgentCircuitData agent_data = new AgentCircuitData(); + agent_data.SessionID = new LLUUID((string)requestData["session_id"]); + agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]); + agent_data.firstname = (string)requestData["firstname"]; + agent_data.lastname = (string)requestData["lastname"]; + agent_data.AgentID = new LLUUID((string)requestData["agent_id"]); + agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); + + ((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data); + + return new XmlRpcResponse(); + }); + _httpServer.AddRestHandler("GET", "/simstatus/", + delegate(string request, string path) + { + return "OK"; + }); + } + + LoginServer loginServer = null; + LoginServer adminLoginServer = null; + + bool sandBoxWithLoginServer = m_loginserver && m_sandbox; + if (sandBoxWithLoginServer) + { + loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort, this.user_accounts); + loginServer.Startup(); + + if (user_accounts) + { + //sandbox mode with loginserver using accounts + this.GridServers.UserServer = loginServer; + adminLoginServer = loginServer; + + _httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod); + } + else + { + //sandbox mode with loginserver not using accounts + _httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); + } + } + + AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer); + adminWebFront.LoadMethods(_httpServer); + + m_console.WriteLine("Main.cs:Startup() - Starting HTTP server"); + _httpServer.Start(); + + MainServerListener(); + + m_heartbeatTimer.Enabled = true; + m_heartbeatTimer.Interval = 100; + m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); + } + + private SimConfig LoadConfigDll(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + SimConfig config = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("ISimConfig", true); + + if (typeInterface != null) + { + ISimConfig plug = (ISimConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + config = plug.GetConfigObject(); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + return config; + } + + private void OnReceivedData(IAsyncResult result) + { + ipeSender = new IPEndPoint(IPAddress.Any, 0); + epSender = (EndPoint)ipeSender; + Packet packet = null; + int numBytes = Server.EndReceiveFrom(result, ref epSender); + int packetEnd = numBytes - 1; + packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); + + // This is either a new client or a packet to send to an old one + // if (OpenSimRoot.Instance.ClientThreads.ContainsKey(epSender)) + + // do we already have a circuit for this endpoint + if (this.clientCircuits.ContainsKey(epSender)) + { + //ClientThreads[this.clientCircuits[epSender]].InPacket(packet); + this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet); + } + else if (packet.Type == PacketType.UseCircuitCode) + { // new client + UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet; + this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); + SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, _packetServer.ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox); + if ((this.GridServers.UserServer != null) && (user_accounts)) + { + newuser.UserServer = this.GridServers.UserServer; + } + //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser); + this._packetServer.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); + } + else + { // invalid client + Console.Error.WriteLine("Main.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString()); + } + Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); + } + + private void MainServerListener() + { + m_console.WriteLine("Main.cs:MainServerListener() - New thread started"); + m_console.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + regionData.IPListenAddr + ":" + regionData.IPListenPort); + + ServerIncoming = new IPEndPoint(IPAddress.Any, regionData.IPListenPort); + Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + Server.Bind(ServerIncoming); + + m_console.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen"); + + ipeSender = new IPEndPoint(IPAddress.Any, 0); + epSender = (EndPoint)ipeSender; + ReceivedData = new AsyncCallback(this.OnReceivedData); + Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); + + m_console.WriteLine("Main.cs:MainServerListener() - Listening..."); + + } + + public void RegisterPacketServer(PacketServer server) + { + this._packetServer = server; + } + + public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender) + { + // find the endpoint for this circuit + EndPoint sendto = null; + foreach (KeyValuePair p in this.clientCircuits) + { + if (p.Value == circuitcode) + { + sendto = p.Key; + break; + } + } + if (sendto != null) + { + //we found the endpoint so send the packet to it + this.Server.SendTo(buffer, size, flags, sendto); + } + } + + public virtual void RemoveClientCircuit(uint circuitcode) + { + foreach (KeyValuePair p in this.clientCircuits) + { + if (p.Value == circuitcode) + { + this.clientCircuits.Remove(p.Key); + break; + } + } + } + + /// + /// Performs any last-minute sanity checking and shuts down the region server + /// + public virtual void Shutdown() + { + m_console.WriteLine("Main.cs:Shutdown() - Closing all threads"); + m_console.WriteLine("Main.cs:Shutdown() - Killing listener thread"); + m_console.WriteLine("Main.cs:Shutdown() - Killing clients"); + // IMPLEMENT THIS + m_console.WriteLine("Main.cs:Shutdown() - Closing console and terminating"); + LocalWorld.Close(); + GridServers.Close(); + m_console.Close(); + Environment.Exit(0); + } + + /// + /// Performs per-frame updates regularly + /// + /// + /// + void Heartbeat(object sender, System.EventArgs e) + { + LocalWorld.Update(); + } + + /// + /// Runs commands issued by the server console from the operator + /// + /// The first argument of the parameter (the command) + /// Additional arguments passed to the command + public void RunCmd(string command, string[] cmdparams) + { + switch (command) + { + case "help": + m_console.WriteLine("show users - show info about connected users"); + m_console.WriteLine("shutdown - disconnect all clients and shutdown"); + m_console.WriteLine("regenerate - regenerate the sim's terrain"); + break; + + case "show": + Show(cmdparams[0]); + break; + + case "regenerate": + LocalWorld.RegenerateTerrain(); + break; + + case "shutdown": + Shutdown(); + break; + } + } + + /// + /// Outputs to the console information about the region + /// + /// What information to display (valid arguments are "uptime", "users") + public void Show(string ShowWhat) + { + switch (ShowWhat) + { + case "uptime": + m_console.WriteLine("OpenSim has been running since " + startuptime.ToString()); + m_console.WriteLine("That is " + (DateTime.Now - startuptime).ToString()); + break; + case "users": + OpenSim.world.Avatar TempAv; + m_console.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP")); + foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys) + { + if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar") + { + TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID]; + m_console.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString())); + } + } + break; + } + } + } + + +} diff --git a/OpenSim.RegionServer/OpenSimNetworkHandler.cs b/OpenSim.RegionServer/OpenSimNetworkHandler.cs new file mode 100644 index 0000000000..664912038d --- /dev/null +++ b/OpenSim.RegionServer/OpenSimNetworkHandler.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Net; +using System.Net.Sockets; + +namespace OpenSim +{ + public interface OpenSimNetworkHandler + { + //public abstract void StartUp(); + // public abstract void Shutdown(); + void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender); + void RemoveClientCircuit(uint circuitcode); + void RegisterPacketServer(PacketServer server); + } +} diff --git a/OpenSim.RegionServer/PacketServer.cs b/OpenSim.RegionServer/PacketServer.cs new file mode 100644 index 0000000000..f0a1f52380 --- /dev/null +++ b/OpenSim.RegionServer/PacketServer.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.world; +using libsecondlife.Packets; + +namespace OpenSim +{ + public class PacketServer + { + private OpenSimNetworkHandler _networkHandler; + private World _localWorld; + public Dictionary ClientThreads = new Dictionary(); + + public PacketServer(OpenSimNetworkHandler networkHandler) + { + _networkHandler = networkHandler; + _networkHandler.RegisterPacketServer(this); + } + + public World LocalWorld + { + set + { + this._localWorld = value; + } + } + + public void ClientInPacket(uint circuitCode, Packet packet) + { + if (this.ClientThreads.ContainsKey(circuitCode)) + { + ClientThreads[circuitCode].InPacket(packet); + } + } + + public bool AddNewCircuitCodeClient(uint circuitCode) + { + return false; + } + + public void SendPacketToAllClients(Packet packet) + { + + } + + public void SendPacketToAllExcept(Packet packet, SimClient simClient) + { + + } + + public virtual void RegisterClientPacketHandlers() + { + if (this._localWorld != null) + { + SimClient.AddPacketHandler(PacketType.ModifyLand, _localWorld.ModifyTerrain); + SimClient.AddPacketHandler(PacketType.ChatFromViewer, _localWorld.SimChat); + SimClient.AddPacketHandler(PacketType.RezObject, _localWorld.RezObject); + SimClient.AddPacketHandler(PacketType.DeRezObject, _localWorld.DeRezObject); + SimClient.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName); + } + } + + #region Client Packet Handlers + + public bool RequestUUIDName(SimClient simClient, Packet packet) + { + System.Text.Encoding enc = System.Text.Encoding.ASCII; + Console.WriteLine(packet.ToString()); + UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)packet; + UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket(); + nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length]; + + for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++) + { + nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); + nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID; + nameReply.UUIDNameBlock[i].FirstName = enc.GetBytes("Who\0"); //for now send any name + nameReply.UUIDNameBlock[i].LastName = enc.GetBytes("Knows\0"); //in future need to look it up + } + simClient.OutPacket(nameReply); + return true; + } + + #endregion + } +} diff --git a/OpenSim.RegionServer/QueItem.cs b/OpenSim.RegionServer/QueItem.cs new file mode 100644 index 0000000000..747e026327 --- /dev/null +++ b/OpenSim.RegionServer/QueItem.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife.Packets; + +namespace OpenSim +{ + public class QueItem + { + public QueItem() + { + } + + public Packet Packet; + public bool Incoming; + } + +} diff --git a/OpenSim.RegionServer/RegionInfo.cs b/OpenSim.RegionServer/RegionInfo.cs new file mode 100644 index 0000000000..cf0c075856 --- /dev/null +++ b/OpenSim.RegionServer/RegionInfo.cs @@ -0,0 +1,244 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; +using libsecondlife; + +namespace OpenSim +{ + public class RegionInfo // could inherit from SimProfileBase + { + public LLUUID SimUUID; + public string RegionName; + public uint RegionLocX; + public uint RegionLocY; + public ulong RegionHandle; + + public int IPListenPort; + public string IPListenAddr; + + //following should be removed and the GenericConfig object passed around, + //so each class (AssetServer, GridServer etc) can access what config data they want + public string AssetURL = ""; + public string AssetSendKey = ""; + + public string GridURL = ""; + public string GridSendKey = ""; + public string GridRecvKey = ""; + public string UserURL = ""; + public string UserSendKey = ""; + public string UserRecvKey = ""; + private bool isSandbox; + + public RegionInfo() + { + + } + + public void InitConfig(bool sandboxMode, IGenericConfig configData) + { + this.isSandbox = sandboxMode; + try + { + // Sim UUID + string attri = ""; + attri = configData.GetAttribute("SimUUID"); + if (attri == "") + { + this.SimUUID = LLUUID.Random(); + configData.SetAttribute("SimUUID", this.SimUUID.ToString()); + } + else + { + this.SimUUID = new LLUUID(attri); + } + + // Sim name + attri = ""; + attri = configData.GetAttribute("SimName"); + if (attri == "") + { + this.RegionName = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Name [OpenSim test]: ", "OpenSim test"); + configData.SetAttribute("SimName", this.RegionName); + } + else + { + this.RegionName = attri; + } + // Sim/Grid location X + attri = ""; + attri = configData.GetAttribute("SimLocationX"); + if (attri == "") + { + string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location X [997]: ", "997"); + configData.SetAttribute("SimLocationX", location); + this.RegionLocX = (uint)Convert.ToUInt32(location); + } + else + { + this.RegionLocX = (uint)Convert.ToUInt32(attri); + } + // Sim/Grid location Y + attri = ""; + attri = configData.GetAttribute("SimLocationY"); + if (attri == "") + { + string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location Y [996]: ", "996"); + configData.SetAttribute("SimLocationY", location); + this.RegionLocY = (uint)Convert.ToUInt32(location); + } + else + { + this.RegionLocY = (uint)Convert.ToUInt32(attri); + } + //Sim Listen Port + attri = ""; + attri = configData.GetAttribute("SimListenPort"); + if (attri == "") + { + string port = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("UDP port for client connections [9000]: ", "9000"); + configData.SetAttribute("SimListenPort", port); + this.IPListenPort = Convert.ToInt32(port); + } + else + { + this.IPListenPort = Convert.ToInt32(attri); + } + //Sim Listen Address + attri = ""; + attri = configData.GetAttribute("SimListenAddress"); + if (attri == "") + { + this.IPListenAddr = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ", "127.0.0.1"); + configData.SetAttribute("SimListenAddress", this.IPListenAddr); + } + else + { + this.IPListenAddr = attri; + } + + if (!isSandbox) + { + //shouldn't be reading this data in here, it should be up to the classes implementing the server interfaces to read what they need from the config object + + // Asset Server URL + attri = ""; + attri = configData.GetAttribute("AssetServerURL"); + if (attri == "") + { + this.AssetURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server URL: "); + configData.SetAttribute("AssetServerURL", this.AssetURL); + } + else + { + this.AssetURL = attri; + } + //Asset Server key + attri = ""; + attri = configData.GetAttribute("AssetServerKey"); + if (attri == "") + { + this.AssetSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server key: "); + configData.SetAttribute("AssetServerKey", this.AssetSendKey); + } + else + { + this.AssetSendKey = attri; + } + //Grid Sever URL + attri = ""; + attri = configData.GetAttribute("GridServerURL"); + if (attri == "") + { + this.GridURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid server URL: "); + configData.SetAttribute("GridServerURL", this.GridURL); + } + else + { + this.GridURL = attri; + } + //Grid Send Key + attri = ""; + attri = configData.GetAttribute("GridSendKey"); + if (attri == "") + { + this.GridSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to grid server: "); + configData.SetAttribute("GridSendKey", this.GridSendKey); + } + else + { + this.GridSendKey = attri; + } + //Grid Receive Key + attri = ""; + attri = configData.GetAttribute("GridRecvKey"); + if (attri == "") + { + this.GridRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from grid server: "); + configData.SetAttribute("GridRecvKey", this.GridRecvKey); + } + else + { + this.GridRecvKey = attri; + } + //User Server URL + attri = ""; + attri = configData.GetAttribute("UserServerURL"); + if (attri == "") + { + this.UserURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("User server URL: "); + configData.SetAttribute("UserServerURL", this.UserURL); + } + else + { + this.UserURL = attri; + } + //User Send Key + attri = ""; + attri = configData.GetAttribute("UserSendKey"); + if (attri == "") + { + this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server: "); + configData.SetAttribute("UserSendKey", this.UserSendKey); + } + else + { + this.UserSendKey = attri; + } + //User Receive Key + attri = ""; + attri = configData.GetAttribute("UserRecvKey"); + if (attri == "") + { + this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server: "); + configData.SetAttribute("UserRecvKey", this.UserRecvKey); + } + else + { + this.UserRecvKey = attri; + } + } + this.RegionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); + configData.Commit(); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); + } + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sim settings loaded:"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("UUID: " + this.SimUUID.ToStringHyphenated()); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Name: " + this.RegionName); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString()); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sandbox Mode? " + isSandbox.ToString()); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset URL: " + this.AssetURL); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset key: " + this.AssetSendKey); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid URL: " + this.GridURL); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid key: " + this.GridSendKey); + } + } +} diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs new file mode 100644 index 0000000000..6d174c8e11 --- /dev/null +++ b/OpenSim.RegionServer/SimClient.cs @@ -0,0 +1,944 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using libsecondlife.Packets; +using System.Net; +using System.Net.Sockets; +using System.IO; +using System.Threading; +using System.Timers; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; +using OpenSim.world; +using OpenSim.Assets; + +namespace OpenSim +{ + public delegate bool PacketMethod(SimClient simClient, Packet packet); + + /// + /// Handles new client connections + /// Constructor takes a single Packet and authenticates everything + /// + public class SimClient + { + public LLUUID AgentID; + public LLUUID SessionID; + public LLUUID SecureSessionID = LLUUID.Zero; + public uint CircuitCode; + public world.Avatar ClientAvatar; + private UseCircuitCodePacket cirpack; + private Thread ClientThread; + public EndPoint userEP; + private BlockingQueue PacketQueue; + private Dictionary PendingAcks = new Dictionary(); + private Dictionary NeedAck = new Dictionary(); + //private Dictionary UploadedAssets = new Dictionary(); + private System.Timers.Timer AckTimer; + private uint Sequence = 0; + private object SequenceLock = new object(); + private const int MAX_APPENDED_ACKS = 10; + private const int RESEND_TIMEOUT = 4000; + private const int MAX_SEQUENCE = 0xFFFFFF; + private AgentAssetUpload UploadAssets; + private LLUUID newAssetFolder = LLUUID.Zero; + private bool debug = false; + private World m_world; + private Dictionary m_clientThreads; + private AssetCache m_assetCache; + private IGridServer m_gridServer; + private IUserServer m_userServer = null; + private OpenSimNetworkHandler m_application; + private InventoryCache m_inventoryCache; + private bool m_sandboxMode; + private int cachedtextureserial = 0; + + protected static Dictionary PacketHandlers = new Dictionary(); //Global/static handlers for all clients + + protected Dictionary m_packetHandlers = new Dictionary(); //local handlers for this instance + + public IUserServer UserServer + { + set + { + this.m_userServer = value; + } + } + + public SimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode) + { + m_world = world; + m_clientThreads = clientThreads; + m_assetCache = assetCache; + m_gridServer = gridServer; + m_application = application; + m_inventoryCache = inventoryCache; + m_sandboxMode = sandboxMode; + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request"); + cirpack = initialcirpack; + userEP = remoteEP; + PacketQueue = new BlockingQueue(); + + this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); + AckTimer = new System.Timers.Timer(500); + AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); + AckTimer.Start(); + + this.RegisterLocalPacketHandlers(); + + ClientThread = new Thread(new ThreadStart(AuthUser)); + ClientThread.IsBackground = true; + ClientThread.Start(); + } + + protected virtual void RegisterLocalPacketHandlers() + { + this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout); + this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached); + this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); + } + + public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) + { + bool result = false; + lock (PacketHandlers) + { + if (!PacketHandlers.ContainsKey(packetType)) + { + PacketHandlers.Add(packetType, handler); + result = true; + } + } + return result; + } + + public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler) + { + bool result = false; + lock (m_packetHandlers) + { + if (!m_packetHandlers.ContainsKey(packetType)) + { + m_packetHandlers.Add(packetType, handler); + result = true; + } + } + return result; + } + + protected virtual bool ProcessPacketMethod(Packet packet) + { + bool result = false; + bool found = false; + PacketMethod method; + if (m_packetHandlers.TryGetValue(packet.Type, out method)) + { + //there is a local handler for this packet type + result = method(this, packet); + } + else + { + //there is not a local handler so see if there is a Global handler + lock (PacketHandlers) + { + found = PacketHandlers.TryGetValue(packet.Type, out method); + } + if (found) + { + result = method(this, packet); + } + } + return result; + } + + private void ack_pack(Packet Pack) + { + if (Pack.Header.Reliable) + { + libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket(); + ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; + ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); + ack_it.Packets[0].ID = Pack.Header.Sequence; + ack_it.Header.Reliable = false; + + OutPacket(ack_it); + + } + /* + if (Pack.Header.Reliable) + { + lock (PendingAcks) + { + uint sequence = (uint)Pack.Header.Sequence; + if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } + } + }*/ + } + + protected virtual void ProcessInPacket(Packet Pack) + { + ack_pack(Pack); + if (debug) + { + if (Pack.Type != PacketType.AgentUpdate) + { + Console.WriteLine(Pack.Type.ToString()); + } + } + + if (this.ProcessPacketMethod(Pack)) + { + //there is a handler registered that handled this packet type + return; + } + else + { + System.Text.Encoding _enc = System.Text.Encoding.ASCII; + + switch (Pack.Type) + { + case PacketType.CompleteAgentMovement: + ClientAvatar.CompleteMovement(m_world); + ClientAvatar.SendInitialPosition(); + break; + case PacketType.RegionHandshakeReply: + m_world.SendLayerData(this); + break; + case PacketType.AgentWearablesRequest: + ClientAvatar.SendInitialAppearance(); + foreach (SimClient client in m_clientThreads.Values) + { + if (client.AgentID != this.AgentID) + { + ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket(); + this.OutPacket(objupdate); + client.ClientAvatar.SendAppearanceToOtherAgent(this); + } + } + m_world.GetInitialPrims(this); + break; + case PacketType.AgentIsNowWearing: + AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; + //Console.WriteLine(Pack.ToString()); + break; + case PacketType.AgentSetAppearance: + AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; + // Console.WriteLine(appear.ToString()); + this.ClientAvatar.SetAppearance(appear); + break; + case PacketType.ObjectAdd: + m_world.AddNewPrim((ObjectAddPacket)Pack, this); + break; + case PacketType.ObjectLink: + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString()); + ObjectLinkPacket link = (ObjectLinkPacket)Pack; + uint parentprimid = 0; + OpenSim.world.Primitive parentprim = null; + if (link.ObjectData.Length > 1) + { + parentprimid = link.ObjectData[0].ObjectLocalID; + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == parentprimid) + { + parentprim = (OpenSim.world.Primitive)ent; + + } + } + for (int i = 1; i < link.ObjectData.Length; i++) + { + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == link.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).MakeParent(parentprim); + } + } + } + } + break; + case PacketType.ObjectScale: + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString()); + break; + case PacketType.ObjectShape: + ObjectShapePacket shape = (ObjectShapePacket)Pack; + for (int i = 0; i < shape.ObjectData.Length; i++) + { + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == shape.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).UpdateShape(shape.ObjectData[i]); + } + } + } + break; + case PacketType.RequestImage: + RequestImagePacket imageRequest = (RequestImagePacket)Pack; + for (int i = 0; i < imageRequest.RequestImage.Length; i++) + { + m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); + } + break; + case PacketType.TransferRequest: + //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); + TransferRequestPacket transfer = (TransferRequestPacket)Pack; + m_assetCache.AddAssetRequest(this, transfer); + break; + case PacketType.AgentUpdate: + ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); + break; + case PacketType.ObjectImage: + ObjectImagePacket imagePack = (ObjectImagePacket)Pack; + for (int i = 0; i < imagePack.ObjectData.Length; i++) + { + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == imagePack.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).UpdateTexture(imagePack.ObjectData[i].TextureEntry); + } + } + } + break; + case PacketType.ObjectFlagUpdate: + ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == flags.AgentData.ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags); + } + } + break; + case PacketType.AssetUploadRequest: + AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; + this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); + break; + case PacketType.RequestXfer: + //Console.WriteLine(Pack.ToString()); + break; + case PacketType.SendXferPacket: + this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); + break; + case PacketType.CreateInventoryFolder: + CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; + m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Helpers.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); + //Console.WriteLine(Pack.ToString()); + break; + case PacketType.CreateInventoryItem: + //Console.WriteLine(Pack.ToString()); + CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; + if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) + { + this.UploadAssets.CreateInventoryItem(createItem); + } + else + { + // Console.Write(Pack.ToString()); + this.CreateInventoryItem(createItem); + } + break; + case PacketType.FetchInventory: + //Console.WriteLine("fetch item packet"); + FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; + m_inventoryCache.FetchInventory(this, FetchInventory); + break; + case PacketType.FetchInventoryDescendents: + FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; + m_inventoryCache.FetchInventoryDescendents(this, Fetch); + break; + case PacketType.UpdateInventoryItem: + UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; + //Console.WriteLine(Pack.ToString()); + for (int i = 0; i < update.InventoryData.Length; i++) + { + if (update.InventoryData[i].TransactionID != LLUUID.Zero) + { + AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); + if (asset != null) + { + // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); + m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); + } + else + { + asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); + if (asset != null) + { + //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); + m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); + } + else + { + //Console.WriteLine("trying to update inventory item, but asset is null"); + } + } + } + else + { + m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; + } + } + break; + case PacketType.ViewerEffect: + ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; + foreach (SimClient client in m_clientThreads.Values) + { + if (client.AgentID != this.AgentID) + { + viewer.AgentData.AgentID = client.AgentID; + viewer.AgentData.SessionID = client.SessionID; + client.OutPacket(viewer); + } + } + break; + case PacketType.RequestTaskInventory: + // Console.WriteLine(Pack.ToString()); + RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; + ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket(); + bool foundent = false; + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == requesttask.InventoryData.LocalID) + { + replytask.InventoryData.TaskID = ent.uuid; + replytask.InventoryData.Serial = 0; + replytask.InventoryData.Filename = new byte[0]; + foundent = true; + } + } + if (foundent) + { + this.OutPacket(replytask); + } + break; + case PacketType.UpdateTaskInventory: + // Console.WriteLine(Pack.ToString()); + UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; + AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID); + if (myinventory != null) + { + if (updatetask.UpdateData.Key == 0) + { + if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null) + { + if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7) + { + LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID; + AssetBase assBase = this.m_assetCache.GetAsset(noteaid); + if (assBase != null) + { + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == updatetask.UpdateData.LocalID) + { + if (ent is OpenSim.world.Primitive) + { + this.m_world.AddScript(ent, Helpers.FieldToString(assBase.Data)); + } + } + } + } + } + } + } + } + break; + case PacketType.AgentAnimation: + AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; + for (int i = 0; i < AgentAni.AnimationList.Length; i++) + { + if (AgentAni.AnimationList[i].StartAnim) + { + ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID; + ClientAvatar.anim_seq = 1; + ClientAvatar.SendAnimPack(); + } + } + break; + case PacketType.ObjectSelect: + ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; + for (int i = 0; i < incomingselect.ObjectData.Length; i++) + { + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).GetProperites(this); + break; + } + } + } + break; + } + } + } + + private void ResendUnacked() + { + int now = Environment.TickCount; + + lock (NeedAck) + { + foreach (Packet packet in NeedAck.Values) + { + if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Resending " + packet.Type.ToString() + " packet, " + + (now - packet.TickCount) + "ms have passed"); + + packet.Header.Resent = true; + OutPacket(packet); + } + } + } + } + + private void SendAcks() + { + lock (PendingAcks) + { + if (PendingAcks.Count > 0) + { + if (PendingAcks.Count > 250) + { + // FIXME: Handle the odd case where we have too many pending ACKs queued up + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Too many ACKs queued up!"); + return; + } + + //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sending PacketAck"); + + + int i = 0; + PacketAckPacket acks = new PacketAckPacket(); + acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; + + foreach (uint ack in PendingAcks.Values) + { + acks.Packets[i] = new PacketAckPacket.PacketsBlock(); + acks.Packets[i].ID = ack; + i++; + } + + acks.Header.Reliable = false; + OutPacket(acks); + + PendingAcks.Clear(); + } + } + } + + private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) + { + SendAcks(); + ResendUnacked(); + } + + protected virtual void ProcessOutPacket(Packet Pack) + { + + // Keep track of when this packet was sent out + Pack.TickCount = Environment.TickCount; + + if (!Pack.Header.Resent) + { + // Set the sequence number + lock (SequenceLock) + { + if (Sequence >= MAX_SEQUENCE) + Sequence = 1; + else + Sequence++; + Pack.Header.Sequence = Sequence; + } + + if (Pack.Header.Reliable) //DIRTY HACK + { + lock (NeedAck) + { + if (!NeedAck.ContainsKey(Pack.Header.Sequence)) + { + NeedAck.Add(Pack.Header.Sequence, Pack); + } + else + { + // Client.Log("Attempted to add a duplicate sequence number (" + + // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + + // packet.Type.ToString(), Helpers.LogLevel.Warning); + } + } + + // Don't append ACKs to resent packets, in case that's what was causing the + // delivery to fail + if (!Pack.Header.Resent) + { + // Append any ACKs that need to be sent out to this packet + lock (PendingAcks) + { + if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && + Pack.Type != PacketType.PacketAck && + Pack.Type != PacketType.LogoutRequest) + { + Pack.Header.AckList = new uint[PendingAcks.Count]; + int i = 0; + + foreach (uint ack in PendingAcks.Values) + { + Pack.Header.AckList[i] = ack; + i++; + } + + PendingAcks.Clear(); + Pack.Header.AppendedAcks = true; + } + } + } + } + } + + byte[] ZeroOutBuffer = new byte[4096]; + byte[] sendbuffer; + sendbuffer = Pack.ToBytes(); + + try + { + if (Pack.Header.Zerocoded) + { + int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); + m_application.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP); + } + else + { + m_application.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP); + } + } + catch (Exception) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); + ClientThread.Abort(); + } + + } + + public virtual void InPacket(Packet NewPack) + { + // Handle appended ACKs + if (NewPack.Header.AppendedAcks) + { + lock (NeedAck) + { + foreach (uint ack in NewPack.Header.AckList) + { + NeedAck.Remove(ack); + } + } + } + + // Handle PacketAck packets + if (NewPack.Type == PacketType.PacketAck) + { + PacketAckPacket ackPacket = (PacketAckPacket)NewPack; + + lock (NeedAck) + { + foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) + { + NeedAck.Remove(block.ID); + } + } + } + else if ((NewPack.Type == PacketType.StartPingCheck)) + { + //reply to pingcheck + libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack; + libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket(); + endPing.PingID.PingID = startPing.PingID.PingID; + OutPacket(endPing); + } + else + { + QueItem item = new QueItem(); + item.Packet = NewPack; + item.Incoming = true; + this.PacketQueue.Enqueue(item); + } + + } + + public virtual void OutPacket(Packet NewPack) + { + QueItem item = new QueItem(); + item.Packet = NewPack; + item.Incoming = false; + this.PacketQueue.Enqueue(item); + } + + protected virtual void ClientLoop() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ClientLoop() - Entered loop"); + while (true) + { + QueItem nextPacket = PacketQueue.Dequeue(); + if (nextPacket.Incoming) + { + //is a incoming packet + ProcessInPacket(nextPacket.Packet); + } + else + { + //is a out going packet + ProcessOutPacket(nextPacket.Packet); + } + } + } + + protected virtual void InitNewClient() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); + + m_world.AddViewerAgent(this); + world.Entity tempent = m_world.Entities[this.AgentID]; + + this.ClientAvatar = (world.Avatar)tempent; + } + + protected virtual void AuthUser() + { + AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); + if (!sessionInfo.Authorised) + { + //session/circuit not authorised + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); + ClientThread.Abort(); + } + else + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); + //session is authorised + this.AgentID = cirpack.CircuitCode.ID; + this.SessionID = cirpack.CircuitCode.SessionID; + this.CircuitCode = cirpack.CircuitCode.Code; + InitNewClient(); //shouldn't be called here as we might be a child agent and not want a full avatar + this.ClientAvatar.firstname = sessionInfo.LoginInfo.First; + this.ClientAvatar.lastname = sessionInfo.LoginInfo.Last; + if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) + { + this.SecureSessionID = sessionInfo.LoginInfo.SecureSession; + } + + // Create Inventory, currently only works for sandbox mode + if (m_sandboxMode) + { + AgentInventory inventory = null; + if (sessionInfo.LoginInfo.InventoryFolder != null) + { + inventory = this.CreateInventory(sessionInfo.LoginInfo.InventoryFolder); + if (sessionInfo.LoginInfo.BaseFolder != null) + { + if (!inventory.HasFolder(sessionInfo.LoginInfo.BaseFolder)) + { + m_inventoryCache.CreateNewInventoryFolder(this, sessionInfo.LoginInfo.BaseFolder); + } + this.newAssetFolder = sessionInfo.LoginInfo.BaseFolder; + AssetBase[] inventorySet = m_assetCache.CreateNewInventorySet(this.AgentID); + if (inventorySet != null) + { + for (int i = 0; i < inventorySet.Length; i++) + { + if (inventorySet[i] != null) + { + m_inventoryCache.AddNewInventoryItem(this, sessionInfo.LoginInfo.BaseFolder, inventorySet[i]); + } + } + } + } + } + } + + ClientLoop(); + } + } + #region Packet handlers + + protected virtual bool Logout(SimClient simClient, Packet packet) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); + //send reply to let the client logout + LogoutReplyPacket logReply = new LogoutReplyPacket(); + logReply.AgentData.AgentID = this.AgentID; + logReply.AgentData.SessionID = this.SessionID; + logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; + logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); + logReply.InventoryData[0].ItemID = LLUUID.Zero; + OutPacket(logReply); + //tell all clients to kill our object + KillObjectPacket kill = new KillObjectPacket(); + kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; + kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); + kill.ObjectData[0].ID = this.ClientAvatar.localid; + foreach (SimClient client in m_clientThreads.Values) + { + client.OutPacket(kill); + } + if (this.m_userServer != null) + { + this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer); + } + else + { + this.m_inventoryCache.ClientLeaving(this.AgentID, null); + } + + m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode); + /*lock (m_world.Entities) + { + m_world.Entities.Remove(this.AgentID); + }*/ + m_world.RemoveViewerAgent(this); + //need to do other cleaning up here too + m_clientThreads.Remove(this.CircuitCode); + m_application.RemoveClientCircuit(this.CircuitCode); + this.ClientThread.Abort(); + return true; + } + + protected bool AgentTextureCached(SimClient simclient, Packet packet) + { + // Console.WriteLine(packet.ToString()); + AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet; + AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); + cachedresp.AgentData.AgentID = this.AgentID; + cachedresp.AgentData.SessionID = this.SessionID; + cachedresp.AgentData.SerialNum = this.cachedtextureserial; + this.cachedtextureserial++; + cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; + for (int i = 0; i < chechedtex.WearableData.Length; i++) + { + cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); + cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex; + cachedresp.WearableData[i].TextureID = LLUUID.Zero; + cachedresp.WearableData[i].HostName = new byte[0]; + } + this.OutPacket(cachedresp); + return true; + } + + protected bool MultipleObjUpdate(SimClient simClient, Packet packet) + { + MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; + for (int i = 0; i < multipleupdate.ObjectData.Length; i++) + { + if (multipleupdate.ObjectData[i].Type == 9) //change position + { + libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).UpdatePosition(pos); + + } + } + //should update stored position of the prim + } + else if (multipleupdate.ObjectData[i].Type == 10)//rotation + { + libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID) + { + ent.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z); + ((OpenSim.world.Primitive)ent).UpdateFlag = true; + } + } + } + else if (multipleupdate.ObjectData[i].Type == 13)//scale + { + + libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).Scale = scale; + } + } + } + } + return true; + } + + #endregion + + private AgentInventory CreateInventory(LLUUID baseFolder) + { + AgentInventory inventory = null; + if (this.m_userServer != null) + { + // a user server is set so request the inventory from it + Console.WriteLine("getting inventory from user server"); + inventory = m_inventoryCache.FetchAgentsInventory(this.AgentID, m_userServer); + } + else + { + inventory = new AgentInventory(); + inventory.AgentID = this.AgentID; + inventory.CreateRootFolder(this.AgentID, false); + m_inventoryCache.AddNewAgentsInventory(inventory); + m_inventoryCache.CreateNewInventoryFolder(this, baseFolder); + } + return inventory; + } + + private void CreateInventoryItem(CreateInventoryItemPacket packet) + { + if (packet.InventoryBlock.Type == 7) + { + //lets try this out with creating a notecard + AssetBase asset = new AssetBase(); + asset.Name = Helpers.FieldToString(packet.InventoryBlock.Name); + asset.Description = Helpers.FieldToString(packet.InventoryBlock.Description); + asset.InvType = packet.InventoryBlock.InvType; + asset.Type = packet.InventoryBlock.Type; + asset.FullID = LLUUID.Random(); + asset.Data = new byte[0]; + + m_assetCache.AddAsset(asset); + m_inventoryCache.AddNewInventoryItem(this, packet.InventoryBlock.FolderID, asset); + } + } + } +} diff --git a/OpenSim.RegionServer/SimConsole.cs b/OpenSim.RegionServer/SimConsole.cs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/OpenSim.RegionServer/VersionInfo.cs b/OpenSim.RegionServer/VersionInfo.cs new file mode 100644 index 0000000000..39767df665 --- /dev/null +++ b/OpenSim.RegionServer/VersionInfo.cs @@ -0,0 +1,37 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; + +namespace OpenSim +{ + /// + /// + public class VersionInfo + { + public static string Version = "0.1, Build 1173843165, Revision 193:206M"; + } +} diff --git a/OpenSim.RegionServer/types/Mesh.cs b/OpenSim.RegionServer/types/Mesh.cs new file mode 100644 index 0000000000..3e00c9130b --- /dev/null +++ b/OpenSim.RegionServer/types/Mesh.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.types +{ + // TODO: This will need some performance tuning no doubt. + public class Mesh + { + public List mesh; + + public Mesh() + { + mesh = new List(); + } + + public void AddTri(Triangle tri) + { + mesh.Add(tri); + } + + public static Mesh operator +(Mesh a, Mesh b) + { + a.mesh.AddRange(b.mesh); + return a; + } + } +} diff --git a/OpenSim.RegionServer/types/Triangle.cs b/OpenSim.RegionServer/types/Triangle.cs new file mode 100644 index 0000000000..8dfea6e762 --- /dev/null +++ b/OpenSim.RegionServer/types/Triangle.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Axiom.MathLib; + +namespace OpenSim.types +{ + public class Triangle + { + Vector3 a; + Vector3 b; + Vector3 c; + + public Triangle() + { + a = new Vector3(); + b = new Vector3(); + c = new Vector3(); + } + + public Triangle(Vector3 A, Vector3 B, Vector3 C) + { + a = A; + b = B; + c = C; + } + } +} diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs new file mode 100644 index 0000000000..f507797002 --- /dev/null +++ b/OpenSim.RegionServer/world/Avatar.cs @@ -0,0 +1,351 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Physics.Manager; +using OpenSim.Framework.Inventory; +using Axiom.MathLib; + +namespace OpenSim.world +{ + public partial class Avatar : Entity + { + public static bool PhysicsEngineFlying = false; + public static AvatarAnimations Animations; + public string firstname; + public string lastname; + public SimClient ControllingClient; + public LLUUID current_anim; + public int anim_seq; + private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; + private bool updateflag = false; + private byte movementflag = 0; + private List forcesList = new List(); + private short _updateCount = 0; + private Axiom.MathLib.Quaternion bodyRot; + private LLObject.TextureEntry avatarAppearanceTexture = null; + private byte[] visualParams; + private AvatarWearable[] Wearables; + private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); + private ulong m_regionHandle; + private Dictionary m_clientThreads; + private string m_regionName; + private bool childShadowAvatar = false; + + public Avatar(SimClient TheClient, World world, string regionName, Dictionary clientThreads, ulong regionHandle) + { + m_world = world; + m_clientThreads = clientThreads; + m_regionName = regionName; + m_regionHandle = regionHandle; + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); + ControllingClient = TheClient; + localid = 8880000 + (this.m_world._localNumber++); + Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain.map[(int)Pos.X, (int)Pos.Y] + 1.0f); + visualParams = new byte[218]; + for (int i = 0; i < 218; i++) + { + visualParams[i] = 100; + } + Wearables = new AvatarWearable[13]; //should be 13 of these + for (int i = 0; i < 13; i++) + { + Wearables[i] = new AvatarWearable(); + } + this.Wearables[0].AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + this.Wearables[0].ItemID = LLUUID.Random(); + + this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); + + } + + public PhysicsActor PhysActor + { + set + { + this._physActor = value; + } + } + + public override void addForces() + { + lock (this.forcesList) + { + if (this.forcesList.Count > 0) + { + for (int i = 0; i < this.forcesList.Count; i++) + { + NewForce force = this.forcesList[i]; + PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z); + lock (m_world.LockPhysicsEngine) + { + this._physActor.Velocity = phyVector; + } + this.updateflag = true; + this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this + // but as we are setting the velocity (rather than using real forces) at the moment it is okay. + } + for (int i = 0; i < this.forcesList.Count; i++) + { + this.forcesList.RemoveAt(0); + } + } + } + } + + public static void SetupTemplate(string name) + { + int i = 0; + FileInfo fInfo = new FileInfo(name); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); + BinaryReader br = new BinaryReader(fStream); + byte[] data1 = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + + libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); + + System.Text.Encoding enc = System.Text.Encoding.ASCII; + libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); + pos.X = 100f; + objdata.ID = 8880000; + objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); + libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100f, 23f); + //objdata.FullID=user.AgentID; + byte[] pb = pos.GetBytes(); + Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); + + Avatar.AvatarTemplate = objdata; + } + + public void CompleteMovement(World RegionInfo) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); + AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); + mov.AgentData.SessionID = this.ControllingClient.SessionID; + mov.AgentData.AgentID = this.ControllingClient.AgentID; + mov.Data.RegionHandle = this.m_regionHandle; + // TODO - dynamicalise this stuff + mov.Data.Timestamp = 1172750370; + mov.Data.Position = new LLVector3(100f, 100f, 23f); + mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); + + ControllingClient.OutPacket(mov); + } + + public void HandleUpdate(AgentUpdatePacket pack) + { + if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_FLY) != 0) + { + if (this._physActor.Flying == false) + { + this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_FLY"]; + this.anim_seq = 1; + this.SendAnimPack(); + } + this._physActor.Flying = true; + + } + else + { + if (this._physActor.Flying == true) + { + this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"]; + this.anim_seq = 1; + this.SendAnimPack(); + } + this._physActor.Flying = false; + } + if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) != 0) + { + Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z); + if (((movementflag & 1) == 0) || (q != this.bodyRot)) + { + + if (((movementflag & 1) == 0) && (!this._physActor.Flying)) + { + this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_WALK"]; + this.anim_seq = 1; + this.SendAnimPack(); + } + + + //we should add a new force to the list + // but for now we will deal with velocities + NewForce newVelocity = new NewForce(); + Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0); + Axiom.MathLib.Vector3 direc = q * v3; + direc.Normalize(); + + //work out velocity for sim physics system + direc = direc * ((0.03f) * 128f); + if (this._physActor.Flying) + direc *= 2; + + newVelocity.X = direc.x; + newVelocity.Y = direc.y; + newVelocity.Z = direc.z; + this.forcesList.Add(newVelocity); + movementflag = 1; + this.bodyRot = q; + } + } + else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_POS) != 0) && (PhysicsEngineFlying)) + { + if (((movementflag & 2) == 0) && this._physActor.Flying) + { + //we should add a new force to the list + // but for now we will deal with velocities + NewForce newVelocity = new NewForce(); + Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, 1); + Axiom.MathLib.Vector3 direc = v3; + direc.Normalize(); + + //work out velocity for sim physics system + direc = direc * ((0.03f) * 128f * 2); + newVelocity.X = direc.x; + newVelocity.Y = direc.y; + newVelocity.Z = direc.z; + this.forcesList.Add(newVelocity); + movementflag = 2; + } + } + else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_NEG) != 0) && (PhysicsEngineFlying)) + { + if (((movementflag & 4) == 0) && this._physActor.Flying) + { + //we should add a new force to the list + // but for now we will deal with velocities + NewForce newVelocity = new NewForce(); + Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1); + //Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z); + Axiom.MathLib.Vector3 direc = v3; + direc.Normalize(); + + //work out velocity for sim physics system + direc = direc * ((0.03f) * 128f * 2); + newVelocity.X = direc.x; + newVelocity.Y = direc.y; + newVelocity.Z = direc.z; + this.forcesList.Add(newVelocity); + movementflag = 4; + } + } + else if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_NEG) != 0) + { + Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z); + if (((movementflag & 8) == 0) || (q != this.bodyRot)) + { + //we should add a new force to the list + // but for now we will deal with velocities + NewForce newVelocity = new NewForce(); + Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0); + Axiom.MathLib.Vector3 direc = q * v3; + direc.Normalize(); + + //work out velocity for sim physics system + direc = direc * ((0.03f) * 128f); + if (this._physActor.Flying) + direc *= 2; + + newVelocity.X = direc.x; + newVelocity.Y = direc.y; + newVelocity.Z = direc.z; + this.forcesList.Add(newVelocity); + movementflag = 8; + this.bodyRot = q; + } + } + else + { + if (movementflag == 16) + { + movementflag = 0; + } + if ((movementflag) != 0) + { + NewForce newVelocity = new NewForce(); + newVelocity.X = 0; + newVelocity.Y = 0; + newVelocity.Z = 0; + this.forcesList.Add(newVelocity); + movementflag = 0; + // We're standing still, so make it show! + if (this._physActor.Flying == false) + { + this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"]; + this.anim_seq = 1; + this.SendAnimPack(); + } + this.movementflag = 16; + + } + } + } + + //really really should be moved somewhere else + public void SendRegionHandshake(World RegionInfo) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet"); + System.Text.Encoding _enc = System.Text.Encoding.ASCII; + RegionHandshakePacket handshake = new RegionHandshakePacket(); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details"); + handshake.RegionInfo.BillableFactor = 0; + handshake.RegionInfo.IsEstateManager = false; + handshake.RegionInfo.TerrainHeightRange00 = 60; + handshake.RegionInfo.TerrainHeightRange01 = 60; + handshake.RegionInfo.TerrainHeightRange10 = 60; + handshake.RegionInfo.TerrainHeightRange11 = 60; + handshake.RegionInfo.TerrainStartHeight00 = 10; + handshake.RegionInfo.TerrainStartHeight01 = 10; + handshake.RegionInfo.TerrainStartHeight10 = 10; + handshake.RegionInfo.TerrainStartHeight11 = 10; + handshake.RegionInfo.SimAccess = 13; + handshake.RegionInfo.WaterHeight = 20; + handshake.RegionInfo.RegionFlags = 72458694 -32; + handshake.RegionInfo.SimName = _enc.GetBytes(m_regionName + "\0"); + handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); + handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); + handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); + handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); + handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); + handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000"); + handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000"); + handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000"); + handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000"); + handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet"); + this.ControllingClient.OutPacket(handshake); + } + + public static void LoadAnims() + { + Avatar.Animations = new AvatarAnimations(); + Avatar.Animations.LoadAnims(); + } + + public override void LandRenegerated() + { + Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain.map[(int)Pos.X, (int)Pos.Y] + 50.0f); + } + } + + public class NewForce + { + public float X; + public float Y; + public float Z; + + public NewForce() + { + + } + } + +} diff --git a/OpenSim.RegionServer/world/AvatarAnimations.cs b/OpenSim.RegionServer/world/AvatarAnimations.cs new file mode 100644 index 0000000000..36c4c7ef18 --- /dev/null +++ b/OpenSim.RegionServer/world/AvatarAnimations.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.world +{ + public class AvatarAnimations + { + + public Dictionary AnimsLLUUID = new Dictionary(); + public Dictionary AnimsNames = new Dictionary(); + + public AvatarAnimations() + { + } + + public void LoadAnims() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:LoadAnims() - Loading avatar animations"); + AnimsLLUUID.Add("ANIM_AGENT_AFRAID", new LLUUID("6b61c8e8-4747-0d75-12d7-e49ff207a4ca")); + AnimsLLUUID.Add("ANIM_AGENT_AIM_BAZOOKA_R", new LLUUID("b5b4a67d-0aee-30d2-72cd-77b333e932ef")); + AnimsLLUUID.Add("ANIM_AGENT_AIM_BOW_L", new LLUUID("46bb4359-de38-4ed8-6a22-f1f52fe8f506")); + AnimsLLUUID.Add("ANIM_AGENT_AIM_HANDGUN_R", new LLUUID("3147d815-6338-b932-f011-16b56d9ac18b")); + AnimsLLUUID.Add("ANIM_AGENT_AIM_RIFLE_R", new LLUUID("ea633413-8006-180a-c3ba-96dd1d756720")); + AnimsLLUUID.Add("ANIM_AGENT_ANGRY", new LLUUID("5747a48e-073e-c331-f6f3-7c2149613d3e")); + AnimsLLUUID.Add("ANIM_AGENT_AWAY", new LLUUID("fd037134-85d4-f241-72c6-4f42164fedee")); + AnimsLLUUID.Add("ANIM_AGENT_BACKFLIP", new LLUUID("c4ca6188-9127-4f31-0158-23c4e2f93304")); + AnimsLLUUID.Add("ANIM_AGENT_BELLY_LAUGH", new LLUUID("18b3a4b5-b463-bd48-e4b6-71eaac76c515")); + AnimsLLUUID.Add("ANIM_AGENT_BLOW_KISS", new LLUUID("db84829b-462c-ee83-1e27-9bbee66bd624")); + AnimsLLUUID.Add("ANIM_AGENT_BORED", new LLUUID("b906c4ba-703b-1940-32a3-0c7f7d791510")); + AnimsLLUUID.Add("ANIM_AGENT_BOW", new LLUUID("82e99230-c906-1403-4d9c-3889dd98daba")); + AnimsLLUUID.Add("ANIM_AGENT_BRUSH", new LLUUID("349a3801-54f9-bf2c-3bd0-1ac89772af01")); + AnimsLLUUID.Add("ANIM_AGENT_BUSY", new LLUUID("efcf670c-2d18-8128-973a-034ebc806b67")); + AnimsLLUUID.Add("ANIM_AGENT_CLAP", new LLUUID("9b0c1c4e-8ac7-7969-1494-28c874c4f668")); + AnimsLLUUID.Add("ANIM_AGENT_COURTBOW", new LLUUID("9ba1c942-08be-e43a-fb29-16ad440efc50")); + AnimsLLUUID.Add("ANIM_AGENT_CROUCH", new LLUUID("201f3fdf-cb1f-dbec-201f-7333e328ae7c")); + AnimsLLUUID.Add("ANIM_AGENT_CROUCHWALK", new LLUUID("47f5f6fb-22e5-ae44-f871-73aaaf4a6022")); + AnimsLLUUID.Add("ANIM_AGENT_CRY", new LLUUID("92624d3e-1068-f1aa-a5ec-8244585193ed")); + AnimsLLUUID.Add("ANIM_AGENT_CUSTOMIZE", new LLUUID("038fcec9-5ebd-8a8e-0e2e-6e71a0a1ac53")); + AnimsLLUUID.Add("ANIM_AGENT_CUSTOMIZE_DONE", new LLUUID("6883a61a-b27b-5914-a61e-dda118a9ee2c")); + AnimsLLUUID.Add("ANIM_AGENT_DANCE1", new LLUUID("b68a3d7c-de9e-fc87-eec8-543d787e5b0d")); + AnimsLLUUID.Add("ANIM_AGENT_DANCE2", new LLUUID("928cae18-e31d-76fd-9cc9-2f55160ff818")); + AnimsLLUUID.Add("ANIM_AGENT_DANCE3", new LLUUID("30047778-10ea-1af7-6881-4db7a3a5a114")); + AnimsLLUUID.Add("ANIM_AGENT_DANCE4", new LLUUID("951469f4-c7b2-c818-9dee-ad7eea8c30b7")); + AnimsLLUUID.Add("ANIM_AGENT_DANCE5", new LLUUID("4bd69a1d-1114-a0b4-625f-84e0a5237155")); + AnimsLLUUID.Add("ANIM_AGENT_DANCE6", new LLUUID("cd28b69b-9c95-bb78-3f94-8d605ff1bb12")); + AnimsLLUUID.Add("ANIM_AGENT_DANCE7", new LLUUID("a54d8ee2-28bb-80a9-7f0c-7afbbe24a5d6")); + AnimsLLUUID.Add("ANIM_AGENT_DANCE8", new LLUUID("b0dc417c-1f11-af36-2e80-7e7489fa7cdc")); + AnimsLLUUID.Add("ANIM_AGENT_DEAD", new LLUUID("57abaae6-1d17-7b1b-5f98-6d11a6411276")); + AnimsLLUUID.Add("ANIM_AGENT_DRINK", new LLUUID("0f86e355-dd31-a61c-fdb0-3a96b9aad05f")); + AnimsLLUUID.Add("ANIM_AGENT_EMBARRASSED", new LLUUID("514af488-9051-044a-b3fc-d4dbf76377c6")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_AFRAID", new LLUUID("aa2df84d-cf8f-7218-527b-424a52de766e")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_ANGER", new LLUUID("1a03b575-9634-b62a-5767-3a679e81f4de")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_BORED", new LLUUID("214aa6c1-ba6a-4578-f27c-ce7688f61d0d")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_CRY", new LLUUID("d535471b-85bf-3b4d-a542-93bea4f59d33")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_DISDAIN", new LLUUID("d4416ff1-09d3-300f-4183-1b68a19b9fc1")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_EMBARRASSED", new LLUUID("0b8c8211-d78c-33e8-fa28-c51a9594e424")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_FROWN", new LLUUID("fee3df48-fa3d-1015-1e26-a205810e3001")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_KISS", new LLUUID("1e8d90cc-a84e-e135-884c-7c82c8b03a14")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_LAUGH", new LLUUID("62570842-0950-96f8-341c-809e65110823")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_OPEN_MOUTH", new LLUUID("d63bc1f9-fc81-9625-a0c6-007176d82eb7")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_REPULSED", new LLUUID("f76cda94-41d4-a229-2872-e0296e58afe1")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SAD", new LLUUID("eb6ebfb2-a4b3-a19c-d388-4dd5c03823f7")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SHRUG", new LLUUID("a351b1bc-cc94-aac2-7bea-a7e6ebad15ef")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SMILE", new LLUUID("b7c7c833-e3d3-c4e3-9fc0-131237446312")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SURPRISE", new LLUUID("728646d9-cc79-08b2-32d6-937f0a835c24")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_TONGUE_OUT", new LLUUID("835965c6-7f2f-bda2-5deb-2478737f91bf")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_TOOTHSMILE", new LLUUID("b92ec1a5-e7ce-a76b-2b05-bcdb9311417e")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_WINK", new LLUUID("da020525-4d94-59d6-23d7-81fdebf33148")); + AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_WORRY", new LLUUID("9c05e5c7-6f07-6ca4-ed5a-b230390c3950")); + AnimsLLUUID.Add("ANIM_AGENT_FALLDOWN", new LLUUID("666307d9-a860-572d-6fd4-c3ab8865c094")); + AnimsLLUUID.Add("ANIM_AGENT_FEMALE_WALK", new LLUUID("f5fc7433-043d-e819-8298-f519a119b688")); + AnimsLLUUID.Add("ANIM_AGENT_FINGER_WAG", new LLUUID("c1bc7f36-3ba0-d844-f93c-93be945d644f")); + AnimsLLUUID.Add("ANIM_AGENT_FIST_PUMP", new LLUUID("7db00ccd-f380-f3ee-439d-61968ec69c8a")); + AnimsLLUUID.Add("ANIM_AGENT_FLY", new LLUUID("aec4610c-757f-bc4e-c092-c6e9caf18daf")); + AnimsLLUUID.Add("ANIM_AGENT_FLYSLOW", new LLUUID("2b5a38b2-5e00-3a97-a495-4c826bc443e6")); + AnimsLLUUID.Add("ANIM_AGENT_HELLO", new LLUUID("9b29cd61-c45b-5689-ded2-91756b8d76a9")); + AnimsLLUUID.Add("ANIM_AGENT_HOLD_BAZOOKA_R", new LLUUID("ef62d355-c815-4816-2474-b1acc21094a6")); + AnimsLLUUID.Add("ANIM_AGENT_HOLD_BOW_L", new LLUUID("8b102617-bcba-037b-86c1-b76219f90c88")); + AnimsLLUUID.Add("ANIM_AGENT_HOLD_HANDGUN_R", new LLUUID("efdc1727-8b8a-c800-4077-975fc27ee2f2")); + AnimsLLUUID.Add("ANIM_AGENT_HOLD_RIFLE_R", new LLUUID("3d94bad0-c55b-7dcc-8763-033c59405d33")); + AnimsLLUUID.Add("ANIM_AGENT_HOLD_THROW_R", new LLUUID("7570c7b5-1f22-56dd-56ef-a9168241bbb6")); + AnimsLLUUID.Add("ANIM_AGENT_HOVER", new LLUUID("4ae8016b-31b9-03bb-c401-b1ea941db41d")); + AnimsLLUUID.Add("ANIM_AGENT_HOVER_DOWN", new LLUUID("20f063ea-8306-2562-0b07-5c853b37b31e")); + AnimsLLUUID.Add("ANIM_AGENT_HOVER_UP", new LLUUID("62c5de58-cb33-5743-3d07-9e4cd4352864")); + AnimsLLUUID.Add("ANIM_AGENT_IMPATIENT", new LLUUID("5ea3991f-c293-392e-6860-91dfa01278a3")); + AnimsLLUUID.Add("ANIM_AGENT_JUMP", new LLUUID("2305bd75-1ca9-b03b-1faa-b176b8a8c49e")); + AnimsLLUUID.Add("ANIM_AGENT_JUMP_FOR_JOY", new LLUUID("709ea28e-1573-c023-8bf8-520c8bc637fa")); + AnimsLLUUID.Add("ANIM_AGENT_KISS_MY_BUTT", new LLUUID("19999406-3a3a-d58c-a2ac-d72e555dcf51")); + AnimsLLUUID.Add("ANIM_AGENT_LAND", new LLUUID("7a17b059-12b2-41b1-570a-186368b6aa6f")); + AnimsLLUUID.Add("ANIM_AGENT_LAUGH_SHORT", new LLUUID("ca5b3f14-3194-7a2b-c894-aa699b718d1f")); + AnimsLLUUID.Add("ANIM_AGENT_MEDIUM_LAND", new LLUUID("f4f00d6e-b9fe-9292-f4cb-0ae06ea58d57")); + AnimsLLUUID.Add("ANIM_AGENT_MOTORCYCLE_SIT", new LLUUID("08464f78-3a8e-2944-cba5-0c94aff3af29")); + AnimsLLUUID.Add("ANIM_AGENT_MUSCLE_BEACH", new LLUUID("315c3a41-a5f3-0ba4-27da-f893f769e69b")); + AnimsLLUUID.Add("ANIM_AGENT_NO", new LLUUID("5a977ed9-7f72-44e9-4c4c-6e913df8ae74")); + AnimsLLUUID.Add("ANIM_AGENT_NO_UNHAPPY", new LLUUID("d83fa0e5-97ed-7eb2-e798-7bd006215cb4")); + AnimsLLUUID.Add("ANIM_AGENT_NYAH_NYAH", new LLUUID("f061723d-0a18-754f-66ee-29a44795a32f")); + AnimsLLUUID.Add("ANIM_AGENT_ONETWO_PUNCH", new LLUUID("eefc79be-daae-a239-8c04-890f5d23654a")); + AnimsLLUUID.Add("ANIM_AGENT_PEACE", new LLUUID("b312b10e-65ab-a0a4-8b3c-1326ea8e3ed9")); + AnimsLLUUID.Add("ANIM_AGENT_POINT_ME", new LLUUID("17c024cc-eef2-f6a0-3527-9869876d7752")); + AnimsLLUUID.Add("ANIM_AGENT_POINT_YOU", new LLUUID("ec952cca-61ef-aa3b-2789-4d1344f016de")); + AnimsLLUUID.Add("ANIM_AGENT_PRE_JUMP", new LLUUID("7a4e87fe-de39-6fcb-6223-024b00893244")); + AnimsLLUUID.Add("ANIM_AGENT_PUNCH_LEFT", new LLUUID("f3300ad9-3462-1d07-2044-0fef80062da0")); + AnimsLLUUID.Add("ANIM_AGENT_PUNCH_RIGHT", new LLUUID("c8e42d32-7310-6906-c903-cab5d4a34656")); + AnimsLLUUID.Add("ANIM_AGENT_REPULSED", new LLUUID("36f81a92-f076-5893-dc4b-7c3795e487cf")); + AnimsLLUUID.Add("ANIM_AGENT_ROUNDHOUSE_KICK", new LLUUID("49aea43b-5ac3-8a44-b595-96100af0beda")); + AnimsLLUUID.Add("ANIM_AGENT_RPS_COUNTDOWN", new LLUUID("35db4f7e-28c2-6679-cea9-3ee108f7fc7f")); + AnimsLLUUID.Add("ANIM_AGENT_RPS_PAPER", new LLUUID("0836b67f-7f7b-f37b-c00a-460dc1521f5a")); + AnimsLLUUID.Add("ANIM_AGENT_RPS_ROCK", new LLUUID("42dd95d5-0bc6-6392-f650-777304946c0f")); + AnimsLLUUID.Add("ANIM_AGENT_RPS_SCISSORS", new LLUUID("16803a9f-5140-e042-4d7b-d28ba247c325")); + AnimsLLUUID.Add("ANIM_AGENT_RUN", new LLUUID("05ddbff8-aaa9-92a1-2b74-8fe77a29b445")); + AnimsLLUUID.Add("ANIM_AGENT_SAD", new LLUUID("0eb702e2-cc5a-9a88-56a5-661a55c0676a")); + AnimsLLUUID.Add("ANIM_AGENT_SALUTE", new LLUUID("cd7668a6-7011-d7e2-ead8-fc69eff1a104")); + AnimsLLUUID.Add("ANIM_AGENT_SHOOT_BOW_L", new LLUUID("e04d450d-fdb5-0432-fd68-818aaf5935f8")); + AnimsLLUUID.Add("ANIM_AGENT_SHOUT", new LLUUID("6bd01860-4ebd-127a-bb3d-d1427e8e0c42")); + AnimsLLUUID.Add("ANIM_AGENT_SHRUG", new LLUUID("70ea714f-3a97-d742-1b01-590a8fcd1db5")); + AnimsLLUUID.Add("ANIM_AGENT_SIT", new LLUUID("1a5fe8ac-a804-8a5d-7cbd-56bd83184568")); + AnimsLLUUID.Add("ANIM_AGENT_SIT_FEMALE", new LLUUID("b1709c8d-ecd3-54a1-4f28-d55ac0840782")); + AnimsLLUUID.Add("ANIM_AGENT_SIT_GENERIC", new LLUUID("245f3c54-f1c0-bf2e-811f-46d8eeb386e7")); + AnimsLLUUID.Add("ANIM_AGENT_SIT_GROUND", new LLUUID("1c7600d6-661f-b87b-efe2-d7421eb93c86")); + AnimsLLUUID.Add("ANIM_AGENT_SIT_GROUND_CONSTRAINED", new LLUUID("1a2bd58e-87ff-0df8-0b4c-53e047b0bb6e")); + AnimsLLUUID.Add("ANIM_AGENT_SIT_TO_STAND", new LLUUID("a8dee56f-2eae-9e7a-05a2-6fb92b97e21e")); + AnimsLLUUID.Add("ANIM_AGENT_SLEEP", new LLUUID("f2bed5f9-9d44-39af-b0cd-257b2a17fe40")); + AnimsLLUUID.Add("ANIM_AGENT_SMOKE_IDLE", new LLUUID("d2f2ee58-8ad1-06c9-d8d3-3827ba31567a")); + AnimsLLUUID.Add("ANIM_AGENT_SMOKE_INHALE", new LLUUID("6802d553-49da-0778-9f85-1599a2266526")); + AnimsLLUUID.Add("ANIM_AGENT_SMOKE_THROW_DOWN", new LLUUID("0a9fb970-8b44-9114-d3a9-bf69cfe804d6")); + AnimsLLUUID.Add("ANIM_AGENT_SNAPSHOT", new LLUUID("eae8905b-271a-99e2-4c0e-31106afd100c")); + AnimsLLUUID.Add("ANIM_AGENT_STAND", new LLUUID("2408fe9e-df1d-1d7d-f4ff-1384fa7b350f")); + AnimsLLUUID.Add("ANIM_AGENT_STANDUP", new LLUUID("3da1d753-028a-5446-24f3-9c9b856d9422")); + AnimsLLUUID.Add("ANIM_AGENT_STAND_1", new LLUUID("15468e00-3400-bb66-cecc-646d7c14458e")); + AnimsLLUUID.Add("ANIM_AGENT_STAND_2", new LLUUID("370f3a20-6ca6-9971-848c-9a01bc42ae3c")); + AnimsLLUUID.Add("ANIM_AGENT_STAND_3", new LLUUID("42b46214-4b44-79ae-deb8-0df61424ff4b")); + AnimsLLUUID.Add("ANIM_AGENT_STAND_4", new LLUUID("f22fed8b-a5ed-2c93-64d5-bdd8b93c889f")); + AnimsLLUUID.Add("ANIM_AGENT_STRETCH", new LLUUID("80700431-74ec-a008-14f8-77575e73693f")); + AnimsLLUUID.Add("ANIM_AGENT_STRIDE", new LLUUID("1cb562b0-ba21-2202-efb3-30f82cdf9595")); + AnimsLLUUID.Add("ANIM_AGENT_SURF", new LLUUID("41426836-7437-7e89-025d-0aa4d10f1d69")); + AnimsLLUUID.Add("ANIM_AGENT_SURPRISE", new LLUUID("313b9881-4302-73c0-c7d0-0e7a36b6c224")); + AnimsLLUUID.Add("ANIM_AGENT_SWORD_STRIKE", new LLUUID("85428680-6bf9-3e64-b489-6f81087c24bd")); + AnimsLLUUID.Add("ANIM_AGENT_TALK", new LLUUID("5c682a95-6da4-a463-0bf6-0f5b7be129d1")); + AnimsLLUUID.Add("ANIM_AGENT_TANTRUM", new LLUUID("11000694-3f41-adc2-606b-eee1d66f3724")); + AnimsLLUUID.Add("ANIM_AGENT_THROW_R", new LLUUID("aa134404-7dac-7aca-2cba-435f9db875ca")); + AnimsLLUUID.Add("ANIM_AGENT_TRYON_SHIRT", new LLUUID("83ff59fe-2346-f236-9009-4e3608af64c1")); + AnimsLLUUID.Add("ANIM_AGENT_TURNLEFT", new LLUUID("56e0ba0d-4a9f-7f27-6117-32f2ebbf6135")); + AnimsLLUUID.Add("ANIM_AGENT_TURNRIGHT", new LLUUID("2d6daa51-3192-6794-8e2e-a15f8338ec30")); + AnimsLLUUID.Add("ANIM_AGENT_TYPE", new LLUUID("c541c47f-e0c0-058b-ad1a-d6ae3a4584d9")); + AnimsLLUUID.Add("ANIM_AGENT_WALK", new LLUUID("6ed24bd8-91aa-4b12-ccc7-c97c857ab4e0")); + AnimsLLUUID.Add("ANIM_AGENT_WHISPER", new LLUUID("7693f268-06c7-ea71-fa21-2b30d6533f8f")); + AnimsLLUUID.Add("ANIM_AGENT_WHISTLE", new LLUUID("b1ed7982-c68e-a982-7561-52a88a5298c0")); + AnimsLLUUID.Add("ANIM_AGENT_WINK", new LLUUID("869ecdad-a44b-671e-3266-56aef2e3ac2e")); + AnimsLLUUID.Add("ANIM_AGENT_WINK_HOLLYWOOD", new LLUUID("c0c4030f-c02b-49de-24ba-2331f43fe41c")); + AnimsLLUUID.Add("ANIM_AGENT_WORRY", new LLUUID("9f496bd2-589a-709f-16cc-69bf7df1d36c")); + AnimsLLUUID.Add("ANIM_AGENT_YES", new LLUUID("15dd911d-be82-2856-26db-27659b142875")); + AnimsLLUUID.Add("ANIM_AGENT_YES_HAPPY", new LLUUID("b8c8b2a3-9008-1771-3bfc-90924955ab2d")); + AnimsLLUUID.Add("ANIM_AGENT_YOGA_FLOAT", new LLUUID("42ecd00b-9947-a97c-400a-bbc9174c7aeb")); + + foreach (KeyValuePair kp in OpenSim.world.Avatar.Animations.AnimsLLUUID) + { + AnimsNames.Add(kp.Value, kp.Key); + } + } + } +} diff --git a/OpenSim.RegionServer/world/AvatarClient.cs b/OpenSim.RegionServer/world/AvatarClient.cs new file mode 100644 index 0000000000..7656a89002 --- /dev/null +++ b/OpenSim.RegionServer/world/AvatarClient.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife.Packets; + +namespace OpenSim.world +{ + partial class Avatar + { + private List updateList = new List(); + private List interestList = new List(); + + public void SendPacketToViewer(Packet packet) + { + this.ControllingClient.OutPacket(packet); + } + + public void AddTerseUpdateToViewersList(ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock) + { + + } + + public void SendUpdateListToViewer() + { + + } + + private void UpdateInterestList() + { + + } + } +} diff --git a/OpenSim.RegionServer/world/AvatarUpdate.cs b/OpenSim.RegionServer/world/AvatarUpdate.cs new file mode 100644 index 0000000000..d315de799d --- /dev/null +++ b/OpenSim.RegionServer/world/AvatarUpdate.cs @@ -0,0 +1,301 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace OpenSim.world +{ + partial class Avatar + { + public override void update() + { + libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z); + if (this.updateflag) + { + //need to send movement info + //so create the improvedterseobjectupdate packet + //use CreateTerseBlock() + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = m_regionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = terseBlock; + foreach (SimClient client in m_clientThreads.Values) + { + client.OutPacket(terse); + } + + updateflag = false; + //this._updateCount = 0; + } + else + { + + if ((pos2 != this.positionLastFrame) || (this.movementflag == 16)) + { + _updateCount++; + if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0)) + { + //It has been a while since last update was sent so lets send one. + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = m_regionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = terseBlock; + foreach (SimClient client in m_clientThreads.Values) + { + client.OutPacket(terse); + } + _updateCount = 0; + } + + if (this.movementflag == 16) + { + movementflag = 0; + } + } + + } + this.positionLastFrame = pos2; + } + + public ObjectUpdatePacket CreateUpdatePacket() + { + System.Text.Encoding _enc = System.Text.Encoding.ASCII; + //send a objectupdate packet with information about the clients avatar + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = m_regionHandle; + objupdate.RegionData.TimeDilation = 64096; + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + + objupdate.ObjectData[0] = AvatarTemplate; + //give this avatar object a local id and assign the user a name + objupdate.ObjectData[0].ID = this.localid; + objupdate.ObjectData[0].FullID = ControllingClient.AgentID; + objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); + + libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z); + + byte[] pb = pos2.GetBytes(); + + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); + return objupdate; + } + + public void SendInitialPosition() + { + System.Text.Encoding _enc = System.Text.Encoding.ASCII; + //send a objectupdate packet with information about the clients avatar + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = m_regionHandle; + objupdate.RegionData.TimeDilation = 64096; + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + + objupdate.ObjectData[0] = AvatarTemplate; + //give this avatar object a local id and assign the user a name + objupdate.ObjectData[0].ID = this.localid; + this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID; + objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); + libsecondlife.LLVector3 pos2 = new LLVector3((float)this.Pos.X, (float)this.Pos.Y, (float)this.Pos.Z); + byte[] pb = pos2.GetBytes(); + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); + m_world._localNumber++; + + foreach (SimClient client in m_clientThreads.Values) + { + client.OutPacket(objupdate); + if (client.AgentID != ControllingClient.AgentID) + { + //the below line is already in Simclient.cs at line number 245 , directly below the call to this method + //if there is a problem/bug with that , then lets fix it there rather than duplicating it here + //client.ClientAvatar.SendAppearanceToOtherAgent(this.ControllingClient); + + SendAppearanceToOtherAgent(client); + } + } + } + + public void SendInitialAppearance() + { + AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); + aw.AgentData.AgentID = this.ControllingClient.AgentID; + aw.AgentData.SerialNum = 0; + aw.AgentData.SessionID = ControllingClient.SessionID; + + aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; + AgentWearablesUpdatePacket.WearableDataBlock awb; + for (int i = 0; i < 13; i++) + { + awb = new AgentWearablesUpdatePacket.WearableDataBlock(); + awb.WearableType = (byte)i; + awb.AssetID = this.Wearables[i].AssetID; + awb.ItemID = this.Wearables[i].ItemID; + aw.WearableData[i] = awb; + } + + ControllingClient.OutPacket(aw); + } + + public void SendAppearanceToOtherAgent(SimClient userInfo) + { + AvatarAppearancePacket avp = new AvatarAppearancePacket(); + avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; + avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes(); + + //a wearable update packets should only be sent about the viewers/agents own avatar not for other avatars + //but it seems that the following code only created the packets and never actually sent them anyway + /*AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); + aw.AgentData.AgentID = this.ControllingClient.AgentID; + aw.AgentData.SessionID = userInfo.SessionID; + aw.AgentData.SerialNum = 0; //removed the use of a random number as a random number could be less than the last number, should have a counter variable for this + + aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; + AgentWearablesUpdatePacket.WearableDataBlock awb; + for (int i = 0; i < 13; i++) + { + awb = new AgentWearablesUpdatePacket.WearableDataBlock(); + awb.WearableType = (byte)i; + awb.AssetID = this.Wearables[i].AssetID; + awb.ItemID = this.Wearables[i].ItemID; + aw.WearableData[i] = awb; + }*/ + + AvatarAppearancePacket.VisualParamBlock avblock = null; + for (int i = 0; i < 218; i++) + { + avblock = new AvatarAppearancePacket.VisualParamBlock(); + avblock.ParamValue = visualParams[i]; + avp.VisualParam[i] = avblock; + } + + avp.Sender.IsTrial = false; + avp.Sender.ID = ControllingClient.AgentID; + userInfo.OutPacket(avp); + } + + public void SetAppearance(AgentSetAppearancePacket appear) + { + LLObject.TextureEntry tex = new LLObject.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); + this.avatarAppearanceTexture = tex; + for (int i = 0; i < appear.VisualParam.Length; i++) + { + this.visualParams[i] = appear.VisualParam[i].ParamValue; + } + foreach (SimClient client in m_clientThreads.Values) + { + if (client.AgentID != ControllingClient.AgentID) + { + SendAppearanceToOtherAgent(client); + } + } + } + + public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() + { + byte[] bytes = new byte[60]; + int i = 0; + ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); + + dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry; + libsecondlife.LLVector3 pos2 = new LLVector3(0, 0, 0); + lock (m_world.LockPhysicsEngine) + { + pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z); + } + + uint ID = this.localid; + + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = 0; + bytes[i++] = 1; + i += 14; + bytes[i++] = 128; + bytes[i++] = 63; + + byte[] pb = pos2.GetBytes(); + Array.Copy(pb, 0, bytes, i, pb.Length); + i += 12; + ushort InternVelocityX; + ushort InternVelocityY; + ushort InternVelocityZ; + Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(0, 0, 0); + lock (m_world.LockPhysicsEngine) + { + internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z); + } + internDirec = internDirec / 128.0f; + internDirec.x += 1; + internDirec.y += 1; + internDirec.z += 1; + + InternVelocityX = (ushort)(32768 * internDirec.x); + InternVelocityY = (ushort)(32768 * internDirec.y); + InternVelocityZ = (ushort)(32768 * internDirec.z); + + ushort ac = 32767; + bytes[i++] = (byte)(InternVelocityX % 256); + bytes[i++] = (byte)((InternVelocityX >> 8) % 256); + bytes[i++] = (byte)(InternVelocityY % 256); + bytes[i++] = (byte)((InternVelocityY >> 8) % 256); + bytes[i++] = (byte)(InternVelocityZ % 256); + bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); + + //accel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + //rot + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + //rotation vel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + dat.Data = bytes; + return (dat); + } + + // Sends animation update + public void SendAnimPack() + { + AvatarAnimationPacket ani = new AvatarAnimationPacket(); + ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; + ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); + ani.AnimationSourceList[0].ObjectID = ControllingClient.AgentID; + ani.Sender = new AvatarAnimationPacket.SenderBlock(); + ani.Sender.ID = ControllingClient.AgentID; + ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; + ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); + ani.AnimationList[0].AnimID = this.current_anim; + ani.AnimationList[0].AnimSequenceID = this.anim_seq; + + //ControllingClient.OutPacket(ani); + foreach (SimClient client in m_clientThreads.Values) + { + client.OutPacket(ani); + } + } + + } +} diff --git a/OpenSim.RegionServer/world/Entity.cs b/OpenSim.RegionServer/world/Entity.cs new file mode 100644 index 0000000000..96e039aae6 --- /dev/null +++ b/OpenSim.RegionServer/world/Entity.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Axiom.MathLib; +using OpenSim.Physics.Manager; +using OpenSim.types; +using libsecondlife; +using OpenSim.RegionServer.world.scripting; + +namespace OpenSim.world +{ + public abstract class Entity : IScriptReadonlyEntity + { + public libsecondlife.LLUUID uuid; + public uint localid; + public LLVector3 velocity; + public Quaternion rotation; + protected List children; + + protected string m_name; + public virtual string Name + { + get { return m_name; } + } + + protected LLVector3 m_pos; + protected PhysicsActor _physActor; + protected World m_world; + + public virtual LLVector3 Pos + { + get + { + if (this._physActor != null) + { + m_pos.X = _physActor.Position.X; + m_pos.Y = _physActor.Position.Y; + m_pos.Z = _physActor.Position.Z; + } + + return m_pos; + } + set + { + if (this._physActor != null) + { + try + { + lock (this.m_world.LockPhysicsEngine) + { + + this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z); + } + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + + m_pos = value; + } + } + + /// + /// Creates a new Entity (should not occur on it's own) + /// + public Entity() + { + uuid = new libsecondlife.LLUUID(); + localid = 0; + m_pos = new LLVector3(); + velocity = new LLVector3(); + rotation = new Quaternion(); + m_name = "(basic entity)"; + children = new List(); + } + + public virtual void addForces() + { + foreach (Entity child in children) + { + child.addForces(); + } + } + + /// + /// Performs any updates that need to be done at each frame. This function is overridable from it's children. + /// + public virtual void update() { + // Do any per-frame updates needed that are applicable to every type of entity + foreach (Entity child in children) + { + child.update(); + } + } + + /// + /// Returns a mesh for this object and any dependents + /// + /// The mesh of this entity tree + public virtual Mesh getMesh() + { + Mesh mesh = new Mesh(); + + foreach (Entity child in children) + { + mesh += child.getMesh(); + } + + return mesh; + } + + public virtual void BackUp() + { + + } + + public virtual void LandRenegerated() + { + + } + } +} diff --git a/OpenSim.RegionServer/world/Primitive.cs b/OpenSim.RegionServer/world/Primitive.cs new file mode 100644 index 0000000000..8ff66f90ab --- /dev/null +++ b/OpenSim.RegionServer/world/Primitive.cs @@ -0,0 +1,563 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.types; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Physics.Manager; +using OpenSim.Framework.Assets; + +namespace OpenSim.world +{ + public class Primitive : Entity + { + protected float mesh_cutbegin; + protected float mesh_cutend; + protected PrimData primData; + protected bool newPrimFlag = false; + protected bool updateFlag = false; + protected bool dirtyFlag = false; + private ObjectUpdatePacket OurPacket; + private bool physicsEnabled = false; + private bool physicstest = false; + private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); + private Dictionary m_clientThreads; + private ulong m_regionHandle; + private const uint FULL_MASK_PERMISSIONS = 2147483647; + + public bool PhysicsEnabled + { + get + { + return physicsEnabled; + } + set + { + physicsEnabled = value; + } + } + public bool UpdateFlag + { + get + { + return updateFlag; + } + set + { + updateFlag = value; + } + } + public LLVector3 Scale + { + set + { + this.primData.Scale = value; + this.dirtyFlag = true; + } + get + { + return this.primData.Scale; + } + } + public PhysicsActor PhysActor + { + set + { + this._physActor = value; + } + } + + public Primitive(Dictionary clientThreads, ulong regionHandle, World world) + { + mesh_cutbegin = 0.0f; + mesh_cutend = 1.0f; + + m_clientThreads = clientThreads; + m_regionHandle = regionHandle; + m_world = world; + } + + public override Mesh getMesh() + { + Mesh mesh = new Mesh(); + Triangle tri = new Triangle( + new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f), + new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f), + new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f)); + + mesh.AddTri(tri); + mesh += base.getMesh(); + + return mesh; + } + + public byte[] GetByteArray() + { + return this.primData.ToBytes(); + } + + public void GetProperites(SimClient client) + { + ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); + proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; + proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); + proper.ObjectData[0].ItemID = LLUUID.Zero; // this.uuid; + proper.ObjectData[0].CreationDate = (ulong) this.primData.CreationDate; + proper.ObjectData[0].CreatorID = this.primData.OwnerID; + proper.ObjectData[0].FolderID = LLUUID.Zero; + proper.ObjectData[0].FromTaskID = LLUUID.Zero; + proper.ObjectData[0].GroupID = LLUUID.Zero; + proper.ObjectData[0].InventorySerial = 0; + proper.ObjectData[0].LastOwnerID = LLUUID.Zero; + proper.ObjectData[0].ObjectID = this.uuid; + proper.ObjectData[0].OwnerID = primData.OwnerID; + proper.ObjectData[0].TouchName = new byte[0]; + proper.ObjectData[0].TextureID = new byte[0]; + proper.ObjectData[0].SitName = new byte[0]; + proper.ObjectData[0].Name = new byte[0]; + proper.ObjectData[0].Description = new byte[0]; + proper.ObjectData[0].OwnerMask = this.primData.OwnerMask; + proper.ObjectData[0].NextOwnerMask = this.primData.NextOwnerMask; + proper.ObjectData[0].GroupMask = this.primData.GroupMask; + proper.ObjectData[0].EveryoneMask = this.primData.EveryoneMask; + proper.ObjectData[0].BaseMask = this.primData.BaseMask; + + client.OutPacket(proper); + } + + public void UpdatePosition(LLVector3 pos) + { + this.Pos = pos; + if (this._physActor != null) // && this.physicsEnabled) + { + try + { + lock (m_world.LockPhysicsEngine) + { + this._physActor.Position = new PhysicsVector(pos.X, pos.Y, pos.Z); + } + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + this.updateFlag = true; + } + + public override void update() + { + LLVector3 pos2 = new LLVector3(0, 0, 0); + if (this._physActor != null && this.physicsEnabled) + { + + PhysicsVector pPos = this._physActor.Position; + pos2 = new LLVector3(pPos.X, pPos.Y, pPos.Z); + } + if (this.newPrimFlag) + { + foreach (SimClient client in m_clientThreads.Values) + { + client.OutPacket(OurPacket); + } + this.newPrimFlag = false; + } + else if (this.updateFlag) + { + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = m_regionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = this.CreateImprovedBlock(); + foreach (SimClient client in m_clientThreads.Values) + { + client.OutPacket(terse); + } + this.updateFlag = false; + } + else if (this.dirtyFlag) + { + foreach (SimClient client in m_clientThreads.Values) + { + UpdateClient(client); + } + this.dirtyFlag = false; + } + else + { + if (this._physActor != null && this.physicsEnabled) + { + if (pos2 != this.positionLastFrame) + { + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = m_regionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = this.CreateImprovedBlock(); + foreach (SimClient client in m_clientThreads.Values) + { + client.OutPacket(terse); + } + } + this.positionLastFrame = pos2; + } + } + + if (this.physicstest) + { + LLVector3 pos = this.Pos; + pos.Z += 0.0001f; + this.UpdatePosition(pos); + this.physicstest = false; + } + } + + public void UpdateClient(SimClient RemoteClient) + { + + LLVector3 lPos; + if (this._physActor != null && this.physicsEnabled) + { + PhysicsVector pPos = this._physActor.Position; + lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); + } + else + { + lPos = this.Pos; + } + byte[] pb = lPos.GetBytes(); + Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length); + + // OurPacket should be update with the follwing in updateShape() rather than having to do it here + OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID; + OurPacket.ObjectData[0].PCode = this.primData.PCode; + OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin; + OurPacket.ObjectData[0].PathEnd = this.primData.PathEnd; + OurPacket.ObjectData[0].PathScaleX = this.primData.PathScaleX; + OurPacket.ObjectData[0].PathScaleY = this.primData.PathScaleY; + OurPacket.ObjectData[0].PathShearX = this.primData.PathShearX; + OurPacket.ObjectData[0].PathShearY = this.primData.PathShearY; + OurPacket.ObjectData[0].PathSkew = this.primData.PathSkew; + OurPacket.ObjectData[0].ProfileBegin = this.primData.ProfileBegin; + OurPacket.ObjectData[0].ProfileEnd = this.primData.ProfileEnd; + OurPacket.ObjectData[0].Scale = this.primData.Scale; + OurPacket.ObjectData[0].PathCurve = this.primData.PathCurve; + OurPacket.ObjectData[0].ProfileCurve = this.primData.ProfileCurve; + OurPacket.ObjectData[0].ParentID = this.primData.ParentID ; + OurPacket.ObjectData[0].ProfileHollow = this.primData.ProfileHollow; + //finish off copying rest of shape data + OurPacket.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset; + OurPacket.ObjectData[0].PathRevolutions = this.primData.PathRevolutions; + OurPacket.ObjectData[0].PathTaperX = this.primData.PathTaperX; + OurPacket.ObjectData[0].PathTaperY = this.primData.PathTaperY; + OurPacket.ObjectData[0].PathTwist = this.primData.PathTwist; + OurPacket.ObjectData[0].PathTwistBegin = this.primData.PathTwistBegin; + + RemoteClient.OutPacket(OurPacket); + } + + public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket) + { + this.primData.PathBegin = addPacket.PathBegin; + this.primData.PathEnd = addPacket.PathEnd; + this.primData.PathScaleX = addPacket.PathScaleX; + this.primData.PathScaleY = addPacket.PathScaleY; + this.primData.PathShearX = addPacket.PathShearX; + this.primData.PathShearY = addPacket.PathShearY; + this.primData.PathSkew = addPacket.PathSkew; + this.primData.ProfileBegin = addPacket.ProfileBegin; + this.primData.ProfileEnd = addPacket.ProfileEnd; + this.primData.PathCurve = addPacket.PathCurve; + this.primData.ProfileCurve = addPacket.ProfileCurve; + this.primData.ProfileHollow = addPacket.ProfileHollow; + this.primData.PathRadiusOffset = addPacket.PathRadiusOffset; + this.primData.PathRevolutions = addPacket.PathRevolutions; + this.primData.PathTaperX = addPacket.PathTaperX; + this.primData.PathTaperY = addPacket.PathTaperY; + this.primData.PathTwist = addPacket.PathTwist; + this.primData.PathTwistBegin = addPacket.PathTwistBegin; + this.dirtyFlag = true; + } + + public void UpdateTexture(byte[] tex) + { + this.OurPacket.ObjectData[0].TextureEntry = tex; + this.primData.Texture = tex; + this.dirtyFlag = true; + } + + public void UpdateObjectFlags(ObjectFlagUpdatePacket pack) + { + if (this._physActor != null) + { + if (this._physActor.Kinematic == pack.AgentData.UsePhysics) + { + this._physActor.Kinematic = !pack.AgentData.UsePhysics; //if Usephysics = true, then Kinematic should = false + } + this.physicsEnabled = pack.AgentData.UsePhysics; + if (this._physActor.Kinematic == false) + { + LLVector3 pos = this.Pos; + this.UpdatePosition(pos); + pos.Z += 0.000001f; + this.UpdatePosition(pos); + this.physicstest = true; + } + else + { + PhysicsVector vec = this._physActor.Position; + LLVector3 pos = new LLVector3(vec.X, vec.Y, vec.Z); + this.Pos = pos; + this.updateFlag = true; + } + } + } + + public void MakeParent(Primitive prim) + { + this.primData.ParentID = prim.localid; + this.Pos -= prim.Pos; + this.dirtyFlag = true; + } + + public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) + { + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = m_regionHandle; + objupdate.RegionData.TimeDilation = 64096; + + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + PrimData PData = new PrimData(); + this.primData = PData; + this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + + objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); + objupdate.ObjectData[0].PSBlock = new byte[0]; + objupdate.ObjectData[0].ExtraParams = new byte[1]; + objupdate.ObjectData[0].MediaURL = new byte[0]; + objupdate.ObjectData[0].NameValue = new byte[0]; + objupdate.ObjectData[0].Text = new byte[0]; + objupdate.ObjectData[0].TextColor = new byte[4]; + objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0); + objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0); + objupdate.ObjectData[0].Material = 3; + objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456; + objupdate.ObjectData[0].TextureAnim = new byte[0]; + objupdate.ObjectData[0].Sound = LLUUID.Zero; + LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); + this.primData.Texture = objupdate.ObjectData[0].TextureEntry = ntex.ToBytes(); + objupdate.ObjectData[0].State = 0; + objupdate.ObjectData[0].Data = new byte[0]; + PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID; + PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode; + PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin; + PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd; + PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX; + PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY; + PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX; + PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY; + PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew; + PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin; + PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd; + PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale; + PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve; + PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve; + PData.ParentID = objupdate.ObjectData[0].ParentID = 0; + PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow; + PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; + PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions; + PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX; + PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY; + PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist; + PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin; + objupdate.ObjectData[0].ID = (uint)(localID); + objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID - 702000).ToString("00000")); + objupdate.ObjectData[0].ObjectData = new byte[60]; + objupdate.ObjectData[0].ObjectData[46] = 128; + objupdate.ObjectData[0].ObjectData[47] = 63; + LLVector3 pos1 = addPacket.ObjectData.RayEnd; + //update position + byte[] pb = pos1.GetBytes(); + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); + this.newPrimFlag = true; + this.primData.FullID = this.uuid = objupdate.ObjectData[0].FullID; + this.localid = objupdate.ObjectData[0].ID; + this.primData.Position = this.Pos = pos1; + this.OurPacket = objupdate; + } + + public void CreateFromStorage(PrimData store) + { + this.CreateFromStorage(store, store.Position, store.LocalID, false); + } + + public void CreateFromStorage(PrimData store, LLVector3 posi, uint localID, bool newprim) + { + //need to clean this up as it shares a lot of code with CreateFromPacket() + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = m_regionHandle; + objupdate.RegionData.TimeDilation = 64096; + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + + this.primData = store; + objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); + objupdate.ObjectData[0].PSBlock = new byte[0]; + objupdate.ObjectData[0].ExtraParams = new byte[1]; + objupdate.ObjectData[0].MediaURL = new byte[0]; + objupdate.ObjectData[0].NameValue = new byte[0]; + objupdate.ObjectData[0].Text = new byte[0]; + objupdate.ObjectData[0].TextColor = new byte[4]; + objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0); + objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0); + objupdate.ObjectData[0].Material = 3; + objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456; + objupdate.ObjectData[0].TextureAnim = new byte[0]; + objupdate.ObjectData[0].Sound = LLUUID.Zero; + + if (store.Texture == null) + { + LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); + objupdate.ObjectData[0].TextureEntry = ntex.ToBytes(); + } + else + { + objupdate.ObjectData[0].TextureEntry = store.Texture; + } + + objupdate.ObjectData[0].State = 0; + objupdate.ObjectData[0].Data = new byte[0]; + objupdate.ObjectData[0].OwnerID = this.primData.OwnerID; + objupdate.ObjectData[0].PCode = this.primData.PCode; + objupdate.ObjectData[0].PathBegin = this.primData.PathBegin; + objupdate.ObjectData[0].PathEnd = this.primData.PathEnd; + objupdate.ObjectData[0].PathScaleX = this.primData.PathScaleX; + objupdate.ObjectData[0].PathScaleY = this.primData.PathScaleY; + objupdate.ObjectData[0].PathShearX = this.primData.PathShearX; + objupdate.ObjectData[0].PathShearY = this.primData.PathShearY; + objupdate.ObjectData[0].PathSkew = this.primData.PathSkew; + objupdate.ObjectData[0].ProfileBegin = this.primData.ProfileBegin; + objupdate.ObjectData[0].ProfileEnd = this.primData.ProfileEnd; + objupdate.ObjectData[0].Scale = this.primData.Scale; + objupdate.ObjectData[0].PathCurve = this.primData.PathCurve; + objupdate.ObjectData[0].ProfileCurve = this.primData.ProfileCurve; + objupdate.ObjectData[0].ParentID = 0; + objupdate.ObjectData[0].ProfileHollow = this.primData.ProfileHollow; + //finish off copying rest of shape data + objupdate.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset; + objupdate.ObjectData[0].PathRevolutions = this.primData.PathRevolutions; + objupdate.ObjectData[0].PathTaperX = this.primData.PathTaperX; + objupdate.ObjectData[0].PathTaperY = this.primData.PathTaperY; + objupdate.ObjectData[0].PathTwist = this.primData.PathTwist; + objupdate.ObjectData[0].PathTwistBegin = this.primData.PathTwistBegin; + + objupdate.ObjectData[0].ID = localID; // (uint)store.LocalID; + objupdate.ObjectData[0].FullID = store.FullID; + + objupdate.ObjectData[0].ObjectData = new byte[60]; + objupdate.ObjectData[0].ObjectData[46] = 128; + objupdate.ObjectData[0].ObjectData[47] = 63; + LLVector3 pos1 = posi; // store.Position; + //update position + byte[] pb = pos1.GetBytes(); + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); + + this.uuid = objupdate.ObjectData[0].FullID; + this.localid = objupdate.ObjectData[0].ID; + this.Pos = pos1; + this.OurPacket = objupdate; + if (newprim) + { + this.newPrimFlag = true; + } + } + + public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() + { + uint ID = this.localid; + byte[] bytes = new byte[60]; + + int i = 0; + ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); + //dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry; + dat.TextureEntry = new byte[0]; + //Console.WriteLine("texture-entry length in improvedterse block is " + this.OurPacket.ObjectData[0].TextureEntry.Length); + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = 0; + bytes[i++] = 0; + + LLVector3 lPos; + Axiom.MathLib.Quaternion lRot; + if (this._physActor != null && this.physicsEnabled) + { + PhysicsVector pPos = this._physActor.Position; + lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); + lRot = this._physActor.Orientation; + } + else + { + lPos = this.Pos; + lRot = this.rotation; + } + byte[] pb = lPos.GetBytes(); + Array.Copy(pb, 0, bytes, i, pb.Length); + i += 12; + ushort ac = 32767; + + //vel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + //accel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + ushort rw, rx, ry, rz; + rw = (ushort)(32768 * (lRot.w + 1)); + rx = (ushort)(32768 * (lRot.x + 1)); + ry = (ushort)(32768 * (lRot.y + 1)); + rz = (ushort)(32768 * (lRot.z + 1)); + + //rot + bytes[i++] = (byte)(rx % 256); + bytes[i++] = (byte)((rx >> 8) % 256); + bytes[i++] = (byte)(ry % 256); + bytes[i++] = (byte)((ry >> 8) % 256); + bytes[i++] = (byte)(rz % 256); + bytes[i++] = (byte)((rz >> 8) % 256); + bytes[i++] = (byte)(rw % 256); + bytes[i++] = (byte)((rw >> 8) % 256); + + //rotation vel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + dat.Data = bytes; + return dat; + } + + public override void BackUp() + { + this.primData.FullID = this.uuid; + this.primData.LocalID = this.localid; + this.primData.Position = this.Pos; + this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w); + this.m_world.localStorage.StorePrim(this.primData); + } + } +} diff --git a/OpenSim.RegionServer/world/Primitive2.cs b/OpenSim.RegionServer/world/Primitive2.cs new file mode 100644 index 0000000000..4b26fbe51a --- /dev/null +++ b/OpenSim.RegionServer/world/Primitive2.cs @@ -0,0 +1,429 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.types; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Physics.Manager; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Inventory; + +namespace OpenSim.world +{ + public class Primitive2 :Entity + { + protected PrimData primData; + private ObjectUpdatePacket OurPacket; + private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); + private Dictionary m_clientThreads; + private ulong m_regionHandle; + private const uint FULL_MASK_PERMISSIONS = 2147483647; + private bool physicsEnabled = false; + + private Dictionary inventoryItems; + private string inventoryFileName = ""; + + #region Properties + + public LLVector3 Scale + { + set + { + this.primData.Scale = value; + //this.dirtyFlag = true; + } + get + { + return this.primData.Scale; + } + } + + public PhysicsActor PhysActor + { + set + { + this._physActor = value; + } + } + + #endregion + + public Primitive2(Dictionary clientThreads, ulong regionHandle, World world) + { + m_clientThreads = clientThreads; + m_regionHandle = regionHandle; + m_world = world; + inventoryItems = new Dictionary(); + } + + public byte[] GetByteArray() + { + byte[] result = null; + List dataArrays = new List(); + dataArrays.Add(primData.ToBytes()); + foreach (Entity child in children) + { + if (child is OpenSim.world.Primitive2) + { + dataArrays.Add(((OpenSim.world.Primitive2)child).GetByteArray()); + } + } + byte[] primstart = Helpers.StringToField(""); + byte[] primend = Helpers.StringToField(""); + int totalLength = primstart.Length + primend.Length; + for (int i = 0; i < dataArrays.Count; i++) + { + totalLength += dataArrays[i].Length; + } + + result = new byte[totalLength]; + int arraypos = 0; + Array.Copy(primstart, 0, result, 0, primstart.Length); + arraypos += primstart.Length; + for (int i = 0; i < dataArrays.Count; i++) + { + Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length); + arraypos += dataArrays[i].Length; + } + Array.Copy(primend, 0, result, arraypos, primend.Length); + + return result; + } + + #region Overridden Methods + + public override void update() + { + LLVector3 pos2 = new LLVector3(0, 0, 0); + } + + public override void BackUp() + { + + } + + #endregion + + #region Packet handlers + + public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket) + { + this.primData.PathBegin = addPacket.PathBegin; + this.primData.PathEnd = addPacket.PathEnd; + this.primData.PathScaleX = addPacket.PathScaleX; + this.primData.PathScaleY = addPacket.PathScaleY; + this.primData.PathShearX = addPacket.PathShearX; + this.primData.PathShearY = addPacket.PathShearY; + this.primData.PathSkew = addPacket.PathSkew; + this.primData.ProfileBegin = addPacket.ProfileBegin; + this.primData.ProfileEnd = addPacket.ProfileEnd; + this.primData.PathCurve = addPacket.PathCurve; + this.primData.ProfileCurve = addPacket.ProfileCurve; + this.primData.ProfileHollow = addPacket.ProfileHollow; + this.primData.PathRadiusOffset = addPacket.PathRadiusOffset; + this.primData.PathRevolutions = addPacket.PathRevolutions; + this.primData.PathTaperX = addPacket.PathTaperX; + this.primData.PathTaperY = addPacket.PathTaperY; + this.primData.PathTwist = addPacket.PathTwist; + this.primData.PathTwistBegin = addPacket.PathTwistBegin; + } + + public void UpdateTexture(byte[] tex) + { + this.OurPacket.ObjectData[0].TextureEntry = tex; + this.primData.Texture = tex; + //this.dirtyFlag = true; + } + + public void UpdateObjectFlags(ObjectFlagUpdatePacket pack) + { + + } + + public void AssignToParent(Primitive prim) + { + + } + + #endregion + + # region Inventory Methods + + public bool AddToInventory(InventoryItem item) + { + return false; + } + + public InventoryItem RemoveFromInventory(LLUUID itemID) + { + return null; + } + + public void RequestInventoryInfo(SimClient simClient, RequestTaskInventoryPacket packet) + { + + } + + public void RequestXferInventory(SimClient simClient, ulong xferID) + { + //will only currently work if the total size of the inventory data array is under about 1000 bytes + SendXferPacketPacket send = new SendXferPacketPacket(); + + send.XferID.ID = xferID; + send.XferID.Packet = 1 + 2147483648; + send.DataPacket.Data = this.ConvertInventoryToBytes(); + + simClient.OutPacket(send); + } + + public byte[] ConvertInventoryToBytes() + { + System.Text.Encoding enc = System.Text.Encoding.ASCII; + byte[] result = new byte[0]; + List inventoryData = new List(); + int totallength = 0; + foreach (InventoryItem invItem in inventoryItems.Values) + { + byte[] data = enc.GetBytes(invItem.ExportString()); + inventoryData.Add(data); + totallength += data.Length; + } + //TODO: copy arrays into the single result array + + return result; + } + + public void CreateInventoryFromBytes(byte[] data) + { + + } + + #endregion + + #region Update viewers Methods + + public void SendFullUpdateToClient(SimClient remoteClient) + { + LLVector3 lPos; + if (this._physActor != null && this.physicsEnabled) + { + PhysicsVector pPos = this._physActor.Position; + lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); + } + else + { + lPos = this.Pos; + } + byte[] pb = lPos.GetBytes(); + Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length); + + this.UpdatePacketShapeData(); + remoteClient.OutPacket(OurPacket); + } + + public void SendTerseUpdateToClient(SimClient RemoteClient) + { + + } + + public void SendTerseUpdateToALLClients() + { + + } + + #endregion + + #region Create Methods + + public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) + { + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = m_regionHandle; + objupdate.RegionData.TimeDilation = 64096; + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + PrimData PData = new PrimData(); + this.primData = PData; + this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + + objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); + this.SetDefaultPacketValues(objupdate.ObjectData[0]); + + objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456; + PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID; + PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode; + PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin; + PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd; + PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX; + PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY; + PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX; + PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY; + PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew; + PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin; + PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd; + PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale; + PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve; + PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve; + PData.ParentID = objupdate.ObjectData[0].ParentID = 0; + PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow; + PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; + PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions; + PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX; + PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY; + PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist; + PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin; + objupdate.ObjectData[0].ID = (uint)(localID); + objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID - 702000).ToString("00000")); + LLVector3 pos1 = addPacket.ObjectData.RayEnd; + //update position + byte[] pb = pos1.GetBytes(); + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); + //this.newPrimFlag = true; + this.primData.FullID = this.uuid = objupdate.ObjectData[0].FullID; + this.localid = objupdate.ObjectData[0].ID; + this.primData.Position = this.Pos = pos1; + this.OurPacket = objupdate; + } + + public void CreateFromBytes(byte[] data) + { + + } + + public void CreateFromPrimData(PrimData primData) + { + + } + + #endregion + + #region Packet Update Methods + protected void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata) + { + objdata.PSBlock = new byte[0]; + objdata.ExtraParams = new byte[1]; + objdata.MediaURL = new byte[0]; + objdata.NameValue = new byte[0]; + objdata.Text = new byte[0]; + objdata.TextColor = new byte[4]; + objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); + objdata.JointPivot = new LLVector3(0, 0, 0); + objdata.Material = 3; + objdata.TextureAnim = new byte[0]; + objdata.Sound = LLUUID.Zero; + LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); + this.primData.Texture = objdata.TextureEntry = ntex.ToBytes(); + objdata.State = 0; + objdata.Data = new byte[0]; + + objdata.ObjectData = new byte[60]; + objdata.ObjectData[46] = 128; + objdata.ObjectData[47] = 63; + } + + protected void UpdatePacketShapeData() + { + OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID; + OurPacket.ObjectData[0].PCode = this.primData.PCode; + OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin; + OurPacket.ObjectData[0].PathEnd = this.primData.PathEnd; + OurPacket.ObjectData[0].PathScaleX = this.primData.PathScaleX; + OurPacket.ObjectData[0].PathScaleY = this.primData.PathScaleY; + OurPacket.ObjectData[0].PathShearX = this.primData.PathShearX; + OurPacket.ObjectData[0].PathShearY = this.primData.PathShearY; + OurPacket.ObjectData[0].PathSkew = this.primData.PathSkew; + OurPacket.ObjectData[0].ProfileBegin = this.primData.ProfileBegin; + OurPacket.ObjectData[0].ProfileEnd = this.primData.ProfileEnd; + OurPacket.ObjectData[0].Scale = this.primData.Scale; + OurPacket.ObjectData[0].PathCurve = this.primData.PathCurve; + OurPacket.ObjectData[0].ProfileCurve = this.primData.ProfileCurve; + OurPacket.ObjectData[0].ParentID = this.primData.ParentID; + OurPacket.ObjectData[0].ProfileHollow = this.primData.ProfileHollow; + OurPacket.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset; + OurPacket.ObjectData[0].PathRevolutions = this.primData.PathRevolutions; + OurPacket.ObjectData[0].PathTaperX = this.primData.PathTaperX; + OurPacket.ObjectData[0].PathTaperY = this.primData.PathTaperY; + OurPacket.ObjectData[0].PathTwist = this.primData.PathTwist; + OurPacket.ObjectData[0].PathTwistBegin = this.primData.PathTwistBegin; + } + + #endregion + + protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() + { + uint ID = this.localid; + byte[] bytes = new byte[60]; + + int i = 0; + ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); + dat.TextureEntry = new byte[0]; + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = 0; + bytes[i++] = 0; + + LLVector3 lPos; + Axiom.MathLib.Quaternion lRot; + if (this._physActor != null && this.physicsEnabled) + { + PhysicsVector pPos = this._physActor.Position; + lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); + lRot = this._physActor.Orientation; + } + else + { + lPos = this.Pos; + lRot = this.rotation; + } + byte[] pb = lPos.GetBytes(); + Array.Copy(pb, 0, bytes, i, pb.Length); + i += 12; + ushort ac = 32767; + + //vel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + //accel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + ushort rw, rx, ry, rz; + rw = (ushort)(32768 * (lRot.w + 1)); + rx = (ushort)(32768 * (lRot.x + 1)); + ry = (ushort)(32768 * (lRot.y + 1)); + rz = (ushort)(32768 * (lRot.z + 1)); + + //rot + bytes[i++] = (byte)(rx % 256); + bytes[i++] = (byte)((rx >> 8) % 256); + bytes[i++] = (byte)(ry % 256); + bytes[i++] = (byte)((ry >> 8) % 256); + bytes[i++] = (byte)(rz % 256); + bytes[i++] = (byte)((rz >> 8) % 256); + bytes[i++] = (byte)(rw % 256); + bytes[i++] = (byte)((rw >> 8) % 256); + + //rotation vel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + dat.Data = bytes; + return dat; + } + } +} diff --git a/OpenSim.RegionServer/world/ScriptEngine.cs b/OpenSim.RegionServer/world/ScriptEngine.cs new file mode 100644 index 0000000000..f20a08ec1b --- /dev/null +++ b/OpenSim.RegionServer/world/ScriptEngine.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.world +{ + public class ScriptEngine + { + public ScriptEngine(World env) + { + } + + public void LoadScript() + { + + } + } +} diff --git a/OpenSim.RegionServer/world/SurfacePatch.cs b/OpenSim.RegionServer/world/SurfacePatch.cs new file mode 100644 index 0000000000..71e4116d11 --- /dev/null +++ b/OpenSim.RegionServer/world/SurfacePatch.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.world +{ + public class SurfacePatch + { + public float[] HeightMap; + + public SurfacePatch() { + HeightMap = new float[16*16]; + + int xinc; + int yinc; + for(xinc=0; xinc<16; xinc++) for(yinc=0; yinc<16; yinc++) { + HeightMap[xinc+(yinc*16)]=100.0f; + } + + } + } +} diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs new file mode 100644 index 0000000000..2951ce3d91 --- /dev/null +++ b/OpenSim.RegionServer/world/World.cs @@ -0,0 +1,417 @@ +using System; +using libsecondlife; +using libsecondlife.Packets; +using System.Collections.Generic; +using System.Text; +using System.Reflection; +using System.IO; +using OpenSim.Physics.Manager; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Terrain; +using OpenSim.Framework.Inventory; +using OpenSim.Assets; +using OpenSim.world.scripting; +using OpenSim.RegionServer.world.scripting; +using OpenSim.RegionServer.world.scripting.Scripts; +using OpenSim.Terrain; + +namespace OpenSim.world +{ + public partial class World : ILocalStorageReceiver, IScriptAPI + { + public object LockPhysicsEngine = new object(); + public Dictionary Entities; + public Dictionary Avatars; + public Dictionary Prims; +// public float[] LandMap; + public ScriptEngine Scripts; + public TerrainEngine Terrain; //TODO: Replace TerrainManager with this. + public uint _localNumber = 0; + private PhysicsScene phyScene; + private float timeStep = 0.1f; + private libsecondlife.TerrainManager TerrainManager; + public ILocalStorage localStorage; + private Random Rand = new Random(); + private uint _primCount = 702000; + private int storageCount; + private Dictionary m_clientThreads; + private Dictionary m_scriptHandlers; + private Dictionary m_scripts; + private ulong m_regionHandle; + private string m_regionName; + private InventoryCache _inventoryCache; + private AssetCache _assetCache; + + public World(Dictionary clientThreads, ulong regionHandle, string regionName) + { + m_clientThreads = clientThreads; + m_regionHandle = regionHandle; + m_regionName = regionName; + + m_scriptHandlers = new Dictionary(); + m_scripts = new Dictionary(); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); + Entities = new Dictionary(); + Avatars = new Dictionary(); + Prims = new Dictionary(); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating LandMap"); + TerrainManager = new TerrainManager(new SecondLife()); + Terrain = new TerrainEngine(); + Avatar.SetupTemplate("avatar-template.dat"); + // MainConsole.Instance.WriteLine("World.cs - Creating script engine instance"); + // Initialise this only after the world has loaded + // Scripts = new ScriptEngine(this); + Avatar.LoadAnims(); + this.SetDefaultScripts(); + this.LoadScriptEngines(); + } + + public void AddScript(Entity entity, Script script) + { + ScriptHandler scriptHandler = new ScriptHandler(script, entity, this); + m_scriptHandlers.Add(scriptHandler.ScriptId, scriptHandler); + } + + public void AddScript(Entity entity, string scriptData) + { + int scriptstart = 0; + int scriptend = 0; + string substring; + scriptstart = scriptData.LastIndexOf(""); + substring = scriptData.Substring(scriptstart + 8, scriptend - scriptstart - 8); + substring = substring.Trim(); + //Console.WriteLine("searching for script to add: " + substring); + + ScriptFactory scriptFactory; + + if (this.m_scripts.TryGetValue(substring, out scriptFactory)) + { + //Console.WriteLine("added script"); + this.AddScript(entity, scriptFactory()); + } + + } + + public InventoryCache InventoryCache + { + set + { + this._inventoryCache = value; + } + } + + public AssetCache AssetCache + { + set + { + this._assetCache = value; + } + } + public PhysicsScene PhysScene + { + set + { + this.phyScene = value; + } + get + { + return (this.phyScene); + } + } + + public void Update() + { + if (this.phyScene.IsThreaded) + { + this.phyScene.GetResults(); + + } + + foreach (libsecondlife.LLUUID UUID in Entities.Keys) + { + Entities[UUID].addForces(); + } + + lock (this.LockPhysicsEngine) + { + this.phyScene.Simulate(timeStep); + } + + foreach (libsecondlife.LLUUID UUID in Entities.Keys) + { + Entities[UUID].update(); + } + + foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values) + { + scriptHandler.OnFrame(); + } + + //backup world data + this.storageCount++; + if (storageCount > 1200) //set to how often you want to backup + { + this.Backup(); + storageCount = 0; + } + } + + public bool LoadStorageDLL(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + ILocalStorage store = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("ILocalStorage", true); + + if (typeInterface != null) + { + ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + store = plug; + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + this.localStorage = store; + return (store == null); + } + + #region Regenerate Terrain + + public void RegenerateTerrain() + { + Terrain.hills(); + + lock (this.LockPhysicsEngine) + { + this.phyScene.SetTerrain(Terrain.getHeights1D()); + } + this.localStorage.SaveMap(this.Terrain.map); + + foreach (SimClient client in m_clientThreads.Values) + { + this.SendLayerData(client); + } + + foreach (libsecondlife.LLUUID UUID in Entities.Keys) + { + Entities[UUID].LandRenegerated(); + } + } + + public void RegenerateTerrain(float[,] newMap) + { + this.Terrain.map = newMap; + lock (this.LockPhysicsEngine) + { + this.phyScene.SetTerrain(this.Terrain.getHeights1D()); + } + this.localStorage.SaveMap(this.Terrain.map); + + foreach (SimClient client in m_clientThreads.Values) + { + this.SendLayerData(client); + } + + foreach (libsecondlife.LLUUID UUID in Entities.Keys) + { + Entities[UUID].LandRenegerated(); + } + } + + public void RegenerateTerrain(bool changes, int pointx, int pointy) + { + if (changes) + { + lock (this.LockPhysicsEngine) + { + this.phyScene.SetTerrain(this.Terrain.getHeights1D()); + } + this.localStorage.SaveMap(this.Terrain.map); + + foreach (SimClient client in m_clientThreads.Values) + { + this.SendLayerData(pointx, pointy, client); + } + } + } + + #endregion + + public void LoadWorldMap() + { + float[,] map = this.localStorage.LoadWorld(); + if (map == null) + { + Console.WriteLine("creating new terrain"); + this.Terrain.hills(); + + //this.localStorage.SaveMap(this.Terrain.map); + } + else + { + this.Terrain.map = map; + } + } + + public void LoadPrimsFromStorage() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives"); + this.localStorage.LoadPrimitives(this); + } + + public void PrimFromStorage(PrimData prim) + { + if (prim.LocalID >= this._primCount) + { + _primCount = prim.LocalID + 1; + } + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId " + prim.LocalID + " ) from storage"); + Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this); + nPrim.CreateFromStorage(prim); + this.Entities.Add(nPrim.uuid, nPrim); + } + + public void Close() + { + this.localStorage.ShutDown(); + } + + public void SendLayerData(SimClient RemoteClient) + { + int[] patches = new int[4]; + + for (int y = 0; y < 16; y++) + { + for (int x = 0; x < 16; x = x + 4) + { + patches[0] = x + 0 + y * 16; + patches[1] = x + 1 + y * 16; + patches[2] = x + 2 + y * 16; + patches[3] = x + 3 + y * 16; + + Packet layerpack = TerrainManager.CreateLandPacket(Terrain.getHeights1D(), patches); + RemoteClient.OutPacket(layerpack); + } + } + } + + public void SendLayerData(int px, int py, SimClient RemoteClient) + { + int[] patches = new int[1]; + int patchx, patchy; + patchx = px / 16; + /* if (patchx > 12) + { + patchx = 12; + }*/ + patchy = py / 16; + + patches[0] = patchx + 0 + patchy * 16; + //patches[1] = patchx + 1 + patchy * 16; + //patches[2] = patchx + 2 + patchy * 16; + //patches[3] = patchx + 3 + patchy * 16; + + Packet layerpack = TerrainManager.CreateLandPacket(Terrain.getHeights1D(), patches); + RemoteClient.OutPacket(layerpack); + } + + public void GetInitialPrims(SimClient RemoteClient) + { + foreach (libsecondlife.LLUUID UUID in Entities.Keys) + { + if (Entities[UUID] is Primitive) + { + Primitive primitive = Entities[UUID] as Primitive; + primitive.UpdateClient(RemoteClient); + } + } + } + + public void AddViewerAgent(SimClient agentClient) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); + Avatar newAvatar = new Avatar(agentClient, this, m_regionName, m_clientThreads, m_regionHandle); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); + newAvatar.SendRegionHandshake(this); + PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); + lock (this.LockPhysicsEngine) + { + newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); + } + lock (Entities) + { + this.Entities.Add(agentClient.AgentID, newAvatar); + } + lock (Avatars) + { + this.Avatars.Add(agentClient.AgentID, newAvatar); + } + } + + public void RemoveViewerAgent(SimClient agentClient) + { + lock (Entities) + { + Entities.Remove(agentClient.AgentID); + } + lock (Avatars) + { + Avatars.Remove(agentClient.AgentID); + } + } + + public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim"); + Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this); + prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount); + PhysicsVector pVec = new PhysicsVector(prim.Pos.X, prim.Pos.Y, prim.Pos.Z); + PhysicsVector pSize = new PhysicsVector(0.255f, 0.255f, 0.255f); + if (OpenSim.world.Avatar.PhysicsEngineFlying) + { + lock (this.LockPhysicsEngine) + { + prim.PhysActor = this.phyScene.AddPrim(pVec, pSize); + } + } + + this.Entities.Add(prim.uuid, prim); + this._primCount++; + } + + public bool Backup() + { + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Backup() - Backing up Primitives"); + foreach (libsecondlife.LLUUID UUID in Entities.Keys) + { + Entities[UUID].BackUp(); + } + return true; + } + + public void SetDefaultScripts() + { + this.m_scripts.Add("FollowRandomAvatar", delegate() + { + return new FollowRandomAvatar(); + }); + } + + } +} diff --git a/OpenSim.RegionServer/world/WorldPacketHandlers.cs b/OpenSim.RegionServer/world/WorldPacketHandlers.cs new file mode 100644 index 0000000000..0643a4e8f7 --- /dev/null +++ b/OpenSim.RegionServer/world/WorldPacketHandlers.cs @@ -0,0 +1,182 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Physics.Manager; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Terrain; +using OpenSim.Framework.Inventory; +using OpenSim.Assets; + +namespace OpenSim.world +{ + partial class World + { + public bool ModifyTerrain(SimClient simClient, Packet packet) + { + ModifyLandPacket modify = (ModifyLandPacket)packet; + + switch (modify.ModifyBlock.Action) + { + case 1: + // raise terrain + if (modify.ParcelData.Length > 0) + { + Terrain.raise(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1); + RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West); + } + break; + case 2: + //lower terrain + if (modify.ParcelData.Length > 0) + { + Terrain.lower(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1); + RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West); + } + break; + } + return true; + } + + public bool SimChat(SimClient simClient, Packet packet) + { + System.Text.Encoding enc = System.Text.Encoding.ASCII; + ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)packet; + if (Helpers.FieldToString(inchatpack.ChatData.Message) == "") + { + //empty message so don't bother with it + return true; + } + + libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); + reply.ChatData.Audible = 1; + reply.ChatData.Message = inchatpack.ChatData.Message; + reply.ChatData.ChatType = 1; + reply.ChatData.SourceType = 1; + reply.ChatData.Position = simClient.ClientAvatar.Pos; + reply.ChatData.FromName = enc.GetBytes(simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname + "\0"); + reply.ChatData.OwnerID = simClient.AgentID; + reply.ChatData.SourceID = simClient.AgentID; + foreach (SimClient client in m_clientThreads.Values) + { + client.OutPacket(reply); + } + return true; + } + + public bool RezObject(SimClient simClient, Packet packet) + { + RezObjectPacket rezPacket = (RezObjectPacket)packet; + AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID); + if (inven != null) + { + if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID)) + { + AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID); + if (asset != null) + { + PrimData primd = new PrimData(asset.Data); + Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this); + nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true); + this.Entities.Add(nPrim.uuid, nPrim); + this._primCount++; + this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID); + } + } + } + return true; + } + + public bool DeRezObject(SimClient simClient, Packet packet) + { + DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; + + //Needs to delete object from physics at a later date + if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) + { + //currently following code not used (or don't know of any case of destination being zero + libsecondlife.LLUUID[] DeRezEnts; + DeRezEnts = new libsecondlife.LLUUID[DeRezPacket.ObjectData.Length]; + int i = 0; + foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) + { + + //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); + foreach (Entity ent in this.Entities.Values) + { + if (ent.localid == Data.ObjectLocalID) + { + DeRezEnts[i++] = ent.uuid; + this.localStorage.RemovePrim(ent.uuid); + KillObjectPacket kill = new KillObjectPacket(); + kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; + kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); + kill.ObjectData[0].ID = ent.localid; + foreach (SimClient client in m_clientThreads.Values) + { + client.OutPacket(kill); + } + //Uncommenting this means an old UUID will be re-used, thus crashing the asset server + //Uncomment when prim/object UUIDs are random or such + //2007-03-22 - Randomskk + //this._primCount--; + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Deleted UUID " + ent.uuid); + } + } + } + foreach (libsecondlife.LLUUID uuid in DeRezEnts) + { + lock (Entities) + { + Entities.Remove(uuid); + } + } + } + else + { + foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) + { + Entity selectedEnt = null; + //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); + foreach (Entity ent in this.Entities.Values) + { + if (ent.localid == Data.ObjectLocalID) + { + AssetBase primAsset = new AssetBase(); + primAsset.FullID = LLUUID.Random();//DeRezPacket.AgentBlock.TransactionID.Combine(LLUUID.Zero); //should be combining with securesessionid + primAsset.InvType = 6; + primAsset.Type = 6; + primAsset.Name = "Prim"; + primAsset.Description = ""; + primAsset.Data = ((Primitive)ent).GetByteArray(); + this._assetCache.AddAsset(primAsset); + this._inventoryCache.AddNewInventoryItem(simClient, DeRezPacket.AgentBlock.DestinationID, primAsset); + selectedEnt = ent; + break; + } + } + if (selectedEnt != null) + { + this.localStorage.RemovePrim(selectedEnt.uuid); + KillObjectPacket kill = new KillObjectPacket(); + kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; + kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); + kill.ObjectData[0].ID = selectedEnt.localid; + foreach (SimClient client in m_clientThreads.Values) + { + client.OutPacket(kill); + } + lock (Entities) + { + Entities.Remove(selectedEnt.uuid); + } + } + } + } + return true; + } + + } +} diff --git a/OpenSim.RegionServer/world/WorldScripting.cs b/OpenSim.RegionServer/world/WorldScripting.cs new file mode 100644 index 0000000000..a4f3d56ebe --- /dev/null +++ b/OpenSim.RegionServer/world/WorldScripting.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Reflection; +using OpenSim.Framework; +using OpenSim.Framework.Interfaces; + +namespace OpenSim.world +{ + public partial class World + { + private Dictionary scriptEngines = new Dictionary(); + + private void LoadScriptEngines() + { + this.LoadScriptPlugins(); + } + + public void LoadScriptPlugins() + { + string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ScriptEngines"); + string[] pluginFiles = Directory.GetFiles(path, "*.dll"); + + + for (int i = 0; i < pluginFiles.Length; i++) + { + this.AddPlugin(pluginFiles[i]); + } + } + + private void AddPlugin(string FileName) + { + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IScriptEngine", true); + + if (typeInterface != null) + { + IScriptEngine plug = (IScriptEngine)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug.Init(this); + this.scriptEngines.Add(plug.GetName(), plug); + + } + + typeInterface = null; + } + } + } + + pluginAssembly = null; + } + + public void LoadScript(string scriptType, string scriptName, string script, Entity ent) + { + if(this.scriptEngines.ContainsKey(scriptType)) + { + this.scriptEngines[scriptType].LoadScript(script, scriptName, ent.localid); + } + } + + #region IScriptAPI Methods + + public OSVector3 GetEntityPosition(uint localID) + { + Console.WriteLine("script- getting entity " + localID + " position"); + return new OSVector3(); + } + + public void SetEntityPosition(uint localID, float x , float y, float z) + { + Console.WriteLine("script- setting entity " + localID + " positon"); + } + + public uint GetRandomAvatarID() + { + Console.WriteLine("script- getting random avatar id"); + uint res = 0; + foreach (Entity entity in this.Entities.Values) + { + if (entity is Avatar) + { + res = entity.localid; + } + } + return res; + } + + #endregion + + + } +} diff --git a/OpenSim.RegionServer/world/scripting/IScript.cs b/OpenSim.RegionServer/world/scripting/IScript.cs new file mode 100644 index 0000000000..550594d343 --- /dev/null +++ b/OpenSim.RegionServer/world/scripting/IScript.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.world.scripting +{ + public interface IScriptHost { + bool Register(IScript iscript); + } + public interface IScript + { + string Name{get;set;} + IScriptHost Host{get;set;} + void Show(); + } +} diff --git a/OpenSim.RegionServer/world/scripting/IScriptContext.cs b/OpenSim.RegionServer/world/scripting/IScriptContext.cs new file mode 100644 index 0000000000..465c23b61e --- /dev/null +++ b/OpenSim.RegionServer/world/scripting/IScriptContext.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.RegionServer.world.scripting +{ + public interface IScriptContext + { + IScriptEntity Entity { get; } + bool TryGetRandomAvatar(out IScriptReadonlyEntity avatar); + } +} diff --git a/OpenSim.RegionServer/world/scripting/IScriptEntity.cs b/OpenSim.RegionServer/world/scripting/IScriptEntity.cs new file mode 100644 index 0000000000..2ef16a4bf0 --- /dev/null +++ b/OpenSim.RegionServer/world/scripting/IScriptEntity.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.RegionServer.world.scripting +{ + public interface IScriptReadonlyEntity + { + LLVector3 Pos { get; } + string Name { get; } + } + + public interface IScriptEntity + { + LLVector3 Pos { get; set; } + string Name { get; } + } +} diff --git a/OpenSim.RegionServer/world/scripting/IScriptHandler.cs b/OpenSim.RegionServer/world/scripting/IScriptHandler.cs new file mode 100644 index 0000000000..15efc49574 --- /dev/null +++ b/OpenSim.RegionServer/world/scripting/IScriptHandler.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Physics.Manager; +using OpenSim.world; +using Avatar=OpenSim.world.Avatar; +using Primitive = OpenSim.world.Primitive; + +namespace OpenSim.RegionServer.world.scripting +{ + public delegate void ScriptEventHandler(IScriptContext context); + + public class ScriptHandler : IScriptContext, IScriptEntity, IScriptReadonlyEntity + { + private World m_world; + private Script m_script; + private Entity m_entity; + + public LLUUID ScriptId + { + get + { + return m_script.ScriptId; + } + } + + public void OnFrame() + { + m_script.OnFrame(this); + } + + public ScriptHandler(Script script, Entity entity, World world) + { + m_script = script; + m_entity = entity; + m_world = world; + } + + #region IScriptContext Members + + IScriptEntity IScriptContext.Entity + { + get + { + return this; + } + } + + bool IScriptContext.TryGetRandomAvatar(out IScriptReadonlyEntity avatar) + { + foreach (Entity entity in m_world.Entities.Values ) + { + if( entity is Avatar ) + { + avatar = entity; + return true; + } + } + + avatar = null; + return false; + } + + #endregion + + #region IScriptEntity and IScriptReadonlyEntity Members + + public string Name + { + get + { + return m_entity.Name; + } + } + + public LLVector3 Pos + { + get + { + return m_entity.Pos; + } + + set + { + if (m_entity is Primitive) + { + Primitive prim = m_entity as Primitive; + // Of course, we really should have asked the physEngine if this is possible, and if not, returned false. + prim.UpdatePosition( value ); + } + } + } + + #endregion + } + +} diff --git a/OpenSim.RegionServer/world/scripting/Script.cs b/OpenSim.RegionServer/world/scripting/Script.cs new file mode 100644 index 0000000000..48c18ff999 --- /dev/null +++ b/OpenSim.RegionServer/world/scripting/Script.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.RegionServer.world.scripting +{ + public class Script + { + private LLUUID m_scriptId; + public virtual LLUUID ScriptId + { + get + { + return m_scriptId; + } + } + + public Script( LLUUID scriptId ) + { + m_scriptId = scriptId; + } + + public ScriptEventHandler OnFrame; + } +} diff --git a/OpenSim.RegionServer/world/scripting/ScriptFactory.cs b/OpenSim.RegionServer/world/scripting/ScriptFactory.cs new file mode 100644 index 0000000000..4c6d373dd3 --- /dev/null +++ b/OpenSim.RegionServer/world/scripting/ScriptFactory.cs @@ -0,0 +1,8 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.RegionServer.world.scripting +{ + public delegate Script ScriptFactory(); +} diff --git a/OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs b/OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs new file mode 100644 index 0000000000..388a95cb75 --- /dev/null +++ b/OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.RegionServer.world.scripting.Scripts +{ + public class FollowRandomAvatar : Script + { + public FollowRandomAvatar() + : base(LLUUID.Random()) + { + OnFrame += MyOnFrame; + } + + private void MyOnFrame(IScriptContext context) + { + LLVector3 pos = context.Entity.Pos; + + IScriptReadonlyEntity avatar; + + if (context.TryGetRandomAvatar(out avatar)) + { + LLVector3 avatarPos = avatar.Pos; + + float x = pos.X + ((float)avatarPos.X.CompareTo(pos.X)) / 2; + float y = pos.Y + ((float)avatarPos.Y.CompareTo(pos.Y)) / 2; + + LLVector3 newPos = new LLVector3(x, y, pos.Z); + + context.Entity.Pos = newPos; + } + } + } + + +} diff --git a/OpenSim.Scripting.EmbeddedJVM/ClassInstance.cs b/OpenSim.Scripting.EmbeddedJVM/ClassInstance.cs new file mode 100644 index 0000000000..15ef814af0 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/ClassInstance.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class ClassInstance : Object + { + public int size; + public Dictionary Fields = new Dictionary(); + + public ClassInstance() + { + + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/ClassRecord.cs b/OpenSim.Scripting.EmbeddedJVM/ClassRecord.cs new file mode 100644 index 0000000000..ac4c9fd0aa --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/ClassRecord.cs @@ -0,0 +1,475 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class ClassRecord + { + private ushort _majorVersion; + private ushort _minorVersion; + private ushort _constantPoolCount; + private ushort _accessFlags; + private ushort _thisClass; + private ushort _supperClass; + private ushort _interfaceCount; + private ushort _fieldCount; + private ushort _methodCount; + private ushort _attributeCount; + private string _name; + public Dictionary StaticFields = new Dictionary(); + public PoolClass mClass; + + public List _constantsPool = new List(); + private List _methodsList = new List(); + private List _fieldList = new List(); + + public ClassRecord() + { + + } + + public ClassInstance CreateNewInstance() + { + return new ClassInstance(); + } + + public void LoadClassFromFile(string fileName) + { + FileStream fs = File.OpenRead(fileName); + this.LoadClassFromBytes(ReadFully(fs)); + fs.Close(); + } + + public void LoadClassFromBytes(byte[] data) + { + int i = 0; + i += 4; + _minorVersion = (ushort)((data[i++] << 8) + data[i++] ); + _majorVersion = (ushort)((data[i++] << 8) + data[i++] ); + _constantPoolCount = (ushort)((data[i++] << 8) + data[i++] ); + //Console.WriteLine("there should be " + _constantPoolCount + " items in the pool"); + for (int count = 0; count < _constantPoolCount -1 ; count++) + { + //read in the constant pool + byte pooltype = data[i++]; + //Console.WriteLine("#" +count +": new constant type = " +pooltype); + //Console.WriteLine("start position is: " + i); + switch (pooltype) + { + case 1: //Utf8 + ushort uLength = (ushort)((data[i++] << 8) + data[i++] ); + + // Console.WriteLine("new utf8 type, length is " + uLength); + PoolUtf8 utf8 = new PoolUtf8(); + utf8.readValue(data, ref i, uLength); + this._constantsPool.Add(utf8); + break; + case 3: //Int + break; + case 7: //Class + PoolClass pClass = new PoolClass(this); + pClass.readValue(data, ref i); + this._constantsPool.Add(pClass); + break; + case 10: //Method + PoolMethodRef pMeth = new PoolMethodRef(this); + pMeth.readValue(data, ref i); + this._constantsPool.Add(pMeth); + break; + case 12: //NamedType + PoolNamedType pNamed = new PoolNamedType(this); + pNamed.readValue(data, ref i); + this._constantsPool.Add(pNamed); + break; + } + } + + _accessFlags = (ushort)((data[i++] << 8) + data[i++] ); + _thisClass = (ushort)((data[i++] << 8) + data[i++] ); + _supperClass = (ushort)((data[i++] << 8) + data[i++] ); + + if (this._constantsPool[this._thisClass - 1] is PoolClass) + { + this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]); + } + + _interfaceCount = (ushort)((data[i++] << 8) + data[i++]); + //should now read in the info for each interface + _fieldCount = (ushort)((data[i++] << 8) + data[i++]); + //should now read in the info for each field + _methodCount = (ushort)((data[i++] << 8) + data[i++]); + for (int count = 0; count < _methodCount; count++) + { + MethodInfo methInf = new MethodInfo(this); + methInf.ReadData(data, ref i); + this._methodsList.Add(methInf); + } + } + + public void AddMethodsToMemory(MethodMemory memory) + { + for (int count = 0; count < _methodCount; count++) + { + this._methodsList[count].AddMethodCode(memory); + } + } + + public bool StartMethod(Thread thread, string methodName) + { + for (int count = 0; count < _methodCount; count++) + { + if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8) + { + if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName) + { + //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); + thread.SetPC(this._methodsList[count].CodePointer); + return true; + } + } + } + return false; + } + + public void PrintToConsole() + { + // Console.WriteLine("Class File:"); + // Console.WriteLine("Major version: " + _majorVersion); + // Console.WriteLine("Minor version: " + _minorVersion); + //Console.WriteLine("Pool size: " + _constantPoolCount); + + for (int i = 0; i < _constantsPool.Count; i++) + { + this._constantsPool[i].Print(); + } + + // Console.WriteLine("Access flags: " + _accessFlags); + // Console.WriteLine("This class: " + _thisClass ); + // Console.WriteLine("Super class: " + _supperClass); + + for (int count = 0; count < _methodCount; count++) + { + Console.WriteLine(); + this._methodsList[count].Print(); + } + + // Console.WriteLine("class name is " + this.mClass.Name.Value); + } + + public static byte[] ReadFully(Stream stream) + { + byte[] buffer = new byte[1024]; + using (MemoryStream ms = new MemoryStream()) + { + while (true) + { + int read = stream.Read(buffer, 0, buffer.Length); + if (read <= 0) + return ms.ToArray(); + ms.Write(buffer, 0, read); + } + } + } + + #region nested classes + public class PoolItem + { + public virtual void Print() + { + + } + } + + public class PoolUtf8 : PoolItem + { + public string Value = ""; + + public void readValue(byte[] data,ref int pointer , int length) + { + for (int i = 0; i < length; i++) + { + int a =(int) data[pointer++]; + if ((a & 0x80) == 0) + { + Value = Value + (char)a; + } + else if ((a & 0x20) == 0) + { + int b = (int) data[pointer++]; + Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); + } + else + { + int b = (int)data[pointer++]; + int c = (int)data[pointer++]; + Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); + } + } + } + + public override void Print() + { + // Console.WriteLine("Utf8 type: " + Value); + } + } + + private class PoolInt : PoolItem + { + + } + + public class PoolClass : PoolItem + { + //public string name = ""; + public ushort namePointer = 0; + private ClassRecord parent; + public PoolUtf8 Name; + + public PoolClass(ClassRecord paren) + { + parent = paren; + } + + public void readValue(byte[] data, ref int pointer) + { + namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); + } + + public override void Print() + { + this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); + //Console.Write("Class type: " + namePointer); + //Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); + + } + } + + public class PoolMethodRef : PoolItem + { + public ushort classPointer = 0; + public ushort nameTypePointer = 0; + public PoolNamedType mNameType; + public PoolClass mClass; + private ClassRecord parent; + + public PoolMethodRef(ClassRecord paren) + { + parent = paren; + } + + public void readValue(byte[] data, ref int pointer) + { + classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + } + + public override void Print() + { + this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); + this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); + // Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); + } + } + + public class PoolNamedType : PoolItem + { + public ushort namePointer = 0; + public ushort typePointer = 0; + private ClassRecord parent; + public PoolUtf8 Name; + public PoolUtf8 Type; + + public PoolNamedType(ClassRecord paren) + { + parent = paren; + } + + public void readValue(byte[] data, ref int pointer) + { + namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); + typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); + } + + public override void Print() + { + Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]); + Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]); + //Console.Write("Named type: " + namePointer + " , " + typePointer ); + //Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value); + } + } + + //*********************** + public class MethodInfo + { + public ushort AccessFlags = 0; + public ushort NameIndex = 0; + public string Name = ""; + public ushort DescriptorIndex = 0; + public ushort AttributeCount = 0; + public List Attributes = new List(); + private ClassRecord parent; + public int CodePointer = 0; + + public MethodInfo(ClassRecord paren) + { + parent = paren; + } + + public void AddMethodCode(MethodMemory memory) + { + Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length); + memory.Methodcount++; + this.CodePointer = memory.NextMethodPC; + memory.NextMethodPC += this.Attributes[0].Code.Length; + } + + public void ReadData(byte[] data, ref int pointer) + { + AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); + NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); + for(int i =0; i< AttributeCount; i++) + { + MethodAttribute attri = new MethodAttribute(this.parent); + attri.ReadData(data, ref pointer); + this.Attributes.Add(attri); + } + } + + public void Print() + { + // Console.WriteLine("Method Info Struct: "); + // Console.WriteLine("AccessFlags: " + AccessFlags); + // Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); + // Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value); + // Console.WriteLine("Attribute Count:" + AttributeCount); + for (int i = 0; i < AttributeCount; i++) + { + this.Attributes[i].Print(); + } + } + + public class MethodAttribute + { + public ushort NameIndex = 0; + public string Name = ""; + public Int32 Length = 0; + //for now only support code attribute + public ushort MaxStack = 0; + public ushort MaxLocals = 0; + public Int32 CodeLength = 0; + public byte[] Code; + public ushort ExceptionTableLength = 0; + public ushort SubAttributeCount = 0; + public List SubAttributes = new List(); + private ClassRecord parent; + + public MethodAttribute(ClassRecord paren) + { + parent = paren; + } + + public void ReadData(byte[] data, ref int pointer) + { + NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]); + MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]); + CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + Code = new byte[CodeLength]; + for (int i = 0; i < CodeLength; i++) + { + Code[i] = data[pointer++]; + } + ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]); + SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); + for (int i = 0; i < SubAttributeCount; i++) + { + SubAttribute subAttri = new SubAttribute(this.parent); + subAttri.ReadData(data, ref pointer); + this.SubAttributes.Add(subAttri); + } + } + + public void Print() + { + // Console.WriteLine("Method Attribute: "); + // Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); + // Console.WriteLine("Length: " + Length); + // Console.WriteLine("MaxStack: " + MaxStack); + // Console.WriteLine("MaxLocals: " + MaxLocals); + // Console.WriteLine("CodeLength: " + CodeLength); + for (int i = 0; i < Code.Length; i++) + { + // Console.WriteLine("OpCode #" + i + " is: " + Code[i]); + } + // Console.WriteLine("SubAttributes: " + SubAttributeCount); + for (int i = 0; i < SubAttributeCount; i++) + { + this.SubAttributes[i].Print(); + } + } + + public class SubAttribute + { + public ushort NameIndex = 0; + public string Name = ""; + public Int32 Length = 0; + public byte[] Data; + private ClassRecord parent; + + public SubAttribute(ClassRecord paren) + { + parent = paren; + } + + public void ReadData(byte[] data, ref int pointer) + { + NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + Data = new byte[Length]; + for (int i = 0; i < Length; i++) + { + Data[i] = data[pointer++]; + } + } + + public void Print() + { + //Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); + } + + } + } + + } + private class InterfaceInfo + { + public void ReadData(byte[] data, ref int i) + { + + } + } + private class FieldInfo + { + public void ReadData(byte[] data, ref int i) + { + + } + } + private class AttributeInfo + { + public void ReadData(byte[] data, ref int i) + { + + } + } + #endregion + + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Heap.cs b/OpenSim.Scripting.EmbeddedJVM/Heap.cs new file mode 100644 index 0000000000..138e85ebc9 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Heap.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class Heap + { + public List ClassObjects = new List(); + + public Heap() + { + + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Interpreter.cs b/OpenSim.Scripting.EmbeddedJVM/Interpreter.cs new file mode 100644 index 0000000000..aeeee0ad41 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Interpreter.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; +using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + partial class Thread + { + private partial class Interpreter + { + private Thread _mThread; + + public Interpreter(Thread parentThread) + { + _mThread = parentThread; + } + + public bool Excute() + { + bool run = true; + byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++]; + // Console.WriteLine("opCode is: " + currentOpCode); + bool handled = false; + + handled = this.IsLogicOpCode(currentOpCode); + if (!handled) + { + handled = this.IsMethodOpCode(currentOpCode); + } + if (!handled) + { + if (currentOpCode == 172) + { + if (this._mThread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning int from function"); + int retPC1 = this._mThread.currentFrame.ReturnPC; + BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); + this._mThread.stack.StackFrames.Pop(); + this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); + this._mThread.PC = retPC1; + if (bas1 is Int) + { + this._mThread.currentFrame.OpStack.Push((Int)bas1); + } + } + else + { + // Console.WriteLine("No parent function so ending program"); + run = false; + } + handled = true; + } + if (currentOpCode == 174) + { + if (this._mThread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning float from function"); + int retPC1 = this._mThread.currentFrame.ReturnPC; + BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); + this._mThread.stack.StackFrames.Pop(); + this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); + this._mThread.PC = retPC1; + if (bas1 is Float) + { + this._mThread.currentFrame.OpStack.Push((Float)bas1); + } + } + else + { + // Console.WriteLine("No parent function so ending program"); + run = false; + } + handled = true; + } + if (currentOpCode == 177) + { + if (this._mThread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning from function"); + int retPC = this._mThread.currentFrame.ReturnPC; + this._mThread.stack.StackFrames.Pop(); + this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); + this._mThread.PC = retPC; + } + else + { + // Console.WriteLine("No parent function so ending program"); + run = false; + } + handled = true; + } + } + if (!handled) + { + Console.WriteLine("opcode " + currentOpCode + " not been handled "); + } + return run; + + } + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/InterpreterLogic.cs b/OpenSim.Scripting.EmbeddedJVM/InterpreterLogic.cs new file mode 100644 index 0000000000..95d402a34c --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/InterpreterLogic.cs @@ -0,0 +1,283 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; +using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + partial class Thread + { + private partial class Interpreter + { + private bool IsLogicOpCode(byte opcode) + { + bool result = false; + switch (opcode) + { + case 2: + Int m_int= new Int(); + m_int.mValue = -1; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 3: + m_int= new Int(); + m_int.mValue = 0; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 4: + m_int = new Int(); + m_int.mValue = 1; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 5: + m_int = new Int(); + m_int.mValue = 2; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 6: + m_int = new Int(); + m_int.mValue = 3; + this._mThread.currentFrame.OpStack.Push(m_int); + break; + case 7: + m_int = new Int(); + m_int.mValue = 4; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 8: + m_int = new Int(); + m_int.mValue = 5; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 11: + Float m_float = new Float(); + m_float.mValue = 0.0f; + this._mThread.currentFrame.OpStack.Push(m_float); + result = true; + break; + case 12: + m_float = new Float(); + m_float.mValue = 1.0f; + this._mThread.currentFrame.OpStack.Push(m_float); + result = true; + break; + case 13: + m_float = new Float(); + m_float.mValue = 2.0f; + this._mThread.currentFrame.OpStack.Push(m_float); + result = true; + break; + case 16: + int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]; + Int pushInt = new Int(); + pushInt.mValue = pushvalue; + this._mThread.currentFrame.OpStack.Push(pushInt); + this._mThread.PC++; + result = true; + break; + case 17: + short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); + Int pushInt2 = new Int(); + pushInt2.mValue = pushvalue2; + this._mThread.currentFrame.OpStack.Push(pushInt2); + this._mThread.PC += 2; + result = true; + break; + case 26: + if (this._mThread.currentFrame.LocalVariables[0] != null) + { + if (this._mThread.currentFrame.LocalVariables[0] is Int) + { + Int newInt = new Int(); + newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue; + this._mThread.currentFrame.OpStack.Push(newInt); + } + } + result = true; + break; + case 27: + if (this._mThread.currentFrame.LocalVariables[1] != null) + { + if (this._mThread.currentFrame.LocalVariables[1] is Int) + { + Int newInt = new Int(); + newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue; + this._mThread.currentFrame.OpStack.Push(newInt); + } + } + result = true; + break; + case 34: + if (this._mThread.currentFrame.LocalVariables[0] != null) + { + if (this._mThread.currentFrame.LocalVariables[0] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue; + this._mThread.currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case 35: + if (this._mThread.currentFrame.LocalVariables[1] != null) + { + if (this._mThread.currentFrame.LocalVariables[1] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue; + this._mThread.currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case 59: + BaseType baset = this._mThread.currentFrame.OpStack.Pop(); + if (baset is Int) + { + this._mThread.currentFrame.LocalVariables[0] = (Int)baset; + } + result = true; + break; + case 60: + baset = this._mThread.currentFrame.OpStack.Pop(); + if (baset is Int) + { + this._mThread.currentFrame.LocalVariables[1] = (Int)baset; + } + result = true; + break; + case 67: + baset = this._mThread.currentFrame.OpStack.Pop(); + if (baset is Float) + { + this._mThread.currentFrame.LocalVariables[0] = (Float)baset; + } + result = true; + break; + case 68: + baset = this._mThread.currentFrame.OpStack.Pop(); + if (baset is Float) + { + this._mThread.currentFrame.LocalVariables[1] = (Float)baset; + } + result = true; + break; + case 87: + this._mThread.currentFrame.OpStack.Pop(); + result = true; + break; + case 98: + BaseType bf2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType bf1 = this._mThread.currentFrame.OpStack.Pop(); + if (bf1 is Float && bf2 is Float) + { + Float nflt = new Float(); + nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; + this._mThread.currentFrame.OpStack.Push(nflt); + } + result = true; + break; + case 104: //check the order of the two values off the stack is correct + BaseType bs2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); + if (bs1 is Int && bs2 is Int) + { + Int nInt = new Int(); + nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; + this._mThread.currentFrame.OpStack.Push(nInt); + } + result = true; + break; + case 132: + if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null) + { + if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int) + { + ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]; + } + } + this._mThread.PC += 2; + result = true; + break; + case 139: + BaseType conv1 = this._mThread.currentFrame.OpStack.Pop(); + if (conv1 is Float) + { + Int newconv = new Int(); + newconv.mValue = (int)((Float)conv1).mValue; + this._mThread.currentFrame.OpStack.Push(newconv); + } + result = true; + break; + case 162: + short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); + BaseType bc2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType bc1 = this._mThread.currentFrame.OpStack.Pop(); + if (bc1 is Int && bc2 is Int) + { + Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); + if (((Int)bc1).mValue >= ((Int)bc2).mValue) + { + Console.WriteLine("branch compare true , offset is " +compareoffset); + Console.WriteLine("current PC is " + this._mThread.PC); + this._mThread.PC += -1 + compareoffset; + Console.WriteLine("new PC is " + this._mThread.PC); + } + else + { + Console.WriteLine("branch compare false"); + this._mThread.PC += 2; + } + } + else + { + this._mThread.PC += 2; + } + result = true; + break; + case 164: + short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); + BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop(); + if (bcl1 is Int && bcl2 is Int) + { + Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); + if (((Int)bcl1).mValue <= ((Int)bcl2).mValue) + { + Console.WriteLine("branch compare true , offset is " + compareloffset); + Console.WriteLine("current PC is " + this._mThread.PC); + this._mThread.PC += -1 + compareloffset; + Console.WriteLine("new PC is " + this._mThread.PC); + } + else + { + Console.WriteLine("branch compare false"); + this._mThread.PC += 2; + } + } + else + { + this._mThread.PC += 2; + } + result = true; + break; + case 167: + short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); + this._mThread.PC += -1 + offset; + result = true; + break; + } + + return result; + } + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/InterpreterMethods.cs b/OpenSim.Scripting.EmbeddedJVM/InterpreterMethods.cs new file mode 100644 index 0000000000..d2c76915a1 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/InterpreterMethods.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; +using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + partial class Thread + { + private partial class Interpreter + { + private bool IsMethodOpCode(byte opcode) + { + bool result = false; + switch (opcode) + { + case 184: + short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); + //Console.WriteLine("call to method : "+refIndex); + if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) + { + // Console.WriteLine("which is " + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value + "." + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value); + // Console.WriteLine("of type " + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value); + string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value; + string typeparam = ""; + string typereturn = ""; + int firstbrak = 0; + int secondbrak = 0; + firstbrak = typ.LastIndexOf('('); + secondbrak = typ.LastIndexOf(')'); + typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); + typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); + //Console.WriteLine("split is " + typeparam + " which is length " + typeparam.Length + " , " + typereturn); + if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value) + { + //calling a method in this class + if (typeparam.Length == 0) + { + this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2)); + } + else + { + this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2)); + } + } + else + { + //calling a method of a different class + + //for now we will have a built in OpenSimAPI class, but this should be a java class that then calls native methods + if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") + { + switch (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value) + { + case "GetEntityID": + Int entityID = new Int(); + entityID.mValue =(int) this._mThread.EntityId; + this._mThread.currentFrame.OpStack.Push(entityID); + this._mThread.PC += 2; + break; + case "GetRandomAvatarID": + entityID = new Int(); + entityID.mValue = (int)Thread.OpenSimScriptAPI.GetRandomAvatarID(); + this._mThread.currentFrame.OpStack.Push(entityID); + this._mThread.PC += 2; + break; + case "GetEntityPositionX": + BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); + if (bs1 is Int) + { + //should get the position of the entity from the IScriptAPI + OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); + Float pos = new Float(); + pos.mValue = vec3.X; + this._mThread.currentFrame.OpStack.Push(pos); + } + this._mThread.PC += 2; + break; + case "GetEntityPositionY": + bs1 = this._mThread.currentFrame.OpStack.Pop(); + if (bs1 is Int) + { + //should get the position of the entity from the IScriptAPI + OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); + Float pos = new Float(); + pos.mValue = vec3.Y; + this._mThread.currentFrame.OpStack.Push(pos); + } + this._mThread.PC += 2; + break; + case "GetEntityPositionZ": + bs1 = this._mThread.currentFrame.OpStack.Pop(); + if (bs1 is Int) + { + //should get the position of the entity from the IScriptAPI + OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); + Float pos = new Float(); + pos.mValue = vec3.Z; + this._mThread.currentFrame.OpStack.Push(pos); + } + this._mThread.PC += 2; + break; + case "SetEntityPosition": + //pop the three float values and the entity id + BaseType ft3 = this._mThread.currentFrame.OpStack.Pop(); + BaseType ft2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType ft1 = this._mThread.currentFrame.OpStack.Pop(); + BaseType in1 = this._mThread.currentFrame.OpStack.Pop(); + if (ft1 is Float && ft2 is Float && ft3 is Float) + { + if(in1 is Int) + { + Thread.OpenSimScriptAPI.SetEntityPosition((uint)((Int) in1).mValue, ((Float)ft1).mValue, ((Float)ft2).mValue, ((Float)ft3).mValue); + } + } + this._mThread.PC += 2; + break; + } + } + } + } + else + { + this._mThread.PC += 2; + } + result = true; + break; + } + + return result; + } + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/InterpreterReturn.cs b/OpenSim.Scripting.EmbeddedJVM/InterpreterReturn.cs new file mode 100644 index 0000000000..6704e31727 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/InterpreterReturn.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + partial class Thread + { + private partial class Interpreter + { + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/MainMemory.cs b/OpenSim.Scripting.EmbeddedJVM/MainMemory.cs new file mode 100644 index 0000000000..ff18f9095e --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/MainMemory.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class MainMemory + { + public Heap HeapArea; + public MethodMemory MethodArea; + + public MainMemory() + { + MethodArea = new MethodMemory(); + HeapArea = new Heap(); + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/MethodMemory.cs b/OpenSim.Scripting.EmbeddedJVM/MethodMemory.cs new file mode 100644 index 0000000000..2541991dab --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/MethodMemory.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class MethodMemory + { + public byte[] MethodBuffer; + public List Classes = new List(); + public int NextMethodPC = 0; + public int Methodcount = 0; + + public MethodMemory() + { + MethodBuffer = new byte[20000]; + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Object.cs b/OpenSim.Scripting.EmbeddedJVM/Object.cs new file mode 100644 index 0000000000..e6e392c698 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Object.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class Object + { + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj b/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj new file mode 100644 index 0000000000..dc08f3e625 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj @@ -0,0 +1,75 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {17CB6836-7500-4A3C-9B81-71D4FE564421} + Library + Properties + OpenSim.Scripting.EmbeddedJVM + OpenSim.Scripting.EmbeddedJVM + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {8ACA2445-0000-0000-0000-000000000000} + OpenSim.Framework + + + + + \ No newline at end of file diff --git a/OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs b/OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs new file mode 100644 index 0000000000..d9ee388830 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Threading; +using OpenSim.Framework; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class OpenSimJVM : IScriptEngine + { + private List _threads = new List(); + private BlockingQueue CompileScripts = new BlockingQueue(); + private MainMemory _mainMemory; + private System.Threading.Thread compileThread; + + public OpenSimJVM() + { + + } + + public bool Init(IScriptAPI api) + { + _mainMemory = new MainMemory(); + Thread.GlobalMemory = this._mainMemory; + Thread.OpenSimScriptAPI = api; + compileThread = new System.Threading.Thread(new ThreadStart(CompileScript)); + compileThread.IsBackground = true; + compileThread.Start(); + return true; + } + + public string GetName() + { + return "OpenSimJVM"; + } + + public void LoadScript(string script, string scriptName, uint entityID) + { + CompileInfo comp = new CompileInfo(); + comp.entityId = entityID; + comp.script = script; + comp.scriptName = scriptName; + this.CompileScripts.Enqueue(comp); + } + + public void CompileScript() + { + while (true) + { + CompileInfo comp = this.CompileScripts.Dequeue(); + string script = comp.script; + string scriptName = comp.scriptName; + uint entityID = comp.entityId; + try + { + //need to compile the script into a java class file + + //first save it to a java source file + TextWriter tw = new StreamWriter(scriptName + ".java"); + tw.WriteLine(script); + tw.Close(); + + //now compile + System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:\Program Files\Java\jdk1.6.0_01\bin\javac.exe *.java"); + psi.RedirectStandardOutput = true; + psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + psi.UseShellExecute = false; + System.Diagnostics.Process javacomp; + javacomp = System.Diagnostics.Process.Start(psi); + javacomp.WaitForExit(); + + //now load in class file + ClassRecord class1 = new ClassRecord(); + class1.LoadClassFromFile(scriptName + ".class"); + class1.PrintToConsole(); + //Console.WriteLine(); + this._mainMemory.MethodArea.Classes.Add(class1); + + Thread newThread = new Thread(); + this._threads.Add(newThread); + newThread.EntityId = entityID; + newThread.currentClass = class1; + + //now delete the created files + System.IO.File.Delete(scriptName + ".java"); + System.IO.File.Delete(scriptName + ".class"); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + } + + public void OnFrame() + { + for (int i = 0; i < this._threads.Count; i++) + { + if (!this._threads[i].running) + { + this._threads[i].StartMethod("OnFrame"); + bool run = true; + while (run) + { + run = this._threads[i].Excute(); + } + } + } + } + + private class CompileInfo + { + public string script; + public string scriptName; + public uint entityId; + + public CompileInfo() + { + + } + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Properties/AssemblyInfo.cs b/OpenSim.Scripting.EmbeddedJVM/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..53a0f08d63 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Scripting.EmbeddedJVM")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenSim.Scripting.EmbeddedJVM")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("087c0917-5a6a-4b47-a4dd-0928dd85bd4b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim.Scripting.EmbeddedJVM/Stack.cs b/OpenSim.Scripting.EmbeddedJVM/Stack.cs new file mode 100644 index 0000000000..d77d82e32e --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Stack.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class Stack + { + public Stack StackFrames = new Stack(); + + public Stack() + { + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/StackFrame.cs b/OpenSim.Scripting.EmbeddedJVM/StackFrame.cs new file mode 100644 index 0000000000..afca7a9989 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/StackFrame.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class StackFrame + { + public BaseType[] LocalVariables; + public Stack OpStack = new Stack(); + + public int ReturnPC = 0; + public ClassRecord CallingClass = null; + + public StackFrame() + { + LocalVariables = new BaseType[20]; + } + + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Thread.cs b/OpenSim.Scripting.EmbeddedJVM/Thread.cs new file mode 100644 index 0000000000..436949c1ac --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Thread.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; +using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; +using OpenSim.Framework; +using OpenSim.Framework.Interfaces; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public partial class Thread + { + public static MainMemory GlobalMemory; + public static IScriptAPI OpenSimScriptAPI; + private int PC = 0; + private Stack stack; + private Interpreter mInterpreter; + public ClassRecord currentClass; + public ClassInstance currentInstance; + private StackFrame currentFrame; + public int excutionCounter = 0; + public bool running = false; + public uint EntityId = 0; + + public Thread() + { + this.mInterpreter = new Interpreter(this); + this.stack = new Stack(); + } + + public void SetPC(int methodpointer) + { + //Console.WriteLine("Thread PC has been set to " + methodpointer); + PC = methodpointer; + } + + public void StartMethod(ClassRecord rec, string methName) + { + currentFrame = new StackFrame(); + this.stack.StackFrames.Push(currentFrame); + this.currentClass = rec; + currentClass.StartMethod(this, methName); + } + + public void StartMethod( string methName) + { + currentFrame = new StackFrame(); + this.stack.StackFrames.Push(currentFrame); + currentClass.StartMethod(this, methName); + } + + public void JumpToStaticVoidMethod(string methName, int returnPC) + { + currentFrame = new StackFrame(); + currentFrame.ReturnPC = returnPC; + this.stack.StackFrames.Push(currentFrame); + currentClass.StartMethod(this, methName); + } + + public void JumpToStaticParamMethod(string methName, string param, int returnPC) + { + if (param == "I") + { + BaseType bs1 = currentFrame.OpStack.Pop(); + currentFrame = new StackFrame(); + currentFrame.ReturnPC = returnPC; + this.stack.StackFrames.Push(currentFrame); + currentFrame.LocalVariables[0] = ((Int)bs1); + currentClass.StartMethod(this, methName); + } + if (param == "F") + { + + } + } + + public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC) + { + + } + + public bool Excute() + { + excutionCounter++; + return this.mInterpreter.Excute(); + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/ArrayReference.cs b/OpenSim.Scripting.EmbeddedJVM/Types/ArrayReference.cs new file mode 100644 index 0000000000..2854eabd3a --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Types/ArrayReference.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types +{ + public class ArrayReference :BaseType + { + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/BaseType.cs b/OpenSim.Scripting.EmbeddedJVM/Types/BaseType.cs new file mode 100644 index 0000000000..270aa7be7c --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Types/BaseType.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types +{ + public class BaseType : Object + { + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/ObjectReference.cs b/OpenSim.Scripting.EmbeddedJVM/Types/ObjectReference.cs new file mode 100644 index 0000000000..da28eaa8b5 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Types/ObjectReference.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types +{ + public class ObjectReference : BaseType + { + public ushort Reference; + + public ObjectReference() + { + + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Byte.cs b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Byte.cs new file mode 100644 index 0000000000..1a3ecfff7d --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Byte.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes +{ + public class Byte : BaseType + { + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Char.cs b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Char.cs new file mode 100644 index 0000000000..19002d44fc --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Char.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes +{ + public class Char : BaseType + { + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Float.cs b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Float.cs new file mode 100644 index 0000000000..91f1679293 --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Float.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes +{ + public class Float : BaseType + { + public float mValue = 0; + + public Float() + { + + } + } +} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Int.cs b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Int.cs new file mode 100644 index 0000000000..4ecd325fff --- /dev/null +++ b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Int.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes +{ + public class Int : BaseType + { + public int mValue = 0; + + public Int() + { + + } + } +} diff --git a/OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs b/OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs new file mode 100644 index 0000000000..66106068df --- /dev/null +++ b/OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("Db4LocalStorage")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Db4LocalStorage")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs b/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs new file mode 100644 index 0000000000..189ee1a614 --- /dev/null +++ b/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs @@ -0,0 +1,174 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Terrain; + +namespace OpenSim.Storage.LocalStorageDb4o +{ + /// + /// + /// + public class Db4LocalStorage : ILocalStorage + { + private IObjectContainer db; + + public Db4LocalStorage() + { + try + { + db = Db4oFactory.OpenFile("localworld.yap"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4LocalStorage creation"); + } + catch(Exception e) + { + db.Close(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4LocalStorage :Constructor - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); + } + } + + public void StorePrim(PrimData prim) + { + IObjectSet result = db.Query(new UUIDQuery(prim.FullID)); + if(result.Count>0) + { + //prim already in storage + //so update it + PrimData found = (PrimData) result.Next(); + found.PathBegin = prim.PathBegin; + found.PathCurve= prim.PathCurve; + found.PathEnd = prim.PathEnd; + found.PathRadiusOffset = prim.PathRadiusOffset; + found.PathRevolutions = prim.PathRevolutions; + found.PathScaleX= prim.PathScaleX; + found.PathScaleY = prim.PathScaleY; + found.PathShearX = prim.PathShearX; + found.PathShearY = prim.PathShearY; + found.PathSkew = prim.PathSkew; + found.PathTaperX = prim.PathTaperX; + found.PathTaperY = prim.PathTaperY; + found.PathTwist = prim.PathTwist; + found.PathTwistBegin = prim.PathTwistBegin; + found.PCode = prim.PCode; + found.ProfileBegin = prim.ProfileBegin; + found.ProfileCurve = prim.ProfileCurve; + found.ProfileEnd = prim.ProfileEnd; + found.ProfileHollow = prim.ProfileHollow; + found.Position = prim.Position; + found.Rotation = prim.Rotation; + found.Texture = prim.Texture; + db.Set(found); + db.Commit(); + } + else + { + //not in storage + db.Set(prim); + db.Commit(); + } + } + + public void RemovePrim(LLUUID primID) + { + IObjectSet result = db.Query(new UUIDQuery(primID)); + if(result.Count>0) + { + PrimData found = (PrimData) result.Next(); + db.Delete(found); + } + } + + + public void LoadPrimitives(ILocalStorageReceiver receiver) + { + IObjectSet result = db.Get(typeof(PrimData)); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is "+result.Count); + foreach (PrimData prim in result) { + receiver.PrimFromStorage(prim); + } + } + + public float[,] LoadWorld() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Loading world...."); + //World blank = new World(); + float[,] heightmap = null; + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Looking for a heightmap in local DB"); + IObjectSet world_result = db.Get(typeof(MapStorage)); + if (world_result.Count > 0) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Found a heightmap in local database, loading"); + MapStorage map = (MapStorage)world_result.Next(); + //blank.LandMap = map.Map; + heightmap = map.Map; + } + else + { + /* + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - No heightmap found, generating new one"); + HeightmapGenHills hills = new HeightmapGenHills(); + // blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); + // heightmap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); + heightmap = new float[256, 256]; + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Saving heightmap to local database"); + MapStorage map = new MapStorage(); + map.Map = heightmap; //blank.LandMap; + db.Set(map); + db.Commit(); + */ + } + return heightmap; + } + + public void SaveMap(float[,] heightmap) + { + IObjectSet world_result = db.Get(typeof(MapStorage)); + if (world_result.Count > 0) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SaveWorld() - updating saved copy of heightmap in local database"); + MapStorage map = (MapStorage)world_result.Next(); + db.Delete(map); + } + MapStorage map1 = new MapStorage(); + map1.Map = heightmap; //OpenSim_Main.local_world.LandMap; + db.Set(map1); + db.Commit(); + } + + public void ShutDown() + { + db.Commit(); + db.Close(); + } + } +} diff --git a/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs b/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs new file mode 100644 index 0000000000..dc5793ed7b --- /dev/null +++ b/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Storage.LocalStorageDb4o +{ + public class MapStorage + { + public float[,] Map; + + public MapStorage() + { + + } + } +} \ No newline at end of file diff --git a/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj new file mode 100644 index 0000000000..6504b77527 --- /dev/null +++ b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj @@ -0,0 +1,113 @@ + + + Local + 8.0.50727 + 2.0 + {E1B79ECF-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Storage.LocalStorageDb4o + JScript + Grid + IE50 + false + Library + + OpenSim.Storage.LocalStorageDb4o + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + ..\..\bin\Db4objects.Db4o.dll + False + + + ..\..\bin\libsecondlife.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj.user b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build new file mode 100644 index 0000000000..439f440097 --- /dev/null +++ b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs b/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs new file mode 100644 index 0000000000..16b6685c3b --- /dev/null +++ b/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; + +namespace OpenSim.Storage.LocalStorageDb4o +{ + public class UUIDQuery : Predicate + { + private LLUUID _findID; + + public UUIDQuery(LLUUID find) + { + _findID = find; + } + public bool Match(PrimData prim) + { + return (prim.FullID == _findID); + } + } +} diff --git a/OpenSim.Terrain.BasicTerrain/Hills.cs b/OpenSim.Terrain.BasicTerrain/Hills.cs new file mode 100644 index 0000000000..40543a998a --- /dev/null +++ b/OpenSim.Terrain.BasicTerrain/Hills.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Terrain.BasicTerrain +{ + static class Hills + { + /// + /// Generates a series of spheres which are then either max()'d or added together. Inspired by suggestion from jh. + /// + /// 3-Clause BSD Licensed + /// The number of hills to generate + /// The minimum size of each hill + /// The maximum size of each hill + /// Whether to bias hills towards the center of the map + /// Whether to add hills together or to pick the largest value + /// Generates hill-shaped noise instead of consistent hills + public static void hillsSpheres(float[,] map,int seed, int number, double scale_min, double scale_range, bool island, bool additive, bool noisy) + { + Random random = new Random(seed); + int w = map.GetLength(0); + int h = map.GetLength(1); + int x, y; + int i; + + for (i = 0; i < number; i++) + { + double rx = Math.Min(255.0, random.NextDouble() * w); + double ry = Math.Min(255.0, random.NextDouble() * h); + double rand = random.NextDouble(); + + if (island) + { + // Move everything towards the center + rx -= w / 2; + rx /= 2; + rx += w / 2; + + ry -= h / 2; + ry /= 2; + ry += h / 2; + } + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + if (noisy) + rand = random.NextDouble(); + + double z = (scale_min + (scale_range * rand)); + z *= z; + z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); + + if (z < 0) + z = 0; + + if (additive) + { + map[x, y] += (float)z; + } + else + { + map[x, y] = (float)Math.Max(map[x, y], z); + } + } + } + } + } + } +} diff --git a/OpenSim.Terrain.BasicTerrain/Normalise.cs b/OpenSim.Terrain.BasicTerrain/Normalise.cs new file mode 100644 index 0000000000..0d37f44d55 --- /dev/null +++ b/OpenSim.Terrain.BasicTerrain/Normalise.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Terrain.BasicTerrain +{ + static class Normalise + { + /// + /// Converts the heightmap to values ranging from 0..1 + /// + /// The heightmap to be normalised + public static void normalise(float[,] map) + { + double max = findMax(map); + double min = findMin(map); + int w = map.GetLength(0); + int h = map.GetLength(1); + + int x, y; + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + map[x, y] = (float)((map[x, y] - min) * (1.0 / (max - min))); + } + } + } + + /// + /// Converts the heightmap to values ranging from 0.. + /// + /// The heightmap to be normalised + /// The new maximum height value of the map + public static void normalise(float[,] map, double newmax) + { + double max = findMax(map); + double min = findMin(map); + int w = map.GetLength(0); + int h = map.GetLength(1); + + int x, y; + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + map[x, y] = (float)((map[x, y] - min) * (1.0 / (max - min)) * newmax); + } + } + } + + /// + /// Finds the largest value in the heightmap + /// + /// The heightmap + /// The highest value + public static double findMax(float[,] map) + { + int x, y; + int w = map.GetLength(0); + int h = map.GetLength(1); + double max = double.MinValue; + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + if (map[x, y] > max) + max = map[x, y]; + } + } + + return max; + } + + /// + /// Finds the lowest value in a heightmap + /// + /// The heightmap + /// The minimum value + public static double findMin(float[,] map) + { + int x, y; + int w = map.GetLength(0); + int h = map.GetLength(1); + double min = double.MaxValue; + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + if (map[x, y] < min) + min = map[x, y]; + } + } + + return min; + } + } +} diff --git a/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj b/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj new file mode 100644 index 0000000000..328f69de7c --- /dev/null +++ b/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj @@ -0,0 +1,50 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {FFD5951C-4002-4ACA-9ADF-68852357B94A} + Library + Properties + OpenSim.Terrain.BasicTerrain + OpenSim.Terrain.BasicTerrain + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenSim.Terrain.BasicTerrain/Properties/AssemblyInfo.cs b/OpenSim.Terrain.BasicTerrain/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..bd74993d2f --- /dev/null +++ b/OpenSim.Terrain.BasicTerrain/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Terrain.BasicTerrain")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenSim.Terrain.BasicTerrain")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim.Terrain.BasicTerrain/RaiseLower.cs b/OpenSim.Terrain.BasicTerrain/RaiseLower.cs new file mode 100644 index 0000000000..384bcc0696 --- /dev/null +++ b/OpenSim.Terrain.BasicTerrain/RaiseLower.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Terrain.BasicTerrain +{ + static class RaiseLower + { + /// + /// Raises land around the selection + /// + /// The center the X coordinate of where you wish to raise the land + /// The center the Y coordinate of where you wish to raise the land + /// The radius of the dimple + /// How much impact to add to the terrain (0..2 usually) + public static void raise(float[,] map, double rx, double ry, double size, double amount) + { + raiseSphere(map, rx, ry, size, amount); + } + + /// + /// Raises land in a sphere around the selection + /// + /// The center the X coordinate of where you wish to raise the land + /// The center the Y coordinate of where you wish to raise the land + /// The radius of the sphere dimple + /// How much impact to add to the terrain (0..2 usually) + public static void raiseSphere(float[,] map, double rx, double ry, double size, double amount) + { + int x, y; + int w = map.GetLength(0); + int h = map.GetLength(1); + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + double z = size; + z *= z; + z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); + + if (z < 0) + z = 0; + + map[x, y] += (float)(z * amount); + } + } + } + + /// + /// Lowers land in a sphere around the selection + /// + /// The center the X coordinate of where you wish to lower the land + /// The center the Y coordinate of where you wish to lower the land + /// The radius of the sphere dimple + /// How much impact to remove from the terrain (0..2 usually) + public static void lower(float[,] map, double rx, double ry, double size, double amount) + { + lowerSphere(map, rx, ry, size, amount); + } + + /// + /// Lowers land in a sphere around the selection + /// + /// The center the X coordinate of where you wish to lower the land + /// The center the Y coordinate of where you wish to lower the land + /// The radius of the sphere dimple + /// How much impact to remove from the terrain (0..2 usually) + public static void lowerSphere(float[,] map, double rx, double ry, double size, double amount) + { + int x, y; + int w = map.GetLength(0); + int h = map.GetLength(1); + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + double z = size; + z *= z; + z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); + + if (z < 0) + z = 0; + + map[x, y] -= (float)(z * amount); + } + } + } + } +} diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs new file mode 100644 index 0000000000..fc30af6841 --- /dev/null +++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Terrain.BasicTerrain; + +namespace OpenSim.Terrain +{ + public class TerrainEngine + { + /// + /// A [normally] 256x256 heightmap + /// + public float[,] map; + /// + /// A 256x256 heightmap storing water height values + /// + public float[,] water; + int w, h; + + /// + /// Generate a new TerrainEngine instance and creates a new heightmap + /// + public TerrainEngine() + { + w = 256; + h = 256; + map = new float[w, h]; + water = new float[w, h]; + + } + + /// + /// Converts the heightmap to a 65536 value 1D floating point array + /// + /// A float[65536] array containing the heightmap + public float[] getHeights1D() + { + float[] heights = new float[w * h]; + int i; + + for (i = 0; i < w * h; i++) + { + heights[i] = map[i / w, i % w]; + } + + return heights; + } + + /// + /// Imports a 1D floating point array into the 2D heightmap array + /// + /// The array to import (must have 65536 members) + public void setHeights1D(float[] heights) + { + int i; + for (i = 0; i < w * h; i++) + { + map[i / w, i % w] = heights[i]; + } + } + + /// + /// Loads a file consisting of 256x256 doubles and imports it as an array into the map. + /// + /// The filename of the double array to import + public void loadFromFileF64(string filename) + { + System.IO.FileInfo file = new System.IO.FileInfo(filename); + System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read); + System.IO.BinaryReader bs = new System.IO.BinaryReader(s); + int x, y; + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + map[x, y] = (float)bs.ReadDouble(); + } + } + } + + /// + /// Swaps the references between the height and water buffers to allow you to edit the water heightmap. Remember to swap back when you are done. + /// + public void swapWaterBuffer() + { + float[,] temp = map; + map = water; + water = temp; + } + + /// + /// Raises land in a sphere around the specified coordinates + /// + /// Center of the sphere on the X axis + /// Center of the sphere on the Y axis + /// The radius of the sphere + /// Scale the height of the sphere by this amount (recommended 0..2) + public void raise(double rx, double ry, double size, double amount) + { + lock (map) + { + RaiseLower.raiseSphere(this.map, rx, ry, size, amount); + } + } + + /// + /// Lowers the land in a sphere around the specified coordinates + /// + /// The center of the sphere at the X axis + /// The center of the sphere at the Y axis + /// The radius of the sphere in meters + /// Scale the height of the sphere by this amount (recommended 0..2) + public void lower(double rx, double ry, double size, double amount) + { + lock (map) + { + RaiseLower.lowerSphere(this.map, rx, ry, size, amount); + } + } + + /// + /// Generates a simple set of hills in the shape of an island + /// + public void hills() + { + lock (map) + { + Hills.hillsSpheres(this.map, 1337, 200, 20, 40, false, true, false); + Normalise.normalise(this.map,60); + } + } + + } +} diff --git a/OpenSim.build b/OpenSim.build new file mode 100644 index 0000000000..ec017266a7 --- /dev/null +++ b/OpenSim.build @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.sln b/OpenSim.sln new file mode 100644 index 0000000000..d91c4d58df --- /dev/null +++ b/OpenSim.sln @@ -0,0 +1,127 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C# Express 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim", "OpenSim\OpenSim.csproj", "{438A9556-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.OdePlugin", "OpenSim.Physics\OdePlugin\OpenSim.Physics.OdePlugin.csproj", "{63A05FE9-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Framework.Console", "OpenSim.Framework.Console\OpenSim.Framework.Console.csproj", "{A7CD0630-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.GenericConfig.Xml", "OpenSim.GenericConfig\Xml\OpenSim.GenericConfig.Xml.csproj", "{E88EF749-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.Manager", "OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj", "{8BE16150-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGridServices.UserServer", "OpenGridServices.UserServer\OpenGridServices.UserServer.csproj", "{66591469-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.BasicPhysicsPlugin", "OpenSim.Physics\BasicPhysicsPlugin\OpenSim.Physics.BasicPhysicsPlugin.csproj", "{4F874463-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGrid.Config.GridConfigDb4o", "OpenGrid.Config\GridConfigDb4o\OpenGrid.Config.GridConfigDb4o.csproj", "{B0027747-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Servers", "Servers\OpenSim.Servers.csproj", "{8BB20F0A-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.PhysXPlugin", "OpenSim.Physics\PhysXPlugin\OpenSim.Physics.PhysXPlugin.csproj", "{988F0AC4-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.GridInterfaces.Remote", "OpenSim.GridInterfaces\Remote\OpenSim.GridInterfaces.Remote.csproj", "{B55C0B5D-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Framework", "OpenSim.Framework\OpenSim.Framework.csproj", "{8ACA2445-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.RegionServer", "OpenSim.RegionServer\OpenSim.RegionServer.csproj", "{632E1BFD-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Storage.LocalStorageDb4o", "OpenSim.Storage\LocalStorageDb4o\OpenSim.Storage.LocalStorageDb4o.csproj", "{E1B79ECF-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenUser.Config.UserConfigDb4o", "OpenUser.Config\UserConfigDb4o\OpenUser.Config.UserConfigDb4o.csproj", "{7E494328-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.GridInterfaces.Local", "OpenSim.GridInterfaces\Local\OpenSim.GridInterfaces.Local.csproj", "{546099CD-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGridServices.GridServer", "OpenGridServices.GridServer\OpenGridServices.GridServer.csproj", "{21BFC8E2-0000-0000-0000-000000000000}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Terrain.BasicTerrain", "OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj", "{FFD5951C-4002-4ACA-9ADF-68852357B94A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Scripting.EmbeddedJVM", "OpenSim.Scripting.EmbeddedJVM\OpenSim.Scripting.EmbeddedJVM.csproj", "{17CB6836-7500-4A3C-9B81-71D4FE564421}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {438A9556-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {438A9556-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {438A9556-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {438A9556-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {63A05FE9-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63A05FE9-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63A05FE9-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63A05FE9-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {A7CD0630-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7CD0630-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7CD0630-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7CD0630-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {E88EF749-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E88EF749-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E88EF749-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E88EF749-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {8BE16150-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8BE16150-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8BE16150-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8BE16150-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {66591469-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {66591469-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {66591469-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {66591469-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {4F874463-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F874463-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F874463-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F874463-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {B0027747-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0027747-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0027747-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0027747-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {8BB20F0A-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8BB20F0A-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8BB20F0A-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8BB20F0A-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {988F0AC4-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {988F0AC4-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {988F0AC4-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {988F0AC4-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {B55C0B5D-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B55C0B5D-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B55C0B5D-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B55C0B5D-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {8ACA2445-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8ACA2445-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8ACA2445-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8ACA2445-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {632E1BFD-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {632E1BFD-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {632E1BFD-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {632E1BFD-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {E1B79ECF-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1B79ECF-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1B79ECF-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1B79ECF-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {7E494328-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7E494328-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7E494328-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7E494328-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {546099CD-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {546099CD-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {546099CD-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {546099CD-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {21BFC8E2-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {21BFC8E2-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {21BFC8E2-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {21BFC8E2-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + {FFD5951C-4002-4ACA-9ADF-68852357B94A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FFD5951C-4002-4ACA-9ADF-68852357B94A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FFD5951C-4002-4ACA-9ADF-68852357B94A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FFD5951C-4002-4ACA-9ADF-68852357B94A}.Release|Any CPU.Build.0 = Release|Any CPU + {17CB6836-7500-4A3C-9B81-71D4FE564421}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17CB6836-7500-4A3C-9B81-71D4FE564421}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17CB6836-7500-4A3C-9B81-71D4FE564421}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17CB6836-7500-4A3C-9B81-71D4FE564421}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/OpenSim.suo b/OpenSim.suo new file mode 100644 index 0000000000000000000000000000000000000000..e4d4da9c36312b69d0312a6b57793a24a7dea237 GIT binary patch literal 224256 zcmeI537i~dng1){Mgc)Y4uyb-3S`XW4gq8`nUEkMkqHEJfFzTXoX$+bt>V3axa)~{ ztg>Ee;fdVqOAFEAhI0~P>h z0t6_Yz4LfuLXvHVPHF;@!Y}rGT?IH3gAlMD&T71 z8sK%n>wz}_=kiNigOOkoE#Ja-lp$_0! zN{L%(;UY?3%cs7u*6vxB|Az$=Cs_G9XZeoa5$@_(#t014yJyqW!?gcA{;#1@I`mTLkIDws!XrytME|cVy;xqp=>H%!*haY12^^7Zb~LR^mOzslB8{mtl! z=zv|VrJpAuv55O^XWTb&)z7`{^nv<+5>nIvShbbfZ07$KB&z|q^?W$>05fPXycW;e z#PhXW`|~k79yX^Q!s`)hTIRFxxBO`2UiojOUGGg#P5>7q-@XEnocO?JrXTXlXP(-r z`{Hr)0r5ru{z|STJL~Z8iyB`DNY3`}t3ARy9sd1t{96pZYn&wqE-%f6t>#fvotaca70#zK>Am5SS(Gizt;zhHJp7kq`q#i$tM)igZe8{vB3F`9A*7r>%ov z`{vRw`)yvzGjW47N;HM?B^#;Vv$p>Wy!)MZ@{c2}e3M1z(=#JL($PivqGc*uN76gx z_YUO7QV~Ip{^0m$J>7HCJN|y*7aqIy!RLNr`9Ws~4}I;|7rgzrul9ZRlVMqnjau#p}YJ(|K_H=3UQ z>!`-PFL+SWsq~|+!LSEQ^RpldTC-CcwhWanCI#; zTD{l@=6~J#*H`$3JC1fgvjiS@DKd#<6<2mN$IlNn_*iij7spY)bP$LA+3;VwpJa3$ zy|i8$;Bd$TB@LF>!o64Rzw|%pJBI*S=bul1jLL})Zlf+5VNpZzVD){v^dX&T;sniS zP$qNv*TXjs)fYHsgi@?#+msrg+&j_#Yrwa2sh{LZ_23%p3q9b@70lmWaPB;wuVr?t z71C$t@#bnuJPpgDj=3SfyNWUH;r$-u>FNA6R-cHQ)mxY8)aWWKN7JZBA2eqkoM?WH z9+CW?{HMNI4KBG+luWXn(OnWswbla%&;!z<vgq{%pnptYLxp@|JZ!uh988g&reyhP} zpJuHYBZ<%Wo7yBkmd+c8ss9jfIURBf-;l=A@7;}PyrfTSuWU`S&v!KRlVMHu>WqiDVsh?W6XqsQ2nnURjOB-LUeC5CbI3^w3JlBUgl6M;096>lQ|J z&1h@IUmnXBufJ0e-SwmtR! zT(!Ae|5?nel3l_1R-`rg`cV&KITA|T)&nEUe)RA$u^y;p87^}BHFrfpBl>y4_iw#i zGHHYX>6Y&$!NYAH|9nxy>U3fNZ}4U`AUh|~kndc-=`gb+IbE{${ClL${U7HBeyavb zQk#EoK3sk}Gj0IgYE{B>n}m|Fet(PdNvj_WrR{2-v#&Q; zel7Z1i~hv%FNu3Q-NEVAvTMm+VLiOpJHCI*Ua@x9>p9HV{7Y)TS&`#CV4QJYZ~xNs z-+P_d{^-$#FmvX-{$9nh~>65)3 zzMvw#LzG|*_DJ9M=%P8chSu7FvienyO#Iva@9A^-apt_U7v&AtdcZ8%VfCztx;K5zXl&V_9j1iAEP!ed_6b%%kTd zk!timU-EBd%Lhgyx{~SNU2Pq~a*CEz|3$>6$ww*gs5EGK2%JV^qc!l_AKs!_A93&O zF)eQV?U&BIYuWYXa#uS4&zJU|P3K)6_MyBHT{*KpRIh&=Q^dV}&HaV{J-1ttcM%3; zjdODH-^s6=ds1BQl_xEW{Fkr!U%mg5e5bOP=0krl`*wVO4^*A`kq#kD*j9xueCfHj zUl*6^6@iTNkK=AAitPINXurv*#;2VBIilUZRu#2fpX{6d8%E7;{K$p-U0ag~s!=(V8#E zlXed8E+IOsANmoGCRG$)7tj09KnC!dy7*JymcAqOO-go9l^u?q|e?LJB&>@0xA%TsYDo{jw(Pm#v|k<>ZX7zVesfjYkW&SN<-q ze|S1%~--ZJ2V(bIuku^ErGYa#p_dpCpRg6YBVinq5R+NZQe77vXEY^4^y{ zaB5tCh2sQt*9%J<7fuUZf;Su*5=>5`Gia3TJu;q#vQqD z|Dr@Mg!RH%@poR{r09k7 zpazOMT?v;~{Eg#xkzB~+Pd$jg9i^p?C#1d}KJ?>X7cw_p)Q_UPHc=bj15<6)K~zSg zPFE>E=onR=zQ)BMMWikBL24S_AB)NMhS%+<F#;0|1Ti^S8}Fe zYP0sgc(~S9>acaLl3s`53;js4;th(~RaAJb5g1GRpG{%Qf5XCIotbpH3EWlavX z&u*|_GFRP+3jQ58P0?zLB$V_)kmM@8bM!;60`5_i=tda8v2}X3if3K2*B?2 zP3hWx>vvrL9{5A){{L{^3v|$ zxu!tYkMncd6GkaSFJ!@qEDzQT^WZO2p{@&no(5vr)eCb*dtp3mKv7#nCsqDyM$2!n z?WY_ctN9!%$D?`c8_WZ}EGKv@MZ~1Lo!9`K{htmwpqa%)_1?96niTlLA?e{_Pc&Ns?cANb+Ud%-v$2ps? z=kSE~rhn6Kdr^6kY<=aUT#b+U?Jbrh^qhoN#$_hIZS9b6_Mrm4?@O|d4)MQs`rMS! zz^|A2w>p+w&ULx-VnlBp7+6<9Y6O?mUsFS)*ICV1v_N_|fo4Dtk|R=$$q1*K=L8 z`65rIylh&)Ix5%w)c#H}P< zT)VZ(VNy#@UPo8tNlwnvDqD>bw}VEq|F#0QDc+V|G)6^+ui~uyCByjD{1tQJxkVhg zcq`*=GFh)3{Ip!&Y)2hn%P||6>ZBuyr!V^bjZeC#?*EA_JINzYuO10zvD=k=t@?M& zDj4VKKfCbAa3yx$Y+u#e(Y&@tJl%RBA1k_(_^RP+eYUUay%=G`*lk~Vvl3NrZGB=8nZyZVI6Ay9{)OJ4SiGs#`KU)9j zuOO|Ip5pIUt~m8`*qF?4H5Bx?2FI}*WI-b@~UAg{xzN_R;##A=58&`x?YTkm*SUOEe1C)R;T(}>UM?OO4gft zZ1#E0VIU{WQ5;KlF|<;aV+ zUwg(%+pqmrsc9iLui&DclDbi&@>PS`?UfyEKZ~~CUaF;46!G<~M%Tn+baX5d@hrS! z@#zoFf7=q*o9_SA{hdWZj{bJe@$$JH_oNJzVtZwuh(9UcM?3D(h`-yF=~t4i6@S|4 zAM)@i8(+MC@@mOQkFK1?Xx6f5SpNU9;n3LQEic<8FwMoSr_a~OLh#yMqRr`X2WB@Y z_BufEVvC7vW*+{$$j_a1zmgQ|$v1D(dF`I7-_Ka=xpFvjC0(v5k3HlI;gL5Z|ilO3|UpTABw*(yYDZ``6fge|3QA`;{K9__w}DH=GJ0*v)c#-x$=!>zHp-&v>yhs<( zzwOlh{b*IKkS~{R)YI#p_sK8zLS1jIX~S%=l3R9eWa3Q%lD-Z%n**Y;N-d z;gRI^sTNOq9^c3lu4Twhyf^e0dIg-p$D5olDK5 zx1!DUHVvhm+qK`8(@wd@*JJbIU925<=hwR3^s^qkiXu`e>V23CU z4s{|ttLdxep|M?sAl%_0?o+(krg5%K^Gi+a=)FPX(UW)Y|IVANKXrZ`%5$F9bDEYE zk6F_iwDs%&F-#BC7cZIoy|~_Nnr2?sbGD-oim7*JS=X7|n_X2fsu6wsQsz@T_3?5_ zYPhc$M%j|=x_l0$`+LP%HWajF$t`xX-*lg1M`%gfHhHxZ&Dc&UTk|9@JNHF+e@U<$ zi`Gik{<`(sm*555%39zp*j+}jbVXW^Fv;dbUNnVHMCM8?s?H|qM(S`zDV@%zMPwEg zKaZf*_2M*N2@lQ7cF=`tSzw|l)M)pXi=H*`Wvj2wzd683<=65#PZEViy=f=5kq|G} zLR$v;B>6%%#?2vhS(D(oO8ahC?7PX*`CB`E;YFaD&Qb*LSQjIg)jL)XmN<&YkB3J+ zp0jOyqp0)BpJmot$$p@`tx2-lW}zN_D@{KcAwEL9a7Xw*@^>j(r>LW8ZA;$c(&Vuf zZEj&bcJ%n}FTRB7^pxht+IIXioru+re@6RhTozKr0XVH&K|YLkeQfLCYWw&){+W({ zMi{phZoCoR)TB=Vw`NLS^68nz-=5^MeIv+U6X@YsPz*a_PRL1#Lz7yB%4qN+{ z*@IWzJ7Ej$%#-|9S?~JWR!o1&ag0P(O|7z*OxEK^!lNFItlcrIXt&xNsCof^_@;)0EjYbkCufJSTfHqV{%evgfkzQMb zIpMsk@pw*)QjJ=YH_vF&?6zE~@wUWcQ!86GPykF*izKgFHnM13iZR#CZj@~OSy_M) zScK(jFdT(#aEw0qhKtHwqgzFwzmm1w3KZid zm7Kf??U=`U8MS01^Fci1Rm_YvAw*QTSUf$MMzuSVISVg54~nGqOHt3~ZJ+5R9JvQ71GVu@;Pcp5%ehE-&vhT6+uRf z%epRkl>Y!YkS7811~FZ0Ph9f2fQDUSM6ZnX5fRshky?Q9|8Ux_$cr(;1=L7fR6*80B#391$-L#OW;;O z=|4XU+y<fi~ z=dDO+tI05?ID@s^nT#)GydxN>Dvpq)mIV`PuYrXAhJq@aq}DlwcOw17<<@;yu#%D&D7$>Kb&|?Eb%bhKmx} z+Ge~i*Gr_;%F`i=?`u+(@f6kGbQ0P&xQ8+@?>}L$qt_5IGO~-evzXB%FJ@G-Mvqh< z@3BYqYf7|}s%OW37da=nNKqv_&}~NmKl4;^Fx+p;Fw&iTPx5j)3$?OrmHR&RY$O&l zv$8NF=i_aqrLj2eaGJBTzFRJlNWWiSnDK}#by|TIUG*}b2C;Jc9`;>lPWdxxLD6GGW2dKH(Z31uPID>%zhu${o=yZ-FXxjL7%mjGit%w!nDBW zM;7@cezPHr*o<1VsW2^y%N4S$jEu(KSIbRvmC`?OC8karLttyDdqd0WVpF@gqt<>|1gIkJr8v>i0?W$7K zD-Ol>N5!`_^oIVIa%?MpyUs(GSPjRO1RKqwVz#S4jA*hPE0QBdLajDx*S5mYI3Ev} zBPk4penDS0ip#QoB-*uwY-KH;D}C4bM-|n1898vI_pavi<|G$n zml@x;pkxJ$n(MWA9B;AO(pRa)l2iJL6SRDIQL>a`3tDB zwcfC^>y`6!f-l+P#3oQ%K_263+Z|U~J0Gv#d&P;e^J~2#C)ip}-O|?f#v{tq8b{sw zg4z7_K^bSUi_M${soUE#_l&brXtm;MzH?fz2mga$Ztx2JUlmf8dDLhQpL(fVL_g9$ z8C9|KHSpp2Q2SL_N!A5dL(8||NuI=SE+s!m7qP`!2Hp(uXWF=1p)H9e{zQ4E^^UMz>#JPeLmQ*BY1j91)vjz~R9hzuplMqD zk*6`M-nKaRsvWbS{O)t({c;FyHpJO|wsnnzqqOlNTKTKdR$j{0{i9dySP2xzKbK!VITGC;%Sz9`(UrYu z(cJ}XQAAg)B?r=y#|qezTHX|E-$}IZj$E}bDGx(h2D>15A#J#^)CTR>GKe%OyM}z~ z!$`Q!Pc$i9Q!&ClXFHVjP1fuIZ}oK2JL0FCna_@s4h6>}MK8kYF@xDW139>xC+G8< zq6C&lAqY;TP7^2OiH>EX&$aNTJ}+EA4{Pmbp86pPzapD#Jkw2pG^I78d8&Us{AigM zD{L*Zdqx4|-}rH1TPXW^CC3%6OQ#&-skL)}cIHbSjOS|b=}`QMS>gteY0rc9%r9j! ziZZDNtRU7}J*;6=3Op@Ot0qLtzW(N($MDhQ6- zg>W(+sgPtNIGNVwi@r#5$z~&nzgZb|5}@G(!B=vHp-Ft)G?IAk!vL9088IBa7%vI2 z8yT?+a1x?shwPkM@3$KJt3}%dfmWdBOT&nBpDcVya`d*)np>WGi0mM_n-|qNQ$)?O z`R0S*1X`Cb-Mt?9a0yln%bH_yl2*dqp8J`el&>oY4l3kmXushg_`=`)HYkSr!V zf{=PEHbl8#e7lQpL(`}gb+q>U=7TTUJJ#Z{(ZPIKnv(dETd^SSv=u*_@?fs<_7cd0 z#jhT!VH%`pq;cG6&7l9(X=g@Rv^L|eTv3+loWRzYXpL5U#kVr(DPf2gsI2}X#ZXS1ONuI+wc$KG8|Fdbw7UqcbC9O=?YCy~P5QKj5M{=iw${h@s; zpE8Z)D-NOh82J*b-~J@)g5t08B^e}9^jdj#gWx%|2vtE2Pb@+C!=t=cimu&@7 z5WIjk-C2+}nJiwu-a82Pr4>)*sukrjM--P8e-f8Mvb<&3_)6ORyBHUsnk06IkJ5EJz(Q<6m2X*l!&$5*L$rEN7IIUNriqb#ksWx(Z3hh*ejn~%l4;b z?UkNjPA78aumb|X1m!b}(>QbO|fc0Tv=S@cVv z7ZT;JJ1$1vS!#Q!XECL4MMM}aD9?`&uzsmH8ep8}na*UGv>z?Wmscjv{axhQ7O1d1 zfwJ$%pZ9=|E=QrY=uBFaFKa|~8PwPOhG|K9j?<*IlRHJNF zDP6hCC>nKfE+-~k zJdcOsU&?a&&D26V5 zJfF<{*_?GxOQ1DYvoXIY75pygPi_jccld zOA*FQVSF@F)4_*EaA^>nUkSbl4~30dw73OaG$pY47}N;v{IP>O(5Yr_l+y_A_!LK< z<0k#)V@~(fMsVj39o)$g?!@uVaW==FTY)!?@~jT-jB$gmMpooI!D9+yz#PPZ`60V= ztL&rI_eq~@CBB`rtjOPooCG~cC|8xlo#vD(xxCR8`OWMFt;la=L?ph?3k62yl5he@ zt43tP=!i74)MkuGGwajnh%8_<=7Y0yfbLLeo{muHghL6^%F-=Cx`(%vUqb@-Y~G!U zh&=JluCBg_E_mx6U+B(=-QD*I%u<2Y6tPU0omOcXlGspfGx zZ#-3cE3N#g^i!>a@<*dqvzD)Qf!do+TaPY=+;X50#d2Dq^P- zK^svAD(%lAdC5sZmXt8qxe=RhbJI$EI|*?jR?AA8xy-w|Qn6FGS+xQcqRYbDw#9{T76)<1fRq7du#V8aOcB0R5C-A|vZ80|B zO<}8*eIv?=?B>a(ybV|zlYwnB%JygW(w%;RI{`mEZ`EVUUnv}V?) zQLCnu?;h;sGw>qxF)m5HpLEYg!p`-LNHa@q#)vetK8=n@^Y*K#ZD)==Kg}$)86(on z`ZPKs&C9W0&xka$)MkuGGwajnh%|5al6pp@nWZ*kM4DNjMn_~O++5!3Zg~96apWV- zE43LT(#&3HbVL+XI~zSp!NKBhNnAYXo^fnLS!y#zq?z?;bVTNrA~dgHe*DZS)WEnL=zgCZEVUUU(#-laIwEtRS+h%{ z(F^5D>iwj9HWGHOZ$z3|YBNTpne}OOMCQTQXJB=i!c3Xb;%LoCA8BT(%@~np)~C@C zkp)HZe^W!=K4YBbNW9bl*G~|9wyoB<@)g`}kF;~K$PHqfimX>=k5i_~d}XYTub{29 z!d5GWqxHAeD($^E{;N(`gLTb!FqH>o#B)4%L4mZSDQU+j+ZQuF*Oe>Hx7cJ&~8aL(6+2 zPF<3Ep;@w{dO;br9X>2)w}f-xvrB^Ic-TY}gzs9~s+^u{v9x#bybnws03)3*N-==) zu5IMr4)}s{cx$JZDQFr~0cGk?D2bf-@?1r^#v?2jrmH6MT8v*!;^o`^!-^u!!|bTN z8>)5;to;@*g-4$7-7>XA*|fE|*zOv>A46VRnmek>KV@k>}K1Mw4nZP`+ZP6?xk_A-DbayE4awxI9K1( zv@3}35}Y*7wZHB6fpSgcu@B;MbG6;h52yC!W1jv^zwO16OO(a4ysdEw#&28peV%t0 zIbZwnmG@s(T|qr-(o=ioxMx$7WJyo;)6p&oZy(C`Yv$KS5lfEBjEC$Sr;%Eb;MdD& zsMSvrX$1Yf^LqQ2KKPNp`4L|mJsv+={o3FAHtw{OT9)H){d?l1|3a6y>ty`5O+s`w z2}{It^U=o~{IebRPPn1dFKBSe!|4(fbrClunRF?Wq0F>S7M5129Ny8fbEnpn zZVmU|(XOKY`u9pJOB_40;Ej_^t-Pd~>}e0Zv#8k+*TtT7ZuTf^tIKOz-h09wwRCIY zTWT3wmHtYLTNYu@j55!ujhhPJ#%lXrs&$(S-#Xc#lXp!s+s%qLx3M0}X0m=P-tTO_ z&5J_Q=;uYFFm9c0&rvT3RP%O9XnsA4V^{KPT|8@vYVT%1b8Y>3uq_vB7Iy5f^1|66 zTC{?TcFKE=^Oq#MTy5*E-v`B`DD~T4+d(UK1uKPg$pb-_>QN@?dZcVfksdjh-|55e zejdB;>8P$#mU0Nyp;HFI%lSpqDWm#!^htkpWn3G~va@kVpLBL8af^;Vsr=#ce2z!F zPW`yr(I;KRYEn#VbkCw%?R-tBl@&{p^);f7KIsyCn=Dy70>SUS;z@rUeX?~l*l;MD zRi~p*cJxVYhp{G<=JiifQt>ECN1v=O;1j~_;52J6Y_e$iO=n{$C%IB zc5Sn$H``azd!45?>D$TP?!3g-Sk2=t8c1zXGy9{MUT)ta zQO(Pp+_SZCW$YgAym$?h+g%HzG}r8#{w#`g^kTO!-KX90igvWv=B(L>b8ufD?07|O zyS2%6Bu+KG$>ayiW|!oNiB_q!!YkU|m{A{-+TnAt@{Lj!%c|AUr#t%e?x|0=mukt) z7?0adTGJ?fRrZZ`(6x>)IS9tnmpqxVPV*(34ieXgJ6fBslSOusj@Gto#2Q7Omrg8e zCzjRUIKuRwj_*;MQ=4Z!>61OPv-7^USN<`rsa?{ImEY0Y#&2u+>@!y0vD))m(y@+R zgVS}QYBz+rT`KKYZj{|Px0h;lw6^RydgAupv8+>m-~%gU8Xi3!dx3DEzxVar$%Dt% zEUss=)^r1wTdf9EhN2N)L+k7L)jYKI zFIf6|s+D0()&~7a3OtF?#Uva#pux*RR&&IrR^h`cq(dJf~ z?3%^f<}6amcBeQs%hc7eWLQ2*^@L>hP84+~idxzI8_mGk4(~|EelY&Kb{h?@Z5im; z531?X<~=g*1St*=(c?}Ob+hx-I;p(lNgZEL>PcX9nkTiRU1hOVMAEtGARX;${CQrv zzG0eDZCg_`e)gS?c4Z#0>|U~BMe~_d+R?72hCb2h*k7|tjehSHPZm<`TM^yc(XJvK zviPF(%wwIH+D=UE?io|t4qCA*Xjk+5TxRAU-}jAUoj&gV-#E#6Jg?z04<65QNm4tz z$jjM9b|vQn^<~V+-&y`N{d>vY&NuGHeUMjAr*ayv2`&esW9QD3xiI~^nuoJqjEI-w zms>5b@>*(9ea=ikT$%{%0qhCv1?&y%1MCYN3hWO&3wSp0Nq+4>&IbX{0S*QZ0iFvy z4>%n-0(cQ{IB-00B=ADuV&M6}(ZI35Gdp+g?BaYJa58WL@M7R4z{`M_0w)50MVTjY z-U>_xUJe`sOaZ!qslYT~Ixqv63Cspg1Lgpy0CRy;fmZ-$0%rg{z(Qai&`4nAKFyb-txxEim;SF19i9GWo zM9R3h7_%x>_iV2!XnU0tYy)@|jogNUw!~RV-S{c7CxQiZk zv}{IHdwZo&AEP_Eb0-3118Z8NwM?D(`c8cPn!qx6o8}_!*IugC(VeH_otXm6;J@}( zo`t6~ZcT_=+sCpl{{`>;?#_v4eDkcEf4KfFFIxW9vyNm_tvs&FUlz*#+6&rwc zn9qak4<=uvJ&EE}Y-K?Fc^CVKC4Vy>sdD_=A2{y8EAO3Pb{fr#tUF`7Ii!7~w~|Q43$1B zBqdVfRL5!5X>u@!H)iv$o_4drp6c4id#au4*G-MC4oq>jN!6dwV|`^kc2;nHu$Uej z`*-70@@mRFh2Psk?`!dfHtQb0gh!3w%rID^BqAHBvk28@THxB2N8I^U2X{gNc``Fz z0WOW3of^R%XFOg5_Kf5hXZD`hp*K>h@_{qrVI$OLC=?*pls=1VjRf1dYvD}Ir#_AF ztbNCfL#^0OvXMDE2w#$rIUGs~3QQbov9!=gzdzNX_c@~Xk*v@v384{OdG?s+Xh*Kp zM#@rIHzV&yru9bX%m_-QLUEOvZY4BEvgH*a%@HpWz2Ab|&`Mde5nMX7gG)K0J3cPS z>>xbdfV{8)DOhqtglSH?Xccwpp4tdb1s$BqDNd~lC87wET8BT4+D;Da;80F+$k&C% z-NuK@HA0V`LAG|by(w7Q=3sG~kB(?d3(`N?TXs&e!&xB9qEU^nwdrc}WrJH6@~PFb ztq&tol}85oV%CySP})+8f2_>mvWU2kBU?BkmY49keOw(TJi^i zb7_xjjdII46PF{&YS#{o$*r>1H-EHfh}k=Q?B7Jg2E$<+VCd|#)62z&G?YW3bTia4 z%UUC}<2q=^Y^?M1KRpM{jks>a>udOde0{xJfQSju0PW`!_RX?>&^vhh1^=r>`%#o zQjCUNUhGx%>y0E@ld`}{^4A;-;JAAD6a$0on+(Rv%F0M zIG0x<)%7b(LX$;Y!Zo}3ehqo#8{y@*hrGOpj&4RsX{A5Da-)?>{$BY`o_Kt@9W?Tk zTWFdBH=P`}vBc(I3*%oCLaWBTGv?*QqLn_*q%oJ060tg2w4LPV&2{AjnMfpz&dUFy z{3m+@mj6Y$Tm1Yl2XL)-58`b3Uv#bfFUl3895A|8o)_hRQ7#x=AI13vfbzg7zl-v> zOahJtjsx_La>XeB%L%1x<$qBg80COb{ukwlQT`X@j8P7lr2H@XokouZ{I+t$C^wAd zfl&^avw_8ca>CS;|3!6D{uj$1qdYjuC!_l-Ij<^xw)`*F2IYTIE*M=aAB=LqY%X1I z<*eK=$^)b4!TS-T|Pg>-AM*e++7cEE#Q;l^JeqzR3h?b5QR67XL>Km z-k06LQ?A`-{brtJ0txd`sBahYfQ9nLpD0Sxe>0J5G#P9Bn9Xa(6tnpoYGk%vJEvQD zqNn!0orOE6A{r|~QpORdPM+RSB&UEF)i-B`pg7m7A=Qn_)%P&pW~SL6W>M8zhwKlcn%WW2QO{c6aJk`rQF_g-3%wMS zQ;?okdCSee4hk(KtbNG-BYTF~ENXwl@x(0eWqn8Owj=9zn)#lUt#iG`$+u z(2Ier2!zKp=u02Gc3#MNBdVDG$!MjWllX0QVXU0LR(mtg z{B#HcWu`{o#vV5{I+07UAXl`^zS4-y_4$r%1^iDlac8lu#Pw_$);6?kw0&7=Z0lPl z5~DE_c{!Z-Y4oR?S85%ie@F4sOM$HP=e@l9v(gWzm){!t{{hPWL#Fa;d!W>Q<2_m1 zuk~n8Why@#{XdT1vO1K0Hudx>o_@3R#t34rLLa3anl0eG|9#0flo2P(Z~i1#`mcPK zQG5J7hvQEoJGlFFHs5mY?)ZDwBTv2bgMXzpwUs^cgIu-08Y7J}CEqA0_rH7vasQXK z`}OzVa#$P_HlvpK_K|$~KeDyo_x1Eu7)8m|JUs9Cy~;*gj9i+@=8`eO?O3@ac(fqn zA6b1A1fY;7g{E#vl|Q>-6SWS>pU0H-Rju!==7sN-UP`0?wM)l_O!F;U0 z`)G#pyHUDp9cus4yi`dUs((|FPg%;JUHvCUpQ!!Ea;41kS=)at?>Eyjm)I4t=4e zvI}^#`cm0@3ex_i;rMQ(O-Z}gkthFmhrZ8jC~ma1IKpUNoaXxia}oXjJ& zEB(2KpL?wIlWFDGmVQI}KT3PEmj7DHej-EpwY3k&e^l;~{9e}b|B83Bv|n*zwT`j$ z|0aIa_>bF}U3u);gJR3YAFYM&<@I@}Aow4bf1;~OzW1WTuKBg330Wx*2Q;cW%3JQP zAJ0|$vxl@t8c)<0e#D&d#(j3YVXN8plX~IyT(#fl@_uWg-9)Tir@Zjk2bBdT9NKVn zvv7Nt{mWmd{$xSg?*f4;;~zVA-#YDoLx@GS?Y>DWwtr7bn9ISUsI1FE6N~~*w}zrf zB%U~Q&0kF359B*E8)65C#tnz!mgXj4N1FUKivg~6NdFZLRi0&?YrU`M2TllrACz89 zFTb`0z{*$II=`5 zQ}Z#~Imy?&6w{T$^_0|5yj9`tTL8H=hPW>GILF`bDtq72)qJeqD#wp)Wi6HI!f$E( zdHiV;_ywbwlyk2U-1vEiUW_ZfFqcnUmRKL+QGCf${^ZUlJGhbqToK2SxwMs0Ese)H zbm&TTvwbV%kYu{z*1#yHI9f`WKf3Znhpx1ou0$rNZSWdpbd@tI&UeiD(i#kDEH7{v zFWs?uK=-pOjVYH~v*|S}J=a{Tq}4`b)vttl%r3MRH7(Ceb!)osOhnCf@RU_UAo$riwt)yV( z{5@%&Z-oph%uq|a6qY-!#3Y(8-8C}Sw|3@ro&Kw&u@-AB4-RbpI5)cH@!K6eujP7P zWd>XcGqTG!A0HZ-_jh)1Az0n`1|8+DmFil9ldgv$6N) zT4GUD7C|J^CLO0MD1YLdOLjND+j0O=4T8L_kBQR3I6Wmw2{2IFqgQdiL!lm{HV+UX z>jXA!=_JK}5!y%;J*|wFiYLrd77*!FQM=Oelg8il^(=>#YMoXq6ti^;LsQMB(K$B1 z@9aftk=8%B7A@Dp;bz-&oNZbAc*Ik!G@tr6uG8)Iu?mY==P)1l_;TzQa+{0R4MCwr zrPo3Qx_I74#@_+fLD=?NQBtuT(75{cSyb4GKzMk%hlj1N$9zy-G5=j~olX4tHBqFs z&4||5BwoJF%J%d|*>b*C#H#o<-R+pVw0uzhpjOF*jp_)GcI3jA=m>F(fef-ErL?RY z%e+9X#Eiy#KzDa=V;pcpQA-j}TZadY=#6g&2RgaMry~*!hk~{&d@d{c<*0O<_`D4v zLM{?{cejEstsBQi_bchl=hnoC7*4n)m72?u%Ge4$ppp4}SBIvzgr=Jw=<-WDqfaX- zK?eu4+qR;eMVFm5el_yF^zf=a-Y&Ge_-5U<^|b6f64T=wp~~BDWIeLoU5NgauS@_* z+G;$oM&c@7JrV6iZ_DlU^S|fA75B{-rb5f9v_d_EXRL z;I*%PZ|oqKx6w1?3T8`F|dp=p-j1# zD2YDz!>Bfwyb#JUBQH^Typ!@Q;YmgmvW; zDgItp5G8hqKe1nMBEjg|HYHG>#*)0rBv03(JT1#p0`+M$RjH_zuDUyX+Kohzv=Ox= zg*EsFw-fbvb(l}*ieM7oUP^xXE(A}_;1R^p^?XwPfgm_7&@MtjFgIMa+QTzNO-g0# z<^6Tx8~X;@jX-ltRA6N&(w6`FT%IUHlUqnXUX(0u#_U2qu9gtMc{*;Veaa^#gJ=F~ zt2#NQA>OV=#DQVP)6c@F6bCN5V*JT!ux2{Xl)uc2glEpFekC?sou8R`snexR1+F?4Leao{fG+VVJo>Uv@&LCX5wI4Qd2(xcwD z?W%hxI7|Q~IFOlpm3=0i4ur4rPx)NLSyzEmTc8_P1j_2RjBhJoU-2bwoqRX6ZVFUw zE}&1A?)Sqr(2cFkF)o$X&Y8l zQXTfRhu&G*+NE5NzeJ(U3>wEOE#TIylf7Xx{i@z}_@b7n=Zo61Wwb=IO|dmgX;*x+ zc>n1<-V~*Y+P${W?Oso7#mmhhppnd5>`?ZZsc4DF7M6^sR~CA_vf}9isG@cewLO(I zuGroL-)LsCx$~i;N}94ZZFs>ePTF_WRygz1R9F)jOgt4 z0=LiSAWM){Y;PUOByt0Y2A8)tZ!wPbP~nBNM_VpLqjy<>M^6%g)5PkF!7Z|^Cqso> z5FS|tqtU#)z@zEU#dKNE@tmmD%28WX2{)O4ivEnCgAPG`qIPcF<=PpwZD^Nkn=kR2 z_qXVpX54<^yx-9n$_h}_dFWH09_F2_7FUF}iE45{k@ZVo)``Y%O@YTR;)_vxicBvf z$y>ZYR>+~4EnrK5$I72;=CibWZuBh9znw7)vaJe4vz0Zpos?}=Xy2=}jYcw{turwj zsA~QaK;gH|O2ML@XwS+Ezg0FS?TD{2oG|<>9$p**PQ>6x1KhEj6dw3u;E2le-oeQ~|gV{0OR>hl- z?6KdN_A1|hSC1(vI8JHx(KgJ(eh@?JFv-O%jun^oZ4{Tnr1_nHyKN6N$6Ft1cC!6x z>co920kVFz2=wua+o~-gDoRrc~GPDQ-WN^Cl;KS zY{%fe0VBt2Im`8CK`gD1No+0TSb53)opo@GRP*zp`0>vQFN+8Kv`(^6+;aw8c%-dX zpmM5QkLR~PsV@ugU6w?)_meAi1QS=)aR?>?ESd|R1PdO6{w_MgQ4dfLB|_n#>JR(ktev;XB^Qug;Um7i(< z%h9%H?f<`{?B8T4e;Vt9Y8~o-VM#sxukm`S^uuZWuZ{L<9V-81UaF^jt%Q2mes~HC zqqN{t%RU!C=(H4cHh(k2ds8@1$6=Jb>tAEC!DqufTFr9gU!B1PoGsWunX09yZzXj4 z>Rj2M)>5mLEQivfO&KLO!j{dV;1-lCy=7}MZFfV9GT9S^Sc&@N0`O}-F334RH<%`j zll4(1XklP)h;eiHKc6=zgL%Tk89blH|5+>_o)f;8WT#vfiX`eCNylj^f6EOHS-owq!S#Vmp@6IJ4+^bn7x)`}o>p?GJQVn9L)w;v&eD3A5awO^VLJ-o=lIvE| zj)cTQ-72}*>OYVAwS8x0W)c)w!79moXy;8j4QYtn;C46 ziL~N3@P!Vo*ulhT#p3+zw8BwSp^m1iOB2vK?$VenaeGIWfKLuEPJTWYU!9LXQDTlt zSwg%aIaNce#=Q}l;sjzJB(u&gQLdTD3F#SGqNkD9(|t;kDa>FXJ}Lu<3+vTY{7KxL zP|p0~@A{HS{E7c7uD8cU)-YpYWo|qf8b?MQmO*g->PP=VR-Q=H*n-)!D4uZN3D<{I zQ{KAg{qq;*91v^WW{|12J1}21FU8fHf6mB&l3rI+6t`^Q%)`xhC?m)c$H zQ2S-2P))P;|66$X$M(bZ?(?>-WJWcr80i}EC)?m9k&!jaTY2O$+6zFrzLf)PCZH5q z5f@4SG!`DCv?p5tg&`@EYb|aPe}4>o0}UXUwcm;m8yx=Bm!qnZZ3V$ExBv9r(te^j zDNd2BX%>Zk`uxMsvc9|YbEyajlMfxC>ejh~(0$-Nta z_W|z({uFo*@Gjupz%9W0fzL7apW}QJ@B!dv;KRV{fFWQpV85yJ$GQFs;A6lifX@TE z|0T|oN}qMDdilqvdG;yqxt@Kd?Am|7^SQDIDs!*}p|G2UU`Kh+ZbK-}&oY8IBN{;3 zi4#@JHuuF`*IFAVtU;ag*{IdLc{v5eW_+vAe2j-KC!ao<<;Z`-F_|DZm|0#F>RnCx zU4{B6L%;L^Yu6;&bsK#me9nvA@k~Zy5%m$fm&Ue$IuC)@R_7k-d|#=~=YTch;d)2; zHk}|LGmf)XR^!AHH{zToi~b`KNLzuF3o2R7>awZEP0|4^g;$Kj2<(8;Z40xX_R^Ch z^rvN!2@v)2vKyu4WQ>~&94`2xV*I({C>6aP+0z%&q90V?NV@)$P5+RVs8!A4E}Uu} zpWuxw`p>j%`sW0ddj`Lmwfv9q?#}=nY3-MLs@5U>OXb>8>wP`{Fz~C=i|OU#bE|QT zrTjnPH=il}ZaZm2b!&w$ZTn$v$<`{Pf-j{_dE0N*UqqHAy|d%LinVeJ9~I*)TJKas zYpMLJ&Dkp#644rl5N9P_kX9FdWp;ydp)CGfgYJ{BD$#3g^;7KO04R;F?qRK0-4z>WS(b z@I31EMf;?-*7*2MdsrIE*tVlXlF2Fv4x_)Y4j@UkT2d`1Ox1(+own6HU280{6xnO* za#||Knw(YcsIB3Gz(TwBrqGYm{z`>C{ybV0;fP8edBaoKjptxFo{btd1(!=NN>aMD zIC?r3yYbR0!Oi7rnZ4(@a96N&tn@!lDdkaf@zjyN@zvEI+V^>&VMGO!ylKKyagF_f z2R<|XkY7IY)J{tQuY1xh{QI&xydLQD?%Q{i?cEOlJG!?Ya3)ZGU(a+ja$oh|0BBbW z|92#ho&w0P=-=mZ^q4rIojI76r0PEk)2nqz|5(gR(%CiAwcgkBV}UICmqPz)9h5(c zVOh)n_sr#I^8bbU-#Pqd*7E;v=JGT7KkIJ)FDd`O0Ugb?`ef7SeE*3u2Pn|Vx4;eV z=s#v3>ZbnGA&ayYwItc2@+CiJYkxnE(IHr_7}*-U^0q&Y$;dz5v**v_krvK!H;kmI z7{kc!{zc;W8>1hIe8W{_T;fj{+Nm@sF6Q_yuK1HmJwweb{AWCi^Xp04fjlp^@_B*VyzAP#k0Qp`FI=B?T?xGf1qr7J*A%E zRP%TTZ7|DT{( z3(3P-+y9Te`&g-b80!}3Z!J9`Ml-_i6p2S9xl$|d<&ifi55rW%@OkisUbM+RuF^R| z^fZk(oEZ|k)uT&!r4MRLqArvqk-_LmJPxV+Y5Mo_h$HJt?UR{Fi9IsBV5Q*nR)*>d_zyeM)+xRkWsi>a^+B^VJ;3FE&lye;!5&%g&Oue90>JXDUC_`s2F&zh9v2Eb@n@aIHiAueao> z&)WV6c-QPN&9F(Es^yG|T9WEqedQ{dMK67tDU_dRvEAGL@5t8pxPYtow0zx4xoUok zFBJqsv_3|0(ChuDF=q}P4zl9N&X=QYtXsBOH7o*d~tk{h3 zvj$Z{5df=6rm%xMX1ly66uq0jz}0@AX!Kn5P||WsXr z+wLa|*w%;n@X}jdvnrSEuYEi0ugg)OhQion`972bLQxCxY*v<_A_z`==xdk7y+Qtt z_2?+#^wX1Zqel4? zXVkE}3v2j)v*~||EItd!s(<{LcTN9D)Bm*CuGTRY|L<@4(I-kjoL+u5{cj1srMBxR z{cP&#r#!u*^hSF5ne^WYujIE}>DkJEn)km~D&IG11;NEv|Nb8oDG~izx^qq~kB(|F z4q5NNjh|91Mb`HZ;$4UT&eWl`&D;2sM_C$$)_BWQnuEPk zQZ4n?|*dAoxm-aJGxsIp=hd?lcneaElI+&KD(R ziLkp_`kzlfyTZ(($@wE{Y2Cj6Ty=J<&s6iv_*JdHT+QdrQ0N^YWnM{(jV?d->3{l~ z=zhd?6c1EA=Euk6e8f+isXe}0Bg=Y^^TL&V^Go^9q75R5(CR+w*YRG_TK!W2KYl(7 zubjYlt_Kv;;lKZEuI=#e+dZAL-WM;HOV(U=T>->zu(IH@{1^zU^381 zxzFSKCju|X_&aCt-i1I{#`izTd!GXoU+dTNeWm+Ze}~sc5Br@x1~csGHc{H8JLa*| z;Q8;pPT?n`N7tc2sNFg#NitLG>^GI68`)wIwI)N7LUu}ij%@X66uo8`YQ=QD+IKndLZQgL&5Q^ zreB0cuf0F#@L!sxziwb2a)IWGNdl)PG>aV}{Xqgoz z0@5CuCs0G99a^^_{ql8y4*$Np(r!jkm&^>h#V`#OnM9BJjx%w~U@@G5?18IZO8ucrK4 zRX9g_`Q7fNl>cLC|3#Glk)wffXic)?>OJn;GaM=G#6L`Kkx#x0T_eg%8n+?)<4_qz z5Z~l#*NT70hvhU){+Q0Pq*}*V)%V;Q zFaMWMXUz7Y{MH+wd22$QR7t*r;P5X$uueMN-hiw;&jFqf90j}pI0iTlurV)+|Ib;d zd$GdEvhLQAN`ICOsEa$%>bF|)TfQfej^Ox7t}HoYZHtz>sy8C6sB9_uPutp7pLaTL z=*Y;OW3H9kM#vUt7-qO}g{sawd(j14^oH@;W2F&|&GA)?NYWBDWp0dbhSY_RNxQHd zLXFE8K~%o&xAFARHZI3TbqtR4Gg5$odD6`P=~np}P5CrN&z#3aIT5HE1!FdlVuHB;P`Uo*cx zr;TfUE}-W&jrN!*vtO^Sz&*G6&F?#VQ3UeQW_-85;sN-zeYTby zNK5ju1DnN%WNS&K1S<(5lF+SvC(%AX7NmXo1Fd~Y6me1FQeSJs3u(iRC2SjO3}*d4 zycwZ6b?X(lL((UIe@tcnR<_K;y00jF$uQ3{3^51G3V{QX&aad*O&PzXCV|*aBP* zTn$_cTnF3$+z7lA_!DTr^}suTcLIL~yc>8g@P6O}zz2a31Ah*D6u1TWIPgi})4;93 zXMx**&jDWm{u=l)a69l7;A_CwfjfXZfxCdafqQ^^fqw+P1>6sO8+ZtK7sR{3q~B;Mc%^0lx$O0Q?W|N8o8-CoqAr+5^}N*az4T zcouK~a3Js;;1J-s!1I9T14jTy0WSoO295!a16~Zg3^*B>3`_y00@Hz+z-(YHa4K** za0W0Bm=7!f76NAhX9MQ|OM!ENWx)Bs1;DF;0pKEF1+WTO4Xgz=02_fVz&2nA7y)(w zmjhP54Z`q8Tb(J5#Xc1$ADV^vx5j5 zr=Srj*o$iuz{{w@GncxOF3GLZN@m`IeR~RyX49UGnL0qPj4Fs-d|7sYwff#YwL+u91&}YW|GN2)#bam<+Yc- zS&c=gtL-}+r}-adX7vA@OMkq&)F+&39$O%;(gSs*moKR%{TPe?NqbO9Kh=?5{%rSB z%72xAA`45+_(#w}bmwt?;{Z~-_Bc-2hzs^v7&iLA0l1>!gv(#vf zqJlfSK(r_JI7$CI4?3sXIL?qI3%umQNJ>olRGF?yw)D%O!?LRn@xM}9I}mBD2i$NQ zI?fxTyy};H4fI>sD_-VeSFfgoE!g@e!PT5(wl>^0cmz(jo=@73$)rc=YSPl0Tc7#V zMJcD&q48y@i+rB({U2Qmv$m}$mZEC>*Jb)-%)a4TjH{q5&8nMW zXY+osIr2g?>yxg3$ikd{NdM^PmGgnD`p*jVk8JB7rll9o)3NA3gOq<;>6g>nFD{jS zsQmMIWjTX#KaX|LTS!DL%&eUV2N? zx?BCO_4}s9-TUgh52l))#VENeZXWmgcT-1Ozjk&Qo3w^#AVrtBOh(bV_9Jfp_meP@ zr?#Qd%!?myu>Fm4n`UypS`yr|M&*TOmfE + + Local + 8.0.50727 + 2.0 + {438A9556-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim + JScript + Grid + IE50 + false + Exe + + OpenSim + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + ..\bin\libsecondlife.dll + False + + + ..\bin\Axiom.MathLib.dll + False + + + ..\bin\Db4objects.Db4o.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Physics.Manager + {8BE16150-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Servers + {8BB20F0A-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.RegionServer + {632E1BFD-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + + + + + + + + diff --git a/OpenSim/OpenSim.csproj.user b/OpenSim/OpenSim.csproj.user new file mode 100644 index 0000000000..88e11f7253 --- /dev/null +++ b/OpenSim/OpenSim.csproj.user @@ -0,0 +1,13 @@ + + + Debug + AnyCPU + -loginserver -sandbox -accounts + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim/OpenSim.exe.build b/OpenSim/OpenSim.exe.build new file mode 100644 index 0000000000..54b7a3b64d --- /dev/null +++ b/OpenSim/OpenSim.exe.build @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenUser.Config/UserConfigDb4o/AssemblyInfo.cs b/OpenUser.Config/UserConfigDb4o/AssemblyInfo.cs new file mode 100644 index 0000000000..56a5535d5d --- /dev/null +++ b/OpenUser.Config/UserConfigDb4o/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("UserConfig")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("UserConfig")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenUser.Config/UserConfigDb4o/DbUserConfig.cs b/OpenUser.Config/UserConfigDb4o/DbUserConfig.cs new file mode 100644 index 0000000000..f18e373b07 --- /dev/null +++ b/OpenUser.Config/UserConfigDb4o/DbUserConfig.cs @@ -0,0 +1,95 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using Db4objects.Db4o; + +namespace OpenUser.Config.UserConfigDb4o +{ + public class Db4oConfigPlugin: IUserConfig + { + public UserConfig GetConfigObject() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Loading Db40Config dll"); + return ( new DbUserConfig()); + } + } + + public class DbUserConfig : UserConfig + { + private IObjectContainer db; + + public void LoadDefaults() { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); + + this.DefaultStartupMsg = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default startup message [Welcome to OGS]: ", "Welcome to OGS"); + + this.GridServerURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid server URL: "); + this.GridSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to grid server: "); + this.GridRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from grid server: "); + } + + public override void InitConfig() { + try { + db = Db4oFactory.OpenFile("openuser.yap"); + IObjectSet result = db.Get(typeof(DbUserConfig)); + if(result.Count==1) { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Found a UserConfig object in the local database, loading"); + foreach (DbUserConfig cfg in result) { + this.GridServerURL=cfg.GridServerURL; + this.GridSendKey=cfg.GridSendKey; + this.GridRecvKey=cfg.GridRecvKey; + this.DefaultStartupMsg=cfg.DefaultStartupMsg; + } + } else { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); + LoadDefaults(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Writing out default settings to local database"); + db.Set(this); + db.Close(); + } + } catch(Exception e) { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); + } + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("User settings loaded:"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Default startup message: " + this.DefaultStartupMsg); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid server URL: " + this.GridServerURL); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to send to grid: " + this.GridSendKey); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Key to expect from sims: " + this.GridRecvKey); + } + + + public void Shutdown() { + db.Close(); + } + } + +} diff --git a/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.csproj b/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.csproj new file mode 100644 index 0000000000..8c4fd39a6f --- /dev/null +++ b/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.csproj @@ -0,0 +1,111 @@ + + + Local + 8.0.50727 + 2.0 + {7E494328-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenUser.Config.UserConfigDb4o + JScript + Grid + IE50 + false + Library + + OpenUser.Config.UserConfigDb4o + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + ..\..\bin\System.Data.dll + False + + + System.Xml.dll + False + + + ..\..\bin\libsecondlife.dll + False + + + ..\..\bin\Db4objects.Db4o.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + + + + + + + + diff --git a/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.csproj.user b/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.csproj.user new file mode 100644 index 0000000000..90c1e94b3a --- /dev/null +++ b/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim02-04\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.dll.build b/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.dll.build new file mode 100644 index 0000000000..0abcfa125c --- /dev/null +++ b/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.dll.build @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Prebuild/Prebuild.build b/Prebuild/Prebuild.build new file mode 100644 index 0000000000..743b8263b6 --- /dev/null +++ b/Prebuild/Prebuild.build @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Prebuild/Prebuild.sln b/Prebuild/Prebuild.sln new file mode 100644 index 0000000000..449896b4ee --- /dev/null +++ b/Prebuild/Prebuild.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prebuild", "src\Prebuild.csproj", "{92E80C1C-0000-0000-0000-000000000000}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {92E80C1C-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92E80C1C-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92E80C1C-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92E80C1C-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Prebuild/README b/Prebuild/README new file mode 100644 index 0000000000..eca6be17e2 --- /dev/null +++ b/Prebuild/README @@ -0,0 +1,230 @@ +Prebuild Instructions + +Prebuild is an XML-driven pre-build tool allowing developers to easily generate project or make files for major IDE's and .NET development tools including: Visual Studio 2005, Visual Studio 2003, Visual Studio 2002, SharpDevelop, SharpDevelop2, MonoDevelop, and NAnt. + +_________________________________________________________________________________ +Overview + +Prebuild can be either be run from the command line to generate the project and make files or you can execute the included batch (*.bat) and Unix Shell script (*.sh) files. +The Prebuild file + +_________________________________________________________________________________ +The currently supported developement tools and their associated batch and shell script files. + +Visual Studio .NET 2005 (VS2005.bat) +Visual Studio .NET 2003 (VS2003.bat) +Visual Studio .NET 2002 (VS2002.bat) +SharpDevelop (SharpDevelop.bat) - http://www.icsharpcode.net/OpenSource/SD/ +SharpDevelop2 (SharpDevelop.bat) - http://www.icsharpcode.net/OpenSource/SD/ +MonoDevelop (MonoDevelop.sh) - http://www.monodevelop.com/ +NAnt (nant.sh and nant.bat) - http://nant.sourceforge.net/ +Autotools (autotools.bat and autotools.sh) http://www.gnu.org. Only partial support + +Notes: +A Unix Shell script is provided for MonoDevelop, as this is more appropriate than a windows batch file. +Visual Studio .NET 2005 and the Visual Express IDE's can import solutions from older versions of Visual Studio .NET. +Makefiles are not currently supported. + +_________________________________________________________________________________ +Command Line Syntax: + +Example: +>Prebuild /target vs2003 + +This will generate the project files for Visual Studio.NET 2003 and place the redirect the log to a file named PrebuildLog.txt in the parent directory + + +The syntax structure is as below, where commandParameter is optional depending on the command and you can provide several option-value pairs. +Note: The '>' signified the command line, do not actually enter this manually + +>Prebuild /